@etherisc/gif-next 0.0.2-e875d61-189 → 0.0.2-e922e07-736
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 +314 -27
 - package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
 - package/artifacts/contracts/components/Component.sol/Component.json +774 -0
 - package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
 - package/artifacts/contracts/components/Distribution.sol/Distribution.json +1261 -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} +234 -239
 - package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
 - package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +811 -0
 - package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
 - package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +804 -131
 - package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
 - package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +455 -62
 - package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
 - package/artifacts/contracts/components/Pool.sol/Pool.json +1192 -196
 - package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
 - package/artifacts/contracts/components/Product.sol/Product.json +865 -114
 - 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 +1556 -1003
 - package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
 - package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +509 -0
 - package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
 - package/artifacts/contracts/instance/Instance.sol/Instance.json +2282 -1171
 - 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 +1355 -0
 - package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
 - package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +1046 -0
 - package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +693 -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 +552 -0
 - package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
 - package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
 - package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
 - package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
 - package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +37 -245
 - package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
 - package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +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 +968 -0
 - package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +665 -0
 - package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1096 -0
 - package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +661 -0
 - package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +754 -0
 - package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +637 -0
 - package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1724 -0
 - package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +801 -0
 - package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +556 -0
 - package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +633 -0
 - package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
 - package/artifacts/contracts/instance/{base/InstanceBase.sol/InstanceBase.json → service/IClaimService.sol/IClaimService.json} +221 -156
 - package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +1013 -0
 - package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +540 -0
 - package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
 - package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +136 -165
 - package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
 - package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +139 -232
 - package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1021 -0
 - package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +689 -0
 - package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
 - package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +416 -160
 - package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +649 -0
 - package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
 - package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +401 -297
 - package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +649 -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 +890 -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 +1177 -0
 - package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
 - package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +670 -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 +498 -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} +38 -74
 - package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
 - package/artifacts/contracts/{instance/module/component/IComponent.sol/IComponentModule.json → shared/IPolicyHolder.sol/IPolicyHolder.json} +66 -73
 - package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
 - package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +100 -33
 - package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
 - package/artifacts/contracts/{experiment/inheritance/IB.sol/IB.json → shared/IRegistryLinked.sol/IRegistryLinked.json} +18 -20
 - package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
 - package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/IService.sol/IService.json} +121 -152
 - package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
 - package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +16 -125
 - package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
 - package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +251 -0
 - package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
 - package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +248 -0
 - package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
 - package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +582 -0
 - package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
 - package/artifacts/contracts/shared/Registerable.sol/Registerable.json +256 -25
 - package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
 - package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +84 -0
 - package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
 - package/artifacts/contracts/{instance/service/IComponentOwnerService.sol/IComponentOwnerService.json → shared/Service.sol/Service.json} +220 -159
 - 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 +29 -115
 - 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 +272 -26
 - 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 +281 -139
 - 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 +38 -140
 - 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/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
 - package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +100 -0
 - 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/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
 - package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +100 -0
 - package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
 - package/artifacts/contracts/types/Referral.sol/ReferralLib.json +142 -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/Seconds.sol/SecondsLib.dbg.json +4 -0
 - package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
 - package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
 - package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
 - package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
 - package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +38 -7
 - package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
 - package/artifacts/contracts/{experiment/types/TypeB.sol/TypeBLib.json → types/UFixed.sol/MathLib.json} +4 -4
 - 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 +221 -0
 - package/contracts/components/Distribution.sol +280 -0
 - package/contracts/components/IComponent.sol +68 -0
 - package/contracts/components/IDistributionComponent.sol +71 -0
 - package/contracts/components/IPoolComponent.sol +136 -42
 - package/contracts/components/IProductComponent.sol +30 -9
 - package/contracts/components/Pool.sol +308 -121
 - package/contracts/components/Product.sol +211 -56
 - package/contracts/instance/BundleManager.sol +125 -0
 - package/contracts/instance/Cloneable.sol +46 -0
 - package/contracts/instance/IInstance.sol +85 -43
 - package/contracts/instance/IInstanceService.sol +59 -0
 - package/contracts/instance/Instance.sol +277 -57
 - package/contracts/instance/InstanceAccessManager.sol +297 -0
 - package/contracts/instance/InstanceReader.sol +293 -0
 - package/contracts/instance/InstanceService.sol +489 -0
 - package/contracts/instance/InstanceServiceManager.sol +54 -0
 - package/contracts/instance/ObjectManager.sol +84 -0
 - package/contracts/instance/base/ComponentService.sol +134 -0
 - package/contracts/instance/base/IKeyValueStore.sol +13 -14
 - package/contracts/instance/base/ILifecycle.sol +3 -3
 - package/contracts/instance/base/KeyValueStore.sol +49 -38
 - package/contracts/instance/base/Lifecycle.sol +11 -3
 - package/contracts/instance/module/IAccess.sol +47 -0
 - package/contracts/instance/module/IBundle.sol +21 -0
 - package/contracts/instance/module/IDistribution.sol +41 -0
 - package/contracts/instance/module/IPolicy.sol +72 -0
 - package/contracts/instance/module/IRisk.sol +11 -0
 - package/contracts/instance/module/ISetup.sol +46 -0
 - package/contracts/instance/module/ITreasury.sol +23 -0
 - package/contracts/instance/service/ApplicationService.sol +349 -0
 - package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
 - package/contracts/instance/service/BundleService.sol +299 -0
 - package/contracts/instance/service/BundleServiceManager.sol +51 -0
 - package/contracts/instance/service/ClaimService.sol +151 -0
 - package/contracts/instance/service/ClaimServiceManager.sol +35 -0
 - package/contracts/instance/service/DistributionService.sol +450 -0
 - package/contracts/instance/service/DistributionServiceManager.sol +51 -0
 - package/contracts/instance/service/IApplicationService.sol +82 -0
 - package/contracts/instance/service/IBundleService.sol +55 -0
 - package/contracts/instance/service/IClaimService.sol +61 -0
 - package/contracts/instance/service/IDistributionService.sol +98 -0
 - package/contracts/instance/service/IPolicyService.sol +72 -0
 - package/contracts/instance/service/IPoolService.sol +8 -18
 - package/contracts/instance/service/IProductService.sol +21 -39
 - package/contracts/instance/service/PolicyService.sol +394 -0
 - package/contracts/instance/service/PolicyServiceManager.sol +54 -0
 - package/contracts/instance/service/PoolService.sol +77 -97
 - package/contracts/instance/service/PoolServiceManager.sol +51 -0
 - package/contracts/instance/service/ProductService.sol +168 -301
 - 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 +283 -0
 - package/contracts/registry/RegistryServiceManager.sol +62 -0
 - package/contracts/registry/ReleaseManager.sol +322 -0
 - package/contracts/registry/TokenRegistry.sol +116 -0
 - package/contracts/shared/ContractDeployerLib.sol +72 -0
 - package/contracts/shared/ERC165.sol +14 -8
 - package/contracts/shared/INftOwnable.sol +23 -0
 - package/contracts/shared/IPolicyHolder.sol +26 -0
 - package/contracts/shared/IRegisterable.sol +10 -19
 - package/contracts/shared/IRegistryLinked.sol +12 -0
 - package/contracts/shared/IService.sol +18 -0
 - package/contracts/shared/IVersionable.sol +38 -37
 - package/contracts/shared/NftOwnable.sol +120 -0
 - package/contracts/shared/PolicyHolder.sol +81 -0
 - package/contracts/shared/ProxyManager.sol +169 -0
 - package/contracts/shared/Registerable.sol +54 -66
 - package/contracts/shared/RegistryLinked.sol +48 -0
 - package/contracts/shared/Service.sol +58 -0
 - package/contracts/shared/TokenHandler.sol +27 -0
 - package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
 - package/contracts/shared/Versionable.sol +38 -68
 - package/contracts/test/TestFee.sol +2 -2
 - package/contracts/test/TestRegisterable.sol +5 -6
 - package/contracts/test/TestRoleId.sol +1 -1
 - package/contracts/test/TestService.sol +7 -14
 - package/contracts/types/ClaimId.sol +52 -0
 - 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 +44 -11
 - package/contracts/types/PayoutId.sol +54 -0
 - package/contracts/types/Referral.sol +89 -0
 - package/contracts/types/RiskId.sol +43 -0
 - package/contracts/types/RoleId.sol +67 -10
 - package/contracts/types/Seconds.sol +54 -0
 - package/contracts/types/StateId.sol +5 -1
 - package/contracts/types/Timestamp.sol +16 -13
 - 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/experiment/errors/Require.sol/Require.dbg.json +0 -4
 - package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
 - package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
 - package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
 - package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
 - package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
 - package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
 - package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
 - package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
 - package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
 - package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
 - package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
 - package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
 - package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
 - package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
 - package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
 - package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
 - package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
 - package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
 - package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
 - package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
 - package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
 - package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
 - package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
 - package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
 - package/artifacts/contracts/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 -81
 - 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/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/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/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
 - package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -523
 - 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 -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/components/BaseComponent.sol +0 -94
 - package/contracts/components/IBaseComponent.sol +0 -19
 - package/contracts/experiment/errors/Require.sol +0 -38
 - package/contracts/experiment/errors/Revert.sol +0 -44
 - package/contracts/experiment/inheritance/A.sol +0 -53
 - package/contracts/experiment/inheritance/B.sol +0 -28
 - package/contracts/experiment/inheritance/C.sol +0 -34
 - package/contracts/experiment/inheritance/IA.sol +0 -13
 - package/contracts/experiment/inheritance/IB.sol +0 -10
 - package/contracts/experiment/inheritance/IC.sol +0 -12
 - package/contracts/experiment/statemachine/Dummy.sol +0 -27
 - package/contracts/experiment/statemachine/ISM.sol +0 -25
 - package/contracts/experiment/statemachine/README.md +0 -112
 - package/contracts/experiment/statemachine/SM.sol +0 -57
 - package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
 - package/contracts/experiment/types/TypeA.sol +0 -47
 - package/contracts/experiment/types/TypeB.sol +0 -29
 - package/contracts/instance/IInstanceLinked.sol +0 -8
 - package/contracts/instance/base/ComponentServiceBase.sol +0 -42
 - package/contracts/instance/base/IInstanceBase.sol +0 -19
 - package/contracts/instance/base/IService.sol +0 -15
 - 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/ComponentOwnerService.sol +0 -155
 - 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 -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 
     | 
    
         
            -
            }
         
     |