Sandwich Attack

Last Updated Sep 24, 2026

In One Sentence

A sandwich attack places transactions before and after a target trade to profit from its price impact while worsening the target's execution.

A sandwich attack exploits transaction ordering around another user's trade, commonly in an automated market maker. The attacker takes a position before the target transaction and reverses it afterward, aiming to capture the price movement created by the target. The resulting execution can be worse for the target than it would have been without those surrounding trades.

Why the sequence matters

For a target purchase, an earlier purchase can push the pool price upward. The target then buys under less favorable conditions, and the attacker sells after that purchase. Actual profitability depends on liquidity, trade sizes, ordering, and costs; success is not guaranteed.

This is a form of MEV. It differs from simply arbitraging an existing price difference, and a poor fill alone does not prove a sandwich occurred. Ordinary price movement and the user's own price impact can also worsen execution.

Limits and protective measures

A minimum-output requirement or tighter slippage tolerance can restrict the deterioration a trade accepts. If conditions are not met, execution may revert and still consume network fees.

Private transaction routing or alternative execution mechanisms can reduce exposure to public order monitoring, but introduce their own assumptions about intermediaries and handling. No single setting eliminates every ordering risk or guarantees that a trade will execute.