the protocol is utilizing dynamic interest rate model using prime rate as reference. the prime rate is a value derived from oracle, but when the prime rate is updated by oracle the baseRate
, optimalRate
, and maxRate
are not updated accordingly leading to inaccurate state when calling updateInterestRatesAndLiquidity
, a crucial function to determine the correct interest rate for entire protocol.
when deploying LendingPool
contract, the prime rate and other crucial rate are set in constructor:
and when the RAACPrimeRateOracle
contract updates the prime rate, this function is invoked inside LendingPool
:
now we should check how the newPrimeRate is handled inside the ReserveLibrary
contract:
the function only check if the primeRate
change are within 5% of its old value, after that the new value are getting updated inside rateData.primeRate
.
the issue is the value rateData.baseRate
, rateData.optimalRate
and rateData.maxRate
are not updated and still use 25%, 50% and 400% of the old value as their value.
why this crucial? because the updated and unupdated rate are now getting used inside updateInterestRatesAndLiquidity
function to calculate few things:
first, it calculate the currentUsageRate
or borrow rate, by using old value in baseRate
(min borrow rate), optimalRate
(rate at optimal utilization), and maxRate
(max borrow rate) the resulting value would be inaccurate representing the current borrow rate.
second, the liquidity rate are also affected by this because the currentUsageRate
used are not accurate. the currentLiquidityRate
would be inaccurate as the result of this.
the final issue is, when updateReserveInterests
are called by using inaccurate rateData
, where this value would later be used to calculate reserve.liquidityIndex
and reserve.usageIndex
. as we knowthis two value are crucial in calculating core protocol state, example: how much the value of normalized RToken
, DebtToken
.
by using inaccurate rate after the prime rate updated, the protocol would be in a state where the interest index used would be different than what it should be. this discrepancy would potentially cause the user and protocol overall experience to degrade because the calculation would be inaccurate, example: leading to lender to loss potential reward, borrower debt would be inaccurate and can lead to liquidation.
manual review
function ReserveLibrary.setPrimeRate
should also update the value of rateData.baseRate
, rateData.optimalRate
and rateData.maxRate
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.