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

NameTypeDescription
useraddressThe address receiving the minted tokens
amountuint256The amount of tokens to mint
indexuint256The liquidity index of the reserve

Return Values

TypeDescription
boolTrue 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

NameTypeDescription
useraddressThe address from which to burn tokens
receiverOfUnderlyingaddressThe address that will receive the underlying
amountuint256The amount to burn
indexuint256The liquidity index of the reserve

Return Values

TypeDescription
boolTrue 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

NameTypeDescription
fromaddressThe address sending the tokens
toaddressThe address receiving the tokens
valueuint256The 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

TypeDescription
addressThe 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

TypeDescription
addressThe 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

NameTypeDescription
useraddressThe address of the user

Return Values

TypeDescription
uint256The 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