forked from compound-finance/comet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
217 lines (194 loc) · 5.42 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
import 'dotenv/config';
import { HardhatUserConfig, task } from 'hardhat/config';
import '@compound-finance/hardhat-import';
import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-etherscan';
import '@typechain/hardhat';
import 'hardhat-cover';
import 'hardhat-contract-sizer';
import 'hardhat-gas-reporter';
// Hardhat tasks
import './tasks/deployment_manager/task.ts';
import './tasks/spider/task.ts';
import './tasks/scenario/task.ts';
// Relation Config
import relationConfigMap from './deployments/relations';
import fujiRelationConfigMap from './deployments/fuji/relations';
import kovanRelationConfigMap from './deployments/kovan/relations';
task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => {
for (const account of await hre.ethers.getSigners()) console.log(account.address);
});
/* note: boolean environment variables are imported as strings */
const {
COINMARKETCAP_API_KEY,
ETH_PK = '',
ETHERSCAN_KEY,
SNOWTRACE_KEY,
INFURA_KEY,
MNEMONIC = '',
REPORT_GAS = 'false',
} = process.env;
function throwIfMissing(envVariable, msg: string) {
if (!envVariable) {
throw new Error(msg);
}
}
// required environment variables
throwIfMissing(ETHERSCAN_KEY, 'Missing required environment variable: ETHERSCAN_KEY');
throwIfMissing(SNOWTRACE_KEY, 'Missing required environment variable: SNOWTRACE_KEY');
throwIfMissing(INFURA_KEY, 'Missing required environment variable: INFURA_KEY');
// Networks
interface NetworkConfig {
network: string;
chainId: number;
url?: string;
gas?: number | 'auto';
gasPrice?: number | 'auto';
}
const networkConfigs: NetworkConfig[] = [
{ network: 'mainnet', chainId: 1 },
{ network: 'ropsten', chainId: 3 },
{ network: 'rinkeby', chainId: 4 },
{ network: 'goerli', chainId: 5 },
{ network: 'kovan', chainId: 42 },
{
network: 'avalanche',
chainId: 43114,
url: 'https://api.avax.network/ext/bc/C/rpc',
},
{
network: 'fuji',
chainId: 43113,
url: 'https://api.avax-test.network/ext/bc/C/rpc',
},
];
function getDefaultProviderURL(network: string) {
return `https://${network}.infura.io/v3/${INFURA_KEY}`;
}
function setupDefaultNetworkProviders(hardhatConfig: HardhatUserConfig) {
for (const netConfig of networkConfigs) {
hardhatConfig.networks[netConfig.network] = {
chainId: netConfig.chainId,
url: netConfig.url || getDefaultProviderURL(netConfig.network),
gas: netConfig.gas || 'auto',
gasPrice: netConfig.gasPrice || 'auto',
accounts: ETH_PK
? [ETH_PK]
: {
mnemonic: MNEMONIC,
},
};
}
}
/**
* @type import('hardhat/config').HardhatUserConfig
*/
const config: HardhatUserConfig = {
solidity: {
version: '0.8.15',
settings: {
optimizer: (
process.env['OPTIMIZER_DISABLED'] ? { enabled: false } : {
enabled: true,
runs: 1,
details: {
yulDetails: {
optimizerSteps: 'dhfoDgvulfnTUtnIf [xa[r]scLM cCTUtTOntnfDIul Lcul Vcul [j] Tpeul xa[rul] xa[r]cL gvif CTUca[r]LsTOtfDnca[r]Iulc] jmul[jul] VcTOcul jmul'
},
},
}
),
outputSelection: {
"*": {
"*": ["evm.deployedBytecode.sourceMap"]
},
},
viaIR: process.env['OPTIMIZER_DISABLED'] ? false : true,
},
},
networks: {
hardhat: {
chainId: 1337,
loggingEnabled: !!process.env['LOGGING'],
gas: 12000000,
gasPrice: 'auto',
blockGasLimit: 12000000,
accounts: {
mnemonic: MNEMONIC || 'myth like bonus scare over problem client lizard pioneer submit female collect',
},
// this should be default commented out and only enabled during dev to allow partial testing
// XXX comment out by default once we've made the full contract fit
allowUnlimitedContractSize: true,
},
},
// See https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html#multiple-api-keys-and-alternative-block-explorers
etherscan: {
apiKey: {
// Ethereum
mainnet: ETHERSCAN_KEY,
ropsten: ETHERSCAN_KEY,
rinkeby: ETHERSCAN_KEY,
goerli: ETHERSCAN_KEY,
kovan: ETHERSCAN_KEY,
// Avalanche
avalanche: SNOWTRACE_KEY,
avalancheFujiTestnet: SNOWTRACE_KEY,
},
},
typechain: {
outDir: 'build/types',
target: 'ethers-v5',
},
deploymentManager: {
relationConfigMap,
networks: {
fuji: fujiRelationConfigMap,
kovan: kovanRelationConfigMap,
},
},
scenario: {
bases: [
{
name: 'development',
},
{
name: 'kovan',
chainId: 42,
url: getDefaultProviderURL('kovan'),
allocation: 0.1, // eth
},
{
name: 'fuji',
chainId: 43113,
url: 'https://api.avax-test.network/ext/bc/C/rpc',
},
],
},
mocha: {
reporter: 'mocha-multi-reporters',
reporterOptions: {
reporterEnabled: ['spec', 'json'],
jsonReporterOptions: {
output: 'test-results.json',
},
},
},
paths: {
tests: './{test,plugins/deployment_manager/test}',
},
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
runOnCompile: true,
strict: false, // allow tests to run anyway
},
gasReporter: {
enabled: REPORT_GAS === 'true' ? true : false,
currency: 'USD',
coinmarketcap: COINMARKETCAP_API_KEY,
gasPrice: 200, // gwei
},
};
setupDefaultNetworkProviders(config);
export default config;