> For the complete documentation index, see [llms.txt](https://button-labs.gitbook.io/button/gKgg6YSLPuW40VjoL4W1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://button-labs.gitbook.io/button/gKgg6YSLPuW40VjoL4W1/core/lending-pools.md).

# Lending Pools

### Overview

Button Lending Pools on HyperEVM provide collateralized lending infrastructure specifically designed for providing margin to Button strategies. Button Lending Pools integrate with a margin Accountant to evaluate borrower solvency across the protocol, ensuring platform wide risk management.

This design enables Tailors to borrow against both collateral and the value of its strategies. For example, a Pocket holding a basis trade on HyperCore can borrow against both its deposited BTC collateral and the value of its active trade position (with a haircut), unlocking significantly higher capital efficiency while maintaining robust risk management.

<figure><img src="/files/CfBkRqcDl9AOyGqEWzTB" alt=""><figcaption></figcaption></figure>

### Technical Components

#### Pools

Button Lend pools are isolated strategy specific lending pools, allowing for borrowing of an ERC20 debt asset, using an ERC20 collateral asset for a specific Button strategy.&#x20;

Each pool is independently configured with its own:

* **Interest rate model:** Typically a fixed interest rate
* **LTV:** Loan to value, maximum borrowing power per dollar of collateral
* **Liquidation parameters:** Thresholds and incentives
* **Oracle configuration:** Price feed sources and staleness limits

#### Accountant

The Margin Accountant is a specialized contract that calculates total position health across multiple collateral sources. When a lending pool checks if a borrower is solvent, it delegates to the Accountant, which aggregates:

1. **Collateral in lending pools:** BTC or other assets deposited as collateral
2. **Assets held in Pockets:** Undeployed capital available for margin
3. **HyperCore position values:** Real time valuation of basis trades and other strategies, via an Oracle

The Accountant is configured to apply different discounts depending on the collateral source and Tailor strategy, and returns a unified health factor:

Health Factor = (Total Collateral Value / Total Debt Value) × 100%

This health factor is used to determine solvency and trigger liquidations.&#x20;

#### Liquidations

Liquidations are triggered when the health factor of a Tailor falls below the defined configuration in its Accountant. Liquidations are asynchronous, and processed in phases:

**Phase 1: Liquidation Triggered**

When health falls below the liquidation threshold, the Tailor's pocket is placed into liquidation mode

* Pocket is marked as "liquidating"
* All operations (such as withdrawals) that allow for removal of NAV are blocked

**Phase 2: Position Unwinding**

Agents will begin unwinding the position to bring the Pocket below the liquidation threshold. If debt is fully repaid during this period, the liquidation is cancelled and the Pocket returns to normal operation.

**Phase 3: Collateral Liquidations**

If agents determine that the debt cannot be repayed with only unwinding the position, then collateral is liquidated to repay debt.

#### Oracles

Button lending infrastructure relies on multiple oracle systems to ensure accurate valuation and robust risk management.

1. **Collateral Price Oracles:** All collateral assets (BTC) are priced using Pyth Network oracles. Pyth is a pull-based oracle system that provides high-frequency price feeds with sub-second latency, ideal for volatile crypto markets.
2. **HyperCore Position Oracle:** HyperCore position oracles track the real time value of basis trades and other strategies executed on HyperCore. Unlike collateral price oracles, this oracle reports position specific data. Off chain agents query the Hyperliquid API and submit signed position updates onchain. Only authorized agents can update position data.

### Smart Contracts

Button Lending Pools are built on a modified version of [fraxlend](https://docs.frax.finance/fraxlend), a battle tested isolated lending pair protocol. We chose Fraxlend as our foundation because it provides:

* **Isolated risk pools:** Each lending pair operates independently
* **Flexible interest rate models:** Variable, linear, or fixed rate calculators
* Efficient share based accounting
* Ease of modifications

The source code for Button’s modified version can be found [here](https://github.com/buttonxyz/button-fraxlend), and audits of the modifications can be found [here](https://github.com/buttonxyz/button-fraxlend/reports/audits).
