The prize pool and fee calculations use integer division which can result in precision loss.
With certain entrance fee values, the sum of prizePool + fee may not equal totalAmountCollected, leaving dust ETH permanently locked in the contract.
Likelihood: Low
Reason 1 // Only occurs with specific entrance fee values
Reason 2 // Standard 1 ETH fee divides evenly
Impact: Medium
Impact 1 // Small amounts of ETH permanently locked per raffle
Impact 2 // Accumulates over many raffles
Impact 3 // No mechanism to recover dust
The following demonstrates precision loss with a non-standard entrance fee.
Calculate fee as the remainder after prize pool to avoid dust.
## Description `fee` should be 'totalAmountCollected-prizePool' to prevent decimal loss ## Vulnerability Details ``` uint256 totalAmountCollected = players.length * entranceFee; uint256 prizePool = (totalAmountCollected * 80) / 100; uint256 fee = (totalAmountCollected * 20) / 100; ``` This formula calculates `fee` should be 'totalAmountCollected-prizePool' ## Impact By calculates `fee` like the formula above can cause a loss in `totalAmountCollected' if the `prizePool` is rounded. ## Recommendations ```diff - uint256 fee = (totalAmountCollected * 20) / 100; + uint256 fee = totalAmountCollected-prizePool; ```
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.