@0xmonaco/types 1.1.5 → 1.1.7

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.
Files changed (42) hide show
  1. package/README.md +1 -3
  2. package/dist/analytics/builders.d.ts +135 -0
  3. package/dist/analytics/builders.js +11 -0
  4. package/dist/analytics/index.d.ts +153 -0
  5. package/dist/analytics/index.js +27 -0
  6. package/dist/analytics/wallets.d.ts +205 -0
  7. package/dist/analytics/wallets.js +16 -0
  8. package/dist/applications/requests.d.ts +5 -5
  9. package/dist/buildercodes/index.d.ts +13 -11
  10. package/dist/buildercodes/responses.d.ts +1 -0
  11. package/dist/buildercodes/responses.js +10 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +1 -0
  14. package/dist/margin-accounts/index.d.ts +7 -2
  15. package/dist/market/index.d.ts +19 -20
  16. package/dist/profile/index.d.ts +10 -17
  17. package/dist/rfq/responses.d.ts +145 -0
  18. package/dist/rfq/responses.js +102 -0
  19. package/dist/sdk/index.d.ts +4 -1
  20. package/dist/trading/index.d.ts +7 -3
  21. package/dist/trading/orders.d.ts +11 -0
  22. package/dist/trading/responses.d.ts +9 -3
  23. package/dist/validation/margin-accounts.d.ts +2 -2
  24. package/dist/validation/margin-accounts.js +5 -5
  25. package/dist/validation/trading.d.ts +15 -0
  26. package/dist/validation/trading.js +34 -42
  27. package/dist/websocket/base.d.ts +40 -10
  28. package/dist/websocket/client.d.ts +32 -4
  29. package/dist/websocket/depth.d.ts +142 -0
  30. package/dist/websocket/depth.js +13 -0
  31. package/dist/websocket/events/market-stats-events.d.ts +19 -0
  32. package/dist/websocket/events/orderbook-events.d.ts +41 -1
  33. package/dist/websocket/events/position-events.d.ts +3 -2
  34. package/dist/websocket/events/rfq-events.d.ts +51 -1
  35. package/dist/websocket/events/trade-events.d.ts +37 -0
  36. package/dist/websocket/index.d.ts +1 -0
  37. package/dist/websocket/index.js +1 -0
  38. package/dist/websocket/snapshots.d.ts +23 -1
  39. package/dist/wire/operations.d.ts +1 -1
  40. package/dist/wire/operations.js +16 -0
  41. package/dist/wire/schema.d.ts +2485 -308
  42. package/package.json +2 -2
@@ -101,8 +101,9 @@ export interface PositionEventData {
101
101
  /**
102
102
  * Initial margin this position requires at `markPrice` (decimal string),
103
103
  * honoring both its effective leverage and the market initial-margin floor —
104
- * the same `initialMarginRequired` REST returns (0XM-2668). `"0"` when the
105
- * position has no open exposure.
104
+ * the same `initialMarginRequired` REST returns (0XM-2668). Each unit keeps
105
+ * the leverage of the order that opened it. `"0"` when the position has no
106
+ * open exposure.
106
107
  *
107
108
  * UNVERSIONED, for the same reason as `maintenanceMarginRequired`.
108
109
  */
@@ -42,9 +42,33 @@ export interface RfqRequestedEvent {
42
42
  }
43
43
  /** One side of the taker's view: the allocation that would fill the quantity. */
44
44
  export interface RfqSideViewEventData {
45
- /** All-in volume-weighted price, the taker's fee included. */
45
+ /** All-in volume-weighted price, the taker's Monaco and builder fees included. */
46
46
  vwap: string;
47
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 requested size on the public order book, for comparison. Display
58
+ * only; absent when a fresh book snapshot cannot fill the whole size.
59
+ */
60
+ book?: RfqBookComparisonEventData;
61
+ }
62
+ /** The taker's requested size priced against the public order book, with the view's fee rates. */
63
+ export interface RfqBookComparisonEventData {
64
+ /** All-in book VWAP: the cost per unit when buying, the net proceeds per unit when selling. */
65
+ vwap: string;
66
+ /** The book VWAP before fees. */
67
+ grossVwap: string;
68
+ /** When the book snapshot was read, Unix milliseconds. */
69
+ asOfMs: number;
70
+ /** Price levels the size walked. */
71
+ levels: number;
48
72
  }
49
73
  /** The taker's view of the quotes. No maker identity or individual quote. */
50
74
  export interface RfqViewEventData {
@@ -57,6 +81,10 @@ export interface RfqViewEventData {
57
81
  asOfMs: number;
58
82
  /** Pushes can arrive out of order: keep the view with the highest `sequence`. */
59
83
  sequence: number;
84
+ /** Your Monaco taker fee rate in this view, in centi-bps. */
85
+ monacoFeeCbps?: number;
86
+ /** Your frontend's builder fee rate in this view, in centi-bps; frozen when you accept. */
87
+ builderFeeCbps?: number;
60
88
  }
61
89
  /** To the taker: its view moved. */
62
90
  export interface RfqViewEvent {
@@ -82,6 +110,18 @@ export interface RfqSelectionEventData {
82
110
  makerFeeCbps: number;
83
111
  /** Reject or improve before this time; silence executes. */
84
112
  lastLookDeadlineAtMs: number;
113
+ /**
114
+ * The MOST your frontend's builder add-on charges on this fill, in centi-bps:
115
+ * the rate stored on your quote order. A fill charges it or nothing, never
116
+ * more; the receipt shows what was charged. Absent when it could not be read.
117
+ */
118
+ maxBuilderFeeCbps?: number;
119
+ /**
120
+ * Estimated net at `quantity` and `price`, in the quote asset, at
121
+ * `makerFeeCbps` plus `maxBuilderFeeCbps`: the least you receive when
122
+ * selling, the most you pay when buying. Absent with `maxBuilderFeeCbps`.
123
+ */
124
+ estimatedNet?: string;
85
125
  }
86
126
  /** To one selected maker: its last-look prompt. */
87
127
  export interface RfqSelectedEvent {
@@ -94,7 +134,12 @@ export interface RfqFillEventData {
94
134
  executionId: string;
95
135
  price: string;
96
136
  quantity: string;
137
+ /** Your whole taker fee on this fill: `monacoFee` plus `builderFee`. */
97
138
  fee: string;
139
+ /** The Monaco part of `fee`. */
140
+ monacoFee?: string;
141
+ /** The builder part of `fee`. */
142
+ builderFee?: string;
98
143
  }
99
144
  /** How an RFQ ended, for its taker. */
100
145
  export interface RfqOutcomeEventData {
@@ -103,6 +148,11 @@ export interface RfqOutcomeEventData {
103
148
  /** Gross VWAP of the fills; absent when nothing filled. */
104
149
  vwap?: string;
105
150
  fills: RfqFillEventData[];
151
+ /**
152
+ * Your all-in VWAP: notional plus your whole fee for a buy, minus it for a
153
+ * sell, over the executed quantity. Absent when nothing filled.
154
+ */
155
+ allInVwap?: string;
106
156
  }
107
157
  /** To the taker and every maker that quoted: the RFQ ended. */
108
158
  export interface RfqOutcomeEvent {
@@ -40,6 +40,12 @@ export interface TradeEventData {
40
40
  quoteVolumeRaw?: string;
41
41
  /** Application (frontend) that placed the taker order; trade volume and fees are attributed to it. REST trade reads only. */
42
42
  takerApplicationId?: string;
43
+ /**
44
+ * The taker's builder fee: the add-on the taker's application charged, in
45
+ * raw quote-asset units, on top of `takerFeeRaw`; `"0"` when it charged
46
+ * none. REST trade reads only.
47
+ */
48
+ builderFeeRaw?: string;
43
49
  }
44
50
  /**
45
51
  * Trade event emitted when a trade is executed
@@ -53,4 +59,35 @@ export interface TradeEvent {
53
59
  tradingMode: TradingMode | (string & {});
54
60
  /** Trade execution data */
55
61
  data: TradeEventData;
62
+ /**
63
+ * The trade's position in its pair's chain: the durable-log sequence of the
64
+ * step that executed it. Present only when the server sources trades from
65
+ * market-data (`WS_TRADES_SOURCE=market_data`); absent otherwise.
66
+ */
67
+ seq?: number;
68
+ /** The trade's index among its step's fills; with `seq`, the trade's key. Same presence as `seq`. */
69
+ matchIndex?: number;
70
+ /** `seq` of the previous trade on the pair; 0 when the publisher knows none. Same presence as `seq`. */
71
+ prevSeq?: number;
72
+ /** `matchIndex` of the previous trade on the pair; `null` when the publisher knows none. Same presence as `seq`. */
73
+ prevMatchIndex?: number | null;
74
+ }
75
+ /**
76
+ * A sequenced trade `ws.trades` received that did not link to the last trade
77
+ * it delivered (or the snapshot cursor). The server forwards only linking
78
+ * trades, so this means a frame was lost or unreadable on the client; the
79
+ * trade is still delivered and the chain continues from it.
80
+ */
81
+ export interface TradeGap {
82
+ tradingPairId: string;
83
+ /** The key of the last trade delivered, or the snapshot cursor. */
84
+ expected: {
85
+ seq: number;
86
+ matchIndex: number;
87
+ };
88
+ /** The received trade's link as sent; `null` where the frame carried none. */
89
+ received: {
90
+ prevSeq: number | null;
91
+ prevMatchIndex: number | null;
92
+ };
56
93
  }
@@ -6,5 +6,6 @@
6
6
  export * from "./base";
7
7
  export * from "./client";
8
8
  export * from "./clients/orderbook-client";
9
+ export * from "./depth";
9
10
  export * from "./events";
10
11
  export * from "./snapshots";
@@ -6,5 +6,6 @@
6
6
  export * from "./base";
7
7
  export * from "./client";
8
8
  export * from "./clients/orderbook-client";
9
+ export * from "./depth";
9
10
  export * from "./events";
10
11
  export * from "./snapshots";
@@ -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 ["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_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_rfq", "get_rfq_capabilities", "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_all_liquidation_events", "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_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_my_followers", "list_my_follows", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_sweeper_deposits", "list_trades", "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", "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"];
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];
@@ -44,6 +44,9 @@ export const OPERATION_IDS = [
44
44
  "get_application_config",
45
45
  "get_application_stats",
46
46
  "get_available_collateral",
47
+ "get_builder",
48
+ "get_builder_series",
49
+ "get_builder_totals",
47
50
  "get_buildercode_payout_summary",
48
51
  "get_buildercode_rewards_balance",
49
52
  "get_buildercodes_config",
@@ -86,6 +89,8 @@ export const OPERATION_IDS = [
86
89
  "get_position",
87
90
  "get_position_pnl_history",
88
91
  "get_position_risk",
92
+ "get_protocol_series",
93
+ "get_protocol_totals",
89
94
  "get_pulse",
90
95
  "get_region_status",
91
96
  "get_rewards_balance",
@@ -96,12 +101,14 @@ export const OPERATION_IDS = [
96
101
  "get_sub_account_limits",
97
102
  "get_sweeper_chains",
98
103
  "get_sweeper_deposit_status",
104
+ "get_token_custody",
99
105
  "get_trade_by_id",
100
106
  "get_trade_flow",
101
107
  "get_trader_code_info",
102
108
  "get_trader_metrics",
103
109
  "get_trades",
104
110
  "get_trading_pair_by_id",
111
+ "get_treasury_net_fees",
105
112
  "get_twap_order",
106
113
  "get_twap_order_tca",
107
114
  "get_user_balance_by_asset",
@@ -109,6 +116,7 @@ export const OPERATION_IDS = [
109
116
  "get_user_movements",
110
117
  "get_user_profile",
111
118
  "get_user_trades",
119
+ "get_wallet_summary",
112
120
  "get_withdrawal",
113
121
  "health_check",
114
122
  "initiate_withdrawal",
@@ -119,7 +127,9 @@ export const OPERATION_IDS = [
119
127
  "list_application_orders",
120
128
  "list_application_users",
121
129
  "list_builder_fee_changes",
130
+ "list_builder_leaderboard",
122
131
  "list_buildercode_payouts",
132
+ "list_builders",
123
133
  "list_conditional_orders",
124
134
  "list_delegated_agent_owners",
125
135
  "list_delegated_agents",
@@ -134,6 +144,7 @@ export const OPERATION_IDS = [
134
144
  "list_liquidation_events",
135
145
  "list_managed_market_assignments",
136
146
  "list_margin_accounts",
147
+ "list_market_volumes",
137
148
  "list_my_followers",
138
149
  "list_my_follows",
139
150
  "list_pending_withdrawals",
@@ -141,10 +152,15 @@ export const OPERATION_IDS = [
141
152
  "list_positions",
142
153
  "list_sub_accounts_with_balances",
143
154
  "list_sweeper_deposits",
155
+ "list_token_custody",
144
156
  "list_trades",
145
157
  "list_trading_pairs",
146
158
  "list_twap_order_slices",
147
159
  "list_twap_orders",
160
+ "list_vault_deposits",
161
+ "list_vault_withdrawals",
162
+ "list_wallet_leaderboard",
163
+ "list_wallet_liquidations",
148
164
  "mint_tokens",
149
165
  "preview_follow",
150
166
  "refresh_managed_market_quotes",