@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,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Market-data depth and BBO types (0XM-3551).
|
|
3
|
+
*
|
|
4
|
+
* The `depth:<tradingPairId>:<SPOT|MARGIN>` and `bbo:<tradingPairId>:<SPOT|MARGIN>`
|
|
5
|
+
* WebSocket channels carry the market-data service's sequenced book: a
|
|
6
|
+
* subscribe-time snapshot, then live frames linked by `bookSeq` /
|
|
7
|
+
* `prevBookSeq`. The SDK's `ws.depth` and `ws.bbo` helpers keep the local
|
|
8
|
+
* state for you; the frame shapes are exported for callers that need them.
|
|
9
|
+
*
|
|
10
|
+
* Sequence numbers are durable-log positions (u64). They are surfaced as
|
|
11
|
+
* decimal strings, since a u64 can exceed `Number.MAX_SAFE_INTEGER`; compare
|
|
12
|
+
* them with `BigInt`.
|
|
13
|
+
*/
|
|
14
|
+
import type { TradingMode } from "../trading";
|
|
15
|
+
/** One price level, with its absolute (not incremental) values. */
|
|
16
|
+
export interface DepthLevel {
|
|
17
|
+
/** Price, a decimal string. */
|
|
18
|
+
price: string;
|
|
19
|
+
/** Resting quantity at this price, a decimal string. */
|
|
20
|
+
quantity: string;
|
|
21
|
+
/** Number of resting orders at this price. */
|
|
22
|
+
orderCount: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The `depth` channel's subscribe-time snapshot: up to 1000 levels per side,
|
|
26
|
+
* best first, exact as of `bookSeq`.
|
|
27
|
+
*/
|
|
28
|
+
export interface DepthSnapshot {
|
|
29
|
+
tradingPairId: string;
|
|
30
|
+
tradingMode: TradingMode | (string & {});
|
|
31
|
+
/** The durable-log sequence the snapshot is exact as of (u64, decimal string). */
|
|
32
|
+
bookSeq: string;
|
|
33
|
+
bids: DepthLevel[];
|
|
34
|
+
asks: DepthLevel[];
|
|
35
|
+
/** Every bid level is in `bids`; when false, levels below the last one are unknown. */
|
|
36
|
+
bidsComplete: boolean;
|
|
37
|
+
/** Every ask level is in `asks`; when false, levels above the last one are unknown. */
|
|
38
|
+
asksComplete: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A live `depth` frame: only the levels that changed since `prevBookSeq`,
|
|
42
|
+
* each with its absolute value at `bookSeq`. A quantity of `"0"` (order
|
|
43
|
+
* count 0) removes the level.
|
|
44
|
+
*/
|
|
45
|
+
export interface DepthDelta {
|
|
46
|
+
tradingPairId: string;
|
|
47
|
+
tradingMode: TradingMode | (string & {});
|
|
48
|
+
/** The durable-log sequence of the last change this frame includes. */
|
|
49
|
+
bookSeq: string;
|
|
50
|
+
/** The `bookSeq` this frame continues from. */
|
|
51
|
+
prevBookSeq: string;
|
|
52
|
+
/** The durable-log timestamp of the step at `bookSeq`, in milliseconds. */
|
|
53
|
+
timestampMs: number;
|
|
54
|
+
bids: DepthLevel[];
|
|
55
|
+
asks: DepthLevel[];
|
|
56
|
+
/** Set while the publisher lags the durable log. */
|
|
57
|
+
stale: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** The local book `ws.depth` maintains and hands to its listener. */
|
|
60
|
+
export interface DepthBook {
|
|
61
|
+
tradingPairId: string;
|
|
62
|
+
tradingMode: TradingMode | (string & {});
|
|
63
|
+
/** The sequence the book is current as of (u64, decimal string). */
|
|
64
|
+
bookSeq: string;
|
|
65
|
+
/** Bids, best (highest) first. */
|
|
66
|
+
bids: DepthLevel[];
|
|
67
|
+
/** Asks, best (lowest) first. */
|
|
68
|
+
asks: DepthLevel[];
|
|
69
|
+
/**
|
|
70
|
+
* Every bid level is known. When false, the book holds only levels at or
|
|
71
|
+
* above the snapshot's deepest bid: a level below it that a removal would
|
|
72
|
+
* promote stays unknown until the next snapshot.
|
|
73
|
+
*/
|
|
74
|
+
bidsComplete: boolean;
|
|
75
|
+
/** Every ask level is known (see `bidsComplete`). */
|
|
76
|
+
asksComplete: boolean;
|
|
77
|
+
/** The latest applied frame was published while the service lagged. */
|
|
78
|
+
stale: boolean;
|
|
79
|
+
/** Durable-log time of the latest applied frame; absent right after a snapshot. */
|
|
80
|
+
timestampMs?: number;
|
|
81
|
+
}
|
|
82
|
+
/** The `bbo` channel's subscribe-time snapshot. An empty side is `null`. */
|
|
83
|
+
export interface BboSnapshot {
|
|
84
|
+
tradingPairId: string;
|
|
85
|
+
tradingMode: TradingMode | (string & {});
|
|
86
|
+
bookSeq: string;
|
|
87
|
+
bestBid: string | null;
|
|
88
|
+
/** Quantity resting at `bestBid`. */
|
|
89
|
+
bidQty: string | null;
|
|
90
|
+
bestAsk: string | null;
|
|
91
|
+
/** Quantity resting at `bestAsk`. */
|
|
92
|
+
askQty: string | null;
|
|
93
|
+
}
|
|
94
|
+
/** A live `bbo` frame. */
|
|
95
|
+
export interface BboEvent extends BboSnapshot {
|
|
96
|
+
prevBookSeq: string;
|
|
97
|
+
timestampMs: number;
|
|
98
|
+
stale: boolean;
|
|
99
|
+
}
|
|
100
|
+
/** The top of book `ws.bbo` maintains and hands to its listener. */
|
|
101
|
+
export interface Bbo extends BboSnapshot {
|
|
102
|
+
/** The latest applied frame was published while the service lagged. */
|
|
103
|
+
stale: boolean;
|
|
104
|
+
/** Durable-log time of the latest applied frame; absent right after a snapshot. */
|
|
105
|
+
timestampMs?: number;
|
|
106
|
+
}
|
|
107
|
+
/** Why a local book was discarded and is being rebuilt from a new snapshot. */
|
|
108
|
+
export type LocalBookResyncReason =
|
|
109
|
+
/** A frame did not link to the book (a lost frame), or could not be read. */
|
|
110
|
+
"gap"
|
|
111
|
+
/**
|
|
112
|
+
* The server could not serve a snapshot (`SNAPSHOT_UNAVAILABLE`; it retries
|
|
113
|
+
* and sends one when the book heals), or the one it sent could not be read.
|
|
114
|
+
*/
|
|
115
|
+
| "snapshot_unavailable"
|
|
116
|
+
/**
|
|
117
|
+
* A side whose snapshot was incomplete has thinned below half its snapshot
|
|
118
|
+
* depth: the levels beyond its boundary are unknown, so a fresh snapshot is
|
|
119
|
+
* taken.
|
|
120
|
+
*/
|
|
121
|
+
| "truncated"
|
|
122
|
+
/** The connection dropped; the book is rebuilt from the snapshot the reconnect brings. */
|
|
123
|
+
| "disconnected";
|
|
124
|
+
/** A channel-level error the server sent for a `depth` / `bbo` subscription. */
|
|
125
|
+
export interface LocalBookError {
|
|
126
|
+
/** The server's error code, e.g. `INVALID_SUBSCRIPTION`. */
|
|
127
|
+
code: string;
|
|
128
|
+
message: string;
|
|
129
|
+
}
|
|
130
|
+
/** Options for `ws.depth` and `ws.bbo`. */
|
|
131
|
+
export interface LocalBookOptions {
|
|
132
|
+
/**
|
|
133
|
+
* Called when the local state is discarded to be rebuilt; the listener is
|
|
134
|
+
* called again once the new snapshot arrives.
|
|
135
|
+
*/
|
|
136
|
+
onResync?: (reason: LocalBookResyncReason) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Called when the server rejects the subscription with an error other than
|
|
139
|
+
* `SNAPSHOT_UNAVAILABLE` (which is retried): the book will not arrive.
|
|
140
|
+
*/
|
|
141
|
+
onError?: (error: LocalBookError) => void;
|
|
142
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Market-data depth and BBO types (0XM-3551).
|
|
3
|
+
*
|
|
4
|
+
* The `depth:<tradingPairId>:<SPOT|MARGIN>` and `bbo:<tradingPairId>:<SPOT|MARGIN>`
|
|
5
|
+
* WebSocket channels carry the market-data service's sequenced book: a
|
|
6
|
+
* subscribe-time snapshot, then live frames linked by `bookSeq` /
|
|
7
|
+
* `prevBookSeq`. The SDK's `ws.depth` and `ws.bbo` helpers keep the local
|
|
8
|
+
* state for you; the frame shapes are exported for callers that need them.
|
|
9
|
+
*
|
|
10
|
+
* Sequence numbers are durable-log positions (u64). They are surfaced as
|
|
11
|
+
* decimal strings, since a u64 can exceed `Number.MAX_SAFE_INTEGER`; compare
|
|
12
|
+
* them with `BigInt`.
|
|
13
|
+
*/
|
|
@@ -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";
|
|
@@ -67,6 +67,46 @@ export interface OrderbookEvent {
|
|
|
67
67
|
quoteDecimals: number;
|
|
68
68
|
/** Event timestamp */
|
|
69
69
|
timestamp: string;
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Sequence number for ordering. Under the default engine source it is the
|
|
72
|
+
* matching engine's own frame counter; when the server renders the channel
|
|
73
|
+
* from market-data's book (`WS_ORDERBOOK_SOURCE=market_data`) it equals
|
|
74
|
+
* `bookSeq`. The two are different number spaces: do not compare a value
|
|
75
|
+
* from one source with a value from the other (a reconnect or deploy can
|
|
76
|
+
* switch sources). For exact comparison under the market-data source use
|
|
77
|
+
* `bookSeq`, a u64 decimal string.
|
|
78
|
+
*/
|
|
71
79
|
sequence: number;
|
|
80
|
+
/**
|
|
81
|
+
* Durable-log sequence this book is exact as of, as a decimal string
|
|
82
|
+
* (a u64 can exceed `Number.MAX_SAFE_INTEGER`; compare with `BigInt`).
|
|
83
|
+
*
|
|
84
|
+
* Present on a REST snapshot of more than 100 levels: a point-in-time
|
|
85
|
+
* read and staleness check, not a base for applying depth deltas (the REST
|
|
86
|
+
* snapshot may come from a different market-data replica than the stream;
|
|
87
|
+
* for a live local book use `sdk.ws.depth`, which hands off from the
|
|
88
|
+
* `depth` channel's own snapshot). A side that came back with as many
|
|
89
|
+
* levels as requested may hold more.
|
|
90
|
+
*
|
|
91
|
+
* Also present on every `orderbook` WebSocket frame and snapshot row when
|
|
92
|
+
* the server renders the channel from market-data's book
|
|
93
|
+
* (`WS_ORDERBOOK_SOURCE=market_data`): the same watermark the `depth`
|
|
94
|
+
* channel carries, identical on every server. Each such frame restates the
|
|
95
|
+
* book, so per subscription (one channel string: pair, mode, magnitude and
|
|
96
|
+
* quotation) a frame whose `bookSeq` is not past the last one applied to it
|
|
97
|
+
* can be ignored. The watermark is the book's, shared by every magnitude
|
|
98
|
+
* and quotation of it: a newly subscribed variant starts from its own
|
|
99
|
+
* snapshot even when its `bookSeq` equals another variant's.
|
|
100
|
+
*/
|
|
101
|
+
bookSeq?: string;
|
|
102
|
+
/**
|
|
103
|
+
* On an `orderbook` WebSocket frame rendered from market-data's book
|
|
104
|
+
* (`WS_ORDERBOOK_SOURCE=market_data`): the `bookSeq` of the previous frame
|
|
105
|
+
* this server rendered for the book, `"0"` before the first, as a decimal
|
|
106
|
+
* string. A `prevBookSeq` at or below the `bookSeq` you hold means no
|
|
107
|
+
* rendered state was skipped. Informational only: every frame restates the
|
|
108
|
+
* whole book, so nothing needs to be re-requested when it is higher.
|
|
109
|
+
* Absent under the engine source and on REST snapshots.
|
|
110
|
+
*/
|
|
111
|
+
prevBookSeq?: string;
|
|
72
112
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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 Monaco and builder fees included. */
|
|
46
|
+
vwap: string;
|
|
47
|
+
availableQuantity: string;
|
|
48
|
+
/** The volume-weighted price before fees. */
|
|
49
|
+
grossVwap?: string;
|
|
50
|
+
/** Estimated Monaco taker fee on `availableQuantity`, in the quote asset. */
|
|
51
|
+
estimatedMonacoFee?: string;
|
|
52
|
+
/** Estimated builder fee on `availableQuantity`, in the quote asset. */
|
|
53
|
+
estimatedBuilderFee?: string;
|
|
54
|
+
/** Estimated total taker fee on `availableQuantity`, in the quote asset. */
|
|
55
|
+
estimatedTotalFee?: string;
|
|
56
|
+
}
|
|
57
|
+
/** The taker's view of the quotes. No maker identity or individual quote. */
|
|
58
|
+
export interface RfqViewEventData {
|
|
59
|
+
/** Opaque token to hand back unchanged when you accept; compare for equality only. */
|
|
60
|
+
viewVersion: number;
|
|
61
|
+
/** Makers buying: you can sell into it. */
|
|
62
|
+
bid?: RfqSideViewEventData;
|
|
63
|
+
/** Makers selling: you can buy from it. */
|
|
64
|
+
ask?: RfqSideViewEventData;
|
|
65
|
+
asOfMs: number;
|
|
66
|
+
/** Pushes can arrive out of order: keep the view with the highest `sequence`. */
|
|
67
|
+
sequence: number;
|
|
68
|
+
/** Your Monaco taker fee rate in this view, in centi-bps. */
|
|
69
|
+
monacoFeeCbps?: number;
|
|
70
|
+
/** Your frontend's builder fee rate in this view, in centi-bps; frozen when you accept. */
|
|
71
|
+
builderFeeCbps?: number;
|
|
72
|
+
}
|
|
73
|
+
/** To the taker: its view moved. */
|
|
74
|
+
export interface RfqViewEvent {
|
|
75
|
+
eventType: "RfqView";
|
|
76
|
+
rfqId: string;
|
|
77
|
+
view: RfqViewEventData;
|
|
78
|
+
}
|
|
79
|
+
/** A selected maker's own part of an acceptance; never another maker's or the taker's fee. */
|
|
80
|
+
export interface RfqSelectionEventData {
|
|
81
|
+
/** Names the acceptance in your last-look response. */
|
|
82
|
+
acceptanceId: string;
|
|
83
|
+
/** The taker's side. */
|
|
84
|
+
takerSide: RfqSide | (string & {});
|
|
85
|
+
makerAccountId: string;
|
|
86
|
+
quoteId: string;
|
|
87
|
+
quoteVersion: number;
|
|
88
|
+
/** The quantity selected from your quote. */
|
|
89
|
+
quantity: string;
|
|
90
|
+
/** Your frozen quote terms on the side you fill. */
|
|
91
|
+
price: string;
|
|
92
|
+
capacity: string;
|
|
93
|
+
/** Your own tier rate in centi-bps, frozen at acceptance; negative for a rebate. */
|
|
94
|
+
makerFeeCbps: number;
|
|
95
|
+
/** Reject or improve before this time; silence executes. */
|
|
96
|
+
lastLookDeadlineAtMs: number;
|
|
97
|
+
/**
|
|
98
|
+
* The MOST your frontend's builder add-on charges on this fill, in centi-bps:
|
|
99
|
+
* the rate stored on your quote order. A fill charges it or nothing, never
|
|
100
|
+
* more; the receipt shows what was charged. Absent when it could not be read.
|
|
101
|
+
*/
|
|
102
|
+
maxBuilderFeeCbps?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Estimated net at `quantity` and `price`, in the quote asset, at
|
|
105
|
+
* `makerFeeCbps` plus `maxBuilderFeeCbps`: the least you receive when
|
|
106
|
+
* selling, the most you pay when buying. Absent with `maxBuilderFeeCbps`.
|
|
107
|
+
*/
|
|
108
|
+
estimatedNet?: string;
|
|
109
|
+
}
|
|
110
|
+
/** To one selected maker: its last-look prompt. */
|
|
111
|
+
export interface RfqSelectedEvent {
|
|
112
|
+
eventType: "RfqSelected";
|
|
113
|
+
rfqId: string;
|
|
114
|
+
selection: RfqSelectionEventData;
|
|
115
|
+
}
|
|
116
|
+
/** One executed child as the taker sees it: no maker. */
|
|
117
|
+
export interface RfqFillEventData {
|
|
118
|
+
executionId: string;
|
|
119
|
+
price: string;
|
|
120
|
+
quantity: string;
|
|
121
|
+
/** Your whole taker fee on this fill: `monacoFee` plus `builderFee`. */
|
|
122
|
+
fee: string;
|
|
123
|
+
/** The Monaco part of `fee`. */
|
|
124
|
+
monacoFee?: string;
|
|
125
|
+
/** The builder part of `fee`. */
|
|
126
|
+
builderFee?: string;
|
|
127
|
+
}
|
|
128
|
+
/** How an RFQ ended, for its taker. */
|
|
129
|
+
export interface RfqOutcomeEventData {
|
|
130
|
+
executedQuantity: string;
|
|
131
|
+
unfilledQuantity: string;
|
|
132
|
+
/** Gross VWAP of the fills; absent when nothing filled. */
|
|
133
|
+
vwap?: string;
|
|
134
|
+
fills: RfqFillEventData[];
|
|
135
|
+
}
|
|
136
|
+
/** To the taker and every maker that quoted: the RFQ ended. */
|
|
137
|
+
export interface RfqOutcomeEvent {
|
|
138
|
+
eventType: "RfqOutcome";
|
|
139
|
+
rfqId: string;
|
|
140
|
+
state: RfqTerminalState | (string & {});
|
|
141
|
+
/** The taker's push only; makers get `state` alone. */
|
|
142
|
+
outcome?: RfqOutcomeEventData;
|
|
143
|
+
}
|
|
144
|
+
/** Any `rfq` channel push; narrow on `eventType`. */
|
|
145
|
+
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
|
+
}
|
|
@@ -18,6 +18,28 @@ export interface TradeEventData {
|
|
|
18
18
|
makerSide: OrderSide | (string & {});
|
|
19
19
|
/** Timestamp when the trade was executed (ISO 8601) */
|
|
20
20
|
executedAt: string;
|
|
21
|
+
/**
|
|
22
|
+
* How the trade executed: CLOB (on the order book) or RFQ (a request-for-quote
|
|
23
|
+
* block fill). Set on REST trade reads; the WebSocket `trades` channel carries
|
|
24
|
+
* order-book trades only.
|
|
25
|
+
*/
|
|
26
|
+
executionSource?: "CLOB" | "RFQ" | (string & {});
|
|
27
|
+
/** Maker wallet address. Set on REST trade reads; WebSocket frames omit it. */
|
|
28
|
+
makerAddress?: string;
|
|
29
|
+
/** Taker wallet address. Set on REST trade reads; WebSocket frames omit it. */
|
|
30
|
+
takerAddress?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Monaco's taker fee, in raw quote-asset units (the asset's smallest unit),
|
|
33
|
+
* excluding the frontend's builder fee. Set on REST trade reads when recorded.
|
|
34
|
+
*/
|
|
35
|
+
takerFeeRaw?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Executed notional, in raw quote-asset units (the asset's smallest unit).
|
|
38
|
+
* Set on REST trade reads when recorded.
|
|
39
|
+
*/
|
|
40
|
+
quoteVolumeRaw?: string;
|
|
41
|
+
/** Application (frontend) that placed the taker order; trade volume and fees are attributed to it. REST trade reads only. */
|
|
42
|
+
takerApplicationId?: string;
|
|
21
43
|
}
|
|
22
44
|
/**
|
|
23
45
|
* Trade event emitted when a trade is executed
|
|
@@ -31,4 +53,35 @@ export interface TradeEvent {
|
|
|
31
53
|
tradingMode: TradingMode | (string & {});
|
|
32
54
|
/** Trade execution data */
|
|
33
55
|
data: TradeEventData;
|
|
56
|
+
/**
|
|
57
|
+
* The trade's position in its pair's chain: the durable-log sequence of the
|
|
58
|
+
* step that executed it. Present only when the server sources trades from
|
|
59
|
+
* market-data (`WS_TRADES_SOURCE=market_data`); absent otherwise.
|
|
60
|
+
*/
|
|
61
|
+
seq?: number;
|
|
62
|
+
/** The trade's index among its step's fills; with `seq`, the trade's key. Same presence as `seq`. */
|
|
63
|
+
matchIndex?: number;
|
|
64
|
+
/** `seq` of the previous trade on the pair; 0 when the publisher knows none. Same presence as `seq`. */
|
|
65
|
+
prevSeq?: number;
|
|
66
|
+
/** `matchIndex` of the previous trade on the pair; `null` when the publisher knows none. Same presence as `seq`. */
|
|
67
|
+
prevMatchIndex?: number | null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A sequenced trade `ws.trades` received that did not link to the last trade
|
|
71
|
+
* it delivered (or the snapshot cursor). The server forwards only linking
|
|
72
|
+
* trades, so this means a frame was lost or unreadable on the client; the
|
|
73
|
+
* trade is still delivered and the chain continues from it.
|
|
74
|
+
*/
|
|
75
|
+
export interface TradeGap {
|
|
76
|
+
tradingPairId: string;
|
|
77
|
+
/** The key of the last trade delivered, or the snapshot cursor. */
|
|
78
|
+
expected: {
|
|
79
|
+
seq: number;
|
|
80
|
+
matchIndex: number;
|
|
81
|
+
};
|
|
82
|
+
/** The received trade's link as sent; `null` where the frame carried none. */
|
|
83
|
+
received: {
|
|
84
|
+
prevSeq: number | null;
|
|
85
|
+
prevMatchIndex: number | null;
|
|
86
|
+
};
|
|
34
87
|
}
|
package/dist/websocket/index.js
CHANGED
|
@@ -51,7 +51,29 @@ import type { OrderOrigin } from "./events/orders-events";
|
|
|
51
51
|
* already holds a second subscriber's callback waits for the next reconnect;
|
|
52
52
|
* see `MonacoWebSocket` for the full rule.
|
|
53
53
|
*/
|
|
54
|
-
export type SnapshotHandler<T> = (items: T[]) => void;
|
|
54
|
+
export type SnapshotHandler<T> = (items: T[], meta?: SnapshotMeta) => void;
|
|
55
|
+
/**
|
|
56
|
+
* The trade a `trades:<pair>` snapshot is current as of: trades at or below
|
|
57
|
+
* this key, compared as `(seq, matchIndex)`, are already reflected, and the
|
|
58
|
+
* next live trade links to it exactly.
|
|
59
|
+
*/
|
|
60
|
+
export interface TradeSnapshotCursor {
|
|
61
|
+
seq: number;
|
|
62
|
+
matchIndex: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* What a `Snapshot` frame carries beside its rows. Today only the
|
|
66
|
+
* `trades:<pair>` snapshot uses it, and only when the server sources trades
|
|
67
|
+
* from market-data.
|
|
68
|
+
*/
|
|
69
|
+
export interface SnapshotMeta {
|
|
70
|
+
/**
|
|
71
|
+
* `trades:<pair>` only: the trade the live frames continue from, or `null`
|
|
72
|
+
* when nothing was applied since the server seeded the pair (the first live
|
|
73
|
+
* trade is then the base). Absent under the default engine source.
|
|
74
|
+
*/
|
|
75
|
+
cursor?: TradeSnapshotCursor | null;
|
|
76
|
+
}
|
|
55
77
|
/**
|
|
56
78
|
* One candle in an `ohlcv` channel snapshot: the live frame's candlestick
|
|
57
79
|
* without `s`.
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
* hand-written SDK surface. CI regenerates it and fails on a diff, identical to
|
|
11
11
|
* the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
|
|
12
12
|
*/
|
|
13
|
-
export declare const OPERATION_IDS: readonly ["add_follow_position_margin", "attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_conditional_order", "cancel_order", "cancel_twap_order", "check_trader_code_availability", "claim_buildercode_rewards", "claim_managed_market_lease", "clear_trader_code", "close_all_copy_positions", "close_follow_positions", "close_position", "close_sub_account", "create_challenge", "create_delegated_session", "create_order", "create_sub_account", "create_sub_account_limit", "create_twap_order", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_buildercode_payout_summary", "get_buildercode_rewards_balance", "get_buildercodes_config", "get_candles", "get_conditional_order", "get_faucet_info", "get_fee_schedule", "get_follow", "get_funding_state", "get_index_price", "get_lead_trader", "get_liquidation_metrics", "get_margin_account_movements", "get_margin_account_pnl", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_lead_trader", "get_my_referral_downline", "get_my_referral_position", "get_my_referral_tree", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_pulse", "get_region_status", "get_rewards_balance", "get_screener", "get_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_sweeper_deposit_status", "get_trade_by_id", "get_trade_flow", "get_trader_code_info", "get_trader_metrics", "get_trades", "get_trading_pair_by_id", "get_twap_order", "get_twap_order_tca", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_builder_fee_changes", "list_buildercode_payouts", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_follow_leader_positions", "list_funding_history", "list_funding_payments", "list_invite_codes", "list_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "list_liquidation_events", "list_managed_market_assignments", "list_margin_accounts", "list_my_followers", "list_my_follows", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_sweeper_deposits", "list_trading_pairs", "list_twap_order_slices", "list_twap_orders", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "request_invite_codes", "revoke_delegated_agent", "revoke_session", "set_builder_fee", "set_self_trade_prevention_default", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "stop_follow", "transfer_collateral", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_from_sub_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_collateral_to_sub_account", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "upsert_follow", "upsert_lead_trader", "verify_signature"];
|
|
13
|
+
export declare const OPERATION_IDS: readonly ["accept_rfq", "add_follow_position_margin", "attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_all_after", "cancel_conditional_order", "cancel_order", "cancel_rfq", "cancel_twap_order", "check_trader_code_availability", "claim_buildercode_rewards", "claim_managed_market_lease", "clear_trader_code", "close_all_copy_positions", "close_follow_positions", "close_position", "close_sub_account", "create_challenge", "create_delegated_session", "create_order", "create_rfq", "create_sub_account", "create_sub_account_limit", "create_twap_order", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_builder", "get_builder_series", "get_builder_totals", "get_buildercode_payout_summary", "get_buildercode_rewards_balance", "get_buildercodes_config", "get_candles", "get_conditional_order", "get_faucet_info", "get_fee_schedule", "get_follow", "get_funding_state", "get_index_price", "get_lead_trader", "get_liquidation_metrics", "get_margin_account_movements", "get_margin_account_pnl", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_lead_trader", "get_my_referral_downline", "get_my_referral_position", "get_my_referral_tree", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_protocol_series", "get_protocol_totals", "get_pulse", "get_region_status", "get_rewards_balance", "get_rfq", "get_rfq_capabilities", "get_screener", "get_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_sweeper_deposit_status", "get_token_custody", "get_trade_by_id", "get_trade_flow", "get_trader_code_info", "get_trader_metrics", "get_trades", "get_trading_pair_by_id", "get_treasury_net_fees", "get_twap_order", "get_twap_order_tca", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_wallet_summary", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_all_liquidation_events", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_builder_fee_changes", "list_builder_leaderboard", "list_buildercode_payouts", "list_builders", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_follow_leader_positions", "list_funding_history", "list_funding_payments", "list_insurance_funds", "list_invite_codes", "list_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "list_liquidation_events", "list_managed_market_assignments", "list_margin_accounts", "list_market_volumes", "list_my_followers", "list_my_follows", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_sweeper_deposits", "list_token_custody", "list_trades", "list_trading_pairs", "list_twap_order_slices", "list_twap_orders", "list_vault_deposits", "list_vault_withdrawals", "list_wallet_leaderboard", "list_wallet_liquidations", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "request_invite_codes", "respond_rfq_last_look", "revoke_delegated_agent", "revoke_session", "set_builder_fee", "set_self_trade_prevention_default", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "stop_follow", "transfer_collateral", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_from_sub_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_collateral_to_sub_account", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "upsert_follow", "upsert_lead_trader", "upsert_rfq_quote", "verify_signature", "withdraw_rfq_quote"];
|
|
14
14
|
/** Union of every OpenAPI operationId in the spec. */
|
|
15
15
|
export type OperationId = (typeof OPERATION_IDS)[number];
|