The liquidateBorrower
function in the provided Solidity code erroneously scales the user's debt twice. This occurs because the user's debt has already been scaled in the lending pool, and the function applies another scaling operation, resulting in incorrect debt calculations.
The liquidate borrower function liquidates bad debts through the stability pool, which calls finalizeLiquidation function in the lending pool. Before liquidating the bad debt the stabilityPool#liquidateBorrower function scales the user debt about to be liquidated, the issue however lies in the sense that user debt have been scaled when getting the user debt details from the lending pool leading to case of double scaling.
In the below code the function gets the user debt from the lending pool and scales it with the debt index of the liquidity pool, however the scaling had been carried out already while getting user debt..
user debt function with already scaled user debt below
By scaling the user's debt twice, the function produces an incorrect debt amount. This could have several negative implications:
Users might end up with higher-than-expected debt amounts, leading to potential financial losses or unfair liquidations.
manual review
To address this issue, remove the second scaling operation from the liquidateBorrower
.
By making this change, the function will correctly handle the user’s debt without applying redundant scaling, ensuring accurate debt calculations and maintaining the integrity of the lending platform.
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.