aftermath-ts-sdk 1.3.23-perps.25 → 1.3.23-perps.27

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.
@@ -1,208 +1,475 @@
1
1
  import { AnyObjectType, ApiDataWithCursorBody, Balance, Byte, Event, ObjectDigest, ObjectId, ObjectVersion, PackageId, Percentage, SerializedTransaction, SuiAddress, Timestamp, TransactionDigest } from "../../general/types/generalTypes";
2
2
  import { CoinDecimal, CoinSymbol, CoinType } from "../coin/coinTypes";
3
3
  import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
4
+ /**
5
+ * Unique identifier for a perpetuals market, represented as a Sui object ID
6
+ * (i.e. the `ClearingHouse` object on-chain).
7
+ */
4
8
  export type PerpetualsMarketId = ObjectId;
9
+ /**
10
+ * Unique numeric identifier for a perpetuals account.
11
+ *
12
+ * This is a bigint, as it is derived directly from the on-chain representation.
13
+ */
5
14
  export type PerpetualsAccountId = bigint;
15
+ /**
16
+ * Unique numeric identifier for a perpetuals order.
17
+ *
18
+ * This ID is stable across events and API responses.
19
+ */
6
20
  export type PerpetualsOrderId = bigint;
21
+ /**
22
+ * String representation of a {@link PerpetualsOrderId}.
23
+ *
24
+ * Some APIs serialize order IDs as strings instead of `bigint`.
25
+ */
7
26
  export type PerpetualsOrderIdAsString = string;
27
+ /**
28
+ * Price type for orders, represented as a fixed-point `bigint` in the
29
+ * on-chain format (e.g., scaled by `1e9`).
30
+ */
8
31
  export type PerpetualsOrderPrice = bigint;
32
+ /**
33
+ * Side of a perpetuals order.
34
+ *
35
+ * - `Bid` (0): Long-side orders / buyers.
36
+ * - `Ask` (1): Short-side orders / sellers.
37
+ */
9
38
  export declare enum PerpetualsOrderSide {
10
39
  Ask = 1,// true
11
40
  Bid = 0
12
41
  }
42
+ /**
43
+ * Order execution and posting behavior.
44
+ *
45
+ * - `Standard`: No special constraints.
46
+ * - `FillOrKill`: Either fully fills immediately or cancels.
47
+ * - `PostOnly`: Only posts to the book; will not take liquidity.
48
+ * - `ImmediateOrCancel`: Fills as much as possible immediately; remainder is canceled.
49
+ */
13
50
  export declare enum PerpetualsOrderType {
14
51
  Standard = 0,
15
52
  FillOrKill = 1,
16
53
  PostOnly = 2,
17
54
  ImmediateOrCancel = 3
18
55
  }
56
+ /**
57
+ * Stop order mode.
58
+ *
59
+ * - `SlTp`: Stop Loss / Take Profit order, intended to close a position
60
+ * (fully or partially).
61
+ * - `Standalone`: Independent stop order that can both reduce or increase
62
+ * the position, potentially requiring additional allocated collateral.
63
+ */
19
64
  export declare enum PerpetualsStopOrderType {
20
65
  SlTp = 0,
21
66
  Standalone = 1
22
67
  }
68
+ /**
69
+ * Aggregate market configuration and state for a single perpetuals market.
70
+ */
23
71
  export interface PerpetualsMarketData {
72
+ /** Package ID of the deployed perpetuals contract. */
24
73
  packageId: PackageId;
74
+ /** Object ID for the market (clearing house) on-chain. */
25
75
  objectId: ObjectId;
76
+ /** Collateral coin type used for margin in this market. */
26
77
  collateralCoinType: CoinType;
78
+ /** Static configuration parameters for this market. */
27
79
  marketParams: PerpetualsMarketParams;
80
+ /** Dynamic runtime state (funding, open interest, etc.). */
28
81
  marketState: PerpetualsMarketState;
82
+ /** Current price of collateral in USD or the platform's base unit. */
29
83
  collateralPrice: number;
84
+ /** Oracle/index price of the base asset for this market. */
30
85
  indexPrice: number;
86
+ /** Estimated funding rate for the next funding interval. */
31
87
  estimatedFundingRate: Percentage;
88
+ /** Timestamp (ms) for the next funding event, as a bigint. */
32
89
  nextFundingTimestampMs: bigint;
33
90
  }
91
+ /**
92
+ * On-chain capability object that grants control over a perpetuals account.
93
+ *
94
+ * This represents an "owned" account capability, used to sign and authorize
95
+ * account-level actions.
96
+ */
34
97
  export interface PerpetualsAccountCap {
98
+ /** Object ID of the account capability on-chain. */
35
99
  objectId: ObjectId;
100
+ /** Wallet address that owns this account capability. */
36
101
  walletAddress: SuiAddress;
102
+ /** Logical ID of the associated perpetuals account. */
37
103
  accountId: PerpetualsAccountId;
104
+ /** Object ID of the associated `PerpetualsAccountObject`. */
38
105
  accountObjectId: ObjectId;
106
+ /** Collateral coin type backing this account. */
39
107
  collateralCoinType: CoinType;
108
+ /** Total collateral (native units) associated with this account. */
40
109
  collateral: number;
110
+ /** On-chain object version. */
41
111
  objectVersion: ObjectVersion;
112
+ /** On-chain object digest. */
42
113
  objectDigest: ObjectDigest;
43
114
  }
115
+ /**
116
+ * Base vault-capability object, as represented on-chain.
117
+ */
44
118
  export interface PerpetualsVaultCap {
119
+ /** Vault object ID that this cap grants permissions for. */
45
120
  vaultId: ObjectId;
121
+ /** Capability object ID. */
46
122
  objectId: ObjectId;
123
+ /** Owner of the vault-capability. */
47
124
  ownerAddress: SuiAddress;
48
- }
49
- export type PerpetualsVaultCapExtended = {
50
- vaultId: ObjectId;
51
- ownerAddress: SuiAddress;
125
+ /** Collateral coin type used by the vault account. */
126
+ collateralCoinType: CoinType;
127
+ /** Perpetuals account ID controlled by the vault. */
52
128
  accountId: PerpetualsAccountId;
129
+ /** Object ID of the account object owned by the vault. */
53
130
  accountObjectId: ObjectId;
54
- collateralCoinType: CoinType;
55
- };
131
+ }
132
+ export type PerpetualsPartialVaultCap = Omit<PerpetualsVaultCap, "objectId">;
133
+ export interface PerpetualsVaultLpCoin {
134
+ vaultId: ObjectId;
135
+ objectId: ObjectId;
136
+ lpAmount: Balance;
137
+ lpAmountUsd: number;
138
+ }
139
+ /**
140
+ * Aggregate position data for a single perpetuals market and account.
141
+ *
142
+ * Values are generally denoted in:
143
+ * - Base asset units (e.g. BTC)
144
+ * - Quote units (e.g. USD)
145
+ * - Collateral units (per `collateralCoinType`)
146
+ */
56
147
  export interface PerpetualsPosition {
148
+ /** Allocated collateral (in collateral coins). */
57
149
  collateral: number;
150
+ /** Net base asset amount (positive = long, negative = short). */
58
151
  baseAssetAmount: number;
152
+ /** Notional exposure of the position in quote units. */
59
153
  quoteAssetNotionalAmount: number;
154
+ /** Cumulative funding rate accrued on the long side. */
60
155
  cumFundingRateLong: number;
156
+ /** Cumulative funding rate accrued on the short side. */
61
157
  cumFundingRateShort: number;
158
+ /** Aggregate size of resting asks in this market for the account. */
62
159
  asksQuantity: number;
160
+ /** Aggregate size of resting bids in this market for the account. */
63
161
  bidsQuantity: number;
162
+ /** Market identifier for this position. */
64
163
  marketId: PerpetualsMarketId;
164
+ /** All pending (open) orders associated with this position. */
65
165
  pendingOrders: {
166
+ /** Unique ID of the order. */
66
167
  orderId: PerpetualsOrderId;
168
+ /** Side of the order (Bid/Ask). */
67
169
  side: PerpetualsOrderSide;
170
+ /** Size of the order in base units (scaled as bigint). */
68
171
  size: bigint;
69
172
  }[];
173
+ /** Maker fee rate applied to this position (as a fraction). */
70
174
  makerFee: number;
175
+ /** Taker fee rate applied to this position (as a fraction). */
71
176
  takerFee: number;
177
+ /** Effective leverage applied to the position. */
72
178
  leverage: number;
179
+ /** Collateral value in USD. */
73
180
  collateralUsd: number;
181
+ /** Current margin ratio (collateral / exposure). */
74
182
  marginRatio: number;
183
+ /** Free margin available in USD. */
75
184
  freeMarginUsd: number;
185
+ /** Free (unlocked) collateral in collateral units. */
76
186
  freeCollateral: number;
187
+ /** Unrealized funding PnL in USD. */
77
188
  unrealizedFundingsUsd: number;
189
+ /** Unrealized position PnL in USD. */
78
190
  unrealizedPnlUsd: number;
191
+ /** Average entry price of the position. */
79
192
  entryPrice: number;
193
+ /** Approximate liquidation price for the position. */
80
194
  liquidationPrice: number;
81
195
  }
196
+ /**
197
+ * Static configuration parameters describing a perpetuals market.
198
+ *
199
+ * These values are typically immutable or rarely changed, and are used
200
+ * to drive risk limits, pricing, and fee schedules.
201
+ */
82
202
  export interface PerpetualsMarketParams {
203
+ /** Initial margin requirement for new positions (fraction). */
83
204
  marginRatioInitial: number;
205
+ /** Maintenance margin requirement for open positions (fraction). */
84
206
  marginRatioMaintenance: number;
207
+ /** Symbol of the underlying asset. */
85
208
  baseAssetSymbol: CoinSymbol;
209
+ /** On-chain ID of the oracle providing the base asset price. */
86
210
  basePriceFeedId: ObjectId;
211
+ /** On-chain ID of the oracle providing the collateral asset price. */
87
212
  collateralPriceFeedId: ObjectId;
213
+ /** Funding interval duration in milliseconds. */
88
214
  fundingFrequencyMs: bigint;
215
+ /** Funding period used for calculations in milliseconds. */
89
216
  fundingPeriodMs: bigint;
217
+ /** TWAP frequency for the premium in milliseconds. */
90
218
  premiumTwapFrequencyMs: bigint;
219
+ /** TWAP period for the premium in milliseconds. */
91
220
  premiumTwapPeriodMs: bigint;
221
+ /** TWAP frequency for the spread in milliseconds. */
92
222
  spreadTwapFrequencyMs: bigint;
223
+ /** TWAP period for the spread in milliseconds. */
93
224
  spreadTwapPeriodMs: bigint;
225
+ /** TWAP period for gas price in milliseconds. */
94
226
  gasPriceTwapPeriodMs: bigint;
227
+ /** Maker fee rate (fraction) charged for providing liquidity. */
95
228
  makerFee: number;
229
+ /** Taker fee rate (fraction) charged for taking liquidity. */
96
230
  takerFee: number;
231
+ /** Liquidation fee rate (fraction) charged on liquidations. */
97
232
  liquidationFee: number;
233
+ /** Fee rate (fraction) for forced cancellation. */
98
234
  forceCancelFee: number;
235
+ /** Fraction of fees directed to the insurance fund. */
99
236
  insuranceFundFee: number;
237
+ /** Minimum notional order value in USD. */
100
238
  minOrderUsdValue: number;
239
+ /** Minimum base size increment for orders (lot size, scaled bigint). */
101
240
  lotSize: bigint;
241
+ /** Minimum price increment (tick size, scaled bigint). */
102
242
  tickSize: bigint;
243
+ /** Scaling factor used in internal fixed-point conversions. */
103
244
  scalingFactor: number;
245
+ /** Additional taker fee that depends on gas cost. */
104
246
  gasPriceTakerFee: number;
247
+ /** Z-score threshold used for outlier detection in pricing. */
105
248
  zScoreThreshold: number;
249
+ /** Maximum open interest (notional or base) allowed in the market. */
106
250
  maxPendingOrders: bigint;
251
+ /** Oracle tolerance for the base asset price (scaled bigint). */
107
252
  baseOracleTolerance: bigint;
253
+ /** Oracle tolerance for the collateral price (scaled bigint). */
108
254
  collateralOracleTolerance: bigint;
255
+ /** Maximum open interest (absolute). */
109
256
  maxOpenInterest: number;
257
+ /** Threshold above which open interest is considered elevated. */
110
258
  maxOpenInterestThreshold: number;
259
+ /** Maximum fraction of open interest a single position can hold. */
111
260
  maxOpenInterestPositionPercent: number;
112
261
  }
262
+ /**
263
+ * Dynamic runtime state of a perpetuals market.
264
+ *
265
+ * These values are updated frequently and used to compute funding
266
+ * and other time-variant metrics.
267
+ */
113
268
  export interface PerpetualsMarketState {
269
+ /** Cumulative funding rate for long positions. */
114
270
  cumFundingRateLong: number;
271
+ /** Cumulative funding rate for short positions. */
115
272
  cumFundingRateShort: number;
273
+ /** Last timestamp when funding was updated. */
116
274
  fundingLastUpdateTimestamp: Timestamp;
275
+ /** Premium TWAP value (book vs index). */
117
276
  premiumTwap: number;
277
+ /** Timestamp of last premium TWAP update. */
118
278
  premiumTwapLastUpdateTimestamp: Timestamp;
279
+ /** Spread TWAP value. */
119
280
  spreadTwap: number;
281
+ /** Timestamp of last spread TWAP update. */
120
282
  spreadTwapLastUpdateTimestamp: Timestamp;
283
+ /** Current open interest in the market. */
121
284
  openInterest: number;
285
+ /** Total fees accrued by the market. */
122
286
  feesAccrued: number;
123
287
  }
288
+ /**
289
+ * Single OHLCV data point for a market candle.
290
+ *
291
+ * Typically used in charts and historical data views.
292
+ */
124
293
  export interface PerpetualsMarketCandleDataPoint {
294
+ /** Start timestamp of this candle. */
125
295
  timestamp: Timestamp;
296
+ /** High price within this interval. */
126
297
  high: number;
298
+ /** Low price within this interval. */
127
299
  low: number;
300
+ /** Open price at the beginning of the interval. */
128
301
  open: number;
302
+ /** Close price at the end of the interval. */
129
303
  close: number;
304
+ /** Traded volume (base units) during the interval. */
130
305
  volume: number;
131
306
  }
307
+ /**
308
+ * A single entry (price level) in an orderbook side.
309
+ */
132
310
  export interface PerpetualsOrderbookItem {
311
+ /** Total size resting at this price level (base units). */
133
312
  size: number;
313
+ /** Price level for the aggregated orders. */
134
314
  price: number;
135
315
  }
316
+ /**
317
+ * Aggregated orderbook snapshot for a perpetuals market.
318
+ */
136
319
  export interface PerpetualsOrderbook {
320
+ /** Bid-side price levels (sorted descending by price). */
137
321
  bids: PerpetualsOrderbookItem[];
322
+ /** Ask-side price levels (sorted ascending by price). */
138
323
  asks: PerpetualsOrderbookItem[];
324
+ /** Sum of bid-side size across all levels. */
139
325
  asksTotalSize: number;
326
+ /** Sum of ask-side size across all levels. */
140
327
  bidsTotalSize: number;
328
+ /** Best bid price (highest bid), or undefined if no bids. */
141
329
  bestBidPrice: number | undefined;
330
+ /** Best ask price (lowest ask), or undefined if no asks. */
142
331
  bestAskPrice: number | undefined;
332
+ /** Mid price between best bid and best ask, if both exist. */
143
333
  midPrice: number | undefined;
334
+ /** Incremental nonce associated with this snapshot. */
144
335
  nonce: bigint;
145
336
  }
337
+ /**
338
+ * Incremental deltas to an orderbook snapshot.
339
+ *
340
+ * These are typically used over websockets for streaming updates.
341
+ */
146
342
  export interface PerpetualsOrderbookDeltas {
343
+ /** Updated bid-side price levels. */
147
344
  bidsDeltas: PerpetualsOrderbookItem[];
345
+ /** Updated ask-side price levels. */
148
346
  asksDeltas: PerpetualsOrderbookItem[];
347
+ /** Delta of total ask-side size. */
149
348
  asksTotalSizeDelta: number;
349
+ /** Delta of total bid-side size. */
150
350
  bidsTotalSizeDelta: number;
351
+ /** Nonce for ordering deltas. */
151
352
  nonce: bigint;
152
353
  }
354
+ /**
355
+ * Core order metadata for perpetuals orders.
356
+ *
357
+ * This is shared across multiple internal and external APIs.
358
+ */
153
359
  export interface PerpetualsOrderData {
360
+ /** Unique ID of the order. */
154
361
  orderId: PerpetualsOrderId;
362
+ /** Initial order size in scaled base units. */
155
363
  initialSize: bigint;
364
+ /** Already-filled size in scaled base units. */
156
365
  filledSize: bigint;
366
+ /** Order side (Bid or Ask). */
157
367
  side: PerpetualsOrderSide;
368
+ /** Market this order belongs to. */
158
369
  marketId: PerpetualsMarketId;
159
370
  }
371
+ /**
372
+ * Full stop-order representation on-chain.
373
+ *
374
+ * Can represent:
375
+ * - SL/TP orders (`slTp`)
376
+ * - Standalone stops (`nonSlTp`)
377
+ */
160
378
  export interface PerpetualsStopOrderData {
379
+ /** ID of the stop order object on-chain. */
161
380
  objectId: ObjectId;
381
+ /** Market the stop order is tied to. */
162
382
  marketId: PerpetualsMarketId;
383
+ /** Size to execute when triggered (scaled base units). */
163
384
  size: bigint;
385
+ /** Direction of the stop order. */
164
386
  side: PerpetualsOrderSide;
387
+ /** Optional expiration time (ms or seconds, depending on protocol). */
165
388
  expiryTimestamp?: bigint;
389
+ /** Optional limit order parameters when the stop triggers. */
166
390
  limitOrder?: {
391
+ /** Limit price to post or execute at, scaled bigint. */
167
392
  price: bigint;
393
+ /** Order type semantics. */
168
394
  orderType: PerpetualsOrderType;
169
395
  };
396
+ /** Stop loss / take profit configuration. */
170
397
  slTp?: {
398
+ /** Index price at which to trigger a stop loss. */
171
399
  stopLossIndexPrice?: number;
400
+ /** Index price at which to take profit. */
172
401
  takeProfitIndexPrice?: number;
173
402
  };
403
+ /** Non-SL/TP standalone stop configuration. */
174
404
  nonSlTp?: {
405
+ /** Index price threshold used for triggering. */
175
406
  stopIndexPrice: number;
407
+ /** If true, triggers when index >= threshold, otherwise index <= threshold. */
176
408
  triggerIfGeStopIndexPrice: boolean;
409
+ /** Whether the stop can only reduce an existing position. */
177
410
  reduceOnly: boolean;
178
411
  };
179
412
  }
413
+ /**
414
+ * Filled order data used in execution price previews and trade details.
415
+ */
180
416
  export interface PerpetualsFilledOrderData {
417
+ /** Filled size in base units (non-scaled). */
181
418
  size: number;
419
+ /** Execution price for the fill. */
182
420
  price: number;
183
421
  }
422
+ /**
423
+ * High-level order info with price and size only.
424
+ */
184
425
  export interface PerpetualsOrderInfo {
426
+ /** Order price. */
185
427
  price: number;
428
+ /** Order size (scaled base units). */
186
429
  size: bigint;
187
430
  }
431
+ /**
432
+ * Pairing of a perpetuals account capability and its current account state.
433
+ */
188
434
  export interface PerpetualsAccountData {
435
+ /** Account capability object. */
189
436
  accountCap: PerpetualsAccountCap;
437
+ /** Account state object. */
190
438
  account: PerpetualsAccountObject;
191
439
  }
440
+ /**
441
+ * Aggregate account-level metrics for perpetuals.
442
+ */
192
443
  export interface PerpetualsAccountObject {
444
+ /** Numeric ID of the account. */
193
445
  accountId: PerpetualsAccountId;
446
+ /** Total equity in USD. */
194
447
  totalEquityUsd: number;
448
+ /** Available collateral in collateral units. */
195
449
  availableCollateral: number;
450
+ /** Available collateral in USD. */
196
451
  availableCollateralUsd: number;
452
+ /** Sum of unrealized funding PnL across markets. */
197
453
  totalUnrealizedFundingsUsd: number;
454
+ /** Sum of unrealized position PnL across markets. */
198
455
  totalUnrealizedPnlUsd: number;
456
+ /** Per-market positions for this account. */
199
457
  positions: PerpetualsPosition[];
200
458
  }
459
+ /**
460
+ * On-chain representation of a vault that manages user collateral and
461
+ * interacts with clearing houses on their behalf.
462
+ */
201
463
  export interface PerpetualsVaultObject {
202
464
  objectId: ObjectId;
203
465
  version: bigint;
466
+ name: string;
204
467
  lpSupply: Balance;
205
- collateral: Balance;
468
+ idleCollateral: Balance;
469
+ idleCollateralUsd: number;
470
+ totalCollateral: Balance;
471
+ totalCollateralUsd: number;
472
+ tvlUsd: number;
206
473
  marketIds: PerpetualsMarketId[];
207
474
  withdrawQueue: PerpetualsVaultWithdrawRequest[];
208
475
  parameters: {
@@ -210,39 +477,86 @@ export interface PerpetualsVaultObject {
210
477
  ownerFeePercentage: number;
211
478
  forceWithdrawDelayMs: bigint;
212
479
  collateralPriceFeedStorageId: ObjectId;
480
+ collateralPriceFeedStorageSourceId: ObjectId;
481
+ collateralPriceFeedStorageTolerance: bigint;
482
+ maxForceWithdrawMarginRatioTolerance: number;
213
483
  scalingFactor: number;
214
484
  maxMarketsInVault: bigint;
215
485
  maxPendingOrdersPerPosition: bigint;
486
+ maxTotalDepositedCollateral: Balance;
216
487
  };
488
+ /** Owner address of the vault. */
217
489
  ownerAddress: SuiAddress;
490
+ /** Creation timestamp of the vault. */
218
491
  creationTimestamp: Timestamp;
219
- collateralCoinType: CoinType;
220
- lpCoinDecimals: CoinDecimal;
492
+ /** Underlying perpetuals account ID that the vault uses. */
221
493
  accountId: PerpetualsAccountId;
494
+ /** Account object ID used by the vault. */
222
495
  accountObjectId: ObjectId;
496
+ /** Collateral coin type accepted by this vault. */
497
+ collateralCoinType: CoinType;
498
+ lpCoinType: CoinType;
499
+ /** Decimals for the LP token minted by this vault. */
500
+ lpCoinDecimals: CoinDecimal;
223
501
  }
502
+ /**
503
+ * Represents a single pending vault withdrawal request.
504
+ */
224
505
  export interface PerpetualsVaultWithdrawRequest {
225
506
  userAddress: SuiAddress;
507
+ vaultId: SuiAddress;
226
508
  lpAmountOut: Balance;
227
509
  requestTimestamp: Timestamp;
228
510
  minLpAmountOut: Balance;
229
511
  }
512
+ /**
513
+ * Event emitted when a clearing house (market) is upgraded to a new version.
514
+ */
230
515
  export interface UpdatedMarketVersionEvent extends Event {
516
+ /** Market identifier for which the version changed. */
231
517
  marketId: PerpetualsMarketId;
518
+ /** New version value. */
232
519
  version: bigint;
233
520
  }
521
+ /**
522
+ * Type guard for {@link UpdatedMarketVersionEvent}.
523
+ *
524
+ * @param event - Generic event.
525
+ * @returns `true` if this is an `UpdatedMarketVersionEvent`.
526
+ */
234
527
  export declare const isUpdatedMarketVersion: (event: Event) => event is UpdatedMarketVersionEvent;
528
+ /**
529
+ * Cursor-based response wrapping a list of collateral changes for an account.
530
+ */
235
531
  export interface PerpetualsAccountCollateralChangesWithCursor {
532
+ /** Collateral changes in chronological order (or per backend contract). */
236
533
  collateralChanges: PerpetualsAccountCollateralChange[];
534
+ /** Next cursor (timestamp) or undefined if there is no next page. */
237
535
  nextCursor: Timestamp | undefined;
238
536
  }
537
+ /**
538
+ * Single collateral change record for an account.
539
+ *
540
+ * This may represent:
541
+ * - Deposits / withdrawals
542
+ * - Liquidations
543
+ * - Funding settlements
544
+ * - Trading fees
545
+ */
239
546
  export type PerpetualsAccountCollateralChange = {
547
+ /** When the change occurred. */
240
548
  timestamp: Timestamp;
549
+ /** Sui transaction digest that produced this change. */
241
550
  txDigest: TransactionDigest;
551
+ /** Market ID, if applicable (can be undefined for global changes). */
242
552
  marketId: PerpetualsMarketId | undefined;
553
+ /** Concrete event type fully qualified (Sui struct type). */
243
554
  eventType: AnyObjectType;
555
+ /** Net change in collateral units. */
244
556
  collateralChange: number;
557
+ /** Net change in USD value. */
245
558
  collateralChangeUsd: number;
559
+ /** Optional breakdown of fees, with variant shapes based on event. */
246
560
  fees?: {
247
561
  netFeesUsd: number;
248
562
  liquidationFeesUsd: number;
@@ -255,43 +569,82 @@ export type PerpetualsAccountCollateralChange = {
255
569
  netFeesUsd: number;
256
570
  };
257
571
  };
572
+ /**
573
+ * Cursor-based response wrapping a list of trades for an account.
574
+ */
258
575
  export interface PerpetualsAccountTradesWithCursor {
576
+ /** Trades in chronological order (or per backend contract). */
259
577
  trades: PerpetualsAccountTrade[];
578
+ /** Next cursor (timestamp) or undefined if no next page. */
260
579
  nextCursor: Timestamp | undefined;
261
580
  }
581
+ /**
582
+ * Historical margin data point for an account, used in margin history views.
583
+ */
262
584
  export interface PerpetualsAccountMarginData {
585
+ /** Timestamp of this snapshot. */
263
586
  timestamp: Timestamp;
587
+ /** Collateral value in USD at that time. */
264
588
  collateralUsd: number;
589
+ /** Unrealized funding PnL in USD at that time. */
265
590
  unrealizedFundingUsd: number;
591
+ /** Unrealized position PnL in USD at that time. */
266
592
  unrealizedPnlUsd: number;
267
593
  }
594
+ /**
595
+ * Individual trade affecting an account.
596
+ */
268
597
  export type PerpetualsAccountTrade = {
598
+ /** Timestamp of the trade. */
269
599
  timestamp: Timestamp;
600
+ /** Sui transaction digest. */
270
601
  txDigest: TransactionDigest;
602
+ /** Market in which this trade occurred. */
271
603
  marketId: PerpetualsMarketId;
604
+ /** Concrete event type. */
272
605
  eventType: AnyObjectType;
606
+ /** Side of the trade relative to the account (Bid/Ask). */
273
607
  side: PerpetualsOrderSide;
608
+ /** Execution price. */
274
609
  price: number;
610
+ /** Trade size in base units. */
275
611
  size: number;
276
612
  };
613
+ /**
614
+ * Event emitted when collateral is deposited into an account.
615
+ */
277
616
  export interface DepositedCollateralEvent extends Event {
278
617
  accountId: PerpetualsAccountId;
279
618
  collateralDelta: Balance;
280
619
  }
620
+ /**
621
+ * Event emitted when collateral is allocated from general account collateral
622
+ * into a specific market position.
623
+ */
281
624
  export interface AllocatedCollateralEvent extends Event {
282
625
  marketId: PerpetualsMarketId;
283
626
  accountId: PerpetualsAccountId;
284
627
  collateralDelta: Balance;
285
628
  }
629
+ /**
630
+ * Event emitted when collateral is deallocated from a market back to
631
+ * the account's general collateral.
632
+ */
286
633
  export interface DeallocatedCollateralEvent extends Event {
287
634
  marketId: PerpetualsMarketId;
288
635
  accountId: PerpetualsAccountId;
289
636
  collateralDelta: Balance;
290
637
  }
638
+ /**
639
+ * Event emitted when collateral is withdrawn from the account.
640
+ */
291
641
  export interface WithdrewCollateralEvent extends Event {
292
642
  accountId: PerpetualsAccountId;
293
643
  collateralDelta: Balance;
294
644
  }
645
+ /**
646
+ * Event emitted when funding is settled for an account and market.
647
+ */
295
648
  export interface SettledFundingEvent extends Event {
296
649
  accountId: PerpetualsAccountId;
297
650
  collateralDeltaUsd: number;
@@ -299,52 +652,111 @@ export interface SettledFundingEvent extends Event {
299
652
  marketFundingRateLong: number;
300
653
  marketFundingRateShort: number;
301
654
  }
655
+ /**
656
+ * Union of all event types that impact account collateral.
657
+ */
302
658
  export type CollateralEvent = WithdrewCollateralEvent | DepositedCollateralEvent | SettledFundingEvent | LiquidatedEvent | FilledTakerOrderEvent | FilledMakerOrdersEvent | AllocatedCollateralEvent | DeallocatedCollateralEvent;
659
+ /**
660
+ * Type guard for {@link WithdrewCollateralEvent}.
661
+ */
303
662
  export declare const isWithdrewCollateralEvent: (event: Event) => event is WithdrewCollateralEvent;
663
+ /**
664
+ * Type guard for {@link DepositedCollateralEvent}.
665
+ */
304
666
  export declare const isDepositedCollateralEvent: (event: Event) => event is DepositedCollateralEvent;
667
+ /**
668
+ * Type guard for {@link DeallocatedCollateralEvent}.
669
+ */
305
670
  export declare const isDeallocatedCollateralEvent: (event: Event) => event is DeallocatedCollateralEvent;
671
+ /**
672
+ * Type guard for {@link AllocatedCollateralEvent}.
673
+ */
306
674
  export declare const isAllocatedCollateralEvent: (event: Event) => event is AllocatedCollateralEvent;
675
+ /**
676
+ * Type guard for {@link SettledFundingEvent}.
677
+ */
307
678
  export declare const isSettledFundingEvent: (event: Event) => event is SettledFundingEvent;
679
+ /**
680
+ * Event emitted when an account is liquidated in a given market.
681
+ */
308
682
  export interface LiquidatedEvent extends Event {
309
683
  accountId: PerpetualsAccountId;
310
684
  collateralDeltaUsd: number;
685
+ /** Liquidator's account ID. */
311
686
  liqorAccountId: PerpetualsAccountId;
312
687
  marketId: PerpetualsMarketId;
313
688
  side: PerpetualsOrderSide;
689
+ /** Amount of base asset liquidated. */
314
690
  baseLiquidated: number;
691
+ /** Amount of quote asset liquidated. */
315
692
  quoteLiquidated: number;
693
+ /** Liquidated account's PnL in USD for this event. */
316
694
  liqeePnlUsd: number;
695
+ /** Liquidation fee paid in USD. */
317
696
  liquidationFeesUsd: number;
697
+ /** Force-cancel fees collected in USD. */
318
698
  forceCancelFeesUsd: number;
699
+ /** Fees directed to the insurance fund in USD. */
319
700
  insuranceFundFeesUsd: number;
320
701
  }
702
+ /**
703
+ * Type guard for {@link LiquidatedEvent}.
704
+ */
321
705
  export declare const isLiquidatedEvent: (event: Event) => event is LiquidatedEvent;
706
+ /**
707
+ * Event emitted when a new perpetuals account is created for a user.
708
+ */
322
709
  export interface CreatedAccountEvent extends Event {
323
710
  user: SuiAddress;
324
711
  accountId: PerpetualsAccountId;
325
712
  }
713
+ /**
714
+ * Event emitted when an account's initial margin ratio for a position
715
+ * is explicitly set or adjusted.
716
+ */
326
717
  export interface SetPositionInitialMarginRatioEvent extends Event {
327
718
  marketId: PerpetualsMarketId;
328
719
  accountId: PerpetualsAccountId;
329
720
  initialMarginRatio: number;
330
721
  }
722
+ /**
723
+ * Trade data used for market-level trade history.
724
+ */
331
725
  export interface PerpetualsTradeHistoryData {
726
+ /** Timestamp of the trade. */
332
727
  timestamp: Timestamp;
728
+ /** Transaction digest. */
333
729
  txDigest: TransactionDigest;
730
+ /** Side of the trade. */
334
731
  side: PerpetualsOrderSide;
732
+ /** Filled size in base units. */
335
733
  sizeFilled: number;
734
+ /** Order price (limit price) used for the trade. */
336
735
  orderPrice: number;
337
736
  }
737
+ /**
738
+ * Cursor-based wrapper for market-level trade history.
739
+ */
338
740
  export interface PerpetualsTradeHistoryWithCursor {
741
+ /** Trades in this page. */
339
742
  trades: PerpetualsTradeHistoryData[];
743
+ /** Next cursor or undefined if there are no more pages. */
340
744
  nextCursor: Timestamp | undefined;
341
745
  }
746
+ /**
747
+ * Event emitted when an order is filled or dropped by the orderbook
748
+ * (book-keeping receipt).
749
+ */
342
750
  export interface OrderbookFillReceiptEvent extends Event {
343
751
  accountId: PerpetualsAccountId;
344
752
  orderId: PerpetualsOrderId;
345
753
  size: bigint;
754
+ /** Whether the order was dropped instead of filled. */
346
755
  dropped: boolean;
347
756
  }
757
+ /**
758
+ * Event emitted when an order is canceled.
759
+ */
348
760
  export interface CanceledOrderEvent extends Event {
349
761
  accountId: PerpetualsAccountId;
350
762
  marketId: PerpetualsMarketId;
@@ -352,6 +764,9 @@ export interface CanceledOrderEvent extends Event {
352
764
  size: bigint;
353
765
  orderId: PerpetualsOrderId;
354
766
  }
767
+ /**
768
+ * Event emitted when a new order is posted to the orderbook.
769
+ */
355
770
  export interface PostedOrderEvent extends Event {
356
771
  accountId: PerpetualsAccountId;
357
772
  marketId: PerpetualsMarketId;
@@ -360,9 +775,16 @@ export interface PostedOrderEvent extends Event {
360
775
  reduceOnly: boolean;
361
776
  expiryTimestamp?: bigint;
362
777
  }
778
+ /**
779
+ * Event emitted when one or more maker orders are filled against a taker.
780
+ */
363
781
  export interface FilledMakerOrdersEvent extends Event {
782
+ /** List of per-maker fills for this aggregate event. */
364
783
  events: FilledMakerOrderEventFields[];
365
784
  }
785
+ /**
786
+ * Details for a single maker order fill inside a {@link FilledMakerOrdersEvent}.
787
+ */
366
788
  export interface FilledMakerOrderEventFields {
367
789
  accountId: PerpetualsAccountId;
368
790
  takerAccountId: PerpetualsAccountId;
@@ -377,6 +799,9 @@ export interface FilledMakerOrderEventFields {
377
799
  feesUsd: number;
378
800
  canceledSize: bigint;
379
801
  }
802
+ /**
803
+ * Event emitted when a taker order is executed.
804
+ */
380
805
  export interface FilledTakerOrderEvent extends Event {
381
806
  accountId: PerpetualsAccountId;
382
807
  collateralDeltaUsd: number;
@@ -387,7 +812,16 @@ export interface FilledTakerOrderEvent extends Event {
387
812
  takerPnlUsd: number;
388
813
  takerFeesUsd: number;
389
814
  }
815
+ /**
816
+ * Union of all order-related events in the protocol.
817
+ */
390
818
  export type PerpetualsOrderEvent = CanceledOrderEvent | PostedOrderEvent | PostedOrderEvent | FilledMakerOrdersEvent | FilledTakerOrderEvent | LiquidatedEvent | ReducedOrderEvent;
819
+ /**
820
+ * Event emitted when an order is posted.
821
+ *
822
+ * NOTE: This is a second definition of `PostedOrderEvent` used in a
823
+ * simplified context (without `reduceOnly` / `expiryTimestamp`).
824
+ */
391
825
  export interface PostedOrderEvent extends Event {
392
826
  accountId: PerpetualsAccountId;
393
827
  marketId: PerpetualsMarketId;
@@ -395,17 +829,42 @@ export interface PostedOrderEvent extends Event {
395
829
  size: bigint;
396
830
  side: PerpetualsOrderSide;
397
831
  }
832
+ /**
833
+ * Event emitted when an existing order is reduced (partial cancellation or
834
+ * adjustment of size).
835
+ */
398
836
  export interface ReducedOrderEvent extends Event {
399
837
  marketId: PerpetualsMarketId;
400
838
  accountId: PerpetualsAccountId;
401
839
  sizeChange: bigint;
402
840
  orderId: PerpetualsOrderId;
403
841
  }
842
+ /**
843
+ * Type guard for {@link CanceledOrderEvent}.
844
+ */
404
845
  export declare const isCanceledOrderEvent: (event: Event) => event is CanceledOrderEvent;
846
+ /**
847
+ * Type guard for {@link PostedOrderEvent}.
848
+ */
405
849
  export declare const isPostedOrderEvent: (event: Event) => event is PostedOrderEvent;
850
+ /**
851
+ * Type guard for {@link FilledMakerOrdersEvent}.
852
+ */
406
853
  export declare const isFilledMakerOrdersEvent: (event: Event) => event is FilledMakerOrdersEvent;
854
+ /**
855
+ * Type guard for {@link FilledTakerOrderEvent}.
856
+ */
407
857
  export declare const isFilledTakerOrderEvent: (event: Event) => event is FilledTakerOrderEvent;
858
+ /**
859
+ * Type guard for {@link ReducedOrderEvent}.
860
+ */
408
861
  export declare const isReducedOrderEvent: (event: Event) => event is ReducedOrderEvent;
862
+ /**
863
+ * Event emitted when a stop order ticket is created.
864
+ *
865
+ * Stop order tickets represent off-chain-executable stop orders that
866
+ * executors can trigger.
867
+ */
409
868
  export interface CreatedStopOrderTicketEvent extends Event {
410
869
  ticketId: ObjectId;
411
870
  accountId: PerpetualsAccountId;
@@ -413,19 +872,29 @@ export interface CreatedStopOrderTicketEvent extends Event {
413
872
  executors: SuiAddress[];
414
873
  gas: Balance;
415
874
  stopOrderType: PerpetualsStopOrderType;
875
+ /** Encrypted stop-order details (payload). */
416
876
  encryptedDetails: Byte[];
417
877
  }
878
+ /**
879
+ * Event emitted when a stop order ticket is executed.
880
+ */
418
881
  export interface ExecutedStopOrderTicketEvent extends Event {
419
882
  ticketId: ObjectId;
420
883
  accountId: PerpetualsAccountId;
421
884
  executor: SuiAddress;
422
885
  }
886
+ /**
887
+ * Event emitted when a stop order ticket is deleted or canceled.
888
+ */
423
889
  export interface DeletedStopOrderTicketEvent extends Event {
424
890
  ticketId: ObjectId;
425
891
  accountId: PerpetualsAccountId;
426
892
  subAccountId?: ObjectId;
427
893
  executor: SuiAddress;
428
894
  }
895
+ /**
896
+ * Event emitted when the details (payload) of a stop order ticket are edited.
897
+ */
429
898
  export interface EditedStopOrderTicketDetailsEvent extends Event {
430
899
  ticketId: ObjectId;
431
900
  accountId: PerpetualsAccountId;
@@ -433,23 +902,38 @@ export interface EditedStopOrderTicketDetailsEvent extends Event {
433
902
  encryptedDetails: Byte[];
434
903
  stopOrderType: PerpetualsStopOrderType;
435
904
  }
905
+ /**
906
+ * Event emitted when the set of executors for a stop order ticket is edited.
907
+ */
436
908
  export interface EditedStopOrderTicketExecutorEvent extends Event {
437
909
  ticketId: ObjectId;
438
910
  accountId: PerpetualsAccountId;
439
911
  subAccountId?: ObjectId;
440
912
  executors: SuiAddress[];
441
913
  }
914
+ /**
915
+ * Event emitted when deallocated collateral is transferred from a clearing
916
+ * house to an account or subaccount.
917
+ */
442
918
  export interface TransferredDeallocatedCollateralEvent extends Event {
443
919
  chId: ObjectId;
920
+ /** Account or SubAccount object id. */
444
921
  objectId: ObjectId;
445
922
  accountId: PerpetualsAccountId;
446
923
  collateral: Balance;
447
924
  }
925
+ /**
926
+ * Event emitted when an account or subaccount receives collateral.
927
+ */
448
928
  export interface ReceivedCollateralEvent extends Event {
929
+ /** Account or SubAccount object id. */
449
930
  objectId: ObjectId;
450
931
  accountId: PerpetualsAccountId;
451
932
  collateral: Balance;
452
933
  }
934
+ /**
935
+ * Event emitted when premium TWAP is updated for a market.
936
+ */
453
937
  export interface UpdatedPremiumTwapEvent extends Event {
454
938
  marketId: PerpetualsMarketId;
455
939
  bookPrice: number;
@@ -457,6 +941,9 @@ export interface UpdatedPremiumTwapEvent extends Event {
457
941
  premiumTwap: number;
458
942
  premiumTwapLastUpdateMs: number;
459
943
  }
944
+ /**
945
+ * Event emitted when spread TWAP is updated for a market.
946
+ */
460
947
  export interface UpdatedSpreadTwapEvent extends Event {
461
948
  marketId: PerpetualsMarketId;
462
949
  bookPrice: number;
@@ -464,44 +951,91 @@ export interface UpdatedSpreadTwapEvent extends Event {
464
951
  spreadTwap: number;
465
952
  spreadTwapLastUpdateMs: number;
466
953
  }
954
+ /**
955
+ * Union of all TWAP-related events.
956
+ */
467
957
  export type PerpetualsTwapEvent = UpdatedPremiumTwapEvent | UpdatedSpreadTwapEvent;
958
+ /**
959
+ * Type guard for {@link UpdatedPremiumTwapEvent}.
960
+ */
468
961
  export declare const isUpdatedPremiumTwapEvent: (event: Event) => event is UpdatedPremiumTwapEvent;
962
+ /**
963
+ * Type guard for {@link UpdatedSpreadTwapEvent}.
964
+ */
469
965
  export declare const isUpdatedSpreadTwapEvent: (event: Event) => event is UpdatedSpreadTwapEvent;
966
+ /**
967
+ * Event emitted when market funding values are updated.
968
+ */
470
969
  export interface UpdatedFundingEvent extends Event {
471
970
  marketId: PerpetualsMarketId;
472
971
  cumFundingRateLong: number;
473
972
  cumFundingRateShort: number;
474
973
  fundingLastUpdateMs: Timestamp;
475
974
  }
975
+ /**
976
+ * Type guard for {@link UpdatedFundingEvent}.
977
+ */
476
978
  export declare const isUpdatedFundingEvent: (event: Event) => event is UpdatedFundingEvent;
979
+ /**
980
+ * Request body for fetching all account caps owned by a given wallet.
981
+ */
477
982
  export interface ApiPerpetualsOwnedAccountCapsBody {
478
983
  walletAddress: SuiAddress;
479
984
  }
985
+ /**
986
+ * Request body for fetching specific account caps by their object IDs.
987
+ */
480
988
  export interface ApiPerpetualsAccountCapsBody {
481
989
  accountCapIds: ObjectId[];
482
990
  }
991
+ export type ApiPerpetualsAccountMarginHistoryBody = ApiDataWithCursorBody<Timestamp> & {
992
+ accountId: PerpetualsAccountId;
993
+ collateralCoinType: CoinType;
994
+ };
995
+ /**
996
+ * Request body for fetching account-level order history with a cursor.
997
+ */
483
998
  export type ApiPerpetualsAccountOrderHistoryBody = ApiDataWithCursorBody<Timestamp> & {
484
999
  accountId: PerpetualsAccountId;
485
1000
  };
1001
+ /**
1002
+ * Request body for fetching account collateral history with a cursor.
1003
+ */
486
1004
  export type ApiPerpetualsAccountCollateralHistoryBody = ApiDataWithCursorBody<Timestamp> & {
487
1005
  accountId: PerpetualsAccountId;
488
1006
  collateralCoinType: CoinType;
489
1007
  };
1008
+ /**
1009
+ * Request body for previewing a market order placement (before sending a tx).
1010
+ *
1011
+ * This version is used by the API and includes account or vault context.
1012
+ */
490
1013
  export type ApiPerpetualsPreviewPlaceMarketOrderBody = Omit<ApiPerpetualsMarketOrderBody, "collateralChange" | "walletAddress" | "hasPosition" | "txKind" | "accountId" | "slTp"> & {
1014
+ /** Optional leverage override for the preview. */
491
1015
  leverage?: number;
492
1016
  } & ({
493
1017
  accountId: PerpetualsAccountId | undefined;
494
1018
  } | {
495
1019
  vaultId: ObjectId | undefined;
496
1020
  });
1021
+ /**
1022
+ * Request body for previewing a limit order placement (before sending a tx).
1023
+ *
1024
+ * This version is used by the API and includes account or vault context.
1025
+ */
497
1026
  export type ApiPerpetualsPreviewPlaceLimitOrderBody = Omit<ApiPerpetualsLimitOrderBody, "collateralChange" | "walletAddress" | "hasPosition" | "txKind" | "accountId" | "slTp"> & {
1027
+ /** Optional leverage override for the preview. */
498
1028
  leverage?: number;
499
1029
  } & ({
500
1030
  accountId: PerpetualsAccountId | undefined;
501
1031
  } | {
502
1032
  vaultId: ObjectId | undefined;
503
1033
  });
1034
+ /**
1035
+ * Request body for previewing cancel-order operations.
1036
+ */
504
1037
  export type ApiPerpetualsPreviewCancelOrdersBody = {
1038
+ /** Per-market mapping of order IDs to cancel. */
505
1039
  marketIdsToData: Record<PerpetualsMarketId, {
506
1040
  orderIds: PerpetualsOrderId[];
507
1041
  }>;
@@ -510,6 +1044,9 @@ export type ApiPerpetualsPreviewCancelOrdersBody = {
510
1044
  } | {
511
1045
  vaultId: ObjectId;
512
1046
  });
1047
+ /**
1048
+ * Request body for previewing a leverage change for a given position.
1049
+ */
513
1050
  export type ApiPerpetualsPreviewSetLeverageBody = {
514
1051
  marketId: PerpetualsMarketId;
515
1052
  leverage: number;
@@ -518,16 +1055,46 @@ export type ApiPerpetualsPreviewSetLeverageBody = {
518
1055
  } | {
519
1056
  vaultId: ObjectId;
520
1057
  });
1058
+ /**
1059
+ * Request body for previewing a collateral allocation/deallocation for a given position.
1060
+ */
1061
+ export type ApiPerpetualsPreviewEditCollateralBody = {
1062
+ marketId: PerpetualsMarketId;
1063
+ collateralChange: Balance;
1064
+ } & ({
1065
+ accountId: PerpetualsAccountId;
1066
+ } | {
1067
+ vaultId: ObjectId;
1068
+ });
1069
+ /**
1070
+ * Response type for a leverage preview request.
1071
+ *
1072
+ * Either returns an error, or the position and collateral after the change.
1073
+ */
521
1074
  export type ApiPerpetualsPreviewSetLeverageResponse = {
522
1075
  error: string;
523
1076
  } | {
524
- positionAfterSetLeverage: PerpetualsPosition;
1077
+ updatedPosition: PerpetualsPosition;
525
1078
  collateralChange: number;
526
1079
  };
1080
+ /**
1081
+ * Response type for a allocate/deallocate collateral preview request.
1082
+ *
1083
+ * Either returns an error, or the position and collateral after the change.
1084
+ */
1085
+ export type ApiPerpetualsPreviewEditCollateralResponse = {
1086
+ error: string;
1087
+ } | {
1088
+ updatedPosition: PerpetualsPosition;
1089
+ collateralChange: number;
1090
+ };
1091
+ /**
1092
+ * Generic response type for a place-order preview (market or limit).
1093
+ */
527
1094
  export type ApiPerpetualsPreviewPlaceOrderResponse = {
528
1095
  error: string;
529
1096
  } | {
530
- positionAfterOrder: PerpetualsPosition;
1097
+ updatedPosition: PerpetualsPosition;
531
1098
  priceSlippage: number;
532
1099
  percentSlippage: Percentage;
533
1100
  filledSize: number;
@@ -537,28 +1104,50 @@ export type ApiPerpetualsPreviewPlaceOrderResponse = {
537
1104
  collateralChange: number;
538
1105
  executionPrice: number;
539
1106
  };
1107
+ /**
1108
+ * Response type for cancel-order preview.
1109
+ */
540
1110
  export type ApiPerpetualsPreviewCancelOrdersResponse = {
541
1111
  error: string;
542
1112
  } | {
543
- marketIdsToPositionAfterCancelOrders: Record<PerpetualsMarketId, PerpetualsPosition>;
1113
+ updatedPositions: PerpetualsPosition[];
544
1114
  collateralChange: number;
545
1115
  };
1116
+ /**
1117
+ * Request body for computing an execution price for a hypothetical trade
1118
+ * using the current orderbook state and oracle prices.
1119
+ */
546
1120
  export interface ApiPerpetualsExecutionPriceBody {
547
1121
  side: PerpetualsOrderSide;
548
1122
  size: bigint;
1123
+ /** Lot size used to discretize the order size. */
549
1124
  lotSize: number;
1125
+ /** Available collateral. */
550
1126
  collateral: Balance;
1127
+ /** Oracle ID for the base price. */
551
1128
  basePriceFeedId: ObjectId;
1129
+ /** Oracle ID for the collateral price. */
552
1130
  collateralPriceFeedId: ObjectId;
1131
+ /** Optional user-specified price constraint. */
553
1132
  price?: number;
554
1133
  }
1134
+ /**
1135
+ * Response body for execution price previews.
1136
+ */
555
1137
  export interface ApiPerpetualsExecutionPriceResponse {
556
1138
  executionPrice: number;
557
1139
  sizeFilled: number;
558
1140
  sizePosted: number;
559
1141
  fills: PerpetualsFilledOrderData[];
560
1142
  }
1143
+ /**
1144
+ * Response type for historical market candle data.
1145
+ */
561
1146
  export type ApiPerpetualsHistoricalMarketDataResponse = PerpetualsMarketCandleDataPoint[];
1147
+ /**
1148
+ * Request body for computing the maximum order size for an account in a
1149
+ * given market.
1150
+ */
562
1151
  export interface ApiPerpetualsMaxOrderSizeBody {
563
1152
  marketId: PerpetualsMarketId;
564
1153
  accountId: PerpetualsAccountId;
@@ -566,6 +1155,9 @@ export interface ApiPerpetualsMaxOrderSizeBody {
566
1155
  leverage?: number;
567
1156
  price?: number;
568
1157
  }
1158
+ /**
1159
+ * Request body for fetching enriched order data for an account.
1160
+ */
569
1161
  export interface ApiPerpetualsAccountOrderDatasBody {
570
1162
  accountId: PerpetualsAccountId;
571
1163
  orderDatas: {
@@ -573,6 +1165,12 @@ export interface ApiPerpetualsAccountOrderDatasBody {
573
1165
  currentSize: bigint;
574
1166
  }[];
575
1167
  }
1168
+ /**
1169
+ * (Duplicated) request body for fetching enriched order data for an account.
1170
+ *
1171
+ * NOTE: This is intentionally left for compatibility; both interfaces are
1172
+ * identical.
1173
+ */
576
1174
  export interface ApiPerpetualsAccountOrderDatasBody {
577
1175
  accountId: PerpetualsAccountId;
578
1176
  orderDatas: {
@@ -580,24 +1178,38 @@ export interface ApiPerpetualsAccountOrderDatasBody {
580
1178
  currentSize: bigint;
581
1179
  }[];
582
1180
  }
583
- export interface ApiPerpetualsAccountStopOrderDatasBody {
584
- accountId: PerpetualsAccountId;
1181
+ /**
1182
+ * Request body for fetching stop-order data associated with an account or vault,
1183
+ * validated using a wallet signature.
1184
+ */
1185
+ export type ApiPerpetualsStopOrderDatasBody = {
585
1186
  walletAddress: SuiAddress;
586
1187
  bytes: string;
587
1188
  signature: string;
588
- marketIds: PerpetualsMarketId[];
589
- }
1189
+ marketIds?: PerpetualsMarketId[];
1190
+ } & ({
1191
+ accountId: PerpetualsAccountId;
1192
+ } | {
1193
+ vaultId: ObjectId;
1194
+ });
1195
+ /**
1196
+ * Request body for creating a vault capability (vault cap) for a given wallet.
1197
+ */
590
1198
  export interface ApiPerpetualsCreateVaultCapBody {
591
1199
  walletAddress: SuiAddress;
592
1200
  }
1201
+ /**
1202
+ * Request body for creating a new vault with initial deposit.
1203
+ *
1204
+ * The deposit can be specified either:
1205
+ * - As a numeric `initialDepositAmount`, or
1206
+ * - As an existing `depositCoinArg` (coin object).
1207
+ */
593
1208
  export type ApiPerpetualsCreateVaultBody = {
594
1209
  name: string;
595
1210
  walletAddress: SuiAddress;
596
1211
  lpCoinType: CoinType;
597
1212
  collateralCoinType: CoinType;
598
- collateralOracleId: ObjectId;
599
- collateralPriceFeedId: ObjectId;
600
- collateralPriceFeedTolerance: bigint;
601
1213
  lockPeriodMs: bigint;
602
1214
  ownerFeePercentage: Percentage;
603
1215
  forceWithdrawDelayMs: bigint;
@@ -608,11 +1220,22 @@ export type ApiPerpetualsCreateVaultBody = {
608
1220
  } | {
609
1221
  initialDepositCoinArg: TransactionObjectArgument;
610
1222
  });
1223
+ /**
1224
+ * Request body for creating a new perpetuals account for a given wallet
1225
+ * and collateral coin type.
1226
+ */
611
1227
  export interface ApiPerpetualsCreateAccountBody {
612
1228
  walletAddress: SuiAddress;
613
1229
  collateralCoinType: CoinType;
614
1230
  txKind?: SerializedTransaction;
615
1231
  }
1232
+ /**
1233
+ * Request body for depositing collateral into a perpetuals account or vault.
1234
+ *
1235
+ * The deposit can be provided by:
1236
+ * - `depositAmount` (numeric amount), or
1237
+ * - `depositCoinArg` (Sui coin object).
1238
+ */
616
1239
  export type ApiPerpetualsDepositCollateralBody = {
617
1240
  walletAddress: SuiAddress;
618
1241
  collateralCoinType: CoinType;
@@ -627,10 +1250,14 @@ export type ApiPerpetualsDepositCollateralBody = {
627
1250
  } | {
628
1251
  vaultId: ObjectId;
629
1252
  });
1253
+ /**
1254
+ * Request body for withdrawing collateral from an account or vault.
1255
+ */
630
1256
  export type ApiPerpetualsWithdrawCollateralBody = {
631
1257
  walletAddress: SuiAddress;
632
1258
  collateralCoinType: CoinType;
633
1259
  withdrawAmount: Balance;
1260
+ /** Optional destination wallet address; defaults to owner if omitted. */
634
1261
  recipientAddress?: SuiAddress;
635
1262
  txKind?: SerializedTransaction;
636
1263
  } & ({
@@ -638,10 +1265,18 @@ export type ApiPerpetualsWithdrawCollateralBody = {
638
1265
  } | {
639
1266
  vaultId: ObjectId;
640
1267
  });
1268
+ /**
1269
+ * Response body for withdraw-collateral transactions.
1270
+ *
1271
+ * The SDK typically uses `txKind` to reconstruct a transaction locally.
1272
+ */
641
1273
  export interface ApiPerpetualsWithdrawCollateralResponse {
642
1274
  txKind: SerializedTransaction;
643
1275
  coinOutArg: TransactionObjectArgument;
644
1276
  }
1277
+ /**
1278
+ * Request body for transferring collateral between two perpetuals accounts.
1279
+ */
645
1280
  export interface ApiPerpetualsTransferCollateralBody {
646
1281
  walletAddress: SuiAddress;
647
1282
  collateralCoinType: CoinType;
@@ -650,6 +1285,9 @@ export interface ApiPerpetualsTransferCollateralBody {
650
1285
  transferAmount: Balance;
651
1286
  txKind?: SerializedTransaction;
652
1287
  }
1288
+ /**
1289
+ * Request body for allocating collateral to a given market (account/vault).
1290
+ */
653
1291
  export type ApiPerpetualsAllocateCollateralBody = {
654
1292
  marketId: PerpetualsMarketId;
655
1293
  allocateAmount: Balance;
@@ -659,6 +1297,9 @@ export type ApiPerpetualsAllocateCollateralBody = {
659
1297
  } | {
660
1298
  vaultId: ObjectId;
661
1299
  });
1300
+ /**
1301
+ * Request body for deallocating collateral from a given market (account/vault).
1302
+ */
662
1303
  export type ApiPerpetualsDeallocateCollateralBody = {
663
1304
  marketId: PerpetualsMarketId;
664
1305
  deallocateAmount: Balance;
@@ -668,12 +1309,24 @@ export type ApiPerpetualsDeallocateCollateralBody = {
668
1309
  } | {
669
1310
  vaultId: ObjectId;
670
1311
  });
1312
+ /**
1313
+ * SDK-level inputs for placing one or more stop orders.
1314
+ *
1315
+ * This is a client-facing type that wraps the on-chain format.
1316
+ */
671
1317
  export interface SdkPerpetualsPlaceStopOrdersInputs {
1318
+ /** Stop orders to place (without objectId, which is created on-chain). */
672
1319
  stopOrders: Omit<PerpetualsStopOrderData, "objectId">[];
1320
+ /** Optional transaction to embed the call in. */
673
1321
  tx?: Transaction;
1322
+ /** Optional gas coin for sponsored or custom gas usage. */
674
1323
  gasCoinArg?: TransactionObjectArgument;
1324
+ /** Whether the transaction is expected to be sponsored by the API. */
675
1325
  isSponsoredTx?: boolean;
676
1326
  }
1327
+ /**
1328
+ * Request body for placing stop orders via the API.
1329
+ */
677
1330
  export type ApiPerpetualsPlaceStopOrdersBody = {
678
1331
  walletAddress: SuiAddress;
679
1332
  stopOrders: Omit<PerpetualsStopOrderData, "objectId">[];
@@ -685,15 +1338,28 @@ export type ApiPerpetualsPlaceStopOrdersBody = {
685
1338
  } | {
686
1339
  vaultId: ObjectId;
687
1340
  });
1341
+ /**
1342
+ * SDK-level inputs for placing stop-loss / take-profit orders bound to a
1343
+ * specific market and position side.
1344
+ */
688
1345
  export type SdkPerpetualsPlaceSlTpOrdersInputs = {
689
1346
  marketId: PerpetualsMarketId;
1347
+ /** Optional target size for SL/TP orders (scaled base units). */
690
1348
  size?: bigint;
1349
+ /** Index price at which to trigger stop loss. */
691
1350
  stopLossIndexPrice?: number;
1351
+ /** Index price at which to trigger take profit. */
692
1352
  takeProfitIndexPrice?: number;
1353
+ /** Optional transaction to embed in. */
693
1354
  tx?: Transaction;
1355
+ /** Optional gas coin argument. */
694
1356
  gasCoinArg?: TransactionObjectArgument;
1357
+ /** Whether to treat the transaction as sponsored. */
695
1358
  isSponsoredTx?: boolean;
696
1359
  };
1360
+ /**
1361
+ * API request body for placing SL/TP orders bound to a position.
1362
+ */
697
1363
  export type ApiPerpetualsPlaceSlTpOrdersBody = {
698
1364
  marketId: PerpetualsMarketId;
699
1365
  walletAddress: SuiAddress;
@@ -710,6 +1376,10 @@ export type ApiPerpetualsPlaceSlTpOrdersBody = {
710
1376
  } | {
711
1377
  vaultId: ObjectId;
712
1378
  });
1379
+ /**
1380
+ * API request body for editing existing stop orders for an
1381
+ * account or vault.
1382
+ */
713
1383
  export type ApiPerpetualsEditStopOrdersBody = {
714
1384
  stopOrders: PerpetualsStopOrderData[];
715
1385
  txKind?: SerializedTransaction;
@@ -718,14 +1388,26 @@ export type ApiPerpetualsEditStopOrdersBody = {
718
1388
  } | {
719
1389
  vaultId: ObjectId;
720
1390
  });
1391
+ /**
1392
+ * API request body for placing a market order in a given market.
1393
+ *
1394
+ * This form is used by the backend and includes contextual information
1395
+ * like `accountId` or `vaultId`.
1396
+ */
721
1397
  export type ApiPerpetualsMarketOrderBody = {
722
1398
  marketId: PerpetualsMarketId;
723
1399
  side: PerpetualsOrderSide;
1400
+ /** Order size in scaled base units. */
724
1401
  size: bigint;
1402
+ /** Change in collateral allocated to this position (collateral units). */
725
1403
  collateralChange: number;
1404
+ /** Whether the account already has a position in this market. */
726
1405
  hasPosition: boolean;
1406
+ /** If true, order can only reduce an existing position. */
727
1407
  reduceOnly: boolean;
1408
+ /** Optional leverage override. */
728
1409
  leverage?: number;
1410
+ /** Optional SL/TP instructions to be placed along with the market order. */
729
1411
  slTp?: {
730
1412
  walletAddress: SuiAddress;
731
1413
  gasCoinArg?: TransactionObjectArgument;
@@ -734,23 +1416,36 @@ export type ApiPerpetualsMarketOrderBody = {
734
1416
  stopLossIndexPrice?: number;
735
1417
  takeProfitIndexPrice?: number;
736
1418
  };
1419
+ /** Optional serialized transaction kind if assembled by the API. */
737
1420
  txKind?: SerializedTransaction;
738
1421
  } & ({
739
1422
  accountId: PerpetualsAccountId;
740
1423
  } | {
741
1424
  vaultId: ObjectId;
742
1425
  });
1426
+ /**
1427
+ * API request body for placing a limit order in a given market.
1428
+ */
743
1429
  export type ApiPerpetualsLimitOrderBody = {
744
1430
  marketId: PerpetualsMarketId;
745
1431
  side: PerpetualsOrderSide;
1432
+ /** Order size in scaled base units. */
746
1433
  size: bigint;
1434
+ /** Limit price in scaled fixed-point representation. */
747
1435
  price: bigint;
1436
+ /** How the order behaves on the orderbook. */
748
1437
  orderType: PerpetualsOrderType;
1438
+ /** Change in collateral allocated to this position. */
749
1439
  collateralChange: number;
1440
+ /** Whether the account already has a position in this market. */
750
1441
  hasPosition: boolean;
1442
+ /** If true, order can only reduce an existing position. */
751
1443
  reduceOnly: boolean;
1444
+ /** Optional expiration for the order. */
752
1445
  expiryTimestamp?: bigint;
1446
+ /** Optional leverage override. */
753
1447
  leverage?: number;
1448
+ /** Optional SL/TP instructions to be placed along with the limit order. */
754
1449
  slTp?: {
755
1450
  walletAddress: SuiAddress;
756
1451
  gasCoinArg?: TransactionObjectArgument;
@@ -759,15 +1454,21 @@ export type ApiPerpetualsLimitOrderBody = {
759
1454
  stopLossIndexPrice?: number;
760
1455
  takeProfitIndexPrice?: number;
761
1456
  };
1457
+ /** Optionally pre-built transaction payload. */
762
1458
  txKind?: SerializedTransaction;
763
1459
  } & ({
764
1460
  accountId: PerpetualsAccountId;
765
1461
  } | {
766
1462
  vaultId: ObjectId;
767
1463
  });
1464
+ /**
1465
+ * API request body for canceling one or more orders for an
1466
+ * account or vault, per market.
1467
+ */
768
1468
  export type ApiPerpetualsCancelOrdersBody = {
769
1469
  marketIdsToData: Record<PerpetualsMarketId, {
770
1470
  orderIds: PerpetualsOrderId[];
1471
+ /** Collateral change associated with canceling these orders. */
771
1472
  collateralChange: number;
772
1473
  }>;
773
1474
  txKind?: SerializedTransaction;
@@ -776,6 +1477,9 @@ export type ApiPerpetualsCancelOrdersBody = {
776
1477
  } | {
777
1478
  vaultId: ObjectId;
778
1479
  });
1480
+ /**
1481
+ * API request body for canceling stop orders identified by object IDs.
1482
+ */
779
1483
  export type ApiPerpetualsCancelStopOrdersBody = {
780
1484
  stopOrderIds: ObjectId[];
781
1485
  txKind?: SerializedTransaction;
@@ -784,6 +1488,9 @@ export type ApiPerpetualsCancelStopOrdersBody = {
784
1488
  } | {
785
1489
  vaultId: ObjectId;
786
1490
  });
1491
+ /**
1492
+ * API body for setting leverage on an existing position.
1493
+ */
787
1494
  export type ApiPerpetualsSetLeverageTxBody = {
788
1495
  marketId: PerpetualsMarketId;
789
1496
  collateralChange: number;
@@ -794,70 +1501,125 @@ export type ApiPerpetualsSetLeverageTxBody = {
794
1501
  } | {
795
1502
  vaultId: ObjectId;
796
1503
  });
1504
+ /**
1505
+ * 24 hour statistics for a single perpetuals market.
1506
+ */
797
1507
  export interface PerpetualsMarket24hrStats {
1508
+ /** 24h volume in USD. */
798
1509
  volumeUsd: number;
1510
+ /** 24h volume in base asset units. */
799
1511
  volumeBaseAssetAmount: number;
1512
+ /** Absolute price change over 24 hours. */
800
1513
  priceChange: number;
1514
+ /** Relative price change percentage over 24 hours. */
801
1515
  priceChangePercentage: number;
802
1516
  }
1517
+ /**
1518
+ * Response type for requesting 24h stats for multiple markets.
1519
+ */
803
1520
  export type ApiPerpetualsMarkets24hrStatsResponse = PerpetualsMarket24hrStats[];
1521
+ /**
1522
+ * API body to process forced withdrawals in a vault.
1523
+ */
804
1524
  export interface ApiPerpetualsVaultProcessForceWithdrawsTxBody {
805
1525
  vaultId: ObjectId;
1526
+ /** Per-market sizes to close as part of force withdraw. */
806
1527
  sizesToClose: Record<PerpetualsMarketId, Balance>;
807
1528
  txKind?: SerializedTransaction;
808
1529
  }
1530
+ /**
1531
+ * API body to process regular withdraw requests for a vault.
1532
+ */
809
1533
  export interface ApiPerpetualsVaultProcessWithdrawRequestsTxBody {
810
1534
  vaultId: ObjectId;
811
1535
  userAddresses: SuiAddress[];
812
1536
  txKind?: SerializedTransaction;
813
1537
  }
1538
+ /**
1539
+ * API body to update slippage parameters for pending vault withdraw
1540
+ * requests across several vaults.
1541
+ */
814
1542
  export interface ApiPerpetualsVaultUpdateWithdrawRequestSlippagesTxBody {
815
1543
  vaultIds: ObjectId[];
816
1544
  minLpAmountsOut: Balance[];
817
1545
  txKind?: SerializedTransaction;
818
1546
  }
1547
+ /**
1548
+ * API body to update the force-withdrawal delay in a vault.
1549
+ */
819
1550
  export interface ApiPerpetualsVaultUpdateForceWithdrawDelayTxBody {
820
1551
  vaultId: ObjectId;
821
1552
  forceWithdrawDelayMs: bigint;
822
1553
  txKind?: SerializedTransaction;
823
1554
  }
1555
+ /**
1556
+ * API body to update the lock period on a vault.
1557
+ */
824
1558
  export interface ApiPerpetualsVaultUpdateLockPeriodTxBody {
825
1559
  vaultId: ObjectId;
826
1560
  lockPeriodMs: bigint;
827
1561
  txKind?: SerializedTransaction;
828
1562
  }
1563
+ /**
1564
+ * API body to update the owner's fee percentage on a vault.
1565
+ */
829
1566
  export interface ApiPerpetualsVaultUpdateOwnerFeePercentageTxBody {
830
1567
  vaultId: ObjectId;
831
1568
  ownerFeePercentage: number;
832
1569
  txKind?: SerializedTransaction;
833
1570
  }
1571
+ /**
1572
+ * API body for the vault owner withdrawing collected fees.
1573
+ */
834
1574
  export interface ApiPerpetualsVaultWithdrawOwnerFeesTxBody {
835
1575
  vaultId: ObjectId;
836
1576
  withdrawAmount: Balance;
837
1577
  recipientAddress?: SuiAddress;
838
1578
  txKind?: SerializedTransaction;
839
1579
  }
1580
+ /**
1581
+ * Response for owner-fee withdrawal transactions.
1582
+ */
840
1583
  export interface ApiPerpetualsVaultWithdrawOwnerFeesTxResponse {
841
1584
  txKind: SerializedTransaction;
842
1585
  coinOutArg: TransactionObjectArgument | undefined;
843
1586
  }
844
- export interface ApiPerpetualsVaultAllWithdrawRequestsBody {
845
- vaultId: ObjectId;
1587
+ /**
1588
+ * Request body for fetching all withdrawal requests for specific vaults.
1589
+ */
1590
+ export interface ApiPerpetualsVaultsWithdrawRequestsBody {
1591
+ vaultIds: ObjectId[];
846
1592
  }
1593
+ /**
1594
+ * Request body for fetching withdrawal requests for a given wallet across
1595
+ * its vault positions.
1596
+ */
847
1597
  export interface ApiPerpetualsVaultWithdrawRequestsBody {
848
1598
  walletAddress: SuiAddress;
849
1599
  }
1600
+ /**
1601
+ * API body for creating a single withdraw request from a vault.
1602
+ */
850
1603
  export interface ApiPerpetualsVaultCreateWithdrawRequestTxBody {
851
1604
  vaultId: ObjectId;
1605
+ walletAddress: SuiAddress;
852
1606
  lpWithdrawAmount: Balance;
853
1607
  minLpWithdrawAmount: Balance;
854
1608
  txKind?: SerializedTransaction;
855
1609
  }
1610
+ /**
1611
+ * API body for canceling withdrawal requests across vaults for a wallet.
1612
+ */
856
1613
  export interface ApiPerpetualsVaultCancelWithdrawRequestsTxBody {
857
1614
  vaultIds: ObjectId[];
858
1615
  walletAddress: SuiAddress;
859
1616
  txKind?: SerializedTransaction;
860
1617
  }
1618
+ /**
1619
+ * Request body for depositing into a vault.
1620
+ *
1621
+ * Deposit can be specified as a numeric amount or as an existing coin object.
1622
+ */
861
1623
  export type ApiPerpetualsVaultDepositTxBody = {
862
1624
  vaultId: ObjectId;
863
1625
  walletAddress: SuiAddress;
@@ -866,47 +1628,90 @@ export type ApiPerpetualsVaultDepositTxBody = {
866
1628
  isSponsoredTx?: boolean;
867
1629
  } & ({
868
1630
  depositAmount: Balance;
1631
+ collateralCoinType: CoinType;
869
1632
  } | {
870
1633
  depositCoinArg: TransactionObjectArgument;
871
1634
  });
1635
+ /**
1636
+ * Request body for previewing a vault withdrawal request.
1637
+ */
872
1638
  export interface ApiPerpetualsVaultPreviewCreateWithdrawRequestBody {
873
1639
  vaultId: ObjectId;
874
1640
  lpWithdrawAmount: Balance;
875
1641
  }
1642
+ /**
1643
+ * Response body for vault withdrawal preview.
1644
+ */
876
1645
  export interface ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse {
877
- collateralAmountOut: number;
878
- collateralAmountOutUsd: number;
1646
+ collateralAmountOut: Balance;
1647
+ collateralPrice: number;
879
1648
  }
1649
+ /**
1650
+ * Request body for previewing a vault deposit.
1651
+ */
880
1652
  export interface ApiPerpetualsVaultPreviewDepositBody {
881
1653
  vaultId: ObjectId;
882
1654
  depositAmount: Balance;
883
1655
  }
1656
+ /**
1657
+ * Response body for vault deposit preview.
1658
+ */
884
1659
  export interface ApiPerpetualsVaultPreviewDepositResponse {
885
- lpAmountOut: number;
1660
+ lpAmountOut: Balance;
1661
+ collateralPrice: number;
1662
+ depositedAmountUsd: number;
886
1663
  }
1664
+ /**
1665
+ * Request body for previewing forced withdraw processing for a vault.
1666
+ */
887
1667
  export interface ApiPerpetualsVaultPreviewProcessForceWithdrawBody {
888
1668
  vaultId: ObjectId;
889
1669
  walletAddress: SuiAddress;
890
1670
  }
1671
+ /**
1672
+ * Response body for forced withdraw processing preview.
1673
+ */
891
1674
  export interface ApiPerpetualsVaultPreviewProcessForceWithdrawResponse {
892
- collateralAmountOut: number;
893
- collateralAmountOutUsd: number;
894
- sizesToClose: Record<PerpetualsMarketId, Balance>;
1675
+ collateralAmountOut: Balance;
1676
+ collateralPrice: number;
1677
+ sizesToClose: Record<PerpetualsMarketId, bigint>;
895
1678
  }
1679
+ /**
1680
+ * Request body for previewing normal withdraw requests processing for a vault.
1681
+ */
896
1682
  export interface ApiPerpetualsVaultPreviewProcessWithdrawRequestsBody {
897
1683
  vaultId: ObjectId;
898
1684
  userAddresses: SuiAddress[];
899
1685
  }
900
- export type ApiPerpetualsVaultPreviewProcessWithdrawRequestsResponse = {
901
- lpAmountOut: number;
902
- }[];
1686
+ /**
1687
+ * Response body for previewing normal withdraw requests processing.
1688
+ */
1689
+ export interface ApiPerpetualsVaultPreviewProcessWithdrawRequestsResponse {
1690
+ userPreviews: {
1691
+ userAddress: SuiAddress;
1692
+ lpAmountOut: number;
1693
+ }[];
1694
+ collateralPrice: number;
1695
+ }
1696
+ /**
1697
+ * Request body for previewing maximum owner fees withdrawable from a vault.
1698
+ */
903
1699
  export interface ApiPerpetualsVaultPreviewWithdrawOwnerFeesBody {
904
1700
  vaultId: ObjectId;
905
1701
  }
1702
+ /**
1703
+ * Response body for previewing vault owner fee withdrawal.
1704
+ */
906
1705
  export interface ApiPerpetualsVaultPreviewWithdrawOwnerFeesResponse {
907
1706
  maxFeesToWithdraw: Balance;
908
1707
  feeCoinType: CoinType;
909
1708
  }
1709
+ /**
1710
+ * SDK-level inputs for placing a market order from a client.
1711
+ *
1712
+ * This omits server-managed fields like `accountId`, `hasPosition`,
1713
+ * and serialized `txKind`, and exposes a client-friendly `slTp` wrapper.
1714
+ */
910
1715
  export type SdkPerpetualsPlaceMarketOrderInputs = Omit<ApiPerpetualsMarketOrderBody, "accountId" | "hasPosition" | "txKind" | "slTp"> & {
911
1716
  tx?: Transaction;
912
1717
  slTp?: {
@@ -917,6 +1722,9 @@ export type SdkPerpetualsPlaceMarketOrderInputs = Omit<ApiPerpetualsMarketOrderB
917
1722
  takeProfitIndexPrice?: number;
918
1723
  };
919
1724
  };
1725
+ /**
1726
+ * SDK-level inputs for placing a limit order from a client.
1727
+ */
920
1728
  export type SdkPerpetualsPlaceLimitOrderInputs = Omit<ApiPerpetualsLimitOrderBody, "accountId" | "hasPosition" | "txKind" | "slTp"> & {
921
1729
  tx?: Transaction;
922
1730
  slTp?: {
@@ -927,15 +1735,35 @@ export type SdkPerpetualsPlaceLimitOrderInputs = Omit<ApiPerpetualsLimitOrderBod
927
1735
  takeProfitIndexPrice?: number;
928
1736
  };
929
1737
  };
1738
+ /**
1739
+ * SDK-level inputs for previewing a market order.
1740
+ */
930
1741
  export type SdkPerpetualsPlaceMarketOrderPreviewInputs = Omit<ApiPerpetualsPreviewPlaceMarketOrderBody, "collateralCoinType" | "accountId">;
1742
+ /**
1743
+ * SDK-level inputs for previewing a limit order.
1744
+ */
931
1745
  export type SdkPerpetualsPlaceLimitOrderPreviewInputs = Omit<ApiPerpetualsPreviewPlaceLimitOrderBody, "collateralCoinType" | "accountId">;
1746
+ /**
1747
+ * SDK-level inputs for previewing order cancellations.
1748
+ */
932
1749
  export type SdkPerpetualsCancelOrdersPreviewInputs = Omit<ApiPerpetualsPreviewCancelOrdersBody, "collateralCoinType" | "accountId">;
1750
+ /**
1751
+ * Action for websocket subscription messages.
1752
+ */
933
1753
  export type PerpetualsWsUpdatesSubscriptionAction = "subscribe" | "unsubscribe";
1754
+ /**
1755
+ * Websocket subscription payload for subscribing to a specific market's
1756
+ * updates (orderbook, prices, etc.).
1757
+ */
934
1758
  export interface PerpetualsWsUpdatesMarketSubscriptionType {
935
1759
  market: {
936
1760
  marketId: PerpetualsMarketId;
937
1761
  };
938
1762
  }
1763
+ /**
1764
+ * Websocket subscription payload for subscribing to user/account updates,
1765
+ * optionally including stop-order data (via signature).
1766
+ */
939
1767
  export interface PerpetualsWsUpdatesUserSubscriptionType {
940
1768
  user: {
941
1769
  accountId: PerpetualsAccountId;
@@ -946,61 +1774,106 @@ export interface PerpetualsWsUpdatesUserSubscriptionType {
946
1774
  } | undefined;
947
1775
  };
948
1776
  }
1777
+ /**
1778
+ * Websocket subscription payload for market oracle price updates.
1779
+ */
949
1780
  export interface PerpetualsWsUpdatesOracleSubscriptionType {
950
1781
  oracle: {
951
1782
  marketId: PerpetualsMarketId;
952
1783
  };
953
1784
  }
1785
+ /**
1786
+ * Websocket subscription payload for orderbook updates.
1787
+ */
954
1788
  export interface PerpetualsWsUpdatesOrderbookSubscriptionType {
955
1789
  orderbook: {
956
1790
  marketId: PerpetualsMarketId;
957
1791
  };
958
1792
  }
1793
+ /**
1794
+ * Websocket subscription payload for market trades stream.
1795
+ */
959
1796
  export interface PerpetualsWsUpdatesMarketTradesSubscriptionType {
960
1797
  marketTrades: {
961
1798
  marketId: PerpetualsMarketId;
962
1799
  };
963
1800
  }
1801
+ /**
1802
+ * Websocket subscription payload for user-specific trade updates.
1803
+ */
964
1804
  export interface PerpetualsWsUpdatesUserTradesSubscriptionType {
965
1805
  userTrades: {
966
1806
  accountId: PerpetualsAccountId;
967
1807
  };
968
1808
  }
1809
+ /**
1810
+ * Websocket subscription payload for user-specific collateral changes.
1811
+ */
969
1812
  export interface PerpetualsWsUpdatesUserCollateralChangesSubscriptionType {
970
1813
  userCollateralChanges: {
971
1814
  accountId: PerpetualsAccountId;
972
1815
  };
973
1816
  }
1817
+ /**
1818
+ * Union of all websocket subscription types for perpetuals updates.
1819
+ */
974
1820
  export type PerpetualsWsUpdatesSubscriptionType = PerpetualsWsUpdatesMarketSubscriptionType | PerpetualsWsUpdatesUserSubscriptionType | PerpetualsWsUpdatesOracleSubscriptionType | PerpetualsWsUpdatesOrderbookSubscriptionType | PerpetualsWsUpdatesMarketTradesSubscriptionType | PerpetualsWsUpdatesUserTradesSubscriptionType | PerpetualsWsUpdatesUserCollateralChangesSubscriptionType;
1821
+ /**
1822
+ * Websocket payload for oracle price updates.
1823
+ */
975
1824
  export interface PerpetualsWsUpdatesOraclePayload {
976
- priceFeedId: ObjectId;
977
- price: number;
978
- isBasePriceFeed: boolean;
1825
+ marketId: PerpetualsMarketId;
1826
+ basePrice: number;
1827
+ collateralPrice: number;
979
1828
  }
1829
+ /**
1830
+ * Websocket payload for market trades stream.
1831
+ */
980
1832
  export interface PerpetualsWsUpdatesMarketTradesPayload {
981
1833
  marketId: PerpetualsMarketId;
982
1834
  trades: PerpetualsTradeHistoryData[];
983
1835
  }
1836
+ /**
1837
+ * Websocket payload for user-specific trades stream.
1838
+ */
984
1839
  export interface PerpetualsWsUpdatesUserTradesPayload {
985
1840
  accountId: PerpetualsAccountId;
986
1841
  trades: PerpetualsAccountTrade[];
987
1842
  }
1843
+ /**
1844
+ * Websocket payload for user-specific collateral changes.
1845
+ */
988
1846
  export interface PerpetualsWsUpdatesUserCollateralChangesPayload {
989
1847
  accountId: PerpetualsAccountId;
990
1848
  collateralChanges: PerpetualsAccountCollateralChange[];
991
1849
  }
1850
+ /**
1851
+ * Websocket payload for incremental orderbook updates.
1852
+ */
992
1853
  export interface PerpetualsWsUpdatesOrderbookPayload {
993
1854
  marketId: PerpetualsMarketId;
994
1855
  orderbookDeltas: PerpetualsOrderbookDeltas;
995
1856
  }
1857
+ /**
1858
+ * Websocket payload for user account and stop-order updates.
1859
+ */
996
1860
  export interface PerpetualsWsUpdatesUserPayload {
997
1861
  account: PerpetualsAccountObject;
998
1862
  stopOrders: PerpetualsStopOrderData[] | undefined;
999
1863
  }
1864
+ /**
1865
+ * Websocket subscription message format sent by clients to manage
1866
+ * their subscriptions.
1867
+ */
1000
1868
  export interface PerpetualsWsUpdatesSubscriptionMessage {
1001
1869
  action: PerpetualsWsUpdatesSubscriptionAction;
1002
1870
  subscriptionType: PerpetualsWsUpdatesSubscriptionType;
1003
1871
  }
1872
+ /**
1873
+ * Websocket response message for `/perpetuals/ws/updates`.
1874
+ *
1875
+ * Each response includes exactly one of the following discriminated unions.
1876
+ */
1004
1877
  export type PerpetualsWsUpdatesResponseMessage = {
1005
1878
  market: PerpetualsMarketData;
1006
1879
  } | {
@@ -1016,6 +1889,10 @@ export type PerpetualsWsUpdatesResponseMessage = {
1016
1889
  } | {
1017
1890
  userCollateralChanges: PerpetualsWsUpdatesUserCollateralChangesPayload;
1018
1891
  };
1892
+ /**
1893
+ * Websocket response message carrying the last candle for a given market
1894
+ * and interval.
1895
+ */
1019
1896
  export interface PerpetualsWsCandleResponseMessage {
1020
1897
  marketId: PerpetualsMarketId;
1021
1898
  lastCandle: PerpetualsMarketCandleDataPoint | undefined;