2020-11-05 11:18:20 +00:00
|
|
|
import path from 'path';
|
|
|
|
import fs from 'fs';
|
2020-11-30 13:14:29 +00:00
|
|
|
import { HardhatUserConfig } from 'hardhat/types';
|
2020-11-05 11:18:20 +00:00
|
|
|
// @ts-ignore
|
2020-11-30 13:14:29 +00:00
|
|
|
import { accounts } from './test-wallets.js';
|
2021-02-23 14:42:47 +00:00
|
|
|
import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
|
2020-11-30 13:14:29 +00:00
|
|
|
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
|
2021-05-14 12:47:19 +00:00
|
|
|
import {
|
|
|
|
NETWORKS_RPC_URL,
|
|
|
|
NETWORKS_DEFAULT_GAS,
|
|
|
|
BLOCK_TO_FORK,
|
|
|
|
buildForkConfig,
|
|
|
|
} from './helper-hardhat-config';
|
2021-03-03 11:25:10 +00:00
|
|
|
|
2020-12-02 15:56:38 +00:00
|
|
|
require('dotenv').config();
|
|
|
|
|
2020-11-05 11:18:20 +00:00
|
|
|
import '@nomiclabs/hardhat-ethers';
|
|
|
|
import '@nomiclabs/hardhat-waffle';
|
2020-11-09 14:52:28 +00:00
|
|
|
import 'temp-hardhat-etherscan';
|
2020-11-05 11:18:20 +00:00
|
|
|
import 'hardhat-gas-reporter';
|
|
|
|
import 'hardhat-typechain';
|
2020-11-12 13:12:26 +00:00
|
|
|
import '@tenderly/hardhat-tenderly';
|
2021-04-23 16:04:43 +00:00
|
|
|
import 'solidity-coverage';
|
2020-11-05 11:18:20 +00:00
|
|
|
|
|
|
|
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
|
|
|
|
const DEFAULT_BLOCK_GAS_LIMIT = 12450000;
|
2020-11-16 15:08:07 +00:00
|
|
|
const DEFAULT_GAS_MUL = 5;
|
2021-05-31 14:21:41 +00:00
|
|
|
const DEFAULT_GAS_PRICE = 65000000000;
|
2020-11-05 11:18:20 +00:00
|
|
|
const HARDFORK = 'istanbul';
|
2021-05-31 14:21:41 +00:00
|
|
|
const INFURA_KEY = process.env.INFURA_KEY || '';
|
|
|
|
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 || '';
|
2021-05-31 14:21:41 +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) {
|
2021-01-12 11:11:03 +00:00
|
|
|
['misc', 'migrations', 'dev', 'full', 'verifications', 'deployments', 'helpers'].forEach(
|
|
|
|
(folder) => {
|
|
|
|
const tasksPath = path.join(__dirname, 'tasks', folder);
|
|
|
|
fs.readdirSync(tasksPath)
|
|
|
|
.filter((pth) => pth.includes('.ts'))
|
|
|
|
.forEach((task) => {
|
|
|
|
require(`${tasksPath}/${task}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
2020-11-05 11:18:20 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 12:44:20 +00:00
|
|
|
require(`${path.join(__dirname, 'tasks/misc')}/set-bre.ts`);
|
|
|
|
|
2021-02-23 14:42:47 +00:00
|
|
|
const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({
|
2021-02-22 08:59:21 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
});
|
2020-11-05 11:18:20 +00:00
|
|
|
|
2021-05-31 14:21:41 +00:00
|
|
|
const mainnetFork = MAINNET_FORK
|
|
|
|
? {
|
2021-06-02 08:20:22 +00:00
|
|
|
blockNumber: 12521999,
|
2021-05-31 14:21:41 +00:00
|
|
|
url: ALCHEMY_KEY
|
|
|
|
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
|
|
|
|
: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
|
|
|
|
}
|
|
|
|
: undefined;
|
2020-11-16 10:09:23 +00:00
|
|
|
|
|
|
|
const buidlerConfig: HardhatUserConfig = {
|
2021-05-31 14:21:41 +00:00
|
|
|
gasReporter: {
|
2021-06-01 09:07:08 +00:00
|
|
|
enabled: false,
|
2021-05-31 14:21:41 +00:00
|
|
|
},
|
2020-11-05 11:18:20 +00:00
|
|
|
solidity: {
|
2021-05-31 14:21:41 +00:00
|
|
|
compilers: [
|
|
|
|
{
|
|
|
|
version: '0.6.12',
|
|
|
|
settings: {
|
|
|
|
optimizer: {
|
|
|
|
enabled: true,
|
|
|
|
runs: 200,
|
|
|
|
details: {
|
|
|
|
yul: true,
|
|
|
|
yulDetails: {
|
|
|
|
stackAllocation: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
evmVersion: 'istanbul',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '0.8.3',
|
|
|
|
settings: {
|
|
|
|
optimizer: { enabled: true, runs: 200 },
|
|
|
|
evmVersion: 'istanbul',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2020-11-05 11:18:20 +00:00
|
|
|
},
|
|
|
|
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),
|
2021-03-03 11:25:10 +00:00
|
|
|
tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030),
|
2021-02-22 09:55:36 +00:00
|
|
|
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
|
|
|
|
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
|
|
|
|
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
|
2020-11-05 11:18:20 +00:00
|
|
|
hardhat: {
|
2021-04-23 14:03:24 +00:00
|
|
|
hardfork: 'berlin',
|
2020-11-05 11:18:20 +00:00
|
|
|
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
|
|
|
|
gas: DEFAULT_BLOCK_GAS_LIMIT,
|
|
|
|
gasPrice: 8000000000,
|
|
|
|
chainId: BUIDLEREVM_CHAINID,
|
|
|
|
throwOnTransactionFailures: true,
|
|
|
|
throwOnCallFailures: true,
|
2020-11-30 13:14:29 +00:00
|
|
|
accounts: accounts.map(({ secretKey, balance }: { secretKey: string; balance: string }) => ({
|
2020-11-05 11:18:20 +00:00
|
|
|
privateKey: secretKey,
|
|
|
|
balance,
|
|
|
|
})),
|
2021-06-01 09:07:08 +00:00
|
|
|
forking: mainnetFork,
|
|
|
|
mining: {
|
|
|
|
auto: true,
|
|
|
|
},
|
2020-11-05 11:18:20 +00:00
|
|
|
},
|
|
|
|
buidlerevm_docker: {
|
2021-04-23 14:03:24 +00:00
|
|
|
hardfork: 'berlin',
|
2020-11-05 11:18:20 +00:00
|
|
|
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;
|