2021-01-27 14:43:34 +00:00
|
|
|
import { task } from 'hardhat/config';
|
2020-08-20 15:35:05 +00:00
|
|
|
import {
|
2021-07-14 14:41:32 +00:00
|
|
|
deployATokenImplementations,
|
2020-10-27 09:58:51 +00:00
|
|
|
deployATokensAndRatesHelper,
|
2020-08-20 15:35:05 +00:00
|
|
|
deployLendingPool,
|
|
|
|
deployLendingPoolConfigurator,
|
2020-10-27 09:58:51 +00:00
|
|
|
deployStableAndVariableTokensHelper,
|
2020-10-16 09:27:09 +00:00
|
|
|
} from '../../helpers/contracts-deployments';
|
2021-01-27 14:43:34 +00:00
|
|
|
import { eContractid } from '../../helpers/types';
|
|
|
|
import { waitForTx } from '../../helpers/misc-utils';
|
2020-10-15 11:57:03 +00:00
|
|
|
import {
|
|
|
|
getLendingPoolAddressesProvider,
|
|
|
|
getLendingPool,
|
|
|
|
getLendingPoolConfiguratorProxy,
|
|
|
|
} from '../../helpers/contracts-getters';
|
2021-01-27 14:43:34 +00:00
|
|
|
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
2021-07-14 14:41:32 +00:00
|
|
|
import { ConfigNames, loadPoolConfig } from '../../helpers/configuration';
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
2020-11-02 13:45:00 +00:00
|
|
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
2021-07-14 14:41:32 +00:00
|
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
|
|
|
.setAction(async ({ verify, pool }, localBRE) => {
|
2020-11-05 12:44:20 +00:00
|
|
|
await localBRE.run('set-DRE');
|
2020-08-20 15:35:05 +00:00
|
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
2021-07-14 14:41:32 +00:00
|
|
|
const poolConfig = loadPoolConfig(pool);
|
2020-08-20 15:35:05 +00:00
|
|
|
|
|
|
|
const lendingPoolImpl = await deployLendingPool(verify);
|
|
|
|
|
|
|
|
// Set lending pool impl to Address Provider
|
|
|
|
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address));
|
|
|
|
|
|
|
|
const address = await addressesProvider.getLendingPool();
|
|
|
|
const lendingPoolProxy = await getLendingPool(address);
|
|
|
|
|
|
|
|
await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address);
|
|
|
|
|
|
|
|
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify);
|
|
|
|
|
|
|
|
// Set lending pool conf impl to Address Provider
|
|
|
|
await waitForTx(
|
|
|
|
await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImpl.address)
|
|
|
|
);
|
|
|
|
|
|
|
|
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(
|
|
|
|
await addressesProvider.getLendingPoolConfigurator()
|
|
|
|
);
|
|
|
|
await insertContractAddressInDb(
|
|
|
|
eContractid.LendingPoolConfigurator,
|
|
|
|
lendingPoolConfiguratorProxy.address
|
|
|
|
);
|
2020-10-27 09:58:51 +00:00
|
|
|
|
|
|
|
// Deploy deployment helpers
|
|
|
|
await deployStableAndVariableTokensHelper(
|
|
|
|
[lendingPoolProxy.address, addressesProvider.address],
|
|
|
|
verify
|
|
|
|
);
|
|
|
|
await deployATokensAndRatesHelper(
|
|
|
|
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
|
|
|
verify
|
|
|
|
);
|
2021-07-14 14:41:32 +00:00
|
|
|
await deployATokenImplementations(pool, poolConfig.ReservesConfig, verify);
|
2020-08-20 15:35:05 +00:00
|
|
|
});
|