Skip to main content

HToken

Zero-coupon bond that tracks an ERC-20 underlying asset.

Constant Functions

balanceSheet

function balanceSheet() external returns (contract IBalanceSheetV1)

The unique BalanceSheet associated with this HToken.

Return Values

TypeDescription
BalanceSheet contract.

isMatured

function isMatured() external returns (bool)

Checks if the bond matured.

Return Values

TypeDescription
booltrue = bond matured, otherwise it didn't.

maturity

function maturity() external returns (uint256)

Unix timestamp in seconds for when this HToken matures.

totalUnderlyingReserve

function totalUnderlyingReserve() external returns (uint256)

The amount of underlying redeemable after maturation.

underlying

function underlying() external returns (contract IErc20)

The Erc20 underlying, or target, asset for this HToken.

underlyingPrecisionScalar

function underlyingPrecisionScalar() external returns (uint256)

The ratio between normalized precision (1e18) and the underlying precision.

Non-Constant Functions

burn

function burn(
address holder,
uint256 burnAmount
) external

Destroys burnAmount tokens from holder, reducing the token supply.

Emits a {Burn} and a {Transfer} event.

Requirements:

  • Can only be called by the BalanceSheet contract.

Parameters

NameTypeDescription
holderaddressThe account whose hTokens to burn.
burnAmountuint256The amount of hTokens to burn.

mint

function mint(
address beneficiary,
uint256 mintAmount
) external

Prints new tokens into existence and assigns them to beneficiary, increasing the total supply.

Emits a {Mint} and a {Transfer} event.

Requirements:

  • Can only be called by the BalanceSheet contract.

Parameters

NameTypeDescription
beneficiaryaddressThe account to mint the hTokens for.
mintAmountuint256The amount of hTokens to print into existence.

redeem

function redeem(
uint256 hTokenAmount
) external

Pays the token holder the face value after maturation.

Emits a {Redeem} event.

Requirements:

  • Must be called after maturation.
  • The amount to redeem cannot be zero.
  • There must be enough liquidity in the contract.

Parameters

NameTypeDescription
hTokenAmountuint256The amount of hTokens to redeem for the underlying asset.

supplyUnderlying

function supplyUnderlying(
uint256 underlyingAmount
) external

Mints hTokens by supplying an equivalent amount of underlying.

Emits a {SupplyUnderlying} event.

Requirements:

  • The amount to supply cannot be zero.
  • The caller must have allowed this contract to spend underlyingAmount tokens.

Parameters

NameTypeDescription
underlyingAmountuint256The amount of underlying to supply.

_setBalanceSheet

function _setBalanceSheet(
contract IBalanceSheetV1 newBalanceSheet
) external

Updates the address of the BalanceSheet contract.

Throws a {SetBalanceSheet} event.

Requirements:

  • The caller must be the owner.

Parameters

NameTypeDescription
newBalanceSheetcontract IBalanceSheetV1The address of the new BalanceSheet contract.

Events

Burn

  event Burn(
address holder,
uint256 burnAmount
)

Emitted when tokens are burnt.

Parameters

NameTypeDescription
holderaddressThe address of the holder.
burnAmountuint256The amount of burnt tokens.

Mint

  event Mint(
address beneficiary,
uint256 mintAmount
)

Emitted when tokens are minted.

Parameters

NameTypeDescription
beneficiaryaddressThe address of the holder.
mintAmountuint256The amount of minted tokens.

Redeem

  event Redeem(
address account,
uint256 hTokenAmount,
uint256 underlyingAmount
)

Emitted when hTokens are redeemed.

Parameters

NameTypeDescription
accountaddressThe account redeeming the hTokens.
hTokenAmountuint256The amount of redeemed hTokens.
underlyingAmountuint256The amount of received underlying tokens.

SetBalanceSheet

  event SetBalanceSheet(
address owner,
contract IBalanceSheetV1 oldBalanceSheet,
contract IBalanceSheetV1 newBalanceSheet
)

Emitted when the BalanceSheet is set.

Parameters

NameTypeDescription
owneraddressThe address of the owner.
oldBalanceSheetcontract IBalanceSheetV1The address of the old BalanceSheet.
newBalanceSheetcontract IBalanceSheetV1The address of the new BalanceSheet.

SupplyUnderlying

  event SupplyUnderlying(
address account,
uint256 underlyingAmount,
uint256 hTokenAmount
)

Emitted when underlying is supplied in exchange for an equivalent amount of hTokens.

Parameters

NameTypeDescription
accountaddressThe account supplying underlying.
underlyingAmountuint256The amount of supplied underlying.
hTokenAmountuint256The amount of minted hTokens.