Exploring the World of MEV: What It is and How It Works

MEV, short for Maximal Extractable Value (previously Miner Extractable Value), it refers to the value that a miner or validator is able to obtain from reordering transactions within the blocks they produce, on top of the block reward and transaction fees they normally benefit from. Transactions leading to MEV include arbitrage and liquidations.

An illustration on how validators utilize MEV

MEV is a design by-product from block building since the current blockchain does not have rules on content ordering in the block. By design, validators can arrange the ordering of the transactions before submitting them to the block. The order is usually arranged from the highest to lowest gas fee to maximize profit. Theoretically, MEV may seem to only benefit validators. In practice, the benefit have been largely extracted by another independent party called “searchers”.

Searchers in the context of MEV are individuals or entities that use search engines or other tools to find opportunities to extract value through block production in a blockchain. Searchers can be regular individuals; however, at the current state, they largely consist of MEV bots.

MEV bots are automated software programs or smart contracts that are designed to identify and exploit opportunities to extract MEV. MEV bots may be used to engage in activities such as arbitrage, front-running trades, or manipulating transaction fees. Some MEV bots are designed to operate continuously, monitoring the blockchain and identifying opportunities to extract value as they arise. Others may be designed to perform specific tasks, such as analyzing transaction data or monitoring block propagations.

MEV Examples:

Arbitrage

Making, buy and sell transactions of the same asset at the same time and profiting from a difference in prices. Typically done across different markets, it is also possible to do by manipulating transaction ordering within the same block. MEV searchers may use MEV bots to identify and exploit price discrepancies between different exchanges. For example, if the price of Ethereum is higher on one exchange than on another, an MEV bot may buy Ethereum on the cheaper exchange and sell it on the more expensive exchange, extracting value in the process.

An example of how MEV bot utilizes arbitrage using DYDX, Uniswap and Curve Finance platform on August 2020

Sandwich Attack

To understand sandwich attacks, we must first understand front and back running. Front running is the act of monitoring the transaction pool for a particular type of transaction (such as purchasing an Ethereum domain name), then submitting the same transaction with a higher gas fee to ensure it goes through instead of the targeted transaction. The MEV bots are often used to monitor the Ethereum blockchain for large trades or orders, and then submit their own trades or orders ahead of the large ones, in the hopes of profiting from the price movements that result.

As for back running, instead of submitting the transaction before that particular transaction, the back run transaction is being submitted right after that to take advantage of the previous one immediately afterwards (such as executing a liquidation of an on-chain loan after the oracle price update).

Note: Txn = Transaction

Back to the sandwich attack, it is the act of monitoring the transaction pool for a sufficiently valuable transaction (such as a large trade on a decentralized exchange), then submitting two transactions 'sandwiching' the target transaction. The first one immediately before the target pushes the price in one direction, while the second one immediately after the target does the opposite. Hence, utilizing both front running and back running in one attack. The attacker profits from the arbitrage between their two transactions.

For example, suppose Alice wants to send a large amount of cryptocurrency to Bob. The attacker, who is aware of Alice's transaction, submits their own transaction to buy a small amount of cryptocurrency from Alice at a low price, and then immediately submits a second transaction to sell the same amount of cryptocurrency to Bob at a higher price. By doing this, the attacker is able to extract value from Alice's and Bob's transactions, essentially "sandwiching" their own transactions between the two.

MEV plays a key role in sandwich attacks, as the attacker is able to extract value through the exploitation of inefficiencies or vulnerabilities in the network. Sandwich attacks have the potential to negatively impact the efficiency and security of a blockchain network, and as a result, they are often considered malicious or unethical by members of the blockchain community. Some blockchain networks have implemented measures to mitigate the potential negative effects of sandwich attacks on the network.

Liquidation

In Defi, it refers to the process of selling assets off from an under-collateralized loan. Please refer to this article for more information on liquidation. On how it can be exploited, the MEV bot monitors a platform like Aave for signs of imminent liquidation, such as a trader's position becoming overleveraged (i.e., the value of their collateral falls below a certain threshold).

When the MEV bot detects that a liquidation is imminent, it submits its own trades or orders ahead of the liquidation in order to profit from the price movements that result. The MEV bot may also manipulate transaction fees in order to outbid other transactions and secure a higher position in the order, potentially at the expense of traders who are being liquidated.

The good in MEV

At this point, we may come to the conclusion that MEV is bad for the blockchain ecosystem. But, in reality, it is not all bad. Searchers may use MEV to arbitrage between different exchanges, effectively providing liquidity to the market and reducing price discrepancies. They could also use MEV to identify and exploit inefficiencies or vulnerabilities in the network, leading to improved efficiency. On the other hand, it can incentivize the development of new tools and techniques to extract value from the network, which may drive innovation and improve the overall ecosystem.

  • Faiz Adnan
Updated