Query editor
with dedup as (-- as rodadas manuais inseriram algumas horas repetidas; fica 1 linha por (hora, mercado)selectts,symbol,rate,direction,row_number() over (partition by ts, symbol order by ts) as nfrom dune.theosq.lighter_funding_hourly),top8 as (select symbolfrom dune.theosq.lighter_markets_dailywhere snapshot_ts = (select max(snapshot_ts) from dune.theosq.lighter_markets_daily)and status = 'active'order by open_interest_usd desclimit 8)selectcast(d.ts as date) as dia,d.symbol,round(10000 * avg(case when d.direction = 'short' then -d.rate else d.rate end), 3) as funding_medio_bps,count(*) as horasfrom dedup djoin top8 t on t.symbol = d.symbolwhere d.n = 1and d.ts >= current_date - interval '30' daygroup by 1, 2order by 1, 2