@etherisc/gif-next 0.0.2-b8e869c-076 → 0.0.2-b9366f5-670

Sign up to get free protection for your applications and to get access to all the features.
Files changed (300) hide show
  1. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
  2. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +2 -2
  3. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
  4. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
  5. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +2 -2
  6. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
  7. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
  8. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
  9. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +1 -1
  10. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
  11. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +1 -1
  12. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +2 -2
  13. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
  14. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +2 -2
  15. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
  16. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +2 -2
  17. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
  18. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +2 -2
  19. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  20. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  21. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +129 -119
  22. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  23. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +41 -45
  24. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  25. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  26. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +49 -31
  27. package/artifacts/contracts/example_components/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +4 -0
  28. package/artifacts/contracts/example_components/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +1558 -0
  29. package/artifacts/contracts/example_components/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +4 -0
  30. package/artifacts/contracts/example_components/unpermissioned/SimpleOracle.sol/SimpleOracle.json +1318 -0
  31. package/artifacts/contracts/example_components/unpermissioned/SimplePool.sol/SimplePool.dbg.json +4 -0
  32. package/artifacts/contracts/example_components/unpermissioned/SimplePool.sol/SimplePool.json +1664 -0
  33. package/artifacts/contracts/example_components/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +4 -0
  34. package/artifacts/contracts/example_components/unpermissioned/SimpleProduct.sol/SimpleProduct.json +2125 -0
  35. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
  36. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +2 -2
  37. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  38. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  39. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/Instance.sol/Instance.json +2 -2
  41. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  42. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +2 -2
  43. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
  44. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +14 -14
  45. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  46. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +225 -68
  47. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  48. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +2 -2
  49. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  50. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +2 -2
  51. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  52. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +220 -102
  53. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
  55. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  56. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  58. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +2 -2
  60. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +2 -2
  62. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  68. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  69. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
  70. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +2 -2
  71. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
  72. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +2 -2
  73. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  74. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  75. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  76. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  77. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  78. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +2 -2
  79. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  80. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +2 -2
  81. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
  82. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +5 -5
  83. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
  84. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +2 -2
  85. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  86. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +36 -28
  87. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  88. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +19 -15
  89. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  90. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  91. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +5 -5
  92. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  93. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +31 -51
  94. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  95. package/artifacts/contracts/pool/Pool.sol/Pool.json +5 -5
  96. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  97. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +65 -109
  98. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  99. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +18 -30
  100. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  101. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +8 -16
  102. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  103. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +5 -9
  104. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
  105. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +3 -3
  106. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
  107. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +2 -2
  108. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  109. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +178 -72
  110. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  111. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +41 -37
  112. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  113. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  114. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +98 -0
  115. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  116. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +1 -16
  117. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  118. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +43 -43
  119. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  120. package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +1 -1
  121. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  122. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +61 -108
  123. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  124. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +31 -47
  125. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  126. package/artifacts/contracts/product/PricingService.sol/PricingService.json +107 -152
  127. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  128. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +40 -60
  129. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  130. package/artifacts/contracts/product/Product.sol/Product.json +3 -3
  131. package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +1 -1
  132. package/artifacts/contracts/product/RiskService.sol/RiskService.json +2 -2
  133. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +1 -1
  134. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +2 -2
  135. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  136. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  137. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +1 -1
  138. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  139. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  140. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  141. package/artifacts/contracts/registry/Registry.sol/Registry.json +15 -15
  142. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  143. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +2 -2
  144. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  145. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
  146. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  147. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
  148. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
  149. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +2 -2
  150. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
  151. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +2 -2
  152. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
  153. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +6 -6
  154. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  155. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  156. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  157. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  158. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +2 -2
  159. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  160. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +2 -2
  161. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  162. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  163. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  164. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  165. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  166. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  167. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  168. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  169. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  170. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  171. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  172. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
  173. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +1 -1
  174. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  175. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  176. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  177. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
  178. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +2 -2
  179. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  180. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  181. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  182. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  183. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  184. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  185. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  186. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  187. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  188. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  189. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +1 -1
  190. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  191. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +27 -1
  192. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  193. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  194. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +83 -30
  195. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  196. package/artifacts/contracts/staking/Staking.sol/Staking.json +53 -19
  197. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
  198. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +2 -2
  199. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  200. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +14 -10
  201. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  202. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +6 -6
  203. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  204. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +2 -2
  205. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  206. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +2 -2
  207. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  208. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +84 -84
  209. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  210. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +54 -23
  211. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  212. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  213. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  214. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  215. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +2 -2
  216. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  217. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
  218. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  219. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  220. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  221. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  222. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +2 -2
  223. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  224. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  225. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  226. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +2 -2
  227. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  228. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +2 -2
  229. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  230. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
  231. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  232. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
  233. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  234. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +2 -2
  235. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  236. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +2 -2
  237. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  238. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +26 -2
  239. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
  240. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
  241. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  242. package/artifacts/contracts/type/StateId.sol/StateIdLib.json +2 -2
  243. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
  244. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  245. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +2 -2
  246. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  247. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  248. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  249. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  250. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
  251. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  252. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +2 -2
  253. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  254. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
  255. package/contracts/distribution/DistributionService.sol +20 -6
  256. package/contracts/distribution/IDistributionService.sol +8 -2
  257. package/contracts/example_components/unpermissioned/SimpleDistribution.sol +50 -0
  258. package/contracts/example_components/unpermissioned/SimpleOracle.sol +137 -0
  259. package/contracts/example_components/unpermissioned/SimplePool.sol +76 -0
  260. package/contracts/example_components/unpermissioned/SimpleProduct.sol +351 -0
  261. package/contracts/instance/InstanceAuthorizationV3.sol +3 -3
  262. package/contracts/instance/InstanceReader.sol +23 -1
  263. package/contracts/instance/InstanceService.sol +5 -5
  264. package/contracts/instance/InstanceStore.sol +11 -1
  265. package/contracts/instance/base/ObjectLifecycle.sol +7 -1
  266. package/contracts/instance/module/IComponents.sol +1 -1
  267. package/contracts/instance/module/IPolicy.sol +21 -21
  268. package/contracts/oracle/Oracle.sol +1 -0
  269. package/contracts/oracle/OracleService.sol +1 -0
  270. package/contracts/pool/BundleService.sol +8 -6
  271. package/contracts/pool/IPoolService.sol +3 -6
  272. package/contracts/pool/Pool.sol +14 -16
  273. package/contracts/pool/PoolService.sol +7 -39
  274. package/contracts/product/ApplicationService.sol +2 -4
  275. package/contracts/product/BasicProduct.sol +1 -0
  276. package/contracts/product/ClaimService.sol +107 -36
  277. package/contracts/product/IClaimService.sol +27 -5
  278. package/contracts/product/IPolicyService.sol +6 -17
  279. package/contracts/product/IPricingService.sol +7 -7
  280. package/contracts/product/IProductComponent.sol +0 -1
  281. package/contracts/product/PolicyService.sol +58 -69
  282. package/contracts/product/PricingService.sol +37 -40
  283. package/contracts/product/Product.sol +31 -16
  284. package/contracts/registry/IRegistry.sol +1 -1
  285. package/contracts/registry/Registry.sol +1 -1
  286. package/contracts/registry/ReleaseRegistry.sol +1 -1
  287. package/contracts/registry/ServiceAuthorizationV3.sol +2 -3
  288. package/contracts/shared/Component.sol +1 -1
  289. package/contracts/shared/ComponentService.sol +1 -1
  290. package/contracts/shared/ComponentVerifyingService.sol +1 -1
  291. package/contracts/shared/InstanceLinkedComponent.sol +1 -1
  292. package/contracts/shared/NftOwnable.sol +1 -1
  293. package/contracts/staking/IStaking.sol +2 -1
  294. package/contracts/staking/StakeManagerLib.sol +18 -0
  295. package/contracts/staking/Staking.sol +3 -2
  296. package/contracts/staking/TargetManagerLib.sol +7 -3
  297. package/contracts/type/ObjectType.sol +15 -11
  298. package/contracts/type/Seconds.sol +8 -0
  299. package/contracts/type/StateId.sol +1 -0
  300. package/package.json +1 -1
@@ -7,7 +7,7 @@ import {IPolicy} from "../instance/module/IPolicy.sol";
7
7
  import {Amount, AmountLib} from "../type/Amount.sol";
8
8
  import {TimestampLib} from "../type/Timestamp.sol";
9
9
  import {ObjectType, CLAIM, PRODUCT, POOL} from "../type/ObjectType.sol";
10
- import {SUBMITTED, KEEP_STATE, DECLINED, CONFIRMED, CLOSED, PAID} from "../type/StateId.sol";
10
+ import {SUBMITTED, KEEP_STATE, DECLINED, REVOKED, CONFIRMED, CLOSED, PAID} from "../type/StateId.sol";
11
11
  import {NftId} from "../type/NftId.sol";
12
12
  import {FeeLib} from "../type/Fee.sol";
13
13
  import {StateId} from "../type/StateId.sol";
@@ -67,6 +67,7 @@ contract ClaimService is
67
67
  revert ErrorClaimServicePolicyNotOpen(policyNftId);
68
68
  }
69
69
 
70
+ // TODO check claim amount > 0
70
71
  // check policy including this claim is still within sum insured
71
72
  if(policyInfo.payoutAmount + claimAmount > policyInfo.sumInsuredAmount) {
72
73
  revert ErrorClaimServiceClaimExceedsSumInsured(
@@ -80,14 +81,14 @@ contract ClaimService is
80
81
  instance.getInstanceStore().createClaim(
81
82
  policyNftId,
82
83
  claimId,
83
- IPolicy.ClaimInfo(
84
- claimAmount,
85
- AmountLib.zero(), // paidAmount
86
- 0, // payoutsCount
87
- 0, // openPayoutsCount
88
- claimData, // claim submission data
89
- "", // claim processing data
90
- TimestampLib.zero())); // closedAt
84
+ IPolicy.ClaimInfo({
85
+ claimAmount: claimAmount,
86
+ paidAmount: AmountLib.zero(),
87
+ payoutsCount: 0,
88
+ openPayoutsCount: 0,
89
+ submissionData: claimData,
90
+ processData: "",
91
+ closedAt: TimestampLib.zero()}));
91
92
 
92
93
  // update and save policy info with instance
93
94
  policyInfo.claimsCount += 1;
@@ -114,12 +115,17 @@ contract ClaimService is
114
115
  IPolicy.PolicyInfo memory policyInfo
115
116
  ) = _verifyCallerWithPolicy(policyNftId);
116
117
 
118
+ // TODO add check for confirmedAmount > 0 and does not lead to exceeding sum insured
119
+
117
120
  // check/update claim info
118
121
  IPolicy.ClaimInfo memory claimInfo = _verifyClaim(instanceReader, policyNftId, claimId, SUBMITTED());
119
122
  claimInfo.claimAmount = confirmedAmount;
120
123
  claimInfo.processData = data;
121
124
  instance.getInstanceStore().updateClaim(policyNftId, claimId, claimInfo, CONFIRMED());
122
125
 
126
+ // TODO test if claim results in total claim amount == sum insured amount
127
+ // should policy still be active it needs to automatically become expired
128
+
123
129
  // update and save policy info with instance
124
130
  policyInfo.claimAmount = policyInfo.claimAmount + confirmedAmount;
125
131
  instance.getInstanceStore().updatePolicyClaims(policyNftId, policyInfo, KEEP_STATE());
@@ -154,6 +160,34 @@ contract ClaimService is
154
160
  emit LogClaimServiceClaimDeclined(policyNftId, claimId);
155
161
  }
156
162
 
163
+
164
+ // TODO add test case
165
+ function revoke(
166
+ NftId policyNftId,
167
+ ClaimId claimId
168
+ )
169
+ external
170
+ virtual
171
+ {
172
+ (
173
+ IInstance instance,
174
+ InstanceReader instanceReader,
175
+ IPolicy.PolicyInfo memory policyInfo
176
+ ) = _verifyCallerWithPolicy(policyNftId);
177
+
178
+ // check/update claim info
179
+ IPolicy.ClaimInfo memory claimInfo = _verifyClaim(instanceReader, policyNftId, claimId, SUBMITTED());
180
+ claimInfo.closedAt = TimestampLib.blockTimestamp();
181
+ instance.getInstanceStore().updateClaim(policyNftId, claimId, claimInfo, REVOKED());
182
+
183
+ // update and save policy info with instance
184
+ policyInfo.openClaimsCount -= 1;
185
+ instance.getInstanceStore().updatePolicyClaims(policyNftId, policyInfo, KEEP_STATE());
186
+
187
+ emit LogClaimServiceClaimRevoked(policyNftId, claimId);
188
+ }
189
+
190
+
157
191
  function close(
158
192
  NftId policyNftId,
159
193
  ClaimId claimId
@@ -191,6 +225,30 @@ contract ClaimService is
191
225
  instance.getInstanceStore().updateClaim(policyNftId, claimId, claimInfo, CLOSED());
192
226
  }
193
227
 
228
+ // TODO add test
229
+ function createPayoutForBeneficiary(
230
+ NftId policyNftId,
231
+ ClaimId claimId,
232
+ Amount amount,
233
+ address beneficiary,
234
+ bytes memory data
235
+ )
236
+ external
237
+ virtual
238
+ returns (PayoutId payoutId)
239
+ {
240
+ if (beneficiary == address(0)) {
241
+ revert ErrorClaimServiceBeneficiaryIsZero(policyNftId, claimId);
242
+ }
243
+
244
+ return _createPayout(
245
+ policyNftId,
246
+ claimId,
247
+ amount,
248
+ beneficiary,
249
+ data);
250
+ }
251
+
194
252
 
195
253
  function createPayout(
196
254
  NftId policyNftId,
@@ -199,6 +257,26 @@ contract ClaimService is
199
257
  bytes memory data
200
258
  )
201
259
  external
260
+ virtual
261
+ returns (PayoutId payoutId)
262
+ {
263
+ return _createPayout(
264
+ policyNftId,
265
+ claimId,
266
+ amount,
267
+ address(0), // defaults to owner of policy nft
268
+ data);
269
+ }
270
+
271
+ function _createPayout(
272
+ NftId policyNftId,
273
+ ClaimId claimId,
274
+ Amount amount,
275
+ address beneficiary,
276
+ bytes memory data
277
+ )
278
+ internal
279
+ virtual
202
280
  returns (PayoutId payoutId)
203
281
  {
204
282
  (
@@ -221,11 +299,12 @@ contract ClaimService is
221
299
  instance.getInstanceStore().createPayout(
222
300
  policyNftId,
223
301
  payoutId,
224
- IPolicy.PayoutInfo(
225
- payoutId.toClaimId(),
226
- amount,
227
- data,
228
- TimestampLib.zero()));
302
+ IPolicy.PayoutInfo({
303
+ claimId: payoutId.toClaimId(),
304
+ amount: amount,
305
+ beneficiary: beneficiary,
306
+ data: data,
307
+ paidAt: TimestampLib.zero()}));
229
308
 
230
309
  // update and save claim info with instance
231
310
  claimInfo.payoutsCount += 1;
@@ -293,6 +372,7 @@ contract ClaimService is
293
372
  // transfer payout token and fee
294
373
  (
295
374
  Amount netPayoutAmount,
375
+ Amount processingFeeAmount,
296
376
  address beneficiary
297
377
  ) = _calculatePayoutAmount(
298
378
  instanceReader,
@@ -300,15 +380,17 @@ contract ClaimService is
300
380
  policyInfo,
301
381
  payoutInfo);
302
382
 
303
- // TODO callback IPolicyHolder
304
-
305
- emit LogClaimServicePayoutProcessed(policyNftId, payoutId, payoutAmount, beneficiary, netPayoutAmount);
383
+ emit LogClaimServicePayoutProcessed(policyNftId, payoutId, payoutAmount, beneficiary, netPayoutAmount, processingFeeAmount);
306
384
 
307
385
  {
308
386
  NftId poolNftId = getRegistry().getObjectInfo(policyInfo.bundleNftId).parentNftId;
309
387
  IComponents.ComponentInfo memory poolInfo = instanceReader.getComponentInfo(poolNftId);
310
388
  poolInfo.tokenHandler.distributeTokens(poolInfo.wallet, beneficiary, netPayoutAmount);
389
+
390
+ // TODO add 2nd token tx if processingFeeAmount > 0
311
391
  }
392
+
393
+ // TODO callback IPolicyHolder
312
394
  }
313
395
 
314
396
  function _calculatePayoutAmount(
@@ -320,6 +402,7 @@ contract ClaimService is
320
402
  internal
321
403
  returns (
322
404
  Amount netPayoutAmount,
405
+ Amount processingFeeAmount,
323
406
  address beneficiary
324
407
  )
325
408
  {
@@ -333,34 +416,22 @@ contract ClaimService is
333
416
  IComponents.ComponentInfo memory poolInfo = instanceReader.getComponentInfo(poolNftId);
334
417
 
335
418
  netPayoutAmount = payoutAmount;
336
- beneficiary = _getBeneficiary(policyNftId, payoutInfo.claimId);
419
+
420
+ if (payoutInfo.beneficiary == address(0)) {
421
+ beneficiary = getRegistry().ownerOf(policyNftId);
422
+ } else {
423
+ beneficiary = payoutInfo.beneficiary;
424
+ }
337
425
 
338
426
  IComponents.ProductInfo memory productInfo = instanceReader.getProductInfo(productNftId);
339
427
  if(FeeLib.gtz(productInfo.processingFee)) {
340
- // TODO calculate net payout and processing fees
341
- // TODO transfer processing fees to product wallet
342
- // TODO inform product to update fee book keeping
428
+ // TODO calculate and set net payout and processing fees
343
429
  }
344
430
  }
345
431
  }
346
432
 
347
433
  // internal functions
348
434
 
349
- function _getBeneficiary(
350
- NftId policyNftId,
351
- ClaimId claimId
352
- )
353
- internal
354
- returns (address beneficiary)
355
- {
356
- // TODO check if owner is IPolicyHolder
357
- // if so, obtain beneficiary from this contract
358
-
359
- // default beneficiary is policy nft owner
360
- beneficiary = getRegistry().ownerOf(policyNftId);
361
- }
362
-
363
-
364
435
  function _verifyCallerWithPolicy(
365
436
  NftId policyNftId
366
437
  )
@@ -23,14 +23,16 @@ interface IClaimService is
23
23
  event LogClaimServiceClaimSubmitted(NftId policyNftId, ClaimId claimId, Amount claimAmount);
24
24
  event LogClaimServiceClaimConfirmed(NftId policyNftId, ClaimId claimId, Amount confirmedAmount);
25
25
  event LogClaimServiceClaimDeclined(NftId policyNftId, ClaimId claimId);
26
+ event LogClaimServiceClaimRevoked(NftId policyNftId, ClaimId claimId);
26
27
  event LogClaimServiceClaimClosed(NftId policyNftId, ClaimId claimId);
27
28
 
28
29
  event LogClaimServicePayoutCreated(NftId policyNftId, PayoutId payoutId, Amount amount);
29
- event LogClaimServicePayoutProcessed(NftId policyNftId, PayoutId payoutId, Amount amount, address beneficiary, Amount netAmount);
30
+ event LogClaimServicePayoutProcessed(NftId policyNftId, PayoutId payoutId, Amount amount, address beneficiary, Amount netAmount, Amount processingFeeAmount);
30
31
 
31
32
  error ErrorClaimServicePolicyProductMismatch(NftId policyNftId, NftId expectedProduct, NftId actualProduct);
32
33
  error ErrorClaimServicePolicyNotOpen(NftId policyNftId);
33
34
  error ErrorClaimServiceClaimExceedsSumInsured(NftId policyNftId, Amount sumInsured, Amount payoutsIncludingClaimAmount);
35
+ error ErrorClaimServiceBeneficiaryIsZero(NftId policyNftId, ClaimId claimId);
34
36
  error ErrorClaimsServicePayoutAmountIsZero(NftId policyNftId, PayoutId payoutId);
35
37
 
36
38
  error ErrorClaimServiceClaimWithOpenPayouts(NftId policyNftId, ClaimId claimId, uint8 openPayouts);
@@ -47,9 +49,6 @@ interface IClaimService is
47
49
  ) external returns (ClaimId claimId);
48
50
 
49
51
 
50
- // TODO add claim revoke functionality
51
-
52
-
53
52
  /// @dev declines the specified claim
54
53
  /// function can only be called by product, policy needs to match with calling product
55
54
  function decline(
@@ -59,6 +58,14 @@ interface IClaimService is
59
58
  ) external;
60
59
 
61
60
 
61
+ /// @dev revokes the specified claim
62
+ /// function can only be called by product, policy needs to match with calling product
63
+ function revoke(
64
+ NftId policyNftId,
65
+ ClaimId claimId
66
+ ) external;
67
+
68
+
62
69
  /// @dev confirms the specified claim and specifies the payout amount
63
70
  /// function can only be called by product, policy needs to match with calling product
64
71
  function confirm(
@@ -77,7 +84,8 @@ interface IClaimService is
77
84
  ) external;
78
85
 
79
86
 
80
- /// @dev creates a new payout for the specified claim
87
+ /// @dev Creates a new payout for the specified claim.
88
+ /// The beneficiary is the holder of the policy NFT
81
89
  /// returns the id of the newly created payout, this id is unique for the specified policy
82
90
  /// function can only be called by product, policy needs to match with calling product
83
91
  function createPayout(
@@ -90,6 +98,20 @@ interface IClaimService is
90
98
  returns (PayoutId payoutId);
91
99
 
92
100
 
101
+ /// @dev Creates a new payout for the specified claim and beneficiary.
102
+ /// returns the id of the newly created payout, this id is unique for the specified policy
103
+ /// function can only be called by product, policy needs to match with calling product
104
+ function createPayoutForBeneficiary(
105
+ NftId policyNftId,
106
+ ClaimId claimId,
107
+ Amount amount,
108
+ address beneficiary,
109
+ bytes memory data
110
+ )
111
+ external
112
+ returns (PayoutId payoutId);
113
+
114
+
93
115
  /// @dev processes the specified payout
94
116
  /// this includes moving the payout token to the beneficiary (default: policy holder)
95
117
  /// function can only be called by product, policy needs to match with calling product
@@ -1,20 +1,12 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IRisk} from "../instance/module/IRisk.sol";
5
4
  import {IService} from "../shared/IService.sol";
6
5
 
7
6
  import {Amount} from "../type/Amount.sol";
8
- import {ClaimId} from "../type/ClaimId.sol";
9
7
  import {NftId} from "../type/NftId.sol";
10
- import {PayoutId} from "../type/PayoutId.sol";
11
- import {ReferralId} from "../type/Referral.sol";
12
- import {RiskId} from "../type/RiskId.sol";
13
- import {Seconds} from "../type/Seconds.sol";
14
8
  import {StateId} from "../type/StateId.sol";
15
9
  import {Timestamp} from "../type/Timestamp.sol";
16
- import {UFixed} from "../type/UFixed.sol";
17
- import {Fee} from "../type/Fee.sol";
18
10
 
19
11
  interface IPolicyService is IService {
20
12
 
@@ -27,11 +19,11 @@ interface IPolicyService is IService {
27
19
  error ErrorPolicyServiceAllowanceInsufficient(address policyOwner, address tokenHandler, uint256 premiumAmount, uint256 allowance);
28
20
 
29
21
  error ErrorPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
30
- error ErrorPolicyServicePremiumAlreadyPaid(NftId policyNftId, Amount premiumPaidAmount);
22
+ error ErrorPolicyServicePremiumAlreadyPaid(NftId policyNftId);
31
23
  error ErrorPolicyServicePolicyNotActivated(NftId policyNftId);
32
24
  error ErrorPolicyServicePolicyAlreadyClosed(NftId policyNftId);
33
25
  error ErrorPolicyServicePolicyNotActive(NftId policyNftId, StateId state);
34
- error ErrorPolicyServicePremiumNotFullyPaid(NftId policyNftId, Amount premiumAmount, Amount premiumPaidAmount);
26
+ error ErrorPolicyServicePremiumNotPaid(NftId policyNftId, Amount premiumAmount);
35
27
  error ErrorPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
36
28
  error ErrorPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
37
29
  error ErrorPolicyServicePolicyExpirationTooLate(NftId policyNftId, Timestamp upperLimit, Timestamp expiredAt);
@@ -45,15 +37,12 @@ interface IPolicyService is IService {
45
37
 
46
38
  /// @dev creates the policy from {applicationNftId}.
47
39
  /// After successful completion of the function the policy can be referenced using the application NftId.
48
- /// Locks the sum insured amount in the pool.
49
- /// sets the policy state to collateralized
50
- /// optionally collects premiums and activates the policy.
51
- /// - premium payment is only attempted if requirePremiumPayment is set to true
52
- /// - activation is only done if activateAt is a non-zero timestamp
40
+ /// Locks the sum insured amount in the pool, but does not transfer tokens. Call collectPremium to transfer tokens.
41
+ /// Sets the policy state to collateralized.
42
+ /// Optionally activates the policy if activateAt is a non-zero timestamp.
53
43
  /// only the related product may create a policy from an application
54
44
  function createPolicy(
55
45
  NftId applicationNftId,
56
- bool requirePremiumPayment,
57
46
  Timestamp activateAt
58
47
  ) external;
59
48
 
@@ -62,7 +51,7 @@ interface IPolicyService is IService {
62
51
  /// only the related product may decline an application
63
52
  function decline(NftId policyNftId) external;
64
53
 
65
- /// @dev collects the premium token for the specified policy (must be in COLLATERALIZED or ACTIVE state)
54
+ /// @dev collects the premium token for the specified policy (must be in COLLATERALIZED state)
66
55
  function collectPremium(NftId policyNftId, Timestamp activateAt) external;
67
56
 
68
57
  /// @dev activates the specified policy and sets the activation date in the policy metadata
@@ -16,12 +16,12 @@ interface IPricingService is IService
16
16
  error ErrorPricingServiceTargetWalletAmountsMismatch();
17
17
  error ErrorIPricingServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
18
18
  error ErrorIPricingServiceFeeCalculationMismatch(
19
- uint256 distributionFeeFixAmount,
20
- uint256 distributionFeeVarAmount,
21
- uint256 distributionOwnerFeeFixAmount,
22
- uint256 distributionOwnerFeeVarAmount,
23
- uint256 commissionAmount,
24
- uint256 discountAmount
19
+ Amount distributionFeeFixAmount,
20
+ Amount distributionFeeVarAmount,
21
+ Amount distributionOwnerFeeFixAmount,
22
+ Amount distributionOwnerFeeVarAmount,
23
+ Amount commissionAmount,
24
+ Amount discountAmount
25
25
  );
26
26
 
27
27
  function calculatePremium(
@@ -35,5 +35,5 @@ interface IPricingService is IService
35
35
  )
36
36
  external
37
37
  view
38
- returns (IPolicy.Premium memory premium);
38
+ returns (IPolicy.PremiumInfo memory premium);
39
39
  }
@@ -2,7 +2,6 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  import {Amount} from "../type/Amount.sol";
5
- import {Fee} from "../type/Fee.sol";
6
5
  import {IInstanceLinkedComponent} from "../shared/IInstanceLinkedComponent.sol";
7
6
  import {IComponents} from "../instance/module/IComponents.sol";
8
7
  import {NftId} from "../type/NftId.sol";
@@ -14,7 +14,7 @@ import {TokenHandler} from "../shared/TokenHandler.sol";
14
14
  import {Amount, AmountLib} from "../type/Amount.sol";
15
15
  import {Timestamp, TimestampLib, zeroTimestamp} from "../type/Timestamp.sol";
16
16
  import {ObjectType, APPLICATION, COMPONENT, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE, CLAIM, PRICE} from "../type/ObjectType.sol";
17
- import {APPLIED, COLLATERALIZED, KEEP_STATE, CLOSED, DECLINED} from "../type/StateId.sol";
17
+ import {APPLIED, COLLATERALIZED, KEEP_STATE, CLOSED, DECLINED, PAID} from "../type/StateId.sol";
18
18
  import {NftId, NftIdLib} from "../type/NftId.sol";
19
19
  import {ReferralId} from "../type/Referral.sol";
20
20
  import {StateId} from "../type/StateId.sol";
@@ -112,7 +112,6 @@ contract PolicyService is
112
112
  /// @inheritdoc IPolicyService
113
113
  function createPolicy(
114
114
  NftId applicationNftId, // = policyNftId
115
- bool requirePremiumPayment,
116
115
  Timestamp activateAt
117
116
  )
118
117
  external
@@ -136,13 +135,8 @@ contract PolicyService is
136
135
  productNftId);
137
136
  }
138
137
 
139
- StateId newPolicyState = COLLATERALIZED();
140
-
141
138
  // actual collateralizaion
142
- (
143
- Amount localCollateralAmount,
144
- Amount totalCollateralAmount
145
- ) = _poolService.lockCollateral(
139
+ _poolService.lockCollateral(
146
140
  instance,
147
141
  address(instanceReader.getComponentInfo(productNftId).token),
148
142
  productNftId,
@@ -152,36 +146,43 @@ contract PolicyService is
152
146
 
153
147
  // optional activation of policy
154
148
  if(activateAt > zeroTimestamp()) {
155
- applicationInfo.activatedAt = activateAt;
156
- applicationInfo.expiredAt = activateAt.addSeconds(applicationInfo.lifetime);
157
- }
158
-
159
- IPolicy.Premium memory premium;
160
-
161
- // optional: calculate the premium and update counters for collection at the end of this function
162
- if(requirePremiumPayment) {
163
- premium = _calculateAndProcessPremium(
164
- instance,
165
- applicationNftId,
166
- applicationInfo);
167
-
168
- applicationInfo.premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
149
+ applicationInfo = _activate(
150
+ applicationNftId,
151
+ applicationInfo,
152
+ activateAt);
169
153
  }
170
154
 
171
- // store updated policy info
155
+ // update policy and set state to collateralized
172
156
  instance.getInstanceStore().updatePolicy(
173
157
  applicationNftId,
174
158
  applicationInfo,
175
- newPolicyState);
159
+ COLLATERALIZED());
176
160
 
177
- // TODO add calling pool contract if it needs to validate application
161
+ // calculate and store premium
162
+ IPolicy.PremiumInfo memory premium = _pricingService.calculatePremium(
163
+ productNftId,
164
+ applicationInfo.riskId,
165
+ applicationInfo.sumInsuredAmount,
166
+ applicationInfo.lifetime,
167
+ applicationInfo.applicationData,
168
+ applicationInfo.bundleNftId,
169
+ applicationInfo.referralId);
178
170
 
179
- // TODO: add logging
171
+ instance.getInstanceStore().createPremium(
172
+ applicationNftId,
173
+ premium);
180
174
 
181
- // optional: transfer funds for premium
182
- if(requirePremiumPayment) {
183
- _transferFunds(instanceReader, applicationNftId, applicationInfo.productNftId, premium);
175
+ // update referral counter
176
+ {
177
+ IComponents.ProductInfo memory productInfo = instanceReader.getProductInfo(productNftId);
178
+ _distributionService.processReferral(
179
+ productInfo.distributionNftId,
180
+ applicationInfo.referralId);
184
181
  }
182
+
183
+ // TODO add calling pool contract if it needs to validate application
184
+
185
+ // TODO: add logging
185
186
 
186
187
  // TODO: add callback IPolicyHolder.policyActivated() if applicable
187
188
  }
@@ -205,20 +206,19 @@ contract PolicyService is
205
206
  revert ErrorPolicyServicePolicyStateNotCollateralized(policyNftId);
206
207
  }
207
208
 
208
- IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
209
-
210
209
  // check if premium is already collected
211
- if (policyInfo.premiumPaidAmount.gtz()) {
212
- revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
210
+ if (instanceReader.getPremiumInfoState(policyNftId) == PAID()) {
211
+ revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId);
213
212
  }
214
213
 
215
- // calculate premium
216
- IPolicy.Premium memory premium = _calculateAndProcessPremium(
217
- instance,
218
- policyNftId,
219
- policyInfo);
220
-
221
- policyInfo.premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
214
+ IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
215
+ IPolicy.PremiumInfo memory premium = instanceReader.getPremiumInfo(policyNftId);
216
+
217
+ _processPremium(
218
+ instance,
219
+ policyNftId,
220
+ policyInfo,
221
+ premium);
222
222
 
223
223
  // optionally activate policy
224
224
  if(activateAt.gtz()) {
@@ -226,6 +226,7 @@ contract PolicyService is
226
226
  }
227
227
 
228
228
  instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
229
+ instance.getInstanceStore().updatePremiumState(policyNftId, PAID());
229
230
 
230
231
  // TODO: add logging
231
232
 
@@ -333,8 +334,8 @@ contract PolicyService is
333
334
 
334
335
  // TODO consider to allow for underpaid premiums (with the effects of reducing max payouts accordingly)
335
336
  // TODO consider to remove requirement for fully paid premiums altogether
336
- if (!(policyInfo.premiumAmount == policyInfo.premiumPaidAmount)) {
337
- revert ErrorPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
337
+ if (! instanceReader.getPremiumInfoState(policyNftId).eq(PAID())) {
338
+ revert ErrorPolicyServicePremiumNotPaid(policyNftId, policyInfo.premiumAmount);
338
339
  }
339
340
 
340
341
  // release (remaining) collateral that was blocked by policy
@@ -355,30 +356,18 @@ contract PolicyService is
355
356
 
356
357
 
357
358
  /// @dev calculates the premium and updates all counters in the other services
358
- function _calculateAndProcessPremium(
359
+ function _processPremium(
359
360
  IInstance instance,
360
361
  NftId applicationNftId,
361
- IPolicy.PolicyInfo memory applicationInfo
362
+ IPolicy.PolicyInfo memory applicationInfo,
363
+ IPolicy.PremiumInfo memory premium
362
364
  )
363
365
  internal
364
366
  virtual
365
- returns (
366
- IPolicy.Premium memory premium
367
- )
368
367
  {
369
368
  NftId productNftId = applicationInfo.productNftId;
370
369
  InstanceReader instanceReader = instance.getInstanceReader();
371
370
 
372
- // calculate premium details
373
- premium = _pricingService.calculatePremium(
374
- productNftId,
375
- applicationInfo.riskId,
376
- applicationInfo.sumInsuredAmount,
377
- applicationInfo.lifetime,
378
- applicationInfo.applicationData,
379
- applicationInfo.bundleNftId,
380
- applicationInfo.referralId);
381
-
382
371
  // check if premium balance and allowance of policy holder is sufficient
383
372
  {
384
373
  TokenHandler tokenHandler = _getTokenHandler(instanceReader, productNftId);
@@ -388,7 +377,7 @@ contract PolicyService is
388
377
  tokenHandler.getToken(),
389
378
  address(tokenHandler),
390
379
  policyHolder,
391
- AmountLib.toAmount(premium.premiumAmount));
380
+ premium.premiumAmount);
392
381
  }
393
382
 
394
383
  // update the counters
@@ -401,7 +390,6 @@ contract PolicyService is
401
390
  premium);
402
391
  }
403
392
 
404
-
405
393
  function _activate(
406
394
  NftId policyNftId,
407
395
  IPolicy.PolicyInfo memory policyInfo,
@@ -412,10 +400,16 @@ contract PolicyService is
412
400
  view
413
401
  returns (IPolicy.PolicyInfo memory)
414
402
  {
415
- if(! policyInfo.activatedAt.eqz()) {
403
+ // fail if policy has already been activated and activateAt is different
404
+ if(! policyInfo.activatedAt.eqz() && activateAt != policyInfo.activatedAt) {
416
405
  revert ErrorPolicyServicePolicyAlreadyActivated(policyNftId);
417
406
  }
418
407
 
408
+ // ignore if policy has already been activated and activateAt is the same
409
+ if (policyInfo.activatedAt == activateAt) {
410
+ return policyInfo;
411
+ }
412
+
419
413
  policyInfo.activatedAt = activateAt;
420
414
  policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
421
415
 
@@ -429,17 +423,12 @@ contract PolicyService is
429
423
  NftId productNftId,
430
424
  NftId bundleNftId,
431
425
  ReferralId referralId,
432
- IPolicy.Premium memory premium
426
+ IPolicy.PremiumInfo memory premium
433
427
  )
434
428
  internal
435
429
  virtual
436
430
  {
437
- (
438
- NftId distributionNftId,
439
- address distributionWallet,
440
- address poolWallet,
441
- address productWallet
442
- ) = _getDistributionNftAndWallets(
431
+ (NftId distributionNftId, , , ) = _getDistributionNftAndWallets(
443
432
  instanceReader,
444
433
  productNftId);
445
434
 
@@ -447,7 +436,7 @@ contract PolicyService is
447
436
  _componentService.increaseProductFees(
448
437
  instanceStore,
449
438
  productNftId,
450
- AmountLib.toAmount(premium.productFeeVarAmount + premium.productFeeFixAmount));
439
+ premium.productFeeVarAmount + premium.productFeeFixAmount);
451
440
 
452
441
  // update distribution fees and distributor commission and pool fees
453
442
  _distributionService.processSale(
@@ -467,7 +456,7 @@ contract PolicyService is
467
456
  InstanceReader instanceReader,
468
457
  NftId policyNftId,
469
458
  NftId productNftId,
470
- IPolicy.Premium memory premium
459
+ IPolicy.PremiumInfo memory premium
471
460
  )
472
461
  internal
473
462
  virtual