Exploring the World of MEV: What It is and How It Works

MEV, short for Maximal Extractable Value (previously Miner Extractable Value), it refers to the value that a miner or validator is able to obtain from reordering transactions within the blocks they produce, on top of the block reward and transaction fees they normally benefit from.

An illustration on how validators utilize MEV

MEV is a design by-product from block building since the current blockchain does not have rules on content ordering in the block. By design, validators can arrange the ordering of the transactions before submitting them to the block. The order is usually arranged from the highest to lowest gas fee to maximize profit.

Most of the MEV on Ethereum is currently done via an out-of-protocol standard called MEV-Boost. There are generally a few entities involved in the process of MEV, including:

  • MEV Bots

    • They suggest ways to arrange transactions within a block in such a way that there is max profit to be made
    • For example, placing one transaction ahead of another to arbitrage the difference
    • In this block, you can see 2 addresses labelled MEV Bot in the earliest transactions of the block:
  • MEV Builder

    • They specialize in picking out the best arrangement of transactions by multiple MEV Bots to build transactions in a block
    • In this block, it's Flashbots: Builder, which is also a Fee Recipient:
  • Block Proposer/Producer

    • They are network validators who randomly get a chance to propose the transactions to be included in a specific block
    • The only entity that is actually in-protocol out of the 4 listed here
    • In this block, it's Rocket Pool Smoothing Pool
  • MEV Relay

    • The middleman connecting the Block Proposer with different MEV Builders
    • Typically for a given block, the selected proposer will pick the MEV Builder that offers transaction arrangement with the highest reward
    • Etherscan doesn't track who the MEV Relayer is for this block as it is done offchain

Examples of MEV:

1. Arbitrage

Making, buy and sell transactions of the same asset at the same time and profiting from a difference in prices. Typically done across different markets, it is also possible to do by manipulating transaction ordering within the same block. MEV searchers may use MEV bots to identify and exploit price discrepancies between different exchanges. For example, if the price of Ethereum is higher on one exchange than on another, an MEV bot may buy Ethereum on the cheaper exchange and sell it on the more expensive exchange, extracting value in the process.

An illustration of the arbitrage transaction at hash 0x01afae47b0c98731b5d20c776e58bd8ce5c2c89ed4bd3f8727fad3ebf32e9481

2. Sandwich Attack

To understand sandwich attacks, we must first understand front and back running. Front running is the act of monitoring the transaction pool for a particular type of transaction (such as purchasing an Ethereum domain name), then submitting the same transaction with a higher gas fee to ensure it goes through instead of the targeted transaction. The MEV bots are often used to monitor the Ethereum blockchain for large trades or orders, and then submit their own trades or orders ahead of the large ones, in the hopes of profiting from the price movements that result.

As for back running, instead of submitting the transaction before that particular transaction, the back run transaction is being submitted right after that to take advantage of the previous one immediately afterwards (such as executing a liquidation of an on-chain loan after the oracle price update).

Note: Txn = Transaction

Back to the sandwich attack, it is the act of monitoring the transaction pool for a sufficiently valuable transaction (such as a large trade on a decentralized exchange), then submitting two transactions 'sandwiching' the target transaction. The first one immediately before the target pushes the price in one direction, while the second one immediately after the target does the opposite. Hence, utilizing both front running and back running in one attack. The attacker profits from the arbitrage between their two transactions.

For example, suppose Alice wants to send a large amount of cryptocurrency to Bob. The attacker, who is aware of Alice's transaction, submits their own transaction to buy a small amount of cryptocurrency from Alice at a low price, and then immediately submits a second transaction to sell the same amount of cryptocurrency to Bob at a higher price. By doing this, the attacker is able to extract value from Alice's and Bob's transactions, essentially "sandwiching" their own transactions between the two.

MEV plays a key role in sandwich attacks, as the attacker is able to extract value through the exploitation of inefficiencies or vulnerabilities in the network. Sandwich attacks have the potential to negatively impact the efficiency and security of a blockchain network, and as a result, they are often considered malicious or unethical by members of the blockchain community. Some blockchain networks have implemented measures to mitigate the potential negative effects of sandwich attacks on the network.

An example of a sandwich transaction:

The MEV bot identifies a regular transaction in the block that it wants to execute the sandwich attack on. The bot then arranges its own transactions in a way that they come before and after the regular transaction.

Sandwich attack in action within block 17178637

The MEV bot detects that a user intends to buy a token and inserts a transaction before to purchase at a lower price than the user. It then queues a sell transaction after the user's transaction, earning a profit of 0.02 ETH.

Example of a sandwich transaction

3. Liquidation

In Defi, it refers to the process of selling assets off from an under-collateralized loan. Please refer to this article for more information on liquidation. On how it can be exploited, the MEV bot monitors a platform like Aave for signs of imminent liquidation, such as a trader's position becoming overleveraged (i.e., the value of their collateral falls below a certain threshold).

When the MEV bot detects that a liquidation is imminent, it submits its own trades or orders ahead of the liquidation in order to profit from the price movements that result. The MEV bot may also manipulate transaction fees in order to outbid other transactions and secure a higher position in the order, potentially at the expense of traders who are being liquidated.

The good in MEV

At this point, we may come to the conclusion that MEV is bad for the blockchain ecosystem. But, in reality, it is not all bad. Searchers may use MEV to arbitrage between different exchanges, effectively providing liquidity to the market and reducing price discrepancies. They could also use MEV to identify and exploit inefficiencies or vulnerabilities in the network, leading to improved efficiency. On the other hand, it can incentivize the development of new tools and techniques to extract value from the network, which may drive innovation and improve the overall ecosystem.

Faiz Adnan
Faiz Adnan
Last updated: