Query editor
--Largest dex USDC pairs on Avalanche and 3 other chains, over the last 6 monthswith swaps as (selectblockchain,--rename so that token0 is USDC and token1 is other token'USDC' as token0_symbol,case when token_bought_address in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_bought_address else token_sold_address end as token0_address,case when token_bought_address not in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_bought_symbol else token_sold_symbol end as token1_symbol,case when token_bought_address not in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_bought_address else token_sold_address end as token1_address,case when token_bought_address in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_bought_amount else 0 end as token0_bought,case when token_bought_address not in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_bought_amount else 0 end as token1_bought,case when token_sold_address in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_sold_amount else 0 end as token0_sold,case when token_sold_address not in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_sold_amount else 0 end as token1_soldfrom dex.tradeswhereblock_time >= now() - interval '6' monthand ((blockchain = 'avalanche_c' and (token_bought_address = 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6Eor token_sold_address = 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E))or (blockchain = 'arbitrum' and (token_bought_address = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8or token_sold_address = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8))or (blockchain = 'polygon' and (token_bought_address = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174or token_sold_address = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174))or (blockchain = 'optimism' and (token_bought_address = 0x7F5c764cBc14f9669B88837ca1490cCa17c31607or token_sold_address = 0x7F5c764cBc14f9669B88837ca1490cCa17c31607)))),aggregates as (