aftermath-ts-sdk 1.3.26-perps.13 → 1.3.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.
Files changed (120) hide show
  1. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts +0 -3
  2. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +1 -1
  3. package/dist/general/apiHelpers/transactionsApiHelpers.js +0 -12
  4. package/dist/general/providers/aftermath.d.ts +5 -0
  5. package/dist/general/providers/aftermath.d.ts.map +1 -1
  6. package/dist/general/providers/aftermath.js +6 -1
  7. package/dist/general/providers/aftermathApi.d.ts +5 -0
  8. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  9. package/dist/general/providers/aftermathApi.js +5 -0
  10. package/dist/general/types/castingTypes.d.ts +2 -2
  11. package/dist/general/types/castingTypes.d.ts.map +1 -1
  12. package/dist/general/types/configTypes.d.ts +10 -6
  13. package/dist/general/types/configTypes.d.ts.map +1 -1
  14. package/dist/general/types/generalTypes.d.ts +0 -8
  15. package/dist/general/types/generalTypes.d.ts.map +1 -1
  16. package/dist/general/types/moveErrorsInterface.d.ts +1 -1
  17. package/dist/general/types/moveErrorsInterface.d.ts.map +1 -1
  18. package/dist/general/utils/caller.d.ts +2 -34
  19. package/dist/general/utils/caller.d.ts.map +1 -1
  20. package/dist/general/utils/caller.js +12 -111
  21. package/dist/general/utils/casting.d.ts +5 -4
  22. package/dist/general/utils/casting.d.ts.map +1 -1
  23. package/dist/general/utils/casting.js +5 -4
  24. package/dist/general/utils/helpers.d.ts +0 -1
  25. package/dist/general/utils/helpers.d.ts.map +1 -1
  26. package/dist/general/utils/helpers.js +6 -38
  27. package/dist/general/wallet/wallet.d.ts +1 -1
  28. package/dist/general/wallet/wallet.d.ts.map +1 -1
  29. package/dist/packages/coin/coin.d.ts +1 -5
  30. package/dist/packages/coin/coin.d.ts.map +1 -1
  31. package/dist/packages/coin/coin.js +1 -7
  32. package/dist/packages/farms/api/farmsApiCasting.js +27 -27
  33. package/dist/packages/farms/farms.d.ts +1 -1
  34. package/dist/packages/farms/farms.d.ts.map +1 -1
  35. package/dist/packages/farms/farmsStakedPosition.d.ts +1 -1
  36. package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
  37. package/dist/packages/farms/farmsStakingPool.d.ts +1 -1
  38. package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
  39. package/dist/packages/faucet/api/faucetApi.d.ts +17 -9
  40. package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
  41. package/dist/packages/faucet/api/faucetApi.js +49 -44
  42. package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +1 -1
  43. package/dist/packages/faucet/api/faucetApiCasting.js +7 -10
  44. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +4 -1
  45. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +1 -1
  46. package/dist/packages/faucet/faucet.d.ts +1 -1
  47. package/dist/packages/faucet/faucet.d.ts.map +1 -1
  48. package/dist/packages/faucet/faucet.js +1 -1
  49. package/dist/packages/faucet/faucetTypes.d.ts +3 -2
  50. package/dist/packages/faucet/faucetTypes.d.ts.map +1 -1
  51. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.js +3 -3
  52. package/dist/packages/multisig/multisig.d.ts +1 -1
  53. package/dist/packages/multisig/multisig.d.ts.map +1 -1
  54. package/dist/packages/nftAmm/nftAmm.d.ts +1 -1
  55. package/dist/packages/nftAmm/nftAmm.d.ts.map +1 -1
  56. package/dist/packages/oracle/api/oracleApi.d.ts +21 -0
  57. package/dist/packages/oracle/api/oracleApi.d.ts.map +1 -0
  58. package/dist/packages/oracle/api/oracleApi.js +76 -0
  59. package/dist/packages/oracle/api/oracleApiCasting.d.ts +6 -0
  60. package/dist/packages/oracle/api/oracleApiCasting.d.ts.map +1 -0
  61. package/dist/packages/oracle/api/oracleApiCasting.js +25 -0
  62. package/dist/packages/oracle/oracle.d.ts +15 -0
  63. package/dist/packages/oracle/oracle.d.ts.map +1 -0
  64. package/dist/packages/oracle/oracle.js +46 -0
  65. package/dist/packages/oracle/oracleCastingTypes.d.ts +11 -0
  66. package/dist/packages/oracle/oracleCastingTypes.d.ts.map +1 -0
  67. package/dist/packages/oracle/oracleCastingTypes.js +2 -0
  68. package/dist/packages/oracle/oracleTypes.d.ts +10 -0
  69. package/dist/packages/oracle/oracleTypes.d.ts.map +1 -0
  70. package/dist/packages/oracle/oracleTypes.js +2 -0
  71. package/dist/packages/perpetuals/api/perpetualsApi.d.ts +203 -12
  72. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
  73. package/dist/packages/perpetuals/api/perpetualsApi.js +615 -926
  74. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +21 -10
  75. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +1 -1
  76. package/dist/packages/perpetuals/api/perpetualsApiCasting.js +238 -260
  77. package/dist/packages/perpetuals/index.d.ts +0 -1
  78. package/dist/packages/perpetuals/index.d.ts.map +1 -1
  79. package/dist/packages/perpetuals/index.js +0 -1
  80. package/dist/packages/perpetuals/perpetuals.d.ts +28 -813
  81. package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
  82. package/dist/packages/perpetuals/perpetuals.js +70 -984
  83. package/dist/packages/perpetuals/perpetualsAccount.d.ts +170 -754
  84. package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
  85. package/dist/packages/perpetuals/perpetualsAccount.js +312 -1267
  86. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +149 -82
  87. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +1 -1
  88. package/dist/packages/perpetuals/perpetualsMarket.d.ts +27 -341
  89. package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
  90. package/dist/packages/perpetuals/perpetualsMarket.js +78 -411
  91. package/dist/packages/perpetuals/perpetualsTypes.d.ts +319 -2575
  92. package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
  93. package/dist/packages/perpetuals/perpetualsTypes.js +82 -92
  94. package/dist/packages/pools/api/poolsApiCasting.js +3 -3
  95. package/dist/packages/pools/pool.d.ts +1 -1
  96. package/dist/packages/pools/pool.d.ts.map +1 -1
  97. package/dist/packages/pools/pools.d.ts +1 -1
  98. package/dist/packages/pools/pools.d.ts.map +1 -1
  99. package/dist/packages/router/api/routerApiCasting.js +1 -1
  100. package/dist/packages/router/routerTypes.d.ts +1 -1
  101. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  102. package/dist/packages/staking/api/stakingApiCasting.js +3 -3
  103. package/dist/packages/staking/staking.d.ts +1 -1
  104. package/dist/packages/staking/staking.d.ts.map +1 -1
  105. package/dist/packages/sui/sui.d.ts +1 -1
  106. package/dist/packages/sui/sui.d.ts.map +1 -1
  107. package/dist/packages/suiFrens/api/suiFrensApiCasting.js +4 -4
  108. package/dist/packages/suiFrens/stakedSuiFren.d.ts +1 -1
  109. package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +1 -1
  110. package/dist/packages/suiFrens/suiFren.d.ts +1 -1
  111. package/dist/packages/suiFrens/suiFren.d.ts.map +1 -1
  112. package/dist/packages/suiFrens/suiFrens.d.ts +1 -1
  113. package/dist/packages/suiFrens/suiFrens.d.ts.map +1 -1
  114. package/dist/types.d.ts +1 -0
  115. package/dist/types.d.ts.map +1 -1
  116. package/dist/types.js +1 -0
  117. package/package.json +1 -1
  118. package/dist/packages/perpetuals/perpetualsVault.d.ts +0 -438
  119. package/dist/packages/perpetuals/perpetualsVault.d.ts.map +0 -1
  120. package/dist/packages/perpetuals/perpetualsVault.js +0 -601
@@ -1,843 +1,58 @@
1
1
  import { Caller } from "../../general/utils/caller";
2
- import { PerpetualsMarketId, ApiPerpetualsOwnedAccountCapsBody, PerpetualsOrderSide, CoinType, PerpetualsOrderId, FilledTakerOrderEvent, ApiPerpetualsMarketCandleHistoryResponse, PerpetualsAccountCap, PerpetualsAccountId, CallerConfig, SuiAddress, ObjectId, ApiPerpetualsMarkets24hrStatsResponse, ApiPerpetualsAdminAccountCapsBody, Percentage, Balance, ApiPerpetualsVaultOwnedWithdrawRequestsBody, PerpetualsOrderPrice, ApiTransactionResponse, PerpetualsWsUpdatesResponseMessage, PerpetualsWsCandleResponseMessage, ApiPerpetualsCreateVaultCapBody, PerpetualsPartialVaultCap, ApiPerpetualsMarketCandleHistoryBody, ApiPerpetualsAdminAccountCapsResponse, ApiPerpetualsOwnedAccountCapsResponse, ApiPerpetualsAccountPositionsResponse, ApiPerpetualsAccountPositionsBody, ApiPerpetualsMarketsPricesResponse, ApiPerpetualsVaultLpCoinPricesResponse, ApiPerpetualsVaultLpCoinPricesBody, ApiPerpetualsVaultOwnedLpCoinsResponse, ApiPerpetualsVaultOwnedLpCoinsBody, ApiPerpetualsOwnedVaultCapsBody, ApiPerpetualsOwnedVaultCapsResponse, ApiPerpetualsVaultOwnedWithdrawRequestsResponse, SdkTransactionResponse, ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody, ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody, ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody, ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse, ApiPerpetualsBuilderCodesIntegratorConfigBody, ApiPerpetualsBuilderCodesIntegratorConfigResponse, ApiPerpetualsBuilderCodesIntegratorVaultsBody, ApiPerpetualsBuilderCodesIntegratorVaultsResponse, ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody } from "../../types";
2
+ import { ApiPerpetualsCreateAccountBody, PerpetualsMarketId, ApiPerpetualsAccountsBody, PerpetualsOrderSide, CoinType, PerpetualsOrderId, FilledTakerOrderEvent, PerpetualsOrderPrice, Timestamp, ApiPerpetualsHistoricalMarketDataResponse, PerpetualsAccountCap, IFixed, CallerConfig } from "../../types";
3
3
  import { PerpetualsMarket } from "./perpetualsMarket";
4
4
  import { PerpetualsAccount } from "./perpetualsAccount";
5
5
  import { PerpetualsOrderUtils } from "./utils";
6
- import { AftermathApi } from "../../general/providers";
7
- import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
8
- import { PerpetualsVault } from "./perpetualsVault";
9
- /**
10
- * High-level client for interacting with Aftermath Perpetuals.
11
- *
12
- * This class exposes a typed, ergonomic interface over the Perpetuals HTTP API
13
- * and websocket endpoints, including:
14
- *
15
- * - Market discovery (`getAllMarkets`, `getMarkets`, `getMarket`)
16
- * - Vault discovery (`getAllVaults`, `getVaults`, `getVault`)
17
- * - Account & position data (`getAccount`, `getAccounts`, `getAccountObjects`)
18
- * - Ownership queries (`getOwnedAccountCaps`, `getOwnedVaultCaps`)
19
- * - Historical data & stats (`getMarketCandleHistory`, `getMarkets24hrStats`)
20
- * - Pricing helpers (`getPrices`, `getLpCoinPrices`)
21
- * - Transaction builders (`getCreateAccountTx`, `getCreateVaultCapTx`, `getCreateVaultTx`)
22
- * - Websocket feeds (`openUpdatesWebsocketStream`, `openMarketCandlesWebsocketStream`)
23
- *
24
- * Typical usage via the root SDK:
25
- *
26
- * ```ts
27
- * import { Aftermath } from "@aftermath/sdk";
28
- *
29
- * const afSdk = new Aftermath("MAINNET");
30
- * await afSdk.init();
31
- *
32
- * const perps = afSdk.Perpetuals();
33
- *
34
- * // Fetch markets for a given collateral coin type
35
- * const markets = await perps.getAllMarkets({
36
- * collateralCoinType: "0x2::sui::SUI",
37
- * });
38
- *
39
- * // Fetch account + positions for a given account cap
40
- * const [accountCap] = await perps.getOwnedAccountCaps({
41
- * walletAddress: "0x...",
42
- * });
43
- *
44
- * const account = await perps.getAccount({ accountCap });
45
- *
46
- * // Build a create-account transaction (not signed or sent)
47
- * const createAccountTx = await perps.getCreateAccountTx({
48
- * walletAddress: "0x...",
49
- * collateralCoinType: "0x2::sui::SUI",
50
- * });
51
- * ```
52
- */
53
6
  export declare class Perpetuals extends Caller {
54
- readonly Provider?: AftermathApi | undefined;
55
- /**
56
- * Helper namespace for order-specific utilities such as parsing order IDs,
57
- * extracting price bits, etc.
58
- *
59
- * This is a direct alias of {@link PerpetualsOrderUtils}.
60
- */
61
7
  static readonly OrderUtils: typeof PerpetualsOrderUtils;
62
- /**
63
- * Creates a new Perpetuals client.
64
- *
65
- * @param config - Optional caller configuration (network, auth token, etc.).
66
- * @param Provider - Optional shared {@link AftermathApi} provider instance. When
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/...`
74
- */
75
- constructor(config?: CallerConfig, Provider?: AftermathApi | undefined);
76
- /**
77
- * Fetch all perpetual markets for a given collateral coin type.
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
- *
83
- * @param inputs.collateralCoinType - Coin type used as collateral, e.g. `"0x2::sui::SUI"`.
84
- * @returns Object containing `markets`.
85
- *
86
- * @example
87
- * ```ts
88
- * const { markets } = await perps.getAllMarkets({
89
- * collateralCoinType: "0x2::sui::SUI",
90
- * });
91
- * ```
92
- */
8
+ constructor(config?: CallerConfig);
93
9
  getAllMarkets(inputs: {
94
10
  collateralCoinType: CoinType;
95
- }): Promise<{
96
- markets: PerpetualsMarket[];
97
- }>;
98
- /**
99
- * Fetch a single market by ID.
100
- *
101
- * Internally calls {@link getMarkets} and returns the first entry.
102
- *
103
- * @param inputs.marketId - The market (clearing house) object 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.
109
- *
110
- * @example
111
- * ```ts
112
- * const { market } = await perps.getMarket({ marketId: "0x..." });
113
- * ```
114
- */
11
+ }): Promise<PerpetualsMarket[]>;
115
12
  getMarket(inputs: {
116
13
  marketId: PerpetualsMarketId;
117
- }): Promise<{
118
- market: PerpetualsMarket;
119
- }>;
120
- /**
121
- * Fetch multiple markets by ID.
122
- *
123
- * Backend note:
124
- * - The API supports returning orderbooks. This SDK currently constructs
125
- * {@link PerpetualsMarket} from the returned `marketDatas[].market`.
126
- *
127
- * @param inputs.marketIds - Array of market object IDs to fetch.
128
- * @returns Object containing `markets` in the same order as `marketIds`.
129
- *
130
- * @example
131
- * ```ts
132
- * const { markets } = await perps.getMarkets({
133
- * marketIds: ["0x..A", "0x..B"],
134
- * });
135
- * ```
136
- */
14
+ collateralCoinType: CoinType;
15
+ }): Promise<PerpetualsMarket>;
137
16
  getMarkets(inputs: {
138
17
  marketIds: PerpetualsMarketId[];
139
- }): Promise<{
140
- markets: PerpetualsMarket[];
141
- }>;
142
- /**
143
- * Fetch all vaults on the current network.
144
- *
145
- * Vaults are managed accounts that can hold positions; LPs deposit collateral
146
- * and receive an LP coin (see pricing helpers like {@link getLpCoinPrices}).
147
- *
148
- * @returns Object containing `vaults`.
149
- *
150
- * @example
151
- * ```ts
152
- * const { vaults } = await perps.getAllVaults();
153
- * ```
154
- */
155
- getAllVaults(): Promise<{
156
- vaults: PerpetualsVault[];
157
- }>;
158
- /**
159
- * Fetch a single vault by ID.
160
- *
161
- * Internally calls {@link getVaults} and returns the first entry.
162
- *
163
- * @param inputs.vaultId - Vault object ID.
164
- * @returns Object containing `vault`.
165
- */
166
- getVault(inputs: {
167
- vaultId: ObjectId;
168
- }): Promise<{
169
- vault: PerpetualsVault;
170
- }>;
171
- /**
172
- * Fetch multiple vaults by ID.
173
- *
174
- * @param inputs.vaultIds - Array of vault object IDs.
175
- * @returns Object containing `vaults` in the same order as `vaultIds`.
176
- */
177
- getVaults(inputs: {
178
- vaultIds: ObjectId[];
179
- }): Promise<{
180
- vaults: PerpetualsVault[];
181
- }>;
182
- /**
183
- * Convenience helper to fetch a single account (positions + account object) from an account cap.
184
- *
185
- * Internally calls {@link getAccounts} and returns the first entry.
186
- *
187
- * @param inputs.accountCap - Account cap or partial vault cap object to derive account metadata from.
188
- * @param inputs.marketIds - Optional list of markets to filter positions by.
189
- * @returns Object containing `account`.
190
- *
191
- * @example
192
- * ```ts
193
- * const [accountCap] = await perps.getOwnedAccountCaps({ walletAddress: "0x..." });
194
- * const { account } = await perps.getAccount({ accountCap });
195
- * ```
196
- */
18
+ collateralCoinType: CoinType;
19
+ }): Promise<PerpetualsMarket[]>;
197
20
  getAccount(inputs: {
198
- accountCap: PerpetualsAccountCap | PerpetualsPartialVaultCap;
199
- marketIds?: PerpetualsMarketId[];
200
- }): Promise<{
201
- account: PerpetualsAccount;
202
- }>;
203
- /**
204
- * Fetch one or more accounts (positions + account objects) from account caps.
205
- *
206
- * This composes:
207
- * 1) {@link getAccountObjects} to fetch {@link PerpetualsAccountObject}s by account ID
208
- * 2) Local pairing of returned account objects with `accountCaps`
209
- *
210
- * The returned {@link PerpetualsAccount} instances encapsulate:
211
- * - The account snapshot (positions, balances, etc.)
212
- * - The ownership/cap metadata (accountId, collateral type, vaultId, etc.)
213
- *
214
- * @param inputs.accountCaps - Array of account caps or partial vault cap objects.
215
- * @param inputs.marketIds - Optional list of market IDs to filter positions by.
216
- * @returns Object containing `accounts` in the same order as `accountCaps`.
217
- *
218
- * @remarks
219
- * If `accountCaps` is empty, this returns `{ accounts: [] }` without making an API call.
220
- */
221
- getAccounts(inputs: {
222
- accountCaps: (PerpetualsAccountCap | PerpetualsPartialVaultCap)[];
223
- marketIds?: PerpetualsMarketId[];
224
- }): Promise<{
225
- accounts: PerpetualsAccount[];
226
- }>;
227
- /**
228
- * Fetch raw account objects (including positions) for one or more account IDs.
229
- *
230
- * This is the lower-level primitive used by {@link getAccounts}.
231
- *
232
- * @param inputs.accountIds - List of account IDs to query.
233
- * @param inputs.marketIds - Optional list of market IDs to filter positions by.
234
- *
235
- * @returns {@link ApiPerpetualsAccountPositionsResponse} containing `accounts`.
236
- *
237
- * @remarks
238
- * If `accountIds` is empty, this returns `{ accounts: [] }` without making an API call.
239
- */
240
- getAccountObjects(inputs: ApiPerpetualsAccountPositionsBody): Promise<ApiPerpetualsAccountPositionsResponse>;
241
- /**
242
- * Fetch all account caps (perpetuals accounts) owned by a wallet, optionally
243
- * filtered by collateral coin types.
244
- *
245
- * Returned values are “caps” (ownership objects), not full account snapshots.
246
- * To fetch account positions, use {@link getAccount} or {@link getAccounts}.
247
- *
248
- * @param inputs.walletAddress - Owner wallet address.
249
- * @param inputs.collateralCoinTypes - Optional list of collateral coin types to filter by.
250
- * @returns {@link ApiPerpetualsOwnedAccountCapsResponse} containing `accounts`.
251
- *
252
- * @example
253
- * ```ts
254
- * const { accounts } = await perps.getOwnedAccountCaps({
255
- * walletAddress: "0x...",
256
- * collateralCoinTypes: ["0x2::sui::SUI"],
257
- * });
258
- * ```
259
- */
260
- getOwnedAccountCaps(inputs: ApiPerpetualsOwnedAccountCapsBody): Promise<ApiPerpetualsOwnedAccountCapsResponse>;
261
- /**
262
- * Fetch all vault caps owned by a wallet.
263
- *
264
- * Vault caps represent ownership/administrative authority over a vault.
265
- *
266
- * @param inputs.walletAddress - Owner wallet address.
267
- * @returns {@link ApiPerpetualsOwnedVaultCapsResponse} containing vault caps.
268
- */
269
- getOwnedVaultCaps(inputs: ApiPerpetualsOwnedVaultCapsBody): Promise<ApiPerpetualsOwnedVaultCapsResponse>;
270
- /**
271
- * Fetch all pending vault withdrawal requests created by a given wallet.
272
- *
273
- * Withdraw requests are typically created when LPs request to exit a vault
274
- * and may be subject to lock periods / delays depending on vault configuration.
275
- *
276
- * @param inputs.walletAddress - Wallet address that created the withdraw requests.
277
- * @returns {@link ApiPerpetualsVaultOwnedWithdrawRequestsResponse} containing requests.
278
- */
279
- getOwnedVaultWithdrawRequests(inputs: ApiPerpetualsVaultOwnedWithdrawRequestsBody): Promise<ApiPerpetualsVaultOwnedWithdrawRequestsResponse>;
280
- /**
281
- * Fetch all Perpetuals vault LP coins owned by a wallet.
282
- *
283
- * This returns coin objects (or summaries) representing LP token holdings.
284
- * Use {@link getLpCoinPrices} to value them in collateral units.
285
- *
286
- * @param inputs - {@link ApiPerpetualsVaultOwnedLpCoinsBody}.
287
- * @returns {@link ApiPerpetualsVaultOwnedLpCoinsResponse}.
288
- */
289
- getOwnedVaultLpCoins(inputs: ApiPerpetualsVaultOwnedLpCoinsBody): Promise<ApiPerpetualsVaultOwnedLpCoinsResponse>;
290
- /**
291
- * Fetch account caps by their account IDs.
292
- *
293
- * @param inputs.accountCapIds - List of account IDs.
294
- * @returns {@link ApiPerpetualsAccountCapsResponse} containing caps.
295
- */
296
- getAdminAccountCaps(inputs: ApiPerpetualsAdminAccountCapsBody): Promise<ApiPerpetualsAdminAccountCapsResponse>;
297
- /**
298
- * Fetch historical OHLCV candle data for a single market.
299
- *
300
- * @param inputs.marketId - Market ID to query.
301
- * @param inputs.fromTimestamp - Start timestamp (inclusive).
302
- * @param inputs.toTimestamp - End timestamp (exclusive).
303
- * @param inputs.intervalMs - Candle interval in milliseconds.
304
- *
305
- * @returns {@link ApiPerpetualsMarketCandleHistoryResponse} containing candle points.
306
- *
307
- * @remarks
308
- * This is currently implemented on the Perpetuals root client, but it may be
309
- * relocated to {@link PerpetualsMarket} in the future.
310
- */
311
- getMarketCandleHistory(inputs: ApiPerpetualsMarketCandleHistoryBody): Promise<ApiPerpetualsMarketCandleHistoryResponse>;
312
- /**
313
- * Fetch 24-hour stats for multiple markets.
314
- *
315
- * @param inputs.marketIds - Market IDs to query.
316
- * @returns {@link ApiPerpetualsMarkets24hrStatsResponse}.
317
- */
318
- getMarkets24hrStats(inputs: {
319
- marketIds: PerpetualsMarketId[];
320
- }): Promise<ApiPerpetualsMarkets24hrStatsResponse>;
321
- /**
322
- * Fetch the latest oracle prices (base & collateral) for one or more markets.
323
- *
324
- * @param inputs.marketIds - List of market IDs to query.
325
- * @returns {@link ApiPerpetualsMarketsPricesResponse} containing `marketsPrices`.
326
- *
327
- * @remarks
328
- * If `marketIds` is empty, returns `{ marketsPrices: [] }` without making an API call.
329
- */
330
- getPrices(inputs: {
331
- marketIds: ObjectId[];
332
- }): Promise<ApiPerpetualsMarketsPricesResponse>;
333
- /**
334
- * Fetch LP coin prices (in collateral units) for a set of vaults.
335
- *
336
- * @param inputs.vaultIds - List of vault IDs to query.
337
- * @returns {@link ApiPerpetualsVaultLpCoinPricesResponse} containing `lpCoinPrices`.
338
- *
339
- * @remarks
340
- * If `vaultIds` is empty, returns `{ lpCoinPrices: [] }` without making an API call.
341
- */
342
- getLpCoinPrices(inputs: ApiPerpetualsVaultLpCoinPricesBody): Promise<ApiPerpetualsVaultLpCoinPricesResponse>;
343
- /**
344
- * Build a `transfer-cap` transaction that transfers a Perpetuals capability object (cap)
345
- * to another wallet.
346
- *
347
- * Provide the `capObjectId` of the capability you want to transfer (e.g., an account cap
348
- * or vault cap) and the `recipientAddress` that should receive it.
349
- *
350
- * This endpoint builds a transaction only; it does not submit it on-chain.
351
- *
352
- * @param inputs.recipientAddress - Recipient wallet address that should receive the cap.
353
- * @param inputs.capObjectId - Object ID of the capability to transfer.
354
- * @param inputs.tx - Optional transaction to extend.
355
- *
356
- * @returns Transaction response containing a `tx`.
357
- */
358
- getTransferCapTx(inputs: {
359
- recipientAddress: SuiAddress;
360
- capObjectId: ObjectId;
361
- tx?: Transaction;
362
- }): Promise<Omit<ApiTransactionResponse, "txKind"> & {
363
- tx: Transaction;
364
- }>;
365
- /**
366
- * Build a `create-account` transaction for Aftermath Perpetuals.
367
- *
368
- * @param inputs.walletAddress - Wallet address that will own the new account.
369
- * @param inputs.collateralCoinType - Collateral coin type used by the account.
370
- * @param inputs.tx - Optional {@link Transaction} to extend; if provided, the
371
- * create-account commands are appended to this transaction.
372
- *
373
- * @returns {@link SdkTransactionResponse} with `tx`.
374
- */
375
- getCreateAccountTx(inputs: {
376
- walletAddress: SuiAddress;
21
+ accountCap: PerpetualsAccountCap;
22
+ }): Promise<PerpetualsAccount>;
23
+ getUserAccountCaps(inputs: ApiPerpetualsAccountsBody & {
377
24
  collateralCoinType: CoinType;
378
- tx?: Transaction;
379
- }): Promise<SdkTransactionResponse>;
380
- /**
381
- * Build a `create-vault-cap` transaction.
382
- *
383
- * A vault cap is an ownership/admin object for interacting with vault management
384
- * flows. This method returns a transaction kind that mints/creates that cap.
385
- *
386
- * @param inputs - {@link ApiPerpetualsCreateVaultCapBody}.
387
- * @returns {@link SdkTransactionResponse} with `tx`.
388
- */
389
- getCreateVaultCapTx(inputs: ApiPerpetualsCreateVaultCapBody): Promise<Omit<ApiTransactionResponse, "txKind"> & {
390
- tx: Transaction;
391
- }>;
392
- /**
393
- * Build a `create-vault` transaction.
394
- *
395
- * This creates a new vault plus its on-chain metadata and initial LP supply
396
- * seeded by the initial deposit.
397
- *
398
- * Deposit input:
399
- * - Use `initialDepositAmount` to have the API select/merge coins as needed, OR
400
- * - Use `initialDepositCoinArg` if you already have a coin argument in a larger tx.
401
- *
402
- * Metadata:
403
- * - Stored on-chain (or in a referenced object) as part of vault creation.
404
- * - `extraFields` allows forward-compatible additions (e.g. social links).
405
- *
406
- * @param inputs.walletAddress - Address of vault owner/curator.
407
- * @param inputs.metadata - Vault display metadata (name, description, curator info).
408
- * @param inputs.metadata - Vault display metadata (name, description, curator info).
409
- * @param inputs.coinMetadataId - Coin metadata object id obtained from create vault cap tx
410
- * @param inputs.treasuryCapId - Treasury cap object id obtained from create vault cap tx
411
- * @param inputs.collateralCoinType - Collateral coin type for deposits.
412
- * @param inputs.lockPeriodMs - Lock-in period for deposits in milliseconds.
413
- * @param inputs.performanceFeePercentage - Fraction of profits taken as curator fee.
414
- * @param inputs.forceWithdrawDelayMs - Delay before forced withdrawals can be processed.
415
- * @param inputs.isSponsoredTx - Whether this tx is sponsored (gas paid by another party).
416
- * @param inputs.initialDepositAmount - Initial deposit amount (mutually exclusive with `initialDepositCoinArg`).
417
- * @param inputs.initialDepositCoinArg - Transaction object argument referencing the deposit coin.
418
- * @param inputs.tx - Optional {@link Transaction} to extend.
419
- *
420
- * @returns {@link SdkTransactionResponse} with `tx`.
421
- */
422
- getCreateVaultTx(inputs: {
423
- walletAddress: SuiAddress;
424
- metadata: {
425
- /** A human-readable name for the `Vault`. */
426
- name: string;
427
- /** A verbose description of the `Vault`. */
428
- description: string;
429
- /** The `Vault` curator's name. */
430
- curatorName?: string;
431
- /** A url for the `Vault`'s curator. Ideally their website. */
432
- curatorUrl?: string;
433
- /** An image url for the `Vault`'s curator. Ideally their logo. */
434
- curatorLogoUrl?: string;
435
- /**
436
- * Extra / optional fields for future extensibility.
437
- * Recommended keys include: `twitter_url`.
438
- */
439
- extraFields?: Record<string, string>;
440
- };
441
- coinMetadataId: ObjectId;
442
- treasuryCapId: ObjectId;
25
+ }): Promise<PerpetualsAccountCap[]>;
26
+ getMarketHistoricalData(inputs: {
443
27
  collateralCoinType: CoinType;
444
- lockPeriodMs: bigint;
445
- performanceFeePercentage: Percentage;
446
- forceWithdrawDelayMs: bigint;
447
- tx?: Transaction;
448
- isSponsoredTx?: boolean;
449
- } & ({
450
- initialDepositAmount: Balance;
451
- } | {
452
- initialDepositCoinArg: TransactionObjectArgument;
453
- })): Promise<Omit<ApiTransactionResponse, "txKind"> & {
454
- tx: Transaction;
455
- }>;
456
- /**
457
- * Build a transaction to create an integrator configuration.
458
- *
459
- * This endpoint creates a transaction that allows a user to grant permission to an
460
- * integrator to receive fees on orders placed on their behalf. The user specifies
461
- * a maximum taker fee that the integrator can charge. The integrator can then
462
- * include their address and fee (up to the maximum) when placing orders for the user.
463
- *
464
- * The resulting transaction must be signed by the account owner and executed on-chain.
465
- *
466
- * @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody}.
467
- * @returns {@link SdkTransactionResponse} with `tx`.
468
- *
469
- * @example
470
- * ```ts
471
- * const tx = await perps.getCreateBuilderCodeIntegratorConfigTx({
472
- * accountId: 123n,
473
- * integratorAddress: "0x...",
474
- * maxTakerFee: 0.001, // 0.1% max fee
475
- * });
476
- * ```
477
- */
478
- getCreateBuilderCodeIntegratorConfigTx(inputs: ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody): Promise<Omit<ApiTransactionResponse, "txKind"> & {
479
- tx: Transaction;
480
- }>;
481
- /**
482
- * Build a transaction to remove an integrator configuration.
483
- *
484
- * This endpoint creates a transaction that removes an integrator's approval to
485
- * collect fees on orders placed on behalf of the user. Once revoked, the integrator
486
- * will no longer be able to submit orders with integrator fees for this account.
487
- * The user can re-approve the integrator at any time by calling
488
- * {@link getCreateIntegratorConfigTx} again.
489
- *
490
- * The resulting transaction must be signed by the account owner and executed on-chain.
491
- *
492
- * @param inputs - {@link ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody}.
493
- * @returns {@link SdkTransactionResponse} with `tx`.
494
- *
495
- * @example
496
- * ```ts
497
- * const tx = await perps.getRemoveBuilderCodeIntegratorConfigTx({
498
- * accountId: 123n,
499
- * integratorAddress: "0x...",
500
- * });
501
- * ```
502
- */
503
- getRemoveBuilderCodeIntegratorConfigTx(inputs: ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody): Promise<Omit<ApiTransactionResponse, "txKind"> & {
504
- tx: Transaction;
505
- }>;
506
- /**
507
- * Build a transaction to initialize an integrator fee vault for a specific market.
508
- *
509
- * This endpoint creates a transaction that initializes a vault where an integrator's
510
- * fees will accumulate for a specific market (clearing house). This is a one-time
511
- * setup operation that must be performed before the integrator can claim fees from
512
- * that market. Once created, the vault will automatically collect fees as the
513
- * integrator submits orders on behalf of users in that market.
514
- *
515
- * The resulting transaction must be signed by the integrator and executed on-chain.
516
- *
517
- * @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody}.
518
- * @returns {@link SdkTransactionResponse} with `tx`.
519
- *
520
- * @example
521
- * ```ts
522
- * const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({
523
- * marketId: "0x...",
524
- * integratorAddress: "0x...",
525
- * });
526
- * ```
527
- */
528
- getCreateBuilderCodeIntegratorVaultTx(inputs: ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody): Promise<Omit<ApiTransactionResponse, "txKind"> & {
529
- tx: Transaction;
530
- }>;
531
- /**
532
- * Build a transaction to claim accumulated integrator fees from a vault.
533
- *
534
- * This endpoint creates a transaction that allows an integrator to claim the fees
535
- * they have earned from orders placed on behalf of users. Fees accumulate in a vault
536
- * specific to each market (clearing house) and can be claimed at any moment by the
537
- * integrator. The fees are proportional to the taker volume generated by the users'
538
- * orders that the integrator submitted.
539
- *
540
- * If a `recipientAddress` is provided, the claimed fees will be automatically
541
- * transferred to that address. Otherwise, the coin output is exposed as a transaction
542
- * argument for further use in the transaction.
543
- *
544
- * The resulting transaction must be signed by the integrator and executed on-chain.
545
- *
546
- * @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.
547
- * @returns {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse} containing
548
- * `txKind` and optionally `coinOutArg`.
549
- *
550
- * @example
551
- * ```ts
552
- * // Claim with automatic transfer to recipient
553
- * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
554
- * marketId: "0x...",
555
- * integratorAddress: "0x...",
556
- * recipientAddress: "0x...",
557
- * });
558
- *
559
- * // Claim with coin output for further use
560
- * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
561
- * marketId: "0x...",
562
- * integratorAddress: "0x...",
563
- * });
564
- * // response.coinOutArg can be used in subsequent transaction commands
565
- * ```
566
- */
567
- getClaimBuilderCodeIntegratorVaultFeesTx(inputs: ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody): Promise<Omit<ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse, "txKind"> & {
568
- tx: Transaction;
569
- }>;
570
- /**
571
- * Fetch integrator configuration for a specific account and integrator.
572
- *
573
- * This endpoint queries whether an integrator has been approved by an account to collect
574
- * fees on orders placed on behalf of the account. If approved, it returns the maximum
575
- * taker fee the integrator is authorized to charge. This information is useful for:
576
- * - Verifying integrator permissions before placing orders
577
- * - Displaying authorized integrators and their fee limits in UIs
578
- * - Validating that an integrator's requested fee doesn't exceed the approved maximum
579
- *
580
- * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorConfigBody}.
581
- * @returns {@link ApiPerpetualsBuilderCodesIntegratorConfigResponse} containing
582
- * `maxTakerFee` and `exists` flag.
583
- *
584
- * @example
585
- * ```ts
586
- * const config = await perps.getBuilderCodeIntegratorConfig({
587
- * accountId: 123n,
588
- * integratorAddress: "0x...",
589
- * });
590
- *
591
- * if (config.exists) {
592
- * console.log(`Integrator is approved with max fee: ${config.maxTakerFee}`);
593
- * } else {
594
- * console.log("Integrator is not approved for this account");
595
- * }
596
- * ```
597
- */
598
- getBuilderCodeIntegratorConfig(inputs: ApiPerpetualsBuilderCodesIntegratorConfigBody): Promise<ApiPerpetualsBuilderCodesIntegratorConfigResponse>;
599
- /**
600
- * Fetch accumulated integrator vault fees across multiple markets.
601
- *
602
- * This endpoint queries the total fees an integrator has earned and accumulated in their
603
- * vaults across one or more markets (clearing houses). Integrators earn fees proportional
604
- * to the taker volume generated by orders they submit on behalf of users. These fees
605
- * accumulate in per-market vaults and can be claimed at any time using
606
- * {@link getClaimIntegratorVaultFeesTx}.
607
- *
608
- * This information is useful for:
609
- * - Displaying total claimable fees to integrators in dashboards
610
- * - Monitoring fee accrual across different markets
611
- * - Determining which markets have fees ready to be claimed
612
- *
613
- * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.
614
- * @returns {@link ApiPerpetualsBuilderCodesIntegratorVaultsResponse} containing
615
- * a vector of market vault data with accumulated fees.
616
- *
617
- * @example
618
- * ```ts
619
- * const vaultFees = await perps.getBuilderCodeIntegratorVaults({
620
- * marketIds: ["0x...BTCUSD", "0x...SUIUSD"],
621
- * integratorAddress: "0x...",
622
- * });
623
- *
624
- * for (const vault of vaultFees.integratorVaults) {
625
- * console.log(`Market ${vault.marketId}: ${vault.fees} collateral units claimable`);
626
- * }
627
- *
628
- * const totalFees = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.fees, 0);
629
- * console.log(`Total claimable: ${totalFees}`);
630
- * ```
631
- */
632
- getBuilderCodeIntegratorVaults(inputs: ApiPerpetualsBuilderCodesIntegratorVaultsBody): Promise<ApiPerpetualsBuilderCodesIntegratorVaultsResponse>;
633
- /**
634
- * Determine the logical order side (Bid/Ask) from a signed base asset amount.
635
- *
636
- * @param inputs.baseAssetAmount - Position base size. Positive/zero => Bid (long), negative => Ask (short).
637
- * @returns {@link PerpetualsOrderSide}.
638
- */
28
+ marketId: PerpetualsMarketId;
29
+ fromTimestamp: Timestamp;
30
+ toTimestamp: Timestamp;
31
+ intervalMs: number;
32
+ }): Promise<ApiPerpetualsHistoricalMarketDataResponse>;
33
+ getCreateAccountTx(inputs: ApiPerpetualsCreateAccountBody): Promise<import("@mysten/sui/transactions").Transaction>;
639
34
  static positionSide(inputs: {
640
- baseAssetAmount: number;
35
+ baseAssetAmount: IFixed;
641
36
  }): PerpetualsOrderSide;
642
- /**
643
- * Compute the effective trade price from a {@link FilledTakerOrderEvent}.
644
- *
645
- * Uses the ratio: `quoteAssetDelta / baseAssetDelta`.
646
- *
647
- * @param inputs.orderEvent - Filled taker order event.
648
- * @returns Trade price.
649
- */
650
- static orderPriceFromEvent(inputs: {
37
+ static orderPrice(inputs: {
651
38
  orderEvent: FilledTakerOrderEvent;
652
39
  }): number;
653
- /**
654
- * Extract the floating-point price from an encoded order ID.
655
- *
656
- * Internally uses {@link PerpetualsOrderUtils.price} and converts the fixed-point
657
- * {@link PerpetualsOrderPrice} into a `number`.
658
- *
659
- * @param inputs.orderId - Encoded order ID.
660
- * @returns Price as a `number`.
661
- */
662
- static orderPriceFromOrderId(inputs: {
663
- orderId: PerpetualsOrderId;
664
- }): number;
665
- /**
666
- * Convert a floating-point price into a fixed-point {@link PerpetualsOrderPrice}
667
- * using 9 decimal places of precision.
668
- *
669
- * @param inputs.price - Price as a float.
670
- * @returns Fixed-point order price.
671
- */
672
40
  static priceToOrderPrice: (inputs: {
673
41
  price: number;
42
+ lotSize: number | bigint;
43
+ tickSize: number | bigint;
674
44
  }) => PerpetualsOrderPrice;
675
- /**
676
- * Convert a fixed-point {@link PerpetualsOrderPrice} to a float price.
677
- *
678
- * @param inputs.orderPrice - Fixed-point order price.
679
- * @returns Price as a float.
680
- */
681
45
  static orderPriceToPrice: (inputs: {
682
46
  orderPrice: PerpetualsOrderPrice;
47
+ lotSize: number | bigint;
48
+ tickSize: number | bigint;
683
49
  }) => number;
684
- /**
685
- * Convert a fixed-point lot/tick size (9 decimals) to a `number`.
686
- *
687
- * @param lotOrTickSize - Fixed-point size as `bigint`.
688
- * @returns Floating-point size.
689
- */
690
50
  static lotOrTickSizeToNumber(lotOrTickSize: bigint): number;
691
- /**
692
- * Convert a floating-point lot/tick size to its fixed-point representation (9 decimals).
693
- *
694
- * @param lotOrTickSize - Floating-point size.
695
- * @returns Fixed-point size as `bigint`.
696
- */
697
51
  static lotOrTickSizeToBigInt(lotOrTickSize: number): bigint;
698
- /**
699
- * Infer the order side from an encoded order ID.
700
- *
701
- * @param orderId - Encoded order ID.
702
- * @returns {@link PerpetualsOrderSide}.
703
- */
704
52
  static orderIdToSide: (orderId: PerpetualsOrderId) => PerpetualsOrderSide;
705
- /**
706
- * Construct a collateral-specialized Move event type string.
707
- *
708
- * Many Move events are generic over a collateral coin type. This helper appends
709
- * `<collateralCoinType>` to a base `eventType`.
710
- *
711
- * @param inputs.eventType - Base event type without type parameters.
712
- * @param inputs.collateralCoinType - Collateral coin type (e.g. `"0x2::sui::SUI"`).
713
- * @returns Fully-qualified event type string.
714
- */
715
- static eventTypeForCollateral: (inputs: {
716
- eventType: string;
717
- collateralCoinType: CoinType;
718
- }) => string;
719
- /**
720
- * Open the main updates websocket: `/perpetuals/ws/updates`.
721
- *
722
- * The stream emits {@link PerpetualsWsUpdatesResponseMessage} envelopes and supports
723
- * multiple subscription types. This method returns a small controller with
724
- * convenience subscribe/unsubscribe functions.
725
- *
726
- * Subscription types supported by the controller:
727
- * - `market`: market state updates
728
- * - `user`: user account updates (optionally including stop orders)
729
- * - `oracle`: oracle price updates
730
- * - `orderbook`: orderbook deltas
731
- * - `marketOrders`: public market trades/orders
732
- * - `userOrders`: user trade/order events
733
- * - `userCollateralChanges`: user collateral change events
734
- *
735
- * @param args.onMessage - Handler for parsed messages from the websocket.
736
- * @param args.onOpen - Optional handler for the `open` event.
737
- * @param args.onError - Optional handler for the `error` event.
738
- * @param args.onClose - Optional handler for the `close` event.
739
- *
740
- * @returns A controller object containing:
741
- * - `ws`: underlying {@link WebSocket}
742
- * - subscribe/unsubscribe helpers for each subscription type
743
- * - `close()`: closes the websocket
744
- */
745
- openUpdatesWebsocketStream(args: {
746
- onMessage: (env: PerpetualsWsUpdatesResponseMessage) => void;
747
- onOpen?: (ev: Event) => void;
748
- onError?: (ev: Event) => void;
749
- onClose?: (ev: CloseEvent) => void;
750
- }): {
751
- ws: WebSocket;
752
- subscribeMarket: ({ marketId, }: {
753
- marketId: PerpetualsMarketId;
754
- }) => void;
755
- unsubscribeMarket: ({ marketId, }: {
756
- marketId: PerpetualsMarketId;
757
- }) => void;
758
- subscribeUser: ({ accountId, withStopOrders, }: {
759
- accountId: PerpetualsAccountId;
760
- withStopOrders: {
761
- walletAddress: SuiAddress;
762
- bytes: string;
763
- signature: string;
764
- } | undefined;
765
- }) => void;
766
- unsubscribeUser: ({ accountId, withStopOrders, }: {
767
- accountId: PerpetualsAccountId;
768
- withStopOrders: {
769
- walletAddress: SuiAddress;
770
- bytes: string;
771
- signature: string;
772
- } | undefined;
773
- }) => void;
774
- subscribeOracle: ({ marketId, }: {
775
- marketId: PerpetualsMarketId;
776
- }) => void;
777
- unsubscribeOracle: ({ marketId, }: {
778
- marketId: PerpetualsMarketId;
779
- }) => void;
780
- subscribeOrderbook: ({ marketId, }: {
781
- marketId: PerpetualsMarketId;
782
- }) => void;
783
- unsubscribeOrderbook: ({ marketId, }: {
784
- marketId: PerpetualsMarketId;
785
- }) => void;
786
- subscribeMarketOrders: ({ marketId, }: {
787
- marketId: PerpetualsMarketId;
788
- }) => void;
789
- unsubscribeMarketOrders: ({ marketId, }: {
790
- marketId: PerpetualsMarketId;
791
- }) => void;
792
- subscribeUserOrders: ({ accountId, }: {
793
- accountId: PerpetualsAccountId;
794
- }) => void;
795
- unsubscribeUserOrders: ({ accountId, }: {
796
- accountId: PerpetualsAccountId;
797
- }) => void;
798
- subscribeUserCollateralChanges: ({ accountId, }: {
799
- accountId: PerpetualsAccountId;
800
- }) => void;
801
- unsubscribeUserCollateralChanges: ({ accountId, }: {
802
- accountId: PerpetualsAccountId;
803
- }) => void;
804
- close: () => void;
805
- };
806
- /**
807
- * Open a market-candles websocket stream for a single market/interval:
808
- * `/perpetuals/ws/market-candles/{market_id}/{interval_ms}`.
809
- *
810
- * The stream emits {@link PerpetualsWsCandleResponseMessage} messages,
811
- * typically containing the latest candle for the specified interval.
812
- *
813
- * @param args.marketId - Market ID to subscribe to.
814
- * @param args.intervalMs - Candle interval in milliseconds.
815
- * @param args.onMessage - Handler for incoming candle updates.
816
- * @param args.onOpen - Optional hook called when the websocket opens.
817
- * @param args.onError - Optional hook called on websocket error.
818
- * @param args.onClose - Optional hook called when the websocket closes.
819
- *
820
- * @returns A controller containing the raw websocket and a `close()` helper.
821
- *
822
- * @example
823
- * ```ts
824
- * const stream = perps.openMarketCandlesWebsocketStream({
825
- * marketId: "0x...",
826
- * intervalMs: 60_000,
827
- * onMessage: ({ lastCandle }) => console.log(lastCandle),
828
- * });
829
- * ```
830
- */
831
- openMarketCandlesWebsocketStream(args: {
832
- marketId: PerpetualsMarketId;
833
- intervalMs: number;
834
- onMessage: (msg: PerpetualsWsCandleResponseMessage) => void;
835
- onOpen?: (ev: Event) => void;
836
- onError?: (ev: Event) => void;
837
- onClose?: (ev: CloseEvent) => void;
838
- }): {
839
- ws: WebSocket;
840
- close: () => void;
841
- };
53
+ static calcEntryPrice(inputs: {
54
+ baseAssetAmount: IFixed;
55
+ quoteAssetNotionalAmount: IFixed;
56
+ }): number;
842
57
  }
843
58
  //# sourceMappingURL=perpetuals.d.ts.map