Query editor
WITH events AS (SELECT "group" AS g, evt_block_time AS t, 'activated' AS aFROM staked_celo.defaultstrategy_evt_groupactivatedUNION ALLSELECT "group", evt_block_time, 'removed'FROM staked_celo.defaultstrategy_evt_groupremoved),active_groups AS (SELECT gFROM eventsGROUP BY gHAVING max_by(a, t) = 'activated'),latest_per_group AS (SELECT"group" AS g,max_by(output_0, call_block_time) AS receivable_wei,max(call_block_time) AS as_ofFROM staked_celo.manager_call_getreceivablevotesforgroupWHERE call_block_date >= date('2025-01-01')AND call_success = trueGROUP BY "group")SELECTSUM(CAST(lpg.receivable_wei AS double) / 1e18) AS total_capacity_celo,MAX(lpg.as_of) AS as_ofFROM latest_per_group lpgJOIN active_groups ag ON ag.g = lpg.g