> ## Documentation Index
> Fetch the complete documentation index at: https://docs.berachain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Interest Rate Model

> AdaptiveCurveIRM: immutable IRM, target utilization, curve and adaptive mechanisms; supply and borrow rates.

In Bend, the interest rate you pay as a borrower is set by an **Interest Rate Model (IRM)** chosen when the market is created.

The only IRM used for Bend markets is the [AdaptiveCurveIRM](/bend/learn/interest-rates#the-adaptivecurveirm). It differs from typical pool IRMs in two ways:

1. **Immutable**: The model cannot be changed or upgraded. It must respond automatically to market conditions, including rates on other platforms.
2. **Higher target utilization**: Supplied assets in Bend are not used as collateral, so markets don't need to hold large buffers for liquidations. The protocol can target higher utilization and use gentler illiquidity penalties.

The AdaptiveCurveIRM keeps utilization near **90%**. In the short term it avoids utilization drifting too low or too high; over time the rate adapts to market conditions.

Two mechanisms work together:

* [The Curve Mechanism](#the-curve-mechanism)
* [The Adaptive Mechanism](#the-adaptive-mechanism)

## The Curve Mechanism

This mechanism resembles the interest rate curves commonly found in traditional lending protocols.

The curve is defined by the following features:

| Name                       | Description                                                 |
| -------------------------- | ----------------------------------------------------------- |
| Target Rate                | $r_{90\%}$ (corresponding to a target utilization of `0.9`) |
| Fixed Steepness Parameters | c = 4                                                       |

<Frame>
  <img src="https://mintcdn.com/berachain-422fce37/spFyXF2YSQlNtmpH/images/bend/irm-curve-mechanism.png?fit=max&auto=format&n=spFyXF2YSQlNtmpH&q=85&s=75409e2d0ae6fe4c67024f329f92be89" alt="Morpho - Curve Mechanism" width="1200" height="600" data-path="images/bend/irm-curve-mechanism.png" />
</Frame>

> Image provided by [Morpho Docs](https://docs.morpho.org/get-started/resources/contracts/irm#the-curve-mechanism)

Each time you (or any user) interact with the market—e.g. borrow or repay—utilization changes and the rate updates along the curve.

For instance, the following are sample utilization-to-rate relationships:

| Utilization | Rate                |
| ----------- | ------------------- |
| 90%         | $r_{90\%}$          |
| 100%        | $4 \times r_{90\%}$ |

The Curve Mechanism is designed to respond to short-term fluctuations in utilization, helping maintain healthy market liquidity during periods of sudden borrowing or repayment.

## The Adaptive Mechanism

This mechanism continuously shifts the curve to adjust to market conditions over time.

The curve shifts over time so the rate adapts to market conditions even when no one is borrowing or repaying.

<Frame>
  <img src="https://mintcdn.com/berachain-422fce37/spFyXF2YSQlNtmpH/images/bend/irm-adaptive-mechanism.png?fit=max&auto=format&n=spFyXF2YSQlNtmpH&q=85&s=4b14f4b2f079057006071e1ed6f0a29e" alt="Morpho - Adaptive Mechanism" width="1200" height="600" data-path="images/bend/irm-adaptive-mechanism.png" />
</Frame>

> Image provided by [Morpho Docs](https://docs.morpho.org/get-started/resources/contracts/irm#the-adaptive-mechanism)

The adaptive mechanism dynamically shifts the rate curve in response to changing market conditions, even during periods without user interaction.

The key value that moves the curve is $r_{90\%}$—the rate at the target utilization. This value gradually changes over time:

* If utilization rises above the target (90%), $r_{90\%}$ will steadily increase.
* If utilization falls below the target, $r_{90\%}$ will steadily decrease.

The pace at which $r_{90\%}$ moves is recalculated whenever the market is updated (such as through borrowing or repaying). The greater the gap between current and target utilization, the faster $r_{90\%}$ (and thus the whole curve) moves in the appropriate direction.

Example: if utilization stays at 100% for five days, $r_{90\%}$ can roughly double in that period (at maximum speed).

<Tip>
  The values of some
  [constants](https://github.com/morpho-org/morpho-blue-irm/blob/main/src/adaptive-curve-irm/libraries/ConstantsLib.sol)
  are hardcoded into the code deployed on Berachain, such as `TARGET_UTILIZATION`,
  `INITIAL_RATE_AT_TARGET`, etc.
</Tip>

## Formula breakdown

| Name                      | Description                                                                                                        |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| $u$                       | *utilization* - total assets borrowed divided by total assets supplied                                             |
| $t$                       | *time* - the specific moment at which utilization and other parameters are evaluated                               |
| $u(t)$                    | Ratio of total borrow over total supply at time                                                                    |
| $u_{\text{target}} = 0.9$ | Constant target value for utilization (set to 0.9) that the model aims to maintain.                                |
| $\forall t$               | For all *time*                                                                                                     |
| $e$                       | *error* - Difference between the current utilization and the target utilization, divided by a normalization factor |
| $k_{\text{d}}$            | Constant that controls how sharply the interest rate increases when utilization exceeds the target                 |
| $H$                       | The time step (in seconds) between two interest rate updates                                                       |
| $last$                    | Most recent interaction time before or at a specific time                                                          |
| $speed(t)$                | Factor controlling how quickly the interest rate evolves based on utilization changes over time                    |
| $r$                       | Borrow rate                                                                                                        |
| $r_{\text{T}}$            | Rate at target - Interest rate corresponding to the target utilization, updated over time using the speed factors  |

### Utilization

Utilization ($u(t)$) is the ratio of total borrowed assets to total supplied assets at time ($t$), with a constant utilization target ($u_{\text{target}} = 0.9$).

### Error

Error ($e(u)$) is the normalized difference between the current utilization ($u(t)$) and the target utilization ($u_{\text{target}}$), scaled so that the distance between $u_{\text{target}}$ and $u = 1$ equals the distance between $u_{\text{target}}$ and $u = 0$.

$$
\forall t, \quad
e(u) =
\begin{cases}
\dfrac{u(t) - u_{\text{target}}}{1 - u_{\text{target}}}, & \text{if } u(t) > u_{\text{target}} \\
\dfrac{u(t) - u_{\text{target}}}{u_{\text{target}}}, & \text{if } u(t) \le u_{\text{target}}
\end{cases}
$$

<Frame>
  <img src="https://mintcdn.com/berachain-422fce37/spFyXF2YSQlNtmpH/images/bend/irm-formula-error.png?fit=max&auto=format&n=spFyXF2YSQlNtmpH&q=85&s=090cbd20dcd19dce97ef51b8395f3d96" alt="Morpho - Formula Error" width="3600" height="1800" data-path="images/bend/irm-formula-error.png" />
</Frame>

> Image provided by [Morpho Docs](https://docs.morpho.org/get-started/resources/contracts/irm#formal-description)

### Curve

**Curve ($curve(u)$)** determines the shape and sensitivity of the interest rate response to changes in utilization around the target, with different slopes below and above $u_{\text{target}}$ controlled by the constant $k_{\text{d}}$.

$$
\text{curve}(u) =
\begin{cases}
\left(1 - \dfrac{1}{k_d}\right) \cdot e(u) + 1, & \text{if } u \le u_{\text{target}} \\
\left(k_d - 1\right) \cdot e(u) + 1, & \text{if } u > u_{\text{target}}
\end{cases}
$$

with

$$
k_d = 4
$$

### History of interactions

**History of interactions ($H$)** represents the set of all past interaction times up to time ($t$), including the initial time ($0$). Noting that $t_{\text{i}}$ the time at which $i\text{th}$ interaction occurred.

$$
\forall t, \quad H(t) = \{0\} + \{t_i\}_{t_i < t}
$$

### Last interaction

**Last interaction ($last$)** represents the most recent interaction time before or at time ($t$).

$$
\forall t, \quad \text{last}(t) = \max(H(t))
$$

### Speed

**Speed factor ($speed$)** determines how fast the interest rate changes over time based on the error at the last interaction, scaled by ($k_\text{p}$).

$$
\forall t, \quad \text{speed}(t) = \exp\!\left(k_p \cdot e(u(\text{last}(t))) \cdot (t - \text{last}(t))\right), \quad \text{with } k_p = 50
$$

### Rate at target

**Rate at target ($r_{\text{target}}$)** represents the interest rate when utilization equals the target utilization, evolving over time based on the speed factor.

$$
\forall t > 0, \quad r_T(t) = r_T(\text{last}(t)) \cdot \text{speed}(t)
$$

At any time ($t$), the borrow rate ($r$) is given by the formula:

$$
r(t) = r_T(t) \cdot \text{curve}(u(t))
$$

## Calculations

APY is the annualized return for suppliers and cost for borrowers, with compounding. In Bend you use it to compare returns and costs across markets.

### Borrow APY

The Borrow APY is calculated using the following formula:

$$
\text{borrowAPY} = \left( e^{(\text{borrowRate} \times \text{secondsPerYear})} - 1 \right)
$$

Where:

* `borrowRate` is the borrow rate per second, as determined by the Interest Rate Model (IRM).
* `secondsPerYear` represents the total number of seconds in a year (31,536,000).

### Supply APY

The Supply APY is calculated considering the utilization and the fee. The formula is:

$$
\text{supplyAPY} = \text{borrowAPY} \times \text{utilization} \times (1 - \text{fee})
$$

Where:

* `fee` is the fee of the market on a per-market basis and portion of the interest paid by borrowers that is retained by the protocol. See [Yield & Fees](/bend/learn/yield-fees#fee-mechanism) for more details.
* `utilization` is calculated as:

$$
\text{utilization} = \frac{\text{totalBorrowAssets}}{\text{totalSupplyAssets}}
$$

## Constants

The values of the following constants are hardcoded into the [Morpho code deployed on Berachain](https://berascan.com/address/0x24147243f9c08d835C218Cda1e135f8dFD0517D0#code#F7#L1).

* WAD = Wei-based Decimal (WAD = 10^18, meaning 1 WAD = 1.0)

| Parameter                | Description                                       | Value                      |
| ------------------------ | ------------------------------------------------- | -------------------------- |
| `CURVE_STEEPNESS`        | Curve steepness (scaled by WAD)                   | 4                          |
| `ADJUSTMENT_SPEED`       | Adjustment speed per second (scaled by WAD)       | 50/# of seconds per year   |
| `TARGET_UTILIZATION`     | Target utilization (scaled by WAD)                | 90%                        |
| `INITIAL_RATE_AT_TARGET` | Initial rate at target per second (scaled by WAD) | 4%/# of seconds per year   |
| `MIN_RATE_AT_TARGET`     | Minimum rate at target per second (scaled by WAD) | 0.1%/# of seconds per year |
| `MAX_RATE_AT_TARGET`     | Maximum rate at target per second (scaled by WAD) | 200%/# of seconds per year |
