Query editor
WITH official_pools AS (SELECT pool, feeFROM uniswap_v3_ethereum.factory_evt_poolcreatedWHERE contract_address = 0x1F98431c8aD98523631AE4a59f267346ea31F984),latest_events AS (SELECTe.contract_address AS pool,e.feeProtocol0New AS fee_protocol0,e.feeProtocol1New AS fee_protocol1,row_number() OVER (PARTITION BY e.contract_addressORDER BY e.evt_block_number DESC, e.evt_index DESC) AS rnFROM uniswap_v3_ethereum.uniswapv3pool_evt_setfeeprotocol eINNER JOIN official_pools p ON p.pool = e.contract_address),current_state AS (SELECT pool, fee_protocol0, fee_protocol1FROM latest_eventsWHERE rn = 1)SELECTp.fee / 100.0 AS pool_fee_bps,coalesce(c.fee_protocol0, 0) AS fee_protocol0,coalesce(c.fee_protocol1, 0) AS fee_protocol1,CASEWHEN coalesce(c.fee_protocol0, 0) <> 0 OR coalesce(c.fee_protocol1, 0) <> 0 THEN 'protocol_fee_on'ELSE 'protocol_fee_off'END AS protocol_fee_status,count(*) AS poolsFROM official_pools pLEFT JOIN current_state c ON c.pool = p.poolGROUP BY 1, 2, 3, 4ORDER BY pool_fee_bps, protocol_fee_status, fee_protocol0, fee_protocol1