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

74 lines
2.4 KiB
Solidity
Raw Normal View History

2020-10-23 13:18:01 +00:00
// SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.6.8;
pragma experimental ABIEncoderV2;
import {StableDebtToken} from '../tokenization/StableDebtToken.sol';
import {VariableDebtToken} from '../tokenization/VariableDebtToken.sol';
import {LendingRateOracle} from '../mocks/oracle/LendingRateOracle.sol';
import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.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 concat(string memory a, string memory b) internal pure returns (string memory) {
2020-10-28 17:13:31 +00:00
return string(abi.encodePacked(a, b));
2020-10-23 13:18:01 +00:00
}
function initDeployment(
address[] calldata tokens,
string[] calldata symbols,
address incentivesController
) 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(
pool,
tokens[i],
concat('Aave stable debt bearing ', symbols[i]),
concat('stableDebt', symbols[i]),
incentivesController
)
),
address(
new VariableDebtToken(
pool,
tokens[i],
concat('Aave variable debt bearing ', symbols[i]),
concat('variableDebt', symbols[i]),
incentivesController
)
)
);
}
}
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
}