What is MEV
MEV stands for Maximal Extractable Value, which refers to the maximum value that can be extracted from block production in addition to standard block rewards and gas fees by including, excluding, and changing the order of transactions in a block.
Philip Daian and others first coined "MEV" in "Flash Boys 2.0," a 2019 research paper. MEV meant "miner extractable value" in the paper because the paper focused on Proof-of-Work miners. However, MEV exists in both Proof-of-Stake and Proof-of-Work networks. In addition, third parties (MEV bots), rather than block producers, now extract the most types of MEV. As a result, MEV gradually shifted its meaning to maximal extractable value.
In most blockchain systems, pending transactions are held in a publicly visible waiting area called the "mempool." Miners or validators select them from the mempool, order them, and execute them in a new block. The network validates the new block, and the pending transactions become finalized. MEV bots can take advantage of the process.
Who are “miners”? What can they get through mining? Please refer to the content: What is Mining
Examples of Profit-Making Scenarios
Sandwich Attack
A sandwich attack occurs when an MEV bot detects a large pending trade on a decentralized exchange and places a trade right before and right after. The sandwich attack decreases the amount of cryptocurrency the original trader will receive and allows the MEV bot to pocket the difference.
For example, Wayne places an order to buy 10 ETH at $1,000 each on Uniswap for a total of $10,000. The transaction will be sitting in the mempool waiting to be executed. When an MEV bot discovers Wayne's pending transaction, it can immediately place two additional orders to be included in the same block. The sandwich in the confirmed block looks like this:
- Step 1: MEV bot buys $10,000 worth of ETH at $1,000, pumping ETH price to $1,005.
- Step 2: Wayne buys 10 ETH at $1,005, paying $10,050 rather than $10,000.
- Step 3: MEV bot sells 10 ETH at $1,005, netting $50 of profit.
The additional cost for Wayne (the MEV victim) depends on the slippage of his order. Slippage is the percentage difference in price he's willing to accept between the time of the trade order and execution — the lower the slippage, the lower the return from a potential sandwich attack.
Just-in-time ("JIT") Liquidity
JIT Liquidity refers to when an LP provides and removes liquidity immediately before and after a pending swap on a DEX. When an MEV bot observes a large pending swap in the mempool, it adds liquidity to the DEX concentrated in the one tick for which the swap will be in-range. After the swap is completed via the JIT Liquidity and fees are earned, it immediately removes the LP position from the DEX. JIT Liquidity is like a reversed Sandwich Attack on traders, who will benefit from improved trade execution.
What is liquidity? What is an LP? What do they mean to DEX? Please refer to the content: What is Liquidity & LP (pool)
DEX Arbitrage
Cryptocurrencies will often have different prices on different decentralized exchanges. When there's a significant price difference between exchanges, MEV bots can buy from the lower-priced exchange and sell on the higher-priced exchange for a profit. As a result, prices across exchanges are more aligned, making the market more efficient.
Liquidation
When borrowers cannot repay loans on DeFi lending protocols, the protocols allow anyone to liquidate the insolvent borrowers' collateral and earn a liquidation fee. MEV bots usually seize this opportunity.
What is the mechanism of liquidation? And what's it for? Please refer to the content: What is liquidation
The War of Gas Fee
It is a gas war among MEV bots for the right to take advantage of the most apparent MEV opportunities. Transactions with high gas fees will receive priority and get executed before ones with lower gas fees. MEV bots can manipulate the ordering of their transaction within a block by changing the transaction fee they pay to block producers.
In other words, the only way to guarantee an MEV transaction goes through is if it is submitted with the highest gas price.
As a result, although the miners and validators are not seeking MEV arbitrage, they take home most of the profit. For example, some MEV bots will pay 90% or more of their total MEV profit in gas fees to beat others in the same business for a potential MEV opportunity.
Influence of MEV
Some forms of MEV extraction are detrimental to the network and its users, while others can be beneficial. For example, victims of sandwich attacks suffer from increased prices. On the other hand, DEX arbitrage MEV provides DEX users with the most accurate price, and speedy liquidation in lending protocols protects lenders.
You might also be interested in the following content:
DeFi
DEX
What else do you want to learn?