refactor: refactored migration scripts and Arc configuration

This commit is contained in:
The3D 2021-08-06 18:00:08 +02:00
parent fd9e49fc4b
commit c9b88505a8
11 changed files with 26 additions and 20 deletions

View File

@ -8,7 +8,7 @@ import {
} from './types'; } from './types';
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers'; import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
import AaveConfig from '../markets/aave'; import AaveConfig from '../markets/aave';
import AaveProConfig from '../markets/aave-pro'; import AaveArcConfig from '../markets/aave-arc';
import MaticConfig from '../markets/matic'; import MaticConfig from '../markets/matic';
import AmmConfig from '../markets/amm'; import AmmConfig from '../markets/amm';
import { CommonsConfig } from '../markets/aave/commons'; import { CommonsConfig } from '../markets/aave/commons';
@ -22,7 +22,7 @@ export enum ConfigNames {
Aave = 'Aave', Aave = 'Aave',
Matic = 'Matic', Matic = 'Matic',
Amm = 'Amm', Amm = 'Amm',
AavePro = 'AavePro' Arc = 'Arc'
} }
export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
@ -35,8 +35,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
return AmmConfig; return AmmConfig;
case ConfigNames.Commons: case ConfigNames.Commons:
return CommonsConfig; return CommonsConfig;
case ConfigNames.AavePro: case ConfigNames.Arc:
return AaveProConfig; return AaveArcConfig;
default: default:
throw new Error(`Unsupported pool configuration: ${Object.values(ConfigNames)}`); throw new Error(`Unsupported pool configuration: ${Object.values(ConfigNames)}`);
} }
@ -57,6 +57,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
[AavePools.matic]: { [AavePools.matic]: {
...MaticConfig.ReservesConfig, ...MaticConfig.ReservesConfig,
}, },
[AavePools.arc]: {
...AaveArcConfig.ReservesConfig
}
}, },
pool pool
); );

View File

@ -180,7 +180,7 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
} }
}; };
export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, pool: AavePools) => { export const getParamPerPool = <T>({ proto, amm, matic, arc }: iParamsPerPool<T>, pool: AavePools) => {
switch (pool) { switch (pool) {
case AavePools.proto: case AavePools.proto:
return proto; return proto;
@ -188,6 +188,8 @@ export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, poo
return amm; return amm;
case AavePools.matic: case AavePools.matic:
return matic; return matic;
case AavePools.arc:
return arc;
default: default:
return proto; return proto;
} }

View File

@ -18,7 +18,7 @@ export const getDefenderRelaySigner = async () => {
const credentials = { apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_SECRET_KEY }; const credentials = { apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_SECRET_KEY };
defenderSigner = new DefenderRelaySigner(credentials, new DefenderRelayProvider(credentials), { defenderSigner = new DefenderRelaySigner(credentials, new DefenderRelayProvider(credentials), {
speed: 'fast', speed: 'fastest',
}); });
const defenderAddress = await defenderSigner.getAddress(); const defenderAddress = await defenderSigner.getAddress();

View File

@ -38,6 +38,7 @@ export enum AavePools {
proto = 'proto', proto = 'proto',
matic = 'matic', matic = 'matic',
amm = 'amm', amm = 'amm',
arc = 'arc'
} }
export enum eContractid { export enum eContractid {
@ -275,7 +276,7 @@ export type iAavePoolAssets<T> = Pick<
| 'xSUSHI' | 'xSUSHI'
>; >;
export type iAaveProPoolAssets<T> = Pick< export type iAaveArcPoolAssets<T> = Pick<
iAssetsWithoutUSD<T>, iAssetsWithoutUSD<T>,
'USDC' | 'WBTC' | 'WETH' | 'AAVE' 'USDC' | 'WBTC' | 'WETH' | 'AAVE'
>; >;
@ -436,6 +437,7 @@ export interface iParamsPerPool<T> {
[AavePools.proto]: T; [AavePools.proto]: T;
[AavePools.matic]: T; [AavePools.matic]: T;
[AavePools.amm]: T; [AavePools.amm]: T;
[AavePools.arc]: T;
} }
export interface iBasicDistributionParams { export interface iBasicDistributionParams {
@ -513,8 +515,8 @@ export interface IAaveConfiguration extends ICommonConfiguration {
ReservesConfig: iAavePoolAssets<IReserveParams>; ReservesConfig: iAavePoolAssets<IReserveParams>;
} }
export interface IAaveProConfiguration extends ICommonConfiguration { export interface IAaveArcConfiguration extends ICommonConfiguration {
ReservesConfig: iAaveProPoolAssets<IReserveParams>; ReservesConfig: iAaveArcPoolAssets<IReserveParams>;
} }
export interface IAmmConfiguration extends ICommonConfiguration { export interface IAmmConfiguration extends ICommonConfiguration {
ReservesConfig: iLpPoolAssets<IReserveParams>; ReservesConfig: iLpPoolAssets<IReserveParams>;

View File

@ -1,5 +1,5 @@
import { ZERO_ADDRESS } from '../../helpers/constants'; import { ZERO_ADDRESS } from '../../helpers/constants';
import { IAaveProConfiguration, eEthereumNetwork, eContractid } from '../../helpers/types'; import { IAaveArcConfiguration, eEthereumNetwork, eContractid } from '../../helpers/types';
import { CommonsConfig } from './commons'; import { CommonsConfig } from './commons';
import { import {
@ -13,9 +13,9 @@ import {
// POOL--SPECIFIC PARAMS // POOL--SPECIFIC PARAMS
// ---------------- // ----------------
export const AaveConfig: IAaveProConfiguration = { export const AaveArcConfig: IAaveArcConfiguration = {
...CommonsConfig, ...CommonsConfig,
MarketId: 'Aave Pro market', MarketId: 'Aave Arc market',
ProviderId: 1, ProviderId: 1,
LendingPoolImpl: eContractid.PermissionedLendingPool, LendingPoolImpl: eContractid.PermissionedLendingPool,
ReservesConfig: { ReservesConfig: {
@ -55,4 +55,4 @@ export const AaveConfig: IAaveProConfiguration = {
} }
}; };
export default AaveConfig; export default AaveArcConfig;

View File

@ -106,7 +106,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
let gateWay = getParamPerNetwork(WethGateway, network); let gateWay = getParamPerNetwork(WethGateway, network);
if (!notFalsyOrZeroAddress(gateWay)) { if (!notFalsyOrZeroAddress(gateWay)) {
if (pool === ConfigNames.AavePro) { if (pool === ConfigNames.Arc) {
gateWay = (await getPermissionedWETHGateway()).address; gateWay = (await getPermissionedWETHGateway()).address;
} else { } else {
gateWay = (await getWETHGateway()).address; gateWay = (await getWETHGateway()).address;

View File

@ -7,7 +7,7 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
task('pro:mainnet', 'Deploy development enviroment') task('pro:mainnet', 'Deploy development enviroment')
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({ verify }, DRE) => { .setAction(async ({ verify }, DRE) => {
const POOL_NAME = ConfigNames.AavePro; const POOL_NAME = ConfigNames.Arc;
await DRE.run('set-DRE'); await DRE.run('set-DRE');
// Prevent loss of gas verifying all the needed ENVs for Etherscan verification // Prevent loss of gas verifying all the needed ENVs for Etherscan verification
@ -17,13 +17,12 @@ task('pro:mainnet', 'Deploy development enviroment')
console.log('Migration started\n'); console.log('Migration started\n');
console.log('1. Deploy address provider'); console.log('1. Deploy address provider');
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME }); await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry: true });
console.log('2. Deploy permissions manager'); console.log('2. Deploy permissions manager');
await DRE.run('deploy-permission-manager', { pool: POOL_NAME }); await DRE.run('deploy-permission-manager', { pool: POOL_NAME });
console.log('3. Deploy lending pool'); console.log('3. Deploy lending pool');
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME }); await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });

View File

@ -4,7 +4,7 @@ import { PermissionManagerFactory } from '../../types';
import { verifyContract } from '../../helpers/contracts-helpers'; import { verifyContract } from '../../helpers/contracts-helpers';
import { eContractid } from '../../helpers/types'; import { eContractid } from '../../helpers/types';
import { insertContractAddressInDb } from '../../helpers/contracts-helpers'; import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
import { getLendingPoolAddressesProvider } from '../../helpers/contracts-getters'; import { getFirstSigner, getLendingPoolAddressesProvider } from '../../helpers/contracts-getters';
import { waitForTx } from '../../helpers/misc-utils'; import { waitForTx } from '../../helpers/misc-utils';
import { ethers } from 'ethers'; import { ethers } from 'ethers';
@ -21,7 +21,7 @@ task(`deploy-permission-manager`, `Deploys the PermissionManager contract`)
console.log(`\tDeploying PermissionManager implementation ...`); console.log(`\tDeploying PermissionManager implementation ...`);
const permissionManagerInstance = await new PermissionManagerFactory( const permissionManagerInstance = await new PermissionManagerFactory(
await localBRE.ethers.provider.getSigner() await getFirstSigner()
).deploy(); ).deploy();
await permissionManagerInstance.deployTransaction.wait(); await permissionManagerInstance.deployTransaction.wait();