@0xmonaco/types 0.8.7-develop.0e951a5 → 0.8.7-develop.0f12336
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/README.md +5 -3
- package/dist/api/index.d.ts +7 -0
- package/dist/applications/index.d.ts +47 -5
- package/dist/applications/index.js +2 -1
- package/dist/applications/requests.d.ts +78 -0
- package/dist/applications/requests.js +7 -0
- package/dist/applications/responses.d.ts +213 -2
- package/dist/applications/responses.js +3 -1
- package/dist/auth/index.d.ts +6 -12
- package/dist/auth/index.js +2 -2
- package/dist/auth/responses.d.ts +2 -12
- package/dist/contracts/balances.d.ts +1 -1
- package/dist/delegated-agents/index.d.ts +35 -18
- package/dist/faucet/index.d.ts +54 -0
- package/dist/faucet/index.js +10 -0
- package/dist/fees/index.d.ts +4 -4
- package/dist/fees/responses.d.ts +17 -17
- package/dist/fees/responses.js +20 -20
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/margin-accounts/index.d.ts +91 -55
- package/dist/market/index.d.ts +214 -95
- package/dist/positions/index.d.ts +67 -44
- package/dist/profile/index.d.ts +156 -70
- package/dist/sdk/index.d.ts +24 -3
- package/dist/sub-accounts/index.d.ts +146 -0
- package/dist/sub-accounts/index.js +9 -0
- package/dist/trading/index.d.ts +8 -8
- package/dist/trading/orders.d.ts +20 -20
- package/dist/trading/responses.d.ts +81 -100
- package/dist/validation/margin-accounts.d.ts +53 -13
- package/dist/validation/margin-accounts.js +38 -14
- package/dist/validation/market.d.ts +1 -1
- package/dist/validation/market.js +1 -1
- package/dist/validation/positions.d.ts +11 -7
- package/dist/validation/positions.js +10 -6
- package/dist/validation/profile.d.ts +13 -6
- package/dist/validation/profile.js +13 -6
- package/dist/validation/trading.d.ts +17 -42
- package/dist/validation/trading.js +51 -42
- package/dist/validation/vault.d.ts +8 -0
- package/dist/validation/vault.js +3 -0
- package/dist/vault/index.d.ts +46 -13
- package/dist/vault/responses.d.ts +50 -12
- package/dist/websocket/events/balance-events.d.ts +2 -1
- package/dist/websocket/events/movement-events.d.ts +2 -1
- package/dist/whitelist/index.d.ts +44 -0
- package/dist/whitelist/index.js +10 -0
- package/dist/wire/assert.d.ts +54 -0
- package/dist/wire/assert.js +0 -0
- package/dist/wire/audit.d.ts +47 -0
- package/dist/wire/audit.js +43 -0
- package/dist/wire/coverage.d.ts +1 -0
- package/dist/wire/coverage.js +0 -0
- package/dist/wire/index.d.ts +21 -0
- package/dist/wire/index.js +2 -0
- package/dist/wire/operations.d.ts +15 -0
- package/dist/wire/operations.js +101 -0
- package/dist/wire/schema.d.ts +8930 -0
- package/dist/wire/schema.js +4 -0
- package/dist/withdrawals/index.d.ts +114 -0
- package/dist/withdrawals/index.js +0 -0
- package/package.json +6 -2
package/dist/market/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Types for market data operations including trading pair metadata and OHLCV data.
|
|
5
5
|
*/
|
|
6
|
+
import type { Address } from "viem";
|
|
6
7
|
import type { BaseAPI } from "../api";
|
|
8
|
+
import type { TradingMode } from "../trading";
|
|
7
9
|
/**
|
|
8
10
|
* Trading pair metadata
|
|
9
11
|
*/
|
|
@@ -13,39 +15,45 @@ export interface TradingPair {
|
|
|
13
15
|
/** Trading pair symbol e.g. BTC/USDC */
|
|
14
16
|
symbol: string;
|
|
15
17
|
/** Base token symbol */
|
|
16
|
-
|
|
18
|
+
baseToken: string;
|
|
17
19
|
/** Quote token symbol */
|
|
18
|
-
|
|
20
|
+
quoteToken: string;
|
|
19
21
|
/** Base asset ID (UUID) */
|
|
20
|
-
|
|
22
|
+
baseAssetId: string;
|
|
21
23
|
/** Quote asset ID (UUID) */
|
|
22
|
-
|
|
24
|
+
quoteAssetId: string;
|
|
23
25
|
/** Base token contract address */
|
|
24
|
-
|
|
26
|
+
baseTokenContract: Address;
|
|
25
27
|
/** Quote token contract address */
|
|
26
|
-
|
|
28
|
+
quoteTokenContract: Address;
|
|
27
29
|
/** Base token decimals */
|
|
28
|
-
|
|
30
|
+
baseDecimals: number;
|
|
29
31
|
/** Base token icon URL */
|
|
30
|
-
|
|
32
|
+
baseIconUrl: string;
|
|
31
33
|
/** Quote token decimals */
|
|
32
|
-
|
|
34
|
+
quoteDecimals: number;
|
|
33
35
|
/** Quote token icon URL */
|
|
34
|
-
|
|
35
|
-
/** Market type (
|
|
36
|
-
|
|
36
|
+
quoteIconUrl: string;
|
|
37
|
+
/** Market type (SPOT or MARGIN) */
|
|
38
|
+
marketType: TradingMode;
|
|
39
|
+
/** Asset-class category: crypto, equities, commodities, or fx */
|
|
40
|
+
category: string;
|
|
37
41
|
/** Whether the market is active */
|
|
38
|
-
|
|
42
|
+
isActive: boolean;
|
|
39
43
|
/** Maker fee in basis points */
|
|
40
|
-
|
|
44
|
+
makerFeeBps: number;
|
|
41
45
|
/** Taker fee in basis points */
|
|
42
|
-
|
|
46
|
+
takerFeeBps: number;
|
|
43
47
|
/** Minimum order size */
|
|
44
|
-
|
|
48
|
+
minOrderSize: string;
|
|
45
49
|
/** Maximum order size */
|
|
46
|
-
|
|
50
|
+
maxOrderSize: string;
|
|
47
51
|
/** Tick size for price increments */
|
|
48
|
-
|
|
52
|
+
tickSize: string;
|
|
53
|
+
/** Minimum supported leverage for margin markets (optional, margin only) */
|
|
54
|
+
minLeverage?: string | null;
|
|
55
|
+
/** Maximum supported leverage for margin markets (optional, margin only) */
|
|
56
|
+
maxLeverage?: string | null;
|
|
49
57
|
}
|
|
50
58
|
/**
|
|
51
59
|
* OHLCV candlestick data point (matches API response format)
|
|
@@ -113,31 +121,106 @@ export interface GetTradingPairsParams {
|
|
|
113
121
|
/** Page number (starts from 1) */
|
|
114
122
|
page?: number;
|
|
115
123
|
/** Number of items per page (max 100) */
|
|
116
|
-
|
|
124
|
+
pageSize?: number;
|
|
117
125
|
/** Filter by market type (SPOT, MARGIN) */
|
|
118
|
-
|
|
126
|
+
marketType?: TradingMode;
|
|
119
127
|
/** Filter by base token symbol */
|
|
120
|
-
|
|
128
|
+
baseToken?: string;
|
|
121
129
|
/** Filter by quote token symbol */
|
|
122
|
-
|
|
130
|
+
quoteToken?: string;
|
|
123
131
|
/** Filter by active status */
|
|
124
|
-
|
|
132
|
+
isActive?: boolean;
|
|
133
|
+
/** Filter by asset-class category (crypto, equities, commodities, fx) */
|
|
134
|
+
category?: string;
|
|
125
135
|
}
|
|
126
136
|
/**
|
|
127
137
|
* Response for listing trading pairs with pagination
|
|
128
138
|
*/
|
|
129
139
|
export interface GetTradingPairsResponse {
|
|
130
|
-
|
|
140
|
+
tradingPairs: TradingPair[];
|
|
131
141
|
page: number;
|
|
132
|
-
|
|
142
|
+
pageSize: number;
|
|
133
143
|
total: number;
|
|
134
|
-
|
|
144
|
+
totalPages: number;
|
|
135
145
|
}
|
|
136
146
|
/**
|
|
137
147
|
* Response for a single trading pair
|
|
138
148
|
*/
|
|
139
149
|
export interface GetTradingPairResponse {
|
|
140
|
-
|
|
150
|
+
tradingPair: TradingPair;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Query parameters for the market screener
|
|
154
|
+
*/
|
|
155
|
+
export interface GetScreenerParams {
|
|
156
|
+
/** Page number (min 1, default 1) */
|
|
157
|
+
page?: number;
|
|
158
|
+
/** Items per page (min 1, max 100, default 50) */
|
|
159
|
+
pageSize?: number;
|
|
160
|
+
/** Filter by market type: SPOT or MARGIN */
|
|
161
|
+
marketType?: TradingMode;
|
|
162
|
+
/** Filter by active status */
|
|
163
|
+
isActive?: boolean;
|
|
164
|
+
/** Filter by asset-class category (crypto, equities, commodities, fx) */
|
|
165
|
+
category?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* One UTC-day bucket in a pair's 7-day screener snapshot
|
|
169
|
+
*/
|
|
170
|
+
export interface ScreenerSnapshotPoint {
|
|
171
|
+
/** UTC day boundary (ms since epoch, as string) */
|
|
172
|
+
bucketStart: string;
|
|
173
|
+
/** Quote-token volume for the day */
|
|
174
|
+
quoteVolume: string;
|
|
175
|
+
/** Percent price change (close - open) / open * 100 for the day */
|
|
176
|
+
priceChangePercent: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Per-pair screener row. Window fields are null when there is insufficient history.
|
|
180
|
+
*/
|
|
181
|
+
export interface ScreenerItem {
|
|
182
|
+
/** Trading pair UUID */
|
|
183
|
+
tradingPairId: string;
|
|
184
|
+
/** Trading pair symbol (e.g. "BTC/USDC") */
|
|
185
|
+
symbol: string;
|
|
186
|
+
/** Base token icon URL */
|
|
187
|
+
baseIconUrl: string;
|
|
188
|
+
/** Quote token icon URL */
|
|
189
|
+
quoteIconUrl: string;
|
|
190
|
+
/** Most recent close price (null if no trades yet) */
|
|
191
|
+
lastPrice: string | null;
|
|
192
|
+
/** Timestamp of the last candle (ms since epoch, as string; null if no trades yet) */
|
|
193
|
+
lastPriceTimestamp: string | null;
|
|
194
|
+
/** Quote-token volume in the last 1 hour (null if <1h history) */
|
|
195
|
+
quoteVolume1h: string | null;
|
|
196
|
+
/** Quote-token volume in the last 24 hours (null if <24h history) */
|
|
197
|
+
quoteVolume24h: string | null;
|
|
198
|
+
/** Quote-token volume in the last 7 days (null if <7d history) */
|
|
199
|
+
quoteVolume7d: string | null;
|
|
200
|
+
/** Percent price change over the last 1 hour (null if <1h history) */
|
|
201
|
+
priceChangePercent1h: string | null;
|
|
202
|
+
/** Percent price change over the last 24 hours (null if <24h history) */
|
|
203
|
+
priceChangePercent24h: string | null;
|
|
204
|
+
/** Percent price change over the last 7 days (null if <7d history) */
|
|
205
|
+
priceChangePercent7d: string | null;
|
|
206
|
+
/** Up to 7 UTC-day buckets (oldest first); empty when <1 day of history */
|
|
207
|
+
snapshot7d: ScreenerSnapshotPoint[];
|
|
208
|
+
/** Asset-class category: crypto, equities, commodities, or fx */
|
|
209
|
+
category: string;
|
|
210
|
+
/** Life-to-date cumulative quote-token volume since inception ("0" if no trades yet) */
|
|
211
|
+
totalQuoteVolumeLtd: string;
|
|
212
|
+
/** Life-to-date cumulative number of trades since inception (0 if no trades yet) */
|
|
213
|
+
totalTradeCountLtd: number;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Paginated screener response, sorted by quoteVolume24h desc (nulls last)
|
|
217
|
+
*/
|
|
218
|
+
export interface GetScreenerResponse {
|
|
219
|
+
items: ScreenerItem[];
|
|
220
|
+
page: number;
|
|
221
|
+
pageSize: number;
|
|
222
|
+
total: number;
|
|
223
|
+
totalPages: number;
|
|
141
224
|
}
|
|
142
225
|
/**
|
|
143
226
|
* API response wrapper for single trading pair
|
|
@@ -152,117 +235,131 @@ export interface MarketMetadata {
|
|
|
152
235
|
/** Trading pair symbol (e.g., "BTC/USDC") */
|
|
153
236
|
symbol: string;
|
|
154
237
|
/** Base token icon URL */
|
|
155
|
-
|
|
238
|
+
baseIconUrl: string;
|
|
156
239
|
/** Quote token icon URL */
|
|
157
|
-
|
|
240
|
+
quoteIconUrl: string;
|
|
158
241
|
/** Current price (8 decimal precision, null if no trades yet) */
|
|
159
|
-
|
|
242
|
+
lastPrice: string | null;
|
|
160
243
|
/** Unix timestamp (ms) of latest price (null if no trades yet) */
|
|
161
|
-
|
|
244
|
+
lastPriceTimestamp: number | null;
|
|
162
245
|
/** 24h high price (null if <24h data) */
|
|
163
|
-
|
|
246
|
+
high24h: string | null;
|
|
164
247
|
/** 24h low price (null if <24h data) */
|
|
165
|
-
|
|
248
|
+
low24h: string | null;
|
|
166
249
|
/** 24h volume in base asset (null if <24h data) */
|
|
167
|
-
|
|
250
|
+
volume24h: string | null;
|
|
168
251
|
/** Absolute price change in 24h (null if <24h data) */
|
|
169
|
-
|
|
252
|
+
priceChange24h: string | null;
|
|
170
253
|
/** Percentage price change in 24h (2 decimals, null if <24h data) */
|
|
171
|
-
|
|
254
|
+
priceChangePercent24h: string | null;
|
|
172
255
|
/** Unix timestamp (ms) when market started trading (null if not available) */
|
|
173
|
-
|
|
256
|
+
marketInitializationTimestamp: number | null;
|
|
257
|
+
/** Life-to-date cumulative base-token volume since inception ("0" if no trades yet) */
|
|
258
|
+
totalBaseVolumeLtd: string;
|
|
259
|
+
/** Life-to-date cumulative quote-token volume since inception ("0" if no trades yet) */
|
|
260
|
+
totalQuoteVolumeLtd: string;
|
|
261
|
+
/** Life-to-date cumulative number of trades since inception (0 if no trades yet) */
|
|
262
|
+
totalTradeCountLtd: number;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Exchange-wide life-to-date cumulative statistics across all trading pairs.
|
|
266
|
+
*/
|
|
267
|
+
export interface MarketStats {
|
|
268
|
+
/** Life-to-date cumulative quote-token (notional) volume summed across all pairs */
|
|
269
|
+
totalQuoteVolumeLtd: string;
|
|
270
|
+
/** Life-to-date cumulative number of trades summed across all pairs */
|
|
271
|
+
totalTradeCountLtd: number;
|
|
174
272
|
}
|
|
175
273
|
export interface RiskTier {
|
|
176
274
|
notional_floor: string;
|
|
177
275
|
notional_cap?: string;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
276
|
+
initialMarginRatio: string;
|
|
277
|
+
maintenanceMarginRatio: string;
|
|
278
|
+
maxLeverage: string;
|
|
181
279
|
}
|
|
182
280
|
export interface PerpMarketConfig {
|
|
183
|
-
|
|
281
|
+
tradingPairId: string;
|
|
184
282
|
symbol: string;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
283
|
+
minLeverage: string;
|
|
284
|
+
maxLeverage: string;
|
|
285
|
+
initialMarginRatio: string;
|
|
286
|
+
maintenanceMarginRatio: string;
|
|
287
|
+
fundingIntervalSeconds: number;
|
|
288
|
+
liquidationFeeBps?: string;
|
|
289
|
+
riskTiers: RiskTier[];
|
|
290
|
+
updatedAt: string;
|
|
193
291
|
}
|
|
194
292
|
export interface PerpMarketSummary {
|
|
195
|
-
|
|
293
|
+
tradingPairId: string;
|
|
196
294
|
symbol: string;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
295
|
+
lastPrice: string;
|
|
296
|
+
markPrice: string;
|
|
297
|
+
indexPrice: string;
|
|
298
|
+
high24h?: string;
|
|
299
|
+
low24h?: string;
|
|
300
|
+
volume24h?: string;
|
|
301
|
+
priceChange24h?: string;
|
|
302
|
+
priceChangePercent24h?: string;
|
|
303
|
+
openInterest: string;
|
|
304
|
+
currentFundingRate?: string;
|
|
305
|
+
estimatedNextFundingRate?: string;
|
|
306
|
+
nextFundingTime?: string;
|
|
307
|
+
marketStatus: string;
|
|
308
|
+
marketRegime: string;
|
|
309
|
+
updatedAt: string;
|
|
212
310
|
}
|
|
213
311
|
export interface MarkPrice {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
312
|
+
tradingPairId: string;
|
|
313
|
+
markPrice: string;
|
|
314
|
+
oracleProvider: string;
|
|
315
|
+
oracleEpoch?: string;
|
|
316
|
+
updatedAt: string;
|
|
219
317
|
regime: string;
|
|
220
318
|
}
|
|
221
319
|
export interface IndexComponent {
|
|
222
320
|
provider: string;
|
|
223
321
|
price: string;
|
|
224
322
|
weight?: string;
|
|
225
|
-
|
|
323
|
+
updatedAt?: string;
|
|
226
324
|
}
|
|
227
325
|
export interface IndexPrice {
|
|
228
|
-
|
|
229
|
-
|
|
326
|
+
tradingPairId: string;
|
|
327
|
+
indexPrice: string;
|
|
230
328
|
components: IndexComponent[];
|
|
231
|
-
|
|
329
|
+
updatedAt: string;
|
|
232
330
|
}
|
|
233
331
|
export interface FundingState {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
332
|
+
tradingPairId: string;
|
|
333
|
+
currentFundingRate: string;
|
|
334
|
+
estimatedNextFundingRate?: string;
|
|
335
|
+
nextFundingTime: string;
|
|
336
|
+
fundingIntervalSeconds: number;
|
|
337
|
+
lastFundingTime?: string;
|
|
338
|
+
updatedAt: string;
|
|
241
339
|
}
|
|
242
340
|
export interface FundingRecord {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
cumulative_funding_per_unit?: string;
|
|
341
|
+
tradingPairId: string;
|
|
342
|
+
fundingRate: string;
|
|
343
|
+
cumulativeFundingPerUnit?: string;
|
|
247
344
|
}
|
|
248
345
|
export interface ListFundingHistoryParams {
|
|
249
|
-
|
|
250
|
-
|
|
346
|
+
startTime?: string;
|
|
347
|
+
endTime?: string;
|
|
251
348
|
page?: number;
|
|
252
|
-
|
|
349
|
+
pageSize?: number;
|
|
253
350
|
}
|
|
254
351
|
export interface ListFundingHistoryResponse {
|
|
255
352
|
records: FundingRecord[];
|
|
256
353
|
total: number;
|
|
257
354
|
page: number;
|
|
258
|
-
|
|
355
|
+
pageSize: number;
|
|
259
356
|
}
|
|
260
357
|
export interface OpenInterest {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
358
|
+
tradingPairId: string;
|
|
359
|
+
openInterest?: string;
|
|
360
|
+
openInterestBase: string;
|
|
361
|
+
openInterestNotional: string;
|
|
362
|
+
updatedAt: string;
|
|
266
363
|
}
|
|
267
364
|
/**
|
|
268
365
|
* Market API interface.
|
|
@@ -275,12 +372,34 @@ export interface MarketAPI extends BaseAPI {
|
|
|
275
372
|
* @returns Promise resolving to paginated response with trading pairs
|
|
276
373
|
*/
|
|
277
374
|
getPaginatedTradingPairs(params?: GetTradingPairsParams): Promise<GetTradingPairsResponse>;
|
|
375
|
+
/**
|
|
376
|
+
* Fetch a single trading pair by its UUID.
|
|
377
|
+
* @param tradingPairId - Trading pair UUID
|
|
378
|
+
* @returns Promise resolving to the trading pair
|
|
379
|
+
* @throws {APIError} If the pair is not found
|
|
380
|
+
*/
|
|
381
|
+
getTradingPair(tradingPairId: string): Promise<TradingPair>;
|
|
278
382
|
/**
|
|
279
383
|
* Fetch metadata for a single trading pair by its symbol (e.g. BTC-USDC).
|
|
280
384
|
* @param symbol - Trading pair symbol
|
|
385
|
+
* @param marketType - Optional market type filter (e.g. "SPOT", "MARGIN") to
|
|
386
|
+
* disambiguate a symbol that exists in more than one market
|
|
281
387
|
* @returns Promise resolving to trading pair or undefined if not found
|
|
282
388
|
*/
|
|
283
|
-
getTradingPairBySymbol(symbol: string): Promise<TradingPair | undefined>;
|
|
389
|
+
getTradingPairBySymbol(symbol: string, marketType?: TradingMode): Promise<TradingPair | undefined>;
|
|
390
|
+
/**
|
|
391
|
+
* Fetch the paginated market screener: per-pair price/volume/change windows
|
|
392
|
+
* (1h, 24h, 7d) plus a 7-day daily snapshot, sorted by 24h quote volume.
|
|
393
|
+
* @param params - Optional pagination and filter parameters
|
|
394
|
+
* @returns Promise resolving to the paginated screener response
|
|
395
|
+
*/
|
|
396
|
+
getScreener(params?: GetScreenerParams): Promise<GetScreenerResponse>;
|
|
397
|
+
/**
|
|
398
|
+
* Fetch exchange-wide life-to-date cumulative statistics across all trading
|
|
399
|
+
* pairs: total quote-token (notional) volume and total number of trades.
|
|
400
|
+
* @returns Promise resolving to the global market stats
|
|
401
|
+
*/
|
|
402
|
+
getMarketStats(): Promise<MarketStats>;
|
|
284
403
|
/**
|
|
285
404
|
* Fetch historical candlestick data for a trading pair.
|
|
286
405
|
*
|
|
@@ -3,36 +3,37 @@ import type { OrderType, PositionSide, TimeInForce } from "../trading";
|
|
|
3
3
|
export type PositionStatus = "OPEN" | "CLOSED" | "LIQUIDATING";
|
|
4
4
|
export type ClosePositionType = "MARKET" | "LIMIT" | "IOC";
|
|
5
5
|
export interface Position {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
positionId: string;
|
|
7
|
+
marginAccountId: string;
|
|
8
|
+
riskBucketId?: string;
|
|
9
|
+
tradingPairId: string;
|
|
9
10
|
side: PositionSide;
|
|
10
11
|
size: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
entryPrice: string;
|
|
13
|
+
markPrice: string;
|
|
14
|
+
indexPrice?: string;
|
|
15
|
+
unrealizedPnl: string;
|
|
16
|
+
realizedPnl: string;
|
|
17
|
+
isolatedMargin: string;
|
|
17
18
|
leverage?: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
maintenanceMarginRequired: string;
|
|
20
|
+
initialMarginRequired?: string;
|
|
21
|
+
liquidationPrice: string;
|
|
21
22
|
status: PositionStatus;
|
|
22
|
-
|
|
23
|
+
updatedAt: string;
|
|
23
24
|
}
|
|
24
25
|
export interface ListPositionsParams {
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
marginAccountId?: string;
|
|
27
|
+
tradingPairId?: string;
|
|
27
28
|
status?: PositionStatus;
|
|
28
29
|
page?: number;
|
|
29
|
-
|
|
30
|
+
pageSize?: number;
|
|
30
31
|
}
|
|
31
32
|
export interface ListPositionsResponse {
|
|
32
33
|
positions: Position[];
|
|
33
34
|
total: number;
|
|
34
35
|
page: number;
|
|
35
|
-
|
|
36
|
+
pageSize: number;
|
|
36
37
|
}
|
|
37
38
|
export type GetPositionResponse = Position;
|
|
38
39
|
export interface ClosePositionRequest {
|
|
@@ -42,21 +43,42 @@ export interface ClosePositionRequest {
|
|
|
42
43
|
quantity?: string;
|
|
43
44
|
}
|
|
44
45
|
export interface ClosePositionResponse {
|
|
45
|
-
|
|
46
|
+
closeOrderId: string;
|
|
46
47
|
status: string;
|
|
47
48
|
message: string;
|
|
48
|
-
|
|
49
|
+
submittedQuantity: string;
|
|
50
|
+
}
|
|
51
|
+
export interface BatchCloseAllRequest {
|
|
52
|
+
tradingPairId?: string;
|
|
53
|
+
slippageToleranceBps?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface BatchCloseError {
|
|
56
|
+
code: string;
|
|
57
|
+
message: string;
|
|
58
|
+
}
|
|
59
|
+
export interface BatchCloseResult {
|
|
60
|
+
positionId: string;
|
|
61
|
+
closeOrderId?: string;
|
|
62
|
+
status?: string;
|
|
63
|
+
submittedQuantity?: string;
|
|
64
|
+
error?: BatchCloseError;
|
|
65
|
+
}
|
|
66
|
+
export interface BatchCloseAllResponse {
|
|
67
|
+
totalRequested: number;
|
|
68
|
+
totalClosed: number;
|
|
69
|
+
totalFailed: number;
|
|
70
|
+
results: BatchCloseResult[];
|
|
49
71
|
}
|
|
50
72
|
export interface PositionRisk {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
positionId: string;
|
|
74
|
+
markPrice: string;
|
|
75
|
+
indexPrice?: string;
|
|
76
|
+
unrealizedPnl: string;
|
|
77
|
+
liquidationPrice: string;
|
|
78
|
+
marginRatio: string;
|
|
79
|
+
maintenanceMarginRequired: string;
|
|
80
|
+
initialMarginRequired?: string;
|
|
81
|
+
updatedAt: string;
|
|
60
82
|
}
|
|
61
83
|
export interface AddPositionMarginRequest {
|
|
62
84
|
amount: string;
|
|
@@ -66,9 +88,9 @@ export interface ReducePositionMarginRequest {
|
|
|
66
88
|
amount: string;
|
|
67
89
|
}
|
|
68
90
|
export interface PositionMarginResponse {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
positionId: string;
|
|
92
|
+
marginAccountId: string;
|
|
93
|
+
newIsolatedMargin: string;
|
|
72
94
|
status: string;
|
|
73
95
|
message: string;
|
|
74
96
|
}
|
|
@@ -86,40 +108,41 @@ export interface AttachPositionTpSlRequest {
|
|
|
86
108
|
stopLoss?: TpSlLeg;
|
|
87
109
|
}
|
|
88
110
|
export interface AttachPositionTpSlResponse {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
111
|
+
positionId: string;
|
|
112
|
+
takeProfitOrderId?: string;
|
|
113
|
+
stopLossOrderId?: string;
|
|
92
114
|
status: "SUCCESS" | "FAILED";
|
|
93
115
|
message: string;
|
|
94
116
|
}
|
|
95
117
|
export interface ListPositionHistoryParams {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
118
|
+
positionId?: string;
|
|
119
|
+
marginAccountId?: string;
|
|
120
|
+
tradingPairId?: string;
|
|
99
121
|
page?: number;
|
|
100
|
-
|
|
122
|
+
pageSize?: number;
|
|
101
123
|
}
|
|
102
124
|
export interface PositionHistoryEvent {
|
|
103
125
|
event_id: string;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
positionId?: string;
|
|
127
|
+
marginAccountId?: string;
|
|
128
|
+
tradingPairId?: string;
|
|
129
|
+
eventType: string;
|
|
108
130
|
quantity?: string;
|
|
109
131
|
price?: string;
|
|
110
|
-
|
|
132
|
+
realizedPnl?: string;
|
|
111
133
|
timestamp: string;
|
|
112
134
|
}
|
|
113
135
|
export interface ListPositionHistoryResponse {
|
|
114
136
|
events: PositionHistoryEvent[];
|
|
115
137
|
total: number;
|
|
116
138
|
page: number;
|
|
117
|
-
|
|
139
|
+
pageSize: number;
|
|
118
140
|
}
|
|
119
141
|
export interface PositionsAPI extends BaseAPI {
|
|
120
142
|
listPositions(params?: ListPositionsParams): Promise<ListPositionsResponse>;
|
|
121
143
|
getPosition(positionId: string): Promise<GetPositionResponse>;
|
|
122
144
|
closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
|
|
145
|
+
batchCloseAllPositions(request?: BatchCloseAllRequest): Promise<BatchCloseAllResponse>;
|
|
123
146
|
getPositionRisk(positionId: string): Promise<PositionRisk>;
|
|
124
147
|
addPositionMargin(positionId: string, request: AddPositionMarginRequest): Promise<PositionMarginResponse>;
|
|
125
148
|
reducePositionMargin(positionId: string, request: ReducePositionMarginRequest): Promise<PositionMarginResponse>;
|