@0xmonaco/types 1.1.2-develop.3a25169 → 1.1.5-develop.129b2c6
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/README.md +1 -1
- package/dist/analytics/builders.d.ts +131 -0
- package/dist/analytics/builders.js +11 -0
- package/dist/analytics/index.d.ts +151 -0
- package/dist/analytics/index.js +27 -0
- package/dist/analytics/wallets.d.ts +193 -0
- package/dist/analytics/wallets.js +16 -0
- package/dist/applications/requests.d.ts +5 -5
- package/dist/buildercodes/index.d.ts +13 -11
- package/dist/buildercodes/responses.d.ts +1 -0
- package/dist/buildercodes/responses.js +10 -0
- package/dist/fees/responses.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/margin-accounts/index.d.ts +7 -2
- package/dist/market/index.d.ts +33 -0
- package/dist/profile/index.d.ts +10 -0
- package/dist/rfq/index.d.ts +44 -0
- package/dist/rfq/index.js +10 -0
- package/dist/rfq/responses.d.ts +282 -0
- package/dist/rfq/responses.js +196 -0
- package/dist/sdk/index.d.ts +25 -2
- package/dist/trading/index.d.ts +19 -4
- package/dist/trading/orders.d.ts +12 -1
- package/dist/trading/responses.d.ts +27 -2
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/margin-accounts.d.ts +2 -2
- package/dist/validation/margin-accounts.js +5 -5
- package/dist/validation/market.d.ts +7 -0
- package/dist/validation/market.js +4 -0
- package/dist/validation/rfq.d.ts +109 -0
- package/dist/validation/rfq.js +120 -0
- package/dist/validation/trading.d.ts +24 -0
- package/dist/validation/trading.js +55 -42
- package/dist/websocket/base.d.ts +47 -11
- package/dist/websocket/client.d.ts +51 -4
- package/dist/websocket/depth.d.ts +142 -0
- package/dist/websocket/depth.js +13 -0
- package/dist/websocket/events/index.d.ts +2 -0
- package/dist/websocket/events/index.js +2 -0
- package/dist/websocket/events/orderbook-events.d.ts +41 -1
- package/dist/websocket/events/rfq-events.d.ts +145 -0
- package/dist/websocket/events/rfq-events.js +15 -0
- package/dist/websocket/events/rfq-trade-events.d.ts +28 -0
- package/dist/websocket/events/rfq-trade-events.js +6 -0
- package/dist/websocket/events/trade-events.d.ts +53 -0
- package/dist/websocket/index.d.ts +1 -0
- package/dist/websocket/index.js +1 -0
- package/dist/websocket/snapshots.d.ts +23 -1
- package/dist/wire/operations.d.ts +1 -1
- package/dist/wire/operations.js +28 -0
- package/dist/wire/schema.d.ts +5465 -2050
- package/package.json +2 -2
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFQ (block trading) response types.
|
|
3
|
+
*
|
|
4
|
+
* Zod schemas for every RFQ REST/gRPC response, with the inferred TypeScript
|
|
5
|
+
* types. The REST API returns camelCase JSON; an optional field the server has
|
|
6
|
+
* no value for may arrive as `null` or be absent, so optional fields are typed
|
|
7
|
+
* `T | null | undefined` (`.nullish()`). Prices, quantities and fees are exact
|
|
8
|
+
* decimal strings; versions and `*Ms` times are JSON numbers (times are Unix
|
|
9
|
+
* milliseconds).
|
|
10
|
+
*
|
|
11
|
+
* Label fields (states, sides, products) are typed `Union | (string & {})`:
|
|
12
|
+
* the unions name the values the server sends today, and the schemas accept
|
|
13
|
+
* any string so a value added server-side later does not fail parsing.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
/** A string schema typed as a known-value union that still admits unknown values. */
|
|
17
|
+
function openUnion() {
|
|
18
|
+
return z.string();
|
|
19
|
+
}
|
|
20
|
+
/** A quote's price (quote units per base unit) and capacity (base units). */
|
|
21
|
+
export const RfqQuoteTermsResponseSchema = z.object({
|
|
22
|
+
price: z.string(),
|
|
23
|
+
capacity: z.string(),
|
|
24
|
+
});
|
|
25
|
+
/** The request as created. */
|
|
26
|
+
export const RfqRequestTermsSchema = z.object({
|
|
27
|
+
rfqId: z.string(),
|
|
28
|
+
tradingPairId: z.string(),
|
|
29
|
+
/** `SPOT` or `PERPETUAL`. */
|
|
30
|
+
product: openUnion().nullish(),
|
|
31
|
+
/** Maximum base quantity; not a guaranteed fill. */
|
|
32
|
+
quantity: z.string(),
|
|
33
|
+
createdAtMs: z.number(),
|
|
34
|
+
/** No new quotes after it. */
|
|
35
|
+
deadlineAtMs: z.number(),
|
|
36
|
+
/** The taker's side, `BUY` or `SELL`, for a one-way RFQ (makers see it too); absent for a two-way RFQ. */
|
|
37
|
+
side: openUnion().nullish(),
|
|
38
|
+
/**
|
|
39
|
+
* The side makers quote on a one-way RFQ, the one that fills the taker:
|
|
40
|
+
* `ASK` (an offer) when it buys, `BID` when it sells; a quote on the other
|
|
41
|
+
* side is refused. Absent for a two-way RFQ.
|
|
42
|
+
*/
|
|
43
|
+
quoteSide: openUnion().nullish(),
|
|
44
|
+
/** Taker only: the leverage given on create (perpetuals). */
|
|
45
|
+
leverage: z.string().nullish(),
|
|
46
|
+
/** Taker only: the margin mode given on create (perpetuals). */
|
|
47
|
+
marginMode: z.string().nullish(),
|
|
48
|
+
});
|
|
49
|
+
/** One side of the taker's view: the allocation that would fill the quantity. */
|
|
50
|
+
export const RfqSideViewSchema = z.object({
|
|
51
|
+
/** All-in volume-weighted price, fees included. */
|
|
52
|
+
vwap: z.string(),
|
|
53
|
+
availableQuantity: z.string(),
|
|
54
|
+
/** The volume-weighted price before fees. */
|
|
55
|
+
grossVwap: z.string().nullish(),
|
|
56
|
+
/** Estimated Monaco taker fee on availableQuantity, in the quote asset. */
|
|
57
|
+
estimatedMonacoFee: z.string().nullish(),
|
|
58
|
+
/** Estimated builder fee on availableQuantity, in the quote asset. */
|
|
59
|
+
estimatedBuilderFee: z.string().nullish(),
|
|
60
|
+
/** Estimated total taker fee on availableQuantity, in the quote asset. */
|
|
61
|
+
estimatedTotalFee: z.string().nullish(),
|
|
62
|
+
});
|
|
63
|
+
/** The taker's current view of the quotes. */
|
|
64
|
+
export const RfqViewSchema = z.object({
|
|
65
|
+
/** The version to accept; a newer view refuses an older one. */
|
|
66
|
+
viewVersion: z.number(),
|
|
67
|
+
bid: RfqSideViewSchema.nullish(),
|
|
68
|
+
ask: RfqSideViewSchema.nullish(),
|
|
69
|
+
asOfMs: z.number(),
|
|
70
|
+
/** The taker's Monaco fee rate in this view, in centi-bps. */
|
|
71
|
+
monacoFeeCbps: z.number().nullish(),
|
|
72
|
+
/** The taker's builder fee rate in this view, in centi-bps. */
|
|
73
|
+
builderFeeCbps: z.number().nullish(),
|
|
74
|
+
});
|
|
75
|
+
/** One fill of an executed RFQ. */
|
|
76
|
+
export const RfqFillSchema = z.object({
|
|
77
|
+
executionId: z.string(),
|
|
78
|
+
price: z.string(),
|
|
79
|
+
quantity: z.string(),
|
|
80
|
+
/** The taker's whole fee on this fill: monacoFee plus builderFee. */
|
|
81
|
+
fee: z.string(),
|
|
82
|
+
monacoFee: z.string().nullish(),
|
|
83
|
+
builderFee: z.string().nullish(),
|
|
84
|
+
});
|
|
85
|
+
/** What an accepted RFQ executed. */
|
|
86
|
+
export const RfqOutcomeSchema = z.object({
|
|
87
|
+
executedQuantity: z.string(),
|
|
88
|
+
unfilledQuantity: z.string(),
|
|
89
|
+
vwap: z.string(),
|
|
90
|
+
fills: z.array(RfqFillSchema),
|
|
91
|
+
});
|
|
92
|
+
/** A quoted side the venue refused; nothing is reserved for it. */
|
|
93
|
+
export const RfqRefusedSideSchema = z.object({
|
|
94
|
+
side: openUnion(),
|
|
95
|
+
/** INSUFFICIENT_BALANCE or QUOTE_REJECTED. */
|
|
96
|
+
code: z.string(),
|
|
97
|
+
reason: z.string(),
|
|
98
|
+
});
|
|
99
|
+
/** A quote version as its maker sees it. */
|
|
100
|
+
export const RfqQuoteVersionSchema = z.object({
|
|
101
|
+
rfqId: z.string(),
|
|
102
|
+
quoteId: z.string(),
|
|
103
|
+
/** This version; name it to replace or withdraw. */
|
|
104
|
+
version: z.number(),
|
|
105
|
+
bid: RfqQuoteTermsResponseSchema.nullish(),
|
|
106
|
+
ask: RfqQuoteTermsResponseSchema.nullish(),
|
|
107
|
+
issuedAtMs: z.number(),
|
|
108
|
+
validUntilMs: z.number(),
|
|
109
|
+
/** Perpetuals: the leverage the quote's orders reserve with. */
|
|
110
|
+
leverage: z.string().nullish(),
|
|
111
|
+
/** Perpetuals: ISOLATED or CROSS. */
|
|
112
|
+
marginMode: z.string().nullish(),
|
|
113
|
+
/**
|
|
114
|
+
* Quoted sides the venue refused. The version holds only the funded sides;
|
|
115
|
+
* when none is funded the quote is refused instead.
|
|
116
|
+
*/
|
|
117
|
+
refusedSides: z.array(RfqRefusedSideSchema).nullish(),
|
|
118
|
+
});
|
|
119
|
+
/** A selected maker's own part of an acceptance, for answering last look. */
|
|
120
|
+
export const RfqMakerSelectionSchema = z.object({
|
|
121
|
+
acceptanceId: z.string(),
|
|
122
|
+
/** The taker's side. */
|
|
123
|
+
takerSide: openUnion().nullish(),
|
|
124
|
+
quoteId: z.string(),
|
|
125
|
+
quoteVersion: z.number(),
|
|
126
|
+
quantity: z.string(),
|
|
127
|
+
frozenTerms: RfqQuoteTermsResponseSchema.nullish(),
|
|
128
|
+
lastLookDeadlineAtMs: z.number(),
|
|
129
|
+
/** Your Monaco maker fee rate in centi-bps, frozen at acceptance; negative for a rebate. */
|
|
130
|
+
monacoFeeCbps: z.number().nullish(),
|
|
131
|
+
/**
|
|
132
|
+
* The MOST your frontend's builder add-on charges on this fill, in centi-bps:
|
|
133
|
+
* the rate stored on your quote order. A fill charges it or nothing, never
|
|
134
|
+
* more; an IMPROVE re-places the quote at the rate configured then.
|
|
135
|
+
*/
|
|
136
|
+
maxBuilderFeeCbps: z.number().nullish(),
|
|
137
|
+
/**
|
|
138
|
+
* Estimated net at the selected quantity and frozen price, in the quote
|
|
139
|
+
* asset, at monacoFeeCbps plus the maximum add-on: the least you receive
|
|
140
|
+
* when selling, the most you pay when buying.
|
|
141
|
+
*/
|
|
142
|
+
estimatedNet: z.string().nullish(),
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* Authoritative RFQ status. A taker sees `view` and `outcome`; a maker sees
|
|
146
|
+
* its own latest quote and, once selected, its own selection.
|
|
147
|
+
*/
|
|
148
|
+
export const RfqStatusSchema = z.object({
|
|
149
|
+
terms: RfqRequestTermsSchema.nullish(),
|
|
150
|
+
state: openUnion(),
|
|
151
|
+
stateVersion: z.number(),
|
|
152
|
+
acceptedSide: openUnion().nullish(),
|
|
153
|
+
lastLookDeadlineAtMs: z.number().nullish(),
|
|
154
|
+
view: RfqViewSchema.nullish(),
|
|
155
|
+
ownQuote: RfqQuoteVersionSchema.nullish(),
|
|
156
|
+
ownSelection: RfqMakerSelectionSchema.nullish(),
|
|
157
|
+
/** The `expectedVersion` for your next quote or withdrawal. */
|
|
158
|
+
ownLatestVersion: z.number(),
|
|
159
|
+
ownQuoteWithdrawn: z.boolean(),
|
|
160
|
+
outcome: RfqOutcomeSchema.nullish(),
|
|
161
|
+
durableSequence: z.number(),
|
|
162
|
+
});
|
|
163
|
+
/** A market RFQ is offered on. */
|
|
164
|
+
export const RfqMarketCapabilitySchema = z.object({
|
|
165
|
+
tradingPairId: z.string(),
|
|
166
|
+
product: openUnion().nullish(),
|
|
167
|
+
minQuantity: z.string(),
|
|
168
|
+
maxQuantity: z.string(),
|
|
169
|
+
});
|
|
170
|
+
/** Your RFQ limits and the markets RFQ is offered on. */
|
|
171
|
+
export const GetRfqCapabilitiesResponseSchema = z.object({
|
|
172
|
+
protocolVersion: z.number(),
|
|
173
|
+
/** Whether RFQ is enabled for you. */
|
|
174
|
+
enabled: z.boolean(),
|
|
175
|
+
markets: z.array(RfqMarketCapabilitySchema),
|
|
176
|
+
requestWindowMs: z.number(),
|
|
177
|
+
minQuoteValidityMs: z.number(),
|
|
178
|
+
maxQuoteValidityMs: z.number(),
|
|
179
|
+
lastLookMs: z.number(),
|
|
180
|
+
/** RFQs you may create per quota window. */
|
|
181
|
+
maxNewRfqs: z.number(),
|
|
182
|
+
quotaWindowMs: z.number(),
|
|
183
|
+
quotaRemaining: z.number(),
|
|
184
|
+
quotaRetryAfterMs: z.number(),
|
|
185
|
+
});
|
|
186
|
+
/** A withdrawn quote: the withdrawal's version. */
|
|
187
|
+
export const WithdrawRfqQuoteResponseSchema = z.object({
|
|
188
|
+
rfqId: z.string(),
|
|
189
|
+
version: z.number(),
|
|
190
|
+
});
|
|
191
|
+
/** A recorded last-look answer. */
|
|
192
|
+
export const RespondRfqLastLookResponseSchema = z.object({
|
|
193
|
+
acceptanceId: z.string(),
|
|
194
|
+
response: openUnion().nullish(),
|
|
195
|
+
recordedAtMs: z.number(),
|
|
196
|
+
});
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Address, PublicClient, TransactionReceipt, WalletClient } from "viem";
|
|
2
|
+
import type { AnalyticsAPI } from "../analytics";
|
|
2
3
|
import type { ApplicationsAPI } from "../applications";
|
|
3
4
|
import type { AuthAPI, AuthState } from "../auth/index";
|
|
4
5
|
import type { BuildercodesAPI } from "../buildercodes";
|
|
@@ -14,6 +15,7 @@ import type { PortfolioAPI } from "../portfolio";
|
|
|
14
15
|
import type { PositionsAPI } from "../positions";
|
|
15
16
|
import type { ProfileAPI } from "../profile";
|
|
16
17
|
import type { PulseAPI } from "../pulse";
|
|
18
|
+
import type { RfqAPI } from "../rfq";
|
|
17
19
|
import type { SubAccountsAPI } from "../sub-accounts";
|
|
18
20
|
import type { SweeperAPI } from "../sweeper";
|
|
19
21
|
import type { TraderCodesAPI } from "../tradercodes";
|
|
@@ -120,6 +122,8 @@ export interface MonacoSDK {
|
|
|
120
122
|
buildercodes: BuildercodesAPI;
|
|
121
123
|
/** Copy trading API: lead trader profiles and the leaderboard, and your follows */
|
|
122
124
|
copyTrading: CopyTradingAPI;
|
|
125
|
+
/** RFQ (block trading) API: request and accept quotes as taker, quote and answer last look as maker */
|
|
126
|
+
rfq: RfqAPI;
|
|
123
127
|
/** Testnet faucet API */
|
|
124
128
|
faucet: FaucetAPI;
|
|
125
129
|
/** Deposit-address registration (sweeper) API; requires a session */
|
|
@@ -131,14 +135,16 @@ export interface MonacoSDK {
|
|
|
131
135
|
pulse: PulseAPI;
|
|
132
136
|
/** Public region status API: whether Monaco is available in the caller's region */
|
|
133
137
|
compliance: ComplianceAPI;
|
|
138
|
+
/** Public explorer analytics API: protocol totals and series, market volume, treasury net fees */
|
|
139
|
+
analytics: AnalyticsAPI;
|
|
134
140
|
/** Orderbook REST API for fetching orderbook snapshots */
|
|
135
141
|
orderbook: {
|
|
136
142
|
getOrderbook: (tradingPairId: string, options?: {
|
|
137
|
-
/** Number of price levels
|
|
143
|
+
/** Number of price levels per side (max 1000). Defaults to 10. Above 100 the snapshot comes from the market-data book and carries `bookSeq`. */
|
|
138
144
|
depth?: number;
|
|
139
145
|
/** Trading mode: 'Spot' or 'Margin'. Defaults to 'Spot'. */
|
|
140
146
|
tradingMode?: TradingMode;
|
|
141
|
-
/** Price grouping magnitude. Valid values: 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000. */
|
|
147
|
+
/** Price grouping magnitude. Valid values: 0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000. */
|
|
142
148
|
magnitude?: number;
|
|
143
149
|
/** Quantity denomination: 'BASE' or 'QUOTE'. When 'QUOTE' type, quantities are multiplied by the quote price. */
|
|
144
150
|
denomination?: OrderbookQuotationMode;
|
|
@@ -160,6 +166,23 @@ export interface MonacoSDK {
|
|
|
160
166
|
/** Empty exactly when the walk is finished. */
|
|
161
167
|
nextPageToken: string;
|
|
162
168
|
}>;
|
|
169
|
+
/**
|
|
170
|
+
* One page of the trade feed: every market, newest first, or only the
|
|
171
|
+
* trades one application took (`takerApplicationId`). Public and rate
|
|
172
|
+
* limited per client IP; follow `nextPageToken` until it is empty.
|
|
173
|
+
*/
|
|
174
|
+
listTrades: (options?: {
|
|
175
|
+
/** Only the trades this application (frontend) took, as the taker's application. */
|
|
176
|
+
takerApplicationId?: string;
|
|
177
|
+
/** Maximum number of records to return (default: 25, max: 1000) */
|
|
178
|
+
pageSize?: number;
|
|
179
|
+
/** Cursor from a previous response's `nextPageToken`; omit to start */
|
|
180
|
+
pageToken?: string;
|
|
181
|
+
}) => Promise<{
|
|
182
|
+
trades: TradeEvent[];
|
|
183
|
+
/** Empty exactly when the walk is finished. */
|
|
184
|
+
nextPageToken: string;
|
|
185
|
+
}>;
|
|
163
186
|
};
|
|
164
187
|
/** WebSocket client for real-time data — the full typed channel surface of {@link MonacoWebSocket} */
|
|
165
188
|
ws: MonacoWebSocket;
|
package/dist/trading/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { BaseAPI } from "../api/index";
|
|
7
7
|
import type { MarginMode } from "../margin-accounts";
|
|
8
8
|
import type { Order, OrderSide, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode } from "./orders";
|
|
9
|
-
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrderSlicesParams, ListTwapOrderSlicesResponse, ListTwapOrdersParams, ListTwapOrdersResponse, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TwapOrder } from "./responses";
|
|
9
|
+
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelAllAfterOptions, CancelAllAfterResponse, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrderSlicesParams, ListTwapOrderSlicesResponse, ListTwapOrdersParams, ListTwapOrdersResponse, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TwapOrder } from "./responses";
|
|
10
10
|
/**
|
|
11
11
|
* Trading API interface.
|
|
12
12
|
* Provides methods for placing and managing orders.
|
|
@@ -20,7 +20,7 @@ export interface TradingAPI extends BaseAPI {
|
|
|
20
20
|
* @param quantity - Order quantity as string
|
|
21
21
|
* @param price - Order price as string
|
|
22
22
|
* @param options - Optional parameters for the limit order
|
|
23
|
-
* @param options.tradingMode - Trading mode (
|
|
23
|
+
* @param options.tradingMode - Trading mode ("SPOT" or "MARGIN"). Omit it to use the trading pair market type.
|
|
24
24
|
* @param options.timeInForce - Time in force ("GTC", "IOC", or "FOK")
|
|
25
25
|
* @returns Promise resolving to the order result
|
|
26
26
|
*/
|
|
@@ -42,6 +42,7 @@ export interface TradingAPI extends BaseAPI {
|
|
|
42
42
|
riskBucketId?: string;
|
|
43
43
|
/** Initial order budget; unfilled funds do not back the isolated position. */
|
|
44
44
|
riskBucketCollateral?: string;
|
|
45
|
+
/** Names the margin account by its sub-account key, like `marginAccountId` (`default` is the default account). */
|
|
45
46
|
strategyKey?: string;
|
|
46
47
|
/** @deprecated Order side is authoritative. */
|
|
47
48
|
positionSide?: PositionSide;
|
|
@@ -84,7 +85,7 @@ export interface TradingAPI extends BaseAPI {
|
|
|
84
85
|
* @param side - Order side ("BUY" or "SELL")
|
|
85
86
|
* @param quantity - Order quantity as string
|
|
86
87
|
* @param options - Optional parameters for the market order
|
|
87
|
-
* @param options.tradingMode - Trading mode (
|
|
88
|
+
* @param options.tradingMode - Trading mode ("SPOT" or "MARGIN"). Omit it to use the trading pair market type.
|
|
88
89
|
* @param options.slippageTolerance - Slippage tolerance as decimal (e.g., 0.01 for 1%, 0 for best price only, undefined for unlimited slippage)
|
|
89
90
|
* @returns Promise resolving to the order result
|
|
90
91
|
*/
|
|
@@ -104,6 +105,7 @@ export interface TradingAPI extends BaseAPI {
|
|
|
104
105
|
riskBucketId?: string;
|
|
105
106
|
/** Initial order budget; unfilled funds do not back the isolated position. */
|
|
106
107
|
riskBucketCollateral?: string;
|
|
108
|
+
/** Names the margin account by its sub-account key, like `marginAccountId` (`default` is the default account). */
|
|
107
109
|
strategyKey?: string;
|
|
108
110
|
/** @deprecated Order side is authoritative. */
|
|
109
111
|
positionSide?: PositionSide;
|
|
@@ -165,6 +167,19 @@ export interface TradingAPI extends BaseAPI {
|
|
|
165
167
|
* @returns Promise resolving to the batch cancellation result
|
|
166
168
|
*/
|
|
167
169
|
batchCancelAll(tradingPairId?: string): Promise<BatchCancelOrdersResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Arms, refreshes or disarms a dead man's switch. Unless you call again
|
|
172
|
+
* before `timeoutMs` runs out, the exchange cancels your resting orders
|
|
173
|
+
* with terminalReason `CANCEL_ALL_AFTER`: resting limit orders, triggered
|
|
174
|
+
* TP/SL legs resting on the book, and TWAP parents that are not
|
|
175
|
+
* reduce-only. Untriggered TP/SL on a position, reduce-only TWAPs and RFQ
|
|
176
|
+
* quotes stay; legs still pending on a cancelled entry order end with it.
|
|
177
|
+
* A timer that fires is spent; arm it again to keep the switch on.
|
|
178
|
+
* @param timeoutMs - 0 disarms; otherwise 5000 to 900000 (5 s to 15 min)
|
|
179
|
+
* @param options - Optional scope; see {@link CancelAllAfterOptions}
|
|
180
|
+
* @returns Promise resolving to the deadline that was set
|
|
181
|
+
*/
|
|
182
|
+
cancelAllAfter(timeoutMs: number, options?: CancelAllAfterOptions): Promise<CancelAllAfterResponse>;
|
|
168
183
|
/**
|
|
169
184
|
* Replaces an existing order with new parameters.
|
|
170
185
|
* Updates the order with new price, quantity, and balance settings.
|
|
@@ -290,4 +305,4 @@ export interface TradingAPI extends BaseAPI {
|
|
|
290
305
|
}
|
|
291
306
|
export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
|
|
292
307
|
export { ORDER_STATUS_VALUES } from "./orders";
|
|
293
|
-
export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrderSlicesParams, ListTwapOrderSlicesResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TriggeredOrderSummary, TwapOrder, UpdatedFields, } from "./responses";
|
|
308
|
+
export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelAllAfterOptions, CancelAllAfterResponse, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrderSlicesParams, ListTwapOrderSlicesResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TriggeredOrderSummary, TwapOrder, UpdatedFields, } from "./responses";
|
package/dist/trading/orders.d.ts
CHANGED
|
@@ -164,6 +164,17 @@ export interface Order {
|
|
|
164
164
|
* Wire: `placementMakerFeeBps`.
|
|
165
165
|
*/
|
|
166
166
|
placementMakerFeeBps?: string;
|
|
167
|
+
/**
|
|
168
|
+
* The RFQ (block trade) this order belongs to; set on RFQ orders only
|
|
169
|
+
* (`origin` `RFQ`). Read the RFQ with `rfq.getRfq`. Wire: `rfqId`.
|
|
170
|
+
*/
|
|
171
|
+
rfqId?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Set on a maker's RFQ quote order only: the internal engine id of the quote
|
|
174
|
+
* version the order rested for. Not the public `quoteId`; the taker's order,
|
|
175
|
+
* which fills from several quotes, carries none. Wire: `rfqQuoteId`.
|
|
176
|
+
*/
|
|
177
|
+
rfqQuoteId?: string;
|
|
167
178
|
/**
|
|
168
179
|
* Opaque, compare-only revision counter for this order's state: a strictly
|
|
169
180
|
* higher value is strictly newer state for that order, and equal values
|
|
@@ -211,7 +222,7 @@ export interface Order {
|
|
|
211
222
|
version?: number;
|
|
212
223
|
}
|
|
213
224
|
/** Stable terminal causes for accepted orders that end as CANCELLED. */
|
|
214
|
-
export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SELF_TRADE_PREVENTION" | "AUTO_DELEVERAGING" | "PRICE_BAND" | "SLIPPAGE_TOLERANCE" | "BANKRUPTCY_PRICE" | "SYSTEM";
|
|
225
|
+
export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SELF_TRADE_PREVENTION" | "AUTO_DELEVERAGING" | "PRICE_BAND" | "SLIPPAGE_TOLERANCE" | "BANKRUPTCY_PRICE" | "CANCEL_ALL_AFTER" | "SYSTEM";
|
|
215
226
|
/**
|
|
216
227
|
* Role of the creator or order
|
|
217
228
|
*/
|
|
@@ -371,7 +371,7 @@ export interface BatchCreateOrderParams {
|
|
|
371
371
|
price?: string;
|
|
372
372
|
/** Order quantity */
|
|
373
373
|
quantity: string;
|
|
374
|
-
/** Trading mode
|
|
374
|
+
/** Trading mode: "SPOT" or "MARGIN". Omit it to use the trading pair market type. */
|
|
375
375
|
tradingMode?: TradingMode;
|
|
376
376
|
/** Maximum slippage for market orders as decimal (e.g., 0.01 for 1%) */
|
|
377
377
|
slippageTolerance?: number;
|
|
@@ -684,7 +684,7 @@ export interface CreateTwapOrderOptions {
|
|
|
684
684
|
executionStyle?: "TAKER" | "PASSIVE";
|
|
685
685
|
/** Whether the TWAP parent is reduce-only (margin only). Child orders inherit it and clamp to the live position. */
|
|
686
686
|
reduceOnly?: boolean;
|
|
687
|
-
/** Trading mode: "SPOT" or "MARGIN"
|
|
687
|
+
/** Trading mode: "SPOT" or "MARGIN". Omit it to use the trading pair market type; a mode that does not match the pair is rejected. */
|
|
688
688
|
tradingMode?: TradingMode;
|
|
689
689
|
/** Margin account UUID for margin TWAP orders. Resolved once at creation and reused by every child order. */
|
|
690
690
|
marginAccountId?: string;
|
|
@@ -744,6 +744,31 @@ export interface CreateTwapOrderResponse {
|
|
|
744
744
|
/** Resolved window end (ISO 8601). Execution never continues past it. */
|
|
745
745
|
endTime: string;
|
|
746
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* Options for {@link TradingAPI.cancelAllAfter}.
|
|
749
|
+
*/
|
|
750
|
+
export interface CancelAllAfterOptions {
|
|
751
|
+
/**
|
|
752
|
+
* Scope the timer to one trading pair. Omitted, the timer covers every
|
|
753
|
+
* market. The account-wide timer and each pair's timer are separate.
|
|
754
|
+
* Required for a delegated session.
|
|
755
|
+
*/
|
|
756
|
+
tradingPairId?: string;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Response from arming, refreshing or disarming a cancel-all-after timer.
|
|
760
|
+
*/
|
|
761
|
+
export interface CancelAllAfterResponse {
|
|
762
|
+
/**
|
|
763
|
+
* When the exchange cancels your resting orders unless you call again first
|
|
764
|
+
* (ISO 8601). Absent when the timer was disarmed.
|
|
765
|
+
*/
|
|
766
|
+
cancelAt?: string;
|
|
767
|
+
/** The timeout that was set, echoed back; 0 when disarmed. */
|
|
768
|
+
timeoutMs: number;
|
|
769
|
+
/** The trading pair the timer covers; absent for the account-wide timer. */
|
|
770
|
+
tradingPairId?: string;
|
|
771
|
+
}
|
|
747
772
|
/**
|
|
748
773
|
* Response from cancelling a TWAP parent order.
|
|
749
774
|
*/
|
package/dist/validation/index.js
CHANGED
|
@@ -64,7 +64,7 @@ export declare const TransferCollateralToRiskBucketSchema: z.ZodObject<{
|
|
|
64
64
|
marginMode: z.ZodLiteral<"CROSS">;
|
|
65
65
|
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
66
66
|
selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
|
|
67
|
-
strategyKey: z.ZodOptional<z.
|
|
67
|
+
strategyKey: z.ZodOptional<z.ZodString>;
|
|
68
68
|
tradingPairId: z.ZodOptional<z.ZodNever>;
|
|
69
69
|
}, z.core.$strict>]>>;
|
|
70
70
|
}, z.core.$strip>;
|
|
@@ -171,7 +171,7 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
|
|
|
171
171
|
marginMode: z.ZodLiteral<"CROSS">;
|
|
172
172
|
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
173
173
|
selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
|
|
174
|
-
strategyKey: z.ZodOptional<z.
|
|
174
|
+
strategyKey: z.ZodOptional<z.ZodString>;
|
|
175
175
|
tradingPairId: z.ZodUUID;
|
|
176
176
|
side: z.ZodEnum<{
|
|
177
177
|
BUY: "BUY";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Margin Account API Validation Schemas
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { MarketSlippageToleranceBpsSchema, OrderIdempotencyKeySchema, OrderSideSchema, OrderTypeSchema, PositionSideSchema, PositiveDecimalStringSchema, UUIDSchema, } from "./trading";
|
|
5
|
+
import { MarketSlippageToleranceBpsSchema, OrderIdempotencyKeySchema, OrderSideSchema, OrderTypeSchema, PositionSideSchema, PositiveDecimalStringSchema, StrategyKeySchema, UUIDSchema, } from "./trading";
|
|
6
6
|
const CursorPaginationSchema = z.object({
|
|
7
7
|
/**
|
|
8
8
|
* Rejected, not ignored. A non-strict object would let a JS or `any` caller
|
|
@@ -37,7 +37,7 @@ const TransferCollateralRequestSchema = z
|
|
|
37
37
|
asset: z.string().trim().min(1, "Asset cannot be empty"),
|
|
38
38
|
amount: PositiveDecimalStringSchema,
|
|
39
39
|
tradingPairId: UUIDSchema.optional(),
|
|
40
|
-
strategyKey:
|
|
40
|
+
strategyKey: StrategyKeySchema.optional(),
|
|
41
41
|
// A cross risk bucket has no trading pair, so CROSS is the only way to name
|
|
42
42
|
// one on the way out (0XM-2420). The two never combine.
|
|
43
43
|
marginMode: z.enum(["ISOLATED", "CROSS"]).optional(),
|
|
@@ -54,7 +54,7 @@ const ParentMarginAccountCollateralRequestSchema = z.object({
|
|
|
54
54
|
});
|
|
55
55
|
const RiskBucketRequestSchema = z.object({
|
|
56
56
|
tradingPairId: UUIDSchema,
|
|
57
|
-
strategyKey:
|
|
57
|
+
strategyKey: StrategyKeySchema.optional(),
|
|
58
58
|
});
|
|
59
59
|
const IsolatedRiskBucketRequestSchema = RiskBucketRequestSchema.extend({
|
|
60
60
|
marginMode: z.literal("ISOLATED").optional(),
|
|
@@ -78,7 +78,7 @@ const CrossRiskBucketSimulateRequestSchema = z.object({
|
|
|
78
78
|
marginMode: z.literal("CROSS"),
|
|
79
79
|
marginAccountId: UUIDSchema.optional(),
|
|
80
80
|
selectedTradingPairIds: z.never().optional(),
|
|
81
|
-
strategyKey:
|
|
81
|
+
strategyKey: StrategyKeySchema.optional(),
|
|
82
82
|
});
|
|
83
83
|
// A cross transfer-in names no pairs. Cross scope is derived from trading, so
|
|
84
84
|
// funding has nothing to declare; `selectedTradingPairIds` used to REPLACE the
|
|
@@ -89,7 +89,7 @@ const CrossRiskBucketRequestSchema = z.object({
|
|
|
89
89
|
marginMode: z.literal("CROSS"),
|
|
90
90
|
marginAccountId: UUIDSchema.optional(),
|
|
91
91
|
selectedTradingPairIds: z.never().optional(),
|
|
92
|
-
strategyKey:
|
|
92
|
+
strategyKey: StrategyKeySchema.optional(),
|
|
93
93
|
tradingPairId: z.never().optional(),
|
|
94
94
|
});
|
|
95
95
|
export const TransferCollateralSchema = z.object({
|
|
@@ -267,3 +267,10 @@ export declare const GetTradesSchema: z.ZodObject<{
|
|
|
267
267
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
268
268
|
pageToken: z.ZodOptional<z.ZodString>;
|
|
269
269
|
}, z.core.$strip>;
|
|
270
|
+
/** Options for the every-market trade feed (`listTrades`). */
|
|
271
|
+
export declare const ListTradesSchema: z.ZodObject<{
|
|
272
|
+
page: z.ZodOptional<z.ZodNever>;
|
|
273
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
274
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
275
|
+
takerApplicationId: z.ZodOptional<z.ZodUUID>;
|
|
276
|
+
}, z.core.$strip>;
|
|
@@ -267,3 +267,7 @@ export const GetTradesSchema = z.object({
|
|
|
267
267
|
pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
|
|
268
268
|
pageToken: z.string().optional(),
|
|
269
269
|
});
|
|
270
|
+
/** Options for the every-market trade feed (`listTrades`). */
|
|
271
|
+
export const ListTradesSchema = GetTradesSchema.extend({
|
|
272
|
+
takerApplicationId: UUIDSchema.optional(),
|
|
273
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFQ (block trading) validation schemas.
|
|
3
|
+
*
|
|
4
|
+
* Client-side checks for the RFQ request params, run before a request is
|
|
5
|
+
* sent. The server stays the authority on every business rule (market size
|
|
6
|
+
* rules, deadlines, versions, last-look improvement); these catch malformed
|
|
7
|
+
* input early and mirror the request shape the REST gateway accepts, which
|
|
8
|
+
* rejects unknown fields.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
/** The taker's side, or a quote's side as the taker sees it. */
|
|
12
|
+
export declare const RfqSideSchema: z.ZodEnum<{
|
|
13
|
+
BUY: "BUY";
|
|
14
|
+
SELL: "SELL";
|
|
15
|
+
}>;
|
|
16
|
+
/** The market product an RFQ trades. */
|
|
17
|
+
export declare const RfqProductSchema: z.ZodEnum<{
|
|
18
|
+
PERPETUAL: "PERPETUAL";
|
|
19
|
+
SPOT: "SPOT";
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* A client idempotency key: 1-64 letters, digits, or `. _ : -`. A retry with
|
|
23
|
+
* the same key and body returns the first result. Omitted, the SDK generates
|
|
24
|
+
* one per call.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RfqIdempotencyKeySchema: z.ZodString;
|
|
27
|
+
/** A quote's price (quote units per base unit) and capacity (base units). */
|
|
28
|
+
export declare const RfqQuoteTermsSchema: z.ZodObject<{
|
|
29
|
+
price: z.ZodString;
|
|
30
|
+
capacity: z.ZodString;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
/** Params for requesting quotes. */
|
|
33
|
+
export declare const CreateRfqSchema: z.ZodObject<{
|
|
34
|
+
tradingPairId: z.ZodUUID;
|
|
35
|
+
product: z.ZodEnum<{
|
|
36
|
+
PERPETUAL: "PERPETUAL";
|
|
37
|
+
SPOT: "SPOT";
|
|
38
|
+
}>;
|
|
39
|
+
quantity: z.ZodString;
|
|
40
|
+
side: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
BUY: "BUY";
|
|
42
|
+
SELL: "SELL";
|
|
43
|
+
}>>;
|
|
44
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
45
|
+
marginMode: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
CROSS: "CROSS";
|
|
47
|
+
ISOLATED: "ISOLATED";
|
|
48
|
+
}>>;
|
|
49
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
/** Params for accepting one side of the view the taker last saw. */
|
|
52
|
+
export declare const AcceptRfqSchema: z.ZodObject<{
|
|
53
|
+
side: z.ZodEnum<{
|
|
54
|
+
BUY: "BUY";
|
|
55
|
+
SELL: "SELL";
|
|
56
|
+
}>;
|
|
57
|
+
viewVersion: z.ZodNumber;
|
|
58
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
/** Params for cancelling an RFQ. */
|
|
61
|
+
export declare const CancelRfqSchema: z.ZodObject<{
|
|
62
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
/** Params for placing or replacing a quote: a bid, an ask or both. */
|
|
65
|
+
export declare const UpsertRfqQuoteSchema: z.ZodObject<{
|
|
66
|
+
expectedVersion: z.ZodNumber;
|
|
67
|
+
bid: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
price: z.ZodString;
|
|
69
|
+
capacity: z.ZodString;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
ask: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
price: z.ZodString;
|
|
73
|
+
capacity: z.ZodString;
|
|
74
|
+
}, z.core.$strict>>;
|
|
75
|
+
validityMs: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
77
|
+
marginMode: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
CROSS: "CROSS";
|
|
79
|
+
ISOLATED: "ISOLATED";
|
|
80
|
+
}>>;
|
|
81
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
/** Params for withdrawing your current quote. */
|
|
84
|
+
export declare const WithdrawRfqQuoteSchema: z.ZodObject<{
|
|
85
|
+
expectedVersion: z.ZodNumber;
|
|
86
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.core.$strict>;
|
|
88
|
+
/** Params for answering last look. There is no accept: silence executes. */
|
|
89
|
+
export declare const RespondRfqLastLookSchema: z.ZodObject<{
|
|
90
|
+
acceptanceId: z.ZodUUID;
|
|
91
|
+
response: z.ZodEnum<{
|
|
92
|
+
IMPROVE: "IMPROVE";
|
|
93
|
+
REJECT: "REJECT";
|
|
94
|
+
}>;
|
|
95
|
+
improvedTerms: z.ZodOptional<z.ZodObject<{
|
|
96
|
+
price: z.ZodString;
|
|
97
|
+
capacity: z.ZodString;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
export type RfqSide = z.infer<typeof RfqSideSchema>;
|
|
102
|
+
export type RfqProduct = z.infer<typeof RfqProductSchema>;
|
|
103
|
+
export type RfqQuoteTerms = z.infer<typeof RfqQuoteTermsSchema>;
|
|
104
|
+
export type CreateRfqParams = z.infer<typeof CreateRfqSchema>;
|
|
105
|
+
export type AcceptRfqParams = z.infer<typeof AcceptRfqSchema>;
|
|
106
|
+
export type CancelRfqParams = z.infer<typeof CancelRfqSchema>;
|
|
107
|
+
export type UpsertRfqQuoteParams = z.infer<typeof UpsertRfqQuoteSchema>;
|
|
108
|
+
export type WithdrawRfqQuoteParams = z.infer<typeof WithdrawRfqQuoteSchema>;
|
|
109
|
+
export type RespondRfqLastLookParams = z.infer<typeof RespondRfqLastLookSchema>;
|