Omniscia Steer Protocol Audit
StrategyRegistry Code Style Findings
StrategyRegistry Code Style Findings
SRY-01C: Optimization of Pointer Data Location
Type | Severity | Location |
---|---|---|
Gas Optimization | StrategyRegistry.sol:L303-L305, L308-L309, L312 |
Description:
The strategy
local variable is declared as memory
in the referenced instances, written two and then re-stored in the strategies
entry it originated from.
Example:
302// Retrieve the current strategy details303IStrategyRegistry.RegisteredStrategy memory strategy = strategies[304 tokenIdToExecBundle[_tokenId]305];306
307// Set the gas parameters308strategy.maxGasCost = _maxGasCost;309strategy.maxGasPerAction = _maxGasPerAction;310
311// Update the strategy details with the mutated struct312strategies[tokenIdToExecBundle[_tokenId]] = strategy;
Recommendation:
We advise it to be set as storage
instead rendering the re-assignment at the end redundant and optimizing the code's gas cost.
Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):
The pointer was adjusted to storage
with the final overwrite assignment being omitted, optimizing the gas cost of the setGasParameters
function significantly.
SRY-02C: Suboptimal Struct Declaration Style
Type | Severity | Location |
---|---|---|
Code Style | StrategyRegistry.sol:L126-L133 |
Description:
The linked declaration style of a struct is using index-based argument initialization.
Example:
126strategies[execBundle] = IStrategyRegistry.RegisteredStrategy(127 newStrategyTokenId,128 strategyName,129 strategyCreator,130 execBundle,131 maxGasCost,132 maxGasPerAction133);
Recommendation:
We advise the key-value declaration format to be utilized instead, greatly increasing the legibility of the codebase.
Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):
The key-value syntax is now properly utilized for the definition of the struct, greatly enhancing the readability of the creation statement.