In the darkest day and darkest night, no block shall escape my sight
The craze to get profitable even whilst securing an asset or from front-running innocent transactions in a blockchain has led to chaotic events in the Ethereum ecosystem. The struggle to gain block control to maximize profit both by validators and searchers has led to an increase in transaction fees, which has a ripple effect — a lack of scalability, decentralization, and even security.
Dark Forest
This mayhem occurs in the ETH chain, specifically, in “the dark forest.” As Paradigm researchers Dan Robinson and Georgios Konstantopoulos would say, “ if the ETH chain is a battleground, the memepool is a dark forest.”
The memepool is a database of unconfirmed or pending transactions. Searchers (independent network participants) take advantage of this database. Bots are created specifically to monitor transactions that they can front-run and profit from. Validators and searchers work hand in hand in this act.
How Validators and Searchers work together to extract MEV
Validities as well as searchers read the memepool; validators check to determine which transactions can yield more gain to them. Searchers use their bots to detect profitable transaction opportunities (arbitrage) in the ETH chain thanks to the memepool and submit these transactions to the network. Searchers are willing to pay high gas fees to front-run transactions and get these transactions added to a block and accepted by a validator. Validators will in turn accept these transactions due to the high gas, even if it’s to reorganize the memepool and select the most profitable transactions. This, in practice, is how MEV works.
As stated above, the term “dark forest” is coined from a Chinese fiction book — The Dark Forest, an environment in which detection means fatality. As stated above, searchers and validators noticing a profitable transaction can be unfavorable to the ETH users.
Enough chitchat and talk about the metaphor, “The Dark Forest.” Let’s dive into the topic of the day — MEV.
MEV
Maximum Extractable Value is the profit validators accrue based on their ability to rearrange transactions in a way that will be favorable to them while producing blocks.
Pmcgoohan, an algorithmic trader, predicted MEV activity in 2014. He warned that miners could rearrange transactions in a memepool to increase their profits.
The MEV concept first appeared in a 2019 research work by Phil Daian, Ari Juels, and 5 other colleagues — Flash Boys 2.0. The researchers exhibited real-time MEV dynamics and detailed their effects on users and the ETH blockchain. Also, as mentioned earlier in this article, researchers Dan Robinson and Georgios Konstantopoulos further described ETH as a “dark forest,” highlighting MEV’s impact on the description.
These articles and more gained MEV some popularity. MEV is a multimillion-dollar industry with more research work focused on MEV and curtailing it. Today, Flashbots estimates that over $675 million is the total extracted MEV.
MEV was originally called “Miner Extracted Value” but was changed to Maximum Extractable Value because of ETH’s switch to Proof-of-Stake.
Miners, now validators, are responsible for building blocks (block producers), and they broadcast these blocks to the chain in order to be added to the chain. Nodes collect transactions stored in the memepool for new blocks to be built.
Note, there’s no set of rules to guide block producers on how to order transactions in a block. Block producers are free to reorganize, remove, and include transactions in a way that benefits them.
How does MEV work?
Traders also benefit from MEV thanks to arbitrage opportunities provided by different CEXs (Centralized Exchanges) and DEXs (Decentralized Exchanges).
But for this arbitrage to be successful, two things must occur:
Block producers can choose to ignore the transaction. Hence, the trader loses the value, or the block producer can copy the same transaction for their benefit and include it in the block.
2. Another trader can spot this transaction thanks to a bot, and send the same transaction to the memepool with a higher gas fee so that the block producers can include their trade. However, the trader who initiated the transaction first can increase their gas fee, thereby starting a bidding war.
Ways to Extract MEV
1. Front-Running: Searchers use bots to scan the mempool and replicate users’ transactions with a higher gas price so that validators will choose theirs over others.
2. Sandwich attacks: A type of front-running attack in a DEX. This occurs when a searcher detects a large pending transaction by a user in a DEX, then buys the token before the user and sells the token after the user has bought the token to gain from an artificial price change.
This will occur in the following steps:
Detect a large transaction before it gets executed
Buy the token before it gets executed
Wait for the user’s transaction to be executed
Sell all tokens and enjoy the profit
From the diagram above, each time a token is bought, the price rises. If you buy first and then someone else buys later, the token price goes higher. If you then sell immediately after the person buys, you make a profit.
3. Dex Arbitrage: Tokens in different Dexs have different prices thanks to the nature of Defi. Bots can utilize this opportunity to buy low in a different DEX and sell high in a different DEX. This helps to align the prices of tokens in Defi.
4. Defi Liquidation: In defi lending protocols, borrowers are required to deposit a certain amount of collateral to borrow a loan. When the borrower can’t repay his loan, the protocol allows anyone to liquidate the collateral and earn a liquidation fee. Searchers will compete to determine which borrowers can be liquidated and earn a liquidation fee.
The utility of MEV
While MEV can have a negative impact on a blockchain, as discussed above, it has its usefulness in Defi. Arbitrage traders help maintain token prices on defi whilst arbitraging across different exchanges.
If a token is underpriced, a large buy order will bring a token to its normal price; if it’s overpriced, a large buy order will decrease its price, bringing it to its normal price. This contributes to increased efficiency in the Defi markets.
How to protect yourself from MEV
Searchers are always on the lookout for large transactions on the ETH chain. Using private transaction services like Flashbots might help out, but you’ll need to trust their services.
Also, whilst being a defi enjoyoor, large transactions are on the lookout for. You might want to limit slippage while performing large transactions.
Conclusion
In the future, we hope things get better, and thanks to devs who work and research hard on ways to curtail this menace. A proposal — Danksharding is in talks as a step to avoid block censorship and accelerate MEV’s end.
If you enjoyed this write-up and would like to reach out to me. This is my twitter handle — twitter.com/0xSalazar
Please remember to do your research. None of this is financial advice.