In public blockchains, transactions are collected into blocks, and the miner or validator decides which ones to include and in what order. This very right to choose the sequence creates a loophole: specialized programs monitor pending transactions and earn money by placing their own trades in the right places within the block.
Such programs are usually called MEV bots (from Maximal Extractable Value). They extract profit from the network itself by influencing the order of transactions within a block. An ordinary user encounters them not directly, but through their consequences: unexpected price slippage during a trade on a DEX or increased gas fees.
Understanding MEV is useful for anyone trading through decentralized applications because it directly impacts the efficiency and fairness of a trade. The topic well illustrates how even the basic mechanics of a blockchain can be turned into a source of income by experienced participants.
KEY CONCEPTS
MEV bots are automated programs that maximize profit by playing on the transaction order in the blockchain. To make further analysis easier, let's agree on the terms.
Maximal Extractable Value (MEV): the profit a block producer receives by including, excluding, or reordering transactions within a block.
Transaction Pool (mempool): a "waiting room" for unconfirmed transactions until they are included in a block.
Block Producer: a miner or validator who assembles new blocks in a Proof-of-Work or Proof-of-Stake network.
Smart Contract: a self-executing contract with terms written directly into the code; MEV bots actively use them.
DEX (Decentralized Exchange): a platform where cryptocurrencies are traded directly from a wallet, without intermediaries.
Slippage: the difference between the expected trade price and the price at which it was actually executed, usually due to the price moving during execution.
Front-running: a bot notices another user's pending transaction and pushes its own transaction with a higher gas fee to get into the block earlier and profit from the price movement.
Back-running: a bot places its transaction immediately after a detected one to capture profit from its consequences.
HOW IT WORKS
An MEV bot continuously scans the mempool for profitable opportunities. As soon as it notices a large pending transaction (e.g., a big buy order on a DEX), it acts lightning-fast: it places its own buy order right before the other user's transaction and a sell order immediately after it.
This combination is called a sandwich attack. The bot's purchase slightly pushes the price up, and the user's large purchase pushes it even higher. Then, the bot sells at the higher price what it bought earlier and pockets the difference. The user's transaction ends up literally squeezed between the bot's two trades, hence the name.
To guarantee priority for its transactions with the block producer, bots often pay increased gas fees. This allows the entire scheme to be included in the same block as the victim's trade and extract maximum value from them. Profit is generated from the price shift created by these carefully placed trades.
EXAMPLES OF USE
To make it clearer, let's break down a sandwich attack with hypothetical numbers. A user wants to buy a token at a price of 100, sends a large order, and sees it in the mempool. The events then unfold as follows:
- The bot notices the order and buys the token first at 100, slightly raising the price to 101.
- The user's purchase executes, and the large volume pushes the price to 103.
- The bot immediately sells at 103 what it bought at 101, pocketing a profit of 2 per unit.
The user ultimately bought at a higher price than expected, and this is exactly the slippage they see in the trade report. Most often, people encounter this outcome on DEXs: they received fewer tokens than expected because the bot managed to execute a sandwich attack.
A second typical scenario is arbitrage. MEV bots instantly find price discrepancies between different DEXs or between trading pairs on the same platform and execute trades to capture this small difference before normal market activity smooths it out.
Gas fees also indirectly increase. Bots willing to pay higher fees for priority drive up the average gas prices for everyone in the mempool, which is particularly noticeable during periods of high network congestion.
To keep track of who profits from what, it's useful to summarize the two main tactics in a table.
| Tactic | What the Bot Does | Source of Profit |
|---|---|---|
| Sandwich Attack | Buys before a user's order and sells after it | Price shift created by the victim's large trade |
| Arbitrage | Exploits price discrepancies between DEXs or pairs | The difference in quotes before the market smooths it out |
FREQUENTLY ASKED QUESTIONS
MEV bots operate on many blockchains with a public mempool, including Ethereum. Their complexity and the amount of value extracted depend on network activity and the block production mechanism. The topic is not simple, but even understanding that MEV exists helps in anticipating potential slippage on DEXs.
Users cannot completely ban MEV bots because it is an inherent property of public blockchains. However, the consequences can be mitigated: use DEX aggregators that route trades more intelligently, trade during periods of low network activity, be mindful of potential slippage, and if necessary, break down large trades into smaller parts.
MEV appears to be an unfair advantage, but it also has a flip side: bots quickly close arbitrage discrepancies, thereby supporting market efficiency. Some blockchain research is aimed at making MEV more transparent or distributing its benefits more widely among network participants.