Skip to content

VariableDebtToken Contract Interface

Implements a variable debt token to track the borrowing positions of users at a variable interest rate.

Transfer and approve functionalities are disabled since debt positions are non-transferable

Although debt tokens are modelled on the ERC20/EIP20 standard, they are non-transferrable. Therefore they do not implement any of the standard ERC20/EIP20 functions relating to transfer() and allowance().

balanceOf

solidity
function balanceOf(address user) public view virtual returns (uint256)

mint

solidity
function mint(address user, address onBehalfOf, uint256 amount, uint256 index) external virtual returns (bool, uint256)

Mints debt token to the onBehalfOf address

Parameters

NameTypeDescription
useraddressThe address receiving the borrowed underlying, being the delegatee in case of credit delegate, or same as onBehalfOf otherwise
onBehalfOfaddressThe address receiving the debt tokens
amountuint256The amount of debt being minted
indexuint256The variable debt index of the reserve

Return Values

NameTypeDescription
[0]boolTrue if the previous balance of the user is 0, false otherwise
[1]uint256The scaled total debt of the reserve

burn

solidity
function burn(address from, uint256 amount, uint256 index) external virtual returns (uint256)

Burns user variable debt

In some instances, a burn transaction will emit a mint event if the amount to burn is less than the interest that the user accrued

Parameters

NameTypeDescription
fromaddressThe address from which the debt will be burned
amountuint256The amount getting burned
indexuint256The variable debt index of the reserve

Return Values

NameTypeDescription
[0]uint256The scaled total debt of the reserve

totalSupply

solidity
function totalSupply() public view virtual returns (uint256)

_EIP712BaseId

solidity
function _EIP712BaseId() internal view returns (string)

Returns the user readable name of signing domain (e.g. token name)

Return Values

NameTypeDescription
[0]stringThe name of the signing domain

transfer

solidity
function transfer(address, uint256) external virtual returns (bool)

Being non transferrable, the debt token does not implement any of the standard ERC20 functions for transfer and allowance.

allowance

solidity
function allowance(address, address) external view virtual returns (uint256)

approve

solidity
function approve(address, uint256) external virtual returns (bool)

transferFrom

solidity
function transferFrom(address, address, uint256) external virtual returns (bool)

increaseAllowance

solidity
function increaseAllowance(address, uint256) external virtual returns (bool)

decreaseAllowance

solidity
function decreaseAllowance(address, uint256) external virtual returns (bool)

UNDERLYING_ASSET_ADDRESS

solidity
function UNDERLYING_ASSET_ADDRESS() external view returns (address)

Returns the address of the underlying asset of this debtToken (E.g. WETH for variableDebtWETH)

Return Values

NameTypeDescription
[0]addressThe address of the underlying asset

approveDelegation

solidity
function approveDelegation(address delegatee, uint256 amount) external

Delegates borrowing power to a user on the specific debt token. Delegation will still respect the liquidation constraints (even if delegated, a delegatee cannot force a delegator HF to go below 1)

Parameters

NameTypeDescription
delegateeaddressThe address receiving the delegated borrowing power
amountuint256The maximum amount being delegated.

delegationWithSig

solidity
function delegationWithSig(address delegator, address delegatee, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external

Delegates borrowing power to a user on the specific debt token via ERC712 signature

Parameters

NameTypeDescription
delegatoraddressThe delegator of the credit
delegateeaddressThe delegatee that can use the credit
valueuint256The amount to be delegated
deadlineuint256The deadline timestamp, type(uint256).max for max deadline
vuint8The V signature param
rbytes32The R signature param
sbytes32The S signature param

borrowAllowance

solidity
function borrowAllowance(address fromUser, address toUser) external view returns (uint256)

Returns the borrow allowance of the user

Parameters

NameTypeDescription
fromUseraddressThe user to giving allowance
toUseraddressThe user to give allowance to

Return Values

NameTypeDescription
[0]uint256The current allowance of toUser

scaledBalanceOf

solidity
function scaledBalanceOf(address user) external view returns (uint256)

Returns the scaled balance of the user.

The scaled balance is the sum of all the updated stored balance divided by the reserve's liquidity index at the moment of the update

Parameters

NameTypeDescription
useraddressThe user whose balance is calculated

Return Values

NameTypeDescription
[0]uint256The scaled balance of the user

getScaledUserBalanceAndSupply

solidity
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256)

Returns the scaled balance of the user and the scaled total supply.

Parameters

NameTypeDescription
useraddressThe address of the user

Return Values

NameTypeDescription
[0]uint256The scaled balance of the user
[1]uint256The scaled total supply

scaledTotalSupply

solidity
function scaledTotalSupply() public view virtual returns (uint256)

Returns the scaled total supply of the scaled balance token. Represents sum(debt/index)

Return Values

NameTypeDescription
[0]uint256The scaled total supply

getPreviousIndex

solidity
function getPreviousIndex(address user) external view virtual returns (uint256)

Returns last index interest was accrued to the user's balance

Parameters

NameTypeDescription
useraddressThe address of the user

Return Values

NameTypeDescription
[0]uint256The last index interest was accrued to the user's balance, expressed in ray