DeFi Intel

What Is Front-Running in DeFi?

Plain-English explainer · Updated 2026-07-01 · By DeFi Intel

How it works

On most public blockchains, transactions sit in a mempool — a publicly visible waiting room — before a validator includes them in a block. Front-running bots continuously scan this queue for profitable pending actions: a large swap on a DEX, a popular NFT mint, an under-collateralized loan about to be liquidated. When a bot finds one, it submits its own transaction engineered to execute first, either by bidding a higher gas fee or by paying block builders directly through ordering markets like MEV-Boost.

The most common pattern is the sandwich attack. A bot sees your pending buy on an AMM, buys the same token first (pushing the pool price up), lets your trade execute at the worse price, then sells immediately after you for a near risk-free profit. Your slippage tolerance defines exactly how much the bot can extract — the looser the setting, the bigger the sandwich.

Front-running is a subset of MEV (maximal extractable value), and defenses exist at several layers. Private transaction relays such as Flashbots Protect and MEV Blocker keep your transaction out of the public mempool entirely. Batch-auction DEXs like CoW Swap settle all trades in a batch at one uniform clearing price, making reordering pointless. Tighter slippage settings cap the extractable amount, and some chains and rollups experiment with encrypted mempools or first-come-first-served ordering to shrink the attack surface.

Why it matters

Front-running is an invisible tax on nearly every DeFi user. Research groups such as EigenPhi and Flashbots have documented hundreds of millions of dollars extracted from traders through sandwich attacks on Ethereum alone, with individual victims sometimes losing double-digit percentages on a single swap. It degrades execution quality, punishes anyone who sets loose slippage, and has shaped core infrastructure design — from proposer-builder separation on Ethereum to encrypted-mempool research on newer chains. Understanding how it works is the difference between routing a trade safely through a private relay and unknowingly donating a slice of every swap to a bot.

Real-world examples

In April and May 2023, the sandwich bot run by the pseudonymous "jaredfromsubway.eth" became the single largest gas spender on Ethereum during the PEPE memecoin frenzy. The bot watched the mempool for memecoin buys on Uniswap, front-ran each one with its own purchase, and sold the moment the victim's trade landed. On-chain analysts, including EigenPhi, estimated it extracted millions of dollars from traders within weeks — sandwich front-running at industrial scale.

FAQ

Is front-running illegal in DeFi?

In traditional finance, front-running by a broker is illegal because it breaches a fiduciary duty to the client. In DeFi there is usually no such relationship — the mempool is public and anyone can read it — so it sits in a legal gray zone and is mostly treated as a protocol-design problem to engineer away, though regulators have begun scrutinizing the most predatory forms.

How do I protect my trades from front-running?

Send transactions through a private RPC endpoint such as Flashbots Protect or MEV Blocker so they skip the public mempool, set a tight slippage tolerance, split very large trades into smaller ones, or route through batch-auction venues like CoW Swap that settle everyone at a uniform price.

What is the difference between front-running and MEV?

MEV (maximal extractable value) is the umbrella term for all profit that can be captured by reordering, inserting, or censoring transactions within a block. Front-running is one MEV strategy; others include back-running, cross-DEX arbitrage, and liquidations — and some of those, like pure arbitrage, don't directly take money from an individual trader the way a sandwich attack does.

Related terms

Go deeper

Browse the complete crypto glossary to explore related terms and concepts.

Browse Glossary

Entities mentioned