@etherisc/gif-next 0.0.2-f2b0fa2-473 → 0.0.2-f2df3e2-873
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +75 -14
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +842 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +954 -219
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{instance/service/IComponentOwnerService.sol/IComponentOwnerService.json → components/IComponent.sol/IComponent.json} +303 -164
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +848 -31
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +864 -49
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +682 -9
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +849 -247
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +637 -224
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +778 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +91 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +2444 -184
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +368 -156
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +1033 -1216
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +593 -180
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +357 -211
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +653 -216
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +392 -75
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +256 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +276 -150
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +40 -10
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +71 -45
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
- 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/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1060 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +681 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1266 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +725 -0
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +1040 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +685 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1774 -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 +627 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +686 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +602 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +804 -160
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +937 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +437 -154
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +90 -391
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1511 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +741 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +1237 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +661 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +840 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +653 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +373 -61
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +223 -229
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +333 -188
- 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 +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +227 -330
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +304 -138
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +559 -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 +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +40 -29
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +21 -34
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/{experiment/inheritance/IB.sol/IB.json → shared/IRegistryLinked.sol/IRegistryLinked.json} +18 -20
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +86 -172
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -152
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +120 -27
- 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 +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +294 -61
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +129 -51
- 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 +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +191 -163
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -152
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +129 -51
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +210 -214
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +8 -190
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +4 -0
- package/artifacts/contracts/types/Amount.sol/AmountLib.json +185 -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/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +179 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +209 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- 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 +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +38 -7
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/Component.sol +253 -0
- package/contracts/components/Distribution.sol +204 -86
- package/contracts/components/IComponent.sol +76 -0
- package/contracts/components/IDistributionComponent.sol +44 -16
- package/contracts/components/IPoolComponent.sol +88 -37
- package/contracts/components/IProductComponent.sol +10 -5
- package/contracts/components/Pool.sol +224 -181
- package/contracts/components/Product.sol +249 -175
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +126 -0
- package/contracts/instance/Cloneable.sol +51 -0
- package/contracts/instance/IInstance.sol +88 -14
- package/contracts/instance/IInstanceService.sol +54 -3
- package/contracts/instance/Instance.sol +155 -281
- package/contracts/instance/InstanceAccessManager.sol +414 -175
- package/contracts/instance/InstanceReader.sol +67 -30
- package/contracts/instance/InstanceService.sol +431 -55
- package/contracts/instance/InstanceServiceManager.sol +11 -13
- package/contracts/instance/ObjectManager.sol +82 -0
- package/contracts/instance/base/ComponentService.sol +121 -0
- package/contracts/instance/base/KeyValueStore.sol +13 -5
- package/contracts/instance/base/Lifecycle.sol +23 -6
- package/contracts/instance/module/IAccess.sol +36 -20
- package/contracts/instance/module/IBundle.sol +8 -4
- package/contracts/instance/module/IComponents.sol +41 -0
- package/contracts/instance/module/IDistribution.sol +2 -0
- package/contracts/instance/module/IPolicy.sol +41 -9
- package/contracts/instance/module/ISetup.sol +9 -19
- package/contracts/instance/service/ApplicationService.sol +355 -0
- package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
- package/contracts/instance/service/BundleService.sol +436 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/ClaimService.sol +239 -0
- package/contracts/instance/service/ClaimServiceManager.sol +35 -0
- package/contracts/instance/service/DistributionService.sol +431 -0
- package/contracts/instance/service/DistributionServiceManager.sol +51 -0
- package/contracts/instance/service/IApplicationService.sol +78 -0
- package/contracts/instance/service/IBundleService.sol +96 -0
- package/contracts/instance/service/IClaimService.sol +92 -0
- package/contracts/instance/service/IDistributionService.sol +87 -0
- package/contracts/instance/service/IPolicyService.sol +137 -0
- package/contracts/instance/service/IPoolService.sol +79 -17
- package/contracts/instance/service/IProductService.sol +6 -73
- package/contracts/instance/service/PolicyService.sol +541 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +303 -0
- package/contracts/instance/service/PoolServiceManager.sol +51 -0
- package/contracts/instance/service/ProductService.sol +210 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +9 -1
- package/contracts/registry/IRegistry.sol +52 -8
- package/contracts/registry/IRegistryService.sol +47 -14
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +270 -226
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +111 -268
- package/contracts/registry/RegistryServiceManager.sol +24 -26
- package/contracts/registry/ReleaseManager.sol +324 -0
- package/contracts/registry/TokenRegistry.sol +116 -0
- package/contracts/shared/ERC165.sol +14 -8
- package/contracts/shared/INftOwnable.sol +11 -10
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +4 -6
- package/contracts/shared/IRegistryLinked.sol +12 -0
- package/contracts/shared/IService.sol +5 -4
- package/contracts/shared/IVersionable.sol +4 -47
- package/contracts/shared/NftOwnable.sol +67 -83
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +100 -25
- package/contracts/shared/Registerable.sol +16 -31
- package/contracts/shared/RegistryLinked.sol +48 -0
- package/contracts/shared/Service.sol +42 -24
- package/contracts/shared/TokenHandler.sol +11 -5
- package/contracts/shared/Versionable.sol +4 -92
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestService.sol +4 -3
- package/contracts/types/Amount.sol +65 -0
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/ClaimId.sol +75 -0
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/Fee.sol +13 -5
- package/contracts/types/NftId.sol +8 -0
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/ObjectType.sol +11 -6
- package/contracts/types/PayoutId.sol +82 -0
- package/contracts/types/Referral.sol +4 -0
- package/contracts/types/RoleId.sol +26 -11
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/StateId.sol +11 -2
- package/contracts/types/Timestamp.sol +18 -13
- package/contracts/types/UFixed.sol +1 -0
- package/contracts/types/Version.sol +5 -1
- package/package.json +3 -3
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -314
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -267
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +0 -66
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +0 -24
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +0 -42
- 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/IC.sol/IC.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
- 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/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1119
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
- package/contracts/components/BaseComponent.sol +0 -86
- package/contracts/components/IBaseComponent.sol +0 -24
- package/contracts/experiment/cloning/Cloner.sol +0 -47
- package/contracts/experiment/errors/Require.sol +0 -38
- package/contracts/experiment/errors/Revert.sol +0 -44
- package/contracts/experiment/inheritance/A.sol +0 -53
- package/contracts/experiment/inheritance/B.sol +0 -28
- package/contracts/experiment/inheritance/C.sol +0 -34
- package/contracts/experiment/inheritance/IA.sol +0 -13
- package/contracts/experiment/inheritance/IB.sol +0 -10
- package/contracts/experiment/inheritance/IC.sol +0 -12
- package/contracts/experiment/statemachine/Dummy.sol +0 -27
- package/contracts/experiment/statemachine/ISM.sol +0 -25
- package/contracts/experiment/statemachine/SM.sol +0 -57
- package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
- package/contracts/experiment/types/TypeA.sol +0 -47
- package/contracts/experiment/types/TypeB.sol +0 -29
- package/contracts/instance/AccessManagedSimple.sol +0 -114
- package/contracts/instance/AccessManagerSimple.sol +0 -682
- package/contracts/instance/IAccessManagerSimple.sol +0 -391
- package/contracts/instance/base/ComponentServiceBase.sol +0 -49
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -317
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -3,128 +3,122 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
|
+
import {Amount} from "../types/Amount.sol";
|
7
|
+
import {ClaimId} from "../types/ClaimId.sol";
|
8
|
+
import {Component} from "./Component.sol";
|
9
|
+
import {Fee} from "../types/Fee.sol";
|
6
10
|
import {IRisk} from "../instance/module/IRisk.sol";
|
7
|
-
import {
|
11
|
+
import {IApplicationService} from "../instance/service/IApplicationService.sol";
|
12
|
+
import {IPolicyService} from "../instance/service/IPolicyService.sol";
|
8
13
|
import {IProductService} from "../instance/service/IProductService.sol";
|
14
|
+
import {IClaimService} from "../instance/service/IClaimService.sol";
|
9
15
|
import {IProductComponent} from "./IProductComponent.sol";
|
10
|
-
import {NftId,
|
11
|
-
import {
|
16
|
+
import {NftId, NftIdLib} from "../types/NftId.sol";
|
17
|
+
import {PayoutId} from "../types/PayoutId.sol";
|
18
|
+
import {PRODUCT, APPLICATION, POLICY, CLAIM } from "../types/ObjectType.sol";
|
12
19
|
import {ReferralId} from "../types/Referral.sol";
|
13
20
|
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
21
|
+
import {Seconds} from "../types/Seconds.sol";
|
14
22
|
import {StateId} from "../types/StateId.sol";
|
15
23
|
import {Timestamp} from "../types/Timestamp.sol";
|
16
|
-
import {Fee, FeeLib} from "../types/Fee.sol";
|
17
|
-
import {BaseComponent} from "./BaseComponent.sol";
|
18
24
|
|
19
|
-
import {IRegistry} from "../registry/IRegistry.sol";
|
20
|
-
import {IRegisterable} from "../shared/IRegisterable.sol";
|
21
|
-
import {Registerable} from "../shared/Registerable.sol";
|
22
25
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
23
26
|
|
24
27
|
import {InstanceReader} from "../instance/InstanceReader.sol";
|
28
|
+
import {IPolicy} from "../instance/module/IPolicy.sol";
|
25
29
|
import {ISetup} from "../instance/module/ISetup.sol";
|
30
|
+
import {IComponents} from "../instance/module/IComponents.sol";
|
26
31
|
import {Pool} from "../components/Pool.sol";
|
32
|
+
import {Distribution} from "../components/Distribution.sol";
|
33
|
+
|
34
|
+
abstract contract Product is
|
35
|
+
Component,
|
36
|
+
IProductComponent
|
37
|
+
{
|
38
|
+
// keccak256(abi.encode(uint256(keccak256("etherisc.storage.Product")) - 1)) & ~bytes32(uint256(0xff));
|
39
|
+
bytes32 public constant PRODUCT_STORAGE_LOCATION_V1 = 0x0bb7aafdb8e380f81267337bc5b5dfdf76e6d3a380ecadb51ec665246d9d6800;
|
40
|
+
|
41
|
+
struct ProductStorage {
|
42
|
+
IProductService _productService;
|
43
|
+
IApplicationService _applicationService;
|
44
|
+
IPolicyService _policyService;
|
45
|
+
IClaimService _claimService;
|
46
|
+
Pool _pool;
|
47
|
+
Distribution _distribution;
|
48
|
+
Fee _initialProductFee;
|
49
|
+
Fee _initialProcessingFee;
|
50
|
+
TokenHandler _tokenHandler;
|
51
|
+
NftId _poolNftId;
|
52
|
+
NftId _distributionNftId;
|
53
|
+
}
|
27
54
|
|
28
|
-
|
29
|
-
|
30
|
-
contract Product is BaseComponent, IProductComponent {
|
31
|
-
using NftIdLib for NftId;
|
32
|
-
|
33
|
-
IProductService internal _productService;
|
34
|
-
Pool internal _pool;
|
35
|
-
address internal _distribution;
|
36
|
-
Fee internal _initialProductFee;
|
37
|
-
Fee internal _initialProcessingFee;
|
38
|
-
|
39
|
-
NftId internal _poolNftId;
|
40
|
-
NftId internal _distributionNftId;
|
41
|
-
|
42
|
-
constructor(
|
55
|
+
function initializeProduct(
|
43
56
|
address registry,
|
44
|
-
NftId
|
57
|
+
NftId instanceNftId,
|
58
|
+
string memory name,
|
45
59
|
address token,
|
46
60
|
bool isInterceptor,
|
47
61
|
address pool,
|
48
62
|
address distribution,
|
49
63
|
Fee memory productFee,
|
50
64
|
Fee memory processingFee,
|
51
|
-
address initialOwner
|
52
|
-
|
53
|
-
// TODO add validation
|
54
|
-
// TODO: reactivate when services are available again
|
55
|
-
// _productService = _instance.getProductService();
|
56
|
-
_pool = Pool(pool);
|
57
|
-
_distribution = distribution;
|
58
|
-
_initialProductFee = productFee;
|
59
|
-
_initialProcessingFee = processingFee;
|
60
|
-
|
61
|
-
_poolNftId = getRegistry().getNftId(address(_pool));
|
62
|
-
_distributionNftId = getRegistry().getNftId(_distribution);
|
63
|
-
|
64
|
-
_registerInterface(type(IProductComponent).interfaceId);
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
function calculatePremium(
|
69
|
-
uint256 sumInsuredAmount,
|
70
|
-
RiskId riskId,
|
71
|
-
uint256 lifetime,
|
72
|
-
bytes memory applicationData,
|
73
|
-
ReferralId referralId,
|
74
|
-
NftId bundleNftId
|
65
|
+
address initialOwner,
|
66
|
+
bytes memory registryData // writeonly data that will saved in the object info record of the registry
|
75
67
|
)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
returns (uint256 premiumAmount)
|
68
|
+
public
|
69
|
+
virtual
|
70
|
+
onlyInitializing()
|
80
71
|
{
|
81
|
-
(
|
82
|
-
riskId,
|
83
|
-
sumInsuredAmount,
|
84
|
-
lifetime,
|
85
|
-
applicationData,
|
86
|
-
bundleNftId,
|
87
|
-
referralId
|
88
|
-
);
|
89
|
-
}
|
72
|
+
initializeComponent(registry, instanceNftId, name, token, PRODUCT(), isInterceptor, initialOwner, registryData);
|
90
73
|
|
74
|
+
ProductStorage storage $ = _getProductStorage();
|
75
|
+
// TODO add validation
|
76
|
+
// TODO refactor to go via registry ?
|
77
|
+
$._productService = IProductService(_getServiceAddress(PRODUCT()));
|
78
|
+
$._applicationService = IApplicationService(_getServiceAddress(APPLICATION()));
|
79
|
+
$._policyService = IPolicyService(_getServiceAddress(POLICY()));
|
80
|
+
$._claimService = IClaimService(_getServiceAddress(CLAIM()));
|
81
|
+
$._pool = Pool(pool);
|
82
|
+
$._distribution = Distribution(distribution);
|
83
|
+
$._initialProductFee = productFee;
|
84
|
+
$._initialProcessingFee = processingFee;
|
85
|
+
$._tokenHandler = new TokenHandler(token);
|
86
|
+
$._poolNftId = getRegistry().getNftId(pool);
|
87
|
+
$._distributionNftId = getRegistry().getNftId(distribution);
|
88
|
+
|
89
|
+
registerInterface(type(IProductComponent).interfaceId);
|
90
|
+
}
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
bytes memory applicationData
|
92
|
+
// from product component
|
93
|
+
function setFees(
|
94
|
+
Fee memory productFee,
|
95
|
+
Fee memory processingFee
|
97
96
|
)
|
98
97
|
external
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
onlyOwner
|
99
|
+
restricted()
|
100
|
+
override
|
102
101
|
{
|
103
|
-
|
104
|
-
return sumInsuredAmount / 10;
|
105
|
-
}
|
106
|
-
|
107
|
-
function _toRiskId(string memory riskName) internal pure returns (RiskId riskId) {
|
108
|
-
return RiskIdLib.toRiskId(riskName);
|
102
|
+
_getProductService().setFees(productFee, processingFee);
|
109
103
|
}
|
110
104
|
|
111
105
|
function _createRisk(
|
112
106
|
RiskId id,
|
113
107
|
bytes memory data
|
114
108
|
) internal {
|
115
|
-
|
109
|
+
_getProductService().createRisk(
|
116
110
|
id,
|
117
111
|
data
|
118
112
|
);
|
119
113
|
}
|
120
114
|
|
121
|
-
function
|
115
|
+
function _updateRisk(
|
122
116
|
RiskId id,
|
123
|
-
|
117
|
+
bytes memory data
|
124
118
|
) internal {
|
125
|
-
|
119
|
+
_getProductService().updateRisk(
|
126
120
|
id,
|
127
|
-
|
121
|
+
data
|
128
122
|
);
|
129
123
|
}
|
130
124
|
|
@@ -132,44 +126,47 @@ contract Product is BaseComponent, IProductComponent {
|
|
132
126
|
RiskId id,
|
133
127
|
StateId state
|
134
128
|
) internal {
|
135
|
-
|
129
|
+
_getProductService().updateRiskState(
|
136
130
|
id,
|
137
131
|
state
|
138
132
|
);
|
139
133
|
}
|
140
134
|
|
141
135
|
function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
|
142
|
-
return
|
136
|
+
return getInstance().getInstanceReader().getRiskInfo(id);
|
143
137
|
}
|
144
138
|
|
145
139
|
function _createApplication(
|
146
140
|
address applicationOwner,
|
147
141
|
RiskId riskId,
|
148
142
|
uint256 sumInsuredAmount,
|
149
|
-
|
150
|
-
bytes memory applicationData,
|
143
|
+
Seconds lifetime,
|
151
144
|
NftId bundleNftId,
|
152
|
-
ReferralId referralId
|
153
|
-
|
154
|
-
|
145
|
+
ReferralId referralId,
|
146
|
+
bytes memory applicationData
|
147
|
+
)
|
148
|
+
internal
|
149
|
+
returns (NftId applicationNftId)
|
150
|
+
{
|
151
|
+
return _getProductStorage()._applicationService.create(
|
155
152
|
applicationOwner,
|
156
153
|
riskId,
|
157
154
|
sumInsuredAmount,
|
158
155
|
lifetime,
|
159
|
-
applicationData,
|
160
156
|
bundleNftId,
|
161
|
-
referralId
|
157
|
+
referralId,
|
158
|
+
applicationData
|
162
159
|
);
|
163
160
|
}
|
164
161
|
|
165
|
-
function
|
162
|
+
function _collateralize(
|
166
163
|
NftId policyNftId,
|
167
164
|
bool requirePremiumPayment,
|
168
165
|
Timestamp activateAt
|
169
166
|
)
|
170
167
|
internal
|
171
168
|
{
|
172
|
-
|
169
|
+
_getProductStorage()._policyService.collateralize(
|
173
170
|
policyNftId,
|
174
171
|
requirePremiumPayment,
|
175
172
|
activateAt);
|
@@ -181,7 +178,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
181
178
|
)
|
182
179
|
internal
|
183
180
|
{
|
184
|
-
|
181
|
+
_getProductStorage()._policyService.collectPremium(
|
185
182
|
policyNftId,
|
186
183
|
activateAt);
|
187
184
|
}
|
@@ -192,106 +189,183 @@ contract Product is BaseComponent, IProductComponent {
|
|
192
189
|
)
|
193
190
|
internal
|
194
191
|
{
|
195
|
-
|
192
|
+
_getProductStorage()._policyService.activate(
|
196
193
|
policyNftId,
|
197
194
|
activateAt);
|
198
195
|
}
|
199
196
|
|
200
|
-
function
|
201
|
-
|
197
|
+
function _close(
|
198
|
+
NftId policyNftId
|
199
|
+
)
|
200
|
+
internal
|
201
|
+
{
|
202
|
+
_getProductStorage()._policyService.close(
|
203
|
+
policyNftId);
|
202
204
|
}
|
203
205
|
|
204
|
-
function
|
205
|
-
|
206
|
+
function _submitClaim(
|
207
|
+
NftId policyNftId,
|
208
|
+
Amount claimAmount,
|
209
|
+
bytes memory claimData
|
210
|
+
)
|
211
|
+
internal
|
212
|
+
returns(ClaimId)
|
213
|
+
{
|
214
|
+
return _getProductStorage()._policyService.submitClaim(
|
215
|
+
policyNftId,
|
216
|
+
claimAmount,
|
217
|
+
claimData);
|
206
218
|
}
|
207
219
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
220
|
+
function _confirmClaim(
|
221
|
+
NftId policyNftId,
|
222
|
+
ClaimId claimId,
|
223
|
+
Amount confirmedAmount
|
212
224
|
)
|
213
|
-
|
214
|
-
onlyOwner
|
215
|
-
override
|
225
|
+
internal
|
216
226
|
{
|
217
|
-
|
227
|
+
_getProductStorage()._policyService.confirmClaim(
|
228
|
+
policyNftId,
|
229
|
+
claimId,
|
230
|
+
confirmedAmount);
|
218
231
|
}
|
219
232
|
|
220
|
-
function
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
233
|
+
function _declineClaim(
|
234
|
+
NftId policyNftId,
|
235
|
+
ClaimId claimId
|
236
|
+
)
|
237
|
+
internal
|
238
|
+
{
|
239
|
+
_getProductStorage()._policyService.declineClaim(
|
240
|
+
policyNftId,
|
241
|
+
claimId);
|
242
|
+
}
|
243
|
+
|
244
|
+
function _closeClaim(
|
245
|
+
NftId policyNftId,
|
246
|
+
ClaimId claimId
|
247
|
+
)
|
248
|
+
internal
|
249
|
+
{
|
250
|
+
_getProductStorage()._policyService.closeClaim(
|
251
|
+
policyNftId,
|
252
|
+
claimId);
|
238
253
|
}
|
239
254
|
|
240
|
-
|
255
|
+
function _createPayout(
|
256
|
+
NftId policyNftId,
|
257
|
+
ClaimId claimId,
|
258
|
+
Amount amount,
|
259
|
+
bytes memory data
|
260
|
+
)
|
261
|
+
internal
|
262
|
+
returns (PayoutId)
|
263
|
+
{
|
264
|
+
return _getProductStorage()._policyService.createPayout(
|
265
|
+
policyNftId,
|
266
|
+
claimId,
|
267
|
+
amount,
|
268
|
+
data);
|
269
|
+
}
|
241
270
|
|
242
|
-
|
243
|
-
|
244
|
-
|
271
|
+
function _processPayout(
|
272
|
+
NftId policyNftId,
|
273
|
+
PayoutId payoutId
|
274
|
+
)
|
275
|
+
internal
|
276
|
+
{
|
277
|
+
_getProductStorage()._policyService.processPayout(
|
278
|
+
policyNftId,
|
279
|
+
payoutId);
|
280
|
+
}
|
281
|
+
|
282
|
+
function calculatePremium(
|
283
|
+
uint256 sumInsuredAmount,
|
284
|
+
RiskId riskId,
|
285
|
+
Seconds lifetime,
|
286
|
+
bytes memory applicationData,
|
287
|
+
NftId bundleNftId,
|
288
|
+
ReferralId referralId
|
289
|
+
)
|
290
|
+
external
|
245
291
|
view
|
246
|
-
override
|
247
|
-
returns (
|
292
|
+
override
|
293
|
+
returns (uint256 premiumAmount)
|
248
294
|
{
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
)
|
295
|
+
IPolicy.Premium memory premium = _getProductStorage()._applicationService.calculatePremium(
|
296
|
+
getNftId(),
|
297
|
+
riskId,
|
298
|
+
sumInsuredAmount,
|
299
|
+
lifetime,
|
300
|
+
applicationData,
|
301
|
+
bundleNftId,
|
302
|
+
referralId
|
303
|
+
);
|
304
|
+
premiumAmount = premium.premiumAmount;
|
305
|
+
}
|
306
|
+
|
307
|
+
function calculateNetPremium(
|
308
|
+
uint256 sumInsuredAmount,
|
309
|
+
RiskId riskId,
|
310
|
+
Seconds lifetime,
|
311
|
+
bytes memory applicationData
|
312
|
+
)
|
313
|
+
external
|
314
|
+
view
|
315
|
+
virtual override
|
316
|
+
returns (uint256 netPremiumAmount)
|
317
|
+
{
|
318
|
+
// default 10% of sum insured
|
319
|
+
return sumInsuredAmount / 10;
|
320
|
+
}
|
321
|
+
|
322
|
+
function _toRiskId(string memory riskName) internal pure returns (RiskId riskId) {
|
323
|
+
return RiskIdLib.toRiskId(riskName);
|
324
|
+
}
|
325
|
+
|
326
|
+
function getPoolNftId() external view override returns (NftId poolNftId) {
|
327
|
+
return getRegistry().getNftId(address(_getProductStorage()._pool));
|
328
|
+
}
|
329
|
+
|
330
|
+
function getDistributionNftId() external view override returns (NftId distributionNftId) {
|
331
|
+
return getRegistry().getNftId(address(_getProductStorage()._distribution));
|
332
|
+
}
|
333
|
+
|
334
|
+
function getSetupInfo() public view returns (ISetup.ProductSetupInfo memory setupInfo) {
|
335
|
+
InstanceReader reader = getInstance().getInstanceReader();
|
336
|
+
setupInfo = reader.getProductSetupInfo(getNftId());
|
337
|
+
|
338
|
+
// fallback to initial setup info (wallet is always != address(0))
|
339
|
+
if(setupInfo.wallet == address(0)) {
|
340
|
+
setupInfo = _getInitialSetupInfo();
|
341
|
+
}
|
342
|
+
}
|
343
|
+
|
344
|
+
function _getInitialSetupInfo() internal view returns (ISetup.ProductSetupInfo memory setupInfo) {
|
345
|
+
ProductStorage storage $ = _getProductStorage();
|
346
|
+
|
347
|
+
ISetup.DistributionSetupInfo memory distributionSetupInfo = $._distribution.getSetupInfo();
|
348
|
+
IComponents.PoolInfo memory poolInfo = $._pool.getPoolInfo();
|
349
|
+
|
350
|
+
return ISetup.ProductSetupInfo(
|
351
|
+
getToken(),
|
352
|
+
$._tokenHandler,
|
353
|
+
$._distributionNftId,
|
354
|
+
$._poolNftId,
|
355
|
+
$._initialProductFee,
|
356
|
+
$._initialProcessingFee,
|
357
|
+
false,
|
358
|
+
getWallet()
|
295
359
|
);
|
296
360
|
}
|
361
|
+
|
362
|
+
function _getProductStorage() private pure returns (ProductStorage storage $) {
|
363
|
+
assembly {
|
364
|
+
$.slot := PRODUCT_STORAGE_LOCATION_V1
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
function _getProductService() internal view returns (IProductService) {
|
369
|
+
return _getProductStorage()._productService;
|
370
|
+
}
|
297
371
|
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
|
5
|
+
|
6
|
+
|
7
|
+
contract AccessManagerUpgradeableInitializeable is AccessManagerUpgradeable {
|
8
|
+
|
9
|
+
function initialize(address initialAdmin) initializer public {
|
10
|
+
__AccessManager_init(initialAdmin);
|
11
|
+
}
|
12
|
+
|
13
|
+
}
|
@@ -0,0 +1,126 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IInstance} from "./IInstance.sol";
|
5
|
+
import {INSTANCE} from "../types/ObjectType.sol";
|
6
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
7
|
+
import {IPolicy} from "../instance/module/IPolicy.sol";
|
8
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
9
|
+
import {LibNftIdSet} from "../types/NftIdSet.sol";
|
10
|
+
import {NftId} from "../types/NftId.sol";
|
11
|
+
import {TimestampLib} from "../types/Timestamp.sol";
|
12
|
+
|
13
|
+
import {ObjectManager} from "./ObjectManager.sol";
|
14
|
+
|
15
|
+
contract BundleManager is
|
16
|
+
ObjectManager
|
17
|
+
{
|
18
|
+
|
19
|
+
event LogBundleManagerPolicyLinked(NftId bundleNftId, NftId policyNftId);
|
20
|
+
event LogBundleManagerPolicyUnlinked(NftId bundleNftId, NftId policyNftId);
|
21
|
+
|
22
|
+
event LogBundleManagerBundleAdded(NftId poolNftId, NftId bundleNftId);
|
23
|
+
event LogBundleManagerBundleUnlocked(NftId poolNftId, NftId bundleNftId);
|
24
|
+
event LogBundleManagerBundleLocked(NftId poolNftId, NftId bundleNftId);
|
25
|
+
event LogBundleManagerBundleClosed(NftId poolNftId, NftId bundleNftId);
|
26
|
+
|
27
|
+
error ErrorBundleManagerPolicyAlreadyActivated(NftId policyNftId);
|
28
|
+
error ErrorBundleManagerBundleLocked(NftId bundleNftId, NftId policyNftId);
|
29
|
+
error ErrorBundleManagerPolicyWithOpenClaims(NftId policyNftId, uint256 openClaimsCount);
|
30
|
+
error ErrorBundleManagerPolicyNotCloseable(NftId policyNftId);
|
31
|
+
error ErrorBundleManagerBundleUnknown(NftId bundleNftId);
|
32
|
+
error ErrorBundleManagerBundleNotRegistered(NftId bundleNftId);
|
33
|
+
|
34
|
+
mapping(NftId bundleNftId => LibNftIdSet.Set policies) internal _activePolicies;
|
35
|
+
|
36
|
+
/// @dev links a policy to its bundle
|
37
|
+
// to link a policy it MUST NOT yet have been linked
|
38
|
+
function linkPolicy(NftId policyNftId) external restricted() {
|
39
|
+
NftId bundleNftId = _instance.getInstanceReader().getPolicyInfo(policyNftId).bundleNftId;
|
40
|
+
// decision will likely depend on the decision what to check here and what in the service
|
41
|
+
NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
|
42
|
+
|
43
|
+
// ensure bundle is unlocked (in active set) and registered with this instance
|
44
|
+
if (!_isActive(poolNftId, bundleNftId)) {
|
45
|
+
revert ErrorBundleManagerBundleLocked(bundleNftId, policyNftId);
|
46
|
+
}
|
47
|
+
|
48
|
+
LibNftIdSet.add(_activePolicies[bundleNftId], policyNftId);
|
49
|
+
emit LogBundleManagerPolicyLinked(bundleNftId, policyNftId);
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
/// @dev unlinks a policy from its bundle
|
54
|
+
// to unlink a policy it must closable, ie. meet one of the following criterias
|
55
|
+
// - the policy MUST be past its expiry period and it MUST NOT have any open claims
|
56
|
+
// - the policy's payoutAmount MUST be equal to its sumInsuredAmount and MUST NOT have any open claims
|
57
|
+
function unlinkPolicy(NftId policyNftId) external restricted() {
|
58
|
+
IPolicy.PolicyInfo memory policyInfo = _instance.getInstanceReader().getPolicyInfo(policyNftId);
|
59
|
+
|
60
|
+
NftId bundleNftId = policyInfo.bundleNftId;
|
61
|
+
// decision will likely depend on the decision what to check here and what in the service
|
62
|
+
NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
|
63
|
+
|
64
|
+
// ensure bundle is registered with this instance
|
65
|
+
if (!_contains(poolNftId, bundleNftId)) {
|
66
|
+
revert ErrorBundleManagerBundleUnknown(bundleNftId);
|
67
|
+
}
|
68
|
+
|
69
|
+
LibNftIdSet.remove(_activePolicies[bundleNftId], policyNftId);
|
70
|
+
emit LogBundleManagerPolicyUnlinked(policyInfo.bundleNftId, policyNftId);
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
/// @dev add a new bundle to a pool registerd with this instance
|
75
|
+
// the corresponding pool is fetched via instance reader
|
76
|
+
function add(NftId bundleNftId) external restricted() {
|
77
|
+
NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
|
78
|
+
|
79
|
+
// ensure pool is registered with instance
|
80
|
+
if(poolNftId.eqz()) {
|
81
|
+
revert ErrorBundleManagerBundleNotRegistered(bundleNftId);
|
82
|
+
}
|
83
|
+
|
84
|
+
_add(poolNftId, bundleNftId);
|
85
|
+
emit LogBundleManagerBundleAdded(poolNftId, bundleNftId);
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
/// @dev unlocked (active) bundles are available to collateralize new policies
|
90
|
+
function unlock(NftId bundleNftId) external restricted() {
|
91
|
+
NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
|
92
|
+
_activate(poolNftId, bundleNftId);
|
93
|
+
emit LogBundleManagerBundleUnlocked(poolNftId, bundleNftId);
|
94
|
+
}
|
95
|
+
|
96
|
+
/// @dev locked (deactivated) bundles may not collateralize any new policies
|
97
|
+
function lock(NftId bundleNftId) external restricted() {
|
98
|
+
NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
|
99
|
+
_deactivate(poolNftId, bundleNftId);
|
100
|
+
emit LogBundleManagerBundleLocked(poolNftId, bundleNftId);
|
101
|
+
}
|
102
|
+
|
103
|
+
function bundles(NftId poolNftId) external view returns(uint256) {
|
104
|
+
return _objects(poolNftId);
|
105
|
+
}
|
106
|
+
|
107
|
+
function getBundleNftId(NftId poolNftId, uint256 idx) external view returns(NftId bundleNftId) {
|
108
|
+
return _getObject(poolNftId, idx);
|
109
|
+
}
|
110
|
+
|
111
|
+
function activeBundles(NftId poolNftId) external view returns(uint256) {
|
112
|
+
return _activeObjs(poolNftId);
|
113
|
+
}
|
114
|
+
|
115
|
+
function getActiveBundleNftId(NftId poolNftId, uint256 idx) external view returns(NftId bundleNftId) {
|
116
|
+
return _getActiveObject(poolNftId, idx);
|
117
|
+
}
|
118
|
+
|
119
|
+
function activePolicies(NftId bundleNftId) external view returns(uint256) {
|
120
|
+
return LibNftIdSet.size(_activePolicies[bundleNftId]);
|
121
|
+
}
|
122
|
+
|
123
|
+
function getActivePolicy(NftId bundleNftId, uint256 idx) external view returns(NftId policyNftId) {
|
124
|
+
return LibNftIdSet.getElementAt(_activePolicies[bundleNftId], idx);
|
125
|
+
}
|
126
|
+
}
|