Hashtag Web3 Logo

MEV: Maximal Extractable Value

8 min
advanced

The Dark Forest

In January 2020, researcher Dan Robinson published a paper called "Ethereum is a Dark Forest." The thesis: Ethereum's public mempool is a hostile environment where automated bots ruthlessly extract value from ordinary users' transactions. Any profitable opportunity visible on-chain will be captured by a bot before a human can act.

MEV — Maximal Extractable Value — is the profit that can be extracted by manipulating the order, inclusion, or exclusion of transactions within a block.

Sandwich Attack 1. Bot Front-Runs Buys token FIRST Price goes UP ↑ 2. Your Swap Executes at worse price You get fewer tokens 😞 3. Bot Back-Runs Sells at higher price Pockets difference 💰 🛡️ Protection: Use private RPC (Flashbots Protect) Your TX is hidden from bots → no sandwich possible

How Transactions Get Ordered

When you submit a transaction on Ethereum, it doesn't execute immediately. It enters the mempool — a public waiting area where pending transactions sit until a validator includes them in a block.

Validators have complete discretion over transaction ordering within their block. They can:

  • Reorder transactions to maximize their own profit
  • Include their own transactions at specific positions
  • Exclude transactions entirely

This power is the root of MEV.

The Three Types of MEV

1. Front-Running

A bot sees a profitable transaction in the mempool and submits the same transaction with a higher gas price to execute first.

Example: You spot a new token listing on Uniswap and submit a buy order. A bot sees your pending transaction, submits its own buy with higher gas, executes first at the lower price, and then sells to you at the higher price.

2. Sandwich Attacks

The most common MEV strategy targeting everyday DeFi users.

Mempool state:
 Your transaction: Swap 10 ETH → USDC on Uniswap (slippage tolerance: 1%)

Bot's attack:
 1. BUY: Bot buys USDC with 50 ETH (gas: 100 gwei) → executes FIRST
 Price of USDC increases due to the buy pressure
 2. YOUR TX: Your swap executes at the now-worse price
 You receive fewer USDC than expected (within your 1% slippage)
 3. SELL: Bot sells its USDC back for ETH (gas: 90 gwei)
 Bot profits from the price difference it created

The bot's profit comes directly from the price impact on your trade. You paid ~0.5-1% more than you should have. On a $10,000 swap, that's $50-100 going to the bot.

3. Arbitrage

Arbitrage bots equalize prices across DEXs. If ETH is $2,000 on Uniswap and $2,010 on SushiSwap, a bot simultaneously buys on Uniswap and sells on SushiSwap, pocketing the $10 difference.

Unlike sandwiching, arbitrage is generally considered beneficial — it keeps prices consistent across markets.

The Scale of MEV

Flashbots data shows that over $600M in MEV was extracted on Ethereum in 2023 alone. The real number is likely higher because not all MEV is publicly attributable.

MEV TypeWho BenefitsWho Pays
ArbitrageMarket efficiencyNobody directly (neutral)
LiquidationsProtocol solvencyUndercollateralized borrowers
Sandwich attacksMEV searchersEvery DeFi swap user
Front-runningMEV searchersOriginal transaction submitter

How to Protect Yourself

1. Use a Private RPC

Instead of broadcasting your transaction to the public mempool, send it through a private relay.

  • Flashbots Protect: Free. Add https://rpc.flashbots.net as a custom RPC in MetaMask.
  • MEV Blocker: Free. Maintained by CoW Protocol. Refunds a portion of extracted MEV back to you.

2. Set Tight Slippage Tolerance

Lower slippage tolerance = less room for sandwich bots. But too tight and your transaction may fail.

  • Stablecoin swaps: 0.1-0.3%
  • Major tokens (ETH, BTC): 0.5-1%
  • Small-cap tokens: 1-3% (higher volatility)

3. Use MEV-Aware DEX Aggregators

  • CoW Swap: Batch auctions that match orders off-chain, eliminating MEV by design.
  • 1inch Fusion: Routes through private order flow to minimize front-running exposure.

4. Break Up Large Trades

A $100,000 swap is a much more attractive target than ten $10,000 swaps. The price impact (and therefore MEV profit) scales with order size.

MEV's Impact on Ethereum's Design

MEV is not just a user problem — it affects Ethereum's architecture. Flashbots built MEV-Boost, which separates the roles of validators (who propose blocks) and builders (who construct the optimal block). Over 90% of Ethereum blocks now use MEV-Boost.

Ethereum's roadmap includes Proposer-Builder Separation (PBS) as a protocol-level solution, formally separating block building from block proposing to reduce centralization pressures from MEV.

Key takeaways

  • MEV is profit extracted from manipulating transaction ordering within blocks. It is an inherent property of public blockchains with transparent mempools.
  • Sandwich attacks are the most common form — they cost everyday DeFi users 0.5-1% on every swap.
  • Use private RPCs (Flashbots Protect) and MEV-aware DEXs (CoW Swap) to protect your transactions.
  • Arbitrage MEV is beneficial (market efficiency). Sandwich MEV is extractive (user cost).

Quiz: MEV: Maximal Extractable Value

1 / 5

What is MEV?