EVMTools

What is MEV?

Learn about Maximal Extractable Value: frontrunning, sandwich attacks, Flashbots, and how to protect yourself.

MEV (Maximal Extractable Value) is one of the most important and misunderstood concepts in Ethereum. It refers to the profit that can be extracted by anyone who has the power to include, exclude, or reorder transactions within a block. MEV affects every user of decentralized finance, often invisibly adding costs to swaps, trades, and other on-chain activities. This guide explains what MEV is, how it works, who extracts it, and how you can protect yourself.

What is MEV?

Maximal Extractable Value (MEV) is the total value that can be extracted from block production beyond the standard block reward and gas fees. It is the profit available to whoever controls the ordering of transactions in a block.

The key insight is that transaction order matters. On Ethereum, the order in which transactions are executed within a block can create profit opportunities. If someone buys a large amount of a token on a DEX, the price increases. Knowing this trade is about to happen allows someone to buy the token first (at the lower price) and sell it after (at the higher price).

Think of it this way: Imagine you are in a physical marketplace and you overhear someone about to place a massive buy order for a commodity. If you can rush to buy that commodity before them and sell it to them at a higher price, that is MEV.

From Miner to Maximal Extractable Value

The term "MEV" was originally coined as "Miner Extractable Value" in the 2019 paper "Flash Boys 2.0" by Phil Daian and colleagues at Cornell. The paper documented how miners on Proof of Work Ethereum could reorder, insert, or censor transactions to extract profit.

After Ethereum's transition to Proof of Stake in September 2022, the term was retroactively renamed to "Maximal Extractable Value" since validators (not miners) now have the power to order transactions within blocks. The concept remains the same: whoever controls block production can extract value from transaction ordering.

MEV has grown enormously alongside DeFi. As more value flows through on-chain protocols, the opportunities for profitable reordering have multiplied. It has become a multi-billion dollar phenomenon that shapes Ethereum's infrastructure, economics, and user experience.

Types of MEV

MEV comes in several forms, some beneficial for the ecosystem and others harmful to users:

Frontrunning

A frontrunner detects a profitable pending transaction in the mempool and submits their own transaction with a higher gas price to be executed first. The frontrunner profits from the price impact of the victim's transaction.

Frontrunning Example:
1. Alice submits: Buy 100 ETH worth of TOKEN-X on Uniswap
   (Expected price: $1.00 per token)
2. Bot detects Alice's pending transaction in the mempool
3. Bot submits: Buy TOKEN-X before Alice (higher gas price)
   Bot buys at $1.00
4. Alice's transaction executes at $1.02 (worse price)
5. Bot sells TOKEN-X at $1.02 → profit = $0.02 per token

Sandwich Attacks

A sandwich attack is a more sophisticated form of frontrunning. The attacker places two transactions around the victim's transaction: one before (to push the price up) and one after (to sell at the inflated price).

Sandwich Attack Example:
1. Alice submits: Swap 10 ETH for TOKEN-X (2% slippage tolerance)
2. Bot detects Alice's pending swap

Transaction order in block:
  → Bot buys TOKEN-X (pushes price up by ~1%)
  → Alice's swap executes at 1% worse price
  → Bot sells TOKEN-X (captures the price difference)

Result: Bot profits ~$50-200, Alice gets fewer tokens than expected

Warning: Sandwich attacks are the most common form of harmful MEV affecting everyday users. Setting a lower slippage tolerance on DEX swaps reduces your exposure, but may cause your transaction to fail during volatile markets.

Backrunning

Backrunning involves placing a transaction immediately after another transaction to profit from the state change it creates. This is generally considered less harmful than frontrunning because it does not worsen the price for the original transaction.

A common backrunning scenario is arbitrage: after a large swap moves the price on one DEX, a backrunner arbitrages the price difference between that DEX and another, restoring price equilibrium.

Liquidations

DeFi lending protocols like Aave and Compound allow anyone to liquidate undercollateralized positions and earn a liquidation bonus (typically 5–10% of the collateral). MEV searchers compete to be the first to liquidate these positions, often paying high gas fees to ensure their liquidation transaction is included before competitors.

DEX Arbitrage

When the price of a token differs across DEXes, arbitrageurs profit by buying on the cheaper DEX and selling on the more expensive one in a single transaction. Unlike frontrunning, DEX arbitrage is generally beneficial because it corrects price inefficiencies and improves price consistency across markets.

DEX Arbitrage Example:
  TOKEN-X price on Uniswap:  $1.00
  TOKEN-X price on Sushiswap: $1.05

  Arbitrageur:
    1. Buy TOKEN-X on Uniswap at $1.00
    2. Sell TOKEN-X on Sushiswap at $1.05
    3. Profit: $0.05 per token (minus gas fees)

  After: Both DEXes now show ~$1.025 (prices converge)

How MEV Extraction Works

MEV extraction follows a general pattern regardless of the specific strategy:

  1. Mempool monitoring: Searchers run nodes and monitor the public mempool (the pool of pending transactions) for profitable opportunities. They analyze every pending transaction to determine if it creates an MEV opportunity.
  2. Opportunity identification: Sophisticated algorithms simulate the state changes of pending transactions to identify profitable reorderings, insertions, or exclusions.
  3. Bundle construction: The searcher creates a "bundle" — a set of transactions in a specific order that captures the MEV opportunity.
  4. Gas bidding: Before Flashbots, searchers competed by submitting transactions with extremely high gas prices under the pre-EIP-1559 fee model. This "priority gas auction" (PGA) caused gas price spikes for all users. Today, searchers compete by bidding directly to block builders.
  5. Execution: If the searcher's transaction is included in the right position within the block, they capture the profit.

The MEV Supply Chain: Searchers, Builders, Proposers

Post-Merge Ethereum has a structured MEV supply chain with three distinct roles:

Searchers

Searchers are specialized actors who monitor the mempool and identify MEV opportunities. They write custom software to detect profitable patterns and construct transaction bundles. Searchers compete fiercely: margins are razor-thin, and latency advantages measured in milliseconds can determine who captures the opportunity.

Block Builders

Block builders are entities that aggregate transaction bundles from multiple searchers, combine them with regular user transactions, and construct the most profitable possible block. They optimize for total block value and compete to have their block selected by the proposer. Major builders include Flashbots, BeaverBuild, and Titan Builder.

Proposers (Validators)

Proposers are Ethereum validators who have been selected to propose the next block. Using MEV-Boost, they receive bids from multiple builders and select the highest-paying block. The proposer earns the builder's bid as payment, which typically exceeds what they would earn from building the block themselves.

MEV Supply Chain:

Searchers     →    Builders      →    Proposers
(find MEV)         (build blocks)      (propose blocks)

1. Searchers identify MEV opportunities
2. Searchers send bundles to builders (with bids)
3. Builders construct optimal blocks from multiple bundles
4. Builders bid for block inclusion via MEV-Boost relay
5. Proposer selects the highest-paying block
6. Block is proposed to the network

Revenue split:
  Searcher keeps: MEV profit - bid to builder
  Builder keeps:  Sum of searcher bids - bid to proposer
  Proposer keeps: Builder's bid (on top of base consensus rewards)

Flashbots and MEV-Boost

Flashbots

Flashbots is a research and development organization focused on mitigating the negative externalities of MEV. They created several key pieces of infrastructure:

  • Flashbots Auction: A private channel between searchers and miners/validators that eliminates the need for gas price wars in the public mempool.
  • Flashbots Protect: A free RPC endpoint that users can add to their wallets to send transactions through a private mempool, protecting them from sandwich attacks.
  • MEV-Boost: The middleware that enables validators to outsource block building to specialized builders via an open marketplace.
  • SUAVE: Flashbots' research into a future decentralized block building architecture.

MEV-Boost

MEV-Boost is an open-source middleware that implements Proposer-Builder Separation (PBS) for Ethereum validators. Over 90% of Ethereum blocks are now built through MEV-Boost. Here is how it works:

  1. Builders construct blocks and submit them to relays.
  2. Relays validate the blocks and forward the highest bids to the proposer.
  3. The proposer selects the most profitable block (they only see the bid amount, not the block contents).
  4. The proposer signs the block header, committing to the selected block.
  5. The relay reveals the full block to the proposer, who broadcasts it to the network.

Proposer-Builder Separation (PBS)

PBS is the design principle of separating the roles of block building (transaction ordering and MEV extraction) from block proposing (consensus participation). This separation has several benefits:

  • Validator neutrality: Validators do not need to run sophisticated MEV extraction strategies. They simply select the highest-bidding block.
  • Reduced centralization pressure: Without PBS, validators with advanced MEV strategies would earn disproportionately more, leading to centralization.
  • MEV democratization: All validators benefit from MEV through builder bids, not just those running searcher bots.

Currently, PBS is implemented through MEV-Boost as a voluntary, out-of-protocol solution. Ethereum's roadmap includes plans to enshrine PBS into the protocol itself (ePBS), making it a native feature of the consensus layer.

Impact on Users

MEV has tangible costs for everyday Ethereum users:

  • Higher slippage: Sandwich attacks cause your DEX swaps to execute at worse prices than expected. A swap that should give you 1,000 tokens might only give you 980 tokens.
  • Failed transactions: During periods of intense MEV competition, transactions can fail if a searcher's competing transaction changes the state before yours executes. You still pay gas for the failed transaction.
  • Gas price inflation: Before Flashbots, MEV searchers engaged in priority gas auctions, driving up gas prices for everyone. This has been significantly mitigated by private transaction channels.
  • Hidden costs: MEV costs are often invisible. Users see their swap execute within their slippage tolerance and assume they got a fair price, not realizing they could have received more tokens without MEV.

Real Example with Numbers

StepActionTOKEN-X PriceCost/Revenue
1Alice wants to buy 10 ETH worth$1.00Expected: ~10,000 tokens
2Bot frontrun: buys $50K worth$1.00 → $1.015Bot spent $50,000
3Alice's swap executes$1.015 → $1.025Alice gets ~9,750 tokens (2.5% less)
4Bot backrun: sells tokens$1.025 → $1.01Bot profit: ~$375 (minus gas)

In this example, Alice paid ~$250 more than she should have (received fewer tokens), while the bot profited ~$375 minus gas costs. The gas cost for executing this sandwich on L1 might be $20 – $50. Use our Gas Fee Calculator to estimate the gas costs involved in MEV transactions.

MEV Protection Strategies

Several tools and strategies exist to protect users from harmful MEV:

Private Mempools

Instead of broadcasting your transaction to the public mempool (where searchers can see it), private mempools send your transaction directly to block builders. Popular options include:

  • Flashbots Protect: Free RPC endpoint that sends transactions through a private channel. Add it to MetaMask as a custom RPC.
  • MEV Blocker: A protection service by CoW Protocol and other partners that also refunds some MEV back to users.

MEV-Aware DEXes

Some decentralized exchanges have built-in MEV protection:

  • CoW Swap: Uses batch auctions that match orders off-chain, eliminating frontrunning opportunities.
  • 1inch Fusion: Routes orders through a network of professional market makers rather than on-chain AMMs.
  • UniswapX: Uses Dutch auctions and off-chain order routing to provide MEV-protected swaps.

User Best Practices

  1. Set tight slippage: Use the lowest slippage tolerance you are comfortable with (0.5% for stablecoins, 1–2% for volatile tokens).
  2. Split large trades: Breaking a $100K swap into multiple smaller swaps reduces the profit available to sandwich attackers.
  3. Use limit orders: Limit orders on DEX aggregators execute at your specified price or better, avoiding MEV.
  4. Trade on L2: Layer 2 networks with centralized sequencers (FCFS ordering) have less MEV.

Frequently Asked Questions

Is MEV illegal?

MEV extraction is not illegal in most jurisdictions. Unlike traditional financial markets where frontrunning is regulated, blockchain transactions occur in a permissionless environment without equivalent regulations. However, the ethics of MEV extraction, particularly sandwich attacks that harm retail users, are widely debated in the crypto community.

How much MEV is extracted on Ethereum?

Hundreds of millions of dollars in MEV have been extracted on Ethereum since DeFi became popular. The exact amount is difficult to measure because not all MEV is visible on-chain. According to Flashbots data, billions of dollars in cumulative MEV have been extracted since 2020, with daily extraction ranging from hundreds of thousands to millions of dollars during high-activity periods.

How can I protect myself from MEV?

You can protect yourself by: using MEV-protected RPC endpoints like Flashbots Protect or MEV Blocker, which send your transactions through private mempools; setting low slippage tolerance on DEX swaps; using DEX aggregators with MEV protection built in; breaking large trades into smaller ones; and using L2 networks where MEV is less prevalent.

What is the difference between MEV and front-running?

Frontrunning is one specific type of MEV extraction. MEV (Maximal Extractable Value) is the broad concept of any profit that can be extracted by controlling transaction ordering within a block. Frontrunning specifically means placing your transaction before another user's transaction to profit from the price impact. Other forms of MEV include backrunning, sandwich attacks, liquidations, and cross-DEX arbitrage.

Does MEV exist on Layer 2 networks?

Yes, MEV exists on L2 networks, but it is less prevalent because most L2s use a centralized sequencer that processes transactions in first-come-first-served (FCFS) order. This reduces opportunities for frontrunning. However, as L2s decentralize their sequencers, MEV may become more relevant. Some L2s are exploring MEV-resistant designs like encrypted mempools and fair ordering protocols.

Understand Your Transaction Costs

MEV adds hidden costs to your transactions. Use our Gas Fee Calculator to estimate your gas costs, and learn more about how DeFi works in our What is DeFi? guide.

Related Tools & Guides