The FjordPoints::distributePoints function calculates and distributes points to users based on their staked tokens. This function uses PRECISION_18 to maintain precision during calculation. However, if the total no of staked tokens is too large compared to the PRECISION_18 variable, it can lead to precision loss. This causes stakers to get less than their expected amount of points.
Relevant Link - https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordPoints.sol#L243
The FjordPoints::distributePoints function uses PRECISION_18 to maintain precision during calculation of pointsPerToken. This variable helps ensure that the calculation of points to be distributed is precise. However if the total amount of staked tokens is much higher than PRECISION_18, it will cause a precision loss.
Stakers get slightly less than their expected amount of points.
The impact is demonstrated with the following test, which can be executed with forge test --mt testPointsPrecisionLost.
This test proves that stakers get less than their expected amount of points.
Manual Review, Foundry
Increase the value of PRECISION_18 to 1e28 or higher to ensure that the new precision variable is always larger than any amount leading to accurate distribution. Also rename PRECISION_18 to reflect the updated value (e,g, PRECISION_28).
After adding this change, you can rerun the poc test provided earlier to verify that the points are being distributed correctly and stakers get their expected points
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.