@etherisc/gif-next 0.0.2-da0f894-204 → 0.0.2-db1e1e4-828
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 +6 -83
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +68 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +64 -14
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +158 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +150 -10
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +184 -149
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +158 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +114 -189
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +68 -0
- 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 +127 -182
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +175 -51
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +215 -252
- 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 +102 -168
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +304 -171
- 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 +85 -30
- 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 +145 -53
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +21 -13
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +384 -249
- 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 +104 -41
- 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 +356 -111
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +57 -45
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +101 -14
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +212 -186
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +80 -14
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +250 -18
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +106 -19
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +511 -14
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +152 -60
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -19
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +561 -51
- 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 +114 -51
- 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 -24
- 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 +17 -36
- 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 +80 -14
- 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 +2 -2
- 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 +86 -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 +2 -2
- 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 +101 -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 +1 -1
- 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 +2 -2
- 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 +42 -10
- package/contracts/components/Distribution.sol +0 -13
- package/contracts/components/IComponent.sol +9 -1
- package/contracts/components/IDistributionComponent.sol +0 -8
- package/contracts/components/IPoolComponent.sol +5 -43
- package/contracts/components/Pool.sol +47 -122
- package/contracts/components/Product.sol +4 -0
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +6 -4
- 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 +46 -9
- package/contracts/instance/InstanceAccessManager.sol +388 -158
- package/contracts/instance/InstanceReader.sol +8 -10
- package/contracts/instance/InstanceService.sol +184 -179
- 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 +6 -4
- package/contracts/instance/module/IComponents.sol +41 -0
- package/contracts/instance/module/ISetup.sol +4 -17
- package/contracts/instance/service/ApplicationService.sol +22 -18
- package/contracts/instance/service/BundleService.sol +209 -77
- package/contracts/instance/service/ClaimService.sol +3 -3
- package/contracts/instance/service/DistributionService.sol +118 -77
- package/contracts/instance/service/IApplicationService.sol +1 -0
- package/contracts/instance/service/IBundleService.sol +63 -25
- package/contracts/instance/service/IDistributionService.sol +14 -1
- package/contracts/instance/service/IPolicyService.sol +2 -0
- package/contracts/instance/service/IPoolService.sol +82 -3
- package/contracts/instance/service/PolicyService.sol +96 -138
- 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 +10 -11
- package/contracts/registry/ReleaseManager.sol +20 -18
- package/contracts/shared/IService.sol +4 -6
- 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 +6 -4
- package/contracts/types/StateId.sol +1 -0
- package/contracts/types/Timestamp.sol +1 -0
- package/contracts/types/UFixed.sol +1 -0
- package/contracts/types/Version.sol +1 -0
- package/package.json +1 -1
@@ -10,10 +10,11 @@ import {IPolicy} from "../module/IPolicy.sol";
|
|
10
10
|
|
11
11
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
12
12
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
13
|
-
import {DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
|
13
|
+
import {PRODUCT_SERVICE_ROLE, DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
|
14
14
|
import {KEEP_STATE} from "../../types/StateId.sol";
|
15
15
|
import {ObjectType, DISTRIBUTION, INSTANCE, DISTRIBUTION, DISTRIBUTOR} from "../../types/ObjectType.sol";
|
16
16
|
import {Version, VersionLib} from "../../types/Version.sol";
|
17
|
+
import {RoleId} from "../../types/RoleId.sol";
|
17
18
|
|
18
19
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
19
20
|
import {Versionable} from "../../shared/Versionable.sol";
|
@@ -42,6 +43,7 @@ contract DistributionService is
|
|
42
43
|
using TimestampLib for Timestamp;
|
43
44
|
using UFixedLib for UFixed;
|
44
45
|
using FeeLib for Fee;
|
46
|
+
using ReferralLib for ReferralId;
|
45
47
|
|
46
48
|
address internal _registryAddress;
|
47
49
|
|
@@ -58,11 +60,11 @@ contract DistributionService is
|
|
58
60
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
59
61
|
// TODO while DistributionService is not deployed in DistributionServiceManager constructor
|
60
62
|
// owner is DistributionServiceManager deployer
|
61
|
-
initializeService(registryAddress, owner);
|
63
|
+
initializeService(registryAddress, address(0), owner);
|
62
64
|
registerInterface(type(IDistributionService).interfaceId);
|
63
65
|
}
|
64
66
|
|
65
|
-
function getDomain() public pure override
|
67
|
+
function getDomain() public pure override returns(ObjectType) {
|
66
68
|
return DISTRIBUTION();
|
67
69
|
}
|
68
70
|
|
@@ -86,8 +88,24 @@ contract DistributionService is
|
|
86
88
|
distributionNftId = distributionInfo.nftId;
|
87
89
|
|
88
90
|
instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
|
89
|
-
|
90
|
-
|
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);
|
91
109
|
}
|
92
110
|
|
93
111
|
function setFees(
|
@@ -101,9 +119,8 @@ contract DistributionService is
|
|
101
119
|
revert ErrorIDistributionServiceMinFeeTooHigh(minDistributionOwnerFee.fractionalFee.toInt(), distributionFee.fractionalFee.toInt());
|
102
120
|
}
|
103
121
|
|
104
|
-
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
122
|
+
(NftId distributionNftId, IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
105
123
|
InstanceReader instanceReader = instance.getInstanceReader();
|
106
|
-
NftId distributionNftId = info.nftId;
|
107
124
|
|
108
125
|
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
109
126
|
distSetupInfo.minDistributionOwnerFee = minDistributionOwnerFee;
|
@@ -126,7 +143,7 @@ contract DistributionService is
|
|
126
143
|
external
|
127
144
|
returns (DistributorType distributorType)
|
128
145
|
{
|
129
|
-
(
|
146
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
130
147
|
|
131
148
|
{
|
132
149
|
ISetup.DistributionSetupInfo memory setupInfo = instance.getInstanceReader().getDistributionSetupInfo(distributionNftId);
|
@@ -162,7 +179,7 @@ contract DistributionService is
|
|
162
179
|
bytes memory data
|
163
180
|
) external returns (NftId distributorNftId)
|
164
181
|
{
|
165
|
-
(
|
182
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
166
183
|
|
167
184
|
distributorNftId = getRegistryService().registerDistributor(
|
168
185
|
IRegistry.ObjectInfo(
|
@@ -191,7 +208,7 @@ contract DistributionService is
|
|
191
208
|
bytes memory data
|
192
209
|
) external virtual
|
193
210
|
{
|
194
|
-
(
|
211
|
+
(, IInstance instance) = _getAndVerifyCallingDistribution();
|
195
212
|
InstanceReader instanceReader = instance.getInstanceReader();
|
196
213
|
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
197
214
|
distributorInfo.distributorType = distributorType;
|
@@ -212,7 +229,7 @@ contract DistributionService is
|
|
212
229
|
virtual
|
213
230
|
returns (ReferralId referralId)
|
214
231
|
{
|
215
|
-
(
|
232
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
216
233
|
|
217
234
|
if (bytes(code).length == 0) {
|
218
235
|
revert ErrorIDistributionServiceInvalidReferral(code);
|
@@ -255,20 +272,50 @@ contract DistributionService is
|
|
255
272
|
}
|
256
273
|
|
257
274
|
function processSale(
|
275
|
+
NftId distributionNftId,
|
258
276
|
ReferralId referralId,
|
259
|
-
|
277
|
+
IPolicy.Premium memory premium,
|
278
|
+
uint256 transferredDistributionFeeAmount
|
260
279
|
)
|
261
280
|
external
|
262
281
|
virtual
|
263
282
|
{
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
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
|
+
}
|
272
319
|
}
|
273
320
|
|
274
321
|
function calculateFeeAmount(
|
@@ -281,7 +328,7 @@ contract DistributionService is
|
|
281
328
|
view
|
282
329
|
returns (IPolicy.Premium memory finalPremium)
|
283
330
|
{
|
284
|
-
|
331
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
285
332
|
InstanceReader reader = instance.getInstanceReader();
|
286
333
|
|
287
334
|
// first calculate all fixed and variable fees for the distribution - this will defined the fullPremium
|
@@ -302,22 +349,47 @@ contract DistributionService is
|
|
302
349
|
|
303
350
|
// if the referral is valid, the the commission and discount are calculated based in the full premium
|
304
351
|
// the remaing amount goes to the distribution owner
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
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
|
+
}
|
315
386
|
|
316
387
|
return premium;
|
317
388
|
}
|
318
389
|
|
390
|
+
// TODO: zero should return false
|
319
391
|
function referralIsValid(NftId distributionNftId, ReferralId referralId) public view returns (bool isValid) {
|
320
|
-
|
392
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
321
393
|
IDistribution.ReferralInfo memory info = instance.getInstanceReader().getReferralInfo(referralId);
|
322
394
|
|
323
395
|
if (info.distributorNftId.eqz()) {
|
@@ -332,63 +404,32 @@ contract DistributionService is
|
|
332
404
|
internal
|
333
405
|
view
|
334
406
|
returns(
|
335
|
-
address distributionAddress,
|
336
407
|
NftId distributionNftId,
|
337
408
|
IInstance instance
|
338
409
|
)
|
339
410
|
{
|
340
|
-
|
341
|
-
(
|
342
|
-
|
343
|
-
distributionNftId,
|
344
|
-
objectType,
|
345
|
-
instance
|
346
|
-
) = _getAndVerifyCaller();
|
347
|
-
|
348
|
-
if(objectType != DISTRIBUTION()) {
|
349
|
-
revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
|
411
|
+
distributionNftId = getRegistry().getNftId(msg.sender);
|
412
|
+
if (distributionNftId.eqz()) {
|
413
|
+
revert ErrorDistributionServiceCallerNotRegistered(msg.sender);
|
350
414
|
}
|
351
|
-
}
|
352
415
|
|
353
|
-
function _getAndVerifyDistribution(NftId distributionNftId)
|
354
|
-
internal
|
355
|
-
view
|
356
|
-
returns(
|
357
|
-
address distributionAddress,
|
358
|
-
IInstance instance
|
359
|
-
)
|
360
|
-
{
|
361
416
|
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(distributionNftId);
|
362
|
-
|
363
|
-
|
364
|
-
revert ErrorIDistributionServiceParentNftIdNotInstance(distributionNftId, info.parentNftId);
|
417
|
+
if(info.objectType != DISTRIBUTION()) {
|
418
|
+
revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
|
365
419
|
}
|
366
|
-
|
420
|
+
|
421
|
+
address instanceAddress = getRegistry().getObjectInfo(info.parentNftId).objectAddress;
|
422
|
+
instance = IInstance(instanceAddress);
|
367
423
|
}
|
368
424
|
|
369
|
-
|
425
|
+
|
426
|
+
function _getInstanceForDistribution(NftId distributionNftId)
|
370
427
|
internal
|
371
428
|
view
|
372
|
-
returns(
|
373
|
-
address objectAddress,
|
374
|
-
NftId objectNftId,
|
375
|
-
ObjectType objectType,
|
376
|
-
IInstance instance
|
377
|
-
)
|
429
|
+
returns(IInstance instance)
|
378
430
|
{
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
revert ErrorIServiceCallerUnknown(objectAddress);
|
383
|
-
}
|
384
|
-
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
|
385
|
-
objectType = info.objectType;
|
386
|
-
|
387
|
-
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
388
|
-
if (parentInfo.objectType != INSTANCE()) {
|
389
|
-
revert ErrorIDistributionServiceParentNftIdNotInstance(objectNftId, info.parentNftId);
|
390
|
-
}
|
391
|
-
instance = IInstance(parentInfo.objectAddress);
|
431
|
+
NftId instanceNftId = getRegistry().getObjectInfo(distributionNftId).parentNftId;
|
432
|
+
address instanceAddress = getRegistry().getObjectInfo(instanceNftId).objectAddress;
|
433
|
+
return IInstance(instanceAddress);
|
392
434
|
}
|
393
|
-
|
394
435
|
}
|
@@ -19,6 +19,7 @@ import {Fee} from "../../types/Fee.sol";
|
|
19
19
|
interface IApplicationService is IService {
|
20
20
|
|
21
21
|
error IApplicationServicePolicyNotApplied(NftId applicationNftId);
|
22
|
+
error IApplicationServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
|
22
23
|
|
23
24
|
/// @dev creates a new application based on the specified attributes
|
24
25
|
/// may only be called by a product component
|
@@ -1,6 +1,7 @@
|
|
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
7
|
import {IService} from "../../shared/IService.sol";
|
@@ -8,48 +9,85 @@ import {IBundle} from "../module/IBundle.sol";
|
|
8
9
|
import {IInstance} from "../../instance/IInstance.sol";
|
9
10
|
import {Seconds} from "../../types/Seconds.sol";
|
10
11
|
import {StateId} from "../../types/StateId.sol";
|
12
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
11
13
|
|
12
14
|
interface IBundleService is IService {
|
13
|
-
error ErrorIBundleServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
Fee memory fee,
|
18
|
-
uint256 amount,
|
19
|
-
Seconds lifetime,
|
20
|
-
bytes calldata filter
|
21
|
-
) external returns(NftId bundleNftId);
|
16
|
+
event LogBundleServiceBundleActivated(NftId bundleNftId);
|
17
|
+
event LogBundleServiceBundleLocked(NftId bundleNftId);
|
22
18
|
|
23
|
-
|
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;
|
56
|
+
|
57
|
+
/// @dev set bundle fee to provided value
|
58
|
+
/// may only be called by registered and unlocked pool components
|
59
|
+
function setFee(
|
24
60
|
NftId bundleNftId,
|
25
61
|
Fee memory fee
|
26
62
|
) external;
|
27
63
|
|
28
|
-
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
29
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
|
30
70
|
function lockCollateral(
|
31
71
|
IInstance instanceNftId,
|
32
72
|
NftId policyNftId,
|
33
73
|
NftId bundleNftId,
|
34
74
|
uint256 collateralAmount,
|
35
|
-
uint256
|
36
|
-
)
|
37
|
-
external
|
38
|
-
returns (
|
39
|
-
IBundle.BundleInfo memory bundleInfo
|
40
|
-
);
|
41
|
-
|
42
|
-
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
43
|
-
|
44
|
-
function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
|
75
|
+
uint256 premium // premium amount after pool fee
|
76
|
+
) external;
|
45
77
|
|
46
|
-
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
47
78
|
|
48
|
-
|
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;
|
49
87
|
|
50
|
-
function
|
88
|
+
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
51
89
|
|
52
|
-
function
|
90
|
+
// function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
53
91
|
|
54
|
-
// function
|
92
|
+
// function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
55
93
|
}
|
@@ -12,6 +12,7 @@ import {Timestamp} from "../../types/Timestamp.sol";
|
|
12
12
|
|
13
13
|
|
14
14
|
interface IDistributionService is IService {
|
15
|
+
error ErrorDistributionServiceCallerNotRegistered(address caller);
|
15
16
|
error ErrorIDistributionServiceParentNftIdNotInstance(NftId nftId, NftId parentNftId);
|
16
17
|
error ErrorIDistributionServiceCallerNotDistributor(address caller);
|
17
18
|
error ErrorIDistributionServiceInvalidReferralId(ReferralId referralId);
|
@@ -24,6 +25,16 @@ interface IDistributionService is IService {
|
|
24
25
|
error ErrorIDistributionServiceCommissionTooHigh(uint256 commissionPercentage, uint256 maxCommissionPercentage);
|
25
26
|
error ErrorIDistributionServiceMinFeeTooHigh(uint256 minFee, uint256 limit);
|
26
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);
|
27
38
|
|
28
39
|
function setFees(
|
29
40
|
Fee memory minDistributionOwnerFee,
|
@@ -69,8 +80,10 @@ interface IDistributionService is IService {
|
|
69
80
|
|
70
81
|
/// @dev callback from product service when selling a policy for a specific referralId
|
71
82
|
function processSale(
|
83
|
+
NftId distributionNftId,
|
72
84
|
ReferralId referralId,
|
73
|
-
|
85
|
+
IPolicy.Premium memory premium,
|
86
|
+
uint256 transferredDistributionFeeAmount
|
74
87
|
) external;
|
75
88
|
|
76
89
|
function calculateFeeAmount(
|
@@ -24,6 +24,8 @@ interface IPolicyService is IService {
|
|
24
24
|
error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
25
25
|
error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
26
26
|
|
27
|
+
error ErrorIPolicyServicePremiumMismatch(NftId policyNftId, uint256 premiumAmount, uint256 recalculatedPremiumAmount);
|
28
|
+
|
27
29
|
/// @dev declines an application represented by {policyNftId}
|
28
30
|
/// an application can only be declined in applied state
|
29
31
|
/// only the related product may decline an application
|
@@ -1,20 +1,99 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
4
|
+
import {Amount} from "../../types/Amount.sol";
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {
|
7
|
-
import {IService} from "../../shared/IService.sol";
|
6
|
+
import {NftId} from "../../types/NftId.sol";
|
8
7
|
import {IBundle} from "../module/IBundle.sol";
|
9
8
|
import {IInstance} from "../../instance/IInstance.sol";
|
9
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
10
|
+
import {IService} from "../../shared/IService.sol";
|
11
|
+
import {RoleId} from "../../types/RoleId.sol";
|
12
|
+
import {Seconds} from "../../types/Seconds.sol";
|
13
|
+
import {StateId} from "../../types/StateId.sol";
|
10
14
|
|
11
15
|
interface IPoolService is IService {
|
12
16
|
|
17
|
+
event LogPoolServiceMaxCapitalAmountUpdated(NftId poolNftId, uint256 previousMaxCapitalAmount, uint256 currentMaxCapitalAmount);
|
18
|
+
event LogPoolServiceBundleOwnerRoleSet(NftId poolNftId, RoleId bundleOwnerRole);
|
19
|
+
|
20
|
+
event LogPoolServiceBundleCreated(NftId instanceNftId, NftId poolNftId, NftId bundleNftId);
|
21
|
+
event LogPoolServiceBundleClosed(NftId instanceNftId, NftId poolNftId, NftId bundleNftId);
|
22
|
+
|
23
|
+
error ErrorPoolServiceBundleOwnerRoleAlreadySet(NftId poolNftId);
|
24
|
+
error ErrorPoolServiceBundlePoolMismatch(NftId bundlePoolNftId, NftId productPoolNftId);
|
25
|
+
|
26
|
+
/// @dev registers a new pool with the registry service
|
13
27
|
function register(address poolAddress) external returns(NftId);
|
14
28
|
|
29
|
+
/// @dev defines the required role for bundle owners for the calling pool
|
30
|
+
/// default implementation returns PUBLIC ROLE
|
31
|
+
function setBundleOwnerRole(RoleId bundleOwnerRole) external;
|
32
|
+
|
33
|
+
/// @dev sets the max capital amount for the calling pool
|
34
|
+
function setMaxCapitalAmount(uint256 maxCapitalAmount) external;
|
35
|
+
|
36
|
+
/// @dev set pool sepecific fees
|
15
37
|
function setFees(
|
16
38
|
Fee memory poolFee,
|
17
39
|
Fee memory stakingFee,
|
18
40
|
Fee memory performanceFee
|
19
41
|
) external;
|
42
|
+
|
43
|
+
|
44
|
+
/// @dev locks required collateral to cover the specified application (and turn it into a policy)
|
45
|
+
/// - retention level == 1: the full collateral amount will be locked by the specified bundle
|
46
|
+
/// - retention level < 1: a part of the coverage is provided by the specified bundle, the rest by the pool component
|
47
|
+
/// in which case the pool component might hold a re-insurance policy
|
48
|
+
/// may only be called by the policy service for unlocked pool components
|
49
|
+
function lockCollateral(
|
50
|
+
IInstance instance,
|
51
|
+
NftId productNftId,
|
52
|
+
NftId applicationNftId,
|
53
|
+
IPolicy.PolicyInfo memory applicationInfo,
|
54
|
+
uint256 premiumAmount
|
55
|
+
) external;
|
56
|
+
|
57
|
+
|
58
|
+
/// @dev releases the remaining collateral linked to the specified policy
|
59
|
+
/// may only be called by the policy service for unlocked pool components
|
60
|
+
function releaseCollateral(
|
61
|
+
IInstance instance,
|
62
|
+
NftId policyNftId,
|
63
|
+
IPolicy.PolicyInfo memory policyInfo
|
64
|
+
) external;
|
65
|
+
|
66
|
+
|
67
|
+
/// @dev create a new bundle for the provided parameters
|
68
|
+
/// staking fees will be deducted by the pool service from the staking amount
|
69
|
+
/// may only be called by registered and unlocked pool components
|
70
|
+
function createBundle(
|
71
|
+
address owner, // initial bundle owner
|
72
|
+
Fee memory fee, // fees deducted from premium that go to bundle owner
|
73
|
+
Amount stakingAmount, // staking amount - staking fees result in initial bundle capital
|
74
|
+
Seconds lifetime, // initial duration for which new policies are covered
|
75
|
+
bytes calldata filter // optional use case specific criteria that define if a policy may be covered by this bundle
|
76
|
+
)
|
77
|
+
external
|
78
|
+
returns(NftId bundleNftId); // the nft id of the newly created bundle
|
79
|
+
|
80
|
+
|
81
|
+
/// @dev closes the specified bundle
|
82
|
+
/// only open bundles (active or locked) may be closed
|
83
|
+
/// to close a bundle it may not have any non-closed polices attached to it
|
84
|
+
/// bundle fees and remaining capital (after deduction of the performance fee) will be transferred to the bundle owner
|
85
|
+
/// may only be called by registered and unlocked pool components
|
86
|
+
function closeBundle(NftId bundleNftId) external;
|
87
|
+
|
88
|
+
|
89
|
+
/// @dev increase stakes for bundle
|
90
|
+
/// staking fees will be deducted by the pool service from the staking amount
|
91
|
+
/// may only be called by registered and unlocked pool components
|
92
|
+
// function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
93
|
+
|
94
|
+
|
95
|
+
/// @dev decrease stakes for bundle
|
96
|
+
/// performance fees will be deducted by the pool service from the staking amount
|
97
|
+
/// may only be called by registered and unlocked pool components
|
98
|
+
// function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
20
99
|
}
|