aave-protocol-v2/helper-hardhat-config.ts

86 lines
3.0 KiB
TypeScript
Raw Normal View History

2021-02-22 08:59:21 +00:00
// @ts-ignore
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types';
import {
eAvalancheNetwork,
eEthereumNetwork,
ePolygonNetwork,
eXDaiNetwork,
iParamsPerNetwork,
} from './helpers/types';
2021-02-22 08:59:21 +00:00
require('dotenv').config();
const INFURA_KEY = process.env.INFURA_KEY || '';
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || '';
const TENDERLY_FORK_ID = process.env.TENDERLY_FORK_ID || '';
const FORK = process.env.FORK || '';
const FORK_BLOCK_NUMBER = process.env.FORK_BLOCK_NUMBER
? parseInt(process.env.FORK_BLOCK_NUMBER)
: 0;
2021-02-22 08:59:21 +00:00
const GWEI = 1000 * 1000 * 1000;
export const buildForkConfig = (): HardhatNetworkForkingUserConfig | undefined => {
let forkMode;
if (FORK) {
forkMode = {
url: NETWORKS_RPC_URL[FORK],
};
if (FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK]) {
forkMode.blockNumber = FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK];
}
}
return forkMode;
};
2021-02-22 08:59:21 +00:00
export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
[eEthereumNetwork.kovan]: ALCHEMY_KEY
? `https://eth-kovan.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://kovan.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.ropsten]: ALCHEMY_KEY
? `https://eth-ropsten.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://ropsten.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.main]: ALCHEMY_KEY
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.coverage]: 'http://localhost:8555',
[eEthereumNetwork.hardhat]: 'http://localhost:8545',
[eEthereumNetwork.buidlerevm]: 'http://localhost:8545',
[eEthereumNetwork.tenderly]: `https://rpc.tenderly.co/fork/`,
2021-02-22 09:55:36 +00:00
[ePolygonNetwork.mumbai]: 'https://rpc-mumbai.maticvigil.com',
[ePolygonNetwork.matic]: 'https://rpc-mainnet.matic.network',
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
[eAvalancheNetwork.avalanche]: 'https://cchain.explorer.avax.network/',
[eAvalancheNetwork.fuji]: 'https://api.avax-test.network/ext/bc/C/rpc'
};
2021-02-22 08:59:21 +00:00
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.tenderly]: 1 * GWEI,
[ePolygonNetwork.mumbai]: 1 * GWEI,
[ePolygonNetwork.matic]: 1 * GWEI,
2021-02-22 09:55:36 +00:00
[eXDaiNetwork.xdai]: 1 * GWEI,
[eAvalancheNetwork.avalanche]: 255 * GWEI,
[eAvalancheNetwork.fuji]: 255 * GWEI
};
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
[eEthereumNetwork.main]: 12406069,
[eEthereumNetwork.kovan]: undefined,
[eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.coverage]: undefined,
[eEthereumNetwork.hardhat]: undefined,
[eEthereumNetwork.buidlerevm]: undefined,
[eEthereumNetwork.tenderly]: undefined,
[ePolygonNetwork.mumbai]: undefined,
[ePolygonNetwork.matic]: undefined,
[eXDaiNetwork.xdai]: undefined,
[eAvalancheNetwork.avalanche]: undefined,
[eAvalancheNetwork.fuji]: undefined
};