Query editor
-- Query to analyze Optimism DAO voter participation-- Using the token holders approach that's already working-- Filtering for wallets with active balance > 1 OPWITH-- Calculate token transfers (from your working query)transfers AS (SELECTDAY,address,token_address,SUM(amount)/1e18 AS amountFROM(SELECTDATE_TRUNC('day', evt_block_time) AS DAY,"to" AS address,tr.contract_address AS token_address,CAST(value AS int256) AS amountFROMerc20_optimism.evt_Transfer AS trWHEREcontract_address = 0x4200000000000000000000000000000000000042UNION ALLSELECTDATE_TRUNC('day', evt_block_time) AS DAY,"from" AS address,tr.contract_address AS token_address,- CAST(value AS int256) AS amountFROMerc20_optimism.evt_Transfer AS trWHEREcontract_address = 0x4200000000000000000000000000000000000042) AS tGROUP BY1, 2, 3),-- Calculate balances with gap daysbalances_with_gap_days AS (SELECTt.day,address,SUM(amount) OVER (PARTITION BYaddressORDER BYt.day) AS balance,LEAD(DAY, 1, CURRENT_TIMESTAMP) OVER (PARTITION BYaddressORDER BYt.day) AS next_dayFROMtransfers AS t),-- Generate all days