Omniscia LimeChain Audit
GovernanceV2Facet Code Style Findings
GovernanceV2Facet Code Style Findings
GVF-01C: Inefficient Administrator Lookup
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | GovernanceV2Facet.sol:L41, L51 |
Description:
The updateMember
function redundantly looks up the administrator of a member on each iteration.
Example:
contracts/facets/GovernanceV2Facet.sol
40for (uint256 i = 0; i < LibRouter.nativeTokensCount(); i++) {41 address accountAdmin = LibGovernance.memberAdmin(_account);42 address token = LibRouter.nativeTokenAt(i);43 uint256 claimableFees = LibFeeCalculator.claimReward(44 _account,45 token46 );47 IERC20(token).safeTransfer(accountAdmin, claimableFees);48}49
50for (uint256 i = 0; i < LibPayment.tokensCount(); i++) {51 address accountAdmin = LibGovernance.memberAdmin(_account);52 address token = LibPayment.tokenAt(i);53 uint256 claimableFees = LibFeeCalculator.claimReward(54 _account,55 token56 );57 IERC20(token).safeTransfer(accountAdmin, claimableFees);58}
Recommendation:
We advise this look-up to be performed only once outside the loops as the value of the administrator will not change in between iterations.
Alleviation:
The accountAdmin
of a member is now properly cached outside the for
loops thereby optimizing the codebase.