@etherisc/gif-next 0.0.2-f2b0fa2-473 → 0.0.2-f63e99e-607
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.
- 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 +39 -18
- 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/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +15 -2
- 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 +403 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +59 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +164 -84
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -34
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +168 -37
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +229 -41
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +77 -9
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +29 -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 +681 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +436 -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/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +820 -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/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 +309 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -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 +258 -24
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +20 -44
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +49 -28
- 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 +10 -16
- package/contracts/components/IBaseComponent.sol +1 -0
- package/contracts/components/IDistributionComponent.sol +1 -0
- package/contracts/components/Pool.sol +4 -20
- package/contracts/components/Product.sol +1 -1
- package/contracts/instance/AccessManagedSimple.sol +5 -4
- package/contracts/instance/AccessManagerSimple.sol +10 -0
- package/contracts/instance/IInstance.sol +15 -4
- package/contracts/instance/IInstanceService.sol +14 -1
- package/contracts/instance/Instance.sol +28 -21
- package/contracts/instance/InstanceAccessManager.sol +1 -1
- package/contracts/instance/InstanceReader.sol +27 -1
- package/contracts/instance/InstanceService.sol +104 -24
- package/contracts/instance/base/ComponentServiceBase.sol +19 -8
- package/contracts/instance/module/IBundle.sol +1 -0
- package/contracts/instance/module/ISetup.sol +1 -0
- package/contracts/instance/service/DistributionService.sol +102 -0
- package/contracts/instance/service/DistributionServiceManager.sol +53 -0
- package/contracts/instance/service/PoolService.sol +208 -0
- package/contracts/instance/service/PoolServiceManager.sol +53 -0
- package/contracts/registry/IRegistry.sol +39 -2
- package/contracts/registry/IRegistryService.sol +0 -2
- package/contracts/registry/Registry.sol +94 -28
- package/contracts/registry/RegistryService.sol +9 -49
- package/contracts/registry/RegistryServiceManager.sol +21 -5
- package/contracts/registry/TokenRegistry.sol +111 -0
- package/contracts/shared/ERC165.sol +6 -2
- package/contracts/shared/Registerable.sol +1 -0
- package/contracts/types/RoleId.sol +7 -0
- package/contracts/types/StateId.sol +4 -0
- package/contracts/types/Version.sol +4 -1
- package/package.json +1 -1
@@ -7,18 +7,24 @@ import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
|
7
7
|
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
8
8
|
import {Instance} from "./Instance.sol";
|
9
9
|
import {IInstanceService} from "./IInstanceService.sol";
|
10
|
-
import {
|
10
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
11
11
|
import {IRegistry} from "../registry/IRegistry.sol";
|
12
|
+
import {Registry} from "../registry/Registry.sol";
|
13
|
+
import {RegistryService} from "../registry/RegistryService.sol";
|
14
|
+
import {Service} from "../../contracts/shared/Service.sol";
|
12
15
|
import {IService} from "../shared/IService.sol";
|
13
16
|
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
14
|
-
import {NftId, NftIdLib, zeroNftId} from "
|
17
|
+
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
18
|
+
import {RoleId} from "../types/RoleId.sol";
|
19
|
+
import {VersionLib} from "../types/Version.sol";
|
20
|
+
import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE} from "../types/RoleId.sol";
|
15
21
|
|
16
22
|
contract InstanceService is Service, IInstanceService {
|
17
23
|
|
18
24
|
address internal _registryAddress;
|
19
25
|
address internal _accessManagerMaster;
|
20
|
-
address internal _instanceAccessManagerMaster;
|
21
26
|
address internal _instanceMaster;
|
27
|
+
address internal _instanceReaderMaster;
|
22
28
|
|
23
29
|
// TODO update to real hash when instance is stable
|
24
30
|
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
@@ -27,31 +33,101 @@ contract InstanceService is Service, IInstanceService {
|
|
27
33
|
function createInstanceClone()
|
28
34
|
external
|
29
35
|
returns (
|
30
|
-
AccessManagerSimple
|
31
|
-
|
32
|
-
|
36
|
+
AccessManagerSimple clonedAccessManager,
|
37
|
+
Instance clonedInstance,
|
38
|
+
NftId instanceNftId,
|
39
|
+
InstanceReader clonedInstanceReader
|
33
40
|
)
|
34
41
|
{
|
35
|
-
|
36
|
-
|
37
|
-
|
42
|
+
address instanceOwner = msg.sender;
|
43
|
+
Registry registry = Registry(_registryAddress);
|
44
|
+
NftId registryNftId = registry.getNftId(_registryAddress);
|
45
|
+
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
46
|
+
RegistryService registryService = RegistryService(registryServiceAddress);
|
47
|
+
|
48
|
+
// initially set the authority of the access managar to this (being the instance service).
|
49
|
+
// This will allow the instance service to bootstrap the authorizations of the instance
|
50
|
+
// and then transfer the ownership of the access manager to the instance owner once everything is setup
|
51
|
+
clonedAccessManager = AccessManagerSimple(Clones.clone(_accessManagerMaster));
|
52
|
+
clonedAccessManager.initialize(address(this));
|
53
|
+
|
54
|
+
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
55
|
+
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
56
|
+
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
57
|
+
instanceNftId = info.nftId;
|
58
|
+
|
59
|
+
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
60
|
+
clonedInstanceReader.initialize(_registryAddress, instanceNftId);
|
61
|
+
|
62
|
+
_grantInitialAuthorizations(clonedAccessManager, clonedInstance);
|
63
|
+
|
64
|
+
clonedInstance.setInstanceReader(clonedInstanceReader);
|
65
|
+
|
66
|
+
// to complete setup switch instance ownership to the instance owner
|
67
|
+
// TODO: use a role less powerful than admin, maybe INSTANCE_ADMIN (does not exist yet)
|
68
|
+
clonedAccessManager.grantRole(ADMIN_ROLE().toInt(), instanceOwner, 0);
|
69
|
+
clonedAccessManager.revokeRole(ADMIN_ROLE().toInt(), address(this));
|
70
|
+
|
71
|
+
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), instanceNftId);
|
72
|
+
}
|
73
|
+
|
74
|
+
function _grantInitialAuthorizations(AccessManagerSimple clonedAccessManager, Instance clonedInstance) internal {
|
75
|
+
address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
76
|
+
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE().toInt(), distributionServiceAddress, 0);
|
77
|
+
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
|
78
|
+
instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
|
79
|
+
instanceDistributionServiceSelectors[1] = clonedInstance.updateDistributionSetup.selector;
|
80
|
+
clonedAccessManager.setTargetFunctionRole(
|
81
|
+
address(clonedInstance),
|
82
|
+
instanceDistributionServiceSelectors,
|
83
|
+
DISTRIBUTION_SERVICE_ROLE().toInt());
|
84
|
+
|
85
|
+
address poolServiceAddress = _registry.getServiceAddress("PoolService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
86
|
+
clonedAccessManager.grantRole(POOL_SERVICE_ROLE().toInt(), address(poolServiceAddress), 0);
|
87
|
+
bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
|
88
|
+
instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
|
89
|
+
instancePoolServiceSelectors[1] = clonedInstance.updatePoolSetup.selector;
|
90
|
+
instancePoolServiceSelectors[2] = clonedInstance.createBundle.selector;
|
91
|
+
instancePoolServiceSelectors[3] = clonedInstance.updateBundle.selector;
|
92
|
+
clonedAccessManager.setTargetFunctionRole(
|
93
|
+
address(clonedInstance),
|
94
|
+
instancePoolServiceSelectors,
|
95
|
+
POOL_SERVICE_ROLE().toInt());
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
function setAccessManagerMaster(address accessManagerMaster) external {
|
100
|
+
require(
|
101
|
+
_accessManagerMaster == address(0),
|
102
|
+
"ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
|
103
|
+
_accessManagerMaster = accessManagerMaster;
|
104
|
+
}
|
105
|
+
|
106
|
+
function setInstanceMaster(address instanceMaster) external {
|
107
|
+
require(
|
108
|
+
_instanceMaster == address(0),
|
109
|
+
"ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
110
|
+
_instanceMaster = instanceMaster;
|
38
111
|
}
|
39
112
|
|
40
|
-
function
|
41
|
-
|
113
|
+
function setInstanceReaderMaster(address instanceReaderMaster) external {
|
114
|
+
require(
|
115
|
+
_instanceReaderMaster == address(0),
|
116
|
+
"ERROR:CRD-003:INSTANCE_READER_MASTER_ALREADY_SET");
|
117
|
+
_instanceReaderMaster = instanceReaderMaster;
|
42
118
|
}
|
43
119
|
|
44
|
-
function
|
45
|
-
|
120
|
+
function getInstanceReaderMaster() external view returns (address) {
|
121
|
+
return _instanceReaderMaster;
|
46
122
|
}
|
47
123
|
|
48
|
-
function
|
49
|
-
_instanceMaster
|
124
|
+
function getInstanceMaster() external view returns (address) {
|
125
|
+
return _instanceMaster;
|
50
126
|
}
|
51
127
|
|
52
|
-
function getAccessManagerMaster() external view returns (address) {
|
53
|
-
|
54
|
-
|
128
|
+
function getAccessManagerMaster() external view returns (address) {
|
129
|
+
return _accessManagerMaster;
|
130
|
+
}
|
55
131
|
|
56
132
|
// From IService
|
57
133
|
function getName() public pure override(IService, Service) returns(string memory) {
|
@@ -85,18 +161,22 @@ contract InstanceService is Service, IInstanceService {
|
|
85
161
|
address initialOwner = address(0);
|
86
162
|
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
87
163
|
|
88
|
-
// // TODO register instance in registry
|
89
|
-
IRegistry registry = IRegistry(_registryAddress);
|
90
|
-
NftId registryNftId = registry.getNftId(_registryAddress);
|
91
|
-
|
92
164
|
_initializeService(_registryAddress, initialOwner);
|
93
165
|
|
94
166
|
_registerInterface(type(IService).interfaceId);
|
95
167
|
_registerInterface(type(IInstanceService).interfaceId);
|
96
168
|
}
|
97
169
|
|
98
|
-
function
|
99
|
-
|
170
|
+
function hasRole(address account, RoleId role, NftId instanceNftId) external view returns (bool) {
|
171
|
+
IRegistry.ObjectInfo memory instanceObjectInfo = getRegistry().getObjectInfo(instanceNftId);
|
172
|
+
address instanceAddress = instanceObjectInfo.objectAddress;
|
173
|
+
Instance instance = Instance(instanceAddress);
|
174
|
+
AccessManagerSimple accessManager = AccessManagerSimple(instance.authority());
|
175
|
+
(bool isMember, uint32 executionDelay) = accessManager.hasRole(role.toInt(), account);
|
176
|
+
if (executionDelay > 0) {
|
177
|
+
return false;
|
178
|
+
}
|
179
|
+
return isMember;
|
100
180
|
}
|
101
181
|
}
|
102
182
|
|
@@ -6,21 +6,32 @@ import {IRegistryService} from "../../registry/IRegistryService.sol";
|
|
6
6
|
import {IInstance} from "../../instance/IInstance.sol";
|
7
7
|
import {ObjectType, INSTANCE, PRODUCT, POOL} from "../../types/ObjectType.sol";
|
8
8
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
9
|
+
import {RoleId} from "../../types/RoleId.sol";
|
10
|
+
import {BaseComponent} from "../../components/BaseComponent.sol";
|
9
11
|
|
12
|
+
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
10
13
|
import {Service} from "../../shared/Service.sol";
|
14
|
+
import {InstanceService} from "../InstanceService.sol";
|
11
15
|
import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
|
12
16
|
|
13
17
|
abstract contract ComponentServiceBase is Service {
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
error InvalidRole(RoleId expected, address caller);
|
20
|
+
|
21
|
+
/// @dev modifier to check if caller has a role on the instance the component is registered in
|
22
|
+
modifier onlyInstanceRole(RoleId role, address componentAddress) {
|
23
|
+
address componentOwner = msg.sender;
|
24
|
+
BaseComponent component = BaseComponent(componentAddress);
|
25
|
+
INftOwnable nftOwnable = INftOwnable(address(component.getInstance()));
|
26
|
+
if(! getInstanceService().hasRole(componentOwner, role, nftOwnable.getNftId())) {
|
27
|
+
revert InvalidRole(role, componentOwner);
|
28
|
+
}
|
29
|
+
_;
|
22
30
|
}
|
23
31
|
|
32
|
+
function getInstanceService() public view returns (InstanceService) {
|
33
|
+
return InstanceService(getRegistry().getServiceAddress("InstanceService", getMajorVersion()));
|
34
|
+
}
|
24
35
|
|
25
36
|
function _getAndVerifyComponentInfoAndInstance(
|
26
37
|
ObjectType objectType
|
@@ -32,7 +43,7 @@ abstract contract ComponentServiceBase is Service {
|
|
32
43
|
IInstance instance
|
33
44
|
)
|
34
45
|
{
|
35
|
-
NftId componentNftId =
|
46
|
+
NftId componentNftId = _registry.getNftId(msg.sender);
|
36
47
|
require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
37
48
|
|
38
49
|
info = getRegistry().getObjectInfo(componentNftId);
|
@@ -13,6 +13,7 @@ interface IBundle {
|
|
13
13
|
uint256 capitalAmount; // net investment capital + net premiums - payouts
|
14
14
|
uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
|
15
15
|
uint256 balanceAmount; // total amount of funds: capitalAmount + fees (balance >= captial)
|
16
|
+
uint256 lifetime;
|
16
17
|
Timestamp expiredAt; // no new policies
|
17
18
|
Timestamp closedAt; // no open policies, locked amount = 0
|
18
19
|
}
|
@@ -5,6 +5,7 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
|
|
5
5
|
|
6
6
|
import {Fee} from "../../types/Fee.sol";
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {LibNftIdSet} from "../../types/NftIdSet.sol";
|
8
9
|
import {UFixed} from "../../types/UFixed.sol";
|
9
10
|
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
10
11
|
|
@@ -0,0 +1,102 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
6
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
7
|
+
import {InstanceReader} from "../../instance/InstanceReader.sol";
|
8
|
+
import {ISetup} from "../../instance/module/ISetup.sol";
|
9
|
+
import {ITreasury} from "../../instance/module/ITreasury.sol";
|
10
|
+
|
11
|
+
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
12
|
+
import {Fee} from "../../types/Fee.sol";
|
13
|
+
import {DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
|
14
|
+
import {KEEP_STATE} from "../../types/StateId.sol";
|
15
|
+
import {DISTRIBUTION} from "../../types/ObjectType.sol";
|
16
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
17
|
+
|
18
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
19
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
20
|
+
|
21
|
+
import {IService} from "../../shared/IService.sol";
|
22
|
+
import {Service} from "../../shared/Service.sol";
|
23
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
24
|
+
import {IDistributionService} from "./IDistributionService.sol";
|
25
|
+
import {Distribution} from "../../components/Distribution.sol";
|
26
|
+
import {InstanceService} from "../InstanceService.sol";
|
27
|
+
import {Instance} from "../Instance.sol";
|
28
|
+
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
29
|
+
|
30
|
+
string constant DISTRIBUTION_SERVICE_NAME = "DistributionService";
|
31
|
+
|
32
|
+
contract DistributionService is
|
33
|
+
ComponentServiceBase,
|
34
|
+
IDistributionService
|
35
|
+
{
|
36
|
+
using NftIdLib for NftId;
|
37
|
+
|
38
|
+
string public constant NAME = "DistributionService";
|
39
|
+
|
40
|
+
address internal _registryAddress;
|
41
|
+
|
42
|
+
function _initialize(
|
43
|
+
address owner,
|
44
|
+
bytes memory data
|
45
|
+
)
|
46
|
+
internal
|
47
|
+
initializer
|
48
|
+
virtual override
|
49
|
+
{
|
50
|
+
address initialOwner = address(0);
|
51
|
+
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
52
|
+
|
53
|
+
_initializeService(_registryAddress, initialOwner);
|
54
|
+
|
55
|
+
_registerInterface(type(IService).interfaceId);
|
56
|
+
_registerInterface(type(IDistributionService).interfaceId);
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
function getName() public pure override(IService, Service) returns(string memory name) {
|
61
|
+
return NAME;
|
62
|
+
}
|
63
|
+
|
64
|
+
function register(address distributionComponentAddress)
|
65
|
+
external
|
66
|
+
onlyInstanceRole(DISTRIBUTION_OWNER_ROLE(), distributionComponentAddress)
|
67
|
+
returns (NftId distributionNftId)
|
68
|
+
{
|
69
|
+
address componentOwner = msg.sender;
|
70
|
+
Distribution distribution = Distribution(distributionComponentAddress);
|
71
|
+
IInstance instance = distribution.getInstance();
|
72
|
+
|
73
|
+
IRegistryService registryService = getRegistryService();
|
74
|
+
(IRegistry.ObjectInfo memory distributionObjInfo, bytes memory initialObjData ) = registryService.registerDistribution(
|
75
|
+
distribution,
|
76
|
+
componentOwner
|
77
|
+
);
|
78
|
+
distributionNftId = distributionObjInfo.nftId;
|
79
|
+
|
80
|
+
ISetup.DistributionSetupInfo memory initialSetup = abi.decode(
|
81
|
+
initialObjData,
|
82
|
+
(ISetup.DistributionSetupInfo)
|
83
|
+
);
|
84
|
+
instance.createDistributionSetup(distributionNftId, initialSetup);
|
85
|
+
}
|
86
|
+
|
87
|
+
function setFees(
|
88
|
+
Fee memory distributionFee
|
89
|
+
)
|
90
|
+
external
|
91
|
+
override
|
92
|
+
{
|
93
|
+
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
94
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
95
|
+
NftId distributionNftId = info.nftId;
|
96
|
+
|
97
|
+
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
98
|
+
distSetupInfo.distributionFee = distributionFee;
|
99
|
+
|
100
|
+
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
101
|
+
}
|
102
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
5
|
+
import {ProxyManager} from "../../shared/ProxyManager.sol";
|
6
|
+
import {DistributionService} from "./DistributionService.sol";
|
7
|
+
import {Registry} from "../../registry/Registry.sol";
|
8
|
+
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
+
import {VersionLib} from "../../types/Version.sol";
|
10
|
+
|
11
|
+
contract DistributionServiceManager is ProxyManager {
|
12
|
+
|
13
|
+
DistributionService private _distributionService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with distribution service implementation and deploys instance
|
16
|
+
constructor(
|
17
|
+
address registryAddress
|
18
|
+
)
|
19
|
+
ProxyManager()
|
20
|
+
{
|
21
|
+
DistributionService distSrv = new DistributionService();
|
22
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
23
|
+
IVersionable versionable = deploy(
|
24
|
+
address(distSrv),
|
25
|
+
data);
|
26
|
+
|
27
|
+
_distributionService = DistributionService(address(versionable));
|
28
|
+
|
29
|
+
Registry registry = Registry(registryAddress);
|
30
|
+
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
31
|
+
RegistryService registryService = RegistryService(registryServiceAddress);
|
32
|
+
|
33
|
+
registryService.registerService(_distributionService);
|
34
|
+
|
35
|
+
// link ownership of instance service manager ot nft owner of instance service
|
36
|
+
_linkToNftOwnable(
|
37
|
+
address(registryAddress),
|
38
|
+
address(_distributionService));
|
39
|
+
|
40
|
+
// implies that after this constructor call only upgrade functionality is available
|
41
|
+
_isDeployed = true;
|
42
|
+
}
|
43
|
+
|
44
|
+
//--- view functions ----------------------------------------------------//
|
45
|
+
function getDistributionService()
|
46
|
+
external
|
47
|
+
view
|
48
|
+
returns (DistributionService distributionService)
|
49
|
+
{
|
50
|
+
return _distributionService;
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
@@ -0,0 +1,208 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {Pool} from "../../components/Pool.sol";
|
5
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
6
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
7
|
+
import {IBundle} from "../../instance/module/IBundle.sol";
|
8
|
+
import {TokenHandler} from "../../instance/module/ITreasury.sol";
|
9
|
+
import {ISetup} from "../module/ISetup.sol";
|
10
|
+
|
11
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
12
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
13
|
+
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
14
|
+
|
15
|
+
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
16
|
+
import {POOL, BUNDLE} from "../../types/ObjectType.sol";
|
17
|
+
import {POOL_OWNER_ROLE, RoleId} from "../../types/RoleId.sol";
|
18
|
+
import {Fee, FeeLib} from "../../types/Fee.sol";
|
19
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
20
|
+
import {KEEP_STATE} from "../../types/StateId.sol";
|
21
|
+
import {zeroTimestamp} from "../../types/Timestamp.sol";
|
22
|
+
|
23
|
+
import {IService} from "../../shared/IService.sol";
|
24
|
+
import {Service} from "../../shared/Service.sol";
|
25
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
26
|
+
import {IPoolService} from "./IPoolService.sol";
|
27
|
+
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
28
|
+
import {InstanceService} from "../InstanceService.sol";
|
29
|
+
import {InstanceReader} from "../InstanceReader.sol";
|
30
|
+
|
31
|
+
|
32
|
+
string constant POOL_SERVICE_NAME = "PoolService";
|
33
|
+
|
34
|
+
contract PoolService is
|
35
|
+
ComponentServiceBase,
|
36
|
+
IPoolService
|
37
|
+
{
|
38
|
+
using NftIdLib for NftId;
|
39
|
+
|
40
|
+
string public constant NAME = "PoolService";
|
41
|
+
|
42
|
+
address internal _registryAddress;
|
43
|
+
|
44
|
+
function _initialize(
|
45
|
+
address owner,
|
46
|
+
bytes memory data
|
47
|
+
)
|
48
|
+
internal
|
49
|
+
initializer
|
50
|
+
virtual override
|
51
|
+
{
|
52
|
+
address initialOwner = address(0);
|
53
|
+
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
54
|
+
|
55
|
+
_initializeService(_registryAddress, initialOwner);
|
56
|
+
|
57
|
+
_registerInterface(type(IService).interfaceId);
|
58
|
+
_registerInterface(type(IPoolService).interfaceId);
|
59
|
+
}
|
60
|
+
|
61
|
+
function getName() public pure override(Service, IService) returns(string memory name) {
|
62
|
+
return NAME;
|
63
|
+
}
|
64
|
+
|
65
|
+
function register(address poolComponentAddress)
|
66
|
+
external
|
67
|
+
onlyInstanceRole(POOL_OWNER_ROLE(), poolComponentAddress)
|
68
|
+
returns (NftId poolNftId)
|
69
|
+
{
|
70
|
+
address componentOwner = msg.sender;
|
71
|
+
Pool pool = Pool(poolComponentAddress);
|
72
|
+
IInstance instance = pool.getInstance();
|
73
|
+
|
74
|
+
IRegistryService registryService = getRegistryService();
|
75
|
+
(IRegistry.ObjectInfo memory poolObjInfo, bytes memory initialObjData ) = registryService.registerPool(
|
76
|
+
pool,
|
77
|
+
componentOwner
|
78
|
+
);
|
79
|
+
poolNftId = poolObjInfo.nftId;
|
80
|
+
|
81
|
+
ISetup.PoolSetupInfo memory initialSetup = abi.decode(
|
82
|
+
initialObjData,
|
83
|
+
(ISetup.PoolSetupInfo)
|
84
|
+
);
|
85
|
+
instance.createPoolSetup(poolNftId, initialSetup);
|
86
|
+
}
|
87
|
+
|
88
|
+
function setFees(
|
89
|
+
Fee memory poolFee,
|
90
|
+
Fee memory stakingFee,
|
91
|
+
Fee memory performanceFee
|
92
|
+
)
|
93
|
+
external
|
94
|
+
override
|
95
|
+
{
|
96
|
+
(IRegistry.ObjectInfo memory poolInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
97
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
98
|
+
NftId poolNftId = poolInfo.nftId;
|
99
|
+
|
100
|
+
ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
101
|
+
poolSetupInfo.poolFee = poolFee;
|
102
|
+
poolSetupInfo.stakingFee = stakingFee;
|
103
|
+
poolSetupInfo.performanceFee = performanceFee;
|
104
|
+
|
105
|
+
instance.updatePoolSetup(poolNftId, poolSetupInfo, KEEP_STATE());
|
106
|
+
}
|
107
|
+
|
108
|
+
function createBundle(
|
109
|
+
address owner,
|
110
|
+
Fee memory fee,
|
111
|
+
uint256 stakingAmount,
|
112
|
+
uint256 lifetime,
|
113
|
+
bytes calldata filter
|
114
|
+
)
|
115
|
+
external
|
116
|
+
override
|
117
|
+
returns(NftId bundleNftId)
|
118
|
+
{
|
119
|
+
(IRegistry.ObjectInfo memory info, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
120
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
121
|
+
NftId poolNftId = info.nftId;
|
122
|
+
|
123
|
+
IBundle.BundleInfo memory bundleInfo = IBundle.BundleInfo(
|
124
|
+
poolNftId,
|
125
|
+
FeeLib.zeroFee(),
|
126
|
+
filter,
|
127
|
+
stakingAmount,
|
128
|
+
0,
|
129
|
+
stakingAmount,
|
130
|
+
lifetime,
|
131
|
+
zeroTimestamp(),
|
132
|
+
zeroTimestamp()
|
133
|
+
);
|
134
|
+
|
135
|
+
// register bundle with registry
|
136
|
+
bundleNftId = getRegistryService().registerBundle(
|
137
|
+
IRegistry.ObjectInfo(
|
138
|
+
zeroNftId(),
|
139
|
+
poolNftId,
|
140
|
+
BUNDLE(),
|
141
|
+
false, // intercepting property for bundles is defined on pool
|
142
|
+
address(0),
|
143
|
+
owner,
|
144
|
+
abi.encode(bundleInfo)
|
145
|
+
)
|
146
|
+
);
|
147
|
+
|
148
|
+
// create bundle info in instance
|
149
|
+
instance.createBundle(bundleNftId, bundleInfo);
|
150
|
+
|
151
|
+
// TODO add bundle to pool in instance
|
152
|
+
|
153
|
+
// TODO collect capital
|
154
|
+
// _processStakingByTreasury(
|
155
|
+
// instanceReader,
|
156
|
+
// zeroNftId(),
|
157
|
+
// poolNftId,
|
158
|
+
// bundleNftId,
|
159
|
+
// stakingAmount);
|
160
|
+
|
161
|
+
// TODO add logging
|
162
|
+
}
|
163
|
+
|
164
|
+
function setBundleFee(
|
165
|
+
NftId bundleNftId,
|
166
|
+
Fee memory fee
|
167
|
+
)
|
168
|
+
external
|
169
|
+
override
|
170
|
+
{
|
171
|
+
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
172
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
173
|
+
NftId poolNftId = info.nftId;
|
174
|
+
|
175
|
+
IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
176
|
+
require(bundleInfo.poolNftId.gtz(), "ERROR:PLS-010:BUNDLE_UNKNOWN");
|
177
|
+
require(poolNftId == bundleInfo.poolNftId, "ERROR:PLS-011:BUNDLE_POOL_MISMATCH");
|
178
|
+
|
179
|
+
bundleInfo.fee = fee;
|
180
|
+
|
181
|
+
instance.updateBundle(bundleNftId, bundleInfo, KEEP_STATE());
|
182
|
+
}
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
function _processStakingByTreasury(
|
187
|
+
InstanceReader instanceReader,
|
188
|
+
NftId productNftId,
|
189
|
+
NftId poolNftId,
|
190
|
+
NftId bundleNftId,
|
191
|
+
uint256 stakingAmount
|
192
|
+
)
|
193
|
+
internal
|
194
|
+
{
|
195
|
+
// process token transfer(s)
|
196
|
+
if(stakingAmount > 0) {
|
197
|
+
TokenHandler tokenHandler = TokenHandler(instanceReader.getTokenHandler(productNftId));
|
198
|
+
address bundleOwner = getRegistry().ownerOf(bundleNftId);
|
199
|
+
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
200
|
+
|
201
|
+
tokenHandler.transfer(
|
202
|
+
bundleOwner,
|
203
|
+
poolInfo.wallet,
|
204
|
+
stakingAmount
|
205
|
+
);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
5
|
+
import {ProxyManager} from "../../shared/ProxyManager.sol";
|
6
|
+
import {PoolService} from "./PoolService.sol";
|
7
|
+
import {Registry} from "../../registry/Registry.sol";
|
8
|
+
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
+
import {VersionLib} from "../../types/Version.sol";
|
10
|
+
|
11
|
+
contract PoolServiceManager is ProxyManager {
|
12
|
+
|
13
|
+
PoolService private _poolService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with pool service implementation
|
16
|
+
constructor(
|
17
|
+
address registryAddress
|
18
|
+
)
|
19
|
+
ProxyManager()
|
20
|
+
{
|
21
|
+
PoolService poolSrv = new PoolService();
|
22
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
23
|
+
IVersionable versionable = deploy(
|
24
|
+
address(poolSrv),
|
25
|
+
data);
|
26
|
+
|
27
|
+
_poolService = PoolService(address(versionable));
|
28
|
+
|
29
|
+
Registry registry = Registry(registryAddress);
|
30
|
+
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
31
|
+
RegistryService registryService = RegistryService(registryServiceAddress);
|
32
|
+
|
33
|
+
registryService.registerService(_poolService);
|
34
|
+
|
35
|
+
// link ownership of instance service manager ot nft owner of instance service
|
36
|
+
_linkToNftOwnable(
|
37
|
+
address(registryAddress),
|
38
|
+
address(_poolService));
|
39
|
+
|
40
|
+
// implies that after this constructor call only upgrade functionality is available
|
41
|
+
_isDeployed = true;
|
42
|
+
}
|
43
|
+
|
44
|
+
//--- view functions ----------------------------------------------------//
|
45
|
+
function getPoolService()
|
46
|
+
external
|
47
|
+
view
|
48
|
+
returns (PoolService poolService)
|
49
|
+
{
|
50
|
+
return _poolService;
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|