Omniscia Astrolab DAO Audit
StrategyV5Agent Code Style Findings
StrategyV5Agent Code Style Findings
SVA-01C: Inefficient Iterator Type
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | StrategyV5Agent.sol:L125, L142 |
Description:
The referenced for
loops utilize a uint8
variable as an iterator which is inefficient.
Example:
142for (uint8 i = 0; i < _rewardTokens.length; i++) {
Recommendation:
As the EVM is built to operate on 32-byte (256-bit) data types, we advise the iterator types to be bumped to uint256
, optimizing their gas cost.
Alleviation (59b75fbee1):
While the referenced iterator types have been optimized, the StrategyV5Agent::_setInputWeights
function continues to utilize a uint8
iterator type which is inefficient.
Alleviation (efbeab6478):
The uint8
iterator in the StrategyV5Agent::_setInputWeights
function has been updated accordingly, rendering this exhibit fully addressed.
SVA-02C: Loop Iterator Optimizations
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | StrategyV5Agent.sol:L51, L55, L125, L142 |
Description:
The linked for
loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X
).
Example:
51for (uint256 i = 0; i < rewardLength; 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 (59b75fbee1d8f3dee807c928f18be41c58b904e1):
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.