MEV and sandwich attacks: why your swap got a worse price
What MEV is, how sandwich attacks worsen DEX prices, and which slippage and relay choices really help.
Updated 15 Sept 2026 · Advanced · 4 min read
In short
- MEV is the extra value validators or searchers can extract by reordering, inserting or excluding transactions around yours.
- A sandwich attack brackets your swap with an attacker’s buy and sell, pushing your execution to a worse price within your slippage limit.
- Tighter slippage, deeper liquidity and private relays can help, but they do not guarantee perfect execution or remove every MEV strategy.
What MEV means in practice
MEV began as “miner extractable value” and is now usually read as “maximal extractable value”, because since 2022 Ethereum blocks are proposed by validators, mostly from blocks assembled by specialised builders and searchers, rather than mined. The idea is simple: if someone sees pending transactions before they are final, there is value in choosing their order. Liquidations, arbitrage and some kinds of front-running all fall under that umbrella.
Not all MEV is theft. Arbitrage between pools often keeps prices aligned. The harmful part for ordinary users is when someone extracts value directly from your trade, such as by sandwiching it.
How a sandwich attack works
Suppose you submit a market swap on a decentralised exchange with a generous slippageThe difference between the price you expect and the price you get when a trade executes, usually because the price moved or liquidity was thin. setting. A searcher watching the public mempool sees the order, buys the token first so the price rises, lets your swap execute at that worse price, then sells into the higher post-swap price. Your transaction still succeeds because it stayed within your slippage limit, but you receive fewer tokens than you would have without the attacker around it.
Thin liquidityHow easily an asset can be bought or sold without moving its price., a large order size and a wide slippage tolerance make sandwiching more attractive. Highly liquid pools and a tight slippage limit leave less room for it.
You often notice the result only afterwards: the quoted price looked acceptable, the trade confirmed, but the execution was noticeably worse than the pre-trade estimate. That gap is where sandwich losses usually hide.
Why the mempool matters
Most wallet transactions are first broadcast to the public mempool, where searchers can inspect them before a block is built. That visibility is what enables many sandwich attacks. The attacker does not need your keys; they only need to see the intent and know they can get two transactions in around it.
Private transaction relays try to remove that visibility by sending the transaction straight to block builders without public broadcast. Services such as Flashbots Protect can reduce exposure to ordinary mempool sandwiching, though they introduce trust in the relay path and do not make the transaction invisible to every party involved in building the block. If the relay falls back to public broadcast, or if another path leaks the trade, the usual risks return.
What you can control
- Set the slippage tolerance as tight as the trade allows. Wide defaults are convenient, but they define the room an attacker can use.
- Trade in deeper pools when you can. A small trade against deep liquidity moves the price less.
- Break very large swaps into smaller ones only if the extra gas and market risk still leave you better off.
- Consider a private relay for swaps on chains and wallets that support it.
- Check the quote against the market before signing. Our transaction lookup helps you inspect what happened after the fact.
Some interfaces offer exact-input and exact-output modes. Neither removes the risk on its own: exact input sets the least you will receive, exact output sets the most you will pay, and a sandwich can take anything up to that bound. What protects you is setting the bound from a fresh quote rather than accepting a wide default.
It also helps to avoid tokens and pools you do not understand. Exotic assets with shallow liquidity can move violently on small orders, which means ordinary price impact and exploitable MEV become hard to separate.
What you cannot control
You cannot force validators to give you the best possible ordering, and you cannot remove all forms of MEV from public blockchains. Even with private relays, a builder or relay operator still sees the transaction. Some value extraction, such as arbitrage around genuine price differences, is part of how on-chain markets clear.
The goal is therefore to reduce avoidable losses, not to expect perfect protection. Tighter settings can make a swap revert instead of filling at a bad price; that is often the right trade if execution quality matters more than getting the trade through on the first attempt. Gas spent on a failed trade is frustrating, but a bad fill on a large trade can cost much more.
A quick checklist before you swap
- Check the pool depth and your price impact.
- Lower the slippage setting from the wallet default if the token is liquid enough.
- Avoid trading during violent news moves unless speed matters more than execution quality.
- Use a private relay option when the wallet offers one and you trust the route.
- Review the final execution afterwards in wallet health if the trade behaved oddly or involved risky approvals.
None of this guarantees a perfect trade, but together these steps make you a less easy target. MEV thrives on large, urgent and loosely configured orders. Most retail users can improve outcomes just by avoiding those conditions.