Slippage Explained in Detail
Slippage is the gap between the quoted trade price and the executed price. In DeFi, slippage usually appears when a swap moves through an AMM, aggregator, vault zap, liquidation path, or low-liquidity pool.
Some slippage is normal, but weak slippage checks can leak value or enable exploitation.
Transaction example
-
Quote: The user expects 100 tokens out.
-
Move: Market price changes before execution.
-
Execute: The swap returns 94 tokens.
-
Accept: The transaction succeeds because the minimum output was too low.
Slippage in Auditing
Slippage controls protect users and protocols from stale quotes, low liquidity, and sandwich attacks. A protocol swap with amountOutMin = 0 can leak value even if the Solidity code is otherwise correct.
Slippage also matters when a vault, liquidation, or strategy performs swaps on behalf of users.
Red flags in code
-
amountOutMin = 0. -
Hardcoded slippage tolerance.
-
No deadline on swaps.
-
User cannot set a minimum output.
-
Protocol uses spot price as both quote and execution guard.
-
Low-liquidity pools are used for large trades.
-
Quote and execution happen across separate transactions without protection.
How to test or review it
-
Simulate price movement between quote and execution.
-
Test low-liquidity pools and volatile pairs.
-
Check whether minimum output is user-controlled or derived from a trusted quote.
-
Run front-running and sandwich simulations for user-facing swaps.
-
Verify protocol-owned swaps have conservative bounds and deadlines.
-
Review price manipulation and MEV assumptions when swaps affect collateral, shares, rewards, or liquidations.