@ensuro/core 2.0.1 → 2.1.0-beta1

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.
@@ -37,4 +37,18 @@ interface ILPWhitelist {
37
37
  address providerTo,
38
38
  uint256 amount
39
39
  ) external view returns (bool);
40
+
41
+ /**
42
+ * @dev Indicates whether or not a liquidity provider can withdraw an eToken.
43
+ *
44
+ * @param etoken The eToken (see {EToken}) where the provider wants to withdraw money.
45
+ * @param provider The address of the liquidity provider (user) that wants to withdraw
46
+ * @param amount The amount of the withdrawal
47
+ * @return true if `provider` withdraw request is accepted, false if not
48
+ */
49
+ function acceptsWithdrawal(
50
+ IEToken etoken,
51
+ address provider,
52
+ uint256 amount
53
+ ) external view returns (bool);
40
54
  }
package/js/deploy.js CHANGED
@@ -7,6 +7,12 @@ const _BN = ethers.BigNumber.from;
7
7
  const WAD = _BN(1e10).mul(_BN(1e8)); // 1e10*1e8=1e18
8
8
  const RAY = WAD.mul(_BN(1e9)); // 1e18*1e9=1e27
9
9
 
10
+ const WhitelistStatus = {
11
+ notdefined: 0,
12
+ whitelisted: 1,
13
+ blacklisted: 2,
14
+ };
15
+
10
16
  /**
11
17
  * Creates a fixed-point conversion function for the desired number of decimals
12
18
  * @param decimals The number of decimals. Must be >= 6.
@@ -153,10 +159,8 @@ async function deployProxyContract({ saveAddr, verify, contractClass, constructo
153
159
  }
154
160
 
155
161
  function parseRole(role) {
156
- if (role.startsWith("0x"))
157
- return role;
158
- if (role === "DEFAULT_ADMIN_ROLE")
159
- return ethers.constants.HashZero;
162
+ if (role.startsWith("0x")) return role;
163
+ if (role === "DEFAULT_ADMIN_ROLE") return ethers.constants.HashZero;
160
164
  return ethers.utils.keccak256(ethers.utils.toUtf8Bytes(role));
161
165
  }
162
166
 
@@ -255,8 +259,7 @@ async function deployEToken(
255
259
  hre
256
260
  );
257
261
  const policyPool = await hre.ethers.getContractAt("PolicyPool", poolAddress);
258
- if (opts.addComponent)
259
- await policyPool.addComponent(contract.address, 1);
262
+ if (opts.addComponent) await policyPool.addComponent(contract.address, 1);
260
263
  return contract.address;
261
264
  }
262
265
 
@@ -271,8 +274,7 @@ async function deployPremiumsAccount({ poolAddress, juniorEtk, seniorEtk, ...opt
271
274
  hre
272
275
  );
273
276
  const policyPool = await hre.ethers.getContractAt("PolicyPool", poolAddress);
274
- if (opts.addComponent)
275
- await policyPool.addComponent(contract.address, 3);
277
+ if (opts.addComponent) await policyPool.addComponent(contract.address, 3);
276
278
  return contract.address;
277
279
  }
278
280
 
@@ -338,11 +340,10 @@ async function deployRiskModule(
338
340
  await rm.setParam(4, ensuroCocFee);
339
341
  }
340
342
  if (maxDuration != 24 * 365) {
341
- await rm.setParam(9, ensuroCocFee);
343
+ await rm.setParam(9, maxDuration);
342
344
  }
343
345
  const policyPool = await hre.ethers.getContractAt("PolicyPool", poolAddress);
344
- if (opts.addComponent)
345
- await policyPool.addComponent(contract.address, 2);
346
+ if (opts.addComponent) await policyPool.addComponent(contract.address, 2);
346
347
  return contract.address;
347
348
  }
348
349
 
@@ -415,10 +416,16 @@ async function deployAaveAssetManager({ asset, aave, amClass, ...opts }, hre) {
415
416
  }
416
417
 
417
418
  async function deployWhitelist(
418
- { wlClass, poolAddress, extraConstructorArgs, extraArgs, eToken, eToken2, eToken3, ...opts },
419
+ { wlClass, poolAddress, extraConstructorArgs, extraArgs, eToken, eToken2, eToken3, defaultStatus, ...opts },
419
420
  hre
420
421
  ) {
421
422
  extraArgs = extraArgs || [];
423
+ if (defaultStatus !== "") {
424
+ defaultStatus = defaultStatus
425
+ .split("")
426
+ .map((WB) => (WB == "W" ? WhitelistStatus.whitelisted : WhitelistStatus.blacklisted));
427
+ extraArgs.splice(0, 0, defaultStatus);
428
+ }
422
429
  extraConstructorArgs = extraConstructorArgs || [];
423
430
  const { contract } = await deployProxyContract(
424
431
  {
@@ -706,6 +713,7 @@ function add_task() {
706
713
  .addOptionalParam("eToken", "Set the Whitelist to a given eToken", undefined, types.address)
707
714
  .addOptionalParam("eToken2", "Set the Whitelist to a given eToken", undefined, types.address)
708
715
  .addOptionalParam("eToken3", "Set the Whitelist to a given eToken", undefined, types.address)
716
+ .addOptionalParam("defaultStatus", "Default Status Ej: 'BWWB'", "BWWB", types.str)
709
717
  .addParam("poolAddress", "PolicyPool Address", types.address)
710
718
  .setAction(deployWhitelist);
711
719
 
@@ -776,4 +784,5 @@ module.exports = {
776
784
  deploySignedQuoteRM,
777
785
  setAssetManager,
778
786
  deployWhitelist,
787
+ WhitelistStatus,
779
788
  };
package/js/test-utils.js CHANGED
@@ -414,8 +414,8 @@ function makePolicyId(rm, internalId) {
414
414
 
415
415
  exports.makePolicyId = makePolicyId;
416
416
 
417
- async function makePolicy(pool, rm, cust, payout, premium, lossProb, expiration, internalId) {
418
- let tx = await rm.connect(cust).newPolicy(payout, premium, lossProb, expiration, cust.address, internalId);
417
+ async function makePolicy(pool, rm, cust, payout, premium, lossProb, expiration, internalId, method = "newPolicy") {
418
+ let tx = await rm.connect(cust)[method](payout, premium, lossProb, expiration, cust.address, internalId);
419
419
  let receipt = await tx.wait();
420
420
  const newPolicyEvt = getTransactionEvent(pool.interface, receipt, "NewPolicy");
421
421
 
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.0.1",
4
+ "version": "v2.1.0-beta1",
5
5
  "files": [
6
6
  "**/*.sol",
7
7
  "/build/contracts/*.json",