What is Maximum Extractable Value (MEV), and How Does it Work?
The Maximum Extractable Value (MEV), formerly 'Miner Extractable Value,' is the lesser-spoken ghost lurking in the DeFi space.
Most people are aware of transaction fees when sending a cryptocurrency transaction. However, these are not the only fees that users must pay. Users also pay a hidden cost when interacting with decentralized exchanges (DEXs), called the MEV.
So, what is it, and how does it work?
What Is Maximum Extractable Value (MEV)?
First introduced by Philip Daian and seven other researchers in the paper 'Flash Boys 2.0', Maximal Extractable Value (MEV) is the value block producers can derive by re-ordering, front running, or censoring transactions to be added to the main chain from the mempool.
A mempool is essentially a holding area for all the valid transactions broadcasted to the network but are not yet included in a block.
In simple terms, it is the value that a user could lose due to the miner's ability to manipulate which transactions are included in the next block.
For simplicity, we will refer to the MEV-extracting entity as "MEE."
How Can You Earn MEV?
MEV can be earned by:
- Order filling transactions
- Re-ordering transactions
- Censoring transactions
It is similar to how traditional financial institutions make money from high-frequency trading (HFT).
Order Filling: When a block is produced, the MEE collects all the transactions from the mempool and sorts them according to the gas price. The MEE will fill blocks with the transactions offering the highest gas fees first.
Re-Ordering: The MEE can also re-order transactions in the mempool according to their benefit. This could be done by sorting the transactions in the mempool according to the gas price and selecting the most profitable ones to include in the next block.
Censoring: Another way an MEE can extract MEV is by censoring transactions from the mempool. This could be done by preventing certain transactions from being included in the mempool or by simply not including them in the next block.
These three methods give rise to two most common MEV attacks:
- Frontrunning transactions
- Sandwiching transactions
1. Frontrunning Transactions
Frontrunning a transaction is when the MEE pays more gas fees to execute a profitable transaction before you despite you being the first to initiate it.
This is usually done to steal arbitrage opportunities spotted by other users.
Suppose exchange A has ETH listed at $1,500 while exchange B has it listed at $1,510. If you were to buy ETH from exchange A and sell it immediately on exchange B, you would earn a profit of $10. But to do that, you'd have to pay gas fees.
A frontrunning bot could see this and pay higher gas fees than you so that the MEE's transaction is included first in the block and makes the profit.
2. Sandwiching Transactions
Sandwich bots exploit a trait of Automated Market Makers (AMMs) called "slippage."
Slippage is the difference between the price you expect to pay for an asset and the actual price you end up paying. It occurs for all transactions but is noticeable when there is a large order and insufficient liquidity to fill it at the expected price.
To exploit this, sandwich bots place buy and sell orders on either side of your large order. When your order is finally filled, the sandwich bot's orders will be too, but at a better price due to the slippage.
This allows the MEE to earn MEV from the price difference.
How To Get Rid Of MEV?
There is no sure way to get rid of MEV (yet), as it is a natural by-product of having a decentralized network.
But some things can be done to minimize it:
- Increasing the number of transactions in each block
- Making it harder for MEEs to re-order transactions
- Randomly ordering transactions in the mempool
These methods would make it more difficult for MEEs to extract MEV and make it more difficult for regular users to confirm their transactions quickly.
Flashbots is one project that is working on reducing MEV. It works by concealing the mempool itself. If the MEE does not have access to the mempool, then they cannot manipulate how they produce blocks.
A flashbot is a relayer connected to other block producers also running flashbots. Therefore, by sending private transactions to the network, you can get around MEVs.
Addressing MEV with Transak
While MEV is an inherent challenge within decentralized systems, there are solutions that can help mitigate its impact on users. Transak is an indirect solution to reduce exposure to MEV attacks.
Transak provides a fiat on-ramp directly embedded into DeFi applications.
This means you can purchase cryptocurrencies with your traditional currency without navigating complex exchanges or separate wallets. This streamlines the process, reducing the opportunities for MEV attacks like front-running.
Conclusion
While MEV is often seen as a flaw in the system, it is also an incentive for traders to provide liquidity to the network.
MEV is a natural by-product of having a decentralized network and is somewhat difficult to avoid.
We hope this article has helped you better understand what MEV is and how it works.