# Sandwich attacks: trading around someone else’s swap

A sandwich attack places transactions before and after a target swap to exploit how that swap changes pool prices. The target can receive a worse execution while still meeting a permissive minimum-output condition. Tighter enforced limits and suitable private or order-based routes can reduce exposure, but no single setting guarantees protection from every form of MEV.

Evidence: [Maximal extractable value](https://ethereum.org/en/developers/docs/mev/); [Uniswap v2 whitepaper](https://app.uniswap.org/whitepaper.pdf); [Flashbots Protect overview](https://docs.flashbots.net/flashbots-protect/overview)

Canonical: https://degreesofsatoshi.com/encyclopedia/sandwich-attacks/
Published: 2026-10-02
Substantively modified: 2026-10-02
Independently verified by an automated reviewer: 2026-10-02T18:15:18.493Z
Data current through: 2026-10-02

AI-assisted research and drafting with a separate automated source-verification pass; no external expert or named human review is implied.

## Key facts

- **Ordering:** The attack depends on arranging activity around the target transaction. ([Maximal extractable value](https://ethereum.org/en/developers/docs/mev/))
- **Price effect:** AMM reserve changes affect the next execution price. ([Uniswap v2 whitepaper](https://app.uniswap.org/whitepaper.pdf))
- **Limit:** A minimum output constrains accepted execution, not the initial quote itself. ([UniswapX overview](https://docs.uniswap.org/contracts/uniswapx/overview))

## Follow the change in the pool’s state

A transaction placed before the target moves the pool price against the target’s direction. The target then trades at the changed state. A later transaction can unwind the attacker’s position after the target’s price movement.

Whether the sequence is profitable depends on liquidity, fees, trade size and ordering. The explanation is a risk model, not a claim that every poor swap was sandwiched.

Evidence: [Maximal extractable value](https://ethereum.org/en/developers/docs/mev/); [Uniswap v2 whitepaper](https://app.uniswap.org/whitepaper.pdf)

## A loose limit can permit a worse fill

If the signed operation allows a broad range of acceptable outcomes, the target may execute at the unfavorable end of that range. Reducing the permitted range can instead cause execution to fail when conditions move too far.

Changing tolerance does not improve the pool’s current quote or remove ordinary price impact from a large trade.

Evidence: [UniswapX overview](https://docs.uniswap.org/contracts/uniswapx/overview)

## Reduce visibility with explicit trust assumptions

Private submission services aim to keep transactions out of the public mempool and offer particular inclusion policies. Their operators and downstream participants still form part of the execution path.

Understand routing, fallback and disclosure behavior. A private route is a mechanism with a scope, not a guarantee that every economically unfavorable ordering is impossible.

Evidence: [Flashbots Protect overview](https://docs.flashbots.net/flashbots-protect/overview); [Maximal extractable value](https://ethereum.org/en/developers/docs/mev/)

## Questions

### Is every change between quoted and executed output a sandwich attack?

No. Ordinary intervening trades, price movement, routing and quote age can also change the result. Establish the actual ordering and state changes before attributing an attack.

Evidence: [Maximal extractable value](https://ethereum.org/en/developers/docs/mev/); [Uniswap v2 whitepaper](https://app.uniswap.org/whitepaper.pdf)

## Claims and scope

### sandwich-attacks-quick-answer

A sandwich attack places transactions before and after a target swap to exploit how that swap changes pool prices. The target can receive a worse execution while still meeting a permissive minimum-output condition. Tighter enforced limits and suitable private or order-based routes can reduce exposure, but no single setting guarantees protection from every form of MEV.

Scope: {"collection":"defi","dataAsOf":"2026-10-02","blockHeight":null}

### sandwich-attacks-fact-ordering

Ordering: The attack depends on arranging activity around the target transaction.

Scope: {"collection":"defi","dataAsOf":"2026-10-02","blockHeight":null}

### sandwich-attacks-fact-price-effect

Price effect: AMM reserve changes affect the next execution price.

Scope: {"collection":"defi","dataAsOf":"2026-10-02","blockHeight":null}

### sandwich-attacks-fact-limit

Limit: A minimum output constrains accepted execution, not the initial quote itself.

Scope: {"collection":"defi","dataAsOf":"2026-10-02","blockHeight":null}

## Sources

- [Maximal extractable value](https://ethereum.org/en/developers/docs/mev/) — ethereum.org contributors. Ordering-dependent extraction and limits of private submission. Locator: Sandwich trading; MEV protection. Retrieved: 2026-10-02T17:03:45.625Z.
- [Uniswap v2 whitepaper](https://app.uniswap.org/whitepaper.pdf) — Uniswap. Full-range constant-product inventory and cumulative-price oracle design. Locator: Price oracle; Liquidity; Fees. Retrieved: 2026-10-02T17:03:45.008Z.
- [Flashbots Protect overview](https://docs.flashbots.net/flashbots-protect/overview) — Flashbots. Private submission changes who receives a transaction and depends on relay and builder behavior. Locator: MEV protection; Privacy; How it works. Retrieved: 2026-10-02T17:03:45.401Z.
- [UniswapX overview](https://docs.uniswap.org/contracts/uniswapx/overview) — Uniswap. Signed order execution through fillers; execution conditions are mechanism-specific. Locator: Signed orders; Fillers; Dutch auctions. Retrieved: 2026-10-02T17:21:47.712Z.

## Revision history

- 2026-10-02: First publication after primary-source research and independent automated verification.

## Cite this entry

Degrees of Satoshi editorial project. “Sandwich attacks: trading around someone else’s swap.” Published 2026-10-02; updated 2026-10-02. https://degreesofsatoshi.com/encyclopedia/sandwich-attacks/
