Understanding Maximal Extractable Value (MEV)

Opeyemi
Coinmonks

--

MEV is an abbreviation of “Miner Extractable Value” or “Maximal Extractable Value”. The latter is more commonly used as MEV is not limited to just miners on PoW blockchains, but also validators on PoS blockchains.

MEV is the profit a block producer can earn through their ability to arbitrarily add, remove, or rearrange transactions within the blocks they produce. This is a return a miner or validator can receive from unilaterally reordering, inserting or censoring transactions within blocks being produced.

In a blockchain, miners and validators act as watchdogs to secure the network and confirm transactions. They are independent and have no superior or monitor, this gives them the ability to keep and order transactions in a manner that is beneficial to them.

For example, there is a $5,000 arbitrage opportunity available on Curve after a large trade has led to a price slippage. An arbitrage bit seeks to exploit this opportunity and it submits a transaction to capture it. It offers a $50 transaction fee (tx) to the block producer. Two things may happen:

  1. The block producer copies and blocks the bot’s transaction to exploit the opportunity themselves, or
  2. Other bots notice this same opportunity and bit a higher tx fee, which starts a bidding war for the right to capture the arbitrage. The auction is called a “Priority Gas Auction” (PGA).

The $5,000 potential profit is MEV. If a block producer chooses not to capture the arbitrage, and a PGA begins, the variance between the price at which the auction is settled and the total MEV available is the winning bot or trader’s profit. If a $4,000 fee is paid to a miner or validator, the remaining $1,000 goes to the trader.

This example illustrates how block producers can exploit their role for personal gain on the blockchain. DeFi’s success has caused the Ethereum MEV to grow at an exponential rate. This means, that in the coming year, MEV could create major issues bothering PoW and PoS blockchains.

History

The problem of MEV in Ethereum was initially discovered in 2014 by an analyst coder who goes by the pseudonym Pmcgoohan.

When Pmcgoohan heard about Ethereum and the idea of smart contract blockchains following the global financial crisis of 2008, he really love the idea and was excited about the future potential of the idea. His excitement declined when he discovered a critical flaw in the technology. Pcgoohan realized the full autonomy and control miners had over transaction inclusion and ordering. They could leverage their power to extract an additional value from unsuspecting users of the protocols.

He began to warn about this critical flaw, however, his warning fell on deaf ears. It was until 2019, that a group of researchers highlighted this issue by publishing a paper called Flash Boys 2.0, where the “MEV” term was first coined to explain the issue Pmcgoohan had discovered years ago.

MEV was finally recognized as a fundamental concept after Georgios Konstantopoulos’ and Dan Robinson’s Ethereum is a Dark Forest, and Samczsun’s Escaping the Dark Forest articles, published about it in August and September 2020 respectively. They explained its essence as one of the most critical and challenging issues Ethereum faces today.

Why Maximal-Extractable Value Occurs

Every blockchain has miners (PoW) and validators (PoS). These parties are responsible for regularly collating pending transactions and placing them into blocks, which are then added to the blockchain. They keep updating the blockchain regularly so as to ensure all transactions are valid and there are no bad actors perpetrating fraud.

There is no certainty that transactions will be arranged in the exact manner they were submitted to the blockchain. This is because block producers pick transactions haphazardly from the mempool, order them and include them in their block. There is no standard mode of selection placed by any blockchain for the miners, this gives them full autonomy over their actions of selection and ordering transactions.

Block producers (miners and validators) tend to order transactions by the highest tx fee in order to make the most profit per block. Because of this, they can extract additional profit from users by taking advantage of their ability to unilaterally reorder transactions, creating what is referred to as maximal-extractable value (MEV).

MEV is commonly not seen today with block producers, it is seen amongst third-party bots and parties. These bots or traders manipulate how transactions are ordered in a block by changing the tx fee they pay to block producers. And since block producers always seek to maximize profit, they prioritize transactions with the highest tx fees.

Ultimately, the highest benefactor of the MEV is the block producer as they decide the final order of transactions within a block. MEV is detrimental to regular users who may not have the resources to pay high tx fees for their transactions to be prioritised in the block.

A simple example to explain this phenomenon can be by seeing it as a special sale offer in a supermarket. Imagine a Black Friday sale, customers want to take advantage of massive discounts and special offers. In a situation where there are limited goods and a lot of customers are willing to pay for these goods. The cashier can choose to prioritize the order of customers who can pay the highest tip. This could create a bidding process whereby the highest tipper gets the goods and the others miss out. However, in this case, the cashier is also the owner of the business and there is no external authority that can punish the cashier if they choose to not prioritise the order of the highest bidder. The cashier is also not punished for discriminating against customers who can not compete aggressively in the bidding process.

The highest bidder earns the Maximal Extractable Value (MEV) from that transaction and the cashier sells their products with a high tip.

Key Players in the MEV Process

Key players in the MEV process include block producers, searchers, decentralized applications, and protocol developers.

The block producers, as explained above, are responsible for ordering transactions and determining which transactions go in a block. Block producers can cash in on the MEV process by either selling scarce block space to non-miner MEV extractors through the Priority Gas Auctions (PGA) in exchange for high gas fees, or by capturing MEV themselves through resequencing, including or removing transactions to favour themselves.

DApps and protocol developers have support roles in this process. DApps create MEV opportunities via their nature and the incentives (such as arbitrary) they offer. Protocol developers create the rules for block producers to order transactions, which makes it possible for them to capture MEV.

Searchers or DeFi traders and bot operators constantly seek out MEV opportunities and capture them in diverse ways. They participate in the MEV process by bidding up outrageous gas prices in on-chain PGAs to have transactions ordered in specific ways within blocks by block producers. By also stating transaction sequencing choices to block producers off-chain using MEV extraction tools such as Flashbots. Searchers run complex algorithms to discover profitable MEV opportunities and have bots automatically submit these profitable transactions to the network immediately.

Given that searchers are rational economically, the transaction fee they are willing to pay should be less than 100% of the MEV they seek to capture. This is because if the transaction fee was higher than the MEV, the searcher will lose money. This makes for some highly competitive MEV opportunities, searchers can be willing to pay up to 99% of their total MEV revenue in transaction fees to the block producers because so many people chase the same profitable transaction. This is because by paying the highest transaction fee, they can guarantee their transaction will be given priority by the block producer when ordering transactions in the block.

The Searchers’ Typical MEV Extraction Process

Searchers begin their MEV process by monitoring the blockchain using bots built with complex algorithms and automation tools for potential MEV opportunities. When the opportunity is spotted, they analyze the logic behind the transaction, determine the attack vector, and create a bundle. A bundle refers to multiple transactions collated and executed in the order they are created. Searchers go through this process to guarantee their MEV objective when the block is produced.

After a bundle is created, a searcher will send it a mine using off-chain networks like Flashbots’s MEV-Geth. This lets searchers skip the public mempool and express their transaction sequencing preferences fast and risk-free directly to block producers.

In a situation where a larger number of searchers submit a huge amount of bundles and the block space is limited, block producers auction their block space through a Flashbots Auction. This is an off-chain first-price sealed-bid auction (blind auction) where searchers privately bid for their preferred transaction order. Based on the nature of the auction, no party knows the amount bided by the other parties. Thus, the highest bidder gets their transaction order preference in the block produced.

When the block producer includes a searcher’s bundle in their block, the MEV extraction process is complete.

Types of MEV

MEV occurs on the blockchain in the following ways:

Front-running

This involves getting a transaction to be first in the execution queue ahead of a known transaction in the mempool. Front-running bots monitor large trade entering the mempool and use their advanced knowledge to capture this opportunity.

For instance, if a front-running bot spots a large trade, it can copy the user’s trade and pay a higher transaction fee to get their transaction to receive top priority in the transaction order sequence in the block.

DEX arbitrage

This is the most common form of MEV seen today. Third-party bots perform arbitrage between two or more decentralized exchanges (DEXs). An arbitrage opportunity exists when the price of a crypto asset on one exchange is diverse from another. Arbitrage bots cash in from this kind of opportunity by buying an asset on the exchange at a lower price and selling it on the exchange at a higher price.

DEX arbitrage is the simplest and most popular MEV opportunity and as a result of this, it is the most competitive opportunity. Bots compete aggressively for this kind of opportunity, they do this by engaging in a bidding war which leads them to raise the transaction fee they are willing to pay block producers with the aim of getting their transaction prioritized.

Sandwich Attacks

A sandwich attack is a variation of front-running whereby a bot or trade places two transactions, one before and after another trader’s transaction. Searchers use this attack to extract MEV from unsuspecting traders on DEXes by manipulating the price of an asset.

For example, a trader wants to buy 50,000 ETH with USDC on Uniswap. A trade of this magnitude will have a significant impact on the ETH/USDC pair. That trade could potentially raise the price of ETH relative to USDC. A searcher can calculate the potential price effect of this large transaction on the ETH/USDC pair and execute a buy order right before the large trade, buying ETH at a cheap price, then placing a sell order immediately after the same trade, selling it for the higher price that was brought on the large trade.

Back-Running

This is the act of getting a transaction ordered second in line or right after a known pending target transaction has been executed. Searchers usually use back-running bots to watch the mempool for new token pair listings or liquidity pools created on DEXes. When the bot finds a new token pair listing, it places an order right after the initial liquidity and buys a large number of tokens, leaving a small amount for other traders to buy later. The bot then waits for the price to raise after other traders have purchased the token and sell at a higher price for a profit.

Liquidations

Liquidations is another well-known MEV practice. Searchers that specialize in liquidation MEVs extract value from liquidations of over-collateralized loans on decentralized lending platforms such as Compound, Maker, Aave, and dYdX. Liquidators run bots to either front-run or back-run transactions to be the first to liquidate the collateral. Protocols usually allow anybody to liquidate the collateral, instantly paying off the lenders. If the collateral is liquidated, the borrower is required to pay a hefty liquidation fee, some of this fee goes to the liquidator which is the MEV opportunity.

Time-Bandit Attacks

This is a type of attack which block producers retroactively execute. They reorder blocks that have been mined in the past to capture MEV opportunities. They do this in a case where MEV is high enough that is rational economically to disrupt the consensus to capture MEV in older blocks.

Imagine there are two miners, Chidi and Segun, who receive $50 as a reward for mining each block they find. Chidi has found 4 blocks, the first of which has a $50,000 arbitrage opportunity.

Segun can either mine on the 4 blocks Chidi found, or he can try to re-mine the first block in order to take the arbitrage opportunity for himself. The $50,000 arbitrage is more profitable than the $50 block reward. As a rational block producer, Segun decides to re-mine the first block. As he does so, he will also re-mine the second, third and fourth block, and in case there are MEVs in them, he captures them too.

NFT MEV

This is a relatively new phenomenon in the NFT space and isn't necessarily profitable.

Searchers use similar techniques as those used in other MEV opportunities in the NFT market.

Imagine there popular NFT drop and a searcher wants that NFT or set of NFTs, they could pay higher gas fees for their transaction to be the first in line to buy the NFT. They can also buy the entire set of NFTs in a single transaction before anyone else by front-running. Also, in a case where an NFT is mistakenly listed at a low price, a searcher can run either buyer and buy it at a cheap price.

Effects of MEV

According to Flashbots’ data, which measures the lower bound of total extracted MEV and monitors only eight DeFi protocols. It reported that as of August 2022, more than $673 million has been extracted from unsuspecting victims of the Ethereum network.

MEV is one of the biggest issues Ethereum along with other smart contract blockchains. One major issue MEV constitute is that it is a form of extortion done by block producers to users. Users would need to pay exorbitant fees to execute profitable transactions.

MEV also congests the network and puts upward pressure on gas prices. MEV bots engage in gas price bidding wars which cause regular users to overpay gas fees for transactions. MEV ultimately worsens users' experience.

MEV disrupts blockchain on a protocol level because it puts into question transaction finality and immutability. In a situation where the MEV is bigger than block rewards, block producers will be inclined to destabilize consensus. If a block producer can reorder transactions of previously mined blocks for profit, the entire belief of blockchains as secure, predictable, and permissionless ledgers falls apart.

Ultimately, MEV destroys the usability, neutrality, transparency, decentralization, and security of smart contracts today. It creates an environment where block producers who are more skilled at capturing MEV grow at the expense of honest block producers. This negatively impacts the core incentive structure which is the heart of smart contract blockchains’ security.

Solutions for MEV

There are largely 2 schools of thought when it comes to approaching solving the MEV problem.

  1. Offence: This school of thought believes that MEV is here to stay so we need to find a way to extract and democratize it. This school of thought is also referred to as Front-running as a Service (FaaS) or MEV Auctions (MEVA). Examples of solutions in this school of thought include the use of private transactions, BackRunMe by bloXroute, Flashbots, mistX by alchemist, KeeperDAO, EDEN Network (ArcherSwap) etc.
  2. Defence: This school of thought believes that MEV is bad and should be prevented. This school is also referred to as MEV Minimization. Solutions include Conveyor (Automata Network), SecretSwap (Secret Network), Fair sequencing service (Chainlink), Arbitrum (Offchain Labs) etc.

Conclusion

The MEV problem exists not as a technical flaw in the design of blockchains but due to an inherent flaw in man. People are selfish and will always seek their own to the detriment of others. We all know nobody secures a blockchain out of the goodness of their or because they want to make the world a better place, rather, to maximize returns. Technology cannot solve all of man's problems; looking at it critically, the problem of man is man himself. Therefore, we need to build and adjust technology to mitigate these issues and block out bad actors.

MEV is a critical issue that threatens the core of blockchain technology. This space has constantly shown to be highly innovative and continuous seeks to mitigate issues and improve. Multiple solutions have arisen and much more will come to solve this problem, however, wherever solution becomes mainstream for MEV, it would have to be flexible as people will continue to seek new ways to exploit the blockchain.

Sources and References:

  1. Maximal Extractable Value (MEV)
  2. What Is Miner Extractable Value (MEV)?
  3. What Is MEV? Ethereum’s Invisible Tax Explained
  4. What Is Miner-Extractable Value (MEV)?
  5. MEV and Me
  6. MEV Wiki

New to trading? Try crypto trading bots or copy trading

--

--