What is MEV?

Coined in 2019, MEV stands for Miner Extractable Value. MEV comes from a few core features of Ethereum:

  • Transactions sit on a public mempool waiting to be mined into a block on the blockchain
  • All data required for the transactions are public
  • Any user can take this public data and transactions and do it themselves

Although the Ethereum network runs on consensus, the content of each block is chosen by just one miner (or staker come ETH 2.0). This creates opportunities for miners to extract extra profit from transactions by front-running, back-running, or sandwiching transactions (a combination of both).  

Why are such actions profitable?

Arbitrage opportunities

Due to inefficiencies and fragmentation of liquidity within the crypto markets, plenty of arbitrage opportunities exist. A frontrunner can scan the mempool for transactions which are attempting to score such arbitrages, then pay miners slightly more gas to place their transaction in front. This wins them the arbitrage value, minus the extra gas paid.

Sandwiching transactions

Currently, the vast majority of DEXs (decentralized exchanges) utilize a bonding curve AMM model to determine the price of assets within a pool. When a user (User 1) trades ETH for UNI on Uniswap, they add ETH and remove UNI from the pool. This causes the price of UNI/ETH to increase in accordance with the curve function (x*y=k).

A malicious user (User 2) can profit from this bonding curve mechanism by sandwiching such transactions. After seeing User 1’s transaction in the mempool, User 2 can front-run the transaction, placing a large trade of ETH for UNI just before User 1’s transaction.

This will cause the effective price of UNI/ETH within the Uniswap pool to increase. As a result, User 1 will receive less UNI.

Simultaneously, User 2 can back-run User 1’s transaction, placing their own transaction to sell UNI for ETH immediately after User 1’s. User 1’s transaction will cause the price of UNI/ETH to increase again, at which point User 2’s transaction will execute. User 2 thus makes a profit in ETH.

Why MEV is a problem

The term MEV is slightly misleading because it implies that miners need to actively engage in extracting value. In actuality, users will engage in priority gas wars in an attempt to get their front-running transaction to be placed first within the block. Miners passively benefit by simply collecting the extra gas paid by these frontrunners.

The rise in popularity of DeFi on Ethereum has caused the amount of MEV extracted to skyrocket. Since January 2021, over $700 million worth of MEV has been scooped up by Ethereum miners.

Source: Flashbots

MEV presents a significant issue to the health of Ethereum.

  1. Victims of sandwich attacks. Average DeFi users are exposed to the dangers of the Dark Forest. When a user submits a transaction on Ethereum, the transaction becomes visible in the mempool for anyone to see. Malicious actors can then make a profit at this user’s expense by front-running, or sandwiching the transaction.
  2. Congestion and high gas fees. The opportunity for MEV is also a large contributor to congestion on the Ethereum network. Front-runners engage in gas wars to attempt to have their transactions put first within the block. This causes gas fees to spike as front-runners bid higher and higher amounts of gas. This quickly fills up blocks, making Ethereum slower and more expensive.

Curious about whether or not you have been a victim of the MEV crisis? The sandwiched.wtf website (built by the Alchemist team) will tell you if any of your transactions on Ethereum have been sandwiched.

An example of a sandwich attack that happened to even Vitalik Buterin himself:

The attacker front ran his transaction to sell AKITA, resulting in Vitalik losing 1.4 ETH, or about 1.3% of the transaction.

Is there a solution?

Flashbots

The Flashbots team is constantly working on the MEV problem. In May 2021, the mistX exchange (powered by Flashbots) was launched. When using mistX, users’ transactions are not published to the public mempool. Thus, users are not exposed to malicious frontrunners. You can read more about mistX and how it works here.

Eden Network

The Eden project (Formerly Archer DAO) has also developed their own solution to MEV on Ethereum. Their system, the Eden Network, creates greater rewards for miners, whilst simultaneously protecting users from malicious MEV extraction.

Eden helps to prevent MEV by allowing users to submit private transactions easily via the Eden Network in order to obtain state guarantees around any submitted transaction, instead of sharing transactions across the network that are visible for front-running.

Eden Network for Miners

The Eden Network is a custom RPC that exists on the Ethereum platform. Ethereum block producers can choose to participate in the Eden Network by running the Eden-Geth client. By doing so, they will receive an additional and predictable stream of income in the form of $EDEN tokens, proportional to their hashrate percentage within the Eden Network.

Eden Network for Platforms

Platforms can join the Eden Network as Slot Tenants. For each block produced by the Eden Network, the first three transaction slots are set apart for Slot Tenants. Slot Tenants stake the $EDEN token in order to retain priority blockspace for transactions carried out on their platform. This benefits users of their platform, which in turn, attracts more users who want to avoid malicious MEV extraction.

According to their website, notable platforms such as SushiSwap, Band Protocol, and Alpha Finance have partnered up with Eden. At the time of writing, Bancor also holds a spot as a Slot Tenant.

Eden Network for Traders

Traders can avoid malicious MEV exploitation by interacting with the Eden Network RPC directly. By staking $EDEN and using the Eden RPC, traders can ensure their transactions are granted MEV protection.

Eden’s hashrate has more than doubled in August as well, currently with over 50% of Ethereum’s hashrate going through them at the end of August.

The price of $EDEN over the past month has more than doubled since the start of August, reflecting positive sentiments and demand for the project as $EDEN is required to be staked in order to have priority in the blockspace. This could be correlated to the NFT hype we are experiencing, with a rush to get priority of the blocks during an NFT launch.  

You can read more about the Eden Network and how it works here: https://docs.edennetwork.io/

Frequent Batch Auction

Another realistic approach would be to introduce a trading mechanism (protocol) that enforces batch auctions. The idea of having batch trading is to process orders across a time range and execute them in a batch simultaneously. This creates a price finding mechanism for correctly pricing token pairs with the same clearing price for each block.

In the DeFi system where both miners and validators have the ability to rearrange transactions, batch auctions settlements can get rid of such power from them by forcing the miners to execute transactions regardless of the order they have. Since batch auctions enforce uniform clearing prices, trade orders cannot alter the prices.

Batch auctions allow dapps built on top of a protocol to offer users improved trading methods, such as:

  • Gasless order submission, or when users submit off-chain orders via signed messages
  • Enforcement of the same prices for all trades that happen at the same time, even if they are from different traders
  • Help users get matched directly with one another – in a "coincidence of wants" – without depending on external, third party liquidity pools

For more on Batch Auctions: Implementation Details for Frequent Batch Auctions: Slowing Down Markets to the Blink of an Eye by Eric Budish, Peter Cramton, and John Shim*

Off-Chain Orders

Another approach is to engage in off-chain orders, essentially peer-to-peer order books with the trading activity occurring outside of the blockchain. For such orders, only eventual trade settlement happens on-chain. This means that transactions are not sent to the mempool individually, until they are sent and settled via the batch auction settlement transaction all at once at a later time.

An example of an off-chain order book DEX is dYdX:

Screenshot of DYDX Platform

By settling all in one batch, this makes it harder to replicate and causes the re-organization of transactions to be irrelevant as all trades have the same price regardless of the order.

Off-chain orders also enable protocols to be reliant on non-trading routes, which means that even when a miner picks up the signed messages and attempts to take advantage of them, it would not pose a problem as the miner would not know which AMM pool those trades will be settled against.

Such protocols do not force users to be bound to a specific trading path, which allows it to focus on achieving better prices rather than on executing transactions the fastest.

Protocols that have price-finding mechanisms based on batch auctions with uniform clearing prices and coincidence of wants (CoWs) allows users to enjoy a level of MEV protection unmatched by any other form of MEV prevention developed so far. This is because the protocol matches the trades without external on-chain liquidity, providing the level of protection we have never seen before. This essentially means that in the event of a CoW, the protocol would not be required to execute an on-chain transaction against an automated market maker (AMM) to make trades liquid.

Furthermore, if no CoWs were to be found, uniform clearing prices of a batch auction would make the transaction ordering of the auction irrelevant as all trades of the same token pair would be charged the same settlement price, thus eliminating the likelihood of MEV actors having an opportunity to extract value by reorganizing transactions.

Cowswap is an exchange built by Gnosis, and it protects users from MEV by reducing the amount of extractable value through peer to peer matching (coincidences of wants is abbreviated to CoW), and by delegating trade execution to a professional party that uses very tight slippage bounds at execution time.

Fast Blocktimes

Networks with fast blocktimes, such as Solana’s 0.4s blocktime, also makes it hard for front-running to occur. This is because if it’s too hard to compute if a sandwich attack is profitable within a fast blocktime, it is not effective to front-run transactions.

In Solana’s case, a leader doesn’t find out about the transactions until it is going to be their leader slot, giving them very little time to perform any MEV operations.

At the moment this is not a solution that Ethereum will be able to achieve, however with Ethereum 2.0 and sharding, the blocktime is expected to be reduced dramatically which would hopefully make it harder for MEV to occur, and reduce the amount of sandwich attacks.

Other Layer 2 Chains have also offered different solutions to the MEV problem:

Carbon's Demex

DEMEX, a derivative DEX built on Carbon

Carbon is a purpose-built Cosmos app-chain for trading that uses low block times and frequent batch auctions and to prevent the extraction of malicious MEV.

On Carbon, each block is like a mini auction, and all orders within a block are treated as the same price until they enter the orderbook. For an ask at $3k, if one trader bids at $4k and another at $3.5k, both bids will clear at the unit order price at $3k but the amounts will be prorated and divided up equally between the parties bidding for that quantity.

If there is no quantity at the current bid, and the ask is at $2.5k, it’ll take the weighted average of all the orders and be cleared via an auction. The price determined will be the one that best matches all limit orders, by calculating the clearing price that will match the highest number of parties.  

Optimism

Optimism is an Ethereum Layer 2 rollup scaling solution which formally separates the role of transaction ordering and transaction inclusion in the L2 chain. The right to order transactions is auctioned to the public in a ‘MEVA’, or Miner Extractable Value Auction.

Bankless offers a great explanation on how MEVAs work on Optimism:

"Importantly, the Optimism system enables the capture and repurposing of MEV. In the Optimism L2 system, the roles that miners have (to order transactions and validate blocks) is divided into two separate actors: Sequencers order transactions and Validators add them to the Optimism L2 blockchain.

The right to become a sequencer is then auctioned off to the free market. This is called MEVA, or MEV Auctions, where the right to be able to capture MEV is repeatedly auctioned off for baskets of time.

Note: The specific designs around how a MEV Auction works in practice is still under construction, but the general idea is that there are different ways to extract and focus MEV with a free-market auction mechanism. As Optimism gets rolled out to more and more DeFi apps, the data will come in about how to best construct a MEVA.

Just as front-runners attempt to outbid each other’s transactions to capture MEV, those who wish to capture MEVA are forced to bid for the right to sequence transactions, and ultimately hand this value off to the auctioneer. That auctioneer is Optimism, and the Optimism team intends to enable the redirecting of this captured value to parties that were never going to be able to access it in the first place, but arguably should have: The developers who built the contracts in the first place!

If there’s a group of average retail market participants who are using a Public Good like Uniswap, then there is therefore MEV. If there is MEV, there are bids to sequence the transaction. If there are bids to sequence the transactions, then there are MEVAs where the value is converged.

But this entire chain of economic activity is a result of some developer that built the contracts being transacted on in the first place… and nowhere in this economic chain is the developer being compensated or rewarded for their work. Optimism and MEVA fixes this, offering a potential business model for smart-contract developers."†

Conclusion

MEV presents a key issue to the overall health of the Ethereum ecosystem. The amount of MEV has skyrocketed recently and if nothing is done, will cause the Ethereum ecosystem to be slow and expensive to use, and have a growing number of victims from sandwich attacks which will cause them to leave the ecosystem.

However there are various solutions being built, from batch auctions, MEV Auctions and more, with private mem pools being the popular pick at the moment. However, that presents a potential risk of turning Ethereum into a permission chain unless certain decentralization matters are addressed.