Omniscia LimeChain Audit

LibFeeCalculator Static Analysis Findings

LibFeeCalculator Static Analysis Findings

LFC-01S: Potential Loss of Precision

Description:

The accrue function reverses the division performed on the delta between feesAccrued and previousAccrued using a multiplication which can cause a truncation / loss of precision at most equal to members - 1.

Example:

contracts/libraries/LibFeeCalculator.sol
111function accrue(FeeCalculator storage _fc) internal returns (uint256) {
112 uint256 members = LibGovernance.membersCount();
113 uint256 amount = (_fc.feesAccrued - _fc.previousAccrued) / members;
114 _fc.previousAccrued += amount * members;
115 _fc.accumulator = _fc.accumulator + amount;
116
117 return _fc.accumulator;
118}

Recommendation:

We advise the delta to be stored to a dedicated variable that is then used for calculating the division as well as incrementing previousAccrued. This will also reduce the gas cost of the function.

Alleviation:

The Limechain team has stated that they prefer to retain the current solution in place. While it suffers from precision loss, this loss is carried over until the next distribution guaranteeing that the loss of precision will at some point in time be correctly distributed should the numbers be wholly divisible. As such, we consider this exhibit null.