@etherisc/gif-next 0.0.2-f29e479-370 → 0.0.2-f30e0eb-805
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/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +68 -89
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +113 -140
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +65 -73
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +91 -122
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +256 -189
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +69 -145
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +279 -245
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +73 -162
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +171 -308
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +98 -40
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +260 -379
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +448 -121
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +120 -227
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +148 -161
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +31 -23
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +1 -1
- 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 +54 -71
- 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 +161 -62
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +33 -25
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +137 -140
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +12 -12
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +3 -3
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +2 -2
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +505 -91
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +78 -42
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +110 -27
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +93 -96
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +350 -8
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +21 -64
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +81 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +58 -157
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +19 -47
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +114 -17
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -9
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +7 -7
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +4 -4
- 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/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 +5 -5
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +3 -3
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +7 -7
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +3 -3
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +3 -3
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +3 -3
- 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/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +2 -2
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
- package/contracts/components/Component.sol +95 -85
- package/contracts/components/Distribution.sol +12 -19
- package/contracts/components/IComponent.sol +37 -17
- 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 +171 -126
- package/contracts/components/Product.sol +26 -18
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +7 -5
- package/contracts/instance/Cloneable.sol +7 -2
- package/contracts/instance/IInstance.sol +16 -10
- package/contracts/instance/IInstanceService.sol +18 -5
- package/contracts/instance/Instance.sol +45 -9
- package/contracts/instance/InstanceAccessManager.sol +382 -157
- package/contracts/instance/InstanceReader.sol +7 -10
- package/contracts/instance/InstanceService.sol +174 -155
- package/contracts/instance/ObjectManager.sol +6 -8
- package/contracts/instance/base/ComponentService.sol +5 -5
- package/contracts/instance/base/KeyValueStore.sol +5 -2
- package/contracts/instance/base/Lifecycle.sol +11 -2
- package/contracts/instance/module/IAccess.sol +20 -13
- package/contracts/instance/module/IBundle.sol +2 -1
- package/contracts/instance/module/IComponents.sol +35 -0
- package/contracts/instance/module/IDistribution.sol +2 -1
- package/contracts/instance/module/IPolicy.sol +26 -1
- package/contracts/instance/module/ISetup.sol +7 -22
- package/contracts/instance/service/ApplicationService.sol +123 -41
- package/contracts/instance/service/BundleService.sol +76 -38
- package/contracts/instance/service/DistributionService.sol +139 -47
- package/contracts/instance/service/IApplicationService.sol +7 -7
- package/contracts/instance/service/IBundleService.sol +19 -11
- package/contracts/instance/service/IDistributionService.sol +19 -4
- package/contracts/instance/service/IPolicyService.sol +3 -20
- package/contracts/instance/service/IPoolService.sol +17 -2
- package/contracts/instance/service/PolicyService.sol +59 -132
- package/contracts/instance/service/PoolService.sol +128 -17
- package/contracts/instance/service/ProductService.sol +10 -2
- package/contracts/registry/ChainNft.sol +8 -0
- package/contracts/registry/IRegistry.sol +2 -0
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +23 -20
- package/contracts/registry/RegistryService.sol +5 -5
- package/contracts/shared/Registerable.sol +2 -2
- package/contracts/shared/TokenHandler.sol +11 -5
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/Fee.sol +1 -0
- package/contracts/types/NftId.sol +8 -0
- package/contracts/types/ObjectType.sol +1 -0
- package/contracts/types/Referral.sol +4 -0
- package/contracts/types/RoleId.sol +13 -6
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/StateId.sol +1 -0
- package/contracts/types/Timestamp.sol +13 -13
- package/contracts/types/UFixed.sol +1 -0
- package/contracts/types/Version.sol +1 -0
- package/package.json +1 -1
| @@ -7,6 +7,7 @@ import {IService} from "../../shared/IService.sol"; | |
| 7 7 | 
             
            import {NftId} from "../../types/NftId.sol";
         | 
| 8 8 | 
             
            import {ReferralId} from "../../types/Referral.sol";
         | 
| 9 9 | 
             
            import {RiskId} from "../../types/RiskId.sol";
         | 
| 10 | 
            +
            import {Seconds} from "../../types/Seconds.sol";
         | 
| 10 11 | 
             
            import {StateId} from "../../types/StateId.sol";
         | 
| 11 12 | 
             
            import {Timestamp} from "../../types/Timestamp.sol";
         | 
| 12 13 | 
             
            import {UFixed} from "../../types/UFixed.sol";
         | 
| @@ -23,6 +24,8 @@ interface IPolicyService is IService { | |
| 23 24 | 
             
                error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
         | 
| 24 25 | 
             
                error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
         | 
| 25 26 |  | 
| 27 | 
            +
                error ErrorIPolicyServicePremiumMismatch(NftId policyNftId, uint256 premiumAmount, uint256 recalculatedPremiumAmount);
         | 
| 28 | 
            +
             | 
| 26 29 | 
             
                /// @dev declines an application represented by {policyNftId}
         | 
| 27 30 | 
             
                /// an application can only be declined in applied state
         | 
| 28 31 | 
             
                /// only the related product may decline an application
         | 
| @@ -60,26 +63,6 @@ interface IPolicyService is IService { | |
| 60 63 | 
             
                /// this function can only be called by a product. the policy needs to match with the calling product
         | 
| 61 64 | 
             
                function close(NftId policyNftId) external;
         | 
| 62 65 |  | 
| 63 | 
            -
                /// @dev calculates the total premium amount for the specified attributes
         | 
| 64 | 
            -
                /// also returns the various fees included in the total premium amount
         | 
| 65 | 
            -
                function calculatePremium(
         | 
| 66 | 
            -
                    RiskId riskId,
         | 
| 67 | 
            -
                    uint256 sumInsuredAmount,
         | 
| 68 | 
            -
                    uint256 lifetime,
         | 
| 69 | 
            -
                    bytes memory applicationData,
         | 
| 70 | 
            -
                    NftId bundleNftId,
         | 
| 71 | 
            -
                    ReferralId referralId
         | 
| 72 | 
            -
                )
         | 
| 73 | 
            -
                    external
         | 
| 74 | 
            -
                    view
         | 
| 75 | 
            -
                    returns (
         | 
| 76 | 
            -
                        uint256 premiumAmount,
         | 
| 77 | 
            -
                        uint256 productFeeAmount,
         | 
| 78 | 
            -
                        uint256 poolFeeAmount,
         | 
| 79 | 
            -
                        uint256 bundleFeeAmount,
         | 
| 80 | 
            -
                        uint256 distributionFeeAmount
         | 
| 81 | 
            -
                    );
         | 
| 82 | 
            -
             | 
| 83 66 | 
             
                // TODO move function to pool service
         | 
| 84 67 | 
             
                function calculateRequiredCollateral(
         | 
| 85 68 | 
             
                    UFixed collateralizationLevel, 
         | 
| @@ -1,17 +1,32 @@ | |
| 1 1 | 
             
            // SPDX-License-Identifier: Apache-2.0
         | 
| 2 2 | 
             
            pragma solidity ^0.8.19;
         | 
| 3 3 |  | 
| 4 | 
            -
            import {NftId} from "../../types/NftId.sol";
         | 
| 5 4 | 
             
            import {Fee} from "../../types/Fee.sol";
         | 
| 6 | 
            -
            import { | 
| 5 | 
            +
            import {NftId} from "../../types/NftId.sol";
         | 
| 7 6 | 
             
            import {IService} from "../../shared/IService.sol";
         | 
| 8 7 | 
             
            import {IBundle} from "../module/IBundle.sol";
         | 
| 9 8 | 
             
            import {IInstance} from "../../instance/IInstance.sol";
         | 
| 9 | 
            +
            import {RoleId} from "../../types/RoleId.sol";
         | 
| 10 | 
            +
            import {StateId} from "../../types/StateId.sol";
         | 
| 10 11 |  | 
| 11 12 | 
             
            interface IPoolService is IService {
         | 
| 12 13 |  | 
| 14 | 
            +
                event LogPoolServiceMaxCapitalAmountUpdated(NftId poolNftId, uint256 previousMaxCapitalAmount, uint256 currentMaxCapitalAmount);
         | 
| 15 | 
            +
                event LogPoolServiceBundleOwnerRoleSet(NftId poolNftId, RoleId bundleOwnerRole);
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                error ErrorPoolServiceBundleOwnerRoleAlreadySet(NftId poolNftId);
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                /// @dev registers a new pool with the registry service
         | 
| 13 20 | 
             
                function register(address poolAddress) external returns(NftId);
         | 
| 14 21 |  | 
| 22 | 
            +
                /// @dev defines the required role for bundle owners for the calling pool
         | 
| 23 | 
            +
                /// default implementation returns PUBLIC ROLE
         | 
| 24 | 
            +
                function setBundleOwnerRole(RoleId bundleOwnerRole) external;
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                /// @dev sets the max capital amount for the calling pool
         | 
| 27 | 
            +
                function setMaxCapitalAmount(uint256 maxCapitalAmount) external;
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                /// @dev set pool sepecific fees
         | 
| 15 30 | 
             
                function setFees(
         | 
| 16 31 | 
             
                    Fee memory poolFee,
         | 
| 17 32 | 
             
                    Fee memory stakingFee,
         | 
| @@ -2,43 +2,34 @@ | |
| 2 2 | 
             
            pragma solidity ^0.8.19;
         | 
| 3 3 |  | 
| 4 4 | 
             
            import {IRegistry} from "../../registry/IRegistry.sol";
         | 
| 5 | 
            -
            import {IProductComponent} from "../../components/IProductComponent.sol";
         | 
| 6 5 | 
             
            import {Product} from "../../components/Product.sol";
         | 
| 7 | 
            -
            import { | 
| 6 | 
            +
            import {IComponents} from "../module/IComponents.sol";
         | 
| 8 7 | 
             
            import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
         | 
| 9 8 | 
             
            import {IInstance} from "../IInstance.sol";
         | 
| 10 9 | 
             
            import {IPolicy} from "../module/IPolicy.sol";
         | 
| 10 | 
            +
            import {IPoolComponent} from "../../components/IPoolComponent.sol";
         | 
| 11 11 | 
             
            import {IRisk} from "../module/IRisk.sol";
         | 
| 12 12 | 
             
            import {IBundle} from "../module/IBundle.sol";
         | 
| 13 | 
            -
            import {IProductService} from "./IProductService.sol";
         | 
| 14 | 
            -
            import {ITreasury} from "../module/ITreasury.sol";
         | 
| 15 13 | 
             
            import {ISetup} from "../module/ISetup.sol";
         | 
| 16 14 |  | 
| 17 15 | 
             
            import {TokenHandler} from "../../shared/TokenHandler.sol";
         | 
| 18 16 |  | 
| 19 | 
            -
            import {IVersionable} from "../../shared/IVersionable.sol";
         | 
| 20 | 
            -
            import {Versionable} from "../../shared/Versionable.sol";
         | 
| 21 | 
            -
             | 
| 22 17 | 
             
            import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
         | 
| 23 18 | 
             
            import {UFixed, UFixedLib} from "../../types/UFixed.sol";
         | 
| 24 | 
            -
            import { | 
| 25 | 
            -
            import {ObjectType, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
         | 
| 19 | 
            +
            import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
         | 
| 26 20 | 
             
            import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
         | 
| 27 | 
            -
            import {NftId, NftIdLib | 
| 28 | 
            -
            import {Fee, FeeLib} from "../../types/Fee.sol";
         | 
| 29 | 
            -
            import {ReferralId} from "../../types/Referral.sol";
         | 
| 30 | 
            -
            import {RiskId} from "../../types/RiskId.sol";
         | 
| 21 | 
            +
            import {NftId, NftIdLib} from "../../types/NftId.sol";
         | 
| 31 22 | 
             
            import {StateId} from "../../types/StateId.sol";
         | 
| 32 | 
            -
            import {Version, VersionLib} from "../../types/Version.sol";
         | 
| 33 | 
            -
            //import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
         | 
| 34 23 |  | 
| 35 | 
            -
            import {IService} from "../../shared/IService.sol";
         | 
| 36 | 
            -
            import {Service} from "../../shared/Service.sol";
         | 
| 37 24 | 
             
            import {ComponentService} from "../base/ComponentService.sol";
         | 
| 38 | 
            -
            import { | 
| 25 | 
            +
            import {IApplicationService} from "./IApplicationService.sol";
         | 
| 26 | 
            +
            import {IBundleService} from "./IBundleService.sol";
         | 
| 27 | 
            +
            import {IDistributionService} from "./IDistributionService.sol";
         | 
| 39 28 | 
             
            import {InstanceReader} from "../InstanceReader.sol";
         | 
| 29 | 
            +
            import {IPolicyService} from "./IPolicyService.sol";
         | 
| 40 30 | 
             
            import {IPoolService} from "./IPoolService.sol";
         | 
| 41 | 
            -
            import { | 
| 31 | 
            +
            import {IService} from "../../shared/IService.sol";
         | 
| 32 | 
            +
            import {Service} from "../../shared/Service.sol";
         | 
| 42 33 |  | 
| 43 34 |  | 
| 44 35 | 
             
            contract PolicyService is
         | 
| @@ -50,6 +41,8 @@ contract PolicyService is | |
| 50 41 |  | 
| 51 42 | 
             
                IPoolService internal _poolService;
         | 
| 52 43 | 
             
                IBundleService internal _bundleService;
         | 
| 44 | 
            +
                IApplicationService internal _applicationService;
         | 
| 45 | 
            +
                IDistributionService internal _distributionService;
         | 
| 53 46 |  | 
| 54 47 | 
             
                event LogProductServiceSender(address sender);
         | 
| 55 48 |  | 
| @@ -69,6 +62,8 @@ contract PolicyService is | |
| 69 62 |  | 
| 70 63 | 
             
                    _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
         | 
| 71 64 | 
             
                    _bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getMajorVersion()));
         | 
| 65 | 
            +
                    _applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), getMajorVersion()));
         | 
| 66 | 
            +
                    _distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), getMajorVersion()));
         | 
| 72 67 |  | 
| 73 68 | 
             
                    registerInterface(type(IPolicyService).interfaceId);
         | 
| 74 69 | 
             
                }
         | 
| @@ -85,94 +80,6 @@ contract PolicyService is | |
| 85 80 | 
             
                    product = Product(productInfo.objectAddress);
         | 
| 86 81 | 
             
                }
         | 
| 87 82 |  | 
| 88 | 
            -
                // TODO: no access restrictions
         | 
| 89 | 
            -
                function calculatePremium(
         | 
| 90 | 
            -
                    RiskId riskId,
         | 
| 91 | 
            -
                    uint256 sumInsuredAmount,
         | 
| 92 | 
            -
                    uint256 lifetime,
         | 
| 93 | 
            -
                    bytes memory applicationData,
         | 
| 94 | 
            -
                    NftId bundleNftId,
         | 
| 95 | 
            -
                    ReferralId referralId
         | 
| 96 | 
            -
                )
         | 
| 97 | 
            -
                    public
         | 
| 98 | 
            -
                    view 
         | 
| 99 | 
            -
                    virtual override
         | 
| 100 | 
            -
                    returns (
         | 
| 101 | 
            -
                        uint256 premiumAmount,
         | 
| 102 | 
            -
                        uint256 productFeeAmount,
         | 
| 103 | 
            -
                        uint256 poolFeeAmount,
         | 
| 104 | 
            -
                        uint256 bundleFeeAmount,
         | 
| 105 | 
            -
                        uint256 distributionFeeAmount
         | 
| 106 | 
            -
                    )
         | 
| 107 | 
            -
                {
         | 
| 108 | 
            -
                    Product product = _getAndVerifyInstanceAndProduct();
         | 
| 109 | 
            -
                    uint256 netPremiumAmount = product.calculateNetPremium(
         | 
| 110 | 
            -
                        sumInsuredAmount,
         | 
| 111 | 
            -
                        riskId,
         | 
| 112 | 
            -
                        lifetime,
         | 
| 113 | 
            -
                        applicationData
         | 
| 114 | 
            -
                    );
         | 
| 115 | 
            -
             | 
| 116 | 
            -
                    (
         | 
| 117 | 
            -
                        productFeeAmount,
         | 
| 118 | 
            -
                        poolFeeAmount,
         | 
| 119 | 
            -
                        bundleFeeAmount,
         | 
| 120 | 
            -
                        distributionFeeAmount
         | 
| 121 | 
            -
                    ) = _calculateFeeAmounts(
         | 
| 122 | 
            -
                        netPremiumAmount,
         | 
| 123 | 
            -
                        product,
         | 
| 124 | 
            -
                        bundleNftId,
         | 
| 125 | 
            -
                        referralId
         | 
| 126 | 
            -
                    );
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                    premiumAmount = netPremiumAmount + productFeeAmount;
         | 
| 129 | 
            -
                    premiumAmount += poolFeeAmount + bundleFeeAmount;
         | 
| 130 | 
            -
                    premiumAmount += distributionFeeAmount;
         | 
| 131 | 
            -
                }
         | 
| 132 | 
            -
             | 
| 133 | 
            -
                function _calculateFeeAmounts(
         | 
| 134 | 
            -
                    uint256 netPremiumAmount,
         | 
| 135 | 
            -
                    Product product,
         | 
| 136 | 
            -
                    NftId bundleNftId,
         | 
| 137 | 
            -
                    ReferralId referralId
         | 
| 138 | 
            -
                )
         | 
| 139 | 
            -
                    internal
         | 
| 140 | 
            -
                    view
         | 
| 141 | 
            -
                    returns (
         | 
| 142 | 
            -
                        uint256 productFeeAmount,
         | 
| 143 | 
            -
                        uint256 poolFeeAmount,
         | 
| 144 | 
            -
                        uint256 bundleFeeAmount,
         | 
| 145 | 
            -
                        uint256 distributionFeeAmount
         | 
| 146 | 
            -
                    )
         | 
| 147 | 
            -
                {
         | 
| 148 | 
            -
                    InstanceReader instanceReader;
         | 
| 149 | 
            -
                    {
         | 
| 150 | 
            -
                        IInstance instance = product.getInstance();
         | 
| 151 | 
            -
                        instanceReader = instance.getInstanceReader();
         | 
| 152 | 
            -
                    }
         | 
| 153 | 
            -
                    
         | 
| 154 | 
            -
                    NftId poolNftId = product.getPoolNftId();
         | 
| 155 | 
            -
                    IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
         | 
| 156 | 
            -
                    require(bundleInfo.poolNftId == poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
         | 
| 157 | 
            -
             | 
| 158 | 
            -
                    {
         | 
| 159 | 
            -
                        ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(product.getProductNftId());
         | 
| 160 | 
            -
                        (productFeeAmount,) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
         | 
| 161 | 
            -
                    }
         | 
| 162 | 
            -
                    {
         | 
| 163 | 
            -
                        ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
         | 
| 164 | 
            -
                        (poolFeeAmount,) = FeeLib.calculateFee(poolSetupInfo.poolFee, netPremiumAmount);
         | 
| 165 | 
            -
                    }
         | 
| 166 | 
            -
                    {
         | 
| 167 | 
            -
                        NftId distributionNftId = product.getDistributionNftId();
         | 
| 168 | 
            -
                        ISetup.DistributionSetupInfo memory distributionSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
         | 
| 169 | 
            -
                        // FIXME: call distributionService.calculateFeeAmount
         | 
| 170 | 
            -
                        (distributionFeeAmount,) = FeeLib.calculateFee(distributionSetupInfo.distributionFee, netPremiumAmount);
         | 
| 171 | 
            -
                    }
         | 
| 172 | 
            -
                    
         | 
| 173 | 
            -
                    (bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
         | 
| 174 | 
            -
                }
         | 
| 175 | 
            -
             | 
| 176 83 | 
             
                function _getAndVerifyUnderwritingSetup(
         | 
| 177 84 | 
             
                    IInstance instance,
         | 
| 178 85 | 
             
                    InstanceReader instanceReader,
         | 
| @@ -195,7 +102,9 @@ contract PolicyService is | |
| 195 102 | 
             
                    require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
         | 
| 196 103 |  | 
| 197 104 | 
             
                    // calculate required collateral
         | 
| 198 | 
            -
                     | 
| 105 | 
            +
                    IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
         | 
| 106 | 
            +
                    IComponents.PoolInfo memory poolInfo = abi.decode(
         | 
| 107 | 
            +
                        componentInfo.data, (IComponents.PoolInfo));
         | 
| 199 108 |  | 
| 200 109 | 
             
                    // obtain remaining return values
         | 
| 201 110 | 
             
                    // TODO required collateral amount should be calculated by pool service, not policy service
         | 
| @@ -268,7 +177,6 @@ contract PolicyService is | |
| 268 177 | 
             
                    if(requirePremiumPayment) {
         | 
| 269 178 | 
             
                        netPremiumAmount = _processPremiumByTreasury(
         | 
| 270 179 | 
             
                            instance, 
         | 
| 271 | 
            -
                            productNftId,
         | 
| 272 180 | 
             
                            applicationNftId, 
         | 
| 273 181 | 
             
                            policyInfo.premiumAmount);
         | 
| 274 182 |  | 
| @@ -296,13 +204,19 @@ contract PolicyService is | |
| 296 204 | 
             
                    instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
         | 
| 297 205 |  | 
| 298 206 | 
             
                    // also verify/confirm application by pool if necessary
         | 
| 299 | 
            -
                    if( | 
| 207 | 
            +
                    if(abi.decode(
         | 
| 208 | 
            +
                        instanceReader.getComponentInfo(poolNftId).data, 
         | 
| 209 | 
            +
                        (IComponents.PoolInfo)
         | 
| 210 | 
            +
                        ).isVerifyingApplications
         | 
| 211 | 
            +
                    )
         | 
| 212 | 
            +
                    {
         | 
| 300 213 | 
             
                        IPoolComponent pool = IPoolComponent(
         | 
| 301 214 | 
             
                            getRegistry().getObjectInfo(poolNftId).objectAddress);
         | 
| 302 215 |  | 
| 303 216 | 
             
                        pool.verifyApplication(
         | 
| 304 217 | 
             
                            applicationNftId, 
         | 
| 305 218 | 
             
                            policyInfo.applicationData, 
         | 
| 219 | 
            +
                            bundleNftId,
         | 
| 306 220 | 
             
                            bundleInfo.filter,
         | 
| 307 221 | 
             
                            collateralAmount);
         | 
| 308 222 | 
             
                    }
         | 
| @@ -331,7 +245,6 @@ contract PolicyService is | |
| 331 245 |  | 
| 332 246 | 
             
                    uint256 netPremiumAmount = _processPremiumByTreasury(
         | 
| 333 247 | 
             
                            instance, 
         | 
| 334 | 
            -
                            productInfo.nftId,
         | 
| 335 248 | 
             
                            policyNftId, 
         | 
| 336 249 | 
             
                            unpaidPremiumAmount);
         | 
| 337 250 |  | 
| @@ -435,7 +348,6 @@ contract PolicyService is | |
| 435 348 |  | 
| 436 349 | 
             
                function _processPremiumByTreasury(
         | 
| 437 350 | 
             
                    IInstance instance,
         | 
| 438 | 
            -
                    NftId productNftId,
         | 
| 439 351 | 
             
                    NftId policyNftId,
         | 
| 440 352 | 
             
                    uint256 premiumAmount
         | 
| 441 353 | 
             
                )
         | 
| @@ -444,31 +356,46 @@ contract PolicyService is | |
| 444 356 | 
             
                {
         | 
| 445 357 | 
             
                    // process token transfer(s)
         | 
| 446 358 | 
             
                    if(premiumAmount > 0) {
         | 
| 359 | 
            +
                        NftId productNftId = getRegistry().getObjectInfo(policyNftId).parentNftId;
         | 
| 447 360 | 
             
                        ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
         | 
| 361 | 
            +
                        IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
         | 
| 448 362 | 
             
                        TokenHandler tokenHandler = productSetupInfo.tokenHandler;
         | 
| 449 363 | 
             
                        address policyOwner = getRegistry().ownerOf(policyNftId);
         | 
| 450 | 
            -
                         | 
| 451 | 
            -
                         | 
| 452 | 
            -
             | 
| 453 | 
            -
             | 
| 454 | 
            -
             | 
| 455 | 
            -
             | 
| 456 | 
            -
                             | 
| 457 | 
            -
             | 
| 458 | 
            -
             | 
| 459 | 
            -
                                premiumAmount
         | 
| 364 | 
            +
                        address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
         | 
| 365 | 
            +
                        IPolicy.Premium memory premium = _applicationService.calculatePremium(
         | 
| 366 | 
            +
                            productNftId,
         | 
| 367 | 
            +
                            policyInfo.riskId,
         | 
| 368 | 
            +
                            policyInfo.sumInsuredAmount,
         | 
| 369 | 
            +
                            policyInfo.lifetime,
         | 
| 370 | 
            +
                            policyInfo.applicationData,
         | 
| 371 | 
            +
                            policyInfo.bundleNftId,
         | 
| 372 | 
            +
                            policyInfo.referralId
         | 
| 460 373 | 
             
                            );
         | 
| 461 | 
            -
             | 
| 462 | 
            -
             | 
| 463 | 
            -
                             | 
| 464 | 
            -
             | 
| 465 | 
            -
             | 
| 466 | 
            -
             | 
| 467 | 
            -
             | 
| 468 | 
            -
             | 
| 469 | 
            -
                             | 
| 470 | 
            -
                            // TODO: also move distribution tokens to distribution wallet and call `Distribution.processSale` to update distribution balances
         | 
| 374 | 
            +
             | 
| 375 | 
            +
                        if (premium.premiumAmount != premiumAmount) {
         | 
| 376 | 
            +
                            revert ErrorIPolicyServicePremiumMismatch(policyNftId, premiumAmount, premium.premiumAmount);
         | 
| 377 | 
            +
                        }
         | 
| 378 | 
            +
             | 
| 379 | 
            +
                        // move product fee to product wallet
         | 
| 380 | 
            +
                        address productWallet = productSetupInfo.wallet;
         | 
| 381 | 
            +
                        if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
         | 
| 382 | 
            +
                            revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
         | 
| 471 383 | 
             
                        }
         | 
| 384 | 
            +
                        tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
         | 
| 385 | 
            +
             | 
| 386 | 
            +
                        // move distribution fee to distribution wallet
         | 
| 387 | 
            +
                        ISetup.DistributionSetupInfo memory distributionSetupInfo = instance.getInstanceReader().getDistributionSetupInfo(productSetupInfo.distributionNftId);
         | 
| 388 | 
            +
                        address distributionWallet = distributionSetupInfo.wallet;
         | 
| 389 | 
            +
                        uint256 distributionFeeAmountToTransfer = premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount;
         | 
| 390 | 
            +
                        tokenHandler.transfer(policyOwner, distributionWallet, distributionFeeAmountToTransfer);
         | 
| 391 | 
            +
                        _distributionService.processSale(productSetupInfo.distributionNftId, policyInfo.referralId, premium, distributionFeeAmountToTransfer);
         | 
| 392 | 
            +
                        
         | 
| 393 | 
            +
                        // move netpremium to pool wallet
         | 
| 394 | 
            +
                        tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
         | 
| 395 | 
            +
                        
         | 
| 396 | 
            +
                        // TODO: move pool related tokens too
         | 
| 397 | 
            +
                        // TODO: move bundle related tokens too
         | 
| 398 | 
            +
                        netPremiumAmount = premium.netPremiumAmount;
         | 
| 472 399 | 
             
                    }
         | 
| 473 400 |  | 
| 474 401 | 
             
                    // TODO: add logging
         | 
| @@ -6,20 +6,22 @@ import {IRegistry} from "../../registry/IRegistry.sol"; | |
| 6 6 | 
             
            import {IInstance} from "../../instance/IInstance.sol";
         | 
| 7 7 | 
             
            import {IBundle} from "../../instance/module/IBundle.sol";
         | 
| 8 8 | 
             
            import {TokenHandler} from "../../instance/module/ITreasury.sol";
         | 
| 9 | 
            -
            import { | 
| 9 | 
            +
            import {IComponents} from "../module/IComponents.sol";
         | 
| 10 10 | 
             
            import {IPolicy} from "../module/IPolicy.sol";
         | 
| 11 11 |  | 
| 12 12 | 
             
            import {IVersionable} from "../../shared/IVersionable.sol";
         | 
| 13 13 | 
             
            import {Versionable} from "../../shared/Versionable.sol";
         | 
| 14 14 | 
             
            import {INftOwnable} from "../../shared/INftOwnable.sol";
         | 
| 15 15 |  | 
| 16 | 
            +
            import {Fee, FeeLib} from "../../types/Fee.sol";
         | 
| 16 17 | 
             
            import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
         | 
| 17 18 | 
             
            import {ObjectType, POOL, BUNDLE} from "../../types/ObjectType.sol";
         | 
| 18 | 
            -
            import {POOL_OWNER_ROLE, RoleId} from "../../types/RoleId.sol";
         | 
| 19 | 
            +
            import {PUBLIC_ROLE, POOL_OWNER_ROLE, POLICY_SERVICE_ROLE, RoleId} from "../../types/RoleId.sol";
         | 
| 19 20 | 
             
            import {Fee, FeeLib} from "../../types/Fee.sol";
         | 
| 20 21 | 
             
            import {Version, VersionLib} from "../../types/Version.sol";
         | 
| 21 22 | 
             
            import {KEEP_STATE, StateId} from "../../types/StateId.sol";
         | 
| 22 23 | 
             
            import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
         | 
| 24 | 
            +
            import {Version, VersionLib} from "../../types/Version.sol";
         | 
| 23 25 |  | 
| 24 26 | 
             
            import {IService} from "../../shared/IService.sol";
         | 
| 25 27 | 
             
            import {Service} from "../../shared/Service.sol";
         | 
| @@ -63,7 +65,7 @@ contract PoolService is | |
| 63 65 | 
             
                    return POOL();
         | 
| 64 66 | 
             
                }
         | 
| 65 67 |  | 
| 66 | 
            -
                function register(address poolAddress) 
         | 
| 68 | 
            +
                /*function register(address poolAddress) 
         | 
| 67 69 | 
             
                    external
         | 
| 68 70 | 
             
                    returns(NftId poolNftId)
         | 
| 69 71 | 
             
                {
         | 
| @@ -78,32 +80,141 @@ contract PoolService is | |
| 78 80 | 
             
                        POOL_OWNER_ROLE());
         | 
| 79 81 |  | 
| 80 82 | 
             
                    IPoolComponent pool = IPoolComponent(poolAddress);
         | 
| 81 | 
            -
                    IRegistry.ObjectInfo memory  | 
| 83 | 
            +
                    IRegistry.ObjectInfo memory registryInfo = getRegistryService().registerPool(pool, owner);
         | 
| 82 84 | 
             
                    pool.linkToRegisteredNftId();
         | 
| 83 | 
            -
                    poolNftId =  | 
| 85 | 
            +
                    poolNftId = registryInfo.nftId;
         | 
| 84 86 |  | 
| 85 87 | 
             
                    instance.createPoolSetup(poolNftId, pool.getSetupInfo());
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                     | 
| 88 | 
            +
             | 
| 89 | 
            +
                    bytes4[][] memory selectors = new bytes4[][](2);
         | 
| 90 | 
            +
                    selectors[0] = new bytes4[](1);
         | 
| 91 | 
            +
                    selectors[1] = new bytes4[](1);
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                    selectors[0][0] = IPoolComponent.setFees.selector;
         | 
| 94 | 
            +
                    selectors[1][0] = IPoolComponent.verifyApplication.selector;
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                    RoleId[] memory roles = new RoleId[](2);
         | 
| 97 | 
            +
                    roles[0] = POOL_OWNER_ROLE();
         | 
| 98 | 
            +
                    roles[1] = POLICY_SERVICE_ROLE();
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                    getInstanceService().createGifTarget(
         | 
| 101 | 
            +
                        instanceNftId, 
         | 
| 102 | 
            +
                        poolAddress, 
         | 
| 103 | 
            +
                        pool.getName(), 
         | 
| 104 | 
            +
                        selectors, 
         | 
| 105 | 
            +
                        roles);
         | 
| 106 | 
            +
                }*/
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                function register(address poolAddress) 
         | 
| 109 | 
            +
                    external
         | 
| 110 | 
            +
                    returns(NftId poolNftId)
         | 
| 111 | 
            +
                {
         | 
| 112 | 
            +
                    (
         | 
| 113 | 
            +
                        IComponent component,
         | 
| 114 | 
            +
                        address owner,
         | 
| 115 | 
            +
                        IInstance instance,
         | 
| 116 | 
            +
                        NftId instanceNftId
         | 
| 117 | 
            +
                    ) = _checkComponentForRegistration(
         | 
| 118 | 
            +
                        poolAddress,
         | 
| 119 | 
            +
                        POOL(),
         | 
| 120 | 
            +
                        POOL_OWNER_ROLE());
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                    IPoolComponent pool = IPoolComponent(poolAddress);
         | 
| 123 | 
            +
                    IRegistry.ObjectInfo memory registryInfo = getRegistryService().registerPool(pool, owner);
         | 
| 124 | 
            +
                    pool.linkToRegisteredNftId();
         | 
| 125 | 
            +
                    poolNftId = registryInfo.nftId;
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    // amend component info with pool specific token handler
         | 
| 128 | 
            +
                    IComponents.ComponentInfo memory componentInfo = pool.getComponentInfo();
         | 
| 129 | 
            +
                    componentInfo.tokenHandler = new TokenHandler(address(componentInfo.token));
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                    // save amended component info with instance
         | 
| 132 | 
            +
                    instance.createPoolSetup(poolNftId, componentInfo);
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                    bytes4[][] memory selectors = new bytes4[][](2);
         | 
| 135 | 
            +
                    selectors[0] = new bytes4[](1);
         | 
| 136 | 
            +
                    selectors[1] = new bytes4[](1);
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                    selectors[0][0] = IPoolComponent.setFees.selector;
         | 
| 139 | 
            +
                    selectors[1][0] = IPoolComponent.verifyApplication.selector;
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                    RoleId[] memory roles = new RoleId[](2);
         | 
| 142 | 
            +
                    roles[0] = POOL_OWNER_ROLE();
         | 
| 143 | 
            +
                    roles[1] = POLICY_SERVICE_ROLE();
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                    getInstanceService().createGifTarget(
         | 
| 146 | 
            +
                        instanceNftId, 
         | 
| 147 | 
            +
                        poolAddress, 
         | 
| 148 | 
            +
                        pool.getName(), 
         | 
| 149 | 
            +
                        selectors, 
         | 
| 150 | 
            +
                        roles);
         | 
| 151 | 
            +
                }
         | 
| 152 | 
            +
             | 
| 153 | 
            +
             | 
| 154 | 
            +
                function setMaxCapitalAmount(uint256 maxCapitalAmount)
         | 
| 155 | 
            +
                    external
         | 
| 156 | 
            +
                    virtual
         | 
| 157 | 
            +
                {
         | 
| 158 | 
            +
                    (IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
         | 
| 159 | 
            +
                    InstanceReader instanceReader = instance.getInstanceReader();
         | 
| 160 | 
            +
                    NftId poolNftId = registryInfo.nftId;
         | 
| 161 | 
            +
             | 
| 162 | 
            +
                    IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
         | 
| 163 | 
            +
                    IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
         | 
| 164 | 
            +
                    uint256 previousMaxCapitalAmount = poolInfo.maxCapitalAmount;
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                    poolInfo.maxCapitalAmount = maxCapitalAmount;
         | 
| 167 | 
            +
                    componentInfo.data = abi.encode(poolInfo);
         | 
| 168 | 
            +
                    instance.updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                    emit LogPoolServiceMaxCapitalAmountUpdated(poolNftId, previousMaxCapitalAmount, maxCapitalAmount);
         | 
| 88 171 | 
             
                }
         | 
| 89 172 |  | 
| 173 | 
            +
                function setBundleOwnerRole(RoleId bundleOwnerRole)
         | 
| 174 | 
            +
                    external
         | 
| 175 | 
            +
                    virtual
         | 
| 176 | 
            +
                {
         | 
| 177 | 
            +
                    (IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
         | 
| 178 | 
            +
                    InstanceReader instanceReader = instance.getInstanceReader();
         | 
| 179 | 
            +
                    NftId poolNftId = registryInfo.nftId;
         | 
| 180 | 
            +
             | 
| 181 | 
            +
                    IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
         | 
| 182 | 
            +
                    IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
         | 
| 183 | 
            +
             | 
| 184 | 
            +
                    // bundle owner role may only be set once per pool
         | 
| 185 | 
            +
                    if(poolInfo.bundleOwnerRole != PUBLIC_ROLE()) {
         | 
| 186 | 
            +
                        revert ErrorPoolServiceBundleOwnerRoleAlreadySet(poolNftId);
         | 
| 187 | 
            +
                    }
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                    poolInfo.bundleOwnerRole = bundleOwnerRole;
         | 
| 190 | 
            +
                    componentInfo.data = abi.encode(poolInfo);
         | 
| 191 | 
            +
                    instance.updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                    emit LogPoolServiceBundleOwnerRoleSet(poolNftId, bundleOwnerRole);
         | 
| 194 | 
            +
                }
         | 
| 195 | 
            +
             | 
| 196 | 
            +
             | 
| 90 197 | 
             
                function setFees(
         | 
| 91 198 | 
             
                    Fee memory poolFee,
         | 
| 92 199 | 
             
                    Fee memory stakingFee,
         | 
| 93 200 | 
             
                    Fee memory performanceFee
         | 
| 94 201 | 
             
                )
         | 
| 95 202 | 
             
                    external
         | 
| 96 | 
            -
                     | 
| 203 | 
            +
                    virtual
         | 
| 97 204 | 
             
                {
         | 
| 98 | 
            -
                    (IRegistry.ObjectInfo memory  | 
| 205 | 
            +
                    (IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
         | 
| 99 206 | 
             
                    InstanceReader instanceReader = instance.getInstanceReader();
         | 
| 100 | 
            -
                    NftId poolNftId =  | 
| 101 | 
            -
             | 
| 102 | 
            -
                     | 
| 103 | 
            -
                     | 
| 104 | 
            -
             | 
| 105 | 
            -
                     | 
| 106 | 
            -
                    
         | 
| 107 | 
            -
                     | 
| 207 | 
            +
                    NftId poolNftId = registryInfo.nftId;
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                    IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
         | 
| 210 | 
            +
                    IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                    poolInfo.poolFee = poolFee;
         | 
| 213 | 
            +
                    poolInfo.stakingFee = stakingFee;
         | 
| 214 | 
            +
                    poolInfo.performanceFee = performanceFee;
         | 
| 215 | 
            +
                    componentInfo.data = abi.encode(poolInfo);
         | 
| 216 | 
            +
                    instance.updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                    // TODO add logging
         | 
| 108 219 | 
             
                }
         | 
| 109 220 | 
             
            }
         | 
| @@ -113,12 +113,20 @@ contract ProductService is ComponentService, IProductService { | |
| 113 113 | 
             
                    // create product setup in instance
         | 
| 114 114 | 
             
                    instance.createProductSetup(productNftId, product.getSetupInfo());
         | 
| 115 115 |  | 
| 116 | 
            +
                    bytes4[][] memory selectors = new bytes4[][](1);
         | 
| 117 | 
            +
                    selectors[0] = new bytes4[](1);
         | 
| 118 | 
            +
                    selectors[0][0] = IProductComponent.setFees.selector;
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                    RoleId[] memory roles = new RoleId[](1);
         | 
| 121 | 
            +
                    roles[0] = PRODUCT_OWNER_ROLE();
         | 
| 122 | 
            +
             | 
| 116 123 | 
             
                    // create target for instane access manager
         | 
| 117 124 | 
             
                    getInstanceService().createGifTarget(
         | 
| 118 125 | 
             
                        getRegistry().getNftId(address(instance)), 
         | 
| 119 126 | 
             
                        address(product), 
         | 
| 120 | 
            -
                        product.getName() | 
| 121 | 
            -
             | 
| 127 | 
            +
                        product.getName(),
         | 
| 128 | 
            +
                        selectors,
         | 
| 129 | 
            +
                        roles);
         | 
| 122 130 | 
             
                }
         | 
| 123 131 |  | 
| 124 132 | 
             
                function getDomain() public pure override(IService, Service) returns(ObjectType) {
         | 
| @@ -95,6 +95,10 @@ contract ChainNft is ERC721Enumerable { | |
| 95 95 |  | 
| 96 96 | 
             
                    _totalMinted++;
         | 
| 97 97 | 
             
                    _safeMint(to, tokenId);
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                    if(interceptor != address(0)) {
         | 
| 100 | 
            +
                        ITransferInterceptor(interceptor).nftMint(to, tokenId);
         | 
| 101 | 
            +
                    }
         | 
| 98 102 | 
             
                }
         | 
| 99 103 |  | 
| 100 104 |  | 
| @@ -195,6 +199,10 @@ contract ChainNft is ERC721Enumerable { | |
| 195 199 | 
             
                        _chainIdDigits;
         | 
| 196 200 | 
             
                }
         | 
| 197 201 |  | 
| 202 | 
            +
                function getNextTokenId() external view returns (uint256) {
         | 
| 203 | 
            +
                    return calculateTokenId(_idNext);
         | 
| 204 | 
            +
                }
         | 
| 205 | 
            +
             | 
| 198 206 | 
             
                function _getNextTokenId() private returns (uint256 id) {
         | 
| 199 207 | 
             
                    id = calculateTokenId(_idNext);
         | 
| 200 208 | 
             
                    _idNext++;
         | 
| @@ -84,6 +84,8 @@ interface IRegistry is IERC165 { | |
| 84 84 |  | 
| 85 85 | 
             
                function isRegisteredService(address contractAddress) external view returns (bool);
         | 
| 86 86 |  | 
| 87 | 
            +
                function isRegisteredComponent(address object) external view returns (bool);
         | 
| 88 | 
            +
             | 
| 87 89 | 
             
                function isValidRelease(VersionPart version) external view returns (bool);
         | 
| 88 90 |  | 
| 89 91 | 
             
                function getServiceAddress(
         |