@symmio/trading-core 4.0.0 → 4.1.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 (223) 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 +46 -3
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +408 -388
  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/trade-history/query-document.d.ts +3 -0
  95. package/dist/pools/trade-history/query-document.d.ts.map +1 -1
  96. package/dist/pools/trade-history/query-document.js +1 -1
  97. package/dist/pools/trade-history/query-document.js.map +1 -1
  98. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.d.ts +22 -12
  99. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.d.ts.map +1 -1
  100. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.js +20 -21
  101. package/dist/quotes/get-quote-events-by-type/get-quote-events-by-type.js.map +1 -1
  102. package/dist/quotes/get-quote-events-by-type/query-document.d.ts +5 -5
  103. package/dist/quotes/get-quote-events-by-type/query-document.d.ts.map +1 -1
  104. package/dist/quotes/get-quote-events-by-type/query-document.js +1 -1
  105. package/dist/quotes/get-quote-events-by-type/query-document.js.map +1 -1
  106. package/dist/quotes/get-quote-events-by-type/query.d.ts +7 -6
  107. package/dist/quotes/get-quote-events-by-type/query.d.ts.map +1 -1
  108. package/dist/quotes/get-quote-events-by-type/query.js +19 -17
  109. package/dist/quotes/get-quote-events-by-type/query.js.map +1 -1
  110. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.d.ts +2 -2
  111. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.d.ts.map +1 -1
  112. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.js +1 -3
  113. package/dist/quotes/get-quote-events-by-type/to-quote-event-row.js.map +1 -1
  114. package/dist/quotes/get-quote-events-by-type/types.d.ts +14 -3
  115. package/dist/quotes/get-quote-events-by-type/types.d.ts.map +1 -1
  116. package/dist/quotes/get-quote-events-by-type/types.js.map +1 -1
  117. package/dist/quotes/get-quote-funding/get-quote-funding.d.ts +12 -2
  118. package/dist/quotes/get-quote-funding/get-quote-funding.d.ts.map +1 -1
  119. package/dist/quotes/get-quote-funding/get-quote-funding.js +21 -17
  120. package/dist/quotes/get-quote-funding/get-quote-funding.js.map +1 -1
  121. package/dist/quotes/get-quote-funding/query-document.d.ts +3 -2
  122. package/dist/quotes/get-quote-funding/query-document.d.ts.map +1 -1
  123. package/dist/quotes/get-quote-funding/query-document.js +1 -1
  124. package/dist/quotes/get-quote-funding/query-document.js.map +1 -1
  125. package/dist/quotes/get-quote-funding/query.d.ts.map +1 -1
  126. package/dist/quotes/get-quote-funding/query.js +2 -1
  127. package/dist/quotes/get-quote-funding/query.js.map +1 -1
  128. package/dist/quotes/get-quote-funding/to-funding-row.d.ts.map +1 -1
  129. package/dist/quotes/get-quote-funding/to-funding-row.js +1 -3
  130. package/dist/quotes/get-quote-funding/to-funding-row.js.map +1 -1
  131. package/dist/quotes/get-quote-history/get-quote-history.d.ts +18 -7
  132. package/dist/quotes/get-quote-history/get-quote-history.d.ts.map +1 -1
  133. package/dist/quotes/get-quote-history/get-quote-history.js +32 -22
  134. package/dist/quotes/get-quote-history/get-quote-history.js.map +1 -1
  135. package/dist/quotes/get-quote-history/query-document.d.ts +12 -7
  136. package/dist/quotes/get-quote-history/query-document.d.ts.map +1 -1
  137. package/dist/quotes/get-quote-history/query-document.js +1 -1
  138. package/dist/quotes/get-quote-history/query-document.js.map +1 -1
  139. package/dist/quotes/get-quote-history/query.d.ts +3 -2
  140. package/dist/quotes/get-quote-history/query.d.ts.map +1 -1
  141. package/dist/quotes/get-quote-history/query.js +22 -19
  142. package/dist/quotes/get-quote-history/query.js.map +1 -1
  143. package/dist/quotes/get-quote-history/to-history-row.d.ts.map +1 -1
  144. package/dist/quotes/get-quote-history/to-history-row.js +52 -37
  145. package/dist/quotes/get-quote-history/to-history-row.js.map +1 -1
  146. package/dist/quotes/get-quote-history/types.d.ts +41 -0
  147. package/dist/quotes/get-quote-history/types.d.ts.map +1 -1
  148. package/dist/quotes/get-quote-history/types.js.map +1 -1
  149. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.d.ts +21 -11
  150. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.d.ts.map +1 -1
  151. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.js +19 -21
  152. package/dist/quotes/get-quotes-events-by-type/get-quotes-events-by-type.js.map +1 -1
  153. package/dist/quotes/get-quotes-events-by-type/query-document.d.ts +7 -7
  154. package/dist/quotes/get-quotes-events-by-type/query-document.d.ts.map +1 -1
  155. package/dist/quotes/get-quotes-events-by-type/query-document.js +1 -1
  156. package/dist/quotes/get-quotes-events-by-type/query-document.js.map +1 -1
  157. package/dist/quotes/get-quotes-events-by-type/query.d.ts +8 -6
  158. package/dist/quotes/get-quotes-events-by-type/query.d.ts.map +1 -1
  159. package/dist/quotes/get-quotes-events-by-type/query.js +22 -20
  160. package/dist/quotes/get-quotes-events-by-type/query.js.map +1 -1
  161. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.d.ts +38 -0
  162. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.d.ts.map +1 -0
  163. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.js +28 -0
  164. package/dist/quotes/get-subgraph-quotes/get-subgraph-quotes.js.map +1 -0
  165. package/dist/quotes/get-subgraph-quotes/index.d.ts +5 -0
  166. package/dist/quotes/get-subgraph-quotes/index.d.ts.map +1 -0
  167. package/dist/quotes/get-subgraph-quotes/query-document.d.ts +15 -0
  168. package/dist/quotes/get-subgraph-quotes/query-document.d.ts.map +1 -0
  169. package/dist/quotes/get-subgraph-quotes/query-document.js +7 -0
  170. package/dist/quotes/get-subgraph-quotes/query-document.js.map +1 -0
  171. package/dist/quotes/get-subgraph-quotes/query.d.ts +37 -0
  172. package/dist/quotes/get-subgraph-quotes/query.d.ts.map +1 -0
  173. package/dist/quotes/get-subgraph-quotes/query.js +23 -0
  174. package/dist/quotes/get-subgraph-quotes/query.js.map +1 -0
  175. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.d.ts +12 -0
  176. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.d.ts.map +1 -0
  177. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.js +32 -0
  178. package/dist/quotes/get-subgraph-quotes/to-subgraph-quote-row.js.map +1 -0
  179. package/dist/quotes/get-subgraph-quotes/types.d.ts +54 -0
  180. package/dist/quotes/get-subgraph-quotes/types.d.ts.map +1 -0
  181. package/dist/quotes/index.d.ts +1 -0
  182. package/dist/quotes/index.d.ts.map +1 -1
  183. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.d.ts +122 -0
  184. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.d.ts.map +1 -0
  185. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.js +80 -0
  186. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/get-party-a-open-positions-batch.js.map +1 -0
  187. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/index.d.ts +3 -0
  188. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/index.d.ts.map +1 -0
  189. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.d.ts +37 -0
  190. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.d.ts.map +1 -0
  191. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.js +27 -0
  192. package/dist/symmio-contracts/symmio/get-party-a-open-positions-batch/query.js.map +1 -0
  193. package/dist/symmio-contracts/symmio/index.d.ts +2 -0
  194. package/dist/symmio-contracts/symmio/index.d.ts.map +1 -1
  195. package/dist/symmio-contracts/symmio/is-party-a-liquidated/index.d.ts +3 -0
  196. package/dist/symmio-contracts/symmio/is-party-a-liquidated/index.d.ts.map +1 -0
  197. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.d.ts +37 -0
  198. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.d.ts.map +1 -0
  199. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.js +15 -0
  200. package/dist/symmio-contracts/symmio/is-party-a-liquidated/is-party-a-liquidated.js.map +1 -0
  201. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.d.ts +38 -0
  202. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.d.ts.map +1 -0
  203. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.js +29 -0
  204. package/dist/symmio-contracts/symmio/is-party-a-liquidated/query.js.map +1 -0
  205. package/dist/symmio-subgraph/index.d.ts +1 -0
  206. package/dist/symmio-subgraph/index.d.ts.map +1 -1
  207. package/dist/symmio-subgraph/subgraph-decode.d.ts +51 -0
  208. package/dist/symmio-subgraph/subgraph-decode.d.ts.map +1 -0
  209. package/dist/symmio-subgraph/subgraph-decode.js +24 -0
  210. package/dist/symmio-subgraph/subgraph-decode.js.map +1 -0
  211. package/dist/symmio-subgraph/subgraph-filters.d.ts +97 -0
  212. package/dist/symmio-subgraph/subgraph-filters.d.ts.map +1 -0
  213. package/dist/symmio-subgraph/subgraph-filters.js +39 -0
  214. package/dist/symmio-subgraph/subgraph-filters.js.map +1 -0
  215. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts +25 -5
  216. package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts.map +1 -1
  217. package/dist/symmio-subgraph/types/generated/analytics/gql.js +16 -11
  218. package/dist/symmio-subgraph/types/generated/analytics/gql.js.map +1 -1
  219. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts +3640 -9
  220. package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts.map +1 -1
  221. package/dist/symmio-subgraph/types/generated/analytics/graphql.js +2 -2
  222. package/dist/symmio-subgraph/types/generated/analytics/graphql.js.map +1 -1
  223. package/package.json +1 -1
@@ -1,33 +1,37 @@
1
1
  import { querySubgraph as e } from "../../symmio-subgraph/query-subgraph/query-subgraph.js";
2
- import { QuotesFundingDocument as t } from "./query-document.js";
3
- import { toQuoteFundingRow as n } from "./to-funding-row.js";
2
+ import { compactWhere as t, stringList as n } from "../../symmio-subgraph/subgraph-filters.js";
3
+ import { QuotesFundingDocument as r } from "./query-document.js";
4
+ import { toQuoteFundingRow as i } from "./to-funding-row.js";
4
5
  //#region src/quotes/get-quote-funding/get-quote-funding.ts
5
- var r = 1e3;
6
- function i(e) {
6
+ var a = 1e3;
7
+ function o(e) {
7
8
  let t = [];
8
- for (let n = 0; n < e.length; n += r) t.push(e.slice(n, n + r));
9
+ for (let n = 0; n < e.length; n += a) t.push(e.slice(n, n + a));
9
10
  return t;
10
11
  }
11
- async function a(a, o) {
12
- let { chainId: s, quoteIds: c } = o;
13
- if (c.length === 0) return {
12
+ async function s(s, c) {
13
+ let { chainId: l, quoteIds: u, source: d } = c;
14
+ if (u.length === 0) return {
14
15
  rows: [],
15
16
  missingQuoteIds: []
16
17
  };
17
- let l = (await Promise.all(i(c).map((n) => e(a, {
18
- chainId: s,
19
- document: t,
18
+ let f = (await Promise.all(o(u).map((i) => e(s, {
19
+ chainId: l,
20
+ document: r,
20
21
  variables: {
21
- ids: n.map((e) => e.toString()),
22
- first: r
22
+ where: t({
23
+ quoteId_in: n(i),
24
+ source: d?.toLowerCase()
25
+ }),
26
+ first: a
23
27
  }
24
- })))).flatMap((e) => e.quotes.map(n)), u = new Set(l.map((e) => e.quoteId));
28
+ })))).flatMap((e) => e.quotes.map(i)), p = new Set(f.map((e) => e.quoteId));
25
29
  return {
26
- rows: l,
27
- missingQuoteIds: c.filter((e) => !u.has(e))
30
+ rows: f,
31
+ missingQuoteIds: u.filter((e) => !p.has(e))
28
32
  };
29
33
  }
30
34
  //#endregion
31
- export { r as QUOTES_FUNDING_MAX_IDS_PER_REQUEST, a as getQuoteFunding };
35
+ export { a as QUOTES_FUNDING_MAX_IDS_PER_REQUEST, s as getQuoteFunding };
32
36
 
33
37
  //# sourceMappingURL=get-quote-funding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-quote-funding.js","names":[],"sources":["../../../src/quotes/get-quote-funding/get-quote-funding.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { querySubgraph } from \"../../symmio-subgraph/query-subgraph\";\nimport { QuotesFundingDocument } from \"./query-document\";\nimport { toQuoteFundingRow } from \"./to-funding-row\";\nimport type { QuoteFundingData } from \"./types\";\n\n/**\n * Maximum number of quote ids sent in one `QuotesFunding` request.\n *\n * The Graph caps a `first` argument at 1000 entities per query (and silently\n * defaults to 100 when `first` is omitted), so {@link getQuoteFunding} chunks\n * its input at this size and merges the responses. Exported so callers that\n * size their own batches (and tests) can reuse the exact ceiling.\n */\nexport const QUOTES_FUNDING_MAX_IDS_PER_REQUEST = 1000;\n\n/**\n * Parameters for {@link getQuoteFunding}.\n */\nexport type GetQuoteFundingParameters = Compute<\n ChainIdParameter & {\n /** On-chain quote ids to read. */\n quoteIds: readonly bigint[];\n }\n>;\n\n/** Return type of {@link getQuoteFunding}. */\nexport interface GetQuoteFundingReturnType {\n /** One row per quote id the subgraph returned. */\n rows: QuoteFundingData[];\n /** Subset of input ids the subgraph did not return (indexing lag). */\n missingQuoteIds: bigint[];\n}\n\n/**\n * Split an id list into request-sized batches of at most\n * {@link QUOTES_FUNDING_MAX_IDS_PER_REQUEST} ids, preserving input order.\n */\nfunction chunkQuoteIds(quoteIds: readonly bigint[]): bigint[][] {\n const batches: bigint[][] = [];\n for (let index = 0; index < quoteIds.length; index += QUOTES_FUNDING_MAX_IDS_PER_REQUEST) {\n batches.push(quoteIds.slice(index, index + QUOTES_FUNDING_MAX_IDS_PER_REQUEST));\n }\n return batches;\n}\n\n/**\n * Read funding totals (`userPaidFunding`, `userReceivedFunding`) for a batch of\n * quotes from the analytics subgraph. Filters by the protocol-level `quoteId`\n * scalar so callers never need the diamond address.\n *\n * The action **pages internally**: `quoteIds` is chunked into requests of at\n * most {@link QUOTES_FUNDING_MAX_IDS_PER_REQUEST} ids, issued concurrently, and\n * the responses are merged. Callers pass the full id list — however long — and\n * never need to chunk it themselves. (Without an explicit `first`, The Graph\n * caps a query at 100 entities, which silently truncated large batches; the\n * extras then surfaced as `missingQuoteIds` and any caller that ignored\n * completeness rendered a wrong total.)\n *\n * The returned funding is what the analytics subgraph has **settled to date**:\n * funding accrued since the quote's last funding charge is not indexed by the\n * subgraph and is therefore not included — read it with\n * {@link getQuotePendingFunding}.\n *\n * Returns both the resolved rows and any input ids the subgraph did not yet\n * surface — callers (typically the React layer) decide whether to refetch on\n * indexing lag.\n *\n * @param config - The SDK config.\n * @param parameters - Quote ids and optional chain id.\n * @returns Funding rows (merged across all internal requests) plus the input ids\n * the subgraph did not return, computed across the full input set.\n * @throws {SymmError} when the chain has no analytics subgraph.\n * @throws {SymmApiError} when any subgraph request fails.\n *\n * @example\n * ```ts\n * const { rows, missingQuoteIds } = await getQuoteFunding(config, { quoteIds: [7334n, 7335n] });\n * ```\n */\nexport async function getQuoteFunding(\n config: Config,\n parameters: GetQuoteFundingParameters,\n): Promise<GetQuoteFundingReturnType> {\n const { chainId, quoteIds } = parameters;\n\n if (quoteIds.length === 0) return { rows: [], missingQuoteIds: [] };\n\n const responses = await Promise.all(\n chunkQuoteIds(quoteIds).map((batch) =>\n querySubgraph(config, {\n chainId,\n document: QuotesFundingDocument,\n variables: { ids: batch.map((id) => id.toString()), first: QUOTES_FUNDING_MAX_IDS_PER_REQUEST },\n }),\n ),\n );\n\n const rows = responses.flatMap((data) => data.quotes.map(toQuoteFundingRow));\n const seen = new Set(rows.map((row) => row.quoteId));\n const missingQuoteIds = quoteIds.filter((id) => !seen.has(id));\n return { rows, missingQuoteIds };\n}\n"],"mappings":";;;;AAeA,IAAa,IAAqC;AAwBlD,SAAS,EAAc,GAAyC;CAC9D,IAAM,IAAsB,CAAC;CAC7B,KAAK,IAAI,IAAQ,GAAG,IAAQ,EAAS,QAAQ,KAAS,GACpD,EAAQ,KAAK,EAAS,MAAM,GAAO,IAAQ,CAAkC,CAAC;CAEhF,OAAO;AACT;AAoCA,eAAsB,EACpB,GACA,GACoC;CACpC,IAAM,EAAE,YAAS,gBAAa;CAE9B,IAAI,EAAS,WAAW,GAAG,OAAO;EAAE,MAAM,CAAC;EAAG,iBAAiB,CAAC;CAAE;CAYlE,IAAM,KAAO,MAVW,QAAQ,IAC9B,EAAc,CAAQ,EAAE,KAAK,MAC3B,EAAc,GAAQ;EACpB;EACA,UAAU;EACV,WAAW;GAAE,KAAK,EAAM,KAAK,MAAO,EAAG,SAAS,CAAC;GAAG,OAAO;EAAmC;CAChG,CAAC,CACH,CACF,GAEuB,SAAS,MAAS,EAAK,OAAO,IAAI,CAAiB,CAAC,GACrE,IAAO,IAAI,IAAI,EAAK,KAAK,MAAQ,EAAI,OAAO,CAAC;CAEnD,OAAO;EAAE;EAAM,iBADS,EAAS,QAAQ,MAAO,CAAC,EAAK,IAAI,CAAE,CAC7C;CAAgB;AACjC"}
1
+ {"version":3,"file":"get-quote-funding.js","names":[],"sources":["../../../src/quotes/get-quote-funding/get-quote-funding.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { querySubgraph } from \"../../symmio-subgraph/query-subgraph\";\nimport { compactWhere, stringList } from \"../../symmio-subgraph/subgraph-filters\";\nimport type { Quote_Filter } from \"../../symmio-subgraph/types/generated/analytics/graphql\";\nimport { QuotesFundingDocument } from \"./query-document\";\nimport { toQuoteFundingRow } from \"./to-funding-row\";\nimport type { QuoteFundingData } from \"./types\";\n\n/**\n * Maximum number of quote ids sent in one `QuotesFunding` request.\n *\n * The Graph caps a `first` argument at 1000 entities per query (and silently\n * defaults to 100 when `first` is omitted), so {@link getQuoteFunding} chunks\n * its input at this size and merges the responses. Exported so callers that\n * size their own batches (and tests) can reuse the exact ceiling.\n */\nexport const QUOTES_FUNDING_MAX_IDS_PER_REQUEST = 1000;\n\n/**\n * Parameters for {@link getQuoteFunding}.\n */\nexport type GetQuoteFundingParameters = Compute<\n ChainIdParameter & {\n /** On-chain quote ids to read. */\n quoteIds: readonly bigint[];\n /**\n * The deployment's diamond address (the subgraph's `source`). Omit to match a\n * quote id on any deployment the subgraph indexes; pass it when one subgraph\n * indexes several diamonds, whose quote ids can collide.\n */\n source?: Address;\n }\n>;\n\n/** Return type of {@link getQuoteFunding}. */\nexport interface GetQuoteFundingReturnType {\n /** One row per quote id the subgraph returned. */\n rows: QuoteFundingData[];\n /** Subset of input ids the subgraph did not return (indexing lag). */\n missingQuoteIds: bigint[];\n}\n\n/**\n * Split an id list into request-sized batches of at most\n * {@link QUOTES_FUNDING_MAX_IDS_PER_REQUEST} ids, preserving input order.\n */\nfunction chunkQuoteIds(quoteIds: readonly bigint[]): bigint[][] {\n const batches: bigint[][] = [];\n for (let index = 0; index < quoteIds.length; index += QUOTES_FUNDING_MAX_IDS_PER_REQUEST) {\n batches.push(quoteIds.slice(index, index + QUOTES_FUNDING_MAX_IDS_PER_REQUEST));\n }\n return batches;\n}\n\n/**\n * Read funding totals (`userPaidFunding`, `userReceivedFunding`) for a batch of\n * quotes from the analytics subgraph. Filters by the protocol-level `quoteId`\n * scalar so callers never need the diamond address.\n *\n * The action **pages internally**: `quoteIds` is chunked into requests of at\n * most {@link QUOTES_FUNDING_MAX_IDS_PER_REQUEST} ids, issued concurrently, and\n * the responses are merged. Callers pass the full id list — however long — and\n * never need to chunk it themselves. (Without an explicit `first`, The Graph\n * caps a query at 100 entities, which silently truncated large batches; the\n * extras then surfaced as `missingQuoteIds` and any caller that ignored\n * completeness rendered a wrong total.)\n *\n * The returned funding is what the analytics subgraph has **settled to date**:\n * funding accrued since the quote's last funding charge is not indexed by the\n * subgraph and is therefore not included — read it with\n * {@link getQuotePendingFunding}.\n *\n * Returns both the resolved rows and any input ids the subgraph did not yet\n * surface — callers (typically the React layer) decide whether to refetch on\n * indexing lag.\n *\n * @param config - The SDK config.\n * @param parameters - Quote ids, optional diamond (`source`), optional chain id.\n * @returns Funding rows (merged across all internal requests) plus the input ids\n * the subgraph did not return, computed across the full input set.\n * @throws {SymmError} when the chain has no analytics subgraph.\n * @throws {SymmApiError} when any subgraph request fails.\n *\n * @example\n * ```ts\n * const { rows, missingQuoteIds } = await getQuoteFunding(config, {\n * quoteIds: [7334n, 7335n],\n * source: \"0xdiamond…\",\n * });\n * ```\n */\nexport async function getQuoteFunding(\n config: Config,\n parameters: GetQuoteFundingParameters,\n): Promise<GetQuoteFundingReturnType> {\n const { chainId, quoteIds, source } = parameters;\n\n if (quoteIds.length === 0) return { rows: [], missingQuoteIds: [] };\n\n const responses = await Promise.all(\n chunkQuoteIds(quoteIds).map((batch) =>\n querySubgraph(config, {\n chainId,\n document: QuotesFundingDocument,\n variables: {\n where: compactWhere<Quote_Filter>({\n quoteId_in: stringList(batch),\n source: source?.toLowerCase(),\n }),\n first: QUOTES_FUNDING_MAX_IDS_PER_REQUEST,\n },\n }),\n ),\n );\n\n const rows = responses.flatMap((data) => data.quotes.map(toQuoteFundingRow));\n const seen = new Set(rows.map((row) => row.quoteId));\n const missingQuoteIds = quoteIds.filter((id) => !seen.has(id));\n return { rows, missingQuoteIds };\n}\n"],"mappings":";;;;;AAkBA,IAAa,IAAqC;AA8BlD,SAAS,EAAc,GAAyC;CAC9D,IAAM,IAAsB,CAAC;CAC7B,KAAK,IAAI,IAAQ,GAAG,IAAQ,EAAS,QAAQ,KAAS,GACpD,EAAQ,KAAK,EAAS,MAAM,GAAO,IAAQ,CAAkC,CAAC;CAEhF,OAAO;AACT;AAuCA,eAAsB,EACpB,GACA,GACoC;CACpC,IAAM,EAAE,YAAS,aAAU,cAAW;CAEtC,IAAI,EAAS,WAAW,GAAG,OAAO;EAAE,MAAM,CAAC;EAAG,iBAAiB,CAAC;CAAE;CAkBlE,IAAM,KAAO,MAhBW,QAAQ,IAC9B,EAAc,CAAQ,EAAE,KAAK,MAC3B,EAAc,GAAQ;EACpB;EACA,UAAU;EACV,WAAW;GACT,OAAO,EAA2B;IAChC,YAAY,EAAW,CAAK;IAC5B,QAAQ,GAAQ,YAAY;GAC9B,CAAC;GACD,OAAO;EACT;CACF,CAAC,CACH,CACF,GAEuB,SAAS,MAAS,EAAK,OAAO,IAAI,CAAiB,CAAC,GACrE,IAAO,IAAI,IAAI,EAAK,KAAK,MAAQ,EAAI,OAAO,CAAC;CAEnD,OAAO;EAAE;EAAM,iBADS,EAAS,QAAQ,MAAO,CAAC,EAAK,IAAI,CAAE,CAC7C;CAAgB;AACjC"}
@@ -2,12 +2,13 @@
2
2
  * Batch read of `userPaidFunding` / `userReceivedFunding` for the given on-chain
3
3
  * quote ids. Filters on the protocol-level `quoteId` scalar — not the subgraph's
4
4
  * opaque composite `id` — so callers never need the diamond address to query
5
- * funding.
5
+ * funding. The action builds `$where` (`quoteId_in`, plus `source` only when the
6
+ * caller passes a diamond), so an omitted filter is absent rather than null.
6
7
  *
7
8
  * The document compiles to a typed query string via graphql-codegen.
8
9
  */
9
10
  export declare const QuotesFundingDocument: import('../../symmio-subgraph/types/generated/analytics/graphql.js').TypedDocumentString<import('../../symmio-subgraph/types/generated/analytics/graphql.js').QuotesFundingQuery, {
10
- ids: Array<string> | string;
11
+ where: import('../../symmio-subgraph/types/generated/analytics/graphql.js').Quote_Filter;
11
12
  first: number;
12
13
  }>;
13
14
  //# sourceMappingURL=query-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-document.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-funding/query-document.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;;EAQhC,CAAC"}
1
+ {"version":3,"file":"query-document.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-funding/query-document.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;;;EAQhC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { graphql as e } from "../../symmio-subgraph/types/generated/analytics/gql.js";
2
2
  //#region src/quotes/get-quote-funding/query-document.ts
3
- var t = e("\n query QuotesFunding($ids: [BigInt!]!, $first: Int!) {\n quotes(first: $first, where: { quoteId_in: $ids }) {\n quoteId\n userPaidFunding\n userReceivedFunding\n }\n }\n");
3
+ var t = e("\n query QuotesFunding($where: Quote_filter!, $first: Int!) {\n quotes(first: $first, where: $where) {\n quoteId\n userPaidFunding\n userReceivedFunding\n }\n }\n");
4
4
  //#endregion
5
5
  export { t as QuotesFundingDocument };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"query-document.js","names":[],"sources":["../../../src/quotes/get-quote-funding/query-document.ts"],"sourcesContent":["import { graphql } from \"../../symmio-subgraph/types/generated/analytics\";\n\n/**\n * Batch read of `userPaidFunding` / `userReceivedFunding` for the given on-chain\n * quote ids. Filters on the protocol-level `quoteId` scalar — not the subgraph's\n * opaque composite `id` — so callers never need the diamond address to query\n * funding.\n *\n * The document compiles to a typed query string via graphql-codegen.\n */\nexport const QuotesFundingDocument = graphql(`\n query QuotesFunding($ids: [BigInt!]!, $first: Int!) {\n quotes(first: $first, where: { quoteId_in: $ids }) {\n quoteId\n userPaidFunding\n userReceivedFunding\n }\n }\n`);\n"],"mappings":";;AAUA,IAAa,IAAwB,EAAQ,oMAQ5C"}
1
+ {"version":3,"file":"query-document.js","names":[],"sources":["../../../src/quotes/get-quote-funding/query-document.ts"],"sourcesContent":["import { graphql } from \"../../symmio-subgraph/types/generated/analytics\";\n\n/**\n * Batch read of `userPaidFunding` / `userReceivedFunding` for the given on-chain\n * quote ids. Filters on the protocol-level `quoteId` scalar — not the subgraph's\n * opaque composite `id` — so callers never need the diamond address to query\n * funding. The action builds `$where` (`quoteId_in`, plus `source` only when the\n * caller passes a diamond), so an omitted filter is absent rather than null.\n *\n * The document compiles to a typed query string via graphql-codegen.\n */\nexport const QuotesFundingDocument = graphql(`\n query QuotesFunding($where: Quote_filter!, $first: Int!) {\n quotes(first: $first, where: $where) {\n quoteId\n userPaidFunding\n userReceivedFunding\n }\n }\n`);\n"],"mappings":";;AAWA,IAAa,IAAwB,EAAQ,2LAQ5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-funding/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;AAGnF,OAAO,EAAmB,KAAK,yBAAyB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEtH,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,yBAAyB,GAAG,kBAAkB,CAAC;;GAGvG;AAED,kEAAkE;AAClE,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,yBAAyB,GAAG,cAAc,CAAC,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,CAAC,CACrH,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GAAG,kBAAkB,CAC1D,mBAAmB,EACnB,KAAK,EACL,mBAAmB,EACnB,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,sBAAsB,GAC9B,2BAA2B,CAU7B"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-funding/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;AAGnF,OAAO,EAAmB,KAAK,yBAAyB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEtH,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,yBAAyB,GAAG,kBAAkB,CAAC;;GAGvG;AAED,kEAAkE;AAClE,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,yBAAyB,GAAG,cAAc,CAAC,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,CAAC,CACrH,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GAAG,kBAAkB,CAC1D,mBAAmB,EACnB,KAAK,EACL,mBAAmB,EACnB,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,sBAAsB,GAC9B,2BAA2B,CAW7B"}
@@ -18,7 +18,8 @@ function i(e, n) {
18
18
  enabled: (n.query?.enabled ?? !0) && n.quoteIds.length > 0,
19
19
  queryFn: () => t(e, {
20
20
  chainId: n.chainId,
21
- quoteIds: n.quoteIds
21
+ quoteIds: n.quoteIds,
22
+ source: n.source
22
23
  })
23
24
  };
24
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","names":[],"sources":["../../../src/quotes/get-quote-funding/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 { toQuoteIdKeyPart } from \"../quote-id-key-part\";\nimport { getQuoteFunding, type GetQuoteFundingParameters, type GetQuoteFundingReturnType } from \"./get-quote-funding\";\n\n/** Data resolved by the {@link getQuoteFundingQueryOptions} query. */\nexport type GetQuoteFundingData = GetQuoteFundingReturnType;\n\n/**\n * Build the TanStack Query key for {@link getQuoteFundingQueryOptions}.\n *\n * @param options - Query parameters (quote ids, chain id, config key).\n * @returns A stable, hashable query key. The `bigint` quote ids are stringified so\n * the key is JSON-safe, and sorted so id order does not fragment the cache.\n */\nexport function getQuoteFundingQueryKey(options: Compute<GetQuoteFundingParameters & ConfigKeyParameter>) {\n const filtered = filterQueryOptions(options);\n return [\"getQuoteFunding\", { ...filtered, quoteIds: toQuoteIdKeyPart(options.quoteIds) }] as const;\n}\n\n/** Query-key type produced by {@link getQuoteFundingQueryKey}. */\nexport type GetQuoteFundingQueryKey = ReturnType<typeof getQuoteFundingQueryKey>;\n\n/**\n * Options accepted by {@link getQuoteFundingQueryOptions}: the action's\n * parameters plus TanStack overrides.\n */\nexport type GetQuoteFundingOptions = Compute<\n GetQuoteFundingParameters & QueryParameter<GetQuoteFundingData, Error, GetQuoteFundingData, GetQuoteFundingQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getQuoteFundingQueryOptions}. */\nexport type GetQuoteFundingQueryOptions = SymmioQueryOptions<\n GetQuoteFundingData,\n Error,\n GetQuoteFundingData,\n GetQuoteFundingQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getQuoteFunding}. The query is\n * disabled until at least one `quoteId` is supplied.\n *\n * @param config - The SDK config.\n * @param options - Query parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(\n * getQuoteFundingQueryOptions(config, { quoteIds: [7334n] }),\n * );\n * ```\n */\nexport function getQuoteFundingQueryOptions(\n config: Config,\n options: GetQuoteFundingOptions,\n): GetQuoteFundingQueryOptions {\n return {\n ...options.query,\n queryKey: getQuoteFundingQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: (options.query?.enabled ?? true) && options.quoteIds.length > 0,\n queryFn: () => getQuoteFunding(config, { chainId: options.chainId, quoteIds: options.quoteIds }),\n };\n}\n"],"mappings":";;;;AAiBA,SAAgB,EAAwB,GAAkE;CAExG,OAAO,CAAC,mBAAmB;EAAE,GADZ,EAAmB,CACJ;EAAU,UAAU,EAAiB,EAAQ,QAAQ;CAAE,CAAC;AAC1F;AAoCA,SAAgB,EACd,GACA,GAC6B;CAC7B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAwB;GAChC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,UAAU,EAAQ,OAAO,WAAW,OAAS,EAAQ,SAAS,SAAS;EACvE,eAAe,EAAgB,GAAQ;GAAE,SAAS,EAAQ;GAAS,UAAU,EAAQ;EAAS,CAAC;CACjG;AACF"}
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/quotes/get-quote-funding/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 { toQuoteIdKeyPart } from \"../quote-id-key-part\";\nimport { getQuoteFunding, type GetQuoteFundingParameters, type GetQuoteFundingReturnType } from \"./get-quote-funding\";\n\n/** Data resolved by the {@link getQuoteFundingQueryOptions} query. */\nexport type GetQuoteFundingData = GetQuoteFundingReturnType;\n\n/**\n * Build the TanStack Query key for {@link getQuoteFundingQueryOptions}.\n *\n * @param options - Query parameters (quote ids, chain id, config key).\n * @returns A stable, hashable query key. The `bigint` quote ids are stringified so\n * the key is JSON-safe, and sorted so id order does not fragment the cache.\n */\nexport function getQuoteFundingQueryKey(options: Compute<GetQuoteFundingParameters & ConfigKeyParameter>) {\n const filtered = filterQueryOptions(options);\n return [\"getQuoteFunding\", { ...filtered, quoteIds: toQuoteIdKeyPart(options.quoteIds) }] as const;\n}\n\n/** Query-key type produced by {@link getQuoteFundingQueryKey}. */\nexport type GetQuoteFundingQueryKey = ReturnType<typeof getQuoteFundingQueryKey>;\n\n/**\n * Options accepted by {@link getQuoteFundingQueryOptions}: the action's\n * parameters plus TanStack overrides.\n */\nexport type GetQuoteFundingOptions = Compute<\n GetQuoteFundingParameters & QueryParameter<GetQuoteFundingData, Error, GetQuoteFundingData, GetQuoteFundingQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getQuoteFundingQueryOptions}. */\nexport type GetQuoteFundingQueryOptions = SymmioQueryOptions<\n GetQuoteFundingData,\n Error,\n GetQuoteFundingData,\n GetQuoteFundingQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getQuoteFunding}. The query is\n * disabled until at least one `quoteId` is supplied.\n *\n * @param config - The SDK config.\n * @param options - Query parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(\n * getQuoteFundingQueryOptions(config, { quoteIds: [7334n] }),\n * );\n * ```\n */\nexport function getQuoteFundingQueryOptions(\n config: Config,\n options: GetQuoteFundingOptions,\n): GetQuoteFundingQueryOptions {\n return {\n ...options.query,\n queryKey: getQuoteFundingQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: (options.query?.enabled ?? true) && options.quoteIds.length > 0,\n queryFn: () =>\n getQuoteFunding(config, { chainId: options.chainId, quoteIds: options.quoteIds, source: options.source }),\n };\n}\n"],"mappings":";;;;AAiBA,SAAgB,EAAwB,GAAkE;CAExG,OAAO,CAAC,mBAAmB;EAAE,GADZ,EAAmB,CACJ;EAAU,UAAU,EAAiB,EAAQ,QAAQ;CAAE,CAAC;AAC1F;AAoCA,SAAgB,EACd,GACA,GAC6B;CAC7B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAwB;GAChC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,UAAU,EAAQ,OAAO,WAAW,OAAS,EAAQ,SAAS,SAAS;EACvE,eACE,EAAgB,GAAQ;GAAE,SAAS,EAAQ;GAAS,UAAU,EAAQ;GAAU,QAAQ,EAAQ;EAAO,CAAC;CAC5G;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"to-funding-row.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-funding/to-funding-row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,8DAA8D;AAC9D,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAOtE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,kBAAkB,GAAG,gBAAgB,CAS3E"}
1
+ {"version":3,"file":"to-funding-row.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-funding/to-funding-row.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,8DAA8D;AAC9D,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,kBAAkB,GAAG,gBAAgB,CAS3E"}
@@ -1,7 +1,5 @@
1
+ import { toBigIntOrZero as e } from "../../symmio-subgraph/subgraph-decode.js";
1
2
  //#region src/quotes/get-quote-funding/to-funding-row.ts
2
- function e(e) {
3
- return e ? BigInt(e) : 0n;
4
- }
5
3
  function t(t) {
6
4
  let n = e(t.userPaidFunding), r = e(t.userReceivedFunding);
7
5
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"to-funding-row.js","names":[],"sources":["../../../src/quotes/get-quote-funding/to-funding-row.ts"],"sourcesContent":["import type { QuotesFundingQuery } from \"../../symmio-subgraph/types/generated/analytics/graphql\";\nimport type { QuoteFundingData } from \"./types\";\n\n/** A single `quotes` row as returned by the funding query. */\nexport type RawQuoteFundingRow = QuotesFundingQuery[\"quotes\"][number];\n\n/** Parse a wei string to `bigint`, defaulting null/undefined to `0n`. */\nfunction toBigInt(value: string | null | undefined): bigint {\n return value ? BigInt(value) : 0n;\n}\n\n/**\n * Build a {@link QuoteFundingData} from one raw subgraph `quotes` row.\n * `netReceived` is `received − paid`, so a positive value means the position\n * earned funding.\n */\nexport function toQuoteFundingRow(row: RawQuoteFundingRow): QuoteFundingData {\n const paid = toBigInt(row.userPaidFunding);\n const received = toBigInt(row.userReceivedFunding);\n return {\n quoteId: toBigInt(row.quoteId),\n paid,\n received,\n netReceived: received - paid,\n };\n}\n"],"mappings":";AAOA,SAAS,EAAS,GAA0C;CAC1D,OAAO,IAAQ,OAAO,CAAK,IAAI;AACjC;AAOA,SAAgB,EAAkB,GAA2C;CAC3E,IAAM,IAAO,EAAS,EAAI,eAAe,GACnC,IAAW,EAAS,EAAI,mBAAmB;CACjD,OAAO;EACL,SAAS,EAAS,EAAI,OAAO;EAC7B;EACA;EACA,aAAa,IAAW;CAC1B;AACF"}
1
+ {"version":3,"file":"to-funding-row.js","names":[],"sources":["../../../src/quotes/get-quote-funding/to-funding-row.ts"],"sourcesContent":["import { toBigIntOrZero } from \"../../symmio-subgraph/subgraph-decode\";\nimport type { QuotesFundingQuery } from \"../../symmio-subgraph/types/generated/analytics/graphql\";\nimport type { QuoteFundingData } from \"./types\";\n\n/** A single `quotes` row as returned by the funding query. */\nexport type RawQuoteFundingRow = QuotesFundingQuery[\"quotes\"][number];\n\n/**\n * Build a {@link QuoteFundingData} from one raw subgraph `quotes` row.\n * `netReceived` is `received − paid`, so a positive value means the position\n * earned funding.\n */\nexport function toQuoteFundingRow(row: RawQuoteFundingRow): QuoteFundingData {\n const paid = toBigIntOrZero(row.userPaidFunding);\n const received = toBigIntOrZero(row.userReceivedFunding);\n return {\n quoteId: toBigIntOrZero(row.quoteId),\n paid,\n received,\n netReceived: received - paid,\n };\n}\n"],"mappings":";;AAYA,SAAgB,EAAkB,GAA2C;CAC3E,IAAM,IAAO,EAAe,EAAI,eAAe,GACzC,IAAW,EAAe,EAAI,mBAAmB;CACvD,OAAO;EACL,SAAS,EAAe,EAAI,OAAO;EACnC;EACA;EACA,aAAa,IAAW;CAC1B;AACF"}
@@ -9,11 +9,12 @@ import { QuoteCloseType, QuoteHistoryRow } from './types.js';
9
9
  export type GetQuoteHistoryParameters = Compute<ChainIdParameter & {
10
10
  /**
11
11
  * The accounts whose history to read — a SubAccount and/or its Virtual
12
- * Accounts. Pass every account that may own the relevant quotes. Required; an
13
- * empty array reads nothing. All accounts in one call must share the
14
- * `isolationType` below (they select the same filter field).
12
+ * Accounts. Pass every account that may own the relevant quotes. Omit to read
13
+ * every account's history; an empty array reads nothing. All accounts in one
14
+ * call must share the `isolationType` below (they select the same filter
15
+ * field).
15
16
  */
16
- subAccounts: readonly Address[];
17
+ subAccounts?: readonly Address[];
17
18
  /**
18
19
  * The subaccount's isolation type, which picks the subgraph filter field:
19
20
  * `CUSTOM` (cross-margin) filters by `partyA` because those quotes carry no
@@ -21,6 +22,13 @@ export type GetQuoteHistoryParameters = Compute<ChainIdParameter & {
21
22
  * quote's `subAccount`. Omit for VA-isolation reads.
22
23
  */
23
24
  isolationType?: SubAccountIsolationType;
25
+ /**
26
+ * The deployment's diamond address (the subgraph's `source`). Omit to read
27
+ * every deployment the subgraph indexes.
28
+ */
29
+ source?: Address;
30
+ /** Market ids (`symbolId`) to read. Omit for every market; an empty array reads nothing. */
31
+ marketIds?: readonly number[];
24
32
  /** Close-type filter. @default QuoteCloseType.All */
25
33
  closeType?: QuoteCloseType;
26
34
  /** Page size. @default 50 */
@@ -45,11 +53,13 @@ export interface GetQuoteHistoryReturnType {
45
53
  *
46
54
  * Each row is one terminal event with its frozen `metadata` snapshot overlaid, so
47
55
  * a quote closed across multiple partial closes yields multiple, individually
48
- * accurate rows (see {@link "toQuoteHistoryRow"}). Filtering by close type, time
49
- * range, and pagination all happen server-side.
56
+ * accurate rows (see {@link "toQuoteHistoryRow"}). Filtering by account,
57
+ * deployment, market, close type, time range, and pagination all happen
58
+ * server-side. Account, deployment and market filters are optional and applied
59
+ * only when passed.
50
60
  *
51
61
  * @param config - The SDK config.
52
- * @param parameters - Accounts, optional close-type filter, pagination, time range, sort, chain id.
62
+ * @param parameters - Optional accounts, deployment, markets, close type, pagination, time range, sort, chain id.
53
63
  * @returns The history rows.
54
64
  * @throws {SymmError} when the chain is unsupported or has no analytics subgraph.
55
65
  * @throws {SymmApiError} when the subgraph request fails.
@@ -58,6 +68,7 @@ export interface GetQuoteHistoryReturnType {
58
68
  * ```ts
59
69
  * const { rows } = await getQuoteHistory(config, {
60
70
  * subAccounts: ["0xsub…"],
71
+ * source: "0xdiamond…",
61
72
  * closeType: QuoteCloseType.Liquidated,
62
73
  * first: 10,
63
74
  * });
@@ -1 +1 @@
1
- {"version":3,"file":"get-quote-history.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/get-quote-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAMrF,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAqB/D;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,gBAAgB,GAAG;IACjB;;;;;OAKG;IACH,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;IAChC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,qDAAqD;IACrD,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACjC,CACF,CAAC;AAEF,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC,oFAAoF;IACpF,IAAI,EAAE,eAAe,EAAE,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,yBAAyB,CAAC,CA8BpC"}
1
+ {"version":3,"file":"get-quote-history.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/get-quote-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAOrF,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAyB/D;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,gBAAgB,GAAG;IACjB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACjC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,qDAAqD;IACrD,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACjC,CACF,CAAC;AAEF,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC,oFAAoF;IACpF,IAAI,EAAE,eAAe,EAAE,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,yBAAyB,CAAC,CA8BpC"}
@@ -1,32 +1,42 @@
1
1
  import { SubAccountIsolationType as e } from "../../symmio-contracts/account-layer/types.js";
2
2
  import { querySubgraph as t } from "../../symmio-subgraph/query-subgraph/query-subgraph.js";
3
- import { QuoteCloseType as n } from "./types.js";
4
- import { closeTypeToEventTypes as r } from "./close-type.js";
5
- import { QuoteEventsForHistoryDocument as i } from "./query-document.js";
6
- import { toQuoteHistoryRow as a } from "./to-history-row.js";
3
+ import { compactWhere as n, hasEmptyListFilter as r, lowercaseList as i, stringList as a } from "../../symmio-subgraph/subgraph-filters.js";
4
+ import { QuoteCloseType as o } from "./types.js";
5
+ import { closeTypeToEventTypes as s } from "./close-type.js";
6
+ import { QuoteEventsForHistoryDocument as c } from "./query-document.js";
7
+ import { toQuoteHistoryRow as l } from "./to-history-row.js";
7
8
  //#region src/quotes/get-quote-history/get-quote-history.ts
8
- function o(t) {
9
- let n = i.toString();
10
- return t === e.CUSTOM ? n.replace("subAccount_in", "partyA_in") : n;
9
+ function u(t) {
10
+ let r = i(t.subAccounts), o = t.isolationType === e.CUSTOM;
11
+ return n({
12
+ subAccount_in: o ? void 0 : r,
13
+ partyA_in: o ? r : void 0,
14
+ source: t.source?.toLowerCase(),
15
+ symbolId_in: a(t.marketIds)
16
+ });
11
17
  }
12
- var s = 50, c = 2e9;
13
- async function l(e, i) {
14
- let { chainId: l, subAccounts: u, isolationType: d, closeType: f = n.All, first: p = s, skip: m = 0, startTime: h = 0, endTime: g = c, orderDirection: _ = "desc" } = i;
15
- return u.length === 0 ? { rows: [] } : { rows: (await t(e, {
16
- chainId: l,
17
- document: o(d),
18
+ var d = 50, f = 2e9;
19
+ async function p(e, i) {
20
+ let { chainId: a, subAccounts: p, marketIds: m, closeType: h = o.All, first: g = d, skip: _ = 0, startTime: v = 0, endTime: y = f, orderDirection: b = "desc" } = i;
21
+ if (r(p, m)) return { rows: [] };
22
+ let x = u(i);
23
+ return { rows: (await t(e, {
24
+ chainId: a,
25
+ document: c,
18
26
  variables: {
19
- typeIn: r[f],
20
- subAccounts: u.map((e) => e.toLowerCase()),
21
- first: p,
22
- skip: m,
23
- orderDirection: _,
24
- startDate: h.toString(),
25
- endDate: g.toString()
27
+ where: n({
28
+ type_in: s[h],
29
+ timestamp_gte: v.toString(),
30
+ timestamp_lte: y.toString(),
31
+ quote_: Object.keys(x).length > 0 ? x : void 0
32
+ }),
33
+ first: g,
34
+ skip: _,
35
+ orderDirection: b
26
36
  }
27
- })).quoteEvents.map(a) };
37
+ })).quoteEvents.map(l) };
28
38
  }
29
39
  //#endregion
30
- export { l as getQuoteHistory };
40
+ export { p as getQuoteHistory };
31
41
 
32
42
  //# sourceMappingURL=get-quote-history.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-quote-history.js","names":[],"sources":["../../../src/quotes/get-quote-history/get-quote-history.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { SubAccountIsolationType } from \"../../symmio-contracts/account-layer/types\";\nimport { querySubgraph } from \"../../symmio-subgraph/query-subgraph\";\nimport type { QuoteEventsForHistoryQuery } from \"../../symmio-subgraph/types/generated/analytics/graphql\";\nimport { closeTypeToEventTypes } from \"./close-type\";\nimport { QuoteEventsForHistoryDocument } from \"./query-document\";\nimport { toQuoteHistoryRow } from \"./to-history-row\";\nimport { QuoteCloseType, type QuoteHistoryRow } from \"./types\";\n\n/**\n * The history query to run for a subaccount's isolation type. Cross-margin\n * (`CUSTOM`) quotes carry **no** `subAccount` on the subgraph, so they must be\n * filtered by `partyA` (which equals the subaccount address); VA isolation\n * (`MARKET` / `MARKET_DIRECTION`) filters by the quote's `subAccount`. The `partyA`\n * variant is derived from the canonical document by swapping its single filter\n * field, so both share one selection and one result type (the `$subAccounts`\n * variable simply feeds whichever field is active).\n */\nfunction historyDocumentFor(isolationType: SubAccountIsolationType | undefined): string {\n const document = QuoteEventsForHistoryDocument.toString();\n return isolationType === SubAccountIsolationType.CUSTOM ? document.replace(\"subAccount_in\", \"partyA_in\") : document;\n}\n\n/** Default page size when `first` is omitted. */\nconst DEFAULT_PAGE_SIZE = 50;\n/** Default upper time bound (far-future unix seconds) when `endTime` is omitted. */\nconst DEFAULT_END_TIME = 2_000_000_000;\n\n/**\n * Parameters for {@link getQuoteHistory}.\n */\nexport type GetQuoteHistoryParameters = Compute<\n ChainIdParameter & {\n /**\n * The accounts whose history to read — a SubAccount and/or its Virtual\n * Accounts. Pass every account that may own the relevant quotes. Required; an\n * empty array reads nothing. All accounts in one call must share the\n * `isolationType` below (they select the same filter field).\n */\n subAccounts: readonly Address[];\n /**\n * The subaccount's isolation type, which picks the subgraph filter field:\n * `CUSTOM` (cross-margin) filters by `partyA` because those quotes carry no\n * `subAccount`; `MARKET` / `MARKET_DIRECTION` (and the default) filter by the\n * quote's `subAccount`. Omit for VA-isolation reads.\n */\n isolationType?: SubAccountIsolationType;\n /** Close-type filter. @default QuoteCloseType.All */\n closeType?: QuoteCloseType;\n /** Page size. @default 50 */\n first?: number;\n /** Page offset. @default 0 */\n skip?: number;\n /** Lower bound on the event timestamp (unix seconds). @default 0 */\n startTime?: number;\n /** Upper bound on the event timestamp (unix seconds). @default 2_000_000_000 */\n endTime?: number;\n /** Sort direction on the event timestamp. @default \"desc\" */\n orderDirection?: \"asc\" | \"desc\";\n }\n>;\n\n/** Return type of {@link getQuoteHistory}. */\nexport interface GetQuoteHistoryReturnType {\n /** The decoded, snapshot-applied history rows (one per close/liquidation event). */\n rows: QuoteHistoryRow[];\n}\n\n/**\n * Read a subaccount's closed/liquidated quote history from the analytics\n * subgraph's immutable `quoteEvents` collection.\n *\n * Each row is one terminal event with its frozen `metadata` snapshot overlaid, so\n * a quote closed across multiple partial closes yields multiple, individually\n * accurate rows (see {@link \"toQuoteHistoryRow\"}). Filtering by close type, time\n * range, and pagination all happen server-side.\n *\n * @param config - The SDK config.\n * @param parameters - Accounts, optional close-type filter, pagination, time range, sort, chain id.\n * @returns The history rows.\n * @throws {SymmError} when the chain is unsupported or has no analytics subgraph.\n * @throws {SymmApiError} when the subgraph request fails.\n *\n * @example\n * ```ts\n * const { rows } = await getQuoteHistory(config, {\n * subAccounts: [\"0xsub…\"],\n * closeType: QuoteCloseType.Liquidated,\n * first: 10,\n * });\n * ```\n */\nexport async function getQuoteHistory(\n config: Config,\n parameters: GetQuoteHistoryParameters,\n): Promise<GetQuoteHistoryReturnType> {\n const {\n chainId,\n subAccounts,\n isolationType,\n closeType = QuoteCloseType.All,\n first = DEFAULT_PAGE_SIZE,\n skip = 0,\n startTime = 0,\n endTime = DEFAULT_END_TIME,\n orderDirection = \"desc\",\n } = parameters;\n\n if (subAccounts.length === 0) return { rows: [] };\n\n const data = await querySubgraph<QuoteEventsForHistoryQuery>(config, {\n chainId,\n document: historyDocumentFor(isolationType),\n variables: {\n typeIn: closeTypeToEventTypes[closeType] as string[],\n subAccounts: subAccounts.map((account) => account.toLowerCase()),\n first,\n skip,\n orderDirection,\n startDate: startTime.toString(),\n endDate: endTime.toString(),\n },\n });\n\n return { rows: data.quoteEvents.map(toQuoteHistoryRow) };\n}\n"],"mappings":";;;;;;;AAoBA,SAAS,EAAmB,GAA4D;CACtF,IAAM,IAAW,EAA8B,SAAS;CACxD,OAAO,MAAkB,EAAwB,SAAS,EAAS,QAAQ,iBAAiB,WAAW,IAAI;AAC7G;AAGA,IAAM,IAAoB,IAEpB,IAAmB;AAkEzB,eAAsB,EACpB,GACA,GACoC;CACpC,IAAM,EACJ,YACA,gBACA,kBACA,eAAY,EAAe,KAC3B,WAAQ,GACR,UAAO,GACP,eAAY,GACZ,aAAU,GACV,oBAAiB,WACf;CAkBJ,OAhBI,EAAY,WAAW,IAAU,EAAE,MAAM,CAAC,EAAE,IAgBzC,EAAE,OAAM,MAdI,EAA0C,GAAQ;EACnE;EACA,UAAU,EAAmB,CAAa;EAC1C,WAAW;GACT,QAAQ,EAAsB;GAC9B,aAAa,EAAY,KAAK,MAAY,EAAQ,YAAY,CAAC;GAC/D;GACA;GACA;GACA,WAAW,EAAU,SAAS;GAC9B,SAAS,EAAQ,SAAS;EAC5B;CACF,CAAC,GAEmB,YAAY,IAAI,CAAiB,EAAE;AACzD"}
1
+ {"version":3,"file":"get-quote-history.js","names":[],"sources":["../../../src/quotes/get-quote-history/get-quote-history.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { SubAccountIsolationType } from \"../../symmio-contracts/account-layer/types\";\nimport { querySubgraph } from \"../../symmio-subgraph/query-subgraph\";\nimport { compactWhere, hasEmptyListFilter, lowercaseList, stringList } from \"../../symmio-subgraph/subgraph-filters\";\nimport type { Quote_Filter, QuoteEvent_Filter } from \"../../symmio-subgraph/types/generated/analytics/graphql\";\nimport { closeTypeToEventTypes } from \"./close-type\";\nimport { QuoteEventsForHistoryDocument } from \"./query-document\";\nimport { toQuoteHistoryRow } from \"./to-history-row\";\nimport { QuoteCloseType, type QuoteHistoryRow } from \"./types\";\n\n/**\n * The `quote_` filter for the requested accounts, deployment and markets.\n * Cross-margin (`CUSTOM`) quotes carry **no** `subAccount` on the subgraph, so\n * their accounts filter `partyA` (which equals the subaccount address); VA\n * isolation (`MARKET` / `MARKET_DIRECTION`) filters the quote's `subAccount`.\n * Each filter is present only when the caller passed it.\n */\nfunction quoteFilterFor(parameters: GetQuoteHistoryParameters): Quote_Filter {\n const accounts = lowercaseList(parameters.subAccounts);\n const isCrossMargin = parameters.isolationType === SubAccountIsolationType.CUSTOM;\n return compactWhere<Quote_Filter>({\n subAccount_in: isCrossMargin ? undefined : accounts,\n partyA_in: isCrossMargin ? accounts : undefined,\n source: parameters.source?.toLowerCase(),\n symbolId_in: stringList(parameters.marketIds),\n });\n}\n\n/** Default page size when `first` is omitted. */\nconst DEFAULT_PAGE_SIZE = 50;\n/** Default upper time bound (far-future unix seconds) when `endTime` is omitted. */\nconst DEFAULT_END_TIME = 2_000_000_000;\n\n/**\n * Parameters for {@link getQuoteHistory}.\n */\nexport type GetQuoteHistoryParameters = Compute<\n ChainIdParameter & {\n /**\n * The accounts whose history to read — a SubAccount and/or its Virtual\n * Accounts. Pass every account that may own the relevant quotes. Omit to read\n * every account's history; an empty array reads nothing. All accounts in one\n * call must share the `isolationType` below (they select the same filter\n * field).\n */\n subAccounts?: readonly Address[];\n /**\n * The subaccount's isolation type, which picks the subgraph filter field:\n * `CUSTOM` (cross-margin) filters by `partyA` because those quotes carry no\n * `subAccount`; `MARKET` / `MARKET_DIRECTION` (and the default) filter by the\n * quote's `subAccount`. Omit for VA-isolation reads.\n */\n isolationType?: SubAccountIsolationType;\n /**\n * The deployment's diamond address (the subgraph's `source`). Omit to read\n * every deployment the subgraph indexes.\n */\n source?: Address;\n /** Market ids (`symbolId`) to read. Omit for every market; an empty array reads nothing. */\n marketIds?: readonly number[];\n /** Close-type filter. @default QuoteCloseType.All */\n closeType?: QuoteCloseType;\n /** Page size. @default 50 */\n first?: number;\n /** Page offset. @default 0 */\n skip?: number;\n /** Lower bound on the event timestamp (unix seconds). @default 0 */\n startTime?: number;\n /** Upper bound on the event timestamp (unix seconds). @default 2_000_000_000 */\n endTime?: number;\n /** Sort direction on the event timestamp. @default \"desc\" */\n orderDirection?: \"asc\" | \"desc\";\n }\n>;\n\n/** Return type of {@link getQuoteHistory}. */\nexport interface GetQuoteHistoryReturnType {\n /** The decoded, snapshot-applied history rows (one per close/liquidation event). */\n rows: QuoteHistoryRow[];\n}\n\n/**\n * Read a subaccount's closed/liquidated quote history from the analytics\n * subgraph's immutable `quoteEvents` collection.\n *\n * Each row is one terminal event with its frozen `metadata` snapshot overlaid, so\n * a quote closed across multiple partial closes yields multiple, individually\n * accurate rows (see {@link \"toQuoteHistoryRow\"}). Filtering by account,\n * deployment, market, close type, time range, and pagination all happen\n * server-side. Account, deployment and market filters are optional and applied\n * only when passed.\n *\n * @param config - The SDK config.\n * @param parameters - Optional accounts, deployment, markets, close type, pagination, time range, sort, chain id.\n * @returns The history rows.\n * @throws {SymmError} when the chain is unsupported or has no analytics subgraph.\n * @throws {SymmApiError} when the subgraph request fails.\n *\n * @example\n * ```ts\n * const { rows } = await getQuoteHistory(config, {\n * subAccounts: [\"0xsub…\"],\n * source: \"0xdiamond…\",\n * closeType: QuoteCloseType.Liquidated,\n * first: 10,\n * });\n * ```\n */\nexport async function getQuoteHistory(\n config: Config,\n parameters: GetQuoteHistoryParameters,\n): Promise<GetQuoteHistoryReturnType> {\n const {\n chainId,\n subAccounts,\n marketIds,\n closeType = QuoteCloseType.All,\n first = DEFAULT_PAGE_SIZE,\n skip = 0,\n startTime = 0,\n endTime = DEFAULT_END_TIME,\n orderDirection = \"desc\",\n } = parameters;\n\n if (hasEmptyListFilter(subAccounts, marketIds)) return { rows: [] };\n\n const quoteFilter = quoteFilterFor(parameters);\n const where = compactWhere<QuoteEvent_Filter>({\n type_in: closeTypeToEventTypes[closeType] as string[],\n timestamp_gte: startTime.toString(),\n timestamp_lte: endTime.toString(),\n quote_: Object.keys(quoteFilter).length > 0 ? quoteFilter : undefined,\n });\n\n const data = await querySubgraph(config, {\n chainId,\n document: QuoteEventsForHistoryDocument,\n variables: { where, first, skip, orderDirection },\n });\n\n return { rows: data.quoteEvents.map(toQuoteHistoryRow) };\n}\n"],"mappings":";;;;;;;;AAmBA,SAAS,EAAe,GAAqD;CAC3E,IAAM,IAAW,EAAc,EAAW,WAAW,GAC/C,IAAgB,EAAW,kBAAkB,EAAwB;CAC3E,OAAO,EAA2B;EAChC,eAAe,IAAgB,KAAA,IAAY;EAC3C,WAAW,IAAgB,IAAW,KAAA;EACtC,QAAQ,EAAW,QAAQ,YAAY;EACvC,aAAa,EAAW,EAAW,SAAS;CAC9C,CAAC;AACH;AAGA,IAAM,IAAoB,IAEpB,IAAmB;AA6EzB,eAAsB,EACpB,GACA,GACoC;CACpC,IAAM,EACJ,YACA,gBACA,cACA,eAAY,EAAe,KAC3B,WAAQ,GACR,UAAO,GACP,eAAY,GACZ,aAAU,GACV,oBAAiB,WACf;CAEJ,IAAI,EAAmB,GAAa,CAAS,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE;CAElE,IAAM,IAAc,EAAe,CAAU;CAc7C,OAAO,EAAE,OAAM,MANI,EAAc,GAAQ;EACvC;EACA,UAAU;EACV,WAAW;GAAE,OAVD,EAAgC;IAC5C,SAAS,EAAsB;IAC/B,eAAe,EAAU,SAAS;IAClC,eAAe,EAAQ,SAAS;IAChC,QAAQ,OAAO,KAAK,CAAW,EAAE,SAAS,IAAI,IAAc,KAAA;GAC9D,CAKe;GAAO;GAAO;GAAM;EAAe;CAClD,CAAC,GAEmB,YAAY,IAAI,CAAiB,EAAE;AACzD"}
@@ -4,17 +4,22 @@
4
4
  * snapshot plus the (mutable) `quote` it belongs to — the snapshot is what makes
5
5
  * multiple partial-close rows of the same quote distinct.
6
6
  *
7
- * Filtered server-side by event `type_in` (close-type), `timestamp` range, and
8
- * the quote's `subAccount_in`. Sorted by event `timestamp` (the row's close
9
- * time). The document compiles to a typed query string via graphql-codegen.
7
+ * Every filter travels in one `$where` object that the action builds, so a
8
+ * filter the caller omits is absent rather than sent as `null` (graph-node
9
+ * rejects a null `_in` filter). The action always sets the event `type_in`
10
+ * (close-type) and `timestamp` range; account (`subAccount_in` / `partyA_in`),
11
+ * deployment (`source`) and market (`symbolId_in`) filters go on `quote_` only
12
+ * when passed. Sorted by event `timestamp` (the row's close time).
13
+ *
14
+ * Alongside the quote's own fields it reads two relations: the `SEND_QUOTE`
15
+ * event's transaction (the open transaction), and the raw `metadata` of the
16
+ * quote's `OPEN_POSITION` events, left undecoded for the consumer. The document
17
+ * compiles to a typed query string via graphql-codegen.
10
18
  */
11
19
  export declare const QuoteEventsForHistoryDocument: import('../../symmio-subgraph/types/generated/analytics/graphql.js').TypedDocumentString<import('../../symmio-subgraph/types/generated/analytics/graphql.js').QuoteEventsForHistoryQuery, {
12
- typeIn: Array<string> | string;
13
- subAccounts: Array<string> | string;
20
+ where: import('../../symmio-subgraph/types/generated/analytics/graphql.js').QuoteEvent_Filter;
14
21
  first: number;
15
22
  skip: number;
16
23
  orderDirection: import('../../symmio-subgraph/types/generated/analytics/graphql.js').OrderDirection;
17
- startDate: string;
18
- endDate: string;
19
24
  }>;
20
25
  //# sourceMappingURL=query-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-document.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/query-document.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;EAqDxC,CAAC"}
1
+ {"version":3,"file":"query-document.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/query-document.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,6BAA6B;;;;;EAuDxC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { graphql as e } from "../../symmio-subgraph/types/generated/analytics/gql.js";
2
2
  //#region src/quotes/get-quote-history/query-document.ts
3
- var t = e("\n query QuoteEventsForHistory(\n $typeIn: [String!]!\n $subAccounts: [String!]!\n $first: Int!\n $skip: Int!\n $orderDirection: OrderDirection!\n $startDate: BigInt!\n $endDate: BigInt!\n ) {\n quoteEvents(\n first: $first\n skip: $skip\n orderBy: timestamp\n orderDirection: $orderDirection\n where: {\n type_in: $typeIn\n timestamp_gte: $startDate\n timestamp_lte: $endDate\n quote_: { subAccount_in: $subAccounts }\n }\n ) {\n id\n type\n metadata\n timestamp\n quoteId\n blockNumber\n transaction\n quote {\n quoteId\n quoteStatus\n positionType\n orderTypeOpen\n symbol\n symbolId\n partyA\n partyB\n subAccount {\n id\n }\n quantity\n openedPrice\n requestedOpenPrice\n averageClosedPrice\n closePrice\n closedAmount\n quantityToClose\n liquidateAmount\n liquidatePrice\n }\n }\n }\n");
3
+ var t = e("\n query QuoteEventsForHistory($where: QuoteEvent_filter!, $first: Int!, $skip: Int!, $orderDirection: OrderDirection!) {\n quoteEvents(first: $first, skip: $skip, orderBy: timestamp, orderDirection: $orderDirection, where: $where) {\n id\n type\n metadata\n timestamp\n quoteId\n blockNumber\n transaction\n source\n quote {\n quoteId\n quoteStatus\n positionType\n orderTypeOpen\n symbol\n symbolId\n partyA\n partyB\n subAccount {\n id\n owner\n }\n quantity\n openedPrice\n initialOpenedPrice\n requestedOpenPrice\n marketPrice\n averageClosedPrice\n closePrice\n closedPrice\n closedAmount\n quantityToClose\n liquidateAmount\n liquidatePrice\n tradingFee\n closeFee\n leverage\n cva\n lf\n initialCva\n initialLf\n initialPartyAmm\n timestampSendQuote\n timestampOpenPosition\n sendQuoteEvents: quoteEvents(where: { type: \"SEND_QUOTE\" }, first: 1) {\n transaction\n }\n openPositionEvents: quoteEvents(where: { type: \"OPEN_POSITION\" }, first: 1000) {\n metadata\n }\n }\n }\n }\n");
4
4
  //#endregion
5
5
  export { t as QuoteEventsForHistoryDocument };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"query-document.js","names":[],"sources":["../../../src/quotes/get-quote-history/query-document.ts"],"sourcesContent":["import { graphql } from \"../../symmio-subgraph/types/generated/analytics\";\n\n/**\n * History query over the immutable `quoteEvents` collection (SYMMIO subgraphs\n * v0.8.6+). Each row is one close/liquidation event with a frozen `metadata`\n * snapshot plus the (mutable) `quote` it belongs to — the snapshot is what makes\n * multiple partial-close rows of the same quote distinct.\n *\n * Filtered server-side by event `type_in` (close-type), `timestamp` range, and\n * the quote's `subAccount_in`. Sorted by event `timestamp` (the row's close\n * time). The document compiles to a typed query string via graphql-codegen.\n */\nexport const QuoteEventsForHistoryDocument = graphql(`\n query QuoteEventsForHistory(\n $typeIn: [String!]!\n $subAccounts: [String!]!\n $first: Int!\n $skip: Int!\n $orderDirection: OrderDirection!\n $startDate: BigInt!\n $endDate: BigInt!\n ) {\n quoteEvents(\n first: $first\n skip: $skip\n orderBy: timestamp\n orderDirection: $orderDirection\n where: {\n type_in: $typeIn\n timestamp_gte: $startDate\n timestamp_lte: $endDate\n quote_: { subAccount_in: $subAccounts }\n }\n ) {\n id\n type\n metadata\n timestamp\n quoteId\n blockNumber\n transaction\n quote {\n quoteId\n quoteStatus\n positionType\n orderTypeOpen\n symbol\n symbolId\n partyA\n partyB\n subAccount {\n id\n }\n quantity\n openedPrice\n requestedOpenPrice\n averageClosedPrice\n closePrice\n closedAmount\n quantityToClose\n liquidateAmount\n liquidatePrice\n }\n }\n }\n`);\n"],"mappings":";;AAYA,IAAa,IAAgC,EAAQ,8iCAqDpD"}
1
+ {"version":3,"file":"query-document.js","names":[],"sources":["../../../src/quotes/get-quote-history/query-document.ts"],"sourcesContent":["import { graphql } from \"../../symmio-subgraph/types/generated/analytics\";\n\n/**\n * History query over the immutable `quoteEvents` collection (SYMMIO subgraphs\n * v0.8.6+). Each row is one close/liquidation event with a frozen `metadata`\n * snapshot plus the (mutable) `quote` it belongs to — the snapshot is what makes\n * multiple partial-close rows of the same quote distinct.\n *\n * Every filter travels in one `$where` object that the action builds, so a\n * filter the caller omits is absent rather than sent as `null` (graph-node\n * rejects a null `_in` filter). The action always sets the event `type_in`\n * (close-type) and `timestamp` range; account (`subAccount_in` / `partyA_in`),\n * deployment (`source`) and market (`symbolId_in`) filters go on `quote_` only\n * when passed. Sorted by event `timestamp` (the row's close time).\n *\n * Alongside the quote's own fields it reads two relations: the `SEND_QUOTE`\n * event's transaction (the open transaction), and the raw `metadata` of the\n * quote's `OPEN_POSITION` events, left undecoded for the consumer. The document\n * compiles to a typed query string via graphql-codegen.\n */\nexport const QuoteEventsForHistoryDocument = graphql(`\n query QuoteEventsForHistory($where: QuoteEvent_filter!, $first: Int!, $skip: Int!, $orderDirection: OrderDirection!) {\n quoteEvents(first: $first, skip: $skip, orderBy: timestamp, orderDirection: $orderDirection, where: $where) {\n id\n type\n metadata\n timestamp\n quoteId\n blockNumber\n transaction\n source\n quote {\n quoteId\n quoteStatus\n positionType\n orderTypeOpen\n symbol\n symbolId\n partyA\n partyB\n subAccount {\n id\n owner\n }\n quantity\n openedPrice\n initialOpenedPrice\n requestedOpenPrice\n marketPrice\n averageClosedPrice\n closePrice\n closedPrice\n closedAmount\n quantityToClose\n liquidateAmount\n liquidatePrice\n tradingFee\n closeFee\n leverage\n cva\n lf\n initialCva\n initialLf\n initialPartyAmm\n timestampSendQuote\n timestampOpenPosition\n sendQuoteEvents: quoteEvents(where: { type: \"SEND_QUOTE\" }, first: 1) {\n transaction\n }\n openPositionEvents: quoteEvents(where: { type: \"OPEN_POSITION\" }, first: 1000) {\n metadata\n }\n }\n }\n }\n`);\n"],"mappings":";;AAoBA,IAAa,IAAgC,EAAQ,yzCAuDpD"}
@@ -22,8 +22,9 @@ export type GetQuoteHistoryOptions = Compute<GetQuoteHistoryParameters & QueryPa
22
22
  export type GetQuoteHistoryQueryOptions = SymmioQueryOptions<GetQuoteHistoryData, Error, GetQuoteHistoryData, GetQuoteHistoryQueryKey>;
23
23
  /**
24
24
  * Build TanStack Query options for {@link getQuoteHistory}. Pass
25
- * `query.refetchInterval` to poll; the query is disabled until at least one
26
- * `subAccount` is supplied.
25
+ * `query.refetchInterval` to poll. The query is disabled while `subAccounts` or
26
+ * `marketIds` is an empty array (it would match nothing); omitting either reads
27
+ * without that filter.
27
28
  *
28
29
  * @param config - The SDK config.
29
30
  * @param options - Query parameters and TanStack overrides.
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/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;AAEtH,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,yBAAyB,GAAG,kBAAkB,CAAC,yDAEvG;AAED,kEAAkE;AAClE,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,yBAAyB,GAAG,cAAc,CAAC,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,CAAC,CACrH,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GAAG,kBAAkB,CAC1D,mBAAmB,EACnB,KAAK,EACL,mBAAmB,EACnB,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,sBAAsB,GAC9B,2BAA2B,CAqB7B"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/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;AAGnF,OAAO,EAAmB,KAAK,yBAAyB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEtH,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,yBAAyB,GAAG,kBAAkB,CAAC,yDAEvG;AAED,kEAAkE;AAClE,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,yBAAyB,GAAG,cAAc,CAAC,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,CAAC,CACrH,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GAAG,kBAAkB,CAC1D,mBAAmB,EACnB,KAAK,EACL,mBAAmB,EACnB,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,sBAAsB,GAC9B,2BAA2B,CAuB7B"}
@@ -1,31 +1,34 @@
1
1
  import { filterQueryOptions as e } from "../../shared/utils/query.js";
2
- import { getQuoteHistory as t } from "./get-quote-history.js";
2
+ import { hasEmptyListFilter as t } from "../../symmio-subgraph/subgraph-filters.js";
3
+ import { getQuoteHistory as n } from "./get-quote-history.js";
3
4
  //#region src/quotes/get-quote-history/query.ts
4
- function n(t) {
5
+ function r(t) {
5
6
  return ["getQuoteHistory", e(t)];
6
7
  }
7
- function r(e, r) {
8
+ function i(e, i) {
8
9
  return {
9
- ...r.query,
10
- queryKey: n({
11
- ...r,
12
- configKey: e.getChainConfigKey(r.chainId)
10
+ ...i.query,
11
+ queryKey: r({
12
+ ...i,
13
+ configKey: e.getChainConfigKey(i.chainId)
13
14
  }),
14
- enabled: (r.query?.enabled ?? !0) && r.subAccounts.length > 0,
15
- queryFn: () => t(e, {
16
- chainId: r.chainId,
17
- subAccounts: r.subAccounts,
18
- isolationType: r.isolationType,
19
- closeType: r.closeType,
20
- first: r.first,
21
- skip: r.skip,
22
- startTime: r.startTime,
23
- endTime: r.endTime,
24
- orderDirection: r.orderDirection
15
+ enabled: (i.query?.enabled ?? !0) && !t(i.subAccounts, i.marketIds),
16
+ queryFn: () => n(e, {
17
+ chainId: i.chainId,
18
+ subAccounts: i.subAccounts,
19
+ isolationType: i.isolationType,
20
+ source: i.source,
21
+ marketIds: i.marketIds,
22
+ closeType: i.closeType,
23
+ first: i.first,
24
+ skip: i.skip,
25
+ startTime: i.startTime,
26
+ endTime: i.endTime,
27
+ orderDirection: i.orderDirection
25
28
  })
26
29
  };
27
30
  }
28
31
  //#endregion
29
- export { n as getQuoteHistoryQueryKey, r as getQuoteHistoryQueryOptions };
32
+ export { r as getQuoteHistoryQueryKey, i as getQuoteHistoryQueryOptions };
30
33
 
31
34
  //# sourceMappingURL=query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","names":[],"sources":["../../../src/quotes/get-quote-history/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 { getQuoteHistory, type GetQuoteHistoryParameters, type GetQuoteHistoryReturnType } from \"./get-quote-history\";\n\n/** Data resolved by the {@link getQuoteHistoryQueryOptions} query. */\nexport type GetQuoteHistoryData = GetQuoteHistoryReturnType;\n\n/**\n * Build the TanStack Query key for {@link getQuoteHistoryQueryOptions}.\n *\n * @param options - Query parameters (accounts, close type, paging, time range, chain id, config key).\n * @returns A stable, hashable query key.\n */\nexport function getQuoteHistoryQueryKey(options: Compute<GetQuoteHistoryParameters & ConfigKeyParameter>) {\n return [\"getQuoteHistory\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getQuoteHistoryQueryKey}. */\nexport type GetQuoteHistoryQueryKey = ReturnType<typeof getQuoteHistoryQueryKey>;\n\n/**\n * Options accepted by {@link getQuoteHistoryQueryOptions}: the action's\n * parameters plus TanStack overrides.\n */\nexport type GetQuoteHistoryOptions = Compute<\n GetQuoteHistoryParameters & QueryParameter<GetQuoteHistoryData, Error, GetQuoteHistoryData, GetQuoteHistoryQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getQuoteHistoryQueryOptions}. */\nexport type GetQuoteHistoryQueryOptions = SymmioQueryOptions<\n GetQuoteHistoryData,\n Error,\n GetQuoteHistoryData,\n GetQuoteHistoryQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getQuoteHistory}. Pass\n * `query.refetchInterval` to poll; the query is disabled until at least one\n * `subAccount` is supplied.\n *\n * @param config - The SDK config.\n * @param options - Query parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(\n * getQuoteHistoryQueryOptions(config, {\n * subAccounts: [\"0xsub…\"],\n * query: { refetchInterval: 20_000 },\n * }),\n * );\n * ```\n */\nexport function getQuoteHistoryQueryOptions(\n config: Config,\n options: GetQuoteHistoryOptions,\n): GetQuoteHistoryQueryOptions {\n return {\n ...options.query,\n queryKey: getQuoteHistoryQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: (options.query?.enabled ?? true) && options.subAccounts.length > 0,\n queryFn: () =>\n getQuoteHistory(config, {\n chainId: options.chainId,\n subAccounts: options.subAccounts,\n isolationType: options.isolationType,\n closeType: options.closeType,\n first: options.first,\n skip: options.skip,\n startTime: options.startTime,\n endTime: options.endTime,\n orderDirection: options.orderDirection,\n }),\n };\n}\n"],"mappings":";;;AAeA,SAAgB,EAAwB,GAAkE;CACxG,OAAO,CAAC,mBAAmB,EAAmB,CAAO,CAAC;AACxD;AAwCA,SAAgB,EACd,GACA,GAC6B;CAC7B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAwB;GAChC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,UAAU,EAAQ,OAAO,WAAW,OAAS,EAAQ,YAAY,SAAS;EAC1E,eACE,EAAgB,GAAQ;GACtB,SAAS,EAAQ;GACjB,aAAa,EAAQ;GACrB,eAAe,EAAQ;GACvB,WAAW,EAAQ;GACnB,OAAO,EAAQ;GACf,MAAM,EAAQ;GACd,WAAW,EAAQ;GACnB,SAAS,EAAQ;GACjB,gBAAgB,EAAQ;EAC1B,CAAC;CACL;AACF"}
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/quotes/get-quote-history/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 { hasEmptyListFilter } from \"../../symmio-subgraph/subgraph-filters\";\nimport { getQuoteHistory, type GetQuoteHistoryParameters, type GetQuoteHistoryReturnType } from \"./get-quote-history\";\n\n/** Data resolved by the {@link getQuoteHistoryQueryOptions} query. */\nexport type GetQuoteHistoryData = GetQuoteHistoryReturnType;\n\n/**\n * Build the TanStack Query key for {@link getQuoteHistoryQueryOptions}.\n *\n * @param options - Query parameters (accounts, close type, paging, time range, chain id, config key).\n * @returns A stable, hashable query key.\n */\nexport function getQuoteHistoryQueryKey(options: Compute<GetQuoteHistoryParameters & ConfigKeyParameter>) {\n return [\"getQuoteHistory\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getQuoteHistoryQueryKey}. */\nexport type GetQuoteHistoryQueryKey = ReturnType<typeof getQuoteHistoryQueryKey>;\n\n/**\n * Options accepted by {@link getQuoteHistoryQueryOptions}: the action's\n * parameters plus TanStack overrides.\n */\nexport type GetQuoteHistoryOptions = Compute<\n GetQuoteHistoryParameters & QueryParameter<GetQuoteHistoryData, Error, GetQuoteHistoryData, GetQuoteHistoryQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getQuoteHistoryQueryOptions}. */\nexport type GetQuoteHistoryQueryOptions = SymmioQueryOptions<\n GetQuoteHistoryData,\n Error,\n GetQuoteHistoryData,\n GetQuoteHistoryQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getQuoteHistory}. Pass\n * `query.refetchInterval` to poll. The query is disabled while `subAccounts` or\n * `marketIds` is an empty array (it would match nothing); omitting either reads\n * without that filter.\n *\n * @param config - The SDK config.\n * @param options - Query parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(\n * getQuoteHistoryQueryOptions(config, {\n * subAccounts: [\"0xsub…\"],\n * query: { refetchInterval: 20_000 },\n * }),\n * );\n * ```\n */\nexport function getQuoteHistoryQueryOptions(\n config: Config,\n options: GetQuoteHistoryOptions,\n): GetQuoteHistoryQueryOptions {\n return {\n ...options.query,\n queryKey: getQuoteHistoryQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: (options.query?.enabled ?? true) && !hasEmptyListFilter(options.subAccounts, options.marketIds),\n queryFn: () =>\n getQuoteHistory(config, {\n chainId: options.chainId,\n subAccounts: options.subAccounts,\n isolationType: options.isolationType,\n source: options.source,\n marketIds: options.marketIds,\n closeType: options.closeType,\n first: options.first,\n skip: options.skip,\n startTime: options.startTime,\n endTime: options.endTime,\n orderDirection: options.orderDirection,\n }),\n };\n}\n"],"mappings":";;;;AAgBA,SAAgB,EAAwB,GAAkE;CACxG,OAAO,CAAC,mBAAmB,EAAmB,CAAO,CAAC;AACxD;AAyCA,SAAgB,EACd,GACA,GAC6B;CAC7B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAwB;GAChC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,UAAU,EAAQ,OAAO,WAAW,OAAS,CAAC,EAAmB,EAAQ,aAAa,EAAQ,SAAS;EACvG,eACE,EAAgB,GAAQ;GACtB,SAAS,EAAQ;GACjB,aAAa,EAAQ;GACrB,eAAe,EAAQ;GACvB,QAAQ,EAAQ;GAChB,WAAW,EAAQ;GACnB,WAAW,EAAQ;GACnB,OAAO,EAAQ;GACf,MAAM,EAAQ;GACd,WAAW,EAAQ;GACnB,SAAS,EAAQ;GACjB,gBAAgB,EAAQ;EAC1B,CAAC;CACL;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"to-history-row.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/to-history-row.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AAG1G,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpE,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAqCjF;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,eAAe,CAqDxE"}
1
+ {"version":3,"file":"to-history-row.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/to-history-row.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AAG1G,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpE,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAgCjF;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,eAAe,CAsExE"}