@etherisc/gif-next 0.0.2-e922e07-736 → 0.0.2-e964d24-516
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -83
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/{components → distribution}/Distribution.sol/Distribution.json +129 -14
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +1556 -0
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +780 -0
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/{components → distribution}/IDistributionComponent.sol/IDistributionComponent.json +203 -14
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/{instance/service → distribution}/IDistributionService.sol/IDistributionService.json +110 -283
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +68 -54
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +309 -2078
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +183 -76
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +434 -2823
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +493 -129
- package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +124 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +406 -192
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +224 -291
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +45 -82
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2788 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
- 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 +44 -14
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +38 -13
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +56 -73
- 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/pool/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +1288 -0
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +696 -0
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/{instance/service → pool}/IBundleService.sol/IBundleService.json +291 -189
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/{components → pool}/IPoolComponent.sol/IPoolComponent.json +231 -165
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +1077 -0
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/{components → pool}/Pool.sol/Pool.json +160 -204
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +1622 -0
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +708 -0
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +918 -0
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +648 -0
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +4 -0
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +1376 -0
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +748 -0
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/{instance/service/IClaimService.sol/IClaimService.json → product/IApplicationService.sol/IApplicationService.json} +184 -100
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +4 -0
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +743 -0
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/{instance/service → product}/IPolicyService.sol/IPolicyService.json +211 -100
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +4 -0
- package/artifacts/contracts/{instance/service/IApplicationService.sol/IApplicationService.json → product/IPricingService.sol/IPricingService.json} +120 -166
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/{components → product}/IProductComponent.sol/IProductComponent.json +210 -21
- package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/{instance/service → product}/IProductService.sol/IProductService.json +86 -28
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +1281 -0
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +740 -0
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +4 -0
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +1004 -0
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +688 -0
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/{components → product}/Product.sol/Product.json +121 -22
- package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/product/ProductService.sol/ProductService.json +864 -0
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +640 -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 +19 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +5 -37
- 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 +35 -16
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +4 -4
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +26 -53
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +27 -40
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +30 -18
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
- package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
- package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/{components → shared}/Component.sol/Component.json +106 -7
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/{instance/base → shared}/ComponentService.sol/ComponentService.json +114 -35
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{components → shared}/IComponent.sol/IComponent.json +196 -7
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +0 -13
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +69 -9
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -13
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +0 -13
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +85 -27
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +8 -21
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +80 -26
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +20 -33
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +8 -21
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +91 -28
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +24 -6
- 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/staking/IStakingService.sol/IStakingService.dbg.json +4 -0
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +523 -0
- package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.json +628 -0
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +4 -0
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +767 -0
- package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/AddressSet.sol/LibAddressSet.json +3 -3
- package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +4 -0
- package/artifacts/contracts/type/Amount.sol/AmountLib.json +281 -0
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/Blocknumber.sol/BlocknumberLib.json +3 -3
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +179 -0
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/DistributorType.sol/DistributorTypeLib.json +5 -5
- package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +4 -0
- package/artifacts/contracts/type/Fee.sol/FeeLib.json +312 -0
- package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/Key32.sol/Key32Lib.json +3 -3
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +4 -0
- package/artifacts/contracts/type/NftId.sol/NftIdLib.json +166 -0
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/NftIdSet.sol/LibNftIdSet.json +3 -3
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/ObjectType.sol/ObjectTypeLib.json +3 -3
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +209 -0
- package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/Referral.sol/ReferralLib.json +5 -5
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/RiskId.sol/RiskIdLib.json +5 -5
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/RoleId.sol/RoleIdLib.json +5 -5
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/Seconds.sol/SecondsLib.json +3 -3
- package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/StateId.sol/StateIdLib.json +3 -3
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/Timestamp.sol/TimestampLib.json +20 -7
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/UFixed.sol/MathLib.json +3 -3
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/UFixed.sol/UFixedLib.json +3 -3
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/Version.sol/VersionLib.json +3 -3
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +4 -0
- package/artifacts/contracts/{types → type}/Version.sol/VersionPartLib.json +3 -3
- package/contracts/{components → distribution}/Distribution.sol +21 -16
- package/contracts/distribution/DistributionService.sol +348 -0
- package/contracts/{instance/service → distribution}/DistributionServiceManager.sol +5 -5
- package/contracts/{components → distribution}/IDistributionComponent.sol +7 -7
- package/contracts/{instance/service → distribution}/IDistributionService.sol +19 -30
- package/contracts/instance/BundleManager.sol +13 -12
- package/contracts/instance/Cloneable.sol +7 -2
- package/contracts/instance/IInstance.sol +48 -63
- package/contracts/instance/IInstanceService.sol +31 -17
- package/contracts/instance/Instance.sol +131 -193
- package/contracts/instance/InstanceAccessManager.sol +405 -161
- package/contracts/instance/InstanceAuthorizationsLib.sol +308 -0
- package/contracts/instance/InstanceReader.sol +101 -26
- package/contracts/instance/InstanceService.sol +173 -354
- package/contracts/instance/InstanceServiceManager.sol +1 -1
- package/contracts/instance/InstanceStore.sol +211 -0
- package/contracts/instance/ObjectManager.sol +9 -11
- package/contracts/instance/base/IKeyValueStore.sol +5 -5
- package/contracts/instance/base/ILifecycle.sol +3 -3
- package/contracts/instance/base/KeyValueStore.sol +18 -41
- package/contracts/instance/base/Lifecycle.sol +27 -7
- package/contracts/instance/module/IAccess.sol +23 -16
- package/contracts/instance/module/IBundle.sol +10 -8
- package/contracts/instance/module/IComponents.sol +41 -0
- package/contracts/instance/module/IDistribution.sol +7 -6
- package/contracts/instance/module/IPolicy.sol +19 -14
- package/contracts/instance/module/IRisk.sol +1 -1
- package/contracts/instance/module/ISetup.sol +5 -18
- package/contracts/instance/module/ITreasury.sol +2 -2
- package/contracts/pool/BundleService.sol +382 -0
- package/contracts/{instance/service → pool}/BundleServiceManager.sol +5 -5
- package/contracts/pool/IBundleService.sol +118 -0
- package/contracts/{components → pool}/IPoolComponent.sol +19 -56
- package/contracts/pool/IPoolService.sol +114 -0
- package/contracts/{components → pool}/Pool.sol +62 -138
- package/contracts/pool/PoolService.sol +403 -0
- package/contracts/{instance/service → pool}/PoolServiceManager.sol +5 -5
- package/contracts/product/ApplicationService.sol +186 -0
- package/contracts/{instance/service → product}/ApplicationServiceManager.sol +2 -2
- package/contracts/product/ClaimService.sol +437 -0
- package/contracts/{instance/service → product}/ClaimServiceManager.sol +2 -2
- package/contracts/{instance/service → product}/IApplicationService.sol +14 -34
- package/contracts/product/IClaimService.sol +90 -0
- package/contracts/{instance/service → product}/IPolicyService.sol +34 -26
- package/contracts/product/IPricingService.sol +37 -0
- package/contracts/{components → product}/IProductComponent.sol +11 -10
- package/contracts/{instance/service → product}/IProductService.sol +10 -10
- package/contracts/product/PolicyService.sol +376 -0
- package/contracts/{instance/service → product}/PolicyServiceManager.sol +5 -5
- package/contracts/product/PricingService.sol +275 -0
- package/contracts/product/PricingServiceManager.sol +51 -0
- package/contracts/{components → product}/Product.sol +160 -74
- package/contracts/product/ProductService.sol +210 -0
- package/contracts/{instance/service → product}/ProductServiceManager.sol +5 -5
- package/contracts/registry/ChainNft.sol +8 -0
- package/contracts/registry/IRegistry.sol +6 -4
- package/contracts/registry/IRegistryService.sol +6 -7
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +26 -23
- package/contracts/registry/RegistryAccessManager.sol +1 -1
- package/contracts/registry/RegistryService.sol +33 -31
- package/contracts/registry/RegistryServiceManager.sol +0 -2
- package/contracts/registry/ReleaseManager.sol +24 -22
- package/contracts/registry/TokenRegistry.sol +2 -2
- package/contracts/shared/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/{components → shared}/Component.sol +68 -18
- package/contracts/shared/ComponentService.sol +150 -0
- package/contracts/{components → shared}/IComponent.sol +28 -6
- package/contracts/shared/INftOwnable.sol +1 -1
- package/contracts/shared/IPolicyHolder.sol +24 -10
- package/contracts/shared/IRegistryLinked.sol +0 -1
- package/contracts/shared/IService.sol +6 -6
- package/contracts/shared/IVersionable.sol +1 -1
- package/contracts/shared/NftOwnable.sol +1 -3
- package/contracts/shared/PolicyHolder.sol +31 -18
- package/contracts/shared/ProxyManager.sol +3 -3
- package/contracts/shared/Registerable.sol +12 -11
- package/contracts/shared/RegistryLinked.sol +0 -5
- package/contracts/shared/Service.sol +23 -9
- package/contracts/shared/TokenHandler.sol +14 -6
- package/contracts/shared/Versionable.sol +1 -1
- package/contracts/staking/IStakingService.sol +102 -0
- package/contracts/staking/StakeingServiceManager.sol +37 -0
- package/contracts/staking/StakingService.sol +166 -0
- package/contracts/type/Amount.sol +109 -0
- package/contracts/{types → type}/Blocknumber.sol +1 -0
- package/contracts/{types → type}/ClaimId.sol +25 -2
- package/contracts/{types → type}/Fee.sol +17 -8
- package/contracts/{types → type}/NftId.sol +8 -0
- package/contracts/{types → type}/NftIdSet.sol +1 -1
- package/contracts/{types → type}/ObjectType.sol +10 -5
- package/contracts/{types → type}/PayoutId.sol +33 -5
- package/contracts/{types → type}/RoleId.sol +6 -4
- package/contracts/{types → type}/StateId.sol +7 -2
- package/contracts/{types → type}/Timestamp.sol +6 -0
- package/contracts/{types → type}/UFixed.sol +1 -0
- package/contracts/{types → type}/Version.sol +1 -0
- package/package.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +0 -4
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +0 -4
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +0 -4
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +0 -4
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +0 -968
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +0 -665
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +0 -1096
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +0 -4
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +0 -661
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +0 -754
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +0 -637
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +0 -1724
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +0 -4
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +0 -801
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +0 -347
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +0 -1021
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +0 -4
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +0 -689
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +0 -727
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +0 -4
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +0 -649
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +0 -777
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +0 -649
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +0 -4
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +0 -107
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +0 -4
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +0 -119
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +0 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +0 -383
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +0 -4
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +0 -116
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +0 -4
- package/artifacts/contracts/test/TestService.sol/TestService.json +0 -521
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +0 -4
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +0 -376
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +0 -4
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +0 -218
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +0 -4
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +0 -104
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +0 -4
- package/artifacts/contracts/test/Usdc.sol/USDC.json +0 -376
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +0 -4
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +0 -4
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +0 -10
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +0 -100
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +0 -4
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +0 -4
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +0 -257
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +0 -4
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +0 -153
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +0 -4
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +0 -100
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +0 -4
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +0 -100
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +0 -4
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +0 -4
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +0 -4
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +0 -4
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +0 -4
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +0 -4
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +0 -4
- package/contracts/instance/base/ComponentService.sol +0 -134
- package/contracts/instance/service/ApplicationService.sol +0 -349
- package/contracts/instance/service/BundleService.sol +0 -299
- package/contracts/instance/service/ClaimService.sol +0 -151
- package/contracts/instance/service/DistributionService.sol +0 -450
- package/contracts/instance/service/IBundleService.sol +0 -55
- package/contracts/instance/service/IClaimService.sol +0 -61
- package/contracts/instance/service/IPoolService.sol +0 -20
- package/contracts/instance/service/PolicyService.sol +0 -394
- package/contracts/instance/service/PoolService.sol +0 -109
- package/contracts/instance/service/ProductService.sol +0 -233
- package/contracts/shared/ContractDeployerLib.sol +0 -72
- package/contracts/test/TestFee.sol +0 -25
- package/contracts/test/TestRegisterable.sol +0 -18
- package/contracts/test/TestRoleId.sol +0 -14
- package/contracts/test/TestService.sol +0 -25
- package/contracts/test/TestToken.sol +0 -26
- package/contracts/test/TestVersion.sol +0 -44
- package/contracts/test/TestVersionable.sol +0 -17
- package/contracts/test/Usdc.sol +0 -26
- package/contracts/types/ChainId.sol +0 -38
- package/contracts/types/NumberId.sol +0 -52
- /package/contracts/{types → type}/AddressSet.sol +0 -0
- /package/contracts/{types → type}/DistributorType.sol +0 -0
- /package/contracts/{types → type}/Key32.sol +0 -0
- /package/contracts/{types → type}/Referral.sol +0 -0
- /package/contracts/{types → type}/RiskId.sol +0 -0
- /package/contracts/{types → type}/Seconds.sol +0 -0
@@ -1,450 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
-
import {IInstance} from "../../instance/IInstance.sol";
|
6
|
-
import {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 {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
|
-
|
18
|
-
import {IVersionable} from "../../shared/IVersionable.sol";
|
19
|
-
import {Versionable} from "../../shared/Versionable.sol";
|
20
|
-
|
21
|
-
import {IService} from "../../shared/IService.sol";
|
22
|
-
import {Service} from "../../shared/Service.sol";
|
23
|
-
import {ComponentService} from "../base/ComponentService.sol";
|
24
|
-
import {InstanceService} from "../InstanceService.sol";
|
25
|
-
import {IComponent} from "../../components/IComponent.sol";
|
26
|
-
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
27
|
-
import {IDistributionService} from "./IDistributionService.sol";
|
28
|
-
|
29
|
-
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
30
|
-
import {DistributorType, DistributorTypeLib} from "../../types/DistributorType.sol";
|
31
|
-
import {ReferralId, ReferralStatus, ReferralLib} from "../../types/Referral.sol";
|
32
|
-
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
33
|
-
import {Key32} from "../../types/Key32.sol";
|
34
|
-
import {IDistribution} from "../module/IDistribution.sol";
|
35
|
-
|
36
|
-
|
37
|
-
contract DistributionService is
|
38
|
-
ComponentService,
|
39
|
-
IDistributionService
|
40
|
-
{
|
41
|
-
using NftIdLib for NftId;
|
42
|
-
using TimestampLib for Timestamp;
|
43
|
-
using UFixedLib for UFixed;
|
44
|
-
using FeeLib for Fee;
|
45
|
-
using ReferralLib for ReferralId;
|
46
|
-
|
47
|
-
address internal _registryAddress;
|
48
|
-
|
49
|
-
function _initialize(
|
50
|
-
address owner,
|
51
|
-
bytes memory data
|
52
|
-
)
|
53
|
-
internal
|
54
|
-
initializer
|
55
|
-
virtual override
|
56
|
-
{
|
57
|
-
address initialOwner;
|
58
|
-
address registryAddress;
|
59
|
-
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
60
|
-
// TODO while DistributionService is not deployed in DistributionServiceManager constructor
|
61
|
-
// owner is DistributionServiceManager deployer
|
62
|
-
initializeService(registryAddress, owner);
|
63
|
-
registerInterface(type(IDistributionService).interfaceId);
|
64
|
-
}
|
65
|
-
|
66
|
-
function getDomain() public pure override(Service, IService) returns(ObjectType) {
|
67
|
-
return DISTRIBUTION();
|
68
|
-
}
|
69
|
-
|
70
|
-
function register(address distributionAddress)
|
71
|
-
external
|
72
|
-
returns(NftId distributionNftId)
|
73
|
-
{
|
74
|
-
(
|
75
|
-
IComponent component,
|
76
|
-
address owner,
|
77
|
-
IInstance instance,
|
78
|
-
NftId instanceNftId
|
79
|
-
) = _checkComponentForRegistration(
|
80
|
-
distributionAddress,
|
81
|
-
DISTRIBUTION(),
|
82
|
-
DISTRIBUTION_OWNER_ROLE());
|
83
|
-
|
84
|
-
IRegistry.ObjectInfo memory distributionInfo = getRegistryService().registerDistribution(component, owner);
|
85
|
-
IDistributionComponent distribution = IDistributionComponent(distributionAddress);
|
86
|
-
distribution.linkToRegisteredNftId();
|
87
|
-
distributionNftId = distributionInfo.nftId;
|
88
|
-
|
89
|
-
instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
|
90
|
-
getInstanceService().createGifTarget(instanceNftId, distributionAddress, distribution.getName());
|
91
|
-
getInstanceService().grantDistributionDefaultPermissions(instanceNftId, distributionAddress, distribution.getName());
|
92
|
-
}
|
93
|
-
|
94
|
-
function setFees(
|
95
|
-
Fee memory minDistributionOwnerFee,
|
96
|
-
Fee memory distributionFee
|
97
|
-
)
|
98
|
-
external
|
99
|
-
override
|
100
|
-
{
|
101
|
-
if (minDistributionOwnerFee.fractionalFee > distributionFee.fractionalFee) {
|
102
|
-
revert ErrorIDistributionServiceMinFeeTooHigh(minDistributionOwnerFee.fractionalFee.toInt(), distributionFee.fractionalFee.toInt());
|
103
|
-
}
|
104
|
-
|
105
|
-
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
106
|
-
InstanceReader instanceReader = instance.getInstanceReader();
|
107
|
-
NftId distributionNftId = info.nftId;
|
108
|
-
|
109
|
-
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
110
|
-
distSetupInfo.minDistributionOwnerFee = minDistributionOwnerFee;
|
111
|
-
distSetupInfo.distributionFee = distributionFee;
|
112
|
-
|
113
|
-
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
114
|
-
}
|
115
|
-
|
116
|
-
function createDistributorType(
|
117
|
-
string memory name,
|
118
|
-
UFixed minDiscountPercentage,
|
119
|
-
UFixed maxDiscountPercentage,
|
120
|
-
UFixed commissionPercentage,
|
121
|
-
uint32 maxReferralCount,
|
122
|
-
uint32 maxReferralLifetime,
|
123
|
-
bool allowSelfReferrals,
|
124
|
-
bool allowRenewals,
|
125
|
-
bytes memory data
|
126
|
-
)
|
127
|
-
external
|
128
|
-
returns (DistributorType distributorType)
|
129
|
-
{
|
130
|
-
(,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
131
|
-
|
132
|
-
{
|
133
|
-
ISetup.DistributionSetupInfo memory setupInfo = instance.getInstanceReader().getDistributionSetupInfo(distributionNftId);
|
134
|
-
UFixed variableFeesPartsTotal = setupInfo.minDistributionOwnerFee.fractionalFee.add(commissionPercentage);
|
135
|
-
UFixed maxDiscountPercentageLimit = setupInfo.distributionFee.fractionalFee.sub(variableFeesPartsTotal);
|
136
|
-
if (maxDiscountPercentage.gt(maxDiscountPercentageLimit)) {
|
137
|
-
revert ErrorIDistributionServiceMaxDiscountTooHigh(maxDiscountPercentage.toInt(), maxDiscountPercentageLimit.toInt());
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
distributorType = DistributorTypeLib.toDistributorType(distributionNftId, name);
|
142
|
-
Key32 key32 = distributorType.toKey32();
|
143
|
-
|
144
|
-
if(!instance.exists(key32)) {
|
145
|
-
IDistribution.DistributorTypeInfo memory info = IDistribution.DistributorTypeInfo(
|
146
|
-
name,
|
147
|
-
minDiscountPercentage,
|
148
|
-
maxDiscountPercentage,
|
149
|
-
commissionPercentage,
|
150
|
-
maxReferralCount,
|
151
|
-
maxReferralLifetime,
|
152
|
-
allowSelfReferrals,
|
153
|
-
allowRenewals,
|
154
|
-
data);
|
155
|
-
|
156
|
-
instance.createDistributorType(key32, info);
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
160
|
-
function createDistributor(
|
161
|
-
address distributor,
|
162
|
-
DistributorType distributorType,
|
163
|
-
bytes memory data
|
164
|
-
) external returns (NftId distributorNftId)
|
165
|
-
{
|
166
|
-
(, NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
167
|
-
|
168
|
-
distributorNftId = getRegistryService().registerDistributor(
|
169
|
-
IRegistry.ObjectInfo(
|
170
|
-
zeroNftId(),
|
171
|
-
distributionNftId,
|
172
|
-
DISTRIBUTOR(),
|
173
|
-
true, // intercepting property for bundles is defined on pool
|
174
|
-
address(0),
|
175
|
-
distributor,
|
176
|
-
""
|
177
|
-
));
|
178
|
-
|
179
|
-
IDistribution.DistributorInfo memory info = IDistribution.DistributorInfo(
|
180
|
-
distributorType,
|
181
|
-
true, // active
|
182
|
-
data,
|
183
|
-
0,
|
184
|
-
0);
|
185
|
-
|
186
|
-
instance.createDistributor(distributorNftId, info);
|
187
|
-
}
|
188
|
-
|
189
|
-
function updateDistributorType(
|
190
|
-
NftId distributorNftId,
|
191
|
-
DistributorType distributorType,
|
192
|
-
bytes memory data
|
193
|
-
) external virtual
|
194
|
-
{
|
195
|
-
(,, IInstance instance) = _getAndVerifyCallingDistribution();
|
196
|
-
InstanceReader instanceReader = instance.getInstanceReader();
|
197
|
-
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
198
|
-
distributorInfo.distributorType = distributorType;
|
199
|
-
distributorInfo.data = data;
|
200
|
-
instance.updateDistributor(distributorNftId, distributorInfo, KEEP_STATE());
|
201
|
-
}
|
202
|
-
|
203
|
-
|
204
|
-
function createReferral(
|
205
|
-
NftId distributorNftId,
|
206
|
-
string memory code,
|
207
|
-
UFixed discountPercentage,
|
208
|
-
uint32 maxReferrals,
|
209
|
-
Timestamp expiryAt,
|
210
|
-
bytes memory data
|
211
|
-
)
|
212
|
-
external
|
213
|
-
virtual
|
214
|
-
returns (ReferralId referralId)
|
215
|
-
{
|
216
|
-
(,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
217
|
-
|
218
|
-
if (bytes(code).length == 0) {
|
219
|
-
revert ErrorIDistributionServiceInvalidReferral(code);
|
220
|
-
}
|
221
|
-
if (expiryAt.eqz()) {
|
222
|
-
revert ErrorIDistributionServiceExpirationInvalid(expiryAt);
|
223
|
-
}
|
224
|
-
|
225
|
-
InstanceReader instanceReader = instance.getInstanceReader();
|
226
|
-
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
227
|
-
DistributorType distributorType = distributorInfo.distributorType;
|
228
|
-
IDistribution.DistributorTypeInfo memory distributorTypeData = instanceReader.getDistributorTypeInfo(distributorType);
|
229
|
-
|
230
|
-
if (distributorTypeData.maxReferralCount < maxReferrals) {
|
231
|
-
revert ErrorIDistributionServiceMaxReferralsExceeded(distributorTypeData.maxReferralCount);
|
232
|
-
}
|
233
|
-
if (distributorTypeData.minDiscountPercentage > discountPercentage) {
|
234
|
-
revert ErrorIDistributionServiceDiscountTooLow(distributorTypeData.minDiscountPercentage.toInt(), discountPercentage.toInt());
|
235
|
-
}
|
236
|
-
if (distributorTypeData.maxDiscountPercentage < discountPercentage) {
|
237
|
-
revert ErrorIDistributionServiceDiscountTooHigh(distributorTypeData.maxDiscountPercentage.toInt(), discountPercentage.toInt());
|
238
|
-
}
|
239
|
-
if (expiryAt.toInt() - TimestampLib.blockTimestamp().toInt() > distributorTypeData.maxReferralLifetime) {
|
240
|
-
revert ErrorIDistributionServiceExpiryTooLong(distributorTypeData.maxReferralLifetime, expiryAt.toInt());
|
241
|
-
}
|
242
|
-
|
243
|
-
referralId = ReferralLib.toReferralId(distributionNftId, code);
|
244
|
-
IDistribution.ReferralInfo memory info = IDistribution.ReferralInfo(
|
245
|
-
distributorNftId,
|
246
|
-
code,
|
247
|
-
discountPercentage,
|
248
|
-
maxReferrals,
|
249
|
-
0, // used referrals
|
250
|
-
expiryAt,
|
251
|
-
data
|
252
|
-
);
|
253
|
-
|
254
|
-
instance.createReferral(referralId.toKey32(), info);
|
255
|
-
return referralId;
|
256
|
-
}
|
257
|
-
|
258
|
-
function processSale(
|
259
|
-
NftId distributionNftId,
|
260
|
-
ReferralId referralId,
|
261
|
-
IPolicy.Premium memory premium,
|
262
|
-
uint256 transferredDistributionFeeAmount
|
263
|
-
)
|
264
|
-
external
|
265
|
-
virtual
|
266
|
-
{
|
267
|
-
bool isReferral = ! referralId.eqz();
|
268
|
-
bool referralValid = referralIsValid(distributionNftId, referralId);
|
269
|
-
|
270
|
-
if (isReferral && ! referralValid) {
|
271
|
-
revert ErrorIDistributionServiceReferralInvalid(distributionNftId, referralId);
|
272
|
-
}
|
273
|
-
|
274
|
-
(, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
|
275
|
-
InstanceReader reader = instance.getInstanceReader();
|
276
|
-
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
277
|
-
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
278
|
-
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
279
|
-
|
280
|
-
uint256 distributionOwnerFee = premium.distributionOwnerFeeFixAmount + premium.distributionOwnerFeeVarAmount;
|
281
|
-
uint256 commissionAmount = premium.commissionAmount;
|
282
|
-
|
283
|
-
if (transferredDistributionFeeAmount != distributionOwnerFee + commissionAmount) {
|
284
|
-
revert ErrorIDistributionServiceInvalidFeeTransferred(transferredDistributionFeeAmount, distributionOwnerFee + commissionAmount);
|
285
|
-
}
|
286
|
-
|
287
|
-
|
288
|
-
if (distributionOwnerFee > 0) {
|
289
|
-
setupInfo.sumDistributionOwnerFees += distributionOwnerFee;
|
290
|
-
instance.updateDistributionSetup(distributionNftId, setupInfo, KEEP_STATE());
|
291
|
-
}
|
292
|
-
|
293
|
-
if (isReferral) {
|
294
|
-
referralInfo.usedReferrals += 1;
|
295
|
-
instance.updateReferral(referralId.toKey32(), referralInfo, KEEP_STATE());
|
296
|
-
|
297
|
-
if (commissionAmount > 0) {
|
298
|
-
distributorInfo.sumCommisions += commissionAmount;
|
299
|
-
distributorInfo.numPoliciesSold += 1;
|
300
|
-
instance.updateDistributor(referralInfo.distributorNftId, distributorInfo, KEEP_STATE());
|
301
|
-
}
|
302
|
-
}
|
303
|
-
}
|
304
|
-
|
305
|
-
function calculateFeeAmount(
|
306
|
-
NftId distributionNftId,
|
307
|
-
ReferralId referralId,
|
308
|
-
IPolicy.Premium memory premium
|
309
|
-
)
|
310
|
-
external
|
311
|
-
virtual
|
312
|
-
view
|
313
|
-
returns (IPolicy.Premium memory finalPremium)
|
314
|
-
{
|
315
|
-
(, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
|
316
|
-
InstanceReader reader = instance.getInstanceReader();
|
317
|
-
|
318
|
-
// first calculate all fixed and variable fees for the distribution - this will defined the fullPremium
|
319
|
-
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
320
|
-
Fee memory distributionFee = setupInfo.distributionFee;
|
321
|
-
Fee memory minDistributionOwnerFee = setupInfo.minDistributionOwnerFee;
|
322
|
-
uint256 distributionFeeVarAmount = (UFixedLib.toUFixed(premium.netPremiumAmount) * distributionFee.fractionalFee).toInt();
|
323
|
-
premium.distributionFeeVarAmount = distributionFeeVarAmount;
|
324
|
-
premium.fullPremiumAmount += distributionFeeVarAmount;
|
325
|
-
|
326
|
-
// if the referral is not valid, then the distribution owner gets everything
|
327
|
-
if (! referralIsValid(distributionNftId, referralId)) {
|
328
|
-
premium.distributionOwnerFeeFixAmount = premium.distributionFeeFixAmount;
|
329
|
-
premium.distributionOwnerFeeVarAmount = premium.distributionFeeVarAmount;
|
330
|
-
premium.premiumAmount = premium.fullPremiumAmount;
|
331
|
-
return premium;
|
332
|
-
}
|
333
|
-
|
334
|
-
// if the referral is valid, the the commission and discount are calculated based in the full premium
|
335
|
-
// the remaing amount goes to the distribution owner
|
336
|
-
{
|
337
|
-
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
338
|
-
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
339
|
-
IDistribution.DistributorTypeInfo memory distributorTypeInfo = reader.getDistributorTypeInfo(distributorInfo.distributorType);
|
340
|
-
|
341
|
-
uint256 commissionAmount = UFixedLib.toUFixed(premium.netPremiumAmount).mul(distributorTypeInfo.commissionPercentage).toInt();
|
342
|
-
premium.commissionAmount = commissionAmount;
|
343
|
-
premium.discountAmount = UFixedLib.toUFixed(premium.fullPremiumAmount).mul(referralInfo.discountPercentage).toInt();
|
344
|
-
premium.distributionOwnerFeeFixAmount = minDistributionOwnerFee.fixedFee;
|
345
|
-
premium.distributionOwnerFeeVarAmount = distributionFeeVarAmount - commissionAmount - premium.discountAmount;
|
346
|
-
premium.premiumAmount = premium.fullPremiumAmount - premium.discountAmount;
|
347
|
-
}
|
348
|
-
|
349
|
-
// sanity check to validate the fee calculation
|
350
|
-
if (premium.distributionOwnerFeeFixAmount < minDistributionOwnerFee.fixedFee) {
|
351
|
-
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
352
|
-
premium.distributionFeeFixAmount,
|
353
|
-
premium.distributionFeeVarAmount,
|
354
|
-
premium.distributionOwnerFeeFixAmount,
|
355
|
-
premium.distributionOwnerFeeVarAmount,
|
356
|
-
premium.commissionAmount,
|
357
|
-
premium.discountAmount
|
358
|
-
);
|
359
|
-
}
|
360
|
-
if ((premium.distributionFeeVarAmount) != (premium.discountAmount + premium.distributionOwnerFeeVarAmount + premium.commissionAmount)) {
|
361
|
-
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
362
|
-
premium.distributionFeeFixAmount,
|
363
|
-
premium.distributionFeeVarAmount,
|
364
|
-
premium.distributionOwnerFeeFixAmount,
|
365
|
-
premium.distributionOwnerFeeVarAmount,
|
366
|
-
premium.commissionAmount,
|
367
|
-
premium.discountAmount
|
368
|
-
);
|
369
|
-
}
|
370
|
-
|
371
|
-
return premium;
|
372
|
-
}
|
373
|
-
|
374
|
-
// TODO: zero should return false
|
375
|
-
function referralIsValid(NftId distributionNftId, ReferralId referralId) public view returns (bool isValid) {
|
376
|
-
(address distributionAddress, IInstance instance) = _getAndVerifyDistribution(distributionNftId);
|
377
|
-
IDistribution.ReferralInfo memory info = instance.getInstanceReader().getReferralInfo(referralId);
|
378
|
-
|
379
|
-
if (info.distributorNftId.eqz()) {
|
380
|
-
return false;
|
381
|
-
}
|
382
|
-
|
383
|
-
isValid = info.expiryAt.eqz() || (info.expiryAt.gtz() && TimestampLib.blockTimestamp() <= info.expiryAt);
|
384
|
-
isValid = isValid && info.usedReferrals < info.maxReferrals;
|
385
|
-
}
|
386
|
-
|
387
|
-
function _getAndVerifyCallingDistribution()
|
388
|
-
internal
|
389
|
-
view
|
390
|
-
returns(
|
391
|
-
address distributionAddress,
|
392
|
-
NftId distributionNftId,
|
393
|
-
IInstance instance
|
394
|
-
)
|
395
|
-
{
|
396
|
-
ObjectType objectType;
|
397
|
-
(
|
398
|
-
distributionAddress,
|
399
|
-
distributionNftId,
|
400
|
-
objectType,
|
401
|
-
instance
|
402
|
-
) = _getAndVerifyCaller();
|
403
|
-
|
404
|
-
if(objectType != DISTRIBUTION()) {
|
405
|
-
revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
|
406
|
-
}
|
407
|
-
}
|
408
|
-
|
409
|
-
function _getAndVerifyDistribution(NftId distributionNftId)
|
410
|
-
internal
|
411
|
-
view
|
412
|
-
returns(
|
413
|
-
address distributionAddress,
|
414
|
-
IInstance instance
|
415
|
-
)
|
416
|
-
{
|
417
|
-
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(distributionNftId);
|
418
|
-
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
419
|
-
if (parentInfo.objectType != INSTANCE()) {
|
420
|
-
revert ErrorIDistributionServiceParentNftIdNotInstance(distributionNftId, info.parentNftId);
|
421
|
-
}
|
422
|
-
instance = IInstance(parentInfo.objectAddress);
|
423
|
-
}
|
424
|
-
|
425
|
-
function _getAndVerifyCaller()
|
426
|
-
internal
|
427
|
-
view
|
428
|
-
returns(
|
429
|
-
address objectAddress,
|
430
|
-
NftId objectNftId,
|
431
|
-
ObjectType objectType,
|
432
|
-
IInstance instance
|
433
|
-
)
|
434
|
-
{
|
435
|
-
objectAddress = msg.sender;
|
436
|
-
objectNftId = getRegistry().getNftId(objectAddress);
|
437
|
-
if ( objectNftId.eqz()) {
|
438
|
-
revert ErrorIServiceCallerUnknown(objectAddress);
|
439
|
-
}
|
440
|
-
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
|
441
|
-
objectType = info.objectType;
|
442
|
-
|
443
|
-
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
444
|
-
if (parentInfo.objectType != INSTANCE()) {
|
445
|
-
revert ErrorIDistributionServiceParentNftIdNotInstance(objectNftId, info.parentNftId);
|
446
|
-
}
|
447
|
-
instance = IInstance(parentInfo.objectAddress);
|
448
|
-
}
|
449
|
-
|
450
|
-
}
|
@@ -1,55 +0,0 @@
|
|
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
|
-
error ErrorIBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
14
|
-
|
15
|
-
function createBundle(
|
16
|
-
address owner,
|
17
|
-
Fee memory fee,
|
18
|
-
uint256 amount,
|
19
|
-
Seconds lifetime,
|
20
|
-
bytes calldata filter
|
21
|
-
) external returns(NftId bundleNftId);
|
22
|
-
|
23
|
-
function setBundleFee(
|
24
|
-
NftId bundleNftId,
|
25
|
-
Fee memory fee
|
26
|
-
) external;
|
27
|
-
|
28
|
-
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
29
|
-
|
30
|
-
function lockCollateral(
|
31
|
-
IInstance instanceNftId,
|
32
|
-
NftId policyNftId,
|
33
|
-
NftId bundleNftId,
|
34
|
-
uint256 collateralAmount,
|
35
|
-
uint256 netPremium
|
36
|
-
)
|
37
|
-
external
|
38
|
-
returns (
|
39
|
-
IBundle.BundleInfo memory bundleInfo
|
40
|
-
);
|
41
|
-
|
42
|
-
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
43
|
-
|
44
|
-
function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
|
45
|
-
|
46
|
-
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
47
|
-
|
48
|
-
// function defundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
49
|
-
|
50
|
-
function lockBundle(NftId bundleNftId) external;
|
51
|
-
|
52
|
-
function unlockBundle(NftId bundleNftId) external;
|
53
|
-
|
54
|
-
// function closeBundle(NftId bundleNftId) external;
|
55
|
-
}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {IRisk} from "../module/IRisk.sol";
|
5
|
-
import {IService} from "../../shared/IService.sol";
|
6
|
-
|
7
|
-
import {ClaimId} from "../../types/ClaimId.sol";
|
8
|
-
import {PayoutId} from "../../types/PayoutId.sol";
|
9
|
-
import {NftId} from "../../types/NftId.sol";
|
10
|
-
import {ReferralId} from "../../types/Referral.sol";
|
11
|
-
import {RiskId} from "../../types/RiskId.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 claims and payouts
|
18
|
-
/// only product components may call transaction functions
|
19
|
-
interface IClaimService is
|
20
|
-
IService
|
21
|
-
{
|
22
|
-
|
23
|
-
/// @dev create a new claim for the specified policy
|
24
|
-
/// function can only be called by product, policy needs to match with calling product
|
25
|
-
function createClaim(
|
26
|
-
NftId policyNftId,
|
27
|
-
uint256 claimAmount,
|
28
|
-
bytes memory claimData
|
29
|
-
) external returns (ClaimId);
|
30
|
-
|
31
|
-
/// @dev confirms the specified claim and fixes the final claim amount
|
32
|
-
/// function can only be called by product, policy needs to match with calling product
|
33
|
-
function confirmClaim(NftId policyNftId, ClaimId claimId, uint256 claimAmount) external;
|
34
|
-
|
35
|
-
/// @dev declares the claim as invalid, no payout(s) will be made
|
36
|
-
/// function can only be called by product, policy needs to match with calling product
|
37
|
-
function declineClaim(NftId policyNftId, ClaimId claimId) external;
|
38
|
-
|
39
|
-
/// @dev closes the claim
|
40
|
-
/// a claim may only be closed once all existing payouts have been executed and the sum of the paid out amounts has reached the claim amount
|
41
|
-
/// function can only be called by product, policy needs to match with calling product
|
42
|
-
function closeClaim(NftId policyNftId, ClaimId claimId) external;
|
43
|
-
|
44
|
-
/// @dev create a new payout for the specified policy and claim
|
45
|
-
/// function can only be called by product, policy needs to match with calling product
|
46
|
-
function createPayout(
|
47
|
-
NftId policyNftId,
|
48
|
-
ClaimId claimId,
|
49
|
-
uint256 payoutAmount,
|
50
|
-
bytes calldata payoutData
|
51
|
-
) external returns (PayoutId payoutId);
|
52
|
-
|
53
|
-
/// @dev callback function to confirm transfer of payout token to beneficiary
|
54
|
-
/// allows claim service to update claims/payout book keeping
|
55
|
-
/// only pool service can confirm executed payout
|
56
|
-
function payoutExecuted(
|
57
|
-
NftId policyNftId,
|
58
|
-
PayoutId payoutId
|
59
|
-
) external;
|
60
|
-
|
61
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {NftId} from "../../types/NftId.sol";
|
5
|
-
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {StateId} from "../../types/StateId.sol";
|
7
|
-
import {IService} from "../../shared/IService.sol";
|
8
|
-
import {IBundle} from "../module/IBundle.sol";
|
9
|
-
import {IInstance} from "../../instance/IInstance.sol";
|
10
|
-
|
11
|
-
interface IPoolService is IService {
|
12
|
-
|
13
|
-
function register(address poolAddress) external returns(NftId);
|
14
|
-
|
15
|
-
function setFees(
|
16
|
-
Fee memory poolFee,
|
17
|
-
Fee memory stakingFee,
|
18
|
-
Fee memory performanceFee
|
19
|
-
) external;
|
20
|
-
}
|