Query editor
WITHweeth as (SELECTdate_trunc('day', evt_block_time) day,to as address,SUM(value/1e18) as amountFROMerc20_ethereum.evt_TransferWHERE contract_address = 0x35fA164735182de50811E8e2E824cFb9B6118ac2GROUP BY 1, 2UNION ALLSELECTdate_trunc('day', evt_block_time) day,"from" as address,-SUM(value/1e18) as amountFROMerc20_ethereum.evt_TransferWHERE contract_address = 0x35fA164735182de50811E8e2E824cFb9B6118ac2GROUP BY 1, 2),agg as (SELECTday,address as wallet_address,SUM(amount) as balanceFROMweethGROUP BY 1, 2),tokens_balances as (SELECTday,wallet_address,SUM(balance) OVER (PARTITION BY wallet_address ORDER BY day ASC) as cum_balance,LEAD(day, 1, current_timestamp) OVER (PARTITION BY wallet_address ORDER BY day ASC) as next_dayFROMagg),time_seq AS (SELECTsequence(CAST('2023-11-10' as timestamp),date_trunc('day', cast(now() as timestamp)),interval '1' day) AS time),days AS (SELECTtime.time AS dayFROM time_seqCROSS JOIN unnest(time) AS time(time)),