Omniscia 0xPhase Audit

BalancerCalculationsFacet Static Analysis Findings

BalancerCalculationsFacet Static Analysis Findings

BCF-01S: Ineffectual Usage of Safe Arithmetics

TypeSeverityLocation
Language SpecificBalancerCalculationsFacet.sol:L85, L91

Description:

The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

balancer/diamond/BalancerCalculationsFacet.sol
84if (yieldBalance >= targetBalance) {
85 uint256 offset = yieldBalance - targetBalance;
86
87 arr[i].isPositive = true;
88 arr[i].offset = offset;
89 totalPositive += offset;
90} else {
91 uint256 offset = targetBalance - yieldBalance;
92
93 arr[i].isPositive = false;
94 arr[i].offset = offset;
95 totalNegative += offset;
96}

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.

Alleviation:

All referenced calculations are now safely performed within unchecked code blocks optimizing their gas cost.