Bonding Curve Research Group Library 📚
  • About the BCRG
  • About this Library
  • ♻️From Static to Dynamic Supply Tokens
  • ➰What are Bonding Curves?
  • 🗃️Differentiating Primary & Secondary AMMs
  • 🤖Modeling & Simulating Bonding Curves
  • 🎛️Bonding Curve Parameter Matrix & Trade-Off Decisions
    • Initial Supply
    • Initial Reserve
    • Initial Price
    • Reserve Ratio
    • Mint Fee
    • Burn Fee
    • Max Supply
  • ☠️Attack Vectors
    • Liquidations
    • Sandwich trading
    • Front Running
    • Backrunning
    • Solutions
  • 📓Case Studies
    • 🤖Aavegotchi
      • Bonding Curve Design
      • Pricing Algorithm
      • Governance and Tokenomics
        • Avegotchi DAO Evoution
    • 👣Carbon
      • Asymmetric Liquidity
      • Adjustable Bonding Curves
      • Matching, Routing & Arbitrage in AMMs
      • MEV Resistance
    • 📈Continuous Organization (cOrg)
      • cOrg Token Bonding Curve Model
        • The Decentralized Autonomous Trust
        • Bonding Curve Contract Dynamics in Investment and Sale Operations
    • 🐮CoW Protocol
      • Loss Versus Rebalancing (LVR)
        • Deep dive into Loss-Versus-Rebalancing (LVR)
      • Batch Trading & Function-Maximizing AMMs
      • Implementation - COW AMM
    • ⚙️DXDao
      • DXdao Bonding Curve
    • ⚓Gyroscope
      • The Gyro Bonding Curve
      • Elliptic Concentrated Liquidity Pools (E-CLP)
      • Gyro Consolidated Price Feeds
        • Consolidated Price Feed Approach
    • 🕉️Olympus DAO
      • Range Bound Stability
    • 💸 Public Goods Token Performance Analysis
  • 🍄 Engineering for Resilience with Primary Issuance Markets
  • 💻BCRG Github Repos
  • 📽️BCRG Video Library
  • 📖Glossary
  • 🔎Token Engineering Courses & Resources
Powered by GitBook
On this page
  1. Attack Vectors

Sandwich trading

At its core, the sandwich attack involves an attacker strategically positioning their transactions around a victim’s transaction to capitalize on price variances. The attacker initially inflates the asset’s price with the transaction (1), waits for the victim’s transaction to materialize and subsequently deflates the asset’s price with the transaction (3), thereby securing a profit.

Assume a Bonding Curve holding crypto-token in reserves (τ0) that can be swapped with another token (τ1). Now, suppose that user A wants to swap 20 units of τ0 in her wallet for at least 15 units of τ1. This requires to append to the blockchain a transaction of the form

A:swap0(20:τ0,15:τ1),A : swap^0 (20 : \tau_0 , 15 : τ_1),A:swap0(20:τ0​,15:τ1​),

where the prefix A indicates the wallet involved in the transaction, swap is the called AMM function, and the superscript 0 indicates the swap direction, i.e. deposit 20 : τ0τ_0τ0​ to receive back at least 15 : τ1τ_1τ1​ (a superscript 1 would indicate the opposite direction). In a bonding curve, the actual amount of τ1τ_1τ1​ transferred to A must be such that the “invariant" is preserved before and after a swap. Now, suppose that an adversary M observes A’s transaction, and appends to the blockchain the following sandwich:

M:swap0(5.9:τ0,5.5:τ1)M : swap^0 (5.9 : τ_0, 5.5 : τ_1)M:swap0(5.9:τ0​,5.5:τ1​)

A:swap0(20:τ0,15:τ1)A: swap^0 (20 : τ_0, 15 : τ_1)A:swap0(20:τ0​,15:τ1​)

M:swap1(25.9:τ0,20.6:τ1)M : swap^1 (25.9 : τ_0, 20.6 : τ_1)M:swap1(25.9:τ0​,20.6:τ1​)

where the last transaction is in the opposite direction, i.e. M sends 20.6 : τ1τ_1τ1​ to receive at least 25.9 : τ0τ_0τ0​. As a result, A only yields the minimum amount of 15 : τ1 in return for 20 : τ0τ_0τ0​. This implies that an extra amount has been gained by M and lost by A. This is how a sandwich attack takes place.

PreviousLiquidationsNextFront Running

Last updated 10 months ago

☠️