@etherisc/gif-next 0.0.2-e4b632c-016 → 0.0.2-e510b92-393
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 +67 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +139 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +149 -15
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +101 -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/IPoolComponent.sol/IPoolComponent.json +28 -2
- 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 +181 -16
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +157 -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/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/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- 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/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +775 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
- 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 +1347 -93
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +5 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +180 -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 +177 -38
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +249 -34
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +95 -15
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +272 -0
- 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/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- 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 +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +130 -18
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +32 -16
- 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 +167 -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 +1049 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +464 -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/NftIdSet.sol/LibNftIdSet.json +26 -3
- 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/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 +57 -11
- package/contracts/components/Distribution.sol +15 -18
- package/contracts/components/IBaseComponent.sol +7 -0
- package/contracts/components/IDistributionComponent.sol +1 -0
- package/contracts/components/IPoolComponent.sol +5 -1
- package/contracts/components/Pool.sol +36 -28
- package/contracts/components/Product.sol +34 -42
- package/contracts/instance/AccessManagedSimple.sol +1 -8
- package/contracts/instance/BundleManager.sol +129 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +30 -7
- package/contracts/instance/IInstanceService.sol +3 -1
- package/contracts/instance/Instance.sol +27 -15
- package/contracts/instance/InstanceAccessManager.sol +1 -1
- package/contracts/instance/InstanceReader.sol +26 -1
- package/contracts/instance/InstanceService.sol +108 -14
- package/contracts/instance/InstanceServiceManager.sol +6 -5
- package/contracts/instance/ObjectManager.sol +95 -0
- package/contracts/instance/base/ComponentServiceBase.sol +96 -1
- package/contracts/instance/module/IBundle.sol +1 -0
- package/contracts/instance/module/ISetup.sol +3 -0
- package/contracts/instance/service/DistributionService.sol +26 -8
- package/contracts/instance/service/DistributionServiceManager.sol +7 -6
- package/contracts/instance/service/IPoolService.sol +16 -2
- package/contracts/instance/service/IProductService.sol +6 -3
- package/contracts/instance/service/PoolService.sol +287 -0
- package/contracts/instance/service/PoolServiceManager.sol +54 -0
- package/contracts/instance/service/ProductService.sol +570 -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/NftIdSet.sol +26 -24
- package/contracts/types/RoleId.sol +8 -0
- package/contracts/types/Version.sol +4 -1
- package/package.json +1 -1
@@ -1,23 +1,22 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
+
import {IBaseComponent} from "./IBaseComponent.sol";
|
5
|
+
import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
|
4
6
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
-
|
6
|
-
import {Registerable} from "../shared/Registerable.sol";
|
7
|
-
|
8
|
-
import {IRegistry} from "../registry/IRegistry.sol";
|
9
|
-
import {IInstance} from "../instance/IInstance.sol";
|
10
|
-
|
11
7
|
import {IInstance} from "../instance/IInstance.sol";
|
12
|
-
import {
|
13
|
-
import {
|
14
|
-
import {NftId} from "../types/NftId.sol";
|
8
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
9
|
+
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
15
10
|
import {ObjectType} from "../types/ObjectType.sol";
|
11
|
+
import {Registerable} from "../shared/Registerable.sol";
|
12
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
16
13
|
|
17
14
|
abstract contract BaseComponent is
|
18
15
|
Registerable,
|
19
16
|
IBaseComponent
|
20
17
|
{
|
18
|
+
using NftIdLib for NftId;
|
19
|
+
|
21
20
|
IComponentOwnerService internal _componentOwnerService;
|
22
21
|
|
23
22
|
address internal _deployer;
|
@@ -29,7 +28,6 @@ abstract contract BaseComponent is
|
|
29
28
|
constructor(
|
30
29
|
address registry,
|
31
30
|
NftId instanceNftId,
|
32
|
-
NftId productNftId,
|
33
31
|
address token,
|
34
32
|
ObjectType componentType,
|
35
33
|
bool isInterceptor,
|
@@ -49,16 +47,17 @@ abstract contract BaseComponent is
|
|
49
47
|
_componentOwnerService = _instance.getComponentOwnerService();
|
50
48
|
_wallet = address(this);
|
51
49
|
_token = IERC20Metadata(token);
|
52
|
-
_productNftId = productNftId;
|
53
50
|
|
54
51
|
_registerInterface(type(IBaseComponent).interfaceId);
|
55
52
|
}
|
56
53
|
|
57
54
|
// from component contract
|
55
|
+
// TODO consider to remove/replace with access manager contract locking
|
58
56
|
function lock() external onlyOwner override {
|
59
57
|
_componentOwnerService.lock(this);
|
60
58
|
}
|
61
59
|
|
60
|
+
// TODO consider to remove/replace with access manager contract locking
|
62
61
|
function unlock() external onlyOwner override {
|
63
62
|
_componentOwnerService.unlock(this);
|
64
63
|
}
|
@@ -72,6 +71,48 @@ abstract contract BaseComponent is
|
|
72
71
|
return _wallet;
|
73
72
|
}
|
74
73
|
|
74
|
+
/// @dev Sets the wallet address for the component.
|
75
|
+
/// if the current wallet has tokens, these will be transferred.
|
76
|
+
/// if the new wallet address is externally owned, an approval from the
|
77
|
+
/// owner of the external wallet for the component to move all tokens must exist.
|
78
|
+
function setWallet(address newWallet) external override onlyOwner {
|
79
|
+
address currentWallet = _wallet;
|
80
|
+
uint256 currentBalance = _token.balanceOf(currentWallet);
|
81
|
+
|
82
|
+
// checks
|
83
|
+
if (newWallet == currentWallet) {
|
84
|
+
revert ErrorBaseComponentWalletAddressIsSameAsCurrent(newWallet);
|
85
|
+
}
|
86
|
+
|
87
|
+
if (currentBalance > 0) {
|
88
|
+
if (currentWallet == address(this)) {
|
89
|
+
// move tokens from component smart contract to external wallet
|
90
|
+
} else {
|
91
|
+
// move tokens from external wallet to component smart contract or another external wallet
|
92
|
+
uint256 allowance = _token.allowance(currentWallet, address(this));
|
93
|
+
if (allowance < currentBalance) {
|
94
|
+
revert ErrorBaseComponentWalletAllowanceTooSmall(currentWallet, newWallet, allowance, currentBalance);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
// effects
|
100
|
+
_wallet = newWallet;
|
101
|
+
emit LogBaseComponentWalletAddressChanged(newWallet);
|
102
|
+
|
103
|
+
// interactions
|
104
|
+
if (currentBalance > 0) {
|
105
|
+
// transfer tokens from current wallet to new wallet
|
106
|
+
if (currentWallet == address(this)) {
|
107
|
+
// transferFrom requires self allowance too
|
108
|
+
_token.approve(address(this), currentBalance);
|
109
|
+
}
|
110
|
+
|
111
|
+
SafeERC20.safeTransferFrom(_token, currentWallet, newWallet, currentBalance);
|
112
|
+
emit LogBaseComponentWalletTokensTransferred(currentWallet, newWallet, currentBalance);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
75
116
|
function getToken() public view override returns (IERC20Metadata token) {
|
76
117
|
return _token;
|
77
118
|
}
|
@@ -80,6 +121,11 @@ abstract contract BaseComponent is
|
|
80
121
|
return _instance;
|
81
122
|
}
|
82
123
|
|
124
|
+
function setProductNftId(NftId productNftId) public override onlyOwner {
|
125
|
+
require(_productNftId.eq(zeroNftId()), "product nft id already set");
|
126
|
+
_productNftId = productNftId;
|
127
|
+
}
|
128
|
+
|
83
129
|
function getProductNftId() public view override returns (NftId productNftId) {
|
84
130
|
return _productNftId;
|
85
131
|
}
|
@@ -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
|
}
|
@@ -8,6 +8,11 @@ import {IInstance} from "../instance/IInstance.sol";
|
|
8
8
|
import {NftId} from "../types/NftId.sol";
|
9
9
|
|
10
10
|
interface IBaseComponent is IRegisterable {
|
11
|
+
error ErrorBaseComponentWalletAddressIsSameAsCurrent(address newWallet);
|
12
|
+
error ErrorBaseComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
|
13
|
+
|
14
|
+
event LogBaseComponentWalletAddressChanged(address newWallet);
|
15
|
+
event LogBaseComponentWalletTokensTransferred(address from, address to, uint256 amount);
|
11
16
|
|
12
17
|
function lock() external;
|
13
18
|
|
@@ -15,10 +20,12 @@ interface IBaseComponent is IRegisterable {
|
|
15
20
|
|
16
21
|
function getToken() external view returns (IERC20Metadata token);
|
17
22
|
|
23
|
+
function setWallet(address walletAddress) external;
|
18
24
|
function getWallet() external view returns (address walletAddress);
|
19
25
|
|
20
26
|
function getInstance() external view returns (IInstance instance);
|
21
27
|
|
28
|
+
function setProductNftId(NftId productNftId) external;
|
22
29
|
function getProductNftId() external view returns (NftId productNftId);
|
23
30
|
|
24
31
|
}
|
@@ -43,6 +43,10 @@ interface IPoolComponent {
|
|
43
43
|
uint256 collateralizationAmount
|
44
44
|
) external;
|
45
45
|
|
46
|
+
function lockBundle(NftId bundleNftId) external;
|
47
|
+
|
48
|
+
function unlockBundle(NftId bundleNftId) external;
|
49
|
+
|
46
50
|
/**
|
47
51
|
* @dev returns true iff the policy application data in policyData matches
|
48
52
|
* with the bundle filter criteria encoded in bundleFilter.
|
@@ -55,7 +59,7 @@ interface IPoolComponent {
|
|
55
59
|
view
|
56
60
|
returns (bool isMatching);
|
57
61
|
|
58
|
-
function
|
62
|
+
function isConfirmingApplication() external view returns (bool isConfirmingApplication);
|
59
63
|
|
60
64
|
function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
|
61
65
|
|
@@ -25,13 +25,15 @@ import {Registerable} from "../shared/Registerable.sol";
|
|
25
25
|
contract Pool is BaseComponent, IPoolComponent {
|
26
26
|
using NftIdLib for NftId;
|
27
27
|
|
28
|
-
bool internal
|
28
|
+
bool internal _isConfirmingApplication;
|
29
29
|
UFixed internal _collateralizationLevel;
|
30
30
|
|
31
31
|
Fee internal _initialPoolFee;
|
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,29 +57,29 @@ 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,
|
62
|
-
bool
|
63
|
+
bool isConfirmingApplication,
|
63
64
|
UFixed collateralizationLevel,
|
64
65
|
Fee memory poolFee,
|
65
66
|
Fee memory stakingFee,
|
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
|
+
_isConfirmingApplication = isConfirmingApplication;
|
72
73
|
// TODO add validation
|
73
74
|
_collateralizationLevel = collateralizationLevel;
|
74
75
|
_initialPoolFee = poolFee;
|
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
|
}
|
@@ -138,8 +140,8 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
138
140
|
}
|
139
141
|
|
140
142
|
|
141
|
-
function
|
142
|
-
return
|
143
|
+
function isConfirmingApplication() external view override returns (bool isConfirmingApplication) {
|
144
|
+
return _isConfirmingApplication;
|
143
145
|
}
|
144
146
|
|
145
147
|
function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
|
@@ -169,21 +171,27 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
169
171
|
_poolService.setBundleFee(bundleNftId, fee);
|
170
172
|
}
|
171
173
|
|
172
|
-
function
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
_initialPerformanceFee,
|
182
|
-
_isVerifying,
|
183
|
-
_wallet
|
184
|
-
);
|
185
|
-
}
|
174
|
+
function lockBundle(
|
175
|
+
NftId bundleNftId
|
176
|
+
)
|
177
|
+
external
|
178
|
+
override
|
179
|
+
// TODO add onlyBundleOwner
|
180
|
+
{
|
181
|
+
_poolService.lockBundle(bundleNftId);
|
182
|
+
}
|
186
183
|
|
184
|
+
function unlockBundle(
|
185
|
+
NftId bundleNftId
|
186
|
+
)
|
187
|
+
external
|
188
|
+
override
|
189
|
+
// TODO add onlyBundleOwner
|
190
|
+
{
|
191
|
+
_poolService.unlockBundle(bundleNftId);
|
192
|
+
}
|
193
|
+
|
194
|
+
function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
|
187
195
|
InstanceReader reader = _instance.getInstanceReader();
|
188
196
|
return reader.getPoolSetupInfo(getNftId());
|
189
197
|
}
|
@@ -200,20 +208,20 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
200
208
|
{
|
201
209
|
(
|
202
210
|
IRegistry.ObjectInfo memory info,
|
203
|
-
bytes memory data
|
204
211
|
) = super.getInitialInfo();
|
205
212
|
|
206
213
|
return (
|
207
214
|
info,
|
208
215
|
abi.encode(
|
209
216
|
ISetup.PoolSetupInfo(
|
210
|
-
|
211
|
-
|
217
|
+
_productNftId,
|
218
|
+
_tokenHandler,
|
212
219
|
_collateralizationLevel,
|
213
220
|
_initialPoolFee,
|
214
221
|
_initialStakingFee,
|
215
222
|
_initialPerformanceFee,
|
216
|
-
|
223
|
+
false,
|
224
|
+
_isConfirmingApplication,
|
217
225
|
_wallet
|
218
226
|
)
|
219
227
|
)
|
@@ -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,40 @@ 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
|
+
false,
|
284
|
+
_wallet
|
293
285
|
)
|
294
286
|
)
|
295
287
|
);
|
@@ -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;
|