cryptonist
Fibre optic strands gathered into a bundle, their ends lit

DeFi

What slippage is, and what a slippage setting protects

Slippage is the difference between the price a trade was expected to get and the price it actually got. Part of it is price impact, which a trade causes by its own size and which can be calculated before signing; the rest is whatever moves the market between the quote and the moment of execution. A slippage tolerance improves neither. It sets the worst result the trade will accept, which also makes it the room left to anyone placed to make the result worse.

Two numbers that are easy to merge

Uniswap’s glossary separates them. Price impact is the difference between the mid-price and the execution price caused by the trade’s size relative to the pool’s liquidity, an expected result of the formula an automated market maker prices by. Slippage is the total difference between the expected price when the transaction is submitted and the price at execution, which may include price impact and any other movement before the transaction is mined.

A quote already contains the price impact, and the tolerance is applied to the quote, not to the mid-price. Uniswap’s version 2 software development kit is one example: it describes its tolerance as unfavourable slippage from the trade’s execution price, and computes the minimum by dividing the quoted output by one plus the tolerance. An illustration with invented numbers, fees left out: a pool’s mid-price is 5 units of token B for each unit of token A. A trade of 1,000 A would be worth 5,000 B at that price, but the quote, which reads the pool’s reserves, shows 4,950 B, because the trade moves the price against itself by about 1%. With a tolerance of 0.5%, the minimum written into the transaction is 4,950 ÷ 1.005, or about 4,925.37 B. Measured from the mid-price, the trade has agreed to accept a result about 1.5% worse, three times the figure on the setting.

So the two numbers answer different questions. Price impact says how large the trade is against the depth it trades into, and it can be read off the pool before anyone else acts. The tolerance says how much further the result may drift after the quote, for any reason, before the trade refuses to go through.

On an order book: walking the levels

An order book produces the same effect by a different route. The documentation of Hyperliquid, a venue whose order book runs on its own chain, gives the standard definitions: a market order executes immediately at the current market price, a limit order executes at the selected limit price or better, and orders are matched in price-time priority. A market order larger than the quantity at the best price fills the next level, and the next, which is what the exchange liquidity piece means by depth at the size you trade.

An illustration with invented numbers. The sell side of a book shows:

PriceQuantity
100.002
100.503
101.205
102.0010

A market order to buy 8 takes 2 at 100.00, 3 at 100.50 and 3 at 101.20, for 805.10 in total, an average of 100.64, which is 0.64% above the best price on the screen. Suppose another buyer takes the first level a moment earlier. The same order then fills 3 at 100.50 and 5 at 101.20, for 807.50, an average of 100.94. No price on the book changed; one level disappeared, and the order paid 0.30 more per unit for it.

A limit order is the order book’s version of a slippage bound, with one difference. In the same illustration, a limit to buy 8 at 100.60 takes the 5 available at or below that price, at an average of 100.30, and leaves the other 3 resting on the book unfilled. The price is protected and the size is not. A swap through Uniswap’s version 2 router works the other way round: as shown below, it either delivers at least the minimum for the whole amount or reverts.

Orders that trigger later carry the same trade-off. Hyperliquid’s page on take-profit and stop-loss orders says that when such an order is a market order it has a slippage tolerance of 10%, and that a limit price lets the user set the tolerance instead. Its own example is a stop-loss on a long position, triggered at $10 with a limit of $10: if the price falls from $11 to $9 at once, the order is quite likely to rest at $10 unfilled, whereas with a limit of $8 it is likely to fill somewhere between $9 and $8. A tighter limit risks no fill, a looser one a worse fill; perpetual futures explained covers the margin and liquidation rules of the positions such orders close. The order types page gives large orders another route: a TWAP order splits one into smaller suborders sent at intervals, each limited to a maximum slippage of 3%.

Why a quote moves before the trade lands

On a decentralised exchange the quote is computed from the pool’s state as the interface last read it, and the trade executes against the state at the moment it is included. Ethereum.org’s page on blocks says a validator is chosen to propose a block in every slot, twelve seconds apart, and that it bundles transactions and executes them. Until then a signed transaction waits, as the transactions page puts it, in a pool of all other pending network transactions.

Three things can happen in that gap. Other traders’ swaps in the same pool can be placed ahead of it. Prices can move elsewhere, and arbitrageurs bring the pool into line before the swap runs. Or someone can see the pending swap and trade around it on purpose, buying just before and selling just after, which what MEV is works through with numbers. The longer the wait, the more room for all three, and a transaction sent with too low a fee can wait a long time, for reasons what gas is and stuck crypto transactions explain.

Uniswap’s API documentation treats the quote as perishable. It recommends refreshing quotes more than 30 seconds old before broadcasting, and using a deadline to stop a stale quote from executing, and it notes that even a simulated swap can fail on-chain because gas and slippage may change in between. The movement need not be adverse. An exact-input swap receives whatever the pool pays at execution, so a move in the trader’s favour means more output than quoted; the same page says Uniswap Labs never takes positive slippage and that price improvement at execution goes to the swapper.

What the setting writes into the transaction

The tolerance becomes a number in the transaction’s data. In Uniswap’s version 2 router, swapExactTokensForTokens takes an amountOutMin and reverts with INSUFFICIENT_OUTPUT_AMOUNT if the amount at the end of the route falls short. Its mirror image, swapTokensForExactTokens, fixes the amount out and takes an amountInMax, reverting with EXCESSIVE_INPUT_AMOUNT if the trade would cost more. Both carry a deadline, checked against the block’s timestamp. Uniswap’s archived error guide describes the expiry error as a transaction that took too long to be broadcast, and says a swap that takes more than 20 minutes to execute will not go through. In the router’s code the deadline is a parameter of each transaction, so the 20 minutes is the guide’s figure, not a constant in the contract.

Version 3 keeps the pattern. Its router interface names the fields amountOutMinimum and amountInMaximum, and adds sqrtPriceLimitX96, which the pool interface describes as a price the pool may not pass by the end of the swap.

An illustration for the exact-output case, invented numbers again. A trader wants exactly 5,000 B, and the quote says it will cost 1,010.10 A. With a 0.5% tolerance, applied as the same software kit applies it to an input, the transaction allows up to 1,010.10 × 1.005 = 1,015.15 A. Here the setting caps what is paid rather than what is received.

Two details in the version 2 code are easy to miss. The minimum is checked only against the final amount of a multi-hop route, so one tolerance covers every pool the trade passes through, and each pool adds its own price impact. For illustration, two hops that each cost about 1% compound to 1 − 0.99 × 0.99, or about 1.99%, before the tolerance is applied. And a failed check is not free: on Ethereum a reverted swap still pays for the gas it used, which what gas is prices out. A tolerance too tight for the market costs fees for nothing, and one too loose hands its whole width to whoever can trade around the swap. Uniswap’s API documentation, written for developers who build on its swapping API, addresses the setting directly. It recommends the API’s automatic slippage option first; for developers who set their own, it recommends a low slippage for swaps between two stablecoins, giving 20 basis points as an example, and a higher one for pairs with more price volatility. That is Uniswap’s guidance for its own API, not a figure this piece puts forward for any trade.

When a swap needs a wide tolerance

Sometimes the setting has to be wide for reasons that have nothing to do with the market. Uniswap’s error guide describes fee-on-transfer tokens, which burn or divert a portion of every transfer so that the recipient ends up with less than the sender gave. The router has a separate set of functions for them, and the code checks the minimum against what the recipient’s balance actually gained. For illustration, a token that keeps 5% of each transfer fails any swap whose tolerance is narrower than that cut, unless the quote has already allowed for it. The same guide warns of tokens whose transfers simply fail, most likely, it says, a scam token whose owner has disabled transfers so that users can buy it but not sell it.

The second is the honeypot that rug pulls explained describes, and the first can turn into one: that piece notes that a contract can reach the same result with a sale fee its owner is able to raise to the whole amount. A token that sells only with a tolerance of many per cent is saying something about its transfer code. Widening the setting lets the token’s cut through, and it widens the room for anyone sandwiching the trade by exactly as much.

Contracts that trade face the same requirement as people do. A vault or treasury that swaps without a minimum accepts whatever the pool pays at the moment it runs. As of 22 November 2026, per DefiLlama, the hacks record holds one incident with the technique Missing Slippage Check: YO Protocol, in January 2026, $3.6M, classed as Protocol Logic. The record does not describe how the loss happened.

What to read on a swap screen

Five things on a typical swap screen decide what the trade can cost, and only one of them is the tolerance.

  1. Price impact. The trade’s size against the depth it trades into. The tolerance does not cover it, because it is already in the quote.
  2. Minimum received, or maximum sent. The figure actually written into the transaction. Compare it with the mid-price, not only with the quote.
  3. The route. Each hop adds its own impact, and the minimum is checked only at the end.
  4. The deadline. How long the signed transaction remains valid if it is not included.
  5. The token. Whether it takes a fee on transfer, which no tolerance can tell apart from ordinary price movement.

On a centralised exchange, price impact starts with the spread: even the smallest market order buys at the ask, above the mid-price, and the exchange fees piece explains why that cost appears on no fee schedule. Slippage appears on none either. It shows up only as the difference between the number on the screen and the number that reaches the wallet.