@etherisc/gif-next 0.0.2-e1f23dc-329 → 0.0.2-e3f4f82-063

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 (142) hide show
  1. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  2. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.json +8 -8
  4. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  5. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +2 -2
  8. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  10. package/artifacts/contracts/components/Pool.sol/Pool.json +16 -11
  11. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  12. package/artifacts/contracts/components/Product.sol/Product.json +18 -8
  13. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  14. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  15. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  33. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
  34. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
  35. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  36. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  37. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +30 -0
  38. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  39. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/Instance.sol/Instance.json +52 -22
  41. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  42. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
  43. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  44. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +55 -40
  45. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  46. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +2 -2
  47. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  48. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +2 -2
  49. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  50. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  51. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  53. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  62. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +2 -2
  64. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +2 -2
  66. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +2 -2
  68. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +21 -0
  72. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +21 -0
  74. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +59 -14
  76. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +20 -8
  78. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +89 -36
  80. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +35 -19
  82. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  83. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  84. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  85. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  86. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  87. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  88. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
  89. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  90. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
  91. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  92. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  93. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  94. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  95. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  96. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  97. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  98. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  99. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  100. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  101. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  102. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  103. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  104. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  105. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  106. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  107. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  108. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  109. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  110. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  111. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  112. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  113. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  114. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  115. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  116. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  117. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  118. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  119. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  120. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  121. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  122. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  123. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  124. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  125. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  126. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  127. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  128. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  129. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  130. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  131. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  132. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  133. package/contracts/components/Distribution.sol +5 -1
  134. package/contracts/components/IPoolComponent.sol +1 -1
  135. package/contracts/components/Pool.sol +12 -7
  136. package/contracts/components/Product.sol +7 -2
  137. package/contracts/instance/module/ISetup.sol +3 -0
  138. package/contracts/instance/service/IPoolService.sol +2 -0
  139. package/contracts/instance/service/IProductService.sol +3 -0
  140. package/contracts/instance/service/PoolService.sol +15 -12
  141. package/contracts/instance/service/ProductService.sol +66 -68
  142. package/package.json +1 -1
@@ -323,7 +323,7 @@ contract ProductService is ComponentServiceBase, IProductService {
323
323
  returns (IBundle.BundleInfo memory)
324
324
  {
325
325
  bundleInfo.lockedAmount += collateralAmount;
326
- // FIXME: this
326
+ // FIXME: track policy in bundle and how much is locked for it
327
327
  // instance.collateralizePolicy(bundleNftId, policyNftId, collateralAmount);
328
328
  return bundleInfo;
329
329
  }
@@ -374,7 +374,6 @@ contract ProductService is ComponentServiceBase, IProductService {
374
374
 
375
375
  // check match between policy and calling product
376
376
  NftId productNftId = productInfo.nftId;
377
- // FIXME: this
378
377
  IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
379
378
  require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
380
379
  require(instanceReader.getPolicyState(policyNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
@@ -382,18 +381,20 @@ contract ProductService is ComponentServiceBase, IProductService {
382
381
  NftId bundleNftId;
383
382
  IBundle.BundleInfo memory bundleInfo;
384
383
  uint256 collateralAmount;
385
- ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
386
-
387
- (
388
- bundleNftId,
389
- bundleInfo,
390
- collateralAmount
391
- ) = _getAndVerifyUnderwritingSetup(
392
- instance,
393
- instanceReader,
394
- policyInfo,
395
- productSetupInfo
396
- );
384
+ {
385
+ ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
386
+
387
+ (
388
+ bundleNftId,
389
+ bundleInfo,
390
+ collateralAmount
391
+ ) = _getAndVerifyUnderwritingSetup(
392
+ instance,
393
+ instanceReader,
394
+ policyInfo,
395
+ productSetupInfo
396
+ );
397
+ }
397
398
 
398
399
  // lock bundle collateral
399
400
  bundleInfo = _lockCollateralInBundle(
@@ -402,9 +403,11 @@ contract ProductService is ComponentServiceBase, IProductService {
402
403
  bundleInfo,
403
404
  policyNftId,
404
405
  collateralAmount);
406
+ StateId newPolicyState = UNDERWRITTEN();
405
407
 
406
408
  // optional activation of policy
407
409
  if(activateAt > zeroTimestamp()) {
410
+ newPolicyState = ACTIVE();
408
411
  policyInfo.activatedAt = activateAt;
409
412
  policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
410
413
  }
@@ -421,7 +424,7 @@ contract ProductService is ComponentServiceBase, IProductService {
421
424
  bundleInfo.balanceAmount += netPremiumAmount;
422
425
  }
423
426
 
424
- instance.updatePolicy(policyNftId, policyInfo, UNDERWRITTEN());
427
+ instance.updatePolicy(policyNftId, policyInfo, newPolicyState);
425
428
  _poolService.updateBundle(productInfo.parentNftId, bundleNftId, bundleInfo, KEEP_STATE());
426
429
 
427
430
  // involve pool if necessary
@@ -429,8 +432,7 @@ contract ProductService is ComponentServiceBase, IProductService {
429
432
  NftId poolNftId = bundleInfo.poolNftId;
430
433
  ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
431
434
 
432
- // FIXME: use poolInfo.isVerifying ???
433
- if(poolInfo.isIntercepting) {
435
+ if(poolInfo.isConfirmingApplication) {
434
436
  _underwriteByPool(
435
437
  poolNftId,
436
438
  policyNftId,
@@ -453,51 +455,46 @@ contract ProductService is ComponentServiceBase, IProductService {
453
455
  function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
454
456
  // check caller is registered product
455
457
  (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
458
+ InstanceReader instanceReader = instance.getInstanceReader();
456
459
 
457
- // perform actual token transfers
458
- // FIXME: this
459
- // IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
460
- // ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productInfo.nftId);
460
+ // TODO: check if not paid
461
+ // TODO: transfer premium
462
+ // TODO: optionally activate
461
463
 
464
+ // // perform actual token transfers (this code is probably not complete)
465
+ // IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
466
+
462
467
  // uint256 premiumAmount = policyInfo.premiumAmount;
463
- // _processPremiumByTreasury(instance, productInfo.nftId, treasuryInfo, policyNftId, premiumAmount);
468
+ // _processPremiumByTreasury(instance, productInfo.nftId, policyNftId, premiumAmount);
464
469
 
465
470
  // // policy level book keeping for premium paid
466
471
  // policyInfo.premiumPaidAmount += premiumAmount;
467
472
 
473
+ // instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
474
+
468
475
  // // optional activation of policy
469
476
  // if(activateAt > zeroTimestamp()) {
470
- // require(
471
- // policyInfo.activatedAt.eqz(),
472
- // "ERROR:PRS-030:ALREADY_ACTIVATED");
473
-
474
- // policyInfo.activatedAt = activateAt;
475
- // policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
476
-
477
- // instance.updatePolicyState(policyNftId, ACTIVE());
477
+ // activate(policyNftId, activateAt);
478
478
  // }
479
479
 
480
- // instance.setPolicyInfo(policyNftId, policyInfo);
481
-
482
480
  // TODO add logging
483
481
  }
484
482
 
485
- // FIXME: this
486
- function activate(NftId policyNftId, Timestamp activateAt) external override {
483
+ function activate(NftId policyNftId, Timestamp activateAt) public override {
487
484
  // check caller is registered product
488
485
  (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
486
+ InstanceReader instanceReader = instance.getInstanceReader();
489
487
 
490
- // IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
488
+ IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
491
489
 
492
- // require(
493
- // policyInfo.activatedAt.eqz(),
494
- // "ERROR:PRS-020:ALREADY_ACTIVATED");
490
+ require(
491
+ policyInfo.activatedAt.eqz(),
492
+ "ERROR:PRS-020:ALREADY_ACTIVATED");
495
493
 
496
- // policyInfo.activatedAt = activateAt;
497
- // policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
494
+ policyInfo.activatedAt = activateAt;
495
+ policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
498
496
 
499
- // instance.setPolicyInfo(policyNftId, policyInfo);
500
- // instance.updatePolicyState(policyNftId, ACTIVE());
497
+ instance.updatePolicy(policyNftId, policyInfo, ACTIVE());
501
498
 
502
499
  // TODO add logging
503
500
  }
@@ -517,8 +514,9 @@ contract ProductService is ComponentServiceBase, IProductService {
517
514
  view
518
515
  returns (NftId poolNftid)
519
516
  {
520
- // FIXME: this
521
- // return instance.getTreasuryInfo(productNftId).poolNftId;
517
+ InstanceReader instanceReader = instance.getInstanceReader();
518
+ ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
519
+ return productSetupInfo.poolNftId;
522
520
  }
523
521
 
524
522
 
@@ -533,30 +531,30 @@ contract ProductService is ComponentServiceBase, IProductService {
533
531
  {
534
532
  // process token transfer(s)
535
533
  if(premiumAmount > 0) {
536
- // FIXME: this
537
- // TokenHandler tokenHandler = instance.getTokenHandler(productNftId);
538
- // address policyOwner = getRegistry().ownerOf(policyNftId);
539
- // address poolWallet = instance.getComponentWallet(treasuryInfo.poolNftId);
540
- // netPremiumAmount = premiumAmount;
541
- // Fee memory productFee = treasuryInfo.productFee;
542
-
543
- // if (FeeLib.feeIsZero(productFee)) {
544
- // tokenHandler.transfer(
545
- // policyOwner,
546
- // poolWallet,
547
- // premiumAmount
548
- // );
549
- // } else {
550
- // (uint256 feeAmount, uint256 netAmount) = instance.calculateFeeAmount(
551
- // premiumAmount,
552
- // productFee
553
- // );
554
-
555
- // address productWallet = instance.getComponentWallet(productNftId);
556
- // tokenHandler.transfer(policyOwner, productWallet, feeAmount);
557
- // tokenHandler.transfer(policyOwner, poolWallet, netAmount);
558
- // netPremiumAmount = netAmount;
559
- // }
534
+ ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
535
+ TokenHandler tokenHandler = productSetupInfo.tokenHandler;
536
+ address policyOwner = getRegistry().ownerOf(policyNftId);
537
+ ISetup.PoolSetupInfo memory poolSetupInfo = instance.getInstanceReader().getPoolSetupInfo(productSetupInfo.poolNftId);
538
+ address poolWallet = poolSetupInfo.wallet;
539
+ netPremiumAmount = premiumAmount;
540
+ Fee memory productFee = productSetupInfo.productFee;
541
+
542
+ if (FeeLib.feeIsZero(productFee)) {
543
+ tokenHandler.transfer(
544
+ policyOwner,
545
+ poolWallet,
546
+ premiumAmount
547
+ );
548
+ } else {
549
+ (uint256 productFeeAmount, uint256 netAmount) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
550
+ address productWallet = productSetupInfo.wallet;
551
+ if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premiumAmount) {
552
+ revert ErrorIProductServiceInsufficientAllowance(policyOwner, address(tokenHandler), premiumAmount);
553
+ }
554
+ tokenHandler.transfer(policyOwner, productWallet, productFeeAmount);
555
+ tokenHandler.transfer(policyOwner, poolWallet, netAmount);
556
+ netPremiumAmount = netAmount;
557
+ }
560
558
  }
561
559
 
562
560
  // TODO add logging
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-e1f23dc-329",
3
+ "version": "0.0.2-e3f4f82-063",
4
4
  "description": "This is the repository for the next version of the Generic Insurance Framework (GIF) smart contracts. ",
5
5
  "main": "index.js",
6
6
  "scripts": {