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