@0xmonaco/types 1.0.74 → 1.0.75

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 (43) hide show
  1. package/dist/api/index.d.ts +0 -7
  2. package/dist/applications/index.d.ts +14 -15
  3. package/dist/applications/index.js +2 -2
  4. package/dist/applications/requests.d.ts +70 -15
  5. package/dist/applications/requests.js +2 -3
  6. package/dist/applications/responses.d.ts +35 -39
  7. package/dist/applications/responses.js +1 -1
  8. package/dist/fees/responses.js +2 -2
  9. package/dist/margin-accounts/index.d.ts +72 -12
  10. package/dist/market/index.d.ts +76 -6
  11. package/dist/pitpass/index.d.ts +16 -11
  12. package/dist/pitpass/index.js +1 -1
  13. package/dist/pitpass/responses.d.ts +21 -0
  14. package/dist/pitpass/responses.js +43 -14
  15. package/dist/positions/index.d.ts +81 -14
  16. package/dist/profile/index.d.ts +114 -44
  17. package/dist/trading/index.d.ts +1 -1
  18. package/dist/trading/orders.d.ts +6 -32
  19. package/dist/trading/responses.d.ts +9 -14
  20. package/dist/validation/applications.d.ts +51 -0
  21. package/dist/validation/applications.js +45 -0
  22. package/dist/validation/index.d.ts +1 -0
  23. package/dist/validation/index.js +1 -0
  24. package/dist/validation/margin-accounts.d.ts +10 -3
  25. package/dist/validation/margin-accounts.js +17 -6
  26. package/dist/validation/market.d.ts +24 -0
  27. package/dist/validation/market.js +22 -0
  28. package/dist/validation/positions.d.ts +5 -3
  29. package/dist/validation/positions.js +12 -5
  30. package/dist/validation/profile.d.ts +19 -2
  31. package/dist/validation/profile.js +36 -4
  32. package/dist/validation/trading.d.ts +2 -2
  33. package/dist/websocket/base.d.ts +56 -6
  34. package/dist/websocket/client.d.ts +8 -3
  35. package/dist/websocket/events/index.d.ts +1 -0
  36. package/dist/websocket/events/index.js +1 -0
  37. package/dist/websocket/events/position-events.d.ts +15 -0
  38. package/dist/websocket/events/position-valuation-events.d.ts +60 -0
  39. package/dist/websocket/events/position-valuation-events.js +15 -0
  40. package/dist/wire/operations.d.ts +1 -1
  41. package/dist/wire/operations.js +2 -0
  42. package/dist/wire/schema.d.ts +748 -235
  43. package/package.json +2 -2
@@ -52,7 +52,7 @@ import type { Interval } from "../market";
52
52
  import type { TradingMode } from "../trading";
53
53
  import type { WebSocketStatus } from "./base";
54
54
  import type { OrderbookQuotationMode } from "./clients/orderbook-client";
55
- import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, TradeEvent, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
55
+ import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, PositionValuationEvent, TradeEvent, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
56
56
  import type { OrderSnapshotItem, SnapshotHandler } from "./snapshots";
57
57
  export type MessageHandler<T> = (data: T) => void;
58
58
  export interface MonacoWebSocket {
@@ -84,8 +84,13 @@ export interface MonacoWebSocket {
84
84
  conditionalOrders: (handler: MessageHandler<ConditionalOrderEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<ConditionalOrderEventData>) => () => void;
85
85
  /** Subscribe to TWAP parent-order lifecycle events (requires authentication) */
86
86
  twapOrders: (handler: MessageHandler<TwapOrderEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<TwapOrderEventData>) => () => void;
87
- /** Subscribe to position state updates (requires authentication); omit `tradingPairId` for all pairs. `onSnapshot` receives every open position */
88
- positions: (handler: MessageHandler<PositionEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<PositionEventData>) => () => void;
87
+ /**
88
+ * Subscribe to position state updates (requires authentication); omit `tradingPairId` for all pairs. `onSnapshot` receives every open position.
89
+ *
90
+ * `handler` receives lifecycle `position_update` frames only. `onValuation`, when given, receives the periodic `position_valuation`
91
+ * frames carried on the same channel; without it they are ignored. Apply a valuation only to a position already held as `OPEN`.
92
+ */
93
+ positions: (handler: MessageHandler<PositionEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<PositionEventData>, onValuation?: MessageHandler<PositionValuationEvent>) => () => void;
89
94
  /** Subscribe to liquidation alerts (requires authentication); omit `tradingPairId` for all pairs */
90
95
  liquidations: (handler: MessageHandler<LiquidationEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<LiquidationEventData>) => () => void;
91
96
  /** Subscribe to account-level margin health updates for the authenticated user (requires authentication) */
@@ -10,5 +10,6 @@ export * from "./ohlcv-events";
10
10
  export * from "./orderbook-events";
11
11
  export * from "./orders-events";
12
12
  export * from "./position-events";
13
+ export * from "./position-valuation-events";
13
14
  export * from "./trade-events";
14
15
  export * from "./twap-order-events";
@@ -10,5 +10,6 @@ export * from "./ohlcv-events";
10
10
  export * from "./orderbook-events";
11
11
  export * from "./orders-events";
12
12
  export * from "./position-events";
13
+ export * from "./position-valuation-events";
13
14
  export * from "./trade-events";
14
15
  export * from "./twap-order-events";
@@ -141,6 +141,21 @@ export interface PositionEventData {
141
141
  * that window, and the frame is the fresher one.
142
142
  */
143
143
  updatedAt: string;
144
+ /**
145
+ * When the position OPENED (ISO 8601): the fill that took its exposure from
146
+ * zero to non-zero. It never changes for the life of `positionId`, so time
147
+ * held is now minus `openedAt` while open, and `updatedAt` minus `openedAt`
148
+ * on a terminal frame. A flip closes the position and opens a new one with
149
+ * a new `positionId` and its own `openedAt`.
150
+ *
151
+ * Absent when the server does not know it — never filled with the time the
152
+ * frame was sent. A REST read of the same position reports the same
153
+ * instant, normally to within one matching-engine step; after a server
154
+ * restart it can move by the server's own clock drift. Clamp a computed time
155
+ * held at zero. Not versioned: take it from the newest payload (frame or
156
+ * REST read) rather than skipping it on an equal `version`.
157
+ */
158
+ openedAt?: string;
144
159
  /**
145
160
  * Opaque, non-negative producer-owned row version for this position
146
161
  * (0XM-2673). Compare only within the same `positionId`; higher is newer.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Position Valuation WebSocket Event Types
3
+ *
4
+ * Periodic mark-derived valuation of one OPEN position, delivered on the same
5
+ * authenticated `positions` / `positions:<tradingPairId>` channel as lifecycle
6
+ * `position_update` frames, with `eventType: "position_valuation"`.
7
+ *
8
+ * Valuation data only: it carries no size, side, status or version, and never
9
+ * creates, reopens, closes or resizes a position. Apply it only to a position
10
+ * you already hold as `OPEN` whose `updatedAt` is earlier than the frame's
11
+ * `valuedAt`, and ignore it otherwise: valuations are spread over each
12
+ * interval, so one can arrive after a newer `position_update` (a fill, a close,
13
+ * a funding settlement) for the same position. `@0xmonaco/core` delivers these to the `onValuation` callback of
14
+ * `positions(...)`, never to its lifecycle handler.
15
+ */
16
+ /**
17
+ * The five mark-derived figures of one open position, from the same
18
+ * derivation as a lifecycle frame's figures for that position.
19
+ */
20
+ export interface PositionValuationEventData {
21
+ /** Position identifier (UUID) */
22
+ positionId: string;
23
+ /** Margin account that owns the position (UUID) */
24
+ marginAccountId: string;
25
+ /** Trading pair identifier (UUID) */
26
+ tradingPairId: string;
27
+ /** Current mark price (decimal string) */
28
+ markPrice: string;
29
+ /** Unrealized PnL at the mark price (decimal string) */
30
+ unrealizedPnl: string;
31
+ /**
32
+ * Liquidation price (decimal string), or `null` when the server cannot
33
+ * derive one for this position (for example an isolated risk bucket shared
34
+ * by several positions, or one whose collateral basis is not positive).
35
+ */
36
+ liquidationPrice: string | null;
37
+ /** Initial margin this position requires at the mark price (decimal string) */
38
+ initialMarginRequired: string;
39
+ /** Maintenance margin this position requires at the mark price (decimal string) */
40
+ maintenanceMarginRequired: string;
41
+ /**
42
+ * When the server read the position (RFC 3339). Not the oracle publish time
43
+ * and not the position's last mutation (`updatedAt` on lifecycle frames),
44
+ * but on the same server clock as `updatedAt`: a valuation whose `valuedAt`
45
+ * is not later than the held position's `updatedAt` was read before that
46
+ * state and is stale.
47
+ */
48
+ valuedAt: string;
49
+ }
50
+ /**
51
+ * Periodic valuation frame for one open position.
52
+ */
53
+ export interface PositionValuationEvent {
54
+ /** Event type identifier */
55
+ eventType: "position_valuation";
56
+ /** User ID (UUID) */
57
+ userId: string;
58
+ /** Valuation data */
59
+ data: PositionValuationEventData;
60
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Position Valuation WebSocket Event Types
3
+ *
4
+ * Periodic mark-derived valuation of one OPEN position, delivered on the same
5
+ * authenticated `positions` / `positions:<tradingPairId>` channel as lifecycle
6
+ * `position_update` frames, with `eventType: "position_valuation"`.
7
+ *
8
+ * Valuation data only: it carries no size, side, status or version, and never
9
+ * creates, reopens, closes or resizes a position. Apply it only to a position
10
+ * you already hold as `OPEN` whose `updatedAt` is earlier than the frame's
11
+ * `valuedAt`, and ignore it otherwise: valuations are spread over each
12
+ * interval, so one can arrive after a newer `position_update` (a fill, a close,
13
+ * a funding settlement) for the same position. `@0xmonaco/core` delivers these to the `onValuation` callback of
14
+ * `positions(...)`, never to its lifecycle handler.
15
+ */
@@ -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_follow", "get_funding_state", "get_index_price", "get_lead_trader", "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_rewards_balance", "get_screener", "get_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_trade_by_id", "get_trader_code_info", "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_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "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_trading_pairs", "list_twap_orders", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "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", "submit_whitelist", "transfer_collateral", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "upsert_follow", "upsert_lead_trader", "verify_signature"];
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_follow", "get_funding_state", "get_index_price", "get_lead_trader", "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_rewards_balance", "get_screener", "get_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_trade_by_id", "get_trader_code_info", "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_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "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_trading_pairs", "list_twap_orders", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "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", "submit_whitelist", "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"];
14
14
  /** Union of every OpenAPI operationId in the spec. */
15
15
  export type OperationId = (typeof OPERATION_IDS)[number];
@@ -146,9 +146,11 @@ export const OPERATION_IDS = [
146
146
  "transfer_collateral",
147
147
  "transfer_collateral_from_margin_account",
148
148
  "transfer_collateral_from_parent_margin_account",
149
+ "transfer_collateral_from_sub_account",
149
150
  "transfer_collateral_to_margin_account",
150
151
  "transfer_collateral_to_parent_margin_account",
151
152
  "transfer_collateral_to_risk_bucket",
153
+ "transfer_collateral_to_sub_account",
152
154
  "transfer_rewards",
153
155
  "update_sub_account_limit",
154
156
  "upsert_delegated_agent",