@ensuro/core 1.2.7 → 2.0.0-beta10

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 (109) hide show
  1. package/README.md +63 -27
  2. package/build/contracts/AccessManager.sol/AccessManager.json +559 -0
  3. package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +219 -0
  4. package/build/contracts/EToken.sol/EToken.json +217 -190
  5. package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +17 -4
  6. package/build/contracts/{extras/IPriceRiskModule.sol/IPriceRiskModule.json → LiquidityThresholdAssetManager.sol/LiquidityThresholdAssetManager.json} +81 -131
  7. package/build/contracts/Policy.sol/Policy.json +2 -2
  8. package/build/contracts/PolicyPool.sol/PolicyPool.json +425 -295
  9. package/build/contracts/PolicyPoolComponent.sol/PolicyPoolComponent.json +15 -2
  10. package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +868 -0
  11. package/build/contracts/{BaseAssetManager.sol/BaseAssetManager.json → Reserve.sol/Reserve.json} +37 -166
  12. package/build/contracts/RiskModule.sol/RiskModule.json +85 -312
  13. package/build/contracts/SignedQuoteRiskModule.sol/SignedQuoteRiskModule.json +960 -0
  14. package/build/contracts/{DataTypes.sol/DataTypes.json → TimeScaled.sol/TimeScaled.json} +4 -4
  15. package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +134 -336
  16. package/build/contracts/dependencies/ERC1967Proxy.sol/ERC1967Proxy.json +64 -0
  17. package/build/{interfaces/IExchange.sol/IExchange.json → contracts/dependencies/IERC20Metadata.sol/IERC20Metadata.json} +83 -79
  18. package/build/contracts/{WadRayMath.sol → dependencies/WadRayMath.sol}/WadRayMath.json +3 -3
  19. package/build/{interfaces/IPolicyPoolConfig.sol/IPolicyPoolConfig.json → contracts/interfaces/IAccessManager.sol/IAccessManager.json} +79 -77
  20. package/build/contracts/interfaces/IAssetManager.sol/IAssetManager.json +109 -0
  21. package/build/{interfaces → contracts/interfaces}/IEToken.sol/IEToken.json +39 -91
  22. package/build/{interfaces → contracts/interfaces}/ILPWhitelist.sol/ILPWhitelist.json +1 -1
  23. package/build/{interfaces → contracts/interfaces}/IPolicyHolder.sol/IPolicyHolder.json +1 -1
  24. package/build/{interfaces → contracts/interfaces}/IPolicyPool.sol/IPolicyPool.json +137 -100
  25. package/build/{interfaces → contracts/interfaces}/IPolicyPoolComponent.sol/IPolicyPoolComponent.json +1 -1
  26. package/build/contracts/interfaces/IPremiumsAccount.sol/IPremiumsAccount.json +315 -0
  27. package/build/{interfaces → contracts/interfaces}/IRiskModule.sol/IRiskModule.json +58 -34
  28. package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +736 -0
  29. package/build/contracts/mocks/ForwardProxy.sol/ForwardProxy.json +43 -0
  30. package/build/{interfaces/IInsolvencyHook.sol/IInsolvencyHook.json → contracts/mocks/IMintableERC20.sol/IMintableERC20.json} +13 -8
  31. package/build/contracts/mocks/PolicyHolderMock.sol/PolicyHolderMock.json +228 -0
  32. package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +35 -0
  33. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +702 -0
  34. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +92 -0
  35. package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +764 -0
  36. package/build/contracts/mocks/TestCurrency.sol/TestCurrency.json +343 -0
  37. package/build/contracts/mocks/TestNFT.sol/TestNFT.json +388 -0
  38. package/contracts/AccessManager.sol +103 -0
  39. package/contracts/ERC4626AssetManager.sol +52 -0
  40. package/contracts/EToken.sol +254 -299
  41. package/contracts/LPManualWhitelist.sol +4 -4
  42. package/contracts/LiquidityThresholdAssetManager.sol +160 -0
  43. package/contracts/Policy.sol +49 -45
  44. package/contracts/PolicyPool.sol +379 -514
  45. package/contracts/PolicyPoolComponent.sol +41 -41
  46. package/contracts/PremiumsAccount.sol +480 -0
  47. package/contracts/Reserve.sol +213 -0
  48. package/contracts/RiskModule.sol +233 -174
  49. package/contracts/SignedQuoteRiskModule.sol +241 -0
  50. package/contracts/TimeScaled.sol +138 -0
  51. package/contracts/TrustfulRiskModule.sol +85 -23
  52. package/contracts/dependencies/ERC1967Proxy.sol +19 -0
  53. package/contracts/dependencies/IERC20Metadata.sol +19 -0
  54. package/contracts/dependencies/WadRayMath.sol +126 -0
  55. package/contracts/interfaces/IAccessManager.sol +148 -0
  56. package/contracts/interfaces/IAssetManager.sol +84 -0
  57. package/contracts/interfaces/IEToken.sol +195 -0
  58. package/contracts/interfaces/ILPWhitelist.sol +40 -0
  59. package/{interfaces → contracts/interfaces}/IPolicyHolder.sol +0 -0
  60. package/contracts/interfaces/IPolicyPool.sol +145 -0
  61. package/{interfaces → contracts/interfaces}/IPolicyPoolComponent.sol +3 -0
  62. package/contracts/interfaces/IPremiumsAccount.sol +76 -0
  63. package/contracts/interfaces/IRiskModule.sol +123 -0
  64. package/contracts/mocks/FixedRateVault.sol +85 -0
  65. package/contracts/mocks/ForwardProxy.sol +66 -0
  66. package/contracts/mocks/IMintableERC20.sol +13 -0
  67. package/contracts/mocks/PolicyHolderMock.sol +89 -0
  68. package/contracts/mocks/PolicyPoolComponentMock.sol +17 -0
  69. package/contracts/mocks/PolicyPoolMock.sol +148 -0
  70. package/contracts/mocks/RiskModuleMock.sol +75 -0
  71. package/contracts/mocks/TestCurrency.sol +35 -0
  72. package/contracts/mocks/TestNFT.sol +23 -0
  73. package/js/test-utils.js +356 -0
  74. package/package.json +2 -2
  75. package/build/contracts/AaveAssetManager.sol/AaveAssetManager.json +0 -742
  76. package/build/contracts/Exchange.sol/Exchange.json +0 -591
  77. package/build/contracts/FlightDelayRiskModule.sol/FlightDelayRiskModule.json +0 -1112
  78. package/build/contracts/PolicyNFT.sol/PolicyNFT.json +0 -570
  79. package/build/contracts/PolicyPoolConfig.sol/PolicyPoolConfig.json +0 -686
  80. package/build/contracts/dependencies/ChainlinkClientUpgradeable.sol/ChainlinkClientUpgradeable.json +0 -50
  81. package/build/contracts/extras/PriceRiskModule.sol/PriceRiskModule.json +0 -1055
  82. package/build/contracts/upgraded/IPolicyNFTv1.sol/IPolicyNFTv1.json +0 -322
  83. package/build/contracts/upgraded/PolicyNFTv1.sol/PolicyNFTv1.json +0 -571
  84. package/build/contracts/upgraded/PolicyNFTv1.sol/PolicyNFTv1_Upgrade.json +0 -602
  85. package/build/interfaces/IAssetManager.sol/IAssetManager.json +0 -31
  86. package/build/interfaces/IExchange.sol/IPriceOracle.json +0 -30
  87. package/build/interfaces/IPolicyNFT.sol/IPolicyNFT.json +0 -321
  88. package/contracts/AaveAssetManager.sol +0 -298
  89. package/contracts/BaseAssetManager.sol +0 -301
  90. package/contracts/DataTypes.sol +0 -287
  91. package/contracts/Exchange.sol +0 -189
  92. package/contracts/FlightDelayRiskModule.sol +0 -208
  93. package/contracts/PolicyNFT.sol +0 -96
  94. package/contracts/PolicyPoolConfig.sol +0 -247
  95. package/contracts/WadRayMath.sol +0 -135
  96. package/contracts/dependencies/ChainlinkClientUpgradeable.sol +0 -371
  97. package/contracts/extras/IPriceRiskModule.sol +0 -41
  98. package/contracts/extras/PriceRiskModule.sol +0 -243
  99. package/contracts/upgraded/IPolicyNFTv1.sol +0 -15
  100. package/contracts/upgraded/PolicyNFTv1.sol +0 -126
  101. package/interfaces/IAssetManager.sol +0 -23
  102. package/interfaces/IEToken.sol +0 -48
  103. package/interfaces/IExchange.sol +0 -59
  104. package/interfaces/IInsolvencyHook.sol +0 -27
  105. package/interfaces/ILPWhitelist.sol +0 -23
  106. package/interfaces/IPolicyNFT.sol +0 -15
  107. package/interfaces/IPolicyPool.sol +0 -44
  108. package/interfaces/IPolicyPoolConfig.sol +0 -87
  109. package/interfaces/IRiskModule.sol +0 -29
@@ -0,0 +1,35 @@
1
+ //SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import {IMintableERC20} from "./IMintableERC20.sol";
6
+
7
+ contract TestCurrency is ERC20, IMintableERC20 {
8
+ address private _owner;
9
+ uint8 internal immutable _decimals;
10
+
11
+ constructor(
12
+ string memory name_,
13
+ string memory symbol_,
14
+ uint256 initialSupply,
15
+ uint8 decimals_
16
+ ) ERC20(name_, symbol_) {
17
+ _owner = msg.sender;
18
+ _decimals = decimals_;
19
+ _mint(msg.sender, initialSupply);
20
+ }
21
+
22
+ function decimals() public view virtual override returns (uint8) {
23
+ return _decimals;
24
+ }
25
+
26
+ function mint(address recipient, uint256 amount) external override {
27
+ // require(msg.sender == _owner, "Only owner can mint");
28
+ return _mint(recipient, amount);
29
+ }
30
+
31
+ function burn(address recipient, uint256 amount) external override {
32
+ // require(msg.sender == _owner, "Only owner can burn");
33
+ return _burn(recipient, amount);
34
+ }
35
+ }
@@ -0,0 +1,23 @@
1
+ //SPDX-License-Identifier: Unlicense
2
+ pragma solidity ^0.8.0;
3
+ pragma experimental ABIEncoderV2;
4
+
5
+ import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
6
+
7
+ contract TestNFT is ERC721 {
8
+ address private _owner;
9
+
10
+ constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {
11
+ _owner = msg.sender;
12
+ }
13
+
14
+ function mint(address recipient, uint256 tokenId) public {
15
+ // require(msg.sender == _owner, "Only owner can mint");
16
+ return _mint(recipient, tokenId);
17
+ }
18
+
19
+ function burn(uint256 tokenId) public {
20
+ require(ERC721.ownerOf(tokenId) == msg.sender, "ERC721: burn of token that is not own");
21
+ return _burn(tokenId);
22
+ }
23
+ }
@@ -0,0 +1,356 @@
1
+ const { expect } = require("chai");
2
+ const hre = require("hardhat");
3
+ const { BigNumber } = require("ethers");
4
+ const { LogDescription } = require("ethers/lib/utils");
5
+ exports.WEEK = 3600 * 24 * 7;
6
+ exports.DAY = 3600 * 24;
7
+
8
+ exports.initCurrency = async function (options, initial_targets, initial_balances) {
9
+ const Currency = await hre.ethers.getContractFactory("TestCurrency");
10
+ let currency = await Currency.deploy(
11
+ options.name || "Test Currency",
12
+ options.symbol || "TEST",
13
+ options.initial_supply,
14
+ options.decimals || 18
15
+ );
16
+ initial_targets = initial_targets || [];
17
+ await Promise.all(
18
+ initial_targets.map(async function (user, index) {
19
+ await currency.transfer(user.address, initial_balances[index]);
20
+ })
21
+ );
22
+ return currency;
23
+ };
24
+
25
+ exports.approve_multiple = async function (currency, spender, sources, amounts) {
26
+ return Promise.all(
27
+ sources.map(async function (source, index) {
28
+ await currency.connect(source).approve(spender.address, amounts[index]);
29
+ })
30
+ );
31
+ };
32
+
33
+ exports.check_balances = async function (currency, users, amounts) {
34
+ return Promise.all(
35
+ users.map(async function (user, index) {
36
+ expect(await currency.balanceOf(user.address)).to.equal(amounts[index]);
37
+ })
38
+ );
39
+ };
40
+
41
+ exports.now = function () {
42
+ return Math.floor(new Date().getTime() / 1000);
43
+ };
44
+
45
+ exports.addRiskModule = async function (
46
+ pool,
47
+ premiumsAccount,
48
+ contractFactory,
49
+ {
50
+ rmName,
51
+ scrPercentage,
52
+ scrInterestRate,
53
+ ensuroFee,
54
+ maxScrPerPolicy,
55
+ scrLimit,
56
+ moc,
57
+ wallet,
58
+ extraArgs,
59
+ extraConstructorArgs,
60
+ }
61
+ ) {
62
+ extraArgs = extraArgs || [];
63
+ extraConstructorArgs = extraConstructorArgs || [];
64
+ const _A = pool._A || _W;
65
+ const rm = await hre.upgrades.deployProxy(
66
+ contractFactory,
67
+ [
68
+ rmName || "RiskModule",
69
+ _W(scrPercentage) || _W(1),
70
+ _W(ensuroFee) || _W(0),
71
+ _W(scrInterestRate) || _W(0.1),
72
+ _A(maxScrPerPolicy) || _A(1000),
73
+ _A(scrLimit) || _A(1000000),
74
+ wallet || "0xdD2FD4581271e230360230F9337D5c0430Bf44C0", // Random address
75
+ ...extraArgs,
76
+ ],
77
+ {
78
+ kind: "uups",
79
+ unsafeAllow: ["delegatecall"],
80
+ constructorArgs: [pool.address, premiumsAccount.address, ...extraConstructorArgs],
81
+ }
82
+ );
83
+
84
+ await rm.deployed();
85
+
86
+ if (moc !== undefined && moc != 1.0) {
87
+ moc = _W(moc);
88
+ await rm.setParam(0, moc);
89
+ }
90
+ await pool.addComponent(rm.address, 2);
91
+ return rm;
92
+ };
93
+
94
+ exports.addEToken = async function (
95
+ pool,
96
+ { etkName, etkSymbol, maxUtilizationRate, poolLoanInterestRate, extraArgs, extraConstructorArgs }
97
+ ) {
98
+ const EToken = await hre.ethers.getContractFactory("EToken");
99
+ extraArgs = extraArgs || [];
100
+ extraConstructorArgs = extraConstructorArgs || [];
101
+ const etk = await hre.upgrades.deployProxy(
102
+ EToken,
103
+ [
104
+ etkName || "EToken",
105
+ etkSymbol || "eUSD1YEAR",
106
+ _W(maxUtilizationRate) || _W(1),
107
+ _W(poolLoanInterestRate) || _W("0.05"),
108
+ ...extraArgs,
109
+ ],
110
+ {
111
+ kind: "uups",
112
+ unsafeAllow: ["delegatecall"],
113
+ constructorArgs: [pool.address, ...extraConstructorArgs],
114
+ }
115
+ );
116
+
117
+ await etk.deployed();
118
+ await pool.addComponent(etk.address, 1);
119
+ return etk;
120
+ };
121
+
122
+ exports.expected_change = async function (protocol_attribute, initial, change) {
123
+ change = BigNumber.from(change);
124
+ let actual_value = await protocol_attribute();
125
+ expect(actual_value.sub(initial)).to.equal(change);
126
+ return actual_value;
127
+ };
128
+
129
+ exports.impersonate = async function (address, setBalanceTo) {
130
+ const ok = await hre.network.provider.request({ method: "hardhat_impersonateAccount", params: [address] });
131
+ if (!ok) throw "Error impersonatting " + address;
132
+
133
+ if (setBalanceTo !== undefined)
134
+ await hre.network.provider.request({ method: "hardhat_setBalance", params: [address, setBalanceTo.toHexString()] });
135
+
136
+ return await hre.ethers.getSigner(address);
137
+ };
138
+
139
+ /**
140
+ * Finds an event in the receipt
141
+ * @param {Interface} interface The interface of the contract that contains the requested event
142
+ * @param {TransactionReceipt} receipt Transaction receipt containing the events in the logs
143
+ * @param {String} eventName The name of the event we are interested in
144
+ * @returns {LogDescription}
145
+ */
146
+ const getTransactionEvent = function (interface, receipt, eventName) {
147
+ // for each log in the transaction receipt
148
+ for (const log of receipt.events) {
149
+ let parsedLog;
150
+ try {
151
+ parsedLog = interface.parseLog(log);
152
+ } catch (error) {
153
+ continue;
154
+ }
155
+ if (parsedLog.name == eventName) {
156
+ return parsedLog;
157
+ }
158
+ }
159
+ return null; // not found
160
+ };
161
+
162
+ exports.getTransactionEvent = getTransactionEvent;
163
+
164
+ exports.deployPool = async function (hre, options) {
165
+ const PolicyPool = await hre.ethers.getContractFactory("PolicyPool");
166
+ const AccessManager = await hre.ethers.getContractFactory("AccessManager");
167
+
168
+ // Deploy AccessManager
169
+ const accessManager = await hre.upgrades.deployProxy(AccessManager, [], { kind: "uups" });
170
+
171
+ await accessManager.deployed();
172
+
173
+ const policyPool = await hre.upgrades.deployProxy(
174
+ PolicyPool,
175
+ [
176
+ options.nftName || "Policy NFT",
177
+ options.nftSymbol || "EPOL",
178
+ options.treasuryAddress || hre.ethers.constants.AddressZero,
179
+ ],
180
+ {
181
+ constructorArgs: [accessManager.address, options.currency],
182
+ kind: "uups",
183
+ unsafeAllow: ["delegatecall"],
184
+ }
185
+ );
186
+
187
+ await policyPool.deployed();
188
+
189
+ for (const role of options.grantRoles || []) {
190
+ await grantRole(hre, accessManager, role);
191
+ }
192
+
193
+ await grantRole(hre, accessManager, "LEVEL1_ROLE");
194
+ await grantRole(hre, accessManager, "LEVEL2_ROLE");
195
+ await grantRole(hre, accessManager, "LEVEL3_ROLE");
196
+ return policyPool;
197
+ };
198
+
199
+ exports.deployPremiumsAccount = async function (hre, pool, options, addToPool = true) {
200
+ const PremiumsAccount = await hre.ethers.getContractFactory("PremiumsAccount");
201
+ const premiumsAccount = await hre.upgrades.deployProxy(PremiumsAccount, [], {
202
+ constructorArgs: [
203
+ pool.address,
204
+ options.jrEtkAddr || hre.ethers.constants.AddressZero,
205
+ options.srEtkAddr || hre.ethers.constants.AddressZero,
206
+ ],
207
+ kind: "uups",
208
+ unsafeAllow: ["delegatecall"],
209
+ });
210
+
211
+ await premiumsAccount.deployed();
212
+
213
+ if (addToPool) await pool.addComponent(premiumsAccount.address, 3);
214
+
215
+ return premiumsAccount;
216
+ };
217
+
218
+ async function _getDefaultSigner(hre) {
219
+ const signers = await hre.ethers.getSigners();
220
+ return signers[0];
221
+ }
222
+
223
+ async function grantRole(hre, contract, role, user) {
224
+ let userAddress;
225
+ if (user === undefined) {
226
+ user = await _getDefaultSigner(hre);
227
+ userAddress = user.address;
228
+ } else {
229
+ userAddress = user;
230
+ }
231
+ if (!(await contract.hasRole(getRole(role), userAddress))) {
232
+ await contract.grantRole(getRole(role), userAddress);
233
+ }
234
+ }
235
+
236
+ exports.grantRole = grantRole;
237
+
238
+ async function grantComponentRole(hre, accessManager, component, role, user) {
239
+ let userAddress;
240
+ if (user === undefined) {
241
+ user = await _getDefaultSigner(hre);
242
+ userAddress = user.address;
243
+ } else {
244
+ userAddress = user.address === undefined ? user : user.address;
245
+ }
246
+ const componentRole = getComponentRole(component.address, getRole(role));
247
+ if (!(await accessManager.hasRole(componentRole, userAddress))) {
248
+ await accessManager.grantComponentRole(component.address, getRole(role), userAddress);
249
+ }
250
+ }
251
+
252
+ exports.grantComponentRole = grantComponentRole;
253
+
254
+ exports._E = hre.ethers.utils.parseEther;
255
+
256
+ const _BN = hre.ethers.BigNumber.from;
257
+ const WAD = _BN(1e10).mul(_BN(1e8)); // 1e10*1e8=1e18
258
+ const RAY = WAD.mul(_BN(1e9)); // 1e18*1e9=1e27
259
+
260
+ exports._BN = _BN;
261
+
262
+ const _W = function (value) {
263
+ if (value === undefined) return undefined;
264
+ if (!Number.isInteger(value)) return _BN(Math.round(value * 1e9)).mul(_BN(1e9));
265
+ return _BN(value).mul(WAD);
266
+ };
267
+
268
+ exports._W = _W;
269
+
270
+ const _R = function (value) {
271
+ if (value === undefined) return undefined;
272
+ if (!Number.isInteger(value)) return _BN(Math.round(value * 1e9)).mul(WAD);
273
+ return _BN(value).mul(RAY);
274
+ };
275
+
276
+ exports._R = _R;
277
+
278
+ exports.amountFunction = function (decimals) {
279
+ // Decimals must be at least 6
280
+ return function (value) {
281
+ if (value === undefined) return undefined;
282
+ if (typeof value === "string" || value instanceof String) {
283
+ return _BN(value).mul(_BN(Math.pow(10, decimals)));
284
+ } else {
285
+ return _BN(Math.round(value * 1e6)).mul(_BN(Math.pow(10, decimals - 6)));
286
+ }
287
+ };
288
+ };
289
+
290
+ /**
291
+ * Builds the component role identifier
292
+ *
293
+ * Mimics the behaviour of the PolicyPoolConfig.getComponentRole method
294
+ *
295
+ * Component roles are roles created doing XOR between the component
296
+ * address and the original role.
297
+ *
298
+ * Example:
299
+ * getComponentRole("0xc6e7DF5E7b4f2A278906862b61205850344D4e7d", "ORACLE_ADMIN_ROLE")
300
+ * // "0x05e01b185238b49f750d03d945e38a7f6c3be8b54de0ee42d481eb7814f0d3a8"
301
+ */
302
+ function getComponentRole(componentAddress, roleName) {
303
+ // 32 byte array
304
+ const bytesRole = hre.ethers.utils.arrayify(getRole(roleName));
305
+
306
+ // 20 byte array
307
+ const bytesAddress = hre.ethers.utils.arrayify(componentAddress);
308
+
309
+ // xor each byte, padding bytesAddress with zeros at the end
310
+ return hre.ethers.utils.hexlify(bytesRole.map((elem, idx) => elem ^ (bytesAddress[idx] || 0)));
311
+ }
312
+
313
+ exports.getComponentRole = getComponentRole;
314
+
315
+ /*
316
+ Builds AccessControl error message for comparison in tests
317
+ */
318
+ function accessControlMessage(address, component, role) {
319
+ const roleHash = component !== null ? getComponentRole(component, role) : getRole(role);
320
+
321
+ return `AccessControl: account ${address.toLowerCase()} is missing role ${roleHash}`;
322
+ }
323
+
324
+ exports.accessControlMessage = accessControlMessage;
325
+
326
+ function makePolicyId(rm, internalId) {
327
+ return hre.ethers.BigNumber.from(rm.address).shl(96).add(internalId);
328
+ }
329
+
330
+ exports.makePolicyId = makePolicyId;
331
+
332
+ async function makePolicy(pool, rm, cust, payout, premium, lossProb, expiration, internalId) {
333
+ let tx = await rm.connect(cust).newPolicy(payout, premium, lossProb, expiration, cust.address, internalId);
334
+ let receipt = await tx.wait();
335
+ const newPolicyEvt = getTransactionEvent(pool.interface, receipt, "NewPolicy");
336
+
337
+ return newPolicyEvt;
338
+ }
339
+
340
+ exports.makePolicy = makePolicy;
341
+
342
+ async function blockchainNow(owner) {
343
+ return (await owner.provider.getBlock("latest")).timestamp;
344
+ }
345
+
346
+ exports.blockchainNow = blockchainNow;
347
+
348
+ function getRole(role) {
349
+ return role === "DEFAULT_ADMIN_ROLE"
350
+ ? "0x0000000000000000000000000000000000000000000000000000000000000000"
351
+ : hre.ethers.utils.keccak256(hre.ethers.utils.toUtf8Bytes(role));
352
+ }
353
+
354
+ exports.getRole = getRole;
355
+
356
+ if (process.env.ENABLE_HH_WARNINGS !== "yes") hre.upgrades.silenceWarnings();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ensuro/core",
3
3
  "description": "Ensuro - Decentralized insurance protocol",
4
- "version": "1.2.7",
4
+ "version": "2.0.0-beta10",
5
5
  "files": [
6
6
  "**/*.sol",
7
7
  "/build/contracts/*.json",
8
8
  "/build/interfaces/*.json",
9
- "!/mocks/**/*"
9
+ "/js/*.js"
10
10
  ],
11
11
  "repository": {
12
12
  "type": "git",