@etherisc/gif-next 0.0.2-da0f894-204 → 0.0.2-db1e1e4-828
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -83
- 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 +64 -14
- 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 +150 -10
- 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 +127 -182
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +175 -51
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +215 -252
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +472 -126
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +102 -168
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +304 -171
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +71 -23
- 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 +145 -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 +356 -111
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +57 -45
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +101 -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 +250 -18
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +106 -19
- 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 +152 -60
- 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 +23 -4
- 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/Distribution.sol +0 -13
- package/contracts/components/IComponent.sol +9 -1
- package/contracts/components/IDistributionComponent.sol +0 -8
- 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 +16 -10
- package/contracts/instance/IInstanceService.sol +18 -5
- package/contracts/instance/Instance.sol +46 -9
- package/contracts/instance/InstanceAccessManager.sol +388 -158
- package/contracts/instance/InstanceReader.sol +8 -10
- package/contracts/instance/InstanceService.sol +184 -179
- 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 +4 -17
- package/contracts/instance/service/ApplicationService.sol +22 -18
- package/contracts/instance/service/BundleService.sol +209 -77
- package/contracts/instance/service/ClaimService.sol +3 -3
- package/contracts/instance/service/DistributionService.sol +118 -77
- package/contracts/instance/service/IApplicationService.sol +1 -0
- package/contracts/instance/service/IBundleService.sol +63 -25
- package/contracts/instance/service/IDistributionService.sol +14 -1
- package/contracts/instance/service/IPolicyService.sol +2 -0
- package/contracts/instance/service/IPoolService.sol +82 -3
- package/contracts/instance/service/PolicyService.sol +96 -138
- package/contracts/instance/service/PoolService.sol +214 -20
- package/contracts/instance/service/ProductService.sol +30 -53
- 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/Referral.sol +4 -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
@@ -2,45 +2,35 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
-
import {IProductComponent} from "../../components/IProductComponent.sol";
|
6
5
|
import {Product} from "../../components/Product.sol";
|
7
|
-
import {
|
6
|
+
import {IComponents} from "../module/IComponents.sol";
|
8
7
|
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
9
8
|
import {IInstance} from "../IInstance.sol";
|
10
9
|
import {IPolicy} from "../module/IPolicy.sol";
|
10
|
+
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
11
11
|
import {IRisk} from "../module/IRisk.sol";
|
12
12
|
import {IBundle} from "../module/IBundle.sol";
|
13
|
-
import {IProductService} from "./IProductService.sol";
|
14
|
-
import {ITreasury} from "../module/ITreasury.sol";
|
15
13
|
import {ISetup} from "../module/ISetup.sol";
|
16
14
|
|
17
15
|
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
18
16
|
|
19
|
-
import {IVersionable} from "../../shared/IVersionable.sol";
|
20
|
-
import {Versionable} from "../../shared/Versionable.sol";
|
21
|
-
|
22
|
-
import {Seconds} from "../../types/Seconds.sol";
|
23
17
|
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
24
18
|
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
25
|
-
import {
|
26
|
-
import {ObjectType, APPLICATION, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
|
19
|
+
import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
|
27
20
|
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
|
28
|
-
import {NftId, NftIdLib
|
29
|
-
import {Fee, FeeLib} from "../../types/Fee.sol";
|
30
|
-
import {ReferralId} from "../../types/Referral.sol";
|
31
|
-
import {RiskId} from "../../types/RiskId.sol";
|
21
|
+
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
32
22
|
import {StateId} from "../../types/StateId.sol";
|
33
|
-
import {
|
34
|
-
//import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
|
23
|
+
import {VersionPart} from "../../types/Version.sol";
|
35
24
|
|
36
|
-
import {IService} from "../../shared/IService.sol";
|
37
|
-
import {Service} from "../../shared/Service.sol";
|
38
25
|
import {ComponentService} from "../base/ComponentService.sol";
|
39
26
|
import {IApplicationService} from "./IApplicationService.sol";
|
40
|
-
import {
|
27
|
+
import {IBundleService} from "./IBundleService.sol";
|
28
|
+
import {IDistributionService} from "./IDistributionService.sol";
|
41
29
|
import {InstanceReader} from "../InstanceReader.sol";
|
30
|
+
import {IPolicyService} from "./IPolicyService.sol";
|
42
31
|
import {IPoolService} from "./IPoolService.sol";
|
43
|
-
import {
|
32
|
+
import {IService} from "../../shared/IService.sol";
|
33
|
+
import {Service} from "../../shared/Service.sol";
|
44
34
|
|
45
35
|
|
46
36
|
contract PolicyService is
|
@@ -53,6 +43,7 @@ contract PolicyService is
|
|
53
43
|
IPoolService internal _poolService;
|
54
44
|
IBundleService internal _bundleService;
|
55
45
|
IApplicationService internal _applicationService;
|
46
|
+
IDistributionService internal _distributionService;
|
56
47
|
|
57
48
|
event LogProductServiceSender(address sender);
|
58
49
|
|
@@ -68,56 +59,54 @@ contract PolicyService is
|
|
68
59
|
address initialOwner;
|
69
60
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
70
61
|
|
71
|
-
initializeService(registryAddress, owner);
|
62
|
+
initializeService(registryAddress, address(0), owner);
|
72
63
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
_applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(),
|
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));
|
77
69
|
|
78
70
|
registerInterface(type(IPolicyService).interfaceId);
|
79
71
|
}
|
80
72
|
|
81
73
|
|
82
|
-
function getDomain() public pure override
|
74
|
+
function getDomain() public pure override returns(ObjectType) {
|
83
75
|
return POLICY();
|
84
76
|
}
|
85
77
|
|
86
78
|
|
87
79
|
function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
|
88
80
|
IRegistry.ObjectInfo memory productInfo;
|
89
|
-
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
81
|
+
(, productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
90
82
|
product = Product(productInfo.objectAddress);
|
91
83
|
}
|
92
84
|
|
93
|
-
function _getAndVerifyUnderwritingSetup(
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
{
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
// TODO required collateral amount should be calculated by pool service, not policy service
|
119
|
-
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
120
|
-
}
|
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
|
+
// }
|
121
110
|
|
122
111
|
|
123
112
|
function decline(
|
@@ -140,42 +129,23 @@ contract PolicyService is
|
|
140
129
|
virtual override
|
141
130
|
{
|
142
131
|
// check caller is registered product
|
143
|
-
IInstance instance;
|
144
|
-
InstanceReader instanceReader;
|
145
|
-
NftId productNftId;
|
146
|
-
{
|
147
|
-
IRegistry.ObjectInfo memory productInfo;
|
148
|
-
(productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
149
|
-
instanceReader = instance.getInstanceReader();
|
150
|
-
productNftId = productInfo.nftId;
|
151
|
-
}
|
132
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
133
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
152
134
|
|
153
135
|
// check policy matches with calling product
|
154
|
-
IPolicy.PolicyInfo memory
|
155
|
-
require(
|
136
|
+
IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
|
137
|
+
require(applicationInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
156
138
|
|
157
139
|
// check policy is in state applied
|
158
140
|
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
159
141
|
|
160
|
-
(
|
161
|
-
NftId poolNftId,
|
162
|
-
NftId bundleNftId,
|
163
|
-
IBundle.BundleInfo memory bundleInfo,
|
164
|
-
uint256 collateralAmount
|
165
|
-
) = _getAndVerifyUnderwritingSetup(
|
166
|
-
instance,
|
167
|
-
instanceReader,
|
168
|
-
policyInfo,
|
169
|
-
instanceReader.getProductSetupInfo(productNftId)
|
170
|
-
);
|
171
|
-
|
172
142
|
StateId newPolicyState = UNDERWRITTEN();
|
173
143
|
|
174
144
|
// optional activation of policy
|
175
145
|
if(activateAt > zeroTimestamp()) {
|
176
146
|
newPolicyState = ACTIVE();
|
177
|
-
|
178
|
-
|
147
|
+
applicationInfo.activatedAt = activateAt;
|
148
|
+
applicationInfo.expiredAt = activateAt.addSeconds(applicationInfo.lifetime);
|
179
149
|
}
|
180
150
|
|
181
151
|
// lock bundle collateral
|
@@ -185,45 +155,26 @@ contract PolicyService is
|
|
185
155
|
if(requirePremiumPayment) {
|
186
156
|
netPremiumAmount = _processPremiumByTreasury(
|
187
157
|
instance,
|
188
|
-
productNftId,
|
189
158
|
applicationNftId,
|
190
|
-
|
159
|
+
applicationInfo.premiumAmount);
|
191
160
|
|
192
|
-
|
161
|
+
applicationInfo.premiumPaidAmount += applicationInfo.premiumAmount;
|
193
162
|
}
|
194
163
|
|
195
|
-
//
|
196
|
-
|
197
|
-
|
198
|
-
//
|
199
|
-
//
|
200
|
-
// retention level: fraction of sum insured that product will cover from pool funds directly
|
164
|
+
// store updated policy info
|
165
|
+
instance.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
|
201
169
|
// eg retention level 30%, payouts up to 30% of the sum insured will be made from the product's pool directly
|
202
170
|
// for the remaining 70% the pool owns a policy that will cover claims that exceed the 30% of the sum insured
|
203
|
-
//
|
204
|
-
|
205
|
-
// - when to buy such policies and for which amount? manual trigger or link to bundle creation and/or funding?
|
206
|
-
bundleInfo = _bundleService.lockCollateral(
|
171
|
+
// might also call pool component (for isVerifyingApplications pools)
|
172
|
+
_poolService.lockCollateral(
|
207
173
|
instance,
|
174
|
+
productNftId,
|
208
175
|
applicationNftId,
|
209
|
-
|
210
|
-
|
211
|
-
netPremiumAmount);
|
212
|
-
|
213
|
-
instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
|
214
|
-
|
215
|
-
// also verify/confirm application by pool if necessary
|
216
|
-
if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
|
217
|
-
IPoolComponent pool = IPoolComponent(
|
218
|
-
getRegistry().getObjectInfo(poolNftId).objectAddress);
|
219
|
-
|
220
|
-
pool.verifyApplication(
|
221
|
-
applicationNftId,
|
222
|
-
policyInfo.applicationData,
|
223
|
-
bundleNftId,
|
224
|
-
bundleInfo.filter,
|
225
|
-
collateralAmount);
|
226
|
-
}
|
176
|
+
applicationInfo,
|
177
|
+
netPremiumAmount); // for pool book keeping (fee + additional capital)
|
227
178
|
|
228
179
|
// TODO: add logging
|
229
180
|
}
|
@@ -237,7 +188,7 @@ contract PolicyService is
|
|
237
188
|
|
238
189
|
function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
|
239
190
|
// check caller is registered product
|
240
|
-
(
|
191
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
241
192
|
InstanceReader instanceReader = instance.getInstanceReader();
|
242
193
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
243
194
|
|
@@ -249,7 +200,6 @@ contract PolicyService is
|
|
249
200
|
|
250
201
|
uint256 netPremiumAmount = _processPremiumByTreasury(
|
251
202
|
instance,
|
252
|
-
productInfo.nftId,
|
253
203
|
policyNftId,
|
254
204
|
unpaidPremiumAmount);
|
255
205
|
|
@@ -267,7 +217,7 @@ contract PolicyService is
|
|
267
217
|
|
268
218
|
function activate(NftId policyNftId, Timestamp activateAt) public override {
|
269
219
|
// check caller is registered product
|
270
|
-
(
|
220
|
+
(,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
271
221
|
InstanceReader instanceReader = instance.getInstanceReader();
|
272
222
|
|
273
223
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
@@ -301,7 +251,7 @@ contract PolicyService is
|
|
301
251
|
external
|
302
252
|
override
|
303
253
|
{
|
304
|
-
(
|
254
|
+
(,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
305
255
|
InstanceReader instanceReader = instance.getInstanceReader();
|
306
256
|
|
307
257
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
@@ -333,7 +283,11 @@ contract PolicyService is
|
|
333
283
|
|
334
284
|
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
335
285
|
|
336
|
-
|
286
|
+
_poolService.releaseCollateral(
|
287
|
+
instance,
|
288
|
+
policyNftId,
|
289
|
+
policyInfo);
|
290
|
+
|
337
291
|
instance.updatePolicy(policyNftId, policyInfo, CLOSED());
|
338
292
|
}
|
339
293
|
|
@@ -353,7 +307,6 @@ contract PolicyService is
|
|
353
307
|
|
354
308
|
function _processPremiumByTreasury(
|
355
309
|
IInstance instance,
|
356
|
-
NftId productNftId,
|
357
310
|
NftId policyNftId,
|
358
311
|
uint256 premiumAmount
|
359
312
|
)
|
@@ -362,12 +315,12 @@ contract PolicyService is
|
|
362
315
|
{
|
363
316
|
// process token transfer(s)
|
364
317
|
if(premiumAmount > 0) {
|
318
|
+
NftId productNftId = getRegistry().getObjectInfo(policyNftId).parentNftId;
|
365
319
|
ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
|
366
320
|
IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
367
321
|
TokenHandler tokenHandler = productSetupInfo.tokenHandler;
|
368
322
|
address policyOwner = getRegistry().ownerOf(policyNftId);
|
369
|
-
|
370
|
-
address poolWallet = poolSetupInfo.wallet;
|
323
|
+
address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
|
371
324
|
IPolicy.Premium memory premium = _applicationService.calculatePremium(
|
372
325
|
productNftId,
|
373
326
|
policyInfo.riskId,
|
@@ -378,25 +331,30 @@ contract PolicyService is
|
|
378
331
|
policyInfo.referralId
|
379
332
|
);
|
380
333
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
//
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
334
|
+
if (premium.premiumAmount != premiumAmount) {
|
335
|
+
revert ErrorIPolicyServicePremiumMismatch(policyNftId, premiumAmount, premium.premiumAmount);
|
336
|
+
}
|
337
|
+
|
338
|
+
// move product fee to product wallet
|
339
|
+
address productWallet = productSetupInfo.wallet;
|
340
|
+
if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
|
341
|
+
revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
|
342
|
+
}
|
343
|
+
tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
|
344
|
+
|
345
|
+
// move distribution fee to distribution wallet
|
346
|
+
ISetup.DistributionSetupInfo memory distributionSetupInfo = instance.getInstanceReader().getDistributionSetupInfo(productSetupInfo.distributionNftId);
|
347
|
+
address distributionWallet = distributionSetupInfo.wallet;
|
348
|
+
uint256 distributionFeeAmountToTransfer = premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount;
|
349
|
+
tokenHandler.transfer(policyOwner, distributionWallet, distributionFeeAmountToTransfer);
|
350
|
+
_distributionService.processSale(productSetupInfo.distributionNftId, policyInfo.referralId, premium, distributionFeeAmountToTransfer);
|
351
|
+
|
352
|
+
// move netpremium to pool wallet
|
353
|
+
tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
|
354
|
+
|
355
|
+
// TODO: move pool related tokens too
|
356
|
+
// TODO: move bundle related tokens too
|
357
|
+
netPremiumAmount = premium.netPremiumAmount;
|
400
358
|
}
|
401
359
|
|
402
360
|
// TODO: add logging
|