Slippage is the difference between the price you expect when you submit a trade and the price it actually executes at. It happens because the price moves between quote and fill, or because your order is big enough to use up the best available prices. On a decentralized exchange, the slippage tolerance you set is the largest gap you will accept before the swap fails. A tight tolerance means more failed swaps. A loose one gives a sandwich attacker more room to profit at your expense.
The formula
Slippage (%) = (executed price − expected price) ÷ expected price × 100
- On a buy, a positive result means you paid more than expected (unfavourable). A negative result means you paid less.
- On a sell, the signs flip: a negative result means you received less than expected.
Example: you expect to buy at 100.00 and the fill comes back at 100.40. Slippage is (100.40 − 100.00) ÷ 100.00 × 100 = 0.40%. With a 0.5% tolerance that trade goes through. At 101.00, slippage is 1.00% and a 0.5% tolerance rejects it.
Where slippage comes from
Order books: walking the book
A market order fills against resting orders, best price first. According to the SEC's investor education material, a market order guarantees execution but not the execution price. The SEC's Fast Answers page adds that in fast-moving markets the fill often deviates from the last-traded price or real-time quote.
A hypothetical illustration: the ask side shows 1 BTC at 60,000, 1 BTC at 60,030 and 1 BTC at 60,090. A market buy for 3 BTC takes all three levels, for an average price of 60,040. Against the 60,000 best ask, that is 0.067% slippage, and all of it comes from order size, not from the market moving. Thin books, meaning few orders near the best price, make this effect larger.
AMM pools: trade size against the reserves
Many decentralized exchanges use an automated market maker (AMM) instead of an order book. In a constant product market maker, the pool keeps the product of its two reserves, x × y, constant during swaps (Zhou et al., 2020). Every unit you buy makes the next unit more expensive.
Ignoring fees, the arithmetic works out neatly. If you pay in an amount Δy against a reserve y, your average price is the spot price × (1 + Δy ÷ y). Your premium over spot roughly equals your trade's share of the input reserve. In a hypothetical pool of 1,000 TKN and 2,000,000 USDC (spot price 2,000):
| You pay in | Share of USDC reserve | TKN received | Average price | Premium over spot |
|---|---|---|---|---|
| 10,000 USDC | 0.5% | 4.975 | 2,010 | 0.5% |
| 100,000 USDC | 5% | 47.619 | 2,100 | 5% |
This price impact is predictable before you trade. Anything beyond it comes from other transactions landing first: ordinary market movement, or a deliberate sandwich. Zhou et al. call the extra part "unexpected price slippage". Pools with other pricing curves or concentrated liquidity follow different math.
How far did your fill slip?
Enter the price you expected and the price your trade actually filled at to see the slippage as a percentage.
| Price you expected when you submitted the trade | Price the trade actually executed at | Slippage |
|---|---|---|
| 100 | 100.4 | 0.4 % |
| 100 | 101 | 1 % |
| 60,000 | 60,040 | 0.067 % |
- Both prices are your own inputs; the example values are the article's hypothetical illustrations, not market data.
- On a buy, a positive result means you paid more than expected; on a sell the signs flip, so a negative result means you received less than expected.
- Compare the result with your slippage tolerance: at a 0.5% tolerance, 0.40% goes through and 1.00% is rejected.
This is arithmetic on two prices only: it does not predict slippage before you trade, model pool price impact or fees, or show whether a sandwich attack caused the gap.
How slippage tolerance works
On an AMM swap, the tolerance becomes a floor on what you receive, or a ceiling on what you pay. If the price moves past it before your transaction is included in a block, the swap fails instead of filling. Two costs follow from that:
- A failed swap is not free. Zhou et al. note that a trade which fails still pays its transaction fees.
- Tight settings fail more often. In the paper's words, "the smaller the allowed slippage set by a trader, the more likely the trade fails", especially when volume is high.
Default tolerances differ between swap interfaces. In data from 2020, Zhou et al. reported 1% as the most common setting among the trades they studied. That is a dated observation about one venue, not a current benchmark.
Why a loose tolerance invites sandwich attacks
The ethereum.org documentation on maximal extractable value (MEV) describes the setup: a searcher "will watch the mempool for large DEX trades." The attack has three steps:
- The attacker buys the same asset just before your swap, which pushes the price up.
- Your swap executes at the worse price, still inside your tolerance.
- The attacker sells straight after you and keeps the difference.
The ethereum.org documentation says users who are sandwiched "face increased slippage and worse execution on their trades."
Your tolerance sets how much an attacker can take. Zhou et al. show the attacker's front-run is capped by the maximum amount that can be traded "without breaking" the victim's slippage protection. A looser tolerance raises that cap and with it the attacker's possible profit. Their 2020 measurements found a single adversarial trader could earn "over several thousand USD" a day from sandwiching on one DEX.
Large swaps are exposed twice. They have more price impact, which can push users to loosen their tolerance, and they are what searchers look for.
Ways to limit slippage
- Limit orders, where available. Per the SEC's investor material, a buy limit order executes only at the limit price or lower, and a sell limit only at the limit price or higher. The cost is that a limit order may never execute.
- Size against liquidity. Check order book depth, or your trade's share of the pool's reserves (the table above). Smaller orders or split orders meet less price impact, but each extra on-chain transaction pays its own fees.
- Set tolerance on purpose. Start from the price impact the interface shows and add a small buffer for normal movement. Don't raise the tolerance until a stuck swap goes through.
- Avoid the public mempool where your wallet allows it. The ethereum.org MEV page notes that traders trying to avoid frontrunning and sandwiching use private transaction routing through block builders. This changes who sees your transaction. It does not remove price impact.
- Be careful in volatile periods. Fast markets widen the gap between the quote and the fill on order books and on AMMs alike.
Limitations: the example figures are hypothetical, the AMM math leaves out fees and covers constant product pools only, and the sandwich data dates from 2020.