# DefaultReserveInterestRateStrategy

The DefaultReserveInterestRateStrategy contract is essentially the on-chain interest rate model. It contains two key functions:

1. `calculateInterestRates`
2. `_getOverallBorrowRate`

`calculateInterestRates` calculates the latest supply, variable borrow and stable borrow rates as explained previously.

`_getOverallBorrowRate` calculates the overall borrow rate given how much stable and variable rate loans have been taken.

### Parameters

Each asset has its interest rate parameters stored on-chain via a `DefaultReserveInterestRateStrategy` contract.&#x20;

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FKngz72gJap4aqO2R9Ma9%2Fimage.png?alt=media&#x26;token=e9f7fae0-86d4-4193-9807-62e476ee5727" alt=""><figcaption></figcaption></figure>

These parameters are set in the constructor on deployment. We can explore their values by interacting with the deployed contract. For example, DAI contract on mainnet:&#x20;

<https://etherscan.io/address/0x694d4cFdaeE639239df949b6E24Ff8576A00d1f2#readContract>&#x20;

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FC68Hp9HgwuzNrXNeBOvE%2Fimage.png?alt=media&#x26;token=20fe5ff6-3235-4625-950a-692f9627cb46" alt=""><figcaption><p>on-chain parameters</p></figcaption></figure>

```python
R_intercept = 0
R_slope1 = 0.04
R_slope2 = 0.75
U_optimal = 0.80
```

These parameters were obtained from DAI's `DefaultReserveInterestRateStrategy` contract, and are accurate at time of writing.&#x20;

{% hint style="info" %}
Other contract addresses: <https://docs.aave.com/developers/deployed-contracts/v3-mainnet/ethereum-mainnet>
{% endhint %}

{% hint style="success" %}
Periodically, parameters are modified to better suit market conditions. Proposals to update these parameters are submitted and passed via Aave's governance.
{% endhint %}

## \_getOverallBorrowRate

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FxBWfNhCzN5jROdlqjcUG%2Fimage.png?alt=media&#x26;token=ff1bbbd5-1f70-495d-93e0-1a47cbdfdf4e" alt=""><figcaption></figcaption></figure>

Calculates the overall borrow rate as the weighted average between the total variable debt and total stable debt.

## calculateInterestRates

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FGUXNsFURTvS8cDfNDruK%2Fimage.png?alt=media&#x26;token=d72b364a-85f0-44b0-b164-104b6c2bd25f" alt=""><figcaption></figcaption></figure>

Executed as part of **.updateInterestRates**, it is usually ran towards the end of a state-changing function (borrow, supply, etc). It calculates the new interest rates for

* supply
* variable borrow
* stable borrow

given that liquidity conditions and utilization have changed. This is well explained in the common functions section: [calculateInterestRates](https://calnix.gitbook.io/aave-book/functions/common-functions/.updateinterestrates#.calculateinterestrates).
