What is slippage in a DEX swap, and why does it happen?
Slippage is the difference between the expected price of a swap and the price at which the swap actually executes. It happens because prices on a decentralized exchange (DEX) change continuously as trades are submitted, and your transaction takes time to be mined.
How a DEX sets a price at any moment
A DEX like MilkshakeSwap does not have an order book. Instead, it uses a mathematical formula - typically the constant product formula - to determine the price of every swap. The price you see on screen is calculated from the current ratio of tokens in the liquidity pool. That ratio is valid only for the exact moment the data is fetched.
When you press "Swap," your transaction is broadcast to the network. It enters a queue of pending transactions (the mempool). Other transactions - swaps, adds, removes - can be inserted ahead of yours, changing the pool ratio and therefore the price before your trade executes.
The two components of slippage
Slippage has two causes:
-
Price impact - Your own trade moves the price. A large swap relative to pool liquidity consumes a bigger share of one token, making the effective price worse than the quoted price. This is deterministic and can be calculated before you send the transaction.
-
External price movement - Other trades that execute before yours in the same block push the price in either direction. This is unpredictable. It depends on network congestion, the speed of your chosen gas price, and what other market participants are doing.
The slippage you set as a tolerance (e.g., 0.5% or 1%) is the maximum combined change you will accept from these two sources. If the final price deviates more than your tolerance, the swap reverts - it fails and you pay the gas fee anyway.
Why a swap fails due to slippage
When you submit a swap, the smart contract checks the pool ratio at the moment of execution. It compares that ratio to the one you approved. If the deviation exceeds your slippage tolerance, the contract throws an error and no tokens are exchanged. This is a safety mechanism. Without it, a DEX could execute your trade at any price, and you would lose funds to front-running or sudden volatility.
A swap can also fail because the pool changed too much before your transaction was included in a block. Common reasons:
- You set a low gas price, so miners prioritize other transactions ahead of yours.
- A large trade lands in the same block and drains the pool depth.
- The token you are swapping has low liquidity, so even a small external trade creates a large price swing.
How to choose a slippage tolerance
There is no one-size-fits-all number. Each trade is different.
- High-liquidity pairs (e.g., USDC - ETH on a major chain): 0.1% to 0.5% is usually safe. Price impact is minimal, and external movement is small in a single block.
- Low-liquidity pairs (e.g., an obscure token paired with WETH): You may need 1% to 5% or more. The same dollar amount has a larger price impact, and any external trade can move the price significantly.
- Volatile market conditions: If the price of the token is moving fast, a higher tolerance prevents frequent failures. But a very high tolerance (e.g., 10% on a stable pair) exposes you to being front-run by bots that sandwich your trade.
A practical approach: Start with the default the interface suggests (often 0.5% - 1%). If your swap fails repeatedly, increase the tolerance in small steps. If you are swapping a large amount, check the estimated price impact displayed by the DEX - that number alone already exceeds your tolerance? Then you need to either accept a higher tolerance or split the order.
Slippage and DEX aggregators
A DEX aggregator like those built into some swap interfaces may reduce slippage by splitting your order across multiple pools. The aggregate price is better than any single pool, but the same slippage rules apply to each fragment. The aggregator calculates a combined tolerance, and if any leg of the route fails due to slippage, the entire swap can revert.
What slippage is not
Slippage is not the fee you pay to the protocol or to liquidity providers. Those fees (e.g., 0.3% on Uniswap V2) are deducted from the amount you receive and are separate from slippage. Slippage is also not the same as "price impact" - price impact is the part of slippage caused by your own trade, while slippage includes all movement.
Summary
Slippage exists because DEXs do not guarantee a price. They guarantee a mechanism: you get whatever the pool ratio is at the moment your transaction executes, within a limit you set. That limit - your slippage tolerance - is your protection against paying more than you intended. Set it too tight and your swap fails; set it too loose and you risk a bad execution. The right setting depends on the pair, the trade size, and current network conditions.
Not financial advice. milkshakeswap.finance publishes market data and general information about MilkshakeSwap Token. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.
Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.