@etherisc/gif-next 0.0.2-f29e479-370 → 0.0.2-f30e0eb-805

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  2. package/artifacts/contracts/components/Component.sol/Component.json +68 -89
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +113 -140
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.json +65 -73
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +91 -122
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +256 -189
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +69 -145
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +279 -245
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +73 -162
  17. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  18. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  19. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  20. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
  21. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  22. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
  23. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  24. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +171 -308
  25. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  26. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +98 -40
  27. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  28. package/artifacts/contracts/instance/Instance.sol/Instance.json +260 -379
  29. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  30. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +448 -121
  31. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  32. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +120 -227
  33. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +148 -161
  35. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  36. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +31 -23
  37. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  38. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
  39. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  40. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +1 -1
  41. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +40 -10
  45. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
  47. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  48. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +54 -71
  49. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
  51. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
  52. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  57. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  58. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +161 -62
  59. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  60. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +33 -25
  61. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  62. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +137 -140
  63. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  64. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +12 -12
  65. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  66. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +3 -3
  67. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  68. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +2 -2
  69. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +505 -91
  71. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +78 -42
  73. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +110 -27
  75. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +93 -96
  77. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +350 -8
  80. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +21 -64
  82. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +81 -0
  84. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +58 -157
  87. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +19 -47
  89. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +114 -17
  91. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -9
  93. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +7 -7
  95. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +4 -4
  97. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  98. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
  99. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  100. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
  101. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  102. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  103. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
  104. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  105. package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
  106. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  107. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  108. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  109. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +5 -5
  110. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  111. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +3 -3
  112. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  113. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +7 -7
  114. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  115. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  116. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  117. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  118. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  119. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  120. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  122. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  124. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  126. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  127. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  129. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +3 -3
  132. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  133. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  134. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Service.sol/Service.json +1 -1
  136. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  137. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  138. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  139. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  140. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  143. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +3 -3
  145. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
  147. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestService.sol/TestService.json +3 -3
  149. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  152. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  154. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  155. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  156. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  158. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  162. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/Fee.sol/FeeLib.json +2 -2
  164. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  166. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  168. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  169. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  170. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  173. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
  176. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  178. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  180. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
  181. package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
  182. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  184. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
  186. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  188. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  190. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  192. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  194. package/contracts/components/Component.sol +95 -85
  195. package/contracts/components/Distribution.sol +12 -19
  196. package/contracts/components/IComponent.sol +37 -17
  197. package/contracts/components/IDistributionComponent.sol +1 -22
  198. package/contracts/components/IPoolComponent.sol +73 -47
  199. package/contracts/components/IProductComponent.sol +3 -2
  200. package/contracts/components/Pool.sol +171 -126
  201. package/contracts/components/Product.sol +26 -18
  202. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
  203. package/contracts/instance/BundleManager.sol +7 -5
  204. package/contracts/instance/Cloneable.sol +7 -2
  205. package/contracts/instance/IInstance.sol +16 -10
  206. package/contracts/instance/IInstanceService.sol +18 -5
  207. package/contracts/instance/Instance.sol +45 -9
  208. package/contracts/instance/InstanceAccessManager.sol +382 -157
  209. package/contracts/instance/InstanceReader.sol +7 -10
  210. package/contracts/instance/InstanceService.sol +174 -155
  211. package/contracts/instance/ObjectManager.sol +6 -8
  212. package/contracts/instance/base/ComponentService.sol +5 -5
  213. package/contracts/instance/base/KeyValueStore.sol +5 -2
  214. package/contracts/instance/base/Lifecycle.sol +11 -2
  215. package/contracts/instance/module/IAccess.sol +20 -13
  216. package/contracts/instance/module/IBundle.sol +2 -1
  217. package/contracts/instance/module/IComponents.sol +35 -0
  218. package/contracts/instance/module/IDistribution.sol +2 -1
  219. package/contracts/instance/module/IPolicy.sol +26 -1
  220. package/contracts/instance/module/ISetup.sol +7 -22
  221. package/contracts/instance/service/ApplicationService.sol +123 -41
  222. package/contracts/instance/service/BundleService.sol +76 -38
  223. package/contracts/instance/service/DistributionService.sol +139 -47
  224. package/contracts/instance/service/IApplicationService.sol +7 -7
  225. package/contracts/instance/service/IBundleService.sol +19 -11
  226. package/contracts/instance/service/IDistributionService.sol +19 -4
  227. package/contracts/instance/service/IPolicyService.sol +3 -20
  228. package/contracts/instance/service/IPoolService.sol +17 -2
  229. package/contracts/instance/service/PolicyService.sol +59 -132
  230. package/contracts/instance/service/PoolService.sol +128 -17
  231. package/contracts/instance/service/ProductService.sol +10 -2
  232. package/contracts/registry/ChainNft.sol +8 -0
  233. package/contracts/registry/IRegistry.sol +2 -0
  234. package/contracts/registry/ITransferInterceptor.sol +1 -0
  235. package/contracts/registry/Registry.sol +23 -20
  236. package/contracts/registry/RegistryService.sol +5 -5
  237. package/contracts/shared/Registerable.sol +2 -2
  238. package/contracts/shared/TokenHandler.sol +11 -5
  239. package/contracts/types/Blocknumber.sol +1 -0
  240. package/contracts/types/Fee.sol +1 -0
  241. package/contracts/types/NftId.sol +8 -0
  242. package/contracts/types/ObjectType.sol +1 -0
  243. package/contracts/types/Referral.sol +4 -0
  244. package/contracts/types/RoleId.sol +13 -6
  245. package/contracts/types/Seconds.sol +54 -0
  246. package/contracts/types/StateId.sol +1 -0
  247. package/contracts/types/Timestamp.sol +13 -13
  248. package/contracts/types/UFixed.sol +1 -0
  249. package/contracts/types/Version.sol +1 -0
  250. package/package.json +1 -1
@@ -88,7 +88,7 @@ contract KeyValueStore is Lifecycle, IKeyValueStore {
88
88
 
89
89
  // create log entries
90
90
  // solhint-disable avoid-tx-origin
91
- emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), state, stateOld, updatedBy, tx.origin, lastUpdatedIn);
91
+ emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), stateOld, state, updatedBy, tx.origin, lastUpdatedIn);
92
92
  emit LogInfoUpdated(key32.toObjectType(), key32.toKeyId(), state, updatedBy, tx.origin, lastUpdatedIn);
93
93
  // solhing-enable
94
94
  }
@@ -134,6 +134,9 @@ contract KeyValueStore is Lifecycle, IKeyValueStore {
134
134
  StateId stateOld = metadata.state;
135
135
  require(stateOld.gtz(), "ERROR:KVS-041:NOT_EXISTING");
136
136
 
137
+ // ensure state transistion is valid
138
+ checkTransition(metadata.objectType, stateOld, state);
139
+
137
140
  // update metadata (and state)
138
141
  address updatedBy = msg.sender;
139
142
  Blocknumber lastUpdatedIn = metadata.updatedIn;
@@ -143,7 +146,7 @@ contract KeyValueStore is Lifecycle, IKeyValueStore {
143
146
 
144
147
  // create log entry
145
148
  // solhint-disable-next-line avoid-tx-origin
146
- emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), state, stateOld, updatedBy, tx.origin, lastUpdatedIn);
149
+ emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), stateOld, state, updatedBy, tx.origin, lastUpdatedIn);
147
150
  }
148
151
 
149
152
  function exists(Key32 key32) public view returns (bool) {
@@ -1,19 +1,27 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
+
4
6
  import {NftId} from "../../types/NftId.sol";
5
7
  import {ObjectType, COMPONENT, BUNDLE, POLICY, RISK} from "../../types/ObjectType.sol";
6
8
  import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, UNDERWRITTEN, REVOKED, DECLINED} from "../../types/StateId.sol";
7
9
  import {ILifecycle} from "./ILifecycle.sol";
8
10
 
9
- contract Lifecycle is ILifecycle {
11
+ contract Lifecycle is
12
+ Initializable,
13
+ ILifecycle
14
+ {
10
15
  mapping(ObjectType objectType => StateId initialState)
11
16
  private _initialState;
12
17
 
13
18
  mapping(ObjectType objectType => mapping(StateId stateFrom => mapping(StateId stateTo => bool isValid)))
14
19
  private _isValidTransition;
15
20
 
16
- constructor() {
21
+ function initializeLifecycle()
22
+ public
23
+ onlyInitializing
24
+ {
17
25
  _setupBundleLifecycle();
18
26
  _setupComponentLifecycle();
19
27
  _setupPolicyLifecycle();
@@ -78,6 +86,7 @@ contract Lifecycle is ILifecycle {
78
86
  function _setupBundleLifecycle() internal {
79
87
  _initialState[BUNDLE()] = ACTIVE();
80
88
  _isValidTransition[BUNDLE()][ACTIVE()][PAUSED()] = true;
89
+ _isValidTransition[BUNDLE()][ACTIVE()][CLOSED()] = true;
81
90
  _isValidTransition[BUNDLE()][PAUSED()][ACTIVE()] = true;
82
91
  _isValidTransition[BUNDLE()][PAUSED()][CLOSED()] = true;
83
92
  }
@@ -8,40 +8,47 @@ import {Timestamp} from "../../types/Timestamp.sol";
8
8
 
9
9
  interface IAccess {
10
10
 
11
+ enum Type {
12
+ NotInitialized,
13
+ Core,
14
+ Gif,
15
+ Custom
16
+ }
17
+
11
18
  struct RoleInfo {
12
19
  ShortString name;
13
- bool isCustom;
14
- bool isLocked;
20
+ Type rtype;
21
+ //bool isLocked;
22
+ RoleId admin;
15
23
  Timestamp createdAt;
16
24
  Timestamp updatedAt;
17
25
  }
18
26
 
19
27
  struct TargetInfo {
20
28
  ShortString name;
21
- bool isCustom;
29
+ Type ttype;
22
30
  bool isLocked;
23
31
  Timestamp createdAt;
24
32
  Timestamp updatedAt;
25
33
  }
26
34
 
27
- error ErrorIAccessRoleIdInvalid(RoleId roleId);
35
+ error ErrorIAccessCallerIsNotRoleAdmin(address caller, RoleId roleId);
36
+
37
+ error ErrorIAccessRoleIdDoesNotExist(RoleId roleId);
28
38
  error ErrorIAccessRoleIdTooBig(RoleId roleId);
29
39
  error ErrorIAccessRoleIdTooSmall(RoleId roleId);
30
- error ErrorIAccessRoleIdAlreadyExists(RoleId roleId, ShortString name);
31
- error ErrorIAccessRoleIdNotActive(RoleId roleId);
40
+ error ErrorIAccessRoleIdExists(RoleId roleId);
32
41
  error ErrorIAccessRoleNameEmpty(RoleId roleId);
33
- error ErrorIAccessRoleNameNotUnique(RoleId roleId, ShortString name);
34
- error ErrorIAccessRoleInvalidUpdate(RoleId roleId, bool isCustom);
35
- error ErrorIAccessRoleIsCustomIsImmutable(RoleId roleId, bool isCustom, bool isCustomExisting);
36
- error ErrorIAccessGrantNonexstentRole(RoleId roleId);
37
- error ErrorIAccessRevokeNonexstentRole(RoleId roleId);
38
- error ErrorIAccessRenounceNonexstentRole(RoleId roleId);
42
+ error ErrorIAccessRoleNameExists(RoleId roleId, RoleId existingRoleId, ShortString name);
43
+ error ErrorIAccessRoleTypeInvalid(RoleId roleId, Type rtype);
39
44
 
40
45
  error ErrorIAccessTargetAddressZero();
41
46
  error ErrorIAccessTargetDoesNotExist(ShortString name);
42
- error ErrorIAccessTargetAddressDoesNotExist(address target);
43
47
  error ErrorIAccessTargetExists(address target, ShortString name);
48
+ error ErrorIAccessTargetTypeInvalid(ShortString name, Type ttype);
44
49
  error ErrorIAccessTargetNameEmpty(address target);
45
50
  error ErrorIAccessTargetNameExists(address target, address existingTarget, ShortString name);
46
51
  error ErrorIAccessTargetLocked(address target);
52
+ error ErrorIAccessTargetNotRegistered(address target);
53
+ error ErrorIAccessTargetAuthorityInvalid(address target, address targetAuthority);
47
54
  }
@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {NftId} from "../../types/NftId.sol";
5
5
  import {Fee} from "../../types/Fee.sol";
6
+ import {Seconds} from "../../types/Seconds.sol";
6
7
  import {Timestamp} from "../../types/Timestamp.sol";
7
8
 
8
9
  interface IBundle {
@@ -13,7 +14,7 @@ interface IBundle {
13
14
  uint256 capitalAmount; // net investment capital + net premiums - payouts
14
15
  uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
15
16
  uint256 balanceAmount; // total amount of funds: capitalAmount + fees (balance >= captial)
16
- uint256 lifetime;
17
+ Seconds lifetime;
17
18
  Timestamp expiredAt; // no new policies
18
19
  Timestamp closedAt; // no open policies, locked amount = 0
19
20
  }
@@ -0,0 +1,35 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+
6
+ import {Fee} from "../../types/Fee.sol";
7
+ import {NftId} from "../../types/NftId.sol";
8
+ import {RoleId} from "../../types/RoleId.sol";
9
+ import {TokenHandler} from "../../shared/TokenHandler.sol";
10
+ import {UFixed} from "../../types/UFixed.sol";
11
+
12
+ interface IComponents {
13
+
14
+ struct ComponentInfo {
15
+ string name; // component name (needs to be unique per instance)
16
+ IERC20Metadata token;
17
+ TokenHandler tokenHandler;
18
+ address wallet;
19
+ bytes data; // will hold component type specific additional info (eg encoded pool info)
20
+ }
21
+
22
+ struct PoolInfo {
23
+ NftId productNftId; // the nft of the product this pool is linked to
24
+ RoleId bundleOwnerRole; // the required role for bundle owners
25
+ uint256 maxCapitalAmount; // max capital amount allowed for pool
26
+ bool isInterceptingBundleTransfers; // intercepts nft transfers for bundles
27
+ bool isExternallyManaged; // funding bundles is restricted to book keeping, actual funds may be provided as needed to support payouts
28
+ bool isVerifyingApplications; // underwriting requires the pool component checks/confirms the applications
29
+ UFixed collateralizationLevel; // factor to calculate collateral for sum insurance (default 100%)
30
+ UFixed retentionLevel; // amount of collateral held in pool (default 100%)
31
+ Fee poolFee; // pool fee on net premium
32
+ Fee stakingFee; // pool fee on staked capital from investor
33
+ Fee performanceFee; // pool fee on profits from capital investors
34
+ }
35
+ }
@@ -24,7 +24,8 @@ interface IDistribution {
24
24
  DistributorType distributorType;
25
25
  bool active;
26
26
  bytes data;
27
- // TODO: track commission, number of sold policies, etc.
27
+ uint256 sumCommisions;
28
+ uint256 numPoliciesSold;
28
29
  }
29
30
 
30
31
  struct ReferralInfo {
@@ -5,10 +5,35 @@ import {NftId} from "../../types/NftId.sol";
5
5
  import {ClaimId} from "../../types/ClaimId.sol";
6
6
  import {ReferralId} from "../../types/Referral.sol";
7
7
  import {RiskId} from "../../types/RiskId.sol";
8
+ import {Seconds} from "../../types/Seconds.sol";
8
9
  import {Timestamp} from "../../types/Timestamp.sol";
9
10
 
10
11
  interface IPolicy {
11
12
 
13
+ struct Premium {
14
+ // this is the net premium calculated by the product
15
+ uint256 netPremiumAmount;
16
+ // fullPremium = netPremium + all fixed amounts + all variable amounts (excl commission and minDistribtuionOwnerFee variable part)
17
+ uint256 fullPremiumAmount;
18
+ // premium = fullPremium - discount
19
+ uint256 premiumAmount;
20
+ uint256 productFeeFixAmount;
21
+ uint256 poolFeeFixAmount;
22
+ uint256 bundleFeeFixAmount;
23
+ uint256 distributionFeeFixAmount;
24
+ uint256 productFeeVarAmount;
25
+ uint256 poolFeeVarAmount;
26
+ uint256 bundleFeeVarAmount;
27
+ uint256 distributionFeeVarAmount;
28
+ uint256 distributionOwnerFeeFixAmount;
29
+ // this is the remaining amount when the commission and discount are subtracted from the distribution fee variable part (must be at least the minDistributionOwnerFee)
30
+ uint256 distributionOwnerFeeVarAmount;
31
+ // this value is based on distributor type referenced in the referral
32
+ uint256 commissionAmount;
33
+ // this is based on referral used
34
+ uint256 discountAmount;
35
+ }
36
+
12
37
  /// @dev policy data for the full policy lifecycle
13
38
  struct PolicyInfo {
14
39
  NftId productNftId;
@@ -18,7 +43,7 @@ interface IPolicy {
18
43
  uint256 sumInsuredAmount;
19
44
  uint256 premiumAmount;
20
45
  uint256 premiumPaidAmount;
21
- uint256 lifetime;
46
+ Seconds lifetime;
22
47
  bytes applicationData;
23
48
  bytes policyData;
24
49
  uint16 claimsCount;
@@ -5,21 +5,19 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
5
5
 
6
6
  import {Fee} from "../../types/Fee.sol";
7
7
  import {NftId} from "../../types/NftId.sol";
8
- import {UFixed} from "../../types/UFixed.sol";
8
+ import {RoleId} from "../../types/RoleId.sol";
9
9
  import {TokenHandler} from "../../shared/TokenHandler.sol";
10
+ import {UFixed} from "../../types/UFixed.sol";
10
11
 
11
12
  interface ISetup {
13
+
12
14
  struct ProductSetupInfo {
13
15
  IERC20Metadata token;
14
16
  TokenHandler tokenHandler;
15
17
  NftId distributionNftId;
16
18
  NftId poolNftId;
17
- Fee distributionFee; // default distribution fee (no referral id)
18
19
  Fee productFee; // product fee on net premium
19
- Fee processingFee; // product fee on payout amounts
20
- Fee poolFee; // pool fee on net premium
21
- Fee stakingFee; // pool fee on staked capital from investor
22
- Fee performanceFee; // pool fee on profits from capital investors
20
+ Fee processingFee; // product fee on payout amounts
23
21
  bool isIntercepting; // intercepts nft transfers (for products)
24
22
  address wallet;
25
23
  }
@@ -27,22 +25,9 @@ interface ISetup {
27
25
  struct DistributionSetupInfo {
28
26
  NftId productNftId;
29
27
  TokenHandler tokenHandler;
30
- Fee distributionFee; // default distribution fee (no referral id)
31
- address wallet;
32
- // TODO: add sum of distibution owner fees (excl commissions from distributors)
33
- }
34
-
35
- struct PoolSetupInfo {
36
- NftId productNftId;
37
- TokenHandler tokenHandler;
38
- bool isInterceptingBundleTransfers; // intercepts nft transfers for bundles
39
- bool isExternallyManaged; // funding bundles is restricted to book keeping, actual funds may be provided as needed to support payouts
40
- bool isVerifyingApplications; // underwriting requires the pool component checks/confirms the applications
41
- UFixed collateralizationLevel; // factor to calculate collateral for sum insurance (default 100%)
42
- UFixed retentionLevel; // amount of collateral held in pool (default 100%)
43
- Fee poolFee; // pool fee on net premium
44
- Fee stakingFee; // pool fee on staked capital from investor
45
- Fee performanceFee; // pool fee on profits from capital investors
28
+ Fee minDistributionOwnerFee;
29
+ Fee distributionFee; // recalculated whenever any fee on the product/pool/dist/disttype is changed
46
30
  address wallet;
31
+ uint256 sumDistributionOwnerFees;
47
32
  }
48
33
  }
@@ -10,6 +10,7 @@ import {Product} from "../../components/Product.sol";
10
10
  import {IPoolComponent} from "../../components/IPoolComponent.sol";
11
11
  import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
12
12
  import {IInstance} from "../IInstance.sol";
13
+ import {IComponents} from "../module/IComponents.sol";
13
14
  import {IPolicy} from "../module/IPolicy.sol";
14
15
  import {IRisk} from "../module/IRisk.sol";
15
16
  import {IBundle} from "../module/IBundle.sol";
@@ -22,10 +23,11 @@ import {TokenHandler} from "../../shared/TokenHandler.sol";
22
23
  import {IVersionable} from "../../shared/IVersionable.sol";
23
24
  import {Versionable} from "../../shared/Versionable.sol";
24
25
 
26
+ import {Seconds} from "../../types/Seconds.sol";
25
27
  import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
26
28
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
27
29
  import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
28
- import {ObjectType, INSTANCE, PRODUCT, POOL, APPLICATION, POLICY, BUNDLE} from "../../types/ObjectType.sol";
30
+ import {ObjectType, DISTRIBUTION, INSTANCE, PRODUCT, POOL, APPLICATION, POLICY, BUNDLE} from "../../types/ObjectType.sol";
29
31
  import {APPLIED, REVOKED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
30
32
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
31
33
  import {Fee, FeeLib} from "../../types/Fee.sol";
@@ -38,6 +40,7 @@ import {ComponentService} from "../base/ComponentService.sol";
38
40
  import {InstanceReader} from "../InstanceReader.sol";
39
41
  import {IApplicationService} from "./IApplicationService.sol";
40
42
  import {IBundleService} from "./IBundleService.sol";
43
+ import {IDistributionService} from "./IDistributionService.sol";
41
44
  import {IPoolService} from "./IPoolService.sol";
42
45
  import {IService} from "../../shared/IService.sol";
43
46
  import {Service} from "../../shared/Service.sol";
@@ -47,6 +50,7 @@ contract ApplicationService is
47
50
  ComponentService,
48
51
  IApplicationService
49
52
  {
53
+ IDistributionService internal _distributionService;
50
54
 
51
55
  function _initialize(
52
56
  address owner,
@@ -63,6 +67,8 @@ contract ApplicationService is
63
67
 
64
68
  initializeService(registryAddress, owner);
65
69
  registerInterface(type(IApplicationService).interfaceId);
70
+
71
+ _distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), getMajorVersion()));
66
72
  }
67
73
 
68
74
 
@@ -75,7 +81,7 @@ contract ApplicationService is
75
81
  address applicationOwner,
76
82
  RiskId riskId,
77
83
  uint256 sumInsuredAmount,
78
- uint256 lifetime,
84
+ Seconds lifetime,
79
85
  NftId bundleNftId,
80
86
  ReferralId referralId,
81
87
  bytes memory applicationData
@@ -99,7 +105,9 @@ contract ApplicationService is
99
105
  )
100
106
  );
101
107
 
102
- (uint256 premiumAmount,,,,) = calculatePremium(
108
+ // (uint256 premiumAmount,,,,,) = calculatePremium(
109
+ IPolicy.Premium memory premium = calculatePremium(
110
+ productInfo.nftId,
103
111
  riskId,
104
112
  sumInsuredAmount,
105
113
  lifetime,
@@ -114,7 +122,7 @@ contract ApplicationService is
114
122
  referralId,
115
123
  riskId,
116
124
  sumInsuredAmount,
117
- premiumAmount,
125
+ premium.premiumAmount,
118
126
  0,
119
127
  lifetime,
120
128
  applicationData,
@@ -128,7 +136,6 @@ contract ApplicationService is
128
136
  );
129
137
 
130
138
  instance.createApplication(applicationNftId, policyInfo);
131
- instance.updateApplicationState(applicationNftId, APPLIED());
132
139
 
133
140
  // TODO: add logging
134
141
  }
@@ -169,11 +176,12 @@ contract ApplicationService is
169
176
  instance.updateApplicationState(applicationNftId, REVOKED());
170
177
  }
171
178
 
172
-
179
+ // TODO: maybe move this to a pricing service later
173
180
  function calculatePremium(
181
+ NftId productNftId,
174
182
  RiskId riskId,
175
183
  uint256 sumInsuredAmount,
176
- uint256 lifetime,
184
+ Seconds lifetime,
177
185
  bytes memory applicationData,
178
186
  NftId bundleNftId,
179
187
  ReferralId referralId
@@ -182,42 +190,36 @@ contract ApplicationService is
182
190
  view
183
191
  virtual override
184
192
  returns (
185
- uint256 premiumAmount,
186
- uint256 distributionFeeAmount,
187
- uint256 productFeeAmount,
188
- uint256 poolFeeAmount,
189
- uint256 bundleFeeAmount
193
+ IPolicy.Premium memory premium
190
194
  )
191
195
  {
192
- Product product = _getAndVerifyInstanceAndProduct();
193
- uint256 netPremiumAmount = product.calculateNetPremium(
196
+ uint256 netPremiumAmount = _getAndVerifyProduct(productNftId).calculateNetPremium(
194
197
  sumInsuredAmount,
195
198
  riskId,
196
199
  lifetime,
197
200
  applicationData
198
201
  );
199
202
 
200
- (
201
- productFeeAmount,
202
- poolFeeAmount,
203
- bundleFeeAmount,
204
- distributionFeeAmount
205
- ) = _calculateFeeAmounts(
203
+ premium = _getFixedFeeAmounts(
206
204
  netPremiumAmount,
207
- product,
205
+ _getAndVerifyProduct(productNftId),
208
206
  bundleNftId,
209
207
  referralId
210
208
  );
211
209
 
212
- premiumAmount = netPremiumAmount + productFeeAmount;
213
- premiumAmount += poolFeeAmount + bundleFeeAmount;
214
- premiumAmount += distributionFeeAmount;
210
+ (
211
+ premium
212
+ ) = _calculateVariableFeeAmounts(
213
+ premium,
214
+ _getAndVerifyProduct(productNftId),
215
+ bundleNftId,
216
+ referralId
217
+ );
215
218
  }
216
219
 
217
220
 
218
221
  // internal functions
219
-
220
- function _calculateFeeAmounts(
222
+ function _getFixedFeeAmounts(
221
223
  uint256 netPremiumAmount,
222
224
  Product product,
223
225
  NftId bundleNftId,
@@ -226,10 +228,7 @@ contract ApplicationService is
226
228
  internal
227
229
  view
228
230
  returns (
229
- uint256 productFeeAmount,
230
- uint256 poolFeeAmount,
231
- uint256 bundleFeeAmount,
232
- uint256 distributionFeeAmount
231
+ IPolicy.Premium memory premium
233
232
  )
234
233
  {
235
234
  InstanceReader instanceReader;
@@ -239,24 +238,100 @@ contract ApplicationService is
239
238
  }
240
239
 
241
240
  NftId poolNftId = product.getPoolNftId();
242
- IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
243
- require(bundleInfo.poolNftId == poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
241
+ premium = IPolicy.Premium(
242
+ netPremiumAmount, // net premium
243
+ netPremiumAmount, // full premium
244
+ 0, // premium
245
+ 0, 0, 0, 0, // fix fees
246
+ 0, 0, 0, 0, // variable fees
247
+ 0, 0, 0, 0); // distribution owner fee/commission/discount
244
248
 
245
249
  {
246
- ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(product.getProductNftId());
247
- (productFeeAmount,) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
250
+ {
251
+ ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(product.getProductNftId());
252
+ uint256 t = productSetupInfo.productFee.fixedFee;
253
+ premium.productFeeFixAmount = t;
254
+ premium.fullPremiumAmount += t;
255
+ }
256
+ {
257
+ bytes memory componentData = instanceReader.getComponentInfo(poolNftId).data;
258
+ uint256 t = abi.decode(componentData, (IComponents.PoolInfo)).poolFee.fixedFee;
259
+ premium.poolFeeFixAmount = t;
260
+ premium.fullPremiumAmount += t;
261
+ }
262
+ {
263
+ IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
264
+ if(bundleInfo.poolNftId != poolNftId) {
265
+ revert IApplicationServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, poolNftId);
266
+ }
267
+ uint256 t = bundleInfo.fee.fixedFee;
268
+ premium.bundleFeeFixAmount = t;
269
+ premium.fullPremiumAmount += t;
270
+ }
271
+ {
272
+ ISetup.DistributionSetupInfo memory distInto = instanceReader.getDistributionSetupInfo(product.getDistributionNftId());
273
+ uint256 t = distInto.distributionFee.fixedFee;
274
+ premium.distributionFeeFixAmount = t;
275
+ premium.fullPremiumAmount += t;
276
+ }
248
277
  }
278
+
279
+ }
280
+
281
+ function _calculateVariableFeeAmounts(
282
+ IPolicy.Premium memory premium,
283
+ Product product,
284
+ NftId bundleNftId,
285
+ ReferralId referralId
286
+ )
287
+ internal
288
+ view
289
+ returns (
290
+ IPolicy.Premium memory finalPremium
291
+ )
292
+ {
293
+ InstanceReader instanceReader;
249
294
  {
250
- ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
251
- (poolFeeAmount,) = FeeLib.calculateFee(poolSetupInfo.poolFee, netPremiumAmount);
295
+ IInstance instance = product.getInstance();
296
+ instanceReader = instance.getInstanceReader();
252
297
  }
298
+
299
+ NftId poolNftId = product.getPoolNftId();
300
+ uint256 netPremiumAmount = premium.netPremiumAmount;
301
+
253
302
  {
254
- NftId distributionNftId = product.getDistributionNftId();
255
- ISetup.DistributionSetupInfo memory distributionSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
256
- (distributionFeeAmount,) = FeeLib.calculateFee(distributionSetupInfo.distributionFee, netPremiumAmount);
303
+ {
304
+ ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(product.getProductNftId());
305
+ uint256 t = (UFixedLib.toUFixed(netPremiumAmount) * productSetupInfo.productFee.fractionalFee).toInt();
306
+ premium.productFeeVarAmount = t;
307
+ premium.fullPremiumAmount += t;
308
+ }
309
+ {
310
+ bytes memory componentData = instanceReader.getComponentInfo(poolNftId).data;
311
+ UFixed poolFractionalFee = abi.decode(componentData, (IComponents.PoolInfo)).poolFee.fractionalFee;
312
+ uint256 t = (UFixedLib.toUFixed(netPremiumAmount) * poolFractionalFee).toInt();
313
+ premium.poolFeeVarAmount = t;
314
+ premium.fullPremiumAmount += t;
315
+ }
316
+ {
317
+ IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
318
+ if(bundleInfo.poolNftId != poolNftId) {
319
+ revert IApplicationServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, poolNftId);
320
+ }
321
+ uint256 t = (UFixedLib.toUFixed(netPremiumAmount) * bundleInfo.fee.fractionalFee).toInt();
322
+ premium.bundleFeeVarAmount = t;
323
+ premium.fullPremiumAmount += t;
324
+ }
325
+ {
326
+ premium = _distributionService.calculateFeeAmount(
327
+ product.getDistributionNftId(),
328
+ referralId,
329
+ premium
330
+ );
331
+ }
257
332
  }
258
-
259
- (bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
333
+
334
+ return premium;
260
335
  }
261
336
 
262
337
 
@@ -265,4 +340,11 @@ contract ApplicationService is
265
340
  (productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
266
341
  product = Product(productInfo.objectAddress);
267
342
  }
343
+
344
+ function _getAndVerifyProduct(NftId productNftId) internal view returns (Product product) {
345
+ IRegistry registry = getRegistry();
346
+ IRegistry.ObjectInfo memory productInfo = registry.getObjectInfo(productNftId);
347
+ require(productInfo.objectType == PRODUCT(), "OBJECT_TYPE_INVALID");
348
+ product = Product(productInfo.objectAddress);
349
+ }
268
350
  }