@etherisc/gif-next 0.0.2-78bf628-134 → 0.0.2-7b53731-256
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 +38 -7
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +405 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +340 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +131 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +109 -18
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +194 -3
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +160 -21
- 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/Dummy.sol/LifeCycleModule.json +2 -2
- 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/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +545 -393
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +672 -456
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +32 -0
- 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/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +32 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +14 -14
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +4 -4
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +55 -54
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +56 -55
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +12 -7
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +12 -7
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensation.json → distribution/IDistribution.sol/IDistribution.json} +2 -2
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensationModule.json → distribution/IDistribution.sol/IDistributionModule.json} +2 -2
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +53 -40
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +53 -40
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -5
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -5
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +104 -1
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +126 -5
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +209 -231
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +209 -231
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +28 -20
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +420 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +325 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +64 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +160 -7
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +84 -12
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +216 -31
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
- package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.json +495 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Proxy.sol/Proxy.dbg.json +4 -0
- package/artifacts/contracts/shared/Proxy.sol/Proxy.json +178 -0
- package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +4 -0
- package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.json +129 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.dbg.json +4 -0
- package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.json +187 -0
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +405 -0
- 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/TestPool.sol/TestPool.dbg.json +1 -1
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +194 -3
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +209 -27
- 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 +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
- 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/TestVersionable.sol/TestVersionable.json +2 -2
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +50 -11
- 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 +2 -2
- 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/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
- 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/UFixedMathLib.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/BaseComponent.sol +7 -1
- package/contracts/components/Distribution.sol +132 -0
- package/contracts/components/IDistributionComponent.sol +47 -0
- package/contracts/components/IPoolComponent.sol +14 -0
- package/contracts/components/IProductComponent.sol +24 -5
- package/contracts/components/Pool.sol +64 -3
- package/contracts/components/Product.sol +123 -13
- package/contracts/instance/IInstance.sol +7 -4
- package/contracts/instance/Instance.sol +11 -4
- package/contracts/instance/base/IInstanceBase.sol +3 -0
- package/contracts/instance/base/InstanceBase.sol +7 -0
- package/contracts/instance/base/Lifecycle.sol +10 -2
- package/contracts/instance/base/ModuleBase.sol +22 -17
- package/contracts/instance/module/access/Access.sol +3 -3
- package/contracts/instance/module/bundle/BundleModule.sol +10 -12
- package/contracts/instance/module/bundle/IBundle.sol +6 -11
- package/contracts/instance/module/component/ComponentModule.sol +15 -20
- package/contracts/instance/module/component/IComponent.sol +3 -2
- package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
- package/contracts/instance/module/distribution/IDistribution.sol +10 -0
- package/contracts/instance/module/policy/IPolicy.sol +10 -8
- package/contracts/instance/module/policy/PolicyModule.sol +33 -19
- package/contracts/instance/module/pool/IPoolModule.sol +0 -1
- package/contracts/instance/module/pool/PoolModule.sol +12 -9
- package/contracts/instance/module/risk/IRisk.sol +18 -2
- package/contracts/instance/module/risk/RiskModule.sol +56 -2
- package/contracts/instance/module/treasury/ITreasury.sol +29 -50
- package/contracts/instance/module/treasury/TreasuryModule.sol +71 -85
- package/contracts/instance/service/ComponentOwnerService.sol +19 -24
- package/contracts/instance/service/DistributionService.sol +59 -0
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +7 -0
- package/contracts/instance/service/IProductService.sol +56 -7
- package/contracts/instance/service/PoolService.sol +30 -4
- package/contracts/instance/service/ProductService.sol +229 -74
- package/contracts/registry/Registry.sol +3 -3
- package/contracts/registry/RegistryUpgradeable.sol +416 -0
- package/contracts/shared/Proxy.sol +83 -0
- package/contracts/shared/Versionable.sol +1 -1
- package/contracts/shared/VersionableUpgradeable.sol +108 -0
- package/contracts/test/TestDistribution.sol +21 -0
- package/contracts/test/TestPool.sol +5 -2
- package/contracts/test/TestProduct.sol +35 -7
- package/contracts/types/Fee.sol +8 -3
- package/contracts/types/ObjectType.sol +17 -5
- package/contracts/types/ReferralId.sol +48 -0
- package/contracts/types/RiskId.sol +43 -0
- package/contracts/types/RoleId.sol +2 -2
- package/package.json +1 -1
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +0 -10
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +0 -4
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +0 -4
- package/contracts/instance/module/compensation/CompensationModule.sol +0 -8
- package/contracts/instance/module/compensation/ICompensation.sol +0 -10
@@ -1,27 +1,76 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
+
import {IRisk} from "../module/risk/IRisk.sol";
|
5
|
+
import {IService} from "../base/IService.sol";
|
6
|
+
|
4
7
|
import {NftId} from "../../types/NftId.sol";
|
8
|
+
import {ReferralId} from "../../types/ReferralId.sol";
|
9
|
+
import {RiskId} from "../../types/RiskId.sol";
|
10
|
+
import {StateId} from "../../types/StateId.sol";
|
5
11
|
import {Timestamp} from "../../types/Timestamp.sol";
|
6
12
|
import {UFixed} from "../../types/UFixed.sol";
|
7
13
|
import {Fee} from "../../types/Fee.sol";
|
8
|
-
import {IService} from "../base/IService.sol";
|
9
14
|
|
10
15
|
interface IProductService is IService {
|
11
16
|
function setFees(
|
12
|
-
Fee memory
|
17
|
+
Fee memory productFee,
|
13
18
|
Fee memory processingFee
|
14
19
|
) external;
|
15
20
|
|
21
|
+
function createRisk(
|
22
|
+
RiskId riskId,
|
23
|
+
bytes memory data
|
24
|
+
) external;
|
25
|
+
|
26
|
+
|
27
|
+
function setRiskInfo(
|
28
|
+
RiskId riskId,
|
29
|
+
IRisk.RiskInfo memory data
|
30
|
+
) external;
|
31
|
+
|
32
|
+
|
33
|
+
function updateRiskState(
|
34
|
+
RiskId riskId,
|
35
|
+
StateId state
|
36
|
+
) external;
|
37
|
+
|
38
|
+
|
39
|
+
function calculatePremium(
|
40
|
+
RiskId riskId,
|
41
|
+
uint256 sumInsuredAmount,
|
42
|
+
uint256 lifetime,
|
43
|
+
bytes memory applicationData,
|
44
|
+
NftId bundleNftId,
|
45
|
+
ReferralId referralId
|
46
|
+
)
|
47
|
+
external
|
48
|
+
view
|
49
|
+
returns (
|
50
|
+
uint256 premiumAmount,
|
51
|
+
uint256 productFeeAmount,
|
52
|
+
uint256 poolFeeAmount,
|
53
|
+
uint256 bundleFeeAmount,
|
54
|
+
uint256 distributionFeeAmount
|
55
|
+
);
|
56
|
+
|
57
|
+
|
16
58
|
function createApplication(
|
17
59
|
address applicationOwner,
|
60
|
+
RiskId riskId,
|
18
61
|
uint256 sumInsuredAmount,
|
19
|
-
uint256 premiumAmount,
|
20
62
|
uint256 lifetime,
|
21
|
-
|
63
|
+
bytes memory applicationData,
|
64
|
+
NftId bundleNftId,
|
65
|
+
ReferralId referralId
|
22
66
|
) external returns (NftId nftId);
|
23
67
|
|
24
|
-
|
68
|
+
/**
|
69
|
+
* @dev revokes the application represented by {policyNftId}.
|
70
|
+
* an application can only be revoked in applied state.
|
71
|
+
* only the application holder may revoke an application.
|
72
|
+
*/
|
73
|
+
function revoke(NftId policyNftId) external;
|
25
74
|
|
26
75
|
/**
|
27
76
|
* @dev underwrites the policy represented by {policyNftId}.
|
@@ -38,9 +87,9 @@ interface IProductService is IService {
|
|
38
87
|
// function decline(uint256 nftId) external;
|
39
88
|
// function expire(uint256 nftId) external;
|
40
89
|
|
41
|
-
function collectPremium(NftId
|
90
|
+
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
42
91
|
|
43
|
-
function activate(NftId
|
92
|
+
function activate(NftId policyNftId, Timestamp activateAt) external;
|
44
93
|
|
45
94
|
|
46
95
|
function close(NftId nftId) external;
|
@@ -3,6 +3,7 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
5
|
import {IInstance} from "../../instance/IInstance.sol";
|
6
|
+
import {IBundle} from "../../instance/module/bundle/IBundle.sol";
|
6
7
|
import {ITreasury, ITreasuryModule, TokenHandler} from "../../instance/module/treasury/ITreasury.sol";
|
7
8
|
|
8
9
|
import {IVersionable} from "../../shared/IVersionable.sol";
|
@@ -44,18 +45,26 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
44
45
|
}
|
45
46
|
|
46
47
|
function setFees(
|
48
|
+
Fee memory poolFee,
|
47
49
|
Fee memory stakingFee,
|
48
50
|
Fee memory performanceFee
|
49
51
|
)
|
50
52
|
external
|
51
53
|
override
|
52
54
|
{
|
53
|
-
(IRegistry.ObjectInfo memory
|
54
|
-
|
55
|
+
(IRegistry.ObjectInfo memory poolInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
56
|
+
|
57
|
+
NftId productNftId = instance.getProductNftId(poolInfo.nftId);
|
58
|
+
ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productNftId);
|
59
|
+
treasuryInfo.poolFee = poolFee;
|
60
|
+
treasuryInfo.stakingFee = stakingFee;
|
61
|
+
treasuryInfo.performanceFee = performanceFee;
|
62
|
+
instance.setTreasuryInfo(productNftId, treasuryInfo);
|
55
63
|
}
|
56
64
|
|
57
65
|
function createBundle(
|
58
66
|
address owner,
|
67
|
+
Fee memory fee,
|
59
68
|
uint256 stakingAmount,
|
60
69
|
uint256 lifetime,
|
61
70
|
bytes calldata filter
|
@@ -78,6 +87,7 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
78
87
|
instance.createBundleInfo(
|
79
88
|
bundleNftId,
|
80
89
|
poolNftId,
|
90
|
+
fee,
|
81
91
|
stakingAmount,
|
82
92
|
lifetime,
|
83
93
|
filter);
|
@@ -98,6 +108,21 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
98
108
|
// TODO add logging
|
99
109
|
}
|
100
110
|
|
111
|
+
function setBundleFee(
|
112
|
+
NftId bundleNftId,
|
113
|
+
Fee memory fee
|
114
|
+
)
|
115
|
+
external
|
116
|
+
override
|
117
|
+
{
|
118
|
+
(IRegistry.ObjectInfo memory poolInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
119
|
+
IBundle.BundleInfo memory bundleInfo = instance.getBundleInfo(bundleNftId);
|
120
|
+
require(bundleInfo.poolNftId.gtz(), "ERROR:PLS-010:BUNDLE_UNKNOWN");
|
121
|
+
require(poolInfo.nftId == bundleInfo.poolNftId, "ERROR:PLS-011:BUNDLE_POOL_MISMATCH");
|
122
|
+
bundleInfo.fee = fee;
|
123
|
+
instance.setBundleInfo(bundleNftId, bundleInfo);
|
124
|
+
}
|
125
|
+
|
101
126
|
|
102
127
|
function _processStakingByTreasury(
|
103
128
|
IInstance instance,
|
@@ -109,9 +134,10 @@ contract PoolService is ComponentServiceBase, IPoolService {
|
|
109
134
|
{
|
110
135
|
// process token transfer(s)
|
111
136
|
if(stakingAmount > 0) {
|
112
|
-
|
137
|
+
NftId productNftId = instance.getProductNftId(poolNftId);
|
138
|
+
TokenHandler tokenHandler = instance.getTokenHandler(productNftId);
|
113
139
|
address bundleOwner = _registry.getOwner(bundleNftId);
|
114
|
-
address poolWallet = instance.
|
140
|
+
address poolWallet = instance.getComponentWallet(poolNftId);
|
115
141
|
|
116
142
|
tokenHandler.transfer(
|
117
143
|
bundleOwner,
|
@@ -2,10 +2,13 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IProductComponent} from "../../components/IProductComponent.sol";
|
5
6
|
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
7
|
+
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
6
8
|
import {IInstance} from "../../instance/IInstance.sol";
|
7
9
|
import {IPolicy, IPolicyModule} from "../module/policy/IPolicy.sol";
|
8
10
|
import {IPool} from "../module/pool/IPoolModule.sol";
|
11
|
+
import {IRisk} from "../module/risk/IRisk.sol";
|
9
12
|
import {IBundle} from "../module/bundle/IBundle.sol";
|
10
13
|
import {IProductService} from "./IProductService.sol";
|
11
14
|
import {ITreasury, ITreasuryModule, TokenHandler} from "../../instance/module/treasury/ITreasury.sol";
|
@@ -15,11 +18,14 @@ import {Versionable} from "../../shared/Versionable.sol";
|
|
15
18
|
|
16
19
|
import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
|
17
20
|
import {UFixed, UFixedMathLib} from "../../types/UFixed.sol";
|
21
|
+
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
18
22
|
import {ObjectType, INSTANCE, PRODUCT, POLICY} from "../../types/ObjectType.sol";
|
19
23
|
import {APPLIED, UNDERWRITTEN, ACTIVE} from "../../types/StateId.sol";
|
20
24
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
21
|
-
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
22
25
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
26
|
+
import {ReferralId} from "../../types/ReferralId.sol";
|
27
|
+
import {RiskId} from "../../types/RiskId.sol";
|
28
|
+
import {StateId} from "../../types/StateId.sol";
|
23
29
|
import {Version, VersionLib} from "../../types/Version.sol";
|
24
30
|
|
25
31
|
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
@@ -55,37 +61,168 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
55
61
|
}
|
56
62
|
|
57
63
|
function setFees(
|
58
|
-
Fee memory
|
64
|
+
Fee memory productFee,
|
59
65
|
Fee memory processingFee
|
60
66
|
)
|
61
67
|
external
|
62
68
|
override
|
63
69
|
{
|
64
70
|
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
65
|
-
|
71
|
+
NftId productNftId = productInfo.nftId;
|
72
|
+
ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productNftId);
|
73
|
+
treasuryInfo.productFee = productFee;
|
74
|
+
treasuryInfo.processingFee = processingFee;
|
75
|
+
instance.setTreasuryInfo(productNftId, treasuryInfo);
|
76
|
+
}
|
77
|
+
|
78
|
+
function createRisk(
|
79
|
+
RiskId riskId,
|
80
|
+
bytes memory data
|
81
|
+
) external override {
|
82
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
83
|
+
NftId productNftId = productInfo.nftId;
|
84
|
+
instance.createRisk(
|
85
|
+
riskId,
|
86
|
+
productNftId,
|
87
|
+
data
|
88
|
+
);
|
89
|
+
}
|
90
|
+
|
91
|
+
function setRiskInfo(
|
92
|
+
RiskId riskId,
|
93
|
+
IRisk.RiskInfo memory info
|
94
|
+
) external {
|
95
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
96
|
+
instance.setRiskInfo(
|
97
|
+
riskId,
|
98
|
+
info
|
99
|
+
);
|
100
|
+
}
|
101
|
+
|
102
|
+
function updateRiskState(
|
103
|
+
RiskId riskId,
|
104
|
+
StateId state
|
105
|
+
) external {
|
106
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
107
|
+
instance.updateRiskState(
|
108
|
+
riskId,
|
109
|
+
state
|
110
|
+
);
|
111
|
+
}
|
112
|
+
|
113
|
+
function _getAndVerifyInstanceAndProduct() internal view returns (IProductComponent product) {
|
114
|
+
IRegistry.ObjectInfo memory productInfo;
|
115
|
+
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
116
|
+
product = IProductComponent(productInfo.objectAddress);
|
117
|
+
}
|
118
|
+
|
119
|
+
function calculatePremium(
|
120
|
+
RiskId riskId,
|
121
|
+
uint256 sumInsuredAmount,
|
122
|
+
uint256 lifetime,
|
123
|
+
bytes memory applicationData,
|
124
|
+
NftId bundleNftId,
|
125
|
+
ReferralId referralId
|
126
|
+
)
|
127
|
+
public
|
128
|
+
view
|
129
|
+
override
|
130
|
+
returns (
|
131
|
+
uint256 premiumAmount,
|
132
|
+
uint256 productFeeAmount,
|
133
|
+
uint256 poolFeeAmount,
|
134
|
+
uint256 bundleFeeAmount,
|
135
|
+
uint256 distributionFeeAmount
|
136
|
+
)
|
137
|
+
{
|
138
|
+
IProductComponent product = _getAndVerifyInstanceAndProduct();
|
139
|
+
uint256 netPremiumAmount = product.calculateNetPremium(
|
140
|
+
sumInsuredAmount,
|
141
|
+
riskId,
|
142
|
+
lifetime,
|
143
|
+
applicationData
|
144
|
+
);
|
145
|
+
|
146
|
+
(
|
147
|
+
productFeeAmount,
|
148
|
+
poolFeeAmount,
|
149
|
+
bundleFeeAmount,
|
150
|
+
distributionFeeAmount
|
151
|
+
) = _calculateFeeAmounts(
|
152
|
+
netPremiumAmount,
|
153
|
+
product,
|
154
|
+
bundleNftId,
|
155
|
+
referralId
|
156
|
+
);
|
157
|
+
|
158
|
+
premiumAmount = netPremiumAmount + productFeeAmount;
|
159
|
+
premiumAmount += poolFeeAmount + bundleFeeAmount;
|
160
|
+
premiumAmount += distributionFeeAmount;
|
161
|
+
}
|
162
|
+
|
163
|
+
function _calculateFeeAmounts(
|
164
|
+
uint256 netPremiumAmount,
|
165
|
+
IProductComponent product,
|
166
|
+
NftId bundleNftId,
|
167
|
+
ReferralId referralId
|
168
|
+
)
|
169
|
+
internal
|
170
|
+
view
|
171
|
+
returns (
|
172
|
+
uint256 productFeeAmount,
|
173
|
+
uint256 poolFeeAmount,
|
174
|
+
uint256 bundleFeeAmount,
|
175
|
+
uint256 distributionFeeAmount
|
176
|
+
)
|
177
|
+
{
|
178
|
+
IInstance instance = product.getInstance();
|
179
|
+
ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(product.getNftId());
|
180
|
+
IBundle.BundleInfo memory bundleInfo = instance.getBundleInfo(bundleNftId);
|
181
|
+
require(bundleInfo.poolNftId == treasuryInfo.poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
|
182
|
+
|
183
|
+
(productFeeAmount,) = FeeLib.calculateFee(treasuryInfo.productFee, netPremiumAmount);
|
184
|
+
(poolFeeAmount,) = FeeLib.calculateFee(treasuryInfo.poolFee, netPremiumAmount);
|
185
|
+
(bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
|
186
|
+
|
187
|
+
IRegistry.ObjectInfo memory distributionInfo = _registry.getObjectInfo(treasuryInfo.distributionNftId);
|
188
|
+
IDistributionComponent distribution = IDistributionComponent(distributionInfo.objectAddress);
|
189
|
+
distributionFeeAmount = distribution.calculateFeeAmount(referralId, netPremiumAmount);
|
66
190
|
}
|
67
191
|
|
192
|
+
|
68
193
|
function createApplication(
|
69
194
|
address applicationOwner,
|
195
|
+
RiskId riskId,
|
70
196
|
uint256 sumInsuredAmount,
|
71
|
-
uint256 premiumAmount,
|
72
197
|
uint256 lifetime,
|
73
|
-
|
198
|
+
bytes memory applicationData,
|
199
|
+
NftId bundleNftId,
|
200
|
+
ReferralId referralId
|
74
201
|
) external override returns (NftId policyNftId) {
|
75
202
|
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
76
|
-
NftId productNftId = productInfo.nftId;
|
77
203
|
// TODO add validations (see create bundle in pool service)
|
78
204
|
|
79
205
|
policyNftId = this.getRegistry().registerObjectForInstance(
|
80
|
-
|
206
|
+
productInfo.nftId,
|
81
207
|
POLICY(),
|
82
208
|
applicationOwner,
|
83
209
|
""
|
84
210
|
);
|
85
211
|
|
86
|
-
|
87
|
-
|
212
|
+
(uint256 premiumAmount,,,,) = calculatePremium(
|
213
|
+
riskId,
|
214
|
+
sumInsuredAmount,
|
215
|
+
lifetime,
|
216
|
+
applicationData,
|
217
|
+
bundleNftId,
|
218
|
+
referralId
|
219
|
+
);
|
220
|
+
|
221
|
+
instance.createPolicyInfo(
|
88
222
|
policyNftId,
|
223
|
+
productInfo.nftId,
|
224
|
+
referralId,
|
225
|
+
riskId,
|
89
226
|
sumInsuredAmount,
|
90
227
|
premiumAmount,
|
91
228
|
lifetime,
|
@@ -102,30 +239,29 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
102
239
|
internal
|
103
240
|
view
|
104
241
|
returns (
|
105
|
-
ITreasury.
|
242
|
+
ITreasury.TreasuryInfo memory treasuryInfo,
|
243
|
+
NftId bundleNftId,
|
106
244
|
IBundle.BundleInfo memory bundleInfo,
|
107
|
-
uint256 collateralAmount
|
108
|
-
bool poolIsVerifying,
|
109
|
-
bytes memory bundleFilter
|
245
|
+
uint256 collateralAmount
|
110
246
|
)
|
111
247
|
{
|
112
248
|
// check match between policy and bundle (via pool)
|
113
|
-
|
114
|
-
|
115
|
-
|
249
|
+
treasuryInfo = instance.getTreasuryInfo(policyInfo.productNftId);
|
250
|
+
bundleNftId = policyInfo.bundleNftId;
|
251
|
+
bundleInfo = instance.getBundleInfo(bundleNftId);
|
252
|
+
require(bundleInfo.poolNftId == treasuryInfo.poolNftId, "POLICY_BUNDLE_MISMATCH");
|
116
253
|
|
117
254
|
// calculate required collateral
|
118
|
-
NftId poolNftId =
|
255
|
+
NftId poolNftId = treasuryInfo.poolNftId;
|
119
256
|
IPool.PoolInfo memory poolInfo = instance.getPoolInfo(poolNftId);
|
120
257
|
|
121
258
|
// obtain remaining return values
|
122
|
-
poolIsVerifying = poolInfo.isVerifying;
|
123
259
|
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
124
|
-
bundleFilter = bundleInfo.filter;
|
125
260
|
}
|
126
261
|
|
127
262
|
function _lockCollateralInBundle(
|
128
263
|
IInstance instance,
|
264
|
+
NftId bundleNftId,
|
129
265
|
IBundle.BundleInfo memory bundleInfo,
|
130
266
|
NftId policyNftId,
|
131
267
|
uint256 collateralAmount
|
@@ -134,28 +270,39 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
134
270
|
returns (IBundle.BundleInfo memory)
|
135
271
|
{
|
136
272
|
bundleInfo.lockedAmount += collateralAmount;
|
137
|
-
instance.collateralizePolicy(
|
273
|
+
instance.collateralizePolicy(bundleNftId, policyNftId, collateralAmount);
|
138
274
|
return bundleInfo;
|
139
275
|
}
|
140
276
|
|
141
277
|
function _underwriteByPool(
|
142
|
-
ITreasury.
|
278
|
+
ITreasury.TreasuryInfo memory treasuryInfo,
|
279
|
+
NftId policyNftId,
|
143
280
|
IPolicy.PolicyInfo memory policyInfo,
|
144
281
|
bytes memory bundleFilter,
|
145
282
|
uint256 collateralAmount
|
146
283
|
)
|
147
284
|
internal
|
148
285
|
{
|
149
|
-
address poolAddress = _registry.getObjectInfo(
|
286
|
+
address poolAddress = _registry.getObjectInfo(treasuryInfo.poolNftId).objectAddress;
|
150
287
|
IPoolComponent pool = IPoolComponent(poolAddress);
|
151
288
|
pool.underwrite(
|
152
|
-
|
289
|
+
policyNftId,
|
153
290
|
policyInfo.applicationData,
|
154
291
|
bundleFilter,
|
155
292
|
collateralAmount);
|
156
293
|
}
|
157
294
|
|
158
295
|
|
296
|
+
function revoke(
|
297
|
+
NftId policyNftId
|
298
|
+
)
|
299
|
+
external
|
300
|
+
override
|
301
|
+
{
|
302
|
+
require(false, "ERROR:PRS-234:NOT_YET_IMPLEMENTED");
|
303
|
+
}
|
304
|
+
|
305
|
+
|
159
306
|
function underwrite(
|
160
307
|
NftId policyNftId,
|
161
308
|
bool requirePremiumPayment,
|
@@ -174,14 +321,18 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
174
321
|
NftId productNftId = productInfo.nftId;
|
175
322
|
IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
|
176
323
|
require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
177
|
-
require(
|
324
|
+
require(instance.getState(policyNftId.toKey32(POLICY())) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
325
|
+
|
326
|
+
ITreasury.TreasuryInfo memory treasuryInfo;
|
327
|
+
NftId bundleNftId;
|
328
|
+
IBundle.BundleInfo memory bundleInfo;
|
329
|
+
uint256 collateralAmount;
|
178
330
|
|
179
331
|
(
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
bytes memory bundleFilter
|
332
|
+
treasuryInfo,
|
333
|
+
bundleNftId,
|
334
|
+
bundleInfo,
|
335
|
+
collateralAmount
|
185
336
|
) = _getAndVerifyUnderwritingSetup(
|
186
337
|
instance,
|
187
338
|
policyInfo
|
@@ -190,15 +341,28 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
190
341
|
// lock bundle collateral
|
191
342
|
bundleInfo = _lockCollateralInBundle(
|
192
343
|
instance,
|
344
|
+
bundleNftId,
|
193
345
|
bundleInfo,
|
194
346
|
policyNftId,
|
195
347
|
collateralAmount);
|
196
348
|
|
197
|
-
//
|
349
|
+
// set policy state to underwritten
|
350
|
+
instance.updatePolicyState(policyNftId, UNDERWRITTEN());
|
351
|
+
|
352
|
+
// optional activation of policy
|
353
|
+
if(activateAt > zeroTimestamp()) {
|
354
|
+
policyInfo.activatedAt = activateAt;
|
355
|
+
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
356
|
+
|
357
|
+
instance.updatePolicyState(policyNftId, ACTIVE());
|
358
|
+
}
|
359
|
+
|
360
|
+
// optional collection of premium
|
198
361
|
if(requirePremiumPayment) {
|
199
362
|
uint256 netPremiumAmount = _processPremiumByTreasury(
|
200
363
|
instance,
|
201
|
-
|
364
|
+
productInfo.nftId,
|
365
|
+
treasuryInfo,
|
202
366
|
policyNftId,
|
203
367
|
policyInfo.premiumAmount);
|
204
368
|
|
@@ -206,31 +370,23 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
206
370
|
bundleInfo.balanceAmount += netPremiumAmount;
|
207
371
|
}
|
208
372
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
// integrate pool component
|
227
|
-
if(poolIsVerifying) {
|
228
|
-
_underwriteByPool(
|
229
|
-
productSetup,
|
230
|
-
policyInfo,
|
231
|
-
bundleFilter,
|
232
|
-
collateralAmount
|
233
|
-
);
|
373
|
+
instance.setPolicyInfo(policyNftId, policyInfo);
|
374
|
+
instance.setBundleInfo(bundleNftId, bundleInfo);
|
375
|
+
|
376
|
+
// involve pool if necessary
|
377
|
+
{
|
378
|
+
NftId poolNftId = treasuryInfo.poolNftId;
|
379
|
+
IPool.PoolInfo memory poolInfo = instance.getPoolInfo(poolNftId);
|
380
|
+
|
381
|
+
if(poolInfo.isVerifying) {
|
382
|
+
_underwriteByPool(
|
383
|
+
treasuryInfo,
|
384
|
+
policyNftId,
|
385
|
+
policyInfo,
|
386
|
+
bundleInfo.filter,
|
387
|
+
collateralAmount
|
388
|
+
);
|
389
|
+
}
|
234
390
|
}
|
235
391
|
|
236
392
|
// TODO add logging
|
@@ -248,14 +404,13 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
248
404
|
|
249
405
|
// perform actual token transfers
|
250
406
|
IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
|
251
|
-
ITreasury.
|
407
|
+
ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productInfo.nftId);
|
252
408
|
|
253
409
|
uint256 premiumAmount = policyInfo.premiumAmount;
|
254
|
-
_processPremiumByTreasury(instance,
|
410
|
+
_processPremiumByTreasury(instance, productInfo.nftId, treasuryInfo, policyNftId, premiumAmount);
|
255
411
|
|
256
412
|
// policy level book keeping for premium paid
|
257
413
|
policyInfo.premiumPaidAmount += premiumAmount;
|
258
|
-
policyInfo.updatedIn = blockNumber();
|
259
414
|
|
260
415
|
// optional activation of policy
|
261
416
|
if(activateAt > zeroTimestamp()) {
|
@@ -266,11 +421,10 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
266
421
|
policyInfo.activatedAt = activateAt;
|
267
422
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
268
423
|
|
269
|
-
|
270
|
-
policyInfo.state = ACTIVE();
|
424
|
+
instance.updatePolicyState(policyNftId, ACTIVE());
|
271
425
|
}
|
272
426
|
|
273
|
-
instance.setPolicyInfo(policyInfo);
|
427
|
+
instance.setPolicyInfo(policyNftId, policyInfo);
|
274
428
|
|
275
429
|
// TODO add logging
|
276
430
|
}
|
@@ -288,10 +442,8 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
288
442
|
policyInfo.activatedAt = activateAt;
|
289
443
|
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
290
444
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
instance.setPolicyInfo(policyInfo);
|
445
|
+
instance.setPolicyInfo(policyNftId, policyInfo);
|
446
|
+
instance.updatePolicyState(policyNftId, ACTIVE());
|
295
447
|
|
296
448
|
// TODO add logging
|
297
449
|
}
|
@@ -311,12 +463,14 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
311
463
|
view
|
312
464
|
returns (NftId poolNftid)
|
313
465
|
{
|
314
|
-
return instance.
|
466
|
+
return instance.getTreasuryInfo(productNftId).poolNftId;
|
315
467
|
}
|
316
468
|
|
469
|
+
|
317
470
|
function _processPremiumByTreasury(
|
318
471
|
IInstance instance,
|
319
|
-
|
472
|
+
NftId productNftId,
|
473
|
+
ITreasury.TreasuryInfo memory treasuryInfo,
|
320
474
|
NftId policyNftId,
|
321
475
|
uint256 premiumAmount
|
322
476
|
)
|
@@ -325,13 +479,13 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
325
479
|
{
|
326
480
|
// process token transfer(s)
|
327
481
|
if(premiumAmount > 0) {
|
328
|
-
TokenHandler tokenHandler = instance.getTokenHandler(
|
482
|
+
TokenHandler tokenHandler = instance.getTokenHandler(productNftId);
|
329
483
|
address policyOwner = _registry.getOwner(policyNftId);
|
330
|
-
address poolWallet = instance.
|
484
|
+
address poolWallet = instance.getComponentWallet(treasuryInfo.poolNftId);
|
331
485
|
netPremiumAmount = premiumAmount;
|
332
|
-
Fee memory
|
486
|
+
Fee memory productFee = treasuryInfo.productFee;
|
333
487
|
|
334
|
-
if (FeeLib.feeIsZero(
|
488
|
+
if (FeeLib.feeIsZero(productFee)) {
|
335
489
|
tokenHandler.transfer(
|
336
490
|
policyOwner,
|
337
491
|
poolWallet,
|
@@ -340,10 +494,11 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
340
494
|
} else {
|
341
495
|
(uint256 feeAmount, uint256 netAmount) = instance.calculateFeeAmount(
|
342
496
|
premiumAmount,
|
343
|
-
|
497
|
+
productFee
|
344
498
|
);
|
345
499
|
|
346
|
-
|
500
|
+
address productWallet = instance.getComponentWallet(productNftId);
|
501
|
+
tokenHandler.transfer(policyOwner, productWallet, feeAmount);
|
347
502
|
tokenHandler.transfer(policyOwner, poolWallet, netAmount);
|
348
503
|
netPremiumAmount = netAmount;
|
349
504
|
}
|