Query editor
WITHtransfers AS (SELECTday,address,SUM("value") AS amountFROM(SELECTDATE_TRUNC('day', "evt_block_time") AS day,"to" AS address,cast("value" as INT256) as valueFROMerc20_ethereum.evt_TransferWHERE"contract_address" = 0x3af33bef05c2dcb3c7288b77fe1c8d2aeba4d789UNION ALLSELECTDATE_TRUNC('day', "evt_block_time") AS day,"from" AS address,-1 * cast("value" as INT256) as valueFROMerc20_ethereum.evt_TransferWHERE"contract_address" = 0x3af33bef05c2dcb3c7288b77fe1c8d2aeba4d789) AS txGROUP BY1,2),balances_with_gap_days AS (SELECTt.day,address,SUM(amount) OVER (PARTITION BYaddressORDER BYt.day) AS balance,/* balance per day with a transfer */ LEAD(DAY, 1, CURRENT_TIMESTAMP) OVER (PARTITION BYaddressORDER BYt.day) AS next_day /* the day after a day with a transfer */FROMtransfers AS t),days AS (SELECTDAYFROMUNNEST (SEQUENCE(TRY_CAST('2021-11-21' AS TIMESTAMP),CAST(CAST(CAST(DATE_TRUNC('day', CURRENT_TIMESTAMP) AS TIMESTAMP) AS TIMESTAMP) AS TIMESTAMP