UPD 2024/08/28: Two months ago, I authored a series of articles for Etherpedia, an initiative by the 2077 Collective aimed at providing beginner-friendly content on various Ethereum technologies and roadmap elements. This series included an article titled “The Roadmap: How to Train Your MEV,” which draws heavily from the article you're reading right now. As I consider it an enhanced version of this article, I strongly recommend reading the updated version instead.
I’ll keep the original article uploaded for historical purposes.
Foreword: by “unavoidable“ I don’t mean that it’s impossible to get rid of some MEV, but that all smart contract networks with trustless sequencing have or will have it by default if they don’t fight it. In this article I’ll dispel some myths about MEV, particularly “Ethereum has MEV because it’s broken, chain X does not have it“ and look at different methods to fight MEV.
What do Bitcoin and high-TPS L1 maxis have in common? You probably won’t guess, so I’ll answer - they both use absence of MEV as an argument for their chains. Of course, I see these arguments as completely inappropriate. To prove it, let’s define MEV.
MEV (maximal extractable value) is a practice of block builders using their right to order transactions in their blocks at their discretion to insert certain transactions in certain positions to get additional profit.
As example, on Uniswap ETH costs 1500 USDC, and on Sushiswap it costs 1510 USDC. Block builder creates an arbitrage transaction and inserts it before anyone else’s transactions to prevent anyone from using this arbitrage opportunity before them. By that, block builder got profit from this arbitrage in addition to block reward and priority fees.
However, there are many ways how block builder can use transaction ordering for additional profit. I like this terminology from Domothy:
Non-toxic MEV is MEV that does not affect specific users. An example above is example of such MEV.
Toxic MEV is MEV that targets specific trades, affecting their initiators. Mostly it’s frontrunning (sandwich) attacks.
What’s frontrunning (sandwich) attack? It’ll be simpler to explain by example:
I want to buy 1 million USDC worth of ETH on Uniswap. I create such transaction with 1% slippage (slippage is maximum difference in price at which I’m still willing to make a trade).
Builder that creates a block sees my transaction in mempool, creates a transaction that buys maximum amount of ETH that does not increase the price more than by 1%, inserts it in their block, then inserts my transaction, then inserts their own transaction that sells ETH bought from their previous transaction.
Because my trade is large, it increases ETH/USDC ratio in the pool, which is in turn abused by the block builder. From the point of transaction ordering, it looks like that - they buy ETH cheap making it more expensive, I buy ETH for high price and make it even more expensive, they instantly sell those ETH for the new price, returning the price to previous values and receiving the profit at my expense.
It’s sometimes called sandwich attacks because our transaction is inserted right between two builder transactions, making it similar to sandwich.
While it may seem that both types of MEV are harmful, non-toxic MEV is actually helpful for users.
Before PoS, MEV was not as developed, mainly because the block reward (static 2 ETH/block) was much higher than potential MEV rewards. All arbitrages were happening with on-chain gas competition, which affected gas fees. With MEV, there is no competition for arbitrage, so users can enjoy nearly identical prices on all DEXs without suffering constant gas price “pallet“.
It looks like a great money generator, why don’t all chains have MEV-extracting builders?
With Bitcoin it’s simple. Bitcoin does not have decentralised exchanges because it does not have actual smart contracts. Bitcoin miners don’t extract MEV because there’s nothing to extract it from.
With high-TPS L1s (and by this term I mean dPoS chains), it’s because they are centralised and a right to build blocks is restricted to several entities. For example, BNB Chain has 61 validators, Polygon PoS has 100. They’re usually affiliated with chain team and have an obligation not to extract MEV.
Trustless networks are already starting to get their own MEV solutions. Solana, 3rd smart contract platform with trustless sequencing, has Jito, MEV-boosted validator client. I honestly don’t know why Avalanche, 2nd in this rating, doesn’t yet have its MEV, I assume that it’s because most of its TVL is concentrated in lending platforms and doesn’t circulate.
If we have a public transparent chain with large economic activity happening 24/7 where everyone can build their blocks how they want, it’s impossible to make sure no one’s extracting MEV or only extracting non-toxic MEV.
Is there anything we can do about it?
If we look at non-toxic MEV, I think it’s probably impossible to prevent it.
The point of arbitrage is that you buy for less in one place and sell for more in other place, leveling out supply-demand ratio and therefore price in these two places. To prevent it, arbitrager must not know what price can DEXs offer for certain pairs, which is obviously not possible.
However, preventing toxic MEV is more than possible.
One of solutions that Justin Drake (i don’t know if he was first) suggested is encrypted mempools. As far as I understood, the point is to make encrypted batch transactions which are decrypted only on execution. With this system, it’s not possible to attack certain transactions, only to make some work before and after batch execution, which greatly minimises toxic MEV possibilities.
One DEX that has similar algorithm is CoW Swap.
CoW Swap packs all trades in batches and executes them at one time, so it’s impossible to frontrun certain trade inside the batch. Batches can be created by anyone, so the system does not rely on trust.
It’s worth noting that encrypted mempools mostly are generally not intended to be enshrined in protocol, they can be used by certain protocols that want to protect their users from MEV.
MEV Burn
It’s quite off topic, because it doesn’t prevent MEV itself, but I still want to tell about it, because it’s interesting technology that can help turning MEV to something helpful for the network and from some side even for the users. Also, it’s mentioned in the Ethereum roadmap by Vitalik.
MEV Burn is the part of Proposer-Builder Separation, a proposal that separates block proposing and block building to different entities of the consensus. Its point is an election of block builder based on how much ETH they burn in their block. A simplified example:
Builder A has built a block that collects 1 ETH MEV and notifies the chain that their block can burn 0.5 ETH (they want to keep other 0.5 ETH for themselves)
Builder B has built a block that collects 0.8 ETH MEV and notifies the chain that their block can burn 0.6 ETH (that is, they’ll keep 0.2 ETH)
Builder bids time is ended, chain elects Builder B for building the block because it burns the most ETH.
How is it helpful for users?
Right now, ETH economics work like this: the more people use Ethereum, the higher the fees. The higher are fees, the more ETH is burned. The more ETH is burned, the higher deflation rate. If few people use Ethereum, fees become lower and ETH becomes inflationary, incentivising people to spend it more actively.
MEV burn pushes ETH economics forward: burn rate depends not only on gas usage, but also on economic activities happening on chain. The more trades, loans, etc happen on chain, the more MEV opportunities appear. The more MEV is extracted, the more ETH is burned. All next steps repeat steps from paragraph above :)
By that, Ethereum usage that affects ETH inflation/deflation rate is not just gas used, but actual economic usage by people. Roughly speaking, people can theoretically use 5m gas per block but execute so large amount of trades that ETH will still be deflationary.
In short, MEV burn raises “ultra sound money” to another level.
Summary
MEV will always exist on chains with high economic activities where block building is available for everyone, because MEV is not property of Ethereum, but property of market - making as much money as possible when possible. While it’s not possible to fully prevent MEV, we should seek for solutions that minimise damage from MEV, using encrypted mempools or any other technology. Some of them even already exist and you can use them today.
Thanks for reading.