@etherisc/gif-next 0.0.2-79292f9-089 → 0.0.2-79a4d57-521
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 +28 -7
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +1007 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +744 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +791 -0
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +203 -77
- package/artifacts/contracts/authorization/AccessAdmin.sol/IAccessManagedChecker.dbg.json +4 -0
- package/artifacts/contracts/authorization/AccessAdmin.sol/IAccessManagedChecker.json +24 -0
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +233 -5
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +200 -16
- 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 +142 -44
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +107 -15
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +19 -0
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +63 -5
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +179 -346
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +206 -27
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +119 -262
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +241 -242
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +138 -120
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +119 -110
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +127 -33
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.json +22 -0
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +1475 -0
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +589 -0
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +2040 -0
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +589 -0
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.json +376 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +1479 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +589 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +1195 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +1655 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +589 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +2426 -0
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +193 -45
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +158 -57
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +105 -103
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +194 -154
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +433 -143
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +150 -90
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +955 -264
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +131 -266
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +107 -97
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +688 -439
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +4 -0
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +853 -0
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
- package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +46 -5
- 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 +138 -305
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +180 -29
- 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 +113 -104
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +69 -11
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +114 -257
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +153 -190
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +127 -93
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +131 -274
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +206 -27
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +158 -363
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +111 -129
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +84 -111
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +133 -135
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +306 -294
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.json +131 -285
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.dbg.json +4 -0
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.json +456 -0
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +474 -525
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +156 -106
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +131 -170
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +101 -95
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +249 -331
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +206 -27
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +407 -242
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +145 -119
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +89 -9
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +293 -17
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +281 -64
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +136 -83
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +246 -176
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +1 -1
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.json +55 -2
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +405 -267
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +150 -108
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +227 -314
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +125 -127
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/Product.sol/Product.json +247 -329
- package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +1 -1
- package/artifacts/contracts/product/RiskService.sol/RiskService.json +114 -172
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +112 -90
- 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 +119 -19
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +144 -41
- package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +4 -0
- package/artifacts/contracts/registry/IRelease.sol/IRelease.json +24 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +5 -18
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +164 -56
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +326 -259
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +109 -292
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +99 -85
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +1849 -0
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +47 -6
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +424 -224
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +66 -8
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +4 -4
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.json +92 -217
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +501 -610
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +141 -125
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +57 -111
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +541 -0
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.json +24 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.json +30 -0
- 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 +92 -65
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +446 -276
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +113 -104
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +36 -0
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +36 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +16 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +15 -47
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +148 -0
- 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 +55 -2
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +2 -22
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +113 -256
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +42 -1
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +42 -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 +22 -57
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +19 -141
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +122 -97
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +57 -111
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +327 -73
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.json +484 -0
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +88 -24
- package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/IStaking.sol/IStaking.json +137 -102
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +77 -16
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +84 -31
- package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/staking/Staking.sol/Staking.json +216 -308
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +46 -5
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +128 -101
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +6 -11
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +122 -164
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +104 -90
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +149 -108
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +55 -24
- 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 +33 -9
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +28 -4
- 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 +3 -3
- 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 +4 -0
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.json +33 -0
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/NftId.sol/NftIdLib.json +23 -4
- 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 +2 -2
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +19 -19
- 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 +118 -5
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +79 -15
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +26 -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/StateId.sol/StateIdLib.json +15 -2
- package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +2 -2
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +16 -3
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.json +3 -22
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.json +45 -13
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +76 -75
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
- package/contracts/accounting/AccountingService.sol +262 -0
- package/contracts/accounting/AccountingServiceManager.sol +38 -0
- package/contracts/accounting/IAccountingService.sol +45 -0
- package/contracts/authorization/AccessAdmin.sol +232 -133
- package/contracts/authorization/AccessManagerCloneable.sol +136 -3
- package/contracts/authorization/Authorization.sol +322 -205
- package/contracts/authorization/IAccess.sol +1 -0
- package/contracts/authorization/IAccessAdmin.sol +17 -9
- package/contracts/authorization/IAuthorization.sol +27 -7
- package/contracts/authorization/IServiceAuthorization.sol +3 -1
- package/contracts/authorization/ServiceAuthorization.sol +25 -10
- package/contracts/distribution/BasicDistribution.sol +8 -7
- package/contracts/distribution/BasicDistributionAuthorization.sol +22 -9
- package/contracts/distribution/Distribution.sol +33 -41
- package/contracts/distribution/DistributionService.sol +111 -76
- package/contracts/distribution/DistributionServiceManager.sol +6 -6
- package/contracts/distribution/IDistributionComponent.sol +1 -1
- package/contracts/distribution/IDistributionService.sol +13 -8
- package/contracts/examples/fire/DamageLevel.sol +59 -0
- package/contracts/examples/fire/FirePool.sol +90 -0
- package/contracts/examples/fire/FirePoolAuthorization.sol +35 -0
- package/contracts/examples/fire/FireProduct.sol +438 -0
- package/contracts/examples/fire/FireProductAuthorization.sol +45 -0
- package/contracts/examples/fire/FireUSD.sol +26 -0
- package/contracts/examples/unpermissioned/SimpleDistribution.sol +57 -0
- package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleOracle.sol +137 -0
- package/contracts/examples/unpermissioned/SimplePool.sol +106 -0
- package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleProduct.sol +377 -0
- package/contracts/instance/BundleSet.sol +42 -38
- package/contracts/instance/IInstance.sol +17 -10
- package/contracts/instance/IInstanceService.sol +9 -29
- package/contracts/instance/Instance.sol +53 -35
- package/contracts/instance/InstanceAdmin.sol +257 -100
- package/contracts/instance/InstanceAuthorizationV3.sol +56 -47
- package/contracts/instance/InstanceReader.sol +256 -39
- package/contracts/instance/InstanceService.sol +95 -157
- package/contracts/instance/InstanceServiceManager.sol +6 -7
- package/contracts/instance/InstanceStore.sol +23 -2
- package/contracts/instance/RiskSet.sol +118 -0
- package/contracts/instance/base/ObjectCounter.sol +1 -2
- package/contracts/instance/base/ObjectLifecycle.sol +10 -2
- package/contracts/instance/base/ObjectSet.sol +31 -33
- package/contracts/instance/base/ObjectSetHelperLib.sol +30 -0
- package/contracts/instance/module/IComponents.sol +13 -8
- package/contracts/instance/module/IPolicy.sol +25 -24
- package/contracts/instance/module/IRisk.sol +3 -0
- package/contracts/oracle/BasicOracle.sol +0 -1
- package/contracts/oracle/BasicOracleAuthorization.sol +3 -12
- package/contracts/oracle/IOracleService.sol +2 -1
- package/contracts/oracle/Oracle.sol +6 -17
- package/contracts/oracle/OracleService.sol +113 -82
- package/contracts/oracle/OracleServiceManager.sol +6 -6
- package/contracts/pool/BasicPool.sol +33 -24
- package/contracts/pool/BasicPoolAuthorization.sol +27 -9
- package/contracts/pool/BundleService.sol +93 -134
- package/contracts/pool/BundleServiceManager.sol +6 -6
- package/contracts/pool/IBundleService.sol +15 -34
- package/contracts/pool/IPoolComponent.sol +19 -15
- package/contracts/pool/IPoolService.sol +73 -71
- package/contracts/pool/Pool.sol +139 -122
- package/contracts/pool/PoolLib.sol +216 -0
- package/contracts/pool/PoolService.sol +489 -273
- package/contracts/pool/PoolServiceManager.sol +4 -4
- package/contracts/product/ApplicationService.sol +36 -27
- package/contracts/product/ApplicationServiceManager.sol +4 -4
- package/contracts/product/BasicProduct.sol +10 -12
- package/contracts/product/BasicProductAuthorization.sol +24 -11
- package/contracts/product/ClaimService.sol +366 -150
- package/contracts/product/ClaimServiceManager.sol +4 -4
- package/contracts/product/IApplicationService.sol +5 -2
- package/contracts/product/IClaimService.sol +43 -8
- package/contracts/product/IPolicyService.sol +41 -28
- package/contracts/product/IPricingService.sol +10 -10
- package/contracts/product/IProductComponent.sol +27 -5
- package/contracts/product/PolicyService.sol +456 -274
- package/contracts/product/PolicyServiceManager.sol +4 -4
- package/contracts/product/PricingService.sol +62 -62
- package/contracts/product/PricingServiceManager.sol +4 -4
- package/contracts/product/Product.sol +149 -82
- package/contracts/product/RiskService.sol +77 -29
- package/contracts/product/RiskServiceManager.sol +4 -4
- package/contracts/registry/ChainNft.sol +10 -11
- package/contracts/registry/IRegistry.sol +18 -20
- package/contracts/registry/IRegistryService.sol +5 -12
- package/contracts/registry/IRelease.sol +26 -0
- package/contracts/registry/ITransferInterceptor.sol +1 -2
- package/contracts/registry/Registry.sol +42 -17
- package/contracts/registry/RegistryAdmin.sol +133 -243
- package/contracts/registry/RegistryService.sol +39 -49
- package/contracts/registry/RegistryServiceManager.sol +3 -3
- package/contracts/registry/ReleaseAdmin.sol +245 -0
- package/contracts/registry/ReleaseLifecycle.sol +6 -3
- package/contracts/registry/ReleaseRegistry.sol +236 -263
- package/contracts/registry/ServiceAuthorizationV3.sol +98 -51
- package/contracts/registry/TokenRegistry.sol +6 -8
- package/contracts/shared/Component.sol +74 -115
- package/contracts/shared/ComponentService.sol +427 -376
- package/contracts/shared/ComponentServiceManager.sol +8 -5
- package/contracts/shared/ComponentVerifyingService.sol +28 -17
- package/contracts/shared/ContractLib.sol +253 -0
- package/contracts/shared/IComponent.sol +8 -17
- package/contracts/shared/IComponentService.sol +41 -37
- package/contracts/shared/IInstanceLinkedComponent.sol +3 -22
- package/contracts/shared/ILifecycle.sol +3 -1
- package/contracts/shared/INftOwnable.sol +2 -0
- package/contracts/shared/IPolicyHolder.sol +12 -22
- package/contracts/shared/IRegisterable.sol +23 -1
- package/contracts/shared/IService.sol +3 -5
- package/contracts/shared/InitializableERC165.sol +2 -2
- package/contracts/shared/InstanceLinkedComponent.sol +73 -48
- package/contracts/shared/KeyValueStore.sol +1 -1
- package/contracts/shared/Lifecycle.sol +15 -4
- package/contracts/shared/NftOwnable.sol +29 -9
- package/contracts/shared/PolicyHolder.sol +15 -52
- package/contracts/shared/Registerable.sol +55 -21
- package/contracts/shared/RegistryLinked.sol +9 -14
- package/contracts/shared/Service.sol +15 -32
- package/contracts/shared/TokenHandler.sol +274 -72
- package/contracts/shared/TokenHandlerDeployerLib.sol +10 -2
- package/contracts/staking/IStaking.sol +7 -9
- package/contracts/staking/IStakingService.sol +8 -3
- package/contracts/staking/StakeManagerLib.sol +19 -1
- package/contracts/staking/Staking.sol +69 -40
- package/contracts/staking/StakingManager.sol +8 -6
- package/contracts/staking/StakingReader.sol +13 -6
- package/contracts/staking/StakingService.sol +47 -24
- package/contracts/staking/StakingServiceManager.sol +6 -5
- package/contracts/staking/TargetManagerLib.sol +7 -3
- package/contracts/type/Amount.sol +15 -0
- package/contracts/type/ClaimId.sol +6 -1
- package/contracts/type/Key32.sol +2 -2
- package/contracts/type/Key32Set.sol +62 -0
- package/contracts/type/NftId.sol +7 -0
- package/contracts/type/ObjectType.sol +52 -20
- package/contracts/type/PayoutId.sol +10 -10
- package/contracts/type/RiskId.sol +35 -4
- package/contracts/type/RoleId.sol +23 -15
- package/contracts/type/Seconds.sol +8 -0
- package/contracts/type/Selector.sol +5 -0
- package/contracts/type/StateId.sol +12 -2
- package/contracts/type/Timestamp.sol +0 -5
- package/contracts/type/UFixed.sol +13 -119
- package/contracts/type/Version.sol +17 -10
- package/contracts/upgradeability/ProxyManager.sol +74 -40
- package/contracts/upgradeability/Versionable.sol +2 -2
- package/package.json +4 -3
- package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +0 -4
- package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.json +0 -290
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +0 -4
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +0 -390
- 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/InitializableCustom.sol/InitializableCustom.dbg.json +0 -4
- package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.json +0 -39
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +0 -4
- package/artifacts/contracts/type/UFixed.sol/MathLib.json +0 -16
- package/contracts/authorization/IModuleAuthorization.sol +0 -21
- package/contracts/authorization/ModuleAuthorization.sol +0 -78
- package/contracts/instance/module/IAccess.sol +0 -46
- package/contracts/shared/InitializableCustom.sol +0 -177
@@ -3,46 +3,40 @@ pragma solidity ^0.8.20;
|
|
3
3
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
|
-
import {
|
7
|
-
import {
|
6
|
+
import {IAccountingService} from "../accounting/IAccountingService.sol";
|
7
|
+
import {IComponentService} from "../shared/IComponentService.sol";
|
8
8
|
import {IComponents} from "../instance/module/IComponents.sol";
|
9
|
+
import {IDistributionService} from "../distribution/IDistributionService.sol";
|
10
|
+
import {InstanceReader} from "../instance/InstanceReader.sol";
|
11
|
+
import {InstanceStore} from "../instance/InstanceStore.sol";
|
9
12
|
import {IInstance} from "../instance/IInstance.sol";
|
10
13
|
import {IPolicy} from "../instance/module/IPolicy.sol";
|
14
|
+
import {IPolicyHolder} from "../shared/IPolicyHolder.sol";
|
15
|
+
import {IPolicyService} from "./IPolicyService.sol";
|
16
|
+
import {IPoolService} from "../pool/IPoolService.sol";
|
17
|
+
import {IPricingService} from "./IPricingService.sol";
|
18
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
11
19
|
|
12
|
-
import {
|
13
|
-
|
14
|
-
import {
|
15
|
-
import {
|
16
|
-
import {ObjectType,
|
17
|
-
import {APPLIED, COLLATERALIZED, KEEP_STATE, CLOSED, DECLINED} from "../type/StateId.sol";
|
18
|
-
import {NftId, NftIdLib} from "../type/NftId.sol";
|
20
|
+
import {Amount} from "../type/Amount.sol";
|
21
|
+
import {APPLIED, COLLATERALIZED, KEEP_STATE, CLOSED, DECLINED, PAID} from "../type/StateId.sol";
|
22
|
+
import {ContractLib} from "../shared/ContractLib.sol";
|
23
|
+
import {NftId} from "../type/NftId.sol";
|
24
|
+
import {ObjectType, ACCOUNTING, COMPONENT, DISTRIBUTION, PRODUCT, POOL, POLICY, PRICE} from "../type/ObjectType.sol";
|
19
25
|
import {ReferralId} from "../type/Referral.sol";
|
26
|
+
import {RiskId} from "../type/RiskId.sol";
|
27
|
+
import {Service} from "../shared/Service.sol";
|
20
28
|
import {StateId} from "../type/StateId.sol";
|
29
|
+
import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
|
30
|
+
import {TokenHandler} from "../shared/TokenHandler.sol";
|
21
31
|
import {VersionPart} from "../type/Version.sol";
|
22
32
|
|
23
|
-
import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
|
24
|
-
import {IApplicationService} from "./IApplicationService.sol";
|
25
|
-
import {IBundleService} from "../pool/IBundleService.sol";
|
26
|
-
import {IClaimService} from "./IClaimService.sol";
|
27
|
-
import {IComponentService} from "../shared/IComponentService.sol";
|
28
|
-
import {IDistributionService} from "../distribution/IDistributionService.sol";
|
29
|
-
import {InstanceReader} from "../instance/InstanceReader.sol";
|
30
|
-
import {InstanceStore} from "../instance/InstanceStore.sol";
|
31
|
-
import {IPolicyService} from "./IPolicyService.sol";
|
32
|
-
import {IPoolService} from "../pool/IPoolService.sol";
|
33
|
-
import {IPricingService} from "./IPricingService.sol";
|
34
33
|
|
35
34
|
contract PolicyService is
|
36
|
-
|
35
|
+
Service,
|
37
36
|
IPolicyService
|
38
37
|
{
|
39
|
-
|
40
|
-
using TimestampLib for Timestamp;
|
41
|
-
|
42
|
-
IApplicationService internal _applicationService;
|
38
|
+
IAccountingService private _accountingService;
|
43
39
|
IComponentService internal _componentService;
|
44
|
-
IBundleService internal _bundleService;
|
45
|
-
IClaimService internal _claimService;
|
46
40
|
IDistributionService internal _distributionService;
|
47
41
|
IPoolService internal _poolService;
|
48
42
|
IPricingService internal _pricingService;
|
@@ -53,26 +47,23 @@ contract PolicyService is
|
|
53
47
|
)
|
54
48
|
internal
|
55
49
|
virtual override
|
56
|
-
|
50
|
+
initializer
|
57
51
|
{
|
58
52
|
(
|
59
|
-
address
|
60
|
-
|
61
|
-
|
62
|
-
) = abi.decode(data, (address, address, address));
|
53
|
+
address authority,
|
54
|
+
address registry
|
55
|
+
) = abi.decode(data, (address, address));
|
63
56
|
|
64
|
-
|
57
|
+
__Service_init(authority, registry, owner);
|
65
58
|
|
66
59
|
VersionPart majorVersion = getVersion().toMajorPart();
|
67
|
-
|
68
|
-
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), majorVersion));
|
60
|
+
_accountingService = IAccountingService(getRegistry().getServiceAddress(ACCOUNTING(), majorVersion));
|
69
61
|
_componentService = IComponentService(getRegistry().getServiceAddress(COMPONENT(), majorVersion));
|
70
|
-
_claimService = IClaimService(getRegistry().getServiceAddress(CLAIM(), majorVersion));
|
71
62
|
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), majorVersion));
|
72
63
|
_distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), majorVersion));
|
73
64
|
_pricingService = IPricingService(getRegistry().getServiceAddress(PRICE(), majorVersion));
|
74
65
|
|
75
|
-
|
66
|
+
_registerInterface(type(IPolicyService).interfaceId);
|
76
67
|
}
|
77
68
|
|
78
69
|
|
@@ -80,26 +71,18 @@ contract PolicyService is
|
|
80
71
|
NftId applicationNftId // = policyNftId
|
81
72
|
)
|
82
73
|
external
|
83
|
-
virtual
|
74
|
+
virtual
|
75
|
+
nonReentrant()
|
84
76
|
{
|
85
|
-
|
86
|
-
|
77
|
+
// checks
|
78
|
+
(IInstance instance,,) = _getAndVerifyCallerForPolicy(applicationNftId);
|
87
79
|
|
88
80
|
// check policy is in state applied
|
89
|
-
if (
|
81
|
+
if (instance.getInstanceReader().getPolicyState(applicationNftId) != APPLIED()) {
|
90
82
|
revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
|
91
83
|
}
|
92
84
|
|
93
|
-
//
|
94
|
-
IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
|
95
|
-
if(applicationInfo.productNftId != productNftId) {
|
96
|
-
revert ErrorPolicyServicePolicyProductMismatch(
|
97
|
-
applicationNftId,
|
98
|
-
applicationInfo.productNftId,
|
99
|
-
productNftId);
|
100
|
-
}
|
101
|
-
|
102
|
-
|
85
|
+
// effects
|
103
86
|
// store updated policy info
|
104
87
|
instance.getInstanceStore().updatePolicyState(
|
105
88
|
applicationNftId,
|
@@ -112,78 +95,86 @@ contract PolicyService is
|
|
112
95
|
/// @inheritdoc IPolicyService
|
113
96
|
function createPolicy(
|
114
97
|
NftId applicationNftId, // = policyNftId
|
115
|
-
bool requirePremiumPayment,
|
116
98
|
Timestamp activateAt
|
117
99
|
)
|
118
100
|
external
|
119
|
-
virtual
|
101
|
+
virtual
|
102
|
+
nonReentrant()
|
103
|
+
returns (Amount premiumAmount)
|
120
104
|
{
|
121
|
-
//
|
122
|
-
(
|
123
|
-
|
105
|
+
// checks
|
106
|
+
(
|
107
|
+
IInstance instance,
|
108
|
+
NftId productNftId,
|
109
|
+
IPolicy.PolicyInfo memory applicationInfo
|
110
|
+
) = _getAndVerifyCallerForPolicy(applicationNftId);
|
124
111
|
|
125
112
|
// check policy is in state applied
|
113
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
126
114
|
if (instanceReader.getPolicyState(applicationNftId) != APPLIED()) {
|
127
115
|
revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
|
128
116
|
}
|
129
117
|
|
130
|
-
//
|
131
|
-
IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
|
132
|
-
if(applicationInfo.productNftId != productNftId) {
|
133
|
-
revert ErrorPolicyServicePolicyProductMismatch(
|
134
|
-
applicationNftId,
|
135
|
-
applicationInfo.productNftId,
|
136
|
-
productNftId);
|
137
|
-
}
|
138
|
-
|
139
|
-
StateId newPolicyState = COLLATERALIZED();
|
140
|
-
|
118
|
+
// effects
|
141
119
|
// actual collateralizaion
|
142
|
-
(
|
143
|
-
Amount localCollateralAmount,
|
144
|
-
Amount totalCollateralAmount
|
145
|
-
) = _poolService.lockCollateral(
|
120
|
+
_poolService.lockCollateral(
|
146
121
|
instance,
|
147
|
-
address(instanceReader.
|
122
|
+
address(instanceReader.getToken(productNftId)),
|
148
123
|
productNftId,
|
149
124
|
applicationNftId,
|
150
125
|
applicationInfo.bundleNftId,
|
151
126
|
applicationInfo.sumInsuredAmount);
|
152
127
|
|
153
128
|
// optional activation of policy
|
154
|
-
if(activateAt
|
155
|
-
applicationInfo
|
156
|
-
applicationInfo.expiredAt = activateAt.addSeconds(applicationInfo.lifetime);
|
157
|
-
}
|
158
|
-
|
159
|
-
IPolicy.Premium memory premium;
|
160
|
-
|
161
|
-
// optional: calculate the premium and update counters for collection at the end of this function
|
162
|
-
if(requirePremiumPayment) {
|
163
|
-
premium = _calculateAndProcessPremium(
|
164
|
-
instance,
|
165
|
-
applicationNftId,
|
166
|
-
applicationInfo);
|
167
|
-
|
168
|
-
applicationInfo.premiumPaidAmount = AmountLib.toAmount(premium.premiumAmount);
|
129
|
+
if(activateAt.gtz()) {
|
130
|
+
applicationInfo = _activate(applicationNftId, applicationInfo, activateAt);
|
169
131
|
}
|
170
132
|
|
171
|
-
//
|
133
|
+
// update policy and set state to collateralized
|
172
134
|
instance.getInstanceStore().updatePolicy(
|
173
135
|
applicationNftId,
|
174
136
|
applicationInfo,
|
175
|
-
|
137
|
+
COLLATERALIZED());
|
176
138
|
|
177
|
-
//
|
139
|
+
// calculate and store premium
|
140
|
+
RiskId riskId = applicationInfo.riskId;
|
141
|
+
NftId bundleNftId = applicationInfo.bundleNftId;
|
178
142
|
|
179
|
-
|
143
|
+
IPolicy.PremiumInfo memory premium = _pricingService.calculatePremium(
|
144
|
+
productNftId,
|
145
|
+
riskId,
|
146
|
+
applicationInfo.sumInsuredAmount,
|
147
|
+
applicationInfo.lifetime,
|
148
|
+
applicationInfo.applicationData,
|
149
|
+
bundleNftId,
|
150
|
+
applicationInfo.referralId);
|
151
|
+
|
152
|
+
premiumAmount = premium.fullPremiumAmount;
|
153
|
+
instance.getInstanceStore().createPremium(
|
154
|
+
applicationNftId,
|
155
|
+
premium);
|
180
156
|
|
181
|
-
//
|
182
|
-
|
183
|
-
|
157
|
+
// update referral counter if product has linked distributino component
|
158
|
+
{
|
159
|
+
IComponents.ProductInfo memory productInfo = instanceReader.getProductInfo(productNftId);
|
160
|
+
if (productInfo.hasDistribution) {
|
161
|
+
_distributionService.processReferral(
|
162
|
+
productInfo.distributionNftId,
|
163
|
+
applicationInfo.referralId);
|
164
|
+
}
|
184
165
|
}
|
185
166
|
|
186
|
-
//
|
167
|
+
// link policy to risk and bundle
|
168
|
+
NftId poolNftId = getRegistry().getParentNftId(bundleNftId);
|
169
|
+
instance.getRiskSet().linkPolicy(productNftId, riskId, applicationNftId);
|
170
|
+
instance.getBundleSet().linkPolicy(poolNftId, bundleNftId, applicationNftId);
|
171
|
+
|
172
|
+
// log policy creation before interactions with token and policy holder
|
173
|
+
emit LogPolicyServicePolicyCreated(applicationNftId, premium.premiumAmount, activateAt);
|
174
|
+
|
175
|
+
// interactions
|
176
|
+
// callback to policy holder if applicable
|
177
|
+
_policyHolderPolicyActivated(applicationNftId, activateAt);
|
187
178
|
}
|
188
179
|
|
189
180
|
|
@@ -194,31 +185,49 @@ contract PolicyService is
|
|
194
185
|
)
|
195
186
|
external
|
196
187
|
virtual
|
188
|
+
nonReentrant()
|
197
189
|
{
|
198
|
-
//
|
199
|
-
(
|
200
|
-
|
201
|
-
|
190
|
+
// checks
|
191
|
+
(
|
192
|
+
IInstance instance,
|
193
|
+
NftId productNftId,
|
194
|
+
IPolicy.PolicyInfo memory policyInfo
|
195
|
+
) = _getAndVerifyCallerForPolicy(policyNftId);
|
202
196
|
|
203
|
-
// check policy is in state collateralized
|
204
|
-
|
197
|
+
// check policy is in state collateralized
|
198
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
199
|
+
if (instanceReader.getPolicyState(policyNftId) != COLLATERALIZED()) {
|
205
200
|
revert ErrorPolicyServicePolicyStateNotCollateralized(policyNftId);
|
206
201
|
}
|
207
202
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
if (policyInfo.premiumPaidAmount.gtz()) {
|
212
|
-
revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
|
203
|
+
// check if premium has already been collected
|
204
|
+
if (instanceReader.getPremiumInfoState(policyNftId) == PAID()) {
|
205
|
+
revert ErrorPolicyServicePremiumAlreadyPaid(policyNftId);
|
213
206
|
}
|
214
207
|
|
215
|
-
//
|
216
|
-
IPolicy.
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
208
|
+
// check funds and allowance of policy holder
|
209
|
+
IPolicy.PremiumInfo memory premium = instanceReader.getPremiumInfo(policyNftId);
|
210
|
+
instanceReader.getTokenHandler(
|
211
|
+
productNftId).checkBalanceAndAllowance(
|
212
|
+
getRegistry().ownerOf(policyNftId),
|
213
|
+
premium.premiumAmount,
|
214
|
+
false);
|
215
|
+
|
216
|
+
// )
|
217
|
+
// _checkPremiumBalanceAndAllowance(
|
218
|
+
// tokenHandler.TOKEN(),
|
219
|
+
// address(tokenHandler),
|
220
|
+
// getRegistry().ownerOf(policyNftId),
|
221
|
+
// premium.premiumAmount);
|
222
|
+
|
223
|
+
// effects
|
224
|
+
_processSale(
|
225
|
+
instanceReader,
|
226
|
+
instance.getInstanceStore(),
|
227
|
+
productNftId,
|
228
|
+
policyInfo.bundleNftId,
|
229
|
+
policyInfo.referralId,
|
230
|
+
premium);
|
222
231
|
|
223
232
|
// optionally activate policy
|
224
233
|
if(activateAt.gtz()) {
|
@@ -226,121 +235,167 @@ contract PolicyService is
|
|
226
235
|
}
|
227
236
|
|
228
237
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
238
|
+
instance.getInstanceStore().updatePremiumState(policyNftId, PAID());
|
229
239
|
|
230
|
-
//
|
240
|
+
// log premium collection before interactions with token
|
241
|
+
emit LogPolicyServicePolicyPremiumCollected(policyNftId, premium.premiumAmount);
|
231
242
|
|
232
|
-
|
233
|
-
|
234
|
-
// TODO: add callback IPolicyHolder.policyActivated() if applicable
|
243
|
+
// interactions
|
244
|
+
_transferPremiumAmounts(instanceReader, policyNftId, policyInfo.productNftId, premium);
|
235
245
|
}
|
236
246
|
|
247
|
+
|
237
248
|
/// @inheritdoc IPolicyService
|
238
|
-
function activate(NftId policyNftId, Timestamp activateAt)
|
239
|
-
|
240
|
-
|
241
|
-
|
249
|
+
function activate(NftId policyNftId, Timestamp activateAt)
|
250
|
+
external
|
251
|
+
virtual
|
252
|
+
nonReentrant()
|
253
|
+
{
|
254
|
+
// checks
|
255
|
+
(
|
256
|
+
IInstance instance,,
|
257
|
+
IPolicy.PolicyInfo memory policyInfo
|
258
|
+
) = _getAndVerifyCallerForPolicy(policyNftId);
|
242
259
|
|
243
|
-
|
260
|
+
// effects
|
244
261
|
policyInfo = _activate(policyNftId, policyInfo, activateAt);
|
245
|
-
|
246
262
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
247
263
|
|
248
|
-
//
|
264
|
+
// log policy activation before interactions with policy holder
|
265
|
+
emit LogPolicyServicePolicyActivated(policyNftId, activateAt);
|
249
266
|
|
250
|
-
//
|
267
|
+
// interactions
|
268
|
+
// callback to policy holder if applicable
|
269
|
+
_policyHolderPolicyActivated(policyNftId, activateAt);
|
251
270
|
}
|
252
271
|
|
253
|
-
|
254
272
|
/// @inheritdoc IPolicyService
|
255
|
-
function
|
273
|
+
function adjustActivation(
|
256
274
|
NftId policyNftId,
|
257
|
-
Timestamp
|
275
|
+
Timestamp newActivateAt
|
258
276
|
)
|
259
277
|
external
|
260
|
-
override
|
261
278
|
virtual
|
262
|
-
|
279
|
+
nonReentrant()
|
263
280
|
{
|
264
|
-
|
265
|
-
|
281
|
+
// checks
|
282
|
+
(
|
283
|
+
IInstance instance,,
|
284
|
+
IPolicy.PolicyInfo memory policyInfo
|
285
|
+
) = _getAndVerifyCallerForPolicy(policyNftId);
|
266
286
|
|
267
|
-
|
268
|
-
|
269
|
-
if(policyInfo.productNftId != productNftId) {
|
270
|
-
revert ErrorPolicyServicePolicyProductMismatch(
|
271
|
-
policyNftId,
|
272
|
-
policyInfo.productNftId,
|
273
|
-
productNftId);
|
287
|
+
if (policyInfo.activatedAt.eqz()) {
|
288
|
+
revert ErrorPolicyServicePolicyNotActivated(policyNftId);
|
274
289
|
}
|
275
290
|
|
276
|
-
|
277
|
-
|
278
|
-
if (!_policyHasBeenActivated(policyState, policyInfo)) {
|
279
|
-
revert ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
291
|
+
if (newActivateAt < TimestampLib.blockTimestamp()) {
|
292
|
+
revert ErrorPolicyServicePolicyActivationTooEarly(policyNftId, TimestampLib.blockTimestamp(), newActivateAt);
|
280
293
|
}
|
281
294
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
// update expiredAt to current block timestamp if not set
|
286
|
-
if (expiredAt.eqz()) {
|
287
|
-
expiredAt = TimestampLib.blockTimestamp();
|
295
|
+
if (newActivateAt > policyInfo.expiredAt) {
|
296
|
+
revert ErrorPolicyServicePolicyActivationTooLate(policyNftId, policyInfo.expiredAt, newActivateAt);
|
288
297
|
}
|
289
298
|
|
290
|
-
|
291
|
-
if (expiredAt >= policyInfo.expiredAt) {
|
292
|
-
revert ErrorPolicyServicePolicyExpirationTooLate(policyNftId, policyInfo.expiredAt, expireAt);
|
293
|
-
}
|
294
|
-
if (expiredAt < TimestampLib.blockTimestamp()) {
|
295
|
-
revert ErrorPolicyServicePolicyExpirationTooEarly(policyNftId, TimestampLib.blockTimestamp(), expireAt);
|
296
|
-
}
|
299
|
+
Timestamp originalActivatedAt = policyInfo.activatedAt;
|
297
300
|
|
298
|
-
//
|
299
|
-
policyInfo.
|
301
|
+
// effects
|
302
|
+
policyInfo.activatedAt = newActivateAt;
|
300
303
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
301
304
|
|
302
|
-
|
305
|
+
// log policy activation before interactions with policy holder
|
306
|
+
emit LogPolicyServicePolicyActivatedUpdated(policyNftId, originalActivatedAt, newActivateAt);
|
307
|
+
|
308
|
+
// interactions
|
309
|
+
// callback to policy holder if applicable
|
310
|
+
_policyHolderPolicyActivated(policyNftId, newActivateAt);
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
/// @inheritdoc IPolicyService
|
315
|
+
function expire(
|
316
|
+
NftId policyNftId,
|
317
|
+
Timestamp expireAt
|
318
|
+
)
|
319
|
+
external
|
320
|
+
virtual
|
321
|
+
nonReentrant()
|
322
|
+
returns (Timestamp expiredAt)
|
323
|
+
{
|
324
|
+
// checks
|
325
|
+
(
|
326
|
+
IInstance instance,,
|
327
|
+
IPolicy.PolicyInfo memory policyInfo
|
328
|
+
) = _getAndVerifyCallerForPolicy(policyNftId);
|
329
|
+
|
330
|
+
// more checks, effects + interactions
|
331
|
+
return _expire(
|
332
|
+
instance,
|
333
|
+
policyNftId,
|
334
|
+
policyInfo,
|
335
|
+
expireAt
|
336
|
+
);
|
337
|
+
}
|
338
|
+
|
339
|
+
|
340
|
+
/// @inheritdoc IPolicyService
|
341
|
+
function expirePolicy(
|
342
|
+
IInstance instance,
|
343
|
+
NftId policyNftId,
|
344
|
+
Timestamp expireAt
|
345
|
+
)
|
346
|
+
external
|
347
|
+
virtual
|
348
|
+
nonReentrant()
|
349
|
+
returns (Timestamp expiredAt)
|
350
|
+
{
|
351
|
+
// checks
|
352
|
+
_checkNftType(policyNftId, POLICY());
|
353
|
+
IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(
|
354
|
+
policyNftId);
|
303
355
|
|
304
|
-
//
|
356
|
+
// more checks, effects + interactions
|
357
|
+
return _expire(
|
358
|
+
instance,
|
359
|
+
policyNftId,
|
360
|
+
policyInfo,
|
361
|
+
expireAt
|
362
|
+
);
|
305
363
|
}
|
306
364
|
|
307
365
|
|
366
|
+
/// @inheritdoc IPolicyService
|
308
367
|
function close(
|
309
368
|
NftId policyNftId
|
310
369
|
)
|
311
370
|
external
|
312
|
-
|
371
|
+
virtual
|
372
|
+
nonReentrant()
|
313
373
|
{
|
314
|
-
|
374
|
+
// checks
|
375
|
+
(
|
376
|
+
IInstance instance,
|
377
|
+
NftId productNftId,
|
378
|
+
IPolicy.PolicyInfo memory policyInfo
|
379
|
+
) = _getAndVerifyCallerForPolicy(policyNftId);
|
315
380
|
InstanceReader instanceReader = instance.getInstanceReader();
|
316
381
|
|
317
|
-
// check
|
318
|
-
|
319
|
-
|
320
|
-
if (!_policyHasBeenActivated(policyState, policyInfo)) {
|
321
|
-
revert ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
322
|
-
}
|
323
|
-
|
324
|
-
// check that policy has not already been closed
|
325
|
-
if (policyInfo.closedAt.gtz()) {
|
326
|
-
revert ErrorPolicyServicePolicyAlreadyClosed(policyNftId);
|
382
|
+
// check policy is in a closeable state
|
383
|
+
if (!policyIsCloseable(instanceReader, policyNftId)) {
|
384
|
+
revert ErrorPolicyServicePolicyNotCloseable(policyNftId);
|
327
385
|
}
|
328
386
|
|
329
|
-
// check that policy
|
330
|
-
|
331
|
-
|
332
|
-
}
|
387
|
+
// check that policy has been activated
|
388
|
+
RiskId riskId = policyInfo.riskId;
|
389
|
+
NftId bundleNftId = policyInfo.bundleNftId;
|
333
390
|
|
334
|
-
|
335
|
-
|
336
|
-
if (!(policyInfo.premiumAmount == policyInfo.premiumPaidAmount)) {
|
337
|
-
revert ErrorPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
|
391
|
+
if (instanceReader.getPremiumInfoState(policyNftId) != PAID()) {
|
392
|
+
revert ErrorPolicyServicePremiumNotPaid(policyNftId, policyInfo.premiumAmount);
|
338
393
|
}
|
339
394
|
|
395
|
+
// effects
|
340
396
|
// release (remaining) collateral that was blocked by policy
|
341
397
|
_poolService.releaseCollateral(
|
342
398
|
instance,
|
343
|
-
address(instanceReader.getComponentInfo(policyInfo.productNftId).token),
|
344
399
|
policyNftId,
|
345
400
|
policyInfo);
|
346
401
|
|
@@ -350,55 +405,86 @@ contract PolicyService is
|
|
350
405
|
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
351
406
|
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, CLOSED());
|
352
407
|
|
353
|
-
//
|
408
|
+
// unlink policy from risk and bundle
|
409
|
+
NftId poolNftId = getRegistry().getParentNftId(bundleNftId);
|
410
|
+
instance.getRiskSet().unlinkPolicy(productNftId, riskId, policyNftId);
|
411
|
+
instance.getBundleSet().unlinkPolicy(poolNftId, bundleNftId, policyNftId);
|
412
|
+
|
413
|
+
emit LogPolicyServicePolicyClosed(policyNftId);
|
354
414
|
}
|
355
415
|
|
356
416
|
|
357
|
-
|
358
|
-
|
417
|
+
function policyIsCloseable(InstanceReader instanceReader, NftId policyNftId)
|
418
|
+
public
|
419
|
+
view
|
420
|
+
returns (bool isCloseable)
|
421
|
+
{
|
422
|
+
// policy already closed
|
423
|
+
if (instanceReader.getPolicyState(policyNftId) == CLOSED()) {
|
424
|
+
return false;
|
425
|
+
}
|
426
|
+
|
427
|
+
IPolicy.PolicyInfo memory info = instanceReader.getPolicyInfo(policyNftId);
|
428
|
+
|
429
|
+
if (info.productNftId.eqz()) { return false; } // not closeable: policy does not exist (or does not belong to this instance)
|
430
|
+
if (info.activatedAt.eqz()) { return false; } // not closeable: not yet activated
|
431
|
+
if (info.openClaimsCount > 0) { return false; } // not closeable: has open claims
|
432
|
+
|
433
|
+
// closeable: if sum of claims matches sum insured a policy may be closed prior to the expiry date
|
434
|
+
if (info.claimAmount == info.sumInsuredAmount) { return true; }
|
435
|
+
|
436
|
+
// not closeable: not yet expired
|
437
|
+
if (TimestampLib.blockTimestamp() < info.expiredAt) { return false; }
|
438
|
+
|
439
|
+
// all conditions to close the policy are met
|
440
|
+
return true;
|
441
|
+
}
|
442
|
+
|
443
|
+
/// @dev shared functionality for expire() and policyExpire().
|
444
|
+
function _expire(
|
359
445
|
IInstance instance,
|
360
|
-
NftId
|
361
|
-
IPolicy.PolicyInfo memory
|
446
|
+
NftId policyNftId,
|
447
|
+
IPolicy.PolicyInfo memory policyInfo,
|
448
|
+
Timestamp expireAt
|
362
449
|
)
|
363
450
|
internal
|
364
|
-
|
365
|
-
returns (
|
366
|
-
IPolicy.Premium memory premium
|
367
|
-
)
|
451
|
+
returns (Timestamp expiredAt)
|
368
452
|
{
|
369
|
-
|
370
|
-
|
453
|
+
// checks
|
454
|
+
// check policy is active
|
455
|
+
StateId policyState = instance.getInstanceReader().getPolicyState(policyNftId);
|
456
|
+
if (!_policyHasBeenActivated(policyState, policyInfo)) {
|
457
|
+
revert ErrorPolicyServicePolicyNotActive(policyNftId, policyState);
|
458
|
+
}
|
371
459
|
|
372
|
-
//
|
373
|
-
|
374
|
-
productNftId,
|
375
|
-
applicationInfo.riskId,
|
376
|
-
applicationInfo.sumInsuredAmount,
|
377
|
-
applicationInfo.lifetime,
|
378
|
-
applicationInfo.applicationData,
|
379
|
-
applicationInfo.bundleNftId,
|
380
|
-
applicationInfo.referralId);
|
460
|
+
// set return value to provided timestamp
|
461
|
+
expiredAt = expireAt;
|
381
462
|
|
382
|
-
//
|
383
|
-
{
|
384
|
-
|
385
|
-
address policyHolder = getRegistry().ownerOf(applicationNftId);
|
386
|
-
|
387
|
-
_checkPremiumBalanceAndAllowance(
|
388
|
-
tokenHandler.getToken(),
|
389
|
-
address(tokenHandler),
|
390
|
-
policyHolder,
|
391
|
-
AmountLib.toAmount(premium.premiumAmount));
|
463
|
+
// update expiredAt to current block timestamp if not set
|
464
|
+
if (expiredAt.eqz()) {
|
465
|
+
expiredAt = TimestampLib.blockTimestamp();
|
392
466
|
}
|
393
467
|
|
394
|
-
//
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
468
|
+
// check expiredAt represents a valid expiry time
|
469
|
+
if (expiredAt >= policyInfo.expiredAt) {
|
470
|
+
revert ErrorPolicyServicePolicyExpirationTooLate(policyNftId, policyInfo.expiredAt, expireAt);
|
471
|
+
}
|
472
|
+
|
473
|
+
if (expiredAt < TimestampLib.blockTimestamp()) {
|
474
|
+
revert ErrorPolicyServicePolicyExpirationTooEarly(policyNftId, TimestampLib.blockTimestamp(), expireAt);
|
475
|
+
}
|
476
|
+
|
477
|
+
// effects
|
478
|
+
// update policyInfo with new expiredAt timestamp
|
479
|
+
Timestamp originalExpiredAt = policyInfo.expiredAt;
|
480
|
+
policyInfo.expiredAt = expiredAt;
|
481
|
+
instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
482
|
+
|
483
|
+
emit LogPolicyServicePolicyExpirationUpdated(policyNftId, originalExpiredAt, expiredAt);
|
484
|
+
|
485
|
+
// interactions
|
486
|
+
// callback to policy holder if applicable
|
487
|
+
_policyHolderPolicyExpired(policyNftId, expiredAt);
|
402
488
|
}
|
403
489
|
|
404
490
|
|
@@ -412,10 +498,16 @@ contract PolicyService is
|
|
412
498
|
view
|
413
499
|
returns (IPolicy.PolicyInfo memory)
|
414
500
|
{
|
415
|
-
if
|
501
|
+
// fail if policy has already been activated and activateAt is different
|
502
|
+
if(! policyInfo.activatedAt.eqz() && activateAt != policyInfo.activatedAt) {
|
416
503
|
revert ErrorPolicyServicePolicyAlreadyActivated(policyNftId);
|
417
504
|
}
|
418
505
|
|
506
|
+
// ignore if policy has already been activated and activateAt is the same
|
507
|
+
if (policyInfo.activatedAt == activateAt) {
|
508
|
+
return policyInfo;
|
509
|
+
}
|
510
|
+
|
419
511
|
policyInfo.activatedAt = activateAt;
|
420
512
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
421
513
|
|
@@ -429,31 +521,28 @@ contract PolicyService is
|
|
429
521
|
NftId productNftId,
|
430
522
|
NftId bundleNftId,
|
431
523
|
ReferralId referralId,
|
432
|
-
IPolicy.
|
524
|
+
IPolicy.PremiumInfo memory premium
|
433
525
|
)
|
434
526
|
internal
|
435
527
|
virtual
|
436
528
|
{
|
437
|
-
(
|
438
|
-
NftId distributionNftId,
|
439
|
-
address distributionWallet,
|
440
|
-
address poolWallet,
|
441
|
-
address productWallet
|
442
|
-
) = _getDistributionNftAndWallets(
|
529
|
+
(NftId distributionNftId,,,) = _getDistributionNftAndWallets(
|
443
530
|
instanceReader,
|
444
531
|
productNftId);
|
445
532
|
|
446
533
|
// update product fees, distribution and pool fees
|
447
|
-
|
534
|
+
_accountingService.increaseProductFees(
|
448
535
|
instanceStore,
|
449
536
|
productNftId,
|
450
|
-
|
537
|
+
premium.productFeeVarAmount + premium.productFeeFixAmount);
|
451
538
|
|
452
539
|
// update distribution fees and distributor commission and pool fees
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
540
|
+
if (!distributionNftId.eqz()) { // only call distribution service if a distribution component is connected to the product
|
541
|
+
_distributionService.processSale(
|
542
|
+
distributionNftId,
|
543
|
+
referralId,
|
544
|
+
premium);
|
545
|
+
}
|
457
546
|
|
458
547
|
// update pool and bundle fees
|
459
548
|
_poolService.processSale(
|
@@ -463,16 +552,15 @@ contract PolicyService is
|
|
463
552
|
|
464
553
|
|
465
554
|
/// @dev transfer the premium to the wallets the premium is distributed to
|
466
|
-
function
|
555
|
+
function _transferPremiumAmounts(
|
467
556
|
InstanceReader instanceReader,
|
468
557
|
NftId policyNftId,
|
469
558
|
NftId productNftId,
|
470
|
-
IPolicy.
|
559
|
+
IPolicy.PremiumInfo memory premium
|
471
560
|
)
|
472
561
|
internal
|
473
562
|
virtual
|
474
563
|
{
|
475
|
-
TokenHandler tokenHandler = _getTokenHandler(instanceReader, productNftId);
|
476
564
|
address policyHolder = getRegistry().ownerOf(policyNftId);
|
477
565
|
|
478
566
|
(
|
@@ -484,14 +572,19 @@ contract PolicyService is
|
|
484
572
|
instanceReader,
|
485
573
|
productNftId);
|
486
574
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
575
|
+
// step 1: collect premium amount from policy holder
|
576
|
+
TokenHandler tokenHandler = instanceReader.getTokenHandler(productNftId);
|
577
|
+
tokenHandler.pullToken(policyHolder, premium.premiumAmount);
|
578
|
+
|
579
|
+
// step 2: push distribution fee to distribution wallet
|
580
|
+
if (premium.distributionFeeAndCommissionAmount.gtz()) {
|
581
|
+
tokenHandler.pushToken(distributionWallet, premium.distributionFeeAndCommissionAmount);
|
582
|
+
}
|
583
|
+
|
584
|
+
// step 3: push pool fee, bundle fee and pool premium to pool wallet
|
585
|
+
if (premium.poolPremiumAndFeeAmount.gtz()) {
|
586
|
+
tokenHandler.pushToken(poolWallet, premium.poolPremiumAndFeeAmount);
|
587
|
+
}
|
495
588
|
}
|
496
589
|
|
497
590
|
|
@@ -511,45 +604,106 @@ contract PolicyService is
|
|
511
604
|
}
|
512
605
|
|
513
606
|
|
607
|
+
// TODO cleanup
|
514
608
|
/// @dev checks the balance and allowance of the policy holder
|
515
|
-
function _checkPremiumBalanceAndAllowance(
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
609
|
+
// function _checkPremiumBalanceAndAllowance(
|
610
|
+
// IERC20Metadata token,
|
611
|
+
// address tokenHandlerAddress,
|
612
|
+
// address policyHolder,
|
613
|
+
// Amount premiumAmount
|
614
|
+
// )
|
615
|
+
// internal
|
616
|
+
// virtual
|
617
|
+
// view
|
618
|
+
// {
|
619
|
+
// uint256 premium = premiumAmount.toInt();
|
620
|
+
// uint256 balance = token.balanceOf(policyHolder);
|
621
|
+
// uint256 allowance = token.allowance(policyHolder, tokenHandlerAddress);
|
622
|
+
|
623
|
+
// if (balance < premium) {
|
624
|
+
// revert ErrorPolicyServiceBalanceInsufficient(policyHolder, premium, balance);
|
625
|
+
// }
|
626
|
+
|
627
|
+
// if (allowance < premium) {
|
628
|
+
// revert ErrorPolicyServiceAllowanceInsufficient(policyHolder, tokenHandlerAddress, premium, allowance);
|
629
|
+
// }
|
630
|
+
// }
|
631
|
+
|
632
|
+
|
633
|
+
function _policyHolderPolicyActivated(
|
634
|
+
NftId policyNftId,
|
635
|
+
Timestamp activateAt
|
520
636
|
)
|
521
637
|
internal
|
522
638
|
virtual
|
523
|
-
view
|
524
639
|
{
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
if (balance < premium) {
|
530
|
-
revert ErrorPolicyServiceBalanceInsufficient(policyHolder, premium, balance);
|
640
|
+
// immediately return if policy is not activated
|
641
|
+
if (activateAt.eqz()) {
|
642
|
+
return;
|
531
643
|
}
|
532
644
|
|
533
|
-
|
534
|
-
|
645
|
+
// get policy holder address
|
646
|
+
IPolicyHolder policyHolder = _getPolicyHolder(policyNftId);
|
647
|
+
|
648
|
+
// execute callback if policy holder implements IPolicyHolder
|
649
|
+
if (address(policyHolder) != address(0)) {
|
650
|
+
policyHolder.policyActivated(policyNftId, activateAt);
|
535
651
|
}
|
536
652
|
}
|
537
653
|
|
538
654
|
|
539
|
-
function
|
540
|
-
|
541
|
-
|
655
|
+
function _policyHolderPolicyExpired(
|
656
|
+
NftId policyNftId,
|
657
|
+
Timestamp expiredAt
|
542
658
|
)
|
543
|
-
internal
|
659
|
+
internal
|
544
660
|
virtual
|
661
|
+
{
|
662
|
+
// immediately return if policy is not activated
|
663
|
+
if (expiredAt.eqz()) {
|
664
|
+
return;
|
665
|
+
}
|
666
|
+
|
667
|
+
// get policy holder address
|
668
|
+
IPolicyHolder policyHolder = _getPolicyHolder(policyNftId);
|
669
|
+
|
670
|
+
// execute callback if policy holder implements IPolicyHolder
|
671
|
+
if (address(policyHolder) != address(0)) {
|
672
|
+
policyHolder.policyExpired(policyNftId, expiredAt);
|
673
|
+
}
|
674
|
+
}
|
675
|
+
|
676
|
+
|
677
|
+
function _getPolicyHolder(NftId policyNftId)
|
678
|
+
internal
|
545
679
|
view
|
546
|
-
returns (
|
547
|
-
TokenHandler tokenHandler
|
548
|
-
)
|
680
|
+
returns (IPolicyHolder policyHolder)
|
549
681
|
{
|
550
|
-
|
682
|
+
address policyHolderAddress = getRegistry().ownerOf(policyNftId);
|
683
|
+
policyHolder = IPolicyHolder(policyHolderAddress);
|
684
|
+
|
685
|
+
if (!ContractLib.isPolicyHolder(policyHolderAddress)) {
|
686
|
+
policyHolder = IPolicyHolder(address(0));
|
687
|
+
}
|
551
688
|
}
|
552
689
|
|
690
|
+
|
691
|
+
// TODO cleanup
|
692
|
+
// function _getTokenHandler(
|
693
|
+
// InstanceReader instanceReader,
|
694
|
+
// NftId productNftId
|
695
|
+
// )
|
696
|
+
// internal
|
697
|
+
// virtual
|
698
|
+
// view
|
699
|
+
// returns (
|
700
|
+
// TokenHandler tokenHandler
|
701
|
+
// )
|
702
|
+
// {
|
703
|
+
// tokenHandler = instanceReader.getTokenHandler(productNftId).tokenHandler;
|
704
|
+
// }
|
705
|
+
|
706
|
+
|
553
707
|
function _getDistributionNftAndWallets(
|
554
708
|
InstanceReader instanceReader,
|
555
709
|
NftId productNftId
|
@@ -564,17 +718,45 @@ contract PolicyService is
|
|
564
718
|
)
|
565
719
|
{
|
566
720
|
IComponents.ProductInfo memory productInfo = instanceReader.getProductInfo(productNftId);
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
721
|
+
productWallet = instanceReader.getComponentInfo(productNftId).tokenHandler.getWallet();
|
722
|
+
poolWallet = instanceReader.getComponentInfo(productInfo.poolNftId).tokenHandler.getWallet();
|
723
|
+
|
724
|
+
if (productInfo.hasDistribution) {
|
725
|
+
distributionNftId = productInfo.distributionNftId;
|
726
|
+
distributionWallet = instanceReader.getComponentInfo(distributionNftId).tokenHandler.getWallet();
|
727
|
+
}
|
571
728
|
}
|
572
729
|
|
573
730
|
|
574
|
-
function
|
575
|
-
|
576
|
-
|
577
|
-
|
731
|
+
function _getAndVerifyCallerForPolicy(NftId policyNftId)
|
732
|
+
internal
|
733
|
+
virtual
|
734
|
+
view
|
735
|
+
returns (
|
736
|
+
IInstance instance,
|
737
|
+
NftId productNftId,
|
738
|
+
IPolicy.PolicyInfo memory policyInfo
|
739
|
+
)
|
740
|
+
{
|
741
|
+
(
|
742
|
+
IRegistry.ObjectInfo memory productInfo,
|
743
|
+
address instanceAddress
|
744
|
+
) = ContractLib.getAndVerifyComponent(
|
745
|
+
getRegistry(),
|
746
|
+
msg.sender, // caller contract
|
747
|
+
PRODUCT(), // caller must be product
|
748
|
+
true); // only active caller
|
749
|
+
|
750
|
+
productNftId = productInfo.nftId;
|
751
|
+
instance = IInstance(instanceAddress);
|
752
|
+
policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
753
|
+
|
754
|
+
if (policyInfo.productNftId != productNftId) {
|
755
|
+
revert ErrorPolicyServicePolicyProductMismatch(
|
756
|
+
policyNftId,
|
757
|
+
productNftId,
|
758
|
+
policyInfo.productNftId);
|
759
|
+
}
|
578
760
|
}
|
579
761
|
|
580
762
|
|