@gearbox-protocol/sdk 18.3.1 → 18.4.1-aave.1

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 (292) hide show
  1. package/dist/cjs/abi/310/iKillSwitchProxy.js +130 -0
  2. package/dist/cjs/model/index.js +1 -4
  3. package/dist/cjs/offchain/GearboxAPI.js +0 -7
  4. package/dist/cjs/offchain/index.js +0 -3
  5. package/dist/cjs/onchain/accounts/intents/index.js +1 -0
  6. package/dist/cjs/onchain/accounts/intents/operations.js +21 -0
  7. package/dist/cjs/onchain/accounts/intents/plan.js +33 -0
  8. package/dist/cjs/onchain/accounts/intents/realize.js +44 -0
  9. package/dist/cjs/onchain/accounts/intents/testing/market.js +1 -0
  10. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +2 -1
  11. package/dist/cjs/onchain/accounts/intents/utils/ledger.js +8 -0
  12. package/dist/cjs/onchain/chain/chains.js +4 -0
  13. package/dist/cjs/onchain/index.js +30 -0
  14. package/dist/cjs/onchain/market/adapters/abi/aave/iAaveHorizonBridge.js +94 -0
  15. package/dist/cjs/onchain/market/adapters/abi/aave/iAaveV3Pool.js +112 -0
  16. package/dist/cjs/onchain/market/adapters/abi/aave/index.js +5 -0
  17. package/dist/cjs/onchain/market/adapters/abi/actionAbi.js +1 -0
  18. package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +197 -0
  19. package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.js +177 -0
  20. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.js +113 -0
  21. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.js +258 -0
  22. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.js +161 -0
  23. package/dist/cjs/onchain/market/adapters/abi/adapters/index.js +10 -0
  24. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +2 -0
  25. package/dist/cjs/onchain/market/adapters/abi/index.js +22 -0
  26. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.js +39 -0
  27. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.js +230 -0
  28. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseRouter.js +29 -0
  29. package/dist/cjs/onchain/market/adapters/abi/treehouse/index.js +7 -0
  30. package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +130 -0
  31. package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +205 -0
  32. package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +8 -0
  33. package/dist/cjs/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.js +72 -0
  34. package/dist/cjs/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.js +117 -0
  35. package/dist/cjs/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.js +61 -0
  36. package/dist/cjs/onchain/market/adapters/contracts/index.js +10 -0
  37. package/dist/cjs/onchain/market/adapters/createAdapter.js +10 -0
  38. package/dist/cjs/onchain/market/adapters/index.js +30 -0
  39. package/dist/cjs/onchain/market/adapters/types.js +2 -0
  40. package/dist/cjs/onchain/market/index.js +30 -0
  41. package/dist/cjs/onchain/positions/projectAavePosition.js +40 -0
  42. package/dist/cjs/onchain/preview/preview/loadAdapterReplayState.js +17 -0
  43. package/dist/cjs/onchain/preview/preview/previewOperation.js +2 -0
  44. package/dist/cjs/permissionless/api/index.js +31 -0
  45. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +637 -65
  46. package/dist/cjs/permissionless/api/oracles/enrich.js +99 -0
  47. package/dist/cjs/permissionless/api/oracles/index.js +33 -0
  48. package/dist/cjs/permissionless/api/oracles/onchain-feed.js +25 -0
  49. package/dist/cjs/permissionless/api/oracles/schemas.js +84 -59
  50. package/dist/cjs/permissionless/api/oracles/score/formula.js +56 -0
  51. package/dist/cjs/permissionless/api/oracles/score/index.js +11 -0
  52. package/dist/cjs/permissionless/api/oracles/score/run.js +252 -0
  53. package/dist/cjs/permissionless/api/oracles/score/types.js +1 -0
  54. package/dist/cjs/permissionless/api/oracles/stress/classify.js +258 -0
  55. package/dist/cjs/permissionless/api/oracles/stress/index.js +24 -0
  56. package/dist/cjs/permissionless/api/oracles/stress/override.js +125 -0
  57. package/dist/cjs/permissionless/api/oracles/stress/run.js +485 -0
  58. package/dist/cjs/permissionless/api/oracles/stress/score.js +98 -0
  59. package/dist/cjs/permissionless/api/oracles/stress/types.js +1 -0
  60. package/dist/cjs/permissionless/api/schemas.js +0 -3
  61. package/dist/cjs/permissionless/api/transactions/InstanceOwnerTransactions.js +14 -3
  62. package/dist/cjs/permissionless/api/transactions/lp-price-feeds.js +10 -4
  63. package/dist/cjs/permissionless/bindings/bytecode-repository.js +8 -0
  64. package/dist/cjs/permissionless/bindings/governance/governor.js +1 -1
  65. package/dist/cjs/permissionless/bindings/index.js +8 -3
  66. package/dist/cjs/permissionless/bindings/kill-switch-proxy.js +188 -0
  67. package/dist/cjs/permissionless/bindings/market-configurator-factory.js +39 -1
  68. package/dist/cjs/permissionless/bindings/market-configurator.js +142 -0
  69. package/dist/cjs/permissionless/index.js +42 -3
  70. package/dist/cjs/permissionless/utils/index.js +3 -0
  71. package/dist/cjs/permissionless/utils/literals.js +2 -0
  72. package/dist/cjs/permissionless/utils/price-update/get-prices.js +64 -0
  73. package/dist/cjs/permissionless/utils/price-update/index.js +2 -0
  74. package/dist/cjs/sdk/GearboxSDK.js +0 -9
  75. package/dist/cjs/sdk/prepare/PrepareApi.js +39 -0
  76. package/dist/cjs/sdk/preview/PreviewNamespace.js +33 -0
  77. package/dist/cjs/testnets/TestnetsAPI.js +179 -0
  78. package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
  79. package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
  80. package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
  81. package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
  82. package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
  83. package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
  84. package/dist/cjs/testnets/errors/index.js +13 -0
  85. package/dist/cjs/testnets/index.js +32 -0
  86. package/dist/cjs/testnets/package.json +1 -0
  87. package/dist/cjs/testnets/schemas.js +242 -0
  88. package/dist/cjs/testnets/types.js +1 -0
  89. package/dist/esm/abi/310/iKillSwitchProxy.js +129 -0
  90. package/dist/esm/model/index.js +2 -3
  91. package/dist/esm/offchain/GearboxAPI.js +0 -7
  92. package/dist/esm/offchain/index.js +1 -3
  93. package/dist/esm/onchain/accounts/intents/index.js +2 -1
  94. package/dist/esm/onchain/accounts/intents/operations.js +20 -1
  95. package/dist/esm/onchain/accounts/intents/plan.js +33 -1
  96. package/dist/esm/onchain/accounts/intents/realize.js +46 -2
  97. package/dist/esm/onchain/accounts/intents/testing/market.js +1 -0
  98. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +2 -1
  99. package/dist/esm/onchain/accounts/intents/utils/ledger.js +8 -0
  100. package/dist/esm/onchain/chain/chains.js +4 -0
  101. package/dist/esm/onchain/index.js +16 -1
  102. package/dist/esm/onchain/market/adapters/abi/aave/iAaveHorizonBridge.js +93 -0
  103. package/dist/esm/onchain/market/adapters/abi/aave/iAaveV3Pool.js +111 -0
  104. package/dist/esm/onchain/market/adapters/abi/aave/index.js +3 -0
  105. package/dist/esm/onchain/market/adapters/abi/actionAbi.js +1 -0
  106. package/dist/esm/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +196 -0
  107. package/dist/esm/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.js +176 -0
  108. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.js +112 -0
  109. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.js +257 -0
  110. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.js +160 -0
  111. package/dist/esm/onchain/market/adapters/abi/adapters/index.js +6 -1
  112. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +2 -0
  113. package/dist/esm/onchain/market/adapters/abi/index.js +13 -1
  114. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.js +38 -0
  115. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.js +229 -0
  116. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseRouter.js +28 -0
  117. package/dist/esm/onchain/market/adapters/abi/treehouse/index.js +4 -0
  118. package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +129 -0
  119. package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +204 -0
  120. package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +8 -0
  121. package/dist/esm/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.js +71 -0
  122. package/dist/esm/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.js +116 -0
  123. package/dist/esm/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.js +60 -0
  124. package/dist/esm/onchain/market/adapters/contracts/index.js +6 -1
  125. package/dist/esm/onchain/market/adapters/createAdapter.js +10 -0
  126. package/dist/esm/onchain/market/adapters/index.js +16 -1
  127. package/dist/esm/onchain/market/adapters/types.js +2 -0
  128. package/dist/esm/onchain/market/index.js +16 -1
  129. package/dist/esm/onchain/positions/projectAavePosition.js +39 -0
  130. package/dist/esm/onchain/preview/preview/loadAdapterReplayState.js +16 -0
  131. package/dist/esm/onchain/preview/preview/previewOperation.js +2 -0
  132. package/dist/esm/permissionless/api/index.js +7 -1
  133. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +639 -67
  134. package/dist/esm/permissionless/api/oracles/enrich.js +94 -0
  135. package/dist/esm/permissionless/api/oracles/index.js +10 -1
  136. package/dist/esm/permissionless/api/oracles/onchain-feed.js +24 -0
  137. package/dist/esm/permissionless/api/oracles/schemas.js +80 -58
  138. package/dist/esm/permissionless/api/oracles/score/formula.js +51 -0
  139. package/dist/esm/permissionless/api/oracles/score/index.js +4 -0
  140. package/dist/esm/permissionless/api/oracles/score/run.js +250 -0
  141. package/dist/esm/permissionless/api/oracles/score/types.js +1 -0
  142. package/dist/esm/permissionless/api/oracles/stress/classify.js +256 -0
  143. package/dist/esm/permissionless/api/oracles/stress/index.js +6 -0
  144. package/dist/esm/permissionless/api/oracles/stress/override.js +119 -0
  145. package/dist/esm/permissionless/api/oracles/stress/run.js +478 -0
  146. package/dist/esm/permissionless/api/oracles/stress/score.js +95 -0
  147. package/dist/esm/permissionless/api/oracles/stress/types.js +1 -0
  148. package/dist/esm/permissionless/api/schemas.js +2 -4
  149. package/dist/esm/permissionless/api/transactions/InstanceOwnerTransactions.js +14 -3
  150. package/dist/esm/permissionless/api/transactions/lp-price-feeds.js +10 -4
  151. package/dist/esm/permissionless/bindings/bytecode-repository.js +8 -0
  152. package/dist/esm/permissionless/bindings/governance/governor.js +1 -1
  153. package/dist/esm/permissionless/bindings/index.js +5 -4
  154. package/dist/esm/permissionless/bindings/kill-switch-proxy.js +184 -0
  155. package/dist/esm/permissionless/bindings/market-configurator-factory.js +37 -0
  156. package/dist/esm/permissionless/bindings/market-configurator.js +143 -1
  157. package/dist/esm/permissionless/index.js +13 -6
  158. package/dist/esm/permissionless/utils/index.js +3 -3
  159. package/dist/esm/permissionless/utils/literals.js +2 -1
  160. package/dist/esm/permissionless/utils/price-update/get-prices.js +63 -1
  161. package/dist/esm/permissionless/utils/price-update/index.js +2 -2
  162. package/dist/esm/sdk/GearboxSDK.js +0 -9
  163. package/dist/esm/sdk/prepare/PrepareApi.js +39 -0
  164. package/dist/esm/sdk/preview/PreviewNamespace.js +33 -0
  165. package/dist/esm/testnets/TestnetsAPI.js +178 -0
  166. package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
  167. package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
  168. package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
  169. package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
  170. package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
  171. package/dist/esm/testnets/errors/TestnetsError.js +33 -0
  172. package/dist/esm/testnets/errors/index.js +7 -0
  173. package/dist/esm/testnets/index.js +11 -0
  174. package/dist/esm/testnets/package.json +1 -0
  175. package/dist/esm/testnets/schemas.js +228 -0
  176. package/dist/esm/testnets/types.js +1 -0
  177. package/dist/types/abi/310/iKillSwitchProxy.d.ts +114 -0
  178. package/dist/types/model/aave.d.ts +32 -0
  179. package/dist/types/model/analytics.d.ts +2 -2
  180. package/dist/types/model/index.d.ts +6 -7
  181. package/dist/types/model/opportunities.d.ts +1 -1
  182. package/dist/types/model/positions.d.ts +1 -1
  183. package/dist/types/model/previews.d.ts +15 -0
  184. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
  185. package/dist/types/offchain/GearboxAPI.d.ts +0 -6
  186. package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +1 -1
  187. package/dist/types/offchain/analytics/types.d.ts +1 -1
  188. package/dist/types/offchain/index.d.ts +1 -3
  189. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -1
  190. package/dist/types/offchain/opportunities/types.d.ts +1 -1
  191. package/dist/types/offchain/positions/OffchainPositions.d.ts +1 -1
  192. package/dist/types/offchain/positions/types.d.ts +1 -1
  193. package/dist/types/onchain/accounts/intents/operations.d.ts +37 -1
  194. package/dist/types/onchain/accounts/intents/plan.d.ts +26 -1
  195. package/dist/types/onchain/accounts/intents/testing/market.d.ts +4 -0
  196. package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +4 -0
  197. package/dist/types/onchain/accounts/intents/types.d.ts +20 -1
  198. package/dist/types/onchain/index.d.ts +16 -1
  199. package/dist/types/onchain/market/adapters/abi/aave/iAaveHorizonBridge.d.ts +83 -0
  200. package/dist/types/onchain/market/adapters/abi/aave/iAaveV3Pool.d.ts +90 -0
  201. package/dist/types/onchain/market/adapters/abi/aave/index.d.ts +3 -0
  202. package/dist/types/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.d.ts +186 -0
  203. package/dist/types/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.d.ts +172 -0
  204. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.d.ts +101 -0
  205. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.d.ts +237 -0
  206. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.d.ts +146 -0
  207. package/dist/types/onchain/market/adapters/abi/adapters/index.d.ts +6 -1
  208. package/dist/types/onchain/market/adapters/abi/index.d.ts +13 -1
  209. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.d.ts +33 -0
  210. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.d.ts +207 -0
  211. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseRouter.d.ts +27 -0
  212. package/dist/types/onchain/market/adapters/abi/treehouse/index.d.ts +4 -0
  213. package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +312 -0
  214. package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +312 -0
  215. package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +8 -0
  216. package/dist/types/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.d.ts +156 -0
  217. package/dist/types/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.d.ts +481 -0
  218. package/dist/types/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.d.ts +193 -0
  219. package/dist/types/onchain/market/adapters/contracts/index.d.ts +6 -1
  220. package/dist/types/onchain/market/adapters/index.d.ts +16 -1
  221. package/dist/types/onchain/market/adapters/types.d.ts +3 -1
  222. package/dist/types/onchain/market/index.d.ts +16 -1
  223. package/dist/types/onchain/positions/projectAavePosition.d.ts +16 -0
  224. package/dist/types/onchain/preview/preview/loadAdapterReplayState.d.ts +13 -0
  225. package/dist/types/permissionless/api/index.d.ts +10 -2
  226. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +237 -47
  227. package/dist/types/permissionless/api/oracles/enrich.d.ts +59 -0
  228. package/dist/types/permissionless/api/oracles/index.d.ts +12 -2
  229. package/dist/types/permissionless/api/oracles/onchain-feed.d.ts +15 -0
  230. package/dist/types/permissionless/api/oracles/schemas.d.ts +147 -41
  231. package/dist/types/permissionless/api/oracles/score/formula.d.ts +36 -0
  232. package/dist/types/permissionless/api/oracles/score/index.d.ts +4 -0
  233. package/dist/types/permissionless/api/oracles/score/run.d.ts +42 -0
  234. package/dist/types/permissionless/api/oracles/score/types.d.ts +118 -0
  235. package/dist/types/permissionless/api/oracles/stress/classify.d.ts +57 -0
  236. package/dist/types/permissionless/api/oracles/stress/index.d.ts +6 -0
  237. package/dist/types/permissionless/api/oracles/stress/override.d.ts +59 -0
  238. package/dist/types/permissionless/api/oracles/stress/run.d.ts +100 -0
  239. package/dist/types/permissionless/api/oracles/stress/score.d.ts +57 -0
  240. package/dist/types/permissionless/api/oracles/stress/types.d.ts +272 -0
  241. package/dist/types/permissionless/api/oracles/types.d.ts +320 -125
  242. package/dist/types/permissionless/api/schemas.d.ts +0 -2
  243. package/dist/types/permissionless/api/transactions/lp-price-feeds.d.ts +9 -1
  244. package/dist/types/permissionless/bindings/bytecode-repository.d.ts +10 -1
  245. package/dist/types/permissionless/bindings/index.d.ts +4 -3
  246. package/dist/types/permissionless/bindings/kill-switch-proxy.d.ts +205 -0
  247. package/dist/types/permissionless/bindings/market-configurator-factory.d.ts +30 -0
  248. package/dist/types/permissionless/bindings/market-configurator.d.ts +30 -1
  249. package/dist/types/permissionless/bindings/types.d.ts +27 -0
  250. package/dist/types/permissionless/index.d.ts +15 -6
  251. package/dist/types/permissionless/utils/index.d.ts +3 -3
  252. package/dist/types/permissionless/utils/literals.d.ts +1 -0
  253. package/dist/types/permissionless/utils/price-update/get-prices.d.ts +33 -0
  254. package/dist/types/permissionless/utils/price-update/index.d.ts +2 -2
  255. package/dist/types/sdk/GearboxSDK.d.ts +1 -8
  256. package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +1 -1
  257. package/dist/types/sdk/analytics/types.d.ts +1 -1
  258. package/dist/types/sdk/index.d.ts +3 -3
  259. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
  260. package/dist/types/sdk/opportunities/types.d.ts +1 -1
  261. package/dist/types/sdk/positions/PositionsNamespace.d.ts +1 -1
  262. package/dist/types/sdk/positions/types.d.ts +1 -1
  263. package/dist/types/sdk/prepare/PrepareApi.d.ts +11 -3
  264. package/dist/types/sdk/prepare/index.d.ts +2 -2
  265. package/dist/types/sdk/prepare/types.d.ts +56 -1
  266. package/dist/types/sdk/preview/PreviewNamespace.d.ts +5 -1
  267. package/dist/types/sdk/preview/types.d.ts +10 -1
  268. package/dist/types/sdk/types.d.ts +0 -20
  269. package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
  270. package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
  271. package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
  272. package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
  273. package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
  274. package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
  275. package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
  276. package/dist/types/testnets/errors/index.d.ts +7 -0
  277. package/dist/types/testnets/index.d.ts +11 -0
  278. package/dist/types/testnets/schemas.d.ts +554 -0
  279. package/dist/types/testnets/types.d.ts +717 -0
  280. package/package.json +6 -1
  281. package/dist/cjs/model/notices.schema.js +0 -25
  282. package/dist/cjs/offchain/notices/OffchainNotices.js +0 -27
  283. package/dist/cjs/offchain/notices/index.js +0 -3
  284. package/dist/esm/model/notices.schema.js +0 -23
  285. package/dist/esm/offchain/notices/OffchainNotices.js +0 -26
  286. package/dist/esm/offchain/notices/index.js +0 -1
  287. package/dist/types/model/notices.d.ts +0 -28
  288. package/dist/types/model/notices.schema.d.ts +0 -22
  289. package/dist/types/offchain/notices/OffchainNotices.d.ts +0 -18
  290. package/dist/types/offchain/notices/index.d.ts +0 -2
  291. /package/dist/cjs/model/{notices.js → aave.js} +0 -0
  292. /package/dist/esm/model/{notices.js → aave.js} +0 -0
@@ -0,0 +1,59 @@
1
+ import { PermissionlessAssetQuota, PermissionlessIndexedAssetSummary, PermissionlessQuotaTotals, PriceFeedPrice } from "./types.js";
2
+ import { Address } from "viem";
3
+ //#region src/permissionless/api/oracles/enrich.d.ts
4
+ /**
5
+ * What the oracles namespace works out for itself once the backend has
6
+ * answered.
7
+ *
8
+ * All of it used to be the backend's, and all of it needs the chain: a quota
9
+ * is denominated in its market's own underlying and a market cap is a supply
10
+ * times a price, so none of these can be indexed — they can only be read at
11
+ * the block the reader is on. Keeping them here means one description of each
12
+ * rule rather than one per service that wants it, and a backend that holds no
13
+ * viem client at all.
14
+ **/
15
+ /** Identifies a feed across chains, since an address alone does not. */
16
+ export declare function feedKey(chainId: number, address: Address): string;
17
+ /** Prices looked up the way {@link totalQuotas} and the caps need them. */
18
+ export declare function pricesByFeed(prices: PriceFeedPrice[]): Map<string, bigint | null>;
19
+ /**
20
+ * The asset's quota across its markets, totalled in USD.
21
+ *
22
+ * Each market's figures are converted at the price that market's own oracle
23
+ * holds for its underlying, which is the same number that market's accounting
24
+ * uses.
25
+ *
26
+ * Limits count only the markets still running, because a shut down market's
27
+ * limit is not borrowable; what is already quoted counts everywhere, because
28
+ * debt outstanding is exposure either way. A market whose underlying could not
29
+ * be priced is skipped, which makes both figures floors, and `null` is nothing
30
+ * to total rather than a zero.
31
+ *
32
+ * @param priceOf - The price each underlying feed reports, in the 8 decimals
33
+ * every Gearbox feed uses.
34
+ */
35
+ export declare function totalQuotas(quotas: PermissionlessAssetQuota[], priceOf: (feed: Address) => bigint | null | undefined): PermissionlessQuotaTotals;
36
+ /**
37
+ * What one feed values one asset's supply at: `price × totalSupply`.
38
+ *
39
+ * Multiplied as integers and formatted once, rather than through two floats:
40
+ * an 8-decimal price times an 18-decimal supply loses its small end to a JS
41
+ * number long before it loses the large one, and the figure is a total rather
42
+ * than an estimate.
43
+ *
44
+ * `null` if either side could not be read — an asset nobody could price is
45
+ * not an asset worth nothing.
46
+ */
47
+ export declare function toCap(price: bigint | null | undefined, totalSupply: bigint | null | undefined, decimals: number): string | null;
48
+ /**
49
+ * Assets ordered the way a reader scans them: what the protocol is built on
50
+ * first, then what is actually borrowed against it, then what it is merely
51
+ * allowed to be borrowed against.
52
+ *
53
+ * Applied here and not by the backend because the two middle terms are the
54
+ * converted quotas, which only exist once the chain has been read. The
55
+ * backend orders by the first term and the tie-breakers, so a caller reading
56
+ * the route directly still gets a stable order; this refines it.
57
+ */
58
+ export declare function byCentrality<T extends PermissionlessIndexedAssetSummary & PermissionlessQuotaTotals>(a: T, b: T): number;
59
+ //#endregion
@@ -1,3 +1,13 @@
1
- import { AssetArgs, GetPricesArgs, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetPrices, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs } from "./types.js";
1
+ import { AssetScore, AssetScoresArgs, FeedPairScore, FeedPairScoreArgs, GroupImpact, MarketScore, ScoredFeed } from "./score/types.js";
2
+ import { BreakingPoint, FeedOutcome, GroupReport, GroupScenarioOutcome, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs } from "./stress/types.js";
3
+ import { AssetArgs, AssetCap, AssetsArgs, FeedCap, MarketCap, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessMarketSlot, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PriceFeedArgs, PriceFeedDecimals, PriceFeedPrice, PriceFeedRef } from "./types.js";
2
4
  import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./PermissionlessOracles.js";
3
- export { AssetArgs, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GetPricesArgs, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetPrices, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs };
5
+ import { SCORE_MULTIPLIER, factorOf, finalPrice, scoreOfFactor, worstOf } from "./score/formula.js";
6
+ import { runAssetScores, runFeedPairScore } from "./score/run.js";
7
+ import "./score/index.js";
8
+ import { TreeNode, classifySources, sourcesByFeed } from "./stress/classify.js";
9
+ import { UNBOUNDED_DOWN, UNBOUNDED_UP, groupOverride, perturb, rateStub, roundDataStub } from "./stress/override.js";
10
+ import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readFeedTrees, readForest, readRateTargets, readUnder, runStressTest } from "./stress/run.js";
11
+ import { scoreGroup, slotHarm, verdictOf } from "./stress/score.js";
12
+ import "./stress/index.js";
13
+ export { AssetArgs, AssetCap, AssetScore, AssetScoresArgs, AssetsArgs, BreakingPoint, DEFAULT_SCENARIOS, FeedCap, FeedOutcome, FeedPairScore, FeedPairScoreArgs, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GroupImpact, GroupReport, GroupScenarioOutcome, MarketCap, MarketScore, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessMarketSlot, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PriceFeedArgs, PriceFeedDecimals, PriceFeedPrice, PriceFeedRef, RATE_FEED_TYPE, SCORE_MULTIPLIER, ScoredFeed, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs, TreeNode, UNBOUNDED_DOWN, UNBOUNDED_UP, classifySources, factorOf, finalPrice, groupOverride, perturb, rateStub, readFeedTrees, readForest, readRateTargets, readUnder, roundDataStub, runAssetScores, runFeedPairScore, runStressTest, scoreGroup, scoreOfFactor, slotHarm, sourcesByFeed, verdictOf, worstOf };
@@ -0,0 +1,15 @@
1
+ import { PriceFeed } from "../../core/pricefeed.js";
2
+ import { TreeNode } from "./stress/classify.js";
3
+ //#region src/permissionless/api/oracles/onchain-feed.d.ts
4
+ /**
5
+ * What the store would say about a feed, from what the chain says instead.
6
+ *
7
+ * Two fields are the store's alone and are answered as unknown rather than
8
+ * guessed: who deployed it is a store row, so it is the zero address, and the
9
+ * staleness period is a store setting a feed that was never added does not
10
+ * have, so it is 0. The compressor reports `PRICE_FEED::EXTERNAL` for a
11
+ * contract it cannot otherwise place; an empty type is the same thing said
12
+ * less clearly.
13
+ */
14
+ export declare function onchainPriceFeed(node: TreeNode): PriceFeed;
15
+ //#endregion
@@ -17,7 +17,18 @@ export declare const priceFeedSchema: z.ZodObject<{
17
17
  stalenessPeriod: z.ZodNumber;
18
18
  name: z.ZodString;
19
19
  }, z.core.$loose>;
20
- /** {@link PermissionlessAsset} */
20
+ /**
21
+ * {@link PermissionlessPriceFeedAsset}
22
+ *
23
+ * What identifies an asset, which is all a feed's own listing of one says.
24
+ **/
25
+ export declare const priceFeedAssetSchema: z.ZodObject<{
26
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
27
+ symbol: z.ZodString;
28
+ name: z.ZodString;
29
+ decimals: z.ZodNumber;
30
+ }, z.core.$loose>;
31
+ /** {@link PermissionlessAsset} — identified as above, plus what prices it. */
21
32
  export declare const assetSchema: z.ZodObject<{
22
33
  address: z.ZodCustom<`0x${string}`, `0x${string}`>;
23
34
  symbol: z.ZodString;
@@ -33,7 +44,12 @@ export declare const assetSchema: z.ZodObject<{
33
44
  name: z.ZodString;
34
45
  }, z.core.$loose>>;
35
46
  }, z.core.$loose>;
36
- /** {@link PermissionlessPriceFeedStore} */
47
+ /**
48
+ * {@link PermissionlessPriceFeedStore}
49
+ *
50
+ * A store is a chain's, and is described by the same five fields the chain
51
+ * list answers with, so those are extended rather than restated.
52
+ **/
37
53
  export declare const priceFeedStoreSchema: z.ZodObject<{
38
54
  chainId: z.ZodNumber;
39
55
  name: z.ZodString;
@@ -64,35 +80,103 @@ export declare const priceFeedStoreSchema: z.ZodObject<{
64
80
  name: z.ZodString;
65
81
  }, z.core.$loose>>;
66
82
  }, z.core.$loose>;
67
- /** {@link PermissionlessPrices} */
68
- export declare const pricesSchema: z.ZodObject<{
69
- prices: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
70
- marketCaps: z.ZodType<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown>>;
71
- time: z.ZodNumber;
72
- }, z.core.$loose>;
73
- /** {@link PermissionlessPriceFeedAsset} */
74
- export declare const priceFeedAssetSchema: z.ZodObject<{
75
- address: z.ZodCustom<`0x${string}`, `0x${string}`>;
76
- symbol: z.ZodString;
83
+ /** Every chain's {@link PermissionlessPriceFeedStore}, one per chain. */
84
+ export declare const priceFeedStoresSchema: z.ZodArray<z.ZodObject<{
85
+ chainId: z.ZodNumber;
77
86
  name: z.ZodString;
78
- decimals: z.ZodNumber;
79
- }, z.core.$loose>;
80
- /** {@link PermissionlessPriceFeedMarket} */
87
+ isPublic: z.ZodBoolean;
88
+ isActivated: z.ZodBoolean;
89
+ explorerUrl: z.ZodString;
90
+ assets: z.ZodArray<z.ZodObject<{
91
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
92
+ symbol: z.ZodString;
93
+ name: z.ZodString;
94
+ decimals: z.ZodNumber;
95
+ owner: z.ZodCustom<`0x${string}`, `0x${string}`>;
96
+ priceFeeds: z.ZodArray<z.ZodObject<{
97
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
98
+ contractType: z.ZodString;
99
+ version: z.ZodNumber;
100
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
101
+ stalenessPeriod: z.ZodNumber;
102
+ name: z.ZodString;
103
+ }, z.core.$loose>>;
104
+ }, z.core.$loose>>;
105
+ priceFeeds: z.ZodArray<z.ZodObject<{
106
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
107
+ contractType: z.ZodString;
108
+ version: z.ZodNumber;
109
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
110
+ stalenessPeriod: z.ZodNumber;
111
+ name: z.ZodString;
112
+ }, z.core.$loose>>;
113
+ }, z.core.$loose>>;
114
+ /**
115
+ * {@link PermissionlessIndexedPriceFeedMarket} — the market as the feed's slot
116
+ * in it, before the oracle is asked what period it holds for the slot.
117
+ **/
81
118
  export declare const priceFeedMarketSchema: z.ZodObject<{
82
119
  market: z.ZodCustom<`0x${string}`, `0x${string}`>;
83
120
  marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
84
121
  curatorName: z.ZodNullable<z.ZodString>;
85
122
  marketName: z.ZodNullable<z.ZodString>;
123
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
124
+ isUnderlying: z.ZodBoolean;
125
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
126
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
86
127
  token: z.ZodCustom<`0x${string}`, `0x${string}`>;
87
128
  tokenSymbol: z.ZodNullable<z.ZodString>;
88
- underlyingSymbol: z.ZodNullable<z.ZodString>;
89
129
  reserve: z.ZodBoolean;
130
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
131
+ }, z.core.$loose>;
132
+ /**
133
+ * {@link PermissionlessMarketSlot} — the same slot read from the chain's end,
134
+ * so the feed is a column rather than what was asked for.
135
+ **/
136
+ export declare const marketSlotSchema: z.ZodObject<{
137
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
138
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
139
+ curatorName: z.ZodNullable<z.ZodString>;
140
+ marketName: z.ZodNullable<z.ZodString>;
141
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
90
142
  isUnderlying: z.ZodBoolean;
91
143
  quotaLimit: z.ZodNullable<z.ZodNumber>;
92
144
  quotaUsed: z.ZodNullable<z.ZodNumber>;
93
- marketStalenessPeriod: z.ZodNullable<z.ZodNumber>;
145
+ token: z.ZodCustom<`0x${string}`, `0x${string}`>;
146
+ tokenSymbol: z.ZodNullable<z.ZodString>;
147
+ reserve: z.ZodBoolean;
148
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
149
+ chainId: z.ZodNumber;
150
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
151
+ isShutdown: z.ZodBoolean;
152
+ priceFeed: z.ZodCustom<`0x${string}`, `0x${string}`>;
153
+ priceFeedName: z.ZodNullable<z.ZodString>;
154
+ priceFeedInStore: z.ZodBoolean;
155
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
94
156
  }, z.core.$loose>;
95
- /** {@link PermissionlessPriceFeedDetails} */
157
+ /** Every slot in scope, across whichever chains the read covered. */
158
+ export declare const marketSlotsSchema: z.ZodArray<z.ZodObject<{
159
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
160
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
161
+ curatorName: z.ZodNullable<z.ZodString>;
162
+ marketName: z.ZodNullable<z.ZodString>;
163
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
164
+ isUnderlying: z.ZodBoolean;
165
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
166
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
167
+ token: z.ZodCustom<`0x${string}`, `0x${string}`>;
168
+ tokenSymbol: z.ZodNullable<z.ZodString>;
169
+ reserve: z.ZodBoolean;
170
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
171
+ chainId: z.ZodNumber;
172
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
173
+ isShutdown: z.ZodBoolean;
174
+ priceFeed: z.ZodCustom<`0x${string}`, `0x${string}`>;
175
+ priceFeedName: z.ZodNullable<z.ZodString>;
176
+ priceFeedInStore: z.ZodBoolean;
177
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
178
+ }, z.core.$loose>>;
179
+ /** {@link PermissionlessIndexedPriceFeedDetails} */
96
180
  export declare const priceFeedDetailsSchema: z.ZodObject<{
97
181
  chainId: z.ZodNumber;
98
182
  priceFeed: z.ZodObject<{
@@ -114,36 +198,34 @@ export declare const priceFeedDetailsSchema: z.ZodObject<{
114
198
  marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
115
199
  curatorName: z.ZodNullable<z.ZodString>;
116
200
  marketName: z.ZodNullable<z.ZodString>;
117
- token: z.ZodCustom<`0x${string}`, `0x${string}`>;
118
- tokenSymbol: z.ZodNullable<z.ZodString>;
119
201
  underlyingSymbol: z.ZodNullable<z.ZodString>;
120
- reserve: z.ZodBoolean;
121
202
  isUnderlying: z.ZodBoolean;
122
203
  quotaLimit: z.ZodNullable<z.ZodNumber>;
123
204
  quotaUsed: z.ZodNullable<z.ZodNumber>;
124
- marketStalenessPeriod: z.ZodNullable<z.ZodNumber>;
205
+ token: z.ZodCustom<`0x${string}`, `0x${string}`>;
206
+ tokenSymbol: z.ZodNullable<z.ZodString>;
207
+ reserve: z.ZodBoolean;
208
+ priceOracle: z.ZodCustom<`0x${string}`, `0x${string}`>;
125
209
  }, z.core.$loose>>;
126
210
  }, z.core.$loose>;
127
- /** {@link PermissionlessPriceFeedMarketCaps} */
128
- export declare const priceFeedMarketCapsSchema: z.ZodObject<{
129
- marketCaps: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
130
- time: z.ZodNumber;
131
- }, z.core.$loose>;
132
211
  /** {@link PermissionlessAssetMarketFeed} */
133
212
  export declare const assetMarketFeedSchema: z.ZodObject<{
134
213
  address: z.ZodCustom<`0x${string}`, `0x${string}`>;
135
214
  name: z.ZodNullable<z.ZodString>;
136
215
  inStore: z.ZodBoolean;
137
216
  }, z.core.$loose>;
138
- /** {@link PermissionlessAssetMarket} */
217
+ /** {@link PermissionlessAssetMarket} — the market as what prices the asset in it. */
139
218
  export declare const assetMarketSchema: z.ZodObject<{
140
219
  market: z.ZodCustom<`0x${string}`, `0x${string}`>;
141
220
  marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
142
221
  curatorName: z.ZodNullable<z.ZodString>;
143
222
  marketName: z.ZodNullable<z.ZodString>;
144
- underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
145
223
  underlyingSymbol: z.ZodNullable<z.ZodString>;
146
224
  isUnderlying: z.ZodBoolean;
225
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
226
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
227
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
228
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
147
229
  isShutdown: z.ZodBoolean;
148
230
  mainFeed: z.ZodNullable<z.ZodObject<{
149
231
  address: z.ZodCustom<`0x${string}`, `0x${string}`>;
@@ -155,10 +237,8 @@ export declare const assetMarketSchema: z.ZodObject<{
155
237
  name: z.ZodNullable<z.ZodString>;
156
238
  inStore: z.ZodBoolean;
157
239
  }, z.core.$loose>>;
158
- quotaLimit: z.ZodNullable<z.ZodNumber>;
159
- quotaUsed: z.ZodNullable<z.ZodNumber>;
160
240
  }, z.core.$loose>;
161
- /** {@link PermissionlessAssetDetails} */
241
+ /** {@link PermissionlessIndexedAssetDetails} */
162
242
  export declare const assetDetailsSchema: z.ZodObject<{
163
243
  chainId: z.ZodNumber;
164
244
  asset: z.ZodObject<{
@@ -180,9 +260,12 @@ export declare const assetDetailsSchema: z.ZodObject<{
180
260
  marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
181
261
  curatorName: z.ZodNullable<z.ZodString>;
182
262
  marketName: z.ZodNullable<z.ZodString>;
183
- underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
184
263
  underlyingSymbol: z.ZodNullable<z.ZodString>;
185
264
  isUnderlying: z.ZodBoolean;
265
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
266
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
267
+ underlyingToken: z.ZodCustom<`0x${string}`, `0x${string}`>;
268
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
186
269
  isShutdown: z.ZodBoolean;
187
270
  mainFeed: z.ZodNullable<z.ZodObject<{
188
271
  address: z.ZodCustom<`0x${string}`, `0x${string}`>;
@@ -194,16 +277,39 @@ export declare const assetDetailsSchema: z.ZodObject<{
194
277
  name: z.ZodNullable<z.ZodString>;
195
278
  inStore: z.ZodBoolean;
196
279
  }, z.core.$loose>>;
280
+ }, z.core.$loose>>;
281
+ }, z.core.$loose>;
282
+ /** {@link PermissionlessAssetQuota} */
283
+ export declare const assetQuotaSchema: z.ZodObject<{
284
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
285
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
286
+ isShutdown: z.ZodBoolean;
287
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
288
+ }, z.core.$loose>;
289
+ /** {@link PermissionlessIndexedAssetSummary} */
290
+ export declare const assetSummarySchema: z.ZodObject<{
291
+ chainId: z.ZodNumber;
292
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
293
+ symbol: z.ZodString;
294
+ underlyingMarketCount: z.ZodNumber;
295
+ marketQuotas: z.ZodArray<z.ZodObject<{
197
296
  quotaLimit: z.ZodNullable<z.ZodNumber>;
198
297
  quotaUsed: z.ZodNullable<z.ZodNumber>;
298
+ isShutdown: z.ZodBoolean;
299
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
199
300
  }, z.core.$loose>>;
200
- quotaLimitUsd: z.ZodNullable<z.ZodNumber>;
201
- quotaUsedUsd: z.ZodNullable<z.ZodNumber>;
202
- }, z.core.$loose>;
203
- /** {@link PermissionlessAssetPrices} */
204
- export declare const assetPricesSchema: z.ZodObject<{
205
- prices: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
206
- marketCaps: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
207
- time: z.ZodNumber;
208
301
  }, z.core.$loose>;
302
+ /** The list of {@link PermissionlessAssetSummary}, already ordered. */
303
+ export declare const assetSummariesSchema: z.ZodArray<z.ZodObject<{
304
+ chainId: z.ZodNumber;
305
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
306
+ symbol: z.ZodString;
307
+ underlyingMarketCount: z.ZodNumber;
308
+ marketQuotas: z.ZodArray<z.ZodObject<{
309
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
310
+ quotaUsed: z.ZodNullable<z.ZodNumber>;
311
+ isShutdown: z.ZodBoolean;
312
+ underlyingPriceFeed: z.ZodNullable<z.ZodCustom<`0x${string}`, `0x${string}`>>;
313
+ }, z.core.$loose>>;
314
+ }, z.core.$loose>>;
209
315
  //#endregion
@@ -0,0 +1,36 @@
1
+ import { GroupImpact } from "./types.js";
2
+ //#region src/permissionless/api/oracles/score/formula.d.ts
3
+ /** What every source of a group is made to answer, as a multiple of now. */
4
+ export declare const SCORE_MULTIPLIER = 10;
5
+ /**
6
+ * How far the final price moved, as a multiple of where it was, either way:
7
+ * 1 for a price that did not move, 1.04 for one 4% off, and
8
+ * {@link SCORE_MULTIPLIER} for one that took the whole lie — the most it can
9
+ * take from one leg, and where a price over two legs of one group, moved
10
+ * further, is held too.
11
+ *
12
+ * `null` for a price that stopped answering, which is not a move.
13
+ */
14
+ export declare function scoreOfFactor(factor: number | null): number | null;
15
+ /**
16
+ * The price a market settles on: the lower of main and reserve, or the main
17
+ * feed's alone where there is no reserve to compare it with. `null` where a
18
+ * feed it needs does not answer.
19
+ */
20
+ export declare function finalPrice(main: bigint | null, reserve: bigint | null | undefined): bigint | null;
21
+ /** `stressed / base` as a float, `null` where the stressed price is gone. */
22
+ export declare function factorOf(base: bigint, stressed: bigint | null): number | null;
23
+ /**
24
+ * The market's score and the group it comes from: the furthest any group
25
+ * moved its price. 1 where nothing moved it — no group did, or no source
26
+ * feeds the price at all.
27
+ *
28
+ * A group under which the price stops answering moves nothing and does not
29
+ * set the score; it is listed after those that do, for a reader to see.
30
+ */
31
+ export declare function worstOf(impacts: GroupImpact[]): {
32
+ score: number;
33
+ impacts: GroupImpact[];
34
+ worst: GroupImpact | null;
35
+ };
36
+ //#endregion
@@ -0,0 +1,4 @@
1
+ import { AssetScore, AssetScoresArgs, FeedPairScore, FeedPairScoreArgs, GroupImpact, MarketScore, ScoredFeed } from "./types.js";
2
+ import { SCORE_MULTIPLIER, factorOf, finalPrice, scoreOfFactor, worstOf } from "./formula.js";
3
+ import { runAssetScores, runFeedPairScore } from "./run.js";
4
+ export { AssetScore, AssetScoresArgs, FeedPairScore, FeedPairScoreArgs, GroupImpact, MarketScore, SCORE_MULTIPLIER, ScoredFeed, factorOf, finalPrice, runAssetScores, runFeedPairScore, scoreOfFactor, worstOf };
@@ -0,0 +1,42 @@
1
+ import { AssetScore, FeedPairScore } from "./types.js";
2
+ import { PermissionlessMarketSlot } from "../types.js";
3
+ import { Address, Chain, PublicClient, Transport } from "viem";
4
+ //#region src/permissionless/api/oracles/score/run.d.ts
5
+ type Logger = {
6
+ warn(message: string): void;
7
+ };
8
+ /**
9
+ * Every asset of one chain, scored by what each of its source groups can do
10
+ * to the price its running markets hold for it.
11
+ *
12
+ * One read of the oracles' feed trees, then the simulation of every market's
13
+ * main and reserve pair at once — see {@link simulatePairs}.
14
+ **/
15
+ export declare function runAssetScores({ client, chainId, slots, compressor, logger }: {
16
+ client: PublicClient<Transport, Chain>;
17
+ chainId: number;
18
+ slots: PermissionlessMarketSlot[];
19
+ compressor: Address;
20
+ logger?: Logger;
21
+ }): Promise<AssetScore[]>;
22
+ /**
23
+ * Any main feed and reserve on a chain, scored the way a market holding them
24
+ * would be — whether or not any market does yet.
25
+ *
26
+ * The two trees are read off the compressor by feed rather than by oracle,
27
+ * so a feed the curator has only just deployed scores as well as one in use.
28
+ *
29
+ * @throws Where there is nothing to score: the compressor cannot read a
30
+ * feed, the main feed is a `ZeroPriceFeed`, or the final price does not
31
+ * answer even with every pull feed under it freshened.
32
+ **/
33
+ export declare function runFeedPairScore({ client, chainId, compressor, main, reserve, logger }: {
34
+ client: PublicClient<Transport, Chain>;
35
+ chainId: number;
36
+ compressor: Address;
37
+ main: Address;
38
+ reserve?: Address;
39
+ logger?: Logger;
40
+ }): Promise<FeedPairScore>;
41
+ //#endregion
42
+ export {};
@@ -0,0 +1,118 @@
1
+ import { Address } from "viem";
2
+ //#region src/permissionless/api/oracles/score/types.d.ts
3
+ /**
4
+ * One of a market's two feeds for a token, as the score reads it.
5
+ **/
6
+ export interface ScoredFeed {
7
+ feed: Address;
8
+ /**
9
+ * The store's name for the feed, `null` where it has none or where the
10
+ * feed was named by address alone, as a pair to score is.
11
+ */
12
+ name: string | null;
13
+ /** Gearbox contract type of the feed itself, `""` for one it never deployed. */
14
+ contractType: string;
15
+ /**
16
+ * Every source group beneath the feed: `"Chainlink"`, `"Lido"`, or the
17
+ * description of a source nothing could name.
18
+ */
19
+ sources: string[];
20
+ }
21
+ /**
22
+ * What one source group, lying, does to the price a market holds for an
23
+ * asset.
24
+ **/
25
+ export interface GroupImpact {
26
+ group: string;
27
+ /** The group was recognised rather than inferred from one feed's name. */
28
+ identified: boolean;
29
+ /**
30
+ * The group's sources this market's feeds read, by what they say they are:
31
+ * `"stETH / ETH"`, `"ETH / USD"`.
32
+ */
33
+ feeds: string[];
34
+ /** Which of the market's feeds read the group. */
35
+ reaches: "main" | "reserve" | "both";
36
+ /**
37
+ * The final price under the lie over the final price now, in USD. `null` is
38
+ * a price that stopped answering.
39
+ */
40
+ factor: number | null;
41
+ /** 1 to 10, by {@link scoreOfFactor}; `null` where the price stopped answering. */
42
+ score: number | null;
43
+ }
44
+ /**
45
+ * How far the price a main and a reserve feed give together can be pushed:
46
+ * their manipulation resistance, from 1 (does not move) to 10 (takes the
47
+ * whole lie).
48
+ *
49
+ * Every source group behind the two feeds is made, one group at a time, to
50
+ * answer {@link SCORE_MULTIPLIER} times what it answers now. The pair scores
51
+ * by the group that moves its final price — `min(main, reserve)` — the
52
+ * furthest, as a multiple either way.
53
+ **/
54
+ export interface FeedPairScore {
55
+ main: ScoredFeed;
56
+ /** `null` where there is no reserve at all. */
57
+ reserve: ScoredFeed | null;
58
+ /**
59
+ * The final price is `min(main, reserve)`: a reserve is present, is not a
60
+ * `ZeroPriceFeed`, and answers. Where it is not, the final price is the
61
+ * main feed's alone.
62
+ */
63
+ hasReserve: boolean;
64
+ /** The final price now, in USD. */
65
+ price: number;
66
+ /** Every group behind the two feeds, the most damaging first. */
67
+ impacts: GroupImpact[];
68
+ /** The group the score comes from; `null` where no group moves the price. */
69
+ worst: GroupImpact | null;
70
+ /**
71
+ * The score rests on a source nothing could name.
72
+ *
73
+ * Such a source is a group of its own and is perturbed alone, so where one
74
+ * feed reads it and the other does not, the other is taken to hold — which
75
+ * it would not if one operator stood behind both.
76
+ */
77
+ unverified: boolean;
78
+ score: number;
79
+ /** How the pair is set up, where that explains its score. */
80
+ notes: string[];
81
+ }
82
+ /** One market's price for one asset, scored as the pair of feeds it holds. */
83
+ export interface MarketScore extends FeedPairScore {
84
+ market: Address;
85
+ marketName: string | null;
86
+ marketConfigurator: Address;
87
+ curatorName: string | null;
88
+ }
89
+ /**
90
+ * One asset's score: its worst market's.
91
+ *
92
+ * The maximum, not an average, because the asset is only as well guarded as
93
+ * the most exposed market that prices it.
94
+ **/
95
+ export interface AssetScore {
96
+ chainId: number;
97
+ asset: Address;
98
+ symbol: string | null;
99
+ /** `null` for an asset no running market prices: it is switched off in all. */
100
+ score: number | null;
101
+ /** Some market's score rests on a source nothing could name. */
102
+ unverified: boolean;
103
+ /** The market the score comes from. */
104
+ worst: MarketScore | null;
105
+ /** Every running market pricing the asset, worst first. */
106
+ markets: MarketScore[];
107
+ }
108
+ export interface AssetScoresArgs {
109
+ /** Omitted scores every chain the backend serves markets for. */
110
+ chainId?: number;
111
+ }
112
+ export interface FeedPairScoreArgs {
113
+ chainId: number;
114
+ main: Address;
115
+ /** Omitted scores the main feed alone, as a market with no reserve. */
116
+ reserve?: Address;
117
+ }
118
+ //#endregion
@@ -0,0 +1,57 @@
1
+ import { StressSource } from "./types.js";
2
+ import { Address } from "viem";
3
+ //#region src/permissionless/api/oracles/stress/classify.d.ts
4
+ /**
5
+ * Who a price ultimately comes from, worked out from what the chain says
6
+ * about the feed reporting it.
7
+ *
8
+ * There is no registry on chain of which aggregator belongs to whom, so this
9
+ * is a reading of three things the chain does carry: the Gearbox contract
10
+ * type, which names the provider outright for the feeds Gearbox deploys; the
11
+ * `description()` every Chainlink-shaped feed returns; and the interface
12
+ * version, which separates Chainlink's own proxies from the many contracts
13
+ * that imitate them.
14
+ *
15
+ * Every rule is open to inspection and every unmatched feed is reported as
16
+ * unmatched, because the alternative — guessing from a symbol, or sweeping
17
+ * the remainder into one bucket — would understate exactly the part of the
18
+ * answer a reader should distrust.
19
+ **/
20
+ /** One node of an oracle's feed tree, as the compressor reports it. */
21
+ export interface TreeNode {
22
+ address: Address;
23
+ /** Gearbox contract type, `""` for a contract it never deployed. */
24
+ contractType: string;
25
+ /** `AggregatorV3Interface.version()`, or 0 where there is none. */
26
+ version: number;
27
+ description: string;
28
+ /** The feeds it reads, lowercased. Empty makes it a leaf. */
29
+ underlyingFeeds: Address[];
30
+ }
31
+ /**
32
+ * Every source behind a chain's feed trees.
33
+ *
34
+ * A source per contract, not per feed: two of an oracle's trees carrying the
35
+ * same aggregator is one source read twice, and the test varies it once.
36
+ *
37
+ * `rateTargets` says which contract each rate-bearing feed reads its rate
38
+ * from — the feed's own `lpContract`, read separately because the compressor
39
+ * does not report it. A feed missing from it is left out with a reason, since
40
+ * perturbing the whole feed instead would charge its protocol with a failure
41
+ * of whatever prices the thing the rate is denominated in.
42
+ **/
43
+ export declare function classifySources(chainId: number, nodes: TreeNode[], rateTargets: Map<Address, Address>, baselineOf: (target: Address) => bigint | null): {
44
+ sources: StressSource[];
45
+ unresolved: TreeNode[];
46
+ };
47
+ /**
48
+ * The sources each of the given feeds is priced through, following the trees
49
+ * down from every one of them.
50
+ *
51
+ * A feed is reached by a source when the source sits anywhere beneath it, at
52
+ * any depth: a market reading a composite of a composite of a Chainlink
53
+ * aggregator is a market Chainlink can move. Memoised over the whole forest,
54
+ * so a node shared by twenty trees is walked once.
55
+ **/
56
+ export declare function sourcesByFeed(roots: Address[], nodes: Map<Address, TreeNode>, sources: StressSource[]): Map<Address, Set<Address>>;
57
+ //#endregion
@@ -0,0 +1,6 @@
1
+ import { BreakingPoint, FeedOutcome, GroupReport, GroupScenarioOutcome, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs } from "./types.js";
2
+ import { TreeNode, classifySources, sourcesByFeed } from "./classify.js";
3
+ import { UNBOUNDED_DOWN, UNBOUNDED_UP, groupOverride, perturb, rateStub, roundDataStub } from "./override.js";
4
+ import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readFeedTrees, readForest, readRateTargets, readUnder, runStressTest } from "./run.js";
5
+ import { scoreGroup, slotHarm, verdictOf } from "./score.js";
6
+ export { BreakingPoint, DEFAULT_SCENARIOS, FeedOutcome, GroupReport, GroupScenarioOutcome, RATE_FEED_TYPE, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs, TreeNode, UNBOUNDED_DOWN, UNBOUNDED_UP, classifySources, groupOverride, perturb, rateStub, readFeedTrees, readForest, readRateTargets, readUnder, roundDataStub, runStressTest, scoreGroup, slotHarm, sourcesByFeed, verdictOf };