@etherisc/gif-next 0.0.2-fc8b370-882 → 0.0.2-fe34d97-357
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +36 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.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 +72 -4
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +46 -3
- 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/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/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +540 -401
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +640 -469
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +18 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +49 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +18 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +41 -23
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +4 -4
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +17 -48
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +18 -49
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +2 -2
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +1 -1
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +36 -88
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +36 -88
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +65 -38
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +65 -38
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -5
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -5
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +123 -1
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +145 -5
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +166 -168
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +167 -169
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +21 -21
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.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/IProductService.sol/IProductService.json +71 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +6 -6
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +97 -26
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- 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/TestPool.sol/TestPool.dbg.json +1 -1
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +72 -4
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +90 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
- 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/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- 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/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- 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/UFixedMathLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/BaseComponent.sol +7 -1
- package/contracts/components/Pool.sol +20 -3
- package/contracts/components/Product.sol +69 -5
- package/contracts/instance/IInstance.sol +3 -4
- package/contracts/instance/Instance.sol +7 -4
- package/contracts/instance/base/IInstanceBase.sol +5 -0
- package/contracts/instance/base/IKeyValueStore.sol +4 -3
- package/contracts/instance/base/InstanceBase.sol +6 -2
- package/contracts/instance/base/KeyValueStore.sol +12 -7
- package/contracts/instance/base/Lifecycle.sol +15 -10
- package/contracts/instance/base/ModuleBase.sol +18 -17
- package/contracts/instance/module/bundle/BundleModule.sol +10 -11
- package/contracts/instance/module/bundle/IBundle.sol +4 -11
- package/contracts/instance/module/compensation/CompensationModule.sol +11 -2
- package/contracts/instance/module/component/ComponentModule.sol +39 -53
- package/contracts/instance/module/component/IComponent.sol +6 -30
- package/contracts/instance/module/policy/IPolicy.sol +11 -9
- package/contracts/instance/module/policy/PolicyModule.sol +35 -19
- package/contracts/instance/module/pool/IPoolModule.sol +0 -1
- package/contracts/instance/module/pool/PoolModule.sol +12 -9
- package/contracts/instance/module/risk/IRisk.sol +19 -2
- package/contracts/instance/module/risk/RiskModule.sol +64 -2
- package/contracts/instance/module/treasury/ITreasury.sol +35 -42
- package/contracts/instance/module/treasury/TreasuryModule.sol +96 -77
- package/contracts/instance/service/ComponentOwnerService.sol +19 -34
- package/contracts/instance/service/IProductService.sol +21 -1
- package/contracts/instance/service/PoolService.sol +10 -4
- package/contracts/instance/service/ProductService.sol +120 -68
- package/contracts/registry/Registry.sol +2 -2
- package/contracts/test/TestPool.sol +4 -2
- package/contracts/test/TestProduct.sol +25 -3
- package/contracts/types/ObjectType.sol +20 -8
- package/contracts/types/RiskId.sol +43 -0
- package/package.json +1 -1
@@ -13,25 +13,14 @@ interface ITreasury {
|
|
13
13
|
// TODO add events
|
14
14
|
// TODO add errors
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
NftId
|
16
|
+
// treasury info is linked to product nft id
|
17
|
+
struct TreasuryInfo {
|
18
|
+
NftId compensationNftId;
|
19
19
|
NftId poolNftId;
|
20
20
|
IERC20Metadata token;
|
21
|
-
|
21
|
+
Fee commissionFee;
|
22
22
|
Fee policyFee;
|
23
23
|
Fee processingFee;
|
24
|
-
}
|
25
|
-
|
26
|
-
struct DistributorSetup {
|
27
|
-
NftId distributorNftId;
|
28
|
-
address wallet;
|
29
|
-
Fee commissionFee;
|
30
|
-
}
|
31
|
-
|
32
|
-
struct PoolSetup {
|
33
|
-
NftId poolNftId;
|
34
|
-
address wallet;
|
35
24
|
Fee stakingFee;
|
36
25
|
Fee performanceFee;
|
37
26
|
}
|
@@ -39,47 +28,51 @@ interface ITreasury {
|
|
39
28
|
|
40
29
|
interface ITreasuryModule is ITreasury {
|
41
30
|
|
42
|
-
function
|
31
|
+
function registerProductSetup(
|
43
32
|
NftId productNftId,
|
44
33
|
NftId distributorNftId,
|
45
34
|
NftId poolNftId,
|
46
35
|
IERC20Metadata token,
|
47
|
-
address wallet,
|
48
|
-
Fee memory policyFee,
|
49
|
-
Fee memory processingFee
|
50
|
-
) external;
|
51
|
-
|
52
|
-
function setProductFees(
|
53
|
-
NftId productNftId,
|
54
36
|
Fee memory policyFee,
|
55
|
-
Fee memory processingFee
|
56
|
-
) external;
|
57
|
-
|
58
|
-
function registerPool(
|
59
|
-
NftId poolNftId,
|
60
|
-
address wallet,
|
37
|
+
Fee memory processingFee,
|
61
38
|
Fee memory stakingFee,
|
62
39
|
Fee memory performanceFee
|
63
40
|
) external;
|
64
41
|
|
65
|
-
function
|
66
|
-
NftId
|
67
|
-
|
68
|
-
Fee memory performanceFee
|
42
|
+
function setTreasuryInfo(
|
43
|
+
NftId productNftId,
|
44
|
+
TreasuryInfo memory info
|
69
45
|
) external;
|
70
46
|
|
47
|
+
function getTreasuryInfo(
|
48
|
+
NftId productNftId
|
49
|
+
) external view returns (TreasuryInfo memory info);
|
50
|
+
|
51
|
+
// function setProductFees(
|
52
|
+
// NftId productNftId,
|
53
|
+
// Fee memory policyFee,
|
54
|
+
// Fee memory processingFee
|
55
|
+
// ) external;
|
56
|
+
|
57
|
+
// function setCompensationFees(
|
58
|
+
// NftId poolNftId,
|
59
|
+
// Fee memory distributionFee
|
60
|
+
// ) external;
|
61
|
+
|
62
|
+
// function setPoolFees(
|
63
|
+
// NftId poolNftId,
|
64
|
+
// Fee memory stakingFee,
|
65
|
+
// Fee memory performanceFee
|
66
|
+
// ) external;
|
67
|
+
|
68
|
+
function getProductNftId(
|
69
|
+
NftId componentNftId
|
70
|
+
) external view returns (NftId productNftId);
|
71
|
+
|
71
72
|
function getTokenHandler(
|
72
73
|
NftId componentNftId
|
73
74
|
) external view returns (TokenHandler tokenHandler);
|
74
75
|
|
75
|
-
function getProductSetup(
|
76
|
-
NftId productNftId
|
77
|
-
) external view returns (ProductSetup memory setup);
|
78
|
-
|
79
|
-
function getPoolSetup(
|
80
|
-
NftId poolNftId
|
81
|
-
) external view returns (PoolSetup memory setup);
|
82
|
-
|
83
76
|
function calculateFeeAmount(
|
84
77
|
uint256 amount,
|
85
78
|
Fee memory fee
|
@@ -90,7 +83,7 @@ interface ITreasuryModule is ITreasury {
|
|
90
83
|
uint256 fixedFee
|
91
84
|
) external pure returns (Fee memory fee);
|
92
85
|
|
93
|
-
function getZeroFee() external
|
86
|
+
function getZeroFee() external view returns (Fee memory fee);
|
94
87
|
|
95
88
|
function getUFixed(
|
96
89
|
uint256 a
|
@@ -4,100 +4,125 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
6
|
import {NftId} from "../../../types/NftId.sol";
|
7
|
+
import {TREASURY} from "../../../types/ObjectType.sol";
|
7
8
|
import {Fee, FeeLib} from "../../../types/Fee.sol";
|
8
9
|
import {UFixed, UFixedMathLib} from "../../../types/UFixed.sol";
|
9
10
|
import {TokenHandler} from "./TokenHandler.sol";
|
11
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
10
12
|
import {ITreasuryModule} from "./ITreasury.sol";
|
13
|
+
import {ModuleBase} from "../../base/ModuleBase.sol";
|
14
|
+
|
15
|
+
abstract contract TreasuryModule is
|
16
|
+
ModuleBase,
|
17
|
+
ITreasuryModule
|
18
|
+
{
|
19
|
+
// relation of distributor and pool nft map to product nft
|
20
|
+
mapping(NftId componentNftId => NftId productNftId) internal _productNft;
|
21
|
+
// relation of component nft to token hanlder
|
22
|
+
mapping(NftId componentNftId => TokenHandler tokenHandler) internal _tokenHandler;
|
23
|
+
Fee internal _zeroFee;
|
24
|
+
|
25
|
+
|
26
|
+
function initializeTreasuryModule(IKeyValueStore keyValueStore) internal {
|
27
|
+
_initialize(keyValueStore);
|
28
|
+
_zeroFee = FeeLib.zeroFee();
|
29
|
+
}
|
11
30
|
|
12
|
-
|
13
|
-
mapping(NftId productNftId => ProductSetup setup) private _productSetup;
|
14
|
-
mapping(NftId distributorNftId => DistributorSetup setup)
|
15
|
-
private _distributorSetup;
|
16
|
-
mapping(NftId poolNftId => PoolSetup setup) private _poolSetup;
|
17
|
-
mapping(NftId componentNftId => TokenHandler tokenHanlder) _tokenHandler;
|
18
|
-
|
19
|
-
function registerProduct(
|
31
|
+
function registerProductSetup(
|
20
32
|
NftId productNftId,
|
21
|
-
NftId
|
33
|
+
NftId compensationNftId,
|
22
34
|
NftId poolNftId,
|
23
35
|
IERC20Metadata token,
|
24
|
-
address wallet,
|
25
36
|
Fee memory policyFee,
|
26
|
-
Fee memory processingFee
|
37
|
+
Fee memory processingFee,
|
38
|
+
Fee memory stakingFee,
|
39
|
+
Fee memory performanceFee
|
27
40
|
) external override // TODO add authz (only component module)
|
28
41
|
{
|
29
42
|
require(address(_tokenHandler[productNftId]) == address(0), "ERROR:TRS-010:TOKEN_HANDLER_ALREADY_REGISTERED");
|
30
|
-
require(
|
31
|
-
require(
|
32
|
-
// TODO add additional validations
|
43
|
+
require(_productNft[compensationNftId].eqz(), "ERROR:TRS-011:COMPENSATION_ALREADY_LINKED");
|
44
|
+
require(_productNft[poolNftId].eqz(), "ERROR:TRS-012:POOL_ALREADY_LINKED");
|
33
45
|
|
34
46
|
// deploy product specific handler contract
|
35
47
|
TokenHandler tokenHandler = new TokenHandler(productNftId, address(token));
|
36
48
|
_tokenHandler[productNftId] = tokenHandler;
|
37
|
-
|
38
|
-
|
49
|
+
_productNft[compensationNftId] = productNftId;
|
50
|
+
_productNft[poolNftId] = productNftId;
|
39
51
|
|
40
|
-
|
41
|
-
|
42
|
-
productNftId,
|
43
|
-
distributorNftId,
|
52
|
+
TreasuryInfo memory info = TreasuryInfo(
|
53
|
+
compensationNftId,
|
44
54
|
poolNftId,
|
45
55
|
token,
|
46
|
-
|
56
|
+
_zeroFee,
|
47
57
|
policyFee,
|
48
|
-
processingFee
|
49
|
-
);
|
50
|
-
|
51
|
-
// TODO add logging
|
52
|
-
}
|
53
|
-
|
54
|
-
function setProductFees(
|
55
|
-
NftId productNftId,
|
56
|
-
Fee memory policyFee,
|
57
|
-
Fee memory processingFee
|
58
|
-
) external override // TODO add authz (only component owner service)
|
59
|
-
{
|
60
|
-
// TODO add validation
|
61
|
-
|
62
|
-
ProductSetup storage setup = _productSetup[productNftId];
|
63
|
-
setup.policyFee = policyFee;
|
64
|
-
setup.processingFee = processingFee;
|
65
|
-
|
66
|
-
// TODO add logging
|
67
|
-
}
|
68
|
-
|
69
|
-
function registerPool(
|
70
|
-
NftId poolNftId,
|
71
|
-
address wallet,
|
72
|
-
Fee memory stakingFee,
|
73
|
-
Fee memory performanceFee
|
74
|
-
) external override // TODO add authz (only component module)
|
75
|
-
{
|
76
|
-
// TODO add validation
|
77
|
-
|
78
|
-
_poolSetup[poolNftId] = PoolSetup(
|
79
|
-
poolNftId,
|
80
|
-
wallet,
|
58
|
+
processingFee,
|
81
59
|
stakingFee,
|
82
60
|
performanceFee
|
83
61
|
);
|
84
62
|
|
85
|
-
|
63
|
+
_create(TREASURY(), productNftId, abi.encode(info));
|
86
64
|
}
|
87
65
|
|
88
|
-
function
|
89
|
-
NftId
|
90
|
-
|
91
|
-
|
92
|
-
|
66
|
+
function setTreasuryInfo(
|
67
|
+
NftId productNftId,
|
68
|
+
TreasuryInfo memory info
|
69
|
+
)
|
70
|
+
external
|
71
|
+
// TODO add authz (only component module)
|
72
|
+
override
|
93
73
|
{
|
94
|
-
|
95
|
-
|
96
|
-
PoolSetup storage setup = _poolSetup[poolNftId];
|
97
|
-
setup.stakingFee = stakingFee;
|
98
|
-
setup.performanceFee = performanceFee;
|
74
|
+
_updateData(TREASURY(), productNftId, abi.encode(info));
|
75
|
+
}
|
99
76
|
|
100
|
-
|
77
|
+
// function setProductFees(
|
78
|
+
// NftId productNftId,
|
79
|
+
// Fee memory policyFee,
|
80
|
+
// Fee memory processingFee
|
81
|
+
// ) external override // TODO add authz (only component owner service)
|
82
|
+
// {
|
83
|
+
// TreasuryInfo memory info = getTreasuryInfo(productNftId);
|
84
|
+
// require(address(info.token) != address(0), "ERROR:TRS-020:NOT_FOUND");
|
85
|
+
|
86
|
+
// info.policyFee = policyFee;
|
87
|
+
// info.processingFee = processingFee;
|
88
|
+
|
89
|
+
// _updateData(TREASURY(), productNftId, abi.encode(info));
|
90
|
+
// }
|
91
|
+
|
92
|
+
// function setCompensationFees(
|
93
|
+
// NftId compensationNftId,
|
94
|
+
// Fee memory distributionFee
|
95
|
+
// ) external override // TODO add authz (only component owner service)
|
96
|
+
// {
|
97
|
+
// NftId productNftId = _productNft[compensationNftId];
|
98
|
+
// TreasuryInfo memory info = getTreasuryInfo(productNftId);
|
99
|
+
// require(address(info.token) != address(0), "ERROR:TRS-030:NOT_FOUND");
|
100
|
+
|
101
|
+
// info.commissionFee = distributionFee;
|
102
|
+
|
103
|
+
// _updateData(TREASURY(), productNftId, abi.encode(info));
|
104
|
+
// }
|
105
|
+
|
106
|
+
// function setPoolFees(
|
107
|
+
// NftId poolNftId,
|
108
|
+
// Fee memory stakingFee,
|
109
|
+
// Fee memory performanceFee
|
110
|
+
// ) external override // TODO add authz (only component owner service)
|
111
|
+
// {
|
112
|
+
// NftId productNftId = _productNft[poolNftId];
|
113
|
+
// TreasuryInfo memory info = getTreasuryInfo(productNftId);
|
114
|
+
// require(address(info.token) != address(0), "ERROR:TRS-040:NOT_FOUND");
|
115
|
+
|
116
|
+
// info.stakingFee = stakingFee;
|
117
|
+
// info.performanceFee = performanceFee;
|
118
|
+
|
119
|
+
// _updateData(TREASURY(), productNftId, abi.encode(info));
|
120
|
+
// }
|
121
|
+
|
122
|
+
function getProductNftId(
|
123
|
+
NftId componentNftId
|
124
|
+
) external view returns (NftId productNftId) {
|
125
|
+
return _productNft[componentNftId];
|
101
126
|
}
|
102
127
|
|
103
128
|
function getTokenHandler(
|
@@ -106,16 +131,10 @@ abstract contract TreasuryModule is ITreasuryModule {
|
|
106
131
|
return _tokenHandler[componentNftId];
|
107
132
|
}
|
108
133
|
|
109
|
-
function
|
134
|
+
function getTreasuryInfo(
|
110
135
|
NftId productNftId
|
111
|
-
)
|
112
|
-
return
|
113
|
-
}
|
114
|
-
|
115
|
-
function getPoolSetup(
|
116
|
-
NftId poolNftId
|
117
|
-
) external view override returns (PoolSetup memory setup) {
|
118
|
-
return _poolSetup[poolNftId];
|
136
|
+
) public view override returns (TreasuryInfo memory info) {
|
137
|
+
return abi.decode(_getData(TREASURY(), productNftId), (TreasuryInfo));
|
119
138
|
}
|
120
139
|
|
121
140
|
function calculateFeeAmount(
|
@@ -132,8 +151,8 @@ abstract contract TreasuryModule is ITreasuryModule {
|
|
132
151
|
return FeeLib.toFee(fractionalFee, fixedFee);
|
133
152
|
}
|
134
153
|
|
135
|
-
function getZeroFee() external
|
136
|
-
return
|
154
|
+
function getZeroFee() external view override returns (Fee memory fee) {
|
155
|
+
return _zeroFee;
|
137
156
|
}
|
138
157
|
|
139
158
|
function getUFixed(
|
@@ -11,13 +11,14 @@ import {TreasuryModule} from "../module/treasury/TreasuryModule.sol";
|
|
11
11
|
import {IComponent, IComponentModule} from "../module/component/IComponent.sol";
|
12
12
|
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
13
13
|
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
14
|
-
|
14
|
+
import {IKeyValueStore} from "../../instance/base/IKeyValueStore.sol";
|
15
15
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
16
16
|
import {Versionable} from "../../shared/Versionable.sol";
|
17
17
|
|
18
18
|
import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../types/RoleId.sol";
|
19
|
-
import {ObjectType, PRODUCT, ORACLE, POOL} from "../../types/ObjectType.sol";
|
19
|
+
import {ObjectType, COMPONENT, PRODUCT, ORACLE, POOL} from "../../types/ObjectType.sol";
|
20
20
|
import {StateId, ACTIVE, PAUSED} from "../../types/StateId.sol";
|
21
|
+
import {Key32} from "../../types/Key32.sol";
|
21
22
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
22
23
|
import {Fee} from "../../types/Fee.sol";
|
23
24
|
import {Version, VersionLib} from "../../types/Version.sol";
|
@@ -97,29 +98,28 @@ contract ComponentOwnerService is
|
|
97
98
|
|
98
99
|
instance.registerComponent(
|
99
100
|
nftId,
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
address wallet = component.getWallet();
|
101
|
+
token,
|
102
|
+
component.getWallet());
|
104
103
|
|
105
104
|
// component type specific registration actions
|
106
105
|
if (component.getType() == PRODUCT()) {
|
107
106
|
IProductComponent product = IProductComponent(address(component));
|
108
107
|
NftId poolNftId = product.getPoolNftId();
|
109
108
|
require(poolNftId.gtz(), "ERROR:CMP-005:POOL_UNKNOWN");
|
110
|
-
|
109
|
+
IPoolComponent pool = IPoolComponent(_registry.getObjectInfo(poolNftId).objectAddress);
|
111
110
|
|
112
111
|
// register with tresury
|
113
112
|
// implement and add validation
|
114
113
|
NftId distributorNftId = zeroNftId();
|
115
|
-
instance.
|
114
|
+
instance.registerProductSetup(
|
116
115
|
nftId,
|
117
116
|
distributorNftId,
|
118
117
|
poolNftId,
|
119
118
|
token,
|
120
|
-
wallet,
|
121
119
|
product.getPolicyFee(),
|
122
|
-
product.getProcessingFee()
|
120
|
+
product.getProcessingFee(),
|
121
|
+
pool.getStakingFee(),
|
122
|
+
pool.getPerformanceFee()
|
123
123
|
);
|
124
124
|
} else if (component.getType() == POOL()) {
|
125
125
|
IPoolComponent pool = IPoolComponent(address(component));
|
@@ -129,42 +129,27 @@ contract ComponentOwnerService is
|
|
129
129
|
nftId,
|
130
130
|
pool.isVerifying(),
|
131
131
|
pool.getCollateralizationLevel());
|
132
|
-
|
133
|
-
// register with tresury
|
134
|
-
instance.registerPool(
|
135
|
-
nftId,
|
136
|
-
wallet,
|
137
|
-
pool.getStakingFee(),
|
138
|
-
pool.getPerformanceFee());
|
139
132
|
}
|
140
|
-
// TODO add
|
133
|
+
// TODO add compensation
|
141
134
|
}
|
142
135
|
|
143
136
|
function lock(
|
144
137
|
IBaseComponent component
|
145
138
|
) external override onlyRegisteredComponent(component) {
|
139
|
+
// TODO use msg.sender to get component and get instance via registered parent nft id
|
146
140
|
IInstance instance = component.getInstance();
|
147
|
-
|
148
|
-
|
149
|
-
);
|
150
|
-
require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
151
|
-
|
152
|
-
info.state = PAUSED();
|
153
|
-
// setComponentInfo checks for valid state changes
|
154
|
-
instance.setComponentInfo(info);
|
141
|
+
NftId nftId = component.getNftId();
|
142
|
+
Key32 key = nftId.toKey32(COMPONENT());
|
143
|
+
instance.updateState(key, PAUSED());
|
155
144
|
}
|
156
145
|
|
157
146
|
function unlock(
|
158
147
|
IBaseComponent component
|
159
148
|
) external override onlyRegisteredComponent(component) {
|
149
|
+
// TODO use msg.sender to get component and get instance via registered parent nft id
|
160
150
|
IInstance instance = component.getInstance();
|
161
|
-
|
162
|
-
|
163
|
-
);
|
164
|
-
require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
165
|
-
|
166
|
-
info.state = ACTIVE();
|
167
|
-
// setComponentInfo checks for valid state changes
|
168
|
-
instance.setComponentInfo(info);
|
151
|
+
NftId nftId = component.getNftId();
|
152
|
+
Key32 key = nftId.toKey32(COMPONENT());
|
153
|
+
instance.updateState(key, ACTIVE());
|
169
154
|
}
|
170
155
|
}
|
@@ -1,11 +1,15 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
+
import {IRisk} from "../module/risk/IRisk.sol";
|
5
|
+
import {IService} from "../base/IService.sol";
|
6
|
+
|
4
7
|
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {RiskId} from "../../types/RiskId.sol";
|
9
|
+
import {StateId} from "../../types/StateId.sol";
|
5
10
|
import {Timestamp} from "../../types/Timestamp.sol";
|
6
11
|
import {UFixed} from "../../types/UFixed.sol";
|
7
12
|
import {Fee} from "../../types/Fee.sol";
|
8
|
-
import {IService} from "../base/IService.sol";
|
9
13
|
|
10
14
|
interface IProductService is IService {
|
11
15
|
function setFees(
|
@@ -13,8 +17,24 @@ interface IProductService is IService {
|
|
13
17
|
Fee memory processingFee
|
14
18
|
) external;
|
15
19
|
|
20
|
+
function createRisk(
|
21
|
+
RiskId riskId,
|
22
|
+
bytes memory data
|
23
|
+
) external;
|
24
|
+
|
25
|
+
function setRiskInfo(
|
26
|
+
RiskId riskId,
|
27
|
+
IRisk.RiskInfo memory data
|
28
|
+
) external;
|
29
|
+
|
30
|
+
function updateRiskState(
|
31
|
+
RiskId riskId,
|
32
|
+
StateId state
|
33
|
+
) external;
|
34
|
+
|
16
35
|
function createApplication(
|
17
36
|
address applicationOwner,
|
37
|
+
RiskId riskId,
|
18
38
|
uint256 sumInsuredAmount,
|
19
39
|
uint256 premiumAmount,
|
20
40
|
uint256 lifetime,
|
@@ -50,8 +50,13 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
50
50
|
external
|
51
51
|
override
|
52
52
|
{
|
53
|
-
(IRegistry.ObjectInfo memory
|
54
|
-
|
53
|
+
(IRegistry.ObjectInfo memory poolInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
54
|
+
|
55
|
+
NftId productNftId = instance.getProductNftId(poolInfo.nftId);
|
56
|
+
ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productNftId);
|
57
|
+
treasuryInfo.stakingFee = stakingFee;
|
58
|
+
treasuryInfo.performanceFee = performanceFee;
|
59
|
+
instance.setTreasuryInfo(productNftId, treasuryInfo);
|
55
60
|
}
|
56
61
|
|
57
62
|
function createBundle(
|
@@ -109,9 +114,10 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
109
114
|
{
|
110
115
|
// process token transfer(s)
|
111
116
|
if(stakingAmount > 0) {
|
112
|
-
|
117
|
+
NftId productNftId = instance.getProductNftId(poolNftId);
|
118
|
+
TokenHandler tokenHandler = instance.getTokenHandler(productNftId);
|
113
119
|
address bundleOwner = _registry.getOwner(bundleNftId);
|
114
|
-
address poolWallet = instance.
|
120
|
+
address poolWallet = instance.getComponentWallet(poolNftId);
|
115
121
|
|
116
122
|
tokenHandler.transfer(
|
117
123
|
bundleOwner,
|