What Is Miner-Extractable Value (MEV)?

The blockchain economy is now at over $1T in total value and growing at an exponential pace, with the DeFi ecosystem alone already doubling in value locked since the start of the year. However, alongside the growing adoption of smart contracts are new loopholes where value can be siphoned away from unwitting users. One such example is Miner-Extractable Value (MEV)—a dynamic where blockchain miners are able to extract profits at the expense of users by arbitrarily reordering, including, or excluding transactions within a block. Simply put, miners can determine the order of when transactions are processed on the blockchain and exploit that power to their advantage.

MEV is also increasingly referred to as Maximal Extractable Value, due to MEV not being limited to just miners in Proof-of-Work (PoW) based blockchains, but also applying to validators in Proof-of-Stake (PoS) networks as well. To encompass the full scope of MEV across the multi-chain ecosytem, we’ll refer to the latter terminology within this blog post.

In the research paper “Flash Boys 2.0,” whose authors include Chainlink Labs researchers Ari Juels and Lorenz Breidenbach, MEV and transaction reordering are not just explained as a theoretical concept, but as a dynamic that is already occurring at scale in the form of transaction frontrunning on decentralized exchanges and which can have a significant impact on the user experience. In this article, we’ll explore why MEV exists, examples of MEV today, and how Chainlink Fair Sequencing Services provides a novel solution to this emerging risk in blockchain economies.

Why Maximal-Extractable Value Occurs

Blockchain networks such as Bitcoin and Ethereum are immutable ledgers secured by a decentralized network of computers, known as “block producers,” including miners in PoW blockchains and validators in PoS networks. These block producers are responsible for regularly aggregating pending transactions into blocks, which are then validated by the entire network and appended to the global ledger. While blockchain networks ensure all transactions are valid (e.g. no double-spends) and new blocks of transactions are continually produced (preventing downtime), there isn’t actually a guarantee that transactions will be ordered in the exact manner they were submitted to the blockchain.

Since each block can only contain a limited number of transactions, block producers have full autonomy in selecting which pending transactions in the mempool—the location block producers store unconfirmed transactions off-chain—they will include in their block. While block producers usually order transactions by the highest gas price (transaction fee) in order to maximize their profits, this is not a requirement by the network. As a result, block producers can extract additional profits from users by taking advantage of their ability to arbitrarily reorder transactions, creating what is known as maximal-extractable value (MEV).

Miners ordering transactions by highest gas price to maximize profits
By default, block producers such as miners do not order transactions by time of submission, but the amount of fees paid

While MEV is the most common terminology for this concept, most forms of MEV seen today are taken not from block producers themselves, but from third-party bots. These bots manipulate the ordering of their transaction within a block by changing the transaction fee they pay to block producers. This means MEV can be extracted even when block producers order transactions according to the highest gas prices. However, MEV can be seen as the upper bound of how much value can be extracted by block producers, since they ultimately have control of the final transaction ordering within a block.

MEV comes at the expense of regular users, often in ways that may not be immediately apparent to all users until after their transaction is processed. This can include the increase of the network’s transaction fees and additional slippage on trades, both of which extract value directly from users.

Exchange Arbitrage and Gas Price Bidding Wars

The most common form of MEV seen today is third-party bots performing arbitrage between two or more decentralized exchanges (DEXs). An arbitrage opportunity is created when the price of a crypto asset on one exchange deviates from another, typically caused by a large trade on one of the exchanges. Arbitrage bots profit from this opportunity by purchasing an asset on the exchange offering a lower price and selling it on the exchange offering a higher price, bringing both exchange prices back to equilibrium while earning a profit. Additionally, arbitrage can also be performed between on-chain DEXs and off-chain centralized exchanges.

With the increased adoption of DeFi and growing liquidity within DEXs, the occurrence and profitability of these arbitrage opportunities have increased, leading to a growing competition between arbitrage bots. These bots compete by engaging in a bidding war, which leads to them continually raising the transaction fee they are willing to pay block producers in an attempt to get their transaction processed first. They engage in such behavior because they know block producers are incentivized, as rational economic actors, to order transactions according to the highest gas price. While this form of MEV ensures market prices are aligned across exchanges, it has a detrimental side effect.

The result is that the blockchain network’s bandwidth becomes consumed by increasingly competitive arbitrage transactions, raising the transaction fees for everyone else on the network. The transaction fees paid by the arbitrage bots, which is often a large percentage of the final profits generated from the arbitrage, go directly to the block producers. This means that block producers still benefit from this form of MEV even without taking the arbitrage opportunity for themselves, as they earn increasingly more transaction fee revenue.

Exchange Frontrunning and “Invisible Fees”

Another form of MEV that can be considered more directly detrimental to the user experience is bots who frontrun trades made by users on decentralized exchanges. Because all transactions from users must go through the mempool, these front-running bots can monitor for large trades entering the mempool and use this advanced knowledge to their benefit.

For example, if a large trade is spotted, a front-running bot can copy the user’s trade and pay a higher transaction fee to get their transaction processed first. This moves the market price of the asset being traded, causing the user’s trade to incur a larger amount of slippage—the difference between the expected price of a trade and the actual price. After the user’s trade is processed, the market price of the asset being traded further shifts in the frontrunner’s favor, which allows them to take profits by selling their assets via a backrun trade, resulting in what is commonly known as a “sandwich attack.”

As a result, the user’s trade is executed at a suboptimal exchange rate, increasing the costs of using decentralized exchanges in the form of an “invisible fee” where fewer tokens than initially expected are received. Similar to exchange arbitrage, frontrunning bots compete for these opportunities by engaging in a transaction fee bidding war to get their transaction processed first, thereby inflating the cost of creating any transaction on the blockchain network.

Exchange arbitrage and frontrunning represent just two examples of how MEV is generated and can adversely affect users. However, they are not the only situations in which MEV is possible. If and when block producers begin to capture more MEV opportunities for themselves, it is possible that more advanced reordering strategies are used to further extract value from users. While arbitrage bots and frontrunning bots can only reorder their transactions by paying a higher transaction fee, block producers can reorder and insert their own transactions into a block for free. This opens up even more opportunities for MEV, which in the worst cases can lead to block reorganizations and consensus instability.

Mitigating MEV: Chainlink Fair Sequencing Services

In order to mitigate the detrimental effects of maximal-extractable value, Chainlink is developing Fair Sequencing Services (FSS)—a transaction ordering solution using decentralized oracle networks. Chainlink FSS works by collecting user transactions off-chain, generating decentralized consensus for transaction ordering, and submitting the ordered transactions on-chain, in a decentralized way.

As explored by Chainlink Labs’ Chief Scientist Ari Juels in a recent presentation at SmartCon 2021, FSS is planned for deployment in two phases. The first phase involves secure causal ordering (atomic broadcast), where user transactions are first encrypted by users to hide transaction details, ordered by a decentralized oracle network, and then decrypted for execution on a blockchain network. As a result, the transaction payload will not be visible to nodes before the ordering process begins, removing the ability to front-run transactions based on early visibility.

In phase two, Aequitas ordering (consensus) protocols are planned to be implemented into FSS for transaction ordering based on supermajority receive time. This helps enforce a first-in, first-out (FIFO) ordering policy. When combined with transaction encryption from phase one, a defense-in-depth solution is enabled for the fair ordering of user transactions. The technology making FSS possible is further explored in-depth within section 5 of the Chainlink 2.0 whitepaper.

Chainlink FSS preventing MEV
An example of Chainlink FSS ordering transaction by the time of arrival in the mempool

Fundamentally, Chainlink FSS aims to decentralize the process of transaction ordering, helping ensure that smart contracts process transactions in a provably fair manner devoid of any preferential ordering. FSS not only helps prevent unfair transaction ordering but also has the potential to lower network gas prices (transaction fees) by reducing the occurrence of gas price bidding wars, as the amount of fees a user pays doesn’t affect the final ordering of their transaction relative to other transactions. Chainlink FSS can be used in various ways, including serving as a pre-processing stage for smart contracts on a layer-1 blockchain as well as ordering transactions for layer-2 networks and decentralizing rollup sequencers.

By helping ensure transactions are ordered fairly and lowering network transaction fees, FSS drastically improves the user experience of interacting with smart contract applications. The end result is a DeFi ecosystem that is able to achieve its highest potential of providing a more economically fair world, backed by mathematics and cryptographically enforced guarantees.

If you’re a developer and want to connect your smart contract to existing data and infrastructure outside the underlying blockchain, visit the Chainlink developer documentation or reach out here.

More on This Topic