@etherisc/gif-next 0.0.2-efdb520-159 → 0.0.2-f0d86c2-077
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/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 +2 -2
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +2 -2
- 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/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +48 -204
- 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 +211 -303
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{service → base}/ComponentServiceBase.sol/ComponentServiceBase.json +6 -6
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{IServiceLinked.sol/IServiceLinked.json → base/IInstanceBase.sol/IInstanceBase.json} +15 -2
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +511 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/{module/lifecycle/ILifecycle.sol/ILifecycleModule.json → base/ILifecycle.sol/ILifecycle.json} +10 -77
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/instance/{service → base}/IService.sol/IService.json +6 -6
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol}/InstanceBase.json +19 -6
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +692 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{module/product/ProductModule.sol/ProductModule.json → base/ModuleBase.sol/ModuleBase.json} +2 -2
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{service → base}/ServiceBase.sol/ServiceBase.json +6 -6
- 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 +50 -30
- 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 +50 -30
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +10 -0
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +4 -0
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.json +10 -0
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.json +10 -0
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
- 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/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/PolicyModule.sol/PolicyModule.dbg.json +1 -1
- 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/PoolModule.sol/PoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{product/IProductModule.sol/IProductModule.json → risk/IRisk.sol/IRisk.json} +2 -2
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +10 -0
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +10 -0
- 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 +1 -6
- 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 +1 -6
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +48 -44
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +5 -5
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +5 -5
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +5 -5
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +18 -46
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +47 -59
- 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/IVersionable.sol/IVersionable.json +5 -5
- 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/shared/Versionable.sol/Versionable.json +5 -5
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +28 -4
- package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +2 -2
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +2 -2
- 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/TestRoleId.sol/TestRoleId.json +38 -4
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +15 -43
- 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 +14 -18
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +15 -39
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.json +338 -0
- 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 +4 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +218 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
- 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/RoleId.sol/RoleIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
- 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/UFixedMathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +34 -8
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +63 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
- package/contracts/components/BaseComponent.sol +0 -1
- package/contracts/instance/IInstance.sol +13 -11
- package/contracts/instance/Instance.sol +13 -7
- package/contracts/instance/{service → base}/ComponentServiceBase.sol +1 -0
- package/contracts/instance/base/IInstanceBase.sol +14 -0
- package/contracts/instance/base/IKeyValueStore.sol +49 -0
- package/contracts/instance/base/ILifecycle.sol +30 -0
- package/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol} +21 -15
- package/contracts/instance/base/KeyValueStore.sol +156 -0
- package/contracts/instance/{module/lifecycle/LifecycleModule.sol → base/Lifecycle.sol} +36 -30
- package/contracts/instance/base/ModuleBase.sol +52 -0
- package/contracts/instance/{service → base}/ServiceBase.sol +1 -3
- package/contracts/instance/module/access/Access.sol +3 -3
- package/contracts/instance/module/bundle/BundleModule.sol +24 -116
- package/contracts/instance/module/bundle/IBundle.sol +8 -3
- package/contracts/instance/module/compensation/CompensationModule.sol +8 -0
- package/contracts/instance/module/compensation/ICompensation.sol +10 -0
- package/contracts/instance/module/component/ComponentModule.sol +10 -19
- package/contracts/instance/module/policy/PolicyModule.sol +2 -10
- package/contracts/instance/module/{product/IProductModule.sol → risk/IRisk.sol} +6 -2
- package/contracts/instance/module/risk/RiskModule.sol +8 -0
- package/contracts/instance/module/treasury/ITreasury.sol +2 -3
- package/contracts/instance/module/treasury/TreasuryModule.sol +15 -11
- package/contracts/instance/service/ComponentOwnerService.sol +4 -8
- package/contracts/instance/service/IComponentOwnerService.sol +1 -1
- package/contracts/instance/service/IPoolService.sol +1 -1
- package/contracts/instance/service/IProductService.sol +1 -1
- package/contracts/instance/service/PoolService.sol +36 -11
- package/contracts/instance/service/ProductService.sol +6 -10
- package/contracts/registry/Registry.sol +1 -1
- package/contracts/shared/IVersionable.sol +2 -2
- package/contracts/shared/Versionable.sol +3 -6
- package/contracts/test/TestFee.sol +3 -3
- package/contracts/test/TestPool.sol +1 -1
- package/contracts/test/TestProduct.sol +1 -1
- package/contracts/test/TestRoleId.sol +2 -2
- package/contracts/test/TestService.sol +3 -6
- package/contracts/test/TestVersion.sol +4 -7
- package/contracts/test/TestVersionable.sol +2 -5
- package/contracts/test/Usdc.sol +26 -0
- package/contracts/types/Fee.sol +39 -20
- package/contracts/types/Key32.sol +45 -0
- package/contracts/types/NftId.sol +16 -1
- package/contracts/types/RoleId.sol +11 -9
- package/contracts/types/StateId.sol +7 -1
- package/contracts/types/UFixed.sol +19 -16
- package/contracts/types/Version.sol +29 -25
- package/package.json +1 -1
- package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.dbg.json +0 -4
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.json +0 -134
- package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.json +0 -221
- package/artifacts/contracts/instance/module/product/IProductModule.sol/IProductModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/product/ProductModule.sol/ProductModule.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/contracts/instance/IServiceLinked.sol +0 -12
- package/contracts/instance/module/lifecycle/ILifecycle.sol +0 -47
- package/contracts/instance/module/product/ProductModule.sol +0 -8
- /package/contracts/instance/{service → base}/IService.sol +0 -0
@@ -3,32 +3,32 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {IRegistry} from "../../../registry/IRegistry.sol";
|
5
5
|
|
6
|
-
import {LifecycleModule} from "../lifecycle/LifecycleModule.sol";
|
7
6
|
import {IProductService} from "../../service/IProductService.sol";
|
8
7
|
import {IPoolService} from "../../service/IPoolService.sol";
|
9
8
|
|
10
9
|
import {NftId} from "../../../types/NftId.sol";
|
10
|
+
import {Key32, KeyId} from "../../../types/Key32.sol";
|
11
11
|
import {LibNftIdSet} from "../../../types/NftIdSet.sol";
|
12
12
|
import {ObjectType, PRODUCT, ORACLE, POOL, BUNDLE, POLICY} from "../../../types/ObjectType.sol";
|
13
13
|
import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, REVOKED, DECLINED} from "../../../types/StateId.sol";
|
14
14
|
import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
|
15
15
|
import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
|
16
16
|
|
17
|
-
import {
|
17
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
18
|
+
import {ModuleBase} from "../../base/ModuleBase.sol";
|
19
|
+
|
18
20
|
import {IBundleModule} from "./IBundle.sol";
|
19
21
|
|
20
|
-
abstract contract BundleModule is
|
22
|
+
abstract contract BundleModule is
|
23
|
+
ModuleBase,
|
21
24
|
IBundleModule
|
22
25
|
{
|
23
26
|
|
24
27
|
using LibNftIdSet for LibNftIdSet.Set;
|
25
28
|
|
26
|
-
mapping(NftId bundleNftId => BundleInfo info) private _bundleInfo;
|
27
29
|
mapping(NftId bundleNftId => LibNftIdSet.Set policies) private _collateralizedPolicies;
|
28
30
|
mapping(NftId bundleNftId => mapping(NftId policyNftId => uint256 amount)) private _collateralizationAmount;
|
29
31
|
|
30
|
-
LifecycleModule private _lifecycleModule;
|
31
|
-
|
32
32
|
modifier onlyBundlePoolService() {
|
33
33
|
require(
|
34
34
|
msg.sender == address(this.getPoolService()),
|
@@ -54,8 +54,8 @@ abstract contract BundleModule is
|
|
54
54
|
_;
|
55
55
|
}
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
function initializeBundleModule(IKeyValueStore keyValueStore) internal {
|
58
|
+
_initialize(keyValueStore, BUNDLE());
|
59
59
|
}
|
60
60
|
|
61
61
|
function createBundleInfo(
|
@@ -69,22 +69,18 @@ abstract contract BundleModule is
|
|
69
69
|
onlyBundlePoolService
|
70
70
|
override
|
71
71
|
{
|
72
|
-
|
73
|
-
_bundleInfo[bundleNftId] = BundleInfo(
|
72
|
+
BundleInfo memory bundleInfo = BundleInfo(
|
74
73
|
bundleNftId,
|
75
74
|
poolNftId,
|
76
|
-
_lifecycleModule.getInitialState(BUNDLE()),
|
77
75
|
filter,
|
78
76
|
amount, // capital
|
79
77
|
0, // locked capital
|
80
78
|
amount, // balance
|
81
|
-
blockTimestamp(), // createdAt
|
82
79
|
blockTimestamp().addSeconds(lifetime), // expiredAt
|
83
|
-
zeroTimestamp()
|
84
|
-
blockNumber() // updatedIn
|
80
|
+
zeroTimestamp() // closedAt
|
85
81
|
);
|
86
82
|
|
87
|
-
|
83
|
+
_create(bundleNftId, abi.encode(bundleInfo));
|
88
84
|
}
|
89
85
|
|
90
86
|
function setBundleInfo(BundleInfo memory bundleInfo)
|
@@ -92,78 +88,16 @@ abstract contract BundleModule is
|
|
92
88
|
override
|
93
89
|
onlyPoolOrProductService
|
94
90
|
{
|
95
|
-
|
91
|
+
_updateData(bundleInfo.nftId, abi.encode(bundleInfo));
|
96
92
|
}
|
97
93
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
// {
|
106
|
-
// BundleInfo storage info = _bundleInfo[bundleNftId];
|
107
|
-
// info.state = newState;
|
108
|
-
// info.updatedIn = blockNumber();
|
109
|
-
// }
|
110
|
-
|
111
|
-
// function extendBundle(
|
112
|
-
// NftId bundleNftId,
|
113
|
-
// uint256 lifetimeExtension
|
114
|
-
// )
|
115
|
-
// external
|
116
|
-
// onlyBundlePoolService
|
117
|
-
// override
|
118
|
-
// {
|
119
|
-
// BundleInfo storage info = _bundleInfo[bundleNftId];
|
120
|
-
// info.expiredAt = info.expiredAt.addSeconds(lifetimeExtension);
|
121
|
-
// info.updatedIn = blockNumber();
|
122
|
-
// }
|
123
|
-
|
124
|
-
// function closeBundle(
|
125
|
-
// NftId bundleNftId
|
126
|
-
// )
|
127
|
-
// external
|
128
|
-
// onlyBundlePoolService
|
129
|
-
// override
|
130
|
-
// {
|
131
|
-
// BundleInfo storage info = _bundleInfo[bundleNftId];
|
132
|
-
// info.state = CLOSED();
|
133
|
-
// info.closedAt = blockTimestamp();
|
134
|
-
// info.updatedIn = blockNumber();
|
135
|
-
// }
|
136
|
-
|
137
|
-
// function processStake(
|
138
|
-
// NftId nftId,
|
139
|
-
// uint256 amount
|
140
|
-
// )
|
141
|
-
// external
|
142
|
-
// onlyBundlePoolService
|
143
|
-
// override
|
144
|
-
// {
|
145
|
-
// BundleInfo storage info = _bundleInfo[nftId];
|
146
|
-
// info.capitalAmount += amount;
|
147
|
-
// info.balanceAmount += amount;
|
148
|
-
// info.updatedIn = blockNumber();
|
149
|
-
// }
|
150
|
-
|
151
|
-
// function processUnstake(
|
152
|
-
// NftId nftId,
|
153
|
-
// uint256 amount
|
154
|
-
// )
|
155
|
-
// external
|
156
|
-
// onlyBundlePoolService
|
157
|
-
// override
|
158
|
-
// {
|
159
|
-
// BundleInfo storage info = _bundleInfo[nftId];
|
160
|
-
// // TODO fix book keeping in a way that provides
|
161
|
-
// // continuous infor regarding profitability
|
162
|
-
// // this is needed to properly apply performance fees
|
163
|
-
// info.capitalAmount -= amount;
|
164
|
-
// info.balanceAmount -= amount;
|
165
|
-
// info.updatedIn = blockNumber();
|
166
|
-
// }
|
94
|
+
function updateBundleState(NftId bundleNftId, StateId state)
|
95
|
+
external
|
96
|
+
override
|
97
|
+
onlyBundlePoolService
|
98
|
+
{
|
99
|
+
_updateState(bundleNftId, state);
|
100
|
+
}
|
167
101
|
|
168
102
|
function collateralizePolicy(
|
169
103
|
NftId bundleNftId,
|
@@ -187,42 +121,16 @@ abstract contract BundleModule is
|
|
187
121
|
override
|
188
122
|
returns(uint256 collateralAmount)
|
189
123
|
{
|
190
|
-
// BundleInfo storage info = _bundleInfo[bundleNftId];
|
191
|
-
// info.lockedAmount -= collateralAmount;
|
192
|
-
// info.updatedIn = blockNumber();
|
193
|
-
|
194
124
|
collateralAmount = _collateralizationAmount[bundleNftId][policyNftId];
|
195
125
|
delete _collateralizationAmount[bundleNftId][policyNftId];
|
196
126
|
_collateralizedPolicies[bundleNftId].remove(policyNftId);
|
197
127
|
}
|
198
128
|
|
199
|
-
// function addPremium(NftId bundleNftId, uint256 amount)
|
200
|
-
// external
|
201
|
-
// onlyBundleProductService
|
202
|
-
// override
|
203
|
-
// {
|
204
|
-
// BundleInfo storage info = _bundleInfo[bundleNftId];
|
205
|
-
// info.capitalAmount += amount;
|
206
|
-
// info.balanceAmount += amount;
|
207
|
-
// info.updatedIn = blockNumber();
|
208
|
-
// }
|
209
|
-
|
210
|
-
// function subtractPayout(NftId bundleNftId, NftId policyNftId, uint256 amount)
|
211
|
-
// external
|
212
|
-
// onlyBundleProductService
|
213
|
-
// override
|
214
|
-
// {
|
215
|
-
// BundleInfo storage info = _bundleInfo[bundleNftId];
|
216
|
-
// info.capitalAmount -= amount;
|
217
|
-
// info.lockedAmount -= amount;
|
218
|
-
// info.balanceAmount -= amount;
|
219
|
-
// info.updatedIn = blockNumber();
|
220
|
-
|
221
|
-
// // deduct amount from sum insured for this policy
|
222
|
-
// _collateralizationAmount[bundleNftId][policyNftId] -= amount;
|
223
|
-
// }
|
224
|
-
|
225
129
|
function getBundleInfo(NftId bundleNftId) external view override returns(BundleInfo memory bundleInfo) {
|
226
|
-
return
|
130
|
+
return abi.decode(_getData(bundleNftId), (BundleInfo));
|
227
131
|
}
|
132
|
+
|
133
|
+
function toBundleKey32(NftId bundleNftId) external view override returns (Key32 key32) {
|
134
|
+
return _toKey32(bundleNftId);
|
135
|
+
}
|
228
136
|
}
|
@@ -3,11 +3,13 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {IRegistry} from "../../../registry/IRegistry.sol";
|
5
5
|
import {IInstance} from "../../IInstance.sol";
|
6
|
+
import {Key32} from "../../../types/Key32.sol";
|
6
7
|
import {NftId} from "../../../types/NftId.sol";
|
7
8
|
import {StateId} from "../../../types/StateId.sol";
|
8
9
|
import {Timestamp} from "../../../types/Timestamp.sol";
|
9
10
|
import {Blocknumber} from "../../../types/Blocknumber.sol";
|
10
11
|
|
12
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
11
13
|
import {IProductService} from "../../service/IProductService.sol";
|
12
14
|
import {IPoolService} from "../../service/IPoolService.sol";
|
13
15
|
|
@@ -16,15 +18,12 @@ interface IBundle {
|
|
16
18
|
struct BundleInfo {
|
17
19
|
NftId nftId;
|
18
20
|
NftId poolNftId;
|
19
|
-
StateId state; // active, paused, closed (expriy only implicit)
|
20
21
|
bytes filter; // required conditions for applications to be considered for collateralization by this bundle
|
21
22
|
uint256 capitalAmount; // net investment capital amount (<= balance)
|
22
23
|
uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
|
23
24
|
uint256 balanceAmount; // total amount of funds: net investment capital + net premiums - payouts
|
24
|
-
Timestamp createdAt;
|
25
25
|
Timestamp expiredAt; // no new policies
|
26
26
|
Timestamp closedAt;
|
27
|
-
Blocknumber updatedIn;
|
28
27
|
}
|
29
28
|
}
|
30
29
|
|
@@ -39,14 +38,20 @@ interface IBundleModule is IBundle {
|
|
39
38
|
) external;
|
40
39
|
|
41
40
|
function setBundleInfo(BundleInfo memory bundleInfo) external;
|
41
|
+
function updateBundleState(NftId bundleNftId, StateId state) external;
|
42
|
+
|
42
43
|
function collateralizePolicy(NftId bundleNftId, NftId policyNftId, uint256 amount) external;
|
43
44
|
function releasePolicy(NftId bundleNftId, NftId policyNftId) external returns(uint256 collateralAmount);
|
44
45
|
|
45
46
|
function getBundleInfo(NftId bundleNftId) external view returns(BundleInfo memory bundleInfo);
|
47
|
+
function toBundleKey32(NftId bundleNftId) external view returns (Key32 key32);
|
46
48
|
|
47
49
|
// repeat registry linked signature
|
48
50
|
function getRegistry() external view returns (IRegistry registry);
|
49
51
|
|
52
|
+
// repeat instance base signature
|
53
|
+
function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
|
54
|
+
|
50
55
|
// repeat service linked signatures to avoid linearization issues
|
51
56
|
function getProductService() external returns(IProductService);
|
52
57
|
function getPoolService() external returns(IPoolService);
|
@@ -6,14 +6,12 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
|
|
6
6
|
import {IRegistry} from "../../../registry/IRegistry.sol";
|
7
7
|
import {IInstance} from "../../IInstance.sol";
|
8
8
|
|
9
|
-
import {LifecycleModule} from "../lifecycle/LifecycleModule.sol";
|
10
9
|
import {IComponent, IComponentModule} from "./IComponent.sol";
|
11
10
|
import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
|
12
11
|
import {ObjectType, PRODUCT, ORACLE, POOL} from "../../../types/ObjectType.sol";
|
13
12
|
import {StateId, ACTIVE, PAUSED} from "../../../types/StateId.sol";
|
14
13
|
import {NftId, NftIdLib, zeroNftId} from "../../../types/NftId.sol";
|
15
|
-
import {Fee
|
16
|
-
// import {IBaseComponent} from "../../../components/IBaseComponent.sol";
|
14
|
+
import {Fee} from "../../../types/Fee.sol";
|
17
15
|
|
18
16
|
abstract contract ComponentModule is
|
19
17
|
IComponentModule
|
@@ -25,9 +23,6 @@ abstract contract ComponentModule is
|
|
25
23
|
|
26
24
|
mapping(ObjectType cType => bytes32 role) private _componentOwnerRole;
|
27
25
|
|
28
|
-
// TODO maybe move this to Instance contract as internal variable?
|
29
|
-
LifecycleModule private _lifecycleModule;
|
30
|
-
|
31
26
|
modifier onlyComponentOwnerService() {
|
32
27
|
require(
|
33
28
|
msg.sender == address(this.getComponentOwnerService()),
|
@@ -36,11 +31,6 @@ abstract contract ComponentModule is
|
|
36
31
|
_;
|
37
32
|
}
|
38
33
|
|
39
|
-
constructor() {
|
40
|
-
address componentAddress = address(this);
|
41
|
-
_lifecycleModule = LifecycleModule(componentAddress);
|
42
|
-
}
|
43
|
-
|
44
34
|
function registerComponent(
|
45
35
|
NftId nftId,
|
46
36
|
ObjectType objectType,
|
@@ -50,7 +40,8 @@ abstract contract ComponentModule is
|
|
50
40
|
// create component info
|
51
41
|
_componentInfo[nftId] = ComponentInfo(
|
52
42
|
nftId,
|
53
|
-
_lifecycleModule.getInitialState(objectType),
|
43
|
+
// _lifecycleModule.getInitialState(objectType),
|
44
|
+
ACTIVE(),
|
54
45
|
token
|
55
46
|
);
|
56
47
|
|
@@ -71,13 +62,13 @@ abstract contract ComponentModule is
|
|
71
62
|
// TODO decide if state changes should have explicit functions and not
|
72
63
|
// just a generic setXYZInfo and implicit state transitions
|
73
64
|
// when in doubt go for the explicit approach ...
|
74
|
-
ObjectType objectType = this.getRegistry().getObjectInfo(nftId).objectType;
|
75
|
-
_lifecycleModule.checkAndLogTransition(
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
);
|
65
|
+
// ObjectType objectType = this.getRegistry().getObjectInfo(nftId).objectType;
|
66
|
+
// _lifecycleModule.checkAndLogTransition(
|
67
|
+
// nftId,
|
68
|
+
// objectType,
|
69
|
+
// _componentInfo[nftId].state,
|
70
|
+
// info.state
|
71
|
+
// );
|
81
72
|
_componentInfo[nftId] = info;
|
82
73
|
}
|
83
74
|
|
@@ -3,7 +3,6 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {IRegistry} from "../../../registry/IRegistry.sol";
|
5
5
|
|
6
|
-
import {LifecycleModule} from "../../module/lifecycle/LifecycleModule.sol";
|
7
6
|
import {IProductService} from "../../service/IProductService.sol";
|
8
7
|
import {IPolicy, IPolicyModule} from "./IPolicy.sol";
|
9
8
|
import {ObjectType, POLICY} from "../../../types/ObjectType.sol";
|
@@ -12,15 +11,11 @@ import {NftId, NftIdLib} from "../../../types/NftId.sol";
|
|
12
11
|
import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
|
13
12
|
import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
|
14
13
|
|
15
|
-
import {LifecycleModule} from "../../module/lifecycle/LifecycleModule.sol";
|
16
|
-
|
17
14
|
abstract contract PolicyModule is IPolicyModule {
|
18
15
|
using NftIdLib for NftId;
|
19
16
|
|
20
17
|
mapping(NftId nftId => PolicyInfo info) private _policyInfo;
|
21
18
|
|
22
|
-
LifecycleModule private _lifecycleModule;
|
23
|
-
|
24
19
|
// TODO find a better place to avoid dupliation
|
25
20
|
modifier onlyProductService2() {
|
26
21
|
require(
|
@@ -30,10 +25,6 @@ abstract contract PolicyModule is IPolicyModule {
|
|
30
25
|
_;
|
31
26
|
}
|
32
27
|
|
33
|
-
constructor() {
|
34
|
-
_lifecycleModule = LifecycleModule(address(this));
|
35
|
-
}
|
36
|
-
|
37
28
|
function createApplication(
|
38
29
|
NftId productNftId,
|
39
30
|
NftId policyNftId,
|
@@ -51,7 +42,8 @@ abstract contract PolicyModule is IPolicyModule {
|
|
51
42
|
productNftId,
|
52
43
|
bundleNftId,
|
53
44
|
address(0), // beneficiary = policy nft holder
|
54
|
-
_lifecycleModule.getInitialState(POLICY()),
|
45
|
+
// _lifecycleModule.getInitialState(POLICY()),
|
46
|
+
APPLIED(),
|
55
47
|
sumInsuredAmount,
|
56
48
|
premiumAmount,
|
57
49
|
0, // premium paid amount
|
@@ -18,7 +18,6 @@ interface ITreasury {
|
|
18
18
|
NftId distributorNftId;
|
19
19
|
NftId poolNftId;
|
20
20
|
IERC20Metadata token;
|
21
|
-
TokenHandler tokenHandler;
|
22
21
|
address wallet;
|
23
22
|
Fee policyFee;
|
24
23
|
Fee processingFee;
|
@@ -27,7 +26,7 @@ interface ITreasury {
|
|
27
26
|
struct DistributorSetup {
|
28
27
|
NftId distributorNftId;
|
29
28
|
address wallet;
|
30
|
-
Fee
|
29
|
+
Fee commissionFee;
|
31
30
|
}
|
32
31
|
|
33
32
|
struct PoolSetup {
|
@@ -70,7 +69,7 @@ interface ITreasuryModule is ITreasury {
|
|
70
69
|
) external;
|
71
70
|
|
72
71
|
function getTokenHandler(
|
73
|
-
NftId
|
72
|
+
NftId componentNftId
|
74
73
|
) external view returns (TokenHandler tokenHandler);
|
75
74
|
|
76
75
|
function getProductSetup(
|
@@ -4,7 +4,7 @@ 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 {Fee,
|
7
|
+
import {Fee, FeeLib} from "../../../types/Fee.sol";
|
8
8
|
import {UFixed, UFixedMathLib} from "../../../types/UFixed.sol";
|
9
9
|
import {TokenHandler} from "./TokenHandler.sol";
|
10
10
|
import {ITreasuryModule} from "./ITreasury.sol";
|
@@ -14,6 +14,7 @@ abstract contract TreasuryModule is ITreasuryModule {
|
|
14
14
|
mapping(NftId distributorNftId => DistributorSetup setup)
|
15
15
|
private _distributorSetup;
|
16
16
|
mapping(NftId poolNftId => PoolSetup setup) private _poolSetup;
|
17
|
+
mapping(NftId componentNftId => TokenHandler tokenHanlder) _tokenHandler;
|
17
18
|
|
18
19
|
function registerProduct(
|
19
20
|
NftId productNftId,
|
@@ -25,17 +26,23 @@ abstract contract TreasuryModule is ITreasuryModule {
|
|
25
26
|
Fee memory processingFee
|
26
27
|
) external override // TODO add authz (only component module)
|
27
28
|
{
|
28
|
-
|
29
|
+
require(address(_tokenHandler[productNftId]) == address(0), "ERROR:TRS-010:TOKEN_HANDLER_ALREADY_REGISTERED");
|
30
|
+
require(address(_tokenHandler[poolNftId]) == address(0), "ERROR:TRS-011:TOKEN_HANDLER_ALREADY_REGISTERED");
|
31
|
+
require(address(_tokenHandler[distributorNftId]) == address(0), "ERROR:TRS-012:TOKEN_HANDLER_ALREADY_REGISTERED");
|
32
|
+
// TODO add additional validations
|
29
33
|
|
30
34
|
// deploy product specific handler contract
|
31
35
|
TokenHandler tokenHandler = new TokenHandler(productNftId, address(token));
|
36
|
+
_tokenHandler[productNftId] = tokenHandler;
|
37
|
+
_tokenHandler[poolNftId] = tokenHandler;
|
38
|
+
_tokenHandler[distributorNftId] = tokenHandler;
|
32
39
|
|
40
|
+
// create product setup
|
33
41
|
_productSetup[productNftId] = ProductSetup(
|
34
42
|
productNftId,
|
35
43
|
distributorNftId,
|
36
44
|
poolNftId,
|
37
45
|
token,
|
38
|
-
tokenHandler,
|
39
46
|
wallet,
|
40
47
|
policyFee,
|
41
48
|
processingFee
|
@@ -94,9 +101,9 @@ abstract contract TreasuryModule is ITreasuryModule {
|
|
94
101
|
}
|
95
102
|
|
96
103
|
function getTokenHandler(
|
97
|
-
NftId
|
104
|
+
NftId componentNftId
|
98
105
|
) external view override returns (TokenHandler tokenHandler) {
|
99
|
-
return
|
106
|
+
return _tokenHandler[componentNftId];
|
100
107
|
}
|
101
108
|
|
102
109
|
function getProductSetup(
|
@@ -115,21 +122,18 @@ abstract contract TreasuryModule is ITreasuryModule {
|
|
115
122
|
uint256 amount,
|
116
123
|
Fee memory fee
|
117
124
|
) public pure override returns (uint256 feeAmount, uint256 netAmount) {
|
118
|
-
|
119
|
-
fee.fractionalFee;
|
120
|
-
feeAmount = fractionalAmount.toInt() + fee.fixedFee;
|
121
|
-
netAmount = amount - feeAmount;
|
125
|
+
return FeeLib.calculateFee(amount, fee);
|
122
126
|
}
|
123
127
|
|
124
128
|
function getFee(
|
125
129
|
UFixed fractionalFee,
|
126
130
|
uint256 fixedFee
|
127
131
|
) external pure override returns (Fee memory fee) {
|
128
|
-
return toFee(fractionalFee, fixedFee);
|
132
|
+
return FeeLib.toFee(fractionalFee, fixedFee);
|
129
133
|
}
|
130
134
|
|
131
135
|
function getZeroFee() external pure override returns (Fee memory fee) {
|
132
|
-
return zeroFee();
|
136
|
+
return FeeLib.zeroFee();
|
133
137
|
}
|
134
138
|
|
135
139
|
function getUFixed(
|
@@ -6,7 +6,6 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
|
|
6
6
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
7
7
|
import {IInstance} from "../IInstance.sol";
|
8
8
|
|
9
|
-
import {LifecycleModule} from "../module/lifecycle/LifecycleModule.sol";
|
10
9
|
import {ITreasuryModule} from "../module/treasury/ITreasury.sol";
|
11
10
|
import {TreasuryModule} from "../module/treasury/TreasuryModule.sol";
|
12
11
|
import {IComponent, IComponentModule} from "../module/component/IComponent.sol";
|
@@ -20,11 +19,11 @@ import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "..
|
|
20
19
|
import {ObjectType, PRODUCT, ORACLE, POOL} from "../../types/ObjectType.sol";
|
21
20
|
import {StateId, ACTIVE, PAUSED} from "../../types/StateId.sol";
|
22
21
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
23
|
-
import {Fee
|
24
|
-
import {Version,
|
22
|
+
import {Fee} from "../../types/Fee.sol";
|
23
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
25
24
|
|
26
25
|
import {IProductComponent} from "../../components/IProductComponent.sol";
|
27
|
-
import {ServiceBase} from "
|
26
|
+
import {ServiceBase} from "../base/ServiceBase.sol";
|
28
27
|
import {IComponentOwnerService} from "./IComponentOwnerService.sol";
|
29
28
|
|
30
29
|
contract ComponentOwnerService is
|
@@ -55,10 +54,7 @@ contract ComponentOwnerService is
|
|
55
54
|
virtual override (IVersionable, Versionable)
|
56
55
|
returns(Version)
|
57
56
|
{
|
58
|
-
return toVersion(
|
59
|
-
toVersionPart(3),
|
60
|
-
toVersionPart(0),
|
61
|
-
toVersionPart(0));
|
57
|
+
return VersionLib.toVersion(3,0,0);
|
62
58
|
}
|
63
59
|
|
64
60
|
function getName() external pure override returns(string memory name) {
|
@@ -5,7 +5,7 @@ import {NftId} from "../../types/NftId.sol";
|
|
5
5
|
import {ObjectType} from "../../types/ObjectType.sol";
|
6
6
|
import {RoleId} from "../../types/RoleId.sol";
|
7
7
|
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
8
|
-
import {IService} from "
|
8
|
+
import {IService} from "../base/IService.sol";
|
9
9
|
|
10
10
|
// TODO rename to registry service
|
11
11
|
interface IComponentOwnerService is IService {
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../types/NftId.sol";
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {IService} from "
|
6
|
+
import {IService} from "../base/IService.sol";
|
7
7
|
|
8
8
|
interface IPoolService is IService {
|
9
9
|
function setFees(
|
@@ -5,7 +5,7 @@ import {NftId} from "../../types/NftId.sol";
|
|
5
5
|
import {Timestamp} from "../../types/Timestamp.sol";
|
6
6
|
import {UFixed} from "../../types/UFixed.sol";
|
7
7
|
import {Fee} from "../../types/Fee.sol";
|
8
|
-
import {IService} from "
|
8
|
+
import {IService} from "../base/IService.sol";
|
9
9
|
|
10
10
|
interface IProductService is IService {
|
11
11
|
function setFees(
|
@@ -10,10 +10,10 @@ import {Versionable} from "../../shared/Versionable.sol";
|
|
10
10
|
|
11
11
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
12
12
|
import {POOL, BUNDLE} from "../../types/ObjectType.sol";
|
13
|
-
import {Fee
|
14
|
-
import {Version,
|
13
|
+
import {Fee} from "../../types/Fee.sol";
|
14
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
15
15
|
|
16
|
-
import {ComponentServiceBase} from "
|
16
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
17
17
|
import {IPoolService} from "./IPoolService.sol";
|
18
18
|
|
19
19
|
|
@@ -36,10 +36,7 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
36
36
|
virtual override (IVersionable, Versionable)
|
37
37
|
returns(Version)
|
38
38
|
{
|
39
|
-
return toVersion(
|
40
|
-
toVersionPart(3),
|
41
|
-
toVersionPart(0),
|
42
|
-
toVersionPart(0));
|
39
|
+
return VersionLib.toVersion(3,0,0);
|
43
40
|
}
|
44
41
|
|
45
42
|
function getName() external pure override returns(string memory name) {
|
@@ -59,7 +56,7 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
59
56
|
|
60
57
|
function createBundle(
|
61
58
|
address owner,
|
62
|
-
uint256
|
59
|
+
uint256 stakingAmount,
|
63
60
|
uint256 lifetime,
|
64
61
|
bytes calldata filter
|
65
62
|
)
|
@@ -81,7 +78,7 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
81
78
|
instance.createBundleInfo(
|
82
79
|
bundleNftId,
|
83
80
|
poolNftId,
|
84
|
-
|
81
|
+
stakingAmount,
|
85
82
|
lifetime,
|
86
83
|
filter);
|
87
84
|
|
@@ -89,10 +86,38 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
89
86
|
instance.addBundleToPool(
|
90
87
|
bundleNftId,
|
91
88
|
poolNftId,
|
92
|
-
|
89
|
+
stakingAmount);
|
93
90
|
|
94
|
-
//
|
91
|
+
// collect capital
|
92
|
+
_processStakingByTreasury(
|
93
|
+
instance,
|
94
|
+
poolNftId,
|
95
|
+
bundleNftId,
|
96
|
+
stakingAmount);
|
95
97
|
|
96
98
|
// TODO add logging
|
97
99
|
}
|
100
|
+
|
101
|
+
|
102
|
+
function _processStakingByTreasury(
|
103
|
+
IInstance instance,
|
104
|
+
NftId poolNftId,
|
105
|
+
NftId bundleNftId,
|
106
|
+
uint256 stakingAmount
|
107
|
+
)
|
108
|
+
internal
|
109
|
+
{
|
110
|
+
// process token transfer(s)
|
111
|
+
if(stakingAmount > 0) {
|
112
|
+
TokenHandler tokenHandler = instance.getTokenHandler(poolNftId);
|
113
|
+
address bundleOwner = _registry.getOwner(bundleNftId);
|
114
|
+
address poolWallet = instance.getPoolSetup(poolNftId).wallet;
|
115
|
+
|
116
|
+
tokenHandler.transfer(
|
117
|
+
bundleOwner,
|
118
|
+
poolWallet,
|
119
|
+
stakingAmount
|
120
|
+
);
|
121
|
+
}
|
122
|
+
}
|
98
123
|
}
|