🧬
Head First DeFi: TX & Strategies
  • Decoding the DNA of DeFi Transactions & Strategies
    • From Arbitrage, Sandwich to JIT and Oracle Manipulation
    • Be Prepared To Explore the DeFi World
    • Case Study Format
  • MEV Transaction & Strategy 101
    • A $3.2 Million Profit Arbitrage, the Most Lucrative MEV of 2022
    • Understand Back-Run Arbitrages and Their Signals and Join the MEV Game.
    • Wallchain's MEV Arbitrage Redistribution
    • MEV Blocker, the multi-transaction MEV redistribution system that refunds 90% of builder rewards
    • With NFT arbitrage, someone was snipping your Baby Doge.
    • The Hidden Tax That You Should Know About
    • MEV-Share, Flashbots' MEV Redistribution Solution
  • Don't Let Your Trading Become the Recipe of Someone's Sandwich
    • The Notorious Jaredfromsubway.eth's Sandwich Attack
    • Combined with Flash Loan, This Leveraged Sandwich Launched the Attack with Millions of Volumes
    • Sandwich Targeting Liquidity Providers
    • The Flash-Loan-Enabled Sandwich Attack against Ethereum Foundation
  • Under the Hood of the DeFi Lego
    • What's Really Going on When Processing Liquidity in a Uniswap Pool?
      • Pretend You Are One of the Shareholders of a Bank Branch.
      • Let's Match the Bank Branch to a Uniswap Pool.
      • Adding Liquidity.
      • Removing Liquidity.
      • Conclusion
    • Liquidation: A Good Entry Point to Comprehend Internal Accounting Used by Many DeFi Protocols.
    • A Cross-Chain Arbitrage: The Art of Arbitraging BANANA Cross BSC and Polygon Chains
    • Liquidity Rebalancing: Moving Around $9.4 Million for More Fee Revenues.
    • Rebalancing loan positions utilizing AAVE Flash loan
    • How Does the Grok Token Exploiter Exploit the X Token By Baking His Own Cake And Eating it?
  • Unlocking the Power of Advanced DeFi Transactions and Becoming a DeFi Sleuth
    • Just-in-Time, an MEV Type That Benefits Traders in the Same Trading Venue
    • A Bot Devised Arbitrage Strategies Centered on Autonomous Minting and Burning of Synthetic Tokens
    • The Defect in a Lending Protocol's Oracle Module Was Exploited by a Bot to Generate a $110K Profit
    • A $296K-Profit Arbitrage Done by the Lightning Reflex Bot After the Vyper-Curve Exploit
    • Coffeebabe.eth Utilized Curve's CRV/WETH Pool's Price Deviation for a $5.4 Million Profit Arbitrage.
    • An Attacker Baited MEV Arbitrage Bots and Emptied Their Wallets
    • How Enso Solves 73.5ETH in 116 Steps in One Transaction
Powered by GitBook
On this page
  • Strategy One Liner
  • Big Picture
  • Key Steps
  • Key Protocols
  • Key Addresses
  • Key Assets
  • Simplified Illustration
  • Step-by-step Decoding
  • More Details
  • Keywords

Was this helpful?

  1. Don't Let Your Trading Become the Recipe of Someone's Sandwich

Sandwich Targeting Liquidity Providers

PreviousCombined with Flash Loan, This Leveraged Sandwich Launched the Attack with Millions of VolumesNextThe Flash-Loan-Enabled Sandwich Attack against Ethereum Foundation

Last updated 1 year ago

Was this helpful?

Strategy One Liner

Apart from swap transactions, sandwich attacks may also squeeze add-liquidity transactions. Here is a genius example.

Big Picture

Key Steps

  1. Frontrun: The sandwich bot swapped 21.4778 WETH to 458,875.7693 SYC through UniswapV2.

  2. Victim's Transaction Steps 0,1: A liquidity provider added 15 WETH and 231,712.9637 SYC to UniswapV2 and minted 1,792.6288 UNI-V2 as a voucher.

  3. Backrun Steps 0,1: The sandwich bot swapped 458,875.7693 SYC, as obtained in the front-running transaction, back to 22.4006 WETH.

  4. Backrun Step 3: The attacker gave the block builder a fee to let him put the three transactions in the block with the order preserved.

Key Protocols

Uniswap: the largest DEX as of press time.WETH: an ERC20 token that is 1:1 to ETH.

Key Addresses

  • The solid red oval "UniswapV2Pool" is UniswapV2's SYC/WETH Pool address.

  • The oval "to" in frontrun and backrun is the attacker's contract address.

  • The pentagon "from" in the victim transaction is the victim's EOA.

Key Assets

WETH, ETH, SYC

Simplified Illustration

The UNiswapV2Pool labeled with 🥪 is where the sandwich happened.

Step-by-step Decoding

  1. Frontrun: The sandwich bot swapped 21.4778 WETH to 458,875.7693 SYC through UniswapV2.

  2. Victim's Transaction Step 0: A liquidity provider (LP) sent 15 ETH to UniswapV2 Router. Later, this 15 ETH will be transformed into WETH and added to UniswapPool as Liquidity.

  3. Victim's Transaction Step 1: The LP added 231,712.9637 SYC to UniswapV2.

  4. Victim's Transaction Steps 2,3,4: UniswapV2 Router transformed the 15 ETH it received from the LP to WETH and added to UniswapPool.

  5. Victim's Transaction Step 5: UniswapV2 returned the LP 1,792.6288 UNI-V2 as a voucher.

  6. Backrun: The sandwich bot swapped 458,875.7693 SYC, as obtained in the front-running transaction, back to 22.4006 WETH.

  7. Backrun Step 3: The attacker gave the block builder a fee to let him put the three transactions in the block with the order preserved.

  8. Backrun Step 4: The attacker paid for the gas fee.

More Details

In the end, the bot made a profit of $35.89. It seems simple. But why was the sandwich bot able to profit from LP’s add-liquidity transaction? Where was the revenue coming from? Was it making the maximum amount of revenue possible? And who was being affected negatively?

Let's do it step by step. In the frontrun, the attacker swapped ETH for SYC. So, the price of SYC rose (and rose by 100%!). Then, our poor LP added liquidity with the ratio corresponding to the marginal price after the frontrun. Adding liquidity would stabilize the price at that value, so the attacker would enjoy a smaller slippage when he sells the SYC in the backrun. Finally, the attacker sold SYC to ETH with a higher average price and made a gross profit of nearly 1 ETH. The amount of ETH swapped in the frontrun was carefully calculated to not exceed the thresholds set by LP. In other words, the attacker has reached the maximum amount of revenue possible. The most important takeaway from this case is that LPs should carefully set thresholds tighter.

Keywords

Sandwich attack, Liquidity Provider, Uniswap

The attacker first sold ETH to SYC and then, after the price of SYC rose, repurchased ETH using SYC. In a more thorough , we provide a detailed explanation of this strategy and show that all liquidity providers in this pool bear the most significant losses compared to the LP in the victim transaction.

research report
LogoTransaction Flow Chart | EigenTx:0x6d174d460f7fc2eec5d851d213c7ae39590bbada768ab40400a97e4fe16f4cdf,0x2d38eeebe9deac4c6a180dc94f04b60c28773a829d432f38a2569817e574aae5,0xc82ed6a0514000c42fa817dbc707f04542bdc7610330c05cbe8059dbd758e7ffEigenPhi
The Frontrun
The Victim Transaction
The Backrun