@etherisc/gif-next 0.0.2-f2b0fa2-473 → 0.0.2-f4f484a-692
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 +140 -2
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +832 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +938 -229
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ComponentServiceBase.sol/ComponentServiceBase.json → components/IComponent.sol/IComponent.json} +192 -168
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +743 -26
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +755 -50
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +582 -9
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +818 -236
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +627 -224
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +778 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +91 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +2185 -189
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +299 -153
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +993 -1183
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +571 -177
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +232 -210
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +520 -190
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +352 -75
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +256 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/{shared/RegisterableUpgradable.sol/RegisterableUpgradable.json → instance/base/ComponentService.sol/ComponentService.json} +236 -126
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- 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 +40 -10
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +69 -43
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.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 +1093 -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 +1732 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +805 -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 +630 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/{IComponentOwnerService.sol/IComponentOwnerService.json → IClaimService.sol/IClaimService.json} +150 -207
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +727 -160
- 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 +84 -217
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +47 -414
- 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 +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +824 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +657 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +777 -0
- 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 +15 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +373 -61
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +234 -216
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +333 -188
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +229 -313
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +304 -138
- 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 +1 -1
- 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 +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +40 -29
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +21 -34
- 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 +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +31 -183
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -152
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +120 -27
- 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 +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +294 -61
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +129 -51
- 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 +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +127 -170
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -152
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +129 -51
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +148 -227
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +8 -190
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
- 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 +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +2 -2
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
- 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 +1 -1
- 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 +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- 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 +25 -7
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/Component.sol +251 -0
- package/contracts/components/Distribution.sol +200 -86
- package/contracts/components/IComponent.sol +74 -0
- package/contracts/components/IDistributionComponent.sol +44 -16
- package/contracts/components/IPoolComponent.sol +88 -37
- package/contracts/components/IProductComponent.sol +10 -5
- package/contracts/components/Pool.sol +217 -177
- package/contracts/components/Product.sol +130 -134
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +127 -0
- package/contracts/instance/Cloneable.sol +51 -0
- package/contracts/instance/IInstance.sol +81 -11
- package/contracts/instance/IInstanceService.sol +56 -1
- package/contracts/instance/Instance.sol +156 -265
- package/contracts/instance/InstanceAccessManager.sol +410 -176
- package/contracts/instance/InstanceReader.sol +39 -29
- package/contracts/instance/InstanceService.sol +448 -55
- package/contracts/instance/InstanceServiceManager.sol +11 -13
- package/contracts/instance/ObjectManager.sol +82 -0
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/base/KeyValueStore.sol +5 -2
- package/contracts/instance/base/Lifecycle.sol +11 -2
- package/contracts/instance/module/IAccess.sol +36 -20
- package/contracts/instance/module/IBundle.sol +2 -0
- package/contracts/instance/module/IComponents.sol +35 -0
- package/contracts/instance/module/IDistribution.sol +2 -0
- package/contracts/instance/module/IPolicy.sol +30 -3
- package/contracts/instance/module/ISetup.sol +9 -19
- package/contracts/instance/service/ApplicationService.sol +350 -0
- package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
- package/contracts/instance/service/BundleService.sol +336 -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 +467 -0
- package/contracts/instance/service/DistributionServiceManager.sol +51 -0
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +62 -0
- package/contracts/instance/service/IClaimService.sol +61 -0
- package/contracts/instance/service/IDistributionService.sol +86 -0
- package/contracts/instance/service/IPolicyService.sol +72 -0
- package/contracts/instance/service/IPoolService.sol +21 -23
- package/contracts/instance/service/IProductService.sol +6 -73
- package/contracts/instance/service/PolicyService.sol +403 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +220 -0
- package/contracts/instance/service/PoolServiceManager.sol +51 -0
- package/contracts/instance/service/ProductService.sol +241 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +9 -1
- package/contracts/registry/IRegistry.sol +52 -8
- package/contracts/registry/IRegistryService.sol +46 -14
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +270 -226
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +110 -266
- package/contracts/registry/RegistryServiceManager.sol +24 -26
- package/contracts/registry/ReleaseManager.sol +322 -0
- package/contracts/registry/TokenRegistry.sol +116 -0
- package/contracts/shared/ERC165.sol +14 -8
- package/contracts/shared/INftOwnable.sol +11 -10
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +4 -6
- package/contracts/shared/IRegistryLinked.sol +12 -0
- package/contracts/shared/IService.sol +4 -1
- package/contracts/shared/IVersionable.sol +4 -47
- package/contracts/shared/NftOwnable.sol +67 -83
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +100 -25
- package/contracts/shared/Registerable.sol +16 -31
- package/contracts/shared/RegistryLinked.sol +48 -0
- package/contracts/shared/Service.sol +26 -22
- package/contracts/shared/TokenHandler.sol +11 -5
- package/contracts/shared/Versionable.sol +4 -92
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestService.sol +4 -3
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/ClaimId.sol +52 -0
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/Fee.sol +1 -0
- package/contracts/types/NftId.sol +8 -0
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/ObjectType.sol +10 -5
- package/contracts/types/PayoutId.sol +54 -0
- package/contracts/types/Referral.sol +4 -0
- package/contracts/types/RoleId.sol +26 -11
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/StateId.sol +5 -0
- package/contracts/types/Timestamp.sol +13 -13
- package/contracts/types/UFixed.sol +1 -0
- package/contracts/types/Version.sol +5 -1
- package/package.json +3 -3
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -314
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -267
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +0 -66
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +0 -24
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +0 -42
- 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/experiment/types/TypeB.sol/TypeBLib.json +0 -10
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1119
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/contracts/components/BaseComponent.sol +0 -86
- package/contracts/components/IBaseComponent.sol +0 -24
- package/contracts/experiment/cloning/Cloner.sol +0 -47
- 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/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/AccessManagedSimple.sol +0 -114
- package/contracts/instance/AccessManagerSimple.sol +0 -682
- package/contracts/instance/IAccessManagerSimple.sol +0 -391
- package/contracts/instance/base/ComponentServiceBase.sol +0 -49
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -317
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -0,0 +1,467 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
6
|
+
import {InstanceAccessManager} from "../InstanceAccessManager.sol";
|
7
|
+
import {InstanceReader} from "../../instance/InstanceReader.sol";
|
8
|
+
import {ISetup} from "../../instance/module/ISetup.sol";
|
9
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
10
|
+
|
11
|
+
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
12
|
+
import {Fee, FeeLib} from "../../types/Fee.sol";
|
13
|
+
import {PRODUCT_SERVICE_ROLE, DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
|
14
|
+
import {KEEP_STATE} from "../../types/StateId.sol";
|
15
|
+
import {ObjectType, DISTRIBUTION, INSTANCE, DISTRIBUTION, DISTRIBUTOR} from "../../types/ObjectType.sol";
|
16
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
17
|
+
import {RoleId} from "../../types/RoleId.sol";
|
18
|
+
|
19
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
20
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
21
|
+
|
22
|
+
import {IService} from "../../shared/IService.sol";
|
23
|
+
import {Service} from "../../shared/Service.sol";
|
24
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
25
|
+
import {InstanceService} from "../InstanceService.sol";
|
26
|
+
import {IComponent} from "../../components/IComponent.sol";
|
27
|
+
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
28
|
+
import {IDistributionService} from "./IDistributionService.sol";
|
29
|
+
|
30
|
+
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
31
|
+
import {DistributorType, DistributorTypeLib} from "../../types/DistributorType.sol";
|
32
|
+
import {ReferralId, ReferralStatus, ReferralLib} from "../../types/Referral.sol";
|
33
|
+
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
34
|
+
import {Key32} from "../../types/Key32.sol";
|
35
|
+
import {IDistribution} from "../module/IDistribution.sol";
|
36
|
+
|
37
|
+
|
38
|
+
contract DistributionService is
|
39
|
+
ComponentService,
|
40
|
+
IDistributionService
|
41
|
+
{
|
42
|
+
using NftIdLib for NftId;
|
43
|
+
using TimestampLib for Timestamp;
|
44
|
+
using UFixedLib for UFixed;
|
45
|
+
using FeeLib for Fee;
|
46
|
+
using ReferralLib for ReferralId;
|
47
|
+
|
48
|
+
address internal _registryAddress;
|
49
|
+
|
50
|
+
function _initialize(
|
51
|
+
address owner,
|
52
|
+
bytes memory data
|
53
|
+
)
|
54
|
+
internal
|
55
|
+
initializer
|
56
|
+
virtual override
|
57
|
+
{
|
58
|
+
address initialOwner;
|
59
|
+
address registryAddress;
|
60
|
+
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
61
|
+
// TODO while DistributionService is not deployed in DistributionServiceManager constructor
|
62
|
+
// owner is DistributionServiceManager deployer
|
63
|
+
initializeService(registryAddress, owner);
|
64
|
+
registerInterface(type(IDistributionService).interfaceId);
|
65
|
+
}
|
66
|
+
|
67
|
+
function getDomain() public pure override(Service, IService) returns(ObjectType) {
|
68
|
+
return DISTRIBUTION();
|
69
|
+
}
|
70
|
+
|
71
|
+
function register(address distributionAddress)
|
72
|
+
external
|
73
|
+
returns(NftId distributionNftId)
|
74
|
+
{
|
75
|
+
(
|
76
|
+
IComponent component,
|
77
|
+
address owner,
|
78
|
+
IInstance instance,
|
79
|
+
NftId instanceNftId
|
80
|
+
) = _checkComponentForRegistration(
|
81
|
+
distributionAddress,
|
82
|
+
DISTRIBUTION(),
|
83
|
+
DISTRIBUTION_OWNER_ROLE());
|
84
|
+
|
85
|
+
IRegistry.ObjectInfo memory distributionInfo = getRegistryService().registerDistribution(component, owner);
|
86
|
+
IDistributionComponent distribution = IDistributionComponent(distributionAddress);
|
87
|
+
distribution.linkToRegisteredNftId();
|
88
|
+
distributionNftId = distributionInfo.nftId;
|
89
|
+
|
90
|
+
instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
|
91
|
+
// TODO move to distribution?
|
92
|
+
bytes4[][] memory selectors = new bytes4[][](2);
|
93
|
+
selectors[0] = new bytes4[](1);
|
94
|
+
selectors[1] = new bytes4[](2);
|
95
|
+
|
96
|
+
selectors[0][0] = IDistributionComponent.setFees.selector;
|
97
|
+
selectors[1][0] = IDistributionComponent.processRenewal.selector;
|
98
|
+
|
99
|
+
RoleId[] memory roles = new RoleId[](2);
|
100
|
+
roles[0] = DISTRIBUTION_OWNER_ROLE();
|
101
|
+
roles[1] = PRODUCT_SERVICE_ROLE();
|
102
|
+
|
103
|
+
getInstanceService().createGifTarget(
|
104
|
+
instanceNftId,
|
105
|
+
distributionAddress,
|
106
|
+
distribution.getName(),
|
107
|
+
selectors,
|
108
|
+
roles);
|
109
|
+
}
|
110
|
+
|
111
|
+
function setFees(
|
112
|
+
Fee memory minDistributionOwnerFee,
|
113
|
+
Fee memory distributionFee
|
114
|
+
)
|
115
|
+
external
|
116
|
+
override
|
117
|
+
{
|
118
|
+
if (minDistributionOwnerFee.fractionalFee > distributionFee.fractionalFee) {
|
119
|
+
revert ErrorIDistributionServiceMinFeeTooHigh(minDistributionOwnerFee.fractionalFee.toInt(), distributionFee.fractionalFee.toInt());
|
120
|
+
}
|
121
|
+
|
122
|
+
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
123
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
124
|
+
NftId distributionNftId = info.nftId;
|
125
|
+
|
126
|
+
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
127
|
+
distSetupInfo.minDistributionOwnerFee = minDistributionOwnerFee;
|
128
|
+
distSetupInfo.distributionFee = distributionFee;
|
129
|
+
|
130
|
+
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
131
|
+
}
|
132
|
+
|
133
|
+
function createDistributorType(
|
134
|
+
string memory name,
|
135
|
+
UFixed minDiscountPercentage,
|
136
|
+
UFixed maxDiscountPercentage,
|
137
|
+
UFixed commissionPercentage,
|
138
|
+
uint32 maxReferralCount,
|
139
|
+
uint32 maxReferralLifetime,
|
140
|
+
bool allowSelfReferrals,
|
141
|
+
bool allowRenewals,
|
142
|
+
bytes memory data
|
143
|
+
)
|
144
|
+
external
|
145
|
+
returns (DistributorType distributorType)
|
146
|
+
{
|
147
|
+
(,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
148
|
+
|
149
|
+
{
|
150
|
+
ISetup.DistributionSetupInfo memory setupInfo = instance.getInstanceReader().getDistributionSetupInfo(distributionNftId);
|
151
|
+
UFixed variableFeesPartsTotal = setupInfo.minDistributionOwnerFee.fractionalFee.add(commissionPercentage);
|
152
|
+
UFixed maxDiscountPercentageLimit = setupInfo.distributionFee.fractionalFee.sub(variableFeesPartsTotal);
|
153
|
+
if (maxDiscountPercentage.gt(maxDiscountPercentageLimit)) {
|
154
|
+
revert ErrorIDistributionServiceMaxDiscountTooHigh(maxDiscountPercentage.toInt(), maxDiscountPercentageLimit.toInt());
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
distributorType = DistributorTypeLib.toDistributorType(distributionNftId, name);
|
159
|
+
Key32 key32 = distributorType.toKey32();
|
160
|
+
|
161
|
+
if(!instance.exists(key32)) {
|
162
|
+
IDistribution.DistributorTypeInfo memory info = IDistribution.DistributorTypeInfo(
|
163
|
+
name,
|
164
|
+
minDiscountPercentage,
|
165
|
+
maxDiscountPercentage,
|
166
|
+
commissionPercentage,
|
167
|
+
maxReferralCount,
|
168
|
+
maxReferralLifetime,
|
169
|
+
allowSelfReferrals,
|
170
|
+
allowRenewals,
|
171
|
+
data);
|
172
|
+
|
173
|
+
instance.createDistributorType(key32, info);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
function createDistributor(
|
178
|
+
address distributor,
|
179
|
+
DistributorType distributorType,
|
180
|
+
bytes memory data
|
181
|
+
) external returns (NftId distributorNftId)
|
182
|
+
{
|
183
|
+
(, NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
184
|
+
|
185
|
+
distributorNftId = getRegistryService().registerDistributor(
|
186
|
+
IRegistry.ObjectInfo(
|
187
|
+
zeroNftId(),
|
188
|
+
distributionNftId,
|
189
|
+
DISTRIBUTOR(),
|
190
|
+
true, // intercepting property for bundles is defined on pool
|
191
|
+
address(0),
|
192
|
+
distributor,
|
193
|
+
""
|
194
|
+
));
|
195
|
+
|
196
|
+
IDistribution.DistributorInfo memory info = IDistribution.DistributorInfo(
|
197
|
+
distributorType,
|
198
|
+
true, // active
|
199
|
+
data,
|
200
|
+
0,
|
201
|
+
0);
|
202
|
+
|
203
|
+
instance.createDistributor(distributorNftId, info);
|
204
|
+
}
|
205
|
+
|
206
|
+
function updateDistributorType(
|
207
|
+
NftId distributorNftId,
|
208
|
+
DistributorType distributorType,
|
209
|
+
bytes memory data
|
210
|
+
) external virtual
|
211
|
+
{
|
212
|
+
(,, IInstance instance) = _getAndVerifyCallingDistribution();
|
213
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
214
|
+
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
215
|
+
distributorInfo.distributorType = distributorType;
|
216
|
+
distributorInfo.data = data;
|
217
|
+
instance.updateDistributor(distributorNftId, distributorInfo, KEEP_STATE());
|
218
|
+
}
|
219
|
+
|
220
|
+
|
221
|
+
function createReferral(
|
222
|
+
NftId distributorNftId,
|
223
|
+
string memory code,
|
224
|
+
UFixed discountPercentage,
|
225
|
+
uint32 maxReferrals,
|
226
|
+
Timestamp expiryAt,
|
227
|
+
bytes memory data
|
228
|
+
)
|
229
|
+
external
|
230
|
+
virtual
|
231
|
+
returns (ReferralId referralId)
|
232
|
+
{
|
233
|
+
(,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
234
|
+
|
235
|
+
if (bytes(code).length == 0) {
|
236
|
+
revert ErrorIDistributionServiceInvalidReferral(code);
|
237
|
+
}
|
238
|
+
if (expiryAt.eqz()) {
|
239
|
+
revert ErrorIDistributionServiceExpirationInvalid(expiryAt);
|
240
|
+
}
|
241
|
+
|
242
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
243
|
+
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
244
|
+
DistributorType distributorType = distributorInfo.distributorType;
|
245
|
+
IDistribution.DistributorTypeInfo memory distributorTypeData = instanceReader.getDistributorTypeInfo(distributorType);
|
246
|
+
|
247
|
+
if (distributorTypeData.maxReferralCount < maxReferrals) {
|
248
|
+
revert ErrorIDistributionServiceMaxReferralsExceeded(distributorTypeData.maxReferralCount);
|
249
|
+
}
|
250
|
+
if (distributorTypeData.minDiscountPercentage > discountPercentage) {
|
251
|
+
revert ErrorIDistributionServiceDiscountTooLow(distributorTypeData.minDiscountPercentage.toInt(), discountPercentage.toInt());
|
252
|
+
}
|
253
|
+
if (distributorTypeData.maxDiscountPercentage < discountPercentage) {
|
254
|
+
revert ErrorIDistributionServiceDiscountTooHigh(distributorTypeData.maxDiscountPercentage.toInt(), discountPercentage.toInt());
|
255
|
+
}
|
256
|
+
if (expiryAt.toInt() - TimestampLib.blockTimestamp().toInt() > distributorTypeData.maxReferralLifetime) {
|
257
|
+
revert ErrorIDistributionServiceExpiryTooLong(distributorTypeData.maxReferralLifetime, expiryAt.toInt());
|
258
|
+
}
|
259
|
+
|
260
|
+
referralId = ReferralLib.toReferralId(distributionNftId, code);
|
261
|
+
IDistribution.ReferralInfo memory info = IDistribution.ReferralInfo(
|
262
|
+
distributorNftId,
|
263
|
+
code,
|
264
|
+
discountPercentage,
|
265
|
+
maxReferrals,
|
266
|
+
0, // used referrals
|
267
|
+
expiryAt,
|
268
|
+
data
|
269
|
+
);
|
270
|
+
|
271
|
+
instance.createReferral(referralId.toKey32(), info);
|
272
|
+
return referralId;
|
273
|
+
}
|
274
|
+
|
275
|
+
function processSale(
|
276
|
+
NftId distributionNftId,
|
277
|
+
ReferralId referralId,
|
278
|
+
IPolicy.Premium memory premium,
|
279
|
+
uint256 transferredDistributionFeeAmount
|
280
|
+
)
|
281
|
+
external
|
282
|
+
virtual
|
283
|
+
{
|
284
|
+
bool isReferral = ! referralId.eqz();
|
285
|
+
bool referralValid = referralIsValid(distributionNftId, referralId);
|
286
|
+
|
287
|
+
if (isReferral && ! referralValid) {
|
288
|
+
revert ErrorIDistributionServiceReferralInvalid(distributionNftId, referralId);
|
289
|
+
}
|
290
|
+
|
291
|
+
(, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
|
292
|
+
InstanceReader reader = instance.getInstanceReader();
|
293
|
+
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
294
|
+
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
295
|
+
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
296
|
+
|
297
|
+
uint256 distributionOwnerFee = premium.distributionOwnerFeeFixAmount + premium.distributionOwnerFeeVarAmount;
|
298
|
+
uint256 commissionAmount = premium.commissionAmount;
|
299
|
+
|
300
|
+
if (transferredDistributionFeeAmount != distributionOwnerFee + commissionAmount) {
|
301
|
+
revert ErrorIDistributionServiceInvalidFeeTransferred(transferredDistributionFeeAmount, distributionOwnerFee + commissionAmount);
|
302
|
+
}
|
303
|
+
|
304
|
+
|
305
|
+
if (distributionOwnerFee > 0) {
|
306
|
+
setupInfo.sumDistributionOwnerFees += distributionOwnerFee;
|
307
|
+
instance.updateDistributionSetup(distributionNftId, setupInfo, KEEP_STATE());
|
308
|
+
}
|
309
|
+
|
310
|
+
if (isReferral) {
|
311
|
+
referralInfo.usedReferrals += 1;
|
312
|
+
instance.updateReferral(referralId.toKey32(), referralInfo, KEEP_STATE());
|
313
|
+
|
314
|
+
if (commissionAmount > 0) {
|
315
|
+
distributorInfo.sumCommisions += commissionAmount;
|
316
|
+
distributorInfo.numPoliciesSold += 1;
|
317
|
+
instance.updateDistributor(referralInfo.distributorNftId, distributorInfo, KEEP_STATE());
|
318
|
+
}
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
function calculateFeeAmount(
|
323
|
+
NftId distributionNftId,
|
324
|
+
ReferralId referralId,
|
325
|
+
IPolicy.Premium memory premium
|
326
|
+
)
|
327
|
+
external
|
328
|
+
virtual
|
329
|
+
view
|
330
|
+
returns (IPolicy.Premium memory finalPremium)
|
331
|
+
{
|
332
|
+
(, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
|
333
|
+
InstanceReader reader = instance.getInstanceReader();
|
334
|
+
|
335
|
+
// first calculate all fixed and variable fees for the distribution - this will defined the fullPremium
|
336
|
+
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
337
|
+
Fee memory distributionFee = setupInfo.distributionFee;
|
338
|
+
Fee memory minDistributionOwnerFee = setupInfo.minDistributionOwnerFee;
|
339
|
+
uint256 distributionFeeVarAmount = (UFixedLib.toUFixed(premium.netPremiumAmount) * distributionFee.fractionalFee).toInt();
|
340
|
+
premium.distributionFeeVarAmount = distributionFeeVarAmount;
|
341
|
+
premium.fullPremiumAmount += distributionFeeVarAmount;
|
342
|
+
|
343
|
+
// if the referral is not valid, then the distribution owner gets everything
|
344
|
+
if (! referralIsValid(distributionNftId, referralId)) {
|
345
|
+
premium.distributionOwnerFeeFixAmount = premium.distributionFeeFixAmount;
|
346
|
+
premium.distributionOwnerFeeVarAmount = premium.distributionFeeVarAmount;
|
347
|
+
premium.premiumAmount = premium.fullPremiumAmount;
|
348
|
+
return premium;
|
349
|
+
}
|
350
|
+
|
351
|
+
// if the referral is valid, the the commission and discount are calculated based in the full premium
|
352
|
+
// the remaing amount goes to the distribution owner
|
353
|
+
{
|
354
|
+
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
355
|
+
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
356
|
+
IDistribution.DistributorTypeInfo memory distributorTypeInfo = reader.getDistributorTypeInfo(distributorInfo.distributorType);
|
357
|
+
|
358
|
+
uint256 commissionAmount = UFixedLib.toUFixed(premium.netPremiumAmount).mul(distributorTypeInfo.commissionPercentage).toInt();
|
359
|
+
premium.commissionAmount = commissionAmount;
|
360
|
+
premium.discountAmount = UFixedLib.toUFixed(premium.fullPremiumAmount).mul(referralInfo.discountPercentage).toInt();
|
361
|
+
premium.distributionOwnerFeeFixAmount = minDistributionOwnerFee.fixedFee;
|
362
|
+
premium.distributionOwnerFeeVarAmount = distributionFeeVarAmount - commissionAmount - premium.discountAmount;
|
363
|
+
premium.premiumAmount = premium.fullPremiumAmount - premium.discountAmount;
|
364
|
+
}
|
365
|
+
|
366
|
+
// sanity check to validate the fee calculation
|
367
|
+
if (premium.distributionOwnerFeeFixAmount < minDistributionOwnerFee.fixedFee) {
|
368
|
+
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
369
|
+
premium.distributionFeeFixAmount,
|
370
|
+
premium.distributionFeeVarAmount,
|
371
|
+
premium.distributionOwnerFeeFixAmount,
|
372
|
+
premium.distributionOwnerFeeVarAmount,
|
373
|
+
premium.commissionAmount,
|
374
|
+
premium.discountAmount
|
375
|
+
);
|
376
|
+
}
|
377
|
+
if ((premium.distributionFeeVarAmount) != (premium.discountAmount + premium.distributionOwnerFeeVarAmount + premium.commissionAmount)) {
|
378
|
+
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
379
|
+
premium.distributionFeeFixAmount,
|
380
|
+
premium.distributionFeeVarAmount,
|
381
|
+
premium.distributionOwnerFeeFixAmount,
|
382
|
+
premium.distributionOwnerFeeVarAmount,
|
383
|
+
premium.commissionAmount,
|
384
|
+
premium.discountAmount
|
385
|
+
);
|
386
|
+
}
|
387
|
+
|
388
|
+
return premium;
|
389
|
+
}
|
390
|
+
|
391
|
+
// TODO: zero should return false
|
392
|
+
function referralIsValid(NftId distributionNftId, ReferralId referralId) public view returns (bool isValid) {
|
393
|
+
(address distributionAddress, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
|
394
|
+
IDistribution.ReferralInfo memory info = instance.getInstanceReader().getReferralInfo(referralId);
|
395
|
+
|
396
|
+
if (info.distributorNftId.eqz()) {
|
397
|
+
return false;
|
398
|
+
}
|
399
|
+
|
400
|
+
isValid = info.expiryAt.eqz() || (info.expiryAt.gtz() && TimestampLib.blockTimestamp() <= info.expiryAt);
|
401
|
+
isValid = isValid && info.usedReferrals < info.maxReferrals;
|
402
|
+
}
|
403
|
+
|
404
|
+
function _getAndVerifyCallingDistribution()
|
405
|
+
internal
|
406
|
+
view
|
407
|
+
returns(
|
408
|
+
address distributionAddress,
|
409
|
+
NftId distributionNftId,
|
410
|
+
IInstance instance
|
411
|
+
)
|
412
|
+
{
|
413
|
+
ObjectType objectType;
|
414
|
+
(
|
415
|
+
distributionAddress,
|
416
|
+
distributionNftId,
|
417
|
+
objectType,
|
418
|
+
instance
|
419
|
+
) = _getAndVerifyCaller();
|
420
|
+
|
421
|
+
if(objectType != DISTRIBUTION()) {
|
422
|
+
revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
|
423
|
+
}
|
424
|
+
}
|
425
|
+
|
426
|
+
function _getAndVerifyDistribution(NftId distributionNftId)
|
427
|
+
internal
|
428
|
+
view
|
429
|
+
returns(
|
430
|
+
address distributionAddress,
|
431
|
+
IInstance instance
|
432
|
+
)
|
433
|
+
{
|
434
|
+
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(distributionNftId);
|
435
|
+
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
436
|
+
if (parentInfo.objectType != INSTANCE()) {
|
437
|
+
revert ErrorIDistributionServiceParentNftIdNotInstance(distributionNftId, info.parentNftId);
|
438
|
+
}
|
439
|
+
instance = IInstance(parentInfo.objectAddress);
|
440
|
+
}
|
441
|
+
|
442
|
+
function _getAndVerifyCaller()
|
443
|
+
internal
|
444
|
+
view
|
445
|
+
returns(
|
446
|
+
address objectAddress,
|
447
|
+
NftId objectNftId,
|
448
|
+
ObjectType objectType,
|
449
|
+
IInstance instance
|
450
|
+
)
|
451
|
+
{
|
452
|
+
objectAddress = msg.sender;
|
453
|
+
objectNftId = getRegistry().getNftId(objectAddress);
|
454
|
+
if ( objectNftId.eqz()) {
|
455
|
+
revert ErrorIServiceCallerUnknown(objectAddress);
|
456
|
+
}
|
457
|
+
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
|
458
|
+
objectType = info.objectType;
|
459
|
+
|
460
|
+
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
461
|
+
if (parentInfo.objectType != INSTANCE()) {
|
462
|
+
revert ErrorIDistributionServiceParentNftIdNotInstance(objectNftId, info.parentNftId);
|
463
|
+
}
|
464
|
+
instance = IInstance(parentInfo.objectAddress);
|
465
|
+
}
|
466
|
+
|
467
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
5
|
+
import {ProxyManager} from "../../shared/ProxyManager.sol";
|
6
|
+
import {DistributionService} from "./DistributionService.sol";
|
7
|
+
import {Registry} from "../../registry/Registry.sol";
|
8
|
+
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
+
import {REGISTRY} from "../../types/ObjectType.sol";
|
10
|
+
|
11
|
+
contract DistributionServiceManager is ProxyManager {
|
12
|
+
|
13
|
+
DistributionService private _distributionService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with distribution service implementation and deploys instance
|
16
|
+
constructor(
|
17
|
+
address registryAddress
|
18
|
+
)
|
19
|
+
ProxyManager(registryAddress)
|
20
|
+
{
|
21
|
+
DistributionService distSrv = new DistributionService();
|
22
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
23
|
+
IVersionable versionable = deploy(
|
24
|
+
address(distSrv),
|
25
|
+
data);
|
26
|
+
|
27
|
+
_distributionService = DistributionService(address(versionable));
|
28
|
+
|
29
|
+
// TODO `thi` must have a role or own nft to register service
|
30
|
+
//Registry registry = Registry(registryAddress);
|
31
|
+
//address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _distributionService.getMajorVersion());
|
32
|
+
//RegistryService registryService = RegistryService(registryServiceAddress);
|
33
|
+
//registryService.registerService(_distributionService);
|
34
|
+
|
35
|
+
// TODO no nft to link yet
|
36
|
+
// link ownership of instance service manager ot nft owner of instance service
|
37
|
+
//_linkToNftOwnable(
|
38
|
+
// address(registryAddress),
|
39
|
+
// address(_distributionService));
|
40
|
+
}
|
41
|
+
|
42
|
+
//--- view functions ----------------------------------------------------//
|
43
|
+
function getDistributionService()
|
44
|
+
external
|
45
|
+
view
|
46
|
+
returns (DistributionService distributionService)
|
47
|
+
{
|
48
|
+
return _distributionService;
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
5
|
+
import {IRisk} from "../module/IRisk.sol";
|
6
|
+
import {IService} from "../../shared/IService.sol";
|
7
|
+
|
8
|
+
import {NftId} from "../../types/NftId.sol";
|
9
|
+
import {ReferralId} from "../../types/Referral.sol";
|
10
|
+
import {RiskId} from "../../types/RiskId.sol";
|
11
|
+
import {Seconds} from "../../types/Seconds.sol";
|
12
|
+
import {StateId} from "../../types/StateId.sol";
|
13
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
14
|
+
import {UFixed} from "../../types/UFixed.sol";
|
15
|
+
import {Fee} from "../../types/Fee.sol";
|
16
|
+
|
17
|
+
/// @dev gif service responsible for creating applications
|
18
|
+
/// only product components may call transaction functions
|
19
|
+
interface IApplicationService is IService {
|
20
|
+
|
21
|
+
error IApplicationServicePolicyNotApplied(NftId applicationNftId);
|
22
|
+
error IApplicationServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
|
23
|
+
|
24
|
+
/// @dev creates a new application based on the specified attributes
|
25
|
+
/// may only be called by a product component
|
26
|
+
function create(
|
27
|
+
address applicationOwner,
|
28
|
+
RiskId riskId,
|
29
|
+
uint256 sumInsuredAmount,
|
30
|
+
Seconds lifetime,
|
31
|
+
NftId bundleNftId,
|
32
|
+
ReferralId referralId,
|
33
|
+
bytes memory applicationData
|
34
|
+
) external returns (NftId applicationNftId);
|
35
|
+
|
36
|
+
/// @dev updates application attributes
|
37
|
+
/// may only be called while the application is in applied state
|
38
|
+
/// may only be called by the referenced product related to applicationNftId
|
39
|
+
function adjust(
|
40
|
+
NftId applicationNftId,
|
41
|
+
RiskId riskId,
|
42
|
+
NftId bundleNftId,
|
43
|
+
ReferralId referralId,
|
44
|
+
uint256 sumInsuredAmount,
|
45
|
+
uint256 lifetime,
|
46
|
+
bytes memory applicationData
|
47
|
+
) external;
|
48
|
+
|
49
|
+
/// @dev creates a new application that extends the provided policy
|
50
|
+
/// lifetime will seamlessly extend referenced policy, for closed policies
|
51
|
+
/// lifetime will start at underwriting time
|
52
|
+
/// product will need to limit the time window for renewal as underwriting
|
53
|
+
/// will lock the collateral at underwriting time which might be earlier than activation time
|
54
|
+
/// policyNftId needs to refer to an underwritten (or active or closed) policy
|
55
|
+
/// may only be called by the referenced product related to policyNftId
|
56
|
+
function renew(
|
57
|
+
NftId policyNftId, // policy to be renewd (renewal inherits policy attributes)
|
58
|
+
NftId bundleNftId // will likely need a newer bundle for underwriting
|
59
|
+
) external returns (NftId applicationNftId);
|
60
|
+
|
61
|
+
/// @dev revokes the application represented by {policyNftId}
|
62
|
+
/// an application can only be revoked in applied state
|
63
|
+
/// only the application holder may revoke an application
|
64
|
+
function revoke(NftId policyNftId) external;
|
65
|
+
|
66
|
+
/// @dev calculates the premium amount for the specified attributes
|
67
|
+
/// also returns the various fee components involved with creating a policy
|
68
|
+
function calculatePremium(
|
69
|
+
NftId productNftId,
|
70
|
+
RiskId riskId,
|
71
|
+
uint256 sumInsuredAmount,
|
72
|
+
Seconds lifetime,
|
73
|
+
bytes memory applicationData,
|
74
|
+
NftId bundleNftId,
|
75
|
+
ReferralId referralId
|
76
|
+
)
|
77
|
+
external
|
78
|
+
view
|
79
|
+
returns (
|
80
|
+
IPolicy.Premium memory premium
|
81
|
+
);
|
82
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {NftId} from "../../types/NftId.sol";
|
5
|
+
import {Fee} from "../../types/Fee.sol";
|
6
|
+
import {IService} from "../../shared/IService.sol";
|
7
|
+
import {IBundle} from "../module/IBundle.sol";
|
8
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
9
|
+
import {Seconds} from "../../types/Seconds.sol";
|
10
|
+
import {StateId} from "../../types/StateId.sol";
|
11
|
+
|
12
|
+
interface IBundleService is IService {
|
13
|
+
|
14
|
+
event LogBundleServiceBundleActivated(NftId bundleNftId);
|
15
|
+
event LogBundleServiceBundleLocked(NftId bundleNftId);
|
16
|
+
event LogBundleServiceBundleClosed(NftId bundleNftId);
|
17
|
+
|
18
|
+
error ErrorBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
19
|
+
error ErrorBundleServiceBundleNotOpen(NftId bundleNftId, StateId state);
|
20
|
+
error ErrorBundleServiceBundleWithOpenPolicies(NftId bundleNftId, uint256 openPoliciesCount);
|
21
|
+
|
22
|
+
function create(
|
23
|
+
address owner,
|
24
|
+
Fee memory fee,
|
25
|
+
uint256 amount,
|
26
|
+
Seconds lifetime,
|
27
|
+
bytes calldata filter
|
28
|
+
) external returns(NftId bundleNftId);
|
29
|
+
|
30
|
+
|
31
|
+
function setFee(
|
32
|
+
NftId bundleNftId,
|
33
|
+
Fee memory fee
|
34
|
+
) external;
|
35
|
+
|
36
|
+
|
37
|
+
function lockCollateral(
|
38
|
+
IInstance instanceNftId,
|
39
|
+
NftId policyNftId,
|
40
|
+
NftId bundleNftId,
|
41
|
+
uint256 collateralAmount,
|
42
|
+
uint256 netPremium
|
43
|
+
)
|
44
|
+
external
|
45
|
+
returns (
|
46
|
+
IBundle.BundleInfo memory bundleInfo
|
47
|
+
);
|
48
|
+
|
49
|
+
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
50
|
+
|
51
|
+
function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
|
52
|
+
|
53
|
+
// function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
54
|
+
|
55
|
+
// function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
56
|
+
|
57
|
+
function lock(NftId bundleNftId) external;
|
58
|
+
|
59
|
+
function unlock(NftId bundleNftId) external;
|
60
|
+
|
61
|
+
function close(NftId bundleNftId) external;
|
62
|
+
}
|