Hashtag Web3 Logo

MEV: Maximal Extractable Value

8 min
advanced

Transaction ordering and execution price

Pending transactions can reveal trades and other actions before they are included in a block. Searchers and block builders can use that information when choosing transaction order.

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

A sandwich places transactions before and after a target trade, attempting to profit from its price impact.

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 additional execution cost depends on liquidity, order size, slippage limits, and transaction ordering. It is not a fixed percentage of every swap.

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

MEV estimates depend on which networks, transactions, and strategies a dataset can identify. Check those definitions before comparing totals from different sources.

MEV Type Who Benefits Who Pays
Arbitrage Market efficiency Nobody directly (neutral)
Liquidations Protocol solvency Undercollateralized borrowers
Sandwich attacks MEV searchers Every DeFi swap user
Front-running MEV searchers Original 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: Uses batch auctions and solver competition to reduce exposure to certain forms of MEV.
  • 1inch Fusion: Routes through private order flow to minimize front-running exposure.

4. Break Up Large Trades

Splitting an order can change its price impact, but it also adds fees and exposes more transactions. Compare quoted execution costs rather than assume splitting is always better.

MEV's Impact on Ethereum's Design

MEV-Boost lets participating validators obtain blocks from external builders through relays. The arrangement separates block construction from proposal while adding dependencies on builders and relays.

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 can worsen trade execution; exposure and losses vary by trade.
  • 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?