Omniscia Olympus DAO Audit

FullMath Code Style Findings

FullMath Code Style Findings

FMH-01C: Outdated Implementation

TypeSeverityLocation
Gas OptimizationInformationalFullMath.sol:L33-L44

Description:

The FullMath contract is a copy of the homonymous Uniswap V2 library and implements an outdated version of the mulDiv function which does not contain the optimization of h == 0 as present in the Uniswap V2 equivalent.

Example:

contracts/libraries/FullMath.sol
33function mulDiv(
34 uint256 x,
35 uint256 y,
36 uint256 d
37) internal pure returns (uint256) {
38 (uint256 l, uint256 h) = fullMul(x, y);
39 uint256 mm = mulmod(x, y, d);
40 if (mm > l) h -= 1;
41 l -= mm;
42 require(h < d, 'FullMath::mulDiv: overflow');
43 return fullDiv(l, h, d);
44}

Recommendation:

We advise the optimization to be applied to reduce the gas cost involved with the library.

Alleviation:

The optimization of Uniswap V2 was properly integrated into the codebase.