Omniscia BlazeSwap Audit

FullMath Code Style Findings

FullMath Code Style Findings

FMH-01C: Inexistent Error Message

TypeSeverityLocation
Code StyleFullMath.sol:L44

Description:

The linked require check has no error message explicitly defined.

Example:

contracts/shared/libraries/FullMath.sol
44require(denominator > prod1);

Recommendation:

We advise one to be set so to increase the legibility of the codebase and aid in validating the require check's condition.

Alleviation:

The BlazeSwap team considered this exhibit but opted not to apply a remediation for it as they have stated they will not remediate any issues of minor severity and below.

FMH-02C: Potentially Suboptimal Deviation of Algorithm

Description:

The code implementation is derived off the smart contract implementation of Remco Bloemen as found at their blog, however, a notable difference is observed when it comes to the uint256 twos calculation as the code computes -denominator as type(uint256).max - denominator + 1 to accommodate for the latest Solidity version utilized.

Example:

contracts/shared/libraries/FullMath.sol
62// Factor powers of two out of denominator
63// Compute largest power of two divisor of denominator.
64// Always >= 1.
65uint256 twos = (type(uint256).max - denominator + 1) & denominator;

Recommendation:

We advise the original implementation to be re-applied to the code by replacing -denominator with -1 * int256(denominator) as this calculation should be more gas optimal and "truer" to the original implementation.

Alleviation:

The code was updated according to our recommendation better replicating the original author's algorithm and optimizing its gas cost.

FMH-03C: Redundant Validation Check

TypeSeverityLocation
Code StyleFullMath.sol:L35

Description:

The linked validation check is redundant as no error message accommodates it.

Example:

contracts/shared/libraries/FullMath.sol
33// Handle non-overflow cases, 256 by 256 division
34if (prod1 == 0) {
35 require(denominator > 0);
36 assembly {
37 result := div(prod0, denominator)
38 }
39 return result;
40}

Recommendation:

We advise either an error message to accommodate it or for it to be omitted from the codebase as division-by-zero naturally throws in assembly blocks.

Alleviation:

The BlazeSwap team considered this exhibit but opted not to apply a remediation for it as they have stated they will not remediate any issues of minor severity and below.