2020-11-26 15:11:40 +00:00
|
|
|
import { task } from 'hardhat/config';
|
2021-05-07 14:59:24 +00:00
|
|
|
import { deployLendingPoolAddressesProvider } from '../../helpers/contracts-deployments';
|
2021-05-10 08:16:13 +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';
|
2021-05-10 08:16:13 +00:00
|
|
|
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
|
|
|
import { eNetwork } from '../../helpers/types';
|
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)}`)
|
2021-05-10 08:16:13 +00:00
|
|
|
.addFlag('skipRegistry')
|
|
|
|
.setAction(async ({ verify, pool, skipRegistry }, DRE) => {
|
2020-11-16 18:22:22 +00:00
|
|
|
await DRE.run('set-DRE');
|
2020-08-26 10:38:52 +00:00
|
|
|
const poolConfig = loadPoolConfig(pool);
|
2021-05-07 14:59:24 +00:00
|
|
|
const { MarketId } = poolConfig;
|
2021-05-07 13:15:15 +00:00
|
|
|
|
2021-05-07 14:59:24 +00:00
|
|
|
// 1. Deploy address provider and set genesis manager
|
2020-11-30 18:25:06 +00:00
|
|
|
const addressesProvider = await deployLendingPoolAddressesProvider(MarketId, verify);
|
2021-02-23 14:42:47 +00:00
|
|
|
|
2021-05-10 08:16:13 +00:00
|
|
|
// 2. Add to registry or setup a new one
|
|
|
|
if (!skipRegistry) {
|
|
|
|
const providerRegistryAddress = getParamPerNetwork(
|
|
|
|
poolConfig.ProviderRegistry,
|
|
|
|
<eNetwork>DRE.network.name
|
|
|
|
);
|
2021-02-23 14:42:47 +00:00
|
|
|
|
2021-05-10 08:16:13 +00:00
|
|
|
await DRE.run('add-market-to-registry', {
|
|
|
|
pool,
|
|
|
|
addressesProvider: addressesProvider.address,
|
|
|
|
deployRegistry: !notFalsyOrZeroAddress(providerRegistryAddress),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// 3. Set pool admins
|
2020-11-30 18:25:06 +00:00
|
|
|
await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
|
|
|
|
await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
|
|
|
|
|
|
|
|
console.log('Pool Admin', await addressesProvider.getPoolAdmin());
|
|
|
|
console.log('Emergency Admin', await addressesProvider.getEmergencyAdmin());
|
2020-08-26 10:38:52 +00:00
|
|
|
});
|