Query editor
withtimeline as (select date_trunc('day', time) as dayfrom unnest(sequence(timestamp '2024-10-29',cast(NOW() as timestamp),interval '1' day)) as s(time)), fluid_dex as (select d.*, case when ts.price_address is not null then ts.price_address else d.supply_token end as supply_token_adj, case when tb.price_address is not null then tb.price_address else d.borrow_token end as borrow_token_adjfrom "query_4281603" as dleft join tokens.native as tson d.blockchain = ts.chainand d.supply_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeleft join tokens.native as tbon d.blockchain = tb.chainand d.borrow_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewhere dex_name = '{{dex_name}}'), fluid_dex_swaps as (select *from "query_4227449"where dex_name = '{{dex_name}}'), other_dexes_volume as (selectday, blockchain, case when rnk > 5 then 'Others' else dex end as dex, sum(volume_usd) as volume_usdfrom (select *, rank() over (partition by day, blockchain order by volume_usd desc) as rnkfrom (selectt.block_date as day, t.blockchain, t.project as dex, sum(t.amount_usd) as volume_usdfrom dex.trades as tcross join fluid_dex as dwhere t.block_date >= (select min(day) from timeline)and t.blockchain = 'ethereum'and (t.token_bought_address = d.supply_token_adj and token_sold_address = d.borrow_token_adjor token_bought_address = d.borrow_token_adj and token_sold_address = d.supply_token_adj)and project <> 'fluid' -- no label on Dune yetgroup by 1, 2, 3 ))group by 1, 2, 3), dex_volume_with_fluid_ethereum as (select day, blockchain, dex, volume_usdfrom other_dexes_volume