@etherisc/gif-next 0.0.2-e922e07-736 → 0.0.2-e94f4c7-084

Sign up to get free protection for your applications and to get access to all the features.
Files changed (262) 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 +84 -0
  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 +158 -0
  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 +457 -268
  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 +426 -476
  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 +217 -169
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +304 -210
  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 +175 -83
  60. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  61. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +29 -13
  62. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +426 -233
  64. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +78 -14
  66. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +372 -86
  68. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +55 -7
  70. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +189 -139
  72. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +48 -56
  74. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +111 -40
  76. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +246 -170
  78. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +251 -58
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +101 -24
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +470 -41
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +627 -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 +607 -85
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +71 -19
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +777 -55
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +72 -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 +209 -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/ClaimId.sol/ClaimIdLib.json +83 -4
  168. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  170. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
  172. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  173. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  174. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  176. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  177. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  178. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  181. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +116 -7
  183. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  185. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  187. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  189. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  190. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  192. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +17 -4
  194. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  196. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  198. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  200. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  201. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  202. package/contracts/components/Component.sol +42 -10
  203. package/contracts/components/Distribution.sol +6 -2
  204. package/contracts/components/IComponent.sol +9 -1
  205. package/contracts/components/IPoolComponent.sol +6 -44
  206. package/contracts/components/Pool.sol +50 -126
  207. package/contracts/components/Product.sol +141 -59
  208. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
  209. package/contracts/instance/BundleManager.sol +9 -8
  210. package/contracts/instance/Cloneable.sol +7 -2
  211. package/contracts/instance/IInstance.sol +37 -27
  212. package/contracts/instance/IInstanceService.sol +18 -9
  213. package/contracts/instance/Instance.sol +117 -98
  214. package/contracts/instance/InstanceAccessManager.sol +388 -158
  215. package/contracts/instance/InstanceReader.sol +36 -12
  216. package/contracts/instance/InstanceService.sol +193 -204
  217. package/contracts/instance/ObjectManager.sol +6 -8
  218. package/contracts/instance/base/ComponentService.sol +17 -30
  219. package/contracts/instance/base/KeyValueStore.sol +13 -5
  220. package/contracts/instance/base/Lifecycle.sol +23 -6
  221. package/contracts/instance/module/IAccess.sol +21 -14
  222. package/contracts/instance/module/IBundle.sol +6 -4
  223. package/contracts/instance/module/IComponents.sol +41 -0
  224. package/contracts/instance/module/IPolicy.sol +11 -6
  225. package/contracts/instance/module/ISetup.sol +3 -16
  226. package/contracts/instance/service/ApplicationService.sol +25 -19
  227. package/contracts/instance/service/BundleService.sol +224 -80
  228. package/contracts/instance/service/ClaimService.sol +114 -26
  229. package/contracts/instance/service/DistributionService.sol +58 -77
  230. package/contracts/instance/service/IApplicationService.sol +3 -7
  231. package/contracts/instance/service/IBundleService.sol +72 -25
  232. package/contracts/instance/service/IClaimService.sol +46 -15
  233. package/contracts/instance/service/IDistributionService.sol +1 -0
  234. package/contracts/instance/service/IPolicyService.sol +72 -5
  235. package/contracts/instance/service/IPoolService.sol +85 -3
  236. package/contracts/instance/service/PolicyService.sol +320 -143
  237. package/contracts/instance/service/PoolService.sol +245 -18
  238. package/contracts/instance/service/ProductService.sol +31 -54
  239. package/contracts/registry/ChainNft.sol +8 -0
  240. package/contracts/registry/IRegistry.sol +2 -0
  241. package/contracts/registry/IRegistryService.sol +4 -3
  242. package/contracts/registry/ITransferInterceptor.sol +1 -0
  243. package/contracts/registry/Registry.sol +23 -20
  244. package/contracts/registry/RegistryService.sol +10 -11
  245. package/contracts/registry/ReleaseManager.sol +20 -18
  246. package/contracts/shared/IService.sol +4 -6
  247. package/contracts/shared/Service.sol +21 -7
  248. package/contracts/shared/TokenHandler.sol +11 -5
  249. package/contracts/test/TestService.sol +1 -1
  250. package/contracts/types/Amount.sol +70 -0
  251. package/contracts/types/Blocknumber.sol +1 -0
  252. package/contracts/types/ClaimId.sol +25 -2
  253. package/contracts/types/Fee.sol +13 -5
  254. package/contracts/types/NftId.sol +8 -0
  255. package/contracts/types/ObjectType.sol +6 -5
  256. package/contracts/types/PayoutId.sol +33 -5
  257. package/contracts/types/RoleId.sol +6 -4
  258. package/contracts/types/StateId.sol +7 -2
  259. package/contracts/types/Timestamp.sol +6 -0
  260. package/contracts/types/UFixed.sol +1 -0
  261. package/contracts/types/Version.sol +1 -0
  262. package/package.json +1 -1
@@ -22,18 +22,19 @@ import {TokenHandler} from "../../shared/TokenHandler.sol";
22
22
  import {IVersionable} from "../../shared/IVersionable.sol";
23
23
  import {Versionable} from "../../shared/Versionable.sol";
24
24
 
25
+ import {Amount, AmountLib} from "../../types/Amount.sol";
25
26
  import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
26
27
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
27
28
  import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
28
29
  import {ObjectType, INSTANCE, PRODUCT, POOL, APPLICATION, POLICY, CLAIM, BUNDLE} from "../../types/ObjectType.sol";
29
- import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
30
+ import {SUBMITTED, ACTIVE, KEEP_STATE, DECLINED, CONFIRMED, CLOSED} from "../../types/StateId.sol";
30
31
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
31
32
  import {Fee, FeeLib} from "../../types/Fee.sol";
32
33
  import {ReferralId} from "../../types/Referral.sol";
33
34
  import {RiskId} from "../../types/RiskId.sol";
34
35
  import {StateId} from "../../types/StateId.sol";
35
- import {ClaimId} from "../../types/ClaimId.sol";
36
- import {PayoutId} from "../../types/PayoutId.sol";
36
+ import {ClaimId, ClaimIdLib} from "../../types/ClaimId.sol";
37
+ import {PayoutId, PayoutIdLib} from "../../types/PayoutId.sol";
37
38
  import {Version, VersionLib} from "../../types/Version.sol";
38
39
 
39
40
  import {ComponentService} from "../base/ComponentService.sol";
@@ -50,6 +51,7 @@ contract ClaimService is
50
51
  IClaimService
51
52
  {
52
53
 
54
+ IPoolService internal _poolService;
53
55
 
54
56
  function _initialize(
55
57
  address owner,
@@ -64,77 +66,140 @@ contract ClaimService is
64
66
  address initialOwner;
65
67
  (registryAddress, initialOwner) = abi.decode(data, (address, address));
66
68
 
67
- initializeService(registryAddress, owner);
69
+ initializeService(registryAddress, address(0), owner);
70
+
71
+ _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getVersion().toMajorPart()));
72
+
68
73
  registerInterface(type(IClaimService).interfaceId);
69
74
  }
70
75
 
71
76
 
72
- function getDomain() public pure override(IService, Service) returns(ObjectType) {
77
+ function getDomain() public pure override returns(ObjectType) {
73
78
  return CLAIM();
74
79
  }
75
80
 
76
81
 
77
- function createClaim(
82
+ function submit(
83
+ IInstance instance,
78
84
  NftId policyNftId,
79
- uint256 claimAmount,
85
+ ClaimId claimId,
86
+ Amount claimAmount,
80
87
  bytes memory claimData
81
88
  )
82
89
  external
83
90
  virtual
84
- returns (ClaimId)
91
+ // TODO add restricted and grant to policy service
85
92
  {
86
-
93
+ instance.createClaim(
94
+ policyNftId,
95
+ claimId,
96
+ IPolicy.ClaimInfo(
97
+ claimAmount,
98
+ AmountLib.zero(), // paidAmount
99
+ 0, // payoutsCount
100
+ 0, // openPayoutsCount
101
+ claimData,
102
+ TimestampLib.zero())); // closedAt
87
103
  }
88
104
 
89
105
 
90
- function confirmClaim(NftId policyNftId, ClaimId claimId, uint256 claimAmount)
106
+ function confirm(
107
+ IInstance instance,
108
+ InstanceReader instanceReader,
109
+ NftId policyNftId,
110
+ ClaimId claimId,
111
+ Amount confirmedAmount
112
+ )
91
113
  external
92
114
  virtual
93
- // solhint-disable-next-line no-empty-blocks
94
115
  {
95
-
116
+ IPolicy.ClaimInfo memory claimInfo = _verifyClaim(instanceReader, policyNftId, claimId, SUBMITTED());
117
+ claimInfo.claimAmount = confirmedAmount;
118
+ instance.updateClaim(policyNftId, claimId, claimInfo, CONFIRMED());
96
119
  }
97
120
 
98
-
99
- function declineClaim(NftId policyNftId, ClaimId claimId)
121
+ function decline(
122
+ IInstance instance,
123
+ InstanceReader instanceReader,
124
+ NftId policyNftId,
125
+ ClaimId claimId
126
+ )
100
127
  external
101
128
  virtual
102
- // solhint-disable-next-line no-empty-blocks
103
129
  {
104
-
130
+ IPolicy.ClaimInfo memory claimInfo = _verifyClaim(instanceReader, policyNftId, claimId, SUBMITTED());
131
+ claimInfo.closedAt = TimestampLib.blockTimestamp();
132
+ instance.updateClaim(policyNftId, claimId, claimInfo, DECLINED());
105
133
  }
106
134
 
107
135
 
108
- function closeClaim(NftId policyNftId, ClaimId claimId)
136
+ function close(
137
+ IInstance instance,
138
+ InstanceReader instanceReader,
139
+ NftId policyNftId,
140
+ ClaimId claimId
141
+ )
109
142
  external
110
143
  virtual
111
- // solhint-disable-next-line no-empty-blocks
112
144
  {
113
-
145
+ IPolicy.ClaimInfo memory claimInfo = _verifyClaim(instanceReader, policyNftId, claimId, CONFIRMED());
146
+
147
+ // check claim has no open payouts
148
+ if(claimInfo.openPayoutsCount > 0) {
149
+ revert ErrorClaimServiceClaimWithOpenPayouts(
150
+ policyNftId,
151
+ claimId,
152
+ claimInfo.openPayoutsCount);
153
+ }
154
+
155
+ // check claim paid amount matches with claim amount
156
+ if(claimInfo.paidAmount.toInt() < claimInfo.claimAmount.toInt()) {
157
+ revert ErrorClaimServiceClaimWithMissingPayouts(
158
+ policyNftId,
159
+ claimId,
160
+ claimInfo.claimAmount,
161
+ claimInfo.paidAmount);
162
+ }
163
+
164
+ claimInfo.closedAt = TimestampLib.blockTimestamp();
165
+ instance.updateClaim(policyNftId, claimId, claimInfo, CLOSED());
114
166
  }
115
167
 
116
168
 
117
169
  function createPayout(
170
+ IInstance instance,
118
171
  NftId policyNftId,
119
- ClaimId claimId,
120
- uint256 payoutAmount,
172
+ PayoutId payoutId,
173
+ Amount payoutAmount,
121
174
  bytes calldata payoutData
122
175
  )
123
176
  external
124
177
  virtual
125
- returns(PayoutId payoutId)
126
- // solhint-disable-next-line no-empty-blocks
178
+ // TODO add restricted and grant to policy service
127
179
  {
128
-
180
+ instance.createPayout(
181
+ policyNftId,
182
+ payoutId,
183
+ IPolicy.PayoutInfo(
184
+ payoutId.toClaimId(),
185
+ payoutAmount,
186
+ payoutData,
187
+ TimestampLib.zero()));
129
188
  }
130
189
 
131
190
 
132
- function payoutExecuted(
191
+ function processPayout(
192
+ IInstance instance,
193
+ InstanceReader instanceReader,
133
194
  NftId policyNftId,
134
195
  PayoutId payoutId
135
196
  )
136
197
  external
137
198
  virtual
199
+ returns (
200
+ Amount amount,
201
+ bool payoutIsClosingClaim
202
+ )
138
203
  // solhint-disable-next-line no-empty-blocks
139
204
  {
140
205
 
@@ -143,9 +208,32 @@ contract ClaimService is
143
208
 
144
209
  // internal functions
145
210
 
211
+ function _verifyClaim(
212
+ InstanceReader instanceReader,
213
+ NftId policyNftId,
214
+ ClaimId claimId,
215
+ StateId expectedState
216
+ )
217
+ internal
218
+ view
219
+ returns (
220
+ IPolicy.ClaimInfo memory claimInfo
221
+ )
222
+ {
223
+ // check claim is created state
224
+ StateId claimState = instanceReader.getClaimState(policyNftId, claimId);
225
+ if(claimState != expectedState) {
226
+ revert ErrorClaimServiceClaimNotInExpectedState(
227
+ policyNftId, claimId, expectedState, claimState);
228
+ }
229
+
230
+ // get claim info
231
+ claimInfo = instanceReader.getClaimInfo(policyNftId, claimId);
232
+ }
233
+
146
234
  function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
147
235
  IRegistry.ObjectInfo memory productInfo;
148
- (productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
236
+ (, productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
149
237
  product = Product(productInfo.objectAddress);
150
238
  }
151
239
  }
@@ -10,10 +10,11 @@ import {IPolicy} from "../module/IPolicy.sol";
10
10
 
11
11
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
12
12
  import {Fee, FeeLib} from "../../types/Fee.sol";
13
- import {DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
13
+ import {PRODUCT_SERVICE_ROLE, DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
14
14
  import {KEEP_STATE} from "../../types/StateId.sol";
15
15
  import {ObjectType, DISTRIBUTION, INSTANCE, DISTRIBUTION, DISTRIBUTOR} from "../../types/ObjectType.sol";
16
16
  import {Version, VersionLib} from "../../types/Version.sol";
17
+ import {RoleId} from "../../types/RoleId.sol";
17
18
 
18
19
  import {IVersionable} from "../../shared/IVersionable.sol";
19
20
  import {Versionable} from "../../shared/Versionable.sol";
@@ -59,11 +60,11 @@ contract DistributionService is
59
60
  (registryAddress, initialOwner) = abi.decode(data, (address, address));
60
61
  // TODO while DistributionService is not deployed in DistributionServiceManager constructor
61
62
  // owner is DistributionServiceManager deployer
62
- initializeService(registryAddress, owner);
63
+ initializeService(registryAddress, address(0), owner);
63
64
  registerInterface(type(IDistributionService).interfaceId);
64
65
  }
65
66
 
66
- function getDomain() public pure override(Service, IService) returns(ObjectType) {
67
+ function getDomain() public pure override returns(ObjectType) {
67
68
  return DISTRIBUTION();
68
69
  }
69
70
 
@@ -87,8 +88,24 @@ contract DistributionService is
87
88
  distributionNftId = distributionInfo.nftId;
88
89
 
89
90
  instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
90
- getInstanceService().createGifTarget(instanceNftId, distributionAddress, distribution.getName());
91
- getInstanceService().grantDistributionDefaultPermissions(instanceNftId, distributionAddress, distribution.getName());
91
+ // TODO move to distribution?
92
+ bytes4[][] memory selectors = new bytes4[][](2);
93
+ selectors[0] = new bytes4[](1);
94
+ selectors[1] = new bytes4[](2);
95
+
96
+ selectors[0][0] = IDistributionComponent.setFees.selector;
97
+ selectors[1][0] = IDistributionComponent.processRenewal.selector;
98
+
99
+ RoleId[] memory roles = new RoleId[](2);
100
+ roles[0] = DISTRIBUTION_OWNER_ROLE();
101
+ roles[1] = PRODUCT_SERVICE_ROLE();
102
+
103
+ getInstanceService().createGifTarget(
104
+ instanceNftId,
105
+ distributionAddress,
106
+ distribution.getName(),
107
+ selectors,
108
+ roles);
92
109
  }
93
110
 
94
111
  function setFees(
@@ -102,9 +119,8 @@ contract DistributionService is
102
119
  revert ErrorIDistributionServiceMinFeeTooHigh(minDistributionOwnerFee.fractionalFee.toInt(), distributionFee.fractionalFee.toInt());
103
120
  }
104
121
 
105
- (IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
122
+ (NftId distributionNftId, IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
106
123
  InstanceReader instanceReader = instance.getInstanceReader();
107
- NftId distributionNftId = info.nftId;
108
124
 
109
125
  ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
110
126
  distSetupInfo.minDistributionOwnerFee = minDistributionOwnerFee;
@@ -127,7 +143,7 @@ contract DistributionService is
127
143
  external
128
144
  returns (DistributorType distributorType)
129
145
  {
130
- (,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
146
+ (NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
131
147
 
132
148
  {
133
149
  ISetup.DistributionSetupInfo memory setupInfo = instance.getInstanceReader().getDistributionSetupInfo(distributionNftId);
@@ -139,22 +155,18 @@ contract DistributionService is
139
155
  }
140
156
 
141
157
  distributorType = DistributorTypeLib.toDistributorType(distributionNftId, name);
142
- Key32 key32 = distributorType.toKey32();
143
-
144
- if(!instance.exists(key32)) {
145
- IDistribution.DistributorTypeInfo memory info = IDistribution.DistributorTypeInfo(
146
- name,
147
- minDiscountPercentage,
148
- maxDiscountPercentage,
149
- commissionPercentage,
150
- maxReferralCount,
151
- maxReferralLifetime,
152
- allowSelfReferrals,
153
- allowRenewals,
154
- data);
155
-
156
- instance.createDistributorType(key32, info);
157
- }
158
+ IDistribution.DistributorTypeInfo memory info = IDistribution.DistributorTypeInfo(
159
+ name,
160
+ minDiscountPercentage,
161
+ maxDiscountPercentage,
162
+ commissionPercentage,
163
+ maxReferralCount,
164
+ maxReferralLifetime,
165
+ allowSelfReferrals,
166
+ allowRenewals,
167
+ data);
168
+
169
+ instance.createDistributorType(distributorType, info);
158
170
  }
159
171
 
160
172
  function createDistributor(
@@ -163,7 +175,7 @@ contract DistributionService is
163
175
  bytes memory data
164
176
  ) external returns (NftId distributorNftId)
165
177
  {
166
- (, NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
178
+ (NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
167
179
 
168
180
  distributorNftId = getRegistryService().registerDistributor(
169
181
  IRegistry.ObjectInfo(
@@ -192,7 +204,7 @@ contract DistributionService is
192
204
  bytes memory data
193
205
  ) external virtual
194
206
  {
195
- (,, IInstance instance) = _getAndVerifyCallingDistribution();
207
+ (, IInstance instance) = _getAndVerifyCallingDistribution();
196
208
  InstanceReader instanceReader = instance.getInstanceReader();
197
209
  IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
198
210
  distributorInfo.distributorType = distributorType;
@@ -213,7 +225,7 @@ contract DistributionService is
213
225
  virtual
214
226
  returns (ReferralId referralId)
215
227
  {
216
- (,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
228
+ (NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
217
229
 
218
230
  if (bytes(code).length == 0) {
219
231
  revert ErrorIDistributionServiceInvalidReferral(code);
@@ -251,7 +263,7 @@ contract DistributionService is
251
263
  data
252
264
  );
253
265
 
254
- instance.createReferral(referralId.toKey32(), info);
266
+ instance.createReferral(referralId, info);
255
267
  return referralId;
256
268
  }
257
269
 
@@ -271,7 +283,7 @@ contract DistributionService is
271
283
  revert ErrorIDistributionServiceReferralInvalid(distributionNftId, referralId);
272
284
  }
273
285
 
274
- (, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
286
+ IInstance instance = _getInstanceForDistribution(distributionNftId);
275
287
  InstanceReader reader = instance.getInstanceReader();
276
288
  IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
277
289
  IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
@@ -292,7 +304,7 @@ contract DistributionService is
292
304
 
293
305
  if (isReferral) {
294
306
  referralInfo.usedReferrals += 1;
295
- instance.updateReferral(referralId.toKey32(), referralInfo, KEEP_STATE());
307
+ instance.updateReferral(referralId, referralInfo, KEEP_STATE());
296
308
 
297
309
  if (commissionAmount > 0) {
298
310
  distributorInfo.sumCommisions += commissionAmount;
@@ -312,7 +324,7 @@ contract DistributionService is
312
324
  view
313
325
  returns (IPolicy.Premium memory finalPremium)
314
326
  {
315
- (, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
327
+ IInstance instance = _getInstanceForDistribution(distributionNftId);
316
328
  InstanceReader reader = instance.getInstanceReader();
317
329
 
318
330
  // first calculate all fixed and variable fees for the distribution - this will defined the fullPremium
@@ -373,7 +385,7 @@ contract DistributionService is
373
385
 
374
386
  // TODO: zero should return false
375
387
  function referralIsValid(NftId distributionNftId, ReferralId referralId) public view returns (bool isValid) {
376
- (address distributionAddress, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
388
+ IInstance instance = _getInstanceForDistribution(distributionNftId);
377
389
  IDistribution.ReferralInfo memory info = instance.getInstanceReader().getReferralInfo(referralId);
378
390
 
379
391
  if (info.distributorNftId.eqz()) {
@@ -388,63 +400,32 @@ contract DistributionService is
388
400
  internal
389
401
  view
390
402
  returns(
391
- address distributionAddress,
392
403
  NftId distributionNftId,
393
404
  IInstance instance
394
405
  )
395
406
  {
396
- ObjectType objectType;
397
- (
398
- distributionAddress,
399
- distributionNftId,
400
- objectType,
401
- instance
402
- ) = _getAndVerifyCaller();
403
-
404
- if(objectType != DISTRIBUTION()) {
405
- revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
407
+ distributionNftId = getRegistry().getNftId(msg.sender);
408
+ if (distributionNftId.eqz()) {
409
+ revert ErrorDistributionServiceCallerNotRegistered(msg.sender);
406
410
  }
407
- }
408
411
 
409
- function _getAndVerifyDistribution(NftId distributionNftId)
410
- internal
411
- view
412
- returns(
413
- address distributionAddress,
414
- IInstance instance
415
- )
416
- {
417
412
  IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(distributionNftId);
418
- IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
419
- if (parentInfo.objectType != INSTANCE()) {
420
- revert ErrorIDistributionServiceParentNftIdNotInstance(distributionNftId, info.parentNftId);
413
+ if(info.objectType != DISTRIBUTION()) {
414
+ revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
421
415
  }
422
- instance = IInstance(parentInfo.objectAddress);
416
+
417
+ address instanceAddress = getRegistry().getObjectInfo(info.parentNftId).objectAddress;
418
+ instance = IInstance(instanceAddress);
423
419
  }
424
420
 
425
- function _getAndVerifyCaller()
421
+
422
+ function _getInstanceForDistribution(NftId distributionNftId)
426
423
  internal
427
424
  view
428
- returns(
429
- address objectAddress,
430
- NftId objectNftId,
431
- ObjectType objectType,
432
- IInstance instance
433
- )
425
+ returns(IInstance instance)
434
426
  {
435
- objectAddress = msg.sender;
436
- objectNftId = getRegistry().getNftId(objectAddress);
437
- if ( objectNftId.eqz()) {
438
- revert ErrorIServiceCallerUnknown(objectAddress);
439
- }
440
- IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
441
- objectType = info.objectType;
442
-
443
- IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
444
- if (parentInfo.objectType != INSTANCE()) {
445
- revert ErrorIDistributionServiceParentNftIdNotInstance(objectNftId, info.parentNftId);
446
- }
447
- instance = IInstance(parentInfo.objectAddress);
427
+ NftId instanceNftId = getRegistry().getObjectInfo(distributionNftId).parentNftId;
428
+ address instanceAddress = getRegistry().getObjectInfo(instanceNftId).objectAddress;
429
+ return IInstance(instanceAddress);
448
430
  }
449
-
450
431
  }
@@ -2,24 +2,20 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {IPolicy} from "../module/IPolicy.sol";
5
- import {IRisk} from "../module/IRisk.sol";
6
5
  import {IService} from "../../shared/IService.sol";
7
6
 
8
7
  import {NftId} from "../../types/NftId.sol";
8
+ import {ObjectType} from "../../types/ObjectType.sol";
9
9
  import {ReferralId} from "../../types/Referral.sol";
10
10
  import {RiskId} from "../../types/RiskId.sol";
11
11
  import {Seconds} from "../../types/Seconds.sol";
12
- import {StateId} from "../../types/StateId.sol";
13
- import {Timestamp} from "../../types/Timestamp.sol";
14
- import {UFixed} from "../../types/UFixed.sol";
15
- import {Fee} from "../../types/Fee.sol";
16
12
 
17
13
  /// @dev gif service responsible for creating applications
18
14
  /// only product components may call transaction functions
19
15
  interface IApplicationService is IService {
20
16
 
21
- error IApplicationServicePolicyNotApplied(NftId applicationNftId);
22
- error IApplicationServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
17
+ error ErrorApplicationServiceNotProduct(NftId callerNftId, ObjectType callerType);
18
+ error ErrorApplicationServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
23
19
 
24
20
  /// @dev creates a new application based on the specified attributes
25
21
  /// may only be called by a product component
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {Amount} from "../../types/Amount.sol";
4
5
  import {NftId} from "../../types/NftId.sol";
5
6
  import {Fee} from "../../types/Fee.sol";
6
7
  import {IService} from "../../shared/IService.sol";
@@ -8,48 +9,94 @@ import {IBundle} from "../module/IBundle.sol";
8
9
  import {IInstance} from "../../instance/IInstance.sol";
9
10
  import {Seconds} from "../../types/Seconds.sol";
10
11
  import {StateId} from "../../types/StateId.sol";
12
+ import {Timestamp} from "../../types/Timestamp.sol";
11
13
 
12
14
  interface IBundleService is IService {
13
- error ErrorIBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
14
15
 
15
- function createBundle(
16
- address owner,
17
- Fee memory fee,
18
- uint256 amount,
19
- Seconds lifetime,
20
- bytes calldata filter
21
- ) external returns(NftId bundleNftId);
16
+ event LogBundleServiceBundleActivated(NftId bundleNftId);
17
+ event LogBundleServiceBundleLocked(NftId bundleNftId);
22
18
 
23
- function setBundleFee(
19
+ error ErrorBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
20
+ error ErrorBundleServiceBundleNotOpen(NftId bundleNftId, StateId state, Timestamp expiredAt);
21
+ error ErrorBundleServiceCapacityInsufficient(NftId bundleNftId, uint capacityAmount, uint collateralAmount);
22
+ error ErrorBundleServiceBundleWithOpenPolicies(NftId bundleNftId, uint256 openPoliciesCount);
23
+
24
+ error ErrorBundleServiceBundleUnknown(NftId bundleNftId);
25
+ error ErrorBundleServiceBundlePoolMismatch(NftId expectedPoolNftId, NftId bundlePoolNftId);
26
+
27
+ /// @dev create a new bundle for the specified attributes
28
+ /// may only be called by pool service
29
+ function create(
30
+ IInstance instance, // instance relevant for bundle
31
+ NftId poolNftId, // the pool the bundle will be linked to
32
+ address owner, // initial bundle owner
33
+ Fee memory fee, // fees deducted from premium that go to bundle owner
34
+ Amount stakingAmount, // staking amount - staking fees result in initial bundle capital
35
+ Seconds lifetime, // initial duration for which new policies are covered
36
+ bytes calldata filter // optional use case specific criteria that define if a policy may be covered by this bundle
37
+ )
38
+ external
39
+ returns(NftId bundleNftId); // the nft id of the newly created bundle
40
+
41
+ /// @dev locks the specified bundle, locked bundles are not available to collateralize new policies
42
+ /// only active bundles may be locked
43
+ /// may only be called by registered and unlocked pool components
44
+ function lock(NftId bundleNftId) external;
45
+
46
+ /// @dev activates the specified bundle
47
+ /// only locked bundles may be unlocked
48
+ /// may only be called by registered and unlocked pool components
49
+ function unlock(NftId bundleNftId) external;
50
+
51
+ /// @dev closes the specified bundle
52
+ /// only open bundles (active or locked) may be closed
53
+ /// to close a bundle it may not have any non-closed polices attached to it
54
+ /// may only be called by registered and unlocked pool components
55
+ function close(
56
+ IInstance instance,
57
+ NftId bundleNftId
58
+ ) external;
59
+
60
+ /// @dev set bundle fee to provided value
61
+ /// may only be called by registered and unlocked pool components
62
+ function setFee(
24
63
  NftId bundleNftId,
25
64
  Fee memory fee
26
65
  ) external;
27
66
 
28
- function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
29
67
 
68
+ /// @dev locks the specified collateral in the bundle
69
+ /// the locked collateral is added to the bundle locked capital
70
+ /// the bundles' fees are updated with the fees for this premium
71
+ /// the premium (minus bundle fee) is added to the bundle capital
72
+ /// may only be called by pool service
30
73
  function lockCollateral(
31
74
  IInstance instanceNftId,
32
75
  NftId policyNftId,
33
76
  NftId bundleNftId,
34
77
  uint256 collateralAmount,
35
- uint256 netPremium
36
- )
37
- external
38
- returns (
39
- IBundle.BundleInfo memory bundleInfo
40
- );
41
-
42
- function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
43
-
44
- function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
78
+ uint256 premium // premium amount after pool fee
79
+ ) external;
45
80
 
46
- // function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
81
+ /// @dev updates the bundle's fees of with the provided fee amount
82
+ function updateBundleFees(
83
+ IInstance instance,
84
+ NftId bundleNftId,
85
+ Amount feeAmount
86
+ ) external;
47
87
 
48
- // function defundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
88
+ /// @dev releases the specified collateral in the bundle
89
+ /// may only be called by pool service
90
+ function releaseCollateral(
91
+ IInstance instance,
92
+ NftId policyNftId,
93
+ NftId bundleNftId,
94
+ uint256 collateralAmount
95
+ ) external;
49
96
 
50
- function lockBundle(NftId bundleNftId) external;
97
+ function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
51
98
 
52
- function unlockBundle(NftId bundleNftId) external;
99
+ // function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
53
100
 
54
- // function closeBundle(NftId bundleNftId) external;
101
+ // function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
55
102
  }