Skip to content

Commit

Permalink
feat: remove multi market support
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Valeri committed Aug 3, 2021
1 parent 09e72f2 commit 3b6e9c5
Show file tree
Hide file tree
Showing 40 changed files with 50 additions and 2,174 deletions.
47 changes: 1 addition & 46 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ import fs from 'fs';
import { HardhatUserConfig } from 'hardhat/types';
// @ts-ignore
import { accounts } from './test-wallets.js';
import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
import {
NETWORKS_RPC_URL,
NETWORKS_DEFAULT_GAS,
BLOCK_TO_FORK,
buildForkConfig,
} from './helper-hardhat-config';
import { buildForkConfig } from './helper-hardhat-config';

require('dotenv').config();

Expand All @@ -21,15 +15,10 @@ import 'hardhat-gas-reporter';
import 'hardhat-typechain';
import '@tenderly/hardhat-tenderly';
import 'solidity-coverage';
import { fork } from 'child_process';

const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
const DEFAULT_BLOCK_GAS_LIMIT = 12450000;
const DEFAULT_GAS_MUL = 5;
const HARDFORK = 'istanbul';
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
const MNEMONIC_PATH = "m/44'/60'/0'/0";
const MNEMONIC = process.env.MNEMONIC || '';

// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
Expand All @@ -47,23 +36,6 @@ if (!SKIP_LOAD) {

require(`${path.join(__dirname, 'tasks/misc')}/set-bre.ts`);

const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({
url: NETWORKS_RPC_URL[networkName],
hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
gasPrice: NETWORKS_DEFAULT_GAS[networkName],
chainId: networkId,
accounts: {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
initialIndex: 0,
count: 20,
},
});

let forkMode;

const buidlerConfig: HardhatUserConfig = {
solidity: {
version: '0.6.12',
Expand Down Expand Up @@ -92,13 +64,6 @@ const buidlerConfig: HardhatUserConfig = {
url: 'http://localhost:8555',
chainId: COVERAGE_CHAINID,
},
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan, 42),
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030),
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
hardhat: {
hardfork: 'berlin',
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
Expand All @@ -113,16 +78,6 @@ const buidlerConfig: HardhatUserConfig = {
})),
forking: buildForkConfig(),
},
buidlerevm_docker: {
hardfork: 'berlin',
blockGasLimit: 9500000,
gas: 9500000,
gasPrice: 8000000000,
chainId: BUIDLEREVM_CHAINID,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
url: 'http://localhost:8545',
},
ganache: {
url: 'http://ganache:8545',
accounts: {
Expand Down
26 changes: 1 addition & 25 deletions helper-hardhat-config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-ignore
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types';
import {
eEthereumNetwork,
ePolygonNetwork,
eXDaiNetwork,
iParamsPerNetwork,
} from './helpers/types';
import { eEthereumNetwork, iParamsPerNetwork } from './helpers/types';

require('dotenv').config();

Expand Down Expand Up @@ -46,22 +41,6 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
[eEthereumNetwork.hardhat]: 'http://localhost:8545',
[eEthereumNetwork.buidlerevm]: 'http://localhost:8545',
[eEthereumNetwork.tenderlyMain]: `https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}`,
[ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com',
[ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network',
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
};

export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
[eEthereumNetwork.kovan]: 1 * GWEI,
[eEthereumNetwork.ropsten]: 65 * GWEI,
[eEthereumNetwork.main]: 65 * GWEI,
[eEthereumNetwork.coverage]: 65 * GWEI,
[eEthereumNetwork.hardhat]: 65 * GWEI,
[eEthereumNetwork.buidlerevm]: 65 * GWEI,
[eEthereumNetwork.tenderlyMain]: 0.01 * GWEI,
[ePolygonNetwork.mumbai]: 1 * GWEI,
[ePolygonNetwork.matic]: 1 * GWEI,
[eXDaiNetwork.xdai]: 1 * GWEI,
};

export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
Expand All @@ -72,7 +51,4 @@ export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
[eEthereumNetwork.hardhat]: undefined,
[eEthereumNetwork.buidlerevm]: undefined,
[eEthereumNetwork.tenderlyMain]: 12406069,
[ePolygonNetwork.mumbai]: undefined,
[ePolygonNetwork.matic]: undefined,
[eXDaiNetwork.xdai]: undefined,
};
21 changes: 2 additions & 19 deletions helpers/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
} from './types';
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
import AaveConfig from '../markets/aave';
import MaticConfig from '../markets/matic';
import AmmConfig from '../markets/amm';
import { CommonsConfig } from '../markets/aave/commons';
import { DRE, filterMapBy } from './misc-utils';
import { tEthereumAddress } from './types';
Expand All @@ -19,18 +17,12 @@ import { deployWETHMocked } from './contracts-deployments';
export enum ConfigNames {
Commons = 'Commons',
Aave = 'Aave',
Matic = 'Matic',
Amm = 'Amm',
}

export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
switch (configName) {
case ConfigNames.Aave:
return AaveConfig;
case ConfigNames.Matic:
return MaticConfig;
case ConfigNames.Amm:
return AmmConfig;
case ConfigNames.Commons:
return CommonsConfig;
default:
Expand All @@ -48,12 +40,6 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
[AavePools.proto]: {
...AaveConfig.ReservesConfig,
},
[AavePools.amm]: {
...AmmConfig.ReservesConfig,
},
[AavePools.matic]: {
...MaticConfig.ReservesConfig,
},
},
pool
);
Expand Down Expand Up @@ -84,11 +70,8 @@ export const getEmergencyAdmin = async (
return addressList[addressIndex];
};

export const getTreasuryAddress = async (
config: ICommonConfiguration
): Promise<tEthereumAddress> => {
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork);
export const getTreasuryAddress = (config: ICommonConfiguration): tEthereumAddress | undefined => {
return config.ReserveFactorTreasuryAddress;
};

export const getATokenDomainSeparatorPerNetwork = (
Expand Down
28 changes: 4 additions & 24 deletions helpers/contracts-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ import {
iParamsPerNetwork,
iParamsPerPool,
ePolygonNetwork,
eXDaiNetwork,
eNetwork,
iEthereumParamsPerNetwork,
iPolygonParamsPerNetwork,
iXDaiParamsPerNetwork,
} from './types';
import { MintableERC20 } from '../types/MintableERC20';
import { Artifact } from 'hardhat/types';
import { Artifact as BuidlerArtifact } from '@nomiclabs/buidler/types';
import { verifyEtherscanContract } from './etherscan-verification';
import { getFirstSigner, getIErc20Detailed } from './contracts-getters';
import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
import { usingPolygon, verifyAtPolygon } from './polygon-utils';
import { getDefenderRelaySigner, usingDefender } from './defender-utils';

export type MockTokenMap = { [symbol: string]: MintableERC20 };
Expand Down Expand Up @@ -143,8 +139,6 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
const { main, ropsten, kovan, coverage, buidlerevm, tenderlyMain } =
param as iEthereumParamsPerNetwork<T>;
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
const { xdai } = param as iXDaiParamsPerNetwork<T>;
if (process.env.FORK) {
return param[process.env.FORK as eNetwork] as T;
}
Expand All @@ -164,23 +158,13 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
return main;
case eEthereumNetwork.tenderlyMain:
return tenderlyMain;
case ePolygonNetwork.matic:
return matic;
case ePolygonNetwork.mumbai:
return mumbai;
case eXDaiNetwork.xdai:
return xdai;
}
};

export const getParamPerPool = <T>({ proto, amm, matic }: iParamsPerPool<T>, pool: AavePools) => {
export const getParamPerPool = <T>({ proto }: iParamsPerPool<T>, pool: AavePools) => {
switch (pool) {
case AavePools.proto:
return proto;
case AavePools.amm:
return amm;
case AavePools.matic:
return matic;
default:
return proto;
}
Expand Down Expand Up @@ -337,13 +321,9 @@ export const verifyContract = async (
instance: Contract,
args: (string | string[])[]
) => {
if (usingPolygon()) {
await verifyAtPolygon(id, instance, args);
} else {
if (usingTenderly()) {
await verifyAtTenderly(id, instance);
}
await verifyEtherscanContract(instance.address, args);
if (usingTenderly()) {
await verifyAtTenderly(id, instance);
}
await verifyEtherscanContract(instance.address, args);
return instance;
};
142 changes: 0 additions & 142 deletions helpers/polygon-utils.ts

This file was deleted.

Loading

0 comments on commit 3b6e9c5

Please sign in to comment.