CCamoCrypt camocrypt.com
DeFi Explained

What Is MEV and Front-Running?

Whoever orders transactions in a block can extract value from them. Here is how MEV, front-running, and sandwich attacks work, and how to defend yourself.

Quick answer

MEV (maximal extractable value) is the profit a block producer can make by choosing which transactions to include and in what order, beyond normal rewards and fees. Benign forms include arbitrage and liquidations; harmful forms are front-running and sandwich attacks, where bots exploit your pending trade in the public mempool. You limit the harmful kind with tight slippage tolerance and private transaction routing.

Key points

  • MEV is value extracted by including, excluding, or reordering transactions in a block.
  • Independent 'searchers' scan the public mempool for profitable opportunities.
  • Arbitrage and liquidations are largely benign; front-running and sandwich attacks harm users.
  • A sandwich attack front-runs and back-runs your DEX swap to worsen your price.
  • Proposer-builder separation and MEV-Boost restructure who captures MEV, but don't stop sandwiching by themselves.
  • Tight slippage and private transaction routing are the main user defences.

Maximal extractable value (MEV) is the value someone building a block can capture by controlling which transactions go in and in what order, beyond the normal block reward and gas fees. Ethereum.org defines it as “the maximum value that can be extracted from block production in excess of the standard block reward and gas fees by including, excluding, and changing the order of transactions in a block.” Some MEV is harmless or even useful; some, especially front-running, comes directly out of ordinary users’ pockets. This explainer covers how it works and why it matters for your safety.

Where MEV comes from

Because transactions settle in discrete blocks and their order is chosen by the block’s producer, ordering itself has monetary value. On many DeFi protocols the outcome of a transaction depends on the state at the exact moment it runs, so reordering, inserting, or dropping transactions can be turned into profit. The term began as “miner extractable value” under proof of work; since Ethereum moved to proof of stake, validators occupy that role, which is why the “maximal” framing is now standard. If you are new to that consensus shift, our overview of proof of work vs proof of stake gives the background.

Searchers, the mempool, and ordering

Most MEV is hunted by independent participants called searchers. Ethereum.org describes them as network participants who “run complex algorithms on blockchain data to detect profitable MEV opportunities and have bots to automatically submit those profitable transactions to the network.” Their raw material is the mempool, the public waiting area where pending transactions sit before confirmation. Anyone can watch it, so a searcher can see your trade coming and try to position their own transactions around it, competing by bidding higher fees or paying builders to place their transactions favourably.

The main forms of MEV

DEX arbitrage (mostly benign)

The simplest opportunity is arbitrage: if a token is cheaper on one exchange than another, a searcher buys low and sells high in a single atomic transaction. Ethereum.org calls this essentially “riskless arbitrage.” It does not harm the user who created the price gap and it helps keep prices aligned across venues.

Liquidations (structural)

On lending protocols, when a borrower’s collateral falls below the required threshold, anyone can liquidate the position and collect a fee. Searchers compete to be first. This is part of how lending markets stay solvent, though the competition is fierce.

Front-running and sandwich attacks (harmful)

This is the predatory category. In front-running, a searcher sees your profitable pending transaction and places their own ahead of it, by paying more, to capture the value first. Ethereum.org notes that generalised front-runners even “copy the potentially profitable transaction’s code, replace addresses with the frontrunner’s address” to steal the opportunity outright.

The sandwich attack is the version that hits ordinary swappers. A bot spots a large pending DEX trade, buys just before it to push the price up (the front-run), lets your trade execute at the worse price, then sells right after (the back-run) to profit. You receive a worse rate; the bot pockets the difference. This is tightly connected to your swap settings, which is why understanding slippage in DeFi is the single most practical defence: the attack can only extract value up to the slippage tolerance you allowed.

How MEV is organised today: PBS and MEV-Boost

Rather than leaving every validator to optimise ordering themselves, much of Ethereum’s MEV now flows through proposer-builder separation (PBS). Ethereum.org describes PBS as separating roles so specialised block builders handle transaction ordering while validators simply propose the block, reducing validators’ direct MEV incentives.

Flashbots’ MEV-Boost is the widely used implementation. Per Flashbots’ documentation, it is “open source middleware run by validators to access a competitive block-building market.” In this design, searchers send bundles to builders, builders assemble blocks and bid for the right to have a validator propose them, and relays act as a trusted intermediary passing blocks between builders and validators. The stated goal is to promote “greater competition, decentralization, and censorship-resistance.” Note what this does and does not fix: it changes who captures MEV and how, but it does not by itself stop a sandwich bot from targeting an unprotected public trade.

Why MEV matters to you

  • It is a hidden cost. Front-running and sandwiching quietly worsen the price you get, often without any obvious error.
  • It can affect fairness and trust. Ethereum.org notes that MEV practices such as front-running “pose security and fairness issues, potentially leading to financial losses and a loss of trust.”
  • It has centralisation implications. Because MEV boosts validator income, it can push solo stakers toward large pools with better optimisation, a concern for network decentralisation.

How to protect yourself

You cannot abolish MEV, but you can avoid being an easy target for its harmful forms.

  • Set a tight slippage tolerance. This caps the maximum a sandwich attack can extract, because a larger price move reverts your trade.
  • Use private transaction routing. Services like Flashbots Protect send your transaction to a private mempool “hidden from frontrunning and sandwich bots,” removing the public visibility the attack depends on.
  • Prefer deep liquidity. Large trades in thin pools create the price movement bots exploit; deeper pools and split orders reduce it.
  • Be cautious with large, obvious swaps. A big transaction broadcast to the public mempool is exactly what searchers scan for.

The balanced view

MEV is a structural feature of public, ordered blockchains, not a bug that a single patch removes. Some of it, arbitrage and liquidations, performs a real market function. The predatory slice, front-running and sandwiching, is what you actually need to defend against, and the defences are concrete: tight slippage, private routing, and sensible trade sizing. Understanding that transaction ordering itself is valuable, and that the mempool is a public stage, changes how you approach every on-chain trade. For the mechanics of how a trade’s price can shift before it settles, revisit slippage in DeFi, and to see where your transaction waits and is watched, read about the mempool.

The three positions: front-run, back-run, and the sandwich

It helps to name the ordering plays precisely, because they are not all equally harmful.

Play Where the bot’s transaction sits Effect on you
Front-run Immediately before your transaction Captures an opportunity or moves price against you before you execute
Back-run Immediately after your transaction Often harmless; e.g. arbitrage that realigns price after your trade
Sandwich Both before and after your transaction Directly worsens your fill and profits from the induced price move

Back-running alone is frequently benign, an arbitrageur tidying up a price gap you left. The sandwich is the combination that specifically targets your swap, which is why capping the price movement you tolerate is such an effective defence.

The economics that drive it

Searchers do not act out of malice; they respond to incentives. When a searcher spots an opportunity, they compete with other bots to have their transaction ordered favourably, historically by bidding up gas, and increasingly by paying block builders directly through systems like MEV-Boost. This competition can escalate into “priority gas auctions,” where rival bots repeatedly outbid one another, and it is one reason MEV activity can spike network fees for everyone. It also concentrates sophistication: extracting MEV profitably requires fast infrastructure and capital, which is part of why researchers worry about its centralising pressure on validators, as noted above. Because a transaction’s fate now often depends on builders and relays rather than a simple first-come queue, understanding how a transaction gets confirmed makes the modern pipeline clearer.

What redesigns can and cannot fix

A great deal of research aims to reduce harmful MEV: private mempools and encrypted transactions hide your intent until it is too late to sandwich; batch auctions settle many trades at one uniform price so ordering within the batch stops mattering; and MEV-redistribution schemes try to return some captured value to users. Each helps, but none is a complete cure, and some shift trust to new intermediaries such as relays. The realistic stance for a user is to assume the public mempool is adversarial and to use the concrete protections available today, rather than waiting for a protocol-level fix that fully eliminates the problem.

A note on Layer 2s and other chains

MEV is not unique to Ethereum mainnet. Any blockchain whose block producer controls ordering has some form of it, and the details shift with the architecture. Many Layer 2 rollups currently rely on a single “sequencer” that orders transactions, which changes the shape of the risk: there may be no public mempool for bots to scan, but users must instead trust the sequencer not to abuse its ordering power. As these networks decentralise their sequencing, the familiar mempool-based dynamics can reappear. The practical point is that “which chain am I on?” affects both your exposure and which protections are available, so do not assume a habit that protects you on one network transfers unchanged to another. What stays constant is the underlying truth: wherever someone chooses transaction order, that choice has value, and part of a careful user’s job is to avoid handing it away cheaply.

Sources

Frequently asked questions

What does MEV stand for?
Maximal extractable value. It refers to value that can be extracted from block production beyond the standard block reward and gas fees by controlling which transactions are included and how they are ordered.
Is all MEV bad?
No. Arbitrage that aligns prices across exchanges and liquidations that keep lending markets solvent are largely benign or useful. Front-running and sandwich attacks are the predatory forms that cost ordinary users.
What is a sandwich attack?
A bot buys just before your DEX trade to push the price up, lets your trade execute at the worse price, then sells immediately after to profit. Your trade is 'sandwiched' between the bot's two transactions.
How is MEV possible after Ethereum moved to proof of stake?
MEV comes from the ability to order transactions, which still exists under proof of stake. Validators now play the role miners once did, and much MEV flows through proposer-builder separation and MEV-Boost.
Does MEV-Boost stop front-running?
Not directly. MEV-Boost restructures how blocks are built and who captures MEV for competition and censorship-resistance, but protecting an individual trade still requires tight slippage or private routing.
How do I protect my trades from front-running?
Set a tight slippage tolerance so an attack reverts if it moves the price too far, route trades through a private mempool such as Flashbots Protect, and prefer deep liquidity with sensible trade sizes.

Note: CamoCrypt is security & education only — no prices, no predictions, no investment advice. Verify every address and contract yourself; we cannot recover lost funds and neither can anyone who contacts you claiming they can.