Aave V3 Interest Rate Strategy
Implements the calculation of the interest rates depending on the reserve state. The model of interest rate is based on two slopes, one before the reserve’s optimal usage ratio and another from that point to 100%. Rates are set per reserve through Pool.
With utilization U and optimal usage ratio Uoptimal, the variable borrow rate is:
Each Aave market needs its own instance of this contract, because it caches the PoolAddressesProvider.
The source code is available on GitHub.
View Methods
getInterestRateData
function getInterestRateData(address reserve) external view returns (InterestRateDataRay memory)
Returns the interest rate parameters of the specified reserve, in ray.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| reserve | address | The address of the reserve |
Return Values:
| Type | Description |
|---|---|
Interest | optimal, base, variable and variable, all expressed in ray |
getInterestRateDataBps
function getInterestRateDataBps(address reserve) external view returns (InterestRateData memory)
Returns the interest rate parameters of the specified reserve, in bps.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| reserve | address | The address of the reserve |
Return Values:
| Type | Description |
|---|---|
Interest | optimal, base, variable and variable, all expressed in bps |
getOptimalUsageRatio
function getOptimalUsageRatio(address reserve) external view returns (uint256)
Returns the optimal usage ratio of the specified reserve.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| reserve | address | The address of the reserve |
Return Values:
| Type | Description |
|---|---|
uint256 | The optimal usage ratio, expressed in ray |
getVariableRateSlope1
function getVariableRateSlope1(address reserve) external view returns (uint256)
Returns the variable rate slope below the optimal usage ratio for the specified reserve. Applies while the usage ratio is below the optimal usage ratio.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| reserve | address | The address of the reserve |
Return Values:
| Type | Description |
|---|---|
uint256 | The variable rate slope, expressed in ray |
getVariableRateSlope2
function getVariableRateSlope2(address reserve) external view returns (uint256)
Returns the variable rate slope above the optimal usage ratio for the specified reserve. Applies while the usage ratio is above the optimal usage ratio.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| reserve | address | The address of the reserve |
Return Values:
| Type | Description |
|---|---|
uint256 | The variable rate slope, expressed in ray |
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 | Data | The parameters needed to calculate interest rates |
The Data struct is composed of the following fields:
| Name | Type | Description |
|---|---|---|
| unbacked | uint256 | The reserve deficit (field kept under its pre-V3.4 name); added to the denominator of the supply usage ratio |
| 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 | Deprecated since Aave V3.4, always true |
| virtualUnderlyingBalance | uint256 | The virtual balance of the underlying asset held by the reserve |
Return Values:
| Name | Type | Description |
|---|---|---|
| liquidityRate | uint256 | The liquidity rate, expressed in ray |
| variableBorrowRate | uint256 | The variable borrow rate, expressed in ray |