forked from gmx-io/gmx-synthetics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
170 lines (152 loc) · 3.91 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
import dotenv from "dotenv";
dotenv.config();
import path from "path";
import fs from "fs";
import { ethers } from "ethers";
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "hardhat-contract-sizer";
import "solidity-coverage";
import "hardhat-gas-reporter";
import "hardhat-deploy";
import "@typechain/hardhat";
import "@nomiclabs/hardhat-ethers";
// extends hre with gmx domain data
import "./config";
// add test helper methods
import "./utils/test";
const getRpcUrl = (network) => {
const defaultRpcs = {
arbitrum: "https://arb1.arbitrum.io/rpc",
avalanche: "https://api.avax.network/ext/bc/C/rpc",
arbitrumGoerli: "https://goerli-rollup.arbitrum.io/rpc",
avalancheFuji: "https://api.avax-test.network/ext/bc/C/rpc",
};
let rpc = defaultRpcs[network];
const filepath = path.join("./.rpcs.json");
if (fs.existsSync(filepath)) {
const data = JSON.parse(fs.readFileSync(filepath).toString());
if (data[network]) {
rpc = data[network];
}
}
return rpc;
};
const getEnvAccounts = () => {
const { ACCOUNT_KEY, ACCOUNT_KEY_FILE } = process.env;
if (ACCOUNT_KEY) {
return [ACCOUNT_KEY];
}
if (ACCOUNT_KEY_FILE) {
const filepath = path.join("./keys/", ACCOUNT_KEY_FILE);
const data = JSON.parse(fs.readFileSync(filepath));
if (!data) {
throw new Error("Invalid key file");
}
if (data.key) {
return [data.key];
}
if (!data.mnemonic) {
throw new Error("Invalid mnemonic");
}
const wallet = ethers.Wallet.fromMnemonic(data.mnemonic);
return [wallet.privateKey];
}
return [];
};
const config: HardhatUserConfig = {
solidity: {
version: "0.8.18",
settings: {
optimizer: {
enabled: true,
runs: 10,
details: {
constantOptimizer: true,
},
},
},
},
networks: {
hardhat: {
saveDeployments: true,
// forking: {
// url: `https://rpc.ankr.com/avalanche`,
// blockNumber: 33963320,
// },
},
localhost: {
saveDeployments: true,
},
arbitrum: {
url: getRpcUrl("arbitrum"),
chainId: 42161,
accounts: getEnvAccounts(),
verify: {
etherscan: {
apiUrl: "https://api.arbiscan.io/",
apiKey: process.env.ARBISCAN_API_KEY,
},
},
blockGasLimit: 20_000_000,
},
avalanche: {
url: getRpcUrl("avalanche"),
chainId: 43114,
accounts: getEnvAccounts(),
verify: {
etherscan: {
apiUrl: "https://api.snowtrace.io/",
apiKey: process.env.SNOWTRACE_API_KEY,
},
},
blockGasLimit: 15_000_000,
},
arbitrumGoerli: {
url: getRpcUrl("arbitrumGoerli"),
chainId: 421613,
accounts: getEnvAccounts(),
verify: {
etherscan: {
apiUrl: "https://api-goerli.arbiscan.io/",
apiKey: process.env.ARBISCAN_API_KEY,
},
},
blockGasLimit: 10000000,
},
avalancheFuji: {
url: getRpcUrl("avalancheFuji"),
chainId: 43113,
accounts: getEnvAccounts(),
verify: {
etherscan: {
apiUrl: "https://api-testnet.snowtrace.io/",
apiKey: process.env.SNOWTRACE_API_KEY,
},
},
blockGasLimit: 2500000,
// gasPrice: 50000000000,
},
},
// hardhat-deploy has issues with some contracts
// https://github.com/wighawag/hardhat-deploy/issues/264
etherscan: {
apiKey: {
// hardhat-etherscan plugin uses "avalancheFujiTestnet" name
arbitrumOne: process.env.ARBISCAN_API_KEY,
avalanche: process.env.SNOWTRACE_API_KEY,
arbitrumGoerli: process.env.ARBISCAN_API_KEY,
avalancheFujiTestnet: process.env.SNOWTRACE_API_KEY,
},
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
},
namedAccounts: {
deployer: 0,
},
mocha: {
timeout: 100000000,
},
};
export default config;