Blockchains reliant upon proof-of-stake (PoS) consensus mechanisms, such as Ethereum and Avalanche, are by far the most popular. They rely upon parties known as Validators to store data and add new blocks to their blockchains. Pending transactions are sent to a “mempool” until Validators insert them into a given block, with transactions typically prioritized based on the associated gas fee offered. Gas fees can be considered as a network tax of sorts and are used to disincentivize malicious parties from spamming the network and to compensate Validators. The result is that PoS blockchains are both energy-efficient and secure.
However, as with every system, vulnerabilities can emerge. One of these is the ability for parties to peek into mempools, identify profitable transactions, and submit a similar transaction with a higher gas fee in order to have their trade executed first. This process, known as Maximal Extractable Value (MEV), is the focus of our discussion in this article. Previously termed as Miner Extractable Value, the switch to PoS by Ethereum saw the terminology shift to ‘Maximal’.
MEV is a pressing concern, with over $713M in value has thus far been recorded on Ethereum alone. Numerous projects, such as Flashbots, are deeply invested in researching MEV to increase industry education and to minimize the negative externalities.
Understanding MEV, its workings, and potential solutions is essential for any DeFi enthusiast. Hence, this article aims to offer an accessible introduction to MEV, its common types of attacks, their impact, and how to democratize MEV to bring about greater equality.
A Quick Look at Staking
In PoS blockchains, Validators are essential to the network’s functioning. They store data, validate transactions, and add new blocks to a blockchain. In contrast to how Proof-of-Work (PoW) Miners solve complex mathematical problems to validate transactions, PoS Validators rely upon staking.
Staking involves purchasing a large number of native tokens of a PoS blockchain, such as ETH on Ethereum, and locking them up on the network as collateral. This action makes parties eligible to be Validators, incentivizing them to perform honestly due to the financial stakes involved. Misperformance, intentional or accidental, could lead to penalties, or “slashing,” where Validators lose a portion of their collateral.
I actually wrote about both staking and liquid staking in a prior article – check it out!
What is MEV, and How Does it Work?
PoS staking has revolutionized the consensus mechanisms of blockchain networks, proving to be much more efficient than PoW systems and seeing widespread adoption. Ethereum’s transition from PoW to PoS, an event termed ‘The Merge‘ in late 2022, is a testament to its benefits.
However, this approach gives Validators considerable power over the handling of network transactions, which can lead to vulnerabilities. These parties can exploit pending transactions in the mempool by manipulating them, a power that’s not exclusive to Validators but can be leveraged by arbitrageurs as well.
The method commonly used is known as front-running. Validators or arbitrageurs deploy algorithmic bots to identify profitable trades waiting for execution. The bot then executes the same trade ahead of the original transaction by offering a higher gas fee, effectively outbidding the initial transaction. This process is MEV in action.
MEV measures the profit an actor like a validator, sequencer, or miner can make by re-ordering transactions from the blocks they create. In essence, MEV is the total value these privileged actors extract from a blockchain’s network of users by selectively inserting, censoring, or re-ordering transactions within the blocks.
There are other negative externalities associated with MEV. When validators front-run a promising transaction, it causes a hike in the gas fee of the trade that is next to close. This means the victim user now has to pay a higher gas fee than before to get the same trade executed. So MEV is inherently like a hidden as well as an invisible tax.
Most commonly, these parties are like predators that take the form of “arbitrage bots.” Arbitrage bots monitor pending transactions and attempt to exploit profitable opportunities created by them. Let’s take a look at two popular types of MEV attacks for a better understanding.
Positive Aspects of MEV
It’s worth noting that not all MEV is bad, with liquidations and arbitrage being examples.
- Liquidations: In DeFi, it’s common to take out collateralized positions. For example, MakerDAO enables one to use their cryptocurrency assets as collateral for a USD-denominated loan in the form of DAI. If the value of their collateral drops below the value of their loan, a liquidation alert is triggered. Liquidators sell off the collateral and take a fee for doing so, in return extracting value from the liquidated party. However, this is beneficial to the ecosystem as a whole, as undercollateralized loans could pose a risk to the protocol’s sustainability.
- Arbitrage: The pricing of assets on decentralized exchanges (DEXs) may fluctuate due to liquidity pools becoming imbalanced. This may lead to discrepancies in pricing compared to external DEXs, or compared to centralized exchanges such as CoinBase and Binance. Arbitrage transactions rebalance the liquidity pools in return for profits, resulting in an efficient market whereby pricing is consistent throughout.
We’ll now shift our focus back to the harmful impacts of MEV by looking at front-running and sandwich attacks.
Earlier, I briefly mentioned the concept of front-running. In the context of blockchain and decentralized exchanges, front-running is an exploitative strategy where an entity anticipates a future transaction and capitalizes on this knowledge by executing a similar transaction with a higher gas fee. This results in their transaction being processed earlier, allowing them to gain profits at the expense of others.
To better understand front-running, let’s visualize it using a real-world trading scenario. Consider two major cryptocurrencies, Bitcoin and Ethereum. One day, due to market fluctuations, their prices drop. Traders, looking to avoid further losses, begin exchanging their Bitcoin and Ethereum holdings for a stablecoin like USDC.
As a result of these trades, the liquidity pools for Bitcoin and Ethereum on a decentralized exchange become imbalanced. There is now a surplus of Bitcoin and Ethereum and a corresponding deficit of USDC. This disparity between the two sides of the liquidity pool creates an opportunity for arbitrageurs.
Arbitrageurs can capitalize on this situation by purchasing Bitcoin and Ethereum at a ‘discount’ due to the oversupply, and then selling these assets in a different liquidity pool where the asset’s price is still high. This process, when executed correctly, can yield significant profits.
However, front-runners take this a step further. By monitoring the mempool, front-runners can identify these profitable arbitrage opportunities before they occur. They then create a similar transaction but offer a higher gas fee. Since miners prioritize transactions with higher gas fees, the front-runner’s transaction is processed first, effectively ‘front-running’ the initial trader’s transaction. This allows front-runners to reap the benefits of the arbitrage opportunity before the initial trader, manipulating the market dynamics at the expense of regular traders.
- Sandwich Attacks
These refer to a variation of front-running whereby a trader places two transactions, one before and another after a pending victim transaction. This causes a normal trade of an actual user to get sandwiched between two artificially placed transactions.
This might look as follows:
- An attacker, often an arbitrage bot, monitors the mempool for potentially profitable transactions. Once it identifies a target transaction – perhaps a sizable DEX trade – it moves to the next step.
- Before the target transaction gets a chance to be processed, the attacker places their own significantly sized transaction with a higher gas fee. This is a purchase of the same token that the target transaction intends to buy. The higher gas fee incentivizes validators to process the attacker’s transaction first. This purchase inflates the token’s price due to increased demand.
- After the attacker’s first transaction, the original target transaction is processed. However, due to the price increase from the attacker’s transaction, the victim ends up buying the token at a higher price than anticipated.
- Immediately following the victim’s transaction, the attacker sells the tokens they purchased in the front-running transaction. This action, again, has a higher gas fee to ensure it gets processed quickly. Selling off a large token quantity can cause the price to drop.
According to Dune Dashboards, more than 2.4M sandwich swaps have occurred since August 2020.
One user has become well-known on crypto Twitter recently, netting $950,000 from sandwich attacks on April 19th alone.
Approaches to Addressing MEV
There are several solutions being explored to mitigate the impact of MEV, including:
- Education: Quantifying the impact of MEV capture and spreading awareness to minimize information asymmetry is a key goal.
- Democratization: Efforts to make MEV more equitable include the provision of open-source infrastructure for MEV capture, and democratizing access to it. One such initiative is the MEV Geth, a tool developed by Flashbots that allows validators to extract MEV.
- Distribution of Benefits: Distributing the gains from MEV more equitably is another strategy. An example is MEV Boost, a tool developed by Flashbots that helps validators identify the optimal order of transactions and free up extra block space to boost their staking rewards by up to 60%. This tool benefits not just the validators but also those delegating to them. Similarly, MEV-Share, a programmatically private order flow, allows users to bargain for a share of MEV while keeping their transactions private.
The Impact of MEV
Some people consider MEV a bad practice, while others support it. Whether or not it is, it can obviously lead to unfairness, price manipulation, censorship, and some security or integrity risks to a given blockchain network.
The data shows that more than $690M has been made by MEV attackers in profits since 2020. So in order to democratize MEV and make it fairer, Flashbots developed a tool called MEV Boost. It helps validators identify the optimal order of transactions and free up extra block space to boost their staking rewards by up to 60%, which would, in turn, benefit those delegating to them.
Similarly, another effort of Flashbots known as MEV-Share aims to distribute the gains more broadly (not only to Ethereum validators but also to users).
MEV-Share is a programmatically private order flow system that empowers users to negotiate for a portion of the MEV that their transactions generate. It does so by ensuring that the protocol ensures user transactions are not publicly visible until they’re already included in a block, thereby preventing predatory practices such as frontrunning. This guarantees not only the privacy of user transactions but also enables them to potentially reap a share of the MEV created by their own transaction activity.
MEV is an integral and complex part of the blockchain world. As research and innovation continue to evolve, it is crucial to keep an eye on how the landscape changes, and how the benefits can be distributed more equitably.
MEV is often a hot topic at blockchain conferences, with many researching methods of improving MEV, such as through the democratization of profits. It’s unclear what the future will hold, and what the MEV economics of an efficient blockchain ecosystem might look like.
For those interested in learning about MEV, I’d suggest the following:
Make sure to follow me on Twitter as well!