@ensuro/core 2.0.0-beta8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -14
- package/build/contracts/AccessManager.sol/AccessManager.json +7 -2
- package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +28 -3
- package/build/contracts/EToken.sol/EToken.json +21 -15
- package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +21 -2
- package/build/contracts/LiquidityThresholdAssetManager.sol/LiquidityThresholdAssetManager.json +26 -1
- package/build/contracts/Policy.sol/Policy.json +2 -2
- package/build/contracts/PolicyPool.sol/PolicyPool.json +40 -2
- package/build/contracts/PolicyPoolComponent.sol/PolicyPoolComponent.json +19 -0
- package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +21 -15
- package/build/contracts/Reserve.sol/Reserve.json +19 -13
- package/build/contracts/RiskModule.sol/RiskModule.json +19 -0
- package/build/contracts/SignedQuoteRiskModule.sol/SignedQuoteRiskModule.json +1110 -0
- package/build/contracts/TimeScaled.sol/TimeScaled.json +3 -17
- package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +137 -2
- package/build/contracts/{WadRayMath.sol → dependencies/WadRayMath.sol}/WadRayMath.json +3 -3
- package/build/contracts/interfaces/IAssetManager.sol/IAssetManager.json +26 -1
- package/build/contracts/interfaces/IPolicyPool.sol/IPolicyPool.json +38 -0
- package/build/contracts/interfaces/IPolicyPoolComponent.sol/IPolicyPoolComponent.json +19 -0
- package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +2 -2
- package/build/contracts/mocks/ForwardProxy.sol/ForwardProxy.json +2 -2
- package/build/contracts/mocks/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +180 -0
- package/build/contracts/mocks/PolicyHolderMock.sol/PolicyHolderMock.json +28 -2
- package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +21 -2
- package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +115 -2
- package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +2 -2
- package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +111 -2
- package/build/contracts/mocks/TestCurrency.sol/TestCurrency.json +2 -2
- package/build/contracts/mocks/TestNFT.sol/TestNFT.json +2 -2
- package/contracts/AccessManager.sol +31 -2
- package/contracts/ERC4626AssetManager.sol +8 -2
- package/contracts/EToken.sol +129 -60
- package/contracts/LPManualWhitelist.sol +18 -2
- package/contracts/LiquidityThresholdAssetManager.sol +28 -12
- package/contracts/Policy.sol +5 -3
- package/contracts/PolicyPool.sol +221 -29
- package/contracts/PolicyPoolComponent.sol +36 -25
- package/contracts/PremiumsAccount.sol +220 -32
- package/contracts/Reserve.sol +130 -19
- package/contracts/RiskModule.sol +53 -20
- package/contracts/SignedQuoteRiskModule.sol +310 -0
- package/contracts/TimeScaled.sol +19 -15
- package/contracts/TrustfulRiskModule.sol +107 -6
- package/contracts/dependencies/WadRayMath.sol +126 -0
- package/contracts/interfaces/IAccessManager.sol +68 -13
- package/contracts/interfaces/IAssetManager.sol +69 -2
- package/contracts/interfaces/IEToken.sol +4 -1
- package/contracts/interfaces/ILPWhitelist.sol +17 -0
- package/contracts/interfaces/IPolicyPool.sol +19 -1
- package/contracts/interfaces/IPolicyPoolComponent.sol +5 -1
- package/contracts/interfaces/IRiskModule.sol +67 -4
- package/contracts/mocks/InterfaceIdCalculator.sol +32 -0
- package/contracts/mocks/PolicyHolderMock.sol +21 -0
- package/contracts/mocks/PolicyPoolComponentMock.sol +10 -0
- package/contracts/mocks/PolicyPoolMock.sol +31 -0
- package/contracts/mocks/RiskModuleMock.sol +7 -1
- package/js/deploy.js +734 -0
- package/js/test-utils.js +184 -69
- package/package.json +4 -2
- package/scripts/change-pragma.sh +19 -0
- package/scripts/deploySmokeTest-fork.sh +53 -0
- package/scripts/deploySmokeTest.sh +51 -0
- package/scripts/storageLayout.js +33 -0
- package/scripts/utils.sh +65 -0
- package/contracts/WadRayMath.sol +0 -135
package/js/deploy.js
ADDED
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
const upgrades_core = require("@openzeppelin/upgrades-core");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
|
|
4
|
+
const ethers = require("ethers");
|
|
5
|
+
|
|
6
|
+
const _BN = ethers.BigNumber.from;
|
|
7
|
+
const WAD = _BN(1e10).mul(_BN(1e8)); // 1e10*1e8=1e18
|
|
8
|
+
const RAY = WAD.mul(_BN(1e9)); // 1e18*1e9=1e27
|
|
9
|
+
|
|
10
|
+
function _W(value) {
|
|
11
|
+
if (!Number.isInteger(value)) return _BN(value * 1e10).mul(_BN(1e8));
|
|
12
|
+
return _BN(value).mul(WAD);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function _R(value) {
|
|
16
|
+
if (!Number.isInteger(value)) return _BN(Math.round(value * 1e9)).mul(WAD);
|
|
17
|
+
return _BN(value).mul(RAY);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function amountDecimals() {
|
|
21
|
+
let decimals = Number.parseInt(process.env.DEPLOY_AMOUNT_DECIMALS);
|
|
22
|
+
console.assert(decimals >= 6);
|
|
23
|
+
return decimals;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _A(value) {
|
|
27
|
+
// Decimals must be at least 6
|
|
28
|
+
if (typeof value === "string" || value instanceof String) {
|
|
29
|
+
return _BN(value).mul(_BN(Math.pow(10, amountDecimals())));
|
|
30
|
+
} else {
|
|
31
|
+
return _BN(Math.round(value * 1e6)).mul(_BN(Math.pow(10, amountDecimals() - 6)));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function saveAddress(name, address) {
|
|
36
|
+
if (name === undefined) {
|
|
37
|
+
throw "Didn't specified an address to save. If you don't want to save the address send null";
|
|
38
|
+
}
|
|
39
|
+
if (!name || name === "") return;
|
|
40
|
+
let addresses;
|
|
41
|
+
let addressesFilename;
|
|
42
|
+
if (process.env.ADDRESSES_FILENAME) {
|
|
43
|
+
addressesFilename = process.env.ADDRESSES_FILENAME;
|
|
44
|
+
} else {
|
|
45
|
+
if (process.env.NETWORK) {
|
|
46
|
+
addressesFilename = `.addresses-${process.env.NETWORK}.json`;
|
|
47
|
+
} else {
|
|
48
|
+
addressesFilename = ".addresses-localhost.json";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
addresses = JSON.parse(fs.readFileSync(addressesFilename));
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.log("Error reading .addresses.json", err);
|
|
55
|
+
addresses = {};
|
|
56
|
+
}
|
|
57
|
+
addresses[name] = address;
|
|
58
|
+
fs.writeFileSync(addressesFilename, JSON.stringify(addresses, null, 4));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function etherscanUrl() {
|
|
62
|
+
return process.env.ETHERSCAN_URL;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function logContractCreated(hre, contractName, address) {
|
|
66
|
+
const browserUrl = etherscanUrl();
|
|
67
|
+
if (browserUrl) {
|
|
68
|
+
console.log(`${contractName} deployed to: ${browserUrl}/address/${address}`);
|
|
69
|
+
} else {
|
|
70
|
+
console.log(`${contractName} deployed to: ${address}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function verifyContract(hre, contract, isProxy, constructorArguments) {
|
|
75
|
+
if (isProxy === undefined) isProxy = false;
|
|
76
|
+
if (constructorArguments === undefined) constructorArguments = [];
|
|
77
|
+
let address = contract.address;
|
|
78
|
+
if (isProxy) address = await upgrades_core.getImplementationAddress(hre.network.provider, address);
|
|
79
|
+
try {
|
|
80
|
+
await hre.run("verify:verify", {
|
|
81
|
+
address: address,
|
|
82
|
+
constructorArguments: constructorArguments,
|
|
83
|
+
});
|
|
84
|
+
if (isProxy) {
|
|
85
|
+
console.log(
|
|
86
|
+
"Contract successfully verified, you should verify the proxy at " +
|
|
87
|
+
`${etherscanUrl()}/proxyContractChecker?a=${contract.address}`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.log("Error verifying contract", error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function deployContract({ saveAddr, verify, contractClass, constructorArgs }, hre) {
|
|
96
|
+
const ContractFactory = await hre.ethers.getContractFactory(contractClass);
|
|
97
|
+
const contract = await ContractFactory.deploy(...constructorArgs);
|
|
98
|
+
if (verify) {
|
|
99
|
+
// From https://ethereum.stackexchange.com/a/119622/79726
|
|
100
|
+
await contract.deployTransaction.wait(6);
|
|
101
|
+
} else {
|
|
102
|
+
await contract.deployed();
|
|
103
|
+
}
|
|
104
|
+
await logContractCreated(hre, contractClass, contract.address);
|
|
105
|
+
saveAddress(saveAddr, contract.address);
|
|
106
|
+
if (verify) await verifyContract(hre, contract, false, constructorArgs);
|
|
107
|
+
return { ContractFactory, contract };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function deployProxyContract({ saveAddr, verify, contractClass, constructorArgs, initializeArgs }, hre) {
|
|
111
|
+
const ContractFactory = await hre.ethers.getContractFactory(contractClass);
|
|
112
|
+
const contract = await hre.upgrades.deployProxy(ContractFactory, initializeArgs || [], {
|
|
113
|
+
constructorArgs: constructorArgs,
|
|
114
|
+
kind: "uups",
|
|
115
|
+
unsafeAllow: ["delegatecall"],
|
|
116
|
+
});
|
|
117
|
+
if (verify) {
|
|
118
|
+
// From https://ethereum.stackexchange.com/a/119622/79726
|
|
119
|
+
await contract.deployTransaction.wait(6);
|
|
120
|
+
} else {
|
|
121
|
+
await contract.deployed();
|
|
122
|
+
}
|
|
123
|
+
await logContractCreated(hre, contractClass, contract.address);
|
|
124
|
+
saveAddress(saveAddr, contract.address);
|
|
125
|
+
if (verify) await verifyContract(hre, contract, true, constructorArgs);
|
|
126
|
+
return { ContractFactory, contract };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function grantComponentRole(hre, contract, component, role, user) {
|
|
130
|
+
let userAddress;
|
|
131
|
+
if (user === undefined) {
|
|
132
|
+
user = await _getDefaultSigner(hre);
|
|
133
|
+
userAddress = user.address;
|
|
134
|
+
} else {
|
|
135
|
+
userAddress = user;
|
|
136
|
+
}
|
|
137
|
+
const roleHex = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(role));
|
|
138
|
+
const componentAddress = component.address || component;
|
|
139
|
+
const componentRole = await contract.getComponentRole(componentAddress, roleHex);
|
|
140
|
+
if (!(await contract.hasRole(componentRole, userAddress))) {
|
|
141
|
+
await contract.grantComponentRole(componentAddress, roleHex, userAddress);
|
|
142
|
+
console.log(`Role ${role} (${roleHex}) Component ${componentAddress} granted to ${userAddress}`);
|
|
143
|
+
} else {
|
|
144
|
+
console.log(`Role ${role} (${roleHex}) Component ${componentAddress} already granted to ${userAddress}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function grantRole(hre, contract, role, user) {
|
|
149
|
+
let userAddress;
|
|
150
|
+
if (user === undefined) {
|
|
151
|
+
user = await _getDefaultSigner(hre);
|
|
152
|
+
userAddress = user.address;
|
|
153
|
+
} else {
|
|
154
|
+
userAddress = user;
|
|
155
|
+
}
|
|
156
|
+
const roleHex = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(role));
|
|
157
|
+
if (!(await contract.hasRole(roleHex, userAddress))) {
|
|
158
|
+
await contract.grantRole(roleHex, userAddress);
|
|
159
|
+
console.log(`Role ${role} (${roleHex}) granted to ${userAddress}`);
|
|
160
|
+
} else {
|
|
161
|
+
console.log(`Role ${role} (${roleHex}) already granted to ${userAddress}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function grantRoleTask({ contractAddress, role, account, component }, hre) {
|
|
166
|
+
const contract = await hre.ethers.getContractAt("AccessManager", contractAddress);
|
|
167
|
+
if (component === ethers.constants.AddressZero) {
|
|
168
|
+
await grantRole(hre, contract, role, account);
|
|
169
|
+
} else {
|
|
170
|
+
await grantComponentRole(hre, contract, component, role, account);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function deployTestCurrency({ currName, currSymbol, initialSupply, ...opts }, hre) {
|
|
175
|
+
return (
|
|
176
|
+
await deployContract(
|
|
177
|
+
{
|
|
178
|
+
contractClass: "TestCurrency",
|
|
179
|
+
constructorArgs: [currName, currSymbol, _A(initialSupply), amountDecimals()],
|
|
180
|
+
...opts,
|
|
181
|
+
},
|
|
182
|
+
hre
|
|
183
|
+
)
|
|
184
|
+
).contract.address;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function deployAccessManager(opts, hre) {
|
|
188
|
+
return (await deployProxyContract({ contractClass: "AccessManager", ...opts }, hre)).contract.address;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function _getDefaultSigner(hre) {
|
|
192
|
+
const signers = await hre.ethers.getSigners();
|
|
193
|
+
return signers[0];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async function deployPolicyPool({ accessAddress, currencyAddress, nftName, nftSymbol, treasuryAddress, ...opts }, hre) {
|
|
197
|
+
return (
|
|
198
|
+
await deployProxyContract(
|
|
199
|
+
{
|
|
200
|
+
contractClass: "PolicyPool",
|
|
201
|
+
constructorArgs: [accessAddress, currencyAddress],
|
|
202
|
+
initializeArgs: [nftName, nftSymbol, treasuryAddress],
|
|
203
|
+
...opts,
|
|
204
|
+
},
|
|
205
|
+
hre
|
|
206
|
+
)
|
|
207
|
+
).contract.address;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function deployEToken(
|
|
211
|
+
{ poolAddress, etkName, etkSymbol, maxUtilizationRate, poolLoanInterestRate, ...opts },
|
|
212
|
+
hre
|
|
213
|
+
) {
|
|
214
|
+
const { contract } = await deployProxyContract(
|
|
215
|
+
{
|
|
216
|
+
contractClass: "EToken",
|
|
217
|
+
constructorArgs: [poolAddress],
|
|
218
|
+
initializeArgs: [etkName, etkSymbol, _W(maxUtilizationRate), _W(poolLoanInterestRate)],
|
|
219
|
+
...opts,
|
|
220
|
+
},
|
|
221
|
+
hre
|
|
222
|
+
);
|
|
223
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", poolAddress);
|
|
224
|
+
await policyPool.addComponent(contract.address, 1);
|
|
225
|
+
return contract.address;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async function deployPremiumsAccount({ poolAddress, juniorEtk, seniorEtk, ...opts }, hre) {
|
|
229
|
+
const { contract } = await deployProxyContract(
|
|
230
|
+
{
|
|
231
|
+
contractClass: "PremiumsAccount",
|
|
232
|
+
constructorArgs: [poolAddress, juniorEtk, seniorEtk],
|
|
233
|
+
initializeArgs: [],
|
|
234
|
+
...opts,
|
|
235
|
+
},
|
|
236
|
+
hre
|
|
237
|
+
);
|
|
238
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", poolAddress);
|
|
239
|
+
await policyPool.addComponent(contract.address, 3);
|
|
240
|
+
return contract.address;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function deployRiskModule(
|
|
244
|
+
{
|
|
245
|
+
rmClass,
|
|
246
|
+
rmName,
|
|
247
|
+
poolAddress,
|
|
248
|
+
paAddress,
|
|
249
|
+
collRatio,
|
|
250
|
+
jrCollRatio,
|
|
251
|
+
roc,
|
|
252
|
+
jrRoc,
|
|
253
|
+
ensuroPpFee,
|
|
254
|
+
ensuroCocFee,
|
|
255
|
+
maxPayoutPerPolicy,
|
|
256
|
+
exposureLimit,
|
|
257
|
+
maxDuration,
|
|
258
|
+
moc,
|
|
259
|
+
wallet,
|
|
260
|
+
extraArgs,
|
|
261
|
+
extraConstructorArgs,
|
|
262
|
+
...opts
|
|
263
|
+
},
|
|
264
|
+
hre
|
|
265
|
+
) {
|
|
266
|
+
extraArgs = extraArgs || [];
|
|
267
|
+
extraConstructorArgs = extraConstructorArgs || [];
|
|
268
|
+
const { contract } = await deployProxyContract(
|
|
269
|
+
{
|
|
270
|
+
contractClass: rmClass,
|
|
271
|
+
constructorArgs: [poolAddress, paAddress, ...extraConstructorArgs],
|
|
272
|
+
initializeArgs: [
|
|
273
|
+
rmName,
|
|
274
|
+
_W(collRatio),
|
|
275
|
+
_W(ensuroPpFee),
|
|
276
|
+
_W(roc),
|
|
277
|
+
_A(maxPayoutPerPolicy),
|
|
278
|
+
_A(exposureLimit),
|
|
279
|
+
wallet,
|
|
280
|
+
...extraArgs,
|
|
281
|
+
],
|
|
282
|
+
...opts,
|
|
283
|
+
},
|
|
284
|
+
hre
|
|
285
|
+
);
|
|
286
|
+
const rm = contract;
|
|
287
|
+
|
|
288
|
+
if (moc != 1.0) {
|
|
289
|
+
moc = _W(moc);
|
|
290
|
+
await rm.setParam(0, moc);
|
|
291
|
+
}
|
|
292
|
+
if (jrCollRatio != 0.0) {
|
|
293
|
+
jrCollRatio = _W(jrCollRatio);
|
|
294
|
+
await rm.setParam(1, jrCollRatio);
|
|
295
|
+
}
|
|
296
|
+
if (jrRoc != 0.0) {
|
|
297
|
+
jrRoc = _W(jrRoc);
|
|
298
|
+
await rm.setParam(5, jrRoc);
|
|
299
|
+
}
|
|
300
|
+
if (ensuroCocFee != 0) {
|
|
301
|
+
ensuroCocFee = _W(ensuroCocFee);
|
|
302
|
+
await rm.setParam(4, ensuroCocFee);
|
|
303
|
+
}
|
|
304
|
+
if (maxDuration != 24 * 365) {
|
|
305
|
+
await rm.setParam(9, ensuroCocFee);
|
|
306
|
+
}
|
|
307
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", poolAddress);
|
|
308
|
+
await policyPool.addComponent(contract.address, 2);
|
|
309
|
+
return contract.address;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async function deployFlightDelayRM(opts, hre) {
|
|
313
|
+
opts.extraArgs = [opts.linkToken, [opts.oracle, opts.delayTime, _W(opts.oracleFee), opts.dataJobId, opts.sleepJobId]];
|
|
314
|
+
return deployRiskModule(opts, hre);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
async function deployPriceRM(opts, hre) {
|
|
318
|
+
opts.extraConstructorArgs = [opts.assetOracle, opts.referenceOracle, _W(opts.slotSize)];
|
|
319
|
+
opts.extraArgs = [opts.oracleTolerance];
|
|
320
|
+
const rm = await deployRiskModule(opts, hre);
|
|
321
|
+
if (opts.minDuration != 3600) {
|
|
322
|
+
// TODO: we will need ORACLE_ADMIN_ROLE
|
|
323
|
+
await rm.setMinDuration(opts.minDuration);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async function deploySignedQuoteRM(opts, hre) {
|
|
328
|
+
opts.extraConstructorArgs = [opts.creationIsOpen];
|
|
329
|
+
return deployRiskModule(opts, hre);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async function setAssetManager({ reserve, amAddress, liquidityMin, liquidityMiddle, liquidityMax }, hre) {
|
|
333
|
+
const reserveContract = await hre.ethers.getContractAt("Reserve", reserve);
|
|
334
|
+
await reserveContract.setAssetManager(amAddress, false);
|
|
335
|
+
console.log(`Asset Manager ${amAddress} set to reserve ${reserve}`);
|
|
336
|
+
if (liquidityMin !== undefined || liquidityMiddle !== undefined || liquidityMax !== undefined) {
|
|
337
|
+
liquidityMin = liquidityMin === undefined ? ethers.constants.MaxUint256 : _A(liquidityMin);
|
|
338
|
+
liquidityMiddle = liquidityMiddle === undefined ? ethers.constants.MaxUint256 : _A(liquidityMiddle);
|
|
339
|
+
liquidityMax = liquidityMax === undefined ? ethers.constants.MaxUint256 : _A(liquidityMax);
|
|
340
|
+
const amContract = await hre.ethers.getContractAt(
|
|
341
|
+
"ERC4626AssetManager", // Not relevant if it's ERC4626AssetManager, only need setLiquidityThresholds
|
|
342
|
+
amAddress
|
|
343
|
+
);
|
|
344
|
+
await reserveContract.forwardToAssetManager(
|
|
345
|
+
amContract.interface.encodeFunctionData("setLiquidityThresholds", [liquidityMin, liquidityMiddle, liquidityMax])
|
|
346
|
+
);
|
|
347
|
+
console.log(`setLiquidityThresholds(${liquidityMin}, ${liquidityMiddle}, ${liquidityMax}`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async function deployERC4626AssetManager({ asset, vault, amClass, ...opts }, hre) {
|
|
352
|
+
return (
|
|
353
|
+
await deployContract(
|
|
354
|
+
{
|
|
355
|
+
contractClass: amClass,
|
|
356
|
+
constructorArgs: [asset, vault],
|
|
357
|
+
...opts,
|
|
358
|
+
},
|
|
359
|
+
hre
|
|
360
|
+
)
|
|
361
|
+
).contract.address;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async function deployAaveAssetManager({ asset, aave, amClass, ...opts }, hre) {
|
|
365
|
+
return (
|
|
366
|
+
await deployContract(
|
|
367
|
+
{
|
|
368
|
+
contractClass: amClass,
|
|
369
|
+
constructorArgs: [asset, aave],
|
|
370
|
+
...opts,
|
|
371
|
+
},
|
|
372
|
+
hre
|
|
373
|
+
)
|
|
374
|
+
).contract.address;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
async function deployWhitelist(
|
|
378
|
+
{ wlClass, poolAddress, extraConstructorArgs, extraArgs, eToken, eToken2, eToken3, ...opts },
|
|
379
|
+
hre
|
|
380
|
+
) {
|
|
381
|
+
extraArgs = extraArgs || [];
|
|
382
|
+
extraConstructorArgs = extraConstructorArgs || [];
|
|
383
|
+
const { contract } = await deployProxyContract(
|
|
384
|
+
{
|
|
385
|
+
contractClass: wlClass,
|
|
386
|
+
constructorArgs: [poolAddress, ...extraConstructorArgs],
|
|
387
|
+
initializeArgs: [...extraArgs],
|
|
388
|
+
...opts,
|
|
389
|
+
},
|
|
390
|
+
hre
|
|
391
|
+
);
|
|
392
|
+
if (eToken !== undefined) {
|
|
393
|
+
const etk = await hre.ethers.getContractAt("EToken", eToken);
|
|
394
|
+
await etk.setWhitelist(contract.address);
|
|
395
|
+
}
|
|
396
|
+
if (eToken2 !== undefined) {
|
|
397
|
+
const etk = await hre.ethers.getContractAt("EToken", eToken2);
|
|
398
|
+
await etk.setWhitelist(contract.address);
|
|
399
|
+
}
|
|
400
|
+
if (eToken3 !== undefined) {
|
|
401
|
+
const etk = await hre.ethers.getContractAt("EToken", eToken3);
|
|
402
|
+
await etk.setWhitelist(contract.address);
|
|
403
|
+
}
|
|
404
|
+
return contract.address;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
async function trustfullPolicy({ rmAddress, payout, premium, lossProb, expiration, customer }, hre) {
|
|
408
|
+
const rm = await hre.ethers.getContractAt("TrustfulRiskModule", rmAddress);
|
|
409
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", await rm.policyPool());
|
|
410
|
+
const access = await hre.ethers.getContractAt("AccessManager", await policyPool.access());
|
|
411
|
+
const currency = await hre.ethers.getContractAt("IERC20Metadata", await policyPool.currency());
|
|
412
|
+
await grantComponentRole(hre, access, rm, "PRICER_ROLE");
|
|
413
|
+
|
|
414
|
+
customer = customer || (await _getDefaultSigner(hre));
|
|
415
|
+
premium = _A(premium);
|
|
416
|
+
|
|
417
|
+
await currency.approve(policyPool.address, premium);
|
|
418
|
+
lossProb = _W(lossProb);
|
|
419
|
+
if (expiration === undefined) {
|
|
420
|
+
expiration = 3600;
|
|
421
|
+
}
|
|
422
|
+
if (expiration < 1600000000) {
|
|
423
|
+
expiration = Math.round(new Date().getTime() / 1000) + expiration;
|
|
424
|
+
}
|
|
425
|
+
payout = _A(payout);
|
|
426
|
+
|
|
427
|
+
const tx = await rm.newPolicy(payout, premium, lossProb, expiration, customer.address, { gasLimit: 999999 });
|
|
428
|
+
console.log(tx);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async function resolvePolicy({ rmAddress, payout, fullPayout, policyId }, hre) {
|
|
432
|
+
const rm = await hre.ethers.getContractAt("TrustfulRiskModule", rmAddress);
|
|
433
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", await rm.policyPool());
|
|
434
|
+
const access = await hre.ethers.getContractAt("AccessManager", await policyPool.access());
|
|
435
|
+
await grantComponentRole(hre, access, rm, "RESOLVER_ROLE");
|
|
436
|
+
|
|
437
|
+
let tx;
|
|
438
|
+
|
|
439
|
+
if (fullPayout === undefined) {
|
|
440
|
+
payout = _A(payout);
|
|
441
|
+
tx = await rm.resolvePolicy(policyId, payout);
|
|
442
|
+
} else {
|
|
443
|
+
tx = await rm.resolvePolicyFullPayout(policyId, fullPayout);
|
|
444
|
+
}
|
|
445
|
+
console.log(tx);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
async function flightDelayPolicy(
|
|
449
|
+
{ rmAddress, flight, departure, expectedArrival, tolerance, payout, premium, lossProb, customer },
|
|
450
|
+
hre
|
|
451
|
+
) {
|
|
452
|
+
const rm = await hre.ethers.getContractAt("FlightDelayRiskModule", rmAddress);
|
|
453
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", await rm.policyPool());
|
|
454
|
+
const access = await hre.ethers.getContractAt("AccessManager", await policyPool.access());
|
|
455
|
+
const currency = await hre.ethers.getContractAt("IERC20Metadata", await policyPool.currency());
|
|
456
|
+
|
|
457
|
+
await grantComponentRole(hre, access, rm, "PRICER_ROLE");
|
|
458
|
+
customer = customer || (await _getDefaultSigner(hre));
|
|
459
|
+
premium = _A(premium);
|
|
460
|
+
|
|
461
|
+
await currency.approve(policyPool.address, premium);
|
|
462
|
+
lossProb = _W(lossProb);
|
|
463
|
+
payout = _A(payout);
|
|
464
|
+
|
|
465
|
+
const tx = await rm.newPolicy(
|
|
466
|
+
flight,
|
|
467
|
+
departure,
|
|
468
|
+
expectedArrival,
|
|
469
|
+
tolerance,
|
|
470
|
+
payout,
|
|
471
|
+
premium,
|
|
472
|
+
lossProb,
|
|
473
|
+
customer.address,
|
|
474
|
+
{ gasLimit: 999999 }
|
|
475
|
+
);
|
|
476
|
+
console.log(tx);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
async function listETokens({ poolAddress }, hre) {
|
|
480
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", poolAddress);
|
|
481
|
+
const etkCount = await policyPool.getETokenCount();
|
|
482
|
+
|
|
483
|
+
console.log(`Pool has ${etkCount} tokens`);
|
|
484
|
+
|
|
485
|
+
for (i = 0; i < etkCount; i++) {
|
|
486
|
+
const etk = await hre.ethers.getContractAt("EToken", await policyPool.getETokenAt(i));
|
|
487
|
+
const etkName = await etk.name();
|
|
488
|
+
console.log(`eToken at ${etk.address}: ${etkName}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
async function deposit({ etkAddress, amount }, hre) {
|
|
493
|
+
const etk = await hre.ethers.getContractAt("EToken", etkAddress);
|
|
494
|
+
const policyPool = await hre.ethers.getContractAt("PolicyPool", await etk.policyPool());
|
|
495
|
+
const currency = await hre.ethers.getContractAt("IERC20Metadata", await policyPool.currency());
|
|
496
|
+
amount = _A(amount);
|
|
497
|
+
await currency.approve(policyPool.address, amount);
|
|
498
|
+
const tx = await policyPool.deposit(etk.address, amount, { gasLimit: 999999 });
|
|
499
|
+
console.log(tx);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function add_task() {
|
|
503
|
+
task("deploy", "Deploys the PolicyPool and other required contracts")
|
|
504
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
505
|
+
.addOptionalParam("currName", "Name of Test Currency", "Ensuro Test USD", types.str)
|
|
506
|
+
.addOptionalParam("currSymbol", "Symbol of Test Currency", "EUSD", types.str)
|
|
507
|
+
.addOptionalParam("initialSupply", "Initial supply in the test currency", 2000, types.int)
|
|
508
|
+
.addOptionalParam("nftName", "Name of Policies NFT Token", "Ensuro Policies NFT", types.str)
|
|
509
|
+
.addOptionalParam("nftSymbol", "Symbol of Policies NFT Token", "EPOL", types.str)
|
|
510
|
+
.addOptionalParam("currencyAddress", "Currency Address", undefined, types.address)
|
|
511
|
+
.addOptionalParam("accessAddress", "AccessManager Address", undefined, types.address)
|
|
512
|
+
.addParam("treasuryAddress", "Treasury Address", types.address)
|
|
513
|
+
.setAction(async function (taskArgs, hre) {
|
|
514
|
+
if (taskArgs.currencyAddress === undefined) {
|
|
515
|
+
taskArgs.saveAddr = "CURRENCY";
|
|
516
|
+
taskArgs.currencyAddress = await deployTestCurrency(taskArgs, hre);
|
|
517
|
+
}
|
|
518
|
+
if (taskArgs.accessAddress === undefined) {
|
|
519
|
+
taskArgs.saveAddr = "ACCESSMANAGER";
|
|
520
|
+
taskArgs.accessAddress = await deployAccessManager(taskArgs, hre);
|
|
521
|
+
}
|
|
522
|
+
taskArgs.saveAddr = "POOL";
|
|
523
|
+
let policyPoolAddress = await deployPolicyPool(taskArgs, hre);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
task("deploy:testCurrency", "Deploys the Test Currency")
|
|
527
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
528
|
+
.addOptionalParam("saveAddr", "Save created contract address", "CURRENCY", types.str)
|
|
529
|
+
.addOptionalParam("currName", "Name of Test Currency", "Ensuro Test USD", types.str)
|
|
530
|
+
.addOptionalParam("currSymbol", "Symbol of Test Currency", "EUSD", types.str)
|
|
531
|
+
.addOptionalParam("initialSupply", "Initial supply in the test currency", 2000, types.int)
|
|
532
|
+
.setAction(deployTestCurrency);
|
|
533
|
+
|
|
534
|
+
task("deploy:accessManager", "Deploys the AccessManager")
|
|
535
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
536
|
+
.addOptionalParam("saveAddr", "Save created contract address", "ACCESSMANAGER", types.str)
|
|
537
|
+
.setAction(deployAccessManager);
|
|
538
|
+
|
|
539
|
+
task("deploy:pool", "Deploys the PolicyPool")
|
|
540
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
541
|
+
.addOptionalParam("saveAddr", "Save created contract address", "POOL", types.str)
|
|
542
|
+
.addOptionalParam("nftName", "Name of Policies NFT Token", "Ensuro Policies NFT", types.str)
|
|
543
|
+
.addOptionalParam("nftSymbol", "Symbol of Policies NFT Token", "EPOL", types.str)
|
|
544
|
+
.addOptionalParam("treasuryAddress", "Treasury Address", ethers.constants.AddressZero, types.address)
|
|
545
|
+
.addParam("currencyAddress", "Currency Address", types.address)
|
|
546
|
+
.addParam("accessAddress", "AccessManager Address", types.address)
|
|
547
|
+
.setAction(deployPolicyPool);
|
|
548
|
+
|
|
549
|
+
task("deploy:eToken", "Deploy an EToken and adds it to the pool")
|
|
550
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
551
|
+
.addOptionalParam("saveAddr", "Save created contract address", "ETOKEN", types.str)
|
|
552
|
+
.addParam("poolAddress", "PolicyPool Address", types.address)
|
|
553
|
+
.addParam("etkName", "Name of EToken", types.str)
|
|
554
|
+
.addParam("etkSymbol", "Symbol of EToken", types.str)
|
|
555
|
+
.addOptionalParam("maxUtilizationRate", "Max Utilization Rate", 1.0, types.float)
|
|
556
|
+
.addOptionalParam("poolLoanInterestRate", "Interest rate when pool takes money from eToken", 0.05, types.float)
|
|
557
|
+
.setAction(deployEToken);
|
|
558
|
+
|
|
559
|
+
task("deploy:premiumsAccount", "Deploy a premiums account")
|
|
560
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
561
|
+
.addOptionalParam("saveAddr", "Save created contract address", "PA", types.str)
|
|
562
|
+
.addParam("poolAddress", "PolicyPool Address", types.address)
|
|
563
|
+
.addParam("juniorEtk", "Junior EToken Address", types.address)
|
|
564
|
+
.addParam("seniorEtk", "Senior EToken Address", types.address)
|
|
565
|
+
.setAction(deployPremiumsAccount);
|
|
566
|
+
|
|
567
|
+
task("deploy:riskModule", "Deploys a RiskModule and adds it to the pool")
|
|
568
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
569
|
+
.addOptionalParam("saveAddr", "Save created contract address", "RM", types.str)
|
|
570
|
+
.addParam("poolAddress", "PolicyPool Address", types.address)
|
|
571
|
+
.addParam("paAddress", "PremiumsAccount Address", types.address)
|
|
572
|
+
.addOptionalParam("rmClass", "RiskModule contract", "TrustfulRiskModule", types.str)
|
|
573
|
+
.addOptionalParam("rmName", "Name of the RM", "Test RM", types.str)
|
|
574
|
+
.addOptionalParam("collRatio", "Collateralization ratio", 1.0, types.float)
|
|
575
|
+
.addOptionalParam("jrCollRatio", "Junior Collateralization ratio", 0.0, types.float)
|
|
576
|
+
.addOptionalParam("ensuroPpFee", "Ensuro Pure Premium Fee", 0.02, types.float)
|
|
577
|
+
.addOptionalParam("ensuroCocFee", "Ensuro Coc Fee", 0.1, types.float)
|
|
578
|
+
.addOptionalParam("roc", "Interest rate paid to Senior LPs for solvency capital", 0.05, types.float)
|
|
579
|
+
.addOptionalParam("jrRoc", "Interest rate paid to Junior LPs for solvency capital", 0.0, types.float)
|
|
580
|
+
.addOptionalParam("maxPayoutPerPolicy", "Max Payout Per policy", 10000, types.float)
|
|
581
|
+
.addOptionalParam("exposureLimit", "Exposure (sum of payouts) limit for the RM", 1e6, types.float)
|
|
582
|
+
.addOptionalParam("maxDuration", "Maximum policy duration in hours", 24 * 365, types.int)
|
|
583
|
+
.addOptionalParam("moc", "Margin of Conservativism", 1.0, types.float)
|
|
584
|
+
.addParam("wallet", "RM address", types.address)
|
|
585
|
+
.setAction(deployRiskModule);
|
|
586
|
+
|
|
587
|
+
task("deploy:signedQuoteRiskModule", "Deploys a RiskModule and adds it to the pool")
|
|
588
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
589
|
+
.addOptionalParam("saveAddr", "Save created contract address", "RM", types.str)
|
|
590
|
+
.addParam("poolAddress", "PolicyPool Address", types.address)
|
|
591
|
+
.addParam("paAddress", "PremiumsAccount Address", types.address)
|
|
592
|
+
.addOptionalParam("rmClass", "RiskModule contract", "SignedQuoteRiskModule", types.str)
|
|
593
|
+
.addOptionalParam("rmName", "Name of the RM", "Test RM", types.str)
|
|
594
|
+
.addOptionalParam("collRatio", "Collateralization ratio", 1.0, types.float)
|
|
595
|
+
.addOptionalParam("jrCollRatio", "Junior Collateralization ratio", 0.0, types.float)
|
|
596
|
+
.addOptionalParam("ensuroPpFee", "Ensuro Pure Premium Fee", 0.02, types.float)
|
|
597
|
+
.addOptionalParam("ensuroCocFee", "Ensuro Coc Fee", 0.1, types.float)
|
|
598
|
+
.addOptionalParam("roc", "Interest rate paid to Senior LPs for solvency capital", 0.05, types.float)
|
|
599
|
+
.addOptionalParam("jrRoc", "Interest rate paid to Junior LPs for solvency capital", 0.0, types.float)
|
|
600
|
+
.addOptionalParam("maxPayoutPerPolicy", "Max Payout Per policy", 10000, types.float)
|
|
601
|
+
.addOptionalParam("exposureLimit", "Exposure (sum of payouts) limit for the RM", 1e6, types.float)
|
|
602
|
+
.addOptionalParam("maxDuration", "Maximum policy duration in hours", 24 * 365, types.int)
|
|
603
|
+
.addOptionalParam("moc", "Margin of Conservativism", 1.0, types.float)
|
|
604
|
+
.addOptionalParam("creationIsOpen", "Indicates if anyone can create policies (with a quote)", true, types.boolean)
|
|
605
|
+
.addParam("wallet", "RM address", types.address)
|
|
606
|
+
.setAction(deploySignedQuoteRM);
|
|
607
|
+
|
|
608
|
+
task("deploy:priceRiskModule", "Deploys and injects a Price RiskModule")
|
|
609
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
610
|
+
.addOptionalParam("saveAddr", "Save created contract address", "RM", types.str)
|
|
611
|
+
.addParam("poolAddress", "PolicyPool Address", types.address)
|
|
612
|
+
.addParam("paAddress", "PremiumsAccount Address", types.address)
|
|
613
|
+
.addOptionalParam("rmClass", "RiskModule contract", "PriceRiskModule", types.str)
|
|
614
|
+
.addOptionalParam("rmName", "Name of the RM", "Price Risk Module", types.str)
|
|
615
|
+
.addOptionalParam("collRatio", "Collateralization ratio", 1.0, types.float)
|
|
616
|
+
.addOptionalParam("jrCollRatio", "Junior Collateralization ratio", 0.0, types.float)
|
|
617
|
+
.addOptionalParam("ensuroPpFee", "Ensuro Pure Premium Fee", 0.02, types.float)
|
|
618
|
+
.addOptionalParam("ensuroCocFee", "Ensuro Coc Fee", 0.1, types.float)
|
|
619
|
+
.addOptionalParam("roc", "Interest rate paid to Senior LPs for solvency capital", 0.05, types.float)
|
|
620
|
+
.addOptionalParam("jrRoc", "Interest rate paid to Junior LPs for solvency capital", 0.0, types.float)
|
|
621
|
+
.addOptionalParam("maxPayoutPerPolicy", "Max Payout Per policy", 10000, types.float)
|
|
622
|
+
.addOptionalParam("exposureLimit", "Exposure (sum of payouts) limit for the RM", 1e6, types.float)
|
|
623
|
+
.addOptionalParam("maxDuration", "Maximum policy duration in hours", 24 * 365, types.int)
|
|
624
|
+
.addOptionalParam("moc", "Margin of Conservativism", 1.0, types.float)
|
|
625
|
+
.addParam("wallet", "RM address", types.address)
|
|
626
|
+
.addParam("assetOracle", "Insured asset oracle address", types.address)
|
|
627
|
+
.addOptionalParam("referenceOracle", "Reference currency address", ethers.constants.AddressZero, types.address)
|
|
628
|
+
.addOptionalParam("slotSize", "Slot size", 0.01, types.float)
|
|
629
|
+
.addOptionalParam("oracleTolerance", "Oracle age tolerance", 1800, types.int)
|
|
630
|
+
.addOptionalParam("minDuration", "Minimum time that must elapse before a policy can be triggered", 3600, types.int)
|
|
631
|
+
.setAction(deployPriceRM);
|
|
632
|
+
|
|
633
|
+
task("ens:setAssetManager", "Sets an asset manager to a reserve")
|
|
634
|
+
.addParam("reserve", "Reserve Address", types.address)
|
|
635
|
+
.addParam("amAddress", "Address of Asset Manager (reuse one already deployed)", types.address)
|
|
636
|
+
.addOptionalParam("liquidityMin", "liquidityMin", undefined, types.float)
|
|
637
|
+
.addOptionalParam("liquidityMiddle", "liquidityMiddle", undefined, types.float)
|
|
638
|
+
.addOptionalParam("liquidityMax", "liquidityMax", undefined, types.float)
|
|
639
|
+
.setAction(setAssetManager);
|
|
640
|
+
|
|
641
|
+
task("deploy:erc4626AssetManager", "Deploys an ERC4626 AssetManager")
|
|
642
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
643
|
+
.addOptionalParam("saveAddr", "Save created contract address", "ASSETMANAGER", types.str)
|
|
644
|
+
.addParam("asset", "Asset Address", types.address)
|
|
645
|
+
.addParam("vault", "Vault Address", types.address)
|
|
646
|
+
.addOptionalParam("amClass", "AssetManager contract", "ERC4626AssetManager", types.str)
|
|
647
|
+
.setAction(deployERC4626AssetManager);
|
|
648
|
+
|
|
649
|
+
task("deploy:aaveAssetManager", "Deploys a AaveAssetManager")
|
|
650
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
651
|
+
.addOptionalParam("saveAddr", "Save created contract address", "ASSETMANAGER", types.str)
|
|
652
|
+
.addParam("asset", "Asset Address", types.address)
|
|
653
|
+
.addParam("aave", "AAVE LendingPool Address", types.address)
|
|
654
|
+
.addOptionalParam("amClass", "AssetManager contract", "AAVEv3AssetManager", types.str)
|
|
655
|
+
.setAction(deployAaveAssetManager);
|
|
656
|
+
|
|
657
|
+
task("deploy:whitelist", "Deploys a Whitelisting contract")
|
|
658
|
+
.addOptionalParam("verify", "Verify contract in Etherscan", false, types.boolean)
|
|
659
|
+
.addOptionalParam("saveAddr", "Save created contract address", "WHITELIST", types.str)
|
|
660
|
+
.addOptionalParam("wlClass", "Whitelisting contract", "LPManualWhitelist", types.str)
|
|
661
|
+
.addOptionalParam("eToken", "Set the Whitelist to a given eToken", undefined, types.address)
|
|
662
|
+
.addOptionalParam("eToken2", "Set the Whitelist to a given eToken", undefined, types.address)
|
|
663
|
+
.addOptionalParam("eToken3", "Set the Whitelist to a given eToken", undefined, types.address)
|
|
664
|
+
.addParam("poolAddress", "PolicyPool Address", types.address)
|
|
665
|
+
.setAction(deployWhitelist);
|
|
666
|
+
|
|
667
|
+
task("ens:trustfullPolicy", "Creates a TrustfulRiskModule Policy")
|
|
668
|
+
.addParam("rmAddress", "RiskModule address", types.address)
|
|
669
|
+
.addParam("payout", "Payout for customer in case policy is triggered", undefined, types.int)
|
|
670
|
+
.addParam("premium", "Premium the customer pays", undefined, types.int)
|
|
671
|
+
.addParam("lossProb", "Probability of policy being triggered", undefined, types.float)
|
|
672
|
+
.addOptionalParam("expiration", "Expiration of the policy (relative or absolute)", undefined, types.int)
|
|
673
|
+
.addOptionalParam("customer", "Customer", undefined, types.address)
|
|
674
|
+
.setAction(trustfullPolicy);
|
|
675
|
+
|
|
676
|
+
task("ens:resolvePolicy", "Resolves a TrustfulRiskModule Policy")
|
|
677
|
+
.addParam("rmAddress", "RiskModule address", types.address)
|
|
678
|
+
.addParam("policyId", "Id of the policy", undefined, types.int)
|
|
679
|
+
.addOptionalParam("payout", "Payout for customer in case policy is triggered", undefined, types.int)
|
|
680
|
+
.addOptionalParam("fullPayout", "Full payout or not", undefined, types.boolean)
|
|
681
|
+
.setAction(resolvePolicy);
|
|
682
|
+
|
|
683
|
+
task("ens:flightDelayPolicy", "Creates a Flight Delay Policy")
|
|
684
|
+
.addParam("rmAddress", "RiskModule address", types.address)
|
|
685
|
+
.addParam("flight", "Flight Number as String (ex: NAX105)", types.str)
|
|
686
|
+
.addParam("departure", "Departure in epoch seconds (ex: 1631817600)", undefined, types.int)
|
|
687
|
+
.addParam("expectedArrival", "Expected arrival in epoch seconds (ex: 1631824800)", undefined, types.int)
|
|
688
|
+
.addOptionalParam(
|
|
689
|
+
"tolerance",
|
|
690
|
+
"In seconds, the tolerance margin after expectedArrival before trigger the policy",
|
|
691
|
+
12 * 3600,
|
|
692
|
+
types.int
|
|
693
|
+
)
|
|
694
|
+
.addParam("payout", "Payout for customer in case policy is triggered", undefined, types.int)
|
|
695
|
+
.addParam("premium", "Premium the customer pays", undefined, types.int)
|
|
696
|
+
.addParam("lossProb", "Probability of policy being triggered", undefined, types.float)
|
|
697
|
+
.addOptionalParam("customer", "Customer", undefined, types.address)
|
|
698
|
+
.setAction(flightDelayPolicy);
|
|
699
|
+
|
|
700
|
+
task("ens:listETokens", "Lists eTokens")
|
|
701
|
+
.addParam("poolAddress", "PolicyPool Address", types.address)
|
|
702
|
+
.setAction(listETokens);
|
|
703
|
+
|
|
704
|
+
task("ens:deposit", "Deposits in a given eToken")
|
|
705
|
+
.addParam("etkAddress", "EToken address", types.address)
|
|
706
|
+
.addParam("amount", "Amount to Deposit", undefined, types.int)
|
|
707
|
+
.setAction(deposit);
|
|
708
|
+
|
|
709
|
+
task("ens:grantRole", "Grants a given role")
|
|
710
|
+
.addParam("contractAddress", "Contract", undefined, types.address)
|
|
711
|
+
.addParam("role", "Role", types.str)
|
|
712
|
+
.addOptionalParam("account", "Account", undefined, types.address)
|
|
713
|
+
.addOptionalParam(
|
|
714
|
+
"component",
|
|
715
|
+
"Address of the component if it's a component role",
|
|
716
|
+
ethers.constants.AddressZero,
|
|
717
|
+
types.address
|
|
718
|
+
)
|
|
719
|
+
.setAction(grantRoleTask);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
module.exports = {
|
|
723
|
+
add_task,
|
|
724
|
+
saveAddress,
|
|
725
|
+
logContractCreated,
|
|
726
|
+
deployContract,
|
|
727
|
+
deployProxyContract,
|
|
728
|
+
grantRole,
|
|
729
|
+
grantComponentRole,
|
|
730
|
+
deployRiskModule,
|
|
731
|
+
deploySignedQuoteRM,
|
|
732
|
+
setAssetManager,
|
|
733
|
+
deployWhitelist,
|
|
734
|
+
};
|