@0xmonaco/types 1.0.25 → 1.0.26-develop.aeb6d5b

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.
@@ -47,6 +47,51 @@ export interface MintTokensResponse {
47
47
  /** Remaining faucet requests in the next 24h */
48
48
  remainingRequests24h: number;
49
49
  }
50
+ /** One token minted by a past faucet request. */
51
+ export interface FaucetMintRecord {
52
+ /** Asset UUID */
53
+ assetId: string;
54
+ /** Token symbol */
55
+ symbol: string;
56
+ /** Amount minted in token units */
57
+ amount: string;
58
+ /**
59
+ * On-chain transaction hash; absent when the transaction was submitted but
60
+ * never confirmed
61
+ */
62
+ txHash?: string;
63
+ }
64
+ /**
65
+ * Past faucet mints grouped by clock minute for display. A group can span
66
+ * several endpoint calls made in the same minute; the daily quota counts
67
+ * each call individually.
68
+ */
69
+ export interface FaucetRequestRecord {
70
+ /**
71
+ * Timestamp (ISO 8601) of the request, truncated to the minute (display
72
+ * grouping; the daily quota counts every call)
73
+ */
74
+ requestedAt: string;
75
+ /** Tokens minted in the group, oldest first */
76
+ minted: FaucetMintRecord[];
77
+ }
78
+ /** Result of a faucet info request. */
79
+ export interface GetFaucetInfoResponse {
80
+ /** Remaining faucet requests in the rolling 24h window */
81
+ remainingRequests24h: number;
82
+ /** Maximum faucet requests per rolling 24h window */
83
+ dailyLimit: number;
84
+ /**
85
+ * Timestamp (ISO 8601) safe to retry at or after: when the wallet's next
86
+ * faucet slot frees under the current daily limit, with a small safety
87
+ * margin. When remainingRequests24h is 0 this is when the next mint
88
+ * becomes possible. Absent when no requests are in the rolling 24h window
89
+ * or when the daily limit is 0. Not a calendar-day reset.
90
+ */
91
+ nextAvailableAt?: string;
92
+ /** Up to 5 most recent faucet requests, newest first */
93
+ recentRequests: FaucetRequestRecord[];
94
+ }
50
95
  /**
51
96
  * Faucet API interface. Session-authenticated.
52
97
  */
@@ -68,4 +113,14 @@ export interface FaucetAPI extends BaseAPI {
68
113
  * @returns Promise resolving to the minted tokens and remaining quota
69
114
  */
70
115
  mint(params: MintTokensParams): Promise<MintTokensResponse>;
116
+ /**
117
+ * Fetches the authenticated wallet's faucet quota and recent requests.
118
+ *
119
+ * Read-only: remaining requests in the rolling 24h window, when the next
120
+ * request becomes available, and the 5 most recent requests. Wallet-scoped
121
+ * across apps, matching mint enforcement.
122
+ *
123
+ * @returns Promise resolving to the quota and recent-request history
124
+ */
125
+ getInfo(): Promise<GetFaucetInfoResponse>;
71
126
  }
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from "./pitpass";
17
17
  export * from "./portfolio";
18
18
  export * from "./positions";
19
19
  export * from "./profile";
20
+ export * from "./pulse";
20
21
  export * from "./sdk";
21
22
  export * from "./sub-accounts";
22
23
  export * from "./trading";
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export * from "./pitpass";
18
18
  export * from "./portfolio";
19
19
  export * from "./positions";
20
20
  export * from "./profile";
21
+ export * from "./pulse";
21
22
  export * from "./sdk";
22
23
  export * from "./sub-accounts";
23
24
  export * from "./trading";
@@ -114,11 +114,13 @@ export interface GetMarginAccountMovementsResponse {
114
114
  export interface SimulateOrderRiskRequest {
115
115
  tradingPairId: string;
116
116
  side: OrderSide;
117
- positionSide: PositionSide;
117
+ /** @deprecated `side` is authoritative; when present BUY=LONG and SELL=SHORT. */
118
+ positionSide?: PositionSide;
118
119
  orderType: OrderType;
119
120
  price?: string;
120
121
  quantity: string;
121
- leverage: string;
122
+ /** Required for normal orders; optional and ignored for reduce-only. */
123
+ leverage?: string;
122
124
  reduceOnly?: boolean;
123
125
  }
124
126
  export type SimulateIsolatedRiskBucketOrderRiskRequest = SimulateOrderRiskRequest & {
@@ -213,6 +213,17 @@ export interface ScreenerItem {
213
213
  totalQuoteVolumeLtd: string;
214
214
  /** Life-to-date cumulative number of trades since inception (0 if no trades yet) */
215
215
  totalTradeCountLtd: number;
216
+ /**
217
+ * Latest settled funding rate as a decimal fraction per funding window (the
218
+ * capped settled value); null for spot pairs and margin pairs with no
219
+ * settled funding window yet
220
+ */
221
+ latestFundingRate: string | null;
222
+ /**
223
+ * Close time of the latest settled funding window (ms since epoch, as string);
224
+ * null for spot pairs and margin pairs with no settled funding window yet
225
+ */
226
+ lastFundingTime: string | null;
216
227
  }
217
228
  /**
218
229
  * Paginated screener response, sorted by quoteVolume24h desc (nulls last)
@@ -273,11 +284,12 @@ export interface MarketStats {
273
284
  totalTradeCountLtd: number;
274
285
  }
275
286
  export interface RiskTier {
276
- notional_floor: string;
277
- notional_cap?: string;
278
287
  initialMarginRatio: string;
279
288
  maintenanceMarginRatio: string;
280
- maxLeverage: string;
289
+ /** Maximum authoritative absolute base-asset quantity. */
290
+ maxPositionSize?: string;
291
+ /** @deprecated This legacy alias is base quantity, not notional. */
292
+ maxPositionNotional?: string;
281
293
  }
282
294
  export interface PerpMarketConfig {
283
295
  tradingPairId: string;
@@ -343,12 +355,16 @@ export interface FundingRecord {
343
355
  tradingPairId: string;
344
356
  fundingRate: string;
345
357
  cumulativeFundingPerUnit?: string;
358
+ /** True when the window settled at the carried last rate (sparse-sample rule). */
359
+ carried?: boolean;
346
360
  }
347
361
  export interface ListFundingHistoryParams {
348
362
  startTime?: string;
349
363
  endTime?: string;
350
364
  page?: number;
351
365
  pageSize?: number;
366
+ /** Sort direction for epoch: "ASC" or "DESC" (default DESC). */
367
+ orderBy?: "ASC" | "DESC";
352
368
  }
353
369
  export interface ListFundingHistoryResponse {
354
370
  records: FundingRecord[];
@@ -356,6 +372,20 @@ export interface ListFundingHistoryResponse {
356
372
  page: number;
357
373
  pageSize: number;
358
374
  }
375
+ export interface ListAllFundingHistoryParams {
376
+ startTime?: string;
377
+ endTime?: string;
378
+ page?: number;
379
+ pageSize?: number;
380
+ /** Sort direction for settledAt (default DESC). */
381
+ orderBy?: "ASC" | "DESC";
382
+ }
383
+ export interface ListAllFundingHistoryResponse {
384
+ records: FundingRecord[];
385
+ total: number;
386
+ page: number;
387
+ pageSize: number;
388
+ }
359
389
  export interface OpenInterest {
360
390
  tradingPairId: string;
361
391
  openInterest?: string;
@@ -430,5 +460,14 @@ export interface MarketAPI extends BaseAPI {
430
460
  getIndexPrice(tradingPairId: string): Promise<IndexPrice>;
431
461
  getFundingState(tradingPairId: string): Promise<FundingState>;
432
462
  listFundingHistory(tradingPairId: string, params?: ListFundingHistoryParams): Promise<ListFundingHistoryResponse>;
463
+ /**
464
+ * Fetch settled funding history across every market in one call, so clients
465
+ * don't have to fan out one listFundingHistory request per trading pair.
466
+ * Each record carries its tradingPairId; sorted by settledAt (default DESC).
467
+ * @param params - Optional time bounds (ms-epoch strings, inclusive on
468
+ * settledAt), pagination, and orderBy (ASC or DESC)
469
+ * @returns Promise resolving to the paginated all-markets funding history
470
+ */
471
+ listAllFundingHistory(params?: ListAllFundingHistoryParams): Promise<ListAllFundingHistoryResponse>;
433
472
  getOpenInterest(tradingPairId: string): Promise<OpenInterest>;
434
473
  }
@@ -77,10 +77,17 @@ export interface PortfolioRealizedTotals {
77
77
  netRealizedPnl: string;
78
78
  }
79
79
  export interface PortfolioClosedTradeStats {
80
+ /** Fill-based: closing fills in the window (partial fills each counted). */
80
81
  count: number;
82
+ /**
83
+ * Position-level: each position (one flat -> open -> flat round-trip) is
84
+ * classified once by its net realized PnL after all fees.
85
+ */
81
86
  winners: number;
82
87
  losers: number;
83
88
  breakEven: number;
89
+ /** Total classified positions (= winners + losers + breakEven). */
90
+ positions: number;
84
91
  winRatePct?: string;
85
92
  }
86
93
  export interface PortfolioBestDay {
@@ -10,12 +10,23 @@ export interface Position {
10
10
  marginMode?: MarginMode;
11
11
  tradingPairId: string;
12
12
  side: PositionSide;
13
+ /**
14
+ * Open rows: current absolute position quantity. Terminal rows
15
+ * (CLOSED/LIQUIDATED/EXPIRED): total quantity closed over the position's
16
+ * life, summed from its reducing executions when available.
17
+ */
13
18
  size: string;
14
19
  entryPrice: string;
15
20
  markPrice: string;
16
21
  indexPrice?: string;
17
22
  unrealizedPnl: string;
18
23
  realizedPnl: string;
24
+ /**
25
+ * Open rows: current isolated collateral for this position's risk bucket.
26
+ * Terminal rows: total initial margin allocated across the position's
27
+ * reducing executions when available — the margin basis for lifetime
28
+ * realized return.
29
+ */
19
30
  isolatedMargin: string;
20
31
  leverage?: string;
21
32
  /**
@@ -39,6 +50,16 @@ export interface Position {
39
50
  liquidationPrice: string;
40
51
  status: PositionStatus;
41
52
  updatedAt: string;
53
+ /**
54
+ * Lifetime realized PnL net of trading fees and funding. Terminal rows
55
+ * only; absent when the position's reducing executions are unavailable.
56
+ */
57
+ netRealizedPnl?: string;
58
+ /**
59
+ * Lifetime realized return on the total allocated initial margin, as a
60
+ * percentage. Terminal rows only; absent when unavailable.
61
+ */
62
+ realizedRoe?: string;
42
63
  }
43
64
  export interface ListPositionsParams {
44
65
  marginAccountId?: string;
@@ -133,6 +154,8 @@ export interface TpSlLeg {
133
154
  orderType: OrderType;
134
155
  limitPrice?: string;
135
156
  quantity?: string;
157
+ /** Resolve the full live position size when triggered. */
158
+ closePosition?: boolean;
136
159
  timeInForce?: Extract<TimeInForce, "GTC" | "IOC">;
137
160
  slippageToleranceBps?: number;
138
161
  expiresAt?: string;
@@ -140,6 +163,8 @@ export interface TpSlLeg {
140
163
  export interface AttachPositionTpSlRequest {
141
164
  takeProfit?: TpSlLeg;
142
165
  stopLoss?: TpSlLeg;
166
+ /** Cancel the sibling after one leg triggers. Requires both legs. */
167
+ oco?: boolean;
143
168
  }
144
169
  export interface AttachPositionTpSlResponse {
145
170
  positionId: string;
@@ -237,6 +237,23 @@ export interface GetUserTradesParams {
237
237
  pageSize?: number;
238
238
  /** Filter by trading pair ID (UUID) */
239
239
  tradingPairId?: string;
240
+ /**
241
+ * Pagination cursor with three distinct states:
242
+ * - Omitted (`undefined`): legacy page-number pagination via `page`,
243
+ * limited to recent history once the archive window is enabled.
244
+ * - Empty string (`""`): start a cursor walk with no prior position, from
245
+ * the newest row (this endpoint always sorts newest-first).
246
+ * - Non-empty: an opaque cursor from a previous response's
247
+ * `nextPageToken`; results resume immediately after that position.
248
+ *
249
+ * In either cursor-walk state (empty or non-empty), `page` is ignored, the
250
+ * response omits exact totals (`total`/`totalPages`/`page` are 0), and
251
+ * results cover full trade history — hot and archived rows merged —
252
+ * unlike page-number mode, which only ever sees recent history. Clients
253
+ * that need complete trade history must use the cursor form (pass `""` to
254
+ * start, then follow `nextPageToken`) rather than `page`.
255
+ */
256
+ pageToken?: string;
240
257
  }
241
258
  /**
242
259
  * Response from getting user trades
@@ -252,6 +269,21 @@ export interface GetUserTradesResponse {
252
269
  total: number;
253
270
  /** Total number of pages */
254
271
  totalPages: number;
272
+ /**
273
+ * Cursor for the next page. Empty on every page-number (legacy) response —
274
+ * page-number mode never mints a token, full page or not, since resuming
275
+ * from a legacy-minted position could silently strand archived history
276
+ * newer than wherever that page happened to end.
277
+ *
278
+ * To walk full history, start a cursor-mode request with `pageToken`
279
+ * present but empty (`""`); from then on the token is present whenever
280
+ * that page returned any rows (AIP-158 "maybe more" semantics), not only
281
+ * when the page is exactly full. Empty only when a cursor-mode page
282
+ * returned zero rows, which is the sole proof the walk is exhausted. The
283
+ * two modes never bridge — page-number pagination is deprecated for deep
284
+ * history.
285
+ */
286
+ nextPageToken: string;
255
287
  }
256
288
  /**
257
289
  * Direction of a funding payment from the user's perspective.
@@ -395,7 +427,12 @@ export interface PortfolioStats {
395
427
  totalTrades: number;
396
428
  /** Total fees paid */
397
429
  feesPaid: string;
398
- /** Ratio of profitable trades to total trades. Null when there are no closed trades in the period. */
430
+ /**
431
+ * Position-level win rate: winning positions over winning + losing positions
432
+ * (break-even excluded). Each position (one flat→open→flat round-trip) is
433
+ * classified once by its net realized PnL after all fees, not per fill. Null
434
+ * when the period has no closed positions.
435
+ */
399
436
  winLossRatio: number | null;
400
437
  /** Total equity in USDC terms (spot balances plus perps account equity) */
401
438
  totalEquity: string;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Pulse Types
3
+ *
4
+ * Types for the public market-pulse news feed: AI-synthesized, per-asset
5
+ * headlines served from the backend's hourly-refreshed cache.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and ETag-cacheable.
8
+ * It returns 503 while the backend cache is cold.
9
+ */
10
+ import type { BaseAPI } from "../api";
11
+ /** Provenance for one pulse item, for attribution links. */
12
+ export interface PulseSource {
13
+ /** Source article or post URL. */
14
+ url: string;
15
+ /** Source author or publication name. */
16
+ author: string;
17
+ /** Source channel: "twitter" or "news". */
18
+ source: string;
19
+ /** Source publication time, ISO-8601. */
20
+ createdAt: string;
21
+ /** Relevance score, 1 (low) to 5 (high). */
22
+ relevance: number;
23
+ }
24
+ /** One synthesized market-pulse headline. */
25
+ export interface PulseItem {
26
+ /** Watchlist ticker (e.g. "BTC") or "MARKET" for a cross-asset story. */
27
+ asset: string;
28
+ /** Sentiment tag: "Bullish", "Neutral", or "Bearish". */
29
+ sentiment: string;
30
+ /** Synthesized 1-2 sentence summary (at most 240 characters). */
31
+ summary: string;
32
+ /** Timestamp of the most recent source; render relative time client-side. */
33
+ updatedAt: string;
34
+ /** Provenance for the item. */
35
+ sources: PulseSource[];
36
+ }
37
+ /** The latest pulse snapshot. */
38
+ export interface GetPulseResponse {
39
+ /** When this snapshot was produced upstream (ISO-8601 UTC); also the ETag value. */
40
+ generatedAt: string;
41
+ /** Asset universe the snapshot was synthesized against. */
42
+ watchlist: string[];
43
+ /** Pulse items, pre-sorted (watchlist order, MARKET last, newest first per asset). */
44
+ items: PulseItem[];
45
+ }
46
+ /**
47
+ * Pulse API interface. The endpoint is public (no auth required).
48
+ */
49
+ export interface PulseAPI extends BaseAPI {
50
+ /**
51
+ * Get the latest market pulse news feed snapshot.
52
+ *
53
+ * Public/unauthenticated; served from the backend cache (refreshed hourly).
54
+ * Items whose figures could not be verified upstream are removed
55
+ * server-side before caching.
56
+ *
57
+ * @returns Promise resolving to the latest snapshot
58
+ * @throws 503 while the backend cache is cold
59
+ */
60
+ getPulse(): Promise<GetPulseResponse>;
61
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Pulse Types
3
+ *
4
+ * Types for the public market-pulse news feed: AI-synthesized, per-asset
5
+ * headlines served from the backend's hourly-refreshed cache.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and ETag-cacheable.
8
+ * It returns 503 while the backend cache is cold.
9
+ */
@@ -10,6 +10,7 @@ import type { PitpassAPI } from "../pitpass";
10
10
  import type { PortfolioAPI } from "../portfolio";
11
11
  import type { PositionsAPI } from "../positions";
12
12
  import type { ProfileAPI } from "../profile";
13
+ import type { PulseAPI } from "../pulse";
13
14
  import type { SubAccountsAPI } from "../sub-accounts";
14
15
  import type { TradingAPI, TradingMode } from "../trading";
15
16
  import type { VaultAPI } from "../vault";
@@ -56,6 +57,14 @@ export interface SDKConfig {
56
57
  * (e.g. Docker DNS `ws://ws-api:8080/ws`). Must be a valid absolute URL.
57
58
  */
58
59
  wsUrl?: string;
60
+ /**
61
+ * Polling frequency in milliseconds for the SDK's internal viem public
62
+ * client (e.g. `waitForTransactionReceipt` during vault deposits). Sei
63
+ * produces sub-second blocks, so a value near the chain's block time
64
+ * confirms transactions much sooner than viem's 4000ms default. Defaults to
65
+ * 750ms when omitted. Must be a positive finite number when provided.
66
+ */
67
+ pollingInterval?: number;
59
68
  }
60
69
  /**
61
70
  * Core SDK interface providing access to all Monaco functionality.
@@ -93,6 +102,8 @@ export interface MonacoSDK {
93
102
  whitelist: WhitelistAPI;
94
103
  /** Profile operations API */
95
104
  profile: ProfileAPI;
105
+ /** Public market-pulse news feed API (cached, hourly-refreshed) */
106
+ pulse: PulseAPI;
96
107
  /** Orderbook REST API for fetching orderbook snapshots */
97
108
  orderbook: {
98
109
  getOrderbook: (tradingPairId: string, options?: {
@@ -34,6 +34,7 @@ export interface TradingAPI extends BaseAPI {
34
34
  riskBucketId?: string;
35
35
  riskBucketCollateral?: string;
36
36
  strategyKey?: string;
37
+ /** @deprecated Order side is authoritative. */
37
38
  positionSide?: PositionSide;
38
39
  leverage?: string;
39
40
  reduceOnly?: boolean;
@@ -58,6 +59,7 @@ export interface TradingAPI extends BaseAPI {
58
59
  riskBucketId?: string;
59
60
  riskBucketCollateral?: string;
60
61
  strategyKey?: string;
62
+ /** @deprecated Order side is authoritative. */
61
63
  positionSide?: PositionSide;
62
64
  leverage?: string;
63
65
  reduceOnly?: boolean;
@@ -140,6 +142,6 @@ export interface TradingAPI extends BaseAPI {
140
142
  */
141
143
  getOrder(orderId: string): Promise<GetOrderResponse>;
142
144
  }
143
- export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce, TradingMode, } from "./orders";
145
+ export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderTerminalReason, OrderType, PositionSide, TimeInForce, TradingMode, } from "./orders";
144
146
  export { ORDER_STATUS_VALUES } from "./orders";
145
147
  export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, ConditionalOrder, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, MatchResult, ParentTpSlLegParams, ReplaceOrderResponse, UpdatedFields, } from "./responses";
@@ -70,7 +70,11 @@ export interface Order {
70
70
  reduceOnly?: boolean;
71
71
  /** Position ID linked to the order, when available */
72
72
  positionId?: string;
73
+ /** Stable cause when status is CANCELLED */
74
+ terminalReason?: OrderTerminalReason;
73
75
  }
76
+ /** Stable terminal causes for accepted orders that end as CANCELLED. */
77
+ export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SYSTEM";
74
78
  /**
75
79
  * Role of the creator or order
76
80
  */
@@ -38,8 +38,6 @@ export interface MatchResult {
38
38
  } | null;
39
39
  }
40
40
  /**
41
- * Parent TP/SL leg attached to a normal margin order.
42
- *
43
41
  * Parent TP/SL follows the parent order quantity and becomes active once the
44
42
  * parent order creates or extends a position.
45
43
  */
@@ -139,6 +137,23 @@ export interface GetPaginatedOrdersParams {
139
137
  page?: number;
140
138
  /** Number of orders per page (default: 10, max: 100) */
141
139
  pageSize?: number;
140
+ /**
141
+ * Pagination cursor with three distinct states:
142
+ * - Omitted (`undefined`): legacy page-number pagination via `page`,
143
+ * limited to recent history once the archive window is enabled.
144
+ * - Empty string (`""`): start a cursor walk with no prior position, from
145
+ * the newest row (or the oldest, when `orderBy` is `"ASC"`).
146
+ * - Non-empty: an opaque cursor from a previous response's
147
+ * `nextPageToken`; results resume immediately after that position.
148
+ *
149
+ * In either cursor-walk state (empty or non-empty), `page` is ignored, the
150
+ * response omits exact totals (`total`/`totalPages`/`page` are 0), and
151
+ * results cover full order history — hot and archived rows merged —
152
+ * unlike page-number mode, which only ever sees recent history. Clients
153
+ * that need complete order history must use the cursor form (pass `""` to
154
+ * start, then follow `nextPageToken`) rather than `page`.
155
+ */
156
+ pageToken?: string;
142
157
  }
143
158
  /**
144
159
  * Response from getting paginated orders
@@ -159,6 +174,21 @@ export interface GetPaginatedOrdersResponse {
159
174
  pageSize: number;
160
175
  /** Total number of pages */
161
176
  totalPages: number;
177
+ /**
178
+ * Cursor for the next page. Empty on every page-number (legacy) response —
179
+ * page-number mode never mints a token, full page or not, since resuming
180
+ * from a legacy-minted position could silently strand archived history
181
+ * newer than wherever that page happened to end.
182
+ *
183
+ * To walk full history, start a cursor-mode request with `pageToken`
184
+ * present but empty (`""`); from then on the token is present whenever
185
+ * that page returned any rows (AIP-158 "maybe more" semantics), not only
186
+ * when the page is exactly full. Empty only when a cursor-mode page
187
+ * returned zero rows, which is the sole proof the walk is exhausted. The
188
+ * two modes never bridge — page-number pagination is deprecated for deep
189
+ * history.
190
+ */
191
+ nextPageToken: string;
162
192
  }
163
193
  /**
164
194
  * Response from getting a single order by ID
@@ -75,18 +75,18 @@ export declare const SimulateOrderRiskSchema: z.ZodObject<{
75
75
  BUY: "BUY";
76
76
  SELL: "SELL";
77
77
  }>;
78
- positionSide: z.ZodEnum<{
78
+ positionSide: z.ZodOptional<z.ZodEnum<{
79
79
  LONG: "LONG";
80
80
  SHORT: "SHORT";
81
81
  NONE: "NONE";
82
- }>;
82
+ }>>;
83
83
  orderType: z.ZodEnum<{
84
84
  LIMIT: "LIMIT";
85
85
  MARKET: "MARKET";
86
86
  }>;
87
87
  price: z.ZodOptional<z.ZodString>;
88
88
  quantity: z.ZodString;
89
- leverage: z.ZodString;
89
+ leverage: z.ZodOptional<z.ZodString>;
90
90
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
91
91
  }, z.core.$strict>;
92
92
  }, z.core.$strip>;
@@ -97,18 +97,18 @@ export declare const SimulateParentMarginOrderRiskSchema: z.ZodObject<{
97
97
  BUY: "BUY";
98
98
  SELL: "SELL";
99
99
  }>;
100
- positionSide: z.ZodEnum<{
100
+ positionSide: z.ZodOptional<z.ZodEnum<{
101
101
  LONG: "LONG";
102
102
  SHORT: "SHORT";
103
103
  NONE: "NONE";
104
- }>;
104
+ }>>;
105
105
  orderType: z.ZodEnum<{
106
106
  LIMIT: "LIMIT";
107
107
  MARKET: "MARKET";
108
108
  }>;
109
109
  price: z.ZodOptional<z.ZodString>;
110
110
  quantity: z.ZodString;
111
- leverage: z.ZodString;
111
+ leverage: z.ZodOptional<z.ZodString>;
112
112
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
113
113
  }, z.core.$strict>;
114
114
  }, z.core.$strip>;
@@ -118,18 +118,18 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
118
118
  BUY: "BUY";
119
119
  SELL: "SELL";
120
120
  }>;
121
- positionSide: z.ZodEnum<{
121
+ positionSide: z.ZodOptional<z.ZodEnum<{
122
122
  LONG: "LONG";
123
123
  SHORT: "SHORT";
124
124
  NONE: "NONE";
125
- }>;
125
+ }>>;
126
126
  orderType: z.ZodEnum<{
127
127
  LIMIT: "LIMIT";
128
128
  MARKET: "MARKET";
129
129
  }>;
130
130
  price: z.ZodOptional<z.ZodString>;
131
131
  quantity: z.ZodString;
132
- leverage: z.ZodString;
132
+ leverage: z.ZodOptional<z.ZodString>;
133
133
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
134
134
  tradingPairId: z.ZodUUID;
135
135
  strategyKey: z.ZodOptional<z.ZodString>;
@@ -141,18 +141,18 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
141
141
  BUY: "BUY";
142
142
  SELL: "SELL";
143
143
  }>;
144
- positionSide: z.ZodEnum<{
144
+ positionSide: z.ZodOptional<z.ZodEnum<{
145
145
  LONG: "LONG";
146
146
  SHORT: "SHORT";
147
147
  NONE: "NONE";
148
- }>;
148
+ }>>;
149
149
  orderType: z.ZodEnum<{
150
150
  LIMIT: "LIMIT";
151
151
  MARKET: "MARKET";
152
152
  }>;
153
153
  price: z.ZodOptional<z.ZodString>;
154
154
  quantity: z.ZodString;
155
- leverage: z.ZodString;
155
+ leverage: z.ZodOptional<z.ZodString>;
156
156
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
157
157
  marginMode: z.ZodLiteral<"CROSS">;
158
158
  selectedTradingPairIds: z.ZodArray<z.ZodUUID>;
@@ -78,17 +78,39 @@ export const GetParentMarginAccountMovementsSchema = PaginationSchema.extend({
78
78
  const BaseSimulateOrderRiskRequestSchema = z.object({
79
79
  tradingPairId: UUIDSchema,
80
80
  side: OrderSideSchema,
81
- positionSide: PositionSideSchema,
81
+ positionSide: PositionSideSchema.optional(),
82
82
  orderType: OrderTypeSchema,
83
83
  price: PositiveDecimalStringSchema.optional(),
84
84
  quantity: PositiveDecimalStringSchema,
85
- leverage: PositiveDecimalStringSchema,
85
+ leverage: PositiveDecimalStringSchema.optional(),
86
86
  reduceOnly: z.boolean().optional(),
87
87
  });
88
- const SimulateOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.strict();
89
- const SimulateIsolatedRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(IsolatedRiskBucketRequestSchema).strict();
88
+ const validateOneWaySimulationFields = (data, ctx) => {
89
+ if (data.positionSide !== undefined) {
90
+ const expected = data.side === "BUY" ? "LONG" : "SHORT";
91
+ if (data.positionSide !== expected) {
92
+ ctx.addIssue({
93
+ code: z.ZodIssueCode.custom,
94
+ message: "positionSide must match side when provided (BUY=LONG, SELL=SHORT)",
95
+ path: ["positionSide"],
96
+ });
97
+ }
98
+ }
99
+ if (data.reduceOnly !== true && data.leverage === undefined) {
100
+ ctx.addIssue({
101
+ code: z.ZodIssueCode.custom,
102
+ message: "leverage is required for normal margin orders",
103
+ path: ["leverage"],
104
+ });
105
+ }
106
+ };
107
+ const SimulateOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.strict().superRefine(validateOneWaySimulationFields);
108
+ const SimulateIsolatedRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(IsolatedRiskBucketRequestSchema)
109
+ .strict()
110
+ .superRefine(validateOneWaySimulationFields);
90
111
  const SimulateCrossRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(CrossRiskBucketScopeSchema)
91
112
  .strict()
113
+ .superRefine(validateOneWaySimulationFields)
92
114
  .refine((data) => data.selectedTradingPairIds.includes(data.tradingPairId), {
93
115
  message: "tradingPairId must be included in selectedTradingPairIds for CROSS risk buckets",
94
116
  path: ["selectedTradingPairIds"],