Understanding Price Impact and Price Slippage in Token Swaps
This section clarifies the concepts of price impact and price slippage within the context of token swaps facilitated by the API.
Price Impact
Price impact refers to the immediate difference in the execution price of a swap compared to the quoted price at the time the order is submitted. It arises due to the following factors:
Trade Size: Larger trade sizes can significantly affect the price within a liquidity pool, leading to a less favorable execution price compared to the quoted price.
Liquidity: Swapping tokens within a pool with low liquidity can cause a higher price impact. This is because there might not be enough sellers or buyers readily available to fulfill your order at the quoted price.
Price Slippage
Price slippage signifies the potential difference between the quoted price and the final execution price of a swap. It arises due to external market movements that occur between the time the order is submitted and the time it is executed. Unlike price impact, slippage is independent of the trade size itself.
Minimizing Negative Price Impact
The API offers mechanisms to minimize negative price impact:
Trade Size Optimization: ULDM allow splitting trades into smaller chunks and routing these across multiple liquidity pools, effectively reducing the impact on the pool's price.
Liquidity Checks: The API checks for pool liquidity before executing a swap, preventing trades with high price impact in illiquid pools. This is a configurable setting in the Integrators Portal.
Important Considerations
It's crucial to acknowledge that the API cannot entirely eliminate price impact, especially for illiquid token pairs.
Developers integrating the API should advise users to carefully review the estimated execution price before confirming a swap, considering both the quoted price and potential price slippage.
How is price impact calculated in our system?
This section explains how our DEX aggregator calculates price impact for both single-chain and cross-chain trades. We leverage USD as the standard unit for this calculation, offering several key benefits:
Universal Comparison: USD provides a consistent metric, simplifying the comparison of price impact across different trades, regardless of the specific cryptocurrencies involved.
User Familiarity: Expressing price impact in USD allows users to assess the potential effects on their portfolio in a familiar and stable currency, aiding in informed decision-making.
Cross-Chain Consistency: For cross-chain trades involving assets from different blockchains, USD eliminates the complexities of comparing diverse native tokens, ensuring a universal benchmark.
Financial Relevance: USD's widespread use as a reference point in finance allows users to seamlessly understand and compare the impact of cross-chain trades, fostering a more intuitive user experience.
Calculation Example:
Let's consider a trade where the input is 100 ETH, equivalent to $224,509.65 USD, and the expected output is 224,183.2629 USDT, approximately equal to $224,242.41 USD.
We calculate the price impact using the following formula:
Price Impact = 1 - (Expected Output / Input)
Substituting the values derived from the screenshot:
Price Impact = 1 - (224,242.41 USD / 224,509.65 USD)
Price Impact ≈ 0.00119032745
Expressed as a percentage, the price impact is approximately 0.119%.
In essence, using USD as the common denominator for price impact calculations enhances user experience, transparency, and accessibility across our DEX aggregator platform.
Prioritizing User Protection
Slippage Protection in the Quote API:
The Quote API offers built-in slippage protection for trades through the slippageProtectionPercentage
parameter. The default value is 0.5 (50%), but integrators can customize this based on their users' needs and risk tolerance.
Here's how it works:
Configurable Threshold: By adjusting the
slippageProtectionPercentage
parameter, integrators can ensure the Quote API only considers DEXs with valid slippage protection mechanisms.Accuracy and Risk Minimization: This approach helps maintain the accuracy of trade execution and minimizes the risk of slippage, reducing the difference between the expected and actual trade price for users.
This revised version uses more concise language and emphasizes the user's perspective. It also clarifies how the slippageProtectionPercentage
parameter functions within the Quote API.
Slippage Transparency: We clearly inform users about potential slippage through warnings and prompts. This empowers them to understand the risks and confirm their trades with full awareness.
Price Impact Protection in the Quote API:
The Quote API provides integrators with an additional layer of protection – price impact filtering. We strive to provide accurate results, so when we can calculate price impact estimates, the API filters out DEXs with invalid or unrealistic price impacts. This ensures users are presented with a list of DEXs that offer a more reliable execution experience.
Similar to slippage protection, integrators can customize the threshold for price impact filtering using the priceImpactProtectionPercentage
parameter. This allows them to tailor the API's behavior to their specific needs and risk tolerance.
Last updated