Query editor
-- % increase YTD-- 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 ytd total usd volumedex_ytd_vol as (select sum(amount_usd) as usd_volumefrom dex_tradeswhereblock_date >= date('2024-01-01') andblock_date <= date('2024-02-13')),-- get the usd volume for the same period last yeardex_prev_vol as (select sum(amount_usd) as usd_volumefrom dex_tradeswhereblock_date >= date('2023-01-01') andblock_date <= date('2023-02-13')),-- then get the aggregator trade volumes-- get the ytd total usd volumeagg_ytd_vol as (select sum(amount_usd) as usd_volume