@0xmonaco/types 0.0.0-develop-20260415185155 → 0.0.0-develop-20260420223958
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 +2 -0
- package/dist/index.js +2 -0
- package/dist/margin-accounts/index.d.ts +106 -0
- package/dist/margin-accounts/index.js +0 -0
- package/dist/market/index.d.ts +98 -0
- package/dist/positions/index.d.ts +128 -0
- package/dist/positions/index.js +0 -0
- package/dist/sdk/index.d.ts +8 -1
- package/dist/trading/index.d.ts +24 -4
- package/dist/trading/orders.d.ts +26 -0
- package/dist/trading/responses.d.ts +83 -2
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.js +2 -0
- package/dist/validation/margin-accounts.d.ts +55 -0
- package/dist/validation/margin-accounts.js +59 -0
- package/dist/validation/positions.d.ts +89 -0
- package/dist/validation/positions.js +93 -0
- package/dist/validation/trading.d.ts +121 -0
- package/dist/validation/trading.js +124 -3
- package/dist/websocket/events/conditional-order-events.d.ts +33 -0
- package/dist/websocket/events/conditional-order-events.js +0 -0
- package/dist/websocket/events/index.d.ts +1 -0
- package/dist/websocket/events/index.js +1 -0
- package/package.json +2 -2
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
|
package/dist/market/index.d.ts
CHANGED
|
@@ -172,6 +172,97 @@ export interface MarketMetadata {
|
|
|
172
172
|
/** Unix timestamp (ms) when market started trading (null if not available) */
|
|
173
173
|
market_initialization_timestamp: number | null;
|
|
174
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
|
+
}
|
|
175
266
|
/**
|
|
176
267
|
* Market API interface.
|
|
177
268
|
* Provides methods for fetching market metadata and trading pair information.
|
|
@@ -211,4 +302,11 @@ export interface MarketAPI extends BaseAPI {
|
|
|
211
302
|
* @throws {Error} If pair not found or no data available
|
|
212
303
|
*/
|
|
213
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>;
|
|
214
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
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -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 */
|
|
@@ -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;
|
package/dist/trading/index.d.ts
CHANGED
|
@@ -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
|
|
@@ -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";
|
package/dist/trading/orders.d.ts
CHANGED
|
@@ -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";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Response types for trading operations.
|
|
5
5
|
*/
|
|
6
|
-
import type { Order, OrderSide, OrderStatus, OrderType, TimeInForce, TradingMode } from "./orders";
|
|
6
|
+
import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce, TradingMode } from "./orders";
|
|
7
7
|
/**
|
|
8
8
|
* Match result information for order execution.
|
|
9
9
|
* Contains detailed information about trades, fills, and execution quality.
|
|
@@ -98,6 +98,10 @@ export interface GetPaginatedOrdersParams {
|
|
|
98
98
|
status?: OrderStatus;
|
|
99
99
|
/** Filter by trading pair UUID */
|
|
100
100
|
trading_pair_id?: string;
|
|
101
|
+
/** Filter by trading mode */
|
|
102
|
+
trading_mode?: TradingMode;
|
|
103
|
+
/** Filter by margin account UUID */
|
|
104
|
+
margin_account_id?: string;
|
|
101
105
|
/** Page number for pagination (default: 1) */
|
|
102
106
|
page?: number;
|
|
103
107
|
/** Number of orders per page (default: 10, max: 100) */
|
|
@@ -241,7 +245,7 @@ export interface BatchCreateOrderParams {
|
|
|
241
245
|
/** Order quantity */
|
|
242
246
|
quantity: string;
|
|
243
247
|
/** Trading mode (defaults to "SPOT") */
|
|
244
|
-
tradingMode?:
|
|
248
|
+
tradingMode?: TradingMode;
|
|
245
249
|
/** Maximum slippage for market orders as decimal (e.g., 0.01 for 1%) */
|
|
246
250
|
slippageTolerance?: number;
|
|
247
251
|
/** For sub-accounts: use master's balance */
|
|
@@ -250,6 +254,14 @@ export interface BatchCreateOrderParams {
|
|
|
250
254
|
expirationDate?: string;
|
|
251
255
|
/** Time in force: "GTC", "IOC", or "FOK" */
|
|
252
256
|
timeInForce?: Extract<TimeInForce, "GTC" | "IOC" | "FOK">;
|
|
257
|
+
/** Margin account UUID for margin/perp orders */
|
|
258
|
+
marginAccountId?: string;
|
|
259
|
+
/** Position side for margin/perp orders */
|
|
260
|
+
positionSide?: PositionSide;
|
|
261
|
+
/** Leverage for margin/perp orders */
|
|
262
|
+
leverage?: string;
|
|
263
|
+
/** Whether the order can only reduce existing exposure */
|
|
264
|
+
reduceOnly?: boolean;
|
|
253
265
|
}
|
|
254
266
|
/**
|
|
255
267
|
* Parameters for a single order in a batch replace request
|
|
@@ -264,3 +276,72 @@ export interface BatchReplaceOrderParams {
|
|
|
264
276
|
/** For sub-accounts: use master's balance (optional) */
|
|
265
277
|
useMasterBalance?: boolean;
|
|
266
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Parameters for creating a standalone conditional TP/SL order.
|
|
281
|
+
*/
|
|
282
|
+
export interface CreateConditionalOrderParams {
|
|
283
|
+
tradingPairId: string;
|
|
284
|
+
marginAccountId: string;
|
|
285
|
+
conditionType: ConditionalOrderConditionType;
|
|
286
|
+
triggerPrice: string;
|
|
287
|
+
triggerSource?: ConditionalOrderTriggerSource;
|
|
288
|
+
side: OrderSide;
|
|
289
|
+
positionSide: Exclude<PositionSide, "NONE">;
|
|
290
|
+
orderType: OrderType;
|
|
291
|
+
limitPrice?: string;
|
|
292
|
+
quantity?: string;
|
|
293
|
+
reduceOnly?: boolean;
|
|
294
|
+
timeInForce?: Extract<TimeInForce, "GTC" | "IOC">;
|
|
295
|
+
slippageToleranceBps?: number;
|
|
296
|
+
expiresAt?: string;
|
|
297
|
+
}
|
|
298
|
+
export interface CreateConditionalOrderResponse {
|
|
299
|
+
conditional_order_id: string;
|
|
300
|
+
status: "SUCCESS" | "FAILED";
|
|
301
|
+
message: string;
|
|
302
|
+
state: ConditionalOrderState;
|
|
303
|
+
}
|
|
304
|
+
export interface CancelConditionalOrderResponse {
|
|
305
|
+
conditional_order_id: string;
|
|
306
|
+
status: "SUCCESS" | "FAILED";
|
|
307
|
+
message: string;
|
|
308
|
+
}
|
|
309
|
+
export interface ListConditionalOrdersParams {
|
|
310
|
+
margin_account_id?: string;
|
|
311
|
+
trading_pair_id?: string;
|
|
312
|
+
state?: ConditionalOrderState;
|
|
313
|
+
page?: number;
|
|
314
|
+
page_size?: number;
|
|
315
|
+
}
|
|
316
|
+
export interface ConditionalOrder {
|
|
317
|
+
conditional_order_id: string;
|
|
318
|
+
trading_pair_id: string;
|
|
319
|
+
margin_account_id: string;
|
|
320
|
+
position_id?: string;
|
|
321
|
+
linked_group_id?: string;
|
|
322
|
+
condition_type: ConditionalOrderConditionType;
|
|
323
|
+
trigger_source: ConditionalOrderTriggerSource;
|
|
324
|
+
trigger_price: string;
|
|
325
|
+
side: OrderSide;
|
|
326
|
+
position_side: PositionSide;
|
|
327
|
+
order_type: OrderType;
|
|
328
|
+
limit_price?: string;
|
|
329
|
+
quantity?: string;
|
|
330
|
+
slippage_tolerance_bps?: number;
|
|
331
|
+
reduce_only: boolean;
|
|
332
|
+
time_in_force?: TimeInForce;
|
|
333
|
+
state: ConditionalOrderState;
|
|
334
|
+
triggered_order_id?: string;
|
|
335
|
+
triggered_at?: string;
|
|
336
|
+
cancelled_at?: string;
|
|
337
|
+
expires_at?: string;
|
|
338
|
+
failure_reason?: string;
|
|
339
|
+
created_at: string;
|
|
340
|
+
updated_at: string;
|
|
341
|
+
}
|
|
342
|
+
export interface ListConditionalOrdersResponse {
|
|
343
|
+
orders: ConditionalOrder[];
|
|
344
|
+
total: number;
|
|
345
|
+
page: number;
|
|
346
|
+
page_size: number;
|
|
347
|
+
}
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* - Market schemas (trading pairs, candlesticks)
|
|
15
15
|
*/
|
|
16
16
|
export * from "./common.js";
|
|
17
|
+
export * from "./margin-accounts.js";
|
|
17
18
|
export * from "./market.js";
|
|
19
|
+
export * from "./positions.js";
|
|
18
20
|
export * from "./profile.js";
|
|
19
21
|
export * from "./trading.js";
|
|
20
22
|
export * from "./vault.js";
|
package/dist/validation/index.js
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
// Export validation utilities
|
|
17
17
|
export * from "./common.js";
|
|
18
|
+
export * from "./margin-accounts.js";
|
|
18
19
|
export * from "./market.js";
|
|
20
|
+
export * from "./positions.js";
|
|
19
21
|
// Export module-specific schemas
|
|
20
22
|
export * from "./profile.js";
|
|
21
23
|
export * from "./trading.js";
|