Skip to content

Commit ade6cf8

Browse files
authored
feat: Add zero IR strategy (#818)
* feat: Add zero IR strategy * test: Add test cases for updating reserve interest rate strategy * fix: Format zeroed IR * fix: Use constant instead of immutable for zero values * test: Add rebalance call in tests * fix: Add additional rebalance in test with zero ir
1 parent 37b4d1f commit ade6cf8

File tree

2 files changed

+406
-0
lines changed

2 files changed

+406
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
4+
import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
5+
import {IDefaultInterestRateStrategy} from '../interfaces/IDefaultInterestRateStrategy.sol';
6+
import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol';
7+
import {IPoolAddressesProvider} from '../interfaces/IPoolAddressesProvider.sol';
8+
9+
/**
10+
* @title ZeroReserveInterestRateStrategy contract
11+
* @author Aave
12+
* @notice Interest Rate Strategy contract, with all parameters zeroed.
13+
* @dev It returns zero liquidity and borrow rate.
14+
*/
15+
contract ZeroReserveInterestRateStrategy is IDefaultInterestRateStrategy {
16+
/// @inheritdoc IDefaultInterestRateStrategy
17+
uint256 public constant OPTIMAL_USAGE_RATIO = 0;
18+
19+
/// @inheritdoc IDefaultInterestRateStrategy
20+
uint256 public constant OPTIMAL_STABLE_TO_TOTAL_DEBT_RATIO = 0;
21+
22+
/// @inheritdoc IDefaultInterestRateStrategy
23+
uint256 public constant MAX_EXCESS_USAGE_RATIO = 0;
24+
25+
/// @inheritdoc IDefaultInterestRateStrategy
26+
uint256 public constant MAX_EXCESS_STABLE_TO_TOTAL_DEBT_RATIO = 0;
27+
28+
IPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
29+
30+
// Base variable borrow rate when usage rate = 0. Expressed in ray
31+
uint256 internal constant _baseVariableBorrowRate = 0;
32+
33+
// Slope of the variable interest curve when usage ratio > 0 and <= OPTIMAL_USAGE_RATIO. Expressed in ray
34+
uint256 internal constant _variableRateSlope1 = 0;
35+
36+
// Slope of the variable interest curve when usage ratio > OPTIMAL_USAGE_RATIO. Expressed in ray
37+
uint256 internal constant _variableRateSlope2 = 0;
38+
39+
// Slope of the stable interest curve when usage ratio > 0 and <= OPTIMAL_USAGE_RATIO. Expressed in ray
40+
uint256 internal constant _stableRateSlope1 = 0;
41+
42+
// Slope of the stable interest curve when usage ratio > OPTIMAL_USAGE_RATIO. Expressed in ray
43+
uint256 internal constant _stableRateSlope2 = 0;
44+
45+
// Premium on top of `_variableRateSlope1` for base stable borrowing rate
46+
uint256 internal constant _baseStableRateOffset = 0;
47+
48+
// Additional premium applied to stable rate when stable debt surpass `OPTIMAL_STABLE_TO_TOTAL_DEBT_RATIO`
49+
uint256 internal constant _stableRateExcessOffset = 0;
50+
51+
/**
52+
* @dev Constructor.
53+
* @param provider The address of the PoolAddressesProvider contract
54+
*/
55+
constructor(IPoolAddressesProvider provider) {
56+
ADDRESSES_PROVIDER = provider;
57+
}
58+
59+
/// @inheritdoc IDefaultInterestRateStrategy
60+
function getVariableRateSlope1() external pure returns (uint256) {
61+
return _variableRateSlope1;
62+
}
63+
64+
/// @inheritdoc IDefaultInterestRateStrategy
65+
function getVariableRateSlope2() external pure returns (uint256) {
66+
return _variableRateSlope2;
67+
}
68+
69+
/// @inheritdoc IDefaultInterestRateStrategy
70+
function getStableRateSlope1() external pure returns (uint256) {
71+
return _stableRateSlope1;
72+
}
73+
74+
/// @inheritdoc IDefaultInterestRateStrategy
75+
function getStableRateSlope2() external pure returns (uint256) {
76+
return _stableRateSlope2;
77+
}
78+
79+
/// @inheritdoc IDefaultInterestRateStrategy
80+
function getStableRateExcessOffset() external pure returns (uint256) {
81+
return _stableRateExcessOffset;
82+
}
83+
84+
/// @inheritdoc IDefaultInterestRateStrategy
85+
function getBaseStableBorrowRate() public pure returns (uint256) {
86+
return _variableRateSlope1 + _baseStableRateOffset;
87+
}
88+
89+
/// @inheritdoc IDefaultInterestRateStrategy
90+
function getBaseVariableBorrowRate() external pure override returns (uint256) {
91+
return _baseVariableBorrowRate;
92+
}
93+
94+
/// @inheritdoc IDefaultInterestRateStrategy
95+
function getMaxVariableBorrowRate() external pure override returns (uint256) {
96+
return _baseVariableBorrowRate + _variableRateSlope1 + _variableRateSlope2;
97+
}
98+
99+
/// @inheritdoc IReserveInterestRateStrategy
100+
function calculateInterestRates(
101+
DataTypes.CalculateInterestRatesParams memory
102+
) public pure override returns (uint256, uint256, uint256) {
103+
return (0, 0, 0);
104+
}
105+
}

0 commit comments

Comments
 (0)