Written by @ajcrypto333
Introduction.
‘MEV’ is one of the most significant issues in blockchain and one of the least known problems among crypto folks. In this article, I will take you through the absolute basics of MEV, different MEV strategies, the good and bad effects of MEV, and more in the most simple way possible.
So, make sure you make it to the end.
What do you mean by ‘MEV’?
‘MEV’ is the short form for ‘Maximal Extractable Value’, but what does that mean?
By definition MEV means:
The maximum value that can be extracted from block production over the standard block reward and gas fees by including, excluding, and changing the order of transactions in a block.
And what does this mean?
Simply put, ‘MEV’ is the maximum value aka money miners can make beyond the normal transaction fees by adjusting some transactions here and there.
Don’t worry we’ll learn it along the way.
First some history notes:
● The problem of MEV was first addressed by aReddit user ‘pmcgoohan’, Read the Reddit post here. (2014)
● The term ‘MEV’ was first coined in a research paper “Flash Boys 2.0: Frontrunning, Transaction Reordering, and Consensus Instability in Decentralized Exchanges” (2019)
Working of MEV.
Before understanding the working of MEV, you need to know what a ‘Mempool’ is
Basically, Mempool or Memory pool is a pool where all unverified transactions rest.
For eg, If you submit a transaction in the Ethereum network, the transaction will first go to a Mempool and wait there until some miner verifies your transaction and that’s how your transaction will get completed.
Image credits: Stex.com
Now that you know what a Mempool is, let’s discuss the working of MEV.
Imagine you found out a great trading opportunity on uniswap that could possibly earn you 6 figure profit. So, you initiated the trade, since you are trading on a DEX you need to wait for your trade transaction to get verified.
As we learned earlier, until the transaction is verified, the transaction rests on the Mempool.
Since the txn is on a Mempool, miners can see your trade txn even before the trade settles. So, what if a miner decides to copy your trade, initiate the trade txn, and run his trade before yours? (Thus effectively stealing your profits)
For what? Profit, obviously.
But how? By simply offering more txn fees than your txn’s. Because miners will most likely verify txns with higher txn fee first (before txns that of lower txn fee), thus effectively frontrunning´your trade & stealing your profits.
What we just saw is a common form of MEV called ‘Frontrunning’, where normal users are front ran by a miner by bidding more txn fee aka gas fee than that of user’s txns.
Image source: Chainlink
As in the example above, Front-running is a very common thing used by miners to extract value from users. But, nowadays the MEV is not mainly carried out by miners. They are carried out by ‘Searchers’ aka bots operated by individuals because the mempool data is public and it can be seen by searchers and they’ll use it to their profit.
Searchers.
MEV activities are not always carried out by miners, majorly they are carried out by bots (front-running bots, back-running bots, arbitrage bots, etc) who actively scan the mempool for MEV opportunities, they are known as ‘searchers’. Needless to say, they are the most important actors in MEV.
Just like ‘Frontrunning’, there is also something called ‘Backrunning’.
In a backrunning txn, the backrunner’s txn is desired to execute right after the target user’s txn.
But why?
Imagine you are trading some 1000ETH for DAI in the $ETH/$DAI pool on uniswap, because your trade size is big, it will drag ETH to a lower price compared to sushiswap’s $ETH/$DAI pool. So, a backrunning bot can buy $ETH for a lower price from uniswap right after your trade and sell it on sushiswap for a premium. (Arbitrage)
Now that we know about both ‘Frontrunning’ and ‘Backrunning’, let’s compare them.
– Frontrunning bots participate in gas fee bidding wars (also known as Priority Gas Auction or PGAs), which will in turn increase the gas fee of the whole network.
– The backrunning bots approach is a bit different, they spam the network with multiple txns of the same trade to increase their txn’s chance of getting confirmed right after the target’s txn, thus congesting the network with useless txns.
In a nutshell, Frontrunning bots tend to increase the gas fee of the network but, backrunning bots result in network congestion.
Popular MEV strategies.
1/ Sandwich attack:
This is one of the most common types of MEV attacks where the victim’s txn is sandwiched by 2 txns of the attacker.
For eg: Imagine you placed a buy of 1000ETH in the $ETH/$DAI pool on Uniswap, again because your size is size, it can sizably impact the price of $ETH (upwards).
So, In a sandwich attack, the attacker places a front-running txn to buy $ETH before the victim (This will also impact the slippage of the victim’s order) and places a txn to sell $ETH right after your buy order, Making some risk-free profit.
For better understanding, Let’s say:
Price of $ETH before your order: 1000$
Txn1 = Attacker buys 10E for 10k$ (byfront-running your txn)
Txn2 = You bought 1000E
Price of $ETH after your order: 1200$
Txn3 = Attacker sells 10E for 12k$, Thus making some 2k$ in profits easily.
2/ Arbitrage:
This is the most common type of MEV out there where arbitrage bots spot price differences of the same asset among different protocols and makes a profit from trading it.
For eg,
Price of $ETH in uniswap = 1000$
Price of $ETH in sushiswap = 1100$
Arbitrage buys 10E from uniswap for 10k$& sells it for 11k$ on sushiswap, making a 1k$ in profit.
But this can’t be easily carried out because there are tonnes of arbitrage bots out there always searching for an arbitrage opportunity, so at a time there will be a lot of bots fighting for the same opportunity which obviously leads to a bidding war.
3/ Liquidations:
Lending protocols like Aave, compound, etc provide you with loans but you need to put some collateral in a specific ratio. For eg, if you put up 1000$ worth of $ETH as collateral, you can borrow up to 750$ in $DAI from MakerDAO.
But when the collateral’s value comes down to lower than a specific ratio, A liquidator liquidates the collateral and pays back the lender. When this happens, the borrower is charged a liquidation fee.And this liquidation fee is rewarded to the liquidator.
So, the searchers actively search for such liquidation events to collect the fee for themselves.
4/ NFT MEV:
NFT txns, like every other txns, show up on the mempool and this leads to bidding wars & front-running among different collectors to get their mint confirmed.
The most recent example is ‘The Saudis’ NFT collection’s mint.
Above are some of the most common MEV strategies/opportunities, but they are just the popular ones and might not be easy for a beginner to enter & be profitable because of the heavy competition (saturated market), there are a lot more MEV opportunities that areyet to be discovered (Long tail MEV)
A few more MEV strategies to note:
– Time Bandit attacks: Read more here.
– Uncle Bandit attacks: Read more here.
Effects of MEV.
Bad effects:
● Increases network congestion due to spam txns.
● Increases network gas fees due to bidding wars (or PGAs).
● Sandwich attack marks increased slippage fortarget users.
Good effects:
● Arbitrage bots help in stabilizing the price ofan asset across various protocols.
● Liquidation MEV searchers help in the fast liquidation of collateral and help protocols to ensure that the lenders arepaid back ASAP.
Solutions for MEV.
1/ Flashbots:
“Flashbots is a research and development organization working on mitigating the negative externalities of currentMaximal Extractable Value (from now on MEV) extraction techniques and avoiding the existential risks MEV could cause to state-rich blockchains like Ethereum.”
So, actually what flashbots do is, run their own set of miners and help users to escape the MEV dark forest by not broadcasting the txn details to a public mempool but instead sending them to a private mempool.
If you initiate a txn normally, the txn goes into a public mempool waiting to be verified (as we discussed earlier), but because the mempool is private, everyone can see your txn and some of them will front-run you to keep the profits themselves.
For eg, Imagine you initiated a trade txn, but you know you’ll get front-ran by others because your txn is going to a public mempool. Instead, you can send your txn to the ‘Flashbot relayer’ and the relayer sends your txn to a set of miners run by flashbots and your txn will be mined by them and will only be public when the txn is verified so you cannot be front-ran. This is because they use a private mempool of their own to store unverified txns, that the public doesn’t have access to.
–
1inch integrated "flashbot transactions” into their system, Read about it here.
– Learn more about “Flashbots” here.
2/ Optimism’s MEV Auction(MEVA):
As the name suggests, it’s an auction where the auction winner can reorder submitted txns and insert their own txns as long as they do not delay any txn more than N blocks.
Image source: MEV wiki
Read more about Optimism’s MEVA here.
3/ FSS by Chainlink:
Fair Sequencing Services or FSS is an initiative from chainlink in the hope to reduce the MEV problems for normal users.
In the FSS system, the txn is submitted to a collection of nodes rather than a miner, and this collection of nodes verifies your txn. But the catch here is that the txn fee isn’t revealed to the nodes until they’re verified (encrypted). So, they can’t order txns according to the fees paid by the user. The txns will be ordered according to the time they were submitted (FIFO – First In First Out).
FSS was carried out in 2 phases:
– Phase 1: Secure casual ordering, meaning, the fees paid will be encrypted and the nodes should order & verify the txns somehow to see the fees paid.
– Phase 2: Aequitas, It’s a group of ordering protocols that will help in fairly ordering the txns (Ordering based on the time it was submitted).
Learn more about FSS by watching this video.
Conclusion:
MEV is a major problem for normal users, MEVs are worsening user experience and also seem a little unethical to me. This is not at all limited only to Ethereum but all chains with smart contract functionality. MEV is indeed a dark forest. And I hope I could give you a good understanding of this dark forest.
Lastly, I have curated a list of MEV reading resources and I’ll keep updating it. Have a look at it and enjoy!
Thanks for reading.
If you enjoyed this article, please follow me on twitter @ajcrypto333