_beforeInitialize Prevents Pool CreationThe _beforeInitialize hook is designed to ensure that any new liquidity pool using this hook includes the ReFi token.
However, the implementation contains a logical flaw: if (Currency.unwrap(key.currency1) != ReFi && Currency.unwrap(key.currency1) != ReFi). It incorrectly checks key.currency1 twice and fails to check key.currency0 at all.
As a result, the hook will incorrectly revert and prevent the creation of any pool where ReFi is currency0, which occurs whenever the other token's address is alphabetically greater than the ReFi token's address.
Likelihood:
This bug will prevent the creation of any Uniswap v4 pool using this hook where the ReFi token's address is lower than the other token's address, a condition which makes ReFi the currency0 in the PoolKey.
Impact:
The hook fails its primary purpose of allowing ReFi to be paired with any other token. It arbitrarily blocks the creation of valid liquidity pools, limiting the utility and reach of the ReFi ecosystem on Uniswap v4.
This creates a significant barrier to liquidity providers who wish to create pools with common tokens that happen to have a higher address value than the ReFi token.
The provided test case demonstrates that pool initialization reverts when ReFi is currency0. The hook should allow this, but due to the bug, it reverts.
The logic should be corrected to check both currency0 and currency1, and it should revert only if neither of them is the ReFi token.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.