The LendingPool::setPrimeRate() function does not synchronize the reserve state before updating the prime rate, causing incorrect interest calculations for past periods.
When setting a new prime rate in LendingPool::setPrimeRate(), the function calls ReserveLibrary::setPrimeRate() which updates the prime rate without first synchronizing the reserve state. This means the new prime rate will be applied retroactively to the period between the last update and the current timestamp.
The issue occurs because ReserveLibrary::setPrimeRate() only validates the rate change and updates the rates:
At t=0, prime rate is set to 5 RAY
At t=100, no reserve sync has occurred
At t=100, prime rate is updated to 5.2 RAY
The new rate is applied retroactively to t=0-100
Interest for t=0-100 is calculated using 5.2 RAY instead of the correct 5 RAY
This leads to incorrect interest calculations as the new prime rate is applied retroactively to past periods. Since the prime rate is a key component in calculating both liquidity and usage rates, this affects:
Interest earned by lenders
Interest owed by borrowers
Health factor calculations
The impact is amplified when there are frequent prime rate changes without reserve synchronization.
Synchronize reserves before updating prime rate:
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.