@etherisc/gif-next 0.0.2-e875d61-189 → 0.0.2-eb13b47-989
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -26
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +168 -28
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +610 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +121 -28
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +152 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +74 -181
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +55 -177
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +389 -70
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +477 -71
- 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/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +114 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +1132 -0
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +1082 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +140 -1658
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +2426 -1125
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +930 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1283 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +755 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +432 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +224 -43
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +33 -1
- 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 +4 -4
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +211 -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/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +381 -77
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +177 -75
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/{base/ServiceBase.sol/ServiceBase.json → service/IDistributionService.sol/IDistributionService.json} +204 -58
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +235 -50
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +325 -51
- 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 +460 -38
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +872 -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 +563 -124
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1261 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +508 -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 +2 -2
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +117 -37
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.json +175 -54
- 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 +158 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +190 -37
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/InstanceBase.sol/InstanceBase.json → shared/RegisterableUpgradable.sol/RegisterableUpgradable.json} +188 -90
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/shared/Service.sol/Service.json +468 -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 +204 -36
- 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 +283 -62
- 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 +2 -2
- 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 +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +134 -8
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +15 -2
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +40 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/BaseComponent.sol +20 -28
- package/contracts/components/Distribution.sol +166 -0
- package/contracts/components/IBaseComponent.sol +8 -3
- package/contracts/components/IDistributionComponent.sol +43 -0
- package/contracts/components/IPoolComponent.sol +14 -9
- package/contracts/components/IProductComponent.sol +25 -9
- package/contracts/components/Pool.sol +108 -40
- package/contracts/components/Product.sol +209 -46
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/instance/AccessManagedSimple.sol +122 -0
- package/contracts/instance/AccessManagerSimple.sol +692 -0
- package/contracts/instance/IAccessManagerSimple.sol +391 -0
- package/contracts/instance/IInstance.sol +18 -40
- package/contracts/instance/IInstanceService.sol +30 -0
- package/contracts/instance/Instance.sol +427 -56
- package/contracts/instance/InstanceAccessManager.sol +288 -0
- package/contracts/instance/InstanceReader.sol +290 -0
- package/contracts/instance/InstanceService.sol +138 -0
- package/contracts/instance/InstanceServiceManager.sol +56 -0
- package/contracts/instance/base/ComponentServiceBase.sol +15 -8
- package/contracts/instance/base/IInstanceBase.sol +6 -2
- 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 +11 -3
- package/contracts/instance/module/IAccess.sol +38 -0
- package/contracts/instance/module/IBundle.sol +19 -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 +43 -0
- package/contracts/instance/module/ITreasury.sol +23 -0
- package/contracts/instance/service/ComponentOwnerService.sol +238 -76
- package/contracts/instance/service/IComponentOwnerService.sol +1 -3
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +8 -1
- package/contracts/instance/service/IProductService.sol +56 -7
- package/contracts/registry/ChainNft.sol +80 -37
- package/contracts/registry/IRegistry.sol +58 -25
- package/contracts/registry/IRegistryService.sol +35 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +354 -267
- package/contracts/registry/RegistryService.sol +444 -0
- package/contracts/registry/RegistryServiceManager.sol +64 -0
- package/contracts/shared/ContractDeployerLib.sol +72 -0
- package/contracts/shared/INftOwnable.sol +22 -0
- package/contracts/shared/IRegisterable.sol +8 -15
- package/contracts/{instance/base → shared}/IService.sol +3 -3
- package/contracts/shared/IVersionable.sol +55 -11
- package/contracts/shared/NftOwnable.sol +136 -0
- package/contracts/shared/ProxyManager.sol +94 -0
- package/contracts/shared/Registerable.sol +62 -59
- package/contracts/shared/RegisterableUpgradable.sol +16 -0
- package/contracts/shared/Service.sol +54 -0
- package/contracts/shared/TokenHandler.sol +27 -0
- package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
- package/contracts/shared/Versionable.sol +113 -55
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestRegisterable.sol +5 -6
- package/contracts/test/TestRoleId.sol +1 -1
- package/contracts/test/TestService.sol +5 -13
- package/contracts/types/DistributorType.sol +55 -0
- package/contracts/types/Fee.sol +10 -5
- package/contracts/types/Key32.sol +8 -3
- package/contracts/types/NumberId.sol +52 -0
- package/contracts/types/ObjectType.sol +40 -11
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RiskId.sol +43 -0
- package/contracts/types/RoleId.sol +54 -10
- package/contracts/types/StateId.sol +1 -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 +4 -3
- 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/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/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 -265
- 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 -265
- 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 -136
- 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 -136
- 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 -273
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -273
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -144
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -144
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -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 -531
- 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 -531
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +0 -471
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +0 -673
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -452
- 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 -455
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -436
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/experiment/statemachine/README.md +0 -112
- package/contracts/instance/IInstanceLinked.sol +0 -8
- package/contracts/instance/base/InstanceBase.sol +0 -84
- package/contracts/instance/base/ModuleBase.sol +0 -46
- 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 -135
- package/contracts/instance/module/bundle/IBundle.sol +0 -51
- package/contracts/instance/module/compensation/CompensationModule.sol +0 -17
- package/contracts/instance/module/compensation/ICompensation.sol +0 -10
- package/contracts/instance/module/component/ComponentModule.sol +0 -81
- package/contracts/instance/module/component/IComponent.sol +0 -29
- package/contracts/instance/module/policy/IPolicy.sol +0 -59
- package/contracts/instance/module/policy/PolicyModule.sol +0 -89
- package/contracts/instance/module/pool/IPoolModule.sol +0 -40
- package/contracts/instance/module/pool/PoolModule.sol +0 -90
- package/contracts/instance/module/risk/IRisk.sol +0 -10
- package/contracts/instance/module/risk/RiskModule.sol +0 -17
- package/contracts/instance/module/treasury/ITreasury.sol +0 -96
- package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
- package/contracts/instance/module/treasury/TreasuryModule.sol +0 -171
- package/contracts/instance/service/PoolService.sol +0 -129
- package/contracts/instance/service/ProductService.sol +0 -366
- 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 -24
- package/contracts/test/TestProduct.sol +0 -51
@@ -1,89 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IRegistry} from "../../../registry/IRegistry.sol";
|
5
|
-
|
6
|
-
import {IProductService} from "../../service/IProductService.sol";
|
7
|
-
import {IPolicy, IPolicyModule} from "./IPolicy.sol";
|
8
|
-
import {ObjectType, POLICY} from "../../../types/ObjectType.sol";
|
9
|
-
import {NftId, NftIdLib} from "../../../types/NftId.sol";
|
10
|
-
import {StateId} from "../../../types/StateId.sol";
|
11
|
-
import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
|
12
|
-
|
13
|
-
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
14
|
-
import {ModuleBase} from "../../base/ModuleBase.sol";
|
15
|
-
|
16
|
-
abstract contract PolicyModule is
|
17
|
-
ModuleBase,
|
18
|
-
IPolicyModule
|
19
|
-
{
|
20
|
-
|
21
|
-
// TODO find a better place to avoid dupliation
|
22
|
-
modifier onlyProductService2() {
|
23
|
-
require(
|
24
|
-
msg.sender == address(this.getProductService()),
|
25
|
-
"ERROR:POL-001:NOT_PRODUCT_SERVICE"
|
26
|
-
);
|
27
|
-
_;
|
28
|
-
}
|
29
|
-
|
30
|
-
function initializePolicyModule(IKeyValueStore keyValueStore) internal {
|
31
|
-
_initialize(keyValueStore);
|
32
|
-
}
|
33
|
-
|
34
|
-
function createPolicyInfo(
|
35
|
-
NftId policyNftId,
|
36
|
-
NftId productNftId,
|
37
|
-
uint256 sumInsuredAmount,
|
38
|
-
uint256 premiumAmount,
|
39
|
-
uint256 lifetime,
|
40
|
-
NftId bundleNftId
|
41
|
-
)
|
42
|
-
external
|
43
|
-
onlyProductService2
|
44
|
-
override
|
45
|
-
{
|
46
|
-
PolicyInfo memory info = PolicyInfo(
|
47
|
-
productNftId,
|
48
|
-
bundleNftId,
|
49
|
-
address(0), // beneficiary = policy nft holder
|
50
|
-
sumInsuredAmount,
|
51
|
-
premiumAmount,
|
52
|
-
0, // premium paid amount
|
53
|
-
lifetime,
|
54
|
-
"", // applicationData
|
55
|
-
"", // policyData
|
56
|
-
zeroTimestamp(), // activatedAt
|
57
|
-
zeroTimestamp(), // expiredAt
|
58
|
-
zeroTimestamp() // closedAt
|
59
|
-
);
|
60
|
-
|
61
|
-
_create(POLICY(), policyNftId, abi.encode(info));
|
62
|
-
}
|
63
|
-
|
64
|
-
function setPolicyInfo(NftId policyNftId, PolicyInfo memory info)
|
65
|
-
external
|
66
|
-
override
|
67
|
-
onlyProductService2
|
68
|
-
{
|
69
|
-
_updateData(POLICY(), policyNftId, abi.encode(info));
|
70
|
-
}
|
71
|
-
|
72
|
-
function updatePolicyState(NftId bundleNftId, StateId state)
|
73
|
-
external
|
74
|
-
override
|
75
|
-
onlyProductService2
|
76
|
-
{
|
77
|
-
_updateState(POLICY(), bundleNftId, state);
|
78
|
-
}
|
79
|
-
|
80
|
-
function getPolicyInfo(
|
81
|
-
NftId nftId
|
82
|
-
) external view returns (PolicyInfo memory info) {
|
83
|
-
return abi.decode(_getData(POLICY(), nftId), (PolicyInfo));
|
84
|
-
}
|
85
|
-
|
86
|
-
function getPolicyState(NftId nftId) external view override returns(StateId state) {
|
87
|
-
return _getState(POLICY(), nftId);
|
88
|
-
}
|
89
|
-
}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IRegistry} from "../../../registry/IRegistry.sol";
|
5
|
-
import {NftId} from "../../../types/NftId.sol";
|
6
|
-
import {UFixed} from "../../../types/UFixed.sol";
|
7
|
-
import {IProductService} from "../../service/IProductService.sol";
|
8
|
-
import {IPoolService} from "../../service/IPoolService.sol";
|
9
|
-
|
10
|
-
interface IPool {
|
11
|
-
struct PoolInfo {
|
12
|
-
bool isVerifying;
|
13
|
-
UFixed collateralizationLevel;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
interface IPoolModule is IPool {
|
18
|
-
|
19
|
-
function registerPool(
|
20
|
-
NftId poolNftId,
|
21
|
-
bool isVerifying,
|
22
|
-
UFixed collateralizationLevel
|
23
|
-
) external;
|
24
|
-
|
25
|
-
function addBundleToPool(
|
26
|
-
NftId bundleNftId,
|
27
|
-
NftId poolNftId,
|
28
|
-
uint256 amount
|
29
|
-
) external;
|
30
|
-
|
31
|
-
function getPoolInfo(
|
32
|
-
NftId nftId
|
33
|
-
) external view returns (PoolInfo memory info);
|
34
|
-
|
35
|
-
function getBundleCount(NftId poolNftId) external view returns (uint256 bundleCount);
|
36
|
-
function getBundleNftId(NftId poolNftId, uint256 index) external view returns (NftId bundleNftId);
|
37
|
-
|
38
|
-
// repeat service linked signatures to avoid linearization issues
|
39
|
-
function getPoolService() external returns(IPoolService);
|
40
|
-
}
|
@@ -1,90 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IRegistry} from "../../../registry/IRegistry.sol";
|
5
|
-
import {IProductService} from "../../service/IProductService.sol";
|
6
|
-
import {IPoolService} from "../../service/IPoolService.sol";
|
7
|
-
import {IPolicy, IPolicyModule} from "../../module/policy/IPolicy.sol";
|
8
|
-
import {ITreasuryModule} from "../../module/treasury/ITreasury.sol";
|
9
|
-
|
10
|
-
import {NftId} from "../../../types/NftId.sol";
|
11
|
-
import {POOL} from "../../../types/ObjectType.sol";
|
12
|
-
import {LibNftIdSet} from "../../../types/NftIdSet.sol";
|
13
|
-
import {StateId, APPLIED} from "../../../types/StateId.sol";
|
14
|
-
import {UFixed} from "../../../types/UFixed.sol";
|
15
|
-
|
16
|
-
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
17
|
-
import {IPoolModule} from "./IPoolModule.sol";
|
18
|
-
import {ModuleBase} from "../../base/ModuleBase.sol";
|
19
|
-
|
20
|
-
abstract contract PoolModule is
|
21
|
-
ModuleBase,
|
22
|
-
IPoolModule
|
23
|
-
{
|
24
|
-
using LibNftIdSet for LibNftIdSet.Set;
|
25
|
-
|
26
|
-
// mapping(NftId poolNftId => PoolInfo info) private _poolInfo;
|
27
|
-
mapping(NftId poolNftId => LibNftIdSet.Set bundles) private _bundlesForPool;
|
28
|
-
|
29
|
-
modifier poolServiceCallingPool() {
|
30
|
-
require(
|
31
|
-
msg.sender == address(this.getPoolService()),
|
32
|
-
"ERROR:PL-001:NOT_POOL_SERVICE"
|
33
|
-
);
|
34
|
-
_;
|
35
|
-
}
|
36
|
-
|
37
|
-
function initializePoolModule(IKeyValueStore keyValueStore) internal {
|
38
|
-
_initialize(keyValueStore);
|
39
|
-
}
|
40
|
-
|
41
|
-
function registerPool(
|
42
|
-
NftId nftId,
|
43
|
-
bool isVerifying,
|
44
|
-
UFixed collateralizationRate
|
45
|
-
)
|
46
|
-
public
|
47
|
-
override
|
48
|
-
{
|
49
|
-
PoolInfo memory info = PoolInfo(
|
50
|
-
isVerifying,
|
51
|
-
collateralizationRate
|
52
|
-
);
|
53
|
-
|
54
|
-
_create(POOL(), nftId, abi.encode(info));
|
55
|
-
}
|
56
|
-
|
57
|
-
function addBundleToPool(
|
58
|
-
NftId bundleNftId,
|
59
|
-
NftId poolNftId,
|
60
|
-
uint256 // amount
|
61
|
-
)
|
62
|
-
external
|
63
|
-
override
|
64
|
-
{
|
65
|
-
LibNftIdSet.Set storage bundleSet = _bundlesForPool[poolNftId];
|
66
|
-
require(
|
67
|
-
!bundleSet.contains(bundleNftId),
|
68
|
-
"ERROR:PL-020:BUNDLE_ALREADY_ADDED");
|
69
|
-
|
70
|
-
bundleSet.add(bundleNftId);
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
function getPoolInfo(
|
75
|
-
NftId nftId
|
76
|
-
) external view override returns (PoolInfo memory info) {
|
77
|
-
return abi.decode(_getData(POOL(), nftId), (PoolInfo));
|
78
|
-
}
|
79
|
-
|
80
|
-
|
81
|
-
function getBundleCount(NftId poolNftId) external view override returns (uint256 bundleCount) {
|
82
|
-
return _bundlesForPool[poolNftId].getLength();
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
function getBundleNftId(NftId poolNftId, uint256 index) external view override returns (NftId bundleNftId) {
|
87
|
-
return _bundlesForPool[poolNftId].getElementAt(index);
|
88
|
-
}
|
89
|
-
|
90
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IRiskModule} from "./IRisk.sol";
|
5
|
-
|
6
|
-
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
7
|
-
import {ModuleBase} from "../../base/ModuleBase.sol";
|
8
|
-
|
9
|
-
contract RiskModule is
|
10
|
-
ModuleBase,
|
11
|
-
IRiskModule
|
12
|
-
{
|
13
|
-
function initializeRiskModule(IKeyValueStore keyValueStore) internal {
|
14
|
-
_initialize(keyValueStore);
|
15
|
-
}
|
16
|
-
|
17
|
-
}
|
@@ -1,96 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
-
|
6
|
-
import {NftId} from "../../../types/NftId.sol";
|
7
|
-
import {UFixed} from "../../../types/UFixed.sol";
|
8
|
-
import {Fee} from "../../../types/Fee.sol";
|
9
|
-
|
10
|
-
import {TokenHandler} from "./TokenHandler.sol";
|
11
|
-
|
12
|
-
interface ITreasury {
|
13
|
-
// TODO add events
|
14
|
-
// TODO add errors
|
15
|
-
|
16
|
-
// treasury info is linked to product nft id
|
17
|
-
struct TreasuryInfo {
|
18
|
-
NftId compensationNftId;
|
19
|
-
NftId poolNftId;
|
20
|
-
IERC20Metadata token;
|
21
|
-
Fee commissionFee;
|
22
|
-
Fee policyFee;
|
23
|
-
Fee processingFee;
|
24
|
-
Fee stakingFee;
|
25
|
-
Fee performanceFee;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
interface ITreasuryModule is ITreasury {
|
30
|
-
|
31
|
-
function registerProductSetup(
|
32
|
-
NftId productNftId,
|
33
|
-
NftId distributorNftId,
|
34
|
-
NftId poolNftId,
|
35
|
-
IERC20Metadata token,
|
36
|
-
Fee memory policyFee,
|
37
|
-
Fee memory processingFee,
|
38
|
-
Fee memory stakingFee,
|
39
|
-
Fee memory performanceFee
|
40
|
-
) external;
|
41
|
-
|
42
|
-
function setTreasuryInfo(
|
43
|
-
NftId productNftId,
|
44
|
-
TreasuryInfo memory info
|
45
|
-
) external;
|
46
|
-
|
47
|
-
function getTreasuryInfo(
|
48
|
-
NftId productNftId
|
49
|
-
) external view returns (TreasuryInfo memory info);
|
50
|
-
|
51
|
-
// function setProductFees(
|
52
|
-
// NftId productNftId,
|
53
|
-
// Fee memory policyFee,
|
54
|
-
// Fee memory processingFee
|
55
|
-
// ) external;
|
56
|
-
|
57
|
-
// function setCompensationFees(
|
58
|
-
// NftId poolNftId,
|
59
|
-
// Fee memory distributionFee
|
60
|
-
// ) external;
|
61
|
-
|
62
|
-
// function setPoolFees(
|
63
|
-
// NftId poolNftId,
|
64
|
-
// Fee memory stakingFee,
|
65
|
-
// Fee memory performanceFee
|
66
|
-
// ) external;
|
67
|
-
|
68
|
-
function getProductNftId(
|
69
|
-
NftId componentNftId
|
70
|
-
) external view returns (NftId productNftId);
|
71
|
-
|
72
|
-
function getTokenHandler(
|
73
|
-
NftId componentNftId
|
74
|
-
) external view returns (TokenHandler tokenHandler);
|
75
|
-
|
76
|
-
function calculateFeeAmount(
|
77
|
-
uint256 amount,
|
78
|
-
Fee memory fee
|
79
|
-
) external pure returns (uint256 feeAmount, uint256 netAmount);
|
80
|
-
|
81
|
-
function getFee(
|
82
|
-
UFixed fractionalFee,
|
83
|
-
uint256 fixedFee
|
84
|
-
) external pure returns (Fee memory fee);
|
85
|
-
|
86
|
-
function getZeroFee() external view returns (Fee memory fee);
|
87
|
-
|
88
|
-
function getUFixed(
|
89
|
-
uint256 a
|
90
|
-
) external pure returns (UFixed);
|
91
|
-
|
92
|
-
function getUFixed(
|
93
|
-
uint256 a,
|
94
|
-
int8 exp
|
95
|
-
) external pure returns (UFixed);
|
96
|
-
}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
-
|
6
|
-
import {NftId} from "../../../types/NftId.sol";
|
7
|
-
|
8
|
-
contract TokenHandler {
|
9
|
-
NftId private _productNftId;
|
10
|
-
IERC20Metadata private _token;
|
11
|
-
|
12
|
-
constructor(
|
13
|
-
NftId productNftId,
|
14
|
-
address token
|
15
|
-
)
|
16
|
-
{
|
17
|
-
_productNftId = productNftId;
|
18
|
-
_token = IERC20Metadata(token);
|
19
|
-
}
|
20
|
-
|
21
|
-
// TODO add logging
|
22
|
-
function transfer(
|
23
|
-
address from,
|
24
|
-
address to,
|
25
|
-
uint256 amount
|
26
|
-
)
|
27
|
-
external // TODO add authz (only treasury/instance/product/pool/ service)
|
28
|
-
{
|
29
|
-
// TODO switch to oz safeTransferFrom
|
30
|
-
_token.transferFrom(from, to, amount);
|
31
|
-
}
|
32
|
-
|
33
|
-
function getProductNftId()
|
34
|
-
external
|
35
|
-
view
|
36
|
-
returns(NftId)
|
37
|
-
{
|
38
|
-
return _productNftId;
|
39
|
-
}
|
40
|
-
|
41
|
-
function getToken()
|
42
|
-
external
|
43
|
-
view
|
44
|
-
returns(IERC20Metadata)
|
45
|
-
{
|
46
|
-
return _token;
|
47
|
-
}
|
48
|
-
}
|
@@ -1,171 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
-
|
6
|
-
import {NftId} from "../../../types/NftId.sol";
|
7
|
-
import {TREASURY} from "../../../types/ObjectType.sol";
|
8
|
-
import {Fee, FeeLib} from "../../../types/Fee.sol";
|
9
|
-
import {UFixed, UFixedMathLib} from "../../../types/UFixed.sol";
|
10
|
-
import {TokenHandler} from "./TokenHandler.sol";
|
11
|
-
import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
|
12
|
-
import {ITreasuryModule} from "./ITreasury.sol";
|
13
|
-
import {ModuleBase} from "../../base/ModuleBase.sol";
|
14
|
-
|
15
|
-
abstract contract TreasuryModule is
|
16
|
-
ModuleBase,
|
17
|
-
ITreasuryModule
|
18
|
-
{
|
19
|
-
// relation of distributor and pool nft map to product nft
|
20
|
-
mapping(NftId componentNftId => NftId productNftId) internal _productNft;
|
21
|
-
// relation of component nft to token hanlder
|
22
|
-
mapping(NftId componentNftId => TokenHandler tokenHandler) internal _tokenHandler;
|
23
|
-
Fee internal _zeroFee;
|
24
|
-
|
25
|
-
|
26
|
-
function initializeTreasuryModule(IKeyValueStore keyValueStore) internal {
|
27
|
-
_initialize(keyValueStore);
|
28
|
-
_zeroFee = FeeLib.zeroFee();
|
29
|
-
}
|
30
|
-
|
31
|
-
function registerProductSetup(
|
32
|
-
NftId productNftId,
|
33
|
-
NftId compensationNftId,
|
34
|
-
NftId poolNftId,
|
35
|
-
IERC20Metadata token,
|
36
|
-
Fee memory policyFee,
|
37
|
-
Fee memory processingFee,
|
38
|
-
Fee memory stakingFee,
|
39
|
-
Fee memory performanceFee
|
40
|
-
) external override // TODO add authz (only component module)
|
41
|
-
{
|
42
|
-
require(address(_tokenHandler[productNftId]) == address(0), "ERROR:TRS-010:TOKEN_HANDLER_ALREADY_REGISTERED");
|
43
|
-
require(_productNft[compensationNftId].eqz(), "ERROR:TRS-011:COMPENSATION_ALREADY_LINKED");
|
44
|
-
require(_productNft[poolNftId].eqz(), "ERROR:TRS-012:POOL_ALREADY_LINKED");
|
45
|
-
|
46
|
-
// deploy product specific handler contract
|
47
|
-
TokenHandler tokenHandler = new TokenHandler(productNftId, address(token));
|
48
|
-
_tokenHandler[productNftId] = tokenHandler;
|
49
|
-
_productNft[compensationNftId] = productNftId;
|
50
|
-
_productNft[poolNftId] = productNftId;
|
51
|
-
|
52
|
-
TreasuryInfo memory info = TreasuryInfo(
|
53
|
-
compensationNftId,
|
54
|
-
poolNftId,
|
55
|
-
token,
|
56
|
-
_zeroFee,
|
57
|
-
policyFee,
|
58
|
-
processingFee,
|
59
|
-
stakingFee,
|
60
|
-
performanceFee
|
61
|
-
);
|
62
|
-
|
63
|
-
_create(TREASURY(), productNftId, abi.encode(info));
|
64
|
-
}
|
65
|
-
|
66
|
-
function setTreasuryInfo(
|
67
|
-
NftId productNftId,
|
68
|
-
TreasuryInfo memory info
|
69
|
-
)
|
70
|
-
external
|
71
|
-
// TODO add authz (only component module)
|
72
|
-
override
|
73
|
-
{
|
74
|
-
_updateData(TREASURY(), productNftId, abi.encode(info));
|
75
|
-
}
|
76
|
-
|
77
|
-
// function setProductFees(
|
78
|
-
// NftId productNftId,
|
79
|
-
// Fee memory policyFee,
|
80
|
-
// Fee memory processingFee
|
81
|
-
// ) external override // TODO add authz (only component owner service)
|
82
|
-
// {
|
83
|
-
// TreasuryInfo memory info = getTreasuryInfo(productNftId);
|
84
|
-
// require(address(info.token) != address(0), "ERROR:TRS-020:NOT_FOUND");
|
85
|
-
|
86
|
-
// info.policyFee = policyFee;
|
87
|
-
// info.processingFee = processingFee;
|
88
|
-
|
89
|
-
// _updateData(TREASURY(), productNftId, abi.encode(info));
|
90
|
-
// }
|
91
|
-
|
92
|
-
// function setCompensationFees(
|
93
|
-
// NftId compensationNftId,
|
94
|
-
// Fee memory distributionFee
|
95
|
-
// ) external override // TODO add authz (only component owner service)
|
96
|
-
// {
|
97
|
-
// NftId productNftId = _productNft[compensationNftId];
|
98
|
-
// TreasuryInfo memory info = getTreasuryInfo(productNftId);
|
99
|
-
// require(address(info.token) != address(0), "ERROR:TRS-030:NOT_FOUND");
|
100
|
-
|
101
|
-
// info.commissionFee = distributionFee;
|
102
|
-
|
103
|
-
// _updateData(TREASURY(), productNftId, abi.encode(info));
|
104
|
-
// }
|
105
|
-
|
106
|
-
// function setPoolFees(
|
107
|
-
// NftId poolNftId,
|
108
|
-
// Fee memory stakingFee,
|
109
|
-
// Fee memory performanceFee
|
110
|
-
// ) external override // TODO add authz (only component owner service)
|
111
|
-
// {
|
112
|
-
// NftId productNftId = _productNft[poolNftId];
|
113
|
-
// TreasuryInfo memory info = getTreasuryInfo(productNftId);
|
114
|
-
// require(address(info.token) != address(0), "ERROR:TRS-040:NOT_FOUND");
|
115
|
-
|
116
|
-
// info.stakingFee = stakingFee;
|
117
|
-
// info.performanceFee = performanceFee;
|
118
|
-
|
119
|
-
// _updateData(TREASURY(), productNftId, abi.encode(info));
|
120
|
-
// }
|
121
|
-
|
122
|
-
function getProductNftId(
|
123
|
-
NftId componentNftId
|
124
|
-
) external view returns (NftId productNftId) {
|
125
|
-
return _productNft[componentNftId];
|
126
|
-
}
|
127
|
-
|
128
|
-
function getTokenHandler(
|
129
|
-
NftId componentNftId
|
130
|
-
) external view override returns (TokenHandler tokenHandler) {
|
131
|
-
return _tokenHandler[componentNftId];
|
132
|
-
}
|
133
|
-
|
134
|
-
function getTreasuryInfo(
|
135
|
-
NftId productNftId
|
136
|
-
) public view override returns (TreasuryInfo memory info) {
|
137
|
-
return abi.decode(_getData(TREASURY(), productNftId), (TreasuryInfo));
|
138
|
-
}
|
139
|
-
|
140
|
-
function calculateFeeAmount(
|
141
|
-
uint256 amount,
|
142
|
-
Fee memory fee
|
143
|
-
) public pure override returns (uint256 feeAmount, uint256 netAmount) {
|
144
|
-
return FeeLib.calculateFee(amount, fee);
|
145
|
-
}
|
146
|
-
|
147
|
-
function getFee(
|
148
|
-
UFixed fractionalFee,
|
149
|
-
uint256 fixedFee
|
150
|
-
) external pure override returns (Fee memory fee) {
|
151
|
-
return FeeLib.toFee(fractionalFee, fixedFee);
|
152
|
-
}
|
153
|
-
|
154
|
-
function getZeroFee() external view override returns (Fee memory fee) {
|
155
|
-
return _zeroFee;
|
156
|
-
}
|
157
|
-
|
158
|
-
function getUFixed(
|
159
|
-
uint256 a
|
160
|
-
) external pure override returns (UFixed) {
|
161
|
-
return UFixedMathLib.toUFixed(a);
|
162
|
-
}
|
163
|
-
|
164
|
-
function getUFixed(
|
165
|
-
uint256 a,
|
166
|
-
int8 exp
|
167
|
-
) external pure returns (UFixed)
|
168
|
-
{
|
169
|
-
return UFixedMathLib.toUFixed(a, exp);
|
170
|
-
}
|
171
|
-
}
|
@@ -1,129 +0,0 @@
|
|
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 {ITreasury, ITreasuryModule, TokenHandler} from "../../instance/module/treasury/ITreasury.sol";
|
7
|
-
|
8
|
-
import {IVersionable} from "../../shared/IVersionable.sol";
|
9
|
-
import {Versionable} from "../../shared/Versionable.sol";
|
10
|
-
|
11
|
-
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
12
|
-
import {POOL, BUNDLE} from "../../types/ObjectType.sol";
|
13
|
-
import {Fee} from "../../types/Fee.sol";
|
14
|
-
import {Version, VersionLib} from "../../types/Version.sol";
|
15
|
-
|
16
|
-
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
17
|
-
import {IPoolService} from "./IPoolService.sol";
|
18
|
-
|
19
|
-
|
20
|
-
contract PoolService is ComponentServiceBase, IPoolService {
|
21
|
-
using NftIdLib for NftId;
|
22
|
-
|
23
|
-
string public constant NAME = "PoolService";
|
24
|
-
|
25
|
-
constructor(
|
26
|
-
address registry,
|
27
|
-
NftId registryNftId
|
28
|
-
) ComponentServiceBase(registry, registryNftId) // solhint-disable-next-line no-empty-blocks
|
29
|
-
{
|
30
|
-
_registerInterface(type(IPoolService).interfaceId);
|
31
|
-
}
|
32
|
-
|
33
|
-
function getVersion()
|
34
|
-
public
|
35
|
-
pure
|
36
|
-
virtual override (IVersionable, Versionable)
|
37
|
-
returns(Version)
|
38
|
-
{
|
39
|
-
return VersionLib.toVersion(3,0,0);
|
40
|
-
}
|
41
|
-
|
42
|
-
function getName() external pure override returns(string memory name) {
|
43
|
-
return NAME;
|
44
|
-
}
|
45
|
-
|
46
|
-
function setFees(
|
47
|
-
Fee memory stakingFee,
|
48
|
-
Fee memory performanceFee
|
49
|
-
)
|
50
|
-
external
|
51
|
-
override
|
52
|
-
{
|
53
|
-
(IRegistry.ObjectInfo memory poolInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
54
|
-
|
55
|
-
NftId productNftId = instance.getProductNftId(poolInfo.nftId);
|
56
|
-
ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productNftId);
|
57
|
-
treasuryInfo.stakingFee = stakingFee;
|
58
|
-
treasuryInfo.performanceFee = performanceFee;
|
59
|
-
instance.setTreasuryInfo(productNftId, treasuryInfo);
|
60
|
-
}
|
61
|
-
|
62
|
-
function createBundle(
|
63
|
-
address owner,
|
64
|
-
uint256 stakingAmount,
|
65
|
-
uint256 lifetime,
|
66
|
-
bytes calldata filter
|
67
|
-
)
|
68
|
-
external
|
69
|
-
override
|
70
|
-
returns(NftId bundleNftId)
|
71
|
-
{
|
72
|
-
(IRegistry.ObjectInfo memory info, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
73
|
-
|
74
|
-
// register bundle with registry
|
75
|
-
NftId poolNftId = info.nftId;
|
76
|
-
bundleNftId = _registry.registerObjectForInstance(
|
77
|
-
poolNftId,
|
78
|
-
BUNDLE(),
|
79
|
-
owner,
|
80
|
-
"");
|
81
|
-
|
82
|
-
// create bundle info in instance
|
83
|
-
instance.createBundleInfo(
|
84
|
-
bundleNftId,
|
85
|
-
poolNftId,
|
86
|
-
stakingAmount,
|
87
|
-
lifetime,
|
88
|
-
filter);
|
89
|
-
|
90
|
-
// add bundle to pool in instance
|
91
|
-
instance.addBundleToPool(
|
92
|
-
bundleNftId,
|
93
|
-
poolNftId,
|
94
|
-
stakingAmount);
|
95
|
-
|
96
|
-
// collect capital
|
97
|
-
_processStakingByTreasury(
|
98
|
-
instance,
|
99
|
-
poolNftId,
|
100
|
-
bundleNftId,
|
101
|
-
stakingAmount);
|
102
|
-
|
103
|
-
// TODO add logging
|
104
|
-
}
|
105
|
-
|
106
|
-
|
107
|
-
function _processStakingByTreasury(
|
108
|
-
IInstance instance,
|
109
|
-
NftId poolNftId,
|
110
|
-
NftId bundleNftId,
|
111
|
-
uint256 stakingAmount
|
112
|
-
)
|
113
|
-
internal
|
114
|
-
{
|
115
|
-
// process token transfer(s)
|
116
|
-
if(stakingAmount > 0) {
|
117
|
-
NftId productNftId = instance.getProductNftId(poolNftId);
|
118
|
-
TokenHandler tokenHandler = instance.getTokenHandler(productNftId);
|
119
|
-
address bundleOwner = _registry.getOwner(bundleNftId);
|
120
|
-
address poolWallet = instance.getComponentWallet(poolNftId);
|
121
|
-
|
122
|
-
tokenHandler.transfer(
|
123
|
-
bundleOwner,
|
124
|
-
poolWallet,
|
125
|
-
stakingAmount
|
126
|
-
);
|
127
|
-
}
|
128
|
-
}
|
129
|
-
}
|