Query editor
withstatic as (select'{{timebox}}' as timebox, date_trunc('{{timebox}}', timestamp '{{period from}}') as displayed_from), lop as (selectdate_trunc((select timebox from static), block_time) as time, split_part(upper(blockchain), '_', 1) as blockchain, count(*) as fills, count(distinct order_hash) as orders, count(distinct order_hash) filter(where user) as user_orders, count(distinct order_hash) filter(where rfq) as rfq_orders, count(distinct order_hash) filter(where fusion) as fusion_orders, count(distinct maker) as wallets, count(distinct maker) filter(where user) as user_wallets, count(distinct maker) filter(where fusion) as fusion_wallets, sum(amount_usd) as volume, sum(amount_usd) filter(where user) as user_volume, sum(amount_usd) filter(where rfq) as rfq_volume, sum(amount_usd) filter(where fusion) as fusion_volumefrom (selectblockchain, block_time, tx_hash, user as maker, mode = 'fusion' as fusion, coalesce(element_at(flags, 'contracts_only'), false) as rfq, not coalesce(element_at(flags, 'contracts_only'), false) as user, amount_usd, coalesce(order_hash, tx_hash) as order_hashfrom oneinch.swapswhere trueand tx_success and call_successand not coalesce(element_at(flags, 'second_side'), false)and mode in ('limits', 'fusion', 'cross-chain')and if('{{blockchain}}' in ('all', '= all ='), true, contains(split('{{blockchain}}', ','), blockchain)))group by 1, 2)-- output --select *from lopwhere time >= (select displayed_from from static)order by time desc, volume desc