The fast-paced, high-stakes world of MEV has been compared to:
a “Dark Forest” in which predatory alien civilizations eviscerate each other
crypto’s version of high-frequency trading (HFT)
the mafia underworld
the symbiotic relationship between cleaner fish and sharks
MEV is like a soap opera, if the characters were all trading bots and crypto geeks. There are stories of bot-vs-bot battles, complex heists, and millions of dollars made and lost in seconds. If that doesn’t make you curious to learn more, idk what will. Let’s dive in.
Level 1: Normie
MEV is the potential profit that’s available to whoever builds the blocks in a blockchain. “Building a block” means looking at all the transactions users have submitted and deciding which ones should be added to the next block, and in what order.
MEV originally stood for “miner extractable value” since it’s miners who race to create blocks in proof-of-work (PoW) blockchains like Bitcoin and Ethereum. But as Ethereum transitions to proof-of-stake (PoS) and other PoS chains gain market share, the term had to be updated since PoS chains replace miners with validators. It’s now been renamed to “maximal extractable value” to encompass all the various parties that create blocks.
How does MEV work?
MEV is all about exploiting the privilege of being able to include, exclude, re-order, or insert transactions into the next block.
Block builders make this decision by looking at the transactions in the mempool — an off-chain collection of pending transactions hoping to be included in the next few blocks, sort of like a virtual waiting area — and determining how they can strategically arrange the transactions to earn the greatest profit. Profit-maximizing strategies can be benign (e.g. builders prioritizing transactions that offer fees for being included) or more problematic (e.g. if the builder observes a profitable trade, they can front-run it by including their own copy of the transaction first).
MEV trades are typically made by bots called searchers that scour the mempool for transactions they can leverage to make a quick buck. By observing these transactions before they’re finalized — that is, before they’ve made it from the mempool into a block — the bots get a glimpse into the blockchain’s future. This early knowledge can be extremely valuable.
An example: Imagine you own Token A on Ethereum. You’re watching the mempool and you notice that a whale just submitted a transaction selling a massive chunk of Token A. This sell-off is biiiiiig — big enough to tank the token’s price. The instant the whale’s order gets added to a block, the value of your Token A holdings will plummet.
In this situation, you’d rush to submit a transaction selling all of your tokens, hoping you can get your order into a block before the whale’s. The miner building the next block could therefore profit from their powerful position by charging you the right to have your transaction occur first. This profit is one form of MEV.
A more complex (but more realistic) case of MEV in this situation could come from an arbitrage bot with no prior position in Token A. The bot knows the large sell-off will tank the price of Token A on whichever exchange the whale is using, but it won’t immediately impact the price on other exchanges. After the trade occurs (but within the same block of transactions), the bot could race to buy Token A on the whale’s exchange at a discount, then sell it on other exchanges for a quick and easy profit.
MEV Winners
MEV benefits both searchers and whoever builds blocks (miners, validators). Searchers make money on each trade, but they usually have to pay high fees to incentivize block builders to put their transactions in the right place — for example, immediately after a large token swap. Several bots will often compete to make the same trade, outbidding each other with higher and higher fees in a process known as a priority gas auction.
Miners and validators can benefit from MEV by passively collecting these fees from searchers or by running their own trading strategies and directly adding their transactions to the blocks they produce. The profits at stake here are massive — over $664M in successful MEV capture on Ethereum since January 2020.
MEV trades also benefit the blockchain ecosystem at large by making markets more efficient. For example, arbitrage bots ensure prices are stable across exchanges, and liquidation bots allow collateralized lending applications to function properly.
MEV Losers
Buuuuut of course shady trading bots also come with their downsides. Various MEV strategies can result in greater slippage (worse prices) on token swaps, failed transactions because trades were front-run, and have historically contributed to higher gas prices for all users as bots spammed the network with transactions.
Normie Additional Resources:
Level 2: Degen
There are several flavors of MEV strategies. They can be categorized by where the value-extracting transaction is inserted:
Frontrunning: inserting a transaction just before some target transaction
Ex: racing to be the first to liquidate a user whose collateral has dropped below the minimum collateralization ratio. (More on liquidations and the reward mechanisms used by different lending protocols here.)
Top liquidation MEV transaction: $3,264,587.08 in gross profit
Backrunning: inserting a transaction just after some target transaction
Ex: arbitrage across DEXs following a large transaction
Top arbitrage MEV transaction: $2,848,770.92 in gross profit, made just a few weeks ago
Ex: buying up large quantities of a token as soon as it’s launched
Sandwich Attack: a one-two-punch combo of frontrunning and backrunning. Involves placing one transaction just before a target transaction, and another just after the target
Ex: forcing a user to incur slippage on large trades made using AMMs
MEV strategies can also be characterized by how specialized they are. Some bots focus on very particular trades, while others rely on extremely generalized programs that analyze all sorts of transactions to see if they would be lucrative to mimic. These generalized frontrunning bots pose a particular challenge when white-hat or black-hat hackers try to withdraw funds from vulnerable smart contracts (the iconic Ethereum is a Dark Forest post describes one such story). In the worst case, attempts to save users’ funds can inadvertently end up delivering them straight to MEV bots — not exactly an ideal outcome for a rescue operation.
The MEV Arms Race
For a while, the relationship between bots and the users/applications they exploited became a game of cat-and-mouse. Users worried about getting frontrun could attempt evasive behaviors, like leveraging proxy contracts or splitting transactions across multiple blocks. Large trades could be divided into smaller transactions, each of which was less likely to get sandwiched. And users could try to submit transactions to private mempools whose contents miners promised to conceal from bots.
Even bots themselves have learned to be wary of other bots. Besides competing in gas fee bidding wars, searchers have actively sabotaged one another, finding weaknesses in each other’s strategies and swindling less sophisticated bots for a profit. The (in)famous Salmonella strategy involved a “honeypot” smart contract that baited a sandwich bot into sending Eth to a malicious token contract. Clever tactics like this have earned traders hundreds of Eth in a single night.
Flashbots
Crypto early adopters tend to be fairly tolerant of terrible UX, but it’s tough to not get fed up with MEV. And it certainly doesn’t help the ecosystem’s reputation for being a scam-filled Wild West where only the paranoid survive. Thankfully, there’s a company working to solve this problem on Ethereum — in the most counterintuitive way possible.
Flashbots is “a research and development organization working to mitigate the negative externalities of MEV and to avoid the existential risks MEV could cause to state-rich blockchains like Ethereum.”
Their take is basically: if we can’t prevent MEV, we should at least do everything we can to make it more fair, transparent, and permissionless so that it doesn’t undermine blockchain’s core values. The two main ways they’re addressing MEV are Flashbots Auction and Flashbots Data.
Flashbots Auction lets anyone — including searcher bots — bypass the public mempool and instead submit bundles of ordered transactions directly to miners. A bundle can include transactions from any account, not just the one submitting the bundle — for example, a sandwich attack bundle could include 3 transactions: the searcher’s frontrun ➡️ the victim’s trade ➡️ the searcher’s backrun.
When a user submits a bundle, they include a bid indicating how much they’re willing to pay to have their preferred transactions included at the top of the next block. Miners can accept the bundle(s) with the highest bids and discard the rest — a much more efficient process than the status quo, where bots spam them with transactions that could end up failing/reverting, or could be included in an undesired order.
Around 90% of Ethereum miners have adopted Flashbots. The company’s core software (mev-geth and mev-relay), along with its open-source guides for helping people become searchers, has helped democratize MEV by lowering the barriers to entry. The combination of a private transaction pool and an auction mechanism has had a dramatic impact on how MEV works in practice:
As a result of Flashbots’ efforts, and a general increase in public awareness of MEV, profits for simple trading strategies like arbitrage and liquidations have been largely competed away. Most of the value ends up as fees paid to miners unless a searcher has identified an exotic MEV trade that’s unlikely to face competing bids.
Flashbots Data is the second weapon in the company’s arsenal. An assortment of APIs, libraries, and dashboards helps shine a light on the historically opaque MEV underworld. By open sourcing data points such as total cumulative extracted MEV, Flashbots transactions included in each block, total miner profit, and largest individual MEV transactions, this suite of tools backs up Flashbots’ commitment to transparency.
Degen Additional Resources:
Level 3: Gigabrain
MEV sucks for the average user, but could it be more serious than an annoying tax on trades? Might it even be an existential risk for smart contract blockchains? That’s what some people have argued.
Risk #1: Centralization
In a world where MEV can only be captured by advanced searchers or highly connected miners with lots of resources, economic pressure will push blockchains towards centralization. While “economies of scale” is typically a positive term in the off-chain world, it’s something to be avoided in crypto. Decentralization relies upon a (roughly) linear relationship between a miner/validator’s resources and their earnings so that smaller network participants are not significantly disadvantaged. Fortunately, tools like Flashbots have largely mitigated this risk.
Risk #2: Block Re-orgs and Time-Bandit Attacks
Blockchains rely on miners behaving as rational economic agents, and network protocols are carefully structured so that each miner’s profit-maximizing strategy is to obey certain rules that help secure the entire network. “Time-Bandit Attacks” can occur when MEV rewards break this assumption.
In certain situations, it can be more lucrative for miners to act against the best interest of the network by attempting to overwrite existing blocks instead of following the socially optimal strategy of mining on the longest chain. For example, a powerful miner might notice a large MEV opportunity that some lucky searcher snatched a couple of blocks back. Rather than mining on the newest block, which could only offer meager block rewards, the miner could choose to re-mine the older block, claim the MEV profit, and hope that their fork of the chain eventually overtakes the original chain. Doing so might have a positive EV for the miner, but frequent re-orgs of this type would cause chaos for the blockchain itself by disrupting finality and security.
“Deviant mining strategies” of this kind could even pose a threat to Bitcoin — a blockchain not typically associated with MEV — once the network stops issuing new coins as block rewards. This well-known paper covers the game-theoretical mechanics of how such a strategy could evolve under a transaction fee regime, undermining Bitcoin’s security if additional measures aren’t taken.
While these risks are serious, the notion that MEV poses an existential threat to Ethereum is likely overblown. It’s true that opportunities for MEV will only increase as blockchain applications grow in complexity, and that even more advanced MEV strategies such as DEX/CEX arbitrage and cross-chain MEV pose new challenges. But there are plenty of teams working on solving — or at least mitigating — the worst effects of MEV at the application level and even the protocol level.
That’s not to say, though, that we shouldn’t ignore the many flaws with the current state of MEV and the solutions that exist to date.
Flashbots Criticism
Although Flashbots’ systems — sometimes called “Front-running as a Service” (FaaS) or “MEV Auctions” (MEVA) — have helped lower gas fees and democratize access to MEV, not everyone is a fan. Many argue that resources would be better spent trying to prevent MEV rather than accepting it as inevitable. Some even go so far as to say MEV is theft and MEVA, therefore, is akin to “auction[ing] off the right to mug people and burglarize homes.”
The cofounders of Flashbots give a pretty good rebuttal to these critiques here. The (paraphrased) tl:dr is:
We don’t use force, we publish code. If by writing 100 lines of pretty obvious code and releasing it as mev-geth we’ve enabled widespread theft, then this whole experiment with smart contract blockchains has failed because the system should be able to handle such a weak “attack.”
In any case, generalized frontrunners present some tricky ethical questions. Right up there with philosophical debates around the Trolley Problem and “should you steal bread to save your starving family” is a new dilemma: who’s responsible when a bot accidentally frontruns a hack?
And besides these ethical arguments, there are concerns about the Flashbots’ actual implementation — specifically, the fact that it’s a centralized application whose usage requires certain trust assumptions. The company acknowledges that, as of Flashbots version 0.4, it’s yet to meet a few goals on its roadmap including:
The (Bright?) Future of MEV
As Ethereum transitions to proof of stake and other PoS chains develop more robust MEV infrastructure, the flow of MEV profits could change dramatically. Consider two of the major factors that distinguish MEV on PoS chains compared to PoW:
Searchers know in advance which validators are scheduled to produce future blocks within a given epoch, so it’s no longer necessary to broadcast transactions to all miners.
Users looking to stake their assets can choose which validator(s) to stake with, and this decision impacts the odds of validators being chosen as block proposers.
This second point creates a game-theoretical situation in which validators are pushed towards sharing MEV profits with stakers. A flywheel effect will reward MEV Profit Sharing Validators (MPSVs) while driving out validators who refuse to kickback MEV profits to stakers (more info here):
Putting together all the ideas we’ve covered so far, it’s not unreasonable to view MEV as an evolving market that first favored searchers, has shifted to more strongly favor miners, and will eventually start to favor users as a result of competitive forces.
We might even see a world in which wallets and other applications actually pay users using MEV fees, much like credit cards’ cashback programs.
Flashbots (and other similar tools) ➡️
Lower barriers to entry for becoming a searcher ➡️
Searcher MEV profits competed away ➡️
Value accrues to miners/validators as fees ➡️
PoS systems reward validators that share profits with stakers ➡️
Users/stakers receive MEV profits as incentives to favor certain apps/validators
Still, the future of MEV is complicated and uncertain. New infrastructure will need to be built for Ethereum 2.0, including Flashbots’ post-merge software called mev-boost which will enable proposer-builder separation (PBS) on the post-merge chain. There is even talk of integrating Flashbots into the core Ethereum protocol itself.
Meanwhile, MEV on Solana could be impacted by the chain’s new fee mechanism — and by efforts from Jito Labs, who are building a Flashbots-like system. Marlin is handling MEV tools on Polygon, while Nethermind launched an MEV plugin for xDai.
In other words, it’s an exciting time to be in the world of MEV.
MEV Minimization
Finally, it’s worth mentioning some of the projects and tools out there that are stubbornly fighting the good fight against MEV instead of acquiescing to it. These include:
Strings together transactions in a FIFO order to produce an output that block producers can’t modify with deletions/insertions.
Encrypts pending transactions while they’re in the mempool.
Chainlink's Fair Sequencing Service (FSS)
Uses a network of oracles to order transactions instead of giving that power to a single miner or validator.
Uses a STARK-based verifiable delay function (VDF) to obscure transaction details for a predetermined amount of time (as they’re being ordered), and then makes them public after sequencing is complete.