Omniscia Steadefi Audit

Math Code Style Findings

Math Code Style Findings

MHT-01C: Repetitive Value Literal

TypeSeverityLocation
Code StyleMath.sol:L11

Description:

The linked value literal is repeated across the codebase multiple times.

Example:

contracts/utils/Math.sol
11return ((maxValue - min(value0, value1)) * 10000) <= toleranceBps * maxValue;

Recommendation:

We advise it to be set to a constant variable instead optimizing the legibility of the codebase.

Alleviation (4325253d6de0ea91c1e9fb9e01d2e7e98f3d83a9):

The file is no longer present in the codebase, rendering this exhibit no longer applicable.

MHT-02C: Suboptimal Delta Evaluation

TypeSeverityLocation
Gas OptimizationMath.sol:L11

Description:

The Math::almostEqual function is meant to mandate a maximum tolerance in the deviance between the value0 and value1 input arguments. To achieve this, it assesses both the Math::max and Math::min between the two values sub-optimally.

Example:

contracts/utils/Math.sol
4library Math {
5 function almostEqual(
6 uint256 value0,
7 uint256 value1,
8 uint256 toleranceBps
9 ) internal pure returns (bool) {
10 uint256 maxValue = max(value0, value1);
11 return ((maxValue - min(value0, value1)) * 10000) <= toleranceBps * maxValue;
12 }
13
14 function max(uint256 a, uint256 b) internal pure returns (uint256) {
15 return a >= b ? a : b;
16 }
17
18 function min(uint256 a, uint256 b) internal pure returns (uint256) {
19 return a < b ? a : b;
20 }
21}

Recommendation:

We advise the code to instead introduce a new delta function that will perform the subtraction and yield the absolute delta between the two values, preferably in an unchecked code block further optimizing its execution cost.

Alleviation (4325253d6de0ea91c1e9fb9e01d2e7e98f3d83a9):

The file is no longer present in the codebase, rendering this exhibit no longer applicable.