Slippage Tolerance: Set a Safer Swap Floor
How to set slippage tolerance to reduce sandwich attack risk: choose a narrow floor that allows ordinary quote movement while limiting how far a swap can worsen before it reverts.
Onchain Report Newsroom#0362883 min read
Slippage tolerance reduces sandwich attack risk by setting the lowest output your swap will accept, provided the price stays within that limit. The contract enforces this minimum output, so a worse fill beyond the limit makes the swap revert.
On Matcha swap, the quote already reflects the estimated price impact of your trade. When your concern is exposure to a public mempool, compare that limit with Matcha swap MEV protection options: tolerance limits how much the fill can worsen, while MEV protection addresses attack exposure.
A 1% tolerance sets a 99-token floor
For a quote of 100 tokens at 1% tolerance, the minimum output is 99 tokens. The contract calculates that floor from the quoted output and the tolerance you select.
Price impact is the quote’s estimated effect from your trade, such as the price moving as the trade uses available liquidity. Slippage tolerance is the extra movement allowed after that quote before the swap reverts. They are related, but they are not the same.
Say you expect to receive 100 tokens and set tolerance to 1%. The expected price impact is already reflected in that 100-token quote. Adding the expected impact again as extra tolerance would lower your minimum output further than intended.
A sandwich attacker places a trade before yours and another after it, moving the execution price against your swap. The minimum output bounds how far your fill can deteriorate: at a 99-token floor, the swap should revert rather than accept an output below 99 tokens.
Think of the minimum output as a marked line on a scale: the swap can proceed above it, but crossing it stops the trade. The analogy only goes so far; the contract checks the output against a calculated value, not a physical scale.
Choose a tolerance narrow enough to limit a worse fill, but wide enough to allow ordinary quote movement while your wallet confirms. Lower tolerance tightens the floor and may cause a revert during normal price changes. Higher tolerance makes execution easier, but gives the fill more room to worsen. On Matcha swap, set it against the movement you expect during confirmation, and do not add quoted price impact again.
What does slippage tolerance mean in a crypto swap?
Slippage tolerance is the maximum extra price movement your swap allows before it reverts. It sets the minimum output from the quote, so it defines the tradeoff between completing the swap and limiting a worse fill.
Why can a swap fail with low slippage tolerance?
A swap can fail with low slippage tolerance when the output falls below its minimum before execution. Ordinary price movement can cross that floor, even without an attack, so choose a setting that allows expected movement while keeping the floor meaningful.