Query editor
WITH all_transfers AS (SELECTDATE_TRUNC('day', block_time) AS date,block_time,topic1 as from_address,topic2 as to_address,VARBINARY_TO_UINT256(data) / 1e18 AS token_amountFROM monad_testnet.logsWHEREcontract_address = 0x3a98250F98Dd388C211206983453837C8365BDc1 /* shMON contract */AND topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef),wallet_daily_changes AS (SELECTdate,to_address as wallet_address,SUM(token_amount) as daily_changeFROM all_transfersWHERE to_address != 0x0000000000000000000000000000000000000000000000000000000000000000GROUP BY date, to_addressUNION ALLSELECTdate,from_address as wallet_address,-SUM(token_amount) as daily_changeFROM all_transfersWHERE from_address != 0x0000000000000000000000000000000000000000000000000000000000000000GROUP BY date, from_address),wallet_net_daily_changes AS (SELECTdate,wallet_address,SUM(daily_change) as net_daily_changeFROM wallet_daily_changesGROUP BY date, wallet_address),wallet_cumulative_balances AS (SELECTdate,wallet_address,net_daily_change,SUM(net_daily_change) OVER (PARTITION BY wallet_addressORDER BY dateROWS UNBOUNDED PRECEDING) as cumulative_balanceFROM wallet_net_daily_changes),current_balances AS (SELECTwallet_address,cumulative_balance as current_balanceFROM wallet_cumulative_balancesWHERE date = (SELECT MAX(date) FROM wallet_cumulative_balances)AND cumulative_balance > 0),balance_1d_ago AS (