The DebtToken::totalSupply()
function incorrectly scales the total supply using rayDiv
instead of rayMul
when applying the normalized debt factor. This causes the reported total supply to be significantly lower than the actual value, leading to incorrect utilization rate and borrow rates calculations
The totalSupply()
function is implemented as:
The function incorrectly uses rayDiv
to scale the total supply with the normalized debt. This is incorrect because the normalized debt factor should multiply the supply to get the actual debt amount, not divide it. This is evident when comparing with the balanceOf()
function which correctly uses rayMul
:
The DebtToken::totalSupply()
is assigned to the reserve.totalUsage
variable in the LendingPool::borrow()
, LendingPool::repay()
and LendingPool::finalizeLiquidation()
. The totalUsage
is used to calculate the utilization rate which is used to calculate the borrow rate in ReserveLibrary::updateInterestRatesAndLiquidity()
.
The incorrect scaling leads to:
Significantly understated total debt supply
Wrong utilization rate calculations since total usage is derived from total supply
Incorrect borrow rates as they depend on utilization rate
This is a high severity issue because it directly affects core protocol economics and could lead to significant financial losses through incorrect interest rate calculations.
Manual Review
Add the following test case to the test/unit/core/tokens/DebtToken.test.js
file:
Change rayDiv
to rayMul
in the totalSupply()
function:
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.