2020-11-05 11:18:20 +00:00
|
|
|
import {task} from 'hardhat/config';
|
2020-10-16 09:27:09 +00:00
|
|
|
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
|
2020-08-26 10:38:52 +00:00
|
|
|
import {
|
|
|
|
deployLendingPoolAddressesProvider,
|
|
|
|
deployLendingPoolAddressesProviderRegistry,
|
2020-10-16 09:27:09 +00:00
|
|
|
} from '../../helpers/contracts-deployments';
|
2020-08-26 10:38:52 +00:00
|
|
|
import {waitForTx} from '../../helpers/misc-utils';
|
2020-09-24 15:48:29 +00:00
|
|
|
import {ConfigNames, loadPoolConfig, getGenesisAaveAdmin} from '../../helpers/configuration';
|
2020-08-26 10:38:52 +00:00
|
|
|
import {eEthereumNetwork} from '../../helpers/types';
|
2020-10-15 11:57:03 +00:00
|
|
|
import {getLendingPoolAddressesProviderRegistry} from '../../helpers/contracts-getters';
|
2020-08-26 10:38:52 +00:00
|
|
|
|
|
|
|
task(
|
|
|
|
'full:deploy-address-provider',
|
|
|
|
'Deploy address provider, registry and fee provider for dev enviroment'
|
|
|
|
)
|
2020-09-24 15:48:29 +00:00
|
|
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
2020-08-26 10:38:52 +00:00
|
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
|
|
|
.setAction(async ({verify, pool}, localBRE) => {
|
|
|
|
await localBRE.run('set-bre');
|
|
|
|
const network = <eEthereumNetwork>localBRE.network.name;
|
|
|
|
const poolConfig = loadPoolConfig(pool);
|
|
|
|
const {ProviderId} = poolConfig;
|
|
|
|
|
|
|
|
const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
|
|
|
// Deploy address provider and set genesis manager
|
|
|
|
const addressesProvider = await deployLendingPoolAddressesProvider(verify);
|
2020-09-24 15:48:29 +00:00
|
|
|
await waitForTx(await addressesProvider.setAaveAdmin(await getGenesisAaveAdmin(poolConfig)));
|
2020-08-26 10:38:52 +00:00
|
|
|
|
|
|
|
// If no provider registry is set, deploy lending pool address provider registry and register the address provider
|
|
|
|
const addressesProviderRegistry = !providerRegistryAddress
|
|
|
|
? await deployLendingPoolAddressesProviderRegistry(verify)
|
|
|
|
: await getLendingPoolAddressesProviderRegistry(providerRegistryAddress);
|
|
|
|
|
|
|
|
await waitForTx(
|
|
|
|
await addressesProviderRegistry.registerAddressesProvider(
|
|
|
|
addressesProvider.address,
|
|
|
|
ProviderId
|
|
|
|
)
|
|
|
|
);
|
2020-10-20 10:19:07 +00:00
|
|
|
|
|
|
|
//register the proxy price provider on the addressesProvider
|
|
|
|
const proxyProvider = getParamPerNetwork(poolConfig.ProxyPriceProvider, network);
|
|
|
|
|
|
|
|
if (proxyProvider && proxyProvider !== '') {
|
|
|
|
await waitForTx(await addressesProvider.setPriceOracle(proxyProvider));
|
|
|
|
}
|
2020-08-26 10:38:52 +00:00
|
|
|
});
|