hackquest logo
A

Alok

Everywhere

4

Artículo

3994

Ver

1

Seguidores

0
0

MEV Exposed: The Invisible Auction Controlling Every Block

Alok
2026-02-20 20:29
0
0
MEV Exposed: The Invisible Auction Controlling Every Block

0. Introduction

Imagine this.

You submit a trade on a decentralized exchange.
You double-check the price.
You confirm the gas fee.
You click Swap.

A few seconds later, the transaction completes — but you receive slightly fewer tokens than expected.

Nothing failed.
Nothing was hacked.
The blockchain worked exactly as designed.

Yet… someone profited from your trade before it even landed on-chain.

And it was completely legal.

Welcome to the world of Maximal Extractable Value (MEV) — the invisible economy running beneath every block.


1. The 5W of MEV — Who, What, When, Where, Why

What?
Maximal Extractable Value (MEV) is the maximum profit available to an actor that can control transaction inclusion and ordering in a block — originally “Miner Extractable Value” but generalized to validators/proposers/any block producers. In practice this means capturing arbitrage, reordering transactions to front-run or sandwich trades, deciding whether to include or censor transactions, and other actions that extract value beyond plain gas fees and block reward.

Who?

  • Searchers — automated bots or traders that scan transaction flow (mempools, pending txs) for opportunities.

  • Builders — parties that assemble full blocks (choosing order and which txs) to maximize revenue.

  • Relays — private or semi-private services that accept builder blocks and forward the best to proposers (used in MEV-Boost style setups).

  • Proposers / Validators — the node that ultimately submits a block to the chain and can accept the builder’s block in exchange for a payment.
    These roles form the “MEV supply chain.”

When & Where?
MEV exists whenever ordered transactions are jointly combined in blocks and value can be created by ordering/censoring them — that’s any programmable blockchain with sequenced blocks (Ethereum, many L2s, Solana, BSC, etc.). Its surface grows with DeFi complexity and throughput. Studies and regulators have documented MEV across chains and on rollups.

Why does it matter?
Because MEV changes incentives: it can hurt end-users (worse execution or higher costs), incentivize spam and on-chain waste, centralize block production, and even enable censorship. At the same time, organizing MEV markets can capture value more transparently and reduce harmful side-effects — hence the rush of innovations like private relays and proposer-builder separation.


2. How MEV actually works — the mechanics

At a high level:

  1. Opportunity discovery — searchers monitor the public mempool (or private transaction outlets) for transactions that create extractable value: big swaps, liquidations, cross-DEX price differences, or NFT mints.

  2. Strategy formation — searcher computes a profitable sequence of transactions (e.g., buy-then-sell on another DEX, or sandwich: buy before victim, sell after) and computes gas/fees and probability of success.

  3. Bundle construction — searcher packages transactions into a bundle (group), often with a conditional payment to the block producer if the bundle is included in a block.

  4. Submission channel — bundle is sent to a builder/relay or broadcast in the mempool. Builders integrate the bundle when constructing a candidate block.

  5. Block selection — proposers select the most profitable block they receive (or build themselves) and submit it to the chain. MEV revenue gets split according to arrangements (builder -> proposer -> searcher payments). Flashbots/MEV-Boost formalize parts of this pipeline.

Important nuance: ordering matters. For many DeFi primitives (AMMs), the price impact of a swap makes order critical. Small changes in ordering can convert a profitable arbitrage into a loss — hence the arms race.


3. Categorization: main families of MEV strategies (with simple examples)

1. Pure arbitrage

When two markets price the same asset differently (Uniswap v3 vs Sushi, or different L2 rollups), a searcher can buy on the cheaper market and sell on the pricier one inside the same block — pocketing the price delta minus fees.

Numeric toy example:

  • DEX A: 1 WETH = 2000 USDC

  • DEX B: 1 WETH = 2010 USDC
    Buy 1 WETH on A for 2000 USDC and sell on B for 2010 USDC → gross profit 10 USDC minus gas/fees.

(We’ll simulate this in the Python example below.)

2. Sandwich attacks (front-run + back-run)

Most harmful to casual traders. If a large swap will move price, an attacker can submit: (1) a buy before the victim (front-run), (2) the victim’s transaction, (3) a sell after the victim (back-run). This inflates the victim’s price and extracts the difference.

Illustration: victim intends to buy 10,000 tokens, pushing price upward. Attacker buys first to push price slightly up, victim buys at the now higher price, attacker sells into that inflated price.

Sandwich attacks are front-running combined with back-running and are explicitly called out in many MEV explainers.

3. Liquidation captures

On lending platforms, a large undercollateralized loan becomes liquidatable. Searchers race to present the liquidation transaction in the right order so they capture the liquidation bonus. They may pay high gas fees (or bundle and pay the proposer) to ensure inclusion.

4. Back-running

Executing immediately after a target transaction to capture residual arbitrage left by the target. Less harmful than sandwiching but still extractive.

5. Spam-based & reorg-enabled strategies

On high-throughput or fast-finality chains, attackers may spam small transactions or duplicate them to tip ordering dynamics (or induce reverts). Research shows spam-based arbitrage and revert strategies have grown with rollups and low gas costs.


4. The MEV ecosystem roles (technical levels)

Role

Core Function

Technical Responsibilities

Impact on MEV Extraction

Searchers / Bots

Identify and execute MEV opportunities

• Real-time mempool listening
• Strategy engine (arbitrage, sandwich, liquidation logic)
• Price oracle integration
• Trade simulation engine
• Transaction builder / bundle creator

Directly extract MEV by crafting profitable transaction sequences

Builders

Construct optimized blocks

• Collect bundles from searchers
• Solve block-ordering optimization problem
• Maximize total block revenue
• Decide transaction ordering

Determine which MEV strategies actually make it into a block

Relays

Intermediary between builders and proposers

• Aggregate blocks from multiple builders
• Provide proposer interface (e.g., MEV-Boost model)
• Add privacy protections
• Maintain ordering guarantees

Enable off-chain block auctions and reduce direct proposer-searcher interaction

Proposers / Validators

Final block selection authority

• Select most profitable candidate block
• Validate block correctness
• Propose block to the network

Capture MEV revenue by choosing highest-bid block (under PBS model)

Exchanges / DEXs / Protocols

Define the trading environment

• AMM curve design
• Slippage tolerance logic
• Fee model
• Liquidation rules
• Quotas & rate limits

Protocol design determines how much MEV is possible and what strategies emerge


5. Ecosystem innovations & defenses

  • Proposer-Builder Separation (PBS) — splits block building from proposing to create an open market for blockspace and reduce harmful mempool-based racing. Implementations like MEV-Boost operationalize this for Ethereum. PBS can improve fairness but also alters incentives and may centralize builders if not carefully governed.

  • Private relays / direct-to-builder submission — let users submit transactions directly to builders/relays so they aren’t visible in the public mempool (reducing front-running). Flashbots Protect is an early example.

  • Protocol-level mitigations — rethinking DEX primitives (TWAMMs, batch auctions), enforcing transaction ordering rules (e.g., FCFS vs auction), or introducing verifiable randomness in ordering. Research continues because every mitigation has trade-offs. Recent academic work highlights potential side-effects of enshrined PBS choices.

  • Regulatory & monitoring responses — authorities and financial supervisors are studying MEV’s market impacts; e.g., ESMA and similar bodies are tracking MEV as a market integrity topic.


6. Simulate arbitrage in Python (safe-to-run educational code)

Important: This sample is strictly simulative. It computes arbitrage profit given pool states — it does not interact with real blockchains, mempools, or submit transactions. Use it to practice reasoning and math.

Save as simulate_arbitrage.py and run with python3 simulate_arbitrage.py.

# simulate_arbitrage.py# Simple simulation of constant-product AMM arbitrage between two pools.# Educational only: no network calls, no transaction submission.

from math import sqrt

class AMMPool:
    def __init__(self, reserve_x, reserve_y, fee=0.003):
        self.x = reserve_x
        self.y = reserve_y
        self.fee = fee  # e.g., 0.003 = 0.3%

    def price(self):
        return self.y / self.x

    def swap_x_for_y(self, dx):
        """Swap dx of X for Y; returns dy out and updates reserves."""
        assert dx > 0
        dx_after_fee = dx * (1 - self.fee)
        new_x = self.x + dx_after_fee
        new_y = (self.x * self.y) / new_x
        dy = self.y - new_y
        self.x = new_x
        self.y = new_y
        return dy

    def copy(self):
        return AMMPool(self.x, self.y, self.fee)

def find_best_arbitrage(pool_a, pool_b, max_dx=10000):
    """Brute-force search (educational only): try dx in grid and compute profit."""
    best = {'dx': 0, 'profit': 0}
    for dx in [i * 0.1 for i in range(1, int(max_dx*10))]:
        pa = pool_a.copy()
        pb = pool_b.copy()
        # Buy Y with X on pool A
        dy = pa.swap_x_for_y(dx)
        # Sell Y on pool B (swap y for x)
        # To sell dy of Y to pool_b, we implement symmetric function:
        # swapping dy (Y) for X on pool_b:
        dy_after_fee = dy * (1 - pb.fee)
        new_y = pb.y + dy_after_fee
        new_x = (pb.x * pb.y) / new_y
        dx_returned = pb.x - new_x

        profit = dx_returned - dx  # net X profit
        if profit > best['profit']:
            best = {'dx': dx, 'profit': profit}
    return best

if __name__ == "__main__":
    # Example: Pool A sold cheaply, Pool B is pricier
    pool_a = AMMPool(reserve_x=1000, reserve_y=2_000_000)  # X: WETH, Y: USDC-like
    pool_b = AMMPool(reserve_x=900, reserve_y=1_809_000)

    result = find_best_arbitrage(pool_a, pool_b, max_dx=5)
    print("Best arbitrage plan (X amount in):", result)

How to use & learn from it

  • Tweak reserves to see how the opportunity appears/disappears.

  • Add a simple gas model: subtract an estimated gas-cost (in X) from profit to see net profit thresholds.

  • Extend the script to model slippage, failure probabilities, and bundle payments (simulation only).


7. Where MEV is most (and least) visible — chains & topologies

Chain / Topology

MEV Visibility Level

Why It’s Visible (or Not)

Dominant MEV Patterns

Market Structure & Tooling

Key Risk Factors

Ethereum (L1)

🔴 Very High (Most Transparent & Studied)

• Public mempool
• Large DeFi liquidity • High transaction value
• Mature MEV research ecosystem

• Sandwich attacks • Arbitrage
• Liquidation races • Back-running

• Flashbots ecosystem
• MEV-Boost
• Emerging PBS (Proposer-Builder Separation)
• Formalized block auctions

• Builder centralization
• Blockspace auctions concentration
• Complex incentive dynamics

Solana

🟠 Moderate–High (Different Structure)

• Leader-based scheduling
• Low latency
• No traditional public mempool like Ethereum

• Validator-based extraction
• Spam-based arbitrage
• Revert/spam strategies
• Jito-related block tips

• Validator-integrated MEV
• Specialized infra (e.g., block engines)

• Spam congestion • Latency races
• Validator concentration

Other EVM Chains (BSC, Avalanche, etc.)

🟡 Moderate

• Public mempools (similar to Ethereum) • Shorter block times • Lower fees → more experimentation

• Arbitrage
• Sandwiching
• Liquidation captures

• Less mature PBS markets
• Fewer formal relay systems

• Centralized validator sets
• Opaque ordering practices

Rollups (Optimism, Arbitrum, etc.)

🟢 Lower Public Visibility (But Growing)

• Sequencer-controlled ordering
• Often private mempools
• Centralized sequencing

• Sequencer-level arbitrage
• Cross-domain arbitrage (L1 ↔ L2) • Delayed liquidation capture

• Single sequencer model (currently)
• Limited public builder competition

• Sequencer power concentration
• Opaque ordering policies


8. Structural Differences That Affect MEV Visibility

Factor

High MEV Visibility When…

Lower Visibility When…

Mempool Transparency

Public mempool (Ethereum)

Private / restricted mempool

Block Time

Slower block times (more observable ordering games)

Extremely low latency systems

Liquidity Depth

Deep DeFi markets

Thin liquidity ecosystems

Sequencing Model

Competitive builders

Centralized sequencer

Research & Tooling

Open MEV tooling & dashboards

Opaque internal systems


9. Ethics, legal & security considerations

  • MEV extraction can be legal but ethically fraught — front-running and sandwiching harm ordinary users and can undermine confidence in DeFi markets.

  • Researchers, defenders, and some builders advocate moving MEV extraction into transparent, on-chain markets (auctions) or private channels that reduce user harm.

  • If you practice MEV engineering to learn — use local forks, testnets, and simulated environments only. Do not deploy or test strategies on mainnet against real users without explicit, ethical justification and permission.


10. Defending as a dApp developer or security engineer

  1. Reduce surface: enforce slippage bounds, single-transaction limits, and conservative defaults in front-ends.

  2. Private tx submission: allow users to submit transactions through private relays to avoid mempool visibility. (There are trade-offs around trust.)

  3. Design for robustness: consider batch auctions, Time-Weighted Average Market Makers (TWAMMs), or variable fee curves to limit extractable opportunities.

  4. Monitor: instrument your dApp with mempool watches and alerting on unusual sandwiching/failed tx patterns.

  5. Educate users: show slippage/cost warnings and enable advanced users to choose execution pathways.


11. Resources & further reading (selected)

  • Flashbots / MEV-Boost docs and GitHub (how PBS/MEV-Boost works).

  • a16z MEV explainer (good practitioner primer on sandwich and other attacks).

  • Academic studies on PBS / ePBS and MEV economics (papers and arXiv).

  • Chain-specific notes (Solana MEV intros, rollup studies).

Category

Resource Name

Focus Area

Best For

Official Link

Infrastructure Docs

Flashbots MEV-Boost Documentation

How MEV-Boost works, PBS model, relays & builders

Validators, infra engineers

https://boost.flashbots.net

Source Code

MEV-Boost GitHub Repository

Implementation details, APIs, builder integration

Developers & researchers

https://github.com/flashbots/mev-boost

Practitioner Explainer

a16z “MEV Explained”

Clear breakdown of sandwich, arbitrage, liquidation MEV

Beginners → Intermediate

https://a16zcrypto.com/posts/article/mev-explained/

Flashbots Research Blog

MEV & Scaling Articles

MEV economics, block markets, decentralization

Intermediate → Advanced

https://writings.flashbots.net

Academic Research

“SoK: MEV Countermeasures” (arXiv)

Systematic overview of MEV defenses

Security engineers & researchers

https://arxiv.org/abs/2212.05111

PBS Research

Enshrined PBS (ePBS) Paper

Formal PBS design & Ethereum roadmap impact

Protocol researchers

https://arxiv.org/abs/2601.12989

MEV Economics Study

“The Price of MEV” (Game Theory)

Economic modeling of MEV extraction

Advanced learners

https://arxiv.org/abs/2208.13464

Block Market Study

“Time to Bribe” Paper

Builder competition & block auction dynamics

Advanced researchers

https://arxiv.org/abs/2305.16468

Solana-Specific Research

Solana MEV Analysis (ETH Zurich Study)

MEV behavior in fast-finality chains

Multi-chain researchers

https://tik-old.ee.ethz.ch/file//bdc928e5d6bfd3b11ea0787c0bdf0ab9/_Bait__Solana_MEV.pdf

Cross-Chain Overview

Chainstack MEV Overview

Differences between Ethereum & Solana MEV

Comparative learners

https://chainstack.com/what-is-mev-and-how-does-solana-solves-its-mev-issues/


12. Final thoughts — a forward-thinking view

MEV is not a bug that will simply disappear — it’s a byproduct of programmable, ordered value transfer. The industry is moving toward managing MEV rather than pretending it doesn’t exist: structuring auctions, private channels, and protocol-level changes that reduce harm while keeping incentives aligned.

  • MEV is structural, not a flaw.
    As long as transactions are ordered in blocks, value can be extracted from that ordering.

  • Ordering power = economic power.
    Control over transaction sequencing is one of the most valuable positions in blockchain systems.

  • Users often subsidize sophistication.
    Without protections, everyday traders unintentionally pay for advanced bots’ profits.

  • Incentive design shapes outcomes.
    Protocol rules, fee models, and sequencing policies determine whether MEV becomes toxic or productive.

  • Transparency beats chaos.
    Structured markets like PBS and block auctions aim to reduce harmful racing and hidden extraction.

  • Centralization is the hidden risk.
    Builder concentration and private order flow can quietly shift power away from the broader network.

  • The future is about managing MEV, not eliminating it.
    The goal is minimizing harm while preserving efficient price discovery and market balance.

Original
Ecosistema:Ethereum
Tema:DeFi
Etiqueta:
MEV
DeFi
Blockchain Economics
Actualizado el2026-02-20 20:48
0 / 1000