-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
275 lines (264 loc) · 9.36 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
import "@atixlabs/hardhat-time-n-mine";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-solhint";
import "@nomiclabs/hardhat-waffle";
import "@openzeppelin/hardhat-upgrades";
import "@typechain/hardhat";
// This is done to have the new matchers from waffle,
// because despite the note in https://hardhat.org/guides/waffle-testing.html?#adapting-the-tests
// the changeEtherBalance is not added because its a newer version
import chai from "chai";
import { config as dotenvConfig } from "dotenv";
import { solidity } from "ethereum-waffle";
import "hardhat-contract-sizer";
import "hardhat-deploy";
import "hardhat-docgen";
import "hardhat-gas-reporter";
import "hardhat-preprocessor";
import { removeConsoleLog } from "hardhat-preprocessor";
import "hardhat-prettier";
import { HardhatUserConfig } from "hardhat/types";
import { resolve } from "path";
import { BigNumber, Wallet } from "ethers";
import "solidity-coverage";
import "./scripts/custom-tasks";
import ms from "ms";
import { addMilliseconds } from "date-fns";
chai.use(solidity);
dotenvConfig({ path: resolve(__dirname, "./.env") });
const chainIds = {
ganache: 1337,
hardhat: 31337,
rskTestnetMocked: 31,
rskMainnet: 30,
};
const PPM = BigNumber.from(1e6);
const PCT_BASE = BigNumber.from((1e18).toString());
const DAYS = 24 * 3600;
const startInAnHourFromNow = () => {
const delta = ms("1 hour");
const newDate = addMilliseconds(new Date(), delta);
return BigNumber.from(newDate.getTime()).div(1000);
};
// Ensure that we have all the environment variables we need.
let mnemonic: string;
if (!process.env.MNEMONIC) {
throw new Error("Please set your MNEMONIC in a .env file");
} else {
mnemonic = process.env.MNEMONIC;
}
const getPrivateKey = () =>
process.env.DEPLOYER_PRIVATE_KEY ? [process.env.DEPLOYER_PRIVATE_KEY] : [Wallet.createRandom().privateKey];
type Parameters = {
// the date (unixtime, ms) upon which that presale is to be open [ignored if 0]
startDate: BigNumber;
// the percentage of the raised funds that will be sent to beneficiary address during presale period
mintingBeneficiaryPCT: BigNumber;
// the amount of time, in ms, that the presale will last
presalePeriod: number;
// the exchangeRate [= 1/price] at which [bonded] tokens are to be purchased for that presale [in PPM]
presaleEchangeRate: BigNumber;
// the reserve ratio to be used for that collateral token [in PPM]
reserveRatio: BigNumber;
// the amount of blocks a batch will contain
batchBlock: number;
// the price slippage below which each batch is to be kept for that collateral token [in PCT_BASE]
slippage: BigNumber;
// the fee to be deducted from buy orders [in PCT_BASE]
buyFee: BigNumber;
// the fee to be deducted from sell orders [in PCT_BASE]
selFee: BigNumber;
// the address of the collateral token, only necessary. If not provided, a mock token will be deployed
collateralTokenAddress?: string;
// the address of the bonded token, only necessary. if not provided a mock token will be deployed.
bondedTokenAddress?: string;
// the address of the governance, permissions will be transfer to this address after deployment. If not provided, permissions remains to deployer address
governanceAddress?: string;
// the address of the beneficiary, fees will be transfer to this address.
beneficiaryAddress: string;
};
declare module "hardhat/types/config" {
export interface HardhatNetworkUserConfig {
// If true it will deploy a mocked presale contract version that allow update date to close presale (for testing purposes)
mockPresale: boolean;
parameters: Parameters;
}
export interface HardhatNetworkConfig {
mockPresale: boolean;
parameters: Parameters;
}
}
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
namedAccounts: {
deployer: 0,
otherUser: 1,
},
networks: {
hardhat: {
mockPresale: true,
parameters: {
startDate: BigNumber.from(new Date().getTime()).div(1000).add(DAYS),
mintingBeneficiaryPCT: PPM.mul(35).div(100),
presalePeriod: 14 * DAYS,
presaleEchangeRate: PPM.mul(10000).div(100),
reserveRatio: PPM.mul(40).div(100),
batchBlock: 10,
slippage: PCT_BASE.mul(3).div(100),
buyFee: BigNumber.from(0),
selFee: PCT_BASE.mul(3).div(1000),
beneficiaryAddress: "0x4D1A9fD1E1e67E83Ffe72Bdd769088d689993E4B",
governanceAddress: "0x4D1A9fD1E1e67E83Ffe72Bdd769088d689993E4B",
},
accounts: {
mnemonic,
},
chainId: chainIds.hardhat,
},
rskdev: {
mockPresale: false,
parameters: {
startDate: BigNumber.from(new Date().getTime()).div(1000).add(1000),
mintingBeneficiaryPCT: PPM.mul(35).div(100),
presalePeriod: 14 * DAYS,
presaleEchangeRate: PPM.mul(10000).div(100),
reserveRatio: PPM.mul(40).div(100),
batchBlock: 10,
slippage: PCT_BASE.mul(3).div(100),
buyFee: BigNumber.from(0),
selFee: PCT_BASE.mul(3).div(1000),
beneficiaryAddress: "0xB0D1D7fad89CfC28394b0B1AB51d24c432170f5A",
},
url: "http://localhost:4444",
// regtest default prefunded account
from: "0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826",
gasMultiplier: 1.25,
},
rskTestnetMocked: {
mockPresale: true,
parameters: {
startDate: BigNumber.from(new Date().getTime()).div(1000).add(1000),
mintingBeneficiaryPCT: PPM.mul(35).div(100),
presalePeriod: 2 * DAYS,
presaleEchangeRate: PPM.mul(10000).div(100),
reserveRatio: PPM.mul(40).div(100),
batchBlock: 10,
slippage: PCT_BASE.mul(3).div(100),
buyFee: BigNumber.from(0),
selFee: PCT_BASE.mul(3).div(1000),
beneficiaryAddress: "",
governanceAddress: "",
},
url: "https://public-node.testnet.rsk.co",
accounts: getPrivateKey(),
chainId: chainIds.rskTestnetMocked,
},
rskTestnetMockedWithSOV: {
mockPresale: false,
parameters: {
startDate: startInAnHourFromNow(),
mintingBeneficiaryPCT: PPM.mul(35).div(100),
presalePeriod: 1 * DAYS,
presaleEchangeRate: PPM.mul(10000).div(100),
reserveRatio: PPM.mul(40).div(100),
batchBlock: 10,
slippage: PCT_BASE.mul(3).div(100),
buyFee: BigNumber.from(0),
selFee: PCT_BASE.mul(3).div(1000),
collateralTokenAddress: "0x6a9A07972D07e58F0daf5122d11E069288A375fb",
beneficiaryAddress: "0x4D1A9fD1E1e67E83Ffe72Bdd769088d689993E4B",
governanceAddress: "0x4D1A9fD1E1e67E83Ffe72Bdd769088d689993E4B",
},
url: "https://testnet.sovryn.app/rpc",
accounts: getPrivateKey(),
chainId: chainIds.rskTestnetMocked,
},
myntRSKTestnet: {
mockPresale: false,
parameters: {
startDate: startInAnHourFromNow(),
mintingBeneficiaryPCT: PPM.mul(BigNumber.from("1575")).div(100).div(100),
presalePeriod: 1 * DAYS,
presaleEchangeRate: PPM.mul(10000).div(100),
reserveRatio: PPM.mul(40).div(100),
batchBlock: 10,
slippage: PCT_BASE.mul(3).div(100),
buyFee: BigNumber.from(0),
selFee: PCT_BASE.mul(3).div(1000),
collateralTokenAddress: "0x6a9A07972D07e58F0daf5122d11E069288A375fb",
bondedTokenAddress: "0x139483e22575826183F5b56dd242f8f2C1AEf327",
beneficiaryAddress: "0x4D1A9fD1E1e67E83Ffe72Bdd769088d689993E4B",
governanceAddress: "0x4D1A9fD1E1e67E83Ffe72Bdd769088d689993E4B",
},
url: "https://testnet.sovryn.app/rpc",
accounts: getPrivateKey(),
chainId: chainIds.rskTestnetMocked,
},
myntRSKMainnet: {
mockPresale: false,
parameters: {
startDate: BigNumber.from("1636383600"), // "2021-10-11T15:00:00.000Z"
mintingBeneficiaryPCT: PPM.mul(BigNumber.from("1575")).div(100).div(100),
presalePeriod: 7 * DAYS,
presaleEchangeRate: PPM.mul(10000).div(100),
reserveRatio: PPM.mul(40).div(100),
batchBlock: 10,
slippage: PCT_BASE.mul(3).div(100),
buyFee: BigNumber.from(0),
selFee: PCT_BASE.mul(3).div(1000),
collateralTokenAddress: "0xefc78fc7d48b64958315949279ba181c2114abbd",
bondedTokenAddress: "0x2e6B1d146064613E8f521Eb3c6e65070af964EbB",
beneficiaryAddress: "0x924f5ad34698Fd20c90Fe5D5A8A0abd3b42dc711",
governanceAddress: "0x924f5ad34698Fd20c90Fe5D5A8A0abd3b42dc711",
},
url: "https://mainnet.sovryn.app/rpc",
accounts: getPrivateKey(),
chainId: chainIds.rskMainnet,
timeout: 20000 * 100
},
},
paths: {
artifacts: "./artifacts",
cache: "./cache",
sources: "./contracts",
tests: "./test",
},
solidity: {
version: "0.4.24",
settings: {
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 200,
},
},
},
typechain: {
outDir: "typechain",
target: "ethers-v5",
alwaysGenerateOverloads: false,
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
currency: "USD",
gasPrice: 21,
},
preprocess: {
eachLine: removeConsoleLog(hre => !["hardhat", "localhost"].includes(hre.network.name)),
},
docgen: {
path: "./docs",
clear: true,
runOnCompile: false,
},
contractSizer: {
alphaSort: true,
runOnCompile: true,
disambiguatePaths: false,
},
mocha: {
timeout: 60000,
},
};
config.networks;
export default config;