@n1xyz/nord-ts 0.7.2 → 0.7.3
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 +31 -20
- package/dist/client/Nord.d.ts +10 -2
- package/dist/client/NordUser.d.ts +20 -21
- package/dist/gen/nord_pb.d.ts +217 -179
- package/dist/gen/openapi.d.ts +13 -82
- package/dist/index.browser.js +205 -183
- package/dist/index.common.js +208 -186
- package/dist/types.d.ts +7 -8
- package/package.json +1 -1
- package/dist/gen/core_pb.d.ts +0 -120
- package/dist/gen/src/components/rfq/rfq_pb.d.ts +0 -791
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 { type Duration, FillMode,
|
|
5
|
+
import { type Duration, FillMode, 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"]>;
|
|
@@ -58,7 +58,21 @@ export declare function takeAllPositions(client: Client<paths>, signFn: (message
|
|
|
58
58
|
}): Promise<{
|
|
59
59
|
actionId: bigint;
|
|
60
60
|
} & proto.Receipt_TakeAllPositionsResult>;
|
|
61
|
-
export type
|
|
61
|
+
export type AtomicSelfTarget = {
|
|
62
|
+
targetAccountId?: never;
|
|
63
|
+
useKey?: never;
|
|
64
|
+
};
|
|
65
|
+
export type AtomicDelegatedTarget = {
|
|
66
|
+
targetAccountId: number;
|
|
67
|
+
useKey?: false;
|
|
68
|
+
};
|
|
69
|
+
export type AtomicKeyedTarget = {
|
|
70
|
+
targetAccountId: number;
|
|
71
|
+
useKey: true;
|
|
72
|
+
};
|
|
73
|
+
export type AtomicTarget = AtomicSelfTarget | AtomicDelegatedTarget | AtomicKeyedTarget;
|
|
74
|
+
export type AtomicSelfOrKeyedTarget = AtomicSelfTarget | AtomicKeyedTarget;
|
|
75
|
+
export type AtomicSubaction = (AtomicTarget & ({
|
|
62
76
|
kind: "place";
|
|
63
77
|
marketId: number;
|
|
64
78
|
side: Side;
|
|
@@ -70,26 +84,17 @@ export type AtomicSubaction = {
|
|
|
70
84
|
price?: Decimal.Value;
|
|
71
85
|
quoteSize?: Decimal.Value;
|
|
72
86
|
clientOrderId?: BigIntValue;
|
|
73
|
-
delegatorAccountId?: number;
|
|
74
|
-
placement?: PlacementRequest;
|
|
75
87
|
referrer?: BigIntValue;
|
|
76
88
|
} | {
|
|
77
89
|
kind: "cancel";
|
|
78
90
|
orderId: BigIntValue;
|
|
79
|
-
delegatorAccountId?: number;
|
|
80
|
-
placement?: PlacementRequest;
|
|
81
91
|
} | {
|
|
82
92
|
kind: "cancelByClientId";
|
|
83
93
|
clientOrderId: BigIntValue;
|
|
84
|
-
|
|
85
|
-
placement?: PlacementRequest;
|
|
86
|
-
} | {
|
|
94
|
+
})) | (AtomicDelegatedTarget & {
|
|
87
95
|
kind: "reduceOrderLiquidation";
|
|
88
|
-
targetAccountId: number;
|
|
89
96
|
marketId: number;
|
|
90
|
-
|
|
91
|
-
placement?: PlacementRequest;
|
|
92
|
-
} | {
|
|
97
|
+
}) | (AtomicSelfOrKeyedTarget & ({
|
|
93
98
|
kind: "rfq";
|
|
94
99
|
marketId: number;
|
|
95
100
|
side: Side;
|
|
@@ -99,7 +104,9 @@ export type AtomicSubaction = {
|
|
|
99
104
|
size: Decimal.Value;
|
|
100
105
|
timeout?: Duration;
|
|
101
106
|
clientOrderId?: BigIntValue;
|
|
102
|
-
|
|
107
|
+
minimumSize?: BigIntValue;
|
|
108
|
+
maximumSize?: BigIntValue;
|
|
109
|
+
isReduceOnly?: boolean;
|
|
103
110
|
} | {
|
|
104
111
|
kind: "rfqFill";
|
|
105
112
|
marketId: number;
|
|
@@ -107,7 +114,9 @@ export type AtomicSubaction = {
|
|
|
107
114
|
priceDecimals: number;
|
|
108
115
|
price: Decimal.Value;
|
|
109
116
|
timeout?: Duration;
|
|
110
|
-
|
|
117
|
+
minimumSize?: BigIntValue;
|
|
118
|
+
maximumSize?: BigIntValue;
|
|
119
|
+
isReduceOnly?: boolean;
|
|
111
120
|
} | {
|
|
112
121
|
kind: "addTrigger";
|
|
113
122
|
marketId: number;
|
|
@@ -119,7 +128,6 @@ export type AtomicSubaction = {
|
|
|
119
128
|
limitPrice?: Decimal.Value;
|
|
120
129
|
limitBaseSize?: Decimal.Value;
|
|
121
130
|
limitQuoteSize?: Decimal.Value;
|
|
122
|
-
placement?: PlacementRequest;
|
|
123
131
|
referrer?: BigIntValue;
|
|
124
132
|
} | {
|
|
125
133
|
kind: "editTrigger";
|
|
@@ -133,14 +141,17 @@ export type AtomicSubaction = {
|
|
|
133
141
|
limitPrice?: Decimal.Value;
|
|
134
142
|
limitBaseSize?: Decimal.Value;
|
|
135
143
|
limitQuoteSize?: Decimal.Value;
|
|
136
|
-
placement?: PlacementRequest;
|
|
137
144
|
} | {
|
|
138
145
|
kind: "removeTrigger";
|
|
139
146
|
marketId: number;
|
|
140
147
|
triggerId: BigIntValue;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
export declare function
|
|
148
|
+
}));
|
|
149
|
+
export declare function atomicSubactionToProto(currentTimestamp: bigint, a: AtomicSubaction): proto.AtomicSubaction;
|
|
150
|
+
export declare function createAtomicAction(currentTimestamp: bigint, nonce: number, params: {
|
|
151
|
+
sessionId: BigIntValue;
|
|
152
|
+
accountId?: number;
|
|
153
|
+
actions: AtomicSubaction[];
|
|
154
|
+
}): proto.Action;
|
|
144
155
|
export declare function atomic(client: Client<paths>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
145
156
|
sessionId: BigIntValue;
|
|
146
157
|
accountId?: number;
|
package/dist/client/Nord.d.ts
CHANGED
|
@@ -26,8 +26,9 @@ export declare class Nord {
|
|
|
26
26
|
tokens: Token[];
|
|
27
27
|
/** Map of symbol to market_id */
|
|
28
28
|
private symbolToMarketId;
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/** Configuration and lazily initialized client for proton operations. */
|
|
30
|
+
private readonly protonConfig;
|
|
31
|
+
private protonClientPromise?;
|
|
31
32
|
/** HTTP client for Nord operations */
|
|
32
33
|
readonly httpClient: Client<paths>;
|
|
33
34
|
/**
|
|
@@ -39,6 +40,13 @@ export declare class Nord {
|
|
|
39
40
|
* @throws {Error} If required configuration is missing
|
|
40
41
|
*/
|
|
41
42
|
private constructor();
|
|
43
|
+
/**
|
|
44
|
+
* Get the Proton client, initializing it on first use.
|
|
45
|
+
*
|
|
46
|
+
* Concurrent callers share the same initialization attempt. A failed attempt
|
|
47
|
+
* is not cached, allowing a later call to retry after Proton recovers.
|
|
48
|
+
*/
|
|
49
|
+
getProtonClient(): Promise<ProtonClient>;
|
|
42
50
|
/**
|
|
43
51
|
* Create a WebSocket client with specific subscriptions
|
|
44
52
|
*
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { PublicKey, Transaction, SendOptions } from "@solana/web3.js";
|
|
2
2
|
import Decimal from "decimal.js";
|
|
3
|
-
import { FillMode, Side, SPLTokenInfo, TriggerKind, SelfTradePrevention,
|
|
3
|
+
import { FillMode, Side, SPLTokenInfo, TriggerKind, SelfTradePrevention, VaultWithdrawRequestKind, type Duration, type RfqFillResult } from "../types";
|
|
4
4
|
import * as proto from "../gen/nord_pb";
|
|
5
5
|
import { BigIntValue } from "../utils";
|
|
6
|
+
import { AtomicDelegatedTarget, AtomicSelfOrKeyedTarget, AtomicTarget } from "../actions";
|
|
6
7
|
import { Nord } from "./Nord";
|
|
7
|
-
export type UserAtomicSubaction = {
|
|
8
|
+
export type UserAtomicSubaction = (AtomicTarget & ({
|
|
8
9
|
kind: "place";
|
|
9
10
|
marketId: number;
|
|
10
11
|
side: Side;
|
|
@@ -14,26 +15,17 @@ export type UserAtomicSubaction = {
|
|
|
14
15
|
price?: Decimal.Value;
|
|
15
16
|
quoteSize?: Decimal.Value;
|
|
16
17
|
clientOrderId?: BigIntValue;
|
|
17
|
-
delegatorAccountId?: number;
|
|
18
|
-
placement?: PlacementRequest;
|
|
19
18
|
referrer?: BigIntValue;
|
|
20
19
|
} | {
|
|
21
20
|
kind: "cancel";
|
|
22
21
|
orderId: BigIntValue;
|
|
23
|
-
delegatorAccountId?: number;
|
|
24
|
-
placement?: PlacementRequest;
|
|
25
22
|
} | {
|
|
26
23
|
kind: "cancelByClientId";
|
|
27
24
|
clientOrderId: BigIntValue;
|
|
28
|
-
|
|
29
|
-
placement?: PlacementRequest;
|
|
30
|
-
} | {
|
|
25
|
+
})) | (AtomicDelegatedTarget & {
|
|
31
26
|
kind: "reduceOrderLiquidation";
|
|
32
|
-
targetAccountId: number;
|
|
33
27
|
marketId: number;
|
|
34
|
-
|
|
35
|
-
placement?: PlacementRequest;
|
|
36
|
-
} | {
|
|
28
|
+
}) | (AtomicSelfOrKeyedTarget & ({
|
|
37
29
|
kind: "rfq";
|
|
38
30
|
marketId: number;
|
|
39
31
|
side: Side;
|
|
@@ -41,14 +33,18 @@ export type UserAtomicSubaction = {
|
|
|
41
33
|
size: Decimal.Value;
|
|
42
34
|
timeout?: Duration;
|
|
43
35
|
clientOrderId?: BigIntValue;
|
|
44
|
-
|
|
36
|
+
minimumSize?: BigIntValue;
|
|
37
|
+
maximumSize?: BigIntValue;
|
|
38
|
+
isReduceOnly?: boolean;
|
|
45
39
|
} | {
|
|
46
40
|
kind: "rfqFill";
|
|
47
41
|
marketId: number;
|
|
48
42
|
orderId: BigIntValue;
|
|
49
43
|
price: Decimal.Value;
|
|
50
44
|
timeout?: Duration;
|
|
51
|
-
|
|
45
|
+
minimumSize?: BigIntValue;
|
|
46
|
+
maximumSize?: BigIntValue;
|
|
47
|
+
isReduceOnly?: boolean;
|
|
52
48
|
} | {
|
|
53
49
|
kind: "addTrigger";
|
|
54
50
|
marketId: number;
|
|
@@ -58,7 +54,6 @@ export type UserAtomicSubaction = {
|
|
|
58
54
|
limitPrice?: Decimal.Value;
|
|
59
55
|
limitBaseSize?: Decimal.Value;
|
|
60
56
|
limitQuoteSize?: Decimal.Value;
|
|
61
|
-
placement?: PlacementRequest;
|
|
62
57
|
referrer?: BigIntValue;
|
|
63
58
|
} | {
|
|
64
59
|
kind: "editTrigger";
|
|
@@ -70,13 +65,11 @@ export type UserAtomicSubaction = {
|
|
|
70
65
|
limitPrice?: Decimal.Value;
|
|
71
66
|
limitBaseSize?: Decimal.Value;
|
|
72
67
|
limitQuoteSize?: Decimal.Value;
|
|
73
|
-
placement?: PlacementRequest;
|
|
74
68
|
} | {
|
|
75
69
|
kind: "removeTrigger";
|
|
76
70
|
marketId: number;
|
|
77
71
|
triggerId: BigIntValue;
|
|
78
|
-
|
|
79
|
-
};
|
|
72
|
+
}));
|
|
80
73
|
export declare function decodeRfqFillResult(actionId: bigint, result: proto.Receipt_AtomicSubactionResultKind["inner"] | undefined): RfqFillResult;
|
|
81
74
|
export interface NormalizedReceiptTrade {
|
|
82
75
|
orderId: bigint;
|
|
@@ -405,7 +398,7 @@ export declare class NordUser {
|
|
|
405
398
|
orderId: bigint;
|
|
406
399
|
accountId: number;
|
|
407
400
|
}>;
|
|
408
|
-
placeRfqOrder({ marketId, side, size, price, timeout, accountId, clientOrderId, }: Readonly<{
|
|
401
|
+
placeRfqOrder({ marketId, side, size, price, timeout, accountId, clientOrderId, minimumSize, maximumSize, isReduceOnly, }: Readonly<{
|
|
409
402
|
marketId: number;
|
|
410
403
|
side: Side;
|
|
411
404
|
size: Decimal.Value;
|
|
@@ -413,16 +406,22 @@ export declare class NordUser {
|
|
|
413
406
|
timeout?: Duration;
|
|
414
407
|
accountId?: number;
|
|
415
408
|
clientOrderId?: BigIntValue;
|
|
409
|
+
minimumSize?: BigIntValue;
|
|
410
|
+
maximumSize?: BigIntValue;
|
|
411
|
+
isReduceOnly?: boolean;
|
|
416
412
|
}>): Promise<{
|
|
417
413
|
actionId: bigint;
|
|
418
414
|
orderId: bigint;
|
|
419
415
|
}>;
|
|
420
|
-
fillRfqOrder({ marketId, orderId, price, timeout, accountId, }: Readonly<{
|
|
416
|
+
fillRfqOrder({ marketId, orderId, price, timeout, accountId, minimumSize, maximumSize, isReduceOnly, }: Readonly<{
|
|
421
417
|
marketId: number;
|
|
422
418
|
orderId: BigIntValue;
|
|
423
419
|
price: Decimal.Value;
|
|
424
420
|
timeout?: Duration;
|
|
425
421
|
accountId?: number;
|
|
422
|
+
minimumSize?: BigIntValue;
|
|
423
|
+
maximumSize?: BigIntValue;
|
|
424
|
+
isReduceOnly?: boolean;
|
|
426
425
|
}>): Promise<RfqFillResult>;
|
|
427
426
|
/**
|
|
428
427
|
* Cancel an order by client_order_id.
|