@n1xyz/nord-ts 0.1.7 → 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 (84) hide show
  1. package/dist/actions.js +39 -82
  2. package/dist/bundle.js +79181 -0
  3. package/dist/client/Nord.d.ts +2 -2
  4. package/dist/client/Nord.js +46 -78
  5. package/dist/client/NordAdmin.d.ts +2 -2
  6. package/dist/client/NordAdmin.js +57 -89
  7. package/dist/client/NordUser.js +118 -147
  8. package/dist/const.js +5 -8
  9. package/dist/error.js +7 -5
  10. package/dist/gen/nord_pb.js +88 -92
  11. package/dist/gen/openapi.d.ts +5 -6
  12. package/dist/gen/openapi.js +1 -2
  13. package/dist/index.js +10 -49
  14. package/dist/types.d.ts +1 -0
  15. package/dist/types.js +21 -60
  16. package/dist/utils.js +38 -86
  17. package/dist/websocket/NordWebSocketClient.js +12 -17
  18. package/dist/websocket/Subscriber.js +6 -7
  19. package/dist/websocket/events.js +1 -2
  20. package/dist/websocket/index.js +10 -15
  21. package/package.json +2 -3
  22. package/dist/api/client.d.ts +0 -14
  23. package/dist/api/client.js +0 -45
  24. package/dist/bridge/client.d.ts +0 -151
  25. package/dist/bridge/client.js +0 -434
  26. package/dist/bridge/const.d.ts +0 -23
  27. package/dist/bridge/const.js +0 -47
  28. package/dist/bridge/index.d.ts +0 -4
  29. package/dist/bridge/index.js +0 -23
  30. package/dist/bridge/types.d.ts +0 -120
  31. package/dist/bridge/types.js +0 -18
  32. package/dist/bridge/utils.d.ts +0 -64
  33. package/dist/bridge/utils.js +0 -131
  34. package/dist/gen/common.d.ts +0 -68
  35. package/dist/gen/common.js +0 -215
  36. package/dist/gen/nord.d.ts +0 -882
  37. package/dist/gen/nord.js +0 -6520
  38. package/dist/idl/bridge.d.ts +0 -569
  39. package/dist/idl/bridge.js +0 -8
  40. package/dist/idl/bridge.json +0 -1506
  41. package/dist/idl/index.d.ts +0 -607
  42. package/dist/idl/index.js +0 -8
  43. package/dist/nord/api/actions.d.ts +0 -126
  44. package/dist/nord/api/actions.js +0 -397
  45. package/dist/nord/api/core.d.ts +0 -16
  46. package/dist/nord/api/core.js +0 -81
  47. package/dist/nord/api/market.d.ts +0 -36
  48. package/dist/nord/api/market.js +0 -96
  49. package/dist/nord/api/metrics.d.ts +0 -67
  50. package/dist/nord/api/metrics.js +0 -229
  51. package/dist/nord/api/queries.d.ts +0 -46
  52. package/dist/nord/api/queries.js +0 -109
  53. package/dist/nord/api/triggers.d.ts +0 -7
  54. package/dist/nord/api/triggers.js +0 -38
  55. package/dist/nord/client/Nord.d.ts +0 -396
  56. package/dist/nord/client/Nord.js +0 -747
  57. package/dist/nord/client/NordAdmin.d.ts +0 -259
  58. package/dist/nord/client/NordAdmin.js +0 -395
  59. package/dist/nord/client/NordClient.d.ts +0 -33
  60. package/dist/nord/client/NordClient.js +0 -45
  61. package/dist/nord/client/NordUser.d.ts +0 -362
  62. package/dist/nord/client/NordUser.js +0 -781
  63. package/dist/nord/index.d.ts +0 -11
  64. package/dist/nord/index.js +0 -36
  65. package/dist/nord/models/Subscriber.d.ts +0 -37
  66. package/dist/nord/models/Subscriber.js +0 -25
  67. package/dist/nord/utils/NordError.d.ts +0 -35
  68. package/dist/nord/utils/NordError.js +0 -49
  69. package/src/actions.ts +0 -333
  70. package/src/client/Nord.ts +0 -934
  71. package/src/client/NordAdmin.ts +0 -484
  72. package/src/client/NordUser.ts +0 -1122
  73. package/src/const.ts +0 -34
  74. package/src/error.ts +0 -76
  75. package/src/gen/.gitkeep +0 -0
  76. package/src/gen/nord_pb.ts +0 -5053
  77. package/src/gen/openapi.ts +0 -2904
  78. package/src/index.ts +0 -11
  79. package/src/types.ts +0 -327
  80. package/src/utils.ts +0 -266
  81. package/src/websocket/NordWebSocketClient.ts +0 -316
  82. package/src/websocket/Subscriber.ts +0 -56
  83. package/src/websocket/events.ts +0 -31
  84. package/src/websocket/index.ts +0 -105
@@ -1,396 +0,0 @@
1
- import { ProtonClient } from "@n1xyz/proton";
2
- import { PublicKey } from "@solana/web3.js";
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";
7
- /**
8
- * User subscription interface
9
- */
10
- export interface UserSubscription extends EventEmitter {
11
- close: () => void;
12
- }
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
- /**
25
- * Main Nord client class for interacting with the Nord API
26
- */
27
- export declare class Nord {
28
- /** Base URL for the Nord web server */
29
- readonly webServerUrl: string;
30
- /** Solana RPC URL */
31
- readonly solanaUrl: string;
32
- /** Available markets */
33
- markets: Market[];
34
- /** Available tokens */
35
- tokens: Token[];
36
- /** Map of symbol to market_id */
37
- private symbolToMarketId;
38
- /** Proton client for proton related operations */
39
- protonClient: ProtonClient;
40
- /** HTTP client for Nord operations */
41
- private httpClient;
42
- /**
43
- * Create a new Nord client
44
- *
45
- * @param config - Configuration options for the Nord client
46
- * @param config.webServerUrl - Base URL for the Nord web server
47
- * @param config.solanaUrl - Solana cluster URL
48
- * @throws {Error} If required configuration is missing
49
- */
50
- private constructor();
51
- /**
52
- * Create a WebSocket client with specific subscriptions
53
- *
54
- * @param options - Subscription options that specify which data streams to subscribe to
55
- * @returns A new WebSocket client with the requested subscriptions
56
- * @throws {NordError} If invalid subscription options are provided
57
- *
58
- * @example
59
- * // Create a client for trades and deltas from one market and an account
60
- * const wsClient = nord.createWebSocketClient({
61
- * trades: ["BTCUSDC"],
62
- * deltas: ["BTCUSDC"],
63
- * accounts: [123]
64
- * });
65
- *
66
- * @example
67
- * // Create a client for trades from multiple markets
68
- * const tradesClient = nord.createWebSocketClient({
69
- * trades: ["BTCUSDC", "ETHUSDC"]
70
- * });
71
- */
72
- createWebSocketClient(options: WebSocketSubscriptionOptions): NordWebSocketClient;
73
- private GET;
74
- /**
75
- * Get the current timestamp from the Nord server
76
- *
77
- * @returns Current timestamp as a bigint
78
- * @throws {NordError} If the request fails
79
- */
80
- getTimestamp(): Promise<bigint>;
81
- /**
82
- * Get the last event nonce from the Nord server
83
- *
84
- * @returns Next action nonce
85
- * @throws {NordError} If the request fails
86
- */
87
- getActionNonce(): Promise<number>;
88
- /**
89
- * Fetch information about Nord markets and tokens
90
- *
91
- * @throws {NordError} If the request fails
92
- */
93
- fetchNordInfo(): Promise<void>;
94
- /**
95
- * Initialize a new Nord client
96
- *
97
- * @param nordConfig - Configuration options for the Nord client
98
- * @param nordConfig.webServerUrl - Base URL for the Nord web server
99
- * @param nordConfig.app - App address
100
- * @param nordConfig.solanaUrl - Solana cluster URL
101
- * @returns Initialized Nord client
102
- * @throws {NordError} If initialization fails
103
- */
104
- static initNord({ app, solanaUrl, webServerUrl, protonUrl, }: Readonly<NordConfig>): Promise<Nord>;
105
- /**
106
- * Initialize the Nord client
107
- * @private
108
- */
109
- private init;
110
- /**
111
- * Query a specific action
112
- *
113
- * @param query - Action query parameters
114
- * @returns Action response
115
- * @throws {NordError} If the request fails
116
- */
117
- queryAction({ action_id, }: {
118
- action_id: number;
119
- }): Promise<ActionResponse | null>;
120
- /**
121
- * Query recent actions
122
- *
123
- * @param from - Starting action index
124
- * @param to - Ending action index
125
- * @returns Actions response
126
- * @throws {NordError} If the request fails
127
- */
128
- queryRecentActions(query: {
129
- from: number;
130
- to: number;
131
- }): Promise<ActionResponse[]>;
132
- /**
133
- * Get the last action ID
134
- *
135
- * @returns Last action ID
136
- * @throws {NordError} If the request fails
137
- */
138
- 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
- /**
188
- * Subscribe to orderbook updates for a market
189
- *
190
- * @param symbol - Market symbol
191
- * @returns Orderbook subscription
192
- * @throws {NordError} If symbol is invalid
193
- */
194
- subscribeOrderbook(symbol: string): OrderbookSubscription;
195
- /**
196
- * Subscribe to trade updates for a market
197
- *
198
- * @param symbol - Market symbol
199
- * @returns Trade subscription
200
- * @throws {NordError} If symbol is invalid
201
- */
202
- subscribeTrades(symbol: string): TradeSubscription;
203
- /**
204
- * Subscribe to account updates
205
- *
206
- * @param accountId - Account ID to subscribe to
207
- * @returns User subscription
208
- * @throws {NordError} If accountId is invalid
209
- */
210
- subscribeAccount(accountId: number): UserSubscription;
211
- /**
212
- * Get trades for a market
213
- *
214
- * @param query - Trades query parameters
215
- * @returns Trades response
216
- * @throws {NordError} If the request fails
217
- */
218
- getTrades(query: Readonly<{
219
- marketId?: number;
220
- takerId?: number;
221
- makerId?: number;
222
- takerSide?: "bid" | "ask";
223
- pageSize?: number;
224
- sinceRcf3339?: string;
225
- untilRfc3339?: string;
226
- pageId?: string;
227
- }>): Promise<TradesResponse>;
228
- /**
229
- * Get user account IDs
230
- *
231
- * @param query - User account IDs query parameters
232
- * @returns User account IDs response
233
- * @throws {NordError} If the request fails
234
- */
235
- getUser(query: {
236
- pubkey: string | PublicKey;
237
- }): Promise<User | null>;
238
- /**
239
- * Get orderbook for a market
240
- *
241
- * @param query - Orderbook query parameters (either market_id or symbol must be provided)
242
- * @returns Orderbook response
243
- * @throws {NordError} If the request fails or if the market symbol is unknown
244
- * @remarks It's recommended to initialize the Nord client using the static `initNord` method
245
- * to ensure market information is properly loaded before calling this method.
246
- */
247
- getOrderbook(query: OrderbookQuery): Promise<OrderbookResponse>;
248
- /**
249
- * Get information about the Nord server
250
- *
251
- * @returns Information about markets and tokens
252
- * @throws {NordError} If the request fails
253
- */
254
- getInfo(): Promise<MarketsInfo>;
255
- /**
256
- * Fetch the current fee tier brackets configured on Nord.
257
- *
258
- * @returns Array of fee tier identifiers paired with their configuration
259
- * @throws {NordError} If the request fails
260
- */
261
- getFeeBrackets(): Promise<Array<[FeeTierId, FeeTierConfig]>>;
262
- /**
263
- * Retrieve the fee tier assigned to a specific account.
264
- *
265
- * @param accountId - Account identifier to query
266
- * @returns Fee tier details for the requested account
267
- * @throws {NordError} If the request fails
268
- */
269
- getAccountFeeTier(accountId: number): Promise<FeeTierId>;
270
- /**
271
- * Get account information
272
- *
273
- * @param accountId - Account ID to get information for
274
- * @returns Account information
275
- * @throws {NordError} If the request fails
276
- */
277
- getAccount(accountId: number): Promise<Account>;
278
- /**
279
- * Get the public key associated with an account id.
280
- *
281
- * @param accountId - Account id to query
282
- * @returns Base58-encoded account public key
283
- * @throws {NordError} If the request fails
284
- */
285
- getAccountPubkey(accountId: number): Promise<string>;
286
- /**
287
- * Get the withdrawal fee charged for an account.
288
- *
289
- * @param accountId - Account id to query
290
- * @returns Withdrawal fee quoted in quote token units
291
- * @throws {NordError} If the request fails
292
- */
293
- getAccountWithdrawalFee(accountId: number): Promise<number>;
294
- /**
295
- * Get open orders for an account.
296
- *
297
- * @param accountId - Account id to query
298
- * @param query - Optional pagination parameters
299
- * @returns Page of orders keyed by client order id
300
- * @throws {NordError} If the request fails
301
- */
302
- getAccountOrders(accountId: number, query?: {
303
- startInclusive?: string | null;
304
- pageSize?: number | null;
305
- }): Promise<PageResultStringOrderInfo>;
306
- /**
307
- * List account fee tiers with pagination support.
308
- */
309
- getAccountsFeeTiers(query?: {
310
- startInclusive?: number | null;
311
- pageSize?: number | null;
312
- }): Promise<AccountFeeTierPage>;
313
- /**
314
- * Get profit and loss history for an account
315
- *
316
- * @param accountId - Account ID to query
317
- * @param query - Optional time and pagination filters
318
- * @returns Page of PnL entries ordered from latest to oldest
319
- * @throws {NordError} If the request fails
320
- */
321
- getAccountPnl(accountId: number, query?: Partial<AccountPnlQuery>): Promise<AccountPnlPage>;
322
- /**
323
- * Get market statistics (alias for marketsStats for backward compatibility)
324
- *
325
- * @returns Market statistics response
326
- */
327
- getMarketStats({ marketId, }: {
328
- marketId: number;
329
- }): Promise<MarketStats>;
330
- /**
331
- * Fetch the per-market fee quote for an account.
332
- *
333
- * @param params - Market id, fee kind, and account id to quote
334
- * @returns Fee in quote token units (negative means fee is charged)
335
- * @throws {NordError} If the request fails
336
- */
337
- getMarketFee({ marketId, feeKind, accountId, }: {
338
- marketId: number;
339
- feeKind: FillRole;
340
- accountId: number;
341
- }): Promise<number>;
342
- /**
343
- * Fetch token statistics such as index price and oracle metadata.
344
- *
345
- * @param tokenId - Token identifier
346
- * @returns Token stats
347
- * @throws {NordError} If the request fails
348
- */
349
- getTokenStats(tokenId: number): Promise<TokenStats>;
350
- /**
351
- * Get order summary by order id.
352
- *
353
- * @param orderId - Order identifier
354
- * @returns Order information
355
- * @throws {NordError} If the request fails
356
- */
357
- getOrder(orderId: string): Promise<OrderInfoFromApi>;
358
- /**
359
- * Get trade history for a specific order.
360
- *
361
- * @param orderId - Order identifier
362
- * @param query - Optional pagination parameters
363
- * @returns Page of trades associated with the order
364
- * @throws {NordError} If the request fails
365
- */
366
- getOrderTrades(orderId: string, query?: {
367
- startInclusive?: string | null;
368
- pageSize?: number | null;
369
- }): Promise<PageResultStringTrade>;
370
- /**
371
- * Check if an account exists for the given address
372
- *
373
- * @param address - The public key address to check
374
- * @returns True if the account exists, false otherwise
375
- * @deprecated use getUser instead
376
- */
377
- accountExists(pubkey: string | PublicKey): Promise<boolean>;
378
- /**
379
- * Fetch active triggers for an account.
380
- *
381
- * @param params Optional parameters containing an explicit account id.
382
- * @throws {NordError} If no account can be resolved or the request fails.
383
- */
384
- getAccountTriggers(params?: {
385
- accountId?: number;
386
- }): Promise<AccountTriggerInfo[]>;
387
- /**
388
- * Fetch trigger history for an account.
389
- *
390
- * @param params Optional parameters with account id and history query filters.
391
- * @throws {NordError} If no account can be resolved or the request fails.
392
- */
393
- getAccountTriggerHistory(params: HistoryTriggerQuery & {
394
- accountId?: number;
395
- }): Promise<TriggerHistoryPage>;
396
- }