@etherisc/gif-next 0.0.2-ce87da3-250 → 0.0.2-ceb30b2-601
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 +78 -102
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +139 -153
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +155 -76
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +181 -125
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +342 -178
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +162 -151
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +286 -245
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +83 -175
- 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 +707 -463
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +167 -76
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +630 -625
- 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 +258 -236
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +291 -238
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +79 -48
- 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 +114 -35
- 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 +322 -99
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +59 -44
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +459 -242
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +90 -39
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +646 -84
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +119 -32
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +673 -129
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +96 -69
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +205 -59
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +253 -185
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +373 -51
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +480 -37
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +170 -102
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +776 -46
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +85 -27
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +255 -222
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +37 -78
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +929 -58
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +84 -37
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +145 -58
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +28 -37
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +5 -37
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +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 +23 -50
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +21 -34
- 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 +10 -23
- 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/INftOwnable.sol/INftOwnable.json +0 -13
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +45 -9
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -13
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +0 -13
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +85 -27
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +6 -19
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +47 -24
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +14 -27
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +7 -20
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +92 -29
- 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 +7 -20
- 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 +107 -40
- 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 +209 -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/ClaimId.sol/ClaimIdLib.json +83 -4
- 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/PayoutId.sol/PayoutIdLib.json +116 -7
- 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 +38 -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 +18 -21
- package/contracts/components/IComponent.sol +40 -18
- package/contracts/components/IDistributionComponent.sol +1 -22
- package/contracts/components/IPoolComponent.sol +73 -47
- package/contracts/components/IProductComponent.sol +3 -2
- package/contracts/components/Pool.sol +178 -130
- package/contracts/components/Product.sol +157 -71
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +10 -9
- package/contracts/instance/Cloneable.sol +7 -2
- package/contracts/instance/IInstance.sol +39 -27
- package/contracts/instance/IInstanceService.sol +16 -12
- package/contracts/instance/Instance.sol +125 -98
- package/contracts/instance/InstanceAccessManager.sol +388 -158
- package/contracts/instance/InstanceReader.sol +36 -12
- package/contracts/instance/InstanceService.sol +220 -212
- package/contracts/instance/ObjectManager.sol +6 -8
- package/contracts/instance/base/ComponentService.sol +28 -32
- package/contracts/instance/base/KeyValueStore.sol +13 -36
- package/contracts/instance/base/Lifecycle.sol +23 -6
- 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 -1
- package/contracts/instance/module/IPolicy.sol +38 -7
- package/contracts/instance/module/ISetup.sol +7 -22
- package/contracts/instance/service/ApplicationService.sol +138 -50
- package/contracts/instance/service/BundleService.sol +228 -83
- package/contracts/instance/service/ClaimService.sol +240 -30
- package/contracts/instance/service/DistributionService.sol +179 -114
- package/contracts/instance/service/IApplicationService.sol +9 -13
- package/contracts/instance/service/IBundleService.sol +74 -26
- package/contracts/instance/service/IClaimService.sol +52 -23
- package/contracts/instance/service/IDistributionService.sol +21 -3
- package/contracts/instance/service/IPolicyService.sol +20 -29
- package/contracts/instance/service/IPoolService.sol +127 -3
- package/contracts/instance/service/PolicyService.sol +133 -251
- package/contracts/instance/service/PoolService.sol +258 -18
- package/contracts/instance/service/ProductService.sol +31 -54
- package/contracts/registry/ChainNft.sol +8 -0
- package/contracts/registry/IRegistry.sol +2 -0
- package/contracts/registry/IRegistryService.sol +2 -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/IPolicyHolder.sol +20 -8
- package/contracts/shared/IRegistryLinked.sol +0 -1
- package/contracts/shared/IService.sol +6 -6
- package/contracts/shared/NftOwnable.sol +0 -2
- package/contracts/shared/PolicyHolder.sol +14 -8
- package/contracts/shared/Registerable.sol +12 -11
- package/contracts/shared/RegistryLinked.sol +0 -5
- 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 +70 -0
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/ClaimId.sol +25 -2
- package/contracts/types/Fee.sol +13 -5
- package/contracts/types/NftId.sol +8 -0
- package/contracts/types/ObjectType.sol +6 -5
- package/contracts/types/PayoutId.sol +33 -5
- 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 +7 -2
- package/contracts/types/Timestamp.sol +18 -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
12
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
12
|
-
import {DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.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";
|
@@ -41,6 +43,7 @@ contract DistributionService is
|
|
41
43
|
using TimestampLib for Timestamp;
|
42
44
|
using UFixedLib for UFixed;
|
43
45
|
using FeeLib for Fee;
|
46
|
+
using ReferralLib for ReferralId;
|
44
47
|
|
45
48
|
address internal _registryAddress;
|
46
49
|
|
@@ -57,11 +60,11 @@ contract DistributionService is
|
|
57
60
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
58
61
|
// TODO while DistributionService is not deployed in DistributionServiceManager constructor
|
59
62
|
// owner is DistributionServiceManager deployer
|
60
|
-
initializeService(registryAddress, owner);
|
63
|
+
initializeService(registryAddress, address(0), owner);
|
61
64
|
registerInterface(type(IDistributionService).interfaceId);
|
62
65
|
}
|
63
66
|
|
64
|
-
function getDomain() public pure override
|
67
|
+
function getDomain() public pure override returns(ObjectType) {
|
65
68
|
return DISTRIBUTION();
|
66
69
|
}
|
67
70
|
|
@@ -85,21 +88,42 @@ contract DistributionService is
|
|
85
88
|
distributionNftId = distributionInfo.nftId;
|
86
89
|
|
87
90
|
instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
|
88
|
-
|
89
|
-
|
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);
|
90
109
|
}
|
91
110
|
|
92
111
|
function setFees(
|
112
|
+
Fee memory minDistributionOwnerFee,
|
93
113
|
Fee memory distributionFee
|
94
114
|
)
|
95
115
|
external
|
96
116
|
override
|
97
117
|
{
|
98
|
-
(
|
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());
|
99
123
|
InstanceReader instanceReader = instance.getInstanceReader();
|
100
|
-
NftId distributionNftId = info.nftId;
|
101
124
|
|
102
125
|
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
126
|
+
distSetupInfo.minDistributionOwnerFee = minDistributionOwnerFee;
|
103
127
|
distSetupInfo.distributionFee = distributionFee;
|
104
128
|
|
105
129
|
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
@@ -119,27 +143,30 @@ contract DistributionService is
|
|
119
143
|
external
|
120
144
|
returns (DistributorType distributorType)
|
121
145
|
{
|
122
|
-
(
|
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
|
+
|
123
157
|
distributorType = DistributorTypeLib.toDistributorType(distributionNftId, name);
|
124
|
-
|
158
|
+
IDistribution.DistributorTypeInfo memory info = IDistribution.DistributorTypeInfo(
|
159
|
+
name,
|
160
|
+
minDiscountPercentage,
|
161
|
+
maxDiscountPercentage,
|
162
|
+
commissionPercentage,
|
163
|
+
maxReferralCount,
|
164
|
+
maxReferralLifetime,
|
165
|
+
allowSelfReferrals,
|
166
|
+
allowRenewals,
|
167
|
+
data);
|
125
168
|
|
126
|
-
|
127
|
-
// FIXME: maxDiscountPercentage <= distributionFee
|
128
|
-
|
129
|
-
if(!instance.exists(key32)) {
|
130
|
-
IDistribution.DistributorTypeInfo memory info = IDistribution.DistributorTypeInfo(
|
131
|
-
name,
|
132
|
-
minDiscountPercentage,
|
133
|
-
maxDiscountPercentage,
|
134
|
-
commissionPercentage,
|
135
|
-
maxReferralCount,
|
136
|
-
maxReferralLifetime,
|
137
|
-
allowSelfReferrals,
|
138
|
-
allowRenewals,
|
139
|
-
data);
|
140
|
-
|
141
|
-
instance.createDistributorType(key32, info);
|
142
|
-
}
|
169
|
+
instance.createDistributorType(distributorType, info);
|
143
170
|
}
|
144
171
|
|
145
172
|
function createDistributor(
|
@@ -148,7 +175,7 @@ contract DistributionService is
|
|
148
175
|
bytes memory data
|
149
176
|
) external returns (NftId distributorNftId)
|
150
177
|
{
|
151
|
-
(
|
178
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
152
179
|
|
153
180
|
distributorNftId = getRegistryService().registerDistributor(
|
154
181
|
IRegistry.ObjectInfo(
|
@@ -164,7 +191,9 @@ contract DistributionService is
|
|
164
191
|
IDistribution.DistributorInfo memory info = IDistribution.DistributorInfo(
|
165
192
|
distributorType,
|
166
193
|
true, // active
|
167
|
-
data
|
194
|
+
data,
|
195
|
+
0,
|
196
|
+
0);
|
168
197
|
|
169
198
|
instance.createDistributor(distributorNftId, info);
|
170
199
|
}
|
@@ -175,14 +204,12 @@ contract DistributionService is
|
|
175
204
|
bytes memory data
|
176
205
|
) external virtual
|
177
206
|
{
|
178
|
-
(
|
179
|
-
|
180
|
-
IDistribution.DistributorInfo memory
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
instance.updateDistributor(distributorNftId, info, KEEP_STATE());
|
207
|
+
(, IInstance instance) = _getAndVerifyCallingDistribution();
|
208
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
209
|
+
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
210
|
+
distributorInfo.distributorType = distributorType;
|
211
|
+
distributorInfo.data = data;
|
212
|
+
instance.updateDistributor(distributorNftId, distributorInfo, KEEP_STATE());
|
186
213
|
}
|
187
214
|
|
188
215
|
|
@@ -198,7 +225,7 @@ contract DistributionService is
|
|
198
225
|
virtual
|
199
226
|
returns (ReferralId referralId)
|
200
227
|
{
|
201
|
-
(
|
228
|
+
(NftId distributionNftId, IInstance instance) = _getAndVerifyCallingDistribution();
|
202
229
|
|
203
230
|
if (bytes(code).length == 0) {
|
204
231
|
revert ErrorIDistributionServiceInvalidReferral(code);
|
@@ -208,8 +235,8 @@ contract DistributionService is
|
|
208
235
|
}
|
209
236
|
|
210
237
|
InstanceReader instanceReader = instance.getInstanceReader();
|
211
|
-
IDistribution.DistributorInfo memory
|
212
|
-
DistributorType distributorType =
|
238
|
+
IDistribution.DistributorInfo memory distributorInfo = instanceReader.getDistributorInfo(distributorNftId);
|
239
|
+
DistributorType distributorType = distributorInfo.distributorType;
|
213
240
|
IDistribution.DistributorTypeInfo memory distributorTypeData = instanceReader.getDistributorTypeInfo(distributorType);
|
214
241
|
|
215
242
|
if (distributorTypeData.maxReferralCount < maxReferrals) {
|
@@ -236,60 +263,129 @@ contract DistributionService is
|
|
236
263
|
data
|
237
264
|
);
|
238
265
|
|
239
|
-
instance.createReferral(referralId
|
266
|
+
instance.createReferral(referralId, info);
|
240
267
|
return referralId;
|
241
268
|
}
|
242
269
|
|
243
270
|
function processSale(
|
271
|
+
NftId distributionNftId,
|
244
272
|
ReferralId referralId,
|
245
|
-
|
273
|
+
IPolicy.Premium memory premium,
|
274
|
+
uint256 transferredDistributionFeeAmount
|
246
275
|
)
|
247
276
|
external
|
248
277
|
virtual
|
249
278
|
{
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
279
|
+
bool isReferral = ! referralId.eqz();
|
280
|
+
bool referralValid = referralIsValid(distributionNftId, referralId);
|
281
|
+
|
282
|
+
if (isReferral && ! referralValid) {
|
283
|
+
revert ErrorIDistributionServiceReferralInvalid(distributionNftId, referralId);
|
284
|
+
}
|
285
|
+
|
286
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
287
|
+
InstanceReader reader = instance.getInstanceReader();
|
288
|
+
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
289
|
+
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
290
|
+
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
291
|
+
|
292
|
+
uint256 distributionOwnerFee = premium.distributionOwnerFeeFixAmount + premium.distributionOwnerFeeVarAmount;
|
293
|
+
uint256 commissionAmount = premium.commissionAmount;
|
294
|
+
|
295
|
+
if (transferredDistributionFeeAmount != distributionOwnerFee + commissionAmount) {
|
296
|
+
revert ErrorIDistributionServiceInvalidFeeTransferred(transferredDistributionFeeAmount, distributionOwnerFee + commissionAmount);
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
if (distributionOwnerFee > 0) {
|
301
|
+
setupInfo.sumDistributionOwnerFees += distributionOwnerFee;
|
302
|
+
instance.updateDistributionSetup(distributionNftId, setupInfo, KEEP_STATE());
|
303
|
+
}
|
304
|
+
|
305
|
+
if (isReferral) {
|
306
|
+
referralInfo.usedReferrals += 1;
|
307
|
+
instance.updateReferral(referralId, referralInfo, KEEP_STATE());
|
308
|
+
|
309
|
+
if (commissionAmount > 0) {
|
310
|
+
distributorInfo.sumCommisions += commissionAmount;
|
311
|
+
distributorInfo.numPoliciesSold += 1;
|
312
|
+
instance.updateDistributor(referralInfo.distributorNftId, distributorInfo, KEEP_STATE());
|
313
|
+
}
|
314
|
+
}
|
258
315
|
}
|
259
316
|
|
260
317
|
function calculateFeeAmount(
|
261
318
|
NftId distributionNftId,
|
262
319
|
ReferralId referralId,
|
263
|
-
|
320
|
+
IPolicy.Premium memory premium
|
264
321
|
)
|
265
322
|
external
|
266
323
|
virtual
|
267
324
|
view
|
268
|
-
returns (
|
325
|
+
returns (IPolicy.Premium memory finalPremium)
|
269
326
|
{
|
270
|
-
|
327
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
271
328
|
InstanceReader reader = instance.getInstanceReader();
|
272
|
-
|
273
|
-
// calculate
|
329
|
+
|
330
|
+
// first calculate all fixed and variable fees for the distribution - this will defined the fullPremium
|
274
331
|
ISetup.DistributionSetupInfo memory setupInfo = reader.getDistributionSetupInfo(distributionNftId);
|
275
|
-
Fee memory
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
}
|
288
|
-
|
332
|
+
Fee memory distributionFee = setupInfo.distributionFee;
|
333
|
+
Fee memory minDistributionOwnerFee = setupInfo.minDistributionOwnerFee;
|
334
|
+
uint256 distributionFeeVarAmount = (UFixedLib.toUFixed(premium.netPremiumAmount) * distributionFee.fractionalFee).toInt();
|
335
|
+
premium.distributionFeeVarAmount = distributionFeeVarAmount;
|
336
|
+
premium.fullPremiumAmount += distributionFeeVarAmount;
|
337
|
+
|
338
|
+
// if the referral is not valid, then the distribution owner gets everything
|
339
|
+
if (! referralIsValid(distributionNftId, referralId)) {
|
340
|
+
premium.distributionOwnerFeeFixAmount = premium.distributionFeeFixAmount;
|
341
|
+
premium.distributionOwnerFeeVarAmount = premium.distributionFeeVarAmount;
|
342
|
+
premium.premiumAmount = premium.fullPremiumAmount;
|
343
|
+
return premium;
|
344
|
+
}
|
345
|
+
|
346
|
+
// if the referral is valid, the the commission and discount are calculated based in the full premium
|
347
|
+
// the remaing amount goes to the distribution owner
|
348
|
+
{
|
349
|
+
IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
|
350
|
+
IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
|
351
|
+
IDistribution.DistributorTypeInfo memory distributorTypeInfo = reader.getDistributorTypeInfo(distributorInfo.distributorType);
|
352
|
+
|
353
|
+
uint256 commissionAmount = UFixedLib.toUFixed(premium.netPremiumAmount).mul(distributorTypeInfo.commissionPercentage).toInt();
|
354
|
+
premium.commissionAmount = commissionAmount;
|
355
|
+
premium.discountAmount = UFixedLib.toUFixed(premium.fullPremiumAmount).mul(referralInfo.discountPercentage).toInt();
|
356
|
+
premium.distributionOwnerFeeFixAmount = minDistributionOwnerFee.fixedFee;
|
357
|
+
premium.distributionOwnerFeeVarAmount = distributionFeeVarAmount - commissionAmount - premium.discountAmount;
|
358
|
+
premium.premiumAmount = premium.fullPremiumAmount - premium.discountAmount;
|
359
|
+
}
|
360
|
+
|
361
|
+
// sanity check to validate the fee calculation
|
362
|
+
if (premium.distributionOwnerFeeFixAmount < minDistributionOwnerFee.fixedFee) {
|
363
|
+
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
364
|
+
premium.distributionFeeFixAmount,
|
365
|
+
premium.distributionFeeVarAmount,
|
366
|
+
premium.distributionOwnerFeeFixAmount,
|
367
|
+
premium.distributionOwnerFeeVarAmount,
|
368
|
+
premium.commissionAmount,
|
369
|
+
premium.discountAmount
|
370
|
+
);
|
371
|
+
}
|
372
|
+
if ((premium.distributionFeeVarAmount) != (premium.discountAmount + premium.distributionOwnerFeeVarAmount + premium.commissionAmount)) {
|
373
|
+
revert ErrorIDistributionServiceFeeCalculationMismatch(
|
374
|
+
premium.distributionFeeFixAmount,
|
375
|
+
premium.distributionFeeVarAmount,
|
376
|
+
premium.distributionOwnerFeeFixAmount,
|
377
|
+
premium.distributionOwnerFeeVarAmount,
|
378
|
+
premium.commissionAmount,
|
379
|
+
premium.discountAmount
|
380
|
+
);
|
381
|
+
}
|
382
|
+
|
383
|
+
return premium;
|
289
384
|
}
|
290
385
|
|
386
|
+
// TODO: zero should return false
|
291
387
|
function referralIsValid(NftId distributionNftId, ReferralId referralId) public view returns (bool isValid) {
|
292
|
-
|
388
|
+
IInstance instance = _getInstanceForDistribution(distributionNftId);
|
293
389
|
IDistribution.ReferralInfo memory info = instance.getInstanceReader().getReferralInfo(referralId);
|
294
390
|
|
295
391
|
if (info.distributorNftId.eqz()) {
|
@@ -304,63 +400,32 @@ contract DistributionService is
|
|
304
400
|
internal
|
305
401
|
view
|
306
402
|
returns(
|
307
|
-
address distributionAddress,
|
308
403
|
NftId distributionNftId,
|
309
404
|
IInstance instance
|
310
405
|
)
|
311
406
|
{
|
312
|
-
|
313
|
-
(
|
314
|
-
|
315
|
-
distributionNftId,
|
316
|
-
objectType,
|
317
|
-
instance
|
318
|
-
) = _getAndVerifyCaller();
|
319
|
-
|
320
|
-
if(objectType != DISTRIBUTION()) {
|
321
|
-
revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
|
407
|
+
distributionNftId = getRegistry().getNftId(msg.sender);
|
408
|
+
if (distributionNftId.eqz()) {
|
409
|
+
revert ErrorDistributionServiceCallerNotRegistered(msg.sender);
|
322
410
|
}
|
323
|
-
}
|
324
411
|
|
325
|
-
function _getAndVerifyDistribution(NftId distributionNftId)
|
326
|
-
internal
|
327
|
-
view
|
328
|
-
returns(
|
329
|
-
address distributionAddress,
|
330
|
-
IInstance instance
|
331
|
-
)
|
332
|
-
{
|
333
412
|
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(distributionNftId);
|
334
|
-
|
335
|
-
|
336
|
-
revert ErrorIDistributionServiceParentNftIdNotInstance(distributionNftId, info.parentNftId);
|
413
|
+
if(info.objectType != DISTRIBUTION()) {
|
414
|
+
revert ErrorIDistributionServiceCallerNotDistributor(msg.sender);
|
337
415
|
}
|
338
|
-
|
416
|
+
|
417
|
+
address instanceAddress = getRegistry().getObjectInfo(info.parentNftId).objectAddress;
|
418
|
+
instance = IInstance(instanceAddress);
|
339
419
|
}
|
340
420
|
|
341
|
-
|
421
|
+
|
422
|
+
function _getInstanceForDistribution(NftId distributionNftId)
|
342
423
|
internal
|
343
424
|
view
|
344
|
-
returns(
|
345
|
-
address objectAddress,
|
346
|
-
NftId objectNftId,
|
347
|
-
ObjectType objectType,
|
348
|
-
IInstance instance
|
349
|
-
)
|
425
|
+
returns(IInstance instance)
|
350
426
|
{
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
revert ErrorIServiceCallerUnknown(objectAddress);
|
355
|
-
}
|
356
|
-
IRegistry.ObjectInfo memory info = getRegistry().getObjectInfo(objectNftId);
|
357
|
-
objectType = info.objectType;
|
358
|
-
|
359
|
-
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(info.parentNftId);
|
360
|
-
if (parentInfo.objectType != INSTANCE()) {
|
361
|
-
revert ErrorIDistributionServiceParentNftIdNotInstance(objectNftId, info.parentNftId);
|
362
|
-
}
|
363
|
-
instance = IInstance(parentInfo.objectAddress);
|
427
|
+
NftId instanceNftId = getRegistry().getObjectInfo(distributionNftId).parentNftId;
|
428
|
+
address instanceAddress = getRegistry().getObjectInfo(instanceNftId).objectAddress;
|
429
|
+
return IInstance(instanceAddress);
|
364
430
|
}
|
365
|
-
|
366
431
|
}
|
@@ -1,22 +1,21 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
4
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
5
5
|
import {IService} from "../../shared/IService.sol";
|
6
6
|
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {ObjectType} from "../../types/ObjectType.sol";
|
8
9
|
import {ReferralId} from "../../types/Referral.sol";
|
9
10
|
import {RiskId} from "../../types/RiskId.sol";
|
10
|
-
import {
|
11
|
-
import {Timestamp} from "../../types/Timestamp.sol";
|
12
|
-
import {UFixed} from "../../types/UFixed.sol";
|
13
|
-
import {Fee} from "../../types/Fee.sol";
|
11
|
+
import {Seconds} from "../../types/Seconds.sol";
|
14
12
|
|
15
13
|
/// @dev gif service responsible for creating applications
|
16
14
|
/// only product components may call transaction functions
|
17
15
|
interface IApplicationService is IService {
|
18
16
|
|
19
|
-
error
|
17
|
+
error ErrorApplicationServiceNotProduct(NftId callerNftId, ObjectType callerType);
|
18
|
+
error ErrorApplicationServiceBundlePoolMismatch(NftId bundleNftId, NftId bundlePoolNftId, NftId poolNftId);
|
20
19
|
|
21
20
|
/// @dev creates a new application based on the specified attributes
|
22
21
|
/// may only be called by a product component
|
@@ -24,7 +23,7 @@ interface IApplicationService is IService {
|
|
24
23
|
address applicationOwner,
|
25
24
|
RiskId riskId,
|
26
25
|
uint256 sumInsuredAmount,
|
27
|
-
|
26
|
+
Seconds lifetime,
|
28
27
|
NftId bundleNftId,
|
29
28
|
ReferralId referralId,
|
30
29
|
bytes memory applicationData
|
@@ -63,9 +62,10 @@ interface IApplicationService is IService {
|
|
63
62
|
/// @dev calculates the premium amount for the specified attributes
|
64
63
|
/// also returns the various fee components involved with creating a policy
|
65
64
|
function calculatePremium(
|
65
|
+
NftId productNftId,
|
66
66
|
RiskId riskId,
|
67
67
|
uint256 sumInsuredAmount,
|
68
|
-
|
68
|
+
Seconds lifetime,
|
69
69
|
bytes memory applicationData,
|
70
70
|
NftId bundleNftId,
|
71
71
|
ReferralId referralId
|
@@ -73,10 +73,6 @@ interface IApplicationService is IService {
|
|
73
73
|
external
|
74
74
|
view
|
75
75
|
returns (
|
76
|
-
|
77
|
-
uint256 distributionFeeAmount,
|
78
|
-
uint256 productFeeAmount,
|
79
|
-
uint256 poolFeeAmount,
|
80
|
-
uint256 bundleFeeAmount
|
76
|
+
IPolicy.Premium memory premium
|
81
77
|
);
|
82
78
|
}
|
@@ -1,54 +1,102 @@
|
|
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
|
+
error ErrorBundleServiceBundleUnknown(NftId bundleNftId);
|
25
|
+
error ErrorBundleServiceBundlePoolMismatch(NftId expectedPoolNftId, NftId bundlePoolNftId);
|
26
|
+
|
27
|
+
/// @dev create a new bundle for the specified attributes
|
28
|
+
/// may only be called by pool service
|
29
|
+
function create(
|
30
|
+
IInstance instance, // instance relevant for bundle
|
31
|
+
NftId poolNftId, // the pool the bundle will be linked to
|
32
|
+
address owner, // initial bundle owner
|
33
|
+
Fee memory fee, // fees deducted from premium that go to bundle owner
|
34
|
+
Amount stakingAmount, // staking amount - staking fees result in initial bundle capital
|
35
|
+
Seconds lifetime, // initial duration for which new policies are covered
|
36
|
+
bytes calldata filter // optional use case specific criteria that define if a policy may be covered by this bundle
|
37
|
+
)
|
38
|
+
external
|
39
|
+
returns(NftId bundleNftId); // the nft id of the newly created bundle
|
21
40
|
|
22
|
-
|
41
|
+
/// @dev locks the specified bundle, locked bundles are not available to collateralize new policies
|
42
|
+
/// only active bundles may be locked
|
43
|
+
/// may only be called by registered and unlocked pool components
|
44
|
+
function lock(NftId bundleNftId) external;
|
45
|
+
|
46
|
+
/// @dev activates the specified bundle
|
47
|
+
/// only locked bundles may be unlocked
|
48
|
+
/// may only be called by registered and unlocked pool components
|
49
|
+
function unlock(NftId bundleNftId) external;
|
50
|
+
|
51
|
+
/// @dev closes the specified bundle
|
52
|
+
/// only open bundles (active or locked) may be closed
|
53
|
+
/// to close a bundle it may not have any non-closed polices attached to it
|
54
|
+
/// may only be called by registered and unlocked pool components
|
55
|
+
function close(
|
56
|
+
IInstance instance,
|
57
|
+
NftId bundleNftId
|
58
|
+
) external;
|
59
|
+
|
60
|
+
/// @dev set bundle fee to provided value
|
61
|
+
/// may only be called by registered and unlocked pool components
|
62
|
+
function setFee(
|
23
63
|
NftId bundleNftId,
|
24
64
|
Fee memory fee
|
25
65
|
) external;
|
26
66
|
|
27
|
-
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
28
67
|
|
68
|
+
/// @dev locks the specified collateral in the bundle
|
69
|
+
/// the locked collateral is added to the bundle locked capital
|
70
|
+
/// the bundles' fees are updated with the fees for this premium
|
71
|
+
/// the premium (minus bundle fee) is added to the bundle capital
|
72
|
+
/// may only be called by pool service
|
29
73
|
function lockCollateral(
|
30
74
|
IInstance instanceNftId,
|
31
75
|
NftId policyNftId,
|
32
76
|
NftId bundleNftId,
|
33
77
|
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;
|
78
|
+
uint256 premium // premium amount after pool fee
|
79
|
+
) external;
|
44
80
|
|
45
|
-
|
81
|
+
/// @dev updates the bundle's fees of with the provided fee amount
|
82
|
+
function updateBundleFees(
|
83
|
+
IInstance instance,
|
84
|
+
NftId bundleNftId,
|
85
|
+
Amount feeAmount
|
86
|
+
) external;
|
46
87
|
|
47
|
-
|
88
|
+
/// @dev releases the specified collateral in the bundle
|
89
|
+
/// may only be called by pool service
|
90
|
+
function releaseCollateral(
|
91
|
+
IInstance instance,
|
92
|
+
NftId policyNftId,
|
93
|
+
NftId bundleNftId,
|
94
|
+
uint256 collateralAmount
|
95
|
+
) external;
|
48
96
|
|
49
|
-
function
|
97
|
+
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
50
98
|
|
51
|
-
function
|
99
|
+
// function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
52
100
|
|
53
|
-
// function
|
101
|
+
// function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
54
102
|
}
|