In the ReFiSwapRebateHook::_beforeInitialize function, there is an if statement which tries to make sure the ReFi token is one of the tokens forming the LP token pair.
However, due to the apparent typo, it only compares the second token (Currency.unwrap(key.currency1)) with ReFi token, twice.
Therefore, it passes through, if and only if ReFi token is the second token in the pair. It reverts even if the first token (Currency.unwrap(key.currency0) is ReFi.
Likelihood: High
It can happen literally for half of the times the _beforeInitialize function gets executed. It reverts depending on the position of the ReFi token in the pair (whether it is the first token or the second one). The position of the tokens in the pair are decided based on the ascending order of their addresses.
Impact: High
This is a problem in the implementation of the business logic. While it is supposed to revert only for LP token pairs where none of them is ReFi token, it reverts even if the first token in the pair is ReFi. It severely disrupts the protocol.
Please copy/paste the following code (contract including the test function) to the end of the test file.
Then, run the test function using the command below.
forge test --mt test_theRefiTokenCannotBeTheFirstInThePair -vvvv
You will see the revert with the custom error (ReFiNotInPool) in the output.
The solution is quite easy. Just make the following adjustments.
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.