@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,84 +1,9 @@
1
- import { Connection, PublicKey, Transaction, SendOptions } from "@solana/web3.js";
1
+ import { PublicKey, Transaction, SendOptions } from "@solana/web3.js";
2
2
  import Decimal from "decimal.js";
3
- import { FillMode, Side, SPLTokenInfo, QuoteSize, TriggerKind } from "../../types";
4
- import * as proto from "../../gen/nord_pb";
5
- import { BigIntValue } from "../../utils";
3
+ import { FillMode, Side, SPLTokenInfo, QuoteSize, TriggerKind } from "../types";
4
+ import * as proto from "../gen/nord_pb";
5
+ import { BigIntValue } from "../utils";
6
6
  import { Nord } from "./Nord";
7
- import { NordClient } from "./NordClient";
8
- /**
9
- * Parameters for creating a NordUser instance
10
- */
11
- export interface NordUserParams {
12
- /** Nord client instance */
13
- nord: Nord;
14
- /** User's blockchain address */
15
- address: string;
16
- /** Function to sign messages with the user's wallet */
17
- walletSignFn: (message: Uint8Array | string) => Promise<Uint8Array>;
18
- /** Function to sign messages with the user's session key */
19
- sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
20
- /** Function to sign transactions with the user's wallet (optional) */
21
- transactionSignFn: <T extends Transaction>(tx: T) => Promise<T>;
22
- /** Solana connection (optional) */
23
- connection?: Connection;
24
- /** Session ID (optional) */
25
- sessionId?: bigint;
26
- /** Session public key (required) */
27
- sessionPubKey: Uint8Array;
28
- /** Session public key (required) */
29
- publicKey: PublicKey;
30
- }
31
- /**
32
- * Parameters for placing an order
33
- */
34
- export interface PlaceOrderParams {
35
- /** Market ID */
36
- marketId: number;
37
- /** Order side (bid or ask) */
38
- side: Side;
39
- /** Fill mode (limit, market, etc.) */
40
- fillMode: FillMode;
41
- /** Whether the order is reduce-only */
42
- isReduceOnly: boolean;
43
- /** Order size */
44
- size?: Decimal.Value;
45
- /** Order price */
46
- price?: Decimal.Value;
47
- /** Quote size object (requires non-zero price and size) */
48
- quoteSize?: QuoteSize;
49
- /** Account ID to place the order from */
50
- accountId?: number;
51
- clientOrderId?: BigIntValue;
52
- }
53
- export interface AddTriggerParams {
54
- marketId: number;
55
- side: Side;
56
- kind: TriggerKind;
57
- triggerPrice: Decimal.Value;
58
- limitPrice?: Decimal.Value;
59
- accountId?: number;
60
- }
61
- export interface RemoveTriggerParams {
62
- marketId: number;
63
- side: Side;
64
- kind: TriggerKind;
65
- accountId?: number;
66
- }
67
- /**
68
- * Parameters for transferring tokens between accounts
69
- */
70
- export interface TransferParams {
71
- /** Recipient user */
72
- to: NordUser;
73
- /** Token ID to transfer */
74
- tokenId: number;
75
- /** Amount to transfer */
76
- amount: Decimal.Value;
77
- /** Source account ID */
78
- fromAccountId: number;
79
- /** Destination account ID */
80
- toAccountId: number;
81
- }
82
7
  /**
83
8
  * Parameters for individual atomic subactions (user-friendly version)
84
9
  */
@@ -107,7 +32,15 @@ export interface UserAtomicSubaction {
107
32
  /**
108
33
  * User class for interacting with the Nord protocol
109
34
  */
110
- export declare class NordUser extends NordClient {
35
+ export declare class NordUser {
36
+ readonly nord: Nord;
37
+ readonly sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
38
+ readonly transactionSignFn: (tx: Transaction) => Promise<Transaction>;
39
+ sessionId?: bigint;
40
+ sessionPubKey: PublicKey;
41
+ publicKey: PublicKey;
42
+ lastTs: number;
43
+ private nonce;
111
44
  /** User balances by token symbol */
112
45
  balances: {
113
46
  [key: string]: {
@@ -152,26 +85,31 @@ export declare class NordUser extends NordClient {
152
85
  /**
153
86
  * Create a new NordUser instance
154
87
  *
155
- * @param params - Parameters for creating a NordUser
88
+ * @param nord - Nord client instance
89
+ * @param sessionSignFn - Function to sign messages with the user's session key
90
+ * @param transactionSignFn - Function to sign transactions with the user's wallet (optional)
91
+ * @param sessionId - Existing session identifier
92
+ * @param sessionPubKey - Session public key
93
+ * @param publicKey - Wallet public key
156
94
  * @throws {NordError} If required parameters are missing
157
95
  */
158
- constructor({ address, nord, publicKey, sessionPubKey, sessionSignFn, transactionSignFn, walletSignFn, connection, sessionId, }: NordUserParams);
159
- /**
160
- * Create a clone of this NordUser instance
161
- *
162
- * @returns A new NordUser instance with the same properties
163
- */
164
- clone(): NordUser;
96
+ constructor({ nord, sessionSignFn, transactionSignFn, sessionId, sessionPubKey, publicKey, }: Readonly<{
97
+ nord: Nord;
98
+ sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
99
+ transactionSignFn: (tx: Transaction) => Promise<Transaction>;
100
+ sessionId?: bigint;
101
+ sessionPubKey: Uint8Array;
102
+ publicKey: PublicKey;
103
+ }>);
165
104
  /**
166
105
  * Create a NordUser from a private key
167
106
  *
168
107
  * @param nord - Nord instance
169
108
  * @param privateKey - Private key as string or Uint8Array
170
- * @param connection - Solana connection (optional)
171
109
  * @returns NordUser instance
172
110
  * @throws {NordError} If the private key is invalid
173
111
  */
174
- static fromPrivateKey(nord: Nord, privateKey: string | Uint8Array, connection?: Connection): NordUser;
112
+ static fromPrivateKey(nord: Nord, privateKey: string | Uint8Array): NordUser;
175
113
  /**
176
114
  * Get the associated token account for a token mint
177
115
  *
@@ -261,11 +199,29 @@ export declare class NordUser extends NordClient {
261
199
  /**
262
200
  * Place an order on the exchange
263
201
  *
264
- * @param params - Order parameters
202
+ * @param marketId - Target market identifier
203
+ * @param side - Order side
204
+ * @param fillMode - Fill mode (limit, market, etc.)
205
+ * @param isReduceOnly - Reduce-only flag
206
+ * @param size - Base size to place
207
+ * @param price - Limit price
208
+ * @param quoteSize - Quote-sized order representation
209
+ * @param accountId - Account executing the order
210
+ * @param clientOrderId - Optional client-specified identifier
265
211
  * @returns Object containing actionId, orderId (if posted), fills, and clientOrderId
266
212
  * @throws {NordError} If the operation fails
267
213
  */
268
- placeOrder(params: PlaceOrderParams): Promise<{
214
+ placeOrder({ marketId, side, fillMode, isReduceOnly, size, price, quoteSize, accountId, clientOrderId, }: Readonly<{
215
+ marketId: number;
216
+ side: Side;
217
+ fillMode: FillMode;
218
+ isReduceOnly: boolean;
219
+ size?: Decimal.Value;
220
+ price?: Decimal.Value;
221
+ quoteSize?: QuoteSize;
222
+ accountId?: number;
223
+ clientOrderId?: BigIntValue;
224
+ }>): Promise<{
269
225
  actionId: bigint;
270
226
  orderId?: bigint;
271
227
  fills: proto.Receipt_Trade[];
@@ -286,30 +242,61 @@ export declare class NordUser extends NordClient {
286
242
  /**
287
243
  * Add a trigger for the current session
288
244
  *
289
- * @param params - Trigger parameters including market, side, and prices
245
+ * @param marketId - Market to watch
246
+ * @param side - Order side for the trigger
247
+ * @param kind - Stop-loss or take-profit trigger type
248
+ * @param triggerPrice - Price that activates the trigger
249
+ * @param limitPrice - Limit price placed once the trigger fires
250
+ * @param accountId - Account executing the trigger
290
251
  * @returns Object containing the actionId of the submitted trigger
291
252
  * @throws {NordError} If the operation fails
292
253
  */
293
- addTrigger(params: AddTriggerParams): Promise<{
254
+ addTrigger({ marketId, side, kind, triggerPrice, limitPrice, accountId, }: Readonly<{
255
+ marketId: number;
256
+ side: Side;
257
+ kind: TriggerKind;
258
+ triggerPrice: Decimal.Value;
259
+ limitPrice?: Decimal.Value;
260
+ accountId?: number;
261
+ }>): Promise<{
294
262
  actionId: bigint;
295
263
  }>;
296
264
  /**
297
265
  * Remove a trigger for the current session
298
266
  *
299
- * @param params - Trigger parameters identifying the trigger to remove
267
+ * @param marketId - Market the trigger belongs to
268
+ * @param side - Order side for the trigger
269
+ * @param kind - Stop-loss or take-profit trigger type
270
+ * @param accountId - Account executing the trigger
300
271
  * @returns Object containing the actionId of the removal action
301
272
  * @throws {NordError} If the operation fails
302
273
  */
303
- removeTrigger(params: RemoveTriggerParams): Promise<{
274
+ removeTrigger({ marketId, side, kind, accountId, }: Readonly<{
275
+ marketId: number;
276
+ side: Side;
277
+ kind: TriggerKind;
278
+ accountId?: number;
279
+ }>): Promise<{
304
280
  actionId: bigint;
305
281
  }>;
306
282
  /**
307
283
  * Transfer tokens to another account
308
284
  *
309
- * @param params - Transfer parameters
285
+ * @param tokenId - Token identifier to move
286
+ * @param amount - Amount to transfer
287
+ * @param fromAccountId - Source account id
288
+ * @param toAccountId - Destination account id
310
289
  * @throws {NordError} If the operation fails
311
290
  */
312
- transferToAccount(params: TransferParams): Promise<void>;
291
+ transferToAccount({ tokenId, amount, fromAccountId, toAccountId, }: Readonly<{
292
+ tokenId: number;
293
+ amount: Decimal.Value;
294
+ fromAccountId?: number;
295
+ toAccountId?: number;
296
+ }>): Promise<{
297
+ actionId: bigint;
298
+ newAccountId?: number;
299
+ }>;
313
300
  /**
314
301
  * Execute up to four place/cancel operations atomically.
315
302
  * Per Market:
@@ -359,4 +346,5 @@ export declare class NordUser extends NordClient {
359
346
  [symbol: string]: string;
360
347
  };
361
348
  }>;
349
+ protected submitSignedAction(kind: proto.Action["kind"], makeSignedMessage: (message: Uint8Array) => Promise<Uint8Array>): Promise<proto.Receipt>;
362
350
  }