# Interest Calculator

This module handles the calculations of Utilization Rate, Borrow Rate & Supply Rate for all the PalPools.

The Interest Calculator V2 has 2 ways to calculate Borrow & Supply Rates :&#x20;

* The Jump Rate, relying on the Utilization Rate and the liquidity of a Pool
* The Multiplier Rate, also based on the Utilization Rate, but also on some Governance values : the Proposal Threshold, and the Quorum Amount. This method of calculation allows to calculate a Borrow Rate increased by a Multiplier to prevent any cheap access to huge amounts of voting power that could hurt Governances.

Each PalPool is linked to a Multiplier matching the governance token it holds. The switch between the 2 calculation methods can be done for each PalPool individually, and will depend on the TVL of the PalPool, and the amount of voting power it represents.  <br>

### Methods :&#x20;

**utilizationRate**

`function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns(uint);`

Gives the utilization rate of a Pool given the parameters (uint, scaled 1e18):

Utilization rate = Borrows / (Cash + Borrows - Reserves)

***Parameters:***

| name     | type | desc                                          |
| -------- | ---- | --------------------------------------------- |
| cash     | uint | amount of underlying token in the Pool        |
| borrows  | uint | amount borrowed from the Pool                 |
| reserves | uint | amount of the token set in the Pool’s reserve |

**getSupplyRate**

`function getSupplyRate(address palPool, uint cash, uint borrows, uint reserves, uint reserveFactor) external view override returns(uint);`

Returns the Supply Rate for the given parameters (uint, scaled 1e18).

***Parameters:***

| name          | type    | desc                                          |
| ------------- | ------- | --------------------------------------------- |
| palPool       | address | address of the Pool                           |
| cash          | uint    | amount of underlying token in the Pool        |
| borrows       | uint    | amount borrowed from the Pool                 |
| reserves      | uint    | amount of the token set in the Pool’s Reserve |
| reserveFactor | uint    | ratio of borrow fees to set as Reserve        |

&#x20;

**getBorrowRate**

`function getBorrowRate(address palPool, uint cash, uint borrows, uint reserves) external view override returns(uint);`

Returns the Borrow Rate for the given parameters (uint, scaled 1e18).

***Parameters:***

| name     | type    | desc                                          |
| -------- | ------- | --------------------------------------------- |
| palPool  | address | address of the Pool                           |
| cash     | uint    | amount of underlying token in the Pool        |
| borrows  | uint    | amount borrowed from the Pool                 |
| reserves | uint    | amount of the token set in the Pool’s reserve |

###

### Multipliers

Multipliers, when activated through the Interest Calculator, will check the total amount of voting power borrowed from Paladin for a given Governance (the total amount across multiple PalPools if their tokens are used in the same Governance). Using 2 common values in most Governances, the Proposal Threshold and the Quorum Amount, it will return a multiplier used to increase the Borrow Rate to better price large borrowed amounts of voting power.

The Multiplier is triggered when the Total Borrowed from Paladin reaches 75% of the Proposal Threshold for the given Governance, and will increase based on the Total Borrowed compared to the Proposal Threshold and the Quorum Amount based on the formula :&#x20;

$$
m = 1 + ( ( ( tB / 0.75\*pT ) - 1) \* (qA / tB))
$$

tB : Total Borrowed / pT : Proposal Threshold / qA : Quorum Amount

There are currently 2 types of Multipliers:&#x20;

* The Governor Multiplier: Based on Governor Alpha/Bravo contracts, it used for Compound and Uniswap governances (1 for each governance).
* The Aave Multiplier : Based on Aave Governance, and using Proposal Threshold and Quorum Amount from the Short Executor, it is used for both AAVE & stkAAVE PalPools (where the Total Borrowed amount is the sum of the borrowed amount from both PalPools).
