> For the complete documentation index, see [llms.txt](https://docs.tydro.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tydro.com/developers/smart-contracts/interest-rate-strategy.md).

# Interest Rate Strategy

This contract implements the calculation of interest rates based on the state of each reserve. The model follows a **two-slope structure**:

* One slope applies when utilisation is below the `OPTIMAL_USAGE_RATIO`.
* A steeper slope applies once utilisation rises above the optimal point, up to 100%.

Each Tydro market deploys its own instance of the interest rate strategy contract, as it caches the [`PoolAddressesProvider`](/developers/smart-contracts/pool-addresses-provider.md) and cannot be shared across markets

The source code is available on [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol).

### View Methods

#### getVariableRateSlope1

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

Returns the variable rate slope below the optimal usage ratio for the specified reserve. This is the variable rate when the usage ratio is between 0 and OPTIMAL\_USAGE\_RATIO.

**Input Parameters:**

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

**Return Values:**

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

#### getVariableRateSlope2

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

Returns the variable rate slope above the optimal usage ratio for the specified reserve. This is the variable rate when the usage ratio is greater than OPTIMAL\_USAGE\_RATIO.

**Input Parameters:**

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

**Return Values:**

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

#### getBaseVariableBorrowRate

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

Returns the base variable borrow rate for the specified reserve.

**Input Parameters:**

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

**Return Values:**

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

#### getMaxVariableBorrowRate

```
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 |

**Return Values:**

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

#### calculateInterestRates

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

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

**Input Parameters:**

| Name   | Type                                   | Description                                       |
| ------ | -------------------------------------- | ------------------------------------------------- |
| params | DataTypes.CalculateInterestRatesParams | The parameters needed to calculate interest rates |

The DataTypes.CalculateInterestRatesParams struct is composed of the following fields:

| Name                     | Type    | Description                                                                 |
| ------------------------ | ------- | --------------------------------------------------------------------------- |
| unbacked                 | uint256 | The amount of unbacked tokens                                               |
| liquidityAdded           | uint256 | The liquidity added during the operation                                    |
| liquidityTaken           | uint256 | The liquidity taken during the operation                                    |
| totalDebt                | uint256 | The total borrowed from the reserve                                         |
| reserveFactor            | uint256 | The reserve portion of the interest that goes to the treasury of the market |
| reserve                  | address | The address of the reserve                                                  |
| usingVirtualBalance      | bool    | Flag to indicate if the virtual balance is being used                       |
| virtualUnderlyingBalance | uint256 | The virtual balance of underlying asset used 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.tydro.com/developers/smart-contracts/interest-rate-strategy.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
