@etherisc/gif-next 0.0.2-bcecc4c-647 → 0.0.2-bd8fe7c-423
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +16 -2
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +2 -2
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +2 -2
- package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +2 -2
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +2 -2
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +30 -60
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +2 -2
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +0 -38
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +2 -2
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +2 -2
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +2 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +2 -2
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +2 -2
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +2 -2
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +78 -115
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +2 -2
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +2 -2
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +16 -128
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
- package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +2 -2
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.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/mock/Dip.sol/Dip.dbg.json +1 -1
- package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +18 -48
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +2 -2
- package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +0 -38
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +2 -2
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +2 -2
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +11 -99
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +16 -16
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +131 -93
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +57 -49
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +25 -3
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +1 -57
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +74 -66
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.json +1 -95
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +198 -118
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +63 -27
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +2 -2
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +2 -2
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +0 -38
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +2 -2
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +82 -58
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +34 -30
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +16 -0
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +184 -88
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +291 -139
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +54 -26
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +2 -2
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +2 -2
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/Product.sol/Product.json +0 -38
- package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/product/ProductService.sol/ProductService.json +2 -2
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +2 -2
- 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/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- 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 +2 -2
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +2 -2
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +2 -2
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.json +0 -38
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +74 -58
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +38 -30
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +0 -38
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +53 -6
- package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +2 -2
- package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/staking/Staking.sol/Staking.json +56 -70
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +29 -17
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +2 -2
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +22 -22
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +12 -12
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +2 -2
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +2 -2
- package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +2 -2
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
- package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +23 -4
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
- package/contracts/distribution/DistributionService.sol +1 -2
- package/contracts/instance/InstanceReader.sol +10 -7
- package/contracts/instance/base/ObjectLifecycle.sol +1 -3
- package/contracts/instance/module/IComponents.sol +1 -6
- package/contracts/instance/module/IPolicy.sol +1 -1
- package/contracts/mock/Dip.sol +1 -1
- package/contracts/pool/BasicPool.sol +7 -5
- package/contracts/pool/BasicPoolAuthorization.sol +5 -2
- package/contracts/pool/BundleService.sol +51 -25
- package/contracts/pool/IBundleService.sol +12 -5
- package/contracts/pool/IPoolService.sol +8 -14
- package/contracts/pool/Pool.sol +7 -11
- package/contracts/pool/PoolService.sol +103 -86
- package/contracts/product/BasicProduct.sol +3 -33
- package/contracts/product/ClaimService.sol +16 -9
- package/contracts/product/IClaimService.sol +1 -0
- package/contracts/product/IPolicyService.sol +19 -12
- package/contracts/product/PolicyService.sol +188 -108
- package/contracts/product/Product.sol +19 -0
- package/contracts/shared/Component.sol +8 -7
- package/contracts/shared/ComponentService.sol +1 -2
- package/contracts/shared/IComponent.sol +4 -3
- package/contracts/shared/IInstanceLinkedComponent.sol +8 -8
- package/contracts/shared/TokenHandler.sol +4 -0
- package/contracts/staking/StakingService.sol +8 -12
- package/contracts/type/Blocknumber.sol +7 -1
- package/contracts/type/Timestamp.sol +11 -1
- package/package.json +1 -1
@@ -1,43 +1,15 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {
|
5
|
-
|
6
|
-
import {Amount, AmountLib} from "../type/Amount.sol";
|
7
|
-
import {ClaimId} from "../type/ClaimId.sol";
|
8
|
-
import {InstanceLinkedComponent} from "../shared/InstanceLinkedComponent.sol";
|
9
|
-
import {Fee, FeeLib} from "../type/Fee.sol";
|
10
|
-
import {IRisk} from "../instance/module/IRisk.sol";
|
11
|
-
import {IApplicationService} from "./IApplicationService.sol";
|
4
|
+
import {Fee} from "../type/Fee.sol";
|
12
5
|
import {IAuthorization} from "../authorization/IAuthorization.sol";
|
13
|
-
import {
|
14
|
-
import {IPolicyService} from "./IPolicyService.sol";
|
15
|
-
import {IProductService} from "./IProductService.sol";
|
16
|
-
import {IClaimService} from "./IClaimService.sol";
|
17
|
-
import {IPricingService} from "./IPricingService.sol";
|
18
|
-
import {IProductComponent} from "./IProductComponent.sol";
|
19
|
-
import {NftId, NftIdLib} from "../type/NftId.sol";
|
6
|
+
import {NftId} from "../type/NftId.sol";
|
20
7
|
import {Product} from "../product/Product.sol";
|
21
|
-
import {PayoutId} from "../type/PayoutId.sol";
|
22
|
-
import {COMPONENT, PRODUCT, APPLICATION, POLICY, CLAIM, PRICE } from "../type/ObjectType.sol";
|
23
|
-
import {ReferralId} from "../type/Referral.sol";
|
24
|
-
import {RiskId, RiskIdLib} from "../type/RiskId.sol";
|
25
|
-
import {Seconds} from "../type/Seconds.sol";
|
26
|
-
import {StateId} from "../type/StateId.sol";
|
27
|
-
import {Timestamp} from "../type/Timestamp.sol";
|
28
|
-
|
29
|
-
import {TokenHandler} from "../shared/TokenHandler.sol";
|
30
|
-
|
31
|
-
import {InstanceReader} from "../instance/InstanceReader.sol";
|
32
|
-
import {IPolicy} from "../instance/module/IPolicy.sol";
|
33
|
-
import {IComponents} from "../instance/module/IComponents.sol";
|
34
|
-
import {Pool} from "../pool/Pool.sol";
|
35
|
-
import {Distribution} from "../distribution/Distribution.sol";
|
36
8
|
|
37
9
|
abstract contract BasicProduct is
|
38
10
|
Product
|
39
11
|
{
|
40
|
-
|
12
|
+
|
41
13
|
function setFees(
|
42
14
|
Fee memory productFee,
|
43
15
|
Fee memory processingFee
|
@@ -49,8 +21,6 @@ abstract contract BasicProduct is
|
|
49
21
|
{
|
50
22
|
_setFees(productFee, processingFee);
|
51
23
|
}
|
52
|
-
|
53
|
-
|
54
24
|
function _initializeBasicProduct(
|
55
25
|
address registry,
|
56
26
|
NftId instanceNftId,
|
@@ -294,7 +294,7 @@ contract ClaimService is
|
|
294
294
|
(
|
295
295
|
Amount netPayoutAmount,
|
296
296
|
address beneficiary
|
297
|
-
) =
|
297
|
+
) = _calculatePayoutAmount(
|
298
298
|
instanceReader,
|
299
299
|
policyNftId,
|
300
300
|
policyInfo,
|
@@ -302,11 +302,24 @@ contract ClaimService is
|
|
302
302
|
|
303
303
|
// TODO callback IPolicyHolder
|
304
304
|
|
305
|
+
if (netPayoutAmount.eqz()) {
|
306
|
+
revert ErrorClaimsServicePayoutAmountIsZero(policyNftId, payoutId);
|
307
|
+
}
|
308
|
+
|
305
309
|
emit LogClaimServicePayoutProcessed(policyNftId, payoutId, payoutAmount, beneficiary, netPayoutAmount);
|
310
|
+
|
311
|
+
{
|
312
|
+
NftId poolNftId = getRegistry().getObjectInfo(policyInfo.bundleNftId).parentNftId;
|
313
|
+
IComponents.ComponentInfo memory poolInfo = instanceReader.getComponentInfo(poolNftId);
|
314
|
+
// TODO: centralize token handling (issue #471)
|
315
|
+
poolInfo.tokenHandler.transfer(
|
316
|
+
poolInfo.wallet,
|
317
|
+
beneficiary,
|
318
|
+
netPayoutAmount);
|
319
|
+
}
|
306
320
|
}
|
307
321
|
|
308
|
-
|
309
|
-
function _transferPayoutAmount(
|
322
|
+
function _calculatePayoutAmount(
|
310
323
|
InstanceReader instanceReader,
|
311
324
|
NftId policyNftId,
|
312
325
|
IPolicy.PolicyInfo memory policyInfo,
|
@@ -336,12 +349,6 @@ contract ClaimService is
|
|
336
349
|
// TODO transfer processing fees to product wallet
|
337
350
|
// TODO inform product to update fee book keeping
|
338
351
|
}
|
339
|
-
|
340
|
-
// TODO: centralize token handling (issue #471)
|
341
|
-
poolInfo.tokenHandler.transfer(
|
342
|
-
poolInfo.wallet,
|
343
|
-
beneficiary,
|
344
|
-
netPayoutAmount);
|
345
352
|
}
|
346
353
|
}
|
347
354
|
|
@@ -31,6 +31,7 @@ interface IClaimService is
|
|
31
31
|
error ErrorClaimServicePolicyProductMismatch(NftId policyNftId, NftId expectedProduct, NftId actualProduct);
|
32
32
|
error ErrorClaimServicePolicyNotOpen(NftId policyNftId);
|
33
33
|
error ErrorClaimServiceClaimExceedsSumInsured(NftId policyNftId, Amount sumInsured, Amount payoutsIncludingClaimAmount);
|
34
|
+
error ErrorClaimsServicePayoutAmountIsZero(NftId policyNftId, PayoutId payoutId);
|
34
35
|
|
35
36
|
error ErrorClaimServiceClaimWithOpenPayouts(NftId policyNftId, ClaimId claimId, uint8 openPayouts);
|
36
37
|
error ErrorClaimServiceClaimWithMissingPayouts(NftId policyNftId, ClaimId claimId, Amount claimAmount, Amount paidAmount);
|
@@ -20,25 +20,31 @@ interface IPolicyService is IService {
|
|
20
20
|
|
21
21
|
error ErrorPolicyServicePolicyProductMismatch(NftId applicationNftId, NftId expectedProductNftId, NftId actualProductNftId);
|
22
22
|
error ErrorPolicyServicePolicyStateNotApplied(NftId applicationNftId);
|
23
|
-
error
|
23
|
+
error ErrorPolicyServicePolicyStateNotCollateralized(NftId applicationNftId);
|
24
|
+
error ErrorPolicyServicePolicyAlreadyActivated(NftId policyNftId);
|
24
25
|
|
25
|
-
error ErrorPolicyServicePremiumHigherThanExpected(
|
26
|
+
error ErrorPolicyServicePremiumHigherThanExpected(uint256 premiumExpectedAmount, uint256 premiumToBePaidAmount);
|
26
27
|
error ErrorPolicyServiceBalanceInsufficient(address policyOwner, uint256 premiumAmount, uint256 balance);
|
27
28
|
error ErrorPolicyServiceAllowanceInsufficient(address policyOwner, address tokenHandler, uint256 premiumAmount, uint256 allowance);
|
28
29
|
|
29
|
-
error
|
30
|
+
error ErrorPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
30
31
|
error ErrorPolicyServicePremiumAlreadyPaid(NftId policyNftId, Amount premiumPaidAmount);
|
31
|
-
error
|
32
|
-
error
|
33
|
-
error
|
32
|
+
error ErrorPolicyServicePolicyNotActivated(NftId policyNftId);
|
33
|
+
error ErrorPolicyServicePolicyAlreadyClosed(NftId policyNftId);
|
34
|
+
error ErrorPolicyServicePolicyNotActive(NftId policyNftId, StateId state);
|
34
35
|
error ErrorPolicyServicePremiumNotFullyPaid(NftId policyNftId, Amount premiumAmount, Amount premiumPaidAmount);
|
35
|
-
error
|
36
|
-
error
|
36
|
+
error ErrorPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
37
|
+
error ErrorPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
38
|
+
error ErrorPolicyServicePolicyExpirationTooLate(NftId policyNftId, Timestamp upperLimit, Timestamp expiredAt);
|
39
|
+
error ErrorPolicyServicePolicyExpirationTooEarly(NftId policyNftId, Timestamp lowerLimit, Timestamp expiredAt);
|
37
40
|
|
38
41
|
error ErrorPolicyServicePremiumMismatch(NftId policyNftId, Amount expectedPremiumAmount, Amount recalculatedPremiumAmount);
|
39
42
|
error ErrorPolicyServiceTransferredPremiumMismatch(NftId policyNftId, Amount expectedPremiumAmount, Amount transferredPremiumAmount);
|
40
43
|
|
41
|
-
|
44
|
+
event LogPolicyServicePolicyDeclined(NftId policyNftId);
|
45
|
+
event LogPolicyServicePolicyExpirationUpdated(NftId policyNftId, Timestamp expiredAt);
|
46
|
+
|
47
|
+
/// @dev collateralizes the policy represented by {policyNftId}. locks the sum insured amount in the pool.
|
42
48
|
/// sets the policy state to collateralized
|
43
49
|
/// may set the policy state to activated and set the activation date
|
44
50
|
/// optionally collects premiums and activates the policy.
|
@@ -57,18 +63,19 @@ interface IPolicyService is IService {
|
|
57
63
|
/// only the related product may decline an application
|
58
64
|
function decline(NftId policyNftId) external;
|
59
65
|
|
60
|
-
/// @dev collects the premium token for the specified policy
|
66
|
+
/// @dev collects the premium token for the specified policy (must be in COLLATERALIZED or ACTIVE state)
|
61
67
|
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
62
68
|
|
63
69
|
/// @dev activates the specified policy and sets the activation date in the policy metadata
|
64
70
|
/// to activate a policy it needs to be in underwritten state
|
65
71
|
function activate(NftId policyNftId, Timestamp activateAt) external;
|
66
72
|
|
67
|
-
/// @dev expires the specified policy and sets the expiry date in the policy metadata
|
73
|
+
/// @dev expires the specified policy and sets the expiry date in the policy metadata. If expiry date is set to 0, then the earliest possible expiry date (current blocktime) is set
|
68
74
|
/// 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
|
69
75
|
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
70
76
|
/// this function can only be called by a product. the policy needs to match with the calling product
|
71
|
-
|
77
|
+
/// @return expiredAt the effective expiry date
|
78
|
+
function expire(NftId policyNftId, Timestamp expireAt) external returns (Timestamp expiredAt);
|
72
79
|
|
73
80
|
/// @dev closes the specified policy and sets the closed data in the policy metadata
|
74
81
|
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
@@ -1,26 +1,21 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
+
|
4
6
|
import {IRegistry} from "../registry/IRegistry.sol";
|
5
7
|
import {Product} from "./Product.sol";
|
6
8
|
import {IComponents} from "../instance/module/IComponents.sol";
|
7
|
-
import {IDistributionComponent} from "../distribution/IDistributionComponent.sol";
|
8
9
|
import {IInstance} from "../instance/IInstance.sol";
|
9
10
|
import {IPolicy} from "../instance/module/IPolicy.sol";
|
10
|
-
import {IPoolComponent} from "../pool/IPoolComponent.sol";
|
11
|
-
import {IRisk} from "../instance/module/IRisk.sol";
|
12
|
-
import {IBundle} from "../instance/module/IBundle.sol";
|
13
11
|
|
14
12
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
15
13
|
|
16
14
|
import {Amount, AmountLib} from "../type/Amount.sol";
|
17
|
-
import {ClaimId, ClaimIdLib} from "../type/ClaimId.sol";
|
18
15
|
import {Timestamp, TimestampLib, zeroTimestamp} from "../type/Timestamp.sol";
|
19
|
-
import {UFixed, UFixedLib} from "../type/UFixed.sol";
|
20
16
|
import {ObjectType, APPLICATION, COMPONENT, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE, CLAIM, PRICE} from "../type/ObjectType.sol";
|
21
|
-
import {APPLIED, COLLATERALIZED,
|
17
|
+
import {APPLIED, COLLATERALIZED, KEEP_STATE, CLOSED, DECLINED} from "../type/StateId.sol";
|
22
18
|
import {NftId, NftIdLib} from "../type/NftId.sol";
|
23
|
-
import {PayoutId, PayoutIdLib} from "../type/PayoutId.sol";
|
24
19
|
import {ReferralId} from "../type/Referral.sol";
|
25
20
|
import {StateId} from "../type/StateId.sol";
|
26
21
|
import {VersionPart} from "../type/Version.sol";
|
@@ -36,8 +31,6 @@ import {InstanceStore} from "../instance/InstanceStore.sol";
|
|
36
31
|
import {IPolicyService} from "./IPolicyService.sol";
|
37
32
|
import {IPoolService} from "../pool/IPoolService.sol";
|
38
33
|
import {IPricingService} from "./IPricingService.sol";
|
39
|
-
import {IService} from "../shared/IService.sol";
|
40
|
-
import {Service} from "../shared/Service.sol";
|
41
34
|
|
42
35
|
contract PolicyService is
|
43
36
|
ComponentVerifyingService,
|
@@ -90,20 +83,43 @@ contract PolicyService is
|
|
90
83
|
(, productInfo,) = _getAndVerifyActiveComponent(PRODUCT());
|
91
84
|
product = Product(productInfo.objectAddress);
|
92
85
|
}
|
93
|
-
|
86
|
+
|
94
87
|
|
95
88
|
function decline(
|
96
|
-
NftId policyNftId
|
89
|
+
NftId applicationNftId // = policyNftId
|
97
90
|
)
|
98
91
|
external
|
99
|
-
override
|
92
|
+
virtual override
|
100
93
|
{
|
101
|
-
|
94
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
95
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
96
|
+
|
97
|
+
// check policy is in state applied
|
98
|
+
if (instanceReader.getPolicyState(applicationNftId) != APPLIED()) {
|
99
|
+
revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
|
100
|
+
}
|
101
|
+
|
102
|
+
// check policy matches with calling product
|
103
|
+
IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
|
104
|
+
if(applicationInfo.productNftId != productNftId) {
|
105
|
+
revert ErrorPolicyServicePolicyProductMismatch(
|
106
|
+
applicationNftId,
|
107
|
+
applicationInfo.productNftId,
|
108
|
+
productNftId);
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
// store updated policy info
|
113
|
+
instance.getInstanceStore().updatePolicyState(
|
114
|
+
applicationNftId,
|
115
|
+
DECLINED());
|
116
|
+
|
117
|
+
emit LogPolicyServicePolicyDeclined(applicationNftId);
|
102
118
|
}
|
103
119
|
|
104
120
|
event LogDebug(uint idx, string message);
|
105
121
|
|
106
|
-
/// @
|
122
|
+
/// @inheritdoc IPolicyService
|
107
123
|
function collateralize(
|
108
124
|
NftId applicationNftId, // = policyNftId
|
109
125
|
bool requirePremiumPayment,
|
@@ -146,19 +162,20 @@ contract PolicyService is
|
|
146
162
|
|
147
163
|
// optional activation of policy
|
148
164
|
if(activateAt > zeroTimestamp()) {
|
149
|
-
newPolicyState = ACTIVE();
|
150
165
|
applicationInfo.activatedAt = activateAt;
|
151
166
|
applicationInfo.expiredAt = activateAt.addSeconds(applicationInfo.lifetime);
|
152
167
|
}
|
153
168
|
|
154
|
-
|
169
|
+
IPolicy.Premium memory premium;
|
170
|
+
|
171
|
+
// optional: calculate the premium and update counters for collection at the end of this function
|
155
172
|
if(requirePremiumPayment) {
|
156
|
-
|
173
|
+
premium = _calculateAndProcessPremium(
|
157
174
|
instance,
|
158
175
|
applicationNftId,
|
159
176
|
applicationInfo);
|
160
177
|
|
161
|
-
applicationInfo.premiumPaidAmount =
|
178
|
+
applicationInfo.premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
|
162
179
|
}
|
163
180
|
|
164
181
|
// store updated policy info
|
@@ -170,9 +187,14 @@ contract PolicyService is
|
|
170
187
|
// TODO add calling pool contract if it needs to validate application
|
171
188
|
|
172
189
|
// TODO: add logging
|
173
|
-
}
|
174
190
|
|
191
|
+
// optional: transfer funds for premium
|
192
|
+
if(requirePremiumPayment) {
|
193
|
+
_transferFunds(instanceReader, applicationNftId, applicationInfo.productNftId, premium);
|
194
|
+
}
|
195
|
+
}
|
175
196
|
|
197
|
+
/// @inheritdoc IPolicyService
|
176
198
|
function collectPremium(
|
177
199
|
NftId policyNftId,
|
178
200
|
Timestamp activateAt
|
@@ -186,8 +208,8 @@ contract PolicyService is
|
|
186
208
|
StateId stateId = instanceReader.getPolicyState(policyNftId);
|
187
209
|
|
188
210
|
// check policy is in state collateralized or active
|
189
|
-
if (!(stateId == COLLATERALIZED()
|
190
|
-
revert
|
211
|
+
if (!(stateId == COLLATERALIZED())) {
|
212
|
+
revert ErrorPolicyServicePolicyStateNotCollateralized(policyNftId);
|
191
213
|
}
|
192
214
|
|
193
215
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
@@ -197,11 +219,14 @@ contract PolicyService is
|
|
197
219
|
revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
|
198
220
|
}
|
199
221
|
|
200
|
-
|
222
|
+
// calculate premium
|
223
|
+
IPolicy.Premium memory premium = _calculateAndProcessPremium(
|
201
224
|
instance,
|
202
225
|
policyNftId,
|
203
226
|
policyInfo);
|
204
227
|
|
228
|
+
policyInfo.premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
|
229
|
+
|
205
230
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
206
231
|
|
207
232
|
if(activateAt.gtz() && policyInfo.activatedAt.eqz()) {
|
@@ -209,8 +234,11 @@ contract PolicyService is
|
|
209
234
|
}
|
210
235
|
|
211
236
|
// TODO: add logging
|
237
|
+
|
238
|
+
_transferFunds(instanceReader, policyNftId, policyInfo.productNftId, premium);
|
212
239
|
}
|
213
240
|
|
241
|
+
/// @inheritdoc IPolicyService
|
214
242
|
function activate(NftId policyNftId, Timestamp activateAt) public override {
|
215
243
|
// check caller is registered product
|
216
244
|
(,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
@@ -218,27 +246,66 @@ contract PolicyService is
|
|
218
246
|
|
219
247
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
220
248
|
|
221
|
-
|
222
|
-
|
223
|
-
|
249
|
+
if(! policyInfo.activatedAt.eqz()) {
|
250
|
+
revert ErrorPolicyServicePolicyAlreadyActivated(policyNftId);
|
251
|
+
}
|
224
252
|
|
225
253
|
policyInfo.activatedAt = activateAt;
|
226
254
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
227
255
|
|
228
|
-
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo,
|
256
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
229
257
|
|
230
258
|
// TODO: add logging
|
231
259
|
}
|
232
260
|
|
233
|
-
|
261
|
+
/// @inheritdoc IPolicyService
|
234
262
|
function expire(
|
235
|
-
NftId policyNftId
|
263
|
+
NftId policyNftId,
|
264
|
+
Timestamp expireAt
|
236
265
|
)
|
237
266
|
external
|
238
267
|
override
|
239
|
-
|
268
|
+
virtual
|
269
|
+
returns (Timestamp)
|
240
270
|
{
|
241
|
-
|
271
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
272
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
273
|
+
|
274
|
+
// check policy matches with calling product
|
275
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
276
|
+
if(policyInfo.productNftId != productNftId) {
|
277
|
+
revert ErrorPolicyServicePolicyProductMismatch(
|
278
|
+
policyNftId,
|
279
|
+
policyInfo.productNftId,
|
280
|
+
productNftId);
|
281
|
+
}
|
282
|
+
|
283
|
+
// check policy is active
|
284
|
+
StateId policyState = instanceReader.getPolicyState(policyNftId);
|
285
|
+
if (!_policyHasBeenActivated(policyState, policyInfo)) {
|
286
|
+
revert ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
287
|
+
}
|
288
|
+
|
289
|
+
// set expiryAt to current block timestamp if not set
|
290
|
+
if (expireAt.eqz()) {
|
291
|
+
expireAt = TimestampLib.blockTimestamp();
|
292
|
+
}
|
293
|
+
|
294
|
+
// check expiryAt represents a valid expiry time
|
295
|
+
if (expireAt >= policyInfo.expiredAt) {
|
296
|
+
revert ErrorPolicyServicePolicyExpirationTooLate(policyNftId, policyInfo.expiredAt, expireAt);
|
297
|
+
}
|
298
|
+
if (expireAt < TimestampLib.blockTimestamp()) {
|
299
|
+
revert ErrorPolicyServicePolicyExpirationTooEarly(policyNftId, TimestampLib.blockTimestamp(), expireAt);
|
300
|
+
}
|
301
|
+
|
302
|
+
// update policyInfo with new expiryAt timestamp
|
303
|
+
policyInfo.expiredAt = expireAt;
|
304
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
305
|
+
|
306
|
+
emit LogPolicyServicePolicyExpirationUpdated(policyNftId, expireAt);
|
307
|
+
|
308
|
+
return expireAt;
|
242
309
|
}
|
243
310
|
|
244
311
|
function close(
|
@@ -250,19 +317,21 @@ contract PolicyService is
|
|
250
317
|
(,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
251
318
|
InstanceReader instanceReader = instance.getInstanceReader();
|
252
319
|
|
320
|
+
// check that policy has been activated
|
253
321
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
254
|
-
|
255
|
-
if (policyInfo
|
256
|
-
revert
|
322
|
+
StateId policyState = instanceReader.getPolicyState(policyNftId);
|
323
|
+
if (!_policyHasBeenActivated(policyState, policyInfo)) {
|
324
|
+
revert ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
257
325
|
}
|
258
326
|
|
259
|
-
|
260
|
-
if (
|
261
|
-
revert
|
327
|
+
// check that policy has not already been closed
|
328
|
+
if (policyInfo.closedAt.gtz()) {
|
329
|
+
revert ErrorPolicyServicePolicyAlreadyClosed(policyNftId);
|
262
330
|
}
|
263
331
|
|
264
|
-
|
265
|
-
|
332
|
+
// check that policy does not have any open claims
|
333
|
+
if (policyInfo.openClaimsCount > 0) {
|
334
|
+
revert ErrorPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
|
266
335
|
}
|
267
336
|
|
268
337
|
// TODO consider to allow for underpaid premiums (with the effects of reducing max payouts accordingly)
|
@@ -270,23 +339,37 @@ contract PolicyService is
|
|
270
339
|
revert ErrorPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
|
271
340
|
}
|
272
341
|
|
273
|
-
|
274
|
-
revert ErrorIPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
|
275
|
-
}
|
276
|
-
|
277
|
-
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
278
|
-
|
342
|
+
// release (remaining) collateral that was blocked by policy
|
279
343
|
_poolService.releaseCollateral(
|
280
344
|
instance,
|
281
345
|
address(instanceReader.getComponentInfo(policyInfo.productNftId).token),
|
282
346
|
policyNftId,
|
283
347
|
policyInfo);
|
284
348
|
|
349
|
+
// update policy state to closed
|
350
|
+
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
285
351
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, CLOSED());
|
286
352
|
}
|
287
353
|
|
288
354
|
|
289
|
-
|
355
|
+
/// @dev checks that policy has been collateralized and has been activated.
|
356
|
+
/// does not check if policy has been expired or closed.
|
357
|
+
function _policyHasBeenActivated(
|
358
|
+
StateId policyState,
|
359
|
+
IPolicy.PolicyInfo memory policyInfo
|
360
|
+
)
|
361
|
+
internal
|
362
|
+
view
|
363
|
+
returns (bool)
|
364
|
+
{
|
365
|
+
if (policyState != COLLATERALIZED()) { return false; }
|
366
|
+
if (TimestampLib.blockTimestamp() < policyInfo.activatedAt) { return false; }
|
367
|
+
return true;
|
368
|
+
}
|
369
|
+
|
370
|
+
|
371
|
+
/// @dev calculates the premium and updates all counters in the other services
|
372
|
+
function _calculateAndProcessPremium(
|
290
373
|
IInstance instance,
|
291
374
|
NftId applicationNftId,
|
292
375
|
IPolicy.PolicyInfo memory applicationInfo
|
@@ -294,13 +377,14 @@ contract PolicyService is
|
|
294
377
|
internal
|
295
378
|
virtual
|
296
379
|
returns (
|
297
|
-
|
380
|
+
IPolicy.Premium memory premium
|
298
381
|
)
|
299
382
|
{
|
300
383
|
NftId productNftId = applicationInfo.productNftId;
|
384
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
301
385
|
|
302
386
|
// calculate premium details
|
303
|
-
|
387
|
+
premium = _pricingService.calculatePremium(
|
304
388
|
productNftId,
|
305
389
|
applicationInfo.riskId,
|
306
390
|
applicationInfo.sumInsuredAmount,
|
@@ -309,90 +393,63 @@ contract PolicyService is
|
|
309
393
|
applicationInfo.bundleNftId,
|
310
394
|
applicationInfo.referralId);
|
311
395
|
|
396
|
+
// ensure the calculated premium is not higher than the expected premium from the application
|
397
|
+
if (applicationInfo.premiumAmount.toInt() < premium.premiumAmount) {
|
398
|
+
revert ErrorPolicyServicePremiumHigherThanExpected(applicationInfo.premiumAmount.toInt(), premium.premiumAmount);
|
399
|
+
}
|
312
400
|
|
313
|
-
//
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
function _processAndCollect(
|
326
|
-
IInstance instance,
|
327
|
-
NftId productNftId,
|
328
|
-
NftId policyNftId,
|
329
|
-
Amount premiumExpectedAmount,
|
330
|
-
NftId bundleNftId,
|
331
|
-
ReferralId referralId,
|
332
|
-
IPolicy.Premium memory premium
|
333
|
-
)
|
334
|
-
internal
|
335
|
-
virtual
|
336
|
-
returns (Amount premiumPaidAmount)
|
337
|
-
{
|
338
|
-
InstanceReader instanceReader = instance.getInstanceReader();
|
339
|
-
TokenHandler tokenHandler = instanceReader.getComponentInfo(productNftId).tokenHandler;
|
340
|
-
address policyHolder = getRegistry().ownerOf(policyNftId);
|
341
|
-
premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
|
342
|
-
|
343
|
-
_checkPremiumBalanceAndAllowance(
|
344
|
-
tokenHandler,
|
345
|
-
policyHolder,
|
346
|
-
premiumExpectedAmount,
|
347
|
-
premiumPaidAmount);
|
401
|
+
// check if premium balance and allowance of policy holder is sufficient
|
402
|
+
{
|
403
|
+
TokenHandler tokenHandler = instanceReader.getComponentInfo(productNftId).tokenHandler;
|
404
|
+
address policyHolder = getRegistry().ownerOf(applicationNftId);
|
405
|
+
|
406
|
+
_checkPremiumBalanceAndAllowance(
|
407
|
+
tokenHandler.getToken(),
|
408
|
+
address(tokenHandler),
|
409
|
+
policyHolder,
|
410
|
+
applicationInfo.premiumAmount,
|
411
|
+
AmountLib.toAmount(premium.premiumAmount));
|
412
|
+
}
|
348
413
|
|
349
|
-
|
414
|
+
// update the counters
|
415
|
+
_processSale(
|
350
416
|
instanceReader,
|
351
417
|
instance.getInstanceStore(),
|
352
|
-
tokenHandler,
|
353
|
-
policyHolder,
|
354
418
|
productNftId,
|
355
|
-
bundleNftId,
|
356
|
-
referralId,
|
419
|
+
applicationInfo.bundleNftId,
|
420
|
+
applicationInfo.referralId,
|
357
421
|
premium);
|
358
422
|
}
|
359
423
|
|
360
|
-
|
424
|
+
/// @dev checks the balance and allowance of the policy holder
|
361
425
|
function _checkPremiumBalanceAndAllowance(
|
362
|
-
|
426
|
+
IERC20Metadata token,
|
427
|
+
address tokenHandlerAddress,
|
363
428
|
address policyHolder,
|
364
429
|
Amount premiumExpectedAmount,
|
365
|
-
Amount
|
430
|
+
Amount premiumAmount
|
366
431
|
)
|
367
432
|
internal
|
368
433
|
virtual
|
369
434
|
view
|
370
435
|
{
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
revert ErrorPolicyServicePremiumHigherThanExpected(premiumExpectedAmount, premiumPaidAmount);
|
375
|
-
}
|
376
|
-
|
377
|
-
uint256 premiumAmount = premiumPaidAmount.toInt();
|
378
|
-
uint256 balance = tokenHandler.getToken().balanceOf(policyHolder);
|
379
|
-
uint256 allowance = tokenHandler.getToken().allowance(policyHolder, address(tokenHandler));
|
436
|
+
uint256 premium = premiumAmount.toInt();
|
437
|
+
uint256 balance = token.balanceOf(policyHolder);
|
438
|
+
uint256 allowance = token.allowance(policyHolder, tokenHandlerAddress);
|
380
439
|
|
381
|
-
if (balance <
|
382
|
-
revert ErrorPolicyServiceBalanceInsufficient(policyHolder,
|
440
|
+
if (balance < premium) {
|
441
|
+
revert ErrorPolicyServiceBalanceInsufficient(policyHolder, premium, balance);
|
383
442
|
}
|
384
443
|
|
385
|
-
if (allowance <
|
386
|
-
revert ErrorPolicyServiceAllowanceInsufficient(policyHolder,
|
444
|
+
if (allowance < premium) {
|
445
|
+
revert ErrorPolicyServiceAllowanceInsufficient(policyHolder, tokenHandlerAddress, premium, allowance);
|
387
446
|
}
|
388
447
|
}
|
389
448
|
|
390
|
-
|
391
|
-
function
|
449
|
+
/// @dev update counters by calling the involved services
|
450
|
+
function _processSale(
|
392
451
|
InstanceReader instanceReader,
|
393
452
|
InstanceStore instanceStore,
|
394
|
-
TokenHandler tokenHandler,
|
395
|
-
address policyHolder,
|
396
453
|
NftId productNftId,
|
397
454
|
NftId bundleNftId,
|
398
455
|
ReferralId referralId,
|
@@ -426,6 +483,29 @@ contract PolicyService is
|
|
426
483
|
_poolService.processSale(
|
427
484
|
bundleNftId,
|
428
485
|
premium);
|
486
|
+
}
|
487
|
+
|
488
|
+
/// @dev transfer the premium to the wallets the premium is distributed to
|
489
|
+
function _transferFunds(
|
490
|
+
InstanceReader instanceReader,
|
491
|
+
NftId policyNftId,
|
492
|
+
NftId productNftId,
|
493
|
+
IPolicy.Premium memory premium
|
494
|
+
)
|
495
|
+
internal
|
496
|
+
virtual
|
497
|
+
{
|
498
|
+
TokenHandler tokenHandler = instanceReader.getComponentInfo(productNftId).tokenHandler;
|
499
|
+
address policyHolder = getRegistry().ownerOf(policyNftId);
|
500
|
+
|
501
|
+
(
|
502
|
+
NftId distributionNftId,
|
503
|
+
address distributionWallet,
|
504
|
+
address poolWallet,
|
505
|
+
address productWallet
|
506
|
+
) = _getDistributionNftAndWallets(
|
507
|
+
instanceReader,
|
508
|
+
productNftId);
|
429
509
|
|
430
510
|
// TODO: centralize token handling (issue #471)
|
431
511
|
// transfer premium amounts to target wallets
|