Blockchain

MEV: the Hidden Tax on Every DeFi Transaction

You send a transaction to Uniswap - to buy ETH for 10,000 USDC. Twelve seconds later you receive $150 less than you expected. No error, no failure - someone simply saw your transaction before everyone else and cut in front of it. This is not a bug, not a hack. This is MEV - the invisible tax paid by every DeFi user. Since 2020, bots have extracted over $600M from ordinary Ethereum transactions. How does this shadow market for transaction ordering work - and can you protect yourself?

  • **Sandwich attacks** cost DeFi users $1–3M every day. A single bot `jaredfromsubway.eth` earned over $6M in just a few months - entirely at the expense of ordinary Uniswap users
  • **MEV-Boost** is used by 90%+ of Ethereum validators and has increased their income by 50–100%. The block-building market has become a distinct industry with billions in volume
  • **Order Flow Auctions** (MEV-Share, CoW Protocol) return 70–90% of extracted MEV to users - a new paradigm where instead of losing money, the user receives a rebate

Предварительные знания

  • AMM: Uniswap and Constant Product
  • The Merge: From PoW to PoS

Frontrunning: Profiting from the Public Mempool

Before a transaction is included in a block, it sits in the **mempool** - a public waiting room visible to everyone. Every Ethereum node, every MEV bot, every searcher can see the contents of all pending transactions. **Frontrunning** is the practice of seeing a profitable pending transaction and submitting your own transaction first, with a higher gas price, to capture the profit.

Modern MEV infrastructure runs in milliseconds. MEV bots subscribe to the mempool via WebSocket connections to multiple nodes, run specialized code that evaluates each transaction's profitability within microseconds, and immediately broadcast a competing transaction. The "gas auction" happens automatically: the bot keeps raising its gasPrice until the expected profit exceeds the gas cost. EIP-1559 partially solved priority gas auctions - but MEV simply migrated to the builder level.

**Flashbots Protect** is a service that lets users route transactions through a private mempool. Instead of broadcasting to the public mempool, the transaction goes directly to block builders (via Flashbots MEV-Share). Bots cannot see it until it's already in the block. Result: no frontrunning, no failed transaction gas losses. Used through a special RPC endpoint (https://rpc.flashbots.net) - just change the RPC URL in MetaMask.

Why does a MEV bot set a higher gasPrice than the victim's transaction?

Sandwich Attacks: the Most Common MEV

A **sandwich attack** is the most widespread form of MEV in DeFi. Unlike simple frontrunning (which takes an opportunity away from the victim), a sandwich attack actively extracts value from the victim's own transaction. The name is literal: the victim's transaction is squeezed between two bot transactions - a frontrun (before) and a backrun (after).

**jaredfromsubway.eth** became the most famous sandwich bot in Ethereum history. In the first half of 2023, this single bot spent more on gas than any other address on the entire network - over $6 million. It focused on tokens on Uniswap V2 with high slippage tolerance (meme coins, new launches). Each individual sandwich brought in $50–$500, but with thousands of attacks per day the total was enormous. At its peak the bot consumed 7% of all Ethereum block space.

The main defense for users is a **low slippage tolerance**. Setting 0.1% instead of 1% makes a sandwich economically unviable for small trades - the bot's profit doesn't cover gas costs. But for large trades or volatile tokens, a tight slippage setting leads to frequent failed transactions ("Transaction reverted: insufficient output"). The alternative: **CowSwap** (batch auction based DEX, immune to sandwich attacks by design) or **Flashbots Protect** (private mempool). CoW Protocol uses a batch auction model where all orders within a period are settled at a single clearing price - no sequencing advantage to exploit.

Why does the bot's backrun transaction reliably profit after the victim's swap?

MEV-Boost: Block Building Market

After The Merge (September 2022), Ethereum switched to Proof-of-Stake. Validators replaced miners - but the MEV problem didn't go away. What changed was its distribution. **MEV-Boost**, developed by Flashbots, created a specialized market for block construction: instead of each validator building its own block, a competitive ecosystem of **searchers, builders, and relays** emerged.

**Searchers** are specialized bots that scan the mempool and blockchain in search of MEV opportunities. They submit **bundles** - ordered sets of transactions that must be included together, in order, or not at all. A typical bundle: [frontrun tx, victim tx, backrun tx]. The searcher pays the builder through a transaction at the end of the bundle that transfers part of the profit. **Builders** aggregate bundles from multiple searchers plus regular mempool transactions and assemble the most profitable block possible. Competition between builders means validators consistently capture 80–95% of MEV via the bidding process.

**Private order flow** is a major competitive advantage for builders. Wallets (MetaMask, Coinbase Wallet), DEX aggregators (1inch, Paraswap), and apps can route user transactions directly to a specific builder, bypassing the public mempool. This "exclusive order flow" guarantees that no one can frontrun those transactions. In exchange, users may receive MEV protection or cashback. Builders who secure exclusive order flow from major wallets win more blocks because they assemble more complete (and therefore more profitable) blocks.

Why does the relay hide block content from the validator until the header is signed?

PBS: Proposer-Builder Separation

MEV-Boost solves the MEV distribution problem, but it has a fundamental flaw: it is an **off-protocol** solution. Validators trust relays (centralized intermediaries), and builders depend on relay inclusion. If all relays go offline, validators produce empty or suboptimal blocks. **Proposer-Builder Separation (PBS)** is a proposal to bake the role separation **directly into the Ethereum protocol** (enshrined PBS, or ePBS).

**Why separate the proposer from the builder?** To keep validators decentralized. If proposers must build optimal blocks themselves, the winners are those with the most powerful infrastructure, the fastest mempool connections, and the most sophisticated MEV extraction algorithms. That concentrates power among a few large players. Separation allows: builders compete on MEV optimization (some centralization is acceptable), while proposers simply choose the highest bid (and can be anyone with 32 ETH).

**Builder centralization** is already a real problem. According to mevboost.org, in 2024 the top 3 builders (Flashbots, Beaverbuild, Titan) controlled over 80% of blocks. This creates risks: if two builders collude, they could censor transactions, manipulate MEV, or raise costs. ePBS doesn't solve builder centralization, but **limits their power** through inclusion lists and protocol-level guarantees.

**ePBS status (2025).** Enshrined PBS is under active development and included in Ethereum's long-term roadmap (the "The Scourge" section). Key proposals: EIP-7732 (ePBS), EIP-7547 (inclusion lists), MEV burn. Implementation is expected no earlier than 2026 due to the complexity of consensus-layer changes. In the meantime, MEV-Boost remains the de facto standard.

What key problem do Inclusion Lists solve in the context of PBS?

Order Flow: the Future of MEV

MEV is a consequence of the fact that **transaction ordering has value**. Whoever controls the order extracts value. So far we've examined how MEV is extracted and redistributed. But can the game itself be changed? **Order Flow Auctions (OFA)** are a new paradigm in which users sell the rights to their order flow and receive a share of MEV back, rather than losing it entirely.

**Encrypted mempools** are a radical approach to eliminating MEV. The idea: transactions are encrypted before entering the mempool and decrypted only after inclusion in a block. If a bot cannot see the contents of a transaction, it cannot copy it, frontrun it, or sandwich it. **Threshold encryption** distributes the decryption key among N nodes, and decryption requires the agreement of a majority. The **Shutter Network** project implements this approach on Ethereum.

**SUAVE (Single Unifying Auction for Value Expression)** is a Flashbots project to build a dedicated blockchain for MEV auctions. Instead of each blockchain solving MEV individually, SUAVE offers a unified platform where searchers, builders, and users interact through decentralized block building. SUAVE also addresses **cross-domain MEV** - the extraction of value from transactions that span multiple chains (Ethereum + Arbitrum + Optimism).

The future of MEV lies between two poles. **MEV minimization** (encrypted mempools, batch auctions like CowSwap) tries to eliminate MEV by removing informational advantages. **MEV redistribution** (OFA, MEV-Share, MEV burn) accepts MEV's inevitability and redirects the profits back to users or the network as a whole. In practice, a combination will likely prevail: encrypted mempools to protect against harmful MEV (sandwich attacks), while preserving legitimate MEV (arbitrage, liquidations), with redistribution through auctions.

**MEV on L2.** On rollups (Arbitrum, Optimism, Base) the situation differs: a centralized sequencer has full control over transaction ordering. This eliminates PGA and public frontrunning, but creates trust in the sequencer (it can extract MEV itself). Decentralized sequencing is the next frontier, where PBS-like mechanisms will be applied to L2.

MEV is a bug that can be completely eliminated. Encrypted mempools and batch auctions will destroy MEV, and all transactions will be fair.

MEV is a **fundamental property** of any system with ordered transactions. As long as transaction ordering matters, someone will extract value from that ordering. Encrypted mempools eliminate frontrunning and sandwiching, but **arbitrage between pools** (legitimate MEV, necessary for price efficiency) will continue to exist. Cross-domain MEV between L1 and L2 only grows as the ecosystem scales. The realistic goal is not MEV elimination, but its **minimization** (removing the harmful kind) and **redistribution** (returning profits to users and the network).

The misconception arises from conflating 'harmful MEV' (sandwich attacks, frontrunning) with 'useful MEV' (arbitrage, liquidations). Arbitrage synchronizes prices between DEXs and CEXs - without it, Uniswap could show ETH at $2,500 while Binance has it at $3,000. Liquidations in Aave protect the protocol from bad debt. Encrypted mempools would block useful MEV too, creating new problems. Fighting MEV is an engineering tradeoff, not an on/off switch.

MEV-Share returns part of the extracted MEV to the user. How is this achieved?

Key Takeaways

  • **Frontrunning** exploits the public mempool: bots see pending transactions and place their own before the victim by paying a higher gas price. Defense: private mempool (Flashbots Protect)
  • **Sandwich attacks** are the most widespread form of MEV: frontrun + victim tx + backrun. The bot's profit equals the user's loss. Slippage tolerance is the only user-level defense
  • **MEV-Boost** created a block-building market: searchers → builders → relay → proposer. Validators choose the block with the highest bid, capturing 80%+ of MEV through builder competition
  • **PBS (Proposer-Builder Separation)** will be built into the Ethereum protocol (ePBS), removing the dependency on centralized relays. Inclusion lists ensure censorship resistance; MEV burn ensures fair distribution
  • The invisible MEV tax mentioned at the start won't disappear: transaction ordering will always have value. But Order Flow Auctions, encrypted mempools, and ePBS are transforming MEV from a user loss into revenue for the entire ecosystem

Related Topics

MEV connects AMM pricing, gas economics, Ethereum consensus, and L2 scaling:

  • AMM: Uniswap and Constant Product — AMM is the primary source of MEV on Ethereum. Arbitrage between pools, sandwich attacks on swaps, and JIT liquidity generate 60%+ of all MEV
  • Gas: the Computation Model — Priority Gas Auctions (PGA) used to inflate the base fee as bots competed for position in a block. EIP-1559 partially addressed this, but MEV-Boost shifted the competition to the builder level
  • Ethereum 2.0: The Merge — The switch to PoS changed MEV: miners became validators, direct gas competition became a block auction via MEV-Boost. PBS is part of Ethereum's roadmap (The Scourge)
  • Rollups: L2 Scaling — On rollups, the centralized sequencer controls transaction ordering, creating its own MEV dynamics. Cross-domain MEV between L1 and L2 is a growing challenge that SUAVE aims to solve

Вопросы для размышления

  • If encrypted mempools eliminate frontrunning and sandwich attacks but also block useful arbitrage between DEXs - how would you resolve the tension between protecting users and maintaining market price efficiency?
  • MEV-Boost gave home validators access to MEV, but led to 3 builders controlling 80%+ of blocks. Did Ethereum become more or less decentralized as a result?
  • If SUAVE creates a unified block-building platform for all blockchains - won't that become a new centralization point? How is that different from traditional financial infrastructure?

Связанные уроки

  • alg-20-greedy
MEV: the Hidden Tax on Every DeFi Transaction

0

1

Sign In