What Is MEV and How Does It Work in Blockchain Networks?

What Is MEV and How Does It Work in Blockchain Networks?

What is MEV in crypto?

MEV stands for maximal extractable value. It refers to the extra profit that can come from the order in which transactions are processed in a block.

That order matters because transactions can affect each other. For example, a large buy or sell on a DEX can change the price of a token. A transaction that gets executed before that price change can therefore get a different price than a transaction that happens after it.

If someone manages to get their own transaction into a favorable spot in that order, they can sometimes profit from that price difference. For example, by buying tokens right before a large buy and then selling them again at a higher price afterward. The extra profit that comes from that can be part of MEV.

This plays a major role within DeFi. Say someone makes a large swap on a DEX. That transaction can change the price in a liquidity pool. If another party sees this coming and gets their own transaction executed right before or after that swap, they can sometimes profit from the price change. The profit that comes from this can be part of MEV.

The term MEV originally meant ''miner extractable value.'' That was because miners on proof-of-work blockchains created blocks and had influence over which transactions went into them and in what order.

Since Ethereum switched to proof-of-stake, validators have played an important role in adding new blocks. That's why people usually talk about ''maximal extractable value'' today. MEV is not only relevant for miners and can also happen on other types of blockchains.

MEV can arise in different ways, and its effect depends on the situation. In arbitrage, for example, traders try to take advantage of price differences between different DEXes. That can bring prices on those trading platforms closer together again. Liquidations within lending protocols can also create MEV. Those liquidations are needed to prevent loans from becoming undercollateralized.

Other forms of MEV can actually be harmful to users. A well-known example is a sandwich trade. In that setup, a trader sees that a user wants to make a swap and places their own transaction right before it. That can already move the price. After the user's swap goes through, the trader places another transaction to profit from that price change. The original user can end up getting a worse price.


Key Takeaways

  • MEV is extra value that comes from selecting or ordering transactions smartly in a block.
  • The term is not just about miners, but also about validators and other block producers.
  • MEV often shows up around DeFi swaps, price differences, and liquidations.
  • Arbitrage and liquidations can be useful for how DeFi works.
  • Sandwich MEV can cause a user to get more slippage and a worse execution.

How does MEV work?

MEV happens because the order of transactions can affect the price someone gets or the outcome of a transaction.

You can see that, for example, with an AMM. An AMM is a system that automatically sets the price of tokens in a DEX pool based on the ratio between the tokens in that pool. If someone makes a large swap, that ratio changes. As a result, the price can change right away too.

Say a token costs $10 on DEX A and $10.50 on DEX B. A trader can then try to buy the token for $10 on DEX A first and then sell it for $10.50 on DEX B. If those transactions are executed fast enough and in the right order, that can create profit.

To find these opportunities, so-called searchers often use specialized bots. Those bots constantly monitor on-chain data and often also look at the public mempool. You can think of the mempool as a kind of waiting room for transactions that have already been sent but have not yet been included in a block.

If a bot spots an opportunity, it creates one or more transactions. Sometimes multiple transactions are bundled together in a bundle. That's a package of transactions that has to be executed in a certain order. The bot then tries to make sure those transactions end up in the desired spot in the block.

On Ethereum, it works roughly like this:

  1. A searcher finds an opportunity A bot sees, for example, that the same token is being traded at different prices on two DEXes.

  2. The bot creates a transaction or bundle For example, the bot gives the order to buy first on the cheap DEX and then immediately sell on the more expensive DEX.

  3. A builder assembles a possible block A builder is a specialized party that collects transactions and bundles and tries to turn them into a block that generates as much revenue as possible.

  4. The validator proposes the block The validator, also called the proposer, usually chooses from different block proposals. Builders can bid for that. In this way, part of the MEV revenue can eventually go to the validator, without that validator having to look for arbitrage opportunities themselves.

There are often multiple bots seeing the same opportunity. That creates competition. For example, bots may pay more to get their transactions into a favorable spot in the block. As a result, part of the possible profit goes to builders and validators.

With a public mempool, other bots can see which transactions are still waiting to be processed. That lets them try to act on them. With private submission, a transaction is less visible to other parties before it gets into a block.

The exact process differs by blockchain and Layer 2. The example above mainly describes how MEV often works within Ethereum and other EVM-based DeFi networks.

What forms of MEV exist in crypto?

Well-known forms of MEV are DEX arbitrage, sandwich trading, and liquidations. Those are important examples, but definitely not the only ones. There is also generalized frontrunning, where a bot copies a visible transaction and tries to execute it first. MEV opportunities can also arise around NFT mints and mispriced listings.

The boundaries are not always crystal clear. One transaction can have multiple economic effects. Still, the three forms below are the easiest way to understand how MEV works in practice.

What is arbitrage MEV?

Arbitrage MEV is making money from a price difference for the same token on different DEXes or liquidity pools. If a token is cheaper in pool A than in pool B, a bot can buy it in A and sell it in B almost immediately.

That can often happen in one atomic transaction. Atomic here means: all steps succeed together, or everything gets rolled back. If the sale does not go through as planned, the purchase does not happen either.

Example: Say a token costs 100 euros on DEX A and 102 euros on DEX B. A searcher can buy the token on A and sell it right away on B. That trade usually brings the price on both sides a little closer together again.

That is useful for the crypto market, because price differences do not stay around longer than necessary. The profit usually does not go to the user whose swap caused the price difference. It usually goes to the searcher and, through bidding, partly to the block producer.

Arbitrage is very competitive. Multiple bots often see the same mismatch and all try to get into a block first. An atomic transaction does make the result technically all or nothing, but there are still risks before inclusion. Think of transaction fees, competition, and the risk that another bot gets there first.

What is sandwich MEV?

Sandwich MEV is a strategy where a bot literally places a user's DEX swap between two of its own transactions. The bot buys first, then lets your swap go through, and then sells again.

This usually happens when a bot sees a large swap in the public mempool that could have a lot of price impact. Price impact is the price change caused by your own order because a pool does not have infinite liquidity.

The bot places a buy right before your swap. That already pushes the price up. Your swap then executes at a less favorable price, after which the bot sells after your swap at the higher price.

For you, that usually means extra slippage. Slippage is the difference between the price you expected and the price you actually get. Keep in mind: not every bad execution is sandwiching. A large swap in a shallow pool already has price impact on its own. Sandwich MEV is the extra damage caused by a bot stepping in between.

So a sandwich includes one transaction before and one transaction after your swap. A transaction that simply goes before someone else's is not automatically a sandwich. Unlike the DEX arbitrage described earlier, this strategy depends on the user's order in the middle.

What is liquidation MEV?

Liquidation MEV happens when bots compete to liquidate a lending position that is no longer safe enough. In DeFi, you can borrow crypto by locking up other crypto as collateral. If the value of that collateral drops too far, someone is allowed to liquidate the position according to the protocol rules.

On Aave, a position becomes liquidatable once the health factor drops below 1. The health factor is a number that shows how safe your loan still is. If it falls below 1, a liquidator can repay part of the debt and receive collateral in return with a liquidation bonus.

That bonus is why bots want to be first as quickly as possible. They track positions, oracle prices, and the protocol rules. An oracle provides price data to smart contracts. As soon as a position becomes liquidatable, the fastest bot tries to submit a valid liquidation transaction.

The race to get that bonus first is the MEV part. At the same time, a fast liquidation can be useful: it helps keep the lending protocol better protected against debts with too little collateral, which is also important for people lending crypto.

What role do validators, miners, and bots play in MEV?

Bots look for opportunities, builders turn them into attractive blocks, and validators ultimately choose which block gets proposed. In proof-of-work on, for example, Bitcoin, miners do the selecting and ordering of transactions. On modern Ethereum, validators are the block proposers.

Searchers are independent market participants who try to find MEV opportunities. They run bots that analyze data extremely fast, create transactions, and can send bundles to builders. So a searcher does not have to be a validator.

Builders collect regular transactions and bundles and use them to assemble a possible block. In doing so, they try to build a block that generates as much value as possible.

There can be relays between builders and validators. These pass builder bids on to validators. A validator can then choose an attractive bid and propose the associated block. That lets a validator receive part of the revenue without having to look for MEV opportunities themselves.

That is efficient, but it also has a downside. Good MEV optimization requires fast infrastructure, specialized software, and a lot of knowledge. Bigger professional parties can therefore get an advantage. That can increase the pressure to concentrate block building and validation among fewer parties.

What effects does MEV have on crypto users?

MEV can have both useful and annoying effects for crypto users. The clearest negative example is sandwich MEV: your swap can end up being executed at a worse price than it would have without the bot transactions.

The competition between bots can also raise transaction fees and cause network congestion. If many bots all want priority at the same time, they will pay more to get into the next block.

There are also positive sides:

  • Arbitrage helps prices on different DEXes line up better again.
  • Liquidations can prevent undercollateralized loans from piling up in DeFi protocols.
  • Bids for blocks can shift part of the MEV value to validators.

At the blockchain level, extremely high MEV can create a tougher risk. If the value in an earlier block is unusually large, there can be an incentive to reorganize blocks and try to capture that value anyway. That is a risk to consensus stability, not something that happens with every normal MEV transaction.

The main thing for you as a user: do not just look at the price you see on the screen. With a swap, liquidity, price impact, slippage, and the way your transaction is sent all matter too.

How can users and protocols protect themselves against MEV?

You cannot fully eliminate MEV, but you can reduce the chance of damage. Especially with larger swaps and lending positions, it is smart to check a few settings ahead of time.

  1. Set an appropriate maximum slippage A maximum slippage setting determines how much worse the execution is allowed to be at most. If the price gets worse than your limit, the swap fails instead of you accepting a much worse price. If you set the limit too wide, you give bots more room. If you set it extremely tight, your transaction may fail more often. With a revert like that, you may still lose network fees.

  2. Use a short transaction deadline A deadline is the latest time your swap is still allowed to be executed. With a short deadline, you prevent an old transaction from sitting around for a long time and only getting executed after the price has changed a lot.

  3. Pay attention to the size of your swap and the liquidity Large swaps in pools with low liquidity usually have more price impact. That can also create more room for certain MEV strategies. So before making a swap, check how much price impact is expected and what price you are likely to receive.

  4. Consider private submission where it is available A private transaction is not visible in the same way in the public mempool. That can offer protection against certain bots that try to get ahead of public transactions. It is not complete protection: you do rely on the chosen infrastructure, and you are not automatically protected against a bad market price or all forms of MEV.

  5. Keep enough distance from the liquidation threshold If you have borrowed crypto in DeFi, make sure your health factor stays well above 1. How much room is wise depends, among other things, on the volatility of your collateral and borrowed assets. You can raise your health factor by, for example, adding more collateral or repaying part of your debt. That lowers the chance that your position becomes liquidatable.

Ethereum currently already uses a form of proposer-builder separation (PBS), where specialized builders assemble blocks and validators propose them. This happens mostly through software and infrastructure outside the Ethereum protocol.

Ethereum is also working on enshrined proposer-builder separation (ePBS). With that, this separation between builders and validators becomes part of the protocol itself. One goal is to become less dependent on external relays and other intermediaries.

Techniques such as encrypted transactions are also being explored to make certain forms of harmful MEV harder. But those solutions do not make MEV disappear completely. As long as the order of transactions can have economic value, there will still be ways to profit from it.

Conclusion

MEV is the extra value that can arise because transactions within a block do not all have the same outcome in every possible order. In crypto, you mainly see that around DeFi swaps, arbitrage, and liquidations.

Not all MEV is bad. Arbitrage can correct prices, and liquidations help keep lending protocols healthy. Sandwich MEV, on the other hand, is a clear downside for users because that strategy can give your swap a worse execution.

If you use DeFi, it is smart to pay close attention to slippage, deadlines, liquidity, and the health of any lending positions. That will not always prevent MEV, but it does reduce the chance that a bot gets unnecessary advantage from your transaction.

About Finst

Finst is a leading cryptocurrency platform in the Netherlands, providing ultra-low trading fees, institutional-grade security, and a comprehensive suite of crypto services such as trading, custody, staking, and fiat on/off-ramp. Finst, founded by DEGIRO's ex-core team, is authorized as a crypto-asset service provider under MiCAR by the Dutch Authority for Financial Markets (AFM) and serves both retail and institutional clients in 30 European countries.

The crypto platform for all investors

Whether you're an active trader or long-term investor, Finst enables you to grow your crypto wealth with confidence and peace of mind.

Sign up