Query editor
WITH-- select the events we needstaking_events AS (SELECTaddress,block_time as event_time,slp_delta,locked_untilFROMquery_2667500WHEREslp_delta>0 AND -- only look at ilv stakeslocked_until > from_unixtime(0) AND -- ignore events without locking like unstakeis_claim = FALSE -- only look at staking events),-- get a list of timestamps we want a number fortime_seq AS (SELECT range.time timeFROM unnest(sequence(cast(cast('{{Date from}}' AS timestamp) as date), cast(current_timestamp as date) + interval '365' day, (interval '1' day))) as range(time)),-- calculate the sum of the staked tokens, locked on each timestamp.accumulated AS (SELECTw.time,case when w.time <= now() then sum(events.slp_delta)/power(10,18) else 0 end slp_locked,case when w.time > now() then sum(events.slp_delta)/power(10,18) else 0 end slp_locked_futureFROMtime_seq wJOIN-- join with all staking events that are still locked.staking_events events ON w.time >= events.event_time AND w.time <= events.locked_untilGROUP BY w.time)SELECT * from accumulated