@etherisc/gif-next 0.0.2-836e6e4-400 → 0.0.2-83e16a6-272
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 +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +853 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +874 -257
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +147 -103
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +791 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +655 -43
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +654 -5
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +590 -235
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +524 -161
- 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 +38 -62
- 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 +875 -128
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +122 -165
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +790 -437
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +103 -176
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +61 -97
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +387 -231
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +331 -82
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +175 -155
- 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 +24 -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 +858 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +657 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +394 -232
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +308 -79
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +743 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +637 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +441 -177
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +328 -71
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/{IComponentOwnerService.sol/IComponentOwnerService.json → IApplicationService.sol/IApplicationService.json} +187 -191
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +157 -204
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
- package/artifacts/contracts/{components/IBaseComponent.sol/IBaseComponent.json → instance/service/IClaimService.sol/IClaimService.json} +151 -137
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +184 -150
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +125 -217
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +16 -179
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +16 -179
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +384 -246
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +339 -86
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +209 -198
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +305 -76
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +209 -198
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +305 -76
- 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 +98 -5
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +104 -201
- 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 +112 -27
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +18 -18
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +209 -238
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +300 -81
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +70 -69
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +151 -50
- 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 +40 -29
- 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 +21 -34
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +48 -0
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +16 -179
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -152
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +120 -27
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +248 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +294 -61
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +129 -51
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +84 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +106 -160
- 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 -152
- 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 +129 -51
- 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 +127 -217
- 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 -190
- 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/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +100 -0
- 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/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +100 -0
- 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 +241 -0
- package/contracts/components/Distribution.sol +209 -64
- package/contracts/components/IComponent.sol +54 -0
- package/contracts/components/IDistributionComponent.sol +59 -3
- package/contracts/components/IPoolComponent.sol +50 -29
- package/contracts/components/IProductComponent.sol +7 -3
- package/contracts/components/Pool.sol +135 -152
- package/contracts/components/Product.sol +114 -121
- package/contracts/instance/BundleManager.sol +7 -11
- package/contracts/instance/IInstance.sol +42 -12
- package/contracts/instance/IInstanceService.sol +23 -2
- package/contracts/instance/Instance.sol +84 -69
- package/contracts/instance/InstanceAccessManager.sol +31 -38
- package/contracts/instance/InstanceReader.sol +3 -25
- package/contracts/instance/InstanceService.sol +234 -58
- package/contracts/instance/InstanceServiceManager.sol +1 -1
- package/contracts/instance/ObjectManager.sol +7 -24
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/module/IAccess.sol +4 -5
- package/contracts/instance/module/IPolicy.sol +4 -2
- package/contracts/instance/module/ISetup.sol +5 -4
- package/contracts/instance/service/ApplicationService.sol +268 -0
- package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
- package/contracts/instance/service/BundleService.sol +49 -11
- package/contracts/instance/service/BundleServiceManager.sol +1 -1
- package/contracts/instance/service/ClaimService.sol +151 -0
- package/contracts/instance/service/ClaimServiceManager.sol +35 -0
- package/contracts/instance/service/DistributionService.sol +206 -43
- package/contracts/instance/service/DistributionServiceManager.sol +1 -1
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +12 -3
- package/contracts/instance/service/IClaimService.sol +61 -0
- package/contracts/instance/service/IDistributionService.sol +53 -0
- package/contracts/instance/service/IPolicyService.sol +48 -46
- package/contracts/instance/service/PolicyService.sol +153 -182
- package/contracts/instance/service/PolicyServiceManager.sol +2 -2
- package/contracts/instance/service/PoolService.sol +24 -37
- package/contracts/instance/service/PoolServiceManager.sol +1 -1
- package/contracts/instance/service/ProductService.sol +99 -34
- package/contracts/instance/service/ProductServiceManager.sol +2 -2
- package/contracts/registry/IRegistry.sol +16 -8
- package/contracts/registry/IRegistryService.sol +19 -10
- package/contracts/registry/Registry.sol +120 -52
- package/contracts/registry/RegistryAccessManager.sol +31 -25
- package/contracts/registry/RegistryService.sol +94 -134
- package/contracts/registry/RegistryServiceManager.sol +13 -13
- package/contracts/registry/ReleaseManager.sol +94 -120
- package/contracts/registry/TokenRegistry.sol +19 -13
- package/contracts/shared/ERC165.sol +14 -12
- package/contracts/shared/INftOwnable.sol +11 -10
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +4 -6
- package/contracts/shared/IRegistryLinked.sol +12 -0
- package/contracts/shared/IVersionable.sol +4 -47
- package/contracts/shared/NftOwnable.sol +66 -80
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +100 -25
- package/contracts/shared/Registerable.sol +14 -30
- package/contracts/shared/RegistryLinked.sol +48 -0
- package/contracts/shared/Service.sol +19 -19
- package/contracts/shared/Versionable.sol +4 -92
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/ClaimId.sol +52 -0
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/ObjectType.sol +9 -5
- package/contracts/types/PayoutId.sol +54 -0
- package/contracts/types/RoleId.sol +5 -5
- package/package.json +3 -3
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
- package/contracts/components/BaseComponent.sol +0 -148
- package/contracts/components/IBaseComponent.sol +0 -32
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
- package/contracts/instance/IInstanceBase.sol +0 -26
- package/contracts/instance/InstanceBase.sol +0 -41
- package/contracts/instance/base/ComponentServiceBase.sol +0 -72
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -315
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -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
|
}
|
@@ -15,7 +15,53 @@ import {Fee} from "../../types/Fee.sol";
|
|
15
15
|
interface IPolicyService is IService {
|
16
16
|
|
17
17
|
error ErrorIPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
18
|
-
|
18
|
+
error ErrorIPolicyServicePremiumAlreadyPaid(NftId policyNftId, uint256 premiumPaidAmount);
|
19
|
+
error ErrorIPolicyServicePolicyNotActivated(NftId policyNftId);
|
20
|
+
error ErrorIPolicyServicePolicyAlreadyClosed(NftId policyNftId);
|
21
|
+
error ErrorIPolicyServicePolicyNotActive(NftId policyNftId, StateId state);
|
22
|
+
error ErrorIPolicyServicePremiumNotFullyPaid(NftId policyNftId, uint256 premiumAmount, uint256 premiumPaidAmount);
|
23
|
+
error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
24
|
+
error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
25
|
+
|
26
|
+
/// @dev declines an application represented by {policyNftId}
|
27
|
+
/// an application can only be declined in applied state
|
28
|
+
/// only the related product may decline an application
|
29
|
+
function decline(NftId policyNftId) external;
|
30
|
+
|
31
|
+
/// @dev underwrites the policy represented by {policyNftId}
|
32
|
+
/// sets the policy state to underwritten
|
33
|
+
/// may set the policy state to activated and set the activation date
|
34
|
+
/// optionally collects premiums and activates the policy.
|
35
|
+
/// - premium payment is only attempted if requirePremiumPayment is set to true
|
36
|
+
/// - activation is only done if activateAt is a non-zero timestamp
|
37
|
+
/// an application can only be underwritten in applied state
|
38
|
+
/// only the related product may underwrite an application
|
39
|
+
function underwrite(
|
40
|
+
NftId policyNftId,
|
41
|
+
bool requirePremiumPayment,
|
42
|
+
Timestamp activateAt
|
43
|
+
) external;
|
44
|
+
|
45
|
+
/// @dev collects the premium token for the specified policy
|
46
|
+
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
47
|
+
|
48
|
+
/// @dev activates the specified policy and sets the activation date in the policy metadata
|
49
|
+
/// to activate a policy it needs to be in underwritten state
|
50
|
+
function activate(NftId policyNftId, Timestamp activateAt) external;
|
51
|
+
|
52
|
+
/// @dev expires the specified policy and sets the expiry date in the policy metadata
|
53
|
+
/// to expire a policy it must be in active state, policies may be expired even when the predefined expiry date is still in the future
|
54
|
+
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
55
|
+
/// this function can only be called by a product. the policy needs to match with the calling product
|
56
|
+
function expire(NftId policyNftId) external;
|
57
|
+
|
58
|
+
/// @dev closes the specified policy and sets the closed data in the policy metadata
|
59
|
+
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
60
|
+
/// this function can only be called by a product. the policy needs to match with the calling product
|
61
|
+
function close(NftId policyNftId) external;
|
62
|
+
|
63
|
+
/// @dev calculates the total premium amount for the specified attributes
|
64
|
+
/// also returns the various fees included in the total premium amount
|
19
65
|
function calculatePremium(
|
20
66
|
RiskId riskId,
|
21
67
|
uint256 sumInsuredAmount,
|
@@ -34,51 +80,7 @@ interface IPolicyService is IService {
|
|
34
80
|
uint256 distributionFeeAmount
|
35
81
|
);
|
36
82
|
|
37
|
-
|
38
|
-
function createApplication(
|
39
|
-
address applicationOwner,
|
40
|
-
RiskId riskId,
|
41
|
-
uint256 sumInsuredAmount,
|
42
|
-
uint256 lifetime,
|
43
|
-
bytes memory applicationData,
|
44
|
-
NftId bundleNftId,
|
45
|
-
ReferralId referralId
|
46
|
-
) external returns (NftId nftId);
|
47
|
-
|
48
|
-
/**
|
49
|
-
* @dev revokes the application represented by {policyNftId}.
|
50
|
-
* an application can only be revoked in applied state.
|
51
|
-
* only the application holder may revoke an application.
|
52
|
-
*/
|
53
|
-
function revoke(NftId policyNftId) external;
|
54
|
-
|
55
|
-
/**
|
56
|
-
* @dev underwrites the policy represented by {policyNftId}.
|
57
|
-
* optionally collects premiums and activates the policy.
|
58
|
-
* - premium payment is only attempted if requirePremiumPayment is set to true
|
59
|
-
* - activation is only done if activateAt is a non-zero timestamp
|
60
|
-
*/
|
61
|
-
function underwrite(
|
62
|
-
NftId policyNftId,
|
63
|
-
bool requirePremiumPayment,
|
64
|
-
Timestamp activateAt
|
65
|
-
) external;
|
66
|
-
|
67
|
-
// function decline(uint256 nftId) external;
|
68
|
-
// function expire(uint256 nftId) external;
|
69
|
-
|
70
|
-
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
71
|
-
|
72
|
-
function activate(NftId policyNftId, Timestamp activateAt) external;
|
73
|
-
|
74
|
-
|
75
|
-
function close(NftId nftId) external;
|
76
|
-
|
77
|
-
// function createClaim(uint256 nftId, uint256 claimAmount) external;
|
78
|
-
// function confirmClaim(uint256 nftId, uint256 claimId, uint256 claimAmount) external;
|
79
|
-
// function declineClaim(uint256 nftId, uint256 claimId) external;
|
80
|
-
// function closeClaim(uint256 nftId, uint256 claimId) external; // TODO payoutClaim() -> implicit close when payed out in full
|
81
|
-
|
83
|
+
// TODO move function to pool service
|
82
84
|
function calculateRequiredCollateral(
|
83
85
|
UFixed collateralizationLevel,
|
84
86
|
uint256 sumInsuredAmount
|
@@ -4,7 +4,6 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
5
|
import {IProductComponent} from "../../components/IProductComponent.sol";
|
6
6
|
import {Product} from "../../components/Product.sol";
|
7
|
-
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
8
7
|
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
9
8
|
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
10
9
|
import {IInstance} from "../IInstance.sol";
|
@@ -20,11 +19,11 @@ import {TokenHandler} from "../../shared/TokenHandler.sol";
|
|
20
19
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
21
20
|
import {Versionable} from "../../shared/Versionable.sol";
|
22
21
|
|
23
|
-
import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
|
22
|
+
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
24
23
|
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
25
24
|
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
26
25
|
import {ObjectType, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
|
27
|
-
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
|
26
|
+
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
|
28
27
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
29
28
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
30
29
|
import {ReferralId} from "../../types/Referral.sol";
|
@@ -35,15 +34,19 @@ import {Version, VersionLib} from "../../types/Version.sol";
|
|
35
34
|
|
36
35
|
import {IService} from "../../shared/IService.sol";
|
37
36
|
import {Service} from "../../shared/Service.sol";
|
38
|
-
import {
|
37
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
39
38
|
import {IPolicyService} from "./IPolicyService.sol";
|
40
39
|
import {InstanceReader} from "../InstanceReader.sol";
|
41
40
|
import {IPoolService} from "./IPoolService.sol";
|
42
41
|
import {IBundleService} from "./IBundleService.sol";
|
43
42
|
|
44
43
|
|
45
|
-
contract PolicyService is
|
44
|
+
contract PolicyService is
|
45
|
+
ComponentService,
|
46
|
+
IPolicyService
|
47
|
+
{
|
46
48
|
using NftIdLib for NftId;
|
49
|
+
using TimestampLib for Timestamp;
|
47
50
|
|
48
51
|
IPoolService internal _poolService;
|
49
52
|
IBundleService internal _bundleService;
|
@@ -55,19 +58,19 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
55
58
|
bytes memory data
|
56
59
|
)
|
57
60
|
internal
|
58
|
-
initializer
|
59
61
|
virtual override
|
62
|
+
initializer
|
60
63
|
{
|
61
64
|
address registryAddress;
|
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,7 +84,8 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
81
84
|
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
82
85
|
product = Product(productInfo.objectAddress);
|
83
86
|
}
|
84
|
-
|
87
|
+
|
88
|
+
// TODO: no access restrictions
|
85
89
|
function calculatePremium(
|
86
90
|
RiskId riskId,
|
87
91
|
uint256 sumInsuredAmount,
|
@@ -92,7 +96,7 @@ contract PolicyService is ComponentServiceBase, 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,
|
@@ -168,65 +172,6 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
168
172
|
(bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
|
169
173
|
}
|
170
174
|
|
171
|
-
|
172
|
-
function createApplication(
|
173
|
-
address applicationOwner,
|
174
|
-
RiskId riskId,
|
175
|
-
uint256 sumInsuredAmount,
|
176
|
-
uint256 lifetime,
|
177
|
-
bytes memory applicationData,
|
178
|
-
NftId bundleNftId,
|
179
|
-
ReferralId referralId
|
180
|
-
) external override returns (NftId policyNftId) {
|
181
|
-
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
182
|
-
// TODO add validations (see create bundle in pool service)
|
183
|
-
|
184
|
-
policyNftId = getRegistryService().registerPolicy(
|
185
|
-
IRegistry.ObjectInfo(
|
186
|
-
zeroNftId(),
|
187
|
-
productInfo.nftId,
|
188
|
-
POLICY(),
|
189
|
-
false, // intercepting property for policies is defined on product
|
190
|
-
address(0),
|
191
|
-
applicationOwner,
|
192
|
-
""
|
193
|
-
)
|
194
|
-
);
|
195
|
-
|
196
|
-
(uint256 premiumAmount,,,,) = calculatePremium(
|
197
|
-
riskId,
|
198
|
-
sumInsuredAmount,
|
199
|
-
lifetime,
|
200
|
-
applicationData,
|
201
|
-
bundleNftId,
|
202
|
-
referralId
|
203
|
-
);
|
204
|
-
|
205
|
-
IPolicy.PolicyInfo memory policyInfo = IPolicy.PolicyInfo(
|
206
|
-
productInfo.nftId,
|
207
|
-
bundleNftId,
|
208
|
-
referralId,
|
209
|
-
riskId,
|
210
|
-
sumInsuredAmount,
|
211
|
-
premiumAmount,
|
212
|
-
0,
|
213
|
-
lifetime,
|
214
|
-
applicationData,
|
215
|
-
"",
|
216
|
-
0,
|
217
|
-
0,
|
218
|
-
0,
|
219
|
-
zeroTimestamp(),
|
220
|
-
zeroTimestamp(),
|
221
|
-
zeroTimestamp()
|
222
|
-
);
|
223
|
-
|
224
|
-
instance.createPolicy(policyNftId, policyInfo);
|
225
|
-
instance.updatePolicyState(policyNftId, APPLIED());
|
226
|
-
|
227
|
-
// TODO add logging
|
228
|
-
}
|
229
|
-
|
230
175
|
function _getAndVerifyUnderwritingSetup(
|
231
176
|
IInstance instance,
|
232
177
|
InstanceReader instanceReader,
|
@@ -236,118 +181,78 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
236
181
|
internal
|
237
182
|
view
|
238
183
|
returns (
|
184
|
+
NftId poolNftId,
|
239
185
|
NftId bundleNftId,
|
240
186
|
IBundle.BundleInfo memory bundleInfo,
|
241
187
|
uint256 collateralAmount
|
242
188
|
)
|
243
189
|
{
|
244
190
|
// check match between policy and bundle (via pool)
|
191
|
+
poolNftId = productSetupInfo.poolNftId;
|
245
192
|
bundleNftId = policyInfo.bundleNftId;
|
246
193
|
bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
247
|
-
require(bundleInfo.poolNftId ==
|
194
|
+
require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
|
248
195
|
|
249
196
|
// calculate required collateral
|
250
|
-
NftId poolNftId = productSetupInfo.poolNftId;
|
251
197
|
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
252
198
|
|
253
199
|
// obtain remaining return values
|
200
|
+
// TODO required collateral amount should be calculated by pool service, not policy service
|
254
201
|
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
255
202
|
}
|
256
203
|
|
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
204
|
|
291
|
-
function
|
205
|
+
function decline(
|
292
206
|
NftId policyNftId
|
293
207
|
)
|
294
208
|
external
|
295
209
|
override
|
296
210
|
{
|
297
|
-
require(false, "ERROR:PRS-
|
211
|
+
require(false, "ERROR:PRS-235:NOT_YET_IMPLEMENTED");
|
298
212
|
}
|
299
213
|
|
300
214
|
|
215
|
+
/// @dev underwites application which includes the locking of the required collateral from the pool.
|
301
216
|
function underwrite(
|
302
|
-
NftId policyNftId
|
217
|
+
NftId applicationNftId, // = policyNftId
|
303
218
|
bool requirePremiumPayment,
|
304
219
|
Timestamp activateAt
|
305
220
|
)
|
306
221
|
external
|
307
|
-
override
|
222
|
+
virtual override
|
308
223
|
{
|
309
224
|
// check caller is registered product
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
225
|
+
IInstance instance;
|
226
|
+
InstanceReader instanceReader;
|
227
|
+
NftId productNftId;
|
228
|
+
{
|
229
|
+
IRegistry.ObjectInfo memory productInfo;
|
230
|
+
(productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
231
|
+
instanceReader = instance.getInstanceReader();
|
232
|
+
productNftId = productInfo.nftId;
|
233
|
+
}
|
315
234
|
|
316
|
-
// check
|
317
|
-
|
318
|
-
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
235
|
+
// check policy matches with calling product
|
236
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(applicationNftId);
|
319
237
|
require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
320
|
-
require(instanceReader.getPolicyState(policyNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
321
238
|
|
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
|
-
}
|
239
|
+
// check policy is in state applied
|
240
|
+
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
341
241
|
|
342
|
-
|
343
|
-
|
242
|
+
(
|
243
|
+
NftId poolNftId,
|
244
|
+
NftId bundleNftId,
|
245
|
+
IBundle.BundleInfo memory bundleInfo,
|
246
|
+
uint256 collateralAmount
|
247
|
+
) = _getAndVerifyUnderwritingSetup(
|
344
248
|
instance,
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
StateId newPolicyState = UNDERWRITTEN();
|
249
|
+
instanceReader,
|
250
|
+
policyInfo,
|
251
|
+
instanceReader.getProductSetupInfo(productNftId)
|
252
|
+
);
|
350
253
|
|
254
|
+
StateId newPolicyState = UNDERWRITTEN();
|
255
|
+
|
351
256
|
// optional activation of policy
|
352
257
|
if(activateAt > zeroTimestamp()) {
|
353
258
|
newPolicyState = ACTIVE();
|
@@ -355,38 +260,56 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
355
260
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
356
261
|
}
|
357
262
|
|
263
|
+
// lock bundle collateral
|
264
|
+
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
265
|
+
|
358
266
|
// optional collection of premium
|
359
267
|
if(requirePremiumPayment) {
|
360
268
|
netPremiumAmount = _processPremiumByTreasury(
|
361
269
|
instance,
|
362
|
-
|
363
|
-
|
270
|
+
productNftId,
|
271
|
+
applicationNftId,
|
364
272
|
policyInfo.premiumAmount);
|
365
273
|
|
366
274
|
policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
|
367
275
|
}
|
368
276
|
|
369
|
-
|
370
|
-
|
277
|
+
// lock collateral and update bundle book keeping
|
278
|
+
// TODO introduct indirection via pool service?
|
279
|
+
// well pool would only need to be involved when a part of the collateral
|
280
|
+
// is provided by a "re insurance policy" of the pool
|
281
|
+
// but then again the policiy would likely best be attached to the bundle. really? why?
|
282
|
+
// retention level: fraction of sum insured that product will cover from pool funds directly
|
283
|
+
// eg retention level 30%, payouts up to 30% of the sum insured will be made from the product's pool directly
|
284
|
+
// for the remaining 70% the pool owns a policy that will cover claims that exceed the 30% of the sum insured
|
285
|
+
// open points:
|
286
|
+
// - do we need a link of a bundle to this policy or is it enough to know that the pool has an active policy?
|
287
|
+
// - when to buy such policies and for which amount? manual trigger or link to bundle creation and/or funding?
|
288
|
+
bundleInfo = _bundleService.lockCollateral(
|
289
|
+
instance,
|
290
|
+
applicationNftId,
|
291
|
+
bundleNftId,
|
292
|
+
collateralAmount,
|
293
|
+
netPremiumAmount);
|
294
|
+
|
295
|
+
instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
|
371
296
|
|
372
|
-
//
|
373
|
-
{
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
collateralAmount
|
383
|
-
);
|
384
|
-
}
|
297
|
+
// also verify/confirm application by pool if necessary
|
298
|
+
if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
|
299
|
+
IPoolComponent pool = IPoolComponent(
|
300
|
+
getRegistry().getObjectInfo(poolNftId).objectAddress);
|
301
|
+
|
302
|
+
pool.verifyApplication(
|
303
|
+
applicationNftId,
|
304
|
+
policyInfo.applicationData,
|
305
|
+
bundleInfo.filter,
|
306
|
+
collateralAmount);
|
385
307
|
}
|
386
308
|
|
387
|
-
// TODO add logging
|
309
|
+
// TODO: add logging
|
388
310
|
}
|
389
311
|
|
312
|
+
|
390
313
|
function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
|
391
314
|
UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
|
392
315
|
UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
|
@@ -397,28 +320,30 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
397
320
|
// check caller is registered product
|
398
321
|
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
399
322
|
InstanceReader instanceReader = instance.getInstanceReader();
|
323
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
400
324
|
|
401
|
-
|
402
|
-
|
403
|
-
|
325
|
+
if (policyInfo.premiumPaidAmount == policyInfo.premiumAmount) {
|
326
|
+
revert ErrorIPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
|
327
|
+
}
|
404
328
|
|
405
|
-
|
406
|
-
// IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
407
|
-
|
408
|
-
// uint256 premiumAmount = policyInfo.premiumAmount;
|
409
|
-
// _processPremiumByTreasury(instance, productInfo.nftId, policyNftId, premiumAmount);
|
329
|
+
uint256 unpaidPremiumAmount = policyInfo.premiumAmount - policyInfo.premiumPaidAmount;
|
410
330
|
|
411
|
-
|
412
|
-
|
331
|
+
uint256 netPremiumAmount = _processPremiumByTreasury(
|
332
|
+
instance,
|
333
|
+
productInfo.nftId,
|
334
|
+
policyNftId,
|
335
|
+
unpaidPremiumAmount);
|
336
|
+
|
337
|
+
policyInfo.premiumPaidAmount += unpaidPremiumAmount;
|
413
338
|
|
414
|
-
|
339
|
+
_bundleService.increaseBalance(instance, policyInfo.bundleNftId, netPremiumAmount);
|
340
|
+
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
415
341
|
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
// }
|
342
|
+
if(activateAt.gtz() && policyInfo.activatedAt.eqz()) {
|
343
|
+
activate(policyNftId, activateAt);
|
344
|
+
}
|
420
345
|
|
421
|
-
// TODO add logging
|
346
|
+
// TODO: add logging
|
422
347
|
}
|
423
348
|
|
424
349
|
function activate(NftId policyNftId, Timestamp activateAt) public override {
|
@@ -437,14 +362,60 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
437
362
|
|
438
363
|
instance.updatePolicy(policyNftId, policyInfo, ACTIVE());
|
439
364
|
|
440
|
-
// TODO add logging
|
365
|
+
// TODO: add logging
|
366
|
+
}
|
367
|
+
|
368
|
+
|
369
|
+
function expire(
|
370
|
+
NftId policyNftId
|
371
|
+
)
|
372
|
+
external
|
373
|
+
override
|
374
|
+
// solhint-disable-next-line no-empty-blocks
|
375
|
+
{
|
376
|
+
|
441
377
|
}
|
442
378
|
|
443
379
|
function close(
|
444
380
|
NftId policyNftId
|
445
|
-
)
|
381
|
+
)
|
382
|
+
external
|
383
|
+
override
|
446
384
|
{
|
385
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
386
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
387
|
+
|
388
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
389
|
+
|
390
|
+
if (policyInfo.activatedAt.eqz()) {
|
391
|
+
revert ErrorIPolicyServicePolicyNotActivated(policyNftId);
|
392
|
+
}
|
393
|
+
|
394
|
+
StateId state = instanceReader.getPolicyState(policyNftId);
|
395
|
+
if (state != ACTIVE()) {
|
396
|
+
revert ErrorIPolicyServicePolicyNotActive(policyNftId, state);
|
397
|
+
}
|
398
|
+
|
399
|
+
if (policyInfo.closedAt.gtz()) {
|
400
|
+
revert ErrorIPolicyServicePolicyAlreadyClosed(policyNftId);
|
401
|
+
}
|
402
|
+
|
403
|
+
if (policyInfo.premiumAmount != policyInfo.premiumPaidAmount) {
|
404
|
+
revert ErrorIPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
|
405
|
+
}
|
406
|
+
|
407
|
+
if (policyInfo.openClaimsCount > 0) {
|
408
|
+
revert ErrorIPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
|
409
|
+
}
|
410
|
+
|
411
|
+
if (TimestampLib.blockTimestamp().lte(policyInfo.expiredAt) && (policyInfo.payoutAmount < policyInfo.sumInsuredAmount)) {
|
412
|
+
revert ErrorIPolicyServicePolicyHasNotExpired(policyNftId, policyInfo.expiredAt);
|
413
|
+
}
|
414
|
+
|
415
|
+
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
447
416
|
|
417
|
+
_bundleService.closePolicy(instance, policyNftId, policyInfo.bundleNftId, policyInfo.sumInsuredAmount);
|
418
|
+
instance.updatePolicy(policyNftId, policyInfo, CLOSED());
|
448
419
|
}
|
449
420
|
|
450
421
|
function _getPoolNftId(
|
@@ -498,6 +469,6 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
498
469
|
}
|
499
470
|
}
|
500
471
|
|
501
|
-
// TODO add logging
|
472
|
+
// TODO: add logging
|
502
473
|
}
|
503
474
|
}
|
@@ -16,7 +16,7 @@ contract PolicyServiceManager is ProxyManager {
|
|
16
16
|
constructor(
|
17
17
|
address registryAddress
|
18
18
|
)
|
19
|
-
ProxyManager()
|
19
|
+
ProxyManager(registryAddress)
|
20
20
|
{
|
21
21
|
PolicyService svc = new PolicyService();
|
22
22
|
bytes memory data = abi.encode(registryAddress, address(this));
|
@@ -39,7 +39,7 @@ contract PolicyServiceManager is ProxyManager {
|
|
39
39
|
// address(_productService));
|
40
40
|
|
41
41
|
// implies that after this constructor call only upgrade functionality is available
|
42
|
-
_isDeployed = true;
|
42
|
+
// _isDeployed = true;
|
43
43
|
}
|
44
44
|
|
45
45
|
//--- view functions ----------------------------------------------------//
|