@etherisc/gif-next 0.0.2-db1e1e4-828 → 0.0.2-db81915-875

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.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 +16 -0
  4. package/artifacts/contracts/components/IComponent.sol/IComponent.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/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  9. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  10. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
  11. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  12. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  13. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  14. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  15. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +346 -102
  16. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  17. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  18. package/artifacts/contracts/instance/Instance.sol/Instance.json +276 -289
  19. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  20. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
  21. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  22. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +154 -40
  23. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  24. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +62 -101
  25. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  26. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +32 -32
  27. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  28. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  29. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  30. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  31. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  32. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  33. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +8 -8
  34. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  35. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +6 -6
  36. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  37. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  38. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  39. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  40. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  41. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  42. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  43. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  44. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  45. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +71 -50
  46. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  47. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +18 -10
  48. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  49. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +79 -44
  50. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  51. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +27 -23
  52. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  53. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +284 -61
  54. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +52 -8
  56. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  57. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +42 -66
  58. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  59. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +22 -34
  60. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  61. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +37 -32
  62. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +27 -0
  64. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +173 -46
  66. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  68. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +353 -22
  69. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +4 -4
  71. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +481 -62
  74. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +65 -21
  76. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +12 -12
  78. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +5 -5
  80. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +2 -2
  82. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +2 -2
  84. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  85. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  86. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  87. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  88. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  89. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  90. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  91. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  92. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  93. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
  94. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
  96. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  97. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +2 -2
  98. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  99. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  100. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  101. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  102. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  103. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  104. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  105. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  106. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  107. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  108. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  109. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  110. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  111. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  112. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  113. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  114. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  115. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  116. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  117. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  118. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  119. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  120. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  121. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  122. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  123. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  124. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  125. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  126. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  127. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  128. package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
  129. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  130. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  131. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  132. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  133. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  134. package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +1 -1
  135. package/artifacts/contracts/types/Amount.sol/AmountLib.json +28 -4
  136. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  137. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  138. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  139. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +83 -4
  140. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  141. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  142. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  143. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  144. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  145. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  146. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  147. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  148. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  149. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  152. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +116 -7
  154. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  156. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  158. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  160. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  163. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +17 -4
  165. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  169. package/contracts/components/Distribution.sol +6 -2
  170. package/contracts/components/IPoolComponent.sol +1 -1
  171. package/contracts/components/Pool.sol +3 -4
  172. package/contracts/components/Product.sol +137 -59
  173. package/contracts/instance/BundleManager.sol +3 -4
  174. package/contracts/instance/IInstance.sol +25 -21
  175. package/contracts/instance/IInstanceService.sol +0 -4
  176. package/contracts/instance/Instance.sol +85 -103
  177. package/contracts/instance/InstanceReader.sol +30 -4
  178. package/contracts/instance/InstanceService.sol +11 -28
  179. package/contracts/instance/base/Lifecycle.sol +12 -4
  180. package/contracts/instance/module/IPolicy.sol +11 -6
  181. package/contracts/instance/service/ApplicationService.sol +10 -5
  182. package/contracts/instance/service/BundleService.sol +8 -3
  183. package/contracts/instance/service/ClaimService.sol +111 -23
  184. package/contracts/instance/service/DistributionService.sol +14 -18
  185. package/contracts/instance/service/IApplicationService.sol +3 -7
  186. package/contracts/instance/service/IBundleService.sol +3 -0
  187. package/contracts/instance/service/IClaimService.sol +46 -15
  188. package/contracts/instance/service/IPolicyService.sol +70 -5
  189. package/contracts/instance/service/PolicyService.sol +219 -40
  190. package/contracts/instance/service/ProductService.sol +1 -1
  191. package/contracts/types/Amount.sol +5 -0
  192. package/contracts/types/ClaimId.sol +25 -2
  193. package/contracts/types/ObjectType.sol +5 -5
  194. package/contracts/types/PayoutId.sol +33 -5
  195. package/contracts/types/StateId.sol +6 -2
  196. package/contracts/types/Timestamp.sol +5 -0
  197. package/package.json +1 -1
@@ -3,18 +3,18 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
5
 
6
- import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
6
+ import {Key32} from "../types/Key32.sol";
7
7
  import {NftId} from "../types/NftId.sol";
8
8
  import {ClaimId} from "../types/ClaimId.sol";
9
- import {NumberId} from "../types/NumberId.sol";
10
- import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT, DISTRIBUTOR, DISTRIBUTOR_TYPE} from "../types/ObjectType.sol";
11
- import {RiskId, RiskIdLib} from "../types/RiskId.sol";
12
- import {RoleId, RoleIdLib, INSTANCE_ROLE, INSTANCE_OWNER_ROLE} from "../types/RoleId.sol";
13
- import {StateId, ACTIVE} from "../types/StateId.sol";
14
- import {TimestampLib} from "../types/Timestamp.sol";
9
+ import {DistributorType} from "../types/DistributorType.sol";
10
+ import {PayoutId} from "../types/PayoutId.sol";
11
+ import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, PRODUCT, DISTRIBUTOR} from "../types/ObjectType.sol";
12
+ import {ReferralId} from "../types/Referral.sol";
13
+ import {RiskId} from "../types/RiskId.sol";
14
+ import {INSTANCE_OWNER_ROLE} from "../types/RoleId.sol";
15
+ import {StateId} from "../types/StateId.sol";
15
16
  import {VersionPart, VersionPartLib} from "../types/Version.sol";
16
17
 
17
- import {ERC165} from "../shared/ERC165.sol";
18
18
  import {Registerable} from "../shared/Registerable.sol";
19
19
 
20
20
  import {IRegistry} from "../registry/IRegistry.sol";
@@ -26,7 +26,6 @@ import {BundleManager} from "./BundleManager.sol";
26
26
 
27
27
  import {KeyValueStore} from "./base/KeyValueStore.sol";
28
28
 
29
- import {IAccess} from "./module/IAccess.sol";
30
29
  import {IBundle} from "./module/IBundle.sol";
31
30
  import {IComponents} from "./module/IComponents.sol";
32
31
  import {IDistribution} from "./module/IDistribution.sol";
@@ -34,12 +33,6 @@ import {IPolicy} from "./module/IPolicy.sol";
34
33
  import {IRisk} from "./module/IRisk.sol";
35
34
  import {ISetup} from "./module/ISetup.sol";
36
35
 
37
- import {IDistributionService} from "./service/IDistributionService.sol";
38
- import {IPoolService} from "./service/IPoolService.sol";
39
- import {IProductService} from "./service/IProductService.sol";
40
- import {IPolicyService} from "./service/IPolicyService.sol";
41
- import {IBundleService} from "./service/IBundleService.sol";
42
- import {TokenHandler} from "../shared/TokenHandler.sol";
43
36
  import {VersionPart, VersionPartLib} from "../types/Version.sol";
44
37
 
45
38
  contract Instance is
@@ -123,55 +116,55 @@ contract Instance is
123
116
  }
124
117
 
125
118
  //--- DistributorType -------------------------------------------------------//
126
- function createDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info) external restricted() {
127
- create(distributorKey, abi.encode(info));
119
+ function createDistributorType(DistributorType distributorType, IDistribution.DistributorTypeInfo memory info) external restricted() {
120
+ create(distributorType.toKey32(), abi.encode(info));
128
121
  }
129
122
 
130
- function updateDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info, StateId newState) external restricted() {
131
- update(distributorKey, abi.encode(info), newState);
123
+ function updateDistributorType(DistributorType distributorType, IDistribution.DistributorTypeInfo memory info, StateId newState) external restricted() {
124
+ update(distributorType.toKey32(), abi.encode(info), newState);
132
125
  }
133
126
 
134
- function updateDistributorTypeState(Key32 distributorKey, StateId newState) external restricted() {
135
- updateState(distributorKey, newState);
127
+ function updateDistributorTypeState(DistributorType distributorType, StateId newState) external restricted() {
128
+ updateState(distributorType.toKey32(), newState);
136
129
  }
137
130
 
138
131
  //--- Distributor -------------------------------------------------------//
139
- function createDistributor(NftId nftId, IDistribution.DistributorInfo memory info) external restricted() {
140
- create(toDistributorKey32(nftId), abi.encode(info));
132
+ function createDistributor(NftId distributorNftId, IDistribution.DistributorInfo memory info) external restricted() {
133
+ create(_toNftKey32(distributorNftId, DISTRIBUTOR()), abi.encode(info));
141
134
  }
142
135
 
143
- function updateDistributor(NftId nftId, IDistribution.DistributorInfo memory info, StateId newState) external restricted() {
144
- update(toDistributorKey32(nftId), abi.encode(info), newState);
136
+ function updateDistributor(NftId distributorNftId, IDistribution.DistributorInfo memory info, StateId newState) external restricted() {
137
+ update(_toNftKey32(distributorNftId, DISTRIBUTOR()), abi.encode(info), newState);
145
138
  }
146
139
 
147
- function updateDistributorState(NftId nftId, StateId newState) external restricted() {
148
- updateState(toDistributorKey32(nftId), newState);
140
+ function updateDistributorState(NftId distributorNftId, StateId newState) external restricted() {
141
+ updateState(_toNftKey32(distributorNftId, DISTRIBUTOR()), newState);
149
142
  }
150
143
 
151
144
  //--- Referral ----------------------------------------------------------//
152
- function createReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo) external restricted() {
153
- create(referralKey, abi.encode(referralInfo));
145
+ function createReferral(ReferralId referralId, IDistribution.ReferralInfo memory referralInfo) external restricted() {
146
+ create(referralId.toKey32(), abi.encode(referralInfo));
154
147
  }
155
148
 
156
- function updateReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo, StateId newState) external restricted() {
157
- update(referralKey, abi.encode(referralInfo), newState);
149
+ function updateReferral(ReferralId referralId, IDistribution.ReferralInfo memory referralInfo, StateId newState) external restricted() {
150
+ update(referralId.toKey32(), abi.encode(referralInfo), newState);
158
151
  }
159
152
 
160
- function updateReferralState(Key32 referralKey, StateId newState) external restricted() {
161
- updateState(referralKey, newState);
153
+ function updateReferralState(ReferralId referralId, StateId newState) external restricted() {
154
+ updateState(referralId.toKey32(), newState);
162
155
  }
163
156
 
164
157
  //--- Bundle ------------------------------------------------------------//
165
158
  function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external restricted() {
166
- create(toBundleKey32(bundleNftId), abi.encode(bundle));
159
+ create(_toNftKey32(bundleNftId, BUNDLE()), abi.encode(bundle));
167
160
  }
168
161
 
169
162
  function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external restricted() {
170
- update(toBundleKey32(bundleNftId), abi.encode(bundle), newState);
163
+ update(_toNftKey32(bundleNftId, BUNDLE()), abi.encode(bundle), newState);
171
164
  }
172
165
 
173
166
  function updateBundleState(NftId bundleNftId, StateId newState) external restricted() {
174
- updateState(toBundleKey32(bundleNftId), newState);
167
+ updateState(_toNftKey32(bundleNftId, BUNDLE()), newState);
175
168
  }
176
169
 
177
170
  //--- Risk --------------------------------------------------------------//
@@ -189,50 +182,50 @@ contract Instance is
189
182
 
190
183
  //--- Application (Policy) ----------------------------------------------//
191
184
  function createApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy) external restricted() {
192
- create(toPolicyKey32(applicationNftId), abi.encode(policy));
185
+ create(_toNftKey32(applicationNftId, POLICY()), abi.encode(policy));
193
186
  }
194
187
 
195
188
  function updateApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy, StateId newState) external restricted() {
196
- update(toPolicyKey32(applicationNftId), abi.encode(policy), newState);
189
+ update(_toNftKey32(applicationNftId, POLICY()), abi.encode(policy), newState);
197
190
  }
198
191
 
199
192
  function updateApplicationState(NftId applicationNftId, StateId newState) external restricted() {
200
- updateState(toPolicyKey32(applicationNftId), newState);
193
+ updateState(_toNftKey32(applicationNftId, POLICY()), newState);
201
194
  }
202
195
 
203
196
  //--- Policy ------------------------------------------------------------//
204
197
  function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external restricted() {
205
- update(toPolicyKey32(policyNftId), abi.encode(policy), newState);
198
+ update(_toNftKey32(policyNftId, POLICY()), abi.encode(policy), newState);
206
199
  }
207
200
 
208
201
  function updatePolicyState(NftId policyNftId, StateId newState) external restricted() {
209
- updateState(toPolicyKey32(policyNftId), newState);
202
+ updateState(_toNftKey32(policyNftId, POLICY()), newState);
210
203
  }
211
204
 
212
205
  //--- Claim -------------------------------------------------------------//
213
206
  function createClaim(NftId policyNftId, ClaimId claimId, IPolicy.ClaimInfo memory claim) external restricted() {
214
- create(toPolicyKey32(policyNftId), abi.encode(claim));
207
+ create(_toClaimKey32(policyNftId, claimId), abi.encode(claim));
215
208
  }
216
209
 
217
210
  function updateClaim(NftId policyNftId, ClaimId claimId, IPolicy.ClaimInfo memory claim, StateId newState) external restricted() {
218
- update(toPolicyKey32(policyNftId), abi.encode(claim), newState);
211
+ update(_toClaimKey32(policyNftId, claimId), abi.encode(claim), newState);
219
212
  }
220
213
 
221
214
  function updateClaimState(NftId policyNftId, ClaimId claimId, StateId newState) external restricted() {
222
- updateState(toPolicyKey32(policyNftId), newState);
215
+ updateState(_toClaimKey32(policyNftId, claimId), newState);
223
216
  }
224
217
 
225
218
  //--- Payout ------------------------------------------------------------//
226
- function createPayout(NftId policyNftId, NumberId payoutId, IPolicy.PayoutInfo memory payout) external restricted() {
227
- create(toPolicyKey32(policyNftId), abi.encode(payout));
219
+ function createPayout(NftId policyNftId, PayoutId payoutId, IPolicy.PayoutInfo memory payout) external restricted() {
220
+ create(_toPayoutKey32(policyNftId, payoutId), abi.encode(payout));
228
221
  }
229
222
 
230
- function updatePayout(NftId policyNftId, NumberId payoutId, IPolicy.PayoutInfo memory payout, StateId newState) external restricted() {
231
- update(toPolicyKey32(policyNftId), abi.encode(payout), newState);
223
+ function updatePayout(NftId policyNftId, PayoutId payoutId, IPolicy.PayoutInfo memory payout, StateId newState) external restricted() {
224
+ update(_toPayoutKey32(policyNftId, payoutId), abi.encode(payout), newState);
232
225
  }
233
226
 
234
- function updatePayoutState(NftId policyNftId, StateId newState) external restricted() {
235
- updateState(toPolicyKey32(policyNftId), newState);
227
+ function updatePayoutState(NftId policyNftId, PayoutId payoutId, StateId newState) external restricted() {
228
+ updateState(_toPayoutKey32(policyNftId, payoutId), newState);
236
229
  }
237
230
 
238
231
  //--- ITransferInterceptor ------------------------------------------------------------//
@@ -246,83 +239,72 @@ contract Instance is
246
239
  assert(_accessManager.grantRole(INSTANCE_OWNER_ROLE(), to) == true);
247
240
  }
248
241
 
249
- //--- internal view/pure functions --------------------------------------//
250
- function _toNftKey32(NftId nftId, ObjectType objectType) internal pure returns (Key32) {
251
- return nftId.toKey32(objectType);
252
- }
253
-
254
- function toBundleKey32(NftId bundleNftId) public pure returns (Key32) {
255
- return bundleNftId.toKey32(BUNDLE());
256
- }
257
-
258
- function toPolicyKey32(NftId policyNftId) public pure returns (Key32) {
259
- return policyNftId.toKey32(POLICY());
260
- }
242
+ //--- initial setup functions -------------------------------------------//
261
243
 
262
- function toDistributionKey32(NftId distNftId) public pure returns (Key32) {
263
- return distNftId.toKey32(DISTRIBUTION());
264
- }
244
+ function setInstanceAccessManager(InstanceAccessManager accessManager) external restricted {
245
+ if(address(_accessManager) != address(0)) {
246
+ revert ErrorInstanceInstanceAccessManagerAlreadySet(address(_accessManager));
247
+ }
265
248
 
266
- function toDistributorTypeKey32(NftId distNftId) public pure returns (Key32) {
267
- return distNftId.toKey32(DISTRIBUTOR_TYPE());
268
- }
249
+ if(accessManager.authority() != authority()) {
250
+ revert ErrorInstanceInstanceAccessManagerAuthorityMismatch(authority());
251
+ }
269
252
 
270
- function toDistributorKey32(NftId distNftId) public pure returns (Key32) {
271
- return distNftId.toKey32(DISTRIBUTOR());
272
- }
273
-
274
- function getDistributionService() external view returns (IDistributionService) {
275
- return IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
253
+ _accessManager = accessManager;
276
254
  }
277
255
 
278
- function getProductService() external view returns (IProductService) {
279
- return IProductService(getRegistry().getServiceAddress(PRODUCT(), VersionPart.wrap(3)));
280
- }
256
+ function setBundleManager(BundleManager bundleManager) external restricted() {
257
+ if(address(_bundleManager) != address(0)) {
258
+ revert ErrorInstanceBundleManagerAlreadySet(address(_bundleManager));
259
+ }
281
260
 
282
- function getPoolService() external view returns (IPoolService) {
283
- return IPoolService(getRegistry().getServiceAddress(POOL(), VersionPart.wrap(3)));
284
- }
261
+ if(bundleManager.getInstance() != Instance(this)) {
262
+ revert ErrorInstanceBundleManagerInstanceMismatch(address(this));
263
+ }
285
264
 
286
- function getPolicyService() external view returns (IPolicyService) {
287
- return IPolicyService(getRegistry().getServiceAddress(POLICY(), VersionPart.wrap(3)));
288
- }
265
+ if(bundleManager.authority() != authority()) {
266
+ revert ErrorInstanceBundleManagerAuthorityMismatch(authority());
267
+ }
289
268
 
290
- function getBundleService() external view returns (IBundleService) {
291
- return IBundleService(getRegistry().getServiceAddress(BUNDLE(), VersionPart.wrap(3)));
269
+ _bundleManager = bundleManager;
292
270
  }
293
271
 
294
272
  function setInstanceReader(InstanceReader instanceReader) external restricted() {
295
- require(instanceReader.getInstance() == Instance(this), "InstanceReader instance mismatch");
273
+ if(instanceReader.getInstance() != Instance(this)) {
274
+ revert ErrorInstanceInstanceReaderInstanceMismatch(address(this));
275
+ }
276
+
296
277
  _instanceReader = instanceReader;
297
278
  }
298
279
 
299
- function getMajorVersion() external pure returns (VersionPart majorVersion) {
300
- return VersionPartLib.toVersionPart(GIF_MAJOR_VERSION);
301
- }
280
+ //--- external view functions -------------------------------------------//
302
281
 
303
282
  function getInstanceReader() external view returns (InstanceReader) {
304
283
  return _instanceReader;
305
284
  }
306
-
307
- function setBundleManager(BundleManager bundleManager) external restricted() {
308
- require(address(_bundleManager) == address(0), "BundleManager is set");
309
- require(bundleManager.getInstance() == Instance(this), "BundleManager instance mismatch");
310
- require(bundleManager.authority() == authority(), "BundleManager authority mismatch");
311
- _bundleManager = bundleManager;
312
- }
313
285
 
314
286
  function getBundleManager() external view returns (BundleManager) {
315
287
  return _bundleManager;
316
288
  }
317
289
 
318
- function setInstanceAccessManager(InstanceAccessManager accessManager) external restricted {
319
- require(address(_accessManager) == address(0), "InstanceAccessManager is set");
320
- require(accessManager.authority() == authority(), "InstanceAccessManager authority mismatch");
321
- _accessManager = accessManager;
322
- }
323
-
324
290
  function getInstanceAccessManager() external view returns (InstanceAccessManager) {
325
291
  return _accessManager;
326
292
  }
327
-
293
+
294
+ function getMajorVersion() external pure returns (VersionPart majorVersion) {
295
+ return VersionPartLib.toVersionPart(GIF_MAJOR_VERSION);
296
+ }
297
+
298
+ //--- internal view/pure functions --------------------------------------//
299
+ function _toNftKey32(NftId nftId, ObjectType objectType) private pure returns (Key32) {
300
+ return nftId.toKey32(objectType);
301
+ }
302
+
303
+ function _toClaimKey32(NftId policyNftId, ClaimId claimId) private pure returns (Key32) {
304
+ return claimId.toKey32(policyNftId);
305
+ }
306
+
307
+ function _toPayoutKey32(NftId policyNftId, PayoutId payoutId) private pure returns (Key32) {
308
+ return payoutId.toKey32(policyNftId);
309
+ }
328
310
  }
@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
+ import {ClaimId} from "../types/ClaimId.sol";
6
7
  import {DistributorType} from "../types/DistributorType.sol";
7
8
  import {Fee, FeeLib} from "../types/Fee.sol";
8
9
  import {Key32} from "../types/Key32.sol";
@@ -29,17 +30,23 @@ import {TimestampLib} from "../types/Timestamp.sol";
29
30
 
30
31
 
31
32
  contract InstanceReader {
33
+
34
+ error ErrorInstanceReaderAlreadyInitialized();
35
+ error ErrorInstanceReaderInstanceAddressZero();
36
+
32
37
  bool private _initialized;
33
38
 
34
39
  IInstance internal _instance;
35
40
  IKeyValueStore internal _store;
36
41
 
37
42
  function initialize(address instance) public {
38
- require(!_initialized, "ERROR:CRD-000:ALREADY_INITIALIZED");
43
+ if(_initialized) {
44
+ revert ErrorInstanceReaderAlreadyInitialized();
45
+ }
39
46
 
40
- require(
41
- address(instance) != address(0),
42
- "ERROR:CRD-001:INSTANCE_ZERO");
47
+ if(address(instance) == address(0)) {
48
+ revert ErrorInstanceReaderInstanceAddressZero();
49
+ }
43
50
 
44
51
  _instance = IInstance(instance);
45
52
  _store = IKeyValueStore(instance);
@@ -69,6 +76,25 @@ contract InstanceReader {
69
76
  return _instance.getState(toPolicyKey(policyNftId));
70
77
  }
71
78
 
79
+ function getClaimInfo(NftId policyNftId, ClaimId claimId)
80
+ public
81
+ view
82
+ returns (IPolicy.ClaimInfo memory info)
83
+ {
84
+ bytes memory data = _store.getData(claimId.toKey32(policyNftId));
85
+ if (data.length > 0) {
86
+ return abi.decode(data, (IPolicy.ClaimInfo));
87
+ }
88
+ }
89
+
90
+ function getClaimState(NftId policyNftId, ClaimId claimId)
91
+ public
92
+ view
93
+ returns (StateId state)
94
+ {
95
+ return _instance.getState(claimId.toKey32(policyNftId));
96
+ }
97
+
72
98
  function getRiskInfo(RiskId riskId)
73
99
  public
74
100
  view
@@ -13,16 +13,11 @@ import {BundleManager} from "./BundleManager.sol";
13
13
  import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
14
14
  import {IRegistry} from "../registry/IRegistry.sol";
15
15
  import {IRegistryService} from "../registry/IRegistryService.sol";
16
- import {ChainNft} from "../registry/ChainNft.sol";
17
16
  import {Service} from "../../contracts/shared/Service.sol";
18
- import {IService} from "../shared/IService.sol";
19
17
  import {NftId} from "../../contracts/types/NftId.sol";
20
18
  import {RoleId} from "../types/RoleId.sol";
21
19
  import {ADMIN_ROLE, INSTANCE_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, APPLICATION_SERVICE_ROLE, POLICY_SERVICE_ROLE, CLAIM_SERVICE_ROLE, BUNDLE_SERVICE_ROLE, INSTANCE_ROLE} from "../types/RoleId.sol";
22
20
  import {ObjectType, INSTANCE, BUNDLE, APPLICATION, POLICY, CLAIM, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
23
- import {IDistributionComponent} from "../components/IDistributionComponent.sol";
24
- import {IPoolComponent} from "../components/IPoolComponent.sol";
25
- import {IProductComponent} from "../components/IProductComponent.sol";
26
21
 
27
22
  contract InstanceService is
28
23
  Service,
@@ -72,10 +67,9 @@ contract InstanceService is
72
67
  {
73
68
  address instanceOwner = msg.sender;
74
69
  IRegistry registry = getRegistry();
75
- address registryAddress = address(registry);
76
- NftId registryNftId = registry.getNftId(registryAddress);
77
- address registryServiceAddress = registry.getServiceAddress(REGISTRY(), getVersion().toMajorPart());
78
- IRegistryService registryService = IRegistryService(registryServiceAddress);
70
+ IRegistryService registryService = IRegistryService(
71
+ registry.getServiceAddress(
72
+ REGISTRY(), getVersion().toMajorPart()));
79
73
 
80
74
  clonedOzAccessManager = AccessManagerUpgradeableInitializeable(
81
75
  Clones.clone(_masterOzAccessManager));
@@ -89,7 +83,7 @@ contract InstanceService is
89
83
  clonedInstance = Instance(Clones.clone(_masterInstance));
90
84
  clonedInstance.initialize(
91
85
  address(clonedOzAccessManager),
92
- registryAddress,
86
+ address(registry),
93
87
  instanceOwner);
94
88
 
95
89
  clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
@@ -113,7 +107,6 @@ contract InstanceService is
113
107
 
114
108
  IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
115
109
  clonedInstanceNftId = info.nftId;
116
- // clonedInstance.linkToRegisteredNftId();
117
110
 
118
111
  emit LogInstanceCloned(
119
112
  address(clonedOzAccessManager),
@@ -248,11 +241,12 @@ contract InstanceService is
248
241
  function _grantClaimServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
249
242
  // configure authorization for claim/payout services on instance
250
243
  address claimServiceAddress = getRegistry().getServiceAddress(CLAIM(), getVersion().toMajorPart());
251
- clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), claimServiceAddress);
252
- // TODO add claims function authz
253
- bytes4[] memory instanceClaimServiceSelectors = new bytes4[](0);
254
- // instanceClaimServiceSelectors[0] = clonedInstance.updatePolicy.selector;
255
- // instanceClaimServiceSelectors[1] = clonedInstance.updatePolicyState.selector;
244
+ clonedAccessManager.grantRole(CLAIM_SERVICE_ROLE(), claimServiceAddress);
245
+ bytes4[] memory instanceClaimServiceSelectors = new bytes4[](4);
246
+ instanceClaimServiceSelectors[0] = clonedInstance.createClaim.selector;
247
+ instanceClaimServiceSelectors[1] = clonedInstance.updateClaim.selector;
248
+ instanceClaimServiceSelectors[2] = clonedInstance.createPayout.selector;
249
+ instanceClaimServiceSelectors[3] = clonedInstance.updatePayout.selector;
256
250
  clonedAccessManager.setCoreTargetFunctionRole(
257
251
  "Instance",
258
252
  instanceClaimServiceSelectors,
@@ -395,18 +389,6 @@ contract InstanceService is
395
389
  return _masterInstanceReader;
396
390
  }
397
391
 
398
- function getMasterInstance() external view returns (address) {
399
- return _masterInstance;
400
- }
401
-
402
- function getMasterInstanceAccessManager() external view returns (address) {
403
- return _masterInstanceAccessManager;
404
- }
405
-
406
- function getMasterInstanceBundleManager() external view returns (address) {
407
- return _masterInstanceBundleManager;
408
- }
409
-
410
392
  // From IService
411
393
  function getDomain() public pure override returns(ObjectType) {
412
394
  return INSTANCE();
@@ -460,6 +442,7 @@ contract InstanceService is
460
442
  // TODO called by component, but target can be component helper...so needs target name
461
443
  // TODO check that targetName associated with component...how???
462
444
  function setComponentLocked(bool locked) onlyComponent external {
445
+
463
446
  address componentAddress = msg.sender;
464
447
  IRegistry registry = getRegistry();
465
448
  NftId instanceNftId = registry.getObjectInfo(componentAddress).parentNftId;
@@ -4,8 +4,8 @@ pragma solidity ^0.8.20;
4
4
  import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
5
 
6
6
  import {NftId} from "../../types/NftId.sol";
7
- import {ObjectType, COMPONENT, BUNDLE, POLICY, RISK} from "../../types/ObjectType.sol";
8
- import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, UNDERWRITTEN, REVOKED, DECLINED} from "../../types/StateId.sol";
7
+ import {ObjectType, COMPONENT, BUNDLE, POLICY, RISK, CLAIM} from "../../types/ObjectType.sol";
8
+ import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, COLLATERALIZED, REVOKED, SUBMITTED, CONFIRMED, DECLINED} from "../../types/StateId.sol";
9
9
  import {ILifecycle} from "./ILifecycle.sol";
10
10
 
11
11
  contract Lifecycle is
@@ -25,6 +25,7 @@ contract Lifecycle is
25
25
  _setupBundleLifecycle();
26
26
  _setupComponentLifecycle();
27
27
  _setupPolicyLifecycle();
28
+ _setupClaimLifecycle();
28
29
  _setupRiskLifecycle();
29
30
  }
30
31
 
@@ -95,11 +96,18 @@ contract Lifecycle is
95
96
  _initialState[POLICY()] = APPLIED();
96
97
  _isValidTransition[POLICY()][APPLIED()][REVOKED()] = true;
97
98
  _isValidTransition[POLICY()][APPLIED()][DECLINED()] = true;
98
- _isValidTransition[POLICY()][APPLIED()][UNDERWRITTEN()] = true;
99
- _isValidTransition[POLICY()][UNDERWRITTEN()][ACTIVE()] = true;
99
+ _isValidTransition[POLICY()][APPLIED()][COLLATERALIZED()] = true;
100
+ _isValidTransition[POLICY()][COLLATERALIZED()][ACTIVE()] = true;
100
101
  _isValidTransition[POLICY()][ACTIVE()][CLOSED()] = true;
101
102
  }
102
103
 
104
+ function _setupClaimLifecycle() internal {
105
+ _initialState[CLAIM()] = SUBMITTED();
106
+ _isValidTransition[CLAIM()][SUBMITTED()][CONFIRMED()] = true;
107
+ _isValidTransition[CLAIM()][SUBMITTED()][DECLINED()] = true;
108
+ _isValidTransition[CLAIM()][CONFIRMED()][CLOSED()] = true;
109
+ }
110
+
103
111
  function _setupRiskLifecycle() internal {
104
112
  _initialState[RISK()] = ACTIVE();
105
113
  _isValidTransition[RISK()][ACTIVE()][PAUSED()] = true;
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {Amount} from "../../types/Amount.sol";
4
5
  import {NftId} from "../../types/NftId.sol";
5
6
  import {ClaimId} from "../../types/ClaimId.sol";
6
7
  import {ReferralId} from "../../types/Referral.sol";
@@ -42,13 +43,13 @@ interface IPolicy {
42
43
  RiskId riskId;
43
44
  uint256 sumInsuredAmount;
44
45
  uint256 premiumAmount;
45
- uint256 premiumPaidAmount;
46
+ uint256 premiumPaidAmount; // when lower than premium amount: max payout decreased accordingly
46
47
  Seconds lifetime;
47
48
  bytes applicationData;
48
49
  bytes policyData;
49
50
  uint16 claimsCount;
50
51
  uint16 openClaimsCount;
51
- uint256 payoutAmount;
52
+ Amount payoutAmount;
52
53
  Timestamp activatedAt; // time of underwriting
53
54
  Timestamp expiredAt; // no new claims (activatedAt + lifetime)
54
55
  Timestamp closedAt; // no locked capital (or declinedAt)
@@ -56,16 +57,20 @@ interface IPolicy {
56
57
 
57
58
  // claimId neeeds to be encoded policyNftId:claimId combination
58
59
  struct ClaimInfo {
59
- uint256 claimAmount;
60
- uint256 paidAmount;
60
+ Amount claimAmount;
61
+ Amount paidAmount;
62
+ uint8 payoutsCount;
63
+ uint8 openPayoutsCount;
61
64
  bytes data;
62
- Timestamp closedAt; // payoment of confirmed claim amount (or declinedAt)
65
+ // TODO consider to add processData that may include information supporting confirm or decline
66
+ Timestamp closedAt; // payment of confirmed claim amount (or declinedAt)
63
67
  }
64
68
 
65
69
  // claimId neeeds to be encoded policyNftId:claimId combination
66
70
  struct PayoutInfo {
67
71
  ClaimId claimId;
68
- uint256 amount;
72
+ Amount amount;
73
+ // TODO consider to add a beneficiary address that will be the receiver of the payout tokens
69
74
  bytes data;
70
75
  Timestamp paidAt; // payoment of confirmed claim amount (or declinedAt)
71
76
  }
@@ -23,12 +23,13 @@ import {TokenHandler} from "../../shared/TokenHandler.sol";
23
23
  import {IVersionable} from "../../shared/IVersionable.sol";
24
24
  import {Versionable} from "../../shared/Versionable.sol";
25
25
 
26
+ import {AmountLib} from "../../types/Amount.sol";
26
27
  import {Seconds} from "../../types/Seconds.sol";
27
28
  import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
28
29
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
29
30
  import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
30
31
  import {ObjectType, DISTRIBUTION, INSTANCE, PRODUCT, POOL, APPLICATION, POLICY, BUNDLE} from "../../types/ObjectType.sol";
31
- import {APPLIED, REVOKED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
32
+ import {APPLIED, REVOKED, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
32
33
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
33
34
  import {Fee, FeeLib} from "../../types/Fee.sol";
34
35
  import {ReferralId} from "../../types/Referral.sol";
@@ -129,7 +130,7 @@ contract ApplicationService is
129
130
  "",
130
131
  0,
131
132
  0,
132
- 0,
133
+ AmountLib.zero(),
133
134
  zeroTimestamp(),
134
135
  zeroTimestamp(),
135
136
  zeroTimestamp()
@@ -262,7 +263,7 @@ contract ApplicationService is
262
263
  {
263
264
  IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
264
265
  if(bundleInfo.poolNftId != poolNftId) {
265
- revert IApplicationServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, poolNftId);
266
+ revert ErrorApplicationServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, poolNftId);
266
267
  }
267
268
  uint256 t = bundleInfo.fee.fixedFee;
268
269
  premium.bundleFeeFixAmount = t;
@@ -316,7 +317,7 @@ contract ApplicationService is
316
317
  {
317
318
  IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
318
319
  if(bundleInfo.poolNftId != poolNftId) {
319
- revert IApplicationServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, poolNftId);
320
+ revert ErrorApplicationServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, poolNftId);
320
321
  }
321
322
  uint256 t = (UFixedLib.toUFixed(netPremiumAmount) * bundleInfo.fee.fractionalFee).toInt();
322
323
  premium.bundleFeeVarAmount = t;
@@ -344,7 +345,11 @@ contract ApplicationService is
344
345
  function _getAndVerifyProduct(NftId productNftId) internal view returns (Product product) {
345
346
  IRegistry registry = getRegistry();
346
347
  IRegistry.ObjectInfo memory productInfo = registry.getObjectInfo(productNftId);
347
- require(productInfo.objectType == PRODUCT(), "OBJECT_TYPE_INVALID");
348
+
349
+ if(productInfo.objectType != PRODUCT()) {
350
+ revert ErrorApplicationServiceNotProduct(productNftId, productInfo.objectType);
351
+ }
352
+
348
353
  product = Product(productInfo.objectAddress);
349
354
  }
350
355
  }
@@ -182,8 +182,13 @@ contract BundleService is
182
182
  InstanceReader instanceReader = instance.getInstanceReader();
183
183
 
184
184
  IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
185
- require(bundleInfo.poolNftId.gtz(), "ERROR:PLS-010:BUNDLE_UNKNOWN");
186
- require(poolNftId == bundleInfo.poolNftId, "ERROR:PLS-011:BUNDLE_POOL_MISMATCH");
185
+ if(bundleInfo.poolNftId.eqz()) {
186
+ revert ErrorBundleServiceBundleUnknown(bundleNftId);
187
+ }
188
+
189
+ if(bundleInfo.poolNftId != poolNftId) {
190
+ revert ErrorBundleServiceBundlePoolMismatch(poolNftId, bundleInfo.poolNftId );
191
+ }
187
192
 
188
193
  bundleInfo.fee = fee;
189
194
 
@@ -385,7 +390,7 @@ contract BundleService is
385
390
 
386
391
  // ensure policy is closeable
387
392
  if ( TimestampLib.blockTimestamp() < policyInfo.expiredAt
388
- && policyInfo.payoutAmount < policyInfo.sumInsuredAmount)
393
+ && policyInfo.payoutAmount.toInt() < policyInfo.sumInsuredAmount)
389
394
  {
390
395
  revert BundleManager.ErrorBundleManagerPolicyNotCloseable(policyNftId);
391
396
  }