@0xmonaco/types 1.1.2 → 1.1.5
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/fees/responses.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/market/index.d.ts +51 -2
- package/dist/profile/index.d.ts +15 -2
- package/dist/rfq/index.d.ts +44 -0
- package/dist/rfq/index.js +10 -0
- package/dist/rfq/responses.d.ts +246 -0
- package/dist/rfq/responses.js +167 -0
- package/dist/sdk/index.d.ts +21 -1
- package/dist/trading/index.d.ts +15 -2
- package/dist/trading/orders.d.ts +1 -1
- package/dist/trading/responses.d.ts +25 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- 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 +9 -0
- package/dist/validation/trading.js +21 -0
- package/dist/websocket/base.d.ts +7 -1
- package/dist/websocket/client.d.ts +20 -1
- package/dist/websocket/events/index.d.ts +2 -0
- package/dist/websocket/events/index.js +2 -0
- package/dist/websocket/events/rfq-events.d.ts +116 -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 +22 -0
- package/dist/wire/operations.d.ts +1 -1
- package/dist/wire/operations.js +12 -0
- package/dist/wire/schema.d.ts +1545 -171
- package/package.json +2 -2
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.
|
|
@@ -165,6 +165,19 @@ export interface TradingAPI extends BaseAPI {
|
|
|
165
165
|
* @returns Promise resolving to the batch cancellation result
|
|
166
166
|
*/
|
|
167
167
|
batchCancelAll(tradingPairId?: string): Promise<BatchCancelOrdersResponse>;
|
|
168
|
+
/**
|
|
169
|
+
* Arms, refreshes or disarms a dead man's switch. Unless you call again
|
|
170
|
+
* before `timeoutMs` runs out, the exchange cancels your resting orders
|
|
171
|
+
* with terminalReason `CANCEL_ALL_AFTER`: resting limit orders, triggered
|
|
172
|
+
* TP/SL legs resting on the book, and TWAP parents that are not
|
|
173
|
+
* reduce-only. Untriggered TP/SL on a position, reduce-only TWAPs and RFQ
|
|
174
|
+
* quotes stay; legs still pending on a cancelled entry order end with it.
|
|
175
|
+
* A timer that fires is spent; arm it again to keep the switch on.
|
|
176
|
+
* @param timeoutMs - 0 disarms; otherwise 5000 to 900000 (5 s to 15 min)
|
|
177
|
+
* @param options - Optional scope; see {@link CancelAllAfterOptions}
|
|
178
|
+
* @returns Promise resolving to the deadline that was set
|
|
179
|
+
*/
|
|
180
|
+
cancelAllAfter(timeoutMs: number, options?: CancelAllAfterOptions): Promise<CancelAllAfterResponse>;
|
|
168
181
|
/**
|
|
169
182
|
* Replaces an existing order with new parameters.
|
|
170
183
|
* Updates the order with new price, quantity, and balance settings.
|
|
@@ -290,4 +303,4 @@ export interface TradingAPI extends BaseAPI {
|
|
|
290
303
|
}
|
|
291
304
|
export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
|
|
292
305
|
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";
|
|
306
|
+
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
|
@@ -211,7 +211,7 @@ export interface Order {
|
|
|
211
211
|
version?: number;
|
|
212
212
|
}
|
|
213
213
|
/** 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";
|
|
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" | "CANCEL_ALL_AFTER" | "SYSTEM";
|
|
215
215
|
/**
|
|
216
216
|
* Role of the creator or order
|
|
217
217
|
*/
|
|
@@ -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
|
@@ -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>;
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
import { MarginModeSchema, PositiveDecimalStringSchema, UUIDSchema } from "./trading.js";
|
|
12
|
+
/** The taker's side, or a quote's side as the taker sees it. */
|
|
13
|
+
export const RfqSideSchema = z.enum(["BUY", "SELL"]);
|
|
14
|
+
/** The market product an RFQ trades. */
|
|
15
|
+
export const RfqProductSchema = z.enum(["SPOT", "PERPETUAL"]);
|
|
16
|
+
/**
|
|
17
|
+
* A client idempotency key: 1-64 letters, digits, or `. _ : -`. A retry with
|
|
18
|
+
* the same key and body returns the first result. Omitted, the SDK generates
|
|
19
|
+
* one per call.
|
|
20
|
+
*/
|
|
21
|
+
export const RfqIdempotencyKeySchema = z
|
|
22
|
+
.string()
|
|
23
|
+
.regex(/^[A-Za-z0-9._:-]{1,64}$/, "idempotencyKey must be 1-64 letters, digits, or . _ : - without whitespace");
|
|
24
|
+
/** A version a request names (`expectedVersion`, `viewVersion`). */
|
|
25
|
+
const VersionSchema = z.number().int("version must be an integer").min(0, "version cannot be negative");
|
|
26
|
+
/** A quote's price (quote units per base unit) and capacity (base units). */
|
|
27
|
+
export const RfqQuoteTermsSchema = z
|
|
28
|
+
.object({
|
|
29
|
+
price: PositiveDecimalStringSchema,
|
|
30
|
+
capacity: PositiveDecimalStringSchema,
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
/** Params for requesting quotes. */
|
|
34
|
+
export const CreateRfqSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
tradingPairId: UUIDSchema,
|
|
37
|
+
product: RfqProductSchema,
|
|
38
|
+
/** Maximum base quantity; not a guaranteed fill. */
|
|
39
|
+
quantity: PositiveDecimalStringSchema,
|
|
40
|
+
/**
|
|
41
|
+
* Omit for a two-way RFQ, whose direction stays hidden from makers. Set,
|
|
42
|
+
* makers see it and may quote only the side that fills it (an ask when
|
|
43
|
+
* you buy, a bid when you sell).
|
|
44
|
+
*/
|
|
45
|
+
side: RfqSideSchema.optional(),
|
|
46
|
+
/**
|
|
47
|
+
* Perpetuals: the leverage your order takes when you accept, as on an
|
|
48
|
+
* order (required there, refused on spot). For a two-way RFQ it applies
|
|
49
|
+
* to whichever side you accept.
|
|
50
|
+
*/
|
|
51
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
52
|
+
/** Perpetuals: ISOLATED (the default) or CROSS, as on an order. */
|
|
53
|
+
marginMode: MarginModeSchema.optional(),
|
|
54
|
+
idempotencyKey: RfqIdempotencyKeySchema.optional(),
|
|
55
|
+
})
|
|
56
|
+
.strict();
|
|
57
|
+
/** Params for accepting one side of the view the taker last saw. */
|
|
58
|
+
export const AcceptRfqSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
side: RfqSideSchema,
|
|
61
|
+
/** The `view.viewVersion` being accepted; a newer view refuses it. */
|
|
62
|
+
viewVersion: VersionSchema,
|
|
63
|
+
idempotencyKey: RfqIdempotencyKeySchema.optional(),
|
|
64
|
+
})
|
|
65
|
+
.strict();
|
|
66
|
+
/** Params for cancelling an RFQ. */
|
|
67
|
+
export const CancelRfqSchema = z
|
|
68
|
+
.object({
|
|
69
|
+
idempotencyKey: RfqIdempotencyKeySchema.optional(),
|
|
70
|
+
})
|
|
71
|
+
.strict();
|
|
72
|
+
/** Params for placing or replacing a quote: a bid, an ask or both. */
|
|
73
|
+
export const UpsertRfqQuoteSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
/** Your current version for this RFQ (`ownLatestVersion`); 0 for your first quote. */
|
|
76
|
+
expectedVersion: VersionSchema,
|
|
77
|
+
/** You buying. */
|
|
78
|
+
bid: RfqQuoteTermsSchema.optional(),
|
|
79
|
+
/** You selling. */
|
|
80
|
+
ask: RfqQuoteTermsSchema.optional(),
|
|
81
|
+
/** 15000-60000 ms; omitted means 60000. Capped at the request deadline. */
|
|
82
|
+
validityMs: z
|
|
83
|
+
.number()
|
|
84
|
+
.int("validityMs must be an integer")
|
|
85
|
+
.min(15000, "validityMs must be at least 15000")
|
|
86
|
+
.max(60000, "validityMs cannot exceed 60000")
|
|
87
|
+
.optional(),
|
|
88
|
+
/**
|
|
89
|
+
* Perpetuals: the leverage each side's order reserves with, as on an
|
|
90
|
+
* order (required there, refused on spot). A quote reserves funds like a
|
|
91
|
+
* resting limit order; leverage, margin mode and bucket are fixed while a
|
|
92
|
+
* side rests, so to change them withdraw and quote again.
|
|
93
|
+
*/
|
|
94
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
95
|
+
/** Perpetuals: ISOLATED (the default) or CROSS, as on an order. */
|
|
96
|
+
marginMode: MarginModeSchema.optional(),
|
|
97
|
+
idempotencyKey: RfqIdempotencyKeySchema.optional(),
|
|
98
|
+
})
|
|
99
|
+
.strict()
|
|
100
|
+
.refine((params) => params.bid !== undefined || params.ask !== undefined, "a quote needs a bid, an ask or both");
|
|
101
|
+
/** Params for withdrawing your current quote. */
|
|
102
|
+
export const WithdrawRfqQuoteSchema = z
|
|
103
|
+
.object({
|
|
104
|
+
/** Your current version for this RFQ. */
|
|
105
|
+
expectedVersion: VersionSchema,
|
|
106
|
+
idempotencyKey: RfqIdempotencyKeySchema.optional(),
|
|
107
|
+
})
|
|
108
|
+
.strict();
|
|
109
|
+
/** Params for answering last look. There is no accept: silence executes. */
|
|
110
|
+
export const RespondRfqLastLookSchema = z
|
|
111
|
+
.object({
|
|
112
|
+
/** `ownSelection.acceptanceId` from the RFQ's status. */
|
|
113
|
+
acceptanceId: UUIDSchema,
|
|
114
|
+
response: z.enum(["REJECT", "IMPROVE"]),
|
|
115
|
+
/** IMPROVE only: a strictly better price or a higher capacity than the frozen terms. */
|
|
116
|
+
improvedTerms: RfqQuoteTermsSchema.optional(),
|
|
117
|
+
idempotencyKey: RfqIdempotencyKeySchema.optional(),
|
|
118
|
+
})
|
|
119
|
+
.strict()
|
|
120
|
+
.refine((params) => (params.response === "IMPROVE") === (params.improvedTerms !== undefined), "improvedTerms is required for IMPROVE and not allowed for REJECT");
|
|
@@ -451,6 +451,15 @@ export declare const CreateTwapOrderSchema: z.ZodObject<{
|
|
|
451
451
|
conditionalExpiry: z.ZodOptional<z.ZodISODateTime>;
|
|
452
452
|
}, z.core.$strip>;
|
|
453
453
|
}, z.core.$strip>;
|
|
454
|
+
/** Bounds of a cancel-all-after timeout; 0 disarms. */
|
|
455
|
+
export declare const CANCEL_ALL_AFTER_MIN_TIMEOUT_MS = 5000;
|
|
456
|
+
export declare const CANCEL_ALL_AFTER_MAX_TIMEOUT_MS = 900000;
|
|
457
|
+
export declare const CancelAllAfterSchema: z.ZodObject<{
|
|
458
|
+
timeoutMs: z.ZodNumber;
|
|
459
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
460
|
+
tradingPairId: z.ZodOptional<z.ZodUUID>;
|
|
461
|
+
}, z.core.$strict>>;
|
|
462
|
+
}, z.core.$strict>;
|
|
454
463
|
export declare const CancelTwapOrderSchema: z.ZodObject<{
|
|
455
464
|
twapOrderId: z.ZodUUID;
|
|
456
465
|
}, z.core.$strip>;
|
|
@@ -544,6 +544,27 @@ export const CreateTwapOrderSchema = z
|
|
|
544
544
|
message: "conditionalExpiry cannot be more than 30 days after creation (the maximum window)",
|
|
545
545
|
path: ["options", "conditionalExpiry"],
|
|
546
546
|
});
|
|
547
|
+
/** Bounds of a cancel-all-after timeout; 0 disarms. */
|
|
548
|
+
export const CANCEL_ALL_AFTER_MIN_TIMEOUT_MS = 5_000;
|
|
549
|
+
export const CANCEL_ALL_AFTER_MAX_TIMEOUT_MS = 900_000;
|
|
550
|
+
export const CancelAllAfterSchema = z
|
|
551
|
+
.object({
|
|
552
|
+
timeoutMs: z
|
|
553
|
+
.number()
|
|
554
|
+
.int()
|
|
555
|
+
.refine((ms) => ms === 0 || (ms >= CANCEL_ALL_AFTER_MIN_TIMEOUT_MS && ms <= CANCEL_ALL_AFTER_MAX_TIMEOUT_MS), {
|
|
556
|
+
message: `timeoutMs must be 0 or between ${CANCEL_ALL_AFTER_MIN_TIMEOUT_MS} and ${CANCEL_ALL_AFTER_MAX_TIMEOUT_MS}`,
|
|
557
|
+
}),
|
|
558
|
+
// Strict: a misspelled scope key must fail rather than be dropped, or the
|
|
559
|
+
// call would quietly arm the account-wide timer.
|
|
560
|
+
options: z
|
|
561
|
+
.object({
|
|
562
|
+
tradingPairId: UUIDSchema.optional(),
|
|
563
|
+
})
|
|
564
|
+
.strict()
|
|
565
|
+
.optional(),
|
|
566
|
+
})
|
|
567
|
+
.strict();
|
|
547
568
|
export const CancelTwapOrderSchema = z.object({
|
|
548
569
|
twapOrderId: UUIDSchema,
|
|
549
570
|
});
|
package/dist/websocket/base.d.ts
CHANGED
|
@@ -135,7 +135,13 @@ export type WebSocketErrorCode =
|
|
|
135
135
|
* and back off before reconnecting — a hot re-subscribe loop trips the cap
|
|
136
136
|
* again.
|
|
137
137
|
*/
|
|
138
|
-
| "MESSAGE_RATE_LIMIT"
|
|
138
|
+
| "MESSAGE_RATE_LIMIT"
|
|
139
|
+
/**
|
|
140
|
+
* The `rfq` subscription was refused: RFQ is switched off, or this account
|
|
141
|
+
* is not on its access list. The same `RFQ_DISABLED` the REST and gRPC RFQ
|
|
142
|
+
* calls return. The connection stays open.
|
|
143
|
+
*/
|
|
144
|
+
| "RFQ_DISABLED";
|
|
139
145
|
/**
|
|
140
146
|
* An `Error` frame the server sent on this connection.
|
|
141
147
|
*
|
|
@@ -59,7 +59,7 @@ import type { Interval } from "../market";
|
|
|
59
59
|
import type { TradingMode } from "../trading";
|
|
60
60
|
import type { SubscriptionChangeHandler, WebSocketStatus, WebSocketSubscriptionState } from "./base";
|
|
61
61
|
import type { OrderbookQuotationMode } from "./clients/orderbook-client";
|
|
62
|
-
import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketLiquidationEvent, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, PositionValuationEvent, TradeEvent, TradeEventData, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
|
|
62
|
+
import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketLiquidationEvent, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, PositionValuationEvent, RfqEvent, RfqTradeEvent, TradeEvent, TradeEventData, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
|
|
63
63
|
import type { OHLCVSnapshotCandle, OrderSnapshotItem, SnapshotHandler } from "./snapshots";
|
|
64
64
|
export type MessageHandler<T> = (data: T) => void;
|
|
65
65
|
export interface MonacoWebSocket {
|
|
@@ -158,4 +158,23 @@ export interface MonacoWebSocket {
|
|
|
158
158
|
marketStats: (tradingPairId: string, handler: MessageHandler<MarketStatsEvent>, onSnapshot?: SnapshotHandler<MarketStatsData>) => () => void;
|
|
159
159
|
/** Subscribe to the all-markets statistics summary (public) */
|
|
160
160
|
marketStatsAll: (handler: MessageHandler<MarketStatsAllEvent>, onSnapshot?: SnapshotHandler<MarketStatsSummary>) => () => void;
|
|
161
|
+
/**
|
|
162
|
+
* Subscribe to RFQ pushes for the authenticated account (requires
|
|
163
|
+
* authentication): `RfqRequested` for every new RFQ you can quote as a maker
|
|
164
|
+
* (never your own wallet family's), and for the RFQs you are party to the
|
|
165
|
+
* taker's `RfqView`, a selected maker's `RfqSelected` (its last-look prompt)
|
|
166
|
+
* and `RfqOutcome`. Narrow on `eventType` (the wire's `type` tag). There is
|
|
167
|
+
* no per-pair variant and no
|
|
168
|
+
* snapshot: a push is a notification, so read a missed RFQ with `getRfq`.
|
|
169
|
+
* While RFQ is not enabled for the account the subscribe is refused with an
|
|
170
|
+
* `RFQ_DISABLED` error to `onError`.
|
|
171
|
+
*/
|
|
172
|
+
rfq: (handler: MessageHandler<RfqEvent>) => () => void;
|
|
173
|
+
/**
|
|
174
|
+
* Subscribe to the public, anonymised RFQ block prints for one pair. RFQ
|
|
175
|
+
* fills never print on `trades`. There is no snapshot: deduplicate on
|
|
176
|
+
* `data.executionId`, and backfill from the REST trade reads, which include
|
|
177
|
+
* RFQ fills with `executionSource: "RFQ"`.
|
|
178
|
+
*/
|
|
179
|
+
rfqTrades: (tradingPairId: string, handler: MessageHandler<RfqTradeEvent>) => () => void;
|
|
161
180
|
}
|
|
@@ -12,5 +12,7 @@ export * from "./orderbook-events";
|
|
|
12
12
|
export * from "./orders-events";
|
|
13
13
|
export * from "./position-events";
|
|
14
14
|
export * from "./position-valuation-events";
|
|
15
|
+
export * from "./rfq-events";
|
|
16
|
+
export * from "./rfq-trade-events";
|
|
15
17
|
export * from "./trade-events";
|
|
16
18
|
export * from "./twap-order-events";
|
|
@@ -12,5 +12,7 @@ export * from "./orderbook-events";
|
|
|
12
12
|
export * from "./orders-events";
|
|
13
13
|
export * from "./position-events";
|
|
14
14
|
export * from "./position-valuation-events";
|
|
15
|
+
export * from "./rfq-events";
|
|
16
|
+
export * from "./rfq-trade-events";
|
|
15
17
|
export * from "./trade-events";
|
|
16
18
|
export * from "./twap-order-events";
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFQ WebSocket Event Types
|
|
3
|
+
*
|
|
4
|
+
* Pushes on the authenticated `rfq` channel (RFQ-05): new RFQs to quote as a
|
|
5
|
+
* maker, and the RFQs your account is party to. Every frame's `data` is one
|
|
6
|
+
* push, tagged on the wire by `type`.
|
|
7
|
+
*
|
|
8
|
+
* Unlike the other channels the wire keys are camelCase already, so these
|
|
9
|
+
* types carry them as sent, with one rename: the wire's `type` tag is
|
|
10
|
+
* `eventType` here, the discriminator every other channel's events use.
|
|
11
|
+
* Decimals are exact strings; versions,
|
|
12
|
+
* sequences, fee rates and `*Ms` times are numbers (times are Unix
|
|
13
|
+
* milliseconds). A push is a notification, not authority: if you miss one,
|
|
14
|
+
* read the RFQ's authoritative status (`getRfq`).
|
|
15
|
+
*/
|
|
16
|
+
import type { RfqProduct, RfqSide } from "../../validation/rfq";
|
|
17
|
+
/** The side a maker quotes: `BID` buys from the taker, `ASK` sells to it. */
|
|
18
|
+
export type RfqQuoteSide = "BID" | "ASK";
|
|
19
|
+
/** The state an RFQ ended in. */
|
|
20
|
+
export type RfqTerminalState = "SETTLED" | "CANCELLED" | "EXPIRED" | "REJECTED";
|
|
21
|
+
/**
|
|
22
|
+
* A new RFQ you can quote, sent to every account RFQ is enabled for except the
|
|
23
|
+
* requester's own wallet family. It never names the requester.
|
|
24
|
+
*/
|
|
25
|
+
export interface RfqRequestedEvent {
|
|
26
|
+
eventType: "RfqRequested";
|
|
27
|
+
rfqId: string;
|
|
28
|
+
tradingPairId: string;
|
|
29
|
+
product: RfqProduct | (string & {});
|
|
30
|
+
/** The requested base quantity; not a guaranteed fill. */
|
|
31
|
+
quantity: string;
|
|
32
|
+
/** The taker's side on a one-way request; absent on a two-way request. */
|
|
33
|
+
oneWaySide?: RfqSide | (string & {});
|
|
34
|
+
/**
|
|
35
|
+
* The side to quote on a one-way request, the one that fills the taker:
|
|
36
|
+
* `ASK` when it buys, `BID` when it sells. A quote on the other side is
|
|
37
|
+
* refused. Absent on a two-way request, where you may quote either or both.
|
|
38
|
+
*/
|
|
39
|
+
quoteSide?: RfqQuoteSide | (string & {});
|
|
40
|
+
/** No new quotes after this time. */
|
|
41
|
+
newQuoteCutoffAtMs: number;
|
|
42
|
+
}
|
|
43
|
+
/** One side of the taker's view: the allocation that would fill the quantity. */
|
|
44
|
+
export interface RfqSideViewEventData {
|
|
45
|
+
/** All-in volume-weighted price, the taker's fee included. */
|
|
46
|
+
vwap: string;
|
|
47
|
+
availableQuantity: string;
|
|
48
|
+
}
|
|
49
|
+
/** The taker's view of the quotes. No maker identity or individual quote. */
|
|
50
|
+
export interface RfqViewEventData {
|
|
51
|
+
/** Opaque token to hand back unchanged when you accept; compare for equality only. */
|
|
52
|
+
viewVersion: number;
|
|
53
|
+
/** Makers buying: you can sell into it. */
|
|
54
|
+
bid?: RfqSideViewEventData;
|
|
55
|
+
/** Makers selling: you can buy from it. */
|
|
56
|
+
ask?: RfqSideViewEventData;
|
|
57
|
+
asOfMs: number;
|
|
58
|
+
/** Pushes can arrive out of order: keep the view with the highest `sequence`. */
|
|
59
|
+
sequence: number;
|
|
60
|
+
}
|
|
61
|
+
/** To the taker: its view moved. */
|
|
62
|
+
export interface RfqViewEvent {
|
|
63
|
+
eventType: "RfqView";
|
|
64
|
+
rfqId: string;
|
|
65
|
+
view: RfqViewEventData;
|
|
66
|
+
}
|
|
67
|
+
/** A selected maker's own part of an acceptance; never another maker's or the taker's fee. */
|
|
68
|
+
export interface RfqSelectionEventData {
|
|
69
|
+
/** Names the acceptance in your last-look response. */
|
|
70
|
+
acceptanceId: string;
|
|
71
|
+
/** The taker's side. */
|
|
72
|
+
takerSide: RfqSide | (string & {});
|
|
73
|
+
makerAccountId: string;
|
|
74
|
+
quoteId: string;
|
|
75
|
+
quoteVersion: number;
|
|
76
|
+
/** The quantity selected from your quote. */
|
|
77
|
+
quantity: string;
|
|
78
|
+
/** Your frozen quote terms on the side you fill. */
|
|
79
|
+
price: string;
|
|
80
|
+
capacity: string;
|
|
81
|
+
/** Your own tier rate in centi-bps, frozen at acceptance; negative for a rebate. */
|
|
82
|
+
makerFeeCbps: number;
|
|
83
|
+
/** Reject or improve before this time; silence executes. */
|
|
84
|
+
lastLookDeadlineAtMs: number;
|
|
85
|
+
}
|
|
86
|
+
/** To one selected maker: its last-look prompt. */
|
|
87
|
+
export interface RfqSelectedEvent {
|
|
88
|
+
eventType: "RfqSelected";
|
|
89
|
+
rfqId: string;
|
|
90
|
+
selection: RfqSelectionEventData;
|
|
91
|
+
}
|
|
92
|
+
/** One executed child as the taker sees it: no maker. */
|
|
93
|
+
export interface RfqFillEventData {
|
|
94
|
+
executionId: string;
|
|
95
|
+
price: string;
|
|
96
|
+
quantity: string;
|
|
97
|
+
fee: string;
|
|
98
|
+
}
|
|
99
|
+
/** How an RFQ ended, for its taker. */
|
|
100
|
+
export interface RfqOutcomeEventData {
|
|
101
|
+
executedQuantity: string;
|
|
102
|
+
unfilledQuantity: string;
|
|
103
|
+
/** Gross VWAP of the fills; absent when nothing filled. */
|
|
104
|
+
vwap?: string;
|
|
105
|
+
fills: RfqFillEventData[];
|
|
106
|
+
}
|
|
107
|
+
/** To the taker and every maker that quoted: the RFQ ended. */
|
|
108
|
+
export interface RfqOutcomeEvent {
|
|
109
|
+
eventType: "RfqOutcome";
|
|
110
|
+
rfqId: string;
|
|
111
|
+
state: RfqTerminalState | (string & {});
|
|
112
|
+
/** The taker's push only; makers get `state` alone. */
|
|
113
|
+
outcome?: RfqOutcomeEventData;
|
|
114
|
+
}
|
|
115
|
+
/** Any `rfq` channel push; narrow on `eventType`. */
|
|
116
|
+
export type RfqEvent = RfqRequestedEvent | RfqViewEvent | RfqSelectedEvent | RfqOutcomeEvent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFQ WebSocket Event Types
|
|
3
|
+
*
|
|
4
|
+
* Pushes on the authenticated `rfq` channel (RFQ-05): new RFQs to quote as a
|
|
5
|
+
* maker, and the RFQs your account is party to. Every frame's `data` is one
|
|
6
|
+
* push, tagged on the wire by `type`.
|
|
7
|
+
*
|
|
8
|
+
* Unlike the other channels the wire keys are camelCase already, so these
|
|
9
|
+
* types carry them as sent, with one rename: the wire's `type` tag is
|
|
10
|
+
* `eventType` here, the discriminator every other channel's events use.
|
|
11
|
+
* Decimals are exact strings; versions,
|
|
12
|
+
* sequences, fee rates and `*Ms` times are numbers (times are Unix
|
|
13
|
+
* milliseconds). A push is a notification, not authority: if you miss one,
|
|
14
|
+
* read the RFQ's authoritative status (`getRfq`).
|
|
15
|
+
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFQ Trade WebSocket Event Types
|
|
3
|
+
*
|
|
4
|
+
* Public, anonymised prints of RFQ block fills on `rfq_trades:<pair>`
|
|
5
|
+
* (RFQ-23). RFQ fills never print on the order-book `trades` channel.
|
|
6
|
+
*/
|
|
7
|
+
import type { TradingMode } from "../../trading";
|
|
8
|
+
/** The public facts of one RFQ fill: no account, counterparty, quote or RFQ id. */
|
|
9
|
+
export interface RfqTradeEventData {
|
|
10
|
+
/** Deduplicates redeliveries */
|
|
11
|
+
executionId: string;
|
|
12
|
+
/** Execution price, exact decimal string */
|
|
13
|
+
price: string;
|
|
14
|
+
/** Executed base quantity, exact decimal string */
|
|
15
|
+
quantity: string;
|
|
16
|
+
/** When the fill executed (ISO 8601) */
|
|
17
|
+
executedAt: string;
|
|
18
|
+
/** When the print was published (ISO 8601) */
|
|
19
|
+
publishedAt: string;
|
|
20
|
+
}
|
|
21
|
+
/** One RFQ block print. */
|
|
22
|
+
export interface RfqTradeEvent {
|
|
23
|
+
/** Trading pair ID (UUID) */
|
|
24
|
+
tradingPairId: string;
|
|
25
|
+
/** Trading mode (SPOT or MARGIN) */
|
|
26
|
+
tradingMode: TradingMode | (string & {});
|
|
27
|
+
data: RfqTradeEventData;
|
|
28
|
+
}
|