Sandwich Attack
1 min read
Pronunciation
[sand-wich uh-tak]
Analogy
Think of a sandwich attack like placing two slices of bread around someone’s order at a deli: you buy before they do and sell immediately after to capture the price difference.
Definition
A strategy where an attacker observes a pending transaction in the mempool, places a buy order before it and a sell order after it, profiting from the price movement caused by the victim’s trade.
Key Points Intro
Sandwich attacks extract value by front-running and back-running victim transactions.
Key Points
Front-running: attacker’s buy order executes before victim’s transaction
Back-running: sell order executes immediately after victim’s transaction
Profit extraction: exploits slippage caused by large orders
MEV context: a form of miner/validator extractable value
Example
Technical Deep Dive
Bots monitor the mempool via full-node RPC/WebSocket, calculate optimal gas prices to prioritize their front-run transaction, then submit both transactions in a single bundle (e.g., via Flashbots). Slippage tolerances and gas estimation algorithms are tuned to maximize profit while avoiding failed transactions.
Security Warning
Caveat
Highly competitive environment; profit margins shrink as more bots compete for the same opportunities.
Sandwich Attack - Related Articles
No related articles for this term.