-
Notifications
You must be signed in to change notification settings - Fork 4
/
hardhat.config.ts
366 lines (339 loc) · 14.4 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
import { task, types } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-etherscan'
import '@nomicfoundation/hardhat-chai-matchers'
import '@typechain/hardhat'
import 'hardhat-watcher'
import '@openzeppelin/hardhat-upgrades'
import 'hardhat-dependency-compiler'
import { transferManyShieldTokenTask } from './tasks/transferManyShieldTokenTask'
import { addAllocationsShieldTokenTask } from './tasks/addAllocationsShieldTokenTask'
import { deployBullTokenTask } from './tasks/deployBullTokenTask'
import { claimManyTask } from './tasks/claimManyTask'
import { upgradeContractTask } from './tasks/upgradeContractTask'
import { rollbackBullTokenTask } from './tasks/rollbackBullTokenTask'
import { deployMCPTask } from './tasks/deployMCPTask'
import { deployNonUpgradeableContractTask, deployUpgradeableContractTask } from './tasks/deployContractTask'
import { transferManyTask } from './tasks/transferManyTask'
import { HardhatUserConfig } from 'hardhat/types'
import { maxFeePerGas as gasPrice } from './utils-local/gas'
import { mnemonic } from './utils-local/config'
import { setClaimsTask } from './tasks/setClaimsTask'
import { writeClaimsTask, writeClaimsTaskCacheTtl } from './tasks/writeClaimsTask'
// import 'longjohn'
import { hours, minutes } from './utils-local/time'
import { getJsonRpcUrl } from './utils-local/ethereum'
import { deployColiTokenTask } from './tasks/deployColiTokenTask'
import { bnbmainnet, bnbtestnet, cantomainnet, cantotestnet, goerli, mainnet, rinkeby, ropsten } from './libs/ethereum/data/allNetworks'
import { Network } from './libs/ethereum/models/Network'
import { NetworkUserConfig } from 'hardhat/src/types/config'
import { writeClaimsToZeroTask } from './tasks/writeClaimsToZeroTask'
import { writeTotalsTask } from './tasks/writeTotalsTask'
import { amount, timestamp } from './utils-local/hardhat'
import { addVestingTypesTask } from './tasks/addVestingTypes'
import { addAllocationsTask } from './tasks/addAllocations'
import { assumeIntegerEnvVar } from './utils/env'
import { fetchStringEnvVar } from './libs/utils/process'
// if (process.env.NODE_ENV !== 'production'){
// require('longjohn');
// }
const defaultSolcSettings = {
optimizer: {
enabled: true,
runs: 999999,
},
}
/**
* `Warning: Requested source "${path}" does not exist` - false positive, can be ignored
*/
const modelCheckerSettings = {
'contracts': {
'contracts/InstrumentedERC20Enumerable.sol': ['InstrumentedERC20Enumerable'],
'contracts/Max.sol': ['Max'],
},
'engine': 'chc',
'invariants': ['contract', 'reentrancy'],
'showUnproved': true,
'targets': ['assert', 'divByZero', 'constantCondition', 'balance'],
'timeout': assumeIntegerEnvVar('TIMEOUT', undefined),
}
export const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
solidity: {
compilers: [
{
version: '0.8.16',
settings: {
...defaultSolcSettings,
// 'modelChecker': modelCheckerSettings,
},
},
{
version: '0.8.4',
settings: defaultSolcSettings,
},
{
version: '0.5.16',
settings: defaultSolcSettings,
},
{
version: '0.6.6',
settings: defaultSolcSettings,
},
],
},
namedAccounts: { deployer: '0x7554140235ad2D1Cc75452D2008336700C598Dc1' },
networks: {
hardhat: {
initialDate: new Date(0).toISOString(),
gasPrice,
gasMultiplier: 1,
// forking: {
// url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY_MAINNET}`,
// blockNumber: 12779553,
// },
blockGasLimit: 16000000, // increased blockGasLimit to deploy FairpoolTest.sol
allowUnlimitedContractSize: true,
accounts: { mnemonic },
},
localhost: {
// accounts: { mnemonic },
gasPrice,
gasMultiplier: 1.2,
blockGasLimit: 8000000,
timeout: 30 * minutes,
},
mainnet: fromNetwork(mainnet, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 24 * hours,
}),
goerli: fromNetwork(goerli, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 2 * minutes,
}),
goerli_hardware: fromNetwork(goerli, {
url: 'http://127.0.0.1:1248', // The RPC endpoint exposed by Frame
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 5 * minutes,
}),
ropsten: fromNetwork(ropsten, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 2 * minutes,
}),
rinkeby: fromNetwork(rinkeby, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 2 * minutes,
}),
bnbmainnet: fromNetwork(bnbmainnet, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 24 * hours,
}),
bnbtestnet: fromNetwork(bnbtestnet, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 2 * minutes,
}),
avaxmainnet: {
url: 'https://api.avax.network/ext/bc/C/rpc',
chainId: 43114,
gasPrice,
gasMultiplier: 1.2,
blockGasLimit: 8000000,
accounts: { mnemonic },
timeout: 24 * hours,
},
avaxtestnet: {
url: 'https://api.avax-test.network/ext/bc/C/rpc',
chainId: 43113,
gasPrice,
gasMultiplier: 1.2,
blockGasLimit: 8000000,
accounts: { mnemonic },
timeout: 2 * minutes,
},
cantomainnet: fromNetwork(cantomainnet, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 24 * hours,
}),
cantotestnet: fromNetwork(cantotestnet, {
gasPrice,
gasMultiplier: 1.2,
accounts: { mnemonic },
timeout: 2 * minutes,
}),
},
etherscan: {
apiKey: {
mainnet: fetchStringEnvVar('ETHERSCAN_API_KEY', process.env.ETHERSCAN_API_KEY),
goerli: fetchStringEnvVar('ETHERSCAN_API_KEY', process.env.ETHERSCAN_API_KEY),
ropsten: fetchStringEnvVar('ETHERSCAN_API_KEY', process.env.ETHERSCAN_API_KEY),
rinkeby: fetchStringEnvVar('ETHERSCAN_API_KEY', process.env.ETHERSCAN_API_KEY),
bsc: fetchStringEnvVar('BSCSCAN_API_KEY', process.env.BSCSCAN_API_KEY),
bscTestnet: fetchStringEnvVar('BSCSCAN_API_KEY', process.env.BSCSCAN_API_KEY),
avalanche: fetchStringEnvVar('SNOWTRACE_API_KEY', process.env.SNOWTRACE_API_KEY),
avalancheFujiTestnet: fetchStringEnvVar('SNOWTRACE_API_KEY', process.env.SNOWTRACE_API_KEY),
cantotestnet: fetchStringEnvVar('CANTO_API_KEY', process.env.CANTO_API_KEY),
cantomainnet: fetchStringEnvVar('CANTO_API_KEY', process.env.CANTO_API_KEY),
},
},
mocha: {
parallel: true,
fullStackTrace: true,
fullTrace: true,
},
watcher: {
run: {
tasks: [
'clean',
{ command: 'compile', params: { quiet: true } },
{ command: 'test', params: { noCompile: true, testFiles: ['testfile.ts'] } },
],
},
// doesn't pass extra options (e.g. --grep)
test: {
tasks: [{ command: 'test', params: { grep: process.env.MOCHA_GREP } }],
files: ['./test/**/*', './contracts/**/*', './models/**/*', './data/**/*', './tasks/**/*', './util/**/*', './util-local/**/*'],
verbose: true,
clearOnStart: true,
runOnLaunch: true,
},
},
typechain: {
externalArtifacts: [
'node_modules/@uniswap/v2-core/build/!(Combined-Json).json',
'node_modules/@uniswap/v2-periphery/build/!(Combined-Json).json',
],
},
dependencyCompiler: {
paths: [
'@uniswap/v2-core/contracts/UniswapV2Pair.sol',
'@uniswap/v2-core/contracts/UniswapV2Factory.sol',
'@uniswap/v2-periphery/contracts/UniswapV2Router02.sol',
'@uniswap/v2-periphery/contracts/test/WETH9.sol',
'@uniswap/v2-periphery/contracts/test/WETH9.sol',
],
keep: true,
// path: `${os.tmpdir()}/hardhat-dependency-compiler`,
},
// paths: {
// // sources: "?(.|./node_modules/@uniswap/v2-core|./node_modules/@uniswap/v2-periphery)/contracts",
// sources: "+(./contracts)",
// },
}
Error.stackTraceLimit = Infinity
function fromNetwork(network: Network, config: NetworkUserConfig): NetworkUserConfig {
return {
blockGasLimit: network.blockGasLimit,
url: getJsonRpcUrl(network.name),
...config,
}
}
export default config
task('deployColiToken', 'Deploy ColiToken contract')
.addParam('fromNetwork', '', undefined, types.string)
.addParam('isPaused', '', false, types.boolean)
.addParam('allocations', 'CSV file with allocations', undefined, types.string)
.addParam('expectations', 'TypeScript file with test expectations', undefined, types.string)
.addParam('cacheKey', 'Cache key (should be unique for each run group)', undefined, types.string)
.setAction(deployColiTokenTask)
task('deployBullToken', 'Deploy BullToken contract')
.setAction(deployBullTokenTask)
task('deployMCP', 'Deploy MCP contract')
.addParam('feeDivisorMin', 'Minimal fee divisor', 100, types.int)
.setAction(deployMCPTask)
task('deployNonUpgradeableContract', 'Deploy a non-upgradeable contract')
.addParam('contractName', 'Contract name', undefined, types.string)
.addOptionalParam('contractNameEnvVar', 'Contract name for environment variable', undefined, types.string)
.addOptionalParam('constructorArgsModule', 'File path to a javascript module that exports the list of arguments.', undefined, types.inputFile)
.addOptionalVariadicPositionalParam('constructorArgsParams', 'Contract constructor arguments. Ignored if the --constructorArgsModule option is used.', [])
.addOptionalParam('verify', 'Verify the contract', true, types.boolean)
.addOptionalParam('deployer', 'Deployer address', undefined, types.string)
.setAction(deployNonUpgradeableContractTask)
task('deployUpgradeableContract', 'Deploy a non-upgradeable contract')
.addParam('contractName', 'Contract name', undefined, types.string)
.addOptionalParam('contractNameEnvVar', 'Contract name for environment variable', undefined, types.string)
.addOptionalParam('constructorArgsModule', 'File path to a javascript module that exports the list of arguments.', undefined, types.inputFile)
.addOptionalVariadicPositionalParam('constructorArgsParams', 'Contract constructor arguments. Ignored if the --constructorArgsModule option is used.', [])
.addOptionalParam('verify', 'Verify the contract', true, types.boolean)
.addOptionalParam('deployer', 'Deployer address', undefined, types.string)
.setAction(deployUpgradeableContractTask)
task('upgradeContract', 'Upgrade a contract')
.addParam('contractName', 'Contract name')
.addParam('contractAddress', 'Contract proxy address')
.setAction(upgradeContractTask)
task('transferManyShieldToken', 'Call transferManyShield for allocations without lockup period')
.addParam('token', 'SHLD token contract address')
.addParam('allocations', 'JSON with allocations')
.addParam('chunk', 'Number of recipients in one chunk. Default value is 100.', 100, types.int)
.setAction(transferManyShieldTokenTask)
task('addAllocationsShieldToken', 'Call addAllocations() for allocations with lockup period')
.addParam('token', 'SHLD token contract address')
.addParam('allocations', 'JSON with allocations')
.setAction(addAllocationsShieldTokenTask)
task('writeClaims', 'Write claims for the BULL token contract')
.addParam('rewrites', 'CSV with address rewrites', undefined, types.string)
.addParam('out', 'Filename for writing the balances', undefined, types.string)
.addParam('expectations', 'TypeScript file with test expectations')
.addParam('cacheKey', 'Cache key (should be unique for each run group)', undefined, types.string)
.addParam('cacheTtl', 'Cache ttl (in seconds)', writeClaimsTaskCacheTtl, types.int)
.setAction(writeClaimsTask)
task('writeClaimsToZero', 'Write claims for the BULL token contract')
.addParam('rewrites', 'CSV with address rewrites', undefined, types.string)
.addParam('out', 'Filename for writing the balances', undefined, types.string)
.addParam('expectations', 'TypeScript file with test expectations')
.addParam('cacheKey', 'Cache key (should be unique for each run group)', undefined, types.string)
.addParam('cacheTtl', 'Cache ttl (in seconds)', writeClaimsTaskCacheTtl, types.int)
.setAction(writeClaimsToZeroTask)
task('setClaims', 'Call setClaims() on BULL token contract')
.addParam('claims', 'JSON file with claim balances', '', types.string)
// .addParam('expectations', 'TypeScript file with test expectations')
.addParam('chunkSize', 'Number of addresses in a single transaction', 400, types.int)
.setAction(setClaimsTask)
task('claimMany', 'Call claimMany() on BULL token contract')
.addParam('claimer', 'Claim transaction sender address', undefined, types.string, true)
.addParam('claims', 'CSV file with addresses')
.setAction(claimManyTask)
task('rollback', 'Change the balances of BullToken back to certain date')
.addParam('contractAddress', 'BULL token contract address')
.addParam('from', 'From block number', undefined, types.int, false)
.addParam('to', 'To block number', undefined, types.int, false)
.addParam('pools', 'BULL token Uniswap pools addresses (comma-separated)')
.addParam('holders', 'CSV file with token holder addresses')
.addParam('expectations', 'TypeScript file with test expectations')
.setAction(rollbackBullTokenTask)
task('transferMany', 'Upgrade a token contract')
.addParam('contractName', 'Contract name')
.addParam('contractAddress', 'Contract address')
.addParam('balances', 'File with balances (download from blockchain explorer)')
.addParam('expectations', 'TypeScript file with test expectations')
.setAction(transferManyTask)
task('writeTotals', 'Write totals for specific addresses')
.addParam('addressables', 'CSV with addresses', undefined, types.string)
.addParam('timestamp', 'Timestamp as number or string in ISO format', undefined, timestamp)
.addParam('out', 'Filename for writing the totals', undefined, types.string)
.setAction(writeTotalsTask)
task('addVestingTypes', 'Add vesting types')
.addParam('vestingTypes', 'TS file with vesting types', undefined, types.string)
.addParam('contractAddress', 'Token contract address', undefined, types.string)
.setAction(addVestingTypesTask)
task('addAllocations', 'Add allocations')
.addParam('allocations', 'CSV file with allocations', undefined, types.string)
.addParam('vestingTypes', 'TS file with vesting types', undefined, types.string)
.addParam('contractAddress', 'Token contract address', undefined, types.string)
.addParam('totalAmount', 'Total amount of allocations', undefined, amount)
.setAction(addAllocationsTask)