2021-01-15 15:48:54 +00:00
|
|
|
import { task } from 'hardhat/config';
|
2020-11-16 15:08:07 +00:00
|
|
|
import {
|
|
|
|
getEthersSignersAddresses,
|
|
|
|
insertContractAddressInDb,
|
|
|
|
} from '../../helpers/contracts-helpers';
|
2020-08-20 15:35:05 +00:00
|
|
|
import {
|
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-15 15:48:54 +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-15 15:48:54 +00:00
|
|
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
2020-09-24 15:48:29 +00:00
|
|
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
2021-01-15 15:48:54 +00:00
|
|
|
.setAction(async ({ verify }, DRE: HardhatRuntimeEnvironment) => {
|
2020-11-12 13:41:08 +00:00
|
|
|
try {
|
|
|
|
await DRE.run('set-DRE');
|
|
|
|
|
|
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
|
|
|
|
|
|
|
// Deploy lending pool
|
|
|
|
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);
|
|
|
|
|
|
|
|
// Deploy lending pool configurator
|
|
|
|
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
|
|
|
|
);
|
|
|
|
// Deploy deployment helpers
|
|
|
|
await deployStableAndVariableTokensHelper(
|
|
|
|
[lendingPoolProxy.address, addressesProvider.address],
|
|
|
|
verify
|
|
|
|
);
|
|
|
|
await deployATokensAndRatesHelper(
|
|
|
|
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
|
|
|
verify
|
|
|
|
);
|
|
|
|
} catch (error) {
|
2020-11-16 15:08:07 +00:00
|
|
|
if (DRE.network.name.includes('tenderly')) {
|
|
|
|
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
|
|
|
DRE.config.tenderly.project
|
|
|
|
}/fork/${DRE.tenderlyRPC.getFork()}/simulation/${DRE.tenderlyRPC.getHead()}`;
|
|
|
|
console.error('Check tx error:', transactionLink);
|
|
|
|
}
|
|
|
|
throw error;
|
2020-11-12 13:41:08 +00:00
|
|
|
}
|
2020-08-20 15:35:05 +00:00
|
|
|
});
|