@n1xyz/nord-ts 0.5.1 → 0.6.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
@@ -2,7 +2,7 @@ import Decimal from "decimal.js";
2
2
  import * as proto from "./gen/nord_pb";
3
3
  import { paths } from "./gen/openapi";
4
4
  import { Client } from "openapi-fetch";
5
- import { FillMode, Side, TriggerKind } from "./types";
5
+ import { FillMode, PlacementRequest, Side, TriggerKind } from "./types";
6
6
  import { BigIntValue } from "./utils";
7
7
  import { PublicKey, Transaction } from "@solana/web3.js";
8
8
  type ReceiptKind = NonNullable<proto.Receipt["kind"]>;
@@ -14,6 +14,7 @@ export declare function expectReceiptKind<K extends ReceiptKind["case"]>(receipt
14
14
  kind: ExtractReceiptKind<K>;
15
15
  };
16
16
  export declare function buildLimits(marketPriceDecimals: number, marketSizeDecimals: number, limitPrice?: Decimal.Value, limitBaseSize?: Decimal.Value, limitQuoteSize?: Decimal.Value): proto.OrderLimit | undefined;
17
+ export declare function toProtoU128(value: BigIntValue): proto.U128;
17
18
  export declare function createAction(currentTimestamp: bigint, nonce: number, kind: proto.Action["kind"]): proto.Action;
18
19
  export declare function sendAction(client: Client<paths>, makeSignedMessage: (message: Uint8Array) => Promise<Uint8Array>, action: proto.Action): Promise<proto.Receipt>;
19
20
  export declare function prepareAction(action: proto.Action, makeSignedMessage: (message: Uint8Array) => Promise<Uint8Array>): Promise<Uint8Array<ArrayBufferLike>>;
@@ -55,14 +56,18 @@ export type AtomicSubaction = {
55
56
  quoteSize?: Decimal.Value;
56
57
  clientOrderId?: BigIntValue;
57
58
  delegatorAccountId?: number;
59
+ placement?: PlacementRequest;
60
+ referrer?: BigIntValue;
58
61
  } | {
59
62
  kind: "cancel";
60
63
  orderId: BigIntValue;
61
64
  delegatorAccountId?: number;
65
+ placement?: PlacementRequest;
62
66
  } | {
63
67
  kind: "cancelByClientId";
64
68
  clientOrderId: BigIntValue;
65
69
  delegatorAccountId?: number;
70
+ placement?: PlacementRequest;
66
71
  } | {
67
72
  kind: "addTrigger";
68
73
  marketId: number;
@@ -74,6 +79,8 @@ export type AtomicSubaction = {
74
79
  limitPrice?: Decimal.Value;
75
80
  limitBaseSize?: Decimal.Value;
76
81
  limitQuoteSize?: Decimal.Value;
82
+ placement?: PlacementRequest;
83
+ referrer?: BigIntValue;
77
84
  } | {
78
85
  kind: "editTrigger";
79
86
  triggerId: BigIntValue;
@@ -86,10 +93,12 @@ export type AtomicSubaction = {
86
93
  limitPrice?: Decimal.Value;
87
94
  limitBaseSize?: Decimal.Value;
88
95
  limitQuoteSize?: Decimal.Value;
96
+ placement?: PlacementRequest;
89
97
  } | {
90
98
  kind: "removeTrigger";
91
99
  marketId: number;
92
100
  triggerId: BigIntValue;
101
+ placement?: PlacementRequest;
93
102
  };
94
103
  export declare function atomic(client: Client<paths>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
95
104
  sessionId: BigIntValue;
@@ -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, AccountPositionInfoPage, AccountPnlSummaryResult, AtomicActionId, GetAccountPnlQuery, PagedQuery, ActionResponse, MarketsInfo, Market, MarketStats, NordConfig, OrderbookQuery, OrderbookResponse, FeeTierConfig, Token, TradesResponse, User, AccountTriggerInfo, TriggerPlaceHistoryPage, TriggerFinaliseHistoryPage, WithdrawalHistoryPage, FeeTierId, AccountFeeTierPage, PageResultStringOrderInfo, PageResultStringTrade, OrderInfoFromApi, TokenStats, FillRole, AdminInfo, AccountVolumeInfo, GetAccountVolumeQuery, CandleResolution, TakeAllInfo, MarketsLiveInfo, MarketLiveInfo } from "../types";
6
+ import { Account, AccountPnlInfoPage, AccountPositionInfoPage, AccountPnlSummaryResult, ActionIdSubActionIdMarketIdCursor, AtomicActionId, GetAccountPositionHistoryQuery, GetAccountPnlQuery, PagedQuery, ActionResponse, MarketsInfo, Market, MarketStats, NordConfig, OrderbookQuery, OrderbookResponse, FeeTierConfig, Token, TradesResponse, User, AccountTriggerInfo, TriggerPlaceHistoryPage, TriggerFinaliseHistoryPage, WithdrawalHistoryPage, FeeTierId, AccountFeeTierPage, PageResultStringOrderInfo, PageResultStringTrade, OrderInfoFromApi, TokenStats, FillRole, AdminInfo, AccountVolumeInfo, GetAccountVolumeQuery, CandleResolution, TakeAllInfo, MarketsLiveInfo, MarketLiveInfo } from "../types";
7
7
  import { NordWebSocketClient } from "../websocket/index";
8
8
  import { OrderbookSubscription, TradeSubscription, CandleSubscription } from "../websocket/Subscriber";
9
9
  /**
@@ -321,7 +321,10 @@ export declare class Nord {
321
321
  * @returns Page of PnL entries ordered from latest to oldest
322
322
  * @throws {NordError} If the request fails
323
323
  */
324
- getAccountPnl(accountId: number, { since, until, startInclusive, pageSize, }?: Readonly<Partial<PagedQuery>>): Promise<AccountPnlInfoPage>;
324
+ getAccountPnl(accountId: number, { since, until, startInclusive, pageSize, }?: Readonly<Partial<GetAccountPnlQuery> & {
325
+ startInclusive?: ActionIdSubActionIdMarketIdCursor;
326
+ pageSize?: number;
327
+ }>): Promise<AccountPnlInfoPage>;
325
328
  /**
326
329
  * Get profit and loss totals for an account over a time window.
327
330
  *
@@ -344,9 +347,7 @@ export declare class Nord {
344
347
  * @returns History of position updates
345
348
  * @throws {NordError} If the request fails
346
349
  */
347
- getAccountPositionHistory(accountId: number, { since, until, marketId, pageSize, startInclusive, }?: Readonly<Partial<GetAccountPnlQuery & Omit<PagedQuery, "startInclusive">> & {
348
- startInclusive?: string;
349
- }>): Promise<AccountPositionInfoPage>;
350
+ getAccountPositionHistory(accountId: number, { since, until, marketId, pageSize, startInclusive, }?: Readonly<Partial<GetAccountPositionHistoryQuery>>): Promise<AccountPositionInfoPage>;
350
351
  getAccountPnlSummary(accountId: number, { since, until, marketId }?: Readonly<Partial<GetAccountPnlQuery>>): Promise<AccountPnlSummaryResult>;
351
352
  getMarketsLive(): Promise<MarketsLiveInfo>;
352
353
  getMarketLive({ marketId, }: Readonly<{
@@ -156,6 +156,24 @@ export declare class NordAdmin {
156
156
  }>): Promise<{
157
157
  actionId: bigint;
158
158
  } & proto.Receipt_BackstopAccountSet>;
159
+ createVault({ manager, config, }: Readonly<{
160
+ manager: PublicKey;
161
+ config: proto.VaultConfig;
162
+ }>): Promise<{
163
+ actionId: bigint;
164
+ } & proto.CreateVaultReceipt>;
165
+ updateVaultConfig({ vaultId, configPatch, }: Readonly<{
166
+ vaultId: number;
167
+ configPatch: proto.VaultConfigPatch;
168
+ }>): Promise<{
169
+ actionId: bigint;
170
+ } & proto.UpdateVaultConfigReceipt>;
171
+ setVaultManager({ vaultId, manager, }: Readonly<{
172
+ vaultId: number;
173
+ manager: PublicKey;
174
+ }>): Promise<{
175
+ actionId: bigint;
176
+ } & proto.SetVaultManagerReceipt>;
159
177
  /**
160
178
  * Freeze an individual market, preventing new trades and orders.
161
179
  *
@@ -180,6 +198,24 @@ export declare class NordAdmin {
180
198
  }>): Promise<{
181
199
  actionId: bigint;
182
200
  } & proto.Receipt_MarketFreezeUpdated>;
201
+ /**
202
+ * Prepare a production delisting clear for an admin-frozen market.
203
+ *
204
+ * Only a super admin or market manager can submit this action. The market must
205
+ * already be frozen by an admin action. This cancels every open order and
206
+ * closes all positions at the provided clearance price mantissa.
207
+ *
208
+ * @param marketId - Target admin-frozen market identifier
209
+ * @param clearancePrice - Settlement price mantissa used for closing positions
210
+ * @returns Action identifier and clear-market receipt
211
+ * @throws {NordError} If the action submission fails
212
+ */
213
+ clearMarket({ marketId, clearancePrice, }: Readonly<{
214
+ marketId: number;
215
+ clearancePrice: bigint;
216
+ }>): Promise<{
217
+ actionId: bigint;
218
+ } & proto.Receipt_ClearMarketResult>;
183
219
  /**
184
220
  * Append a new fee tier to the account bracket configuration.
185
221
  *
@@ -1,6 +1,6 @@
1
1
  import { PublicKey, Transaction, SendOptions } from "@solana/web3.js";
2
2
  import Decimal from "decimal.js";
3
- import { FillMode, Side, SPLTokenInfo, TriggerKind, SelfTradePrevention } from "../types";
3
+ import { FillMode, Side, SPLTokenInfo, TriggerKind, SelfTradePrevention, PlacementRequest, VaultWithdrawRequestKind } from "../types";
4
4
  import * as proto from "../gen/nord_pb";
5
5
  import { BigIntValue } from "../utils";
6
6
  import { Nord } from "./Nord";
@@ -15,14 +15,18 @@ export type UserAtomicSubaction = {
15
15
  quoteSize?: Decimal.Value;
16
16
  clientOrderId?: BigIntValue;
17
17
  delegatorAccountId?: number;
18
+ placement?: PlacementRequest;
19
+ referrer?: BigIntValue;
18
20
  } | {
19
21
  kind: "cancel";
20
22
  orderId: BigIntValue;
21
23
  delegatorAccountId?: number;
24
+ placement?: PlacementRequest;
22
25
  } | {
23
26
  kind: "cancelByClientId";
24
27
  clientOrderId: BigIntValue;
25
28
  delegatorAccountId?: number;
29
+ placement?: PlacementRequest;
26
30
  } | {
27
31
  kind: "addTrigger";
28
32
  marketId: number;
@@ -32,6 +36,8 @@ export type UserAtomicSubaction = {
32
36
  limitPrice?: Decimal.Value;
33
37
  limitBaseSize?: Decimal.Value;
34
38
  limitQuoteSize?: Decimal.Value;
39
+ placement?: PlacementRequest;
40
+ referrer?: BigIntValue;
35
41
  } | {
36
42
  kind: "editTrigger";
37
43
  triggerId: BigIntValue;
@@ -42,10 +48,12 @@ export type UserAtomicSubaction = {
42
48
  limitPrice?: Decimal.Value;
43
49
  limitBaseSize?: Decimal.Value;
44
50
  limitQuoteSize?: Decimal.Value;
51
+ placement?: PlacementRequest;
45
52
  } | {
46
53
  kind: "removeTrigger";
47
54
  marketId: number;
48
55
  triggerId: BigIntValue;
56
+ placement?: PlacementRequest;
49
57
  };
50
58
  export interface NormalizedReceiptTrade {
51
59
  orderId: bigint;
@@ -233,7 +241,7 @@ export declare class NordUser {
233
241
  *
234
242
  * @throws {NordError} If the operation fails
235
243
  */
236
- refreshSession(): Promise<void>;
244
+ refreshSession(expiryTimestamp?: bigint): Promise<void>;
237
245
  /**
238
246
  * Revoke a session
239
247
  *
@@ -262,6 +270,29 @@ export declare class NordUser {
262
270
  }>): Promise<{
263
271
  actionId: bigint;
264
272
  }>;
273
+ vaultDeposit({ vaultId, amount, }: Readonly<{
274
+ vaultId: number;
275
+ amount: Decimal.Value;
276
+ }>): Promise<{
277
+ actionId: bigint;
278
+ } & proto.VaultDepositReceipt>;
279
+ vaultWithdrawRequest({ vaultId, kind, amount, }: Readonly<{
280
+ vaultId: number;
281
+ kind: VaultWithdrawRequestKind;
282
+ amount: Decimal.Value;
283
+ }>): Promise<{
284
+ actionId: bigint;
285
+ } & proto.VaultWithdrawReceipt>;
286
+ vaultWithdrawClaim({ vaultId, }: Readonly<{
287
+ vaultId: number;
288
+ }>): Promise<{
289
+ actionId: bigint;
290
+ } & proto.VaultWithdrawReceipt>;
291
+ vaultSyncEpochs({ vaultId, }: Readonly<{
292
+ vaultId: number;
293
+ }>): Promise<{
294
+ actionId: bigint;
295
+ } & proto.VaultSyncEpochsReceipt>;
265
296
  /**
266
297
  * Place an order on the exchange
267
298
  *
@@ -274,10 +305,11 @@ export declare class NordUser {
274
305
  * @param quoteSize - Quote-sized order representation
275
306
  * @param accountId - Account executing the order
276
307
  * @param clientOrderId - Optional client-specified identifier
308
+ * @param referrer - Optional referrer ID. Tracks which frontend/referral source placed order.
277
309
  * @returns Object containing actionId, orderId (if posted), fills, and reducedOrders (reduce-only orders fully or partially cancelled by maintenance)
278
310
  * @throws {NordError} If the operation fails
279
311
  */
280
- placeOrder({ marketId, side, fillMode, isReduceOnly, size, price, quoteSize, selfTradePrevention, accountId, clientOrderId, }: Readonly<{
312
+ placeOrder({ marketId, side, fillMode, isReduceOnly, size, price, quoteSize, selfTradePrevention, accountId, clientOrderId, referrer, }: Readonly<{
281
313
  marketId: number;
282
314
  side: Side;
283
315
  fillMode: FillMode;
@@ -288,6 +320,7 @@ export declare class NordUser {
288
320
  selfTradePrevention?: SelfTradePrevention;
289
321
  accountId?: number;
290
322
  clientOrderId?: BigIntValue;
323
+ referrer?: BigIntValue;
291
324
  }>): Promise<{
292
325
  actionId: bigint;
293
326
  orderId?: bigint;
@@ -350,6 +383,7 @@ export declare class NordUser {
350
383
  * @param limitBaseSize - Optional base size limit used once the trigger fires
351
384
  * @param limitQuoteSize - Optional quote size limit used once the trigger fires
352
385
  * @param accountId - Account executing the trigger
386
+ * @param referrer - Optional referrer ID. Tracks which frontend/referral source placed trigger
353
387
  * @returns Object containing the actionId of the submitted trigger
354
388
  * @throws {NordError} If the operation fails
355
389
  *
@@ -359,7 +393,7 @@ export declare class NordUser {
359
393
  *
360
394
  * Max triggers per position: 16
361
395
  */
362
- addTrigger({ marketId, side, kind, triggerPrice, limitPrice, limitBaseSize, limitQuoteSize, accountId, }: Readonly<{
396
+ addTrigger({ marketId, side, kind, triggerPrice, limitPrice, limitBaseSize, limitQuoteSize, accountId, referrer, }: Readonly<{
363
397
  marketId: number;
364
398
  side: Side;
365
399
  kind: TriggerKind;
@@ -368,6 +402,7 @@ export declare class NordUser {
368
402
  limitBaseSize?: Decimal.Value;
369
403
  limitQuoteSize?: Decimal.Value;
370
404
  accountId?: number;
405
+ referrer?: BigIntValue;
371
406
  }>): Promise<{
372
407
  actionId: bigint;
373
408
  triggerId: bigint;