aave-protocol-v2/contracts/deployments/StableAndVariableTokensHelper.sol

48 lines
1.8 KiB
Solidity
Raw Normal View History

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;
import {StableDebtToken} from '../protocol/tokenization/StableDebtToken.sol';
import {VariableDebtToken} from '../protocol/tokenization/VariableDebtToken.sol';
import {LendingRateOracle} from '../mocks/oracle/LendingRateOracle.sol';
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
contract StableAndVariableTokensHelper is Ownable {
2020-10-23 13:18:01 +00:00
address payable private pool;
address private addressesProvider;
event deployedContracts(address stableToken, address variableToken);
constructor(address payable _pool, address _addressesProvider) public {
pool = _pool;
addressesProvider = _addressesProvider;
}
function initDeployment(address[] calldata tokens, string[] calldata symbols) external onlyOwner {
2020-10-23 13:18:01 +00:00
require(tokens.length == symbols.length, 'Arrays not same length');
require(pool != address(0), 'Pool can not be zero address');
for (uint256 i = 0; i < tokens.length; i++) {
emit deployedContracts(address(new StableDebtToken()), address(new VariableDebtToken()));
2020-10-23 13:18:01 +00:00
}
}
function setOracleBorrowRates(
address[] calldata assets,
uint256[] calldata rates,
address oracle
) external onlyOwner {
require(assets.length == rates.length, 'Arrays not same length');
for (uint256 i = 0; i < assets.length; i++) {
// LendingRateOracle owner must be this contract
LendingRateOracle(oracle).setMarketBorrowRate(assets[i], rates[i]);
}
}
function setOracleOwnership(address oracle, address admin) external onlyOwner {
require(admin != address(0), 'owner can not be zero');
require(LendingRateOracle(oracle).owner() == address(this), 'helper is not owner');
LendingRateOracle(oracle).transferOwnership(admin);
}
2020-10-23 13:18:01 +00:00
}