Slippage Protection
Slippage protection is a mechanism that prevents trades from executing at prices significantly worse than expected, guarding users against price impact and sandwich attacks.
In Depth
Slippage protection sets bounds on acceptable price impact for on-chain trades. When a user submits a swap, the slippage tolerance defines the maximum deviation from the expected price that is acceptable; if the actual execution price exceeds this threshold, the transaction reverts. This mechanism defends against MEV sandwich attacks, where a front-runner inflates the price before the victim's trade and sells immediately after. Effective slippage protection also includes deadline parameters to prevent transactions from executing at stale prices after sitting in the mempool. Protocol developers must carefully calibrate default slippage values to balance user protection against transaction failure rates.
Frequently Asked Questions
What is slippage protection in DeFi?
Slippage protection limits the maximum price impact a trade can incur. If the execution price deviates beyond the user's slippage tolerance, the transaction reverts. This protects users from large price movements and sandwich attacks.
What is a sandwich attack and how does slippage help?
A sandwich attack is when an MEV bot front-runs your trade to push the price up, then back-runs it to profit from the price movement. Tight slippage tolerance causes your transaction to revert if the price moves too much, making sandwich attacks unprofitable.
What is a deadline parameter in swaps?
A deadline parameter sets a timestamp after which a swap transaction will revert. This prevents old transactions stuck in the mempool from executing at outdated prices. Without a deadline, a swap submitted hours ago could execute at a significantly different market price.