Skip to main content

Sandwich Attack

A sandwich attack is an MEV strategy where an attacker observes a pending transaction in the mempool, places a buy order just before it to push the price up (front-run), lets the victim's trade execute at the worse price, then sells just after (back-run) to capture the price difference. The victim effectively pays the spread between the front-run and back-run prices. Sandwich attacks are most profitable against large trades with high slippage tolerance on thin liquidity pools. The attacker must pay gas fees for two transactions and the AMM swap fee, so the strategy requires the victim's trade to move the price enough to overcome these costs. MEV searchers deploy sophisticated mempool monitoring infrastructure and gas-bidding strategies to win sandwich opportunities. Defenses include lower slippage tolerance, flashbots-style private transaction submission (bypassing the public mempool), and protocol-level protections like time-weighted average price or batch auction execution.