In a previous article, we mentioned MEV (Maximal Extractable Value) in the context of MEV-boost software from Flashbots, which allows for increasing the rewards from staking. We also described a series of events that could eventually lead to the division of the Ethereum network into censored and uncensored by OFAC. In this text, we will analyze the operation of the Maximal Extractable Value itself, how to obtain it, and what consequences it may have for you as a user and the blockchain network itself.
What is MEV?
MEV is an abbreviation of "Maximal Extractable Value." It refers to both - Proof of Work miners and Proof of Stake validators who attach further blocks to a chain. For the former, MEV is also referred to as "Miner Extractable Value." It is the profit the aforementioned participants in consensus algorithms can make by unilaterally reordering transactions and inserting or censoring blocks. They act independently of any supervisor, so they can maintain or order transactions in a way that benefits them. They secure the blockchain by coordinating its operation but, unfortunately, at the same time, provide a space for over-prioritizing transactions with the highest tx fee.
Before we explain the operation of Maximal Extractable Value, we will analyze how exactly performing transactions work in blockchain.
- A user of the blockchain network requests a transaction.
- The transaction is broadcast to P2P computers (nodes), which pass it on until it is widely propagated by passing the information to peer nodes. At this stage, it is in a buffer (waiting room) called a mempool. The purpose of this stage is to check if signatures are correct, outputs do not exceed inputs, and resources have not already been spent.
- Validation - miners (PoW) or validators (PoS) select positively audited transactions from the mempool to insert into their block and receive a tx fee reward.
- The transaction is complete and recorded in the blockchain.
MEV refers to the selection of transactions from the mempool by miners or validators to get additional profit from users. Priority is given to selecting transactions with the highest tx fee to get the highest possible reward per block. That is because the blockchain does not have a top-down set of procedures of how transactions are to be selected, so choosing them from the mempool is entirely up to the block producers.
Key parties and MEV operations in detail
The MEV process involves parties such as block producers, searchers, protocol developers, and decentralized applications (Dapps). Block producers can monetize MEV by selling block space to non-miner MEV extractors through PGA - Priority Gas Auctions, where bots bid on gas (transaction fees) with each other, resulting in a price increase for other users. The second option is resequencing, which is the inclusion or removal of transactions to favor oneself. The Dapps mentioned above and protocol developers play a supporting role in this process. Decentralized applications create MEV opportunities by offering incentives in the form of arbitrage.
On the other hand, protocol developers create rules for block producers to mandate trades, enabling MEV. Searchers or DeFi traders, and bots look for MEV opportunities and store them in various ways. They bid high gas prices in the PGA to mandate transactions in specific ways to producers. They also provide sequences of off-chain deal choices through MEV mining tools such as Flashbots. Searchers order bots to instantly send profitable deals to the network by running pre-complex algorithms to discover them. They are willing to pay block producers as much as 99% of the total MEV revenue because there are so many takers for the same deal.
Searchers keep monitoring the blockchain with bots built with algorithms and automation tools. When an opportunity is spotted, they determine the logic and create a bundle - multiple transactions put together and executed in the right order. The process leads to an MEV target guarantee when the bundle is produced. Searcher sends bundles off-chain to mine using MEV-Geth from Flashbots, which allows skipping the public mempool by communicating sequencing preferences to block producers.
When a block producer includes a searcher's bundle in its block, the MEV extraction process is complete. When the number of bundles submitted by searchers is large, and block space is limited, block producers put them up through Flashbots Auction - where searchers bid on the order of the transaction. The process is done blindly - no party knows the amount proposed by other parties. The winner gets the preferred order of transactions in the block produced.
Several types of activities can be listed to obtain Maximal Extractable Value, for example:
Arbitrage of asset exchanges on DEX is the simplest and most popular option to get MEV. If two exchanges offer a token at different prices, then it is bought on the first DEX at a lower price and sold at a profit on the second one in an atomic transaction.
It relies on the transaction being first in the execution queue before a known transaction in the mempool. Front-running bots monitor large transactions and use their advanced knowledge to take advantage of this opportunity. If a front-running bot notices a large trade, it may copy a user's trade and pay a higher transaction fee so that its trade receives the highest priority in the order of trades in the block.
It involves ordering a transaction as the second in line. It is watching the mempool for listings of new tokens or liquidity pools on DEX. When the bot finds a pool of tokens, it immediately places an order for a large number of them, leaving a small amount for other traders. When the price rises, then the bot sells it at a higher price for a profit.
It involves watching the mempool for large DEX transactions that can affect the value of the asset price. Then, before buying, one buys the asset cheaply and sells it as soon as the price rises. However, this is risky because sandwiching is not atomic and is vulnerable to salmonella attack (the contract modifies the standard transfer function to send only a fraction of the requested amount to non-owners of the contract).
Liquidations of loan protocols, for example, Maker and Aave, involve capturing the moment when the value of a borrower's collateral assets falls below the required value of the collateral. At that point, the protocol allows the collateral to be liquidated by paying off the lenders. A liquidation fee is collected, part of which goes to the liquidator. Searchers analyze blockchain data to determine who has been liquidated and be the first to submit a liquidation transaction to take the fee for themselves.
If a prospector wants a certain NFT, it can program the transactions to be the first in line to buy the NFT or the entire set, which is mistakenly listed at a discounted price. For now, this is an unpopular MEV method and not always profitable.
They rely on rewriting blockchain history to steal funds allocated by smart contracts in the past, thereby destabilizing the consensus. These can occur especially when block rewards are small, in which case the incentive to destabilize the consensus through MEV can increase.
Consequences of MEV
Widespread use of MEVs leads to the following negative consequences:
- Overloading the network and increasing gas prices. Bots engaging in bidding wars make ordinary users have to pay more.
- Since August 2022, more than $673 million has been extracted from victims of the Ethereum network.
- Blockchain disruption at the protocol level - destabilization of the consensus deregulates the network's operation and negatively affects honest blockchain producers' motivation.
- Conducted off-chain transactions with validators to ensure the privacy of transactions, which can be developed into so-called "dark pools" open only to users willing to pay certain fees, which will negatively translate into permissionlessness and trustlessness of the Ethereum network.
Possible advantages of MEV include the following:
- DEX arbitrage allows users to receive the correct prices for their tokens.
- Lending protocols through the actions of "good" prospectors ensure capital repayment to lenders.
Summarizing - why should you be aware of how MEV works?
A block producer, by human nature, will always be driven by the desire to get the most money. MEV occurs not only on the Ethereum network (where it appears most often) but also, e.g., on Bitcoin or Solana. The problem will grow as the popularity of DeFi grows, so you can either try to fight MEV or attempt to democratize it with the regulation of an "invisible tax" imposed on network users by miners and validators.
The most important thing is that you should be aware that MEV exists and takes place when you want to perform a transaction. You must recognize this problem, as it will only grow over time, making more and more tx fee money disappear from your wallet.
We power your Web3 future
We are a team of experienced blockchain enthusiasts who are more than willing to help you on your way to Web3. We provide end-to-end blockchain solutions for enterprises and ambitious startups. Let's create your future Web3 success together.