Skip to main content

Table Description

The dex.sandwiches table captures detailed data on the outer trades of sandwich attacks executed via decentralized exchanges (DEXs). This table records the trades that constitute the “bread” of the sandwich attack, which can include both front-running and back-running trades, as well as more complex patterns. It provides a comprehensive view of sandwich attack patterns across various EVM networks.

Functional Overview

The dex.sandwiches table provides an in-depth view of the outer trades in sandwich attacks on decentralized exchanges. A sandwich attack typically occurs when a searcher spots a pending transaction in the mempool, quickly executes a trade before it (front-running), and then immediately after it (back-running) to profit from the price movement caused by the victim’s trade. However, this table also captures more complex sandwich attack patterns. For example: bot1: ETH>USDC victim1: USDC>ETH bot1: USDC>ETH victim2: ETH>USDC bot1: ETH>USDC In this scenario, the bot executes trades on both sides of the liquidity pool, sandwiching multiple victim trades in a single sequence. This table includes entries for all bot trades involved in these attack patterns. Note that the victim trades sandwiched between these outer trades are captured in a separate table, dex.sandwiched. This detailed approach allows for granular analysis of sandwich attack patterns, enabling users to:
  • Identify Sandwich Attacks: Easily spot instances of sandwich attacks across different DEXs and networks, including complex multi-trade patterns.
  • Analyze Attack Patterns: Understand the frequency, size, and potential profitability of sandwich attacks, including sophisticated strategies that target multiple victims in a single sequence.
  • Monitor Market Manipulation: Gain insights into various forms of market manipulation across different DEXs and EVM networks.
By providing comprehensive details of the trades involved in sandwich attacks, the dex.sandwiches table supports advanced analytics and research into DEX trading behavior, market manipulation, and potential areas for improved trade execution or protocol design.

Table Schema

ColumnTypeDescription
blockchainVARCHARBlockchain on which this trade occurred
projectVARCHARName of the DEX on which the trade occurred
versionVARCHARVersion of the DEX protocol/contract
block_timeTIMESTAMPUTC event block time
block_monthDATEUTC event block month (partition key)
block_numberBIGINTBlock number in which the trade occurred
token_sold_addressVARBINARYContract address of the token sold
token_bought_addressVARBINARYContract address of the token bought
token_sold_symbolVARCHARSymbol of the token sold
token_bought_symbolVARCHARSymbol of the token bought
makerVARBINARYAddress that sold tokens (can be contract or EOA)
takerVARBINARYAddress that purchased tokens (can be contract or EOA)
tx_hashVARBINARYTransaction hash
tx_fromVARBINARYEOA address that sent the transaction
tx_toVARBINARYAddress called in the first call of this transaction
project_contract_addressVARBINARYSmart contract address which emitted the trade event
token_pairVARCHARSymbol pair for the tokens involved, always alphabetical order
tx_indexBIGINTIndex of the transaction in the block
token_sold_amount_rawUINT256Raw amount of the token sold
token_bought_amount_rawUINT256Raw amount of the token bought
token_sold_amountDOUBLEAmount of the token sold in display units
token_bought_amountDOUBLEAmount of the token bought in display units
amount_usdDOUBLEUSD value of the trade at time of execution
evt_indexBIGINTIndex of the event in the transaction

Table Sample

Examples

The following query demonstrates how to use the dex.sandwiches table to calculate the total volume of sandwich attack trades on a weekly basis.
SELECT
  date_trunc('week', block_time) AS week,
  COUNT(*) AS sandwich_count,
  SUM(token_sold_amount_usd) AS total_volume_usd
FROM dex.sandwiches
WHERE blockchain = 'ethereum'
  AND block_time >= NOW() - INTERVAL '90' DAY
GROUP BY 1
ORDER BY 1
  • dex.sandwiched: This complementary table captures the victim trades that are sandwiched between the trades recorded in dex.sandwiches.
  • dex.trades: This table captures all trades and is the basis for the dex.sandwiches table.