@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,26 +1,17 @@
1
1
  import { ProtonClient } from "@n1xyz/proton";
2
- import { PublicKey } from "@solana/web3.js";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
3
  import { EventEmitter } from "events";
4
- import { Account, AccountPnlPage, AccountPnlQuery, ActionResponse, AggregateMetrics, MarketsInfo, Market, MarketStats, NordConfig, OrderbookQuery, OrderbookResponse, FeeTierConfig, PeakTpsPeriodUnit, Token, TradesResponse, User, AccountTriggerInfo, HistoryTriggerQuery, TriggerHistoryPage, FeeTierId, AccountFeeTierPage, PageResultStringOrderInfo, PageResultStringTrade, OrderInfoFromApi, TokenStats, FillRole } from "../../types";
5
- import { NordWebSocketClient } from "../../websocket/index";
6
- import { OrderbookSubscription, TradeSubscription } from "../models/Subscriber";
4
+ import { Client } from "openapi-fetch";
5
+ import type { paths } from "../gen/openapi.ts";
6
+ import { Account, AccountPnlPage, AccountPnlQuery, ActionResponse, MarketsInfo, Market, MarketStats, NordConfig, OrderbookQuery, OrderbookResponse, FeeTierConfig, Token, TradesResponse, User, AccountTriggerInfo, HistoryTriggerQuery, TriggerHistoryPage, FeeTierId, AccountFeeTierPage, PageResultStringOrderInfo, PageResultStringTrade, OrderInfoFromApi, TokenStats, FillRole, AdminInfo } from "../types";
7
+ import { NordWebSocketClient } from "../websocket/index";
8
+ import { OrderbookSubscription, TradeSubscription } from "../websocket/Subscriber";
7
9
  /**
8
10
  * User subscription interface
9
11
  */
10
12
  export interface UserSubscription extends EventEmitter {
11
13
  close: () => void;
12
14
  }
13
- /**
14
- * WebSocket subscription options interface
15
- */
16
- export interface WebSocketSubscriptionOptions {
17
- /** Market symbols to subscribe to for trade updates */
18
- trades?: string[];
19
- /** Market symbols to subscribe to for orderbook delta updates */
20
- deltas?: string[];
21
- /** Account IDs to subscribe to for account updates */
22
- accounts?: number[];
23
- }
24
15
  /**
25
16
  * Main Nord client class for interacting with the Nord API
26
17
  */
@@ -28,7 +19,7 @@ export declare class Nord {
28
19
  /** Base URL for the Nord web server */
29
20
  readonly webServerUrl: string;
30
21
  /** Solana RPC URL */
31
- readonly solanaUrl: string;
22
+ readonly solanaConnection: Connection;
32
23
  /** Available markets */
33
24
  markets: Market[];
34
25
  /** Available tokens */
@@ -38,7 +29,7 @@ export declare class Nord {
38
29
  /** Proton client for proton related operations */
39
30
  protonClient: ProtonClient;
40
31
  /** HTTP client for Nord operations */
41
- private httpClient;
32
+ readonly httpClient: Client<paths>;
42
33
  /**
43
34
  * Create a new Nord client
44
35
  *
@@ -51,7 +42,9 @@ export declare class Nord {
51
42
  /**
52
43
  * Create a WebSocket client with specific subscriptions
53
44
  *
54
- * @param options - Subscription options that specify which data streams to subscribe to
45
+ * @param trades - Market symbols to subscribe to for trade updates
46
+ * @param deltas - Market symbols to subscribe to for orderbook delta updates
47
+ * @param accounts - Account IDs to subscribe to for account updates
55
48
  * @returns A new WebSocket client with the requested subscriptions
56
49
  * @throws {NordError} If invalid subscription options are provided
57
50
  *
@@ -69,7 +62,11 @@ export declare class Nord {
69
62
  * trades: ["BTCUSDC", "ETHUSDC"]
70
63
  * });
71
64
  */
72
- createWebSocketClient(options: WebSocketSubscriptionOptions): NordWebSocketClient;
65
+ createWebSocketClient({ trades, deltas, accounts, }: Readonly<{
66
+ trades?: string[];
67
+ deltas?: string[];
68
+ accounts?: number[];
69
+ }>): NordWebSocketClient;
73
70
  private GET;
74
71
  /**
75
72
  * Get the current timestamp from the Nord server
@@ -85,12 +82,21 @@ export declare class Nord {
85
82
  * @throws {NordError} If the request fails
86
83
  */
87
84
  getActionNonce(): Promise<number>;
85
+ /**
86
+ * Get the admin list from the Nord server
87
+ *
88
+ * @returns List of admin registration keys paired with their ACL role mask
89
+ * @throws {NordError} If the request fails
90
+ */
91
+ getAdminList(): Promise<Array<AdminInfo>>;
88
92
  /**
89
93
  * Fetch information about Nord markets and tokens
90
94
  *
91
95
  * @throws {NordError} If the request fails
92
96
  */
93
97
  fetchNordInfo(): Promise<void>;
98
+ /** @deprecated use Nord.new */
99
+ static initNord(x: Readonly<NordConfig>): Promise<Nord>;
94
100
  /**
95
101
  * Initialize a new Nord client
96
102
  *
@@ -101,7 +107,7 @@ export declare class Nord {
101
107
  * @returns Initialized Nord client
102
108
  * @throws {NordError} If initialization fails
103
109
  */
104
- static initNord({ app, solanaUrl, webServerUrl, protonUrl, }: Readonly<NordConfig>): Promise<Nord>;
110
+ static new({ app, solanaConnection, webServerUrl, protonUrl, }: Readonly<NordConfig>): Promise<Nord>;
105
111
  /**
106
112
  * Initialize the Nord client
107
113
  * @private
@@ -110,25 +116,25 @@ export declare class Nord {
110
116
  /**
111
117
  * Query a specific action
112
118
  *
113
- * @param query - Action query parameters
119
+ * @param actionId - Action identifier to fetch
114
120
  * @returns Action response
115
121
  * @throws {NordError} If the request fails
116
122
  */
117
- queryAction({ action_id, }: {
118
- action_id: number;
119
- }): Promise<ActionResponse | null>;
123
+ queryAction({ actionId, }: Readonly<{
124
+ actionId: number;
125
+ }>): Promise<ActionResponse | null>;
120
126
  /**
121
127
  * Query recent actions
122
128
  *
123
- * @param from - Starting action index
124
- * @param to - Ending action index
129
+ * @param from - Starting action index (inclusive)
130
+ * @param to - Ending action index (inclusive)
125
131
  * @returns Actions response
126
132
  * @throws {NordError} If the request fails
127
133
  */
128
- queryRecentActions(query: {
134
+ queryRecentActions({ from, to, }: Readonly<{
129
135
  from: number;
130
136
  to: number;
131
- }): Promise<ActionResponse[]>;
137
+ }>): Promise<ActionResponse[]>;
132
138
  /**
133
139
  * Get the last action ID
134
140
  *
@@ -136,54 +142,6 @@ export declare class Nord {
136
142
  * @throws {NordError} If the request fails
137
143
  */
138
144
  getLastActionId(): Promise<number>;
139
- /**
140
- * Fetch aggregate metrics from the Nord API
141
- *
142
- * @param txPeakTpsPeriod - Period for peak TPS calculation
143
- * @param txPeakTpsPeriodUnit - Unit for peak TPS period
144
- * @returns Aggregate metrics
145
- * @throws {NordError} If the request fails
146
- */
147
- aggregateMetrics(txPeakTpsPeriod?: number, txPeakTpsPeriodUnit?: PeakTpsPeriodUnit): Promise<AggregateMetrics>;
148
- /**
149
- * Get current transactions per second
150
- *
151
- * @param period - Time period for the query
152
- * @returns Current TPS value
153
- * @throws {NordError} If the request fails
154
- */
155
- getCurrentTps(period?: string): Promise<number>;
156
- /**
157
- * Get peak transactions per second
158
- *
159
- * @param period - Time period for the query
160
- * @returns Peak TPS value
161
- * @throws {NordError} If the request fails
162
- */
163
- getPeakTps(period?: string): Promise<number>;
164
- /**
165
- * Get median transaction latency
166
- *
167
- * @param period - Time period for the query
168
- * @returns Median latency in milliseconds
169
- * @throws {NordError} If the request fails
170
- */
171
- getMedianLatency(period?: string): Promise<number>;
172
- /**
173
- * Get total transaction count
174
- *
175
- * @returns Total transaction count
176
- * @throws {NordError} If the request fails
177
- */
178
- getTotalTransactions(): Promise<number>;
179
- /**
180
- * Query Prometheus metrics
181
- *
182
- * @param params - Prometheus query parameters
183
- * @returns Query result as a number
184
- * @throws {NordError} If the request fails
185
- */
186
- queryPrometheus(params: string): Promise<number>;
187
145
  /**
188
146
  * Subscribe to orderbook updates for a market
189
147
  *
@@ -211,40 +169,48 @@ export declare class Nord {
211
169
  /**
212
170
  * Get trades for a market
213
171
  *
214
- * @param query - Trades query parameters
172
+ * @param marketId - Market identifier to filter by
173
+ * @param takerId - Taker account identifier
174
+ * @param makerId - Maker account identifier
175
+ * @param takerSide - Side executed by the taker
176
+ * @param pageSize - Maximum number of trades to return
177
+ * @param since - RFC3339 timestamp to start from (inclusive)
178
+ * @param until - RFC3339 timestamp to end at (exclusive)
179
+ * @param pageId - Pagination cursor returned from a prior call
215
180
  * @returns Trades response
216
181
  * @throws {NordError} If the request fails
217
182
  */
218
- getTrades(query: Readonly<{
183
+ getTrades({ marketId, takerId, makerId, takerSide, pageSize, since, until, startInclusive, }: Readonly<{
219
184
  marketId?: number;
220
185
  takerId?: number;
221
186
  makerId?: number;
222
187
  takerSide?: "bid" | "ask";
223
188
  pageSize?: number;
224
- sinceRcf3339?: string;
225
- untilRfc3339?: string;
226
- pageId?: string;
189
+ since?: string;
190
+ until?: string;
191
+ startInclusive?: string;
227
192
  }>): Promise<TradesResponse>;
228
193
  /**
229
194
  * Get user account IDs
230
195
  *
231
- * @param query - User account IDs query parameters
196
+ * @param pubkey - User public key to query
232
197
  * @returns User account IDs response
233
198
  * @throws {NordError} If the request fails
234
199
  */
235
- getUser(query: {
200
+ getUser({ pubkey, }: Readonly<{
236
201
  pubkey: string | PublicKey;
237
- }): Promise<User | null>;
202
+ }>): Promise<User | null>;
238
203
  /**
239
204
  * Get orderbook for a market
240
205
  *
241
- * @param query - Orderbook query parameters (either market_id or symbol must be provided)
206
+ * @param symbol - Market symbol to resolve into an id
207
+ * @param marketId - Market identifier
242
208
  * @returns Orderbook response
243
209
  * @throws {NordError} If the request fails or if the market symbol is unknown
244
210
  * @remarks It's recommended to initialize the Nord client using the static `initNord` method
245
211
  * to ensure market information is properly loaded before calling this method.
246
212
  */
247
- getOrderbook(query: OrderbookQuery): Promise<OrderbookResponse>;
213
+ getOrderbook({ symbol, marketId, }: OrderbookQuery): Promise<OrderbookResponse>;
248
214
  /**
249
215
  * Get information about the Nord server
250
216
  *
@@ -295,50 +261,62 @@ export declare class Nord {
295
261
  * Get open orders for an account.
296
262
  *
297
263
  * @param accountId - Account id to query
298
- * @param query - Optional pagination parameters
264
+ * @param startInclusive - Pagination cursor (client order id) to resume from
265
+ * @param pageSize - Maximum number of orders to return
299
266
  * @returns Page of orders keyed by client order id
300
267
  * @throws {NordError} If the request fails
301
268
  */
302
- getAccountOrders(accountId: number, query?: {
269
+ getAccountOrders(accountId: number, { startInclusive, pageSize, }?: Readonly<{
303
270
  startInclusive?: string | null;
304
271
  pageSize?: number | null;
305
- }): Promise<PageResultStringOrderInfo>;
272
+ }>): Promise<PageResultStringOrderInfo>;
306
273
  /**
307
274
  * List account fee tiers with pagination support.
275
+ *
276
+ * @param startInclusive - Account id cursor to resume from
277
+ * @param pageSize - Maximum number of entries to return
308
278
  */
309
- getAccountsFeeTiers(query?: {
279
+ getAccountsFeeTiers({ startInclusive, pageSize, }?: Readonly<{
310
280
  startInclusive?: number | null;
311
281
  pageSize?: number | null;
312
- }): Promise<AccountFeeTierPage>;
282
+ }>): Promise<AccountFeeTierPage>;
313
283
  /**
314
284
  * Get profit and loss history for an account
315
285
  *
316
286
  * @param accountId - Account ID to query
317
- * @param query - Optional time and pagination filters
287
+ * @param since - RFC3339 timestamp to start from (inclusive)
288
+ * @param until - RFC3339 timestamp to end at (exclusive)
289
+ * @param startInclusive - Pagination cursor to resume from
290
+ * @param pageSize - Maximum number of entries to return
318
291
  * @returns Page of PnL entries ordered from latest to oldest
319
292
  * @throws {NordError} If the request fails
320
293
  */
321
- getAccountPnl(accountId: number, query?: Partial<AccountPnlQuery>): Promise<AccountPnlPage>;
294
+ getAccountPnl(accountId: number, { since, until, startInclusive, pageSize, }?: Readonly<Partial<AccountPnlQuery>>): Promise<AccountPnlPage>;
322
295
  /**
323
296
  * Get market statistics (alias for marketsStats for backward compatibility)
324
297
  *
298
+ *
299
+ * @param marketId - Market identifier
300
+ *
325
301
  * @returns Market statistics response
326
302
  */
327
- getMarketStats({ marketId, }: {
303
+ getMarketStats({ marketId, }: Readonly<{
328
304
  marketId: number;
329
- }): Promise<MarketStats>;
305
+ }>): Promise<MarketStats>;
330
306
  /**
331
307
  * Fetch the per-market fee quote for an account.
332
308
  *
333
- * @param params - Market id, fee kind, and account id to quote
309
+ * @param marketId - Market identifier
310
+ * @param feeKind - Fill role (maker/taker) to quote
311
+ * @param accountId - Account identifier to quote
334
312
  * @returns Fee in quote token units (negative means fee is charged)
335
313
  * @throws {NordError} If the request fails
336
314
  */
337
- getMarketFee({ marketId, feeKind, accountId, }: {
315
+ getMarketFee({ marketId, feeKind, accountId, }: Readonly<{
338
316
  marketId: number;
339
317
  feeKind: FillRole;
340
318
  accountId: number;
341
- }): Promise<number>;
319
+ }>): Promise<number>;
342
320
  /**
343
321
  * Fetch token statistics such as index price and oracle metadata.
344
322
  *
@@ -359,14 +337,15 @@ export declare class Nord {
359
337
  * Get trade history for a specific order.
360
338
  *
361
339
  * @param orderId - Order identifier
362
- * @param query - Optional pagination parameters
340
+ * @param startInclusive - Trade pagination cursor
341
+ * @param pageSize - Maximum number of trades to return
363
342
  * @returns Page of trades associated with the order
364
343
  * @throws {NordError} If the request fails
365
344
  */
366
- getOrderTrades(orderId: string, query?: {
345
+ getOrderTrades(orderId: string, { startInclusive, pageSize, }?: Readonly<{
367
346
  startInclusive?: string | null;
368
347
  pageSize?: number | null;
369
- }): Promise<PageResultStringTrade>;
348
+ }>): Promise<PageResultStringTrade>;
370
349
  /**
371
350
  * Check if an account exists for the given address
372
351
  *
@@ -378,19 +357,23 @@ export declare class Nord {
378
357
  /**
379
358
  * Fetch active triggers for an account.
380
359
  *
381
- * @param params Optional parameters containing an explicit account id.
360
+ * @param accountId - Account identifier owning the triggers
382
361
  * @throws {NordError} If no account can be resolved or the request fails.
383
362
  */
384
- getAccountTriggers(params?: {
363
+ getAccountTriggers({ accountId, }?: Readonly<{
385
364
  accountId?: number;
386
- }): Promise<AccountTriggerInfo[]>;
365
+ }>): Promise<AccountTriggerInfo[]>;
387
366
  /**
388
367
  * Fetch trigger history for an account.
389
368
  *
390
- * @param params Optional parameters with account id and history query filters.
369
+ * @param accountId - Account identifier owning the triggers
370
+ * @param since - RFC3339 timestamp to start from (inclusive)
371
+ * @param until - RFC3339 timestamp to end at (exclusive)
372
+ * @param pageSize - Maximum number of entries to return
373
+ * @param startInclusive - Pagination cursor to resume from
391
374
  * @throws {NordError} If no account can be resolved or the request fails.
392
375
  */
393
- getAccountTriggerHistory(params: HistoryTriggerQuery & {
376
+ getAccountTriggerHistory({ accountId, since, until, pageSize, startInclusive, }: Readonly<HistoryTriggerQuery & {
394
377
  accountId?: number;
395
- }): Promise<TriggerHistoryPage>;
378
+ }>): Promise<TriggerHistoryPage>;
396
379
  }