DefaultReserveInterestRateStrategy

Implements the calculation of the interest rates depending on the reserve state

_The model of interest rate is based on 2 slopes, one before the OPTIMAL_USAGE_RATIO point of usage and another from that one to 100%.

  • An instance of this same contract, can't be used across different ParaSpace markets, due to the caching of the PoolAddressesProvider_

OPTIMAL_USAGE_RATIO

uint256 OPTIMAL_USAGE_RATIO

This constant represents the usage ratio at which the pool aims to obtain most competitive borrow rates. Expressed in ray

MAX_EXCESS_USAGE_RATIO

uint256 MAX_EXCESS_USAGE_RATIO

This constant represents the excess usage ratio above the optimal. It's always equal to 1-optimal usage ratio. Added as a constant here for gas optimizations. Expressed in ray

ADDRESSES_PROVIDER

contract IPoolAddressesProvider ADDRESSES_PROVIDER

_baseVariableBorrowRate

uint256 _baseVariableBorrowRate

_variableRateSlope1

uint256 _variableRateSlope1

_variableRateSlope2

uint256 _variableRateSlope2

constructor

constructor(contract IPoolAddressesProvider provider, uint256 optimalUsageRatio, uint256 baseVariableBorrowRate, uint256 variableRateSlope1, uint256 variableRateSlope2) public

Constructor.

Parameters

NameTypeDescription

provider

contract IPoolAddressesProvider

The address of the PoolAddressesProvider contract

optimalUsageRatio

uint256

The optimal usage ratio

baseVariableBorrowRate

uint256

The base variable borrow rate

variableRateSlope1

uint256

The variable rate slope below optimal usage ratio

variableRateSlope2

uint256

The variable rate slope above optimal usage ratio

getVariableRateSlope1

function getVariableRateSlope1() external view returns (uint256)

Returns the variable rate slope below optimal usage ratio

Its the variable rate when usage ratio > 0 and <= OPTIMAL_USAGE_RATIO

Return Values

NameTypeDescription

[0]

uint256

The variable rate slope

getVariableRateSlope2

function getVariableRateSlope2() external view returns (uint256)

Returns the variable rate slope above optimal usage ratio

Its the variable rate when usage ratio > OPTIMAL_USAGE_RATIO

Return Values

NameTypeDescription

[0]

uint256

The variable rate slope

getBaseVariableBorrowRate

function getBaseVariableBorrowRate() external view returns (uint256)

Returns the base variable borrow rate

Return Values

NameTypeDescription

[0]

uint256

The base variable borrow rate, expressed in ray

getMaxVariableBorrowRate

function getMaxVariableBorrowRate() external view returns (uint256)

Returns the maximum variable borrow rate

Return Values

NameTypeDescription

[0]

uint256

The maximum variable borrow rate, expressed in ray

CalcInterestRatesLocalVars

struct CalcInterestRatesLocalVars {
  uint256 availableLiquidity;
  uint256 totalDebt;
  uint256 currentVariableBorrowRate;
  uint256 currentLiquidityRate;
  uint256 borrowUsageRatio;
  uint256 supplyUsageRatio;
  uint256 availableLiquidityPlusDebt;
}

calculateInterestRates

function calculateInterestRates(struct DataTypes.CalculateInterestRatesParams params) external view returns (uint256, uint256)

Calculates the interest rates depending on the reserve's state and configurations

Parameters

NameTypeDescription

params

struct DataTypes.CalculateInterestRatesParams

The parameters needed to calculate interest rates

Return Values

NameTypeDescription

[0]

uint256

liquidityRate The liquidity rate expressed in rays

[1]

uint256

variableBorrowRate The variable borrow rate expressed in rays