aftermath-ts-sdk 1.3.23-perps.35 → 1.3.23-perps.37

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,5 +1,5 @@
1
1
  import { Caller } from "../../general/utils/caller";
2
- import { PerpetualsMarketId, ApiPerpetualsOwnedAccountCapsBody, PerpetualsOrderSide, CoinType, PerpetualsOrderId, FilledTakerOrderEvent, ApiPerpetualsMarketCandleHistoryResponse, PerpetualsAccountCap, PerpetualsAccountId, CallerConfig, SuiAddress, ObjectId, ApiPerpetualsMarkets24hrStatsResponse, ApiPerpetualsAccountCapsBody, Percentage, Balance, ApiPerpetualsVaultOwnedWithdrawRequestsBody, PerpetualsOrderPrice, ApiTransactionResponse, PerpetualsWsUpdatesResponseMessage, PerpetualsWsCandleResponseMessage, ApiPerpetualsCreateVaultCapBody, PerpetualsPartialVaultCap, ApiPerpetualsMarketCandleHistoryBody, ApiPerpetualsAccountCapsResponse, ApiPerpetualsOwnedAccountCapsResponse, ApiPerpetualsAccountPositionsResponse, ApiPerpetualsAccountPositionsBody, ApiPerpetualsMarketsPricesResponse, ApiPerpetualsVaultLpCoinPricesResponse, ApiPerpetualsVaultLpCoinPricesBody, ApiPerpetualsVaultOwnedLpCoinsResponse, ApiPerpetualsVaultOwnedLpCoinsBody, ApiPerpetualsOwnedVaultCapsBody, ApiPerpetualsOwnedVaultCapsResponse, ApiPerpetualsVaultOwnedWithdrawRequestsResponse } from "../../types";
2
+ import { PerpetualsMarketId, ApiPerpetualsOwnedAccountCapsBody, PerpetualsOrderSide, CoinType, PerpetualsOrderId, FilledTakerOrderEvent, ApiPerpetualsMarketCandleHistoryResponse, PerpetualsAccountCap, PerpetualsAccountId, CallerConfig, SuiAddress, ObjectId, ApiPerpetualsMarkets24hrStatsResponse, ApiPerpetualsAccountCapsBody, Percentage, Balance, ApiPerpetualsVaultOwnedWithdrawRequestsBody, PerpetualsOrderPrice, ApiTransactionResponse, PerpetualsWsUpdatesResponseMessage, PerpetualsWsCandleResponseMessage, ApiPerpetualsCreateVaultCapBody, PerpetualsPartialVaultCap, ApiPerpetualsMarketCandleHistoryBody, ApiPerpetualsAccountCapsResponse, ApiPerpetualsOwnedAccountCapsResponse, ApiPerpetualsAccountPositionsResponse, ApiPerpetualsAccountPositionsBody, ApiPerpetualsMarketsPricesResponse, ApiPerpetualsVaultLpCoinPricesResponse, ApiPerpetualsVaultLpCoinPricesBody, ApiPerpetualsVaultOwnedLpCoinsResponse, ApiPerpetualsVaultOwnedLpCoinsBody, ApiPerpetualsOwnedVaultCapsBody, ApiPerpetualsOwnedVaultCapsResponse, ApiPerpetualsVaultOwnedWithdrawRequestsResponse, SdkTransactionResponse } from "../../types";
3
3
  import { PerpetualsMarket } from "./perpetualsMarket";
4
4
  import { PerpetualsAccount } from "./perpetualsAccount";
5
5
  import { PerpetualsOrderUtils } from "./utils";
@@ -64,19 +64,28 @@ export declare class Perpetuals extends Caller {
64
64
  *
65
65
  * @param config - Optional caller configuration (network, auth token, etc.).
66
66
  * @param Provider - Optional shared {@link AftermathApi} provider instance. When
67
- * provided, transaction-building helpers (e.g. `getCreateAccountTx`) can
68
- * derive serialized `txKind` from a `Transaction` object.
67
+ * provided, transaction-building helpers can derive serialized `txKind`
68
+ * from a {@link Transaction} object via `Provider.Transactions().fetchBase64TxKindFromTx`.
69
+ *
70
+ * @remarks
71
+ * This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning:
72
+ * - HTTP calls resolve under `/perpetuals/...`
73
+ * - Websocket calls resolve under `/perpetuals/ws/...`
69
74
  */
70
75
  constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
71
76
  /**
72
77
  * Fetch all perpetual markets for a given collateral coin type.
73
78
  *
79
+ * This method returns *wrapped* {@link PerpetualsMarket} instances, not the raw
80
+ * market structs. Each instance provides additional helpers for pricing, margin,
81
+ * and order parsing.
82
+ *
74
83
  * @param inputs.collateralCoinType - Coin type used as collateral, e.g. `"0x2::sui::SUI"`.
75
- * @returns Array of {@link PerpetualsMarket} instances, each wrapping the raw market data.
84
+ * @returns Object containing `markets`.
76
85
  *
77
86
  * @example
78
87
  * ```ts
79
- * const markets = await perps.getAllMarkets({
88
+ * const { markets } = await perps.getAllMarkets({
80
89
  * collateralCoinType: "0x2::sui::SUI",
81
90
  * });
82
91
  * ```
@@ -92,11 +101,15 @@ export declare class Perpetuals extends Caller {
92
101
  * Internally calls {@link getMarkets} and returns the first entry.
93
102
  *
94
103
  * @param inputs.marketId - The market (clearing house) object ID.
95
- * @returns A {@link PerpetualsMarket} instance corresponding to the given ID.
104
+ * @returns Object containing `market`.
105
+ *
106
+ * @throws If the backend returns an empty list for the given `marketId`,
107
+ * this will still attempt to return `markets[0]` (which would be `undefined`).
108
+ * Callers may want to validate the result.
96
109
  *
97
110
  * @example
98
111
  * ```ts
99
- * const market = await perps.getMarket({ marketId: "0x..." });
112
+ * const { market } = await perps.getMarket({ marketId: "0x..." });
100
113
  * ```
101
114
  */
102
115
  getMarket(inputs: {
@@ -107,16 +120,17 @@ export declare class Perpetuals extends Caller {
107
120
  /**
108
121
  * Fetch multiple markets by ID.
109
122
  *
110
- * NOTE: the backend currently always returns market data together with an
111
- * orderbook object, but this SDK helper ignores the orderbook and constructs
112
- * {@link PerpetualsMarket} instances from the `market` field only.
123
+ * Backend note:
124
+ * - The API supports returning orderbooks. This SDK currently forces
125
+ * `withOrderbook: false` and constructs {@link PerpetualsMarket} from
126
+ * the returned `marketDatas[].market`.
113
127
  *
114
128
  * @param inputs.marketIds - Array of market object IDs to fetch.
115
- * @returns Array of {@link PerpetualsMarket} objects in the same order as `marketIds`.
129
+ * @returns Object containing `markets` in the same order as `marketIds`.
116
130
  *
117
131
  * @example
118
132
  * ```ts
119
- * const [marketA, marketB] = await perps.getMarkets({
133
+ * const { markets } = await perps.getMarkets({
120
134
  * marketIds: ["0x..A", "0x..B"],
121
135
  * });
122
136
  * ```
@@ -129,11 +143,14 @@ export declare class Perpetuals extends Caller {
129
143
  /**
130
144
  * Fetch all vaults on the current network.
131
145
  *
132
- * @returns Array of {@link PerpetualsVault} objects, each wrapping a vault on-chain object.
146
+ * Vaults are managed accounts that can hold positions; LPs deposit collateral
147
+ * and receive an LP coin (see pricing helpers like {@link getLpCoinPrices}).
148
+ *
149
+ * @returns Object containing `vaults`.
133
150
  *
134
151
  * @example
135
152
  * ```ts
136
- * const vaults = await perps.getAllVaults();
153
+ * const { vaults } = await perps.getAllVaults();
137
154
  * ```
138
155
  */
139
156
  getAllVaults(): Promise<{
@@ -144,13 +161,12 @@ export declare class Perpetuals extends Caller {
144
161
  *
145
162
  * Internally calls {@link getVaults} and returns the first entry.
146
163
  *
147
- * @param inputs.marketId - The vault object ID (note: named `marketId` for historical reasons).
148
- * @returns A {@link PerpetualsVault} instance.
164
+ * Naming note:
165
+ * - This method’s parameter is named `marketId` for historical reasons,
166
+ * but it refers to a vault object ID.
149
167
  *
150
- * @example
151
- * ```ts
152
- * const vault = await perps.getVault({ marketId: "0x..." });
153
- * ```
168
+ * @param inputs.marketId - Vault object ID.
169
+ * @returns Object containing `vault`.
154
170
  */
155
171
  getVault(inputs: {
156
172
  marketId: ObjectId;
@@ -161,14 +177,7 @@ export declare class Perpetuals extends Caller {
161
177
  * Fetch multiple vaults by ID.
162
178
  *
163
179
  * @param inputs.vaultIds - Array of vault object IDs.
164
- * @returns Array of {@link PerpetualsVault} objects in the same order as `vaultIds`.
165
- *
166
- * @example
167
- * ```ts
168
- * const [vaultA, vaultB] = await perps.getVaults({
169
- * vaultIds: ["0x..A", "0x..B"],
170
- * });
171
- * ```
180
+ * @returns Object containing `vaults` in the same order as `vaultIds`.
172
181
  */
173
182
  getVaults(inputs: {
174
183
  vaultIds: ObjectId[];
@@ -182,12 +191,12 @@ export declare class Perpetuals extends Caller {
182
191
  *
183
192
  * @param inputs.accountCap - Account-cap or vault-cap-extended object to derive account metadata from.
184
193
  * @param inputs.marketIds - Optional list of markets to filter positions by.
185
- * @returns A {@link PerpetualsAccount} instance.
194
+ * @returns Object containing `account`.
186
195
  *
187
196
  * @example
188
197
  * ```ts
189
198
  * const [accountCap] = await perps.getOwnedAccountCaps({ walletAddress: "0x..." });
190
- * const account = await perps.getAccount({ accountCap });
199
+ * const { account } = await perps.getAccount({ accountCap });
191
200
  * ```
192
201
  */
193
202
  getAccount(inputs: {
@@ -199,22 +208,20 @@ export declare class Perpetuals extends Caller {
199
208
  /**
200
209
  * Fetch one or more accounts (positions + account objects) from account caps.
201
210
  *
202
- * This composes two API calls:
203
- * - `/perpetuals/accounts/positions` to fetch {@link PerpetualsAccountObject}s
204
- * - Local pairing with the provided `accountCaps`
211
+ * This composes:
212
+ * 1) {@link getAccountObjects} to fetch {@link PerpetualsAccountObject}s by account ID
213
+ * 2) Local pairing of returned account objects with `accountCaps`
205
214
  *
206
- * The resulting {@link PerpetualsAccount} objects wrap both the on-chain account
207
- * data and the cap metadata in a single helper.
215
+ * The returned {@link PerpetualsAccount} instances encapsulate:
216
+ * - The account snapshot (positions, balances, etc.)
217
+ * - The ownership/cap metadata (accountId, collateral type, vaultId, etc.)
208
218
  *
209
219
  * @param inputs.accountCaps - Array of account caps or vault-cap-extended objects.
210
220
  * @param inputs.marketIds - Optional list of market IDs to filter positions by.
211
- * @returns Array of {@link PerpetualsAccount} instances in the same order as `accountCaps`.
221
+ * @returns Object containing `accounts` in the same order as `accountCaps`.
212
222
  *
213
- * @example
214
- * ```ts
215
- * const accountCaps = await perps.getOwnedAccountCaps({ walletAddress: "0x..." });
216
- * const accounts = await perps.getAccounts({ accountCaps });
217
- * ```
223
+ * @remarks
224
+ * If `accountCaps` is empty, this returns `{ accounts: [] }` without making an API call.
218
225
  */
219
226
  getAccounts(inputs: {
220
227
  accountCaps: (PerpetualsAccountCap | PerpetualsPartialVaultCap)[];
@@ -225,33 +232,31 @@ export declare class Perpetuals extends Caller {
225
232
  /**
226
233
  * Fetch raw account objects (including positions) for one or more account IDs.
227
234
  *
228
- * NOTE: The backend response is wrapped as `{ accounts: [...] }`.
235
+ * This is the lower-level primitive used by {@link getAccounts}.
229
236
  *
230
237
  * @param inputs.accountIds - List of account IDs to query.
231
238
  * @param inputs.marketIds - Optional list of market IDs to filter positions by.
232
- * @returns Array of {@link PerpetualsAccountObject}.
233
239
  *
234
- * @example
235
- * ```ts
236
- * const accountObjects = await perps.getAccountObjects({
237
- * accountIds: [123n, 456n],
238
- * });
239
- * ```
240
+ * @returns {@link ApiPerpetualsAccountPositionsResponse} containing `accounts`.
241
+ *
242
+ * @remarks
243
+ * If `accountIds` is empty, this returns `{ accounts: [] }` without making an API call.
240
244
  */
241
245
  getAccountObjects(inputs: ApiPerpetualsAccountPositionsBody): Promise<ApiPerpetualsAccountPositionsResponse>;
242
246
  /**
243
247
  * Fetch all account caps (perpetuals accounts) owned by a wallet, optionally
244
248
  * filtered by collateral coin types.
245
249
  *
246
- * NOTE: The backend response is wrapped as `{ accounts: [...] }`.
250
+ * Returned values are “caps” (ownership objects), not full account snapshots.
251
+ * To fetch account positions, use {@link getAccount} or {@link getAccounts}.
247
252
  *
248
253
  * @param inputs.walletAddress - Owner wallet address.
249
254
  * @param inputs.collateralCoinTypes - Optional list of collateral coin types to filter by.
250
- * @returns Array of {@link PerpetualsAccountCap} objects.
255
+ * @returns {@link ApiPerpetualsOwnedAccountCapsResponse} containing `accounts`.
251
256
  *
252
257
  * @example
253
258
  * ```ts
254
- * const caps = await perps.getOwnedAccountCaps({
259
+ * const { accounts } = await perps.getOwnedAccountCaps({
255
260
  * walletAddress: "0x...",
256
261
  * collateralCoinTypes: ["0x2::sui::SUI"],
257
262
  * });
@@ -261,44 +266,37 @@ export declare class Perpetuals extends Caller {
261
266
  /**
262
267
  * Fetch all vault caps owned by a wallet.
263
268
  *
264
- * @param inputs.walletAddress - Owner wallet address.
265
- * @returns Array of {@link PerpetualsVaultCap} objects.
269
+ * Vault caps represent ownership/administrative authority over a vault.
266
270
  *
267
- * @example
268
- * ```ts
269
- * const vaultCaps = await perps.getOwnedVaultCaps({
270
- * walletAddress: "0x...",
271
- * });
272
- * ```
271
+ * @param inputs.walletAddress - Owner wallet address.
272
+ * @returns {@link ApiPerpetualsOwnedVaultCapsResponse} containing vault caps.
273
273
  */
274
274
  getOwnedVaultCaps(inputs: ApiPerpetualsOwnedVaultCapsBody): Promise<ApiPerpetualsOwnedVaultCapsResponse>;
275
275
  /**
276
276
  * Fetch all pending vault withdrawal requests created by a given wallet.
277
277
  *
278
- * @param inputs.walletAddress - Wallet address that created the withdraw requests.
279
- * @returns Array of {@link PerpetualsVaultWithdrawRequest}.
278
+ * Withdraw requests are typically created when LPs request to exit a vault
279
+ * and may be subject to lock periods / delays depending on vault configuration.
280
280
  *
281
- * @example
282
- * ```ts
283
- * const withdrawRequests = await perps.getOwnedVaultWithdrawRequests({
284
- * walletAddress: "0x...",
285
- * });
286
- * ```
281
+ * @param inputs.walletAddress - Wallet address that created the withdraw requests.
282
+ * @returns {@link ApiPerpetualsVaultOwnedWithdrawRequestsResponse} containing requests.
287
283
  */
288
284
  getOwnedVaultWithdrawRequests(inputs: ApiPerpetualsVaultOwnedWithdrawRequestsBody): Promise<ApiPerpetualsVaultOwnedWithdrawRequestsResponse>;
285
+ /**
286
+ * Fetch all Perpetuals vault LP coins owned by a wallet.
287
+ *
288
+ * This returns coin objects (or summaries) representing LP token holdings.
289
+ * Use {@link getLpCoinPrices} to value them in collateral units.
290
+ *
291
+ * @param inputs - {@link ApiPerpetualsVaultOwnedLpCoinsBody}.
292
+ * @returns {@link ApiPerpetualsVaultOwnedLpCoinsResponse}.
293
+ */
289
294
  getOwnedVaultLpCoins(inputs: ApiPerpetualsVaultOwnedLpCoinsBody): Promise<ApiPerpetualsVaultOwnedLpCoinsResponse>;
290
295
  /**
291
296
  * Fetch account caps by their cap object IDs.
292
297
  *
293
298
  * @param inputs.accountCapIds - List of account cap object IDs.
294
- * @returns Array of {@link PerpetualsAccountCap}.
295
- *
296
- * @example
297
- * ```ts
298
- * const caps = await perps.getAccountCaps({
299
- * accountCapIds: ["0xcap1", "0xcap2"],
300
- * });
301
- * ```
299
+ * @returns {@link ApiPerpetualsAccountCapsResponse} containing caps.
302
300
  */
303
301
  getAccountCaps(inputs: ApiPerpetualsAccountCapsBody): Promise<ApiPerpetualsAccountCapsResponse>;
304
302
  /**
@@ -308,31 +306,19 @@ export declare class Perpetuals extends Caller {
308
306
  * @param inputs.fromTimestamp - Start timestamp (inclusive).
309
307
  * @param inputs.toTimestamp - End timestamp (exclusive).
310
308
  * @param inputs.intervalMs - Candle interval in milliseconds.
311
- * @returns Array of {@link PerpetualsMarketCandleDataPoint}.
312
309
  *
313
- * @example
314
- * ```ts
315
- * const candles = await perps.getMarketCandleHistory({
316
- * marketId: "0x...",
317
- * fromTimestamp: Date.now() - 24 * 60 * 60 * 1000,
318
- * toTimestamp: Date.now(),
319
- * intervalMs: 60_000, // 1 minute
320
- * });
321
- * ```
310
+ * @returns {@link ApiPerpetualsMarketCandleHistoryResponse} containing candle points.
311
+ *
312
+ * @remarks
313
+ * This is currently implemented on the Perpetuals root client, but it may be
314
+ * relocated to {@link PerpetualsMarket} in the future.
322
315
  */
323
316
  getMarketCandleHistory(inputs: ApiPerpetualsMarketCandleHistoryBody): Promise<ApiPerpetualsMarketCandleHistoryResponse>;
324
317
  /**
325
318
  * Fetch 24-hour stats for multiple markets.
326
319
  *
327
320
  * @param inputs.marketIds - Market IDs to query.
328
- * @returns Array of 24hr stats aligned with `marketIds`.
329
- *
330
- * @example
331
- * ```ts
332
- * const stats = await perps.getMarkets24hrStats({
333
- * marketIds: ["0x...", "0x..."],
334
- * });
335
- * ```
321
+ * @returns {@link ApiPerpetualsMarkets24hrStatsResponse}.
336
322
  */
337
323
  getMarkets24hrStats(inputs: {
338
324
  marketIds: PerpetualsMarketId[];
@@ -341,14 +327,10 @@ export declare class Perpetuals extends Caller {
341
327
  * Fetch the latest oracle prices (base & collateral) for one or more markets.
342
328
  *
343
329
  * @param inputs.marketIds - List of market IDs to query.
344
- * @returns Array of `{ basePrice, collateralPrice }` objects in the same order as `marketIds`.
345
- * Returns `[]` if `marketIds` is empty.
330
+ * @returns {@link ApiPerpetualsMarketsPricesResponse} containing `marketsPrices`.
346
331
  *
347
- * @example
348
- * ```ts
349
- * const prices = await perps.getPrices({ marketIds: ["0x..."] });
350
- * const { basePrice, collateralPrice } = prices[0];
351
- * ```
332
+ * @remarks
333
+ * If `marketIds` is empty, returns `{ marketsPrices: [] }` without making an API call.
352
334
  */
353
335
  getPrices(inputs: {
354
336
  marketIds: ObjectId[];
@@ -357,116 +339,90 @@ export declare class Perpetuals extends Caller {
357
339
  * Fetch LP coin prices (in collateral units) for a set of vaults.
358
340
  *
359
341
  * @param inputs.vaultIds - List of vault IDs to query.
360
- * @returns Array of LP prices corresponding to each vault ID; returns `[]` if none are provided.
342
+ * @returns {@link ApiPerpetualsVaultLpCoinPricesResponse} containing `lpCoinPrices`.
361
343
  *
362
- * @example
363
- * ```ts
364
- * const [price] = await perps.getLpCoinPrices({ vaultIds: ["0x..."] });
365
- * ```
344
+ * @remarks
345
+ * If `vaultIds` is empty, returns `{ lpCoinPrices: [] }` without making an API call.
366
346
  */
367
347
  getLpCoinPrices(inputs: ApiPerpetualsVaultLpCoinPricesBody): Promise<ApiPerpetualsVaultLpCoinPricesResponse>;
368
348
  /**
369
349
  * Build a `create-account` transaction for Aftermath Perpetuals.
370
350
  *
371
- * This helper:
372
- * - Optionally converts a {@link Transaction} into a serialized `txKind`
373
- * via the shared `Provider` (if present).
374
- * - Calls the `/perpetuals/transactions/create-account` endpoint.
375
- * - Returns a serialized transaction (`txKind`) that you can sign and execute.
376
- *
377
- * @param inputs.walletAddress - The wallet address that will own the new account.
378
- * @param inputs.collateralCoinType - Collateral coin type to be used with this account.
379
- * @param inputs.tx - Optional {@link Transaction} to extend; if provided,
380
- * the create-account commands are appended to this transaction.
351
+ * @param inputs.walletAddress - Wallet address that will own the new account.
352
+ * @param inputs.collateralCoinType - Collateral coin type used by the account.
353
+ * @param inputs.tx - Optional {@link Transaction} to extend; if provided, the
354
+ * create-account commands are appended to this transaction.
381
355
  *
382
- * @returns API transaction response containing `txKind`.
383
- *
384
- * @example
385
- * ```ts
386
- * const { txKind } = await perps.getCreateAccountTx({
387
- * walletAddress: "0x...",
388
- * collateralCoinType: "0x2::sui::SUI",
389
- * });
390
- * // sign + execute txKind with your wallet adapter
391
- * ```
356
+ * @returns {@link SdkTransactionResponse} with `tx`.
392
357
  */
393
358
  getCreateAccountTx(inputs: {
394
359
  walletAddress: SuiAddress;
395
360
  collateralCoinType: CoinType;
396
361
  tx?: Transaction;
397
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
398
- tx: Transaction;
399
- }>;
362
+ }): Promise<SdkTransactionResponse>;
363
+ /**
364
+ * Build a `create-vault-cap` transaction.
365
+ *
366
+ * A vault cap is an ownership/admin object for interacting with vault management
367
+ * flows. This method returns a transaction kind that mints/creates that cap.
368
+ *
369
+ * @param inputs - {@link ApiPerpetualsCreateVaultCapBody}.
370
+ * @returns {@link SdkTransactionResponse} with `tx`.
371
+ */
400
372
  getCreateVaultCapTx(inputs: ApiPerpetualsCreateVaultCapBody): Promise<Omit<ApiTransactionResponse, "txKind"> & {
401
373
  tx: Transaction;
402
374
  }>;
403
375
  /**
404
376
  * Build a `create-vault` transaction.
405
377
  *
406
- * This helper:
407
- * - Optionally converts a {@link Transaction} into a serialized `txKind`
408
- * via the shared `Provider` (if present).
409
- * - Calls `/perpetuals/vault/transactions/create-vault`.
410
- * - Returns a serialized transaction (`txKind`) that you can sign and execute.
378
+ * This creates a new vault plus its on-chain metadata and initial LP supply
379
+ * seeded by the initial deposit.
411
380
  *
412
- * You can specify the initial deposit either as an explicit amount or as a
413
- * `depositCoinArg` referring to an existing transaction argument.
381
+ * Deposit input:
382
+ * - Use `initialDepositAmount` to have the API select/merge coins as needed, OR
383
+ * - Use `initialDepositCoinArg` if you already have a coin argument in a larger tx.
414
384
  *
415
- * @param inputs.walletAddress - Address of vault owner.
416
- * @param inputs.lpCoinType - Coin type for the LP token.
417
- * @param inputs.collateralCoinType - Collateral coin type for the vault.
385
+ * Metadata:
386
+ * - Stored on-chain (or in a referenced object) as part of vault creation.
387
+ * - `extraFields` allows forward-compatible additions (e.g. social links).
388
+ *
389
+ * @param inputs.walletAddress - Address of vault owner/curator.
390
+ * @param inputs.metadata - Vault display metadata (name, description, curator info).
391
+ * @param inputs.metadata - Vault display metadata (name, description, curator info).
392
+ * @param inputs.coinMetadataId - Coin metadata object id obtained from create vault cap tx
393
+ * @param inputs.treasuryCapId - Treasury cap object id obtained from create vault cap tx
394
+ * @param inputs.collateralCoinType - Collateral coin type for deposits.
418
395
  * @param inputs.lockPeriodMs - Lock-in period for deposits in milliseconds.
419
- * @param inputs.performanceFeePercentage - Percentage of user profits taken as owner fee.
420
- * @param inputs.forceWithdrawDelayMs - Delay before forced withdrawals are processed.
421
- * @param inputs.isSponsoredTx - Whether this transaction is sponsored (fees paid by another party).
396
+ * @param inputs.performanceFeePercentage - Fraction of profits taken as curator fee.
397
+ * @param inputs.forceWithdrawDelayMs - Delay before forced withdrawals can be processed.
398
+ * @param inputs.isSponsoredTx - Whether this tx is sponsored (gas paid by another party).
422
399
  * @param inputs.initialDepositAmount - Initial deposit amount (mutually exclusive with `initialDepositCoinArg`).
423
400
  * @param inputs.initialDepositCoinArg - Transaction object argument referencing the deposit coin.
424
401
  * @param inputs.tx - Optional {@link Transaction} to extend.
425
402
  *
426
- * @returns API transaction response containing `txKind`.
427
- *
428
- * @example
429
- * ```ts
430
- * const { txKind } = await perps.getCreateVaultTx({
431
- * walletAddress: "0x...",
432
- * lpCoinType: "0x...::lp::LP",
433
- * collateralCoinType: "0x2::sui::SUI",
434
- * lockPeriodMs: BigInt(7 * 24 * 60 * 60 * 1000),
435
- * performanceFeePercentage: 0.2,
436
- * forceWithdrawDelayMs: BigInt(24 * 60 * 60 * 1000),
437
- * initialDepositAmount: BigInt("1000000000"),
438
- * });
439
- * ```
403
+ * @returns {@link SdkTransactionResponse} with `tx`.
440
404
  */
441
405
  getCreateVaultTx(inputs: {
442
406
  walletAddress: SuiAddress;
443
407
  metadata: {
444
- /**
445
- * A human-readable name for the `Vault`.
446
- */
408
+ /** A human-readable name for the `Vault`. */
447
409
  name: string;
448
- /**
449
- * A verbose description of the `Vault`.
450
- */
410
+ /** A verbose description of the `Vault`. */
451
411
  description: string;
452
- /**
453
- * The `Vault` curator's name.
454
- */
412
+ /** The `Vault` curator's name. */
455
413
  curatorName?: string;
456
- /**
457
- * A url for the `Vault`'s curator. Ideally their website.
458
- */
414
+ /** A url for the `Vault`'s curator. Ideally their website. */
459
415
  curatorUrl?: string;
460
- /**
461
- * An image url for the `Vault`'s curator. Ideally their logo.
462
- */
416
+ /** An image url for the `Vault`'s curator. Ideally their logo. */
463
417
  curatorLogoUrl?: string;
464
418
  /**
465
- * Extra / optional fields for future extensibility. Recommended keys include: twitter_url.
419
+ * Extra / optional fields for future extensibility.
420
+ * Recommended keys include: `twitter_url`.
466
421
  */
467
422
  extraFields?: Record<string, string>;
468
423
  };
469
- lpCoinType: CoinType;
424
+ coinMetadataId: ObjectId;
425
+ treasuryCapId: ObjectId;
470
426
  collateralCoinType: CoinType;
471
427
  lockPeriodMs: bigint;
472
428
  performanceFeePercentage: Percentage;
@@ -483,37 +439,31 @@ export declare class Perpetuals extends Caller {
483
439
  /**
484
440
  * Determine the logical order side (Bid/Ask) from a signed base asset amount.
485
441
  *
486
- * @param inputs.baseAssetAmount - Position base size. Positive => Bid (long), negative => Ask (short).
487
- * @returns Corresponding {@link PerpetualsOrderSide}.
488
- *
489
- * @example
490
- * ```ts
491
- * const side = Perpetuals.positionSide({ baseAssetAmount: -1 });
492
- * // side === PerpetualsOrderSide.Ask
493
- * ```
442
+ * @param inputs.baseAssetAmount - Position base size. Positive/zero => Bid (long), negative => Ask (short).
443
+ * @returns {@link PerpetualsOrderSide}.
494
444
  */
495
445
  static positionSide(inputs: {
496
446
  baseAssetAmount: number;
497
447
  }): PerpetualsOrderSide;
498
448
  /**
499
- * Compute the effective price from a {@link FilledTakerOrderEvent}.
449
+ * Compute the effective trade price from a {@link FilledTakerOrderEvent}.
500
450
  *
501
- * Uses `quoteAssetDelta / baseAssetDelta`.
451
+ * Uses the ratio: `quoteAssetDelta / baseAssetDelta`.
502
452
  *
503
453
  * @param inputs.orderEvent - Filled taker order event.
504
- * @returns Trade price as a `number`.
454
+ * @returns Trade price.
505
455
  */
506
456
  static orderPriceFromEvent(inputs: {
507
457
  orderEvent: FilledTakerOrderEvent;
508
458
  }): number;
509
459
  /**
510
- * Extract the price (as floating-point) from an encoded order ID.
460
+ * Extract the floating-point price from an encoded order ID.
511
461
  *
512
- * Internally uses {@link PerpetualsOrderUtils.price} and converts the
513
- * fixed-point `PerpetualsOrderPrice` into a `number`.
462
+ * Internally uses {@link PerpetualsOrderUtils.price} and converts the fixed-point
463
+ * {@link PerpetualsOrderPrice} into a `number`.
514
464
  *
515
465
  * @param inputs.orderId - Encoded order ID.
516
- * @returns Floating-point price.
466
+ * @returns Price as a `number`.
517
467
  */
518
468
  static orderPriceFromOrderId(inputs: {
519
469
  orderId: PerpetualsOrderId;
@@ -522,62 +472,51 @@ export declare class Perpetuals extends Caller {
522
472
  * Convert a floating-point price into a fixed-point {@link PerpetualsOrderPrice}
523
473
  * using 9 decimal places of precision.
524
474
  *
525
- * @param inputs.price - Floating-point price.
526
- * @returns Encoded {@link PerpetualsOrderPrice} as `bigint`.
475
+ * @param inputs.price - Price as a float.
476
+ * @returns Fixed-point order price.
527
477
  */
528
478
  static priceToOrderPrice: (inputs: {
529
479
  price: number;
530
480
  }) => PerpetualsOrderPrice;
531
481
  /**
532
- * Convert a fixed-point {@link PerpetualsOrderPrice} to a human-friendly price.
482
+ * Convert a fixed-point {@link PerpetualsOrderPrice} to a float price.
533
483
  *
534
- * @param inputs.orderPrice - Encoded order price as `bigint`.
535
- * @returns Floating-point price value.
484
+ * @param inputs.orderPrice - Fixed-point order price.
485
+ * @returns Price as a float.
536
486
  */
537
487
  static orderPriceToPrice: (inputs: {
538
488
  orderPrice: PerpetualsOrderPrice;
539
489
  }) => number;
540
490
  /**
541
- * Convert a fixed-point lot or tick size (9 decimals) to a `number`.
491
+ * Convert a fixed-point lot/tick size (9 decimals) to a `number`.
542
492
  *
543
493
  * @param lotOrTickSize - Fixed-point size as `bigint`.
544
- * @returns Floating-point representation.
494
+ * @returns Floating-point size.
545
495
  */
546
496
  static lotOrTickSizeToNumber(lotOrTickSize: bigint): number;
547
497
  /**
548
- * Convert a floating-point lot or tick size to its fixed-point representation (9 decimals).
498
+ * Convert a floating-point lot/tick size to its fixed-point representation (9 decimals).
549
499
  *
550
500
  * @param lotOrTickSize - Floating-point size.
551
- * @returns Fixed-point representation as `bigint`.
501
+ * @returns Fixed-point size as `bigint`.
552
502
  */
553
503
  static lotOrTickSizeToBigInt(lotOrTickSize: number): bigint;
554
504
  /**
555
- * Infer the order side from an order ID.
556
- *
557
- * Uses {@link PerpetualsOrderUtils.isAsk} under the hood.
505
+ * Infer the order side from an encoded order ID.
558
506
  *
559
507
  * @param orderId - Encoded order ID.
560
- * @returns {@link PerpetualsOrderSide.Ask} if ask, otherwise {@link PerpetualsOrderSide.Bid}.
508
+ * @returns {@link PerpetualsOrderSide}.
561
509
  */
562
510
  static orderIdToSide: (orderId: PerpetualsOrderId) => PerpetualsOrderSide;
563
511
  /**
564
- * Construct a full event type string for a collateral-specific event.
512
+ * Construct a collateral-specialized Move event type string.
565
513
  *
566
- * Many Move events are generic over a collateral coin type. This helper
567
- * appends `<collateralCoinType>` to a base `eventType`.
514
+ * Many Move events are generic over a collateral coin type. This helper appends
515
+ * `<collateralCoinType>` to a base `eventType`.
568
516
  *
569
517
  * @param inputs.eventType - Base event type without type parameters.
570
- * @param inputs.collateralCoinType - Collateral coin type, e.g. `"0x2::sui::SUI"`.
518
+ * @param inputs.collateralCoinType - Collateral coin type (e.g. `"0x2::sui::SUI"`).
571
519
  * @returns Fully-qualified event type string.
572
- *
573
- * @example
574
- * ```ts
575
- * const fullType = Perpetuals.eventTypeForCollateral({
576
- * eventType: "0x1::perps::DepositedCollateral",
577
- * collateralCoinType: "0x2::sui::SUI",
578
- * });
579
- * // "0x1::perps::DepositedCollateral<0x2::sui::SUI>"
580
- * ```
581
520
  */
582
521
  static eventTypeForCollateral: (inputs: {
583
522
  eventType: string;
@@ -586,48 +525,28 @@ export declare class Perpetuals extends Caller {
586
525
  /**
587
526
  * Open the main updates websocket: `/perpetuals/ws/updates`.
588
527
  *
589
- * This stream can deliver:
590
- * - Market updates
591
- * - User account + stop order updates
592
- * - Oracle price updates
593
- * - Orderbook deltas
594
- * - Market trades
595
- * - User trades
596
- * - User collateral changes
597
- *
598
- * The returned controller object includes a set of convenient subscribe /
599
- * unsubscribe helpers for each stream type.
600
- *
601
- * @param args.onMessage - Handler for incoming messages from the ws.
602
- * @param args.onOpen - Optional hook called when the websocket is opened.
603
- * @param args.onError - Optional hook called on websocket error.
604
- * @param args.onClose - Optional hook called when the websocket closes.
605
- *
606
- * @returns An object containing:
607
- * - `ws`: the underlying `WebSocket` instance
608
- * - subscribe/unsubscribe helpers:
609
- * - `subscribeMarket` / `unsubscribeMarket`
610
- * - `subscribeUser` / `unsubscribeUser`
611
- * - `subscribeOracle` / `unsubscribeOracle`
612
- * - `subscribeOrderbook` / `unsubscribeOrderbook`
613
- * - `subscribeMarketOrders` / `unsubscribeMarketOrders`
614
- * - `subscribeUserOrders` / `unsubscribeUserOrders`
615
- * - `subscribeUserCollateralChanges` / `unsubscribeUserCollateralChanges`
616
- * - `close`: function to close the websocket
617
- *
618
- * @example
619
- * ```ts
620
- * const stream = perps.openUpdatesWebsocketStream({
621
- * onMessage: (msg) => {
622
- * if ("market" in msg) {
623
- * console.log("Market update", msg.market);
624
- * }
625
- * },
626
- * });
627
- *
628
- * stream.subscribeMarket({ marketId: "0x..." });
629
- * stream.subscribeUser({ accountId: 123n, withStopOrders: undefined });
630
- * ```
528
+ * The stream emits {@link PerpetualsWsUpdatesResponseMessage} envelopes and supports
529
+ * multiple subscription types. This method returns a small controller with
530
+ * convenience subscribe/unsubscribe functions.
531
+ *
532
+ * Subscription types supported by the controller:
533
+ * - `market`: market state updates
534
+ * - `user`: user account updates (optionally including stop orders)
535
+ * - `oracle`: oracle price updates
536
+ * - `orderbook`: orderbook deltas
537
+ * - `marketOrders`: public market trades/orders
538
+ * - `userOrders`: user trade/order events
539
+ * - `userCollateralChanges`: user collateral change events
540
+ *
541
+ * @param args.onMessage - Handler for parsed messages from the websocket.
542
+ * @param args.onOpen - Optional handler for the `open` event.
543
+ * @param args.onError - Optional handler for the `error` event.
544
+ * @param args.onClose - Optional handler for the `close` event.
545
+ *
546
+ * @returns A controller object containing:
547
+ * - `ws`: underlying {@link WebSocket}
548
+ * - subscribe/unsubscribe helpers for each subscription type
549
+ * - `close()`: closes the websocket
631
550
  */
632
551
  openUpdatesWebsocketStream(args: {
633
552
  onMessage: (env: PerpetualsWsUpdatesResponseMessage) => void;
@@ -704,18 +623,14 @@ export declare class Perpetuals extends Caller {
704
623
  * @param args.onError - Optional hook called on websocket error.
705
624
  * @param args.onClose - Optional hook called when the websocket closes.
706
625
  *
707
- * @returns An object containing:
708
- * - `ws`: the underlying `WebSocket` instance
709
- * - `close`: function to close the websocket
626
+ * @returns A controller containing the raw websocket and a `close()` helper.
710
627
  *
711
628
  * @example
712
629
  * ```ts
713
630
  * const stream = perps.openMarketCandlesWebsocketStream({
714
631
  * marketId: "0x...",
715
632
  * intervalMs: 60_000,
716
- * onMessage: ({ lastCandle }) => {
717
- * console.log("New candle:", lastCandle);
718
- * },
633
+ * onMessage: ({ lastCandle }) => console.log(lastCandle),
719
634
  * });
720
635
  * ```
721
636
  */