How Ethereans are fighting against the threat of MEV
What it is, what its implications are, and how Flashbots, ArcherSwap, MistX, CowSwap, and BackRunMe are working on solutions to the issues it creates.
Maximal Extractable Value (MEV) is a radically new financial phenomenon that takes advantage of transaction ordering economics on public blockchain networks. It was an unexpected and new occurrence for most and came to the limelight during 2020’s Decentralized Finance (DeFi) boom. Some, like Phil Daian and numerous other researchers, were forward-looking enough to expect it unlike most; and extensively documented early signs of MEV back in 2019, preparing the research community for the mempool war that would ensue.
- What is MEV?
- CowSwap (Gnosis)
- BackRunMe (bloXroute)
- The implications of MEV
But what is MEV?
MEV is fundamental to blockchains. Any decentralized network that has some mechanism that allows users to express some economic preference for their transaction’s importance through, say, a miner tip, or generally any network where any validator receive a transaction and propagates that transaction or a block consisting of that transaction to other network participants will have MEV.
MEV is comprehensive, but one simple way of looking at MEV is as the value that is extracted by participants in the network that have a preference for how events take place on-chain, and where they can economically express that preference. This dynamic itself is a necessity in a public blockchain, as economic preference for transaction inclusion is how parties differentiate their transactions from spam transactions, which protects the network from denial of service attacks. Let’s consider the following.
Since DeFi exploded in 2020, many different decentralized exchanges and lending protocols have emerged. Across decentralized exchanges (DEXes), arbitrage opportunities exist when there is a price imbalance. Across lending protocols, when a flash crash occurs in crypto prices, the difference between a borrower increasing the health factor of a loan and a borrower being liquidated can ultimately come down to transaction ordering, and some party may be able to profit by pushing for the latter. Across protocols that utilize price oracles in general, there is a time window in the lag between oracle updates that some profit can be extracted.
Quantitative pros have designed bots to take advantage of arbitrage opportunities, which has had negative impacts primarily on decentralized exchange users; they are able to either steal a good price on one exchange that a user was trying to buy at then sell it on another. Since the bot stole the price that the user was buying at, the user’s transaction fails. The bots have also taken advantage of the [typically 2%] slippage included in a transaction to buy the asset at the quoted price before the user, then sell it to them right at the top of their slippage limit (also known as a sandwich attack). How do they get their transactions included before the user’s transaction was submitted? Either by paying more money; or being a dominant miner themselves.
The reason for the last point is that miners [or validators] are in an advantageous position in the blockspace marketplace. Validators both (a) produce blocks by picking and ordering from a pool of pending transactions and (b) propose blocks to add to the Ethereum network. This gives them the ability to extract value by ordering transactions in a way that maximizes the profits that their bots are generating. MEV is commonly misconceived as Miner Extractable Value, but this isn’t necessarily accurate: MEV is value extracted by those taking advantage of the latency between transaction submission and inclusion whereby some mechanism can dictate transaction ordering, which puts validators like miners in an obviously advantageous position to extract it, but it could also be a regular bot that makes an arbitrage trade and prioritizes its position in the transaction queue by attaching a high fee to the transaction.
As of today, MEV has allowed exploitative entities to extract over $750M. Some MEV transactions yield just hundreds of dollars in profits, while some yield tens of thousands of dollars in profits. In some cases, bot operators have spent tens of thousands of dollars on single transactions which would yield significant profits when executed.
It’s worth noting that MEV as a concept is not new. MEV exists on and across centralized exchanges; it exists across clearing houses in the traditional banking world. What is different with on-chain MEV is the rate and scale at which it becomes available in permissionless systems. If the Ethereum ecosystem is still small and MEV is large now, imagine how significant MEV will be when Ethereum grows by a factor of 10x.
MEV has some negative externalities, but it is also a means for creating a highly efficient marketplace. The amount of potential MEV on a blockchain network is a public bounty for balancing prices across exchanges and protocols, though sometimes comes at the expense of users — with failed transactions, and, arbitrage bots latching onto the same MEV opportunities has in the past resulted in inefficient use of blockspace and network congestion on Ethereum. Let’s go over some of the initiatives from the community to mitigate the negative externalities of MEV.
Flashbots is an MEV-focused company that has synthesized live on-chain data to categorize and sort rogue MEV transactions for the community, on their MEV Explore page (although, it is likely that this page underreports total MEV or will significantly underreport in the future, as the Ethereum ecosystem grows in complexity).
However, their main contribution to the ecosystem is in Flashbots Alpha which consists of MEV-Geth, an updated version of the Go-Ethereum node client that includes a direct channel for traders to bid for transaction inclusion with miners; and MEV-Relay, a centrally-operated relay network that aims to protect miners from spam related to MEV-Geth. MEV-Geth solved a critical problem at the time, where frontrunning and backrunning arbitrage bots were congesting the Ethereum network. Miners making use of Flashbots organize compatible arbitrage transactions into ‘bundles’ which get included at the top of the block; and in their v.02 release, Flashbots released bundle merging, which allows miners to include multiple bundles at the top of each block, improving efficiency. The Flashbots Dashboard shows what is happening within the Flashbots ecosystem, and the Flashbots Bundle Explorer shows Flashbots bundle transactions as they go live. Over 86% of the Ethereum hashrate has onboarded onto Flashbots to date.
Flashbots aims to create more transparency in the industry and democratize MEV extraction; where before, backchannel deals between traders and miners would allow certain actors to have an edge in the MEV game, Flashbots aims to create a network effect that convinces arbitrageurs and miners that it is better to play in a fair marketplace rather than doing secretive deals with specific arbitrageurs which could erode transparency, permissionlessness, and trust in Ethereum’s fairness. Flashbots Alpha in its current form is imperfect and is not permissionless, as MEV-Relay requires miners to be manually whitelisted to receive Flashbots bundles. It’s also not private, as it allows miners to see transactions in bundles before being included, which could raise concerns of miners executing transactions for themselves (although they would likely be blacklisted from Flashbots for now if they did choose to do this). It also does not offer finality protection against chain reorgs. Flashbots aims to solve the first two in the future by incorporating secure enclave attestations using Intel SGX as a replacement for a centralized MEV-Relay, called MEV-SGX. MEV-SGX would allow for separating the block construction and block proposal process, by allowing MEV extractors to construct and store a block with their transaction bundle at the top inside an enclave, which can attest to a miner that the block isn’t spam and that the MEV exists. The miner would use the truncated block header hash to compute the block’s proof of work, then receive the block which would be propagated to the network. MEV-SGX is still much of a work in progress, so for now, MEV-Geth is what the community has to work with.
A few teams have been creative enough to make use of MEV-Geth to power more efficient and user-friendly decentralized exchanges. Let’s go over them now.
ArcherSwap is a DEX aggregator (controlled by a mining pool DAO) that is compatible with Flashbots, which aims to offer optimal pricing (like most DEX aggregators), but also zero slippage and protection from being frontrun, backrun, or being sandwich attacked. When a user selects their trade parameters, they sign a transaction that contains data, allowing the ArcherSwap Relayer contract to pull the assets from their account and then submit the trade to Flashbots’ private mempool, rather than the public mempool. The transaction sits in the private Flashbots mempool, so it won’t be executed unless it can be executed successfully, which allows users to set very low slippage tolerances (basically, asking ArcherSwap to stick very close to the quoted price) without fears of wasting gas on a failed transaction. Since the transaction is being communicated directly with the miner through MEV-Relay, the transaction won’t be frontrun, backrun, or sandwich attacked by anyone else, or even the miner, who would get booted from MEV-Relay if they did. ArcherSwap transactions may be routed through Flashbots directly to the Archer DAO mining pool.
MistX is another DEX aggregator (controlled by the Alchemist DAO) that functions similarly to how ArcherSwap does in utilizing Flashbots, however it does not use a Relay contract and instead allows the user to interact with Flashbots more directly. Hasu’s article on MistX walks the user through a typical MistX transaction.
As a private organization, Flashbots could eventually extract a small fee from transactions for itself. The organization’s technology is already having profound network effects, and it intends to bolster its position in the MEV game by deploying solutions onto other blockchains when MEV plays a role on them. Flashbots seems like a unicorn in the making; another for-profit technology provider, like Starkware, that will play a significant role in the DeFi future; though there is room for other players to come in and disrupt their business with the right solution.
What is certain is that MEV exists, and in great scale. Flashbots miners alone are earning over 500 ETH in fee revenue on a bad day through MEV-Geth, which was around 22% of their total fee revenue (excluding block subsidies). The MEV that MEV exploiters are earning, based on Flashbots’ MEV Explore page, is ranging from $1M to $5M per day, and even then this could be significantly underreporting the scale of MEV.
Flashbots.tools is another app that lets anyone submit custom transactions directly to Flashbots’ MEV-Relay, which could be useful for the everyday layman in submitting a private transaction to a miner to rescue ERC20s from a compromised wallet, without alerting the compromiser by broadcasting a transaction to the public mempool. It requires users to paste in a private key, so it is advised to build the tool from source before using it.
CowSwap is a DEX and DEX aggregator hybrid, launched by the Gnosis team, which uses the Gnosis Protocol V2 to first check if it can match submitted transactions peer-to-peer without having to go through a regular AMM like Uniswap or Sushiswap. If two simultaneous users of CowSwap can have their orders matched together in some way, the Gnosis protocol uses its off-chain batch auction scheme to execute that trade. If it cannot, then it forwards the transaction to a decentralized network of solvers who compete to submit the transaction to the best-priced DEX available. Since solvers take on the risk of any potential failed transactions, the user doesn’t face any of the pitfalls of setting a low slippage transaction, and the low slippage itself supposedly makes the transaction protected against sandwich attacks. However, it is unclear if the Gnosis Protocol is enough to protect transactions from being frontrun or backrun, especially since CowSwap’s solvers would have to submit transactions to the public mempool rather than to a private mempool like Flashbots. The Gnosis team states that Flashbots is more expensive than what they are currently offering; it certainly seems like some competition is in the air.
This article breaks down individual transactions, and goes over the pros and cons of each solution.
BackRunMe is another solution to the MEV issue being offered by bloXroute, conceptually similar to Flashbots in that it offers a direct channel with validators, but very different. BackRunMe suggests that users should submit DEX trades and other transactions to BackRunMe and deliberately allow someone to backrun them, with the promise that they won’t be frontrun. BackRunMe shares a quarter of the profits that an MEV exploiter gets by backrunning them with the user, half of the profits with the miner, five percent with bloXroute, and gives only 20% to the arbitrageur. BackRunMe is another project aiming to have network effects that benefit both users, traders, and miners, but it’s incentives need to be studied further and pales today in the traction that Flashbots has.
The implications of MEV
The MEV debate is contentious and controversial. Some have suggested that MEV is outright theft and certain proposals that were made to hold MEV auctions to make MEV extraction more transparent and fair were labelled as glorified ‘frontrunning-as-a-service.’ Some have suggested that fair transaction ordering needs to be implemented on the Ethereum protocol itself. On the other hand, some argue that MEV is inherent in Ethereum as a permissionless and decentralized network, and even implementing some sort of fair ordering scheme will still leave MEV on the table and not properly address the issue, and that we need to think deeper to truly address the issue. Still, it’s clear that the solutions that teams have put forth are having a positive impact in reducing the negative externalities of MEV, at least by reducing the UX hazards that arbitrage bots were causing.
Some differentiate between “good MEV” described as general market arbitrage which tightens market spreads, or a liquidator that saves someone's loan from being liquidated; and “bad MEV” described as someone frontrunning a borrower’s loan repayment with a liquidation, or a miner censoring transactions on an L2 that uses fraud proofs, or if a miner sees an MEV opportunity 5 blocks in the past and implements a time-bounded attack to rewrite the blockchain’s history to take that profit.
Attempts to remove MEV from the protocol will simply result in miners and traders establishing off-protocol channels for facilitating MEV extraction. In the past, attempts to stop sandwich attacks — in which miners would both frontrun, then spam a transaction behind a users’ transaction in a backrun in that same block using the same gas price by updating the Geth client — simply propelled miners further towards using custom mining software, which pushes us further from a solution. All of this establishes a greater case for embracing MEV and focusing on democratizing its profits, whilst making it as permissionless and transparent as possible
Phil Daian argues that implementing some sort of fair ordering scheme will still leave MEV on the table and not properly address the issue, and that we need to think deeper to truly address the issue. Still, it’s clear that the solutions that teams have put forth are having a positive impact in reducing the negative externalities of MEV, at least by reducing the UX hazards that arbitrage bots were causing.
Emin Gun Sirer, the CEO of Ava Labs, argues that no protocol-level MEV exists on Avalanche, in which he likely assumes the notion of ‘Miner’ Extractable Value rather than ‘Maximal’ Extractable Value. There seems to be merit to his claims in that the same transaction prioritization mechanics and block latencies from Ethereum may differ Avalanche, which may vastly reduce the unfairness of any MEV. Phil Daian argues that while Avalanche makes good strides in the right direction, there still exists a power structure that allows certain parties to behave in a way that suits their preference; those participants in that validator set can still bias which transactions they propagate first and they can still influence outcomes probabilistically. Networks like Avalanche still have the same economic properties and implications on their consensus game as Ethereum.
MEV will exist in some form on Avalanche, as well as all other public blockchains and L2s. Cross-chain AMMs like Anyswap and Thorchain will also still leave MEV on the table for certain parties to extract from Avalanche, even if it isn’t extracted solely on Avalanche. Also, Avalanche has not yet seen the scale of DeFi volume that Ethereum has, so much remains to be seen with regards to how MEV manifests itself on Avalanche (and other chains) in the future.
Also, there are some minor implications for MEV when the EIP-1559 upgrade completes. Currently, direct-to-miner transactions on ArcherSwap, MistX, and BackRunMe, as well as peer-to-peer trades on CowSwap consume zero gas, instead directing fees via the smart contract to cover for the computation expenses. The base fee in EIP-1559 will force these transactions to pay a small gas fee, which will result in a minor change in how these transactions occur.
MEV is important, and particularly revealing of how unexpected dilemmas appear when we begin coordinating en masse in a radically new way. It is likely that more dilemmas like MEV will present themselves, and the community will need to be ready to react. The teams that got together and quickly devised strategies to mitigate the negative effects of MEV deserve applause, as their work has benefited everyone. More teams need to get involved in the MEV discussion, and more awareness needs to be raised about the solutions discussed in this article, as there is still lots of rogue MEV activity arguably resulting in some level of unfairness on Ethereum.
I encourage you to participate in the MEV discussions taking place on ethresear.ch and crypto Twitter. If you’ve got any questions, feel free to DM me on Twitter, and I’ll try my best to help out.
Join Coinmonks Telegram Channel and learn about crypto trading and investing
- What is Margin Trading | Dollar-Cost Averaging
- Earn crypto interest | Grid Trading Bot
- The Best Bitcoin Hardware wallet
MEV: The Ultimate Financial Battleground, Where Adversaries Come to Play was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.