Skip to main content

Table Details

Table Columns

Sandwich Trades Table

The Sandwich Trades table captures DEX events where sandwich trading activity is detected. Sandwich trading involves placing two trades (a front-run and a back-run) around a victim’s trade to manipulate the market price for profit.
More on Sandwich Attack

Sample Query

Finding the total USD amount of sandwich trades by project and date:

Methodology

We use the dex.trades table to construct this table. This table contains all trade events from DEX protocols. We identify sandwich trades using the following criteria:
  1. Trade Pair Identification:
    • The sandwich trade (swap1 , swap2) must occur within the same block.
    • It must be executed in the same liquidity pool (same liquidity_pool_address).
    • It must be executed by the same signer (transaction_from_address).
    • The transaction indices must be different (transaction_index).
  2. Direction Determination:
    • If s1.transaction_index > s2.transaction_index, the trade is a “back” part of the sandwich.
    • If s1.transaction_index < s2.transaction_index, the trade is a “front” part of the sandwich.
  3. Token Matching:
    • The token bought in the first trade (s1) must match the token sold in the second trade (s2).
    • Alternatively, the token sold in the first trade (s1) should be the token bought in the second trade (s2).
Exclusion of Non-Applicable Projects:
  • Exclude DEXs without the concept of liquidity pools, such as RFQ protocols like Airswap.