@n1xyz/nord-ts 0.1.6 → 0.1.8

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 (85) hide show
  1. package/dist/actions.d.ts +57 -0
  2. package/dist/actions.js +186 -0
  3. package/dist/bundle.js +79181 -0
  4. package/dist/{nord/client → client}/Nord.d.ts +90 -107
  5. package/dist/{nord/client → client}/Nord.js +157 -218
  6. package/dist/{nord/client → client}/NordAdmin.d.ts +68 -102
  7. package/dist/{nord/client → client}/NordAdmin.js +109 -140
  8. package/dist/{nord/client → client}/NordUser.d.ts +86 -98
  9. package/dist/{nord/client → client}/NordUser.js +204 -271
  10. package/dist/const.js +5 -8
  11. package/dist/{nord/utils/NordError.js → error.js} +7 -5
  12. package/dist/gen/nord_pb.js +88 -92
  13. package/dist/gen/openapi.d.ts +39 -0
  14. package/dist/gen/openapi.js +1 -2
  15. package/dist/index.d.ts +6 -1
  16. package/dist/index.js +10 -21
  17. package/dist/types.d.ts +5 -50
  18. package/dist/types.js +21 -83
  19. package/dist/utils.d.ts +8 -11
  20. package/dist/utils.js +55 -90
  21. package/dist/websocket/NordWebSocketClient.js +12 -17
  22. package/dist/{nord/models → websocket}/Subscriber.d.ts +1 -1
  23. package/dist/{nord/models → websocket}/Subscriber.js +6 -7
  24. package/dist/websocket/events.js +1 -2
  25. package/dist/websocket/index.d.ts +19 -2
  26. package/dist/websocket/index.js +80 -5
  27. package/package.json +2 -3
  28. package/dist/api/client.d.ts +0 -14
  29. package/dist/api/client.js +0 -45
  30. package/dist/bridge/client.d.ts +0 -151
  31. package/dist/bridge/client.js +0 -434
  32. package/dist/bridge/const.d.ts +0 -23
  33. package/dist/bridge/const.js +0 -47
  34. package/dist/bridge/index.d.ts +0 -4
  35. package/dist/bridge/index.js +0 -23
  36. package/dist/bridge/types.d.ts +0 -120
  37. package/dist/bridge/types.js +0 -18
  38. package/dist/bridge/utils.d.ts +0 -64
  39. package/dist/bridge/utils.js +0 -131
  40. package/dist/gen/common.d.ts +0 -68
  41. package/dist/gen/common.js +0 -215
  42. package/dist/gen/nord.d.ts +0 -882
  43. package/dist/gen/nord.js +0 -6520
  44. package/dist/idl/bridge.d.ts +0 -569
  45. package/dist/idl/bridge.js +0 -8
  46. package/dist/idl/bridge.json +0 -1506
  47. package/dist/idl/index.d.ts +0 -607
  48. package/dist/idl/index.js +0 -8
  49. package/dist/nord/api/actions.d.ts +0 -126
  50. package/dist/nord/api/actions.js +0 -397
  51. package/dist/nord/api/core.d.ts +0 -16
  52. package/dist/nord/api/core.js +0 -81
  53. package/dist/nord/api/market.d.ts +0 -36
  54. package/dist/nord/api/market.js +0 -96
  55. package/dist/nord/api/metrics.d.ts +0 -67
  56. package/dist/nord/api/metrics.js +0 -229
  57. package/dist/nord/api/queries.d.ts +0 -46
  58. package/dist/nord/api/queries.js +0 -109
  59. package/dist/nord/api/triggers.d.ts +0 -7
  60. package/dist/nord/api/triggers.js +0 -38
  61. package/dist/nord/client/NordClient.d.ts +0 -33
  62. package/dist/nord/client/NordClient.js +0 -45
  63. package/dist/nord/index.d.ts +0 -11
  64. package/dist/nord/index.js +0 -36
  65. package/src/const.ts +0 -34
  66. package/src/gen/.gitkeep +0 -0
  67. package/src/gen/nord_pb.ts +0 -5053
  68. package/src/gen/openapi.ts +0 -2864
  69. package/src/index.ts +0 -5
  70. package/src/nord/api/actions.ts +0 -648
  71. package/src/nord/api/core.ts +0 -96
  72. package/src/nord/api/metrics.ts +0 -269
  73. package/src/nord/client/Nord.ts +0 -937
  74. package/src/nord/client/NordAdmin.ts +0 -514
  75. package/src/nord/client/NordClient.ts +0 -79
  76. package/src/nord/client/NordUser.ts +0 -1211
  77. package/src/nord/index.ts +0 -25
  78. package/src/nord/models/Subscriber.ts +0 -56
  79. package/src/nord/utils/NordError.ts +0 -76
  80. package/src/types.ts +0 -377
  81. package/src/utils.ts +0 -269
  82. package/src/websocket/NordWebSocketClient.ts +0 -316
  83. package/src/websocket/events.ts +0 -31
  84. package/src/websocket/index.ts +0 -2
  85. /package/dist/{nord/utils/NordError.d.ts → error.d.ts} +0 -0
@@ -1,56 +1,29 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Nord = void 0;
40
- const proton_1 = require("@n1xyz/proton");
41
- const web3_js_1 = require("@solana/web3.js");
42
- const events_1 = require("events");
43
- const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
44
- const proto = __importStar(require("../../gen/nord_pb"));
45
- const types_1 = require("../../types");
46
- const utils = __importStar(require("../../utils"));
47
- const core = __importStar(require("../api/core"));
48
- const metrics = __importStar(require("../api/metrics"));
49
- const NordError_1 = require("../utils/NordError");
1
+ import { ProtonClient } from "@n1xyz/proton";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { EventEmitter } from "events";
4
+ import createClient from "openapi-fetch";
5
+ import * as proto from "../gen/nord_pb";
6
+ import * as utils from "../utils";
7
+ import { initWebSocketClient } from "../websocket";
8
+ import { NordError } from "../error";
50
9
  /**
51
10
  * Main Nord client class for interacting with the Nord API
52
11
  */
53
- class Nord {
12
+ export class Nord {
13
+ /** Base URL for the Nord web server */
14
+ webServerUrl;
15
+ /** Solana RPC URL */
16
+ solanaConnection;
17
+ /** Available markets */
18
+ markets = [];
19
+ /** Available tokens */
20
+ tokens = [];
21
+ /** Map of symbol to market_id */
22
+ symbolToMarketId = new Map();
23
+ /** Proton client for proton related operations */
24
+ protonClient;
25
+ /** HTTP client for Nord operations */
26
+ httpClient;
54
27
  /**
55
28
  * Create a new Nord client
56
29
  *
@@ -59,22 +32,18 @@ class Nord {
59
32
  * @param config.solanaUrl - Solana cluster URL
60
33
  * @throws {Error} If required configuration is missing
61
34
  */
62
- constructor({ solanaUrl, webServerUrl, protonClient, }) {
63
- /** Available markets */
64
- this.markets = [];
65
- /** Available tokens */
66
- this.tokens = [];
67
- /** Map of symbol to market_id */
68
- this.symbolToMarketId = new Map();
35
+ constructor({ solanaConnection, webServerUrl, protonClient, }) {
69
36
  this.webServerUrl = webServerUrl;
70
- this.solanaUrl = solanaUrl;
37
+ this.solanaConnection = solanaConnection;
71
38
  this.protonClient = protonClient;
72
- this.httpClient = (0, openapi_fetch_1.default)({ baseUrl: webServerUrl });
39
+ this.httpClient = createClient({ baseUrl: webServerUrl });
73
40
  }
74
41
  /**
75
42
  * Create a WebSocket client with specific subscriptions
76
43
  *
77
- * @param options - Subscription options that specify which data streams to subscribe to
44
+ * @param trades - Market symbols to subscribe to for trade updates
45
+ * @param deltas - Market symbols to subscribe to for orderbook delta updates
46
+ * @param accounts - Account IDs to subscribe to for account updates
78
47
  * @returns A new WebSocket client with the requested subscriptions
79
48
  * @throws {NordError} If invalid subscription options are provided
80
49
  *
@@ -92,45 +61,45 @@ class Nord {
92
61
  * trades: ["BTCUSDC", "ETHUSDC"]
93
62
  * });
94
63
  */
95
- createWebSocketClient(options) {
64
+ createWebSocketClient({ trades, deltas, accounts, }) {
96
65
  const subscriptions = [];
97
66
  // Add trade subscriptions
98
- if (options.trades && options.trades.length > 0) {
99
- options.trades.forEach((symbol) => {
67
+ if (trades && trades.length > 0) {
68
+ trades.forEach((symbol) => {
100
69
  subscriptions.push(`trades@${symbol}`);
101
70
  });
102
71
  }
103
72
  // Add delta subscriptions
104
- if (options.deltas && options.deltas.length > 0) {
105
- options.deltas.forEach((symbol) => {
73
+ if (deltas && deltas.length > 0) {
74
+ deltas.forEach((symbol) => {
106
75
  subscriptions.push(`deltas@${symbol}`);
107
76
  });
108
77
  }
109
78
  // Add account subscriptions
110
- if (options.accounts && options.accounts.length > 0) {
111
- options.accounts.forEach((accountId) => {
79
+ if (accounts && accounts.length > 0) {
80
+ accounts.forEach((accountId) => {
112
81
  if (isNaN(accountId) || accountId <= 0) {
113
- throw new NordError_1.NordError(`Invalid account ID: ${accountId}. Must be a positive number.`);
82
+ throw new NordError(`Invalid account ID: ${accountId}. Must be a positive number.`);
114
83
  }
115
84
  subscriptions.push(`account@${accountId}`);
116
85
  });
117
86
  }
118
87
  // Validate that at least one subscription was provided
119
88
  if (subscriptions.length === 0) {
120
- throw new NordError_1.NordError("At least one subscription must be provided");
89
+ throw new NordError("At least one subscription must be provided");
121
90
  }
122
91
  // Create and return a new WebSocket client
123
- return core.initWebSocketClient(this.webServerUrl, subscriptions);
92
+ return initWebSocketClient(this.webServerUrl, subscriptions);
124
93
  }
125
94
  async GET(path, options) {
126
95
  const r = await this.httpClient.GET(path, options);
127
96
  if (r.error) {
128
- throw new NordError_1.NordError(`failed to GET ${path}`, { cause: r.error });
97
+ throw new NordError(`failed to GET ${path}`, { cause: r.error });
129
98
  }
130
99
  if (r.data === undefined) {
131
100
  // this should never happen, but the type checker seems unhappy.
132
101
  // if we catch this we'll need to debug accordingly.
133
- throw new NordError_1.NordError("internal assertion violation", { cause: r });
102
+ throw new NordError("internal assertion violation", { cause: r });
134
103
  }
135
104
  return r.data;
136
105
  }
@@ -152,6 +121,15 @@ class Nord {
152
121
  async getActionNonce() {
153
122
  return await this.GET("/event/last-acked-nonce", {});
154
123
  }
124
+ /**
125
+ * Get the admin list from the Nord server
126
+ *
127
+ * @returns List of admin registration keys paired with their ACL role mask
128
+ * @throws {NordError} If the request fails
129
+ */
130
+ async getAdminList() {
131
+ return await this.GET("/admin", {});
132
+ }
155
133
  /**
156
134
  * Fetch information about Nord markets and tokens
157
135
  *
@@ -169,9 +147,13 @@ class Nord {
169
147
  });
170
148
  }
171
149
  catch (error) {
172
- throw new NordError_1.NordError("Failed to fetch Nord info", { cause: error });
150
+ throw new NordError("Failed to fetch Nord info", { cause: error });
173
151
  }
174
152
  }
153
+ /** @deprecated use Nord.new */
154
+ static async initNord(x) {
155
+ return await Nord.new(x);
156
+ }
175
157
  /**
176
158
  * Initialize a new Nord client
177
159
  *
@@ -182,19 +164,15 @@ class Nord {
182
164
  * @returns Initialized Nord client
183
165
  * @throws {NordError} If initialization fails
184
166
  */
185
- static async initNord({ app, solanaUrl, webServerUrl, protonUrl, }) {
186
- // TODO: we should parametrize the connectionn not have it done here.
187
- // this is a dogshit api, only here to be compatible with the shitty
188
- // vibecoded code and not break zero one team's workflow.
189
- const connection = new web3_js_1.Connection(solanaUrl, { commitment: "confirmed" });
190
- const protonClient = await proton_1.ProtonClient.init({
167
+ static async new({ app, solanaConnection, webServerUrl, protonUrl, }) {
168
+ const protonClient = await ProtonClient.init({
191
169
  protonUrl: protonUrl ?? webServerUrl,
192
- app: new web3_js_1.PublicKey(app),
193
- solConn: connection,
170
+ app: new PublicKey(app),
171
+ solConn: solanaConnection,
194
172
  });
195
173
  const nord = new Nord({
196
174
  protonClient,
197
- solanaUrl,
175
+ solanaConnection,
198
176
  webServerUrl,
199
177
  });
200
178
  await nord.init();
@@ -210,28 +188,28 @@ class Nord {
210
188
  /**
211
189
  * Query a specific action
212
190
  *
213
- * @param query - Action query parameters
191
+ * @param actionId - Action identifier to fetch
214
192
  * @returns Action response
215
193
  * @throws {NordError} If the request fails
216
194
  */
217
- async queryAction({ action_id, }) {
195
+ async queryAction({ actionId, }) {
218
196
  return ((await this.queryRecentActions({
219
- from: action_id,
220
- to: action_id,
197
+ from: actionId,
198
+ to: actionId,
221
199
  }))[0] ?? null);
222
200
  }
223
201
  /**
224
202
  * Query recent actions
225
203
  *
226
- * @param from - Starting action index
227
- * @param to - Ending action index
204
+ * @param from - Starting action index (inclusive)
205
+ * @param to - Ending action index (inclusive)
228
206
  * @returns Actions response
229
207
  * @throws {NordError} If the request fails
230
208
  */
231
- async queryRecentActions(query) {
209
+ async queryRecentActions({ from, to, }) {
232
210
  const xs = await this.GET("/action", {
233
211
  params: {
234
- query,
212
+ query: { from, to },
235
213
  },
236
214
  });
237
215
  return xs.map((x) => ({
@@ -249,66 +227,6 @@ class Nord {
249
227
  async getLastActionId() {
250
228
  return await this.GET("/action/last-executed-id", {});
251
229
  }
252
- /**
253
- * Fetch aggregate metrics from the Nord API
254
- *
255
- * @param txPeakTpsPeriod - Period for peak TPS calculation
256
- * @param txPeakTpsPeriodUnit - Unit for peak TPS period
257
- * @returns Aggregate metrics
258
- * @throws {NordError} If the request fails
259
- */
260
- async aggregateMetrics(txPeakTpsPeriod = 1, txPeakTpsPeriodUnit = types_1.PeakTpsPeriodUnit.Day) {
261
- return metrics.aggregateMetrics(this.webServerUrl, txPeakTpsPeriod, txPeakTpsPeriodUnit);
262
- }
263
- /**
264
- * Get current transactions per second
265
- *
266
- * @param period - Time period for the query
267
- * @returns Current TPS value
268
- * @throws {NordError} If the request fails
269
- */
270
- async getCurrentTps(period = "1m") {
271
- return metrics.getCurrentTps(this.webServerUrl, period);
272
- }
273
- /**
274
- * Get peak transactions per second
275
- *
276
- * @param period - Time period for the query
277
- * @returns Peak TPS value
278
- * @throws {NordError} If the request fails
279
- */
280
- async getPeakTps(period = "24h") {
281
- return metrics.getPeakTps(this.webServerUrl, period);
282
- }
283
- /**
284
- * Get median transaction latency
285
- *
286
- * @param period - Time period for the query
287
- * @returns Median latency in milliseconds
288
- * @throws {NordError} If the request fails
289
- */
290
- async getMedianLatency(period = "1m") {
291
- return metrics.getMedianLatency(this.webServerUrl, period);
292
- }
293
- /**
294
- * Get total transaction count
295
- *
296
- * @returns Total transaction count
297
- * @throws {NordError} If the request fails
298
- */
299
- async getTotalTransactions() {
300
- return metrics.getTotalTransactions(this.webServerUrl);
301
- }
302
- /**
303
- * Query Prometheus metrics
304
- *
305
- * @param params - Prometheus query parameters
306
- * @returns Query result as a number
307
- * @throws {NordError} If the request fails
308
- */
309
- async queryPrometheus(params) {
310
- return metrics.queryPrometheus(this.webServerUrl, params);
311
- }
312
230
  /**
313
231
  * Subscribe to orderbook updates for a market
314
232
  *
@@ -318,9 +236,9 @@ class Nord {
318
236
  */
319
237
  subscribeOrderbook(symbol) {
320
238
  if (!symbol || typeof symbol !== "string") {
321
- throw new NordError_1.NordError("Invalid market symbol");
239
+ throw new NordError("Invalid market symbol");
322
240
  }
323
- const subscription = new events_1.EventEmitter();
241
+ const subscription = new EventEmitter();
324
242
  const wsClient = this.createWebSocketClient({
325
243
  deltas: [symbol],
326
244
  });
@@ -346,9 +264,9 @@ class Nord {
346
264
  */
347
265
  subscribeTrades(symbol) {
348
266
  if (!symbol || typeof symbol !== "string") {
349
- throw new NordError_1.NordError("Invalid market symbol");
267
+ throw new NordError("Invalid market symbol");
350
268
  }
351
- const subscription = new events_1.EventEmitter();
269
+ const subscription = new EventEmitter();
352
270
  const wsClient = this.createWebSocketClient({
353
271
  trades: [symbol],
354
272
  });
@@ -374,9 +292,9 @@ class Nord {
374
292
  */
375
293
  subscribeAccount(accountId) {
376
294
  if (isNaN(accountId) || accountId <= 0) {
377
- throw new NordError_1.NordError("Invalid account ID");
295
+ throw new NordError("Invalid account ID");
378
296
  }
379
- const subscription = new events_1.EventEmitter();
297
+ const subscription = new EventEmitter();
380
298
  const wsClient = this.createWebSocketClient({
381
299
  accounts: [accountId],
382
300
  });
@@ -396,28 +314,35 @@ class Nord {
396
314
  /**
397
315
  * Get trades for a market
398
316
  *
399
- * @param query - Trades query parameters
317
+ * @param marketId - Market identifier to filter by
318
+ * @param takerId - Taker account identifier
319
+ * @param makerId - Maker account identifier
320
+ * @param takerSide - Side executed by the taker
321
+ * @param pageSize - Maximum number of trades to return
322
+ * @param since - RFC3339 timestamp to start from (inclusive)
323
+ * @param until - RFC3339 timestamp to end at (exclusive)
324
+ * @param pageId - Pagination cursor returned from a prior call
400
325
  * @returns Trades response
401
326
  * @throws {NordError} If the request fails
402
327
  */
403
- async getTrades(query) {
404
- if (query.sinceRcf3339 && !utils.isRfc3339(query.sinceRcf3339)) {
405
- throw new NordError_1.NordError(`Invalid RFC3339 timestamp: ${query.sinceRcf3339}`);
328
+ async getTrades({ marketId, takerId, makerId, takerSide, pageSize, since, until, startInclusive, }) {
329
+ if (since && !utils.isRfc3339(since)) {
330
+ throw new NordError(`Invalid RFC3339 timestamp: ${since}`);
406
331
  }
407
- if (query.untilRfc3339 && !utils.isRfc3339(query.untilRfc3339)) {
408
- throw new NordError_1.NordError(`Invalid RFC3339 timestamp: ${query.untilRfc3339}`);
332
+ if (until && !utils.isRfc3339(until)) {
333
+ throw new NordError(`Invalid RFC3339 timestamp: ${until}`);
409
334
  }
410
335
  return await this.GET("/trades", {
411
336
  params: {
412
337
  query: {
413
- takerId: query.takerId,
414
- makerId: query.makerId,
415
- marketId: query.marketId,
416
- pageSize: query.pageSize,
417
- takerSide: query.takerSide,
418
- since: query.sinceRcf3339,
419
- until: query.untilRfc3339,
420
- startInclusive: query.pageId,
338
+ takerId,
339
+ makerId,
340
+ marketId,
341
+ pageSize,
342
+ takerSide,
343
+ since,
344
+ until,
345
+ startInclusive,
421
346
  },
422
347
  },
423
348
  });
@@ -425,14 +350,14 @@ class Nord {
425
350
  /**
426
351
  * Get user account IDs
427
352
  *
428
- * @param query - User account IDs query parameters
353
+ * @param pubkey - User public key to query
429
354
  * @returns User account IDs response
430
355
  * @throws {NordError} If the request fails
431
356
  */
432
- async getUser(query) {
357
+ async getUser({ pubkey, }) {
433
358
  const r = await this.httpClient.GET("/user/{pubkey}", {
434
359
  params: {
435
- path: { pubkey: query.pubkey.toString() },
360
+ path: { pubkey: pubkey.toString() },
436
361
  },
437
362
  });
438
363
  if (r.response.status === 404) {
@@ -443,35 +368,36 @@ class Nord {
443
368
  /**
444
369
  * Get orderbook for a market
445
370
  *
446
- * @param query - Orderbook query parameters (either market_id or symbol must be provided)
371
+ * @param symbol - Market symbol to resolve into an id
372
+ * @param marketId - Market identifier
447
373
  * @returns Orderbook response
448
374
  * @throws {NordError} If the request fails or if the market symbol is unknown
449
375
  * @remarks It's recommended to initialize the Nord client using the static `initNord` method
450
376
  * to ensure market information is properly loaded before calling this method.
451
377
  */
452
- async getOrderbook(query) {
378
+ async getOrderbook({ symbol, marketId, }) {
453
379
  // If only symbol is provided, convert it to market_id
454
- let marketId;
455
- if (query.symbol && query.market_id === undefined) {
380
+ let _marketId;
381
+ if (symbol && marketId === undefined) {
456
382
  // If the map is empty, try to fetch market information first
457
383
  if (this.symbolToMarketId.size === 0) {
458
384
  await this.fetchNordInfo();
459
385
  }
460
- const id = this.symbolToMarketId.get(query.symbol);
386
+ const id = this.symbolToMarketId.get(symbol);
461
387
  if (id === undefined) {
462
- throw new NordError_1.NordError(`Unknown market symbol: ${query.symbol}`);
388
+ throw new NordError(`Unknown market symbol: ${symbol}`);
463
389
  }
464
- marketId = id;
390
+ _marketId = id;
465
391
  }
466
- else if (query.market_id !== undefined) {
467
- marketId = query.market_id;
392
+ else if (marketId !== undefined) {
393
+ _marketId = marketId;
468
394
  }
469
395
  else {
470
- throw new NordError_1.NordError("Either symbol or market_id must be provided for orderbook query");
396
+ throw new NordError("Either symbol or market_id must be provided for orderbook query");
471
397
  }
472
398
  return await this.GET("/market/{market_id}/orderbook", {
473
399
  params: {
474
- path: { market_id: marketId },
400
+ path: { market_id: _marketId },
475
401
  },
476
402
  });
477
403
  }
@@ -553,30 +479,34 @@ class Nord {
553
479
  * Get open orders for an account.
554
480
  *
555
481
  * @param accountId - Account id to query
556
- * @param query - Optional pagination parameters
482
+ * @param startInclusive - Pagination cursor (client order id) to resume from
483
+ * @param pageSize - Maximum number of orders to return
557
484
  * @returns Page of orders keyed by client order id
558
485
  * @throws {NordError} If the request fails
559
486
  */
560
- async getAccountOrders(accountId, query) {
487
+ async getAccountOrders(accountId, { startInclusive, pageSize, } = {}) {
561
488
  return await this.GET("/account/{account_id}/orders", {
562
489
  params: {
563
490
  path: { account_id: accountId },
564
491
  query: {
565
- startInclusive: query?.startInclusive,
566
- pageSize: query?.pageSize,
492
+ startInclusive,
493
+ pageSize,
567
494
  },
568
495
  },
569
496
  });
570
497
  }
571
498
  /**
572
499
  * List account fee tiers with pagination support.
500
+ *
501
+ * @param startInclusive - Account id cursor to resume from
502
+ * @param pageSize - Maximum number of entries to return
573
503
  */
574
- async getAccountsFeeTiers(query) {
504
+ async getAccountsFeeTiers({ startInclusive, pageSize, } = {}) {
575
505
  return await this.GET("/accounts/fee-tiers", {
576
506
  params: {
577
507
  query: {
578
- startInclusive: query?.startInclusive ?? undefined,
579
- pageSize: query?.pageSize ?? undefined,
508
+ startInclusive: startInclusive ?? undefined,
509
+ pageSize: pageSize ?? undefined,
580
510
  },
581
511
  },
582
512
  });
@@ -585,19 +515,22 @@ class Nord {
585
515
  * Get profit and loss history for an account
586
516
  *
587
517
  * @param accountId - Account ID to query
588
- * @param query - Optional time and pagination filters
518
+ * @param since - RFC3339 timestamp to start from (inclusive)
519
+ * @param until - RFC3339 timestamp to end at (exclusive)
520
+ * @param startInclusive - Pagination cursor to resume from
521
+ * @param pageSize - Maximum number of entries to return
589
522
  * @returns Page of PnL entries ordered from latest to oldest
590
523
  * @throws {NordError} If the request fails
591
524
  */
592
- async getAccountPnl(accountId, query) {
525
+ async getAccountPnl(accountId, { since, until, startInclusive, pageSize, } = {}) {
593
526
  return await this.GET("/account/{account_id}/pnl", {
594
527
  params: {
595
528
  path: { account_id: accountId },
596
529
  query: {
597
- since: query?.since,
598
- until: query?.until,
599
- startInclusive: query?.startInclusive,
600
- pageSize: query?.pageSize,
530
+ since,
531
+ until,
532
+ startInclusive,
533
+ pageSize,
601
534
  },
602
535
  },
603
536
  });
@@ -605,6 +538,9 @@ class Nord {
605
538
  /**
606
539
  * Get market statistics (alias for marketsStats for backward compatibility)
607
540
  *
541
+ *
542
+ * @param marketId - Market identifier
543
+ *
608
544
  * @returns Market statistics response
609
545
  */
610
546
  async getMarketStats({ marketId, }) {
@@ -617,7 +553,9 @@ class Nord {
617
553
  /**
618
554
  * Fetch the per-market fee quote for an account.
619
555
  *
620
- * @param params - Market id, fee kind, and account id to quote
556
+ * @param marketId - Market identifier
557
+ * @param feeKind - Fill role (maker/taker) to quote
558
+ * @param accountId - Account identifier to quote
621
559
  * @returns Fee in quote token units (negative means fee is charged)
622
560
  * @throws {NordError} If the request fails
623
561
  */
@@ -664,17 +602,18 @@ class Nord {
664
602
  * Get trade history for a specific order.
665
603
  *
666
604
  * @param orderId - Order identifier
667
- * @param query - Optional pagination parameters
605
+ * @param startInclusive - Trade pagination cursor
606
+ * @param pageSize - Maximum number of trades to return
668
607
  * @returns Page of trades associated with the order
669
608
  * @throws {NordError} If the request fails
670
609
  */
671
- async getOrderTrades(orderId, query) {
610
+ async getOrderTrades(orderId, { startInclusive, pageSize, } = {}) {
672
611
  return await this.GET("/order/{order_id}/trades", {
673
612
  params: {
674
613
  path: { order_id: orderId },
675
614
  query: {
676
- startInclusive: query?.startInclusive,
677
- pageSize: query?.pageSize,
615
+ startInclusive,
616
+ pageSize,
678
617
  },
679
618
  },
680
619
  });
@@ -692,13 +631,12 @@ class Nord {
692
631
  /**
693
632
  * Fetch active triggers for an account.
694
633
  *
695
- * @param params Optional parameters containing an explicit account id.
634
+ * @param accountId - Account identifier owning the triggers
696
635
  * @throws {NordError} If no account can be resolved or the request fails.
697
636
  */
698
- async getAccountTriggers(params) {
699
- const accountId = params?.accountId;
637
+ async getAccountTriggers({ accountId, } = {}) {
700
638
  if (accountId == null) {
701
- throw new NordError_1.NordError("Account ID is undefined. Make sure to call updateAccountId() before requesting triggers.");
639
+ throw new NordError("Account ID is undefined. Make sure to call updateAccountId() before requesting triggers.");
702
640
  }
703
641
  try {
704
642
  const triggers = await this.GET("/account/{account_id}/triggers", {
@@ -709,39 +647,40 @@ class Nord {
709
647
  return triggers ?? [];
710
648
  }
711
649
  catch (error) {
712
- throw new NordError_1.NordError("Failed to fetch account triggers", { cause: error });
650
+ throw new NordError("Failed to fetch account triggers", { cause: error });
713
651
  }
714
652
  }
715
653
  /**
716
654
  * Fetch trigger history for an account.
717
655
  *
718
- * @param params Optional parameters with account id and history query filters.
656
+ * @param accountId - Account identifier owning the triggers
657
+ * @param since - RFC3339 timestamp to start from (inclusive)
658
+ * @param until - RFC3339 timestamp to end at (exclusive)
659
+ * @param pageSize - Maximum number of entries to return
660
+ * @param startInclusive - Pagination cursor to resume from
719
661
  * @throws {NordError} If no account can be resolved or the request fails.
720
662
  */
721
- async getAccountTriggerHistory(params) {
722
- const accountId = params?.accountId;
663
+ async getAccountTriggerHistory({ accountId, since, until, pageSize, startInclusive, }) {
723
664
  if (accountId == null) {
724
- throw new NordError_1.NordError("Account ID is undefined. Make sure to call updateAccountId() before requesting trigger history.");
665
+ throw new NordError("Account ID is undefined. Make sure to call updateAccountId() before requesting trigger history.");
725
666
  }
726
- const { accountId: _, ...query } = params;
727
667
  try {
728
668
  return await this.GET("/account/{account_id}/triggers/history", {
729
669
  params: {
730
670
  path: { account_id: accountId },
731
671
  query: {
732
- since: query.since,
733
- until: query.until,
734
- pageSize: query.pageSize,
735
- startInclusive: query.startInclusive,
672
+ since,
673
+ until,
674
+ pageSize,
675
+ startInclusive,
736
676
  },
737
677
  },
738
678
  });
739
679
  }
740
680
  catch (error) {
741
- throw new NordError_1.NordError("Failed to fetch account trigger history", {
681
+ throw new NordError("Failed to fetch account trigger history", {
742
682
  cause: error,
743
683
  });
744
684
  }
745
685
  }
746
686
  }
747
- exports.Nord = Nord;