@0xmonaco/types 0.7.9 → 0.8.4

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.
@@ -0,0 +1,53 @@
1
+ import type { BaseAPI } from "../api";
2
+ export type DelegatedAgentAction = "CREATE_ORDER" | "CANCEL_ORDER" | "REPLACE_ORDER" | "create_order" | "cancel_order" | "replace_order";
3
+ export interface UpsertDelegatedAgentRequest {
4
+ agentAddress: string;
5
+ name?: string;
6
+ expiresAt?: string;
7
+ allowedActions: DelegatedAgentAction[];
8
+ allowedTradingPairIds: string[];
9
+ allowedMarginAccountIds?: string[];
10
+ allowedOrderTypes?: Array<"LIMIT" | "MARKET">;
11
+ allowedTimeInForce?: Array<"GTC" | "IOC" | "FOK">;
12
+ maxLeverage?: string;
13
+ maxOrderNotional?: string;
14
+ maxOpenOrders?: number;
15
+ }
16
+ export interface DelegatedAgent {
17
+ id: string;
18
+ owner_user_id: string;
19
+ agent_address: string;
20
+ name?: string;
21
+ is_active: boolean;
22
+ expires_at?: string;
23
+ revoked_at?: string;
24
+ allowed_actions: string[];
25
+ allowed_trading_pair_ids: string[];
26
+ allowed_margin_account_ids: string[];
27
+ allowed_order_types?: string[];
28
+ allowed_time_in_force?: string[];
29
+ max_leverage?: string;
30
+ max_order_notional?: string;
31
+ max_open_orders?: number;
32
+ }
33
+ export interface ListDelegatedAgentsResponse {
34
+ agents: DelegatedAgent[];
35
+ }
36
+ export interface CreateDelegatedSessionRequest {
37
+ ownerUserId: string;
38
+ }
39
+ export interface CreateDelegatedSessionResponse {
40
+ access_token: string;
41
+ expires_at: number;
42
+ delegation_id: string;
43
+ owner_user_id: string;
44
+ agent_address: string;
45
+ }
46
+ export interface DelegatedAgentsAPI extends BaseAPI {
47
+ upsertDelegatedAgent(request: UpsertDelegatedAgentRequest): Promise<DelegatedAgent>;
48
+ listDelegatedAgents(): Promise<ListDelegatedAgentsResponse>;
49
+ revokeDelegatedAgent(delegatedAgentId: string): Promise<{
50
+ status: "REVOKED";
51
+ }>;
52
+ createDelegatedSession(request: CreateDelegatedSessionRequest): Promise<CreateDelegatedSessionResponse>;
53
+ }
File without changes
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./api";
8
8
  export * from "./applications";
9
9
  export * from "./auth";
10
10
  export * from "./contracts";
11
+ export * from "./delegated-agents";
11
12
  export * from "./fees";
12
13
  export * from "./margin-accounts";
13
14
  export * from "./market";
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ export * from "./api";
9
9
  export * from "./applications";
10
10
  export * from "./auth";
11
11
  export * from "./contracts";
12
+ export * from "./delegated-agents";
12
13
  export * from "./fees";
13
14
  export * from "./margin-accounts";
14
15
  export * from "./market";
@@ -1,6 +1,7 @@
1
1
  import type { PublicClient, TransactionReceipt, WalletClient } from "viem";
2
2
  import type { ApplicationsAPI } from "../applications";
3
3
  import type { AuthAPI, AuthState } from "../auth/index";
4
+ import type { DelegatedAgentsAPI } from "../delegated-agents";
4
5
  import type { FeesAPI } from "../fees";
5
6
  import type { MarginAccountsAPI } from "../margin-accounts";
6
7
  import type { Interval, MarketAPI } from "../market";
@@ -43,6 +44,8 @@ export interface MonacoSDK {
43
44
  auth: AuthAPI;
44
45
  /** Fees operations API */
45
46
  fees: FeesAPI;
47
+ /** Delegated trading agent operations API */
48
+ delegatedAgents: DelegatedAgentsAPI;
46
49
  /** Vault operations API */
47
50
  vault: VaultAPI;
48
51
  /** Trading operations API */
@@ -29,6 +29,7 @@ export interface TradingAPI extends BaseAPI {
29
29
  expirationDate?: string;
30
30
  timeInForce?: TimeInForce;
31
31
  marginAccountId?: string;
32
+ strategyKey?: string;
32
33
  positionSide?: PositionSide;
33
34
  leverage?: string;
34
35
  reduceOnly?: boolean;
@@ -49,6 +50,7 @@ export interface TradingAPI extends BaseAPI {
49
50
  tradingMode?: TradingMode;
50
51
  slippageTolerance?: number;
51
52
  marginAccountId?: string;
53
+ strategyKey?: string;
52
54
  positionSide?: PositionSide;
53
55
  leverage?: string;
54
56
  reduceOnly?: boolean;
@@ -72,6 +72,12 @@ export interface CreateOrderResponse {
72
72
  message: string;
73
73
  /** Match result information if order was processed by matching engine */
74
74
  match_result?: MatchResult;
75
+ /** Resolved margin account ID for margin/perp orders */
76
+ margin_account_id?: string;
77
+ /** Resolved hidden strategy bucket key for auto margin buckets */
78
+ strategy_key?: string;
79
+ /** Delegated agent ID when submitted through a delegated session */
80
+ delegation_id?: string;
75
81
  /** Conditional order ID for an attached take-profit leg */
76
82
  take_profit_order_id?: string;
77
83
  /** Conditional order ID for an attached stop-loss leg */
@@ -280,6 +286,8 @@ export interface BatchCreateOrderParams {
280
286
  timeInForce?: Extract<TimeInForce, "GTC" | "IOC" | "FOK">;
281
287
  /** Margin account UUID for margin/perp orders */
282
288
  marginAccountId?: string;
289
+ /** Optional strategy bucket key used when marginAccountId is omitted */
290
+ strategyKey?: string;
283
291
  /** Position side for margin/perp orders */
284
292
  positionSide?: PositionSide;
285
293
  /** Leverage for margin/perp orders */
@@ -101,6 +101,7 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
101
101
  FOK: "FOK";
102
102
  }>>;
103
103
  marginAccountId: z.ZodOptional<z.ZodUUID>;
104
+ strategyKey: z.ZodOptional<z.ZodString>;
104
105
  positionSide: z.ZodOptional<z.ZodEnum<{
105
106
  LONG: "LONG";
106
107
  SHORT: "SHORT";
@@ -155,6 +156,7 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
155
156
  }>>;
156
157
  slippageTolerance: z.ZodOptional<z.ZodNumber>;
157
158
  marginAccountId: z.ZodOptional<z.ZodUUID>;
159
+ strategyKey: z.ZodOptional<z.ZodString>;
158
160
  positionSide: z.ZodOptional<z.ZodEnum<{
159
161
  LONG: "LONG";
160
162
  SHORT: "SHORT";
@@ -347,6 +349,7 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
347
349
  FOK: "FOK";
348
350
  }>>;
349
351
  marginAccountId: z.ZodOptional<z.ZodUUID>;
352
+ strategyKey: z.ZodOptional<z.ZodString>;
350
353
  positionSide: z.ZodOptional<z.ZodEnum<{
351
354
  LONG: "LONG";
352
355
  SHORT: "SHORT";
@@ -386,6 +389,7 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
386
389
  FOK: "FOK";
387
390
  }>>;
388
391
  marginAccountId: z.ZodOptional<z.ZodUUID>;
392
+ strategyKey: z.ZodOptional<z.ZodString>;
389
393
  positionSide: z.ZodOptional<z.ZodEnum<{
390
394
  LONG: "LONG";
391
395
  SHORT: "SHORT";
@@ -117,6 +117,7 @@ export const PlaceLimitOrderSchema = z
117
117
  expirationDate: ISO8601DateSchema.optional(),
118
118
  timeInForce: TimeInForceSchema.optional(),
119
119
  marginAccountId: UUIDSchema.optional(),
120
+ strategyKey: z.string().min(1).max(128).optional(),
120
121
  positionSide: PositionSideSchema.optional(),
121
122
  leverage: PositiveDecimalStringSchema.optional(),
122
123
  reduceOnly: z.boolean().optional(),
@@ -124,10 +125,6 @@ export const PlaceLimitOrderSchema = z
124
125
  stopLoss: ParentTpSlLegSchema.optional(),
125
126
  })
126
127
  .optional(),
127
- })
128
- .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.marginAccountId !== undefined, {
129
- message: "marginAccountId is required for MARGIN orders",
130
- path: ["options", "marginAccountId"],
131
128
  })
132
129
  .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
133
130
  message: "positionSide is required for MARGIN orders",
@@ -162,6 +159,7 @@ export const PlaceMarketOrderSchema = z
162
159
  tradingMode: TradingModeSchema.optional(),
163
160
  slippageTolerance: SlippageToleranceSchema,
164
161
  marginAccountId: UUIDSchema.optional(),
162
+ strategyKey: z.string().min(1).max(128).optional(),
165
163
  positionSide: PositionSideSchema.optional(),
166
164
  leverage: PositiveDecimalStringSchema.optional(),
167
165
  reduceOnly: z.boolean().optional(),
@@ -169,10 +167,6 @@ export const PlaceMarketOrderSchema = z
169
167
  stopLoss: ParentTpSlLegSchema.optional(),
170
168
  })
171
169
  .optional(),
172
- })
173
- .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.marginAccountId !== undefined, {
174
- message: "marginAccountId is required for MARGIN orders",
175
- path: ["options", "marginAccountId"],
176
170
  })
177
171
  .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
178
172
  message: "positionSide is required for MARGIN orders",
@@ -309,6 +303,7 @@ export const BatchCreateOrderItemSchema = z
309
303
  expirationDate: ISO8601DateSchema.optional(),
310
304
  timeInForce: TimeInForceSchema.optional(),
311
305
  marginAccountId: UUIDSchema.optional(),
306
+ strategyKey: z.string().min(1).max(128).optional(),
312
307
  positionSide: PositionSideSchema.optional(),
313
308
  leverage: PositiveDecimalStringSchema.optional(),
314
309
  reduceOnly: z.boolean().optional(),
@@ -320,10 +315,6 @@ export const BatchCreateOrderItemSchema = z
320
315
  .refine((data) => data.orderType !== "MARKET" || data.price === undefined, {
321
316
  message: "Price must not be provided for MARKET orders",
322
317
  path: ["price"],
323
- })
324
- .refine((data) => data.tradingMode !== "MARGIN" || data.marginAccountId !== undefined, {
325
- message: "marginAccountId is required for MARGIN orders",
326
- path: ["marginAccountId"],
327
318
  })
328
319
  .refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
329
320
  message: "positionSide is required for MARGIN orders",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "0.7.9",
3
+ "version": "0.8.4",
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.7.9",
23
+ "@0xmonaco/contracts": "0.8.4",
24
24
  "zod": "^4.1.12"
25
25
  },
26
26
  "peerDependencies": {