@etherisc/gif-next 0.0.2-b9e43cf-870 → 0.0.2-bb1081a-994
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → Component.sol/Component.json} +230 -14
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +141 -10
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +107 -87
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +543 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +623 -45
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +643 -5
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +227 -73
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +146 -15
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +181 -15
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +0 -5
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +113 -76
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +47 -60
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +42 -83
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +59 -58
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +37 -24
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +102 -31
- 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/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- 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/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +229 -93
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +31 -18
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +126 -47
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +31 -14
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +98 -38
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +0 -5
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +0 -5
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +0 -5
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +0 -5
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +153 -82
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +44 -31
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +126 -47
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +31 -14
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +126 -47
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +31 -14
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +83 -3
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +33 -28
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +96 -24
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +18 -18
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -56
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +28 -15
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +70 -53
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +23 -26
- 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/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +0 -5
- 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 +19 -6
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +13 -5
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- 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/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +29 -21
- 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/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- 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/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- 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/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +247 -0
- package/contracts/components/Distribution.sol +27 -48
- package/contracts/components/IComponent.sol +50 -0
- package/contracts/components/IDistributionComponent.sol +5 -2
- package/contracts/components/IPoolComponent.sol +40 -29
- package/contracts/components/IProductComponent.sol +7 -3
- package/contracts/components/Pool.sol +123 -138
- package/contracts/components/Product.sol +48 -86
- package/contracts/instance/BundleManager.sol +7 -11
- package/contracts/instance/IInstance.sol +20 -10
- package/contracts/instance/IInstanceService.sol +1 -1
- package/contracts/instance/Instance.sol +28 -31
- package/contracts/instance/InstanceAccessManager.sol +6 -11
- package/contracts/instance/InstanceReader.sol +3 -25
- package/contracts/instance/InstanceService.sol +31 -14
- package/contracts/instance/ObjectManager.sol +7 -24
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/module/ISetup.sol +2 -2
- package/contracts/instance/service/BundleService.sol +11 -6
- package/contracts/instance/service/DistributionService.sol +22 -36
- package/contracts/instance/service/IBundleService.sol +11 -1
- package/contracts/instance/service/PolicyService.sol +56 -76
- package/contracts/instance/service/PoolService.sol +19 -55
- package/contracts/instance/service/ProductService.sol +49 -30
- package/contracts/registry/IRegistry.sol +13 -6
- package/contracts/registry/IRegistryService.sol +16 -9
- package/contracts/registry/Registry.sol +100 -44
- package/contracts/registry/RegistryAccessManager.sol +31 -25
- package/contracts/registry/RegistryService.sol +27 -85
- package/contracts/registry/ReleaseManager.sol +72 -82
- package/contracts/registry/TokenRegistry.sol +5 -3
- package/contracts/shared/IRegisterable.sol +1 -3
- package/contracts/shared/NftOwnable.sol +5 -0
- package/contracts/shared/Registerable.sol +10 -14
- package/contracts/shared/Service.sol +4 -2
- package/contracts/types/RoleId.sol +2 -2
- package/package.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
- package/contracts/components/BaseComponent.sol +0 -159
- package/contracts/components/IBaseComponent.sol +0 -34
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
- package/contracts/instance/IInstanceBase.sol +0 -26
- package/contracts/instance/InstanceBase.sol +0 -41
- package/contracts/instance/base/ComponentServiceBase.sol +0 -76
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -315
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -4,7 +4,6 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
5
|
import {IProductComponent} from "../../components/IProductComponent.sol";
|
6
6
|
import {Product} from "../../components/Product.sol";
|
7
|
-
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
8
7
|
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
9
8
|
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
10
9
|
import {IInstance} from "../IInstance.sol";
|
@@ -35,14 +34,14 @@ import {Version, VersionLib} from "../../types/Version.sol";
|
|
35
34
|
|
36
35
|
import {IService} from "../../shared/IService.sol";
|
37
36
|
import {Service} from "../../shared/Service.sol";
|
38
|
-
import {
|
37
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
39
38
|
import {IPolicyService} from "./IPolicyService.sol";
|
40
39
|
import {InstanceReader} from "../InstanceReader.sol";
|
41
40
|
import {IPoolService} from "./IPoolService.sol";
|
42
41
|
import {IBundleService} from "./IBundleService.sol";
|
43
42
|
|
44
43
|
|
45
|
-
contract PolicyService is
|
44
|
+
contract PolicyService is ComponentService, IPolicyService {
|
46
45
|
using NftIdLib for NftId;
|
47
46
|
using TimestampLib for Timestamp;
|
48
47
|
|
@@ -237,18 +236,19 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
237
236
|
internal
|
238
237
|
view
|
239
238
|
returns (
|
239
|
+
NftId poolNftId,
|
240
240
|
NftId bundleNftId,
|
241
241
|
IBundle.BundleInfo memory bundleInfo,
|
242
242
|
uint256 collateralAmount
|
243
243
|
)
|
244
244
|
{
|
245
245
|
// check match between policy and bundle (via pool)
|
246
|
+
poolNftId = productSetupInfo.poolNftId;
|
246
247
|
bundleNftId = policyInfo.bundleNftId;
|
247
248
|
bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
248
|
-
require(bundleInfo.poolNftId ==
|
249
|
+
require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
|
249
250
|
|
250
251
|
// calculate required collateral
|
251
|
-
NftId poolNftId = productSetupInfo.poolNftId;
|
252
252
|
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
253
253
|
|
254
254
|
// obtain remaining return values
|
@@ -270,24 +270,6 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
270
270
|
return bundleInfo;
|
271
271
|
}
|
272
272
|
|
273
|
-
function _underwriteByPool(
|
274
|
-
NftId poolNftId,
|
275
|
-
NftId policyNftId,
|
276
|
-
IPolicy.PolicyInfo memory policyInfo,
|
277
|
-
bytes memory bundleFilter,
|
278
|
-
uint256 collateralAmount
|
279
|
-
)
|
280
|
-
internal
|
281
|
-
{
|
282
|
-
address poolAddress = getRegistry().getObjectInfo(poolNftId).objectAddress;
|
283
|
-
IPoolComponent pool = IPoolComponent(poolAddress);
|
284
|
-
pool.underwrite(
|
285
|
-
policyNftId,
|
286
|
-
policyInfo.applicationData,
|
287
|
-
bundleFilter,
|
288
|
-
collateralAmount);
|
289
|
-
}
|
290
|
-
|
291
273
|
|
292
274
|
function revoke(
|
293
275
|
NftId policyNftId
|
@@ -300,7 +282,7 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
300
282
|
|
301
283
|
|
302
284
|
function underwrite(
|
303
|
-
NftId policyNftId
|
285
|
+
NftId applicationNftId, // = policyNftId
|
304
286
|
bool requirePremiumPayment,
|
305
287
|
Timestamp activateAt
|
306
288
|
)
|
@@ -308,47 +290,37 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
308
290
|
override
|
309
291
|
{
|
310
292
|
// check caller is registered product
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
293
|
+
IInstance instance;
|
294
|
+
InstanceReader instanceReader;
|
295
|
+
NftId productNftId;
|
296
|
+
{
|
297
|
+
IRegistry.ObjectInfo memory productInfo;
|
298
|
+
(productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
299
|
+
instanceReader = instance.getInstanceReader();
|
300
|
+
productNftId = productInfo.nftId;
|
301
|
+
}
|
316
302
|
|
317
|
-
// check
|
318
|
-
|
319
|
-
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
303
|
+
// check policy matches with calling product
|
304
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(applicationNftId);
|
320
305
|
require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
321
|
-
require(instanceReader.getPolicyState(policyNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
322
306
|
|
323
|
-
|
324
|
-
|
325
|
-
uint256 collateralAmount;
|
326
|
-
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
327
|
-
{
|
328
|
-
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
|
329
|
-
IBundle.BundleInfo memory bundleInfo;
|
330
|
-
|
331
|
-
(
|
332
|
-
bundleNftId,
|
333
|
-
bundleInfo,
|
334
|
-
collateralAmount
|
335
|
-
) = _getAndVerifyUnderwritingSetup(
|
336
|
-
instance,
|
337
|
-
instanceReader,
|
338
|
-
policyInfo,
|
339
|
-
productSetupInfo
|
340
|
-
);
|
341
|
-
}
|
307
|
+
// check policy is in state applied
|
308
|
+
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
342
309
|
|
343
|
-
|
344
|
-
|
310
|
+
(
|
311
|
+
NftId poolNftId,
|
312
|
+
NftId bundleNftId,
|
313
|
+
IBundle.BundleInfo memory bundleInfo,
|
314
|
+
uint256 collateralAmount
|
315
|
+
) = _getAndVerifyUnderwritingSetup(
|
345
316
|
instance,
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
StateId newPolicyState = UNDERWRITTEN();
|
317
|
+
instanceReader,
|
318
|
+
policyInfo,
|
319
|
+
instanceReader.getProductSetupInfo(productNftId)
|
320
|
+
);
|
351
321
|
|
322
|
+
StateId newPolicyState = UNDERWRITTEN();
|
323
|
+
|
352
324
|
// optional activation of policy
|
353
325
|
if(activateAt > zeroTimestamp()) {
|
354
326
|
newPolicyState = ACTIVE();
|
@@ -356,38 +328,46 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
|
|
356
328
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
357
329
|
}
|
358
330
|
|
331
|
+
// lock bundle collateral
|
332
|
+
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
333
|
+
|
359
334
|
// optional collection of premium
|
360
335
|
if(requirePremiumPayment) {
|
361
336
|
netPremiumAmount = _processPremiumByTreasury(
|
362
337
|
instance,
|
363
|
-
|
364
|
-
|
338
|
+
productNftId,
|
339
|
+
applicationNftId,
|
365
340
|
policyInfo.premiumAmount);
|
366
341
|
|
367
342
|
policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
|
368
343
|
}
|
369
344
|
|
370
|
-
|
371
|
-
|
345
|
+
// lock collateral and update bundle book keeping
|
346
|
+
bundleInfo = _bundleService.lockCollateral(
|
347
|
+
instance,
|
348
|
+
applicationNftId,
|
349
|
+
bundleNftId,
|
350
|
+
collateralAmount,
|
351
|
+
netPremiumAmount);
|
372
352
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
);
|
385
|
-
}
|
353
|
+
instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
|
354
|
+
|
355
|
+
// also verify/confirm application by pool if necessary
|
356
|
+
if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
|
357
|
+
IPoolComponent pool = IPoolComponent(
|
358
|
+
getRegistry().getObjectInfo(poolNftId).objectAddress);
|
359
|
+
|
360
|
+
pool.verifyApplication(
|
361
|
+
applicationNftId,
|
362
|
+
policyInfo.applicationData,
|
363
|
+
bundleInfo.filter,
|
364
|
+
collateralAmount);
|
386
365
|
}
|
387
366
|
|
388
367
|
// TODO: add logging
|
389
368
|
}
|
390
369
|
|
370
|
+
|
391
371
|
function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
|
392
372
|
UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
|
393
373
|
UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
|
@@ -24,17 +24,18 @@ import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
|
24
24
|
import {IService} from "../../shared/IService.sol";
|
25
25
|
import {Service} from "../../shared/Service.sol";
|
26
26
|
import {BundleManager} from "../BundleManager.sol";
|
27
|
-
import {
|
27
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
28
28
|
import {IPoolService} from "./IPoolService.sol";
|
29
29
|
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
30
30
|
import {InstanceService} from "../InstanceService.sol";
|
31
31
|
import {InstanceReader} from "../InstanceReader.sol";
|
32
|
-
import {
|
32
|
+
import {IComponent} from "../../components/IComponent.sol";
|
33
|
+
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
33
34
|
|
34
35
|
string constant POOL_SERVICE_NAME = "PoolService";
|
35
36
|
|
36
37
|
contract PoolService is
|
37
|
-
|
38
|
+
ComponentService,
|
38
39
|
IPoolService
|
39
40
|
{
|
40
41
|
using NftIdLib for NftId;
|
@@ -67,60 +68,23 @@ contract PoolService is
|
|
67
68
|
external
|
68
69
|
returns(NftId poolNftId)
|
69
70
|
{
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
address(instance));
|
83
|
-
|
84
|
-
if(!hasRole) {
|
85
|
-
revert ExpectedRoleMissing(POOL_OWNER_ROLE(), poolOwner);
|
86
|
-
}
|
87
|
-
|
88
|
-
poolNftId = info.nftId;
|
89
|
-
string memory poolName;
|
90
|
-
ISetup.PoolSetupInfo memory initialSetup;
|
91
|
-
(poolName, initialSetup) = _decodeAndVerifyPoolData(data);
|
92
|
-
instance.createPoolSetup(poolNftId, initialSetup);
|
93
|
-
|
94
|
-
getInstanceService().createTarget(instanceNftId, poolAddress, poolName);
|
95
|
-
|
71
|
+
(
|
72
|
+
IComponent component,
|
73
|
+
address owner,
|
74
|
+
IInstance instance,
|
75
|
+
NftId instanceNftId
|
76
|
+
) = _checkComponentForRegistration(
|
77
|
+
poolAddress,
|
78
|
+
POOL(),
|
79
|
+
POOL_OWNER_ROLE());
|
80
|
+
|
81
|
+
IPoolComponent pool = IPoolComponent(poolAddress);
|
82
|
+
IRegistry.ObjectInfo memory poolInfo = getRegistryService().registerPool(pool, owner);
|
96
83
|
pool.linkToRegisteredNftId();
|
97
|
-
|
98
|
-
|
99
|
-
function _decodeAndVerifyPoolData(bytes memory data)
|
100
|
-
internal
|
101
|
-
returns(string memory name, ISetup.PoolSetupInfo memory setup)
|
102
|
-
{
|
103
|
-
(name, setup) = abi.decode(
|
104
|
-
data,
|
105
|
-
(string, ISetup.PoolSetupInfo)
|
106
|
-
);
|
107
|
-
|
108
|
-
// TODO add checks
|
109
|
-
/*IRegistry _registry = getRegistry();
|
110
|
-
|
111
|
-
if(wallet == address(0)) {
|
112
|
-
revert WalletIsZero();
|
113
|
-
}
|
114
|
-
|
115
|
-
ObjectType tokenType = _registry.getObjectInfo(address(token)).objectType;
|
116
|
-
|
117
|
-
if(tokenType != TOKEN()) {
|
118
|
-
revert InvalidToken();
|
119
|
-
}
|
84
|
+
poolNftId = poolInfo.nftId;
|
120
85
|
|
121
|
-
|
122
|
-
|
123
|
-
}*/
|
86
|
+
instance.createPoolSetup(poolNftId, pool.getSetupInfo());
|
87
|
+
getInstanceService().createTarget(instanceNftId, poolAddress, pool.getName());
|
124
88
|
}
|
125
89
|
|
126
90
|
function setFees(
|
@@ -4,7 +4,7 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
5
|
import {IProductComponent} from "../../components/IProductComponent.sol";
|
6
6
|
import {Product} from "../../components/Product.sol";
|
7
|
-
import {
|
7
|
+
import {IComponent} from "../../components/IComponent.sol";
|
8
8
|
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
9
9
|
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
10
10
|
import {IInstance} from "../IInstance.sol";
|
@@ -35,13 +35,13 @@ import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
|
|
35
35
|
|
36
36
|
import {IService} from "../../shared/IService.sol";
|
37
37
|
import {Service} from "../../shared/Service.sol";
|
38
|
-
import {
|
38
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
39
39
|
import {IProductService} from "./IProductService.sol";
|
40
40
|
import {InstanceReader} from "../InstanceReader.sol";
|
41
41
|
import {IPoolService} from "./PoolService.sol";
|
42
42
|
|
43
43
|
// TODO or name this ProtectionService to have Product be something more generic (loan, savings account, ...)
|
44
|
-
contract ProductService is
|
44
|
+
contract ProductService is ComponentService, IProductService {
|
45
45
|
using NftIdLib for NftId;
|
46
46
|
|
47
47
|
IPoolService internal _poolService;
|
@@ -68,44 +68,63 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
68
68
|
}
|
69
69
|
|
70
70
|
|
71
|
-
function getDomain() public pure override(IService, Service) returns(ObjectType) {
|
72
|
-
return PRODUCT();
|
73
|
-
}
|
74
|
-
|
75
71
|
function register(address productAddress)
|
76
72
|
external
|
77
73
|
returns(NftId productNftId)
|
78
74
|
{
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
75
|
+
(
|
76
|
+
IComponent component,
|
77
|
+
address owner,
|
78
|
+
IInstance instance,
|
79
|
+
NftId instanceNftId
|
80
|
+
) = _checkComponentForRegistration(
|
81
|
+
productAddress,
|
82
|
+
PRODUCT(),
|
83
|
+
PRODUCT_OWNER_ROLE());
|
84
|
+
|
85
|
+
IProductComponent product = IProductComponent(productAddress);
|
86
|
+
IRegistry.ObjectInfo memory productInfo = getRegistryService().registerProduct(product, owner);
|
87
|
+
productNftId = productInfo.nftId;
|
88
|
+
_createProductSetup(
|
89
|
+
instance,
|
90
|
+
product,
|
91
|
+
productNftId);
|
92
|
+
}
|
92
93
|
|
93
|
-
if(!hasRole) {
|
94
|
-
revert ExpectedRoleMissing(PRODUCT_OWNER_ROLE(), productOwner);
|
95
|
-
}
|
96
94
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
function _createProductSetup(
|
96
|
+
IInstance instance,
|
97
|
+
IProductComponent product,
|
98
|
+
NftId productNftId
|
99
|
+
)
|
100
|
+
internal
|
101
|
+
returns (string memory name)
|
102
|
+
{
|
103
|
+
// wire distribution and pool components to product component
|
104
|
+
ISetup.ProductSetupInfo memory setup = product.getSetupInfo();
|
105
|
+
IComponent distribution = IComponent(_registry.getObjectInfo(setup.distributionNftId).objectAddress);
|
106
|
+
IComponent pool = IComponent(_registry.getObjectInfo(setup.poolNftId).objectAddress);
|
107
|
+
|
108
|
+
distribution.setProductNftId(productNftId);
|
109
|
+
pool.setProductNftId(productNftId);
|
110
|
+
product.setProductNftId(productNftId);
|
111
|
+
product.linkToRegisteredNftId();
|
101
112
|
|
102
|
-
instance
|
113
|
+
// create product setup in instance
|
114
|
+
instance.createProductSetup(productNftId, product.getSetupInfo());
|
103
115
|
|
104
|
-
|
116
|
+
// create target for instane access manager
|
117
|
+
getInstanceService().createTarget(
|
118
|
+
_registry.getNftId(address(instance)),
|
119
|
+
address(product),
|
120
|
+
product.getName());
|
121
|
+
}
|
105
122
|
|
106
|
-
|
123
|
+
function getDomain() public pure override(IService, Service) returns(ObjectType) {
|
124
|
+
return PRODUCT();
|
107
125
|
}
|
108
126
|
|
127
|
+
|
109
128
|
function _decodeAndVerifyProductData(bytes memory data)
|
110
129
|
internal
|
111
130
|
returns(string memory name, ISetup.ProductSetupInfo memory setup)
|
@@ -14,13 +14,16 @@ interface IRegistry is IERC165 {
|
|
14
14
|
event LogRegistration(NftId nftId, NftId parentNftId, ObjectType objectType, bool isInterceptor, address objectAddress, address initialOwner);
|
15
15
|
event LogServiceRegistration(VersionPart majorVersion, ObjectType domain);
|
16
16
|
|
17
|
+
// registerService()
|
18
|
+
error CallerNotReleaseManager();
|
19
|
+
error ServiceAlreadyRegistered(address service);
|
20
|
+
|
17
21
|
// register()
|
18
22
|
error CallerNotRegistryService();
|
19
23
|
error ServiceRegistration();
|
20
24
|
|
21
|
-
//
|
22
|
-
error
|
23
|
-
error ServiceAlreadyRegistered(address service);
|
25
|
+
// registerWithCustomTypes()
|
26
|
+
error CoreTypeRegistration();
|
24
27
|
|
25
28
|
// _register()
|
26
29
|
error ZeroParentAddress();
|
@@ -52,11 +55,13 @@ interface IRegistry is IERC165 {
|
|
52
55
|
|
53
56
|
function register(ObjectInfo memory info) external returns (NftId nftId);
|
54
57
|
|
55
|
-
function
|
58
|
+
function registerWithCustomType(ObjectInfo memory info) external returns (NftId nftId);
|
56
59
|
|
57
|
-
function
|
60
|
+
function getInitialVersion() external view returns (VersionPart);
|
58
61
|
|
59
|
-
function
|
62
|
+
function getNextVersion() external view returns (VersionPart);
|
63
|
+
|
64
|
+
function getLatestVersion() external view returns (VersionPart);
|
60
65
|
|
61
66
|
function getReleaseInfo(VersionPart version) external view returns (ReleaseInfo memory);
|
62
67
|
|
@@ -80,6 +85,8 @@ interface IRegistry is IERC165 {
|
|
80
85
|
|
81
86
|
function isRegisteredService(address contractAddress) external view returns (bool);
|
82
87
|
|
88
|
+
function isValidRelease(VersionPart version) external view returns (bool);
|
89
|
+
|
83
90
|
function getServiceAddress(
|
84
91
|
ObjectType serviceDomain,
|
85
92
|
VersionPart releaseVersion
|
@@ -10,7 +10,7 @@ import {IService} from "../shared/IService.sol";
|
|
10
10
|
import {IRegistry} from "./IRegistry.sol";
|
11
11
|
|
12
12
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
13
|
-
import {
|
13
|
+
import {IComponent} from "../components/IComponent.sol";
|
14
14
|
|
15
15
|
interface IRegistryService is
|
16
16
|
IService,
|
@@ -38,18 +38,25 @@ interface IRegistryService is
|
|
38
38
|
bytes4 selector;
|
39
39
|
}
|
40
40
|
|
41
|
+
function getFunctionConfigs()
|
42
|
+
external
|
43
|
+
pure
|
44
|
+
returns(
|
45
|
+
FunctionConfig[] memory config
|
46
|
+
);
|
47
|
+
|
41
48
|
// TODO used by service -> add owner arg
|
42
|
-
|
43
|
-
external returns(IRegistry.ObjectInfo memory info
|
49
|
+
function registerInstance(IRegisterable instance, address owner)
|
50
|
+
external returns(IRegistry.ObjectInfo memory info);
|
44
51
|
|
45
|
-
function registerProduct(
|
46
|
-
external returns(IRegistry.ObjectInfo memory info
|
52
|
+
function registerProduct(IComponent product, address owner)
|
53
|
+
external returns(IRegistry.ObjectInfo memory info);
|
47
54
|
|
48
|
-
function registerPool(
|
49
|
-
external returns(IRegistry.ObjectInfo memory info
|
55
|
+
function registerPool(IComponent pool, address owner)
|
56
|
+
external returns(IRegistry.ObjectInfo memory info);
|
50
57
|
|
51
|
-
function registerDistribution(
|
52
|
-
external returns(IRegistry.ObjectInfo memory info
|
58
|
+
function registerDistribution(IComponent distribution, address owner)
|
59
|
+
external returns(IRegistry.ObjectInfo memory info);
|
53
60
|
|
54
61
|
function registerPolicy(IRegistry.ObjectInfo memory info) external returns(NftId nftId);
|
55
62
|
|