MEV (Maximal Extractable Value) is extracting value from a blockchain network by adding, removing, or reordering transactions included in a block. This concept originated in the Ethereum community quite a long time ago (of course, if we count in crypto years). Still, MEV started to reach a new level of volumes with the growth of DeFi infrastructure, which opened more opportunities for servers.
In simple words, MEV's working principle is: "Hey, miner, put my transaction next to that one so I earn 1 ETH, and I'll give you half”.
Obviously, this is a win-win situation, both for the person who found the transaction (the servers) and for those who can change the order of the transaction when creating the block.
An important term when working with MEVs is mempool. In blockchain terminology, a mempool is a waiting pool for transactions that have not yet been added to the block and are still pending. Of course, anyone can see all the transactions that are in this pending state and understand how they can affect certain contract states.
At the time of writing, the most popular uses of MEV mechanics right now are.
Mempool provides a unique opportunity for traders to anticipate prices on exchanges. Most decentralized exchanges work with market-making algorithms, which allow knowing the current state of pools (exchange contracts) and incoming transactions from the mempool to know the price state after each upcoming transaction in the block. This opens up the possibility of both normal arbitrage between different exchanges within one block and sandwich attacks— buying and selling around one transaction or vice versa. For example, a trader sees a big transaction in the mempool to buy a SAND token. Then he sends his 2 transactions to the miner: his purchase of SAND token right before the big transaction and instant sale after this transaction.
Lending protocols such as Maker, Compound, and Aave require users to deposit collateral (e.g., ETH). This deposited collateral is then used to extend credit to other users. Once this collateral has the potential risk of not securing the loan (the risk parameters for this are determined by the DAO community in advance), any network user can liquidate the debt by taking the collateral for themselves. In this case, for example, the debt could be $80k and its collateral $100k, thus the liquidator gets an instant profit.
Having access to the general information of incoming transactions makes it possible to detect the completion of NFT auctions or their drops, which opens up opportunities to profit from them. For example, if there is a popular NFT drop and a trader wants a particular NFT or set of NFTs, he can set his transaction so that he is first in line to buy the NFT, or he can buy the entire set of NFTs at once.
The Flashbots community played a big role in the development of MEV infrastructure. They proposed the mev-boost infrastructure, which is essentially an improved geth client (i.e., the Ethereum node client). In this article, I will consider this infrastructure, as currently, most builders in the Ethereum network use it. However, the prevalence of Flashbots Builder has fallen dramatically in block production, although at its peak, it collected almost 80% of all Ethereum blocks.
Let's briefly walk through the "mining" process in Ethereum 2.0 after the merge. There are now 3 agents responsible for creating blocks:
Thus, network users can directly influence the collection of blocks through the mev-boost infrastructure. Bundles are used to organize transactions, which are an ordered set of transactions that the server sends to the builder via API.
Imagine Alice wants to swap a large amount of cryptocurrency on a decentralized exchange (DEX). She submits her transaction to the network, but before it gets included in a block, a malicious actor notices the pending transaction. The actor then submits a series of transactions to manipulate the price of the cryptocurrency, executing a front-running or sandwich attack.
Here’s a step-by-step breakdown of what happens:
Without MEV protection, these types of manipulations are more likely to occur, leading to a loss of trust in the blockchain ecosystem and financial harm to users.
Several providers offer RPC nodes with built-in MEV protection, ensuring a safer and fairer blockchain experience. Here are a couple of notable ones.
dRPC provides RPC endpoints with robust MEV protection, prioritizing the fair ordering of transactions and reducing the risk of manipulation. Their services include:
dRPC is a leading provider of decentralized blockchain APIs and RPC Nodes, serving clients like Instadapp, SushiSwap, Lido, Curve, and 500+ other web3 organizations.
Flashbots is a research and development organization focused on mitigating the negative externalities of MEV. Flashbots Protect offers RPC endpoints that help prevent front-running and other MEV-related attacks, promoting a healthier blockchain environment. Their features include:
Flashbots primary focus is to enable a permissionless, transparent, and sustainable ecosystem for MEV.
It is important to choose RPC providers that offer MEV protection. With dRPC and Flashbots Protect, users and developers can significantly reduce the risks associated with MEV and contribute to a more stable and trustworthy decentralized landscape.