Sandwich Attack
Trading around a victim's swap so their own price impact pays you.
Basically
In plain words, an MEV strategy where an attacker front-runs and back-runs a victim's DEX trade, profiting from the price impact they cause.
Key Takeaways
- A sandwich attack is a form of MEV extraction where an attacker places two trades around a victim's pending DEX swap: one before (to inflate the price) and one after (to collect the profit from the artificial price movement).
- Sandwich attacks exploit the deterministic pricing of decentralized exchanges built on automated market makers: because trade outcomes are fully calculable from pool reserves, attackers can simulate exact profits before committing capital.
- Protection methods include private transaction pools (Flashbots Protect, MEV Blocker), intent-based DEX aggregators (CoW Swap, 1inch Fusion), and tight slippage settings. Bitcoin Lightning payments are architecturally immune because they have no public mempool or AMM price curves.
What Is a Sandwich Attack?
A sandwich attack is a front-running strategy used on blockchain networks where an attacker "sandwiches" a victim's pending trade between two of their own transactions. The attacker buys the target asset before the victim (driving the price up), lets the victim's trade execute at the inflated price, then immediately sells for a profit.
The attack is possible because most blockchains broadcast pending transactions to a public mempool before they are included in a block. Automated bots monitor this mempool, identify profitable swap transactions, and pay higher priority fees (or submit bundles to block builders) to guarantee their transactions execute in the desired order. The victim receives fewer tokens than expected, while the attacker pockets the difference.
Sandwich attacks are one of the most common forms of MEV extraction on Ethereum and Solana. Research from EigenPhi and Cointelegraph found that sandwich attacks account for roughly 51% of all MEV volume on Ethereum as of 2025, with 60,000 to 90,000 attacks occurring per month: more than one per block on average.
How It Works
A sandwich attack unfolds in three transactions, all typically included in the same block:
The AMM Price Curve
Sandwich attacks are a direct consequence of how automated market makers (AMMs) calculate prices. Most DEXes use a constant product formula where the product of two token reserves must remain constant:
Because this formula is deterministic, an attacker can simulate the exact outcome of any trade before committing capital. They calculate the optimal front-run size: large enough to extract meaningful profit, but not so large that gas costs and swap fees consume the gains. The victim's slippage tolerance setting defines the upper bound of how much price impact the attacker can inflict: wider tolerance means a larger attack surface.
Execution Priority
On Ethereum, attackers ensure transaction ordering through MEV infrastructure. Post-Merge, specialized "searchers" submit transaction bundles to block builders with priority tips. The builder includes all three transactions (front-run, victim, back-run) as an atomic bundle in the block. On Solana, attackers use Jito bundles or validator relationships for similar ordering guarantees.
A Real-World Example
In March 2025, a trader lost over $215,000 swapping $220,764 USDC to USDT on Uniswap v3. An MEV bot drained nearly all USDC liquidity from the pool in its front-run trade, causing the victim to receive only $5,271 of USDT instead of the expected amount. The attacker tipped the block builder $200,000 and kept roughly $8,000 in profit. The victim's transaction did not originate from Uniswap's front end (which includes built-in MEV protection and default slippage limits), illustrating the importance of proper tooling.
Scale of the Problem
Sandwich attacks represent a significant tax on DEX users across multiple chains:
On Ethereum, a single operator known as jaredfromsubway.eth has been responsible for roughly 70% of all sandwich attacks, accumulating over $22 million in cumulative profit since March 2023. On Solana, the DeezNode-operated bot executed 1.55 million sandwich transactions in a single 30-day period with an 88.9% success rate.
Protection Methods
Private Transaction Pools
The most effective defense is preventing attackers from seeing your transaction before it lands in a block. Private transaction pools route your swap through a protected channel that bypasses the public mempool:
Intent-Based DEX Aggregators
Rather than broadcasting a swap transaction, intent-based systems let users sign an off-chain order that professional solvers fill:
User-Level Defenses
When using a standard DEX interface, the simplest protection is setting a tight slippage tolerance (for example, 0.5% instead of a higher default). This caps the maximum price deviation the attacker can inflict. If the attacker's front-run would push the price beyond the victim's slippage tolerance, the victim's transaction reverts and the attack fails.
Other user-level strategies include trading on deep liquidity pools (where price impact is minimal), splitting large trades into smaller orders, and using DEX front ends with built-in MEV protection.
Protocol-Level Mitigations
Several protocol designs reduce or eliminate sandwich vulnerability:
Why Bitcoin Lightning Is Immune
Bitcoin Layer 2 payment networks like Lightning and Spark are architecturally immune to sandwich attacks for several reasons:
This architectural advantage extends to stablecoin payments settled over Lightning-compatible networks. A stablecoin transfer on Spark moves directly between parties without passing through an exploitable ordering layer, making it inherently resistant to the MEV extraction that costs DEX users hundreds of millions of dollars annually.
Regulatory Developments
Regulators are beginning to treat sandwich attacks as a form of market manipulation. In July 2025, the European Securities and Markets Authority (ESMA) formally flagged sandwich attacks and harmful front-running as potential market manipulation under MiCA. The MiCA transitional period ends July 1, 2026, meaning EU-regulated platforms must actively address harmful MEV practices.
On Solana, enforcement has taken a validator-level approach: the Solana Foundation removed validator operators from its delegation program for facilitating sandwich attacks in June 2024. Jito subsequently blacklisted nefarious validators through governance proposals, and Marinade Finance blacklisted over 50 malicious validators to protect $2 billion of delegated stake.
Risks and Considerations
For DEX Users
Any trader using an AMM-based DEX without MEV protection is exposed to sandwich attacks. The risk scales with trade size relative to pool depth: larger trades in shallower pools suffer disproportionately worse execution. Even with protection tools, no solution is perfect: private transaction pools depend on trusted builders, and intent-based systems introduce settlement delays.
For Liquidity Providers
Sandwich attacks create adverse selection for liquidity providers. LPs consistently trade against informed (MEV-extracting) counterparties, which can exacerbate liquidity challenges and reduce returns. Some AMM designs attempt to mitigate this through dynamic fees or oracle-based pricing.
Systemic Implications
The "invisible tax" of sandwich attacks erodes user trust in decentralized trading. When 1.2% of all Ethereum DEX trades are sandwiched, with average losses of 0.41% per affected trade, the cumulative effect discourages retail participation and pushes volume toward centralized exchanges or alternative settlement layers like Lightning that are immune to these exploits.
This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.