@horsefacts.eth
SLIPPAGE VS PRICE IMPACT
"I set 3% slippage and still got rekt on a swap. What happened?"
Price impact, slippage, and liquidity are three distinct concepts that are related and sometimes conflated. Here is a short explanation of each.
PRICE IMPACT
Price impact is how much your trade moves the market price. In an onchain exchange like Uniswap prices follow an algorithmic curve. Buying moves the price up this curve and selling moves it down.
How far any one trade moves the price depends on the total liquidity in the pool. If you buy or sell into an illiquid pool even a small swap can move the price a lot. And if the size of your trade is more than the available liquidity in the pool, you will get rekt.
Price impact is not unique to AMMs. The same thing happens if you buy or sell into a thin order book on an offchain exchange. If your trade chews through the order book you will move the mid-market price. How far the price moves depends on how deep the order book liquidity is.
SLIPPAGE
Slippage is the difference between what you expect to receive from a trade and what you actually receive when it executes onchain. Setting "max slippage" protects you if the price moves between time of quote and time of execution.
How can this happen? In the few seconds between when you see a swap quote and push the button to execute it, other trades may land onchain and move the market price. Again, if there is low liquidity, a few trades landing before yours can move the price a lot.
Setting 3% max slippage means "cancel the trade if I lose more than 3% on what you quoted." But it doesn't protect against the price impact of your own trade.
LIQUIDITY
Note that both of these concepts are related to liquidity. Liquidity is how much you can trade without moving the price. In an AMM more tokens in the pool means more liquidity. In an offchain exchange more orders in the book means more liquidity.
TO SUMMARIZE:
Price impact is about how much you move the price with your trade. Slippage is about how much other people move the price before your trade. Both are related to liquidity: less liquidity means small swaps move the price more.
WHAT DOES THIS MEAN FOR MY BAGS?
1. If you are swapping, always look at the quoted amount you receive before you swap. This is the most important number on the screen and is where you will see any potential price impact. If the amount you get back is much lower than the amount you are swapping, your trade has high price impact and you probably should not proceed.
2. If you are trying to buy or sell a token with a fast moving price or on an L1 with slow blocks, you may need to adjust slippage.
3. Always pay attention to available liquidity as it impacts 1 and 2. Brand new and obscure tokens are much more likely to have low liquidity. This is also why their prices are often more volatile. You can see liquidity under "Stats" on the token screen.