Ethereum is a machine with many cogs, and the vast majority of its users are unaware of the mechanics at play behind the scenes. One such mechanic is the ability of miners to control transaction inclusion and ordering as they wish, which has given rise to miner extractable value (MEV), more recently referred to as maximal extractable value. As one of the leading causes of network congestion and high gas prices on Ethereum, MEV transactions have extracted over $600 million on Ethereum since December, 2019; it is a real problem with a great deal of solutions and debates surrounding it. This article will define and explain MEV, its current presence on Ethereum, its implemented and proposed solutions, and its effect on Ethereum’s future landscape.
When a user submits a transaction on Ethereum, that transaction is sent to a mempool, the place in which all transactions stay until miners include them in their blocks to confirm them. The miners can choose freely which transactions to include from the mempool, undoubtedly prioritizing the transactions that were sent with the highest gas fees in relation to the other transactions. A transaction with a high gas fee can be sent and confirmed faster than another transaction sent before but with a lower gas fee.
Mempool Visualization (Source: Blocknative)
As such, transaction ordering in Ethereum blocks is arbitrary and not indicative of the order in which the transactions were sent. This presents an opportunity for those controlling the transaction ordering to order them in a manner that will yield them the most profit. These controllers can be either the miners themselves, who can include, exclude, and reorder transactions as they wish, or external actors, such as bots, who can determine the placement of their transactions in a block by setting specific gas fees in relation to the other transactions.
MEV is the measure of the maximum profit a controller can achieve by including, excluding, or reordering the transactions in a block, hence the reason it is called maximal extractable value. There are various MEV extraction opportunities, such as arbitrage trading, sandwich attacks, and liquidation hunting.
Arbitrage Trading
A token is trading at $10 on DEX A and at $11 on DEX B. After confirming that liquidity and slippage is sufficient to profit, a bot could buy on DEX A and sell on DEX B in a single transaction, pocketing the profit.
This type of MEV extraction can be beneficial to ecosystems as it balances prices across DEXs constantly and gives users fair market prices.
Sandwich Attacks
A trader submits a transaction to buy $1000 worth of a token on a DEX, with their slippage set to 5%, which means they are still willing to buy the token were its price to change by up to 5% while their transaction is pending.
A bot could submit a buy transaction to increase the token’s price by 5%, adjusting their gas fee so their transaction confirms before our trader’s transaction, followed by a sell transaction to confirm after our trader’s transaction.
This “sandwiches” our trader’s transaction and causes them to buy the token at a 5% premium.
Our bot pockets the small extra amount our trader paid.
Liquidation Hunting
A trader borrows 1000 USDC on Compound with $1500 ETH in collateral. Their collateral ratio is set at 130%, which means if the price of ETH drops for their collateral to be worth less than $1300, they can be liquidated.
DeFi lending protocols allow anyone to act as the liquidators to keep the protocols solvent, as liquidations carry the cost of gas fees.
Our bot sees that our trader is undercollateralized as the price of ETH has dropped for their collateral to be worth $1200. Our bot sends 1000 USDC to the Compound protocol and receives the ETH collateral in exchange, which they can sell on a DEX in the same transaction for a profit.
MEV bots will compete for their transactions to be included first in Ethereum blocks in pursuit of the opportunities above, usually resulting in gas wars between these bots. Miners or validators always profit, either from running these strategies themselves or simply by receiving the inflated gas fees caused by the MEV bots’ gas wars. General users always lose, either by being a direct victim of an MEV opportunity, such as a sandwich attack, or by paying inflated gas fees for normal transactions.
However, the effect of MEV transactions on Ethereum network congestion and gas prices has lessened since the inception of Flashbots, which is “a research and development organization working on mitigating the negative externalities of current [MEV] extraction techniques.”
While Flashbots does not aim fully to solve the issue of MEV, they aim to mitigate it through three aspects: bringing transparency to MEV activity, democratizing MEV extraction, and redistributing MEV revenue.
Flashbots Banner (Source: Flashbots)
1. Bringing Transparency
With their mev-inspect software, Flashbots has made it possible to scan Ethereum blocks and collect data relevant to MEV extraction. In a block, it finds miner payments, token transfers and profit, swaps and arbitrages, and more.
Their dashboard MEV-Explore visualizes this data and allows anyone to have a clear overview of MEV extraction activity and numbers.
2. Democratizing Extraction
With their mev-geth software, which is a patch on top of the go-ethereum client, Flashbots provides a private communication channel between Ethereum users and miners to communicate preferred transaction order within a block. This moves the bidding war away from the public Ethereum mempools and helps to relieve congestion. As Flashbots states:
“MEV-Geth provides a way for miners to delegate the task of finding and ordering transactions to third parties called ‘searchers’. These searchers compete with each other to find the most profitable ordering and bid for its inclusion in the next block using a standardized template called a ‘transaction bundle’. These bundles are evaluated in a sealed-bid auction hosted by miners to produce a ‘block template’ which holds the information about transaction order required to begin mining.”
Using this method, MEV bots will use first-price sealed-bid auctions to communicate their bid for transaction order preference, hence they will pay no failed gas fee if their bid does not win, as their transaction simply will not submit, unlike public mempools where the transaction would fail, wasting block space and money for the bot. This mechanism also eliminates frontrunning between all MEV bots involved in the process.
While this is not a solution to the MEV issue, it allows for efficient extraction without an effect on Ethereum gas fees and network congestion as the extraction happens privately between miners and users. Although, general users still are vulnerable to sandwich attacks and similar MEV extraction opportunities.
3. Redistribute Revenue
While it does not seem that Flashbots has achieved this goal yet, they have developed Flashbots Protect, which is an RPC endpoint for Ethereum. Sending transactions through this RPC will send them to Flashbots, carrying several benefits, such as frontrunning protection, no failed transactions, and priority in blocks.
Flashbots has helped to mitigate the negative effects of MEV extraction ever since their mev-geth software gained traction among both users and miners. However, the issue remains as MEV bots still can choose to use the traditional forms of extraction, clogging block space, inflating gas fees, and draining capital from general users. A different approach that seeks to eliminate MEV extraction fully is the Chainlink Fair Sequencing Services (FSS) concept by Chainlink Labs.
“In a nutshell, the idea behind FSS is to have an oracle network order the transactions sent to a particular contract, including both user transactions and oracle reports. Oracle nodes ingest transactions and then reach consensus on their ordering, rather than allowing a single leader to dictate it. Oracle nodes then forward the transactions to the contract. They sequence these transactions by attaching nonce or sequence numbers to them or sending them in batches.”
Were Uniswap to implement FSS, any transactions sent through it would be forwarded to an oracle network that would determine their order among many other pending Uniswap transactions. Once it has ordered the transactions, the oracle network would send the transaction batch onward to be mined. This removes a miner’s ability arbitrarily to include, exclude, and reorder transactions, and the ability for users to manipulate their transaction’s order in a block by setting specific gas fees. Effectively, this would eliminate any form of MEV extraction for any protocol that implements FSS.
FSS is also exploring a variant in which “oracle nodes monitor the mempool of a target blockchain and pluck transactions from it on behalf of a relying contract.” A user can then submit a transaction as they would normally and an oracle network would ensure the fair ordering of transactions for the specific protocol with which the user is interacting.
FSS Mempool Monitoring Visualization (Source: Chainlink)
However, the concept presents a challenge: determining fairly the order of the transactions sent by users.
The obvious solution to the order-fairness challenge is to order transactions in the order in which they were sent. However, as transactions are sent across the world, it could prove challenging to determine their relative timestamps. An example order policy for FSS is to order a transaction first if a large fraction of nodes receive it before other transactions. However, as FSS is still in its inception phase, various other policies could be introduced and implemented.
The Chainlink FSS currently is the most viable solution to eliminate the issue of MEV extraction completely. However, it carries its own challenges as its implementation can prove difficult and many might not agree with externalizing the ordering of transactions and moving the process off-chain.
During the event known as The Merge, Ethereum will switch from proof-of-work to proof-of-stake in a full transition. The merge will not impact the network fees or scalability of Ethereum significantly; it will move the power of securing the network, including the power of MEV extraction, from miners to validators.
In their article on the topic of MEV in Ethereum post-merge, Obadia and Vemulapalli state that:
“Since the transaction ordering process in eth2 will be the same as that of PoW Ethereum, it is reasonable to think that MEV opportunities will still exist as we know them today. The difference lies in who has ultimate control over the ordering, namely validators rather than miners, who have been selected to propose a beacon block.”
Comparison of Block Inclusion Before and After Ethereum Merge (Source: Flashbots)
Furthermore, they ran the numbers and determined that MEV extraction remains profitable for validators. While they pose a few open questions in their article, such as the effect of the increased amount of time a selected proposer has to optimize their MEV extraction, they determine that MEV extraction still will exist in Ethereum post-merge.
However, both the software developed by Flashbots and Chainlink’s FSS can be modified to work in a proof-of-stake system. As such, Ethereum switching to proof-of-stake has little effect on MEV extraction opportunities and the debates surrounding them.
A spotlight has been cast on MEV during the past two years, leading to current solutions to optimize and democratize MEV extraction, such as the mev-geth software by Flashbots, or proposed solutions to eliminate it fully, such as Chainlink’s FSS.
Hopefully, general users reading this article have gained insight into MEV extraction opportunities that directly could affect them and the mechanics at play behind the scenes. General users can protect themselves already using the Flashbots Protect RPC, yet they are still exposed to inflated gas fees caused by MEV extraction, and as such, MEV remains an issue.
It seems the future landscape of MEV on Ethereum looks quite consistent with its current state, until the implementation of more drastic measures, which lies fully in the hands of the developers working towards mitigating MEV extraction by creating or conceptualizing solutions. Until then, us general users will need to set low slippages and wait for cheap gas prices.