@0xmonaco/types 1.0.42 → 1.0.44
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/margin-accounts/index.d.ts +9 -5
- package/dist/portfolio/index.d.ts +51 -0
- package/dist/positions/index.d.ts +19 -1
- package/dist/profile/index.d.ts +6 -0
- package/dist/sdk/index.d.ts +2 -1
- package/dist/trading/index.d.ts +39 -5
- package/dist/trading/orders.d.ts +8 -0
- package/dist/trading/responses.d.ts +191 -1
- package/dist/validation/trading.d.ts +60 -0
- package/dist/validation/trading.js +94 -0
- package/dist/validation/vault.d.ts +3 -0
- package/dist/validation/vault.js +6 -0
- package/dist/vault/index.d.ts +22 -2
- package/dist/websocket/events/account-events.d.ts +6 -2
- package/dist/websocket/events/index.d.ts +1 -0
- package/dist/websocket/events/index.js +1 -0
- package/dist/websocket/events/ohlcv-events.d.ts +15 -0
- package/dist/websocket/events/orders-events.d.ts +28 -2
- package/dist/websocket/events/twap-order-events.d.ts +64 -0
- package/dist/websocket/events/twap-order-events.js +0 -0
- package/dist/wire/operations.d.ts +1 -1
- package/dist/wire/operations.js +4 -0
- package/dist/wire/schema.d.ts +710 -7
- package/package.json +3 -7
package/dist/vault/index.d.ts
CHANGED
|
@@ -15,6 +15,21 @@ import type { Balance, TransactionResult, WithdrawalRetryOptions, WithdrawResult
|
|
|
15
15
|
* to spot — funds are never lost.
|
|
16
16
|
*/
|
|
17
17
|
export type DepositTarget = "spot" | "margin";
|
|
18
|
+
/**
|
|
19
|
+
* Options for a deposit.
|
|
20
|
+
*/
|
|
21
|
+
export interface DepositOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Deposit the wrapped-native asset (e.g. WSEI) as its ERC20 instead of in
|
|
24
|
+
* native coin. By default the SDK deposits that asset via the payable
|
|
25
|
+
* `depositNative` (spending native coin, which the vault wraps on entry);
|
|
26
|
+
* set this when the wallet holds the wrapped ERC20 itself — the deposit then
|
|
27
|
+
* goes through the standard `approve` + `depositERC20` path and consumes an
|
|
28
|
+
* ERC20 allowance. Withdrawals still pay out native coin (the vault
|
|
29
|
+
* unwraps). Has no effect on assets that are not the wrapped-native asset.
|
|
30
|
+
*/
|
|
31
|
+
asErc20?: boolean;
|
|
32
|
+
}
|
|
18
33
|
/**
|
|
19
34
|
* Source ledger for an external withdrawal.
|
|
20
35
|
* - `"spot"` (default): withdraw from the spot/main wallet.
|
|
@@ -44,9 +59,11 @@ export interface VaultAPI extends BaseAPI {
|
|
|
44
59
|
* @param target - Destination ledger: `"spot"` (default) or `"margin"` to
|
|
45
60
|
* route the deposit into the parent margin account's collateral. Margin
|
|
46
61
|
* deposits that cannot be routed fall back to spot.
|
|
62
|
+
* @param options - Deposit options; `asErc20` deposits the wrapped-native
|
|
63
|
+
* asset as its ERC20 via `depositERC20` instead of in native coin.
|
|
47
64
|
* @returns Promise resolving to the transaction result
|
|
48
65
|
*/
|
|
49
|
-
deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget): Promise<TransactionResult>;
|
|
66
|
+
deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget, options?: DepositOptions): Promise<TransactionResult>;
|
|
50
67
|
/**
|
|
51
68
|
* Initiates a withdrawal and submits its `executeWithdrawal(...)` calldata
|
|
52
69
|
* on-chain through the connected wallet.
|
|
@@ -99,9 +116,12 @@ export interface VaultAPI extends BaseAPI {
|
|
|
99
116
|
* Checks if a token needs approval for an amount.
|
|
100
117
|
* @param assetId - Asset identifier (UUID) to check
|
|
101
118
|
* @param amount - Amount to check
|
|
119
|
+
* @param options - Deposit options the approval is for; with `asErc20` the
|
|
120
|
+
* wrapped-native asset consumes a real ERC20 allowance, so its allowance
|
|
121
|
+
* is read instead of short-circuiting to false.
|
|
102
122
|
* @returns Promise resolving to whether approval is needed
|
|
103
123
|
*/
|
|
104
|
-
needsApproval(assetId: string, amount: bigint): Promise<boolean>;
|
|
124
|
+
needsApproval(assetId: string, amount: bigint, options?: DepositOptions): Promise<boolean>;
|
|
105
125
|
/**
|
|
106
126
|
* Gets the address of the vault.
|
|
107
127
|
* @returns Promise resolving to the address of the vault
|
|
@@ -23,8 +23,12 @@ export interface AccountEventData {
|
|
|
23
23
|
/** Collateral available for new margin allocation (decimal string) */
|
|
24
24
|
freeCollateral: string;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Account distress ratio: maintenance margin required over equity (higher is
|
|
27
|
+
* closer to liquidation, decimal string). When equity is non-positive the
|
|
28
|
+
* quotient is undefined, so an account that still owes a maintenance
|
|
29
|
+
* requirement saturates to the max-decimal sentinel
|
|
30
|
+
* (`79228162514264337593543950335`, maximal distress) and an empty account
|
|
31
|
+
* with no requirement is `0`. Clamp the sentinel before display.
|
|
28
32
|
*/
|
|
29
33
|
marginRatio: string;
|
|
30
34
|
/** Maintenance margin required to keep the account solvent (decimal string) */
|
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Candlestick, Interval } from "../../market";
|
|
7
7
|
import type { TradingMode } from "../../trading";
|
|
8
|
+
/**
|
|
9
|
+
* OHLCV price series selector for the optional fifth channel token.
|
|
10
|
+
*
|
|
11
|
+
* - `trade` — the trade-derived candles (the default when the token is omitted).
|
|
12
|
+
* - `mark` — the close-only mark-price series (open = high = low = close = mark,
|
|
13
|
+
* zero volume), published on `1m` for margin pairs.
|
|
14
|
+
* - `*` — both series.
|
|
15
|
+
*/
|
|
16
|
+
export type OHLCVPriceType = "trade" | "mark" | "*";
|
|
8
17
|
/**
|
|
9
18
|
* OHLCV update event
|
|
10
19
|
*/
|
|
@@ -15,6 +24,12 @@ export interface OHLCVEvent {
|
|
|
15
24
|
interval: Interval;
|
|
16
25
|
/** Trading mode */
|
|
17
26
|
tradingMode: TradingMode;
|
|
27
|
+
/**
|
|
28
|
+
* Price series this candle belongs to. Always a concrete series on the wire
|
|
29
|
+
* (`trade` or `mark`, never the `*` selector); lets a wildcard subscriber
|
|
30
|
+
* tell the two streams apart. Absent only on legacy frames that omit it.
|
|
31
|
+
*/
|
|
32
|
+
priceType?: "trade" | "mark";
|
|
18
33
|
/** OHLCV candlestick data */
|
|
19
34
|
candlestick: Candlestick;
|
|
20
35
|
}
|
|
@@ -9,7 +9,7 @@ import type { RawEventMessage } from "../base";
|
|
|
9
9
|
/**
|
|
10
10
|
* Order event types
|
|
11
11
|
*/
|
|
12
|
-
export type OrderEventType = "OrderPlaced" | "OrderMatched" | "OrderPartiallyFilled" | "OrderFilled" | "OrderCancelled" | "OrderRejected" | "OrderExpired";
|
|
12
|
+
export type OrderEventType = "OrderPlaced" | "OrderMatched" | "OrderPartiallyFilled" | "OrderFilled" | "OrderCancelled" | "OrderPartiallyCancelled" | "OrderRejected" | "OrderExpired";
|
|
13
13
|
/**
|
|
14
14
|
* Base order event structure
|
|
15
15
|
* All order events share these common fields
|
|
@@ -320,10 +320,36 @@ export interface OrderExpiredEvent extends OrderEvent {
|
|
|
320
320
|
reason: string;
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Partial cancel: the order was reduced IN PLACE to a smaller remaining
|
|
325
|
+
* quantity and is STILL RESTING at its original queue position. NOT a
|
|
326
|
+
* terminal event — an `OrderCancelled` (or fill) still follows eventually.
|
|
327
|
+
* `quantity` is the reduced TOTAL, so `quantity = filledQuantity +
|
|
328
|
+
* remainingQuantity` holds.
|
|
329
|
+
*/
|
|
330
|
+
export interface OrderPartiallyCancelledEvent extends OrderEvent {
|
|
331
|
+
eventType: "OrderPartiallyCancelled";
|
|
332
|
+
data: CommonOrderEventData & {
|
|
333
|
+
/** Order status — non-terminal (the order still rests) */
|
|
334
|
+
status: OrderStatus;
|
|
335
|
+
/** Cumulative filled quantity, unchanged by the reduction */
|
|
336
|
+
filledQuantity: string;
|
|
337
|
+
/** Cumulative filled quantity in RAW precision. Wire: `filled_quantity_raw`. */
|
|
338
|
+
filledQuantityRaw: string;
|
|
339
|
+
/** Remaining quantity after the reduction (the requested target) */
|
|
340
|
+
remainingQuantity: string;
|
|
341
|
+
/** Remaining quantity in RAW precision. Wire: `remaining_quantity_raw`. */
|
|
342
|
+
remainingQuantityRaw: string;
|
|
343
|
+
/** Caller-supplied cancel reason; explicit `null` when none was given */
|
|
344
|
+
reason: string | null;
|
|
345
|
+
/** When the reduction happened (RFC3339 `Z`). Wire: `reduced_at`. */
|
|
346
|
+
reducedAt: string;
|
|
347
|
+
};
|
|
348
|
+
}
|
|
323
349
|
/**
|
|
324
350
|
* Union type of all possible order event data
|
|
325
351
|
*/
|
|
326
|
-
export type OrderEventData = OrderPlacedEvent["data"] | OrderMatchedEvent["data"] | OrderPartiallyFilledEvent["data"] | OrderFilledEvent["data"] | OrderCancelledEvent["data"] | OrderRejectedEvent["data"] | OrderExpiredEvent["data"];
|
|
352
|
+
export type OrderEventData = OrderPlacedEvent["data"] | OrderMatchedEvent["data"] | OrderPartiallyFilledEvent["data"] | OrderFilledEvent["data"] | OrderCancelledEvent["data"] | OrderPartiallyCancelledEvent["data"] | OrderRejectedEvent["data"] | OrderExpiredEvent["data"];
|
|
327
353
|
/**
|
|
328
354
|
* Subscription configuration for order events
|
|
329
355
|
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { OrderSide, TradingMode, TwapOrderState } from "../../trading";
|
|
2
|
+
/**
|
|
3
|
+
* Mutation that produced a TWAP parent-order snapshot.
|
|
4
|
+
*/
|
|
5
|
+
export type TwapOrderEventReason = "created" | "slice_placed" | "slice_skipped" | "cancelled" | "completed";
|
|
6
|
+
/**
|
|
7
|
+
* TWAP parent-order snapshot carried by a `twap_orders` WebSocket event.
|
|
8
|
+
* The server publishes the full read model on every lifecycle transition
|
|
9
|
+
* (created, slice placed/skipped, cancelled, completed), so each event
|
|
10
|
+
* supersedes the previous one for the same `twapOrderId`.
|
|
11
|
+
*
|
|
12
|
+
* Field names mirror the backend `TwapOrderEventData` payload (snake_case on
|
|
13
|
+
* the wire, camelCased by the client); the SDK parser normalizes explicit
|
|
14
|
+
* `null` values to absent, so nullable wire fields are optional here.
|
|
15
|
+
*/
|
|
16
|
+
export interface TwapOrderEventData {
|
|
17
|
+
twapOrderId: string;
|
|
18
|
+
tradingPairId: string;
|
|
19
|
+
side: OrderSide;
|
|
20
|
+
tradingMode: TradingMode;
|
|
21
|
+
totalQuantity: string;
|
|
22
|
+
executedQuantity: string;
|
|
23
|
+
executedNotional: string;
|
|
24
|
+
/** Volume-weighted average fill price (executedNotional / executedQuantity); absent until the first fill */
|
|
25
|
+
averageFillPrice?: string;
|
|
26
|
+
limitPrice?: string;
|
|
27
|
+
slippageToleranceBps: number;
|
|
28
|
+
reduceOnly: boolean;
|
|
29
|
+
marginAccountId?: string;
|
|
30
|
+
/** Isolated risk bucket UUID for risk-bucket-scoped margin TWAP orders */
|
|
31
|
+
riskBucketId?: string;
|
|
32
|
+
leverage?: string;
|
|
33
|
+
useMasterBalance: boolean;
|
|
34
|
+
strategyKey?: string;
|
|
35
|
+
clientTwapId?: string;
|
|
36
|
+
randomize: boolean;
|
|
37
|
+
/** Window start (ISO 8601) */
|
|
38
|
+
startAt: string;
|
|
39
|
+
/** Window end (ISO 8601). Execution stops hard at this time. */
|
|
40
|
+
endAt: string;
|
|
41
|
+
/** Derived base slice interval in milliseconds (int64 on the wire, a JSON number) */
|
|
42
|
+
intervalMs: number;
|
|
43
|
+
plannedSlices: number;
|
|
44
|
+
/** Index of the next slice in the planned schedule */
|
|
45
|
+
nextSliceIndex: number;
|
|
46
|
+
/** Planned time of the next slice (ISO 8601); absent once the parent is terminal */
|
|
47
|
+
nextSliceAt?: string;
|
|
48
|
+
slicesPlaced: number;
|
|
49
|
+
slicesSkipped: number;
|
|
50
|
+
state: TwapOrderState;
|
|
51
|
+
/** Terminal annotation, e.g. "ended with shortfall 1.5"; absent for non-terminal parents */
|
|
52
|
+
terminalReason?: string;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
cancelledAt?: string;
|
|
56
|
+
completedAt?: string;
|
|
57
|
+
/** Mutation that produced this snapshot */
|
|
58
|
+
reason: TwapOrderEventReason;
|
|
59
|
+
}
|
|
60
|
+
export interface TwapOrderEvent {
|
|
61
|
+
eventType: "twap_order_update";
|
|
62
|
+
userId: string;
|
|
63
|
+
data: TwapOrderEventData;
|
|
64
|
+
}
|
|
File without changes
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
* hand-written SDK surface. CI regenerates it and fails on a diff, identical to
|
|
11
11
|
* the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
|
|
12
12
|
*/
|
|
13
|
-
export declare const OPERATION_IDS: readonly ["attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_conditional_order", "cancel_order", "check_trader_code_availability", "clear_trader_code", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_conditional_order", "get_faucet_info", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_pulse", "get_rewards_balance", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "mint_tokens", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
|
|
13
|
+
export declare const OPERATION_IDS: readonly ["attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_conditional_order", "cancel_order", "cancel_twap_order", "check_trader_code_availability", "clear_trader_code", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "create_twap_order", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_conditional_order", "get_faucet_info", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_pulse", "get_rewards_balance", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "get_twap_order", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "list_twap_orders", "mint_tokens", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
|
|
14
14
|
/** Union of every OpenAPI operationId in the spec. */
|
|
15
15
|
export type OperationId = (typeof OPERATION_IDS)[number];
|
package/dist/wire/operations.js
CHANGED
|
@@ -20,6 +20,7 @@ export const OPERATION_IDS = [
|
|
|
20
20
|
"batch_replace_orders",
|
|
21
21
|
"cancel_conditional_order",
|
|
22
22
|
"cancel_order",
|
|
23
|
+
"cancel_twap_order",
|
|
23
24
|
"check_trader_code_availability",
|
|
24
25
|
"clear_trader_code",
|
|
25
26
|
"close_position",
|
|
@@ -27,6 +28,7 @@ export const OPERATION_IDS = [
|
|
|
27
28
|
"create_delegated_session",
|
|
28
29
|
"create_order",
|
|
29
30
|
"create_sub_account_limit",
|
|
31
|
+
"create_twap_order",
|
|
30
32
|
"delete_sub_account_limit",
|
|
31
33
|
"get_application_config",
|
|
32
34
|
"get_application_stats",
|
|
@@ -69,6 +71,7 @@ export const OPERATION_IDS = [
|
|
|
69
71
|
"get_trader_code_info",
|
|
70
72
|
"get_trades",
|
|
71
73
|
"get_trading_pair_by_id",
|
|
74
|
+
"get_twap_order",
|
|
72
75
|
"get_user_balance_by_asset",
|
|
73
76
|
"get_user_balances",
|
|
74
77
|
"get_user_movements",
|
|
@@ -93,6 +96,7 @@ export const OPERATION_IDS = [
|
|
|
93
96
|
"list_positions",
|
|
94
97
|
"list_sub_accounts_with_balances",
|
|
95
98
|
"list_trading_pairs",
|
|
99
|
+
"list_twap_orders",
|
|
96
100
|
"mint_tokens",
|
|
97
101
|
"refresh_session",
|
|
98
102
|
"register_deposit_address",
|