@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.
- package/dist/actions.d.ts +57 -0
- package/dist/actions.js +186 -0
- package/dist/bundle.js +79181 -0
- package/dist/{nord/client → client}/Nord.d.ts +90 -107
- package/dist/{nord/client → client}/Nord.js +157 -218
- package/dist/{nord/client → client}/NordAdmin.d.ts +68 -102
- package/dist/{nord/client → client}/NordAdmin.js +109 -140
- package/dist/{nord/client → client}/NordUser.d.ts +86 -98
- package/dist/{nord/client → client}/NordUser.js +204 -271
- package/dist/const.js +5 -8
- package/dist/{nord/utils/NordError.js → error.js} +7 -5
- package/dist/gen/nord_pb.js +88 -92
- package/dist/gen/openapi.d.ts +39 -0
- package/dist/gen/openapi.js +1 -2
- package/dist/index.d.ts +6 -1
- package/dist/index.js +10 -21
- package/dist/types.d.ts +5 -50
- package/dist/types.js +21 -83
- package/dist/utils.d.ts +8 -11
- package/dist/utils.js +55 -90
- package/dist/websocket/NordWebSocketClient.js +12 -17
- package/dist/{nord/models → websocket}/Subscriber.d.ts +1 -1
- package/dist/{nord/models → websocket}/Subscriber.js +6 -7
- package/dist/websocket/events.js +1 -2
- package/dist/websocket/index.d.ts +19 -2
- package/dist/websocket/index.js +80 -5
- package/package.json +2 -3
- package/dist/api/client.d.ts +0 -14
- package/dist/api/client.js +0 -45
- package/dist/bridge/client.d.ts +0 -151
- package/dist/bridge/client.js +0 -434
- package/dist/bridge/const.d.ts +0 -23
- package/dist/bridge/const.js +0 -47
- package/dist/bridge/index.d.ts +0 -4
- package/dist/bridge/index.js +0 -23
- package/dist/bridge/types.d.ts +0 -120
- package/dist/bridge/types.js +0 -18
- package/dist/bridge/utils.d.ts +0 -64
- package/dist/bridge/utils.js +0 -131
- package/dist/gen/common.d.ts +0 -68
- package/dist/gen/common.js +0 -215
- package/dist/gen/nord.d.ts +0 -882
- package/dist/gen/nord.js +0 -6520
- package/dist/idl/bridge.d.ts +0 -569
- package/dist/idl/bridge.js +0 -8
- package/dist/idl/bridge.json +0 -1506
- package/dist/idl/index.d.ts +0 -607
- package/dist/idl/index.js +0 -8
- package/dist/nord/api/actions.d.ts +0 -126
- package/dist/nord/api/actions.js +0 -397
- package/dist/nord/api/core.d.ts +0 -16
- package/dist/nord/api/core.js +0 -81
- package/dist/nord/api/market.d.ts +0 -36
- package/dist/nord/api/market.js +0 -96
- package/dist/nord/api/metrics.d.ts +0 -67
- package/dist/nord/api/metrics.js +0 -229
- package/dist/nord/api/queries.d.ts +0 -46
- package/dist/nord/api/queries.js +0 -109
- package/dist/nord/api/triggers.d.ts +0 -7
- package/dist/nord/api/triggers.js +0 -38
- package/dist/nord/client/NordClient.d.ts +0 -33
- package/dist/nord/client/NordClient.js +0 -45
- package/dist/nord/index.d.ts +0 -11
- package/dist/nord/index.js +0 -36
- package/src/const.ts +0 -34
- package/src/gen/.gitkeep +0 -0
- package/src/gen/nord_pb.ts +0 -5053
- package/src/gen/openapi.ts +0 -2864
- package/src/index.ts +0 -5
- package/src/nord/api/actions.ts +0 -648
- package/src/nord/api/core.ts +0 -96
- package/src/nord/api/metrics.ts +0 -269
- package/src/nord/client/Nord.ts +0 -937
- package/src/nord/client/NordAdmin.ts +0 -514
- package/src/nord/client/NordClient.ts +0 -79
- package/src/nord/client/NordUser.ts +0 -1211
- package/src/nord/index.ts +0 -25
- package/src/nord/models/Subscriber.ts +0 -56
- package/src/nord/utils/NordError.ts +0 -76
- package/src/types.ts +0 -377
- package/src/utils.ts +0 -269
- package/src/websocket/NordWebSocketClient.ts +0 -316
- package/src/websocket/events.ts +0 -31
- package/src/websocket/index.ts +0 -2
- /package/dist/{nord/utils/NordError.d.ts → error.d.ts} +0 -0
|
@@ -1,84 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey, Transaction, SendOptions } from "@solana/web3.js";
|
|
2
2
|
import Decimal from "decimal.js";
|
|
3
|
-
import { FillMode, Side, SPLTokenInfo, QuoteSize, TriggerKind } from "
|
|
4
|
-
import * as proto from "
|
|
5
|
-
import { BigIntValue } from "
|
|
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
|
|
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
|
|
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({
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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
|
}
|