The getNormalizedDebt
and getNormalizedIncome
functions in the ReserveLibrary.sol
contract returns the total interest
instead of totalDebt
and totalLiquidity
, with the exception that the getNormalizedDebt
function returns totalDebt if timeDelta < 1
. This causes the contract to incorrectly calculate the borrow and liquidity rates
, leading to incorrect calculation of borrow and liquidity amount as well as the minting of incorrect borrowing and liquidity tokens, as well as the incorrect redemption of these tokens.
Core issue: The getNormalizedDebt
and getNormalizedIncome
functions in the ReserveLibrary.sol
contract returns the total interest
instead of totalDebt
and totalLiquidity
, with the exception that the getNormalizedDebt function returns totalDebt when timeDelta < 1
. This affects the calculation of getLiquidityRate,
getBorrowRateand
updateInterestRatesAndLiquidity` functions.
contracts/libraries/pools/ReserveLibrary.sol:getNormalizedDebt#L470-L473
contracts/libraries/pools/ReserveLibrary.sol:getNormalizedIncome#L457-L459
This impacts the getBorrowRate
calculation. If timeDelta < 1
, the calculateUtilizationRate
function will use the totalDebt
and total liquidity interest
to calculate the incorrect utilizationRate
. If timeDelta >= 1
, it will use the total borrow interest
and total liquidity interest
to calculate an incorrect utilizationRate
, which then leads to an incorrect LiquidityRate
. The same issue exists in the getLiquidityRate
and updateInterestRatesAndLiquidity
functions.
contracts/libraries/pools/ReserveLibrary.sol:getBorrowRate#L432
contracts/libraries/pools/ReserveLibrary.sol:getLiquidityRate#L444
contracts/libraries/pools/ReserveLibrary.sol:updateInterestRatesAndLiquidity#L211-L212
Incorrect Utilization Rate: The wrong values for totalDebt
and totalLiquidity
lead to inaccurate utilization rates, affecting the system's ability to properly assess liquidity and debt positions.
Incorrect Borrow and Liquidity Rates: Errors in the utilization rate result in wrong borrow and liquidity rates, leading to incorrect interest charges for borrowers and returns for liquidity providers.
Erroneous Token Minting and Redemption: Miscalculations lead to incorrect amounts of deposit and borrow tokens being minted or redeemed, disrupting the liquidity pools and user transactions.
Exploitation Risks: Attackers could exploit these inaccuracies to arbitrage, manipulate rates, or trigger abnormal behavior, causing financial losses.
Manual Review
Method1: Based on the implementation of the getNormalizedDebt
and getNormalizedIncome
functions in the LendingPool
contract, it is recommended that the getNormalizedDebt
function in the ReserveLibrary.sol
contract should also return the total interest rates instead of totalDebt
and totalLiquidity
. Additionally, the corresponding functions getBorrowRate
, getLiquidityRate
, and updateInterestRatesAndLiquidity
should be updated accordingly. For example:
Method2: Alternatively, both getNormalizedIncome
and getNormalizedDebt
functions could be modified to return totalLiquidity
and totalDebt
.
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.