@etherisc/gif-next 0.0.2-f8e07c7-917 → 0.0.2-f946ccd-184

Sign up to get free protection for your applications and to get access to all the features.
Files changed (412) hide show
  1. package/README.md +19 -2
  2. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
  3. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +33 -52
  4. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
  5. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
  6. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +2 -2
  7. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
  8. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
  9. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +0 -19
  10. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
  11. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +1 -1
  12. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
  13. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +1 -1
  14. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +2 -2
  15. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
  16. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +2 -2
  17. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
  18. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +66 -248
  19. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
  20. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +16 -16
  21. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  22. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +24 -222
  23. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  24. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +228 -217
  25. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  26. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +93 -101
  27. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  28. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +24 -37
  29. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  30. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +120 -31
  31. package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +4 -0
  32. package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +1463 -0
  33. package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +4 -0
  34. package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +410 -0
  35. package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +4 -0
  36. package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +1712 -0
  37. package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +4 -0
  38. package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +414 -0
  39. package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +4 -0
  40. package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.json +376 -0
  41. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +4 -0
  42. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +1411 -0
  43. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +4 -0
  44. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +1171 -0
  45. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +4 -0
  46. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +1517 -0
  47. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +4 -0
  48. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +1978 -0
  49. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
  50. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +2 -2
  51. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  52. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  53. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  54. package/artifacts/contracts/instance/Instance.sol/Instance.json +10 -99
  55. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  56. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +97 -100
  57. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
  58. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +14 -14
  59. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  60. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +238 -123
  61. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  62. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +39 -146
  63. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  64. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +61 -81
  65. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  66. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +215 -219
  67. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
  69. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  70. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  71. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  72. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
  73. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +2 -2
  74. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
  75. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +2 -2
  76. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  80. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  82. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  83. package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
  84. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
  85. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +32 -238
  86. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
  87. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +2 -2
  88. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  89. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  90. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +0 -37
  91. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  92. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  93. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +0 -222
  94. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  95. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +37 -144
  96. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  97. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +60 -80
  98. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
  99. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +36 -284
  100. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
  101. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +16 -16
  102. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  103. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +396 -163
  104. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  105. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +137 -89
  106. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  107. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +205 -1
  108. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  109. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +26 -95
  110. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  111. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +220 -100
  112. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  113. package/artifacts/contracts/pool/Pool.sol/Pool.json +26 -280
  114. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  115. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +269 -248
  116. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  117. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +66 -82
  118. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  119. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +36 -162
  120. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  121. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +57 -89
  122. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
  123. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +3 -225
  124. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
  125. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +2 -2
  126. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  127. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +206 -175
  128. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  129. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +92 -100
  130. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  131. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +5 -0
  132. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  133. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +114 -0
  134. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  135. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +266 -119
  136. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  137. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +43 -43
  138. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  139. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +0 -37
  140. package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +4 -0
  141. package/artifacts/contracts/product/{IProductService.sol/IProductService.json → IRiskService.sol/IRiskService.json} +2 -2
  142. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  143. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +372 -316
  144. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  145. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +104 -100
  146. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  147. package/artifacts/contracts/product/PricingService.sol/PricingService.json +118 -265
  148. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  149. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +80 -120
  150. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  151. package/artifacts/contracts/product/Product.sol/Product.json +3 -225
  152. package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +4 -0
  153. package/artifacts/contracts/product/RiskService.sol/RiskService.json +588 -0
  154. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +4 -0
  155. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +682 -0
  156. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  157. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +59 -16
  158. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  159. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +221 -21
  160. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  161. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  162. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  163. package/artifacts/contracts/registry/Registry.sol/Registry.json +419 -82
  164. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  165. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +243 -131
  166. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  167. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +23 -130
  168. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  169. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +52 -72
  170. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
  171. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +2 -2
  172. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
  173. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +24 -14
  174. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
  175. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +6 -6
  176. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  177. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  178. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  179. package/artifacts/contracts/shared/Component.sol/Component.json +0 -211
  180. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  181. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +132 -199
  182. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  183. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +96 -114
  184. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  185. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +5 -112
  186. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +4 -0
  187. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +92 -0
  188. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  189. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +0 -26
  190. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  191. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +56 -0
  192. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  193. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +0 -37
  194. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  195. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  196. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  197. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  198. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +14 -46
  199. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  200. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  201. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  202. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
  203. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +4 -0
  204. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +53 -0
  205. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  206. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +0 -222
  207. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  208. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  209. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
  210. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +2 -2
  211. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  212. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +6 -57
  213. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  214. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +18 -140
  215. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  216. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +8 -97
  217. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  218. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
  219. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  220. package/artifacts/contracts/shared/Service.sol/Service.json +5 -112
  221. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  222. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +330 -11
  223. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +4 -0
  224. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +108 -0
  225. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  226. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +27 -27
  227. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  228. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  229. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +73 -93
  230. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  231. package/artifacts/contracts/staking/Staking.sol/Staking.json +85 -262
  232. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
  233. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +2 -2
  234. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  235. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +77 -88
  236. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  237. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +6 -6
  238. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  239. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +31 -138
  240. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  241. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +56 -76
  242. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  243. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +89 -84
  244. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  245. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +59 -23
  246. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  247. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  248. package/artifacts/contracts/type/Amount.sol/AmountLib.json +37 -8
  249. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  250. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +2 -2
  251. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  252. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +2 -2
  253. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  254. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
  255. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  256. package/artifacts/contracts/type/Fee.sol/FeeLib.json +7 -2
  257. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  258. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  259. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  260. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +2 -2
  261. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  262. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  263. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  264. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +2 -2
  265. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  266. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +2 -2
  267. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  268. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
  269. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  270. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
  271. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  272. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +60 -4
  273. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  274. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +2 -2
  275. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  276. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +50 -2
  277. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
  278. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
  279. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  280. package/artifacts/contracts/type/StateId.sol/StateIdLib.json +2 -2
  281. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
  282. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  283. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +23 -4
  284. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  285. package/artifacts/contracts/type/UFixed.sol/MathLib.json +9 -3
  286. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  287. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +39 -2
  288. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  289. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  290. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
  291. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  292. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +39 -70
  293. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  294. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
  295. package/contracts/authorization/AccessAdmin.sol +25 -24
  296. package/contracts/authorization/Authorization.sol +0 -1
  297. package/contracts/authorization/IAccessAdmin.sol +0 -1
  298. package/contracts/distribution/BasicDistribution.sol +4 -15
  299. package/contracts/distribution/BasicDistributionAuthorization.sol +2 -1
  300. package/contracts/distribution/Distribution.sol +22 -11
  301. package/contracts/distribution/DistributionService.sol +73 -25
  302. package/contracts/distribution/DistributionServiceManager.sol +6 -6
  303. package/contracts/distribution/IDistributionComponent.sol +6 -1
  304. package/contracts/distribution/IDistributionService.sol +18 -2
  305. package/contracts/examples/fire/FirePool.sol +75 -0
  306. package/contracts/examples/fire/FirePoolAuthorization.sol +34 -0
  307. package/contracts/examples/fire/FireProduct.sol +324 -0
  308. package/contracts/examples/fire/FireProductAuthorization.sol +35 -0
  309. package/contracts/examples/fire/FireUSD.sol +26 -0
  310. package/contracts/examples/unpermissioned/SimpleDistribution.sol +50 -0
  311. package/contracts/examples/unpermissioned/SimpleOracle.sol +137 -0
  312. package/contracts/examples/unpermissioned/SimplePool.sol +76 -0
  313. package/contracts/examples/unpermissioned/SimpleProduct.sol +351 -0
  314. package/contracts/instance/IInstance.sol +7 -30
  315. package/contracts/instance/Instance.sol +10 -35
  316. package/contracts/instance/InstanceAdmin.sol +23 -4
  317. package/contracts/instance/InstanceAuthorizationV3.sol +3 -3
  318. package/contracts/instance/InstanceReader.sol +32 -7
  319. package/contracts/instance/InstanceService.sol +62 -39
  320. package/contracts/instance/InstanceServiceManager.sol +6 -7
  321. package/contracts/instance/InstanceStore.sol +12 -1
  322. package/contracts/instance/base/ObjectLifecycle.sol +9 -4
  323. package/contracts/instance/module/IBundle.sol +1 -1
  324. package/contracts/instance/module/IComponents.sol +1 -6
  325. package/contracts/instance/module/IDistribution.sol +0 -1
  326. package/contracts/instance/module/IPolicy.sol +22 -22
  327. package/contracts/mock/Dip.sol +1 -1
  328. package/contracts/oracle/Oracle.sol +4 -7
  329. package/contracts/oracle/OracleService.sol +9 -6
  330. package/contracts/oracle/OracleServiceManager.sol +6 -6
  331. package/contracts/pool/BasicPool.sol +7 -5
  332. package/contracts/pool/BasicPoolAuthorization.sol +8 -2
  333. package/contracts/pool/BundleService.sol +184 -30
  334. package/contracts/pool/BundleServiceManager.sol +6 -6
  335. package/contracts/pool/IBundleService.sol +33 -5
  336. package/contracts/pool/IPoolComponent.sol +7 -0
  337. package/contracts/pool/IPoolService.sol +36 -26
  338. package/contracts/pool/Pool.sol +39 -24
  339. package/contracts/pool/PoolService.sol +157 -85
  340. package/contracts/pool/PoolServiceManager.sol +4 -4
  341. package/contracts/product/ApplicationService.sol +43 -26
  342. package/contracts/product/ApplicationServiceManager.sol +4 -4
  343. package/contracts/product/BasicProduct.sol +3 -32
  344. package/contracts/product/ClaimService.sol +208 -78
  345. package/contracts/product/ClaimServiceManager.sol +4 -4
  346. package/contracts/product/IApplicationService.sol +1 -0
  347. package/contracts/product/IClaimService.sol +28 -5
  348. package/contracts/product/IPolicyService.sol +31 -32
  349. package/contracts/product/IPricingService.sol +7 -7
  350. package/contracts/product/IProductComponent.sol +0 -1
  351. package/contracts/product/{IProductService.sol → IRiskService.sol} +1 -1
  352. package/contracts/product/PolicyService.sol +370 -194
  353. package/contracts/product/PolicyServiceManager.sol +4 -4
  354. package/contracts/product/PricingService.sol +46 -46
  355. package/contracts/product/PricingServiceManager.sol +3 -3
  356. package/contracts/product/Product.sol +67 -34
  357. package/contracts/product/{ProductService.sol → RiskService.sol} +7 -10
  358. package/contracts/product/RiskServiceManager.sol +39 -0
  359. package/contracts/registry/ChainNft.sol +65 -32
  360. package/contracts/registry/IRegistry.sol +49 -15
  361. package/contracts/registry/Registry.sol +321 -195
  362. package/contracts/registry/RegistryAdmin.sol +150 -51
  363. package/contracts/registry/RegistryService.sol +2 -2
  364. package/contracts/registry/RegistryServiceManager.sol +2 -2
  365. package/contracts/registry/ReleaseRegistry.sol +12 -8
  366. package/contracts/registry/ServiceAuthorizationV3.sol +2 -3
  367. package/contracts/shared/Component.sol +23 -29
  368. package/contracts/shared/ComponentService.sol +51 -32
  369. package/contracts/shared/ComponentServiceManager.sol +8 -5
  370. package/contracts/shared/ComponentVerifyingService.sol +1 -1
  371. package/contracts/shared/ContractLib.sol +38 -0
  372. package/contracts/shared/IComponent.sol +4 -4
  373. package/contracts/shared/IComponentService.sol +5 -9
  374. package/contracts/shared/IInstanceLinkedComponent.sol +8 -15
  375. package/contracts/shared/IPolicyHolder.sol +12 -22
  376. package/contracts/shared/{ERC165.sol → InitializableERC165.sol} +3 -3
  377. package/contracts/shared/InstanceLinkedComponent.sol +4 -4
  378. package/contracts/shared/NftOwnable.sol +7 -7
  379. package/contracts/shared/PolicyHolder.sol +14 -58
  380. package/contracts/shared/Registerable.sol +4 -4
  381. package/contracts/shared/RegistryLinked.sol +3 -2
  382. package/contracts/shared/Service.sol +16 -11
  383. package/contracts/shared/TokenHandler.sol +100 -19
  384. package/contracts/shared/TokenHandlerDeployerLib.sol +12 -0
  385. package/contracts/staking/IStaking.sol +2 -1
  386. package/contracts/staking/StakeManagerLib.sol +18 -25
  387. package/contracts/staking/Staking.sol +11 -27
  388. package/contracts/staking/StakingManager.sol +8 -6
  389. package/contracts/staking/StakingService.sol +10 -14
  390. package/contracts/staking/StakingServiceManager.sol +2 -2
  391. package/contracts/staking/TargetManagerLib.sol +7 -3
  392. package/contracts/type/Amount.sol +12 -5
  393. package/contracts/type/Blocknumber.sol +7 -1
  394. package/contracts/type/NftId.sol +1 -0
  395. package/contracts/type/ObjectType.sol +15 -11
  396. package/contracts/type/Referral.sol +1 -0
  397. package/contracts/type/RiskId.sol +15 -1
  398. package/contracts/type/Seconds.sol +21 -1
  399. package/contracts/type/StateId.sol +1 -0
  400. package/contracts/type/Timestamp.sol +11 -1
  401. package/contracts/type/UFixed.sol +29 -10
  402. package/contracts/upgradeability/ProxyManager.sol +67 -34
  403. package/contracts/upgradeability/Versionable.sol +2 -2
  404. package/package.json +1 -1
  405. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +0 -4
  406. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +0 -4
  407. package/artifacts/contracts/product/ProductService.sol/ProductService.json +0 -708
  408. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +0 -4
  409. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +0 -702
  410. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +0 -4
  411. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +0 -73
  412. package/contracts/product/ProductServiceManager.sol +0 -39
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {IBundle} from "../instance/module/IBundle.sol";
4
5
  import {IBundleService} from "./IBundleService.sol";
5
6
  import {IComponents} from "../instance/module/IComponents.sol";
6
7
  import {IComponentService} from "../shared/IComponentService.sol";
@@ -14,13 +15,12 @@ import {IStaking} from "../staking/IStaking.sol";
14
15
 
15
16
  import {Amount, AmountLib} from "../type/Amount.sol";
16
17
  import {Fee, FeeLib} from "../type/Fee.sol";
17
- import {NftId, NftIdLib} from "../type/NftId.sol";
18
+ import {NftId} from "../type/NftId.sol";
18
19
  import {ObjectType, POOL, BUNDLE, COMPONENT, INSTANCE, REGISTRY} from "../type/ObjectType.sol";
19
20
  import {RoleId, PUBLIC_ROLE} from "../type/RoleId.sol";
20
21
  import {Fee, FeeLib} from "../type/Fee.sol";
21
22
  import {KEEP_STATE} from "../type/StateId.sol";
22
23
  import {Seconds} from "../type/Seconds.sol";
23
- import {TokenHandler} from "../shared/TokenHandler.sol";
24
24
  import {UFixed} from "../type/UFixed.sol";
25
25
  import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
26
26
  import {InstanceReader} from "../instance/InstanceReader.sol";
@@ -32,9 +32,6 @@ contract PoolService is
32
32
  ComponentVerifyingService,
33
33
  IPoolService
34
34
  {
35
- using NftIdLib for NftId;
36
- using AmountLib for Amount;
37
-
38
35
  IBundleService internal _bundleService;
39
36
  IComponentService internal _componentService;
40
37
  IInstanceService private _instanceService;
@@ -47,16 +44,15 @@ contract PoolService is
47
44
  bytes memory data
48
45
  )
49
46
  internal
50
- initializer
51
47
  virtual override
48
+ initializer()
52
49
  {
53
50
  (
54
- address registryAddress,,
55
- //address managerAddress
51
+ address registryAddress,
56
52
  address authority
57
- ) = abi.decode(data, (address, address, address));
53
+ ) = abi.decode(data, (address, address));
58
54
 
59
- initializeService(registryAddress, authority, owner);
55
+ _initializeService(registryAddress, authority, owner);
60
56
 
61
57
  _registryService = IRegistryService(_getServiceAddress(REGISTRY()));
62
58
  _bundleService = IBundleService(_getServiceAddress(BUNDLE()));
@@ -65,27 +61,23 @@ contract PoolService is
65
61
 
66
62
  _staking = IStaking(getRegistry().getStakingAddress());
67
63
 
68
- registerInterface(type(IPoolService).interfaceId);
64
+ _registerInterface(type(IPoolService).interfaceId);
69
65
  }
70
66
 
71
-
72
- function setMaxCapitalAmount(Amount maxCapitalAmount)
67
+ /// @inheritdoc IPoolService
68
+ function setMaxBalanceAmount(Amount maxBalanceAmount)
73
69
  external
74
70
  virtual
75
71
  {
76
- /*
77
72
  (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
78
73
  InstanceReader instanceReader = instance.getInstanceReader();
74
+ IComponents.PoolInfo memory poolInfo = instanceReader.getPoolInfo(poolNftId);
79
75
 
80
- IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
81
- IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
82
- Amount previousMaxCapitalAmount = poolInfo.maxCapitalAmount;
83
-
84
- poolInfo.maxCapitalAmount = maxCapitalAmount;
76
+ Amount previousMaxBalanceAmount = poolInfo.maxBalanceAmount;
77
+ poolInfo.maxBalanceAmount = maxBalanceAmount;
85
78
  instance.getInstanceStore().updatePool(poolNftId, poolInfo, KEEP_STATE());
86
79
 
87
- emit LogPoolServiceMaxCapitalAmountUpdated(poolNftId, previousMaxCapitalAmount, maxCapitalAmount);
88
- */
80
+ emit LogPoolServiceMaxBalanceAmountUpdated(poolNftId, previousMaxBalanceAmount, maxBalanceAmount);
89
81
  }
90
82
 
91
83
  function setBundleOwnerRole(RoleId bundleOwnerRole)
@@ -109,31 +101,10 @@ contract PoolService is
109
101
  emit LogPoolServiceBundleOwnerRoleSet(poolNftId, bundleOwnerRole);
110
102
  }
111
103
 
112
-
113
- function setFees(
114
- Fee memory poolFee,
115
- Fee memory stakingFee,
116
- Fee memory performanceFee
117
- )
118
- external
119
- virtual
120
- {
121
- (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
122
-
123
- IComponents.PoolInfo memory poolInfo = instance.getInstanceReader().getPoolInfo(poolNftId);
124
- poolInfo.poolFee = poolFee;
125
- poolInfo.stakingFee = stakingFee;
126
- poolInfo.performanceFee = performanceFee;
127
-
128
- instance.getInstanceStore().updatePool(poolNftId, poolInfo, KEEP_STATE());
129
-
130
- // TODO add logging
131
- }
132
-
104
+ /// @inheritdoc IPoolService
133
105
  function createBundle(
134
106
  address bundleOwner, // initial bundle owner
135
107
  Fee memory fee, // fees deducted from premium that go to bundle owner
136
- Amount stakingAmount, // staking amount - staking fees result in initial bundle capital
137
108
  Seconds lifetime, // initial duration for which new policies are covered
138
109
  bytes calldata filter // optional use case specific criteria that define if a policy may be covered by this bundle
139
110
  )
@@ -142,38 +113,17 @@ contract PoolService is
142
113
  returns(NftId bundleNftId)
143
114
  {
144
115
  (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
145
- InstanceReader instanceReader = instance.getInstanceReader();
146
-
147
- (
148
- Amount stakingFeeAmount,
149
- Amount stakingNetAmount
150
- ) = FeeLib.calculateFee(
151
- _getStakingFee(instanceReader, poolNftId),
152
- stakingAmount);
153
116
 
117
+ // create the empty bundle
154
118
  bundleNftId = _bundleService.create(
155
119
  instance,
156
120
  poolNftId,
157
121
  bundleOwner,
158
122
  fee,
159
- stakingNetAmount,
123
+ AmountLib.zero(),
160
124
  lifetime,
161
125
  filter);
162
126
 
163
- // pool book keeping
164
- _componentService.increasePoolBalance(
165
- instance.getInstanceStore(),
166
- poolNftId,
167
- stakingAmount,
168
- stakingFeeAmount);
169
-
170
- // pool bookkeeping and collect tokens from bundle owner
171
- _collectStakingAmount(
172
- instanceReader,
173
- poolNftId,
174
- bundleOwner,
175
- stakingAmount);
176
-
177
127
  emit LogPoolServiceBundleCreated(instance.getNftId(), poolNftId, bundleNftId);
178
128
  }
179
129
 
@@ -183,8 +133,8 @@ contract PoolService is
183
133
  view
184
134
  returns (Fee memory stakingFee)
185
135
  {
186
- NftId productNftId = instanceReader.getPoolInfo(poolNftId).productNftId;
187
- return instanceReader.getPoolInfo(productNftId).stakingFee;
136
+ NftId productNftId = instanceReader.getComponentInfo(poolNftId).productNftId;
137
+ return instanceReader.getProductInfo(productNftId).stakingFee;
188
138
  }
189
139
 
190
140
  function closeBundle(NftId bundleNftId)
@@ -193,20 +143,147 @@ contract PoolService is
193
143
  {
194
144
  (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
195
145
 
196
- // TODO book keeping for pool collateral released outside of retention level
146
+ // TODO get performance fee for pool (#477)
197
147
 
198
148
  // releasing collateral in bundle
199
- _bundleService.close(instance, bundleNftId);
200
-
201
- // TODO get performance fee for pool, transfer of remaining funds + bundle fees to bundle owner
149
+ (Amount unstakedAmount, Amount feeAmount) = _bundleService.close(instance, bundleNftId);
202
150
 
151
+ _componentService.decreasePoolBalance(
152
+ instance.getInstanceStore(),
153
+ poolNftId,
154
+ unstakedAmount + feeAmount,
155
+ AmountLib.zero());
156
+
203
157
  emit LogPoolServiceBundleClosed(instance.getNftId(), poolNftId, bundleNftId);
158
+
159
+ if ((unstakedAmount + feeAmount).gtz()){
160
+ IComponents.ComponentInfo memory poolComponentInfo = instance.getInstanceReader().getComponentInfo(poolNftId);
161
+ poolComponentInfo.tokenHandler.distributeTokens(
162
+ poolComponentInfo.wallet,
163
+ getRegistry().ownerOf(bundleNftId),
164
+ unstakedAmount + feeAmount);
165
+ }
166
+ }
167
+
168
+ /// @inheritdoc IPoolService
169
+ function stake(NftId bundleNftId, Amount amount)
170
+ external
171
+ virtual
172
+ // TODO: restricted() (once #462 is done)
173
+ returns(Amount netAmount)
174
+ {
175
+ (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
176
+ InstanceReader instanceReader = instance.getInstanceReader();
177
+ IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
178
+ IComponents.PoolInfo memory poolInfo = instanceReader.getPoolInfo(poolNftId);
179
+
180
+ if (bundleInfo.poolNftId != poolNftId) {
181
+ revert ErrorPoolServiceBundlePoolMismatch(bundleNftId, poolNftId);
182
+ }
183
+
184
+ {
185
+ Amount currentPoolBalance = instanceReader.getBalanceAmount(poolNftId);
186
+ if (currentPoolBalance + amount > poolInfo.maxBalanceAmount) {
187
+ revert ErrorPoolServiceMaxBalanceAmountExceeded(poolNftId, poolInfo.maxBalanceAmount, currentPoolBalance, amount);
188
+ }
189
+ }
190
+
191
+ // calculate fees
192
+ Amount feeAmount;
193
+ (
194
+ feeAmount,
195
+ netAmount
196
+ ) = FeeLib.calculateFee(
197
+ _getStakingFee(instanceReader, poolNftId),
198
+ amount);
199
+
200
+ // do all the bookkeeping
201
+ _componentService.increasePoolBalance(
202
+ instance.getInstanceStore(),
203
+ poolNftId,
204
+ netAmount,
205
+ feeAmount);
206
+
207
+ _bundleService.stake(instance, bundleNftId, netAmount);
208
+
209
+ // collect tokens from bundle owner
210
+ address bundleOwner = getRegistry().ownerOf(bundleNftId);
211
+ emit LogPoolServiceBundleStaked(instance.getNftId(), poolNftId, bundleNftId, amount, netAmount);
212
+
213
+ // TODO only collect staking token when pool is not externally managed
214
+ _collectStakingAmount(
215
+ instanceReader,
216
+ poolNftId,
217
+ bundleOwner,
218
+ amount);
204
219
  }
205
220
 
221
+ /// @inheritdoc IPoolService
222
+ function unstake(NftId bundleNftId, Amount amount)
223
+ external
224
+ virtual
225
+ // TODO: restricted() (once #462 is done)
226
+ returns(Amount netAmount)
227
+ {
228
+ (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
229
+ InstanceReader instanceReader = instance.getInstanceReader();
230
+ InstanceStore instanceStore = instance.getInstanceStore();
231
+ IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
232
+
233
+ if (bundleInfo.poolNftId != poolNftId) {
234
+ revert ErrorPoolServiceBundlePoolMismatch(bundleNftId, poolNftId);
235
+ }
236
+
237
+ // call bundle service for bookkeeping and additional checks
238
+ Amount unstakedAmount = _bundleService.unstake(instance, bundleNftId, amount);
239
+
240
+ // Important: from now on work only with unstakedAmount as it is the only reliable amount.
241
+ // if amount was max, this was set to the available amount
242
+
243
+ // TODO: handle performance fees (issue #477)
244
+
245
+ // update pool bookkeeping - performance fees stay in the pool, but as fees
246
+ _componentService.decreasePoolBalance(
247
+ instanceStore,
248
+ poolNftId,
249
+ unstakedAmount,
250
+ AmountLib.zero());
251
+
252
+ IComponents.ComponentInfo memory poolComponentInfo = instanceReader.getComponentInfo(poolNftId);
253
+ address poolWallet = poolComponentInfo.wallet;
254
+ // transfer amount to bundle owner
255
+ address owner = getRegistry().ownerOf(bundleNftId);
256
+ emit LogPoolServiceBundleUnstaked(instance.getNftId(), poolNftId, bundleNftId, unstakedAmount);
257
+ poolComponentInfo.tokenHandler.distributeTokens(
258
+ poolWallet,
259
+ owner,
260
+ unstakedAmount);
261
+ return unstakedAmount;
262
+ }
263
+
264
+
265
+ function fundPoolWallet(NftId poolNftId, Amount amount)
266
+ external
267
+ virtual
268
+ restricted()
269
+ {
270
+ // TODO check that poolNftId is externally managed
271
+ // TODO implement
272
+ }
273
+
274
+
275
+ function defundPoolWallet(NftId poolNftId, Amount amount)
276
+ external
277
+ virtual
278
+ restricted()
279
+ {
280
+ // TODO check that poolNftId is externally managed
281
+ // TODO implement
282
+ }
206
283
 
207
284
  function processSale(
208
285
  NftId bundleNftId,
209
- IPolicy.Premium memory premium
286
+ IPolicy.PremiumInfo memory premium
210
287
  )
211
288
  external
212
289
  virtual
@@ -218,9 +295,9 @@ contract PoolService is
218
295
  IRegistry.ObjectInfo memory instanceObjectInfo = registry.getObjectInfo(poolObjectInfo.parentNftId);
219
296
  IInstance instance = IInstance(instanceObjectInfo.objectAddress);
220
297
 
221
- Amount poolFeeAmount = AmountLib.toAmount(premium.poolFeeFixAmount + premium.poolFeeVarAmount);
222
- Amount bundleFeeAmount = AmountLib.toAmount(premium.bundleFeeFixAmount + premium.bundleFeeVarAmount);
223
- Amount bundleNetAmount = AmountLib.toAmount(premium.netPremiumAmount);
298
+ Amount poolFeeAmount = premium.poolFeeFixAmount + premium.poolFeeVarAmount;
299
+ Amount bundleFeeAmount = premium.bundleFeeFixAmount + premium.bundleFeeVarAmount;
300
+ Amount bundleNetAmount = premium.netPremiumAmount;
224
301
 
225
302
  InstanceStore instanceStore = instance.getInstanceStore();
226
303
  _componentService.increasePoolBalance(
@@ -406,7 +483,6 @@ contract PoolService is
406
483
  }
407
484
 
408
485
 
409
- // TODO create (I)TreasuryService that deals with all gif related token transfers
410
486
  /// @dev transfers the specified amount from the bundle owner to the pool's wallet
411
487
  function _collectStakingAmount(
412
488
  InstanceReader instanceReader,
@@ -419,15 +495,11 @@ contract PoolService is
419
495
 
420
496
  // collecting investor token
421
497
  IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
422
- TokenHandler tokenHandler = componentInfo.tokenHandler;
423
498
  address poolWallet = componentInfo.wallet;
424
-
425
- if(amount.gtz()) {
426
- tokenHandler.transfer(
427
- bundleOwner,
428
- poolWallet,
429
- amount);
430
- }
499
+ componentInfo.tokenHandler.collectTokens(
500
+ bundleOwner,
501
+ poolWallet,
502
+ amount);
431
503
  }
432
504
 
433
505
  function _getDomain() internal pure override returns(ObjectType) {
@@ -12,14 +12,14 @@ contract PoolServiceManager is ProxyManager {
12
12
  /// @dev initializes proxy manager with pool service implementation
13
13
  constructor(
14
14
  address authority,
15
- address registryAddress,
15
+ address registry,
16
16
  bytes32 salt
17
17
  )
18
- ProxyManager(registryAddress)
19
18
  {
20
19
  PoolService poolSrv = new PoolService{salt: salt}();
21
- bytes memory data = abi.encode(registryAddress, address(this), authority);
22
- IVersionable versionable = deployDetermenistic(
20
+ bytes memory data = abi.encode(registry, authority);
21
+ IVersionable versionable = initialize(
22
+ registry,
23
23
  address(poolSrv),
24
24
  data,
25
25
  salt);
@@ -41,18 +41,17 @@ contract ApplicationService is
41
41
  initializer()
42
42
  {
43
43
  (
44
- address registryAddress,,
45
- //address managerAddress
44
+ address registryAddress,
46
45
  address authority
47
- ) = abi.decode(data, (address, address, address));
46
+ ) = abi.decode(data, (address, address));
48
47
 
49
- initializeService(registryAddress, address(0), owner);
48
+ _initializeService(registryAddress, authority, owner);
50
49
 
51
50
  _distributionService = IDistributionService(_getServiceAddress(DISTRIBUTION()));
52
51
  _pricingService = IPricingService(_getServiceAddress(PRICE()));
53
52
  _registryService = IRegistryService(_getServiceAddress(REGISTRY()));
54
53
 
55
- registerInterface(type(IApplicationService).interfaceId);
54
+ _registerInterface(type(IApplicationService).interfaceId);
56
55
  }
57
56
 
58
57
 
@@ -111,8 +110,7 @@ contract ApplicationService is
111
110
  view
112
111
  returns (Amount premiumAmount)
113
112
  {
114
- return AmountLib.toAmount(
115
- _pricingService.calculatePremium(
113
+ return _pricingService.calculatePremium(
116
114
  info.productNftId,
117
115
  info.riskId,
118
116
  info.sumInsuredAmount,
@@ -120,7 +118,7 @@ contract ApplicationService is
120
118
  info.applicationData,
121
119
  info.bundleNftId,
122
120
  info.referralId
123
- ).premiumAmount);
121
+ ).premiumAmount;
124
122
  }
125
123
 
126
124
 
@@ -128,6 +126,7 @@ contract ApplicationService is
128
126
  address applicationOwner,
129
127
  RiskId riskId,
130
128
  Amount sumInsuredAmount,
129
+ Amount premiumAmount,
131
130
  Seconds lifetime,
132
131
  NftId bundleNftId,
133
132
  ReferralId referralId,
@@ -152,14 +151,45 @@ contract ApplicationService is
152
151
  applicationNftId = _registerApplication(productNftId, applicationOwner);
153
152
 
154
153
  // create policy info for application
155
- IPolicy.PolicyInfo memory applicationInfo = IPolicy.PolicyInfo({
154
+ IPolicy.PolicyInfo memory applicationInfo = _createApplicationInfo(
155
+ productNftId,
156
+ riskId,
157
+ sumInsuredAmount,
158
+ premiumAmount,
159
+ lifetime,
160
+ bundleNftId,
161
+ referralId,
162
+ applicationData);
163
+
164
+ // register application with instance
165
+ instance.getInstanceStore().createApplication(
166
+ applicationNftId,
167
+ applicationInfo);
168
+
169
+ // TODO: add logging
170
+ }
171
+
172
+ function _createApplicationInfo(
173
+ NftId productNftId,
174
+ RiskId riskId,
175
+ Amount sumInsuredAmount,
176
+ Amount premiumAmount,
177
+ Seconds lifetime,
178
+ NftId bundleNftId,
179
+ ReferralId referralId,
180
+ bytes memory applicationData
181
+ )
182
+ internal
183
+ virtual
184
+ returns (IPolicy.PolicyInfo memory applicationInfo)
185
+ {
186
+ return IPolicy.PolicyInfo({
156
187
  productNftId: productNftId,
157
188
  bundleNftId: bundleNftId,
158
189
  referralId: referralId,
159
190
  riskId: riskId,
160
191
  sumInsuredAmount: sumInsuredAmount,
161
- premiumAmount: AmountLib.zero(),
162
- premiumPaidAmount: AmountLib.zero(),
192
+ premiumAmount: premiumAmount,
163
193
  lifetime: lifetime,
164
194
  applicationData: applicationData,
165
195
  processData: "",
@@ -171,21 +201,8 @@ contract ApplicationService is
171
201
  expiredAt: zeroTimestamp(),
172
202
  closedAt: zeroTimestamp()
173
203
  });
174
-
175
- // TODO consider to provide this amount externally
176
- // actual calculation is done 2nd time anyway for premium collection
177
- // calculate premium amount
178
- applicationInfo.premiumAmount = _calculatePremiumAmount(applicationInfo);
179
-
180
- // register application with instance
181
- instance.getInstanceStore().createApplication(
182
- applicationNftId,
183
- applicationInfo);
184
-
185
- // TODO: add logging
186
204
  }
187
205
 
188
-
189
206
  function renew(
190
207
  NftId policyNftId, // policy to be renewd (renewal inherits policy attributes)
191
208
  NftId bundleNftId // will likely need a newer bundle for underwriting
@@ -194,7 +211,7 @@ contract ApplicationService is
194
211
  virtual override
195
212
  returns (NftId applicationNftId)
196
213
  {
197
-
214
+ // TODO implement
198
215
  }
199
216
 
200
217
 
@@ -210,7 +227,7 @@ contract ApplicationService is
210
227
  external
211
228
  virtual override
212
229
  {
213
-
230
+ // TODO implement
214
231
  }
215
232
 
216
233
  function revoke(NftId applicationNftId)
@@ -12,14 +12,14 @@ contract ApplicationServiceManager is ProxyManager {
12
12
  /// @dev initializes proxy manager with service implementation
13
13
  constructor(
14
14
  address authority,
15
- address registryAddress,
15
+ address registry,
16
16
  bytes32 salt
17
17
  )
18
- ProxyManager(registryAddress)
19
18
  {
20
19
  ApplicationService svc = new ApplicationService{salt: salt}();
21
- bytes memory data = abi.encode(registryAddress, address(this), authority);
22
- IVersionable versionable = deployDetermenistic(
20
+ bytes memory data = abi.encode(registry, authority);
21
+ IVersionable versionable = initialize(
22
+ registry,
23
23
  address(svc),
24
24
  data,
25
25
  salt);
@@ -1,43 +1,15 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
-
6
- import {Amount, AmountLib} from "../type/Amount.sol";
7
- import {ClaimId} from "../type/ClaimId.sol";
8
- import {InstanceLinkedComponent} from "../shared/InstanceLinkedComponent.sol";
9
- import {Fee, FeeLib} from "../type/Fee.sol";
10
- import {IRisk} from "../instance/module/IRisk.sol";
11
- import {IApplicationService} from "./IApplicationService.sol";
4
+ import {Fee} from "../type/Fee.sol";
12
5
  import {IAuthorization} from "../authorization/IAuthorization.sol";
13
- import {IComponentService} from "../shared/IComponentService.sol";
14
- import {IPolicyService} from "./IPolicyService.sol";
15
- import {IProductService} from "./IProductService.sol";
16
- import {IClaimService} from "./IClaimService.sol";
17
- import {IPricingService} from "./IPricingService.sol";
18
- import {IProductComponent} from "./IProductComponent.sol";
19
- import {NftId, NftIdLib} from "../type/NftId.sol";
6
+ import {NftId} from "../type/NftId.sol";
20
7
  import {Product} from "../product/Product.sol";
21
- import {PayoutId} from "../type/PayoutId.sol";
22
- import {COMPONENT, PRODUCT, APPLICATION, POLICY, CLAIM, PRICE } from "../type/ObjectType.sol";
23
- import {ReferralId} from "../type/Referral.sol";
24
- import {RiskId, RiskIdLib} from "../type/RiskId.sol";
25
- import {Seconds} from "../type/Seconds.sol";
26
- import {StateId} from "../type/StateId.sol";
27
- import {Timestamp} from "../type/Timestamp.sol";
28
-
29
- import {TokenHandler} from "../shared/TokenHandler.sol";
30
-
31
- import {InstanceReader} from "../instance/InstanceReader.sol";
32
- import {IPolicy} from "../instance/module/IPolicy.sol";
33
- import {IComponents} from "../instance/module/IComponents.sol";
34
- import {Pool} from "../pool/Pool.sol";
35
- import {Distribution} from "../distribution/Distribution.sol";
36
8
 
37
9
  abstract contract BasicProduct is
38
10
  Product
39
11
  {
40
-
12
+
41
13
  function setFees(
42
14
  Fee memory productFee,
43
15
  Fee memory processingFee
@@ -50,7 +22,6 @@ abstract contract BasicProduct is
50
22
  _setFees(productFee, processingFee);
51
23
  }
52
24
 
53
-
54
25
  function _initializeBasicProduct(
55
26
  address registry,
56
27
  NftId instanceNftId,