A potential vulnerability exists in the Rock-Paper-Scissors smart contract's fee calculation mechanism where fees are calculated using percentage integers (10%) instead of basis points. This approach lacks precision and can lead to rounding errors, especially with small bet amounts. When users participate in ETH-based games, the protocol fee is calculated as (totalPot * PROTOCOL_FEE_PERCENT) / 100
, which can result in inconsistent fee collection, potentially impacting the financial integrity of the system.
The issue involves two contract functions that handle fee calculations:
In the finishGame
function, fees are calculated using whole percentages:
Similarly, in the handleTie
function, the same percentage-based approach is used:
The protocol fee percentage is defined as a constant:
Limited precision, as fees can only be set in whole percentage points
Small rounding errors accumulate over time, creating discrepancies between expected and actual fee collection.
Difficulty in making fine-grained fee adjustments (e.g., 10.5%)
Inconsistent fee collection across different transaction sizes
Manual code review
Replace percentage-based calculations with basis points (BPS) where 10000 BPS = 100%:
The tie-handling logic loses one wei due to integer division
The tie-handling logic loses one wei due to integer division
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.