Stop the MEV bots: a guide for crypto traders
Maximal Extracable Value is a hidden tax on all types of Ethereum transactions.
That means any time you want to transact in DeFi: from buying or selling an NFT, lending tokens to a liquidity pool, or swapping one token for another, a group of opportunistic users known as “searchers” have the opportunity to see your trade, and manipulate the criteria surrounding your trade to ensure they make profit, at your expense.
The workhorses of MEV are MEV bots, programs designed to look for certain types of transactions that can be exploited to make money.
In this article, we’re going to be exploring MEV Bots in more detail, looking at how they work, the different types, and what you can do to protect your trades from them.
What is MEV?
Maximal Extractable Value is, as the name suggests, a measure of the maximum amount of value that can be extracted from the contents of a given Ethereum block. Ethereum transactions are not all equally valuable, and validators (the parties responsible for creating the blocks) can pick and choose how to order transactions in blocks to maximize their profits. This means that transactions are not necessarily executed in the order they are received; instead, validators arrange them in a way that maximizes their compensation.
How MEV occurs in an Ethereum block
Upon order submission, Ethereum transactions get sent to a “mempool” where they wait to be added to a block. In this mempool, MEV bots (also known as “searchers”) can view pending transactions and bribe validators to reorder them, exploiting the little guy and profiting in the process.
What is an MEV bot?
MEV bots are programs designed to maximize profits by exploiting opportunities within blockchain transactions.
They operate on Ethereum, but also on chains where transaction ordering and gas price bidding are a feature.
By analyzing mempool data (pending transactions) and executing precise strategies, MEV bots can extract significant value from transactions across the DeFi space.
How does an MEV bot work?
On Ethereum, validators, the entities responsible for verifying transactions, are allowed to re-arrange the order of transactions as they see fit. Validators typically do this if there are opportunities to improve the profit they receive from validating transactions.
Let’s take a closer look at this concept. When you submit a transaction on Ethereum, it does not immediately get added to the next block. Instead, it first goes into the “mempool” which is the collection of all pending transactions. This pool is visible to anyone. You can see a screenshot of this below. And if you’re curious to see what it looks like, here’s a live feed.
Here is where MEV bots come in. Because validators are not required to add transactions to the block in the same order that they were submitted by users, anyone can pay those validators to re-arrange transactions in a certain way. This manipulation of the order of things allows MEV to happen. An MEV bot sometimes referred to as ‘searchers’ look for trades they can make money from.
Types of MEV bots
Now we understand what an MEV bot does, let’s take a look at the different types of MEV attacks that bots use.
Frontrunning Bots
Frontrunning bots place transactions ahead of others by outbidding them in gas fees. They look for high-value trades in the mempool with certain features like high slippage or typically focus on high-value transactions where their execution priority can yield significant profits. Learn more about frontrunning.
Backrunning Bots
Backrunning is a specific type of MEV (Maximal Extractable Value) which causes some traders to miss out on potential profit opportunities from their trades. In practice, backrunning involves strategically executing a transaction immediately after another, high-value transaction. By doing this, the backrunning transaction capitalizes on the arbitrage opportunity left over from the price impact of the initial transaction. Learn more about backrunning.
Sandwich Bots
Sandwich attacks occur when a user’s transaction gets trapped, or “sandwiched,” between two hostile transactions — one before and one after. As a result, the original transaction executes at a much higher price than necessary, leading to an inflated price for the original trader and a profit for the malicious trader placing the two extra trades (known as a “searcher”). Learn more about sandwich attacks.
Arbitrage/LVR Bots
MEV arbitrage bots identify and exploit price differences for the same asset across different decentralized exchanges or DEXes. This is also known as loss versus rebalancing. These bots look for a token price to be higher or lower on different exchanges, and then exploit the price difference between the two. Many liquidity providers haven’t even heard of LVR, but it costs them 5–7% of their liquidity, resulting in hundreds of millions lost each year. In fact, when accounting for LVR, many of the largest liquidity pools are not profitable for LPs at all. Learn more about LVR.
Liquidation Bots
Liquidation bots specialise in monitoring lending platforms looking for undercollateralized loans. If a borrower’s collateral falls below a required threshold, these bots execute liquidation transactions to claim rewards.
Flash Loan Bots
Technically not an MEV bot in the strictest sense, flash loan bots work to finance and facilitate MEV by utilizing flash loans. Flash loans are unsecured loans that must be repaid within a single transaction block. Flash Loan bots are often paired with bots above to facilitate the execution of MEV.
Why MEV bots are bad for Ethereum
As a permissionless, public platform, Ethereum serves as a battleground of opinions on whether MEV is good, bad, or should even be allowed in the first place.
Those sympathetic to the practice argue that MEV is a natural market mechanism that enhances market efficiency and encourages price discovery. While litigating the specifics of the issue is beyond the scope of this article, there are important arguments to be made for why MEV bots are harmful to individual users.
Reduce fairness
At its core, value extraction prioritizes sophisticated traders with the means and know-how to exploit transactions and profit off minute arbitrage opportunities.
Users who may simply be making trades on exchanges or minting NFTs have no way to compete with these value extractors unless they can write better bots to protect their transactions.
Disproportionately target beginners
Those new to DeFi are particularly vulnerable to being exploited. The world of decentralized trading is complex for beginners, who may not even understand settings like slippage tolerance, making them easy prey for bots waiting to take advantage of inexperienced traders.
This creates a negative equilibrium for decentralized trading that may drive newcomers away, hurting the ecosystem as a whole.
Engage in market manipulation
While there are arguments to be made for MEV encouraging market efficiency and price discovery, this is not the case with every type of MEV.
For example, trading MEV bots rely on exploiting slippage tolerances by raising prices up to a threshold and then selling immediately after in a sandwich attack. In this scenario, the AMM does not benefit from price discovery, but instead experiences an artificial pump-and-dump at the expense of a single trader. In traditional markets, such a move could be considered market manipulation as it adds nothing to the market and is designed solely to profit off a market participant.
How to beat MEV bots
While MEV is a pervasive problem across all of Ethereum, there are multiple ways to keep yourself safe.
Use tight slippage when trading
The most basic defense against MEV is setting a low slippage tolerance. Slippage tolerance is essentially how much variation in the final price you receive you are willing to accept. Transactions with a lower slippage tolerance give MEV bots less room to exploit trades.
For users who aren’t utilizing any other MEV protection tools, setting a lower slippage tolerance can be a good first line of defense, however it’s by no means a complete solution.
Setting the slippage tolerance too low often results in failed transactions. Even with optimal slippage, MEV bots may still be able to extract value from your trades. So sometimes we need to do more than adjust our slippage.
Use a Custom RPC Endpoint on Ethereum
A better protection method is to install an MEV protection RPC endpoint. A Remote Procedure Call (RPC) endpoint is an intermediate layer that routes transactions from a user’s wallet to the blockchain itself.
One of the most popular specialized RPC endpoints is MEV Blocker. As the name suggests, MEV Blocker provides protection against MEV across all of Ethereum. The RPC works by managing a permissionless network of searchers and hiding transactions from the public mempool.
These searchers cannot frontrun or sandwich user transactions. Instead, they capture value through backrunning. Anytime a searcher backruns a user’s transaction, the searcher keeps up to 10% of the value and sends the other 90% back to the user as a rebate.
Trade on pools with large liquidity
Fundamentally, MEV relies on arbitrage opportunities. One way to reduce exposure to such arbitrage is to restrict your trading only to pools with large liquidity. On these pools, individual trades won’t have much price impact, so it will be more difficult for MEV bots to extract value.
This strategy limits much of DeFi, of course, as there are constantly new coins launched, and even popular coins may suffer from low liquidity on certain exchanges or during certain times.
Use intent-based trading solutions
While RPC endpoints protect against MEV across many different types of trades, the most comprehensive solutions take place at the application level.
In recent years, there has been a surge in the popularity of intent-based trading solutions like CoW Swap, with leading exchanges like 1inch and Uniswap launching their own intent-based solutions in 1inch Fusion and Uniswap X. Unlike traditional decentralized exchanges, intent-based trading solutions rely on professional execution parties known as “solvers’’ to execute trades on behalf of users.
Delegating execution to professional third parties helps users get the best prices for their trades, as solvers can determine the optimal liquidity sources to tap into. It also means that solvers themselves take the risk of MEV, and users are protected from direct price exploitation.
The flow of a transaction on CoW Swap
(For LPs) Use an MEV-capturing AMM
Until recently, there wasn’t a great solution to MEV in the form of loss-versus-rebalancing (LVR). LPs basically had to accept that providing liquidity for tokens comes with a tax paid to the MEV bots that constantly rebalance the pools (at the expense of the liquidity providers themselves).
This all changed, however, with the launch of CoW AMM — a first-of-its-kind MEV-capturing AMM that redirects profits from pool rebalancing to liquidity providers. CoW AMM works sort of like MEV Blocker in that it makes the MEV bots work FOR users rather than against them. To trade against the liquidity in CoW AMM pools, solvers must bid to provide the most surplus to the pool, thereby giving the majority of LVR profits to the LPs.
Use an MEV-Protected DEX
CoW Swap is a meta DEX aggregator that finds the best prices for trades and provides comprehensive MEV protection. The protocol uses a unique trading mechanism that relies on batch auctions and intents to achieve the best outcomes for users.
Thanks to a powerful combination of delegated trade execution, batch auctions, and protected transaction flow through MEV Blocker, CoW Swap users benefit from thorough MEV protection on all trades.
Become a solver
CoW Protocol is a meta DEX aggregator that relies on bonded third parties known as “solvers” to execute user trades. The protocol uses an intents-based trading system where user intents get grouped into batches.
The solver that can execute the orders at the best price wins the right to settle the batch (find out more about how CoW Protocol works here.)
Solvers are compensated in COW tokens for settling batches, incentivizing them to compete to find better prices and win the right to execute user intents. In return for this compensation, solvers provide users with a number of benefits including:
-
Finding optimal prices for the trades in a batch
-
Protecting users from MEV by executing transactions on their behalf
-
Providing abstraction that allows for benefits like gasless trades, transaction bundles, directly tapping into LPs, and more
Thanks to a permissionless structure, anyone can become a solver. The main requirement is to put up a bond which serves as a guarantee that the solver will follow the rules or risk getting slashed. Solvers that do well find good solutions to the batch auction problem. They also generally:
-
Develop an efficient optimization algorithm
-
Identify and solve special problem instances that are easy to solve
-
Consider diverse liquidity sources
-
Integrate external market makers
Searchers vs. solvers
Fundamentally, searchers and solvers optimize for the same thing: maximizing profits. However, they serve different purposes, so their incentives diverge.
Searchers make money by performing MEV attacks on vulnerable transactions — giving users worse prices and keeping the difference for themselves. Searchers are incentivized to maximize their profits while ensuring that they are bidding enough for their transactions to be included in the next block.
In Ethereum, searchers work to out-bid each other to have their transactions included and make money. This is similar to what solvers do on CoW Protocol. The difference, of course, is that searchers benefit validators while solvers benefit users.
CoW DAO: Protecting Ethereum users from negative outcomes
Ultimately, the goal of Ethereum is to serve as a public platform that enables innovation. MEV as a problem emerges from a largely unrestricted marketplace. This benefits innovation by encouraging novel market mechanisms, but it also poses risks to uninformed traders.
For this reason, it’s important for users to be aware of the solutions available for protecting themselves. Regardless of what side of the MEV debate you stand on, most of us agree that we don’t want our trades exploited. To this end, CoW DAO has your back with products that protect you from Ethereum’s dangers and work to ensure positive outcomes.
-
Install MEV Blocker here: www.mevblocker.io
-
LP on CoW AMM: https://cow.fi/cow-amm
-
Swap on CoW Swap: www.swap.cow.fi
FAQs about MEV Bots
What is MEV and why does it matter in DeFi?
MEV (Maximal Extractable Value) refers to profits miners or validators can extract by manipulating transaction ordering. It creates significant risks for regular DeFi users through practices like front-running and sandwich attacks.
MEV matters because it can result in substantial financial losses for traders on decentralized exchanges. CoW Protocol developed solutions to protect users from these predatory practices.
How can DeFi users protect themselves from MEV attacks?
There are a few ways users can keep themselves safe:
-
Setting appropriate slippage tolerances helps prevent sandwich attacks when using traditional DEXs.
-
Avoiding trading during periods of high network congestion can reduce MEV exposure.
-
Educating yourself about MEV mechanics is an important step in protecting your trades.
-
Users should consider trading on protocols with built-in MEV protection like CoW Swap.
What is the main difference between an RPC endpoint and an intent-based trading solution?
An RPC endpoint like MEV Blocker protects transactions from MEV bots across the entire Ethereum network. Intent-based solutions like CoW Swap operate at the application level, using professional solvers to execute trades. These solvers take on MEV risk themselves, protecting users from direct price exploitation. Both solutions help users avoid MEV, but they work at different blockchain infrastructure levels.
What is a sandwich attack and how does it specifically exploit traders?
A sandwich attack occurs when MEV bots identify a pending trade and execute a transaction before it. The bot's trade drives up the asset price to the victim's slippage tolerance limit. After the victim's transaction executes and raises prices further, the bot sells immediately. This artificial pump-and-dump pattern extracts value directly from the trader without adding any market benefit.
How do MEV bots operate in the Ethereum ecosystem?
MEV bots continuously scan the blockchain's mempool for profitable opportunities to exploit. They often front-run transactions by paying higher gas fees to execute ahead of pending user trades. These automated systems can identify arbitrage opportunities within milliseconds. MEV bots are typically run by specialized teams with technical expertise and access to significant capital.
How does CoW Protocol protect users from MEV attacks?
CoW Protocol uses batch auctions to shield users from harmful MEV extraction. The system searches for "Coincidences of Wants" where users' trades can be matched directly. This peer-to-peer matching eliminates opportunities for MEV bots to front-run transactions. CoW Protocol's solver competition ensures users always receive optimal pricing when trading.
What makes CoW AMM different from traditional automated market makers?
CoW AMM is the first MEV-capturing AMM that redirects profits from pool rebalancing back to liquidity providers. Traditional AMMs subject liquidity providers to value extraction through loss-versus-rebalancing (LVR). With CoW AMM, solvers must bid to provide maximum surplus to the pool. This ensures the majority of MEV profits go to liquidity providers rather than bots.