Omniscia Boson Protocol Audit

TwinHandlerFacet Code Style Findings

TwinHandlerFacet Code Style Findings

THF-01C: Repetitive Invocations of Getter Function

TypeSeverityLocation
Gas OptimizationTwinHandlerFacet.sol:L80, L81

Description:

The linked statements repetitively invoke the same getter function whilst its return value remains unchanged.

Example:

contracts/protocol/facets/TwinHandlerFacet.sol
80TokenRange[] storage twinRanges = protocolLookups().twinRangesBySeller[sellerId][twin.tokenAddress];
81uint256[] storage twinIdsByTokenAddressAndBySeller = protocolLookups().twinIdsByTokenAddressAndBySeller[

Recommendation:

We advise the getter function to be invoked once and its result to be stored to a local variable that is 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.