Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Gho steward v2 #388

Merged
merged 29 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6763340
feat: basic gho steward
JoaquinBattilana Feb 9, 2024
45361a1
feat: init tests for gho steward
JoaquinBattilana Feb 9, 2024
426e39c
feat:updateBorrowCap tests
JoaquinBattilana Feb 9, 2024
7dc49c4
feat: polish tests for GhoStewardV2
JoaquinBattilana Feb 12, 2024
1f23190
feat: new parameters requeriments and natspec for GhoStewardV2
JoaquinBattilana Feb 16, 2024
1373dae
feat: initial test suit for GhoStewardV2
JoaquinBattilana Feb 16, 2024
7000996
feat: refactor to updateFacilitator instead of GHO and GSM by separate
JoaquinBattilana Feb 16, 2024
54ecaff
feat: natspec polish
JoaquinBattilana Feb 16, 2024
7c40a3a
feat: fixed tests
JoaquinBattilana Feb 16, 2024
ba70de3
feat: PR feedback + new tests for GhoStewardV2
JoaquinBattilana Feb 19, 2024
e40f895
Merge branch 'main' into feat/gho-steward-v2
JoaquinBattilana Feb 19, 2024
d548248
feat: deleted not used libraries and added setFacilitators tests
JoaquinBattilana Feb 19, 2024
28face8
feat: fixed PR feedback
JoaquinBattilana Feb 22, 2024
79829a5
Merge branch 'main' into feat/gho-steward-v2
JoaquinBattilana Feb 22, 2024
45c7dc5
feat: format fix
JoaquinBattilana Feb 22, 2024
c160ced
feat: PR reviews 3
JoaquinBattilana Feb 22, 2024
6fe257b
feat: added updateGhoBorrowCap
JoaquinBattilana Feb 22, 2024
9b4e8cb
feat: pr reviews and added test for roles removed
JoaquinBattilana Feb 23, 2024
e2b3e4b
feat: added fixed rate strategy factory and deleted requeriment for b…
JoaquinBattilana Mar 1, 2024
7f42dfc
feat: fixed natspec
JoaquinBattilana Mar 1, 2024
967025c
feat: more natspec cleaning
JoaquinBattilana Mar 1, 2024
7d33cbb
feat: deleted old test
JoaquinBattilana Mar 1, 2024
c23dd42
feat: added tests for decrease gho borrow rate
JoaquinBattilana Mar 1, 2024
2de50ff
feat: added test for missing constructor
JoaquinBattilana Mar 1, 2024
4f67e2e
feat: added FixedRateStrategyFactory tests
JoaquinBattilana Mar 1, 2024
1962c0e
feat: made strategy factory initializable and moved it to correct dir…
JoaquinBattilana Mar 5, 2024
1e9e2c9
feat: PR feedback
JoaquinBattilana Mar 7, 2024
dfabf24
feat: moved event test to common cases instead of separate test
JoaquinBattilana Mar 7, 2024
32f4ff2
fix: Update values for input validation
miguelmtzinf Mar 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {IDefaultInterestRateStrategy} from '@aave/core-v3/contracts/interfaces/IDefaultInterestRateStrategy.sol';
import {VersionedInitializable} from '@aave/core-v3/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol';
import {IFixedRateStrategyFactory} from './interfaces/IFixedRateStrategyFactory.sol';
import {GhoInterestRateStrategy} from './GhoInterestRateStrategy.sol';

/**
* @title FixedRateStrategyFactory
* @author Aave Labs
* @notice Factory contract to create and keep record of Aave v3 fixed rate strategy contracts
* @dev `GhoInterestRateStrategy` is used to provide a fixed interest rate strategy.
*/
contract FixedRateStrategyFactory is VersionedInitializable, IFixedRateStrategyFactory {
///@inheritdoc IFixedRateStrategyFactory
address public immutable POOL_ADDRESSES_PROVIDER;

mapping(uint256 => address) internal _strategiesByRate;
address[] internal _strategies;

/**
* @dev Constructor
* @param addressesProvider The address of the PoolAddressesProvider of Aave V3 Pool
*/
constructor(address addressesProvider) {
require(addressesProvider != address(0), 'INVALID_ADDRESSES_PROVIDER');
POOL_ADDRESSES_PROVIDER = addressesProvider;
}

/**
* @notice FixedRateStrategyFactory initializer
* @dev asumes that the addresses provided are fixed rate deployed strategies.
* @param fixedRateStrategiesList List of fixed rate strategies
*/
function initialize(address[] memory fixedRateStrategiesList) external initializer {
for (uint256 i = 0; i < fixedRateStrategiesList.length; i++) {
address fixedRateStrategy = fixedRateStrategiesList[i];
uint256 rate = IDefaultInterestRateStrategy(fixedRateStrategy).getBaseVariableBorrowRate();

_strategiesByRate[rate] = fixedRateStrategy;
_strategies.push(fixedRateStrategy);

emit RateStrategyCreated(fixedRateStrategy, rate);
}
}

///@inheritdoc IFixedRateStrategyFactory
function createStrategies(uint256[] memory fixedRateList) public returns (address[] memory) {
address[] memory strategies = new address[](fixedRateList.length);
for (uint256 i = 0; i < fixedRateList.length; i++) {
uint256 rate = fixedRateList[i];
address cachedStrategy = _strategiesByRate[rate];

if (cachedStrategy == address(0)) {
cachedStrategy = address(new GhoInterestRateStrategy(POOL_ADDRESSES_PROVIDER, rate));
_strategiesByRate[rate] = cachedStrategy;
_strategies.push(cachedStrategy);

emit RateStrategyCreated(cachedStrategy, rate);
}

strategies[i] = cachedStrategy;
}

return strategies;
}

///@inheritdoc IFixedRateStrategyFactory
function getAllStrategies() external view returns (address[] memory) {
return _strategies;
}

///@inheritdoc IFixedRateStrategyFactory
function getStrategyByRate(uint256 borrowRate) external view returns (address) {
return _strategiesByRate[borrowRate];
}

/// @inheritdoc IFixedRateStrategyFactory
function REVISION() public pure virtual override returns (uint256) {
return 1;
}

/// @inheritdoc VersionedInitializable
function getRevision() internal pure virtual override returns (uint256) {
return REVISION();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IFixedRateStrategyFactory {
/**
* @dev Emitted when a new strategy is created
* @param strategy The address of the new fixed rate strategy
* @param rate The rate of the new strategy, expressed in ray (e.g. 0.0150e27 results in 1.50%)
*/
event RateStrategyCreated(address indexed strategy, uint256 indexed rate);

/**
* @notice Creates new fixed rate strategy contracts from a list of rates.
* @dev Returns the address of a cached contract if a strategy with same rate already exists
* @param fixedRateList The list of rates for interest rates strategies, expressed in ray (e.g. 0.0150e27 results in 1.50%)
* @return The list of fixed interest rate strategy contracts
*/
function createStrategies(uint256[] memory fixedRateList) external returns (address[] memory);

/**
* @notice Returns the address of the Pool Addresses Provider of Aave
* @return The address of the PoolAddressesProvider of Aave
*/
function POOL_ADDRESSES_PROVIDER() external view returns (address);

/**
* @notice Returns all the fixed interest rate strategy contracts of the factory
* @return The list of fixed interest rate strategy contracts
*/
function getAllStrategies() external view returns (address[] memory);

/**
* @notice Returns the fixed interest rate strategy contract which corresponds to the given rate.
* @dev Returns `address(0)` if there is no interest rate strategy for the given rate
* @param rate The rate of the fixed interest rate strategy contract
* @return The address of the fixed interest rate strategy contract
*/
function getStrategyByRate(uint256 rate) external view returns (address);

/**
* @notice Returns the FixedRateStrategyFactory revision number
* @return The revision number
*/
function REVISION() external pure returns (uint256);
}
Loading
Loading