@etherisc/gif-next 0.0.2-da77c50-824 → 0.0.2-e42b0ca-323

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. package/README.md +5 -14
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  4. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  5. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  7. package/artifacts/contracts/components/Pool.sol/Pool.json +2 -2
  8. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  9. package/artifacts/contracts/components/Product.sol/Product.json +2 -2
  10. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  11. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  12. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  13. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  14. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  15. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  22. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  26. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  28. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  30. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  31. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +48 -204
  32. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  33. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  34. package/artifacts/contracts/instance/Instance.sol/Instance.json +211 -303
  35. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  36. package/artifacts/contracts/instance/{service → base}/ComponentServiceBase.sol/ComponentServiceBase.json +6 -6
  37. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  38. package/artifacts/contracts/instance/{IServiceLinked.sol/IServiceLinked.json → base/IInstanceBase.sol/IInstanceBase.json} +15 -2
  39. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  40. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +511 -0
  41. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  42. package/artifacts/contracts/instance/{module/lifecycle/ILifecycle.sol/ILifecycleModule.json → base/ILifecycle.sol/ILifecycle.json} +10 -77
  43. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
  44. package/artifacts/contracts/instance/{service → base}/IService.sol/IService.json +6 -6
  45. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  46. package/artifacts/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol}/InstanceBase.json +19 -6
  47. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  48. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +692 -0
  49. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  50. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  51. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
  52. package/artifacts/contracts/instance/{module/product/ProductModule.sol/ProductModule.json → base/ModuleBase.sol/ModuleBase.json} +2 -2
  53. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
  54. package/artifacts/contracts/instance/{service → base}/ServiceBase.sol/ServiceBase.json +6 -6
  55. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +50 -30
  60. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +50 -30
  63. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +4 -0
  64. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +10 -0
  65. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +4 -0
  66. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.json +10 -0
  67. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +4 -0
  68. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.json +10 -0
  69. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/{product/IProductModule.sol/IProductModule.json → risk/IRisk.sol/IRisk.json} +2 -2
  80. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
  81. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +10 -0
  82. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +10 -0
  84. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  85. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  86. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +1 -6
  87. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  88. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  89. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  90. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +1 -6
  91. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +48 -44
  93. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +5 -5
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +5 -5
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +5 -5
  99. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  100. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +18 -46
  101. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +47 -59
  103. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  104. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  105. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  106. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  107. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  109. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  110. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  111. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  112. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  113. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +5 -5
  114. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  115. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  116. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +5 -5
  117. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  118. package/artifacts/contracts/test/TestFee.sol/TestFee.json +28 -4
  119. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  120. package/artifacts/contracts/test/TestPool.sol/TestPool.json +2 -2
  121. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  122. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +2 -2
  123. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  124. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  125. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  126. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +38 -4
  127. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  128. package/artifacts/contracts/test/TestService.sol/TestService.json +15 -43
  129. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  130. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  131. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +14 -18
  132. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  133. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +15 -39
  134. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  135. package/artifacts/contracts/test/Usdc.sol/USDC.json +338 -0
  136. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  137. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  138. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  139. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  140. package/artifacts/contracts/types/Fee.sol/FeeLib.json +218 -0
  141. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  142. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
  143. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  144. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
  145. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  146. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  147. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  148. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  149. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
  150. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  152. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +34 -8
  155. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/Version.sol/VersionLib.json +63 -2
  157. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  159. package/contracts/components/BaseComponent.sol +0 -1
  160. package/contracts/instance/IInstance.sol +13 -11
  161. package/contracts/instance/Instance.sol +13 -7
  162. package/contracts/instance/{service → base}/ComponentServiceBase.sol +1 -0
  163. package/contracts/instance/base/IInstanceBase.sol +14 -0
  164. package/contracts/instance/base/IKeyValueStore.sol +49 -0
  165. package/contracts/instance/base/ILifecycle.sol +30 -0
  166. package/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol} +21 -15
  167. package/contracts/instance/base/KeyValueStore.sol +156 -0
  168. package/contracts/instance/{module/lifecycle/LifecycleModule.sol → base/Lifecycle.sol} +36 -30
  169. package/contracts/instance/base/ModuleBase.sol +52 -0
  170. package/contracts/instance/{service → base}/ServiceBase.sol +1 -3
  171. package/contracts/instance/module/access/Access.sol +3 -3
  172. package/contracts/instance/module/bundle/BundleModule.sol +24 -116
  173. package/contracts/instance/module/bundle/IBundle.sol +8 -3
  174. package/contracts/instance/module/compensation/CompensationModule.sol +8 -0
  175. package/contracts/instance/module/compensation/ICompensation.sol +10 -0
  176. package/contracts/instance/module/component/ComponentModule.sol +10 -19
  177. package/contracts/instance/module/policy/PolicyModule.sol +2 -10
  178. package/contracts/instance/module/{product/IProductModule.sol → risk/IRisk.sol} +6 -2
  179. package/contracts/instance/module/risk/RiskModule.sol +8 -0
  180. package/contracts/instance/module/treasury/ITreasury.sol +2 -3
  181. package/contracts/instance/module/treasury/TreasuryModule.sol +15 -11
  182. package/contracts/instance/service/ComponentOwnerService.sol +4 -8
  183. package/contracts/instance/service/IComponentOwnerService.sol +1 -1
  184. package/contracts/instance/service/IPoolService.sol +1 -1
  185. package/contracts/instance/service/IProductService.sol +1 -1
  186. package/contracts/instance/service/PoolService.sol +36 -11
  187. package/contracts/instance/service/ProductService.sol +6 -10
  188. package/contracts/registry/Registry.sol +1 -1
  189. package/contracts/shared/IVersionable.sol +2 -2
  190. package/contracts/shared/Versionable.sol +3 -6
  191. package/contracts/test/TestFee.sol +3 -3
  192. package/contracts/test/TestPool.sol +1 -1
  193. package/contracts/test/TestProduct.sol +1 -1
  194. package/contracts/test/TestRoleId.sol +2 -2
  195. package/contracts/test/TestService.sol +3 -6
  196. package/contracts/test/TestVersion.sol +4 -7
  197. package/contracts/test/TestVersionable.sol +2 -5
  198. package/contracts/test/Usdc.sol +26 -0
  199. package/contracts/types/Fee.sol +39 -20
  200. package/contracts/types/Key32.sol +45 -0
  201. package/contracts/types/NftId.sol +16 -1
  202. package/contracts/types/RoleId.sol +11 -9
  203. package/contracts/types/StateId.sol +7 -1
  204. package/contracts/types/UFixed.sol +19 -16
  205. package/contracts/types/Version.sol +29 -25
  206. package/package.json +1 -1
  207. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.dbg.json +0 -4
  208. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  209. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +0 -4
  210. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.json +0 -134
  211. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +0 -4
  212. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +0 -4
  213. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.json +0 -221
  214. package/artifacts/contracts/instance/module/product/IProductModule.sol/IProductModule.dbg.json +0 -4
  215. package/artifacts/contracts/instance/module/product/ProductModule.sol/ProductModule.dbg.json +0 -4
  216. package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  217. package/artifacts/contracts/instance/service/IService.sol/IService.dbg.json +0 -4
  218. package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  219. package/contracts/instance/IServiceLinked.sol +0 -12
  220. package/contracts/instance/module/lifecycle/ILifecycle.sol +0 -47
  221. package/contracts/instance/module/product/ProductModule.sol +0 -8
  222. /package/contracts/instance/{service → base}/IService.sol +0 -0
@@ -3,32 +3,32 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../../registry/IRegistry.sol";
5
5
 
6
- import {LifecycleModule} from "../lifecycle/LifecycleModule.sol";
7
6
  import {IProductService} from "../../service/IProductService.sol";
8
7
  import {IPoolService} from "../../service/IPoolService.sol";
9
8
 
10
9
  import {NftId} from "../../../types/NftId.sol";
10
+ import {Key32, KeyId} from "../../../types/Key32.sol";
11
11
  import {LibNftIdSet} from "../../../types/NftIdSet.sol";
12
12
  import {ObjectType, PRODUCT, ORACLE, POOL, BUNDLE, POLICY} from "../../../types/ObjectType.sol";
13
13
  import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, REVOKED, DECLINED} from "../../../types/StateId.sol";
14
14
  import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
15
15
  import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
16
16
 
17
- import {ILifecycleModule} from "../lifecycle/ILifecycle.sol";
17
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
18
+ import {ModuleBase} from "../../base/ModuleBase.sol";
19
+
18
20
  import {IBundleModule} from "./IBundle.sol";
19
21
 
20
- abstract contract BundleModule is
22
+ abstract contract BundleModule is
23
+ ModuleBase,
21
24
  IBundleModule
22
25
  {
23
26
 
24
27
  using LibNftIdSet for LibNftIdSet.Set;
25
28
 
26
- mapping(NftId bundleNftId => BundleInfo info) private _bundleInfo;
27
29
  mapping(NftId bundleNftId => LibNftIdSet.Set policies) private _collateralizedPolicies;
28
30
  mapping(NftId bundleNftId => mapping(NftId policyNftId => uint256 amount)) private _collateralizationAmount;
29
31
 
30
- LifecycleModule private _lifecycleModule;
31
-
32
32
  modifier onlyBundlePoolService() {
33
33
  require(
34
34
  msg.sender == address(this.getPoolService()),
@@ -54,8 +54,8 @@ abstract contract BundleModule is
54
54
  _;
55
55
  }
56
56
 
57
- constructor() {
58
- _lifecycleModule = LifecycleModule(address(this));
57
+ function initializeBundleModule(IKeyValueStore keyValueStore) internal {
58
+ _initialize(keyValueStore, BUNDLE());
59
59
  }
60
60
 
61
61
  function createBundleInfo(
@@ -69,22 +69,18 @@ abstract contract BundleModule is
69
69
  onlyBundlePoolService
70
70
  override
71
71
  {
72
-
73
- _bundleInfo[bundleNftId] = BundleInfo(
72
+ BundleInfo memory bundleInfo = BundleInfo(
74
73
  bundleNftId,
75
74
  poolNftId,
76
- _lifecycleModule.getInitialState(BUNDLE()),
77
75
  filter,
78
76
  amount, // capital
79
77
  0, // locked capital
80
78
  amount, // balance
81
- blockTimestamp(), // createdAt
82
79
  blockTimestamp().addSeconds(lifetime), // expiredAt
83
- zeroTimestamp(), // closedAt
84
- blockNumber() // updatedIn
80
+ zeroTimestamp() // closedAt
85
81
  );
86
82
 
87
- // TODO add logging
83
+ _create(bundleNftId, abi.encode(bundleInfo));
88
84
  }
89
85
 
90
86
  function setBundleInfo(BundleInfo memory bundleInfo)
@@ -92,78 +88,16 @@ abstract contract BundleModule is
92
88
  override
93
89
  onlyPoolOrProductService
94
90
  {
95
- _bundleInfo[bundleInfo.nftId] = bundleInfo;
91
+ _updateData(bundleInfo.nftId, abi.encode(bundleInfo));
96
92
  }
97
93
 
98
- // function updateBundleState(
99
- // NftId bundleNftId,
100
- // StateId newState
101
- // )
102
- // external
103
- // // add authz (both product and pool service)
104
- // override
105
- // {
106
- // BundleInfo storage info = _bundleInfo[bundleNftId];
107
- // info.state = newState;
108
- // info.updatedIn = blockNumber();
109
- // }
110
-
111
- // function extendBundle(
112
- // NftId bundleNftId,
113
- // uint256 lifetimeExtension
114
- // )
115
- // external
116
- // onlyBundlePoolService
117
- // override
118
- // {
119
- // BundleInfo storage info = _bundleInfo[bundleNftId];
120
- // info.expiredAt = info.expiredAt.addSeconds(lifetimeExtension);
121
- // info.updatedIn = blockNumber();
122
- // }
123
-
124
- // function closeBundle(
125
- // NftId bundleNftId
126
- // )
127
- // external
128
- // onlyBundlePoolService
129
- // override
130
- // {
131
- // BundleInfo storage info = _bundleInfo[bundleNftId];
132
- // info.state = CLOSED();
133
- // info.closedAt = blockTimestamp();
134
- // info.updatedIn = blockNumber();
135
- // }
136
-
137
- // function processStake(
138
- // NftId nftId,
139
- // uint256 amount
140
- // )
141
- // external
142
- // onlyBundlePoolService
143
- // override
144
- // {
145
- // BundleInfo storage info = _bundleInfo[nftId];
146
- // info.capitalAmount += amount;
147
- // info.balanceAmount += amount;
148
- // info.updatedIn = blockNumber();
149
- // }
150
-
151
- // function processUnstake(
152
- // NftId nftId,
153
- // uint256 amount
154
- // )
155
- // external
156
- // onlyBundlePoolService
157
- // override
158
- // {
159
- // BundleInfo storage info = _bundleInfo[nftId];
160
- // // TODO fix book keeping in a way that provides
161
- // // continuous infor regarding profitability
162
- // // this is needed to properly apply performance fees
163
- // info.capitalAmount -= amount;
164
- // info.balanceAmount -= amount;
165
- // info.updatedIn = blockNumber();
166
- // }
94
+ function updateBundleState(NftId bundleNftId, StateId state)
95
+ external
96
+ override
97
+ onlyBundlePoolService
98
+ {
99
+ _updateState(bundleNftId, state);
100
+ }
167
101
 
168
102
  function collateralizePolicy(
169
103
  NftId bundleNftId,
@@ -187,42 +121,16 @@ abstract contract BundleModule is
187
121
  override
188
122
  returns(uint256 collateralAmount)
189
123
  {
190
- // BundleInfo storage info = _bundleInfo[bundleNftId];
191
- // info.lockedAmount -= collateralAmount;
192
- // info.updatedIn = blockNumber();
193
-
194
124
  collateralAmount = _collateralizationAmount[bundleNftId][policyNftId];
195
125
  delete _collateralizationAmount[bundleNftId][policyNftId];
196
126
  _collateralizedPolicies[bundleNftId].remove(policyNftId);
197
127
  }
198
128
 
199
- // function addPremium(NftId bundleNftId, uint256 amount)
200
- // external
201
- // onlyBundleProductService
202
- // override
203
- // {
204
- // BundleInfo storage info = _bundleInfo[bundleNftId];
205
- // info.capitalAmount += amount;
206
- // info.balanceAmount += amount;
207
- // info.updatedIn = blockNumber();
208
- // }
209
-
210
- // function subtractPayout(NftId bundleNftId, NftId policyNftId, uint256 amount)
211
- // external
212
- // onlyBundleProductService
213
- // override
214
- // {
215
- // BundleInfo storage info = _bundleInfo[bundleNftId];
216
- // info.capitalAmount -= amount;
217
- // info.lockedAmount -= amount;
218
- // info.balanceAmount -= amount;
219
- // info.updatedIn = blockNumber();
220
-
221
- // // deduct amount from sum insured for this policy
222
- // _collateralizationAmount[bundleNftId][policyNftId] -= amount;
223
- // }
224
-
225
129
  function getBundleInfo(NftId bundleNftId) external view override returns(BundleInfo memory bundleInfo) {
226
- return _bundleInfo[bundleNftId];
130
+ return abi.decode(_getData(bundleNftId), (BundleInfo));
227
131
  }
132
+
133
+ function toBundleKey32(NftId bundleNftId) external view override returns (Key32 key32) {
134
+ return _toKey32(bundleNftId);
135
+ }
228
136
  }
@@ -3,11 +3,13 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../../registry/IRegistry.sol";
5
5
  import {IInstance} from "../../IInstance.sol";
6
+ import {Key32} from "../../../types/Key32.sol";
6
7
  import {NftId} from "../../../types/NftId.sol";
7
8
  import {StateId} from "../../../types/StateId.sol";
8
9
  import {Timestamp} from "../../../types/Timestamp.sol";
9
10
  import {Blocknumber} from "../../../types/Blocknumber.sol";
10
11
 
12
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
11
13
  import {IProductService} from "../../service/IProductService.sol";
12
14
  import {IPoolService} from "../../service/IPoolService.sol";
13
15
 
@@ -16,15 +18,12 @@ interface IBundle {
16
18
  struct BundleInfo {
17
19
  NftId nftId;
18
20
  NftId poolNftId;
19
- StateId state; // active, paused, closed (expriy only implicit)
20
21
  bytes filter; // required conditions for applications to be considered for collateralization by this bundle
21
22
  uint256 capitalAmount; // net investment capital amount (<= balance)
22
23
  uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
23
24
  uint256 balanceAmount; // total amount of funds: net investment capital + net premiums - payouts
24
- Timestamp createdAt;
25
25
  Timestamp expiredAt; // no new policies
26
26
  Timestamp closedAt;
27
- Blocknumber updatedIn;
28
27
  }
29
28
  }
30
29
 
@@ -39,14 +38,20 @@ interface IBundleModule is IBundle {
39
38
  ) external;
40
39
 
41
40
  function setBundleInfo(BundleInfo memory bundleInfo) external;
41
+ function updateBundleState(NftId bundleNftId, StateId state) external;
42
+
42
43
  function collateralizePolicy(NftId bundleNftId, NftId policyNftId, uint256 amount) external;
43
44
  function releasePolicy(NftId bundleNftId, NftId policyNftId) external returns(uint256 collateralAmount);
44
45
 
45
46
  function getBundleInfo(NftId bundleNftId) external view returns(BundleInfo memory bundleInfo);
47
+ function toBundleKey32(NftId bundleNftId) external view returns (Key32 key32);
46
48
 
47
49
  // repeat registry linked signature
48
50
  function getRegistry() external view returns (IRegistry registry);
49
51
 
52
+ // repeat instance base signature
53
+ function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
54
+
50
55
  // repeat service linked signatures to avoid linearization issues
51
56
  function getProductService() external returns(IProductService);
52
57
  function getPoolService() external returns(IPoolService);
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {ICompensationModule} from "./ICompensation.sol";
5
+
6
+ contract CompensationModule is ICompensationModule {
7
+
8
+ }
@@ -0,0 +1,10 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ interface ICompensation {
5
+
6
+ }
7
+
8
+ interface ICompensationModule is ICompensation {
9
+
10
+ }
@@ -6,14 +6,12 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
6
6
  import {IRegistry} from "../../../registry/IRegistry.sol";
7
7
  import {IInstance} from "../../IInstance.sol";
8
8
 
9
- import {LifecycleModule} from "../lifecycle/LifecycleModule.sol";
10
9
  import {IComponent, IComponentModule} from "./IComponent.sol";
11
10
  import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
12
11
  import {ObjectType, PRODUCT, ORACLE, POOL} from "../../../types/ObjectType.sol";
13
12
  import {StateId, ACTIVE, PAUSED} from "../../../types/StateId.sol";
14
13
  import {NftId, NftIdLib, zeroNftId} from "../../../types/NftId.sol";
15
- import {Fee, zeroFee} from "../../../types/Fee.sol";
16
- // import {IBaseComponent} from "../../../components/IBaseComponent.sol";
14
+ import {Fee} from "../../../types/Fee.sol";
17
15
 
18
16
  abstract contract ComponentModule is
19
17
  IComponentModule
@@ -25,9 +23,6 @@ abstract contract ComponentModule is
25
23
 
26
24
  mapping(ObjectType cType => bytes32 role) private _componentOwnerRole;
27
25
 
28
- // TODO maybe move this to Instance contract as internal variable?
29
- LifecycleModule private _lifecycleModule;
30
-
31
26
  modifier onlyComponentOwnerService() {
32
27
  require(
33
28
  msg.sender == address(this.getComponentOwnerService()),
@@ -36,11 +31,6 @@ abstract contract ComponentModule is
36
31
  _;
37
32
  }
38
33
 
39
- constructor() {
40
- address componentAddress = address(this);
41
- _lifecycleModule = LifecycleModule(componentAddress);
42
- }
43
-
44
34
  function registerComponent(
45
35
  NftId nftId,
46
36
  ObjectType objectType,
@@ -50,7 +40,8 @@ abstract contract ComponentModule is
50
40
  // create component info
51
41
  _componentInfo[nftId] = ComponentInfo(
52
42
  nftId,
53
- _lifecycleModule.getInitialState(objectType),
43
+ // _lifecycleModule.getInitialState(objectType),
44
+ ACTIVE(),
54
45
  token
55
46
  );
56
47
 
@@ -71,13 +62,13 @@ abstract contract ComponentModule is
71
62
  // TODO decide if state changes should have explicit functions and not
72
63
  // just a generic setXYZInfo and implicit state transitions
73
64
  // when in doubt go for the explicit approach ...
74
- ObjectType objectType = this.getRegistry().getObjectInfo(nftId).objectType;
75
- _lifecycleModule.checkAndLogTransition(
76
- nftId,
77
- objectType,
78
- _componentInfo[nftId].state,
79
- info.state
80
- );
65
+ // ObjectType objectType = this.getRegistry().getObjectInfo(nftId).objectType;
66
+ // _lifecycleModule.checkAndLogTransition(
67
+ // nftId,
68
+ // objectType,
69
+ // _componentInfo[nftId].state,
70
+ // info.state
71
+ // );
81
72
  _componentInfo[nftId] = info;
82
73
  }
83
74
 
@@ -3,7 +3,6 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../../registry/IRegistry.sol";
5
5
 
6
- import {LifecycleModule} from "../../module/lifecycle/LifecycleModule.sol";
7
6
  import {IProductService} from "../../service/IProductService.sol";
8
7
  import {IPolicy, IPolicyModule} from "./IPolicy.sol";
9
8
  import {ObjectType, POLICY} from "../../../types/ObjectType.sol";
@@ -12,15 +11,11 @@ import {NftId, NftIdLib} from "../../../types/NftId.sol";
12
11
  import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
13
12
  import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
14
13
 
15
- import {LifecycleModule} from "../../module/lifecycle/LifecycleModule.sol";
16
-
17
14
  abstract contract PolicyModule is IPolicyModule {
18
15
  using NftIdLib for NftId;
19
16
 
20
17
  mapping(NftId nftId => PolicyInfo info) private _policyInfo;
21
18
 
22
- LifecycleModule private _lifecycleModule;
23
-
24
19
  // TODO find a better place to avoid dupliation
25
20
  modifier onlyProductService2() {
26
21
  require(
@@ -30,10 +25,6 @@ abstract contract PolicyModule is IPolicyModule {
30
25
  _;
31
26
  }
32
27
 
33
- constructor() {
34
- _lifecycleModule = LifecycleModule(address(this));
35
- }
36
-
37
28
  function createApplication(
38
29
  NftId productNftId,
39
30
  NftId policyNftId,
@@ -51,7 +42,8 @@ abstract contract PolicyModule is IPolicyModule {
51
42
  productNftId,
52
43
  bundleNftId,
53
44
  address(0), // beneficiary = policy nft holder
54
- _lifecycleModule.getInitialState(POLICY()),
45
+ // _lifecycleModule.getInitialState(POLICY()),
46
+ APPLIED(),
55
47
  sumInsuredAmount,
56
48
  premiumAmount,
57
49
  0, // premium paid amount
@@ -1,6 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- interface IProductModule
5
- {
4
+ interface IRisk {
5
+
6
6
  }
7
+
8
+ interface IRiskModule is IRisk {
9
+
10
+ }
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IRiskModule} from "./IRisk.sol";
5
+
6
+ contract RiskModule is IRiskModule {
7
+
8
+ }
@@ -18,7 +18,6 @@ interface ITreasury {
18
18
  NftId distributorNftId;
19
19
  NftId poolNftId;
20
20
  IERC20Metadata token;
21
- TokenHandler tokenHandler;
22
21
  address wallet;
23
22
  Fee policyFee;
24
23
  Fee processingFee;
@@ -27,7 +26,7 @@ interface ITreasury {
27
26
  struct DistributorSetup {
28
27
  NftId distributorNftId;
29
28
  address wallet;
30
- Fee commissionFees;
29
+ Fee commissionFee;
31
30
  }
32
31
 
33
32
  struct PoolSetup {
@@ -70,7 +69,7 @@ interface ITreasuryModule is ITreasury {
70
69
  ) external;
71
70
 
72
71
  function getTokenHandler(
73
- NftId productNftId
72
+ NftId componentNftId
74
73
  ) external view returns (TokenHandler tokenHandler);
75
74
 
76
75
  function getProductSetup(
@@ -4,7 +4,7 @@ pragma solidity ^0.8.19;
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
6
  import {NftId} from "../../../types/NftId.sol";
7
- import {Fee, feeIsZero, toFee, zeroFee} from "../../../types/Fee.sol";
7
+ import {Fee, FeeLib} from "../../../types/Fee.sol";
8
8
  import {UFixed, UFixedMathLib} from "../../../types/UFixed.sol";
9
9
  import {TokenHandler} from "./TokenHandler.sol";
10
10
  import {ITreasuryModule} from "./ITreasury.sol";
@@ -14,6 +14,7 @@ abstract contract TreasuryModule is ITreasuryModule {
14
14
  mapping(NftId distributorNftId => DistributorSetup setup)
15
15
  private _distributorSetup;
16
16
  mapping(NftId poolNftId => PoolSetup setup) private _poolSetup;
17
+ mapping(NftId componentNftId => TokenHandler tokenHanlder) _tokenHandler;
17
18
 
18
19
  function registerProduct(
19
20
  NftId productNftId,
@@ -25,17 +26,23 @@ abstract contract TreasuryModule is ITreasuryModule {
25
26
  Fee memory processingFee
26
27
  ) external override // TODO add authz (only component module)
27
28
  {
28
- // TODO add validation
29
+ require(address(_tokenHandler[productNftId]) == address(0), "ERROR:TRS-010:TOKEN_HANDLER_ALREADY_REGISTERED");
30
+ require(address(_tokenHandler[poolNftId]) == address(0), "ERROR:TRS-011:TOKEN_HANDLER_ALREADY_REGISTERED");
31
+ require(address(_tokenHandler[distributorNftId]) == address(0), "ERROR:TRS-012:TOKEN_HANDLER_ALREADY_REGISTERED");
32
+ // TODO add additional validations
29
33
 
30
34
  // deploy product specific handler contract
31
35
  TokenHandler tokenHandler = new TokenHandler(productNftId, address(token));
36
+ _tokenHandler[productNftId] = tokenHandler;
37
+ _tokenHandler[poolNftId] = tokenHandler;
38
+ _tokenHandler[distributorNftId] = tokenHandler;
32
39
 
40
+ // create product setup
33
41
  _productSetup[productNftId] = ProductSetup(
34
42
  productNftId,
35
43
  distributorNftId,
36
44
  poolNftId,
37
45
  token,
38
- tokenHandler,
39
46
  wallet,
40
47
  policyFee,
41
48
  processingFee
@@ -94,9 +101,9 @@ abstract contract TreasuryModule is ITreasuryModule {
94
101
  }
95
102
 
96
103
  function getTokenHandler(
97
- NftId productNftId
104
+ NftId componentNftId
98
105
  ) external view override returns (TokenHandler tokenHandler) {
99
- return _productSetup[productNftId].tokenHandler;
106
+ return _tokenHandler[componentNftId];
100
107
  }
101
108
 
102
109
  function getProductSetup(
@@ -115,21 +122,18 @@ abstract contract TreasuryModule is ITreasuryModule {
115
122
  uint256 amount,
116
123
  Fee memory fee
117
124
  ) public pure override returns (uint256 feeAmount, uint256 netAmount) {
118
- UFixed fractionalAmount = UFixedMathLib.toUFixed(amount) *
119
- fee.fractionalFee;
120
- feeAmount = fractionalAmount.toInt() + fee.fixedFee;
121
- netAmount = amount - feeAmount;
125
+ return FeeLib.calculateFee(amount, fee);
122
126
  }
123
127
 
124
128
  function getFee(
125
129
  UFixed fractionalFee,
126
130
  uint256 fixedFee
127
131
  ) external pure override returns (Fee memory fee) {
128
- return toFee(fractionalFee, fixedFee);
132
+ return FeeLib.toFee(fractionalFee, fixedFee);
129
133
  }
130
134
 
131
135
  function getZeroFee() external pure override returns (Fee memory fee) {
132
- return zeroFee();
136
+ return FeeLib.zeroFee();
133
137
  }
134
138
 
135
139
  function getUFixed(
@@ -6,7 +6,6 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
6
6
  import {IRegistry} from "../../registry/IRegistry.sol";
7
7
  import {IInstance} from "../IInstance.sol";
8
8
 
9
- import {LifecycleModule} from "../module/lifecycle/LifecycleModule.sol";
10
9
  import {ITreasuryModule} from "../module/treasury/ITreasury.sol";
11
10
  import {TreasuryModule} from "../module/treasury/TreasuryModule.sol";
12
11
  import {IComponent, IComponentModule} from "../module/component/IComponent.sol";
@@ -20,11 +19,11 @@ import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "..
20
19
  import {ObjectType, PRODUCT, ORACLE, POOL} from "../../types/ObjectType.sol";
21
20
  import {StateId, ACTIVE, PAUSED} from "../../types/StateId.sol";
22
21
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
23
- import {Fee, zeroFee} from "../../types/Fee.sol";
24
- import {Version, toVersion, toVersionPart} from "../../types/Version.sol";
22
+ import {Fee} from "../../types/Fee.sol";
23
+ import {Version, VersionLib} from "../../types/Version.sol";
25
24
 
26
25
  import {IProductComponent} from "../../components/IProductComponent.sol";
27
- import {ServiceBase} from "./ServiceBase.sol";
26
+ import {ServiceBase} from "../base/ServiceBase.sol";
28
27
  import {IComponentOwnerService} from "./IComponentOwnerService.sol";
29
28
 
30
29
  contract ComponentOwnerService is
@@ -55,10 +54,7 @@ contract ComponentOwnerService is
55
54
  virtual override (IVersionable, Versionable)
56
55
  returns(Version)
57
56
  {
58
- return toVersion(
59
- toVersionPart(3),
60
- toVersionPart(0),
61
- toVersionPart(0));
57
+ return VersionLib.toVersion(3,0,0);
62
58
  }
63
59
 
64
60
  function getName() external pure override returns(string memory name) {
@@ -5,7 +5,7 @@ import {NftId} from "../../types/NftId.sol";
5
5
  import {ObjectType} from "../../types/ObjectType.sol";
6
6
  import {RoleId} from "../../types/RoleId.sol";
7
7
  import {IBaseComponent} from "../../components/IBaseComponent.sol";
8
- import {IService} from "./IService.sol";
8
+ import {IService} from "../base/IService.sol";
9
9
 
10
10
  // TODO rename to registry service
11
11
  interface IComponentOwnerService is IService {
@@ -3,7 +3,7 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {NftId} from "../../types/NftId.sol";
5
5
  import {Fee} from "../../types/Fee.sol";
6
- import {IService} from "./IService.sol";
6
+ import {IService} from "../base/IService.sol";
7
7
 
8
8
  interface IPoolService is IService {
9
9
  function setFees(
@@ -5,7 +5,7 @@ import {NftId} from "../../types/NftId.sol";
5
5
  import {Timestamp} from "../../types/Timestamp.sol";
6
6
  import {UFixed} from "../../types/UFixed.sol";
7
7
  import {Fee} from "../../types/Fee.sol";
8
- import {IService} from "./IService.sol";
8
+ import {IService} from "../base/IService.sol";
9
9
 
10
10
  interface IProductService is IService {
11
11
  function setFees(
@@ -10,10 +10,10 @@ import {Versionable} from "../../shared/Versionable.sol";
10
10
 
11
11
  import {NftId, NftIdLib} from "../../types/NftId.sol";
12
12
  import {POOL, BUNDLE} from "../../types/ObjectType.sol";
13
- import {Fee, feeIsZero} from "../../types/Fee.sol";
14
- import {Version, toVersion, toVersionPart} from "../../types/Version.sol";
13
+ import {Fee} from "../../types/Fee.sol";
14
+ import {Version, VersionLib} from "../../types/Version.sol";
15
15
 
16
- import {ComponentServiceBase} from "./ComponentServiceBase.sol";
16
+ import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
17
17
  import {IPoolService} from "./IPoolService.sol";
18
18
 
19
19
 
@@ -36,10 +36,7 @@ contract PoolService is ComponentServiceBase, IPoolService {
36
36
  virtual override (IVersionable, Versionable)
37
37
  returns(Version)
38
38
  {
39
- return toVersion(
40
- toVersionPart(3),
41
- toVersionPart(0),
42
- toVersionPart(0));
39
+ return VersionLib.toVersion(3,0,0);
43
40
  }
44
41
 
45
42
  function getName() external pure override returns(string memory name) {
@@ -59,7 +56,7 @@ contract PoolService is ComponentServiceBase, IPoolService {
59
56
 
60
57
  function createBundle(
61
58
  address owner,
62
- uint256 amount,
59
+ uint256 stakingAmount,
63
60
  uint256 lifetime,
64
61
  bytes calldata filter
65
62
  )
@@ -81,7 +78,7 @@ contract PoolService is ComponentServiceBase, IPoolService {
81
78
  instance.createBundleInfo(
82
79
  bundleNftId,
83
80
  poolNftId,
84
- amount,
81
+ stakingAmount,
85
82
  lifetime,
86
83
  filter);
87
84
 
@@ -89,10 +86,38 @@ contract PoolService is ComponentServiceBase, IPoolService {
89
86
  instance.addBundleToPool(
90
87
  bundleNftId,
91
88
  poolNftId,
92
- amount);
89
+ stakingAmount);
93
90
 
94
- // TODO collect capital
91
+ // collect capital
92
+ _processStakingByTreasury(
93
+ instance,
94
+ poolNftId,
95
+ bundleNftId,
96
+ stakingAmount);
95
97
 
96
98
  // TODO add logging
97
99
  }
100
+
101
+
102
+ function _processStakingByTreasury(
103
+ IInstance instance,
104
+ NftId poolNftId,
105
+ NftId bundleNftId,
106
+ uint256 stakingAmount
107
+ )
108
+ internal
109
+ {
110
+ // process token transfer(s)
111
+ if(stakingAmount > 0) {
112
+ TokenHandler tokenHandler = instance.getTokenHandler(poolNftId);
113
+ address bundleOwner = _registry.getOwner(bundleNftId);
114
+ address poolWallet = instance.getPoolSetup(poolNftId).wallet;
115
+
116
+ tokenHandler.transfer(
117
+ bundleOwner,
118
+ poolWallet,
119
+ stakingAmount
120
+ );
121
+ }
122
+ }
98
123
  }