Cleanup + Collect repay

Overview

We will cover the last three components in this section.

setBorrowing

If there is no outstanding debt left, within userConfig, set the borrowing flag for the asset to 0.

  • For function's inner workings, see: setBorrowing under the borrow section.

updateIsolatedDebtIfIsolated

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)

  • getisolationModeState was previously explained in the borrow section

Drawing

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

Collect repay

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.

  • See withdraw section for AToken.burn

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

Last updated

Was this helpful?