Wiki/Sandwich Attacks: A Comprehensive Guide
Sandwich Attacks: A Comprehensive Guide - Biturai Wiki Knowledge
INTERMEDIATE | BITURAI KNOWLEDGE

Sandwich Attacks: A Comprehensive Guide

Sandwich attacks are a form of market manipulation on decentralized exchanges, where attackers profit by exploiting the predictable price impact of large trades. This guide explains how these attacks work, their risks, and how to spot them.

Biturai Intelligence Logo
Michael Steinbach
Biturai Intelligence
|
Updated: 2/2/2026

Definition

Imagine you're buying a large amount of a cryptocurrency on a decentralized exchange (DEX). Your trade, because it's public on the blockchain, is visible to everyone. A malicious actor, knowing this, can use this information to their advantage. This is the core concept behind a sandwich attack: the attacker places two trades, one before and one after your trade, to profit from your transaction.

Key Takeaway

A sandwich attack is a form of market manipulation where an attacker profits by front-running and back-running a victim's large trade on a DEX.

Mechanics

Let's break down how a sandwich attack works step-by-step:

  1. Victim's Trade is Detected: The attacker monitors the mempool (a holding area for pending transactions) or uses other methods to identify a large pending trade. This trade, if executed, will likely move the market price significantly.

  2. Front-Running Order (The 'Sandwich' Bread): The attacker submits a buy order for the same asset before the victim's trade is executed. This drives up the price slightly. This is the first slice of bread in the sandwich.

  3. Victim's Trade Executes: The victim's large buy order goes through, further increasing the asset's price. This is the filling of the sandwich.

  4. Back-Running Order (The 'Sandwich' Bread): Immediately after the victim's trade, the attacker submits a sell order for the asset they bought earlier. They sell at a higher price than they bought, profiting from the price movement caused by the victim's trade. This is the second slice of bread.

  5. Profit and Slippage: The attacker profits from the difference between the buy and sell prices. They also benefit from any slippage the victim experiences due to the large trade. Slippage is the difference between the expected price and the actual price when a trade is executed.

Slippage: The difference between the expected price of a trade and the price at which the trade is executed.

Example: Imagine Alice wants to buy 100 ETH on a DEX. An attacker, Bob, sees Alice's pending transaction.

  • Bob's First Trade: Bob buys 1 ETH at $3,000.
  • Alice's Trade: Alice buys 100 ETH, driving the price up to $3,050 due to the size of her trade.
  • Bob's Second Trade: Bob immediately sells his 1 ETH at $3,050.

Bob profits $50 (3050 - 3000 = 50) minus transaction fees. Alice, meanwhile, paid a slightly higher price than she would have if Bob hadn't front-run her, and she might have experienced slippage.

Trading Relevance

Sandwich attacks are directly relevant to trading on DEXs. They highlight the importance of understanding market dynamics, especially on platforms with transparent order books and public mempools. Traders must be aware that their large trades can be targeted. The price impact of a trade is key.

  • Slippage Awareness: When trading, be mindful of slippage. Large trades, especially on DEXs with low liquidity, are susceptible to price manipulation from sandwich attacks.
  • Order Size: Consider breaking up large orders into smaller trades to reduce the impact on the price and minimize the risk of being sandwiched. This can reduce the profitability of the attack.
  • Gas Fee Analysis: Attackers often use higher gas fees to ensure their transactions are prioritized by miners, giving them an advantage. This can be an indicator of potential attacks.
  • Transaction Monitoring Tools: There are tools available that can help you monitor transactions and identify potential sandwich attacks in real-time. These tools analyze the mempool and look for suspicious trading patterns.

Risks

Sandwich attacks pose several risks to traders:

  • Financial Loss: Victims of sandwich attacks lose money due to slippage and the manipulated price.
  • Increased Transaction Costs: The attacker's trades increase transaction costs for everyone on the network, as they compete for block space and gas.
  • Market Instability: Repeated sandwich attacks can erode trust in DEXs and contribute to market volatility.
  • Reputational Damage: While the attacks are often legal (depending on jurisdiction), they are viewed negatively by the community and can be considered unethical.

History/Examples

Sandwich attacks have become increasingly prevalent as DEXs have gained popularity. They are a natural consequence of the transparency and immutability of blockchain technology. While it's difficult to provide specific, verifiable examples without compromising on-chain privacy, the following points illustrate the context:

  • Early DeFi Days: As the DeFi space grew, so did the sophistication of attackers. Initially, the attacks were relatively simple, but they have evolved as arbitrage bots and other automated trading strategies have become more common.
  • Ethereum and EVM Chains: Sandwich attacks are particularly common on Ethereum and other EVM (Ethereum Virtual Machine)-compatible chains because of their public mempools and the prevalence of DEXs like Uniswap and SushiSwap.
  • MEV (Miner Extractable Value): Sandwich attacks fall under the umbrella of MEV, which refers to the profit miners can extract from reordering, including, or censoring transactions within a block. MEV extraction is a significant area of research and development in the blockchain space.
  • Mitigation Strategies: Efforts are underway to mitigate sandwich attacks. These include:
    • Private Transaction Pools: Some platforms offer private transaction pools, where trades are hidden from public view until execution. This makes it harder for attackers to front-run trades.
    • Flashbots: Flashbots is a project that aims to create a more efficient and transparent market for MEV extraction. It allows traders to submit transactions directly to miners, bypassing the public mempool.
    • Improved Slippage Controls: DEXs are working on more sophisticated slippage controls and price impact analysis to help traders better understand the potential costs of their trades.

Sandwich attacks are a symptom of the open, permissionless nature of decentralized finance. Understanding them is crucial for anyone participating in the DeFi ecosystem. As the industry matures, expect to see more sophisticated defenses and countermeasures emerge to combat this form of market manipulation.

Trading Benefits

Trade faster. Save fees. Unlock bonuses — via our partner links.

  • 20% cashback on trading fees (refunded via the exchange)
  • Futures & Perps with strong liquidity
  • Start in 2 minutes

Note: Affiliate links. You support Biturai at no extra cost.

Disclaimer

This article is for informational purposes only. The content does not constitute financial advice, investment recommendation, or solicitation to buy or sell securities or cryptocurrencies. Biturai assumes no liability for the accuracy, completeness, or timeliness of the information. Investment decisions should always be made based on your own research and considering your personal financial situation.