Query editor
-- Enhanced query to track funds added and distributed from Allo Pool on Celo-- Uses ERC20 transfers to capture both direct and bundled funding transactionsWITH pool_transfers AS (SELECTet.evt_block_time as block_time,et.evt_block_number as block_number,et.evt_tx_hash as tx_hash,et."from" as token_sender,et."to" as token_recipient,et."value" as raw_amount,et."value" / POWER(10, 18) as amount_formatted,et.contract_address as token_address,'USDGLO' as token_symbol,-- Determine transaction type based on transfer directionCASEWHEN et."to" = 0x33080d27f98747f092021bdee4a006eda42ff2f7 THEN 'funding'WHEN et."from" = 0x33080d27f98747f092021bdee4a006eda42ff2f7 THEN 'distribution'ELSE 'other'END as transaction_type,-- Get the actual transaction initiatort."from" as transaction_initiator,t.success,t.gas_used,t.gas_priceFROM erc20_celo.evt_transfer etINNER JOIN celo.transactions tON et.evt_tx_hash = t.hashAND et.evt_block_number = t.block_numberWHEREet.contract_address = 0x4F604735c1cF31399C6E711D5962b2B3E0225AD3 -- USDGLO contractAND (et."to" = 0x33080d27f98747f092021bdee4a006eda42ff2f7 -- Funding: transfers TO poolOR et."from" = 0x33080d27f98747f092021bdee4a006eda42ff2f7 -- Distribution: transfers FROM pool)AND et."value" > 0AND t.success = trueAND et.evt_block_time >= TIMESTAMP '2024-01-01'),transfers_processed AS (SELECTblock_time,block_number,tx_hash,transaction_type,token_address,token_symbol,-- For funding: sender is the funder, recipient is pool-- For distribution: sender is pool, recipient is the grant recipientCASEWHEN transaction_type = 'funding' THEN token_senderELSE NULLEND as funder,CASEWHEN transaction_type = 'distribution' THEN token_recipientELSE NULLEND as recipient,token_sender,token_recipient,