@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
@@ -4,10 +4,11 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {DISTRIBUTION} from "../types/ObjectType.sol";
|
5
5
|
import {IDistributionService} from "../instance/service/IDistributionService.sol";
|
6
6
|
import {IProductService} from "../instance/service/IProductService.sol";
|
7
|
-
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
8
|
-
import {ReferralId} from "../types/Referral.sol";
|
7
|
+
import {NftId, zeroNftId, NftIdLib, toNftId} from "../types/NftId.sol";
|
8
|
+
import {ReferralId, ReferralStatus, ReferralLib} from "../types/Referral.sol";
|
9
9
|
import {Fee, FeeLib} from "../types/Fee.sol";
|
10
|
-
import {
|
10
|
+
import {Component} from "./Component.sol";
|
11
|
+
import {IDistribution} from "../instance/module/IDistribution.sol";
|
11
12
|
import {IDistributionComponent} from "./IDistributionComponent.sol";
|
12
13
|
import {IRegistry} from "../registry/IRegistry.sol";
|
13
14
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
@@ -15,73 +16,204 @@ import {ISetup} from "../instance/module/ISetup.sol";
|
|
15
16
|
import {Registerable} from "../shared/Registerable.sol";
|
16
17
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
17
18
|
import {InstanceReader} from "../instance/InstanceReader.sol";
|
19
|
+
import {UFixed} from "../types/UFixed.sol";
|
20
|
+
import {DistributorType} from "../types/DistributorType.sol";
|
21
|
+
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
22
|
+
import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
|
18
23
|
|
19
|
-
|
20
|
-
|
24
|
+
|
25
|
+
abstract contract Distribution is
|
26
|
+
Component,
|
21
27
|
IDistributionComponent
|
22
28
|
{
|
23
|
-
|
24
|
-
|
25
|
-
Fee internal _initialDistributionFee;
|
26
|
-
bool internal _isVerifying;
|
29
|
+
// keccak256(abi.encode(uint256(keccak256("etherisc.storage.Distribution")) - 1)) & ~bytes32(uint256(0xff));
|
30
|
+
bytes32 public constant DISTRIBUTION_STORAGE_LOCATION_V1 = 0xaab7c5ea03d290056d6c060e0833d3ebcbe647f7694616a2ec52738a64b2f900;
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
"ERROR:POL-002:NOT_PRODUCT_SERVICE");
|
35
|
-
_;
|
32
|
+
struct DistributionStorage {
|
33
|
+
Fee _minDistributionOwnerFee;
|
34
|
+
Fee _distributionFee;
|
35
|
+
TokenHandler _tokenHandler;
|
36
|
+
IDistributionService _distributionService;
|
37
|
+
mapping(address distributor => NftId distributorNftId) _distributorNftId;
|
36
38
|
}
|
37
39
|
|
38
|
-
|
40
|
+
error ErrorDistributionAlreadyDistributor(address distributor, NftId distributorNftId);
|
41
|
+
|
42
|
+
function initializeDistribution(
|
39
43
|
address registry,
|
40
44
|
NftId instanceNftId,
|
41
|
-
|
42
|
-
// TODO refactor into tokenNftId
|
45
|
+
string memory name,
|
43
46
|
address token,
|
44
|
-
|
47
|
+
Fee memory minDistributionOwnerFee,
|
45
48
|
Fee memory distributionFee,
|
46
|
-
address initialOwner
|
49
|
+
address initialOwner,
|
50
|
+
bytes memory registryData // writeonly data that will saved in the object info record of the registry
|
47
51
|
)
|
48
|
-
|
52
|
+
public
|
53
|
+
virtual
|
54
|
+
onlyInitializing()
|
49
55
|
{
|
50
|
-
|
51
|
-
_initialDistributionFee = distributionFee;
|
56
|
+
initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, registryData);
|
52
57
|
|
53
|
-
|
54
|
-
//
|
55
|
-
|
58
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
59
|
+
// TODO add validation
|
60
|
+
$._minDistributionOwnerFee = minDistributionOwnerFee;
|
61
|
+
$._distributionFee = distributionFee;
|
62
|
+
$._tokenHandler = new TokenHandler(token);
|
63
|
+
$._distributionService = IDistributionService(_getServiceAddress(DISTRIBUTION()));
|
56
64
|
|
57
|
-
|
65
|
+
registerInterface(type(IDistributionComponent).interfaceId);
|
58
66
|
}
|
59
67
|
|
60
|
-
|
61
68
|
function setFees(
|
69
|
+
Fee memory minDistributionOwnerFee,
|
62
70
|
Fee memory distributionFee
|
63
71
|
)
|
64
72
|
external
|
65
73
|
override
|
74
|
+
onlyOwner
|
75
|
+
restricted()
|
66
76
|
{
|
67
|
-
_distributionService.setFees(distributionFee);
|
77
|
+
_getDistributionStorage()._distributionService.setFees(minDistributionOwnerFee, distributionFee);
|
68
78
|
}
|
69
79
|
|
70
|
-
function
|
71
|
-
|
72
|
-
|
80
|
+
function getDistributionFee() external view returns (Fee memory distributionFee) {
|
81
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
82
|
+
return $._distributionFee;
|
83
|
+
}
|
84
|
+
|
85
|
+
function createDistributorType(
|
86
|
+
string memory name,
|
87
|
+
UFixed minDiscountPercentage,
|
88
|
+
UFixed maxDiscountPercentage,
|
89
|
+
UFixed commissionPercentage,
|
90
|
+
uint32 maxReferralCount,
|
91
|
+
uint32 maxReferralLifetime,
|
92
|
+
bool allowSelfReferrals,
|
93
|
+
bool allowRenewals,
|
94
|
+
bytes memory data
|
73
95
|
)
|
96
|
+
public
|
97
|
+
returns (DistributorType distributorType)
|
98
|
+
{
|
99
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
100
|
+
distributorType = $._distributionService.createDistributorType(
|
101
|
+
name,
|
102
|
+
minDiscountPercentage,
|
103
|
+
maxDiscountPercentage,
|
104
|
+
commissionPercentage,
|
105
|
+
maxReferralCount,
|
106
|
+
maxReferralLifetime,
|
107
|
+
allowSelfReferrals,
|
108
|
+
allowRenewals,
|
109
|
+
data);
|
110
|
+
}
|
111
|
+
|
112
|
+
function createDistributor(
|
113
|
+
address distributor,
|
114
|
+
DistributorType distributorType,
|
115
|
+
bytes memory data
|
116
|
+
)
|
117
|
+
public
|
118
|
+
returns(NftId distributorNftId)
|
119
|
+
{
|
120
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
121
|
+
if($._distributorNftId[distributor].gtz()) {
|
122
|
+
revert ErrorDistributionAlreadyDistributor(distributor, $._distributorNftId[distributor]);
|
123
|
+
}
|
124
|
+
|
125
|
+
distributorNftId = $._distributionService.createDistributor(
|
126
|
+
distributor,
|
127
|
+
distributorType,
|
128
|
+
data);
|
129
|
+
|
130
|
+
$._distributorNftId[distributor] = distributorNftId;
|
131
|
+
}
|
132
|
+
|
133
|
+
function updateDistributorType(
|
134
|
+
NftId distributorNftId,
|
135
|
+
DistributorType distributorType,
|
136
|
+
bytes memory data
|
137
|
+
)
|
138
|
+
public
|
139
|
+
// TODO figure out what we need for authz
|
140
|
+
// and add it
|
141
|
+
{
|
142
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
143
|
+
$._distributionService.updateDistributorType(
|
144
|
+
distributorNftId,
|
145
|
+
distributorType,
|
146
|
+
data);
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* @dev lets distributors create referral codes.
|
151
|
+
* referral codes need to be unique
|
152
|
+
*/
|
153
|
+
function _createReferral(
|
154
|
+
NftId distributorNftId,
|
155
|
+
string memory code,
|
156
|
+
UFixed discountPercentage,
|
157
|
+
uint32 maxReferrals,
|
158
|
+
Timestamp expiryAt,
|
159
|
+
bytes memory data
|
160
|
+
)
|
161
|
+
internal
|
162
|
+
returns (ReferralId referralId)
|
163
|
+
{
|
164
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
165
|
+
referralId = $._distributionService.createReferral(
|
166
|
+
distributorNftId,
|
167
|
+
code,
|
168
|
+
discountPercentage,
|
169
|
+
maxReferrals,
|
170
|
+
expiryAt,
|
171
|
+
data);
|
172
|
+
}
|
173
|
+
|
174
|
+
function isDistributor(address candidate)
|
175
|
+
public
|
176
|
+
view
|
177
|
+
returns (bool)
|
178
|
+
{
|
179
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
180
|
+
return $._distributorNftId[candidate].gtz();
|
181
|
+
}
|
182
|
+
|
183
|
+
function getDistributorNftId(address distributor)
|
184
|
+
public
|
185
|
+
view
|
186
|
+
returns (NftId distributorNftId)
|
187
|
+
{
|
188
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
189
|
+
return $._distributorNftId[distributor];
|
190
|
+
}
|
191
|
+
|
192
|
+
function getDiscountPercentage(string memory referralCode)
|
74
193
|
external
|
75
194
|
view
|
76
|
-
|
77
|
-
|
195
|
+
returns (
|
196
|
+
UFixed discountPercentage,
|
197
|
+
ReferralStatus status
|
198
|
+
)
|
78
199
|
{
|
79
|
-
|
80
|
-
|
81
|
-
(feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
|
200
|
+
ReferralId referralId = getReferralId(referralCode);
|
201
|
+
return _getInstanceReader().getDiscountPercentage(referralId);
|
82
202
|
}
|
83
203
|
|
84
204
|
|
205
|
+
function getReferralId(
|
206
|
+
string memory referralCode
|
207
|
+
)
|
208
|
+
public
|
209
|
+
view
|
210
|
+
returns (ReferralId referralId)
|
211
|
+
{
|
212
|
+
return ReferralLib.toReferralId(
|
213
|
+
getNftId(),
|
214
|
+
referralCode);
|
215
|
+
}
|
216
|
+
|
85
217
|
function calculateRenewalFeeAmount(
|
86
218
|
ReferralId referralId,
|
87
219
|
uint256 netPremiumAmount
|
@@ -95,72 +227,58 @@ contract Distribution is
|
|
95
227
|
return 0 * netPremiumAmount;
|
96
228
|
}
|
97
229
|
|
98
|
-
function
|
230
|
+
function processRenewal(
|
99
231
|
ReferralId referralId,
|
100
232
|
uint256 feeAmount
|
101
233
|
)
|
102
234
|
external
|
103
|
-
|
235
|
+
onlyOwner
|
236
|
+
restricted()
|
104
237
|
virtual override
|
105
238
|
{
|
106
239
|
// default is no action
|
107
240
|
}
|
108
241
|
|
109
|
-
function
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
// default is no action
|
242
|
+
function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
243
|
+
InstanceReader reader = getInstance().getInstanceReader();
|
244
|
+
setupInfo = reader.getDistributionSetupInfo(getNftId());
|
245
|
+
|
246
|
+
// fallback to initial setup info (wallet is always != address(0))
|
247
|
+
if(setupInfo.wallet == address(0)) {
|
248
|
+
setupInfo = _getInitialSetupInfo();
|
249
|
+
}
|
118
250
|
}
|
119
251
|
|
120
|
-
function
|
121
|
-
|
122
|
-
return
|
252
|
+
function _getInitialSetupInfo() internal view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
253
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
254
|
+
return ISetup.DistributionSetupInfo(
|
255
|
+
zeroNftId(),
|
256
|
+
$._tokenHandler,
|
257
|
+
$._minDistributionOwnerFee,
|
258
|
+
$._distributionFee,
|
259
|
+
address(this),
|
260
|
+
0
|
261
|
+
);
|
123
262
|
}
|
124
263
|
|
125
|
-
function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
126
|
-
if (getNftId().eq(zeroNftId())) {
|
127
|
-
return ISetup.DistributionSetupInfo(
|
128
|
-
_productNftId,
|
129
|
-
TokenHandler(address(0)),
|
130
|
-
_initialDistributionFee,
|
131
|
-
_isVerifying,
|
132
|
-
address(0)
|
133
|
-
);
|
134
|
-
}
|
135
264
|
|
136
|
-
|
137
|
-
|
265
|
+
function _nftTransferFrom(address from, address to, uint256 tokenId) internal virtual override {
|
266
|
+
// keep track of distributor nft owner
|
267
|
+
emit LogDistributorUpdated(to, msg.sender);
|
268
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
269
|
+
$._distributorNftId[from] = zeroNftId();
|
270
|
+
$._distributorNftId[to] = toNftId(tokenId);
|
138
271
|
}
|
272
|
+
|
139
273
|
|
140
274
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
141
275
|
function isVerifying() external view returns (bool verifying) {
|
142
|
-
return
|
276
|
+
return true;
|
143
277
|
}
|
144
278
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
view
|
150
|
-
override (IRegisterable, Registerable)
|
151
|
-
returns(IRegistry.ObjectInfo memory, bytes memory)
|
152
|
-
{
|
153
|
-
(
|
154
|
-
IRegistry.ObjectInfo memory info,
|
155
|
-
bytes memory data
|
156
|
-
) = super.getInitialInfo();
|
157
|
-
|
158
|
-
return (
|
159
|
-
info,
|
160
|
-
abi.encode(
|
161
|
-
_initialDistributionFee,
|
162
|
-
_isVerifying
|
163
|
-
)
|
164
|
-
);
|
279
|
+
function _getDistributionStorage() private pure returns (DistributionStorage storage $) {
|
280
|
+
assembly {
|
281
|
+
$.slot := DISTRIBUTION_STORAGE_LOCATION_V1
|
282
|
+
}
|
165
283
|
}
|
166
284
|
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
5
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
6
|
+
|
7
|
+
import {IComponents} from "../instance/module/IComponents.sol";
|
8
|
+
import {IInstance} from "../instance/IInstance.sol";
|
9
|
+
import {IInstanceService} from "../instance/IInstanceService.sol";
|
10
|
+
import {IProductService} from "../instance/service/IProductService.sol";
|
11
|
+
import {IRegisterable} from "../shared/IRegisterable.sol";
|
12
|
+
import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
|
13
|
+
import {NftId} from "../types/NftId.sol";
|
14
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
15
|
+
|
16
|
+
/// @dev component base class
|
17
|
+
/// component examples are product, distribution, pool and oracle
|
18
|
+
interface IComponent is
|
19
|
+
IRegisterable,
|
20
|
+
ITransferInterceptor,
|
21
|
+
IAccessManaged
|
22
|
+
{
|
23
|
+
error ErrorComponentNotChainNft(address caller);
|
24
|
+
error ErrorComponentNotProductService(address caller);
|
25
|
+
error ErrorComponentNotInstance(NftId instanceNftId);
|
26
|
+
error ErrorComponentProductNftAlreadySet();
|
27
|
+
|
28
|
+
error ErrorComponentWalletAddressZero();
|
29
|
+
error ErrorComponentWalletAddressIsSameAsCurrent();
|
30
|
+
error ErrorComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
|
31
|
+
|
32
|
+
event LogComponentWalletAddressChanged(address oldWallet, address newWallet);
|
33
|
+
event LogComponentWalletTokensTransferred(address from, address to, uint256 amount);
|
34
|
+
|
35
|
+
/// @dev locks component to disable functions that may change state related to this component, the only exception is function "unlock"
|
36
|
+
/// only component owner (nft holder) is authorizes to call this function
|
37
|
+
function lock() external;
|
38
|
+
|
39
|
+
/// @dev unlocks component to (re-)enable functions that may change state related to this component
|
40
|
+
/// only component owner (nft holder) is authorizes to call this function
|
41
|
+
function unlock() external;
|
42
|
+
|
43
|
+
/// @dev sets the wallet address for the component
|
44
|
+
/// if the current wallet has tokens, these will be transferred
|
45
|
+
/// if the new wallet address is externally owned, an approval from the
|
46
|
+
/// owner of the external wallet for the component to move all tokens must exist
|
47
|
+
function setWallet(address walletAddress) external;
|
48
|
+
|
49
|
+
/// @dev only product service may set product nft id during registration of product setup
|
50
|
+
function setProductNftId(NftId productNftId) external;
|
51
|
+
|
52
|
+
/// @dev returns the name of this component
|
53
|
+
/// to successfully register the component with an instance the name MUST be unique in the linked instance
|
54
|
+
function getName() external view returns (string memory name);
|
55
|
+
|
56
|
+
/// @dev defines which ERC20 token is used by this component
|
57
|
+
function getToken() external view returns (IERC20Metadata token);
|
58
|
+
|
59
|
+
/// @dev defines the instance to which this component is linked to
|
60
|
+
function getInstance() external view returns (IInstance instance);
|
61
|
+
|
62
|
+
/// @dev defines the wallet address used to hold the ERC20 tokens related to this component
|
63
|
+
/// the default address is the component token address
|
64
|
+
function getWallet() external view returns (address walletAddress);
|
65
|
+
|
66
|
+
/// @dev defines the product to which this component is linked to
|
67
|
+
/// this is only relevant for pool and distribution components
|
68
|
+
function getProductNftId() external view returns (NftId productNftId);
|
69
|
+
|
70
|
+
function isNftInterceptor() external view returns(bool isInterceptor);
|
71
|
+
|
72
|
+
/// @dev returns component infos for this pool
|
73
|
+
/// when registered with an instance the info is obtained from the data stored in the instance
|
74
|
+
/// when not registered the function returns the info from the component contract
|
75
|
+
function getComponentInfo() external view returns (IComponents.ComponentInfo memory info);
|
76
|
+
}
|
@@ -2,41 +2,69 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {Fee} from "../types/Fee.sol";
|
5
|
-
import {
|
5
|
+
import {IComponent} from "./IComponent.sol";
|
6
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
7
|
+
import {ReferralId, ReferralStatus} from "../types/Referral.sol";
|
6
8
|
import {NftId} from "../types/NftId.sol";
|
9
|
+
import {DistributorType} from "../types/DistributorType.sol";
|
10
|
+
import {UFixed} from "../types/UFixed.sol";
|
11
|
+
import {Timestamp} from "../types/Timestamp.sol";
|
7
12
|
|
8
|
-
interface IDistributionComponent {
|
13
|
+
interface IDistributionComponent is IComponent {
|
14
|
+
|
15
|
+
event LogDistributorUpdated(address to, address caller);
|
16
|
+
|
17
|
+
function getSetupInfo() external view returns (ISetup.DistributionSetupInfo memory setupInfo);
|
9
18
|
|
10
19
|
function setFees(
|
20
|
+
Fee memory minDistributionOwnerFee,
|
11
21
|
Fee memory distributionFee
|
12
22
|
) external;
|
13
23
|
|
14
|
-
function
|
15
|
-
|
16
|
-
|
17
|
-
|
24
|
+
function createDistributorType(
|
25
|
+
string memory name,
|
26
|
+
UFixed minDiscountPercentage,
|
27
|
+
UFixed maxDiscountPercentage,
|
28
|
+
UFixed commissionPercentage,
|
29
|
+
uint32 maxReferralCount,
|
30
|
+
uint32 maxReferralLifetime,
|
31
|
+
bool allowSelfReferrals,
|
32
|
+
bool allowRenewals,
|
33
|
+
bytes memory data
|
34
|
+
) external returns (DistributorType distributorType);
|
35
|
+
|
36
|
+
function createDistributor(
|
37
|
+
address distributor,
|
38
|
+
DistributorType distributorType,
|
39
|
+
bytes memory data
|
40
|
+
) external returns(NftId distributorNftId);
|
41
|
+
|
42
|
+
function updateDistributorType(
|
43
|
+
NftId distributorNftId,
|
44
|
+
DistributorType distributorType,
|
45
|
+
bytes memory data
|
46
|
+
) external;
|
18
47
|
|
19
48
|
function calculateRenewalFeeAmount(
|
20
49
|
ReferralId referralId,
|
21
50
|
uint256 netPremiumAmount
|
22
51
|
) external view returns (uint256 feeAmount);
|
23
52
|
|
24
|
-
/// @dev callback from product service when selling a policy for a specific referralId
|
25
|
-
/// the used referral id and the collected fee are provided as parameters
|
26
|
-
/// the component implementation can then process this information accordingly
|
27
|
-
function processSale(
|
28
|
-
ReferralId referralId,
|
29
|
-
uint256 feeAmount
|
30
|
-
) external;
|
31
|
-
|
32
53
|
/// @dev callback from product service when a policy is renews for a specific referralId
|
33
54
|
function processRenewal(
|
34
55
|
ReferralId referralId,
|
35
56
|
uint256 feeAmount
|
36
57
|
) external;
|
37
58
|
|
38
|
-
|
39
|
-
|
59
|
+
function getDiscountPercentage(
|
60
|
+
string memory referralCode
|
61
|
+
) external view returns (UFixed discountPercentage, ReferralStatus status);
|
62
|
+
|
63
|
+
function getDistributionFee() external view returns (Fee memory distibutionFee);
|
64
|
+
|
65
|
+
function getReferralId(
|
66
|
+
string memory referralCode
|
67
|
+
) external returns (ReferralId referralId);
|
40
68
|
|
41
69
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
42
70
|
function isVerifying() external view returns (bool verifying);
|
@@ -1,62 +1,113 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {NftId} from "../types/NftId.sol";
|
5
4
|
import {Fee} from "../types/Fee.sol";
|
5
|
+
import {IComponent} from "./IComponent.sol";
|
6
|
+
import {IComponents} from "../instance/module/IComponents.sol";
|
7
|
+
import {NftId} from "../types/NftId.sol";
|
8
|
+
import {RoleId} from "../types/RoleId.sol";
|
9
|
+
import {Seconds} from "../types/Seconds.sol";
|
6
10
|
import {UFixed} from "../types/UFixed.sol";
|
7
11
|
|
8
|
-
|
12
|
+
/// @dev pool components hold and manage the collateral to cover active policies
|
13
|
+
/// pools come in different flavors
|
14
|
+
interface IPoolComponent is IComponent {
|
9
15
|
|
10
|
-
|
16
|
+
error ErrorPoolNotBundleOwner(NftId bundleNftId, address caller);
|
17
|
+
error ErrorPoolNotPoolService(address caller);
|
11
18
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
19
|
+
error ErrorPoolApplicationBundleMismatch(NftId applicationNftId);
|
20
|
+
|
21
|
+
event LogPoolVerifiedByPool(address pool, NftId applicationNftId, uint256 collateralizationAmount);
|
22
|
+
|
23
|
+
/// @dev increases the staked tokens by the specified amount
|
24
|
+
/// only the bundle owner may stake tokens
|
25
|
+
/// bundle MUST be in active or locked state
|
26
|
+
function stake(NftId bundleNftId, uint256 amount) external;
|
27
|
+
|
28
|
+
/// @dev decreases the staked tokens by the specified amount
|
29
|
+
/// only the bundle owner may unstake tokens from the bundle
|
30
|
+
/// bundle MUST be in active, locked or closed state
|
31
|
+
function unstake(NftId bundleNftId, uint256 amount) external;
|
32
|
+
|
33
|
+
/// @dev extends the bundle lifetime of the bundle by the specified time
|
34
|
+
/// only the bundle owner may extend the bundle's lifetime
|
35
|
+
/// bundle MUST be in active or locked state
|
36
|
+
function extend(NftId bundleNftId, Seconds lifetimeExtension) external;
|
37
|
+
|
38
|
+
/// @dev locks the specified bundle
|
39
|
+
/// a bundle to be locked MUST be in active state
|
40
|
+
/// locked bundles may not be used to collateralize any new policy
|
41
|
+
function lockBundle(NftId bundleNftId) external;
|
17
42
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
function createBundle(
|
22
|
-
Fee memory fee,
|
23
|
-
uint256 initialAmount,
|
24
|
-
uint256 lifetime,
|
25
|
-
bytes memory filter
|
26
|
-
) external returns(NftId bundleNftId);
|
43
|
+
/// @dev unlocks the specified bundle
|
44
|
+
/// a bundle to be unlocked MUST be in locked state
|
45
|
+
function unlockBundle(NftId bundleNftId) external;
|
27
46
|
|
47
|
+
/// @dev close the specified bundle
|
48
|
+
/// a bundle to be closed MUST be in active or locked state
|
49
|
+
/// to close a bundle all all linked policies MUST be in closed state as well
|
50
|
+
/// closing a bundle finalizes the bundle bookkeeping including overall profit calculation
|
51
|
+
/// once a bundle is closed this action cannot be reversed
|
52
|
+
function close(NftId bundleNftId) external;
|
53
|
+
|
54
|
+
/// @dev sets the fee for the specified bundle
|
55
|
+
/// the fee is added on top of the poolFee and deducted from the premium amounts
|
56
|
+
/// via these fees individual bundler owner may earn income per policy in the context of peer to peer pools
|
28
57
|
function setBundleFee(
|
29
|
-
NftId
|
58
|
+
NftId bundleNftId,
|
30
59
|
Fee memory fee
|
31
60
|
) external;
|
32
61
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
62
|
+
/// @dev sets the maximum overall capital amound held by this pool
|
63
|
+
/// function may only be called by pool owner
|
64
|
+
function setMaxCapitalAmount(uint256 maxCapitalAmount) external;
|
65
|
+
|
66
|
+
/// @dev sets the required role to create/own bundles
|
67
|
+
/// may only be called once after setting up a pool
|
68
|
+
/// may only be called by pool owner
|
69
|
+
function setBundleOwnerRole(RoleId bundleOwnerRole) external;
|
70
|
+
|
71
|
+
/// @dev update pool fees to the specified values
|
72
|
+
/// pool fees: are deducted from the premium amount and goes to the pool owner
|
73
|
+
/// staking fees: are deducted from the staked tokens by a bundle owner and goes to the pool owner
|
74
|
+
/// performance fees: when a bundle is closed a bundle specific profit is calculated
|
75
|
+
/// the performance fee is deducted from this profit and goes to the pool owner
|
76
|
+
function setFees(
|
77
|
+
Fee memory poolFee,
|
78
|
+
Fee memory stakingFee,
|
79
|
+
Fee memory performanceFee
|
80
|
+
) external;
|
81
|
+
|
82
|
+
/// @dev this is a callback function that is called by the product service when underwriting a policy.
|
83
|
+
/// the pool has the option to check the details and object to underwriting by reverting.
|
84
|
+
/// the function is only called for "active" pools that ask to be involved/notified
|
85
|
+
/// by product related state changes.
|
86
|
+
function verifyApplication(
|
87
|
+
NftId applicationNftId,
|
88
|
+
bytes memory applicationData,
|
89
|
+
NftId bundleNftId,
|
42
90
|
bytes memory bundleFilter,
|
43
91
|
uint256 collateralizationAmount
|
44
92
|
) external;
|
45
93
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
bytes memory
|
52
|
-
|
94
|
+
/// @dev returns true iff the application matches with the bundle
|
95
|
+
/// this is a callback function that is only called if a pool declares itself as a verifying pool
|
96
|
+
/// default implementation returns true
|
97
|
+
function applicationMatchesBundle(
|
98
|
+
NftId applicationNftId,
|
99
|
+
bytes memory applicationData,
|
100
|
+
NftId bundleNftId,
|
101
|
+
bytes memory bundleFilter,
|
102
|
+
uint256 collateralizationAmount
|
53
103
|
)
|
54
104
|
external
|
55
105
|
view
|
56
106
|
returns (bool isMatching);
|
57
107
|
|
58
|
-
|
59
|
-
|
60
|
-
|
108
|
+
/// @dev returns pool specific infos for this pool
|
109
|
+
/// when registered with an instance the info is obtained from the data stored in the instance
|
110
|
+
/// when not registered the function returns the info from the component contract
|
111
|
+
function getPoolInfo() external view returns (IComponents.PoolInfo memory info);
|
61
112
|
|
62
113
|
}
|