entekhab.netentekhab.nettrilingual encyclopedia

Sandwich Attack

ENGLISHSandwich Attackreference
فارسیحملهٔ ساندویچیEstablished equivalent
کوردیهێرشی ساندویچProposed equivalent — not standard
Category
Decentralised Finance
Level
Expert

Simple definition

A pending swap is spotted, and trades are placed immediately before and after it so that the user's swap executes at a worse price. The difference ends up with whoever arranged the order.

Professional definition

An extraction pattern in which a visible pending order is surrounded by two transactions in the same block, so the victim's trade fills at the worst price their acceptance bound allows and the surrounding position is closed for a profit at their expense.

Technical definition

It requires three conditions together: the order is visible before execution, someone can place transactions around it, and its acceptance bound is wide enough to leave surplus. Remove any one and the pattern stops paying. That is why defences are structural: a tighter bound shrinks the surplus to near zero, private routing removes the visibility, and batch or sealed-order designs remove the ability to interleave. The user's loss is capped by the bound they set.

Academic definition

An adversarial ordering strategy exploiting pre-execution visibility of an order together with discretion over intra-block sequencing, transferring to the sequencer the surplus permitted by the victim's execution bound.

Mechanism

The user's own acceptance bound creates the opportunity. A pool's price depends on its reserves, so a trade placed just before the victim's moves the price against them, and the victim's order still executes because it was authorised to accept that much. Nothing is broken and no key is compromised: the cost is the gap the user agreed to leave open, collected by whoever controls the order of the block.

In practice

Who uses it
Retail swappers in thin pools are the usual losers; routers, wallet providers and protocol designers are the parties who can reduce the exposure.
Why it matters
Understanding it is what turns the acceptance bound from a setting people widen to clear errors into the risk control it actually is.
Limitations
Defences are partial. A tight bound raises the failure rate and costs gas on reverts, and a private channel replaces public exposure with trust in the channel operator.

Common mistakes

  • Widening the acceptance bound until a transaction succeeds.
  • Sending a large order to a thin pool in one transaction.
  • Assuming a private channel removes the risk rather than relocating it.

Examples

numeric

A swap quoted at 10,000 output with a three percent bound can legally fill at 9,700, so up to 300 is available to a reordering. Reducing the bound to 0.3 percent reduces the same figure to 30.

Given
  • quoted output = 10,000
  • acceptance bound = 3%
  • alternative bound = 0.3%
Steps
  1. floor at 3% = 10,000 x 0.97 = 9,700, maximum give-up 300
  2. floor at 0.3% = 10,000 x 0.997 = 9,970, maximum give-up 30
  3. the exposure falls by a factor of ten with the bound
The bound the user sets is the ceiling on what this pattern can take.

An upper bound only. Whether anything is taken depends on pool depth, network fees and competition.

market

Two users send identical swaps in the same block, one with a half-percent bound and one with five percent. The first reverts and is resent; the second fills near its floor. The wider setting cost more than the failed attempt did.

Related terminology

parent
Maximal Extractable Value
related
Maximal Extractable Value Front-Running Slippage Tolerance Slippage Mempool Swap Liquidity Pool Constant Product Formula
Commonly confused with

Slippage

Slippage can be ordinary market movement between quote and execution. This pattern manufactures that movement deliberately and keeps the difference.

Sources

Final Report with Policy Recommendations for Decentralized Finance (DeFi)
IOSCO · recommendations on order handling, conflicts and market integrity
https://www.iosco.org/library/pubdocs/pdf/ioscopd754.pdf URL verified
DeFi risks and the decentralisation illusion
BIS Quarterly Review · 2021-12 · execution risks for users of on-chain trading venues
https://www.bis.org/publ/qtrpdf/r_qt2112b.pdf URL verified

Editorial status

Needs expert reviewconsensusv1.02026-11-05

Flagged by the editor as uncertain on a linguistic, mathematical or regulatory point.

Written from the harmed user's perspective: the entry explains the three conditions that must hold and the structural defences, and gives no operational detail on constructing such a pattern. The numbers are upper bounds implied by the user's own setting, not observed losses. Kurdish headword is this project's proposal and needs native-expert review.