# Supply & Borrow Interest

Helios keeps the well-tested “index” model of AAVE : deposit yield accrues linearly into a *liquidity index*, while borrow debt compounds continuously in a *variable-borrow index*. Both indexes start at **1 RAY (10²⁷)** and grow multiplicatively; Whenever anyone supplies, borrows, repays, or withdraws, the contract updates both indexes—so deposit APY compounds *discretely* on each touch, while borrow APR compounds *every second* through a gas-saving binomial approximation.&#x20;

***

### 1 Overview

***BTC in, hToken out*** (for suppliers)\
Suppliers receive hTokens that rebase upward as the liquidity index grows; borrowers watch their BTC debt rise as the variable-borrow index ticks.

***

### 2 Deposit Interest

#### 2.1 Linear-rate accrual

```solidity
nextLiquidityIndex = prevIndex * (1e27 + r * Δt);
```

* `r` = per-second **liquidityRate**; `Δt` = seconds since the last update.&#x20;
* Because the factor **(1 + r Δt)** multiplies the *previous* index, interest already earned also earns interest → true compounding.&#x20;

Indexes update **only on state-changing calls** (supply, withdraw, borrow, repay, liquidation). Between touches the index is flat; over many touches the multiplicative chain matches continuous compounding.&#x20;

***

### 3 Borrow Interest

#### 3.1 Binomial approximation

$$
(1 + r)^{Δt} ≈ 1 + rΔt + (Δt(Δt−1) / 2) r² + (Δt(Δt−1)(Δt−2) / 6) r³
$$

* Accurate to <0.01 % for multi-year loans, but far cheaper than full exponentiation.&#x20;
* Variable-rate debt compounds for **every** borrower interaction; stable-rate debt compounds only when the holder touches their own position.&#x20;

***

### 4 Putting It Together

| Metric                  | Symbol | Formula                      | Why it matters                     |
| ----------------------- | ------ | ---------------------------- | ---------------------------------- |
| Utilization             | **U**  | borrowed BTC ÷ total BTC     | Drives both borrow & supply rates. |
| Borrow APR              | **rᵦ** | `interestRateModel(U)`       | Piece-wise “kink” curve.           |
| LiquidityRate           | **rₗ** | rᵦ × U × (1 – reserveFactor) | Portion paid to suppliers.         |
| **LiquidityIndex**      | **Iₗ** | Iₗ₍prev₎ × (1 + rₗ Δt)       | Updated on every touch.            |
| **VariableBorrowIndex** | **Iᵥ** | Iᵥ₍prev₎ × binomial(rᵦ, Δt)  | Ticks each second.                 |

Reserve-factor BAC diverts a slice of borrower interest to the Helios treasury; the rest becomes deposit yield.&#x20;

***

### 5 What Suppliers Should Know

1. **hToken balances grow only when the pool is touched**—quiet markets mean the bump shows on the next transaction.
2. **Borrowers pay every second** via the variable-borrow index, even if no one interacts.
3. **High utilisation (> 90 %) or congested mempool condition spikes rates.** Borrow APR jumps sharply; liquidityRate climbs more gently, attracting fresh BTC to restore balance.&#x20;

***

### 6 Key Contract Hooks

| Function                        | Role                                                        |
| ------------------------------- | ----------------------------------------------------------- |
| `updateState()`                 | Refreshes both indexes at the start of every mutative call. |
| `calculateLinearInterest()`     | Computes the supply slice for deposits.                     |
| `calculateCompoundedInterest()` | Applies the binomial borrow interest step.                  |

***

#### Summary

* **Deposits:** simple-interest slices multiplied into a growing liquidity index → discrete but effectively compound yield.
* **Borrows:** continuous compounding via binomial math → debt grows each second.
* **Indexes:** both start at **1 RAY** and scale every balance without touching individual accounts, keeping gas low and accounting transparent.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://helios-finance.gitbook.io/helios-finance/for-developers/supply-and-borrow-interest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
