@etherisc/gif-next 0.0.2-2a0a7d0-893 → 0.0.2-2a59cd5-352
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +405 -6
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +883 -141
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +113 -6
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +798 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +662 -43
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +656 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +583 -75
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +504 -5
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/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/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +450 -35
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +111 -7
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +589 -223
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +39 -89
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +58 -53
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +400 -96
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +175 -25
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +166 -7
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +13 -13
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1117 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +290 -66
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +169 -19
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +439 -27
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +194 -16
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +638 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +118 -40
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +217 -7
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +33 -20
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +20 -7
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +20 -7
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +223 -64
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +182 -32
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +186 -27
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +166 -16
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +186 -27
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +166 -16
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +15 -2
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +100 -26
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +28 -15
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +260 -40
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +166 -16
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +11 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +160 -10
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +37 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +18 -5
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +69 -0
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +20 -7
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -2
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +156 -11
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +269 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +156 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +152 -11
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +105 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +166 -7
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -2
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +152 -11
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +184 -25
- 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/TestVersionable.sol/TestVersionable.json +8 -8
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- 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/NumberId.sol/NumberIdLib.dbg.json +1 -1
- 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/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +121 -62
- package/contracts/components/Distribution.sol +207 -53
- package/contracts/components/IComponent.sol +16 -3
- package/contracts/components/IDistributionComponent.sol +59 -3
- package/contracts/components/IPoolComponent.sol +50 -29
- package/contracts/components/IProductComponent.sol +5 -1
- package/contracts/components/Pool.sol +133 -137
- package/contracts/components/Product.sol +90 -107
- package/contracts/instance/IInstance.sol +26 -6
- package/contracts/instance/IInstanceService.sol +19 -0
- package/contracts/instance/Instance.sol +58 -30
- package/contracts/instance/InstanceAccessManager.sol +12 -13
- package/contracts/instance/InstanceService.sol +119 -39
- package/contracts/instance/base/ComponentService.sol +3 -2
- package/contracts/instance/module/IAccess.sol +3 -4
- package/contracts/instance/module/ISetup.sol +5 -4
- package/contracts/instance/service/ApplicationService.sol +268 -0
- package/contracts/instance/service/BundleService.sol +11 -6
- package/contracts/instance/service/DistributionService.sol +197 -30
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +11 -1
- package/contracts/instance/service/IDistributionService.sol +53 -0
- package/contracts/instance/service/IPolicyService.sol +10 -16
- package/contracts/instance/service/PolicyService.sol +84 -98
- package/contracts/instance/service/PoolService.sol +9 -42
- package/contracts/instance/service/ProductService.sol +20 -28
- package/contracts/registry/IRegistry.sol +3 -2
- package/contracts/registry/IRegistryService.sol +16 -6
- package/contracts/registry/Registry.sol +20 -8
- package/contracts/registry/RegistryService.sol +50 -85
- package/contracts/registry/ReleaseManager.sol +19 -40
- package/contracts/registry/TokenRegistry.sol +4 -3
- package/contracts/shared/ERC165.sol +12 -11
- package/contracts/shared/INftOwnable.sol +12 -6
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +4 -4
- package/contracts/shared/IRegistryLinked.sol +15 -0
- package/contracts/shared/IVersionable.sol +2 -2
- package/contracts/shared/NftOwnable.sol +113 -59
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +5 -4
- package/contracts/shared/Registerable.sol +15 -24
- package/contracts/shared/RegistryLinked.sol +64 -0
- package/contracts/shared/Service.sol +5 -5
- package/contracts/shared/Versionable.sol +3 -2
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/ObjectType.sol +6 -2
- package/package.json +3 -3
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -100
- package/contracts/instance/base/IInstanceBase.sol +0 -21
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.19;
|
|
3
|
+
|
|
4
|
+
import {IRisk} from "../module/IRisk.sol";
|
|
5
|
+
import {IService} from "../../shared/IService.sol";
|
|
6
|
+
|
|
7
|
+
import {NftId} from "../../types/NftId.sol";
|
|
8
|
+
import {ReferralId} from "../../types/Referral.sol";
|
|
9
|
+
import {RiskId} from "../../types/RiskId.sol";
|
|
10
|
+
import {StateId} from "../../types/StateId.sol";
|
|
11
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
|
12
|
+
import {UFixed} from "../../types/UFixed.sol";
|
|
13
|
+
import {Fee} from "../../types/Fee.sol";
|
|
14
|
+
|
|
15
|
+
/// @dev gif service responsible for creating applications
|
|
16
|
+
/// only product components may call transaction functions
|
|
17
|
+
interface IApplicationService is IService {
|
|
18
|
+
|
|
19
|
+
error IApplicationServicePolicyNotApplied(NftId applicationNftId);
|
|
20
|
+
|
|
21
|
+
/// @dev creates a new application based on the specified attributes
|
|
22
|
+
/// may only be called by a product component
|
|
23
|
+
function create(
|
|
24
|
+
address applicationOwner,
|
|
25
|
+
RiskId riskId,
|
|
26
|
+
NftId bundleNftId,
|
|
27
|
+
ReferralId referralId,
|
|
28
|
+
uint256 sumInsuredAmount,
|
|
29
|
+
uint256 lifetime,
|
|
30
|
+
bytes memory applicationData
|
|
31
|
+
) external returns (NftId applicationNftId);
|
|
32
|
+
|
|
33
|
+
/// @dev updates application attributes
|
|
34
|
+
/// may only be called while the application is in applied state
|
|
35
|
+
/// may only be called by the referenced product related to applicationNftId
|
|
36
|
+
function ajust(
|
|
37
|
+
NftId applicationNftId,
|
|
38
|
+
RiskId riskId,
|
|
39
|
+
NftId bundleNftId,
|
|
40
|
+
ReferralId referralId,
|
|
41
|
+
uint256 sumInsuredAmount,
|
|
42
|
+
uint256 lifetime,
|
|
43
|
+
bytes memory applicationData
|
|
44
|
+
) external;
|
|
45
|
+
|
|
46
|
+
/// @dev creates a new application that extends the provided policy
|
|
47
|
+
/// lifetime will seamlessly extend referenced policy, for closed policies
|
|
48
|
+
/// lifetime will start at underwriting time
|
|
49
|
+
/// product will need to limit the time window for renewal as underwriting
|
|
50
|
+
/// will lock the collateral at underwriting time which might be earlier than activation time
|
|
51
|
+
/// policyNftId needs to refer to an underwritten (or active or closed) policy
|
|
52
|
+
/// may only be called by the referenced product related to policyNftId
|
|
53
|
+
function renew(
|
|
54
|
+
NftId policyNftId, // policy to be renewd (renewal inherits policy attributes)
|
|
55
|
+
NftId bundleNftId // will likely need a newer bundle for underwriting
|
|
56
|
+
) external returns (NftId applicationNftId);
|
|
57
|
+
|
|
58
|
+
/// @dev revokes the application represented by {policyNftId}
|
|
59
|
+
/// an application can only be revoked in applied state
|
|
60
|
+
/// only the application holder may revoke an application
|
|
61
|
+
function revoke(NftId policyNftId) external;
|
|
62
|
+
|
|
63
|
+
/// @dev calculates the premium amount for the specified attributes
|
|
64
|
+
/// also returns the various fee components involved with creating a policy
|
|
65
|
+
function calculatePremium(
|
|
66
|
+
RiskId riskId,
|
|
67
|
+
uint256 sumInsuredAmount,
|
|
68
|
+
uint256 lifetime,
|
|
69
|
+
bytes memory applicationData,
|
|
70
|
+
NftId bundleNftId,
|
|
71
|
+
ReferralId referralId
|
|
72
|
+
)
|
|
73
|
+
external
|
|
74
|
+
view
|
|
75
|
+
returns (
|
|
76
|
+
uint256 premiumAmount,
|
|
77
|
+
uint256 distributionFeeAmount,
|
|
78
|
+
uint256 productFeeAmount,
|
|
79
|
+
uint256 poolFeeAmount,
|
|
80
|
+
uint256 bundleFeeAmount
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -26,7 +26,17 @@ interface IBundleService is IService {
|
|
|
26
26
|
|
|
27
27
|
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
|
28
28
|
|
|
29
|
-
function
|
|
29
|
+
function lockCollateral(
|
|
30
|
+
IInstance instanceNftId,
|
|
31
|
+
NftId policyNftId,
|
|
32
|
+
NftId bundleNftId,
|
|
33
|
+
uint256 collateralAmount,
|
|
34
|
+
uint256 netPremium
|
|
35
|
+
)
|
|
36
|
+
external
|
|
37
|
+
returns (
|
|
38
|
+
IBundle.BundleInfo memory bundleInfo
|
|
39
|
+
);
|
|
30
40
|
|
|
31
41
|
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
|
32
42
|
|
|
@@ -4,9 +4,62 @@ pragma solidity ^0.8.19;
|
|
|
4
4
|
import {NftId} from "../../types/NftId.sol";
|
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
|
6
6
|
import {IService} from "../../shared/IService.sol";
|
|
7
|
+
import {UFixed} from "../../types/UFixed.sol";
|
|
8
|
+
import {DistributorType} from "../../types/DistributorType.sol";
|
|
9
|
+
import {ReferralId} from "../../types/Referral.sol";
|
|
10
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
|
11
|
+
|
|
7
12
|
|
|
8
13
|
interface IDistributionService is IService {
|
|
9
14
|
function setFees(
|
|
10
15
|
Fee memory distributionFee
|
|
11
16
|
) external;
|
|
17
|
+
|
|
18
|
+
function createDistributorType(
|
|
19
|
+
string memory name,
|
|
20
|
+
UFixed minDiscountPercentage,
|
|
21
|
+
UFixed maxDiscountPercentage,
|
|
22
|
+
UFixed commissionPercentage,
|
|
23
|
+
uint32 maxReferralCount,
|
|
24
|
+
uint32 maxReferralLifetime,
|
|
25
|
+
bool allowSelfReferrals,
|
|
26
|
+
bool allowRenewals,
|
|
27
|
+
bytes memory data
|
|
28
|
+
)
|
|
29
|
+
external
|
|
30
|
+
returns (DistributorType distributorType);
|
|
31
|
+
|
|
32
|
+
function createDistributor(
|
|
33
|
+
address distributor,
|
|
34
|
+
DistributorType distributorType,
|
|
35
|
+
bytes memory data
|
|
36
|
+
) external returns (NftId distributorNftId);
|
|
37
|
+
|
|
38
|
+
function updateDistributorType(
|
|
39
|
+
NftId distributorNftId,
|
|
40
|
+
DistributorType distributorType,
|
|
41
|
+
bytes memory data
|
|
42
|
+
) external;
|
|
43
|
+
|
|
44
|
+
function createReferral(
|
|
45
|
+
NftId distributorNftId,
|
|
46
|
+
string memory code,
|
|
47
|
+
UFixed discountPercentage,
|
|
48
|
+
uint32 maxReferrals,
|
|
49
|
+
Timestamp expiryAt,
|
|
50
|
+
bytes memory data
|
|
51
|
+
)
|
|
52
|
+
external
|
|
53
|
+
returns (ReferralId referralId);
|
|
54
|
+
|
|
55
|
+
/// @dev callback from product service when selling a policy for a specific referralId
|
|
56
|
+
function processSale(
|
|
57
|
+
ReferralId referralId,
|
|
58
|
+
uint256 premiumAmount
|
|
59
|
+
) external;
|
|
60
|
+
|
|
61
|
+
function calculateFeeAmount(
|
|
62
|
+
ReferralId referralId,
|
|
63
|
+
uint256 premiumAmount
|
|
64
|
+
) external view returns (uint256 feeAmount);
|
|
12
65
|
}
|
|
@@ -52,33 +52,27 @@ interface IPolicyService is IService {
|
|
|
52
52
|
ReferralId referralId
|
|
53
53
|
) external returns (NftId nftId);
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
function revoke(NftId policyNftId) external;
|
|
55
|
+
/// @dev declines an application represented by {policyNftId}
|
|
56
|
+
/// an application can only be declined in applied state
|
|
57
|
+
/// only the related product may decline an application
|
|
58
|
+
function decline(NftId policyNftId) external;
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
/// @dev underwrites the policy represented by {policyNftId}.
|
|
61
|
+
/// optionally collects premiums and activates the policy.
|
|
62
|
+
/// - premium payment is only attempted if requirePremiumPayment is set to true
|
|
63
|
+
/// - activation is only done if activateAt is a non-zero timestamp
|
|
64
|
+
/// an application can only be underwritten in applied state
|
|
65
|
+
/// only the related product may underwrite an application
|
|
68
66
|
function underwrite(
|
|
69
67
|
NftId policyNftId,
|
|
70
68
|
bool requirePremiumPayment,
|
|
71
69
|
Timestamp activateAt
|
|
72
70
|
) external;
|
|
73
71
|
|
|
74
|
-
// function decline(uint256 nftId) external;
|
|
75
|
-
// function expire(uint256 nftId) external;
|
|
76
|
-
|
|
77
72
|
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
|
78
73
|
|
|
79
74
|
function activate(NftId policyNftId, Timestamp activateAt) external;
|
|
80
75
|
|
|
81
|
-
|
|
82
76
|
function close(NftId nftId) external;
|
|
83
77
|
|
|
84
78
|
// function createClaim(uint256 nftId, uint256 claimAmount) external;
|
|
@@ -41,7 +41,10 @@ import {IPoolService} from "./IPoolService.sol";
|
|
|
41
41
|
import {IBundleService} from "./IBundleService.sol";
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
contract PolicyService is
|
|
44
|
+
contract PolicyService is
|
|
45
|
+
ComponentService,
|
|
46
|
+
IPolicyService
|
|
47
|
+
{
|
|
45
48
|
using NftIdLib for NftId;
|
|
46
49
|
using TimestampLib for Timestamp;
|
|
47
50
|
|
|
@@ -62,12 +65,12 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
|
62
65
|
address initialOwner;
|
|
63
66
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
initializeService(registryAddress, owner);
|
|
66
69
|
|
|
67
|
-
_poolService = IPoolService(
|
|
68
|
-
_bundleService = IBundleService(
|
|
70
|
+
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
|
|
71
|
+
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getMajorVersion()));
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
registerInterface(type(IPolicyService).interfaceId);
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
|
|
@@ -81,6 +84,7 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
|
81
84
|
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
|
82
85
|
product = Product(productInfo.objectAddress);
|
|
83
86
|
}
|
|
87
|
+
|
|
84
88
|
// TODO: no access restrictions
|
|
85
89
|
function calculatePremium(
|
|
86
90
|
RiskId riskId,
|
|
@@ -92,7 +96,7 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
|
92
96
|
)
|
|
93
97
|
public
|
|
94
98
|
view
|
|
95
|
-
override
|
|
99
|
+
virtual override
|
|
96
100
|
returns (
|
|
97
101
|
uint256 premiumAmount,
|
|
98
102
|
uint256 productFeeAmount,
|
|
@@ -177,7 +181,11 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
|
177
181
|
bytes memory applicationData,
|
|
178
182
|
NftId bundleNftId,
|
|
179
183
|
ReferralId referralId
|
|
180
|
-
)
|
|
184
|
+
)
|
|
185
|
+
external
|
|
186
|
+
virtual override
|
|
187
|
+
returns (NftId policyNftId)
|
|
188
|
+
{
|
|
181
189
|
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
|
182
190
|
// TODO: add validations (see create bundle in pool service)
|
|
183
191
|
|
|
@@ -236,118 +244,78 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
|
236
244
|
internal
|
|
237
245
|
view
|
|
238
246
|
returns (
|
|
247
|
+
NftId poolNftId,
|
|
239
248
|
NftId bundleNftId,
|
|
240
249
|
IBundle.BundleInfo memory bundleInfo,
|
|
241
250
|
uint256 collateralAmount
|
|
242
251
|
)
|
|
243
252
|
{
|
|
244
253
|
// check match between policy and bundle (via pool)
|
|
254
|
+
poolNftId = productSetupInfo.poolNftId;
|
|
245
255
|
bundleNftId = policyInfo.bundleNftId;
|
|
246
256
|
bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
|
247
|
-
require(bundleInfo.poolNftId ==
|
|
257
|
+
require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
|
|
248
258
|
|
|
249
259
|
// calculate required collateral
|
|
250
|
-
NftId poolNftId = productSetupInfo.poolNftId;
|
|
251
260
|
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
|
252
261
|
|
|
253
262
|
// obtain remaining return values
|
|
263
|
+
// TODO required collateral amount should be calculated by pool service, not policy service
|
|
254
264
|
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
|
255
265
|
}
|
|
256
266
|
|
|
257
|
-
function _lockCollateralInBundle(
|
|
258
|
-
IInstance instance,
|
|
259
|
-
NftId bundleNftId,
|
|
260
|
-
IBundle.BundleInfo memory bundleInfo,
|
|
261
|
-
NftId policyNftId,
|
|
262
|
-
uint256 collateralAmount
|
|
263
|
-
)
|
|
264
|
-
internal
|
|
265
|
-
returns (IBundle.BundleInfo memory)
|
|
266
|
-
{
|
|
267
|
-
bundleInfo.lockedAmount += collateralAmount;
|
|
268
|
-
// TODO: track policy associated to bundle in bundlemanager (tbd) and how much is locked for it
|
|
269
|
-
return bundleInfo;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function _underwriteByPool(
|
|
273
|
-
NftId poolNftId,
|
|
274
|
-
NftId policyNftId,
|
|
275
|
-
IPolicy.PolicyInfo memory policyInfo,
|
|
276
|
-
bytes memory bundleFilter,
|
|
277
|
-
uint256 collateralAmount
|
|
278
|
-
)
|
|
279
|
-
internal
|
|
280
|
-
{
|
|
281
|
-
address poolAddress = getRegistry().getObjectInfo(poolNftId).objectAddress;
|
|
282
|
-
IPoolComponent pool = IPoolComponent(poolAddress);
|
|
283
|
-
pool.underwrite(
|
|
284
|
-
policyNftId,
|
|
285
|
-
policyInfo.applicationData,
|
|
286
|
-
bundleFilter,
|
|
287
|
-
collateralAmount);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
267
|
|
|
291
|
-
function
|
|
268
|
+
function decline(
|
|
292
269
|
NftId policyNftId
|
|
293
270
|
)
|
|
294
271
|
external
|
|
295
272
|
override
|
|
296
273
|
{
|
|
297
|
-
require(false, "ERROR:PRS-
|
|
274
|
+
require(false, "ERROR:PRS-235:NOT_YET_IMPLEMENTED");
|
|
298
275
|
}
|
|
299
276
|
|
|
300
277
|
|
|
278
|
+
/// @dev underwites application which includes the locking of the required collateral from the pool.
|
|
301
279
|
function underwrite(
|
|
302
|
-
NftId policyNftId
|
|
280
|
+
NftId applicationNftId, // = policyNftId
|
|
303
281
|
bool requirePremiumPayment,
|
|
304
282
|
Timestamp activateAt
|
|
305
283
|
)
|
|
306
284
|
external
|
|
307
|
-
override
|
|
285
|
+
virtual override
|
|
308
286
|
{
|
|
309
287
|
// check caller is registered product
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
288
|
+
IInstance instance;
|
|
289
|
+
InstanceReader instanceReader;
|
|
290
|
+
NftId productNftId;
|
|
291
|
+
{
|
|
292
|
+
IRegistry.ObjectInfo memory productInfo;
|
|
293
|
+
(productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
|
294
|
+
instanceReader = instance.getInstanceReader();
|
|
295
|
+
productNftId = productInfo.nftId;
|
|
296
|
+
}
|
|
315
297
|
|
|
316
|
-
// check
|
|
317
|
-
|
|
318
|
-
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
|
298
|
+
// check policy matches with calling product
|
|
299
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(applicationNftId);
|
|
319
300
|
require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
|
320
|
-
require(instanceReader.getPolicyState(policyNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
|
321
301
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
uint256 collateralAmount;
|
|
325
|
-
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
|
326
|
-
{
|
|
327
|
-
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
|
|
328
|
-
IBundle.BundleInfo memory bundleInfo;
|
|
329
|
-
|
|
330
|
-
(
|
|
331
|
-
bundleNftId,
|
|
332
|
-
bundleInfo,
|
|
333
|
-
collateralAmount
|
|
334
|
-
) = _getAndVerifyUnderwritingSetup(
|
|
335
|
-
instance,
|
|
336
|
-
instanceReader,
|
|
337
|
-
policyInfo,
|
|
338
|
-
productSetupInfo
|
|
339
|
-
);
|
|
340
|
-
}
|
|
302
|
+
// check policy is in state applied
|
|
303
|
+
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
|
341
304
|
|
|
342
|
-
|
|
343
|
-
|
|
305
|
+
(
|
|
306
|
+
NftId poolNftId,
|
|
307
|
+
NftId bundleNftId,
|
|
308
|
+
IBundle.BundleInfo memory bundleInfo,
|
|
309
|
+
uint256 collateralAmount
|
|
310
|
+
) = _getAndVerifyUnderwritingSetup(
|
|
344
311
|
instance,
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
StateId newPolicyState = UNDERWRITTEN();
|
|
312
|
+
instanceReader,
|
|
313
|
+
policyInfo,
|
|
314
|
+
instanceReader.getProductSetupInfo(productNftId)
|
|
315
|
+
);
|
|
350
316
|
|
|
317
|
+
StateId newPolicyState = UNDERWRITTEN();
|
|
318
|
+
|
|
351
319
|
// optional activation of policy
|
|
352
320
|
if(activateAt > zeroTimestamp()) {
|
|
353
321
|
newPolicyState = ACTIVE();
|
|
@@ -355,38 +323,56 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
|
355
323
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
|
356
324
|
}
|
|
357
325
|
|
|
326
|
+
// lock bundle collateral
|
|
327
|
+
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
|
328
|
+
|
|
358
329
|
// optional collection of premium
|
|
359
330
|
if(requirePremiumPayment) {
|
|
360
331
|
netPremiumAmount = _processPremiumByTreasury(
|
|
361
332
|
instance,
|
|
362
|
-
|
|
363
|
-
|
|
333
|
+
productNftId,
|
|
334
|
+
applicationNftId,
|
|
364
335
|
policyInfo.premiumAmount);
|
|
365
336
|
|
|
366
337
|
policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
|
|
367
338
|
}
|
|
368
339
|
|
|
369
|
-
|
|
370
|
-
|
|
340
|
+
// lock collateral and update bundle book keeping
|
|
341
|
+
// TODO introduct indirection via pool service?
|
|
342
|
+
// well pool would only need to be involved when a part of the collateral
|
|
343
|
+
// is provided by a "re insurance policy" of the pool
|
|
344
|
+
// but then again the policiy would likely best be attached to the bundle. really? why?
|
|
345
|
+
// retention level: fraction of sum insured that product will cover from pool funds directly
|
|
346
|
+
// eg retention level 30%, payouts up to 30% of the sum insured will be made from the product's pool directly
|
|
347
|
+
// for the remaining 70% the pool owns a policy that will cover claims that exceed the 30% of the sum insured
|
|
348
|
+
// open points:
|
|
349
|
+
// - do we need a link of a bundle to this policy or is it enough to know that the pool has an active policy?
|
|
350
|
+
// - when to buy such policies and for which amount? manual trigger or link to bundle creation and/or funding?
|
|
351
|
+
bundleInfo = _bundleService.lockCollateral(
|
|
352
|
+
instance,
|
|
353
|
+
applicationNftId,
|
|
354
|
+
bundleNftId,
|
|
355
|
+
collateralAmount,
|
|
356
|
+
netPremiumAmount);
|
|
357
|
+
|
|
358
|
+
instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
|
|
371
359
|
|
|
372
|
-
//
|
|
373
|
-
{
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
collateralAmount
|
|
383
|
-
);
|
|
384
|
-
}
|
|
360
|
+
// also verify/confirm application by pool if necessary
|
|
361
|
+
if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
|
|
362
|
+
IPoolComponent pool = IPoolComponent(
|
|
363
|
+
getRegistry().getObjectInfo(poolNftId).objectAddress);
|
|
364
|
+
|
|
365
|
+
pool.verifyApplication(
|
|
366
|
+
applicationNftId,
|
|
367
|
+
policyInfo.applicationData,
|
|
368
|
+
bundleInfo.filter,
|
|
369
|
+
collateralAmount);
|
|
385
370
|
}
|
|
386
371
|
|
|
387
372
|
// TODO: add logging
|
|
388
373
|
}
|
|
389
374
|
|
|
375
|
+
|
|
390
376
|
function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
|
|
391
377
|
UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
|
|
392
378
|
UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
|
|
@@ -30,6 +30,7 @@ import {IRegistryService} from "../../registry/IRegistryService.sol";
|
|
|
30
30
|
import {InstanceService} from "../InstanceService.sol";
|
|
31
31
|
import {InstanceReader} from "../InstanceReader.sol";
|
|
32
32
|
import {IComponent} from "../../components/IComponent.sol";
|
|
33
|
+
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
|
33
34
|
|
|
34
35
|
string constant POOL_SERVICE_NAME = "PoolService";
|
|
35
36
|
|
|
@@ -54,9 +55,8 @@ contract PoolService is
|
|
|
54
55
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
|
55
56
|
// TODO while PoolService is not deployed in PoolServiceManager constructor
|
|
56
57
|
// owner is PoolServiceManager deployer
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_registerInterface(type(IPoolService).interfaceId);
|
|
58
|
+
initializeService(registryAddress, owner);
|
|
59
|
+
registerInterface(type(IPoolService).interfaceId);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function getDomain() public pure override(Service, IService) returns(ObjectType) {
|
|
@@ -68,7 +68,7 @@ contract PoolService is
|
|
|
68
68
|
returns(NftId poolNftId)
|
|
69
69
|
{
|
|
70
70
|
(
|
|
71
|
-
IComponent
|
|
71
|
+
IComponent component,
|
|
72
72
|
address owner,
|
|
73
73
|
IInstance instance,
|
|
74
74
|
NftId instanceNftId
|
|
@@ -77,47 +77,14 @@ contract PoolService is
|
|
|
77
77
|
POOL(),
|
|
78
78
|
POOL_OWNER_ROLE());
|
|
79
79
|
|
|
80
|
-
(
|
|
81
|
-
|
|
82
|
-
bytes memory data
|
|
83
|
-
) = getRegistryService().registerPool(pool, owner);
|
|
80
|
+
IPoolComponent pool = IPoolComponent(poolAddress);
|
|
81
|
+
IRegistry.ObjectInfo memory poolInfo = getRegistryService().registerPool(pool, owner);
|
|
84
82
|
pool.linkToRegisteredNftId();
|
|
85
83
|
poolNftId = poolInfo.nftId;
|
|
86
84
|
|
|
87
|
-
(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
) = _decodeAndVerifyPoolData(data);
|
|
91
|
-
instance.createPoolSetup(poolNftId, initialSetup);
|
|
92
|
-
|
|
93
|
-
getInstanceService().createTarget(instanceNftId, poolAddress, name);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function _decodeAndVerifyPoolData(bytes memory data)
|
|
97
|
-
internal
|
|
98
|
-
returns(string memory name, ISetup.PoolSetupInfo memory setup)
|
|
99
|
-
{
|
|
100
|
-
(name, setup) = abi.decode(
|
|
101
|
-
data,
|
|
102
|
-
(string, ISetup.PoolSetupInfo)
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
// TODO add checks
|
|
106
|
-
/*IRegistry _registry = getRegistry();
|
|
107
|
-
|
|
108
|
-
if(wallet == address(0)) {
|
|
109
|
-
revert WalletIsZero();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
ObjectType tokenType = _registry.getObjectInfo(address(token)).objectType;
|
|
113
|
-
|
|
114
|
-
if(tokenType != TOKEN()) {
|
|
115
|
-
revert InvalidToken();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if(UFixedLib.eqz(info.collateralizationLevel)) {
|
|
119
|
-
revert CollateralizationLevelIsZero();
|
|
120
|
-
}*/
|
|
85
|
+
instance.createPoolSetup(poolNftId, pool.getSetupInfo());
|
|
86
|
+
getInstanceService().createGifTarget(instanceNftId, poolAddress, pool.getName());
|
|
87
|
+
getInstanceService().grantPoolDefaultPermissions(instanceNftId, poolAddress, pool.getName());
|
|
121
88
|
}
|
|
122
89
|
|
|
123
90
|
function setFees(
|