Omniscia Moby Audit
FastPriceFeed Code Style Findings
FastPriceFeed Code Style Findings
FPF-01C: Inexistent Usage of Existing Calculation
Type | Severity | Location |
---|---|---|
Gas Optimization | FastPriceFeed.sol:L146, L147 |
Description:
The referenced statements will re-calculate the value of the local index
variable redundantly.
Example:
142uint256 index = i * 8 + j;143
144if (index >= _optionTokenIds.length) { return; }145
146uint256 optionTokenId = _optionTokenIds[i * 8 + j];147uint256 requestIndex = _requestIndexes[i * 8 + j];
Recommendation:
We advise the index
variable to be utilized properly, optimizing their gas cost.
Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):
The index
variable is correctly re-used in place of the referenced re-calculations, optimizing each loop's gas cost.
FPF-02C: Loop Iterator Optimizations
Type | Severity | Location |
---|---|---|
Gas Optimization | FastPriceFeed.sol:L74, L136, L141 |
Description:
The linked for
loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X
).
Example:
74for (uint256 i = 0; i < _optionTokenIds.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.
FPF-03C: Redundant Validation of Literal
Type | Severity | Location |
---|---|---|
Gas Optimization | FastPriceFeed.sol:L39-L40, L42 |
Description:
The FastPriceFeed::initialize
function will validate a known value literal which is inefficient.
Example:
39uint256 _updateDuration = 60; // 60s40require(_updateDuration <= MAX_UPDATE_DURATION, "FastPriceFeed: invalid _updateDuration");41
42updateDuration = _updateDuration;
Recommendation:
We advise the validation to be omitted, and the updateDuration
variable to be assigned to 60
directly.
Alleviation (b02fae335f62cc1f5f4236fb4d982ad16a32bd26):
The redundant validation of the value literal has been safely removed from the codebase, optimizing it in the process.