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