MEV in Web3 Security: The Hidden Tax and Its Implications
Maximal Extractable Value (MEV) has become one of the hotly debated topics in the realm of Web3 security. Derived from the very fabric of blockchain operations, MEV represents both a boon for miners and a potential hazard for regular users.
Defining MEV
MEV, originally referred to as “miner extractable value” in the context of proof-of-work, defines the maximum amount that can be profitably extracted from block production beyond the typical block reward and gas fees. This is achieved by selectively including, excluding, or rearranging transactions within a block. But with the transition to proof-of-stake systems, where validators, not miners, hold these powers, the term has since evolved to “maximal extractable value.”
MEV’s Mechanisms and Implications
When users initiate transactions, there’s a window between the transaction’s broadcast to the network and its mining into a block. This period sees transactions waiting in a “mempool,” a transparent transaction pool. This transparency, while inherent to blockchain’s design, also offers an opportunity for arbitrageurs and miners to observe and capitalize by frontrunning these transactions. This act can be especially lucrative when coupled with profit-sharing schemes like FaaS/MEVA.
But what are the ramifications?
-
User Impact: MEV functions like an invisible tax that miners can impose upon users, thereby increasing transaction costs without users even realizing it.
-
Threat to Ethereum: The lure of MEV can be so enticing that miners may willingly destabilize consensus for a bigger payout, especially when block rewards seem meager in comparison.
Flashbots Dashboard offers In-Depth into these activities, providing real-time data on extracted MEV, illustrating the growing nature of this trend.
Blockchain networks, including prominent ones like Bitcoin and Ethereum, operate as unchangeable ledgers safeguarded by a decentralized ensemble of computers, commonly termed “block producers”. In proof-of-work (PoW) systems, these are known as miners, whereas proof-of-stake (PoS) networks call them validators. Their primary function is to compile pending transactions into blocks. Once validated by the wider network, these blocks are then added to the overarching ledger. While these networks ensure every transaction’s integrity and maintain constant block production, the sequence in which transactions are recorded isn’t necessarily the same as when they’re submitted.
A block has a capacity limit for transactions, which means block producers enjoy the discretion to pick which queued transactions from the mempool—a space where unconfirmed transactions await—they’ll incorporate in their block. Although they often prioritize transactions based on the highest fees to boost their revenue, this isn’t mandated by the network. This flexibility permits them to enhance their earnings by rearranging transactions, leading to the phenomenon of maximal-extractable value (MEV).
Typically, block producers prioritize transactions based on the fees attached, not the submission time
Extracting MEV demands specialized knowledge and resources. Consequently, it’s a standard practice for blockchain network’s block producers to delegate block creation to external networks comprised of searchers, builders, and relayers. Searchers identify MEV possibilities and curate bundles of several transactions, occasionally incorporating another user’s transaction. Afterward, these bundles are directed to builders who merge them to craft a comprehensive block. Completed blocks are then offered to relayers, forming the bridge to a blockchain’s primary block producers. It’s worth noting that while this depicts a prevalent approach to MEV extraction today, the ecosystem is in a state of swift metamorphosis.
MEV’s emergence, unfortunately, often undermines the interests of average users. The repercussions, although not instantly discernible, become evident post-transaction. For instance, users might experience inferior trade execution rates, with MEV being siphoned directly from their transactions.
MEV in Action
To better understand MEV, consider these manifestations:
-
DEX Arbitrage: Perhaps the most basic form of MEV, this entails buying a token on one decentralized exchange (DEX) at a lower price and immediately selling it on another DEX at a higher rate. This strategy assures risk-free profit due to blockchain mechanics.
-
Liquidations: Lending platforms like Aave and Maker let users deposit collateral, which can then be borrowed by other users. When borrowers’ collateral values dip below certain thresholds due to market movements, these platforms allow for the collateral to be liquidated. This offers a ripe MEV opportunity for those who can swiftly spot and act upon these liquidation events.
-
Sandwich Trading: This involves observing large trades in the mempool, and capitalizing on the price effect of these trades. Traders can insert their own transactions before and after a large trade, essentially “sandwiching” the initial trade to reap profits.
-
NFT MEV: While newer and less defined, there are MEV opportunities within the NFT sector. Given that NFT transactions occur on shared blockchains, traditional MEV strategies can be adapted for NFTs, like being the first to buy a highly sought-after NFT.
The long tail
DEX arbitrage, liquidations, and sandwich trading are all very well-known MEV opportunities and are unlikely to be profitable for new searchers. However, there is a long tail of lesser known MEV opportunities (NFT MEV is arguably one such opportunity).
Searchers who are just getting started may be able to find more success by searching for MEV in this longer tail. Flashbot’s MEV job board(opens in a new tab) lists some emerging opportunities.
The Rise of Sniping Bots
During the peak of the “altcoin” frenzy a year ago, sniping bots emerged as a predominant tool amongst opportunistic traders.
Step 1: These bots were programmed to vigilantly scan the blockchain for the launch of a new altcoin, particularly looking for events signaling the addition of liquidity.
Step 2: Once liquidity was detected, the bots would quickly execute a purchase of the new altcoin, securing it at an initial favorable rate before the broader market could react.
Step 3: After this initial acquisition, the bots would simply wait. As more traders discovered and began buying the altcoin, demand would drive the price up.
Step 4: Once the coin’s value had significantly appreciated – sometimes seeing increases of 2x, 5x, 10x, or even more from the initial purchase price – the bot would liquidate its position, selling off the altcoin for a substantial profit.
Such strategies, while lucrative, also introduced volatility and unpredictability in the market, especially for newcomers unaware of these automated players.
https://github.com/topics/pancakeswap-sniper-bot-free
Countering MEV
Efforts are underway to address the challenges posed by MEV. Projects like Flashbots aim to circumvent the public mempool by allowing traders to directly submit MEV transactions to validators. This shields transactions from being preyed upon by frontrunners.
Additionally, the Ethereum community is actively researching and devising techniques to reduce gas usage, such as “gas golfing.” This involves optimizing transaction programming to minimize gas fees, giving traders an edge in MEV opportunities.
Concluding Thoughts
MEV’s emergence showcases the teething problems faced by burgeoning technologies like blockchain. While it offers lucrative prospects for some, its unchecked proliferation can undermine user trust and system stability. As the world of Web3 security evolves, striking a balance between profit motives and system robustness becomes imperative.