@etherisc/gif-next 0.0.2-f0d86c2-077 → 0.0.2-f72939c-683
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +38 -11
- 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
@@ -55,7 +55,7 @@ abstract contract BundleModule is
|
|
55
55
|
}
|
56
56
|
|
57
57
|
function initializeBundleModule(IKeyValueStore keyValueStore) internal {
|
58
|
-
_initialize(keyValueStore
|
58
|
+
_initialize(keyValueStore);
|
59
59
|
}
|
60
60
|
|
61
61
|
function createBundleInfo(
|
@@ -69,8 +69,7 @@ abstract contract BundleModule is
|
|
69
69
|
onlyBundlePoolService
|
70
70
|
override
|
71
71
|
{
|
72
|
-
BundleInfo memory
|
73
|
-
bundleNftId,
|
72
|
+
BundleInfo memory info = BundleInfo(
|
74
73
|
poolNftId,
|
75
74
|
filter,
|
76
75
|
amount, // capital
|
@@ -80,15 +79,15 @@ abstract contract BundleModule is
|
|
80
79
|
zeroTimestamp() // closedAt
|
81
80
|
);
|
82
81
|
|
83
|
-
_create(bundleNftId, abi.encode(
|
82
|
+
_create(BUNDLE(), bundleNftId, abi.encode(info));
|
84
83
|
}
|
85
84
|
|
86
|
-
function setBundleInfo(BundleInfo memory
|
85
|
+
function setBundleInfo(NftId bundleNftId, BundleInfo memory info)
|
87
86
|
external
|
88
87
|
override
|
89
88
|
onlyPoolOrProductService
|
90
89
|
{
|
91
|
-
_updateData(
|
90
|
+
_updateData(BUNDLE(), bundleNftId, abi.encode(info));
|
92
91
|
}
|
93
92
|
|
94
93
|
function updateBundleState(NftId bundleNftId, StateId state)
|
@@ -96,7 +95,7 @@ abstract contract BundleModule is
|
|
96
95
|
override
|
97
96
|
onlyBundlePoolService
|
98
97
|
{
|
99
|
-
_updateState(bundleNftId, state);
|
98
|
+
_updateState(BUNDLE(), bundleNftId, state);
|
100
99
|
}
|
101
100
|
|
102
101
|
function collateralizePolicy(
|
@@ -127,10 +126,10 @@ abstract contract BundleModule is
|
|
127
126
|
}
|
128
127
|
|
129
128
|
function getBundleInfo(NftId bundleNftId) external view override returns(BundleInfo memory bundleInfo) {
|
130
|
-
return abi.decode(_getData(bundleNftId), (BundleInfo));
|
129
|
+
return abi.decode(_getData(BUNDLE(), bundleNftId), (BundleInfo));
|
131
130
|
}
|
132
131
|
|
133
|
-
function
|
134
|
-
return
|
135
|
-
}
|
132
|
+
function getBundleState(NftId bundleNftId) external view override returns(StateId state) {
|
133
|
+
return _getState(BUNDLE(), bundleNftId);
|
134
|
+
}
|
136
135
|
}
|
@@ -16,7 +16,6 @@ import {IPoolService} from "../../service/IPoolService.sol";
|
|
16
16
|
interface IBundle {
|
17
17
|
|
18
18
|
struct BundleInfo {
|
19
|
-
NftId nftId;
|
20
19
|
NftId poolNftId;
|
21
20
|
bytes filter; // required conditions for applications to be considered for collateralization by this bundle
|
22
21
|
uint256 capitalAmount; // net investment capital amount (<= balance)
|
@@ -37,20 +36,14 @@ interface IBundleModule is IBundle {
|
|
37
36
|
bytes calldata filter
|
38
37
|
) external;
|
39
38
|
|
40
|
-
function setBundleInfo(BundleInfo memory bundleInfo) external;
|
41
|
-
function updateBundleState(NftId
|
39
|
+
function setBundleInfo(NftId nftId, BundleInfo memory bundleInfo) external;
|
40
|
+
function updateBundleState(NftId nftId, StateId state) external;
|
42
41
|
|
43
42
|
function collateralizePolicy(NftId bundleNftId, NftId policyNftId, uint256 amount) external;
|
44
43
|
function releasePolicy(NftId bundleNftId, NftId policyNftId) external returns(uint256 collateralAmount);
|
45
44
|
|
46
|
-
function getBundleInfo(NftId
|
47
|
-
function
|
48
|
-
|
49
|
-
// repeat registry linked signature
|
50
|
-
function getRegistry() external view returns (IRegistry registry);
|
51
|
-
|
52
|
-
// repeat instance base signature
|
53
|
-
function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
|
45
|
+
function getBundleInfo(NftId nftId) external view returns(BundleInfo memory bundleInfo);
|
46
|
+
function getBundleState(NftId nftId) external view returns(StateId state);
|
54
47
|
|
55
48
|
// repeat service linked signatures to avoid linearization issues
|
56
49
|
function getProductService() external returns(IProductService);
|
@@ -2,7 +2,16 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {ICompensationModule} from "./ICompensation.sol";
|
5
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
6
|
+
import {ModuleBase} from "../../base/ModuleBase.sol";
|
7
|
+
|
8
|
+
contract CompensationModule is
|
9
|
+
ModuleBase,
|
10
|
+
ICompensationModule
|
11
|
+
{
|
12
|
+
|
13
|
+
function initializeCompensationModule(IKeyValueStore keyValueStore) internal {
|
14
|
+
_initialize(keyValueStore);
|
15
|
+
}
|
5
16
|
|
6
|
-
contract CompensationModule is ICompensationModule {
|
7
|
-
|
8
17
|
}
|
@@ -2,27 +2,21 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
6
|
+
import {IComponentModule} from "./IComponent.sol";
|
5
7
|
|
6
|
-
import {
|
7
|
-
import {
|
8
|
+
import {NftId} from "../../../types/NftId.sol";
|
9
|
+
import {ObjectType, COMPONENT} from "../../../types/ObjectType.sol";
|
10
|
+
import {StateId} from "../../../types/StateId.sol";
|
11
|
+
import {ModuleBase} from "../../base/ModuleBase.sol";
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
import {ObjectType, PRODUCT, ORACLE, POOL} from "../../../types/ObjectType.sol";
|
12
|
-
import {StateId, ACTIVE, PAUSED} from "../../../types/StateId.sol";
|
13
|
-
import {NftId, NftIdLib, zeroNftId} from "../../../types/NftId.sol";
|
14
|
-
import {Fee} from "../../../types/Fee.sol";
|
15
|
-
|
16
|
-
abstract contract ComponentModule is
|
13
|
+
abstract contract ComponentModule is
|
14
|
+
ModuleBase,
|
17
15
|
IComponentModule
|
18
16
|
{
|
19
|
-
using NftIdLib for NftId;
|
20
17
|
|
21
|
-
mapping(NftId nftId => ComponentInfo info) private _componentInfo;
|
22
18
|
NftId[] private _nftIds;
|
23
19
|
|
24
|
-
mapping(ObjectType cType => bytes32 role) private _componentOwnerRole;
|
25
|
-
|
26
20
|
modifier onlyComponentOwnerService() {
|
27
21
|
require(
|
28
22
|
msg.sender == address(this.getComponentOwnerService()),
|
@@ -31,45 +25,43 @@ abstract contract ComponentModule is
|
|
31
25
|
_;
|
32
26
|
}
|
33
27
|
|
28
|
+
function initializeComponentModule(IKeyValueStore keyValueStore) internal {
|
29
|
+
_initialize(keyValueStore);
|
30
|
+
}
|
31
|
+
|
34
32
|
function registerComponent(
|
35
33
|
NftId nftId,
|
36
|
-
|
37
|
-
|
38
|
-
)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
ACTIVE(),
|
45
|
-
token
|
46
|
-
);
|
47
|
-
|
34
|
+
IERC20Metadata token,
|
35
|
+
address wallet
|
36
|
+
)
|
37
|
+
external
|
38
|
+
onlyComponentOwnerService
|
39
|
+
override
|
40
|
+
{
|
41
|
+
ComponentInfo memory info = ComponentInfo(token, wallet);
|
48
42
|
_nftIds.push(nftId);
|
43
|
+
_create(COMPONENT(), nftId, abi.encode(info));
|
44
|
+
}
|
49
45
|
|
50
|
-
|
46
|
+
function getComponentState(
|
47
|
+
NftId nftId
|
48
|
+
)
|
49
|
+
external
|
50
|
+
view
|
51
|
+
override
|
52
|
+
returns (StateId state)
|
53
|
+
{
|
54
|
+
return _getState(COMPONENT(), nftId);
|
51
55
|
}
|
52
56
|
|
53
|
-
function
|
54
|
-
ComponentInfo memory info
|
55
|
-
|
56
|
-
|
57
|
-
require(
|
58
|
-
nftId.gtz() && _componentInfo[nftId].nftId.eq(nftId),
|
59
|
-
"ERROR:CMP-006:COMPONENT_UNKNOWN"
|
60
|
-
);
|
57
|
+
function getComponentToken(NftId nftId) external view override returns(IERC20Metadata token) {
|
58
|
+
ComponentInfo memory info = abi.decode(_getData(COMPONENT(), nftId), (ComponentInfo));
|
59
|
+
return info.token;
|
60
|
+
}
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
// ObjectType objectType = this.getRegistry().getObjectInfo(nftId).objectType;
|
66
|
-
// _lifecycleModule.checkAndLogTransition(
|
67
|
-
// nftId,
|
68
|
-
// objectType,
|
69
|
-
// _componentInfo[nftId].state,
|
70
|
-
// info.state
|
71
|
-
// );
|
72
|
-
_componentInfo[nftId] = info;
|
62
|
+
function getComponentWallet(NftId nftId) external view override returns (address wallet) {
|
63
|
+
ComponentInfo memory info = abi.decode(_getData(COMPONENT(), nftId), (ComponentInfo));
|
64
|
+
return info.wallet;
|
73
65
|
}
|
74
66
|
|
75
67
|
function getComponentCount()
|
@@ -86,10 +78,4 @@ abstract contract ComponentModule is
|
|
86
78
|
) external view override returns (NftId componentNftId) {
|
87
79
|
return _nftIds[idx];
|
88
80
|
}
|
89
|
-
|
90
|
-
function getComponentInfo(
|
91
|
-
NftId nftId
|
92
|
-
) external view override returns (ComponentInfo memory) {
|
93
|
-
return _componentInfo[nftId];
|
94
|
-
}
|
95
|
-
}
|
81
|
+
}
|
@@ -2,52 +2,28 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
+
import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
|
5
6
|
|
6
|
-
|
7
|
-
import {IRegistry} from "../../../registry/IRegistry.sol";
|
8
|
-
import {IInstance} from "../../IInstance.sol";
|
9
7
|
import {StateId} from "../../../types/StateId.sol";
|
10
8
|
import {NftId} from "../../../types/NftId.sol";
|
11
|
-
import {ObjectType} from "../../../types/ObjectType.sol";
|
12
|
-
import {RoleId} from "../../../types/RoleId.sol";
|
13
|
-
import {Fee} from "../../../types/Fee.sol";
|
14
|
-
import {UFixed} from "../../../types/UFixed.sol";
|
15
|
-
|
16
|
-
import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
|
17
|
-
// import {IComponentBase} from "../../../components/IComponentBase.sol";
|
18
9
|
|
19
10
|
interface IComponent {
|
20
|
-
// component dynamic info (static info kept in registry)
|
21
11
|
struct ComponentInfo {
|
22
|
-
NftId nftId;
|
23
|
-
StateId state;
|
24
12
|
IERC20Metadata token;
|
13
|
+
address wallet;
|
25
14
|
}
|
26
15
|
}
|
27
16
|
|
28
17
|
interface IComponentModule is IComponent {
|
29
|
-
function getRegistry() external view returns (IRegistry registry);
|
30
18
|
|
31
|
-
function registerComponent(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
) external;
|
36
|
-
|
37
|
-
function setComponentInfo(
|
38
|
-
ComponentInfo memory info
|
39
|
-
) external returns (NftId componentNftId);
|
40
|
-
|
41
|
-
function getComponentInfo(
|
42
|
-
NftId nftId
|
43
|
-
) external view returns (ComponentInfo memory info);
|
19
|
+
function registerComponent(NftId nftId, IERC20Metadata token, address wallet) external;
|
20
|
+
function getComponentState(NftId nftId) external view returns (StateId state);
|
21
|
+
function getComponentToken(NftId nftId) external view returns (IERC20Metadata token);
|
22
|
+
function getComponentWallet(NftId nftId) external view returns (address wallet);
|
44
23
|
|
45
24
|
function getComponentCount() external view returns (uint256 numberOfCompnents);
|
46
|
-
|
47
25
|
function getComponentId(uint256 idx) external view returns (NftId nftId);
|
48
26
|
|
49
27
|
// repeat service linked signaturea to avoid linearization issues
|
50
28
|
function getComponentOwnerService() external view returns(IComponentOwnerService);
|
51
|
-
|
52
|
-
function hasRole(RoleId role, address member) external view returns (bool);
|
53
29
|
}
|
@@ -5,42 +5,42 @@ import {IRegistry} from "../../../registry/IRegistry.sol";
|
|
5
5
|
import {IInstance} from "../../IInstance.sol";
|
6
6
|
import {IProductService} from "../../service/IProductService.sol";
|
7
7
|
import {NftId} from "../../../types/NftId.sol";
|
8
|
+
import {RiskId} from "../../../types/RiskId.sol";
|
8
9
|
import {StateId} from "../../../types/StateId.sol";
|
9
10
|
import {Timestamp} from "../../../types/Timestamp.sol";
|
10
|
-
import {Blocknumber} from "../../../types/Blocknumber.sol";
|
11
11
|
|
12
12
|
// TODO check if there is value to introuce IContract and let IPolicy derive from IContract
|
13
13
|
interface IPolicy {
|
14
14
|
struct PolicyInfo {
|
15
|
-
NftId nftId;
|
16
15
|
NftId productNftId;
|
17
16
|
NftId bundleNftId;
|
18
17
|
address beneficiary;
|
19
|
-
|
18
|
+
RiskId riskId;
|
20
19
|
uint256 sumInsuredAmount;
|
21
20
|
uint256 premiumAmount;
|
22
21
|
uint256 premiumPaidAmount;
|
23
22
|
uint256 lifetime;
|
24
|
-
bytes
|
25
|
-
|
23
|
+
bytes applicationData;
|
24
|
+
bytes policyData;
|
26
25
|
Timestamp activatedAt; // time of underwriting
|
27
26
|
Timestamp expiredAt; // no new claims (activatedAt + lifetime)
|
28
27
|
Timestamp closedAt; // no locked capital
|
29
|
-
Blocknumber updatedIn; // write log entries in a way to support backtracking of all state changes
|
30
28
|
}
|
31
29
|
}
|
32
30
|
|
33
31
|
interface IPolicyModule is IPolicy {
|
34
|
-
function
|
35
|
-
NftId productNftId,
|
32
|
+
function createPolicyInfo(
|
36
33
|
NftId policyNftId,
|
34
|
+
NftId productNftId,
|
35
|
+
RiskId riskId,
|
37
36
|
uint256 sumInsuredAmount,
|
38
37
|
uint256 premiumAmount,
|
39
38
|
uint256 lifetime,
|
40
39
|
NftId bundleNftId
|
41
40
|
) external;
|
42
41
|
|
43
|
-
function setPolicyInfo(PolicyInfo memory
|
42
|
+
function setPolicyInfo(NftId policyNftId, PolicyInfo memory info) external;
|
43
|
+
function updatePolicyState(NftId nftId, StateId state) external;
|
44
44
|
|
45
45
|
// function underwrite(NftId nftId) external;
|
46
46
|
|
@@ -52,6 +52,8 @@ interface IPolicyModule is IPolicy {
|
|
52
52
|
NftId nftId
|
53
53
|
) external view returns (PolicyInfo memory info);
|
54
54
|
|
55
|
+
function getPolicyState(NftId nftId) external view returns (StateId state);
|
56
|
+
|
55
57
|
// repeat registry linked signature
|
56
58
|
function getRegistry() external view returns (IRegistry registry);
|
57
59
|
|
@@ -6,15 +6,18 @@ import {IRegistry} from "../../../registry/IRegistry.sol";
|
|
6
6
|
import {IProductService} from "../../service/IProductService.sol";
|
7
7
|
import {IPolicy, IPolicyModule} from "./IPolicy.sol";
|
8
8
|
import {ObjectType, POLICY} from "../../../types/ObjectType.sol";
|
9
|
-
import {APPLIED, ACTIVE, UNDERWRITTEN} from "../../../types/StateId.sol";
|
10
9
|
import {NftId, NftIdLib} from "../../../types/NftId.sol";
|
10
|
+
import {RiskId} from "../../../types/RiskId.sol";
|
11
|
+
import {StateId} from "../../../types/StateId.sol";
|
11
12
|
import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
|
12
|
-
import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
15
|
+
import {ModuleBase} from "../../base/ModuleBase.sol";
|
16
16
|
|
17
|
-
|
17
|
+
abstract contract PolicyModule is
|
18
|
+
ModuleBase,
|
19
|
+
IPolicyModule
|
20
|
+
{
|
18
21
|
|
19
22
|
// TODO find a better place to avoid dupliation
|
20
23
|
modifier onlyProductService2() {
|
@@ -25,9 +28,14 @@ abstract contract PolicyModule is IPolicyModule {
|
|
25
28
|
_;
|
26
29
|
}
|
27
30
|
|
28
|
-
function
|
29
|
-
|
31
|
+
function initializePolicyModule(IKeyValueStore keyValueStore) internal {
|
32
|
+
_initialize(keyValueStore);
|
33
|
+
}
|
34
|
+
|
35
|
+
function createPolicyInfo(
|
30
36
|
NftId policyNftId,
|
37
|
+
NftId productNftId,
|
38
|
+
RiskId riskId,
|
31
39
|
uint256 sumInsuredAmount,
|
32
40
|
uint256 premiumAmount,
|
33
41
|
uint256 lifetime,
|
@@ -37,40 +45,48 @@ abstract contract PolicyModule is IPolicyModule {
|
|
37
45
|
onlyProductService2
|
38
46
|
override
|
39
47
|
{
|
40
|
-
|
41
|
-
policyNftId,
|
48
|
+
PolicyInfo memory info = PolicyInfo(
|
42
49
|
productNftId,
|
43
50
|
bundleNftId,
|
44
51
|
address(0), // beneficiary = policy nft holder
|
45
|
-
|
46
|
-
APPLIED(),
|
52
|
+
riskId,
|
47
53
|
sumInsuredAmount,
|
48
54
|
premiumAmount,
|
49
55
|
0, // premium paid amount
|
50
56
|
lifetime,
|
51
|
-
"", //
|
52
|
-
|
57
|
+
"", // applicationData
|
58
|
+
"", // policyData
|
53
59
|
zeroTimestamp(), // activatedAt
|
54
60
|
zeroTimestamp(), // expiredAt
|
55
|
-
zeroTimestamp()
|
56
|
-
blockNumber() // updatedIn
|
61
|
+
zeroTimestamp() // closedAt
|
57
62
|
);
|
58
63
|
|
59
|
-
|
64
|
+
_create(POLICY(), policyNftId, abi.encode(info));
|
60
65
|
}
|
61
66
|
|
62
|
-
function setPolicyInfo(PolicyInfo memory
|
67
|
+
function setPolicyInfo(NftId policyNftId, PolicyInfo memory info)
|
63
68
|
external
|
64
69
|
override
|
65
70
|
onlyProductService2
|
66
71
|
{
|
67
|
-
|
72
|
+
_updateData(POLICY(), policyNftId, abi.encode(info));
|
73
|
+
}
|
74
|
+
|
75
|
+
function updatePolicyState(NftId bundleNftId, StateId state)
|
76
|
+
external
|
77
|
+
override
|
78
|
+
onlyProductService2
|
79
|
+
{
|
80
|
+
_updateState(POLICY(), bundleNftId, state);
|
68
81
|
}
|
69
82
|
|
70
83
|
function getPolicyInfo(
|
71
84
|
NftId nftId
|
72
85
|
) external view returns (PolicyInfo memory info) {
|
73
|
-
return
|
86
|
+
return abi.decode(_getData(POLICY(), nftId), (PolicyInfo));
|
74
87
|
}
|
75
88
|
|
89
|
+
function getPolicyState(NftId nftId) external view override returns(StateId state) {
|
90
|
+
return _getState(POLICY(), nftId);
|
91
|
+
}
|
76
92
|
}
|
@@ -8,18 +8,22 @@ import {IPolicy, IPolicyModule} from "../../module/policy/IPolicy.sol";
|
|
8
8
|
import {ITreasuryModule} from "../../module/treasury/ITreasury.sol";
|
9
9
|
|
10
10
|
import {NftId} from "../../../types/NftId.sol";
|
11
|
+
import {POOL} from "../../../types/ObjectType.sol";
|
11
12
|
import {LibNftIdSet} from "../../../types/NftIdSet.sol";
|
12
13
|
import {StateId, APPLIED} from "../../../types/StateId.sol";
|
13
14
|
import {UFixed} from "../../../types/UFixed.sol";
|
14
15
|
|
16
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
15
17
|
import {IPoolModule} from "./IPoolModule.sol";
|
18
|
+
import {ModuleBase} from "../../base/ModuleBase.sol";
|
16
19
|
|
17
20
|
abstract contract PoolModule is
|
21
|
+
ModuleBase,
|
18
22
|
IPoolModule
|
19
23
|
{
|
20
24
|
using LibNftIdSet for LibNftIdSet.Set;
|
21
25
|
|
22
|
-
mapping(NftId poolNftId => PoolInfo info) private _poolInfo;
|
26
|
+
// mapping(NftId poolNftId => PoolInfo info) private _poolInfo;
|
23
27
|
mapping(NftId poolNftId => LibNftIdSet.Set bundles) private _bundlesForPool;
|
24
28
|
|
25
29
|
modifier poolServiceCallingPool() {
|
@@ -30,6 +34,10 @@ abstract contract PoolModule is
|
|
30
34
|
_;
|
31
35
|
}
|
32
36
|
|
37
|
+
function initializePoolModule(IKeyValueStore keyValueStore) internal {
|
38
|
+
_initialize(keyValueStore);
|
39
|
+
}
|
40
|
+
|
33
41
|
function registerPool(
|
34
42
|
NftId nftId,
|
35
43
|
bool isVerifying,
|
@@ -38,17 +46,12 @@ abstract contract PoolModule is
|
|
38
46
|
public
|
39
47
|
override
|
40
48
|
{
|
41
|
-
|
42
|
-
_poolInfo[nftId].nftId.eqz(),
|
43
|
-
"ERROR:PL-010:ALREADY_CREATED");
|
44
|
-
|
45
|
-
_poolInfo[nftId] = PoolInfo(
|
46
|
-
nftId,
|
49
|
+
PoolInfo memory info = PoolInfo(
|
47
50
|
isVerifying,
|
48
51
|
collateralizationRate
|
49
52
|
);
|
50
53
|
|
51
|
-
|
54
|
+
_create(POOL(), nftId, abi.encode(info));
|
52
55
|
}
|
53
56
|
|
54
57
|
function addBundleToPool(
|
@@ -71,7 +74,7 @@ abstract contract PoolModule is
|
|
71
74
|
function getPoolInfo(
|
72
75
|
NftId nftId
|
73
76
|
) external view override returns (PoolInfo memory info) {
|
74
|
-
|
77
|
+
return abi.decode(_getData(POOL(), nftId), (PoolInfo));
|
75
78
|
}
|
76
79
|
|
77
80
|
|
@@ -1,10 +1,27 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
|
4
|
+
import {NftId} from "../../../types/NftId.sol";
|
5
|
+
import {RiskId} from "../../../types/RiskId.sol";
|
6
|
+
import {StateId} from "../../../types/StateId.sol";
|
5
7
|
|
8
|
+
interface IRisk {
|
9
|
+
struct RiskInfo {
|
10
|
+
NftId productNftId;
|
11
|
+
bytes data;
|
12
|
+
}
|
6
13
|
}
|
7
14
|
|
8
15
|
interface IRiskModule is IRisk {
|
9
|
-
|
16
|
+
function createRisk(
|
17
|
+
RiskId riskId,
|
18
|
+
NftId productNftId,
|
19
|
+
bytes memory data
|
20
|
+
) external;
|
21
|
+
|
22
|
+
function setRiskInfo(RiskId riskId, RiskInfo memory info) external;
|
23
|
+
function updateRiskState(RiskId riskId, StateId state) external;
|
24
|
+
|
25
|
+
function getRiskInfo(RiskId riskId) external view returns (RiskInfo memory info);
|
26
|
+
function getRiskState(RiskId riskId) external view returns (StateId state);
|
10
27
|
}
|
@@ -1,8 +1,70 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
+
import {NftId} from "../../../types/NftId.sol";
|
5
|
+
import {RISK} from "../../../types/ObjectType.sol";
|
6
|
+
import {RiskId} from "../../../types/RiskId.sol";
|
7
|
+
import {StateId} from "../../../types/StateId.sol";
|
8
|
+
|
9
|
+
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
4
10
|
import {IRiskModule} from "./IRisk.sol";
|
11
|
+
import {ModuleBase} from "../../base/ModuleBase.sol";
|
12
|
+
|
13
|
+
contract RiskModule is
|
14
|
+
ModuleBase,
|
15
|
+
IRiskModule
|
16
|
+
{
|
17
|
+
function initializeRiskModule(IKeyValueStore keyValueStore) internal {
|
18
|
+
_initialize(keyValueStore);
|
19
|
+
}
|
20
|
+
|
21
|
+
function createRisk(
|
22
|
+
RiskId riskId,
|
23
|
+
NftId productNftId,
|
24
|
+
bytes memory data
|
25
|
+
) external override {
|
26
|
+
RiskInfo memory info = RiskInfo(
|
27
|
+
productNftId,
|
28
|
+
data
|
29
|
+
);
|
30
|
+
|
31
|
+
_create(RISK(), riskId.toKey32(), abi.encode(info));
|
32
|
+
}
|
33
|
+
|
34
|
+
function setRiskInfo(
|
35
|
+
RiskId riskId,
|
36
|
+
RiskInfo memory info
|
37
|
+
)
|
38
|
+
external
|
39
|
+
override
|
40
|
+
{
|
41
|
+
|
42
|
+
}
|
43
|
+
|
44
|
+
function updateRiskState(
|
45
|
+
RiskId riskId,
|
46
|
+
StateId state
|
47
|
+
)
|
48
|
+
external
|
49
|
+
override
|
50
|
+
{
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
function getRiskInfo(RiskId riskId)
|
55
|
+
external
|
56
|
+
view
|
57
|
+
override
|
58
|
+
returns (RiskInfo memory info)
|
59
|
+
{
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
function getRiskState(RiskId riskId)
|
64
|
+
external
|
65
|
+
view
|
66
|
+
returns (StateId state)
|
67
|
+
{
|
5
68
|
|
6
|
-
|
7
|
-
|
69
|
+
}
|
8
70
|
}
|