Omniscia Moby Audit

OptionsMarket Code Style Findings

OptionsMarket Code Style Findings

OMT-01C: Inefficient mapping Lookups

Description:

The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.

Example:

contracts/OptionsMarket.sol
141return (options[_id].underlyingAssetIndex, indexToUnderlyingAsset[options[_id].underlyingAssetIndex], options[_id].expiry, options[_id].strikePrice, options[_id].notionalVolume);

Recommendation:

As the lookups internally perform an expensive keccak256 operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of the mapping in case of primitive types or holds a storage pointer to the struct contained.

Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):

All referenced inefficient mapping lookups have been optimized to the greatest extent possible, significantly reducing the gas cost of the functions the statements were located in.

OMT-02C: Loop Iterator Optimizations

Description:

The linked for loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X).

Example:

contracts/OptionsMarket.sol
100for (uint256 i = 0; i < _length; i++) {

Recommendation:

We advise the increment / decrement operations to be performed in an unchecked code block as the last statement within each for loop to optimize their execution cost.

Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):

The referenced loop iterator increment statements have been relocated at the end of each respective for loop's body and have been unwrapped in an unchecked code block, optimizing their gas cost.

OMT-03C: Redundant Parenthesis Statement

Description:

The referenced statement is redundantly wrapped in parenthesis (()).

Example:

contracts/OptionsMarket.sol
155return (options[_id].isActive);

Recommendation:

We advise them to be safely omitted, increasing the legibility of the codebase.

Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):

The redundant parenthesis in the referenced statement have been safely omitted.