@etherisc/gif-next 0.0.2-f2df3e2-873 → 0.0.2-f398177-971

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 (252) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  2. package/artifacts/contracts/components/Component.sol/Component.json +37 -6
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +44 -13
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.json +37 -6
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +44 -13
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +55 -24
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +52 -21
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +55 -24
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +52 -21
  17. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  18. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  19. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  20. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  21. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +252 -2210
  22. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  23. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +21 -38
  24. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  25. package/artifacts/contracts/instance/Instance.sol/Instance.json +346 -2685
  26. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  27. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +67 -49
  28. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +4 -0
  29. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +124 -0
  30. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  31. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +219 -53
  32. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  33. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +59 -220
  34. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +32 -117
  36. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
  37. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2788 -0
  38. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  39. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  40. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +37 -13
  42. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
  46. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  48. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  49. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  52. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  56. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  57. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +75 -217
  58. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  59. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +33 -66
  60. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  61. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +155 -133
  62. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +35 -64
  64. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +463 -119
  66. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +109 -42
  68. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +181 -399
  70. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +81 -94
  72. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +11 -145
  74. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +79 -30
  76. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +229 -88
  78. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +23 -273
  80. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +40 -326
  82. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +265 -32
  84. package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.dbg.json +4 -0
  85. package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.json +510 -0
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +5 -13
  88. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +213 -443
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +74 -75
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +439 -54
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +84 -37
  96. package/artifacts/contracts/instance/service/PricingService.sol/PricingService.dbg.json +4 -0
  97. package/artifacts/contracts/instance/service/PricingService.sol/PricingService.json +1004 -0
  98. package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.dbg.json +4 -0
  99. package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.json +688 -0
  100. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +55 -31
  102. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  103. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +22 -35
  104. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  105. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  106. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  107. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +5 -13
  108. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  109. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  110. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  111. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  112. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  113. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  114. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -25
  115. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  116. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +21 -34
  117. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  118. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +2 -2
  119. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  120. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +10 -23
  121. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  122. package/artifacts/contracts/{instance → shared}/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +3 -3
  123. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  124. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  125. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +0 -13
  127. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +69 -9
  129. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -13
  131. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  132. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +0 -13
  133. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  134. package/artifacts/contracts/shared/IService.sol/IService.json +5 -13
  135. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +6 -19
  138. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  139. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +80 -26
  140. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  141. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +14 -27
  142. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  143. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +6 -19
  144. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  145. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
  146. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  147. package/artifacts/contracts/shared/Service.sol/Service.json +5 -13
  148. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  149. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +24 -6
  150. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  151. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  154. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -19
  156. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  158. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestService.sol/TestService.json +17 -25
  160. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  161. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  162. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  163. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  164. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  165. package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/Amount.sol/AmountLib.json +100 -4
  167. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +2 -2
  171. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  173. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Fee.sol/FeeLib.json +42 -18
  175. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  176. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  177. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  179. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  180. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  181. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  184. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +2 -2
  186. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  188. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  190. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  192. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  194. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  196. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  198. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  199. package/contracts/components/Component.sol +21 -2
  200. package/contracts/components/Distribution.sol +5 -4
  201. package/contracts/components/IComponent.sol +16 -2
  202. package/contracts/components/IPoolComponent.sol +7 -6
  203. package/contracts/components/IProductComponent.sol +5 -4
  204. package/contracts/components/Pool.sol +8 -8
  205. package/contracts/components/Product.sol +21 -17
  206. package/contracts/instance/IInstance.sol +28 -53
  207. package/contracts/instance/IInstanceService.sol +15 -10
  208. package/contracts/instance/Instance.sol +90 -171
  209. package/contracts/instance/InstanceAccessManager.sol +35 -21
  210. package/contracts/instance/InstanceAuthorizationsLib.sol +308 -0
  211. package/contracts/instance/InstanceReader.sol +56 -5
  212. package/contracts/instance/InstanceService.sol +96 -266
  213. package/contracts/instance/InstanceStore.sol +212 -0
  214. package/contracts/instance/ObjectManager.sol +1 -1
  215. package/contracts/instance/base/ComponentService.sol +47 -20
  216. package/contracts/instance/base/KeyValueStore.sol +0 -31
  217. package/contracts/instance/base/Lifecycle.sol +7 -4
  218. package/contracts/instance/module/IComponents.sol +3 -3
  219. package/contracts/instance/module/IDistribution.sol +3 -2
  220. package/contracts/instance/module/IPolicy.sol +5 -5
  221. package/contracts/instance/service/ApplicationService.sol +58 -227
  222. package/contracts/instance/service/BundleService.sol +65 -119
  223. package/contracts/instance/service/ClaimService.sol +232 -34
  224. package/contracts/instance/service/DistributionService.sol +51 -134
  225. package/contracts/instance/service/IApplicationService.sol +5 -21
  226. package/contracts/instance/service/IBundleService.sol +32 -10
  227. package/contracts/instance/service/IClaimService.sol +37 -39
  228. package/contracts/instance/service/IDistributionService.sol +10 -22
  229. package/contracts/instance/service/IPolicyService.sol +15 -72
  230. package/contracts/instance/service/IPoolService.sol +18 -3
  231. package/contracts/instance/service/IPricingService.sol +37 -0
  232. package/contracts/instance/service/PolicyService.sol +112 -277
  233. package/contracts/instance/service/PoolService.sol +121 -21
  234. package/contracts/instance/service/PricingService.sol +275 -0
  235. package/contracts/instance/service/PricingServiceManager.sol +51 -0
  236. package/contracts/instance/service/ProductService.sol +10 -10
  237. package/contracts/registry/IRegistryService.sol +0 -2
  238. package/contracts/registry/RegistryService.sol +14 -10
  239. package/contracts/shared/IPolicyHolder.sol +23 -9
  240. package/contracts/shared/IRegistryLinked.sol +0 -1
  241. package/contracts/shared/IService.sol +2 -0
  242. package/contracts/shared/NftOwnable.sol +0 -2
  243. package/contracts/shared/PolicyHolder.sol +30 -17
  244. package/contracts/shared/Registerable.sol +10 -9
  245. package/contracts/shared/RegistryLinked.sol +0 -5
  246. package/contracts/shared/TokenHandler.sol +4 -2
  247. package/contracts/types/Amount.sol +44 -0
  248. package/contracts/types/Fee.sol +7 -6
  249. package/contracts/types/ObjectType.sol +5 -1
  250. package/package.json +1 -1
  251. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  252. /package/contracts/{instance → shared}/AccessManagerUpgradeableInitializeable.sol +0 -0
@@ -18,7 +18,7 @@ import {Amount, AmountLib} from "../../types/Amount.sol";
18
18
  import {ClaimId, ClaimIdLib} from "../../types/ClaimId.sol";
19
19
  import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
20
20
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
21
- import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE, CLAIM} from "../../types/ObjectType.sol";
21
+ import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE, CLAIM, PRICE} from "../../types/ObjectType.sol";
22
22
  import {APPLIED, COLLATERALIZED, ACTIVE, KEEP_STATE, CLOSED, DECLINED, CONFIRMED} from "../../types/StateId.sol";
23
23
  import {NftId, NftIdLib} from "../../types/NftId.sol";
24
24
  import {PayoutId, PayoutIdLib} from "../../types/PayoutId.sol";
@@ -33,10 +33,10 @@ import {IDistributionService} from "./IDistributionService.sol";
33
33
  import {InstanceReader} from "../InstanceReader.sol";
34
34
  import {IPolicyService} from "./IPolicyService.sol";
35
35
  import {IPoolService} from "./IPoolService.sol";
36
+ import {IPricingService} from "./IPricingService.sol";
36
37
  import {IService} from "../../shared/IService.sol";
37
38
  import {Service} from "../../shared/Service.sol";
38
39
 
39
-
40
40
  contract PolicyService is
41
41
  ComponentService,
42
42
  IPolicyService
@@ -49,6 +49,7 @@ contract PolicyService is
49
49
  IClaimService internal _claimService;
50
50
  IDistributionService internal _distributionService;
51
51
  IPoolService internal _poolService;
52
+ IPricingService internal _pricingService;
52
53
 
53
54
  event LogProductServiceSender(address sender);
54
55
 
@@ -72,6 +73,7 @@ contract PolicyService is
72
73
  _claimService = IClaimService(getRegistry().getServiceAddress(CLAIM(), majorVersion));
73
74
  _applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), majorVersion));
74
75
  _distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), majorVersion));
76
+ _pricingService = IPricingService(getRegistry().getServiceAddress(PRICE(), majorVersion));
75
77
 
76
78
  registerInterface(type(IPolicyService).interfaceId);
77
79
  }
@@ -84,7 +86,7 @@ contract PolicyService is
84
86
 
85
87
  function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
86
88
  IRegistry.ObjectInfo memory productInfo;
87
- (, productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
89
+ (, productInfo,) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
88
90
  product = Product(productInfo.objectAddress);
89
91
  }
90
92
 
@@ -95,7 +97,7 @@ contract PolicyService is
95
97
  external
96
98
  override
97
99
  {
98
- require(false, "ERROR:PRS-235:NOT_YET_IMPLEMENTED");
100
+ revert();
99
101
  }
100
102
 
101
103
 
@@ -109,15 +111,22 @@ contract PolicyService is
109
111
  virtual override
110
112
  {
111
113
  // check caller is registered product
112
- (NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
114
+ (NftId productNftId,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
113
115
  InstanceReader instanceReader = instance.getInstanceReader();
114
116
 
115
117
  // check policy matches with calling product
116
118
  IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
117
- require(applicationInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
119
+ if(applicationInfo.productNftId != productNftId) {
120
+ revert ErrorPolicyServicePolicyProductMismatch(
121
+ applicationNftId,
122
+ applicationInfo.productNftId,
123
+ productNftId);
124
+ }
118
125
 
119
126
  // check policy is in state applied
120
- require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
127
+ if (instanceReader.getPolicyState(applicationNftId) != APPLIED()) {
128
+ revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
129
+ }
121
130
 
122
131
  StateId newPolicyState = COLLATERALIZED();
123
132
 
@@ -129,7 +138,7 @@ contract PolicyService is
129
138
  }
130
139
 
131
140
  // lock bundle collateral
132
- uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
141
+ Amount netPremiumAmount = AmountLib.zero(); // > 0 if immediate premium payment
133
142
 
134
143
  // optional collection of premium
135
144
  if(requirePremiumPayment) {
@@ -138,11 +147,11 @@ contract PolicyService is
138
147
  applicationNftId,
139
148
  applicationInfo.premiumAmount);
140
149
 
141
- applicationInfo.premiumPaidAmount += applicationInfo.premiumAmount;
150
+ applicationInfo.premiumPaidAmount = applicationInfo.premiumPaidAmount + applicationInfo.premiumAmount;
142
151
  }
143
152
 
144
153
  // store updated policy info
145
- instance.updatePolicy(applicationNftId, applicationInfo, newPolicyState);
154
+ instance.getInstanceStore().updatePolicy(applicationNftId, applicationInfo, newPolicyState);
146
155
 
147
156
  // lock collateral and update pool and bundle book keeping
148
157
  // pool retention level: fraction of sum insured that product will cover from pool funds directly
@@ -160,33 +169,46 @@ contract PolicyService is
160
169
  }
161
170
 
162
171
 
163
- function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
164
- UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
165
- UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
166
- return collateralUFixed.toInt();
172
+ function calculateRequiredCollateral(
173
+ UFixed collateralizationLevel,
174
+ Amount sumInsuredAmount
175
+ )
176
+ public
177
+ pure
178
+ virtual
179
+ returns(Amount collateralAmount)
180
+ {
181
+ UFixed collateralUFixed = collateralizationLevel * sumInsuredAmount.toUFixed();
182
+ return AmountLib.toAmount(collateralUFixed.toInt());
167
183
  }
168
184
 
169
- function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
185
+ function collectPremium(
186
+ NftId policyNftId,
187
+ Timestamp activateAt
188
+ )
189
+ external
190
+ virtual
191
+ {
170
192
  // check caller is registered product
171
- (NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
193
+ (NftId productNftId,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
172
194
  InstanceReader instanceReader = instance.getInstanceReader();
173
195
  IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
174
196
 
175
197
  if (policyInfo.premiumPaidAmount == policyInfo.premiumAmount) {
176
- revert ErrorIPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
198
+ revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
177
199
  }
178
200
 
179
- uint256 unpaidPremiumAmount = policyInfo.premiumAmount - policyInfo.premiumPaidAmount;
201
+ Amount unpaidPremiumAmount = policyInfo.premiumAmount - policyInfo.premiumPaidAmount;
180
202
 
181
- uint256 netPremiumAmount = _processPremiumByTreasury(
203
+ Amount netPremiumAmount = _processPremiumByTreasury(
182
204
  instance,
183
205
  policyNftId,
184
206
  unpaidPremiumAmount);
185
207
 
186
- policyInfo.premiumPaidAmount += unpaidPremiumAmount;
208
+ policyInfo.premiumPaidAmount = policyInfo.premiumPaidAmount + unpaidPremiumAmount;
187
209
 
188
210
  _bundleService.increaseBalance(instance, policyInfo.bundleNftId, netPremiumAmount);
189
- instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
211
+ instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
190
212
 
191
213
  if(activateAt.gtz() && policyInfo.activatedAt.eqz()) {
192
214
  activate(policyNftId, activateAt);
@@ -197,7 +219,7 @@ contract PolicyService is
197
219
 
198
220
  function activate(NftId policyNftId, Timestamp activateAt) public override {
199
221
  // check caller is registered product
200
- (,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
222
+ (,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
201
223
  InstanceReader instanceReader = instance.getInstanceReader();
202
224
 
203
225
  IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
@@ -209,7 +231,7 @@ contract PolicyService is
209
231
  policyInfo.activatedAt = activateAt;
210
232
  policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
211
233
 
212
- instance.updatePolicy(policyNftId, policyInfo, ACTIVE());
234
+ instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, ACTIVE());
213
235
 
214
236
  // TODO: add logging
215
237
  }
@@ -231,7 +253,7 @@ contract PolicyService is
231
253
  external
232
254
  override
233
255
  {
234
- (,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
256
+ (,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
235
257
  InstanceReader instanceReader = instance.getInstanceReader();
236
258
 
237
259
  IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
@@ -250,8 +272,8 @@ contract PolicyService is
250
272
  }
251
273
 
252
274
  // TODO consider to allow for underpaid premiums (with the effects of reducing max payouts accordingly)
253
- if (policyInfo.premiumAmount != policyInfo.premiumPaidAmount) {
254
- revert ErrorIPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
275
+ if (!(policyInfo.premiumAmount == policyInfo.premiumPaidAmount)) {
276
+ revert ErrorPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
255
277
  }
256
278
 
257
279
  if (policyInfo.openClaimsCount > 0) {
@@ -265,277 +287,90 @@ contract PolicyService is
265
287
  policyNftId,
266
288
  policyInfo);
267
289
 
268
- instance.updatePolicy(policyNftId, policyInfo, CLOSED());
290
+ instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, CLOSED());
269
291
  }
270
292
 
271
- function submitClaim(
272
- NftId policyNftId,
273
- Amount claimAmount,
274
- bytes memory claimData
293
+
294
+ function _processPremiumByTreasury(
295
+ IInstance instance,
296
+ NftId policyNftId,
297
+ Amount premiumExpectedAmount
275
298
  )
276
- external
277
- virtual
278
- returns (ClaimId claimId)
299
+ internal
300
+ returns (Amount netPremiumAmount)
279
301
  {
280
- (
281
- IInstance instance,
282
- InstanceReader instanceReader,
283
- IPolicy.PolicyInfo memory policyInfo
284
- ) = _verifyCallerWithPolicy(policyNftId);
285
-
286
- // check policy is in its active period
287
- if(policyInfo.activatedAt.eqz() || TimestampLib.blockTimestamp() >= policyInfo.expiredAt) {
288
- revert ErrorPolicyServicePolicyNotOpen(policyNftId);
302
+ // process token transfer(s)
303
+ if(premiumExpectedAmount.eqz()) {
304
+ return AmountLib.zero();
289
305
  }
290
306
 
291
- // check policy including this claim is still within sum insured
292
- if(policyInfo.payoutAmount.toInt() + claimAmount.toInt() > policyInfo.sumInsuredAmount) {
293
- revert ErrorPolicyServiceClaimExceedsSumInsured(
307
+ NftId productNftId = getRegistry().getObjectInfo(policyNftId).parentNftId;
308
+ IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
309
+ IPolicy.Premium memory premium = _pricingService.calculatePremium(
310
+ productNftId,
311
+ policyInfo.riskId,
312
+ policyInfo.sumInsuredAmount,
313
+ policyInfo.lifetime,
314
+ policyInfo.applicationData,
315
+ policyInfo.bundleNftId,
316
+ policyInfo.referralId
317
+ );
318
+
319
+ if (premium.premiumAmount != premiumExpectedAmount.toInt()) {
320
+ revert ErrorPolicyServicePremiumMismatch(
294
321
  policyNftId,
295
- AmountLib.toAmount(policyInfo.sumInsuredAmount),
296
- AmountLib.toAmount(policyInfo.payoutAmount.toInt() + claimAmount.toInt()));
322
+ premiumExpectedAmount,
323
+ AmountLib.toAmount(premium.premiumAmount));
297
324
  }
298
325
 
299
- // create new claim
300
- claimId = ClaimIdLib.toClaimId(policyInfo.claimsCount + 1);
301
- _claimService.submit(instance, policyNftId, claimId, claimAmount, claimData);
302
-
303
- // update and save policy info with instance
304
- policyInfo.claimsCount += 1;
305
- policyInfo.openClaimsCount += 1;
306
- instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
307
-
308
- emit LogPolicyServiceClaimSubmitted(policyNftId, claimId, claimAmount);
309
- }
310
-
311
- function confirmClaim(
312
- NftId policyNftId,
313
- ClaimId claimId,
314
- Amount confirmedAmount
315
- )
316
- external
317
- {
318
- (
319
- IInstance instance,
320
- InstanceReader instanceReader,
321
- IPolicy.PolicyInfo memory policyInfo
322
- ) = _verifyCallerWithPolicy(policyNftId);
323
-
324
- // check/update claim info
325
- _claimService.confirm(instance, instanceReader, policyNftId, claimId, confirmedAmount);
326
-
327
- // update and save policy info with instance
328
- instance.updatePolicy(policyNftId, policyInfo, CONFIRMED());
329
-
330
- emit LogPolicyServiceClaimConfirmed(policyNftId, claimId, confirmedAmount);
331
- }
332
-
333
- function declineClaim(
334
- NftId policyNftId,
335
- ClaimId claimId
336
- )
337
- external
338
- {
339
- (
340
- IInstance instance,
341
- InstanceReader instanceReader,
342
- IPolicy.PolicyInfo memory policyInfo
343
- ) = _verifyCallerWithPolicy(policyNftId);
344
-
345
- // check/update claim info
346
- _claimService.decline(instance, instanceReader, policyNftId, claimId);
347
-
348
- // update and save policy info with instance
349
- policyInfo.openClaimsCount -= 1;
350
- instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
351
-
352
- emit LogPolicyServiceClaimDeclined(policyNftId, claimId);
353
- }
354
-
355
- function closeClaim(
356
- NftId policyNftId,
357
- ClaimId claimId
358
- )
359
- external
360
- {
361
- (
362
- IInstance instance,
363
- InstanceReader instanceReader,
364
- IPolicy.PolicyInfo memory policyInfo
365
- ) = _verifyCallerWithPolicy(policyNftId);
366
-
367
- // check/update claim info
368
- _claimService.close(instance, instanceReader, policyNftId, claimId);
369
-
370
- // update and save policy info with instance
371
- policyInfo.openClaimsCount -= 1;
372
- instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
373
-
374
- emit LogPolicyServiceClaimClosed(policyNftId, claimId);
375
- }
376
-
377
- function createPayout(
378
- NftId policyNftId,
379
- ClaimId claimId,
380
- Amount amount,
381
- bytes memory data
382
- )
383
- external
384
- returns (PayoutId payoutId)
385
- {
386
- (
387
- IInstance instance,
388
- InstanceReader instanceReader,
389
- IPolicy.PolicyInfo memory policyInfo
390
- ) = _verifyCallerWithPolicy(policyNftId);
391
-
392
- IPolicy.ClaimInfo memory claimInfo = instanceReader.getClaimInfo(policyNftId, claimId);
393
- StateId claimState = instanceReader.getClaimState(policyNftId, claimId);
394
-
395
- // TODO add checks
396
- // claim needs to be open
397
- // claim.paidAmount + amount <= claim.claimAmount
398
-
399
- // check/update claim info
400
- uint8 claimNo = claimInfo.payoutsCount + 1;
401
- payoutId = PayoutIdLib.toPayoutId(claimId, claimNo);
402
- _claimService.createPayout(
403
- instance,
404
- policyNftId,
405
- payoutId,
406
- amount,
407
- data);
408
-
409
- // update and save policy info with instance
410
- policyInfo.payoutAmount.add(amount);
411
- instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
412
-
413
- emit LogPolicyServicePayoutCreated(policyNftId, payoutId, amount);
414
- }
415
-
416
- function processPayout(
417
- NftId policyNftId,
418
- PayoutId payoutId
419
- )
420
- external
421
- {
422
- (
423
- IInstance instance,
424
- InstanceReader instanceReader,
425
- IPolicy.PolicyInfo memory policyInfo
426
- ) = _verifyCallerWithPolicy(policyNftId);
427
-
428
- // check/update claim info
429
- (
430
- Amount amount,
431
- bool payoutIsClosingClaim
432
- ) = _claimService.processPayout(
433
- instance,
434
- instanceReader,
435
- policyNftId,
436
- payoutId);
437
-
438
- // update policy info if affected by processed payout
439
- if(payoutIsClosingClaim) {
440
- policyInfo.openClaimsCount -= 1;
441
- instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
326
+ address policyOwner = getRegistry().ownerOf(policyNftId);
327
+ ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
328
+ TokenHandler tokenHandler = productSetupInfo.tokenHandler;
329
+ if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
330
+ revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
442
331
  }
443
332
 
444
- emit LogPolicyServicePayoutProcessed(policyNftId, payoutId, amount);
445
- }
333
+ Amount productFeeAmountToTransfer = AmountLib.toAmount(premium.productFeeFixAmount + premium.productFeeVarAmount);
334
+ Amount distributionFeeAmountToTransfer = AmountLib.toAmount(premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount);
335
+ uint256 poolFeeAmountToTransfer = premium.poolFeeFixAmount + premium.poolFeeVarAmount;
336
+ uint256 bundleFeeAmountToTransfer = premium.bundleFeeFixAmount + premium.bundleFeeVarAmount;
337
+ Amount poolAmountToTransfer = AmountLib.toAmount(premium.netPremiumAmount + poolFeeAmountToTransfer + bundleFeeAmountToTransfer);
446
338
 
447
- function _verifyCallerWithPolicy(
448
- NftId policyNftId
449
- )
450
- internal
451
- returns (
452
- IInstance instance,
453
- InstanceReader instanceReader,
454
- IPolicy.PolicyInfo memory policyInfo
455
- )
456
- {
457
- NftId productNftId;
458
- (productNftId,, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
459
- instanceReader = instance.getInstanceReader();
460
-
461
- // check caller(product) policy match
462
- policyInfo = instanceReader.getPolicyInfo(policyNftId);
463
- if(policyInfo.productNftId != productNftId) {
464
- revert ErrorPolicyServicePolicyProductMismatch(policyNftId,
465
- policyInfo.productNftId,
466
- productNftId);
467
- }
468
- }
339
+ netPremiumAmount = AmountLib.toAmount(premium.netPremiumAmount);
469
340
 
470
- function _getPoolNftId(
471
- IInstance instance,
472
- NftId productNftId
473
- )
474
- internal
475
- view
476
- returns (NftId poolNftid)
477
- {
478
- InstanceReader instanceReader = instance.getInstanceReader();
479
- ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
480
- return productSetupInfo.poolNftId;
481
- }
482
-
483
-
484
- function _processPremiumByTreasury(
485
- IInstance instance,
486
- NftId policyNftId,
487
- uint256 premiumExpectedAmount
488
- )
489
- internal
490
- returns (uint256 netPremiumAmount)
491
- {
492
- // process token transfer(s)
493
- if(premiumExpectedAmount > 0) {
494
- NftId productNftId = getRegistry().getObjectInfo(policyNftId).parentNftId;
495
- ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
496
- IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
497
- TokenHandler tokenHandler = productSetupInfo.tokenHandler;
498
- address policyOwner = getRegistry().ownerOf(policyNftId);
499
- address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
500
- IPolicy.Premium memory premium = _applicationService.calculatePremium(
501
- productNftId,
502
- policyInfo.riskId,
503
- policyInfo.sumInsuredAmount,
504
- policyInfo.lifetime,
505
- policyInfo.applicationData,
506
- policyInfo.bundleNftId,
507
- policyInfo.referralId
508
- );
509
-
510
- if (premium.premiumAmount != premiumExpectedAmount) {
511
- revert ErrorIPolicyServicePremiumMismatch(
512
- policyNftId,
513
- premiumExpectedAmount,
514
- premium.premiumAmount);
515
- }
516
-
517
- // move product fee to product wallet
341
+ // move product fee to product wallet
342
+ {
518
343
  address productWallet = productSetupInfo.wallet;
519
- if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
520
- revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
521
- }
522
- tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
344
+ tokenHandler.transfer(policyOwner, productWallet, productFeeAmountToTransfer);
345
+ }
523
346
 
524
- // move distribution fee to distribution wallet
347
+ // move distribution fee to distribution wallet
348
+ {
525
349
  ISetup.DistributionSetupInfo memory distributionSetupInfo = instance.getInstanceReader().getDistributionSetupInfo(productSetupInfo.distributionNftId);
526
350
  address distributionWallet = distributionSetupInfo.wallet;
527
- uint256 distributionFeeAmountToTransfer = premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount;
528
351
  tokenHandler.transfer(policyOwner, distributionWallet, distributionFeeAmountToTransfer);
529
352
  _distributionService.processSale(productSetupInfo.distributionNftId, policyInfo.referralId, premium, distributionFeeAmountToTransfer);
530
-
531
- // move netpremium to pool wallet
532
- tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
533
-
534
- // TODO: move pool related tokens too
535
- // TODO: move bundle related tokens too
536
- netPremiumAmount = premium.netPremiumAmount;
353
+ }
354
+
355
+ // move netpremium, bundleFee and poolFee to pool wallet
356
+ {
357
+ address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
358
+ tokenHandler.transfer(policyOwner, poolWallet, poolAmountToTransfer);
359
+ _poolService.processSale(policyInfo.bundleNftId, premium, poolAmountToTransfer);
360
+ }
361
+
362
+ // validate total amount transferred
363
+ {
364
+ Amount totalTransferred = distributionFeeAmountToTransfer + poolAmountToTransfer + productFeeAmountToTransfer;
365
+
366
+ if (premium.premiumAmount != totalTransferred.toInt()) {
367
+ revert ErrorPolicyServiceTransferredPremiumMismatch(
368
+ policyNftId,
369
+ AmountLib.toAmount(premium.premiumAmount),
370
+ totalTransferred);
371
+ }
537
372
  }
538
373
 
539
374
  // TODO: add logging
540
375
  }
541
- }
376
+ }