@symmio/trading-core 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/dist/index.d.ts +17 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +108 -87
  4. package/dist/pools/add-market/to-created-pool.d.ts.map +1 -1
  5. package/dist/pools/add-market/to-created-pool.js +4 -0
  6. package/dist/pools/add-market/to-created-pool.js.map +1 -1
  7. package/dist/pools/add-market/types.d.ts +8 -0
  8. package/dist/pools/add-market/types.d.ts.map +1 -1
  9. package/dist/pools/auth/authenticate-listing.d.ts +3 -1
  10. package/dist/pools/auth/authenticate-listing.d.ts.map +1 -1
  11. package/dist/pools/auth/authenticate-listing.js +28 -23
  12. package/dist/pools/auth/authenticate-listing.js.map +1 -1
  13. package/dist/pools/auth/can-reuse-listing-challenge.d.ts +5 -0
  14. package/dist/pools/auth/can-reuse-listing-challenge.d.ts.map +1 -0
  15. package/dist/pools/auth/can-reuse-listing-challenge.js +9 -0
  16. package/dist/pools/auth/can-reuse-listing-challenge.js.map +1 -0
  17. package/dist/pools/auth/query.d.ts +15 -0
  18. package/dist/pools/auth/query.d.ts.map +1 -1
  19. package/dist/pools/auth/query.js +28 -4
  20. package/dist/pools/auth/query.js.map +1 -1
  21. package/dist/pools/auth/to-siwe.d.ts +5 -1
  22. package/dist/pools/auth/to-siwe.d.ts.map +1 -1
  23. package/dist/pools/auth/to-siwe.js +4 -2
  24. package/dist/pools/auth/to-siwe.js.map +1 -1
  25. package/dist/pools/auth/types.d.ts +2 -0
  26. package/dist/pools/auth/types.d.ts.map +1 -1
  27. package/dist/pools/cancel-withdraw/cancel-withdraw.js +1 -1
  28. package/dist/pools/cancel-withdraw/cancel-withdraw.js.map +1 -1
  29. package/dist/pools/claim-history/get-pool-claim.d.ts +11 -0
  30. package/dist/pools/claim-history/get-pool-claim.d.ts.map +1 -0
  31. package/dist/pools/claim-history/get-pool-claim.js +25 -0
  32. package/dist/pools/claim-history/get-pool-claim.js.map +1 -0
  33. package/dist/pools/claim-history/index.d.ts +1 -0
  34. package/dist/pools/claim-history/index.d.ts.map +1 -1
  35. package/dist/pools/claim-history/to-pool-claim.d.ts.map +1 -1
  36. package/dist/pools/claim-history/to-pool-claim.js +2 -0
  37. package/dist/pools/claim-history/to-pool-claim.js.map +1 -1
  38. package/dist/pools/composition.d.ts +16 -0
  39. package/dist/pools/composition.d.ts.map +1 -0
  40. package/dist/pools/composition.js +39 -0
  41. package/dist/pools/composition.js.map +1 -0
  42. package/dist/pools/empty-pool-profit.d.ts +4 -0
  43. package/dist/pools/empty-pool-profit.d.ts.map +1 -0
  44. package/dist/pools/empty-pool-profit.js +17 -0
  45. package/dist/pools/empty-pool-profit.js.map +1 -0
  46. package/dist/pools/index.d.ts +8 -0
  47. package/dist/pools/index.d.ts.map +1 -1
  48. package/dist/pools/listing-config/to-listing-config.d.ts +5 -1
  49. package/dist/pools/listing-config/to-listing-config.d.ts.map +1 -1
  50. package/dist/pools/listing-config/to-listing-config.js +19 -8
  51. package/dist/pools/listing-config/to-listing-config.js.map +1 -1
  52. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts +37 -0
  53. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts.map +1 -0
  54. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js +35 -0
  55. package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js.map +1 -0
  56. package/dist/pools/maintenance-fees/index.d.ts +3 -0
  57. package/dist/pools/maintenance-fees/index.d.ts.map +1 -0
  58. package/dist/pools/maintenance-fees/query.d.ts +11 -0
  59. package/dist/pools/maintenance-fees/query.d.ts.map +1 -0
  60. package/dist/pools/maintenance-fees/query.js +21 -0
  61. package/dist/pools/maintenance-fees/query.js.map +1 -0
  62. package/dist/pools/market-config/to-listing-market-config.d.ts +6 -1
  63. package/dist/pools/market-config/to-listing-market-config.d.ts.map +1 -1
  64. package/dist/pools/market-config/to-listing-market-config.js +1 -0
  65. package/dist/pools/market-config/to-listing-market-config.js.map +1 -1
  66. package/dist/pools/market-config/types.d.ts +5 -0
  67. package/dist/pools/market-config/types.d.ts.map +1 -1
  68. package/dist/pools/market-config/types.js.map +1 -1
  69. package/dist/pools/market-data/get-pool-market-data.d.ts +14 -0
  70. package/dist/pools/market-data/get-pool-market-data.d.ts.map +1 -0
  71. package/dist/pools/market-data/get-pool-market-data.js +25 -0
  72. package/dist/pools/market-data/get-pool-market-data.js.map +1 -0
  73. package/dist/pools/market-data/index.d.ts +2 -0
  74. package/dist/pools/market-data/index.d.ts.map +1 -0
  75. package/dist/pools/market-detail/to-listing-market-detail.d.ts +5 -1
  76. package/dist/pools/market-detail/to-listing-market-detail.d.ts.map +1 -1
  77. package/dist/pools/market-detail/to-listing-market-detail.js +45 -33
  78. package/dist/pools/market-detail/to-listing-market-detail.js.map +1 -1
  79. package/dist/pools/markets/to-listing-market.d.ts +13 -1
  80. package/dist/pools/markets/to-listing-market.d.ts.map +1 -1
  81. package/dist/pools/markets/to-listing-market.js +24 -12
  82. package/dist/pools/markets/to-listing-market.js.map +1 -1
  83. package/dist/pools/open-positions/calculate-pool-open-positions.d.ts +39 -0
  84. package/dist/pools/open-positions/calculate-pool-open-positions.d.ts.map +1 -0
  85. package/dist/pools/open-positions/calculate-pool-open-positions.js +83 -0
  86. package/dist/pools/open-positions/calculate-pool-open-positions.js.map +1 -0
  87. package/dist/pools/open-positions/get-pool-open-positions.d.ts +17 -0
  88. package/dist/pools/open-positions/get-pool-open-positions.d.ts.map +1 -0
  89. package/dist/pools/open-positions/get-pool-open-positions.js +39 -0
  90. package/dist/pools/open-positions/get-pool-open-positions.js.map +1 -0
  91. package/dist/pools/open-positions/index.d.ts +4 -0
  92. package/dist/pools/open-positions/index.d.ts.map +1 -0
  93. package/dist/pools/open-positions/query.d.ts +17 -0
  94. package/dist/pools/open-positions/query.d.ts.map +1 -0
  95. package/dist/pools/open-positions/query.js +21 -0
  96. package/dist/pools/open-positions/query.js.map +1 -0
  97. package/dist/pools/portfolio/calculate-pool-portfolio.d.ts +66 -0
  98. package/dist/pools/portfolio/calculate-pool-portfolio.d.ts.map +1 -0
  99. package/dist/pools/portfolio/calculate-pool-portfolio.js +96 -0
  100. package/dist/pools/portfolio/calculate-pool-portfolio.js.map +1 -0
  101. package/dist/pools/portfolio/get-pool-portfolio.d.ts +19 -0
  102. package/dist/pools/portfolio/get-pool-portfolio.d.ts.map +1 -0
  103. package/dist/pools/portfolio/get-pool-portfolio.js +88 -0
  104. package/dist/pools/portfolio/get-pool-portfolio.js.map +1 -0
  105. package/dist/pools/portfolio/index.d.ts +4 -0
  106. package/dist/pools/portfolio/index.d.ts.map +1 -0
  107. package/dist/pools/portfolio/query.d.ts +17 -0
  108. package/dist/pools/portfolio/query.d.ts.map +1 -0
  109. package/dist/pools/portfolio/query.js +21 -0
  110. package/dist/pools/portfolio/query.js.map +1 -0
  111. package/dist/pools/portfolio/read-positions.d.ts +4 -0
  112. package/dist/pools/portfolio/read-positions.d.ts.map +1 -0
  113. package/dist/pools/portfolio/read-positions.js +31 -0
  114. package/dist/pools/portfolio/read-positions.js.map +1 -0
  115. package/dist/pools/position/calculate-pool-position.d.ts +85 -0
  116. package/dist/pools/position/calculate-pool-position.d.ts.map +1 -0
  117. package/dist/pools/position/calculate-pool-position.js +59 -0
  118. package/dist/pools/position/calculate-pool-position.js.map +1 -0
  119. package/dist/pools/position/get-pool-position.d.ts +22 -0
  120. package/dist/pools/position/get-pool-position.d.ts.map +1 -0
  121. package/dist/pools/position/get-pool-position.js +47 -0
  122. package/dist/pools/position/get-pool-position.js.map +1 -0
  123. package/dist/pools/position/index.d.ts +4 -0
  124. package/dist/pools/position/index.d.ts.map +1 -0
  125. package/dist/pools/position/query.d.ts +17 -0
  126. package/dist/pools/position/query.d.ts.map +1 -0
  127. package/dist/pools/position/query.js +21 -0
  128. package/dist/pools/position/query.js.map +1 -0
  129. package/dist/pools/position/sum-deposits.d.ts +10 -0
  130. package/dist/pools/position/sum-deposits.d.ts.map +1 -0
  131. package/dist/pools/position/sum-deposits.js +35 -0
  132. package/dist/pools/position/sum-deposits.js.map +1 -0
  133. package/dist/pools/profit/get-user-profit.d.ts +4 -0
  134. package/dist/pools/profit/get-user-profit.d.ts.map +1 -1
  135. package/dist/pools/profit/get-user-profit.js +18 -12
  136. package/dist/pools/profit/get-user-profit.js.map +1 -1
  137. package/dist/pools/profit/to-user-pool-profit.d.ts +22 -4
  138. package/dist/pools/profit/to-user-pool-profit.d.ts.map +1 -1
  139. package/dist/pools/profit/to-user-pool-profit.js +28 -12
  140. package/dist/pools/profit/to-user-pool-profit.js.map +1 -1
  141. package/dist/pools/quotes/get-pool-quotes.d.ts +8 -1
  142. package/dist/pools/quotes/get-pool-quotes.d.ts.map +1 -1
  143. package/dist/pools/quotes/get-pool-quotes.js +8 -1
  144. package/dist/pools/quotes/get-pool-quotes.js.map +1 -1
  145. package/dist/pools/quotes/query-document.d.ts.map +1 -1
  146. package/dist/pools/quotes/query-document.js +1 -1
  147. package/dist/pools/quotes/query-document.js.map +1 -1
  148. package/dist/pools/quotes/to-pool-quote.d.ts.map +1 -1
  149. package/dist/pools/quotes/to-pool-quote.js +13 -0
  150. package/dist/pools/quotes/to-pool-quote.js.map +1 -1
  151. package/dist/pools/rewards/query.js +25 -25
  152. package/dist/pools/statistics/calculate-pool-statistics.d.ts +69 -0
  153. package/dist/pools/statistics/calculate-pool-statistics.d.ts.map +1 -0
  154. package/dist/pools/statistics/calculate-pool-statistics.js +42 -0
  155. package/dist/pools/statistics/calculate-pool-statistics.js.map +1 -0
  156. package/dist/pools/statistics/get-pool-statistics.d.ts +29 -0
  157. package/dist/pools/statistics/get-pool-statistics.d.ts.map +1 -0
  158. package/dist/pools/statistics/get-pool-statistics.js +61 -0
  159. package/dist/pools/statistics/get-pool-statistics.js.map +1 -0
  160. package/dist/pools/statistics/index.d.ts +4 -0
  161. package/dist/pools/statistics/index.d.ts.map +1 -0
  162. package/dist/pools/statistics/query.d.ts +17 -0
  163. package/dist/pools/statistics/query.d.ts.map +1 -0
  164. package/dist/pools/statistics/query.js +21 -0
  165. package/dist/pools/statistics/query.js.map +1 -0
  166. package/dist/pools/token-metadata/get-listing-token-metadata.d.ts +32 -0
  167. package/dist/pools/token-metadata/get-listing-token-metadata.d.ts.map +1 -0
  168. package/dist/pools/token-metadata/get-listing-token-metadata.js +43 -0
  169. package/dist/pools/token-metadata/get-listing-token-metadata.js.map +1 -0
  170. package/dist/pools/token-metadata/index.d.ts +3 -0
  171. package/dist/pools/token-metadata/index.d.ts.map +1 -0
  172. package/dist/pools/token-metadata/query.d.ts +11 -0
  173. package/dist/pools/token-metadata/query.d.ts.map +1 -0
  174. package/dist/pools/token-metadata/query.js +21 -0
  175. package/dist/pools/token-metadata/query.js.map +1 -0
  176. package/dist/pools/token-support/check-listing-token-support.d.ts +23 -0
  177. package/dist/pools/token-support/check-listing-token-support.d.ts.map +1 -0
  178. package/dist/pools/token-support/check-listing-token-support.js +36 -0
  179. package/dist/pools/token-support/check-listing-token-support.js.map +1 -0
  180. package/dist/pools/token-support/index.d.ts +3 -0
  181. package/dist/pools/token-support/index.d.ts.map +1 -0
  182. package/dist/pools/token-support/query.d.ts +11 -0
  183. package/dist/pools/token-support/query.d.ts.map +1 -0
  184. package/dist/pools/token-support/query.js +21 -0
  185. package/dist/pools/token-support/query.js.map +1 -0
  186. package/dist/pools/trade-history/calculate-history-metrics.d.ts +12 -0
  187. package/dist/pools/trade-history/calculate-history-metrics.d.ts.map +1 -0
  188. package/dist/pools/trade-history/calculate-history-metrics.js +36 -0
  189. package/dist/pools/trade-history/calculate-history-metrics.js.map +1 -0
  190. package/dist/pools/trade-history/get-pool-trade-history.d.ts +21 -1
  191. package/dist/pools/trade-history/get-pool-trade-history.d.ts.map +1 -1
  192. package/dist/pools/trade-history/get-pool-trade-history.js +57 -18
  193. package/dist/pools/trade-history/get-pool-trade-history.js.map +1 -1
  194. package/dist/pools/trade-history/query-document.d.ts.map +1 -1
  195. package/dist/pools/trade-history/query-document.js +1 -1
  196. package/dist/pools/trade-history/query-document.js.map +1 -1
  197. package/dist/pools/transactions/get-pool-transaction-range.d.ts +6 -0
  198. package/dist/pools/transactions/get-pool-transaction-range.d.ts.map +1 -0
  199. package/dist/pools/transactions/get-pool-transaction-range.js +26 -0
  200. package/dist/pools/transactions/get-pool-transaction-range.js.map +1 -0
  201. package/dist/pools/transactions/index.d.ts +1 -0
  202. package/dist/pools/transactions/index.d.ts.map +1 -1
  203. package/dist/pools/types/generated/listing-backend.js +34 -10
  204. package/dist/pools/types/generated/listing-backend.js.map +1 -1
  205. package/dist/pools/types.d.ts +129 -6
  206. package/dist/pools/types.d.ts.map +1 -1
  207. package/dist/pools/types.js.map +1 -1
  208. package/dist/pools/user-markets/get-user-listing-markets.d.ts +2 -0
  209. package/dist/pools/user-markets/get-user-listing-markets.d.ts.map +1 -1
  210. package/dist/pools/user-markets/get-user-listing-markets.js.map +1 -1
  211. package/dist/pools/user-markets/to-user-listing-market.js +1 -1
  212. package/dist/pools/user-markets/to-user-listing-market.js.map +1 -1
  213. package/dist/pools/user-transactions/get-user-transactions.d.ts +2 -0
  214. package/dist/pools/user-transactions/get-user-transactions.d.ts.map +1 -1
  215. package/dist/pools/user-transactions/get-user-transactions.js.map +1 -1
  216. package/dist/pools/user-transactions/to-user-transaction.d.ts +5 -1
  217. package/dist/pools/user-transactions/to-user-transaction.d.ts.map +1 -1
  218. package/dist/pools/user-transactions/to-user-transaction.js +3 -0
  219. package/dist/pools/user-transactions/to-user-transaction.js.map +1 -1
  220. package/dist/quotes/liquidation/calculate-liquidation-price.d.ts +5 -1
  221. package/dist/quotes/liquidation/calculate-liquidation-price.d.ts.map +1 -1
  222. package/dist/quotes/liquidation/calculate-liquidation-price.js +1 -1
  223. package/dist/quotes/liquidation/calculate-liquidation-price.js.map +1 -1
  224. package/dist/quotes/upnl/calculate-quote-pnl.d.ts.map +1 -1
  225. package/dist/quotes/upnl/calculate-quote-pnl.js +8 -8
  226. package/dist/quotes/upnl/calculate-quote-pnl.js.map +1 -1
  227. package/dist/quotes/upnl/calculate-quote-upnl.d.ts +2 -2
  228. package/dist/quotes/upnl/calculate-quote-upnl.d.ts.map +1 -1
  229. package/dist/quotes/upnl/calculate-quote-upnl.js +16 -15
  230. package/dist/quotes/upnl/calculate-quote-upnl.js.map +1 -1
  231. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts +2 -2
  232. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts.map +1 -1
  233. package/dist/symmio-subgraph/types/generated/analytics/gql.js +2 -2
  234. package/dist/symmio-subgraph/types/generated/analytics/gql.js.map +1 -1
  235. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts +21 -0
  236. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts.map +1 -1
  237. package/dist/symmio-subgraph/types/generated/analytics/graphql.js +1 -1
  238. package/dist/symmio-subgraph/types/generated/analytics/graphql.js.map +1 -1
  239. package/package.json +1 -1
@@ -0,0 +1,21 @@
1
+ import { filterQueryOptions as e } from "../../shared/utils/query.js";
2
+ import { getPoolPortfolio as t } from "./get-pool-portfolio.js";
3
+ //#region src/pools/portfolio/query.ts
4
+ function n(t) {
5
+ return ["getPoolPortfolio", e(t)];
6
+ }
7
+ function r(e, r) {
8
+ return {
9
+ ...r.query,
10
+ queryKey: n({
11
+ ...r,
12
+ configKey: e.getChainConfigKey(r.chainId)
13
+ }),
14
+ enabled: (r.query?.enabled ?? !0) && r.accessToken.length > 0 && r.userAddress.length > 0,
15
+ queryFn: () => t(e, r)
16
+ };
17
+ }
18
+ //#endregion
19
+ export { n as getPoolPortfolioQueryKey, r as getPoolPortfolioQueryOptions };
20
+
21
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/portfolio/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 getPoolPortfolio,\n type GetPoolPortfolioParameters,\n type GetPoolPortfolioReturnType,\n} from \"./get-pool-portfolio\";\n/** Stable key for the composed core read. Credentials are excluded. */\nexport function getPoolPortfolioQueryKey(options: Compute<GetPoolPortfolioParameters & ConfigKeyParameter>) {\n return [\"getPoolPortfolio\", filterQueryOptions(options)] as const;\n}\n/** Composed query key type. */\nexport type GetPoolPortfolioQueryKey = ReturnType<typeof getPoolPortfolioQueryKey>;\n/** Query controls plus all required read inputs. */\nexport type GetPoolPortfolioOptions = GetPoolPortfolioParameters &\n QueryParameter<GetPoolPortfolioReturnType, Error, GetPoolPortfolioReturnType, GetPoolPortfolioQueryKey>;\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 getPoolPortfolioQueryOptions(\n config: Config,\n options: GetPoolPortfolioOptions,\n): SymmioQueryOptions<GetPoolPortfolioReturnType, Error, GetPoolPortfolioReturnType, GetPoolPortfolioQueryKey> {\n return {\n ...options.query,\n queryKey: getPoolPortfolioQueryKey({ ...options, configKey: config.getChainConfigKey(options.chainId) }),\n enabled: (options.query?.enabled ?? true) && options.accessToken.length > 0 && options.userAddress.length > 0,\n queryFn: () => getPoolPortfolio(config, options),\n };\n}\n"],"mappings":";;;AAUA,SAAgB,EAAyB,GAAmE;CAC1G,OAAO,CAAC,oBAAoB,EAAmB,CAAO,CAAC;AACzD;AAWA,SAAgB,EACd,GACA,GAC6G;CAC7G,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAyB;GAAE,GAAG;GAAS,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EAAE,CAAC;EACvG,UAAU,EAAQ,OAAO,WAAW,OAAS,EAAQ,YAAY,SAAS,KAAK,EAAQ,YAAY,SAAS;EAC5G,eAAe,EAAiB,GAAQ,CAAO;CACjD;AACF"}
@@ -0,0 +1,4 @@
1
+ import { PoolReadGap } from '../composition.js';
2
+ /** Per-portfolio queue: no more than five endpoint requests, including retries. */
3
+ export declare function createPositionReader(gaps: PoolReadGap[]): <T>(read: () => Promise<T>, source: string, address: string) => Promise<T | null>;
4
+ //# sourceMappingURL=read-positions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-positions.d.ts","sourceRoot":"","sources":["../../../src/pools/portfolio/read-positions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,IAInB,CAAC,EAAE,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA4ClH"}
@@ -0,0 +1,31 @@
1
+ import { readOptional as e } from "../composition.js";
2
+ //#region src/pools/portfolio/read-positions.ts
3
+ function t(t) {
4
+ let n = 0, r = [], i;
5
+ return async function(a, o, s) {
6
+ n >= 5 ? await new Promise((e) => r.push(e)) : n++;
7
+ try {
8
+ return await e(async () => {
9
+ try {
10
+ if (i) throw i;
11
+ return await a();
12
+ } catch (e) {
13
+ if (e && typeof e == "object" && "status" in e && (e.status === 401 || e.status === 403)) throw i = e, e;
14
+ if (i) throw i;
15
+ try {
16
+ return await a();
17
+ } catch (e) {
18
+ throw e && typeof e == "object" && "status" in e && (e.status === 401 || e.status === 403) && (i = e), e;
19
+ }
20
+ }
21
+ }, t, o, s);
22
+ } finally {
23
+ let e = r.shift();
24
+ e ? e() : n--;
25
+ }
26
+ };
27
+ }
28
+ //#endregion
29
+ export { t as createPositionReader };
30
+
31
+ //# sourceMappingURL=read-positions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-positions.js","names":[],"sources":["../../../src/pools/portfolio/read-positions.ts"],"sourcesContent":["import { readOptional, type PoolReadGap } from \"../composition\";\n\n/** Per-portfolio queue: no more than five endpoint requests, including retries. */\nexport function createPositionReader(gaps: PoolReadGap[]) {\n let active = 0;\n const waiting: (() => void)[] = [];\n let authenticationError: unknown;\n return async function readPosition<T>(read: () => Promise<T>, source: string, address: string): Promise<T | null> {\n if (active >= 5) await new Promise<void>((resolve) => waiting.push(resolve));\n else active++;\n try {\n return await readOptional(\n async () => {\n try {\n if (authenticationError) throw authenticationError;\n return await read();\n } catch (error) {\n if (\n error &&\n typeof error === \"object\" &&\n \"status\" in error &&\n (error.status === 401 || error.status === 403)\n ) {\n authenticationError = error;\n throw error;\n }\n if (authenticationError) throw authenticationError;\n try {\n return await read();\n } catch (retryError) {\n if (\n retryError &&\n typeof retryError === \"object\" &&\n \"status\" in retryError &&\n (retryError.status === 401 || retryError.status === 403)\n )\n authenticationError = retryError;\n throw retryError;\n }\n }\n },\n gaps,\n source,\n address,\n );\n } finally {\n const next = waiting.shift();\n if (next) next();\n else active--;\n }\n };\n}\n"],"mappings":";;AAGA,SAAgB,EAAqB,GAAqB;CACxD,IAAI,IAAS,GACP,IAA0B,CAAC,GAC7B;CACJ,OAAO,eAA+B,GAAwB,GAAgB,GAAoC;EAChH,AAAI,KAAU,IAAG,MAAM,IAAI,SAAe,MAAY,EAAQ,KAAK,CAAO,CAAC,IACtE;EACL,IAAI;GACF,OAAO,MAAM,EACX,YAAY;IACV,IAAI;KACF,IAAI,GAAqB,MAAM;KAC/B,OAAO,MAAM,EAAK;IACpB,SAAS,GAAO;KACd,IACE,KACA,OAAO,KAAU,YACjB,YAAY,MACX,EAAM,WAAW,OAAO,EAAM,WAAW,MAG1C,MADA,IAAsB,GAChB;KAER,IAAI,GAAqB,MAAM;KAC/B,IAAI;MACF,OAAO,MAAM,EAAK;KACpB,SAAS,GAAY;MAQnB,MANE,KACA,OAAO,KAAe,YACtB,YAAY,MACX,EAAW,WAAW,OAAO,EAAW,WAAW,SAEpD,IAAsB,IAClB;KACR;IACF;GACF,GACA,GACA,GACA,CACF;EACF,UAAU;GACR,IAAM,IAAO,EAAQ,MAAM;GAC3B,AAAI,IAAM,EAAK,IACV;EACP;CACF;AACF"}
@@ -0,0 +1,85 @@
1
+ import { PoolReadGap } from '../composition.js';
2
+ import { ListingDepositChainId, ListingMarketDetail, ListingMarketStatus, UserPoolProfit, UserTransaction } from '../types.js';
3
+ /** Complete cumulative deposit buckets, already normalized to 18 decimals. */
4
+ export interface PoolDepositHistory {
5
+ pending: bigint;
6
+ transferred: bigint;
7
+ success: bigint;
8
+ rejected: bigint;
9
+ refund: bigint;
10
+ }
11
+ /** One user's stake. Raw token, collateral and LP amounts use 18 decimals; USD values are unformatted numbers. */
12
+ export interface PoolPositionData {
13
+ tokenContractAddress: string | null;
14
+ depositChain: ListingDepositChainId | null;
15
+ marketStatus: ListingMarketStatus | null;
16
+ symbolId: number | null;
17
+ availableToken: bigint | null;
18
+ availableUsdc: bigint | null;
19
+ pendingToken: bigint | null;
20
+ pendingUsdc: bigint | null;
21
+ availableLp: bigint | null;
22
+ pendingLp: bigint | null;
23
+ totalLp: bigint | null;
24
+ /** Pending fraction of total LP, using the same clamped ledger as availableLp; null without profit. */
25
+ pendingRatio: number | null;
26
+ /** Available fraction of the LP ledger; null when the ledger is unavailable. */
27
+ availableRatio: number | null;
28
+ /** Selected available LP, floored at 18 decimals; null without a selection or profit. */
29
+ withdrawalLpAmount: bigint | null;
30
+ /** Estimated token leg before LP rounding, in 18-decimal units. */
31
+ withdrawalTokenAmount: bigint | null;
32
+ /** Estimated USDC leg before LP rounding, in 18-decimal units. */
33
+ withdrawalUsdcAmount: bigint | null;
34
+ /** Estimated USD at 18 decimals; includes only collateral when price is unknown. */
35
+ withdrawalValueUsd: bigint | null;
36
+ totalToken: bigint | null;
37
+ totalUsdc: bigint | null;
38
+ depositedToken: bigint | null;
39
+ /** Complete cumulative history; null for an incomplete or unavailable source. */
40
+ depositHistory: PoolDepositHistory | null;
41
+ currentDepositToken: bigint | null;
42
+ uncreditedDepositToken: bigint | null;
43
+ currentDepositUsd: number | null;
44
+ refundableValueUsd: number | null;
45
+ /** Known pending collateral plus priced pending tokens. */
46
+ pendingValueUsd: number | null;
47
+ pendingDepositToken: bigint | null;
48
+ rejectedDepositToken: bigint | null;
49
+ refundedToken: bigint | null;
50
+ refundableToken: bigint | null;
51
+ fullyRefunded: boolean | null;
52
+ claimableReward: bigint | null;
53
+ claimedReward: bigint | null;
54
+ shareFraction: number | null;
55
+ priceUsd: number | null;
56
+ /** Known collateral plus priced tokens. See valuationComplete before treating it as a complete valuation. */
57
+ balanceUsd: number | null;
58
+ valuationComplete: boolean;
59
+ gaps: PoolReadGap[];
60
+ }
61
+ /** SDK reads consumed unchanged by calculatePoolPosition. Null means the source failed or has not loaded. */
62
+ export interface CalculatePoolPositionParameters {
63
+ /** Omit both identity fields only for already-scoped snapshots. Network reads require both. */
64
+ tokenContractAddress?: string;
65
+ depositChain?: ListingDepositChainId;
66
+ detail: Partial<ListingMarketDetail> | null;
67
+ /** Partial cached snapshots are supported; omitted monetary fields remain unknown. */
68
+ profit: Partial<UserPoolProfit> | null;
69
+ deposits: readonly UserTransaction[] | null;
70
+ /** Complete, already-scoped buckets. Used instead of rows when supplied. */
71
+ depositHistory?: PoolDepositHistory | null;
72
+ /** LP-ledger ownership in whole percent, e.g. 3.2 means 3.2%. */
73
+ userSharePercentage?: number | null;
74
+ depositsComplete?: boolean;
75
+ priceUsd?: number;
76
+ /** Optional integer percentage of available LP, from 0 through 100. Omit for no preview. */
77
+ withdrawalPercent?: number;
78
+ gaps?: readonly PoolReadGap[];
79
+ }
80
+ /** Derive a stake from normalized reads, preserving unknown values and doing balance math in bigint.
81
+ * @param input - Detail, profit, and deposit reads for one pool.
82
+ * @returns Flat position data, shared by the position and portfolio hooks.
83
+ */
84
+ export declare function calculatePoolPosition(input: CalculatePoolPositionParameters): PoolPositionData;
85
+ //# sourceMappingURL=calculate-pool-position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-pool-position.d.ts","sourceRoot":"","sources":["../../../src/pools/position/calculate-pool-position.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,59 @@
1
+ import { units as e } from "../composition.js";
2
+ import { sumPoolDepositHistory as t } from "./sum-deposits.js";
3
+ import { parseUnits as n } from "viem";
4
+ import { toDecimal as r } from "@symmio/utils";
5
+ //#region src/pools/position/calculate-pool-position.ts
6
+ function i(i) {
7
+ let a = i.withdrawalPercent;
8
+ if (a != null && (!Number.isInteger(a) || a < 0 || a > 100)) throw RangeError("Withdrawal percent must be an integer from 0 to 100");
9
+ let { profit: o, detail: s } = i;
10
+ if (i.tokenContractAddress == null != (i.depositChain == null)) throw TypeError("Supply both pool identity fields or neither for scoped snapshots");
11
+ let c = o?.userLpAmount ?? null, l = c == null || o?.pendingWithdrawLpAmount == null ? null : o.pendingWithdrawLpAmount > c ? c : o.pendingWithdrawLpAmount < 0n ? 0n : o.pendingWithdrawLpAmount, u = c == null || l == null ? null : c - l, d = o?.userBalanceInTokens ?? null, f = o?.userBalanceInUsdc ?? null, p = (e) => e == null || c == null || u == null ? null : c > 0n ? e * u / c : 0n, m = p(d), h = p(f), g = i.depositsComplete === !1 ? null : i.depositHistory === void 0 ? i.deposits ? t(i.deposits.filter((e) => e.type === "deposit" && (i.depositChain == null || e.chainId === i.depositChain) && (i.tokenContractAddress == null || e.tokenAddress.toLowerCase() === i.tokenContractAddress.toLowerCase())).map((e) => ({
12
+ amount: e.amount,
13
+ status: e.status
14
+ }))) : null : i.depositHistory, _ = g ? g.success + g.transferred : o?.userDepositedTokenAmount ?? null, v = g ? g.success + g.transferred + g.rejected - g.refund : null, y = (e) => e > 0n ? e : 0n, b = g ? y(g.success + g.transferred + g.pending) : null, x = d == null || m == null ? null : d - m, S = f == null || h == null ? null : f - h, C = i.userSharePercentage, w = o?.totalUsdcInPool ?? s?.totalUsdcInPool, T = C != null && Number.isFinite(C) ? C / 100 : o?.userBalanceInUsdc != null && w != null && w > 0n ? Number(o.userBalanceInUsdc * 10n ** 18n / w) / 0xde0b6b3a7640000 : null, E = i.priceUsd != null && Number.isFinite(i.priceUsd) && i.priceUsd >= 0 ? i.priceUsd : null, D = a == null || u == null ? null : u * BigInt(a), O = c != null && c > 0n ? c * 100n : 1n, k = D == null || d == null ? null : d * D / O, A = D == null || f == null ? null : f * D / O, j = E == null ? 0n : n(r(E).toFixed(), 18);
15
+ return {
16
+ tokenContractAddress: i.tokenContractAddress ?? null,
17
+ depositChain: i.depositChain ?? null,
18
+ marketStatus: s?.marketStatus ?? null,
19
+ symbolId: s?.symbolId ?? null,
20
+ availableToken: m,
21
+ availableUsdc: h,
22
+ pendingToken: x,
23
+ pendingUsdc: S,
24
+ availableLp: u,
25
+ pendingLp: l,
26
+ totalLp: c,
27
+ availableRatio: u == null || c == null ? null : c > 0n ? Number(u * 10n ** 18n / c) / 0xde0b6b3a7640000 : 0,
28
+ pendingRatio: l == null || c == null ? null : c > 0n ? Number(l * 10n ** 18n / c) / 0xde0b6b3a7640000 : 0,
29
+ withdrawalLpAmount: D == null ? null : D / 100n,
30
+ withdrawalTokenAmount: k,
31
+ withdrawalUsdcAmount: A,
32
+ withdrawalValueUsd: k == null || A == null ? null : A + k * j / 10n ** 18n,
33
+ totalToken: d,
34
+ totalUsdc: f,
35
+ depositedToken: _,
36
+ depositHistory: g,
37
+ currentDepositToken: b,
38
+ uncreditedDepositToken: g ? y(g.pending + g.rejected - g.refund) : null,
39
+ currentDepositUsd: b == null || E == null ? null : e(b) * E,
40
+ refundableValueUsd: v == null || E == null ? null : e(y(v)) * E,
41
+ pendingValueUsd: x == null || S == null ? null : e(S) + e(x) * (E ?? 0),
42
+ pendingDepositToken: g?.pending ?? null,
43
+ rejectedDepositToken: g?.rejected ?? null,
44
+ refundedToken: g?.refund ?? null,
45
+ refundableToken: v == null ? null : v > 0n ? v : 0n,
46
+ fullyRefunded: g && v != null ? g.refund > 0n && v <= 0n : null,
47
+ claimableReward: o?.claimableReward ?? null,
48
+ claimedReward: o?.claimedReward ?? null,
49
+ shareFraction: T == null ? null : Math.min(1, Math.max(0, T)),
50
+ priceUsd: E,
51
+ balanceUsd: d == null || f == null ? null : e(f) + e(d) * (E ?? 0),
52
+ valuationComplete: d != null && f != null && (d === 0n || E != null),
53
+ gaps: [...i.gaps ?? []]
54
+ };
55
+ }
56
+ //#endregion
57
+ export { i as calculatePoolPosition };
58
+
59
+ //# sourceMappingURL=calculate-pool-position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-pool-position.js","names":[],"sources":["../../../src/pools/position/calculate-pool-position.ts"],"sourcesContent":["import { toDecimal } from \"@symmio/utils\";\nimport { parseUnits } from \"viem\";\nimport { units, type PoolReadGap } from \"../composition\";\nimport type {\n ListingDepositChainId,\n ListingMarketDetail,\n ListingMarketStatus,\n UserPoolProfit,\n UserTransaction,\n} from \"../types\";\nimport { sumPoolDepositHistory } from \"./sum-deposits\";\n\n/** Complete cumulative deposit buckets, already normalized to 18 decimals. */\nexport interface PoolDepositHistory {\n pending: bigint;\n transferred: bigint;\n success: bigint;\n rejected: bigint;\n refund: bigint;\n}\n\n/** One user's stake. Raw token, collateral and LP amounts use 18 decimals; USD values are unformatted numbers. */\nexport interface PoolPositionData {\n tokenContractAddress: string | null;\n depositChain: ListingDepositChainId | null;\n marketStatus: ListingMarketStatus | null;\n symbolId: number | null;\n availableToken: bigint | null;\n availableUsdc: bigint | null;\n pendingToken: bigint | null;\n pendingUsdc: bigint | null;\n availableLp: bigint | null;\n pendingLp: bigint | null;\n totalLp: bigint | null;\n /** Pending fraction of total LP, using the same clamped ledger as availableLp; null without profit. */\n pendingRatio: number | null;\n /** Available fraction of the LP ledger; null when the ledger is unavailable. */\n availableRatio: number | null;\n /** Selected available LP, floored at 18 decimals; null without a selection or profit. */\n withdrawalLpAmount: bigint | null;\n /** Estimated token leg before LP rounding, in 18-decimal units. */\n withdrawalTokenAmount: bigint | null;\n /** Estimated USDC leg before LP rounding, in 18-decimal units. */\n withdrawalUsdcAmount: bigint | null;\n /** Estimated USD at 18 decimals; includes only collateral when price is unknown. */\n withdrawalValueUsd: bigint | null;\n totalToken: bigint | null;\n totalUsdc: bigint | null;\n depositedToken: bigint | null;\n /** Complete cumulative history; null for an incomplete or unavailable source. */\n depositHistory: PoolDepositHistory | null;\n currentDepositToken: bigint | null;\n uncreditedDepositToken: bigint | null;\n currentDepositUsd: number | null;\n refundableValueUsd: number | null;\n /** Known pending collateral plus priced pending tokens. */\n pendingValueUsd: number | null;\n pendingDepositToken: bigint | null;\n rejectedDepositToken: bigint | null;\n refundedToken: bigint | null;\n refundableToken: bigint | null;\n fullyRefunded: boolean | null;\n claimableReward: bigint | null;\n claimedReward: bigint | null;\n shareFraction: number | null;\n priceUsd: number | null;\n /** Known collateral plus priced tokens. See valuationComplete before treating it as a complete valuation. */\n balanceUsd: number | null;\n valuationComplete: boolean;\n gaps: PoolReadGap[];\n}\n\n/** SDK reads consumed unchanged by calculatePoolPosition. Null means the source failed or has not loaded. */\nexport interface CalculatePoolPositionParameters {\n /** Omit both identity fields only for already-scoped snapshots. Network reads require both. */\n tokenContractAddress?: string;\n depositChain?: ListingDepositChainId;\n detail: Partial<ListingMarketDetail> | null;\n /** Partial cached snapshots are supported; omitted monetary fields remain unknown. */\n profit: Partial<UserPoolProfit> | null;\n deposits: readonly UserTransaction[] | null;\n /** Complete, already-scoped buckets. Used instead of rows when supplied. */\n depositHistory?: PoolDepositHistory | null;\n /** LP-ledger ownership in whole percent, e.g. 3.2 means 3.2%. */\n userSharePercentage?: number | null;\n depositsComplete?: boolean;\n priceUsd?: number;\n /** Optional integer percentage of available LP, from 0 through 100. Omit for no preview. */\n withdrawalPercent?: number;\n gaps?: readonly PoolReadGap[];\n}\n\n/** Derive a stake from normalized reads, preserving unknown values and doing balance math in bigint.\n * @param input - Detail, profit, and deposit reads for one pool.\n * @returns Flat position data, shared by the position and portfolio hooks.\n */\nexport function calculatePoolPosition(input: CalculatePoolPositionParameters): PoolPositionData {\n const percent = input.withdrawalPercent;\n if (percent != null && (!Number.isInteger(percent) || percent < 0 || percent > 100)) {\n throw new RangeError(\"Withdrawal percent must be an integer from 0 to 100\");\n }\n const { profit, detail } = input;\n if ((input.tokenContractAddress == null) !== (input.depositChain == null)) {\n throw new TypeError(\"Supply both pool identity fields or neither for scoped snapshots\");\n }\n const totalLp = profit?.userLpAmount ?? null;\n const pendingLp =\n totalLp == null || profit?.pendingWithdrawLpAmount == null\n ? null\n : profit.pendingWithdrawLpAmount > totalLp\n ? totalLp\n : profit.pendingWithdrawLpAmount < 0n\n ? 0n\n : profit.pendingWithdrawLpAmount;\n const availableLp = totalLp == null || pendingLp == null ? null : totalLp - pendingLp;\n const totalToken = profit?.userBalanceInTokens ?? null;\n const totalUsdc = profit?.userBalanceInUsdc ?? null;\n const split = (amount: bigint | null) =>\n amount == null || totalLp == null || availableLp == null\n ? null\n : totalLp > 0n\n ? (amount * availableLp) / totalLp\n : 0n;\n const availableToken = split(totalToken);\n const availableUsdc = split(totalUsdc);\n const history =\n input.depositsComplete === false\n ? null\n : input.depositHistory !== undefined\n ? input.depositHistory\n : input.deposits\n ? sumPoolDepositHistory(\n input.deposits\n .filter(\n (row) =>\n row.type === \"deposit\" &&\n (input.depositChain == null || row.chainId === input.depositChain) &&\n (input.tokenContractAddress == null ||\n row.tokenAddress.toLowerCase() === input.tokenContractAddress.toLowerCase()),\n )\n .map((row) => ({ amount: row.amount, status: row.status })),\n )\n : null;\n const depositedToken = history ? history.success + history.transferred : (profit?.userDepositedTokenAmount ?? null);\n const refundable = history ? history.success + history.transferred + history.rejected - history.refund : null;\n const nonnegative = (value: bigint) => (value > 0n ? value : 0n);\n const currentDepositToken = history ? nonnegative(history.success + history.transferred + history.pending) : null;\n const pendingToken = totalToken == null || availableToken == null ? null : totalToken - availableToken;\n const pendingUsdc = totalUsdc == null || availableUsdc == null ? null : totalUsdc - availableUsdc;\n const sharePercent = input.userSharePercentage;\n const poolUsdc = profit?.totalUsdcInPool ?? detail?.totalUsdcInPool;\n const share =\n sharePercent != null && Number.isFinite(sharePercent)\n ? sharePercent / 100\n : profit?.userBalanceInUsdc != null && poolUsdc != null && poolUsdc > 0n\n ? Number((profit.userBalanceInUsdc * 10n ** 18n) / poolUsdc) / 1e18\n : null;\n const priceUsd =\n input.priceUsd != null && Number.isFinite(input.priceUsd) && input.priceUsd >= 0 ? input.priceUsd : null;\n const selectedLp = percent == null || availableLp == null ? null : availableLp * BigInt(percent);\n const denominator = totalLp != null && totalLp > 0n ? totalLp * 100n : 1n;\n const withdrawalTokenAmount =\n selectedLp == null || totalToken == null ? null : (totalToken * selectedLp) / denominator;\n const withdrawalUsdcAmount = selectedLp == null || totalUsdc == null ? null : (totalUsdc * selectedLp) / denominator;\n const priceRaw = priceUsd == null ? 0n : parseUnits(toDecimal(priceUsd).toFixed(), 18);\n return {\n tokenContractAddress: input.tokenContractAddress ?? null,\n depositChain: input.depositChain ?? null,\n marketStatus: detail?.marketStatus ?? null,\n symbolId: detail?.symbolId ?? null,\n availableToken,\n availableUsdc,\n pendingToken,\n pendingUsdc,\n availableLp,\n pendingLp,\n totalLp,\n availableRatio:\n availableLp == null || totalLp == null\n ? null\n : totalLp > 0n\n ? Number((availableLp * 10n ** 18n) / totalLp) / 1e18\n : 0,\n pendingRatio:\n pendingLp == null || totalLp == null\n ? null\n : totalLp > 0n\n ? Number((pendingLp * 10n ** 18n) / totalLp) / 1e18\n : 0,\n withdrawalLpAmount: selectedLp == null ? null : selectedLp / 100n,\n withdrawalTokenAmount,\n withdrawalUsdcAmount,\n withdrawalValueUsd:\n withdrawalTokenAmount == null || withdrawalUsdcAmount == null\n ? null\n : withdrawalUsdcAmount + (withdrawalTokenAmount * priceRaw) / 10n ** 18n,\n totalToken,\n totalUsdc,\n depositedToken,\n depositHistory: history,\n currentDepositToken,\n uncreditedDepositToken: history ? nonnegative(history.pending + history.rejected - history.refund) : null,\n currentDepositUsd: currentDepositToken == null || priceUsd == null ? null : units(currentDepositToken)! * priceUsd,\n refundableValueUsd: refundable == null || priceUsd == null ? null : units(nonnegative(refundable))! * priceUsd,\n pendingValueUsd:\n pendingToken == null || pendingUsdc == null ? null : units(pendingUsdc)! + units(pendingToken)! * (priceUsd ?? 0),\n pendingDepositToken: history?.pending ?? null,\n rejectedDepositToken: history?.rejected ?? null,\n refundedToken: history?.refund ?? null,\n refundableToken: refundable == null ? null : refundable > 0n ? refundable : 0n,\n fullyRefunded: history && refundable != null ? history.refund > 0n && refundable <= 0n : null,\n claimableReward: profit?.claimableReward ?? null,\n claimedReward: profit?.claimedReward ?? null,\n shareFraction: share == null ? null : Math.min(1, Math.max(0, share)),\n priceUsd,\n balanceUsd:\n totalToken == null || totalUsdc == null ? null : units(totalUsdc)! + units(totalToken)! * (priceUsd ?? 0),\n valuationComplete: totalToken != null && totalUsdc != null && (totalToken === 0n || priceUsd != null),\n gaps: [...(input.gaps ?? [])],\n };\n}\n"],"mappings":"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"}
@@ -0,0 +1,22 @@
1
+ import { Config } from '../../core/config/index.js';
2
+ import { GetListingMarketDetailParameters } from '../market-detail/get-listing-market-detail.js';
3
+ import { PoolPositionData } from './calculate-pool-position.js';
4
+ /** Identity, authenticated wallet cache scope, and optional externally supplied token price. */
5
+ export type GetPoolPositionParameters = GetListingMarketDetailParameters & {
6
+ accessToken: string;
7
+ userAddress: string;
8
+ priceUsd?: number;
9
+ /** Optional integer percentage (0–100) for the position's exact withdrawal preview. */
10
+ withdrawalPercent?: number;
11
+ /** Existing catalog LP-ledger ownership, in whole percent. No extra catalog request is made. */
12
+ userSharePercentage?: number | null;
13
+ };
14
+ /** Result of getPoolPosition. */
15
+ export type GetPoolPositionReturnType = PoolPositionData;
16
+ /** Read one stake with bounded deposit history; unavailable sources appear in gaps.
17
+ * @param config - SDK deployment config.
18
+ * @param parameters - Pool identity, authenticated user and optional USD price.
19
+ * @returns A flat position with exact amounts and source gaps.
20
+ */
21
+ export declare function getPoolPosition(config: Config, parameters: GetPoolPositionParameters): Promise<GetPoolPositionReturnType>;
22
+ //# sourceMappingURL=get-pool-position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pool-position.d.ts","sourceRoot":"","sources":["../../../src/pools/position/get-pool-position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,4CAA4C,CAAC;AAIpD,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEzF,gGAAgG;AAChG,MAAM,MAAM,yBAAyB,GAAG,gCAAgC,GAAG;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gGAAgG;IAChG,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AACF,iCAAiC;AACjC,MAAM,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AAEzD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,yBAAyB,CAAC,CA+CpC"}
@@ -0,0 +1,47 @@
1
+ import { PoolTransactionType as e } from "../types.js";
2
+ import { getListingMarketDetail as t } from "../market-detail/get-listing-market-detail.js";
3
+ import { readOptional as n, readPages as r } from "../composition.js";
4
+ import { calculatePoolPosition as i } from "./calculate-pool-position.js";
5
+ import { getUserProfit as a } from "../profit/get-user-profit.js";
6
+ import { getUserTransactions as o } from "../user-transactions/get-user-transactions.js";
7
+ //#region src/pools/position/get-pool-position.ts
8
+ async function s(s, c) {
9
+ let l = [], { chainId: u, tokenContractAddress: d, depositChain: f, accessToken: p } = c, [m, h, g] = await Promise.all([
10
+ n(() => t(s, {
11
+ chainId: u,
12
+ tokenContractAddress: d,
13
+ depositChain: f
14
+ }), l, "detail", d),
15
+ n(() => a(s, {
16
+ chainId: u,
17
+ tokenContractAddress: d,
18
+ accessToken: p
19
+ }), l, "profit", d),
20
+ n(() => r(async (t) => {
21
+ let n = await o(s, {
22
+ chainId: u,
23
+ accessToken: p,
24
+ tokenAddress: d,
25
+ transactionType: e.DEPOSIT,
26
+ start: t,
27
+ size: 100
28
+ });
29
+ return {
30
+ items: n.items,
31
+ total: n.count
32
+ };
33
+ }, (e) => e.transactionId, l, "deposits"), l, "deposits", d)
34
+ ]);
35
+ return i({
36
+ ...c,
37
+ detail: m,
38
+ profit: h,
39
+ deposits: g,
40
+ depositsComplete: !l.some((e) => e.source === "deposits"),
41
+ gaps: l
42
+ });
43
+ }
44
+ //#endregion
45
+ export { s as getPoolPosition };
46
+
47
+ //# sourceMappingURL=get-pool-position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pool-position.js","names":[],"sources":["../../../src/pools/position/get-pool-position.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport { readOptional, readPages, type PoolReadGap } from \"../composition\";\nimport {\n getListingMarketDetail,\n type GetListingMarketDetailParameters,\n} from \"../market-detail/get-listing-market-detail\";\nimport { getUserProfit } from \"../profit/get-user-profit\";\nimport { PoolTransactionType } from \"../types\";\nimport { getUserTransactions } from \"../user-transactions/get-user-transactions\";\nimport { calculatePoolPosition, type PoolPositionData } from \"./calculate-pool-position\";\n\n/** Identity, authenticated wallet cache scope, and optional externally supplied token price. */\nexport type GetPoolPositionParameters = GetListingMarketDetailParameters & {\n accessToken: string;\n userAddress: string;\n priceUsd?: number;\n /** Optional integer percentage (0–100) for the position's exact withdrawal preview. */\n withdrawalPercent?: number;\n /** Existing catalog LP-ledger ownership, in whole percent. No extra catalog request is made. */\n userSharePercentage?: number | null;\n};\n/** Result of getPoolPosition. */\nexport type GetPoolPositionReturnType = PoolPositionData;\n\n/** Read one stake with bounded deposit history; unavailable sources appear in gaps.\n * @param config - SDK deployment config.\n * @param parameters - Pool identity, authenticated user and optional USD price.\n * @returns A flat position with exact amounts and source gaps.\n */\nexport async function getPoolPosition(\n config: Config,\n parameters: GetPoolPositionParameters,\n): Promise<GetPoolPositionReturnType> {\n const gaps: PoolReadGap[] = [];\n const { chainId, tokenContractAddress, depositChain, accessToken } = parameters;\n const [detail, profit, deposits] = await Promise.all([\n readOptional(\n () => getListingMarketDetail(config, { chainId, tokenContractAddress, depositChain }),\n gaps,\n \"detail\",\n tokenContractAddress,\n ),\n readOptional(\n () => getUserProfit(config, { chainId, tokenContractAddress, accessToken }),\n gaps,\n \"profit\",\n tokenContractAddress,\n ),\n readOptional(\n () =>\n readPages(\n async (start) => {\n const page = await getUserTransactions(config, {\n chainId,\n accessToken,\n tokenAddress: tokenContractAddress,\n transactionType: PoolTransactionType.DEPOSIT,\n start,\n size: 100,\n });\n return { items: page.items, total: page.count };\n },\n (row) => row.transactionId,\n gaps,\n \"deposits\",\n ),\n gaps,\n \"deposits\",\n tokenContractAddress,\n ),\n ]);\n return calculatePoolPosition({\n ...parameters,\n detail,\n profit,\n deposits,\n depositsComplete: !gaps.some((gap) => gap.source === \"deposits\"),\n gaps,\n });\n}\n"],"mappings":";;;;;;;AA6BA,eAAsB,EACpB,GACA,GACoC;CACpC,IAAM,IAAsB,CAAC,GACvB,EAAE,YAAS,yBAAsB,iBAAc,mBAAgB,GAC/D,CAAC,GAAQ,GAAQ,KAAY,MAAM,QAAQ,IAAI;EACnD,QACQ,EAAuB,GAAQ;GAAE;GAAS;GAAsB;EAAa,CAAC,GACpF,GACA,UACA,CACF;EACA,QACQ,EAAc,GAAQ;GAAE;GAAS;GAAsB;EAAY,CAAC,GAC1E,GACA,UACA,CACF;EACA,QAEI,EACE,OAAO,MAAU;GACf,IAAM,IAAO,MAAM,EAAoB,GAAQ;IAC7C;IACA;IACA,cAAc;IACd,iBAAiB,EAAoB;IACrC;IACA,MAAM;GACR,CAAC;GACD,OAAO;IAAE,OAAO,EAAK;IAAO,OAAO,EAAK;GAAM;EAChD,IACC,MAAQ,EAAI,eACb,GACA,UACF,GACF,GACA,YACA,CACF;CACF,CAAC;CACD,OAAO,EAAsB;EAC3B,GAAG;EACH;EACA;EACA;EACA,kBAAkB,CAAC,EAAK,MAAM,MAAQ,EAAI,WAAW,UAAU;EAC/D;CACF,CAAC;AACH"}
@@ -0,0 +1,4 @@
1
+ export * from './calculate-pool-position.js';
2
+ export * from './get-pool-position.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/position/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,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 { GetPoolPositionParameters, GetPoolPositionReturnType } from './get-pool-position.js';
5
+ /** Stable key for the composed core read. Credentials are excluded. */
6
+ export declare function getPoolPositionQueryKey(options: Compute<GetPoolPositionParameters & ConfigKeyParameter>): readonly ["getPoolPosition", Record<string, unknown>];
7
+ /** Composed query key type. */
8
+ export type GetPoolPositionQueryKey = ReturnType<typeof getPoolPositionQueryKey>;
9
+ /** Query controls plus all required read inputs. */
10
+ export type GetPoolPositionOptions = GetPoolPositionParameters & QueryParameter<GetPoolPositionReturnType, Error, GetPoolPositionReturnType, GetPoolPositionQueryKey>;
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 getPoolPositionQueryOptions(config: Config, options: GetPoolPositionOptions): SymmioQueryOptions<GetPoolPositionReturnType, Error, GetPoolPositionReturnType, GetPoolPositionQueryKey>;
17
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pools/position/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,EAAmB,KAAK,yBAAyB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACtH,uEAAuE;AACvE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,yBAAyB,GAAG,kBAAkB,CAAC,yDAEvG;AACD,+BAA+B;AAC/B,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACjF,oDAAoD;AACpD,MAAM,MAAM,sBAAsB,GAAG,yBAAyB,GAC5D,cAAc,CAAC,yBAAyB,EAAE,KAAK,EAAE,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;AACvG;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,sBAAsB,GAC9B,kBAAkB,CAAC,yBAAyB,EAAE,KAAK,EAAE,yBAAyB,EAAE,uBAAuB,CAAC,CAO1G"}
@@ -0,0 +1,21 @@
1
+ import { filterQueryOptions as e } from "../../shared/utils/query.js";
2
+ import { getPoolPosition as t } from "./get-pool-position.js";
3
+ //#region src/pools/position/query.ts
4
+ function n(t) {
5
+ return ["getPoolPosition", e(t)];
6
+ }
7
+ function r(e, r) {
8
+ return {
9
+ ...r.query,
10
+ queryKey: n({
11
+ ...r,
12
+ configKey: e.getChainConfigKey(r.chainId)
13
+ }),
14
+ enabled: (r.query?.enabled ?? !0) && r.accessToken.length > 0 && r.userAddress.length > 0,
15
+ queryFn: () => t(e, r)
16
+ };
17
+ }
18
+ //#endregion
19
+ export { n as getPoolPositionQueryKey, r as getPoolPositionQueryOptions };
20
+
21
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/position/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 { getPoolPosition, type GetPoolPositionParameters, type GetPoolPositionReturnType } from \"./get-pool-position\";\n/** Stable key for the composed core read. Credentials are excluded. */\nexport function getPoolPositionQueryKey(options: Compute<GetPoolPositionParameters & ConfigKeyParameter>) {\n return [\"getPoolPosition\", filterQueryOptions(options)] as const;\n}\n/** Composed query key type. */\nexport type GetPoolPositionQueryKey = ReturnType<typeof getPoolPositionQueryKey>;\n/** Query controls plus all required read inputs. */\nexport type GetPoolPositionOptions = GetPoolPositionParameters &\n QueryParameter<GetPoolPositionReturnType, Error, GetPoolPositionReturnType, GetPoolPositionQueryKey>;\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 getPoolPositionQueryOptions(\n config: Config,\n options: GetPoolPositionOptions,\n): SymmioQueryOptions<GetPoolPositionReturnType, Error, GetPoolPositionReturnType, GetPoolPositionQueryKey> {\n return {\n ...options.query,\n queryKey: getPoolPositionQueryKey({ ...options, configKey: config.getChainConfigKey(options.chainId) }),\n enabled: (options.query?.enabled ?? true) && options.accessToken.length > 0 && options.userAddress.length > 0,\n queryFn: () => getPoolPosition(config, options),\n };\n}\n"],"mappings":";;;AAMA,SAAgB,EAAwB,GAAkE;CACxG,OAAO,CAAC,mBAAmB,EAAmB,CAAO,CAAC;AACxD;AAWA,SAAgB,EACd,GACA,GAC0G;CAC1G,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAwB;GAAE,GAAG;GAAS,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EAAE,CAAC;EACtG,UAAU,EAAQ,OAAO,WAAW,OAAS,EAAQ,YAAY,SAAS,KAAK,EAAQ,YAAY,SAAS;EAC5G,eAAe,EAAgB,GAAQ,CAAO;CAChD;AACF"}
@@ -0,0 +1,10 @@
1
+ import { UserTransaction } from '../types.js';
2
+ /** Internal cumulative history. Amounts are already normalized to 18 decimals. */
3
+ export declare function sumPoolDepositHistory(deposits: readonly Pick<UserTransaction, "amount" | "status">[]): {
4
+ pending: bigint;
5
+ transferred: bigint;
6
+ refund: bigint;
7
+ rejected: bigint;
8
+ success: bigint;
9
+ };
10
+ //# sourceMappingURL=sum-deposits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum-deposits.d.ts","sourceRoot":"","sources":["../../../src/pools/position/sum-deposits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,QAAQ,CAAC,EAAE;;;;;;EAyBpG"}
@@ -0,0 +1,35 @@
1
+ //#region src/pools/position/sum-deposits.ts
2
+ function e(e) {
3
+ let t = {
4
+ pending: 0n,
5
+ transferred: 0n,
6
+ refund: 0n,
7
+ rejected: 0n,
8
+ success: 0n
9
+ };
10
+ for (let { amount: n, status: r } of e) switch (r) {
11
+ case "waiting":
12
+ case "pending":
13
+ t.pending += n;
14
+ break;
15
+ case "deposited":
16
+ case "transferred":
17
+ t.transferred += n;
18
+ break;
19
+ case "refund":
20
+ case "refound":
21
+ t.refund += n;
22
+ break;
23
+ case "rejected":
24
+ t.rejected += n;
25
+ break;
26
+ case "success":
27
+ t.success += n;
28
+ break;
29
+ }
30
+ return t;
31
+ }
32
+ //#endregion
33
+ export { e as sumPoolDepositHistory };
34
+
35
+ //# sourceMappingURL=sum-deposits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum-deposits.js","names":[],"sources":["../../../src/pools/position/sum-deposits.ts"],"sourcesContent":["import type { UserTransaction } from \"../types\";\n/** Internal cumulative history. Amounts are already normalized to 18 decimals. */\nexport function sumPoolDepositHistory(deposits: readonly Pick<UserTransaction, \"amount\" | \"status\">[]) {\n const history = { pending: 0n, transferred: 0n, refund: 0n, rejected: 0n, success: 0n };\n for (const { amount, status } of deposits) {\n switch (status as string) {\n case \"waiting\":\n case \"pending\":\n history.pending += amount;\n break;\n case \"deposited\":\n case \"transferred\":\n history.transferred += amount;\n break;\n case \"refund\":\n case \"refound\":\n history.refund += amount;\n break;\n case \"rejected\":\n history.rejected += amount;\n break;\n case \"success\":\n history.success += amount;\n break;\n }\n }\n return history;\n}\n"],"mappings":";AAEA,SAAgB,EAAsB,GAAiE;CACrG,IAAM,IAAU;EAAE,SAAS;EAAI,aAAa;EAAI,QAAQ;EAAI,UAAU;EAAI,SAAS;CAAG;CACtF,KAAK,IAAM,EAAE,WAAQ,eAAY,GAC/B,QAAQ,GAAR;EACE,KAAK;EACL,KAAK;GACH,EAAQ,WAAW;GACnB;EACF,KAAK;EACL,KAAK;GACH,EAAQ,eAAe;GACvB;EACF,KAAK;EACL,KAAK;GACH,EAAQ,UAAU;GAClB;EACF,KAAK;GACH,EAAQ,YAAY;GACpB;EACF,KAAK;GACH,EAAQ,WAAW;GACnB;CACJ;CAEF,OAAO;AACT"}
@@ -14,6 +14,8 @@ export type GetUserProfitParameters = Compute<ChainIdParameter & {
14
14
  * yields a `401`.
15
15
  */
16
16
  accessToken: string;
17
+ /** Optional authenticated wallet cache scope. Supply it consistently in all private read hooks; it is not sent to the endpoint. */
18
+ userAddress?: string;
17
19
  /**
18
20
  * The pool's token contract address — the id that addresses a single market
19
21
  * in the listing API. An EVM `0x…` address, or a Solana base58 address for a
@@ -34,6 +36,8 @@ export type GetUserProfitReturnType = UserPoolProfit;
34
36
  * is not uniform: most fields are 1e18-scaled integers, but `claimable_reward`
35
37
  * arrives in plain decimal units and is scaled up (see `toUserPoolProfit`).
36
38
  * Enigma-only.
39
+ * HTTP 404 with backend error code 22 (Market not listed) confirms no LP position
40
+ * and returns zero stake fields. Other failures remain errors; this action does not retry.
37
41
  *
38
42
  * @param config - The SDK config.
39
43
  * @param parameters - The bearer token and the pool's token contract address.
@@ -1 +1 @@
1
- {"version":3,"file":"get-user-profit.d.ts","sourceRoot":"","sources":["../../../src/pools/profit/get-user-profit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAC3C,gBAAgB,GAAG;IACjB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CACF,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,uBAAuB,GAClC,OAAO,CAAC,uBAAuB,CAAC,CAwBlC"}
1
+ {"version":3,"file":"get-user-profit.d.ts","sourceRoot":"","sources":["../../../src/pools/profit/get-user-profit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAG/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAC3C,gBAAgB,GAAG;IACjB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,mIAAmI;IACnI,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CACF,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,uBAAuB,GAClC,OAAO,CAAC,uBAAuB,CAAC,CA2BlC"}
@@ -1,24 +1,30 @@
1
1
  import { SymmApiError as e, SymmError as t } from "../../shared/errors/symm-error.js";
2
2
  import { resolveListingService as n } from "../resolve-listing.js";
3
3
  import { getProfitByTokenV2ProfitTokenContractAddressGet as r } from "../types/generated/listing-backend.js";
4
- import { toUserPoolProfit as i } from "./to-user-pool-profit.js";
5
- import { isAxiosError as a } from "axios";
4
+ import { emptyPoolProfit as i } from "../empty-pool-profit.js";
5
+ import { toUserPoolProfit as a } from "./to-user-pool-profit.js";
6
+ import { isAxiosError as o } from "axios";
6
7
  //#region src/pools/profit/get-user-profit.ts
7
- async function o(o, s) {
8
- let { url: c } = n(o, { chainId: s.chainId });
8
+ async function s(s, c) {
9
+ let { url: l } = n(s, { chainId: c.chainId });
9
10
  try {
10
- return i((await r(s.tokenContractAddress, {
11
- baseURL: c,
12
- headers: { Authorization: `Bearer ${s.accessToken}` }
11
+ return a((await r(c.tokenContractAddress, {
12
+ baseURL: l,
13
+ headers: { Authorization: `Bearer ${c.accessToken}` }
13
14
  })).data);
14
15
  } catch (n) {
15
- throw n instanceof t ? n : a(n) ? e.fromAxios(n, {
16
- code: "FETCH_USER_PROFIT_FAILED",
17
- baseURL: c
18
- }) : new t("api", "FETCH_USER_PROFIT_FAILED", `Failed to fetch user profit: ${n instanceof Error ? n.message : String(n)}`, { cause: n instanceof Error ? n : void 0 });
16
+ if (n instanceof t) throw n;
17
+ if (o(n)) {
18
+ if (n.response?.status === 404 && n.response.data?.error_code === 22) return i();
19
+ throw e.fromAxios(n, {
20
+ code: "FETCH_USER_PROFIT_FAILED",
21
+ baseURL: l
22
+ });
23
+ }
24
+ throw new t("api", "FETCH_USER_PROFIT_FAILED", `Failed to fetch user profit: ${n instanceof Error ? n.message : String(n)}`, { cause: n instanceof Error ? n : void 0 });
19
25
  }
20
26
  }
21
27
  //#endregion
22
- export { o as getUserProfit };
28
+ export { s as getUserProfit };
23
29
 
24
30
  //# sourceMappingURL=get-user-profit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-user-profit.js","names":[],"sources":["../../../src/pools/profit/get-user-profit.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport type { UserPoolProfit } from \"../types\";\nimport { getProfitByTokenV2ProfitTokenContractAddressGet } from \"../types/generated/listing-backend\";\nimport { toUserPoolProfit } from \"./to-user-pool-profit\";\n\n/**\n * Parameters for {@link getUserProfit}.\n *\n * Pool listing is chain-level, so this takes only a `chainId`: the listing\n * backend is resolved from the chain.\n */\nexport type GetUserProfitParameters = Compute<\n ChainIdParameter & {\n /**\n * Bearer token from `authenticateListing`; required — the endpoint is authed.\n * Sent as the `Authorization: Bearer <token>` header; a bad or expired token\n * yields a `401`.\n */\n accessToken: string;\n /**\n * The pool's token contract address — the id that addresses a single market\n * in the listing API. An EVM `0x…` address, or a Solana base58 address for a\n * Solana-deposited listing.\n */\n tokenContractAddress: string;\n }\n>;\n\n/** Return type of {@link getUserProfit}: the signed-in user's position in one pool. */\nexport type GetUserProfitReturnType = UserPoolProfit;\n\n/**\n * Fetch the signed-in user's LP position and profit in a single pool — their LP\n * shares, LP balance valued in tokens and USDC, claimable and claimed rewards,\n * deposited token amount, and the LP shares queued for withdrawal.\n *\n * This hits the authed `/v2/profit/{token_contract_address}` endpoint with the\n * caller's bearer token. Every value is normalized to a `bigint` at\n * `LISTING_VALUE_DECIMALS`, absent ones defaulting to `0n` — even though the wire\n * is not uniform: most fields are 1e18-scaled integers, but `claimable_reward`\n * arrives in plain decimal units and is scaled up (see `toUserPoolProfit`).\n * Enigma-only.\n *\n * @param config - The SDK config.\n * @param parameters - The bearer token and the pool's token contract address.\n * @returns The user's {@link UserPoolProfit} for the pool.\n * @throws {SymmApiError} when the endpoint request fails, including a `401` on a bad or expired token.\n * @throws {SymmError} `LISTING_NOT_CONFIGURED` when the chain has no listing\n * backend. Gate with `supportsListingService` to hide Pools instead.\n *\n * @example\n * ```ts\n * const profit = await getUserProfit(config, {\n * accessToken: token.accessToken,\n * tokenContractAddress: \"0x1234…\",\n * });\n * ```\n */\nexport async function getUserProfit(\n config: Config,\n parameters: GetUserProfitParameters,\n): Promise<GetUserProfitReturnType> {\n const { url: baseURL } = resolveListingService(config, { chainId: parameters.chainId });\n\n try {\n const response = await getProfitByTokenV2ProfitTokenContractAddressGet(parameters.tokenContractAddress, {\n baseURL,\n headers: { Authorization: `Bearer ${parameters.accessToken}` },\n });\n\n return toUserPoolProfit(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_USER_PROFIT_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"FETCH_USER_PROFIT_FAILED\",\n `Failed to fetch user profit: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;AA8DA,eAAsB,EACpB,GACA,GACkC;CAClC,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,EAAE,SAAS,EAAW,QAAQ,CAAC;CAEtF,IAAI;EAMF,OAAO,GAAiB,MALD,EAAgD,EAAW,sBAAsB;GACtG;GACA,SAAS,EAAE,eAAe,UAAU,EAAW,cAAc;EAC/D,CAAC,GAEgC,IAAI;CACvC,SAAS,GAAK;EAOZ,MANI,aAAe,IAAiB,IAEhC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAA4B;EAAQ,CAAC,IAG3E,IAAI,EACR,OACA,4BACA,gCAAgC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAC/E,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
1
+ {"version":3,"file":"get-user-profit.js","names":[],"sources":["../../../src/pools/profit/get-user-profit.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { emptyPoolProfit } from \"../empty-pool-profit\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport type { UserPoolProfit } from \"../types\";\nimport { getProfitByTokenV2ProfitTokenContractAddressGet } from \"../types/generated/listing-backend\";\nimport { toUserPoolProfit } from \"./to-user-pool-profit\";\n\n/**\n * Parameters for {@link getUserProfit}.\n *\n * Pool listing is chain-level, so this takes only a `chainId`: the listing\n * backend is resolved from the chain.\n */\nexport type GetUserProfitParameters = Compute<\n ChainIdParameter & {\n /**\n * Bearer token from `authenticateListing`; required — the endpoint is authed.\n * Sent as the `Authorization: Bearer <token>` header; a bad or expired token\n * yields a `401`.\n */\n accessToken: string;\n /** Optional authenticated wallet cache scope. Supply it consistently in all private read hooks; it is not sent to the endpoint. */\n userAddress?: string;\n /**\n * The pool's token contract address — the id that addresses a single market\n * in the listing API. An EVM `0x…` address, or a Solana base58 address for a\n * Solana-deposited listing.\n */\n tokenContractAddress: string;\n }\n>;\n\n/** Return type of {@link getUserProfit}: the signed-in user's position in one pool. */\nexport type GetUserProfitReturnType = UserPoolProfit;\n\n/**\n * Fetch the signed-in user's LP position and profit in a single pool — their LP\n * shares, LP balance valued in tokens and USDC, claimable and claimed rewards,\n * deposited token amount, and the LP shares queued for withdrawal.\n *\n * This hits the authed `/v2/profit/{token_contract_address}` endpoint with the\n * caller's bearer token. Every value is normalized to a `bigint` at\n * `LISTING_VALUE_DECIMALS`, absent ones defaulting to `0n` — even though the wire\n * is not uniform: most fields are 1e18-scaled integers, but `claimable_reward`\n * arrives in plain decimal units and is scaled up (see `toUserPoolProfit`).\n * Enigma-only.\n * HTTP 404 with backend error code 22 (Market not listed) confirms no LP position\n * and returns zero stake fields. Other failures remain errors; this action does not retry.\n *\n * @param config - The SDK config.\n * @param parameters - The bearer token and the pool's token contract address.\n * @returns The user's {@link UserPoolProfit} for the pool.\n * @throws {SymmApiError} when the endpoint request fails, including a `401` on a bad or expired token.\n * @throws {SymmError} `LISTING_NOT_CONFIGURED` when the chain has no listing\n * backend. Gate with `supportsListingService` to hide Pools instead.\n *\n * @example\n * ```ts\n * const profit = await getUserProfit(config, {\n * accessToken: token.accessToken,\n * tokenContractAddress: \"0x1234…\",\n * });\n * ```\n */\nexport async function getUserProfit(\n config: Config,\n parameters: GetUserProfitParameters,\n): Promise<GetUserProfitReturnType> {\n const { url: baseURL } = resolveListingService(config, { chainId: parameters.chainId });\n\n try {\n const response = await getProfitByTokenV2ProfitTokenContractAddressGet(parameters.tokenContractAddress, {\n baseURL,\n headers: { Authorization: `Bearer ${parameters.accessToken}` },\n });\n\n return toUserPoolProfit(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n // This exact response describes an existing market without an LP position.\n // Other 404s (including code 21), transport and server errors stay errors.\n if (err.response?.status === 404 && err.response.data?.error_code === 22) return emptyPoolProfit();\n throw SymmApiError.fromAxios(err, { code: \"FETCH_USER_PROFIT_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"FETCH_USER_PROFIT_FAILED\",\n `Failed to fetch user profit: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;;AAmEA,eAAsB,EACpB,GACA,GACkC;CAClC,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,EAAE,SAAS,EAAW,QAAQ,CAAC;CAEtF,IAAI;EAMF,OAAO,GAAiB,MALD,EAAgD,EAAW,sBAAsB;GACtG;GACA,SAAS,EAAE,eAAe,UAAU,EAAW,cAAc;EAC/D,CAAC,GAEgC,IAAI;CACvC,SAAS,GAAK;EACZ,IAAI,aAAe,GAAW,MAAM;EAEpC,IAAI,EAAa,CAAG,GAAG;GAGrB,IAAI,EAAI,UAAU,WAAW,OAAO,EAAI,SAAS,MAAM,eAAe,IAAI,OAAO,EAAgB;GACjG,MAAM,EAAa,UAAU,GAAK;IAAE,MAAM;IAA4B;GAAQ,CAAC;EACjF;EAEA,MAAM,IAAI,EACR,OACA,4BACA,gCAAgC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAC/E,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
@@ -11,9 +11,9 @@ import { LPTokenProfitSchema } from '../types/generated/listing-backend.js';
11
11
  * 18-decimal `bigint`. Running it through `toListingValue` like the others would
12
12
  * truncate the value to its integer part (`0n`).
13
13
  *
14
- * Every field is defaulted to `0n` when the service omits it or sends an empty
15
- * value — a missing figure on this per-user read means "nothing here", so zero is
16
- * the right collapse (unlike the catalog rows, where absent stays `null`).
14
+ * Core position fields retain their existing `0n` defaults. Supplemental market
15
+ * snapshots (TVL, APY, position metrics and totals) retain absence as `null` so
16
+ * callers can distinguish an unknown rollout field from a measured zero.
17
17
  *
18
18
  * `availableLpAmount` is **derived**, not a wire field: the LP shares free to
19
19
  * withdraw are the user's shares minus what is already queued
@@ -23,5 +23,23 @@ import { LPTokenProfitSchema } from '../types/generated/listing-backend.js';
23
23
  * @param raw - The endpoint's `/v2/profit/{token_contract_address}` response body.
24
24
  * @returns The normalized user pool profit.
25
25
  */
26
- export declare function toUserPoolProfit(raw: LPTokenProfitSchema): UserPoolProfit;
26
+ export declare function toUserPoolProfit(raw: LPTokenProfitSchema & {
27
+ tvl?: string | null;
28
+ apy_30d?: string | null;
29
+ long_position_amount?: string | null;
30
+ long_position_value?: string | null;
31
+ long_position_avg_open_price?: string | null;
32
+ long_position_upnl?: string | null;
33
+ short_position_amount?: string | null;
34
+ short_position_value?: string | null;
35
+ short_position_avg_open_price?: string | null;
36
+ short_position_upnl?: string | null;
37
+ apy_lifetime?: string | null;
38
+ apy_all_time?: string | null;
39
+ total_usdc_in_pool?: string | null;
40
+ total_token_in_pool?: string | null;
41
+ buyback_ratio?: string | number | null;
42
+ active_lps?: number | null;
43
+ age?: number | null;
44
+ }): UserPoolProfit;
27
45
  //# sourceMappingURL=to-user-pool-profit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-user-pool-profit.d.ts","sourceRoot":"","sources":["../../../src/pools/profit/to-user-pool-profit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,GAAG,cAAc,CAczE"}
1
+ {"version":3,"file":"to-user-pool-profit.d.ts","sourceRoot":"","sources":["../../../src/pools/profit/to-user-pool-profit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,mBAAmB,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,4BAA4B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,6BAA6B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,GACA,cAAc,CA8BhB"}