In the liquidateBorrower
function, the user's debt is scaled twice using the same reserve.usageIndex
:
First, userDebt
is calculated as user.scaledDebtBalance.rayMul(reserve.usageIndex)
in the getUserDebt
function.
Then, scaledUserDebt
is calculated as WadRayMath.rayMul(userDebt, lendingPool.getNormalizedDebt())
, where getNormalizedDebt()
also returns reserve.usageIndex
.
This double scaling results in the user's debt being multiplied by reserve.usageIndex
twice, leading to:
Overestimation of the user's debt.
Incorrect liquidation amounts, potentially causing financial harm to borrowers or the Stability Pool.
liquidateBorrower
in StabilityPool:
getUserDebt
in LendingPool:
getNormalizedDebt
in LendingPool:
The getUserDebt
function already scales the user's debt by reserve.usageIndex
.
The liquidateBorrower
function then scales the already scaled userDebt
by reserve.usageIndex
again, effectively applying the scaling twice.
Assume:
user.scaledDebtBalance = 100e18
reserve.usageIndex = 1.1e27
(10% interest)
First Scaling (in getUserDebt
):
Second Scaling (in liquidateBorrower
):
The user's debt is incorrectly calculated as 121e18
instead of the correct 110e18
. This overestimation could lead to excessive liquidation, causing financial harm to the borrower.
To fix this issue, remove the second scaling step in the liquidateBorrower
function. The corrected function should look like this:
The second scaling step (WadRayMath.rayMul(userDebt, lendingPool.getNormalizedDebt())
) is removed.
The userDebt
value returned by lendingPool.getUserDebt(userAddress)
is already correctly scaled by reserve.usageIndex
and does not need further adjustment.
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.