Query editor
-- Shogunwith date_series as (select timefrom unnest(sequence(timestamp'2021-06-30 00:00:00', CAST(NOW() AS TIMESTAMP), INTERVAL'1' DAY)) as date_table(time)), eth_staking_transfers as (SELECT date_trunc('day', evt_block_time) as time, "from" as address, -CAST(value as double)/1e18 as amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xe76c6c83af64e4c60245d8c7de953df673a7a33d and"from" <> 0xee6a649aa3766bd117e12c161726b693a1b2ee20UNION ALLSELECT date_trunc('day', evt_block_time) as time, "to" as address, CAST(value as double)/1e18 as amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xe76c6c83af64e4c60245d8c7de953df673a7a33d and"to" <> 0xee6a649aa3766bd117e12c161726b693a1b2ee20union allSELECT date_trunc('day', evt_block_time) as time, "from" as address, CAST(value as double)/1e18 as amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xe76c6c83af64e4c60245d8c7de953df673a7a33d and"to" = 0xee6a649aa3766bd117e12c161726b693a1b2ee20UNION ALLSELECT date_trunc('day', evt_block_time) as time, "to" as address, -CAST(value as double)/1e18 as amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xe76c6c83af64e4c60245d8c7de953df673a7a33d and"from" = 0xee6a649aa3766bd117e12c161726b693a1b2ee20), address_balance_for_all_days as (with all_chain_transfers as (SELECT time, address, SUM(amount) as amountFROM (select time, address, amountFROM eth_staking_transfers)GROUP BY 1, 2), balance_with_gap_days as (SELECT time, address, SUM(amount) OVER (PARTITION BY address ORDER BY time) as balance,lead(time, 1, NOW()) OVER (PARTITION BY address ORDER BY time) as next_dayFROM all_chain_transfers)SELECT d.time, address, SUM(balance) as balanceFROM balance_with_gap_days AS bJOIN date_series as d on b.time <= d.timeand d.time < b.next_dayGROUP BY 1, 2ORDER BY 1, 2)SELECT time, total_holders,IF(holders_change >= 0, holders_change, NULL) as green_change,IF(holders_change < 0, holders_change, NULL) as red_change,format('%d (%s%d)', total_holders, (CASEWHEN holders_change > 0 THEN '+'ELSE ''END), holders_change) as holding_change_formatFROM (