What Is a Sandwich Attack?
A sandwich attack represents one of the most common and profitable forms of MEV extraction in decentralized finance. The concept's simple: an attacker monitors the public transaction mempool (where all pending transactions wait before confirmation), identifies a large swap order, then executes their own trades immediately before and after the victim's transaction to profit from the induced price movement.
Think of it like a market maker who sees your order coming and trades against you before you can complete it. In traditional finance, this would be illegal front-running. In DeFi's transparent mempool, it's technically feasible but ethically questionable.
The mechanics work because most DEX transactions interact with automated market makers using constant product formulas. When you swap a large amount of Token A for Token B, you move the price along the bonding curve. Sandwich attackers exploit this predictable price impact.
How Sandwich Attacks Work: Step-by-Step
Here's what happens during a typical sandwich attack on Uniswap or similar AMMs:
Step 1: Mempool Monitoring The attacker runs bots that constantly scan the Ethereum mempool for pending swap transactions. They're looking for trades large enough to cause meaningful slippage — typically swaps worth several thousand dollars or more.
Step 2: Front-Run Transaction Once identified, the attacker submits their own transaction with a higher gas price to ensure it's processed first. This "front-run" transaction buys the same token the victim wants to purchase, moving the price up before the victim's trade executes.
Step 3: Victim's Transaction Executes The victim's transaction goes through, but now they're buying at the artificially elevated price caused by the attacker's front-run. They receive fewer tokens than expected due to increased slippage.
Step 4: Back-Run Transaction Immediately after, the attacker's second transaction executes, selling the tokens they bought in step 2. Since the victim's large trade pushed the price even higher, the attacker sells at a profit.
The victim loses money twice: once to the front-run that raised the entry price, and again because their own trade's price impact benefits the attacker's exit.
Real Numbers: How Much Do Sandwich Attacks Extract?
According to research from Flashbots, sandwich attacks extracted approximately $1.2 billion in MEV value between January 2020 and September 2021 on Ethereum alone. More recent data from EigenPhi shows daily sandwich attack volumes ranging from $2-5 million across major DEXs in 2025.
Individual sandwich attacks typically extract between 0.5% and 3% of the victim's transaction value. On a $10,000 swap, that's $50 to $300 lost to the attacker. For retail traders, these losses accumulate significantly over time.
Larger transactions face proportionally more extraction. A $100,000 swap might lose $1,500-$3,000 to sandwich attacks — far exceeding normal DEX fees and slippage expectations.
Why Sandwich Attacks Persist
You might wonder: if everyone knows about sandwich attacks, why do they keep working?
Transparent Mempools Ethereum and most EVM chains broadcast pending transactions publicly before confirmation. This design choice enables decentralized validation but creates an information asymmetry that attackers exploit. Validators and searchers see your transaction before it executes.
Gas Price Competition Attackers can outbid regular users for transaction priority. They're willing to pay higher gas fees because they're extracting value that exceeds the cost. During peak activity, attackers have paid over 1000 gwei to secure profitable sandwich positions.
Lack of User Protection Most wallet interfaces don't adequately protect users from MEV extraction. Default slippage tolerances (often 0.5%-1%) are insufficient for large trades, but users rarely adjust these settings or understand the implications.
Liquidity Pool Mechanics AMM designs inherently create exploitable price impacts. The larger your trade relative to pool size, the more vulnerable you are. A $10,000 swap in a $50,000 pool will get absolutely destroyed by sandwich bots.
Protecting Yourself from Sandwich Attacks
I've watched traders lose thousands to sandwich attacks that were completely preventable. Here's what actually works:
Set Tight Slippage Tolerances This is your first defense. If you set 0.3% slippage tolerance, any sandwich attack that would cause more than 0.3% price deviation will cause your transaction to revert. You won't lose money, though you'll waste gas fees. Better than getting sandwiched.
Split Large Orders Breaking a $50,000 trade into five $10,000 trades reduces each individual trade's price impact. Yes, you'll pay more in gas fees, but you'll typically save more by avoiding sandwich extraction than you spend on extra transactions.
Use Flashbots Protect RPC Flashbots Protect (protect.flashbots.net) allows you to submit transactions that skip the public mempool entirely. Your transaction goes directly to validators through a private channel. This prevents front-running since attackers never see your pending transaction.
Trade on Private Transaction Networks Services like CowSwap, 1inch's "stealth" mode, or Eden Network route transactions through private channels that shield them from sandwich bots. These typically charge small fees but save you more than they cost on trades above $5,000.
Choose Liquid Pools Trade in pools with deep liquidity relative to your order size. A $10,000 trade in a $5 million pool creates minimal price impact — making sandwich attacks unprofitable for attackers.
Use Limit Orders Instead of market swaps, place limit orders at your desired price. Services like 1inch Limit Order Protocol let you specify exact execution prices. No price impact means no sandwich opportunity.
The MEV Supply Chain
Sandwich attacks exist within a broader MEV extraction ecosystem. Understanding this helps explain why they're so prevalent:
Searchers — bots and algorithms that identify profitable MEV opportunities in the mempool Builders — entities that construct optimized transaction bundles combining user transactions with MEV extraction Validators — Ethereum validators who propose blocks and can include high-MEV bundles for additional profit
This three-tier structure means sandwich attacks aren't just random bots — they're part of an industrialized MEV extraction operation. The attacker who sandwiches your transaction likely splits profits with the block builder and validator.
Research from Flashbots indicates validators earn an additional 2-3% on top of standard block rewards through MEV-related tips. This creates incentives that perpetuate sandwich attacks throughout the validation supply chain.
Sandwich Attacks Across Different Chains
Different blockchain architectures face varying sandwich attack dynamics:
Ethereum and EVM Chains The most sandwich-attack-prone environment due to transparent mempools and sufficient block space. Layer 2 scaling solutions like Arbitrum and Optimism actually make sandwich attacks easier because lower gas costs reduce the attacker's expenses.
Solana Solana's architecture creates different MEV dynamics. While the mempool isn't public in the same way as Ethereum's, validators still have transaction ordering power. Jito Labs has documented significant MEV extraction on Solana, though sandwich attacks are less prevalent due to different AMM designs. For more on Solana's architecture, see our Solana vs Ethereum comparison.
Private Mempools and Encrypted Transactions Chains experimenting with encrypted mempools (like Osmosis with threshold encryption) or private transaction ordering significantly reduce sandwich attack viability. These remain experimental but show promise.
Are Sandwich Attacks Always Bad?
Here's a controversial take: not everyone agrees sandwich attacks are purely harmful. Some arguments in their defense:
Liquidity Provision Attackers effectively provide liquidity by taking the opposite side of large trades. Without them, large swaps might face even worse slippage in thin markets.
Price Efficiency MEV extraction mechanisms, including sandwich attacks, contribute to rapid price convergence across markets. This arguable benefits overall market efficiency.
Opt-In Vulnerability Users who don't set appropriate slippage tolerance or use protection mechanisms are essentially opting into the risk. With available protections, some argue victims share responsibility.
I don't buy most of these arguments. The "liquidity provision" claim particularly rings hollow — attackers aren't providing liquidity from their own capital at risk, they're exploiting information asymmetry for guaranteed profits. That's parasitic, not productive.
The Future of Sandwich Attacks
The MEV arms race continues evolving:
Proposer-Builder Separation (PBS) Ethereum's shift toward PBS formalizes MEV extraction into protocol design. This might reduce the most aggressive sandwich attacks by creating fair MEV redistribution mechanisms, but it won't eliminate them.
Account Abstraction and Intent-Based Protocols New transaction paradigms where users express intents rather than specific transaction paths could reduce sandwich vulnerability. If you say "I want $10,000 of ETH at market price" rather than "execute this specific swap," solvers can route around MEV extraction.
Encrypted Mempools Several projects are building threshold encryption schemes where transactions remain encrypted until block inclusion. This would eliminate mempool-based sandwich attacks entirely, though validator-level MEV would persist.
Regulation As DeFi matures, regulators might eventually classify certain MEV extraction as market manipulation. The SEC has shown interest in MEV practices, though concrete regulatory frameworks remain distant.
Key Insight
Sandwich attacks represent a fundamental tension in blockchain design: transparency enables decentralization but creates exploitable information asymmetries. You can't eliminate sandwich attacks without changing core blockchain properties like public mempools and transaction ordering mechanisms.
Until architectural solutions mature, your best defense combines education, proper slippage settings, and MEV-protection tools. On trades above $5,000, the extra steps to avoid sandwich attacks are always worth the effort.
For related trading protection strategies, explore our guides on setting stop losses and understanding market impact from whale movements.