Normal behavior:
The contract calculates platformFee
and previousKingPayout
during each claimThrone()
call by applying a percentage to the sentAmount
. These values are expected to reflect exact proportions (e.g., 5%) of the input ETH.
Issue:
Solidity does not support floating-point arithmetic. All percentage calculations using integers truncate fractional results (i.e., round down). For small sentAmount
values or low platformFeePercentage
, this rounding can consistently lead to zero or reduced fees, especially for the platform, which may rely on these micro-fees over time.
This creates:
Loss of revenue for the platform.
Unpredictable fee outcomes for small claimThrone()
values.
Likelihood: HIGH
Occurs every time a player claims the throne with low claimFee
or small platformFeePercentage
.
Becomes more frequent during early game rounds or when claimFee is reset to a small value.
Impact: Low
The platform may collect zero or suboptimal fees, especially during early rounds.
Rounding issues can add up across many claims, reducing sustainability or incentivization.
Use higher precision for percentage calculations by multiplying first, then dividing, and using basis points (1/10,000 instead of 1/100):
Also update the variable and setter functions accordingly:
This allows much finer granularity and reduces rounding errors.
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.