Query editor
WITH mints_and_burns AS (SELECT-- Convert hex data to numeric valuebytearray_to_uint256(data) AS raw_value,-- Extract the "from" address (topic1) and "to" address (topic2)-- We slice the 32-byte topic to get the 20-byte addressbytearray_substring(topic1, 13, 20) AS from_address,bytearray_substring(topic2, 13, 20) AS to_addressFROM celo.logsWHERE contract_address = 0x34C11A932853Ae24E845Ad4B633E3cEf91afE583-- Filter for Transfer events only (Topic0 signature)AND topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef),supply_sum AS (SELECT-- Sum Mints: Where "from" is the zero addressSUM(CASEWHEN from_address = 0x0000000000000000000000000000000000000000THEN raw_valueELSE CAST(0 AS uint256)END) AS total_minted,-- Sum Burns: Where "to" is the zero addressSUM(CASEWHEN to_address = 0x0000000000000000000000000000000000000000THEN raw_valueELSE CAST(0 AS uint256)END) AS total_burnedFROM mints_and_burns)SELECT-- Calculate Current Supply(total_minted - total_burned) / 1e18 AS total_supply,-- Hardcoded Cap (22 Million)22000000 AS cap,-- Result: Supply / Cap((total_minted - total_burned) / 1e18) / 22000000 AS supply_cap_ratio,-- Percentage(((total_minted - total_burned) / 1e18) / 22000000) * 100 AS percentage_filledFROM supply_sum