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