Precision loss in SophonFarming.sol:_pendingPoints.
Summary
In this function multiplication is done after the division which can lead to the precision loss
Vulnerability Detail
pointReward is calculated by multiplying (blockMultiplier *pointsPerBlock *pool.allocPoint ) and then dividing by totalAllocPoint. Then after division it is getting multipled by 1e18 and divided by (lpSupply + accPointsPerShare) and accPointsPerShare has 1e18 decimal place. This can lead to a precision loss.
Impact
depositors may get less reward due to precision loss.
nikhil840096
medium
Precision loss in
SophonFarming.sol:_pendingPoints
.Summary
In this function multiplication is done after the division which can lead to the precision loss
Vulnerability Detail
pointReward
is calculated by multiplying(blockMultiplier *pointsPerBlock *pool.allocPoint )
and then dividing bytotalAllocPoint
. Then after division it is getting multipled by1e18
and divided by(lpSupply + accPointsPerShare)
andaccPointsPerShare
has1e18
decimal place. This can lead to a precision loss.Impact
depositors may get less reward due to precision loss.
Code Snippet
https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L367-L383
Tool used
Manual Review
Recommendation
Use best practice to save from precision loss.