Glossary · S
Sandwich Attack
An MEV attack where a bot detects a large pending DEX swap, places a buy order immediately before it (frontrun — pushing the price up), lets the victim's trade execute at the worse price, then immediately sells (backrun — pocketing the price impact). The victim receives fewer tokens than expected; the bot profits from the spread. Protection: use MEV-resistant RPCs (Flashbots Protect), tight slippage tolerance, or intent-based protocols like CoW Protocol.
Last updated
How Sandwich Attack works in practice
A sandwich attack brackets a victim's trade with two of the attacker's own. Seeing a pending buy, the attacker buys first to push the price up, lets the victim fill at the worse price, then sells into the recovery. It is the most common form of MEV that ordinary users encounter.
Worked example
You submit a 50,000 USDC buy with 3% slippage tolerance. A searcher buys ahead of you, moving the price up nearly 3%. Your order fills at that worse price. They sell immediately after, pocketing most of the 1,500 difference.
Figures are illustrative and chosen to be checkable, not live market data.
The mistake that costs people money
Slippage tolerance is a ceiling on how much can be taken from you. Setting it generously to avoid failed transactions is an invitation. Use tight tolerances and route through a private mempool for large trades.
Sandwich Attack: common questions
- What is Sandwich Attack?
- An MEV attack where a bot detects a large pending DEX swap, places a buy order immediately before it (frontrun — pushing the price up), lets the victim's trade execute at the worse price, then immediately sells (backrun — pocketing the price impact). The victim receives fewer tokens than expected; the bot profits from the spread. Protection: use MEV-resistant RPCs (Flashbots Protect), tight slippage tolerance, or intent-based protocols like CoW Protocol.
- How does Sandwich Attack work in practice?
- A sandwich attack brackets a victim's trade with two of the attacker's own. Seeing a pending buy, the attacker buys first to push the price up, lets the victim fill at the worse price, then sells into the recovery. It is the most common form of MEV that ordinary users encounter.
- Can you give an example of Sandwich Attack?
- You submit a 50,000 USDC buy with 3% slippage tolerance. A searcher buys ahead of you, moving the price up nearly 3%. Your order fills at that worse price. They sell immediately after, pocketing most of the 1,500 difference.
- What do people get wrong about Sandwich Attack?
- Slippage tolerance is a ceiling on how much can be taken from you. Setting it generously to avoid failed transactions is an invitation. Use tight tolerances and route through a private mempool for large trades.