The ReserveLibrary contract has a critical bug in its debt calculation mechanism, which adversely affects the computation of the utilization rate as well as the resulting borrow and liquidity rates. Specifically, the getNormalizedDebt function erroneously computes debt using compounded interest rather than returning the actual debt value. This miscalculation distorts the utilization rate, leading to incorrect rates that impact the lending and borrowing operations of the protocol.
Issue:
The getNormalizedDebt function currently calculates total debt as follows:
This method incorporates compounded interest via the usageIndex, which means the value returned reflects an interest factor rather than the actual debt. The correct approach should be to calculate the debt as:
Affected Calculations:
The utilization rate in functions like getBorrowRate and getLiquidityRate relies on the output of getNormalizedDebt. Since this function returns an incorrect value, the resulting utilization rate, as well as the borrow and liquidity rates, are miscalculated.
Faulty Utilization Rate:
The utilization rate will be computed based on an inflated or distorted total debt value, leading to inaccurate calculations.
Erroneous Borrow and Liquidity Rates:
Borrowers might face incorrect interest rates, and liquidity providers could receive improper incentives due to the miscalculation.
Financial Discrepancies:
Users may overpay or receive less than expected, causing significant financial imbalances within the system.
Manual Code Review
Correct the Debt Calculation:
Update the getNormalizedDebt function to return the true debt amount:
Revise the Utilization Rate Formula:
Modify the calculation in getBorrowRate and getLiquidityRate to utilize the corrected debt value:
Recompute Rates:
After using the correct total debt in the utilization rate, recalculate the borrow and liquidity rates to ensure they accurately reflect the underlying economics.
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.