fix bug in LibFractions reference function

This commit is contained in:
Michael Zhu 2019-12-11 18:06:27 -08:00
parent 49538f272e
commit e4a3b1cb05
2 changed files with 2 additions and 8 deletions

View File

@ -129,7 +129,7 @@ export const LibFractions = {
normalize: (
numerator: BigNumber,
denominator: BigNumber,
maxValue: BigNumber = new BigNumber(2 ** 127),
maxValue: BigNumber = new BigNumber(2).exponentiatedBy(127),
): [BigNumber, BigNumber] => {
if (numerator.isGreaterThan(maxValue) || denominator.isGreaterThan(maxValue)) {
let rescaleBase = numerator.isGreaterThanOrEqualTo(denominator) ? numerator : denominator;

View File

@ -179,13 +179,7 @@ export function validFinalizePoolAssertion(
beforeInfo.poolStats.membersStake,
);
[numerator, denominator] = ReferenceFunctions.LibFractions.normalize(numerator, denominator);
// There's a bug in our reference functions, probably due to the fact that safeDiv in
// Solidity truncates in bits, whereas the safeDiv reference function truncates in base 10.
assertRoughlyEquals(
mostRecentCumulativeRewards.numerator.dividedBy(mostRecentCumulativeRewards.denominator),
numerator.dividedBy(denominator),
PRECISION,
);
expect(mostRecentCumulativeRewards).to.deep.equal({ numerator, denominator });
// Check that aggregated stats have been updated
const aggregatedStats = AggregatedStats.fromArray(