Query editor
WITH fee_events AS (SELECTblock_time,block_number,-- First 32 bytes is the log typebytearray_to_uint256(bytearray_substring(data, 1, 32)) as log_type,CASE bytearray_to_uint256(bytearray_substring(data, 1, 32))WHEN 103 THEN 'FEE_PROPOSE'WHEN 203 THEN 'FEE_SET'WHEN 303 THEN 'FEE_CANCEL'END as event_type,-- The recipient address starts at position 96, and we want exactly 40 characters for the address-- Previously we were taking 25,40 which gave us 2 extra leading zeros'0x' || SUBSTRING(CAST(bytearray_substring(data, 97, 32) AS varchar), 27, 40) as fee_recipient,-- Min basis points is at offset 128bytearray_to_uint256(bytearray_substring(data, 129, 32)) as min_basis_points,-- Max basis points is at offset 160bytearray_to_uint256(bytearray_substring(data, 161, 32)) as max_basis_pointsFROM ethereum.logsWHEREtopic0 = 0xc580531c0d70bc831ea0e492033aa55ca4001fbe1b6d400060a026374db2afddAND contract_address = 0x99A055251170411c4505519aaeC57020B6129BB8AND bytearray_to_uint256(bytearray_substring(data, 1, 32)) IN (103, 203, 303) -- Only fee events)SELECTevent_type,fee_recipient,-- Convert basis points to percentages (100 basis points = 1%)CAST(min_basis_points AS double) / 100.0 as min_fee_percent,CAST(max_basis_points AS double) / 100.0 as max_fee_percent,block_number,block_time as timestampFROM fee_eventsORDER BY block_number DESCLIMIT 5;