** When users borrow from the lending pool, debt tokens are minted by dividing the borrowed amount by the current reserve.usageIndex. The function mint in the DebtToken contract returns totalSupply() / newTotalSupply, which is then used in the borrow function of LendingPool.sol. After borrowing, reserve.totalUsage is updated to the new total supply of debt tokens.**
However, there is an error in the totalSupply() function of the DebtToken contract. Instead of multiplying the total supply of debt tokens by reserve.usageIndex, the contract divides it. This miscalculation leads to an underestimated totalSupply(), causing reserve.totalUsage to be lower than expected.
Since reserve.totalUsage is lower than expected, the utilization rate is also underestimated. This results in a lower-than-expected BorrowRate and LiquidityRate, affecting the overall lending and borrowing dynamics.
A similar issue occurs when the _repay function in LendingPool.sol is called, leading to an incorrect update of reserve.totalUsage.
**1. When users borrows from lendingpool, debt tokens are minted to the users. Debt tokens are minted dividing the borrowed amount by current reserve.usageIndex. **
2. totalSupply()/newTotalSupply is returned when calling debt token contract’s function mint in the function borrow(LendingPool.sol).
**3. Then reserve.totalUsage is set/updated to newTotalSupply of debt tokens in the function borrow(LendingPool.sol). But totalSupply()/newTotalSupply calculation is incorrect in the contract DebtToken. **
**4.See function totalSupply() in the contract DebtToken where debt token totalsupply is divided by reserve.usageIndex, here debt token totalsupply should be multiplied by reserve.usageIndex. As debt token totalsupply is divided by reserve.usageIndex, so totalsupply calculation of debt token will be less than expected and reserve.totalUsage will be less than expected. **
5. As reserve.totalUsage will be less than expected, so utilization rate will be less than expected. As a result BorrowRate and LiquidityRate will be less than expected.
Similarly , when function _repay(lendingpool) is called , reserve.totalUsage will be updated incorrectly.
** Since reserve.totalUsage is lower than expected, the utilization rate is also underestimated. This results in a lower-than-expected BorrowRate and LiquidityRate, affecting the overall lending and borrowing dynamics.**
manual review
multiply super.totalSupply with reserve.usageIndex in the function totalSupply(DebtToken.sol)
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.