Omniscia Moby Audit
Controller Code Style Findings
Controller Code Style Findings
CRE-01C: Inefficient Iterator Type
Type | Severity | Location |
---|---|---|
Gas Optimization | Controller.sol:L152 |
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:
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
Type | Severity | Location |
---|---|---|
Gas Optimization | Controller.sol:L152, L546 |
Description:
The linked for
loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X
).
Example:
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
Type | Severity | Location |
---|---|---|
Gas Optimization | Controller.sol:L203 |
Description:
The referenced conditional will redundantly evaluate that diff > sVaultThresholdDays
which is guaranteed by the preceding if
conditional.
Example:
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
Type | Severity | Location |
---|---|---|
Code Style | Controller.sol:L34, L136, L137, L152, L185 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
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.