Bible Network Crypto DeFi Onchain RWA AI Agent Stablecoin CryptoTax DeFAI Chain SAFU AGI Claude Me Claude Skill Claude Cowork
Independent Media
Not affiliated with any project
DeFi Protocol Mechanics, Decoded
defi-bible.com
LATEST
Every Time You Get Sandwiched, You Might Think 'Someone' Is Watching You — Here's What's Actually Happening  ·  The Price on Screen Suddenly Gets Cut in Half, and You Have Only Seconds to Decide — What to Do and Not Do During a Flash Crash  ·  A Protocol Once Had Bad Debt — Permanent Blacklist, or Worth Reconsidering?  ·  How Much of This Token 'Hasn't Been Released Yet' Matters More Than How Much It's Up Right Now  ·  Too Narrow a Range Means High Fees but High Risk Too: How to Pick a Concentrated Liquidity Range You Won't Regret  ·  A Vote Passes and Executes the Next Second — Efficiency or a Vulnerability? Check a DAO's Timelock in Three Minutes
Glossary · MEV & Market Microstructure

Sandwich Attack

MEV & Market Microstructure intermediate

30-Second Version · For the impatient
A MEV attack where an attacker, upon spotting a victim's large DEX trade, inserts a same-direction buy order immediately before it (pushing the victim's execution price higher), then places a sell order immediately after to profit — with the victim sandwiched in the middle, forced to execute at a worse price.
Full Explanation +
01 · What is this?

How does a sandwich attack work, and why does it succeed?

Sandwich attacks exploit two key mechanisms: (1) mempool transparency, and (2) gas bids determining transaction order.

Attack flow: ① Victim submits a transaction — "buy ETH with 10,000 USDC on Uniswap" — to the mempool, with 1% slippage tolerance ② The attacker's bot instantly spots this transaction and assesses sufficient profit margin ③ Attacker submits a "buy ETH" transaction with higher gas than the victim, ensuring it's prioritized — this is the frontrun ④ The attacker's buy pushes ETH's price higher in the pool ⑤ The victim's buy executes, but ETH is now more expensive — the victim gets less ETH for their USDC (within tolerance) ⑥ Attacker immediately submits a sell ETH transaction (backrun) at the price elevated by the victim's trade, locking in profit

Throughout this, the attacker's profit = the victim's overpayment, minus gas fees.

02 · Why does it exist?

Which situations are most likely to be targeted by sandwich attacks?

Three factors determine whether you're an attractive target:

(1) Large trade size: small trades ($50) have little extractable margin — gas fees may exceed profit, making attacks unattractive. Large trades ($1,000+) offer enough margin to cover gas costs and remain the primary targets.

(2) Wide slippage tolerance: if you set 3% tolerance, the attacker knows up to 3% can be extracted. Setting strict 0.1% tolerance dramatically reduces attack risk (too little room for the attacker).

(3) Shallow liquidity pairs: pools with low liquidity already have large natural slippage; a small push makes it easier for the victim's trade to still execute within tolerance, while also generating higher attacker profit.

Popular stablecoin pairs (USDC/USDT) are virtually immune to sandwich attacks — prices barely move, leaving almost no attack window.

03 · How does it affect your decisions?

What measures can users take to protect themselves from sandwich attacks?

(1) Strict slippage settings: setting tolerance to 0.1–0.5% greatly reduces the attacker's operating window. The tradeoff: transactions may fail during high-volatility periods.

(2) Private mempool services: Flashbots Protect, MEV Blocker, and similar services keep your transaction out of the public mempool — attackers simply can't see it. One of the most effective defenses currently available.

(3) Split large orders: break one large trade into multiple smaller ones executed in batches, reducing each transaction's size and diminishing attack profit margins.

(4) Choose deep-liquidity pools: deep pools have less price impact per transaction, leaving attackers less profit to extract.

(5) Use MEV-resistant DEXs: some DEXs designed to reduce MEV (like CoW Protocol's batch auction mechanism) prevent user transactions from being front-run.

04 · What should you do?

How does a sandwich attack differ from a general front-running attack?

Front-running is the broader concept: an attacker inserts their own transaction before a target transaction to profit.

A sandwich attack is a specific front-running pattern defined by its key characteristic: "both a pre-trade and a post-trade" — the attacker inserts a trade on both sides, sandwiching the victim.

Other front-running forms: (1) Pure front-run: only inserts before the victim's trade, completing the action first and leaving the victim without the opportunity (e.g., sniping NFT mints, racing for arbitrage) (2) Back-run: only inserts after the victim's trade, profiting from the price movement caused by the victim (e.g., post-liquidation arbitrage)

Sandwich attack = front-run + back-run combined — the most complex pattern, but also the most reliable for continuously extracting from ordinary users.

Real-World Example +

According to EigenPhi on-chain analysis, Ethereum averaged over 4,400 sandwich attacks per day between October 2022 and September 2024. The most thoroughly documented operator is the bot jaredfromsubway.eth: since launching in March 2023, it accumulated over $22 million in profit through sandwich attacks, verifiable on EigenPhi's public Dune Dashboard. A specific verifiable case: on March 12, 2025, a user submitted a $220,764 USDC swap on Uniswap v3's USDC-USDT pool and received only $5,271 USDT after a sandwich attack — a loss of over $215,000. (Transaction hash 0xee9fcd2b9996e96b642cb4cda47fc140f98fdaf07ee02657743d4bfcc4670106 is verifiable on Etherscan.)

Common Misconceptions +
✕ Misconception 1
× Misconception: Only large traders get sandwich attacked. In reality: attack targets are determined by "profit margin > gas fees," not absolute trade size. If your trade is large enough relative to a shallow pool, or your slippage tolerance is wide enough, even non-"whales" can be targeted.
✕ Misconception 2
× Misconception: Decentralized exchanges have no market maker — no one can manipulate my trade. In reality: the public mempool lets anyone see your pending transaction and act first. Sandwich bots are a mechanism that operates legally (technically permitted) but unethically, extracting from users within a decentralized environment.
The Missing Link +
Direct Impact

Private mempool solves the sandwich attack problem but introduces new trust assumptions — you must trust services like Flashbots not to exploit your transaction information themselves. Strict slippage tolerance defends against attacks but raises transaction failure rates. There is no perfect solution currently; MEV is an inherent property of public blockchain architecture, and sandwich attacks are merely its most visible negative manifestation.

Ask a Question
Please enter at least 10 characters
Related Articles
Every Time You Get Sandwiched, You Might Think 'Someone' Is Watching You — Here's What's Actually Happening
beginners · Jul 26
The Displayed Price Is One Thing, What You Actually Get Is Another: A Beginner's Guide to Slippage
beginners · Jul 25
Every Trade You Make Could Be Front-Run: Concrete Ways to Reduce MEV Losses
strategies · Jul 24
Related News
More Related Topics