Omniscia Bonq Audit

external-price-feed Code Style Findings

external-price-feed Code Style Findings

EXT-01C: Inefficient Loop Limit Evaluation

Description:

The linked for loop evaluates its limit inefficiently on each iteration.

Example:

contracts/external-price-feed.sol
99for (uint256 i = 1; i < snapshots.length; i++) {

Recommendation:

We advise the statements within the for loop limit to be relocated outside to a local variable declaration that is consequently utilized for the evaluation to significantly reduce the codebase's gas cost. We should note the same optimization is applicable for storage reads present in such limits as they are newly read on each iteration (i.e. length members of arrays in storage).

Alleviation:

The Bonq Protocol team has NOT made any changes in the source code to apply this optimization and as such, we consider it as acknowledged.

EXT-02C: Inefficient Ternary Operators

Description:

The linked ternary operators are redundant as a modulo (%) mechanism can be utilized instead.

Example:

contracts/external-price-feed.sol
80shift = shift + 1 == PRICE_AVERAGE_PERIOD ? 0 : shift + 1;

Recommendation:

We advise the addition result to be normalized via a modulo operation with the value of PRICE_AVERAGE_PERIOD thus achieving the same logical result.

Alleviation:

The Bonq Protocol team has NOT made any changes in the source code to apply this optimization and as such, we consider it as acknowledged.