A Walk Through the Dark Forest

By Katsuragi

There’s been much ado about MEV lately. Why is it so hot right now? No telling, really. MEV has been widely present (and captured) on Ethereum for many months now. Proper understanding eludes the masses due to its complex technical nature, so we set out to share our thoughts on it and why it is important. The existence of MEV on state-rich blockchains like Ethereum creates powerful incentive structure that can pervert the decentralized nature of the EVM itself, as we will explore.

Let’s start at the beginning: what is MEV? MEV, or Maximal/Miner Extractable Value, can be defined as a measure of the profit a miner can make through their ability to arbitrarily re-order transactions within the blocks they produce. Since Miners can re-order transactions based on what is most profitable for them, therein lies an opportunity for users to take advantage of. Below is a chart on the gross profit of cumulatively extracted MEV, which reached almost $600 million in just a few months:

source: Flashbots
source: Flashbots

The concept of MEV is better understood in the context of high-frequency trading on Wall Street. Michael Lewis’ seminal book Flash Boys tells the story of the traditional finance world’s battle over best execution in markets. By setting up trading operations strategically located near purpose-built fiber optic cables, traders could cut time to execution by a few milliseconds. In the arena of high-frequency trading, this enables a disproportionate advantage over competitors, due to the ability to capture better prices based on those mere milliseconds.

MEV on EVM-based blockchains is mechanically very different, but can be qualified similarly in the arena of DeFi. Since miners are able to include, exclude, or re-order transactions based on who is willing to pay the most in gas, algorithms employed by “searchers” (individuals attempting to exploit MEV opportunities) are able to capture value for themselves from various types of transaction activity within the blocks that miners are confirming.

Enter the Dark Forest: the Mempool

The mempool is often referred to as a Dark Forest. A frightening and lonely place, filled with predators laying in wait to strike and frontrun your transactions. To the uninitiated, a venture into this realm quickly becomes a cautionary tale. To the predator, it’s a battleground more akin to the Roman Colosseum than an enchanted mystical place.

The mempool is the blockchain’s waiting room that all transactions must pass through before they are ordered neatly to be submitted into sequential blocks. It is both a gateway and a warzone. Recall that transactions can be ordered on priority via the amount of gas submitted. As transactions vie with each other to be selected into the next block, myriad opportunities open up to be exploited by an experienced searcher.

Consider attempting to mint an NFT for a popular project. There are hundreds of thousands of individuals in the Discord, and the moment minting on the contract opens, the Ethereum Virtual Machine is slammed with transaction attempts by whales, shrimps, and bots alike in a mad dash to acquire the NFTs before they sell out. If its your first time participating in such an event, you’re likely to end up disappointed; you waited 10 minutes for your transaction to confirm before you finally submitted a cancellation request, resulting in the loss of gas and no NFT yet. So you try again; Ope! look at that, you waited too long. Now the NFT is sold out and you must pay double to acquire it on the secondary market.

This type of scenario presents ripe opportunities for value extraction. Aside from larger-order bidders cutting to the front of the line by setting gas considerably higher than a normal participant would, searchers can front-run the mint transactions sent to the mempool up and down the board. But what do these opportunities look like?

MEV Strategies

MEV extraction by searchers exist in a variety of forms, but we’ll stick to the most common strategies as they make up a majority of MEV extracted (for this reason, they are also likely to be the least profitable for new searchers):

Generalized frontrunning is perhaps the most obvious use case to anyone familiar with normal marketplace mechanics. This strategy’s simplest form can be boiled down to the process of reviewing all publicly available transactions in the mempool, and simulating whether frontrunning any of them would result in a profit. If person A attempts to send a transaction to a liquidity pool, and person B (i.e., the frontrunner) can identify a profitable arbitrage by beating the order to confirmation, person B will execute the frontrunning transaction and subsequently sell person A their desired asset, albeit at a slightly higher price. Various strategies in this category can quickly become infinitely more complex, but for the purposes of this article we want to keep it very basic, and thus will loosely define this strategy as the ability to capture arbitrage opportunities solely by mimicking a given sender’s behavior and beating them to execution.

The sandwich attack is a form of frontrunning based on exploiting the existence of pending transactions waiting to be confirmed in the mempool. The sandwich attack is the closest parallel to the strategies employed by high-frequency traders on Wall Street. If you can observe an individual sending an order in the mempool to Uniswap and recognize that this order will cause a price impact, you can frontrun said transaction, and then quickly turn around and sell the asset back to the individual sending the original transaction at a higher price, keeping the difference for yourself. The key difference between this and other generalized frontrunning strategies is a function of price impact when transacting on various AMMs. Since Uniswap uses a constant product market maker function, you can factor these formulas into a MEV bot algorithm to determine a transactions price impact, and thus the potential profitability.

The atomic arbitrage is another strategy. Definitionally, basic arbitrage is the practice of buying an asset at a discount on one exchange and simultaneously selling it on another exchange at fair value. This might sound nefarious, however it is a strategy executed across all markets by many participants, and it serves the purpose of enabling better price discovery for an asset. A core tenant of financial arbitrage is that is essentially riskless - i.e., in the attempt to discover a discrepancy in price among bids and asks, one can assess the profitability prior to execution. Any time an asset is arbitraged, the price of the asset on one exchange gets closer to the price on another exchange. Atomic arbitrage, however, includes a twist on this. Since blocks on Ethereum are ordered sequentially, searchers are able to attempt to arbitrage a transaction in a single block re-ordering, but if the attempt contains a check on whether or not the transaction will return a profit for the searcher, the transaction can fail and revert back to the original state if, indeed, the results determine it will not be a profitable transaction.

MEV can be extracted via numerous other strategies not listed here, but we’d be sharing too much alpha by identifying all of them. After all, MEV searching is a dog eat dog world.

The Good and the Bad on MEV

At its core, the opportunities that MEV enable typically translate into higher prices that consumers must endure as a byproduct of the technical framework that enables the Ethereum Virtual Machine to operate at scale. Since MEV is present, it will be captured; Miners are incentivized to rearrange the order of transactions submitted to a block based on whatever is most profitable for them. Furthermore, miners could be incentivized to act collectively in a manner that perverts the decentralized nature Ethereum attempts to secure. This is something that Ethereum researchers, Vitalik included, are deeply concerned over, since the incentive structure creates some negative results:

  1. active re-organization of transactions requires better, more expensive hardware, thus making block validation less decentralized
  2. longer wait times for transaction confirmation
  3. attacks on the network become easier to execute.

These are all major risks that, over time, can slowly distort many of the most valuable features of the Ethereum virtual machine, particularly in regards to decentralization. However, at the moment, there isn’t a quick fix - recall that the existence of MEV is a byproduct of how Ethereum works today. Eliminating MEV would mean a structural overhaul of the Ethereum virtual machine itself.

In addition to the existential risks MEV presents Ethereum, many searchers looking to capitalize on opportunities engage in particularly nefarious forms of value extraction, as mentioned previously. These value extractions come at a cost to the unknowing Ethereum user, who selects “Confirm” on Metamask and is given an estimation of the gas cost he or she will incur. With an arbitrage or sandwich opportunity present, the unknowing user will likely execute at price point for the asset above the price they were quoted when they selected “Confirm”. Most Ethereum retailers probably have no understanding of what is going on behind the scenes; perhaps ignorance is bliss in this regard. They’ll say, ah, the network must be congested, and chalk it up to unknown variables.

However, on the other hand, MEV does serve some interesting market functions for improved efficiency. In the words of 0xMebius (who posted one of the more comprehensive introductory deep dives into MEV on the internet today), MEV as an engine of economic efficiency is described as follows:

When a user submits a swap, they effectively declare their maximum willingness to pay through the parameter minOutput/maxInput. If their order fills at a more favorable price than the declared WTP, it implies the existence of a consumer surplus and consequently the absence of a Nash Equilibrium. A third party, the sandwich bot operator, moves the economic system towards the Nash Equilibrium such that the market meets the consumer’s maximum WTP while also extracting value for the operator. In doing so, the sandwich bot has generated more global utility and reached the Nash Equilibrium where no other action would produce additional utility given the current state of the system and the declared economic preferences of all agents involved.

The thing about MEV is, well… it exists. As such, bots searching for opportunities will exist. It is a negative externality borne from the current state of Ethereum architecture; an unfortunate consequence that harms naive market participants, but also a feature in that it serves to the larger goal of market-making efficiency. It’s also deeply technical in nature, requiring a comprehensive understanding of the Ethereum state machine, DeFi marketplace opportunities, and some math.

This means the barrier to entry is high for new searcher entrants looking to capture MEV. Anyone looking to take advantage of this system must not only hurdle the technical obstacles required to operate a profitable MEV bot, but also compete against the many MEV participants that have been engaging in this realm for months. All of them have a massive head start over you, as they’ve fine-tuned their algorithms over time to capture the most profitable opportunities.

The Democratization of MEV Capture: Flashbots

As soon as MEV opportunities began to get captured on greater scales, many blockchain researchers recognized the threat it inherently poses to Ethereum and its users. Remember the game theory here, we really want to hammer this home: MEV is present, and therefore it will be extracted. You can’t prevent the existence of MEV without overhauling the structure of the mempool itself. So what is the answer?

Robert Miller quickly realized this, and formed a team toward the goal of democratizing MEV capture. The result was Flashbots, a research and development organization that provides a suite of tools to eliminate many of the technical hurdles and enable greater access to capturing MEV. The value proposition sounds like an oxymoron: in order to combat the problem that MEV poses, the solution might be to create... more tools to capture it.

But in reality, the objective is to enable a significantly larger pool of individuals capturing MEV, arming searchers with tools to battle each other in the mempool. Given the rapid increase in searchers leveraging Flashbots relay channels, and incentives to provide Miners access to such relay channels, the introduction of this suite of tooling has likely had a positive impact on the state of MEV’s existence by enabling greater accessibility. Eliminating many of the technical hurdles means more participants joining in the fray, which works to decentralize the extraction of value. More market participants means more competition, and thus extraction opportunities begin to get competed away (market efficiency!). This could work to mitigate many of the biggest issues that MEV presents, but the jury is still out on this and this story continues to unfold, especially as Ethereum transitions to proof-of-stake and the incentives for searchers and miners begin to shift.

Looking Forward

Where is this all headed? More and more searchers are entering the arena attempting to capitalize on these opportunities, and so the space has become extremely crowded. Many searchers spend months optimizing algorithms and studying arbitrage opportunities before finally realizing a profit. Alpha is extremely difficult to find, and successful searchers are not incentivized to share their strategies. Thus, if you’re a new entrant looking to capture MEV, you’ll find its a lonely journey. You’ll need to do the work yourself, nobody is going to hand it to you.

How will MEV impact the longer-term realization of Etheruem’s value proposition? That remains to be seen, although some of crypto’s biggest gigabrains are working hard to solve this problem. Folks far smarter than us. And we are optimistic that the problems MEV creates can be greatly mitigated before actually impacting the network enough for a much larger share of market participants to notice. Time will tell, and in the meantime, we’ll keep searching...

Subscribe to Unit Zero
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.