Sandwich Attack
By Menno — 13 years in crypto, 3 bear markets survived, zero paid promotions
Last updated: March 2026
A sandwich attack is an MEV strategy where a bot places a buy order before and a sell order after a victim's pending DEX trade, profiting from the price impact. The victim receives a worse execution price while the attacker captures the spread.
A sandwich attack is the most common form of harmful MEV extraction on decentralized exchanges. It works by exploiting the predictable price impact of pending transactions visible in the mempool.
The mechanics: (1) A user submits a swap on Uniswap (e.g., buy 10 ETH worth of TOKEN). (2) A MEV bot spots this pending transaction and calculates that it will push TOKEN's price up by 0.5%. (3) The bot submits a buy order for TOKEN with higher gas, ensuring it executes before the victim (front-run). (4) The victim's trade executes at a now-higher price. (5) The bot immediately sells TOKEN at the inflated price (back-run), pocketing the difference minus gas costs.
The victim's loss is the difference between the price they should have received and the price they actually got. On a $10,000 swap, a sandwich attack might extract $20-100 depending on liquidity depth and slippage tolerance. Across all of Ethereum, sandwich attacks extract millions of dollars per month from DEX traders. Analysis by EigenPhi shows that sandwich bots generated over $250 million in revenue between 2022-2024.
Protection measures: set low slippage tolerance (the tighter your slippage, the less profit a sandwich can extract — if the attack can't fit within your slippage, it fails). Use private transaction pools like Flashbots Protect or MEV Blocker. Trade on DEXs with built-in MEV protection (CowSwap uses batch auctions). Trade on L2s where single sequencers make mempool-based sandwiching harder.
Frequently Asked Questions
How do I know if I was sandwich attacked?
Check your transaction on Etherscan and look at the block's transaction list. If the transaction directly before yours bought the same token and the transaction directly after sold it, you were likely sandwiched. Tools like EigenPhi and Flashbots Explore let you search by wallet to see if your transactions have been targeted.
Does sandwich attacking happen on all chains?
Primarily on Ethereum mainnet where the public mempool is visible to searchers. On L2s like Arbitrum and Optimism, the centralized sequencer makes traditional sandwich attacks harder but not impossible. On Solana, a different MEV ecosystem exists with validators running Jito's modified client. On chains with private mempools or encrypted transaction ordering, sandwich attacks are significantly reduced.
Related Terms
MEV (Maximal Extractable Value)
MEV (Maximal Extractable Value) is the profit that block producers can extract by reordering, inserting, or censoring transactions within a block. MEV includes front-running, sandwich attacks, and arbitrage, and has generated over $600 million on Ethereum since 2020.
Front-Running
Front-running in crypto is when a bot or actor sees a pending transaction in the mempool and submits their own transaction first (with higher gas) to profit from the anticipated price impact. It is a form of MEV extraction that costs retail traders billions annually.
Slippage
Slippage is the difference between the expected price of a trade and the actual execution price. It typically occurs in low-liquidity markets or with large orders, and can significantly increase the cost of trading.
DEX (Decentralized Exchange)
A DEX is a cryptocurrency exchange that operates on a blockchain without a central authority. Users trade directly from their wallets using smart contracts, maintaining custody of their funds. Examples include Uniswap, Jupiter, and Raydium.
Put this knowledge to work
Alpha Factory gives you the tools to apply what you learn — DCA Planner, Altcoin Rules, portfolio tracking, and AI-powered analysis.
Start Free Trial