Skip to content

Commit

Permalink
Merge pull request aave-dao#25 from aave/fix/ir-strategy2-misc
Browse files Browse the repository at this point in the history
fix: Fix misc on DefaultInterestRateStrategyV2
  • Loading branch information
kyzia551 authored Jun 18, 2024
2 parents 0025683 + 6e77b56 commit 3c991c4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/Aave-v3.1-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<br>

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/contracts/protocol/libraries/helpers/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tests/core/RateStrategy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 3c991c4

Please sign in to comment.