Query editor
withL as (select * from dune.fadz2323.result_base_liq_open_race_events where t < timestamp '2026-12-04'),S as (select * from dune.fadz2323.result_base_liq_open_race_svr),days as (select date_trunc('day', timestamp) d, (max(price)-min(price))/min(price) rngfrom prices.hour where blockchain = 'base' and contract_address = 0xcbb7c0000ab88b473b1f5afd9ef808440eed33bfand timestamp >= timestamp '2026-10-01' and timestamp < timestamp '2026-12-04'group by 1),dq as (select d, rng, ntile(4) over (order by rng) q from days),e as (select date_trunc('day', L.t) d, L.is_atlas, L.bonus_usd, L.proto, L.mkey,case when L.is_atlas then 'atlas'when (S.last_atlas_ts is not null and L.ts - S.last_atlas_ts <= 10) or (S.last_s_ts is not null and L.ts - S.last_s_ts <= 10) then 'leftover'when S.lag_fb_mapped is not null or (S.svr_agg is null and S.lag_fb_any <= 3) then 'fallback'when S.nonsvr_hit >= 0 then 'non_svr'else 'drift' end clsfrom L left join S on S.tx = L.tx and S.ei = L.ei),daily as (select dq.d, dq.q, dq.rng,coalesce(sum(case when cls='atlas' then bonus_usd end),0) atlas,coalesce(sum(case when cls<>'atlas' then bonus_usd end),0) open_all,coalesce(sum(case when cls='leftover' then bonus_usd end),0) leftover,coalesce(sum(case when cls='fallback' then bonus_usd end),0) fallback,coalesce(sum(case when cls='non_svr' then bonus_usd end),0) non_svr,coalesce(sum(case when cls='drift' then bonus_usd end),0) drift,coalesce(sum(case when cls<>'atlas' and (proto='compound' or mkey = 0x0ca10126f6c94cbd9cf0a48cc9516ae5e3dec5aa68303e6d988ee37c5149bf0d) then bonus_usd end),0) soft_setfrom dq left join e on e.d = dq.dgroup by 1,2,3)select 'Q' || cast(q as varchar) bucket, count(*) days, round(avg(rng),3) avg_btc_range,round(approx_percentile(open_all,0.5)*30) med_mo_open, round(avg(open_all)*30) mean_mo_open,round(avg(leftover)*30) mo_leftover, round(avg(fallback)*30) mo_fallback, round(avg(non_svr)*30) mo_nonsvr, round(avg(drift)*30) mo_drift,round(avg(soft_set)*30) mo_soft_set, round(avg(atlas)*30) mo_atlasfrom daily group by 1union allselect 'M ' || cast(date_format(d, '%Y-%m') as varchar), count(*), round(avg(rng),3),round(approx_percentile(open_all,0.5)*30), round(sum(open_all)),round(sum(leftover)), round(sum(fallback)), round(sum(non_svr)), round(sum(drift)), round(sum(soft_set)), round(sum(atlas))from daily group by 1union allselect * from (select 'D ' || cast(date_format(d, '%m-%d') as varchar), 1, round(rng,3), null, round(open_all), round(leftover), round(fallback), round(non_svr), round(drift), round(soft_set), round(atlas)from daily order by open_all desc limit 6)order by 1