@etherisc/gif-next 0.0.2-93de5de-423 → 0.0.2-94237b7-984
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -71
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +78 -89
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +123 -183
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +156 -64
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +169 -143
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +353 -176
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +162 -138
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +299 -245
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +83 -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 +199 -316
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +185 -50
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +288 -387
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +472 -126
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +137 -234
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +313 -169
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +71 -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 +86 -20
- 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 +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/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +261 -80
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +41 -25
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +387 -241
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +74 -14
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +105 -31
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +11 -7
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +933 -70
- 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 +200 -40
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +220 -183
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +90 -13
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +630 -20
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +103 -69
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +521 -13
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +90 -13
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +150 -167
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -47
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +562 -41
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +24 -12
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +115 -41
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
- 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 +0 -13
- 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 +18 -26
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
- 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 +90 -13
- 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 +97 -15
- 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 +112 -26
- 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/Amount.sol/AmountLib.dbg.json +4 -0
- package/artifacts/contracts/types/Amount.sol/AmountLib.json +161 -0
- 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 +40 -9
- 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 +99 -87
- package/contracts/components/Distribution.sol +16 -44
- package/contracts/components/IComponent.sol +40 -18
- 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 +177 -128
- 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 +388 -158
- package/contracts/instance/InstanceReader.sol +8 -10
- package/contracts/instance/InstanceService.sol +184 -165
- package/contracts/instance/ObjectManager.sol +6 -8
- package/contracts/instance/base/ComponentService.sol +17 -30
- package/contracts/instance/base/KeyValueStore.sol +13 -5
- package/contracts/instance/base/Lifecycle.sol +11 -2
- package/contracts/instance/module/IAccess.sol +21 -14
- package/contracts/instance/module/IBundle.sol +8 -5
- package/contracts/instance/module/IComponents.sol +41 -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 +130 -48
- package/contracts/instance/service/BundleService.sol +213 -80
- package/contracts/instance/service/ClaimService.sol +3 -3
- package/contracts/instance/service/DistributionService.sol +212 -54
- package/contracts/instance/service/IApplicationService.sol +7 -7
- package/contracts/instance/service/IBundleService.sol +65 -26
- package/contracts/instance/service/IDistributionService.sol +37 -3
- package/contracts/instance/service/IPolicyService.sol +3 -20
- package/contracts/instance/service/IPoolService.sol +82 -3
- package/contracts/instance/service/PolicyService.sol +107 -219
- package/contracts/instance/service/PoolService.sol +214 -20
- package/contracts/instance/service/ProductService.sol +30 -53
- package/contracts/registry/ChainNft.sol +8 -0
- package/contracts/registry/IRegistry.sol +2 -0
- package/contracts/registry/IRegistryService.sol +4 -3
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +23 -20
- package/contracts/registry/RegistryService.sol +15 -16
- package/contracts/registry/ReleaseManager.sol +20 -18
- package/contracts/shared/IService.sol +4 -4
- package/contracts/shared/Registerable.sol +2 -2
- package/contracts/shared/Service.sol +21 -7
- package/contracts/shared/TokenHandler.sol +11 -5
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/Amount.sol +60 -0
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/Fee.sol +13 -5
- 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
@@ -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
|
|
@@ -54,11 +60,11 @@ contract DistributionService is
|
|
54
60
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
55
61
|
// TODO while DistributionService is not deployed in DistributionServiceManager constructor
|
56
62
|
// owner is DistributionServiceManager deployer
|
57
|
-
initializeService(registryAddress, owner);
|
63
|
+
initializeService(registryAddress, address(0), owner);
|
58
64
|
registerInterface(type(IDistributionService).interfaceId);
|
59
65
|
}
|
60
66
|
|
61
|
-
function getDomain() public pure override
|
67
|
+
function getDomain() public pure override returns(ObjectType) {
|
62
68
|
return DISTRIBUTION();
|
63
69
|
}
|
64
70
|
|
@@ -82,21 +88,42 @@ 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
|
{
|
95
|
-
(
|
118
|
+
if (minDistributionOwnerFee.fractionalFee > distributionFee.fractionalFee) {
|
119
|
+
revert ErrorIDistributionServiceMinFeeTooHigh(minDistributionOwnerFee.fractionalFee.toInt(), distributionFee.fractionalFee.toInt());
|
120
|
+
}
|
121
|
+
|
122
|
+
(NftId distributionNftId, IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
96
123
|
InstanceReader instanceReader = instance.getInstanceReader();
|
97
|
-
NftId distributionNftId = info.nftId;
|
98
124
|
|
99
125
|
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
126
|
+
distSetupInfo.minDistributionOwnerFee = minDistributionOwnerFee;
|
100
127
|
distSetupInfo.distributionFee = distributionFee;
|
101
128
|
|
102
129
|
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
@@ -116,7 +143,17 @@ contract DistributionService is
|
|
116
143
|
external
|
117
144
|
returns (DistributorType distributorType)
|
118
145
|
{
|
119
|
-
(
|
146
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
147
|
+
|
148
|
+
{
|
149
|
+
ISetup.DistributionSetupInfo memory setupInfo = instance.getInstanceReader().getDistributionSetupInfo(distributionNftId);
|
150
|
+
UFixed variableFeesPartsTotal = setupInfo.minDistributionOwnerFee.fractionalFee.add(commissionPercentage);
|
151
|
+
UFixed maxDiscountPercentageLimit = setupInfo.distributionFee.fractionalFee.sub(variableFeesPartsTotal);
|
152
|
+
if (maxDiscountPercentage.gt(maxDiscountPercentageLimit)) {
|
153
|
+
revert ErrorIDistributionServiceMaxDiscountTooHigh(maxDiscountPercentage.toInt(), maxDiscountPercentageLimit.toInt());
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
120
157
|
distributorType = DistributorTypeLib.toDistributorType(distributionNftId, name);
|
121
158
|
Key32 key32 = distributorType.toKey32();
|
122
159
|
|
@@ -142,7 +179,7 @@ contract DistributionService is
|
|
142
179
|
bytes memory data
|
143
180
|
) external returns (NftId distributorNftId)
|
144
181
|
{
|
145
|
-
(
|
182
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
146
183
|
|
147
184
|
distributorNftId = getRegistryService().registerDistributor(
|
148
185
|
IRegistry.ObjectInfo(
|
@@ -158,7 +195,9 @@ contract DistributionService is
|
|
158
195
|
IDistribution.DistributorInfo memory info = IDistribution.DistributorInfo(
|
159
196
|
distributorType,
|
160
197
|
true, // active
|
161
|
-
data
|
198
|
+
data,
|
199
|
+
0,
|
200
|
+
0);
|
162
201
|
|
163
202
|
instance.createDistributor(distributorNftId, info);
|
164
203
|
}
|
@@ -169,14 +208,12 @@ contract DistributionService is
|
|
169
208
|
bytes memory data
|
170
209
|
) external virtual
|
171
210
|
{
|
172
|
-
(
|
173
|
-
|
174
|
-
IDistribution.DistributorInfo memory
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
instance.updateDistributor(distributorNftId, info, KEEP_STATE());
|
211
|
+
(, IInstance instance) = _getAndVerifyCallingDistribution();
|
212
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
213
|
+
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
214
|
+
distributorInfo.distributorType = distributorType;
|
215
|
+
distributorInfo.data = data;
|
216
|
+
instance.updateDistributor(distributorNftId, distributorInfo, KEEP_STATE());
|
180
217
|
}
|
181
218
|
|
182
219
|
|
@@ -192,9 +229,32 @@ contract DistributionService is
|
|
192
229
|
virtual
|
193
230
|
returns (ReferralId referralId)
|
194
231
|
{
|
195
|
-
(
|
196
|
-
|
197
|
-
|
232
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
233
|
+
|
234
|
+
if (bytes(code).length == 0) {
|
235
|
+
revert ErrorIDistributionServiceInvalidReferral(code);
|
236
|
+
}
|
237
|
+
if (expiryAt.eqz()) {
|
238
|
+
revert ErrorIDistributionServiceExpirationInvalid(expiryAt);
|
239
|
+
}
|
240
|
+
|
241
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
242
|
+
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
243
|
+
DistributorType distributorType = distributorInfo.distributorType;
|
244
|
+
IDistribution.DistributorTypeInfo memory distributorTypeData = instanceReader.getDistributorTypeInfo(distributorType);
|
245
|
+
|
246
|
+
if (distributorTypeData.maxReferralCount < maxReferrals) {
|
247
|
+
revert ErrorIDistributionServiceMaxReferralsExceeded(distributorTypeData.maxReferralCount);
|
248
|
+
}
|
249
|
+
if (distributorTypeData.minDiscountPercentage > discountPercentage) {
|
250
|
+
revert ErrorIDistributionServiceDiscountTooLow(distributorTypeData.minDiscountPercentage.toInt(), discountPercentage.toInt());
|
251
|
+
}
|
252
|
+
if (distributorTypeData.maxDiscountPercentage < discountPercentage) {
|
253
|
+
revert ErrorIDistributionServiceDiscountTooHigh(distributorTypeData.maxDiscountPercentage.toInt(), discountPercentage.toInt());
|
254
|
+
}
|
255
|
+
if (expiryAt.toInt() - TimestampLib.blockTimestamp().toInt() > distributorTypeData.maxReferralLifetime) {
|
256
|
+
revert ErrorIDistributionServiceExpiryTooLong(distributorTypeData.maxReferralLifetime, expiryAt.toInt());
|
257
|
+
}
|
198
258
|
|
199
259
|
referralId = ReferralLib.toReferralId(distributionNftId, code);
|
200
260
|
IDistribution.ReferralInfo memory info = IDistribution.ReferralInfo(
|
@@ -212,66 +272,164 @@ contract DistributionService is
|
|
212
272
|
}
|
213
273
|
|
214
274
|
function processSale(
|
275
|
+
NftId distributionNftId,
|
215
276
|
ReferralId referralId,
|
216
|
-
|
277
|
+
IPolicy.Premium memory premium,
|
278
|
+
uint256 transferredDistributionFeeAmount
|
217
279
|
)
|
218
280
|
external
|
219
281
|
virtual
|
220
282
|
{
|
221
|
-
|
283
|
+
bool isReferral = ! referralId.eqz();
|
284
|
+
bool referralValid = referralIsValid(distributionNftId, referralId);
|
285
|
+
|
286
|
+
if (isReferral && ! referralValid) {
|
287
|
+
revert ErrorIDistributionServiceReferralInvalid(distributionNftId, referralId);
|
288
|
+
}
|
289
|
+
|
290
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
291
|
+
InstanceReader reader = instance.getInstanceReader();
|
292
|
+
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
293
|
+
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
294
|
+
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
295
|
+
|
296
|
+
uint256 distributionOwnerFee = premium.distributionOwnerFeeFixAmount + premium.distributionOwnerFeeVarAmount;
|
297
|
+
uint256 commissionAmount = premium.commissionAmount;
|
298
|
+
|
299
|
+
if (transferredDistributionFeeAmount != distributionOwnerFee + commissionAmount) {
|
300
|
+
revert ErrorIDistributionServiceInvalidFeeTransferred(transferredDistributionFeeAmount, distributionOwnerFee + commissionAmount);
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
if (distributionOwnerFee > 0) {
|
305
|
+
setupInfo.sumDistributionOwnerFees += distributionOwnerFee;
|
306
|
+
instance.updateDistributionSetup(distributionNftId, setupInfo, KEEP_STATE());
|
307
|
+
}
|
308
|
+
|
309
|
+
if (isReferral) {
|
310
|
+
referralInfo.usedReferrals += 1;
|
311
|
+
instance.updateReferral(referralId.toKey32(), referralInfo, KEEP_STATE());
|
312
|
+
|
313
|
+
if (commissionAmount > 0) {
|
314
|
+
distributorInfo.sumCommisions += commissionAmount;
|
315
|
+
distributorInfo.numPoliciesSold += 1;
|
316
|
+
instance.updateDistributor(referralInfo.distributorNftId, distributorInfo, KEEP_STATE());
|
317
|
+
}
|
318
|
+
}
|
222
319
|
}
|
223
320
|
|
224
321
|
function calculateFeeAmount(
|
322
|
+
NftId distributionNftId,
|
225
323
|
ReferralId referralId,
|
226
|
-
|
324
|
+
IPolicy.Premium memory premium
|
227
325
|
)
|
228
326
|
external
|
229
327
|
virtual
|
230
328
|
view
|
231
|
-
returns (
|
329
|
+
returns (IPolicy.Premium memory finalPremium)
|
232
330
|
{
|
233
|
-
|
331
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
332
|
+
InstanceReader reader = instance.getInstanceReader();
|
333
|
+
|
334
|
+
// first calculate all fixed and variable fees for the distribution - this will defined the fullPremium
|
335
|
+
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
336
|
+
Fee memory distributionFee = setupInfo.distributionFee;
|
337
|
+
Fee memory minDistributionOwnerFee = setupInfo.minDistributionOwnerFee;
|
338
|
+
uint256 distributionFeeVarAmount = (UFixedLib.toUFixed(premium.netPremiumAmount) * distributionFee.fractionalFee).toInt();
|
339
|
+
premium.distributionFeeVarAmount = distributionFeeVarAmount;
|
340
|
+
premium.fullPremiumAmount += distributionFeeVarAmount;
|
341
|
+
|
342
|
+
// if the referral is not valid, then the distribution owner gets everything
|
343
|
+
if (! referralIsValid(distributionNftId, referralId)) {
|
344
|
+
premium.distributionOwnerFeeFixAmount = premium.distributionFeeFixAmount;
|
345
|
+
premium.distributionOwnerFeeVarAmount = premium.distributionFeeVarAmount;
|
346
|
+
premium.premiumAmount = premium.fullPremiumAmount;
|
347
|
+
return premium;
|
348
|
+
}
|
349
|
+
|
350
|
+
// if the referral is valid, the the commission and discount are calculated based in the full premium
|
351
|
+
// the remaing amount goes to the distribution owner
|
352
|
+
{
|
353
|
+
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
354
|
+
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
355
|
+
IDistribution.DistributorTypeInfo memory distributorTypeInfo = reader.getDistributorTypeInfo(distributorInfo.distributorType);
|
356
|
+
|
357
|
+
uint256 commissionAmount = UFixedLib.toUFixed(premium.netPremiumAmount).mul(distributorTypeInfo.commissionPercentage).toInt();
|
358
|
+
premium.commissionAmount = commissionAmount;
|
359
|
+
premium.discountAmount = UFixedLib.toUFixed(premium.fullPremiumAmount).mul(referralInfo.discountPercentage).toInt();
|
360
|
+
premium.distributionOwnerFeeFixAmount = minDistributionOwnerFee.fixedFee;
|
361
|
+
premium.distributionOwnerFeeVarAmount = distributionFeeVarAmount - commissionAmount - premium.discountAmount;
|
362
|
+
premium.premiumAmount = premium.fullPremiumAmount - premium.discountAmount;
|
363
|
+
}
|
364
|
+
|
365
|
+
// sanity check to validate the fee calculation
|
366
|
+
if (premium.distributionOwnerFeeFixAmount < minDistributionOwnerFee.fixedFee) {
|
367
|
+
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
368
|
+
premium.distributionFeeFixAmount,
|
369
|
+
premium.distributionFeeVarAmount,
|
370
|
+
premium.distributionOwnerFeeFixAmount,
|
371
|
+
premium.distributionOwnerFeeVarAmount,
|
372
|
+
premium.commissionAmount,
|
373
|
+
premium.discountAmount
|
374
|
+
);
|
375
|
+
}
|
376
|
+
if ((premium.distributionFeeVarAmount) != (premium.discountAmount + premium.distributionOwnerFeeVarAmount + premium.commissionAmount)) {
|
377
|
+
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
378
|
+
premium.distributionFeeFixAmount,
|
379
|
+
premium.distributionFeeVarAmount,
|
380
|
+
premium.distributionOwnerFeeFixAmount,
|
381
|
+
premium.distributionOwnerFeeVarAmount,
|
382
|
+
premium.commissionAmount,
|
383
|
+
premium.discountAmount
|
384
|
+
);
|
385
|
+
}
|
386
|
+
|
387
|
+
return premium;
|
388
|
+
}
|
389
|
+
|
390
|
+
// TODO: zero should return false
|
391
|
+
function referralIsValid(NftId distributionNftId, ReferralId referralId) public view returns (bool isValid) {
|
392
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
393
|
+
IDistribution.ReferralInfo memory info = instance.getInstanceReader().getReferralInfo(referralId);
|
394
|
+
|
395
|
+
if (info.distributorNftId.eqz()) {
|
396
|
+
return false;
|
397
|
+
}
|
398
|
+
|
399
|
+
isValid = info.expiryAt.eqz() || (info.expiryAt.gtz() && TimestampLib.blockTimestamp() <= info.expiryAt);
|
400
|
+
isValid = isValid && info.usedReferrals < info.maxReferrals;
|
234
401
|
}
|
235
402
|
|
236
403
|
function _getAndVerifyCallingDistribution()
|
237
404
|
internal
|
238
405
|
view
|
239
406
|
returns(
|
240
|
-
address distributionAddress,
|
241
407
|
NftId distributionNftId,
|
242
408
|
IInstance instance
|
243
409
|
)
|
244
410
|
{
|
245
|
-
|
246
|
-
(
|
247
|
-
|
248
|
-
|
249
|
-
objectType,
|
250
|
-
instance
|
251
|
-
) = _getAndVerifyCaller();
|
411
|
+
distributionNftId = getRegistry().getNftId(msg.sender);
|
412
|
+
if (distributionNftId.eqz()) {
|
413
|
+
revert ErrorDistributionServiceCallerNotRegistered(msg.sender);
|
414
|
+
}
|
252
415
|
|
253
|
-
|
416
|
+
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(distributionNftId);
|
417
|
+
if(info.objectType != DISTRIBUTION()) {
|
418
|
+
revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
|
419
|
+
}
|
420
|
+
|
421
|
+
address instanceAddress = getRegistry().getObjectInfo(info.parentNftId).objectAddress;
|
422
|
+
instance = IInstance(instanceAddress);
|
254
423
|
}
|
255
424
|
|
256
|
-
|
425
|
+
|
426
|
+
function _getInstanceForDistribution(NftId distributionNftId)
|
257
427
|
internal
|
258
428
|
view
|
259
|
-
returns(
|
260
|
-
address objectAddress,
|
261
|
-
NftId objectNftId,
|
262
|
-
ObjectType objectType,
|
263
|
-
IInstance instance
|
264
|
-
)
|
429
|
+
returns(IInstance instance)
|
265
430
|
{
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
|
270
|
-
objectType = info.objectType;
|
271
|
-
|
272
|
-
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
273
|
-
require(parentInfo.objectType == INSTANCE(), "ERROR:SRV-031:PARENT_NOT_INSTANCE");
|
274
|
-
instance = IInstance(parentInfo.objectAddress);
|
431
|
+
NftId instanceNftId = getRegistry().getObjectInfo(distributionNftId).parentNftId;
|
432
|
+
address instanceAddress = getRegistry().getObjectInfo(instanceNftId).objectAddress;
|
433
|
+
return IInstance(instanceAddress);
|
275
434
|
}
|
276
|
-
|
277
435
|
}
|
@@ -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
|
}
|
@@ -1,54 +1,93 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
+
import {Amount} from "../../types/Amount.sol";
|
4
5
|
import {NftId} from "../../types/NftId.sol";
|
5
6
|
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {StateId} from "../../types/StateId.sol";
|
7
7
|
import {IService} from "../../shared/IService.sol";
|
8
8
|
import {IBundle} from "../module/IBundle.sol";
|
9
9
|
import {IInstance} from "../../instance/IInstance.sol";
|
10
|
+
import {Seconds} from "../../types/Seconds.sol";
|
11
|
+
import {StateId} from "../../types/StateId.sol";
|
12
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
10
13
|
|
11
14
|
interface IBundleService is IService {
|
12
|
-
error ErrorIBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
event LogBundleServiceBundleActivated(NftId bundleNftId);
|
17
|
+
event LogBundleServiceBundleLocked(NftId bundleNftId);
|
18
|
+
|
19
|
+
error ErrorBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
20
|
+
error ErrorBundleServiceBundleNotOpen(NftId bundleNftId, StateId state, Timestamp expiredAt);
|
21
|
+
error ErrorBundleServiceCapacityInsufficient(NftId bundleNftId, uint capacityAmount, uint collateralAmount);
|
22
|
+
error ErrorBundleServiceBundleWithOpenPolicies(NftId bundleNftId, uint256 openPoliciesCount);
|
23
|
+
|
24
|
+
/// @dev create a new bundle for the specified attributes
|
25
|
+
/// may only be called by pool service
|
26
|
+
function create(
|
27
|
+
IInstance instance, // instance relevant for bundle
|
28
|
+
NftId poolNftId, // the pool the bundle will be linked to
|
29
|
+
address owner, // initial bundle owner
|
30
|
+
Fee memory fee, // fees deducted from premium that go to bundle owner
|
31
|
+
Amount stakingAmount, // staking amount - staking fees result in initial bundle capital
|
32
|
+
Seconds lifetime, // initial duration for which new policies are covered
|
33
|
+
bytes calldata filter // optional use case specific criteria that define if a policy may be covered by this bundle
|
34
|
+
)
|
35
|
+
external
|
36
|
+
returns(NftId bundleNftId); // the nft id of the newly created bundle
|
37
|
+
|
38
|
+
/// @dev locks the specified bundle, locked bundles are not available to collateralize new policies
|
39
|
+
/// only active bundles may be locked
|
40
|
+
/// may only be called by registered and unlocked pool components
|
41
|
+
function lock(NftId bundleNftId) external;
|
42
|
+
|
43
|
+
/// @dev activates the specified bundle
|
44
|
+
/// only locked bundles may be unlocked
|
45
|
+
/// may only be called by registered and unlocked pool components
|
46
|
+
function unlock(NftId bundleNftId) external;
|
47
|
+
|
48
|
+
/// @dev closes the specified bundle
|
49
|
+
/// only open bundles (active or locked) may be closed
|
50
|
+
/// to close a bundle it may not have any non-closed polices attached to it
|
51
|
+
/// may only be called by registered and unlocked pool components
|
52
|
+
function close(
|
53
|
+
IInstance instance,
|
54
|
+
NftId bundleNftId
|
55
|
+
) external;
|
21
56
|
|
22
|
-
|
57
|
+
/// @dev set bundle fee to provided value
|
58
|
+
/// may only be called by registered and unlocked pool components
|
59
|
+
function setFee(
|
23
60
|
NftId bundleNftId,
|
24
61
|
Fee memory fee
|
25
62
|
) external;
|
26
63
|
|
27
|
-
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
28
64
|
|
65
|
+
/// @dev locks the specified collateral in the bundle
|
66
|
+
/// the locked collateral is added to the bundle locked capital
|
67
|
+
/// the bundles' fees are updated with the fees for this premium
|
68
|
+
/// the premium (minus bundle fee) is added to the bundle capital
|
69
|
+
/// may only be called by pool service
|
29
70
|
function lockCollateral(
|
30
71
|
IInstance instanceNftId,
|
31
72
|
NftId policyNftId,
|
32
73
|
NftId bundleNftId,
|
33
74
|
uint256 collateralAmount,
|
34
|
-
uint256
|
35
|
-
)
|
36
|
-
external
|
37
|
-
returns (
|
38
|
-
IBundle.BundleInfo memory bundleInfo
|
39
|
-
);
|
40
|
-
|
41
|
-
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
42
|
-
|
43
|
-
function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
|
75
|
+
uint256 premium // premium amount after pool fee
|
76
|
+
) external;
|
44
77
|
|
45
|
-
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
46
78
|
|
47
|
-
|
79
|
+
/// @dev releases the specified collateral in the bundle
|
80
|
+
/// may only be called by pool service
|
81
|
+
function releaseCollateral(
|
82
|
+
IInstance instance,
|
83
|
+
NftId policyNftId,
|
84
|
+
NftId bundleNftId,
|
85
|
+
uint256 collateralAmount
|
86
|
+
) external;
|
48
87
|
|
49
|
-
function
|
88
|
+
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
50
89
|
|
51
|
-
function
|
90
|
+
// function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
52
91
|
|
53
|
-
// function
|
92
|
+
// function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
54
93
|
}
|
@@ -3,6 +3,7 @@ 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 {IPolicy} from "../module/IPolicy.sol";
|
6
7
|
import {IService} from "../../shared/IService.sol";
|
7
8
|
import {UFixed} from "../../types/UFixed.sol";
|
8
9
|
import {DistributorType} from "../../types/DistributorType.sol";
|
@@ -11,7 +12,32 @@ import {Timestamp} from "../../types/Timestamp.sol";
|
|
11
12
|
|
12
13
|
|
13
14
|
interface IDistributionService is IService {
|
15
|
+
error ErrorDistributionServiceCallerNotRegistered(address caller);
|
16
|
+
error ErrorIDistributionServiceParentNftIdNotInstance(NftId nftId, NftId parentNftId);
|
17
|
+
error ErrorIDistributionServiceCallerNotDistributor(address caller);
|
18
|
+
error ErrorIDistributionServiceInvalidReferralId(ReferralId referralId);
|
19
|
+
error ErrorIDistributionServiceMaxReferralsExceeded(uint256 maxReferrals);
|
20
|
+
error ErrorIDistributionServiceDiscountTooLow(uint256 minDiscountPercentage, uint256 discountPercentage);
|
21
|
+
error ErrorIDistributionServiceDiscountTooHigh(uint256 maxDiscountPercentage, uint256 discountPercentage);
|
22
|
+
error ErrorIDistributionServiceExpiryTooLong(uint256 maxReferralLifetime, uint256 expiryAt);
|
23
|
+
error ErrorIDistributionServiceInvalidReferral(string code);
|
24
|
+
error ErrorIDistributionServiceExpirationInvalid(Timestamp expiryAt);
|
25
|
+
error ErrorIDistributionServiceCommissionTooHigh(uint256 commissionPercentage, uint256 maxCommissionPercentage);
|
26
|
+
error ErrorIDistributionServiceMinFeeTooHigh(uint256 minFee, uint256 limit);
|
27
|
+
error ErrorIDistributionServiceMaxDiscountTooHigh(uint256 maxDiscountPercentage, uint256 limit);
|
28
|
+
error ErrorIDistributionServiceFeeCalculationMismatch(
|
29
|
+
uint256 distributionFeeFixAmount,
|
30
|
+
uint256 distributionFeeVarAmount,
|
31
|
+
uint256 distributionOwnerFeeFixAmount,
|
32
|
+
uint256 distributionOwnerFeeVarAmount,
|
33
|
+
uint256 commissionAmount,
|
34
|
+
uint256 discountAmount
|
35
|
+
);
|
36
|
+
error ErrorIDistributionServiceReferralInvalid(NftId distributionNftId, ReferralId referralId);
|
37
|
+
error ErrorIDistributionServiceInvalidFeeTransferred(uint256 transferredDistributionFeeAmount, uint256 expectedDistributionFeeAmount);
|
38
|
+
|
14
39
|
function setFees(
|
40
|
+
Fee memory minDistributionOwnerFee,
|
15
41
|
Fee memory distributionFee
|
16
42
|
) external;
|
17
43
|
|
@@ -54,12 +80,20 @@ interface IDistributionService is IService {
|
|
54
80
|
|
55
81
|
/// @dev callback from product service when selling a policy for a specific referralId
|
56
82
|
function processSale(
|
83
|
+
NftId distributionNftId,
|
57
84
|
ReferralId referralId,
|
58
|
-
|
85
|
+
IPolicy.Premium memory premium,
|
86
|
+
uint256 transferredDistributionFeeAmount
|
59
87
|
) external;
|
60
88
|
|
61
89
|
function calculateFeeAmount(
|
90
|
+
NftId distributionNftId,
|
62
91
|
ReferralId referralId,
|
63
|
-
|
64
|
-
) external view returns (
|
92
|
+
IPolicy.Premium memory premium
|
93
|
+
) external view returns (IPolicy.Premium memory finalPremium);
|
94
|
+
|
95
|
+
function referralIsValid(
|
96
|
+
NftId distributorNftId,
|
97
|
+
ReferralId referralId
|
98
|
+
) external view returns (bool isValid);
|
65
99
|
}
|
@@ -7,6 +7,7 @@ import {IService} from "../../shared/IService.sol";
|
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
8
|
import {ReferralId} from "../../types/Referral.sol";
|
9
9
|
import {RiskId} from "../../types/RiskId.sol";
|
10
|
+
import {Seconds} from "../../types/Seconds.sol";
|
10
11
|
import {StateId} from "../../types/StateId.sol";
|
11
12
|
import {Timestamp} from "../../types/Timestamp.sol";
|
12
13
|
import {UFixed} from "../../types/UFixed.sol";
|
@@ -23,6 +24,8 @@ interface IPolicyService is IService {
|
|
23
24
|
error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
24
25
|
error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
25
26
|
|
27
|
+
error ErrorIPolicyServicePremiumMismatch(NftId policyNftId, uint256 premiumAmount, uint256 recalculatedPremiumAmount);
|
28
|
+
|
26
29
|
/// @dev declines an application represented by {policyNftId}
|
27
30
|
/// an application can only be declined in applied state
|
28
31
|
/// only the related product may decline an application
|
@@ -60,26 +63,6 @@ interface IPolicyService is IService {
|
|
60
63
|
/// this function can only be called by a product. the policy needs to match with the calling product
|
61
64
|
function close(NftId policyNftId) external;
|
62
65
|
|
63
|
-
/// @dev calculates the total premium amount for the specified attributes
|
64
|
-
/// also returns the various fees included in the total premium amount
|
65
|
-
function calculatePremium(
|
66
|
-
RiskId riskId,
|
67
|
-
uint256 sumInsuredAmount,
|
68
|
-
uint256 lifetime,
|
69
|
-
bytes memory applicationData,
|
70
|
-
NftId bundleNftId,
|
71
|
-
ReferralId referralId
|
72
|
-
)
|
73
|
-
external
|
74
|
-
view
|
75
|
-
returns (
|
76
|
-
uint256 premiumAmount,
|
77
|
-
uint256 productFeeAmount,
|
78
|
-
uint256 poolFeeAmount,
|
79
|
-
uint256 bundleFeeAmount,
|
80
|
-
uint256 distributionFeeAmount
|
81
|
-
);
|
82
|
-
|
83
66
|
// TODO move function to pool service
|
84
67
|
function calculateRequiredCollateral(
|
85
68
|
UFixed collateralizationLevel,
|