aftermath-ts-sdk 1.3.27 → 1.3.28

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 (128) hide show
  1. package/dist/general/apiHelpers/objectsApiHelpers.d.ts.map +1 -1
  2. package/dist/general/apiHelpers/objectsApiHelpers.js +5 -4
  3. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts +3 -0
  4. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +1 -1
  5. package/dist/general/apiHelpers/transactionsApiHelpers.js +14 -2
  6. package/dist/general/providers/aftermath.d.ts +19 -19
  7. package/dist/general/providers/aftermath.d.ts.map +1 -1
  8. package/dist/general/providers/aftermath.js +20 -20
  9. package/dist/general/providers/aftermathApi.d.ts +0 -5
  10. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  11. package/dist/general/providers/aftermathApi.js +0 -5
  12. package/dist/general/types/castingTypes.d.ts +2 -2
  13. package/dist/general/types/castingTypes.d.ts.map +1 -1
  14. package/dist/general/types/configTypes.d.ts +6 -10
  15. package/dist/general/types/configTypes.d.ts.map +1 -1
  16. package/dist/general/types/generalTypes.d.ts +8 -0
  17. package/dist/general/types/generalTypes.d.ts.map +1 -1
  18. package/dist/general/types/moveErrorsInterface.d.ts +1 -1
  19. package/dist/general/types/moveErrorsInterface.d.ts.map +1 -1
  20. package/dist/general/utils/caller.d.ts +34 -2
  21. package/dist/general/utils/caller.d.ts.map +1 -1
  22. package/dist/general/utils/caller.js +111 -12
  23. package/dist/general/utils/casting.d.ts +4 -5
  24. package/dist/general/utils/casting.d.ts.map +1 -1
  25. package/dist/general/utils/casting.js +4 -5
  26. package/dist/general/utils/helpers.d.ts +1 -0
  27. package/dist/general/utils/helpers.d.ts.map +1 -1
  28. package/dist/general/utils/helpers.js +40 -9
  29. package/dist/general/wallet/wallet.d.ts +1 -1
  30. package/dist/general/wallet/wallet.d.ts.map +1 -1
  31. package/dist/packages/coin/coin.d.ts +5 -1
  32. package/dist/packages/coin/coin.d.ts.map +1 -1
  33. package/dist/packages/coin/coin.js +7 -1
  34. package/dist/packages/farms/api/farmsApiCasting.js +27 -27
  35. package/dist/packages/farms/farms.d.ts +1 -1
  36. package/dist/packages/farms/farms.d.ts.map +1 -1
  37. package/dist/packages/farms/farmsStakedPosition.d.ts +1 -1
  38. package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
  39. package/dist/packages/farms/farmsStakingPool.d.ts +1 -1
  40. package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
  41. package/dist/packages/faucet/api/faucetApi.d.ts +9 -17
  42. package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
  43. package/dist/packages/faucet/api/faucetApi.js +44 -49
  44. package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +1 -1
  45. package/dist/packages/faucet/api/faucetApiCasting.js +10 -7
  46. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +1 -4
  47. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +1 -1
  48. package/dist/packages/faucet/faucet.d.ts +1 -1
  49. package/dist/packages/faucet/faucet.d.ts.map +1 -1
  50. package/dist/packages/faucet/faucet.js +1 -1
  51. package/dist/packages/faucet/faucetTypes.d.ts +2 -3
  52. package/dist/packages/faucet/faucetTypes.d.ts.map +1 -1
  53. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.js +3 -3
  54. package/dist/packages/multisig/multisig.d.ts +1 -1
  55. package/dist/packages/multisig/multisig.d.ts.map +1 -1
  56. package/dist/packages/nftAmm/nftAmm.d.ts +1 -1
  57. package/dist/packages/nftAmm/nftAmm.d.ts.map +1 -1
  58. package/dist/packages/perpetuals/api/perpetualsApi.d.ts +12 -203
  59. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
  60. package/dist/packages/perpetuals/api/perpetualsApi.js +926 -615
  61. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +10 -21
  62. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +1 -1
  63. package/dist/packages/perpetuals/api/perpetualsApiCasting.js +260 -238
  64. package/dist/packages/perpetuals/index.d.ts +1 -0
  65. package/dist/packages/perpetuals/index.d.ts.map +1 -1
  66. package/dist/packages/perpetuals/index.js +1 -0
  67. package/dist/packages/perpetuals/perpetuals.d.ts +830 -28
  68. package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
  69. package/dist/packages/perpetuals/perpetuals.js +1013 -70
  70. package/dist/packages/perpetuals/perpetualsAccount.d.ts +754 -170
  71. package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
  72. package/dist/packages/perpetuals/perpetualsAccount.js +1270 -312
  73. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +82 -149
  74. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +1 -1
  75. package/dist/packages/perpetuals/perpetualsMarket.d.ts +327 -27
  76. package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
  77. package/dist/packages/perpetuals/perpetualsMarket.js +392 -79
  78. package/dist/packages/perpetuals/perpetualsTypes.d.ts +2662 -318
  79. package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
  80. package/dist/packages/perpetuals/perpetualsTypes.js +92 -82
  81. package/dist/packages/perpetuals/perpetualsVault.d.ts +438 -0
  82. package/dist/packages/perpetuals/perpetualsVault.d.ts.map +1 -0
  83. package/dist/packages/perpetuals/perpetualsVault.js +601 -0
  84. package/dist/packages/pools/api/poolsApiCasting.js +3 -3
  85. package/dist/packages/pools/pool.d.ts +1 -1
  86. package/dist/packages/pools/pool.d.ts.map +1 -1
  87. package/dist/packages/pools/pools.d.ts +1 -1
  88. package/dist/packages/pools/pools.d.ts.map +1 -1
  89. package/dist/packages/rewards/index.d.ts +2 -0
  90. package/dist/packages/rewards/index.d.ts.map +1 -0
  91. package/dist/packages/rewards/index.js +17 -0
  92. package/dist/packages/rewards/rewards.d.ts +21 -0
  93. package/dist/packages/rewards/rewards.d.ts.map +1 -0
  94. package/dist/packages/rewards/rewards.js +65 -0
  95. package/dist/packages/rewards/rewardsTypes.d.ts +169 -0
  96. package/dist/packages/rewards/rewardsTypes.d.ts.map +1 -0
  97. package/dist/packages/router/api/routerApiCasting.js +1 -1
  98. package/dist/packages/staking/api/stakingApiCasting.js +3 -3
  99. package/dist/packages/staking/staking.d.ts +1 -1
  100. package/dist/packages/staking/staking.d.ts.map +1 -1
  101. package/dist/packages/sui/sui.d.ts +1 -1
  102. package/dist/packages/sui/sui.d.ts.map +1 -1
  103. package/dist/packages/suiFrens/api/suiFrensApiCasting.js +4 -4
  104. package/dist/packages/suiFrens/stakedSuiFren.d.ts +1 -1
  105. package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +1 -1
  106. package/dist/packages/suiFrens/suiFren.d.ts +1 -1
  107. package/dist/packages/suiFrens/suiFren.d.ts.map +1 -1
  108. package/dist/packages/suiFrens/suiFrens.d.ts +1 -1
  109. package/dist/packages/suiFrens/suiFrens.d.ts.map +1 -1
  110. package/dist/types.d.ts +1 -1
  111. package/dist/types.d.ts.map +1 -1
  112. package/dist/types.js +1 -1
  113. package/package.json +1 -1
  114. package/dist/packages/oracle/api/oracleApi.d.ts +0 -21
  115. package/dist/packages/oracle/api/oracleApi.d.ts.map +0 -1
  116. package/dist/packages/oracle/api/oracleApi.js +0 -76
  117. package/dist/packages/oracle/api/oracleApiCasting.d.ts +0 -6
  118. package/dist/packages/oracle/api/oracleApiCasting.d.ts.map +0 -1
  119. package/dist/packages/oracle/api/oracleApiCasting.js +0 -25
  120. package/dist/packages/oracle/oracle.d.ts +0 -15
  121. package/dist/packages/oracle/oracle.d.ts.map +0 -1
  122. package/dist/packages/oracle/oracle.js +0 -46
  123. package/dist/packages/oracle/oracleCastingTypes.d.ts +0 -11
  124. package/dist/packages/oracle/oracleCastingTypes.d.ts.map +0 -1
  125. package/dist/packages/oracle/oracleTypes.d.ts +0 -10
  126. package/dist/packages/oracle/oracleTypes.d.ts.map +0 -1
  127. package/dist/packages/oracle/oracleTypes.js +0 -2
  128. /package/dist/packages/{oracle/oracleCastingTypes.js → rewards/rewardsTypes.js} +0 -0
@@ -1,257 +1,1030 @@
1
- import { BcsType } from "@mysten/sui/bcs";
2
- import { AnyObjectType, ApiDataWithCursorBody, Balance, Event, IFixed, Object, ObjectDigest, ObjectId, ObjectVersion, PackageId, Percentage, SuiAddress, Timestamp, TransactionDigest } from "../../general/types/generalTypes";
1
+ import { AnyObjectType, Balance, Byte, Event, ObjectDigest, ObjectId, ObjectVersion, PackageId, Percentage, SerializedTransaction, Slippage, SuiAddress, Timestamp, TransactionDigest } from "../../general/types/generalTypes";
3
2
  import { CoinDecimal, CoinSymbol, CoinType } from "../coin/coinTypes";
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
  }
19
- declare function Field<N extends BcsType<any>, V extends BcsType<any>>(name: N, value: V): import("@mysten/sui/bcs").BcsStruct<{
20
- name: N;
21
- value: V;
22
- }, string>;
23
- export interface PerpetualsAdminCapability extends Object {
24
- }
25
- export interface PerpetualsRegistry extends Object {
26
- activeCollaterals: CoinType[];
27
- }
28
- export interface PerpetualsVault extends Object {
29
- balance: Balance;
30
- scalingFactor: bigint;
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
+ */
64
+ export declare enum PerpetualsStopOrderType {
65
+ /**
66
+ * Stop Loss / Take Profit stop order. Can to be placed to close (fully or partially)
67
+ * the position.
68
+ */
69
+ SlTp = 0,
70
+ /**
71
+ * Stop order that can be both reduce or increase the position's size. May require
72
+ * some collateral to be allocated to be able to be placed.
73
+ */
74
+ Standalone = 1
31
75
  }
76
+ /**
77
+ * Aggregate market configuration and state for a single perpetuals market.
78
+ */
32
79
  export interface PerpetualsMarketData {
80
+ /** Package ID of the deployed perpetuals contract. */
33
81
  packageId: PackageId;
82
+ /** Object ID for the market (clearing house) on-chain. */
34
83
  objectId: ObjectId;
35
- initialSharedVersion: ObjectVersion;
84
+ /** Collateral coin type used for margin in this market. */
36
85
  collateralCoinType: CoinType;
86
+ /** Static configuration parameters for this market. */
37
87
  marketParams: PerpetualsMarketParams;
88
+ /** Dynamic runtime state (funding, open interest, etc.). */
38
89
  marketState: PerpetualsMarketState;
90
+ /** Current price of collateral in USD or the platform's base unit. */
91
+ collateralPrice: number;
92
+ /** Oracle/index price of the base asset for this market. */
93
+ indexPrice: number;
94
+ /** Estimated funding rate for the next funding interval. */
95
+ estimatedFundingRate: Percentage;
96
+ /** Timestamp (ms) for the next funding event, as a bigint. */
97
+ nextFundingTimestampMs: bigint;
39
98
  }
40
- export interface PerpetualsAccountCap extends Object {
99
+ /**
100
+ * On-chain capability object that grants control over a perpetuals account.
101
+ *
102
+ * This represents an "owned" account capability, used to sign and authorize
103
+ * account-level actions.
104
+ */
105
+ export interface PerpetualsAccountCap {
106
+ /** Object ID of the account capability on-chain. */
107
+ objectId: ObjectId;
108
+ /** Wallet address that owns this account capability. */
109
+ walletAddress: SuiAddress;
110
+ /** Logical ID of the associated perpetuals account. */
41
111
  accountId: PerpetualsAccountId;
112
+ /** Object ID of the associated `PerpetualsAccountObject`. */
113
+ accountObjectId: ObjectId;
114
+ /** Collateral coin type backing this account. */
42
115
  collateralCoinType: CoinType;
43
- collateral: IFixed;
44
- collateralDecimals: CoinDecimal;
116
+ /** Total collateral (native units) associated with this account. */
117
+ collateral: number;
118
+ /** On-chain object version. */
45
119
  objectVersion: ObjectVersion;
120
+ /** On-chain object digest. */
46
121
  objectDigest: ObjectDigest;
122
+ /** True if this account cap was allocated to an agent wallet from the admin account cap owner. */
123
+ isAgent: boolean;
124
+ /** Initial shared version of the underlying perpetuals `Account` object. Required when constructing transactions that reference the shared account object. */
125
+ accountObjectInitialSharedVersion: ObjectVersion;
126
+ /** Sui object IDs of agent account caps that have been whitelisted to operate on behalf of this account. */
127
+ whitelistedAgentCapIds: ObjectId[];
47
128
  }
48
- export type PerpetualsRawAccountCap = Omit<PerpetualsAccountCap, "collateral" | "collateralDecimals"> & {
49
- collateral: Balance;
50
- };
51
- export interface PerpetualsPosition {
52
- collateral: IFixed;
53
- baseAssetAmount: IFixed;
54
- quoteAssetNotionalAmount: IFixed;
55
- cumFundingRateLong: IFixed;
56
- cumFundingRateShort: IFixed;
57
- asksQuantity: IFixed;
58
- bidsQuantity: IFixed;
129
+ /**
130
+ * Base vault-capability object, as represented on-chain.
131
+ */
132
+ export interface PerpetualsVaultCap {
133
+ /** Vault object ID that this cap grants permissions for. */
134
+ vaultId: ObjectId;
135
+ /** Capability object ID. */
136
+ objectId: ObjectId;
137
+ /** Owner of the vault-capability. */
138
+ ownerAddress: SuiAddress;
139
+ /** Collateral coin type used by the vault account. */
59
140
  collateralCoinType: CoinType;
141
+ /** Perpetuals account ID controlled by the vault. */
142
+ accountId: PerpetualsAccountId;
143
+ /** Object ID of the account object owned by the vault. */
144
+ accountObjectId: ObjectId;
145
+ }
146
+ export type PerpetualsPartialVaultCap = Omit<PerpetualsVaultCap, "objectId">;
147
+ /**
148
+ * Representation of an LP (share) coin position for a specific vault.
149
+ *
150
+ * This is typically returned by API endpoints that enumerate a wallet's vault
151
+ * positions. `lpAmount` is the raw on-chain balance for the vault's LP coin type.
152
+ *
153
+ * Notes:
154
+ * - `lpAmountUsd` is a convenience valuation derived from current vault TVL and LP supply.
155
+ * - The LP coin itself is an on-chain `Coin<T>` object, but here we expose the derived,
156
+ * aggregated view needed by UIs.
157
+ */
158
+ export interface PerpetualsVaultLpCoin {
159
+ /** Vault identifier that minted the LP coin. */
160
+ vaultId: ObjectId;
161
+ /** Object ID of the specific LP coin object held by the user. */
162
+ objectId: ObjectId;
163
+ /** Raw LP token amount (native units; not human-decimal adjusted). */
164
+ lpAmount: Balance;
165
+ /** Estimated USD value of `lpAmount` at query time. */
166
+ lpAmountUsd: number;
167
+ }
168
+ /**
169
+ * Aggregate position data for a single perpetuals market and account.
170
+ *
171
+ * Values are generally denoted in:
172
+ * - Base asset units (e.g. BTC)
173
+ * - Quote units (e.g. USD)
174
+ * - Collateral units (per `collateralCoinType`)
175
+ */
176
+ export interface PerpetualsPosition {
177
+ /** Allocated collateral (in collateral coins). */
178
+ collateral: number;
179
+ /** Net base asset amount (positive = long, negative = short). */
180
+ baseAssetAmount: number;
181
+ /** Notional exposure of the position in quote units. */
182
+ quoteAssetNotionalAmount: number;
183
+ /** Cumulative funding rate accrued on the long side. */
184
+ cumFundingRateLong: number;
185
+ /** Cumulative funding rate accrued on the short side. */
186
+ cumFundingRateShort: number;
187
+ /** Aggregate size of resting asks in this market for the account. */
188
+ asksQuantity: number;
189
+ /** Aggregate size of resting bids in this market for the account. */
190
+ bidsQuantity: number;
191
+ /** Market identifier for this position. */
60
192
  marketId: PerpetualsMarketId;
193
+ /** All pending (open) orders associated with this position. */
61
194
  pendingOrders: {
195
+ /** Unique ID of the order. */
62
196
  orderId: PerpetualsOrderId;
197
+ /** Side of the order (Bid/Ask). */
63
198
  side: PerpetualsOrderSide;
64
- size: bigint;
199
+ /** Current size remaining of the order in base units (scaled as bigint). */
200
+ currentSize: bigint;
201
+ /** Initial size of the order in base units (scaled as bigint). */
202
+ initialSize: bigint;
65
203
  }[];
66
- makerFee: IFixed;
67
- takerFee: IFixed;
204
+ /** Maker fee rate applied to this position (as a fraction). */
205
+ makerFee: Percentage;
206
+ /** Taker fee rate applied to this position (as a fraction). */
207
+ takerFee: Percentage;
208
+ /** Effective leverage applied to the position. */
68
209
  leverage: number;
210
+ /** Collateral value in USD. */
211
+ collateralUsd: number;
212
+ /** Current margin ratio (collateral / exposure). */
213
+ marginRatio: number;
214
+ /** Free margin available in USD. */
215
+ freeMarginUsd: number;
216
+ /** Free (unlocked) collateral in collateral units. */
217
+ freeCollateral: number;
218
+ /** Unrealized funding PnL in USD. */
219
+ unrealizedFundingsUsd: number;
220
+ /** Unrealized position PnL in USD. */
221
+ unrealizedPnlUsd: number;
222
+ /** Average entry price of the position. */
223
+ entryPrice: number;
224
+ /** Approximate liquidation price for the position. */
225
+ liquidationPrice: number;
69
226
  }
227
+ /**
228
+ * Static configuration parameters describing a perpetuals market.
229
+ *
230
+ * These values are typically immutable or rarely changed, and are used
231
+ * to drive risk limits, pricing, and fee schedules.
232
+ */
70
233
  export interface PerpetualsMarketParams {
71
- marginRatioInitial: IFixed;
72
- marginRatioMaintenance: IFixed;
234
+ /** Initial margin requirement for new positions (fraction). */
235
+ marginRatioInitial: number;
236
+ /** Maintenance margin requirement for open positions (fraction). */
237
+ marginRatioMaintenance: number;
238
+ /** Symbol of the underlying asset. */
73
239
  baseAssetSymbol: CoinSymbol;
240
+ /** On-chain ID of the oracle providing the base asset price. */
74
241
  basePriceFeedId: ObjectId;
242
+ /** On-chain ID of the oracle providing the collateral asset price. */
75
243
  collateralPriceFeedId: ObjectId;
244
+ /** Funding interval duration in milliseconds. */
76
245
  fundingFrequencyMs: bigint;
246
+ /** Funding period used for calculations in milliseconds. */
77
247
  fundingPeriodMs: bigint;
248
+ /** TWAP frequency for the premium in milliseconds. */
78
249
  premiumTwapFrequencyMs: bigint;
250
+ /** TWAP period for the premium in milliseconds. */
79
251
  premiumTwapPeriodMs: bigint;
252
+ /** TWAP frequency for the spread in milliseconds. */
80
253
  spreadTwapFrequencyMs: bigint;
254
+ /** TWAP period for the spread in milliseconds. */
81
255
  spreadTwapPeriodMs: bigint;
82
- makerFee: IFixed;
83
- takerFee: IFixed;
84
- liquidationFee: IFixed;
85
- forceCancelFee: IFixed;
86
- insuranceFundFee: IFixed;
87
- minOrderUsdValue: IFixed;
256
+ /** TWAP period for gas price in milliseconds. */
257
+ gasPriceTwapPeriodMs: bigint;
258
+ /** Maker fee rate (fraction) charged for providing liquidity. */
259
+ makerFee: Percentage;
260
+ /** Taker fee rate (fraction) charged for taking liquidity. */
261
+ takerFee: Percentage;
262
+ /** Liquidation fee rate (fraction) charged on liquidations. */
263
+ liquidationFee: Percentage;
264
+ /** Fee rate (fraction) for forced cancellation. */
265
+ forceCancelFee: Percentage;
266
+ /** Fraction of fees directed to the insurance fund. */
267
+ insuranceFundFee: Percentage;
268
+ /** Minimum notional order value in USD. */
269
+ minOrderUsdValue: number;
270
+ /** Minimum base size increment for orders (lot size, scaled bigint). */
88
271
  lotSize: bigint;
272
+ /** Minimum price increment (tick size, scaled bigint). */
89
273
  tickSize: bigint;
90
- liquidationTolerance: bigint;
274
+ /** Scaling factor used in internal fixed-point conversions. */
275
+ scalingFactor: number;
276
+ /** Additional taker fee that depends on gas cost. */
277
+ gasPriceTakerFee: Percentage;
278
+ /** Z-score threshold used for outlier detection in pricing. */
279
+ zScoreThreshold: number;
280
+ /** Maximum open interest (notional or base) allowed in the market. */
91
281
  maxPendingOrders: bigint;
92
- oracleTolerance: bigint;
282
+ /** Oracle tolerance for the base asset price (scaled bigint). */
283
+ baseOracleTolerance: bigint;
284
+ /** Oracle tolerance for the collateral price (scaled bigint). */
285
+ collateralOracleTolerance: bigint;
286
+ /** Maximum open interest (absolute). */
287
+ maxOpenInterest: number;
288
+ /** Threshold above which open interest is considered elevated. */
289
+ maxOpenInterestThreshold: number;
290
+ /** Maximum fraction of open interest a single position can hold. */
291
+ maxOpenInterestPositionPercent: number;
93
292
  }
293
+ /**
294
+ * Dynamic runtime state of a perpetuals market.
295
+ *
296
+ * These values are updated frequently and used to compute funding
297
+ * and other time-variant metrics.
298
+ */
94
299
  export interface PerpetualsMarketState {
95
- cumFundingRateLong: IFixed;
96
- cumFundingRateShort: IFixed;
97
- fundingLastUpdateMs: Timestamp;
98
- premiumTwap: IFixed;
99
- premiumTwapLastUpdateMs: Timestamp;
100
- spreadTwap: IFixed;
101
- spreadTwapLastUpdateMs: Timestamp;
102
- openInterest: IFixed;
103
- feesAccrued: IFixed;
300
+ /** Cumulative funding rate for long positions. */
301
+ cumFundingRateLong: number;
302
+ /** Cumulative funding rate for short positions. */
303
+ cumFundingRateShort: number;
304
+ /** Last timestamp when funding was updated. */
305
+ fundingLastUpdateTimestamp: Timestamp;
306
+ /** Premium TWAP value (book vs index). */
307
+ premiumTwap: number;
308
+ /** Timestamp of last premium TWAP update. */
309
+ premiumTwapLastUpdateTimestamp: Timestamp;
310
+ /** Spread TWAP value. */
311
+ spreadTwap: number;
312
+ /** Timestamp of last spread TWAP update. */
313
+ spreadTwapLastUpdateTimestamp: Timestamp;
314
+ /** Current open interest in the market. */
315
+ openInterest: number;
316
+ /** Total fees accrued by the market. */
317
+ feesAccrued: number;
104
318
  }
319
+ /**
320
+ * Single OHLCV data point for a market candle.
321
+ *
322
+ * Typically used in charts and historical data views.
323
+ */
105
324
  export interface PerpetualsMarketCandleDataPoint {
106
- time: Timestamp;
325
+ /** Start timestamp of this candle. */
326
+ timestamp: Timestamp;
327
+ /** High price within this interval. */
107
328
  high: number;
329
+ /** Low price within this interval. */
108
330
  low: number;
331
+ /** Open price at the beginning of the interval. */
109
332
  open: number;
333
+ /** Close price at the end of the interval. */
110
334
  close: number;
335
+ /** Traded volume (base units) during the interval. */
111
336
  volume: number;
112
337
  }
338
+ /**
339
+ * A single entry (price level) in an orderbook side.
340
+ */
341
+ export interface PerpetualsOrderbookItem {
342
+ /** Total size resting at this price level (base units). */
343
+ size: number;
344
+ /** Price level for the aggregated orders. */
345
+ price: number;
346
+ }
347
+ /**
348
+ * Aggregated orderbook snapshot for a perpetuals market.
349
+ */
113
350
  export interface PerpetualsOrderbook {
114
- bids: Record<PerpetualsOrderIdAsString, {
115
- accountId: PerpetualsAccountId;
116
- size: number;
117
- price: number;
118
- }>;
119
- asks: Record<PerpetualsOrderIdAsString, {
120
- accountId: PerpetualsAccountId;
121
- size: number;
122
- price: number;
123
- }>;
351
+ /** Bid-side price levels (sorted descending by price). */
352
+ bids: PerpetualsOrderbookItem[];
353
+ /** Ask-side price levels (sorted ascending by price). */
354
+ asks: PerpetualsOrderbookItem[];
355
+ /** Sum of bid-side size across all levels. */
124
356
  asksTotalSize: number;
357
+ /** Sum of ask-side size across all levels. */
125
358
  bidsTotalSize: number;
359
+ /** Best bid price (highest bid), or undefined if no bids. */
126
360
  bestBidPrice: number | undefined;
361
+ /** Best ask price (lowest ask), or undefined if no asks. */
127
362
  bestAskPrice: number | undefined;
363
+ /** Mid price between best bid and best ask, if both exist. */
128
364
  midPrice: number | undefined;
365
+ /** Incremental nonce associated with this snapshot. */
366
+ nonce: bigint;
367
+ }
368
+ /**
369
+ * Incremental deltas to an orderbook snapshot.
370
+ *
371
+ * These are typically used over websockets for streaming updates.
372
+ */
373
+ export interface PerpetualsOrderbookDeltas {
374
+ /** Updated bid-side price levels. */
375
+ bidsDeltas: PerpetualsOrderbookItem[];
376
+ /** Updated ask-side price levels. */
377
+ asksDeltas: PerpetualsOrderbookItem[];
378
+ /** Delta of total ask-side size. */
379
+ asksTotalSizeDelta: number;
380
+ /** Delta of total bid-side size. */
381
+ bidsTotalSizeDelta: number;
382
+ /** Nonce for ordering deltas. */
383
+ nonce: bigint;
129
384
  }
385
+ /**
386
+ * Core order metadata for perpetuals orders.
387
+ *
388
+ * This is shared across multiple internal and external APIs.
389
+ */
130
390
  export interface PerpetualsOrderData {
391
+ /** Unique ID of the order. */
131
392
  orderId: PerpetualsOrderId;
393
+ /** Initial order size in scaled base units. */
132
394
  initialSize: bigint;
133
- filledSize: bigint;
395
+ /** Current size remaining in scaled base units. */
396
+ currentSize: bigint;
397
+ /** Order side (Bid or Ask). */
134
398
  side: PerpetualsOrderSide;
399
+ /** Market this order belongs to. */
135
400
  marketId: PerpetualsMarketId;
136
401
  }
402
+ /**
403
+ * Optional integrator fee configuration for an order.
404
+ *
405
+ * When provided, this allows an approved integrator to collect a fee on the taker
406
+ * volume generated by this order. The integrator must have been previously approved
407
+ * by the user via the create-integration endpoint, and the taker fee must not exceed
408
+ * the maximum fee approved by the user.
409
+ */
410
+ export interface PerpetualsBuilderCodeParamaters {
411
+ /**
412
+ * Sui address of the integrator who will receive the fee.
413
+ *
414
+ * This integrator must have been previously approved by the account owner,
415
+ * and must have a vault created for the market where the order is being placed.
416
+ */
417
+ integratorAddress: SuiAddress;
418
+ /**
419
+ * Taker fee (as a decimal) to be charged on this order's taker volume.
420
+ *
421
+ * For example, 0.0005 represents a 0.05% fee. This value must not exceed
422
+ * the maximum taker fee that the user approved for this integrator.
423
+ * The fee is only applied to taker volume (not maker volume).
424
+ */
425
+ takerFee: Percentage;
426
+ }
427
+ /**
428
+ * Full stop-order representation on-chain.
429
+ *
430
+ * Can represent:
431
+ * - SL/TP orders (`slTp`)
432
+ * - Standalone stops (`nonSlTp`)
433
+ */
434
+ export interface PerpetualsStopOrderData {
435
+ /** ID of the stop order object on-chain. */
436
+ objectId: ObjectId;
437
+ /** Market the stop order is tied to. */
438
+ marketId: PerpetualsMarketId;
439
+ /** Size to execute when triggered (scaled base units). */
440
+ size: bigint;
441
+ /** Direction of the stop order. */
442
+ side: PerpetualsOrderSide;
443
+ /** Optional expiration time (ms or seconds, depending on protocol). */
444
+ expiryTimestamp?: bigint;
445
+ /** Optional limit order parameters when the stop triggers. */
446
+ limitOrder?: {
447
+ /** Limit price to post or execute at, scaled bigint. */
448
+ price: bigint;
449
+ /** Order type semantics. */
450
+ orderType: PerpetualsOrderType;
451
+ };
452
+ /** Stop loss / take profit configuration. */
453
+ slTp?: {
454
+ /** Index price at which to trigger a stop loss. */
455
+ stopLossIndexPrice?: number;
456
+ /** Index price at which to take profit. */
457
+ takeProfitIndexPrice?: number;
458
+ /** Unique order identifier for limit order sl/tp is tied to. */
459
+ limitOrderId?: PerpetualsOrderId;
460
+ };
461
+ /** Non-SL/TP standalone stop configuration. */
462
+ nonSlTp?: {
463
+ /** Index price threshold used for triggering. */
464
+ stopIndexPrice: number;
465
+ /** If true, triggers when index >= threshold, otherwise index <= threshold. */
466
+ triggerIfGeStopIndexPrice: boolean;
467
+ /** Whether the stop can only reduce an existing position. */
468
+ reduceOnly: boolean;
469
+ };
470
+ }
471
+ /**
472
+ * Filled order data used in execution price previews and trade details.
473
+ */
137
474
  export interface PerpetualsFilledOrderData {
475
+ /** Filled size in base units (non-scaled). */
138
476
  size: number;
477
+ /** Execution price for the fill. */
139
478
  price: number;
140
479
  }
480
+ /**
481
+ * High-level order info with price and size only.
482
+ */
141
483
  export interface PerpetualsOrderInfo {
142
- price: PerpetualsOrderPrice;
484
+ /** Order price. */
485
+ price: number;
486
+ /** Order size (scaled base units). */
143
487
  size: bigint;
144
488
  }
489
+ /**
490
+ * Pairing of a perpetuals account capability and its current account state.
491
+ */
145
492
  export interface PerpetualsAccountData {
493
+ /** Account capability object. */
146
494
  accountCap: PerpetualsAccountCap;
495
+ /** Account state object. */
147
496
  account: PerpetualsAccountObject;
148
497
  }
498
+ /**
499
+ * Aggregate account-level metrics for perpetuals.
500
+ */
149
501
  export interface PerpetualsAccountObject {
502
+ /** Numeric ID of the account. */
503
+ accountId: PerpetualsAccountId;
504
+ /** Total equity in USD. */
505
+ totalEquityUsd: number;
506
+ /** Available collateral in collateral units. */
507
+ availableCollateral: number;
508
+ /** Available collateral in USD. */
509
+ availableCollateralUsd: number;
510
+ /** Sum of unrealized funding PnL across markets. */
511
+ totalUnrealizedFundingsUsd: number;
512
+ /** Sum of unrealized position PnL across markets. */
513
+ totalUnrealizedPnlUsd: number;
514
+ /** Per-market positions for this account. */
150
515
  positions: PerpetualsPosition[];
151
516
  }
517
+ /**
518
+ * Human-facing metadata for vault discovery / browsing.
519
+ *
520
+ * This is intended for UI display and is not used for any on-chain risk or
521
+ * accounting logic.
522
+ *
523
+ * Note: The type name contains a historical misspelling ("Metatada") and is
524
+ * preserved for backward compatibility.
525
+ */
526
+ export interface PerpetualsVaultMetatada {
527
+ /**
528
+ * A human-readable name for the `Vault`.
529
+ */
530
+ name: string;
531
+ /**
532
+ * A verbose description of the `Vault`.
533
+ */
534
+ description: string;
535
+ /**
536
+ * The `Vault` curator's name.
537
+ */
538
+ curatorName: string | undefined;
539
+ /**
540
+ * A url for the `Vault`'s curator. Ideally their website.
541
+ */
542
+ curatorUrl: string | undefined;
543
+ /**
544
+ * An image url for the `Vault`'s curator. Ideally their logo.
545
+ */
546
+ curatorLogoUrl: string | undefined;
547
+ /**
548
+ * Extra / optional fields for future extensibility. Recommended keys include: twitter_url.
549
+ */
550
+ extraFields: Record<string, string>;
551
+ }
552
+ /**
553
+ * On-chain representation of a vault that manages user collateral and
554
+ * interacts with clearing houses on their behalf.
555
+ */
556
+ export interface PerpetualsVaultObject {
557
+ /**
558
+ * Unique identifier for distinct network identification.
559
+ */
560
+ objectId: ObjectId;
561
+ /**
562
+ * Contract version number for controlled upgrades.
563
+ */
564
+ version: bigint;
565
+ /**
566
+ * Curator-provided metadata used for vault discovery and display.
567
+ *
568
+ * This data is expected to be relatively stable and is typically set at
569
+ * creation time (though it may be updatable depending on protocol rules).
570
+ */
571
+ metadata: PerpetualsVaultMetatada;
572
+ /**
573
+ * Supply of LP coins from a `TreasuryCap` for liquidity integrity.
574
+ *
575
+ * This is the total minted supply of the vault's LP token. Together with
576
+ * `tvlUsd` and `totalCollateral`, this is used to derive LP share price.
577
+ */
578
+ lpSupply: Balance;
579
+ /**
580
+ * Total balance of underlying Coin (`C`), deposited by users.
581
+ *
582
+ * "Idle" collateral is not currently allocated to any clearing house
583
+ * position. It remains held by the vault and can be used for new allocations
584
+ * or withdrawals (subject to lock/queue rules).
585
+ */
586
+ idleCollateral: Balance;
587
+ /**
588
+ * USD valuation of `idleCollateral` at query time.
589
+ *
590
+ * This is derived using the vault's collateral oracle price and is provided
591
+ * for UI convenience.
592
+ */
593
+ idleCollateralUsd: number;
594
+ /**
595
+ * Total collateral owned by the vault in native units.
596
+ *
597
+ * This is the sum of:
598
+ * - idle collateral held directly by the vault, and
599
+ * - collateral currently allocated across clearing houses/positions.
600
+ */
601
+ totalCollateral: Balance;
602
+ /**
603
+ * USD valuation of `totalCollateral` at query time.
604
+ *
605
+ * This is typically derived from `totalCollateral` and the collateral oracle
606
+ * price used by the vault.
607
+ */
608
+ totalCollateralUsd: number;
609
+ /**
610
+ * Total value locked in USD for this vault.
611
+ *
612
+ * Depending on protocol accounting, this may match `totalCollateralUsd`, or
613
+ * may incorporate additional adjustments. It is the primary headline number
614
+ * used for ranking and display.
615
+ */
616
+ tvlUsd: number;
617
+ /**
618
+ * IDs of `ClearingHouse` where `Vault` has positions.
619
+ */
620
+ marketIds: PerpetualsMarketId[];
621
+ /**
622
+ * Vault parameters
623
+ */
624
+ parameters: {
625
+ /**
626
+ * Lock-in duration for engaged assets in milliseconds.
627
+ */
628
+ lockPeriodMs: bigint;
629
+ /**
630
+ * Fee rate for vault's owner, collected from user's profits when they withdraw
631
+ */
632
+ performanceFeePercentage: number;
633
+ /**
634
+ * Delay period to wait for eventual force withdrawing
635
+ *
636
+ * Force-withdrawal is an emergency/escape hatch path; this delay gives the
637
+ * vault time to unwind positions before executing the withdrawal.
638
+ */
639
+ forceWithdrawDelayMs: bigint;
640
+ /**
641
+ * Price feed storage id idetifying the oracle price for `C`
642
+ */
643
+ collateralPriceFeedStorageId: ObjectId;
644
+ /**
645
+ * Source object ID for the collateral price feed storage.
646
+ *
647
+ * Some oracle integrations separate the "storage object" from the "source"
648
+ * (e.g., an aggregator or publisher object). This field identifies the
649
+ * upstream source used to populate `collateralPriceFeedStorageId`.
650
+ */
651
+ collateralPriceFeedStorageSourceId: ObjectId;
652
+ /**
653
+ * Maximum tolerated deviation for the collateral oracle price.
654
+ *
655
+ * Used as a safety bound when valuing deposits/withdrawals and computing
656
+ * USD conversions. This is typically a fixed-point or scaled bigint value,
657
+ * consistent with the on-chain oracle representation.
658
+ */
659
+ collateralPriceFeedStorageTolerance: bigint;
660
+ /**
661
+ * Maximum margin ratio tolerance for force-withdraw processing.
662
+ *
663
+ * Force-withdraw generally requires closing positions. This tolerance
664
+ * controls how much worse (or better) the resulting margin ratio is allowed
665
+ * to be, compared to a target/expected value, before rejecting the action.
666
+ */
667
+ maxForceWithdrawMarginRatioTolerance: number;
668
+ /**
669
+ * Scaling factor to apply to `C` to convert a balance to ifixed.
670
+ */
671
+ /**
672
+ * Used to calculate user's minimum deposit value in usd
673
+ */
674
+ scalingFactor: number;
675
+ /**
676
+ * The maximum number of distinct `ClearingHouse`.
677
+ */
678
+ maxMarketsInVault: bigint;
679
+ /**
680
+ * The maximum number of pending orders allowed for a single position in the `Vault`.
681
+ */
682
+ maxPendingOrdersPerPosition: bigint;
683
+ /**
684
+ * Maximum total collateral (native units) that can be deposited into the vault.
685
+ *
686
+ * This is a capacity/risk control parameter. Deposits that would cause the
687
+ * vault to exceed this limit should be rejected by the protocol/backend.
688
+ */
689
+ maxTotalDepositedCollateral: Balance;
690
+ /** Minimum position margin (USD) to trigger full close during force withdraw. */
691
+ minForceWithdrawValueUsd: number;
692
+ };
693
+ /** Owner address of the vault. */
694
+ ownerAddress: SuiAddress;
695
+ /** Creation timestamp of the vault. */
696
+ creationTimestamp: Timestamp | undefined;
697
+ /** Underlying perpetuals account ID that the vault uses. */
698
+ accountId: PerpetualsAccountId;
699
+ /** Account object ID used by the vault. */
700
+ accountObjectId: ObjectId;
701
+ /** Collateral coin type accepted by this vault. */
702
+ collateralCoinType: CoinType;
703
+ /**
704
+ * LP coin type minted by this vault.
705
+ *
706
+ * This is the `Coin<T>` type used to represent shares in the vault. Users
707
+ * receive LP coins on deposit and burn/return them on withdrawal.
708
+ */
709
+ lpCoinType: CoinType;
710
+ /** Decimals for the LP token minted by this vault. */
711
+ lpCoinDecimals: CoinDecimal;
712
+ /**
713
+ * Estimated monthly APR for this vault, expressed as a percentage.
714
+ *
715
+ * This is typically computed off-chain from historical performance and/or
716
+ * accounting state. It is a display metric and should not be treated as a
717
+ * guaranteed rate.
718
+ */
719
+ monthlyAprPercentage: Percentage;
720
+ /** The annualized percentage return from incentives (added yields) */
721
+ monthlyBoostedAprPercentage: Percentage;
722
+ /** Indicates the vault is temporarily paused until the timestamp (if present). */
723
+ pausedUntilTimestamp: bigint | undefined;
724
+ /** Timestamp at which `pause_vault_for_force_withdraw` was last called. */
725
+ lastPausedTimestamp: Timestamp;
726
+ }
727
+ /**
728
+ * Represents a single pending vault withdrawal request.
729
+ */
730
+ export interface PerpetualsVaultWithdrawRequest {
731
+ /**
732
+ * The address of the user that created the withdraw request
733
+ */
734
+ userAddress: SuiAddress;
735
+ /**
736
+ * Object id of the vault associated with the withdraw request
737
+ */
738
+ vaultId: SuiAddress;
739
+ /**
740
+ * The amount of the shares requested for withdrawal.
741
+ */
742
+ lpAmountIn: Balance;
743
+ /**
744
+ * USD valuation of `lpAmountIn` at request time (or at query time, depending on backend).
745
+ *
746
+ * This field is provided for UI convenience and may be computed using the
747
+ * vault's LP share price.
748
+ */
749
+ lpAmountInUsd: number;
750
+ /**
751
+ * Timestamp of request's creation
752
+ */
753
+ requestTimestamp: Timestamp;
754
+ /**
755
+ * The minimum amount of the collateral balance expected as output for this withdrawal
756
+ *
757
+ * This acts as a slippage/price-protection bound for the user.
758
+ */
759
+ minCollateralAmountOut: Balance;
760
+ /**
761
+ * USD valuation of `minCollateralAmountOut`, using the vault's collateral oracle.
762
+ *
763
+ * Provided for display; the on-chain constraint is enforced by
764
+ * `minCollateralAmountOut` (native units).
765
+ */
766
+ minCollateralAmountOutUsd: number;
767
+ }
768
+ /**
769
+ * Event emitted when a clearing house (market) is upgraded to a new version.
770
+ */
152
771
  export interface UpdatedMarketVersionEvent extends Event {
772
+ /** Market identifier for which the version changed. */
153
773
  marketId: PerpetualsMarketId;
774
+ /** New version value. */
154
775
  version: bigint;
155
776
  }
777
+ /**
778
+ * Type guard for {@link UpdatedMarketVersionEvent}.
779
+ *
780
+ * @param event - Generic event.
781
+ * @returns `true` if this is an `UpdatedMarketVersionEvent`.
782
+ */
156
783
  export declare const isUpdatedMarketVersion: (event: Event) => event is UpdatedMarketVersionEvent;
157
- export interface PerpetualsAccountCollateralChangesWithCursor {
784
+ /**
785
+ * Cursor-based response wrapping a list of collateral changes for an account.
786
+ */
787
+ export type ApiPerpetualsAccountCollateralHistoryResponse = ApiPerpetualsHistoricalDataWithCursorResponse & {
788
+ /** Collateral changes in chronological order. */
158
789
  collateralChanges: PerpetualsAccountCollateralChange[];
159
- nextCursor: Timestamp | undefined;
160
- }
790
+ };
791
+ /**
792
+ * Single collateral change record for an account.
793
+ *
794
+ * This may represent:
795
+ * - Deposits / withdrawals
796
+ * - Liquidations
797
+ * - Funding settlements
798
+ * - Trading fees
799
+ */
161
800
  export type PerpetualsAccountCollateralChange = {
801
+ /** When the change occurred. */
162
802
  timestamp: Timestamp;
803
+ /** Sui transaction digest that produced this change. */
163
804
  txDigest: TransactionDigest;
805
+ /** Market ID, if applicable (can be undefined for global changes). */
164
806
  marketId: PerpetualsMarketId | undefined;
807
+ /** Concrete event type fully qualified (Sui struct type). */
165
808
  eventType: AnyObjectType;
809
+ /** Net change in collateral units. */
166
810
  collateralChange: number;
811
+ /** Net change in USD value. */
167
812
  collateralChangeUsd: number;
813
+ /** Optional breakdown of fees, with variant shapes based on event. */
814
+ fees?: {
815
+ netFeesUsd: number;
816
+ liquidationFeesUsd: number;
817
+ forceCancelFeesUsd: number;
818
+ insuranceFundFeesUsd: number;
819
+ } | {
820
+ netFeesUsd: number;
821
+ liqorFeesUsd: number;
822
+ } | {
823
+ netFeesUsd: number;
824
+ };
825
+ };
826
+ /**
827
+ * Cursor-based response wrapping a list of orders for an account.
828
+ */
829
+ export type ApiPerpetualsAccountOrderHistoryResponse = ApiPerpetualsHistoricalDataWithCursorResponse & {
830
+ /** Orders in chronological order. */
831
+ orders: PerpetualsAccountOrderHistoryData[];
168
832
  };
169
- export interface PerpetualsAccountTradesWithCursor {
170
- trades: PerpetualsAccountTrade[];
171
- nextCursor: Timestamp | undefined;
833
+ /**
834
+ * Historical margin data point for an account, used in margin history views.
835
+ */
836
+ export interface PerpetualsAccountMarginHistoryData {
837
+ /** Timestamp of this snapshot. */
838
+ timestamp: Timestamp;
839
+ /** Available collateral in USD. */
840
+ availableCollateralUsd: number;
841
+ /** Total equity in USD. */
842
+ totalEquityUsd: number;
843
+ /** Unrealized funding PnL in USD at that time. */
844
+ unrealizedFundingsUsd: number;
845
+ /** Unrealized position PnL in USD at that time. */
846
+ unrealizedPnlUsd: number;
172
847
  }
173
- export type PerpetualsAccountTrade = {
848
+ /**
849
+ * Individual order affecting an account.
850
+ */
851
+ export type PerpetualsAccountOrderHistoryData = {
852
+ /** Timestamp of the order. */
174
853
  timestamp: Timestamp;
854
+ /** Sui transaction digest. */
175
855
  txDigest: TransactionDigest;
856
+ /** Market in which this order occurred. */
176
857
  marketId: PerpetualsMarketId;
858
+ /** Concrete event type. */
177
859
  eventType: AnyObjectType;
860
+ /** Side of the order relative to the account (Bid/Ask). */
178
861
  side: PerpetualsOrderSide;
179
- } & ({
180
- orderPrice: bigint;
181
- } | {
862
+ /** Price for this order. */
182
863
  price: number;
183
- }) & ({
184
- sizeLots: bigint;
185
- } | {
864
+ /** Size in base units. */
186
865
  size: number;
187
- });
866
+ /** Optional stop-loss / take-profit data. */
867
+ slTp?: {
868
+ /** Optional stop-loss trigger price based on the index price. */
869
+ stopLossIndexPrice?: number;
870
+ /** Optional take-profit trigger price based on the index price. */
871
+ takeProfitIndexPrice?: number;
872
+ /** Unique order identifier for limit order sl/tp is tied to. */
873
+ limitOrderId?: PerpetualsOrderId;
874
+ };
875
+ /** Stop order data that is not a stop-loss / take-profit order
876
+ * (e.g. generic trigger orders).
877
+ */
878
+ stopOrder?: {
879
+ /** Index price at which the stop order should trigger. */
880
+ stopIndexPrice: number;
881
+ };
882
+ };
883
+ /**
884
+ * Event emitted when collateral is deposited into an account.
885
+ */
188
886
  export interface DepositedCollateralEvent extends Event {
189
887
  accountId: PerpetualsAccountId;
190
888
  collateralDelta: Balance;
191
889
  }
890
+ /**
891
+ * Event emitted when collateral is allocated from general account collateral
892
+ * into a specific market position.
893
+ */
192
894
  export interface AllocatedCollateralEvent extends Event {
895
+ marketId: PerpetualsMarketId;
193
896
  accountId: PerpetualsAccountId;
194
897
  collateralDelta: Balance;
195
- positionCollateralAfter: IFixed;
196
898
  }
899
+ /**
900
+ * Event emitted when collateral is deallocated from a market back to
901
+ * the account's general collateral.
902
+ */
197
903
  export interface DeallocatedCollateralEvent extends Event {
904
+ marketId: PerpetualsMarketId;
198
905
  accountId: PerpetualsAccountId;
199
906
  collateralDelta: Balance;
200
- positionCollateralAfter: IFixed;
201
907
  }
908
+ /**
909
+ * Event emitted when collateral is withdrawn from the account.
910
+ */
202
911
  export interface WithdrewCollateralEvent extends Event {
203
912
  accountId: PerpetualsAccountId;
204
913
  collateralDelta: Balance;
205
914
  }
915
+ /**
916
+ * Event emitted when funding is settled for an account and market.
917
+ */
206
918
  export interface SettledFundingEvent extends Event {
207
919
  accountId: PerpetualsAccountId;
208
- collateralDeltaUsd: IFixed;
920
+ collateralDeltaUsd: number;
209
921
  marketId: PerpetualsMarketId;
210
- marketFundingRateLong: IFixed;
211
- marketFundingRateShort: IFixed;
922
+ marketFundingRateLong: number;
923
+ marketFundingRateShort: number;
212
924
  }
213
- export type CollateralEvent = WithdrewCollateralEvent | DepositedCollateralEvent | SettledFundingEvent | LiquidatedEvent | FilledTakerOrderEvent | FilledMakerOrderEvent | AllocatedCollateralEvent | DeallocatedCollateralEvent;
925
+ /**
926
+ * Union of all event types that impact account collateral.
927
+ */
928
+ export type CollateralEvent = WithdrewCollateralEvent | DepositedCollateralEvent | SettledFundingEvent | LiquidatedEvent | FilledTakerOrderEvent | FilledMakerOrdersEvent | AllocatedCollateralEvent | DeallocatedCollateralEvent;
929
+ /**
930
+ * Type guard for {@link WithdrewCollateralEvent}.
931
+ */
214
932
  export declare const isWithdrewCollateralEvent: (event: Event) => event is WithdrewCollateralEvent;
933
+ /**
934
+ * Type guard for {@link DepositedCollateralEvent}.
935
+ */
215
936
  export declare const isDepositedCollateralEvent: (event: Event) => event is DepositedCollateralEvent;
937
+ /**
938
+ * Type guard for {@link DeallocatedCollateralEvent}.
939
+ */
216
940
  export declare const isDeallocatedCollateralEvent: (event: Event) => event is DeallocatedCollateralEvent;
941
+ /**
942
+ * Type guard for {@link AllocatedCollateralEvent}.
943
+ */
217
944
  export declare const isAllocatedCollateralEvent: (event: Event) => event is AllocatedCollateralEvent;
945
+ /**
946
+ * Type guard for {@link SettledFundingEvent}.
947
+ */
218
948
  export declare const isSettledFundingEvent: (event: Event) => event is SettledFundingEvent;
949
+ /**
950
+ * Event emitted when an account is liquidated in a given market.
951
+ */
219
952
  export interface LiquidatedEvent extends Event {
220
953
  accountId: PerpetualsAccountId;
221
- collateralDeltaUsd: IFixed;
954
+ collateralDeltaUsd: number;
955
+ /** Liquidator's account ID. */
222
956
  liqorAccountId: PerpetualsAccountId;
223
- size: bigint;
224
- markPrice: IFixed;
225
957
  marketId: PerpetualsMarketId;
226
958
  side: PerpetualsOrderSide;
959
+ /** Amount of base asset liquidated. */
960
+ baseLiquidated: number;
961
+ /** Amount of quote asset liquidated. */
962
+ quoteLiquidated: number;
963
+ /** Liquidated account's PnL in USD for this event. */
964
+ liqeePnlUsd: number;
965
+ /** Liquidation fee paid in USD. */
966
+ liquidationFeesUsd: number;
967
+ /** Force-cancel fees collected in USD. */
968
+ forceCancelFeesUsd: number;
969
+ /** Fees directed to the insurance fund in USD. */
970
+ insuranceFundFeesUsd: number;
227
971
  }
972
+ /**
973
+ * Type guard for {@link LiquidatedEvent}.
974
+ */
228
975
  export declare const isLiquidatedEvent: (event: Event) => event is LiquidatedEvent;
976
+ /**
977
+ * Event emitted when a new perpetuals account is created for a user.
978
+ */
229
979
  export interface CreatedAccountEvent extends Event {
230
980
  user: SuiAddress;
231
981
  accountId: PerpetualsAccountId;
232
982
  }
233
- export interface PerpetualsTradeHistoryData {
983
+ /**
984
+ * Event emitted when an account's initial margin ratio for a position
985
+ * is explicitly set or adjusted.
986
+ */
987
+ export interface SetPositionInitialMarginRatioEvent extends Event {
988
+ marketId: PerpetualsMarketId;
989
+ accountId: PerpetualsAccountId;
990
+ initialMarginRatio: number;
991
+ }
992
+ /**
993
+ * Trade data used for market-level trade history.
994
+ */
995
+ export interface PerpetualsMarketOrderHistoryData {
996
+ /** Timestamp of the trade. */
234
997
  timestamp: Timestamp;
998
+ /** Transaction digest. */
235
999
  txDigest: TransactionDigest;
1000
+ /** Side of the trade. */
236
1001
  side: PerpetualsOrderSide;
1002
+ /** Filled size in base units. */
237
1003
  sizeFilled: number;
1004
+ /** Order price (limit price) used for the trade. */
238
1005
  orderPrice: number;
239
1006
  }
240
- export interface PerpetualsTradeHistoryWithCursor {
241
- trades: PerpetualsTradeHistoryData[];
242
- nextCursor: Timestamp | undefined;
243
- }
244
- export interface OrderbookPostReceiptEvent extends Event {
245
- accountId: PerpetualsAccountId;
246
- orderId: PerpetualsOrderId;
247
- size: bigint;
248
- }
1007
+ /**
1008
+ * Cursor-based wrapper for market-level order history.
1009
+ */
1010
+ export type ApiPerpetualsMarketOrderHistoryResponse = ApiPerpetualsHistoricalDataWithCursorResponse & {
1011
+ /** Orders in this page. */
1012
+ orders: PerpetualsMarketOrderHistoryData[];
1013
+ };
1014
+ /**
1015
+ * Event emitted when an order is filled or dropped by the orderbook
1016
+ * (book-keeping receipt).
1017
+ */
249
1018
  export interface OrderbookFillReceiptEvent extends Event {
250
1019
  accountId: PerpetualsAccountId;
251
1020
  orderId: PerpetualsOrderId;
252
1021
  size: bigint;
1022
+ /** Whether the order was dropped instead of filled. */
253
1023
  dropped: boolean;
254
1024
  }
1025
+ /**
1026
+ * Event emitted when an order is canceled.
1027
+ */
255
1028
  export interface CanceledOrderEvent extends Event {
256
1029
  accountId: PerpetualsAccountId;
257
1030
  marketId: PerpetualsMarketId;
@@ -259,366 +1032,1937 @@ export interface CanceledOrderEvent extends Event {
259
1032
  size: bigint;
260
1033
  orderId: PerpetualsOrderId;
261
1034
  }
1035
+ /**
1036
+ * Event emitted when a new order is posted to the orderbook.
1037
+ */
262
1038
  export interface PostedOrderEvent extends Event {
263
1039
  accountId: PerpetualsAccountId;
264
1040
  marketId: PerpetualsMarketId;
265
- side: PerpetualsOrderSide;
1041
+ orderId: PerpetualsOrderId;
266
1042
  size: bigint;
267
- asksQuantity: IFixed;
268
- bidsQuantity: IFixed;
1043
+ reduceOnly: boolean;
1044
+ expiryTimestamp?: bigint;
1045
+ }
1046
+ /**
1047
+ * Event emitted when one or more maker orders are filled against a taker.
1048
+ */
1049
+ export interface FilledMakerOrdersEvent extends Event {
1050
+ /** List of per-maker fills for this aggregate event. */
1051
+ events: FilledMakerOrderEventFields[];
269
1052
  }
270
- export interface FilledMakerOrderEvent extends Event {
1053
+ /**
1054
+ * Details for a single maker order fill inside a {@link FilledMakerOrdersEvent}.
1055
+ */
1056
+ export interface FilledMakerOrderEventFields {
271
1057
  accountId: PerpetualsAccountId;
272
- collateralDeltaUsd: IFixed;
1058
+ takerAccountId: PerpetualsAccountId;
1059
+ collateralDeltaUsd: number;
273
1060
  marketId: PerpetualsMarketId;
274
1061
  side: PerpetualsOrderSide;
275
1062
  size: bigint;
1063
+ sizeRemaining: bigint;
276
1064
  orderId: PerpetualsOrderId;
277
1065
  dropped: boolean;
278
- baseAssetAmount: IFixed;
279
- quoteAssetNotionalAmount: IFixed;
280
- asksQuantity: IFixed;
281
- bidsQuantity: IFixed;
1066
+ pnlUsd: number;
1067
+ feesUsd: number;
1068
+ canceledSize: bigint;
282
1069
  }
1070
+ /**
1071
+ * Event emitted when a taker order is executed.
1072
+ */
283
1073
  export interface FilledTakerOrderEvent extends Event {
284
1074
  accountId: PerpetualsAccountId;
285
- collateralDeltaUsd: IFixed;
1075
+ collateralDeltaUsd: number;
286
1076
  marketId: PerpetualsMarketId;
287
- baseAssetAmount: IFixed;
288
- quoteAssetNotionalAmount: IFixed;
289
1077
  side: PerpetualsOrderSide;
290
- baseAssetDelta: IFixed;
291
- quoteAssetDelta: IFixed;
292
- liquidatedVolume: IFixed;
1078
+ baseAssetDelta: number;
1079
+ quoteAssetDelta: number;
1080
+ takerPnlUsd: number;
1081
+ takerFeesUsd: number;
293
1082
  }
294
- export type PerpetualsOrderEvent = CanceledOrderEvent | PostedOrderReceiptEvent | FilledMakerOrderEvent | FilledTakerOrderEvent | LiquidatedEvent | ReducedOrderEvent;
295
- export interface PostedOrderReceiptEvent extends Event {
1083
+ /**
1084
+ * Union of all order-related events in the protocol.
1085
+ */
1086
+ export type PerpetualsOrderEvent = CanceledOrderEvent | PostedOrderEvent | PostedOrderEvent | FilledMakerOrdersEvent | FilledTakerOrderEvent | LiquidatedEvent | ReducedOrderEvent;
1087
+ /**
1088
+ * Event emitted when an order is posted.
1089
+ *
1090
+ * NOTE: This is a second definition of `PostedOrderEvent` used in a
1091
+ * simplified context (without `reduceOnly` / `expiryTimestamp`).
1092
+ */
1093
+ export interface PostedOrderEvent extends Event {
296
1094
  accountId: PerpetualsAccountId;
297
1095
  marketId: PerpetualsMarketId;
298
1096
  orderId: PerpetualsOrderId;
299
1097
  size: bigint;
300
1098
  side: PerpetualsOrderSide;
301
1099
  }
1100
+ /**
1101
+ * Event emitted when an existing order is reduced (partial cancellation or
1102
+ * adjustment of size).
1103
+ */
302
1104
  export interface ReducedOrderEvent extends Event {
303
1105
  marketId: PerpetualsMarketId;
304
1106
  accountId: PerpetualsAccountId;
305
1107
  sizeChange: bigint;
306
1108
  orderId: PerpetualsOrderId;
307
1109
  }
1110
+ /**
1111
+ * Type guard for {@link CanceledOrderEvent}.
1112
+ */
308
1113
  export declare const isCanceledOrderEvent: (event: Event) => event is CanceledOrderEvent;
1114
+ /**
1115
+ * Type guard for {@link PostedOrderEvent}.
1116
+ */
309
1117
  export declare const isPostedOrderEvent: (event: Event) => event is PostedOrderEvent;
310
- export declare const isPostedOrderReceiptEvent: (event: Event) => event is PostedOrderReceiptEvent;
311
- export declare const isFilledMakerOrderEvent: (event: Event) => event is FilledMakerOrderEvent;
1118
+ /**
1119
+ * Type guard for {@link FilledMakerOrdersEvent}.
1120
+ */
1121
+ export declare const isFilledMakerOrdersEvent: (event: Event) => event is FilledMakerOrdersEvent;
1122
+ /**
1123
+ * Type guard for {@link FilledTakerOrderEvent}.
1124
+ */
312
1125
  export declare const isFilledTakerOrderEvent: (event: Event) => event is FilledTakerOrderEvent;
1126
+ /**
1127
+ * Type guard for {@link ReducedOrderEvent}.
1128
+ */
313
1129
  export declare const isReducedOrderEvent: (event: Event) => event is ReducedOrderEvent;
1130
+ /**
1131
+ * Event emitted when a stop order ticket is created.
1132
+ *
1133
+ * Stop order tickets represent off-chain-executable stop orders that
1134
+ * executors can trigger.
1135
+ */
1136
+ export interface CreatedStopOrderTicketEvent extends Event {
1137
+ ticketId: ObjectId;
1138
+ accountId: PerpetualsAccountId;
1139
+ subAccountId?: ObjectId;
1140
+ executors: SuiAddress[];
1141
+ gas: Balance;
1142
+ stopOrderType: PerpetualsStopOrderType;
1143
+ /** Encrypted stop-order details (payload). */
1144
+ encryptedDetails: Byte[];
1145
+ }
1146
+ /**
1147
+ * Event emitted when a stop order ticket is executed.
1148
+ */
1149
+ export interface ExecutedStopOrderTicketEvent extends Event {
1150
+ ticketId: ObjectId;
1151
+ accountId: PerpetualsAccountId;
1152
+ executor: SuiAddress;
1153
+ }
1154
+ /**
1155
+ * Event emitted when a stop order ticket is deleted or canceled.
1156
+ */
1157
+ export interface DeletedStopOrderTicketEvent extends Event {
1158
+ ticketId: ObjectId;
1159
+ accountId: PerpetualsAccountId;
1160
+ subAccountId?: ObjectId;
1161
+ executor: SuiAddress;
1162
+ }
1163
+ /**
1164
+ * Event emitted when the details (payload) of a stop order ticket are edited.
1165
+ */
1166
+ export interface EditedStopOrderTicketDetailsEvent extends Event {
1167
+ ticketId: ObjectId;
1168
+ accountId: PerpetualsAccountId;
1169
+ subAccountId?: ObjectId;
1170
+ encryptedDetails: Byte[];
1171
+ stopOrderType: PerpetualsStopOrderType;
1172
+ }
1173
+ /**
1174
+ * Event emitted when the set of executors for a stop order ticket is edited.
1175
+ */
1176
+ export interface EditedStopOrderTicketExecutorEvent extends Event {
1177
+ ticketId: ObjectId;
1178
+ accountId: PerpetualsAccountId;
1179
+ subAccountId?: ObjectId;
1180
+ executors: SuiAddress[];
1181
+ }
1182
+ /**
1183
+ * Event emitted when deallocated collateral is transferred from a clearing
1184
+ * house to an account or subaccount.
1185
+ */
1186
+ export interface TransferredDeallocatedCollateralEvent extends Event {
1187
+ chId: ObjectId;
1188
+ /** Account or SubAccount object id. */
1189
+ objectId: ObjectId;
1190
+ accountId: PerpetualsAccountId;
1191
+ collateral: Balance;
1192
+ }
1193
+ /**
1194
+ * Event emitted when an account or subaccount receives collateral.
1195
+ */
1196
+ export interface ReceivedCollateralEvent extends Event {
1197
+ /** Account or SubAccount object id. */
1198
+ objectId: ObjectId;
1199
+ accountId: PerpetualsAccountId;
1200
+ collateral: Balance;
1201
+ }
1202
+ /**
1203
+ * Event emitted when premium TWAP is updated for a market.
1204
+ */
314
1205
  export interface UpdatedPremiumTwapEvent extends Event {
315
1206
  marketId: PerpetualsMarketId;
316
- bookPrice: IFixed;
317
- indexPrice: IFixed;
318
- premiumTwap: IFixed;
1207
+ bookPrice: number;
1208
+ indexPrice: number;
1209
+ premiumTwap: number;
319
1210
  premiumTwapLastUpdateMs: number;
320
1211
  }
1212
+ /**
1213
+ * Event emitted when spread TWAP is updated for a market.
1214
+ */
321
1215
  export interface UpdatedSpreadTwapEvent extends Event {
322
1216
  marketId: PerpetualsMarketId;
323
- bookPrice: IFixed;
324
- indexPrice: IFixed;
325
- spreadTwap: IFixed;
1217
+ bookPrice: number;
1218
+ indexPrice: number;
1219
+ spreadTwap: number;
326
1220
  spreadTwapLastUpdateMs: number;
327
1221
  }
1222
+ /**
1223
+ * Union of all TWAP-related events.
1224
+ */
328
1225
  export type PerpetualsTwapEvent = UpdatedPremiumTwapEvent | UpdatedSpreadTwapEvent;
1226
+ /**
1227
+ * Type guard for {@link UpdatedPremiumTwapEvent}.
1228
+ */
329
1229
  export declare const isUpdatedPremiumTwapEvent: (event: Event) => event is UpdatedPremiumTwapEvent;
1230
+ /**
1231
+ * Type guard for {@link UpdatedSpreadTwapEvent}.
1232
+ */
330
1233
  export declare const isUpdatedSpreadTwapEvent: (event: Event) => event is UpdatedSpreadTwapEvent;
1234
+ /**
1235
+ * Event emitted when market funding values are updated.
1236
+ */
331
1237
  export interface UpdatedFundingEvent extends Event {
332
1238
  marketId: PerpetualsMarketId;
333
- cumFundingRateLong: IFixed;
334
- cumFundingRateShort: IFixed;
1239
+ cumFundingRateLong: number;
1240
+ cumFundingRateShort: number;
335
1241
  fundingLastUpdateMs: Timestamp;
336
1242
  }
1243
+ /**
1244
+ * Type guard for {@link UpdatedFundingEvent}.
1245
+ */
337
1246
  export declare const isUpdatedFundingEvent: (event: Event) => event is UpdatedFundingEvent;
338
- export interface ApiPerpetualsAccountsBody {
1247
+ /**
1248
+ * Request body for fetching all account caps owned by a given wallet.
1249
+ */
1250
+ export interface ApiPerpetualsOwnedAccountCapsBody {
339
1251
  walletAddress: SuiAddress;
1252
+ collateralCoinTypes?: CoinType[];
340
1253
  }
341
- export type ApiPerpetualsAccountOrderHistoryBody = ApiDataWithCursorBody<Timestamp>;
342
- export type ApiPerpetualsAccountCollateralHistoryBody = ApiDataWithCursorBody<Timestamp>;
343
- export interface ApiPerpetualsSetPositionLeverageBody {
344
- walletAddress: SuiAddress;
345
- bytes: string;
346
- signature: string;
1254
+ /**
1255
+ * Request body for fetching specific admin account caps by their account IDs.
1256
+ */
1257
+ export interface ApiPerpetualsAdminAccountCapsBody {
1258
+ accountIds: PerpetualsAccountId[];
347
1259
  }
348
- export type ApiPerpetualsPreviewOrderBody = (Omit<ApiPerpetualsLimitOrderBody, "collateralChange" | "walletAddress" | "accountObjectId" | "accountObjectVersion" | "accountObjectDigest"> | Omit<ApiPerpetualsMarketOrderBody, "collateralChange" | "walletAddress" | "accountObjectId" | "accountObjectVersion" | "accountObjectDigest"> | Omit<ApiPerpetualsSLTPOrderBody, "collateralChange" | "walletAddress" | "accountObjectId" | "accountObjectVersion" | "accountObjectDigest">) & {
349
- collateralCoinType: CoinType;
1260
+ /**
1261
+ * Response payload for fetching positions for one or more accounts.
1262
+ *
1263
+ * The backend returns a list of {@link PerpetualsAccountObject} snapshots.
1264
+ * Each snapshot includes per-market {@link PerpetualsPosition} data.
1265
+ */
1266
+ export interface ApiPerpetualsAccountPositionsResponse {
1267
+ accounts: PerpetualsAccountObject[];
1268
+ }
1269
+ /**
1270
+ * Request body for fetching positions for a set of accounts.
1271
+ *
1272
+ * `marketIds` can be supplied as an optimization hint to limit the markets
1273
+ * included in each account's returned `positions` array.
1274
+ */
1275
+ export interface ApiPerpetualsAccountPositionsBody {
1276
+ accountIds: PerpetualsAccountId[];
1277
+ marketIds?: PerpetualsMarketId[];
1278
+ }
1279
+ /**
1280
+ * Response payload for fetching admin account caps by explicit account IDs.
1281
+ */
1282
+ export interface ApiPerpetualsAdminAccountCapsResponse {
1283
+ accountCaps: PerpetualsAccountCap[];
1284
+ }
1285
+ /**
1286
+ * Response payload for fetching all account caps owned by a wallet.
1287
+ *
1288
+ * This is typically used during onboarding / wallet connect to discover
1289
+ * existing accounts.
1290
+ */
1291
+ export interface ApiPerpetualsOwnedAccountCapsResponse {
1292
+ accountCaps: PerpetualsAccountCap[];
1293
+ }
1294
+ /**
1295
+ * Generic shape for Perpetuals API historical data requests that include
1296
+ * `beforeTimestampCursor` and `limit` pagination parameters.
1297
+ */
1298
+ export interface ApiPerpetualsHistoricalDataWithCursorBody {
1299
+ /**
1300
+ * Cursor for pagination.
1301
+ */
1302
+ beforeTimestampCursor?: Timestamp;
1303
+ /**
1304
+ * Limit for pagination.
1305
+ */
1306
+ limit?: number;
1307
+ }
1308
+ /**
1309
+ * Generic shape for Perpetuals API historical data responses that include
1310
+ * `nextBeforeTimestampCursor` pagination parameter.
1311
+ */
1312
+ export interface ApiPerpetualsHistoricalDataWithCursorResponse {
1313
+ /**
1314
+ * The next cursor position. If undefined, no more data is available.
1315
+ */
1316
+ nextBeforeTimestampCursor: Timestamp | undefined;
1317
+ }
1318
+ /**
1319
+ * Enumerates the timeframes available for retrieving historical account margin data,
1320
+ * such as `"1D"`, `"1W"`, `"1M"`, etc.
1321
+ */
1322
+ export type PerpetualsAccountMarginHistoryTimeframeKey = "1D" | "1W" | "1M" | "ALL";
1323
+ /**
1324
+ * Request payload for fetching historical margin metrics for an account.
1325
+ */
1326
+ export interface ApiPerpetualsAccountMarginHistoryBody {
1327
+ /**
1328
+ * Account ID.
1329
+ */
350
1330
  accountId: PerpetualsAccountId;
351
- lotSize: number;
352
- tickSize: number;
353
- leverage: number;
1331
+ /**
1332
+ * Timeframe from which to obtain historical data from.
1333
+ */
1334
+ timeframe: PerpetualsAccountMarginHistoryTimeframeKey;
1335
+ }
1336
+ /**
1337
+ * Response payload for historical margin metrics.
1338
+ *
1339
+ * The returned array is ordered chronologically by `timestamp` (oldest -> newest)
1340
+ * unless the backend specifies otherwise.
1341
+ */
1342
+ export interface ApiPerpetualsAccountMarginHistoryResponse {
1343
+ marginHistoryDatas: PerpetualsAccountMarginHistoryData[];
1344
+ }
1345
+ /**
1346
+ * Request body for fetching account-level order history with a cursor.
1347
+ */
1348
+ export type ApiPerpetualsMarketOrderHistoryBody = ApiPerpetualsHistoricalDataWithCursorBody & {
1349
+ marketId: PerpetualsMarketId;
354
1350
  };
355
- export interface ApiPerpetualsPreviewCancelOrdersBody {
1351
+ /**
1352
+ * Request body for fetching account-level order history with a cursor.
1353
+ */
1354
+ export type ApiPerpetualsAccountOrderHistoryBody = ApiPerpetualsHistoricalDataWithCursorBody & {
356
1355
  accountId: PerpetualsAccountId;
357
- collateralCoinType: CoinType;
1356
+ authentication?: {
1357
+ walletAddress: SuiAddress;
1358
+ bytes: string;
1359
+ signature: string;
1360
+ };
1361
+ };
1362
+ /**
1363
+ * Request body for fetching account collateral history with a cursor.
1364
+ */
1365
+ export type ApiPerpetualsAccountCollateralHistoryBody = ApiPerpetualsHistoricalDataWithCursorBody & {
1366
+ accountId: PerpetualsAccountId;
1367
+ authentication?: {
1368
+ walletAddress: SuiAddress;
1369
+ bytes: string;
1370
+ signature: string;
1371
+ };
1372
+ };
1373
+ /**
1374
+ * Request body for previewing a market order placement (before sending a tx).
1375
+ *
1376
+ * This version is used by the API and includes account or vault context.
1377
+ */
1378
+ export type ApiPerpetualsPreviewPlaceMarketOrderBody = Omit<ApiPerpetualsMarketOrderBody, "collateralChange" | "walletAddress" | "hasPosition" | "cancelSlTp" | "txKind" | "accountId" | "slTp" | "slippage"> & {
1379
+ /** Optional leverage override for the preview. */
1380
+ leverage?: number;
1381
+ } & ({
1382
+ accountId: PerpetualsAccountId | undefined;
1383
+ } | {
1384
+ vaultId: ObjectId | undefined;
1385
+ });
1386
+ /**
1387
+ * Request body for previewing a limit order placement (before sending a tx).
1388
+ *
1389
+ * This version is used by the API and includes account or vault context.
1390
+ */
1391
+ export type ApiPerpetualsPreviewPlaceLimitOrderBody = Omit<ApiPerpetualsLimitOrderBody, "collateralChange" | "walletAddress" | "hasPosition" | "cancelSlTp" | "txKind" | "accountId" | "slTp"> & {
1392
+ /** Optional leverage override for the preview. */
1393
+ leverage?: number;
1394
+ } & ({
1395
+ accountId: PerpetualsAccountId | undefined;
1396
+ } | {
1397
+ vaultId: ObjectId | undefined;
1398
+ });
1399
+ /**
1400
+ * Request body for previewing cancel-order operations.
1401
+ */
1402
+ export type ApiPerpetualsPreviewCancelOrdersBody = {
1403
+ /** Per-market mapping of order IDs to cancel. */
358
1404
  marketIdsToData: Record<PerpetualsMarketId, {
359
1405
  orderIds: PerpetualsOrderId[];
360
- leverage: number;
361
1406
  }>;
362
- }
363
- export interface ApiPerpetualsPreviewReduceOrdersBody {
364
- marketId: PerpetualsMarketId;
1407
+ } & ({
365
1408
  accountId: PerpetualsAccountId;
1409
+ accountCapId?: ObjectId;
1410
+ } | {
1411
+ vaultId: ObjectId;
1412
+ });
1413
+ /**
1414
+ * Request body for previewing a leverage change for a given position.
1415
+ */
1416
+ export type ApiPerpetualsPreviewSetLeverageBody = {
1417
+ marketId: PerpetualsMarketId;
366
1418
  leverage: number;
367
- orderIds: PerpetualsOrderId[];
368
- sizesToSubtract: bigint[];
369
- collateralCoinType: CoinType;
370
- }
371
- export type ApiPerpetualsPreviewReduceOrdersResponse = {
1419
+ } & ({
1420
+ accountId: PerpetualsAccountId;
1421
+ accountCapId?: ObjectId;
1422
+ } | {
1423
+ vaultId: ObjectId;
1424
+ });
1425
+ /**
1426
+ * Request body for previewing a collateral allocation/deallocation for a given position.
1427
+ */
1428
+ export type ApiPerpetualsPreviewEditCollateralBody = {
1429
+ marketId: PerpetualsMarketId;
1430
+ collateralChange: Balance;
1431
+ } & ({
1432
+ accountId: PerpetualsAccountId;
1433
+ accountCapId?: ObjectId;
1434
+ } | {
1435
+ vaultId: ObjectId;
1436
+ });
1437
+ /**
1438
+ * Response type for a leverage preview request.
1439
+ *
1440
+ * Either returns an error, or the position and collateral after the change.
1441
+ */
1442
+ export type ApiPerpetualsPreviewSetLeverageResponse = {
372
1443
  error: string;
373
1444
  } | {
374
- positionAfterReduceOrders: PerpetualsPosition;
1445
+ updatedPosition: PerpetualsPosition;
375
1446
  collateralChange: number;
376
1447
  };
377
- export type ApiPerpetualsPreviewOrderResponse = {
1448
+ /**
1449
+ * Response type for a allocate/deallocate collateral preview request.
1450
+ *
1451
+ * Either returns an error, or the position and collateral after the change.
1452
+ */
1453
+ export type ApiPerpetualsPreviewEditCollateralResponse = {
378
1454
  error: string;
379
1455
  } | {
380
- positionAfterOrder: PerpetualsPosition;
1456
+ updatedPosition: PerpetualsPosition;
1457
+ collateralChange: number;
1458
+ };
1459
+ /**
1460
+ * Generic response type for a place-order preview (market or limit).
1461
+ */
1462
+ export type ApiPerpetualsPreviewPlaceOrderResponse = {
1463
+ error: string;
1464
+ } | {
1465
+ /** Simulated position after the market order. */
1466
+ updatedPosition: PerpetualsPosition;
1467
+ /** Absolute price slippage between reference price and execution price. */
381
1468
  priceSlippage: number;
382
- percentSlippage: Percentage;
1469
+ /** Relative price slippage expressed as a fraction
1470
+ * (e.g. `0.01` == 1% slippage). */
1471
+ percentSlippage: number;
1472
+ /** Size that is expected to be filled immediately (in base units). */
383
1473
  filledSize: number;
1474
+ /** Notional value in USD of the `filledSize`. */
384
1475
  filledSizeUsd: number;
1476
+ /** Any size that remains posted as liquidity (for market orders this is
1477
+ * usually zero unless partially resting is supported). */
385
1478
  postedSize: number;
1479
+ /** Notional value in USD of the `postedSize`. For pure market orders this
1480
+ * is typically `0`. */
386
1481
  postedSizeUsd: number;
1482
+ /** Net collateral change in USD (e.g. fees, margin changes). */
387
1483
  collateralChange: number;
1484
+ /** Effective execution price for the filled portion of the order. */
388
1485
  executionPrice: number;
1486
+ /** Whether there is an existing position in this market. */
1487
+ hasPosition: boolean;
1488
+ /** True is position is closed. */
1489
+ cancelSlTp: boolean;
389
1490
  };
1491
+ /**
1492
+ * Response type for cancel-order preview.
1493
+ */
390
1494
  export type ApiPerpetualsPreviewCancelOrdersResponse = {
391
1495
  error: string;
392
1496
  } | {
393
- marketIdsToPositionAfterCancelOrders: Record<PerpetualsMarketId, PerpetualsPosition>;
394
- collateralChange: number;
1497
+ marketIdsToData: Record<PerpetualsMarketId, {
1498
+ updatedPosition: PerpetualsPosition;
1499
+ collateralChange: number;
1500
+ }>;
395
1501
  };
1502
+ /**
1503
+ * Request body for computing an execution price for a hypothetical trade
1504
+ * using the current orderbook state and oracle prices.
1505
+ */
396
1506
  export interface ApiPerpetualsExecutionPriceBody {
397
1507
  side: PerpetualsOrderSide;
398
1508
  size: bigint;
1509
+ /** Lot size used to discretize the order size. */
399
1510
  lotSize: number;
1511
+ /** Available collateral. */
400
1512
  collateral: Balance;
1513
+ /** Oracle ID for the base price. */
401
1514
  basePriceFeedId: ObjectId;
1515
+ /** Oracle ID for the collateral price. */
402
1516
  collateralPriceFeedId: ObjectId;
403
- price?: PerpetualsOrderPrice;
1517
+ /** Optional user-specified price constraint. */
1518
+ price?: number;
404
1519
  }
1520
+ /**
1521
+ * Response body for execution price previews.
1522
+ */
405
1523
  export interface ApiPerpetualsExecutionPriceResponse {
406
1524
  executionPrice: number;
407
1525
  sizeFilled: number;
408
1526
  sizePosted: number;
409
1527
  fills: PerpetualsFilledOrderData[];
410
1528
  }
411
- export type ApiPerpetualsHistoricalMarketDataResponse = PerpetualsMarketCandleDataPoint[];
1529
+ /**
1530
+ * Request payload for fetching historical candle (OHLCV) data for a given
1531
+ * perpetuals market.
1532
+ */
1533
+ export interface ApiPerpetualsMarketCandleHistoryBody {
1534
+ /**
1535
+ * Identifier of the perpetuals market whose candles you want to fetch.
1536
+ *
1537
+ * Must be a valid on-chain market ID.
1538
+ */
1539
+ marketId: PerpetualsMarketId;
1540
+ /**
1541
+ * Start of the time range to query, as a Unix timestamp in **milliseconds**.
1542
+ */
1543
+ fromTimestamp: Timestamp;
1544
+ /**
1545
+ * End of the time range to query, as a Unix timestamp in **milliseconds**.
1546
+ */
1547
+ toTimestamp: Timestamp;
1548
+ /**
1549
+ * Candle interval / resolution in **milliseconds** (e.g. 60_000 for 1m,
1550
+ * 300_000 for 5m).
1551
+ */
1552
+ intervalMs: number;
1553
+ }
1554
+ /**
1555
+ * Response type for historical market candle data.
1556
+ */
1557
+ export interface ApiPerpetualsMarketCandleHistoryResponse {
1558
+ candles: PerpetualsMarketCandleDataPoint[];
1559
+ }
1560
+ /**
1561
+ * Request body for computing the maximum order size for an account in a
1562
+ * given market.
1563
+ */
412
1564
  export interface ApiPerpetualsMaxOrderSizeBody {
1565
+ marketId: PerpetualsMarketId;
413
1566
  accountId: PerpetualsAccountId;
414
- collateral: Balance;
415
1567
  side: PerpetualsOrderSide;
416
- leverage: number;
417
- price?: PerpetualsOrderPrice;
1568
+ leverage?: number;
1569
+ price?: number;
1570
+ /**
1571
+ * Optional integrator fee configuration for an order.
1572
+ *
1573
+ * If provided, the integrator specified in the configuration will receive a fee
1574
+ * on the taker volume generated by this order. The integrator must have been
1575
+ * previously approved by the account owner, and the fee must not exceed the
1576
+ * maximum fee the user approved for that integrator.
1577
+ */
1578
+ builderCode?: PerpetualsBuilderCodeParamaters;
418
1579
  }
419
- export interface ApiPerpetualsAccountOrderDatasBody {
420
- orderDatas: {
421
- orderId: PerpetualsOrderId;
422
- currentSize: bigint;
423
- }[];
1580
+ /**
1581
+ * Request body for fetching stop-order data associated with an account or vault,
1582
+ * validated using a wallet signature.
1583
+ */
1584
+ export type ApiPerpetualsStopOrderDatasBody = {
1585
+ walletAddress: SuiAddress;
1586
+ bytes: string;
1587
+ signature: string;
1588
+ marketIds?: PerpetualsMarketId[];
1589
+ } & ({
1590
+ accountId: PerpetualsAccountId;
1591
+ accountCapId?: ObjectId;
1592
+ } | {
1593
+ vaultId: ObjectId;
1594
+ });
1595
+ /**
1596
+ * Response payload for stop-order queries.
1597
+ *
1598
+ * Stop orders are returned in their normalized on-chain shape
1599
+ * ({@link PerpetualsStopOrderData}). Clients should interpret `slTp` vs `nonSlTp`
1600
+ * to determine the stop semantics.
1601
+ */
1602
+ export interface ApiPerpetualsStopOrderDatasResponse {
1603
+ stopOrderDatas: PerpetualsStopOrderData[];
424
1604
  }
425
- export interface ApiPerpetualsCreateAccountBody {
1605
+ /**
1606
+ * Request body for creating a vault capability (vault cap) for a given wallet.
1607
+ */
1608
+ export interface ApiPerpetualsCreateVaultCapBody {
426
1609
  walletAddress: SuiAddress;
427
- collateralCoinType: CoinType;
1610
+ lpCoinMetadata: {
1611
+ /** Name for the token */
1612
+ name: string;
1613
+ /** Symbol for the token */
1614
+ symbol: string;
1615
+ /** Description of the token */
1616
+ description: string;
1617
+ /** URL for the token logo */
1618
+ iconUrl?: string;
1619
+ };
428
1620
  }
429
- export interface ApiPerpetualsDepositCollateralBody {
1621
+ /**
1622
+ * Request body for creating a new vault with initial deposit.
1623
+ *
1624
+ * The deposit can be specified either:
1625
+ * - As a numeric `initialDepositAmount`, or
1626
+ * - As an existing `depositCoinArg` (coin object).
1627
+ */
1628
+ export type ApiPerpetualsCreateVaultBody = {
430
1629
  walletAddress: SuiAddress;
1630
+ metadata: {
1631
+ /**
1632
+ * A human-readable name for the `Vault`.
1633
+ */
1634
+ name: string;
1635
+ /**
1636
+ * A verbose description of the `Vault`.
1637
+ */
1638
+ description: string;
1639
+ /**
1640
+ * The `Vault` curator's name.
1641
+ */
1642
+ curatorName?: string;
1643
+ /**
1644
+ * A url for the `Vault`'s curator. Ideally their website.
1645
+ */
1646
+ curatorUrl?: string;
1647
+ /**
1648
+ * An image url for the `Vault`'s curator. Ideally their logo.
1649
+ */
1650
+ curatorLogoUrl?: string;
1651
+ /**
1652
+ * Extra / optional fields for future extensibility. Recommended keys include: twitter_url.
1653
+ */
1654
+ extraFields?: Record<string, string>;
1655
+ };
1656
+ coinMetadataId: ObjectId;
1657
+ treasuryCapId: ObjectId;
431
1658
  collateralCoinType: CoinType;
432
- accountCapId: ObjectId;
433
- amount: Balance;
1659
+ lockPeriodMs: bigint;
1660
+ performanceFeePercentage: Percentage;
1661
+ forceWithdrawDelayMs: bigint;
1662
+ txKind?: SerializedTransaction;
434
1663
  isSponsoredTx?: boolean;
1664
+ } & ({
1665
+ initialDepositAmount: Balance;
1666
+ } | {
1667
+ initialDepositCoinArg: TransactionObjectArgument;
1668
+ });
1669
+ /**
1670
+ * Request payload for creating an integrator configuration approval transaction.
1671
+ *
1672
+ * This transaction allows a user to approve an integrator to receive fees on orders
1673
+ * placed on their behalf. The user sets a maximum taker fee that the integrator
1674
+ * can charge per order.
1675
+ */
1676
+ export interface ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody {
1677
+ /**
1678
+ * Account ID encoded as a bigint.
1679
+ *
1680
+ * This is the perpetuals account that is granting permission to the integrator.
1681
+ */
1682
+ accountId: PerpetualsAccountId;
1683
+ /**
1684
+ * Sui address of the integrator being approved.
1685
+ *
1686
+ * Must be a valid Sui object ID.
1687
+ */
1688
+ integratorAddress: SuiAddress;
1689
+ /**
1690
+ * Maximum taker fee (as a decimal) that the integrator can charge per order.
1691
+ *
1692
+ * For example, 0.001 represents a 0.1% maximum fee. The integrator can set
1693
+ * any fee up to this maximum when placing orders on behalf of the user.
1694
+ */
1695
+ maxTakerFee: Percentage;
1696
+ /**
1697
+ * Optional existing transaction kind (base64-encoded) to extend.
1698
+ *
1699
+ * If provided, the new integrator approval will be added to this transaction.
1700
+ */
1701
+ txKind?: SerializedTransaction;
1702
+ }
1703
+ /**
1704
+ * Request payload for creating a transaction to revoke an integrator's permissions.
1705
+ *
1706
+ * This transaction removes an integrator's approval to collect fees on orders
1707
+ * placed on behalf of the user. After revocation, the integrator will no longer
1708
+ * be able to submit orders with fees for this account.
1709
+ */
1710
+ export interface ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody {
1711
+ /**
1712
+ * Account ID encoded as a bigint.
1713
+ *
1714
+ * This is the perpetuals account that is revoking the integrator's permission.
1715
+ */
1716
+ accountId: PerpetualsAccountId;
1717
+ /**
1718
+ * Sui address of the integrator whose permissions are being revoked.
1719
+ *
1720
+ * Must be a valid Sui object ID.
1721
+ */
1722
+ integratorAddress: SuiAddress;
1723
+ /**
1724
+ * Optional existing transaction kind (base64-encoded) to extend.
1725
+ *
1726
+ * If provided, the integrator removal will be added to this transaction.
1727
+ */
1728
+ txKind?: SerializedTransaction;
1729
+ }
1730
+ /**
1731
+ * Request payload for creating a transaction to initialize an integrator fee vault.
1732
+ *
1733
+ * Before an integrator can claim fees from a specific market, they must first create
1734
+ * a vault for that market. This is a one-time setup per integrator per market.
1735
+ */
1736
+ export interface ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody {
1737
+ /**
1738
+ * Market (clearing house) ID where the integrator vault will be created.
1739
+ *
1740
+ * Must be a valid Sui object ID.
1741
+ */
1742
+ marketId: PerpetualsMarketId;
1743
+ /**
1744
+ * Sui address of the integrator creating the vault.
1745
+ *
1746
+ * Must be a valid Sui object ID.
1747
+ * This integrator will be able to claim fees from this vault.
1748
+ */
1749
+ integratorAddress: SuiAddress;
1750
+ /**
1751
+ * Optional existing transaction kind (base64-encoded) to extend.
1752
+ *
1753
+ * If provided, the vault creation will be added to this transaction.
1754
+ */
1755
+ txKind?: SerializedTransaction;
1756
+ }
1757
+ /**
1758
+ * Request payload for creating a transaction to claim accumulated integrator fees from a vault.
1759
+ *
1760
+ * Integrators earn fees on taker volume generated by orders they submit on behalf of users.
1761
+ * These fees accumulate in a vault per market (clearing house), and can be claimed at any time
1762
+ * by the integrator.
1763
+ */
1764
+ export interface ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody {
1765
+ /**
1766
+ * Market (clearing house) ID where the integrator fees were earned.
1767
+ *
1768
+ * Must be a valid Sui object ID.
1769
+ */
1770
+ marketId: PerpetualsMarketId;
1771
+ /**
1772
+ * Sui address of the integrator claiming their fees.
1773
+ *
1774
+ * Must be a valid Sui object ID.
1775
+ * Only the integrator who earned the fees can claim them.
1776
+ */
1777
+ integratorAddress: SuiAddress;
1778
+ /**
1779
+ * Optional recipient address for the claimed fees.
1780
+ *
1781
+ * When provided, the transaction will include an on-chain transfer of the
1782
+ * claimed coin to this address. When omitted, the claimed coin is exposed
1783
+ * as a transaction argument that can be used in subsequent commands.
1784
+ */
1785
+ recipientAddress?: SuiAddress;
1786
+ /**
1787
+ * Optional existing transaction kind (base64-encoded) to extend.
1788
+ *
1789
+ * If provided, the fee claim will be added to this transaction.
1790
+ */
1791
+ txKind?: SerializedTransaction;
1792
+ }
1793
+ /**
1794
+ * Response payload for claim integrator vault fees transaction.
1795
+ *
1796
+ * Contains the transaction kind and optionally a coin output argument when
1797
+ * no recipient address was provided.
1798
+ */
1799
+ export interface ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse {
1800
+ /**
1801
+ * Base64-encoded Sui `TransactionKind` representing the claim (and
1802
+ * optional transfer) transaction.
1803
+ */
1804
+ txKind: SerializedTransaction;
1805
+ /**
1806
+ * When `recipientAddress` is omitted, this contains a readable argument
1807
+ * pointing to the claimed coin output, so callers can wire it into
1808
+ * subsequent steps.
1809
+ */
1810
+ coinOutArg?: TransactionObjectArgument;
435
1811
  }
436
- export interface ApiPerpetualsWithdrawCollateralBody {
1812
+ /**
1813
+ * Request payload for fetching integrator configuration for a specific account and integrator.
1814
+ *
1815
+ * This endpoint checks whether an integrator has been approved by an account to collect fees,
1816
+ * and if so, returns the maximum taker fee the integrator is authorized to charge.
1817
+ */
1818
+ export interface ApiPerpetualsBuilderCodesIntegratorConfigBody {
1819
+ /**
1820
+ * Account ID encoded as a bigint.
1821
+ *
1822
+ * This is the perpetuals account whose integrator approval is being queried.
1823
+ */
1824
+ accountId: PerpetualsAccountId;
1825
+ /**
1826
+ * Sui address of the integrator whose configuration is being queried.
1827
+ *
1828
+ * Must be a valid Sui object ID.
1829
+ */
1830
+ integratorAddress: SuiAddress;
1831
+ }
1832
+ /**
1833
+ * Response payload containing integrator configuration details.
1834
+ *
1835
+ * Returns whether an integrator configuration exists and the maximum taker fee
1836
+ * if the integrator has been approved.
1837
+ */
1838
+ export interface ApiPerpetualsBuilderCodesIntegratorConfigResponse {
1839
+ /**
1840
+ * Maximum taker fee (as a decimal) that the integrator is authorized to charge.
1841
+ *
1842
+ * For example, 0.001 represents a 0.1% maximum fee. This value is only meaningful
1843
+ * if `exists` is true.
1844
+ */
1845
+ maxTakerFee: Percentage | undefined;
1846
+ /**
1847
+ * Whether an integrator configuration exists for this account-integrator pair.
1848
+ *
1849
+ * If false, the integrator has not been approved by the account and cannot
1850
+ * collect fees on orders placed on behalf of the account.
1851
+ */
1852
+ exists: boolean;
1853
+ }
1854
+ /**
1855
+ * Individual integrator vault data for a specific market.
1856
+ *
1857
+ * Contains the market ID and the accumulated fees available to claim from that market's vault.
1858
+ */
1859
+ export interface PerpetualsIntegratorVaultData {
1860
+ /**
1861
+ * Market (clearing house) object ID.
1862
+ */
1863
+ marketId: PerpetualsMarketId;
1864
+ /**
1865
+ * Total accumulated fees in the market's collateral currency that are available to claim.
1866
+ *
1867
+ * Fees are denominated in the collateral coin type used by the market.
1868
+ */
1869
+ fees: number;
1870
+ }
1871
+ /**
1872
+ * Request payload for fetching integrator vault fees across multiple markets.
1873
+ *
1874
+ * This endpoint returns the accumulated fees an integrator has earned in their vaults
1875
+ * across one or more markets (clearing houses). These fees are generated from taker
1876
+ * volume on orders the integrator submitted on behalf of users.
1877
+ */
1878
+ export interface ApiPerpetualsBuilderCodesIntegratorVaultsBody {
1879
+ /**
1880
+ * List of market (clearing house) IDs to query for integrator vault fees.
1881
+ *
1882
+ * Each market ID must be a valid Sui object ID.
1883
+ */
1884
+ marketIds: PerpetualsMarketId[];
1885
+ /**
1886
+ * Sui address of the integrator whose vault fees are being queried.
1887
+ *
1888
+ * Must be a valid Sui object ID.
1889
+ */
1890
+ integratorAddress: SuiAddress;
1891
+ }
1892
+ /**
1893
+ * Response payload containing accumulated fees per market for an integrator.
1894
+ *
1895
+ * Returns a vector of integrator vault data, one entry per market queried.
1896
+ * Markets where the integrator has no vault may be omitted or have zero fees.
1897
+ */
1898
+ export interface ApiPerpetualsBuilderCodesIntegratorVaultsResponse {
1899
+ /**
1900
+ * Vector of integrator vault data containing market IDs and their accumulated fees.
1901
+ *
1902
+ * Each entry represents a market where the integrator has a vault and potentially
1903
+ * claimable fees. The order matches the order of market IDs in the request.
1904
+ */
1905
+ integratorVaults: PerpetualsIntegratorVaultData[];
1906
+ }
1907
+ /**
1908
+ * Request body for creating a new perpetuals account for a given wallet
1909
+ * and collateral coin type.
1910
+ */
1911
+ export interface ApiPerpetualsCreateAccountBody {
437
1912
  walletAddress: SuiAddress;
438
1913
  collateralCoinType: CoinType;
439
- accountCapId: ObjectId;
440
- amount: Balance;
1914
+ txKind?: SerializedTransaction;
441
1915
  }
442
- export interface ApiPerpetualsTransferCollateralBody {
1916
+ /**
1917
+ * Request body for depositing collateral into a perpetuals account.
1918
+ *
1919
+ * The deposit can be provided by:
1920
+ * - `depositAmount` (numeric amount), or
1921
+ * - `depositCoinArg` (Sui coin object).
1922
+ */
1923
+ export type ApiPerpetualsDepositCollateralBody = {
443
1924
  walletAddress: SuiAddress;
1925
+ accountId: PerpetualsAccountId;
1926
+ accountCapId?: ObjectId;
444
1927
  collateralCoinType: CoinType;
445
- fromAccountCapId: ObjectId;
446
- toAccountCapId: ObjectId;
447
- amount: Balance;
1928
+ txKind?: SerializedTransaction;
1929
+ isSponsoredTx?: boolean;
1930
+ } & ({
1931
+ depositAmount: Balance;
1932
+ } | {
1933
+ depositCoinArg: TransactionObjectArgument;
1934
+ });
1935
+ /**
1936
+ * Request body for withdrawing collateral from an account.
1937
+ */
1938
+ export type ApiPerpetualsWithdrawCollateralBody = {
1939
+ accountId: PerpetualsAccountId;
1940
+ withdrawAmount: Balance;
1941
+ recipientAddress?: SuiAddress;
1942
+ txKind?: SerializedTransaction;
1943
+ };
1944
+ /**
1945
+ * Response body for withdraw-collateral transactions.
1946
+ *
1947
+ * The SDK typically uses `txKind` to reconstruct a transaction locally.
1948
+ */
1949
+ export interface ApiPerpetualsWithdrawCollateralResponse {
1950
+ txKind: SerializedTransaction;
1951
+ coinOutArg: TransactionObjectArgument | undefined;
448
1952
  }
449
- export interface ApiPerpetualsAllocateCollateralBody {
1953
+ /**
1954
+ * Request body for transferring collateral between two perpetuals accounts.
1955
+ */
1956
+ export interface ApiPerpetualsTransferCollateralBody {
450
1957
  walletAddress: SuiAddress;
451
- packageId: PackageId;
452
- collateralCoinType: CoinType;
453
- accountCapId: ObjectId;
1958
+ fromAccountId: PerpetualsAccountId;
1959
+ fromAccountCapId?: ObjectId;
1960
+ toAccountId: PerpetualsAccountId;
1961
+ toAccountCapId?: ObjectId;
1962
+ transferAmount: Balance;
1963
+ txKind?: SerializedTransaction;
1964
+ }
1965
+ /**
1966
+ * Request body for allocating collateral to a given market (account/vault).
1967
+ */
1968
+ export type ApiPerpetualsAllocateCollateralBody = {
454
1969
  marketId: PerpetualsMarketId;
455
- marketInitialSharedVersion: ObjectVersion;
456
- amount: Balance;
1970
+ allocateAmount: Balance;
1971
+ txKind?: SerializedTransaction;
1972
+ } & ({
1973
+ accountId: PerpetualsAccountId;
1974
+ accountCapId?: ObjectId;
1975
+ } | {
1976
+ vaultId: ObjectId;
1977
+ });
1978
+ /**
1979
+ * Request body for deallocating collateral from a given market (account/vault).
1980
+ */
1981
+ export type ApiPerpetualsDeallocateCollateralBody = {
1982
+ marketId: PerpetualsMarketId;
1983
+ deallocateAmount: Balance;
1984
+ txKind?: SerializedTransaction;
1985
+ } & ({
1986
+ accountId: PerpetualsAccountId;
1987
+ accountCapId?: ObjectId;
1988
+ } | {
1989
+ vaultId: ObjectId;
1990
+ });
1991
+ /**
1992
+ * SDK-level inputs for placing one or more stop orders.
1993
+ *
1994
+ * This is a client-facing type that wraps the on-chain format.
1995
+ */
1996
+ export interface SdkPerpetualsPlaceStopOrdersInputs {
1997
+ /** Stop orders to place (without objectId, which is created on-chain). */
1998
+ stopOrders: Omit<PerpetualsStopOrderData, "objectId">[];
1999
+ /** Optional transaction to embed the call in. */
2000
+ tx?: Transaction;
2001
+ /** Optional gas coin for sponsored or custom gas usage. */
2002
+ gasCoinArg?: TransactionObjectArgument;
2003
+ /** Whether the transaction is expected to be sponsored by the API. */
2004
+ isSponsoredTx?: boolean;
457
2005
  }
458
- export interface ApiPerpetualsDeallocateCollateralBody {
2006
+ /**
2007
+ * Request body for placing stop orders via the API.
2008
+ */
2009
+ export type ApiPerpetualsPlaceStopOrdersBody = {
459
2010
  walletAddress: SuiAddress;
460
- packageId: PackageId;
461
- collateralCoinType: CoinType;
462
- accountCapId: ObjectId;
463
- basePriceFeedId: ObjectId;
464
- collateralPriceFeedId: ObjectId;
2011
+ stopOrders: Omit<PerpetualsStopOrderData, "objectId">[];
2012
+ gasCoinArg?: TransactionObjectArgument;
2013
+ isSponsoredTx?: boolean;
2014
+ txKind?: SerializedTransaction;
2015
+ } & ({
2016
+ accountId: PerpetualsAccountId;
2017
+ accountCapId?: ObjectId;
2018
+ } | {
2019
+ vaultId: ObjectId;
2020
+ });
2021
+ /**
2022
+ * SDK-level inputs for placing stop-loss / take-profit orders bound to a
2023
+ * specific market and position side.
2024
+ */
2025
+ export type SdkPerpetualsPlaceSlTpOrdersInputs = {
465
2026
  marketId: PerpetualsMarketId;
466
- marketInitialSharedVersion: ObjectVersion;
467
- amount: Balance;
468
- }
469
- export interface ApiPerpetualsMarketOrderBody {
2027
+ /** Optional target size for SL/TP orders (scaled base units). */
2028
+ size?: bigint;
2029
+ /** Index price at which to trigger stop loss. */
2030
+ stopLossIndexPrice?: number;
2031
+ /** Index price at which to trigger take profit. */
2032
+ takeProfitIndexPrice?: number;
2033
+ /** Unique order identifier for limit order sl/tp is tied to. */
2034
+ limitOrderId?: PerpetualsOrderId;
2035
+ /** Optional transaction to embed in. */
2036
+ tx?: Transaction;
2037
+ /** Optional gas coin argument. */
2038
+ gasCoinArg?: TransactionObjectArgument;
2039
+ /** Whether to treat the transaction as sponsored. */
2040
+ isSponsoredTx?: boolean;
2041
+ };
2042
+ /**
2043
+ * API request body for placing SL/TP orders bound to a position.
2044
+ */
2045
+ export type ApiPerpetualsPlaceSlTpOrdersBody = {
2046
+ marketId: PerpetualsMarketId;
2047
+ walletAddress: SuiAddress;
2048
+ positionSide: PerpetualsOrderSide;
2049
+ size?: bigint;
2050
+ stopLossIndexPrice?: number;
2051
+ takeProfitIndexPrice?: number;
2052
+ limitOrderId?: PerpetualsOrderId;
2053
+ gasCoinArg?: TransactionObjectArgument;
2054
+ isSponsoredTx?: boolean;
2055
+ leverage?: number;
2056
+ txKind?: SerializedTransaction;
2057
+ } & ({
2058
+ accountId: PerpetualsAccountId;
2059
+ accountCapId?: ObjectId;
2060
+ } | {
2061
+ vaultId: ObjectId;
2062
+ });
2063
+ /**
2064
+ * API request body for editing existing stop orders for an
2065
+ * account or vault.
2066
+ */
2067
+ export type ApiPerpetualsEditStopOrdersBody = {
2068
+ stopOrders: PerpetualsStopOrderData[];
2069
+ txKind?: SerializedTransaction;
2070
+ } & ({
2071
+ accountId: PerpetualsAccountId;
2072
+ accountCapId?: ObjectId;
2073
+ } | {
2074
+ vaultId: ObjectId;
2075
+ });
2076
+ /**
2077
+ * API request body for placing a market order in a given market.
2078
+ *
2079
+ * This form is used by the backend and includes contextual information
2080
+ * like `accountId` or `vaultId`.
2081
+ */
2082
+ export type ApiPerpetualsMarketOrderBody = {
470
2083
  walletAddress: SuiAddress;
471
2084
  marketId: PerpetualsMarketId;
472
- accountObjectId: ObjectId;
473
- accountObjectVersion: number;
474
- accountObjectDigest: ObjectId;
475
2085
  side: PerpetualsOrderSide;
2086
+ /** Order size in scaled base units. */
476
2087
  size: bigint;
477
- collateralChange: Balance;
2088
+ /** Change in collateral allocated to this position (collateral units). */
2089
+ collateralChange: number;
2090
+ /** Whether the account already has a position in this market. */
478
2091
  hasPosition: boolean;
479
- }
480
- export interface ApiPerpetualsLimitOrderBody {
481
- walletAddress: SuiAddress;
2092
+ /** True is position is closed. */
2093
+ cancelSlTp: boolean;
2094
+ /** If true, order can only reduce an existing position. */
2095
+ reduceOnly: boolean;
2096
+ /** Allowable max slippage for trade execution. */
2097
+ slippage: Slippage;
2098
+ /** Optional leverage override. */
2099
+ leverage?: number;
2100
+ /** Optional SL/TP instructions to be placed along with the market order. */
2101
+ slTp?: {
2102
+ gasCoinArg?: TransactionObjectArgument;
2103
+ isSponsoredTx?: boolean;
2104
+ size?: bigint;
2105
+ stopLossIndexPrice?: number;
2106
+ takeProfitIndexPrice?: number;
2107
+ };
2108
+ /**
2109
+ * Optional integrator fee configuration for this order.
2110
+ *
2111
+ * If provided, the integrator specified in the configuration will receive a fee
2112
+ * on the taker volume generated by this order. The integrator must have been
2113
+ * previously approved by the account owner, and the fee must not exceed the
2114
+ * maximum fee the user approved for that integrator.
2115
+ */
2116
+ builderCode?: PerpetualsBuilderCodeParamaters;
2117
+ /** Optional serialized transaction kind if assembled by the API. */
2118
+ txKind?: SerializedTransaction;
2119
+ } & ({
2120
+ accountId: PerpetualsAccountId;
2121
+ accountCapId?: ObjectId;
2122
+ } | {
2123
+ vaultId: ObjectId;
2124
+ });
2125
+ /**
2126
+ * API request body for placing a limit order in a given market.
2127
+ */
2128
+ export type ApiPerpetualsLimitOrderBody = {
482
2129
  marketId: PerpetualsMarketId;
483
- accountObjectId: ObjectId;
484
- accountObjectVersion: number;
485
- accountObjectDigest: ObjectId;
2130
+ walletAddress: SuiAddress;
486
2131
  side: PerpetualsOrderSide;
2132
+ /** Order size in scaled base units. */
487
2133
  size: bigint;
488
- price: PerpetualsOrderPrice;
2134
+ /** Limit price in scaled fixed-point representation. */
2135
+ price: bigint;
2136
+ /** How the order behaves on the orderbook. */
489
2137
  orderType: PerpetualsOrderType;
490
- collateralChange: Balance;
2138
+ /** Change in collateral allocated to this position. */
2139
+ collateralChange: number;
2140
+ /** Whether the account already has a position in this market. */
491
2141
  hasPosition: boolean;
492
- }
493
- export interface ApiPerpetualsCancelOrderBody {
494
- packageId: PackageId;
2142
+ /** True is position is closed. */
2143
+ cancelSlTp: boolean;
2144
+ /** If true, order can only reduce an existing position. */
2145
+ reduceOnly: boolean;
2146
+ /** Optional expiration for the order. */
2147
+ expiryTimestamp?: bigint;
2148
+ /** Optional leverage override. */
2149
+ leverage?: number;
2150
+ /** Optional SL/TP instructions to be placed along with the limit order. */
2151
+ slTp?: {
2152
+ gasCoinArg?: TransactionObjectArgument;
2153
+ isSponsoredTx?: boolean;
2154
+ size?: bigint;
2155
+ stopLossIndexPrice?: number;
2156
+ takeProfitIndexPrice?: number;
2157
+ };
2158
+ /**
2159
+ * Optional integrator fee configuration for this order.
2160
+ *
2161
+ * If provided, the integrator specified in the configuration will receive a fee
2162
+ * on the taker volume generated by this order. The integrator must have been
2163
+ * previously approved by the account owner, and the fee must not exceed the
2164
+ * maximum fee the user approved for that integrator.
2165
+ */
2166
+ builderCode?: PerpetualsBuilderCodeParamaters;
2167
+ /** Optionally pre-built transaction payload. */
2168
+ txKind?: SerializedTransaction;
2169
+ } & ({
2170
+ accountId: PerpetualsAccountId;
2171
+ accountCapId?: ObjectId;
2172
+ } | {
2173
+ vaultId: ObjectId;
2174
+ });
2175
+ /**
2176
+ * API request body for canceling one or more orders for an
2177
+ * account or vault, per market.
2178
+ */
2179
+ export type ApiPerpetualsCancelOrdersBody = {
495
2180
  walletAddress: SuiAddress;
496
- collateralCoinType: CoinType;
497
- accountCapId: ObjectId;
2181
+ marketIdsToData: Record<PerpetualsMarketId, {
2182
+ orderIds: PerpetualsOrderId[];
2183
+ /** Collateral change associated with canceling these orders. */
2184
+ collateralChange: number;
2185
+ }>;
2186
+ txKind?: SerializedTransaction;
2187
+ } & ({
2188
+ accountId: PerpetualsAccountId;
2189
+ accountCapId?: ObjectId;
2190
+ } | {
2191
+ vaultId: ObjectId;
2192
+ });
2193
+ /**
2194
+ * API request body for canceling stop orders identified by object IDs.
2195
+ */
2196
+ export type ApiPerpetualsCancelStopOrdersBody = {
2197
+ stopOrderIds: ObjectId[];
2198
+ txKind?: SerializedTransaction;
2199
+ } & ({
2200
+ accountId: PerpetualsAccountId;
2201
+ accountCapId?: ObjectId;
2202
+ } | {
2203
+ vaultId: ObjectId;
2204
+ });
2205
+ /**
2206
+ * API body for setting leverage on an existing position.
2207
+ */
2208
+ export type ApiPerpetualsSetLeverageTxBody = {
498
2209
  marketId: PerpetualsMarketId;
499
- marketInitialSharedVersion: ObjectVersion;
500
- orderId: PerpetualsOrderId;
501
- collateralChange: Balance;
502
- basePriceFeedId: ObjectId;
503
- collateralPriceFeedId: ObjectId;
2210
+ collateralChange: number;
2211
+ leverage: number;
2212
+ txKind?: SerializedTransaction;
2213
+ } & ({
2214
+ accountId: PerpetualsAccountId;
2215
+ accountCapId?: ObjectId;
2216
+ } | {
2217
+ vaultId: ObjectId;
2218
+ });
2219
+ /**
2220
+ * 24-hour volume and price change statistics for a single market.
2221
+ */
2222
+ export interface PerpetualsMarket24hrStats {
2223
+ /** The total 24h volume in USD. */
2224
+ volumeUsd: number;
2225
+ /** The total 24h volume measured in the base asset. */
2226
+ volumeBaseAssetAmount: number;
2227
+ /**
2228
+ * Absolute price change over the last 24h, denominated in the
2229
+ * base asset's quote units.
2230
+ */
2231
+ priceChange: number;
2232
+ /** Relative price change over the last 24h (e.g. +5% => `0.05`). */
2233
+ priceChangePercentage: number;
2234
+ /** Latest base asset price for this market. */
2235
+ basePrice: number;
2236
+ /** Latest collateral asset price used in this market. */
2237
+ collateralPrice: number;
2238
+ /**
2239
+ * Mid price derived from the current order book.
2240
+ *
2241
+ * Calculated as the average of the best bid and best ask.
2242
+ * `undefined` if either side of the book is empty.
2243
+ */
2244
+ midPrice: number | undefined;
2245
+ /**
2246
+ * Mark price used for liquidations and risk calculations.
2247
+ *
2248
+ * Computed as the median of the index TWAP, the current
2249
+ * book-derived price, and the index price adjusted for
2250
+ * funding contributions.
2251
+ */
2252
+ markPrice: number;
504
2253
  }
505
- export interface ApiPerpetualsCancelOrdersBody {
506
- walletAddress: SuiAddress;
2254
+ /**
2255
+ * Response type for requesting 24h stats for multiple markets.
2256
+ */
2257
+ export interface ApiPerpetualsMarkets24hrStatsResponse {
2258
+ marketsStats: PerpetualsMarket24hrStats[];
2259
+ }
2260
+ /**
2261
+ * Request body for fetching all markets for a given collateral type.
2262
+ *
2263
+ * This endpoint is commonly used to populate a "Markets" list filtered by
2264
+ * the user's selected collateral (e.g., USDC-margined markets).
2265
+ */
2266
+ export interface ApiPerpetualsAllMarketsBody {
507
2267
  collateralCoinType: CoinType;
508
- accountCapId: ObjectId;
509
- orderDatas: {
510
- packageId: PackageId;
511
- orderId: PerpetualsOrderId;
2268
+ }
2269
+ /**
2270
+ * Response payload for {@link ApiPerpetualsAllMarketsBody}.
2271
+ *
2272
+ * Returns enriched market data including parameters, state, and current prices.
2273
+ */
2274
+ export interface ApiPerpetualsAllMarketsResponse {
2275
+ markets: PerpetualsMarketData[];
2276
+ }
2277
+ /**
2278
+ * Request body for fetching a specific set of markets by ID.
2279
+ */
2280
+ export interface ApiPerpetualsMarketsBody {
2281
+ marketIds: PerpetualsMarketId[];
2282
+ }
2283
+ /**
2284
+ * Response payload for {@link ApiPerpetualsMarketsBody}.
2285
+ *
2286
+ * Each item includes the market data.
2287
+ */
2288
+ export interface ApiPerpetualsMarketsResponse {
2289
+ marketDatas: {
2290
+ market: PerpetualsMarketData;
2291
+ }[];
2292
+ }
2293
+ /**
2294
+ * Request body for fetching a specific set of orderbooks by market ID.
2295
+ */
2296
+ export interface ApiPerpetualsOrderbooksBody {
2297
+ marketIds: PerpetualsMarketId[];
2298
+ }
2299
+ /**
2300
+ * Response payload for {@link ApiPerpetualsOrderbooksBody}.
2301
+ *
2302
+ * Each item includes the current orderbook snapshot.
2303
+ */
2304
+ export interface ApiPerpetualsOrderbooksResponse {
2305
+ orderbooks: {
2306
+ orderbook: PerpetualsOrderbook;
2307
+ }[];
2308
+ }
2309
+ /**
2310
+ * Request body for fetching vault objects.
2311
+ *
2312
+ * If `vaultIds` is omitted, the API may return all vaults (potentially paginated
2313
+ * at the transport layer).
2314
+ */
2315
+ export interface ApiPerpetualsVaultsBody {
2316
+ vaultIds?: ObjectId[];
2317
+ }
2318
+ /**
2319
+ * Response payload for vault queries.
2320
+ */
2321
+ export interface ApiPerpetualsVaultsResponse {
2322
+ vaults: PerpetualsVaultObject[];
2323
+ }
2324
+ /**
2325
+ * Request body for fetching current prices for a list of markets.
2326
+ *
2327
+ * This is a lightweight alternative to fetching full {@link PerpetualsMarketData}
2328
+ * when only prices are needed.
2329
+ */
2330
+ export interface ApiPerpetualsMarketsPricesBody {
2331
+ marketIds: PerpetualsMarketId[];
2332
+ }
2333
+ /**
2334
+ * Response payload for {@link ApiPerpetualsMarketsPricesBody}.
2335
+ *
2336
+ * Returns base (index/oracle) and collateral prices, the order book mid price,
2337
+ * and the mark price used for liquidations and risk calculations.
2338
+ */
2339
+ export interface ApiPerpetualsMarketsPricesResponse {
2340
+ marketsPrices: {
2341
+ /** Identifier of the market. */
512
2342
  marketId: PerpetualsMarketId;
513
- marketInitialSharedVersion: ObjectVersion;
514
- collateralChange: Balance;
515
- basePriceFeedId: ObjectId;
516
- collateralPriceFeedId: ObjectId;
2343
+ /** Latest base asset price for this market. */
2344
+ basePrice: number;
2345
+ /** Latest collateral asset price used in this market. */
2346
+ collateralPrice: number;
2347
+ /**
2348
+ * Mid price derived from the current order book.
2349
+ *
2350
+ * Calculated as the average of the best bid and best ask.
2351
+ * `undefined` if either side of the book is empty.
2352
+ */
2353
+ midPrice: number | undefined;
2354
+ /**
2355
+ * Mark price used for liquidations and risk calculations.
2356
+ *
2357
+ * Computed as the median of the index TWAP, the current
2358
+ * book-derived price, and the index price adjusted for
2359
+ * funding contributions.
2360
+ */
2361
+ markPrice: number;
517
2362
  }[];
518
2363
  }
519
- export interface ApiPerpetualsReduceOrdersBody {
2364
+ /**
2365
+ * Request body for granting an Agent Wallet on a perpetuals account.
2366
+ *
2367
+ * This corresponds to `POST /api/perpetuals/account/transactions/grant-agent-wallet`.
2368
+ *
2369
+ * The resulting on-chain transaction must be signed by the **account admin** wallet.
2370
+ * After execution, `recipientAddress` receives assistant-level permissions for `accountId`
2371
+ * (trading actions are allowed, but **withdrawing collateral** and managing other agent wallets are not).
2372
+ */
2373
+ export type ApiPerpetualsGrantAgentWalletTxBody = {
2374
+ recipientAddress: SuiAddress;
2375
+ accountId: PerpetualsAccountId;
2376
+ txKind?: SerializedTransaction;
2377
+ };
2378
+ /**
2379
+ * Request body for revoking an Agent Wallet from a perpetuals account.
2380
+ *
2381
+ * This corresponds to `POST /api/perpetuals/account/transactions/revoke-agent-wallet`.
2382
+ *
2383
+ * The resulting on-chain transaction must be signed by the **account admin** wallet.
2384
+ * `accountCapId` is the object ID of the assistant capability to revoke.
2385
+ */
2386
+ export type ApiPerpetualsRevokeAgentWalletTxBody = {
2387
+ accountId: PerpetualsAccountId;
2388
+ accountCapId: ObjectId;
2389
+ txKind?: SerializedTransaction;
2390
+ };
2391
+ export type ApiPerpetualsTransferCapTxBody = {
2392
+ /**
2393
+ * Recipient wallet address that should receive the capability object.
2394
+ *
2395
+ * Must be a valid Sui address string.
2396
+ */
2397
+ recipientAddress: SuiAddress;
2398
+ /**
2399
+ * Object ID of the capability to transfer.
2400
+ *
2401
+ * This should be the object ID of the cap being transferred (e.g., an account cap or vault cap).
2402
+ */
2403
+ capObjectId: ObjectId;
2404
+ /**
2405
+ * Optional serialized (base64) Sui `TransactionKind` to extend.
2406
+ *
2407
+ * When provided, the transfer operation is appended to the existing transaction.
2408
+ */
2409
+ txKind?: SerializedTransaction;
2410
+ };
2411
+ /**
2412
+ * Request body for fetching LP coin prices for a set of vaults.
2413
+ *
2414
+ * LP coin price is typically expressed in USD per 1 LP token (native units adjusted
2415
+ * using `lpCoinDecimals` on the vault object).
2416
+ */
2417
+ export interface ApiPerpetualsVaultLpCoinPricesBody {
2418
+ vaultIds: ObjectId[];
2419
+ }
2420
+ /**
2421
+ * Response payload for {@link ApiPerpetualsVaultLpCoinPricesBody}.
2422
+ *
2423
+ * The response is index-aligned with the request `vaultIds` array.
2424
+ */
2425
+ export interface ApiPerpetualsVaultLpCoinPricesResponse {
2426
+ lpCoinPrices: number[];
2427
+ }
2428
+ /**
2429
+ * Request body for fetching a wallet's owned LP coin objects across vaults.
2430
+ */
2431
+ export interface ApiPerpetualsVaultOwnedLpCoinsBody {
520
2432
  walletAddress: SuiAddress;
521
- packageId: PackageId;
2433
+ }
2434
+ /**
2435
+ * Response payload listing owned LP coin objects (per vault).
2436
+ */
2437
+ export interface ApiPerpetualsVaultOwnedLpCoinsResponse {
2438
+ ownedLpCoins: PerpetualsVaultLpCoin[];
2439
+ }
2440
+ /**
2441
+ * Request body for fetching vault capability objects owned by a wallet.
2442
+ *
2443
+ * Vault caps are typically owned by the vault creator/owner and are required
2444
+ * for privileged vault actions (processing withdrawals, updating parameters, etc.).
2445
+ */
2446
+ export interface ApiPerpetualsOwnedVaultCapsBody {
2447
+ walletAddress: SuiAddress;
2448
+ }
2449
+ /**
2450
+ * Response payload listing all vault caps owned by the wallet.
2451
+ */
2452
+ export interface ApiPerpetualsOwnedVaultCapsResponse {
2453
+ ownedVaultCaps: PerpetualsVaultCap[];
2454
+ }
2455
+ /**
2456
+ * API body to process forced withdrawals in a vault.
2457
+ */
2458
+ export interface ApiPerpetualsVaultProcessForceWithdrawRequestTxBody {
2459
+ walletAddress: SuiAddress;
2460
+ vaultId: ObjectId;
2461
+ /** Per-market sizes to close as part of force withdraw. */
2462
+ sizesToClose: Record<PerpetualsMarketId, Balance>;
2463
+ recipientAddress?: SuiAddress;
2464
+ txKind?: SerializedTransaction;
2465
+ }
2466
+ /**
2467
+ * Response body for force-withdraw processing transactions.
2468
+ *
2469
+ * - `txKind` is a serialized transaction kind the client can sign/submit.
2470
+ * - `coinOutArg` (if present) is the transaction argument referencing the
2471
+ * withdrawn collateral coin output.
2472
+ */
2473
+ export interface ApiPerpetualsVaultProcessForceWithdrawRequestTxResponse {
2474
+ txKind: SerializedTransaction;
2475
+ coinOutArg: TransactionObjectArgument | undefined;
2476
+ }
2477
+ export interface ApiPerpetualsVaultPauseVaultForForceWithdrawRequestTxBody {
2478
+ vaultId: ObjectId;
2479
+ txKind?: SerializedTransaction;
2480
+ }
2481
+ /**
2482
+ * API body to process regular withdraw requests for a vault.
2483
+ */
2484
+ export interface ApiPerpetualsVaultOwnerProcessWithdrawRequestsTxBody {
2485
+ vaultId: ObjectId;
2486
+ userAddresses: SuiAddress[];
2487
+ txKind?: SerializedTransaction;
2488
+ }
2489
+ /**
2490
+ * API body to update slippage parameter for pending vault withdraw
2491
+ * request for a specific vault.
2492
+ */
2493
+ export interface ApiPerpetualsVaultUpdateWithdrawRequestSlippageTxBody {
2494
+ vaultId: ObjectId;
2495
+ minCollateralAmountOut: Balance;
2496
+ txKind?: SerializedTransaction;
2497
+ }
2498
+ /**
2499
+ * API body to update the force-withdrawal delay in a vault.
2500
+ */
2501
+ export interface ApiPerpetualsVaultOwnerUpdateForceWithdrawDelayTxBody {
2502
+ vaultId: ObjectId;
2503
+ forceWithdrawDelayMs: bigint;
2504
+ txKind?: SerializedTransaction;
2505
+ }
2506
+ /**
2507
+ * API body to update the lock period on a vault.
2508
+ */
2509
+ export interface ApiPerpetualsVaultOwnerUpdateLockPeriodTxBody {
2510
+ vaultId: ObjectId;
2511
+ lockPeriodMs: bigint;
2512
+ txKind?: SerializedTransaction;
2513
+ }
2514
+ /**
2515
+ * API body to update the owner's fee percentage on a vault.
2516
+ */
2517
+ export interface ApiPerpetualsVaultOwnerUpdatePerformanceFeeTxBody {
2518
+ vaultId: ObjectId;
2519
+ performanceFeePercentage: number;
2520
+ txKind?: SerializedTransaction;
2521
+ }
2522
+ /**
2523
+ * API body for the vault owner withdrawing collected fees.
2524
+ */
2525
+ export interface ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxBody {
2526
+ vaultId: ObjectId;
2527
+ withdrawAmount: Balance;
2528
+ recipientAddress?: SuiAddress;
2529
+ txKind?: SerializedTransaction;
2530
+ }
2531
+ /**
2532
+ * Response for owner-fee withdrawal transactions.
2533
+ */
2534
+ export interface ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse {
2535
+ txKind: SerializedTransaction;
2536
+ coinOutArg: TransactionObjectArgument | undefined;
2537
+ }
2538
+ /**
2539
+ * Request body for fetching all withdrawal requests for specific vaults.
2540
+ */
2541
+ export interface ApiPerpetualsVaultsWithdrawRequestsBody {
2542
+ vaultIds: ObjectId[];
2543
+ }
2544
+ /**
2545
+ * Response payload listing withdrawal requests for the requested vaults.
2546
+ *
2547
+ * Depending on backend behavior, this may include all queued requests across
2548
+ * all specified vaults.
2549
+ */
2550
+ export interface ApiPerpetualsVaultsWithdrawRequestsResponse {
2551
+ withdrawRequests: PerpetualsVaultWithdrawRequest[];
2552
+ }
2553
+ /**
2554
+ * Request body for fetching withdrawal requests for a given wallet across
2555
+ * its vault positions.
2556
+ */
2557
+ export interface ApiPerpetualsVaultOwnedWithdrawRequestsBody {
2558
+ walletAddress: SuiAddress;
2559
+ }
2560
+ /**
2561
+ * Response payload listing withdrawal requests created by `walletAddress`.
2562
+ */
2563
+ export interface ApiPerpetualsVaultOwnedWithdrawRequestsResponse {
2564
+ ownedWithdrawRequests: PerpetualsVaultWithdrawRequest[];
2565
+ }
2566
+ /**
2567
+ * API body for creating a single withdraw request from a vault.
2568
+ */
2569
+ export interface ApiPerpetualsVaultCreateWithdrawRequestTxBody {
2570
+ vaultId: ObjectId;
2571
+ walletAddress: SuiAddress;
2572
+ lpWithdrawAmount: Balance;
2573
+ minCollateralAmountOut: Balance;
2574
+ txKind?: SerializedTransaction;
2575
+ }
2576
+ /**
2577
+ * API body for withdrawing collateral from a vault as owner.
2578
+ */
2579
+ export interface ApiPerpetualsVaultOwnerWithdrawCollateralTxBody {
2580
+ vaultId: ObjectId;
2581
+ lpWithdrawAmount: Balance;
2582
+ minCollateralAmountOut: Balance;
2583
+ recipientAddress?: SuiAddress;
2584
+ txKind?: SerializedTransaction;
2585
+ }
2586
+ /**
2587
+ * Response body for vault owner withdraw-collateral transactions.
2588
+ *
2589
+ * The SDK typically uses `txKind` to reconstruct a transaction locally.
2590
+ */
2591
+ export interface ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse {
2592
+ txKind: SerializedTransaction;
2593
+ coinOutArg: TransactionObjectArgument | undefined;
2594
+ }
2595
+ /**
2596
+ * API body for canceling withdrawal requests across vaults for a wallet.
2597
+ */
2598
+ export interface ApiPerpetualsVaultCancelWithdrawRequestTxBody {
2599
+ vaultId: ObjectId;
2600
+ walletAddress: SuiAddress;
2601
+ txKind?: SerializedTransaction;
2602
+ }
2603
+ /**
2604
+ * Request body for depositing into a vault.
2605
+ *
2606
+ * Deposit can be specified as a numeric amount or as an existing coin object.
2607
+ */
2608
+ export type ApiPerpetualsVaultDepositTxBody = {
2609
+ vaultId: ObjectId;
2610
+ walletAddress: SuiAddress;
2611
+ minLpAmountOut: Balance;
2612
+ txKind?: SerializedTransaction;
2613
+ isSponsoredTx?: boolean;
2614
+ } & ({
2615
+ depositAmount: Balance;
522
2616
  collateralCoinType: CoinType;
523
- accountCapId: ObjectId;
524
- marketId: PerpetualsMarketId;
525
- marketInitialSharedVersion: ObjectVersion;
526
- orderIds: PerpetualsOrderId[];
527
- sizesToSubtract: bigint[];
528
- basePriceFeedId: ObjectId;
529
- collateralPriceFeedId: ObjectId;
530
- collateralChange: Balance;
2617
+ } | {
2618
+ depositCoinArg: TransactionObjectArgument;
2619
+ });
2620
+ /**
2621
+ * Request body for previewing a vault withdrawal request.
2622
+ */
2623
+ export interface ApiPerpetualsVaultPreviewCreateWithdrawRequestBody {
2624
+ vaultId: ObjectId;
2625
+ walletAddress: SuiAddress;
2626
+ lpWithdrawAmount: Balance;
531
2627
  }
532
- export type ApiPerpetualsSLTPOrderBody = ((ApiPerpetualsMarketOrderBody & {
533
- marketPrice: PerpetualsOrderPrice;
534
- }) | ApiPerpetualsLimitOrderBody) & ({
535
- slPrice: PerpetualsOrderPrice;
2628
+ /**
2629
+ * Response body for vault withdrawal preview.
2630
+ */
2631
+ export type ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse = {
2632
+ error: string;
536
2633
  } | {
537
- tpPrice: PerpetualsOrderPrice;
2634
+ collateralAmountOut: Balance;
2635
+ collateralPrice: number;
2636
+ };
2637
+ /**
2638
+ * Request body for previewing a vault owner collateral withdrawal.
2639
+ */
2640
+ export interface ApiPerpetualsVaultPreviewOwnerWithdrawCollateralBody {
2641
+ vaultId: ObjectId;
2642
+ lpWithdrawAmount: Balance;
2643
+ }
2644
+ /**
2645
+ * Response body for vault owner collateral withdrawal preview.
2646
+ */
2647
+ export type ApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse = {
2648
+ error: string;
538
2649
  } | {
539
- slPrice: PerpetualsOrderPrice;
540
- tpPrice: PerpetualsOrderPrice;
541
- });
542
- export interface ApiPerpetualsMarket24hrVolumeResponse {
543
- volumeBaseAssetAmount: number;
544
- volumeUsd: number;
2650
+ collateralAmountOut: Balance;
2651
+ collateralPrice: number;
2652
+ };
2653
+ /**
2654
+ * Request body for previewing a vault deposit.
2655
+ */
2656
+ export interface ApiPerpetualsVaultPreviewDepositBody {
2657
+ vaultId: ObjectId;
2658
+ depositAmount: Balance;
545
2659
  }
546
- export interface ApiPerpetualsMarket24hrVolumeResponse {
547
- volumeUsd: number;
548
- volumeBaseAssetAmount: number;
2660
+ /**
2661
+ * Response body for vault deposit preview.
2662
+ */
2663
+ export type ApiPerpetualsVaultPreviewDepositResponse = {
2664
+ error: string;
2665
+ } | {
2666
+ lpAmountOut: Balance;
2667
+ collateralPrice: number;
2668
+ depositedAmountUsd: number;
2669
+ };
2670
+ /**
2671
+ * Request body for previewing forced withdraw processing for a vault.
2672
+ */
2673
+ export interface ApiPerpetualsVaultPreviewProcessForceWithdrawRequestBody {
2674
+ vaultId: ObjectId;
2675
+ walletAddress: SuiAddress;
549
2676
  }
550
- export type SdkPerpetualsMarketOrderInputs = Omit<ApiPerpetualsMarketOrderBody, "accountObjectId" | "accountObjectVersion" | "accountObjectDigest">;
551
- export type SdkPerpetualsLimitOrderInputs = Omit<ApiPerpetualsLimitOrderBody, "accountObjectId" | "accountObjectVersion" | "accountObjectDigest">;
552
- export type SdkPerpetualsSLTPOrderInputs = ((SdkPerpetualsMarketOrderInputs & {
553
- marketPrice: PerpetualsOrderPrice;
554
- }) | SdkPerpetualsLimitOrderInputs) & ({
555
- slPrice: PerpetualsOrderPrice;
2677
+ /**
2678
+ * Response body for forced withdraw processing preview.
2679
+ */
2680
+ export type ApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse = {
2681
+ error: string;
556
2682
  } | {
557
- tpPrice: PerpetualsOrderPrice;
2683
+ collateralAmountOut: Balance;
2684
+ collateralPrice: number;
2685
+ sizesToClose: Record<PerpetualsMarketId, bigint>;
2686
+ priceImpact: Percentage;
2687
+ performanceFeesChargedUsd: number;
2688
+ isWithinWithdrawRequestSlippage: boolean;
2689
+ minCollateralAmountOut: Balance;
2690
+ };
2691
+ export interface ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestBody {
2692
+ vaultId: ObjectId;
2693
+ walletAddress: SuiAddress;
2694
+ }
2695
+ export type ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestResponse = {
2696
+ error: string;
558
2697
  } | {
559
- slPrice: PerpetualsOrderPrice;
560
- tpPrice: PerpetualsOrderPrice;
561
- });
562
- export declare const perpetualsRegistry: {
563
- Account: import("@mysten/sui/bcs").BcsStruct<{
564
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
565
- accountId: BcsType<string, string | number | bigint, "u64">;
566
- collateral: import("@mysten/sui/bcs").BcsStruct<{
567
- value: BcsType<string, string | number | bigint, "u64">;
568
- }, string>;
569
- }, string>;
570
- AdminCapability: import("@mysten/sui/bcs").BcsStruct<{
571
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
572
- }, string>;
573
- BalanceStruct: import("@mysten/sui/bcs").BcsStruct<{
574
- value: BcsType<string, string | number | bigint, "u64">;
575
- }, string>;
576
- Coin: import("@mysten/sui/bcs").BcsStruct<{
577
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
578
- balance: import("@mysten/sui/bcs").BcsStruct<{
579
- value: BcsType<string, string | number | bigint, "u64">;
580
- }, string>;
581
- }, string>;
582
- Field: typeof Field;
583
- MarketKey: import("@mysten/sui/bcs").BcsStruct<{
584
- marketId: BcsType<string, string | number | bigint, "u64">;
585
- }, string>;
586
- OrderInfo: import("@mysten/sui/bcs").BcsStruct<{
587
- price: BcsType<string, string | number | bigint, "u64">;
588
- size: BcsType<string, string | number | bigint, "u64">;
589
- }, string>;
590
- Position: import("@mysten/sui/bcs").BcsStruct<{
591
- collateral: BcsType<string, string | number | bigint, "u256">;
592
- baseAssetAmount: BcsType<string, string | number | bigint, "u256">;
593
- quoteAssetNotionalAmount: BcsType<string, string | number | bigint, "u256">;
594
- cumFundingRateLong: BcsType<string, string | number | bigint, "u256">;
595
- cumFundingRateShort: BcsType<string, string | number | bigint, "u256">;
596
- asksQuantity: BcsType<string, string | number | bigint, "u256">;
597
- bidsQuantity: BcsType<string, string | number | bigint, "u256">;
598
- pendingOrders: BcsType<string, string | number | bigint, "u64">;
599
- makerFee: BcsType<string, string | number | bigint, "u256">;
600
- takerFee: BcsType<string, string | number | bigint, "u256">;
601
- }, string>;
602
- PositionKey: import("@mysten/sui/bcs").BcsStruct<{
603
- accountId: BcsType<string, string | number | bigint, "u64">;
604
- }, string>;
605
- Registry: import("@mysten/sui/bcs").BcsStruct<{
606
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
607
- activeCollaterals: BcsType<string[], Iterable<string> & {
608
- length: number;
609
- }, string>;
610
- nextAccountId: BcsType<string, string | number | bigint, "u64">;
611
- }, string>;
612
- Vault: import("@mysten/sui/bcs").BcsStruct<{
613
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
614
- collateral_balance: import("@mysten/sui/bcs").BcsStruct<{
615
- value: BcsType<string, string | number | bigint, "u64">;
616
- }, string>;
617
- insurance_fund_balance: import("@mysten/sui/bcs").BcsStruct<{
618
- value: BcsType<string, string | number | bigint, "u64">;
619
- }, string>;
620
- scalingFactor: BcsType<string, string | number | bigint, "u64">;
621
- }, string>;
2698
+ isPausable: boolean;
2699
+ minNextPauseTimestamp: bigint;
2700
+ };
2701
+ /**
2702
+ * Request body for previewing normal withdraw requests processing for a vault.
2703
+ */
2704
+ export interface ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsBody {
2705
+ vaultId: ObjectId;
2706
+ userAddresses: SuiAddress[];
2707
+ }
2708
+ /**
2709
+ * Response body for previewing normal withdraw requests processing.
2710
+ */
2711
+ export type ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse = {
2712
+ error: string;
2713
+ } | {
2714
+ userPreviews: {
2715
+ userAddress: SuiAddress;
2716
+ collateralAmountOut: Balance;
2717
+ }[];
2718
+ collateralPrice: number;
622
2719
  };
623
- export {};
2720
+ /**
2721
+ * Request body for previewing maximum performance fees withdrawable from a vault.
2722
+ */
2723
+ export interface ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesBody {
2724
+ vaultId: ObjectId;
2725
+ }
2726
+ /**
2727
+ * Response body for previewing vault performance fee withdrawal.
2728
+ */
2729
+ export type ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse = {
2730
+ error: string;
2731
+ } | {
2732
+ maxFeesToWithdraw: Balance;
2733
+ feeCoinType: CoinType;
2734
+ };
2735
+ /**
2736
+ * SDK-level inputs for placing a market order from a client.
2737
+ *
2738
+ * This omits server-managed fields like `accountId`, `hasPosition`,
2739
+ * and serialized `txKind`, and exposes a client-friendly `slTp` wrapper.
2740
+ */
2741
+ export type SdkPerpetualsPlaceMarketOrderInputs = Omit<ApiPerpetualsMarketOrderBody, "accountId" | "txKind" | "slTp" | "walletAddress"> & {
2742
+ tx?: Transaction;
2743
+ slTp?: {
2744
+ gasCoinArg?: TransactionObjectArgument;
2745
+ isSponsoredTx?: boolean;
2746
+ size?: bigint;
2747
+ stopLossIndexPrice?: number;
2748
+ takeProfitIndexPrice?: number;
2749
+ };
2750
+ };
2751
+ /**
2752
+ * SDK-level inputs for placing a limit order from a client.
2753
+ */
2754
+ export type SdkPerpetualsPlaceLimitOrderInputs = Omit<ApiPerpetualsLimitOrderBody, "accountId" | "txKind" | "slTp" | "walletAddress"> & {
2755
+ tx?: Transaction;
2756
+ slTp?: {
2757
+ gasCoinArg?: TransactionObjectArgument;
2758
+ isSponsoredTx?: boolean;
2759
+ size?: bigint;
2760
+ stopLossIndexPrice?: number;
2761
+ takeProfitIndexPrice?: number;
2762
+ };
2763
+ };
2764
+ /**
2765
+ * SDK-level inputs for previewing a market order.
2766
+ */
2767
+ export type SdkPerpetualsPlaceMarketOrderPreviewInputs = Omit<ApiPerpetualsPreviewPlaceMarketOrderBody, "collateralCoinType" | "accountId">;
2768
+ /**
2769
+ * SDK-level inputs for previewing a limit order.
2770
+ */
2771
+ export type SdkPerpetualsPlaceLimitOrderPreviewInputs = Omit<ApiPerpetualsPreviewPlaceLimitOrderBody, "collateralCoinType" | "accountId">;
2772
+ /**
2773
+ * SDK-level inputs for previewing order cancellations.
2774
+ */
2775
+ export type SdkPerpetualsCancelOrdersPreviewInputs = Omit<ApiPerpetualsPreviewCancelOrdersBody, "collateralCoinType" | "accountId">;
2776
+ /**
2777
+ * Action for websocket subscription messages.
2778
+ */
2779
+ export type PerpetualsWsUpdatesSubscriptionAction = "subscribe" | "unsubscribe";
2780
+ /**
2781
+ * Websocket subscription payload for subscribing to a specific market's
2782
+ * updates (orderbook, prices, etc.).
2783
+ */
2784
+ export interface PerpetualsWsUpdatesMarketSubscriptionType {
2785
+ market: {
2786
+ marketId: PerpetualsMarketId;
2787
+ };
2788
+ }
2789
+ /**
2790
+ * Websocket subscription payload for subscribing to user/account updates,
2791
+ * optionally including stop-order data (via signature).
2792
+ */
2793
+ export interface PerpetualsWsUpdatesUserSubscriptionType {
2794
+ user: {
2795
+ accountId: PerpetualsAccountId;
2796
+ withStopOrders: {
2797
+ walletAddress: SuiAddress;
2798
+ bytes: string;
2799
+ signature: string;
2800
+ } | undefined;
2801
+ };
2802
+ }
2803
+ /**
2804
+ * Websocket subscription payload for market oracle price updates.
2805
+ */
2806
+ export interface PerpetualsWsUpdatesOracleSubscriptionType {
2807
+ oracle: {
2808
+ marketId: PerpetualsMarketId;
2809
+ };
2810
+ }
2811
+ /**
2812
+ * Websocket subscription payload for orderbook updates.
2813
+ */
2814
+ export interface PerpetualsWsUpdatesOrderbookSubscriptionType {
2815
+ orderbook: {
2816
+ marketId: PerpetualsMarketId;
2817
+ };
2818
+ }
2819
+ /**
2820
+ * Websocket subscription payload for market orders stream.
2821
+ */
2822
+ export interface PerpetualsWsUpdatesMarketOrdersSubscriptionType {
2823
+ marketOrders: {
2824
+ marketId: PerpetualsMarketId;
2825
+ };
2826
+ }
2827
+ /**
2828
+ * Websocket subscription payload for user-specific order updates.
2829
+ */
2830
+ export interface PerpetualsWsUpdatesUserOrdersSubscriptionType {
2831
+ userOrders: {
2832
+ accountId: PerpetualsAccountId;
2833
+ };
2834
+ }
2835
+ /**
2836
+ * Websocket subscription payload for user-specific collateral changes.
2837
+ */
2838
+ export interface PerpetualsWsUpdatesUserCollateralChangesSubscriptionType {
2839
+ userCollateralChanges: {
2840
+ accountId: PerpetualsAccountId;
2841
+ };
2842
+ }
2843
+ /**
2844
+ * Websocket subscription payload for bucketed orderbook snapshots
2845
+ * (top of orderbook) for a specific market.
2846
+ */
2847
+ export interface PerpetualsWsUpdatesTopOfOrderbookSubscriptionType {
2848
+ topOfOrderbook: {
2849
+ marketId: PerpetualsMarketId;
2850
+ priceBucketSize: number;
2851
+ bucketsNumber: number;
2852
+ };
2853
+ }
2854
+ /**
2855
+ * Union of all websocket subscription types for perpetuals updates.
2856
+ */
2857
+ export type PerpetualsWsUpdatesSubscriptionType = PerpetualsWsUpdatesMarketSubscriptionType | PerpetualsWsUpdatesUserSubscriptionType | PerpetualsWsUpdatesOracleSubscriptionType | PerpetualsWsUpdatesOrderbookSubscriptionType | PerpetualsWsUpdatesMarketOrdersSubscriptionType | PerpetualsWsUpdatesUserOrdersSubscriptionType | PerpetualsWsUpdatesUserCollateralChangesSubscriptionType | PerpetualsWsUpdatesTopOfOrderbookSubscriptionType;
2858
+ /**
2859
+ * Websocket payload for oracle price updates.
2860
+ */
2861
+ export interface PerpetualsWsUpdatesOraclePayload {
2862
+ marketId: PerpetualsMarketId;
2863
+ basePrice: number;
2864
+ collateralPrice: number;
2865
+ }
2866
+ /**
2867
+ * Websocket payload for market orders stream.
2868
+ */
2869
+ export interface PerpetualsWsUpdatesMarketOrdersPayload {
2870
+ marketId: PerpetualsMarketId;
2871
+ orders: PerpetualsMarketOrderHistoryData[];
2872
+ }
2873
+ /**
2874
+ * Websocket payload for user-specific orders stream.
2875
+ */
2876
+ export interface PerpetualsWsUpdatesUserOrdersPayload {
2877
+ accountId: PerpetualsAccountId;
2878
+ orders: PerpetualsAccountOrderHistoryData[];
2879
+ }
2880
+ /**
2881
+ * Websocket payload for user-specific collateral changes.
2882
+ */
2883
+ export interface PerpetualsWsUpdatesUserCollateralChangesPayload {
2884
+ accountId: PerpetualsAccountId;
2885
+ collateralChanges: PerpetualsAccountCollateralChange[];
2886
+ }
2887
+ /**
2888
+ * Websocket payload for incremental orderbook updates.
2889
+ */
2890
+ export interface PerpetualsWsUpdatesOrderbookPayload {
2891
+ marketId: PerpetualsMarketId;
2892
+ orderbookDeltas: PerpetualsOrderbookDeltas;
2893
+ }
2894
+ /**
2895
+ * A single data point in the bucketed (top of) orderbook.
2896
+ */
2897
+ export interface PerpetualsTopOfOrderbookDataPoint {
2898
+ price: number;
2899
+ size: number;
2900
+ totalSize: number;
2901
+ sizeUsd: number;
2902
+ totalSizeUsd: number;
2903
+ }
2904
+ /**
2905
+ * Bucketed orderbook state for top-of-orderbook updates.
2906
+ */
2907
+ export interface PerpetualsTopOfOrderbook {
2908
+ bids: PerpetualsTopOfOrderbookDataPoint[];
2909
+ asks: PerpetualsTopOfOrderbookDataPoint[];
2910
+ minAskPrice: number | undefined;
2911
+ maxBidPrice: number | undefined;
2912
+ }
2913
+ /**
2914
+ * Websocket payload for bucketed orderbook (top of orderbook) updates.
2915
+ */
2916
+ export interface PerpetualsWsUpdatesTopOfOrderbookPayload {
2917
+ marketId: PerpetualsMarketId;
2918
+ bids: PerpetualsTopOfOrderbookDataPoint[];
2919
+ asks: PerpetualsTopOfOrderbookDataPoint[];
2920
+ minAskPrice: number | undefined;
2921
+ maxBidPrice: number | undefined;
2922
+ }
2923
+ /**
2924
+ * Websocket payload for user account and stop-order updates.
2925
+ */
2926
+ export interface PerpetualsWsUpdatesUserPayload {
2927
+ account: PerpetualsAccountObject;
2928
+ stopOrders: PerpetualsStopOrderData[] | undefined;
2929
+ }
2930
+ /**
2931
+ * Websocket subscription message format sent by clients to manage
2932
+ * their subscriptions.
2933
+ */
2934
+ export interface PerpetualsWsUpdatesSubscriptionMessage {
2935
+ action: PerpetualsWsUpdatesSubscriptionAction;
2936
+ subscriptionType: PerpetualsWsUpdatesSubscriptionType;
2937
+ }
2938
+ /**
2939
+ * Websocket response message for `/perpetuals/ws/updates`.
2940
+ *
2941
+ * Each response includes exactly one of the following discriminated unions.
2942
+ */
2943
+ export type PerpetualsWsUpdatesResponseMessage = {
2944
+ market: PerpetualsMarketData;
2945
+ } | {
2946
+ user: PerpetualsWsUpdatesUserPayload;
2947
+ } | {
2948
+ oracle: PerpetualsWsUpdatesOraclePayload;
2949
+ } | {
2950
+ orderbook: PerpetualsWsUpdatesOrderbookPayload;
2951
+ } | {
2952
+ marketOrders: PerpetualsWsUpdatesMarketOrdersPayload;
2953
+ } | {
2954
+ userOrders: PerpetualsWsUpdatesUserOrdersPayload;
2955
+ } | {
2956
+ userCollateralChanges: PerpetualsWsUpdatesUserCollateralChangesPayload;
2957
+ } | {
2958
+ topOfOrderbook: PerpetualsWsUpdatesTopOfOrderbookPayload;
2959
+ };
2960
+ /**
2961
+ * Websocket response message carrying the last candle for a given market
2962
+ * and interval.
2963
+ */
2964
+ export interface PerpetualsWsCandleResponseMessage {
2965
+ marketId: PerpetualsMarketId;
2966
+ lastCandle: PerpetualsMarketCandleDataPoint | undefined;
2967
+ }
624
2968
  //# sourceMappingURL=perpetualsTypes.d.ts.map