Query editor
with balance_adjusted_events as (select *,'0x' || ltrim(to_hex(topic1), '0') as mech_address,varbinary_to_uint256(varbinary_substring(data, 1 + (32 * 0), 32)) as deliveryRate,varbinary_to_uint256(varbinary_substring(data, 1 + (32 * 1), 32)) as balance,varbinary_to_uint256(varbinary_substring(data, 1 + (32 * 2), 32)) as rateDifffrom gnosis.logswhere contract_address = 0x21cE6799A22A3Da84B7c44a814a9c79ab1d2A50Dand topic0 = 0xd11af879a940c7604caa3933cb8a021f09a06692f4d05a5843fe06a003abed68),withdraw_event as ( select *,'0x' || ltrim(to_hex(topic1), '0') as mech_address,varbinary_to_uint256(varbinary_substring(data, 1 + (32 * 0), 32)) as amountfrom gnosis.logswhere contract_address = 0x21cE6799A22A3Da84B7c44a814a9c79ab1d2A50Dand topic0 = 0x9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb),accrued as (select mech_address, sum(deliveryRate) as accrued_feefrom balance_adjusted_eventsgroup by mech_address),collected as (select mech_address, sum(amount) as collected_feefrom withdraw_eventgroup by mech_address)selecta.mech_address,a.accrued_fee / 1e18 as accrued_fee,coalesce(c.collected_fee, 0) / 1e18 as collected_feefrom accrued aleft join collected con a.mech_address = c.mech_addressorder by accrued_fee desc