Query editor
--Largest dex USDC pairs on Avalanche and 3 other chains, over the last 6 monthswith swaps as (selectblockchain,project,--rename so that token0 is USDC'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 in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_bought_amount else 0 end as token0_bought,case when token_sold_address in(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E,0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8,0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174,0x7F5c764cBc14f9669B88837ca1490cCa17c31607)then token_sold_amount else 0 end as token0_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 (select*,row_number() over (partition by blockchain order by usdc_bought desc) as rnfrom (selectblockchain,project,token0_address, --USDCtoken0_symbol,sum(token0_bought) as usdc_bought,sum(token0_sold) as usdc_soldfrom swapsgroup by 1,2,3,4))selectcasewhen blockchain = 'avalanche_c' then 'Avalanche'when blockchain = 'arbitrum' then 'Arbitrum'