@etherisc/gif-next 0.0.2-ebbe63d → 0.0.2-ecbd488-936
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 +390 -2
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +327 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +618 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +280 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +152 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +249 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +157 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/components/Pool.sol/Pool.json +782 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +719 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.json +105 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +105 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/A.json +128 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +42 -0
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/B.sol/B.json +76 -0
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/C.sol/C.json +89 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +128 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +37 -0
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.json +50 -0
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +63 -0
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +4 -0
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +10 -0
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +4 -0
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +10 -0
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +101 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +1132 -0
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +1082 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1014 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +4 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.json +3552 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +917 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1388 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +931 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +508 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +540 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +429 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +502 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +211 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.json +10 -0
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.json +10 -0
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.json +10 -0
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.json +10 -0
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.json +10 -0
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.json +10 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +716 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +444 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +739 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +839 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +448 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1046 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +448 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +4 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +771 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +626 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +947 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +4 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.json +809 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1293 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +513 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +201 -0
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/shared/IService.sol/IService.json +421 -0
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +274 -0
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/shared/Service.sol/Service.json +468 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +305 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
- package/artifacts/contracts/test/TestService.sol/TestService.json +600 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +376 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +286 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.json +376 -0
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +10 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +125 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +153 -0
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -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 +4 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +249 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +479 -0
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +49 -0
- package/contracts/components/BaseComponent.sol +91 -0
- package/contracts/components/Distribution.sol +159 -0
- package/contracts/components/IBaseComponent.sol +25 -0
- package/contracts/components/IDistributionComponent.sol +44 -0
- package/contracts/components/IPoolComponent.sol +62 -0
- package/contracts/components/IProductComponent.sol +35 -0
- package/contracts/components/Pool.sol +242 -0
- package/contracts/components/Product.sol +284 -0
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/experiment/errors/Require.sol +38 -0
- package/contracts/experiment/errors/Revert.sol +44 -0
- package/contracts/experiment/inheritance/A.sol +53 -0
- package/contracts/experiment/inheritance/B.sol +28 -0
- package/contracts/experiment/inheritance/C.sol +34 -0
- package/contracts/experiment/inheritance/IA.sol +13 -0
- package/contracts/experiment/inheritance/IB.sol +10 -0
- package/contracts/experiment/inheritance/IC.sol +12 -0
- package/contracts/experiment/statemachine/Dummy.sol +27 -0
- package/contracts/experiment/statemachine/ISM.sol +25 -0
- package/contracts/experiment/statemachine/SM.sol +57 -0
- package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
- package/contracts/experiment/types/TypeA.sol +47 -0
- package/contracts/experiment/types/TypeB.sol +29 -0
- package/contracts/instance/AccessManagedSimple.sol +115 -0
- package/contracts/instance/AccessManagerSimple.sol +692 -0
- package/contracts/instance/IAccessManagerSimple.sol +391 -0
- package/contracts/instance/IInstance.sol +48 -0
- package/contracts/instance/IInstanceService.sol +30 -0
- package/contracts/instance/Instance.sol +443 -0
- package/contracts/instance/InstanceAccessManager.sol +288 -0
- package/contracts/instance/InstanceReader.sol +306 -0
- package/contracts/instance/InstanceService.sol +195 -0
- package/contracts/instance/InstanceServiceManager.sol +57 -0
- package/contracts/instance/base/ComponentServiceBase.sol +124 -0
- package/contracts/instance/base/IInstanceBase.sol +23 -0
- package/contracts/instance/base/IKeyValueStore.sol +49 -0
- package/contracts/instance/base/ILifecycle.sol +30 -0
- package/contracts/instance/base/KeyValueStore.sol +172 -0
- package/contracts/instance/base/Lifecycle.sol +100 -0
- package/contracts/instance/module/IAccess.sol +38 -0
- package/contracts/instance/module/IBundle.sol +20 -0
- package/contracts/instance/module/IDistribution.sol +39 -0
- package/contracts/instance/module/IPolicy.sol +45 -0
- package/contracts/instance/module/IRisk.sol +11 -0
- package/contracts/instance/module/ISetup.sol +44 -0
- package/contracts/instance/module/ITreasury.sol +23 -0
- package/contracts/instance/service/ComponentOwnerService.sol +317 -0
- package/contracts/instance/service/DistributionService.sol +88 -0
- package/contracts/instance/service/DistributionServiceManager.sol +54 -0
- package/contracts/instance/service/IComponentOwnerService.sol +20 -0
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +37 -0
- package/contracts/instance/service/IProductService.sol +107 -0
- package/contracts/instance/service/PoolService.sol +194 -0
- package/contracts/instance/service/PoolServiceManager.sol +54 -0
- package/contracts/instance/service/ProductService.sol +543 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +202 -0
- package/contracts/registry/IRegistry.sol +79 -0
- package/contracts/registry/IRegistryService.sol +50 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +444 -0
- package/contracts/registry/RegistryService.sol +358 -0
- package/contracts/registry/RegistryServiceManager.sol +80 -0
- package/contracts/registry/TokenRegistry.sol +111 -0
- package/contracts/shared/ContractDeployerLib.sol +72 -0
- package/contracts/shared/ERC165.sol +25 -0
- package/contracts/shared/INftOwnable.sol +22 -0
- package/contracts/shared/IRegisterable.sol +17 -0
- package/contracts/shared/IService.sol +15 -0
- package/contracts/shared/IVersionable.sol +96 -0
- package/contracts/shared/NftOwnable.sol +134 -0
- package/contracts/shared/ProxyManager.sol +94 -0
- package/contracts/shared/Registerable.sol +90 -0
- package/contracts/shared/RegisterableUpgradable.sol +16 -0
- package/contracts/shared/Service.sol +55 -0
- package/contracts/shared/TokenHandler.sol +27 -0
- package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
- package/contracts/shared/Versionable.sol +147 -0
- package/contracts/test/TestFee.sol +25 -0
- package/contracts/test/TestRegisterable.sol +18 -0
- package/contracts/test/TestRoleId.sol +14 -0
- package/contracts/test/TestService.sol +24 -0
- package/contracts/{Dip.sol → test/TestToken.sol} +5 -5
- package/contracts/test/TestVersion.sol +44 -0
- package/contracts/test/TestVersionable.sol +17 -0
- package/contracts/test/Usdc.sol +26 -0
- package/contracts/types/AddressSet.sol +58 -0
- package/contracts/types/Blocknumber.sol +118 -0
- package/contracts/types/ChainId.sol +38 -0
- package/contracts/types/DistributorType.sol +55 -0
- package/contracts/types/Fee.sol +56 -0
- package/contracts/types/Key32.sol +50 -0
- package/contracts/types/NftId.sol +72 -0
- package/contracts/types/NftIdSet.sol +60 -0
- package/contracts/types/NumberId.sol +52 -0
- package/contracts/types/ObjectType.sol +152 -0
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RiskId.sol +43 -0
- package/contracts/types/RoleId.sol +90 -0
- package/contracts/types/StateId.sol +105 -0
- package/contracts/types/Timestamp.sol +127 -0
- package/contracts/types/UFixed.sol +325 -0
- package/contracts/types/Version.sol +107 -0
- package/package.json +26 -10
- package/artifacts/contracts/Dip.sol/DIP.dbg.json +0 -4
- package/artifacts/contracts/Dip.sol/DIP.json +0 -338
- package/artifacts/contracts/Lock.sol/Lock.dbg.json +0 -4
- package/artifacts/contracts/Lock.sol/Lock.json +0 -74
- package/contracts/Lock.sol +0 -34
@@ -0,0 +1,543 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IProductComponent} from "../../components/IProductComponent.sol";
|
6
|
+
import {Product} from "../../components/Product.sol";
|
7
|
+
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
8
|
+
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
9
|
+
import {IInstance} from "../IInstance.sol";
|
10
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
11
|
+
import {IRisk} from "../module/IRisk.sol";
|
12
|
+
import {IBundle} from "../module/IBundle.sol";
|
13
|
+
import {IProductService} from "./IProductService.sol";
|
14
|
+
import {ITreasury} from "../module/ITreasury.sol";
|
15
|
+
import {ISetup} from "../module/ISetup.sol";
|
16
|
+
|
17
|
+
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
18
|
+
|
19
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
20
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
21
|
+
|
22
|
+
import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
|
23
|
+
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
24
|
+
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
25
|
+
import {ObjectType, INSTANCE, PRODUCT, POLICY} from "../../types/ObjectType.sol";
|
26
|
+
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
|
27
|
+
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
28
|
+
import {Fee, FeeLib} from "../../types/Fee.sol";
|
29
|
+
import {ReferralId} from "../../types/Referral.sol";
|
30
|
+
import {RiskId} from "../../types/RiskId.sol";
|
31
|
+
import {StateId} from "../../types/StateId.sol";
|
32
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
33
|
+
|
34
|
+
import {IService} from "../../shared/IService.sol";
|
35
|
+
import {Service} from "../../shared/Service.sol";
|
36
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
37
|
+
import {IProductService} from "./IProductService.sol";
|
38
|
+
import {InstanceReader} from "../InstanceReader.sol";
|
39
|
+
|
40
|
+
string constant PRODUCT_SERVICE_NAME = "ProductService";
|
41
|
+
|
42
|
+
// TODO or name this ProtectionService to have Product be something more generic (loan, savings account, ...)
|
43
|
+
contract ProductService is ComponentServiceBase, IProductService {
|
44
|
+
using NftIdLib for NftId;
|
45
|
+
|
46
|
+
string public constant NAME = "ProductService";
|
47
|
+
|
48
|
+
address internal _registryAddress;
|
49
|
+
|
50
|
+
event LogProductServiceSender(address sender);
|
51
|
+
|
52
|
+
function _initialize(
|
53
|
+
address owner,
|
54
|
+
bytes memory data
|
55
|
+
)
|
56
|
+
internal
|
57
|
+
initializer
|
58
|
+
virtual override
|
59
|
+
{
|
60
|
+
address initialOwner = address(0);
|
61
|
+
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
62
|
+
|
63
|
+
_initializeService(_registryAddress, owner);
|
64
|
+
|
65
|
+
_registerInterface(type(IService).interfaceId);
|
66
|
+
_registerInterface(type(IProductService).interfaceId);
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
function getName() public pure override(IService, Service) returns(string memory name) {
|
71
|
+
return NAME;
|
72
|
+
}
|
73
|
+
|
74
|
+
function _finalizeComponentRegistration(NftId componentNftId, bytes memory initialObjData, IInstance instance) internal override {
|
75
|
+
ISetup.ProductSetupInfo memory initialSetup = abi.decode(
|
76
|
+
initialObjData,
|
77
|
+
(ISetup.ProductSetupInfo)
|
78
|
+
);
|
79
|
+
instance.createProductSetup(componentNftId, initialSetup);
|
80
|
+
}
|
81
|
+
|
82
|
+
function setFees(
|
83
|
+
Fee memory productFee,
|
84
|
+
Fee memory processingFee
|
85
|
+
)
|
86
|
+
external
|
87
|
+
override
|
88
|
+
{
|
89
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
90
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
91
|
+
NftId productNftId = productInfo.nftId;
|
92
|
+
|
93
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
|
94
|
+
productSetupInfo.productFee = productFee;
|
95
|
+
productSetupInfo.processingFee = processingFee;
|
96
|
+
|
97
|
+
instance.updateProductSetup(productNftId, productSetupInfo, KEEP_STATE());
|
98
|
+
}
|
99
|
+
|
100
|
+
// FIXME: this
|
101
|
+
function createRisk(
|
102
|
+
RiskId riskId,
|
103
|
+
bytes memory data
|
104
|
+
) external override {
|
105
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
106
|
+
NftId productNftId = productInfo.nftId;
|
107
|
+
IRisk.RiskInfo memory riskInfo = IRisk.RiskInfo(productNftId, data);
|
108
|
+
instance.createRisk(
|
109
|
+
riskId,
|
110
|
+
riskInfo
|
111
|
+
);
|
112
|
+
}
|
113
|
+
|
114
|
+
function updateRisk(
|
115
|
+
RiskId riskId,
|
116
|
+
bytes memory data
|
117
|
+
) external {
|
118
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
119
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
120
|
+
IRisk.RiskInfo memory riskInfo = instanceReader.getRiskInfo(riskId);
|
121
|
+
riskInfo.data = data;
|
122
|
+
instance.updateRisk(riskId, riskInfo, KEEP_STATE());
|
123
|
+
}
|
124
|
+
|
125
|
+
function updateRiskState(
|
126
|
+
RiskId riskId,
|
127
|
+
StateId state
|
128
|
+
) external {
|
129
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
130
|
+
instance.updateRiskState(riskId, state);
|
131
|
+
}
|
132
|
+
|
133
|
+
function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
|
134
|
+
IRegistry.ObjectInfo memory productInfo;
|
135
|
+
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
136
|
+
product = Product(productInfo.objectAddress);
|
137
|
+
}
|
138
|
+
|
139
|
+
function calculatePremium(
|
140
|
+
RiskId riskId,
|
141
|
+
uint256 sumInsuredAmount,
|
142
|
+
uint256 lifetime,
|
143
|
+
bytes memory applicationData,
|
144
|
+
NftId bundleNftId,
|
145
|
+
ReferralId referralId
|
146
|
+
)
|
147
|
+
public
|
148
|
+
view
|
149
|
+
override
|
150
|
+
returns (
|
151
|
+
uint256 premiumAmount,
|
152
|
+
uint256 productFeeAmount,
|
153
|
+
uint256 poolFeeAmount,
|
154
|
+
uint256 bundleFeeAmount,
|
155
|
+
uint256 distributionFeeAmount
|
156
|
+
)
|
157
|
+
{
|
158
|
+
Product product = _getAndVerifyInstanceAndProduct();
|
159
|
+
uint256 netPremiumAmount = product.calculateNetPremium(
|
160
|
+
sumInsuredAmount,
|
161
|
+
riskId,
|
162
|
+
lifetime,
|
163
|
+
applicationData
|
164
|
+
);
|
165
|
+
|
166
|
+
(
|
167
|
+
productFeeAmount,
|
168
|
+
poolFeeAmount,
|
169
|
+
bundleFeeAmount,
|
170
|
+
distributionFeeAmount
|
171
|
+
) = _calculateFeeAmounts(
|
172
|
+
netPremiumAmount,
|
173
|
+
product,
|
174
|
+
bundleNftId,
|
175
|
+
referralId
|
176
|
+
);
|
177
|
+
|
178
|
+
premiumAmount = netPremiumAmount + productFeeAmount;
|
179
|
+
premiumAmount += poolFeeAmount + bundleFeeAmount;
|
180
|
+
premiumAmount += distributionFeeAmount;
|
181
|
+
}
|
182
|
+
|
183
|
+
function _calculateFeeAmounts(
|
184
|
+
uint256 netPremiumAmount,
|
185
|
+
Product product,
|
186
|
+
NftId bundleNftId,
|
187
|
+
ReferralId referralId
|
188
|
+
)
|
189
|
+
internal
|
190
|
+
view
|
191
|
+
returns (
|
192
|
+
uint256 productFeeAmount,
|
193
|
+
uint256 poolFeeAmount,
|
194
|
+
uint256 bundleFeeAmount,
|
195
|
+
uint256 distributionFeeAmount
|
196
|
+
)
|
197
|
+
{
|
198
|
+
IInstance instance = product.getInstance();
|
199
|
+
// FIXME: this
|
200
|
+
// ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(product.getNftId());
|
201
|
+
// IBundle.BundleInfo memory bundleInfo = instance.getBundleInfo(bundleNftId);
|
202
|
+
// require(bundleInfo.poolNftId == treasuryInfo.poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
|
203
|
+
|
204
|
+
// (productFeeAmount,) = FeeLib.calculateFee(treasuryInfo.productFee, netPremiumAmount);
|
205
|
+
// (poolFeeAmount,) = FeeLib.calculateFee(treasuryInfo.poolFee, netPremiumAmount);
|
206
|
+
// (bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
|
207
|
+
|
208
|
+
// IRegistry.ObjectInfo memory distributionInfo = getRegistry().getObjectInfo(treasuryInfo.distributionNftId);
|
209
|
+
// IDistributionComponent distribution = IDistributionComponent(distributionInfo.objectAddress);
|
210
|
+
// distributionFeeAmount = distribution.calculateFeeAmount(referralId, netPremiumAmount);
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
function createApplication(
|
215
|
+
address applicationOwner,
|
216
|
+
RiskId riskId,
|
217
|
+
uint256 sumInsuredAmount,
|
218
|
+
uint256 lifetime,
|
219
|
+
bytes memory applicationData,
|
220
|
+
NftId bundleNftId,
|
221
|
+
ReferralId referralId
|
222
|
+
) external override returns (NftId policyNftId) {
|
223
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
224
|
+
// TODO add validations (see create bundle in pool service)
|
225
|
+
|
226
|
+
policyNftId = getRegistryService().registerPolicy(
|
227
|
+
IRegistry.ObjectInfo(
|
228
|
+
zeroNftId(),
|
229
|
+
productInfo.nftId,
|
230
|
+
POLICY(),
|
231
|
+
false, // intercepting property for policies is defined on product
|
232
|
+
address(0),
|
233
|
+
applicationOwner,
|
234
|
+
""
|
235
|
+
)
|
236
|
+
);
|
237
|
+
|
238
|
+
(uint256 premiumAmount,,,,) = calculatePremium(
|
239
|
+
riskId,
|
240
|
+
sumInsuredAmount,
|
241
|
+
lifetime,
|
242
|
+
applicationData,
|
243
|
+
bundleNftId,
|
244
|
+
referralId
|
245
|
+
);
|
246
|
+
|
247
|
+
// FIXME: this
|
248
|
+
// instance.createPolicyInfo(
|
249
|
+
// policyNftId,
|
250
|
+
// productInfo.nftId,
|
251
|
+
// referralId,
|
252
|
+
// riskId,
|
253
|
+
// sumInsuredAmount,
|
254
|
+
// premiumAmount,
|
255
|
+
// lifetime,
|
256
|
+
// bundleNftId
|
257
|
+
// );
|
258
|
+
|
259
|
+
// TODO add logging
|
260
|
+
}
|
261
|
+
|
262
|
+
function _getAndVerifyUnderwritingSetup(
|
263
|
+
IInstance instance,
|
264
|
+
IPolicy.PolicyInfo memory policyInfo
|
265
|
+
)
|
266
|
+
internal
|
267
|
+
view
|
268
|
+
returns (
|
269
|
+
ITreasury.TreasuryInfo memory treasuryInfo,
|
270
|
+
NftId bundleNftId,
|
271
|
+
IBundle.BundleInfo memory bundleInfo,
|
272
|
+
uint256 collateralAmount
|
273
|
+
)
|
274
|
+
{
|
275
|
+
// FIXME: this
|
276
|
+
// check match between policy and bundle (via pool)
|
277
|
+
// treasuryInfo = instance.getTreasuryInfo(policyInfo.productNftId);
|
278
|
+
// bundleNftId = policyInfo.bundleNftId;
|
279
|
+
// bundleInfo = instance.getBundleInfo(bundleNftId);
|
280
|
+
// require(bundleInfo.poolNftId == treasuryInfo.poolNftId, "POLICY_BUNDLE_MISMATCH");
|
281
|
+
|
282
|
+
// // calculate required collateral
|
283
|
+
// NftId poolNftId = treasuryInfo.poolNftId;
|
284
|
+
// ISetup.PoolSetupInfo memory poolInfo = instance.getPoolInfo(poolNftId);
|
285
|
+
|
286
|
+
// // obtain remaining return values
|
287
|
+
// collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
288
|
+
}
|
289
|
+
|
290
|
+
function _lockCollateralInBundle(
|
291
|
+
IInstance instance,
|
292
|
+
NftId bundleNftId,
|
293
|
+
IBundle.BundleInfo memory bundleInfo,
|
294
|
+
NftId policyNftId,
|
295
|
+
uint256 collateralAmount
|
296
|
+
)
|
297
|
+
internal
|
298
|
+
returns (IBundle.BundleInfo memory)
|
299
|
+
{
|
300
|
+
bundleInfo.lockedAmount += collateralAmount;
|
301
|
+
// FIXME: this
|
302
|
+
// instance.collateralizePolicy(bundleNftId, policyNftId, collateralAmount);
|
303
|
+
return bundleInfo;
|
304
|
+
}
|
305
|
+
|
306
|
+
function _underwriteByPool(
|
307
|
+
ITreasury.TreasuryInfo memory treasuryInfo,
|
308
|
+
NftId policyNftId,
|
309
|
+
IPolicy.PolicyInfo memory policyInfo,
|
310
|
+
bytes memory bundleFilter,
|
311
|
+
uint256 collateralAmount
|
312
|
+
)
|
313
|
+
internal
|
314
|
+
{
|
315
|
+
address poolAddress = getRegistry().getObjectInfo(treasuryInfo.poolNftId).objectAddress;
|
316
|
+
IPoolComponent pool = IPoolComponent(poolAddress);
|
317
|
+
pool.underwrite(
|
318
|
+
policyNftId,
|
319
|
+
policyInfo.applicationData,
|
320
|
+
bundleFilter,
|
321
|
+
collateralAmount);
|
322
|
+
}
|
323
|
+
|
324
|
+
|
325
|
+
function revoke(
|
326
|
+
NftId policyNftId
|
327
|
+
)
|
328
|
+
external
|
329
|
+
override
|
330
|
+
{
|
331
|
+
require(false, "ERROR:PRS-234:NOT_YET_IMPLEMENTED");
|
332
|
+
}
|
333
|
+
|
334
|
+
|
335
|
+
function underwrite(
|
336
|
+
NftId policyNftId,
|
337
|
+
bool requirePremiumPayment,
|
338
|
+
Timestamp activateAt
|
339
|
+
)
|
340
|
+
external
|
341
|
+
override
|
342
|
+
{
|
343
|
+
// check caller is registered product
|
344
|
+
(
|
345
|
+
IRegistry.ObjectInfo memory productInfo,
|
346
|
+
IInstance instance
|
347
|
+
) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
348
|
+
|
349
|
+
// check match between policy and calling product
|
350
|
+
NftId productNftId = productInfo.nftId;
|
351
|
+
// FIXME: this
|
352
|
+
// IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
|
353
|
+
// require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
354
|
+
// require(instance.getState(policyNftId.toKey32(POLICY())) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
355
|
+
|
356
|
+
// ITreasury.TreasuryInfo memory treasuryInfo;
|
357
|
+
// NftId bundleNftId;
|
358
|
+
// IBundle.BundleInfo memory bundleInfo;
|
359
|
+
// uint256 collateralAmount;
|
360
|
+
|
361
|
+
// (
|
362
|
+
// treasuryInfo,
|
363
|
+
// bundleNftId,
|
364
|
+
// bundleInfo,
|
365
|
+
// collateralAmount
|
366
|
+
// ) = _getAndVerifyUnderwritingSetup(
|
367
|
+
// instance,
|
368
|
+
// policyInfo
|
369
|
+
// );
|
370
|
+
|
371
|
+
// // lock bundle collateral
|
372
|
+
// bundleInfo = _lockCollateralInBundle(
|
373
|
+
// instance,
|
374
|
+
// bundleNftId,
|
375
|
+
// bundleInfo,
|
376
|
+
// policyNftId,
|
377
|
+
// collateralAmount);
|
378
|
+
|
379
|
+
// // set policy state to underwritten
|
380
|
+
// instance.updatePolicyState(policyNftId, UNDERWRITTEN());
|
381
|
+
|
382
|
+
// // optional activation of policy
|
383
|
+
// if(activateAt > zeroTimestamp()) {
|
384
|
+
// policyInfo.activatedAt = activateAt;
|
385
|
+
// policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
386
|
+
|
387
|
+
// instance.updatePolicyState(policyNftId, ACTIVE());
|
388
|
+
// }
|
389
|
+
|
390
|
+
// // optional collection of premium
|
391
|
+
// if(requirePremiumPayment) {
|
392
|
+
// uint256 netPremiumAmount = _processPremiumByTreasury(
|
393
|
+
// instance,
|
394
|
+
// productInfo.nftId,
|
395
|
+
// treasuryInfo,
|
396
|
+
// policyNftId,
|
397
|
+
// policyInfo.premiumAmount);
|
398
|
+
|
399
|
+
// policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
|
400
|
+
// bundleInfo.balanceAmount += netPremiumAmount;
|
401
|
+
// }
|
402
|
+
|
403
|
+
// instance.setPolicyInfo(policyNftId, policyInfo);
|
404
|
+
// instance.setBundleInfo(bundleNftId, bundleInfo);
|
405
|
+
|
406
|
+
// // involve pool if necessary
|
407
|
+
// {
|
408
|
+
// NftId poolNftId = treasuryInfo.poolNftId;
|
409
|
+
// ISetup.PoolSetupInfo memory poolInfo = instance.getPoolInfo(poolNftId);
|
410
|
+
|
411
|
+
// if(poolInfo.isVerifying) {
|
412
|
+
// _underwriteByPool(
|
413
|
+
// treasuryInfo,
|
414
|
+
// policyNftId,
|
415
|
+
// policyInfo,
|
416
|
+
// bundleInfo.filter,
|
417
|
+
// collateralAmount
|
418
|
+
// );
|
419
|
+
// }
|
420
|
+
// }
|
421
|
+
|
422
|
+
// TODO add logging
|
423
|
+
}
|
424
|
+
|
425
|
+
function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
|
426
|
+
UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
|
427
|
+
UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
|
428
|
+
return collateralUFixed.toInt();
|
429
|
+
}
|
430
|
+
|
431
|
+
function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
|
432
|
+
// check caller is registered product
|
433
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
434
|
+
|
435
|
+
// perform actual token transfers
|
436
|
+
// FIXME: this
|
437
|
+
// IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
|
438
|
+
// ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productInfo.nftId);
|
439
|
+
|
440
|
+
// uint256 premiumAmount = policyInfo.premiumAmount;
|
441
|
+
// _processPremiumByTreasury(instance, productInfo.nftId, treasuryInfo, policyNftId, premiumAmount);
|
442
|
+
|
443
|
+
// // policy level book keeping for premium paid
|
444
|
+
// policyInfo.premiumPaidAmount += premiumAmount;
|
445
|
+
|
446
|
+
// // optional activation of policy
|
447
|
+
// if(activateAt > zeroTimestamp()) {
|
448
|
+
// require(
|
449
|
+
// policyInfo.activatedAt.eqz(),
|
450
|
+
// "ERROR:PRS-030:ALREADY_ACTIVATED");
|
451
|
+
|
452
|
+
// policyInfo.activatedAt = activateAt;
|
453
|
+
// policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
454
|
+
|
455
|
+
// instance.updatePolicyState(policyNftId, ACTIVE());
|
456
|
+
// }
|
457
|
+
|
458
|
+
// instance.setPolicyInfo(policyNftId, policyInfo);
|
459
|
+
|
460
|
+
// TODO add logging
|
461
|
+
}
|
462
|
+
|
463
|
+
// FIXME: this
|
464
|
+
function activate(NftId policyNftId, Timestamp activateAt) external override {
|
465
|
+
// check caller is registered product
|
466
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
467
|
+
|
468
|
+
// IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
|
469
|
+
|
470
|
+
// require(
|
471
|
+
// policyInfo.activatedAt.eqz(),
|
472
|
+
// "ERROR:PRS-020:ALREADY_ACTIVATED");
|
473
|
+
|
474
|
+
// policyInfo.activatedAt = activateAt;
|
475
|
+
// policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
476
|
+
|
477
|
+
// instance.setPolicyInfo(policyNftId, policyInfo);
|
478
|
+
// instance.updatePolicyState(policyNftId, ACTIVE());
|
479
|
+
|
480
|
+
// TODO add logging
|
481
|
+
}
|
482
|
+
|
483
|
+
function close(
|
484
|
+
NftId policyNftId
|
485
|
+
) external override // solhint-disable-next-line no-empty-blocks
|
486
|
+
{
|
487
|
+
|
488
|
+
}
|
489
|
+
|
490
|
+
function _getPoolNftId(
|
491
|
+
IInstance instance,
|
492
|
+
NftId productNftId
|
493
|
+
)
|
494
|
+
internal
|
495
|
+
view
|
496
|
+
returns (NftId poolNftid)
|
497
|
+
{
|
498
|
+
// FIXME: this
|
499
|
+
// return instance.getTreasuryInfo(productNftId).poolNftId;
|
500
|
+
}
|
501
|
+
|
502
|
+
|
503
|
+
function _processPremiumByTreasury(
|
504
|
+
IInstance instance,
|
505
|
+
NftId productNftId,
|
506
|
+
ITreasury.TreasuryInfo memory treasuryInfo,
|
507
|
+
NftId policyNftId,
|
508
|
+
uint256 premiumAmount
|
509
|
+
)
|
510
|
+
internal
|
511
|
+
returns (uint256 netPremiumAmount)
|
512
|
+
{
|
513
|
+
// process token transfer(s)
|
514
|
+
if(premiumAmount > 0) {
|
515
|
+
// FIXME: this
|
516
|
+
// TokenHandler tokenHandler = instance.getTokenHandler(productNftId);
|
517
|
+
// address policyOwner = getRegistry().ownerOf(policyNftId);
|
518
|
+
// address poolWallet = instance.getComponentWallet(treasuryInfo.poolNftId);
|
519
|
+
// netPremiumAmount = premiumAmount;
|
520
|
+
// Fee memory productFee = treasuryInfo.productFee;
|
521
|
+
|
522
|
+
// if (FeeLib.feeIsZero(productFee)) {
|
523
|
+
// tokenHandler.transfer(
|
524
|
+
// policyOwner,
|
525
|
+
// poolWallet,
|
526
|
+
// premiumAmount
|
527
|
+
// );
|
528
|
+
// } else {
|
529
|
+
// (uint256 feeAmount, uint256 netAmount) = instance.calculateFeeAmount(
|
530
|
+
// premiumAmount,
|
531
|
+
// productFee
|
532
|
+
// );
|
533
|
+
|
534
|
+
// address productWallet = instance.getComponentWallet(productNftId);
|
535
|
+
// tokenHandler.transfer(policyOwner, productWallet, feeAmount);
|
536
|
+
// tokenHandler.transfer(policyOwner, poolWallet, netAmount);
|
537
|
+
// netPremiumAmount = netAmount;
|
538
|
+
// }
|
539
|
+
}
|
540
|
+
|
541
|
+
// TODO add logging
|
542
|
+
}
|
543
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
5
|
+
import {ProxyManager} from "../../shared/ProxyManager.sol";
|
6
|
+
import {ProductService} from "./ProductService.sol";
|
7
|
+
import {Registry} from "../../registry/Registry.sol";
|
8
|
+
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
+
import {VersionLib} from "../../types/Version.sol";
|
10
|
+
|
11
|
+
contract ProductServiceManager is ProxyManager {
|
12
|
+
|
13
|
+
ProductService private _productService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with product service implementation
|
16
|
+
constructor(
|
17
|
+
address registryAddress
|
18
|
+
)
|
19
|
+
ProxyManager()
|
20
|
+
{
|
21
|
+
ProductService svc = new ProductService();
|
22
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
23
|
+
IVersionable versionable = deploy(
|
24
|
+
address(svc),
|
25
|
+
data);
|
26
|
+
|
27
|
+
_productService = ProductService(address(versionable));
|
28
|
+
|
29
|
+
// Registry registry = Registry(registryAddress);
|
30
|
+
// address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
31
|
+
// RegistryService registryService = RegistryService(registryServiceAddress);
|
32
|
+
// TODO this must have a role or own nft to register service
|
33
|
+
//registryService.registerService(_productService);
|
34
|
+
|
35
|
+
// TODO no nft to link yet
|
36
|
+
// link ownership of instance service manager ot nft owner of instance service
|
37
|
+
//_linkToNftOwnable(
|
38
|
+
// address(registryAddress),
|
39
|
+
// address(_productService));
|
40
|
+
|
41
|
+
// implies that after this constructor call only upgrade functionality is available
|
42
|
+
_isDeployed = true;
|
43
|
+
}
|
44
|
+
|
45
|
+
//--- view functions ----------------------------------------------------//
|
46
|
+
function getProductService()
|
47
|
+
external
|
48
|
+
view
|
49
|
+
returns (ProductService productService)
|
50
|
+
{
|
51
|
+
return _productService;
|
52
|
+
}
|
53
|
+
|
54
|
+
}
|