Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

Inaccurate prize pool and fee calculations in `PuppyRaffle` contract due to integer division

Summary

The selectWinner() function in the PuppyRaffle contract uses integer division to calculate the prize pool and fee. This can result in precision loss.

Vulnerability Details

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.

Impact

Precision loss can lead to inaccurate results

Tools Used

Manual analysis

Recommendations

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.

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

loss of precision

like 1 wei

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!