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