We hear about slippage all the time, but what is slippage anyway? Is it enough to know that high slippage is bad and low slippage is good? Maybe.
Here’s some intuitive explanation on what is slippage and how to minimize them:
- Slippage refers to the difference between the amount of tokens you should initially receive estimated by the Automated Market Maker (“AMM”) / price oracle, and the actual amount of tokens you actually receive when the transaction is completed. For example 10% slippage means if you were estimated to receive 100 tokens based on current market price, you may end up with 91 tokens, at the very least, in your wallet. As such, slippage is calculated by dividing the dollar amount of slippage by the difference between the price estimated by the oracle and the worst execution price. The dollar amount of slippage should be a number that is between the price estimated by oracle and the worst execution price
What causes slippage?
- Blockchain processing time: The fact that transactions in AMM are executed on-chain, it means when we click the ‘Swap’ button to swap Token A for Token B, it does not immediately happen. The price difference between the time we click the button to when the token actually arrived in our wallet is what is referred to as slippage. An example of how it might happen is, imagine completing a swap when at the same time there’s another person swapping a huge amount of token which caused quite significant imbalance in the pool. As price of token A is defined in terms of the ratio of supply between Token A and Token B, if there is someone ahead of you who swap a huge amount of Token A for Token B, there will be significantly less Token B in the pool by the time your transaction executes, which means, if you were buying Token B, it could be priced at significantly higher price when the transaction executes compared to when you first click the ‘Swap’ button. It could be advantageous or disadvantageous to you depending on which side of the trade you are on
- Thin liquidity: Imagine an extremely illiquid pool that only has 5 Token A and 3 Token B. This means, the price of 1 Token A in terms of Token B is 3/5= 0.60. If I want to buy 1 Token A from this pool (which is a significant % compared to the size of the pool), I would remove 1 Token A from the pool and add 0.8 Token B into the pool. Now suppose there’s another transaction immediately after mine — their implied price for Token A would then be 3.8 / 4.0 = 0.94, which is very sizeable difference to the initial price 0.60. If my transaction executes first, this person’s slippage could be up to 0.94, unless he specifically specifies his maximum acceptable slippage rate
- The bonding curve: Do all AMMs have slippage? Not really. But for most AMMs, like Uniswap and Sushiswap, there is a slippage due to the liquidity pool model employed by these protocol, which is referred to as the Constant Product Model. Note that pools that have model such as Constant Sum Model is a zero slippage model but this model is hardly used in reality as it can be easily drained out by traders
- A little bit on how this model works: assume we have 2 tokens i.e. Token A and Token B. The price curve is defined as q(A)*q(B) = K, in which q(A) and q(B) are quantities of respective Token A and B, and K is constant variable (only changed when liquidity is being added or removed from the pool). The resulting price curve is a convex-shaped negative correlation between Token A and Token B shown in the box below. This means, at a very low balance of Token A, to purchase another unit of Token A will require a huge amount of Token B, and the opposite is also true. The area shaded in green below shows the area in which ‘slippage’ is at the lowest
- Intuitively, we can work out from the diagrams above that to reduce slippage as much as possible, we need to have sufficient liquidity in terms of Token A and Token B. As such, a single transaction does not push us along the curve to the top or to the bottom, where slippage is at the steepest
How to reduce slippage
- Set a higher gas limit: This is to ensure that your transaction gets executed faster and does not get stuck /pending for hours. You don’t have to overdo it, but at least you should match your gas with current suggested gas limit
- Trade only in pools with high liquidity
- Use L2: As blockchain processing time is much lower in L2, slippage is also lower if you trade in L2 chains instead of L1. For example, Arbitrum is a rollup solution to Ethereum, so transaction speed at Arbitrum happens almost instantly as they happen offchain, and is periodically settled in batches with Ethereum network onchain. This means Arbitrum does not rely on Ethereum onchain speed to process their transaction
- Consider splitting huge transactions into smaller chunks: This strategy would need to be considered in conjuction with the extra gas fees that you need to pay to execute a separate transaction. When gwei is low, this may be a cheaper method
- Always remember to set your slippage tolerance rate to the level that is comfortable for you, and to the level that is reasonable to get the transaction executed. Remember that if you set your slippage too low, your transaction will not execute if you are trading during peak times as it keeps falling outside of the range you specified, but if you adjust it too high, you will be paying more for the tokens than you intended. Important to note as well that failed transactions cost gas, so be very sure to adjust your slippage tolerance accordingly