Query editor
with grants_approved as (selectcast(cgp_id as int) as cgp_id, proposal, from_hex(substring(address, 3)) as recipient, sum(amount_celo) as amount_approvedfrom query_5084491where address like '0x%' and length(address) = 42group by 1,2,3), grants_claimed as (SELECTrecipient,SUM(total_claimed) as total_claimedFROM (SELECTt."to" as recipient,SUM(amount) as total_claimedFROM tokens.transfers tWHERE t.contract_address = from_hex('471ece3750da237f93b8e339c536989b8978a438')AND t."from" = from_hex('d533ca259b330c7a88f74e000a3faea2d63b7972')AND t."to" NOT IN (from_hex('91606ba0b9a5527Bf384001B94Ab908c9054C677'),from_hex('275d5828bf7e5aaf51bf8ef2f0668ac4a98f0d23'),from_hex('1b98202492Bd78bB042523674EEC19cd0AC50f96'),from_hex('083ab4a0C5d6CC899008bD5e8E1312379d629320'),from_hex('9138AD934D63a81A3BD10e5E6a2511dB13C1C1CA'),from_hex('f3D173c38E4Ee44Afcf65692D5E02D350F0f2CE2'),from_hex('da2069f47D252121c2288301D6EF50B87220A693'),from_hex('0D8b5f1CD567656b6Ad4c88e8F082F1f694e5Bb5'),from_hex('5374cF78F82E3610f9678bD7AF617785FF6c578a'),from_hex('5374cF78F82E3610f9678bD7AF617785FF6c578a'),from_hex('9C257bDC314dc516e673728D70F45444F6e22412'),from_hex('275D5828bF7e5aaf51Bf8EF2f0668ac4a98F0d23'),from_hex('da2069f47D252121c2288301D6EF50B87220A692'),from_hex('9cf769bcce5e750534d88b251fb5b58da9776190'),from_hex('6f62e32cae54d66e234f0d1e27be7e33896dc4c1'))GROUP BY t."to"UNION ALLSELECTfrom_hex(substring(address, 3)) as recipient,amount_celo as total_claimedFROM query_5193638) as subGROUP BY recipient),allocations as (selectdistinctg.recipient, g.cgp_id, g.proposal, g.amount_approved, c.total_claimed, sum(g.amount_approved) over (partition by g.recipient order by g.cgp_idrows between unbounded preceding and 1 preceding) as approvals_before, least(