@ensuro/core 2.2.1 → 2.4.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.
Files changed (29) hide show
  1. package/build/contracts/AccessManager.sol/AccessManager.json +2 -2
  2. package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +2 -2
  3. package/build/contracts/EToken.sol/EToken.json +2 -2
  4. package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +2 -2
  5. package/build/contracts/Policy.sol/Policy.json +2 -2
  6. package/build/contracts/PolicyPool.sol/PolicyPool.json +2 -2
  7. package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +41 -2
  8. package/build/contracts/SignedQuoteRiskModule.sol/SignedQuoteRiskModule.json +2 -2
  9. package/build/contracts/TieredSignedQuoteRiskModule.sol/TieredSignedQuoteRiskModule.json +1316 -0
  10. package/build/contracts/TimeScaled.sol/TimeScaled.json +2 -2
  11. package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +2 -2
  12. package/build/contracts/migration/LPManualWhitelistV20Upgraded.sol/LPManualWhitelistV20Upgraded.json +2 -2
  13. package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +6 -6
  14. package/build/contracts/mocks/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +2 -2
  15. package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +2 -2
  16. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +2 -2
  17. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +2 -2
  18. package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +2 -2
  19. package/build/contracts/mocks/TestCurrency.sol/TestCurrency.json +2 -2
  20. package/build/contracts/mocks/TestNFT.sol/TestNFT.json +2 -2
  21. package/contracts/PolicyPool.sol +3 -2
  22. package/contracts/PremiumsAccount.sol +61 -56
  23. package/contracts/RiskModule.sol +5 -38
  24. package/contracts/SignedQuoteRiskModule.sol +3 -3
  25. package/contracts/TieredSignedQuoteRiskModule.sol +165 -0
  26. package/contracts/TrustfulRiskModule.sol +7 -2
  27. package/js/deploy.js +31 -7
  28. package/js/test-utils.js +41 -29
  29. package/package.json +1 -1
package/js/test-utils.js CHANGED
@@ -41,6 +41,19 @@ async function check_balances(currency, users, amounts) {
41
41
  );
42
42
  }
43
43
 
44
+ const RiskModuleParameter = {
45
+ moc: 0,
46
+ jrCollRatio: 1,
47
+ collRatio: 2,
48
+ ensuroPpFee: 3,
49
+ ensuroCocFee: 4,
50
+ jrRoc: 5,
51
+ srRoc: 6,
52
+ maxPayoutPerPolicy: 7,
53
+ exposureLimit: 8,
54
+ maxDuration: 9,
55
+ };
56
+
44
57
  const createRiskModule = async function (
45
58
  pool,
46
59
  premiumsAccount,
@@ -75,7 +88,6 @@ const createRiskModule = async function (
75
88
  ],
76
89
  {
77
90
  kind: "uups",
78
- unsafeAllow: ["delegatecall"],
79
91
  constructorArgs: [pool.address, premiumsAccount.address, ...extraConstructorArgs],
80
92
  }
81
93
  );
@@ -84,7 +96,7 @@ const createRiskModule = async function (
84
96
 
85
97
  if (moc !== undefined && moc != 1.0) {
86
98
  moc = _W(moc);
87
- await rm.setParam(0, moc);
99
+ await rm.setParam(RiskModuleParameter.moc, moc);
88
100
  }
89
101
  return rm;
90
102
  };
@@ -141,7 +153,7 @@ const createEToken = async function (
141
153
  ],
142
154
  {
143
155
  kind: "uups",
144
- unsafeAllow: ["delegatecall"],
156
+ unsafeAllow: ["delegatecall"], // This holds, because EToken is a reserve and uses delegatecall
145
157
  constructorArgs: [pool.address, ...extraConstructorArgs],
146
158
  }
147
159
  );
@@ -236,7 +248,6 @@ async function deployPool(hre, options) {
236
248
  {
237
249
  constructorArgs: [accessManager.address, options.currency],
238
250
  kind: "uups",
239
- unsafeAllow: ["delegatecall"],
240
251
  }
241
252
  );
242
253
 
@@ -264,7 +275,7 @@ async function deployPremiumsAccount(hre, pool, options, addToPool = true) {
264
275
  options.srEtkAddr || hre.ethers.constants.AddressZero,
265
276
  ],
266
277
  kind: "uups",
267
- unsafeAllow: ["delegatecall"],
278
+ unsafeAllow: ["delegatecall"], // This holds, because EToken is a reserve and uses delegatecall
268
279
  });
269
280
 
270
281
  await premiumsAccount.deployed();
@@ -424,34 +435,35 @@ async function makeSignedQuote(signer, policyParams) {
424
435
  if (process.env.ENABLE_HH_WARNINGS !== "yes") hre.upgrades.silenceWarnings();
425
436
 
426
437
  module.exports = {
427
- getStorageLayout,
428
- makeQuoteMessage,
429
- makeSignedQuote,
430
- getRole,
431
- WEEK,
432
- DAY,
433
- createRiskModule,
434
- createEToken,
435
- grantRole,
436
- grantComponentRole,
437
- initCurrency,
438
+ _BN,
439
+ _E,
440
+ _R,
441
+ _W,
442
+ accessControlMessage,
443
+ addEToken,
444
+ addRiskModule,
445
+ amountFunction,
438
446
  approve_multiple,
439
447
  check_balances,
440
- addRiskModule,
441
- addEToken,
442
- expected_change,
443
- getTransactionEvent,
448
+ createEToken,
449
+ createRiskModule,
450
+ DAY,
444
451
  deployPool,
445
452
  deployPremiumsAccount,
446
- _E,
447
- _BN,
448
- WAD,
449
- RAY,
450
- amountFunction,
451
- _W,
452
- _R,
453
+ expected_change,
453
454
  getComponentRole,
454
- accessControlMessage,
455
- makePolicyId,
455
+ getRole,
456
+ getStorageLayout,
457
+ getTransactionEvent,
458
+ grantComponentRole,
459
+ grantRole,
460
+ initCurrency,
456
461
  makePolicy,
462
+ makePolicyId,
463
+ makeQuoteMessage,
464
+ makeSignedQuote,
465
+ RAY,
466
+ RiskModuleParameter,
467
+ WAD,
468
+ WEEK,
457
469
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ensuro/core",
3
3
  "description": "Ensuro - Decentralized insurance protocol",
4
- "version": "2.2.1",
4
+ "version": "2.4.0",
5
5
  "files": [
6
6
  "**/*.sol",
7
7
  "/build/contracts/*.json",