MEV sandwich attacks explained: how bots tax your DEX swap
MEV sandwich attacks explained: how a bot trades before and after your DEX swap, what it costs at 0.5–3% slippage, and six ways to keep bots out of it.

Contents
- What MEV is and where it comes from
- How a sandwich attack works: three transactions in one block
- Why the bot can see your trade first
- What it costs: a worked example at November 24, 2026 prices
- The real numbers: from $2.5M a month to one $215,000 swap
- How to protect yourself from sandwich attacks
- What about Solana and layer 2 networks
- Common mistakes
- FAQ
A MEV sandwich attack happens when a bot spots your pending swap on a decentralized exchange, buys the same token right before you, lets your trade execute at the worse price, and sells immediately after. The difference goes to the bot and to whoever builds the block, and you receive fewer tokens than the interface quoted. How much can be taken is set by your own slippage tolerance: bots extract the gap between that tolerance and the actual price movement.
What MEV is and where it comes from
MEV, or maximal extractable value, is the most value that can be pulled out of block production beyond the standard block reward and gas fees by including, excluding and reordering transactions. That is how the Ethereum documentation defines it. The root cause is simple: transactions in a block execute one after another, and whoever controls the queue can place their own trade in a profitable spot.
The EU markets regulator ESMA, in a risk analysis published July 1, 2025, sorts MEV into three groups:
- arbitrage, which closes price gaps between venues;
- front-running and sandwich attacks, which place trades around someone else's transaction;
- liquidations, the race to close undercollateralized loans on lending protocols.
Arbitrage and liquidations keep DeFi working: they pull pool prices back to the market and clear bad debt. A sandwich is different, because the bot's profit comes straight out of one specific user's result.
On scale, the same ESMA paper cites a Flashbots estimate: from September 2022 to early June 2024, Ethereum validators received 526,207 ETH, about $1.1 billion, or roughly 0.12% of DEX volume on the network. ESMA adds that MEV data are sparse and that methodologies differ between sources.
How a sandwich attack works: three transactions in one block
The Ethereum docs walk through an example: someone wants to buy 10,000 UNI with DAI on Uniswap. A trade that size will noticeably lift the UNI price in the pool. A searcher bot calculates that move in advance and acts in three steps:
- Front-run. The bot buys UNI ahead of the victim and pushes the pool price up.
- Victim's trade. It executes at the inflated price, still inside the slippage tolerance, so it does not revert.
- Back-run. The bot sells what it bought, at a higher price than it paid.
The bot submits all three as one bundle that executes entirely or not at all. ESMA calls this "atomic" MEV: if anything goes wrong the bundle reverts, so the attacker carries almost no price risk. What it does risk is gas and the payment to the block builder.
There is a second variant that needs no token purchase. The bot briefly pulls liquidity out of the pool, the victim's trade runs through a nearly empty pool with enormous slippage, and the liquidity goes back in afterwards. ESMA describes it as a "liquidity provider vs taker" attack. For how pools themselves work, see our guide to impermanent loss.
Why the bot can see your trade first
On Ethereum, a transaction sent from a regular wallet lands in the public mempool, a waiting area anyone can read. Order inside the block, as the Uniswap documentation puts it, is set by the gas offered: pay more, go earlier. While your swap waits, a bot can read its parameters: the pool, the size and the minimum you agreed to accept.
Bitcoin's mempool is public too, and miners also sort by fee, as covered in our piece on Bitcoin mempool fees. But Bitcoin's base layer has no pools with automatic pricing, so a plain BTC transfer cannot be sandwiched. The risk appears when bitcoin trades in DeFi as a wrapped token.
What it costs: a worked example at November 24, 2026 prices
According to our data, ether traded near $1,684 on November 24, 2026, down 28.8% from a month earlier (the live price is on the Ethereum page). Take a hypothetical pool at that price: 1,000 ETH and 1,684,000 USDC, a 0.3% fee, constant-product formula. This is a calculated model, not data from a real pool.
You buy ETH with $50,000. Untouched, the swap returns 28.751 ETH at an average price of $1,739, because the trade itself moves the price by 3.3%. From there everything depends on slippage tolerance.
| Slippage tolerance | Bot buys ahead of you | You receive | Shortfall | Bot's gross take |
|---|---|---|---|---|
| no attack | — | 28.751 ETH | — | — |
| 0.5% | $4,294 | 28.607 ETH | 0.144 ETH (≈ $242) | ≈ $230 |
| 1% | $8,621 | 28.464 ETH | 0.288 ETH (≈ $484) | ≈ $460 |
| 3% | $26,260 | 27.889 ETH | 0.863 ETH (≈ $1,452) | ≈ $1,379 |
The table makes one point: the loss is close to the tolerance multiplied by the trade size. Slippage tolerance is a ceiling on what can be taken from you, and the bot pushes the price right up to the line where your transaction would otherwise revert.
The real numbers: from $2.5M a month to one $215,000 swap
Cointelegraph Research, using EigenPhi data for November 2024 through October 2025, describes the picture on Ethereum:
- traders lose about $60 million a year to these attacks;
- monthly extraction fell from nearly $10 million in late 2024 to about $2.5 million by October 2025, even as DEX volume grew;
- the number of attacks stayed between 60,000 and 90,000 a month;
- roughly 70% of attacks are tied to a single operator, jaredfromsubway.eth;
- attackers keep a margin of about 5%, with the rest going to block builders as gas fees;
- about 38% of attacks hit low-volatility pools (stablecoins, wrapped tokens, liquid staking tokens), and around 12% hit stablecoin swaps.
That last item matters. A dollar-for-dollar swap feels safe, yet it has no extra protection. On March 12, 2025, a trader swapped $220,764 of USDC and received $5,271 of USDT, losing almost 98% in eight seconds, Cointelegraph reported. The trade went through a Uniswap v3 pool holding $19.8 million; the bot removed the USDC liquidity before the swap and restored it after. According to analyst Michael Nadeau, quoted in the report, the attacker tipped the block builder $200,000 and kept $8,000. An outcome like that is only possible when a transaction goes out with practically no minimum-received limit.
How to protect yourself from sandwich attacks
- Set slippage tolerance deliberately. Liquid pairs usually need only a fraction of a percent. ETH Zurich researchers showed that a constant auto-slippage cannot adjust to trade size and pool, while a tolerance tuned to the trade lets most transactions avoid attacks with a low risk of failure.
- Send the trade around the public mempool. Flashbots Protect routes transactions to a private mempool hidden from sandwich bots; a transaction is included only if it does not revert, and failed attempts cost no fees. MEV Blocker offers a similar RPC endpoint. Both run on Ethereum mainnet and pass back part of the revenue from harmless backruns, the arbitrage that follows your trade.
- Check that protection is on in your wallet. In Uniswap Wallet, swap protection is enabled for all Ethereum mainnet transactions. In other wallets it may be a separate toggle or a custom RPC.
- Use intent-based trading. On CoW Protocol, trades settle in batches at a uniform clearing price per pair, so ordering inside the batch changes nothing. UniswapX sends your order to a private network of fillers instead of the mempool.
- Split large orders and pick deep pools. The smaller your trade relative to the pool, the smaller the price move a bot can exploit.
- Read the "minimum received" line. That number is your true worst case. If it sits far below what you expect, do not sign.
What about Solana and layer 2 networks
Solana has no public mempool at the protocol level, but Jito, the client validators use to receive transaction bundles, used to run one. On March 8, 2024, Jito Labs shut its mempool down, citing harm to users. Attacks did not vanish; part of the activity moved to private channels. As a defense, Jito offers the jitodontfront marker: a bundle containing such a transaction is rejected unless that transaction comes first.
On Ethereum rollups, ordering is usually set by a single operator, the sequencer, and many have no public mempool. That lowers the odds of a classic sandwich, but the other rules still apply: tolerance and minimum received work the same way.
Common mistakes
- High tolerance "so it goes through." A 5–10% tolerance on a large swap is an open invitation to a bot.
- Trusting stablecoin swaps. About 12% of attacks in the EigenPhi sample hit exactly those.
- Swapping through a third-party interface or your own script with no protection. Built-in protection only works where it is switched on.
- A large trade in a shallow pool. Check pool depth and price impact first.
- Mixing up slippage and price impact. Price impact is what your own trade moves; slippage is what can change while it waits.
Protection has limits too: a private channel means trusting its operator and the block builders, and inclusion can be slower.
FAQ
Are sandwich attacks legal? There is no single answer. ESMA's 2025 paper describes the harm to users and says the topic should inform future EU regulatory discussions. In the US, the high-profile Peraire-Bueno case concerned a different scheme, an operation against MEV trading bots, and ended in acquittal on November 16, 2026.
Can I get my money back after an attack? No. The trade executed within the terms you signed, and it cannot be reversed on-chain.
How do I know I was sandwiched? Open the block containing your transaction in an explorer. A buy right before it and a sell right after it, in the same token and from the same address, is the pattern.
Does this happen on centralized exchanges? Not in this form. Orders there are matched by the exchange itself, with no public queue to read. The risks are different, as explained in our guide to order types.
This is not investment advice.



Comments