DeFi

MEV (maximal extractable value)

Also called: MEV · maximal extractable value · miner extractable value · sandwich attack

Definition

MEV, or maximal extractable value, is the profit that block producers and specialised bots can make by choosing, inserting or reordering transactions inside a block, often at the expense of ordinary users.

How MEV works

Pending transactions wait in a public mempool before they are included in a block. Bots, called searchers, watch it and pay to have their own transactions placed before or after yours. Block builders and validators pick the most profitable order.

Some MEV is neutral or helpful, such as arbitrage that keeps DEX prices in line and liquidations that keep lending protocols solvent. The harmful kind for users is the sandwich attack: a bot buys just before your swap, lets your trade push the price up, then sells right after.

You can reduce exposure by setting a tight slippage tolerance, splitting large swaps, using DEX aggregators or wallets that offer MEV protection, and sending transactions through private RPC endpoints that do not broadcast to the public mempool.

Example

Suppose you swap 10,000 USDC for a token on a DEX with a 3 percent slippage tolerance. A bot sees the pending trade and buys first, pushing the price up 2 percent. Your swap fills at that worse price, so you receive about 2 percent fewer tokens, roughly 200 USDC worth. The bot then sells into the higher price and keeps the difference minus gas. With a 0.5 percent slippage limit, the attack would not have been worth doing, because the bot could not push the price that far without your swap failing.

Common mistakes

  • Setting a high slippage tolerance on large swaps of thinly traded tokens.
  • Assuming MEV only exists on Ethereum; it appears on many chains with public transaction ordering.
  • Paying for MEV bot software sold on social media, a common scam.

Learn and practise

FAQ

What is a sandwich attack?

A bot places a buy before your swap and a sell after it, profiting from the price move your trade causes. You get a worse price.

Does MEV affect centralized exchange trades?

Not in the same way. Trades on a centralized exchange are matched off-chain, so public mempool MEV does not apply, though deposits and withdrawals still go on-chain.