DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Code Improvement Report - KeeperProxy.sol

Summary

Inside KeeperProxy.sol, the function _absDiff is implemented as follows:

function _absDiff(uint256 a, uint256 b) internal pure returns (uint256 diff) {
if (a > b) return a - b;
else return b - a;
}

The else condition can be removed, and the code can be optimized using a ternary operator while maintaining the same functionality.

Vulnerability Details

The _absDiff function contains an unnecessary else condition, which can be refactored for better readability and efficiency.

Impact

  • Code Maintainability: The function can be simplified to improve readability.

  • Gas Optimization: Reducing unnecessary conditions can lead to slightly more efficient bytecode.

Tools Used

  • Manual Code Review

  • Solidity Static Analysis Tools

Recommendations

Solution: Using a Ternary Operator

Refactor _absDiff to remove unnecessary conditions and improve readability.

Updated Code

function _absDiff(uint256 a, uint256 b) internal pure returns (uint256 diff) {
return a > b ? (a - b) : (b - a);
}
Updates

Lead Judging Commences

n0kto Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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