30555 - [SC - Low] Precision loss when calculating the FLUX amount...
Last updated
Was this helpful?
Was this helpful?
function amountToRagequit(uint256 _tokenId) public view returns (uint256) {
// amount of flux earned in one epoch
uint256 oneEpochFlux = claimableFlux(_tokenId);
// total amount of epochs in fluxMultiplier amount of years
uint256 totalEpochs = fluxMultiplier * ((MAXTIME) / EPOCH);
// based on one epoch, calculate total amount of flux over fluxMultiplier amount of years
uint256 ragequitAmount = oneEpochFlux * totalEpochs;
return ragequitAmount;
} totalEpochs = fluxMultiplier * ((MAXTIME) / EPOCH); function amountToRagequit(uint256 _tokenId) public view returns (uint256) {
// amount of flux earned in one epoch
uint256 oneEpochFlux = claimableFlux(_tokenId);
// total amount of epochs in fluxMultiplier amount of years
- uint256 totalEpochs = fluxMultiplier * ((MAXTIME) / EPOCH);
// based on one epoch, calculate total amount of flux over fluxMultiplier amount of years
- uint256 ragequitAmount = oneEpochFlux * totalEpochs;
+ uint256 ragequitAmount = (oneEpochFlux * fluxMultiplier * MAXTIME) / EPOCH;
return ragequitAmount;
} function test_precissionLoss() public {
uint256 oneEpochFlux = claimableFlux;
uint256 totalEpochs = fluxMultiplier * ((MAXTIME) / EPOCH);
uint256 ragequitAmount_actual = (oneEpochFlux * totalEpochs);
uint256 ragequitAmount_accurate = (oneEpochFlux * fluxMultiplier * MAXTIME) / EPOCH;
console.log("Current Implementation ", ragequitAmount_actual);
console.log("Actual Implementation ", ragequitAmount_accurate);
} Current Implementation 16277040000000
Actual Implementation 16321757142857