The selectWinner() function in the PuppyRaffle contract uses integer division to calculate the prize pool and fee. This can result in precision loss.
The code calculates the fee variable as a percentage of totalAmountCollected using integer arithmetic. This can result in precision loss, especially if totalAmountCollected is not a multiple of 100. The code increments totalFees with the potentially imprecise fee value,which can lead to cumulative inaccuracies in the calculation of fees over time.
Precision loss can lead to inaccurate results
Manual analysis
The selectWinner() function should be updated to use fixed-point arithmetic to calculate the prize pool and fee. This will ensure that the results are accurate to the desired precision.
like 1 wei
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.