-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhardhat.config.ts
283 lines (251 loc) · 6.75 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
import type {
HardhatUserConfig,
NetworkUserConfig,
HardhatNetworkForkingUserConfig,
} from "hardhat/types";
import "hardhat-deploy";
import "hardhat-abi-exporter";
import "@nomicfoundation/hardhat-toolbox";
import { resolve } from "path";
import { config as dotenvConfig } from "dotenv";
const SKIP_LOAD = process.env.SKIP_LOAD === "true";
dotenvConfig({ path: resolve(__dirname, "./.env") });
// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
require("./tasks");
}
const deployerAccount = [process.env.PRIVATE_KEY as string];
const defaultAccount = {
mnemonic: "test test test test test test test test test test test junk",
initialIndex: 0,
path: "m/44'/60'/0'/0",
count: 20,
accountsBalance: "10000000000000000000000",
};
const chainIds = {
ethereum: 1,
optimism: 10,
polygon: 137,
arbitrum: 42161,
avalanche: 43114,
};
const infuraApiKey: string | undefined = process.env.INFURA_API_KEY;
if (!infuraApiKey) {
throw new Error("Please set your INFURA_API_KEY in a .env file");
}
function getForkConfig(chain: number): HardhatNetworkForkingUserConfig {
let jsonRpcUrl: string | undefined;
let blockNumber: number | undefined;
switch (chain) {
case 1:
jsonRpcUrl = process.env.ETHEREUM_API as string;
blockNumber = 14655838;
break;
case 10:
jsonRpcUrl = process.env.OPTIMISM_API as string;
blockNumber = 8031180;
break;
case 137:
jsonRpcUrl = process.env.POLYGON_API as string;
blockNumber = 27633365;
break;
case 43114:
jsonRpcUrl = process.env.ARBITRUM_API as string;
blockNumber = 15968233;
break;
default:
jsonRpcUrl = process.env.GOERLI_API as string;
blockNumber = 7825205;
}
return { url: jsonRpcUrl, blockNumber: blockNumber };
}
function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
let jsonRpcUrl: string;
let gasMultiplier: number;
switch (chain) {
case "ethereum":
jsonRpcUrl = process.env.ETHEREUM_API as string;
gasMultiplier = 1;
break;
case "optimism":
jsonRpcUrl = process.env.OPTIMISM_API as string;
gasMultiplier = 1;
break;
case "polygon":
jsonRpcUrl = process.env.POLYGON_API as string;
gasMultiplier = 2;
break;
case "arbitrum":
jsonRpcUrl = process.env.ARBITRUM_API as string;
gasMultiplier = 2;
break;
case "avalanche":
jsonRpcUrl = process.env.AVALANCHE_API as string;
gasMultiplier = 2;
break;
default:
jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey;
gasMultiplier = 1;
}
return {
url: jsonRpcUrl,
chainId: chainIds[chain],
accounts: deployerAccount,
gasMultiplier: gasMultiplier,
// harhdat-deploy config
live: true,
saveDeployments: true,
tags: ["live-network"],
deploy: ["deploy/common", "deploy/" + chain],
};
}
const config: HardhatUserConfig = {
// Networks
defaultNetwork: "hardhat",
networks: {
hardhat: {
forking: getForkConfig(parseInt(process.env.CHAIN_ID as string)),
hardfork: "london",
// harhdat-deploy config
live: false,
tags: ["local-fork"],
deploy: ["deploy-test/common", "deploy-test/hardhat"],
},
// Needed for `solidity-coverage`
coverage: {
url: "http://localhost:8555",
gas: "auto",
hardfork: "london",
initialBaseFeePerGas: 1,
gasPrice: 2,
gasMultiplier: 1.5,
// harhdat-deploy config
live: false,
saveDeployments: false,
tags: ["coverage-network"],
},
ganache: {
url: "http://localhost:7545",
chainId: 5777,
accounts: defaultAccount,
gas: "auto",
hardfork: "london",
initialBaseFeePerGas: 1,
gasPrice: 20000000000, // 1 gwei
gasMultiplier: 1.5,
// harhdat-deploy config
live: false,
saveDeployments: true,
tags: ["local"],
},
goerli: {
accounts: deployerAccount,
gas: "auto",
hardfork: "london",
url: process.env.GOERLI_API as string,
// harhdat-deploy config
live: false,
saveDeployments: false,
tags: ["test-network"],
},
polygon: getChainConfig("polygon"),
ethereum: getChainConfig("ethereum"),
arbitrum: getChainConfig("arbitrum"),
optimism: getChainConfig("optimism"),
avalanche: getChainConfig("avalanche"),
},
// Named accounts, needed for hardhat-deploy
namedAccounts: {
deployer: {
default: 0,
},
safe: {
default: 1,
ethereum: process.env.MAINNET_SAFE || null,
optimism: process.env.OPT_SAFE || null,
avalanche: process.env.AVAX_SAFE || null,
arbitrum: process.env.ARBITRUM_SAFE || null,
},
oneinch: {
ethereum: "0x1111111254fb6c44bac0bed2854e76f90643097d",
avalanche: "0x1111111254fb6c44bac0bed2854e76f90643097d",
optimism: "0x1111111254760f7ab3f16433eea9304126dcd199",
arbitrum: "0x1111111254fb6c44bac0bed2854e76f90643097d",
},
strategist: {
default: "TODO",
},
harvester: {
default: "TODO",
},
operator: {
default: "TODO",
arbitrum: "TODO",
},
usdc: {
ethereum: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
optimism: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
arbitrum: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
},
weth: {
default: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
arbitrum: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
},
wavax: {
avalanche: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
},
usdt: {
arbitrum: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
},
dai: {
ethereum: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
arbitrum: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
},
convexBooster: {
hardhat: "0xF403C135812408BFbE8713b5A23a04b3D48AAE31",
ethereum: "0xF403C135812408BFbE8713b5A23a04b3D48AAE31",
},
convexFraxBooster: {
ethereum: "0x9ca3ec5f627ad5d92498fd1b006b35577760ba9a",
},
cdai: {
ethereum: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
},
comptroller: {
ethereum: "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B",
},
dssFlash: {
ethereum: "0x1EB4CF3A948E7D72A198fe073cCb8C7a948cD853",
},
},
// Compiler
solidity: {
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
// Testing
mocha: {
timeout: 2000000,
},
// typechain
typechain: {
outDir: "typechain",
},
// hardhat-abi-exporter
abiExporter: {
except: [".*Mock$"],
clear: true,
flat: true,
},
// hardhat-gas-reporter
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
gasPrice: 70,
},
};
export default config;