Omniscia Moby Audit

Controller Code Style Findings

Controller Code Style Findings

CRE-01C: Inefficient Iterator Type

Description:

The EVM is built to operate on 256-bit data slots and is inefficient when dealing with any data type less than that.

The referenced for loop utilizes a uint8 iterator unnecessarily.

Example:

contracts/Controller.sol
152for (uint8 i = 0; i < 3; i++) {
153 vaultToVaultUtil[_vaults[i]] = _vaultUtils[i];
154}

Recommendation:

We advise its iterator to be set as uint256, optimizing each loop's increment cost.

Alleviation (b02fae335f62cc1f5f4236fb4d982ad16a32bd26):

The iterator type has been updated to uint256, optimizing the code's gas cost.

CRE-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/Controller.sol
152for (uint8 i = 0; i < 3; 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.

CRE-03C: Redundant Conditional Evaluation

Description:

The referenced conditional will redundantly evaluate that diff > sVaultThresholdDays which is guaranteed by the preceding if conditional.

Example:

contracts/Controller.sol
201if (diff <= sVaultThresholdDays) {
202 return (0, vaults[0]);
203} else if (diff > sVaultThresholdDays && diff <= mVaultThresholdDays) {
204 return (1, vaults[1]);
205}

Recommendation:

We advise that segment of the conditional to be omitted, optimizing its gas cost.

Alleviation (b02fae335f62cc1f5f4236fb4d982ad16a32bd26):

The redundant conditional evaluation portion has been omitted, optimizing the statement's gas cost.

CRE-04C: Repetitive Value Literal

Description:

The linked value literal is repeated across the codebase multiple times.

Example:

contracts/Controller.sol
34address[3] public vaults;

Recommendation:

We advise it to be set to a constant variable instead optimizing the legibility of the codebase.

Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):

The Moby team stated that it is not possible to define the vault value as constant, however, we believe they have misinterpreted the exhibit.

The exhibit states that the value literal 3 should be set as a constant, rendering it to remain acknowledged.