@etherisc/gif-next 0.0.2-b1059a4-617 → 0.0.2-b13fcec-949
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/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +68 -89
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +113 -183
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +65 -73
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +90 -164
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +256 -189
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +69 -145
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +279 -245
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +73 -162
- 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 +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
- 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 +171 -308
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +109 -40
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +260 -379
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +448 -121
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +120 -227
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +159 -161
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +31 -23
- 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/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +12 -1
- 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 +54 -71
- 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 +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +172 -62
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +33 -25
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +139 -131
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +12 -12
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +14 -3
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +2 -2
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +864 -67
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +142 -14
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +121 -27
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +104 -96
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +11 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +540 -7
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +32 -64
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +92 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +11 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +69 -157
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +19 -47
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +125 -17
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -9
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +18 -7
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +4 -4
- 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 +11 -0
- 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 +31 -12
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +16 -5
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +3 -3
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +7 -7
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- 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/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +11 -0
- 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 +2 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +3 -3
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +12 -1
- 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/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 +3 -3
- 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 +14 -3
- 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 +2 -2
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
- 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 +2 -2
- package/contracts/components/Component.sol +95 -85
- package/contracts/components/Distribution.sol +16 -44
- package/contracts/components/IComponent.sol +37 -17
- package/contracts/components/IDistributionComponent.sol +1 -30
- package/contracts/components/IPoolComponent.sol +73 -47
- package/contracts/components/IProductComponent.sol +3 -2
- package/contracts/components/Pool.sol +171 -126
- package/contracts/components/Product.sol +26 -18
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +7 -5
- package/contracts/instance/Cloneable.sol +7 -2
- package/contracts/instance/IInstance.sol +16 -10
- package/contracts/instance/IInstanceService.sol +18 -5
- package/contracts/instance/Instance.sol +45 -9
- package/contracts/instance/InstanceAccessManager.sol +382 -157
- package/contracts/instance/InstanceReader.sol +7 -10
- package/contracts/instance/InstanceService.sol +174 -155
- package/contracts/instance/ObjectManager.sol +6 -8
- package/contracts/instance/base/ComponentService.sol +5 -5
- package/contracts/instance/base/KeyValueStore.sol +5 -2
- package/contracts/instance/base/Lifecycle.sol +11 -2
- package/contracts/instance/module/IAccess.sol +20 -13
- package/contracts/instance/module/IBundle.sol +2 -1
- package/contracts/instance/module/IComponents.sol +35 -0
- package/contracts/instance/module/IDistribution.sol +2 -0
- package/contracts/instance/module/IPolicy.sol +26 -1
- package/contracts/instance/module/ISetup.sol +7 -21
- package/contracts/instance/service/ApplicationService.sol +123 -41
- package/contracts/instance/service/BundleService.sol +76 -38
- package/contracts/instance/service/DistributionService.sol +213 -23
- package/contracts/instance/service/IApplicationService.sol +7 -7
- package/contracts/instance/service/IBundleService.sol +19 -11
- package/contracts/instance/service/IDistributionService.sol +36 -3
- package/contracts/instance/service/IPolicyService.sol +3 -20
- package/contracts/instance/service/IPoolService.sol +17 -2
- package/contracts/instance/service/PolicyService.sol +59 -130
- package/contracts/instance/service/PoolService.sol +128 -17
- package/contracts/instance/service/ProductService.sol +10 -2
- package/contracts/registry/ChainNft.sol +8 -0
- package/contracts/registry/IRegistry.sol +2 -0
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +23 -20
- package/contracts/registry/RegistryService.sol +5 -5
- package/contracts/shared/IService.sol +2 -0
- package/contracts/shared/Registerable.sol +2 -2
- package/contracts/shared/TokenHandler.sol +11 -5
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/Fee.sol +1 -0
- package/contracts/types/NftId.sol +8 -0
- package/contracts/types/ObjectType.sol +1 -0
- package/contracts/types/Referral.sol +4 -0
- package/contracts/types/RoleId.sol +13 -6
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/StateId.sol +1 -0
- package/contracts/types/Timestamp.sol +13 -13
- package/contracts/types/UFixed.sol +1 -0
- package/contracts/types/Version.sol +1 -0
- package/package.json +1 -1
@@ -1,25 +1,27 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
4
|
+
import {IBundle} from "../../instance/module/IBundle.sol";
|
5
|
+
import {IComponents} from "../module/IComponents.sol";
|
5
6
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
6
7
|
import {IInstance} from "../../instance/IInstance.sol";
|
7
|
-
import {IBundle} from "../../instance/module/IBundle.sol";
|
8
8
|
import {TokenHandler} from "../../instance/module/ITreasury.sol";
|
9
9
|
import {ISetup} from "../module/ISetup.sol";
|
10
10
|
import {IPolicy} from "../module/IPolicy.sol";
|
11
11
|
|
12
12
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
13
|
-
import {Versionable} from "../../shared/Versionable.sol";
|
14
13
|
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
15
|
-
|
16
14
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
17
15
|
import {ObjectType, POOL, BUNDLE} from "../../types/ObjectType.sol";
|
18
16
|
import {POOL_OWNER_ROLE, RoleId} from "../../types/RoleId.sol";
|
17
|
+
import {Pool} from "../../components/Pool.sol";
|
18
|
+
|
19
19
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
20
|
-
import {
|
21
|
-
import {
|
20
|
+
import {StateId, ACTIVE, PAUSED, CLOSED, KEEP_STATE} from "../../types/StateId.sol";
|
21
|
+
import {Seconds} from "../../types/Seconds.sol";
|
22
22
|
import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
23
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
24
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
23
25
|
|
24
26
|
import {IService} from "../../shared/IService.sol";
|
25
27
|
import {Service} from "../../shared/Service.sol";
|
@@ -63,11 +65,11 @@ contract BundleService is
|
|
63
65
|
return BUNDLE();
|
64
66
|
}
|
65
67
|
|
66
|
-
function
|
68
|
+
function create(
|
67
69
|
address owner,
|
68
70
|
Fee memory fee,
|
69
71
|
uint256 stakingAmount,
|
70
|
-
|
72
|
+
Seconds lifetime,
|
71
73
|
bytes calldata filter
|
72
74
|
)
|
73
75
|
external
|
@@ -118,7 +120,7 @@ contract BundleService is
|
|
118
120
|
// TODO add logging
|
119
121
|
}
|
120
122
|
|
121
|
-
function
|
123
|
+
function setFee(
|
122
124
|
NftId bundleNftId,
|
123
125
|
Fee memory fee
|
124
126
|
)
|
@@ -138,30 +140,6 @@ contract BundleService is
|
|
138
140
|
instance.updateBundle(bundleNftId, bundleInfo, KEEP_STATE());
|
139
141
|
}
|
140
142
|
|
141
|
-
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state)
|
142
|
-
external
|
143
|
-
onlyService
|
144
|
-
{
|
145
|
-
IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
|
146
|
-
IInstance instance = IInstance(instanceInfo.objectAddress);
|
147
|
-
instance.updateBundle(bundleNftId, bundleInfo, state);
|
148
|
-
}
|
149
|
-
|
150
|
-
function lockBundle(NftId bundleNftId)
|
151
|
-
external
|
152
|
-
{
|
153
|
-
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
154
|
-
BundleManager bundleManager = instance.getBundleManager();
|
155
|
-
bundleManager.lock(bundleNftId);
|
156
|
-
}
|
157
|
-
|
158
|
-
function unlockBundle(NftId bundleNftId)
|
159
|
-
external
|
160
|
-
{
|
161
|
-
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
162
|
-
BundleManager bundleManager = instance.getBundleManager();
|
163
|
-
bundleManager.unlock(bundleNftId);
|
164
|
-
}
|
165
143
|
|
166
144
|
function lockCollateral(
|
167
145
|
IInstance instance,
|
@@ -190,6 +168,64 @@ contract BundleService is
|
|
190
168
|
linkPolicy(instance, policyNftId);
|
191
169
|
}
|
192
170
|
|
171
|
+
|
172
|
+
function lock(NftId bundleNftId)
|
173
|
+
external
|
174
|
+
virtual
|
175
|
+
{
|
176
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
177
|
+
|
178
|
+
// udpate bundle state
|
179
|
+
instance.updateBundleState(bundleNftId, PAUSED());
|
180
|
+
|
181
|
+
// update set of active bundles
|
182
|
+
BundleManager bundleManager = instance.getBundleManager();
|
183
|
+
bundleManager.lock(bundleNftId);
|
184
|
+
|
185
|
+
emit LogBundleServiceBundleLocked(bundleNftId);
|
186
|
+
}
|
187
|
+
|
188
|
+
|
189
|
+
function unlock(NftId bundleNftId)
|
190
|
+
external
|
191
|
+
virtual
|
192
|
+
{
|
193
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
194
|
+
|
195
|
+
// udpate bundle state
|
196
|
+
instance.updateBundleState(bundleNftId, ACTIVE());
|
197
|
+
|
198
|
+
// update set of active bundles
|
199
|
+
BundleManager bundleManager = instance.getBundleManager();
|
200
|
+
bundleManager.unlock(bundleNftId);
|
201
|
+
|
202
|
+
emit LogBundleServiceBundleActivated(bundleNftId);
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
function close(NftId bundleNftId)
|
207
|
+
external
|
208
|
+
virtual
|
209
|
+
{
|
210
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
211
|
+
|
212
|
+
// udpate bundle state
|
213
|
+
instance.updateBundleState(bundleNftId, CLOSED());
|
214
|
+
|
215
|
+
// ensure no open policies attached to bundle
|
216
|
+
BundleManager bundleManager = instance.getBundleManager();
|
217
|
+
uint256 openPolicies = bundleManager.activePolicies(bundleNftId);
|
218
|
+
if(openPolicies > 0) {
|
219
|
+
revert ErrorBundleServiceBundleWithOpenPolicies(bundleNftId, openPolicies);
|
220
|
+
}
|
221
|
+
|
222
|
+
// update set of active bundles
|
223
|
+
bundleManager.lock(bundleNftId);
|
224
|
+
|
225
|
+
emit LogBundleServiceBundleClosed(bundleNftId);
|
226
|
+
}
|
227
|
+
|
228
|
+
|
193
229
|
function increaseBalance(IInstance instance,
|
194
230
|
NftId bundleNftId,
|
195
231
|
uint256 amount
|
@@ -234,7 +270,7 @@ contract BundleService is
|
|
234
270
|
|
235
271
|
// ensure policy has not yet been activated
|
236
272
|
if (policyInfo.activatedAt.gtz()) {
|
237
|
-
revert BundleManager.
|
273
|
+
revert BundleManager.ErrorBundleManagerPolicyAlreadyActivated(policyNftId);
|
238
274
|
}
|
239
275
|
|
240
276
|
BundleManager bundleManager = instance.getBundleManager();
|
@@ -277,18 +313,20 @@ contract BundleService is
|
|
277
313
|
{
|
278
314
|
// process token transfer(s)
|
279
315
|
if(stakingAmount > 0) {
|
280
|
-
|
281
|
-
|
316
|
+
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
317
|
+
IComponents.PoolInfo memory poolInfo = abi.decode(
|
318
|
+
componentInfo.data, (IComponents.PoolInfo));
|
319
|
+
|
320
|
+
TokenHandler tokenHandler = componentInfo.tokenHandler;
|
282
321
|
address bundleOwner = getRegistry().ownerOf(bundleNftId);
|
283
322
|
Fee memory stakingFee = poolInfo.stakingFee;
|
284
323
|
|
285
324
|
tokenHandler.transfer(
|
286
325
|
bundleOwner,
|
287
|
-
|
326
|
+
componentInfo.wallet,
|
288
327
|
stakingAmount
|
289
328
|
);
|
290
329
|
|
291
|
-
|
292
330
|
if (! FeeLib.feeIsZero(stakingFee)) {
|
293
331
|
(uint256 stakingFeeAmount, uint256 netAmount) = FeeLib.calculateFee(stakingFee, stakingAmount);
|
294
332
|
// TODO: track staking fees in pool's state (issue #177)
|
@@ -6,13 +6,15 @@ import {IInstance} from "../../instance/IInstance.sol";
|
|
6
6
|
import {InstanceAccessManager} from "../InstanceAccessManager.sol";
|
7
7
|
import {InstanceReader} from "../../instance/InstanceReader.sol";
|
8
8
|
import {ISetup} from "../../instance/module/ISetup.sol";
|
9
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
9
10
|
|
10
11
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
11
|
-
import {Fee} from "../../types/Fee.sol";
|
12
|
-
import {DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
|
12
|
+
import {Fee, FeeLib} from "../../types/Fee.sol";
|
13
|
+
import {PRODUCT_SERVICE_ROLE, DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
|
13
14
|
import {KEEP_STATE} from "../../types/StateId.sol";
|
14
15
|
import {ObjectType, DISTRIBUTION, INSTANCE, DISTRIBUTION, DISTRIBUTOR} from "../../types/ObjectType.sol";
|
15
16
|
import {Version, VersionLib} from "../../types/Version.sol";
|
17
|
+
import {RoleId} from "../../types/RoleId.sol";
|
16
18
|
|
17
19
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
18
20
|
import {Versionable} from "../../shared/Versionable.sol";
|
@@ -25,7 +27,7 @@ import {IComponent} from "../../components/IComponent.sol";
|
|
25
27
|
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
26
28
|
import {IDistributionService} from "./IDistributionService.sol";
|
27
29
|
|
28
|
-
import {UFixed} from "../../types/UFixed.sol";
|
30
|
+
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
29
31
|
import {DistributorType, DistributorTypeLib} from "../../types/DistributorType.sol";
|
30
32
|
import {ReferralId, ReferralStatus, ReferralLib} from "../../types/Referral.sol";
|
31
33
|
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
@@ -38,6 +40,10 @@ contract DistributionService is
|
|
38
40
|
IDistributionService
|
39
41
|
{
|
40
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;
|
41
47
|
|
42
48
|
address internal _registryAddress;
|
43
49
|
|
@@ -82,21 +88,43 @@ contract DistributionService is
|
|
82
88
|
distributionNftId = distributionInfo.nftId;
|
83
89
|
|
84
90
|
instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
|
85
|
-
|
86
|
-
|
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);
|
87
109
|
}
|
88
110
|
|
89
111
|
function setFees(
|
112
|
+
Fee memory minDistributionOwnerFee,
|
90
113
|
Fee memory distributionFee
|
91
114
|
)
|
92
115
|
external
|
93
116
|
override
|
94
117
|
{
|
118
|
+
if (minDistributionOwnerFee.fractionalFee > distributionFee.fractionalFee) {
|
119
|
+
revert ErrorIDistributionServiceMinFeeTooHigh(minDistributionOwnerFee.fractionalFee.toInt(), distributionFee.fractionalFee.toInt());
|
120
|
+
}
|
121
|
+
|
95
122
|
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
96
123
|
InstanceReader instanceReader = instance.getInstanceReader();
|
97
124
|
NftId distributionNftId = info.nftId;
|
98
125
|
|
99
126
|
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
127
|
+
distSetupInfo.minDistributionOwnerFee = minDistributionOwnerFee;
|
100
128
|
distSetupInfo.distributionFee = distributionFee;
|
101
129
|
|
102
130
|
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
@@ -117,6 +145,16 @@ contract DistributionService is
|
|
117
145
|
returns (DistributorType distributorType)
|
118
146
|
{
|
119
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
|
+
|
120
158
|
distributorType = DistributorTypeLib.toDistributorType(distributionNftId, name);
|
121
159
|
Key32 key32 = distributorType.toKey32();
|
122
160
|
|
@@ -158,7 +196,9 @@ contract DistributionService is
|
|
158
196
|
IDistribution.DistributorInfo memory info = IDistribution.DistributorInfo(
|
159
197
|
distributorType,
|
160
198
|
true, // active
|
161
|
-
data
|
199
|
+
data,
|
200
|
+
0,
|
201
|
+
0);
|
162
202
|
|
163
203
|
instance.createDistributor(distributorNftId, info);
|
164
204
|
}
|
@@ -170,13 +210,11 @@ contract DistributionService is
|
|
170
210
|
) external virtual
|
171
211
|
{
|
172
212
|
(,, IInstance instance) = _getAndVerifyCallingDistribution();
|
173
|
-
|
174
|
-
IDistribution.DistributorInfo memory
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
instance.updateDistributor(distributorNftId, info, KEEP_STATE());
|
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());
|
180
218
|
}
|
181
219
|
|
182
220
|
|
@@ -193,8 +231,31 @@ contract DistributionService is
|
|
193
231
|
returns (ReferralId referralId)
|
194
232
|
{
|
195
233
|
(,NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
196
|
-
|
197
|
-
|
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
|
+
}
|
198
259
|
|
199
260
|
referralId = ReferralLib.toReferralId(distributionNftId, code);
|
200
261
|
IDistribution.ReferralInfo memory info = IDistribution.ReferralInfo(
|
@@ -212,25 +273,132 @@ contract DistributionService is
|
|
212
273
|
}
|
213
274
|
|
214
275
|
function processSale(
|
276
|
+
NftId distributionNftId,
|
215
277
|
ReferralId referralId,
|
216
|
-
|
278
|
+
IPolicy.Premium memory premium,
|
279
|
+
uint256 transferredDistributionFeeAmount
|
217
280
|
)
|
218
281
|
external
|
219
282
|
virtual
|
220
283
|
{
|
221
|
-
|
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
|
+
}
|
222
320
|
}
|
223
321
|
|
224
322
|
function calculateFeeAmount(
|
323
|
+
NftId distributionNftId,
|
225
324
|
ReferralId referralId,
|
226
|
-
|
325
|
+
IPolicy.Premium memory premium
|
227
326
|
)
|
228
327
|
external
|
229
328
|
virtual
|
230
329
|
view
|
231
|
-
returns (
|
330
|
+
returns (IPolicy.Premium memory finalPremium)
|
232
331
|
{
|
233
|
-
|
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;
|
234
402
|
}
|
235
403
|
|
236
404
|
function _getAndVerifyCallingDistribution()
|
@@ -250,7 +418,25 @@ contract DistributionService is
|
|
250
418
|
instance
|
251
419
|
) = _getAndVerifyCaller();
|
252
420
|
|
253
|
-
|
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);
|
254
440
|
}
|
255
441
|
|
256
442
|
function _getAndVerifyCaller()
|
@@ -265,12 +451,16 @@ contract DistributionService is
|
|
265
451
|
{
|
266
452
|
objectAddress = msg.sender;
|
267
453
|
objectNftId = getRegistry().getNftId(objectAddress);
|
268
|
-
|
454
|
+
if ( objectNftId.eqz()) {
|
455
|
+
revert ErrorIServiceCallerUnknown(objectAddress);
|
456
|
+
}
|
269
457
|
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
|
270
458
|
objectType = info.objectType;
|
271
459
|
|
272
460
|
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
273
|
-
|
461
|
+
if (parentInfo.objectType != INSTANCE()) {
|
462
|
+
revert ErrorIDistributionServiceParentNftIdNotInstance(objectNftId, info.parentNftId);
|
463
|
+
}
|
274
464
|
instance = IInstance(parentInfo.objectAddress);
|
275
465
|
}
|
276
466
|
|
@@ -1,12 +1,14 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
4
5
|
import {IRisk} from "../module/IRisk.sol";
|
5
6
|
import {IService} from "../../shared/IService.sol";
|
6
7
|
|
7
8
|
import {NftId} from "../../types/NftId.sol";
|
8
9
|
import {ReferralId} from "../../types/Referral.sol";
|
9
10
|
import {RiskId} from "../../types/RiskId.sol";
|
11
|
+
import {Seconds} from "../../types/Seconds.sol";
|
10
12
|
import {StateId} from "../../types/StateId.sol";
|
11
13
|
import {Timestamp} from "../../types/Timestamp.sol";
|
12
14
|
import {UFixed} from "../../types/UFixed.sol";
|
@@ -17,6 +19,7 @@ import {Fee} from "../../types/Fee.sol";
|
|
17
19
|
interface IApplicationService is IService {
|
18
20
|
|
19
21
|
error IApplicationServicePolicyNotApplied(NftId applicationNftId);
|
22
|
+
error IApplicationServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
|
20
23
|
|
21
24
|
/// @dev creates a new application based on the specified attributes
|
22
25
|
/// may only be called by a product component
|
@@ -24,7 +27,7 @@ interface IApplicationService is IService {
|
|
24
27
|
address applicationOwner,
|
25
28
|
RiskId riskId,
|
26
29
|
uint256 sumInsuredAmount,
|
27
|
-
|
30
|
+
Seconds lifetime,
|
28
31
|
NftId bundleNftId,
|
29
32
|
ReferralId referralId,
|
30
33
|
bytes memory applicationData
|
@@ -63,9 +66,10 @@ interface IApplicationService is IService {
|
|
63
66
|
/// @dev calculates the premium amount for the specified attributes
|
64
67
|
/// also returns the various fee components involved with creating a policy
|
65
68
|
function calculatePremium(
|
69
|
+
NftId productNftId,
|
66
70
|
RiskId riskId,
|
67
71
|
uint256 sumInsuredAmount,
|
68
|
-
|
72
|
+
Seconds lifetime,
|
69
73
|
bytes memory applicationData,
|
70
74
|
NftId bundleNftId,
|
71
75
|
ReferralId referralId
|
@@ -73,10 +77,6 @@ interface IApplicationService is IService {
|
|
73
77
|
external
|
74
78
|
view
|
75
79
|
returns (
|
76
|
-
|
77
|
-
uint256 distributionFeeAmount,
|
78
|
-
uint256 productFeeAmount,
|
79
|
-
uint256 poolFeeAmount,
|
80
|
-
uint256 bundleFeeAmount
|
80
|
+
IPolicy.Premium memory premium
|
81
81
|
);
|
82
82
|
}
|
@@ -3,28 +3,36 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../types/NftId.sol";
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {StateId} from "../../types/StateId.sol";
|
7
6
|
import {IService} from "../../shared/IService.sol";
|
8
7
|
import {IBundle} from "../module/IBundle.sol";
|
9
8
|
import {IInstance} from "../../instance/IInstance.sol";
|
9
|
+
import {Seconds} from "../../types/Seconds.sol";
|
10
|
+
import {StateId} from "../../types/StateId.sol";
|
10
11
|
|
11
12
|
interface IBundleService is IService {
|
12
|
-
error ErrorIBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
13
13
|
|
14
|
-
|
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(
|
15
23
|
address owner,
|
16
24
|
Fee memory fee,
|
17
25
|
uint256 amount,
|
18
|
-
|
26
|
+
Seconds lifetime,
|
19
27
|
bytes calldata filter
|
20
28
|
) external returns(NftId bundleNftId);
|
21
29
|
|
22
|
-
|
30
|
+
|
31
|
+
function setFee(
|
23
32
|
NftId bundleNftId,
|
24
33
|
Fee memory fee
|
25
34
|
) external;
|
26
35
|
|
27
|
-
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
28
36
|
|
29
37
|
function lockCollateral(
|
30
38
|
IInstance instanceNftId,
|
@@ -42,13 +50,13 @@ interface IBundleService is IService {
|
|
42
50
|
|
43
51
|
function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
|
44
52
|
|
45
|
-
// function
|
53
|
+
// function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
46
54
|
|
47
|
-
// function
|
55
|
+
// function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
48
56
|
|
49
|
-
function
|
57
|
+
function lock(NftId bundleNftId) external;
|
50
58
|
|
51
|
-
function
|
59
|
+
function unlock(NftId bundleNftId) external;
|
52
60
|
|
53
|
-
|
61
|
+
function close(NftId bundleNftId) external;
|
54
62
|
}
|