@0xmonaco/types 0.8.7-develop.34bd452 → 0.8.7-develop.ab57a24

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.
Files changed (47) hide show
  1. package/dist/api/index.d.ts +7 -0
  2. package/dist/applications/index.d.ts +47 -5
  3. package/dist/applications/index.js +2 -1
  4. package/dist/applications/requests.d.ts +78 -0
  5. package/dist/applications/requests.js +7 -0
  6. package/dist/applications/responses.d.ts +211 -1
  7. package/dist/applications/responses.js +3 -1
  8. package/dist/auth/index.d.ts +6 -12
  9. package/dist/auth/index.js +2 -2
  10. package/dist/auth/responses.d.ts +0 -11
  11. package/dist/delegated-agents/index.d.ts +17 -1
  12. package/dist/faucet/index.d.ts +54 -0
  13. package/dist/faucet/index.js +10 -0
  14. package/dist/index.d.ts +4 -0
  15. package/dist/index.js +4 -0
  16. package/dist/margin-accounts/index.d.ts +10 -3
  17. package/dist/market/index.d.ts +83 -0
  18. package/dist/positions/index.d.ts +1 -0
  19. package/dist/profile/index.d.ts +88 -1
  20. package/dist/sdk/index.d.ts +12 -0
  21. package/dist/sub-accounts/index.d.ts +145 -0
  22. package/dist/sub-accounts/index.js +9 -0
  23. package/dist/trading/index.d.ts +4 -0
  24. package/dist/trading/responses.d.ts +8 -2
  25. package/dist/validation/margin-accounts.d.ts +6 -1
  26. package/dist/validation/margin-accounts.js +11 -1
  27. package/dist/validation/profile.d.ts +7 -0
  28. package/dist/validation/profile.js +7 -0
  29. package/dist/validation/trading.d.ts +8 -0
  30. package/dist/validation/trading.js +42 -0
  31. package/dist/whitelist/index.d.ts +44 -0
  32. package/dist/whitelist/index.js +10 -0
  33. package/dist/wire/assert.d.ts +54 -0
  34. package/dist/wire/assert.js +0 -0
  35. package/dist/wire/audit.d.ts +47 -0
  36. package/dist/wire/audit.js +43 -0
  37. package/dist/wire/coverage.d.ts +1 -0
  38. package/dist/wire/coverage.js +0 -0
  39. package/dist/wire/index.d.ts +21 -0
  40. package/dist/wire/index.js +2 -0
  41. package/dist/wire/operations.d.ts +15 -0
  42. package/dist/wire/operations.js +95 -0
  43. package/dist/wire/schema.d.ts +8432 -0
  44. package/dist/wire/schema.js +4 -0
  45. package/dist/withdrawals/index.d.ts +43 -0
  46. package/dist/withdrawals/index.js +0 -0
  47. package/package.json +6 -2
@@ -46,6 +46,10 @@ export interface TradingPair {
46
46
  max_order_size: string;
47
47
  /** Tick size for price increments */
48
48
  tick_size: string;
49
+ /** Minimum supported leverage for margin markets (optional, margin only) */
50
+ min_leverage?: string | null;
51
+ /** Maximum supported leverage for margin markets (optional, margin only) */
52
+ max_leverage?: string | null;
49
53
  }
50
54
  /**
51
55
  * OHLCV candlestick data point (matches API response format)
@@ -139,6 +143,71 @@ export interface GetTradingPairsResponse {
139
143
  export interface GetTradingPairResponse {
140
144
  trading_pair: TradingPair;
141
145
  }
146
+ /**
147
+ * Query parameters for the market screener
148
+ */
149
+ export interface GetScreenerParams {
150
+ /** Page number (min 1, default 1) */
151
+ page?: number;
152
+ /** Items per page (min 1, max 100, default 50) */
153
+ page_size?: number;
154
+ /** Filter by market type: SPOT or MARGIN */
155
+ market_type?: string;
156
+ /** Filter by active status */
157
+ is_active?: boolean;
158
+ }
159
+ /**
160
+ * One UTC-day bucket in a pair's 7-day screener snapshot
161
+ */
162
+ export interface ScreenerSnapshotPoint {
163
+ /** UTC day boundary (ms since epoch, as string) */
164
+ bucket_start: string;
165
+ /** Quote-token volume for the day */
166
+ quote_volume: string;
167
+ /** Percent price change (close - open) / open * 100 for the day */
168
+ price_change_percent: string;
169
+ }
170
+ /**
171
+ * Per-pair screener row. Window fields are null when there is insufficient history.
172
+ */
173
+ export interface ScreenerItem {
174
+ /** Trading pair UUID */
175
+ trading_pair_id: string;
176
+ /** Trading pair symbol (e.g. "BTC/USDC") */
177
+ symbol: string;
178
+ /** Base token icon URL */
179
+ base_icon_url: string;
180
+ /** Quote token icon URL */
181
+ quote_icon_url: string;
182
+ /** Most recent close price (null if no trades yet) */
183
+ last_price: string | null;
184
+ /** Timestamp of the last candle (ms since epoch, as string; null if no trades yet) */
185
+ last_price_timestamp: string | null;
186
+ /** Quote-token volume in the last 1 hour (null if <1h history) */
187
+ quote_volume_1h: string | null;
188
+ /** Quote-token volume in the last 24 hours (null if <24h history) */
189
+ quote_volume_24h: string | null;
190
+ /** Quote-token volume in the last 7 days (null if <7d history) */
191
+ quote_volume_7d: string | null;
192
+ /** Percent price change over the last 1 hour (null if <1h history) */
193
+ price_change_percent_1h: string | null;
194
+ /** Percent price change over the last 24 hours (null if <24h history) */
195
+ price_change_percent_24h: string | null;
196
+ /** Percent price change over the last 7 days (null if <7d history) */
197
+ price_change_percent_7d: string | null;
198
+ /** Up to 7 UTC-day buckets (oldest first); empty when <1 day of history */
199
+ snapshot_7d: ScreenerSnapshotPoint[];
200
+ }
201
+ /**
202
+ * Paginated screener response, sorted by quote_volume_24h desc (nulls last)
203
+ */
204
+ export interface GetScreenerResponse {
205
+ items: ScreenerItem[];
206
+ page: number;
207
+ page_size: number;
208
+ total: number;
209
+ total_pages: number;
210
+ }
142
211
  /**
143
212
  * API response wrapper for single trading pair
144
213
  */
@@ -275,12 +344,26 @@ export interface MarketAPI extends BaseAPI {
275
344
  * @returns Promise resolving to paginated response with trading pairs
276
345
  */
277
346
  getPaginatedTradingPairs(params?: GetTradingPairsParams): Promise<GetTradingPairsResponse>;
347
+ /**
348
+ * Fetch a single trading pair by its UUID.
349
+ * @param tradingPairId - Trading pair UUID
350
+ * @returns Promise resolving to the trading pair
351
+ * @throws {APIError} If the pair is not found
352
+ */
353
+ getTradingPair(tradingPairId: string): Promise<TradingPair>;
278
354
  /**
279
355
  * Fetch metadata for a single trading pair by its symbol (e.g. BTC-USDC).
280
356
  * @param symbol - Trading pair symbol
281
357
  * @returns Promise resolving to trading pair or undefined if not found
282
358
  */
283
359
  getTradingPairBySymbol(symbol: string): Promise<TradingPair | undefined>;
360
+ /**
361
+ * Fetch the paginated market screener: per-pair price/volume/change windows
362
+ * (1h, 24h, 7d) plus a 7-day daily snapshot, sorted by 24h quote volume.
363
+ * @param params - Optional pagination and filter parameters
364
+ * @returns Promise resolving to the paginated screener response
365
+ */
366
+ getScreener(params?: GetScreenerParams): Promise<GetScreenerResponse>;
284
367
  /**
285
368
  * Fetch historical candlestick data for a trading pair.
286
369
  *
@@ -5,6 +5,7 @@ export type ClosePositionType = "MARKET" | "LIMIT" | "IOC";
5
5
  export interface Position {
6
6
  position_id: string;
7
7
  margin_account_id: string;
8
+ margin_bucket_id?: string;
8
9
  trading_pair_id: string;
9
10
  side: PositionSide;
10
11
  size: string;
@@ -76,6 +76,12 @@ export interface LedgerMovement {
76
76
  block_number: number | null;
77
77
  /** Transaction timestamp */
78
78
  created_at: string | null;
79
+ /** Asset UUID this movement affects */
80
+ asset_id?: string | null;
81
+ /** User UUID who owns this movement */
82
+ user_id?: string | null;
83
+ /** Balance UUID this movement affects */
84
+ balance_id?: string | null;
79
85
  }
80
86
  /**
81
87
  * Ledger entry type for filtering movements.
@@ -190,7 +196,7 @@ export interface AccountBalance {
190
196
  available_balance: string;
191
197
  /** Locked balance (in orders or pending operations, normalized) */
192
198
  locked_balance: string;
193
- /** Total balance (available + locked + margin collateral, normalized) */
199
+ /** Total balance (available + locked, normalized) */
194
200
  total_balance: string;
195
201
  /** Available balance in raw format (wei) */
196
202
  available_balance_raw: string;
@@ -244,6 +250,67 @@ export interface GetUserTradesResponse {
244
250
  /** Total number of pages */
245
251
  total_pages: number;
246
252
  }
253
+ /**
254
+ * Direction of a funding payment from the user's perspective.
255
+ */
256
+ export type FundingDirection = "PAID" | "RECEIVED";
257
+ /**
258
+ * A single funding payment settled against a margin position.
259
+ */
260
+ export interface FundingPayment {
261
+ /** Funding payment unique identifier (UUID) */
262
+ id: string;
263
+ /** Margin position identifier (UUID) */
264
+ position_id: string;
265
+ /** Margin account identifier (UUID) */
266
+ margin_account_id: string;
267
+ /** Trading pair identifier (UUID) */
268
+ trading_pair_id: string;
269
+ /** Funding rate applied for the epoch (as string to preserve precision) */
270
+ funding_rate: string;
271
+ /** Absolute position size at settlement (as string to preserve precision) */
272
+ position_size: string;
273
+ /** Signed funding amount; positive means paid, negative means received (as string) */
274
+ payment_amount: string;
275
+ /** Funding direction for the user */
276
+ direction: FundingDirection;
277
+ /** Funding window start timestamp (ISO 8601), if known */
278
+ period_start?: string;
279
+ /** Funding window end timestamp (ISO 8601), if known */
280
+ period_end?: string;
281
+ /** Funding payment creation timestamp (ISO 8601), if known */
282
+ created_at?: string;
283
+ }
284
+ /**
285
+ * Query parameters for listing funding payments.
286
+ */
287
+ export interface ListFundingPaymentsParams {
288
+ /** Page number (starts from 1) */
289
+ page?: number;
290
+ /** Number of items per page (max 100) */
291
+ page_size?: number;
292
+ /** Filter by trading pair ID (UUID) */
293
+ trading_pair_id?: string;
294
+ /** Filter by margin position ID (UUID) */
295
+ position_id?: string;
296
+ /** Filter by margin account ID (UUID) */
297
+ margin_account_id?: string;
298
+ }
299
+ /**
300
+ * Response from listing funding payments.
301
+ */
302
+ export interface ListFundingPaymentsResponse {
303
+ /** List of funding payment records */
304
+ records: FundingPayment[];
305
+ /** Current page number */
306
+ page: number;
307
+ /** Items per page */
308
+ page_size: number;
309
+ /** Total number of matching records */
310
+ total: number;
311
+ /** Total number of pages */
312
+ total_pages: number;
313
+ }
247
314
  /**
248
315
  * Time period for portfolio stats and chart queries.
249
316
  */
@@ -315,6 +382,10 @@ export interface UserProfile {
315
382
  maker_fee_bps: number;
316
383
  /** Account creation timestamp (ISO string) */
317
384
  created_at: string;
385
+ /** Additional taker fee in basis points contributed by the application (if any) */
386
+ application_taker_fee_bps?: number;
387
+ /** Additional maker fee in basis points contributed by the application (if any) */
388
+ application_maker_fee_bps?: number;
318
389
  }
319
390
  /**
320
391
  * Profile API interface.
@@ -402,4 +473,20 @@ export interface ProfileAPI extends BaseAPI {
402
473
  * @throws ValidationError If pagination params (page/limit) are invalid or trading_pair_id is not a valid UUID; this may occur before any network request.
403
474
  */
404
475
  getUserTrades(params?: GetUserTradesParams): Promise<GetUserTradesResponse>;
476
+ /**
477
+ * List the current user's funding payment history with pagination and filters.
478
+ *
479
+ * Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
480
+ * Requires a valid access token to be set.
481
+ *
482
+ * @param params - Optional query parameters for pagination and filtering
483
+ * @param params.page - Page number (starts from 1)
484
+ * @param params.page_size - Number of items per page (max 100)
485
+ * @param params.trading_pair_id - Filter by trading pair ID (UUID)
486
+ * @param params.position_id - Filter by margin position ID (UUID)
487
+ * @param params.margin_account_id - Filter by margin account ID (UUID)
488
+ * @returns Promise resolving to paginated funding payments response
489
+ * @throws ValidationError If pagination params or a UUID filter are invalid; this may occur before any network request.
490
+ */
491
+ listFundingPayments(params?: ListFundingPaymentsParams): Promise<ListFundingPaymentsResponse>;
405
492
  }
@@ -2,14 +2,18 @@ import type { PublicClient, TransactionReceipt, WalletClient } from "viem";
2
2
  import type { ApplicationsAPI } from "../applications";
3
3
  import type { AuthAPI, AuthState, SessionCredentials } from "../auth/index";
4
4
  import type { DelegatedAgentsAPI } from "../delegated-agents";
5
+ import type { FaucetAPI } from "../faucet";
5
6
  import type { FeesAPI } from "../fees";
6
7
  import type { MarginAccountsAPI } from "../margin-accounts";
7
8
  import type { Interval, MarketAPI } from "../market";
8
9
  import type { PositionsAPI } from "../positions";
9
10
  import type { ProfileAPI } from "../profile";
11
+ import type { SubAccountsAPI } from "../sub-accounts";
10
12
  import type { TradingAPI, TradingMode } from "../trading";
11
13
  import type { VaultAPI } from "../vault";
12
14
  import type { ConditionalOrderEvent, OHLCVEvent, OrderbookEvent, OrderbookQuotationMode, OrderEvent, TradeEvent, UserBalanceEvent, UserMovementEvent } from "../websocket";
15
+ import type { WhitelistAPI } from "../whitelist";
16
+ import type { WithdrawalsAPI } from "../withdrawals";
13
17
  import type { Network } from "./network";
14
18
  /**
15
19
  * Configuration options for the Monaco SDK.
@@ -65,6 +69,8 @@ export interface MonacoSDK {
65
69
  delegatedAgents: DelegatedAgentsAPI;
66
70
  /** Vault operations API */
67
71
  vault: VaultAPI;
72
+ /** Low-level withdrawals API (initiate + fetch signed calldata) */
73
+ withdrawals: WithdrawalsAPI;
68
74
  /** Trading operations API */
69
75
  trading: TradingAPI;
70
76
  /** Market metadata API */
@@ -73,6 +79,12 @@ export interface MonacoSDK {
73
79
  marginAccounts: MarginAccountsAPI;
74
80
  /** Perp position operations API */
75
81
  positions: PositionsAPI;
82
+ /** Sub-account management API */
83
+ subAccounts: SubAccountsAPI;
84
+ /** Testnet faucet API */
85
+ faucet: FaucetAPI;
86
+ /** Public whitelist (waitlist) submission API */
87
+ whitelist: WhitelistAPI;
76
88
  /** Profile operations API */
77
89
  profile: ProfileAPI;
78
90
  /** Orderbook REST API for fetching orderbook snapshots */
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Sub-Accounts Types
3
+ *
4
+ * Types for managing sub-accounts and their per-asset spending limits. All
5
+ * endpoints are session-authenticated; the limit mutations additionally
6
+ * require the caller to be a master account with the `ManageSubAccounts`
7
+ * permission (enforced server-side). Wire shapes are snake_case; optional
8
+ * fields are `null` rather than omitted.
9
+ */
10
+ import type { BaseAPI } from "../api";
11
+ import type { AccountBalance } from "../profile";
12
+ /**
13
+ * A sub-account owned by the authenticated master account, with its balances.
14
+ */
15
+ export interface SubAccount {
16
+ /** Sub-account UUID */
17
+ id: string;
18
+ /** Sub-account wallet address */
19
+ address: string;
20
+ /** Sub-account display username */
21
+ username: string | null;
22
+ /** Whether the sub-account is allowed to withdraw */
23
+ can_withdraw: boolean;
24
+ /** Account creation timestamp (ISO 8601) */
25
+ created_at: string;
26
+ /** Per-asset balances held by the sub-account */
27
+ balances: AccountBalance[];
28
+ }
29
+ /**
30
+ * A per-asset spending limit on a sub-account.
31
+ */
32
+ export interface SubAccountLimit {
33
+ /** Limit UUID */
34
+ id: string;
35
+ /** Sub-account UUID this limit applies to */
36
+ sub_account_id: string;
37
+ /** Token contract address */
38
+ token: string;
39
+ /** Maximum daily spending limit in token units */
40
+ daily_limit: string | null;
41
+ /** Amount used today against the limit */
42
+ used_today: string;
43
+ /** Limit creation timestamp (ISO 8601) */
44
+ created_at: string;
45
+ /** Last update timestamp (ISO 8601) */
46
+ updated_at: string | null;
47
+ /** Master account UUID that owns this sub-account */
48
+ master_account_id: string;
49
+ /** Maximum amount allowed in token units */
50
+ max_amount: string;
51
+ /** Last reset timestamp for the daily limit (ISO 8601) */
52
+ last_reset_at: string | null;
53
+ /** Whether the limit is active */
54
+ is_active: boolean;
55
+ }
56
+ /**
57
+ * Body for creating a sub-account limit.
58
+ */
59
+ export interface CreateSubAccountLimitRequest {
60
+ /** Sub-account UUID to create the limit for */
61
+ sub_account_id: string;
62
+ /** Asset UUID to limit */
63
+ asset_id: string;
64
+ /** Maximum amount allowed in token units */
65
+ max_amount: string;
66
+ /** Maximum daily spending limit in token units */
67
+ daily_limit?: string;
68
+ }
69
+ /**
70
+ * Body for updating a sub-account limit. The sub-account and asset are taken
71
+ * from the path; all body fields are optional (partial update).
72
+ */
73
+ export interface UpdateSubAccountLimitBody {
74
+ /** New maximum amount allowed in token units */
75
+ max_amount?: string;
76
+ /** New maximum daily spending limit in token units */
77
+ daily_limit?: string;
78
+ /** Whether the limit is active */
79
+ is_active?: boolean;
80
+ }
81
+ /** Paginated list of the master account's sub-accounts. */
82
+ export interface ListSubAccountsResponse {
83
+ sub_accounts: SubAccount[];
84
+ /** Total number of sub-accounts */
85
+ total: number;
86
+ }
87
+ /** Response wrapping a single created limit. */
88
+ export interface CreateSubAccountLimitResponse {
89
+ limit: SubAccountLimit;
90
+ }
91
+ /** Response wrapping a single updated limit. */
92
+ export interface UpdateSubAccountLimitResponse {
93
+ limit: SubAccountLimit;
94
+ }
95
+ /** Response wrapping a sub-account's limits. */
96
+ export interface GetSubAccountLimitsResponse {
97
+ limits: SubAccountLimit[];
98
+ }
99
+ /**
100
+ * Sub-accounts API interface.
101
+ *
102
+ * `list` and `getLimits` need only session auth; `createLimit`, `updateLimit`,
103
+ * and `deleteLimit` additionally require the master account to hold the
104
+ * `ManageSubAccounts` permission (enforced server-side — a non-master or
105
+ * unpermissioned caller gets a 403).
106
+ */
107
+ export interface SubAccountsAPI extends BaseAPI {
108
+ /**
109
+ * Lists the authenticated master account's sub-accounts with balances.
110
+ *
111
+ * @returns Promise resolving to the sub-accounts and total count
112
+ */
113
+ list(): Promise<ListSubAccountsResponse>;
114
+ /**
115
+ * Creates a per-asset spending limit on a sub-account.
116
+ *
117
+ * @param body - Sub-account, asset, max amount, and optional daily limit
118
+ * @returns Promise resolving to the created limit
119
+ */
120
+ createLimit(body: CreateSubAccountLimitRequest): Promise<CreateSubAccountLimitResponse>;
121
+ /**
122
+ * Gets the limits configured for a sub-account.
123
+ *
124
+ * @param subAccountId - Sub-account UUID
125
+ * @returns Promise resolving to the sub-account's limits
126
+ */
127
+ getLimits(subAccountId: string): Promise<GetSubAccountLimitsResponse>;
128
+ /**
129
+ * Updates a sub-account's per-asset limit (partial update).
130
+ *
131
+ * @param subAccountId - Sub-account UUID
132
+ * @param assetId - Asset UUID
133
+ * @param body - Fields to update
134
+ * @returns Promise resolving to the updated limit
135
+ */
136
+ updateLimit(subAccountId: string, assetId: string, body: UpdateSubAccountLimitBody): Promise<UpdateSubAccountLimitResponse>;
137
+ /**
138
+ * Deletes a sub-account's per-asset limit.
139
+ *
140
+ * @param subAccountId - Sub-account UUID
141
+ * @param assetId - Asset UUID
142
+ * @returns Promise resolving when the limit is deleted
143
+ */
144
+ deleteLimit(subAccountId: string, assetId: string): Promise<void>;
145
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sub-Accounts Types
3
+ *
4
+ * Types for managing sub-accounts and their per-asset spending limits. All
5
+ * endpoints are session-authenticated; the limit mutations additionally
6
+ * require the caller to be a master account with the `ManageSubAccounts`
7
+ * permission (enforced server-side). Wire shapes are snake_case; optional
8
+ * fields are `null` rather than omitted.
9
+ */
@@ -29,6 +29,8 @@ export interface TradingAPI extends BaseAPI {
29
29
  expirationDate?: string;
30
30
  timeInForce?: TimeInForce;
31
31
  marginAccountId?: string;
32
+ marginBucketId?: string;
33
+ marginBucketCollateral?: string;
32
34
  strategyKey?: string;
33
35
  positionSide?: PositionSide;
34
36
  leverage?: string;
@@ -50,6 +52,8 @@ export interface TradingAPI extends BaseAPI {
50
52
  tradingMode?: TradingMode;
51
53
  slippageTolerance?: number;
52
54
  marginAccountId?: string;
55
+ marginBucketId?: string;
56
+ marginBucketCollateral?: string;
53
57
  strategyKey?: string;
54
58
  positionSide?: PositionSide;
55
59
  leverage?: string;
@@ -74,7 +74,9 @@ export interface CreateOrderResponse {
74
74
  match_result?: MatchResult;
75
75
  /** Resolved margin account ID for margin/perp orders */
76
76
  margin_account_id?: string;
77
- /** Resolved hidden strategy bucket key for auto margin buckets */
77
+ /** Resolved isolated margin bucket ID for bucket-scoped margin orders */
78
+ margin_bucket_id?: string;
79
+ /** Client strategy key carried for compatibility */
78
80
  strategy_key?: string;
79
81
  /** Delegated agent ID when submitted through a delegated session */
80
82
  delegation_id?: string;
@@ -286,7 +288,11 @@ export interface BatchCreateOrderParams {
286
288
  timeInForce?: Extract<TimeInForce, "GTC" | "IOC" | "FOK">;
287
289
  /** Margin account UUID for margin/perp orders */
288
290
  marginAccountId?: string;
289
- /** Optional strategy bucket key used when marginAccountId is omitted */
291
+ /** Existing isolated margin bucket UUID for bucket-scoped margin orders */
292
+ marginBucketId?: string;
293
+ /** Collateral to allocate into a new isolated margin bucket */
294
+ marginBucketCollateral?: string;
295
+ /** Client strategy key carried for compatibility */
290
296
  strategyKey?: string;
291
297
  /** Position side for margin/perp orders */
292
298
  positionSide?: PositionSide;
@@ -8,9 +8,14 @@ export declare const ListMarginAccountsSchema: z.ZodObject<{
8
8
  state: z.ZodOptional<z.ZodString>;
9
9
  tradingPairId: z.ZodOptional<z.ZodUUID>;
10
10
  }, z.core.$strip>;
11
- export declare const CreateMarginAccountSchema: z.ZodOptional<z.ZodObject<{
11
+ export declare const EnsureParentMarginAccountSchema: z.ZodOptional<z.ZodObject<{
12
12
  label: z.ZodOptional<z.ZodString>;
13
13
  collateralAsset: z.ZodOptional<z.ZodString>;
14
+ marginMode: z.ZodOptional<z.ZodEnum<{
15
+ ISOLATED: "ISOLATED";
16
+ CROSS: "CROSS";
17
+ }>>;
18
+ selectedTradingPairIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
14
19
  }, z.core.$strip>>;
15
20
  export declare const GetMarginAccountSummarySchema: z.ZodObject<{
16
21
  marginAccountId: z.ZodUUID;
@@ -11,10 +11,20 @@ export const ListMarginAccountsSchema = PaginationSchema.extend({
11
11
  state: z.string().trim().min(1, "State cannot be empty").optional(),
12
12
  tradingPairId: UUIDSchema.optional(),
13
13
  });
14
- export const CreateMarginAccountSchema = z
14
+ export const EnsureParentMarginAccountSchema = z
15
15
  .object({
16
16
  label: z.string().trim().min(1, "Label cannot be empty").optional(),
17
17
  collateralAsset: z.string().trim().min(1, "Collateral asset cannot be empty").optional(),
18
+ marginMode: z.enum(["ISOLATED", "CROSS"]).optional(),
19
+ selectedTradingPairIds: z.array(UUIDSchema).optional(),
20
+ })
21
+ .refine((data) => data.marginMode !== "CROSS" || (data.selectedTradingPairIds?.length ?? 0) > 0, {
22
+ message: "selectedTradingPairIds is required when marginMode is CROSS",
23
+ path: ["selectedTradingPairIds"],
24
+ })
25
+ .refine((data) => data.marginMode === "CROSS" || (data.selectedTradingPairIds?.length ?? 0) === 0, {
26
+ message: "selectedTradingPairIds can only be set when marginMode is CROSS",
27
+ path: ["selectedTradingPairIds"],
18
28
  })
19
29
  .optional();
20
30
  export const GetMarginAccountSummarySchema = z.object({
@@ -67,3 +67,10 @@ export declare const GetUserTradesSchema: z.ZodObject<{
67
67
  page_size: z.ZodOptional<z.ZodNumber>;
68
68
  trading_pair_id: z.ZodOptional<z.ZodUUID>;
69
69
  }, z.core.$strip>;
70
+ export declare const ListFundingPaymentsSchema: z.ZodObject<{
71
+ page: z.ZodOptional<z.ZodNumber>;
72
+ page_size: z.ZodOptional<z.ZodNumber>;
73
+ trading_pair_id: z.ZodOptional<z.ZodUUID>;
74
+ position_id: z.ZodOptional<z.ZodUUID>;
75
+ margin_account_id: z.ZodOptional<z.ZodUUID>;
76
+ }, z.core.$strip>;
@@ -42,3 +42,10 @@ export const GetUserTradesSchema = z.object({
42
42
  page_size: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
43
43
  trading_pair_id: UUIDSchema.optional(),
44
44
  });
45
+ export const ListFundingPaymentsSchema = z.object({
46
+ page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
47
+ page_size: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
48
+ trading_pair_id: UUIDSchema.optional(),
49
+ position_id: UUIDSchema.optional(),
50
+ margin_account_id: UUIDSchema.optional(),
51
+ });
@@ -101,6 +101,8 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
101
101
  FOK: "FOK";
102
102
  }>>;
103
103
  marginAccountId: z.ZodOptional<z.ZodUUID>;
104
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
105
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
104
106
  strategyKey: z.ZodOptional<z.ZodString>;
105
107
  positionSide: z.ZodOptional<z.ZodEnum<{
106
108
  LONG: "LONG";
@@ -156,6 +158,8 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
156
158
  }>>;
157
159
  slippageTolerance: z.ZodOptional<z.ZodNumber>;
158
160
  marginAccountId: z.ZodOptional<z.ZodUUID>;
161
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
162
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
159
163
  strategyKey: z.ZodOptional<z.ZodString>;
160
164
  positionSide: z.ZodOptional<z.ZodEnum<{
161
165
  LONG: "LONG";
@@ -349,6 +353,8 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
349
353
  FOK: "FOK";
350
354
  }>>;
351
355
  marginAccountId: z.ZodOptional<z.ZodUUID>;
356
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
357
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
352
358
  strategyKey: z.ZodOptional<z.ZodString>;
353
359
  positionSide: z.ZodOptional<z.ZodEnum<{
354
360
  LONG: "LONG";
@@ -389,6 +395,8 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
389
395
  FOK: "FOK";
390
396
  }>>;
391
397
  marginAccountId: z.ZodOptional<z.ZodUUID>;
398
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
399
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
392
400
  strategyKey: z.ZodOptional<z.ZodString>;
393
401
  positionSide: z.ZodOptional<z.ZodEnum<{
394
402
  LONG: "LONG";
@@ -117,6 +117,8 @@ export const PlaceLimitOrderSchema = z
117
117
  expirationDate: ISO8601DateSchema.optional(),
118
118
  timeInForce: TimeInForceSchema.optional(),
119
119
  marginAccountId: UUIDSchema.optional(),
120
+ marginBucketId: UUIDSchema.optional(),
121
+ marginBucketCollateral: PositiveDecimalStringSchema.optional(),
120
122
  strategyKey: z.string().min(1).max(128).optional(),
121
123
  positionSide: PositionSideSchema.optional(),
122
124
  leverage: PositiveDecimalStringSchema.optional(),
@@ -145,6 +147,18 @@ export const PlaceLimitOrderSchema = z
145
147
  .refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
146
148
  message: "Parent TP/SL cannot be attached to reduceOnly orders",
147
149
  path: ["options", "reduceOnly"],
150
+ })
151
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
152
+ message: "marginBucketCollateral is only supported for MARGIN orders",
153
+ path: ["options", "tradingMode"],
154
+ })
155
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.marginBucketId === undefined, {
156
+ message: "marginBucketCollateral creates a new bucket and cannot be combined with marginBucketId",
157
+ path: ["options", "marginBucketId"],
158
+ })
159
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.reduceOnly !== true, {
160
+ message: "reduceOnly orders cannot create a new margin bucket",
161
+ path: ["options", "reduceOnly"],
148
162
  });
149
163
  /**
150
164
  * Place Market Order validation schema
@@ -159,6 +173,8 @@ export const PlaceMarketOrderSchema = z
159
173
  tradingMode: TradingModeSchema.optional(),
160
174
  slippageTolerance: SlippageToleranceSchema,
161
175
  marginAccountId: UUIDSchema.optional(),
176
+ marginBucketId: UUIDSchema.optional(),
177
+ marginBucketCollateral: PositiveDecimalStringSchema.optional(),
162
178
  strategyKey: z.string().min(1).max(128).optional(),
163
179
  positionSide: PositionSideSchema.optional(),
164
180
  leverage: PositiveDecimalStringSchema.optional(),
@@ -187,6 +203,18 @@ export const PlaceMarketOrderSchema = z
187
203
  .refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
188
204
  message: "Parent TP/SL cannot be attached to reduceOnly orders",
189
205
  path: ["options", "reduceOnly"],
206
+ })
207
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
208
+ message: "marginBucketCollateral is only supported for MARGIN orders",
209
+ path: ["options", "tradingMode"],
210
+ })
211
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.marginBucketId === undefined, {
212
+ message: "marginBucketCollateral creates a new bucket and cannot be combined with marginBucketId",
213
+ path: ["options", "marginBucketId"],
214
+ })
215
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.reduceOnly !== true, {
216
+ message: "reduceOnly orders cannot create a new margin bucket",
217
+ path: ["options", "reduceOnly"],
190
218
  });
191
219
  /**
192
220
  * Cancel Order validation schema
@@ -303,6 +331,8 @@ export const BatchCreateOrderItemSchema = z
303
331
  expirationDate: ISO8601DateSchema.optional(),
304
332
  timeInForce: TimeInForceSchema.optional(),
305
333
  marginAccountId: UUIDSchema.optional(),
334
+ marginBucketId: UUIDSchema.optional(),
335
+ marginBucketCollateral: PositiveDecimalStringSchema.optional(),
306
336
  strategyKey: z.string().min(1).max(128).optional(),
307
337
  positionSide: PositionSideSchema.optional(),
308
338
  leverage: PositiveDecimalStringSchema.optional(),
@@ -315,6 +345,18 @@ export const BatchCreateOrderItemSchema = z
315
345
  .refine((data) => data.orderType !== "MARKET" || data.price === undefined, {
316
346
  message: "Price must not be provided for MARKET orders",
317
347
  path: ["price"],
348
+ })
349
+ .refine((data) => data.marginBucketCollateral === undefined || data.tradingMode === "MARGIN", {
350
+ message: "marginBucketCollateral is only supported for MARGIN orders",
351
+ path: ["tradingMode"],
352
+ })
353
+ .refine((data) => data.marginBucketCollateral === undefined || data.marginBucketId === undefined, {
354
+ message: "marginBucketCollateral creates a new bucket and cannot be combined with marginBucketId",
355
+ path: ["marginBucketId"],
356
+ })
357
+ .refine((data) => data.marginBucketCollateral === undefined || data.reduceOnly !== true, {
358
+ message: "reduceOnly orders cannot create a new margin bucket",
359
+ path: ["reduceOnly"],
318
360
  })
319
361
  .refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
320
362
  message: "positionSide is required for MARGIN orders",