Query editor
withparams as (select now() - interval '24' hour as start_time, now() as end_time),quote_assets(asset) as (values (0x0000000000000000000000000000000000000000),(0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2),(0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48),(0xdac17f958d2ee523a2206206994597c13d831ec7),(0x6b175474e89094c44da98b954eedeac495271d0f),(0x2260fac5e5542a773aa44fbcfedf7c193bc2c599),(0x853d955acef822db058eb8505911ed77f175b99e),(0x4d224452801aced8b2f0aebe155379bb5d594381)),denied_factories(factory, label) as (values (0xaec49a050917ddba7a09db04fa27360f44df6db3, 'baesscan denied factory address watchlist')),trusted_hooks(hook, label) as (-- Public allowlist placeholder. Keep zero hook excluded; add audited/known-good hooks here as baesscan chooses to publish them.values (0x0000000000000000000000000000000000000000, 'zero/no hook')),clean_trades as (selectd.block_time,date_trunc('hour', d.block_time) as hour,d.block_number,d.tx_hash,d.evt_index,coalesce(d.taker, d.tx_from) as wallet,d.project,d.version,d.amount_usd,d.token_bought_address,d.token_sold_address,d.token_bought_symbol,d.token_sold_symbol,casewhen d.token_bought_address not in (select asset from quote_assets) then d.token_bought_addresswhen d.token_sold_address not in (select asset from quote_assets) then d.token_sold_addresselse nullend as primary_token,casewhen d.token_bought_address not in (select asset from quote_assets) then d.token_bought_symbolwhen d.token_sold_address not in (select asset from quote_assets) then d.token_sold_symbolelse nullend as primary_symbol,casewhen d.token_bought_address not in (select asset from quote_assets) and d.token_sold_address in (select asset from quote_assets) then 'buy'when d.token_sold_address not in (select asset from quote_assets) and d.token_bought_address in (select asset from quote_assets) then 'sell'else 'other'end as side,casewhen d.token_bought_address not in (select asset from quote_assets) and d.token_sold_address in (select asset from quote_assets) then d.token_bought_amountwhen d.token_sold_address not in (select asset from quote_assets) and d.token_bought_address in (select asset from quote_assets) then d.token_sold_amountelse nullend as primary_token_amountfrom dex.trades dwhere d.blockchain = 'ethereum'and d.block_time >= (select start_time from params)and d.amount_usd is not nulland d.amount_usd > 0and (d.token_bought_address not in (select asset from quote_assets)or d.token_sold_address not in (select asset from quote_assets))),