What is MEV, and how does a sandwich attack work?
MEV is profit made by choosing which transactions go into a block and in what order.1 In a sandwich attack, a bot trades just before and just after a large swap, so the swapper gets a worse price and the bot keeps the difference.1,2
What MEV is
ethereum.org defines maximal extractable value (MEV) as the value that can be taken from making a block by including, leaving out or reordering its transactions.1 This is on top of the normal block reward and fees.1
Much of it is taken by independent bot operators, which ethereum.org calls "searchers".1 They watch the mempool, the queue of transactions waiting to go into a block.1,3
IOSCO, the international body of securities regulators met in Lesson 5, describes one common move in its 2022 report on DeFi. A front-runner pays a higher gas fee so that its transaction is placed ahead of others in the queue.3 It says front-running can leave the people pushed back with worse terms.3
How a sandwich works
ethereum.org gives an example. Someone wants to buy a large amount of a token on a DEX, enough to push its price up.1
- A searcher spots the large swap waiting in the mempool.1
- The searcher buys the token just before it, while it is cheaper.1
- The large swap goes through, at a worse price than it would have got, and pushes the price up further.1
- The searcher sells just after it, at the higher price the large swap caused.1
The same trick works around a large sale. Uniswap Labs describes it in general terms: bots insert their own transactions around yours, to profit from the price move your trade will cause.2
ethereum.org says people who are sandwiched face more slippage and worse execution.1 Uniswap Labs says sandwich bots prey on wide slippage tolerances, pushing the price just far enough to still trigger your swap.4
Not all MEV is bad
ethereum.org notes that some MEV helps. It says arbitrage between DEXs ensures users get the best, most correct prices for their tokens.1 IOSCO says bots can make markets more efficient, but can also mean worse execution and higher slippage for others.3
Private routes
One response is to keep a swap out of the public mempool, so bots can't see it coming. ethereum.org describes Flashbots as an independent project with a service that lets searchers send transactions to validators without revealing them in the public mempool.1
As of October 2026, Flashbots' own documentation says its Protect service sends transactions to a private mempool, hidden from frontrunning and sandwich bots.5 It also says users do not pay fees for failed transactions sent this way.5
Uniswap Labs suggests other steps too: routes that use private pools, limit orders, and a low slippage tolerance.4 It adds that no single tactic gets rid of harmful MEV forever.4
ethereum.org draws a line here. It warns that private, pay-to-play deals between traders and validators would weaken Ethereum's permissionless design.1 By contrast, it calls private channels to many competing block builders beneficial, partly because having several builders makes censoring impractical.1
We name Flashbots, Uniswap and CoW Protocol because their documents explain how these things work. Naming a tool is not a recommendation to use it.5,4
- Maximal extractable value (MEV). ethereum.org developer docs, last updated 26 February 2026.
- What is Slippage?. Uniswap Labs blog, 11 September 2025.
- IOSCO Decentralized Finance Report (OR01/2022). International Organization of Securities Commissions (read via the Internet Archive copy of 15 December 2024, because iosco.org refused our automated download), March 2022.
- How to Secure Your Swaps from MEV Attacks. Uniswap Labs blog, 24 October 2025.
- MEV Protection: Flashbots Protect overview. Flashbots documentation.
General education built from the publicly available sources listed above. Not financial, legal, tax or investment advice. Naming a company, project or regulator is not an endorsement either way. Last checked 2026-10-22. Terms and disclaimer.