Query editor
with hooked_pools as ( -- 84select i.evt_block_time as created_time-- , i.evt_tx_hash, COALESCE(tk0.symbol, cast(currency0 as varchar)) || '-' || COALESCE(tk1.symbol, cast(currency1 as varchar)) || ' ' || format('%,.2f', i.fee / 1e4) || '%' as pair, i.id as pool_id, currency0 as token0_address, currency1 as token1_address, i.fee/1e4 as fee_in_percent, hooksfrom uniswap_v4_sepolia.PoolManager_evt_Initialize ileft join tokens.erc20 tk0 on tk0.contract_address = i.currency0 -- and blockchain = 'sepolia'left join tokens.erc20 tk1 on tk1.contract_address = i.currency1 -- and blockchain = 'sepolia'where i.hooks in (0x1EC90889C6633A0d01932fbf83be93c22d194888 -- CSMM, 0x9067ABa6C8D31113910B41e386c4Ea52bAFBC080 -- Dynamic Fee (MoonFee), 0xE9FeDDd1C31C6F4AE05F58a1094daC58A5Aa4080 -- Override))-- 4888 CSMM | 01 00100010001000 _before_add_liquidity, _before_swap, _before_swap_returns_delta-- C080 Dynamic Fee | 11 00000010000000 _before_swap-- 4080 Override Fee | 01 00000010000000 _before_swap-- altho it's 16 bits, there are only 14 hook flags, so ignore the left 2 bits, conversion as (SELECTcase when hooks = 0xe9feddd1c31c6f4ae05f58a1094dac58a5aa4080 then 'OverrideFee'when hooks = 0x1ec90889c6633a0d01932fbf83be93c22d194888 then 'CSMM'when hooks = 0x9067aba6c8d31113910b41e386c4ea52bafbc080 then 'MoonFee'end as hooks,to_base(CAST(varbinary_to_uint256(substr(hooks, -2)) AS BIGINT), 2) AS bits16 -- take the last 2 bytes of the hook address, convert it to 16 bits to prep for hook flag binary mathFROM hooked_pools)select distincthooks,bits16,-- bitwise AND with the flag to see if the hook function is setbitwise_and(from_base(bits16, 2), from_base('0000000010000000', 2)) != 0 AS _before_swap,bitwise_and(from_base(bits16, 2), from_base('0000000000001000', 2)) != 0 AS _before_swap_returns_delta,bitwise_and(from_base(bits16, 2), from_base('0000100000000000', 2)) != 0 AS _before_add_liquidityFROM conversion-- test result checks out!