HyToken
The HyToken.sol
contract represents deposits in the HypurrFi protocol. When users deposit assets into HypurrFi lending pools, they receive corresponding HyTokens. These tokens accrue interest through a rebase mechanism, meaning the token balance automatically increases over time.
HyTokens follow the ERC20 standard with additional functionality specific to the HypurrFi protocol. Each HyToken is pegged 1:1 to the value of the underlying asset that is deposited in the HypurrFi protocol.
Write Methods
mint
function mint(
address user,
uint256 amount,
uint256 index
) external returns (bool)
Mints HyTokens to the user’s address when they deposit assets into the protocol.
Call Params
Name | Type | Description |
---|---|---|
user | address | The address receiving the minted tokens |
amount | uint256 | The amount of tokens to mint |
index | uint256 | The liquidity index of the reserve |
Return Values
Type | Description |
---|---|
bool | True if the mint was successful |
burn
function burn(
address user,
address receiverOfUnderlying,
uint256 amount,
uint256 index
) external returns (bool)
Burns HyTokens when a user withdraws their underlying assets from the protocol.
Call Params
Name | Type | Description |
---|---|---|
user | address | The address from which to burn tokens |
receiverOfUnderlying | address | The address that will receive the underlying |
amount | uint256 | The amount to burn |
index | uint256 | The liquidity index of the reserve |
Return Values
Type | Description |
---|---|
bool | True if the burn was successful |
transferOnLiquidation
function transferOnLiquidation(
address from,
address to,
uint256 value
) external
Transfers HyTokens from one address to another during liquidation events.
Call Params
Name | Type | Description |
---|---|---|
from | address | The address sending the tokens |
to | address | The address receiving the tokens |
value | uint256 | The amount of tokens to transfer |
View Methods
UNDERLYING_ASSET_ADDRESS
function UNDERLYING_ASSET_ADDRESS() external view returns (address)
Returns the address of the underlying asset of this HyToken.
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 HyToken is used.
Return Values
Type | Description |
---|---|
address | The address of the lending pool |
scaledBalanceOf
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.
Call Params
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Return Values
Type | Description |
---|---|
uint256 | The scaled balance of the user |
Events
Mint
event Mint(
address indexed from,
uint256 value,
uint256 index
)
Emitted when new HyTokens are minted.
Burn
event Burn(
address indexed from,
address indexed target,
uint256 value,
uint256 index
)
Emitted when HyTokens are burned.
Usage Example
// Deposit 100 DAI into HypurrFi
// User receives 100 hyDAI tokens
lendingPool.deposit(DAI_ADDRESS, 100, userAddress, 0);
// hyDAI balance increases automatically as interest accrues
// After some time, balance might be 102 hyDAI
// Withdraw all hyDAI
// User receives underlying DAI plus earned interest
lendingPool.withdraw(DAI_ADDRESS, type(uint256).max, userAddress);
ABI
[
{
"type": "constructor",
"inputs": [
{
"name": "pool",
"type": "address",
"internalType": "contract IPool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "ATOKEN_REVISION",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"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": "PERMIT_TYPEHASH",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bytes32",
"internalType": "bytes32"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "POOL",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IPool"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "RESERVE_TREASURY_ADDRESS",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "UNDERLYING_ASSET_ADDRESS",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "allowance",
"inputs": [
{
"name": "owner",
"type": "address",
"internalType": "address"
},
{
"name": "spender",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "approve",
"inputs": [
{
"name": "spender",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "balanceOf",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "burn",
"inputs": [
{
"name": "from",
"type": "address",
"internalType": "address"
},
{
"name": "receiverOfUnderlying",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "index",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "decimals",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint8",
"internalType": "uint8"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "decreaseAllowance",
"inputs": [
{
"name": "spender",
"type": "address",
"internalType": "address"
},
{
"name": "subtractedValue",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"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": "handleRepayment",
"inputs": [
{
"name": "user",
"type": "address",
"internalType": "address"
},
{
"name": "onBehalfOf",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "increaseAllowance",
"inputs": [
{
"name": "spender",
"type": "address",
"internalType": "address"
},
{
"name": "addedValue",
"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": "treasury",
"type": "address",
"internalType": "address"
},
{
"name": "underlyingAsset",
"type": "address",
"internalType": "address"
},
{
"name": "incentivesController",
"type": "address",
"internalType": "contract IAaveIncentivesController"
},
{
"name": "aTokenDecimals",
"type": "uint8",
"internalType": "uint8"
},
{
"name": "aTokenName",
"type": "string",
"internalType": "string"
},
{
"name": "aTokenSymbol",
"type": "string",
"internalType": "string"
},
{
"name": "params",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "mint",
"inputs": [
{
"name": "caller",
"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"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "mintToTreasury",
"inputs": [
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "index",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"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": "permit",
"inputs": [
{
"name": "owner",
"type": "address",
"internalType": "address"
},
{
"name": "spender",
"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": "rescueTokens",
"inputs": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "to",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"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": "recipient",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "transferFrom",
"inputs": [
{
"name": "sender",
"type": "address",
"internalType": "address"
},
{
"name": "recipient",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "transferOnLiquidation",
"inputs": [
{
"name": "from",
"type": "address",
"internalType": "address"
},
{
"name": "to",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "transferUnderlyingTo",
"inputs": [
{
"name": "target",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"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": "BalanceTransfer",
"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"
},
{
"name": "index",
"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": "treasury",
"type": "address",
"indexed": false,
"internalType": "address"
},
{
"name": "incentivesController",
"type": "address",
"indexed": false,
"internalType": "address"
},
{
"name": "aTokenDecimals",
"type": "uint8",
"indexed": false,
"internalType": "uint8"
},
{
"name": "aTokenName",
"type": "string",
"indexed": false,
"internalType": "string"
},
{
"name": "aTokenSymbol",
"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
}
]