MEV Analysis 101
Since summer 2021, DeFi on Ethereum has grown substantially with an enormous influx of end-users and countless numbers of emerging protocols. These new protocols introduce lots of profitable opportunities, such as arbitrages between DEXs and liquidations in lending protocols. The profit available to be extracted is commonly known as MEV. MEV brings both upside and downside to end-users and the blockchain. Hence, we have researched the effects of MEV – both current and future – and introduced potential solutions for MEV.
What is MEV?
MEV, or Maximal (formerly Miner*) Extractable Value, refers to the profit that can be drawn out from submitted transactions by miners or validators, who can insert, delete or reorder transactions in a block.
*Note: It is no longer “Miner” due to some chains being PoS-based. Blocks are chosen by selected validators instead of miners. But for simplicity, we’ll use the term “miner” here to refer to the party selecting the block.
An example of MEV extraction is when miners see a profitable transaction in the public mempool waiting to be executed and simply generate a new transaction with the same calldata to instead reap the profits for themselves. Miners are then better off including this new transaction into the block for mining. If successful, the profit will then be transferred to the miners instead of the original submitter.
However, even if miners have such power over transaction orders, in practice, the majority of MEV profits are captured by “searchers” who develop bots with advanced algorithms to automatically detect new, complicated profitable opportunities in the market.
To date, over $600M* of MEV has been extracted by searchers and miners combined.
*Note: The actual MEV number could be much higher, as this data is only limited to opportunities submitted via Flashbots.
As MEV opportunities become more well-known, more searchers start to enter the game. The competition between searchers arises as there can only be one winning transaction that successfully extracts the MEV opportunity. Searchers secure their victory by bidding higher gas prices, incentivizing miners to put their transactions before others'.
MEV Strategies
Apart from bidding on gas prices, veteran searchers can utilize diverse strategies to reduce competition and increase their chances of successful extractions. Some of the most notable MEV techniques are listed below:
1. Frontrunning
Frontrunning is when exploiters insert their transactions before the victims’ transactions. The inserted transaction can be as simple as copying the target’s transaction data so that the profit is paid to the frontrunner instead. A more complex frontrunning requires an alteration of some parameters inside the transaction such as detecting onlyOwner modifier – a requirement that only allows the contract's owner to be the transaction caller – in the target’s transaction and bypassing the condition.
Examples: DEXs arbitrages, liquidations, and NFT launch minting.
2. Backrunning
Backrunning is when a transaction is inserted right after a target transaction to capture the created profits. The majority of this MEV class is the arbitrages between DEXs after large volume swaps that may cause large price imbalances across DEXs. A searcher can buy a token for a lower price from one DEX and sell it for a higher price on another DEX, netting some profit.
Example: DEX rebalance, and an immediate buy of a mispriced NFT sale.
3. Sandwiching
A sandwich attack wraps a victim's transaction between two transactions – a combination of frontrunning and backrunning. The majority of sandwich attacks capture profits from large volume swap transactions with high slippage tolerance. A frontrunning transaction buys tokens at a regular price, pumping up the price and making the victim receive a worse rate. Then the backrunning transaction sells tokens at a higher price, gaining some profit.
Example: DEX slippage tolerance extraction
4. Long-tail
Long-tail utilizes unconventional strategies that may only appear from time to time. Automated bots cannot monitor these kinds of opportunities, so there are much fewer competitions for searchers, leading to less profit for them to share with miners. For example, a long-tail strategy may interact with newly launched protocols or may use a series of complex transactions involving multiple protocols.
Example: Flash-claiming $APE tokens
Effects of MEV
MEV has both pros and cons for the end-users and/or the market.
Pros
1. Lower protocol risk
Many DeFi protocols, such as pool-based lending protocols, require open positions to always remain “healthy”. In case of price fluctuations, the protocols require external parties (i.e. liquidators) to close down positions that are at risk asap. MEV bots help reduce protocol risks by capturing MEVs before the positions go underwater and incur losses to the protocols.
2. Market efficiency
Arbitrages between DEXs help ensure the stability of token prices. If the prices are different across DEXs, MEV bots can capture profit opportunities by buying cheap and selling high. Constant MEV extractions from bots ensure that users receive the most correct prices on any exchange.
Cons
1. Poor user experience
Frontrunning causes users’ rewards from pending transactions to be snatched by searchers. Backrunning exploits users’ mistakes and creates unfairness when protocols or NFTs minting launch. Backrunners will be one of the first to have access to the opportunities. In sandwich attacks, users can get worse rates from swaps. Liquidity providers can receive less amount of trading fees from providing just-in-time liquidity.
2. High gas price
The number of searchers' bots grows over time, increasing the demand for transaction submissions. These bots submit transactions with high gas prices to have their txs included in blocks. This ultimately drives up the gas price to successfully submit transactions since miners will select transactions with the highest gas prices to maximize their profits.
3. Block re-organizations
In extreme cases where the MEV reward in a mined block is higher than the current block reward, miners may prioritize re-mining the last block and cause re-organization in the blockchain, aka the “time-bandit” attack. Miners may harm the security of the blockchain in exchange for their profits.
MEV Solutions
The downside of MEV poses a big problem in blockchain not only for user experience but also for consensus destabilization. To tackle the issue, several solutions have been researched and developed. Below are some of the most widely used solutions.
1. Private transactions
Private transactions are transactions that are not sent to the mempool, but instead relayed directly to miners. Thus, the transactions cannot be hunted by searchers to extract profit. The most well-known organizations that develop private transactions are Ethermine and Flashbots, which have been gaining mass adoption with over 90% of Ethereum hashrate over the past year.
2. Fair Sequencing Service (FSS)
FSS acts as an additional layer that incorporates extra information, such as time of arrival in the mempool and data encryption, into transactions before actually passing them to the mempool. With this feature, FSS can ensure that transactions are executed sequentially according to the arrival time in the mempool. Some chains' sequencer providers FCFS transaction ordering, while some may rely on external parties like Chainlink collaborating with Arbitrum to utilize FSS as a way to mitigate MEV on layer 2 through rollups.
3. Protocol-specific implementation
Protocols can countermeasure some MEV extractions internally in their implementation designs. For example, Chainflip AMM efficiently matches buy and sell in batches to avoid MEV extraction on price slippages. Another example is that a protocol can disallow adding and removing liquidity of large amounts in a single block to avoid just-in-time liquidity sandwich attacks.
The Future of MEV
Currently, the two parties – searchers and miners – share the MEV profits. The miner's share started low and grew over time due to more intense competition among searchers as displayed by the graph below of the average MEV shares miners receive from June 2020 to March 2022. Some of these transactions are offering as much as ~95% of MEV profit.
As long as miners are satisfied with the profit share they receive from searchers, they can just idly receive the share portion. However, in theory, these miners can (and likely will) become searchers themselves, capturing all MEVs because they can control the transaction inclusion. This will be the case if miners want to maximize the profit opportunity available in the market. Consequently, searchers will only be able to extract MEV by using long-tail strategies unmonitored by miners.
Zooming out to the MEV problem itself, the issue will persist as long as there are profitable opportunities in the market. Regular users must be aware of the fact and adapt accordingly. MEV mitigations such as private transactions will likely be a common practice for all users. One example scenario is MetaMask and other wallet providers using Flashbots as the default RPC endpoint.
On the protocol side, new protocols can integrate MEV prevention implementation such as using an exact value as slippage control over percentage. As MEV opportunities become harder to extract, searchers will be looking for more opportunities in other emerging chains where there are fewer competitions.
References
- Maximal Extractable Value
- Flashing A Light On The Dark Forest - Part 1
- MEV and Me
- The 0 to 1 Guide for MEV
About Alpha Venture DAO (Previously Alpha Finance Lab)
A Builders’ DAO. We explore and innovate at the fringes of Web3 and drive significant value to Web3 users, and ultimately, alpha returns to the Alpha community.
Join our Telegram/Discord for the latest updates, follow us on Twitter, or read more about us on our Blog and Document!