Omniscia SaucerSwap Audit

SafeCast Code Style Findings

SafeCast Code Style Findings

SCT-01C: Inexistent Error Messages

TypeSeverityLocation
Code StyleSafeCast.sol:L12, L19, L26

Description:

The linked require checks have no error messages explicitly defined.

Example:

contracts/libraries/SafeCast.sol
12require((z = uint160(y)) == y);

Recommendation:

We advise each to be set so to increase the legibility of the codebase and aid in validating the require checks' conditions.

Alleviation (3248d1d2fdfa6e1e270ff27db8eefb13dcb55c40):

The SaucerSwap team evaluated this exhibit and opted to acknowledge it.

SCT-02C: Redundant Comparison of Value

Description:

The referenced conditional will evaluate that the value, a uint256 data type, is greater-than-or-equal-to the value of type(uint64).min which evaluates to 0.

Example:

contracts/libraries/SafeCast.sol
33function toInt64(uint256 value) internal pure returns (int64) {
34 require(
35 value >= type(uint64).min && value <= 2**63-1, 'sc64'
36 );
37 return int64(uint64(value));
38}

Recommendation:

Given that an unsigned number is guaranteed to be greater-than-or-equal-to zero, we advise the first part of the referenced conditional to be omitted, optimizing the function's gas cost.

Alleviation (3248d1d2fdfa6e1e270ff27db8eefb13dcb55c40):

The SaucerSwap team evaluated this exhibit and opted to acknowledge it.

SCT-03C: Suboptimal Representations of Numeric Maximums

Description:

The referenced require checks are meant to ensure that the y and value values being cast from the uint256 data type to the int256 data type and from the uint256 to the uint64 data type respectively will properly fit.

To ensure they are cast safely, they perform a comparison with value literals.

Example:

contracts/libraries/SafeCast.sol
26require(y < 2**255);

Recommendation:

We advise the type notation to be utilized and specifically type(int256).max and type(uint64).max respectively, greatly increasing the legibility of each statement whilst retaining the same gas cost.

To note, the comparator would also have to be adjusted to be inclusive for the first referenced instance.

Alleviation (3248d1d2fdfa6e1e270ff27db8eefb13dcb55c40):

The SaucerSwap team evaluated this exhibit and opted to acknowledge it.