Crypto
4 min read

Front-Running

Placing a transaction ahead of a known, pending transaction to profit from the price impact it will cause. On public blockchains, bots scan the mempool for opportunities — a key form of MEV.

How front-running works on chains

Most blockchains have a public mempool — pending transactions visible to anyone before they're included in blocks. Searchers and bots monitor the mempool for valuable opportunities:

  1. A user submits a swap on Uniswap, planning to buy 1,000 ETH at the current price.
  2. A bot sees this transaction in the mempool and notices the trade will move the price.
  3. The bot submits its own transaction with a higher gas price, ensuring it gets included first.
  4. The bot's transaction buys ETH first, pushing the price up.
  5. The user's transaction executes at the new (higher) price.
  6. The bot can then sell ETH back at the higher price the user just paid, capturing the difference.

This is the basic sandwich attack pattern — a specific form of front-running that includes both the front-run and the back-run.

In traditional finance

Front-running has long been a regulated offense in traditional markets:

  • A broker who knows a client is about to place a large order trades for their own account first, profiting from the client's market impact.
  • Regulators (SEC, FINRA) have brought numerous enforcement actions against brokers, market makers, and traders for various forms of front-running.
  • The practice is illegal in most jurisdictions when it involves specific fiduciary duties or material non-public information.

The crypto on-chain version is different in important ways:

  • The information isn't private — anyone watching the mempool can see the pending order.
  • The "front-runners" don't have fiduciary duty to the affected user.
  • The activity isn't illegal under existing securities or trading laws (in most jurisdictions).

This is why on-chain front-running is described as "MEV" (Maximal Extractable Value) rather than as illegal trading.

How it costs users

Front-running and sandwich attacks impose real costs on regular users. For example:

  • A user trying to buy $10,000 of a less-liquid token might pay $100-500 more than they should because of sandwich attacks.
  • Aggregate annual MEV extraction on Ethereum has been estimated in the hundreds of millions to billions of dollars.

Most affected users don't realize they're being sandwiched — they see "slippage" in their trade and assume that's normal market impact. In reality, much of that slippage is value being extracted by bots.

Defenses

Several mechanisms reduce front-running exposure:

  • Slippage protection. Users can set maximum slippage on their swaps. If price moves more than the threshold, the trade reverts. Setting tight slippage limits reduces sandwich profitability.
  • Private mempools. Services like Flashbots Protect, MEV Blocker, or CowSwap submit transactions through private channels that bots can't see in the mempool.
  • Batched and ordered execution. Order-flow auctions where solvers compete to fill trades atomically, removing front-running incentives.
  • Trade aggregators. Tools that split trades across multiple venues and use private routing reduce sandwich exposure.

For active DeFi users, using a private RPC (like Flashbots Protect) for trades on liquid tokens is a meaningful protection.

Searcher economics

The bots running these strategies are "searchers." They:

  • Monitor mempools for opportunities.
  • Calculate expected profit from various MEV strategies.
  • Submit competing transactions, often offering a portion of expected profit as priority fee to ensure inclusion.
  • Compete with other searchers for the same opportunities.

Searcher revenue is significant — leading searchers extract millions of dollars per month. The competition is intense; only the fastest, most sophisticated operations capture sustained profit.

Order flow and the broader supply chain

Front-running is part of a broader "order flow" supply chain:

  • Users submit transactions.
  • Searchers look for MEV opportunities.
  • Builders assemble blocks combining user transactions and searcher bundles.
  • Validators/proposers select which builder's block to propose.

Each layer captures some economic value. Order-flow services (PBS, MEV-Boost, etc.) have professionalized this process, creating revenue streams at each layer.

The result: MEV doesn't just disappear when users defend themselves with private mempools. It gets redirected — sometimes to validators, sometimes to builders, sometimes to users themselves through rebates.

Where front-running matters most

The biggest victims of front-running are:

  • Large swap users on AMMs — bigger trades have bigger price impact, more sandwich profit potential.
  • Less-liquid tokens — thin liquidity means even modest trades can be profitably sandwiched.
  • Time-sensitive arbitrage — bots compete to capture arbitrage spreads, with users sometimes losing to faster bots.
  • NFT mints — front-running mint transactions during popular drops.

For typical small swaps on highly-liquid pairs, sandwich attack risk is minimal. The economics don't work for bots on small trades.

Where this is heading

Active research and infrastructure development aim to reduce or fairly redistribute MEV:

  • Encrypted mempools — proposals to encrypt pending transactions so they're invisible to searchers until inclusion.
  • Order-flow auctions — solvers compete to fill user trades, returning surplus to users.
  • MEV-aware DEX designs — Uniswap V4 hooks enable custom logic that can capture or refund MEV.
  • Validator rebates — some validators share captured MEV with their delegators.

The honest picture: front-running on public chains is unlikely to disappear, but its share of user costs has been declining as defenses and infrastructure mature. For active users, defending against it is part of operational hygiene.