forked from aave/aave-stake-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
147 lines (136 loc) · 4.11 KB
/
hardhat.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { eEthereumNetwork } from './helpers/types';
// @ts-ignore
import { accounts } from './test-wallets';
import path from 'path';
import fs from 'fs';
import dotenv from 'dotenv';
import { HardhatUserConfig } from 'hardhat/types';
import '@typechain/hardhat';
import 'solidity-coverage';
import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-etherscan';
import '@tenderly/hardhat-tenderly';
dotenv.config();
export const BUIDLEREVM_CHAIN_ID = 31337;
const DEFAULT_BLOCK_GAS_LIMIT = 12500000;
const HARDFORK = 'london';
const INFURA_KEY = process.env.INFURA_KEY || '';
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
const MNEMONIC_PATH = "m/44'/60'/0'/0";
const MNEMONIC = process.env.MNEMONIC || '';
const PRIVATE_KEY = process.env.PRIVATE_KEY || '';
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || '';
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
const FORKING_BLOCK = parseInt(process.env.FORKING_BLOCK || '12369243');
// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
['misc', 'migrations', 'deployments', 'proposals'].forEach((folder) => {
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-dre.ts`);
const mainnetFork = MAINNET_FORK
? {
blockNumber: FORKING_BLOCK,
url: ALCHEMY_KEY
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://main.infura.io/v3/${INFURA_KEY}`,
}
: undefined;
// Use of mnemonic over private key if mnemonic is provided
const accountsToUse =
PRIVATE_KEY == ''
? {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
initialIndex: 0,
count: 20,
}
: [PRIVATE_KEY];
const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => {
return {
url: ALCHEMY_KEY
? `https://eth-${
networkName === 'main' ? 'mainnet' : networkName
}.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://${networkName}.infura.io/v3/${INFURA_KEY}`,
hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
chainId: networkId,
accounts: accountsToUse,
};
};
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: '0.6.12',
settings: {
optimizer: { enabled: true, runs: 200 },
evmVersion: 'istanbul',
},
},
{
version: '0.7.5',
settings: {
optimizer: { enabled: true, runs: 200 },
evmVersion: 'istanbul',
},
},
],
},
typechain: {
outDir: 'types',
},
etherscan: {
apiKey: ETHERSCAN_KEY,
},
defaultNetwork: 'hardhat',
mocha: {
timeout: 0,
},
tenderly: {
project: process.env.TENDERLY_PROJECT || '',
username: process.env.TENDERLY_USERNAME || '',
forkNetwork: '3030', //Network id of the network we want to fork
},
networks: {
tenderly: getCommonNetworkConfig(eEthereumNetwork.tenderly, 3030),
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan, 42),
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
goerli: getCommonNetworkConfig(eEthereumNetwork.goerli, 5),
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
hardhat: {
hardfork: 'london',
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gas: DEFAULT_BLOCK_GAS_LIMIT,
chainId: BUIDLEREVM_CHAIN_ID,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
accounts: accounts.map(({ secretKey, balance }: { secretKey: string; balance: string }) => ({
privateKey: secretKey,
balance,
})),
forking: mainnetFork,
},
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,
},
},
coverage: {
url: 'http://localhost:8555',
},
},
};
export default config;