feat: updated deployment scripts for the permissioned market

This commit is contained in:
The3D 2021-05-24 10:46:11 +02:00
parent 0150023517
commit b47fd4f7b9
7 changed files with 66 additions and 5 deletions

View File

@ -33,7 +33,7 @@ const MNEMONIC = process.env.MNEMONIC || '';
// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
['misc', 'migrations', 'dev', 'full', 'verifications', 'deployments', 'helpers'].forEach(
['misc', 'migrations', 'dev', 'full', 'verifications', 'deployments', 'permissioned', 'helpers'].forEach(
(folder) => {
const tasksPath = path.join(__dirname, 'tasks', folder);
fs.readdirSync(tasksPath)

View File

@ -51,7 +51,8 @@ import {
FlashLiquidationAdapterFactory,
PermissionedVariableDebtTokenFactory,
PermissionedStableDebtTokenFactory,
PermissionedLendingPoolFactory
PermissionedLendingPoolFactory,
PermissionedWETHGatewayFactory
} from '../types';
import {
withSaveAndVerify,
@ -584,6 +585,15 @@ export const deployWETHGateway = async (args: [tEthereumAddress], verify?: boole
verify
);
export const deployPermissionedWETHGateway = async (args: [tEthereumAddress], verify?: boolean) =>
withSaveAndVerify(
await new PermissionedWETHGatewayFactory(await getFirstSigner()).deploy(...args),
eContractid.PermissionedWETHGateway,
args,
verify
);
export const authorizeWETHGateway = async (
wethGateWay: tEthereumAddress,
lendingPool: tEthereumAddress

View File

@ -30,6 +30,7 @@ import {
WETH9MockedFactory,
WETHGatewayFactory,
FlashLiquidationAdapterFactory,
PermissionManagerFactory,
} from '../types';
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
import { getEthersSigners, MockTokenMap } from './contracts-helpers';
@ -364,3 +365,11 @@ export const getFlashLiquidationAdapter = async (address?: tEthereumAddress) =>
.address,
await getFirstSigner()
);
export const getPermissionManager = async (address?: tEthereumAddress) =>
await PermissionManagerFactory.connect(
address ||
(await getDb().get(`${eContractid.PermissionManager}.${DRE.network.name}`).value()).address,
await getFirstSigner()
);

View File

@ -90,7 +90,8 @@ export enum eContractid {
PermissionManager = 'PermissionManager',
PermissionedStableDebtToken = 'PermissionedStableDebtToken',
PermissionedVariableDebtToken = 'PermissionedVariableDebtToken',
PermissionedLendingPool = 'PermissionedLendingPool'
PermissionedLendingPool = 'PermissionedLendingPool',
PermissionedWETHGateway = 'PermissionedWETHGateway'
}
/*

View File

@ -33,8 +33,8 @@ task('pro:mainnet', 'Deploy development enviroment')
console.log('5. Deploy Data Provider');
await DRE.run('full:data-provider', { pool: POOL_NAME });
console.log('6. Deploy WETH Gateway');
await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME });
console.log('6. Deploy Permissioned WETH Gateway');
await DRE.run('full-deploy-permissioned-weth-gateway', { pool: POOL_NAME });
console.log('7. Initialize lending pool');
await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME });

View File

@ -0,0 +1,41 @@
import { task } from 'hardhat/config';
import {
loadPoolConfig,
ConfigNames,
getWrappedNativeTokenAddress,
} from '../../helpers/configuration';
import { deployPermissionedWETHGateway, deployWETHGateway } from '../../helpers/contracts-deployments';
import { getFirstSigner, getPermissionManager } from '../../helpers/contracts-getters';
import { waitForTx } from '../../helpers/misc-utils';
const CONTRACT_NAME = 'WETHGateway';
task(`full-deploy-permissioned-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 poolConfig = loadPoolConfig(pool);
const Weth = await getWrappedNativeTokenAddress(poolConfig);
if (!localBRE.network.config.chainId) {
throw new Error('INVALID_CHAIN_ID');
}
const wethGateWay = await deployPermissionedWETHGateway([Weth], verify);
const deployer = await getFirstSigner();
const deployerAddress = await deployer.getAddress();
//adding permissions to the permission manager for the weth gateway
const permissionManager = await getPermissionManager();
await waitForTx(await permissionManager.addPermissionAdmins([deployerAddress]));
await waitForTx(await permissionManager.connect(deployer).addPermissions([0, 1],[deployerAddress, deployerAddress] ));
await waitForTx(await permissionManager.removePermissionAdmins([deployerAddress]));
console.log(`${CONTRACT_NAME}.address`, wethGateWay.address);
console.log(`\tFinished ${CONTRACT_NAME} deployment`);
});