aftermath-ts-sdk 1.3.23-perps.26 → 1.3.23-perps.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packages/perpetuals/perpetuals.d.ts +539 -14
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.js +540 -57
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +474 -8
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +489 -25
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +337 -3
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +321 -1
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +907 -30
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsTypes.js +70 -0
- package/dist/packages/perpetuals/perpetualsVault.d.ts +3 -2
- package/dist/packages/perpetuals/perpetualsVault.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsVault.js +29 -24
- package/package.json +1 -1
|
@@ -1,17 +1,138 @@
|
|
|
1
1
|
import { Caller } from "../../general/utils/caller";
|
|
2
2
|
import { CoinType, PerpetualsMarketId, PerpetualsMarketParams, PerpetualsMarketState, PerpetualsOrderData, PerpetualsOrderSide, PerpetualsOrderbook, PerpetualsPosition, Timestamp, PerpetualsMarketData, ApiDataWithCursorBody, PerpetualsTradeHistoryWithCursor, CallerConfig, Percentage, PerpetualsMarket24hrStats, SdkPerpetualsPlaceLimitOrderPreviewInputs, SdkPerpetualsPlaceMarketOrderPreviewInputs, PerpetualsAccountId } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* High-level wrapper around a single perpetuals market.
|
|
5
|
+
*
|
|
6
|
+
* This class provides:
|
|
7
|
+
*
|
|
8
|
+
* - Lightweight accessors for immutable market properties:
|
|
9
|
+
* - `marketId`, `indexPrice`, `collateralPrice`, `collateralCoinType`
|
|
10
|
+
* - `marketParams`, `marketState`
|
|
11
|
+
* - Read endpoints for:
|
|
12
|
+
* - Orderbook snapshots
|
|
13
|
+
* - 24h stats and trade history
|
|
14
|
+
* - Market prices and derived funding metrics
|
|
15
|
+
* - Helpers for:
|
|
16
|
+
* - Order sizing (max size, lot/tick rounding)
|
|
17
|
+
* - Margin and collateral calculations
|
|
18
|
+
* - Constructing an “empty” position for a market
|
|
19
|
+
*
|
|
20
|
+
* Typical usage:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const perps = new Perpetuals(config);
|
|
24
|
+
* const markets = await perps.getMarkets({ marketIds: ["0x..."] });
|
|
25
|
+
* const btcPerp = new PerpetualsMarket(markets[0], config);
|
|
26
|
+
*
|
|
27
|
+
* const ob = await btcPerp.getOrderbook();
|
|
28
|
+
* const stats = await btcPerp.get24hrStats();
|
|
29
|
+
* const prices = await btcPerp.getPrices();
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
3
32
|
export declare class PerpetualsMarket extends Caller {
|
|
4
33
|
marketData: PerpetualsMarketData;
|
|
34
|
+
/** Unique identifier for this perpetuals market (object ID on chain). */
|
|
5
35
|
readonly marketId: PerpetualsMarketId;
|
|
36
|
+
/**
|
|
37
|
+
* Current oracle/index price for the market's underlying asset, quoted in
|
|
38
|
+
* the index unit (typically USD).
|
|
39
|
+
*/
|
|
6
40
|
readonly indexPrice: number;
|
|
41
|
+
/**
|
|
42
|
+
* Current price of the collateral asset in USD (or the platform's base
|
|
43
|
+
* pricing unit).
|
|
44
|
+
*/
|
|
7
45
|
readonly collateralPrice: number;
|
|
46
|
+
/** Sui type of the collateral coin (e.g. `"0x2::sui::SUI"`). */
|
|
8
47
|
readonly collateralCoinType: CoinType;
|
|
48
|
+
/** Static market configuration parameters (lot size, tick size, margins, etc.). */
|
|
9
49
|
readonly marketParams: PerpetualsMarketParams;
|
|
50
|
+
/** Dynamic market state (funding rates, open interest, etc.). */
|
|
10
51
|
readonly marketState: PerpetualsMarketState;
|
|
52
|
+
/**
|
|
53
|
+
* Create a new {@link PerpetualsMarket} wrapper from raw market data.
|
|
54
|
+
*
|
|
55
|
+
* @param marketData - Snapshot of market configuration and state.
|
|
56
|
+
* @param config - Optional {@link CallerConfig} (network, base URL, etc.).
|
|
57
|
+
*/
|
|
11
58
|
constructor(marketData: PerpetualsMarketData, config?: CallerConfig);
|
|
12
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Fetch the mid price for this market’s orderbook.
|
|
61
|
+
*
|
|
62
|
+
* This is a convenience endpoint that returns only:
|
|
63
|
+
*
|
|
64
|
+
* - `midPrice`: The midpoint between best bid and best ask, or `undefined`
|
|
65
|
+
* if the orderbook is empty or malformed.
|
|
66
|
+
*
|
|
67
|
+
* @returns A promise resolving to `{ midPrice }`.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const { midPrice } = await market.getOrderbookMidPrice();
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
getOrderbookMidPrice(): Promise<{
|
|
75
|
+
midPrice: number | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Fetch the 24-hour statistics for this specific market.
|
|
79
|
+
*
|
|
80
|
+
* Under the hood, this calls {@link Perpetuals.getMarkets24hrStats} and
|
|
81
|
+
* returns the first (and only) entry for this market.
|
|
82
|
+
*
|
|
83
|
+
* @returns {@link PerpetualsMarket24hrStats} with volume, high/low, and other metrics.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const stats = await market.get24hrStats();
|
|
88
|
+
* console.log(stats.volumeUsd, stats.priceChangePct);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
13
91
|
get24hrStats(): Promise<PerpetualsMarket24hrStats>;
|
|
92
|
+
/**
|
|
93
|
+
* Fetch the full orderbook snapshot for this market.
|
|
94
|
+
*
|
|
95
|
+
* Currently implemented via the generic `markets` endpoint with:
|
|
96
|
+
* - `marketIds: [this.marketId]`
|
|
97
|
+
* - `withOrderbook: true`
|
|
98
|
+
*
|
|
99
|
+
* @returns {@link PerpetualsOrderbook} for this market.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const ob = await market.getOrderbook();
|
|
104
|
+
* console.log(ob.bids[0], ob.asks[0]);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
14
107
|
getOrderbook(): Promise<PerpetualsOrderbook>;
|
|
108
|
+
/**
|
|
109
|
+
* Compute the maximum order size that can be placed by a given account
|
|
110
|
+
* in this market, under optional leverage and price assumptions.
|
|
111
|
+
*
|
|
112
|
+
* This is useful for frontends to:
|
|
113
|
+
* - Drive "max" buttons.
|
|
114
|
+
* - Validate order inputs against risk limits.
|
|
115
|
+
*
|
|
116
|
+
* **Note:** This lives on the `account` namespace since it depends on
|
|
117
|
+
* account state.
|
|
118
|
+
*
|
|
119
|
+
* @param inputs.accountId - Perpetuals account ID.
|
|
120
|
+
* @param inputs.side - Order side (Bid/Ask).
|
|
121
|
+
* @param inputs.leverage - Optional leverage to assume (defaults to account-level).
|
|
122
|
+
* @param inputs.price - Optional limit price; if omitted, a default or index-based
|
|
123
|
+
* assumption may be used by the backend.
|
|
124
|
+
*
|
|
125
|
+
* @returns An object containing `maxOrderSize` (as `bigint` in base units).
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* const { maxOrderSize } = await market.getMaxOrderSize({
|
|
130
|
+
* accountId,
|
|
131
|
+
* side: PerpetualsOrderSide.Bid,
|
|
132
|
+
* leverage: 5,
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
15
136
|
getMaxOrderSize: (inputs: {
|
|
16
137
|
accountId: PerpetualsAccountId;
|
|
17
138
|
side: PerpetualsOrderSide;
|
|
@@ -20,10 +141,32 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
20
141
|
}) => Promise<{
|
|
21
142
|
maxOrderSize: bigint;
|
|
22
143
|
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Market-level preview of placing a market order.
|
|
146
|
+
*
|
|
147
|
+
* Unlike the account-specific preview on {@link PerpetualsAccount},
|
|
148
|
+
* this version:
|
|
149
|
+
* - Calls `account/previews/place-market-order`.
|
|
150
|
+
* - Explicitly sets `accountId: undefined`, allowing the backend to use
|
|
151
|
+
* generic or hypothetical assumptions about account state.
|
|
152
|
+
*
|
|
153
|
+
* @param inputs - See {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.
|
|
154
|
+
* @param abortSignal - Optional `AbortSignal` to cancel the HTTP request.
|
|
155
|
+
*
|
|
156
|
+
* @returns Either:
|
|
157
|
+
* - `{ error }`, or
|
|
158
|
+
* - A preview with:
|
|
159
|
+
* - `updatedPosition`
|
|
160
|
+
* - `priceSlippage` / `percentSlippage`
|
|
161
|
+
* - `filledSize` / `filledSizeUsd`
|
|
162
|
+
* - `postedSize` / `postedSizeUsd`
|
|
163
|
+
* - `collateralChange`
|
|
164
|
+
* - `executionPrice`
|
|
165
|
+
*/
|
|
23
166
|
getPlaceMarketOrderPreview(inputs: SdkPerpetualsPlaceMarketOrderPreviewInputs, abortSignal?: AbortSignal): Promise<{
|
|
24
167
|
error: string;
|
|
25
168
|
} | {
|
|
26
|
-
|
|
169
|
+
updatedPosition: PerpetualsPosition;
|
|
27
170
|
priceSlippage: number;
|
|
28
171
|
percentSlippage: Percentage;
|
|
29
172
|
filledSize: number;
|
|
@@ -33,10 +176,24 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
33
176
|
collateralChange: number;
|
|
34
177
|
executionPrice: number;
|
|
35
178
|
}>;
|
|
179
|
+
/**
|
|
180
|
+
* Market-level preview of placing a limit order.
|
|
181
|
+
*
|
|
182
|
+
* Similar to {@link getPlaceMarketOrderPreview}, this uses:
|
|
183
|
+
* - `account/previews/place-limit-order`
|
|
184
|
+
* - `accountId: undefined`
|
|
185
|
+
*
|
|
186
|
+
* @param inputs - See {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.
|
|
187
|
+
* @param abortSignal - Optional `AbortSignal` to cancel the request.
|
|
188
|
+
*
|
|
189
|
+
* @returns Either:
|
|
190
|
+
* - `{ error }`, or
|
|
191
|
+
* - A preview object with post-order position, slippage, and collateral changes.
|
|
192
|
+
*/
|
|
36
193
|
getPlaceLimitOrderPreview(inputs: SdkPerpetualsPlaceLimitOrderPreviewInputs, abortSignal?: AbortSignal): Promise<{
|
|
37
194
|
error: string;
|
|
38
195
|
} | {
|
|
39
|
-
|
|
196
|
+
updatedPosition: PerpetualsPosition;
|
|
40
197
|
priceSlippage: number;
|
|
41
198
|
percentSlippage: Percentage;
|
|
42
199
|
filledSize: number;
|
|
@@ -46,14 +203,98 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
46
203
|
collateralChange: number;
|
|
47
204
|
executionPrice: number;
|
|
48
205
|
}>;
|
|
206
|
+
/**
|
|
207
|
+
* Fetch paginated trade history for this market.
|
|
208
|
+
*
|
|
209
|
+
* This returns *market-level* trade history (not account-specific), useful
|
|
210
|
+
* for charting, recent trades lists, etc.
|
|
211
|
+
*
|
|
212
|
+
* @param inputs.cursor - Optional pagination cursor.
|
|
213
|
+
* @param inputs.limit - Optional number of trades per page.
|
|
214
|
+
*
|
|
215
|
+
* @returns {@link PerpetualsTradeHistoryWithCursor} including a list of
|
|
216
|
+
* trades and a `nextCursor`.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const result = await market.getTradeHistory({ limit: 100 });
|
|
221
|
+
* console.log(result.trades.length, result.nextCursor);
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
49
224
|
getTradeHistory(inputs: ApiDataWithCursorBody<Timestamp>): Promise<PerpetualsTradeHistoryWithCursor>;
|
|
225
|
+
/**
|
|
226
|
+
* Fetch the current base and collateral prices for this market.
|
|
227
|
+
*
|
|
228
|
+
* Internally calls {@link Perpetuals.getPrices} and returns the first
|
|
229
|
+
* element corresponding to `this.marketId`.
|
|
230
|
+
*
|
|
231
|
+
* @returns `{ basePrice, collateralPrice }` for this market.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* const { basePrice, collateralPrice } = await market.getPrices();
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
50
238
|
getPrices(): Promise<{
|
|
51
239
|
basePrice: number;
|
|
52
240
|
collateralPrice: number;
|
|
53
241
|
}>;
|
|
242
|
+
/**
|
|
243
|
+
* Compute the remaining time until the next funding event, in milliseconds.
|
|
244
|
+
*
|
|
245
|
+
* - If the on-chain `nextFundingTimestampMs` exceeds `Number.MAX_SAFE_INTEGER`,
|
|
246
|
+
* this uses `Number.MAX_SAFE_INTEGER` as a cap via {@link nextFundingTimeMs}.
|
|
247
|
+
*
|
|
248
|
+
* @returns `nextFundingTimeMs() - Date.now()`.
|
|
249
|
+
*/
|
|
54
250
|
timeUntilNextFundingMs: () => Timestamp;
|
|
251
|
+
/**
|
|
252
|
+
* Get the scheduled timestamp for the next funding event, in milliseconds.
|
|
253
|
+
*
|
|
254
|
+
* - If `nextFundingTimestampMs` doesn't fit in JS `number` safely
|
|
255
|
+
* (i.e. `> Number.MAX_SAFE_INTEGER`), this method returns
|
|
256
|
+
* `Number.MAX_SAFE_INTEGER` as a safeguard.
|
|
257
|
+
*
|
|
258
|
+
* @returns Next funding timestamp (ms) as a JS `number`.
|
|
259
|
+
*/
|
|
55
260
|
nextFundingTimeMs: () => Timestamp;
|
|
261
|
+
/**
|
|
262
|
+
* Estimated funding rate per period for this market.
|
|
263
|
+
*
|
|
264
|
+
* Conceptually defined as:
|
|
265
|
+
*
|
|
266
|
+
* ```text
|
|
267
|
+
* (bookTwap - indexTwap) / indexPrice * (fundingFrequency / fundingPeriod)
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* but here it's read directly from `marketData.estimatedFundingRate`.
|
|
271
|
+
*
|
|
272
|
+
* @returns Estimated funding rate as a fraction (e.g. 0.01 = 1%).
|
|
273
|
+
*/
|
|
56
274
|
estimatedFundingRate: () => Percentage;
|
|
275
|
+
/**
|
|
276
|
+
* Calculate the collateral required to support an order given leverage
|
|
277
|
+
* and prices.
|
|
278
|
+
*
|
|
279
|
+
* The formula is (in USD):
|
|
280
|
+
*
|
|
281
|
+
* ```text
|
|
282
|
+
* remainingSizeBase * indexPrice * initialMarginRatio
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* where:
|
|
286
|
+
* - `remainingSizeBase` = `(initialSize - filledSize) / fixedOneN9`
|
|
287
|
+
* - `initialMarginRatio` = `1 / leverage` (or 1 if leverage is falsy).
|
|
288
|
+
*
|
|
289
|
+
* @param inputs.leverage - Target leverage for the order.
|
|
290
|
+
* @param inputs.orderData - Order data containing `initialSize` and `filledSize`.
|
|
291
|
+
* @param inputs.indexPrice - Current index price of the underlying.
|
|
292
|
+
* @param inputs.collateralPrice - Price of the collateral asset in USD.
|
|
293
|
+
*
|
|
294
|
+
* @returns Object with:
|
|
295
|
+
* - `collateralUsd`: required collateral in USD.
|
|
296
|
+
* - `collateral`: required collateral in collateral coins.
|
|
297
|
+
*/
|
|
57
298
|
calcCollateralUsedForOrder: (inputs: {
|
|
58
299
|
leverage: number;
|
|
59
300
|
orderData: PerpetualsOrderData;
|
|
@@ -63,31 +304,124 @@ export declare class PerpetualsMarket extends Caller {
|
|
|
63
304
|
collateral: number;
|
|
64
305
|
collateralUsd: number;
|
|
65
306
|
};
|
|
307
|
+
/**
|
|
308
|
+
* Get the base asset lot size for this market as a `number`.
|
|
309
|
+
*
|
|
310
|
+
* Order sizes must be a multiple of this lot size.
|
|
311
|
+
*
|
|
312
|
+
* @returns Lot size in base asset units.
|
|
313
|
+
*/
|
|
66
314
|
lotSize(): number;
|
|
315
|
+
/**
|
|
316
|
+
* Get the minimal price tick for this market as a `number`.
|
|
317
|
+
*
|
|
318
|
+
* Limit prices must be a multiple of this tick size.
|
|
319
|
+
*
|
|
320
|
+
* @returns Tick size in quote units (e.g. USD).
|
|
321
|
+
*/
|
|
67
322
|
tickSize(): number;
|
|
323
|
+
/**
|
|
324
|
+
* Get the maximum theoretical leverage for this market, computed as:
|
|
325
|
+
*
|
|
326
|
+
* ```ts
|
|
327
|
+
* 1 / marginRatioInitial
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @returns Maximum leverage value for opening positions.
|
|
331
|
+
*/
|
|
68
332
|
maxLeverage(): number;
|
|
333
|
+
/**
|
|
334
|
+
* Get the initial margin ratio for this market.
|
|
335
|
+
*
|
|
336
|
+
* This is the minimum margin required when opening a position.
|
|
337
|
+
*
|
|
338
|
+
* @returns Initial margin ratio as a fraction (e.g. 0.05 = 20x).
|
|
339
|
+
*/
|
|
69
340
|
initialMarginRatio(): number;
|
|
341
|
+
/**
|
|
342
|
+
* Get the maintenance margin ratio for this market.
|
|
343
|
+
*
|
|
344
|
+
* Falling below this ratio may result in liquidation.
|
|
345
|
+
*
|
|
346
|
+
* @returns Maintenance margin ratio as a fraction.
|
|
347
|
+
*/
|
|
70
348
|
maintenanceMarginRatio(): number;
|
|
349
|
+
/**
|
|
350
|
+
* Round a price to the nearest valid tick for this market.
|
|
351
|
+
*
|
|
352
|
+
* @param inputs.price - Raw price to round.
|
|
353
|
+
* @param inputs.floor - If `true`, always round down to the previous tick.
|
|
354
|
+
* @param inputs.ceil - If `true`, always round up to the next tick.
|
|
355
|
+
*
|
|
356
|
+
* If neither `floor` nor `ceil` are set, this uses `Math.round`.
|
|
357
|
+
*
|
|
358
|
+
* @returns Price snapped to a valid tick.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```ts
|
|
362
|
+
* const validPrice = market.roundToValidPrice({ price: 27123.45 });
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
71
365
|
roundToValidPrice: (inputs: {
|
|
72
366
|
price: number;
|
|
73
367
|
floor?: boolean;
|
|
74
368
|
ceil?: boolean;
|
|
75
369
|
}) => number;
|
|
370
|
+
/**
|
|
371
|
+
* Round a price to the nearest valid tick for this market, expressed as
|
|
372
|
+
* a `bigint` scaled by `Fixed.fixedOneN9`.
|
|
373
|
+
*
|
|
374
|
+
* This is useful when you need the on-chain representation directly.
|
|
375
|
+
*
|
|
376
|
+
* @param inputs.price - Raw price as a JS number.
|
|
377
|
+
* @param inputs.floor - If `true`, always round down.
|
|
378
|
+
* @param inputs.ceil - If `true`, always round up.
|
|
379
|
+
*
|
|
380
|
+
* @returns Price scaled by `1e9` and snapped to a valid tick as a `bigint`.
|
|
381
|
+
*/
|
|
76
382
|
roundToValidPriceBigInt: (inputs: {
|
|
77
383
|
price: number;
|
|
78
384
|
floor?: boolean;
|
|
79
385
|
ceil?: boolean;
|
|
80
386
|
}) => bigint;
|
|
387
|
+
/**
|
|
388
|
+
* Round a base-asset size to the nearest valid lot size for this market.
|
|
389
|
+
*
|
|
390
|
+
* @param inputs.size - Raw size in base asset units.
|
|
391
|
+
* @param inputs.floor - If `true`, always round down.
|
|
392
|
+
* @param inputs.ceil - If `true`, always round up.
|
|
393
|
+
*
|
|
394
|
+
* @returns Size snapped to a valid lot boundary.
|
|
395
|
+
*/
|
|
81
396
|
roundToValidSize: (inputs: {
|
|
82
397
|
size: number;
|
|
83
398
|
floor?: boolean;
|
|
84
399
|
ceil?: boolean;
|
|
85
400
|
}) => number;
|
|
401
|
+
/**
|
|
402
|
+
* Round a base-asset size to the nearest valid lot size for this market,
|
|
403
|
+
* as a scaled `bigint` (`Fixed.fixedOneN9`).
|
|
404
|
+
*
|
|
405
|
+
* @param inputs.size - Raw size in base units.
|
|
406
|
+
* @param inputs.floor - If `true`, always round down.
|
|
407
|
+
* @param inputs.ceil - If `true`, always round up.
|
|
408
|
+
*
|
|
409
|
+
* @returns Size scaled by `1e9` and snapped to valid lot as a `bigint`.
|
|
410
|
+
*/
|
|
86
411
|
roundToValidSizeBigInt: (inputs: {
|
|
87
412
|
size: number;
|
|
88
413
|
floor?: boolean;
|
|
89
414
|
ceil?: boolean;
|
|
90
415
|
}) => bigint;
|
|
416
|
+
/**
|
|
417
|
+
* Construct an "empty" position object for this market.
|
|
418
|
+
*
|
|
419
|
+
* This is useful for UI and calculations when an account has no open
|
|
420
|
+
* position but you still want a full {@link PerpetualsPosition}-shaped
|
|
421
|
+
* object with defaulted values.
|
|
422
|
+
*
|
|
423
|
+
* @returns A zeroed-out {@link PerpetualsPosition} for `this.marketId`.
|
|
424
|
+
*/
|
|
91
425
|
emptyPosition: () => PerpetualsPosition;
|
|
92
426
|
}
|
|
93
427
|
//# sourceMappingURL=perpetualsMarket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpetualsMarket.d.ts","sourceRoot":"","sources":["../../../src/packages/perpetuals/perpetualsMarket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAIN,QAAQ,EAKR,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EAGnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAElB,SAAS,EAET,oBAAoB,EAKpB,qBAAqB,EACrB,gCAAgC,EAChC,YAAY,EACZ,UAAU,EAEV,yBAAyB,EAEzB,yCAAyC,EAEzC,0CAA0C,EAC1C,mBAAmB,EACnB,MAAM,aAAa,CAAC;AAIrB,qBAAa,gBAAiB,SAAQ,MAAM;
|
|
1
|
+
{"version":3,"file":"perpetualsMarket.d.ts","sourceRoot":"","sources":["../../../src/packages/perpetuals/perpetualsMarket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAIN,QAAQ,EAKR,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EAGnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAElB,SAAS,E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