RebateFi Hook

First Flight #53
Beginner FriendlyDeFi
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Duplicate Logic Statement Causing Misunderstanding

Description

  • The RebateFiHook.sol::_beforeInitialize() function contains a duplicate logic check in the if statement and can be safely removed.

function _beforeInitialize(address, PoolKey calldata key, uint160) internal view override returns (bytes4) {
if (Currency.unwrap(key.currency1) != ReFi &&
@> Currency.unwrap(key.currency1) != ReFi) {
revert ReFiNotInPool();
}
return BaseHook.beforeInitialize.selector;
}

Risk

Likelihood:

  • High as this duplicated check is always evaluated, though it does not affect the contract's behaviour.

Impact:

  • Low as this is a code quality issue with no direct impact on functionality or security.

Proof of Concept

Past the following into a test contract and run forge test --mt testCall in the terminal.

contract PoC is Test {
address constant ReFiTest = address(0x123);
function _beforeInitializeTest(address currencyx1) internal pure returns (bool) {
if (currencyx1 != ReFiTest && currencyx1 != ReFiTest) {
revert("ReFiNotInPool");
}
return true;
}
function testCall() external pure {
assertTrue(_beforeInitializeTest(ReFiTest));
}
}

Recommended Mitigation

Refactor the function to remove the duplicate condition, as shown below, to improve readability and maintainability.

function _beforeInitialize(address, PoolKey calldata key, uint160) internal view override returns (bytes4) {//@audit-issue no checking of parameters
- if (Currency.unwrap(key.currency1) != ReFi &&
- Currency.unwrap(key.currency1) != ReFi) {
+ if (Currency.unwrap(key.currency1) != ReFi) {
revert ReFiNotInPool();
}
return BaseHook.beforeInitialize.selector;
}
Updates

Lead Judging Commences

chaossr Lead Judge
9 days ago
chaossr Lead Judge 8 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!