Query editor
-- % increase since 2020-- first clean dex aggregator trades data (unsure if necessary)with aggregator_trades as (select *from dex_aggregator.tradeswhere-- exclude outlier wrong tx data (informed from https://dune.com/queries/2481194/4081997)not (block_date = date('2023-05-23')and tx_hash = 0x14613a8f439f5f65b3235fbae95b67bc5f6aa7b0937af73e8df593e00d8abb12)and not (blockchain = 'polygon'and tx_hash in (0xb2f18844b54f21170bb4b6d136ef2e2f3e4b0aa21bf322b6c28b53468b47652a,0xaf822bbff8daf6c6fa9fa9d76068f919cc104e78ce60d8ae160de2b778b41e25))),-- next get the raw dex trade volumes for comparison-- remove any chains not present in our aggregator dataremove_chains as (SELECT DISTINCT blockchainFROM dex.tradesEXCEPTSELECT DISTINCT blockchainFROM dex_aggregator.trades),dex_trades as (select * from dex.trades twhere not EXISTS (SELECT 1FROM remove_chains rcWHERE rc.blockchain = t.blockchain)),-- get the most recent full year of usd volumedex_current_vol as (select sum(amount_usd) as usd_volumefrom dex_tradeswhereblock_date >= date('2023-02-14') andblock_date <= date('2024-02-13')),-- get the year 2020 usd volumedex_2020_vol as (select sum(amount_usd) as usd_volumefrom dex_tradeswhereblock_date >= date('2020-01-01') andblock_date <= date('2020-12-31')),-- then get the aggregator trade volumes-- get the most recent full year of usd volumeagg_current_vol as (select sum(amount_usd) as usd_volume