The VariableDebtToken.sol contract represents the debt owed by users who have borrowed assets from the HypurrFi protocol at a variable interest rate. The token balance represents the user’s debt that continuously increases based on the variable interest rate.

Debt tokens are non-transferrable tokens that track a user’s debt position in the protocol. Each token is specific to an underlying asset and accrues interest based on the current variable interest rate of that asset.

Write Methods

mint

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

Mints debt tokens to track a new borrow position.

Call Params

NameTypeDescription
useraddressThe address performing the mint
onBehalfOfaddressThe address receiving the minted tokens
amountuint256The amount of tokens to mint
indexuint256The variable debt index of the reserve

Return Values

TypeDescription
boolTrue if the previous balance of the user was 0
uint256The scaled total supply after minting

burn

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

Burns debt tokens when a user repays their debt.

Call Params

NameTypeDescription
fromaddressThe address from which to burn tokens
amountuint256The amount to burn
indexuint256The variable debt index of the reserve

Return Values

TypeDescription
uint256The scaled total supply after burning

approveDelegation

function approveDelegation(
    address delegatee,
    uint256 amount
) external

Approves a delegatee to borrow a specific amount on behalf of the delegator.

Call Params

NameTypeDescription
delegateeaddressThe address authorized to borrow
amountuint256The amount the delegatee is authorized to borrow

View Methods

borrowAllowance

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

Returns the borrow allowance of toUser on behalf of fromUser.

Call Params

NameTypeDescription
fromUseraddressThe user granting borrowing rights
toUseraddressThe user being granted borrowing rights

Return Values

TypeDescription
uint256The current borrow allowance

UNDERLYING_ASSET_ADDRESS

function UNDERLYING_ASSET_ADDRESS() external view returns (address)

Returns the address of the underlying asset of this debt token.

Return Values

TypeDescription
addressThe address of the underlying asset

POOL

function POOL() external view returns (address)

Returns the address of the lending pool where this debt token is used.

Return Values

TypeDescription
addressThe address of the lending pool

Events

Mint

event Mint(
    address indexed caller,
    address indexed onBehalfOf,
    uint256 value,
    uint256 balanceIncrease,
    uint256 index
)

Emitted when debt tokens are minted.

Burn

event Burn(
    address indexed from,
    address indexed target,
    uint256 value,
    uint256 balanceIncrease,
    uint256 index
)

Emitted when debt tokens are burned.

BorrowAllowanceDelegated

event BorrowAllowanceDelegated(
    address indexed fromUser,
    address indexed toUser,
    address indexed asset,
    uint256 amount
)

Emitted when borrow allowance is delegated.

Usage Example

// Approve delegation for borrowing
variableDebtToken.approveDelegation(delegatee, 1000);

// Borrow assets through delegation
pool.borrow(asset, 1000, VARIABLE_RATE, 0, delegator);

// Repay borrowed assets
pool.repay(asset, 1000, VARIABLE_RATE, onBehalfOf);

Security Considerations

  • Variable Debt Tokens cannot be transferred between accounts
  • Only the HypurrFi Pool contract can mint or burn tokens
  • Delegation approvals should be managed carefully
  • Interest accrual is continuous based on the variable rate

ABI