This section provides a technical deep dive into the implementation details of isolated markets in HypurrFi.For a conceptual overview of what isolated markets are and their benefits, please refer to the Isolated Lending Markets section. For additional details, see the Fraxlend documentation.Isolated Markets are a fundamental primitive within the isolated markets protocol, implementing specialized lending and borrowing functionality between pairs of ERC-20 tokens.The technical design follows a shares-based accounting model that enables gas-efficient interest accrual and position management.
Each pair is an isolated market to borrow a single ERC-20 token (known as the Asset Token) by depositing a different ERC-20 token (known as the Collateral Token).When Lenders deposit Asset Tokens into the Pair, they receive hyTokens. hyTokens are ERC-20 tokens and are redeemable for Asset Tokens (sometimes referred to as the underlying asset).As interest is accrued, hyTokens are redeemable for increasing amounts of the underlying asset.Borrowers deposit Collateral Tokens into the Pair and in exchange receive the right to borrow Asset Tokens.
Each borrower’s position has a Loan-To-Value (LTV). This represents the ratio between the value of the assets borrowed and the value of the collateral deposited. The LTV changes when:
The exchange rate between Asset and Collateral Tokens moves
Interest is capitalized
If a borrower’s LTV rises above the Maximum LTV, their position is considered unhealthy. To remediate this, a borrower can:
Add collateral
Repay debt
The Maximum LTV value is immutable and configured at deployment.Typically the value is set to 75%. Custom Term Sheet deployments can set this value manually, even creating under-collateralized loans by setting the value above 100%.Maximum LTV configured above 100% must be accompanied by a borrower whitelist to protect against malicious actors.
When lenders deposit Asset Tokens, they receive hyTokens at the current hyToken Share Price. hyTokens represent:
A lender’s share of the total amount of underlying assets deposited
Capitalized interest from borrowers
As interest accrues, the Share Price increases. Upon redemption, hyTokens are redeemable for an ever-increasing amount of Asset Tokens which includes capitalized interest.
The Vault Account is a core concept to all accounting in the Pair. A Vault Account is a struct containing:
Copy
Ask AI
struct VaultAccount { // Represents the total amount of tokens in the vault uint128 amount; // Analogous to market capitalization // Represents the total number of shares or claims to the vault uint128 shares; // Analogous to shares outstanding}
The Shares represent the total number of claims to the amount. Shares can be redeemed for Asset Tokens. The rate of redemption, known as the Share Price, is determined by: