Query editor
with e as (select block_time, cast(date_trunc('day', block_time) as date) day, index,bytearray_to_bigint(bytearray_substring(topic2, 25, 8)) pair_index,varbinary_to_uint256(varbinary_substring(data, 129, 32))/1e6 long_oi_usd,varbinary_to_uint256(varbinary_substring(data, 161, 32))/1e6 short_oi_usdfrom arbitrum.logswhere block_date >= date '2026-09-01'and contract_address = 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3and topic0 = 0x7a50afa193d27f20574d9d7c0bc0100211894a58118f9b152156eea4b1cc9bb7), eod as (select day, pair_index, max_by(long_oi_usd, (block_time, index)) long_oi_usd, max_by(short_oi_usd, (block_time, index)) short_oi_usdfrom e group by 1,2), pairs as (select distinct pair_index, min(day) over (partition by pair_index) first_day from eod),days as (select day from unnest(sequence(date '2026-09-30', current_date, interval '1' day)) as x(day)),grid as (select d.day, p.pair_index from days d cross join pairs p where d.day >= p.first_day),ff as (select g.day, g.pair_index,last_value(o.long_oi_usd) ignore nulls over (partition by g.pair_index order by g.day rows between unbounded preceding and current row) long_oi_usd,last_value(o.short_oi_usd) ignore nulls over (partition by g.pair_index order by g.day rows between unbounded preceding and current row) short_oi_usdfrom grid g left join eod o on o.day = g.day and o.pair_index = g.pair_index)select day, pair_index,case pair_index when 331 then 'HYPE/USD' when 452 then 'HYPE1000/USD' when 453 then 'ANTH/USD' when 454 then 'ANTH1000/USD' when 455 then 'KNTQ/USD' when 456 then 'PEARL/USD' else 'pair_' || cast(pair_index as varchar) end pair,long_oi_usd, short_oi_usd, long_oi_usd + short_oi_usd total_oi_usd, long_oi_usd - short_oi_usd net_oi_usdfrom ff order by day, pair_index