@etherisc/gif-next 0.0.2-9620cae-586 → 0.0.2-9628b30-648

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.
Files changed (589) hide show
  1. package/README.md +103 -9
  2. package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +4 -0
  3. package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +1075 -0
  4. package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +4 -0
  5. package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +790 -0
  6. package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +4 -0
  7. package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +843 -0
  8. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
  9. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +673 -262
  10. package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.dbg.json +4 -0
  11. package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.json +1289 -0
  12. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
  13. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +202 -5
  14. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
  15. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +456 -24
  16. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
  17. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
  18. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +549 -209
  19. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
  20. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +215 -18
  21. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
  22. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +265 -16
  23. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
  24. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +473 -17
  25. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
  26. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +212 -473
  27. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
  28. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +431 -36
  29. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  30. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +139 -381
  31. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  32. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +814 -399
  33. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  34. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +228 -124
  35. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  36. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +135 -187
  37. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  38. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +582 -141
  39. package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.dbg.json +4 -0
  40. package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.json +22 -0
  41. package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +4 -0
  42. package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +1484 -0
  43. package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +4 -0
  44. package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +805 -0
  45. package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +4 -0
  46. package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +2053 -0
  47. package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +4 -0
  48. package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +805 -0
  49. package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +4 -0
  50. package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.json +376 -0
  51. package/artifacts/contracts/examples/flight/FlightOracle.sol/FlightOracle.dbg.json +4 -0
  52. package/artifacts/contracts/examples/flight/FlightOracle.sol/FlightOracle.json +1208 -0
  53. package/artifacts/contracts/examples/flight/FlightOracleAuthorization.sol/FlightOracleAuthorization.dbg.json +4 -0
  54. package/artifacts/contracts/examples/flight/FlightOracleAuthorization.sol/FlightOracleAuthorization.json +805 -0
  55. package/artifacts/contracts/examples/flight/FlightPool.sol/FlightPool.dbg.json +4 -0
  56. package/artifacts/contracts/examples/flight/FlightPool.sol/FlightPool.json +1476 -0
  57. package/artifacts/contracts/examples/flight/FlightPoolAuthorization.sol/FlightPoolAuthorization.dbg.json +4 -0
  58. package/artifacts/contracts/examples/flight/FlightPoolAuthorization.sol/FlightPoolAuthorization.json +805 -0
  59. package/artifacts/contracts/examples/flight/FlightProduct.sol/FlightProduct.dbg.json +4 -0
  60. package/artifacts/contracts/examples/flight/FlightProduct.sol/FlightProduct.json +2572 -0
  61. package/artifacts/contracts/examples/flight/FlightProductAuthorization.sol/FlightProductAuthorization.dbg.json +4 -0
  62. package/artifacts/contracts/examples/flight/FlightProductAuthorization.sol/FlightProductAuthorization.json +805 -0
  63. package/artifacts/contracts/examples/flight/FlightUSD.sol/FlightUSD.dbg.json +4 -0
  64. package/artifacts/contracts/examples/flight/FlightUSD.sol/FlightUSD.json +376 -0
  65. package/artifacts/contracts/examples/flight/originalV1.sol/FlightDelayChainlink.dbg.json +4 -0
  66. package/artifacts/contracts/examples/flight/originalV1.sol/FlightDelayChainlink.json +901 -0
  67. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +4 -0
  68. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +1439 -0
  69. package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +4 -0
  70. package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +805 -0
  71. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +4 -0
  72. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +1171 -0
  73. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +4 -0
  74. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +1647 -0
  75. package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +4 -0
  76. package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +805 -0
  77. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +4 -0
  78. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +2585 -0
  79. package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +4 -0
  80. package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +805 -0
  81. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
  82. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +193 -45
  83. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  84. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +567 -67
  85. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +385 -60
  87. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  88. package/artifacts/contracts/instance/Instance.sol/Instance.json +573 -165
  89. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  90. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1034 -311
  91. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
  92. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +369 -68
  93. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  94. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1798 -793
  95. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +399 -231
  97. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +143 -105
  99. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  100. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +983 -782
  101. package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +4 -0
  102. package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +866 -0
  103. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  104. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +8 -8
  105. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  106. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  107. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  108. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
  109. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +46 -5
  110. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
  111. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +16 -5
  112. package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.dbg.json +4 -0
  113. package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.json +168 -0
  114. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  115. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  116. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  117. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  118. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  119. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  120. package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
  121. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
  122. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +152 -350
  123. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
  124. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +424 -37
  125. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  126. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  127. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +129 -129
  128. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  129. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +98 -11
  130. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  131. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +128 -318
  132. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  133. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +198 -190
  134. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  135. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +177 -97
  136. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
  137. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +198 -433
  138. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
  139. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +430 -35
  140. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  141. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +574 -270
  142. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  143. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +216 -104
  144. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  145. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +383 -53
  146. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  147. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +158 -212
  148. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  149. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +711 -340
  150. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  151. package/artifacts/contracts/pool/Pool.sol/Pool.json +148 -392
  152. package/artifacts/contracts/pool/PoolLib.sol/PoolLib.dbg.json +4 -0
  153. package/artifacts/contracts/pool/PoolLib.sol/PoolLib.json +522 -0
  154. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  155. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +925 -545
  156. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  157. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +230 -106
  158. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  159. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +353 -180
  160. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  161. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +159 -99
  162. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
  163. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +287 -427
  164. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
  165. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +430 -35
  166. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  167. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +466 -245
  168. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  169. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +187 -123
  170. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  171. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +301 -9
  172. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  173. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +350 -18
  174. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  175. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +417 -101
  176. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  177. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +183 -80
  178. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  179. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +272 -222
  180. package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +4 -0
  181. package/artifacts/contracts/{shared/ComponentVerifyingService.sol/ComponentVerifyingService.json → product/IRiskService.sol/IRiskService.json} +283 -157
  182. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  183. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +532 -311
  184. package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.dbg.json +4 -0
  185. package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.json +783 -0
  186. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  187. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +196 -108
  188. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  189. package/artifacts/contracts/product/PricingService.sol/PricingService.json +249 -329
  190. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  191. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +165 -137
  192. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  193. package/artifacts/contracts/product/Product.sol/Product.json +279 -419
  194. package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +4 -0
  195. package/artifacts/contracts/product/RiskService.sol/RiskService.json +873 -0
  196. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +4 -0
  197. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +774 -0
  198. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  199. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +59 -16
  200. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  201. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +359 -48
  202. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  203. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +169 -37
  204. package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +4 -0
  205. package/artifacts/contracts/registry/IRelease.sol/IRelease.json +24 -0
  206. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  207. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +5 -18
  208. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  209. package/artifacts/contracts/registry/Registry.sol/Registry.json +565 -109
  210. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  211. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +791 -377
  212. package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
  213. package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1074 -0
  214. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  215. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +136 -290
  216. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  217. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +141 -89
  218. package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +4 -0
  219. package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +2152 -0
  220. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
  221. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +47 -6
  222. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
  223. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +483 -253
  224. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
  225. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +489 -20
  226. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  227. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +120 -60
  228. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  229. package/artifacts/contracts/shared/Component.sol/Component.json +86 -277
  230. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  231. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +624 -560
  232. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  233. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +198 -120
  234. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +4 -0
  235. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +632 -0
  236. package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.dbg.json +4 -0
  237. package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.json +24 -0
  238. package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.dbg.json +4 -0
  239. package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.json +30 -0
  240. package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.dbg.json +4 -0
  241. package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.json +40 -0
  242. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  243. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +92 -93
  244. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  245. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +535 -240
  246. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  247. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +118 -129
  248. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  249. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +42 -6
  250. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  251. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +36 -0
  252. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  253. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +35 -0
  254. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  255. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +15 -47
  256. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  257. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +167 -0
  258. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  259. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  260. package/artifacts/contracts/shared/IService.sol/IService.json +84 -2
  261. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +4 -0
  262. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +53 -0
  263. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  264. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +117 -318
  265. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  266. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +48 -7
  267. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  268. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +42 -1
  269. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
  270. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +2 -2
  271. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  272. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +41 -57
  273. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  274. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +19 -141
  275. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  276. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +141 -97
  277. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  278. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
  279. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  280. package/artifacts/contracts/shared/Service.sol/Service.json +86 -111
  281. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  282. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +585 -12
  283. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.dbg.json +4 -0
  284. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.json +484 -0
  285. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +4 -0
  286. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +172 -0
  287. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  288. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +1510 -191
  289. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  290. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +235 -123
  291. package/artifacts/contracts/staking/ITargetLimitHandler.sol/ITargetLimitHandler.dbg.json +4 -0
  292. package/artifacts/contracts/staking/ITargetLimitHandler.sol/ITargetLimitHandler.json +50 -0
  293. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  294. package/artifacts/contracts/staking/Staking.sol/Staking.json +1635 -455
  295. package/artifacts/contracts/staking/StakingLib.sol/StakingLib.dbg.json +4 -0
  296. package/artifacts/contracts/staking/StakingLib.sol/StakingLib.json +470 -0
  297. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  298. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +191 -105
  299. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  300. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +295 -183
  301. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  302. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +282 -281
  303. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  304. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +144 -96
  305. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  306. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +1643 -783
  307. package/artifacts/contracts/staking/TargetHandler.sol/TargetHandler.dbg.json +4 -0
  308. package/artifacts/contracts/staking/TargetHandler.sol/TargetHandler.json +309 -0
  309. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  310. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +184 -76
  311. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  312. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  313. package/artifacts/contracts/type/Amount.sol/AmountLib.json +63 -10
  314. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  315. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +45 -19
  316. package/artifacts/contracts/type/ChainId.sol/ChainIdLib.dbg.json +4 -0
  317. package/artifacts/contracts/type/ChainId.sol/ChainIdLib.json +193 -0
  318. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  319. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +28 -4
  320. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  321. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
  322. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  323. package/artifacts/contracts/type/Fee.sol/FeeLib.json +98 -37
  324. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  325. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  326. package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.dbg.json +4 -0
  327. package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.json +33 -0
  328. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  329. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +23 -4
  330. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  331. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  332. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  333. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +33 -31
  334. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  335. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +19 -19
  336. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  337. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +23 -4
  338. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  339. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
  340. package/artifacts/contracts/type/RequestIdSet.sol/RequestIdSet.dbg.json +4 -0
  341. package/artifacts/contracts/type/RequestIdSet.sol/RequestIdSet.json +33 -0
  342. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  343. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +125 -7
  344. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  345. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +42 -157
  346. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  347. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +112 -2
  348. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
  349. package/artifacts/contracts/type/Selector.sol/SelectorLib.json +21 -2
  350. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
  351. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +2 -2
  352. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  353. package/artifacts/contracts/type/StateId.sol/StateIdLib.json +15 -2
  354. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
  355. package/artifacts/contracts/type/String.sol/StrLib.json +50 -2
  356. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  357. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +56 -5
  358. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  359. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +109 -35
  360. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  361. package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -21
  362. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  363. package/artifacts/contracts/type/Version.sol/VersionPartLib.json +101 -2
  364. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +4 -0
  365. package/artifacts/contracts/{shared → upgradeability}/IVersionable.sol/IVersionable.json +11 -1
  366. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  367. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +656 -0
  368. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  369. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +142 -0
  370. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +4 -0
  371. package/artifacts/contracts/{shared → upgradeability}/Versionable.sol/Versionable.json +11 -1
  372. package/contracts/accounting/AccountingService.sol +274 -0
  373. package/contracts/accounting/AccountingServiceManager.sol +38 -0
  374. package/contracts/accounting/IAccountingService.sol +47 -0
  375. package/contracts/authorization/AccessAdmin.sol +458 -269
  376. package/contracts/authorization/AccessAdminLib.sol +396 -0
  377. package/contracts/authorization/AccessManagerCloneable.sol +146 -4
  378. package/contracts/authorization/Authorization.sol +159 -208
  379. package/contracts/authorization/IAccess.sol +25 -6
  380. package/contracts/authorization/IAccessAdmin.sol +87 -79
  381. package/contracts/authorization/IAuthorization.sol +9 -37
  382. package/contracts/authorization/IServiceAuthorization.sol +57 -17
  383. package/contracts/authorization/ServiceAuthorization.sol +255 -25
  384. package/contracts/distribution/BasicDistribution.sol +22 -30
  385. package/contracts/distribution/BasicDistributionAuthorization.sol +34 -10
  386. package/contracts/distribution/Distribution.sol +48 -84
  387. package/contracts/distribution/DistributionService.sol +276 -130
  388. package/contracts/distribution/DistributionServiceManager.sol +8 -11
  389. package/contracts/distribution/IDistributionComponent.sol +11 -14
  390. package/contracts/distribution/IDistributionService.sol +56 -26
  391. package/contracts/examples/fire/DamageLevel.sol +59 -0
  392. package/contracts/examples/fire/FirePool.sol +86 -0
  393. package/contracts/examples/fire/FirePoolAuthorization.sol +35 -0
  394. package/contracts/examples/fire/FireProduct.sol +433 -0
  395. package/contracts/examples/fire/FireProductAuthorization.sol +45 -0
  396. package/contracts/examples/fire/FireUSD.sol +26 -0
  397. package/contracts/examples/flight/FlightOracle.sol +160 -0
  398. package/contracts/examples/flight/FlightOracleAuthorization.sol +34 -0
  399. package/contracts/examples/flight/FlightPool.sol +89 -0
  400. package/contracts/examples/flight/FlightPoolAuthorization.sol +37 -0
  401. package/contracts/examples/flight/FlightProduct.sol +661 -0
  402. package/contracts/examples/flight/FlightProductAuthorization.sol +42 -0
  403. package/contracts/examples/flight/FlightUSD.sol +26 -0
  404. package/contracts/examples/flight/originalV1.sol +396 -0
  405. package/contracts/examples/unpermissioned/SimpleDistribution.sol +81 -0
  406. package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +28 -0
  407. package/contracts/examples/unpermissioned/SimpleOracle.sol +133 -0
  408. package/contracts/examples/unpermissioned/SimplePool.sol +102 -0
  409. package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +28 -0
  410. package/contracts/examples/unpermissioned/SimpleProduct.sol +437 -0
  411. package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +28 -0
  412. package/contracts/instance/BundleSet.sol +42 -38
  413. package/contracts/instance/IInstance.sol +102 -43
  414. package/contracts/instance/IInstanceService.sol +59 -34
  415. package/contracts/instance/Instance.sol +193 -100
  416. package/contracts/instance/InstanceAdmin.sol +275 -158
  417. package/contracts/instance/InstanceAuthorizationV3.sol +120 -56
  418. package/contracts/instance/InstanceReader.sol +500 -251
  419. package/contracts/instance/InstanceService.sol +293 -236
  420. package/contracts/instance/InstanceServiceManager.sol +8 -13
  421. package/contracts/instance/InstanceStore.sol +24 -2
  422. package/contracts/instance/RiskSet.sol +126 -0
  423. package/contracts/instance/base/BalanceStore.sol +4 -6
  424. package/contracts/instance/base/ObjectCounter.sol +1 -2
  425. package/contracts/instance/base/ObjectLifecycle.sol +13 -10
  426. package/contracts/instance/base/ObjectSet.sol +31 -33
  427. package/contracts/instance/base/ObjectSetHelperLib.sol +30 -0
  428. package/contracts/instance/module/IBundle.sol +6 -5
  429. package/contracts/instance/module/IComponents.sol +30 -20
  430. package/contracts/instance/module/IDistribution.sol +21 -9
  431. package/contracts/instance/module/IPolicy.sol +50 -29
  432. package/contracts/instance/module/IRisk.sol +5 -0
  433. package/contracts/mock/Dip.sol +1 -1
  434. package/contracts/oracle/BasicOracle.sol +2 -5
  435. package/contracts/oracle/BasicOracleAuthorization.sol +14 -8
  436. package/contracts/oracle/IOracle.sol +9 -4
  437. package/contracts/oracle/IOracleComponent.sol +2 -1
  438. package/contracts/oracle/IOracleService.sol +14 -13
  439. package/contracts/oracle/Oracle.sol +23 -26
  440. package/contracts/oracle/OracleService.sol +119 -87
  441. package/contracts/oracle/OracleServiceManager.sol +8 -11
  442. package/contracts/pool/BasicPool.sol +39 -41
  443. package/contracts/pool/BasicPoolAuthorization.sol +43 -11
  444. package/contracts/pool/BundleService.sol +218 -128
  445. package/contracts/pool/BundleServiceManager.sol +8 -11
  446. package/contracts/pool/IBundleService.sol +43 -33
  447. package/contracts/pool/IPoolComponent.sol +20 -10
  448. package/contracts/pool/IPoolService.sol +97 -77
  449. package/contracts/pool/Pool.sol +146 -124
  450. package/contracts/pool/PoolLib.sol +341 -0
  451. package/contracts/pool/PoolService.sol +419 -256
  452. package/contracts/pool/PoolServiceManager.sol +6 -9
  453. package/contracts/product/ApplicationService.sol +153 -80
  454. package/contracts/product/ApplicationServiceManager.sol +6 -6
  455. package/contracts/product/BasicProduct.sol +13 -46
  456. package/contracts/product/BasicProductAuthorization.sol +33 -10
  457. package/contracts/product/ClaimService.sol +382 -194
  458. package/contracts/product/ClaimServiceManager.sol +6 -6
  459. package/contracts/product/IApplicationService.sol +29 -3
  460. package/contracts/product/IClaimService.sol +48 -11
  461. package/contracts/product/IPolicyService.sol +61 -37
  462. package/contracts/product/IPricingService.sol +11 -10
  463. package/contracts/product/IProductComponent.sol +28 -5
  464. package/contracts/product/IRiskService.sol +48 -0
  465. package/contracts/product/PolicyService.sol +443 -273
  466. package/contracts/product/PolicyServiceLib.sol +139 -0
  467. package/contracts/product/PolicyServiceManager.sol +6 -9
  468. package/contracts/product/PricingService.sol +90 -84
  469. package/contracts/product/PricingServiceManager.sol +6 -9
  470. package/contracts/product/Product.sol +201 -100
  471. package/contracts/product/RiskService.sol +190 -0
  472. package/contracts/product/RiskServiceManager.sol +39 -0
  473. package/contracts/registry/ChainNft.sol +72 -40
  474. package/contracts/registry/IRegistry.sol +70 -32
  475. package/contracts/registry/IRegistryService.sol +5 -12
  476. package/contracts/registry/IRelease.sol +29 -0
  477. package/contracts/registry/ITransferInterceptor.sol +1 -2
  478. package/contracts/registry/Registry.sol +367 -207
  479. package/contracts/registry/RegistryAdmin.sol +114 -288
  480. package/contracts/registry/RegistryAuthorization.sol +336 -0
  481. package/contracts/registry/RegistryService.sol +42 -67
  482. package/contracts/registry/RegistryServiceManager.sol +5 -5
  483. package/contracts/registry/ReleaseAdmin.sol +195 -0
  484. package/contracts/registry/ReleaseLifecycle.sol +8 -3
  485. package/contracts/registry/ReleaseRegistry.sol +279 -241
  486. package/contracts/registry/ServiceAuthorizationV3.sol +205 -63
  487. package/contracts/registry/TokenRegistry.sol +61 -59
  488. package/contracts/shared/Component.sol +70 -137
  489. package/contracts/shared/ComponentService.sol +452 -346
  490. package/contracts/shared/ComponentServiceManager.sol +10 -7
  491. package/contracts/shared/ContractLib.sol +312 -0
  492. package/contracts/shared/IComponent.sol +6 -18
  493. package/contracts/shared/IComponentService.sol +50 -41
  494. package/contracts/shared/IInstanceLinkedComponent.sol +7 -27
  495. package/contracts/shared/IKeyValueStore.sol +1 -1
  496. package/contracts/shared/ILifecycle.sol +3 -1
  497. package/contracts/shared/INftOwnable.sol +4 -0
  498. package/contracts/shared/IPolicyHolder.sol +12 -22
  499. package/contracts/shared/IRegisterable.sol +22 -1
  500. package/contracts/shared/IService.sol +4 -6
  501. package/contracts/shared/{ERC165.sol → InitializableERC165.sol} +11 -3
  502. package/contracts/shared/InstanceLinkedComponent.sol +132 -49
  503. package/contracts/shared/KeyValueStore.sol +4 -4
  504. package/contracts/shared/Lifecycle.sol +15 -4
  505. package/contracts/shared/NftOwnable.sol +33 -11
  506. package/contracts/shared/PolicyHolder.sol +20 -59
  507. package/contracts/shared/Registerable.sol +52 -21
  508. package/contracts/shared/RegistryLinked.sol +9 -14
  509. package/contracts/shared/Service.sol +22 -38
  510. package/contracts/shared/TokenHandler.sol +310 -26
  511. package/contracts/shared/TokenHandlerDeployerLib.sol +20 -0
  512. package/contracts/staking/IStaking.sol +272 -72
  513. package/contracts/staking/IStakingService.sol +45 -78
  514. package/contracts/staking/ITargetLimitHandler.sol +17 -0
  515. package/contracts/staking/Staking.sol +533 -246
  516. package/contracts/staking/StakingLib.sol +195 -0
  517. package/contracts/staking/StakingManager.sol +14 -14
  518. package/contracts/staking/StakingReader.sol +72 -87
  519. package/contracts/staking/StakingService.sol +62 -152
  520. package/contracts/staking/StakingServiceManager.sol +9 -7
  521. package/contracts/staking/StakingStore.sol +1094 -341
  522. package/contracts/staking/TargetHandler.sol +132 -0
  523. package/contracts/staking/TargetManagerLib.sol +73 -46
  524. package/contracts/type/Amount.sol +31 -5
  525. package/contracts/type/Blocknumber.sol +22 -16
  526. package/contracts/type/ChainId.sol +101 -0
  527. package/contracts/type/ClaimId.sol +6 -1
  528. package/contracts/type/Fee.sol +8 -8
  529. package/contracts/type/Key32.sol +2 -2
  530. package/contracts/type/Key32Set.sol +62 -0
  531. package/contracts/type/NftId.sol +7 -0
  532. package/contracts/type/ObjectType.sol +73 -37
  533. package/contracts/type/PayoutId.sol +10 -10
  534. package/contracts/type/Referral.sol +7 -0
  535. package/contracts/type/RequestIdSet.sol +62 -0
  536. package/contracts/type/RiskId.sol +38 -6
  537. package/contracts/type/RoleId.sol +61 -55
  538. package/contracts/type/Seconds.sol +44 -1
  539. package/contracts/type/Selector.sol +5 -0
  540. package/contracts/type/StateId.sol +15 -1
  541. package/contracts/type/String.sol +12 -0
  542. package/contracts/type/Timestamp.sol +24 -8
  543. package/contracts/type/UFixed.sol +57 -126
  544. package/contracts/type/Version.sol +54 -5
  545. package/contracts/{shared → upgradeability}/IVersionable.sol +3 -0
  546. package/contracts/{shared → upgradeability}/ProxyManager.sol +96 -49
  547. package/contracts/upgradeability/UpgradableProxyWithAdmin.sol +24 -0
  548. package/contracts/{shared → upgradeability}/Versionable.sol +8 -5
  549. package/package.json +5 -4
  550. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +0 -4
  551. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.json +0 -290
  552. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +0 -4
  553. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +0 -390
  554. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +0 -4
  555. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +0 -129
  556. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +0 -4
  557. package/artifacts/contracts/product/IProductService.sol/IProductService.json +0 -400
  558. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +0 -4
  559. package/artifacts/contracts/product/ProductService.sol/ProductService.json +0 -708
  560. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +0 -4
  561. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +0 -702
  562. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +0 -4
  563. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +0 -4
  564. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +0 -73
  565. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +0 -4
  566. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +0 -4
  567. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.json +0 -39
  568. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +0 -4
  569. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +0 -617
  570. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +0 -4
  571. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +0 -129
  572. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +0 -4
  573. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +0 -4
  574. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +0 -460
  575. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +0 -4
  576. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +0 -164
  577. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +0 -4
  578. package/artifacts/contracts/type/UFixed.sol/MathLib.json +0 -10
  579. package/contracts/authorization/IModuleAuthorization.sol +0 -21
  580. package/contracts/authorization/ModuleAuthorization.sol +0 -78
  581. package/contracts/instance/module/IAccess.sol +0 -46
  582. package/contracts/product/IProductService.sol +0 -33
  583. package/contracts/product/ProductService.sol +0 -124
  584. package/contracts/product/ProductServiceManager.sol +0 -42
  585. package/contracts/shared/ComponentVerifyingService.sol +0 -117
  586. package/contracts/shared/InitializableCustom.sol +0 -177
  587. package/contracts/shared/UpgradableProxyWithAdmin.sol +0 -16
  588. package/contracts/staking/StakeManagerLib.sol +0 -231
  589. package/contracts/staking/StakingLifecycle.sol +0 -23
@@ -1,24 +1,40 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ /// @dev Target: Cover durations of 1000 years.
4
5
  type Seconds is uint40;
5
6
 
6
7
  using {
7
8
  SecondsEq as ==,
9
+ SecondsLt as <,
8
10
  SecondsGt as >,
11
+ SecondsAdd as +,
9
12
  SecondsLib.eqz,
10
13
  SecondsLib.gtz,
11
- SecondsLib.toInt
14
+ SecondsLib.eq,
15
+ SecondsLib.gt,
16
+ SecondsLib.lt,
17
+ SecondsLib.toInt,
18
+ SecondsLib.add
12
19
  } for Seconds global;
13
20
 
14
21
  function SecondsEq(Seconds duration1, Seconds duration2) pure returns (bool) {
15
22
  return SecondsLib.eq(duration1, duration2);
16
23
  }
17
24
 
25
+ function SecondsLt(Seconds duration1, Seconds duration2) pure returns (bool) {
26
+ return SecondsLib.lt(duration1, duration2);
27
+ }
28
+
18
29
  function SecondsGt(Seconds duration1, Seconds duration2) pure returns (bool) {
19
30
  return SecondsLib.gt(duration1, duration2);
20
31
  }
21
32
 
33
+ function SecondsAdd(Seconds duration1, Seconds duration2) pure returns (Seconds) {
34
+ return SecondsLib.add(duration1, duration2);
35
+ }
36
+
37
+
22
38
  library SecondsLib {
23
39
 
24
40
  error ErrorSecondsLibDurationTooBig(uint256 duration);
@@ -31,10 +47,18 @@ library SecondsLib {
31
47
  return Seconds.wrap(_max());
32
48
  }
33
49
 
50
+ function fromHours(uint32 numberOfHours) public pure returns (Seconds duration) {
51
+ return Seconds.wrap(numberOfHours * 3600);
52
+ }
53
+
34
54
  function oneDay() public pure returns (Seconds duration) {
35
55
  return Seconds.wrap(24 * 3600);
36
56
  }
37
57
 
58
+ function fromDays(uint32 numberOfDays) public pure returns (Seconds duration) {
59
+ return Seconds.wrap(numberOfDays * 24 * 3600);
60
+ }
61
+
38
62
  function oneYear() public pure returns (Seconds duration) {
39
63
  return Seconds.wrap(365 * 24 * 3600);
40
64
  }
@@ -70,6 +94,25 @@ library SecondsLib {
70
94
  return Seconds.unwrap(duration1) > Seconds.unwrap(duration2);
71
95
  }
72
96
 
97
+ /// @dev return true if duration1 is smaller than duration2
98
+ function lt(Seconds duration1, Seconds duration2) public pure returns (bool) {
99
+ return Seconds.unwrap(duration1) < Seconds.unwrap(duration2);
100
+ }
101
+
102
+ /// @dev returns the smaller of the duration
103
+ function min(Seconds duration1, Seconds duration2) public pure returns (Seconds) {
104
+ if (Seconds.unwrap(duration1) < Seconds.unwrap(duration2)) {
105
+ return duration1;
106
+ }
107
+
108
+ return duration2;
109
+ }
110
+
111
+ /// @dev return add duration1 and duration2
112
+ function add(Seconds duration1, Seconds duration2) public pure returns (Seconds) {
113
+ return Seconds.wrap(Seconds.unwrap(duration1) + Seconds.unwrap(duration2));
114
+ }
115
+
73
116
  function toInt(Seconds duration) public pure returns (uint256) {
74
117
  return uint256(uint40(Seconds.unwrap(duration)));
75
118
  }
@@ -8,6 +8,7 @@ using {
8
8
  eqSelector as ==,
9
9
  neSelector as !=,
10
10
  SelectorLib.toBytes4,
11
+ SelectorLib.toString,
11
12
  SelectorLib.eqz
12
13
  } for Selector global;
13
14
 
@@ -46,6 +47,10 @@ library SelectorLib {
46
47
  function toBytes4(Selector s) public pure returns (bytes4) {
47
48
  return Selector.unwrap(s);
48
49
  }
50
+
51
+ function toString(Selector s) public pure returns (string memory) {
52
+ return string(abi.encode(Selector.unwrap(s)));
53
+ }
49
54
  }
50
55
 
51
56
  // selector specific set library
@@ -9,6 +9,7 @@ using {
9
9
  eqStateId as ==,
10
10
  neStateId as !=,
11
11
  StateIdLib.eqz,
12
+ StateIdLib.eq,
12
13
  StateIdLib.gtz,
13
14
  StateIdLib.toInt
14
15
  } for StateId global;
@@ -27,10 +28,18 @@ function DEPLOYING() pure returns (StateId) {
27
28
  return toStateId(3);
28
29
  }
29
30
 
30
- function ACTIVE() pure returns (StateId) {
31
+ function DEPLOYED() pure returns (StateId) {
31
32
  return toStateId(4);
32
33
  }
33
34
 
35
+ function ACTIVE() pure returns (StateId) {
36
+ return toStateId(5);
37
+ }
38
+
39
+ function SKIPPED() pure returns (StateId) {
40
+ return toStateId(6);
41
+ }
42
+
34
43
  function APPLIED() pure returns (StateId) {
35
44
  return toStateId(10);
36
45
  }
@@ -113,6 +122,11 @@ function neStateId(StateId a, StateId b) pure returns (bool isDifferent) {
113
122
 
114
123
  // library functions that operate on user defined type
115
124
  library StateIdLib {
125
+
126
+ function zero() public pure returns (StateId) {
127
+ return StateId.wrap(0);
128
+ }
129
+
116
130
  /// @dev Converts the NftId to a uint256.
117
131
  function toInt(StateId stateId) public pure returns (uint96) {
118
132
  return uint96(StateId.unwrap(stateId));
@@ -12,10 +12,12 @@ using {
12
12
  StrLib.length
13
13
  } for Str global;
14
14
 
15
+ // pure free function needed for the operator overloading
15
16
  function StrEq(Str s1, Str s2) pure returns (bool) {
16
17
  return StrLib.eq(s1, s2);
17
18
  }
18
19
 
20
+ // pure free function needed for the operator overloading
19
21
  function StrNe(Str s1, Str s2) pure returns (bool) {
20
22
  return StrLib.ne(s1, s2);
21
23
  }
@@ -39,6 +41,16 @@ library StrLib {
39
41
  return Str.unwrap(s1) != Str.unwrap(s2);
40
42
  }
41
43
 
44
+ /// @dev return true iff s1 equals from s2
45
+ function eq(string memory s1, string memory s2) public pure returns (bool) {
46
+ return keccak256(bytes(s1)) == keccak256(bytes(s2));
47
+ }
48
+
49
+ /// @dev return true iff s1 differs s2
50
+ function ne(string memory s1, string memory s2) public pure returns (bool) {
51
+ return !eq(s1, s2);
52
+ }
53
+
42
54
  /// @dev converts the provided short string into a string.
43
55
  /// uses ShortStrings.toString
44
56
  function toString(Str str) public pure returns (string memory) {
@@ -3,6 +3,8 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {Seconds} from "./Seconds.sol";
5
5
 
6
+ /// @dev Target: Cover 10 years with 1 ms block time resolution.
7
+ /// Typical block time resolution is 1s.
6
8
  type Timestamp is uint40;
7
9
 
8
10
  using {
@@ -12,9 +14,16 @@ using {
12
14
  lteTimestamp as <=,
13
15
  eqTimestamp as ==,
14
16
  neTimestamp as !=,
17
+ TimestampLib.eq,
18
+ TimestampLib.ne,
19
+ TimestampLib.gt,
20
+ TimestampLib.gte,
21
+ TimestampLib.lt,
22
+ TimestampLib.lte,
15
23
  TimestampLib.gtz,
16
24
  TimestampLib.eqz,
17
25
  TimestampLib.addSeconds,
26
+ TimestampLib.subtractSeconds,
18
27
  TimestampLib.toInt
19
28
  } for Timestamp global;
20
29
 
@@ -48,11 +57,6 @@ function neTimestamp(Timestamp a, Timestamp b) pure returns (bool) {
48
57
  return Timestamp.unwrap(a) != Timestamp.unwrap(b);
49
58
  }
50
59
 
51
- /// @dev Converts the uint256 to a Timestamp.
52
- function toTimestamp(uint256 timestamp) pure returns (Timestamp) {
53
- return Timestamp.wrap(uint40(timestamp));
54
- }
55
-
56
60
  // TODO move to TimestampLib and rename to zero()
57
61
  /// @dev Return the Timestamp zero (0)
58
62
  function zeroTimestamp() pure returns (Timestamp) {
@@ -68,10 +72,14 @@ library TimestampLib {
68
72
  function max() public pure returns (Timestamp) {
69
73
  return Timestamp.wrap(type(uint40).max);
70
74
  }
71
-
72
- function blockTimestamp() public view returns (Timestamp) {
75
+
76
+ function current() public view returns (Timestamp) {
73
77
  return Timestamp.wrap(uint40(block.timestamp));
74
78
  }
79
+
80
+ function toTimestamp(uint256 timestamp) public pure returns (Timestamp) {
81
+ return Timestamp.wrap(uint40(timestamp));
82
+ }
75
83
 
76
84
  /// @dev return true if Timestamp a is after Timestamp b
77
85
  function gt(Timestamp a, Timestamp b) public pure returns (bool isAfter) {
@@ -122,7 +130,7 @@ library TimestampLib {
122
130
  return Timestamp.unwrap(timestamp) > 0;
123
131
  }
124
132
 
125
- /// @dev return true if Timestamp a is not equal to Timestamp b
133
+ /// @dev return a new timestamp that is duration seconds later than the provided timestamp.
126
134
  function addSeconds(
127
135
  Timestamp timestamp,
128
136
  Seconds duration
@@ -130,6 +138,14 @@ library TimestampLib {
130
138
  return toTimestamp(Timestamp.unwrap(timestamp) + duration.toInt());
131
139
  }
132
140
 
141
+ /// @dev return a new timestamp that is duration seconds earlier than the provided timestamp.
142
+ function subtractSeconds(
143
+ Timestamp timestamp,
144
+ Seconds duration
145
+ ) public pure returns (Timestamp) {
146
+ return toTimestamp(Timestamp.unwrap(timestamp) - duration.toInt());
147
+ }
148
+
133
149
  function toInt(Timestamp timestamp) public pure returns (uint256) {
134
150
  return uint256(uint40(Timestamp.unwrap(timestamp)));
135
151
  }
@@ -1,8 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- /// @dev UFixed is a fixed point number with 18 decimals precision.
5
- type UFixed is uint256;
4
+ import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
5
+
6
+ /// @dev UFixed is a 160-bit fixed point number with 15 decimals precision.
7
+ type UFixed is uint160;
6
8
 
7
9
  using {
8
10
  addUFixed as +,
@@ -15,9 +17,11 @@ using {
15
17
  lteUFixed as <=,
16
18
  eqUFixed as ==,
17
19
  neUFixed as !=,
20
+ UFixedLib.gt,
21
+ UFixedLib.eqz,
22
+ UFixedLib.gtz,
18
23
  UFixedLib.toInt,
19
- UFixedLib.toInt1000,
20
- UFixedLib.gtz
24
+ UFixedLib.toInt1000
21
25
  } for UFixed global;
22
26
 
23
27
  // TODO move to UFixedLib and rename to zero()
@@ -30,20 +34,24 @@ function addUFixed(UFixed a, UFixed b) pure returns (UFixed) {
30
34
  }
31
35
 
32
36
  function subUFixed(UFixed a, UFixed b) pure returns (UFixed) {
33
- require(a >= b, "ERROR:UFM-010:NEGATIVE_RESULT");
37
+ if (a < b) {
38
+ revert UFixedLib.UFixedLibNegativeResult();
39
+ }
34
40
  return UFixed.wrap(UFixed.unwrap(a) - UFixed.unwrap(b));
35
41
  }
36
42
 
37
43
  function mulUFixed(UFixed a, UFixed b) pure returns (UFixed) {
38
44
  return
39
- UFixed.wrap(MathLib.mulDiv(UFixed.unwrap(a), UFixed.unwrap(b), 10 ** 18));
45
+ UFixed.wrap(uint160(Math.mulDiv(UFixed.unwrap(a), UFixed.unwrap(b), 10 ** 15)));
40
46
  }
41
47
 
42
48
  function divUFixed(UFixed a, UFixed b) pure returns (UFixed) {
43
- require(UFixed.unwrap(b) > 0, "ERROR:UFM-020:DIVISOR_ZERO");
44
-
49
+ if (UFixed.unwrap(b) == 0) {
50
+ revert UFixedLib.UFixedLibDivisionByZero();
51
+ }
52
+
45
53
  return
46
- UFixed.wrap(MathLib.mulDiv(UFixed.unwrap(a), 10 ** 18, UFixed.unwrap(b)));
54
+ UFixed.wrap(uint160(Math.mulDiv(UFixed.unwrap(a), 10 ** 15, UFixed.unwrap(b))));
47
55
  }
48
56
 
49
57
  function gtUFixed(UFixed a, UFixed b) pure returns (bool isGreaterThan) {
@@ -86,116 +94,16 @@ function deltaUFixed(UFixed a, UFixed b) pure returns (UFixed) {
86
94
  return b - a;
87
95
  }
88
96
 
89
- /// @dev copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.3/contracts/utils/math/Math.sol
90
- library MathLib {
91
-
92
- enum Rounding {
93
- Down, // Toward negative infinity
94
- Up, // Toward infinity
95
- Zero // Toward zero
96
- }
97
+ library UFixedLib {
98
+ error UFixedLibNegativeResult();
99
+ error UFixedLibDivisionByZero();
97
100
 
98
- /**
99
- * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
100
- * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
101
- * with further edits by Uniswap Labs also under MIT license.
102
- */
103
- function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
104
- unchecked {
105
- // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
106
- // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
107
- // variables such that product = prod1 * 2^256 + prod0.
108
- uint256 prod0; // Least significant 256 bits of the product
109
- uint256 prod1; // Most significant 256 bits of the product
110
- assembly {
111
- let mm := mulmod(x, y, not(0))
112
- prod0 := mul(x, y)
113
- prod1 := sub(sub(mm, prod0), lt(mm, prod0))
114
- }
115
-
116
- // Handle non-overflow cases, 256 by 256 division.
117
- if (prod1 == 0) {
118
- // Solidity will revert if denominator == 0, unlike the div opcode on its own.
119
- // The surrounding unchecked block does not change this fact.
120
- // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
121
- return prod0 / denominator;
122
- }
123
-
124
- // Make sure the result is less than 2^256. Also prevents denominator == 0.
125
- require(denominator > prod1, "Math: mulDiv overflow");
126
-
127
- ///////////////////////////////////////////////
128
- // 512 by 256 division.
129
- ///////////////////////////////////////////////
130
-
131
- // Make division exact by subtracting the remainder from [prod1 prod0].
132
- uint256 remainder;
133
- assembly {
134
- // Compute remainder using mulmod.
135
- remainder := mulmod(x, y, denominator)
136
-
137
- // Subtract 256 bit number from 512 bit number.
138
- prod1 := sub(prod1, gt(remainder, prod0))
139
- prod0 := sub(prod0, remainder)
140
- }
141
-
142
- // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
143
- // See https://cs.stackexchange.com/q/138556/92363.
144
-
145
- // Does not overflow because the denominator cannot be zero at this stage in the function.
146
- uint256 twos = denominator & (~denominator + 1);
147
- assembly {
148
- // Divide denominator by twos.
149
- denominator := div(denominator, twos)
150
-
151
- // Divide [prod1 prod0] by twos.
152
- prod0 := div(prod0, twos)
153
-
154
- // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
155
- twos := add(div(sub(0, twos), twos), 1)
156
- }
157
-
158
- // Shift in bits from prod1 into prod0.
159
- prod0 |= prod1 * twos;
160
-
161
- // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
162
- // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
163
- // four bits. That is, denominator * inv = 1 mod 2^4.
164
- uint256 inverse = (3 * denominator) ^ 2;
165
-
166
- // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
167
- // in modular arithmetic, doubling the correct bits in each step.
168
- inverse *= 2 - denominator * inverse; // inverse mod 2^8
169
- inverse *= 2 - denominator * inverse; // inverse mod 2^16
170
- inverse *= 2 - denominator * inverse; // inverse mod 2^32
171
- inverse *= 2 - denominator * inverse; // inverse mod 2^64
172
- inverse *= 2 - denominator * inverse; // inverse mod 2^128
173
- inverse *= 2 - denominator * inverse; // inverse mod 2^256
174
-
175
- // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
176
- // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
177
- // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
178
- // is no longer required.
179
- result = prod0 * inverse;
180
- return result;
181
- }
182
- }
101
+ error UFixedLibExponentTooSmall(int8 exp);
102
+ error UFixedLibExponentTooLarge(int8 exp);
183
103
 
184
- /**
185
- * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
186
- */
187
- function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
188
- uint256 result = mulDiv(x, y, denominator);
189
- if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
190
- result += 1;
191
- }
192
- return result;
193
- }
104
+ error UFixedLibNumberTooLarge(uint256 number);
194
105
 
195
- }
196
-
197
- library UFixedLib {
198
- int8 public constant EXP = 18;
106
+ int8 public constant EXP = 15;
199
107
  uint256 public constant MULTIPLIER = 10 ** uint256(int256(EXP));
200
108
  uint256 public constant MULTIPLIER_HALF = MULTIPLIER / 2;
201
109
 
@@ -214,17 +122,32 @@ library UFixedLib {
214
122
  return uint8(2);
215
123
  }
216
124
 
217
- /// @dev Converts the uint256 to a UFixed.
125
+ /// @dev Converts the uint256 to a uint160 based UFixed.
126
+ /// This method reverts if the number is too large to fit in a uint160.
218
127
  function toUFixed(uint256 a) public pure returns (UFixed) {
219
- return UFixed.wrap(a * MULTIPLIER);
128
+ uint256 n = a * MULTIPLIER;
129
+ if (n > type(uint160).max) {
130
+ revert UFixedLibNumberTooLarge(a);
131
+ }
132
+ return UFixed.wrap(uint160(n));
220
133
  }
221
134
 
222
135
  /// @dev Converts the uint256 to a UFixed with given exponent.
223
136
  function toUFixed(uint256 a, int8 exp) public pure returns (UFixed) {
224
- require(EXP + exp >= 0, "ERROR:FM-010:EXPONENT_TOO_SMALL");
225
- require(EXP + exp <= 64, "ERROR:FM-011:EXPONENT_TOO_LARGE");
137
+ if (EXP + exp < 0) {
138
+ revert UFixedLibExponentTooSmall(exp);
139
+ }
140
+ if (EXP + exp > 48) {
141
+ revert UFixedLibExponentTooLarge(exp);
142
+ }
143
+
144
+ uint256 n = a * 10 ** uint8(EXP + exp);
226
145
 
227
- return UFixed.wrap(a * 10 ** uint8(EXP + exp));
146
+ if (n > type(uint160).max) {
147
+ revert UFixedLibNumberTooLarge(n);
148
+ }
149
+
150
+ return UFixed.wrap(uint160(n));
228
151
  }
229
152
 
230
153
  /// @dev returns the decimals precision of the UFixed type
@@ -246,23 +169,23 @@ library UFixedLib {
246
169
  function toIntWithRounding(UFixed a, uint8 rounding) public pure returns (uint256) {
247
170
  if (rounding == ROUNDING_HALF_UP()) {
248
171
  return
249
- MathLib.mulDiv(
172
+ Math.mulDiv(
250
173
  UFixed.unwrap(a) + MULTIPLIER_HALF,
251
174
  1,
252
175
  MULTIPLIER,
253
- MathLib.Rounding.Down
176
+ Math.Rounding.Floor
254
177
  );
255
178
  } else if (rounding == ROUNDING_DOWN()) {
256
179
  return
257
- MathLib.mulDiv(
180
+ Math.mulDiv(
258
181
  UFixed.unwrap(a),
259
182
  1,
260
183
  MULTIPLIER,
261
- MathLib.Rounding.Down
184
+ Math.Rounding.Floor
262
185
  );
263
186
  } else {
264
187
  return
265
- MathLib.mulDiv(UFixed.unwrap(a), 1, MULTIPLIER, MathLib.Rounding.Up);
188
+ Math.mulDiv(UFixed.unwrap(a), 1, MULTIPLIER, Math.Rounding.Ceil);
266
189
  }
267
190
  }
268
191
 
@@ -325,6 +248,14 @@ library UFixedLib {
325
248
  return UFixed.wrap(0);
326
249
  }
327
250
 
251
+ function one() public pure returns (UFixed) {
252
+ return UFixed.wrap(uint160(MULTIPLIER));
253
+ }
254
+
255
+ function max() public pure returns (UFixed) {
256
+ return UFixed.wrap(type(uint160).max);
257
+ }
258
+
328
259
  /// @dev return the absolute delta between two UFixed numbers
329
260
  function delta(UFixed a, UFixed b) public pure returns (UFixed) {
330
261
  return deltaUFixed(a, b);
@@ -8,7 +8,10 @@ using {
8
8
  versionPartEq as ==,
9
9
  versionPartNe as !=,
10
10
  VersionPartLib.eqz,
11
- VersionPartLib.toInt
11
+ VersionPartLib.gtz,
12
+ VersionPartLib.toInt,
13
+ VersionPartLib.toString,
14
+ VersionPartLib.isValidRelease
12
15
  }
13
16
  for VersionPart global;
14
17
 
@@ -17,9 +20,54 @@ function versionPartEq(VersionPart a, VersionPart b) pure returns(bool isSame) {
17
20
  function versionPartNe(VersionPart a, VersionPart b) pure returns(bool isSame) { return VersionPart.unwrap(a) != VersionPart.unwrap(b); }
18
21
 
19
22
  library VersionPartLib {
23
+
24
+ error ErrorReleaseTooBig(VersionPart releaseMax, VersionPart release);
25
+
26
+ function releaseMin() public pure returns (VersionPart) { return toVersionPart(3); }
27
+ function releaseMax() public pure returns (VersionPart) { return toVersionPart(99); }
28
+
29
+ function isValidRelease(VersionPart release) external pure returns(bool) {
30
+ uint256 releaseInt = VersionPart.unwrap(release);
31
+ return 3 <= releaseInt && releaseInt <= 99;
32
+ }
33
+
34
+ function toString(VersionPart a) external pure returns (string memory) {
35
+ if (a > releaseMax()) {
36
+ revert ErrorReleaseTooBig(releaseMax(), a);
37
+ }
38
+
39
+ uint256 value = VersionPart.unwrap(a);
40
+ if (value == 0) {
41
+ return "0";
42
+ }
43
+
44
+ uint256 temp = value;
45
+ uint256 digits = 0;
46
+ while (temp != 0) {
47
+ digits++;
48
+ temp /= 10;
49
+ }
50
+
51
+ bytes memory buffer = new bytes(digits);
52
+ uint index = digits - 1;
53
+
54
+ temp = value;
55
+ while (temp != 0) {
56
+ buffer[index] = bytes1(uint8(48 + temp % 10));
57
+ temp /= 10;
58
+
59
+ if (index > 0) {
60
+ index--;
61
+ }
62
+ }
63
+
64
+ return string(buffer);
65
+ }
66
+
20
67
  function eqz(VersionPart a) external pure returns(bool) { return VersionPart.unwrap(a) == 0; }
68
+ function gtz(VersionPart a) external pure returns(bool) { return VersionPart.unwrap(a) > 0; }
21
69
  function toInt(VersionPart a) external pure returns(uint256) { return VersionPart.unwrap(a); }
22
- function toVersionPart(uint256 a) external pure returns(VersionPart) { return VersionPart.wrap(uint8(a)); }
70
+ function toVersionPart(uint256 a) public pure returns(VersionPart) { return VersionPart.wrap(uint8(a)); }
23
71
  }
24
72
 
25
73
  type Version is uint24; // contains major,minor,patch version parts
@@ -38,6 +86,7 @@ function versionGt(Version a, Version b) pure returns(bool isGreaterThan) { retu
38
86
  function versionEq(Version a, Version b) pure returns(bool isSame) { return Version.unwrap(a) == Version.unwrap(b); }
39
87
 
40
88
  library VersionLib {
89
+
41
90
  function toInt(Version version) external pure returns(uint) { return Version.unwrap(version); }
42
91
 
43
92
  function toUint64(Version version) external pure returns(uint64) { return Version.unwrap(version); }
@@ -75,9 +124,9 @@ library VersionLib {
75
124
  );
76
125
  }
77
126
 
78
- function toVersionPart(uint256 versionPart) external pure returns(VersionPart) {
79
- return VersionPart.wrap(uint8(versionPart));
80
- }
127
+ // function toVersionPart(uint256 versionPart) public pure returns(VersionPart) {
128
+ // return VersionPart.wrap(uint8(versionPart));
129
+ // }
81
130
 
82
131
  function toVersion(
83
132
  uint256 major,
@@ -28,6 +28,9 @@ import {Version} from "../type/Version.sol";
28
28
 
29
29
  interface IVersionable {
30
30
 
31
+ error ErrorVersionableInitializeNotImplemented();
32
+ error ErrorVersionableUpgradeNotImplemented();
33
+
31
34
  /**
32
35
  * @dev IMPORTANT
33
36
  * implementation MUST be guarded by initializer modifier