@etherisc/gif-next 0.0.2-d408403-475 → 0.0.2-d551b5e-892
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +231 -27
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +302 -23
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +393 -54
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +217 -23
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -188
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +15 -227
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +0 -213
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +460 -99
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +491 -80
- 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 +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/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 +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -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 +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +868 -1164
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +485 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +2421 -1250
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +940 -0
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1422 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +999 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +532 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +264 -43
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
- 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 +37 -245
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- 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/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{distribution/IDistribution.sol → IDistribution.sol}/IDistribution.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
- package/artifacts/contracts/instance/{base/ModuleBase.sol/ModuleBase.json → module/ISetup.sol/ISetup.json} +2 -2
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
- package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +375 -79
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +317 -53
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +428 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +177 -75
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +174 -53
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +664 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +337 -49
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +171 -263
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +984 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +464 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +527 -53
- 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 +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +290 -359
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +420 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +186 -12
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +377 -37
- 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 +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +487 -123
- 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 +517 -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 +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
- package/artifacts/contracts/{instance/module/component/ComponentModule.sol/ComponentModule.json → shared/INftOwnable.sol/INftOwnable.json} +67 -57
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +117 -37
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/InstanceBase.sol/InstanceBase.json → shared/IService.sol/IService.json} +168 -123
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +55 -14
- 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 +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +190 -37
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/IService.sol/IService.json → shared/RegisterableUpgradable.sol/RegisterableUpgradable.json} +215 -73
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/Service.sol/Service.json} +222 -54
- 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 +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +78 -14
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +204 -36
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +283 -62
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
- 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 +103 -23
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
- 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 +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- 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 +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 +134 -8
- 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 +15 -2
- 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/{UFixedMathLib.json → UFixedLib.json} +3 -3
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +40 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/BaseComponent.sol +75 -37
- package/contracts/components/Distribution.sol +49 -18
- package/contracts/components/IBaseComponent.sol +15 -3
- package/contracts/components/IDistributionComponent.sol +3 -7
- package/contracts/components/IPoolComponent.sol +7 -12
- package/contracts/components/IProductComponent.sol +4 -7
- package/contracts/components/Pool.sol +111 -79
- package/contracts/components/Product.sol +118 -53
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
- package/contracts/instance/BundleManager.sol +129 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IAccessManagerSimple.sol +391 -0
- package/contracts/instance/IInstance.sol +50 -45
- package/contracts/instance/IInstanceBase.sol +26 -0
- package/contracts/instance/IInstanceService.sol +32 -0
- package/contracts/instance/Instance.sol +443 -57
- package/contracts/instance/InstanceAccessManager.sol +288 -0
- package/contracts/instance/InstanceBase.sol +41 -0
- package/contracts/instance/InstanceReader.sol +315 -0
- package/contracts/instance/InstanceService.sol +252 -0
- package/contracts/instance/InstanceServiceManager.sol +57 -0
- package/contracts/instance/ObjectManager.sol +101 -0
- package/contracts/instance/base/ComponentServiceBase.sol +46 -16
- package/contracts/instance/base/IInstanceBase.sol +3 -2
- package/contracts/instance/base/IKeyValueStore.sol +13 -14
- package/contracts/instance/base/ILifecycle.sol +3 -3
- package/contracts/instance/base/KeyValueStore.sol +49 -38
- package/contracts/instance/base/Lifecycle.sol +1 -1
- 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 +46 -0
- package/contracts/instance/module/ITreasury.sol +23 -0
- package/contracts/instance/service/ComponentOwnerService.sol +232 -72
- package/contracts/instance/service/DistributionService.sol +78 -19
- package/contracts/instance/service/DistributionServiceManager.sol +54 -0
- package/contracts/instance/service/IComponentOwnerService.sol +1 -3
- package/contracts/instance/service/IDistributionService.sol +1 -1
- package/contracts/instance/service/IPolicyService.sol +87 -0
- package/contracts/instance/service/IPoolService.sol +17 -3
- package/contracts/instance/service/IProductService.sol +9 -76
- package/contracts/instance/service/PolicyService.sol +513 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +219 -51
- package/contracts/instance/service/PoolServiceManager.sol +54 -0
- package/contracts/instance/service/ProductService.sol +100 -436
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +80 -37
- package/contracts/registry/IRegistry.sol +49 -25
- package/contracts/registry/IRegistryService.sol +50 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +336 -270
- 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 +6 -2
- package/contracts/shared/INftOwnable.sol +22 -0
- package/contracts/shared/IRegisterable.sol +8 -15
- package/contracts/{instance/base → shared}/IService.sol +3 -3
- package/contracts/shared/IVersionable.sol +55 -11
- package/contracts/shared/NftOwnable.sol +134 -0
- package/contracts/shared/ProxyManager.sol +94 -0
- package/contracts/shared/Registerable.sol +63 -59
- 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 +113 -55
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestRegisterable.sol +5 -6
- package/contracts/test/TestRoleId.sol +1 -1
- package/contracts/test/TestService.sol +5 -13
- package/contracts/types/DistributorType.sol +55 -0
- package/contracts/types/Fee.sol +3 -3
- package/contracts/types/Key32.sol +8 -3
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/NumberId.sol +52 -0
- package/contracts/types/ObjectType.sol +35 -14
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RoleId.sol +62 -9
- package/contracts/types/StateId.sol +5 -1
- package/contracts/types/Timestamp.sol +7 -3
- package/contracts/types/UFixed.sol +128 -12
- package/contracts/types/Version.sol +13 -1
- package/package.json +4 -3
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -297
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -297
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +0 -117
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +0 -10
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +0 -4
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +0 -10
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -284
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -284
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -144
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -144
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -113
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -131
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -511
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -511
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -452
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -405
- package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -578
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -575
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/experiment/statemachine/README.md +0 -112
- package/contracts/instance/IInstanceLinked.sol +0 -8
- package/contracts/instance/base/InstanceBase.sol +0 -91
- package/contracts/instance/base/ModuleBase.sol +0 -57
- package/contracts/instance/base/ServiceBase.sol +0 -37
- package/contracts/instance/module/access/Access.sol +0 -149
- package/contracts/instance/module/access/IAccess.sol +0 -53
- package/contracts/instance/module/bundle/BundleModule.sol +0 -134
- package/contracts/instance/module/bundle/IBundle.sol +0 -53
- package/contracts/instance/module/component/ComponentModule.sol +0 -70
- package/contracts/instance/module/component/IComponent.sol +0 -28
- package/contracts/instance/module/distribution/DistributionModule.sol +0 -17
- package/contracts/instance/module/distribution/IDistribution.sol +0 -10
- package/contracts/instance/module/policy/IPolicy.sol +0 -63
- package/contracts/instance/module/policy/PolicyModule.sol +0 -91
- package/contracts/instance/module/pool/IPoolModule.sol +0 -40
- package/contracts/instance/module/pool/PoolModule.sol +0 -90
- package/contracts/instance/module/risk/IRisk.sol +0 -26
- package/contracts/instance/module/risk/RiskModule.sol +0 -62
- package/contracts/instance/module/treasury/ITreasury.sol +0 -82
- package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
- package/contracts/instance/module/treasury/TreasuryModule.sol +0 -138
- package/contracts/registry/IChainNft.sol +0 -21
- package/contracts/registry/IRegistryLinked.sol +0 -8
- package/contracts/shared/IOwnable.sol +0 -6
- package/contracts/test/TestDistribution.sol +0 -21
- package/contracts/test/TestPool.sol +0 -25
- package/contracts/test/TestProduct.sol +0 -72
- package/contracts/types/ReferralId.sol +0 -48
@@ -3,9 +3,14 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../types/NftId.sol";
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {
|
6
|
+
import {StateId} from "../../types/StateId.sol";
|
7
|
+
import {IService} from "../../shared/IService.sol";
|
8
|
+
import {IBundle} from "../module/IBundle.sol";
|
9
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
7
10
|
|
8
11
|
interface IPoolService is IService {
|
12
|
+
error ErrorIPoolServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
13
|
+
|
9
14
|
function setFees(
|
10
15
|
Fee memory poolFee,
|
11
16
|
Fee memory stakingFee,
|
@@ -25,13 +30,22 @@ interface IPoolService is IService {
|
|
25
30
|
Fee memory fee
|
26
31
|
) external;
|
27
32
|
|
33
|
+
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
34
|
+
|
35
|
+
function underwritePolicy(IInstance instanceNftId,
|
36
|
+
NftId policyNftId,
|
37
|
+
NftId bundleNftId,
|
38
|
+
uint256 collateralAmount,
|
39
|
+
uint256 netPremium
|
40
|
+
) external;
|
41
|
+
|
28
42
|
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
29
43
|
|
30
44
|
// function defundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
31
45
|
|
32
|
-
|
46
|
+
function lockBundle(NftId bundleNftId) external;
|
33
47
|
|
34
|
-
|
48
|
+
function unlockBundle(NftId bundleNftId) external;
|
35
49
|
|
36
50
|
// function closeBundle(NftId bundleNftId) external;
|
37
51
|
}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {IRisk} from "../module/
|
5
|
-
import {IService} from "
|
4
|
+
import {IRisk} from "../module/IRisk.sol";
|
5
|
+
import {IService} from "../../shared/IService.sol";
|
6
6
|
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
|
-
import {ReferralId} from "../../types/
|
8
|
+
import {ReferralId} from "../../types/Referral.sol";
|
9
9
|
import {RiskId} from "../../types/RiskId.sol";
|
10
10
|
import {StateId} from "../../types/StateId.sol";
|
11
11
|
import {Timestamp} from "../../types/Timestamp.sol";
|
@@ -13,6 +13,9 @@ import {UFixed} from "../../types/UFixed.sol";
|
|
13
13
|
import {Fee} from "../../types/Fee.sol";
|
14
14
|
|
15
15
|
interface IProductService is IService {
|
16
|
+
|
17
|
+
error ErrorIProductServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
18
|
+
|
16
19
|
function setFees(
|
17
20
|
Fee memory productFee,
|
18
21
|
Fee memory processingFee
|
@@ -24,84 +27,14 @@ interface IProductService is IService {
|
|
24
27
|
) external;
|
25
28
|
|
26
29
|
|
27
|
-
function
|
30
|
+
function updateRisk(
|
28
31
|
RiskId riskId,
|
29
|
-
|
32
|
+
bytes memory data
|
30
33
|
) external;
|
31
34
|
|
32
35
|
|
33
36
|
function updateRiskState(
|
34
37
|
RiskId riskId,
|
35
|
-
StateId
|
38
|
+
StateId newState
|
36
39
|
) external;
|
37
|
-
|
38
|
-
|
39
|
-
function calculatePremium(
|
40
|
-
RiskId riskId,
|
41
|
-
uint256 sumInsuredAmount,
|
42
|
-
uint256 lifetime,
|
43
|
-
bytes memory applicationData,
|
44
|
-
NftId bundleNftId,
|
45
|
-
ReferralId referralId
|
46
|
-
)
|
47
|
-
external
|
48
|
-
view
|
49
|
-
returns (
|
50
|
-
uint256 premiumAmount,
|
51
|
-
uint256 productFeeAmount,
|
52
|
-
uint256 poolFeeAmount,
|
53
|
-
uint256 bundleFeeAmount,
|
54
|
-
uint256 distributionFeeAmount
|
55
|
-
);
|
56
|
-
|
57
|
-
|
58
|
-
function createApplication(
|
59
|
-
address applicationOwner,
|
60
|
-
RiskId riskId,
|
61
|
-
uint256 sumInsuredAmount,
|
62
|
-
uint256 lifetime,
|
63
|
-
bytes memory applicationData,
|
64
|
-
NftId bundleNftId,
|
65
|
-
ReferralId referralId
|
66
|
-
) external returns (NftId nftId);
|
67
|
-
|
68
|
-
/**
|
69
|
-
* @dev revokes the application represented by {policyNftId}.
|
70
|
-
* an application can only be revoked in applied state.
|
71
|
-
* only the application holder may revoke an application.
|
72
|
-
*/
|
73
|
-
function revoke(NftId policyNftId) external;
|
74
|
-
|
75
|
-
/**
|
76
|
-
* @dev underwrites the policy represented by {policyNftId}.
|
77
|
-
* optionally collects premiums and activates the policy.
|
78
|
-
* - premium payment is only attempted if requirePremiumPayment is set to true
|
79
|
-
* - activation is only done if activateAt is a non-zero timestamp
|
80
|
-
*/
|
81
|
-
function underwrite(
|
82
|
-
NftId policyNftId,
|
83
|
-
bool requirePremiumPayment,
|
84
|
-
Timestamp activateAt
|
85
|
-
) external;
|
86
|
-
|
87
|
-
// function decline(uint256 nftId) external;
|
88
|
-
// function expire(uint256 nftId) external;
|
89
|
-
|
90
|
-
function collectPremium(NftId policyNftId, Timestamp activateAt) external;
|
91
|
-
|
92
|
-
function activate(NftId policyNftId, Timestamp activateAt) external;
|
93
|
-
|
94
|
-
|
95
|
-
function close(NftId nftId) external;
|
96
|
-
|
97
|
-
// function createClaim(uint256 nftId, uint256 claimAmount) external;
|
98
|
-
// function confirmClaim(uint256 nftId, uint256 claimId, uint256 claimAmount) external;
|
99
|
-
// function declineClaim(uint256 nftId, uint256 claimId) external;
|
100
|
-
// function closeClaim(uint256 nftId, uint256 claimId) external;
|
101
|
-
|
102
|
-
function calculateRequiredCollateral(
|
103
|
-
UFixed collateralizationLevel,
|
104
|
-
uint256 sumInsuredAmount
|
105
|
-
) external pure returns(uint256 collateralAmount);
|
106
|
-
|
107
40
|
}
|
@@ -0,0 +1,513 @@
|
|
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 {IBaseComponent} from "../../components/IBaseComponent.sol";
|
8
|
+
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
9
|
+
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
10
|
+
import {IInstance} from "../IInstance.sol";
|
11
|
+
import {IPolicy} from "../module/IPolicy.sol";
|
12
|
+
import {IRisk} from "../module/IRisk.sol";
|
13
|
+
import {IBundle} from "../module/IBundle.sol";
|
14
|
+
import {IProductService} from "./IProductService.sol";
|
15
|
+
import {ITreasury} from "../module/ITreasury.sol";
|
16
|
+
import {ISetup} from "../module/ISetup.sol";
|
17
|
+
|
18
|
+
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
19
|
+
|
20
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
21
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
22
|
+
|
23
|
+
import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
|
24
|
+
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
25
|
+
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
26
|
+
import {ObjectType, INSTANCE, PRODUCT, POLICY} from "../../types/ObjectType.sol";
|
27
|
+
import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
|
28
|
+
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
29
|
+
import {Fee, FeeLib} from "../../types/Fee.sol";
|
30
|
+
import {ReferralId} from "../../types/Referral.sol";
|
31
|
+
import {RiskId} from "../../types/RiskId.sol";
|
32
|
+
import {StateId} from "../../types/StateId.sol";
|
33
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
34
|
+
//import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
|
35
|
+
|
36
|
+
import {IService} from "../../shared/IService.sol";
|
37
|
+
import {Service} from "../../shared/Service.sol";
|
38
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
39
|
+
import {IPolicyService} from "./IPolicyService.sol";
|
40
|
+
import {InstanceReader} from "../InstanceReader.sol";
|
41
|
+
import {IPoolService} from "./PoolService.sol";
|
42
|
+
import {POOL_SERVICE_NAME} from "./PoolService.sol";
|
43
|
+
|
44
|
+
string constant PRODUCT_SERVICE_NAME = "ProductService";
|
45
|
+
|
46
|
+
contract PolicyService is ComponentServiceBase, IPolicyService {
|
47
|
+
using NftIdLib for NftId;
|
48
|
+
|
49
|
+
string public constant NAME = "PolicyService";
|
50
|
+
|
51
|
+
IPoolService internal _poolService;
|
52
|
+
|
53
|
+
event LogProductServiceSender(address sender);
|
54
|
+
|
55
|
+
function _initialize(
|
56
|
+
address owner,
|
57
|
+
bytes memory data
|
58
|
+
)
|
59
|
+
internal
|
60
|
+
initializer
|
61
|
+
virtual override
|
62
|
+
{
|
63
|
+
address registryAddress;
|
64
|
+
address initialOwner;
|
65
|
+
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
66
|
+
|
67
|
+
_initializeService(registryAddress, owner);
|
68
|
+
|
69
|
+
_poolService = IPoolService(_registry.getServiceAddress(POOL_SERVICE_NAME, getMajorVersion()));
|
70
|
+
|
71
|
+
_registerInterface(type(IPolicyService).interfaceId);
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
function getName() public pure override(IService, Service) returns(string memory name) {
|
76
|
+
return NAME;
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
|
81
|
+
IRegistry.ObjectInfo memory productInfo;
|
82
|
+
(productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
83
|
+
product = Product(productInfo.objectAddress);
|
84
|
+
}
|
85
|
+
// TODO no access restrictions
|
86
|
+
function calculatePremium(
|
87
|
+
RiskId riskId,
|
88
|
+
uint256 sumInsuredAmount,
|
89
|
+
uint256 lifetime,
|
90
|
+
bytes memory applicationData,
|
91
|
+
NftId bundleNftId,
|
92
|
+
ReferralId referralId
|
93
|
+
)
|
94
|
+
public
|
95
|
+
view
|
96
|
+
override
|
97
|
+
returns (
|
98
|
+
uint256 premiumAmount,
|
99
|
+
uint256 productFeeAmount,
|
100
|
+
uint256 poolFeeAmount,
|
101
|
+
uint256 bundleFeeAmount,
|
102
|
+
uint256 distributionFeeAmount
|
103
|
+
)
|
104
|
+
{
|
105
|
+
Product product = _getAndVerifyInstanceAndProduct();
|
106
|
+
uint256 netPremiumAmount = product.calculateNetPremium(
|
107
|
+
sumInsuredAmount,
|
108
|
+
riskId,
|
109
|
+
lifetime,
|
110
|
+
applicationData
|
111
|
+
);
|
112
|
+
|
113
|
+
(
|
114
|
+
productFeeAmount,
|
115
|
+
poolFeeAmount,
|
116
|
+
bundleFeeAmount,
|
117
|
+
distributionFeeAmount
|
118
|
+
) = _calculateFeeAmounts(
|
119
|
+
netPremiumAmount,
|
120
|
+
product,
|
121
|
+
bundleNftId,
|
122
|
+
referralId
|
123
|
+
);
|
124
|
+
|
125
|
+
premiumAmount = netPremiumAmount + productFeeAmount;
|
126
|
+
premiumAmount += poolFeeAmount + bundleFeeAmount;
|
127
|
+
premiumAmount += distributionFeeAmount;
|
128
|
+
}
|
129
|
+
|
130
|
+
function _calculateFeeAmounts(
|
131
|
+
uint256 netPremiumAmount,
|
132
|
+
Product product,
|
133
|
+
NftId bundleNftId,
|
134
|
+
ReferralId referralId
|
135
|
+
)
|
136
|
+
internal
|
137
|
+
view
|
138
|
+
returns (
|
139
|
+
uint256 productFeeAmount,
|
140
|
+
uint256 poolFeeAmount,
|
141
|
+
uint256 bundleFeeAmount,
|
142
|
+
uint256 distributionFeeAmount
|
143
|
+
)
|
144
|
+
{
|
145
|
+
InstanceReader instanceReader;
|
146
|
+
{
|
147
|
+
IInstance instance = product.getInstance();
|
148
|
+
instanceReader = instance.getInstanceReader();
|
149
|
+
}
|
150
|
+
|
151
|
+
NftId poolNftId = product.getPoolNftId();
|
152
|
+
IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
153
|
+
require(bundleInfo.poolNftId == poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
|
154
|
+
|
155
|
+
{
|
156
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(product.getProductNftId());
|
157
|
+
(productFeeAmount,) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
|
158
|
+
}
|
159
|
+
{
|
160
|
+
ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
161
|
+
(poolFeeAmount,) = FeeLib.calculateFee(poolSetupInfo.poolFee, netPremiumAmount);
|
162
|
+
}
|
163
|
+
{
|
164
|
+
NftId distributionNftId = product.getDistributionNftId();
|
165
|
+
ISetup.DistributionSetupInfo memory distributionSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
166
|
+
(distributionFeeAmount,) = FeeLib.calculateFee(distributionSetupInfo.distributionFee, netPremiumAmount);
|
167
|
+
}
|
168
|
+
|
169
|
+
(bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
|
170
|
+
}
|
171
|
+
|
172
|
+
|
173
|
+
function createApplication(
|
174
|
+
address applicationOwner,
|
175
|
+
RiskId riskId,
|
176
|
+
uint256 sumInsuredAmount,
|
177
|
+
uint256 lifetime,
|
178
|
+
bytes memory applicationData,
|
179
|
+
NftId bundleNftId,
|
180
|
+
ReferralId referralId
|
181
|
+
) external override returns (NftId policyNftId) {
|
182
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
183
|
+
// TODO add validations (see create bundle in pool service)
|
184
|
+
|
185
|
+
policyNftId = getRegistryService().registerPolicy(
|
186
|
+
IRegistry.ObjectInfo(
|
187
|
+
zeroNftId(),
|
188
|
+
productInfo.nftId,
|
189
|
+
POLICY(),
|
190
|
+
false, // intercepting property for policies is defined on product
|
191
|
+
address(0),
|
192
|
+
applicationOwner,
|
193
|
+
""
|
194
|
+
)
|
195
|
+
);
|
196
|
+
|
197
|
+
(uint256 premiumAmount,,,,) = calculatePremium(
|
198
|
+
riskId,
|
199
|
+
sumInsuredAmount,
|
200
|
+
lifetime,
|
201
|
+
applicationData,
|
202
|
+
bundleNftId,
|
203
|
+
referralId
|
204
|
+
);
|
205
|
+
|
206
|
+
IPolicy.PolicyInfo memory policyInfo = IPolicy.PolicyInfo(
|
207
|
+
productInfo.nftId,
|
208
|
+
bundleNftId,
|
209
|
+
referralId,
|
210
|
+
riskId,
|
211
|
+
sumInsuredAmount,
|
212
|
+
premiumAmount,
|
213
|
+
0,
|
214
|
+
lifetime,
|
215
|
+
applicationData,
|
216
|
+
"",
|
217
|
+
0,
|
218
|
+
0,
|
219
|
+
0,
|
220
|
+
zeroTimestamp(),
|
221
|
+
zeroTimestamp(),
|
222
|
+
zeroTimestamp()
|
223
|
+
);
|
224
|
+
|
225
|
+
instance.createPolicy(policyNftId, policyInfo);
|
226
|
+
instance.updatePolicyState(policyNftId, APPLIED());
|
227
|
+
|
228
|
+
// TODO add logging
|
229
|
+
}
|
230
|
+
|
231
|
+
function _getAndVerifyUnderwritingSetup(
|
232
|
+
IInstance instance,
|
233
|
+
InstanceReader instanceReader,
|
234
|
+
IPolicy.PolicyInfo memory policyInfo,
|
235
|
+
ISetup.ProductSetupInfo memory productSetupInfo
|
236
|
+
)
|
237
|
+
internal
|
238
|
+
view
|
239
|
+
returns (
|
240
|
+
NftId bundleNftId,
|
241
|
+
IBundle.BundleInfo memory bundleInfo,
|
242
|
+
uint256 collateralAmount
|
243
|
+
)
|
244
|
+
{
|
245
|
+
// check match between policy and bundle (via pool)
|
246
|
+
bundleNftId = policyInfo.bundleNftId;
|
247
|
+
bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
248
|
+
require(bundleInfo.poolNftId == productSetupInfo.poolNftId, "POLICY_BUNDLE_MISMATCH");
|
249
|
+
|
250
|
+
// calculate required collateral
|
251
|
+
NftId poolNftId = productSetupInfo.poolNftId;
|
252
|
+
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
253
|
+
|
254
|
+
// obtain remaining return values
|
255
|
+
collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
|
256
|
+
}
|
257
|
+
|
258
|
+
function _lockCollateralInBundle(
|
259
|
+
IInstance instance,
|
260
|
+
NftId bundleNftId,
|
261
|
+
IBundle.BundleInfo memory bundleInfo,
|
262
|
+
NftId policyNftId,
|
263
|
+
uint256 collateralAmount
|
264
|
+
)
|
265
|
+
internal
|
266
|
+
returns (IBundle.BundleInfo memory)
|
267
|
+
{
|
268
|
+
bundleInfo.lockedAmount += collateralAmount;
|
269
|
+
// TODO: track policy associated to bundle in bundlemanager (tbd) and how much is locked for it
|
270
|
+
return bundleInfo;
|
271
|
+
}
|
272
|
+
|
273
|
+
function _underwriteByPool(
|
274
|
+
NftId poolNftId,
|
275
|
+
NftId policyNftId,
|
276
|
+
IPolicy.PolicyInfo memory policyInfo,
|
277
|
+
bytes memory bundleFilter,
|
278
|
+
uint256 collateralAmount
|
279
|
+
)
|
280
|
+
internal
|
281
|
+
{
|
282
|
+
address poolAddress = getRegistry().getObjectInfo(poolNftId).objectAddress;
|
283
|
+
IPoolComponent pool = IPoolComponent(poolAddress);
|
284
|
+
pool.underwrite(
|
285
|
+
policyNftId,
|
286
|
+
policyInfo.applicationData,
|
287
|
+
bundleFilter,
|
288
|
+
collateralAmount);
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
function revoke(
|
293
|
+
NftId policyNftId
|
294
|
+
)
|
295
|
+
external
|
296
|
+
override
|
297
|
+
{
|
298
|
+
require(false, "ERROR:PRS-234:NOT_YET_IMPLEMENTED");
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
function underwrite(
|
303
|
+
NftId policyNftId,
|
304
|
+
bool requirePremiumPayment,
|
305
|
+
Timestamp activateAt
|
306
|
+
)
|
307
|
+
external
|
308
|
+
override
|
309
|
+
{
|
310
|
+
// check caller is registered product
|
311
|
+
(
|
312
|
+
IRegistry.ObjectInfo memory productInfo,
|
313
|
+
IInstance instance
|
314
|
+
) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
315
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
316
|
+
|
317
|
+
// check match between policy and calling product
|
318
|
+
NftId productNftId = productInfo.nftId;
|
319
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
320
|
+
require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
|
321
|
+
require(instanceReader.getPolicyState(policyNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
322
|
+
|
323
|
+
NftId bundleNftId;
|
324
|
+
IBundle.BundleInfo memory bundleInfo;
|
325
|
+
uint256 collateralAmount;
|
326
|
+
uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
|
327
|
+
{
|
328
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
|
329
|
+
IBundle.BundleInfo memory bundleInfo;
|
330
|
+
|
331
|
+
(
|
332
|
+
bundleNftId,
|
333
|
+
bundleInfo,
|
334
|
+
collateralAmount
|
335
|
+
) = _getAndVerifyUnderwritingSetup(
|
336
|
+
instance,
|
337
|
+
instanceReader,
|
338
|
+
policyInfo,
|
339
|
+
productSetupInfo
|
340
|
+
);
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
// lock bundle collateral
|
345
|
+
bundleInfo = _lockCollateralInBundle(
|
346
|
+
instance,
|
347
|
+
bundleNftId,
|
348
|
+
bundleInfo,
|
349
|
+
policyNftId,
|
350
|
+
collateralAmount);
|
351
|
+
|
352
|
+
// lock bundle collateral
|
353
|
+
bundleInfo = _lockCollateralInBundle(
|
354
|
+
instance,
|
355
|
+
bundleNftId,
|
356
|
+
bundleInfo,
|
357
|
+
policyNftId,
|
358
|
+
collateralAmount);
|
359
|
+
StateId newPolicyState = UNDERWRITTEN();
|
360
|
+
|
361
|
+
// optional activation of policy
|
362
|
+
if(activateAt > zeroTimestamp()) {
|
363
|
+
newPolicyState = ACTIVE();
|
364
|
+
policyInfo.activatedAt = activateAt;
|
365
|
+
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
366
|
+
}
|
367
|
+
|
368
|
+
// optional collection of premium
|
369
|
+
if(requirePremiumPayment) {
|
370
|
+
netPremiumAmount = _processPremiumByTreasury(
|
371
|
+
instance,
|
372
|
+
productInfo.nftId,
|
373
|
+
policyNftId,
|
374
|
+
policyInfo.premiumAmount);
|
375
|
+
|
376
|
+
policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
|
377
|
+
}
|
378
|
+
|
379
|
+
_poolService.underwritePolicy(instance, policyNftId, bundleNftId, collateralAmount, netPremiumAmount);
|
380
|
+
instance.updatePolicy(policyNftId, policyInfo, newPolicyState);
|
381
|
+
|
382
|
+
// involve pool if necessary
|
383
|
+
{
|
384
|
+
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(bundleInfo.poolNftId);
|
385
|
+
|
386
|
+
if(poolInfo.isConfirmingApplication) {
|
387
|
+
_underwriteByPool(
|
388
|
+
bundleInfo.poolNftId,
|
389
|
+
policyNftId,
|
390
|
+
policyInfo,
|
391
|
+
bundleInfo.filter,
|
392
|
+
collateralAmount
|
393
|
+
);
|
394
|
+
}
|
395
|
+
}
|
396
|
+
|
397
|
+
// TODO add logging
|
398
|
+
}
|
399
|
+
|
400
|
+
function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
|
401
|
+
UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
|
402
|
+
UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
|
403
|
+
return collateralUFixed.toInt();
|
404
|
+
}
|
405
|
+
|
406
|
+
function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
|
407
|
+
// check caller is registered product
|
408
|
+
(IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
409
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
410
|
+
|
411
|
+
// TODO: check if not paid
|
412
|
+
// TODO: transfer premium
|
413
|
+
// TODO: optionally activate
|
414
|
+
|
415
|
+
// // perform actual token transfers (this code is probably not complete)
|
416
|
+
// IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
417
|
+
|
418
|
+
// uint256 premiumAmount = policyInfo.premiumAmount;
|
419
|
+
// _processPremiumByTreasury(instance, productInfo.nftId, policyNftId, premiumAmount);
|
420
|
+
|
421
|
+
// // policy level book keeping for premium paid
|
422
|
+
// policyInfo.premiumPaidAmount += premiumAmount;
|
423
|
+
|
424
|
+
// instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
425
|
+
|
426
|
+
// // optional activation of policy
|
427
|
+
// if(activateAt > zeroTimestamp()) {
|
428
|
+
// activate(policyNftId, activateAt);
|
429
|
+
// }
|
430
|
+
|
431
|
+
// TODO add logging
|
432
|
+
}
|
433
|
+
|
434
|
+
function activate(NftId policyNftId, Timestamp activateAt) public override {
|
435
|
+
// check caller is registered product
|
436
|
+
(, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
437
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
438
|
+
|
439
|
+
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
440
|
+
|
441
|
+
require(
|
442
|
+
policyInfo.activatedAt.eqz(),
|
443
|
+
"ERROR:PRS-020:ALREADY_ACTIVATED");
|
444
|
+
|
445
|
+
policyInfo.activatedAt = activateAt;
|
446
|
+
policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
|
447
|
+
|
448
|
+
instance.updatePolicy(policyNftId, policyInfo, ACTIVE());
|
449
|
+
|
450
|
+
// TODO add logging
|
451
|
+
}
|
452
|
+
|
453
|
+
function close(
|
454
|
+
NftId policyNftId
|
455
|
+
) external override // solhint-disable-next-line no-empty-blocks
|
456
|
+
{
|
457
|
+
|
458
|
+
}
|
459
|
+
|
460
|
+
function _getPoolNftId(
|
461
|
+
IInstance instance,
|
462
|
+
NftId productNftId
|
463
|
+
)
|
464
|
+
internal
|
465
|
+
view
|
466
|
+
returns (NftId poolNftid)
|
467
|
+
{
|
468
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
469
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
|
470
|
+
return productSetupInfo.poolNftId;
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
function _processPremiumByTreasury(
|
475
|
+
IInstance instance,
|
476
|
+
NftId productNftId,
|
477
|
+
NftId policyNftId,
|
478
|
+
uint256 premiumAmount
|
479
|
+
)
|
480
|
+
internal
|
481
|
+
returns (uint256 netPremiumAmount)
|
482
|
+
{
|
483
|
+
// process token transfer(s)
|
484
|
+
if(premiumAmount > 0) {
|
485
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
|
486
|
+
TokenHandler tokenHandler = productSetupInfo.tokenHandler;
|
487
|
+
address policyOwner = getRegistry().ownerOf(policyNftId);
|
488
|
+
ISetup.PoolSetupInfo memory poolSetupInfo = instance.getInstanceReader().getPoolSetupInfo(productSetupInfo.poolNftId);
|
489
|
+
address poolWallet = poolSetupInfo.wallet;
|
490
|
+
netPremiumAmount = premiumAmount;
|
491
|
+
Fee memory productFee = productSetupInfo.productFee;
|
492
|
+
|
493
|
+
if (FeeLib.feeIsZero(productFee)) {
|
494
|
+
tokenHandler.transfer(
|
495
|
+
policyOwner,
|
496
|
+
poolWallet,
|
497
|
+
premiumAmount
|
498
|
+
);
|
499
|
+
} else {
|
500
|
+
(uint256 productFeeAmount, uint256 netAmount) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
|
501
|
+
address productWallet = productSetupInfo.wallet;
|
502
|
+
if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premiumAmount) {
|
503
|
+
revert ErrorIProductServiceInsufficientAllowance(policyOwner, address(tokenHandler), premiumAmount);
|
504
|
+
}
|
505
|
+
tokenHandler.transfer(policyOwner, productWallet, productFeeAmount);
|
506
|
+
tokenHandler.transfer(policyOwner, poolWallet, netAmount);
|
507
|
+
netPremiumAmount = netAmount;
|
508
|
+
}
|
509
|
+
}
|
510
|
+
|
511
|
+
// TODO add logging
|
512
|
+
}
|
513
|
+
}
|