-
Notifications
You must be signed in to change notification settings - Fork 1
/
hardhat.config.ts
184 lines (173 loc) · 6.08 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
import '@nomiclabs/hardhat-waffle';
import 'hardhat-tracer';
import '@typechain/hardhat';
import 'hardhat-gas-reporter';
import 'hardhat-contract-sizer';
import 'hardhat-deploy';
import 'solidity-coverage';
import '@nomiclabs/hardhat-etherscan';
import '@protodev-rage/hardhat-tenderly';
import 'hardhat-dependency-compiler';
import 'hardhat-storage-layout-changes';
import { config } from 'dotenv';
import { ethers } from 'ethers';
import { Fragment } from 'ethers/lib/utils';
import { readJsonSync, writeJsonSync } from 'fs-extra';
import { TASK_COMPILE } from 'hardhat/builtin-tasks/task-names';
import { task } from 'hardhat/config';
import nodePath from 'path';
config();
const { ALCHEMY_KEY, LEDGER_ADDRESS } = process.env;
// this compile task override is needed to copy missing abi fragments to respective artifacts (note its not aval to typechain)
task(TASK_COMPILE, 'Compiles the entire project, building all artifacts').setAction(async (taskArgs, _, runSuper) => {
const compileSolOutput: any = await runSuper(taskArgs);
copyEventErrorAbi(
'artifacts/contracts/libraries/Logic.sol/Logic.json',
'artifacts/contracts/yieldStrategy/CurveYieldStrategy.sol/CurveYieldStrategy.json',
);
copyEventErrorAbi(
'artifacts/contracts/libraries/SwapManager.sol/SwapManager.json',
'artifacts/contracts/yieldStrategy/CurveYieldStrategy.sol/CurveYieldStrategy.json',
);
function copyEventErrorAbi(from: string, to: string) {
const fromArtifact = readJsonSync(nodePath.resolve(__dirname, from));
const toArtifact = readJsonSync(nodePath.resolve(__dirname, to));
fromArtifact.abi.forEach((fromFragment: Fragment) => {
if (
// only copy error and event fragments
(fromFragment.type === 'error' || fromFragment.type === 'event') &&
// if fragment is already in the toArtifact, don't copy it
!toArtifact.abi.find(
({ name, type }: Fragment) => name + '-' + type === fromFragment.name + '-' + fromFragment.type,
)
) {
toArtifact.abi.push(fromFragment);
}
});
writeJsonSync(nodePath.resolve(__dirname, to), toArtifact, { spaces: 2 });
}
return compileSolOutput;
});
if (!process.env.ALCHEMY_KEY) {
console.warn('PLEASE NOTE: The env var ALCHEMY_KEY is not set');
}
const pk = process.env.PRIVATE_KEY || ethers.utils.hexlify(ethers.utils.randomBytes(32));
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
export default {
networks: {
hardhat: {
forking: {
url: `https://arb-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`,
blockNumber: 22049346, // 9323800,
},
blockGasLimit: 0x1fffffffffff,
gasPrice: 0,
initialBaseFeePerGas: 0,
allowUnlimitedContractSize: false,
},
rinkeby: {
url: `https://eth-rinkeby.alchemyapi.io/v2/${ALCHEMY_KEY}`,
accounts: [pk],
},
mainnet: {
url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`,
accounts: [pk],
},
arbmain: {
url: `https://arb1.arbitrum.io/rpc`,
accounts: [pk],
chainId: 42161,
},
arbtest: {
url: `https://rinkeby.arbitrum.io/rpc`,
accounts: [pk],
chainId: 421611,
},
},
solidity: {
compilers: [
{
version: '0.8.14',
settings: {
optimizer: {
enabled: true,
runs: 256,
},
metadata: {
// do not include the metadata hash, since this is machine dependent
// and we want all generated code to be deterministic
// https://docs.soliditylang.org/en/v0.8.10/metadata.html
bytecodeHash: 'none',
},
outputSelection: {
'*': {
'*': ['storageLayout'],
},
},
},
},
],
},
dependencyCompiler: {
paths: [
'@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol',
'@ragetrade/core/contracts/protocol/clearinghouse/ClearingHouse.sol',
'@ragetrade/core/contracts/protocol/RageTradeFactory.sol',
'@ragetrade/core/contracts/protocol/wrapper/VPoolWrapper.sol',
'@ragetrade/core/contracts/protocol/insurancefund/InsuranceFund.sol',
'@ragetrade/core/contracts/lens/SwapSimulator.sol',
'@ragetrade/core/contracts/oracles/ChainlinkOracle.sol',
'@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol',
'@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol',
'@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol',
],
},
typechain: {
target: 'ethers-v5',
alwaysGenerateOverloads: false,
externalArtifacts: [
'node_modules/@uniswap/v3-periphery/artifacts/contracts/interfaces/IQuoter.sol/IQuoter.json',
'node_modules/@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json',
'node_modules/@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json',
'node_modules/@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json',
'node_modules/@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3PoolDeployer.sol/IUniswapV3PoolDeployer.json',
'node_modules/@uniswap/v2-core/build/IUniswapV2Factory.json',
'node_modules/@uniswap/v2-core/build/IUniswapV2Pair.json',
'node_modules/@uniswap/v2-periphery/build/IUniswapV2Router02.json',
],
},
etherscan: {
apiKey: process.env.ETHERSCAN_KEY,
},
mocha: {
timeout: 400000,
},
gasReporter: {
currency: 'USD',
gasPrice: 100,
enabled: !!process.env.REPORT_GAS, // REPORT_GAS=true yarn test
coinmarketcap: process.env.COINMARKETCAP, // https://coinmarketcap.com/api/pricing/
},
contractSizer: {
strict: true,
},
namedAccounts: {
deployer: LEDGER_ADDRESS
? `ledger://${LEDGER_ADDRESS}`
: {
default: 0,
},
},
tenderly: {
project: process.env.TENDERLY_PROJECT,
username: process.env.TENDERLY_USERNAME,
},
storageLayoutChanges: {
contracts: ['CurveYieldStrategy', 'VaultPeriphery'],
fullPath: false,
},
};