# Interest Rate

#### **The Role of Interest Rates in Lending**

Interest rates are the economic engine of lending markets. They serve two critical functions:

1. **Compensation for lenders**: Suppliers earn interest as payment for providing capital and accepting risk
2. **Cost for borrowers**: Borrowers pay interest for the privilege of accessing liquidity without selling their collateral

But how should these rates be determined? Too high, and borrowing becomes unattractive. Too low, and lending doesn't provide adequate returns. The Interest Rate Model (IRM) solves this by dynamically adjusting rates based on market conditions.

#### **IRM-Agnostic Design**

Similar to Linx's oracle flexibility, the protocol supports any interest rate model that implements the standard interface. Each market creator selects their preferred IRM from a protocol-approved set when deploying a market.

This flexibility allows:

* **Market-specific optimization**: Different assets can use different rate curves
* **Economic experimentation**: New rate models can be introduced without protocol changes
* **Long-term adaptability**: Markets can use IRMs designed for their specific characteristics

#### **The IRM Interface**

All Linx-compatible IRMs implement a standardized interface in Ralph:

```ralph
pub fn borrowRate(marketParams: MarketParams, marketState: MarketState) -> U256
```

This function accepts:

* **marketParams**: The immutable parameters defining the market
* **marketState**: Current state (total borrowed, total supplied, etc.)

And returns the instantaneous borrow rate per second, scaled appropriately.

#### **Understanding Rates: Borrow vs Supply**

**Borrow Rate** The interest rate charged to borrowers, expressed as an annual percentage. This is what borrowers pay for their loans.

**Supply Rate** The interest rate earned by lenders, expressed as an annual percentage. This is derived from the borrow rate but adjusted for:

* **Utilization**: How much of the supplied capital is currently borrowed
* **Fees**: Any protocol fees (currently 0% on Linx)

The relationship:

```
Supply Rate = Borrow Rate × Utilization × (1 - Fee)
```

**Why the difference?** Lenders only earn interest on capital that's actively borrowed. If only 50% of supplied capital is borrowed, lenders collectively earn half of what borrowers pay in interest.

#### **Calculating APY from Rates**

Interest compounds continuously in Linx Lending. The Annualized Percentage Yield (APY) accounts for this compounding:

**Borrow APY:**

```
Borrow APY = (1 + borrowRatePerSecond)^secondsPerYear - 1
```

Where `secondsPerYear = 31,536,000`

**Supply APY:**

```
Supply APY = Borrow APY × Utilization × (1 - Fee)
```

**Example:**

* Utilization: 80%
* Fee: 0%
* Borrow APY: \~3.15%
* Supply APY: 3.15% × 0.80 = 2.52%

#### **Market Utilization**

Utilization is the key metric driving interest rate adjustments:

```
Utilization = Total Borrowed / Total Supplied
```

* **High utilization** (e.g., 95%): Most capital is borrowed, liquidity is scarce → rates increase
* **Low utilization** (e.g., 20%): Most capital sits idle → rates decrease
* **Target utilization** (90%): Optimal balance between capital efficiency and liquidity

#### **The DynamicIRM**

Linx's primary IRM implementation combines two mechanisms to maintain optimal market conditions:

**Design Philosophy** \
The DynamicIRM targets a specific utilization rate (90%) by continuously adjusting interest rates. Unlike traditional fixed curves, it adapts to market conditions autonomously - no governance intervention required.

This high target is possible because Linx doesn't rehypothecate collateral. Since collateral remains locked in the market contract, there are no liquidation liquidity constraints, enabling higher capital efficiency.

**The Two Mechanisms**

**1. The Curve Component** A traditional interest rate curve that responds to current utilization:

* Below target utilization → moderate rates
* Near target → rates increase sharply to discourage further borrowing
* Above target → very high rates to encourage repayment

This manages short-term liquidity and prevents utilization spikes.

**2. The Adaptive Component** Automatically shifts the entire curve up or down over time:

* **Utilization above target**: Curve shifts upward, raising rates to reduce borrowing
* **Utilization below target**: Curve shifts downward, lowering rates to encourage borrowing

The adjustment speed increases with distance from target - small deviations cause gradual shifts, large deviations trigger rapid adjustments.

**How They Work Together**

Imagine the curve as a flexible band:

1. The **curve mechanism** stretches the band based on current utilization (immediate response)
2. The **adaptive mechanism** slides the entire band up or down (long-term adjustment)

Together, they create a self-balancing system that discovers market equilibrium rates without external input.

**Visual Behavior:**

* Market starts with initial rates (4%)
* High demand → utilization rises → curve pushes rates up (immediate)
* Sustained high utilization → adaptive mechanism raises the base curve (gradual)
* Eventually, higher rates reduce demand and utilization returns to target
* Process reverses if utilization drops below target

#### **IRM Immutability**

Like all market parameters, the IRM address cannot be changed after market creation. This permanence means:

* **Predictability**: Rate behavior remains consistent forever
* **Autonomy requirement**: IRMs must handle all conditions without updates
* **Selection importance**: Market creators must choose carefully

The DynamicIRM is designed specifically for this constraint - its adaptive nature allows it to handle any market condition across any asset type without requiring governance intervention.

#### **Implementation Notes**

**State Updates** IRM calculations occur on every borrow, repay, supply, or withdraw action. The contract queries the IRM for the current rate and updates accrued interest accordingly.

**Gas Efficiency** IRMs should be optimized for frequent calls. The DynamicIRM uses efficient mathematical operations suitable for Alephium's VM.


---

# 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://docs.linxlabs.org/lending-technical-documentation/interest-rate.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.
