@etherisc/gif-next 0.0.2-e4b632c-016 → 0.0.2-e59218b-293

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +4 -0
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +13 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +23 -15
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +13 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.json +21 -13
  13. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  14. package/artifacts/contracts/components/Product.sol/Product.json +26 -56
  15. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  35. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
  36. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +0 -13
  37. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
  38. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1314 -93
  41. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  42. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/Instance.sol/Instance.json +134 -101
  44. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  45. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -47
  46. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +167 -38
  48. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +209 -33
  50. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +91 -15
  52. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  53. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +59 -0
  54. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  55. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  56. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  58. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  66. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +18 -18
  68. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +130 -18
  70. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +32 -16
  72. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +87 -0
  76. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +40 -31
  78. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  79. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +926 -0
  80. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  81. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +448 -0
  82. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  83. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1147 -0
  84. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  85. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +488 -0
  86. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  87. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  88. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +201 -0
  89. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  90. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -19
  91. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  92. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  93. package/artifacts/contracts/registry/Registry.sol/Registry.json +172 -49
  94. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  95. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -29
  96. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  97. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +47 -34
  98. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  99. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
  100. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  101. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  102. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  103. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  104. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  105. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  106. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  107. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  108. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  109. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  110. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  111. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  112. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +4 -4
  113. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  114. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  115. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  116. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  117. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  118. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  119. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  120. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  121. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  122. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  123. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  124. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  125. package/artifacts/contracts/test/TestService.sol/TestService.json +11 -11
  126. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  127. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  128. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  129. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  130. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  131. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  132. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  133. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  134. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  135. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  136. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  137. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  138. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  139. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  140. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  141. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  142. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  143. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  144. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  145. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  146. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  147. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  148. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  152. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  154. package/contracts/components/BaseComponent.sol +8 -3
  155. package/contracts/components/Distribution.sol +15 -18
  156. package/contracts/components/IBaseComponent.sol +1 -0
  157. package/contracts/components/IDistributionComponent.sol +1 -0
  158. package/contracts/components/Pool.sol +9 -22
  159. package/contracts/components/Product.sol +33 -42
  160. package/contracts/instance/AccessManagedSimple.sol +1 -8
  161. package/contracts/instance/IInstance.sol +28 -7
  162. package/contracts/instance/Instance.sol +16 -15
  163. package/contracts/instance/InstanceAccessManager.sol +1 -1
  164. package/contracts/instance/InstanceReader.sol +26 -1
  165. package/contracts/instance/InstanceService.sol +69 -9
  166. package/contracts/instance/InstanceServiceManager.sol +6 -5
  167. package/contracts/instance/base/ComponentServiceBase.sol +96 -1
  168. package/contracts/instance/module/IBundle.sol +1 -0
  169. package/contracts/instance/module/ISetup.sol +2 -0
  170. package/contracts/instance/service/DistributionService.sol +26 -8
  171. package/contracts/instance/service/DistributionServiceManager.sol +7 -6
  172. package/contracts/instance/service/IPoolService.sol +4 -0
  173. package/contracts/instance/service/IProductService.sol +6 -3
  174. package/contracts/instance/service/PoolService.sol +201 -0
  175. package/contracts/instance/service/PoolServiceManager.sol +54 -0
  176. package/contracts/instance/service/ProductService.sol +567 -0
  177. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  178. package/contracts/registry/IRegistry.sol +25 -2
  179. package/contracts/registry/IRegistryService.sol +27 -12
  180. package/contracts/registry/Registry.sol +60 -35
  181. package/contracts/registry/RegistryService.sol +30 -116
  182. package/contracts/registry/RegistryServiceManager.sol +21 -5
  183. package/contracts/registry/TokenRegistry.sol +111 -0
  184. package/contracts/shared/ERC165.sol +6 -2
  185. package/contracts/shared/NftOwnable.sol +2 -4
  186. package/contracts/shared/Registerable.sol +1 -0
  187. package/contracts/shared/Service.sol +1 -0
  188. package/contracts/types/RoleId.sol +8 -0
  189. package/contracts/types/Version.sol +4 -1
  190. package/package.json +1 -1
@@ -25,6 +25,8 @@ contract Distribution is
25
25
  Fee internal _initialDistributionFee;
26
26
  bool internal _isVerifying;
27
27
 
28
+ TokenHandler internal _tokenHandler;
29
+
28
30
  IDistributionService private _distributionService;
29
31
  IProductService private _productService;
30
32
 
@@ -38,21 +40,21 @@ contract Distribution is
38
40
  constructor(
39
41
  address registry,
40
42
  NftId instanceNftId,
41
- NftId productNftId,
42
43
  // TODO refactor into tokenNftId
43
44
  address token,
44
45
  bool verifying,
45
46
  Fee memory distributionFee,
46
47
  address initialOwner
47
48
  )
48
- BaseComponent(registry, instanceNftId, productNftId, token, DISTRIBUTION(), true, initialOwner)
49
+ BaseComponent(registry, instanceNftId, token, DISTRIBUTION(), true, initialOwner)
49
50
  {
50
51
  _isVerifying = verifying;
51
52
  _initialDistributionFee = distributionFee;
52
53
 
53
- // TODO: reactivate when services are available again
54
- // _distributionService = _instance.getDistributionService();
55
- // _productService = _instance.getProductService();
54
+ _tokenHandler = TokenHandler(token);
55
+
56
+ _distributionService = _instance.getDistributionService();
57
+ _productService = _instance.getProductService();
56
58
 
57
59
  _registerInterface(type(IDistributionComponent).interfaceId);
58
60
  }
@@ -123,19 +125,10 @@ contract Distribution is
123
125
  }
124
126
 
125
127
  function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
126
- if (getNftId().eq(zeroNftId())) {
127
- return ISetup.DistributionSetupInfo(
128
- _productNftId,
129
- TokenHandler(address(0)),
130
- _initialDistributionFee,
131
- _isVerifying,
132
- address(0)
133
- );
134
- }
135
-
136
128
  InstanceReader reader = _instance.getInstanceReader();
137
129
  return reader.getDistributionSetupInfo(getNftId());
138
130
  }
131
+
139
132
 
140
133
  /// @dev returns true iff the component needs to be called when selling/renewing policis
141
134
  function isVerifying() external view returns (bool verifying) {
@@ -152,14 +145,18 @@ contract Distribution is
152
145
  {
153
146
  (
154
147
  IRegistry.ObjectInfo memory info,
155
- bytes memory data
156
148
  ) = super.getInitialInfo();
157
149
 
158
150
  return (
159
151
  info,
160
152
  abi.encode(
161
- _initialDistributionFee,
162
- _isVerifying
153
+ ISetup.DistributionSetupInfo(
154
+ _productNftId,
155
+ _tokenHandler,
156
+ _initialDistributionFee,
157
+ _isVerifying,
158
+ address(this)
159
+ )
163
160
  )
164
161
  );
165
162
  }
@@ -19,6 +19,7 @@ interface IBaseComponent is IRegisterable {
19
19
 
20
20
  function getInstance() external view returns (IInstance instance);
21
21
 
22
+ function setProductNftId(NftId productNftId) external;
22
23
  function getProductNftId() external view returns (NftId productNftId);
23
24
 
24
25
  }
@@ -4,6 +4,7 @@ pragma solidity ^0.8.19;
4
4
  import {Fee} from "../types/Fee.sol";
5
5
  import {ReferralId} from "../types/Referral.sol";
6
6
  import {NftId} from "../types/NftId.sol";
7
+ import {ISetup} from "../instance/module/ISetup.sol";
7
8
 
8
9
  interface IDistributionComponent {
9
10
 
@@ -32,6 +32,8 @@ contract Pool is BaseComponent, IPoolComponent {
32
32
  Fee internal _initialStakingFee;
33
33
  Fee internal _initialPerformanceFee;
34
34
 
35
+ TokenHandler internal _tokenHandler;
36
+
35
37
  // may be used to interact with instance by derived contracts
36
38
  IPoolService internal _poolService;
37
39
 
@@ -55,7 +57,6 @@ contract Pool is BaseComponent, IPoolComponent {
55
57
  constructor(
56
58
  address registry,
57
59
  NftId instanceNftId,
58
- NftId productNftId,
59
60
  // TODO refactor into tokenNftId
60
61
  address token,
61
62
  bool isInterceptor,
@@ -66,7 +67,7 @@ contract Pool is BaseComponent, IPoolComponent {
66
67
  Fee memory performanceFee,
67
68
  address initialOwner
68
69
  )
69
- BaseComponent(registry, instanceNftId, productNftId, token, POOL(), isInterceptor, initialOwner)
70
+ BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
70
71
  {
71
72
  _isVerifying = verifying;
72
73
  // TODO add validation
@@ -75,9 +76,10 @@ contract Pool is BaseComponent, IPoolComponent {
75
76
  _initialStakingFee = stakingFee;
76
77
  _initialPerformanceFee = performanceFee;
77
78
 
78
- // TODO: reactivate when services are available again
79
- // _poolService = _instance.getPoolService();
80
- // _productService = _instance.getProductService();
79
+ _tokenHandler = new TokenHandler(token);
80
+
81
+ _poolService = _instance.getPoolService();
82
+ _productService = _instance.getProductService();
81
83
 
82
84
  _registerInterface(type(IPoolComponent).interfaceId);
83
85
  }
@@ -170,20 +172,6 @@ contract Pool is BaseComponent, IPoolComponent {
170
172
  }
171
173
 
172
174
  function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
173
- // TODO fix this
174
- if (getNftId().eq(zeroNftId())) {
175
- return ISetup.PoolSetupInfo(
176
- _productNftId,
177
- TokenHandler(address(0)),
178
- _collateralizationLevel,
179
- _initialPoolFee,
180
- _initialStakingFee,
181
- _initialPerformanceFee,
182
- _isVerifying,
183
- _wallet
184
- );
185
- }
186
-
187
175
  InstanceReader reader = _instance.getInstanceReader();
188
176
  return reader.getPoolSetupInfo(getNftId());
189
177
  }
@@ -200,15 +188,14 @@ contract Pool is BaseComponent, IPoolComponent {
200
188
  {
201
189
  (
202
190
  IRegistry.ObjectInfo memory info,
203
- bytes memory data
204
191
  ) = super.getInitialInfo();
205
192
 
206
193
  return (
207
194
  info,
208
195
  abi.encode(
209
196
  ISetup.PoolSetupInfo(
210
- getProductNftId(),
211
- TokenHandler(address(0)),
197
+ _productNftId,
198
+ _tokenHandler,
212
199
  _collateralizationLevel,
213
200
  _initialPoolFee,
214
201
  _initialStakingFee,
@@ -24,6 +24,7 @@ import {TokenHandler} from "../shared/TokenHandler.sol";
24
24
  import {InstanceReader} from "../instance/InstanceReader.sol";
25
25
  import {ISetup} from "../instance/module/ISetup.sol";
26
26
  import {Pool} from "../components/Pool.sol";
27
+ import {Distribution} from "../components/Distribution.sol";
27
28
 
28
29
  import {zeroNftId} from "../types/NftId.sol";
29
30
 
@@ -32,9 +33,10 @@ contract Product is BaseComponent, IProductComponent {
32
33
 
33
34
  IProductService internal _productService;
34
35
  Pool internal _pool;
35
- address internal _distribution;
36
+ Distribution internal _distribution;
36
37
  Fee internal _initialProductFee;
37
38
  Fee internal _initialProcessingFee;
39
+ TokenHandler internal _tokenHandler;
38
40
 
39
41
  NftId internal _poolNftId;
40
42
  NftId internal _distributionNftId;
@@ -49,17 +51,18 @@ contract Product is BaseComponent, IProductComponent {
49
51
  Fee memory productFee,
50
52
  Fee memory processingFee,
51
53
  address initialOwner
52
- ) BaseComponent(registry, instanceNftid, zeroNftId(), token, PRODUCT(), isInterceptor, initialOwner) {
54
+ ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
53
55
  // TODO add validation
54
- // TODO: reactivate when services are available again
55
- // _productService = _instance.getProductService();
56
+ _productService = _instance.getProductService();
56
57
  _pool = Pool(pool);
57
- _distribution = distribution;
58
+ _distribution = Distribution(distribution);
58
59
  _initialProductFee = productFee;
59
60
  _initialProcessingFee = processingFee;
60
61
 
62
+ _tokenHandler = new TokenHandler(token);
63
+
61
64
  _poolNftId = getRegistry().getNftId(address(_pool));
62
- _distributionNftId = getRegistry().getNftId(_distribution);
65
+ _distributionNftId = getRegistry().getNftId(address(_distribution));
63
66
 
64
67
  _registerInterface(type(IProductComponent).interfaceId);
65
68
  }
@@ -118,13 +121,13 @@ contract Product is BaseComponent, IProductComponent {
118
121
  );
119
122
  }
120
123
 
121
- function _setRiskInfo(
124
+ function _updateRisk(
122
125
  RiskId id,
123
- IRisk.RiskInfo memory info
126
+ bytes memory data
124
127
  ) internal {
125
- _productService.setRiskInfo(
128
+ _productService.updateRisk(
126
129
  id,
127
- info
130
+ data
128
131
  );
129
132
  }
130
133
 
@@ -202,7 +205,7 @@ contract Product is BaseComponent, IProductComponent {
202
205
  }
203
206
 
204
207
  function getDistributionNftId() external view override returns (NftId distributionNftId) {
205
- return getRegistry().getNftId(_distribution);
208
+ return getRegistry().getNftId(address(_distribution));
206
209
  }
207
210
 
208
211
  // from product component
@@ -218,28 +221,12 @@ contract Product is BaseComponent, IProductComponent {
218
221
  }
219
222
 
220
223
  function getSetupInfo() public view returns (ISetup.ProductSetupInfo memory setupInfo) {
221
- if (getNftId().eq(zeroNftId())) {
222
- return ISetup.ProductSetupInfo(
223
- _token,
224
- TokenHandler(address(0)),
225
- _distributionNftId,
226
- _poolNftId,
227
- FeeLib.zeroFee(), //_instance.getDistributionFee(_distributionNftId)
228
- _initialProductFee,
229
- _initialProcessingFee,
230
- FeeLib.zeroFee(), //_instance.getPoolFee(_poolNftId)
231
- FeeLib.zeroFee(), //_instance.getStakingFee(_poolNftId)
232
- FeeLib.zeroFee() //_instance.getPerformanceFee(_poolNftId)
233
- );
234
- }
235
-
236
224
  InstanceReader reader = _instance.getInstanceReader();
237
225
  return reader.getProductSetupInfo(getNftId());
238
226
  }
239
227
 
240
228
  // from IRegisterable
241
229
 
242
- // TODO used only once, occupies space
243
230
  function getInitialInfo()
244
231
  public
245
232
  view
@@ -251,7 +238,7 @@ contract Product is BaseComponent, IProductComponent {
251
238
  IRegistry.ObjectInfo memory productInfo,
252
239
  bytes memory data
253
240
  ) = super.getInitialInfo();
254
-
241
+
255
242
  // TODO read pool & distribution fees
256
243
  // 1) from pool -> the only option -> pool must be registered first?
257
244
  // 2) from instance -> all fees are set into instance at product registration which is ongoing here
@@ -261,35 +248,39 @@ contract Product is BaseComponent, IProductComponent {
261
248
 
262
249
  // from PoolComponent
263
250
  (
264
- IRegistry.ObjectInfo memory poolInfo,
251
+ ,
265
252
  bytes memory poolData
266
253
  ) = _pool.getInitialInfo();
254
+
255
+ (
256
+ ISetup.PoolSetupInfo memory poolSetupInfo
257
+ ) = abi.decode(poolData, (ISetup.PoolSetupInfo));
267
258
 
259
+ // from DistributionComponent
268
260
  (
269
- /*IPool.PoolInfo memory info*/,
270
- /*address wallet*/,
271
- /*IERC20Metadata token*/,
272
- Fee memory initialPoolFee,
273
- Fee memory initialStakingFee,
274
- Fee memory initialPerformanceFee
275
- ) = abi.decode(poolData, (ISetup.PoolSetupInfo, address, IERC20Metadata, Fee, Fee, Fee));
261
+ ,
262
+ bytes memory distributionData
263
+ ) = _distribution.getInitialInfo();
276
264
 
277
- // TODO from DistributionComponent
265
+ (
266
+ ISetup.DistributionSetupInfo memory distributionSetupInfo
267
+ ) = abi.decode(distributionData, (ISetup.DistributionSetupInfo));
278
268
 
279
269
  return (
280
270
  productInfo,
281
271
  abi.encode(
282
272
  ISetup.ProductSetupInfo(
283
273
  _token,
284
- TokenHandler(address(0)),
274
+ _tokenHandler,
285
275
  _distributionNftId,
286
276
  _poolNftId,
287
- FeeLib.zeroFee(), //_instance.getDistributionFee(_distributionNftId)
277
+ distributionSetupInfo.distributionFee,
288
278
  _initialProductFee,
289
279
  _initialProcessingFee,
290
- initialPoolFee,
291
- initialStakingFee,
292
- initialPerformanceFee
280
+ poolSetupInfo.poolFee,
281
+ poolSetupInfo.stakingFee,
282
+ poolSetupInfo.performanceFee,
283
+ _wallet
293
284
  )
294
285
  )
295
286
  );
@@ -24,14 +24,7 @@ abstract contract AccessManagedSimple is Context, IAccessManaged {
24
24
 
25
25
  bool private _consumingSchedule;
26
26
 
27
- /**
28
- * @dev Initializes the contract connected to an initial authority.
29
- */
30
- constructor(address initialAuthority) {
31
- initialize(initialAuthority);
32
- }
33
-
34
- function initialize(address initialAuthority) public {
27
+ function initializeAccessManagedSimple(address initialAuthority) internal {
35
28
  require(!_initialized, "AccessManaged: already initialized");
36
29
  _setAuthority(initialAuthority);
37
30
  _initialized = true;
@@ -9,25 +9,46 @@ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
9
9
  import {IDistributionService} from "./service/IDistributionService.sol";
10
10
  import {IPoolService} from "./service/IPoolService.sol";
11
11
  import {IProductService} from "./service/IProductService.sol";
12
+ import {IBundle} from "./module/IBundle.sol";
12
13
  import {ISetup} from "./module/ISetup.sol";
13
14
  import {NftId} from "../types/NftId.sol";
14
15
  import {StateId} from "../types/StateId.sol";
16
+ import {RiskId} from "../types/RiskId.sol";
17
+ import {IRisk} from "./module/IRisk.sol";
18
+ import {IPolicy} from "./module/IPolicy.sol";
19
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
15
20
 
16
- interface IInstance is IERC165 {
21
+
22
+ interface IInstance is IERC165, IKeyValueStore {
17
23
 
18
24
  function getComponentOwnerService() external view returns (IComponentOwnerService);
19
- // TODO: renable these when we have the services
20
25
  function getDistributionService() external view returns (IDistributionService);
21
- // function getProductService() external view returns (IProductService);
22
- // function getPoolService() external view returns (IPoolService);
23
-
24
- function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
26
+ function getProductService() external view returns (IProductService);
27
+ function getPoolService() external view returns (IPoolService);
25
28
 
26
29
  function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
27
30
  function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
28
31
  function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
29
32
 
30
- function createPoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup) external;
33
+ function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external;
34
+ function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external;
35
+ function updatePoolSetupState(NftId poolNftId, StateId newState) external;
36
+
37
+ function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external;
38
+ function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external;
39
+ function updateBundleState(NftId bundleNftId, StateId newState) external;
40
+
41
+ function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
42
+ function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external;
43
+ function updateProductSetupState(NftId productNftId, StateId newState) external;
44
+
45
+ function createRisk(RiskId riskId, IRisk.RiskInfo memory risk) external;
46
+ function updateRisk(RiskId riskId, IRisk.RiskInfo memory risk, StateId newState) external;
47
+ function updateRiskState(RiskId riskId, StateId newState) external;
48
+
49
+ function createPolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy) external;
50
+ function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
51
+ function updatePolicyState(NftId policyNftId, StateId newState) external;
31
52
 
32
53
  function getInstanceReader() external view returns (InstanceReader);
33
54
  }
@@ -26,6 +26,8 @@ import {Registerable} from "../shared/Registerable.sol";
26
26
  import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
27
27
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
28
28
  import {IDistributionService} from "./service/IDistributionService.sol";
29
+ import {IPoolService} from "./service/IPoolService.sol";
30
+ import {IProductService} from "./service/IProductService.sol";
29
31
  import {VersionPart} from "../types/Version.sol";
30
32
 
31
33
  contract Instance is
@@ -54,7 +56,6 @@ contract Instance is
54
56
  InstanceReader internal _instanceReader;
55
57
 
56
58
  constructor(address accessManagerAddress, address registryAddress, NftId registryNftId)
57
- AccessManagedSimple(accessManagerAddress)
58
59
  {
59
60
  initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
60
61
  }
@@ -62,6 +63,8 @@ contract Instance is
62
63
  function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
63
64
  require(!_initialized, "Contract instance has already been initialized");
64
65
 
66
+ initializeAccessManagedSimple(accessManagerAddress);
67
+
65
68
  _accessManager = AccessManagerSimple(accessManagerAddress);
66
69
  _createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
67
70
  _createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
@@ -219,16 +222,16 @@ contract Instance is
219
222
  }
220
223
 
221
224
  //--- PoolSetup ------------------------------------------------------//
222
- function createPoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
223
- create(_toNftKey32(distributionNftId, POOL()), abi.encode(setup));
225
+ function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
226
+ create(_toNftKey32(poolNftId, POOL()), abi.encode(setup));
224
227
  }
225
228
 
226
- function updatePoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
227
- update(_toNftKey32(distributionNftId, POOL()), abi.encode(setup), newState);
229
+ function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
230
+ update(_toNftKey32(poolNftId, POOL()), abi.encode(setup), newState);
228
231
  }
229
232
 
230
- function updatePoolSetupState(NftId distributionNftId, StateId newState) external restricted() {
231
- updateState(_toNftKey32(distributionNftId, POOL()), newState);
233
+ function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
234
+ updateState(_toNftKey32(poolNftId, POOL()), newState);
232
235
  }
233
236
 
234
237
  //--- DistributorType ---------------------------------------------------//
@@ -421,15 +424,13 @@ contract Instance is
421
424
  return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
422
425
  }
423
426
 
424
- // TODO reactivate when services are available
425
- // function getProductService() external view returns (IProductService) {
426
- // return ProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
427
- // }
427
+ function getProductService() external view returns (IProductService) {
428
+ return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
429
+ }
428
430
 
429
- // TODO reactivate when services are available
430
- // function getPoolService() external view returns (IPoolService) {
431
- // return PoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
432
- // }
431
+ function getPoolService() external view returns (IPoolService) {
432
+ return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
433
+ }
433
434
 
434
435
  function setInstanceReader(InstanceReader instanceReader) external restricted() {
435
436
  require(address(_instanceReader) == address(0), "InstanceReader is set");
@@ -79,9 +79,9 @@ contract InstanceAccessManager is
79
79
  AccessManagerSimple internal _accessManager;
80
80
 
81
81
  constructor(address accessManager)
82
- AccessManagedSimple(accessManager)
83
82
  {
84
83
  _accessManager = AccessManagerSimple(accessManager);
84
+ initializeAccessManagedSimple(accessManager);
85
85
 
86
86
  _createRole(RoleIdLib.toRoleId(_accessManager.ADMIN_ROLE()), ADMIN_ROLE_NAME, false, false);
87
87
  _createRole(RoleIdLib.toRoleId(_accessManager.PUBLIC_ROLE()), PUBLIC_ROLE_NAME, false, false);
@@ -7,14 +7,16 @@ import {DistributorType} from "../types/DistributorType.sol";
7
7
  import {Fee, FeeLib} from "../types/Fee.sol";
8
8
  import {Key32} from "../types/Key32.sol";
9
9
  import {NftId} from "../types/NftId.sol";
10
- import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY} from "../types/ObjectType.sol";
10
+ import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY, BUNDLE} from "../types/ObjectType.sol";
11
11
  import {ReferralId, ReferralStatus, ReferralLib, REFERRAL_OK, REFERRAL_ERROR_UNKNOWN, REFERRAL_ERROR_EXPIRED, REFERRAL_ERROR_EXHAUSTED} from "../types/Referral.sol";
12
12
  import {Registerable} from "../shared/Registerable.sol";
13
13
  import {RiskId} from "../types/RiskId.sol";
14
14
  import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
15
15
  import {Version} from "../types/Version.sol";
16
+ import {StateId} from "../types/StateId.sol";
16
17
 
17
18
  import {IRegistry} from "../registry/IRegistry.sol";
19
+ import {IBundle} from "../instance/module/IBundle.sol";
18
20
  import {IDistribution} from "../instance/module/IDistribution.sol";
19
21
  import {IInstance} from "./IInstance.sol";
20
22
  import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
@@ -80,6 +82,14 @@ contract InstanceReader {
80
82
  }
81
83
  }
82
84
 
85
+ function getPolicyState(NftId policyNftId)
86
+ public
87
+ view
88
+ returns (StateId state)
89
+ {
90
+ return _instance.getState(toPolicyKey(policyNftId));
91
+ }
92
+
83
93
  function getRiskInfo(RiskId riskId)
84
94
  public
85
95
  view
@@ -114,6 +124,17 @@ contract InstanceReader {
114
124
  return abi.decode(data, (ITreasury.TreasuryInfo));
115
125
  }
116
126
  }
127
+
128
+ function getBundleInfo(NftId bundleNftId)
129
+ public
130
+ view
131
+ returns (IBundle.BundleInfo memory info)
132
+ {
133
+ bytes memory data = _store.getData(toBundleKey(bundleNftId));
134
+ if (data.length > 0) {
135
+ return abi.decode(data, (IBundle.BundleInfo));
136
+ }
137
+ }
117
138
 
118
139
  function getDistributorTypeInfo(DistributorType distributorType)
119
140
  public
@@ -259,6 +280,10 @@ contract InstanceReader {
259
280
  return distributionNftId.toKey32(DISTRIBUTION());
260
281
  }
261
282
 
283
+ function toBundleKey(NftId poolNftId) public pure returns (Key32) {
284
+ return poolNftId.toKey32(BUNDLE());
285
+ }
286
+
262
287
  function toPoolKey(NftId poolNftId) public pure returns (Key32) {
263
288
  return poolNftId.toKey32(POOL());
264
289
  }