@symmio/trading-core 3.6.0 → 4.0.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 (84) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +248 -246
  4. package/dist/pools/markets/get-listing-markets.d.ts +2 -0
  5. package/dist/pools/markets/get-listing-markets.d.ts.map +1 -1
  6. package/dist/pools/markets/get-listing-markets.js +1 -0
  7. package/dist/pools/markets/get-listing-markets.js.map +1 -1
  8. package/dist/pools/markets/query.d.ts.map +1 -1
  9. package/dist/pools/markets/query.js +1 -0
  10. package/dist/pools/markets/query.js.map +1 -1
  11. package/dist/pools/markets/to-search-params.d.ts +1 -0
  12. package/dist/pools/markets/to-search-params.d.ts.map +1 -1
  13. package/dist/pools/markets/to-search-params.js +1 -1
  14. package/dist/pools/markets/to-search-params.js.map +1 -1
  15. package/dist/solvers/estimated-price/get-estimated-price.d.ts +2 -0
  16. package/dist/solvers/estimated-price/get-estimated-price.d.ts.map +1 -1
  17. package/dist/solvers/estimated-price/get-estimated-price.js +4 -1
  18. package/dist/solvers/estimated-price/get-estimated-price.js.map +1 -1
  19. package/dist/solvers/estimated-price/query.d.ts +6 -2
  20. package/dist/solvers/estimated-price/query.d.ts.map +1 -1
  21. package/dist/solvers/estimated-price/query.js +3 -2
  22. package/dist/solvers/estimated-price/query.js.map +1 -1
  23. package/dist/solvers/funding-info/adapters/enigma-funding-info.d.ts +4 -0
  24. package/dist/solvers/funding-info/adapters/enigma-funding-info.d.ts.map +1 -0
  25. package/dist/solvers/funding-info/adapters/enigma-funding-info.js +17 -0
  26. package/dist/solvers/funding-info/adapters/enigma-funding-info.js.map +1 -0
  27. package/dist/solvers/funding-info/adapters/rasa-funding-info.d.ts +4 -0
  28. package/dist/solvers/funding-info/adapters/rasa-funding-info.d.ts.map +1 -0
  29. package/dist/solvers/funding-info/adapters/rasa-funding-info.js +21 -0
  30. package/dist/solvers/funding-info/adapters/rasa-funding-info.js.map +1 -0
  31. package/dist/solvers/funding-info/get-funding-info.d.ts +22 -13
  32. package/dist/solvers/funding-info/get-funding-info.d.ts.map +1 -1
  33. package/dist/solvers/funding-info/get-funding-info.js +24 -12
  34. package/dist/solvers/funding-info/get-funding-info.js.map +1 -1
  35. package/dist/solvers/funding-info/query.d.ts +14 -6
  36. package/dist/solvers/funding-info/query.d.ts.map +1 -1
  37. package/dist/solvers/funding-info/query.js +1 -0
  38. package/dist/solvers/funding-info/query.js.map +1 -1
  39. package/dist/solvers/funding-info/to-funding-info.d.ts +8 -4
  40. package/dist/solvers/funding-info/to-funding-info.d.ts.map +1 -1
  41. package/dist/solvers/funding-info/to-funding-info.js +2 -1
  42. package/dist/solvers/funding-info/to-funding-info.js.map +1 -1
  43. package/dist/solvers/funding-info/types.d.ts +26 -4
  44. package/dist/solvers/funding-info/types.d.ts.map +1 -1
  45. package/dist/solvers/market-info/adapters/enigma-market-info.d.ts +3 -3
  46. package/dist/solvers/market-info/adapters/enigma-market-info.d.ts.map +1 -1
  47. package/dist/solvers/market-info/adapters/enigma-market-info.js +7 -5
  48. package/dist/solvers/market-info/adapters/enigma-market-info.js.map +1 -1
  49. package/dist/solvers/market-info/get-market-info.d.ts +3 -2
  50. package/dist/solvers/market-info/get-market-info.d.ts.map +1 -1
  51. package/dist/solvers/market-info/get-market-info.js.map +1 -1
  52. package/dist/solvers/market-info/types.d.ts +4 -3
  53. package/dist/solvers/market-info/types.d.ts.map +1 -1
  54. package/dist/solvers/notional-cap/get-notional-cap-all.d.ts +10 -10
  55. package/dist/solvers/notional-cap/get-notional-cap-all.d.ts.map +1 -1
  56. package/dist/solvers/notional-cap/get-notional-cap-all.js +26 -23
  57. package/dist/solvers/notional-cap/get-notional-cap-all.js.map +1 -1
  58. package/dist/solvers/notional-cap/get-notional-cap-page.d.ts +49 -0
  59. package/dist/solvers/notional-cap/get-notional-cap-page.d.ts.map +1 -0
  60. package/dist/solvers/notional-cap/get-notional-cap-page.js +37 -0
  61. package/dist/solvers/notional-cap/get-notional-cap-page.js.map +1 -0
  62. package/dist/solvers/notional-cap/index.d.ts +2 -0
  63. package/dist/solvers/notional-cap/index.d.ts.map +1 -1
  64. package/dist/solvers/notional-cap/query-page.d.ts +45 -0
  65. package/dist/solvers/notional-cap/query-page.d.ts.map +1 -0
  66. package/dist/solvers/notional-cap/query-page.js +26 -0
  67. package/dist/solvers/notional-cap/query-page.js.map +1 -0
  68. package/dist/solvers/symbols/get-symbols.d.ts +3 -2
  69. package/dist/solvers/symbols/get-symbols.d.ts.map +1 -1
  70. package/dist/solvers/symbols/get-symbols.js +17 -3
  71. package/dist/solvers/symbols/get-symbols.js.map +1 -1
  72. package/dist/solvers/trade-volume/get-trade-volume.d.ts +2 -1
  73. package/dist/solvers/trade-volume/get-trade-volume.d.ts.map +1 -1
  74. package/dist/solvers/trade-volume/get-trade-volume.js +6 -1
  75. package/dist/solvers/trade-volume/get-trade-volume.js.map +1 -1
  76. package/dist/solvers/trade-volume/to-daily-volume.d.ts +6 -6
  77. package/dist/solvers/trade-volume/to-daily-volume.js.map +1 -1
  78. package/dist/solvers/trade-volume/types.d.ts +4 -3
  79. package/dist/solvers/trade-volume/types.d.ts.map +1 -1
  80. package/dist/solvers/types/generated/enigma-solver.js +3 -3
  81. package/dist/solvers/types/generated/enigma-solver.js.map +1 -1
  82. package/dist/solvers/types/generated/rasa-solver.js +8 -2
  83. package/dist/solvers/types/generated/rasa-solver.js.map +1 -1
  84. package/package.json +3 -3
@@ -1,14 +1,18 @@
1
1
  import { ApiFundingInfoResponse } from '../types/generated/enigma-solver.js';
2
- import { MarketFundingInfo } from './types.js';
2
+ import { EnigmaMarketFundingInfo } from './types.js';
3
3
  /** One market's raw entry from `ApiFundingInfoResponse` (the map value). */
4
4
  type RawFundingInfo = ApiFundingInfoResponse[string];
5
5
  /**
6
- * Map one `ApiFundingInfoResponse` entry (keyed by market name) into the SDK's
6
+ * Map one `ApiFundingInfoResponse` entry (keyed by symbol ID) into the SDK's
7
7
  * {@link MarketFundingInfo}. Missing numeric fields default to `0`.
8
8
  *
9
- * @param symbol - The market name (the response map key).
9
+ * @param symbolId - The market ID (the response map key).
10
10
  * @param raw - The raw funding entry for that market.
11
+ * @returns Funding figures identified by symbol ID, with unchanged rate/time units.
12
+ * @throws Does not throw for a valid funding entry.
13
+ * @example
14
+ * toMarketFundingInfo(12, { next_funding_rate_long: "0.001", next_funding_time: 1783209600000 });
11
15
  */
12
- export declare function toMarketFundingInfo(symbol: string, raw: RawFundingInfo): MarketFundingInfo;
16
+ export declare function toMarketFundingInfo(symbolId: number, raw: RawFundingInfo): EnigmaMarketFundingInfo;
13
17
  export {};
14
18
  //# sourceMappingURL=to-funding-info.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-funding-info.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/to-funding-info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,4EAA4E;AAC5E,KAAK,cAAc,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,iBAAiB,CAQ1F"}
1
+ {"version":3,"file":"to-funding-info.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/to-funding-info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,4EAA4E;AAC5E,KAAK,cAAc,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,uBAAuB,CASlG"}
@@ -2,7 +2,8 @@ import { toFiniteNumber as e } from "@symmio/utils/number";
2
2
  //#region src/solvers/funding-info/to-funding-info.ts
3
3
  function t(t, n) {
4
4
  return {
5
- symbol: t,
5
+ kind: "enigma",
6
+ symbolId: t,
6
7
  nextFundingRateLong: e(n.next_funding_rate_long),
7
8
  nextFundingRateShort: e(n.next_funding_rate_short),
8
9
  nextFundingTime: e(n.next_funding_time),
@@ -1 +1 @@
1
- {"version":3,"file":"to-funding-info.js","names":[],"sources":["../../../src/solvers/funding-info/to-funding-info.ts"],"sourcesContent":["import { toFiniteNumber } from \"@symmio/utils/number\";\nimport type { ApiFundingInfoResponse } from \"../types/generated/enigma-solver\";\nimport type { MarketFundingInfo } from \"./types\";\n\n/** One market's raw entry from `ApiFundingInfoResponse` (the map value). */\ntype RawFundingInfo = ApiFundingInfoResponse[string];\n\n/**\n * Map one `ApiFundingInfoResponse` entry (keyed by market name) into the SDK's\n * {@link MarketFundingInfo}. Missing numeric fields default to `0`.\n *\n * @param symbol - The market name (the response map key).\n * @param raw - The raw funding entry for that market.\n */\nexport function toMarketFundingInfo(symbol: string, raw: RawFundingInfo): MarketFundingInfo {\n return {\n symbol,\n nextFundingRateLong: toFiniteNumber(raw.next_funding_rate_long),\n nextFundingRateShort: toFiniteNumber(raw.next_funding_rate_short),\n nextFundingTime: toFiniteNumber(raw.next_funding_time),\n epochDurationSeconds: toFiniteNumber(raw.funding_rate_epoch_duration),\n };\n}\n"],"mappings":";;AAcA,SAAgB,EAAoB,GAAgB,GAAwC;CAC1F,OAAO;EACL;EACA,qBAAqB,EAAe,EAAI,sBAAsB;EAC9D,sBAAsB,EAAe,EAAI,uBAAuB;EAChE,iBAAiB,EAAe,EAAI,iBAAiB;EACrD,sBAAsB,EAAe,EAAI,2BAA2B;CACtE;AACF"}
1
+ {"version":3,"file":"to-funding-info.js","names":[],"sources":["../../../src/solvers/funding-info/to-funding-info.ts"],"sourcesContent":["import { toFiniteNumber } from \"@symmio/utils/number\";\nimport type { ApiFundingInfoResponse } from \"../types/generated/enigma-solver\";\nimport type { EnigmaMarketFundingInfo } from \"./types\";\n\n/** One market's raw entry from `ApiFundingInfoResponse` (the map value). */\ntype RawFundingInfo = ApiFundingInfoResponse[string];\n\n/**\n * Map one `ApiFundingInfoResponse` entry (keyed by symbol ID) into the SDK's\n * {@link MarketFundingInfo}. Missing numeric fields default to `0`.\n *\n * @param symbolId - The market ID (the response map key).\n * @param raw - The raw funding entry for that market.\n * @returns Funding figures identified by symbol ID, with unchanged rate/time units.\n * @throws Does not throw for a valid funding entry.\n * @example\n * toMarketFundingInfo(12, { next_funding_rate_long: \"0.001\", next_funding_time: 1783209600000 });\n */\nexport function toMarketFundingInfo(symbolId: number, raw: RawFundingInfo): EnigmaMarketFundingInfo {\n return {\n kind: \"enigma\",\n symbolId,\n nextFundingRateLong: toFiniteNumber(raw.next_funding_rate_long),\n nextFundingRateShort: toFiniteNumber(raw.next_funding_rate_short),\n nextFundingTime: toFiniteNumber(raw.next_funding_time),\n epochDurationSeconds: toFiniteNumber(raw.funding_rate_epoch_duration),\n };\n}\n"],"mappings":";;AAkBA,SAAgB,EAAoB,GAAkB,GAA8C;CAClG,OAAO;EACL,MAAM;EACN;EACA,qBAAqB,EAAe,EAAI,sBAAsB;EAC9D,sBAAsB,EAAe,EAAI,uBAAuB;EAChE,iBAAiB,EAAe,EAAI,iBAAiB;EACrD,sBAAsB,EAAe,EAAI,2BAA2B;CACtE;AACF"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Next-epoch funding figures for one solver market, normalized from the
3
- * generated `/get_funding_info` response.
3
+ * generated `/funding-info` response.
4
4
  *
5
5
  * Funding is charged per epoch: the long side pays (or receives) at
6
6
  * {@link MarketFundingInfo.nextFundingRateLong} and the short side at
@@ -8,10 +8,10 @@
8
8
  * per-epoch decimal fractions the solver reports — multiply by `100` for a
9
9
  * percentage. A **positive** rate means that side *receives* funding; a
10
10
  * **negative** rate means it *pays*.
11
+ * @example
12
+ * const row: MarketFundingInfo = { kind: "enigma", symbolId: 117, nextFundingRateLong: 0.0001, nextFundingRateShort: -0.0001, nextFundingTime: 1783209600000, epochDurationSeconds: 43200 };
11
13
  */
12
- export interface MarketFundingInfo {
13
- /** Market ticker and solver map key (e.g. `"BTCUSDT"`). */
14
- symbol: string;
14
+ interface BaseMarketFundingInfo {
15
15
  /**
16
16
  * Next funding rate for the long side, as a per-epoch decimal fraction
17
17
  * (`0.0001` = `0.01%`). Positive receives, negative pays.
@@ -32,4 +32,26 @@ export interface MarketFundingInfo {
32
32
  /** Length of one funding epoch, in seconds (e.g. `43200` = 12h). `0` when absent. */
33
33
  epochDurationSeconds: number;
34
34
  }
35
+ /** Funding from Enigma's symbol-ID endpoint. */
36
+ export interface EnigmaMarketFundingInfo extends BaseMarketFundingInfo {
37
+ /** Discriminant identifying the solver response. */
38
+ kind: "enigma";
39
+ /** Stable solver symbol ID; join with getSymbols for names. */
40
+ symbolId: number;
41
+ }
42
+ /** Funding from Rasa's existing ticker endpoint. */
43
+ export interface RasaMarketFundingInfo extends BaseMarketFundingInfo {
44
+ /** Discriminant identifying the solver response. */
45
+ kind: "rasa";
46
+ /** Market ticker from the response map key. */
47
+ symbol: string;
48
+ }
49
+ /** Solver funding row. Narrow on kind before reading symbolId or symbol. */
50
+ export type MarketFundingInfo = EnigmaMarketFundingInfo | RasaMarketFundingInfo;
51
+ /** Maps each solver kind to its funding row, used to narrow actions and hooks. */
52
+ export interface NormalizedFundingInfoByKind {
53
+ enigma: EnigmaMarketFundingInfo;
54
+ rasa: RasaMarketFundingInfo;
55
+ }
56
+ export {};
35
57
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,qFAAqF;IACrF,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,qFAAqF;IACrF,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,gDAAgD;AAChD,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,oDAAoD;IACpD,IAAI,EAAE,QAAQ,CAAC;IACf,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,oDAAoD;AACpD,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GAAG,qBAAqB,CAAC;AAChF,kFAAkF;AAClF,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,uBAAuB,CAAC;IAChC,IAAI,EAAE,qBAAqB,CAAC;CAC7B"}
@@ -1,10 +1,10 @@
1
- import { GetGetMarketInfo200 } from '../../types/generated/enigma-solver.js';
1
+ import { GetMarketInfo200 } from '../../types/generated/enigma-solver.js';
2
2
  import { EnigmaMarketInfo } from '../types.js';
3
3
  /**
4
- * Map Enigma's flat `/get_market_info` bag into {@link EnigmaMarketInfo},
4
+ * Map Enigma's flat `/market-info` bag into {@link EnigmaMarketInfo},
5
5
  * splitting the top-level aggregate totals from the per-market volume rows.
6
6
  */
7
- export declare function toEnigmaMarketInfo(raw: GetGetMarketInfo200): EnigmaMarketInfo;
7
+ export declare function toEnigmaMarketInfo(raw: GetMarketInfo200): EnigmaMarketInfo;
8
8
  /**
9
9
  * Fetch and normalize market info from an **Enigma** solver — the generated
10
10
  * client call plus mapping to {@link EnigmaMarketInfo}.
@@ -1 +1 @@
1
- {"version":3,"file":"enigma-market-info.d.ts","sourceRoot":"","sources":["../../../../src/solvers/market-info/adapters/enigma-market-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AACjG,OAAO,KAAK,EAAE,gBAAgB,EAAgB,MAAM,UAAU,CAAC;AAmB/D;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,gBAAgB,CAkB7E;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAGtF"}
1
+ {"version":3,"file":"enigma-market-info.d.ts","sourceRoot":"","sources":["../../../../src/solvers/market-info/adapters/enigma-market-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAChH,OAAO,KAAK,EAAE,gBAAgB,EAAgB,MAAM,UAAU,CAAC;AAmB/D;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,GAAG,gBAAgB,CAoB1E;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAGtF"}
@@ -1,4 +1,4 @@
1
- import { getGetMarketInfo as e } from "../../types/generated/enigma-solver.js";
1
+ import { getMarketInfo as e } from "../../types/generated/enigma-solver.js";
2
2
  //#region src/solvers/market-info/adapters/enigma-market-info.ts
3
3
  var t = new Set(["total_value_24h", "total_lifetime_value"]);
4
4
  function n(e) {
@@ -10,11 +10,13 @@ function r(e) {
10
10
  let r = [];
11
11
  for (let [i, a] of Object.entries(e)) {
12
12
  if (t.has(i) || typeof a != "object" || !a) continue;
13
- let e = a;
13
+ let e = Number(i);
14
+ if (!Number.isSafeInteger(e) || e <= 0) continue;
15
+ let o = a;
14
16
  r.push({
15
- symbol: i,
16
- tradingVolume: n(e.trading_volume),
17
- lifetimeValue: n(e.lifetime_value)
17
+ symbolId: e,
18
+ tradingVolume: n(o.trading_volume),
19
+ lifetimeValue: n(o.lifetime_value)
18
20
  });
19
21
  }
20
22
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"enigma-market-info.js","names":[],"sources":["../../../../src/solvers/market-info/adapters/enigma-market-info.ts"],"sourcesContent":["import { getGetMarketInfo, type GetGetMarketInfo200 } from \"../../types/generated/enigma-solver\";\nimport type { EnigmaMarketInfo, MarketVolume } from \"../types\";\n\n/**\n * Top-level aggregate keys in Enigma's `/get_market_info` bag. Every other key is\n * a market name whose value is a `{ trading_volume, lifetime_value }` object.\n */\nconst AGGREGATE_KEYS = new Set<string>([\"total_value_24h\", \"total_lifetime_value\"]);\n\n/**\n * Coerce an optional numeric solver field to a finite `number`, defaulting to\n * `0`. Enigma's volume bag is untyped in the OpenAPI spec but the running solver\n * may serve numbers or decimal strings, so accept both.\n */\nfunction toNumber(value: unknown): number {\n if (value === undefined || value === null) return 0;\n const parsed = typeof value === \"number\" ? value : Number(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\n/**\n * Map Enigma's flat `/get_market_info` bag into {@link EnigmaMarketInfo},\n * splitting the top-level aggregate totals from the per-market volume rows.\n */\nexport function toEnigmaMarketInfo(raw: GetGetMarketInfo200): EnigmaMarketInfo {\n const markets: MarketVolume[] = [];\n for (const [key, value] of Object.entries(raw)) {\n if (AGGREGATE_KEYS.has(key)) continue;\n if (typeof value !== \"object\" || value === null) continue;\n const entry = value as Record<string, unknown>;\n markets.push({\n symbol: key,\n tradingVolume: toNumber(entry.trading_volume),\n lifetimeValue: toNumber(entry.lifetime_value),\n });\n }\n return {\n kind: \"enigma\",\n markets,\n totalValue24h: toNumber(raw.total_value_24h),\n totalLifetimeValue: toNumber(raw.total_lifetime_value),\n };\n}\n\n/**\n * Fetch and normalize market info from an **Enigma** solver — the generated\n * client call plus mapping to {@link EnigmaMarketInfo}.\n *\n * @internal\n */\nexport async function fetchEnigmaMarketInfo(baseURL: string): Promise<EnigmaMarketInfo> {\n const response = await getGetMarketInfo({ baseURL });\n return toEnigmaMarketInfo(response.data);\n}\n"],"mappings":";;AAOA,IAAM,IAAiB,IAAI,IAAY,CAAC,mBAAmB,sBAAsB,CAAC;AAOlF,SAAS,EAAS,GAAwB;CACxC,IAAI,KAAiC,MAAM,OAAO;CAClD,IAAM,IAAS,OAAO,KAAU,WAAW,IAAQ,OAAO,CAAK;CAC/D,OAAO,OAAO,SAAS,CAAM,IAAI,IAAS;AAC5C;AAMA,SAAgB,EAAmB,GAA4C;CAC7E,IAAM,IAA0B,CAAC;CACjC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAG,GAAG;EAE9C,IADI,EAAe,IAAI,CAAG,KACtB,OAAO,KAAU,aAAY,GAAgB;EACjD,IAAM,IAAQ;EACd,EAAQ,KAAK;GACX,QAAQ;GACR,eAAe,EAAS,EAAM,cAAc;GAC5C,eAAe,EAAS,EAAM,cAAc;EAC9C,CAAC;CACH;CACA,OAAO;EACL,MAAM;EACN;EACA,eAAe,EAAS,EAAI,eAAe;EAC3C,oBAAoB,EAAS,EAAI,oBAAoB;CACvD;AACF;AAQA,eAAsB,EAAsB,GAA4C;CAEtF,OAAO,GAAmB,MADH,EAAiB,EAAE,WAAQ,CAAC,GAChB,IAAI;AACzC"}
1
+ {"version":3,"file":"enigma-market-info.js","names":[],"sources":["../../../../src/solvers/market-info/adapters/enigma-market-info.ts"],"sourcesContent":["import { getMarketInfo as requestMarketInfo, type GetMarketInfo200 } from \"../../types/generated/enigma-solver\";\nimport type { EnigmaMarketInfo, MarketVolume } from \"../types\";\n\n/**\n * Top-level aggregate keys in Enigma's `/market-info` bag. Every other key is\n * a symbol ID whose value is a `{ trading_volume, lifetime_value }` object.\n */\nconst AGGREGATE_KEYS = new Set<string>([\"total_value_24h\", \"total_lifetime_value\"]);\n\n/**\n * Coerce an optional numeric solver field to a finite `number`, defaulting to\n * `0`. Enigma's volume bag is untyped in the OpenAPI spec but the running solver\n * may serve numbers or decimal strings, so accept both.\n */\nfunction toNumber(value: unknown): number {\n if (value === undefined || value === null) return 0;\n const parsed = typeof value === \"number\" ? value : Number(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\n/**\n * Map Enigma's flat `/market-info` bag into {@link EnigmaMarketInfo},\n * splitting the top-level aggregate totals from the per-market volume rows.\n */\nexport function toEnigmaMarketInfo(raw: GetMarketInfo200): EnigmaMarketInfo {\n const markets: MarketVolume[] = [];\n for (const [key, value] of Object.entries(raw)) {\n if (AGGREGATE_KEYS.has(key)) continue;\n if (typeof value !== \"object\" || value === null) continue;\n const symbolId = Number(key);\n if (!Number.isSafeInteger(symbolId) || symbolId <= 0) continue;\n const entry = value as Record<string, unknown>;\n markets.push({\n symbolId,\n tradingVolume: toNumber(entry.trading_volume),\n lifetimeValue: toNumber(entry.lifetime_value),\n });\n }\n return {\n kind: \"enigma\",\n markets,\n totalValue24h: toNumber(raw.total_value_24h),\n totalLifetimeValue: toNumber(raw.total_lifetime_value),\n };\n}\n\n/**\n * Fetch and normalize market info from an **Enigma** solver — the generated\n * client call plus mapping to {@link EnigmaMarketInfo}.\n *\n * @internal\n */\nexport async function fetchEnigmaMarketInfo(baseURL: string): Promise<EnigmaMarketInfo> {\n const response = await requestMarketInfo({ baseURL });\n return toEnigmaMarketInfo(response.data);\n}\n"],"mappings":";;AAOA,IAAM,IAAiB,IAAI,IAAY,CAAC,mBAAmB,sBAAsB,CAAC;AAOlF,SAAS,EAAS,GAAwB;CACxC,IAAI,KAAiC,MAAM,OAAO;CAClD,IAAM,IAAS,OAAO,KAAU,WAAW,IAAQ,OAAO,CAAK;CAC/D,OAAO,OAAO,SAAS,CAAM,IAAI,IAAS;AAC5C;AAMA,SAAgB,EAAmB,GAAyC;CAC1E,IAAM,IAA0B,CAAC;CACjC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAG,GAAG;EAE9C,IADI,EAAe,IAAI,CAAG,KACtB,OAAO,KAAU,aAAY,GAAgB;EACjD,IAAM,IAAW,OAAO,CAAG;EAC3B,IAAI,CAAC,OAAO,cAAc,CAAQ,KAAK,KAAY,GAAG;EACtD,IAAM,IAAQ;EACd,EAAQ,KAAK;GACX;GACA,eAAe,EAAS,EAAM,cAAc;GAC5C,eAAe,EAAS,EAAM,cAAc;EAC9C,CAAC;CACH;CACA,OAAO;EACL,MAAM;EACN;EACA,eAAe,EAAS,EAAI,eAAe;EAC3C,oBAAoB,EAAS,EAAI,oBAAoB;CACvD;AACF;AAQA,eAAsB,EAAsB,GAA4C;CAEtF,OAAO,GAAmB,MADH,EAAkB,EAAE,WAAQ,CAAC,GACjB,IAAI;AACzC"}
@@ -14,11 +14,12 @@ export type GetMarketInfoParameters<K extends SymmioSolverKind = SymmioSolverKin
14
14
  /** Return type of {@link getMarketInfo}: the market-info type for kind `K` (the {@link MarketInfo} union when unspecified). */
15
15
  export type GetMarketInfoReturnType<K extends SymmioSolverKind = SymmioSolverKind> = NormalizedMarketInfoByKind[K];
16
16
  /**
17
- * Fetch per-market info from the chain's solver `/get_market_info` endpoint,
17
+ * Fetch market info from Enigma `/market-info` or Rasa `/get_market_info`,
18
18
  * normalized to the {@link MarketInfo} union. The response diverges by solver
19
19
  * kind — **Enigma** returns per-market 24h volume + lifetime value plus aggregate
20
- * totals; **Rasa** returns per-market price / 24h change / volume / notional cap.
20
+ * totals keyed by symbol ID; **Rasa** returns per-market price / 24h change / volume / notional cap.
21
21
  * So **narrow on `kind`** before reading either side's rows.
22
+ * Enigma has no per-market route: select a symbol ID from this shared response.
22
23
  *
23
24
  * Pass a **literal** `solverId` to narrow the return to that solver's type; omit
24
25
  * it (default solver) to get the union.
@@ -1 +1 @@
1
- {"version":3,"file":"get-market-info.d.ts","sourceRoot":"","sources":["../../../src/solvers/market-info/get-market-info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,KAAK,EAAc,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,OAAO,CAC1F,gBAAgB,GAAG;IACjB,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,CAAC,CAAC;CACd,CACF,CAAC;AAEF,+HAA+H;AAC/H,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,0BAA0B,CAAC,CAAC,CAAC,CAAC;AAEnH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,aAAa,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAC/E,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,uBAAuB,CAAC,CAAC,CAAM,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAQrC"}
1
+ {"version":3,"file":"get-market-info.d.ts","sourceRoot":"","sources":["../../../src/solvers/market-info/get-market-info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,KAAK,EAAc,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,OAAO,CAC1F,gBAAgB,GAAG;IACjB,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,CAAC,CAAC;CACd,CACF,CAAC;AAEF,+HAA+H;AAC/H,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,0BAA0B,CAAC,CAAC,CAAC,CAAC;AAEnH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,aAAa,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAC/E,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,uBAAuB,CAAC,CAAC,CAAM,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAQrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-market-info.js","names":[],"sources":["../../../src/solvers/market-info/get-market-info.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { SymmioResolvedSolver, SymmioSolverKind } from \"../../core/chains/types\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { fetchEnigmaMarketInfo, fetchRasaMarketInfo } from \"./adapters\";\nimport type { MarketInfo, NormalizedMarketInfoByKind } from \"./types\";\n\n/**\n * Parameters for {@link getMarketInfo}, generic over the solver kind `K`. A\n * **literal** `solverId` narrows the return to that solver's market-info type; a\n * variable or omitted `solverId` yields the {@link MarketInfo} union.\n */\nexport type GetMarketInfoParameters<K extends SymmioSolverKind = SymmioSolverKind> = Compute<\n ChainIdParameter & {\n /** Which solver kind to read. A literal narrows the return; omit for the chain's default. */\n solverId?: K;\n }\n>;\n\n/** Return type of {@link getMarketInfo}: the market-info type for kind `K` (the {@link MarketInfo} union when unspecified). */\nexport type GetMarketInfoReturnType<K extends SymmioSolverKind = SymmioSolverKind> = NormalizedMarketInfoByKind[K];\n\n/**\n * Fetch per-market info from the chain's solver `/get_market_info` endpoint,\n * normalized to the {@link MarketInfo} union. The response diverges by solver\n * kind — **Enigma** returns per-market 24h volume + lifetime value plus aggregate\n * totals; **Rasa** returns per-market price / 24h change / volume / notional cap.\n * So **narrow on `kind`** before reading either side's rows.\n *\n * Pass a **literal** `solverId` to narrow the return to that solver's type; omit\n * it (default solver) to get the union.\n *\n * @param config - The SDK config.\n * @param parameters - Optional chain id and solver kind.\n * @returns Normalized market info for the resolved solver.\n * @throws {SymmApiError} when the API request fails.\n * @throws {SymmError} when the chain or solver is unsupported.\n *\n * @example\n * ```ts\n * const info = await getMarketInfo(config, {});\n * if (info.kind === \"enigma\") console.log(info.totalValue24h);\n * else console.log(info.markets[0]?.price); // Rasa\n * ```\n */\nexport async function getMarketInfo<K extends SymmioSolverKind = SymmioSolverKind>(\n config: Config,\n parameters: GetMarketInfoParameters<K> = {},\n): Promise<GetMarketInfoReturnType<K>> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n try {\n const info = await fetchMarketInfoBySolverKind(solver);\n return info as GetMarketInfoReturnType<K>;\n } catch (err) {\n throw toMarketInfoError(err, solver.url);\n }\n}\n\n/**\n * Dispatch to the resolved solver's per-kind market-info adapter (each owns its\n * client call + normalization). Exhaustive over the solver kinds — a new kind\n * fails to compile at the `never` guard until its adapter is wired in.\n *\n * @internal\n */\nasync function fetchMarketInfoBySolverKind(solver: SymmioResolvedSolver): Promise<MarketInfo> {\n switch (solver.id) {\n case \"enigma\":\n return fetchEnigmaMarketInfo(solver.url);\n case \"rasa\":\n return fetchRasaMarketInfo(solver.url);\n default: {\n const unreachable: never = solver.id;\n throw new SymmError(\n \"api\",\n \"UNSUPPORTED_BY_SOLVER\",\n `Market info is not supported by solver kind \"${unreachable}\".`,\n );\n }\n }\n}\n\n/**\n * Map a fetch failure to a typed {@link SymmError}.\n *\n * @internal\n */\nfunction toMarketInfoError(err: unknown, baseURL: string): SymmError {\n if (err instanceof SymmError) return err;\n if (isAxiosError(err)) {\n return SymmApiError.fromAxios(err, { code: \"FETCH_MARKET_INFO_FAILED\", baseURL });\n }\n return new SymmError(\n \"api\",\n \"FETCH_MARKET_INFO_FAILED\",\n `Failed to fetch market info: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n}\n"],"mappings":";;;;;AA8CA,eAAsB,EACpB,GACA,IAAyC,CAAC,GACL;CACrC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAC9F,IAAI;EAEF,OAAO,MADY,EAA4B,CAAM;CAEvD,SAAS,GAAK;EACZ,MAAM,EAAkB,GAAK,EAAO,GAAG;CACzC;AACF;AASA,eAAe,EAA4B,GAAmD;CAC5F,QAAQ,EAAO,IAAf;EACE,KAAK,UACH,OAAO,EAAsB,EAAO,GAAG;EACzC,KAAK,QACH,OAAO,EAAoB,EAAO,GAAG;EACvC,SAAS;GACP,IAAM,IAAqB,EAAO;GAClC,MAAM,IAAI,EACR,OACA,yBACA,gDAAgD,EAAY,GAC9D;EACF;CACF;AACF;AAOA,SAAS,EAAkB,GAAc,GAA4B;CAKnE,OAJI,aAAe,IAAkB,IACjC,EAAa,CAAG,IACX,EAAa,UAAU,GAAK;EAAE,MAAM;EAA4B;CAAQ,CAAC,IAE3E,IAAI,EACT,OACA,4BACA,gCAAgC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAC/E,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;AACF"}
1
+ {"version":3,"file":"get-market-info.js","names":[],"sources":["../../../src/solvers/market-info/get-market-info.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { SymmioResolvedSolver, SymmioSolverKind } from \"../../core/chains/types\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { fetchEnigmaMarketInfo, fetchRasaMarketInfo } from \"./adapters\";\nimport type { MarketInfo, NormalizedMarketInfoByKind } from \"./types\";\n\n/**\n * Parameters for {@link getMarketInfo}, generic over the solver kind `K`. A\n * **literal** `solverId` narrows the return to that solver's market-info type; a\n * variable or omitted `solverId` yields the {@link MarketInfo} union.\n */\nexport type GetMarketInfoParameters<K extends SymmioSolverKind = SymmioSolverKind> = Compute<\n ChainIdParameter & {\n /** Which solver kind to read. A literal narrows the return; omit for the chain's default. */\n solverId?: K;\n }\n>;\n\n/** Return type of {@link getMarketInfo}: the market-info type for kind `K` (the {@link MarketInfo} union when unspecified). */\nexport type GetMarketInfoReturnType<K extends SymmioSolverKind = SymmioSolverKind> = NormalizedMarketInfoByKind[K];\n\n/**\n * Fetch market info from Enigma `/market-info` or Rasa `/get_market_info`,\n * normalized to the {@link MarketInfo} union. The response diverges by solver\n * kind — **Enigma** returns per-market 24h volume + lifetime value plus aggregate\n * totals keyed by symbol ID; **Rasa** returns per-market price / 24h change / volume / notional cap.\n * So **narrow on `kind`** before reading either side's rows.\n * Enigma has no per-market route: select a symbol ID from this shared response.\n *\n * Pass a **literal** `solverId` to narrow the return to that solver's type; omit\n * it (default solver) to get the union.\n *\n * @param config - The SDK config.\n * @param parameters - Optional chain id and solver kind.\n * @returns Normalized market info for the resolved solver.\n * @throws {SymmApiError} when the API request fails.\n * @throws {SymmError} when the chain or solver is unsupported.\n *\n * @example\n * ```ts\n * const info = await getMarketInfo(config, {});\n * if (info.kind === \"enigma\") console.log(info.totalValue24h);\n * else console.log(info.markets[0]?.price); // Rasa\n * ```\n */\nexport async function getMarketInfo<K extends SymmioSolverKind = SymmioSolverKind>(\n config: Config,\n parameters: GetMarketInfoParameters<K> = {},\n): Promise<GetMarketInfoReturnType<K>> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n try {\n const info = await fetchMarketInfoBySolverKind(solver);\n return info as GetMarketInfoReturnType<K>;\n } catch (err) {\n throw toMarketInfoError(err, solver.url);\n }\n}\n\n/**\n * Dispatch to the resolved solver's per-kind market-info adapter (each owns its\n * client call + normalization). Exhaustive over the solver kinds — a new kind\n * fails to compile at the `never` guard until its adapter is wired in.\n *\n * @internal\n */\nasync function fetchMarketInfoBySolverKind(solver: SymmioResolvedSolver): Promise<MarketInfo> {\n switch (solver.id) {\n case \"enigma\":\n return fetchEnigmaMarketInfo(solver.url);\n case \"rasa\":\n return fetchRasaMarketInfo(solver.url);\n default: {\n const unreachable: never = solver.id;\n throw new SymmError(\n \"api\",\n \"UNSUPPORTED_BY_SOLVER\",\n `Market info is not supported by solver kind \"${unreachable}\".`,\n );\n }\n }\n}\n\n/**\n * Map a fetch failure to a typed {@link SymmError}.\n *\n * @internal\n */\nfunction toMarketInfoError(err: unknown, baseURL: string): SymmError {\n if (err instanceof SymmError) return err;\n if (isAxiosError(err)) {\n return SymmApiError.fromAxios(err, { code: \"FETCH_MARKET_INFO_FAILED\", baseURL });\n }\n return new SymmError(\n \"api\",\n \"FETCH_MARKET_INFO_FAILED\",\n `Failed to fetch market info: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n}\n"],"mappings":";;;;;AA+CA,eAAsB,EACpB,GACA,IAAyC,CAAC,GACL;CACrC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAC9F,IAAI;EAEF,OAAO,MADY,EAA4B,CAAM;CAEvD,SAAS,GAAK;EACZ,MAAM,EAAkB,GAAK,EAAO,GAAG;CACzC;AACF;AASA,eAAe,EAA4B,GAAmD;CAC5F,QAAQ,EAAO,IAAf;EACE,KAAK,UACH,OAAO,EAAsB,EAAO,GAAG;EACzC,KAAK,QACH,OAAO,EAAoB,EAAO,GAAG;EACvC,SAAS;GACP,IAAM,IAAqB,EAAO;GAClC,MAAM,IAAI,EACR,OACA,yBACA,gDAAgD,EAAY,GAC9D;EACF;CACF;AACF;AAOA,SAAS,EAAkB,GAAc,GAA4B;CAKnE,OAJI,aAAe,IAAkB,IACjC,EAAa,CAAG,IACX,EAAa,UAAU,GAAK;EAAE,MAAM;EAA4B;CAAQ,CAAC,IAE3E,IAAI,EACT,OACA,4BACA,gCAAgC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAC/E,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;AACF"}
@@ -1,12 +1,13 @@
1
1
  /**
2
- * 24h volume figures for one **Enigma** market, normalized from `/get_market_info`.
2
+ * 24h volume figures for one **Enigma** market, normalized from `/market-info`.
3
3
  *
4
4
  * Every numeric field is a plain JavaScript `number` in the **dollar units the
5
5
  * solver already reports** — no decimal scaling. `1234` here means $1,234.
6
+ * @example const row: MarketVolume = { symbolId: 117, tradingVolume: 1234, lifetimeValue: 5678 };
6
7
  */
7
8
  export interface MarketVolume {
8
- /** Market ticker and solver map key (e.g. `"BTCUSDT"`). */
9
- symbol: string;
9
+ /** Stable solver symbol ID; join with getSymbols for names and tickers. */
10
+ symbolId: number;
10
11
  /** Rolling 24-hour trading volume for the market (dollars). */
11
12
  tradingVolume: number;
12
13
  /** Cumulative lifetime traded value for the market (dollars). */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/solvers/market-info/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,IAAI,EAAE,QAAQ,CAAC;IACf,mEAAmE;IACnE,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAE3D,gEAAgE;AAChE,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,EAAE,cAAc,CAAC;CACtB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/solvers/market-info/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,IAAI,EAAE,QAAQ,CAAC;IACf,mEAAmE;IACnE,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAE3D,gEAAgE;AAChE,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,EAAE,cAAc,CAAC;CACtB"}
@@ -17,18 +17,18 @@ export interface GetNotionalCapAllReturnType {
17
17
  symbols: EnigmaNotionalCap[];
18
18
  }
19
19
  /**
20
- * Fetch every market's notional cap in one call (`/notional_cap`). Surfaces the
21
- * aggregate `totalOpenInterest` / `totalUsed` and the per-symbol rows decoded
22
- * via {@link toMarketNotionalCap} — the same mapper the single-symbol read uses.
23
- *
24
- * Dollar amounts are returned as plain `number` values exactly as the solver
25
- * reports them; no decimal scaling. HTTP / transport failures throw
26
- * {@link SymmApiError}.
27
- *
20
+ * Fetch every Enigma notional-cap page in server order and sum page totals.
21
+ * Dollar amounts remain plain numbers, with the existing zero fallback for
22
+ * missing fields. A failed later page rejects the whole read.
23
+ * @param config - SDK configuration selecting the deployment.
24
+ * @param parameters - Optional chain and solver selection.
25
+ * @returns All rows, their count and aggregate totals in float dollars.
26
+ * @throws {SymmError} For an unsupported solver or chain.
27
+ * @throws {SymmApiError} When any page request fails.
28
28
  * @example
29
29
  * ```ts
30
- * const all = await getNotionalCapAll(config, {});
31
- * console.log(all.totalOpenInterest, all.symbols.length);
30
+ * const caps = await getNotionalCapAll(config, {});
31
+ * console.log(caps.count, caps.totalUsed);
32
32
  * ```
33
33
  */
34
34
  export declare function getNotionalCapAll(config: Config, parameters?: GetNotionalCapAllParameters): Promise<GetNotionalCapAllReturnType>;
@@ -1 +1 @@
1
- {"version":3,"file":"get-notional-cap-all.d.ts","sourceRoot":"","sources":["../../../src/solvers/notional-cap/get-notional-cap-all.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEvE,oFAAoF;AACpF,MAAM,WAAW,2BAA2B;IAC1C,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,2BAAgC,GAC3C,OAAO,CAAC,2BAA2B,CAAC,CAwBtC"}
1
+ {"version":3,"file":"get-notional-cap-all.d.ts","sourceRoot":"","sources":["../../../src/solvers/notional-cap/get-notional-cap-all.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAElF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEvE,oFAAoF;AACpF,MAAM,WAAW,2BAA2B;IAC1C,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,2BAAgC,GAC3C,OAAO,CAAC,2BAA2B,CAAC,CA4BtC"}
@@ -1,30 +1,33 @@
1
1
  import { SymmApiError as e, SymmError as t } from "../../shared/errors/symm-error.js";
2
- import { getNotionalCap as n } from "../types/generated/enigma-solver.js";
3
- import { toEnigmaNotionalCap as r } from "./adapters/enigma-notional-cap.js";
4
- import { isAxiosError as i } from "axios";
5
- import { toFiniteNumber as a } from "@symmio/utils/number";
2
+ import { getNotionalCapPage as n } from "./get-notional-cap-page.js";
3
+ import { isAxiosError as r } from "axios";
6
4
  //#region src/solvers/notional-cap/get-notional-cap-all.ts
7
- async function o(o, s = {}) {
8
- let c = o.getSolver({
9
- chainId: s.chainId,
10
- solverId: s.solverId
11
- });
12
- try {
13
- let e = (await n(void 0, { baseURL: c.url })).data, t = Array.isArray(e.symbols) ? e.symbols : [];
14
- return {
15
- count: a(e.count),
16
- totalOpenInterest: a(e.total_open_interest),
17
- totalUsed: a(e.total_used),
18
- symbols: t.map(r)
19
- };
20
- } catch (n) {
21
- throw n instanceof t ? n : i(n) ? e.fromAxios(n, {
22
- code: "FETCH_NOTIONAL_CAP_ALL_FAILED",
23
- baseURL: c.url
24
- }) : new t("api", "FETCH_NOTIONAL_CAP_ALL_FAILED", `Failed to fetch notional caps: ${n instanceof Error ? n.message : String(n)}`, { cause: n instanceof Error ? n : void 0 });
5
+ async function i(i, a = {}) {
6
+ let o = {
7
+ count: 0,
8
+ totalOpenInterest: 0,
9
+ totalUsed: 0,
10
+ symbols: []
11
+ };
12
+ for (let s = 0;; s += 100) {
13
+ let c;
14
+ try {
15
+ c = await n(i, {
16
+ ...a,
17
+ limit: 100,
18
+ offset: s
19
+ });
20
+ } catch (n) {
21
+ throw n instanceof e && r(n.cause) ? e.fromAxios(n.cause, {
22
+ code: "FETCH_NOTIONAL_CAP_ALL_FAILED",
23
+ baseURL: i.getSolver(a).url
24
+ }) : n instanceof t && n.code === "FETCH_NOTIONAL_CAP_PAGE_FAILED" ? new t(n.kind, "FETCH_NOTIONAL_CAP_ALL_FAILED", n.message, { cause: n.cause }) : n;
25
+ }
26
+ if (o.symbols.push(...c.symbols), o.totalOpenInterest += c.totalOpenInterest, o.totalUsed += c.totalUsed, c.symbols.length < 100) break;
25
27
  }
28
+ return o.count = o.symbols.length, o;
26
29
  }
27
30
  //#endregion
28
- export { o as getNotionalCapAll };
31
+ export { i as getNotionalCapAll };
29
32
 
30
33
  //# sourceMappingURL=get-notional-cap-all.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-notional-cap-all.js","names":[],"sources":["../../../src/solvers/notional-cap/get-notional-cap-all.ts"],"sourcesContent":["import { toFiniteNumber } from \"@symmio/utils/number\";\nimport { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { getNotionalCap } from \"../types/generated/enigma-solver\";\nimport { toEnigmaNotionalCap } from \"./adapters\";\nimport type { EnigmaNotionalCap } from \"./types\";\n\n/**\n * Parameters for {@link getNotionalCapAll}.\n */\nexport type GetNotionalCapAllParameters = Compute<ReadSolverParameter>;\n\n/** Return type of {@link getNotionalCapAll}: aggregate totals + per-symbol rows. */\nexport interface GetNotionalCapAllReturnType {\n /** Number of symbols the solver returned. */\n count: number;\n /** Σ `openInterest` across every market (dollars). */\n totalOpenInterest: number;\n /** Σ `used` across every market (dollars). */\n totalUsed: number;\n /** Per-symbol rows. `/notional_cap` (list) is Enigma-only, so rows are always Enigma-shaped. */\n symbols: EnigmaNotionalCap[];\n}\n\n/**\n * Fetch every market's notional cap in one call (`/notional_cap`). Surfaces the\n * aggregate `totalOpenInterest` / `totalUsed` and the per-symbol rows decoded\n * via {@link toMarketNotionalCap} — the same mapper the single-symbol read uses.\n *\n * Dollar amounts are returned as plain `number` values exactly as the solver\n * reports them; no decimal scaling. HTTP / transport failures throw\n * {@link SymmApiError}.\n *\n * @example\n * ```ts\n * const all = await getNotionalCapAll(config, {});\n * console.log(all.totalOpenInterest, all.symbols.length);\n * ```\n */\nexport async function getNotionalCapAll(\n config: Config,\n parameters: GetNotionalCapAllParameters = {},\n): Promise<GetNotionalCapAllReturnType> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n try {\n const response = await getNotionalCap(undefined, { baseURL: solver.url });\n const r = response.data as Record<string, unknown>;\n const rawSymbols = Array.isArray(r.symbols) ? (r.symbols as Parameters<typeof toEnigmaNotionalCap>[0][]) : [];\n return {\n count: toFiniteNumber(r.count as number | string | undefined),\n totalOpenInterest: toFiniteNumber(r.total_open_interest as number | string | undefined),\n totalUsed: toFiniteNumber(r.total_used as number | string | undefined),\n symbols: rawSymbols.map(toEnigmaNotionalCap),\n };\n } catch (err) {\n if (err instanceof SymmError) throw err;\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_NOTIONAL_CAP_ALL_FAILED\", baseURL: solver.url });\n }\n throw new SymmError(\n \"api\",\n \"FETCH_NOTIONAL_CAP_ALL_FAILED\",\n `Failed to fetch notional caps: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;AAyCA,eAAsB,EACpB,GACA,IAA0C,CAAC,GACL;CACtC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAC9F,IAAI;EAEF,IAAM,KAAI,MADa,EAAe,KAAA,GAAW,EAAE,SAAS,EAAO,IAAI,CAAC,GACrD,MACb,IAAa,MAAM,QAAQ,EAAE,OAAO,IAAK,EAAE,UAA0D,CAAC;EAC5G,OAAO;GACL,OAAO,EAAe,EAAE,KAAoC;GAC5D,mBAAmB,EAAe,EAAE,mBAAkD;GACtF,WAAW,EAAe,EAAE,UAAyC;GACrE,SAAS,EAAW,IAAI,CAAmB;EAC7C;CACF,SAAS,GAAK;EAKZ,MAJI,aAAe,IAAiB,IAChC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAAiC,SAAS,EAAO;EAAI,CAAC,IAE5F,IAAI,EACR,OACA,iCACA,kCAAkC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KACjF,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
1
+ {"version":3,"file":"get-notional-cap-all.js","names":[],"sources":["../../../src/solvers/notional-cap/get-notional-cap-all.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { getNotionalCapPage } from \"./get-notional-cap-page\";\nimport type { EnigmaNotionalCap } from \"./types\";\n\n/**\n * Parameters for {@link getNotionalCapAll}.\n */\nexport type GetNotionalCapAllParameters = Compute<ReadSolverParameter>;\n\n/** Return type of {@link getNotionalCapAll}: aggregate totals + per-symbol rows. */\nexport interface GetNotionalCapAllReturnType {\n /** Number of symbols the solver returned. */\n count: number;\n /** Σ `openInterest` across every market (dollars). */\n totalOpenInterest: number;\n /** Σ `used` across every market (dollars). */\n totalUsed: number;\n /** Per-symbol rows. `/notional_cap` (list) is Enigma-only, so rows are always Enigma-shaped. */\n symbols: EnigmaNotionalCap[];\n}\n\n/**\n * Fetch every Enigma notional-cap page in server order and sum page totals.\n * Dollar amounts remain plain numbers, with the existing zero fallback for\n * missing fields. A failed later page rejects the whole read.\n * @param config - SDK configuration selecting the deployment.\n * @param parameters - Optional chain and solver selection.\n * @returns All rows, their count and aggregate totals in float dollars.\n * @throws {SymmError} For an unsupported solver or chain.\n * @throws {SymmApiError} When any page request fails.\n * @example\n * ```ts\n * const caps = await getNotionalCapAll(config, {});\n * console.log(caps.count, caps.totalUsed);\n * ```\n */\nexport async function getNotionalCapAll(\n config: Config,\n parameters: GetNotionalCapAllParameters = {},\n): Promise<GetNotionalCapAllReturnType> {\n const result: GetNotionalCapAllReturnType = { count: 0, totalOpenInterest: 0, totalUsed: 0, symbols: [] };\n // Live limit differs from the generated vendor spec. Do not raise it to 500.\n const pageSize = 100;\n for (let offset = 0; ; offset += pageSize) {\n let page: GetNotionalCapAllReturnType;\n try {\n page = await getNotionalCapPage(config, { ...parameters, limit: pageSize, offset });\n } catch (error) {\n // Preserve the bulk action's existing error code for transport failures.\n if (error instanceof SymmApiError && isAxiosError(error.cause)) {\n throw SymmApiError.fromAxios(error.cause, {\n code: \"FETCH_NOTIONAL_CAP_ALL_FAILED\",\n baseURL: config.getSolver(parameters).url,\n });\n }\n if (error instanceof SymmError && error.code === \"FETCH_NOTIONAL_CAP_PAGE_FAILED\") {\n throw new SymmError(error.kind, \"FETCH_NOTIONAL_CAP_ALL_FAILED\", error.message, { cause: error.cause });\n }\n throw error;\n }\n result.symbols.push(...page.symbols);\n result.totalOpenInterest += page.totalOpenInterest;\n result.totalUsed += page.totalUsed;\n if (page.symbols.length < pageSize) break;\n }\n result.count = result.symbols.length;\n return result;\n}\n"],"mappings":";;;;AAuCA,eAAsB,EACpB,GACA,IAA0C,CAAC,GACL;CACtC,IAAM,IAAsC;EAAE,OAAO;EAAG,mBAAmB;EAAG,WAAW;EAAG,SAAS,CAAC;CAAE;CAGxG,KAAK,IAAI,IAAS,IAAK,KAAU,KAAU;EACzC,IAAI;EACJ,IAAI;GACF,IAAO,MAAM,EAAmB,GAAQ;IAAE,GAAG;IAAY,OAAO;IAAU;GAAO,CAAC;EACpF,SAAS,GAAO;GAWd,MATI,aAAiB,KAAgB,EAAa,EAAM,KAAK,IACrD,EAAa,UAAU,EAAM,OAAO;IACxC,MAAM;IACN,SAAS,EAAO,UAAU,CAAU,EAAE;GACxC,CAAC,IAEC,aAAiB,KAAa,EAAM,SAAS,mCACzC,IAAI,EAAU,EAAM,MAAM,iCAAiC,EAAM,SAAS,EAAE,OAAO,EAAM,MAAM,CAAC,IAElG;EACR;EAIA,IAHA,EAAO,QAAQ,KAAK,GAAG,EAAK,OAAO,GACnC,EAAO,qBAAqB,EAAK,mBACjC,EAAO,aAAa,EAAK,WACrB,EAAK,QAAQ,SAAS,KAAU;CACtC;CAEA,OADA,EAAO,QAAQ,EAAO,QAAQ,QACvB;AACT"}
@@ -0,0 +1,49 @@
1
+ import { Config } from '../../core/config/index.js';
2
+ import { Compute, ReadSolverParameter } from '../../shared/types/properties.js';
3
+ import { EnigmaNotionalCap } from './types.js';
4
+ /**
5
+ * Parameters for {@link getNotionalCapPage}.
6
+ * Paging is optional; omit it for the first 100 rows. Totals cover only that page.
7
+ * @example
8
+ * const parameters: GetNotionalCapPageParameters = { chainId: 42161, limit: 50, offset: 100 };
9
+ */
10
+ export type GetNotionalCapPageParameters = Compute<ReadSolverParameter & {
11
+ /** Maximum rows in this page (1–100, default 100). */
12
+ limit?: number;
13
+ /** Zero-based row offset (default 0). */
14
+ offset?: number;
15
+ }>;
16
+ /**
17
+ * One page of normalized caps and its aggregate totals in float dollars.
18
+ * Missing numeric wire fields are zero, matching the existing cap API.
19
+ * @example
20
+ * const page: GetNotionalCapPageReturnType = await getNotionalCapPage(config, { offset: 100 });
21
+ * console.log(page.symbols, page.totalUsed);
22
+ */
23
+ export interface GetNotionalCapPageReturnType {
24
+ /** Number of symbols the solver returned. */
25
+ count: number;
26
+ /** Σ `openInterest` across this page (dollars). */
27
+ totalOpenInterest: number;
28
+ /** Σ `used` across this page (dollars). */
29
+ totalUsed: number;
30
+ /** Per-symbol rows. `/notional_cap` (list) is Enigma-only, so rows are always Enigma-shaped. */
31
+ symbols: EnigmaNotionalCap[];
32
+ }
33
+ /**
34
+ * Fetch one Enigma notional-cap page, with page-only totals in float dollars.
35
+ * The live endpoint accepts at most 100 rows despite the generated spec's 500.
36
+ * Missing numeric fields retain the existing zero fallback.
37
+ * @param config - SDK configuration selecting the deployment.
38
+ * @param parameters - Chain, solver and optional limit/offset.
39
+ * @returns Normalized rows and totals for this page only.
40
+ * @throws {SymmError} For invalid paging or an unsupported solver/chain.
41
+ * @throws {SymmApiError} When the upstream request fails.
42
+ * @example
43
+ * ```ts
44
+ * const page = await getNotionalCapPage(config, { limit: 100, offset: 100 });
45
+ * console.log(page.totalUsed, page.symbols);
46
+ * ```
47
+ */
48
+ export declare function getNotionalCapPage(config: Config, parameters?: GetNotionalCapPageParameters): Promise<GetNotionalCapPageReturnType>;
49
+ //# sourceMappingURL=get-notional-cap-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-notional-cap-page.d.ts","sourceRoot":"","sources":["../../../src/solvers/notional-cap/get-notional-cap-page.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAChD,mBAAmB,GAAG;IACpB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,4BAAiC,GAC5C,OAAO,CAAC,4BAA4B,CAAC,CAkCvC"}
@@ -0,0 +1,37 @@
1
+ import { SymmApiError as e, SymmError as t } from "../../shared/errors/symm-error.js";
2
+ import { getNotionalCap as n } from "../types/generated/enigma-solver.js";
3
+ import { assertSolverKind as r } from "../assert-solver-kind.js";
4
+ import { toEnigmaNotionalCap as i } from "./adapters/enigma-notional-cap.js";
5
+ import { isAxiosError as a } from "axios";
6
+ import { toFiniteNumber as o } from "@symmio/utils/number";
7
+ //#region src/solvers/notional-cap/get-notional-cap-page.ts
8
+ async function s(s, c = {}) {
9
+ let l = s.getSolver({
10
+ chainId: c.chainId,
11
+ solverId: c.solverId
12
+ });
13
+ r(l, "enigma", "getNotionalCapPage");
14
+ let u = c.limit ?? 100, d = c.offset ?? 0;
15
+ if (!Number.isInteger(u) || u < 1 || u > 100 || !Number.isInteger(d) || d < 0) throw new t("validation", "INVALID_NOTIONAL_CAP_PAGE", "limit must be an integer from 1 to 100 and offset a non-negative integer.");
16
+ try {
17
+ let e = (await n({
18
+ limit: u,
19
+ offset: d
20
+ }, { baseURL: l.url })).data, t = Array.isArray(e.symbols) ? e.symbols : [];
21
+ return {
22
+ count: o(e.count),
23
+ totalOpenInterest: o(e.total_open_interest),
24
+ totalUsed: o(e.total_used),
25
+ symbols: t.map(i)
26
+ };
27
+ } catch (n) {
28
+ throw n instanceof t ? n : a(n) ? e.fromAxios(n, {
29
+ code: "FETCH_NOTIONAL_CAP_PAGE_FAILED",
30
+ baseURL: l.url
31
+ }) : new t("api", "FETCH_NOTIONAL_CAP_PAGE_FAILED", `Failed to fetch notional caps: ${n instanceof Error ? n.message : String(n)}`, { cause: n instanceof Error ? n : void 0 });
32
+ }
33
+ }
34
+ //#endregion
35
+ export { s as getNotionalCapPage };
36
+
37
+ //# sourceMappingURL=get-notional-cap-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-notional-cap-page.js","names":[],"sources":["../../../src/solvers/notional-cap/get-notional-cap-page.ts"],"sourcesContent":["import { toFiniteNumber } from \"@symmio/utils/number\";\nimport { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { assertSolverKind } from \"../assert-solver-kind\";\nimport { getNotionalCap } from \"../types/generated/enigma-solver\";\nimport { toEnigmaNotionalCap } from \"./adapters\";\nimport type { EnigmaNotionalCap } from \"./types\";\n\n/**\n * Parameters for {@link getNotionalCapPage}.\n * Paging is optional; omit it for the first 100 rows. Totals cover only that page.\n * @example\n * const parameters: GetNotionalCapPageParameters = { chainId: 42161, limit: 50, offset: 100 };\n */\nexport type GetNotionalCapPageParameters = Compute<\n ReadSolverParameter & {\n /** Maximum rows in this page (1–100, default 100). */\n limit?: number;\n /** Zero-based row offset (default 0). */\n offset?: number;\n }\n>;\n\n/**\n * One page of normalized caps and its aggregate totals in float dollars.\n * Missing numeric wire fields are zero, matching the existing cap API.\n * @example\n * const page: GetNotionalCapPageReturnType = await getNotionalCapPage(config, { offset: 100 });\n * console.log(page.symbols, page.totalUsed);\n */\nexport interface GetNotionalCapPageReturnType {\n /** Number of symbols the solver returned. */\n count: number;\n /** Σ `openInterest` across this page (dollars). */\n totalOpenInterest: number;\n /** Σ `used` across this page (dollars). */\n totalUsed: number;\n /** Per-symbol rows. `/notional_cap` (list) is Enigma-only, so rows are always Enigma-shaped. */\n symbols: EnigmaNotionalCap[];\n}\n\n/**\n * Fetch one Enigma notional-cap page, with page-only totals in float dollars.\n * The live endpoint accepts at most 100 rows despite the generated spec's 500.\n * Missing numeric fields retain the existing zero fallback.\n * @param config - SDK configuration selecting the deployment.\n * @param parameters - Chain, solver and optional limit/offset.\n * @returns Normalized rows and totals for this page only.\n * @throws {SymmError} For invalid paging or an unsupported solver/chain.\n * @throws {SymmApiError} When the upstream request fails.\n * @example\n * ```ts\n * const page = await getNotionalCapPage(config, { limit: 100, offset: 100 });\n * console.log(page.totalUsed, page.symbols);\n * ```\n */\nexport async function getNotionalCapPage(\n config: Config,\n parameters: GetNotionalCapPageParameters = {},\n): Promise<GetNotionalCapPageReturnType> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n assertSolverKind(solver, \"enigma\", \"getNotionalCapPage\");\n const limit = parameters.limit ?? 100;\n const offset = parameters.offset ?? 0;\n if (!Number.isInteger(limit) || limit < 1 || limit > 100 || !Number.isInteger(offset) || offset < 0) {\n throw new SymmError(\n \"validation\",\n \"INVALID_NOTIONAL_CAP_PAGE\",\n \"limit must be an integer from 1 to 100 and offset a non-negative integer.\",\n );\n }\n try {\n const response = await getNotionalCap({ limit, offset }, { baseURL: solver.url });\n const r = response.data as Record<string, unknown>;\n const rawSymbols = Array.isArray(r.symbols) ? (r.symbols as Parameters<typeof toEnigmaNotionalCap>[0][]) : [];\n return {\n count: toFiniteNumber(r.count as number | string | undefined),\n totalOpenInterest: toFiniteNumber(r.total_open_interest as number | string | undefined),\n totalUsed: toFiniteNumber(r.total_used as number | string | undefined),\n symbols: rawSymbols.map(toEnigmaNotionalCap),\n };\n } catch (err) {\n if (err instanceof SymmError) throw err;\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_NOTIONAL_CAP_PAGE_FAILED\", baseURL: solver.url });\n }\n throw new SymmError(\n \"api\",\n \"FETCH_NOTIONAL_CAP_PAGE_FAILED\",\n `Failed to fetch notional caps: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;;AA0DA,eAAsB,EACpB,GACA,IAA2C,CAAC,GACL;CACvC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAC9F,EAAiB,GAAQ,UAAU,oBAAoB;CACvD,IAAM,IAAQ,EAAW,SAAS,KAC5B,IAAS,EAAW,UAAU;CACpC,IAAI,CAAC,OAAO,UAAU,CAAK,KAAK,IAAQ,KAAK,IAAQ,OAAO,CAAC,OAAO,UAAU,CAAM,KAAK,IAAS,GAChG,MAAM,IAAI,EACR,cACA,6BACA,2EACF;CAEF,IAAI;EAEF,IAAM,KAAI,MADa,EAAe;GAAE;GAAO;EAAO,GAAG,EAAE,SAAS,EAAO,IAAI,CAAC,GAC7D,MACb,IAAa,MAAM,QAAQ,EAAE,OAAO,IAAK,EAAE,UAA0D,CAAC;EAC5G,OAAO;GACL,OAAO,EAAe,EAAE,KAAoC;GAC5D,mBAAmB,EAAe,EAAE,mBAAkD;GACtF,WAAW,EAAe,EAAE,UAAyC;GACrE,SAAS,EAAW,IAAI,CAAmB;EAC7C;CACF,SAAS,GAAK;EAKZ,MAJI,aAAe,IAAiB,IAChC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAAkC,SAAS,EAAO;EAAI,CAAC,IAE7F,IAAI,EACR,OACA,kCACA,kCAAkC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KACjF,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
@@ -1,9 +1,11 @@
1
1
  export * from './check-notional-cap.js';
2
2
  export * from './get-notional-cap-all.js';
3
3
  export * from './get-notional-cap-by-symbol-id.js';
4
+ export * from './get-notional-cap-page.js';
4
5
  export * from './get-open-interest-by-symbol-id.js';
5
6
  export * from './query.js';
6
7
  export * from './query-all.js';
7
8
  export * from './query-open-interest.js';
9
+ export * from './query-page.js';
8
10
  export * from './types.js';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solvers/notional-cap/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solvers/notional-cap/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,45 @@
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 { GetNotionalCapPageParameters, GetNotionalCapPageReturnType } from './get-notional-cap-page.js';
5
+ /**
6
+ * One page of normalized cap rows and page-only totals resolved by the query.
7
+ * @example const page: GetNotionalCapPageData = await getNotionalCapPage(config, {});
8
+ */
9
+ export type GetNotionalCapPageData = GetNotionalCapPageReturnType;
10
+ /** Build a deployment- and page-specific query key.
11
+ * @param options - Paging and deployment identity.
12
+ * @returns A stable query-key tuple.
13
+ * @throws Does not throw for valid options.
14
+ * @example getNotionalCapPageQueryKey({ limit: 100, offset: 100 });
15
+ */
16
+ export declare function getNotionalCapPageQueryKey(options: Compute<GetNotionalCapPageParameters & ConfigKeyParameter>): readonly ["getNotionalCapPage", Record<string, unknown>];
17
+ /**
18
+ * Stable tuple identifying a page and its deployment in the query cache.
19
+ * @example const key: GetNotionalCapPageQueryKey = getNotionalCapPageQueryKey({ offset: 100 });
20
+ */
21
+ export type GetNotionalCapPageQueryKey = ReturnType<typeof getNotionalCapPageQueryKey>;
22
+ /**
23
+ * Page/deployment inputs and TanStack Query overrides for the page read.
24
+ * @example const options: GetNotionalCapPageOptions = { limit: 50, query: { enabled: false } };
25
+ */
26
+ export type GetNotionalCapPageOptions = Compute<GetNotionalCapPageParameters & QueryParameter<GetNotionalCapPageData, Error, GetNotionalCapPageData, GetNotionalCapPageQueryKey>>;
27
+ /**
28
+ * Executable query options with a page-specific key and normalized cap result.
29
+ * @example const query: GetNotionalCapPageQueryOptions = getNotionalCapPageQueryOptions(config, { offset: 100 });
30
+ */
31
+ export type GetNotionalCapPageQueryOptions = SymmioQueryOptions<GetNotionalCapPageData, Error, GetNotionalCapPageData, GetNotionalCapPageQueryKey>;
32
+ /**
33
+ * Build TanStack Query options for one notional-cap page.
34
+ * @param config - SDK configuration.
35
+ * @param options - Paging, deployment and query overrides.
36
+ * @returns Options whose key includes the page and deployment identity.
37
+ * @throws {SymmError} When configuration cannot be resolved; the query function propagates action errors.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * useQuery(getNotionalCapPageQueryOptions(config, {}));
42
+ * ```
43
+ */
44
+ export declare function getNotionalCapPageQueryOptions(config: Config, options?: GetNotionalCapPageOptions): GetNotionalCapPageQueryOptions;
45
+ //# sourceMappingURL=query-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-page.d.ts","sourceRoot":"","sources":["../../../src/solvers/notional-cap/query-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EAClC,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,4BAA4B,GAAG,kBAAkB,CAAC,4DAE7G;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEvF;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,4BAA4B,GAC1B,cAAc,CAAC,sBAAsB,EAAE,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,CAAC,CACpG,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,kBAAkB,CAC7D,sBAAsB,EACtB,KAAK,EACL,sBAAsB,EACtB,0BAA0B,CAC3B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,yBAA8B,GACtC,8BAA8B,CAgBhC"}
@@ -0,0 +1,26 @@
1
+ import { filterQueryOptions as e } from "../../shared/utils/query.js";
2
+ import { getNotionalCapPage as t } from "./get-notional-cap-page.js";
3
+ //#region src/solvers/notional-cap/query-page.ts
4
+ function n(t) {
5
+ return ["getNotionalCapPage", e(t)];
6
+ }
7
+ function r(e, r = {}) {
8
+ return {
9
+ ...r.query,
10
+ queryKey: n({
11
+ ...r,
12
+ configKey: e.getChainConfigKey(r.chainId)
13
+ }),
14
+ enabled: r.query?.enabled ?? !0,
15
+ queryFn: () => t(e, {
16
+ chainId: r.chainId,
17
+ solverId: r.solverId,
18
+ limit: r.limit,
19
+ offset: r.offset
20
+ })
21
+ };
22
+ }
23
+ //#endregion
24
+ export { n as getNotionalCapPageQueryKey, r as getNotionalCapPageQueryOptions };
25
+
26
+ //# sourceMappingURL=query-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-page.js","names":[],"sources":["../../../src/solvers/notional-cap/query-page.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 getNotionalCapPage,\n type GetNotionalCapPageParameters,\n type GetNotionalCapPageReturnType,\n} from \"./get-notional-cap-page\";\n\n/**\n * One page of normalized cap rows and page-only totals resolved by the query.\n * @example const page: GetNotionalCapPageData = await getNotionalCapPage(config, {});\n */\nexport type GetNotionalCapPageData = GetNotionalCapPageReturnType;\n\n/** Build a deployment- and page-specific query key.\n * @param options - Paging and deployment identity.\n * @returns A stable query-key tuple.\n * @throws Does not throw for valid options.\n * @example getNotionalCapPageQueryKey({ limit: 100, offset: 100 });\n */\nexport function getNotionalCapPageQueryKey(options: Compute<GetNotionalCapPageParameters & ConfigKeyParameter>) {\n return [\"getNotionalCapPage\", filterQueryOptions(options)] as const;\n}\n\n/**\n * Stable tuple identifying a page and its deployment in the query cache.\n * @example const key: GetNotionalCapPageQueryKey = getNotionalCapPageQueryKey({ offset: 100 });\n */\nexport type GetNotionalCapPageQueryKey = ReturnType<typeof getNotionalCapPageQueryKey>;\n\n/**\n * Page/deployment inputs and TanStack Query overrides for the page read.\n * @example const options: GetNotionalCapPageOptions = { limit: 50, query: { enabled: false } };\n */\nexport type GetNotionalCapPageOptions = Compute<\n GetNotionalCapPageParameters &\n QueryParameter<GetNotionalCapPageData, Error, GetNotionalCapPageData, GetNotionalCapPageQueryKey>\n>;\n\n/**\n * Executable query options with a page-specific key and normalized cap result.\n * @example const query: GetNotionalCapPageQueryOptions = getNotionalCapPageQueryOptions(config, { offset: 100 });\n */\nexport type GetNotionalCapPageQueryOptions = SymmioQueryOptions<\n GetNotionalCapPageData,\n Error,\n GetNotionalCapPageData,\n GetNotionalCapPageQueryKey\n>;\n\n/**\n * Build TanStack Query options for one notional-cap page.\n * @param config - SDK configuration.\n * @param options - Paging, deployment and query overrides.\n * @returns Options whose key includes the page and deployment identity.\n * @throws {SymmError} When configuration cannot be resolved; the query function propagates action errors.\n *\n * @example\n * ```ts\n * useQuery(getNotionalCapPageQueryOptions(config, {}));\n * ```\n */\nexport function getNotionalCapPageQueryOptions(\n config: Config,\n options: GetNotionalCapPageOptions = {},\n): GetNotionalCapPageQueryOptions {\n return {\n ...options.query,\n queryKey: getNotionalCapPageQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: options.query?.enabled ?? true,\n queryFn: () =>\n getNotionalCapPage(config, {\n chainId: options.chainId,\n solverId: options.solverId,\n limit: options.limit,\n offset: options.offset,\n }),\n };\n}\n"],"mappings":";;;AAsBA,SAAgB,EAA2B,GAAqE;CAC9G,OAAO,CAAC,sBAAsB,EAAmB,CAAO,CAAC;AAC3D;AAwCA,SAAgB,EACd,GACA,IAAqC,CAAC,GACN;CAChC,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAA2B;GACnC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,SAAS,EAAQ,OAAO,WAAW;EACnC,eACE,EAAmB,GAAQ;GACzB,SAAS,EAAQ;GACjB,UAAU,EAAQ;GAClB,OAAO,EAAQ;GACf,QAAQ,EAAQ;EAClB,CAAC;CACL;AACF"}