Query editor
WITH maker_rebates AS (SELECTCONCAT('0x',SUBSTRING(LOWER(TRY_CAST(topic2 AS VARCHAR)), 27, 40)) AS wallet,SUM(CAST(varbinary_to_uint256(data) AS decimal(38,0)) / POWER(10, 6)) AS total_maker_rebatesFROM polygon.logsWHEREcontract_address IN (FROM_HEX('2791Bca1f2de4661ED88A30C99A7a9449Aa84174'), -- USDC.eFROM_HEX('c011a7e12a19f7b1f670d46f03b03f3342e82dfb') -- PUSD)AND topic0 = FROM_HEX('ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef') -- TransferAND topic1 = FROM_HEX('0000000000000000000000003a9418b2651c8164db5ebc56f12008137865e0f7') -- Maker rebates senderGROUP BY 1),total_rebates AS (SELECTSUM(total_maker_rebates) AS total_maker_rebates_all_walletsFROM maker_rebates)SELECTROW_NUMBER() OVER (ORDER BY mr.total_maker_rebates DESC) AS serial_no,mr.wallet,mr.total_maker_rebates,(mr.total_maker_rebates / tr.total_maker_rebates_all_wallets) * 100 AS percent_of_totalFROM maker_rebates mrCROSS JOIN total_rebates trORDER BY mr.total_maker_rebates DESC;