A guide to MEV on Ethereum
Ethereum is one, if not the largest blockchain ecosystem in the crypto space. There are thousands of tokens, projects, DAOs, and communities all built on top of Ethereum thanks to its customizable token standards, and a host of other features.
But one of the lesser-known features of Ethereum is something called MEV, or “maximal extractable value”. In this article, we’re going to be exploring this idea in more detail, and how it impacts the buying and selling of tokens on Ethereum.
What is MEV?
At its simplest, Maximal Extracable Value is a hidden tax on all types of Ethereum transactions. That means any time you want to transact in DeFi: from buying or selling an NFT, lending tokens to a liquidity pool, or swapping one token for another, a group of opportunistic users known as “searchers” have the opportunity to see your trade, and manipulate the criteria surrounding your trade to ensure they make profit, at your expense.
There are lots of different ways MEV can take place on Ethereum, which we’ll explore further down in the article. But for now, it’s important to understand the mechanics of MEV, and how Ethereum makes this all possible.
How Does MEV Work?
On Ethereum, validators, the entities responsible for verifying transactions, are allowed to re-arrange the order of transactions as they see fit. Validators typically do this if there are opportunities to improve the profit they receive from validating transactions.
Let’s take a closer look at this concept. When you submit a transaction on Ethereum, it does not immediately get added to the next block.
Instead, it first goes into the “mempool” which is the collection of all pending transactions. This pool is visible to anyone. You can see a screenshot of this below. And if you’re curious to see what it looks like, here’s a live feed.
Here is where the opportunity to extract value through MEV comes in. Because validators are not required to add transactions to the block in the same order that they were submitted by users, anyone can pay those validators to re-arrange transactions in a certain way.
This manipulation of the order of things allows MEV to happen. A person and or entity, sometimes referred to as ‘searchers’ look for trades they can make money from.
In the next section we’ll look at the specific ways at how MEV can take place.
The Different Types of MEV on Ethereum
There are broadly four types of MEV on Ethereum. They are:
-
Frontrunning
-
Backrunning
-
Sandwich attacks
-
Loss versus rebalancing (LVR)
We’ll look at each one of these in turn.
Frontrunning on Ethereum
Frontrunning is a particular type of MEV that affects all forms of Ethereum transactions including trades, NFT mints, and more.
Frontrunning takes place when a user makes a transaction but gets “front run” by an MEV bot who makes the same transactions ahead of them.
This happens in three distinct steps:
-
A searcher goes looking for potential trades in the Ethereum mempool: The first step involves monitoring the blockchain network’s mempool, a holding area for pending transactions. Here, frontrunners, who are often sophisticated bots, scan the mempool to identify transactions that can carry significant value that they want to snatch away or that could influence the price of a particular asset.
-
A searcher picks a transaction it can make profit from: The frontrunner will analyze the potential market impact once such a transaction is identified. For instance, if a large buy order for a specific token is detected, the frontrunner knows that this transaction could increase the asset’s price once processed.
-
The searcher places a new transaction BEFORE the transaction in question: The frontrunner will place their buy order for the same asset, intending to get their transaction processed before the initially detected transaction. They typically give the validators a higher “tip” to execute their transaction first in the block in comparison to the target transaction.
This feature on Ethereum costs users billions of dollars in lost value, benefitting more sophisticated actors working on Ethereum.
We have a longer article on “What is Frontrunning”.
Backrunning on Ethereum
Backrunning is another form of MEV that affects various Ethereum transactions, including trades, NFT mints, and more. Unlike frontrunning, backrunning takes advantage of transactions after they have been executed.
Backrunning occurs when a user makes a transaction that gets followed by an MEV bot executing a strategic transaction right after theirs in order to capture a price movement.
-
Monitoring Pending Transactions: Like frontrunning, backrunning attacks begin with searchers monitoring the mempool for profitable opportunities. In particular, they are looking for transactions that cause a large price impact, as the backrunning attack involves capturing the arbitrage opportunity left behind after a large trade.
-
Finding a Transaction with a Large Price Impact: Once a valuable transaction is identified, the searcher analyzes its impact. For instance, if a large sell order for a specific token is detected, the backrunner knows that this transaction could decrease the asset’s price once processed.
-
Capturing the Price Impact: By placing a transaction directly after a previous, large transaction, the MEV bot can capture the price movement that the transaction causes on the AMM. The backrunner makes a transaction correcting this price impact and collecting the arbitrage in the process.
Backrunning is considered the least harmful type of MEV. While it still captures value, it does not do it at the expense of the trader. When done in isolation, it only captures leftover arbitrage after a large transaction moves an asset’s price.
We have a longer article on “What is Backrunning” if you’d like to know more.
Sandwich Attacks on Ethereum
A sandwich attack combines both frontrunning and backrunning to extract the most value from a transaction.
This is when a transaction gets sandwiched between two hostile transactions, one before and one after. As a result, the original transaction executes at a much higher price than necessary, leading to an inflated price for the original trader and a profit for the searcher placing the two extra trades.
This happens in four distinct stages.
-
A searcher looks through the public mempool: Like all other types of MEV, sandwich attacks begin with searchers monitoring the mempool for profitable opportunities. What they are looking for is large trades where they can capture value before the transaction, and afterwards.
-
A searcher inserts a frontrunning transaction: When a trade is identified, the searcher will duplicate it and place their own transaction right before the victim’s — in essence frontrunning. The searcher gauges the size of their transaction to cause just enough price impact to push the asset’s price up to the precise slippage tolerance the victim has set.
-
Re-order the transactions: Since a sandwich attack is a 2-part process, the searcher orders transactions so that the victim’s transaction executes right after the seracher’s frontrunning transaction, but just before their backrunning transaction.
-
Complete the attack by inserting a backrunning transaction: After the victim transaction executes, its price impact pushes the price of the asset even further (remember it was already raised as a result of the searcher’s frontrunning transaction). Once this takes place, the searcher executes a backrunning transaction, selling the asset and profiting from the arbitrage.
Sandwich attacks are the most common types of swap-related MEV, taking advantage of a user’s slippage tolerance to cause maximum pain for the trader and maximum profit for the searcher.
If you’d like to know more, we have an article dedicated to understanding “What is a Sandwich Attack”.
Loss-Versus-Rebalancing (LVR) on Ethereum
The last form of MEV on Ethereum is loss-versus-rebalancing (LVR). This is a distinct type of MEV that affects liquidity providers (LPs) and accounts for more value loss than all other types of MEV combined. LPs typically lose 5-7% of the total liquidity per year to this phenomenon.
This is because liquidity providers - who facilitate trades in DeFi by providing liquidity to certain trading pairs - can be exploited when the price of an asset is not universal across all markets. Let’s take a closer look at how LVR.
LVR is a form of arbitrage that occurs whenever an AMM has an outdated (stale) price in comparison to some other trading venue.
Arbitrageurs exploit this price difference by trading from the AMM to the more liquid exchange (usually a centralized exchange like Binance), correcting the arbitrage and extracting value from LPs in the process.
It sounds complicated, but essentially it’s the buying and selling of assets done in a way that takes advantage of prices not being universal. Learn more about LVR in our article: “What is Loss-Versus-Rebalancing (LVR)?”
Is MEV on Ethereum a bad thing?
Like many things in crypto, the easiest answer is, “it’s complicated.” MEV is no different.
Some argue MEV is a natural part of the Ethereum market mechanism and it helps to find the most efficient prices. Others believe that MEV can be harmful, but only if it’s concentrated in the hands of a few validators — therefore they work to “democratize” MEV and allow anyone to extract value from on-chain transactions.
Whatever side of the fence you sit on, if you don’t want prying eyes spying on your trades, there are a number of strategies and tools you can use to prevent MEV from happening to you.
How to Protect Yourself from MEV on Ethereum
There are multiple ways to avoid MEV. Some you can do yourself but others offer a more comprehensive form of defense that mean you can set and forget. Below are a list of the most effective tools you can start using today.
Reduce Slippage on Ethereum
The most basic defense against MEV is setting a low slippage tolerance. Slippage tolerance is essentially how much variation in the final price you receive you are willing to accept.
Transactions with a lower slippage tolerance give searchers less room to exploit trades.
For users who aren’t utilizing any other MEV protection tools, setting a lower slippage tolerance can be a good first line of defense, however it’s by no means a complete solution.
Setting the slippage tolerance too low often results in failed transactions. Even with optimal slippage, MEV bots may still be able to extract value from your trades.
So sometimes we need to do more than adjust our slippage.
Use a Custom RPC Endpoint on Ethereum
A better protection method is to install an MEV protection RPC endpoint. A Remote Procedure Call (RPC) endpoint is an intermediate layer that routes transactions from a user’s wallet to the blockchain itself.
One of the most popular specialized RPC endpoints is MEV Blocker. As the name suggests, MEV Blocker provides protection against MEV across all of Ethereum. The RPC works by managing a permissionless network of searchers and hiding transactions from the public mempool. These searchers cannot frontrun or sandwich user transactions.
Instead, they capture value through backrunning. Anytime a searcher backruns a user’s transaction, the searcher keeps up to 10% of the value and sends the other 90% back to the user as a rebate.
Install MEV Blocker here: https://cow.fi/mev-blocker
The best solution? Use an MEV-Protected DEX
CoW Swap is a meta DEX aggregator that finds the best prices for trades and provides comprehensive MEV protection. The protocol uses a unique trading mechanism that relies on batch auctions and intents to achieve the best outcomes for users.
Thanks to a powerful combination of delegated trade execution, batch auctions, and protected transaction flow through MEV Blocker, CoW Swap users benefit from thorough MEV protection on all trades.
Try CoW Swap here: https://swap.cow.fi/#/
In summary
MEV is a critical problem for the Ethereum ecosystem because it undermines the fundamental principles of fairness and transparency that blockchain technology aims to uphold. The ability of sophisticated actors to extract value from everyday traders pushes users away and discourages the broad adoption of decentralized technologies.
Addressing — and eventually solving — MEV is essential to keeping Ethereum a robust, innovative, and user-friendly platform for all participants. To this end, CoW DAO is working hard to secure a decentralized future by creating products that ensure a fair and protective decentralized financial system.
Learn more about CoW DAO, its mission, and its various products here: https://cow.fi/.