Omniscia Colony Lab Audit

TimedValuesStorage Code Style Findings

TimedValuesStorage Code Style Findings

TVS-01C: Inefficient Loop Length Evaluation

Description:

The linked for loop limits are inefficiently evaluated as they are retrieved from storage on each iteration.

Example:

contracts/Staking/TimedValuesStorage.sol
103for (uint i = 0; i < realDepositsLength[account]; i++) {

Recommendation:

We advise their limits to instead be stored to a local variable that is consequently utilized for the for loop limit to significantly reduce their gas cost.

Alleviation:

The Colony Lab team considered this exhibit but opted not to apply a remediation for it in the current iteration of the codebase.

TVS-02C: Inefficient break Statement

Description:

The linked break statement will cause the code to always return.

Example:

contracts/Staking/TimedValuesStorage.sol
60for (uint i = 0; i < realDepositsLength[account]; i++) {
61 if (deposits[account][i].timestamp > maxTimestamp) {
62 break;
63 }
64
65 enoughValue += deposits[account][i].value;
66
67 if (enoughValue >= minValue) {
68 return true;
69 }
70}
71
72return false;

Recommendation:

We advise the relevant value to be directly returned instead optimizing each function's execution cost.

Alleviation:

The Colony Lab team considered this exhibit but opted not to apply a remediation for it in the current iteration of the codebase.