DEX Table

The DEX Table in Increment standardizes and normalizes trading data across a wide range of decentralized exchanges. This simplifies querying trading data for your favorite tokens, eliminating the need to interact individually with different DEX smart contracts. The DEX Table allows you to easily access and analyze trading data across various decentralized exchanges.

Example Queries

Examine DEX sales volume on Ethereum, Arbitrum, Polygon, and Optimism over the last 30 days.

sql
SELECT 
      sum(abs(amount0_usd)) as Volume
      , date_trunc('day', signed_at) as Date
      , chain_name as Chain
FROM reports.dex
WHERE chain_name IN ('optimism_mainnet', 'arbitrum_mainnet', 'avalanche_mainnet', 'eth_mainnet')
AND signed_at > now() - interval '30 day'  
GROUP BY Date, Chain
ORDER BY Date DESC 

Examine Swap events per DEX protocol on Ethereum over the last 30 days.

sql
SELECT 
      count(*) as Swaps
      , protocol_name as protocol
      , date_trunc('day',signed_at) as Date 
FROM reports.dex
WHERE event = 'swap'
  --other options include add_liquidity, pair_created, remove_liquidity and sync
AND signed_at > now() - interval '30 day' 
AND chain_name = 'eth_mainnet'
GROUP BY protocol, Date
ORDER BY Swaps DESC     

Table Columns

Column NameData TypeDescription
chain_namestringStores the chain name.
chain_idintegerEvery chain_name has a unique number that acts as a numerical identifier for that chain.
block_heightintegerStores the block height.
signed_atdatetimeStores the timestamp.
tx_hashstringEvery transaction on the blockchain has a transaction hash (tx_hash) that acts as a unique identifier for that transaction. The tx_hash column allows you to query specific information from a particular transaction.
protocol_namestringStores the name of the DEX that facilitated the event.
protocol_addressstringStores the contract address of the DEX that facilitated the event.
versionfloatDEXs often have multiple version - e.g Uniswap V1, V2 and V3. The version column allows you to look at a specific version of the DEX.
forkstringMany DEXs are a fork of an already established DEX. The fork column allows you to see which DEX has been forked.
fork_versionstringSimilarly to the version column, fork_version gives you the version of the forked DEX. For example, most DEXs are a fork of Uniswap V2; therefore, fork = aave & fork_version = 2
aggregator_namestringStores the aggregator responsible for the event.
aggregator_addressstringStores the contract address of the aggregator responsible for the event.
eventstringStores the event taking place - e.g swap, add_liquidity and remove_liquidity.
pair_addressstringStores the address of the pair that the user interacts with.
token0_addressstringStores the address of token0 in the specific pair.
token0_tickerstringStores the ticker symbol of token0 in the specific pair.
token1_addressstringStores the address of token1 in the specific pair.
token1_tickerstringStores the ticker symbol of token1 in the specific pair.
amount0_unscaledfloatStores the raw, on-chain amount of token0 involved in the event. Blockchains don't work with decimal numbers which is why they multiply values by 10^num_decimal to turn decimal numbers (price or token amount) into integers. For example, instead of a transaction's gas cost being 0.000000000000000001 ether, it's shown as 1 . Therefore, this field has all the raw token amounts that are multiplied by 10^num_decimal.
amount0floatStores the amount of token0 used in the transaction. For example, 1 ETH, 100 USDC, 30 UNI, etc.
amount0_usdfloatStores the USD amount of token0 used in the transaction.
amount1_unscaledfloatStores the raw, on-chain amount of token1 involved in the transaction.
amount1floatStores the amount of token1 used in the transaction. For example, 1 ETH, 100 USDC, 30 UNI, etc.
amount1_usdfloatStores the USD amount of token1 used in the transaction.
senderstringStores the wallet address that initiated the transaction.
gas_ethfloatStores the gas fee, denominated in ETH.
gas_usdfloatStores the gas fee, denominated in USD.