forked from ToucanProtocol/example-implementations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
161 lines (147 loc) · 4.26 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
import * as dotenv from "dotenv";
import { HardhatUserConfig, subtask, task } from "hardhat/config";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "solidity-docgen";
import { tokens } from "./utils/tokens";
import addresses, { mumbaiAddresses } from "./utils/addresses";
import { network } from "hardhat";
import { boolean } from "hardhat/internal/core/params/argumentTypes";
import { relative } from "path";
dotenv.config();
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
task("deployOffsetHelper", "Deploys and verifies OffsetHelper")
.addOptionalParam(
"verify",
"Set false to not verify the OffsetHelper after deployment",
true,
boolean
)
.setAction(async (taskArgs, hre) => {
const OffsetHelper = await hre.ethers.getContractFactory("OffsetHelper");
const addressesToUse =
hre.network.name == "mumbai" ? mumbaiAddresses : addresses;
const oh = await OffsetHelper.deploy(tokens, [
addressesToUse.bct,
addressesToUse.nct,
addressesToUse.usdc,
addressesToUse.weth,
addressesToUse.wmatic,
]);
await oh.deployed();
console.log(`OffsetHelper deployed on ${hre.network.name} to:`, oh.address);
if (taskArgs.verify === true) {
await oh.deployTransaction.wait(5);
await hre.run("verify:verify", {
address: oh.address,
constructorArguments: [
tokens,
[
addressesToUse.bct,
addressesToUse.nct,
addressesToUse.usdc,
addressesToUse.weth,
addressesToUse.wmatic,
],
],
});
console.log(
`OffsetHelper verified on ${hre.network.name} to:`,
oh.address
);
}
});
task("deploySwapper", "Deploys and verifies Swapper")
.addOptionalParam(
"verify",
"Set false to not verify the Swapper after deployment",
true,
boolean
)
.setAction(async (taskArgs, hre) => {
const Swapper = await hre.ethers.getContractFactory("Swapper");
const addressesToUse =
hre.network.name == "mumbai" ? mumbaiAddresses : addresses;
const swapper = await Swapper.deploy(tokens, [
addressesToUse.bct,
addressesToUse.nct,
addressesToUse.usdc,
addressesToUse.weth,
addressesToUse.wmatic,
]);
await swapper.deployed();
console.log(`Swapper deployed on ${hre.network.name} to:`, swapper.address);
if (taskArgs.verify === true) {
await swapper.deployTransaction.wait(5);
await hre.run("verify:verify", {
address: swapper.address,
constructorArguments: [
tokens,
[
addressesToUse.bct,
addressesToUse.nct,
addressesToUse.usdc,
addressesToUse.weth,
addressesToUse.wmatic,
],
],
});
console.log(
`Swapper verified on ${hre.network.name} to:`,
swapper.address
);
}
});
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks: {
polygon: {
url:
process.env.POLYGON_URL || "https://matic-mainnet.chainstacklabs.com",
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
mumbai: {
url: process.env.MUMBAI_URL || "https://matic-mumbai.chainstacklabs.com",
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
hardhat: {
forking: {
url:
process.env.POLYGON_URL ||
"https://polygon-mainnet.g.alchemy.com/v2/4rzRS2MH5LIunV6cejmLhQelv_Vd82rq",
},
},
},
mocha: {
timeout: 150000,
},
etherscan: {
apiKey: process.env.POLYGONSCAN_API_KEY || "",
},
docgen: {
pages: (item: any, file: any) =>
file.absolutePath.startsWith("contracts/OffsetHelper")
? relative("contracts", file.absolutePath).replace(".sol", ".md")
: undefined,
},
};
export default config;