@etherisc/gif-next 0.0.2-952752e-374 → 0.0.2-957bd35-589
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 -312
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +1 -1
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +106 -38
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +111 -45
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +1 -1
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +58 -6
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +690 -296
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.dbg.json +4 -0
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.json +2008 -0
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +8 -39
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +438 -35
- 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 +529 -221
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +191 -21
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +256 -16
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +426 -27
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +66 -154
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +427 -53
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +21 -98
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +512 -204
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +167 -77
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +20 -97
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +358 -82
- 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 +109 -110
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +401 -59
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +145 -142
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +426 -52
- 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 +128 -178
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +426 -52
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +39 -73
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +130 -148
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +401 -59
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +360 -193
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +426 -52
- package/artifacts/contracts/instance/BaseStore.sol/BaseStore.dbg.json +4 -0
- package/artifacts/contracts/{shared/IKeyValueStore.sol/IKeyValueStore.json → instance/BaseStore.sol/BaseStore.json} +51 -229
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +2 -2
- package/artifacts/contracts/instance/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 +482 -28
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +355 -12
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +520 -85
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1037 -437
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +369 -71
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +674 -487
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +387 -64
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +100 -52
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +1328 -2007
- package/artifacts/contracts/instance/ProductStore.sol/ProductStore.dbg.json +4 -0
- package/artifacts/contracts/instance/ProductStore.sol/ProductStore.json +3427 -0
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +1 -1
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +101 -88
- 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 +2 -2
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.json +20 -20
- 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 +33 -45
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +425 -54
- 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 +19 -31
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +29 -0
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +19 -31
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +87 -42
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +116 -50
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +59 -79
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +401 -59
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +280 -209
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +134 -68
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +174 -87
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +29 -41
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +306 -166
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.json +29 -41
- 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 +547 -340
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +162 -68
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +273 -50
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +123 -41
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +46 -58
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +426 -52
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +137 -139
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +128 -82
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +208 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +45 -23
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +133 -65
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +50 -0
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +40 -52
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +1 -1
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.json +231 -19
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +245 -161
- 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 +146 -80
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +116 -114
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +115 -65
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/Product.sol/Product.json +40 -52
- package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +1 -1
- package/artifacts/contracts/product/RiskService.sol/RiskService.json +279 -43
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +111 -41
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +52 -22
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +29 -0
- package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +90 -60
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +824 -430
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1137 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +47 -18
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +96 -38
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +933 -457
- 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 +202 -126
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +459 -26
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +119 -59
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.json +19 -31
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +206 -252
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +130 -72
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +130 -39
- 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 +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.json +2 -2
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.json +19 -31
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +111 -157
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +19 -31
- 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 +19 -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 +29 -0
- 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 +19 -31
- 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 +19 -0
- 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 +29 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +62 -161
- 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 +1453 -153
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +187 -107
- 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 +1565 -239
- 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 +146 -67
- 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 +229 -157
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +99 -45
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +1633 -819
- 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 +159 -87
- 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 +10 -10
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +64 -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 +93 -37
- 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 +9 -4
- 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 +60 -36
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.json +56 -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 +81 -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 +15 -3
- package/contracts/accounting/IAccountingService.sol +4 -2
- package/contracts/authorization/AccessAdmin.sol +364 -344
- package/contracts/authorization/AccessAdminLib.sol +678 -0
- package/contracts/authorization/AccessManagerCloneable.sol +23 -32
- package/contracts/authorization/Authorization.sol +161 -260
- package/contracts/authorization/IAccess.sol +29 -12
- package/contracts/authorization/IAccessAdmin.sol +85 -83
- package/contracts/authorization/IAuthorization.sol +9 -43
- package/contracts/authorization/IServiceAuthorization.sol +55 -17
- package/contracts/authorization/ServiceAuthorization.sol +228 -34
- package/contracts/distribution/BasicDistribution.sol +14 -13
- package/contracts/distribution/BasicDistributionAuthorization.sol +29 -9
- package/contracts/distribution/Distribution.sol +22 -64
- package/contracts/distribution/DistributionService.sol +166 -75
- 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 +7 -12
- 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 +94 -27
- package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +1 -1
- package/contracts/instance/BaseStore.sol +93 -0
- package/contracts/instance/IBaseStore.sol +37 -0
- package/contracts/instance/IInstance.sol +103 -13
- package/contracts/instance/IInstanceService.sol +54 -7
- package/contracts/instance/Instance.sol +177 -61
- package/contracts/instance/InstanceAdmin.sol +199 -218
- package/contracts/instance/InstanceAuthorizationV3.sol +120 -70
- package/contracts/instance/InstanceReader.sol +392 -382
- package/contracts/instance/InstanceService.sol +283 -173
- package/contracts/instance/InstanceStore.sol +153 -128
- package/contracts/instance/ProductStore.sol +290 -0
- package/contracts/instance/RiskSet.sol +10 -2
- package/contracts/instance/TargetNames.sol +10 -0
- package/contracts/instance/base/BalanceStore.sol +4 -6
- package/contracts/instance/base/ObjectLifecycle.sol +2 -6
- package/contracts/instance/module/IBundle.sol +6 -5
- package/contracts/instance/module/IComponents.sol +15 -6
- package/contracts/instance/module/IDistribution.sol +21 -8
- package/contracts/instance/module/IPolicy.sol +28 -8
- package/contracts/instance/module/IRisk.sol +2 -0
- package/contracts/oracle/BasicOracle.sol +3 -6
- package/contracts/oracle/BasicOracleAuthorization.sol +15 -8
- package/contracts/oracle/IOracle.sol +9 -4
- package/contracts/oracle/Oracle.sol +4 -8
- package/contracts/oracle/OracleService.sol +8 -8
- package/contracts/pool/BasicPool.sol +4 -18
- package/contracts/pool/BasicPoolAuthorization.sol +29 -16
- package/contracts/pool/BundleService.sol +57 -96
- package/contracts/pool/IBundleService.sol +27 -32
- package/contracts/pool/IPoolService.sol +57 -40
- package/contracts/pool/Pool.sol +15 -29
- package/contracts/pool/PoolLib.sol +341 -0
- package/contracts/pool/PoolService.sol +189 -190
- package/contracts/product/ApplicationService.sol +85 -17
- package/contracts/product/BasicProduct.sol +2 -5
- package/contracts/product/BasicProductAuthorization.sol +31 -9
- package/contracts/product/ClaimService.sol +112 -194
- package/contracts/product/IApplicationService.sol +24 -2
- package/contracts/product/IClaimService.sol +6 -6
- package/contracts/product/IPolicyService.sol +20 -8
- package/contracts/product/IPricingService.sol +1 -0
- package/contracts/product/IRiskService.sol +25 -10
- package/contracts/product/PolicyService.sol +110 -201
- package/contracts/product/PolicyServiceLib.sol +139 -0
- package/contracts/product/PricingService.sol +33 -31
- package/contracts/product/Product.sol +61 -33
- package/contracts/product/RiskService.sol +63 -25
- package/contracts/registry/IRegistry.sol +17 -9
- package/contracts/registry/IRelease.sol +6 -3
- package/contracts/registry/Registry.sol +19 -9
- package/contracts/registry/RegistryAdmin.sol +85 -256
- package/contracts/registry/RegistryAuthorization.sol +337 -0
- package/contracts/registry/RegistryService.sol +1 -1
- package/contracts/registry/ReleaseAdmin.sol +70 -116
- package/contracts/registry/ReleaseRegistry.sol +57 -43
- package/contracts/registry/ServiceAuthorizationV3.sol +131 -31
- package/contracts/registry/TokenRegistry.sol +56 -52
- package/contracts/shared/Component.sol +19 -35
- package/contracts/shared/ComponentService.sol +281 -290
- package/contracts/shared/ContractLib.sol +137 -77
- package/contracts/shared/IComponent.sol +1 -4
- package/contracts/shared/IComponentService.sol +21 -26
- package/contracts/shared/INftOwnable.sol +2 -0
- package/contracts/shared/IRegisterable.sol +0 -1
- package/contracts/shared/InitializableERC165.sol +9 -1
- package/contracts/shared/InstanceLinkedComponent.sol +8 -13
- package/contracts/shared/NftOwnable.sol +4 -2
- package/contracts/shared/PolicyHolder.sol +3 -2
- package/contracts/shared/Registerable.sol +1 -4
- package/contracts/shared/Service.sol +6 -4
- package/contracts/shared/TokenHandler.sol +44 -91
- package/contracts/staking/IStaking.sol +265 -72
- package/contracts/staking/IStakingService.sol +45 -75
- package/contracts/staking/ITargetLimitHandler.sol +17 -0
- package/contracts/staking/Staking.sol +475 -204
- 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 -180
- 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 +17 -22
- 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 +69 -52
- package/contracts/type/RiskId.sol +4 -3
- package/contracts/type/RoleId.sol +60 -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 -2
- package/contracts/type/UFixed.sol +28 -10
- package/contracts/type/Version.sol +39 -0
- 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/AccessAdmin.sol/IAccessManagedChecker.json +0 -24
- 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 -485
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +0 -4
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +0 -4
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +0 -538
- 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/contracts/instance/module/IAccess.sol +0 -46
- package/contracts/shared/ComponentVerifyingService.sol +0 -128
- package/contracts/shared/IKeyValueStore.sol +0 -54
- package/contracts/shared/KeyValueStore.sol +0 -131
- package/contracts/staking/StakingLifecycle.sol +0 -23
@@ -5,7 +5,6 @@ import {IService} from "../shared/IService.sol";
|
|
5
5
|
|
6
6
|
import {Amount} from "../type/Amount.sol";
|
7
7
|
import {IInstance} from "../instance/IInstance.sol";
|
8
|
-
import {InstanceReader} from "../instance/InstanceReader.sol";
|
9
8
|
import {NftId} from "../type/NftId.sol";
|
10
9
|
import {StateId} from "../type/StateId.sol";
|
11
10
|
import {Timestamp} from "../type/Timestamp.sol";
|
@@ -16,17 +15,20 @@ interface IPolicyService is IService {
|
|
16
15
|
event LogPolicyServicePolicyDeclined(NftId policyNftId);
|
17
16
|
event LogPolicyServicePolicyPremiumCollected(NftId policyNftId, Amount premiumAmount);
|
18
17
|
event LogPolicyServicePolicyActivated(NftId policyNftId, Timestamp activatedAt);
|
19
|
-
event
|
18
|
+
event LogPolicyServicePolicyActivatedUpdated(NftId policyNftId, Timestamp activatedAt);
|
19
|
+
event LogPolicyServicePolicyExpirationUpdated(NftId policyNftId, Timestamp expiredAt);
|
20
20
|
event LogPolicyServicePolicyClosed(NftId policyNftId);
|
21
21
|
|
22
|
+
error LogPolicyServiceMaxPremiumAmountExceeded(NftId policyNftId, Amount maxPremiumAmount, Amount premiumAmount);
|
22
23
|
error ErrorPolicyServicePolicyProductMismatch(NftId applicationNftId, NftId expectedProductNftId, NftId actualProductNftId);
|
23
24
|
error ErrorPolicyServicePolicyStateNotApplied(NftId applicationNftId);
|
24
25
|
error ErrorPolicyServicePolicyStateNotCollateralized(NftId applicationNftId);
|
25
26
|
error ErrorPolicyServicePolicyAlreadyActivated(NftId policyNftId);
|
26
27
|
|
27
|
-
error
|
28
|
-
error
|
29
|
-
|
28
|
+
error ErrorPolicyServicePolicyNotActivated(NftId policyNftId);
|
29
|
+
error ErrorPolicyServicePolicyActivationTooEarly(NftId policyNftId, Timestamp lowerLimit, Timestamp activatedAt);
|
30
|
+
error ErrorPolicyServicePolicyActivationTooLate(NftId policyNftId, Timestamp upperLimit, Timestamp activatedAt);
|
31
|
+
|
30
32
|
error ErrorPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
31
33
|
error ErrorPolicyServicePremiumAlreadyPaid(NftId policyNftId);
|
32
34
|
|
@@ -43,14 +45,21 @@ interface IPolicyService is IService {
|
|
43
45
|
error ErrorPolicyServiceTransferredPremiumMismatch(NftId policyNftId, Amount expectedPremiumAmount, Amount transferredPremiumAmount);
|
44
46
|
|
45
47
|
/// @dev creates the policy from {applicationNftId}.
|
48
|
+
/// @param applicationNftId the application NftId
|
49
|
+
/// @param activateAt the timestamp when the policy should be activated
|
50
|
+
/// @param maxPremiumAmount the maximum premium amount that the policy holder is willing to pay
|
51
|
+
/// During policy creation, the effective premium amount is calculated based on the provided parameters. If this
|
52
|
+
/// amount is higher than the maxPremiumAmount, the function will revert.
|
46
53
|
/// After successful completion of the function the policy can be referenced using the application NftId.
|
47
54
|
/// Locks the sum insured amount in the pool, but does not transfer tokens. Call collectPremium to transfer tokens.
|
48
55
|
/// Sets the policy state to collateralized.
|
49
56
|
/// Optionally activates the policy if activateAt is a non-zero timestamp.
|
50
57
|
/// only the related product may create a policy from an application
|
58
|
+
/// @return premiumAmount the effective premium amount
|
51
59
|
function createPolicy(
|
52
60
|
NftId applicationNftId,
|
53
|
-
Timestamp activateAt
|
61
|
+
Timestamp activateAt,
|
62
|
+
Amount maxPremiumAmount
|
54
63
|
)
|
55
64
|
external
|
56
65
|
returns (Amount premiumAmount);
|
@@ -67,6 +76,11 @@ interface IPolicyService is IService {
|
|
67
76
|
/// to activate a policy it needs to be in underwritten state
|
68
77
|
function activate(NftId policyNftId, Timestamp activateAt) external;
|
69
78
|
|
79
|
+
/// @dev adjusts the activation date of the specified policy and sets the new activation date in the policy metadata
|
80
|
+
/// to adjust the activation date of a policy it needs to have an activation date set.
|
81
|
+
/// the new activation date must not be before the current block timestamp or after the expiry date
|
82
|
+
function adjustActivation(NftId policyNftId, Timestamp newActivateAt) external;
|
83
|
+
|
70
84
|
/// @dev Expires the specified policy and sets the expiry date in the policy metadata.
|
71
85
|
/// Function consumers are products.
|
72
86
|
/// If expiry date is set to 0, then the earliest possible expiry date (current blocktime) is set
|
@@ -85,6 +99,4 @@ interface IPolicyService is IService {
|
|
85
99
|
/// Function consumers is claim service.
|
86
100
|
function expirePolicy(IInstance instance, NftId policyNftId, Timestamp expireAt) external returns (Timestamp expiredAt);
|
87
101
|
|
88
|
-
/// @dev Returns true iff policy is closeable
|
89
|
-
function policyIsCloseable(InstanceReader instanceReader, NftId policyNftId) external view returns (bool isCloseable);
|
90
102
|
}
|
@@ -14,6 +14,7 @@ interface IPricingService is IService
|
|
14
14
|
{
|
15
15
|
|
16
16
|
error ErrorPricingServiceTargetWalletAmountsMismatch();
|
17
|
+
error ErrorPricingServiceRiskProductMismatch(RiskId riskId, NftId riskProductNftId, NftId productNftId);
|
17
18
|
error ErrorPricingServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
|
18
19
|
error ErrorPricingServiceFeeCalculationMismatch(
|
19
20
|
Amount distributionFeeFixAmount,
|
@@ -1,23 +1,32 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {IRisk} from "../instance/module/IRisk.sol";
|
5
4
|
import {IService} from "../shared/IService.sol";
|
6
5
|
|
7
6
|
import {NftId} from "../type/NftId.sol";
|
8
|
-
import {ReferralId} from "../type/Referral.sol";
|
9
7
|
import {RiskId} from "../type/RiskId.sol";
|
10
8
|
import {StateId} from "../type/StateId.sol";
|
11
|
-
import {Timestamp} from "../type/Timestamp.sol";
|
12
|
-
import {UFixed} from "../type/UFixed.sol";
|
13
|
-
import {Fee} from "../type/Fee.sol";
|
14
9
|
|
15
10
|
interface IRiskService is IService {
|
16
11
|
|
12
|
+
event LogRiskServiceRiskCreated(NftId productNftId, RiskId riskId);
|
13
|
+
event LogRiskServiceRiskUpdated(NftId productNftId, RiskId riskId);
|
14
|
+
event LogRiskServiceRiskLocked(NftId productNftId, RiskId riskId);
|
15
|
+
event LogRiskServiceRiskUnlocked(NftId productNftId, RiskId riskId);
|
16
|
+
event LogRiskServiceRiskClosed(NftId productNftId, RiskId riskId);
|
17
|
+
|
18
|
+
error ErrorRiskServiceRiskProductMismatch(RiskId riskId, NftId riskProductNftId, NftId productNftId);
|
19
|
+
error ErrorRiskServiceRiskNotActive(NftId productNftId, RiskId riskId);
|
20
|
+
error ErrorRiskServiceUnknownRisk(NftId productNftId, RiskId riskId);
|
21
|
+
error ErrorRiskServiceRiskNotLocked(NftId productNftId, RiskId riskId);
|
22
|
+
|
23
|
+
/// @dev Create a new risk with the given id and provided data.
|
24
|
+
/// The key of the risk derived from the risk id in comination with the product NftId.
|
25
|
+
/// Risk data is stored in the instance store.
|
17
26
|
function createRisk(
|
18
|
-
|
27
|
+
bytes32 id,
|
19
28
|
bytes memory data
|
20
|
-
) external;
|
29
|
+
) external returns (RiskId riskId);
|
21
30
|
|
22
31
|
|
23
32
|
function updateRisk(
|
@@ -25,9 +34,15 @@ interface IRiskService is IService {
|
|
25
34
|
bytes memory data
|
26
35
|
) external;
|
27
36
|
|
28
|
-
|
29
|
-
|
37
|
+
/// @dev Locks/unlocks the risk with the given id.
|
38
|
+
/// No new policies can be underwritten for a locked risk.
|
39
|
+
function setRiskLocked(
|
30
40
|
RiskId riskId,
|
31
|
-
|
41
|
+
bool locked
|
42
|
+
) external;
|
43
|
+
|
44
|
+
/// @dev Close the risk with the given id.
|
45
|
+
function closeRisk(
|
46
|
+
RiskId riskId
|
32
47
|
) external;
|
33
48
|
}
|
@@ -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";
|
@@ -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
|
|