Omniscia Sova Network Audit

KycRulesHook Code Style Findings

KycRulesHook Code Style Findings

KRH-01C: Inefficient Function Body

Description:

The referenced statements will all ultimately result in a single bool variable being yielded.

Example:

src/hooks/KycRulesHook.sol
178function isAllowed(address account) public view returns (bool) {
179 // If explicitly denied, always return false (blacklist supersedes whitelist)
180 if (isAddressDenied[account] || !isAddressAllowed[account]) {
181 return false;
182 }
183
184 // If explicitly allowed, return true
185 return true;
186}

Recommendation:

We advise the code to be revised to a single return statement that yields the value of !isAddressDenied[account] && isAddressAllowed[account], optimizing the code's gas cost.

Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):

The function's body was optimized as advised, directly yielding the conditional's value efficiently.

KRH-02C: Redundant Code Duplication

TypeSeverityLocation
Gas OptimizationKycRulesHook.sol:
I-1: L104-L109
I-2: L129-L134
I-3: L154-L159

Description:

The referenced statements are a direct replication of the non-batch variants of each respective function.

Example:

src/hooks/KycRulesHook.sol
94/**
95 * @notice Batch allow addresses to transfer/receive tokens
96 * @param accounts Array of addresses to allow
97 */
98function batchAllow(address[] calldata accounts) external onlyRoles(roleManager.KYC_OPERATOR()) {
99 uint256 length = accounts.length;
100 if (length == 0) revert InvalidArrayLength();
101
102 for (uint256 i = 0; i < length;) {
103 address account = accounts[i];
104 if (account == address(0)) revert ZeroAddress();
105 if (isAddressDenied[account]) revert AddressAlreadyDenied();
106
107 isAddressAllowed[account] = true;
108
109 emit AddressAllowed(account, msg.sender);
110
111 unchecked {
112 ++i;
113 }
114 }
115
116 emit BatchAddressAllowed(length, msg.sender);
117}

Recommendation:

We advise each non-batch function's statements to be relocated to an internal function that can be invoked by both the normal and batch function variants, optimizing the code's bytecode size and maintainability.

Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):

The code of the overall contract was refactored as advised, introducing internal function variants in use by both the batch and non-batch operation counterparts.