forked from AngleProtocol/angle-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
256 lines (241 loc) · 5.89 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
/// ENVVAR
// - ENABLE_GAS_REPORT
// - CI
// - RUNS
import 'dotenv/config'
import yargs from 'yargs'
import { nodeUrl, accounts } from './utils/network'
import { HardhatUserConfig, subtask } from 'hardhat/config'
import { TASK_COMPILE_GET_COMPILATION_TASKS } from 'hardhat/builtin-tasks/task-names'
import '@nomiclabs/hardhat-vyper'
import path from 'path'
import fse from 'fs-extra'
import 'hardhat-contract-sizer'
import 'hardhat-spdx-license-identifier'
import 'hardhat-docgen'
import 'hardhat-deploy'
import 'hardhat-abi-exporter'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-truffle5'
import '@nomiclabs/hardhat-solhint'
import '@openzeppelin/hardhat-upgrades'
import 'solidity-coverage'
import '@tenderly/hardhat-tenderly'
import '@typechain/hardhat'
const argv = yargs
.env('')
.boolean('enableGasReport')
.boolean('ci')
.number('runs')
.boolean('fork')
.boolean('disableAutoMining')
.parseSync()
if (argv.enableGasReport) {
import('hardhat-gas-reporter') // eslint-disable-line
}
const VYPER_TEMP_DIR = path.join(__dirname, 'vyper_temp_dir')
subtask(
TASK_COMPILE_GET_COMPILATION_TASKS,
async (_, { config }, runSuper): Promise<string[]> => {
await runSuper()
// We save already compiled vyper artifacts
const glob = await import('glob')
const vyFiles = glob.sync(path.join(config.paths.artifacts, '**', '*.vy'))
const vpyFiles = glob.sync(
path.join(config.paths.artifacts, '**', '*.v.py'),
)
const files = [...vyFiles, ...vpyFiles]
await fse.remove(VYPER_TEMP_DIR)
await fse.mkdir(VYPER_TEMP_DIR)
for (const file of files) {
const filename = file.replace(config.paths.artifacts + '/contracts/', '')
await fse.move(file, path.join(VYPER_TEMP_DIR, filename))
}
return ['compile:solidity', 'restore_vyper_artifacts', 'compile:vyper']
},
)
subtask<{ force: boolean }>(
'restore_vyper_artifacts',
async (args, { config }) => {
if (!args.force) {
const dirs = await fse.readdir(VYPER_TEMP_DIR)
for (const dir of dirs) {
const destination = path.join(config.paths.artifacts, 'contracts', dir)
if (!fse.pathExists(destination)) {
await fse.move(
path.join(VYPER_TEMP_DIR, dir),
path.join(config.paths.artifacts, 'contracts', dir),
)
} else {
const files = await fse.readdir(path.join(VYPER_TEMP_DIR, dir))
for (const file of files) {
await fse.move(
path.join(VYPER_TEMP_DIR, dir, file),
path.join(config.paths.artifacts, 'contracts', dir, file),
{
overwrite: true,
},
)
}
}
}
}
await fse.remove(VYPER_TEMP_DIR)
},
)
subtask('compile:vyper', async (_, { config, artifacts }) => {
const { compile } = await import('./vyperCompile')
const { generateVyperTypes } = await import('./vyperTypesGenerator')
await compile(config.vyper, config.paths, artifacts)
await generateVyperTypes()
})
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: '0.8.7',
settings: {
optimizer: {
enabled: true,
runs: 1000000,
},
// debug: { revertStrings: 'strip' },
},
},
],
overrides: {
'contracts/stableMaster/StableMasterFront.sol': {
version: '0.8.7',
settings: {
optimizer: {
enabled: true,
runs: 830,
},
},
},
'contracts/perpetualManager/PerpetualManagerFront.sol': {
version: '0.8.7',
settings: {
optimizer: {
enabled: true,
runs: 283,
},
},
},
},
},
vyper: {
version: '0.2.16',
},
defaultNetwork: 'hardhat',
networks: {
hardhat: {
accounts: accounts('mainnet'),
live: argv.fork || false,
blockGasLimit: 125e5,
initialBaseFeePerGas: 0,
hardfork: 'london',
forking: {
enabled: argv.fork || false,
url: nodeUrl('fork'),
// blockNumber: 13473325,
},
mining: argv.disableAutoMining
? {
auto: false,
interval: 1000,
}
: { auto: true },
chainId: 1337,
},
kovan: {
live: false,
url: nodeUrl('kovan'),
accounts: accounts('kovan'),
gas: 12e6,
gasPrice: 1e9,
chainId: 42,
},
rinkeby: {
live: true,
url: nodeUrl('rinkeby'),
accounts: accounts('rinkeby'),
gas: 'auto',
// gasPrice: 12e8,
chainId: 4,
},
mumbai: {
url: nodeUrl('mumbai'),
accounts: accounts('mumbai'),
gas: 'auto',
},
polygon: {
url: nodeUrl('polygon'),
accounts: accounts('polygon'),
gas: 'auto',
},
mainnet: {
live: true,
url: nodeUrl('mainnet'),
accounts: accounts('mainnet'),
gas: 'auto',
gasMultiplier: 1.3,
chainId: 1,
},
angleTestNet: {
url: nodeUrl('angle'),
accounts: accounts('angle'),
gas: 12e6,
gasPrice: 5e9,
},
},
paths: {
sources: './contracts',
tests: './test',
},
namedAccounts: {
deployer: 0,
guardian: 1,
user: 2,
slp: 3,
ha: 4,
keeper: 5,
user2: 6,
slp2: 7,
ha2: 8,
keeper2: 9,
},
mocha: {
timeout: 100000,
retries: argv.ci ? 10 : 0,
},
contractSizer: {
alphaSort: true,
runOnCompile: false,
disambiguatePaths: false,
},
gasReporter: {
currency: 'USD',
outputFile: argv.ci ? 'gas-report.txt' : undefined,
},
spdxLicenseIdentifier: {
overwrite: true,
runOnCompile: false,
},
docgen: {
path: './docs',
clear: true,
runOnCompile: false,
},
abiExporter: {
path: './export/abi',
clear: true,
flat: true,
spacing: 2,
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
},
}
export default config