diff --git a/docs/Aave-v3.1-features.md b/docs/Aave-v3.1-features.md index 0e3a2b95..8a15dbd2 100644 --- a/docs/Aave-v3.1-features.md +++ b/docs/Aave-v3.1-features.md @@ -120,7 +120,7 @@ Implementation-wise, this feature: - [ConfigurationInputTypes](../src/core/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol) - Added `interestRateData` on the `InitReserveInput` used on listing. - [Errors](../src/core/contracts/protocol/libraries/helpers/Errors.sol) - - In relation with this feature, added the `INVALID_MAXRATE` and `SLOPE_2_MUST_BE_GTE_SLOPE_1` errors. + - In relation with this feature, added the `INVALID_MAX_RATE` and `SLOPE_2_MUST_BE_GTE_SLOPE_1` errors.
diff --git a/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol b/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol index c0e1afae..5b8b0149 100644 --- a/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol +++ b/src/core/contracts/interfaces/IDefaultInterestRateStrategyV2.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import './IReserveInterestRateStrategy.sol'; +import {IReserveInterestRateStrategy} from './IReserveInterestRateStrategy.sol'; import {IPoolAddressesProvider} from './IPoolAddressesProvider.sol'; /** diff --git a/src/core/contracts/protocol/libraries/helpers/Errors.sol b/src/core/contracts/protocol/libraries/helpers/Errors.sol index 2e4521b4..208b561c 100644 --- a/src/core/contracts/protocol/libraries/helpers/Errors.sol +++ b/src/core/contracts/protocol/libraries/helpers/Errors.sol @@ -97,7 +97,7 @@ library Errors { string public constant SILOED_BORROWING_VIOLATION = '89'; // 'User is trying to borrow multiple assets including a siloed one' string public constant RESERVE_DEBT_NOT_ZERO = '90'; // the total debt of the reserve needs to be 0 string public constant FLASHLOAN_DISABLED = '91'; // FlashLoaning for this asset is disabled - string public constant INVALID_MAXRATE = '92'; // The expect maximum borrow rate is invalid + string public constant INVALID_MAX_RATE = '92'; // The expect maximum borrow rate is invalid string public constant WITHDRAW_TO_ATOKEN = '93'; // Withdrawing to the aToken is not allowed string public constant SUPPLY_TO_ATOKEN = '94'; // Supplying to the aToken is not allowed string public constant SLOPE_2_MUST_BE_GTE_SLOPE_1 = '95'; // Variable interest rate slope 2 can not be lower than slope 1 diff --git a/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol b/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol index 5620eef0..4f0e0834 100644 --- a/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol +++ b/src/core/contracts/protocol/pool/DefaultReserveInterestRateStrategyV2.sol @@ -34,16 +34,9 @@ contract DefaultReserveInterestRateStrategyV2 is IDefaultInterestRateStrategyV2 /// @inheritdoc IDefaultInterestRateStrategyV2 uint256 public constant MAX_OPTIMAL_POINT = 99_00; - /// @dev Underlying asset listed on the Aave pool => rate data - mapping(address reserve => InterestRateData) internal _interestRateData; + /// @dev Map of reserves address and their interest rate data (reserveAddress => interestRateData) + mapping(address => InterestRateData) internal _interestRateData; - /** - * @param provider The address of the PoolAddressesProvider of the associated Aave pool - */ - constructor(address provider) { - require(provider != address(0), Errors.INVALID_ADDRESSES_PROVIDER); - ADDRESSES_PROVIDER = IPoolAddressesProvider(provider); - } modifier onlyPoolConfigurator() { require( @@ -53,6 +46,15 @@ contract DefaultReserveInterestRateStrategyV2 is IDefaultInterestRateStrategyV2 _; } + /** + * @dev Constructor. + * @param provider The address of the PoolAddressesProvider of the associated Aave pool + */ + constructor(address provider) { + require(provider != address(0), Errors.INVALID_ADDRESSES_PROVIDER); + ADDRESSES_PROVIDER = IPoolAddressesProvider(provider); + } + /// @inheritdoc IReserveInterestRateStrategy function setInterestRateParams( address reserve, @@ -203,7 +205,7 @@ contract DefaultReserveInterestRateStrategyV2 is IDefaultInterestRateStrategyV2 /** * @dev Doing validations and data update for an asset * @param reserve address of the underlying asset of the reserve - * @param rateData Encoded eserve interest rate data to apply + * @param rateData Encoded reserve interest rate data to apply */ function _setInterestRateParams(address reserve, InterestRateData memory rateData) internal { require(reserve != address(0), Errors.ZERO_ADDRESS_NOT_VALID); @@ -225,7 +227,7 @@ contract DefaultReserveInterestRateStrategyV2 is IDefaultInterestRateStrategyV2 uint256(rateData.variableRateSlope1) + uint256(rateData.variableRateSlope2) <= MAX_BORROW_RATE, - Errors.INVALID_MAXRATE + Errors.INVALID_MAX_RATE ); _interestRateData[reserve] = rateData; diff --git a/tests/core/RateStrategy.t.sol b/tests/core/RateStrategy.t.sol index 9cc3e6bb..dd7cf3a8 100644 --- a/tests/core/RateStrategy.t.sol +++ b/tests/core/RateStrategy.t.sol @@ -525,7 +525,7 @@ contract RateStrategyTests is TestnetProcedures { vm.prank(report.poolConfiguratorProxy); - vm.expectRevert(bytes(Errors.INVALID_MAXRATE)); + vm.expectRevert(bytes(Errors.INVALID_MAX_RATE)); rateStrategy.setInterestRateParams(tokenList.usdx, abi.encode(rateData)); } @@ -556,7 +556,7 @@ contract RateStrategyTests is TestnetProcedures { vm.prank(report.poolConfiguratorProxy); - vm.expectRevert(bytes(Errors.INVALID_MAXRATE)); + vm.expectRevert(bytes(Errors.INVALID_MAX_RATE)); rateStrategy.setInterestRateParams(tokenList.usdx, rateData); }