@symmio/trading-core 4.1.0 → 4.2.0

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 (239) hide show
  1. package/dist/index.d.ts +17 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +108 -87
  4. package/dist/pools/add-market/to-created-pool.d.ts.map +1 -1
  5. package/dist/pools/add-market/to-created-pool.js +4 -0
  6. package/dist/pools/add-market/to-created-pool.js.map +1 -1
  7. package/dist/pools/add-market/types.d.ts +8 -0
  8. package/dist/pools/add-market/types.d.ts.map +1 -1
  9. package/dist/pools/auth/authenticate-listing.d.ts +3 -1
  10. package/dist/pools/auth/authenticate-listing.d.ts.map +1 -1
  11. package/dist/pools/auth/authenticate-listing.js +28 -23
  12. package/dist/pools/auth/authenticate-listing.js.map +1 -1
  13. package/dist/pools/auth/can-reuse-listing-challenge.d.ts +5 -0
  14. package/dist/pools/auth/can-reuse-listing-challenge.d.ts.map +1 -0
  15. package/dist/pools/auth/can-reuse-listing-challenge.js +9 -0
  16. package/dist/pools/auth/can-reuse-listing-challenge.js.map +1 -0
  17. package/dist/pools/auth/query.d.ts +15 -0
  18. package/dist/pools/auth/query.d.ts.map +1 -1
  19. package/dist/pools/auth/query.js +28 -4
  20. package/dist/pools/auth/query.js.map +1 -1
  21. package/dist/pools/auth/to-siwe.d.ts +5 -1
  22. package/dist/pools/auth/to-siwe.d.ts.map +1 -1
  23. package/dist/pools/auth/to-siwe.js +4 -2
  24. package/dist/pools/auth/to-siwe.js.map +1 -1
  25. package/dist/pools/auth/types.d.ts +2 -0
  26. package/dist/pools/auth/types.d.ts.map +1 -1
  27. package/dist/pools/cancel-withdraw/cancel-withdraw.js +1 -1
  28. package/dist/pools/cancel-withdraw/cancel-withdraw.js.map +1 -1
  29. package/dist/pools/claim-history/get-pool-claim.d.ts +11 -0
  30. package/dist/pools/claim-history/get-pool-claim.d.ts.map +1 -0
  31. package/dist/pools/claim-history/get-pool-claim.js +25 -0
  32. package/dist/pools/claim-history/get-pool-claim.js.map +1 -0
  33. package/dist/pools/claim-history/index.d.ts +1 -0
  34. package/dist/pools/claim-history/index.d.ts.map +1 -1
  35. package/dist/pools/claim-history/to-pool-claim.d.ts.map +1 -1
  36. package/dist/pools/claim-history/to-pool-claim.js +2 -0
  37. package/dist/pools/claim-history/to-pool-claim.js.map +1 -1
  38. package/dist/pools/composition.d.ts +16 -0
  39. package/dist/pools/composition.d.ts.map +1 -0
  40. package/dist/pools/composition.js +39 -0
  41. package/dist/pools/composition.js.map +1 -0
  42. package/dist/pools/empty-pool-profit.d.ts +4 -0
  43. package/dist/pools/empty-pool-profit.d.ts.map +1 -0
  44. package/dist/pools/empty-pool-profit.js +17 -0
  45. package/dist/pools/empty-pool-profit.js.map +1 -0
  46. package/dist/pools/index.d.ts +8 -0
  47. package/dist/pools/index.d.ts.map +1 -1
  48. package/dist/pools/listing-config/to-listing-config.d.ts +5 -1
  49. package/dist/pools/listing-config/to-listing-config.d.ts.map +1 -1
  50. package/dist/pools/listing-config/to-listing-config.js +19 -8
  51. package/dist/pools/listing-config/to-listing-config.js.map +1 -1
  52. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts +37 -0
  53. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts.map +1 -0
  54. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js +35 -0
  55. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js.map +1 -0
  56. package/dist/pools/maintenance-fees/index.d.ts +3 -0
  57. package/dist/pools/maintenance-fees/index.d.ts.map +1 -0
  58. package/dist/pools/maintenance-fees/query.d.ts +11 -0
  59. package/dist/pools/maintenance-fees/query.d.ts.map +1 -0
  60. package/dist/pools/maintenance-fees/query.js +21 -0
  61. package/dist/pools/maintenance-fees/query.js.map +1 -0
  62. package/dist/pools/market-config/to-listing-market-config.d.ts +6 -1
  63. package/dist/pools/market-config/to-listing-market-config.d.ts.map +1 -1
  64. package/dist/pools/market-config/to-listing-market-config.js +1 -0
  65. package/dist/pools/market-config/to-listing-market-config.js.map +1 -1
  66. package/dist/pools/market-config/types.d.ts +5 -0
  67. package/dist/pools/market-config/types.d.ts.map +1 -1
  68. package/dist/pools/market-config/types.js.map +1 -1
  69. package/dist/pools/market-data/get-pool-market-data.d.ts +14 -0
  70. package/dist/pools/market-data/get-pool-market-data.d.ts.map +1 -0
  71. package/dist/pools/market-data/get-pool-market-data.js +25 -0
  72. package/dist/pools/market-data/get-pool-market-data.js.map +1 -0
  73. package/dist/pools/market-data/index.d.ts +2 -0
  74. package/dist/pools/market-data/index.d.ts.map +1 -0
  75. package/dist/pools/market-detail/to-listing-market-detail.d.ts +5 -1
  76. package/dist/pools/market-detail/to-listing-market-detail.d.ts.map +1 -1
  77. package/dist/pools/market-detail/to-listing-market-detail.js +45 -33
  78. package/dist/pools/market-detail/to-listing-market-detail.js.map +1 -1
  79. package/dist/pools/markets/to-listing-market.d.ts +13 -1
  80. package/dist/pools/markets/to-listing-market.d.ts.map +1 -1
  81. package/dist/pools/markets/to-listing-market.js +24 -12
  82. package/dist/pools/markets/to-listing-market.js.map +1 -1
  83. package/dist/pools/open-positions/calculate-pool-open-positions.d.ts +39 -0
  84. package/dist/pools/open-positions/calculate-pool-open-positions.d.ts.map +1 -0
  85. package/dist/pools/open-positions/calculate-pool-open-positions.js +83 -0
  86. package/dist/pools/open-positions/calculate-pool-open-positions.js.map +1 -0
  87. package/dist/pools/open-positions/get-pool-open-positions.d.ts +17 -0
  88. package/dist/pools/open-positions/get-pool-open-positions.d.ts.map +1 -0
  89. package/dist/pools/open-positions/get-pool-open-positions.js +39 -0
  90. package/dist/pools/open-positions/get-pool-open-positions.js.map +1 -0
  91. package/dist/pools/open-positions/index.d.ts +4 -0
  92. package/dist/pools/open-positions/index.d.ts.map +1 -0
  93. package/dist/pools/open-positions/query.d.ts +17 -0
  94. package/dist/pools/open-positions/query.d.ts.map +1 -0
  95. package/dist/pools/open-positions/query.js +21 -0
  96. package/dist/pools/open-positions/query.js.map +1 -0
  97. package/dist/pools/portfolio/calculate-pool-portfolio.d.ts +66 -0
  98. package/dist/pools/portfolio/calculate-pool-portfolio.d.ts.map +1 -0
  99. package/dist/pools/portfolio/calculate-pool-portfolio.js +96 -0
  100. package/dist/pools/portfolio/calculate-pool-portfolio.js.map +1 -0
  101. package/dist/pools/portfolio/get-pool-portfolio.d.ts +19 -0
  102. package/dist/pools/portfolio/get-pool-portfolio.d.ts.map +1 -0
  103. package/dist/pools/portfolio/get-pool-portfolio.js +88 -0
  104. package/dist/pools/portfolio/get-pool-portfolio.js.map +1 -0
  105. package/dist/pools/portfolio/index.d.ts +4 -0
  106. package/dist/pools/portfolio/index.d.ts.map +1 -0
  107. package/dist/pools/portfolio/query.d.ts +17 -0
  108. package/dist/pools/portfolio/query.d.ts.map +1 -0
  109. package/dist/pools/portfolio/query.js +21 -0
  110. package/dist/pools/portfolio/query.js.map +1 -0
  111. package/dist/pools/portfolio/read-positions.d.ts +4 -0
  112. package/dist/pools/portfolio/read-positions.d.ts.map +1 -0
  113. package/dist/pools/portfolio/read-positions.js +31 -0
  114. package/dist/pools/portfolio/read-positions.js.map +1 -0
  115. package/dist/pools/position/calculate-pool-position.d.ts +85 -0
  116. package/dist/pools/position/calculate-pool-position.d.ts.map +1 -0
  117. package/dist/pools/position/calculate-pool-position.js +59 -0
  118. package/dist/pools/position/calculate-pool-position.js.map +1 -0
  119. package/dist/pools/position/get-pool-position.d.ts +22 -0
  120. package/dist/pools/position/get-pool-position.d.ts.map +1 -0
  121. package/dist/pools/position/get-pool-position.js +47 -0
  122. package/dist/pools/position/get-pool-position.js.map +1 -0
  123. package/dist/pools/position/index.d.ts +4 -0
  124. package/dist/pools/position/index.d.ts.map +1 -0
  125. package/dist/pools/position/query.d.ts +17 -0
  126. package/dist/pools/position/query.d.ts.map +1 -0
  127. package/dist/pools/position/query.js +21 -0
  128. package/dist/pools/position/query.js.map +1 -0
  129. package/dist/pools/position/sum-deposits.d.ts +10 -0
  130. package/dist/pools/position/sum-deposits.d.ts.map +1 -0
  131. package/dist/pools/position/sum-deposits.js +35 -0
  132. package/dist/pools/position/sum-deposits.js.map +1 -0
  133. package/dist/pools/profit/get-user-profit.d.ts +4 -0
  134. package/dist/pools/profit/get-user-profit.d.ts.map +1 -1
  135. package/dist/pools/profit/get-user-profit.js +18 -12
  136. package/dist/pools/profit/get-user-profit.js.map +1 -1
  137. package/dist/pools/profit/to-user-pool-profit.d.ts +22 -4
  138. package/dist/pools/profit/to-user-pool-profit.d.ts.map +1 -1
  139. package/dist/pools/profit/to-user-pool-profit.js +28 -12
  140. package/dist/pools/profit/to-user-pool-profit.js.map +1 -1
  141. package/dist/pools/quotes/get-pool-quotes.d.ts +8 -1
  142. package/dist/pools/quotes/get-pool-quotes.d.ts.map +1 -1
  143. package/dist/pools/quotes/get-pool-quotes.js +8 -1
  144. package/dist/pools/quotes/get-pool-quotes.js.map +1 -1
  145. package/dist/pools/quotes/query-document.d.ts.map +1 -1
  146. package/dist/pools/quotes/query-document.js +1 -1
  147. package/dist/pools/quotes/query-document.js.map +1 -1
  148. package/dist/pools/quotes/to-pool-quote.d.ts.map +1 -1
  149. package/dist/pools/quotes/to-pool-quote.js +13 -0
  150. package/dist/pools/quotes/to-pool-quote.js.map +1 -1
  151. package/dist/pools/rewards/query.js +25 -25
  152. package/dist/pools/statistics/calculate-pool-statistics.d.ts +69 -0
  153. package/dist/pools/statistics/calculate-pool-statistics.d.ts.map +1 -0
  154. package/dist/pools/statistics/calculate-pool-statistics.js +42 -0
  155. package/dist/pools/statistics/calculate-pool-statistics.js.map +1 -0
  156. package/dist/pools/statistics/get-pool-statistics.d.ts +29 -0
  157. package/dist/pools/statistics/get-pool-statistics.d.ts.map +1 -0
  158. package/dist/pools/statistics/get-pool-statistics.js +61 -0
  159. package/dist/pools/statistics/get-pool-statistics.js.map +1 -0
  160. package/dist/pools/statistics/index.d.ts +4 -0
  161. package/dist/pools/statistics/index.d.ts.map +1 -0
  162. package/dist/pools/statistics/query.d.ts +17 -0
  163. package/dist/pools/statistics/query.d.ts.map +1 -0
  164. package/dist/pools/statistics/query.js +21 -0
  165. package/dist/pools/statistics/query.js.map +1 -0
  166. package/dist/pools/token-metadata/get-listing-token-metadata.d.ts +32 -0
  167. package/dist/pools/token-metadata/get-listing-token-metadata.d.ts.map +1 -0
  168. package/dist/pools/token-metadata/get-listing-token-metadata.js +43 -0
  169. package/dist/pools/token-metadata/get-listing-token-metadata.js.map +1 -0
  170. package/dist/pools/token-metadata/index.d.ts +3 -0
  171. package/dist/pools/token-metadata/index.d.ts.map +1 -0
  172. package/dist/pools/token-metadata/query.d.ts +11 -0
  173. package/dist/pools/token-metadata/query.d.ts.map +1 -0
  174. package/dist/pools/token-metadata/query.js +21 -0
  175. package/dist/pools/token-metadata/query.js.map +1 -0
  176. package/dist/pools/token-support/check-listing-token-support.d.ts +23 -0
  177. package/dist/pools/token-support/check-listing-token-support.d.ts.map +1 -0
  178. package/dist/pools/token-support/check-listing-token-support.js +36 -0
  179. package/dist/pools/token-support/check-listing-token-support.js.map +1 -0
  180. package/dist/pools/token-support/index.d.ts +3 -0
  181. package/dist/pools/token-support/index.d.ts.map +1 -0
  182. package/dist/pools/token-support/query.d.ts +11 -0
  183. package/dist/pools/token-support/query.d.ts.map +1 -0
  184. package/dist/pools/token-support/query.js +21 -0
  185. package/dist/pools/token-support/query.js.map +1 -0
  186. package/dist/pools/trade-history/calculate-history-metrics.d.ts +12 -0
  187. package/dist/pools/trade-history/calculate-history-metrics.d.ts.map +1 -0
  188. package/dist/pools/trade-history/calculate-history-metrics.js +36 -0
  189. package/dist/pools/trade-history/calculate-history-metrics.js.map +1 -0
  190. package/dist/pools/trade-history/get-pool-trade-history.d.ts +21 -1
  191. package/dist/pools/trade-history/get-pool-trade-history.d.ts.map +1 -1
  192. package/dist/pools/trade-history/get-pool-trade-history.js +57 -18
  193. package/dist/pools/trade-history/get-pool-trade-history.js.map +1 -1
  194. package/dist/pools/trade-history/query-document.d.ts.map +1 -1
  195. package/dist/pools/trade-history/query-document.js +1 -1
  196. package/dist/pools/trade-history/query-document.js.map +1 -1
  197. package/dist/pools/transactions/get-pool-transaction-range.d.ts +6 -0
  198. package/dist/pools/transactions/get-pool-transaction-range.d.ts.map +1 -0
  199. package/dist/pools/transactions/get-pool-transaction-range.js +26 -0
  200. package/dist/pools/transactions/get-pool-transaction-range.js.map +1 -0
  201. package/dist/pools/transactions/index.d.ts +1 -0
  202. package/dist/pools/transactions/index.d.ts.map +1 -1
  203. package/dist/pools/types/generated/listing-backend.js +34 -10
  204. package/dist/pools/types/generated/listing-backend.js.map +1 -1
  205. package/dist/pools/types.d.ts +129 -6
  206. package/dist/pools/types.d.ts.map +1 -1
  207. package/dist/pools/types.js.map +1 -1
  208. package/dist/pools/user-markets/get-user-listing-markets.d.ts +2 -0
  209. package/dist/pools/user-markets/get-user-listing-markets.d.ts.map +1 -1
  210. package/dist/pools/user-markets/get-user-listing-markets.js.map +1 -1
  211. package/dist/pools/user-markets/to-user-listing-market.js +1 -1
  212. package/dist/pools/user-markets/to-user-listing-market.js.map +1 -1
  213. package/dist/pools/user-transactions/get-user-transactions.d.ts +2 -0
  214. package/dist/pools/user-transactions/get-user-transactions.d.ts.map +1 -1
  215. package/dist/pools/user-transactions/get-user-transactions.js.map +1 -1
  216. package/dist/pools/user-transactions/to-user-transaction.d.ts +5 -1
  217. package/dist/pools/user-transactions/to-user-transaction.d.ts.map +1 -1
  218. package/dist/pools/user-transactions/to-user-transaction.js +3 -0
  219. package/dist/pools/user-transactions/to-user-transaction.js.map +1 -1
  220. package/dist/quotes/liquidation/calculate-liquidation-price.d.ts +5 -1
  221. package/dist/quotes/liquidation/calculate-liquidation-price.d.ts.map +1 -1
  222. package/dist/quotes/liquidation/calculate-liquidation-price.js +1 -1
  223. package/dist/quotes/liquidation/calculate-liquidation-price.js.map +1 -1
  224. package/dist/quotes/upnl/calculate-quote-pnl.d.ts.map +1 -1
  225. package/dist/quotes/upnl/calculate-quote-pnl.js +8 -8
  226. package/dist/quotes/upnl/calculate-quote-pnl.js.map +1 -1
  227. package/dist/quotes/upnl/calculate-quote-upnl.d.ts +2 -2
  228. package/dist/quotes/upnl/calculate-quote-upnl.d.ts.map +1 -1
  229. package/dist/quotes/upnl/calculate-quote-upnl.js +16 -15
  230. package/dist/quotes/upnl/calculate-quote-upnl.js.map +1 -1
  231. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts +2 -2
  232. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts.map +1 -1
  233. package/dist/symmio-subgraph/types/generated/analytics/gql.js +2 -2
  234. package/dist/symmio-subgraph/types/generated/analytics/gql.js.map +1 -1
  235. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts +21 -0
  236. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts.map +1 -1
  237. package/dist/symmio-subgraph/types/generated/analytics/graphql.js +1 -1
  238. package/dist/symmio-subgraph/types/generated/analytics/graphql.js.map +1 -1
  239. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pools/maintenance-fees/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Config } from '../../core/config/index.js';
2
+ import { ConfigKeyParameter } from '../../shared/types/properties.js';
3
+ import { QueryParameter, SymmioQueryOptions } from '../../shared/types/query.js';
4
+ import { GetPoolMaintenanceFeesParameters, GetPoolMaintenanceFeesReturnType } from './get-pool-maintenance-fees.js';
5
+ /** Query options for {@link getPoolMaintenanceFees}. */
6
+ export type GetPoolMaintenanceFeesOptions = GetPoolMaintenanceFeesParameters & QueryParameter<GetPoolMaintenanceFeesReturnType>;
7
+ /** Stable cache identity, including deployment configuration. */
8
+ export declare function getPoolMaintenanceFeesQueryKey(options: GetPoolMaintenanceFeesParameters & ConfigKeyParameter): readonly ["getPoolMaintenanceFees", Record<string, unknown>];
9
+ /** Build options for the listing read. Required identity/auth inputs gate execution. */
10
+ export declare function getPoolMaintenanceFeesQueryOptions(config: Config, options: GetPoolMaintenanceFeesOptions): SymmioQueryOptions<GetPoolMaintenanceFeesReturnType>;
11
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pools/maintenance-fees/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EACtC,MAAM,6BAA6B,CAAC;AAErC,wDAAwD;AACxD,MAAM,MAAM,6BAA6B,GAAG,gCAAgC,GAC1E,cAAc,CAAC,gCAAgC,CAAC,CAAC;AACnD,iEAAiE;AACjE,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,gCAAgC,GAAG,kBAAkB,gEAE5G;AACD,wFAAwF;AACxF,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,6BAA6B,GACrC,kBAAkB,CAAC,gCAAgC,CAAC,CAOtD"}
@@ -0,0 +1,21 @@
1
+ import { filterQueryOptions as e } from "../../shared/utils/query.js";
2
+ import { getPoolMaintenanceFees as t } from "./get-pool-maintenance-fees.js";
3
+ //#region src/pools/maintenance-fees/query.ts
4
+ function n(t) {
5
+ return ["getPoolMaintenanceFees", e({ ...t })];
6
+ }
7
+ function r(e, r) {
8
+ return {
9
+ ...r.query,
10
+ queryKey: n({
11
+ ...r,
12
+ configKey: e.getChainConfigKey(r.chainId)
13
+ }),
14
+ enabled: (r.query?.enabled ?? !0) && !!r.tokenContractAddress,
15
+ queryFn: () => t(e, r)
16
+ };
17
+ }
18
+ //#endregion
19
+ export { n as getPoolMaintenanceFeesQueryKey, r as getPoolMaintenanceFeesQueryOptions };
20
+
21
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/maintenance-fees/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getPoolMaintenanceFees,\n type GetPoolMaintenanceFeesParameters,\n type GetPoolMaintenanceFeesReturnType,\n} from \"./get-pool-maintenance-fees\";\n\n/** Query options for {@link getPoolMaintenanceFees}. */\nexport type GetPoolMaintenanceFeesOptions = GetPoolMaintenanceFeesParameters &\n QueryParameter<GetPoolMaintenanceFeesReturnType>;\n/** Stable cache identity, including deployment configuration. */\nexport function getPoolMaintenanceFeesQueryKey(options: GetPoolMaintenanceFeesParameters & ConfigKeyParameter) {\n return [\"getPoolMaintenanceFees\", filterQueryOptions({ ...options })] as const;\n}\n/** Build options for the listing read. Required identity/auth inputs gate execution. */\nexport function getPoolMaintenanceFeesQueryOptions(\n config: Config,\n options: GetPoolMaintenanceFeesOptions,\n): SymmioQueryOptions<GetPoolMaintenanceFeesReturnType> {\n return {\n ...options.query,\n queryKey: getPoolMaintenanceFeesQueryKey({ ...options, configKey: config.getChainConfigKey(options.chainId) }),\n enabled: (options.query?.enabled ?? true) && !!options.tokenContractAddress,\n queryFn: () => getPoolMaintenanceFees(config, options),\n };\n}\n"],"mappings":";;;AAcA,SAAgB,EAA+B,GAAgE;CAC7G,OAAO,CAAC,0BAA0B,EAAmB,EAAE,GAAG,EAAQ,CAAC,CAAC;AACtE;AAEA,SAAgB,EACd,GACA,GACsD;CACtD,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAA+B;GAAE,GAAG;GAAS,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EAAE,CAAC;EAC7G,UAAU,EAAQ,OAAO,WAAW,OAAS,CAAC,CAAC,EAAQ;EACvD,eAAe,EAAuB,GAAQ,CAAO;CACvD;AACF"}
@@ -14,5 +14,10 @@ import { ListingMarketConfig } from './types.js';
14
14
  * @param raw - The service's `/v2/market/config` response body.
15
15
  * @returns The normalized market config.
16
16
  */
17
- export declare function toListingMarketConfig(raw: UpdateMarketConfigResponseSchema): ListingMarketConfig;
17
+ export declare function toListingMarketConfig(raw: UpdateMarketConfigResponseSchema & {
18
+ max_leverage_bounds?: {
19
+ minimum: number;
20
+ maximum: number;
21
+ } | null;
22
+ }): ListingMarketConfig;
18
23
  //# sourceMappingURL=to-listing-market-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-listing-market-config.d.ts","sourceRoot":"","sources":["../../../src/pools/market-config/to-listing-market-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,gCAAgC,GAAG,mBAAmB,CAShG"}
1
+ {"version":3,"file":"to-listing-market-config.d.ts","sourceRoot":"","sources":["../../../src/pools/market-config/to-listing-market-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,gCAAgC,GAAG;IAAE,mBAAmB,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC5G,mBAAmB,CAUrB"}
@@ -1,6 +1,7 @@
1
1
  //#region src/pools/market-config/to-listing-market-config.ts
2
2
  function e(e) {
3
3
  return {
4
+ maxLeverageBounds: e.max_leverage_bounds ?? null,
4
5
  tokenContractAddress: e.token_contract_address,
5
6
  depositChain: e.deposit_chain,
6
7
  userMaxLeverage: e.user_max_leverage ?? null,
@@ -1 +1 @@
1
- {"version":3,"file":"to-listing-market-config.js","names":[],"sources":["../../../src/pools/market-config/to-listing-market-config.ts"],"sourcesContent":["import type { ListingDepositChainId } from \"../types\";\nimport type { UpdateMarketConfigResponseSchema } from \"../types/generated/listing-backend\";\nimport type { ListingMarketConfig } from \"./types\";\n\n/**\n * Map the listing service's raw `/v2/market/config` body into the SDK's\n * {@link ListingMarketConfig}.\n *\n * Both endpoints on that path — the `GET` read and the `POST` write — return the\n * same schema, so both actions share this mapper. Nothing is rescaled: the four\n * numbers are plain whole values on the wire (`50` = 50%, `20` = 20x), unlike\n * every money field on the listing service. The nullable `user_*` fields are\n * normalized from `undefined` to `null`, so \"never configured\" is one value\n * rather than two.\n *\n * @param raw - The service's `/v2/market/config` response body.\n * @returns The normalized market config.\n */\nexport function toListingMarketConfig(raw: UpdateMarketConfigResponseSchema): ListingMarketConfig {\n return {\n tokenContractAddress: raw.token_contract_address,\n depositChain: raw.deposit_chain as ListingDepositChainId,\n userMaxLeverage: raw.user_max_leverage ?? null,\n userBuybackRatio: raw.user_buyback_ratio ?? null,\n maxLeverage: raw.max_leverage,\n buybackRatio: raw.buyback_ratio,\n };\n}\n"],"mappings":";AAkBA,SAAgB,EAAsB,GAA4D;CAChG,OAAO;EACL,sBAAsB,EAAI;EAC1B,cAAc,EAAI;EAClB,iBAAiB,EAAI,qBAAqB;EAC1C,kBAAkB,EAAI,sBAAsB;EAC5C,aAAa,EAAI;EACjB,cAAc,EAAI;CACpB;AACF"}
1
+ {"version":3,"file":"to-listing-market-config.js","names":[],"sources":["../../../src/pools/market-config/to-listing-market-config.ts"],"sourcesContent":["import type { ListingDepositChainId } from \"../types\";\nimport type { UpdateMarketConfigResponseSchema } from \"../types/generated/listing-backend\";\nimport type { ListingMarketConfig } from \"./types\";\n\n/**\n * Map the listing service's raw `/v2/market/config` body into the SDK's\n * {@link ListingMarketConfig}.\n *\n * Both endpoints on that path — the `GET` read and the `POST` write — return the\n * same schema, so both actions share this mapper. Nothing is rescaled: the four\n * numbers are plain whole values on the wire (`50` = 50%, `20` = 20x), unlike\n * every money field on the listing service. The nullable `user_*` fields are\n * normalized from `undefined` to `null`, so \"never configured\" is one value\n * rather than two.\n *\n * @param raw - The service's `/v2/market/config` response body.\n * @returns The normalized market config.\n */\nexport function toListingMarketConfig(\n raw: UpdateMarketConfigResponseSchema & { max_leverage_bounds?: { minimum: number; maximum: number } | null },\n): ListingMarketConfig {\n return {\n maxLeverageBounds: raw.max_leverage_bounds ?? null,\n tokenContractAddress: raw.token_contract_address,\n depositChain: raw.deposit_chain as ListingDepositChainId,\n userMaxLeverage: raw.user_max_leverage ?? null,\n userBuybackRatio: raw.user_buyback_ratio ?? null,\n maxLeverage: raw.max_leverage,\n buybackRatio: raw.buyback_ratio,\n };\n}\n"],"mappings":";AAkBA,SAAgB,EACd,GACqB;CACrB,OAAO;EACL,mBAAmB,EAAI,uBAAuB;EAC9C,sBAAsB,EAAI;EAC1B,cAAc,EAAI;EAClB,iBAAiB,EAAI,qBAAqB;EAC1C,kBAAkB,EAAI,sBAAsB;EAC5C,aAAa,EAAI;EACjB,cAAc,EAAI;CACpB;AACF"}
@@ -39,6 +39,11 @@ export declare const LISTING_MARKET_CONFIG_BOUNDS: {
39
39
  * `ListingMarketDetail.buybackRatio` and `ListingMarketDetail.maxLeverage` use.
40
40
  */
41
41
  export interface ListingMarketConfig {
42
+ /** Server-published inclusive leverage limits, when available. */
43
+ maxLeverageBounds?: {
44
+ minimum: number;
45
+ maximum: number;
46
+ } | null;
42
47
  /**
43
48
  * The market's token contract address, echoed back by the service — an EVM
44
49
  * `0x…` address, or a Solana base58 address for a Solana-deposited listing.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRo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,eAAe,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,2EAA2E;IAC3E,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,oDAAoD;AACpD,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC;;;OAGG;IACH,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/pools/market-config/types.ts"],"sourcesContent":["import type { ListingDepositChainId } from \"../types\";\n\n/**\n * Client-side bounds for the two {@link ListingMarketConfig} knobs.\n *\n * The listing service does **not** publish these: `getListingConfig`'s\n * `/v2/configs` payload carries deposit guidance, the listing fee, supported\n * deposit chains, rate limits, and the protocol reward share — but no leverage\n * or buyback range. Until it grows one, these are the values the listing team's\n * own UI enforces, and the service is the final authority: a value outside them\n * is rejected server-side with a `422`.\n *\n * Use them to bound a slider or a numeric input; do not treat them as a\n * substitute for handling the service's rejection.\n */\nexport const LISTING_MARKET_CONFIG_BOUNDS = {\n /** Whole multiplier, inclusive. */\n maxLeverage: { min: 1, max: 20 },\n /** Whole percent, inclusive. */\n buybackRatio: { min: 0, max: 100 },\n} as const;\n\n/**\n * One market's configuration as the listing service sees it for the signed-in\n * user — the caller's own opinion alongside the pool-level values in force.\n *\n * The pool does not take a single LP's word for its configuration. Every LP\n * submits an opinion through `updateListingMarketConfig`, and the service folds\n * them into a deposit-weighted average: `maxLeverage` and `buybackRatio` are\n * that blend, `userMaxLeverage` and `userBuybackRatio` are this caller's\n * contribution to it.\n *\n * Both ratios are plain numbers, **not** 18-decimal values: `buybackRatio: 50`\n * means 50%, `maxLeverage: 20` means 20x. This is the same convention\n * `ListingMarketDetail.buybackRatio` and `ListingMarketDetail.maxLeverage` use.\n */\nexport interface ListingMarketConfig {\n /**\n * The market's token contract address, echoed back by the service — an EVM\n * `0x…` address, or a Solana base58 address for a Solana-deposited listing.\n */\n tokenContractAddress: string;\n /** The market's deposit chain, echoed back by the service. */\n depositChain: ListingDepositChainId;\n /**\n * The caller's own max-leverage opinion, a whole multiplier. `null` until the\n * caller has ever submitted one for this market.\n */\n userMaxLeverage: number | null;\n /**\n * The caller's own buyback opinion, a whole percent. `null` until the caller\n * has ever submitted one for this market.\n */\n userBuybackRatio: number | null;\n /**\n * The pool-level max leverage in force — the deposit-weighted blend of every\n * LP's opinion. Matches `ListingMarketDetail.maxLeverage`.\n */\n maxLeverage: number;\n /**\n * The pool-level buyback percentage in force — the deposit-weighted blend of\n * every LP's opinion. Matches `ListingMarketDetail.buybackRatio`.\n */\n buybackRatio: number;\n}\n\n/**\n * Inputs for {@link projectListingMarketConfig}.\n *\n * The pool-side figures come from `getListingMarketDetail`, the caller's prior\n * opinion from `getListingMarketConfig`, and the caller's stake from whichever\n * token-denominated balance the consumer trusts — `getUserProfit`'s\n * `userBalanceInTokens` is the recommended source, since it is the live stake\n * and is denominated in the same tokens as `totalTokenInPool`.\n */\nexport interface ProjectListingMarketConfigParameters {\n /**\n * The pool-level buyback percentage in force, from\n * `ListingMarketDetail.buybackRatio`. `null` when unknown — the projection\n * for that knob is then `null` too.\n */\n poolBuybackRatio: number | null;\n /**\n * The pool-level max leverage in force, from `ListingMarketDetail.maxLeverage`.\n * `null` when unknown.\n */\n poolMaxLeverage: number | null;\n /**\n * The caller's prior buyback opinion, from\n * `ListingMarketConfig.userBuybackRatio`. `null` when the caller has never\n * configured this market — the pool value is then used as the baseline, which\n * makes the projection an approximation rather than a first-order exact shift.\n */\n priorBuybackRatio: number | null;\n /** The caller's prior max-leverage opinion, from `ListingMarketConfig.userMaxLeverage`. */\n priorMaxLeverage: number | null;\n /** The buyback percentage the caller is about to submit. Omit to skip that knob. */\n buybackRatio?: number;\n /** The max leverage the caller is about to submit. Omit to skip that knob. */\n maxLeverage?: number;\n /**\n * The caller's stake in the pool, token-denominated at\n * `LISTING_VALUE_DECIMALS` (18). `getUserProfit`'s `userBalanceInTokens` is\n * the recommended source.\n */\n userTokenAmount: bigint;\n /** The pool's total token balance, from `ListingMarketDetail.totalTokenInPool`. */\n totalTokenInPool: bigint;\n /** The pool's total value in USD, from `ListingMarketDetail.tvl`. */\n tvl: bigint | null;\n /** The pool's USDC balance, from `ListingMarketDetail.totalUsdcInPool`. */\n totalUsdcInPool: bigint;\n}\n\n/** Result of {@link projectListingMarketConfig}. */\nexport interface ListingMarketConfigProjection {\n /**\n * The caller's deposit-**value** share of the pool, clamped to `0..1` — the\n * weight the service gives their opinion.\n */\n share: number;\n /**\n * Where the pool's buyback percentage lands once the opinion is saved, or\n * `null` when `poolBuybackRatio` or the entered value is unknown.\n */\n projectedBuybackRatio: number | null;\n /**\n * Where the pool's max leverage lands once the opinion is saved, or `null`\n * when `poolMaxLeverage` or the entered value is unknown.\n */\n projectedMaxLeverage: number | null;\n}\n"],"mappings":";AAeA,IAAa,IAA+B;CAE1C,aAAa;EAAE,KAAK;EAAG,KAAK;CAAG;CAE/B,cAAc;EAAE,KAAK;EAAG,KAAK;CAAI;AACnC"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/pools/market-config/types.ts"],"sourcesContent":["import type { ListingDepositChainId } from \"../types\";\n\n/**\n * Client-side bounds for the two {@link ListingMarketConfig} knobs.\n *\n * The listing service does **not** publish these: `getListingConfig`'s\n * `/v2/configs` payload carries deposit guidance, the listing fee, supported\n * deposit chains, rate limits, and the protocol reward share — but no leverage\n * or buyback range. Until it grows one, these are the values the listing team's\n * own UI enforces, and the service is the final authority: a value outside them\n * is rejected server-side with a `422`.\n *\n * Use them to bound a slider or a numeric input; do not treat them as a\n * substitute for handling the service's rejection.\n */\nexport const LISTING_MARKET_CONFIG_BOUNDS = {\n /** Whole multiplier, inclusive. */\n maxLeverage: { min: 1, max: 20 },\n /** Whole percent, inclusive. */\n buybackRatio: { min: 0, max: 100 },\n} as const;\n\n/**\n * One market's configuration as the listing service sees it for the signed-in\n * user — the caller's own opinion alongside the pool-level values in force.\n *\n * The pool does not take a single LP's word for its configuration. Every LP\n * submits an opinion through `updateListingMarketConfig`, and the service folds\n * them into a deposit-weighted average: `maxLeverage` and `buybackRatio` are\n * that blend, `userMaxLeverage` and `userBuybackRatio` are this caller's\n * contribution to it.\n *\n * Both ratios are plain numbers, **not** 18-decimal values: `buybackRatio: 50`\n * means 50%, `maxLeverage: 20` means 20x. This is the same convention\n * `ListingMarketDetail.buybackRatio` and `ListingMarketDetail.maxLeverage` use.\n */\nexport interface ListingMarketConfig {\n /** Server-published inclusive leverage limits, when available. */\n maxLeverageBounds?: { minimum: number; maximum: number } | null;\n /**\n * The market's token contract address, echoed back by the service — an EVM\n * `0x…` address, or a Solana base58 address for a Solana-deposited listing.\n */\n tokenContractAddress: string;\n /** The market's deposit chain, echoed back by the service. */\n depositChain: ListingDepositChainId;\n /**\n * The caller's own max-leverage opinion, a whole multiplier. `null` until the\n * caller has ever submitted one for this market.\n */\n userMaxLeverage: number | null;\n /**\n * The caller's own buyback opinion, a whole percent. `null` until the caller\n * has ever submitted one for this market.\n */\n userBuybackRatio: number | null;\n /**\n * The pool-level max leverage in force — the deposit-weighted blend of every\n * LP's opinion. Matches `ListingMarketDetail.maxLeverage`.\n */\n maxLeverage: number;\n /**\n * The pool-level buyback percentage in force — the deposit-weighted blend of\n * every LP's opinion. Matches `ListingMarketDetail.buybackRatio`.\n */\n buybackRatio: number;\n}\n\n/**\n * Inputs for {@link projectListingMarketConfig}.\n *\n * The pool-side figures come from `getListingMarketDetail`, the caller's prior\n * opinion from `getListingMarketConfig`, and the caller's stake from whichever\n * token-denominated balance the consumer trusts — `getUserProfit`'s\n * `userBalanceInTokens` is the recommended source, since it is the live stake\n * and is denominated in the same tokens as `totalTokenInPool`.\n */\nexport interface ProjectListingMarketConfigParameters {\n /**\n * The pool-level buyback percentage in force, from\n * `ListingMarketDetail.buybackRatio`. `null` when unknown — the projection\n * for that knob is then `null` too.\n */\n poolBuybackRatio: number | null;\n /**\n * The pool-level max leverage in force, from `ListingMarketDetail.maxLeverage`.\n * `null` when unknown.\n */\n poolMaxLeverage: number | null;\n /**\n * The caller's prior buyback opinion, from\n * `ListingMarketConfig.userBuybackRatio`. `null` when the caller has never\n * configured this market — the pool value is then used as the baseline, which\n * makes the projection an approximation rather than a first-order exact shift.\n */\n priorBuybackRatio: number | null;\n /** The caller's prior max-leverage opinion, from `ListingMarketConfig.userMaxLeverage`. */\n priorMaxLeverage: number | null;\n /** The buyback percentage the caller is about to submit. Omit to skip that knob. */\n buybackRatio?: number;\n /** The max leverage the caller is about to submit. Omit to skip that knob. */\n maxLeverage?: number;\n /**\n * The caller's stake in the pool, token-denominated at\n * `LISTING_VALUE_DECIMALS` (18). `getUserProfit`'s `userBalanceInTokens` is\n * the recommended source.\n */\n userTokenAmount: bigint;\n /** The pool's total token balance, from `ListingMarketDetail.totalTokenInPool`. */\n totalTokenInPool: bigint;\n /** The pool's total value in USD, from `ListingMarketDetail.tvl`. */\n tvl: bigint | null;\n /** The pool's USDC balance, from `ListingMarketDetail.totalUsdcInPool`. */\n totalUsdcInPool: bigint;\n}\n\n/** Result of {@link projectListingMarketConfig}. */\nexport interface ListingMarketConfigProjection {\n /**\n * The caller's deposit-**value** share of the pool, clamped to `0..1` — the\n * weight the service gives their opinion.\n */\n share: number;\n /**\n * Where the pool's buyback percentage lands once the opinion is saved, or\n * `null` when `poolBuybackRatio` or the entered value is unknown.\n */\n projectedBuybackRatio: number | null;\n /**\n * Where the pool's max leverage lands once the opinion is saved, or `null`\n * when `poolMaxLeverage` or the entered value is unknown.\n */\n projectedMaxLeverage: number | null;\n}\n"],"mappings":";AAeA,IAAa,IAA+B;CAE1C,aAAa;EAAE,KAAK;EAAG,KAAK;CAAG;CAE/B,cAAc;EAAE,KAAK;EAAG,KAAK;CAAI;AACnC"}
@@ -0,0 +1,14 @@
1
+ import { Config } from '../../core/config/index.js';
2
+ import { ChainIdParameter } from '../../shared/types/properties.js';
3
+ /** Inventory-backed legacy pool metric pair, at 18 decimals. */
4
+ export interface PoolMarketData {
5
+ marketCap: bigint | null;
6
+ apr: bigint | null;
7
+ }
8
+ /** Deployment and exact token addresses for the legacy batch metrics read. */
9
+ export type GetPoolMarketDataParameters = ChainIdParameter & {
10
+ addresses: readonly string[];
11
+ };
12
+ /** Read the legacy pool metrics in one request, preserving address keys and unknown values. */
13
+ export declare function getPoolMarketData(config: Config, parameters: GetPoolMarketDataParameters): Promise<Record<string, PoolMarketData>>;
14
+ //# sourceMappingURL=get-pool-market-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pool-market-data.d.ts","sourceRoot":"","sources":["../../../src/pools/market-data/get-pool-market-data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAKtE,gEAAgE;AAChE,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AACD,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GAAG,gBAAgB,GAAG;IAAE,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE9F,+FAA+F;AAC/F,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,2BAA2B,GACtC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAczC"}
@@ -0,0 +1,25 @@
1
+ import { SymmApiError as e } from "../../shared/errors/symm-error.js";
2
+ import { resolveListingService as t } from "../resolve-listing.js";
3
+ import { getPoolsV2PoolsGet as n } from "../types/generated/listing-backend.js";
4
+ import { toListingPercent as r, toListingValue as i } from "../markets/to-listing-market.js";
5
+ import { isAxiosError as a } from "axios";
6
+ //#region src/pools/market-data/get-pool-market-data.ts
7
+ async function o(o, s) {
8
+ let { url: c } = t(o, s);
9
+ try {
10
+ let { data: e } = await n({ addresses: s.addresses.join(",") }, { baseURL: c });
11
+ return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, {
12
+ marketCap: i(t.market_cap),
13
+ apr: r(t.apr)
14
+ }]));
15
+ } catch (t) {
16
+ throw a(t) ? e.fromAxios(t, {
17
+ code: "GET_POOL_MARKET_DATA_FAILED",
18
+ baseURL: c
19
+ }) : t;
20
+ }
21
+ }
22
+ //#endregion
23
+ export { o as getPoolMarketData };
24
+
25
+ //# sourceMappingURL=get-pool-market-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pool-market-data.js","names":[],"sources":["../../../src/pools/market-data/get-pool-market-data.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter } from \"../../shared/types/properties\";\nimport { toListingPercent, toListingValue } from \"../markets/to-listing-market\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport { getPoolsV2PoolsGet } from \"../types/generated/listing-backend\";\n\n/** Inventory-backed legacy pool metric pair, at 18 decimals. */\nexport interface PoolMarketData {\n marketCap: bigint | null;\n apr: bigint | null;\n}\n/** Deployment and exact token addresses for the legacy batch metrics read. */\nexport type GetPoolMarketDataParameters = ChainIdParameter & { addresses: readonly string[] };\n\n/** Read the legacy pool metrics in one request, preserving address keys and unknown values. */\nexport async function getPoolMarketData(\n config: Config,\n parameters: GetPoolMarketDataParameters,\n): Promise<Record<string, PoolMarketData>> {\n const { url: baseURL } = resolveListingService(config, parameters);\n try {\n const { data } = await getPoolsV2PoolsGet({ addresses: parameters.addresses.join(\",\") }, { baseURL });\n return Object.fromEntries(\n Object.entries(data).map(([address, value]) => [\n address,\n { marketCap: toListingValue(value.market_cap), apr: toListingPercent(value.apr) },\n ]),\n );\n } catch (error) {\n if (isAxiosError(error)) throw SymmApiError.fromAxios(error, { code: \"GET_POOL_MARKET_DATA_FAILED\", baseURL });\n throw error;\n }\n}\n"],"mappings":";;;;;;AAiBA,eAAsB,EACpB,GACA,GACyC;CACzC,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,CAAU;CACjE,IAAI;EACF,IAAM,EAAE,YAAS,MAAM,EAAmB,EAAE,WAAW,EAAW,UAAU,KAAK,GAAG,EAAE,GAAG,EAAE,WAAQ,CAAC;EACpG,OAAO,OAAO,YACZ,OAAO,QAAQ,CAAI,EAAE,KAAK,CAAC,GAAS,OAAW,CAC7C,GACA;GAAE,WAAW,EAAe,EAAM,UAAU;GAAG,KAAK,EAAiB,EAAM,GAAG;EAAE,CAClF,CAAC,CACH;CACF,SAAS,GAAO;EAEd,MADI,EAAa,CAAK,IAAS,EAAa,UAAU,GAAO;GAAE,MAAM;GAA+B;EAAQ,CAAC,IACvG;CACR;AACF"}
@@ -0,0 +1,2 @@
1
+ export * from './get-pool-market-data.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pools/market-data/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -7,5 +7,9 @@ import { GetMarketResponseSchema } from '../types/generated/listing-backend.js';
7
7
  * @param raw - The raw market-detail response body.
8
8
  * @returns The normalized pool detail.
9
9
  */
10
- export declare function toListingMarketDetail(raw: GetMarketResponseSchema): ListingMarketDetail;
10
+ export declare function toListingMarketDetail(raw: GetMarketResponseSchema & {
11
+ apy_all_time?: string | null;
12
+ lifetime_reward?: string | null;
13
+ buy_back_ratio?: number;
14
+ }): ListingMarketDetail;
11
15
  //# sourceMappingURL=to-listing-market-detail.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-listing-market-detail.d.ts","sourceRoot":"","sources":["../../../src/pools/market-detail/to-listing-market-detail.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,mBAAmB,EAGzB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AA+DlF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,uBAAuB,GAAG,mBAAmB,CAwCvF"}
1
+ {"version":3,"file":"to-listing-market-detail.d.ts","sourceRoot":"","sources":["../../../src/pools/market-detail/to-listing-market-detail.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,mBAAmB,EAGzB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAgElF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,mBAAmB,CAiDrB"}
@@ -1,36 +1,45 @@
1
1
  import { MarketLockReason as e, PoolPositionSide as t } from "../types.js";
2
- import { toListingValue as n } from "../markets/to-listing-market.js";
2
+ import { toListingPercent as n, toListingValue as r } from "../markets/to-listing-market.js";
3
3
  //#region src/pools/market-detail/to-listing-market-detail.ts
4
- function r(e) {
5
- return n(e) ?? 0n;
4
+ function i(e) {
5
+ return r(e) ?? 0n;
6
6
  }
7
- var i = new Set(Object.values(e));
8
- function a(t) {
9
- return i.has(t) ? t : e.UNKNOWN;
7
+ var a = new Set(Object.values(e));
8
+ function o(t) {
9
+ return a.has(t) ? t : e.UNKNOWN;
10
10
  }
11
- function o(e, t) {
12
- let r = e;
11
+ function s(e, t) {
12
+ let i = e, a = t.includes("apy") ? n : r;
13
13
  return {
14
- h1: n(r[`${t}_1h`]),
15
- h6: n(r[`${t}_6h`]),
16
- h24: n(r[`${t}_24h`]),
17
- d30: n(r[`${t}_30d`]),
18
- lifetime: n(r[`${t}_lifetime`])
14
+ h1: a(i[`${t}_1h`]),
15
+ h6: a(i[`${t}_6h`]),
16
+ h24: a(i[`${t}_24h`]),
17
+ d30: a(i[`${t}_30d`]),
18
+ lifetime: a(i[`${t}_lifetime`])
19
19
  };
20
20
  }
21
- function s(e, t, i, a, o) {
22
- let s = n(t);
21
+ function c(e, t, n, a, o) {
22
+ let s = r(t);
23
23
  return s === null ? null : {
24
24
  side: e,
25
25
  size: s,
26
- value: r(i),
27
- avgOpenPrice: r(a),
28
- upnl: r(o)
26
+ value: i(n),
27
+ avgOpenPrice: i(a),
28
+ upnl: i(o)
29
29
  };
30
30
  }
31
- function c(e) {
31
+ function l(e) {
32
32
  return {
33
33
  tokenContractAddress: e.token_contract_address,
34
+ reportedTotalTokenInPool: r(e.total_token_in_pool),
35
+ reportedTotalUsdcInPool: r(e.total_usdc_in_pool),
36
+ reportedMaintenanceFees: r(e.maintenance_fees),
37
+ legacyLifetimeReward: e.lifetime_reward ?? null,
38
+ isTax: e.is_tax ?? null,
39
+ userWhitelistTax: e.user_whitelist_tax ?? null,
40
+ additionalChains: e.additional_chains ?? null,
41
+ mainPool: e.main_pool ?? null,
42
+ cexList: e.cex_list ?? null,
34
43
  depositChain: e.deposit_chain,
35
44
  tokenName: e.token_name,
36
45
  tokenTicker: e.token_ticker ?? null,
@@ -38,26 +47,29 @@ function c(e) {
38
47
  symbolId: e.symbol_id ?? null,
39
48
  marketStatus: e.market_status,
40
49
  isLocked: e.is_locked ?? !1,
41
- lockReasons: (e.lock_reasons ?? []).map(a),
50
+ lockReasons: (e.lock_reasons ?? []).map(o),
42
51
  maxLeverage: e.max_leverage,
43
- buybackRatio: e.buyback_ratio,
52
+ buybackRatio: e.buyback_ratio ?? e.buy_back_ratio,
44
53
  listingTime: e.listing_time ?? null,
45
54
  age: e.age ?? null,
46
55
  activeLps: e.active_lps,
47
- tvl: n(e.tvl),
48
- totalUsdcInPool: r(e.total_usdc_in_pool),
49
- totalTokenInPool: r(e.total_token_in_pool),
50
- maintenanceFees: r(e.maintenance_fees),
51
- rewards: o(e, "reward"),
52
- solverRevenue: o(e, "solver_revenue"),
53
- apy: o(e, "apy"),
54
- tvlDrivenApy: o(e, "tvl_driven_apy"),
55
- priceDrivenApy: o(e, "price_driven_apy"),
56
- longPosition: s(t.LONG, e.long_position_amount, e.long_position_value, e.long_position_avg_open_price, e.long_position_upnl),
57
- shortPosition: s(t.SHORT, e.short_position_amount, e.short_position_value, e.short_position_avg_open_price, e.short_position_upnl)
56
+ tvl: r(e.tvl),
57
+ totalUsdcInPool: i(e.total_usdc_in_pool),
58
+ totalTokenInPool: i(e.total_token_in_pool),
59
+ maintenanceFees: i(e.maintenance_fees),
60
+ rewards: s(e, "reward"),
61
+ solverRevenue: s(e, "solver_revenue"),
62
+ apy: {
63
+ ...s(e, "apy"),
64
+ lifetime: n(e.apy_lifetime ?? e.apy_all_time)
65
+ },
66
+ tvlDrivenApy: s(e, "tvl_driven_apy"),
67
+ priceDrivenApy: s(e, "price_driven_apy"),
68
+ longPosition: c(t.LONG, e.long_position_amount, e.long_position_value, e.long_position_avg_open_price, e.long_position_upnl),
69
+ shortPosition: c(t.SHORT, e.short_position_amount, e.short_position_value, e.short_position_avg_open_price, e.short_position_upnl)
58
70
  };
59
71
  }
60
72
  //#endregion
61
- export { c as toListingMarketDetail };
73
+ export { l as toListingMarketDetail };
62
74
 
63
75
  //# sourceMappingURL=to-listing-market-detail.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-listing-market-detail.js","names":[],"sources":["../../../src/pools/market-detail/to-listing-market-detail.ts"],"sourcesContent":["import { toListingValue } from \"../markets/to-listing-market\";\nimport {\n MarketLockReason,\n PoolPositionSide,\n type ListingApyWindows,\n type ListingDepositChainId,\n type ListingMarketDetail,\n type ListingMarketStatus,\n type PoolPosition,\n} from \"../types\";\nimport type { GetMarketResponseSchema } from \"../types/generated/listing-backend\";\n\n/** Parse a required 18-decimal figure, defaulting an absent one to `0n`. */\nfunction toRequiredValue(raw: string | null | undefined): bigint {\n return toListingValue(raw) ?? 0n;\n}\n\n/** Every lock reason this release knows, keyed by its wire value. */\nconst KNOWN_LOCK_REASONS = new Set<string>(Object.values(MarketLockReason));\n\n/**\n * Name a wire lock reason, folding anything unrecognized into\n * {@link MarketLockReason.UNKNOWN} so a reason added by a newer backend cannot\n * break the read.\n */\nfunction toMarketLockReason(raw: string): MarketLockReason {\n return KNOWN_LOCK_REASONS.has(raw) ? (raw as MarketLockReason) : MarketLockReason.UNKNOWN;\n}\n\n/**\n * Map the five windows of a metric whose wire keys share `prefix`.\n *\n * The detail response reports every series over the same five windows, unlike\n * the catalogue where only the APY series carry a lifetime column.\n */\nfunction toWindows(raw: GetMarketResponseSchema, prefix: string): ListingApyWindows {\n const row = raw as unknown as Record<string, string | null | undefined>;\n return {\n h1: toListingValue(row[`${prefix}_1h`]),\n h6: toListingValue(row[`${prefix}_6h`]),\n h24: toListingValue(row[`${prefix}_24h`]),\n d30: toListingValue(row[`${prefix}_30d`]),\n lifetime: toListingValue(row[`${prefix}_lifetime`]),\n };\n}\n\n/**\n * Build one side's {@link PoolPosition}, or `null` when the backend reported no\n * size for it.\n *\n * `null` rather than a zero row on purpose: a pool with no short inventory and a\n * pool whose short side nets to zero are different states, and the table should\n * be able to tell them apart.\n */\nfunction toPosition(\n side: PoolPositionSide,\n size: string | null | undefined,\n value: string | null | undefined,\n avgOpenPrice: string | null | undefined,\n upnl: string | null | undefined,\n): PoolPosition | null {\n const parsedSize = toListingValue(size);\n if (parsedSize === null) return null;\n\n return {\n side,\n size: parsedSize,\n value: toRequiredValue(value),\n avgOpenPrice: toRequiredValue(avgOpenPrice),\n upnl: toRequiredValue(upnl),\n };\n}\n\n/**\n * Map the listing backend's `GET /v2/market` response into the SDK's\n * {@link ListingMarketDetail}.\n *\n * @param raw - The raw market-detail response body.\n * @returns The normalized pool detail.\n */\nexport function toListingMarketDetail(raw: GetMarketResponseSchema): ListingMarketDetail {\n return {\n tokenContractAddress: raw.token_contract_address,\n depositChain: raw.deposit_chain as ListingDepositChainId,\n tokenName: raw.token_name,\n tokenTicker: raw.token_ticker ?? null,\n tokenDecimal: raw.token_decimal,\n symbolId: raw.symbol_id ?? null,\n marketStatus: raw.market_status as unknown as ListingMarketStatus,\n isLocked: raw.is_locked ?? false,\n lockReasons: (raw.lock_reasons ?? []).map(toMarketLockReason),\n maxLeverage: raw.max_leverage,\n buybackRatio: raw.buyback_ratio,\n listingTime: raw.listing_time ?? null,\n age: raw.age ?? null,\n activeLps: raw.active_lps,\n tvl: toListingValue(raw.tvl),\n totalUsdcInPool: toRequiredValue(raw.total_usdc_in_pool),\n totalTokenInPool: toRequiredValue(raw.total_token_in_pool),\n maintenanceFees: toRequiredValue(raw.maintenance_fees),\n rewards: toWindows(raw, \"reward\"),\n solverRevenue: toWindows(raw, \"solver_revenue\"),\n apy: toWindows(raw, \"apy\"),\n tvlDrivenApy: toWindows(raw, \"tvl_driven_apy\"),\n priceDrivenApy: toWindows(raw, \"price_driven_apy\"),\n longPosition: toPosition(\n PoolPositionSide.LONG,\n raw.long_position_amount,\n raw.long_position_value,\n raw.long_position_avg_open_price,\n raw.long_position_upnl,\n ),\n shortPosition: toPosition(\n PoolPositionSide.SHORT,\n raw.short_position_amount,\n raw.short_position_value,\n raw.short_position_avg_open_price,\n raw.short_position_upnl,\n ),\n };\n}\n"],"mappings":";;;AAaA,SAAS,EAAgB,GAAwC;CAC/D,OAAO,EAAe,CAAG,KAAK;AAChC;AAGA,IAAM,IAAqB,IAAI,IAAY,OAAO,OAAO,CAAgB,CAAC;AAO1E,SAAS,EAAmB,GAA+B;CACzD,OAAO,EAAmB,IAAI,CAAG,IAAK,IAA2B,EAAiB;AACpF;AAQA,SAAS,EAAU,GAA8B,GAAmC;CAClF,IAAM,IAAM;CACZ,OAAO;EACL,IAAI,EAAe,EAAI,GAAG,EAAO,KAAK;EACtC,IAAI,EAAe,E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ing-market-detail.js","names":[],"sources":["../../../src/pools/market-detail/to-listing-market-detail.ts"],"sourcesContent":["import { toListingPercent, toListingValue } from \"../markets/to-listing-market\";\nimport {\n MarketLockReason,\n PoolPositionSide,\n type ListingApyWindows,\n type ListingDepositChainId,\n type ListingMarketDetail,\n type ListingMarketStatus,\n type PoolPosition,\n} from \"../types\";\nimport type { GetMarketResponseSchema } from \"../types/generated/listing-backend\";\n\n/** Parse a required 18-decimal figure, defaulting an absent one to `0n`. */\nfunction toRequiredValue(raw: string | null | undefined): bigint {\n return toListingValue(raw) ?? 0n;\n}\n\n/** Every lock reason this release knows, keyed by its wire value. */\nconst KNOWN_LOCK_REASONS = new Set<string>(Object.values(MarketLockReason));\n\n/**\n * Name a wire lock reason, folding anything unrecognized into\n * {@link MarketLockReason.UNKNOWN} so a reason added by a newer backend cannot\n * break the read.\n */\nfunction toMarketLockReason(raw: string): MarketLockReason {\n return KNOWN_LOCK_REASONS.has(raw) ? (raw as MarketLockReason) : MarketLockReason.UNKNOWN;\n}\n\n/**\n * Map the five windows of a metric whose wire keys share `prefix`.\n *\n * The detail response reports every series over the same five windows, unlike\n * the catalogue where only the APY series carry a lifetime column.\n */\nfunction toWindows(raw: GetMarketResponseSchema, prefix: string): ListingApyWindows {\n const row = raw as unknown as Record<string, string | null | undefined>;\n const parse = prefix.includes(\"apy\") ? toListingPercent : toListingValue;\n return {\n h1: parse(row[`${prefix}_1h`]),\n h6: parse(row[`${prefix}_6h`]),\n h24: parse(row[`${prefix}_24h`]),\n d30: parse(row[`${prefix}_30d`]),\n lifetime: parse(row[`${prefix}_lifetime`]),\n };\n}\n\n/**\n * Build one side's {@link PoolPosition}, or `null` when the backend reported no\n * size for it.\n *\n * `null` rather than a zero row on purpose: a pool with no short inventory and a\n * pool whose short side nets to zero are different states, and the table should\n * be able to tell them apart.\n */\nfunction toPosition(\n side: PoolPositionSide,\n size: string | null | undefined,\n value: string | null | undefined,\n avgOpenPrice: string | null | undefined,\n upnl: string | null | undefined,\n): PoolPosition | null {\n const parsedSize = toListingValue(size);\n if (parsedSize === null) return null;\n\n return {\n side,\n size: parsedSize,\n value: toRequiredValue(value),\n avgOpenPrice: toRequiredValue(avgOpenPrice),\n upnl: toRequiredValue(upnl),\n };\n}\n\n/**\n * Map the listing backend's `GET /v2/market` response into the SDK's\n * {@link ListingMarketDetail}.\n *\n * @param raw - The raw market-detail response body.\n * @returns The normalized pool detail.\n */\nexport function toListingMarketDetail(\n raw: GetMarketResponseSchema & {\n apy_all_time?: string | null;\n lifetime_reward?: string | null;\n buy_back_ratio?: number;\n },\n): ListingMarketDetail {\n return {\n tokenContractAddress: raw.token_contract_address,\n reportedTotalTokenInPool: toListingValue(raw.total_token_in_pool),\n reportedTotalUsdcInPool: toListingValue(raw.total_usdc_in_pool),\n reportedMaintenanceFees: toListingValue(raw.maintenance_fees),\n legacyLifetimeReward: raw.lifetime_reward ?? null,\n isTax: raw.is_tax ?? null,\n userWhitelistTax: raw.user_whitelist_tax ?? null,\n additionalChains: raw.additional_chains ?? null,\n mainPool: raw.main_pool ?? null,\n cexList: raw.cex_list ?? null,\n depositChain: raw.deposit_chain as ListingDepositChainId,\n tokenName: raw.token_name,\n tokenTicker: raw.token_ticker ?? null,\n tokenDecimal: raw.token_decimal,\n symbolId: raw.symbol_id ?? null,\n marketStatus: raw.market_status as unknown as ListingMarketStatus,\n isLocked: raw.is_locked ?? false,\n lockReasons: (raw.lock_reasons ?? []).map(toMarketLockReason),\n maxLeverage: raw.max_leverage,\n buybackRatio: raw.buyback_ratio ?? raw.buy_back_ratio,\n listingTime: raw.listing_time ?? null,\n age: raw.age ?? null,\n activeLps: raw.active_lps,\n tvl: toListingValue(raw.tvl),\n totalUsdcInPool: toRequiredValue(raw.total_usdc_in_pool),\n totalTokenInPool: toRequiredValue(raw.total_token_in_pool),\n maintenanceFees: toRequiredValue(raw.maintenance_fees),\n rewards: toWindows(raw, \"reward\"),\n solverRevenue: toWindows(raw, \"solver_revenue\"),\n apy: { ...toWindows(raw, \"apy\"), lifetime: toListingPercent(raw.apy_lifetime ?? raw.apy_all_time) },\n tvlDrivenApy: toWindows(raw, \"tvl_driven_apy\"),\n priceDrivenApy: toWindows(raw, \"price_driven_apy\"),\n longPosition: toPosition(\n PoolPositionSide.LONG,\n raw.long_position_amount,\n raw.long_position_value,\n raw.long_position_avg_open_price,\n raw.long_position_upnl,\n ),\n shortPosition: toPosition(\n PoolPositionSide.SHORT,\n raw.short_position_amount,\n raw.short_position_value,\n raw.short_position_avg_open_price,\n raw.short_position_upnl,\n ),\n };\n}\n"],"mappings":";;;AAaA,SAAS,EAAgB,GAAwC;CAC/D,OAAO,EAAe,CAAG,KAAK;AAChC;AAGA,IAAM,IAAqB,IAAI,IAAY,OAAO,OAAO,CAAgB,CAAC;AAO1E,SAAS,EAAmB,GAA+B;CACzD,OAAO,EAAmB,IAAI,CAAG,IAAK,IAA2B,EAAiB;AACpF;AAQA,SAAS,EAAU,GAA8B,GAAmC;CAClF,IAAM,IAAM,GACN,IAAQ,EAAO,SAAS,KAAK,IAAI,IAAmB;CAC1D,OAAO;EACL,IAAI,EAAM,EAAI,GAAG,EAAO,KAAK;EAC7B,IAAI,EAAM,EAAI,GAAG,EAAO,KAAK;EAC7B,KAAK,EAAM,EAAI,GAAG,EAAO,MAAM;EAC/B,KAAK,EAAM,EAAI,GAAG,EAAO,MAAM;EAC/B,UAAU,EAAM,EAAI,GAAG,EAAO,WAAW;CAC3C;AACF;AAUA,SAAS,EACP,GACA,GACA,GACA,GACA,GACqB;CACrB,IAAM,IAAa,EAAe,CAAI;CAGtC,OAFI,MAAe,OAAa,OAEzB;EACL;EACA,MAAM;EACN,OAAO,EAAgB,CAAK;EAC5B,cAAc,EAAgB,CAAY;EAC1C,MAAM,EAAgB,CAAI;CAC5B;AACF;AASA,SAAgB,EACd,GAKqB;CACrB,OAAO;EACL,sBAAsB,EAAI;EAC1B,0BAA0B,EAAe,EAAI,mBAAmB;EAChE,yBAAyB,EAAe,EAAI,kBAAkB;EAC9D,yBAAyB,EAAe,EAAI,gBAAgB;EAC5D,sBAAsB,EAAI,mBAAmB;EAC7C,OAAO,EAAI,UAAU;EACrB,kBAAkB,EAAI,sBAAsB;EAC5C,kBAAkB,EAAI,qBAAqB;EAC3C,UAAU,EAAI,aAAa;EAC3B,SAAS,EAAI,YAAY;EACzB,cAAc,EAAI;EAClB,WAAW,EAAI;EACf,aAAa,EAAI,gBAAgB;EACjC,cAAc,EAAI;EAClB,UAAU,EAAI,aAAa;EAC3B,cAAc,EAAI;EAClB,UAAU,EAAI,aAAa;EAC3B,cAAc,EAAI,gBAAgB,CAAC,GAAG,IAAI,CAAkB;EAC5D,aAAa,EAAI;EACjB,cAAc,EAAI,iBAAiB,EAAI;EACvC,aAAa,EAAI,gBAAgB;EACjC,KAAK,EAAI,OAAO;EAChB,WAAW,EAAI;EACf,KAAK,EAAe,EAAI,GAAG;EAC3B,iBAAiB,EAAgB,EAAI,kBAAkB;EACvD,kBAAkB,EAAgB,EAAI,mBAAmB;EACzD,iBAAiB,EAAgB,EAAI,gBAAgB;EACrD,SAAS,EAAU,GAAK,QAAQ;EAChC,eAAe,EAAU,GAAK,gBAAgB;EAC9C,KAAK;GAAE,GAAG,EAAU,GAAK,KAAK;GAAG,UAAU,EAAiB,EAAI,gBAAgB,EAAI,YAAY;EAAE;EAClG,cAAc,EAAU,GAAK,gBAAgB;EAC7C,gBAAgB,EAAU,GAAK,kBAAkB;EACjD,cAAc,EACZ,EAAiB,MACjB,EAAI,sBACJ,EAAI,qBACJ,EAAI,8BACJ,EAAI,kBACN;EACA,eAAe,EACb,EAAiB,OACjB,EAAI,uBACJ,EAAI,sBACJ,EAAI,+BACJ,EAAI,mBACN;CACF;AACF"}
@@ -50,7 +50,17 @@ export declare function parseListingValue(raw: string | null | undefined): bigin
50
50
  * @param raw - One row of the service's `/v2/market/search` response.
51
51
  * @returns The normalized market.
52
52
  */
53
- export declare function toListingMarket(raw: MarketSearchItem): ListingMarket;
53
+ export declare function toListingMarket(raw: MarketSearchItem & {
54
+ price_usd?: string | null;
55
+ apy_24h?: string | null;
56
+ apy_30d?: string | null;
57
+ apy_lifetime?: string | null;
58
+ reward_30d?: string | null;
59
+ reward_lifetime?: string | null;
60
+ solver_revenue_24h?: string | null;
61
+ solver_revenue_30d?: string | null;
62
+ solver_revenue_lifetime?: string | null;
63
+ }): ListingMarket;
54
64
  /**
55
65
  * Map the service's paginated envelope into a {@link ListingMarketPage}.
56
66
  *
@@ -62,4 +72,6 @@ export declare function toListingMarket(raw: MarketSearchItem): ListingMarket;
62
72
  * @returns The normalized page.
63
73
  */
64
74
  export declare function toListingMarketPage(raw: PaginationResponseMarketSearchItem): ListingMarketPage;
75
+ /** Normalize rollout-era plain percentages and fixed-point percentages to 18 decimals. */
76
+ export declare function toListingPercent(raw: string | null | undefined): bigint | null;
65
77
  //# sourceMappingURL=to-listing-market.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-listing-market.d.ts","sourceRoot":"","sources":["../../../src/pools/markets/to-listing-market.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEvB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,gBAAgB,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE/G;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CA2B5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAW/E;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,CAsBpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kCAAkC,GAAG,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,SAAS,GAAG,MAAM,GAAG,IAAI,CAI9E"}
@@ -24,24 +24,33 @@ function n(t) {
24
24
  return null;
25
25
  }
26
26
  }
27
- function r(e, n) {
28
- let r = e;
27
+ function r(e, t) {
28
+ let n = e;
29
29
  return {
30
- h1: t(r[`${n}_1h`]),
31
- h6: t(r[`${n}_6h`]),
32
- h24: t(r[`${n}_24h`]),
33
- d30: t(r[`${n}_30d`])
30
+ h1: s(n[`${t}_1h`]),
31
+ h6: s(n[`${t}_6h`]),
32
+ h24: s(n[`${t}_24h`]),
33
+ d30: s(n[`${t}_30d`])
34
34
  };
35
35
  }
36
- function i(e, n) {
37
- let i = e;
36
+ function i(e, t) {
37
+ let n = e;
38
38
  return {
39
- ...r(e, n),
40
- lifetime: t(i[`${n}_lifetime`])
39
+ ...r(e, t),
40
+ lifetime: s(n[`${t}_lifetime`])
41
41
  };
42
42
  }
43
43
  function a(e) {
44
44
  return {
45
+ priceUsd: e.price_usd ?? null,
46
+ apy24h: s(e.apy_24h),
47
+ apy30d: s(e.apy_30d),
48
+ apyLifetime: s(e.apy_lifetime),
49
+ reward30d: t(e.reward_30d),
50
+ rewardLifetime: t(e.reward_lifetime),
51
+ solverRevenue24h: t(e.solver_revenue_24h),
52
+ solverRevenue30d: t(e.solver_revenue_30d),
53
+ solverRevenueLifetime: t(e.solver_revenue_lifetime),
45
54
  contractAddress: e.contract_address,
46
55
  chainId: e.chain_id,
47
56
  symbolId: e.symbol_id ?? null,
@@ -54,7 +63,7 @@ function a(e) {
54
63
  liquidity: t(e.liquidity),
55
64
  openInterest: t(e.open_interest),
56
65
  reward24h: t(e.reward_24h),
57
- apr: t(e.apr),
66
+ apr: s(e.apr),
58
67
  aprByWindow: r(e, "apr"),
59
68
  tvlDrivenApy: i(e, "tvl_driven_apy"),
60
69
  priceDrivenApy: i(e, "price_driven_apy"),
@@ -71,7 +80,10 @@ function o(e) {
71
80
  items: (e.items ?? []).map(a)
72
81
  };
73
82
  }
83
+ function s(e) {
84
+ return e == null || e.trim() === "" || !Number.isFinite(Number(e)) ? null : Math.abs(Number(e)) > 1e6 ? t(e) : n(e);
85
+ }
74
86
  //#endregion
75
- export { n as parseListingValue, a as toListingMarket, o as toListingMarketPage, t as toListingValue };
87
+ export { n as parseListingValue, a as toListingMarket, o as toListingMarketPage, s as toListingPercent, t as toListingValue };
76
88
 
77
89
  //# sourceMappingURL=to-listing-market.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-listing-market.js","names":[],"sources":["../../../src/pools/markets/to-listing-market.ts"],"sourcesContent":["import { parseUnits } from \"viem\";\nimport {\n LISTING_VALUE_DECIMALS,\n ListingDepositChainId,\n ListingMarketStatus,\n type ListingApyWindows,\n type ListingMarket,\n type ListingMarketPage,\n type ListingTrailingWindows,\n} from \"../types\";\nimport type { MarketSearchItem, PaginationResponseMarketSearchItem } from \"../types/generated/listing-backend\";\n\n/**\n * Parse one of the service's 18-decimal value strings into a `bigint`.\n *\n * Returns `null` for `null`, `undefined`, and the empty string — an absent\n * figure is not zero, and collapsing the two would make a market with no 30-day\n * history indistinguishable from one that earned nothing.\n *\n * The service's own schema types these as plain unsigned decimal strings, but\n * live responses are looser than that in three ways, all handled here:\n *\n * - **Signs.** APY and uPnL fields go negative; a leading `-` is preserved.\n * - **Fractional tails.** `long_position_upnl` arrives as\n * `\"22411664984426494286154.904298\"`, which `BigInt()` would reject. The\n * fraction is truncated toward zero.\n * - **Scientific notation.** uPnL fields also arrive as `\"0E-36\"` (a Python\n * `Decimal` serialization). Every live instance is zero today, so a parser\n * that rejected the form would still *look* correct — but a tiny non-zero\n * uPnL would then silently read as `0`. The exponent is applied instead.\n */\nexport function toListingValue(raw: string | null | undefined): bigint | null {\n if (raw === null || raw === undefined) return null;\n\n const trimmed = raw.trim();\n if (trimmed === \"\") return null;\n\n const match = /^([+-]?)(\\d*)(?:\\.(\\d*))?(?:[eE]([+-]?\\d+))?$/.exec(trimmed);\n if (match === null) return null;\n\n const [, sign = \"\", intPart = \"\", fracPart = \"\", exponentPart] = match;\n if (intPart === \"\" && fracPart === \"\") return null;\n\n /**\n * Shift the decimal point by the exponent, then truncate. Working on the digit\n * string rather than via `10n ** exponent` keeps a large negative exponent\n * (`E-36`) from being an expensive division, and truncates toward zero for\n * free.\n */\n const digits = `${intPart}${fracPart}`;\n const pointIndex = intPart.length + (exponentPart === undefined ? 0 : Number(exponentPart));\n\n if (pointIndex <= 0) return 0n;\n\n const integerDigits = pointIndex >= digits.length ? digits.padEnd(pointIndex, \"0\") : digits.slice(0, pointIndex);\n\n const magnitude = BigInt(integerDigits);\n return sign === \"-\" ? -magnitude : magnitude;\n}\n\n/**\n * Parse a **human-decimal** listing figure — a plain dollar/token amount like\n * `\"0.037699391270769714\"` — into a `bigint` at {@link LISTING_VALUE_DECIMALS}\n * (18), scaling it **up** by `1e18`.\n *\n * This is the counterpart to {@link toListingValue}, not a variant of it. Most of\n * the listing API's money fields arrive already 1e18-scaled (`\"5300000000000000000\"`\n * = `5.3`), and `toListingValue` reads those by truncating a fractional dust tail.\n * A few fields — notably `claimable_reward` on `/v2/profit` — instead arrive in\n * **plain units** (`\"0.0377\"` = `$0.0377`); feeding those to `toListingValue`\n * would truncate the whole value to its integer part (here `0n`). Use this to\n * scale them into the SDK's uniform 18-decimal `bigint` instead.\n *\n * Returns `null` for a null / empty / unparseable value; a value with more than\n * 18 fractional digits is rounded by `parseUnits`.\n *\n * @param raw - The wire string, in plain (un-scaled) decimal units.\n * @returns The value at `LISTING_VALUE_DECIMALS`, or `null`.\n */\nexport function parseListingValue(raw: string | null | undefined): bigint | null {\n if (raw === null || raw === undefined) return null;\n\n const trimmed = raw.trim();\n if (trimmed === \"\") return null;\n\n try {\n return parseUnits(trimmed, LISTING_VALUE_DECIMALS);\n } catch {\n return null;\n }\n}\n\n/**\n * Map the four trailing windows of a metric whose wire keys share `prefix`.\n *\n * @param raw - The response row.\n * @param prefix - Wire key prefix, e.g. `\"apr\"` for `apr_1h` … `apr_30d`.\n */\nfunction toTrailingWindows(raw: MarketSearchItem, prefix: string): ListingTrailingWindows {\n const row = raw as unknown as Record<string, string | null | undefined>;\n return {\n h1: toListingValue(row[`${prefix}_1h`]),\n h6: toListingValue(row[`${prefix}_6h`]),\n h24: toListingValue(row[`${prefix}_24h`]),\n d30: toListingValue(row[`${prefix}_30d`]),\n };\n}\n\n/** Map the trailing windows plus the lifetime column of an APY series. */\nfunction toApyWindows(raw: MarketSearchItem, prefix: string): ListingApyWindows {\n const row = raw as unknown as Record<string, string | null | undefined>;\n return {\n ...toTrailingWindows(raw, prefix),\n lifetime: toListingValue(row[`${prefix}_lifetime`]),\n };\n}\n\n/**\n * Map one raw `MarketSearchItem` from the listing service into the SDK's\n * {@link ListingMarket}.\n *\n * Value fields become `bigint` at {@link ListingMarket} scale, absent figures\n * stay `null`, and the wire's snake_case becomes the SDK's camelCase.\n *\n * @param raw - One row of the service's `/v2/market/search` response.\n * @returns The normalized market.\n */\nexport function toListingMarket(raw: MarketSearchItem): ListingMarket {\n return {\n contractAddress: raw.contract_address,\n chainId: raw.chain_id as ListingDepositChainId,\n symbolId: raw.symbol_id ?? null,\n tokenTicker: raw.token_ticker,\n tokenName: raw.token_name,\n maxLeverage: raw.max_leverage,\n marketCap: toListingValue(raw.market_cap),\n vol24h: toListingValue(raw.vol24h),\n tvl: toListingValue(raw.tvl),\n liquidity: toListingValue(raw.liquidity),\n openInterest: toListingValue(raw.open_interest),\n reward24h: toListingValue(raw.reward_24h),\n apr: toListingValue(raw.apr),\n aprByWindow: toTrailingWindows(raw, \"apr\"),\n tvlDrivenApy: toApyWindows(raw, \"tvl_driven_apy\"),\n priceDrivenApy: toApyWindows(raw, \"price_driven_apy\"),\n listingTime: raw.listing_time ?? null,\n marketStatus: raw.market_status as unknown as ListingMarketStatus,\n isLocked: raw.is_locked,\n };\n}\n\n/**\n * Map the service's paginated envelope into a {@link ListingMarketPage}.\n *\n * The generated schema marks every envelope field optional (the service declares\n * defaults rather than requiring them), so each is defaulted here: counts to `0`\n * and `items` to an empty array.\n *\n * @param raw - The service's `/v2/market/search` response body.\n * @returns The normalized page.\n */\nexport function toListingMarketPage(raw: PaginationResponseMarketSearchItem): ListingMarketPage {\n return {\n total: raw.total ?? 0,\n limit: raw.limit ?? 0,\n offset: raw.offset ?? 0,\n items: (raw.items ?? []).map(toListingMarket),\n };\n}\n"],"mappings":";;;AA+BA,SAAgB,EAAe,GAA+C;CAC5E,IAAI,KAAQ,MAA2B,OAAO;CAE9C,IAAM,IAAU,EAAI,KAAK;CACzB,IAAI,MAAY,IAAI,OAAO;CAE3B,IAAM,IAAQ,gDAAgD,KAAK,CAAO;CAC1E,IAAI,MAAU,MAAM,OAAO;CAE3B,IAAM,GAAG,IAAO,IAAI,IAAU,IAAI,IAAW,IAAI,KAAgB;CACjE,IAAI,MAAY,MAAM,MAAa,IAAI,OAAO;CAQ9C,IAAM,IAAS,GAAG,IAAU,KACtB,IAAa,EAAQ,UAAU,MAAiB,KAAA,IAAY,IAAI,OAAO,CAAY;CAEzF,IAAI,KAAc,GAAG,OAAO;CAE5B,IAAM,IAAgB,KAAc,EAAO,SAAS,EAAO,OAAO,GAAY,GAAG,IAAI,EAAO,MAAM,GAAG,CAAU,GAEzG,IAAY,OAAO,CAAa;CACtC,OAAO,MAAS,MAAM,CAAC,IAAY;AACrC;AAqBA,SAAgB,EAAkB,GAA+C;CAC/E,IAAI,KAAQ,MAA2B,OAAO;CAE9C,IAAM,IAAU,EAAI,KAAK;CACzB,IAAI,MAAY,IAAI,OAAO;CAE3B,IAAI;EACF,OAAO,EAAW,GAAA,EAA+B;CACnD,QAAQ;EACN,OAAO;CACT;AACF;AAQA,SAAS,EAAkB,GAAuB,GAAwC;CACxF,IAAM,IAAM;CACZ,OAAO;EACL,IAAI,EAAe,EAAI,GAAG,EAAO,KAAK;EACtC,IAAI,EAAe,EAAI,GAAG,EAAO,KAAK;EACtC,KAAK,EAAe,EAAI,GAAG,EAAO,MAAM;EACxC,KAAK,EAAe,EAAI,GAAG,EAAO,MAAM;CAC1C;AACF;AAGA,SAAS,EAAa,GAAuB,GAAmC;CAC9E,IAAM,IAAM;CACZ,OAAO;EACL,GAAG,EAAkB,GAAK,CAAM;EAChC,UAAU,EAAe,EAAI,GAAG,EAAO,WAAW;CACpD;AACF;AAYA,SAAgB,EAAgB,GAAsC;CACpE,OAAO;EACL,iBAAiB,EAAI;EACrB,SAAS,EAAI;EACb,UAAU,EAAI,aAAa;EAC3B,aAAa,EAAI;EACjB,WAAW,EAAI;EACf,aAAa,EAAI;EACjB,WAAW,EAAe,EAAI,UAAU;EACxC,QAAQ,EAAe,EAAI,MAAM;EACjC,KAAK,EAAe,EAAI,GAAG;EAC3B,WAAW,EAAe,EAAI,SAAS;EACvC,cAAc,EAAe,EAAI,aAAa;EAC9C,WAAW,EAAe,EAAI,UAAU;EACxC,KAAK,EAAe,EAAI,GAAG;EAC3B,aAAa,EAAkB,GAAK,KAAK;EACzC,cAAc,EAAa,GAAK,gBAAgB;EAChD,gBAAgB,EAAa,GAAK,kBAAkB;EACpD,aAAa,EAAI,gBAAgB;EACjC,cAAc,EAAI;EAClB,UAAU,EAAI;CAChB;AACF;AAYA,SAAgB,EAAoB,GAA4D;CAC9F,OAAO;EACL,OAAO,EAAI,SAAS;EACpB,OAAO,EAAI,SAAS;EACpB,QAAQ,EAAI,UAAU;EACtB,QAAQ,EAAI,SAAS,CAAC,GAAG,IAAI,CAAe;CAC9C;AACF"}
1
+ {"version":3,"file":"to-listing-market.js","names":[],"sources":["../../../src/pools/markets/to-listing-market.ts"],"sourcesContent":["import { parseUnits } from \"viem\";\nimport {\n LISTING_VALUE_DECIMALS,\n ListingDepositChainId,\n ListingMarketStatus,\n type ListingApyWindows,\n type ListingMarket,\n type ListingMarketPage,\n type ListingTrailingWindows,\n} from \"../types\";\nimport type { MarketSearchItem, PaginationResponseMarketSearchItem } from \"../types/generated/listing-backend\";\n\n/**\n * Parse one of the service's 18-decimal value strings into a `bigint`.\n *\n * Returns `null` for `null`, `undefined`, and the empty string — an absent\n * figure is not zero, and collapsing the two would make a market with no 30-day\n * history indistinguishable from one that earned nothing.\n *\n * The service's own schema types these as plain unsigned decimal strings, but\n * live responses are looser than that in three ways, all handled here:\n *\n * - **Signs.** APY and uPnL fields go negative; a leading `-` is preserved.\n * - **Fractional tails.** `long_position_upnl` arrives as\n * `\"22411664984426494286154.904298\"`, which `BigInt()` would reject. The\n * fraction is truncated toward zero.\n * - **Scientific notation.** uPnL fields also arrive as `\"0E-36\"` (a Python\n * `Decimal` serialization). Every live instance is zero today, so a parser\n * that rejected the form would still *look* correct — but a tiny non-zero\n * uPnL would then silently read as `0`. The exponent is applied instead.\n */\nexport function toListingValue(raw: string | null | undefined): bigint | null {\n if (raw === null || raw === undefined) return null;\n\n const trimmed = raw.trim();\n if (trimmed === \"\") return null;\n\n const match = /^([+-]?)(\\d*)(?:\\.(\\d*))?(?:[eE]([+-]?\\d+))?$/.exec(trimmed);\n if (match === null) return null;\n\n const [, sign = \"\", intPart = \"\", fracPart = \"\", exponentPart] = match;\n if (intPart === \"\" && fracPart === \"\") return null;\n\n /**\n * Shift the decimal point by the exponent, then truncate. Working on the digit\n * string rather than via `10n ** exponent` keeps a large negative exponent\n * (`E-36`) from being an expensive division, and truncates toward zero for\n * free.\n */\n const digits = `${intPart}${fracPart}`;\n const pointIndex = intPart.length + (exponentPart === undefined ? 0 : Number(exponentPart));\n\n if (pointIndex <= 0) return 0n;\n\n const integerDigits = pointIndex >= digits.length ? digits.padEnd(pointIndex, \"0\") : digits.slice(0, pointIndex);\n\n const magnitude = BigInt(integerDigits);\n return sign === \"-\" ? -magnitude : magnitude;\n}\n\n/**\n * Parse a **human-decimal** listing figure — a plain dollar/token amount like\n * `\"0.037699391270769714\"` — into a `bigint` at {@link LISTING_VALUE_DECIMALS}\n * (18), scaling it **up** by `1e18`.\n *\n * This is the counterpart to {@link toListingValue}, not a variant of it. Most of\n * the listing API's money fields arrive already 1e18-scaled (`\"5300000000000000000\"`\n * = `5.3`), and `toListingValue` reads those by truncating a fractional dust tail.\n * A few fields — notably `claimable_reward` on `/v2/profit` — instead arrive in\n * **plain units** (`\"0.0377\"` = `$0.0377`); feeding those to `toListingValue`\n * would truncate the whole value to its integer part (here `0n`). Use this to\n * scale them into the SDK's uniform 18-decimal `bigint` instead.\n *\n * Returns `null` for a null / empty / unparseable value; a value with more than\n * 18 fractional digits is rounded by `parseUnits`.\n *\n * @param raw - The wire string, in plain (un-scaled) decimal units.\n * @returns The value at `LISTING_VALUE_DECIMALS`, or `null`.\n */\nexport function parseListingValue(raw: string | null | undefined): bigint | null {\n if (raw === null || raw === undefined) return null;\n\n const trimmed = raw.trim();\n if (trimmed === \"\") return null;\n\n try {\n return parseUnits(trimmed, LISTING_VALUE_DECIMALS);\n } catch {\n return null;\n }\n}\n\n/**\n * Map the four trailing windows of a metric whose wire keys share `prefix`.\n *\n * @param raw - The response row.\n * @param prefix - Wire key prefix, e.g. `\"apr\"` for `apr_1h` … `apr_30d`.\n */\nfunction toTrailingWindows(raw: MarketSearchItem, prefix: string): ListingTrailingWindows {\n const row = raw as unknown as Record<string, string | null | undefined>;\n return {\n h1: toListingPercent(row[`${prefix}_1h`]),\n h6: toListingPercent(row[`${prefix}_6h`]),\n h24: toListingPercent(row[`${prefix}_24h`]),\n d30: toListingPercent(row[`${prefix}_30d`]),\n };\n}\n\n/** Map the trailing windows plus the lifetime column of an APY series. */\nfunction toApyWindows(raw: MarketSearchItem, prefix: string): ListingApyWindows {\n const row = raw as unknown as Record<string, string | null | undefined>;\n return {\n ...toTrailingWindows(raw, prefix),\n lifetime: toListingPercent(row[`${prefix}_lifetime`]),\n };\n}\n\n/**\n * Map one raw `MarketSearchItem` from the listing service into the SDK's\n * {@link ListingMarket}.\n *\n * Value fields become `bigint` at {@link ListingMarket} scale, absent figures\n * stay `null`, and the wire's snake_case becomes the SDK's camelCase.\n *\n * @param raw - One row of the service's `/v2/market/search` response.\n * @returns The normalized market.\n */\nexport function toListingMarket(\n raw: MarketSearchItem & {\n price_usd?: string | null;\n apy_24h?: string | null;\n apy_30d?: string | null;\n apy_lifetime?: string | null;\n reward_30d?: string | null;\n reward_lifetime?: string | null;\n solver_revenue_24h?: string | null;\n solver_revenue_30d?: string | null;\n solver_revenue_lifetime?: string | null;\n },\n): ListingMarket {\n return {\n priceUsd: raw.price_usd ?? null,\n apy24h: toListingPercent(raw.apy_24h),\n apy30d: toListingPercent(raw.apy_30d),\n apyLifetime: toListingPercent(raw.apy_lifetime),\n reward30d: toListingValue(raw.reward_30d),\n rewardLifetime: toListingValue(raw.reward_lifetime),\n solverRevenue24h: toListingValue(raw.solver_revenue_24h),\n solverRevenue30d: toListingValue(raw.solver_revenue_30d),\n solverRevenueLifetime: toListingValue(raw.solver_revenue_lifetime),\n contractAddress: raw.contract_address,\n chainId: raw.chain_id as ListingDepositChainId,\n symbolId: raw.symbol_id ?? null,\n tokenTicker: raw.token_ticker,\n tokenName: raw.token_name,\n maxLeverage: raw.max_leverage,\n marketCap: toListingValue(raw.market_cap),\n vol24h: toListingValue(raw.vol24h),\n tvl: toListingValue(raw.tvl),\n liquidity: toListingValue(raw.liquidity),\n openInterest: toListingValue(raw.open_interest),\n reward24h: toListingValue(raw.reward_24h),\n apr: toListingPercent(raw.apr),\n aprByWindow: toTrailingWindows(raw, \"apr\"),\n tvlDrivenApy: toApyWindows(raw, \"tvl_driven_apy\"),\n priceDrivenApy: toApyWindows(raw, \"price_driven_apy\"),\n listingTime: raw.listing_time ?? null,\n marketStatus: raw.market_status as unknown as ListingMarketStatus,\n isLocked: raw.is_locked,\n };\n}\n\n/**\n * Map the service's paginated envelope into a {@link ListingMarketPage}.\n *\n * The generated schema marks every envelope field optional (the service declares\n * defaults rather than requiring them), so each is defaulted here: counts to `0`\n * and `items` to an empty array.\n *\n * @param raw - The service's `/v2/market/search` response body.\n * @returns The normalized page.\n */\nexport function toListingMarketPage(raw: PaginationResponseMarketSearchItem): ListingMarketPage {\n return {\n total: raw.total ?? 0,\n limit: raw.limit ?? 0,\n offset: raw.offset ?? 0,\n items: (raw.items ?? []).map(toListingMarket),\n };\n}\n\n/** Normalize rollout-era plain percentages and fixed-point percentages to 18 decimals. */\nexport function toListingPercent(raw: string | null | undefined): bigint | null {\n if (raw == null || raw.trim() === \"\" || !Number.isFinite(Number(raw))) return null;\n // Compatibility boundary: older listing deployments report large fixed-point rates.\n return Math.abs(Number(raw)) > 1_000_000 ? toListingValue(raw) : parseListingValue(raw);\n}\n"],"mappings":";;;AA+BA,SAAgB,EAAe,GAA+C;CAC5E,IAAI,KAAQ,MAA2B,OAAO;CAE9C,IAAM,IAAU,EAAI,KAAK;CACzB,IAAI,MAAY,IAAI,OAAO;CAE3B,IAAM,IAAQ,gDAAgD,KAAK,CAAO;CAC1E,IAAI,MAAU,MAAM,OAAO;CAE3B,IAAM,GAAG,IAAO,IAAI,IAAU,IAAI,IAAW,IAAI,KAAgB;CACjE,IAAI,MAAY,MAAM,MAAa,IAAI,OAAO;CAQ9C,IAAM,IAAS,GAAG,IAAU,KACtB,IAAa,EAAQ,UAAU,MAAiB,KAAA,IAAY,IAAI,OAAO,CAAY;CAEzF,IAAI,KAAc,GAAG,OAAO;CAE5B,IAAM,IAAgB,KAAc,EAAO,SAAS,EAAO,OAAO,GAAY,GAAG,IAAI,EAAO,MAAM,GAAG,CAAU,GAEzG,IAAY,OAAO,CAAa;CACtC,OAAO,MAAS,MAAM,CAAC,IAAY;AACrC;AAqBA,SAAgB,EAAkB,GAA+C;CAC/E,IAAI,KAAQ,MAA2B,OAAO;CAE9C,IAAM,IAAU,EAAI,KAAK;CACzB,IAAI,MAAY,IAAI,OAAO;CAE3B,IAAI;EACF,OAAO,EAAW,GAAA,EAA+B;CACnD,QAAQ;EACN,OAAO;CACT;AACF;AAQA,SAAS,EAAkB,GAAuB,GAAwC;CACxF,IAAM,IAAM;CACZ,OAAO;EACL,IAAI,EAAiB,EAAI,GAAG,EAAO,KAAK;EACxC,IAAI,EAAiB,EAAI,GAAG,EAAO,KAAK;EACxC,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CAC9C;AACF;AAGA,SAAgB,EAAiB,GAA+C;CAG9E,OAFI,KAAO,QAAQ,EAAI,KAAK,MAAM,MAAM,CAAC,OAAO,SAAS,OAAO,CAAG,CAAC,IAAU,OAEvE,KAAK,IAAI,OAAO,CAAG,CAAC,IAAI,MAAY,EAAe,CAAG,IAAI,EAAkB,CAAG;AACxF"}
@@ -0,0 +1,39 @@
1
+ import { AccountBalanceInfo } from '../../symmio-contracts/account-layer/types.js';
2
+ import { PoolReadGap } from '../composition.js';
3
+ import { PoolQuote } from '../types.js';
4
+ /** Normalized quote and account reads for the pool's open positions. */
5
+ export interface CalculatePoolOpenPositionsParameters {
6
+ quotes: readonly Partial<PoolQuote>[];
7
+ balances: Readonly<Record<string, Pick<AccountBalanceInfo, "allocatedBalance" | "lockedCVA" | "lockedLF" | "pendingLockedCVA" | "pendingLockedLF"> | null>>;
8
+ /** External/current mark price in USD. Omit when unknown. */
9
+ priceUsd?: number;
10
+ /** Set false when quotes are only a page; incomplete accounts cannot yield liquidation estimates. */
11
+ complete?: boolean;
12
+ /** Opt in to a quote-lock estimate when account liquidation is unavailable. */
13
+ allowQuoteLockEstimate?: boolean;
14
+ gaps?: readonly PoolReadGap[];
15
+ }
16
+ /** Calculate table metrics using the shared SDK quote primitives.
17
+ * @param input - SDK quotes, account balances and optional mark price.
18
+ * @returns Quote fields plus metrics; priceChangePercent is deliberately unleveraged.
19
+ */
20
+ export declare function calculatePoolOpenPositions<TQuote extends Partial<PoolQuote>>(input: Omit<CalculatePoolOpenPositionsParameters, "quotes"> & {
21
+ quotes: readonly TQuote[];
22
+ }): {
23
+ entries: (TQuote & {
24
+ remainingQuantity: bigint | null;
25
+ entryPrice: bigint | null;
26
+ positionValueUsd: number | null;
27
+ entryValueUsd: number | null;
28
+ leverageMultiplier: number | null;
29
+ upnlUsd: number | null;
30
+ priceChangePercent: number | null;
31
+ liquidationPrice: bigint | null;
32
+ liquidationSource: "account" | "quote-lock" | null;
33
+ openedAt: number | null;
34
+ })[];
35
+ gaps: PoolReadGap[];
36
+ };
37
+ /** Pool open-position table projection. */
38
+ export type PoolOpenPositions = ReturnType<typeof calculatePoolOpenPositions<PoolQuote>>;
39
+ //# sourceMappingURL=calculate-pool-open-positions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-pool-open-positions.d.ts","sourceRoot":"","sources":["../../../src/pools/open-positions/calculate-pool-open-positions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,wEAAwE;AACxE,MAAM,WAAW,oCAAoC;IACnD,MAAM,EAAE,SAAS,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;IACtC,QAAQ,EAAE,QAAQ,CAChB,MAAM,CACJ,MAAM,EACN,IAAI,CACF,kBAAkB,EAClB,kBAAkB,GAAG,WAAW,GAAG,UAAU,GAAG,kBAAkB,GAAG,iBAAiB,CACvF,GAAG,IAAI,CACT,CACF,CAAC;IACF,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qGAAqG;IACrG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,IAAI,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,SAAS,OAAO,CAAC,SAAS,CAAC,EAC1E,KAAK,EAAE,IAAI,CAAC,oCAAoC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE;;;;;;;;;;;;;;EA6E5F;AACD,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,SAAS,CAAC,CAAC,CAAC"}