Trades

The DEX trades table contains swaps made on decentralized exchanges, consolidated into a single table.

Project Coverage:

Currently, we support the following projects on Polygon.

Projects
Protocol

kyberswap, uniswap

uniswap_v3

sushiswap, quickswap, polycat, mmfinance, jetswap, gravityfinance, fraxswap, elkfinance, dfyn-network, apeswap-amm

uniswap_v2

balancer

balancer_v2

curve

curve_v1, curve_v2

Methodology

We adopted a protocol-based and event log-based approach to index swap events.

In brief, the swap events for each protocol are identified by the event signature (topic0), which contains the amount of tokens swapped and the address of the sender and receiver.

For protocols such as Uniswap v2 and v3 the token address swapped is identified by the liquidity pool creation event using the pool address. The amount of tokens traded is adjusted by the token's decimal value and then multiplied by hourly price oracle data to give the USD value of the transaction.

Sample Query

Finding the swap volume of indexed projects on Polygon in the last 7 days.

select 
  date(block_timestamp) as date,
  project, 
  sum(usd_amount) as usd_volume 
from polygon.dex.trades
  where current_date - date(block_timestamp) < 7
  group by date, project
  order by date desc 

Table Columns

_str columns are numeric fields casted as varchar to retain precision when summing.

Column Name
Description
Example

project

The project (decentralized exchange) of the liquidity pool that the swap occurred from.

uniswap

protocol

Version of the protocol.

uniswap_v3

liquidity_pool_address

Contract address of the liquidity pool holding the asset. For protocols such as airswap, this will be null.

0x057932cec2f7aceeb3f8495baa42cb30570b790a

sender_address

The address of the sender emitted on the swap event logs. This can be a router or pool address, which is different from the transaction initatior transaction_from_address that initiated the swap.

0xe592427a0aece92de3edee1f18e0157c05861564

to_address

Address of the recipient emitted on the swap event logs. For example, we use the to_address from the uniswap v2 swap event log and the recipient_address from the uniswap v3 swap event log.

0xdb6f1920a889355780af7570773609bd8cb1f498

token_bought_address

Token address of the token bought, i.e. the asset acquired from the trade.

0x00c7bfc4fc822629ee60b62b9b41fa8df4d4715a

token_bought_name

Name of the token bought.

Ballswapper Accelerator Reflecti

token_bought_symbol

Symbol of the token bought.

BART

token_sold_address

Token address of the token sold.

0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270

token_sold_name

Name of the token sold.

Wrapped Matic

token_sold_symbol

Symbol of the token sold.

WMATIC

token_bought_amount_raw

Raw amount of tokens bought (unnormalized).

3.20E+19

token_bought_amount_raw_str

Raw amount of tokens bought (unnormalized) in string.

3.20209E+19

token_bought_amount

Amount of tokens bought.

32,020,943,037.69

token_bought_amount_str

Amount of tokens bought in string.

32020943038

usd_bought_amount

Amount of token bought in USD value.

token_sold_amount_raw

Raw amount of tokens sold (unnormalized).

9,788,021,815,345,290,000.00

token_sold_amount_raw_str

Raw amount of tokens sold (unnormalized) in string.

9.78802E+18

token_sold_amount

Amount of tokens sold.

9.79

token_sold_amount_str

Amount of tokens sold in string.

9.788021815

usd_sold_amount

Amount of token sold in USD value.

16.11108391

usd_amount

USD value of the swap. This field preferentially selects the USD value of ETH-priced tokens, as scam-related token prices can conflate the true swap value.

16.11108391

transaction_hash

Transaction hash that this swap belongs to.

0x95b4d0f6118076f4ed814a2a38f04e7414cd2fb91be6ab06015e64235534b264

transaction_from_address

Transaction sender address. I.e. the address of the transaction initiator. (from_address in the raw.transactions field for the transaction_hash of this swap).

0x67ebc532d648e6164a6fd726ff0b39e69180dafe

transaction_to_address

Transaction receiver. (to_address in the raw.transactions field for the transaction_hash of this swap).

0xdef1c0ded9bec7f1a1670819833240f027b25eff

log_index

The position of the swap event log in the transaction.

200

block_timestamp

Block timestamp of the swap event.

2022-03-27 19:26:47

block_number

Block number of the swap event.

26,433,314

block_hash

Block hash of the swap event.

0xdcd8faaf66130323e2528b97e8dac4356fac0a1f4780acaacbfd7f354fdf9774

unique_id

Unique ID of the swap.

txn-0x95b4d0f6118076f4ed814a2a38f04e7414cd2fb91be6ab06015e64235534b264_log_index-200

Last updated