@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/fees/responses.js
CHANGED
|
@@ -107,7 +107,7 @@ export const GetMyFeeTierParamsSchema = z.object({
|
|
|
107
107
|
export const FeeTierScheduleRowSchema = z.object({
|
|
108
108
|
/** Tier level, 1 (lowest volume) through 6 (highest) */
|
|
109
109
|
tierLevel: z.number().int(),
|
|
110
|
-
/**
|
|
110
|
+
/** Minimum weighted 14-day volume for this tier, in quote/USD units */
|
|
111
111
|
minVolumeThreshold: z.string(),
|
|
112
112
|
/** Maker fee in human basis points; negative is a rebate */
|
|
113
113
|
makerFeeBps: z.string(),
|
|
@@ -118,7 +118,7 @@ export const FeeTierScheduleRowSchema = z.object({
|
|
|
118
118
|
* Zod schema for the "my fee tier" response
|
|
119
119
|
*/
|
|
120
120
|
export const GetMyFeeTierResponseSchema = z.object({
|
|
121
|
-
/** Caller's resolved tier (1–6) from
|
|
121
|
+
/** Caller's resolved tier (1–6) from their wallet's recorded weighted 14-day volume */
|
|
122
122
|
currentTierLevel: z.number().int(),
|
|
123
123
|
/** Caller's weighted 14-day volume (perp + 2.5× spot), summed across every application the wallet trades through */
|
|
124
124
|
weightedVolume14d: z.string(),
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/market/index.d.ts
CHANGED
|
@@ -54,9 +54,25 @@ export interface TradingPair {
|
|
|
54
54
|
* `CROSS_MARGIN_NOT_ALLOWED`; open the position with `marginMode: "ISOLATED"`.
|
|
55
55
|
*/
|
|
56
56
|
isolatedOnly: boolean;
|
|
57
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Flat pair-level maker fee in basis points (negative = rebate).
|
|
59
|
+
*
|
|
60
|
+
* @deprecated Not the rate an order is charged: fees are tiered per account.
|
|
61
|
+
* Use `fees.getFeeSchedule(tradingPairId)` for the pair's tier schedule,
|
|
62
|
+
* `fees.getMyFeeTier({ tradingPairId })` for your own rate, and
|
|
63
|
+
* `placementMakerFeeBps` on an order for the rate it was placed at. This
|
|
64
|
+
* field will be removed in a later release.
|
|
65
|
+
*/
|
|
58
66
|
makerFeeBps: number;
|
|
59
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Flat pair-level taker fee in basis points.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated Not the rate an order is charged: fees are tiered per account.
|
|
71
|
+
* Use `fees.getFeeSchedule(tradingPairId)` for the pair's tier schedule,
|
|
72
|
+
* `fees.getMyFeeTier({ tradingPairId })` for your own rate, and
|
|
73
|
+
* `placementTakerFeeBps` on an order for the rate it was placed at. This
|
|
74
|
+
* field will be removed in a later release.
|
|
75
|
+
*/
|
|
60
76
|
takerFeeBps: number;
|
|
61
77
|
/** Minimum order size */
|
|
62
78
|
minOrderSize: string;
|
|
@@ -693,6 +709,10 @@ export interface LiquidationHistoryEvent {
|
|
|
693
709
|
/** Position size × event-time mark price, in quote-asset units. */
|
|
694
710
|
markNotional: string;
|
|
695
711
|
quoteAssetSymbol: string;
|
|
712
|
+
/** The position's liquidation (trigger) price captured with the event, in quote units per base unit. */
|
|
713
|
+
liquidationPrice: string;
|
|
714
|
+
/** Liquidation penalty charged on the event, in quote-asset units; null when none was charged. */
|
|
715
|
+
liquidationFee?: string | null;
|
|
696
716
|
}
|
|
697
717
|
export interface ListLiquidationEventsResponse {
|
|
698
718
|
tradingPairId: string;
|
|
@@ -701,6 +721,27 @@ export interface ListLiquidationEventsResponse {
|
|
|
701
721
|
pageSize: number;
|
|
702
722
|
nextPageToken: string;
|
|
703
723
|
}
|
|
724
|
+
/** Query for {@link MarketAPI.listAllLiquidationEvents}: the per-pair listing's window and cursor. */
|
|
725
|
+
export type ListAllLiquidationEventsParams = ListLiquidationEventsParams;
|
|
726
|
+
export interface ListAllLiquidationEventsResponse {
|
|
727
|
+
/** Events across every market, newest first; each carries its tradingPairId. */
|
|
728
|
+
events: LiquidationHistoryEvent[];
|
|
729
|
+
pageSize: number;
|
|
730
|
+
/** Cursor for the next page; empty when the walk is finished. */
|
|
731
|
+
nextPageToken: string;
|
|
732
|
+
}
|
|
733
|
+
/** One asset's insurance fund. Scale the balance with the asset's decimals from the trading pairs listing. */
|
|
734
|
+
export interface InsuranceFund {
|
|
735
|
+
assetId: string;
|
|
736
|
+
/** Balance available to cover bad debt, in raw asset units (the asset's smallest unit). */
|
|
737
|
+
availableBalanceRaw: string;
|
|
738
|
+
/** When the balance last changed (ISO 8601). */
|
|
739
|
+
updatedAt: string;
|
|
740
|
+
}
|
|
741
|
+
export interface ListInsuranceFundsResponse {
|
|
742
|
+
/** Every insurance fund, one per asset. */
|
|
743
|
+
funds: InsuranceFund[];
|
|
744
|
+
}
|
|
704
745
|
export type LiquidationMetricsInterval = "1m" | "5m" | "1h";
|
|
705
746
|
export interface GetLiquidationMetricsParams {
|
|
706
747
|
interval: LiquidationMetricsInterval;
|
|
@@ -817,4 +858,12 @@ export interface MarketAPI extends BaseAPI {
|
|
|
817
858
|
listLiquidationEvents(tradingPairId: string, params?: ListLiquidationEventsParams): Promise<ListLiquidationEventsResponse>;
|
|
818
859
|
/** Fetch bounded UTC-aligned long/short liquidation totals by side. */
|
|
819
860
|
getLiquidationMetrics(tradingPairId: string, params: GetLiquidationMetricsParams): Promise<LiquidationMetrics>;
|
|
861
|
+
/**
|
|
862
|
+
* Fetch liquidation events across every market, newest first, with the same
|
|
863
|
+
* window and keyset cursor as listLiquidationEvents. Public; each client IP
|
|
864
|
+
* has a read budget.
|
|
865
|
+
*/
|
|
866
|
+
listAllLiquidationEvents(params?: ListAllLiquidationEventsParams): Promise<ListAllLiquidationEventsResponse>;
|
|
867
|
+
/** Fetch every insurance fund's current balance, one per asset. Public; each client IP has a read budget. */
|
|
868
|
+
listInsuranceFunds(): Promise<ListInsuranceFundsResponse>;
|
|
820
869
|
}
|
package/dist/profile/index.d.ts
CHANGED
|
@@ -602,9 +602,22 @@ export interface UserProfile {
|
|
|
602
602
|
accountType: string;
|
|
603
603
|
/** Whether the user can withdraw funds */
|
|
604
604
|
canWithdraw: boolean;
|
|
605
|
-
/**
|
|
605
|
+
/**
|
|
606
|
+
* Flat taker fee in basis points, echoed from a trading pair.
|
|
607
|
+
*
|
|
608
|
+
* @deprecated Not the rate you are charged: fees are tiered per account. Use
|
|
609
|
+
* `fees.getMyFeeTier({ tradingPairId })` for your own rate. This field will
|
|
610
|
+
* be removed in a later release.
|
|
611
|
+
*/
|
|
606
612
|
takerFeeBps: number;
|
|
607
|
-
/**
|
|
613
|
+
/**
|
|
614
|
+
* Flat maker fee in basis points (negative = rebate), echoed from a trading
|
|
615
|
+
* pair.
|
|
616
|
+
*
|
|
617
|
+
* @deprecated Not the rate you are charged: fees are tiered per account. Use
|
|
618
|
+
* `fees.getMyFeeTier({ tradingPairId })` for your own rate. This field will
|
|
619
|
+
* be removed in a later release.
|
|
620
|
+
*/
|
|
608
621
|
makerFeeBps: number;
|
|
609
622
|
/** Account creation timestamp (ISO string) */
|
|
610
623
|
createdAt: string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFQ (block trading) Types
|
|
3
|
+
*
|
|
4
|
+
* A taker requests quotes for a size; makers quote privately; the taker
|
|
5
|
+
* accepts one side of the best allocation, and each selected maker then has a
|
|
6
|
+
* short last look (reject or improve; silence executes). Available only to
|
|
7
|
+
* accounts RFQ is enabled for: other callers get `403` with code
|
|
8
|
+
* `RFQ_DISABLED`.
|
|
9
|
+
*/
|
|
10
|
+
import type { BaseAPI } from "../api";
|
|
11
|
+
import type { AcceptRfqParams, CancelRfqParams, CreateRfqParams, RespondRfqLastLookParams, UpsertRfqQuoteParams, WithdrawRfqQuoteParams } from "../validation/rfq";
|
|
12
|
+
import type { GetRfqCapabilitiesResponse, RespondRfqLastLookResponse, RfqQuoteVersion, RfqStatus, WithdrawRfqQuoteResponse } from "./responses";
|
|
13
|
+
/**
|
|
14
|
+
* RFQ API.
|
|
15
|
+
*
|
|
16
|
+
* Every call is signed and acts for the session's account. Every write takes
|
|
17
|
+
* an `idempotencyKey` (generated when omitted): a retry with the same key and
|
|
18
|
+
* body returns the first result, and the SDK resends a write whose outcome is
|
|
19
|
+
* unknown with the same key. Maker writes (quote, withdraw, last look) are
|
|
20
|
+
* stored with the request exactly as signed.
|
|
21
|
+
*/
|
|
22
|
+
export interface RfqAPI extends BaseAPI {
|
|
23
|
+
/** Your RFQ limits and the markets RFQ is offered on. */
|
|
24
|
+
getCapabilities(): Promise<GetRfqCapabilitiesResponse>;
|
|
25
|
+
/** Request quotes for up to `quantity`. Omit `side` for a two-way RFQ. Delegated agents cannot. */
|
|
26
|
+
createRfq(params: CreateRfqParams): Promise<RfqStatus>;
|
|
27
|
+
/**
|
|
28
|
+
* An RFQ's authoritative status. As taker: the current `view` and, once
|
|
29
|
+
* executed, the `outcome`. As maker: your latest quote, `ownLatestVersion`
|
|
30
|
+
* and, once selected, `ownSelection` for last look.
|
|
31
|
+
*/
|
|
32
|
+
getRfq(rfqId: string): Promise<RfqStatus>;
|
|
33
|
+
/** Accept one side of the view you last saw (`view.viewVersion`). Binding. */
|
|
34
|
+
acceptRfq(rfqId: string, params: AcceptRfqParams): Promise<RfqStatus>;
|
|
35
|
+
/** Cancel an RFQ you have not accepted, before its deadline. */
|
|
36
|
+
cancelRfq(rfqId: string, params?: CancelRfqParams): Promise<RfqStatus>;
|
|
37
|
+
/** As maker: place or replace your quote (a bid, an ask or both), naming your current version. */
|
|
38
|
+
upsertQuote(rfqId: string, params: UpsertRfqQuoteParams): Promise<RfqQuoteVersion>;
|
|
39
|
+
/** As maker: withdraw your current quote, naming your current version. */
|
|
40
|
+
withdrawQuote(rfqId: string, params: WithdrawRfqQuoteParams): Promise<WithdrawRfqQuoteResponse>;
|
|
41
|
+
/** As a selected maker: reject, or improve your frozen terms, before the last-look deadline. */
|
|
42
|
+
respondLastLook(rfqId: string, params: RespondRfqLastLookParams): Promise<RespondRfqLastLookResponse>;
|
|
43
|
+
}
|
|
44
|
+
export * from "./responses";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFQ (block trading) Types
|
|
3
|
+
*
|
|
4
|
+
* A taker requests quotes for a size; makers quote privately; the taker
|
|
5
|
+
* accepts one side of the best allocation, and each selected maker then has a
|
|
6
|
+
* short last look (reject or improve; silence executes). Available only to
|
|
7
|
+
* accounts RFQ is enabled for: other callers get `403` with code
|
|
8
|
+
* `RFQ_DISABLED`.
|
|
9
|
+
*/
|
|
10
|
+
export * from "./responses";
|
|
@@ -0,0 +1,246 @@
|
|
|
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
|
+
/** An RFQ's lifecycle state. */
|
|
17
|
+
export type RfqState = "COLLECTING" | "LAST_LOOK" | "RISK_CLEARING" | "CONFIRMED" | "SETTLED" | "CANCELLED" | "EXPIRED" | "REJECTED";
|
|
18
|
+
/** A quote's price (quote units per base unit) and capacity (base units). */
|
|
19
|
+
export declare const RfqQuoteTermsResponseSchema: z.ZodObject<{
|
|
20
|
+
price: z.ZodString;
|
|
21
|
+
capacity: z.ZodString;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/** The request as created. */
|
|
24
|
+
export declare const RfqRequestTermsSchema: z.ZodObject<{
|
|
25
|
+
rfqId: z.ZodString;
|
|
26
|
+
tradingPairId: z.ZodString;
|
|
27
|
+
product: z.ZodOptional<z.ZodNullable<z.ZodType<"PERPETUAL" | "SPOT" | (string & {}), unknown, z.core.$ZodTypeInternals<"PERPETUAL" | "SPOT" | (string & {}), unknown>>>>;
|
|
28
|
+
quantity: z.ZodString;
|
|
29
|
+
createdAtMs: z.ZodNumber;
|
|
30
|
+
deadlineAtMs: z.ZodNumber;
|
|
31
|
+
side: z.ZodOptional<z.ZodNullable<z.ZodType<"BUY" | "SELL" | (string & {}), unknown, z.core.$ZodTypeInternals<"BUY" | "SELL" | (string & {}), unknown>>>>;
|
|
32
|
+
quoteSide: z.ZodOptional<z.ZodNullable<z.ZodType<"ASK" | "BID" | (string & {}), unknown, z.core.$ZodTypeInternals<"ASK" | "BID" | (string & {}), unknown>>>>;
|
|
33
|
+
leverage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
marginMode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
/** One side of the taker's view: the allocation that would fill the quantity. */
|
|
37
|
+
export declare const RfqSideViewSchema: z.ZodObject<{
|
|
38
|
+
vwap: z.ZodString;
|
|
39
|
+
availableQuantity: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
/** The taker's current view of the quotes. */
|
|
42
|
+
export declare const RfqViewSchema: z.ZodObject<{
|
|
43
|
+
viewVersion: z.ZodNumber;
|
|
44
|
+
bid: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
45
|
+
vwap: z.ZodString;
|
|
46
|
+
availableQuantity: z.ZodString;
|
|
47
|
+
}, z.core.$strip>>>;
|
|
48
|
+
ask: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
49
|
+
vwap: z.ZodString;
|
|
50
|
+
availableQuantity: z.ZodString;
|
|
51
|
+
}, z.core.$strip>>>;
|
|
52
|
+
asOfMs: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
/** One fill of an executed RFQ. */
|
|
55
|
+
export declare const RfqFillSchema: z.ZodObject<{
|
|
56
|
+
executionId: z.ZodString;
|
|
57
|
+
price: z.ZodString;
|
|
58
|
+
quantity: z.ZodString;
|
|
59
|
+
fee: z.ZodString;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
/** What an accepted RFQ executed. */
|
|
62
|
+
export declare const RfqOutcomeSchema: z.ZodObject<{
|
|
63
|
+
executedQuantity: z.ZodString;
|
|
64
|
+
unfilledQuantity: z.ZodString;
|
|
65
|
+
vwap: z.ZodString;
|
|
66
|
+
fills: z.ZodArray<z.ZodObject<{
|
|
67
|
+
executionId: z.ZodString;
|
|
68
|
+
price: z.ZodString;
|
|
69
|
+
quantity: z.ZodString;
|
|
70
|
+
fee: z.ZodString;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
/** A quoted side the venue refused; nothing is reserved for it. */
|
|
74
|
+
export declare const RfqRefusedSideSchema: z.ZodObject<{
|
|
75
|
+
side: z.ZodType<"ASK" | "BID" | (string & {}), unknown, z.core.$ZodTypeInternals<"ASK" | "BID" | (string & {}), unknown>>;
|
|
76
|
+
code: z.ZodString;
|
|
77
|
+
reason: z.ZodString;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
/** A quote version as its maker sees it. */
|
|
80
|
+
export declare const RfqQuoteVersionSchema: z.ZodObject<{
|
|
81
|
+
rfqId: z.ZodString;
|
|
82
|
+
quoteId: z.ZodString;
|
|
83
|
+
version: z.ZodNumber;
|
|
84
|
+
bid: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
85
|
+
price: z.ZodString;
|
|
86
|
+
capacity: z.ZodString;
|
|
87
|
+
}, z.core.$strip>>>;
|
|
88
|
+
ask: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
89
|
+
price: z.ZodString;
|
|
90
|
+
capacity: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>>;
|
|
92
|
+
issuedAtMs: z.ZodNumber;
|
|
93
|
+
validUntilMs: z.ZodNumber;
|
|
94
|
+
leverage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
95
|
+
marginMode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
96
|
+
refusedSides: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
97
|
+
side: z.ZodType<"ASK" | "BID" | (string & {}), unknown, z.core.$ZodTypeInternals<"ASK" | "BID" | (string & {}), unknown>>;
|
|
98
|
+
code: z.ZodString;
|
|
99
|
+
reason: z.ZodString;
|
|
100
|
+
}, z.core.$strip>>>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
/** A selected maker's own part of an acceptance, for answering last look. */
|
|
103
|
+
export declare const RfqMakerSelectionSchema: z.ZodObject<{
|
|
104
|
+
acceptanceId: z.ZodString;
|
|
105
|
+
takerSide: z.ZodOptional<z.ZodNullable<z.ZodType<"BUY" | "SELL" | (string & {}), unknown, z.core.$ZodTypeInternals<"BUY" | "SELL" | (string & {}), unknown>>>>;
|
|
106
|
+
quoteId: z.ZodString;
|
|
107
|
+
quoteVersion: z.ZodNumber;
|
|
108
|
+
quantity: z.ZodString;
|
|
109
|
+
frozenTerms: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
110
|
+
price: z.ZodString;
|
|
111
|
+
capacity: z.ZodString;
|
|
112
|
+
}, z.core.$strip>>>;
|
|
113
|
+
lastLookDeadlineAtMs: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
/**
|
|
116
|
+
* Authoritative RFQ status. A taker sees `view` and `outcome`; a maker sees
|
|
117
|
+
* its own latest quote and, once selected, its own selection.
|
|
118
|
+
*/
|
|
119
|
+
export declare const RfqStatusSchema: z.ZodObject<{
|
|
120
|
+
terms: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
121
|
+
rfqId: z.ZodString;
|
|
122
|
+
tradingPairId: z.ZodString;
|
|
123
|
+
product: z.ZodOptional<z.ZodNullable<z.ZodType<"PERPETUAL" | "SPOT" | (string & {}), unknown, z.core.$ZodTypeInternals<"PERPETUAL" | "SPOT" | (string & {}), unknown>>>>;
|
|
124
|
+
quantity: z.ZodString;
|
|
125
|
+
createdAtMs: z.ZodNumber;
|
|
126
|
+
deadlineAtMs: z.ZodNumber;
|
|
127
|
+
side: z.ZodOptional<z.ZodNullable<z.ZodType<"BUY" | "SELL" | (string & {}), unknown, z.core.$ZodTypeInternals<"BUY" | "SELL" | (string & {}), unknown>>>>;
|
|
128
|
+
quoteSide: z.ZodOptional<z.ZodNullable<z.ZodType<"ASK" | "BID" | (string & {}), unknown, z.core.$ZodTypeInternals<"ASK" | "BID" | (string & {}), unknown>>>>;
|
|
129
|
+
leverage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
marginMode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
}, z.core.$strip>>>;
|
|
132
|
+
state: z.ZodType<RfqState | (string & {}), unknown, z.core.$ZodTypeInternals<RfqState | (string & {}), unknown>>;
|
|
133
|
+
stateVersion: z.ZodNumber;
|
|
134
|
+
acceptedSide: z.ZodOptional<z.ZodNullable<z.ZodType<"BUY" | "SELL" | (string & {}), unknown, z.core.$ZodTypeInternals<"BUY" | "SELL" | (string & {}), unknown>>>>;
|
|
135
|
+
lastLookDeadlineAtMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
136
|
+
view: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
137
|
+
viewVersion: z.ZodNumber;
|
|
138
|
+
bid: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
139
|
+
vwap: z.ZodString;
|
|
140
|
+
availableQuantity: z.ZodString;
|
|
141
|
+
}, z.core.$strip>>>;
|
|
142
|
+
ask: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
143
|
+
vwap: z.ZodString;
|
|
144
|
+
availableQuantity: z.ZodString;
|
|
145
|
+
}, z.core.$strip>>>;
|
|
146
|
+
asOfMs: z.ZodNumber;
|
|
147
|
+
}, z.core.$strip>>>;
|
|
148
|
+
ownQuote: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
149
|
+
rfqId: z.ZodString;
|
|
150
|
+
quoteId: z.ZodString;
|
|
151
|
+
version: z.ZodNumber;
|
|
152
|
+
bid: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
153
|
+
price: z.ZodString;
|
|
154
|
+
capacity: z.ZodString;
|
|
155
|
+
}, z.core.$strip>>>;
|
|
156
|
+
ask: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
157
|
+
price: z.ZodString;
|
|
158
|
+
capacity: z.ZodString;
|
|
159
|
+
}, z.core.$strip>>>;
|
|
160
|
+
issuedAtMs: z.ZodNumber;
|
|
161
|
+
validUntilMs: z.ZodNumber;
|
|
162
|
+
leverage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
163
|
+
marginMode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
+
refusedSides: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
165
|
+
side: z.ZodType<"ASK" | "BID" | (string & {}), unknown, z.core.$ZodTypeInternals<"ASK" | "BID" | (string & {}), unknown>>;
|
|
166
|
+
code: z.ZodString;
|
|
167
|
+
reason: z.ZodString;
|
|
168
|
+
}, z.core.$strip>>>>;
|
|
169
|
+
}, z.core.$strip>>>;
|
|
170
|
+
ownSelection: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
171
|
+
acceptanceId: z.ZodString;
|
|
172
|
+
takerSide: z.ZodOptional<z.ZodNullable<z.ZodType<"BUY" | "SELL" | (string & {}), unknown, z.core.$ZodTypeInternals<"BUY" | "SELL" | (string & {}), unknown>>>>;
|
|
173
|
+
quoteId: z.ZodString;
|
|
174
|
+
quoteVersion: z.ZodNumber;
|
|
175
|
+
quantity: z.ZodString;
|
|
176
|
+
frozenTerms: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
177
|
+
price: z.ZodString;
|
|
178
|
+
capacity: z.ZodString;
|
|
179
|
+
}, z.core.$strip>>>;
|
|
180
|
+
lastLookDeadlineAtMs: z.ZodNumber;
|
|
181
|
+
}, z.core.$strip>>>;
|
|
182
|
+
ownLatestVersion: z.ZodNumber;
|
|
183
|
+
ownQuoteWithdrawn: z.ZodBoolean;
|
|
184
|
+
outcome: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
185
|
+
executedQuantity: z.ZodString;
|
|
186
|
+
unfilledQuantity: z.ZodString;
|
|
187
|
+
vwap: z.ZodString;
|
|
188
|
+
fills: z.ZodArray<z.ZodObject<{
|
|
189
|
+
executionId: z.ZodString;
|
|
190
|
+
price: z.ZodString;
|
|
191
|
+
quantity: z.ZodString;
|
|
192
|
+
fee: z.ZodString;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
}, z.core.$strip>>>;
|
|
195
|
+
durableSequence: z.ZodNumber;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
/** A market RFQ is offered on. */
|
|
198
|
+
export declare const RfqMarketCapabilitySchema: z.ZodObject<{
|
|
199
|
+
tradingPairId: z.ZodString;
|
|
200
|
+
product: z.ZodOptional<z.ZodNullable<z.ZodType<"PERPETUAL" | "SPOT" | (string & {}), unknown, z.core.$ZodTypeInternals<"PERPETUAL" | "SPOT" | (string & {}), unknown>>>>;
|
|
201
|
+
minQuantity: z.ZodString;
|
|
202
|
+
maxQuantity: z.ZodString;
|
|
203
|
+
}, z.core.$strip>;
|
|
204
|
+
/** Your RFQ limits and the markets RFQ is offered on. */
|
|
205
|
+
export declare const GetRfqCapabilitiesResponseSchema: z.ZodObject<{
|
|
206
|
+
protocolVersion: z.ZodNumber;
|
|
207
|
+
enabled: z.ZodBoolean;
|
|
208
|
+
markets: z.ZodArray<z.ZodObject<{
|
|
209
|
+
tradingPairId: z.ZodString;
|
|
210
|
+
product: z.ZodOptional<z.ZodNullable<z.ZodType<"PERPETUAL" | "SPOT" | (string & {}), unknown, z.core.$ZodTypeInternals<"PERPETUAL" | "SPOT" | (string & {}), unknown>>>>;
|
|
211
|
+
minQuantity: z.ZodString;
|
|
212
|
+
maxQuantity: z.ZodString;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
requestWindowMs: z.ZodNumber;
|
|
215
|
+
minQuoteValidityMs: z.ZodNumber;
|
|
216
|
+
maxQuoteValidityMs: z.ZodNumber;
|
|
217
|
+
lastLookMs: z.ZodNumber;
|
|
218
|
+
maxNewRfqs: z.ZodNumber;
|
|
219
|
+
quotaWindowMs: z.ZodNumber;
|
|
220
|
+
quotaRemaining: z.ZodNumber;
|
|
221
|
+
quotaRetryAfterMs: z.ZodNumber;
|
|
222
|
+
}, z.core.$strip>;
|
|
223
|
+
/** A withdrawn quote: the withdrawal's version. */
|
|
224
|
+
export declare const WithdrawRfqQuoteResponseSchema: z.ZodObject<{
|
|
225
|
+
rfqId: z.ZodString;
|
|
226
|
+
version: z.ZodNumber;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
/** A recorded last-look answer. */
|
|
229
|
+
export declare const RespondRfqLastLookResponseSchema: z.ZodObject<{
|
|
230
|
+
acceptanceId: z.ZodString;
|
|
231
|
+
response: z.ZodOptional<z.ZodNullable<z.ZodType<"IMPROVE" | "REJECT" | (string & {}), unknown, z.core.$ZodTypeInternals<"IMPROVE" | "REJECT" | (string & {}), unknown>>>>;
|
|
232
|
+
recordedAtMs: z.ZodNumber;
|
|
233
|
+
}, z.core.$strip>;
|
|
234
|
+
export type RfqRequestTerms = z.infer<typeof RfqRequestTermsSchema>;
|
|
235
|
+
export type RfqSideView = z.infer<typeof RfqSideViewSchema>;
|
|
236
|
+
export type RfqView = z.infer<typeof RfqViewSchema>;
|
|
237
|
+
export type RfqFill = z.infer<typeof RfqFillSchema>;
|
|
238
|
+
export type RfqOutcome = z.infer<typeof RfqOutcomeSchema>;
|
|
239
|
+
export type RfqQuoteVersion = z.infer<typeof RfqQuoteVersionSchema>;
|
|
240
|
+
export type RfqRefusedSide = z.infer<typeof RfqRefusedSideSchema>;
|
|
241
|
+
export type RfqMakerSelection = z.infer<typeof RfqMakerSelectionSchema>;
|
|
242
|
+
export type RfqStatus = z.infer<typeof RfqStatusSchema>;
|
|
243
|
+
export type RfqMarketCapability = z.infer<typeof RfqMarketCapabilitySchema>;
|
|
244
|
+
export type GetRfqCapabilitiesResponse = z.infer<typeof GetRfqCapabilitiesResponseSchema>;
|
|
245
|
+
export type WithdrawRfqQuoteResponse = z.infer<typeof WithdrawRfqQuoteResponseSchema>;
|
|
246
|
+
export type RespondRfqLastLookResponse = z.infer<typeof RespondRfqLastLookResponseSchema>;
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
});
|
|
55
|
+
/** The taker's current view of the quotes. */
|
|
56
|
+
export const RfqViewSchema = z.object({
|
|
57
|
+
/** The version to accept; a newer view refuses an older one. */
|
|
58
|
+
viewVersion: z.number(),
|
|
59
|
+
bid: RfqSideViewSchema.nullish(),
|
|
60
|
+
ask: RfqSideViewSchema.nullish(),
|
|
61
|
+
asOfMs: z.number(),
|
|
62
|
+
});
|
|
63
|
+
/** One fill of an executed RFQ. */
|
|
64
|
+
export const RfqFillSchema = z.object({
|
|
65
|
+
executionId: z.string(),
|
|
66
|
+
price: z.string(),
|
|
67
|
+
quantity: z.string(),
|
|
68
|
+
fee: z.string(),
|
|
69
|
+
});
|
|
70
|
+
/** What an accepted RFQ executed. */
|
|
71
|
+
export const RfqOutcomeSchema = z.object({
|
|
72
|
+
executedQuantity: z.string(),
|
|
73
|
+
unfilledQuantity: z.string(),
|
|
74
|
+
vwap: z.string(),
|
|
75
|
+
fills: z.array(RfqFillSchema),
|
|
76
|
+
});
|
|
77
|
+
/** A quoted side the venue refused; nothing is reserved for it. */
|
|
78
|
+
export const RfqRefusedSideSchema = z.object({
|
|
79
|
+
side: openUnion(),
|
|
80
|
+
/** INSUFFICIENT_BALANCE or QUOTE_REJECTED. */
|
|
81
|
+
code: z.string(),
|
|
82
|
+
reason: z.string(),
|
|
83
|
+
});
|
|
84
|
+
/** A quote version as its maker sees it. */
|
|
85
|
+
export const RfqQuoteVersionSchema = z.object({
|
|
86
|
+
rfqId: z.string(),
|
|
87
|
+
quoteId: z.string(),
|
|
88
|
+
/** This version; name it to replace or withdraw. */
|
|
89
|
+
version: z.number(),
|
|
90
|
+
bid: RfqQuoteTermsResponseSchema.nullish(),
|
|
91
|
+
ask: RfqQuoteTermsResponseSchema.nullish(),
|
|
92
|
+
issuedAtMs: z.number(),
|
|
93
|
+
validUntilMs: z.number(),
|
|
94
|
+
/** Perpetuals: the leverage the quote's orders reserve with. */
|
|
95
|
+
leverage: z.string().nullish(),
|
|
96
|
+
/** Perpetuals: ISOLATED or CROSS. */
|
|
97
|
+
marginMode: z.string().nullish(),
|
|
98
|
+
/**
|
|
99
|
+
* Quoted sides the venue refused. The version holds only the funded sides;
|
|
100
|
+
* when none is funded the quote is refused instead.
|
|
101
|
+
*/
|
|
102
|
+
refusedSides: z.array(RfqRefusedSideSchema).nullish(),
|
|
103
|
+
});
|
|
104
|
+
/** A selected maker's own part of an acceptance, for answering last look. */
|
|
105
|
+
export const RfqMakerSelectionSchema = z.object({
|
|
106
|
+
acceptanceId: z.string(),
|
|
107
|
+
/** The taker's side. */
|
|
108
|
+
takerSide: openUnion().nullish(),
|
|
109
|
+
quoteId: z.string(),
|
|
110
|
+
quoteVersion: z.number(),
|
|
111
|
+
quantity: z.string(),
|
|
112
|
+
frozenTerms: RfqQuoteTermsResponseSchema.nullish(),
|
|
113
|
+
lastLookDeadlineAtMs: z.number(),
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* Authoritative RFQ status. A taker sees `view` and `outcome`; a maker sees
|
|
117
|
+
* its own latest quote and, once selected, its own selection.
|
|
118
|
+
*/
|
|
119
|
+
export const RfqStatusSchema = z.object({
|
|
120
|
+
terms: RfqRequestTermsSchema.nullish(),
|
|
121
|
+
state: openUnion(),
|
|
122
|
+
stateVersion: z.number(),
|
|
123
|
+
acceptedSide: openUnion().nullish(),
|
|
124
|
+
lastLookDeadlineAtMs: z.number().nullish(),
|
|
125
|
+
view: RfqViewSchema.nullish(),
|
|
126
|
+
ownQuote: RfqQuoteVersionSchema.nullish(),
|
|
127
|
+
ownSelection: RfqMakerSelectionSchema.nullish(),
|
|
128
|
+
/** The `expectedVersion` for your next quote or withdrawal. */
|
|
129
|
+
ownLatestVersion: z.number(),
|
|
130
|
+
ownQuoteWithdrawn: z.boolean(),
|
|
131
|
+
outcome: RfqOutcomeSchema.nullish(),
|
|
132
|
+
durableSequence: z.number(),
|
|
133
|
+
});
|
|
134
|
+
/** A market RFQ is offered on. */
|
|
135
|
+
export const RfqMarketCapabilitySchema = z.object({
|
|
136
|
+
tradingPairId: z.string(),
|
|
137
|
+
product: openUnion().nullish(),
|
|
138
|
+
minQuantity: z.string(),
|
|
139
|
+
maxQuantity: z.string(),
|
|
140
|
+
});
|
|
141
|
+
/** Your RFQ limits and the markets RFQ is offered on. */
|
|
142
|
+
export const GetRfqCapabilitiesResponseSchema = z.object({
|
|
143
|
+
protocolVersion: z.number(),
|
|
144
|
+
/** Whether RFQ is enabled for you. */
|
|
145
|
+
enabled: z.boolean(),
|
|
146
|
+
markets: z.array(RfqMarketCapabilitySchema),
|
|
147
|
+
requestWindowMs: z.number(),
|
|
148
|
+
minQuoteValidityMs: z.number(),
|
|
149
|
+
maxQuoteValidityMs: z.number(),
|
|
150
|
+
lastLookMs: z.number(),
|
|
151
|
+
/** RFQs you may create per quota window. */
|
|
152
|
+
maxNewRfqs: z.number(),
|
|
153
|
+
quotaWindowMs: z.number(),
|
|
154
|
+
quotaRemaining: z.number(),
|
|
155
|
+
quotaRetryAfterMs: z.number(),
|
|
156
|
+
});
|
|
157
|
+
/** A withdrawn quote: the withdrawal's version. */
|
|
158
|
+
export const WithdrawRfqQuoteResponseSchema = z.object({
|
|
159
|
+
rfqId: z.string(),
|
|
160
|
+
version: z.number(),
|
|
161
|
+
});
|
|
162
|
+
/** A recorded last-look answer. */
|
|
163
|
+
export const RespondRfqLastLookResponseSchema = z.object({
|
|
164
|
+
acceptanceId: z.string(),
|
|
165
|
+
response: openUnion().nullish(),
|
|
166
|
+
recordedAtMs: z.number(),
|
|
167
|
+
});
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { PortfolioAPI } from "../portfolio";
|
|
|
14
14
|
import type { PositionsAPI } from "../positions";
|
|
15
15
|
import type { ProfileAPI } from "../profile";
|
|
16
16
|
import type { PulseAPI } from "../pulse";
|
|
17
|
+
import type { RfqAPI } from "../rfq";
|
|
17
18
|
import type { SubAccountsAPI } from "../sub-accounts";
|
|
18
19
|
import type { SweeperAPI } from "../sweeper";
|
|
19
20
|
import type { TraderCodesAPI } from "../tradercodes";
|
|
@@ -120,6 +121,8 @@ export interface MonacoSDK {
|
|
|
120
121
|
buildercodes: BuildercodesAPI;
|
|
121
122
|
/** Copy trading API: lead trader profiles and the leaderboard, and your follows */
|
|
122
123
|
copyTrading: CopyTradingAPI;
|
|
124
|
+
/** RFQ (block trading) API: request and accept quotes as taker, quote and answer last look as maker */
|
|
125
|
+
rfq: RfqAPI;
|
|
123
126
|
/** Testnet faucet API */
|
|
124
127
|
faucet: FaucetAPI;
|
|
125
128
|
/** Deposit-address registration (sweeper) API; requires a session */
|
|
@@ -138,7 +141,7 @@ export interface MonacoSDK {
|
|
|
138
141
|
depth?: number;
|
|
139
142
|
/** Trading mode: 'Spot' or 'Margin'. Defaults to 'Spot'. */
|
|
140
143
|
tradingMode?: TradingMode;
|
|
141
|
-
/** Price grouping magnitude. Valid values: 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000. */
|
|
144
|
+
/** Price grouping magnitude. Valid values: 0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000. */
|
|
142
145
|
magnitude?: number;
|
|
143
146
|
/** Quantity denomination: 'BASE' or 'QUOTE'. When 'QUOTE' type, quantities are multiplied by the quote price. */
|
|
144
147
|
denomination?: OrderbookQuotationMode;
|
|
@@ -160,6 +163,23 @@ export interface MonacoSDK {
|
|
|
160
163
|
/** Empty exactly when the walk is finished. */
|
|
161
164
|
nextPageToken: string;
|
|
162
165
|
}>;
|
|
166
|
+
/**
|
|
167
|
+
* One page of the trade feed: every market, newest first, or only the
|
|
168
|
+
* trades one application took (`takerApplicationId`). Public and rate
|
|
169
|
+
* limited per client IP; follow `nextPageToken` until it is empty.
|
|
170
|
+
*/
|
|
171
|
+
listTrades: (options?: {
|
|
172
|
+
/** Only the trades this application (frontend) took, as the taker's application. */
|
|
173
|
+
takerApplicationId?: string;
|
|
174
|
+
/** Maximum number of records to return (default: 25, max: 1000) */
|
|
175
|
+
pageSize?: number;
|
|
176
|
+
/** Cursor from a previous response's `nextPageToken`; omit to start */
|
|
177
|
+
pageToken?: string;
|
|
178
|
+
}) => Promise<{
|
|
179
|
+
trades: TradeEvent[];
|
|
180
|
+
/** Empty exactly when the walk is finished. */
|
|
181
|
+
nextPageToken: string;
|
|
182
|
+
}>;
|
|
163
183
|
};
|
|
164
184
|
/** WebSocket client for real-time data — the full typed channel surface of {@link MonacoWebSocket} */
|
|
165
185
|
ws: MonacoWebSocket;
|