@etherisc/gif-next 0.0.2-e79d227-681 → 0.0.2-e7a5428-226
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +57 -1
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +1075 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +790 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +843 -0
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +640 -269
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.dbg.json +4 -0
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.json +1289 -0
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +202 -5
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +409 -33
- 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/IAccessAdmin.sol/IAccessAdmin.json +525 -213
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +179 -19
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +246 -16
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +420 -27
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +105 -185
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +381 -46
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +58 -127
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +533 -218
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +150 -82
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +37 -106
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +379 -79
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +183 -128
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +355 -52
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +324 -250
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +380 -45
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +191 -182
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +94 -100
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +196 -155
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +600 -296
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +805 -0
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +88 -45
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +482 -50
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +373 -13
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +493 -85
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1017 -334
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +380 -52
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +914 -554
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +377 -80
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +83 -57
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +690 -566
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +1 -1
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +141 -85
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +8 -8
- 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 +16 -5
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.json +168 -0
- 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/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +77 -81
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +379 -47
- 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/IOracleComponent.sol/IOracleComponent.json +41 -45
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +56 -3
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +61 -65
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +120 -68
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +99 -55
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +102 -114
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +355 -52
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +304 -226
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +120 -76
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +200 -89
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +59 -63
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +333 -169
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.json +72 -76
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.dbg.json +4 -0
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.json +522 -0
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +574 -360
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +146 -74
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +293 -63
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +106 -46
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +193 -182
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +380 -45
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +292 -195
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +127 -99
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +235 -4
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +181 -19
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +160 -68
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +77 -3
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +168 -157
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +1 -1
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.json +258 -22
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +278 -187
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.dbg.json +4 -0
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.json +783 -0
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +129 -85
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +135 -126
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +103 -75
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/Product.sol/Product.json +187 -176
- package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +1 -1
- package/artifacts/contracts/product/RiskService.sol/RiskService.json +326 -91
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +103 -47
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +54 -19
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +56 -3
- package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +4 -0
- package/artifacts/contracts/{authorization/AccessAdmin.sol/IAccessManagedChecker.json → registry/IRelease.sol/IRelease.json} +6 -6
- 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 +92 -57
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +727 -479
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1061 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +75 -39
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +79 -43
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +2152 -0
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +2 -2
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +386 -64
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +437 -26
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +120 -60
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.json +60 -50
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +247 -531
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +111 -95
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +178 -34
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.json +40 -0
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.json +41 -31
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +155 -382
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +41 -45
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +6 -6
- 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/INftOwnable.sol/INftOwnable.json +19 -0
- 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/IRegisterable.sol/IRegisterable.json +139 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +56 -3
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +2 -2
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +60 -64
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +6 -6
- 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/NftIdSet.sol/NftIdSet.json +2 -2
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +21 -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 +137 -62
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +51 -11
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +63 -162
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.json +118 -29
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +32 -32
- package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/IStaking.sol/IStaking.json +1026 -101
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +214 -110
- package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/staking/Staking.sol/Staking.json +1218 -214
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.dbg.json +4 -0
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.json +470 -0
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +2 -2
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +139 -61
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +174 -217
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +253 -174
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +87 -55
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +957 -603
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +101 -51
- 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/Amount.sol/AmountLib.json +11 -11
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +45 -19
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.dbg.json +4 -0
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.json +193 -0
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +2 -2
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Fee.sol/FeeLib.json +94 -38
- package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.dbg.json +1 -1
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.json +2 -2
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +33 -31
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +2 -2
- package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +30 -6
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +42 -157
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +45 -2
- package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorLib.json +21 -2
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +2 -2
- 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/String.sol/StrLib.json +50 -2
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +3 -3
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +61 -37
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -21
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.json +101 -2
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.json +10 -0
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +65 -27
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +15 -2
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.json +10 -0
- package/contracts/accounting/AccountingService.sol +274 -0
- package/contracts/accounting/AccountingServiceManager.sol +38 -0
- package/contracts/accounting/IAccountingService.sol +47 -0
- package/contracts/authorization/AccessAdmin.sol +422 -258
- package/contracts/authorization/AccessAdminLib.sol +396 -0
- package/contracts/authorization/AccessManagerCloneable.sol +146 -4
- package/contracts/authorization/Authorization.sol +142 -262
- package/contracts/authorization/IAccess.sol +25 -7
- package/contracts/authorization/IAccessAdmin.sol +87 -80
- package/contracts/authorization/IAuthorization.sol +9 -43
- package/contracts/authorization/IServiceAuthorization.sol +55 -17
- package/contracts/authorization/ServiceAuthorization.sol +248 -34
- package/contracts/distribution/BasicDistribution.sol +16 -14
- package/contracts/distribution/BasicDistributionAuthorization.sol +29 -9
- package/contracts/distribution/Distribution.sol +38 -75
- package/contracts/distribution/DistributionService.sol +181 -87
- package/contracts/distribution/DistributionServiceManager.sol +1 -1
- package/contracts/distribution/IDistributionComponent.sol +3 -10
- package/contracts/distribution/IDistributionService.sol +34 -19
- package/contracts/examples/fire/FirePool.sol +6 -6
- package/contracts/examples/fire/FirePoolAuthorization.sol +2 -1
- package/contracts/examples/fire/FireProduct.sol +15 -13
- package/contracts/examples/fire/FireProductAuthorization.sol +2 -1
- package/contracts/examples/unpermissioned/SimpleDistribution.sol +34 -11
- package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleOracle.sol +4 -8
- package/contracts/examples/unpermissioned/SimplePool.sol +7 -13
- package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleProduct.sol +119 -27
- package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +28 -0
- package/contracts/instance/BundleSet.sol +4 -4
- package/contracts/instance/IInstance.sol +92 -19
- package/contracts/instance/IInstanceService.sol +52 -9
- package/contracts/instance/Instance.sol +163 -57
- package/contracts/instance/InstanceAdmin.sol +271 -166
- package/contracts/instance/InstanceAuthorizationV3.sol +89 -40
- package/contracts/instance/InstanceReader.sol +422 -369
- package/contracts/instance/InstanceService.sol +252 -176
- package/contracts/instance/InstanceServiceManager.sol +1 -1
- package/contracts/instance/InstanceStore.sol +13 -2
- package/contracts/instance/RiskSet.sol +21 -14
- package/contracts/instance/base/BalanceStore.sol +4 -6
- package/contracts/instance/base/ObjectCounter.sol +1 -2
- package/contracts/instance/base/ObjectLifecycle.sol +6 -8
- package/contracts/instance/base/ObjectSet.sol +7 -8
- package/contracts/instance/base/ObjectSetHelperLib.sol +30 -0
- package/contracts/instance/module/IBundle.sol +6 -5
- package/contracts/instance/module/IComponents.sol +19 -7
- package/contracts/instance/module/IDistribution.sol +21 -8
- package/contracts/instance/module/IPolicy.sol +28 -8
- package/contracts/instance/module/IRisk.sol +4 -0
- package/contracts/oracle/BasicOracle.sol +2 -4
- package/contracts/oracle/BasicOracleAuthorization.sol +15 -8
- package/contracts/oracle/IOracle.sol +9 -4
- package/contracts/oracle/Oracle.sol +3 -5
- package/contracts/oracle/OracleService.sol +24 -23
- package/contracts/oracle/OracleServiceManager.sol +1 -1
- package/contracts/pool/BasicPool.sol +3 -16
- package/contracts/pool/BasicPoolAuthorization.sol +29 -16
- package/contracts/pool/BundleService.sol +67 -104
- package/contracts/pool/BundleServiceManager.sol +1 -1
- package/contracts/pool/IBundleService.sol +27 -33
- package/contracts/pool/IPoolService.sol +57 -40
- package/contracts/pool/Pool.sol +13 -25
- package/contracts/pool/PoolLib.sol +341 -0
- package/contracts/pool/PoolService.sol +203 -201
- package/contracts/pool/PoolServiceManager.sol +1 -1
- package/contracts/product/ApplicationService.sol +86 -18
- package/contracts/product/ApplicationServiceManager.sol +1 -1
- package/contracts/product/BasicProduct.sol +3 -3
- package/contracts/product/BasicProductAuthorization.sol +32 -11
- package/contracts/product/ClaimService.sol +187 -171
- package/contracts/product/ClaimServiceManager.sol +1 -1
- package/contracts/product/IApplicationService.sol +24 -2
- package/contracts/product/IClaimService.sol +18 -5
- package/contracts/product/IPolicyService.sol +20 -8
- package/contracts/product/IPricingService.sol +1 -0
- package/contracts/product/IProductComponent.sol +4 -1
- package/contracts/product/IRiskService.sol +25 -10
- package/contracts/product/PolicyService.sol +110 -198
- package/contracts/product/PolicyServiceLib.sol +139 -0
- package/contracts/product/PolicyServiceManager.sol +1 -1
- package/contracts/product/PricingService.sol +52 -46
- package/contracts/product/PricingServiceManager.sol +3 -3
- package/contracts/product/Product.sol +93 -27
- package/contracts/product/RiskService.sol +119 -36
- package/contracts/product/RiskServiceManager.sol +1 -1
- package/contracts/registry/ChainNft.sol +4 -2
- package/contracts/registry/IRegistry.sol +23 -24
- package/contracts/registry/IRelease.sol +29 -0
- package/contracts/registry/Registry.sol +22 -11
- package/contracts/registry/RegistryAdmin.sol +100 -363
- package/contracts/registry/RegistryAuthorization.sol +309 -0
- package/contracts/registry/RegistryService.sol +4 -4
- package/contracts/registry/RegistryServiceManager.sol +1 -1
- package/contracts/registry/ReleaseAdmin.sol +195 -0
- package/contracts/registry/ReleaseLifecycle.sol +2 -0
- package/contracts/registry/ReleaseRegistry.sol +157 -117
- package/contracts/registry/ServiceAuthorizationV3.sol +194 -27
- package/contracts/registry/TokenRegistry.sol +61 -59
- package/contracts/shared/Component.sol +34 -37
- package/contracts/shared/ComponentService.sol +314 -433
- package/contracts/shared/ComponentServiceManager.sol +1 -1
- package/contracts/shared/ContractLib.sol +164 -76
- package/contracts/shared/IComponent.sol +1 -10
- package/contracts/shared/IComponentService.sol +22 -41
- package/contracts/shared/IInstanceLinkedComponent.sol +0 -11
- package/contracts/shared/IKeyValueStore.sol +1 -1
- package/contracts/shared/INftOwnable.sol +2 -0
- package/contracts/shared/IRegisterable.sol +15 -5
- package/contracts/shared/IService.sol +3 -5
- package/contracts/shared/InitializableERC165.sol +9 -1
- package/contracts/shared/InstanceLinkedComponent.sol +7 -18
- package/contracts/shared/KeyValueStore.sol +3 -3
- package/contracts/shared/NftOwnable.sol +8 -6
- package/contracts/shared/PolicyHolder.sol +4 -3
- package/contracts/shared/Registerable.sol +42 -19
- package/contracts/shared/RegistryLinked.sol +1 -1
- package/contracts/shared/Service.sol +13 -30
- package/contracts/shared/TokenHandler.sol +45 -92
- package/contracts/staking/IStaking.sol +155 -64
- package/contracts/staking/IStakingService.sol +45 -75
- package/contracts/staking/Staking.sol +444 -203
- package/contracts/staking/{StakeManagerLib.sol → StakingLib.sol} +55 -84
- package/contracts/staking/StakingManager.sol +1 -2
- package/contracts/staking/StakingReader.sol +41 -80
- package/contracts/staking/StakingService.sol +62 -181
- package/contracts/staking/StakingServiceManager.sol +6 -4
- package/contracts/staking/StakingStore.sol +697 -329
- package/contracts/staking/TargetManagerLib.sol +1 -1
- package/contracts/type/Amount.sol +4 -0
- package/contracts/type/Blocknumber.sol +15 -15
- package/contracts/type/ChainId.sol +101 -0
- package/contracts/type/Fee.sol +8 -8
- package/contracts/type/NftId.sol +3 -3
- package/contracts/type/ObjectType.sol +67 -38
- package/contracts/type/RiskId.sol +9 -3
- package/contracts/type/RoleId.sol +63 -45
- package/contracts/type/Seconds.sol +14 -0
- package/contracts/type/Selector.sol +5 -0
- package/contracts/type/String.sol +12 -0
- package/contracts/type/Timestamp.sol +4 -7
- package/contracts/type/UFixed.sol +35 -127
- package/contracts/type/Version.sol +54 -5
- package/contracts/upgradeability/IVersionable.sol +3 -0
- package/contracts/upgradeability/ProxyManager.sol +26 -12
- package/contracts/upgradeability/UpgradableProxyWithAdmin.sol +12 -2
- package/contracts/upgradeability/Versionable.sol +6 -3
- package/package.json +2 -2
- package/artifacts/contracts/authorization/AccessAdmin.sol/IAccessManagedChecker.dbg.json +0 -4
- package/artifacts/contracts/authorization/ReleaseAccessManager.sol/ReleaseAccessManager.dbg.json +0 -4
- package/artifacts/contracts/authorization/ReleaseAccessManager.sol/ReleaseAccessManager.json +0 -1196
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +0 -129
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +0 -4
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +0 -474
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +0 -4
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +0 -440
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +0 -4
- package/artifacts/contracts/type/UFixed.sol/MathLib.json +0 -16
- package/contracts/authorization/ReleaseAccessManager.sol +0 -38
- package/contracts/instance/module/IAccess.sol +0 -46
- package/contracts/shared/ComponentVerifyingService.sol +0 -128
@@ -1,8 +1,7 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {
|
5
|
-
|
4
|
+
import {IAccountingService} from "../accounting/IAccountingService.sol";
|
6
5
|
import {IComponentService} from "../shared/IComponentService.sol";
|
7
6
|
import {IComponents} from "../instance/module/IComponents.sol";
|
8
7
|
import {IDistributionService} from "../distribution/IDistributionService.sol";
|
@@ -20,11 +19,11 @@ import {Amount} from "../type/Amount.sol";
|
|
20
19
|
import {APPLIED, COLLATERALIZED, KEEP_STATE, CLOSED, DECLINED, PAID} from "../type/StateId.sol";
|
21
20
|
import {ContractLib} from "../shared/ContractLib.sol";
|
22
21
|
import {NftId} from "../type/NftId.sol";
|
23
|
-
import {ObjectType, COMPONENT, DISTRIBUTION, PRODUCT, POOL, POLICY, PRICE} from "../type/ObjectType.sol";
|
22
|
+
import {ObjectType, ACCOUNTING, COMPONENT, DISTRIBUTION, PRODUCT, POOL, POLICY, PRICE} from "../type/ObjectType.sol";
|
23
|
+
import {PolicyServiceLib} from "./PolicyServiceLib.sol";
|
24
24
|
import {ReferralId} from "../type/Referral.sol";
|
25
25
|
import {RiskId} from "../type/RiskId.sol";
|
26
26
|
import {Service} from "../shared/Service.sol";
|
27
|
-
import {StateId} from "../type/StateId.sol";
|
28
27
|
import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
|
29
28
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
30
29
|
import {VersionPart} from "../type/Version.sol";
|
@@ -34,6 +33,7 @@ contract PolicyService is
|
|
34
33
|
Service,
|
35
34
|
IPolicyService
|
36
35
|
{
|
36
|
+
IAccountingService private _accountingService;
|
37
37
|
IComponentService internal _componentService;
|
38
38
|
IDistributionService internal _distributionService;
|
39
39
|
IPoolService internal _poolService;
|
@@ -48,13 +48,14 @@ contract PolicyService is
|
|
48
48
|
initializer
|
49
49
|
{
|
50
50
|
(
|
51
|
-
address
|
52
|
-
address
|
51
|
+
address authority,
|
52
|
+
address registry
|
53
53
|
) = abi.decode(data, (address, address));
|
54
54
|
|
55
|
-
|
55
|
+
__Service_init(authority, registry, owner);
|
56
56
|
|
57
57
|
VersionPart majorVersion = getVersion().toMajorPart();
|
58
|
+
_accountingService = IAccountingService(getRegistry().getServiceAddress(ACCOUNTING(), majorVersion));
|
58
59
|
_componentService = IComponentService(getRegistry().getServiceAddress(COMPONENT(), majorVersion));
|
59
60
|
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), majorVersion));
|
60
61
|
_distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), majorVersion));
|
@@ -69,6 +70,7 @@ contract PolicyService is
|
|
69
70
|
)
|
70
71
|
external
|
71
72
|
virtual
|
73
|
+
restricted()
|
72
74
|
nonReentrant()
|
73
75
|
{
|
74
76
|
// checks
|
@@ -92,10 +94,12 @@ contract PolicyService is
|
|
92
94
|
/// @inheritdoc IPolicyService
|
93
95
|
function createPolicy(
|
94
96
|
NftId applicationNftId, // = policyNftId
|
95
|
-
Timestamp activateAt
|
97
|
+
Timestamp activateAt,
|
98
|
+
Amount maxPremiumAmount
|
96
99
|
)
|
97
100
|
external
|
98
101
|
virtual
|
102
|
+
restricted()
|
99
103
|
nonReentrant()
|
100
104
|
returns (Amount premiumAmount)
|
101
105
|
{
|
@@ -116,15 +120,15 @@ contract PolicyService is
|
|
116
120
|
// actual collateralizaion
|
117
121
|
_poolService.lockCollateral(
|
118
122
|
instance,
|
119
|
-
address(instanceReader.
|
123
|
+
address(instanceReader.getToken(productNftId)),
|
120
124
|
productNftId,
|
121
125
|
applicationNftId,
|
122
126
|
applicationInfo.bundleNftId,
|
123
127
|
applicationInfo.sumInsuredAmount);
|
124
128
|
|
125
129
|
// optional activation of policy
|
126
|
-
if(activateAt
|
127
|
-
applicationInfo =
|
130
|
+
if(activateAt.gtz()) {
|
131
|
+
applicationInfo = PolicyServiceLib.activate(applicationNftId, applicationInfo, activateAt);
|
128
132
|
}
|
129
133
|
|
130
134
|
// update policy and set state to collateralized
|
@@ -146,7 +150,14 @@ contract PolicyService is
|
|
146
150
|
bundleNftId,
|
147
151
|
applicationInfo.referralId);
|
148
152
|
|
149
|
-
premiumAmount
|
153
|
+
if (premium.premiumAmount > maxPremiumAmount) {
|
154
|
+
revert LogPolicyServiceMaxPremiumAmountExceeded(
|
155
|
+
applicationNftId,
|
156
|
+
maxPremiumAmount,
|
157
|
+
premium.premiumAmount);
|
158
|
+
}
|
159
|
+
|
160
|
+
premiumAmount = premium.premiumAmount;
|
150
161
|
instance.getInstanceStore().createPremium(
|
151
162
|
applicationNftId,
|
152
163
|
premium);
|
@@ -162,7 +173,7 @@ contract PolicyService is
|
|
162
173
|
}
|
163
174
|
|
164
175
|
// link policy to risk and bundle
|
165
|
-
NftId poolNftId = getRegistry().
|
176
|
+
NftId poolNftId = getRegistry().getParentNftId(bundleNftId);
|
166
177
|
instance.getRiskSet().linkPolicy(productNftId, riskId, applicationNftId);
|
167
178
|
instance.getBundleSet().linkPolicy(poolNftId, bundleNftId, applicationNftId);
|
168
179
|
|
@@ -182,6 +193,7 @@ contract PolicyService is
|
|
182
193
|
)
|
183
194
|
external
|
184
195
|
virtual
|
196
|
+
restricted()
|
185
197
|
nonReentrant()
|
186
198
|
{
|
187
199
|
// checks
|
@@ -198,18 +210,24 @@ contract PolicyService is
|
|
198
210
|
}
|
199
211
|
|
200
212
|
// check if premium has already been collected
|
201
|
-
if (instanceReader.
|
213
|
+
if (instanceReader.getPremiumState(policyNftId) == PAID()) {
|
202
214
|
revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId);
|
203
215
|
}
|
204
216
|
|
205
217
|
// check funds and allowance of policy holder
|
206
218
|
IPolicy.PremiumInfo memory premium = instanceReader.getPremiumInfo(policyNftId);
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
219
|
+
instanceReader.getTokenHandler(
|
220
|
+
productNftId).checkBalanceAndAllowance(
|
221
|
+
getRegistry().ownerOf(policyNftId),
|
222
|
+
premium.premiumAmount,
|
223
|
+
false);
|
224
|
+
|
225
|
+
// )
|
226
|
+
// _checkPremiumBalanceAndAllowance(
|
227
|
+
// tokenHandler.TOKEN(),
|
228
|
+
// address(tokenHandler),
|
229
|
+
// getRegistry().ownerOf(policyNftId),
|
230
|
+
// premium.premiumAmount);
|
213
231
|
|
214
232
|
// effects
|
215
233
|
_processSale(
|
@@ -222,7 +240,7 @@ contract PolicyService is
|
|
222
240
|
|
223
241
|
// optionally activate policy
|
224
242
|
if(activateAt.gtz()) {
|
225
|
-
policyInfo =
|
243
|
+
policyInfo = PolicyServiceLib.activate(policyNftId, policyInfo, activateAt);
|
226
244
|
}
|
227
245
|
|
228
246
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
@@ -232,7 +250,7 @@ contract PolicyService is
|
|
232
250
|
emit LogPolicyServicePolicyPremiumCollected(policyNftId, premium.premiumAmount);
|
233
251
|
|
234
252
|
// interactions
|
235
|
-
|
253
|
+
_transferPremiumAmounts(instanceReader, policyNftId, policyInfo.productNftId, premium);
|
236
254
|
}
|
237
255
|
|
238
256
|
|
@@ -240,6 +258,7 @@ contract PolicyService is
|
|
240
258
|
function activate(NftId policyNftId, Timestamp activateAt)
|
241
259
|
external
|
242
260
|
virtual
|
261
|
+
restricted()
|
243
262
|
nonReentrant()
|
244
263
|
{
|
245
264
|
// checks
|
@@ -249,7 +268,7 @@ contract PolicyService is
|
|
249
268
|
) = _getAndVerifyCallerForPolicy(policyNftId);
|
250
269
|
|
251
270
|
// effects
|
252
|
-
policyInfo =
|
271
|
+
policyInfo = PolicyServiceLib.activate(policyNftId, policyInfo, activateAt);
|
253
272
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
254
273
|
|
255
274
|
// log policy activation before interactions with policy holder
|
@@ -260,6 +279,46 @@ contract PolicyService is
|
|
260
279
|
_policyHolderPolicyActivated(policyNftId, activateAt);
|
261
280
|
}
|
262
281
|
|
282
|
+
/// @inheritdoc IPolicyService
|
283
|
+
function adjustActivation(
|
284
|
+
NftId policyNftId,
|
285
|
+
Timestamp newActivateAt
|
286
|
+
)
|
287
|
+
external
|
288
|
+
virtual
|
289
|
+
restricted()
|
290
|
+
nonReentrant()
|
291
|
+
{
|
292
|
+
// checks
|
293
|
+
(
|
294
|
+
IInstance instance,,
|
295
|
+
IPolicy.PolicyInfo memory policyInfo
|
296
|
+
) = _getAndVerifyCallerForPolicy(policyNftId);
|
297
|
+
|
298
|
+
if (policyInfo.activatedAt.eqz()) {
|
299
|
+
revert ErrorPolicyServicePolicyNotActivated(policyNftId);
|
300
|
+
}
|
301
|
+
|
302
|
+
if (newActivateAt < TimestampLib.current()) {
|
303
|
+
revert ErrorPolicyServicePolicyActivationTooEarly(policyNftId, TimestampLib.current(), newActivateAt);
|
304
|
+
}
|
305
|
+
|
306
|
+
if (newActivateAt > policyInfo.expiredAt) {
|
307
|
+
revert ErrorPolicyServicePolicyActivationTooLate(policyNftId, policyInfo.expiredAt, newActivateAt);
|
308
|
+
}
|
309
|
+
|
310
|
+
// effects
|
311
|
+
policyInfo.activatedAt = newActivateAt;
|
312
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
313
|
+
|
314
|
+
// log policy activation before interactions with policy holder
|
315
|
+
emit LogPolicyServicePolicyActivatedUpdated(policyNftId, newActivateAt);
|
316
|
+
|
317
|
+
// interactions
|
318
|
+
// callback to policy holder if applicable
|
319
|
+
_policyHolderPolicyActivated(policyNftId, newActivateAt);
|
320
|
+
}
|
321
|
+
|
263
322
|
|
264
323
|
/// @inheritdoc IPolicyService
|
265
324
|
function expire(
|
@@ -268,6 +327,7 @@ contract PolicyService is
|
|
268
327
|
)
|
269
328
|
external
|
270
329
|
virtual
|
330
|
+
restricted()
|
271
331
|
nonReentrant()
|
272
332
|
returns (Timestamp expiredAt)
|
273
333
|
{
|
@@ -295,6 +355,7 @@ contract PolicyService is
|
|
295
355
|
)
|
296
356
|
external
|
297
357
|
virtual
|
358
|
+
restricted()
|
298
359
|
nonReentrant()
|
299
360
|
returns (Timestamp expiredAt)
|
300
361
|
{
|
@@ -319,6 +380,7 @@ contract PolicyService is
|
|
319
380
|
)
|
320
381
|
external
|
321
382
|
virtual
|
383
|
+
restricted()
|
322
384
|
nonReentrant()
|
323
385
|
{
|
324
386
|
// checks
|
@@ -330,7 +392,7 @@ contract PolicyService is
|
|
330
392
|
InstanceReader instanceReader = instance.getInstanceReader();
|
331
393
|
|
332
394
|
// check policy is in a closeable state
|
333
|
-
if (!policyIsCloseable(instanceReader, policyNftId)) {
|
395
|
+
if (!PolicyServiceLib.policyIsCloseable(instanceReader, policyNftId)) {
|
334
396
|
revert ErrorPolicyServicePolicyNotCloseable(policyNftId);
|
335
397
|
}
|
336
398
|
|
@@ -338,7 +400,7 @@ contract PolicyService is
|
|
338
400
|
RiskId riskId = policyInfo.riskId;
|
339
401
|
NftId bundleNftId = policyInfo.bundleNftId;
|
340
402
|
|
341
|
-
if (instanceReader.
|
403
|
+
if (instanceReader.getPremiumState(policyNftId) != PAID()) {
|
342
404
|
revert ErrorPolicyServicePremiumNotPaid(policyNftId, policyInfo.premiumAmount);
|
343
405
|
}
|
344
406
|
|
@@ -346,18 +408,17 @@ contract PolicyService is
|
|
346
408
|
// release (remaining) collateral that was blocked by policy
|
347
409
|
_poolService.releaseCollateral(
|
348
410
|
instance,
|
349
|
-
address(instanceReader.getComponentInfo(productNftId).token),
|
350
411
|
policyNftId,
|
351
412
|
policyInfo);
|
352
413
|
|
353
414
|
// TODO consider to also set expiredAt to current block timestamp if that timestamp is still in the futue
|
354
415
|
|
355
416
|
// update policy state to closed
|
356
|
-
policyInfo.closedAt = TimestampLib.
|
417
|
+
policyInfo.closedAt = TimestampLib.current();
|
357
418
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, CLOSED());
|
358
419
|
|
359
420
|
// unlink policy from risk and bundle
|
360
|
-
NftId poolNftId = getRegistry().
|
421
|
+
NftId poolNftId = getRegistry().getParentNftId(bundleNftId);
|
361
422
|
instance.getRiskSet().unlinkPolicy(productNftId, riskId, policyNftId);
|
362
423
|
instance.getBundleSet().unlinkPolicy(poolNftId, bundleNftId, policyNftId);
|
363
424
|
|
@@ -365,32 +426,6 @@ contract PolicyService is
|
|
365
426
|
}
|
366
427
|
|
367
428
|
|
368
|
-
function policyIsCloseable(InstanceReader instanceReader, NftId policyNftId)
|
369
|
-
public
|
370
|
-
view
|
371
|
-
returns (bool isCloseable)
|
372
|
-
{
|
373
|
-
// policy already closed
|
374
|
-
if (instanceReader.getPolicyState(policyNftId) == CLOSED()) {
|
375
|
-
return false;
|
376
|
-
}
|
377
|
-
|
378
|
-
IPolicy.PolicyInfo memory info = instanceReader.getPolicyInfo(policyNftId);
|
379
|
-
|
380
|
-
if (info.productNftId.eqz()) { return false; } // not closeable: policy does not exist (or does not belong to this instance)
|
381
|
-
if (info.activatedAt.eqz()) { return false; } // not closeable: not yet activated
|
382
|
-
if (info.openClaimsCount > 0) { return false; } // not closeable: has open claims
|
383
|
-
|
384
|
-
// closeable: if sum of claims matches sum insured a policy may be closed prior to the expiry date
|
385
|
-
if (info.claimAmount == info.sumInsuredAmount) { return true; }
|
386
|
-
|
387
|
-
// not closeable: not yet expired
|
388
|
-
if (TimestampLib.blockTimestamp() < info.expiredAt) { return false; }
|
389
|
-
|
390
|
-
// all conditions to close the policy are met
|
391
|
-
return true;
|
392
|
-
}
|
393
|
-
|
394
429
|
/// @dev shared functionality for expire() and policyExpire().
|
395
430
|
function _expire(
|
396
431
|
IInstance instance,
|
@@ -399,93 +434,24 @@ contract PolicyService is
|
|
399
434
|
Timestamp expireAt
|
400
435
|
)
|
401
436
|
internal
|
402
|
-
returns (Timestamp
|
437
|
+
returns (Timestamp)
|
403
438
|
{
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
}
|
410
|
-
|
411
|
-
// set return value to provided timestamp
|
412
|
-
expiredAt = expireAt;
|
413
|
-
|
414
|
-
// update expiredAt to current block timestamp if not set
|
415
|
-
if (expiredAt.eqz()) {
|
416
|
-
expiredAt = TimestampLib.blockTimestamp();
|
417
|
-
}
|
418
|
-
|
419
|
-
// check expiredAt represents a valid expiry time
|
420
|
-
if (expiredAt >= policyInfo.expiredAt) {
|
421
|
-
revert ErrorPolicyServicePolicyExpirationTooLate(policyNftId, policyInfo.expiredAt, expireAt);
|
422
|
-
}
|
423
|
-
|
424
|
-
if (expiredAt < TimestampLib.blockTimestamp()) {
|
425
|
-
revert ErrorPolicyServicePolicyExpirationTooEarly(policyNftId, TimestampLib.blockTimestamp(), expireAt);
|
426
|
-
}
|
439
|
+
policyInfo = PolicyServiceLib.expire(
|
440
|
+
instance.getInstanceReader(),
|
441
|
+
policyNftId,
|
442
|
+
policyInfo,
|
443
|
+
expireAt);
|
427
444
|
|
428
|
-
// effects
|
429
|
-
// update policyInfo with new expiredAt timestamp
|
430
|
-
Timestamp originalExpiredAt = policyInfo.expiredAt;
|
431
|
-
policyInfo.expiredAt = expiredAt;
|
432
445
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
433
446
|
|
434
|
-
emit LogPolicyServicePolicyExpirationUpdated(policyNftId,
|
447
|
+
emit LogPolicyServicePolicyExpirationUpdated(policyNftId, policyInfo.expiredAt);
|
435
448
|
|
436
449
|
// interactions
|
437
450
|
// callback to policy holder if applicable
|
438
|
-
_policyHolderPolicyExpired(policyNftId, expiredAt);
|
451
|
+
_policyHolderPolicyExpired(policyNftId, policyInfo.expiredAt);
|
452
|
+
return policyInfo.expiredAt;
|
439
453
|
}
|
440
454
|
|
441
|
-
// TODO cleanup
|
442
|
-
// /// @dev Calculates the premium and updates all counters in the other services.
|
443
|
-
// /// Only book keeping, no token transfers.
|
444
|
-
// function _processPremium(
|
445
|
-
// IInstance instance,
|
446
|
-
// NftId applicationNftId,
|
447
|
-
// IPolicy.PolicyInfo memory applicationInfo,
|
448
|
-
// IPolicy.PremiumInfo memory premium
|
449
|
-
// )
|
450
|
-
// internal
|
451
|
-
// virtual
|
452
|
-
// {
|
453
|
-
// // update the counters
|
454
|
-
// _processSale(
|
455
|
-
// instanceReader,
|
456
|
-
// instance.getInstanceStore(),
|
457
|
-
// productNftId,
|
458
|
-
// applicationInfo.bundleNftId,
|
459
|
-
// applicationInfo.referralId,
|
460
|
-
// premium);
|
461
|
-
// }
|
462
|
-
|
463
|
-
|
464
|
-
function _activate(
|
465
|
-
NftId policyNftId,
|
466
|
-
IPolicy.PolicyInfo memory policyInfo,
|
467
|
-
Timestamp activateAt
|
468
|
-
)
|
469
|
-
internal
|
470
|
-
virtual
|
471
|
-
view
|
472
|
-
returns (IPolicy.PolicyInfo memory)
|
473
|
-
{
|
474
|
-
// fail if policy has already been activated and activateAt is different
|
475
|
-
if(! policyInfo.activatedAt.eqz() && activateAt != policyInfo.activatedAt) {
|
476
|
-
revert ErrorPolicyServicePolicyAlreadyActivated(policyNftId);
|
477
|
-
}
|
478
|
-
|
479
|
-
// ignore if policy has already been activated and activateAt is the same
|
480
|
-
if (policyInfo.activatedAt == activateAt) {
|
481
|
-
return policyInfo;
|
482
|
-
}
|
483
|
-
|
484
|
-
policyInfo.activatedAt = activateAt;
|
485
|
-
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
486
|
-
|
487
|
-
return policyInfo;
|
488
|
-
}
|
489
455
|
|
490
456
|
/// @dev update counters by calling the involved services
|
491
457
|
function _processSale(
|
@@ -504,7 +470,7 @@ contract PolicyService is
|
|
504
470
|
productNftId);
|
505
471
|
|
506
472
|
// update product fees, distribution and pool fees
|
507
|
-
|
473
|
+
_accountingService.increaseProductFees(
|
508
474
|
instanceStore,
|
509
475
|
productNftId,
|
510
476
|
premium.productFeeVarAmount + premium.productFeeFixAmount);
|
@@ -525,7 +491,7 @@ contract PolicyService is
|
|
525
491
|
|
526
492
|
|
527
493
|
/// @dev transfer the premium to the wallets the premium is distributed to
|
528
|
-
function
|
494
|
+
function _transferPremiumAmounts(
|
529
495
|
InstanceReader instanceReader,
|
530
496
|
NftId policyNftId,
|
531
497
|
NftId productNftId,
|
@@ -534,7 +500,6 @@ contract PolicyService is
|
|
534
500
|
internal
|
535
501
|
virtual
|
536
502
|
{
|
537
|
-
TokenHandler tokenHandler = _getTokenHandler(instanceReader, productNftId);
|
538
503
|
address policyHolder = getRegistry().ownerOf(policyNftId);
|
539
504
|
|
540
505
|
(
|
@@ -546,58 +511,20 @@ contract PolicyService is
|
|
546
511
|
instanceReader,
|
547
512
|
productNftId);
|
548
513
|
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
premium.productFeeAmount,
|
553
|
-
distributionWallet,
|
554
|
-
premium.distributionFeeAndCommissionAmount,
|
555
|
-
poolWallet,
|
556
|
-
premium.poolPremiumAndFeeAmount);
|
557
|
-
}
|
558
|
-
|
514
|
+
// step 1: collect premium amount from policy holder
|
515
|
+
TokenHandler tokenHandler = instanceReader.getTokenHandler(productNftId);
|
516
|
+
tokenHandler.pullToken(policyHolder, premium.premiumAmount);
|
559
517
|
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
StateId policyState,
|
564
|
-
IPolicy.PolicyInfo memory policyInfo
|
565
|
-
)
|
566
|
-
internal
|
567
|
-
view
|
568
|
-
returns (bool)
|
569
|
-
{
|
570
|
-
if (policyState != COLLATERALIZED()) { return false; }
|
571
|
-
if (TimestampLib.blockTimestamp() < policyInfo.activatedAt) { return false; }
|
572
|
-
return true;
|
573
|
-
}
|
574
|
-
|
575
|
-
|
576
|
-
/// @dev checks the balance and allowance of the policy holder
|
577
|
-
function _checkPremiumBalanceAndAllowance(
|
578
|
-
IERC20Metadata token,
|
579
|
-
address tokenHandlerAddress,
|
580
|
-
address policyHolder,
|
581
|
-
Amount premiumAmount
|
582
|
-
)
|
583
|
-
internal
|
584
|
-
virtual
|
585
|
-
view
|
586
|
-
{
|
587
|
-
uint256 premium = premiumAmount.toInt();
|
588
|
-
uint256 balance = token.balanceOf(policyHolder);
|
589
|
-
uint256 allowance = token.allowance(policyHolder, tokenHandlerAddress);
|
590
|
-
|
591
|
-
if (balance < premium) {
|
592
|
-
revert ErrorPolicyServiceBalanceInsufficient(policyHolder, premium, balance);
|
518
|
+
// step 2: push distribution fee to distribution wallet
|
519
|
+
if (premium.distributionFeeAndCommissionAmount.gtz()) {
|
520
|
+
tokenHandler.pushToken(distributionWallet, premium.distributionFeeAndCommissionAmount);
|
593
521
|
}
|
594
522
|
|
595
|
-
|
596
|
-
|
523
|
+
// step 3: push pool fee, bundle fee and pool premium to pool wallet
|
524
|
+
if (premium.poolPremiumAndFeeAmount.gtz()) {
|
525
|
+
tokenHandler.pushToken(poolWallet, premium.poolPremiumAndFeeAmount);
|
597
526
|
}
|
598
527
|
}
|
599
|
-
|
600
|
-
|
601
528
|
function _policyHolderPolicyActivated(
|
602
529
|
NftId policyNftId,
|
603
530
|
Timestamp activateAt
|
@@ -656,21 +583,6 @@ contract PolicyService is
|
|
656
583
|
}
|
657
584
|
|
658
585
|
|
659
|
-
function _getTokenHandler(
|
660
|
-
InstanceReader instanceReader,
|
661
|
-
NftId productNftId
|
662
|
-
)
|
663
|
-
internal
|
664
|
-
virtual
|
665
|
-
view
|
666
|
-
returns (
|
667
|
-
TokenHandler tokenHandler
|
668
|
-
)
|
669
|
-
{
|
670
|
-
tokenHandler = instanceReader.getComponentInfo(productNftId).tokenHandler;
|
671
|
-
}
|
672
|
-
|
673
|
-
|
674
586
|
function _getDistributionNftAndWallets(
|
675
587
|
InstanceReader instanceReader,
|
676
588
|
NftId productNftId
|
@@ -714,7 +626,7 @@ contract PolicyService is
|
|
714
626
|
PRODUCT(), // caller must be product
|
715
627
|
true); // only active caller
|
716
628
|
|
717
|
-
productNftId = productInfo.nftId;
|
629
|
+
productNftId = productInfo.nftId; // calling product nft id
|
718
630
|
instance = IInstance(instanceAddress);
|
719
631
|
policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
720
632
|
|
@@ -0,0 +1,139 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {InstanceReader} from "../instance/InstanceReader.sol";
|
5
|
+
import {IPolicy} from "../instance/module/IPolicy.sol";
|
6
|
+
import {IPolicyService} from "../product/IPolicyService.sol";
|
7
|
+
import {NftId} from "../type/NftId.sol";
|
8
|
+
import {StateId, CLOSED, COLLATERALIZED} from "../type/StateId.sol";
|
9
|
+
import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
|
10
|
+
|
11
|
+
library PolicyServiceLib {
|
12
|
+
|
13
|
+
function policyIsActive(InstanceReader instanceReader, NftId policyNftId)
|
14
|
+
external
|
15
|
+
view
|
16
|
+
returns (bool isActive)
|
17
|
+
{
|
18
|
+
// policy not collateralized
|
19
|
+
if (instanceReader.getPolicyState(policyNftId) != COLLATERALIZED()) {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
|
23
|
+
IPolicy.PolicyInfo memory info = instanceReader.getPolicyInfo(policyNftId);
|
24
|
+
|
25
|
+
if (info.productNftId.eqz()) { return false; } // not closeable: policy does not exist (or does not belong to this instance)
|
26
|
+
if (info.activatedAt.eqz()) { return false; } // not closeable: not yet activated
|
27
|
+
if (info.activatedAt > TimestampLib.current()) { return false; } // not yet active
|
28
|
+
if (info.expiredAt <= TimestampLib.current()) { return false; } // already expired
|
29
|
+
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
|
33
|
+
function activate(
|
34
|
+
NftId policyNftId,
|
35
|
+
IPolicy.PolicyInfo memory policyInfo,
|
36
|
+
Timestamp activateAt
|
37
|
+
)
|
38
|
+
external
|
39
|
+
pure
|
40
|
+
returns (IPolicy.PolicyInfo memory)
|
41
|
+
{
|
42
|
+
// fail if policy has already been activated and activateAt is different
|
43
|
+
if(! policyInfo.activatedAt.eqz() && activateAt != policyInfo.activatedAt) {
|
44
|
+
revert IPolicyService.ErrorPolicyServicePolicyAlreadyActivated(policyNftId);
|
45
|
+
}
|
46
|
+
|
47
|
+
// ignore if policy has already been activated and activateAt is the same
|
48
|
+
if (policyInfo.activatedAt == activateAt) {
|
49
|
+
return policyInfo;
|
50
|
+
}
|
51
|
+
|
52
|
+
policyInfo.activatedAt = activateAt;
|
53
|
+
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
54
|
+
|
55
|
+
return policyInfo;
|
56
|
+
}
|
57
|
+
|
58
|
+
function expire(
|
59
|
+
InstanceReader instanceReader,
|
60
|
+
NftId policyNftId,
|
61
|
+
IPolicy.PolicyInfo memory policyInfo,
|
62
|
+
Timestamp expireAt
|
63
|
+
)
|
64
|
+
external
|
65
|
+
view
|
66
|
+
returns (IPolicy.PolicyInfo memory)
|
67
|
+
{
|
68
|
+
StateId policyState = instanceReader.getPolicyState(policyNftId);
|
69
|
+
|
70
|
+
checkExpiration(
|
71
|
+
expireAt,
|
72
|
+
policyNftId,
|
73
|
+
policyState,
|
74
|
+
policyInfo);
|
75
|
+
|
76
|
+
// effects
|
77
|
+
// update policyInfo with new expiredAt timestamp
|
78
|
+
if (expireAt.gtz()) {
|
79
|
+
policyInfo.expiredAt = expireAt;
|
80
|
+
} else {
|
81
|
+
policyInfo.expiredAt = TimestampLib.current();
|
82
|
+
}
|
83
|
+
|
84
|
+
return policyInfo;
|
85
|
+
}
|
86
|
+
|
87
|
+
function checkExpiration(
|
88
|
+
Timestamp newExpiredAt,
|
89
|
+
NftId policyNftId,
|
90
|
+
StateId policyState,
|
91
|
+
IPolicy.PolicyInfo memory policyInfo
|
92
|
+
)
|
93
|
+
public
|
94
|
+
view
|
95
|
+
{
|
96
|
+
if (policyState != COLLATERALIZED()) {
|
97
|
+
revert IPolicyService.ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
98
|
+
}
|
99
|
+
if (TimestampLib.current() < policyInfo.activatedAt) {
|
100
|
+
revert IPolicyService.ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
101
|
+
}
|
102
|
+
|
103
|
+
// check expiredAt represents a valid expiry time
|
104
|
+
if (newExpiredAt >= policyInfo.expiredAt) {
|
105
|
+
revert IPolicyService.ErrorPolicyServicePolicyExpirationTooLate(policyNftId, policyInfo.expiredAt, newExpiredAt);
|
106
|
+
}
|
107
|
+
|
108
|
+
if (newExpiredAt.gtz() && newExpiredAt < TimestampLib.current()) {
|
109
|
+
revert IPolicyService.ErrorPolicyServicePolicyExpirationTooEarly(policyNftId, TimestampLib.current(), newExpiredAt);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
function policyIsCloseable(InstanceReader instanceReader, NftId policyNftId)
|
114
|
+
external
|
115
|
+
view
|
116
|
+
returns (bool isCloseable)
|
117
|
+
{
|
118
|
+
// policy already closed
|
119
|
+
if (instanceReader.getPolicyState(policyNftId) == CLOSED()) {
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
|
123
|
+
IPolicy.PolicyInfo memory info = instanceReader.getPolicyInfo(policyNftId);
|
124
|
+
|
125
|
+
if (info.productNftId.eqz()) { return false; } // not closeable: policy does not exist (or does not belong to this instance)
|
126
|
+
if (info.activatedAt.eqz()) { return false; } // not closeable: not yet activated
|
127
|
+
if (info.openClaimsCount > 0) { return false; } // not closeable: has open claims
|
128
|
+
|
129
|
+
// closeable: if sum of claims matches sum insured a policy may be closed prior to the expiry date
|
130
|
+
if (info.claimAmount == info.sumInsuredAmount) { return true; }
|
131
|
+
|
132
|
+
// not closeable: not yet expired
|
133
|
+
if (TimestampLib.current() < info.expiredAt) { return false; }
|
134
|
+
|
135
|
+
// all conditions to close the policy are met
|
136
|
+
return true;
|
137
|
+
}
|
138
|
+
|
139
|
+
}
|