VariableDebtToken
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
Name | Type | Description |
---|---|---|
user | address | The address performing the mint |
onBehalfOf | address | The address receiving the minted tokens |
amount | uint256 | The amount of tokens to mint |
index | uint256 | The variable debt index of the reserve |
Return Values
Type | Description |
---|---|
bool | True if the previous balance of the user was 0 |
uint256 | The 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
Name | Type | Description |
---|---|---|
from | address | The address from which to burn tokens |
amount | uint256 | The amount to burn |
index | uint256 | The variable debt index of the reserve |
Return Values
Type | Description |
---|---|
uint256 | The 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
Name | Type | Description |
---|---|---|
delegatee | address | The address authorized to borrow |
amount | uint256 | The 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
Name | Type | Description |
---|---|---|
fromUser | address | The user granting borrowing rights |
toUser | address | The user being granted borrowing rights |
Return Values
Type | Description |
---|---|
uint256 | The 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
Type | Description |
---|---|
address | The 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
Type | Description |
---|---|
address | The 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
[
{
"type": "constructor",
"inputs": [
{
"name": "pool",
"type": "address",
"internalType": "contract IPool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "DEBT_TOKEN_REVISION",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "DELEGATION_WITH_SIG_TYPEHASH",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bytes32",
"internalType": "bytes32"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "DOMAIN_SEPARATOR",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bytes32",
"internalType": "bytes32"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "EIP712_REVISION",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bytes",
"internalType": "bytes"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "POOL",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IPool"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "UNDERLYING_ASSET_ADDRESS",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "allowance",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "approve",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "approveDelegation",
"inputs": [
{
"name": "delegatee",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "balanceOf",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "borrowAllowance",
"inputs": [
{
"name": "fromUser",
"type": "address",
"internalType": "address"
},
{
"name": "toUser",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "burn",
"inputs": [
{
"name": "from",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "index",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "decimals",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint8",
"internalType": "uint8"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "decreaseAllowance",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "delegationWithSig",
"inputs": [
{
"name": "delegator",
"type": "address",
"internalType": "address"
},
{
"name": "delegatee",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "deadline",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "v",
"type": "uint8",
"internalType": "uint8"
},
{
"name": "r",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "s",
"type": "bytes32",
"internalType": "bytes32"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "getIncentivesController",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IAaveIncentivesController"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getPreviousIndex",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getScaledUserBalanceAndSupply",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "increaseAllowance",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "initialize",
"inputs": [
{
"name": "initializingPool",
"type": "address",
"internalType": "contract IPool"
},
{
"name": "underlyingAsset",
"type": "address",
"internalType": "address"
},
{
"name": "incentivesController",
"type": "address",
"internalType": "contract IAaveIncentivesController"
},
{
"name": "debtTokenDecimals",
"type": "uint8",
"internalType": "uint8"
},
{
"name": "debtTokenName",
"type": "string",
"internalType": "string"
},
{
"name": "debtTokenSymbol",
"type": "string",
"internalType": "string"
},
{
"name": "params",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "mint",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
},
{
"name": "onBehalfOf",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "index",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "name",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "nonces",
"inputs": [
{
"name": "owner",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "scaledBalanceOf",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "scaledTotalSupply",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "setIncentivesController",
"inputs": [
{
"name": "controller",
"type": "address",
"internalType": "contract IAaveIncentivesController"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "symbol",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "totalSupply",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "transfer",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "transferFrom",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "event",
"name": "Approval",
"inputs": [
{
"name": "owner",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "spender",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "event",
"name": "BorrowAllowanceDelegated",
"inputs": [
{
"name": "fromUser",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "toUser",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "asset",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "event",
"name": "Burn",
"inputs": [
{
"name": "from",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "target",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "balanceIncrease",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "index",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "event",
"name": "Initialized",
"inputs": [
{
"name": "underlyingAsset",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "pool",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "incentivesController",
"type": "address",
"indexed": false,
"internalType": "address"
},
{
"name": "debtTokenDecimals",
"type": "uint8",
"indexed": false,
"internalType": "uint8"
},
{
"name": "debtTokenName",
"type": "string",
"indexed": false,
"internalType": "string"
},
{
"name": "debtTokenSymbol",
"type": "string",
"indexed": false,
"internalType": "string"
},
{
"name": "params",
"type": "bytes",
"indexed": false,
"internalType": "bytes"
}
],
"anonymous": false
},
{
"type": "event",
"name": "Mint",
"inputs": [
{
"name": "caller",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "onBehalfOf",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "balanceIncrease",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "index",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "event",
"name": "Transfer",
"inputs": [
{
"name": "from",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "to",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
}
]