Slippage Tolerance
- Category
- Decentralised Finance
- Level
- Professional
Simple definition
The worst price you agree to accept before a swap is cancelled. Set it low and the trade may fail; set it high and you may be filled much worse than quoted.
Professional definition
A limit written into the swap transaction as a minimum output the contract must deliver, or the transaction reverts. It protects against the pool state changing between quote and execution, whether from ordinary flow or from a deliberate reordering of the block.
Technical definition
The parameter sets the minimum acceptable output, usually the quoted output times one minus the tolerance. It is a bound, not a target: anything between the quote and that bound executes silently, so the tolerance is also the maximum value an attacker can extract by trading around the order. Raising it to clear a failing transaction widens exactly the window a sandwich needs; failures themselves cost gas but not principal.
Academic definition
A user-specified lower bound on realised swap output, enforced atomically by the executing contract, which jointly caps execution risk from state drift and the surplus available to an adversarial transaction ordering.
Mechanism
An on-chain swap is quoted against a state that no longer exists by the time it executes, because other transactions land in between and the block builder decides the order. The tolerance converts that uncertainty into a hard floor: either the contract delivers at least the floor, or nothing happens. Everything above the floor is surplus the user has already agreed to give up.
In practice
- Who uses it
- Anyone sending a swap on a public chain, routers that set the parameter automatically, and desks writing execution policy for on-chain orders.
- Why it matters
- It is the only user-side control over how bad an on-chain fill may be, and the main defence against value being extracted around the order.
- Limitations
- It caps the loss but does not prevent it, and it cannot distinguish an honest price move from an engineered one. It does nothing about the fee or the price impact already in the quote.
Common mistakes
- Raising the tolerance until the transaction goes through.
- Using one default percentage for both a pegged pair and a thin token.
- Reading a reverted swap as a protocol failure rather than the limit working.
Examples
A swap is quoted at 9,871.6 output. With a tolerance of 0.5 percent the contract must deliver at least 9,822.2, so the worst acceptable fill is about 49.4 below the quote. With 5 percent it is about 493.6 below.
- quoted output = 9,871.6
- tolerance s = 0.5%
- alternative tolerance s = 5%
- floor at 0.5% = 9,871.6 x (1 - 0.005) = 9,822.24
- give-up at 0.5% = 9,871.6 - 9,822.24 = 49.36
- floor at 5% = 9,871.6 x (1 - 0.05) = 9,378.02
- give-up at 5% = 493.58
A fill anywhere above the floor is accepted without warning, so the floor is the figure to reason about, not the quote.
A swap in a thin pool reverts twice at 0.1 percent tolerance because other trades keep landing first. Raising the limit to 5 percent makes it succeed, and also makes a worse fill cheap for anyone who can order the block.
Mathematical foundation
Variables
| \Delta y_{\min} | Minimum output the contract must deliver or revert | token units |
| \widehat{\Delta y} | Output quoted against the pool state when the transaction was built | token units |
| s | Slippage tolerance set by the user | fraction |
Procedure
Compute the expected output from the pool state at build time, multiply by one minus the tolerance, and write the result into the transaction as the minimum output. At execution the contract compares the real output with that floor and reverts if it falls short, which costs the gas spent but leaves the balance untouched.
Worked example
- quoted output = 9,871.6 units
- s = 0.005
- 1 - s = 0.995
- 9,871.6 x 0.995 = 9,822.24
Interpretation
The number is a worst case the user has authorised in advance, not an expected outcome. Treating it as the planned price is the right way to size a trade, because any fill between the floor and the quote is accepted without notice.
Assumptions
- The limit is enforced on the output amount by the swap contract itself. Some routers instead express it as a maximum input for an exact-output swap, which is the same bound written the other way round.
- The quote is taken from the pool state at build time; a stale quote makes the floor stale too.
- The bound caps the loss per transaction but says nothing about how often the fill lands near the floor rather than near the quote.
- It offers no protection against the fee and price impact already contained in the quote, nor against a malicious token contract.
- Protocol front ends choose different defaults and some adjust them automatically, so a quoted default is not a standard.
Related terminology
- parent
- Slippage
- related
- Slippage Swap Sandwich Attack Maximal Extractable Value Constant Product Formula Decentralised Exchange Execution Quality Mempool
Slippage
Slippage is the outcome: the gap between expected and realised price. Tolerance is the limit the user sets on how large that gap may be.
Sources
IOSCO · recommendations on order handling and conflicts in DeFi trading
https://www.iosco.org/library/pubdocs/pdf/ioscopd754.pdf URL verified
BIS Quarterly Review · 2021-12 · discussion of execution risks in on-chain trading
https://www.bis.org/publ/qtrpdf/r_qt2112b.pdf URL verified
Editorial status
Flagged by the editor as uncertain on a linguistic, mathematical or regulatory point.
