@etherisc/gif-next 0.0.2-da0f894-204 → 0.0.2-db1e1e4-828

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. package/README.md +6 -83
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +68 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +64 -14
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IComponent.sol/IComponent.json +158 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +150 -10
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +184 -149
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +158 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +114 -189
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +68 -0
  18. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  19. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  20. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  21. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
  22. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  23. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
  24. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  25. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +127 -182
  26. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  27. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +175 -51
  28. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  29. package/artifacts/contracts/instance/Instance.sol/Instance.json +215 -252
  30. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  31. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +472 -126
  32. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  33. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +102 -168
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +304 -171
  36. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +71 -23
  38. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  39. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
  40. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +85 -30
  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 +40 -10
  46. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
  48. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  49. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +56 -73
  50. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
  52. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
  53. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  58. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  59. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +145 -53
  60. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  61. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +21 -13
  62. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +384 -249
  64. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +74 -14
  66. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +104 -41
  68. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +11 -7
  70. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +356 -111
  72. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +57 -45
  74. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +101 -14
  76. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +212 -186
  78. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +80 -14
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +250 -18
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +106 -19
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +511 -14
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
  88. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +152 -60
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -19
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +561 -51
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +24 -12
  96. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +114 -51
  98. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
  100. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  101. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
  102. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  103. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
  104. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  105. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -24
  106. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  107. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
  108. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  109. package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
  110. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  111. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  112. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  113. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -36
  114. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  115. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
  116. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  117. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
  118. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  119. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  120. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  121. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  122. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  124. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  126. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IService.sol/IService.json +80 -14
  128. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  131. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  132. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  133. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  134. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  137. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  138. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  139. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  140. package/artifacts/contracts/shared/Service.sol/Service.json +86 -15
  141. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  142. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  143. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  144. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  145. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  147. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  148. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  150. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
  152. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestService.sol/TestService.json +101 -26
  154. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  156. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  157. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  158. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  159. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  160. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  161. package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +4 -0
  162. package/artifacts/contracts/types/Amount.sol/AmountLib.json +161 -0
  163. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  165. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  169. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
  171. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  172. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  173. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  175. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  176. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  177. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  180. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
  183. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  185. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  187. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  190. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +2 -2
  192. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  194. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  196. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  198. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  200. package/contracts/components/Component.sol +42 -10
  201. package/contracts/components/Distribution.sol +0 -13
  202. package/contracts/components/IComponent.sol +9 -1
  203. package/contracts/components/IDistributionComponent.sol +0 -8
  204. package/contracts/components/IPoolComponent.sol +5 -43
  205. package/contracts/components/Pool.sol +47 -122
  206. package/contracts/components/Product.sol +4 -0
  207. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
  208. package/contracts/instance/BundleManager.sol +6 -4
  209. package/contracts/instance/Cloneable.sol +7 -2
  210. package/contracts/instance/IInstance.sol +16 -10
  211. package/contracts/instance/IInstanceService.sol +18 -5
  212. package/contracts/instance/Instance.sol +46 -9
  213. package/contracts/instance/InstanceAccessManager.sol +388 -158
  214. package/contracts/instance/InstanceReader.sol +8 -10
  215. package/contracts/instance/InstanceService.sol +184 -179
  216. package/contracts/instance/ObjectManager.sol +6 -8
  217. package/contracts/instance/base/ComponentService.sol +17 -30
  218. package/contracts/instance/base/KeyValueStore.sol +13 -5
  219. package/contracts/instance/base/Lifecycle.sol +11 -2
  220. package/contracts/instance/module/IAccess.sol +21 -14
  221. package/contracts/instance/module/IBundle.sol +6 -4
  222. package/contracts/instance/module/IComponents.sol +41 -0
  223. package/contracts/instance/module/ISetup.sol +4 -17
  224. package/contracts/instance/service/ApplicationService.sol +22 -18
  225. package/contracts/instance/service/BundleService.sol +209 -77
  226. package/contracts/instance/service/ClaimService.sol +3 -3
  227. package/contracts/instance/service/DistributionService.sol +118 -77
  228. package/contracts/instance/service/IApplicationService.sol +1 -0
  229. package/contracts/instance/service/IBundleService.sol +63 -25
  230. package/contracts/instance/service/IDistributionService.sol +14 -1
  231. package/contracts/instance/service/IPolicyService.sol +2 -0
  232. package/contracts/instance/service/IPoolService.sol +82 -3
  233. package/contracts/instance/service/PolicyService.sol +96 -138
  234. package/contracts/instance/service/PoolService.sol +214 -20
  235. package/contracts/instance/service/ProductService.sol +30 -53
  236. package/contracts/registry/ChainNft.sol +8 -0
  237. package/contracts/registry/IRegistry.sol +2 -0
  238. package/contracts/registry/IRegistryService.sol +4 -3
  239. package/contracts/registry/ITransferInterceptor.sol +1 -0
  240. package/contracts/registry/Registry.sol +23 -20
  241. package/contracts/registry/RegistryService.sol +10 -11
  242. package/contracts/registry/ReleaseManager.sol +20 -18
  243. package/contracts/shared/IService.sol +4 -6
  244. package/contracts/shared/Service.sol +21 -7
  245. package/contracts/shared/TokenHandler.sol +11 -5
  246. package/contracts/test/TestService.sol +1 -1
  247. package/contracts/types/Amount.sol +60 -0
  248. package/contracts/types/Blocknumber.sol +1 -0
  249. package/contracts/types/Fee.sol +13 -5
  250. package/contracts/types/NftId.sol +8 -0
  251. package/contracts/types/ObjectType.sol +1 -0
  252. package/contracts/types/Referral.sol +4 -0
  253. package/contracts/types/RoleId.sol +6 -4
  254. package/contracts/types/StateId.sol +1 -0
  255. package/contracts/types/Timestamp.sol +1 -0
  256. package/contracts/types/UFixed.sol +1 -0
  257. package/contracts/types/Version.sol +1 -0
  258. package/package.json +1 -1
@@ -2,45 +2,35 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../registry/IRegistry.sol";
5
- import {IProductComponent} from "../../components/IProductComponent.sol";
6
5
  import {Product} from "../../components/Product.sol";
7
- import {IPoolComponent} from "../../components/IPoolComponent.sol";
6
+ import {IComponents} from "../module/IComponents.sol";
8
7
  import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
9
8
  import {IInstance} from "../IInstance.sol";
10
9
  import {IPolicy} from "../module/IPolicy.sol";
10
+ import {IPoolComponent} from "../../components/IPoolComponent.sol";
11
11
  import {IRisk} from "../module/IRisk.sol";
12
12
  import {IBundle} from "../module/IBundle.sol";
13
- import {IProductService} from "./IProductService.sol";
14
- import {ITreasury} from "../module/ITreasury.sol";
15
13
  import {ISetup} from "../module/ISetup.sol";
16
14
 
17
15
  import {TokenHandler} from "../../shared/TokenHandler.sol";
18
16
 
19
- import {IVersionable} from "../../shared/IVersionable.sol";
20
- import {Versionable} from "../../shared/Versionable.sol";
21
-
22
- import {Seconds} from "../../types/Seconds.sol";
23
17
  import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
24
18
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
25
- import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
26
- import {ObjectType, APPLICATION, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
19
+ import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
27
20
  import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
28
- import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
29
- import {Fee, FeeLib} from "../../types/Fee.sol";
30
- import {ReferralId} from "../../types/Referral.sol";
31
- import {RiskId} from "../../types/RiskId.sol";
21
+ import {NftId, NftIdLib} from "../../types/NftId.sol";
32
22
  import {StateId} from "../../types/StateId.sol";
33
- import {Version, VersionLib} from "../../types/Version.sol";
34
- //import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
23
+ import {VersionPart} from "../../types/Version.sol";
35
24
 
36
- import {IService} from "../../shared/IService.sol";
37
- import {Service} from "../../shared/Service.sol";
38
25
  import {ComponentService} from "../base/ComponentService.sol";
39
26
  import {IApplicationService} from "./IApplicationService.sol";
40
- import {IPolicyService} from "./IPolicyService.sol";
27
+ import {IBundleService} from "./IBundleService.sol";
28
+ import {IDistributionService} from "./IDistributionService.sol";
41
29
  import {InstanceReader} from "../InstanceReader.sol";
30
+ import {IPolicyService} from "./IPolicyService.sol";
42
31
  import {IPoolService} from "./IPoolService.sol";
43
- import {IBundleService} from "./IBundleService.sol";
32
+ import {IService} from "../../shared/IService.sol";
33
+ import {Service} from "../../shared/Service.sol";
44
34
 
45
35
 
46
36
  contract PolicyService is
@@ -53,6 +43,7 @@ contract PolicyService is
53
43
  IPoolService internal _poolService;
54
44
  IBundleService internal _bundleService;
55
45
  IApplicationService internal _applicationService;
46
+ IDistributionService internal _distributionService;
56
47
 
57
48
  event LogProductServiceSender(address sender);
58
49
 
@@ -68,56 +59,54 @@ contract PolicyService is
68
59
  address initialOwner;
69
60
  (registryAddress, initialOwner) = abi.decode(data, (address, address));
70
61
 
71
- initializeService(registryAddress, owner);
62
+ initializeService(registryAddress, address(0), owner);
72
63
 
73
- _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
74
- _bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getMajorVersion()));
75
- // FIXME: application service is currently deployed AFTER policy service
76
- _applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), getMajorVersion()));
64
+ VersionPart majorVersion = getVersion().toMajorPart();
65
+ _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), majorVersion));
66
+ _bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), majorVersion));
67
+ _applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), majorVersion));
68
+ _distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), majorVersion));
77
69
 
78
70
  registerInterface(type(IPolicyService).interfaceId);
79
71
  }
80
72
 
81
73
 
82
- function getDomain() public pure override(IService, Service) returns(ObjectType) {
74
+ function getDomain() public pure override returns(ObjectType) {
83
75
  return POLICY();
84
76
  }
85
77
 
86
78
 
87
79
  function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
88
80
  IRegistry.ObjectInfo memory productInfo;
89
- (productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
81
+ (, productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
90
82
  product = Product(productInfo.objectAddress);
91
83
  }
92
84
 
93
- function _getAndVerifyUnderwritingSetup(
94
- IInstance instance,
95
- InstanceReader instanceReader,
96
- IPolicy.PolicyInfo memory policyInfo,
97
- ISetup.ProductSetupInfo memory productSetupInfo
98
- )
99
- internal
100
- view
101
- returns (
102
- NftId poolNftId,
103
- NftId bundleNftId,
104
- IBundle.BundleInfo memory bundleInfo,
105
- uint256 collateralAmount
106
- )
107
- {
108
- // check match between policy and bundle (via pool)
109
- poolNftId = productSetupInfo.poolNftId;
110
- bundleNftId = policyInfo.bundleNftId;
111
- bundleInfo = instanceReader.getBundleInfo(bundleNftId);
112
- require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
113
-
114
- // calculate required collateral
115
- ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
116
-
117
- // obtain remaining return values
118
- // TODO required collateral amount should be calculated by pool service, not policy service
119
- collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
120
- }
85
+ // function _getAndVerifyUnderwritingSetup(
86
+ // IInstance instance,
87
+ // InstanceReader instanceReader,
88
+ // IPolicy.PolicyInfo memory policyInfo,
89
+ // ISetup.ProductSetupInfo memory productSetupInfo
90
+ // )
91
+ // internal
92
+ // view
93
+ // returns (
94
+ // NftId poolNftId,
95
+ // IComponents.PoolInfo memory poolInfo,
96
+ // NftId bundleNftId,
97
+ // IBundle.BundleInfo memory bundleInfo
98
+ // )
99
+ // {
100
+ // // check match between policy and bundle (via pool)
101
+ // poolNftId = productSetupInfo.poolNftId;
102
+ // bundleNftId = policyInfo.bundleNftId;
103
+ // bundleInfo = instanceReader.getBundleInfo(bundleNftId);
104
+ // require(bundleInfo.poolNftId == poolNftId, "BUNDLE_POOL_MISMATCH");
105
+
106
+ // // calculate required collateral
107
+ // IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
108
+ // poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
109
+ // }
121
110
 
122
111
 
123
112
  function decline(
@@ -140,42 +129,23 @@ contract PolicyService is
140
129
  virtual override
141
130
  {
142
131
  // check caller is registered product
143
- IInstance instance;
144
- InstanceReader instanceReader;
145
- NftId productNftId;
146
- {
147
- IRegistry.ObjectInfo memory productInfo;
148
- (productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
149
- instanceReader = instance.getInstanceReader();
150
- productNftId = productInfo.nftId;
151
- }
132
+ (NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
133
+ InstanceReader instanceReader = instance.getInstanceReader();
152
134
 
153
135
  // check policy matches with calling product
154
- IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(applicationNftId);
155
- require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
136
+ IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
137
+ require(applicationInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
156
138
 
157
139
  // check policy is in state applied
158
140
  require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
159
141
 
160
- (
161
- NftId poolNftId,
162
- NftId bundleNftId,
163
- IBundle.BundleInfo memory bundleInfo,
164
- uint256 collateralAmount
165
- ) = _getAndVerifyUnderwritingSetup(
166
- instance,
167
- instanceReader,
168
- policyInfo,
169
- instanceReader.getProductSetupInfo(productNftId)
170
- );
171
-
172
142
  StateId newPolicyState = UNDERWRITTEN();
173
143
 
174
144
  // optional activation of policy
175
145
  if(activateAt > zeroTimestamp()) {
176
146
  newPolicyState = ACTIVE();
177
- policyInfo.activatedAt = activateAt;
178
- policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
147
+ applicationInfo.activatedAt = activateAt;
148
+ applicationInfo.expiredAt = activateAt.addSeconds(applicationInfo.lifetime);
179
149
  }
180
150
 
181
151
  // lock bundle collateral
@@ -185,45 +155,26 @@ contract PolicyService is
185
155
  if(requirePremiumPayment) {
186
156
  netPremiumAmount = _processPremiumByTreasury(
187
157
  instance,
188
- productNftId,
189
158
  applicationNftId,
190
- policyInfo.premiumAmount);
159
+ applicationInfo.premiumAmount);
191
160
 
192
- policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
161
+ applicationInfo.premiumPaidAmount += applicationInfo.premiumAmount;
193
162
  }
194
163
 
195
- // lock collateral and update bundle book keeping
196
- // TODO introduct indirection via pool service?
197
- // well pool would only need to be involved when a part of the collateral
198
- // is provided by a "re insurance policy" of the pool
199
- // but then again the policiy would likely best be attached to the bundle. really? why?
200
- // retention level: fraction of sum insured that product will cover from pool funds directly
164
+ // store updated policy info
165
+ instance.updatePolicy(applicationNftId, applicationInfo, newPolicyState);
166
+
167
+ // lock collateral and update pool and bundle book keeping
168
+ // pool retention level: fraction of sum insured that product will cover from pool funds directly
201
169
  // eg retention level 30%, payouts up to 30% of the sum insured will be made from the product's pool directly
202
170
  // for the remaining 70% the pool owns a policy that will cover claims that exceed the 30% of the sum insured
203
- // open points:
204
- // - do we need a link of a bundle to this policy or is it enough to know that the pool has an active policy?
205
- // - when to buy such policies and for which amount? manual trigger or link to bundle creation and/or funding?
206
- bundleInfo = _bundleService.lockCollateral(
171
+ // might also call pool component (for isVerifyingApplications pools)
172
+ _poolService.lockCollateral(
207
173
  instance,
174
+ productNftId,
208
175
  applicationNftId,
209
- bundleNftId,
210
- collateralAmount,
211
- netPremiumAmount);
212
-
213
- instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
214
-
215
- // also verify/confirm application by pool if necessary
216
- if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
217
- IPoolComponent pool = IPoolComponent(
218
- getRegistry().getObjectInfo(poolNftId).objectAddress);
219
-
220
- pool.verifyApplication(
221
- applicationNftId,
222
- policyInfo.applicationData,
223
- bundleNftId,
224
- bundleInfo.filter,
225
- collateralAmount);
226
- }
176
+ applicationInfo,
177
+ netPremiumAmount); // for pool book keeping (fee + additional capital)
227
178
 
228
179
  // TODO: add logging
229
180
  }
@@ -237,7 +188,7 @@ contract PolicyService is
237
188
 
238
189
  function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
239
190
  // check caller is registered product
240
- (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
191
+ (NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
241
192
  InstanceReader instanceReader = instance.getInstanceReader();
242
193
  IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
243
194
 
@@ -249,7 +200,6 @@ contract PolicyService is
249
200
 
250
201
  uint256 netPremiumAmount = _processPremiumByTreasury(
251
202
  instance,
252
- productInfo.nftId,
253
203
  policyNftId,
254
204
  unpaidPremiumAmount);
255
205
 
@@ -267,7 +217,7 @@ contract PolicyService is
267
217
 
268
218
  function activate(NftId policyNftId, Timestamp activateAt) public override {
269
219
  // check caller is registered product
270
- (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
220
+ (,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
271
221
  InstanceReader instanceReader = instance.getInstanceReader();
272
222
 
273
223
  IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
@@ -301,7 +251,7 @@ contract PolicyService is
301
251
  external
302
252
  override
303
253
  {
304
- (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
254
+ (,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
305
255
  InstanceReader instanceReader = instance.getInstanceReader();
306
256
 
307
257
  IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
@@ -333,7 +283,11 @@ contract PolicyService is
333
283
 
334
284
  policyInfo.closedAt = TimestampLib.blockTimestamp();
335
285
 
336
- _bundleService.closePolicy(instance, policyNftId, policyInfo.bundleNftId, policyInfo.sumInsuredAmount);
286
+ _poolService.releaseCollateral(
287
+ instance,
288
+ policyNftId,
289
+ policyInfo);
290
+
337
291
  instance.updatePolicy(policyNftId, policyInfo, CLOSED());
338
292
  }
339
293
 
@@ -353,7 +307,6 @@ contract PolicyService is
353
307
 
354
308
  function _processPremiumByTreasury(
355
309
  IInstance instance,
356
- NftId productNftId,
357
310
  NftId policyNftId,
358
311
  uint256 premiumAmount
359
312
  )
@@ -362,12 +315,12 @@ contract PolicyService is
362
315
  {
363
316
  // process token transfer(s)
364
317
  if(premiumAmount > 0) {
318
+ NftId productNftId = getRegistry().getObjectInfo(policyNftId).parentNftId;
365
319
  ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
366
320
  IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
367
321
  TokenHandler tokenHandler = productSetupInfo.tokenHandler;
368
322
  address policyOwner = getRegistry().ownerOf(policyNftId);
369
- ISetup.PoolSetupInfo memory poolSetupInfo = instance.getInstanceReader().getPoolSetupInfo(productSetupInfo.poolNftId);
370
- address poolWallet = poolSetupInfo.wallet;
323
+ address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
371
324
  IPolicy.Premium memory premium = _applicationService.calculatePremium(
372
325
  productNftId,
373
326
  policyInfo.riskId,
@@ -378,25 +331,30 @@ contract PolicyService is
378
331
  policyInfo.referralId
379
332
  );
380
333
 
381
- // if (FeeLib.feeIsZero(premium.productFeeAmount)) {
382
- // tokenHandler.transfer(
383
- // policyOwner,
384
- // poolWallet,
385
- // premiumAmount
386
- // );
387
- // } else {
388
- // FIXME: this is wrong as netPremium is not netPremium here!!!
389
- // (uint256 productFeeAmount, uint256 netAmount) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
390
- address productWallet = productSetupInfo.wallet;
391
- if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
392
- revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
393
- }
394
- tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
395
- tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
396
- netPremiumAmount = premium.netPremiumAmount;
397
- // TODO: also move distribution tokens to distribution wallet and call `Distribution.processSale` to update distribution balances
398
- // }
399
-
334
+ if (premium.premiumAmount != premiumAmount) {
335
+ revert ErrorIPolicyServicePremiumMismatch(policyNftId, premiumAmount, premium.premiumAmount);
336
+ }
337
+
338
+ // move product fee to product wallet
339
+ address productWallet = productSetupInfo.wallet;
340
+ if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
341
+ revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
342
+ }
343
+ tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
344
+
345
+ // move distribution fee to distribution wallet
346
+ ISetup.DistributionSetupInfo memory distributionSetupInfo = instance.getInstanceReader().getDistributionSetupInfo(productSetupInfo.distributionNftId);
347
+ address distributionWallet = distributionSetupInfo.wallet;
348
+ uint256 distributionFeeAmountToTransfer = premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount;
349
+ tokenHandler.transfer(policyOwner, distributionWallet, distributionFeeAmountToTransfer);
350
+ _distributionService.processSale(productSetupInfo.distributionNftId, policyInfo.referralId, premium, distributionFeeAmountToTransfer);
351
+
352
+ // move netpremium to pool wallet
353
+ tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
354
+
355
+ // TODO: move pool related tokens too
356
+ // TODO: move bundle related tokens too
357
+ netPremiumAmount = premium.netPremiumAmount;
400
358
  }
401
359
 
402
360
  // TODO: add logging