Omniscia Alliance Block Audit

LibFeeCalculator Code Style Findings

LibFeeCalculator Code Style Findings

LFC-01C: Redundant Addition

TypeSeverityLocation
Gas OptimizationInformationalLibFeeCalculator.sol:L62

Description:

The fcs.claimedRewardsPerAccount[claimer] member should be set to fcs.accumulator directly as its right-side operation always results in this value.

Example:

contracts/libraries/LibFeeCalculator.sol
50function claimReward(address claimer)
51 internal
52 returns (uint256)
53{
54 LibFeeCalculator.Storage storage fcs = feeCalculatorStorage();
55 uint256 amount = fcs.feesAccrued.sub(fcs.previousAccrued).div(LibDiamond.membersCount());
56
57 fcs.previousAccrued = fcs.feesAccrued;
58 fcs.accumulator = fcs.accumulator.add(amount);
59
60 uint256 claimableAmount = fcs.accumulator.sub(fcs.claimedRewardsPerAccount[claimer]);
61
62 fcs.claimedRewardsPerAccount[claimer] = fcs.claimedRewardsPerAccount[claimer].add(claimableAmount);
63
64 return claimableAmount;
65}

Recommendation:

We advise the recommendation in the description to be applied to the linked statement.

Alleviation:

The recommended optimization was applied properly.