Root + Impact
Description
The constructor does not validate that the `_ReFi` token address is not the zero address, which could lead to the hook being deployed with an invalid token address, causing all pool validations and swap logic to fail.
**Description**:
* The normal behavior expects the constructor to validate that the ReFi token address is a valid non-zero address before storing it as an immutable value.
* The specific issue is that if `address(0)` is passed as `_ReFi`, the hook will be deployed with an invalid token address, causing `_beforeInitialize` validation to always fail (since no pool will contain the zero address as a token) and `_isReFiBuy` logic to malfunction.
**Root cause in the codebase**:
```solidity
constructor(IPoolManager _poolManager, address _ReFi) BaseHook(_poolManager) Ownable(msg.sender) {
ReFi = _ReFi;
}
```
No validation is performed to ensure `_ReFi != address(0)` before assigning it to the immutable `ReFi` variable.
Risk
Likelihood:
Impact:
-
* Hook deployed with invalid token address cannot be used with any pools
* All pool initializations will fail validation since no pool contains `address(0)` as a token
* Hook becomes completely non-functional and must be redeployed
* Gas wasted on deployment of unusable contract
Proof of Concept
The following demonstrates how a zero address can break the hook:
```solidity
address zeroAddress = address(0);
IPoolManager poolManager = ...;
ReFiSwapRebateHook hook = new ReFiSwapRebateHook(poolManager, zeroAddress);
PoolKey memory key;
key.currency0 = Currency.wrap(actualReFiToken);
key.currency1 = Currency.wrap(otherToken);
function _beforeInitialize(...) {
if (Currency.unwrap(key.currency0) != ReFi &&
Currency.unwrap(key.currency1) != ReFi) {
revert ReFiNotInPool();
}
}
```
**Step-by-step execution:**
1. Deployer calls constructor with `_ReFi = address(0)` (accidental or malicious)
2. Constructor stores `ReFi = address(0)` without validation
3. Hook is deployed but with invalid configuration
4. User attempts to initialize pool with actual ReFi token
5. `_beforeInitialize()` checks if pool contains `address(0)` (it never will)
6. Validation always fails, no pools can be initialized
7. Hook is completely non-functional, must be redeployed
Recommended Mitigation
Add zero address validation in the constructor:
```diff
// src/RebateFiHook.sol:48-50
+ error InvalidReFiAddress();
// src/RebateFiHook.sol:60-62
constructor(IPoolManager _poolManager, address _ReFi) BaseHook(_poolManager) Ownable(msg.sender) {
+ if (_ReFi == address(0)) {
+ revert InvalidReFiAddress();
+ }
ReFi = _ReFi;
}
```
**Explanation:**
- Validate that `_ReFi` is not the zero address before storing
- Revert with clear error message if zero address is provided
- Prevents deployment of non-functional hooks
- Ensures hook can only be deployed with valid token addresses
- Follows best practice of validating constructor parameters