The setPrimeRate function in the ReserveLibrary does not update the reserve state (updateReserveInterests) before accessing the oldPrimeRate. This oversight can result in the use of stale data for the maximum change validation, potentially allowing invalid primeRate updates if interest has accrued since the last state update. This issue undermines the integrity of the interest rate adjustment mechanism.
The setPrimeRate function is responsible for updating the primeRate, a critical parameter influencing borrowing and lending rates. Before updating the primeRate, the function checks whether the new rate exceeds the maximum allowed change (5% of the oldPrimeRate). However, the function does not call updateReserveInterests to refresh the reserve state before accessing oldPrimeRate.
If interest has accrued since the last state update, the oldPrimeRate used for validation may not reflect the current state of the reserve.
This can lead to two scenarios:
Overly Permissive Validation: If the primeRate has increased due to accrued interest but the state is not updated, the maximum change check may allow a larger-than-intended adjustment.
Overly Restrictive Validation: If the primeRate has decreased due to accrued interest, the maximum change check may incorrectly reject valid adjustments.
primeRate = 1e26 (RAY)
Last reserve state update timestamp: t0
Current block timestamp: t1 (where t1 > t0)
Due to accrued interest between t0 and t1, the effective primeRate increases to 1.1e26.
Admin calls setPrimeRate with newPrimeRate = 1.15e26 (a 15% increase from the initial primeRate).
The function uses the stale oldPrimeRate = 1e26 for validation.
maxChange = 1e26 * 5% = 5e24.
diff = 1.15e26 - 1e26 = 1.5e25.
Since 1.5e25 > 5e24, the function incorrectly allows the update, despite the effective primeRate already being 1.1e26.
Incorrect primeRate adjustments can lead to unfair borrowing costs or liquidity provider returns, undermining protocol trust.
Manual Review
Call updateReserveInterests at the start of setPrimeRate to ensure oldPrimeRate reflects the current state:
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.