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