Omniscia Boson Protocol Audit
GroupBase Code Style Findings
GroupBase Code Style Findings
GBE-01C: Repetitive Invocations of Getter Functions
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | GroupBase.sol:L56, L59, L155, L161 |
Description:
The linked statements repetitively invoke the same getter functions whilst their return values remain unchanged.
Example:
contracts/protocol/bases/GroupBase.sol
55// add to groupIdByOffer mapping56protocolLookups().groupIdByOffer[_group.offerIds[i]] = groupId;57
58// Set index mapping. Should be index in offerIds + 159protocolLookups().offerIdIndexByGroup[groupId][_group.offerIds[i]] = i + 1;
Recommendation:
We advise the getter functions to be invoked once and their results to be stored to local variables that are consequently utilized optimizing the gas cost of the statements significantly.
Alleviation (44009967e4f68092941d841e9e0f5dd2bb31bf0b):
The protocol lookups are now correctly cached to local variable declarations thus optimizing the codebase's gas cost.