Query editor
with--timetime AS(with time_seq as (SELECTsequence(cast('2023-07-26 00:00' as TIMESTAMP) --Gravita Launched on Arbitrum, date_trunc('day', cast(now() as TIMESTAMP)), interval '1' day) as time)SELECTtime.time as dayFROM time_seqCROSS JOIN unnest(time) as time(time)),balance as (SELECTdate_trunc('day', evt_block_time) as day, max(_balance / 1e18) as amount_balancefrom gravita_arbitrum.ActivePool_evt_ActivePoolAssetBalanceUpdatedwhere_asset = 0x5979D7b546E38E414F7E9822514be443A4800529 -- wstETH (Arbitrum)GROUP by 1order by 1 desc),balance_raw as (SELECTt.day, amount_balance, count(amount_balance) over (order by t.day) as _grpfrom time tleft join balance bon t.day = b.day),balance_fill as (selectday, max(amount_balance) over (partition by _grp order by day) as amount_balancefrom balance_raw b),-- Get the daily token prices in USDtoken_prices as (SELECT DISTINCTq.day,c.contract_address,decimals,symbol,FIRST_VALUE(q.price) OVER (PARTITION BY q.value_partitionORDER BY q.dayROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as priceFROM (