How a Swap Works
Unlike a traditional exchange where you trade with another individual’s specific “buy” or “sell” order, a swap on Koan Protocol interacts with an Automated Market Maker (AMM). Our AMM is powered by liquidity pools, which are smart contracts containing reserves of two or more tokens. When you swap, you are essentially trading your token with this pool. In a single, atomic transaction:- Your token is added to the pool.
- Your desired token is pulled from the pool.
- The price of the tokens in the pool is instantly and algorithmically recalculated based on the new ratio.
Price Impact & Slippage
When you swap on any DEX, two key factors can influence the final amount of tokens you receive: Price Impact and Slippage. We believe in full transparency, so let’s break down what they mean.Price Impact
Price impact is the change in a token’s price directly caused by your trade. Think of it this way:- Low Price Impact: You want to swap a small amount of KOAN for USDC in a pool with millions in liquidity. Your trade is a tiny ripple in a very deep pool. The price of KOAN barely moves, and you get a price very close to what you expected.
- High Price Impact: You want to swap a large amount of KOAN for USDC in a pool with low liquidity. Your trade is a big splash in a shallow pond. Your action significantly changes the ratio of assets in the pool, causing the price to shift and resulting in you receiving fewer USDC than you initially anticipated.
Slippage - The Volatility Tax
Slippage is the difference between the price you see when you submit your transaction and the price at which the transaction is actually executed. This happens when the price of an asset changes between the moment you click “swap” and the moment the transaction is confirmed on the blockchain.- Positive Slippage: The price moves in your favor, and you get more tokens than you expected.
- Negative Slippage: The price moves against you, and you get fewer tokens than you expected. You can set a Slippage Tolerance—a percentage you are willing to accept for a trade. If the price moves outside of this tolerance while the transaction is pending, the transaction will automatically fail, and you won’t be charged the gas fee.
Built-in Safety Checks
Our protocol includes robust safety features to protect you from unexpected price changes and failed transactions.- Transaction Expiration: Every swap is given a deadline. If the transaction remains unconfirmed after this time, it will be automatically canceled. This protects you from having a swap execute at a drastically different price hours after you submitted it.
- Insufficient Output Amount: This check ensures your swap will only succeed if the final amount of tokens you receive is within your specified slippage tolerance. If the price moves against you too much, the transaction will fail, protecting your funds.