2020-10-23 13:18:01 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
2020-11-20 10:45:20 +00:00
|
|
|
pragma solidity 0.6.12;
|
2020-10-23 13:18:01 +00:00
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
2020-11-23 10:28:57 +00:00
|
|
|
import {LendingPool} from '../protocol/lendingpool/LendingPool.sol';
|
|
|
|
import {
|
|
|
|
LendingPoolAddressesProvider
|
|
|
|
} from '../protocol/configuration/LendingPoolAddressesProvider.sol';
|
|
|
|
import {LendingPoolConfigurator} from '../protocol/lendingpool/LendingPoolConfigurator.sol';
|
|
|
|
import {AToken} from '../protocol/tokenization/AToken.sol';
|
2020-10-23 13:18:01 +00:00
|
|
|
import {
|
|
|
|
DefaultReserveInterestRateStrategy
|
2020-11-23 10:28:57 +00:00
|
|
|
} from '../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol';
|
2020-10-27 09:58:51 +00:00
|
|
|
import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol';
|
2020-11-19 13:23:46 +00:00
|
|
|
import {StringLib} from './StringLib.sol';
|
2020-10-23 13:18:01 +00:00
|
|
|
|
2020-10-27 09:58:51 +00:00
|
|
|
contract ATokensAndRatesHelper is Ownable {
|
2020-10-23 13:18:01 +00:00
|
|
|
address payable private pool;
|
|
|
|
address private addressesProvider;
|
|
|
|
address private poolConfigurator;
|
|
|
|
event deployedContracts(address aToken, address strategy);
|
|
|
|
|
2021-01-28 10:05:19 +00:00
|
|
|
struct InitDeploymentInput {
|
|
|
|
address asset;
|
|
|
|
uint256[6] rates;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ConfigureReserveInput {
|
|
|
|
address asset;
|
|
|
|
uint256 baseLTV;
|
|
|
|
uint256 liquidationThreshold;
|
|
|
|
uint256 liquidationBonus;
|
|
|
|
uint256 reserveFactor;
|
|
|
|
bool stableBorrowingEnabled;
|
2021-03-31 15:39:59 +00:00
|
|
|
bool borrowingEnabled;
|
2021-01-28 10:05:19 +00:00
|
|
|
}
|
|
|
|
|
2020-10-23 13:18:01 +00:00
|
|
|
constructor(
|
|
|
|
address payable _pool,
|
|
|
|
address _addressesProvider,
|
|
|
|
address _poolConfigurator
|
|
|
|
) public {
|
|
|
|
pool = _pool;
|
|
|
|
addressesProvider = _addressesProvider;
|
|
|
|
poolConfigurator = _poolConfigurator;
|
|
|
|
}
|
|
|
|
|
2021-01-28 10:05:19 +00:00
|
|
|
function initDeployment(InitDeploymentInput[] calldata inputParams) external onlyOwner {
|
|
|
|
for (uint256 i = 0; i < inputParams.length; i++) {
|
2020-11-10 13:53:16 +00:00
|
|
|
emit deployedContracts(
|
2021-01-28 10:05:19 +00:00
|
|
|
address(new AToken()),
|
2020-10-23 13:18:01 +00:00
|
|
|
address(
|
|
|
|
new DefaultReserveInterestRateStrategy(
|
|
|
|
LendingPoolAddressesProvider(addressesProvider),
|
2021-01-28 10:05:19 +00:00
|
|
|
inputParams[i].rates[0],
|
|
|
|
inputParams[i].rates[1],
|
|
|
|
inputParams[i].rates[2],
|
|
|
|
inputParams[i].rates[3],
|
|
|
|
inputParams[i].rates[4],
|
|
|
|
inputParams[i].rates[5]
|
2020-10-23 13:18:01 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 10:05:19 +00:00
|
|
|
function configureReserves(ConfigureReserveInput[] calldata inputParams) external onlyOwner {
|
2020-11-28 11:54:54 +00:00
|
|
|
LendingPoolConfigurator configurator = LendingPoolConfigurator(poolConfigurator);
|
2021-01-28 10:05:19 +00:00
|
|
|
for (uint256 i = 0; i < inputParams.length; i++) {
|
2020-11-28 11:54:54 +00:00
|
|
|
configurator.configureReserveAsCollateral(
|
2021-01-28 10:05:19 +00:00
|
|
|
inputParams[i].asset,
|
|
|
|
inputParams[i].baseLTV,
|
|
|
|
inputParams[i].liquidationThreshold,
|
|
|
|
inputParams[i].liquidationBonus
|
2020-10-26 16:43:10 +00:00
|
|
|
);
|
|
|
|
|
2021-03-31 15:39:59 +00:00
|
|
|
if (inputParams[i].borrowingEnabled) {
|
|
|
|
configurator.enableBorrowingOnReserve(
|
|
|
|
inputParams[i].asset,
|
|
|
|
inputParams[i].stableBorrowingEnabled
|
|
|
|
);
|
|
|
|
}
|
2021-01-28 10:05:19 +00:00
|
|
|
configurator.setReserveFactor(inputParams[i].asset, inputParams[i].reserveFactor);
|
2020-10-26 16:43:10 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-23 13:18:01 +00:00
|
|
|
}
|