Term

Sandwich attack

A sandwich attack is a specific form of MEV in which a searcher spots a large pending DEX trade in the mempool, buys the same asset just before it (raising the price), lets the victim's trade execute at the worse rate, then sells just after (capturing the difference).

A sandwich attack is a two-transaction MEV exploit against a pending decentralized exchange trade. When a large user swap appears in the mempool, an attacker submits: (1) a buy of the same asset just before it — pushing the pool price up; (2) the victim's trade executes at the now-worse price; (3) a sell just after — capturing the price bump the victim's trade created. The victim ends up with less asset than they would have without the sandwich.

Because the attacker's two legs are on either side of the victim (the "sandwich"), the profit is bounded by the victim's slippage tolerance — the maximum price movement they authorized their swap to accept. A tight slippage tolerance (e.g. 0.5%) limits sandwich profitability but risks the victim's trade failing entirely if the pool moved.

Mitigations: use private mempools (Flashbots Protect, MEV Blocker) that hide the pending transaction from searchers; use a DEX with anti-MEV protection built in; split large trades into smaller ones; set slippage tolerance carefully — tight enough to bound attacks, loose enough that legit trades execute.

Want to put this to work?

← All terms