@n1xyz/nord-ts 0.4.0 → 0.4.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/actions.d.ts +13 -0
- package/dist/client/Nord.d.ts +11 -2
- package/dist/client/NordAdmin.d.ts +5 -0
- package/dist/client/NordUser.d.ts +33 -3
- package/dist/gen/nord_pb.d.ts +414 -312
- package/dist/gen/openapi.d.ts +187 -4
- package/dist/index.browser.js +239 -101
- package/dist/index.common.js +242 -104
- package/dist/types.d.ts +37 -3
- package/dist/utils.d.ts +1 -0
- package/dist/websocket/events.d.ts +2 -1
- package/dist/websocket/index.d.ts +2 -1
- package/package.json +16 -16
package/dist/actions.d.ts
CHANGED
|
@@ -31,6 +31,16 @@ export declare function revokeSession(client: Client<paths>, signMessage: (_: Ui
|
|
|
31
31
|
}): Promise<{
|
|
32
32
|
actionId: bigint;
|
|
33
33
|
}>;
|
|
34
|
+
export declare function createTakeAllPositionsInput(params: {
|
|
35
|
+
sessionId: BigIntValue;
|
|
36
|
+
targetAccountId: number;
|
|
37
|
+
}): proto.Action_TakeAllPositions;
|
|
38
|
+
export declare function takeAllPositions(client: Client<paths>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
39
|
+
sessionId: BigIntValue;
|
|
40
|
+
targetAccountId: number;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
actionId: bigint;
|
|
43
|
+
} & proto.Receipt_TakeAllPositionsResult>;
|
|
34
44
|
export type AtomicSubaction = {
|
|
35
45
|
kind: "place";
|
|
36
46
|
marketId: number;
|
|
@@ -46,6 +56,9 @@ export type AtomicSubaction = {
|
|
|
46
56
|
} | {
|
|
47
57
|
kind: "cancel";
|
|
48
58
|
orderId: BigIntValue;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "cancelByClientId";
|
|
61
|
+
clientOrderId: BigIntValue;
|
|
49
62
|
};
|
|
50
63
|
export declare function atomic(client: Client<paths>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
51
64
|
sessionId: BigIntValue;
|
package/dist/client/Nord.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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, CandleResolution } 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, TakeAllInfo } from "../types";
|
|
7
7
|
import { NordWebSocketClient } from "../websocket/index";
|
|
8
8
|
import { OrderbookSubscription, TradeSubscription, CandleSubscription } from "../websocket/Subscriber";
|
|
9
9
|
/**
|
|
@@ -46,6 +46,7 @@ export declare class Nord {
|
|
|
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
48
|
* @param candles - Candle subscriptions with symbol and resolution
|
|
49
|
+
* @param liquidations - Whether to subscribe to take-all liquidation updates
|
|
49
50
|
* @returns A new WebSocket client with the requested subscriptions
|
|
50
51
|
* @throws {NordError} If invalid subscription options are provided
|
|
51
52
|
*
|
|
@@ -63,7 +64,7 @@ export declare class Nord {
|
|
|
63
64
|
* trades: ["BTCUSDC", "ETHUSDC"]
|
|
64
65
|
* });
|
|
65
66
|
*/
|
|
66
|
-
createWebSocketClient({ trades, deltas, accounts, candles, }: Readonly<{
|
|
67
|
+
createWebSocketClient({ trades, deltas, accounts, candles, liquidations, }: Readonly<{
|
|
67
68
|
trades?: string[];
|
|
68
69
|
deltas?: string[];
|
|
69
70
|
accounts?: number[];
|
|
@@ -71,6 +72,7 @@ export declare class Nord {
|
|
|
71
72
|
symbol: string;
|
|
72
73
|
resolution: CandleResolution;
|
|
73
74
|
}>;
|
|
75
|
+
liquidations?: boolean;
|
|
74
76
|
}>): NordWebSocketClient;
|
|
75
77
|
private GET;
|
|
76
78
|
/**
|
|
@@ -105,6 +107,13 @@ export declare class Nord {
|
|
|
105
107
|
* @throws {NordError} If the request fails
|
|
106
108
|
*/
|
|
107
109
|
getAccountVolume({ accountId, since, until, marketId, }: Readonly<GetAccountVolumeQuery>): Promise<Array<AccountVolumeInfo>>;
|
|
110
|
+
/**
|
|
111
|
+
* Get recent take-all liquidation rows.
|
|
112
|
+
*
|
|
113
|
+
* @returns Recent take-all history entries
|
|
114
|
+
* @throws {NordError} If the request fails
|
|
115
|
+
*/
|
|
116
|
+
getTakeAlls(): Promise<Array<TakeAllInfo>>;
|
|
108
117
|
/**
|
|
109
118
|
* Fetch information about Nord markets and tokens
|
|
110
119
|
*
|
|
@@ -151,6 +151,11 @@ export declare class NordAdmin {
|
|
|
151
151
|
unpause(): Promise<{
|
|
152
152
|
actionId: bigint;
|
|
153
153
|
}>;
|
|
154
|
+
setBackstopAccount({ accountId, }: Readonly<{
|
|
155
|
+
accountId: number;
|
|
156
|
+
}>): Promise<{
|
|
157
|
+
actionId: bigint;
|
|
158
|
+
} & proto.Receipt_BackstopAccountSet>;
|
|
154
159
|
/**
|
|
155
160
|
* Freeze an individual market, preventing new trades and orders.
|
|
156
161
|
*
|
|
@@ -9,7 +9,7 @@ import { Nord } from "./Nord";
|
|
|
9
9
|
*/
|
|
10
10
|
export interface UserAtomicSubaction {
|
|
11
11
|
/** The type of action to perform. */
|
|
12
|
-
kind: "place" | "cancel";
|
|
12
|
+
kind: "place" | "cancel" | "cancelByClientId";
|
|
13
13
|
/** The market ID to place the order in. */
|
|
14
14
|
marketId?: number;
|
|
15
15
|
/** The order ID to cancel. */
|
|
@@ -29,6 +29,22 @@ export interface UserAtomicSubaction {
|
|
|
29
29
|
/** The client order ID of the order. */
|
|
30
30
|
clientOrderId?: BigIntValue;
|
|
31
31
|
}
|
|
32
|
+
export interface NormalizedReceiptTrade {
|
|
33
|
+
orderId: bigint;
|
|
34
|
+
price: number;
|
|
35
|
+
size: number;
|
|
36
|
+
accountId: number;
|
|
37
|
+
}
|
|
38
|
+
export interface NormalizedTakeAllBalance {
|
|
39
|
+
tokenId: number;
|
|
40
|
+
amount: number;
|
|
41
|
+
}
|
|
42
|
+
export interface NormalizedTakeAllPosition {
|
|
43
|
+
marketId: number;
|
|
44
|
+
baseSize: number;
|
|
45
|
+
settlementPrice: number;
|
|
46
|
+
bankruptcyPrice: number;
|
|
47
|
+
}
|
|
32
48
|
/**
|
|
33
49
|
* User class for interacting with the Nord protocol
|
|
34
50
|
*/
|
|
@@ -240,7 +256,7 @@ export declare class NordUser {
|
|
|
240
256
|
* @param quoteSize - Quote-sized order representation
|
|
241
257
|
* @param accountId - Account executing the order
|
|
242
258
|
* @param clientOrderId - Optional client-specified identifier
|
|
243
|
-
* @returns Object containing actionId, orderId (if posted), fills, and
|
|
259
|
+
* @returns Object containing actionId, orderId (if posted), fills, and reducedOrders (reduce-only orders fully or partially cancelled by maintenance)
|
|
244
260
|
* @throws {NordError} If the operation fails
|
|
245
261
|
*/
|
|
246
262
|
placeOrder({ marketId, side, fillMode, isReduceOnly, size, price, quoteSize, accountId, clientOrderId, }: Readonly<{
|
|
@@ -256,7 +272,13 @@ export declare class NordUser {
|
|
|
256
272
|
}>): Promise<{
|
|
257
273
|
actionId: bigint;
|
|
258
274
|
orderId?: bigint;
|
|
259
|
-
fills:
|
|
275
|
+
fills: NormalizedReceiptTrade[];
|
|
276
|
+
reducedOrders: {
|
|
277
|
+
orderId: bigint;
|
|
278
|
+
remainingSize: number;
|
|
279
|
+
cancelledSize: number;
|
|
280
|
+
price: number;
|
|
281
|
+
}[];
|
|
260
282
|
}>;
|
|
261
283
|
/**
|
|
262
284
|
* Cancel an order
|
|
@@ -284,6 +306,14 @@ export declare class NordUser {
|
|
|
284
306
|
orderId: bigint;
|
|
285
307
|
accountId: number;
|
|
286
308
|
}>;
|
|
309
|
+
takePositions({ targetAccountId, }: Readonly<{
|
|
310
|
+
targetAccountId: number;
|
|
311
|
+
}>): Promise<{
|
|
312
|
+
actionId: bigint;
|
|
313
|
+
takerAccountId: number;
|
|
314
|
+
takenBalances: NormalizedTakeAllBalance[];
|
|
315
|
+
takenPositions: NormalizedTakeAllPosition[];
|
|
316
|
+
}>;
|
|
287
317
|
/**
|
|
288
318
|
* Add a trigger for the current session
|
|
289
319
|
*
|