VariableDebtToken
Note that debt tokens cannot be transferred and therefore do not have their related functions.
User State
balance
: user's scaled balanceadditionalData
: user's last index at which his state was updated
mint
amountScaled
: scale the borrow amount against variableBorrowIndexscaledBalance
: user's scaled balancebalanceIncrease
: calculate the balance increase due to interest accrued from the previous time interest was calculated for the user till now.additionalData
: index at which user's scaledBalance was previously calculated
Update additionalData
with the current variableBorrowIndex, to reflect current mint action.
_mint
increment
totalSupply
byamountScaled
increment user's balance by
amountScaled
burn
This function is typically called when the user repays his debt, therefore fully or partially reducing his loan. Accordingly, the corresponding amount of variable debt tokens will be burn, reflecting his repayment.
burn
calls_burnScaled
on VariableDebtToken.sol._burnScaled
scales the burn amount againstvariableBorrowIndex
and calls_burn
passingamountScaled
._burn
is defined on MintableIncentivizedERC20.sol:reduces total supply
reduces user's balance
_burnScaled
scale burn amount against
variableBorrowIndex
balanceIncrease
: update user's variable debt balance to bring it in-line with latest indexadditionalData
contains the index at which the balance was last updated.this is referenced to calculated
balanceIncrease
, then subsequently updated
call
_burn
, passing scaled amountif
balanceIncrease
>amount
:interest accrued outweighs the burn amount
emit mint and transfer
Else
amount
>balanceIncrease
:burn amount outweighs interest accrued
emit burn and transfer
Note:
InbalanceIncrease
> amount
, tokens are not actually minted. amountToMint
is simply a representation of the remaining interest accrued, less the nominal burn amount.
Essentially, each unit of scaled token represents itself and the interest it has accrued as dictated by the index. Therefore, to account for the interest, the nominal amount is divided by the index to obtain amountScaled
.
Index here refers to variableBorrowIndex
Note: the actual number of tokens being burnt is amountScaled
. This is because debt tokens accrue interest in the same way that ATokens do; against an index.
_burn
reduce total supply by burn amount
get user's balance decrement it by burn amount
apply incentives if defined (
.handleAction
)
Last updated