📚
EigenPhi Classroom
EigenPhiTwitterAlertSubstack
  • A Brief Introduction about EigenPhi Classroom
  • Glossary
    • MEV
    • MEV Contract
    • Malicious Token
    • Trading Volume
    • Trading Volume Change%
    • Transaction Profit Distribution (percentile)
    • Arbitrage ID
    • 1D/7D/30D
    • Liquidity Pool
    • Smart Contract
    • Protocol
    • Profit%
    • TFIDF
    • Asset, Liquidation
    • Borrower, Liquidation
    • Liquidator, Liquidation
    • Collateral, Liquidation
    • LTV, Liquidation
    • Liquidation Threshold, Liquidation
  • MEV Types
    • Arbitrage
      • Arbitrage Using 2 Tokens Between 2 Trading Venues
      • Arbitrage Involving 3 Tokens Among 3 Trading Venues
      • Arbitrage Requiring More Tokens and More Trading Venues
      • Arbitrage package
    • Sandwich MEV
    • Liquidation
      • Liquidation transaction with Aave V2 involved
  • Users of EigenPhi
    • Researcher
    • Searcher
    • Retail Investor
  • Communities & Channels
    • Our MEV Daily Report
      • Overview Section of Daily Report
      • Summary Data by MEV Types of Daily Report
      • MEV-Bot Data by MEV Types of Daily Report
      • Hot Liquidity Pools and Hot Tokens of Daily Report
      • MEV Transaction Profit Leaderboard of Daily Report
      • Download And Share Daily Report Data
    • Our Sandwich Daily Report
      • Overview Section of Sandwich Daily Report
      • Sandwich MEV Trends of Last 24 Hours and 7 Days
      • What Were the Sandwich Searchers Capable of Yesterday?
      • The 5 Most Delicious Sandwiches
      • Watch Out When Using These Protocols, Routers, and Proxies!
      • Top Attackers and Victims
      • Download And Share Sandwich Daily Report Data
    • Our Data Sources
    • Our Content and Social Channels
  • EigenPhi's Methodologies
    • Do You Have These Questions When Doing DeFi Trading?
    • 2 Biggest Concerns That Haven't Been Properly Addressed
    • 3 Pillars of DeFi: Structure, Behavior, and Network
    • The EigenPhi Way
    • Why MEV?
    • How EigenPhi Identifies MEV
      • Recognizing Atomic Arbitrage MEV Transactions
        • Implementation
        • A Typical Arbitrage Example
      • Recognizing Cross-Transaction Sandwich MEV
        • Example
Powered by GitBook
On this page
  1. MEV Types

Sandwich MEV

PreviousArbitrage packageNextLiquidation

Last updated 2 years ago

A sandwich attack involves "sandwiching" the transactions between two transactions initiated by the /, whose reordering of the transactions inflicts an implicit loss on the victimized users and possibly benefits the attacker.

Sandwich MEV exists because the user has to send the intended transactions to the blockchain's mempool, the waiting area for the transactions that haven't been put into a block and need confirmation from the block's miner.

If the user sets a too-high slippage for the transaction, the searcher could exploit the opportunity by:

  • Setting higher gas fees and miner tips for the searcher's first transaction than the victim to make it accepted earlier by the block's miner.

  • Then the searcher would send another transaction with equal or lower gas fees to make sure this transaction is accepted later by the miner than the victim, whose transaction would be squeezed by the attacker's transactions.

How exactly does the attacker gain revenues during the process? Here is an example.

  1. In a UNISWAP liquidity pool, Bob is a retail investor who wants to trade 1000 $WETH for $USDC. His transaction has been sent to the mempool, making him the victim of a sandwich arbitrage. The transaction is marked as â‘  in the figure below.

  2. Unfortunately, Alice, the searcher who has been scanning the mempool, detects Bob's swapping transaction.

  3. Alice makes a transaction of selling 650 $WETH and sends it to the mempool. In the end, she receives 1,842,200 $USDC at the exchange rate of 1 $WETH for 2,834 $USDC. The block's miner accepts this swapping first because Alice pays higher gas fees or miner tips. The swapping causes the exchange rate to change to 1 $WETH for 2,821 $USDC. This transaction and one Alice sent after Bob's are marked as â‘¡ in the figure below.

  4. Bob's transaction goes through the mempool and to the block selling 1000 $WETH for 2,821,000 $USDC, which he should have been able to get 2,834,000 $USDC.

  5. Alice's selling of 1,842,200 $USDC passes the mempool and gets recorded by the miner in the block. She receives 652.9 $WETH.

  6. All three transactions are marked as â‘¢ in the figure below, which shows in the order the miner accepts them.

Alice's revenue from this Sandwich arbitrage is 2.9 $WETH. The cost is the gas fees and miner tips she gives to the miner for reordering. Assuming it's 1.2 $WETH. In the end, Alice's profit is 1.7 $WETH.

These are the four basic arbitrage types on the transaction and contract levels. But, of course, other kinds of arbitrages also occur on the higher level of blockchain, which we will get to them later.

Now we will examine three types of users who are interested in EigenPhi.

victim's
searchers
attackers