@symmio/trading-core 4.0.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 (447) hide show
  1. package/dist/balance-history/get-balance-history/types.d.ts +3 -1
  2. package/dist/balance-history/get-balance-history/types.d.ts.map +1 -1
  3. package/dist/balance-history/get-balance-history/types.js +1 -1
  4. package/dist/balance-history/get-balance-history/types.js.map +1 -1
  5. package/dist/funding/get-funding-index-checkpoints/get-funding-index-checkpoints.d.ts +50 -0
  6. package/dist/funding/get-funding-index-checkpoints/get-funding-index-checkpoints.d.ts.map +1 -0
  7. package/dist/funding/get-funding-index-checkpoints/get-funding-index-checkpoints.js +30 -0
  8. package/dist/funding/get-funding-index-checkpoints/get-funding-index-checkpoints.js.map +1 -0
  9. package/dist/funding/get-funding-index-checkpoints/index.d.ts +5 -0
  10. package/dist/funding/get-funding-index-checkpoints/index.d.ts.map +1 -0
  11. package/dist/funding/get-funding-index-checkpoints/query-document.d.ts +16 -0
  12. package/dist/funding/get-funding-index-checkpoints/query-document.d.ts.map +1 -0
  13. package/dist/funding/get-funding-index-checkpoints/query-document.js +7 -0
  14. package/dist/funding/get-funding-index-checkpoints/query-document.js.map +1 -0
  15. package/dist/funding/get-funding-index-checkpoints/query.d.ts +37 -0
  16. package/dist/funding/get-funding-index-checkpoints/query.d.ts.map +1 -0
  17. package/dist/funding/get-funding-index-checkpoints/query.js +23 -0
  18. package/dist/funding/get-funding-index-checkpoints/query.js.map +1 -0
  19. package/dist/funding/get-funding-index-checkpoints/to-funding-index-checkpoint-row.d.ts +12 -0
  20. package/dist/funding/get-funding-index-checkpoints/to-funding-index-checkpoint-row.d.ts.map +1 -0
  21. package/dist/funding/get-funding-index-checkpoints/to-funding-index-checkpoint-row.js +31 -0
  22. package/dist/funding/get-funding-index-checkpoints/to-funding-index-checkpoint-row.js.map +1 -0
  23. package/dist/funding/get-funding-index-checkpoints/types.d.ts +51 -0
  24. package/dist/funding/get-funding-index-checkpoints/types.d.ts.map +1 -0
  25. package/dist/funding/get-quote-funding-settlements/get-quote-funding-settlements.d.ts +47 -0
  26. package/dist/funding/get-quote-funding-settlements/get-quote-funding-settlements.d.ts.map +1 -0
  27. package/dist/funding/get-quote-funding-settlements/get-quote-funding-settlements.js +30 -0
  28. package/dist/funding/get-quote-funding-settlements/get-quote-funding-settlements.js.map +1 -0
  29. package/dist/funding/get-quote-funding-settlements/index.d.ts +5 -0
  30. package/dist/funding/get-quote-funding-settlements/index.d.ts.map +1 -0
  31. package/dist/funding/get-quote-funding-settlements/query-document.d.ts +16 -0
  32. package/dist/funding/get-quote-funding-settlements/query-document.d.ts.map +1 -0
  33. package/dist/funding/get-quote-funding-settlements/query-document.js +7 -0
  34. package/dist/funding/get-quote-funding-settlements/query-document.js.map +1 -0
  35. package/dist/funding/get-quote-funding-settlements/query.d.ts +37 -0
  36. package/dist/funding/get-quote-funding-settlements/query.d.ts.map +1 -0
  37. package/dist/funding/get-quote-funding-settlements/query.js +23 -0
  38. package/dist/funding/get-quote-funding-settlements/query.js.map +1 -0
  39. package/dist/funding/get-quote-funding-settlements/to-quote-funding-settlement-row.d.ts +12 -0
  40. package/dist/funding/get-quote-funding-settlements/to-quote-funding-settlement-row.d.ts.map +1 -0
  41. package/dist/funding/get-quote-funding-settlements/to-quote-funding-settlement-row.js +33 -0
  42. package/dist/funding/get-quote-funding-settlements/to-quote-funding-settlement-row.js.map +1 -0
  43. package/dist/funding/get-quote-funding-settlements/types.d.ts +56 -0
  44. package/dist/funding/get-quote-funding-settlements/types.d.ts.map +1 -0
  45. package/dist/funding/index.d.ts +3 -0
  46. package/dist/funding/index.d.ts.map +1 -0
  47. package/dist/index.d.ts +63 -4
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +427 -386
  50. package/dist/liquidation/get-liquidation-details/get-liquidation-details.d.ts +44 -0
  51. package/dist/liquidation/get-liquidation-details/get-liquidation-details.d.ts.map +1 -0
  52. package/dist/liquidation/get-liquidation-details/get-liquidation-details.js +30 -0
  53. package/dist/liquidation/get-liquidation-details/get-liquidation-details.js.map +1 -0
  54. package/dist/liquidation/get-liquidation-details/index.d.ts +5 -0
  55. package/dist/liquidation/get-liquidation-details/index.d.ts.map +1 -0
  56. package/dist/liquidation/get-liquidation-details/query-document.d.ts +16 -0
  57. package/dist/liquidation/get-liquidation-details/query-document.d.ts.map +1 -0
  58. package/dist/liquidation/get-liquidation-details/query-document.js +7 -0
  59. package/dist/liquidation/get-liquidation-details/query-document.js.map +1 -0
  60. package/dist/liquidation/get-liquidation-details/query.d.ts +37 -0
  61. package/dist/liquidation/get-liquidation-details/query.d.ts.map +1 -0
  62. package/dist/liquidation/get-liquidation-details/query.js +23 -0
  63. package/dist/liquidation/get-liquidation-details/query.js.map +1 -0
  64. package/dist/liquidation/get-liquidation-details/to-liquidation-detail-row.d.ts +12 -0
  65. package/dist/liquidation/get-liquidation-details/to-liquidation-detail-row.d.ts.map +1 -0
  66. package/dist/liquidation/get-liquidation-details/to-liquidation-detail-row.js +32 -0
  67. package/dist/liquidation/get-liquidation-details/to-liquidation-detail-row.js.map +1 -0
  68. package/dist/liquidation/get-liquidation-details/types.d.ts +47 -0
  69. package/dist/liquidation/get-liquidation-details/types.d.ts.map +1 -0
  70. package/dist/liquidation/index.d.ts +2 -0
  71. package/dist/liquidation/index.d.ts.map +1 -0
  72. package/dist/margin/get-margin-transfers/get-margin-transfers.d.ts +51 -0
  73. package/dist/margin/get-margin-transfers/get-margin-transfers.d.ts.map +1 -0
  74. package/dist/margin/get-margin-transfers/get-margin-transfers.js +32 -0
  75. package/dist/margin/get-margin-transfers/get-margin-transfers.js.map +1 -0
  76. package/dist/margin/get-margin-transfers/index.d.ts +5 -0
  77. package/dist/margin/get-margin-transfers/index.d.ts.map +1 -0
  78. package/dist/margin/get-margin-transfers/query-document.d.ts +17 -0
  79. package/dist/margin/get-margin-transfers/query-document.d.ts.map +1 -0
  80. package/dist/margin/get-margin-transfers/query-document.js +7 -0
  81. package/dist/margin/get-margin-transfers/query-document.js.map +1 -0
  82. package/dist/margin/get-margin-transfers/query.d.ts +37 -0
  83. package/dist/margin/get-margin-transfers/query.d.ts.map +1 -0
  84. package/dist/margin/get-margin-transfers/query.js +23 -0
  85. package/dist/margin/get-margin-transfers/query.js.map +1 -0
  86. package/dist/margin/get-margin-transfers/to-margin-transfer-row.d.ts +12 -0
  87. package/dist/margin/get-margin-transfers/to-margin-transfer-row.d.ts.map +1 -0
  88. package/dist/margin/get-margin-transfers/to-margin-transfer-row.js +19 -0
  89. package/dist/margin/get-margin-transfers/to-margin-transfer-row.js.map +1 -0
  90. package/dist/margin/get-margin-transfers/types.d.ts +27 -0
  91. package/dist/margin/get-margin-transfers/types.d.ts.map +1 -0
  92. package/dist/margin/index.d.ts +1 -0
  93. package/dist/margin/index.d.ts.map +1 -1
  94. package/dist/pools/add-market/to-created-pool.d.ts.map +1 -1
  95. package/dist/pools/add-market/to-created-pool.js +4 -0
  96. package/dist/pools/add-market/to-created-pool.js.map +1 -1
  97. package/dist/pools/add-market/types.d.ts +8 -0
  98. package/dist/pools/add-market/types.d.ts.map +1 -1
  99. package/dist/pools/auth/authenticate-listing.d.ts +3 -1
  100. package/dist/pools/auth/authenticate-listing.d.ts.map +1 -1
  101. package/dist/pools/auth/authenticate-listing.js +28 -23
  102. package/dist/pools/auth/authenticate-listing.js.map +1 -1
  103. package/dist/pools/auth/can-reuse-listing-challenge.d.ts +5 -0
  104. package/dist/pools/auth/can-reuse-listing-challenge.d.ts.map +1 -0
  105. package/dist/pools/auth/can-reuse-listing-challenge.js +9 -0
  106. package/dist/pools/auth/can-reuse-listing-challenge.js.map +1 -0
  107. package/dist/pools/auth/query.d.ts +15 -0
  108. package/dist/pools/auth/query.d.ts.map +1 -1
  109. package/dist/pools/auth/query.js +28 -4
  110. package/dist/pools/auth/query.js.map +1 -1
  111. package/dist/pools/auth/to-siwe.d.ts +5 -1
  112. package/dist/pools/auth/to-siwe.d.ts.map +1 -1
  113. package/dist/pools/auth/to-siwe.js +4 -2
  114. package/dist/pools/auth/to-siwe.js.map +1 -1
  115. package/dist/pools/auth/types.d.ts +2 -0
  116. package/dist/pools/auth/types.d.ts.map +1 -1
  117. package/dist/pools/cancel-withdraw/cancel-withdraw.js +1 -1
  118. package/dist/pools/cancel-withdraw/cancel-withdraw.js.map +1 -1
  119. package/dist/pools/claim-history/get-pool-claim.d.ts +11 -0
  120. package/dist/pools/claim-history/get-pool-claim.d.ts.map +1 -0
  121. package/dist/pools/claim-history/get-pool-claim.js +25 -0
  122. package/dist/pools/claim-history/get-pool-claim.js.map +1 -0
  123. package/dist/pools/claim-history/index.d.ts +1 -0
  124. package/dist/pools/claim-history/index.d.ts.map +1 -1
  125. package/dist/pools/claim-history/to-pool-claim.d.ts.map +1 -1
  126. package/dist/pools/claim-history/to-pool-claim.js +2 -0
  127. package/dist/pools/claim-history/to-pool-claim.js.map +1 -1
  128. package/dist/pools/composition.d.ts +16 -0
  129. package/dist/pools/composition.d.ts.map +1 -0
  130. package/dist/pools/composition.js +39 -0
  131. package/dist/pools/composition.js.map +1 -0
  132. package/dist/pools/empty-pool-profit.d.ts +4 -0
  133. package/dist/pools/empty-pool-profit.d.ts.map +1 -0
  134. package/dist/pools/empty-pool-profit.js +17 -0
  135. package/dist/pools/empty-pool-profit.js.map +1 -0
  136. package/dist/pools/index.d.ts +8 -0
  137. package/dist/pools/index.d.ts.map +1 -1
  138. package/dist/pools/listing-config/to-listing-config.d.ts +5 -1
  139. package/dist/pools/listing-config/to-listing-config.d.ts.map +1 -1
  140. package/dist/pools/listing-config/to-listing-config.js +19 -8
  141. package/dist/pools/listing-config/to-listing-config.js.map +1 -1
  142. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts +37 -0
  143. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts.map +1 -0
  144. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js +35 -0
  145. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js.map +1 -0
  146. package/dist/pools/maintenance-fees/index.d.ts +3 -0
  147. package/dist/pools/maintenance-fees/index.d.ts.map +1 -0
  148. package/dist/pools/maintenance-fees/query.d.ts +11 -0
  149. package/dist/pools/maintenance-fees/query.d.ts.map +1 -0
  150. package/dist/pools/maintenance-fees/query.js +21 -0
  151. package/dist/pools/maintenance-fees/query.js.map +1 -0
  152. package/dist/pools/market-config/to-listing-market-config.d.ts +6 -1
  153. package/dist/pools/market-config/to-listing-market-config.d.ts.map +1 -1
  154. package/dist/pools/market-config/to-listing-market-config.js +1 -0
  155. package/dist/pools/market-config/to-listing-market-config.js.map +1 -1
  156. package/dist/pools/market-config/types.d.ts +5 -0
  157. package/dist/pools/market-config/types.d.ts.map +1 -1
  158. package/dist/pools/market-config/types.js.map +1 -1
  159. package/dist/pools/market-data/get-pool-market-data.d.ts +14 -0
  160. package/dist/pools/market-data/get-pool-market-data.d.ts.map +1 -0
  161. package/dist/pools/market-data/get-pool-market-data.js +25 -0
  162. package/dist/pools/market-data/get-pool-market-data.js.map +1 -0
  163. package/dist/pools/market-data/index.d.ts +2 -0
  164. package/dist/pools/market-data/index.d.ts.map +1 -0
  165. package/dist/pools/market-detail/to-listing-market-detail.d.ts +5 -1
  166. package/dist/pools/market-detail/to-listing-market-detail.d.ts.map +1 -1
  167. package/dist/pools/market-detail/to-listing-market-detail.js +45 -33
  168. package/dist/pools/market-detail/to-listing-market-detail.js.map +1 -1
  169. package/dist/pools/markets/to-listing-market.d.ts +13 -1
  170. package/dist/pools/markets/to-listing-market.d.ts.map +1 -1
  171. package/dist/pools/markets/to-listing-market.js +24 -12
  172. package/dist/pools/markets/to-listing-market.js.map +1 -1
  173. package/dist/pools/open-positions/calculate-pool-open-positions.d.ts +39 -0
  174. package/dist/pools/open-positions/calculate-pool-open-positions.d.ts.map +1 -0
  175. package/dist/pools/open-positions/calculate-pool-open-positions.js +83 -0
  176. package/dist/pools/open-positions/calculate-pool-open-positions.js.map +1 -0
  177. package/dist/pools/open-positions/get-pool-open-positions.d.ts +17 -0
  178. package/dist/pools/open-positions/get-pool-open-positions.d.ts.map +1 -0
  179. package/dist/pools/open-positions/get-pool-open-positions.js +39 -0
  180. package/dist/pools/open-positions/get-pool-open-positions.js.map +1 -0
  181. package/dist/pools/open-positions/index.d.ts +4 -0
  182. package/dist/pools/open-positions/index.d.ts.map +1 -0
  183. package/dist/pools/open-positions/query.d.ts +17 -0
  184. package/dist/pools/open-positions/query.d.ts.map +1 -0
  185. package/dist/pools/open-positions/query.js +21 -0
  186. package/dist/pools/open-positions/query.js.map +1 -0
  187. package/dist/pools/portfolio/calculate-pool-portfolio.d.ts +66 -0
  188. package/dist/pools/portfolio/calculate-pool-portfolio.d.ts.map +1 -0
  189. package/dist/pools/portfolio/calculate-pool-portfolio.js +96 -0
  190. package/dist/pools/portfolio/calculate-pool-portfolio.js.map +1 -0
  191. package/dist/pools/portfolio/get-pool-portfolio.d.ts +19 -0
  192. package/dist/pools/portfolio/get-pool-portfolio.d.ts.map +1 -0
  193. package/dist/pools/portfolio/get-pool-portfolio.js +88 -0
  194. package/dist/pools/portfolio/get-pool-portfolio.js.map +1 -0
  195. package/dist/pools/portfolio/index.d.ts +4 -0
  196. package/dist/pools/portfolio/index.d.ts.map +1 -0
  197. package/dist/pools/portfolio/query.d.ts +17 -0
  198. package/dist/pools/portfolio/query.d.ts.map +1 -0
  199. package/dist/pools/portfolio/query.js +21 -0
  200. package/dist/pools/portfolio/query.js.map +1 -0
  201. package/dist/pools/portfolio/read-positions.d.ts +4 -0
  202. package/dist/pools/portfolio/read-positions.d.ts.map +1 -0
  203. package/dist/pools/portfolio/read-positions.js +31 -0
  204. package/dist/pools/portfolio/read-positions.js.map +1 -0
  205. package/dist/pools/position/calculate-pool-position.d.ts +85 -0
  206. package/dist/pools/position/calculate-pool-position.d.ts.map +1 -0
  207. package/dist/pools/position/calculate-pool-position.js +59 -0
  208. package/dist/pools/position/calculate-pool-position.js.map +1 -0
  209. package/dist/pools/position/get-pool-position.d.ts +22 -0
  210. package/dist/pools/position/get-pool-position.d.ts.map +1 -0
  211. package/dist/pools/position/get-pool-position.js +47 -0
  212. package/dist/pools/position/get-pool-position.js.map +1 -0
  213. package/dist/pools/position/index.d.ts +4 -0
  214. package/dist/pools/position/index.d.ts.map +1 -0
  215. package/dist/pools/position/query.d.ts +17 -0
  216. package/dist/pools/position/query.d.ts.map +1 -0
  217. package/dist/pools/position/query.js +21 -0
  218. package/dist/pools/position/query.js.map +1 -0
  219. package/dist/pools/position/sum-deposits.d.ts +10 -0
  220. package/dist/pools/position/sum-deposits.d.ts.map +1 -0
  221. package/dist/pools/position/sum-deposits.js +35 -0
  222. package/dist/pools/position/sum-deposits.js.map +1 -0
  223. package/dist/pools/profit/get-user-profit.d.ts +4 -0
  224. package/dist/pools/profit/get-user-profit.d.ts.map +1 -1
  225. package/dist/pools/profit/get-user-profit.js +18 -12
  226. package/dist/pools/profit/get-user-profit.js.map +1 -1
  227. package/dist/pools/profit/to-user-pool-profit.d.ts +22 -4
  228. package/dist/pools/profit/to-user-pool-profit.d.ts.map +1 -1
  229. package/dist/pools/profit/to-user-pool-profit.js +28 -12
  230. package/dist/pools/profit/to-user-pool-profit.js.map +1 -1
  231. package/dist/pools/quotes/get-pool-quotes.d.ts +8 -1
  232. package/dist/pools/quotes/get-pool-quotes.d.ts.map +1 -1
  233. package/dist/pools/quotes/get-pool-quotes.js +8 -1
  234. package/dist/pools/quotes/get-pool-quotes.js.map +1 -1
  235. package/dist/pools/quotes/query-document.d.ts.map +1 -1
  236. package/dist/pools/quotes/query-document.js +1 -1
  237. package/dist/pools/quotes/query-document.js.map +1 -1
  238. package/dist/pools/quotes/to-pool-quote.d.ts.map +1 -1
  239. package/dist/pools/quotes/to-pool-quote.js +13 -0
  240. package/dist/pools/quotes/to-pool-quote.js.map +1 -1
  241. package/dist/pools/rewards/query.js +25 -25
  242. package/dist/pools/statistics/calculate-pool-statistics.d.ts +69 -0
  243. package/dist/pools/statistics/calculate-pool-statistics.d.ts.map +1 -0
  244. package/dist/pools/statistics/calculate-pool-statistics.js +42 -0
  245. package/dist/pools/statistics/calculate-pool-statistics.js.map +1 -0
  246. package/dist/pools/statistics/get-pool-statistics.d.ts +29 -0
  247. package/dist/pools/statistics/get-pool-statistics.d.ts.map +1 -0
  248. package/dist/pools/statistics/get-pool-statistics.js +61 -0
  249. package/dist/pools/statistics/get-pool-statistics.js.map +1 -0
  250. package/dist/pools/statistics/index.d.ts +4 -0
  251. package/dist/pools/statistics/index.d.ts.map +1 -0
  252. package/dist/pools/statistics/query.d.ts +17 -0
  253. package/dist/pools/statistics/query.d.ts.map +1 -0
  254. package/dist/pools/statistics/query.js +21 -0
  255. package/dist/pools/statistics/query.js.map +1 -0
  256. package/dist/pools/token-metadata/get-listing-token-metadata.d.ts +32 -0
  257. package/dist/pools/token-metadata/get-listing-token-metadata.d.ts.map +1 -0
  258. package/dist/pools/token-metadata/get-listing-token-metadata.js +43 -0
  259. package/dist/pools/token-metadata/get-listing-token-metadata.js.map +1 -0
  260. package/dist/pools/token-metadata/index.d.ts +3 -0
  261. package/dist/pools/token-metadata/index.d.ts.map +1 -0
  262. package/dist/pools/token-metadata/query.d.ts +11 -0
  263. package/dist/pools/token-metadata/query.d.ts.map +1 -0
  264. package/dist/pools/token-metadata/query.js +21 -0
  265. package/dist/pools/token-metadata/query.js.map +1 -0
  266. package/dist/pools/token-support/check-listing-token-support.d.ts +23 -0
  267. package/dist/pools/token-support/check-listing-token-support.d.ts.map +1 -0
  268. package/dist/pools/token-support/check-listing-token-support.js +36 -0
  269. package/dist/pools/token-support/check-listing-token-support.js.map +1 -0
  270. package/dist/pools/token-support/index.d.ts +3 -0
  271. package/dist/pools/token-support/index.d.ts.map +1 -0
  272. package/dist/pools/token-support/query.d.ts +11 -0
  273. package/dist/pools/token-support/query.d.ts.map +1 -0
  274. package/dist/pools/token-support/query.js +21 -0
  275. package/dist/pools/token-support/query.js.map +1 -0
  276. package/dist/pools/trade-history/calculate-history-metrics.d.ts +12 -0
  277. package/dist/pools/trade-history/calculate-history-metrics.d.ts.map +1 -0
  278. package/dist/pools/trade-history/calculate-history-metrics.js +36 -0
  279. package/dist/pools/trade-history/calculate-history-metrics.js.map +1 -0
  280. package/dist/pools/trade-history/get-pool-trade-history.d.ts +21 -1
  281. package/dist/pools/trade-history/get-pool-trade-history.d.ts.map +1 -1
  282. package/dist/pools/trade-history/get-pool-trade-history.js +57 -18
  283. package/dist/pools/trade-history/get-pool-trade-history.js.map +1 -1
  284. package/dist/pools/trade-history/query-document.d.ts +3 -0
  285. package/dist/pools/trade-history/query-document.d.ts.map +1 -1
  286. package/dist/pools/trade-history/query-document.js +1 -1
  287. package/dist/pools/trade-history/query-document.js.map +1 -1
  288. package/dist/pools/transactions/get-pool-transaction-range.d.ts +6 -0
  289. package/dist/pools/transactions/get-pool-transaction-range.d.ts.map +1 -0
  290. package/dist/pools/transactions/get-pool-transaction-range.js +26 -0
  291. package/dist/pools/transactions/get-pool-transaction-range.js.map +1 -0
  292. package/dist/pools/transactions/index.d.ts +1 -0
  293. package/dist/pools/transactions/index.d.ts.map +1 -1
  294. package/dist/pools/types/generated/listing-backend.js +34 -10
  295. package/dist/pools/types/generated/listing-backend.js.map +1 -1
  296. package/dist/pools/types.d.ts +129 -6
  297. package/dist/pools/types.d.ts.map +1 -1
  298. package/dist/pools/types.js.map +1 -1
  299. package/dist/pools/user-markets/get-user-listing-markets.d.ts +2 -0
  300. package/dist/pools/user-markets/get-user-listing-markets.d.ts.map +1 -1
  301. package/dist/pools/user-markets/get-user-listing-markets.js.map +1 -1
  302. package/dist/pools/user-markets/to-user-listing-market.js +1 -1
  303. package/dist/pools/user-markets/to-user-listing-market.js.map +1 -1
  304. package/dist/pools/user-transactions/get-user-transactions.d.ts +2 -0
  305. package/dist/pools/user-transactions/get-user-transactions.d.ts.map +1 -1
  306. package/dist/pools/user-transactions/get-user-transactions.js.map +1 -1
  307. package/dist/pools/user-transactions/to-user-transaction.d.ts +5 -1
  308. package/dist/pools/user-transactions/to-user-transaction.d.ts.map +1 -1
  309. package/dist/pools/user-transactions/to-user-transaction.js +3 -0
  310. package/dist/pools/user-transactions/to-user-transaction.js.map +1 -1
  311. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.d.ts +22 -12
  312. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.d.ts.map +1 -1
  313. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.js +20 -21
  314. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.js.map +1 -1
  315. package/dist/quotes/get-quote-events-by-type/query-document.d.ts +5 -5
  316. package/dist/quotes/get-quote-events-by-type/query-document.d.ts.map +1 -1
  317. package/dist/quotes/get-quote-events-by-type/query-document.js +1 -1
  318. package/dist/quotes/get-quote-events-by-type/query-document.js.map +1 -1
  319. package/dist/quotes/get-quote-events-by-type/query.d.ts +7 -6
  320. package/dist/quotes/get-quote-events-by-type/query.d.ts.map +1 -1
  321. package/dist/quotes/get-quote-events-by-type/query.js +19 -17
  322. package/dist/quotes/get-quote-events-by-type/query.js.map +1 -1
  323. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.d.ts +2 -2
  324. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.d.ts.map +1 -1
  325. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.js +1 -3
  326. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.js.map +1 -1
  327. package/dist/quotes/get-quote-events-by-type/types.d.ts +14 -3
  328. package/dist/quotes/get-quote-events-by-type/types.d.ts.map +1 -1
  329. package/dist/quotes/get-quote-events-by-type/types.js.map +1 -1
  330. package/dist/quotes/get-quote-funding/get-quote-funding.d.ts +12 -2
  331. package/dist/quotes/get-quote-funding/get-quote-funding.d.ts.map +1 -1
  332. package/dist/quotes/get-quote-funding/get-quote-funding.js +21 -17
  333. package/dist/quotes/get-quote-funding/get-quote-funding.js.map +1 -1
  334. package/dist/quotes/get-quote-funding/query-document.d.ts +3 -2
  335. package/dist/quotes/get-quote-funding/query-document.d.ts.map +1 -1
  336. package/dist/quotes/get-quote-funding/query-document.js +1 -1
  337. package/dist/quotes/get-quote-funding/query-document.js.map +1 -1
  338. package/dist/quotes/get-quote-funding/query.d.ts.map +1 -1
  339. package/dist/quotes/get-quote-funding/query.js +2 -1
  340. package/dist/quotes/get-quote-funding/query.js.map +1 -1
  341. package/dist/quotes/get-quote-funding/to-funding-row.d.ts.map +1 -1
  342. package/dist/quotes/get-quote-funding/to-funding-row.js +1 -3
  343. package/dist/quotes/get-quote-funding/to-funding-row.js.map +1 -1
  344. package/dist/quotes/get-quote-history/get-quote-history.d.ts +18 -7
  345. package/dist/quotes/get-quote-history/get-quote-history.d.ts.map +1 -1
  346. package/dist/quotes/get-quote-history/get-quote-history.js +32 -22
  347. package/dist/quotes/get-quote-history/get-quote-history.js.map +1 -1
  348. package/dist/quotes/get-quote-history/query-document.d.ts +12 -7
  349. package/dist/quotes/get-quote-history/query-document.d.ts.map +1 -1
  350. package/dist/quotes/get-quote-history/query-document.js +1 -1
  351. package/dist/quotes/get-quote-history/query-document.js.map +1 -1
  352. package/dist/quotes/get-quote-history/query.d.ts +3 -2
  353. package/dist/quotes/get-quote-history/query.d.ts.map +1 -1
  354. package/dist/quotes/get-quote-history/query.js +22 -19
  355. package/dist/quotes/get-quote-history/query.js.map +1 -1
  356. package/dist/quotes/get-quote-history/to-history-row.d.ts.map +1 -1
  357. package/dist/quotes/get-quote-history/to-history-row.js +52 -37
  358. package/dist/quotes/get-quote-history/to-history-row.js.map +1 -1
  359. package/dist/quotes/get-quote-history/types.d.ts +41 -0
  360. package/dist/quotes/get-quote-history/types.d.ts.map +1 -1
  361. package/dist/quotes/get-quote-history/types.js.map +1 -1
  362. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.d.ts +21 -11
  363. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.d.ts.map +1 -1
  364. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.js +19 -21
  365. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.js.map +1 -1
  366. package/dist/quotes/get-quotes-events-by-type/query-document.d.ts +7 -7
  367. package/dist/quotes/get-quotes-events-by-type/query-document.d.ts.map +1 -1
  368. package/dist/quotes/get-quotes-events-by-type/query-document.js +1 -1
  369. package/dist/quotes/get-quotes-events-by-type/query-document.js.map +1 -1
  370. package/dist/quotes/get-quotes-events-by-type/query.d.ts +8 -6
  371. package/dist/quotes/get-quotes-events-by-type/query.d.ts.map +1 -1
  372. package/dist/quotes/get-quotes-events-by-type/query.js +22 -20
  373. package/dist/quotes/get-quotes-events-by-type/query.js.map +1 -1
  374. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.d.ts +38 -0
  375. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.d.ts.map +1 -0
  376. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.js +28 -0
  377. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.js.map +1 -0
  378. package/dist/quotes/get-subgraph-quotes/index.d.ts +5 -0
  379. package/dist/quotes/get-subgraph-quotes/index.d.ts.map +1 -0
  380. package/dist/quotes/get-subgraph-quotes/query-document.d.ts +15 -0
  381. package/dist/quotes/get-subgraph-quotes/query-document.d.ts.map +1 -0
  382. package/dist/quotes/get-subgraph-quotes/query-document.js +7 -0
  383. package/dist/quotes/get-subgraph-quotes/query-document.js.map +1 -0
  384. package/dist/quotes/get-subgraph-quotes/query.d.ts +37 -0
  385. package/dist/quotes/get-subgraph-quotes/query.d.ts.map +1 -0
  386. package/dist/quotes/get-subgraph-quotes/query.js +23 -0
  387. package/dist/quotes/get-subgraph-quotes/query.js.map +1 -0
  388. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.d.ts +12 -0
  389. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.d.ts.map +1 -0
  390. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.js +32 -0
  391. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.js.map +1 -0
  392. package/dist/quotes/get-subgraph-quotes/types.d.ts +54 -0
  393. package/dist/quotes/get-subgraph-quotes/types.d.ts.map +1 -0
  394. package/dist/quotes/index.d.ts +1 -0
  395. package/dist/quotes/index.d.ts.map +1 -1
  396. package/dist/quotes/liquidation/calculate-liquidation-price.d.ts +5 -1
  397. package/dist/quotes/liquidation/calculate-liquidation-price.d.ts.map +1 -1
  398. package/dist/quotes/liquidation/calculate-liquidation-price.js +1 -1
  399. package/dist/quotes/liquidation/calculate-liquidation-price.js.map +1 -1
  400. package/dist/quotes/upnl/calculate-quote-pnl.d.ts.map +1 -1
  401. package/dist/quotes/upnl/calculate-quote-pnl.js +8 -8
  402. package/dist/quotes/upnl/calculate-quote-pnl.js.map +1 -1
  403. package/dist/quotes/upnl/calculate-quote-upnl.d.ts +2 -2
  404. package/dist/quotes/upnl/calculate-quote-upnl.d.ts.map +1 -1
  405. package/dist/quotes/upnl/calculate-quote-upnl.js +16 -15
  406. package/dist/quotes/upnl/calculate-quote-upnl.js.map +1 -1
  407. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.d.ts +122 -0
  408. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.d.ts.map +1 -0
  409. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.js +80 -0
  410. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.js.map +1 -0
  411. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/index.d.ts +3 -0
  412. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/index.d.ts.map +1 -0
  413. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.d.ts +37 -0
  414. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.d.ts.map +1 -0
  415. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.js +27 -0
  416. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.js.map +1 -0
  417. package/dist/symmio-contracts/symmio/index.d.ts +2 -0
  418. package/dist/symmio-contracts/symmio/index.d.ts.map +1 -1
  419. package/dist/symmio-contracts/symmio/is-party-a-liquidated/index.d.ts +3 -0
  420. package/dist/symmio-contracts/symmio/is-party-a-liquidated/index.d.ts.map +1 -0
  421. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.d.ts +37 -0
  422. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.d.ts.map +1 -0
  423. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.js +15 -0
  424. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.js.map +1 -0
  425. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.d.ts +38 -0
  426. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.d.ts.map +1 -0
  427. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.js +29 -0
  428. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.js.map +1 -0
  429. package/dist/symmio-subgraph/index.d.ts +1 -0
  430. package/dist/symmio-subgraph/index.d.ts.map +1 -1
  431. package/dist/symmio-subgraph/subgraph-decode.d.ts +51 -0
  432. package/dist/symmio-subgraph/subgraph-decode.d.ts.map +1 -0
  433. package/dist/symmio-subgraph/subgraph-decode.js +24 -0
  434. package/dist/symmio-subgraph/subgraph-decode.js.map +1 -0
  435. package/dist/symmio-subgraph/subgraph-filters.d.ts +97 -0
  436. package/dist/symmio-subgraph/subgraph-filters.d.ts.map +1 -0
  437. package/dist/symmio-subgraph/subgraph-filters.js +39 -0
  438. package/dist/symmio-subgraph/subgraph-filters.js.map +1 -0
  439. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts +26 -6
  440. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts.map +1 -1
  441. package/dist/symmio-subgraph/types/generated/analytics/gql.js +16 -11
  442. package/dist/symmio-subgraph/types/generated/analytics/gql.js.map +1 -1
  443. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts +3661 -9
  444. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts.map +1 -1
  445. package/dist/symmio-subgraph/types/generated/analytics/graphql.js +2 -2
  446. package/dist/symmio-subgraph/types/generated/analytics/graphql.js.map +1 -1
  447. package/package.json +1 -1
@@ -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,EAAI,GAAG,EAAO,KAAK;EACtC,KAAK,EAAe,EAAI,GAAG,EAAO,MAAM;EACxC,KAAK,EAAe,EAAI,GAAG,EAAO,MAAM;EACxC,UAAU,EAAe,EAAI,GAAG,EAAO,WAAW;CACpD;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,EAAsB,GAAmD;CACvF,OAAO;EACL,sBAAsB,EAAI;EAC1B,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;EAClB,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,EAAU,GAAK,KAAK;EACzB,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"}
1
+ {"version":3,"file":"to-listing-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,K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U,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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,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC,GACA,aAAa,CA+Bf;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kCAAkC,GAAG,iBAAiB,CAO9F;AAED,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,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,IA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,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,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;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,EAAiB,EAAI,GAAG;EAC7B,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;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"}
@@ -0,0 +1,83 @@
1
+ import { PositionType as e } from "../../symmio-contracts/symmio/types.js";
2
+ import { calculateLiquidationPrice as t } from "../../quotes/liquidation/calculate-liquidation-price.js";
3
+ import { calculateQuoteLeverage as n } from "../../quotes/upnl/calculate-quote-leverage.js";
4
+ import { calculateQuoteUpnl as r } from "../../quotes/upnl/calculate-quote-upnl.js";
5
+ import { units as i } from "../composition.js";
6
+ import { parseUnits as a } from "viem";
7
+ import { toDecimal as o } from "@symmio/utils";
8
+ //#region src/pools/open-positions/calculate-pool-open-positions.ts
9
+ function s(n) {
10
+ let a = n.priceUsd != null && Number.isFinite(n.priceUsd) && n.priceUsd >= 0 ? n.priceUsd : null;
11
+ return {
12
+ entries: n.quotes.map((o) => {
13
+ let s = [
14
+ o.openedPrice,
15
+ o.initialOpenedPrice,
16
+ o.requestedOpenPrice
17
+ ].find((e) => e != null && e > 0n) ?? null, u = o.quantity == null || o.closedAmount == null ? null : o.quantity > o.closedAmount ? o.quantity - o.closedAmount : 0n, d = c(o, s), f = o.positionType === e.SHORT || o.positionType === e.LONG ? o.positionType : null, p = a == null || s == null || u == null || f == null ? null : r({
18
+ markPrice: String(a),
19
+ positionType: f,
20
+ quantity: u,
21
+ closedAmount: 0n,
22
+ openedPrice: s,
23
+ leverage: "1"
24
+ }), m = o.partyA?.toLowerCase(), h = m == null ? null : n.balances[m], g = m == null ? [] : n.quotes.filter((e) => e.partyA?.toLowerCase() === m), _ = g.flatMap((e) => e.quantity == null || e.closedAmount == null || e.openedPrice == null ? [] : [{
25
+ quantity: e.quantity,
26
+ closedAmount: e.closedAmount,
27
+ openedPrice: e.openedPrice
28
+ }]), v = g.every((e) => e.symbolId === o.symbolId && Number(e.positionType) === Number(o.positionType)), y = h && f != null && n.complete !== !1 && v && g.length > 0 && _.length === g.length ? t({
29
+ ...h,
30
+ positions: _,
31
+ positionType: f
32
+ }) : null, b = n.allowQuoteLockEstimate && f != null && s != null && u != null && u > 0n ? l(o, s, d, f) : null, x = y ?? b;
33
+ return {
34
+ ...o,
35
+ remainingQuantity: u,
36
+ entryPrice: s,
37
+ positionValueUsd: u == null || a == null ? null : i(u) * a,
38
+ entryValueUsd: u == null || s == null ? null : i(u * s / 10n ** 18n),
39
+ leverageMultiplier: d,
40
+ upnlUsd: p ? Number(p.upnl) : null,
41
+ priceChangePercent: p && u != null && u > 0n && s != null ? Number(p.upnl) / (i(u) * i(s)) * 100 : null,
42
+ liquidationPrice: x,
43
+ liquidationSource: y == null ? b == null ? null : "quote-lock" : "account",
44
+ openedAt: [
45
+ o.timestampOpenPosition,
46
+ o.timestampSendQuote,
47
+ o.timestamp
48
+ ].find((e) => e != null && e > 0) ?? null
49
+ };
50
+ }),
51
+ gaps: [...n.gaps ?? []]
52
+ };
53
+ }
54
+ function c(e, t) {
55
+ if (e.leverage != null && e.leverage > 0n) return i(e.leverage);
56
+ if (e.initialCva == null || e.initialLf == null || e.initialPartyAmm == null) return null;
57
+ let r = e.initialCva + e.initialLf + e.initialPartyAmm;
58
+ if (r <= 0n) return null;
59
+ if (e.initialLf > 0n) return Math.max(1, Math.round(Number(e.initialLf * 100n * 10n ** 18n / r) / 0xde0b6b3a7640000));
60
+ if (e.quantity == null || e.quantity <= 0n || t == null) return null;
61
+ let a = (t) => Number(n({
62
+ quantity: e.quantity,
63
+ openedPrice: t,
64
+ requestedOpenPrice: t,
65
+ lockedValues: {
66
+ cva: e.initialCva,
67
+ lf: e.initialLf,
68
+ partyAmm: e.initialPartyAmm,
69
+ partyBmm: 0n
70
+ }
71
+ })), o = a(t), s = e.requestedOpenPrice != null && e.requestedOpenPrice > 0n ? a(e.requestedOpenPrice) : o;
72
+ return Math.max(1, Math.round(Math.abs(s - Math.round(s)) < Math.abs(o - Math.round(o)) ? s : o));
73
+ }
74
+ function l(t, n, r, i) {
75
+ let s = t.quantity != null && t.quantity > 0n && t.initialPartyAmm != null && t.initialPartyAmm > 0n ? t.initialPartyAmm * 10n ** 18n / t.quantity : r != null && Number.isFinite(r) && r > 0 ? n * 10n ** 18n / a(o(r).toFixed(), 18) : null;
76
+ if (s == null) return null;
77
+ let c = i === e.SHORT ? n + s : n - s;
78
+ return c > 0n ? c : 0n;
79
+ }
80
+ //#endregion
81
+ export { s as calculatePoolOpenPositions };
82
+
83
+ //# sourceMappingURL=calculate-pool-open-positions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-pool-open-positions.js","names":[],"sources":["../../../src/pools/open-positions/calculate-pool-open-positions.ts"],"sourcesContent":["import { toDecimal } from \"@symmio/utils\";\nimport { parseUnits } from \"viem\";\nimport { calculateLiquidationPrice } from \"../../quotes/liquidation/calculate-liquidation-price\";\nimport { calculateQuoteLeverage } from \"../../quotes/upnl/calculate-quote-leverage\";\nimport { calculateQuoteUpnl } from \"../../quotes/upnl/calculate-quote-upnl\";\nimport type { AccountBalanceInfo } from \"../../symmio-contracts/account-layer/types\";\nimport { PositionType } from \"../../symmio-contracts/symmio/types\";\nimport { units, type PoolReadGap } from \"../composition\";\nimport type { PoolQuote } from \"../types\";\n\n/** Normalized quote and account reads for the pool's open positions. */\nexport interface CalculatePoolOpenPositionsParameters {\n quotes: readonly Partial<PoolQuote>[];\n balances: Readonly<\n Record<\n string,\n Pick<\n AccountBalanceInfo,\n \"allocatedBalance\" | \"lockedCVA\" | \"lockedLF\" | \"pendingLockedCVA\" | \"pendingLockedLF\"\n > | null\n >\n >;\n /** External/current mark price in USD. Omit when unknown. */\n priceUsd?: number;\n /** Set false when quotes are only a page; incomplete accounts cannot yield liquidation estimates. */\n complete?: boolean;\n /** Opt in to a quote-lock estimate when account liquidation is unavailable. */\n allowQuoteLockEstimate?: boolean;\n gaps?: readonly PoolReadGap[];\n}\n\n/** Calculate table metrics using the shared SDK quote primitives.\n * @param input - SDK quotes, account balances and optional mark price.\n * @returns Quote fields plus metrics; priceChangePercent is deliberately unleveraged.\n */\nexport function calculatePoolOpenPositions<TQuote extends Partial<PoolQuote>>(\n input: Omit<CalculatePoolOpenPositionsParameters, \"quotes\"> & { quotes: readonly TQuote[] },\n) {\n const price =\n input.priceUsd != null && Number.isFinite(input.priceUsd) && input.priceUsd >= 0 ? input.priceUsd : null;\n const entries = input.quotes.map((quote) => {\n const openedPrice =\n [quote.openedPrice, quote.initialOpenedPrice, quote.requestedOpenPrice].find(\n (value) => value != null && value > 0n,\n ) ?? null;\n const quantity =\n quote.quantity == null || quote.closedAmount == null\n ? null\n : quote.quantity > quote.closedAmount\n ? quote.quantity - quote.closedAmount\n : 0n;\n const leverage = poolLeverage(quote, openedPrice);\n const positionType =\n quote.positionType === PositionType.SHORT || quote.positionType === PositionType.LONG ? quote.positionType : null;\n const pnl =\n price == null || openedPrice == null || quantity == null || positionType == null\n ? null\n : calculateQuoteUpnl({\n markPrice: String(price),\n positionType,\n quantity,\n closedAmount: 0n,\n openedPrice,\n leverage: \"1\",\n });\n const account = quote.partyA?.toLowerCase();\n const balance = account == null ? null : input.balances[account];\n const accountQuotes = account == null ? [] : input.quotes.filter((row) => row.partyA?.toLowerCase() === account);\n const positions = accountQuotes.flatMap((row) =>\n row.quantity == null || row.closedAmount == null || row.openedPrice == null\n ? []\n : [{ quantity: row.quantity, closedAmount: row.closedAmount, openedPrice: row.openedPrice }],\n );\n const compatible = accountQuotes.every(\n (row) => row.symbolId === quote.symbolId && Number(row.positionType) === Number(quote.positionType),\n );\n const accountLiquidation =\n balance &&\n positionType != null &&\n input.complete !== false &&\n compatible &&\n accountQuotes.length > 0 &&\n positions.length === accountQuotes.length\n ? calculateLiquidationPrice({ ...balance, positions, positionType })\n : null;\n const lockEstimate =\n input.allowQuoteLockEstimate && positionType != null && openedPrice != null && quantity != null && quantity > 0n\n ? quoteLockLiquidation(quote, openedPrice, leverage, positionType)\n : null;\n const liquidationPrice = accountLiquidation ?? lockEstimate;\n return {\n ...quote,\n remainingQuantity: quantity,\n entryPrice: openedPrice,\n positionValueUsd: quantity == null || price == null ? null : units(quantity)! * price,\n entryValueUsd: quantity == null || openedPrice == null ? null : units((quantity * openedPrice) / 10n ** 18n),\n leverageMultiplier: leverage,\n upnlUsd: pnl ? Number(pnl.upnl) : null,\n // The shared helper's percent is display-rounded. This read exposes the unrounded notional return.\n priceChangePercent:\n pnl && quantity != null && quantity > 0n && openedPrice != null\n ? (Number(pnl.upnl) / (units(quantity)! * units(openedPrice)!)) * 100\n : null,\n liquidationPrice,\n liquidationSource:\n accountLiquidation != null ? (\"account\" as const) : lockEstimate != null ? (\"quote-lock\" as const) : null,\n openedAt:\n [quote.timestampOpenPosition, quote.timestampSendQuote, quote.timestamp].find(\n (value) => value != null && value > 0,\n ) ?? null,\n };\n });\n return { entries, gaps: [...(input.gaps ?? [])] };\n}\n/** Pool open-position table projection. */\nexport type PoolOpenPositions = ReturnType<typeof calculatePoolOpenPositions<PoolQuote>>;\n\n/** Preserve the pool table's legacy integer leverage inference when the backend omits leverage. */\nfunction poolLeverage(quote: Partial<PoolQuote>, openedPrice: bigint | null): number | null {\n if (quote.leverage != null && quote.leverage > 0n) return units(quote.leverage);\n if (quote.initialCva == null || quote.initialLf == null || quote.initialPartyAmm == null) return null;\n const margin = quote.initialCva + quote.initialLf + quote.initialPartyAmm;\n if (margin <= 0n) return null;\n if (quote.initialLf > 0n)\n return Math.max(1, Math.round(Number((quote.initialLf * 100n * 10n ** 18n) / margin) / 1e18));\n if (quote.quantity == null || quote.quantity <= 0n || openedPrice == null) return null;\n const candidate = (price: bigint) =>\n Number(\n calculateQuoteLeverage({\n quantity: quote.quantity!,\n openedPrice: price,\n requestedOpenPrice: price,\n lockedValues: { cva: quote.initialCva!, lf: quote.initialLf!, partyAmm: quote.initialPartyAmm!, partyBmm: 0n },\n }),\n );\n const opened = candidate(openedPrice);\n const requested =\n quote.requestedOpenPrice != null && quote.requestedOpenPrice > 0n ? candidate(quote.requestedOpenPrice) : opened;\n return Math.max(\n 1,\n Math.round(\n Math.abs(requested - Math.round(requested)) < Math.abs(opened - Math.round(opened)) ? requested : opened,\n ),\n );\n}\n\n/** Historical quote-lock estimate, explicitly separate from live account collateral. */\nfunction quoteLockLiquidation(\n quote: Partial<PoolQuote>,\n price: bigint,\n leverage: number | null,\n side: PositionType,\n): bigint | null {\n const marginPerToken =\n quote.quantity != null && quote.quantity > 0n && quote.initialPartyAmm != null && quote.initialPartyAmm > 0n\n ? (quote.initialPartyAmm * 10n ** 18n) / quote.quantity\n : leverage != null && Number.isFinite(leverage) && leverage > 0\n ? (price * 10n ** 18n) / parseUnits(toDecimal(leverage).toFixed(), 18)\n : null;\n if (marginPerToken == null) return null;\n const result = side === PositionType.SHORT ? price + marginPerToken : price - marginPerToken;\n return result > 0n ? result : 0n;\n}\n"],"mappings":";;;;;;;;AAmCA,SAAgB,EACd,GACA;CACA,IAAM,IACJ,EAAM,YAAY,QAAQ,OAAO,SAAS,EAAM,QAAQ,KAAK,EAAM,YAAY,IAAI,EAAM,WAAW;CAyEtG,OAAO;EAAE,SAxEO,EAAM,OAAO,KAAK,MAAU;GAC1C,IAAM,IACJ;IAAC,EAAM;IAAa,EAAM;IAAoB,EAAM;GAAkB,EAAE,MACrE,MAAU,KAAS,QAAQ,IAAQ,EACtC,KA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OAAO,KAAK,IACV,GACA,KAAK,MACH,KAAK,IAAI,IAAY,KAAK,MAAM,CAAS,CAAC,IAAI,KAAK,IAAI,IAAS,KAAK,MAAM,CAAM,CAAC,IAAI,IAAY,CACpG,CACF;AACF;AAGA,SAAS,EACP,GACA,GACA,GACA,GACe;CACf,IAAM,IACJ,EAAM,YAAY,QAAQ,EAAM,WAAW,MAAM,EAAM,mBAAmB,QAAQ,EAAM,kBAAkB,KACrG,EAAM,kBAAkB,OAAO,MAAO,EAAM,WAC7C,KAAY,QAAQ,OAAO,SAAS,CAAQ,KAAK,IAAW,IACzD,IAAQ,OAAO,MAAO,EAAW,EAAU,CAAQ,EAAE,QAAQ,GAAG,EAAE,IACnE;CACR,IAAI,KAAkB,MAAM,OAAO;CACnC,IAAM,IAAS,MAAS,EAAa,QAAQ,IAAQ,IAAiB,IAAQ;CAC9E,OAAO,IAAS,KAAK,IAAS;AAChC"}
@@ -0,0 +1,17 @@
1
+ import { Config } from '../../core/config/index.js';
2
+ import { GetPoolQuotesParameters } from '../quotes/get-pool-quotes.js';
3
+ import { PoolOpenPositions } from './calculate-pool-open-positions.js';
4
+ /** Read a bounded complete open book; caller filtering/paging follows calculation. */
5
+ export type GetPoolOpenPositionsParameters = Pick<GetPoolQuotesParameters, "chainId" | "symbolId" | "orderDirection"> & {
6
+ priceUsd?: number;
7
+ allowQuoteLockEstimate?: boolean;
8
+ };
9
+ /** Result of getPoolOpenPositions. */
10
+ export type GetPoolOpenPositionsReturnType = PoolOpenPositions;
11
+ /** Read open quotes and deduplicated account balances before deriving table metrics.
12
+ * @param config - SDK configuration.
13
+ * @param parameters - Market identity and optional external mark price.
14
+ * @returns Open positions and source gaps; incomplete books have no liquidation estimate.
15
+ */
16
+ export declare function getPoolOpenPositions(config: Config, parameters: GetPoolOpenPositionsParameters): Promise<PoolOpenPositions>;
17
+ //# sourceMappingURL=get-pool-open-positions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pool-open-positions.d.ts","sourceRoot":"","sources":["../../../src/pools/open-positions/get-pool-open-positions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAA2C,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAClH,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAErG,sFAAsF;AACtF,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAC/C,uBAAuB,EACvB,SAAS,GAAG,UAAU,GAAG,gBAAgB,CAC1C,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAC5D,sCAAsC;AACtC,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAAC;AAE/D;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,8BAA8B,GACzC,OAAO,CAAC,iBAAiB,CAAC,CA0C5B"}
@@ -0,0 +1,39 @@
1
+ import { getAccountBalanceInfo as e } from "../../symmio-contracts/account-layer/actions/get-account-balance-info.js";
2
+ import { readOptional as t, readPages as n } from "../composition.js";
3
+ import { calculatePoolOpenPositions as r } from "./calculate-pool-open-positions.js";
4
+ import { POOL_OPEN_QUOTE_STATUSES as i, getPoolQuotes as a } from "../quotes/get-pool-quotes.js";
5
+ //#region src/pools/open-positions/get-pool-open-positions.ts
6
+ async function o(o, s) {
7
+ let c = [], l = await n(async (e) => {
8
+ let t = await a(o, {
9
+ chainId: s.chainId,
10
+ symbolId: s.symbolId,
11
+ orderDirection: s.orderDirection,
12
+ quoteStatuses: i,
13
+ first: 100,
14
+ skip: e
15
+ });
16
+ return {
17
+ items: t.quotes,
18
+ total: t.quotes.length < 100 ? e + t.quotes.length : 2 ** 53 - 1
19
+ };
20
+ }, (e) => e.id, c, "quotes"), u = {}, d = [...new Set(l.map((e) => e.partyA.toLowerCase()))];
21
+ for (let n = 0; n < d.length; n += 8) await Promise.all(d.slice(n, n + 8).map(async (n) => {
22
+ u[n] = await t(() => e(o, {
23
+ chainId: s.chainId,
24
+ account: n
25
+ }), c, "accountBalance", n);
26
+ }));
27
+ return r({
28
+ quotes: l,
29
+ balances: u,
30
+ priceUsd: s.priceUsd,
31
+ allowQuoteLockEstimate: s.allowQuoteLockEstimate,
32
+ complete: !c.some((e) => e.source === "quotes"),
33
+ gaps: c
34
+ });
35
+ }
36
+ //#endregion
37
+ export { o as getPoolOpenPositions };
38
+
39
+ //# sourceMappingURL=get-pool-open-positions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pool-open-positions.js","names":[],"sources":["../../../src/pools/open-positions/get-pool-open-positions.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../core/config\";\nimport { getAccountBalanceInfo } from \"../../symmio-contracts/account-layer/actions/get-account-balance-info\";\nimport { readOptional, readPages, type PoolReadGap } from \"../composition\";\nimport { getPoolQuotes, POOL_OPEN_QUOTE_STATUSES, type GetPoolQuotesParameters } from \"../quotes/get-pool-quotes\";\nimport { calculatePoolOpenPositions, type PoolOpenPositions } from \"./calculate-pool-open-positions\";\n\n/** Read a bounded complete open book; caller filtering/paging follows calculation. */\nexport type GetPoolOpenPositionsParameters = Pick<\n GetPoolQuotesParameters,\n \"chainId\" | \"symbolId\" | \"orderDirection\"\n> & { priceUsd?: number; allowQuoteLockEstimate?: boolean };\n/** Result of getPoolOpenPositions. */\nexport type GetPoolOpenPositionsReturnType = PoolOpenPositions;\n\n/** Read open quotes and deduplicated account balances before deriving table metrics.\n * @param config - SDK configuration.\n * @param parameters - Market identity and optional external mark price.\n * @returns Open positions and source gaps; incomplete books have no liquidation estimate.\n */\nexport async function getPoolOpenPositions(\n config: Config,\n parameters: GetPoolOpenPositionsParameters,\n): Promise<PoolOpenPositions> {\n const gaps: PoolReadGap[] = [];\n const quotes = await readPages(\n async (skip) => {\n const page = await getPoolQuotes(config, {\n chainId: parameters.chainId,\n symbolId: parameters.symbolId,\n orderDirection: parameters.orderDirection,\n quoteStatuses: POOL_OPEN_QUOTE_STATUSES,\n first: 100,\n skip,\n });\n return {\n items: page.quotes,\n total: page.quotes.length < 100 ? skip + page.quotes.length : Number.MAX_SAFE_INTEGER,\n };\n },\n (row) => row.id,\n gaps,\n \"quotes\",\n );\n const balances: Record<string, Awaited<ReturnType<typeof getAccountBalanceInfo>> | null> = {};\n const accounts = [...new Set(quotes.map((row) => row.partyA.toLowerCase()))];\n for (let offset = 0; offset < accounts.length; offset += 8)\n await Promise.all(\n accounts.slice(offset, offset + 8).map(async (account) => {\n balances[account] = await readOptional(\n () => getAccountBalanceInfo(config, { chainId: parameters.chainId, account: account as Address }),\n gaps,\n \"accountBalance\",\n account,\n );\n }),\n );\n return calculatePoolOpenPositions({\n quotes,\n balances,\n priceUsd: parameters.priceUsd,\n allowQuoteLockEstimate: parameters.allowQuoteLockEstimate,\n complete: !gaps.some((gap) => gap.source === \"quotes\"),\n gaps,\n });\n}\n"],"mappings":";;;;;AAoBA,eAAsB,EACpB,GACA,GAC4B;CAC5B,IAAM,IAAsB,CAAC,GACvB,IAAS,MAAM,EACnB,OAAO,MAAS;EACd,IAAM,IAAO,MAAM,EAAc,GAAQ;GACvC,SAAS,EAAW;GACpB,UAAU,EAAW;GACrB,gBAAgB,EAAW;GAC3B,eAAe;GACf,OAAO;GACP;EACF,CAAC;EACD,OAAO;GACL,OAAO,EAAK;GACZ,OAAO,EAAK,OAAO,SAAS,MAAM,IAAO,EAAK,OAAO;EACvD;CACF,IACC,MAAQ,EAAI,IACb,GACA,QACF,GACM,IAAqF,CAAC,GACtF,IAAW,CAAC,GAAG,IAAI,IAAI,EAAO,KAAK,MAAQ,EAAI,OAAO,YAAY,CAAC,CAAC,CAAC;CAC3E,KAAK,IAAI,IAAS,GAAG,IAAS,EAAS,QAAQ,KAAU,GACvD,MAAM,QAAQ,IACZ,EAAS,MAAM,GAAQ,IAAS,CAAC,EAAE,IAAI,OAAO,MAAY;EACxD,EAAS,KAAW,MAAM,QAClB,EAAsB,GAAQ;GAAE,SAAS,EAAW;GAAkB;EAAmB,CAAC,GAChG,GACA,kBACA,CACF;CACF,CAAC,CACH;CACF,OAAO,EAA2B;EAChC;EACA;EACA,UAAU,EAAW;EACrB,wBAAwB,EAAW;EACnC,UAAU,CAAC,EAAK,MAAM,MAAQ,EAAI,WAAW,QAAQ;EACrD;CACF,CAAC;AACH"}
@@ -0,0 +1,4 @@
1
+ export * from './calculate-pool-open-positions.js';
2
+ export * from './get-pool-open-positions.js';
3
+ export * from './query.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pools/open-positions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Config } from '../../core/config/index.js';
2
+ import { Compute, ConfigKeyParameter } from '../../shared/types/properties.js';
3
+ import { QueryParameter, SymmioQueryOptions } from '../../shared/types/query.js';
4
+ import { GetPoolOpenPositionsParameters, GetPoolOpenPositionsReturnType } from './get-pool-open-positions.js';
5
+ /** Stable key for the composed core read. Credentials are excluded. */
6
+ export declare function getPoolOpenPositionsQueryKey(options: Compute<GetPoolOpenPositionsParameters & ConfigKeyParameter>): readonly ["getPoolOpenPositions", Record<string, unknown>];
7
+ /** Composed query key type. */
8
+ export type GetPoolOpenPositionsQueryKey = ReturnType<typeof getPoolOpenPositionsQueryKey>;
9
+ /** Query controls plus all required read inputs. */
10
+ export type GetPoolOpenPositionsOptions = GetPoolOpenPositionsParameters & QueryParameter<GetPoolOpenPositionsReturnType, Error, GetPoolOpenPositionsReturnType, GetPoolOpenPositionsQueryKey>;
11
+ /** Build options for non-React consumers; React composition uses the underlying primitive queries instead.
12
+ * @param config - SDK configuration.
13
+ * @param options - Required read inputs and optional query controls.
14
+ * @returns Typed query options with a credential-free key.
15
+ */
16
+ export declare function getPoolOpenPositionsQueryOptions(config: Config, options: GetPoolOpenPositionsOptions): SymmioQueryOptions<GetPoolOpenPositionsReturnType, Error, GetPoolOpenPositionsReturnType, GetPoolOpenPositionsQueryKey>;
17
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pools/open-positions/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACpC,MAAM,2BAA2B,CAAC;AACnC,uEAAuE;AACvE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,CAAC,8BAA8B,GAAG,kBAAkB,CAAC,8DAEjH;AACD,+BAA+B;AAC/B,MAAM,MAAM,4BAA4B,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAC3F,oDAAoD;AACpD,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,GACtE,cAAc,CAAC,8BAA8B,EAAE,KAAK,EAAE,8BAA8B,EAAE,4BAA4B,CAAC,CAAC;AACtH;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,2BAA2B,GACnC,kBAAkB,CACnB,8BAA8B,EAC9B,KAAK,EACL,8BAA8B,EAC9B,4BAA4B,CAC7B,CAOA"}
@@ -0,0 +1,21 @@
1
+ import { filterQueryOptions as e } from "../../shared/utils/query.js";
2
+ import { getPoolOpenPositions as t } from "./get-pool-open-positions.js";
3
+ //#region src/pools/open-positions/query.ts
4
+ function n(t) {
5
+ return ["getPoolOpenPositions", 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,
15
+ queryFn: () => t(e, r)
16
+ };
17
+ }
18
+ //#endregion
19
+ export { n as getPoolOpenPositionsQueryKey, r as getPoolOpenPositionsQueryOptions };
20
+
21
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/open-positions/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getPoolOpenPositions,\n type GetPoolOpenPositionsParameters,\n type GetPoolOpenPositionsReturnType,\n} from \"./get-pool-open-positions\";\n/** Stable key for the composed core read. Credentials are excluded. */\nexport function getPoolOpenPositionsQueryKey(options: Compute<GetPoolOpenPositionsParameters & ConfigKeyParameter>) {\n return [\"getPoolOpenPositions\", filterQueryOptions(options)] as const;\n}\n/** Composed query key type. */\nexport type GetPoolOpenPositionsQueryKey = ReturnType<typeof getPoolOpenPositionsQueryKey>;\n/** Query controls plus all required read inputs. */\nexport type GetPoolOpenPositionsOptions = GetPoolOpenPositionsParameters &\n QueryParameter<GetPoolOpenPositionsReturnType, Error, GetPoolOpenPositionsReturnType, GetPoolOpenPositionsQueryKey>;\n/** Build options for non-React consumers; React composition uses the underlying primitive queries instead.\n * @param config - SDK configuration.\n * @param options - Required read inputs and optional query controls.\n * @returns Typed query options with a credential-free key.\n */\nexport function getPoolOpenPositionsQueryOptions(\n config: Config,\n options: GetPoolOpenPositionsOptions,\n): SymmioQueryOptions<\n GetPoolOpenPositionsReturnType,\n Error,\n GetPoolOpenPositionsReturnType,\n GetPoolOpenPositionsQueryKey\n> {\n return {\n ...options.query,\n queryKey: getPoolOpenPositionsQueryKey({ ...options, configKey: config.getChainConfigKey(options.chainId) }),\n enabled: options.query?.enabled ?? true,\n queryFn: () => getPoolOpenPositions(config, options),\n };\n}\n"],"mappings":";;;AAUA,SAAgB,EAA6B,GAAuE;CAClH,OAAO,CAAC,wBAAwB,EAAmB,CAAO,CAAC;AAC7D;AAWA,SAAgB,EACd,GACA,GAMA;CACA,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAA6B;GAAE,GAAG;GAAS,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EAAE,CAAC;EAC3G,SAAS,EAAQ,OAAO,WAAW;EACnC,eAAe,EAAqB,GAAQ,CAAO;CACrD;AACF"}
@@ -0,0 +1,66 @@
1
+ import { PoolReadGap } from '../composition.js';
2
+ import { PoolPositionData } from '../position/calculate-pool-position.js';
3
+ import { ListingMarketDetail, UserListingMarket, UserPoolProfit, UserTransaction } from '../types.js';
4
+ /** Pool identity and an optional third-party price, supplied by the consumer. */
5
+ export interface PoolPortfolioPrice {
6
+ tokenContractAddress: string;
7
+ depositChain: number;
8
+ priceUsd: number;
9
+ }
10
+ /** Flat portfolio row. Stake fields have exactly the position read's semantics. */
11
+ export interface PoolPortfolioPosition extends PoolPositionData {
12
+ tokenContractAddress: string;
13
+ depositChain: number;
14
+ /** Original normalized catalog snapshot, including rates, flags and ownership metadata. */
15
+ market: UserListingMarket | null;
16
+ /** Positive deposit observed in history or catalog; null when incomplete history cannot establish absence. */
17
+ hasDeposit: boolean | null;
18
+ tokenName: string | null;
19
+ tokenTicker: string | null;
20
+ apr: number | null;
21
+ }
22
+ /** Portfolio values before any consumer filtering or pagination. */
23
+ export interface PoolPortfolio {
24
+ entries: PoolPortfolioPosition[];
25
+ totalBalanceUsd: number | null;
26
+ totalDepositedUsd: number | null;
27
+ claimableRewardUsd: number | null;
28
+ claimedRewardUsd: number | null;
29
+ rewardWindowUsd: number | null;
30
+ averageApr: number | null;
31
+ /** ROI over the same fully priced positions on both sides. Null when no comparable deposits exist. */
32
+ roiPercent: number | null;
33
+ /** Partial known-value totals; consult totalBalanceUsd/totalDepositedUsd for source completeness. */
34
+ knownBalanceUsd: number;
35
+ knownDepositedUsd: number;
36
+ knownValueRoiPercent: number | null;
37
+ /** Historical claimed plus claimable rewards, including positions no longer held. */
38
+ lifetimeRewardsUsd: number | null;
39
+ gaps: PoolReadGap[];
40
+ }
41
+ /** Normalized reads for portfolio assembly; no wire strings or generated vendor types. */
42
+ export interface CalculatePoolPortfolioParameters {
43
+ listed: readonly UserListingMarket[];
44
+ nonListed: readonly UserListingMarket[];
45
+ deposits: readonly UserTransaction[] | null;
46
+ positions: readonly {
47
+ tokenContractAddress: string;
48
+ depositChain: number;
49
+ profit: Partial<UserPoolProfit> | null;
50
+ detail: ListingMarketDetail | null;
51
+ }[];
52
+ prices?: readonly PoolPortfolioPrice[];
53
+ reward: bigint | null;
54
+ /** Optional complete historical reward ledger. Values include any consumer optimistic projection. */
55
+ rewardPositions?: readonly {
56
+ claimed: bigint | null;
57
+ claimable: bigint | null;
58
+ }[];
59
+ gaps?: readonly PoolReadGap[];
60
+ }
61
+ /** Assemble holdings and totals from SDK reads; filtering and top-earner selection remain consumer-owned.
62
+ * @param input - Normalized source snapshots and explicit read gaps.
63
+ * @returns Rows with exact stake amounts, USD totals and completeness information.
64
+ */
65
+ export declare function calculatePoolPortfolio(input: CalculatePoolPortfolioParameters): PoolPortfolio;
66
+ //# sourceMappingURL=calculate-pool-portfolio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-pool-portfolio.d.ts","sourceRoot":"","sources":["../../../src/pools/portfolio/calculate-pool-portfolio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cA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