Omniscia Euler Finance Audit

SwapHandlerCombinedBase Code Style Findings

SwapHandlerCombinedBase Code Style Findings

SHC-01C: Illegible Value Literal

Description:

The 20 + (20 * 23) literal should be represented via a contract-level constant variable that is utilized in the require statement thus optimizing its gas cost.

Example:

contracts/swapHandlers/SwapHandlerCombinedBase.sol
31require(path.length >= 40 && path.length < 20 + (20 * 23), "SwapHandlerPayloadBase: secondary path format");

Recommendation:

We advise this to be done so increasing the legibility of the codebase and potentially optimizing the require path evaluation cost depending on the Solidity compiler utilized.

Alleviation:

The Euler Finance team opted to retain the literals in place as they did not observe a change in the final gas cost of the function, however, they have significantly increased the comments surrounding the require check to properly describe what the literal values represent. As a result, we consider this exhibit adequately addressed.

SHC-02C: Ineffectual Usage of Safe Arithmetics

Description:

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

Example:

contracts/swapHandlers/SwapHandlerCombinedBase.sol
75for(uint i; i < addressPathSize; ++i) {
76 addressPath[i] = toAddress(path, i * 20);
77}

Recommendation:

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

Alleviation:

The for loop including the iterator increment and the iterator multiplication within the statement of the for loop has been wrapped in an unchecked directive thus alleviating this exhibit in full.