Learn about MEV, a crucial concept in blockchain economics. Discover how miners extract value and what it means for DeFi
According to the Flashbots dashboard, MEV has been a significant issue in Ethereum’s ecosystem. For instance, over the past month, nearly $20 million worth of MEV has been extracted, impacting market dynamics and transaction costs. So if you don’t think it’s not your cup of tea, you might be wrong. Originally called Miner Extractable Value, MEV extends beyond miners to include validators in various blockchain systems. For instance, a validator might front-run your transaction by buying tokens before you, causing their price to rise, thus making you pay more. So, let’s see how you can mitigate the risks!
MEV, originally known as Miner Extractable Value, refers to the additional profit that miners or validators can earn beyond the standard block reward. By strategically manipulating the order of transactions or including or excluding certain transactions, these entities can capture extra value from the blockchain ecosystem.
Let's say you're trying to buy 100 tokens of a new cryptocurrency at a price of 10 ETH per 100 tokens. You submit your transaction on Uniswap, but before it gets processed, a validator, or miner, sees that your transaction is pending and notices that once it's executed, the price of the tokens will likely rise.
The validator front-runs your trade by submitting a transaction ahead of yours. They buy the tokens at the same price of 10 ETH per 100 tokens, which increases the token’s price due to the mechanics of automated market makers (AMMs). So by the time your transaction is processed, the price has gone up, and now you have to pay 10.2 ETH per 100 tokens instead of the original 10 ETH.
Since the DEX transaction is executed automatically once it reaches the blockchain, you can’t cancel or back out of it, and you end up paying more than you originally intended. The validator profits by selling those tokens at the new higher price back into the market, while you're stuck paying more for the same amount of tokens. This is called MEV, or Maximal Extractable Value.
While the term "miner extractable value" was initially coined for proof-of-work (PoW) blockchains, MEV is not limited to miners alone. In proof-of-stake (PoS) and other types of networks, validators have the same opportunity to extract additional value. To reflect this broader applicability, MEV is increasingly referred to as "maximal extractable value." In this blog post, we'll use the term "MEV" to encompass the full scope of this phenomenon across various blockchain networks.
MEV bots operate on the fringes of blockchain ecosystems, constantly searching for opportunities to extract additional value beyond standard transaction fees. These software programs act as silent observers and strategists, connected directly to blockchain nodes.
First off, MEV bot owners choose a target blockchain, often Ethereum due to its established infrastructure and developer base. Public node providers like Infura or Alchemy simplify the setup process, granting the bot owner access to real-time data on pending transactions and block proposals.
Next comes the selection of a programming language. Python, with its vast libraries for blockchain development, is a popular choice. Alternatively, Go offers superior performance and concurrency, making it ideal for high-volume applications.
With the foundation laid, the bot owner enters the critical phase: strategy development. This involves pinpointing specific MEV opportunities, such as large trades on DEXs, arbitrage opportunities, liquidation opportunities in lending protocols, high-value NFT purchases, and different attack types such as front-running or sandwiches. Sophisticated algorithms are then crafted to detect and exploit all this. Take a look!
MEV isn’t just an isolated issue for traders; it has ripple effects across the entire blockchain ecosystem. When validators or miners extract MEV, it can lead to a range of outcomes that influence everything from transaction fees to the overall user experience on decentralized applications (dApps).
One of the most immediate impacts of MEV is the increased cost of transactions. In a typical scenario, validators who spot opportunities for MEV are often willing to pay higher gas fees to ensure their transactions are included first. This creates a bidding war, as regular users may also try to increase their gas fees to ensure their transactions are processed in time. The end result? Higher transaction costs for everyone, particularly during times of network congestion.
For example, if a validator spots an arbitrage opportunity on a DEX, they might raise the gas price to prioritize their transaction, causing others to do the same in a competitive gas war. Users who aren’t even involved in the arbitrage or MEV activity are forced to pay more for their transactions as a result, and this dynamic can make using dApps more expensive and less predictable.
MEV doesn’t just drive up costs—it can also make interacting with dApps less user-friendly. Front-running, for example, can cause users to miss out on profitable trades or purchases. Imagine trying to buy tokens or NFTs, only to find that someone else (usually a bot) has scooped them up ahead of you, pushing the price higher. This can lead to frustration and a loss of trust in the fairness of decentralized systems, as users feel they’re competing against bots rather than participating in a fair market.
Additionally, sandwich attacks and other MEV strategies that manipulate transaction ordering can create uncertainty for users. Since users have no control over how their transactions are ordered once submitted, they are at the mercy of validators or miners prioritizing profits over transaction fairness. This uncertainty harms the overall user experience and can deter broader adoption of dApps and decentralized finance (DeFi) platforms.
MEV can also contribute to the centralization of power in blockchain ecosystems. As MEV becomes more lucrative, validators and miners who can extract the most value may dominate the network. They can reinvest their profits into hardware, access to better information, or even preferential treatment from flashbot relayers, giving them an advantage over smaller players.
This concentration of power undermines the decentralized ethos of blockchain technology. When a few powerful actors have the ability to manipulate transactions and extract value at the expense of regular users, it creates an uneven playing field, which can deter participation from smaller validators and harm the network's overall decentralization.
MEV extraction is not limited to just a single approach; rather, there are several strategies and techniques that miners and validators use to maximize their profits. Two of the most common strategies are front-running and sandwich attacks.
What is Front-Running? Front-running is a classic MEV technique where a miner or validator reorders transactions to gain an advantage. Specifically, they insert their own transaction before a pending one that they know will likely cause a market shift, allowing them to profit from the difference in price.
How Front-Running Works (Example): Actually, in the very beginning of the article, we’ve already talked about this attack type, but now you know that it’s front-running. Read through this brief explanation of how the attack works again and be prepared to compare it to the sandwich attack down below.
Again, you're trying to buy 100 tokens of a new cryptocurrency on a decentralized exchange (DEX) like Uniswap for 10 ETH. When you submit your transaction, it doesn’t get processed immediately—it enters a mempool, a public waiting area for unconfirmed transactions. Validators, miners, or MEV bots scan the mempool, searching for profitable opportunities.
Now, a validator sees your pending transaction and notices that when it goes through, the price of the tokens will increase. Instead of letting your transaction be processed first, they insert their own buy order just ahead of yours for the same 100 tokens at 10 ETH. Once the validator's transaction is processed, the price of the tokens rises due to the automated market maker (AMM) mechanics on the DEX. When your transaction is finally processed, you now have to pay 10.2 ETH instead of 10 ETH. The validator can immediately sell the tokens at a higher price, profiting from the price difference, while you lose money on the same purchase.
In this way, front-running allows validators to “cut in line” and profit at the expense of other users, distorting market fairness.
What is a Sandwich Attack? A sandwich attack is a more advanced form of front-running, where the validator both front-runs and back-runs a user's transaction to extract maximum value. Essentially, they "sandwich" the user's transaction between two of their own—one placed before and one placed after.
How Sandwich Attacks Work (Example): Imagine you want to buy 100 tokens of a cryptocurrency, and you submit your transaction to a DEX like Uniswap. Let’s say the current price is 10 ETH for 100 tokens. Your transaction enters the mempool, and a validator running an MEV bot notices your pending trade. Here’s what happens next in a sandwich attack:
Step 1: Front-Run The validator places a buy order for the same tokens right before your transaction, buying them at 10 ETH. This purchase increases the price of the tokens due to the AMM system.
Step 2: Your Transaction Now, when your transaction is processed, the price has already increased because of the validator's front-running. Instead of buying 100 tokens for 10 ETH, you now have to pay 10.2 ETH due to the price increase caused by the validator.
Step 3: Back-Run After your transaction goes through, the validator places another transaction right after yours—this time, selling the same 100 tokens they bought earlier at the inflated price. They profit from the higher price, while you're left overpaying for your tokens.
At first glance, front-running and sandwich attacks may seem similar, but there are key differences between the two. In a front-running attack, the attacker (validator, miner, or bot) spots your transaction in the mempool and places their own transaction ahead of yours. The key point is that they only place one order before yours, raising the price slightly before your transaction gets processed. A sandwich attack, on the other hand, involves two transactions placed around yours—one before and one after. In this attack, the front-run action still happens as the attacker buys the asset before your transaction, raising the price.
To address the challenges posed by MEV, one of the most notable solutions is provided by Flashbots, a pioneering organization of researchers dedicated to mitigating the negative effects of MEV. Flashbots employs a sophisticated mechanism to counteract manipulative practices and promote fairness in transaction processing. Here’s a closer look at how Flashbots operates under the hood.
At its core, Flashbots involves several key components:
Flashbots introduces a private mempool for transactions, which is separate from the public mempool where transactions are usually broadcasted. This private pool is accessible only to participants within the Flashbots network, including miners and validators. By submitting transactions to this private pool, users can avoid the public mempool’s exposure, which reduces the likelihood of their transactions being front-run or manipulated by opportunistic actors.
Within the Flashbots ecosystem, transactions are not simply included in blocks on a first-come, first-served basis. Instead, transactions are auctioned to miners and validators who participate in the Flashbots network. This auction mechanism involves transaction submitters bidding for block space, which helps ensure that transactions are processed in a more predictable and fair manner. By allowing miners to bid on transactions, Flashbots aligns the incentives of both users and miners, reducing the need for manipulative practices.
A crucial component of the Flashbots infrastructure is the MEV-Boost relay system. MEV-Boost acts as an intermediary between transaction submitters and miners. It facilitates the auction process by collecting bids from miners for transaction inclusion and then selecting the highest bidder to include transactions in the next block. This system enhances transparency by providing a competitive environment for block space and ensures that transactions are processed based on fair bidding rather than exploitative tactics.
Flashbots also emphasizes transparency by providing detailed reporting and analytics on MEV activities. This includes insights into transaction orders, bidding patterns, and the overall impact of MEV on the network. By making this data available, Flashbots helps users and developers better understand the dynamics of MEV and take informed steps to mitigate its effects.
Overall, Flashbots' approach combines a private transaction pool with an auction mechanism and a relay system to create a more equitable environment for transaction processing. By mitigating the potential for MEV exploits and promoting transparency, Flashbots aims to address some of the core challenges associated with Maximal Extractable Value.
Many popular wallets, such as MetaMask and MyCrypto, support Flashbots.
MetaMask
Update MetaMask: Ensure you have the latest version of MetaMask installed.
Enable Flashbots Relay: Go to your MetaMask settings and look for the "Advanced" section. Enable the "Flashbots Relay" option.
Configure Settings: You may need to configure additional settings, such as the relay URL and your public Ethereum address. Refer to the MetaMask documentation for specific instructions.
MyCrypto
Install Flashbots Extension: Download and install the Flashbots browser extension from the Chrome Web Store.
Connect MyCrypto: Connect your MyCrypto wallet to the Flashbots extension.
Configure Settings: Follow the on-screen instructions to configure the necessary settings.
Submit Transactions Through Flashbots! When you submit a transaction, select the option to use Flashbots.
Maximal Extractable Value (MEV) is likely to remain a key issue as blockchain ecosystems evolve, especially with the rise of decentralized finance (DeFi) and increasingly complex smart contracts. While Flashbots and similar solutions have made strides in addressing some of the negative impacts of MEV, the landscape is still far from immune to manipulation. As more validators and bots compete for a slice of the MEV pie, the arms race for transaction ordering and inclusion will intensify.
One possible future involves more sophisticated auction mechanisms and off-chain coordination to reduce gas wars and front-running attacks. Additionally, new privacy-focused blockchain technologies like zero-knowledge proofs (ZKPs) could help obfuscate transaction details, making it harder for opportunistic actors to exploit the mempool. This may offer a path toward reducing the extractable value without compromising transparency and security.
Developers are also exploring ways to redesign decentralized exchanges (DEXs) and other dApps to minimize MEV exposure, creating fairer environments for users. As research and development continue, we can expect to see more innovations in both offensive and defensive MEV strategies, shaping the future of DeFi and blockchain networks.
While there's no foolproof way to protect oneself from MEV attacks, using tools like Flashbots can help reduce the risk. Flashbots bundles transactions and allows users to submit them to a private pool, minimizing the chances of being front-run. Additionally, users can stay informed about MEV strategies and adjust their trading habits accordingly.
The future of MEV is likely to be complex and dynamic. While solutions like Flashbots have made progress, the ongoing arms race between MEV searchers and MEV mitigation techniques suggests that the issue will persist. New technologies and regulatory frameworks may emerge to further address MEV, but the overall landscape will likely continue to evolve.