@etherisc/gif-next 0.0.2-da06f3b-803 → 0.0.2-da0f894-204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +212 -94
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +552 -122
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +64 -72
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +279 -98
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +406 -90
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +68 -144
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +654 -117
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +316 -166
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +765 -323
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +97 -180
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +841 -574
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +134 -231
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +98 -124
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +265 -269
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +319 -99
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +118 -169
- 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 +62 -36
- 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 +947 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +665 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +261 -267
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +305 -93
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +754 -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 +1031 -250
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +441 -85
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +535 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +130 -212
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +409 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +552 -135
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +40 -287
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +22 -169
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +22 -169
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +164 -391
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +311 -127
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +142 -221
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +302 -90
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +142 -221
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +302 -90
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +15 -21
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +83 -174
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +28 -34
- 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 +193 -216
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +300 -94
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +11 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +141 -37
- 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 -29
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/{experiment/inheritance/IB.sol/IB.json → shared/IRegistryLinked.sol/IRegistryLinked.json} +18 -20
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +22 -169
- 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 +113 -33
- 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 -74
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +125 -55
- 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 +113 -164
- 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 +125 -55
- 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 +134 -221
- 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/Seconds.sol/SecondsLib.dbg.json +4 -0
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
- 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/Timestamp.sol/TimestampLib.json +25 -7
- 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 +82 -77
- package/contracts/components/Distribution.sol +188 -48
- package/contracts/components/IComponent.sol +42 -17
- package/contracts/components/IDistributionComponent.sol +39 -7
- package/contracts/components/IPoolComponent.sol +121 -21
- package/contracts/components/IProductComponent.sol +3 -2
- package/contracts/components/Pool.sol +290 -120
- package/contracts/components/Product.sol +92 -69
- package/contracts/instance/BundleManager.sol +1 -1
- package/contracts/instance/IInstance.sol +21 -1
- package/contracts/instance/IInstanceService.sol +19 -2
- package/contracts/instance/Instance.sol +58 -36
- package/contracts/instance/InstanceAccessManager.sol +136 -253
- package/contracts/instance/InstanceService.sol +154 -137
- package/contracts/instance/InstanceServiceManager.sol +1 -1
- package/contracts/instance/base/ComponentService.sol +1 -1
- package/contracts/instance/module/IAccess.sol +10 -11
- package/contracts/instance/module/IBundle.sol +2 -1
- package/contracts/instance/module/IDistribution.sol +2 -0
- package/contracts/instance/module/IPolicy.sol +30 -3
- package/contracts/instance/module/ISetup.sol +10 -10
- package/contracts/instance/service/ApplicationService.sol +346 -0
- package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
- package/contracts/instance/service/BundleService.sol +15 -9
- 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 +303 -15
- package/contracts/instance/service/DistributionServiceManager.sol +1 -1
- package/contracts/instance/service/IApplicationService.sol +81 -0
- package/contracts/instance/service/IBundleService.sol +14 -3
- package/contracts/instance/service/IClaimService.sol +61 -0
- package/contracts/instance/service/IDistributionService.sol +74 -0
- package/contracts/instance/service/IPolicyService.sol +26 -50
- package/contracts/instance/service/PolicyService.sol +126 -260
- package/contracts/instance/service/PolicyServiceManager.sol +2 -2
- package/contracts/instance/service/PoolService.sol +2 -3
- package/contracts/instance/service/PoolServiceManager.sol +1 -1
- package/contracts/instance/service/ProductService.sol +9 -9
- package/contracts/instance/service/ProductServiceManager.sol +2 -2
- package/contracts/registry/IRegistry.sol +3 -4
- package/contracts/registry/IRegistryService.sol +10 -8
- package/contracts/registry/Registry.sol +28 -21
- package/contracts/registry/RegistryService.sol +69 -48
- package/contracts/registry/RegistryServiceManager.sol +13 -13
- package/contracts/registry/ReleaseManager.sol +18 -28
- package/contracts/registry/TokenRegistry.sol +16 -12
- 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 +3 -3
- package/contracts/shared/IRegistryLinked.sol +12 -0
- package/contracts/shared/IService.sol +2 -0
- package/contracts/shared/IVersionable.sol +4 -47
- package/contracts/shared/NftOwnable.sol +66 -85
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +100 -25
- package/contracts/shared/Registerable.sol +7 -19
- package/contracts/shared/RegistryLinked.sol +48 -0
- package/contracts/shared/Service.sol +15 -17
- 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 +14 -12
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/Timestamp.sol +12 -13
- package/package.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +0 -66
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +0 -24
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +0 -42
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +0 -4
- package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +0 -10
- package/contracts/experiment/cloning/Cloner.sol +0 -47
- package/contracts/experiment/errors/Require.sol +0 -38
- package/contracts/experiment/errors/Revert.sol +0 -44
- package/contracts/experiment/inheritance/A.sol +0 -53
- package/contracts/experiment/inheritance/B.sol +0 -28
- package/contracts/experiment/inheritance/C.sol +0 -34
- package/contracts/experiment/inheritance/IA.sol +0 -13
- package/contracts/experiment/inheritance/IB.sol +0 -10
- package/contracts/experiment/inheritance/IC.sol +0 -12
- package/contracts/experiment/statemachine/Dummy.sol +0 -27
- package/contracts/experiment/statemachine/ISM.sol +0 -25
- package/contracts/experiment/statemachine/SM.sol +0 -57
- package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
- package/contracts/experiment/types/TypeA.sol +0 -47
- package/contracts/experiment/types/TypeB.sol +0 -29
@@ -7,6 +7,7 @@ import {IService} from "../../shared/IService.sol";
|
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
8
|
import {ReferralId} from "../../types/Referral.sol";
|
9
9
|
import {RiskId} from "../../types/RiskId.sol";
|
10
|
+
import {Seconds} from "../../types/Seconds.sol";
|
10
11
|
import {StateId} from "../../types/StateId.sol";
|
11
12
|
import {Timestamp} from "../../types/Timestamp.sol";
|
12
13
|
import {UFixed} from "../../types/UFixed.sol";
|
@@ -22,70 +23,45 @@ interface IPolicyService is IService {
|
|
22
23
|
error ErrorIPolicyServicePremiumNotFullyPaid(NftId policyNftId, uint256 premiumAmount, uint256 premiumPaidAmount);
|
23
24
|
error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
24
25
|
error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
25
|
-
|
26
|
-
function calculatePremium(
|
27
|
-
RiskId riskId,
|
28
|
-
uint256 sumInsuredAmount,
|
29
|
-
uint256 lifetime,
|
30
|
-
bytes memory applicationData,
|
31
|
-
NftId bundleNftId,
|
32
|
-
ReferralId referralId
|
33
|
-
)
|
34
|
-
external
|
35
|
-
view
|
36
|
-
returns (
|
37
|
-
uint256 premiumAmount,
|
38
|
-
uint256 productFeeAmount,
|
39
|
-
uint256 poolFeeAmount,
|
40
|
-
uint256 bundleFeeAmount,
|
41
|
-
uint256 distributionFeeAmount
|
42
|
-
);
|
43
|
-
|
44
|
-
|
45
|
-
function createApplication(
|
46
|
-
address applicationOwner,
|
47
|
-
RiskId riskId,
|
48
|
-
uint256 sumInsuredAmount,
|
49
|
-
uint256 lifetime,
|
50
|
-
bytes memory applicationData,
|
51
|
-
NftId bundleNftId,
|
52
|
-
ReferralId referralId
|
53
|
-
) external returns (NftId nftId);
|
54
26
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
*/
|
60
|
-
function revoke(NftId policyNftId) external;
|
27
|
+
/// @dev declines an application represented by {policyNftId}
|
28
|
+
/// an application can only be declined in applied state
|
29
|
+
/// only the related product may decline an application
|
30
|
+
function decline(NftId policyNftId) external;
|
61
31
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
32
|
+
/// @dev underwrites the policy represented by {policyNftId}
|
33
|
+
/// sets the policy state to underwritten
|
34
|
+
/// may set the policy state to activated and set the activation date
|
35
|
+
/// optionally collects premiums and activates the policy.
|
36
|
+
/// - premium payment is only attempted if requirePremiumPayment is set to true
|
37
|
+
/// - activation is only done if activateAt is a non-zero timestamp
|
38
|
+
/// an application can only be underwritten in applied state
|
39
|
+
/// only the related product may underwrite an application
|
68
40
|
function underwrite(
|
69
41
|
NftId policyNftId,
|
70
42
|
bool requirePremiumPayment,
|
71
43
|
Timestamp activateAt
|
72
44
|
) external;
|
73
45
|
|
74
|
-
|
75
|
-
// function expire(uint256 nftId) external;
|
76
|
-
|
46
|
+
/// @dev collects the premium token for the specified policy
|
77
47
|
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
78
48
|
|
49
|
+
/// @dev activates the specified policy and sets the activation date in the policy metadata
|
50
|
+
/// to activate a policy it needs to be in underwritten state
|
79
51
|
function activate(NftId policyNftId, Timestamp activateAt) external;
|
80
52
|
|
53
|
+
/// @dev expires the specified policy and sets the expiry date in the policy metadata
|
54
|
+
/// 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
|
55
|
+
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
56
|
+
/// this function can only be called by a product. the policy needs to match with the calling product
|
57
|
+
function expire(NftId policyNftId) external;
|
81
58
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
// function declineClaim(uint256 nftId, uint256 claimId) external;
|
87
|
-
// function closeClaim(uint256 nftId, uint256 claimId) external; // TODO payoutClaim() -> implicit close when payed out in full
|
59
|
+
/// @dev closes the specified policy and sets the closed data in the policy metadata
|
60
|
+
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
61
|
+
/// this function can only be called by a product. the policy needs to match with the calling product
|
62
|
+
function close(NftId policyNftId) external;
|
88
63
|
|
64
|
+
// TODO move function to pool service
|
89
65
|
function calculateRequiredCollateral(
|
90
66
|
UFixed collateralizationLevel,
|
91
67
|
uint256 sumInsuredAmount
|
@@ -19,10 +19,11 @@ import {TokenHandler} from "../../shared/TokenHandler.sol";
|
|
19
19
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
20
20
|
import {Versionable} from "../../shared/Versionable.sol";
|
21
21
|
|
22
|
+
import {Seconds} from "../../types/Seconds.sol";
|
22
23
|
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
23
24
|
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
24
25
|
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
25
|
-
import {ObjectType, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
|
26
|
+
import {ObjectType, APPLICATION, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
|
26
27
|
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
|
27
28
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
28
29
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
@@ -35,18 +36,23 @@ import {Version, VersionLib} from "../../types/Version.sol";
|
|
35
36
|
import {IService} from "../../shared/IService.sol";
|
36
37
|
import {Service} from "../../shared/Service.sol";
|
37
38
|
import {ComponentService} from "../base/ComponentService.sol";
|
39
|
+
import {IApplicationService} from "./IApplicationService.sol";
|
38
40
|
import {IPolicyService} from "./IPolicyService.sol";
|
39
41
|
import {InstanceReader} from "../InstanceReader.sol";
|
40
42
|
import {IPoolService} from "./IPoolService.sol";
|
41
43
|
import {IBundleService} from "./IBundleService.sol";
|
42
44
|
|
43
45
|
|
44
|
-
contract PolicyService is
|
46
|
+
contract PolicyService is
|
47
|
+
ComponentService,
|
48
|
+
IPolicyService
|
49
|
+
{
|
45
50
|
using NftIdLib for NftId;
|
46
51
|
using TimestampLib for Timestamp;
|
47
52
|
|
48
53
|
IPoolService internal _poolService;
|
49
54
|
IBundleService internal _bundleService;
|
55
|
+
IApplicationService internal _applicationService;
|
50
56
|
|
51
57
|
event LogProductServiceSender(address sender);
|
52
58
|
|
@@ -55,19 +61,21 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
55
61
|
bytes memory data
|
56
62
|
)
|
57
63
|
internal
|
58
|
-
initializer
|
59
64
|
virtual override
|
65
|
+
initializer
|
60
66
|
{
|
61
67
|
address registryAddress;
|
62
68
|
address initialOwner;
|
63
69
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
64
70
|
|
65
|
-
|
71
|
+
initializeService(registryAddress, owner);
|
66
72
|
|
67
|
-
_poolService = IPoolService(
|
68
|
-
_bundleService = IBundleService(
|
73
|
+
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
|
74
|
+
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getMajorVersion()));
|
75
|
+
// FIXME: application service is currently deployed AFTER policy service
|
76
|
+
_applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), getMajorVersion()));
|
69
77
|
|
70
|
-
|
78
|
+
registerInterface(type(IPolicyService).interfaceId);
|
71
79
|
}
|
72
80
|
|
73
81
|
|
@@ -81,151 +89,6 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
81
89
|
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
82
90
|
product = Product(productInfo.objectAddress);
|
83
91
|
}
|
84
|
-
// TODO: no access restrictions
|
85
|
-
function calculatePremium(
|
86
|
-
RiskId riskId,
|
87
|
-
uint256 sumInsuredAmount,
|
88
|
-
uint256 lifetime,
|
89
|
-
bytes memory applicationData,
|
90
|
-
NftId bundleNftId,
|
91
|
-
ReferralId referralId
|
92
|
-
)
|
93
|
-
public
|
94
|
-
view
|
95
|
-
override
|
96
|
-
returns (
|
97
|
-
uint256 premiumAmount,
|
98
|
-
uint256 productFeeAmount,
|
99
|
-
uint256 poolFeeAmount,
|
100
|
-
uint256 bundleFeeAmount,
|
101
|
-
uint256 distributionFeeAmount
|
102
|
-
)
|
103
|
-
{
|
104
|
-
Product product = _getAndVerifyInstanceAndProduct();
|
105
|
-
uint256 netPremiumAmount = product.calculateNetPremium(
|
106
|
-
sumInsuredAmount,
|
107
|
-
riskId,
|
108
|
-
lifetime,
|
109
|
-
applicationData
|
110
|
-
);
|
111
|
-
|
112
|
-
(
|
113
|
-
productFeeAmount,
|
114
|
-
poolFeeAmount,
|
115
|
-
bundleFeeAmount,
|
116
|
-
distributionFeeAmount
|
117
|
-
) = _calculateFeeAmounts(
|
118
|
-
netPremiumAmount,
|
119
|
-
product,
|
120
|
-
bundleNftId,
|
121
|
-
referralId
|
122
|
-
);
|
123
|
-
|
124
|
-
premiumAmount = netPremiumAmount + productFeeAmount;
|
125
|
-
premiumAmount += poolFeeAmount + bundleFeeAmount;
|
126
|
-
premiumAmount += distributionFeeAmount;
|
127
|
-
}
|
128
|
-
|
129
|
-
function _calculateFeeAmounts(
|
130
|
-
uint256 netPremiumAmount,
|
131
|
-
Product product,
|
132
|
-
NftId bundleNftId,
|
133
|
-
ReferralId referralId
|
134
|
-
)
|
135
|
-
internal
|
136
|
-
view
|
137
|
-
returns (
|
138
|
-
uint256 productFeeAmount,
|
139
|
-
uint256 poolFeeAmount,
|
140
|
-
uint256 bundleFeeAmount,
|
141
|
-
uint256 distributionFeeAmount
|
142
|
-
)
|
143
|
-
{
|
144
|
-
InstanceReader instanceReader;
|
145
|
-
{
|
146
|
-
IInstance instance = product.getInstance();
|
147
|
-
instanceReader = instance.getInstanceReader();
|
148
|
-
}
|
149
|
-
|
150
|
-
NftId poolNftId = product.getPoolNftId();
|
151
|
-
IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
152
|
-
require(bundleInfo.poolNftId == poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
|
153
|
-
|
154
|
-
{
|
155
|
-
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(product.getProductNftId());
|
156
|
-
(productFeeAmount,) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
|
157
|
-
}
|
158
|
-
{
|
159
|
-
ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
160
|
-
(poolFeeAmount,) = FeeLib.calculateFee(poolSetupInfo.poolFee, netPremiumAmount);
|
161
|
-
}
|
162
|
-
{
|
163
|
-
NftId distributionNftId = product.getDistributionNftId();
|
164
|
-
ISetup.DistributionSetupInfo memory distributionSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
165
|
-
(distributionFeeAmount,) = FeeLib.calculateFee(distributionSetupInfo.distributionFee, netPremiumAmount);
|
166
|
-
}
|
167
|
-
|
168
|
-
(bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
|
169
|
-
}
|
170
|
-
|
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
92
|
|
230
93
|
function _getAndVerifyUnderwritingSetup(
|
231
94
|
IInstance instance,
|
@@ -236,118 +99,78 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
236
99
|
internal
|
237
100
|
view
|
238
101
|
returns (
|
102
|
+
NftId poolNftId,
|
239
103
|
NftId bundleNftId,
|
240
104
|
IBundle.BundleInfo memory bundleInfo,
|
241
105
|
uint256 collateralAmount
|
242
106
|
)
|
243
107
|
{
|
244
108
|
// check match between policy and bundle (via pool)
|
109
|
+
poolNftId = productSetupInfo.poolNftId;
|
245
110
|
bundleNftId = policyInfo.bundleNftId;
|
246
111
|
bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
247
|
-
require(bundleInfo.poolNftId ==
|
112
|
+
require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
|
248
113
|
|
249
114
|
// calculate required collateral
|
250
|
-
NftId poolNftId = productSetupInfo.poolNftId;
|
251
115
|
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
252
116
|
|
253
117
|
// obtain remaining return values
|
118
|
+
// TODO required collateral amount should be calculated by pool service, not policy service
|
254
119
|
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
255
120
|
}
|
256
121
|
|
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
122
|
|
272
|
-
function
|
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
|
-
|
291
|
-
function revoke(
|
123
|
+
function decline(
|
292
124
|
NftId policyNftId
|
293
125
|
)
|
294
126
|
external
|
295
127
|
override
|
296
128
|
{
|
297
|
-
require(false, "ERROR:PRS-
|
129
|
+
require(false, "ERROR:PRS-235:NOT_YET_IMPLEMENTED");
|
298
130
|
}
|
299
131
|
|
300
132
|
|
133
|
+
/// @dev underwites application which includes the locking of the required collateral from the pool.
|
301
134
|
function underwrite(
|
302
|
-
NftId policyNftId
|
135
|
+
NftId applicationNftId, // = policyNftId
|
303
136
|
bool requirePremiumPayment,
|
304
137
|
Timestamp activateAt
|
305
138
|
)
|
306
139
|
external
|
307
|
-
override
|
140
|
+
virtual override
|
308
141
|
{
|
309
142
|
// check caller is registered product
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
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
|
+
}
|
315
152
|
|
316
|
-
// check
|
317
|
-
|
318
|
-
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
153
|
+
// check policy matches with calling product
|
154
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(applicationNftId);
|
319
155
|
require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
320
|
-
require(instanceReader.getPolicyState(policyNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
321
156
|
|
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
|
-
}
|
157
|
+
// check policy is in state applied
|
158
|
+
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
341
159
|
|
342
|
-
|
343
|
-
|
160
|
+
(
|
161
|
+
NftId poolNftId,
|
162
|
+
NftId bundleNftId,
|
163
|
+
IBundle.BundleInfo memory bundleInfo,
|
164
|
+
uint256 collateralAmount
|
165
|
+
) = _getAndVerifyUnderwritingSetup(
|
344
166
|
instance,
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
StateId newPolicyState = UNDERWRITTEN();
|
167
|
+
instanceReader,
|
168
|
+
policyInfo,
|
169
|
+
instanceReader.getProductSetupInfo(productNftId)
|
170
|
+
);
|
350
171
|
|
172
|
+
StateId newPolicyState = UNDERWRITTEN();
|
173
|
+
|
351
174
|
// optional activation of policy
|
352
175
|
if(activateAt > zeroTimestamp()) {
|
353
176
|
newPolicyState = ACTIVE();
|
@@ -355,38 +178,57 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
355
178
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
356
179
|
}
|
357
180
|
|
181
|
+
// lock bundle collateral
|
182
|
+
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
183
|
+
|
358
184
|
// optional collection of premium
|
359
185
|
if(requirePremiumPayment) {
|
360
186
|
netPremiumAmount = _processPremiumByTreasury(
|
361
187
|
instance,
|
362
|
-
|
363
|
-
|
188
|
+
productNftId,
|
189
|
+
applicationNftId,
|
364
190
|
policyInfo.premiumAmount);
|
365
191
|
|
366
192
|
policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
|
367
193
|
}
|
368
194
|
|
369
|
-
|
370
|
-
|
195
|
+
// lock collateral and update bundle book keeping
|
196
|
+
// TODO introduct indirection via pool service?
|
197
|
+
// well pool would only need to be involved when a part of the collateral
|
198
|
+
// is provided by a "re insurance policy" of the pool
|
199
|
+
// but then again the policiy would likely best be attached to the bundle. really? why?
|
200
|
+
// retention level: fraction of sum insured that product will cover from pool funds directly
|
201
|
+
// eg retention level 30%, payouts up to 30% of the sum insured will be made from the product's pool directly
|
202
|
+
// for the remaining 70% the pool owns a policy that will cover claims that exceed the 30% of the sum insured
|
203
|
+
// open points:
|
204
|
+
// - do we need a link of a bundle to this policy or is it enough to know that the pool has an active policy?
|
205
|
+
// - when to buy such policies and for which amount? manual trigger or link to bundle creation and/or funding?
|
206
|
+
bundleInfo = _bundleService.lockCollateral(
|
207
|
+
instance,
|
208
|
+
applicationNftId,
|
209
|
+
bundleNftId,
|
210
|
+
collateralAmount,
|
211
|
+
netPremiumAmount);
|
212
|
+
|
213
|
+
instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
|
371
214
|
|
372
|
-
//
|
373
|
-
{
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
);
|
384
|
-
}
|
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);
|
385
226
|
}
|
386
227
|
|
387
228
|
// TODO: add logging
|
388
229
|
}
|
389
230
|
|
231
|
+
|
390
232
|
function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
|
391
233
|
UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
|
392
234
|
UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
|
@@ -442,9 +284,22 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
442
284
|
// TODO: add logging
|
443
285
|
}
|
444
286
|
|
287
|
+
|
288
|
+
function expire(
|
289
|
+
NftId policyNftId
|
290
|
+
)
|
291
|
+
external
|
292
|
+
override
|
293
|
+
// solhint-disable-next-line no-empty-blocks
|
294
|
+
{
|
295
|
+
|
296
|
+
}
|
297
|
+
|
445
298
|
function close(
|
446
299
|
NftId policyNftId
|
447
|
-
)
|
300
|
+
)
|
301
|
+
external
|
302
|
+
override
|
448
303
|
{
|
449
304
|
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
450
305
|
InstanceReader instanceReader = instance.getInstanceReader();
|
@@ -508,29 +363,40 @@ contract PolicyService is ComponentService, IPolicyService {
|
|
508
363
|
// process token transfer(s)
|
509
364
|
if(premiumAmount > 0) {
|
510
365
|
ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
|
366
|
+
IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
511
367
|
TokenHandler tokenHandler = productSetupInfo.tokenHandler;
|
512
368
|
address policyOwner = getRegistry().ownerOf(policyNftId);
|
513
369
|
ISetup.PoolSetupInfo memory poolSetupInfo = instance.getInstanceReader().getPoolSetupInfo(productSetupInfo.poolNftId);
|
514
370
|
address poolWallet = poolSetupInfo.wallet;
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
371
|
+
IPolicy.Premium memory premium = _applicationService.calculatePremium(
|
372
|
+
productNftId,
|
373
|
+
policyInfo.riskId,
|
374
|
+
policyInfo.sumInsuredAmount,
|
375
|
+
policyInfo.lifetime,
|
376
|
+
policyInfo.applicationData,
|
377
|
+
policyInfo.bundleNftId,
|
378
|
+
policyInfo.referralId
|
523
379
|
);
|
524
|
-
|
525
|
-
|
380
|
+
|
381
|
+
// if (FeeLib.feeIsZero(premium.productFeeAmount)) {
|
382
|
+
// tokenHandler.transfer(
|
383
|
+
// policyOwner,
|
384
|
+
// poolWallet,
|
385
|
+
// premiumAmount
|
386
|
+
// );
|
387
|
+
// } else {
|
388
|
+
// FIXME: this is wrong as netPremium is not netPremium here!!!
|
389
|
+
// (uint256 productFeeAmount, uint256 netAmount) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
|
526
390
|
address productWallet = productSetupInfo.wallet;
|
527
|
-
if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premiumAmount) {
|
528
|
-
revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premiumAmount);
|
391
|
+
if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
|
392
|
+
revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
|
529
393
|
}
|
530
|
-
tokenHandler.transfer(policyOwner, productWallet,
|
531
|
-
tokenHandler.transfer(policyOwner, poolWallet,
|
532
|
-
netPremiumAmount =
|
533
|
-
|
394
|
+
tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
|
395
|
+
tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
|
396
|
+
netPremiumAmount = premium.netPremiumAmount;
|
397
|
+
// TODO: also move distribution tokens to distribution wallet and call `Distribution.processSale` to update distribution balances
|
398
|
+
// }
|
399
|
+
|
534
400
|
}
|
535
401
|
|
536
402
|
// TODO: add logging
|
@@ -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 ----------------------------------------------------//
|
@@ -55,9 +55,8 @@ contract PoolService is
|
|
55
55
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
56
56
|
// TODO while PoolService is not deployed in PoolServiceManager constructor
|
57
57
|
// owner is PoolServiceManager deployer
|
58
|
-
|
59
|
-
|
60
|
-
_registerInterface(type(IPoolService).interfaceId);
|
58
|
+
initializeService(registryAddress, owner);
|
59
|
+
registerInterface(type(IPoolService).interfaceId);
|
61
60
|
}
|
62
61
|
|
63
62
|
function getDomain() public pure override(Service, IService) returns(ObjectType) {
|
@@ -16,7 +16,7 @@ contract PoolServiceManager is ProxyManager {
|
|
16
16
|
constructor(
|
17
17
|
address registryAddress
|
18
18
|
)
|
19
|
-
ProxyManager()
|
19
|
+
ProxyManager(registryAddress)
|
20
20
|
{
|
21
21
|
PoolService poolSrv = new PoolService();
|
22
22
|
bytes memory data = abi.encode(registryAddress, address(this));
|