@etherisc/gif-next 0.0.2-d408403-475 → 0.0.2-d48ae55-246
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +303 -27
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +897 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +1142 -114
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{registry/IChainNft.sol/IChainNft.json → components/IComponent.sol/IComponent.json} +292 -224
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +639 -29
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +526 -119
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +512 -69
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +1033 -245
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +975 -129
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1430 -1050
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +674 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +2060 -1122
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +984 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1386 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +1260 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +610 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +754 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
- 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 +37 -245
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +254 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{distribution/IDistribution.sol → IDistribution.sol}/IDistribution.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
- package/artifacts/contracts/instance/{base/ModuleBase.sol/ModuleBase.json → module/ISetup.sol/ISetup.json} +2 -2
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1117 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1318 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +586 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +896 -116
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +614 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +638 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +798 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +372 -41
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +784 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +188 -116
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +185 -266
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1378 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +642 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +532 -118
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +574 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +490 -341
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +574 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +186 -12
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +466 -34
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +1055 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +470 -103
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1407 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +601 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +531 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
- package/artifacts/contracts/{components/IBaseComponent.sol/IBaseComponent.json → shared/INftOwnable.sol/INftOwnable.json} +62 -72
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/{instance/module/component/IComponent.sol/IComponentModule.json → shared/IPolicyHolder.sol/IPolicyHolder.json} +69 -57
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +125 -32
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +69 -0
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/{instance/service/IComponentOwnerService.sol/IComponentOwnerService.json → shared/IService.sol/IService.json} +181 -111
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +55 -14
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +303 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +269 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +499 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +318 -24
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +105 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/shared/Service.sol/Service.json +627 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +78 -14
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +333 -24
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +436 -56
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
- 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 +103 -23
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- 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 +4 -0
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
- 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/Referral.sol/ReferralLib.dbg.json +4 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +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 +134 -8
- 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 +15 -2
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +40 -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 +236 -0
- package/contracts/components/Distribution.sol +230 -46
- package/contracts/components/IComponent.sol +50 -0
- package/contracts/components/IDistributionComponent.sol +58 -6
- package/contracts/components/IPoolComponent.sol +55 -39
- package/contracts/components/IProductComponent.sol +10 -9
- package/contracts/components/Pool.sol +170 -151
- package/contracts/components/Product.sol +118 -67
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/instance/BundleManager.sol +125 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +78 -45
- package/contracts/instance/IInstanceService.sol +59 -0
- package/contracts/instance/Instance.sol +266 -59
- package/contracts/instance/InstanceAccessManager.sol +297 -0
- package/contracts/instance/InstanceReader.sol +293 -0
- package/contracts/instance/InstanceService.sol +442 -0
- package/contracts/instance/InstanceServiceManager.sol +54 -0
- package/contracts/instance/ObjectManager.sol +84 -0
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/base/IKeyValueStore.sol +13 -14
- package/contracts/instance/base/ILifecycle.sol +3 -3
- package/contracts/instance/base/KeyValueStore.sol +49 -38
- package/contracts/instance/base/Lifecycle.sol +1 -1
- package/contracts/instance/module/IAccess.sol +47 -0
- package/contracts/instance/module/IBundle.sol +20 -0
- package/contracts/instance/module/IDistribution.sol +39 -0
- package/contracts/instance/module/IPolicy.sol +45 -0
- package/contracts/instance/module/IRisk.sol +11 -0
- package/contracts/instance/module/ISetup.sol +47 -0
- package/contracts/instance/module/ITreasury.sol +23 -0
- package/contracts/instance/service/ApplicationService.sol +268 -0
- package/contracts/instance/service/BundleService.sol +298 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/DistributionService.sol +257 -25
- package/contracts/instance/service/DistributionServiceManager.sol +51 -0
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +54 -0
- package/contracts/instance/service/IDistributionService.sol +54 -1
- package/contracts/instance/service/IPolicyService.sol +88 -0
- package/contracts/instance/service/IPoolService.sol +7 -24
- package/contracts/instance/service/IProductService.sol +9 -76
- package/contracts/instance/service/PolicyService.sol +524 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +76 -116
- package/contracts/instance/service/PoolServiceManager.sol +51 -0
- package/contracts/instance/service/ProductService.sol +158 -434
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +79 -36
- package/contracts/registry/IRegistry.sol +66 -24
- package/contracts/registry/IRegistryService.sol +67 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +366 -284
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +277 -0
- package/contracts/registry/RegistryServiceManager.sol +62 -0
- package/contracts/registry/ReleaseManager.sol +331 -0
- package/contracts/registry/TokenRegistry.sol +113 -0
- package/contracts/shared/ContractDeployerLib.sol +72 -0
- package/contracts/shared/ERC165.sol +13 -8
- package/contracts/shared/INftOwnable.sol +28 -0
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +10 -19
- package/contracts/shared/IRegistryLinked.sol +15 -0
- package/contracts/shared/IService.sol +16 -0
- package/contracts/shared/IVersionable.sol +55 -11
- package/contracts/shared/NftOwnable.sol +190 -0
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +95 -0
- package/contracts/shared/Registerable.sol +58 -63
- package/contracts/shared/RegistryLinked.sol +64 -0
- package/contracts/shared/Service.sol +60 -0
- package/contracts/shared/TokenHandler.sol +27 -0
- package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
- package/contracts/shared/Versionable.sol +113 -54
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestRegisterable.sol +5 -6
- package/contracts/test/TestRoleId.sol +1 -1
- package/contracts/test/TestService.sol +7 -14
- package/contracts/types/DistributorType.sol +55 -0
- package/contracts/types/Fee.sol +3 -3
- package/contracts/types/Key32.sol +8 -3
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/NumberId.sol +52 -0
- package/contracts/types/ObjectType.sol +40 -15
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RoleId.sol +61 -9
- package/contracts/types/StateId.sol +5 -1
- package/contracts/types/Timestamp.sol +7 -3
- package/contracts/types/UFixed.sol +128 -12
- package/contracts/types/Version.sol +13 -1
- package/package.json +6 -5
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -174
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +0 -300
- 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/base/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IService.sol/IService.json +0 -300
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +0 -376
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +0 -300
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -297
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -297
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +0 -117
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +0 -10
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +0 -4
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +0 -10
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -284
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -284
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -144
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -144
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -113
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -131
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -511
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -511
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -531
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -405
- package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -578
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -575
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/components/BaseComponent.sol +0 -94
- package/contracts/components/IBaseComponent.sol +0 -19
- package/contracts/experiment/statemachine/README.md +0 -112
- package/contracts/instance/IInstanceLinked.sol +0 -8
- package/contracts/instance/base/ComponentServiceBase.sol +0 -42
- package/contracts/instance/base/IInstanceBase.sol +0 -22
- package/contracts/instance/base/IService.sol +0 -15
- package/contracts/instance/base/InstanceBase.sol +0 -91
- package/contracts/instance/base/ModuleBase.sol +0 -57
- package/contracts/instance/base/ServiceBase.sol +0 -37
- package/contracts/instance/module/access/Access.sol +0 -149
- package/contracts/instance/module/access/IAccess.sol +0 -53
- package/contracts/instance/module/bundle/BundleModule.sol +0 -134
- package/contracts/instance/module/bundle/IBundle.sol +0 -53
- package/contracts/instance/module/component/ComponentModule.sol +0 -70
- package/contracts/instance/module/component/IComponent.sol +0 -28
- package/contracts/instance/module/distribution/DistributionModule.sol +0 -17
- package/contracts/instance/module/distribution/IDistribution.sol +0 -10
- package/contracts/instance/module/policy/IPolicy.sol +0 -63
- package/contracts/instance/module/policy/PolicyModule.sol +0 -91
- package/contracts/instance/module/pool/IPoolModule.sol +0 -40
- package/contracts/instance/module/pool/PoolModule.sol +0 -90
- package/contracts/instance/module/risk/IRisk.sol +0 -26
- package/contracts/instance/module/risk/RiskModule.sol +0 -62
- package/contracts/instance/module/treasury/ITreasury.sol +0 -82
- package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
- package/contracts/instance/module/treasury/TreasuryModule.sol +0 -138
- package/contracts/instance/service/ComponentOwnerService.sol +0 -157
- package/contracts/instance/service/IComponentOwnerService.sol +0 -22
- package/contracts/registry/IChainNft.sol +0 -21
- package/contracts/registry/IRegistryLinked.sol +0 -8
- package/contracts/shared/IOwnable.sol +0 -6
- package/contracts/test/TestDistribution.sol +0 -21
- package/contracts/test/TestPool.sol +0 -25
- package/contracts/test/TestProduct.sol +0 -72
- package/contracts/types/ReferralId.sol +0 -48
@@ -1,58 +1,166 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
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} from "../types/NftId.sol";
|
8
|
-
import {ReferralId} from "../types/
|
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";
|
13
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
14
|
+
import {IRegisterable} from "../shared/IRegisterable.sol";
|
15
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
16
|
+
import {Registerable} from "../shared/Registerable.sol";
|
17
|
+
import {TokenHandler} from "../shared/TokenHandler.sol";
|
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";
|
12
23
|
|
13
|
-
|
14
|
-
|
24
|
+
|
25
|
+
abstract contract Distribution is
|
26
|
+
Component,
|
15
27
|
IDistributionComponent
|
16
28
|
{
|
29
|
+
// keccak256(abi.encode(uint256(keccak256("etherisc.storage.Distribution")) - 1)) & ~bytes32(uint256(0xff));
|
30
|
+
bytes32 public constant DISTRIBUTION_STORAGE_LOCATION_V1 = 0xaab7c5ea03d290056d6c060e0833d3ebcbe647f7694616a2ec52738a64b2f900;
|
17
31
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
modifier onlyProductService() {
|
25
|
-
require(
|
26
|
-
msg.sender == address(_productService),
|
27
|
-
"ERROR:POL-002:NOT_PRODUCT_SERVICE");
|
28
|
-
_;
|
32
|
+
struct DistributionStorage {
|
33
|
+
Fee _distributionFee;
|
34
|
+
TokenHandler _tokenHandler;
|
35
|
+
IDistributionService _distributionService;
|
36
|
+
mapping(address distributor => NftId distributorNftId) _distributorNftId;
|
29
37
|
}
|
30
38
|
|
31
|
-
|
39
|
+
function initializeDistribution(
|
32
40
|
address registry,
|
33
41
|
NftId instanceNftId,
|
34
|
-
|
42
|
+
string memory name,
|
35
43
|
address token,
|
36
|
-
|
37
|
-
|
44
|
+
Fee memory distributionFee,
|
45
|
+
address initialOwner,
|
46
|
+
bytes memory data
|
38
47
|
)
|
39
|
-
|
48
|
+
public
|
49
|
+
virtual
|
50
|
+
onlyInitializing()
|
40
51
|
{
|
41
|
-
|
42
|
-
_initialDistributionFee = distributionFee;
|
52
|
+
initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, data);
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
|
54
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
55
|
+
// TODO add validation
|
56
|
+
$._distributionFee = distributionFee;
|
57
|
+
$._tokenHandler = new TokenHandler(token);
|
58
|
+
$._distributionService = getInstance().getDistributionService();
|
47
59
|
|
60
|
+
registerInterface(type(IDistributionComponent).interfaceId);
|
61
|
+
}
|
48
62
|
|
49
63
|
function setFees(
|
50
64
|
Fee memory distributionFee
|
51
65
|
)
|
52
66
|
external
|
53
67
|
override
|
68
|
+
onlyOwner
|
69
|
+
restricted()
|
70
|
+
{
|
71
|
+
_getDistributionStorage()._distributionService.setFees(distributionFee);
|
72
|
+
}
|
73
|
+
|
74
|
+
function getDistributionFee() external view returns (Fee memory distributionFee) {
|
75
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
76
|
+
return $._distributionFee;
|
77
|
+
}
|
78
|
+
|
79
|
+
function createDistributorType(
|
80
|
+
string memory name,
|
81
|
+
UFixed minDiscountPercentage,
|
82
|
+
UFixed maxDiscountPercentage,
|
83
|
+
UFixed commissionPercentage,
|
84
|
+
uint32 maxReferralCount,
|
85
|
+
uint32 maxReferralLifetime,
|
86
|
+
bool allowSelfReferrals,
|
87
|
+
bool allowRenewals,
|
88
|
+
bytes memory data
|
89
|
+
)
|
90
|
+
public
|
91
|
+
returns (DistributorType distributorType)
|
54
92
|
{
|
55
|
-
|
93
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
94
|
+
distributorType = $._distributionService.createDistributorType(
|
95
|
+
name,
|
96
|
+
minDiscountPercentage,
|
97
|
+
maxDiscountPercentage,
|
98
|
+
commissionPercentage,
|
99
|
+
maxReferralCount,
|
100
|
+
maxReferralLifetime,
|
101
|
+
allowSelfReferrals,
|
102
|
+
allowRenewals,
|
103
|
+
data);
|
104
|
+
}
|
105
|
+
|
106
|
+
function createDistributor(
|
107
|
+
address distributor,
|
108
|
+
DistributorType distributorType,
|
109
|
+
bytes memory data
|
110
|
+
)
|
111
|
+
public
|
112
|
+
returns(NftId distributorNftId)
|
113
|
+
{
|
114
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
115
|
+
require($._distributorNftId[distributor].eqz(), "ERROR:DST-030:ALREADY_DISTRIBUTOR");
|
116
|
+
|
117
|
+
distributorNftId = $._distributionService.createDistributor(
|
118
|
+
distributor,
|
119
|
+
distributorType,
|
120
|
+
data);
|
121
|
+
|
122
|
+
$._distributorNftId[distributor] = distributorNftId;
|
123
|
+
}
|
124
|
+
|
125
|
+
function updateDistributorType(
|
126
|
+
NftId distributorNftId,
|
127
|
+
DistributorType distributorType,
|
128
|
+
bytes memory data
|
129
|
+
)
|
130
|
+
public
|
131
|
+
// TODO figure out what we need for authz
|
132
|
+
// and add it
|
133
|
+
{
|
134
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
135
|
+
$._distributionService.updateDistributorType(
|
136
|
+
distributorNftId,
|
137
|
+
distributorType,
|
138
|
+
data);
|
139
|
+
}
|
140
|
+
|
141
|
+
/**
|
142
|
+
* @dev lets distributors create referral codes.
|
143
|
+
* referral codes need to be unique
|
144
|
+
*/
|
145
|
+
function _createReferral(
|
146
|
+
NftId distributorNftId,
|
147
|
+
string memory code,
|
148
|
+
UFixed discountPercentage,
|
149
|
+
uint32 maxReferrals,
|
150
|
+
Timestamp expiryAt,
|
151
|
+
bytes memory data
|
152
|
+
)
|
153
|
+
internal
|
154
|
+
returns (ReferralId referralId)
|
155
|
+
{
|
156
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
157
|
+
referralId = $._distributionService.createReferral(
|
158
|
+
distributorNftId,
|
159
|
+
code,
|
160
|
+
discountPercentage,
|
161
|
+
maxReferrals,
|
162
|
+
expiryAt,
|
163
|
+
data);
|
56
164
|
}
|
57
165
|
|
58
166
|
function calculateFeeAmount(
|
@@ -64,10 +172,56 @@ contract Distribution is
|
|
64
172
|
virtual override
|
65
173
|
returns (uint256 feeAmount)
|
66
174
|
{
|
67
|
-
|
175
|
+
// TODO: this is only if referralId is not valid
|
176
|
+
ISetup.DistributionSetupInfo memory setupInfo = getSetupInfo();
|
177
|
+
Fee memory fee = setupInfo.distributionFee;
|
68
178
|
(feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
|
179
|
+
// TODO: use this?
|
180
|
+
// return _distributionService.calculateFeeAmount(referralId, premiumAmount);
|
181
|
+
}
|
182
|
+
|
183
|
+
function isDistributor(address candidate)
|
184
|
+
public
|
185
|
+
view
|
186
|
+
returns (bool)
|
187
|
+
{
|
188
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
189
|
+
return $._distributorNftId[candidate].gtz();
|
190
|
+
}
|
191
|
+
|
192
|
+
function getDistributorNftId(address distributor)
|
193
|
+
public
|
194
|
+
view
|
195
|
+
returns (NftId distributorNftId)
|
196
|
+
{
|
197
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
198
|
+
return $._distributorNftId[distributor];
|
69
199
|
}
|
70
200
|
|
201
|
+
function getDiscountPercentage(string memory referralCode)
|
202
|
+
external
|
203
|
+
view
|
204
|
+
returns (
|
205
|
+
UFixed discountPercentage,
|
206
|
+
ReferralStatus status
|
207
|
+
)
|
208
|
+
{
|
209
|
+
ReferralId referralId = getReferralId(referralCode);
|
210
|
+
return getInstanceReader().getDiscountPercentage(referralId);
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
function getReferralId(
|
215
|
+
string memory referralCode
|
216
|
+
)
|
217
|
+
public
|
218
|
+
view
|
219
|
+
returns (ReferralId referralId)
|
220
|
+
{
|
221
|
+
return ReferralLib.toReferralId(
|
222
|
+
getNftId(),
|
223
|
+
referralCode);
|
224
|
+
}
|
71
225
|
|
72
226
|
function calculateRenewalFeeAmount(
|
73
227
|
ReferralId referralId,
|
@@ -84,13 +238,15 @@ contract Distribution is
|
|
84
238
|
|
85
239
|
function processSale(
|
86
240
|
ReferralId referralId,
|
87
|
-
uint256
|
241
|
+
uint256 premiumAmount
|
88
242
|
)
|
89
243
|
external
|
90
|
-
|
244
|
+
onlyOwner
|
245
|
+
restricted()
|
91
246
|
virtual override
|
92
247
|
{
|
93
|
-
|
248
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
249
|
+
$._distributionService.processSale(referralId, premiumAmount);
|
94
250
|
}
|
95
251
|
|
96
252
|
function processRenewal(
|
@@ -98,35 +254,63 @@ contract Distribution is
|
|
98
254
|
uint256 feeAmount
|
99
255
|
)
|
100
256
|
external
|
101
|
-
|
257
|
+
onlyOwner
|
258
|
+
restricted()
|
102
259
|
virtual override
|
103
260
|
{
|
104
261
|
// default is no action
|
105
262
|
}
|
106
263
|
|
107
264
|
function referralIsValid(ReferralId referralId) external view returns (bool isValid) {
|
108
|
-
|
109
|
-
|
265
|
+
InstanceReader reader = getInstance().getInstanceReader();
|
266
|
+
IDistribution.ReferralInfo memory info = reader.getReferralInfo(referralId);
|
267
|
+
|
268
|
+
if (info.distributorNftId.eqz()) {
|
269
|
+
return false;
|
270
|
+
}
|
271
|
+
|
272
|
+
isValid = info.expiryAt.eqz() || (info.expiryAt.gtz() && TimestampLib.blockTimestamp() <= info.expiryAt);
|
273
|
+
isValid = isValid && info.usedReferrals < info.maxReferrals;
|
110
274
|
}
|
111
275
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
276
|
+
function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
277
|
+
InstanceReader reader = getInstance().getInstanceReader();
|
278
|
+
setupInfo = reader.getDistributionSetupInfo(getNftId());
|
279
|
+
|
280
|
+
// fallback to initial setup info (wallet is always != address(0))
|
281
|
+
if(setupInfo.wallet == address(0)) {
|
282
|
+
setupInfo = _getInitialSetupInfo();
|
119
283
|
}
|
120
284
|
}
|
121
285
|
|
286
|
+
function _getInitialSetupInfo() internal view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
287
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
288
|
+
return ISetup.DistributionSetupInfo(
|
289
|
+
zeroNftId(),
|
290
|
+
$._tokenHandler,
|
291
|
+
$._distributionFee,
|
292
|
+
address(this)
|
293
|
+
);
|
294
|
+
}
|
295
|
+
|
296
|
+
|
297
|
+
function nftTransferFrom(address from, address to, uint256 tokenId) external virtual override (Component, ITransferInterceptor) {
|
298
|
+
// keep track of distributor nft owner
|
299
|
+
emit LogDistributorUpdated(to, msg.sender);
|
300
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
301
|
+
$._distributorNftId[from] = zeroNftId();
|
302
|
+
$._distributorNftId[to] = toNftId(tokenId);
|
303
|
+
}
|
304
|
+
|
122
305
|
|
123
306
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
124
307
|
function isVerifying() external view returns (bool verifying) {
|
125
|
-
return
|
308
|
+
return true;
|
126
309
|
}
|
127
310
|
|
128
|
-
|
129
|
-
|
130
|
-
|
311
|
+
function _getDistributionStorage() private pure returns (DistributionStorage storage $) {
|
312
|
+
assembly {
|
313
|
+
$.slot := DISTRIBUTION_STORAGE_LOCATION_V1
|
314
|
+
}
|
131
315
|
}
|
132
316
|
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
+
|
6
|
+
import {IRegisterable} from "../shared/IRegisterable.sol";
|
7
|
+
import {IInstance} from "../instance/IInstance.sol";
|
8
|
+
import {IInstanceService} from "../instance/IInstanceService.sol";
|
9
|
+
import {IProductService} from "../instance/service/IProductService.sol";
|
10
|
+
import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
|
11
|
+
import {NftId} from "../types/NftId.sol";
|
12
|
+
|
13
|
+
interface IComponent is
|
14
|
+
IRegisterable,
|
15
|
+
ITransferInterceptor
|
16
|
+
{
|
17
|
+
|
18
|
+
error ErrorComponentNotChainNft(address caller);
|
19
|
+
error ErrorComponentNotProductService(address caller);
|
20
|
+
error ErrorComponentNotInstance(NftId instanceNftId, address instance);
|
21
|
+
error ErrorComponentProductNftAlreadySet();
|
22
|
+
error ErrorComponentWalletAddressZero();
|
23
|
+
error ErrorComponentWalletAddressIsSameAsCurrent(address newWallet);
|
24
|
+
error ErrorComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
|
25
|
+
error ErrorComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
|
26
|
+
|
27
|
+
event LogComponentWalletAddressChanged(address newWallet);
|
28
|
+
event LogComponentWalletTokensTransferred(address from, address to, uint256 amount);
|
29
|
+
|
30
|
+
function getName() external view returns (string memory name);
|
31
|
+
|
32
|
+
// TODO remove and replace with accessmanaged target locking mechanism
|
33
|
+
function lock() external;
|
34
|
+
function unlock() external;
|
35
|
+
|
36
|
+
function getToken() external view returns (IERC20Metadata token);
|
37
|
+
|
38
|
+
function setWallet(address walletAddress) external;
|
39
|
+
function getWallet() external view returns (address walletAddress);
|
40
|
+
|
41
|
+
function isNftInterceptor() external view returns(bool isInterceptor);
|
42
|
+
|
43
|
+
function getInstance() external view returns (IInstance instance);
|
44
|
+
|
45
|
+
function setProductNftId(NftId productNftId) external;
|
46
|
+
function getProductNftId() external view returns (NftId productNftId);
|
47
|
+
|
48
|
+
function getInstanceService() external view returns (IInstanceService);
|
49
|
+
function getProductService() external view returns (IProductService);
|
50
|
+
}
|
@@ -2,17 +2,62 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {Fee} from "../types/Fee.sol";
|
5
|
+
import {IComponent} from "./IComponent.sol";
|
6
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
7
|
+
import {ReferralId, ReferralStatus} from "../types/Referral.sol";
|
5
8
|
import {NftId} from "../types/NftId.sol";
|
6
|
-
import {
|
9
|
+
import {DistributorType} from "../types/DistributorType.sol";
|
10
|
+
import {UFixed} from "../types/UFixed.sol";
|
11
|
+
import {Timestamp} from "../types/Timestamp.sol";
|
7
12
|
|
8
|
-
|
13
|
+
interface IDistributionComponent is IComponent {
|
9
14
|
|
10
|
-
|
15
|
+
event LogDistributorUpdated(address to, address caller);
|
16
|
+
|
17
|
+
function getSetupInfo() external view returns (ISetup.DistributionSetupInfo memory setupInfo);
|
11
18
|
|
12
19
|
function setFees(
|
13
20
|
Fee memory distributionFee
|
14
21
|
) external;
|
15
22
|
|
23
|
+
function createDistributorType(
|
24
|
+
string memory name,
|
25
|
+
UFixed minDiscountPercentage,
|
26
|
+
UFixed maxDiscountPercentage,
|
27
|
+
UFixed commissionPercentage,
|
28
|
+
uint32 maxReferralCount,
|
29
|
+
uint32 maxReferralLifetime,
|
30
|
+
bool allowSelfReferrals,
|
31
|
+
bool allowRenewals,
|
32
|
+
bytes memory data
|
33
|
+
) external returns (DistributorType distributorType);
|
34
|
+
|
35
|
+
function createDistributor(
|
36
|
+
address distributor,
|
37
|
+
DistributorType distributorType,
|
38
|
+
bytes memory data
|
39
|
+
) external returns(NftId distributorNftId);
|
40
|
+
|
41
|
+
function updateDistributorType(
|
42
|
+
NftId distributorNftId,
|
43
|
+
DistributorType distributorType,
|
44
|
+
bytes memory data
|
45
|
+
) external;
|
46
|
+
|
47
|
+
/**
|
48
|
+
* @dev lets distributors create referral codes.
|
49
|
+
* referral codes need to be unique
|
50
|
+
* distributor is identified via msg.sender.
|
51
|
+
*/
|
52
|
+
function createReferral(
|
53
|
+
NftId distributorNftId,
|
54
|
+
string memory code,
|
55
|
+
UFixed discountPercentage,
|
56
|
+
uint32 maxReferrals,
|
57
|
+
Timestamp expiryAt,
|
58
|
+
bytes memory data
|
59
|
+
) external returns (ReferralId referralId);
|
60
|
+
|
16
61
|
function calculateFeeAmount(
|
17
62
|
ReferralId referralId,
|
18
63
|
uint256 netPremiumAmount
|
@@ -37,12 +82,19 @@ interface IDistributionComponent is IBaseComponent {
|
|
37
82
|
uint256 feeAmount
|
38
83
|
) external;
|
39
84
|
|
85
|
+
function getDiscountPercentage(
|
86
|
+
string memory referralCode
|
87
|
+
) external view returns (UFixed discountPercentage, ReferralStatus status);
|
88
|
+
|
89
|
+
function getDistributionFee() external view returns (Fee memory distibutionFee);
|
90
|
+
|
91
|
+
function getReferralId(
|
92
|
+
string memory referralCode
|
93
|
+
) external returns (ReferralId referralId);
|
94
|
+
|
40
95
|
/// @dev returns true iff the referral id is valid
|
41
96
|
function referralIsValid(ReferralId referralId) external view returns (bool isValid);
|
42
97
|
|
43
|
-
/// @dev default distribution fee, ie when not using any valid referralId
|
44
|
-
function getDistributionFee() external view returns (Fee memory distributionFee);
|
45
|
-
|
46
98
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
47
99
|
function isVerifying() external view returns (bool verifying);
|
48
100
|
}
|
@@ -1,71 +1,87 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.
|
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 {ISetup} from "../instance/module/ISetup.sol";
|
7
|
+
import {NftId} from "../types/NftId.sol";
|
6
8
|
import {UFixed} from "../types/UFixed.sol";
|
7
|
-
import {IBaseComponent} from "./IBaseComponent.sol";
|
8
9
|
|
9
|
-
|
10
|
+
/// @dev pool components hold and manage the collateral to cover active policies
|
11
|
+
/// pools come in different flavors
|
12
|
+
interface IPoolComponent is IComponent {
|
10
13
|
|
11
14
|
event LogUnderwrittenByPool(NftId policyNftId, uint256 collateralizationAmount, address pool);
|
12
15
|
|
16
|
+
error ErrorPoolNotPoolService(address service);
|
17
|
+
|
18
|
+
function getSetupInfo() external view returns (ISetup.PoolSetupInfo memory setupInfo);
|
19
|
+
|
13
20
|
function setFees(
|
14
21
|
Fee memory poolFee,
|
15
22
|
Fee memory stakingFee,
|
16
23
|
Fee memory performanceFee
|
17
24
|
) external;
|
18
25
|
|
19
|
-
|
20
|
-
|
21
|
-
*/
|
22
|
-
function createBundle(
|
23
|
-
Fee memory fee,
|
24
|
-
uint256 initialAmount,
|
25
|
-
uint256 lifetime,
|
26
|
-
bytes memory filter
|
27
|
-
) external returns(NftId bundleNftId);
|
28
|
-
|
26
|
+
/// @dev sets an additional bundle fee, this fee is added on top of the poolFee and deducted from the premium amounts.
|
27
|
+
/// via these fees individual bundler owner may earn income per policy in the context of peer to peer pools
|
29
28
|
function setBundleFee(
|
30
|
-
NftId
|
29
|
+
NftId bundleNftId,
|
31
30
|
Fee memory fee
|
32
31
|
) external;
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
function underwrite(
|
41
|
-
NftId policyNftId,
|
33
|
+
/// @dev this is a callback function that is called by the product service when underwriting a policy.
|
34
|
+
/// the pool has the option to check the details and object to underwriting by reverting.
|
35
|
+
/// the function is only called for "active" pools that ask to be involved/notified
|
36
|
+
/// by product related state changes.
|
37
|
+
function verifyApplication(
|
38
|
+
NftId applicationNftId,
|
42
39
|
bytes memory policyData,
|
43
40
|
bytes memory bundleFilter,
|
44
41
|
uint256 collateralizationAmount
|
45
42
|
) external;
|
46
43
|
|
47
|
-
|
48
|
-
* @dev returns true iff the policy application data in policyData matches
|
49
|
-
* with the bundle filter criteria encoded in bundleFilter.
|
50
|
-
*/
|
51
|
-
function policyMatchesBundle(
|
52
|
-
bytes memory policyData,
|
53
|
-
bytes memory bundleFilter
|
54
|
-
)
|
55
|
-
external
|
56
|
-
view
|
57
|
-
returns (bool isMatching);
|
44
|
+
function lockBundle(NftId bundleNftId) external;
|
58
45
|
|
59
|
-
function
|
46
|
+
function unlockBundle(NftId bundleNftId) external;
|
60
47
|
|
48
|
+
/// @dev defines the multiplier to calculate the required collateral to cover a given sum insured amount
|
49
|
+
/// default implementation returns 100%
|
61
50
|
function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
|
62
51
|
|
63
|
-
|
52
|
+
/// @dev defines the amount of collateral held in the pool.
|
53
|
+
/// if the value is < 100% the pool is required to hold a policy that covers the locally missing collateral
|
54
|
+
/// default implementation returns 100%
|
55
|
+
function getRetentionLevel() external view returns (UFixed retentionLevel);
|
56
|
+
|
57
|
+
/// @dev declares if pool intercept transfers of bundle nft ids
|
58
|
+
/// - yes: pool may block transfer of bundle ownership or simply updates some bookkeeping related to bundle ownership. callback function is nftTransferFrom
|
59
|
+
/// - no: pool is not involved in transfer of bundle ownership
|
60
|
+
/// default implementation returns false (no)
|
61
|
+
function isInterceptingBundleTransfers() external view returns (bool);
|
64
62
|
|
65
|
-
|
63
|
+
/// @dev declares if pool relies on external management of collateral (yes/no):
|
64
|
+
/// - yes: underwriting of new policies does not require an actual token balance, instead it is assumed that the pool owner will manage funds externally and inject enough tokens to allow process confirmed payouts
|
65
|
+
/// - no: the pool smart contract ensures that the necessary capacity of the pool prior to underwriting.
|
66
|
+
/// default implementation returns false (no)
|
67
|
+
function isExternallyManaged() external view returns (bool);
|
66
68
|
|
67
|
-
|
69
|
+
/// @dev declares if pool component is actively involved in underwriting (yes/no):
|
70
|
+
/// - yes: verifying pools components actively confirm underwriting applications, ie the pool component logic explicitly needs to confirm the locking of collateral to cover the sum insured of the policy
|
71
|
+
/// - no: underwriting a policy does not require any interaction with the pool component if the covering bundle can provide the necessary captial
|
72
|
+
/// default implementation returnsfalse (no)
|
73
|
+
function isVerifyingApplications() external view returns (bool);
|
74
|
+
|
75
|
+
/// @dev returns true iff the policy application data in policyData matches
|
76
|
+
/// with the bundle filter criteria encoded in bundleFilter
|
77
|
+
/// this is a callback function that is only called if a pool declares itself as a verifying pool
|
78
|
+
/// default implementation returns true
|
79
|
+
function policyMatchesBundle(
|
80
|
+
bytes memory policyData,
|
81
|
+
bytes memory bundleFilter
|
82
|
+
)
|
68
83
|
external
|
69
84
|
view
|
70
|
-
returns (
|
85
|
+
returns (bool isMatching);
|
86
|
+
|
71
87
|
}
|
@@ -1,14 +1,17 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.
|
2
|
+
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {Fee} from "../types/Fee.sol";
|
5
|
+
import {IComponent} from "./IComponent.sol";
|
6
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
5
7
|
import {NftId} from "../types/NftId.sol";
|
6
|
-
import {ReferralId} from "../types/
|
8
|
+
import {ReferralId} from "../types/Referral.sol";
|
7
9
|
import {RiskId} from "../types/RiskId.sol";
|
8
10
|
|
9
|
-
|
11
|
+
interface IProductComponent is IComponent {
|
12
|
+
|
13
|
+
function getSetupInfo() external view returns (ISetup.ProductSetupInfo memory setupInfo);
|
10
14
|
|
11
|
-
interface IProductComponent is IBaseComponent {
|
12
15
|
function setFees(
|
13
16
|
Fee memory productFee,
|
14
17
|
Fee memory processingFee
|
@@ -19,8 +22,8 @@ interface IProductComponent is IBaseComponent {
|
|
19
22
|
RiskId riskId,
|
20
23
|
uint256 lifetime,
|
21
24
|
bytes memory applicationData,
|
22
|
-
|
23
|
-
|
25
|
+
NftId bundleNftId,
|
26
|
+
ReferralId referralId
|
24
27
|
) external view returns (uint256 premiumAmount);
|
25
28
|
|
26
29
|
function calculateNetPremium(
|
@@ -30,9 +33,7 @@ interface IProductComponent is IBaseComponent {
|
|
30
33
|
bytes memory applicationData
|
31
34
|
) external view returns (uint256 netPremiumAmount);
|
32
35
|
|
33
|
-
|
34
|
-
function getProcessingFee() external view returns (Fee memory processingFee);
|
35
|
-
|
36
|
+
|
36
37
|
function getPoolNftId() external view returns (NftId poolNftId);
|
37
38
|
function getDistributionNftId() external view returns (NftId distributionNftId);
|
38
39
|
}
|