Query editor
withscope as (withdeltas as (selectdate_trunc('week', evt_block_time) period,case when "to" = 0xf861483fa7E511fbc37487D91B6FAa803aF5d37c then cast(value as int256) else -cast(value as int256) end as delta_bnfrom frax_ethereum.FPI_evt_Transferwhere"to" = 0xf861483fa7E511fbc37487D91B6FAa803aF5d37cor "from" = 0xf861483fa7E511fbc37487D91B6FAa803aF5d37c -- transfers from an to the curve frax-fpi curve pool),lowest_date as (select cast(date_trunc('week', min(period)) as timestamp) as period from deltas),_periods_seq as (select sequence((select period from lowest_date), date_trunc('week', cast(now() as timestamp)), interval '7' day) as period)-- stolen from https://dune.com/queries/1764158,periods_seq as (selectperiods.period as periodfrom _periods_seqcross join unnest(period) as periods(period))selectperiod, cast(sum(sum(delta_bn)) over (order by period) as double) / pow(10, 18) as fpi_balance_dec, cast(sum(delta_bn) as double) / pow(10, 18) as delta_decfrom (select * from deltas b union all select *, null from periods_seq) q group by period)select * from scope