• Mon. May 20th, 2024

What Is MEV (Maximal Extractable Value) in Crypto?

What Is MEV?

Maximal extractable value, popularly known as MEV, refers to the maximum value miners or network validators can extract by rearranging and reordering transactions waiting to be added to the blockchain.


Key Takeaways

  • MEV is the maximum amount of value miners or network validators can extract by rearranging and reordering transactions waiting for confirmation.

  • It is commonly referred to as the “invisible tax” miners collect from other participants in the cryptocurrency market.

  • MEV is a prominent phenomenon on Ethereum. However, it is not unique to the smart contract platform.

  • This article explains the maximal extractable value phenomenon, how it impacts the crypto industry, and how to avoid it.


The MEV phenomenon was first highlighted in 2014 by a pseudonymous algorithmic trader, Pmcgoohan, who predicted that miners might be able to manipulate the transactions in the validation process to generate a profit. “Miners can see all the contract code they run (obviously) and the order in which transactions run is up to individual miners. What is to stop front running by a miner in any marketplace implementation by Ethereum?”, they wrote in a post on Reddit.

However, the MEV term was not coined until 2019 when Phil Daian and other smart contract researchers wrote a paper titled “Flash Boys 2.0”. In the 2019 research paper, the term denoted miner extractable value, which Daian and his colleagues defined as the total amount of ETH miners can extract from reordering transactions within a given block.

In 2022, following Ethereum’s transition from the Proof-of-Work (PoW) to a Proof-of-Stake (PoS) consensus mechanism, the MEV term changed to “maximal extractable value” to represent a broader range of techniques to extract value from users. It is worth noting that while the MEV phenomenon is most prominent on the Ethereum network, it is also common on other blockchains.

How Does MEV Work?

Maximal extractable value (MEV) is possible due to the decentralized nature of blockchain technology and the cryptocurrency industry. Contrary to the traditional finance world, where transaction orders are rigidly enforced, crypto miners and validators can reorder and sequence a set of transactions as they wish within a given block.

In the decentralized cryptocurrency system – both the PoW and PoS consensus mechanisms, pending transactions are temporarily sent to and held in the blockchain’s mempool, a publicly accessible waiting area. The transactions in this mempool are selected by miners or network validators, who then sequence order them to create a block that is then verified and added to the blockchain. In theory, miners/validators should simply prioritize processing transactions by gas fees; however, because of the transparency of the mempool, it gives rise to other more profitable opportunities to extract value, such as arbitrage, sandwich attacks, and liquidations.

On paper, miners and validators should receive the maximal extractable value since they are responsible for the execution and, ultimately, the success of MEV extraction. However, in actual practice, MEV extraction is mainly carried out by independent network participants known as “searchers,” who use complex algorithms and bots to detect MEV opportunities and generate profit.

In the most common MEV types, these searchers pay high gas fees to incentivize the miners or validators to include their transactions in target blocks in order to derive additional value. The gas fees often serve as incentives and as the portion of the maximal extractable value that goes to the miners and validators. In recent times we have even seen searchers partner directly with miners / validators for MEV extraction. 

Types of MEV

To fully understand the concept of MEV, it is essential to discuss the different ways through which these searchers generate additional value in the market. Below, we will dive into details of the different MEV types in the current crypto landscape.

DEX Arbitrage

In the traditional financial system, arbitrage takes advantage of a difference in an asset’s price across different trading venues. Similarly, arbitrage-based MEV extraction takes advantage of price discrepancies of tokens across various decentralized exchanges (DEXs).

In this MEV type, searchers generate additional value by purchasing tokens at a lower price on one exchange to sell them on another exchange at a higher value. They also derive a profit by taking advantage of any price discrepancies across different liquidity pools on the same exchange.

Here’s a scenario – let’s assume the exchange rates of BUSD/SOL in two separate liquidity pools (LP1 and LP2) on PancakeSwap V2 are 143 BUSD and 146 BUSD for 1 SOL, respectively. 

A searcher can take advantage of the arbitrage opportunity within the same block itself by injecting the following transactions into the block;

  1. Sell 50 SOL in LP2 and receive 7,300 BUSD.

  2. Sell 7,300 BUSD in LP1 and receive 51.05 SOL.

From the example above, the searcher generates a profit of 1.05 SOL (excluding the transaction costs for the two transactions). While it might seem like an unfair advantage, arbitrage helps to improve DeFi market efficiency by ensuring token prices are aligned across different exchanges.

Liquidations

In decentralized finance, liquidation is a process that occurs when the value of a borrower’s collateral does not cover the value of their loan or debt. Once a debt is liquidated, any individual can purchase the original collateral at a discount and resell the asset at a higher price to make a profit.

In this MEV type, searchers act as liquidators who scan the blockchain for unhealthy loan positions that need to be liquidated. These individuals identify loan positions that are eligible for liquidation, acquire the borrowers’ collaterals at a discounted price, and resell at a higher price to gain extra value.

Indeed, this type of MEV is often neutral and non-harmful because liquidations are a regular occurrence in any financial system that allows buying and borrowing. However, liquidations can sometimes be malicious and are referred to as “toxic liquidations.”

Sandwich Attacks

Sandwich attacks are a malicious type of MEV, where the searcher executes a transaction ahead of an initially identified trade (front-running) and follows the target transaction with another trade (back-running). This strategy is often employed to take advantage of large orders that cause the price of assets to fluctuate.

Here’s a simple breakdown of a sandwich attack;

  1. MEV searcher executes a buy order, driving up the asset’s price.

  2. MEV target purchases the asset at a higher price.

  3. MEV searcher sells the asset at the higher price, gaining a profit from the price difference

Front-running

Front-running is the first phase in a sandwich attack, which involves searching through a blockchain’s mempool for pending transactions that could impact a specific asset’s price and from which they can extract significant value. For instance, if a frontrunner – often a sophisticated bot –- detects a large buy order for a specific cryptocurrency, they recognize that this transaction could drive the token’s value higher once confirmed.

The bot will then create a buy order for the same token, to get their transaction processed before the target transaction. They assign a higher gas price to their transaction, incentivizing the validator to prioritize their buy order over the initially detected transaction.

Back-running

To complete the sandwich attack, the bot also creates a sell order, intending to have it executed right after the target transaction, thereby selling the asset at a higher price. This strategy is known as back-running, and it is accomplished by assigning a lower gas price to the second trade to ensure that it is validated after the target transaction. 

Ultimately, this type of MEV will reduce the value the targeted traders would have otherwise gained from their transactions. Meanwhile, the searcher benefits from the price fluctuations triggered by the target transaction.

MEV Attacks and How to Avoid Them

Having gone through the various types of MEV, it is clear how MEV attacks may significantly affect participants on a blockchain network, particularly the decentralized finance space. Below are some of the countermeasures to avoid falling victim to MEV attacks.

  1. RPC Endpoints (MEV Blockers)

MEV blockers are software tools that protect users from MEV exploitation. Since MEV extraction relies on rearranging transactions in a new and profitable order, it is possible to avoid this manipulation by submitting transactions to a specialized network of searchers bound by specific rules that ensure favorable execution for users.

MEV blockers operate through RPC (Remote Procedure Call) endpoints, a communication protocol between the blockchain and a user’s wallet. RPC endpoints safely reroute towards the aforementioned network of searchers rather than sending transactions to the publicly visible mempool where malicious searchers are waiting to strike.

The specialized network of searchers commits to not front-run or sandwich users’ transactions. Contrarily, they even extract value and put money back into the users’ pockets by back-running large transactions and returning a large portion of the gains. 

  1. Lower Slippage Tolerance

Slippage is defined as the difference between the intended execution price of a transaction and the actual execution price of the transaction. This often occurs in crypto due to the volatile nature of the market, and it accounts for why some MEV attacks are possible.

A slippage tolerance allows the execution of a transaction only if the token price remains within the set range. Setting a lower slippage tolerance can help protect users against sandwich attacks and limit unexpected losses.

Here’s an example – an exploiter places a large order ahead of a trader’s transaction, which triggers a significant shift in the token price. If this price change exceeds the trader’s slippage tolerance, their transaction will get canceled.

  1. Priority Gas Fees

Although selecting lower gas fees for transactions is the most economical option, there is the risk that the transactions may be processed slowly and discovered by malicious actors. Hence, traders should consider paying priority gas fees for their transactions, especially large amounts, in order to avoid falling victim to MEV attacks. 

Miners or validators will prioritize and process a transaction with a higher gas fee, and attackers will need to assign an even higher fee to front-run such a transaction. Ultimately, the steep price and cost-reward ratio may discourage most searchers from targeting the transaction.

  1. DEX-Native MEV Protection

Traders can protect themselves from MEV exploits by utilizing DEXs or dApps designed to mitigate the impacts of MEV. CoW Protocol, for instance, is a DEX aggregator that employs batch auctions and intents as its trading mechanism to produce favorable results for users.

A batch auction is a type of trading mechanism that collects orders together in batches and “auctions” them to execution parties (also known as solvers) who compete with each other to find the most optimal order settlement paths. This technique enforces specific execution rules that prevent MEV exploits.

MEV on Solana vs. MEV on Ethereum

Although MEV and MEV-related exploits are most popular on the Ethereum network, they are not restricted to the smart contract platform. Maximal extractable value is a common phenomenon on other blockchains and smart contract platforms, such as Solana. However, there are different manifestations of MEV on these blockchains due to their unique designs and consensus mechanisms.

Here, we’ll look at how the maximal extractable value on Ethereum compares to that on Solana under the following topics.

  1. Consensus Mechanism

Ethereum network is a proof-of-stake network. Solana, on the other hand, operates on a unique combination of Proof-of-History (PoH) and delegated Proof-of-Stake consensus mechanisms. This forms the foundation of the differences between both blockchains in terms of MEV extraction.

For instance, Solana’s PoH mechanism operates by establishing a trustless and verifiable order of transactions on the blockchain. The chronological nature of this consensus algorithm makes it difficult to rearrange or manipulate transactions in order to gain additional value, as in the case of front-running attacks.

  1. Network Infrastructure

The difference in the design of Solana and Ethereum provides another point of comparison between both networks in terms of MEV. There are certain features that make users of either blockchain vulnerable to MEV-related exploits.

For instance, unlike Ethereum’s, the Solana infrastructure does not have a publicly visible mempool, where transactions wait for validation. This means that searchers can’t target individual transactions, reducing the possibility of sandwich attacks and front-running transactions.

Solana is a Layer 1 blockchain, which, upon launch, was dubbed the “Ethereum Killer” because of its relatively higher speed and better energy efficiency. As a result of its high throughput and low latency, transactions are processed quickly and in large volumes, limiting the window of opportunity for MEV exploits.

What’s more, transaction fees on Solana are virtually nonexistent compared to Ethereum. With the negligible costs of most transactions, it is challenging to engage in MEV practices that rely on gas wars for favorable placement. If a searcher can not push their order ahead of a target transaction by assigning a higher gas fee, then the possibility of front-running such a transaction is close to zero.

However, Solana is more susceptible to MEV NFT bots, where bots swarm the NFT minting program with mint requests to get as many NFTs as possible upon launch and resell them immediately. This is possible due to the low transaction gas fees on Solana, with the effect of impacting the NFT market and also congests the network. Proposed solutions include a “tax” for invalid transaction and dynamic pricing for popular NFTs. 

Final Thoughts

Maximal extractable value is a phenomenon in the crypto space that has continued to evolve over the years. Understanding the distinct techniques of MEV on different blockchain platforms is essential to adapt to the evolving risks and avoid becoming unwilling victims of such exploits.

As addressed in this article, there are different individual-based strategies and protocol-level methods for protection against MEV-related activities. While some cases of MEV extractions are deemed malicious, there are still some advantages attached to having such activities in the cryptocurrency market.

Some MEV strategies, such as arbitrage, help to enhance efficiency in the cryptocurrency market by ensuring the alignment of prices across various exchanges. All in all, maximal extractable value is a hot and complex topic that requires much more in-depth research for a better understanding.