# ↪ interest rate strategy

**Implements the computation of interest rates based on the current state of the reserve. This interest rate model utilizes two distinct slopes: one applicable before reaching the `OPTIMAL_USAGE_RATIO`, and another that applies from that point up to full utilization (100%).**

Due to caching of the `PoolAddressesProvider`, an instance of this contract cannot be shared across different Hyperlend markets.

The source code is available on GitHub.

***

#### View Methods

**`getVariableRateSlope1`**

```solidity
function getVariableRateSlope1(address reserve) external view returns (uint256)
```

Provides the variable rate slope for the specified reserve when the usage ratio is below the optimal threshold. This rate is relevant when the usage ratio ranges from 0 up to `OPTIMAL_USAGE_RATIO`.

**Input Parameters:**

| Name    | Type    | Description                      |
| ------- | ------- | -------------------------------- |
| reserve | address | The address of the reserve asset |

**Return Values:**

| Type    | Description                   |
| ------- | ----------------------------- |
| uint256 | The variable rate slope value |

***

**`getVariableRateSlope2`**

```solidity
function getVariableRateSlope2(address reserve) external view returns (uint256)
```

Provides the variable rate slope for the specified reserve when the usage ratio exceeds the optimal threshold. This rate applies when the usage ratio is greater than `OPTIMAL_USAGE_RATIO`.

**Input Parameters:**

| Name    | Type    | Description                      |
| ------- | ------- | -------------------------------- |
| reserve | address | The address of the reserve asset |

**Return Values:**

| Type    | Description                   |
| ------- | ----------------------------- |
| uint256 | The variable rate slope value |

***

**`getBaseVariableBorrowRate`**

```solidity
function getBaseVariableBorrowRate(address reserve) external view override returns (uint256)
```

Returns the base variable borrow rate for the given reserve.

**Input Parameters:**

| Name    | Type    | Description                      |
| ------- | ------- | -------------------------------- |
| reserve | address | The address of the reserve asset |

**Return Values:**

| Type    | Description                           |
| ------- | ------------------------------------- |
| uint256 | The base variable borrow rate, in ray |

***

**`getMaxVariableBorrowRate`**

```solidity
function getMaxVariableBorrowRate(address reserve) external view override returns (uint256)
```

Returns the maximum variable borrow rate for the specified reserve.

**Input Parameters:**

| Name    | Type    | Description                      |
| ------- | ------- | -------------------------------- |
| reserve | address | The address of the reserve asset |

**Return Values:**

| Type    | Description                              |
| ------- | ---------------------------------------- |
| uint256 | The maximum variable borrow rate, in ray |

***

**`calculateInterestRates`**

```solidity
function calculateInterestRates(
    DataTypes.CalculateInterestRatesParams memory params
) external view override returns (uint256, uint256)
```

Calculates the interest rates based on the reserve's current state and configurations. This function returns two values: the liquidity rate and the variable borrow rate.

**Input Parameters:**

| Name   | Type                                   | Description                                   |
| ------ | -------------------------------------- | --------------------------------------------- |
| params | DataTypes.CalculateInterestRatesParams | Parameters required to compute interest rates |

The `DataTypes.CalculateInterestRatesParams` struct includes the following fields:

| Name                     | Type    | Description                                                 |
| ------------------------ | ------- | ----------------------------------------------------------- |
| unbacked                 | uint256 | The amount of unbacked tokens                               |
| liquidityAdded           | uint256 | Liquidity added during the operation                        |
| liquidityTaken           | uint256 | Liquidity withdrawn during the operation                    |
| totalDebt                | uint256 | Total amount borrowed from the reserve                      |
| reserveFactor            | uint256 | Portion of interest allocated to the market's treasury      |
| reserve                  | address | The address of the reserve                                  |
| usingVirtualBalance      | bool    | Indicates if a virtual balance is being utilized            |
| virtualUnderlyingBalance | uint256 | Virtual balance of the underlying asset for mintable assets |

**Return Values:**

| Name               | Type    | Description                                |
| ------------------ | ------- | ------------------------------------------ |
| liquidityRate      | uint256 | The liquidity rate, expressed in ray       |
| variableBorrowRate | uint256 | The variable borrow rate, expressed in ray |

***


---

# 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.hyperlend.finance/developer-documentation/core-pools/interest-rate-strategy.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.
