2020-11-26 15:11:40 +00:00
|
|
|
import { task } from 'hardhat/config';
|
|
|
|
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-11-26 15:11:40 +00:00
|
|
|
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
|
2020-11-05 11:35:50 +00:00
|
|
|
import {
|
|
|
|
ConfigNames,
|
|
|
|
loadPoolConfig,
|
|
|
|
getGenesisPoolAdmin,
|
|
|
|
getEmergencyAdmin,
|
|
|
|
} from '../../helpers/configuration';
|
2020-11-26 15:11:40 +00:00
|
|
|
import { eEthereumNetwork } from '../../helpers/types';
|
|
|
|
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)}`)
|
2020-11-26 15:11:40 +00:00
|
|
|
.setAction(async ({ verify, pool }, DRE) => {
|
2020-11-16 18:22:22 +00:00
|
|
|
await DRE.run('set-DRE');
|
|
|
|
|
|
|
|
const network = <eEthereumNetwork>DRE.network.name;
|
2020-08-26 10:38:52 +00:00
|
|
|
const poolConfig = loadPoolConfig(pool);
|
2020-11-26 15:11:40 +00:00
|
|
|
const { ProviderId, MarketId } = poolConfig;
|
2020-08-26 10:38:52 +00:00
|
|
|
|
|
|
|
const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
|
|
|
// Deploy address provider and set genesis manager
|
2020-11-26 15:11:40 +00:00
|
|
|
const addressesProvider = await deployLendingPoolAddressesProvider(MarketId, verify);
|
2020-11-12 13:12:26 +00:00
|
|
|
|
2020-11-05 11:35:50 +00:00
|
|
|
await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
|
2020-11-16 15:08:07 +00:00
|
|
|
await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
|
2020-11-05 11:35:50 +00:00
|
|
|
|
2020-11-16 15:08:07 +00:00
|
|
|
console.log('Pool Admin', await addressesProvider.getPoolAdmin());
|
|
|
|
console.log('Emergency Admin', await addressesProvider.getEmergencyAdmin());
|
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
|
2020-11-16 15:08:07 +00:00
|
|
|
const addressesProviderRegistry = notFalsyOrZeroAddress(providerRegistryAddress)
|
|
|
|
? await getLendingPoolAddressesProviderRegistry(providerRegistryAddress)
|
|
|
|
: await deployLendingPoolAddressesProviderRegistry(verify);
|
2020-08-26 10:38:52 +00:00
|
|
|
|
|
|
|
await waitForTx(
|
|
|
|
await addressesProviderRegistry.registerAddressesProvider(
|
|
|
|
addressesProvider.address,
|
|
|
|
ProviderId
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|