@etherisc/gif-next 0.0.2-d3ee0cc-268 → 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 +314 -11
- 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 +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +1433 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{registry/IChainNft.sol/IChainNft.json → components/IComponent.sol/IComponent.json} +292 -224
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +950 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +614 -76
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +594 -60
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +1138 -159
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +1084 -99
- 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 +1539 -1018
- 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 +2262 -1095
- 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 +45 -127
- 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 +55 -245
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +4 -4
- 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/{access/IAccess.sol/IAccess.json → IDistribution.sol/IDistribution.json} +2 -2
- 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 +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1200 -0
- 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 +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +656 -0
- 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 +208 -72
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +217 -145
- 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 +570 -84
- 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 +546 -212
- 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/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +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 +44 -10
- 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 +52 -13
- 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 +4 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
- package/artifacts/contracts/types/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 +316 -0
- package/contracts/components/IComponent.sol +50 -0
- package/contracts/components/IDistributionComponent.sol +100 -0
- package/contracts/components/IPoolComponent.sol +65 -35
- package/contracts/components/IProductComponent.sol +29 -9
- package/contracts/components/Pool.sol +180 -100
- package/contracts/components/Product.sol +203 -42
- 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 +79 -45
- package/contracts/instance/IInstanceService.sol +59 -0
- package/contracts/instance/Instance.sol +266 -53
- 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 -13
- package/contracts/instance/base/ILifecycle.sol +3 -3
- package/contracts/instance/base/KeyValueStore.sol +53 -37
- package/contracts/instance/base/Lifecycle.sol +16 -11
- 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 +291 -0
- 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 +65 -0
- package/contracts/instance/service/IPolicyService.sol +88 -0
- package/contracts/instance/service/IPoolService.sol +8 -18
- package/contracts/instance/service/IProductService.sol +21 -39
- package/contracts/instance/service/PolicyService.sol +524 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +78 -92
- package/contracts/instance/service/PoolServiceManager.sol +51 -0
- package/contracts/instance/service/ProductService.sol +168 -289
- 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 -283
- 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 +2 -2
- package/contracts/test/TestService.sol +7 -14
- package/contracts/types/DistributorType.sol +55 -0
- package/contracts/types/Fee.sol +10 -5
- 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 +55 -14
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RiskId.sol +43 -0
- package/contracts/types/RoleId.sol +65 -11
- 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 -63
- 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 -326
- 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/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 -296
- 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 -296
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +0 -10
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +0 -4
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.json +0 -10
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.json +0 -10
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +0 -188
- 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 -188
- 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 -261
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -261
- 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 -149
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -149
- 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 -10
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -10
- 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 -533
- 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 -533
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -491
- 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/TestPool.sol/TestPool.dbg.json +0 -4
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -387
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -393
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/components/BaseComponent.sol +0 -88
- 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 -14
- package/contracts/instance/base/IService.sol +0 -15
- package/contracts/instance/base/InstanceBase.sol +0 -80
- package/contracts/instance/base/ModuleBase.sol +0 -52
- 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 -136
- package/contracts/instance/module/bundle/IBundle.sol +0 -58
- package/contracts/instance/module/compensation/CompensationModule.sol +0 -8
- package/contracts/instance/module/compensation/ICompensation.sol +0 -10
- package/contracts/instance/module/component/ComponentModule.sol +0 -95
- package/contracts/instance/module/component/IComponent.sol +0 -53
- package/contracts/instance/module/policy/IPolicy.sol +0 -60
- package/contracts/instance/module/policy/PolicyModule.sol +0 -76
- package/contracts/instance/module/pool/IPoolModule.sol +0 -41
- package/contracts/instance/module/pool/PoolModule.sol +0 -87
- package/contracts/instance/module/risk/IRisk.sol +0 -10
- package/contracts/instance/module/risk/RiskModule.sol +0 -8
- package/contracts/instance/module/treasury/ITreasury.sol +0 -103
- package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
- package/contracts/instance/module/treasury/TreasuryModule.sol +0 -152
- package/contracts/instance/service/ComponentOwnerService.sol +0 -170
- 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/TestPool.sol +0 -22
- package/contracts/test/TestProduct.sol +0 -44
@@ -0,0 +1,291 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
6
|
+
import {InstanceAccessManager} from "../InstanceAccessManager.sol";
|
7
|
+
import {InstanceReader} from "../../instance/InstanceReader.sol";
|
8
|
+
import {ISetup} from "../../instance/module/ISetup.sol";
|
9
|
+
|
10
|
+
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
11
|
+
import {Fee} from "../../types/Fee.sol";
|
12
|
+
import {DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
|
13
|
+
import {KEEP_STATE} from "../../types/StateId.sol";
|
14
|
+
import {ObjectType, DISTRIBUTION, INSTANCE, DISTRIBUTION, DISTRIBUTOR} from "../../types/ObjectType.sol";
|
15
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
16
|
+
|
17
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
18
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
19
|
+
|
20
|
+
import {IService} from "../../shared/IService.sol";
|
21
|
+
import {Service} from "../../shared/Service.sol";
|
22
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
23
|
+
import {InstanceService} from "../InstanceService.sol";
|
24
|
+
import {IComponent} from "../../components/IComponent.sol";
|
25
|
+
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
26
|
+
import {IDistributionService} from "./IDistributionService.sol";
|
27
|
+
|
28
|
+
import {UFixed} from "../../types/UFixed.sol";
|
29
|
+
import {DistributorType, DistributorTypeLib} from "../../types/DistributorType.sol";
|
30
|
+
import {ReferralId, ReferralStatus, ReferralLib} from "../../types/Referral.sol";
|
31
|
+
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
32
|
+
import {Key32} from "../../types/Key32.sol";
|
33
|
+
import {IDistribution} from "../module/IDistribution.sol";
|
34
|
+
|
35
|
+
|
36
|
+
contract DistributionService is
|
37
|
+
ComponentService,
|
38
|
+
IDistributionService
|
39
|
+
{
|
40
|
+
using NftIdLib for NftId;
|
41
|
+
using TimestampLib for Timestamp;
|
42
|
+
|
43
|
+
address internal _registryAddress;
|
44
|
+
|
45
|
+
function _initialize(
|
46
|
+
address owner,
|
47
|
+
bytes memory data
|
48
|
+
)
|
49
|
+
internal
|
50
|
+
initializer
|
51
|
+
virtual override
|
52
|
+
{
|
53
|
+
address initialOwner;
|
54
|
+
address registryAddress;
|
55
|
+
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
56
|
+
// TODO while DistributionService is not deployed in DistributionServiceManager constructor
|
57
|
+
// owner is DistributionServiceManager deployer
|
58
|
+
initializeService(registryAddress, owner);
|
59
|
+
registerInterface(type(IDistributionService).interfaceId);
|
60
|
+
}
|
61
|
+
|
62
|
+
function getDomain() public pure override(Service, IService) returns(ObjectType) {
|
63
|
+
return DISTRIBUTION();
|
64
|
+
}
|
65
|
+
|
66
|
+
function register(address distributionAddress)
|
67
|
+
external
|
68
|
+
returns(NftId distributionNftId)
|
69
|
+
{
|
70
|
+
(
|
71
|
+
IComponent component,
|
72
|
+
address owner,
|
73
|
+
IInstance instance,
|
74
|
+
NftId instanceNftId
|
75
|
+
) = _checkComponentForRegistration(
|
76
|
+
distributionAddress,
|
77
|
+
DISTRIBUTION(),
|
78
|
+
DISTRIBUTION_OWNER_ROLE());
|
79
|
+
|
80
|
+
IRegistry.ObjectInfo memory distributionInfo = getRegistryService().registerDistribution(component, owner);
|
81
|
+
IDistributionComponent distribution = IDistributionComponent(distributionAddress);
|
82
|
+
distribution.linkToRegisteredNftId();
|
83
|
+
distributionNftId = distributionInfo.nftId;
|
84
|
+
|
85
|
+
instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
|
86
|
+
getInstanceService().createGifTarget(instanceNftId, distributionAddress, distribution.getName());
|
87
|
+
getInstanceService().grantDistributionDefaultPermissions(instanceNftId, distributionAddress, distribution.getName());
|
88
|
+
}
|
89
|
+
|
90
|
+
function setFees(
|
91
|
+
Fee memory distributionFee
|
92
|
+
)
|
93
|
+
external
|
94
|
+
override
|
95
|
+
{
|
96
|
+
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
97
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
98
|
+
NftId distributionNftId = info.nftId;
|
99
|
+
|
100
|
+
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
101
|
+
distSetupInfo.distributionFee = distributionFee;
|
102
|
+
|
103
|
+
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
104
|
+
}
|
105
|
+
|
106
|
+
function createDistributorType(
|
107
|
+
string memory name,
|
108
|
+
UFixed minDiscountPercentage,
|
109
|
+
UFixed maxDiscountPercentage,
|
110
|
+
UFixed commissionPercentage,
|
111
|
+
uint32 maxReferralCount,
|
112
|
+
uint32 maxReferralLifetime,
|
113
|
+
bool allowSelfReferrals,
|
114
|
+
bool allowRenewals,
|
115
|
+
bytes memory data
|
116
|
+
)
|
117
|
+
external
|
118
|
+
returns (DistributorType distributorType)
|
119
|
+
{
|
120
|
+
(,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
121
|
+
distributorType = DistributorTypeLib.toDistributorType(distributionNftId, name);
|
122
|
+
Key32 key32 = distributorType.toKey32();
|
123
|
+
|
124
|
+
if(!instance.exists(key32)) {
|
125
|
+
IDistribution.DistributorTypeInfo memory info = IDistribution.DistributorTypeInfo(
|
126
|
+
name,
|
127
|
+
minDiscountPercentage,
|
128
|
+
maxDiscountPercentage,
|
129
|
+
commissionPercentage,
|
130
|
+
maxReferralCount,
|
131
|
+
maxReferralLifetime,
|
132
|
+
allowSelfReferrals,
|
133
|
+
allowRenewals,
|
134
|
+
data);
|
135
|
+
|
136
|
+
instance.createDistributorType(key32, info);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
function createDistributor(
|
141
|
+
address distributor,
|
142
|
+
DistributorType distributorType,
|
143
|
+
bytes memory data
|
144
|
+
) external returns (NftId distributorNftId)
|
145
|
+
{
|
146
|
+
(, NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
147
|
+
|
148
|
+
distributorNftId = getRegistryService().registerDistributor(
|
149
|
+
IRegistry.ObjectInfo(
|
150
|
+
zeroNftId(),
|
151
|
+
distributionNftId,
|
152
|
+
DISTRIBUTOR(),
|
153
|
+
true, // intercepting property for bundles is defined on pool
|
154
|
+
address(0),
|
155
|
+
distributor,
|
156
|
+
""
|
157
|
+
));
|
158
|
+
|
159
|
+
IDistribution.DistributorInfo memory info = IDistribution.DistributorInfo(
|
160
|
+
distributorType,
|
161
|
+
true, // active
|
162
|
+
data);
|
163
|
+
|
164
|
+
instance.createDistributor(distributorNftId, info);
|
165
|
+
}
|
166
|
+
|
167
|
+
function updateDistributorType(
|
168
|
+
NftId distributorNftId,
|
169
|
+
DistributorType distributorType,
|
170
|
+
bytes memory data
|
171
|
+
) external virtual
|
172
|
+
{
|
173
|
+
(,, IInstance instance) = _getAndVerifyCallingDistribution();
|
174
|
+
|
175
|
+
IDistribution.DistributorInfo memory info = IDistribution.DistributorInfo(
|
176
|
+
distributorType,
|
177
|
+
true, // active
|
178
|
+
data);
|
179
|
+
|
180
|
+
instance.updateDistributor(distributorNftId, info, KEEP_STATE());
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
function createReferral(
|
185
|
+
NftId distributorNftId,
|
186
|
+
string memory code,
|
187
|
+
UFixed discountPercentage,
|
188
|
+
uint32 maxReferrals,
|
189
|
+
Timestamp expiryAt,
|
190
|
+
bytes memory data
|
191
|
+
)
|
192
|
+
external
|
193
|
+
virtual
|
194
|
+
returns (ReferralId referralId)
|
195
|
+
{
|
196
|
+
(,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
197
|
+
require(bytes(code).length > 0, "ERROR:DSV-030:CODE_INVALID");
|
198
|
+
require(expiryAt > zeroTimestamp(), "ERROR:DSV-031:EXPIRY_AT_ZERO");
|
199
|
+
|
200
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
201
|
+
IDistribution.DistributorInfo memory distributorTypeInfo = instanceReader.getDistributorInfo(distributorNftId);
|
202
|
+
DistributorType distributorType = distributorTypeInfo.distributorType;
|
203
|
+
IDistribution.DistributorTypeInfo memory distributorTypeData = instanceReader.getDistributorTypeInfo(distributorType);
|
204
|
+
|
205
|
+
require(distributorTypeData.maxReferralCount >= maxReferrals, "ERROR:DSV-032:MAX_REFERRALS_EXCEEDED");
|
206
|
+
require(distributorTypeData.minDiscountPercentage <= discountPercentage, "ERROR:DSV-033:DISCOUNT_TOO_LOW");
|
207
|
+
require(distributorTypeData.maxDiscountPercentage >= discountPercentage, "ERROR:DSV-034:DISCOUNT_TOO_HIGH");
|
208
|
+
require(expiryAt.toInt() - TimestampLib.blockTimestamp().toInt() <= distributorTypeData.maxReferralLifetime, "ERROR:DSV-035:EXPIRY_TOO_LONG");
|
209
|
+
|
210
|
+
referralId = ReferralLib.toReferralId(distributionNftId, code);
|
211
|
+
IDistribution.ReferralInfo memory info = IDistribution.ReferralInfo(
|
212
|
+
distributorNftId,
|
213
|
+
code,
|
214
|
+
discountPercentage,
|
215
|
+
maxReferrals,
|
216
|
+
0, // used referrals
|
217
|
+
expiryAt,
|
218
|
+
data
|
219
|
+
);
|
220
|
+
|
221
|
+
instance.createReferral(referralId.toKey32(), info);
|
222
|
+
return referralId;
|
223
|
+
}
|
224
|
+
|
225
|
+
function processSale(
|
226
|
+
ReferralId referralId,
|
227
|
+
uint256 premiumAmount
|
228
|
+
)
|
229
|
+
external
|
230
|
+
virtual
|
231
|
+
{
|
232
|
+
// TODO: fetch referral
|
233
|
+
// TODO: if referral is active, process sale with condiutions of this referral
|
234
|
+
// TODO: if referral is not active, process sale with conditions of distribution component
|
235
|
+
revert("NOT_IMPLEMENTED_YET");
|
236
|
+
}
|
237
|
+
|
238
|
+
function calculateFeeAmount(
|
239
|
+
ReferralId referralId,
|
240
|
+
uint256 premiumAmount
|
241
|
+
)
|
242
|
+
external
|
243
|
+
virtual
|
244
|
+
view
|
245
|
+
returns (uint256 feeAmount)
|
246
|
+
{
|
247
|
+
revert("NOT_IMPLEMENTED_YET");
|
248
|
+
}
|
249
|
+
|
250
|
+
function _getAndVerifyCallingDistribution()
|
251
|
+
internal
|
252
|
+
view
|
253
|
+
returns(
|
254
|
+
address distributionAddress,
|
255
|
+
NftId distributionNftId,
|
256
|
+
IInstance instance
|
257
|
+
)
|
258
|
+
{
|
259
|
+
ObjectType objectType;
|
260
|
+
(
|
261
|
+
distributionAddress,
|
262
|
+
distributionNftId,
|
263
|
+
objectType,
|
264
|
+
instance
|
265
|
+
) = _getAndVerifyCaller();
|
266
|
+
|
267
|
+
require(objectType == DISTRIBUTION(), "ERROR:PRS-031:CALLER_NOT_DISTRUBUTION");
|
268
|
+
}
|
269
|
+
|
270
|
+
function _getAndVerifyCaller()
|
271
|
+
internal
|
272
|
+
view
|
273
|
+
returns(
|
274
|
+
address objectAddress,
|
275
|
+
NftId objectNftId,
|
276
|
+
ObjectType objectType,
|
277
|
+
IInstance instance
|
278
|
+
)
|
279
|
+
{
|
280
|
+
objectAddress = msg.sender;
|
281
|
+
objectNftId = getRegistry().getNftId(objectAddress);
|
282
|
+
require(objectNftId.gtz(), "ERROR:SRV-030:CALLER_UNKNOWN");
|
283
|
+
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
|
284
|
+
objectType = info.objectType;
|
285
|
+
|
286
|
+
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
287
|
+
require(parentInfo.objectType == INSTANCE(), "ERROR:SRV-031:PARENT_NOT_INSTANCE");
|
288
|
+
instance = IInstance(parentInfo.objectAddress);
|
289
|
+
}
|
290
|
+
|
291
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
5
|
+
import {ProxyManager} from "../../shared/ProxyManager.sol";
|
6
|
+
import {DistributionService} from "./DistributionService.sol";
|
7
|
+
import {Registry} from "../../registry/Registry.sol";
|
8
|
+
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
+
import {REGISTRY} from "../../types/ObjectType.sol";
|
10
|
+
|
11
|
+
contract DistributionServiceManager is ProxyManager {
|
12
|
+
|
13
|
+
DistributionService private _distributionService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with distribution service implementation and deploys instance
|
16
|
+
constructor(
|
17
|
+
address registryAddress
|
18
|
+
)
|
19
|
+
ProxyManager()
|
20
|
+
{
|
21
|
+
DistributionService distSrv = new DistributionService();
|
22
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
23
|
+
IVersionable versionable = deploy(
|
24
|
+
address(distSrv),
|
25
|
+
data);
|
26
|
+
|
27
|
+
_distributionService = DistributionService(address(versionable));
|
28
|
+
|
29
|
+
// TODO `thi` must have a role or own nft to register service
|
30
|
+
//Registry registry = Registry(registryAddress);
|
31
|
+
//address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _distributionService.getMajorVersion());
|
32
|
+
//RegistryService registryService = RegistryService(registryServiceAddress);
|
33
|
+
//registryService.registerService(_distributionService);
|
34
|
+
|
35
|
+
// TODO no nft to link yet
|
36
|
+
// link ownership of instance service manager ot nft owner of instance service
|
37
|
+
//_linkToNftOwnable(
|
38
|
+
// address(registryAddress),
|
39
|
+
// address(_distributionService));
|
40
|
+
}
|
41
|
+
|
42
|
+
//--- view functions ----------------------------------------------------//
|
43
|
+
function getDistributionService()
|
44
|
+
external
|
45
|
+
view
|
46
|
+
returns (DistributionService distributionService)
|
47
|
+
{
|
48
|
+
return _distributionService;
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRisk} from "../module/IRisk.sol";
|
5
|
+
import {IService} from "../../shared/IService.sol";
|
6
|
+
|
7
|
+
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {ReferralId} from "../../types/Referral.sol";
|
9
|
+
import {RiskId} from "../../types/RiskId.sol";
|
10
|
+
import {StateId} from "../../types/StateId.sol";
|
11
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
12
|
+
import {UFixed} from "../../types/UFixed.sol";
|
13
|
+
import {Fee} from "../../types/Fee.sol";
|
14
|
+
|
15
|
+
/// @dev gif service responsible for creating applications
|
16
|
+
/// only product components may call transaction functions
|
17
|
+
interface IApplicationService is IService {
|
18
|
+
|
19
|
+
error IApplicationServicePolicyNotApplied(NftId applicationNftId);
|
20
|
+
|
21
|
+
/// @dev creates a new application based on the specified attributes
|
22
|
+
/// may only be called by a product component
|
23
|
+
function create(
|
24
|
+
address applicationOwner,
|
25
|
+
RiskId riskId,
|
26
|
+
NftId bundleNftId,
|
27
|
+
ReferralId referralId,
|
28
|
+
uint256 sumInsuredAmount,
|
29
|
+
uint256 lifetime,
|
30
|
+
bytes memory applicationData
|
31
|
+
) external returns (NftId applicationNftId);
|
32
|
+
|
33
|
+
/// @dev updates application attributes
|
34
|
+
/// may only be called while the application is in applied state
|
35
|
+
/// may only be called by the referenced product related to applicationNftId
|
36
|
+
function ajust(
|
37
|
+
NftId applicationNftId,
|
38
|
+
RiskId riskId,
|
39
|
+
NftId bundleNftId,
|
40
|
+
ReferralId referralId,
|
41
|
+
uint256 sumInsuredAmount,
|
42
|
+
uint256 lifetime,
|
43
|
+
bytes memory applicationData
|
44
|
+
) external;
|
45
|
+
|
46
|
+
/// @dev creates a new application that extends the provided policy
|
47
|
+
/// lifetime will seamlessly extend referenced policy, for closed policies
|
48
|
+
/// lifetime will start at underwriting time
|
49
|
+
/// product will need to limit the time window for renewal as underwriting
|
50
|
+
/// will lock the collateral at underwriting time which might be earlier than activation time
|
51
|
+
/// policyNftId needs to refer to an underwritten (or active or closed) policy
|
52
|
+
/// may only be called by the referenced product related to policyNftId
|
53
|
+
function renew(
|
54
|
+
NftId policyNftId, // policy to be renewd (renewal inherits policy attributes)
|
55
|
+
NftId bundleNftId // will likely need a newer bundle for underwriting
|
56
|
+
) external returns (NftId applicationNftId);
|
57
|
+
|
58
|
+
/// @dev revokes the application represented by {policyNftId}
|
59
|
+
/// an application can only be revoked in applied state
|
60
|
+
/// only the application holder may revoke an application
|
61
|
+
function revoke(NftId policyNftId) external;
|
62
|
+
|
63
|
+
/// @dev calculates the premium amount for the specified attributes
|
64
|
+
/// also returns the various fee components involved with creating a policy
|
65
|
+
function calculatePremium(
|
66
|
+
RiskId riskId,
|
67
|
+
uint256 sumInsuredAmount,
|
68
|
+
uint256 lifetime,
|
69
|
+
bytes memory applicationData,
|
70
|
+
NftId bundleNftId,
|
71
|
+
ReferralId referralId
|
72
|
+
)
|
73
|
+
external
|
74
|
+
view
|
75
|
+
returns (
|
76
|
+
uint256 premiumAmount,
|
77
|
+
uint256 distributionFeeAmount,
|
78
|
+
uint256 productFeeAmount,
|
79
|
+
uint256 poolFeeAmount,
|
80
|
+
uint256 bundleFeeAmount
|
81
|
+
);
|
82
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {NftId} from "../../types/NftId.sol";
|
5
|
+
import {Fee} from "../../types/Fee.sol";
|
6
|
+
import {StateId} from "../../types/StateId.sol";
|
7
|
+
import {IService} from "../../shared/IService.sol";
|
8
|
+
import {IBundle} from "../module/IBundle.sol";
|
9
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
10
|
+
|
11
|
+
interface IBundleService is IService {
|
12
|
+
error ErrorIBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
13
|
+
|
14
|
+
function createBundle(
|
15
|
+
address owner,
|
16
|
+
Fee memory fee,
|
17
|
+
uint256 amount,
|
18
|
+
uint256 lifetime,
|
19
|
+
bytes calldata filter
|
20
|
+
) external returns(NftId bundleNftId);
|
21
|
+
|
22
|
+
function setBundleFee(
|
23
|
+
NftId bundleNftId,
|
24
|
+
Fee memory fee
|
25
|
+
) external;
|
26
|
+
|
27
|
+
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
28
|
+
|
29
|
+
function lockCollateral(
|
30
|
+
IInstance instanceNftId,
|
31
|
+
NftId policyNftId,
|
32
|
+
NftId bundleNftId,
|
33
|
+
uint256 collateralAmount,
|
34
|
+
uint256 netPremium
|
35
|
+
)
|
36
|
+
external
|
37
|
+
returns (
|
38
|
+
IBundle.BundleInfo memory bundleInfo
|
39
|
+
);
|
40
|
+
|
41
|
+
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
42
|
+
|
43
|
+
function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
|
44
|
+
|
45
|
+
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
46
|
+
|
47
|
+
// function defundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
48
|
+
|
49
|
+
function lockBundle(NftId bundleNftId) external;
|
50
|
+
|
51
|
+
function unlockBundle(NftId bundleNftId) external;
|
52
|
+
|
53
|
+
// function closeBundle(NftId bundleNftId) external;
|
54
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {NftId} from "../../types/NftId.sol";
|
5
|
+
import {Fee} from "../../types/Fee.sol";
|
6
|
+
import {IService} from "../../shared/IService.sol";
|
7
|
+
import {UFixed} from "../../types/UFixed.sol";
|
8
|
+
import {DistributorType} from "../../types/DistributorType.sol";
|
9
|
+
import {ReferralId} from "../../types/Referral.sol";
|
10
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
11
|
+
|
12
|
+
|
13
|
+
interface IDistributionService is IService {
|
14
|
+
function setFees(
|
15
|
+
Fee memory distributionFee
|
16
|
+
) external;
|
17
|
+
|
18
|
+
function createDistributorType(
|
19
|
+
string memory name,
|
20
|
+
UFixed minDiscountPercentage,
|
21
|
+
UFixed maxDiscountPercentage,
|
22
|
+
UFixed commissionPercentage,
|
23
|
+
uint32 maxReferralCount,
|
24
|
+
uint32 maxReferralLifetime,
|
25
|
+
bool allowSelfReferrals,
|
26
|
+
bool allowRenewals,
|
27
|
+
bytes memory data
|
28
|
+
)
|
29
|
+
external
|
30
|
+
returns (DistributorType distributorType);
|
31
|
+
|
32
|
+
function createDistributor(
|
33
|
+
address distributor,
|
34
|
+
DistributorType distributorType,
|
35
|
+
bytes memory data
|
36
|
+
) external returns (NftId distributorNftId);
|
37
|
+
|
38
|
+
function updateDistributorType(
|
39
|
+
NftId distributorNftId,
|
40
|
+
DistributorType distributorType,
|
41
|
+
bytes memory data
|
42
|
+
) external;
|
43
|
+
|
44
|
+
function createReferral(
|
45
|
+
NftId distributorNftId,
|
46
|
+
string memory code,
|
47
|
+
UFixed discountPercentage,
|
48
|
+
uint32 maxReferrals,
|
49
|
+
Timestamp expiryAt,
|
50
|
+
bytes memory data
|
51
|
+
)
|
52
|
+
external
|
53
|
+
returns (ReferralId referralId);
|
54
|
+
|
55
|
+
/// @dev callback from product service when selling a policy for a specific referralId
|
56
|
+
function processSale(
|
57
|
+
ReferralId referralId,
|
58
|
+
uint256 premiumAmount
|
59
|
+
) external;
|
60
|
+
|
61
|
+
function calculateFeeAmount(
|
62
|
+
ReferralId referralId,
|
63
|
+
uint256 premiumAmount
|
64
|
+
) external view returns (uint256 feeAmount);
|
65
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRisk} from "../module/IRisk.sol";
|
5
|
+
import {IService} from "../../shared/IService.sol";
|
6
|
+
|
7
|
+
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {ReferralId} from "../../types/Referral.sol";
|
9
|
+
import {RiskId} from "../../types/RiskId.sol";
|
10
|
+
import {StateId} from "../../types/StateId.sol";
|
11
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
12
|
+
import {UFixed} from "../../types/UFixed.sol";
|
13
|
+
import {Fee} from "../../types/Fee.sol";
|
14
|
+
|
15
|
+
interface IPolicyService is IService {
|
16
|
+
|
17
|
+
error ErrorIPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
18
|
+
error ErrorIPolicyServicePremiumAlreadyPaid(NftId policyNftId, uint256 premiumPaidAmount);
|
19
|
+
error ErrorIPolicyServicePolicyNotActivated(NftId policyNftId);
|
20
|
+
error ErrorIPolicyServicePolicyAlreadyClosed(NftId policyNftId);
|
21
|
+
error ErrorIPolicyServicePolicyNotActive(NftId policyNftId, StateId state);
|
22
|
+
error ErrorIPolicyServicePremiumNotFullyPaid(NftId policyNftId, uint256 premiumAmount, uint256 premiumPaidAmount);
|
23
|
+
error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
24
|
+
error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
25
|
+
|
26
|
+
function calculatePremium(
|
27
|
+
RiskId riskId,
|
28
|
+
uint256 sumInsuredAmount,
|
29
|
+
uint256 lifetime,
|
30
|
+
bytes memory applicationData,
|
31
|
+
NftId bundleNftId,
|
32
|
+
ReferralId referralId
|
33
|
+
)
|
34
|
+
external
|
35
|
+
view
|
36
|
+
returns (
|
37
|
+
uint256 premiumAmount,
|
38
|
+
uint256 productFeeAmount,
|
39
|
+
uint256 poolFeeAmount,
|
40
|
+
uint256 bundleFeeAmount,
|
41
|
+
uint256 distributionFeeAmount
|
42
|
+
);
|
43
|
+
|
44
|
+
|
45
|
+
function createApplication(
|
46
|
+
address applicationOwner,
|
47
|
+
RiskId riskId,
|
48
|
+
uint256 sumInsuredAmount,
|
49
|
+
uint256 lifetime,
|
50
|
+
bytes memory applicationData,
|
51
|
+
NftId bundleNftId,
|
52
|
+
ReferralId referralId
|
53
|
+
) external returns (NftId nftId);
|
54
|
+
|
55
|
+
/// @dev declines an application represented by {policyNftId}
|
56
|
+
/// an application can only be declined in applied state
|
57
|
+
/// only the related product may decline an application
|
58
|
+
function decline(NftId policyNftId) external;
|
59
|
+
|
60
|
+
/// @dev underwrites the policy represented by {policyNftId}.
|
61
|
+
/// optionally collects premiums and activates the policy.
|
62
|
+
/// - premium payment is only attempted if requirePremiumPayment is set to true
|
63
|
+
/// - activation is only done if activateAt is a non-zero timestamp
|
64
|
+
/// an application can only be underwritten in applied state
|
65
|
+
/// only the related product may underwrite an application
|
66
|
+
function underwrite(
|
67
|
+
NftId policyNftId,
|
68
|
+
bool requirePremiumPayment,
|
69
|
+
Timestamp activateAt
|
70
|
+
) external;
|
71
|
+
|
72
|
+
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
73
|
+
|
74
|
+
function activate(NftId policyNftId, Timestamp activateAt) external;
|
75
|
+
|
76
|
+
function close(NftId nftId) external;
|
77
|
+
|
78
|
+
// function createClaim(uint256 nftId, uint256 claimAmount) external;
|
79
|
+
// function confirmClaim(uint256 nftId, uint256 claimId, uint256 claimAmount) external;
|
80
|
+
// function declineClaim(uint256 nftId, uint256 claimId) external;
|
81
|
+
// function closeClaim(uint256 nftId, uint256 claimId) external; // TODO payoutClaim() -> implicit close when payed out in full
|
82
|
+
|
83
|
+
function calculateRequiredCollateral(
|
84
|
+
UFixed collateralizationLevel,
|
85
|
+
uint256 sumInsuredAmount
|
86
|
+
) external pure returns(uint256 collateralAmount);
|
87
|
+
|
88
|
+
}
|
@@ -3,28 +3,18 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../types/NftId.sol";
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {
|
6
|
+
import {StateId} from "../../types/StateId.sol";
|
7
|
+
import {IService} from "../../shared/IService.sol";
|
8
|
+
import {IBundle} from "../module/IBundle.sol";
|
9
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
7
10
|
|
8
11
|
interface IPoolService is IService {
|
12
|
+
|
13
|
+
function register(address poolAddress) external returns(NftId);
|
14
|
+
|
9
15
|
function setFees(
|
16
|
+
Fee memory poolFee,
|
10
17
|
Fee memory stakingFee,
|
11
18
|
Fee memory performanceFee
|
12
19
|
) external;
|
13
|
-
|
14
|
-
function createBundle(
|
15
|
-
address owner,
|
16
|
-
uint256 amount,
|
17
|
-
uint256 lifetime,
|
18
|
-
bytes calldata filter
|
19
|
-
) external returns(NftId bundleNftId);
|
20
|
-
|
21
|
-
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
22
|
-
|
23
|
-
// function defundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
24
|
-
|
25
|
-
// function lockBundle(NftId bundleNftId) external;
|
26
|
-
|
27
|
-
// function unlockBundle(NftId bundleNftId) external;
|
28
|
-
|
29
|
-
// function closeBundle(NftId bundleNftId) external;
|
30
20
|
}
|