aave-protocol-v2/tasks/full/5-deploy-wethGateWay.ts

33 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-02-22 13:58:16 +00:00
import { task } from 'hardhat/config';
import { AaveConfig } from '../../markets/aave/index';
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
2021-02-22 14:57:48 +00:00
import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration';
2021-02-22 13:58:16 +00:00
import { deployWETHGateway } from '../../helpers/contracts-deployments';
import { DRE } from '../../helpers/misc-utils';
import { eNetwork } from '../../helpers/types';
2021-02-22 13:58:16 +00:00
const CONTRACT_NAME = 'WETHGateway';
task(`full-deploy-weth-gateway`, `Deploys the ${CONTRACT_NAME} contract`)
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`)
.setAction(async ({ verify, pool }, localBRE) => {
await localBRE.run('set-DRE');
const network = <eNetwork>localBRE.network.name;
2021-02-22 13:58:16 +00:00
const poolConfig = loadPoolConfig(pool);
2021-02-22 14:57:48 +00:00
const Weth = await getWethAddress(poolConfig);
2021-02-22 13:58:16 +00:00
const { WethGateway } = poolConfig;
if (!localBRE.network.config.chainId) {
throw new Error('INVALID_CHAIN_ID');
}
let gateWay = getParamPerNetwork(WethGateway, network);
if (gateWay === '') {
const wethGateWay = await deployWETHGateway([Weth], verify);
console.log(`${CONTRACT_NAME}.address`, wethGateWay.address);
console.log(`\tFinished ${CONTRACT_NAME} deployment`);
} else {
console.log(`Weth gateway already deployed. Address: ${gateWay}`);
}
});