aave-protocol-v2/hardhat.config.ts

141 lines
4.0 KiB
TypeScript
Raw Normal View History

2020-11-05 11:18:20 +00:00
import path from 'path';
import fs from 'fs';
2020-11-16 10:09:23 +00:00
import {HardhatUserConfig} from 'hardhat/types';
2020-11-05 11:18:20 +00:00
// @ts-ignore
import {accounts} from './test-wallets.js';
import {eEthereumNetwork} from './helpers/types';
import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/buidler-constants';
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-waffle';
import 'temp-hardhat-etherscan';
2020-11-05 11:18:20 +00:00
import 'hardhat-gas-reporter';
import 'hardhat-typechain';
import '@tenderly/hardhat-tenderly';
2020-11-05 11:18:20 +00:00
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
const DEFAULT_BLOCK_GAS_LIMIT = 12450000;
const DEFAULT_GAS_MUL = 5;
const DEFAULT_GAS_PRICE = 2000000000;
2020-11-05 11:18:20 +00:00
const HARDFORK = 'istanbul';
const INFURA_KEY = process.env.INFURA_KEY || '';
2020-11-12 08:11:17 +00:00
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || '';
2020-11-05 11:18:20 +00:00
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
const MNEMONIC_PATH = "m/44'/60'/0'/0";
const MNEMONIC = process.env.MNEMONIC || '';
2020-11-16 10:09:23 +00:00
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
2020-11-05 11:18:20 +00:00
// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
['misc', 'migrations', 'dev', 'full', 'verifications'].forEach((folder) => {
2020-11-05 11:18:20 +00:00
const tasksPath = path.join(__dirname, 'tasks', folder);
fs.readdirSync(tasksPath)
.filter((pth) => pth.includes('.ts'))
.forEach((task) => {
require(`${tasksPath}/${task}`);
});
});
}
require(`${path.join(__dirname, 'tasks/misc')}/set-bre.ts`);
2020-11-05 11:18:20 +00:00
const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => {
return {
2020-11-12 08:11:17 +00:00
url: ALCHEMY_KEY
2020-11-16 10:09:23 +00:00
? `https://eth-${
networkName === 'main' ? 'mainnet' : networkName
}.alchemyapi.io/v2/${ALCHEMY_KEY}`
2020-11-12 08:11:17 +00:00
: `https://${networkName}.infura.io/v3/${INFURA_KEY}`,
2020-11-05 11:18:20 +00:00
hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
gasPrice: DEFAULT_GAS_PRICE,
2020-11-05 11:18:20 +00:00
chainId: networkId,
accounts: {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
initialIndex: 0,
count: 20,
},
};
};
2020-11-16 10:09:23 +00:00
const mainnetFork = MAINNET_FORK
? {
blockNumber: 11268220,
url: ALCHEMY_KEY
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://main.infura.io/v3/${INFURA_KEY}`,
}
: undefined;
const buidlerConfig: HardhatUserConfig = {
2020-11-05 11:18:20 +00:00
solidity: {
version: '0.6.8',
settings: {
optimizer: {enabled: true, runs: 200},
evmVersion: 'istanbul',
},
},
typechain: {
outDir: 'types',
target: 'ethers-v5',
},
etherscan: {
apiKey: ETHERSCAN_KEY,
},
mocha: {
timeout: 0,
},
2020-11-12 08:11:17 +00:00
tenderly: {
2020-11-16 10:09:23 +00:00
project: process.env.TENDERLY_PROJECT || '',
username: process.env.TENDERLY_USERNAME || '',
2020-11-12 08:11:17 +00:00
forkNetwork: '1', //Network id of the network we want to fork
},
2020-11-05 11:18:20 +00:00
networks: {
coverage: {
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.main, 1),
2020-11-05 11:18:20 +00:00
hardhat: {
hardfork: 'istanbul',
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gas: DEFAULT_BLOCK_GAS_LIMIT,
gasPrice: 8000000000,
chainId: BUIDLEREVM_CHAINID,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
accounts: accounts.map(({secretKey, balance}: {secretKey: string; balance: string}) => ({
privateKey: secretKey,
balance,
})),
2020-11-16 10:09:23 +00:00
forking: mainnetFork,
2020-11-05 11:18:20 +00:00
},
buidlerevm_docker: {
hardfork: 'istanbul',
blockGasLimit: 9500000,
gas: 9500000,
gasPrice: 8000000000,
chainId: BUIDLEREVM_CHAINID,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
url: 'http://localhost:8545',
},
ganache: {
url: 'http://ganache:8545',
accounts: {
mnemonic: 'fox sight canyon orphan hotel grow hedgehog build bless august weather swarm',
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 20,
},
},
},
};
export default buidlerConfig;