@n1xyz/nord-ts 0.3.2 → 0.3.4-alpha.1

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/actions.d.ts CHANGED
@@ -4,7 +4,7 @@ import { paths } from "./gen/openapi";
4
4
  import { Client } from "openapi-fetch";
5
5
  import { FillMode, Side, QuoteSize } from "./types";
6
6
  import { BigIntValue } from "./utils";
7
- import { PublicKey } from "@solana/web3.js";
7
+ import { PublicKey, Transaction } from "@solana/web3.js";
8
8
  type ReceiptKind = NonNullable<proto.Receipt["kind"]>;
9
9
  type ExtractReceiptKind<K extends ReceiptKind["case"]> = Extract<ReceiptKind, {
10
10
  case: K;
@@ -19,7 +19,9 @@ export declare function prepareAction(action: proto.Action, makeSignedMessage: (
19
19
  export declare function createSession(client: Client<paths>, signMessage: (_: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
20
20
  userPubkey: PublicKey;
21
21
  sessionPubkey: PublicKey;
22
+ signatureFraming: "hex" | "solanaTransaction";
22
23
  expiryTimestamp?: bigint;
24
+ signTransactionFn: (tx: Transaction) => Promise<Transaction>;
23
25
  }): Promise<{
24
26
  actionId: bigint;
25
27
  sessionId: bigint;
@@ -3,9 +3,9 @@ import { Connection, PublicKey } from "@solana/web3.js";
3
3
  import { EventEmitter } from "events";
4
4
  import { Client } from "openapi-fetch";
5
5
  import type { paths } from "../gen/openapi.ts";
6
- import { Account, AccountPnlInfoPage, PagedQuery, ActionResponse, MarketsInfo, Market, MarketStats, NordConfig, OrderbookQuery, OrderbookResponse, FeeTierConfig, Token, TradesResponse, User, AccountTriggerInfo, TriggerHistoryPage, WithdrawalHistoryPage, FeeTierId, AccountFeeTierPage, PageResultStringOrderInfo, PageResultStringTrade, OrderInfoFromApi, TokenStats, FillRole, AdminInfo, AccountVolumeInfo, GetAccountVolumeQuery, PreviousMarketPrice } from "../types";
6
+ import { Account, AccountPnlInfoPage, PagedQuery, ActionResponse, MarketsInfo, Market, MarketStats, NordConfig, OrderbookQuery, OrderbookResponse, FeeTierConfig, Token, TradesResponse, User, AccountTriggerInfo, TriggerHistoryPage, WithdrawalHistoryPage, FeeTierId, AccountFeeTierPage, PageResultStringOrderInfo, PageResultStringTrade, OrderInfoFromApi, TokenStats, FillRole, AdminInfo, AccountVolumeInfo, GetAccountVolumeQuery, CandleResolution } from "../types";
7
7
  import { NordWebSocketClient } from "../websocket/index";
8
- import { OrderbookSubscription, TradeSubscription } from "../websocket/Subscriber";
8
+ import { OrderbookSubscription, TradeSubscription, CandleSubscription } from "../websocket/Subscriber";
9
9
  /**
10
10
  * User subscription interface
11
11
  */
@@ -45,6 +45,7 @@ export declare class Nord {
45
45
  * @param trades - Market symbols to subscribe to for trade updates
46
46
  * @param deltas - Market symbols to subscribe to for orderbook delta updates
47
47
  * @param accounts - Account IDs to subscribe to for account updates
48
+ * @param candles - Candle subscriptions with symbol and resolution
48
49
  * @returns A new WebSocket client with the requested subscriptions
49
50
  * @throws {NordError} If invalid subscription options are provided
50
51
  *
@@ -62,10 +63,14 @@ export declare class Nord {
62
63
  * trades: ["BTCUSDC", "ETHUSDC"]
63
64
  * });
64
65
  */
65
- createWebSocketClient({ trades, deltas, accounts, }: Readonly<{
66
+ createWebSocketClient({ trades, deltas, accounts, candles, }: Readonly<{
66
67
  trades?: string[];
67
68
  deltas?: string[];
68
69
  accounts?: number[];
70
+ candles?: Array<{
71
+ symbol: string;
72
+ resolution: CandleResolution;
73
+ }>;
69
74
  }>): NordWebSocketClient;
70
75
  private GET;
71
76
  /**
@@ -161,6 +166,7 @@ export declare class Nord {
161
166
  * @throws {NordError} If symbol is invalid
162
167
  */
163
168
  subscribeOrderbook(symbol: string): OrderbookSubscription;
169
+ subscribeBars(symbol: string, resolution: CandleResolution): CandleSubscription;
164
170
  /**
165
171
  * Subscribe to trade updates for a market
166
172
  *
@@ -199,7 +205,7 @@ export declare class Nord {
199
205
  pageSize?: number;
200
206
  since?: string;
201
207
  until?: string;
202
- startInclusive?: string;
208
+ startInclusive?: number;
203
209
  }>): Promise<TradesResponse>;
204
210
  /**
205
211
  * Get user account IDs
@@ -278,18 +284,20 @@ export declare class Nord {
278
284
  * @throws {NordError} If the request fails
279
285
  */
280
286
  getAccountOrders(accountId: number, { startInclusive, pageSize, }?: Readonly<{
281
- startInclusive?: string | null;
282
- pageSize?: number | null;
287
+ startInclusive?: number;
288
+ pageSize?: number;
283
289
  }>): Promise<PageResultStringOrderInfo>;
284
290
  /**
285
291
  * List account fee tiers with pagination support.
286
292
  *
287
293
  * @param startInclusive - Account id cursor to resume from
288
294
  * @param pageSize - Maximum number of entries to return
295
+ * @param tier - Optional fee tier filter
289
296
  */
290
- getAccountsFeeTiers({ startInclusive, pageSize, }?: Readonly<{
291
- startInclusive?: number | null;
292
- pageSize?: number | null;
297
+ getAccountsFeeTiers({ startInclusive, pageSize, tier, }?: Readonly<{
298
+ startInclusive?: number;
299
+ pageSize?: number;
300
+ tier?: FeeTierId;
293
301
  }>): Promise<AccountFeeTierPage>;
294
302
  /**
295
303
  * Get profit and loss history for an account
@@ -328,18 +336,6 @@ export declare class Nord {
328
336
  feeKind: FillRole;
329
337
  accountId: number;
330
338
  }>): Promise<number>;
331
- /**
332
- * Fetch the latest available market price at or before the given timestamp.
333
- *
334
- * @param marketId - Market identifier
335
- * @param atOrBefore - RFC3339 timestamp to look back from (returns the latest price at or before this time)
336
- * @returns Previous market price record; price is `null` if no trades exist at or before `at`
337
- * @throws {NordError} If the request fails
338
- */
339
- getPrevMarketPrice({ marketId, atOrBefore, }: Readonly<{
340
- marketId: number;
341
- atOrBefore: string;
342
- }>): Promise<PreviousMarketPrice>;
343
339
  /**
344
340
  * Fetch token statistics such as index price and oracle metadata.
345
341
  *
@@ -355,7 +351,7 @@ export declare class Nord {
355
351
  * @returns Order information
356
352
  * @throws {NordError} If the request fails
357
353
  */
358
- getOrder(orderId: string): Promise<OrderInfoFromApi>;
354
+ getOrder(orderId: number): Promise<OrderInfoFromApi>;
359
355
  /**
360
356
  * Get trade history for a specific order.
361
357
  *
@@ -365,9 +361,9 @@ export declare class Nord {
365
361
  * @returns Page of trades associated with the order
366
362
  * @throws {NordError} If the request fails
367
363
  */
368
- getOrderTrades(orderId: string, { startInclusive, pageSize, }?: Readonly<{
369
- startInclusive?: string | null;
370
- pageSize?: number | null;
364
+ getOrderTrades(orderId: number, { startInclusive, pageSize, }?: Readonly<{
365
+ startInclusive?: number;
366
+ pageSize?: number;
371
367
  }>): Promise<PageResultStringTrade>;
372
368
  /**
373
369
  * Check if an account exists for the given address
@@ -2,6 +2,7 @@ import { PublicKey, Transaction } from "@solana/web3.js";
2
2
  import * as proto from "../gen/nord_pb";
3
3
  import { Nord } from "./Nord";
4
4
  import { FeeTierConfig } from "../gen/nord_pb";
5
+ import Decimal from "decimal.js";
5
6
  export declare enum AclRole {
6
7
  FEE_MANAGER = 1,
7
8
  MARKET_MANAGER = 2,
@@ -222,4 +223,11 @@ export declare class NordAdmin {
222
223
  updateAccountsTier(accounts: number[], tierId: number): Promise<{
223
224
  actionId: bigint;
224
225
  } & proto.Receipt_AccountsTierUpdated>;
226
+ feeVaultTransfer({ recipient, tokenId, amount, }: Readonly<{
227
+ recipient: number;
228
+ tokenId: number;
229
+ amount: Decimal.Value;
230
+ }>): Promise<{
231
+ actionId: bigint;
232
+ } & proto.Receipt_FeeVaultTransferred>;
225
233
  }
@@ -36,6 +36,13 @@ export declare class NordUser {
36
36
  private readonly signSessionMessage;
37
37
  private readonly signMessage;
38
38
  private readonly signTransaction;
39
+ /** If set, will use signTransaction instead of signMessage for session creation.
40
+ * Because ledgers don't support signMessage, we have an escape hatch for them.
41
+ * However, the escape hatch is brittle and we recommend avoiditing as much as
42
+ * possible. Thus, _only_ use this if you are forced to use ledgers.
43
+ * To use this, just set it to true in your NordUser instance.
44
+ */
45
+ __use_solana_transaction_framing__: boolean;
39
46
  readonly nord: Nord;
40
47
  sessionId?: bigint;
41
48
  sessionPubKey: PublicKey;
@@ -52,7 +59,7 @@ export declare class NordUser {
52
59
  };
53
60
  orders: {
54
61
  [key: string]: {
55
- orderId: string;
62
+ orderId: number;
56
63
  marketId: number;
57
64
  side: "ask" | "bid";
58
65
  size: number;
@@ -211,11 +218,13 @@ export declare class NordUser {
211
218
  *
212
219
  * @param tokenId - Token ID to withdraw
213
220
  * @param amount - Amount to withdraw
221
+ * @param destPubkey - Optional destination registration pubkey (base58); defaults to session owner
214
222
  * @throws {NordError} If the operation fails
215
223
  */
216
- withdraw({ amount, tokenId, }: Readonly<{
224
+ withdraw({ amount, tokenId, destPubkey, }: Readonly<{
217
225
  tokenId: number;
218
226
  amount: number;
227
+ destPubkey?: string;
219
228
  }>): Promise<{
220
229
  actionId: bigint;
221
230
  }>;