​​This article aims to provide insight into maximal extractable value (MEV) and how it is extracted. If you are unfamiliar with decentralized finance (DeFi), consider reading our introductory articles on DeFi, blockchain, and cryptocurrency here first. You might also want to read our articles on Ethereum, the Merge, and consensus mechanisms before reading this article.

An Introduction to MEV

Maximal extractable value (MEV) refers to the maximum profit miners or validators can gain from excluding, including, or reordering transactions in a block that is being generated. MEV is earned on top of the usual block reward and gas fees, so it is sometimes seen as an “invisible tax” on Ethereum users.

MEV was previously known as “miner extractable value” since this concept grew popular because of miner activity on the Ethereum chain before the Merge. After moving from Proof-of-Work (PoW) to Proof-of-Stake (PoS), this concept no longer only applies to miners but validators as well. 

The concept of MEV gained prominence in August 2020 when two researchers, Dan Robinson and Georgios Konstantopoulos, released an article calling Ethereum’s mempool a “dark forest” because of its predatory environment filled with bots ready to capture MEV. It is important to note that although MEV is primarily associated with Ethereum, it is not an Ethereum-only issue. Chains similar to Ethereum can face MEV-related problems too. 

Performance of MEV

MEV activity has grown tremendously since early 2020, with a cumulative gross profit exceeding US$675M among all MEV transactions. Projects focused on building products to capture MEV, such as Flashbots and Manifold Finance, are constantly entering the space.

How Does MEV Work in Proof-of-Work Chains?

The Miners

In pre-Merge Ethereum, or on PoW chains, miners are responsible for selecting and arranging user transactions from the mempool, a pre-chain storage area where pending transactions await confirmation. They then add these transactions to the next block. By default, miners choose transactions with the highest gas or transaction fees to optimize profit. However, since miners run the contract code, they can decide the order of transactions to make profits above the usual block rewards. 

The Searchers

A large portion of MEV is actually extracted by searchers and their bots, not miners. Searchers are users who search for opportunities to capture MEV on the blockchain, usually making use of bots and automation tools.

How Searchers Work With Miners

When a profit extraction opportunity is identified, a searcher creates a bundle of transactions in their desired order. Once a bundle is created, the searcher must appeal to miners to validate the transactions to extract MEV. There are two ways to do so:

  1. Searchers can compete by bidding up fees in priority gas auctions (PGAs)
  2. Searchers can communicate their ordering preferences to miners privately through Flashbots

Common MEV Strategies

Frontrunning

Think of frontrunning as jumping ahead of the execution queue before a known future transaction occurs. Searchers use specialized frontrunning bots to trawl the mempool to detect profitable transactions. These bots help to submit competing transactions with higher gas fees for approval before the original transaction.

Backrunning

Backrunning occurs when a transaction is placed immediately after a known pending target transaction. Backrunning bots look for large transactions that cause imbalances in automated market maker (AMM) pools so they can execute opposite trades to maximize profits. They also monitor the mempool for new token pair listings to buy as many of one token from the pair behind the initial liquidity, leaving only a small amount for other traders to buy later. This causes the bought token’s price to go up, after which the bot will profit by selling back the tokens at a higher price.

Sandwich Attacks

Sandwich attacks are similar to frontrunning, but two transactions are placed by the searcher instead of just one. To sandwich, a searcher must identify large decentralized exchange (DEX) trades that will significantly raise the price of one token of a pair. The searcher will then buy the identified token from the pool immediately before the trade for the purpose of selling it right after the trade to profit from the token’s price increase. 

Liquidations

Liquidators extract MEV by liquidating overcollateralized loans on lending protocols such as Aave, Compound, and Maker. See your positions in these protocols on Harvest. By competing to be the first to liquidate a loan, searchers extract MEV from unsuspecting borrowers by liquidating their loans before they can repay the debt to collect the discounted collateral and liquidation fee.

Time Bandit Attacks

Time bandit attacks involve the reorganization of past blocks and make sense when MEV is much larger than block rewards. Suppose a miner found an arbitrage opportunity in the first of three blocks. Another miner with significant hash power notices this. Instead of mining on top of the three blocks found by the former miner, the latter miner may propose three competing blocks containing altered transactions to capture the arbitrage opportunity.

Negative Effects of MEV 

Effects on Networks

Time-bandit attacks destabilize networks because it compromises transaction finality and immutability. If miners are incentivized to reorganize blocks to capture MEV, the premise of blockchains as secure, predictable, and permissionless ledgers falls apart.

Effects on Users

Strategies such as frontrunning and sandwich attacks result in increased price slippage and lost arbitrage opportunities for amateur traders. Frontrunning bots also often cause network congestion and high transaction fees.

Solutions for the Future?

Proposer-Builder Separation

With Ethereum’s Merge and transition from PoW to PoS, a solution known as the proposer-builder separation (PBS) has been introduced to combat the adverse effects of MEV at the consensus layer

Traditionally, a network of miners in PoW and validators and PoS work together to build blocks of ordered transactions and propose new blocks for addition to the chain. With PBS, validators still propose and vote on blocks, but a new class of specialized entities called block builders are now responsible for ordering transactions and producing blocks. 

Unlike the traditional approach, validators cannot see the contents of a block until after they accept the winning bid. This reduces the stealing of MEV by parties that could otherwise control the transaction ordering in a block. Due to the decreased economic incentive, PBS also prevents centralization as large mining pools are less likely to emerge to control the block proposer role. 

Builder API

While PBS should reduce the effects of MEV extraction, implementing it requires changes to Ethereum’s consensus protocol. In the meantime, Builder API serves as a temporary working implementation of PBS. An example of the Builder API is MEV-Boost by Flashbots. 

In MEV-Boost, searchers look for profitable MEV transactions and send them to block builders who are responsible for aggregating and bundling these transactions. Instead of passing through the public mempool, relayers check the blocks from builders before passing them to validators for block proposals. ‍This process encourages transaction privacy, which prevents MEV attacks such as frontrunning and sandwiching.

MEV-Boost also mitigates the risk of centralization as any validator, including solo stakers, can access MEV opportunities and have less pressure to integrate with large staking pools to boost MEV profits. MEV-Boost also helps lower gas fees and reduce network congestion since searchers participate in off-chain sealed-price bid auctions instead of PGA-style bidding wars.

MEV… What Now? 

Combating MEV-related problems in post-Merge Ethereum is a core area of research. With the improvements mentioned above introduced, hopefully, crypto users will be able to stay safe without any worries about MEV attacks. On the trading side, the future looks bright for MEV. As more MEV tools are being built, we envision that the sector will keep growing.

Disclaimer

This publication is provided for informational and entertainment purposes only. Nothing contained in this publication constitutes financial advice, trading advice, or any other advice, nor does it constitute an offer to buy or sell securities or any other assets or participate in any particular trading strategy. This publication does not take into account your personal investment objectives, financial situation, or needs. Treehouse does not warrant that the information provided in this publication is up to date or accurate.

New to DeFi? If you found this useful, check out our other Learn DeFi articles to dive deeper into the wonderful world of DeFi! Alternatively, browse our Insights section to read more in-depth analyses on the DeFi space. You can also try out our flagship product, Harvest, to get a comprehensive analysis of your DeFi assets. Lastly, subscribe to newsletter updates in the box below!