@etherisc/gif-next 0.0.2-7b65ccc-404 → 0.0.2-7bdd29a-841
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 +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 +16 -16
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +9 -9
- 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 +4 -98
- 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 +111 -103
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +48 -52
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +17 -1
- 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 +12 -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 +112 -118
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +51 -27
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +21 -32
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +9 -17
- 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/IApplicationService.sol/IApplicationService.json +5 -0
- 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 +188 -108
- 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 +260 -167
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +42 -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/InstanceService.sol +51 -27
- package/contracts/instance/base/ObjectLifecycle.sol +2 -3
- package/contracts/instance/module/IComponents.sol +1 -7
- package/contracts/instance/module/IPolicy.sol +1 -1
- package/contracts/mock/Dip.sol +1 -1
- package/contracts/pool/BasicPool.sol +4 -4
- package/contracts/pool/BasicPoolAuthorization.sol +2 -2
- package/contracts/pool/BundleService.sol +35 -19
- package/contracts/pool/IBundleService.sol +6 -3
- package/contracts/pool/IPoolService.sol +5 -14
- package/contracts/pool/Pool.sol +7 -11
- package/contracts/pool/PoolService.sol +64 -67
- package/contracts/product/ApplicationService.sol +37 -17
- package/contracts/product/BasicProduct.sol +3 -33
- package/contracts/product/ClaimService.sol +16 -9
- package/contracts/product/IApplicationService.sol +1 -0
- package/contracts/product/IClaimService.sol +1 -0
- package/contracts/product/IPolicyService.sol +23 -17
- package/contracts/product/PolicyService.sol +229 -127
- package/contracts/product/PricingService.sol +5 -1
- package/contracts/product/Product.sol +26 -5
- package/contracts/shared/Component.sol +8 -7
- package/contracts/shared/ComponentService.sol +3 -4
- 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,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,
|
@@ -85,26 +78,41 @@ contract PolicyService is
|
|
85
78
|
}
|
86
79
|
|
87
80
|
|
88
|
-
function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
|
89
|
-
IRegistry.ObjectInfo memory productInfo;
|
90
|
-
(, productInfo,) = _getAndVerifyActiveComponent(PRODUCT());
|
91
|
-
product = Product(productInfo.objectAddress);
|
92
|
-
}
|
93
|
-
|
94
|
-
|
95
81
|
function decline(
|
96
|
-
NftId policyNftId
|
82
|
+
NftId applicationNftId // = policyNftId
|
97
83
|
)
|
98
84
|
external
|
99
|
-
override
|
85
|
+
virtual override
|
100
86
|
{
|
101
|
-
|
87
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
88
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
89
|
+
|
90
|
+
// check policy is in state applied
|
91
|
+
if (instanceReader.getPolicyState(applicationNftId) != APPLIED()) {
|
92
|
+
revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
|
93
|
+
}
|
94
|
+
|
95
|
+
// check policy matches with calling product
|
96
|
+
IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
|
97
|
+
if(applicationInfo.productNftId != productNftId) {
|
98
|
+
revert ErrorPolicyServicePolicyProductMismatch(
|
99
|
+
applicationNftId,
|
100
|
+
applicationInfo.productNftId,
|
101
|
+
productNftId);
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
// store updated policy info
|
106
|
+
instance.getInstanceStore().updatePolicyState(
|
107
|
+
applicationNftId,
|
108
|
+
DECLINED());
|
109
|
+
|
110
|
+
emit LogPolicyServicePolicyDeclined(applicationNftId);
|
102
111
|
}
|
103
112
|
|
104
|
-
event LogDebug(uint idx, string message);
|
105
113
|
|
106
|
-
/// @
|
107
|
-
function
|
114
|
+
/// @inheritdoc IPolicyService
|
115
|
+
function createPolicy(
|
108
116
|
NftId applicationNftId, // = policyNftId
|
109
117
|
bool requirePremiumPayment,
|
110
118
|
Timestamp activateAt
|
@@ -146,19 +154,20 @@ contract PolicyService is
|
|
146
154
|
|
147
155
|
// optional activation of policy
|
148
156
|
if(activateAt > zeroTimestamp()) {
|
149
|
-
newPolicyState = ACTIVE();
|
150
157
|
applicationInfo.activatedAt = activateAt;
|
151
158
|
applicationInfo.expiredAt = activateAt.addSeconds(applicationInfo.lifetime);
|
152
159
|
}
|
153
160
|
|
154
|
-
|
161
|
+
IPolicy.Premium memory premium;
|
162
|
+
|
163
|
+
// optional: calculate the premium and update counters for collection at the end of this function
|
155
164
|
if(requirePremiumPayment) {
|
156
|
-
|
165
|
+
premium = _calculateAndProcessPremium(
|
157
166
|
instance,
|
158
167
|
applicationNftId,
|
159
168
|
applicationInfo);
|
160
169
|
|
161
|
-
applicationInfo.premiumPaidAmount =
|
170
|
+
applicationInfo.premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
|
162
171
|
}
|
163
172
|
|
164
173
|
// store updated policy info
|
@@ -170,9 +179,17 @@ contract PolicyService is
|
|
170
179
|
// TODO add calling pool contract if it needs to validate application
|
171
180
|
|
172
181
|
// TODO: add logging
|
182
|
+
|
183
|
+
// optional: transfer funds for premium
|
184
|
+
if(requirePremiumPayment) {
|
185
|
+
_transferFunds(instanceReader, applicationNftId, applicationInfo.productNftId, premium);
|
186
|
+
}
|
187
|
+
|
188
|
+
// TODO: add callback IPolicyHolder.policyActivated() if applicable
|
173
189
|
}
|
174
190
|
|
175
191
|
|
192
|
+
/// @inheritdoc IPolicyService
|
176
193
|
function collectPremium(
|
177
194
|
NftId policyNftId,
|
178
195
|
Timestamp activateAt
|
@@ -186,8 +203,8 @@ contract PolicyService is
|
|
186
203
|
StateId stateId = instanceReader.getPolicyState(policyNftId);
|
187
204
|
|
188
205
|
// check policy is in state collateralized or active
|
189
|
-
if (!(stateId == COLLATERALIZED()
|
190
|
-
revert
|
206
|
+
if (!(stateId == COLLATERALIZED())) {
|
207
|
+
revert ErrorPolicyServicePolicyStateNotCollateralized(policyNftId);
|
191
208
|
}
|
192
209
|
|
193
210
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
@@ -197,50 +214,99 @@ contract PolicyService is
|
|
197
214
|
revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
|
198
215
|
}
|
199
216
|
|
200
|
-
|
217
|
+
// calculate premium
|
218
|
+
IPolicy.Premium memory premium = _calculateAndProcessPremium(
|
201
219
|
instance,
|
202
220
|
policyNftId,
|
203
221
|
policyInfo);
|
204
222
|
|
205
|
-
|
223
|
+
policyInfo.premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
|
206
224
|
|
207
|
-
|
208
|
-
|
225
|
+
// optionally activate policy
|
226
|
+
if(activateAt.gtz()) {
|
227
|
+
policyInfo = _activate(policyNftId, policyInfo, activateAt);
|
209
228
|
}
|
210
229
|
|
230
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
231
|
+
|
211
232
|
// TODO: add logging
|
233
|
+
|
234
|
+
_transferFunds(instanceReader, policyNftId, policyInfo.productNftId, premium);
|
235
|
+
|
236
|
+
// TODO: add callback IPolicyHolder.policyActivated() if applicable
|
212
237
|
}
|
213
238
|
|
239
|
+
/// @inheritdoc IPolicyService
|
214
240
|
function activate(NftId policyNftId, Timestamp activateAt) public override {
|
215
241
|
// check caller is registered product
|
216
242
|
(,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
217
243
|
InstanceReader instanceReader = instance.getInstanceReader();
|
218
244
|
|
219
245
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
246
|
+
policyInfo = _activate(policyNftId, policyInfo, activateAt);
|
220
247
|
|
221
|
-
|
222
|
-
policyInfo.activatedAt.eqz(),
|
223
|
-
"ERROR:PRS-020:ALREADY_ACTIVATED");
|
224
|
-
|
225
|
-
policyInfo.activatedAt = activateAt;
|
226
|
-
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
227
|
-
|
228
|
-
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, ACTIVE());
|
248
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
229
249
|
|
230
250
|
// TODO: add logging
|
251
|
+
|
252
|
+
// TODO: add callback IPolicyHolder.policyActivated() if applicable
|
231
253
|
}
|
232
254
|
|
233
255
|
|
256
|
+
/// @inheritdoc IPolicyService
|
234
257
|
function expire(
|
235
|
-
NftId policyNftId
|
258
|
+
NftId policyNftId,
|
259
|
+
Timestamp expireAt
|
236
260
|
)
|
237
261
|
external
|
238
262
|
override
|
239
|
-
|
263
|
+
virtual
|
264
|
+
returns (Timestamp expiredAt)
|
240
265
|
{
|
241
|
-
|
266
|
+
(NftId productNftId,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
267
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
268
|
+
|
269
|
+
// check policy matches with calling product
|
270
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
271
|
+
if(policyInfo.productNftId != productNftId) {
|
272
|
+
revert ErrorPolicyServicePolicyProductMismatch(
|
273
|
+
policyNftId,
|
274
|
+
policyInfo.productNftId,
|
275
|
+
productNftId);
|
276
|
+
}
|
277
|
+
|
278
|
+
// check policy is active
|
279
|
+
StateId policyState = instanceReader.getPolicyState(policyNftId);
|
280
|
+
if (!_policyHasBeenActivated(policyState, policyInfo)) {
|
281
|
+
revert ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
282
|
+
}
|
283
|
+
|
284
|
+
// set return value to provided timestamp
|
285
|
+
expiredAt = expireAt;
|
286
|
+
|
287
|
+
// update expiredAt to current block timestamp if not set
|
288
|
+
if (expiredAt.eqz()) {
|
289
|
+
expiredAt = TimestampLib.blockTimestamp();
|
290
|
+
}
|
291
|
+
|
292
|
+
// check expiredAt represents a valid expiry time
|
293
|
+
if (expiredAt >= policyInfo.expiredAt) {
|
294
|
+
revert ErrorPolicyServicePolicyExpirationTooLate(policyNftId, policyInfo.expiredAt, expireAt);
|
295
|
+
}
|
296
|
+
if (expiredAt < TimestampLib.blockTimestamp()) {
|
297
|
+
revert ErrorPolicyServicePolicyExpirationTooEarly(policyNftId, TimestampLib.blockTimestamp(), expireAt);
|
298
|
+
}
|
299
|
+
|
300
|
+
// update policyInfo with new expiredAt timestamp
|
301
|
+
policyInfo.expiredAt = expiredAt;
|
302
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
303
|
+
|
304
|
+
emit LogPolicyServicePolicyExpirationUpdated(policyNftId, expiredAt);
|
305
|
+
|
306
|
+
// TODO: add callback IPolicyHolder.policyExpired() if applicable
|
242
307
|
}
|
243
308
|
|
309
|
+
|
244
310
|
function close(
|
245
311
|
NftId policyNftId
|
246
312
|
)
|
@@ -250,19 +316,21 @@ contract PolicyService is
|
|
250
316
|
(,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
|
251
317
|
InstanceReader instanceReader = instance.getInstanceReader();
|
252
318
|
|
319
|
+
// check that policy has been activated
|
253
320
|
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
254
|
-
|
255
|
-
if (policyInfo
|
256
|
-
revert
|
321
|
+
StateId policyState = instanceReader.getPolicyState(policyNftId);
|
322
|
+
if (!_policyHasBeenActivated(policyState, policyInfo)) {
|
323
|
+
revert ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
257
324
|
}
|
258
325
|
|
259
|
-
|
260
|
-
if (
|
261
|
-
revert
|
326
|
+
// check that policy has not already been closed
|
327
|
+
if (policyInfo.closedAt.gtz()) {
|
328
|
+
revert ErrorPolicyServicePolicyAlreadyClosed(policyNftId);
|
262
329
|
}
|
263
330
|
|
264
|
-
|
265
|
-
|
331
|
+
// check that policy does not have any open claims
|
332
|
+
if (policyInfo.openClaimsCount > 0) {
|
333
|
+
revert ErrorPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
|
266
334
|
}
|
267
335
|
|
268
336
|
// TODO consider to allow for underpaid premiums (with the effects of reducing max payouts accordingly)
|
@@ -270,23 +338,21 @@ contract PolicyService is
|
|
270
338
|
revert ErrorPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
|
271
339
|
}
|
272
340
|
|
273
|
-
|
274
|
-
revert ErrorIPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
|
275
|
-
}
|
276
|
-
|
277
|
-
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
278
|
-
|
341
|
+
// release (remaining) collateral that was blocked by policy
|
279
342
|
_poolService.releaseCollateral(
|
280
343
|
instance,
|
281
344
|
address(instanceReader.getComponentInfo(policyInfo.productNftId).token),
|
282
345
|
policyNftId,
|
283
346
|
policyInfo);
|
284
347
|
|
348
|
+
// update policy state to closed
|
349
|
+
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
285
350
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, CLOSED());
|
286
351
|
}
|
287
352
|
|
288
353
|
|
289
|
-
|
354
|
+
/// @dev calculates the premium and updates all counters in the other services
|
355
|
+
function _calculateAndProcessPremium(
|
290
356
|
IInstance instance,
|
291
357
|
NftId applicationNftId,
|
292
358
|
IPolicy.PolicyInfo memory applicationInfo
|
@@ -294,13 +360,14 @@ contract PolicyService is
|
|
294
360
|
internal
|
295
361
|
virtual
|
296
362
|
returns (
|
297
|
-
|
363
|
+
IPolicy.Premium memory premium
|
298
364
|
)
|
299
365
|
{
|
300
366
|
NftId productNftId = applicationInfo.productNftId;
|
367
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
301
368
|
|
302
369
|
// calculate premium details
|
303
|
-
|
370
|
+
premium = _pricingService.calculatePremium(
|
304
371
|
productNftId,
|
305
372
|
applicationInfo.riskId,
|
306
373
|
applicationInfo.sumInsuredAmount,
|
@@ -309,90 +376,53 @@ contract PolicyService is
|
|
309
376
|
applicationInfo.bundleNftId,
|
310
377
|
applicationInfo.referralId);
|
311
378
|
|
379
|
+
// check if premium balance and allowance of policy holder is sufficient
|
380
|
+
{
|
381
|
+
TokenHandler tokenHandler = _getTokenHandler(instanceReader, productNftId);
|
382
|
+
address policyHolder = getRegistry().ownerOf(applicationNftId);
|
383
|
+
|
384
|
+
_checkPremiumBalanceAndAllowance(
|
385
|
+
tokenHandler.getToken(),
|
386
|
+
address(tokenHandler),
|
387
|
+
policyHolder,
|
388
|
+
AmountLib.toAmount(premium.premiumAmount));
|
389
|
+
}
|
312
390
|
|
313
|
-
// update
|
314
|
-
|
315
|
-
instance,
|
316
|
-
productNftId,
|
317
|
-
applicationNftId,
|
318
|
-
applicationInfo.premiumAmount,
|
319
|
-
applicationInfo.bundleNftId,
|
320
|
-
applicationInfo.referralId,
|
321
|
-
premium);
|
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);
|
348
|
-
|
349
|
-
_processSaleAndTransferFunds(
|
391
|
+
// update the counters
|
392
|
+
_processSale(
|
350
393
|
instanceReader,
|
351
394
|
instance.getInstanceStore(),
|
352
|
-
tokenHandler,
|
353
|
-
policyHolder,
|
354
395
|
productNftId,
|
355
|
-
bundleNftId,
|
356
|
-
referralId,
|
396
|
+
applicationInfo.bundleNftId,
|
397
|
+
applicationInfo.referralId,
|
357
398
|
premium);
|
358
399
|
}
|
359
400
|
|
360
401
|
|
361
|
-
function
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
Amount premiumPaidAmount
|
402
|
+
function _activate(
|
403
|
+
NftId policyNftId,
|
404
|
+
IPolicy.PolicyInfo memory policyInfo,
|
405
|
+
Timestamp activateAt
|
366
406
|
)
|
367
407
|
internal
|
368
408
|
virtual
|
369
|
-
view
|
409
|
+
view
|
410
|
+
returns (IPolicy.PolicyInfo memory)
|
370
411
|
{
|
371
|
-
|
372
|
-
|
373
|
-
if (premiumExpectedAmount < premiumPaidAmount) {
|
374
|
-
revert ErrorPolicyServicePremiumHigherThanExpected(premiumExpectedAmount, premiumPaidAmount);
|
412
|
+
if(! policyInfo.activatedAt.eqz()) {
|
413
|
+
revert ErrorPolicyServicePolicyAlreadyActivated(policyNftId);
|
375
414
|
}
|
376
415
|
|
377
|
-
|
378
|
-
|
379
|
-
uint256 allowance = tokenHandler.getToken().allowance(policyHolder, address(tokenHandler));
|
380
|
-
|
381
|
-
if (balance < premiumAmount) {
|
382
|
-
revert ErrorPolicyServiceBalanceInsufficient(policyHolder, premiumAmount, balance);
|
383
|
-
}
|
416
|
+
policyInfo.activatedAt = activateAt;
|
417
|
+
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
384
418
|
|
385
|
-
|
386
|
-
revert ErrorPolicyServiceAllowanceInsufficient(policyHolder, address(tokenHandler), premiumAmount, allowance);
|
387
|
-
}
|
419
|
+
return policyInfo;
|
388
420
|
}
|
389
421
|
|
390
|
-
|
391
|
-
function
|
422
|
+
/// @dev update counters by calling the involved services
|
423
|
+
function _processSale(
|
392
424
|
InstanceReader instanceReader,
|
393
425
|
InstanceStore instanceStore,
|
394
|
-
TokenHandler tokenHandler,
|
395
|
-
address policyHolder,
|
396
426
|
NftId productNftId,
|
397
427
|
NftId bundleNftId,
|
398
428
|
ReferralId referralId,
|
@@ -426,6 +456,30 @@ contract PolicyService is
|
|
426
456
|
_poolService.processSale(
|
427
457
|
bundleNftId,
|
428
458
|
premium);
|
459
|
+
}
|
460
|
+
|
461
|
+
|
462
|
+
/// @dev transfer the premium to the wallets the premium is distributed to
|
463
|
+
function _transferFunds(
|
464
|
+
InstanceReader instanceReader,
|
465
|
+
NftId policyNftId,
|
466
|
+
NftId productNftId,
|
467
|
+
IPolicy.Premium memory premium
|
468
|
+
)
|
469
|
+
internal
|
470
|
+
virtual
|
471
|
+
{
|
472
|
+
TokenHandler tokenHandler = _getTokenHandler(instanceReader, productNftId);
|
473
|
+
address policyHolder = getRegistry().ownerOf(policyNftId);
|
474
|
+
|
475
|
+
(
|
476
|
+
NftId distributionNftId,
|
477
|
+
address distributionWallet,
|
478
|
+
address poolWallet,
|
479
|
+
address productWallet
|
480
|
+
) = _getDistributionNftAndWallets(
|
481
|
+
instanceReader,
|
482
|
+
productNftId);
|
429
483
|
|
430
484
|
// TODO: centralize token handling (issue #471)
|
431
485
|
// transfer premium amounts to target wallets
|
@@ -435,7 +489,48 @@ contract PolicyService is
|
|
435
489
|
}
|
436
490
|
|
437
491
|
|
438
|
-
|
492
|
+
/// @dev checks that policy has been collateralized and has been activated.
|
493
|
+
/// does not check if policy has been expired or closed.
|
494
|
+
function _policyHasBeenActivated(
|
495
|
+
StateId policyState,
|
496
|
+
IPolicy.PolicyInfo memory policyInfo
|
497
|
+
)
|
498
|
+
internal
|
499
|
+
view
|
500
|
+
returns (bool)
|
501
|
+
{
|
502
|
+
if (policyState != COLLATERALIZED()) { return false; }
|
503
|
+
if (TimestampLib.blockTimestamp() < policyInfo.activatedAt) { return false; }
|
504
|
+
return true;
|
505
|
+
}
|
506
|
+
|
507
|
+
|
508
|
+
/// @dev checks the balance and allowance of the policy holder
|
509
|
+
function _checkPremiumBalanceAndAllowance(
|
510
|
+
IERC20Metadata token,
|
511
|
+
address tokenHandlerAddress,
|
512
|
+
address policyHolder,
|
513
|
+
Amount premiumAmount
|
514
|
+
)
|
515
|
+
internal
|
516
|
+
virtual
|
517
|
+
view
|
518
|
+
{
|
519
|
+
uint256 premium = premiumAmount.toInt();
|
520
|
+
uint256 balance = token.balanceOf(policyHolder);
|
521
|
+
uint256 allowance = token.allowance(policyHolder, tokenHandlerAddress);
|
522
|
+
|
523
|
+
if (balance < premium) {
|
524
|
+
revert ErrorPolicyServiceBalanceInsufficient(policyHolder, premium, balance);
|
525
|
+
}
|
526
|
+
|
527
|
+
if (allowance < premium) {
|
528
|
+
revert ErrorPolicyServiceAllowanceInsufficient(policyHolder, tokenHandlerAddress, premium, allowance);
|
529
|
+
}
|
530
|
+
}
|
531
|
+
|
532
|
+
|
533
|
+
function _getTokenHandler(
|
439
534
|
InstanceReader instanceReader,
|
440
535
|
NftId productNftId
|
441
536
|
)
|
@@ -470,6 +565,13 @@ contract PolicyService is
|
|
470
565
|
}
|
471
566
|
|
472
567
|
|
568
|
+
function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
|
569
|
+
IRegistry.ObjectInfo memory productInfo;
|
570
|
+
(, productInfo,) = _getAndVerifyActiveComponent(PRODUCT());
|
571
|
+
product = Product(productInfo.objectAddress);
|
572
|
+
}
|
573
|
+
|
574
|
+
|
473
575
|
function _getDomain() internal pure override returns(ObjectType) {
|
474
576
|
return POLICY();
|
475
577
|
}
|
@@ -84,6 +84,7 @@ contract PricingService is
|
|
84
84
|
IInstance instance
|
85
85
|
) = _getAndVerifyComponentInfo(productNftId, PRODUCT(), false);
|
86
86
|
|
87
|
+
// get instance reader from local instance variable
|
87
88
|
reader = instance.getInstanceReader();
|
88
89
|
|
89
90
|
// calculate net premium
|
@@ -104,19 +105,21 @@ contract PricingService is
|
|
104
105
|
revert ErrorIPricingServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, productInfo.poolNftId);
|
105
106
|
}
|
106
107
|
|
107
|
-
// calculate
|
108
|
+
// calculate fixed fees for product, pool, bundle
|
108
109
|
premium = _getFixedFeeAmounts(
|
109
110
|
netPremiumAmount,
|
110
111
|
productInfo,
|
111
112
|
bundleInfo
|
112
113
|
);
|
113
114
|
|
115
|
+
// calculate variable fees for product, pool, bundle
|
114
116
|
premium = _calculateVariableFeeAmounts(
|
115
117
|
premium,
|
116
118
|
productInfo,
|
117
119
|
bundleInfo
|
118
120
|
);
|
119
121
|
|
122
|
+
// calculate distribution fee and (if applicable) commission
|
120
123
|
premium = _calculateDistributionOwnerFeeAmount(
|
121
124
|
premium,
|
122
125
|
productInfo,
|
@@ -124,6 +127,7 @@ contract PricingService is
|
|
124
127
|
reader
|
125
128
|
);
|
126
129
|
|
130
|
+
// calculate resulting amounts for product, pool, and distribution wallets
|
127
131
|
premium = _calculateTargetWalletAmounts(premium);
|
128
132
|
|
129
133
|
// sanity check to validate the fee calculation
|
@@ -62,7 +62,7 @@ abstract contract Product is
|
|
62
62
|
NftId bundleNftId,
|
63
63
|
ReferralId referralId
|
64
64
|
)
|
65
|
-
|
65
|
+
public
|
66
66
|
view
|
67
67
|
override
|
68
68
|
returns (Amount premiumAmount)
|
@@ -233,6 +233,7 @@ abstract contract Product is
|
|
233
233
|
address applicationOwner,
|
234
234
|
RiskId riskId,
|
235
235
|
Amount sumInsuredAmount,
|
236
|
+
Amount premiumAmount,
|
236
237
|
Seconds lifetime,
|
237
238
|
NftId bundleNftId,
|
238
239
|
ReferralId referralId,
|
@@ -245,6 +246,7 @@ abstract contract Product is
|
|
245
246
|
applicationOwner,
|
246
247
|
riskId,
|
247
248
|
sumInsuredAmount,
|
249
|
+
premiumAmount,
|
248
250
|
lifetime,
|
249
251
|
bundleNftId,
|
250
252
|
referralId,
|
@@ -252,19 +254,38 @@ abstract contract Product is
|
|
252
254
|
);
|
253
255
|
}
|
254
256
|
|
255
|
-
function
|
256
|
-
NftId
|
257
|
+
function _createPolicy(
|
258
|
+
NftId applicationNftId,
|
257
259
|
bool requirePremiumPayment,
|
258
260
|
Timestamp activateAt
|
259
261
|
)
|
260
262
|
internal
|
261
263
|
{
|
262
|
-
_getProductStorage()._policyService.
|
263
|
-
|
264
|
+
_getProductStorage()._policyService.createPolicy(
|
265
|
+
applicationNftId,
|
264
266
|
requirePremiumPayment,
|
265
267
|
activateAt);
|
266
268
|
}
|
267
269
|
|
270
|
+
function _decline(
|
271
|
+
NftId policyNftId
|
272
|
+
)
|
273
|
+
internal
|
274
|
+
{
|
275
|
+
_getProductStorage()._policyService.decline(
|
276
|
+
policyNftId);
|
277
|
+
}
|
278
|
+
|
279
|
+
function _expire(
|
280
|
+
NftId policyNftId,
|
281
|
+
Timestamp expireAt
|
282
|
+
)
|
283
|
+
internal
|
284
|
+
returns (Timestamp expiredAt)
|
285
|
+
{
|
286
|
+
expiredAt = _getProductStorage()._policyService.expire(policyNftId, expireAt);
|
287
|
+
}
|
288
|
+
|
268
289
|
function _collectPremium(
|
269
290
|
NftId policyNftId,
|
270
291
|
Timestamp activateAt
|