Let see work flow of StabilityPool.liquidateBorrower()
it 1st fetch User(User which registered for liquidation) DEBT balance as userDebt
calculate User's scaledDebt scaledUserDebt
by multiplying userDebt
with UsageIndex
-
After own balance check give approval to lendingPool with scaledUserDebt
, and then all lendingPool.updateState()
to update interst rates like liquidityIndex
and debtIndex
and finally call lendingPool.finalizeLiquidation()
And problem lies here, i explain how
StabilityPool give allowance to lending pool with scaledUserDebt
, which is calculated as User.DEBT rayMultiply with usageIndex
Here UsageIndex is besically Debt rate which compounded with time
Here usageIndex that used to calculate scaledUserDebt
balance could be a Old value, and right after calculation, this usageIndex get updated via call lendingPool.update()
When move to lendingpool.finalizeLiquidation()
function it again calculate User's scaledUserDebt as StabilityPool
does but this time with updated usageIndex
and fetch this amount of token from stability pool
So here point is scaledUserDebt
calculated in StabilityPool and userDebt
calculated in Lending pool could be different value as usageIndex used in first case was Old and 2nd case is New. Depending on time frequently or less frequently this ReserveLibrary.updateReserveState()
called these value varies, and point to note here that usageIndex compounded with time.
So Considering above discussion, its possible that allowane given by Stabilitypool to LendingPool is not sufficient and call to lendingPool.finalizeLiquidity() will gonna fail
inside liquidateBorrower() call lendingPool.updateState()
eairlier than calculating User's `scaledUserDebt`
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.