mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
86 lines
2.6 KiB
Solidity
86 lines
2.6 KiB
Solidity
// SPDX-License-Identifier: agpl-3.0
|
|
pragma solidity 0.6.12;
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
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';
|
|
import {
|
|
DefaultReserveInterestRateStrategy
|
|
} from '../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol';
|
|
import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol';
|
|
import {StringLib} from './StringLib.sol';
|
|
|
|
contract ATokensAndRatesHelper is Ownable {
|
|
address payable private pool;
|
|
address private addressesProvider;
|
|
address private poolConfigurator;
|
|
event deployedContracts(address aToken, address strategy);
|
|
|
|
struct InitDeploymentInput {
|
|
address asset;
|
|
uint256[6] rates;
|
|
}
|
|
|
|
struct ConfigureReserveInput {
|
|
address asset;
|
|
uint256 baseLTV;
|
|
uint256 liquidationThreshold;
|
|
uint256 liquidationBonus;
|
|
uint256 reserveFactor;
|
|
uint256 borrowCap;
|
|
bool stableBorrowingEnabled;
|
|
}
|
|
|
|
constructor(
|
|
address payable _pool,
|
|
address _addressesProvider,
|
|
address _poolConfigurator
|
|
) public {
|
|
pool = _pool;
|
|
addressesProvider = _addressesProvider;
|
|
poolConfigurator = _poolConfigurator;
|
|
}
|
|
|
|
function initDeployment(InitDeploymentInput[] calldata inputParams) external onlyOwner {
|
|
for (uint256 i = 0; i < inputParams.length; i++) {
|
|
emit deployedContracts(
|
|
address(new AToken()),
|
|
address(
|
|
new DefaultReserveInterestRateStrategy(
|
|
LendingPoolAddressesProvider(addressesProvider),
|
|
inputParams[i].rates[0],
|
|
inputParams[i].rates[1],
|
|
inputParams[i].rates[2],
|
|
inputParams[i].rates[3],
|
|
inputParams[i].rates[4],
|
|
inputParams[i].rates[5]
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
function configureReserves(ConfigureReserveInput[] calldata inputParams) external onlyOwner {
|
|
LendingPoolConfigurator configurator = LendingPoolConfigurator(poolConfigurator);
|
|
for (uint256 i = 0; i < inputParams.length; i++) {
|
|
configurator.configureReserveAsCollateral(
|
|
inputParams[i].asset,
|
|
inputParams[i].baseLTV,
|
|
inputParams[i].liquidationThreshold,
|
|
inputParams[i].liquidationBonus
|
|
);
|
|
|
|
configurator.enableBorrowingOnReserve(
|
|
inputParams[i].asset,
|
|
inputParams[i].borrowCap,
|
|
inputParams[i].stableBorrowingEnabled
|
|
);
|
|
configurator.setReserveFactor(inputParams[i].asset, inputParams[i].reserveFactor);
|
|
}
|
|
}
|
|
}
|