The _absDiff
function in KeeperProxy can be optimized using unchecked math since the conditional logic already prevents underflows, leading to gas savings without compromising safety.
Current implementation:
The function is safe by design because:
Conditional check ensures larger number is always subtracted from
Both inputs are uint256, preventing overflow scenarios
Function is used only in price validation contexts
Severity: Gas Optimization (Low)
Effects:
Gas savings: ~40-100 per operation
No security implications
Cumulative savings with frequent price checks
Operation | Before | After | Savings |
---|---|---|---|
Single Call | ~150 gas | ~50 gas | ~100 gas |
Price Check (3 tokens) | ~450 gas | ~150 gas | ~300 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.
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.