Error
The xSwap platform, like all sophisticated decentralized finance (DeFi) systems, incorporates various smart contracts that are meticulously designed to facilitate seamless and secure transactions. However, users and developers might encounter specific errors while interacting with the xSwap protocol. This documentation aims to elucidate some of the common error codes, providing context and solutions to enhance the user experience on xSwap.
Common xSwap Error Codes
xSwap: K
This error is tied to the foundational constant product formula X * Y = K
, where "X" and "Y" denote the reserves of two ERC-20 tokens, and "K" is the product of these reserves. The "K" error indicates a trade that would result in an imbalance in the reserves, violating the constant product rule, leading to transaction reversion.
Causes and Solutions:
Fee On Transfer Tokens: Some tokens apply a transaction fee that alters the final amount transferred. This can cause discrepancies with expected reserve balances.
Inclusive Fee On Transfer Tokens: Use swap functions ending with “SupportingFeeOnTransfer” to adjust for the fee within the transaction parameters.
Exclusive Fee On Transfer Tokens: These tokens may necessitate a customized router contract to accommodate their unique fee structure.
Rebasing Tokens: Tokens that can change balance independently of user transactions can disrupt the constant product formula.
Negative Rebasing: May lead to reduced token balances in the pool. Solution involves syncing the pool after each rebase to maintain balance.
Positive Rebasing: Can result in excess tokens within the pool. The
skim()
function can be utilized to correct this surplus.
xSwap: LOCKED
A security measure to prevent reentrancy attacks by blocking malicious contracts from embedding harmful code into transactions. This error may also arise due to local development environment issues, often remedied by restarting the local fork.
xSwap: TRANSFER_FAILED
Occurs when a token transfer cannot be completed, usually due to restrictions within the token contract itself, potentially indicating a non-compliant or malicious token.
xSwap: EXPIRED
Transactions that exceed a 20-minute execution window are automatically rejected to prevent outdated transactions from being processed at possibly unfavorable conditions.
Last updated