The setPrimeRate function in the ReserveLibrary fails to update derived interest rate parameters (baseRate, optimalRate, maxRate) after modifying the primeRate. This omission results in inconsistent interest rate calculations, potentially causing reverts in critical functions and disrupting protocol operations. Additionally, the maximum allowed change check for primeRate may not account for accrued interest due to an outdated reserve state.
The primeRate is a foundational parameter influencing other rates (baseRate, optimalRate, maxRate). These derived rates are initialized as percentages of primeRate during contract deployment.
However, when primeRate is updated via setPrimeRate, the derived rates remain static.
Invalid Rate Parameters: Subsequent calls to calculateBorrowRate may revert if the updated primeRate exceeds the outdated maxRate or falls below baseRate, violating function preconditions.
Incorrect Interest Calculations: Even without reverts, the derived rates no longer reflect the intended percentages of the current primeRate, leading to miscalculated borrow and liquidity rates.
Initial State:
primeRate = 1e26 (RAY)
baseRate = 1e26 * 25% = 2.5e25
maxRate = 1e26 * 400% = 4e26
Admin Action:
Incrementally increases primeRate by 5% multiple times (allowed per the 5% max change check).
After several increments, primeRate reaches 4.2e26.
Result:
Outcome:
maxRate remains at 4e26 (400% of initial primeRate).
calculateBorrowRate checks primeRate <= baseRate || primeRate >= maxRate.
With primeRate = 4.2e26 and maxRate = 4e26, the condition primeRate >= maxRate is true, causing a revert.
Borrowing, deposit, and withdrawal functions relying on interest rate calculations may revert, halting user operations.
Incorrect interest rates lead to unfair borrowing costs or liquidity provider returns, undermining protocol trust.
Manual Review
Update Derived Rates in setPrimeRate:
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.