@etherisc/gif-next 0.0.2-e922e07-736 → 0.0.2-e9a637d-547
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 +0 -71
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +68 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +68 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +158 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +158 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +184 -149
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +158 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +114 -189
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +68 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +214 -2063
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +196 -51
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +363 -2832
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +491 -127
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +101 -167
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +333 -171
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +75 -23
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2677 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +85 -30
- 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 +40 -10
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +56 -73
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
- 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 +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +124 -53
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +21 -13
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +384 -249
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +74 -14
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +104 -41
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +11 -7
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +195 -121
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +51 -47
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +80 -14
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +212 -186
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +80 -14
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +101 -24
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +90 -24
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +511 -14
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +136 -65
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -19
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +561 -51
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +24 -12
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +114 -51
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -24
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
- 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 +17 -36
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- 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/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +80 -14
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +86 -15
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.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 +6 -6
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +101 -26
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +4 -0
- package/artifacts/contracts/types/Amount.sol/AmountLib.json +161 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.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/Fee.sol/FeeLib.json +40 -9
- 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 +17 -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/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/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- 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/Seconds.sol/SecondsLib.dbg.json +1 -1
- 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/Timestamp.sol/TimestampLib.json +2 -2
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
- package/contracts/components/Component.sol +42 -10
- package/contracts/components/IComponent.sol +9 -1
- package/contracts/components/IPoolComponent.sol +5 -43
- package/contracts/components/Pool.sol +47 -122
- package/contracts/components/Product.sol +4 -0
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +6 -4
- package/contracts/instance/Cloneable.sol +7 -2
- package/contracts/instance/IInstance.sol +23 -55
- package/contracts/instance/IInstanceService.sol +31 -6
- package/contracts/instance/Instance.sol +90 -182
- package/contracts/instance/InstanceAccessManager.sol +402 -159
- package/contracts/instance/InstanceReader.sol +12 -12
- package/contracts/instance/InstanceService.sol +287 -246
- package/contracts/instance/InstanceStore.sol +219 -0
- package/contracts/instance/ObjectManager.sol +6 -8
- package/contracts/instance/base/ComponentService.sol +17 -30
- package/contracts/instance/base/KeyValueStore.sol +13 -5
- package/contracts/instance/base/Lifecycle.sol +11 -2
- package/contracts/instance/module/IAccess.sol +21 -14
- package/contracts/instance/module/IBundle.sol +6 -4
- package/contracts/instance/module/IComponents.sol +41 -0
- package/contracts/instance/module/ISetup.sol +3 -16
- package/contracts/instance/service/ApplicationService.sol +18 -16
- package/contracts/instance/service/BundleService.sol +213 -81
- package/contracts/instance/service/ClaimService.sol +3 -3
- package/contracts/instance/service/DistributionService.sol +57 -70
- package/contracts/instance/service/IBundleService.sol +63 -25
- package/contracts/instance/service/IDistributionService.sol +1 -0
- package/contracts/instance/service/IPoolService.sol +82 -3
- package/contracts/instance/service/PolicyService.sol +68 -100
- package/contracts/instance/service/PoolService.sol +214 -20
- package/contracts/instance/service/ProductService.sol +34 -58
- package/contracts/registry/ChainNft.sol +8 -0
- package/contracts/registry/IRegistry.sol +2 -0
- package/contracts/registry/IRegistryService.sol +4 -3
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +23 -20
- package/contracts/registry/RegistryService.sol +10 -11
- package/contracts/registry/ReleaseManager.sol +20 -18
- package/contracts/shared/IService.sol +4 -6
- package/contracts/shared/Service.sol +21 -7
- package/contracts/shared/TokenHandler.sol +11 -5
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/Amount.sol +60 -0
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/Fee.sol +13 -5
- package/contracts/types/NftId.sol +8 -0
- package/contracts/types/ObjectType.sol +1 -0
- package/contracts/types/RoleId.sol +6 -4
- package/contracts/types/StateId.sol +1 -0
- package/contracts/types/Timestamp.sol +1 -0
- package/contracts/types/UFixed.sol +1 -0
- package/contracts/types/Version.sol +1 -0
- package/package.json +1 -1
@@ -3,9 +3,12 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
5
|
import {Product} from "../../components/Product.sol";
|
6
|
-
import {
|
6
|
+
import {IComponents} from "../module/IComponents.sol";
|
7
|
+
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
7
8
|
import {IInstance} from "../IInstance.sol";
|
8
9
|
import {IPolicy} from "../module/IPolicy.sol";
|
10
|
+
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
11
|
+
import {IRisk} from "../module/IRisk.sol";
|
9
12
|
import {IBundle} from "../module/IBundle.sol";
|
10
13
|
import {ISetup} from "../module/ISetup.sol";
|
11
14
|
|
@@ -17,6 +20,7 @@ import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE} fr
|
|
17
20
|
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
|
18
21
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
19
22
|
import {StateId} from "../../types/StateId.sol";
|
23
|
+
import {VersionPart} from "../../types/Version.sol";
|
20
24
|
|
21
25
|
import {ComponentService} from "../base/ComponentService.sol";
|
22
26
|
import {IApplicationService} from "./IApplicationService.sol";
|
@@ -55,56 +59,54 @@ contract PolicyService is
|
|
55
59
|
address initialOwner;
|
56
60
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
57
61
|
|
58
|
-
initializeService(registryAddress, owner);
|
62
|
+
initializeService(registryAddress, address(0), owner);
|
59
63
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
VersionPart majorVersion = getVersion().toMajorPart();
|
65
|
+
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), majorVersion));
|
66
|
+
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), majorVersion));
|
67
|
+
_applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), majorVersion));
|
68
|
+
_distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), majorVersion));
|
64
69
|
|
65
70
|
registerInterface(type(IPolicyService).interfaceId);
|
66
71
|
}
|
67
72
|
|
68
73
|
|
69
|
-
function getDomain() public pure override
|
74
|
+
function getDomain() public pure override returns(ObjectType) {
|
70
75
|
return POLICY();
|
71
76
|
}
|
72
77
|
|
73
78
|
|
74
79
|
function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
|
75
80
|
IRegistry.ObjectInfo memory productInfo;
|
76
|
-
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
81
|
+
(, productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
77
82
|
product = Product(productInfo.objectAddress);
|
78
83
|
}
|
79
84
|
|
80
|
-
function _getAndVerifyUnderwritingSetup(
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
{
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
// TODO required collateral amount should be calculated by pool service, not policy service
|
106
|
-
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
107
|
-
}
|
85
|
+
// function _getAndVerifyUnderwritingSetup(
|
86
|
+
// IInstance instance,
|
87
|
+
// InstanceReader instanceReader,
|
88
|
+
// IPolicy.PolicyInfo memory policyInfo,
|
89
|
+
// ISetup.ProductSetupInfo memory productSetupInfo
|
90
|
+
// )
|
91
|
+
// internal
|
92
|
+
// view
|
93
|
+
// returns (
|
94
|
+
// NftId poolNftId,
|
95
|
+
// IComponents.PoolInfo memory poolInfo,
|
96
|
+
// NftId bundleNftId,
|
97
|
+
// IBundle.BundleInfo memory bundleInfo
|
98
|
+
// )
|
99
|
+
// {
|
100
|
+
// // check match between policy and bundle (via pool)
|
101
|
+
// poolNftId = productSetupInfo.poolNftId;
|
102
|
+
// bundleNftId = policyInfo.bundleNftId;
|
103
|
+
// bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
104
|
+
// require(bundleInfo.poolNftId == poolNftId, "BUNDLE_POOL_MISMATCH");
|
105
|
+
|
106
|
+
// // calculate required collateral
|
107
|
+
// IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
108
|
+
// poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
109
|
+
// }
|
108
110
|
|
109
111
|
|
110
112
|
function decline(
|
@@ -127,42 +129,23 @@ contract PolicyService is
|
|
127
129
|
virtual override
|
128
130
|
{
|
129
131
|
// check caller is registered product
|
130
|
-
IInstance instance;
|
131
|
-
InstanceReader instanceReader;
|
132
|
-
NftId productNftId;
|
133
|
-
{
|
134
|
-
IRegistry.ObjectInfo memory productInfo;
|
135
|
-
(productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
136
|
-
instanceReader = instance.getInstanceReader();
|
137
|
-
productNftId = productInfo.nftId;
|
138
|
-
}
|
132
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
133
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
139
134
|
|
140
135
|
// check policy matches with calling product
|
141
|
-
IPolicy.PolicyInfo memory
|
142
|
-
require(
|
136
|
+
IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
|
137
|
+
require(applicationInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
143
138
|
|
144
139
|
// check policy is in state applied
|
145
140
|
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
146
141
|
|
147
|
-
(
|
148
|
-
NftId poolNftId,
|
149
|
-
NftId bundleNftId,
|
150
|
-
IBundle.BundleInfo memory bundleInfo,
|
151
|
-
uint256 collateralAmount
|
152
|
-
) = _getAndVerifyUnderwritingSetup(
|
153
|
-
instance,
|
154
|
-
instanceReader,
|
155
|
-
policyInfo,
|
156
|
-
instanceReader.getProductSetupInfo(productNftId)
|
157
|
-
);
|
158
|
-
|
159
142
|
StateId newPolicyState = UNDERWRITTEN();
|
160
143
|
|
161
144
|
// optional activation of policy
|
162
145
|
if(activateAt > zeroTimestamp()) {
|
163
146
|
newPolicyState = ACTIVE();
|
164
|
-
|
165
|
-
|
147
|
+
applicationInfo.activatedAt = activateAt;
|
148
|
+
applicationInfo.expiredAt = activateAt.addSeconds(applicationInfo.lifetime);
|
166
149
|
}
|
167
150
|
|
168
151
|
// lock bundle collateral
|
@@ -173,43 +156,25 @@ contract PolicyService is
|
|
173
156
|
netPremiumAmount = _processPremiumByTreasury(
|
174
157
|
instance,
|
175
158
|
applicationNftId,
|
176
|
-
|
159
|
+
applicationInfo.premiumAmount);
|
177
160
|
|
178
|
-
|
161
|
+
applicationInfo.premiumPaidAmount += applicationInfo.premiumAmount;
|
179
162
|
}
|
180
163
|
|
181
|
-
//
|
182
|
-
|
183
|
-
|
184
|
-
//
|
185
|
-
//
|
186
|
-
// retention level: fraction of sum insured that product will cover from pool funds directly
|
164
|
+
// store updated policy info
|
165
|
+
instance.getInstanceStore().updatePolicy(applicationNftId, applicationInfo, newPolicyState);
|
166
|
+
|
167
|
+
// lock collateral and update pool and bundle book keeping
|
168
|
+
// pool retention level: fraction of sum insured that product will cover from pool funds directly
|
187
169
|
// eg retention level 30%, payouts up to 30% of the sum insured will be made from the product's pool directly
|
188
170
|
// for the remaining 70% the pool owns a policy that will cover claims that exceed the 30% of the sum insured
|
189
|
-
//
|
190
|
-
|
191
|
-
// - when to buy such policies and for which amount? manual trigger or link to bundle creation and/or funding?
|
192
|
-
bundleInfo = _bundleService.lockCollateral(
|
171
|
+
// might also call pool component (for isVerifyingApplications pools)
|
172
|
+
_poolService.lockCollateral(
|
193
173
|
instance,
|
174
|
+
productNftId,
|
194
175
|
applicationNftId,
|
195
|
-
|
196
|
-
|
197
|
-
netPremiumAmount);
|
198
|
-
|
199
|
-
instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
|
200
|
-
|
201
|
-
// also verify/confirm application by pool if necessary
|
202
|
-
if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
|
203
|
-
IPoolComponent pool = IPoolComponent(
|
204
|
-
getRegistry().getObjectInfo(poolNftId).objectAddress);
|
205
|
-
|
206
|
-
pool.verifyApplication(
|
207
|
-
applicationNftId,
|
208
|
-
policyInfo.applicationData,
|
209
|
-
bundleNftId,
|
210
|
-
bundleInfo.filter,
|
211
|
-
collateralAmount);
|
212
|
-
}
|
176
|
+
applicationInfo,
|
177
|
+
netPremiumAmount); // for pool book keeping (fee + additional capital)
|
213
178
|
|
214
179
|
// TODO: add logging
|
215
180
|
}
|
@@ -223,7 +188,7 @@ contract PolicyService is
|
|
223
188
|
|
224
189
|
function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
|
225
190
|
// check caller is registered product
|
226
|
-
(
|
191
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
227
192
|
InstanceReader instanceReader = instance.getInstanceReader();
|
228
193
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
229
194
|
|
@@ -241,7 +206,7 @@ contract PolicyService is
|
|
241
206
|
policyInfo.premiumPaidAmount += unpaidPremiumAmount;
|
242
207
|
|
243
208
|
_bundleService.increaseBalance(instance, policyInfo.bundleNftId, netPremiumAmount);
|
244
|
-
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
209
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
245
210
|
|
246
211
|
if(activateAt.gtz() && policyInfo.activatedAt.eqz()) {
|
247
212
|
activate(policyNftId, activateAt);
|
@@ -252,7 +217,7 @@ contract PolicyService is
|
|
252
217
|
|
253
218
|
function activate(NftId policyNftId, Timestamp activateAt) public override {
|
254
219
|
// check caller is registered product
|
255
|
-
(
|
220
|
+
(,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
256
221
|
InstanceReader instanceReader = instance.getInstanceReader();
|
257
222
|
|
258
223
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
@@ -264,7 +229,7 @@ contract PolicyService is
|
|
264
229
|
policyInfo.activatedAt = activateAt;
|
265
230
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
266
231
|
|
267
|
-
instance.updatePolicy(policyNftId, policyInfo, ACTIVE());
|
232
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, ACTIVE());
|
268
233
|
|
269
234
|
// TODO: add logging
|
270
235
|
}
|
@@ -286,7 +251,7 @@ contract PolicyService is
|
|
286
251
|
external
|
287
252
|
override
|
288
253
|
{
|
289
|
-
(
|
254
|
+
(,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
290
255
|
InstanceReader instanceReader = instance.getInstanceReader();
|
291
256
|
|
292
257
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
@@ -318,8 +283,12 @@ contract PolicyService is
|
|
318
283
|
|
319
284
|
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
320
285
|
|
321
|
-
|
322
|
-
|
286
|
+
_poolService.releaseCollateral(
|
287
|
+
instance,
|
288
|
+
policyNftId,
|
289
|
+
policyInfo);
|
290
|
+
|
291
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, CLOSED());
|
323
292
|
}
|
324
293
|
|
325
294
|
function _getPoolNftId(
|
@@ -351,8 +320,7 @@ contract PolicyService is
|
|
351
320
|
IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
352
321
|
TokenHandler tokenHandler = productSetupInfo.tokenHandler;
|
353
322
|
address policyOwner = getRegistry().ownerOf(policyNftId);
|
354
|
-
|
355
|
-
address poolWallet = poolSetupInfo.wallet;
|
323
|
+
address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
|
356
324
|
IPolicy.Premium memory premium = _applicationService.calculatePremium(
|
357
325
|
productNftId,
|
358
326
|
policyInfo.riskId,
|
@@ -6,25 +6,30 @@ import {IRegistry} from "../../registry/IRegistry.sol";
|
|
6
6
|
import {IInstance} from "../../instance/IInstance.sol";
|
7
7
|
import {IBundle} from "../../instance/module/IBundle.sol";
|
8
8
|
import {TokenHandler} from "../../instance/module/ITreasury.sol";
|
9
|
-
import {
|
9
|
+
import {IComponents} from "../module/IComponents.sol";
|
10
10
|
import {IPolicy} from "../module/IPolicy.sol";
|
11
11
|
|
12
12
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
13
13
|
import {Versionable} from "../../shared/Versionable.sol";
|
14
14
|
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
15
15
|
|
16
|
+
import {Amount} from "../../types/Amount.sol";
|
17
|
+
import {Fee, FeeLib} from "../../types/Fee.sol";
|
16
18
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
17
19
|
import {ObjectType, POOL, BUNDLE} from "../../types/ObjectType.sol";
|
18
|
-
import {POOL_OWNER_ROLE, RoleId} from "../../types/RoleId.sol";
|
20
|
+
import {PUBLIC_ROLE, POOL_OWNER_ROLE, POLICY_SERVICE_ROLE, RoleId} from "../../types/RoleId.sol";
|
19
21
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
20
22
|
import {Version, VersionLib} from "../../types/Version.sol";
|
21
23
|
import {KEEP_STATE, StateId} from "../../types/StateId.sol";
|
24
|
+
import {Seconds} from "../../types/Seconds.sol";
|
22
25
|
import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
26
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
23
27
|
|
24
28
|
import {IService} from "../../shared/IService.sol";
|
25
29
|
import {Service} from "../../shared/Service.sol";
|
26
30
|
import {BundleManager} from "../BundleManager.sol";
|
27
31
|
import {ComponentService} from "../base/ComponentService.sol";
|
32
|
+
import {IBundleService} from "./IBundleService.sol";
|
28
33
|
import {IPoolService} from "./IPoolService.sol";
|
29
34
|
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
30
35
|
import {InstanceService} from "../InstanceService.sol";
|
@@ -40,7 +45,7 @@ contract PoolService is
|
|
40
45
|
{
|
41
46
|
using NftIdLib for NftId;
|
42
47
|
|
43
|
-
|
48
|
+
IBundleService internal _bundleService;
|
44
49
|
|
45
50
|
function _initialize(
|
46
51
|
address owner,
|
@@ -55,11 +60,14 @@ contract PoolService is
|
|
55
60
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
56
61
|
// TODO while PoolService is not deployed in PoolServiceManager constructor
|
57
62
|
// owner is PoolServiceManager deployer
|
58
|
-
initializeService(registryAddress, owner);
|
63
|
+
initializeService(registryAddress, address(0), owner);
|
64
|
+
|
65
|
+
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getVersion().toMajorPart()));
|
66
|
+
|
59
67
|
registerInterface(type(IPoolService).interfaceId);
|
60
68
|
}
|
61
69
|
|
62
|
-
function getDomain() public pure override
|
70
|
+
function getDomain() public pure override returns(ObjectType) {
|
63
71
|
return POOL();
|
64
72
|
}
|
65
73
|
|
@@ -78,32 +86,218 @@ contract PoolService is
|
|
78
86
|
POOL_OWNER_ROLE());
|
79
87
|
|
80
88
|
IPoolComponent pool = IPoolComponent(poolAddress);
|
81
|
-
IRegistry.ObjectInfo memory
|
89
|
+
IRegistry.ObjectInfo memory registryInfo = getRegistryService().registerPool(pool, owner);
|
82
90
|
pool.linkToRegisteredNftId();
|
83
|
-
poolNftId =
|
91
|
+
poolNftId = registryInfo.nftId;
|
92
|
+
|
93
|
+
// amend component info with pool specific token handler
|
94
|
+
IComponents.ComponentInfo memory componentInfo = pool.getComponentInfo();
|
95
|
+
componentInfo.tokenHandler = new TokenHandler(address(componentInfo.token));
|
96
|
+
|
97
|
+
// save amended component info with instance
|
98
|
+
instance.getInstanceStore().createPoolSetup(poolNftId, componentInfo);
|
99
|
+
|
100
|
+
bytes4[][] memory selectors = new bytes4[][](2);
|
101
|
+
selectors[0] = new bytes4[](1);
|
102
|
+
selectors[1] = new bytes4[](1);
|
103
|
+
|
104
|
+
selectors[0][0] = IPoolComponent.setFees.selector;
|
105
|
+
selectors[1][0] = IPoolComponent.verifyApplication.selector;
|
106
|
+
|
107
|
+
RoleId[] memory roles = new RoleId[](2);
|
108
|
+
roles[0] = POOL_OWNER_ROLE();
|
109
|
+
roles[1] = POLICY_SERVICE_ROLE();
|
110
|
+
|
111
|
+
getInstanceService().createGifTarget(
|
112
|
+
instanceNftId,
|
113
|
+
poolAddress,
|
114
|
+
pool.getName(),
|
115
|
+
selectors,
|
116
|
+
roles);
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
function setMaxCapitalAmount(uint256 maxCapitalAmount)
|
121
|
+
external
|
122
|
+
virtual
|
123
|
+
{
|
124
|
+
(NftId poolNftId, IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
125
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
126
|
+
|
127
|
+
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
128
|
+
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
129
|
+
uint256 previousMaxCapitalAmount = poolInfo.maxCapitalAmount;
|
130
|
+
|
131
|
+
poolInfo.maxCapitalAmount = maxCapitalAmount;
|
132
|
+
componentInfo.data = abi.encode(poolInfo);
|
133
|
+
instance.getInstanceStore().updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
|
84
134
|
|
85
|
-
|
86
|
-
getInstanceService().createGifTarget(instanceNftId, poolAddress, pool.getName());
|
87
|
-
getInstanceService().grantPoolDefaultPermissions(instanceNftId, poolAddress, pool.getName());
|
135
|
+
emit LogPoolServiceMaxCapitalAmountUpdated(poolNftId, previousMaxCapitalAmount, maxCapitalAmount);
|
88
136
|
}
|
89
137
|
|
138
|
+
function setBundleOwnerRole(RoleId bundleOwnerRole)
|
139
|
+
external
|
140
|
+
virtual
|
141
|
+
{
|
142
|
+
(NftId poolNftId, IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
143
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
144
|
+
|
145
|
+
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
146
|
+
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
147
|
+
|
148
|
+
// bundle owner role may only be set once per pool
|
149
|
+
if(poolInfo.bundleOwnerRole != PUBLIC_ROLE()) {
|
150
|
+
revert ErrorPoolServiceBundleOwnerRoleAlreadySet(poolNftId);
|
151
|
+
}
|
152
|
+
|
153
|
+
poolInfo.bundleOwnerRole = bundleOwnerRole;
|
154
|
+
componentInfo.data = abi.encode(poolInfo);
|
155
|
+
instance.getInstanceStore().updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
|
156
|
+
|
157
|
+
emit LogPoolServiceBundleOwnerRoleSet(poolNftId, bundleOwnerRole);
|
158
|
+
}
|
159
|
+
|
160
|
+
|
90
161
|
function setFees(
|
91
162
|
Fee memory poolFee,
|
92
163
|
Fee memory stakingFee,
|
93
164
|
Fee memory performanceFee
|
94
165
|
)
|
95
166
|
external
|
96
|
-
|
167
|
+
virtual
|
97
168
|
{
|
98
|
-
(IRegistry.ObjectInfo memory
|
169
|
+
(NftId poolNftId, IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
99
170
|
InstanceReader instanceReader = instance.getInstanceReader();
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
171
|
+
|
172
|
+
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
173
|
+
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
174
|
+
|
175
|
+
poolInfo.poolFee = poolFee;
|
176
|
+
poolInfo.stakingFee = stakingFee;
|
177
|
+
poolInfo.performanceFee = performanceFee;
|
178
|
+
componentInfo.data = abi.encode(poolInfo);
|
179
|
+
instance.getInstanceStore().updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
|
180
|
+
|
181
|
+
// TODO add logging
|
108
182
|
}
|
183
|
+
|
184
|
+
|
185
|
+
function createBundle(
|
186
|
+
address owner, // initial bundle owner
|
187
|
+
Fee memory fee, // fees deducted from premium that go to bundle owner
|
188
|
+
Amount stakingAmount, // staking amount - staking fees result in initial bundle capital
|
189
|
+
Seconds lifetime, // initial duration for which new policies are covered
|
190
|
+
bytes calldata filter // optional use case specific criteria that define if a policy may be covered by this bundle
|
191
|
+
)
|
192
|
+
external
|
193
|
+
virtual
|
194
|
+
returns(NftId bundleNftId)
|
195
|
+
{
|
196
|
+
(NftId poolNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
197
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
198
|
+
|
199
|
+
// TODO add implementation that takes care of staking fees
|
200
|
+
Amount stakingAfterFeesAmount = stakingAmount;
|
201
|
+
|
202
|
+
bundleNftId = _bundleService.create(
|
203
|
+
instance,
|
204
|
+
poolNftId,
|
205
|
+
owner,
|
206
|
+
fee,
|
207
|
+
stakingAfterFeesAmount,
|
208
|
+
lifetime,
|
209
|
+
filter);
|
210
|
+
|
211
|
+
emit LogPoolServiceBundleCreated(instance.getNftId(), poolNftId, bundleNftId);
|
212
|
+
}
|
213
|
+
|
214
|
+
|
215
|
+
function closeBundle(NftId bundleNftId)
|
216
|
+
external
|
217
|
+
virtual
|
218
|
+
{
|
219
|
+
(NftId poolNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
220
|
+
|
221
|
+
// TODO book keeping for pool collateral released outside of retention level
|
222
|
+
|
223
|
+
// releasing collateral in bundle
|
224
|
+
_bundleService.close(instance, bundleNftId);
|
225
|
+
|
226
|
+
// TODO get performance fee for pool, transfer of remaining funds + bundle fees to bundle owner
|
227
|
+
|
228
|
+
emit LogPoolServiceBundleClosed(instance.getNftId(), poolNftId, bundleNftId);
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
function lockCollateral(
|
233
|
+
IInstance instance,
|
234
|
+
NftId productNftId,
|
235
|
+
NftId applicationNftId,
|
236
|
+
IPolicy.PolicyInfo memory applicationInfo,
|
237
|
+
uint256 premiumAmount // premium amount after product and distribution fees
|
238
|
+
)
|
239
|
+
external
|
240
|
+
virtual
|
241
|
+
// TODO add restricted and granting for policy service
|
242
|
+
{
|
243
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
244
|
+
NftId poolNftId = instanceReader.getProductSetupInfo(productNftId).poolNftId;
|
245
|
+
NftId bundleNftId = applicationInfo.bundleNftId;
|
246
|
+
|
247
|
+
// TODO move this check to application creation and don't repeat this here
|
248
|
+
// ensure that pool for bundle from application matches with pool for product of application
|
249
|
+
IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
250
|
+
if(bundleInfo.poolNftId != poolNftId) {
|
251
|
+
revert ErrorPoolServiceBundlePoolMismatch(bundleInfo.poolNftId, poolNftId);
|
252
|
+
}
|
253
|
+
|
254
|
+
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
255
|
+
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
256
|
+
|
257
|
+
// TODO add correct required collateral calculation (collateralization level mibht be != 1, retention level might be < 1)
|
258
|
+
uint256 collateralAmount = applicationInfo.sumInsuredAmount;
|
259
|
+
|
260
|
+
// TODO add correct net premium calculation (pool fee might be > 0)
|
261
|
+
uint256 premiumAfterPoolFeeAmount = premiumAmount;
|
262
|
+
|
263
|
+
// lock collateral amount from involvedd bundle
|
264
|
+
_bundleService.lockCollateral(
|
265
|
+
instance,
|
266
|
+
applicationNftId,
|
267
|
+
bundleNftId,
|
268
|
+
collateralAmount,
|
269
|
+
premiumAfterPoolFeeAmount);
|
270
|
+
|
271
|
+
// also verify/confirm application by pool if necessary
|
272
|
+
if(poolInfo.isVerifyingApplications) {
|
273
|
+
address poolAddress = getRegistry().getObjectInfo(poolNftId).objectAddress;
|
274
|
+
IPoolComponent(poolAddress).verifyApplication(
|
275
|
+
applicationNftId,
|
276
|
+
applicationInfo.applicationData,
|
277
|
+
bundleNftId,
|
278
|
+
bundleInfo.filter,
|
279
|
+
collateralAmount);
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
/// @dev releases the remaining collateral linked to the specified policy
|
285
|
+
/// may only be called by the policy service for unlocked pool components
|
286
|
+
function releaseCollateral(
|
287
|
+
IInstance instance,
|
288
|
+
NftId policyNftId,
|
289
|
+
IPolicy.PolicyInfo memory policyInfo
|
290
|
+
)
|
291
|
+
external
|
292
|
+
virtual
|
293
|
+
// TODO add restricted and granting for policy service
|
294
|
+
{
|
295
|
+
// release collateral from involved bundle
|
296
|
+
_bundleService.releaseCollateral(
|
297
|
+
instance,
|
298
|
+
policyNftId,
|
299
|
+
policyInfo.bundleNftId,
|
300
|
+
policyInfo.sumInsuredAmount);
|
301
|
+
}
|
302
|
+
|
109
303
|
}
|