@0xmonaco/types 0.6.3 → 0.7.0

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/index.d.ts CHANGED
@@ -9,7 +9,9 @@ export * from "./applications";
9
9
  export * from "./auth";
10
10
  export * from "./contracts";
11
11
  export * from "./fees";
12
+ export * from "./margin-accounts";
12
13
  export * from "./market";
14
+ export * from "./positions";
13
15
  export * from "./profile";
14
16
  export * from "./sdk";
15
17
  export * from "./trading";
package/dist/index.js CHANGED
@@ -10,7 +10,9 @@ export * from "./applications";
10
10
  export * from "./auth";
11
11
  export * from "./contracts";
12
12
  export * from "./fees";
13
+ export * from "./margin-accounts";
13
14
  export * from "./market";
15
+ export * from "./positions";
14
16
  export * from "./profile";
15
17
  export * from "./sdk";
16
18
  export * from "./trading";
@@ -0,0 +1,106 @@
1
+ import type { BaseAPI } from "../api";
2
+ import type { OrderSide, OrderType, PositionSide } from "../trading";
3
+ export interface MarginAccountSummary {
4
+ margin_account_id: string;
5
+ account_state: string;
6
+ equity: string;
7
+ initial_margin_required: string;
8
+ maintenance_margin_required: string;
9
+ free_collateral: string;
10
+ withdrawable_collateral: string;
11
+ total_position_notional: string;
12
+ unrealized_pnl: string;
13
+ realized_pnl: string;
14
+ updated_at: string;
15
+ }
16
+ export interface ListMarginAccountsParams {
17
+ page?: number;
18
+ page_size?: number;
19
+ state?: string;
20
+ }
21
+ export interface ListMarginAccountsResponse {
22
+ accounts: MarginAccountSummary[];
23
+ total: number;
24
+ page: number;
25
+ page_size: number;
26
+ }
27
+ export interface CreateMarginAccountRequest {
28
+ label?: string;
29
+ collateralAsset?: string;
30
+ }
31
+ export interface CreateMarginAccountResponse {
32
+ margin_account_id: string;
33
+ account_state: string;
34
+ collateral_asset: string;
35
+ created_at: string;
36
+ }
37
+ export interface GetAvailableCollateralParams {
38
+ asset?: string;
39
+ }
40
+ export interface GetAvailableCollateralResponse {
41
+ asset: string;
42
+ wallet_available: string;
43
+ wallet_locked: string;
44
+ margin_transferable?: string;
45
+ }
46
+ export interface TransferCollateralRequest {
47
+ asset: string;
48
+ amount: string;
49
+ }
50
+ export interface TransferCollateralResponse {
51
+ movement_id: string;
52
+ margin_account_id: string;
53
+ asset: string;
54
+ amount: string;
55
+ status: string;
56
+ new_equity: string;
57
+ }
58
+ export interface GetMarginAccountMovementsParams {
59
+ movement_type?: string;
60
+ page?: number;
61
+ page_size?: number;
62
+ }
63
+ export interface MarginAccountMovement {
64
+ movement_id: string;
65
+ margin_account_id: string;
66
+ movement_type: string;
67
+ asset: string;
68
+ amount: string;
69
+ created_at: string;
70
+ }
71
+ export interface GetMarginAccountMovementsResponse {
72
+ movements: MarginAccountMovement[];
73
+ total: number;
74
+ page: number;
75
+ page_size: number;
76
+ }
77
+ export interface SimulateOrderRiskRequest {
78
+ tradingPairId: string;
79
+ side: OrderSide;
80
+ positionSide: PositionSide;
81
+ orderType: OrderType;
82
+ price?: string;
83
+ quantity: string;
84
+ leverage: string;
85
+ reduceOnly?: boolean;
86
+ }
87
+ export interface SimulateOrderRiskResponse {
88
+ accepted: boolean;
89
+ reject_reason?: string;
90
+ equity_after: string;
91
+ initial_margin_required_after: string;
92
+ maintenance_margin_required_after: string;
93
+ free_collateral_after: string;
94
+ estimated_fee?: string;
95
+ estimated_liquidation_price?: string;
96
+ }
97
+ export interface MarginAccountsAPI extends BaseAPI {
98
+ listMarginAccounts(params?: ListMarginAccountsParams): Promise<ListMarginAccountsResponse>;
99
+ createMarginAccount(request?: CreateMarginAccountRequest): Promise<CreateMarginAccountResponse>;
100
+ getMarginAccountSummary(marginAccountId: string): Promise<MarginAccountSummary>;
101
+ getAvailableCollateral(params?: GetAvailableCollateralParams): Promise<GetAvailableCollateralResponse>;
102
+ transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
103
+ transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
104
+ getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
105
+ simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
106
+ }
File without changes
@@ -113,7 +113,7 @@ export interface GetTradingPairsParams {
113
113
  /** Page number (starts from 1) */
114
114
  page?: number;
115
115
  /** Number of items per page (max 100) */
116
- limit?: number;
116
+ page_size?: number;
117
117
  /** Filter by market type (SPOT, MARGIN) */
118
118
  market_type?: string;
119
119
  /** Filter by base token symbol */
@@ -124,35 +124,26 @@ export interface GetTradingPairsParams {
124
124
  is_active?: boolean;
125
125
  }
126
126
  /**
127
- * Paginated response for trading pairs
127
+ * Response for listing trading pairs with pagination
128
128
  */
129
- export interface PaginatedTradingPairs {
130
- data: TradingPair[];
131
- limit: number;
129
+ export interface GetTradingPairsResponse {
130
+ trading_pairs: TradingPair[];
132
131
  page: number;
132
+ page_size: number;
133
133
  total: number;
134
134
  total_pages: number;
135
135
  }
136
136
  /**
137
- * API response wrapper for trading pairs
138
- */
139
- export interface GetTradingPairsResponse {
140
- data: PaginatedTradingPairs;
141
- success: boolean;
142
- }
143
- /**
144
- * API response wrapper for single trading pair
137
+ * Response for a single trading pair
145
138
  */
146
139
  export interface GetTradingPairResponse {
147
- data: TradingPair;
148
- success: boolean;
140
+ trading_pair: TradingPair;
149
141
  }
150
142
  /**
151
143
  * API response wrapper for single trading pair
152
144
  */
153
145
  export interface GetCandlestickResponse {
154
146
  data: Candlestick[];
155
- success: boolean;
156
147
  }
157
148
  /**
158
149
  * Market metadata with 24-hour statistics
@@ -181,6 +172,97 @@ export interface MarketMetadata {
181
172
  /** Unix timestamp (ms) when market started trading (null if not available) */
182
173
  market_initialization_timestamp: number | null;
183
174
  }
175
+ export interface RiskTier {
176
+ notional_floor: string;
177
+ notional_cap?: string;
178
+ initial_margin_ratio: string;
179
+ maintenance_margin_ratio: string;
180
+ max_leverage: string;
181
+ }
182
+ export interface PerpMarketConfig {
183
+ trading_pair_id: string;
184
+ symbol: string;
185
+ min_leverage: string;
186
+ max_leverage: string;
187
+ initial_margin_ratio: string;
188
+ maintenance_margin_ratio: string;
189
+ funding_interval_seconds: number;
190
+ liquidation_fee_bps?: string;
191
+ risk_tiers: RiskTier[];
192
+ updated_at: string;
193
+ }
194
+ export interface PerpMarketSummary {
195
+ trading_pair_id: string;
196
+ symbol: string;
197
+ last_price: string;
198
+ mark_price: string;
199
+ index_price: string;
200
+ high_24h?: string;
201
+ low_24h?: string;
202
+ volume_24h?: string;
203
+ price_change_24h?: string;
204
+ price_change_percent_24h?: string;
205
+ open_interest: string;
206
+ current_funding_rate?: string;
207
+ estimated_next_funding_rate?: string;
208
+ next_funding_time?: string;
209
+ market_status: string;
210
+ market_regime: string;
211
+ updated_at: string;
212
+ }
213
+ export interface MarkPrice {
214
+ trading_pair_id: string;
215
+ mark_price: string;
216
+ oracle_provider: string;
217
+ oracle_epoch?: string;
218
+ updated_at: string;
219
+ regime: string;
220
+ }
221
+ export interface IndexComponent {
222
+ provider: string;
223
+ price: string;
224
+ weight?: string;
225
+ updated_at?: string;
226
+ }
227
+ export interface IndexPrice {
228
+ trading_pair_id: string;
229
+ index_price: string;
230
+ components: IndexComponent[];
231
+ updated_at: string;
232
+ }
233
+ export interface FundingState {
234
+ trading_pair_id: string;
235
+ current_funding_rate: string;
236
+ estimated_next_funding_rate?: string;
237
+ next_funding_time: string;
238
+ funding_interval_seconds: number;
239
+ last_funding_time?: string;
240
+ updated_at: string;
241
+ }
242
+ export interface FundingRecord {
243
+ trading_pair_id: string;
244
+ funding_rate: string;
245
+ funding_time: string;
246
+ cumulative_funding_per_unit?: string;
247
+ }
248
+ export interface ListFundingHistoryParams {
249
+ start_time?: string;
250
+ end_time?: string;
251
+ page?: number;
252
+ page_size?: number;
253
+ }
254
+ export interface ListFundingHistoryResponse {
255
+ records: FundingRecord[];
256
+ total: number;
257
+ page: number;
258
+ page_size: number;
259
+ }
260
+ export interface OpenInterest {
261
+ trading_pair_id: string;
262
+ open_interest_base: string;
263
+ open_interest_notional: string;
264
+ updated_at: string;
265
+ }
184
266
  /**
185
267
  * Market API interface.
186
268
  * Provides methods for fetching market metadata and trading pair information.
@@ -220,4 +302,11 @@ export interface MarketAPI extends BaseAPI {
220
302
  * @throws {Error} If pair not found or no data available
221
303
  */
222
304
  getMarketMetadata(tradingPairId: string): Promise<MarketMetadata>;
305
+ getPerpMarketConfig(tradingPairId: string): Promise<PerpMarketConfig>;
306
+ getPerpMarketSummary(tradingPairId: string): Promise<PerpMarketSummary>;
307
+ getMarkPrice(tradingPairId: string): Promise<MarkPrice>;
308
+ getIndexPrice(tradingPairId: string): Promise<IndexPrice>;
309
+ getFundingState(tradingPairId: string): Promise<FundingState>;
310
+ listFundingHistory(tradingPairId: string, params?: ListFundingHistoryParams): Promise<ListFundingHistoryResponse>;
311
+ getOpenInterest(tradingPairId: string): Promise<OpenInterest>;
223
312
  }
@@ -0,0 +1,128 @@
1
+ import type { BaseAPI } from "../api";
2
+ import type { OrderType, PositionSide, TimeInForce } from "../trading";
3
+ export type PositionStatus = "OPEN" | "CLOSED" | "LIQUIDATING";
4
+ export type ClosePositionType = "MARKET" | "LIMIT" | "IOC";
5
+ export interface Position {
6
+ position_id: string;
7
+ margin_account_id: string;
8
+ trading_pair_id: string;
9
+ side: PositionSide;
10
+ size: string;
11
+ entry_price: string;
12
+ mark_price: string;
13
+ index_price?: string;
14
+ unrealized_pnl: string;
15
+ realized_pnl: string;
16
+ isolated_margin: string;
17
+ leverage?: string;
18
+ maintenance_margin_required: string;
19
+ initial_margin_required?: string;
20
+ liquidation_price: string;
21
+ status: PositionStatus;
22
+ updated_at: string;
23
+ }
24
+ export interface ListPositionsParams {
25
+ margin_account_id?: string;
26
+ trading_pair_id?: string;
27
+ status?: PositionStatus;
28
+ page?: number;
29
+ page_size?: number;
30
+ }
31
+ export interface ListPositionsResponse {
32
+ positions: Position[];
33
+ total: number;
34
+ page: number;
35
+ page_size: number;
36
+ }
37
+ export type GetPositionResponse = Position;
38
+ export interface ClosePositionRequest {
39
+ closeType: ClosePositionType;
40
+ limitPrice?: string;
41
+ slippageToleranceBps?: number;
42
+ quantity?: string;
43
+ }
44
+ export interface ClosePositionResponse {
45
+ close_order_id: string;
46
+ status: string;
47
+ message: string;
48
+ submitted_quantity: string;
49
+ }
50
+ export interface PositionRisk {
51
+ position_id: string;
52
+ mark_price: string;
53
+ index_price?: string;
54
+ unrealized_pnl: string;
55
+ liquidation_price: string;
56
+ margin_ratio: string;
57
+ maintenance_margin_required: string;
58
+ initial_margin_required?: string;
59
+ updated_at: string;
60
+ }
61
+ export interface AddPositionMarginRequest {
62
+ amount: string;
63
+ asset: string;
64
+ }
65
+ export interface ReducePositionMarginRequest {
66
+ amount: string;
67
+ }
68
+ export interface PositionMarginResponse {
69
+ position_id: string;
70
+ margin_account_id: string;
71
+ new_isolated_margin: string;
72
+ status: string;
73
+ message: string;
74
+ }
75
+ export interface TpSlLeg {
76
+ triggerPrice: string;
77
+ orderType: OrderType;
78
+ limitPrice?: string;
79
+ quantity?: string;
80
+ timeInForce?: Extract<TimeInForce, "GTC" | "IOC">;
81
+ slippageToleranceBps?: number;
82
+ expiresAt?: string;
83
+ }
84
+ export interface AttachPositionTpSlRequest {
85
+ takeProfit?: TpSlLeg;
86
+ stopLoss?: TpSlLeg;
87
+ }
88
+ export interface AttachPositionTpSlResponse {
89
+ position_id: string;
90
+ take_profit_order_id?: string;
91
+ stop_loss_order_id?: string;
92
+ status: "SUCCESS" | "FAILED";
93
+ message: string;
94
+ }
95
+ export interface ListPositionHistoryParams {
96
+ position_id?: string;
97
+ margin_account_id?: string;
98
+ trading_pair_id?: string;
99
+ page?: number;
100
+ page_size?: number;
101
+ }
102
+ export interface PositionHistoryEvent {
103
+ event_id: string;
104
+ position_id?: string;
105
+ margin_account_id?: string;
106
+ trading_pair_id?: string;
107
+ event_type: string;
108
+ quantity?: string;
109
+ price?: string;
110
+ realized_pnl?: string;
111
+ timestamp: string;
112
+ }
113
+ export interface ListPositionHistoryResponse {
114
+ events: PositionHistoryEvent[];
115
+ total: number;
116
+ page: number;
117
+ page_size: number;
118
+ }
119
+ export interface PositionsAPI extends BaseAPI {
120
+ listPositions(params?: ListPositionsParams): Promise<ListPositionsResponse>;
121
+ getPosition(positionId: string): Promise<GetPositionResponse>;
122
+ closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
123
+ getPositionRisk(positionId: string): Promise<PositionRisk>;
124
+ addPositionMargin(positionId: string, request: AddPositionMarginRequest): Promise<PositionMarginResponse>;
125
+ reducePositionMargin(positionId: string, request: ReducePositionMarginRequest): Promise<PositionMarginResponse>;
126
+ attachPositionTpSl(positionId: string, request: AttachPositionTpSlRequest): Promise<AttachPositionTpSlResponse>;
127
+ listPositionHistory(params?: ListPositionHistoryParams): Promise<ListPositionHistoryResponse>;
128
+ }
File without changes
@@ -94,7 +94,7 @@ export interface GetUserMovementsParams {
94
94
  /** Page number (starts from 1) */
95
95
  page?: number;
96
96
  /** Number of items per page (max 100) */
97
- limit?: number;
97
+ page_size?: number;
98
98
  /** Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE) */
99
99
  entry_type?: LedgerEntryType;
100
100
  /** Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD) */
@@ -106,10 +106,10 @@ export interface GetUserMovementsParams {
106
106
  * Query parameters for getting user balances
107
107
  */
108
108
  export interface GetUserBalancesParams {
109
- /** Number of items to return */
110
- limit?: number;
111
- /** Number of items to skip */
112
- offset?: number;
109
+ /** Page number (starts from 1) */
110
+ page?: number;
111
+ /** Number of items per page (max 100) */
112
+ page_size?: number;
113
113
  }
114
114
  /**
115
115
  * Response from getting user movements
@@ -126,9 +126,9 @@ export interface GetPaginatedUserMovementsResponse {
126
126
  /** Current page number */
127
127
  page: number;
128
128
  /** Items per page */
129
- limit: number;
129
+ page_size: number;
130
130
  /** Total number of movements in PostgreSQL */
131
- total_count: number;
131
+ total: number;
132
132
  /** Total number of pages */
133
133
  total_pages: number;
134
134
  }
@@ -139,11 +139,13 @@ export interface GetUserBalancesResponse {
139
139
  /** List of token balances for the user */
140
140
  balances: AccountBalance[];
141
141
  /** Total number of balances */
142
- total_count: number;
143
- /** Number of items returned */
144
- limit: number;
145
- /** Number of items skipped */
146
- offset: number;
142
+ total: number;
143
+ /** Items per page */
144
+ page_size: number;
145
+ /** Current page number */
146
+ page: number;
147
+ /** Total number of pages */
148
+ total_pages: number;
147
149
  }
148
150
  /**
149
151
  * Order information for recent orders.
@@ -152,8 +154,8 @@ export interface GetUserBalancesResponse {
152
154
  export interface ProfileOrder {
153
155
  /** Order identifier */
154
156
  id: string;
155
- /** Trading pair/market identifier (e.g., "ETH-USD") */
156
- trading_pair: string;
157
+ /** Trading pair symbol (e.g., "ETH-USD") */
158
+ symbol: string;
157
159
  /** Order side */
158
160
  side: OrderSide;
159
161
  /** Order type */
@@ -223,7 +225,7 @@ export interface GetUserTradesParams {
223
225
  /** Page number (starts from 1) */
224
226
  page?: number;
225
227
  /** Number of items per page (max 100) */
226
- limit?: number;
228
+ page_size?: number;
227
229
  /** Filter by trading pair ID (UUID) */
228
230
  trading_pair_id?: string;
229
231
  }
@@ -236,9 +238,9 @@ export interface GetUserTradesResponse {
236
238
  /** Current page number */
237
239
  page: number;
238
240
  /** Items per page */
239
- limit: number;
241
+ page_size: number;
240
242
  /** Total number of trades */
241
- total_count: number;
243
+ total: number;
242
244
  /** Total number of pages */
243
245
  total_pages: number;
244
246
  }
@@ -2,11 +2,13 @@ import type { PublicClient, TransactionReceipt, WalletClient } from "viem";
2
2
  import type { ApplicationsAPI } from "../applications";
3
3
  import type { AuthAPI, AuthState } from "../auth/index";
4
4
  import type { FeesAPI } from "../fees";
5
+ import type { MarginAccountsAPI } from "../margin-accounts";
5
6
  import type { Interval, MarketAPI } from "../market";
7
+ import type { PositionsAPI } from "../positions";
6
8
  import type { ProfileAPI } from "../profile";
7
9
  import type { TradingAPI, TradingMode } from "../trading";
8
10
  import type { VaultAPI } from "../vault";
9
- import type { OHLCVEvent, OrderbookEvent, OrderbookQuotationMode, OrderEvent, TradeEvent, UserBalanceEvent, UserMovementEvent } from "../websocket";
11
+ import type { ConditionalOrderEvent, OHLCVEvent, OrderbookEvent, OrderbookQuotationMode, OrderEvent, TradeEvent, UserBalanceEvent, UserMovementEvent } from "../websocket";
10
12
  import type { Network } from "./network";
11
13
  /**
12
14
  * Configuration options for the Monaco SDK.
@@ -47,6 +49,10 @@ export interface MonacoSDK {
47
49
  trading: TradingAPI;
48
50
  /** Market metadata API */
49
51
  market: MarketAPI;
52
+ /** Margin account operations API */
53
+ marginAccounts: MarginAccountsAPI;
54
+ /** Perp position operations API */
55
+ positions: PositionsAPI;
50
56
  /** Profile operations API */
51
57
  profile: ProfileAPI;
52
58
  /** Orderbook REST API for fetching orderbook snapshots */
@@ -65,10 +71,10 @@ export interface MonacoSDK {
65
71
  /** Trades REST API for fetching historical trades */
66
72
  trades: {
67
73
  getTrades: (tradingPairId: string, options?: {
68
- /** Number of records to skip (default: 0) */
69
- skip?: number;
74
+ /** Page number (starts from 1, default: 1) */
75
+ page?: number;
70
76
  /** Maximum number of records to return (default: 25, max: 100) */
71
- limit?: number;
77
+ page_size?: number;
72
78
  }) => Promise<TradeEvent[]>;
73
79
  };
74
80
  /** WebSocket client for real-time data (orders, orderbook, ohlcv) */
@@ -85,6 +91,7 @@ export interface MonacoSDK {
85
91
  movements: (handler: (event: UserMovementEvent) => void) => () => void;
86
92
  userOrders: (handler: (event: OrderEvent) => void) => () => void;
87
93
  balances: (handler: (event: UserBalanceEvent) => void) => () => void;
94
+ conditionalOrders: (handler: (event: ConditionalOrderEvent) => void, tradingPairId?: string) => () => void;
88
95
  };
89
96
  /** Wallet client for all blockchain operations (undefined until set) */
90
97
  walletClient: WalletClient | undefined;
@@ -4,8 +4,8 @@
4
4
  * Types for trading operations including order placement and management.
5
5
  */
6
6
  import type { BaseAPI } from "../api/index";
7
- import type { OrderSide, TimeInForce, TradingMode } from "./orders";
8
- import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ReplaceOrderResponse } from "./responses";
7
+ import type { OrderSide, PositionSide, TimeInForce, TradingMode } from "./orders";
8
+ import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ReplaceOrderResponse } from "./responses";
9
9
  /**
10
10
  * Trading API interface.
11
11
  * Provides methods for placing and managing orders.
@@ -28,6 +28,10 @@ export interface TradingAPI extends BaseAPI {
28
28
  useMasterBalance?: boolean;
29
29
  expirationDate?: string;
30
30
  timeInForce?: TimeInForce;
31
+ marginAccountId?: string;
32
+ positionSide?: PositionSide;
33
+ leverage?: string;
34
+ reduceOnly?: boolean;
31
35
  }): Promise<CreateOrderResponse>;
32
36
  /**
33
37
  * Places a market order for immediate execution.
@@ -42,6 +46,10 @@ export interface TradingAPI extends BaseAPI {
42
46
  placeMarketOrder(tradingPairId: string, side: OrderSide, quantity: string, options?: {
43
47
  tradingMode?: TradingMode;
44
48
  slippageTolerance?: number;
49
+ marginAccountId?: string;
50
+ positionSide?: PositionSide;
51
+ leverage?: string;
52
+ reduceOnly?: boolean;
45
53
  }): Promise<CreateOrderResponse>;
46
54
  /**
47
55
  * Cancels an existing order.
@@ -49,6 +57,18 @@ export interface TradingAPI extends BaseAPI {
49
57
  * @returns Promise resolving to the cancellation result
50
58
  */
51
59
  cancelOrder(orderId: string): Promise<CancelOrderResponse>;
60
+ /**
61
+ * Creates a standalone conditional TP/SL order.
62
+ */
63
+ createConditionalOrder(params: CreateConditionalOrderParams): Promise<CreateConditionalOrderResponse>;
64
+ /**
65
+ * Cancels an active conditional TP/SL order.
66
+ */
67
+ cancelConditionalOrder(conditionalOrderId: string): Promise<CancelConditionalOrderResponse>;
68
+ /**
69
+ * Lists conditional TP/SL orders for the authenticated user.
70
+ */
71
+ listConditionalOrders(params?: ListConditionalOrdersParams): Promise<ListConditionalOrdersResponse>;
52
72
  /**
53
73
  * Batch cancels specific orders by their IDs.
54
74
  * @param orderIds - Array of order IDs to cancel
@@ -94,7 +114,7 @@ export interface TradingAPI extends BaseAPI {
94
114
  * Gets paginated orders based on query parameters.
95
115
  * @param params - Query parameters for filtering orders
96
116
  * @param params.status - Filter by order status (optional)
97
- * @param params.trading_pair - Filter by trading pair (optional)
117
+ * @param params.trading_pair_id - Filter by trading pair UUID (optional)
98
118
  * @param params.page - Page number for pagination (optional)
99
119
  * @param params.page_size - Number of orders per page (optional)
100
120
  * @returns Promise resolving to the paginated orders result
@@ -107,6 +127,6 @@ export interface TradingAPI extends BaseAPI {
107
127
  */
108
128
  getOrder(orderId: string): Promise<GetOrderResponse>;
109
129
  }
110
- export type { Order, OrderRole, OrderSide, OrderStatus, OrderType, TimeInForce, TradingMode, } from "./orders";
130
+ export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce, TradingMode, } from "./orders";
111
131
  export { ORDER_STATUS_VALUES } from "./orders";
112
- export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, MatchResult, ReplaceOrderResponse, UpdatedFields, } from "./responses";
132
+ export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, ConditionalOrder, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, MatchResult, ReplaceOrderResponse, UpdatedFields, } from "./responses";
@@ -23,7 +23,7 @@ export interface Order {
23
23
  /** Order identifier (UUID) */
24
24
  id: string;
25
25
  /** Trading pair ID (UUID format, e.g., "456e7890-e12b-12d3-a456-426614174000") */
26
- trading_pair: string;
26
+ trading_pair_id: string;
27
27
  /** Order side (BUY or SELL) */
28
28
  side: OrderSide;
29
29
  /** Order type - see OrderType for all supported types */
@@ -60,6 +60,16 @@ export interface Order {
60
60
  taker_total_payment?: string;
61
61
  /** Total receipt for maker after rebates in quote currency - populated after fills */
62
62
  maker_total_receipt?: string;
63
+ /** Margin account ID for margin/perp orders */
64
+ margin_account_id?: string;
65
+ /** Position side for margin/perp orders */
66
+ position_side?: PositionSide;
67
+ /** Leverage used for margin/perp orders */
68
+ leverage?: string;
69
+ /** Whether the order can only reduce existing exposure */
70
+ reduce_only?: boolean;
71
+ /** Position ID linked to the order, when available */
72
+ position_id?: string;
63
73
  }
64
74
  /**
65
75
  * Role of the creator or order
@@ -69,6 +79,10 @@ export type OrderRole = "maker" | "taker";
69
79
  * Order side for trading operations
70
80
  */
71
81
  export type OrderSide = "BUY" | "SELL";
82
+ /**
83
+ * Position side for margin/perp trading
84
+ */
85
+ export type PositionSide = "LONG" | "SHORT" | "NONE";
72
86
  /**
73
87
  * Order type for different order strategies
74
88
  * - LIMIT: Execute only at specified price or better
@@ -109,3 +123,15 @@ export type TradingMode = "SPOT" | "MARGIN";
109
123
  * - GTD: Good Till Date - remains active until specified expiration date
110
124
  */
111
125
  export type TimeInForce = "GTC" | "IOC" | "FOK" | "GTD";
126
+ /**
127
+ * Conditional TP/SL condition type.
128
+ */
129
+ export type ConditionalOrderConditionType = "STOP_LOSS" | "TAKE_PROFIT";
130
+ /**
131
+ * Conditional order trigger source. v1 supports mark-price triggers.
132
+ */
133
+ export type ConditionalOrderTriggerSource = "MARK_PRICE";
134
+ /**
135
+ * Conditional TP/SL lifecycle state.
136
+ */
137
+ export type ConditionalOrderState = "ACTIVE" | "TRIGGERING" | "TRIGGERED" | "CANCELLED" | "EXPIRED" | "FAILED";