Cleanup + Collect repay
Last updated
Was this helpful?
Last updated
Was this helpful?
We will cover the last three components in this section.
If there is no outstanding debt left, within userConfig, set the borrowing flag for the asset to 0
.
In the event that the debt position was collateralized by an isolated asset, and a repay or liquidation occurred
total debt of the isolated asset must be decremented (isolationModeTotalDebt
)
If user is in isolation mode:
get total isolated debt from reservesData
(isolationModeTotalDebt
)
rebase the decimals of paybackAmount
if isolationModeTotalDebt < repayAmount
reset total isolated debt on asset to 0
Else: decrement total isolated debt by repayAmount
Finally, the repayment is collected from the function caller.
If useATokens
was set to true
, like in repayWithATokens
, Atokens would be burnt.
Example: User has DAI debt and also holds aDAI token
can use aDAI to repay DAI debt in single transaction without any approvals or having to withdraw their supplied liquidity to the pool using repayWithATokens
feature
aDAI tokens would be burnt, reducing his claim on supplied assets.
Else, useATokens
is set to false
, in the case of repay
;
asset is pulled from user via safeTransferFrom
example: borrowed USDC, repaying USDC: principal + plus interest
For function's inner workings, see: under the borrow section.
was previously explained in the borrow section
See withdraw section for