@etherisc/gif-next 0.0.2-f79a517-071 → 0.0.2-f7a5beb-202
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +67 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +613 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +353 -104
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → components/IComponent.sol/IComponent.json} +185 -151
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +527 -9
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +611 -66
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +618 -30
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +492 -212
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +429 -137
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- 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 +1035 -995
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/{service/IComponentOwnerService.sol/IComponentOwnerService.json → IInstanceService.sol/IInstanceService.json} +155 -56
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +1821 -1096
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +1034 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1381 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +964 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +473 -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/{InstanceBase.sol/InstanceBase.json → ComponentService.sol/ComponentService.json} +134 -75
- 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/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1102 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +449 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +194 -52
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +437 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +715 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -18
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +766 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +15 -82
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +25 -245
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1227 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +505 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +181 -128
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +437 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +174 -386
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +437 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +339 -59
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +220 -111
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +301 -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 +83 -128
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +53 -85
- 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 +394 -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 +2 -2
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.json +14 -19
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +19 -6
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ComponentServiceBase.sol/ComponentServiceBase.json → shared/Service.sol/Service.json} +28 -33
- 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 +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/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
- 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 +58 -34
- 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 +18 -2
- 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/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/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 +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- 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 +247 -0
- package/contracts/components/Distribution.sol +37 -49
- package/contracts/components/IComponent.sol +50 -0
- package/contracts/components/IDistributionComponent.sol +6 -5
- package/contracts/components/IPoolComponent.sol +42 -29
- package/contracts/components/IProductComponent.sol +9 -7
- package/contracts/components/Pool.sol +137 -116
- package/contracts/components/Product.sol +78 -114
- package/contracts/instance/BundleManager.sol +125 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +64 -44
- package/contracts/instance/IInstanceService.sol +40 -0
- package/contracts/instance/Instance.sol +251 -65
- package/contracts/instance/InstanceAccessManager.sol +298 -0
- package/contracts/instance/InstanceReader.sol +293 -0
- package/contracts/instance/InstanceService.sol +362 -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 +48 -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 +46 -0
- package/contracts/instance/module/ITreasury.sol +23 -0
- package/contracts/instance/service/BundleService.sol +293 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/DistributionService.sol +72 -20
- package/contracts/instance/service/DistributionServiceManager.sol +51 -0
- package/contracts/instance/service/IBundleService.sol +44 -0
- package/contracts/instance/service/IDistributionService.sol +1 -1
- package/contracts/instance/service/IPolicyService.sol +94 -0
- package/contracts/instance/service/IPoolService.sol +7 -24
- package/contracts/instance/service/IProductService.sol +9 -76
- package/contracts/instance/service/PolicyService.sol +538 -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 +154 -432
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +1 -1
- package/contracts/registry/IRegistry.sol +47 -6
- package/contracts/registry/IRegistryService.sol +50 -20
- package/contracts/registry/Registry.sol +243 -214
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +84 -263
- package/contracts/registry/RegistryServiceManager.sol +20 -22
- package/contracts/registry/ReleaseManager.sol +332 -0
- package/contracts/registry/TokenRegistry.sol +112 -0
- package/contracts/shared/ERC165.sol +6 -2
- package/contracts/shared/IRegisterable.sol +1 -3
- package/contracts/shared/IService.sol +16 -0
- package/contracts/shared/NftOwnable.sol +7 -4
- package/contracts/shared/ProxyManager.sol +1 -1
- package/contracts/shared/Registerable.sol +11 -14
- package/contracts/shared/Service.sol +60 -0
- package/contracts/shared/TokenHandler.sol +27 -0
- package/contracts/shared/Versionable.sol +2 -2
- package/contracts/test/TestRoleId.sol +1 -1
- package/contracts/test/TestService.sol +6 -7
- package/contracts/types/DistributorType.sol +55 -0
- 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 +35 -14
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RoleId.sol +60 -15
- package/contracts/types/StateId.sol +5 -1
- package/contracts/types/Timestamp.sol +7 -3
- package/contracts/types/Version.sol +4 -1
- package/package.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -301
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -254
- 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/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/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- 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/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/component/IComponent.sol/IComponentModule.json +0 -117
- 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 -271
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -271
- 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 -164
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -164
- 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 -638
- 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 -638
- 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/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -557
- package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -716
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -744
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
- package/contracts/components/BaseComponent.sol +0 -79
- package/contracts/components/IBaseComponent.sol +0 -19
- package/contracts/instance/IInstanceLinked.sol +0 -8
- package/contracts/instance/base/ComponentServiceBase.sol +0 -49
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/base/IService.sol +0 -15
- package/contracts/instance/base/InstanceBase.sol +0 -89
- package/contracts/instance/base/ModuleBase.sol +0 -57
- package/contracts/instance/base/ServiceBase.sol +0 -44
- 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 -71
- 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 -41
- package/contracts/instance/module/pool/PoolModule.sol +0 -95
- 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 -84
- package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
- package/contracts/instance/module/treasury/TreasuryModule.sol +0 -131
- package/contracts/instance/service/ComponentOwnerService.sol +0 -315
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/test/TestDistribution.sol +0 -22
- package/contracts/test/TestPool.sol +0 -27
- package/contracts/test/TestProduct.sol +0 -74
- package/contracts/types/ReferralId.sol +0 -48
@@ -0,0 +1,247 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
5
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
6
|
+
|
7
|
+
import {IComponent} from "./IComponent.sol";
|
8
|
+
import {IProductService} from "../instance/service/IProductService.sol";
|
9
|
+
import {IInstanceService} from "../instance/IInstanceService.sol";
|
10
|
+
import {IInstance} from "../instance/IInstance.sol";
|
11
|
+
import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
|
12
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
13
|
+
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
14
|
+
import {ObjectType, INSTANCE, PRODUCT} from "../types/ObjectType.sol";
|
15
|
+
import {VersionPart} from "../types/Version.sol";
|
16
|
+
import {Registerable} from "../shared/Registerable.sol";
|
17
|
+
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
18
|
+
import {IAccess} from "../instance/module/IAccess.sol";
|
19
|
+
|
20
|
+
// TODO discuss to inherit from oz accessmanaged
|
21
|
+
// TODO make contract upgradeable
|
22
|
+
// then add (Distribution|Pool|Product)Upradeable that also intherit from Versionable
|
23
|
+
// same pattern as for Service which is also upgradeable
|
24
|
+
abstract contract Component is
|
25
|
+
Registerable,
|
26
|
+
IComponent
|
27
|
+
{
|
28
|
+
// keccak256(abi.encode(uint256(keccak256("gif-next.contracts.component.Component.sol")) - 1)) & ~bytes32(uint256(0xff));
|
29
|
+
bytes32 public constant CONTRACT_LOCATION_V1 = 0xffe8d4462baed26a47154f4b8f6db497d2f772496965791d25bd456e342b7f00;
|
30
|
+
|
31
|
+
struct ComponentStorage {
|
32
|
+
IInstance _instance; // instance for this component
|
33
|
+
|
34
|
+
string _name; // unique (per instance) component name
|
35
|
+
IERC20Metadata _token; // token for this component
|
36
|
+
address _wallet; // wallet for this component (default = component contract itself)
|
37
|
+
bool _isNftInterceptor; // declares if component is involved in nft transfers
|
38
|
+
IInstanceService _instanceService; // instance service for this component
|
39
|
+
|
40
|
+
NftId _productNftId; // only relevant for components that are linked to a aproduct
|
41
|
+
IProductService _productService; // product service for component, might not be relevant for some component types (eg oracles)
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
modifier onlyChainNft() {
|
46
|
+
if(msg.sender != address(getRegistry().getChainNft())) {
|
47
|
+
revert ErrorComponentNotChainNft(msg.sender);
|
48
|
+
}
|
49
|
+
_;
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
modifier onlyProductService() {
|
54
|
+
if(msg.sender != address(_getComponentStorage()._productService)) {
|
55
|
+
revert ErrorComponentNotProductService(msg.sender);
|
56
|
+
}
|
57
|
+
_;
|
58
|
+
}
|
59
|
+
|
60
|
+
// TODO discuss replacement with modifier restricted from accessmanaged
|
61
|
+
modifier onlyInstanceRole(uint64 roleIdNum) {
|
62
|
+
RoleId roleId = RoleIdLib.toRoleId(roleIdNum);
|
63
|
+
InstanceAccessManager accessManager = InstanceAccessManager(_getComponentStorage()._instance.authority());
|
64
|
+
if( !accessManager.hasRole(roleId, msg.sender)) {
|
65
|
+
revert ErrorComponentUnauthorized(msg.sender, roleIdNum);
|
66
|
+
}
|
67
|
+
_;
|
68
|
+
}
|
69
|
+
|
70
|
+
// TODO discuss replacement with modifier restricted from accessmanaged
|
71
|
+
modifier isNotLocked() {
|
72
|
+
InstanceAccessManager accessManager = InstanceAccessManager(_getComponentStorage()._instance.authority());
|
73
|
+
if (accessManager.isTargetLocked(address(this))) {
|
74
|
+
revert IAccess.ErrorIAccessTargetLocked(address(this));
|
75
|
+
}
|
76
|
+
_;
|
77
|
+
}
|
78
|
+
|
79
|
+
function _getComponentStorage() private pure returns (ComponentStorage storage $) {
|
80
|
+
assembly {
|
81
|
+
$.slot := CONTRACT_LOCATION_V1
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
function _initializeComponent(
|
87
|
+
address registry,
|
88
|
+
NftId instanceNftId,
|
89
|
+
string memory name,
|
90
|
+
address token,
|
91
|
+
ObjectType componentType,
|
92
|
+
bool isInterceptor,
|
93
|
+
address initialOwner,
|
94
|
+
bytes memory data
|
95
|
+
)
|
96
|
+
internal
|
97
|
+
//onlyInitializing//TODO uncomment when "fully" upgradeable
|
98
|
+
virtual
|
99
|
+
{
|
100
|
+
ComponentStorage storage $ = _getComponentStorage();
|
101
|
+
_initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, data);
|
102
|
+
|
103
|
+
// set unique name of component
|
104
|
+
$._name = name;
|
105
|
+
$._isNftInterceptor = isInterceptor;
|
106
|
+
|
107
|
+
// set and check linked instance
|
108
|
+
IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
|
109
|
+
$._instance = IInstance(instanceInfo.objectAddress);
|
110
|
+
if(!$._instance.supportsInterface(type(IInstance).interfaceId)) {
|
111
|
+
revert ErrorComponentNotInstance(instanceNftId, instanceInfo.objectAddress);
|
112
|
+
}
|
113
|
+
|
114
|
+
// set linked services
|
115
|
+
VersionPart gifVersion = $._instance.getMajorVersion();
|
116
|
+
$._instanceService = IInstanceService(getRegistry().getServiceAddress(INSTANCE(), gifVersion));
|
117
|
+
$._productService = IProductService(getRegistry().getServiceAddress(PRODUCT(), gifVersion));
|
118
|
+
|
119
|
+
// set wallet and token
|
120
|
+
$._wallet = address(this);
|
121
|
+
$._token = IERC20Metadata(token);
|
122
|
+
|
123
|
+
_registerInterface(type(IComponent).interfaceId);
|
124
|
+
}
|
125
|
+
|
126
|
+
/// @dev callback function for nft transfers. may only be called by chain nft contract.
|
127
|
+
/// default implementation is empty. overriding functions MUST add onlyChainNft modifier
|
128
|
+
function nftTransferFrom(address from, address to, uint256 tokenId)
|
129
|
+
external
|
130
|
+
virtual override
|
131
|
+
onlyChainNft()
|
132
|
+
{ }
|
133
|
+
|
134
|
+
// TODO discuss replacement with modifier restricted from accessmanaged
|
135
|
+
function lock() external onlyOwner override {
|
136
|
+
_getComponentStorage()._instanceService.setTargetLocked(getName(), true);
|
137
|
+
}
|
138
|
+
|
139
|
+
// TODO discuss replacement with modifier restricted from accessmanaged
|
140
|
+
function unlock() external onlyOwner override {
|
141
|
+
_getComponentStorage()._instanceService.setTargetLocked(getName(), false);
|
142
|
+
}
|
143
|
+
|
144
|
+
// only product service may set product nft id during registration of product setup
|
145
|
+
function setProductNftId(NftId productNftId)
|
146
|
+
external
|
147
|
+
override
|
148
|
+
onlyProductService()
|
149
|
+
{
|
150
|
+
ComponentStorage storage $ = _getComponentStorage();
|
151
|
+
|
152
|
+
if($._productNftId.gtz()) {
|
153
|
+
revert ErrorComponentProductNftAlreadySet();
|
154
|
+
}
|
155
|
+
|
156
|
+
$._productNftId = productNftId;
|
157
|
+
}
|
158
|
+
|
159
|
+
/// @dev Sets the wallet address for the component.
|
160
|
+
/// if the current wallet has tokens, these will be transferred.
|
161
|
+
/// if the new wallet address is externally owned, an approval from the
|
162
|
+
/// owner of the external wallet for the component to move all tokens must exist.
|
163
|
+
function setWallet(address newWallet)
|
164
|
+
external
|
165
|
+
override
|
166
|
+
onlyOwner
|
167
|
+
{
|
168
|
+
ComponentStorage storage $ = _getComponentStorage();
|
169
|
+
|
170
|
+
address currentWallet = $._wallet;
|
171
|
+
uint256 currentBalance = $._token.balanceOf(currentWallet);
|
172
|
+
|
173
|
+
// checks
|
174
|
+
if (newWallet == address(0)) {
|
175
|
+
revert ErrorComponentWalletAddressZero();
|
176
|
+
}
|
177
|
+
if (newWallet == currentWallet) {
|
178
|
+
revert ErrorComponentWalletAddressIsSameAsCurrent(newWallet);
|
179
|
+
}
|
180
|
+
|
181
|
+
if (currentBalance > 0) {
|
182
|
+
if (currentWallet == address(this)) {
|
183
|
+
// move tokens from component smart contract to external wallet
|
184
|
+
} else {
|
185
|
+
// move tokens from external wallet to component smart contract or another external wallet
|
186
|
+
uint256 allowance = $._token.allowance(currentWallet, address(this));
|
187
|
+
if (allowance < currentBalance) {
|
188
|
+
revert ErrorComponentWalletAllowanceTooSmall(currentWallet, newWallet, allowance, currentBalance);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
// effects
|
194
|
+
$._wallet = newWallet;
|
195
|
+
emit LogComponentWalletAddressChanged(newWallet);
|
196
|
+
|
197
|
+
// interactions
|
198
|
+
if (currentBalance > 0) {
|
199
|
+
// transfer tokens from current wallet to new wallet
|
200
|
+
if (currentWallet == address(this)) {
|
201
|
+
// transferFrom requires self allowance too
|
202
|
+
$._token.approve(address(this), currentBalance);
|
203
|
+
}
|
204
|
+
|
205
|
+
SafeERC20.safeTransferFrom($._token, currentWallet, newWallet, currentBalance);
|
206
|
+
emit LogComponentWalletTokensTransferred(currentWallet, newWallet, currentBalance);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
function getWallet()
|
211
|
+
public
|
212
|
+
view
|
213
|
+
override
|
214
|
+
returns (address walletAddress)
|
215
|
+
{
|
216
|
+
return _getComponentStorage()._wallet;
|
217
|
+
}
|
218
|
+
|
219
|
+
function getToken() public view override returns (IERC20Metadata token) {
|
220
|
+
return _getComponentStorage()._token;
|
221
|
+
}
|
222
|
+
|
223
|
+
function isNftInterceptor() public view override returns(bool isInterceptor) {
|
224
|
+
return _getComponentStorage()._isNftInterceptor;
|
225
|
+
}
|
226
|
+
|
227
|
+
function getInstance() public view override returns (IInstance instance) {
|
228
|
+
return _getComponentStorage()._instance;
|
229
|
+
}
|
230
|
+
|
231
|
+
function getName() public view override returns(string memory name) {
|
232
|
+
return _getComponentStorage()._name;
|
233
|
+
}
|
234
|
+
|
235
|
+
function getProductNftId() public view override returns (NftId productNftId) {
|
236
|
+
return _getComponentStorage()._productNftId;
|
237
|
+
}
|
238
|
+
|
239
|
+
function getInstanceService() public view returns (IInstanceService) {
|
240
|
+
return _getComponentStorage()._instanceService;
|
241
|
+
}
|
242
|
+
|
243
|
+
function getProductService() public view returns (IProductService) {
|
244
|
+
return _getComponentStorage()._productService;
|
245
|
+
}
|
246
|
+
|
247
|
+
}
|
@@ -4,49 +4,48 @@ 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} from "../types/NftId.sol";
|
8
|
-
import {ReferralId} from "../types/
|
7
|
+
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
8
|
+
import {ReferralId} from "../types/Referral.sol";
|
9
9
|
import {Fee, FeeLib} from "../types/Fee.sol";
|
10
|
-
import {
|
10
|
+
import {Component} from "./Component.sol";
|
11
11
|
import {IDistributionComponent} from "./IDistributionComponent.sol";
|
12
12
|
import {IRegistry} from "../registry/IRegistry.sol";
|
13
13
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
14
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
14
15
|
import {Registerable} from "../shared/Registerable.sol";
|
16
|
+
import {TokenHandler} from "../shared/TokenHandler.sol";
|
17
|
+
import {InstanceReader} from "../instance/InstanceReader.sol";
|
15
18
|
|
16
|
-
contract Distribution is
|
17
|
-
|
19
|
+
abstract contract Distribution is
|
20
|
+
Component,
|
18
21
|
IDistributionComponent
|
19
22
|
{
|
20
|
-
|
21
|
-
Fee internal _initialDistributionFee;
|
22
23
|
bool internal _isVerifying;
|
24
|
+
Fee internal _initialDistributionFee;
|
23
25
|
|
24
|
-
|
25
|
-
IProductService private _productService;
|
26
|
+
TokenHandler internal _tokenHandler;
|
26
27
|
|
27
|
-
|
28
|
-
require(
|
29
|
-
msg.sender == address(_productService),
|
30
|
-
"ERROR:POL-002:NOT_PRODUCT_SERVICE");
|
31
|
-
_;
|
32
|
-
}
|
28
|
+
IDistributionService private _distributionService;
|
33
29
|
|
34
30
|
constructor(
|
35
31
|
address registry,
|
36
32
|
NftId instanceNftId,
|
37
33
|
// TODO refactor into tokenNftId
|
34
|
+
string memory name,
|
38
35
|
address token,
|
39
36
|
bool verifying,
|
40
37
|
Fee memory distributionFee,
|
41
|
-
address initialOwner
|
38
|
+
address initialOwner,
|
39
|
+
bytes memory data
|
42
40
|
)
|
43
|
-
BaseComponent(registry, instanceNftId, token, DISTRIBUTION(), true, initialOwner)
|
44
41
|
{
|
42
|
+
_initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, data);
|
43
|
+
|
45
44
|
_isVerifying = verifying;
|
46
45
|
_initialDistributionFee = distributionFee;
|
47
46
|
|
48
|
-
|
49
|
-
|
47
|
+
_tokenHandler = new TokenHandler(token);
|
48
|
+
_distributionService = getInstance().getDistributionService();
|
50
49
|
|
51
50
|
_registerInterface(type(IDistributionComponent).interfaceId);
|
52
51
|
}
|
@@ -70,7 +69,8 @@ contract Distribution is
|
|
70
69
|
virtual override
|
71
70
|
returns (uint256 feeAmount)
|
72
71
|
{
|
73
|
-
|
72
|
+
ISetup.DistributionSetupInfo memory setupInfo = getSetupInfo();
|
73
|
+
Fee memory fee = setupInfo.distributionFee;
|
74
74
|
(feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
|
75
75
|
}
|
76
76
|
|
@@ -115,41 +115,29 @@ contract Distribution is
|
|
115
115
|
return false;
|
116
116
|
}
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
118
|
+
function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
119
|
+
InstanceReader reader = getInstance().getInstanceReader();
|
120
|
+
setupInfo = reader.getDistributionSetupInfo(getNftId());
|
121
|
+
|
122
|
+
// fallback to initial setup info (wallet is always != address(0))
|
123
|
+
if(setupInfo.wallet == address(0)) {
|
124
|
+
setupInfo = _getInitialSetupInfo();
|
125
125
|
}
|
126
126
|
}
|
127
127
|
|
128
|
+
function _getInitialSetupInfo() internal view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
129
|
+
return ISetup.DistributionSetupInfo(
|
130
|
+
zeroNftId(),
|
131
|
+
_tokenHandler,
|
132
|
+
_initialDistributionFee,
|
133
|
+
_isVerifying,
|
134
|
+
address(this)
|
135
|
+
);
|
136
|
+
}
|
137
|
+
|
128
138
|
|
129
139
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
130
140
|
function isVerifying() external view returns (bool verifying) {
|
131
141
|
return _isVerifying;
|
132
142
|
}
|
133
|
-
|
134
|
-
// from IRegisterable
|
135
|
-
|
136
|
-
function getInitialInfo()
|
137
|
-
public
|
138
|
-
view
|
139
|
-
override (IRegisterable, Registerable)
|
140
|
-
returns(IRegistry.ObjectInfo memory, bytes memory)
|
141
|
-
{
|
142
|
-
(
|
143
|
-
IRegistry.ObjectInfo memory info,
|
144
|
-
bytes memory data
|
145
|
-
) = super.getInitialInfo();
|
146
|
-
|
147
|
-
return (
|
148
|
-
info,
|
149
|
-
abi.encode(
|
150
|
-
_initialDistributionFee,
|
151
|
-
_isVerifying
|
152
|
-
)
|
153
|
-
);
|
154
|
-
}
|
155
143
|
}
|
@@ -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,10 +2,14 @@
|
|
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} from "../types/Referral.sol";
|
6
8
|
import {NftId} from "../types/NftId.sol";
|
7
9
|
|
8
|
-
interface IDistributionComponent {
|
10
|
+
interface IDistributionComponent is IComponent {
|
11
|
+
|
12
|
+
function getSetupInfo() external view returns (ISetup.DistributionSetupInfo memory setupInfo);
|
9
13
|
|
10
14
|
function setFees(
|
11
15
|
Fee memory distributionFee
|
@@ -38,9 +42,6 @@ interface IDistributionComponent {
|
|
38
42
|
/// @dev returns true iff the referral id is valid
|
39
43
|
function referralIsValid(ReferralId referralId) external view returns (bool isValid);
|
40
44
|
|
41
|
-
/// @dev default distribution fee, ie when not using any valid referralId
|
42
|
-
function getDistributionFee() external view returns (Fee memory distributionFee);
|
43
|
-
|
44
45
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
45
46
|
function isVerifying() external view returns (bool verifying);
|
46
47
|
}
|
@@ -1,41 +1,39 @@
|
|
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 {ISetup} from "../instance/module/ISetup.sol";
|
7
|
+
import {NftId} from "../types/NftId.sol";
|
6
8
|
import {UFixed} from "../types/UFixed.sol";
|
7
9
|
|
8
|
-
|
10
|
+
/// @dev pool components hold and manage the collateral to cover active policies
|
11
|
+
/// pools come in different flavors
|
12
|
+
interface IPoolComponent is IComponent {
|
9
13
|
|
10
14
|
event LogUnderwrittenByPool(NftId policyNftId, uint256 collateralizationAmount, address pool);
|
11
15
|
|
16
|
+
error ErrorPoolNotPoolService(address service);
|
17
|
+
|
18
|
+
function getSetupInfo() external view returns (ISetup.PoolSetupInfo memory setupInfo);
|
19
|
+
|
12
20
|
function setFees(
|
13
21
|
Fee memory poolFee,
|
14
22
|
Fee memory stakingFee,
|
15
23
|
Fee memory performanceFee
|
16
24
|
) external;
|
17
25
|
|
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);
|
27
|
-
|
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
|
28
28
|
function setBundleFee(
|
29
|
-
NftId
|
29
|
+
NftId bundleNftId,
|
30
30
|
Fee memory fee
|
31
31
|
) external;
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
* by product related state changes.
|
38
|
-
*/
|
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.
|
39
37
|
function underwrite(
|
40
38
|
NftId policyNftId,
|
41
39
|
bytes memory policyData,
|
@@ -43,10 +41,31 @@ interface IPoolComponent {
|
|
43
41
|
uint256 collateralizationAmount
|
44
42
|
) external;
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
function lockBundle(NftId bundleNftId) external;
|
45
|
+
|
46
|
+
function unlockBundle(NftId bundleNftId) external;
|
47
|
+
|
48
|
+
/// @dev defines the multiplier to calculate the required collateral to cover a given sum insured amount
|
49
|
+
function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
|
50
|
+
|
51
|
+
/// @dev declares if pool intercept transfers of bundle nft ids
|
52
|
+
/// - yes: pool may block transfer of bundle ownership or simply updates some bookkeeping related to bundle ownership
|
53
|
+
/// - no: pool is not involved in transfer of bundle ownership
|
54
|
+
function isInterceptingBundleTransfers() external view returns (bool);
|
55
|
+
|
56
|
+
/// @dev declares if pool relies on external management of collateral (yes/no):
|
57
|
+
/// - 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
|
58
|
+
/// - no: the pool smart contract ensures that the necessary capacity of the pool prior to underwriting.
|
59
|
+
function isExternallyManaged() external view returns (bool);
|
60
|
+
|
61
|
+
/// @dev declares if pool component is actively involved in underwriting (yes/no):
|
62
|
+
/// - 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
|
63
|
+
/// - no: underwriting a policy does not require any interaction with the pool component if the covering bundle can provide the necessary captial
|
64
|
+
function isVerifyingApplications() external view returns (bool);
|
65
|
+
|
66
|
+
/// @dev returns true iff the policy application data in policyData matches
|
67
|
+
/// with the bundle filter criteria encoded in bundleFilter
|
68
|
+
/// this is a callback function that is only called if a pool declares itself as a verifying pool
|
50
69
|
function policyMatchesBundle(
|
51
70
|
bytes memory policyData,
|
52
71
|
bytes memory bundleFilter
|
@@ -55,10 +74,4 @@ interface IPoolComponent {
|
|
55
74
|
view
|
56
75
|
returns (bool isMatching);
|
57
76
|
|
58
|
-
function isVerifying() external view returns (bool verifying);
|
59
|
-
|
60
|
-
function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
|
61
|
-
|
62
|
-
function getFees() external view returns (Fee memory poolFee, Fee memory stakingFee, Fee memory performanceFee);
|
63
|
-
|
64
77
|
}
|
@@ -2,11 +2,15 @@
|
|
2
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
|
-
interface IProductComponent {
|
11
|
+
interface IProductComponent is IComponent {
|
12
|
+
|
13
|
+
function getSetupInfo() external view returns (ISetup.ProductSetupInfo memory setupInfo);
|
10
14
|
|
11
15
|
function setFees(
|
12
16
|
Fee memory productFee,
|
@@ -18,8 +22,8 @@ interface IProductComponent {
|
|
18
22
|
RiskId riskId,
|
19
23
|
uint256 lifetime,
|
20
24
|
bytes memory applicationData,
|
21
|
-
|
22
|
-
|
25
|
+
NftId bundleNftId,
|
26
|
+
ReferralId referralId
|
23
27
|
) external view returns (uint256 premiumAmount);
|
24
28
|
|
25
29
|
function calculateNetPremium(
|
@@ -29,9 +33,7 @@ interface IProductComponent {
|
|
29
33
|
bytes memory applicationData
|
30
34
|
) external view returns (uint256 netPremiumAmount);
|
31
35
|
|
32
|
-
|
33
|
-
function getProcessingFee() external view returns (Fee memory processingFee);
|
34
|
-
|
36
|
+
|
35
37
|
function getPoolNftId() external view returns (NftId poolNftId);
|
36
38
|
function getDistributionNftId() external view returns (NftId distributionNftId);
|
37
39
|
}
|