@etherisc/gif-next 0.0.2-bd7444a → 0.0.2-bdcb44f-543
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +436 -8
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +626 -31
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +1279 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{registry/IChainNft.sol/IChainNft.json → components/IComponent.sol/IComponent.json} +234 -239
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +829 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +1029 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +672 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +1319 -81
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +959 -91
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +2038 -508
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +509 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +2715 -456
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +984 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1355 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +1046 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +693 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +552 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +429 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +502 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +254 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
- package/artifacts/contracts/instance/{access/IAccess.sol/IAccess.json → module/IBundle.sol/IBundle.json} +2 -2
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.json +10 -0
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
- package/artifacts/contracts/instance/{policy → module}/IPolicy.sol/IPolicy.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
- package/artifacts/contracts/instance/{pool/IPoolModule.sol/IPool.json → module/IRisk.sol/IRisk.json} +2 -2
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
- package/artifacts/contracts/instance/{component/IComponent.sol/IComponent.json → module/ISetup.sol/ISetup.json} +2 -2
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.json +10 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +968 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +665 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1096 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +661 -0
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +754 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +637 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1553 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +793 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +556 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +633 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +409 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +858 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +519 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +347 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +384 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1000 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +689 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +727 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +649 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +777 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +649 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +239 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +519 -61
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +890 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +567 -75
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1177 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +670 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +498 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +73 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
- package/artifacts/contracts/{registry/Registry.sol/Registerable.json → shared/INftOwnable.sol/INftOwnable.json} +46 -74
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/{instance/product/IProductService.sol/IProductService.json → shared/IPolicyHolder.sol/IPolicyHolder.json} +68 -53
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
- package/artifacts/contracts/{instance/pool/PoolModule.sol/PoolModule.json → shared/IRegisterable.sol/IRegisterable.json} +106 -80
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/{registry/IRegistry.sol → shared/IRegistryLinked.sol}/IRegistryLinked.json +18 -19
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/shared/IService.sol/IService.json +269 -0
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +55 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +251 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +248 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +582 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +352 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +84 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/shared/Service.sol/Service.json +425 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +78 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +383 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
- package/artifacts/contracts/test/TestService.sol/TestService.json +521 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +376 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +104 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.json +376 -0
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +100 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +125 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +33 -0
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +100 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +97 -4
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +479 -0
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +49 -0
- package/contracts/components/Component.sol +198 -39
- package/contracts/components/Distribution.sol +293 -0
- package/contracts/components/IComponent.sol +68 -0
- package/contracts/components/IDistributionComponent.sol +79 -0
- package/contracts/components/IPoolComponent.sol +151 -0
- package/contracts/components/IProductComponent.sol +40 -0
- package/contracts/components/Pool.sol +366 -17
- package/contracts/components/Product.sol +256 -33
- package/contracts/instance/BundleManager.sol +125 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +87 -15
- package/contracts/instance/IInstanceService.sol +59 -0
- package/contracts/instance/Instance.sol +270 -43
- package/contracts/instance/InstanceAccessManager.sol +297 -0
- package/contracts/instance/InstanceReader.sol +293 -0
- package/contracts/instance/InstanceService.sol +490 -0
- package/contracts/instance/InstanceServiceManager.sol +54 -0
- package/contracts/instance/ObjectManager.sol +84 -0
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/base/IKeyValueStore.sol +49 -0
- package/contracts/instance/base/ILifecycle.sol +30 -0
- package/contracts/instance/base/KeyValueStore.sol +172 -0
- package/contracts/instance/base/Lifecycle.sol +100 -0
- package/contracts/instance/module/IAccess.sol +47 -0
- package/contracts/instance/module/IBundle.sol +21 -0
- package/contracts/instance/module/IDistribution.sol +41 -0
- package/contracts/instance/module/IPolicy.sol +72 -0
- package/contracts/instance/module/IRisk.sol +11 -0
- package/contracts/instance/module/ISetup.sol +46 -0
- package/contracts/instance/module/ITreasury.sol +23 -0
- package/contracts/instance/service/ApplicationService.sol +349 -0
- package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
- package/contracts/instance/service/BundleService.sol +299 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/ClaimService.sol +151 -0
- package/contracts/instance/service/ClaimServiceManager.sol +35 -0
- package/contracts/instance/service/DistributionService.sol +394 -0
- package/contracts/instance/service/DistributionServiceManager.sol +51 -0
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +55 -0
- package/contracts/instance/service/IClaimService.sol +61 -0
- package/contracts/instance/service/IDistributionService.sol +86 -0
- package/contracts/instance/service/IPolicyService.sol +70 -0
- package/contracts/instance/service/IPoolService.sol +20 -0
- package/contracts/instance/service/IProductService.sol +40 -0
- package/contracts/instance/service/PolicyService.sol +402 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +109 -0
- package/contracts/instance/service/PoolServiceManager.sol +51 -0
- package/contracts/instance/service/ProductService.sol +233 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +138 -109
- package/contracts/registry/IRegistry.sol +78 -49
- package/contracts/registry/IRegistryService.sol +67 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +398 -116
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +283 -0
- package/contracts/registry/RegistryServiceManager.sol +62 -0
- package/contracts/registry/ReleaseManager.sol +322 -0
- package/contracts/registry/TokenRegistry.sol +116 -0
- package/contracts/shared/ContractDeployerLib.sol +72 -0
- package/contracts/shared/ERC165.sol +27 -0
- package/contracts/shared/INftOwnable.sol +23 -0
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +15 -0
- package/contracts/shared/IRegistryLinked.sol +12 -0
- package/contracts/shared/IService.sol +18 -0
- package/contracts/shared/IVersionable.sol +53 -0
- package/contracts/shared/NftOwnable.sol +120 -0
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +169 -0
- package/contracts/shared/Registerable.sol +74 -0
- package/contracts/shared/RegistryLinked.sol +48 -0
- package/contracts/shared/Service.sol +58 -0
- package/contracts/shared/TokenHandler.sol +27 -0
- package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
- package/contracts/shared/Versionable.sol +59 -0
- package/contracts/test/TestFee.sol +25 -0
- package/contracts/test/TestRegisterable.sol +18 -0
- package/contracts/test/TestRoleId.sol +14 -0
- package/contracts/test/TestService.sol +25 -0
- package/contracts/test/TestToken.sol +26 -0
- package/contracts/test/TestVersion.sol +44 -0
- package/contracts/test/TestVersionable.sol +17 -0
- package/contracts/test/Usdc.sol +26 -0
- package/contracts/types/AddressSet.sol +58 -0
- package/contracts/types/Blocknumber.sol +76 -18
- package/contracts/types/ChainId.sol +18 -10
- package/contracts/types/ClaimId.sol +52 -0
- package/contracts/types/DistributorType.sol +55 -0
- package/contracts/types/Fee.sol +56 -0
- package/contracts/types/Key32.sol +50 -0
- package/contracts/types/NftId.sol +48 -11
- package/contracts/types/NftIdSet.sol +62 -0
- package/contracts/types/NumberId.sol +52 -0
- package/contracts/types/ObjectType.sol +156 -0
- package/contracts/types/PayoutId.sol +54 -0
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RiskId.sol +43 -0
- package/contracts/types/RoleId.sol +95 -0
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/StateId.sol +105 -0
- package/contracts/types/Timestamp.sol +90 -19
- package/contracts/types/UFixed.sol +193 -75
- package/contracts/types/Version.sol +107 -0
- package/package.json +21 -6
- package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +0 -4
- package/artifacts/contracts/components/Component.sol/InstanceLinked.json +0 -35
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.json +0 -179
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +0 -192
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +0 -4
- package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.json +0 -50
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +0 -10
- package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/access/Access.sol/AccessModule.json +0 -400
- package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +0 -35
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.json +0 -50
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.json +0 -336
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +0 -327
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +0 -147
- package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +0 -179
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +0 -245
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +0 -94
- package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.json +0 -24
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.json +0 -231
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.json +0 -231
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +0 -4
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.json +0 -149
- package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +0 -4
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +0 -75
- package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +0 -4
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +0 -4
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.json +0 -75
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +0 -4
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +0 -167
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.json +0 -24
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +0 -166
- package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +0 -4
- package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +0 -4
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +0 -4
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +0 -60
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +0 -440
- package/contracts/components/IPool.sol +0 -9
- package/contracts/components/IProduct.sol +0 -12
- package/contracts/experiment/errors/Require.sol +0 -33
- package/contracts/experiment/errors/Revert.sol +0 -39
- package/contracts/experiment/inheritance/A.sol +0 -56
- package/contracts/experiment/inheritance/B.sol +0 -23
- package/contracts/experiment/inheritance/C.sol +0 -28
- package/contracts/experiment/inheritance/IA.sol +0 -18
- package/contracts/experiment/inheritance/IB.sol +0 -9
- package/contracts/experiment/inheritance/IC.sol +0 -11
- package/contracts/experiment/types/TypeA.sol +0 -42
- package/contracts/experiment/types/TypeB.sol +0 -24
- package/contracts/instance/access/Access.sol +0 -218
- package/contracts/instance/access/IAccess.sol +0 -83
- package/contracts/instance/component/ComponentModule.sol +0 -248
- package/contracts/instance/component/IComponent.sol +0 -95
- package/contracts/instance/policy/IPolicy.sol +0 -66
- package/contracts/instance/policy/PolicyModule.sol +0 -107
- package/contracts/instance/pool/IPoolModule.sol +0 -41
- package/contracts/instance/pool/PoolModule.sol +0 -86
- package/contracts/instance/product/IProductService.sol +0 -46
- package/contracts/instance/product/ProductService.sol +0 -108
- package/contracts/registry/IChainNft.sol +0 -18
@@ -0,0 +1,86 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {NftId} from "../../types/NftId.sol";
|
5
|
+
import {Fee} from "../../types/Fee.sol";
|
6
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
7
|
+
import {IService} from "../../shared/IService.sol";
|
8
|
+
import {UFixed} from "../../types/UFixed.sol";
|
9
|
+
import {DistributorType} from "../../types/DistributorType.sol";
|
10
|
+
import {ReferralId} from "../../types/Referral.sol";
|
11
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
12
|
+
|
13
|
+
|
14
|
+
interface IDistributionService is IService {
|
15
|
+
error ErrorIDistributionServiceParentNftIdNotInstance(NftId nftId, NftId parentNftId);
|
16
|
+
error ErrorIDistributionServiceCallerNotDistributor(address caller);
|
17
|
+
error ErrorIDistributionServiceInvalidReferralId(ReferralId referralId);
|
18
|
+
error ErrorIDistributionServiceMaxReferralsExceeded(uint256 maxReferrals);
|
19
|
+
error ErrorIDistributionServiceDiscountTooLow(uint256 minDiscountPercentage, uint256 discountPercentage);
|
20
|
+
error ErrorIDistributionServiceDiscountTooHigh(uint256 maxDiscountPercentage, uint256 discountPercentage);
|
21
|
+
error ErrorIDistributionServiceExpiryTooLong(uint256 maxReferralLifetime, uint256 expiryAt);
|
22
|
+
error ErrorIDistributionServiceInvalidReferral(string code);
|
23
|
+
error ErrorIDistributionServiceExpirationInvalid(Timestamp expiryAt);
|
24
|
+
error ErrorIDistributionServiceCommissionTooHigh(uint256 commissionPercentage, uint256 maxCommissionPercentage);
|
25
|
+
error ErrorIDistributionServiceMinFeeTooHigh(uint256 minFee, uint256 limit);
|
26
|
+
error ErrorIDistributionServiceMaxDiscountTooHigh(uint256 maxDiscountPercentage, uint256 limit);
|
27
|
+
|
28
|
+
function setFees(
|
29
|
+
Fee memory minDistributionOwnerFee,
|
30
|
+
Fee memory distributionFee
|
31
|
+
) external;
|
32
|
+
|
33
|
+
function createDistributorType(
|
34
|
+
string memory name,
|
35
|
+
UFixed minDiscountPercentage,
|
36
|
+
UFixed maxDiscountPercentage,
|
37
|
+
UFixed commissionPercentage,
|
38
|
+
uint32 maxReferralCount,
|
39
|
+
uint32 maxReferralLifetime,
|
40
|
+
bool allowSelfReferrals,
|
41
|
+
bool allowRenewals,
|
42
|
+
bytes memory data
|
43
|
+
)
|
44
|
+
external
|
45
|
+
returns (DistributorType distributorType);
|
46
|
+
|
47
|
+
function createDistributor(
|
48
|
+
address distributor,
|
49
|
+
DistributorType distributorType,
|
50
|
+
bytes memory data
|
51
|
+
) external returns (NftId distributorNftId);
|
52
|
+
|
53
|
+
function updateDistributorType(
|
54
|
+
NftId distributorNftId,
|
55
|
+
DistributorType distributorType,
|
56
|
+
bytes memory data
|
57
|
+
) external;
|
58
|
+
|
59
|
+
function createReferral(
|
60
|
+
NftId distributorNftId,
|
61
|
+
string memory code,
|
62
|
+
UFixed discountPercentage,
|
63
|
+
uint32 maxReferrals,
|
64
|
+
Timestamp expiryAt,
|
65
|
+
bytes memory data
|
66
|
+
)
|
67
|
+
external
|
68
|
+
returns (ReferralId referralId);
|
69
|
+
|
70
|
+
/// @dev callback from product service when selling a policy for a specific referralId
|
71
|
+
function processSale(
|
72
|
+
ReferralId referralId,
|
73
|
+
uint256 premiumAmount
|
74
|
+
) external;
|
75
|
+
|
76
|
+
function calculateFeeAmount(
|
77
|
+
NftId distributionNftId,
|
78
|
+
ReferralId referralId,
|
79
|
+
IPolicy.Premium memory premium
|
80
|
+
) external view returns (IPolicy.Premium memory finalPremium);
|
81
|
+
|
82
|
+
function referralIsValid(
|
83
|
+
NftId distributorNftId,
|
84
|
+
ReferralId referralId
|
85
|
+
) external view returns (bool isValid);
|
86
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRisk} from "../module/IRisk.sol";
|
5
|
+
import {IService} from "../../shared/IService.sol";
|
6
|
+
|
7
|
+
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {ReferralId} from "../../types/Referral.sol";
|
9
|
+
import {RiskId} from "../../types/RiskId.sol";
|
10
|
+
import {Seconds} from "../../types/Seconds.sol";
|
11
|
+
import {StateId} from "../../types/StateId.sol";
|
12
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
13
|
+
import {UFixed} from "../../types/UFixed.sol";
|
14
|
+
import {Fee} from "../../types/Fee.sol";
|
15
|
+
|
16
|
+
interface IPolicyService is IService {
|
17
|
+
|
18
|
+
error ErrorIPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
19
|
+
error ErrorIPolicyServicePremiumAlreadyPaid(NftId policyNftId, uint256 premiumPaidAmount);
|
20
|
+
error ErrorIPolicyServicePolicyNotActivated(NftId policyNftId);
|
21
|
+
error ErrorIPolicyServicePolicyAlreadyClosed(NftId policyNftId);
|
22
|
+
error ErrorIPolicyServicePolicyNotActive(NftId policyNftId, StateId state);
|
23
|
+
error ErrorIPolicyServicePremiumNotFullyPaid(NftId policyNftId, uint256 premiumAmount, uint256 premiumPaidAmount);
|
24
|
+
error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
25
|
+
error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
26
|
+
|
27
|
+
/// @dev declines an application represented by {policyNftId}
|
28
|
+
/// an application can only be declined in applied state
|
29
|
+
/// only the related product may decline an application
|
30
|
+
function decline(NftId policyNftId) external;
|
31
|
+
|
32
|
+
/// @dev underwrites the policy represented by {policyNftId}
|
33
|
+
/// sets the policy state to underwritten
|
34
|
+
/// may set the policy state to activated and set the activation date
|
35
|
+
/// optionally collects premiums and activates the policy.
|
36
|
+
/// - premium payment is only attempted if requirePremiumPayment is set to true
|
37
|
+
/// - activation is only done if activateAt is a non-zero timestamp
|
38
|
+
/// an application can only be underwritten in applied state
|
39
|
+
/// only the related product may underwrite an application
|
40
|
+
function underwrite(
|
41
|
+
NftId policyNftId,
|
42
|
+
bool requirePremiumPayment,
|
43
|
+
Timestamp activateAt
|
44
|
+
) external;
|
45
|
+
|
46
|
+
/// @dev collects the premium token for the specified policy
|
47
|
+
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
48
|
+
|
49
|
+
/// @dev activates the specified policy and sets the activation date in the policy metadata
|
50
|
+
/// to activate a policy it needs to be in underwritten state
|
51
|
+
function activate(NftId policyNftId, Timestamp activateAt) external;
|
52
|
+
|
53
|
+
/// @dev expires the specified policy and sets the expiry date in the policy metadata
|
54
|
+
/// to expire a policy it must be in active state, policies may be expired even when the predefined expiry date is still in the future
|
55
|
+
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
56
|
+
/// this function can only be called by a product. the policy needs to match with the calling product
|
57
|
+
function expire(NftId policyNftId) external;
|
58
|
+
|
59
|
+
/// @dev closes the specified policy and sets the closed data in the policy metadata
|
60
|
+
/// a policy can only be closed when it has been expired. in addition, it must not have any open claims
|
61
|
+
/// this function can only be called by a product. the policy needs to match with the calling product
|
62
|
+
function close(NftId policyNftId) external;
|
63
|
+
|
64
|
+
// TODO move function to pool service
|
65
|
+
function calculateRequiredCollateral(
|
66
|
+
UFixed collateralizationLevel,
|
67
|
+
uint256 sumInsuredAmount
|
68
|
+
) external pure returns(uint256 collateralAmount);
|
69
|
+
|
70
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {NftId} from "../../types/NftId.sol";
|
5
|
+
import {Fee} from "../../types/Fee.sol";
|
6
|
+
import {StateId} from "../../types/StateId.sol";
|
7
|
+
import {IService} from "../../shared/IService.sol";
|
8
|
+
import {IBundle} from "../module/IBundle.sol";
|
9
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
10
|
+
|
11
|
+
interface IPoolService is IService {
|
12
|
+
|
13
|
+
function register(address poolAddress) external returns(NftId);
|
14
|
+
|
15
|
+
function setFees(
|
16
|
+
Fee memory poolFee,
|
17
|
+
Fee memory stakingFee,
|
18
|
+
Fee memory performanceFee
|
19
|
+
) external;
|
20
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRisk} from "../module/IRisk.sol";
|
5
|
+
import {IService} from "../../shared/IService.sol";
|
6
|
+
|
7
|
+
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {ReferralId} from "../../types/Referral.sol";
|
9
|
+
import {RiskId} from "../../types/RiskId.sol";
|
10
|
+
import {StateId} from "../../types/StateId.sol";
|
11
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
12
|
+
import {UFixed} from "../../types/UFixed.sol";
|
13
|
+
import {Fee} from "../../types/Fee.sol";
|
14
|
+
|
15
|
+
interface IProductService is IService {
|
16
|
+
|
17
|
+
function register(address productAddress) external returns(NftId);
|
18
|
+
|
19
|
+
function setFees(
|
20
|
+
Fee memory productFee,
|
21
|
+
Fee memory processingFee
|
22
|
+
) external;
|
23
|
+
|
24
|
+
function createRisk(
|
25
|
+
RiskId riskId,
|
26
|
+
bytes memory data
|
27
|
+
) external;
|
28
|
+
|
29
|
+
|
30
|
+
function updateRisk(
|
31
|
+
RiskId riskId,
|
32
|
+
bytes memory data
|
33
|
+
) external;
|
34
|
+
|
35
|
+
|
36
|
+
function updateRiskState(
|
37
|
+
RiskId riskId,
|
38
|
+
StateId newState
|
39
|
+
) external;
|
40
|
+
}
|
@@ -0,0 +1,402 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IProductComponent} from "../../components/IProductComponent.sol";
|
6
|
+
import {Product} from "../../components/Product.sol";
|
7
|
+
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
8
|
+
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
9
|
+
import {IInstance} from "../IInstance.sol";
|
10
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
11
|
+
import {IRisk} from "../module/IRisk.sol";
|
12
|
+
import {IBundle} from "../module/IBundle.sol";
|
13
|
+
import {IProductService} from "./IProductService.sol";
|
14
|
+
import {ITreasury} from "../module/ITreasury.sol";
|
15
|
+
import {ISetup} from "../module/ISetup.sol";
|
16
|
+
|
17
|
+
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
18
|
+
|
19
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
20
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
21
|
+
|
22
|
+
import {Seconds} from "../../types/Seconds.sol";
|
23
|
+
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
24
|
+
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
25
|
+
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
26
|
+
import {ObjectType, APPLICATION, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
|
27
|
+
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
|
28
|
+
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
29
|
+
import {Fee, FeeLib} from "../../types/Fee.sol";
|
30
|
+
import {ReferralId} from "../../types/Referral.sol";
|
31
|
+
import {RiskId} from "../../types/RiskId.sol";
|
32
|
+
import {StateId} from "../../types/StateId.sol";
|
33
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
34
|
+
//import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
|
35
|
+
|
36
|
+
import {IService} from "../../shared/IService.sol";
|
37
|
+
import {Service} from "../../shared/Service.sol";
|
38
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
39
|
+
import {IApplicationService} from "./IApplicationService.sol";
|
40
|
+
import {IPolicyService} from "./IPolicyService.sol";
|
41
|
+
import {InstanceReader} from "../InstanceReader.sol";
|
42
|
+
import {IPoolService} from "./IPoolService.sol";
|
43
|
+
import {IBundleService} from "./IBundleService.sol";
|
44
|
+
|
45
|
+
|
46
|
+
contract PolicyService is
|
47
|
+
ComponentService,
|
48
|
+
IPolicyService
|
49
|
+
{
|
50
|
+
using NftIdLib for NftId;
|
51
|
+
using TimestampLib for Timestamp;
|
52
|
+
|
53
|
+
IPoolService internal _poolService;
|
54
|
+
IBundleService internal _bundleService;
|
55
|
+
IApplicationService internal _applicationService;
|
56
|
+
|
57
|
+
event LogProductServiceSender(address sender);
|
58
|
+
|
59
|
+
function _initialize(
|
60
|
+
address owner,
|
61
|
+
bytes memory data
|
62
|
+
)
|
63
|
+
internal
|
64
|
+
virtual override
|
65
|
+
initializer
|
66
|
+
{
|
67
|
+
address registryAddress;
|
68
|
+
address initialOwner;
|
69
|
+
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
70
|
+
|
71
|
+
initializeService(registryAddress, owner);
|
72
|
+
|
73
|
+
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
|
74
|
+
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getMajorVersion()));
|
75
|
+
_applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), getMajorVersion()));
|
76
|
+
|
77
|
+
registerInterface(type(IPolicyService).interfaceId);
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
function getDomain() public pure override(IService, Service) returns(ObjectType) {
|
82
|
+
return POLICY();
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
|
87
|
+
IRegistry.ObjectInfo memory productInfo;
|
88
|
+
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
89
|
+
product = Product(productInfo.objectAddress);
|
90
|
+
}
|
91
|
+
|
92
|
+
function _getAndVerifyUnderwritingSetup(
|
93
|
+
IInstance instance,
|
94
|
+
InstanceReader instanceReader,
|
95
|
+
IPolicy.PolicyInfo memory policyInfo,
|
96
|
+
ISetup.ProductSetupInfo memory productSetupInfo
|
97
|
+
)
|
98
|
+
internal
|
99
|
+
view
|
100
|
+
returns (
|
101
|
+
NftId poolNftId,
|
102
|
+
NftId bundleNftId,
|
103
|
+
IBundle.BundleInfo memory bundleInfo,
|
104
|
+
uint256 collateralAmount
|
105
|
+
)
|
106
|
+
{
|
107
|
+
// check match between policy and bundle (via pool)
|
108
|
+
poolNftId = productSetupInfo.poolNftId;
|
109
|
+
bundleNftId = policyInfo.bundleNftId;
|
110
|
+
bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
111
|
+
require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
|
112
|
+
|
113
|
+
// calculate required collateral
|
114
|
+
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
115
|
+
|
116
|
+
// obtain remaining return values
|
117
|
+
// TODO required collateral amount should be calculated by pool service, not policy service
|
118
|
+
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
function decline(
|
123
|
+
NftId policyNftId
|
124
|
+
)
|
125
|
+
external
|
126
|
+
override
|
127
|
+
{
|
128
|
+
require(false, "ERROR:PRS-235:NOT_YET_IMPLEMENTED");
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
/// @dev underwites application which includes the locking of the required collateral from the pool.
|
133
|
+
function underwrite(
|
134
|
+
NftId applicationNftId, // = policyNftId
|
135
|
+
bool requirePremiumPayment,
|
136
|
+
Timestamp activateAt
|
137
|
+
)
|
138
|
+
external
|
139
|
+
virtual override
|
140
|
+
{
|
141
|
+
// check caller is registered product
|
142
|
+
IInstance instance;
|
143
|
+
InstanceReader instanceReader;
|
144
|
+
NftId productNftId;
|
145
|
+
{
|
146
|
+
IRegistry.ObjectInfo memory productInfo;
|
147
|
+
(productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
148
|
+
instanceReader = instance.getInstanceReader();
|
149
|
+
productNftId = productInfo.nftId;
|
150
|
+
}
|
151
|
+
|
152
|
+
// check policy matches with calling product
|
153
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(applicationNftId);
|
154
|
+
require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
155
|
+
|
156
|
+
// check policy is in state applied
|
157
|
+
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
158
|
+
|
159
|
+
(
|
160
|
+
NftId poolNftId,
|
161
|
+
NftId bundleNftId,
|
162
|
+
IBundle.BundleInfo memory bundleInfo,
|
163
|
+
uint256 collateralAmount
|
164
|
+
) = _getAndVerifyUnderwritingSetup(
|
165
|
+
instance,
|
166
|
+
instanceReader,
|
167
|
+
policyInfo,
|
168
|
+
instanceReader.getProductSetupInfo(productNftId)
|
169
|
+
);
|
170
|
+
|
171
|
+
StateId newPolicyState = UNDERWRITTEN();
|
172
|
+
|
173
|
+
// optional activation of policy
|
174
|
+
if(activateAt > zeroTimestamp()) {
|
175
|
+
newPolicyState = ACTIVE();
|
176
|
+
policyInfo.activatedAt = activateAt;
|
177
|
+
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
178
|
+
}
|
179
|
+
|
180
|
+
// lock bundle collateral
|
181
|
+
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
182
|
+
|
183
|
+
// optional collection of premium
|
184
|
+
if(requirePremiumPayment) {
|
185
|
+
netPremiumAmount = _processPremiumByTreasury(
|
186
|
+
instance,
|
187
|
+
productNftId,
|
188
|
+
applicationNftId,
|
189
|
+
policyInfo.premiumAmount);
|
190
|
+
|
191
|
+
policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
|
192
|
+
}
|
193
|
+
|
194
|
+
// lock collateral and update bundle book keeping
|
195
|
+
// TODO introduct indirection via pool service?
|
196
|
+
// well pool would only need to be involved when a part of the collateral
|
197
|
+
// is provided by a "re insurance policy" of the pool
|
198
|
+
// but then again the policiy would likely best be attached to the bundle. really? why?
|
199
|
+
// retention level: fraction of sum insured that product will cover from pool funds directly
|
200
|
+
// eg retention level 30%, payouts up to 30% of the sum insured will be made from the product's pool directly
|
201
|
+
// for the remaining 70% the pool owns a policy that will cover claims that exceed the 30% of the sum insured
|
202
|
+
// open points:
|
203
|
+
// - do we need a link of a bundle to this policy or is it enough to know that the pool has an active policy?
|
204
|
+
// - when to buy such policies and for which amount? manual trigger or link to bundle creation and/or funding?
|
205
|
+
bundleInfo = _bundleService.lockCollateral(
|
206
|
+
instance,
|
207
|
+
applicationNftId,
|
208
|
+
bundleNftId,
|
209
|
+
collateralAmount,
|
210
|
+
netPremiumAmount);
|
211
|
+
|
212
|
+
instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
|
213
|
+
|
214
|
+
// also verify/confirm application by pool if necessary
|
215
|
+
if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
|
216
|
+
IPoolComponent pool = IPoolComponent(
|
217
|
+
getRegistry().getObjectInfo(poolNftId).objectAddress);
|
218
|
+
|
219
|
+
pool.verifyApplication(
|
220
|
+
applicationNftId,
|
221
|
+
policyInfo.applicationData,
|
222
|
+
bundleNftId,
|
223
|
+
bundleInfo.filter,
|
224
|
+
collateralAmount);
|
225
|
+
}
|
226
|
+
|
227
|
+
// TODO: add logging
|
228
|
+
}
|
229
|
+
|
230
|
+
|
231
|
+
function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
|
232
|
+
UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
|
233
|
+
UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
|
234
|
+
return collateralUFixed.toInt();
|
235
|
+
}
|
236
|
+
|
237
|
+
function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
|
238
|
+
// check caller is registered product
|
239
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
240
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
241
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
242
|
+
|
243
|
+
if (policyInfo.premiumPaidAmount == policyInfo.premiumAmount) {
|
244
|
+
revert ErrorIPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
|
245
|
+
}
|
246
|
+
|
247
|
+
uint256 unpaidPremiumAmount = policyInfo.premiumAmount - policyInfo.premiumPaidAmount;
|
248
|
+
|
249
|
+
uint256 netPremiumAmount = _processPremiumByTreasury(
|
250
|
+
instance,
|
251
|
+
productInfo.nftId,
|
252
|
+
policyNftId,
|
253
|
+
unpaidPremiumAmount);
|
254
|
+
|
255
|
+
policyInfo.premiumPaidAmount += unpaidPremiumAmount;
|
256
|
+
|
257
|
+
_bundleService.increaseBalance(instance, policyInfo.bundleNftId, netPremiumAmount);
|
258
|
+
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
259
|
+
|
260
|
+
if(activateAt.gtz() && policyInfo.activatedAt.eqz()) {
|
261
|
+
activate(policyNftId, activateAt);
|
262
|
+
}
|
263
|
+
|
264
|
+
// TODO: add logging
|
265
|
+
}
|
266
|
+
|
267
|
+
function activate(NftId policyNftId, Timestamp activateAt) public override {
|
268
|
+
// check caller is registered product
|
269
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
270
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
271
|
+
|
272
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
273
|
+
|
274
|
+
require(
|
275
|
+
policyInfo.activatedAt.eqz(),
|
276
|
+
"ERROR:PRS-020:ALREADY_ACTIVATED");
|
277
|
+
|
278
|
+
policyInfo.activatedAt = activateAt;
|
279
|
+
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
280
|
+
|
281
|
+
instance.updatePolicy(policyNftId, policyInfo, ACTIVE());
|
282
|
+
|
283
|
+
// TODO: add logging
|
284
|
+
}
|
285
|
+
|
286
|
+
|
287
|
+
function expire(
|
288
|
+
NftId policyNftId
|
289
|
+
)
|
290
|
+
external
|
291
|
+
override
|
292
|
+
// solhint-disable-next-line no-empty-blocks
|
293
|
+
{
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
function close(
|
298
|
+
NftId policyNftId
|
299
|
+
)
|
300
|
+
external
|
301
|
+
override
|
302
|
+
{
|
303
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
304
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
305
|
+
|
306
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
307
|
+
|
308
|
+
if (policyInfo.activatedAt.eqz()) {
|
309
|
+
revert ErrorIPolicyServicePolicyNotActivated(policyNftId);
|
310
|
+
}
|
311
|
+
|
312
|
+
StateId state = instanceReader.getPolicyState(policyNftId);
|
313
|
+
if (state != ACTIVE()) {
|
314
|
+
revert ErrorIPolicyServicePolicyNotActive(policyNftId, state);
|
315
|
+
}
|
316
|
+
|
317
|
+
if (policyInfo.closedAt.gtz()) {
|
318
|
+
revert ErrorIPolicyServicePolicyAlreadyClosed(policyNftId);
|
319
|
+
}
|
320
|
+
|
321
|
+
if (policyInfo.premiumAmount != policyInfo.premiumPaidAmount) {
|
322
|
+
revert ErrorIPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
|
323
|
+
}
|
324
|
+
|
325
|
+
if (policyInfo.openClaimsCount > 0) {
|
326
|
+
revert ErrorIPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
|
327
|
+
}
|
328
|
+
|
329
|
+
if (TimestampLib.blockTimestamp().lte(policyInfo.expiredAt) && (policyInfo.payoutAmount < policyInfo.sumInsuredAmount)) {
|
330
|
+
revert ErrorIPolicyServicePolicyHasNotExpired(policyNftId, policyInfo.expiredAt);
|
331
|
+
}
|
332
|
+
|
333
|
+
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
334
|
+
|
335
|
+
_bundleService.closePolicy(instance, policyNftId, policyInfo.bundleNftId, policyInfo.sumInsuredAmount);
|
336
|
+
instance.updatePolicy(policyNftId, policyInfo, CLOSED());
|
337
|
+
}
|
338
|
+
|
339
|
+
function _getPoolNftId(
|
340
|
+
IInstance instance,
|
341
|
+
NftId productNftId
|
342
|
+
)
|
343
|
+
internal
|
344
|
+
view
|
345
|
+
returns (NftId poolNftid)
|
346
|
+
{
|
347
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
348
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
|
349
|
+
return productSetupInfo.poolNftId;
|
350
|
+
}
|
351
|
+
|
352
|
+
|
353
|
+
function _processPremiumByTreasury(
|
354
|
+
IInstance instance,
|
355
|
+
NftId productNftId,
|
356
|
+
NftId policyNftId,
|
357
|
+
uint256 premiumAmount
|
358
|
+
)
|
359
|
+
internal
|
360
|
+
returns (uint256 netPremiumAmount)
|
361
|
+
{
|
362
|
+
// process token transfer(s)
|
363
|
+
if(premiumAmount > 0) {
|
364
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
|
365
|
+
IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
366
|
+
TokenHandler tokenHandler = productSetupInfo.tokenHandler;
|
367
|
+
address policyOwner = getRegistry().ownerOf(policyNftId);
|
368
|
+
ISetup.PoolSetupInfo memory poolSetupInfo = instance.getInstanceReader().getPoolSetupInfo(productSetupInfo.poolNftId);
|
369
|
+
address poolWallet = poolSetupInfo.wallet;
|
370
|
+
IPolicy.Premium memory premium = _applicationService.calculatePremium(
|
371
|
+
productNftId,
|
372
|
+
policyInfo.riskId,
|
373
|
+
policyInfo.sumInsuredAmount,
|
374
|
+
policyInfo.lifetime,
|
375
|
+
policyInfo.applicationData,
|
376
|
+
policyInfo.bundleNftId,
|
377
|
+
policyInfo.referralId
|
378
|
+
);
|
379
|
+
|
380
|
+
// if (FeeLib.feeIsZero(premium.productFeeAmount)) {
|
381
|
+
// tokenHandler.transfer(
|
382
|
+
// policyOwner,
|
383
|
+
// poolWallet,
|
384
|
+
// premiumAmount
|
385
|
+
// );
|
386
|
+
// } else {
|
387
|
+
address productWallet = productSetupInfo.wallet;
|
388
|
+
if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
|
389
|
+
revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
|
390
|
+
}
|
391
|
+
tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
|
392
|
+
tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
|
393
|
+
netPremiumAmount = premium.netPremiumAmount;
|
394
|
+
// TODO: also move distribution tokens to distribution wallet and call `Distribution.processSale` to update distribution balances
|
395
|
+
// }
|
396
|
+
// TODO: move pool/bundle related tokens too
|
397
|
+
|
398
|
+
}
|
399
|
+
|
400
|
+
// TODO: add logging
|
401
|
+
}
|
402
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
5
|
+
import {ProxyManager} from "../../shared/ProxyManager.sol";
|
6
|
+
import {PolicyService} from "./PolicyService.sol";
|
7
|
+
import {Registry} from "../../registry/Registry.sol";
|
8
|
+
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
+
import {VersionLib} from "../../types/Version.sol";
|
10
|
+
|
11
|
+
contract PolicyServiceManager is ProxyManager {
|
12
|
+
|
13
|
+
PolicyService private _policyService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with product service implementation
|
16
|
+
constructor(
|
17
|
+
address registryAddress
|
18
|
+
)
|
19
|
+
ProxyManager(registryAddress)
|
20
|
+
{
|
21
|
+
PolicyService svc = new PolicyService();
|
22
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
23
|
+
IVersionable versionable = deploy(
|
24
|
+
address(svc),
|
25
|
+
data);
|
26
|
+
|
27
|
+
_policyService = PolicyService(address(versionable));
|
28
|
+
|
29
|
+
// Registry registry = Registry(registryAddress);
|
30
|
+
// address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
31
|
+
// RegistryService registryService = RegistryService(registryServiceAddress);
|
32
|
+
// TODO this must have a role or own nft to register service
|
33
|
+
//registryService.registerService(_productService);
|
34
|
+
|
35
|
+
// TODO no nft to link yet
|
36
|
+
// link ownership of instance service manager ot nft owner of instance service
|
37
|
+
//_linkToNftOwnable(
|
38
|
+
// address(registryAddress),
|
39
|
+
// address(_productService));
|
40
|
+
|
41
|
+
// implies that after this constructor call only upgrade functionality is available
|
42
|
+
// _isDeployed = true;
|
43
|
+
}
|
44
|
+
|
45
|
+
//--- view functions ----------------------------------------------------//
|
46
|
+
function getPolicyService()
|
47
|
+
external
|
48
|
+
view
|
49
|
+
returns (PolicyService policyService)
|
50
|
+
{
|
51
|
+
return _policyService;
|
52
|
+
}
|
53
|
+
|
54
|
+
}
|