The performUpkeep function in the RebaseController contract is at risk of arithmetic errors due to the multiplication of a potentially large totalDepositChange by 10000. This can result in numerical inaccuracies and cause the transaction to fail, disrupting the contract's intended functionality.
Multiplying totalDepositChange by 10000 can produce a value that exceeds the numerical limits of the data type.
Scenario:
- Values:
totalDepositChange = 2,000,000,000,000,000,000,000 (2e21)
stakingPool.totalSupply() = 10,000,000,000,000,000,000,000 (1e22)
maxRebaseLossBP = 500 (5%)
- Calculation:
Multiplication:
Calculate 10000 * totalDepositChange
10000 * 2,000,000,000,000,000,000,000 = 20,000,000,000,000,000,000,000,000
Division:
(20,000,000,000,000,000,000,000,000,000) / 10,000,000,000,000,000,000,000
The result is 2000
Result:
2000 > maxRebaseLossBP (500)
The arithmetic error can cause repeated transaction failures.
Legitimate updates to strategy rewards may be blocked.
Manual review
Instead of performing a direct multiplication, you can rearrange the arithmetic to avoid large intermediate values. This approach involves calculating the ratio first and then scaling it.
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.