@etherisc/gif-next 0.0.2-b312c9a-831 → 0.0.2-b37fa8b-169
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 +63 -1
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +1 -1
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +134 -59
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +94 -50
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +1 -1
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +85 -9
- 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 -153
- 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 -95
- 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 +45 -82
- 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 +157 -114
- 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 +298 -236
- 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 +178 -168
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +380 -45
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +94 -68
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +183 -141
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +355 -52
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +574 -282
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +380 -45
- package/artifacts/contracts/instance/BaseStore.sol/BaseStore.dbg.json +4 -0
- package/artifacts/contracts/instance/BaseStore.sol/BaseStore.json +332 -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/IBaseStore.sol/IBaseStore.dbg.json +4 -0
- package/artifacts/contracts/instance/IBaseStore.sol/IBaseStore.json +304 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +494 -49
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +395 -12
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +542 -109
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +965 -365
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +327 -64
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +907 -571
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +399 -79
- 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 +802 -1748
- package/artifacts/contracts/instance/ProductStore.sol/ProductStore.dbg.json +4 -0
- package/artifacts/contracts/instance/ProductStore.sol/ProductStore.json +2835 -0
- 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 -49
- 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 +49 -21
- 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 -33
- 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 -82
- 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 -31
- 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 -44
- 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 +572 -358
- 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 -150
- 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 +176 -133
- 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 -144
- 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 -466
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1074 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +71 -35
- 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 -32
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +227 -250
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +113 -69
- 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 +49 -21
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +131 -153
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +49 -21
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +43 -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 -32
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +43 -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 +1468 -128
- 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/ITargetLimitHandler.sol/ITargetLimitHandler.dbg.json +4 -0
- package/artifacts/contracts/staking/ITargetLimitHandler.sol/ITargetLimitHandler.json +50 -0
- package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/staking/Staking.sol/Staking.json +1623 -254
- 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/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +132 -65
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +294 -177
- 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 +1632 -818
- package/artifacts/contracts/staking/TargetHandler.sol/TargetHandler.dbg.json +4 -0
- package/artifacts/contracts/staking/TargetHandler.sol/TargetHandler.json +309 -0
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +160 -88
- 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 +18 -8
- package/contracts/accounting/AccountingServiceManager.sol +1 -1
- package/contracts/accounting/IAccountingService.sol +4 -2
- 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 +13 -11
- package/contracts/distribution/BasicDistributionAuthorization.sol +29 -9
- package/contracts/distribution/Distribution.sol +20 -60
- package/contracts/distribution/DistributionService.sol +172 -81
- 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 +0 -4
- package/contracts/examples/fire/FirePoolAuthorization.sol +1 -1
- package/contracts/examples/fire/FireProduct.sol +10 -13
- package/contracts/examples/fire/FireProductAuthorization.sol +1 -1
- package/contracts/examples/unpermissioned/SimpleDistribution.sol +32 -8
- package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +1 -1
- package/contracts/examples/unpermissioned/SimpleOracle.sol +4 -8
- package/contracts/examples/unpermissioned/SimplePool.sol +0 -5
- package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +1 -1
- package/contracts/examples/unpermissioned/SimpleProduct.sol +112 -27
- package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +1 -1
- package/contracts/instance/BaseStore.sol +93 -0
- package/contracts/instance/BundleSet.sol +4 -4
- package/contracts/instance/IBaseStore.sol +37 -0
- package/contracts/instance/IInstance.sol +103 -18
- package/contracts/instance/IInstanceService.sol +55 -6
- package/contracts/instance/Instance.sol +176 -64
- package/contracts/instance/InstanceAdmin.sol +263 -169
- package/contracts/instance/InstanceAuthorizationV3.sol +119 -64
- package/contracts/instance/InstanceReader.sol +420 -369
- package/contracts/instance/InstanceService.sol +306 -183
- package/contracts/instance/InstanceServiceManager.sol +1 -1
- package/contracts/instance/InstanceStore.sol +10 -72
- package/contracts/instance/ProductStore.sol +235 -0
- package/contracts/instance/RiskSet.sol +21 -14
- package/contracts/instance/TargetNames.sol +10 -0
- 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 +60 -99
- package/contracts/pool/BundleServiceManager.sol +1 -1
- package/contracts/pool/IBundleService.sol +27 -32
- 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 +192 -193
- package/contracts/pool/PoolServiceManager.sol +1 -1
- package/contracts/product/ApplicationService.sol +88 -20
- package/contracts/product/ApplicationServiceManager.sol +1 -1
- package/contracts/product/BasicProduct.sol +3 -3
- package/contracts/product/BasicProductAuthorization.sol +31 -9
- package/contracts/product/ClaimService.sol +221 -209
- 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 +113 -204
- 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 +121 -38
- 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 +107 -373
- package/contracts/registry/RegistryAuthorization.sol +336 -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 +163 -28
- package/contracts/registry/TokenRegistry.sol +61 -59
- package/contracts/shared/Component.sol +23 -28
- package/contracts/shared/ComponentService.sol +317 -317
- package/contracts/shared/ComponentServiceManager.sol +1 -1
- package/contracts/shared/ContractLib.sol +164 -76
- package/contracts/shared/IComponent.sol +1 -5
- package/contracts/shared/IComponentService.sol +21 -26
- package/contracts/shared/IKeyValueStore.sol +9 -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 +6 -9
- 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 +266 -72
- package/contracts/staking/IStakingService.sol +45 -75
- package/contracts/staking/ITargetLimitHandler.sol +17 -0
- package/contracts/staking/Staking.sol +494 -211
- package/contracts/staking/{StakeManagerLib.sol → StakingLib.sol} +55 -84
- package/contracts/staking/StakingManager.sol +4 -3
- package/contracts/staking/StakingReader.sol +58 -77
- package/contracts/staking/StakingService.sol +62 -181
- package/contracts/staking/StakingServiceManager.sol +6 -4
- package/contracts/staking/StakingStore.sol +1093 -330
- package/contracts/staking/TargetHandler.sol +132 -0
- package/contracts/staking/TargetManagerLib.sol +69 -46
- 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 +62 -41
- package/contracts/type/RiskId.sol +9 -3
- package/contracts/type/RoleId.sol +63 -45
- package/contracts/type/Seconds.sol +19 -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/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +0 -4
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +0 -205
- 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
- package/contracts/staking/StakingLifecycle.sol +0 -23
@@ -1,8 +1,6 @@
|
|
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
|
-
|
6
4
|
import {IAccountingService} from "../accounting/IAccountingService.sol";
|
7
5
|
import {IComponentService} from "../shared/IComponentService.sol";
|
8
6
|
import {IComponents} from "../instance/module/IComponents.sol";
|
@@ -22,10 +20,10 @@ import {APPLIED, COLLATERALIZED, KEEP_STATE, CLOSED, DECLINED, PAID} from "../ty
|
|
22
20
|
import {ContractLib} from "../shared/ContractLib.sol";
|
23
21
|
import {NftId} from "../type/NftId.sol";
|
24
22
|
import {ObjectType, ACCOUNTING, COMPONENT, DISTRIBUTION, PRODUCT, POOL, POLICY, PRICE} from "../type/ObjectType.sol";
|
23
|
+
import {PolicyServiceLib} from "./PolicyServiceLib.sol";
|
25
24
|
import {ReferralId} from "../type/Referral.sol";
|
26
25
|
import {RiskId} from "../type/RiskId.sol";
|
27
26
|
import {Service} from "../shared/Service.sol";
|
28
|
-
import {StateId} from "../type/StateId.sol";
|
29
27
|
import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
|
30
28
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
31
29
|
import {VersionPart} from "../type/Version.sol";
|
@@ -50,11 +48,11 @@ contract PolicyService is
|
|
50
48
|
initializer
|
51
49
|
{
|
52
50
|
(
|
53
|
-
address
|
54
|
-
address
|
51
|
+
address authority,
|
52
|
+
address registry
|
55
53
|
) = abi.decode(data, (address, address));
|
56
54
|
|
57
|
-
|
55
|
+
__Service_init(authority, registry, owner);
|
58
56
|
|
59
57
|
VersionPart majorVersion = getVersion().toMajorPart();
|
60
58
|
_accountingService = IAccountingService(getRegistry().getServiceAddress(ACCOUNTING(), majorVersion));
|
@@ -72,6 +70,7 @@ contract PolicyService is
|
|
72
70
|
)
|
73
71
|
external
|
74
72
|
virtual
|
73
|
+
restricted()
|
75
74
|
nonReentrant()
|
76
75
|
{
|
77
76
|
// checks
|
@@ -84,7 +83,7 @@ contract PolicyService is
|
|
84
83
|
|
85
84
|
// effects
|
86
85
|
// store updated policy info
|
87
|
-
instance.
|
86
|
+
instance.getProductStore().updatePolicyState(
|
88
87
|
applicationNftId,
|
89
88
|
DECLINED());
|
90
89
|
|
@@ -95,10 +94,12 @@ contract PolicyService is
|
|
95
94
|
/// @inheritdoc IPolicyService
|
96
95
|
function createPolicy(
|
97
96
|
NftId applicationNftId, // = policyNftId
|
98
|
-
Timestamp activateAt
|
97
|
+
Timestamp activateAt,
|
98
|
+
Amount maxPremiumAmount
|
99
99
|
)
|
100
100
|
external
|
101
101
|
virtual
|
102
|
+
restricted()
|
102
103
|
nonReentrant()
|
103
104
|
returns (Amount premiumAmount)
|
104
105
|
{
|
@@ -119,19 +120,19 @@ contract PolicyService is
|
|
119
120
|
// actual collateralizaion
|
120
121
|
_poolService.lockCollateral(
|
121
122
|
instance,
|
122
|
-
address(instanceReader.
|
123
|
+
address(instanceReader.getToken(productNftId)),
|
123
124
|
productNftId,
|
124
125
|
applicationNftId,
|
125
126
|
applicationInfo.bundleNftId,
|
126
127
|
applicationInfo.sumInsuredAmount);
|
127
128
|
|
128
129
|
// optional activation of policy
|
129
|
-
if(activateAt
|
130
|
-
applicationInfo =
|
130
|
+
if(activateAt.gtz()) {
|
131
|
+
applicationInfo = PolicyServiceLib.activate(applicationNftId, applicationInfo, activateAt);
|
131
132
|
}
|
132
133
|
|
133
134
|
// update policy and set state to collateralized
|
134
|
-
instance.
|
135
|
+
instance.getProductStore().updatePolicy(
|
135
136
|
applicationNftId,
|
136
137
|
applicationInfo,
|
137
138
|
COLLATERALIZED());
|
@@ -149,8 +150,15 @@ contract PolicyService is
|
|
149
150
|
bundleNftId,
|
150
151
|
applicationInfo.referralId);
|
151
152
|
|
152
|
-
premiumAmount
|
153
|
-
|
153
|
+
if (premium.premiumAmount > maxPremiumAmount) {
|
154
|
+
revert LogPolicyServiceMaxPremiumAmountExceeded(
|
155
|
+
applicationNftId,
|
156
|
+
maxPremiumAmount,
|
157
|
+
premium.premiumAmount);
|
158
|
+
}
|
159
|
+
|
160
|
+
premiumAmount = premium.premiumAmount;
|
161
|
+
instance.getProductStore().createPremium(
|
154
162
|
applicationNftId,
|
155
163
|
premium);
|
156
164
|
|
@@ -165,7 +173,7 @@ contract PolicyService is
|
|
165
173
|
}
|
166
174
|
|
167
175
|
// link policy to risk and bundle
|
168
|
-
NftId poolNftId = getRegistry().
|
176
|
+
NftId poolNftId = getRegistry().getParentNftId(bundleNftId);
|
169
177
|
instance.getRiskSet().linkPolicy(productNftId, riskId, applicationNftId);
|
170
178
|
instance.getBundleSet().linkPolicy(poolNftId, bundleNftId, applicationNftId);
|
171
179
|
|
@@ -185,6 +193,7 @@ contract PolicyService is
|
|
185
193
|
)
|
186
194
|
external
|
187
195
|
virtual
|
196
|
+
restricted()
|
188
197
|
nonReentrant()
|
189
198
|
{
|
190
199
|
// checks
|
@@ -201,18 +210,24 @@ contract PolicyService is
|
|
201
210
|
}
|
202
211
|
|
203
212
|
// check if premium has already been collected
|
204
|
-
if (instanceReader.
|
213
|
+
if (instanceReader.getPremiumState(policyNftId) == PAID()) {
|
205
214
|
revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId);
|
206
215
|
}
|
207
216
|
|
208
217
|
// check funds and allowance of policy holder
|
209
218
|
IPolicy.PremiumInfo memory premium = instanceReader.getPremiumInfo(policyNftId);
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
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);
|
216
231
|
|
217
232
|
// effects
|
218
233
|
_processSale(
|
@@ -225,17 +240,17 @@ contract PolicyService is
|
|
225
240
|
|
226
241
|
// optionally activate policy
|
227
242
|
if(activateAt.gtz()) {
|
228
|
-
policyInfo =
|
243
|
+
policyInfo = PolicyServiceLib.activate(policyNftId, policyInfo, activateAt);
|
229
244
|
}
|
230
245
|
|
231
|
-
instance.
|
232
|
-
instance.
|
246
|
+
instance.getProductStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
247
|
+
instance.getProductStore().updatePremiumState(policyNftId, PAID());
|
233
248
|
|
234
249
|
// log premium collection before interactions with token
|
235
250
|
emit LogPolicyServicePolicyPremiumCollected(policyNftId, premium.premiumAmount);
|
236
251
|
|
237
252
|
// interactions
|
238
|
-
|
253
|
+
_transferPremiumAmounts(instanceReader, policyNftId, policyInfo.productNftId, premium);
|
239
254
|
}
|
240
255
|
|
241
256
|
|
@@ -243,6 +258,7 @@ contract PolicyService is
|
|
243
258
|
function activate(NftId policyNftId, Timestamp activateAt)
|
244
259
|
external
|
245
260
|
virtual
|
261
|
+
restricted()
|
246
262
|
nonReentrant()
|
247
263
|
{
|
248
264
|
// checks
|
@@ -252,8 +268,8 @@ contract PolicyService is
|
|
252
268
|
) = _getAndVerifyCallerForPolicy(policyNftId);
|
253
269
|
|
254
270
|
// effects
|
255
|
-
policyInfo =
|
256
|
-
instance.
|
271
|
+
policyInfo = PolicyServiceLib.activate(policyNftId, policyInfo, activateAt);
|
272
|
+
instance.getProductStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
257
273
|
|
258
274
|
// log policy activation before interactions with policy holder
|
259
275
|
emit LogPolicyServicePolicyActivated(policyNftId, activateAt);
|
@@ -263,6 +279,46 @@ contract PolicyService is
|
|
263
279
|
_policyHolderPolicyActivated(policyNftId, activateAt);
|
264
280
|
}
|
265
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.getProductStore().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
|
+
|
266
322
|
|
267
323
|
/// @inheritdoc IPolicyService
|
268
324
|
function expire(
|
@@ -271,6 +327,7 @@ contract PolicyService is
|
|
271
327
|
)
|
272
328
|
external
|
273
329
|
virtual
|
330
|
+
restricted()
|
274
331
|
nonReentrant()
|
275
332
|
returns (Timestamp expiredAt)
|
276
333
|
{
|
@@ -298,6 +355,7 @@ contract PolicyService is
|
|
298
355
|
)
|
299
356
|
external
|
300
357
|
virtual
|
358
|
+
restricted()
|
301
359
|
nonReentrant()
|
302
360
|
returns (Timestamp expiredAt)
|
303
361
|
{
|
@@ -322,6 +380,7 @@ contract PolicyService is
|
|
322
380
|
)
|
323
381
|
external
|
324
382
|
virtual
|
383
|
+
restricted()
|
325
384
|
nonReentrant()
|
326
385
|
{
|
327
386
|
// checks
|
@@ -333,7 +392,7 @@ contract PolicyService is
|
|
333
392
|
InstanceReader instanceReader = instance.getInstanceReader();
|
334
393
|
|
335
394
|
// check policy is in a closeable state
|
336
|
-
if (!policyIsCloseable(instanceReader, policyNftId)) {
|
395
|
+
if (!PolicyServiceLib.policyIsCloseable(instanceReader, policyNftId)) {
|
337
396
|
revert ErrorPolicyServicePolicyNotCloseable(policyNftId);
|
338
397
|
}
|
339
398
|
|
@@ -341,7 +400,7 @@ contract PolicyService is
|
|
341
400
|
RiskId riskId = policyInfo.riskId;
|
342
401
|
NftId bundleNftId = policyInfo.bundleNftId;
|
343
402
|
|
344
|
-
if (instanceReader.
|
403
|
+
if (instanceReader.getPremiumState(policyNftId) != PAID()) {
|
345
404
|
revert ErrorPolicyServicePremiumNotPaid(policyNftId, policyInfo.premiumAmount);
|
346
405
|
}
|
347
406
|
|
@@ -349,18 +408,17 @@ contract PolicyService is
|
|
349
408
|
// release (remaining) collateral that was blocked by policy
|
350
409
|
_poolService.releaseCollateral(
|
351
410
|
instance,
|
352
|
-
address(instanceReader.getComponentInfo(productNftId).token),
|
353
411
|
policyNftId,
|
354
412
|
policyInfo);
|
355
413
|
|
356
414
|
// TODO consider to also set expiredAt to current block timestamp if that timestamp is still in the futue
|
357
415
|
|
358
416
|
// update policy state to closed
|
359
|
-
policyInfo.closedAt = TimestampLib.
|
360
|
-
instance.
|
417
|
+
policyInfo.closedAt = TimestampLib.current();
|
418
|
+
instance.getProductStore().updatePolicy(policyNftId, policyInfo, CLOSED());
|
361
419
|
|
362
420
|
// unlink policy from risk and bundle
|
363
|
-
NftId poolNftId = getRegistry().
|
421
|
+
NftId poolNftId = getRegistry().getParentNftId(bundleNftId);
|
364
422
|
instance.getRiskSet().unlinkPolicy(productNftId, riskId, policyNftId);
|
365
423
|
instance.getBundleSet().unlinkPolicy(poolNftId, bundleNftId, policyNftId);
|
366
424
|
|
@@ -368,32 +426,6 @@ contract PolicyService is
|
|
368
426
|
}
|
369
427
|
|
370
428
|
|
371
|
-
function policyIsCloseable(InstanceReader instanceReader, NftId policyNftId)
|
372
|
-
public
|
373
|
-
view
|
374
|
-
returns (bool isCloseable)
|
375
|
-
{
|
376
|
-
// policy already closed
|
377
|
-
if (instanceReader.getPolicyState(policyNftId) == CLOSED()) {
|
378
|
-
return false;
|
379
|
-
}
|
380
|
-
|
381
|
-
IPolicy.PolicyInfo memory info = instanceReader.getPolicyInfo(policyNftId);
|
382
|
-
|
383
|
-
if (info.productNftId.eqz()) { return false; } // not closeable: policy does not exist (or does not belong to this instance)
|
384
|
-
if (info.activatedAt.eqz()) { return false; } // not closeable: not yet activated
|
385
|
-
if (info.openClaimsCount > 0) { return false; } // not closeable: has open claims
|
386
|
-
|
387
|
-
// closeable: if sum of claims matches sum insured a policy may be closed prior to the expiry date
|
388
|
-
if (info.claimAmount == info.sumInsuredAmount) { return true; }
|
389
|
-
|
390
|
-
// not closeable: not yet expired
|
391
|
-
if (TimestampLib.blockTimestamp() < info.expiredAt) { return false; }
|
392
|
-
|
393
|
-
// all conditions to close the policy are met
|
394
|
-
return true;
|
395
|
-
}
|
396
|
-
|
397
429
|
/// @dev shared functionality for expire() and policyExpire().
|
398
430
|
function _expire(
|
399
431
|
IInstance instance,
|
@@ -402,93 +434,24 @@ contract PolicyService is
|
|
402
434
|
Timestamp expireAt
|
403
435
|
)
|
404
436
|
internal
|
405
|
-
returns (Timestamp
|
437
|
+
returns (Timestamp)
|
406
438
|
{
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
}
|
413
|
-
|
414
|
-
// set return value to provided timestamp
|
415
|
-
expiredAt = expireAt;
|
416
|
-
|
417
|
-
// update expiredAt to current block timestamp if not set
|
418
|
-
if (expiredAt.eqz()) {
|
419
|
-
expiredAt = TimestampLib.blockTimestamp();
|
420
|
-
}
|
421
|
-
|
422
|
-
// check expiredAt represents a valid expiry time
|
423
|
-
if (expiredAt >= policyInfo.expiredAt) {
|
424
|
-
revert ErrorPolicyServicePolicyExpirationTooLate(policyNftId, policyInfo.expiredAt, expireAt);
|
425
|
-
}
|
426
|
-
|
427
|
-
if (expiredAt < TimestampLib.blockTimestamp()) {
|
428
|
-
revert ErrorPolicyServicePolicyExpirationTooEarly(policyNftId, TimestampLib.blockTimestamp(), expireAt);
|
429
|
-
}
|
439
|
+
policyInfo = PolicyServiceLib.expire(
|
440
|
+
instance.getInstanceReader(),
|
441
|
+
policyNftId,
|
442
|
+
policyInfo,
|
443
|
+
expireAt);
|
430
444
|
|
431
|
-
|
432
|
-
// update policyInfo with new expiredAt timestamp
|
433
|
-
Timestamp originalExpiredAt = policyInfo.expiredAt;
|
434
|
-
policyInfo.expiredAt = expiredAt;
|
435
|
-
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
445
|
+
instance.getProductStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
436
446
|
|
437
|
-
emit LogPolicyServicePolicyExpirationUpdated(policyNftId,
|
447
|
+
emit LogPolicyServicePolicyExpirationUpdated(policyNftId, policyInfo.expiredAt);
|
438
448
|
|
439
449
|
// interactions
|
440
450
|
// callback to policy holder if applicable
|
441
|
-
_policyHolderPolicyExpired(policyNftId, expiredAt);
|
451
|
+
_policyHolderPolicyExpired(policyNftId, policyInfo.expiredAt);
|
452
|
+
return policyInfo.expiredAt;
|
442
453
|
}
|
443
454
|
|
444
|
-
// TODO cleanup
|
445
|
-
// /// @dev Calculates the premium and updates all counters in the other services.
|
446
|
-
// /// Only book keeping, no token transfers.
|
447
|
-
// function _processPremium(
|
448
|
-
// IInstance instance,
|
449
|
-
// NftId applicationNftId,
|
450
|
-
// IPolicy.PolicyInfo memory applicationInfo,
|
451
|
-
// IPolicy.PremiumInfo memory premium
|
452
|
-
// )
|
453
|
-
// internal
|
454
|
-
// virtual
|
455
|
-
// {
|
456
|
-
// // update the counters
|
457
|
-
// _processSale(
|
458
|
-
// instanceReader,
|
459
|
-
// instance.getInstanceStore(),
|
460
|
-
// productNftId,
|
461
|
-
// applicationInfo.bundleNftId,
|
462
|
-
// applicationInfo.referralId,
|
463
|
-
// premium);
|
464
|
-
// }
|
465
|
-
|
466
|
-
|
467
|
-
function _activate(
|
468
|
-
NftId policyNftId,
|
469
|
-
IPolicy.PolicyInfo memory policyInfo,
|
470
|
-
Timestamp activateAt
|
471
|
-
)
|
472
|
-
internal
|
473
|
-
virtual
|
474
|
-
view
|
475
|
-
returns (IPolicy.PolicyInfo memory)
|
476
|
-
{
|
477
|
-
// fail if policy has already been activated and activateAt is different
|
478
|
-
if(! policyInfo.activatedAt.eqz() && activateAt != policyInfo.activatedAt) {
|
479
|
-
revert ErrorPolicyServicePolicyAlreadyActivated(policyNftId);
|
480
|
-
}
|
481
|
-
|
482
|
-
// ignore if policy has already been activated and activateAt is the same
|
483
|
-
if (policyInfo.activatedAt == activateAt) {
|
484
|
-
return policyInfo;
|
485
|
-
}
|
486
|
-
|
487
|
-
policyInfo.activatedAt = activateAt;
|
488
|
-
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
489
|
-
|
490
|
-
return policyInfo;
|
491
|
-
}
|
492
455
|
|
493
456
|
/// @dev update counters by calling the involved services
|
494
457
|
function _processSale(
|
@@ -528,7 +491,7 @@ contract PolicyService is
|
|
528
491
|
|
529
492
|
|
530
493
|
/// @dev transfer the premium to the wallets the premium is distributed to
|
531
|
-
function
|
494
|
+
function _transferPremiumAmounts(
|
532
495
|
InstanceReader instanceReader,
|
533
496
|
NftId policyNftId,
|
534
497
|
NftId productNftId,
|
@@ -537,7 +500,6 @@ contract PolicyService is
|
|
537
500
|
internal
|
538
501
|
virtual
|
539
502
|
{
|
540
|
-
TokenHandler tokenHandler = _getTokenHandler(instanceReader, productNftId);
|
541
503
|
address policyHolder = getRegistry().ownerOf(policyNftId);
|
542
504
|
|
543
505
|
(
|
@@ -549,58 +511,20 @@ contract PolicyService is
|
|
549
511
|
instanceReader,
|
550
512
|
productNftId);
|
551
513
|
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
premium.productFeeAmount,
|
556
|
-
distributionWallet,
|
557
|
-
premium.distributionFeeAndCommissionAmount,
|
558
|
-
poolWallet,
|
559
|
-
premium.poolPremiumAndFeeAmount);
|
560
|
-
}
|
561
|
-
|
562
|
-
|
563
|
-
/// @dev checks that policy has been collateralized and has been activated.
|
564
|
-
/// does not check if policy has been expired or closed.
|
565
|
-
function _policyHasBeenActivated(
|
566
|
-
StateId policyState,
|
567
|
-
IPolicy.PolicyInfo memory policyInfo
|
568
|
-
)
|
569
|
-
internal
|
570
|
-
view
|
571
|
-
returns (bool)
|
572
|
-
{
|
573
|
-
if (policyState != COLLATERALIZED()) { return false; }
|
574
|
-
if (TimestampLib.blockTimestamp() < policyInfo.activatedAt) { return false; }
|
575
|
-
return true;
|
576
|
-
}
|
577
|
-
|
514
|
+
// step 1: collect premium amount from policy holder
|
515
|
+
TokenHandler tokenHandler = instanceReader.getTokenHandler(productNftId);
|
516
|
+
tokenHandler.pullToken(policyHolder, premium.premiumAmount);
|
578
517
|
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
address tokenHandlerAddress,
|
583
|
-
address policyHolder,
|
584
|
-
Amount premiumAmount
|
585
|
-
)
|
586
|
-
internal
|
587
|
-
virtual
|
588
|
-
view
|
589
|
-
{
|
590
|
-
uint256 premium = premiumAmount.toInt();
|
591
|
-
uint256 balance = token.balanceOf(policyHolder);
|
592
|
-
uint256 allowance = token.allowance(policyHolder, tokenHandlerAddress);
|
593
|
-
|
594
|
-
if (balance < premium) {
|
595
|
-
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);
|
596
521
|
}
|
597
522
|
|
598
|
-
|
599
|
-
|
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);
|
600
526
|
}
|
601
527
|
}
|
602
|
-
|
603
|
-
|
604
528
|
function _policyHolderPolicyActivated(
|
605
529
|
NftId policyNftId,
|
606
530
|
Timestamp activateAt
|
@@ -659,21 +583,6 @@ contract PolicyService is
|
|
659
583
|
}
|
660
584
|
|
661
585
|
|
662
|
-
function _getTokenHandler(
|
663
|
-
InstanceReader instanceReader,
|
664
|
-
NftId productNftId
|
665
|
-
)
|
666
|
-
internal
|
667
|
-
virtual
|
668
|
-
view
|
669
|
-
returns (
|
670
|
-
TokenHandler tokenHandler
|
671
|
-
)
|
672
|
-
{
|
673
|
-
tokenHandler = instanceReader.getComponentInfo(productNftId).tokenHandler;
|
674
|
-
}
|
675
|
-
|
676
|
-
|
677
586
|
function _getDistributionNftAndWallets(
|
678
587
|
InstanceReader instanceReader,
|
679
588
|
NftId productNftId
|
@@ -717,7 +626,7 @@ contract PolicyService is
|
|
717
626
|
PRODUCT(), // caller must be product
|
718
627
|
true); // only active caller
|
719
628
|
|
720
|
-
productNftId = productInfo.nftId;
|
629
|
+
productNftId = productInfo.nftId; // calling product nft id
|
721
630
|
instance = IInstance(instanceAddress);
|
722
631
|
policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
723
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
|
+
}
|