@etherisc/gif-next 0.0.2-d63a6a1-078 → 0.0.2-d64ea51-772
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +13 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +23 -15
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +13 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +21 -13
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +26 -56
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +0 -13
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1333 -19
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +147 -101
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -47
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +167 -38
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +209 -33
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +91 -15
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +59 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +18 -18
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +716 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +444 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +87 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +40 -31
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +926 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +448 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1147 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +488 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +201 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -19
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +172 -49
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -29
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +47 -34
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +4 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +11 -11
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/BaseComponent.sol +8 -3
- package/contracts/components/Distribution.sol +15 -18
- package/contracts/components/IBaseComponent.sol +1 -0
- package/contracts/components/IDistributionComponent.sol +1 -0
- package/contracts/components/Pool.sol +9 -22
- package/contracts/components/Product.sol +33 -42
- package/contracts/instance/AccessManagedSimple.sol +1 -8
- package/contracts/instance/IInstance.sol +33 -7
- package/contracts/instance/Instance.sol +20 -19
- package/contracts/instance/InstanceAccessManager.sol +1 -1
- package/contracts/instance/InstanceReader.sol +26 -1
- package/contracts/instance/InstanceService.sol +69 -9
- package/contracts/instance/InstanceServiceManager.sol +6 -5
- package/contracts/instance/base/ComponentServiceBase.sol +91 -6
- package/contracts/instance/module/IBundle.sol +1 -0
- package/contracts/instance/module/ISetup.sol +2 -0
- package/contracts/instance/service/DistributionService.sol +88 -0
- package/contracts/instance/service/DistributionServiceManager.sol +54 -0
- package/contracts/instance/service/IPoolService.sol +4 -0
- package/contracts/instance/service/IProductService.sol +6 -3
- package/contracts/instance/service/PoolService.sol +201 -0
- package/contracts/instance/service/PoolServiceManager.sol +54 -0
- package/contracts/instance/service/ProductService.sol +563 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/IRegistry.sol +25 -2
- package/contracts/registry/IRegistryService.sol +27 -12
- package/contracts/registry/Registry.sol +60 -35
- package/contracts/registry/RegistryService.sol +30 -116
- package/contracts/registry/RegistryServiceManager.sol +21 -5
- package/contracts/registry/TokenRegistry.sol +111 -0
- package/contracts/shared/ERC165.sol +6 -2
- package/contracts/shared/NftOwnable.sol +2 -4
- package/contracts/shared/Registerable.sol +1 -0
- package/contracts/shared/Service.sol +1 -0
- package/contracts/types/RoleId.sol +8 -0
- package/contracts/types/StateId.sol +4 -0
- package/contracts/types/Version.sol +4 -1
- package/package.json +1 -1
@@ -11,13 +11,15 @@ import {IInstance} from "../instance/IInstance.sol";
|
|
11
11
|
import {IInstance} from "../instance/IInstance.sol";
|
12
12
|
import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
|
13
13
|
import {IBaseComponent} from "./IBaseComponent.sol";
|
14
|
-
import {NftId} from "../types/NftId.sol";
|
14
|
+
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
15
15
|
import {ObjectType} from "../types/ObjectType.sol";
|
16
16
|
|
17
17
|
abstract contract BaseComponent is
|
18
18
|
Registerable,
|
19
19
|
IBaseComponent
|
20
20
|
{
|
21
|
+
using NftIdLib for NftId;
|
22
|
+
|
21
23
|
IComponentOwnerService internal _componentOwnerService;
|
22
24
|
|
23
25
|
address internal _deployer;
|
@@ -29,7 +31,6 @@ abstract contract BaseComponent is
|
|
29
31
|
constructor(
|
30
32
|
address registry,
|
31
33
|
NftId instanceNftId,
|
32
|
-
NftId productNftId,
|
33
34
|
address token,
|
34
35
|
ObjectType componentType,
|
35
36
|
bool isInterceptor,
|
@@ -49,7 +50,6 @@ abstract contract BaseComponent is
|
|
49
50
|
_componentOwnerService = _instance.getComponentOwnerService();
|
50
51
|
_wallet = address(this);
|
51
52
|
_token = IERC20Metadata(token);
|
52
|
-
_productNftId = productNftId;
|
53
53
|
|
54
54
|
_registerInterface(type(IBaseComponent).interfaceId);
|
55
55
|
}
|
@@ -80,6 +80,11 @@ abstract contract BaseComponent is
|
|
80
80
|
return _instance;
|
81
81
|
}
|
82
82
|
|
83
|
+
function setProductNftId(NftId productNftId) public override onlyOwner {
|
84
|
+
require(_productNftId.eq(zeroNftId()), "product nft id already set");
|
85
|
+
_productNftId = productNftId;
|
86
|
+
}
|
87
|
+
|
83
88
|
function getProductNftId() public view override returns (NftId productNftId) {
|
84
89
|
return _productNftId;
|
85
90
|
}
|
@@ -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,
|
49
|
+
BaseComponent(registry, instanceNftId, token, DISTRIBUTION(), true, initialOwner)
|
49
50
|
{
|
50
51
|
_isVerifying = verifying;
|
51
52
|
_initialDistributionFee = distributionFee;
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
162
|
-
|
153
|
+
ISetup.DistributionSetupInfo(
|
154
|
+
_productNftId,
|
155
|
+
_tokenHandler,
|
156
|
+
_initialDistributionFee,
|
157
|
+
_isVerifying,
|
158
|
+
address(this)
|
159
|
+
)
|
163
160
|
)
|
164
161
|
);
|
165
162
|
}
|
@@ -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,
|
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
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
211
|
-
|
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
|
-
|
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,
|
54
|
+
) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
|
53
55
|
// TODO add validation
|
54
|
-
|
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
|
124
|
+
function _updateRisk(
|
122
125
|
RiskId id,
|
123
|
-
|
126
|
+
bytes memory data
|
124
127
|
) internal {
|
125
|
-
_productService.
|
128
|
+
_productService.updateRisk(
|
126
129
|
id,
|
127
|
-
|
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
|
-
|
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
|
-
|
270
|
-
|
271
|
-
|
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
|
-
|
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
|
-
|
274
|
+
_tokenHandler,
|
285
275
|
_distributionNftId,
|
286
276
|
_poolNftId,
|
287
|
-
|
277
|
+
distributionSetupInfo.distributionFee,
|
288
278
|
_initialProductFee,
|
289
279
|
_initialProcessingFee,
|
290
|
-
|
291
|
-
|
292
|
-
|
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,20 +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";
|
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";
|
14
20
|
|
15
|
-
|
21
|
+
|
22
|
+
interface IInstance is IERC165, IKeyValueStore {
|
16
23
|
|
17
24
|
function getComponentOwnerService() external view returns (IComponentOwnerService);
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
// function getPoolService() external view returns (IPoolService);
|
25
|
+
function getDistributionService() external view returns (IDistributionService);
|
26
|
+
function getProductService() external view returns (IProductService);
|
27
|
+
function getPoolService() external view returns (IPoolService);
|
22
28
|
|
23
|
-
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
|
24
29
|
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
|
25
|
-
function
|
30
|
+
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
|
31
|
+
function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
|
32
|
+
|
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;
|
26
52
|
|
27
53
|
function getInstanceReader() external view returns (InstanceReader);
|
28
54
|
}
|
@@ -25,6 +25,9 @@ import {ERC165} from "../shared/ERC165.sol";
|
|
25
25
|
import {Registerable} from "../shared/Registerable.sol";
|
26
26
|
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
27
27
|
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
28
|
+
import {IDistributionService} from "./service/IDistributionService.sol";
|
29
|
+
import {IPoolService} from "./service/IPoolService.sol";
|
30
|
+
import {IProductService} from "./service/IProductService.sol";
|
28
31
|
import {VersionPart} from "../types/Version.sol";
|
29
32
|
|
30
33
|
contract Instance is
|
@@ -53,7 +56,6 @@ contract Instance is
|
|
53
56
|
InstanceReader internal _instanceReader;
|
54
57
|
|
55
58
|
constructor(address accessManagerAddress, address registryAddress, NftId registryNftId)
|
56
|
-
AccessManagedSimple(accessManagerAddress)
|
57
59
|
{
|
58
60
|
initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
|
59
61
|
}
|
@@ -61,6 +63,8 @@ contract Instance is
|
|
61
63
|
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
|
62
64
|
require(!_initialized, "Contract instance has already been initialized");
|
63
65
|
|
66
|
+
initializeAccessManagedSimple(accessManagerAddress);
|
67
|
+
|
64
68
|
_accessManager = AccessManagerSimple(accessManagerAddress);
|
65
69
|
_createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
|
66
70
|
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
@@ -218,16 +222,16 @@ contract Instance is
|
|
218
222
|
}
|
219
223
|
|
220
224
|
//--- PoolSetup ------------------------------------------------------//
|
221
|
-
function createPoolSetup(NftId
|
222
|
-
create(_toNftKey32(
|
225
|
+
function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
|
226
|
+
create(_toNftKey32(poolNftId, POOL()), abi.encode(setup));
|
223
227
|
}
|
224
228
|
|
225
|
-
function updatePoolSetup(NftId
|
226
|
-
update(_toNftKey32(
|
229
|
+
function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
|
230
|
+
update(_toNftKey32(poolNftId, POOL()), abi.encode(setup), newState);
|
227
231
|
}
|
228
232
|
|
229
|
-
function updatePoolSetupState(NftId
|
230
|
-
updateState(_toNftKey32(
|
233
|
+
function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
|
234
|
+
updateState(_toNftKey32(poolNftId, POOL()), newState);
|
231
235
|
}
|
232
236
|
|
233
237
|
//--- DistributorType ---------------------------------------------------//
|
@@ -416,20 +420,17 @@ contract Instance is
|
|
416
420
|
return ComponentOwnerService(_registry.getServiceAddress("ComponentOwnerService", VersionPart.wrap(3)));
|
417
421
|
}
|
418
422
|
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
// }
|
423
|
+
function getDistributionService() external view returns (IDistributionService) {
|
424
|
+
return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
|
425
|
+
}
|
423
426
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
// }
|
427
|
+
function getProductService() external view returns (IProductService) {
|
428
|
+
return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
|
429
|
+
}
|
428
430
|
|
429
|
-
|
430
|
-
|
431
|
-
|
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
|
}
|