aftermath-ts-sdk 1.3.23-perps.34 → 1.3.23-perps.36
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.
- package/dist/general/types/generalTypes.d.ts +4 -0
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.d.ts +177 -262
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.js +185 -256
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +178 -34
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +183 -39
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +116 -140
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +125 -159
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +241 -5
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsVault.d.ts +273 -19
- package/dist/packages/perpetuals/perpetualsVault.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsVault.js +289 -78
- package/package.json +1 -1
|
@@ -22,12 +22,12 @@ import { CoinType, PerpetualsMarketId, PerpetualsMarketParams, PerpetualsMarketS
|
|
|
22
22
|
*
|
|
23
23
|
* ```ts
|
|
24
24
|
* const perps = new Perpetuals(config);
|
|
25
|
-
* const markets = await perps.getMarkets({ marketIds: ["0x..."] });
|
|
26
|
-
* const
|
|
25
|
+
* const { markets } = await perps.getMarkets({ marketIds: ["0x..."] });
|
|
26
|
+
* const market = markets[0];
|
|
27
27
|
*
|
|
28
|
-
* const
|
|
29
|
-
* const stats = await
|
|
30
|
-
* const
|
|
28
|
+
* const { orderbook } = await market.getOrderbook();
|
|
29
|
+
* const stats = await market.get24hrStats();
|
|
30
|
+
* const { basePrice, collateralPrice } = await market.getPrices();
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export declare class PerpetualsMarket extends Caller {
|
|
@@ -56,17 +56,21 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
56
56
|
*
|
|
57
57
|
* @param marketData - Snapshot of market configuration and state.
|
|
58
58
|
* @param config - Optional {@link CallerConfig} (network, base URL, etc.).
|
|
59
|
+
* @param Provider - Optional shared {@link AftermathApi} provider instance.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning
|
|
63
|
+
* all HTTP requests resolve under `/perpetuals/...`.
|
|
59
64
|
*/
|
|
60
65
|
constructor(marketData: PerpetualsMarketData, config?: CallerConfig, Provider?: AftermathApi | undefined);
|
|
61
66
|
/**
|
|
62
67
|
* Fetch the mid price for this market’s orderbook.
|
|
63
68
|
*
|
|
64
69
|
* This is a convenience endpoint that returns only:
|
|
70
|
+
* - `midPrice`: midpoint between best bid and best ask, or `undefined`
|
|
71
|
+
* if the orderbook is empty or unavailable.
|
|
65
72
|
*
|
|
66
|
-
*
|
|
67
|
-
* if the orderbook is empty or malformed.
|
|
68
|
-
*
|
|
69
|
-
* @returns A promise resolving to `{ midPrice }`.
|
|
73
|
+
* @returns `{ midPrice }`.
|
|
70
74
|
*
|
|
71
75
|
* @example
|
|
72
76
|
* ```ts
|
|
@@ -80,30 +84,29 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
80
84
|
* Fetch the 24-hour statistics for this specific market.
|
|
81
85
|
*
|
|
82
86
|
* Under the hood, this calls {@link Perpetuals.getMarkets24hrStats} and
|
|
83
|
-
* returns the first (and only) entry
|
|
87
|
+
* returns the first (and only) entry.
|
|
84
88
|
*
|
|
85
|
-
* @returns {@link PerpetualsMarket24hrStats}
|
|
89
|
+
* @returns {@link PerpetualsMarket24hrStats}.
|
|
86
90
|
*
|
|
87
|
-
* @
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* ```
|
|
91
|
+
* @remarks
|
|
92
|
+
* This method creates a new {@link Perpetuals} instance using `this.config`.
|
|
93
|
+
* If you need shared Provider behavior, prefer calling `perps.getMarkets24hrStats`
|
|
94
|
+
* directly with the same Provider you initialized.
|
|
92
95
|
*/
|
|
93
96
|
get24hrStats(): Promise<PerpetualsMarket24hrStats>;
|
|
94
97
|
/**
|
|
95
98
|
* Fetch the full orderbook snapshot for this market.
|
|
96
99
|
*
|
|
97
|
-
*
|
|
98
|
-
* - `
|
|
99
|
-
* - `
|
|
100
|
+
* Implementation note:
|
|
101
|
+
* - Currently implemented via the generic `markets` endpoint with `withOrderbook: true`
|
|
102
|
+
* - The backend returns `marketDatas[]` which include both `market` and `orderbook`
|
|
100
103
|
*
|
|
101
|
-
* @returns
|
|
104
|
+
* @returns Object containing `orderbook`.
|
|
102
105
|
*
|
|
103
106
|
* @example
|
|
104
107
|
* ```ts
|
|
105
|
-
* const
|
|
106
|
-
* console.log(
|
|
108
|
+
* const { orderbook } = await market.getOrderbook();
|
|
109
|
+
* console.log(orderbook.bids[0], orderbook.asks[0]);
|
|
107
110
|
* ```
|
|
108
111
|
*/
|
|
109
112
|
getOrderbook(): Promise<{
|
|
@@ -113,25 +116,24 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
113
116
|
* Compute the maximum order size that can be placed by a given account
|
|
114
117
|
* in this market, under optional leverage and price assumptions.
|
|
115
118
|
*
|
|
116
|
-
* This is
|
|
117
|
-
* -
|
|
118
|
-
* -
|
|
119
|
+
* This is a common frontend helper for:
|
|
120
|
+
* - "max size" buttons
|
|
121
|
+
* - input validation against risk limits
|
|
119
122
|
*
|
|
120
|
-
* **Note:** This
|
|
121
|
-
* account
|
|
123
|
+
* **Note:** This is routed through the `account` namespace because it depends on
|
|
124
|
+
* the account's collateral and positions.
|
|
122
125
|
*
|
|
123
126
|
* @param inputs.accountId - Perpetuals account ID.
|
|
124
127
|
* @param inputs.side - Order side (Bid/Ask).
|
|
125
|
-
* @param inputs.leverage - Optional leverage
|
|
126
|
-
* @param inputs.price - Optional
|
|
127
|
-
* assumption may be used by the backend.
|
|
128
|
+
* @param inputs.leverage - Optional assumed leverage.
|
|
129
|
+
* @param inputs.price - Optional assumed price (e.g. for limit orders).
|
|
128
130
|
*
|
|
129
|
-
* @returns
|
|
131
|
+
* @returns `{ maxOrderSize }` in base units (scaled integer as `bigint`).
|
|
130
132
|
*
|
|
131
133
|
* @example
|
|
132
134
|
* ```ts
|
|
133
135
|
* const { maxOrderSize } = await market.getMaxOrderSize({
|
|
134
|
-
* accountId,
|
|
136
|
+
* accountId: 123n,
|
|
135
137
|
* side: PerpetualsOrderSide.Bid,
|
|
136
138
|
* leverage: 5,
|
|
137
139
|
* });
|
|
@@ -148,24 +150,16 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
148
150
|
/**
|
|
149
151
|
* Market-level preview of placing a market order.
|
|
150
152
|
*
|
|
151
|
-
* Unlike
|
|
152
|
-
*
|
|
153
|
-
* -
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* @param
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* - `{ error }`, or
|
|
162
|
-
* - A preview with:
|
|
163
|
-
* - `updatedPosition`
|
|
164
|
-
* - `priceSlippage` / `percentSlippage`
|
|
165
|
-
* - `filledSize` / `filledSizeUsd`
|
|
166
|
-
* - `postedSize` / `postedSizeUsd`
|
|
167
|
-
* - `collateralChange`
|
|
168
|
-
* - `executionPrice`
|
|
153
|
+
* Unlike {@link PerpetualsAccount.getPlaceMarketOrderPreview}, this version:
|
|
154
|
+
* - Calls `account/previews/place-market-order`
|
|
155
|
+
* - Explicitly sets `accountId: undefined`, allowing a “generic” preview that
|
|
156
|
+
* doesn’t rely on a specific account’s on-chain positions/collateral.
|
|
157
|
+
*
|
|
158
|
+
* @param inputs - {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.
|
|
159
|
+
* @param abortSignal - Optional abort signal to cancel the request.
|
|
160
|
+
*
|
|
161
|
+
* @returns Either `{ error }` or a preview containing the simulated updated position,
|
|
162
|
+
* slippage, filled/posted sizes, collateral change, and execution price.
|
|
169
163
|
*/
|
|
170
164
|
getPlaceMarketOrderPreview(inputs: SdkPerpetualsPlaceMarketOrderPreviewInputs, abortSignal?: AbortSignal): Promise<{
|
|
171
165
|
error: string;
|
|
@@ -187,12 +181,10 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
187
181
|
* - `account/previews/place-limit-order`
|
|
188
182
|
* - `accountId: undefined`
|
|
189
183
|
*
|
|
190
|
-
* @param inputs -
|
|
191
|
-
* @param abortSignal - Optional
|
|
184
|
+
* @param inputs - {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.
|
|
185
|
+
* @param abortSignal - Optional abort signal to cancel the request.
|
|
192
186
|
*
|
|
193
|
-
* @returns Either
|
|
194
|
-
* - `{ error }`, or
|
|
195
|
-
* - A preview object with post-order position, slippage, and collateral changes.
|
|
187
|
+
* @returns Either `{ error }` or a preview describing the simulated post-order state.
|
|
196
188
|
*/
|
|
197
189
|
getPlaceLimitOrderPreview(inputs: SdkPerpetualsPlaceLimitOrderPreviewInputs, abortSignal?: AbortSignal): Promise<{
|
|
198
190
|
error: string;
|
|
@@ -210,34 +202,26 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
210
202
|
/**
|
|
211
203
|
* Fetch paginated order history for this market.
|
|
212
204
|
*
|
|
213
|
-
* This
|
|
214
|
-
* for charting, recent orders lists, etc.
|
|
215
|
-
*
|
|
216
|
-
* @param inputs.cursor - Optional pagination cursor.
|
|
217
|
-
* @param inputs.limit - Optional number of orders per page.
|
|
205
|
+
* This is market-wide (public) history, not scoped to any account.
|
|
218
206
|
*
|
|
219
|
-
* @
|
|
220
|
-
*
|
|
207
|
+
* @param inputs.beforeTimestampCursor - Optional pagination cursor.
|
|
208
|
+
* @param inputs.limit - Optional page size.
|
|
221
209
|
*
|
|
222
|
-
* @
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* console.log(result.orders.length, result.nextBeforeTimestampCursor);
|
|
226
|
-
* ```
|
|
210
|
+
* @returns {@link ApiPerpetualsMarketOrderHistoryResponse} containing:
|
|
211
|
+
* - `orders`
|
|
212
|
+
* - `nextBeforeTimestampCursor`
|
|
227
213
|
*/
|
|
228
214
|
getOrderHistory(inputs: Omit<ApiPerpetualsMarketOrderHistoryBody, "marketId">): Promise<ApiPerpetualsMarketOrderHistoryResponse>;
|
|
229
215
|
/**
|
|
230
216
|
* Fetch the current base and collateral prices for this market.
|
|
231
217
|
*
|
|
232
|
-
* Internally calls {@link Perpetuals.getPrices} and returns the first
|
|
233
|
-
* element corresponding to `this.marketId`.
|
|
218
|
+
* Internally calls {@link Perpetuals.getPrices} and returns the first result.
|
|
234
219
|
*
|
|
235
|
-
* @returns `{ basePrice, collateralPrice }
|
|
220
|
+
* @returns `{ basePrice, collateralPrice }`.
|
|
236
221
|
*
|
|
237
|
-
* @
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* ```
|
|
222
|
+
* @remarks
|
|
223
|
+
* This method instantiates a new {@link Perpetuals} client using `this.config`.
|
|
224
|
+
* If you rely on a shared Provider, call `perps.getPrices(...)` directly instead.
|
|
241
225
|
*/
|
|
242
226
|
getPrices(): Promise<{
|
|
243
227
|
basePrice: number;
|
|
@@ -246,18 +230,20 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
246
230
|
/**
|
|
247
231
|
* Compute the remaining time until the next funding event, in milliseconds.
|
|
248
232
|
*
|
|
249
|
-
* - If the on-chain `nextFundingTimestampMs` exceeds `Number.MAX_SAFE_INTEGER`,
|
|
250
|
-
* this uses `Number.MAX_SAFE_INTEGER` as a cap via {@link nextFundingTimeMs}.
|
|
251
|
-
*
|
|
252
233
|
* @returns `nextFundingTimeMs() - Date.now()`.
|
|
234
|
+
*
|
|
235
|
+
* @remarks
|
|
236
|
+
* If the next funding timestamp does not fit safely into a JS `number`,
|
|
237
|
+
* {@link nextFundingTimeMs} returns `Number.MAX_SAFE_INTEGER`, and the
|
|
238
|
+
* difference may be very large.
|
|
253
239
|
*/
|
|
254
240
|
timeUntilNextFundingMs: () => Timestamp;
|
|
255
241
|
/**
|
|
256
242
|
* Get the scheduled timestamp for the next funding event, in milliseconds.
|
|
257
243
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* `Number.MAX_SAFE_INTEGER
|
|
244
|
+
* Safety behavior:
|
|
245
|
+
* - If `marketData.nextFundingTimestampMs` exceeds `Number.MAX_SAFE_INTEGER`,
|
|
246
|
+
* this returns `Number.MAX_SAFE_INTEGER`.
|
|
261
247
|
*
|
|
262
248
|
* @returns Next funding timestamp (ms) as a JS `number`.
|
|
263
249
|
*/
|
|
@@ -265,39 +251,31 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
265
251
|
/**
|
|
266
252
|
* Estimated funding rate per period for this market.
|
|
267
253
|
*
|
|
268
|
-
*
|
|
254
|
+
* This is read directly from `marketData.estimatedFundingRate`.
|
|
269
255
|
*
|
|
270
|
-
*
|
|
271
|
-
* (bookTwap - indexTwap) / indexPrice * (fundingFrequency / fundingPeriod)
|
|
272
|
-
* ```
|
|
273
|
-
*
|
|
274
|
-
* but here it's read directly from `marketData.estimatedFundingRate`.
|
|
275
|
-
*
|
|
276
|
-
* @returns Estimated funding rate as a fraction (e.g. 0.01 = 1%).
|
|
256
|
+
* @returns Estimated funding rate as a fraction (e.g. `0.01` = 1%).
|
|
277
257
|
*/
|
|
278
258
|
estimatedFundingRate: () => Percentage;
|
|
279
259
|
/**
|
|
280
|
-
* Calculate the collateral required to support an order given leverage
|
|
281
|
-
* and prices.
|
|
260
|
+
* Calculate the collateral required to support an order given leverage and prices.
|
|
282
261
|
*
|
|
283
|
-
* The
|
|
262
|
+
* The computed collateral is based on the *remaining* unfilled size:
|
|
263
|
+
* `remaining = initialSize - filledSize`.
|
|
284
264
|
*
|
|
265
|
+
* USD requirement:
|
|
285
266
|
* ```text
|
|
286
|
-
*
|
|
267
|
+
* remainingBase * indexPrice * initialMarginRatio
|
|
287
268
|
* ```
|
|
269
|
+
* where `initialMarginRatio = 1 / leverage` (or 1 if leverage is falsy).
|
|
288
270
|
*
|
|
289
|
-
*
|
|
290
|
-
* - `remainingSizeBase` = `(initialSize - filledSize) / fixedOneN9`
|
|
291
|
-
* - `initialMarginRatio` = `1 / leverage` (or 1 if leverage is falsy).
|
|
292
|
-
*
|
|
293
|
-
* @param inputs.leverage - Target leverage for the order.
|
|
271
|
+
* @param inputs.leverage - Target leverage for the order (>= 1).
|
|
294
272
|
* @param inputs.orderData - Order data containing `initialSize` and `filledSize`.
|
|
295
|
-
* @param inputs.indexPrice -
|
|
296
|
-
* @param inputs.collateralPrice - Price of the collateral asset
|
|
273
|
+
* @param inputs.indexPrice - Index/oracle price of the base asset.
|
|
274
|
+
* @param inputs.collateralPrice - Price of the collateral asset.
|
|
297
275
|
*
|
|
298
276
|
* @returns Object with:
|
|
299
|
-
* - `collateralUsd`: required collateral in USD
|
|
300
|
-
* - `collateral`: required collateral in collateral
|
|
277
|
+
* - `collateralUsd`: required collateral in USD
|
|
278
|
+
* - `collateral`: required collateral in collateral coin units
|
|
301
279
|
*/
|
|
302
280
|
calcCollateralUsedForOrder: (inputs: {
|
|
303
281
|
leverage: number;
|
|
@@ -309,29 +287,30 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
309
287
|
collateralUsd: number;
|
|
310
288
|
};
|
|
311
289
|
/**
|
|
312
|
-
* Get the base
|
|
290
|
+
* Get the base-asset lot size for this market as a `number`.
|
|
313
291
|
*
|
|
314
|
-
* Order sizes must be
|
|
292
|
+
* Order sizes must be multiples of this lot size.
|
|
315
293
|
*
|
|
316
294
|
* @returns Lot size in base asset units.
|
|
317
295
|
*/
|
|
318
296
|
lotSize(): number;
|
|
319
297
|
/**
|
|
320
|
-
* Get the minimal price tick for this market as a `number`.
|
|
298
|
+
* Get the minimal price tick size for this market as a `number`.
|
|
321
299
|
*
|
|
322
|
-
* Limit prices must be
|
|
300
|
+
* Limit prices must be multiples of this tick size.
|
|
323
301
|
*
|
|
324
302
|
* @returns Tick size in quote units (e.g. USD).
|
|
325
303
|
*/
|
|
326
304
|
tickSize(): number;
|
|
327
305
|
/**
|
|
328
|
-
* Get the maximum theoretical leverage for this market
|
|
306
|
+
* Get the maximum theoretical leverage for this market.
|
|
329
307
|
*
|
|
308
|
+
* Computed as:
|
|
330
309
|
* ```ts
|
|
331
310
|
* 1 / marginRatioInitial
|
|
332
311
|
* ```
|
|
333
312
|
*
|
|
334
|
-
* @returns Maximum leverage
|
|
313
|
+
* @returns Maximum leverage.
|
|
335
314
|
*/
|
|
336
315
|
maxLeverage(): number;
|
|
337
316
|
/**
|
|
@@ -345,7 +324,7 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
345
324
|
/**
|
|
346
325
|
* Get the maintenance margin ratio for this market.
|
|
347
326
|
*
|
|
348
|
-
* Falling below this ratio may
|
|
327
|
+
* Falling below this ratio may trigger liquidation.
|
|
349
328
|
*
|
|
350
329
|
* @returns Maintenance margin ratio as a fraction.
|
|
351
330
|
*/
|
|
@@ -353,18 +332,15 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
353
332
|
/**
|
|
354
333
|
* Round a price to the nearest valid tick for this market.
|
|
355
334
|
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* If neither `floor` nor `ceil` are set, this uses `Math.round`.
|
|
361
|
-
*
|
|
362
|
-
* @returns Price snapped to a valid tick.
|
|
335
|
+
* Rounding mode:
|
|
336
|
+
* - `floor: true` => round down
|
|
337
|
+
* - `ceil: true` => round up
|
|
338
|
+
* - neither => nearest tick (`Math.round`)
|
|
363
339
|
*
|
|
364
|
-
* @
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
340
|
+
* @param inputs.price - Raw price to round.
|
|
341
|
+
* @param inputs.floor - Force floor rounding.
|
|
342
|
+
* @param inputs.ceil - Force ceil rounding.
|
|
343
|
+
* @returns Price snapped to the market tick size.
|
|
368
344
|
*/
|
|
369
345
|
roundToValidPrice: (inputs: {
|
|
370
346
|
price: number;
|
|
@@ -372,16 +348,15 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
372
348
|
ceil?: boolean;
|
|
373
349
|
}) => number;
|
|
374
350
|
/**
|
|
375
|
-
* Round a price to the nearest valid tick
|
|
376
|
-
* a `bigint` scaled by `Fixed.fixedOneN9`.
|
|
351
|
+
* Round a price to the nearest valid tick as a fixed-point `bigint` (1e9 precision).
|
|
377
352
|
*
|
|
378
|
-
* This is
|
|
353
|
+
* This is helpful when you need the on-chain representation directly
|
|
354
|
+
* (e.g. order price fields stored in 9-decimal fixed).
|
|
379
355
|
*
|
|
380
356
|
* @param inputs.price - Raw price as a JS number.
|
|
381
|
-
* @param inputs.floor -
|
|
382
|
-
* @param inputs.ceil -
|
|
383
|
-
*
|
|
384
|
-
* @returns Price scaled by `1e9` and snapped to a valid tick as a `bigint`.
|
|
357
|
+
* @param inputs.floor - Force floor rounding.
|
|
358
|
+
* @param inputs.ceil - Force ceil rounding.
|
|
359
|
+
* @returns Tick-snapped price scaled by `1e9`.
|
|
385
360
|
*/
|
|
386
361
|
roundToValidPriceBigInt: (inputs: {
|
|
387
362
|
price: number;
|
|
@@ -391,11 +366,15 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
391
366
|
/**
|
|
392
367
|
* Round a base-asset size to the nearest valid lot size for this market.
|
|
393
368
|
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
369
|
+
* Rounding mode:
|
|
370
|
+
* - `floor: true` => round down
|
|
371
|
+
* - `ceil: true` => round up
|
|
372
|
+
* - neither => nearest lot (`Math.round`)
|
|
397
373
|
*
|
|
398
|
-
* @
|
|
374
|
+
* @param inputs.size - Raw size in base asset units.
|
|
375
|
+
* @param inputs.floor - Force floor rounding.
|
|
376
|
+
* @param inputs.ceil - Force ceil rounding.
|
|
377
|
+
* @returns Size snapped to the market lot size.
|
|
399
378
|
*/
|
|
400
379
|
roundToValidSize: (inputs: {
|
|
401
380
|
size: number;
|
|
@@ -403,14 +382,12 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
403
382
|
ceil?: boolean;
|
|
404
383
|
}) => number;
|
|
405
384
|
/**
|
|
406
|
-
* Round a base-asset size to the nearest valid lot
|
|
407
|
-
* as a scaled `bigint` (`Fixed.fixedOneN9`).
|
|
408
|
-
*
|
|
409
|
-
* @param inputs.size - Raw size in base units.
|
|
410
|
-
* @param inputs.floor - If `true`, always round down.
|
|
411
|
-
* @param inputs.ceil - If `true`, always round up.
|
|
385
|
+
* Round a base-asset size to the nearest valid lot as a fixed-point `bigint` (1e9 precision).
|
|
412
386
|
*
|
|
413
|
-
* @
|
|
387
|
+
* @param inputs.size - Raw base size as a JS number.
|
|
388
|
+
* @param inputs.floor - Force floor rounding.
|
|
389
|
+
* @param inputs.ceil - Force ceil rounding.
|
|
390
|
+
* @returns Lot-snapped size scaled by `1e9`.
|
|
414
391
|
*/
|
|
415
392
|
roundToValidSizeBigInt: (inputs: {
|
|
416
393
|
size: number;
|
|
@@ -420,9 +397,8 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
420
397
|
/**
|
|
421
398
|
* Construct an "empty" position object for this market.
|
|
422
399
|
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
* object with defaulted values.
|
|
400
|
+
* Useful when an account has no open position but downstream UI/calculations
|
|
401
|
+
* expect a {@link PerpetualsPosition}-shaped object.
|
|
426
402
|
*
|
|
427
403
|
* @returns A zeroed-out {@link PerpetualsPosition} for `this.marketId`.
|
|
428
404
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpetualsMarket.d.ts","sourceRoot":"","sources":["../../../src/packages/perpetuals/perpetualsMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM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