@0xmonaco/types 0.8.16 → 0.8.19

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.
@@ -4,7 +4,7 @@
4
4
  * Types for fees operations including fee simulation.
5
5
  */
6
6
  import type { BaseAPI } from "../api/index";
7
- import type { SimulateFeeParams, SimulateFeeResponse } from "./responses";
7
+ import type { GetMyFeeTierParams, GetMyFeeTierResponse, SimulateFeeParams, SimulateFeeResponse } from "./responses";
8
8
  /**
9
9
  * Fees API interface.
10
10
  * Provides methods for simulating and calculating trading fees.
@@ -34,6 +34,28 @@ export interface FeesAPI extends BaseAPI {
34
34
  * ```
35
35
  */
36
36
  simulateFees(params: SimulateFeeParams): Promise<SimulateFeeResponse>;
37
+ /**
38
+ * Get the caller's current fee tier, rolling 14-day volumes, and a pair's schedule.
39
+ *
40
+ * Returns the caller's resolved tier (1–6) and weighted 14-day volume (with the
41
+ * spot/perp breakdown), the volume still needed to reach the next tier, and the
42
+ * requested pair's six-row fee schedule (threshold plus maker/taker bps).
43
+ *
44
+ * @param params - Parameters for the lookup
45
+ * @param params.tradingPairId - Trading pair whose fee schedule to return
46
+ * @returns Promise resolving to the caller's tier and the pair's schedule
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const tier = await feesAPI.getMyFeeTier({
51
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
52
+ * });
53
+ * console.log(`Current tier: ${tier.currentTierLevel}`);
54
+ * console.log(`14d volume: ${tier.weightedVolume14d}`);
55
+ * console.log(`To next tier: ${tier.volumeToNextTier ?? "already at top tier"}`);
56
+ * ```
57
+ */
58
+ getMyFeeTier(params: GetMyFeeTierParams): Promise<GetMyFeeTierResponse>;
37
59
  }
38
- export type { SimulateFeeParams, SimulateFeeResponse } from "./responses";
39
- export { SimulateFeeParamsSchema, SimulateFeeResponseSchema } from "./responses";
60
+ export type { FeeTierScheduleRow, GetMyFeeTierParams, GetMyFeeTierResponse, SimulateFeeParams, SimulateFeeResponse, } from "./responses";
61
+ export { FeeTierScheduleRowSchema, GetMyFeeTierParamsSchema, GetMyFeeTierResponseSchema, SimulateFeeParamsSchema, SimulateFeeResponseSchema, } from "./responses";
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * Types for fees operations including fee simulation.
5
5
  */
6
- export { SimulateFeeParamsSchema, SimulateFeeResponseSchema } from "./responses";
6
+ export { FeeTierScheduleRowSchema, GetMyFeeTierParamsSchema, GetMyFeeTierResponseSchema, SimulateFeeParamsSchema, SimulateFeeResponseSchema, } from "./responses";
@@ -52,3 +52,50 @@ export type SimulateFeeParams = z.infer<typeof SimulateFeeParamsSchema>;
52
52
  * @remarks Type is inferred from SimulateFeeResponseSchema
53
53
  */
54
54
  export type SimulateFeeResponse = z.infer<typeof SimulateFeeResponseSchema>;
55
+ /**
56
+ * Zod schema for the parameters of a "my fee tier" lookup
57
+ */
58
+ export declare const GetMyFeeTierParamsSchema: z.ZodObject<{
59
+ tradingPairId: z.ZodString;
60
+ }, z.core.$strip>;
61
+ /**
62
+ * Zod schema for one row of a pair's fee-tier schedule
63
+ */
64
+ export declare const FeeTierScheduleRowSchema: z.ZodObject<{
65
+ tierLevel: z.ZodNumber;
66
+ minVolumeThreshold: z.ZodString;
67
+ makerFeeBps: z.ZodString;
68
+ takerFeeBps: z.ZodString;
69
+ }, z.core.$strip>;
70
+ /**
71
+ * Zod schema for the "my fee tier" response
72
+ */
73
+ export declare const GetMyFeeTierResponseSchema: z.ZodObject<{
74
+ currentTierLevel: z.ZodNumber;
75
+ weightedVolume14d: z.ZodString;
76
+ spotVolume14d: z.ZodString;
77
+ perpVolume14d: z.ZodString;
78
+ volumeToNextTier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ nextTierLevel: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
80
+ feeSchedule: z.ZodArray<z.ZodObject<{
81
+ tierLevel: z.ZodNumber;
82
+ minVolumeThreshold: z.ZodString;
83
+ makerFeeBps: z.ZodString;
84
+ takerFeeBps: z.ZodString;
85
+ }, z.core.$strip>>;
86
+ }, z.core.$strip>;
87
+ /**
88
+ * Parameters for a "my fee tier" lookup
89
+ * @remarks Type is inferred from GetMyFeeTierParamsSchema
90
+ */
91
+ export type GetMyFeeTierParams = z.infer<typeof GetMyFeeTierParamsSchema>;
92
+ /**
93
+ * One row of a pair's fee-tier schedule
94
+ * @remarks Type is inferred from FeeTierScheduleRowSchema
95
+ */
96
+ export type FeeTierScheduleRow = z.infer<typeof FeeTierScheduleRowSchema>;
97
+ /**
98
+ * The caller's current fee tier, rolling 14-day volumes, and a pair's schedule
99
+ * @remarks Type is inferred from GetMyFeeTierResponseSchema
100
+ */
101
+ export type GetMyFeeTierResponse = z.infer<typeof GetMyFeeTierResponseSchema>;
@@ -84,3 +84,42 @@ export const SimulateFeeResponseSchema = z.object({
84
84
  /** Slippage tolerance used in the calculation, echoed back for MARKET orders (null for LIMIT orders) */
85
85
  slippageToleranceBps: z.number().nullable(),
86
86
  });
87
+ /**
88
+ * Zod schema for the parameters of a "my fee tier" lookup
89
+ */
90
+ export const GetMyFeeTierParamsSchema = z.object({
91
+ /** Trading pair ID whose six-row fee schedule to return */
92
+ tradingPairId: z.string().trim().min(1, "Trading pair ID is required and cannot be empty"),
93
+ });
94
+ /**
95
+ * Zod schema for one row of a pair's fee-tier schedule
96
+ */
97
+ export const FeeTierScheduleRowSchema = z.object({
98
+ /** Tier level, 1 (lowest volume) through 6 (highest) */
99
+ tierLevel: z.number().int(),
100
+ /** Weighted 14-day volume floor for this tier, in quote/USD units */
101
+ minVolumeThreshold: z.string(),
102
+ /** Maker fee in human basis points; negative is a rebate */
103
+ makerFeeBps: z.string(),
104
+ /** Taker fee in human basis points */
105
+ takerFeeBps: z.string(),
106
+ });
107
+ /**
108
+ * Zod schema for the "my fee tier" response
109
+ */
110
+ export const GetMyFeeTierResponseSchema = z.object({
111
+ /** Caller's resolved tier (1–6) from stored weighted 14-day volume */
112
+ currentTierLevel: z.number().int(),
113
+ /** Caller's weighted 14-day volume (perp + 2.5× spot) */
114
+ weightedVolume14d: z.string(),
115
+ /** Caller's rolling 14-day spot volume */
116
+ spotVolume14d: z.string(),
117
+ /** Caller's rolling 14-day perp volume */
118
+ perpVolume14d: z.string(),
119
+ /** Additional weighted volume needed to reach the next tier; absent at tier 6 */
120
+ volumeToNextTier: z.string().nullable().optional(),
121
+ /** Next tier level; absent when already at tier 6 */
122
+ nextTierLevel: z.number().int().nullable().optional(),
123
+ /** Six-row fee schedule for the requested pair, ascending by tier */
124
+ feeSchedule: z.array(FeeTierScheduleRowSchema),
125
+ });
@@ -1,10 +1,12 @@
1
1
  import type { BaseAPI } from "../api";
2
2
  import type { OrderSide, OrderType, PositionSide } from "../trading";
3
+ export type MarginMode = "ISOLATED" | "CROSS";
3
4
  export interface MarginAccountSummary {
4
5
  marginAccountId: string;
5
6
  label?: string;
6
7
  riskBucketId?: string;
7
- marginMode?: "ISOLATED" | "CROSS";
8
+ marginMode?: MarginMode;
9
+ selectedTradingPairIds?: string[];
8
10
  tradingPairId?: string;
9
11
  strategyKey?: string;
10
12
  accountState: string;
@@ -59,10 +61,19 @@ export interface TransferCollateralToParentMarginAccountRequest {
59
61
  asset: string;
60
62
  amount: string;
61
63
  }
62
- export interface TransferCollateralToRiskBucketRequest extends TransferCollateralToParentMarginAccountRequest {
64
+ export interface TransferCollateralToIsolatedRiskBucketRequest extends TransferCollateralToParentMarginAccountRequest {
65
+ marginMode?: "ISOLATED";
63
66
  tradingPairId: string;
64
67
  strategyKey?: string;
68
+ selectedTradingPairIds?: never;
65
69
  }
70
+ export interface TransferCollateralToCrossRiskBucketRequest extends TransferCollateralToParentMarginAccountRequest {
71
+ marginMode: "CROSS";
72
+ selectedTradingPairIds: string[];
73
+ tradingPairId?: never;
74
+ strategyKey?: never;
75
+ }
76
+ export type TransferCollateralToRiskBucketRequest = TransferCollateralToIsolatedRiskBucketRequest | TransferCollateralToCrossRiskBucketRequest;
66
77
  export interface TransferCollateralFromParentMarginAccountRequest {
67
78
  asset: string;
68
79
  amount: string;
@@ -71,6 +82,9 @@ export interface TransferCollateralResponse {
71
82
  movementId: string;
72
83
  marginAccountId: string;
73
84
  strategyKey?: string;
85
+ riskBucketId?: string;
86
+ marginMode?: MarginMode;
87
+ selectedTradingPairIds?: string[];
74
88
  asset: string;
75
89
  amount: string;
76
90
  status: string;
@@ -107,14 +121,25 @@ export interface SimulateOrderRiskRequest {
107
121
  leverage: string;
108
122
  reduceOnly?: boolean;
109
123
  }
110
- export interface SimulateRiskBucketOrderRiskRequest extends SimulateOrderRiskRequest {
124
+ export type SimulateIsolatedRiskBucketOrderRiskRequest = SimulateOrderRiskRequest & {
125
+ marginMode?: "ISOLATED";
111
126
  strategyKey?: string;
112
- }
127
+ selectedTradingPairIds?: never;
128
+ };
129
+ export type SimulateCrossRiskBucketOrderRiskRequest = SimulateOrderRiskRequest & {
130
+ marginMode: "CROSS";
131
+ selectedTradingPairIds: string[];
132
+ strategyKey?: never;
133
+ };
134
+ export type SimulateRiskBucketOrderRiskRequest = SimulateIsolatedRiskBucketOrderRiskRequest | SimulateCrossRiskBucketOrderRiskRequest;
113
135
  export interface SimulateOrderRiskResponse {
114
136
  accepted: boolean;
115
137
  rejectReason?: string;
116
138
  marginAccountId: string;
117
139
  strategyKey?: string;
140
+ riskBucketId?: string;
141
+ marginMode?: MarginMode;
142
+ selectedTradingPairIds?: string[];
118
143
  equityAfter: string;
119
144
  initialMarginRequiredAfter: string;
120
145
  maintenanceMarginRequiredAfter: string;
@@ -1,4 +1,5 @@
1
1
  import type { BaseAPI } from "../api";
2
+ import type { MarginMode } from "../margin-accounts";
2
3
  import type { OrderType, PositionSide, TimeInForce } from "../trading";
3
4
  export type PositionStatus = "OPEN" | "CLOSED" | "LIQUIDATING";
4
5
  export type ClosePositionType = "MARKET" | "LIMIT" | "IOC";
@@ -6,6 +7,7 @@ export interface Position {
6
7
  positionId: string;
7
8
  marginAccountId: string;
8
9
  riskBucketId?: string;
10
+ marginMode?: MarginMode;
9
11
  tradingPairId: string;
10
12
  side: PositionSide;
11
13
  size: string;
@@ -4,6 +4,7 @@
4
4
  * Types for trading operations including order placement and management.
5
5
  */
6
6
  import type { BaseAPI } from "../api/index";
7
+ import type { MarginMode } from "../margin-accounts";
7
8
  import type { OrderSide, PositionSide, TimeInForce, TradingMode } from "./orders";
8
9
  import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ParentTpSlLegParams, ReplaceOrderResponse } from "./responses";
9
10
  /**
@@ -29,6 +30,7 @@ export interface TradingAPI extends BaseAPI {
29
30
  expirationDate?: string;
30
31
  timeInForce?: TimeInForce;
31
32
  marginAccountId?: string;
33
+ marginMode?: MarginMode;
32
34
  riskBucketId?: string;
33
35
  riskBucketCollateral?: string;
34
36
  strategyKey?: string;
@@ -52,6 +54,7 @@ export interface TradingAPI extends BaseAPI {
52
54
  tradingMode?: TradingMode;
53
55
  slippageTolerance?: number;
54
56
  marginAccountId?: string;
57
+ marginMode?: MarginMode;
55
58
  riskBucketId?: string;
56
59
  riskBucketCollateral?: string;
57
60
  strategyKey?: string;
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Response types for trading operations.
5
5
  */
6
+ import type { MarginMode } from "../margin-accounts";
6
7
  import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce, TradingMode } from "./orders";
7
8
  /**
8
9
  * Match result information for order execution.
@@ -288,6 +289,8 @@ export interface BatchCreateOrderParams {
288
289
  timeInForce?: Extract<TimeInForce, "GTC" | "IOC" | "FOK">;
289
290
  /** Margin account UUID for margin/perp orders */
290
291
  marginAccountId?: string;
292
+ /** Risk bucket mode for margin/perp orders */
293
+ marginMode?: MarginMode;
291
294
  /** Existing isolated risk bucket UUID for risk-bucket-scoped margin orders */
292
295
  riskBucketId?: string;
293
296
  /** Collateral to allocate into a new isolated risk bucket */
@@ -34,12 +34,21 @@ export declare const TransferCollateralToParentMarginAccountSchema: z.ZodObject<
34
34
  }, z.core.$strip>;
35
35
  }, z.core.$strip>;
36
36
  export declare const TransferCollateralToRiskBucketSchema: z.ZodObject<{
37
- request: z.ZodObject<{
37
+ request: z.ZodUnion<readonly [z.ZodObject<{
38
38
  asset: z.ZodString;
39
39
  amount: z.ZodString;
40
40
  tradingPairId: z.ZodUUID;
41
41
  strategyKey: z.ZodOptional<z.ZodString>;
42
- }, z.core.$strip>;
42
+ marginMode: z.ZodOptional<z.ZodLiteral<"ISOLATED">>;
43
+ selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
44
+ }, z.core.$strict>, z.ZodObject<{
45
+ asset: z.ZodString;
46
+ amount: z.ZodString;
47
+ marginMode: z.ZodLiteral<"CROSS">;
48
+ selectedTradingPairIds: z.ZodArray<z.ZodUUID>;
49
+ strategyKey: z.ZodOptional<z.ZodNever>;
50
+ tradingPairId: z.ZodOptional<z.ZodNever>;
51
+ }, z.core.$strict>]>;
43
52
  }, z.core.$strip>;
44
53
  export declare const TransferCollateralFromParentMarginAccountSchema: z.ZodObject<{
45
54
  request: z.ZodObject<{
@@ -104,7 +113,7 @@ export declare const SimulateParentMarginOrderRiskSchema: z.ZodObject<{
104
113
  }, z.core.$strict>;
105
114
  }, z.core.$strip>;
106
115
  export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
107
- request: z.ZodObject<{
116
+ request: z.ZodUnion<readonly [z.ZodObject<{
108
117
  side: z.ZodEnum<{
109
118
  BUY: "BUY";
110
119
  SELL: "SELL";
@@ -124,5 +133,29 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
124
133
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
125
134
  tradingPairId: z.ZodUUID;
126
135
  strategyKey: z.ZodOptional<z.ZodString>;
127
- }, z.core.$strict>;
136
+ marginMode: z.ZodOptional<z.ZodLiteral<"ISOLATED">>;
137
+ selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ tradingPairId: z.ZodUUID;
140
+ side: z.ZodEnum<{
141
+ BUY: "BUY";
142
+ SELL: "SELL";
143
+ }>;
144
+ positionSide: z.ZodEnum<{
145
+ LONG: "LONG";
146
+ SHORT: "SHORT";
147
+ NONE: "NONE";
148
+ }>;
149
+ orderType: z.ZodEnum<{
150
+ LIMIT: "LIMIT";
151
+ MARKET: "MARKET";
152
+ }>;
153
+ price: z.ZodOptional<z.ZodString>;
154
+ quantity: z.ZodString;
155
+ leverage: z.ZodString;
156
+ reduceOnly: z.ZodOptional<z.ZodBoolean>;
157
+ marginMode: z.ZodLiteral<"CROSS">;
158
+ selectedTradingPairIds: z.ZodArray<z.ZodUUID>;
159
+ strategyKey: z.ZodOptional<z.ZodNever>;
160
+ }, z.core.$strict>]>;
128
161
  }, z.core.$strip>;
@@ -39,6 +39,19 @@ const RiskBucketRequestSchema = z.object({
39
39
  tradingPairId: UUIDSchema,
40
40
  strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
41
41
  });
42
+ const SelectedCrossTradingPairIdsSchema = z.array(UUIDSchema).min(1, "selectedTradingPairIds is required for CROSS risk buckets");
43
+ const IsolatedRiskBucketRequestSchema = RiskBucketRequestSchema.extend({
44
+ marginMode: z.literal("ISOLATED").optional(),
45
+ selectedTradingPairIds: z.never().optional(),
46
+ });
47
+ const CrossRiskBucketScopeSchema = z.object({
48
+ marginMode: z.literal("CROSS"),
49
+ selectedTradingPairIds: SelectedCrossTradingPairIdsSchema,
50
+ strategyKey: z.never().optional(),
51
+ });
52
+ const CrossRiskBucketRequestSchema = CrossRiskBucketScopeSchema.extend({
53
+ tradingPairId: z.never().optional(),
54
+ });
42
55
  export const TransferCollateralSchema = z.object({
43
56
  marginAccountId: UUIDSchema,
44
57
  request: TransferCollateralRequestSchema,
@@ -47,7 +60,10 @@ export const TransferCollateralToParentMarginAccountSchema = z.object({
47
60
  request: ParentMarginAccountCollateralRequestSchema,
48
61
  });
49
62
  export const TransferCollateralToRiskBucketSchema = z.object({
50
- request: ParentMarginAccountCollateralRequestSchema.merge(RiskBucketRequestSchema),
63
+ request: z.union([
64
+ ParentMarginAccountCollateralRequestSchema.merge(IsolatedRiskBucketRequestSchema).strict(),
65
+ ParentMarginAccountCollateralRequestSchema.merge(CrossRiskBucketRequestSchema).strict(),
66
+ ]),
51
67
  });
52
68
  export const TransferCollateralFromParentMarginAccountSchema = z.object({
53
69
  request: ParentMarginAccountCollateralRequestSchema,
@@ -70,7 +86,14 @@ const BaseSimulateOrderRiskRequestSchema = z.object({
70
86
  reduceOnly: z.boolean().optional(),
71
87
  });
72
88
  const SimulateOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.strict();
73
- const SimulateRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(RiskBucketRequestSchema).strict();
89
+ const SimulateIsolatedRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(IsolatedRiskBucketRequestSchema).strict();
90
+ const SimulateCrossRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(CrossRiskBucketScopeSchema)
91
+ .strict()
92
+ .refine((data) => data.selectedTradingPairIds.includes(data.tradingPairId), {
93
+ message: "tradingPairId must be included in selectedTradingPairIds for CROSS risk buckets",
94
+ path: ["selectedTradingPairIds"],
95
+ });
96
+ const SimulateRiskBucketOrderRiskRequestSchema = z.union([SimulateIsolatedRiskBucketOrderRiskRequestSchema, SimulateCrossRiskBucketOrderRiskRequestSchema]);
74
97
  export const SimulateOrderRiskSchema = z
75
98
  .object({
76
99
  marginAccountId: UUIDSchema,
@@ -19,6 +19,10 @@ export declare const TradingModeSchema: z.ZodEnum<{
19
19
  SPOT: "SPOT";
20
20
  MARGIN: "MARGIN";
21
21
  }>;
22
+ export declare const MarginModeSchema: z.ZodEnum<{
23
+ ISOLATED: "ISOLATED";
24
+ CROSS: "CROSS";
25
+ }>;
22
26
  /**
23
27
  * Position side validation
24
28
  */
@@ -101,6 +105,10 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
101
105
  FOK: "FOK";
102
106
  }>>;
103
107
  marginAccountId: z.ZodOptional<z.ZodUUID>;
108
+ marginMode: z.ZodOptional<z.ZodEnum<{
109
+ ISOLATED: "ISOLATED";
110
+ CROSS: "CROSS";
111
+ }>>;
104
112
  riskBucketId: z.ZodOptional<z.ZodUUID>;
105
113
  riskBucketCollateral: z.ZodOptional<z.ZodString>;
106
114
  strategyKey: z.ZodOptional<z.ZodString>;
@@ -158,6 +166,10 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
158
166
  }>>;
159
167
  slippageTolerance: z.ZodOptional<z.ZodNumber>;
160
168
  marginAccountId: z.ZodOptional<z.ZodUUID>;
169
+ marginMode: z.ZodOptional<z.ZodEnum<{
170
+ ISOLATED: "ISOLATED";
171
+ CROSS: "CROSS";
172
+ }>>;
161
173
  riskBucketId: z.ZodOptional<z.ZodUUID>;
162
174
  riskBucketCollateral: z.ZodOptional<z.ZodString>;
163
175
  strategyKey: z.ZodOptional<z.ZodString>;
@@ -320,6 +332,10 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
320
332
  FOK: "FOK";
321
333
  }>>;
322
334
  marginAccountId: z.ZodOptional<z.ZodUUID>;
335
+ marginMode: z.ZodOptional<z.ZodEnum<{
336
+ ISOLATED: "ISOLATED";
337
+ CROSS: "CROSS";
338
+ }>>;
323
339
  riskBucketId: z.ZodOptional<z.ZodUUID>;
324
340
  riskBucketCollateral: z.ZodOptional<z.ZodString>;
325
341
  strategyKey: z.ZodOptional<z.ZodString>;
@@ -362,6 +378,10 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
362
378
  FOK: "FOK";
363
379
  }>>;
364
380
  marginAccountId: z.ZodOptional<z.ZodUUID>;
381
+ marginMode: z.ZodOptional<z.ZodEnum<{
382
+ ISOLATED: "ISOLATED";
383
+ CROSS: "CROSS";
384
+ }>>;
365
385
  riskBucketId: z.ZodOptional<z.ZodUUID>;
366
386
  riskBucketCollateral: z.ZodOptional<z.ZodString>;
367
387
  strategyKey: z.ZodOptional<z.ZodString>;
@@ -18,6 +18,9 @@ export const OrderSideSchema = z.enum(["BUY", "SELL"], {
18
18
  export const TradingModeSchema = z.enum(["SPOT", "MARGIN"], {
19
19
  message: 'Trading mode must be "SPOT" or "MARGIN"',
20
20
  });
21
+ export const MarginModeSchema = z.enum(["ISOLATED", "CROSS"], {
22
+ message: 'Margin mode must be "ISOLATED" or "CROSS"',
23
+ });
21
24
  /**
22
25
  * Position side validation
23
26
  */
@@ -117,6 +120,7 @@ export const PlaceLimitOrderSchema = z
117
120
  expirationDate: ISO8601DateSchema.optional(),
118
121
  timeInForce: TimeInForceSchema.optional(),
119
122
  marginAccountId: UUIDSchema.optional(),
123
+ marginMode: MarginModeSchema.optional(),
120
124
  riskBucketId: UUIDSchema.optional(),
121
125
  riskBucketCollateral: PositiveDecimalStringSchema.optional(),
122
126
  strategyKey: z.string().min(1).max(128).optional(),
@@ -151,6 +155,26 @@ export const PlaceLimitOrderSchema = z
151
155
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
152
156
  message: "riskBucketCollateral is only supported for MARGIN orders",
153
157
  path: ["options", "tradingMode"],
158
+ })
159
+ .refine((data) => data.options?.marginMode === undefined || data.options?.tradingMode === "MARGIN", {
160
+ message: "marginMode is only supported for MARGIN orders",
161
+ path: ["options", "tradingMode"],
162
+ })
163
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.marginAccountId !== undefined, {
164
+ message: "marginAccountId is required for CROSS margin orders",
165
+ path: ["options", "marginAccountId"],
166
+ })
167
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketId === undefined, {
168
+ message: "marginMode CROSS cannot be combined with riskBucketId",
169
+ path: ["options", "riskBucketId"],
170
+ })
171
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketCollateral === undefined, {
172
+ message: "marginMode CROSS cannot be combined with riskBucketCollateral",
173
+ path: ["options", "riskBucketCollateral"],
174
+ })
175
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.strategyKey === undefined, {
176
+ message: "marginMode CROSS cannot be combined with strategyKey",
177
+ path: ["options", "strategyKey"],
154
178
  })
155
179
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.riskBucketId === undefined, {
156
180
  message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
@@ -173,6 +197,7 @@ export const PlaceMarketOrderSchema = z
173
197
  tradingMode: TradingModeSchema.optional(),
174
198
  slippageTolerance: SlippageToleranceSchema,
175
199
  marginAccountId: UUIDSchema.optional(),
200
+ marginMode: MarginModeSchema.optional(),
176
201
  riskBucketId: UUIDSchema.optional(),
177
202
  riskBucketCollateral: PositiveDecimalStringSchema.optional(),
178
203
  strategyKey: z.string().min(1).max(128).optional(),
@@ -207,6 +232,26 @@ export const PlaceMarketOrderSchema = z
207
232
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
208
233
  message: "riskBucketCollateral is only supported for MARGIN orders",
209
234
  path: ["options", "tradingMode"],
235
+ })
236
+ .refine((data) => data.options?.marginMode === undefined || data.options?.tradingMode === "MARGIN", {
237
+ message: "marginMode is only supported for MARGIN orders",
238
+ path: ["options", "tradingMode"],
239
+ })
240
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.marginAccountId !== undefined, {
241
+ message: "marginAccountId is required for CROSS margin orders",
242
+ path: ["options", "marginAccountId"],
243
+ })
244
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketId === undefined, {
245
+ message: "marginMode CROSS cannot be combined with riskBucketId",
246
+ path: ["options", "riskBucketId"],
247
+ })
248
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketCollateral === undefined, {
249
+ message: "marginMode CROSS cannot be combined with riskBucketCollateral",
250
+ path: ["options", "riskBucketCollateral"],
251
+ })
252
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.strategyKey === undefined, {
253
+ message: "marginMode CROSS cannot be combined with strategyKey",
254
+ path: ["options", "strategyKey"],
210
255
  })
211
256
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.riskBucketId === undefined, {
212
257
  message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
@@ -298,6 +343,7 @@ export const BatchCreateOrderItemSchema = z
298
343
  expirationDate: ISO8601DateSchema.optional(),
299
344
  timeInForce: TimeInForceSchema.optional(),
300
345
  marginAccountId: UUIDSchema.optional(),
346
+ marginMode: MarginModeSchema.optional(),
301
347
  riskBucketId: UUIDSchema.optional(),
302
348
  riskBucketCollateral: PositiveDecimalStringSchema.optional(),
303
349
  strategyKey: z.string().min(1).max(128).optional(),
@@ -316,6 +362,26 @@ export const BatchCreateOrderItemSchema = z
316
362
  .refine((data) => data.riskBucketCollateral === undefined || data.tradingMode === "MARGIN", {
317
363
  message: "riskBucketCollateral is only supported for MARGIN orders",
318
364
  path: ["tradingMode"],
365
+ })
366
+ .refine((data) => data.marginMode === undefined || data.tradingMode === "MARGIN", {
367
+ message: "marginMode is only supported for MARGIN orders",
368
+ path: ["tradingMode"],
369
+ })
370
+ .refine((data) => data.marginMode !== "CROSS" || data.marginAccountId !== undefined, {
371
+ message: "marginAccountId is required for CROSS margin orders",
372
+ path: ["marginAccountId"],
373
+ })
374
+ .refine((data) => data.marginMode !== "CROSS" || data.riskBucketId === undefined, {
375
+ message: "marginMode CROSS cannot be combined with riskBucketId",
376
+ path: ["riskBucketId"],
377
+ })
378
+ .refine((data) => data.marginMode !== "CROSS" || data.riskBucketCollateral === undefined, {
379
+ message: "marginMode CROSS cannot be combined with riskBucketCollateral",
380
+ path: ["riskBucketCollateral"],
381
+ })
382
+ .refine((data) => data.marginMode !== "CROSS" || data.strategyKey === undefined, {
383
+ message: "marginMode CROSS cannot be combined with strategyKey",
384
+ path: ["strategyKey"],
319
385
  })
320
386
  .refine((data) => data.riskBucketCollateral === undefined || data.riskBucketId === undefined, {
321
387
  message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
@@ -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 ["add_position_margin", "attach_position_tp_sl", "authenticate_backend", "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", "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_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "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_chart", "get_portfolio_stats", "get_position", "get_position_risk", "get_screener", "get_sub_account_limits", "get_trade_by_id", "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_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", "reduce_position_margin", "refresh_session", "replace_order", "revoke_delegated_agent", "revoke_session", "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", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
13
+ export declare const OPERATION_IDS: readonly ["add_position_margin", "attach_position_tp_sl", "authenticate_backend", "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", "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_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_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_chart", "get_portfolio_stats", "get_position", "get_position_risk", "get_screener", "get_sub_account_limits", "get_trade_by_id", "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_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", "reduce_position_margin", "refresh_session", "replace_order", "revoke_delegated_agent", "revoke_session", "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", "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];
@@ -39,6 +39,7 @@ export const OPERATION_IDS = [
39
39
  "get_mark_price",
40
40
  "get_market_metadata",
41
41
  "get_market_stats",
42
+ "get_my_fee_tier",
42
43
  "get_open_interest",
43
44
  "get_order_by_id",
44
45
  "get_orderbook_snapshot",
@@ -704,6 +704,26 @@ export interface paths {
704
704
  patch?: never;
705
705
  trace?: never;
706
706
  };
707
+ "/api/v1/fees/tier": {
708
+ parameters: {
709
+ query?: never;
710
+ header?: never;
711
+ path?: never;
712
+ cookie?: never;
713
+ };
714
+ /**
715
+ * Get my fee tier and pair schedule
716
+ * @description Return the caller's current fee tier, rolling 14-day volumes, and a pair's schedule.
717
+ */
718
+ get: operations["get_my_fee_tier"];
719
+ put?: never;
720
+ post?: never;
721
+ delete?: never;
722
+ options?: never;
723
+ head?: never;
724
+ patch?: never;
725
+ trace?: never;
726
+ };
707
727
  "/api/v1/margin/accounts": {
708
728
  parameters: {
709
729
  query?: never;
@@ -2310,6 +2330,12 @@ export interface components {
2310
2330
  * @example my-strategy
2311
2331
  */
2312
2332
  strategyKey?: string | null;
2333
+ /**
2334
+ * @description Risk bucket mode for margin orders. Defaults to ISOLATED. Values: ISOLATED, CROSS.
2335
+ * @example CROSS
2336
+ * @enum {string|null}
2337
+ */
2338
+ marginMode?: "ISOLATED" | "CROSS" | null;
2313
2339
  };
2314
2340
  BatchCreateOrdersRequest: {
2315
2341
  orders: components["schemas"]["BatchCreateOrderItem"][];
@@ -2739,6 +2765,12 @@ export interface components {
2739
2765
  * @example my-strategy
2740
2766
  */
2741
2767
  strategyKey?: string | null;
2768
+ /**
2769
+ * @description Risk bucket mode for margin orders. Defaults to ISOLATED. Values: ISOLATED, CROSS.
2770
+ * @example CROSS
2771
+ * @enum {string|null}
2772
+ */
2773
+ marginMode?: "ISOLATED" | "CROSS" | null;
2742
2774
  };
2743
2775
  CreateOrderResponse: {
2744
2776
  /**
@@ -2884,6 +2916,29 @@ export interface components {
2884
2916
  */
2885
2917
  error?: string | null;
2886
2918
  };
2919
+ FeeTierScheduleRow: {
2920
+ /**
2921
+ * Format: int32
2922
+ * @description Tier level 1 (lowest volume) through 6 (highest)
2923
+ * @example 1
2924
+ */
2925
+ tierLevel?: number | null;
2926
+ /**
2927
+ * @description Weighted 14-day volume floor for this tier, in quote/USD units
2928
+ * @example 5000000
2929
+ */
2930
+ minVolumeThreshold?: string | null;
2931
+ /**
2932
+ * @description Maker fee in human basis points; negative is a rebate
2933
+ * @example -1.15
2934
+ */
2935
+ makerFeeBps?: string | null;
2936
+ /**
2937
+ * @description Taker fee in human basis points
2938
+ * @example 6.5
2939
+ */
2940
+ takerFeeBps?: string | null;
2941
+ };
2887
2942
  FundingPaymentRecord: {
2888
2943
  /**
2889
2944
  * Format: uuid
@@ -3149,6 +3204,7 @@ export interface components {
3149
3204
  strategyKey?: string | null;
3150
3205
  riskBucketId?: string | null;
3151
3206
  marginMode?: string | null;
3207
+ selectedTradingPairIds?: string[] | null;
3152
3208
  };
3153
3209
  GetMarkPriceResponse: {
3154
3210
  /** Format: uuid */
@@ -3292,6 +3348,42 @@ export interface components {
3292
3348
  */
3293
3349
  totalPages?: number | null;
3294
3350
  };
3351
+ GetMyFeeTierResponse: {
3352
+ /**
3353
+ * Format: int32
3354
+ * @description Caller's resolved tier (1–6) from stored weighted 14-day volume
3355
+ * @example 2
3356
+ */
3357
+ currentTierLevel?: number | null;
3358
+ /**
3359
+ * @description Caller's weighted 14-day volume (perp + 2.5× spot)
3360
+ * @example 7500000
3361
+ */
3362
+ weightedVolume14d?: string | null;
3363
+ /**
3364
+ * @description Caller's rolling 14-day spot volume
3365
+ * @example 1000000
3366
+ */
3367
+ spotVolume14d?: string | null;
3368
+ /**
3369
+ * @description Caller's rolling 14-day perp volume
3370
+ * @example 5000000
3371
+ */
3372
+ perpVolume14d?: string | null;
3373
+ /**
3374
+ * @description Additional weighted volume needed to reach the next tier; omitted at tier 6
3375
+ * @example 17500000
3376
+ */
3377
+ volumeToNextTier?: string | null;
3378
+ /**
3379
+ * Format: int32
3380
+ * @description Next tier level when not already at 6
3381
+ * @example 3
3382
+ */
3383
+ nextTierLevel?: number | null;
3384
+ /** @description Six-row fee schedule for the requested pair, ascending by tier */
3385
+ feeSchedule?: components["schemas"]["FeeTierScheduleRow"][] | null;
3386
+ };
3295
3387
  /** @description Latest public open interest for a trading pair. */
3296
3388
  GetOpenInterestResponse: {
3297
3389
  /**
@@ -3703,6 +3795,7 @@ export interface components {
3703
3795
  status?: string | null;
3704
3796
  updatedAt?: string | null;
3705
3797
  riskBucketId?: string | null;
3798
+ marginMode?: string | null;
3706
3799
  };
3707
3800
  GetPositionRiskResponse: {
3708
3801
  positionId?: string | null;
@@ -4305,6 +4398,8 @@ export interface components {
4305
4398
  riskBucketId?: string | null;
4306
4399
  /** @description Present only for risk-bucket summary rows. Values: ISOLATED, CROSS. */
4307
4400
  marginMode?: string | null;
4401
+ /** @description Present for cross risk-bucket summary rows. */
4402
+ selectedTradingPairIds?: string[] | null;
4308
4403
  };
4309
4404
  MatchResult: {
4310
4405
  /**
@@ -4494,6 +4589,7 @@ export interface components {
4494
4589
  status?: string | null;
4495
4590
  updatedAt?: string | null;
4496
4591
  riskBucketId?: string | null;
4592
+ marginMode?: string | null;
4497
4593
  };
4498
4594
  PositionHistoryEvent: {
4499
4595
  id?: string | null;
@@ -4881,6 +4977,12 @@ export interface components {
4881
4977
  marginAccountId?: string | null;
4882
4978
  /** @description Populated when the simulated account is an auto-resolved bucket. */
4883
4979
  strategyKey?: string | null;
4980
+ /** @description Present when the simulation resolved against a risk bucket. */
4981
+ riskBucketId?: string | null;
4982
+ /** @description Present when the simulation resolved against a risk bucket. Values: ISOLATED, CROSS. */
4983
+ marginMode?: string | null;
4984
+ /** @description Present for cross risk-bucket simulations. */
4985
+ selectedTradingPairIds?: string[] | null;
4884
4986
  };
4885
4987
  SimulateParentMarginOrderRiskRequest: {
4886
4988
  /** Format: uuid */
@@ -4904,6 +5006,10 @@ export interface components {
4904
5006
  quantity?: string | null;
4905
5007
  leverage?: string | null;
4906
5008
  reduceOnly?: boolean | null;
5009
+ /** @description Risk bucket mode. Defaults to ISOLATED. Values: ISOLATED, CROSS. */
5010
+ marginMode?: string | null;
5011
+ /** @description Trading pair UUIDs selected into the cross risk bucket. Required when marginMode is CROSS. */
5012
+ selectedTradingPairIds?: string[] | null;
4907
5013
  };
4908
5014
  SubAccount: {
4909
5015
  /**
@@ -5234,6 +5340,12 @@ export interface components {
5234
5340
  newTotalCollateralValue?: string | null;
5235
5341
  newWithdrawableCollateral?: string | null;
5236
5342
  strategyKey?: string | null;
5343
+ /** @description Present when collateral was allocated to a risk bucket. */
5344
+ riskBucketId?: string | null;
5345
+ /** @description Present when collateral was allocated to a risk bucket. Values: ISOLATED, CROSS. */
5346
+ marginMode?: string | null;
5347
+ /** @description Present for cross risk-bucket transfers. */
5348
+ selectedTradingPairIds?: string[] | null;
5237
5349
  };
5238
5350
  TransferCollateralToParentMarginAccountRequest: {
5239
5351
  asset?: string | null;
@@ -5244,10 +5356,15 @@ export interface components {
5244
5356
  amount?: string | null;
5245
5357
  /**
5246
5358
  * Format: uuid
5247
- * @description Trading pair UUID whose risk bucket receives collateral.
5359
+ * @description Trading pair UUID whose isolated risk bucket receives collateral.
5360
+ * Required for isolated risk buckets; omitted for cross risk buckets.
5248
5361
  */
5249
5362
  tradingPairId?: string | null;
5250
5363
  strategyKey?: string | null;
5364
+ /** @description Risk bucket mode. Defaults to ISOLATED. Values: ISOLATED, CROSS. */
5365
+ marginMode?: string | null;
5366
+ /** @description Trading pair UUIDs selected into the cross risk bucket. Required when marginMode is CROSS. */
5367
+ selectedTradingPairIds?: string[] | null;
5251
5368
  };
5252
5369
  UpdateLimitRequest: {
5253
5370
  /**
@@ -7013,6 +7130,57 @@ export interface operations {
7013
7130
  };
7014
7131
  };
7015
7132
  };
7133
+ get_my_fee_tier: {
7134
+ parameters: {
7135
+ query?: {
7136
+ /** @description Trading pair identifier (UUID) */
7137
+ tradingPairId?: string;
7138
+ };
7139
+ header?: never;
7140
+ path?: never;
7141
+ cookie?: never;
7142
+ };
7143
+ requestBody?: never;
7144
+ responses: {
7145
+ /** @description OK */
7146
+ 200: {
7147
+ headers: {
7148
+ [name: string]: unknown;
7149
+ };
7150
+ content: {
7151
+ "application/json": components["schemas"]["GetMyFeeTierResponse"];
7152
+ };
7153
+ };
7154
+ /** @description Bad request (invalid trading pair id) */
7155
+ 400: {
7156
+ headers: {
7157
+ [name: string]: unknown;
7158
+ };
7159
+ content?: never;
7160
+ };
7161
+ /** @description Authentication required */
7162
+ 401: {
7163
+ headers: {
7164
+ [name: string]: unknown;
7165
+ };
7166
+ content?: never;
7167
+ };
7168
+ /** @description Trading pair or fee schedule not found */
7169
+ 404: {
7170
+ headers: {
7171
+ [name: string]: unknown;
7172
+ };
7173
+ content?: never;
7174
+ };
7175
+ /** @description Internal server error */
7176
+ 500: {
7177
+ headers: {
7178
+ [name: string]: unknown;
7179
+ };
7180
+ content?: never;
7181
+ };
7182
+ };
7183
+ };
7016
7184
  list_margin_accounts: {
7017
7185
  parameters: {
7018
7186
  query?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "0.8.16",
3
+ "version": "0.8.19",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "lint": "biome lint ."
21
21
  },
22
22
  "dependencies": {
23
- "@0xmonaco/contracts": "0.8.16",
23
+ "@0xmonaco/contracts": "0.8.19",
24
24
  "zod": "^4.1.12"
25
25
  },
26
26
  "peerDependencies": {