@0xmonaco/types 0.8.7-develop.0e951a5 → 0.8.7-develop.0f12336

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 (63) hide show
  1. package/README.md +5 -3
  2. package/dist/api/index.d.ts +7 -0
  3. package/dist/applications/index.d.ts +47 -5
  4. package/dist/applications/index.js +2 -1
  5. package/dist/applications/requests.d.ts +78 -0
  6. package/dist/applications/requests.js +7 -0
  7. package/dist/applications/responses.d.ts +213 -2
  8. package/dist/applications/responses.js +3 -1
  9. package/dist/auth/index.d.ts +6 -12
  10. package/dist/auth/index.js +2 -2
  11. package/dist/auth/responses.d.ts +2 -12
  12. package/dist/contracts/balances.d.ts +1 -1
  13. package/dist/delegated-agents/index.d.ts +35 -18
  14. package/dist/faucet/index.d.ts +54 -0
  15. package/dist/faucet/index.js +10 -0
  16. package/dist/fees/index.d.ts +4 -4
  17. package/dist/fees/responses.d.ts +17 -17
  18. package/dist/fees/responses.js +20 -20
  19. package/dist/index.d.ts +4 -0
  20. package/dist/index.js +4 -0
  21. package/dist/margin-accounts/index.d.ts +91 -55
  22. package/dist/market/index.d.ts +214 -95
  23. package/dist/positions/index.d.ts +67 -44
  24. package/dist/profile/index.d.ts +156 -70
  25. package/dist/sdk/index.d.ts +24 -3
  26. package/dist/sub-accounts/index.d.ts +146 -0
  27. package/dist/sub-accounts/index.js +9 -0
  28. package/dist/trading/index.d.ts +8 -8
  29. package/dist/trading/orders.d.ts +20 -20
  30. package/dist/trading/responses.d.ts +81 -100
  31. package/dist/validation/margin-accounts.d.ts +53 -13
  32. package/dist/validation/margin-accounts.js +38 -14
  33. package/dist/validation/market.d.ts +1 -1
  34. package/dist/validation/market.js +1 -1
  35. package/dist/validation/positions.d.ts +11 -7
  36. package/dist/validation/positions.js +10 -6
  37. package/dist/validation/profile.d.ts +13 -6
  38. package/dist/validation/profile.js +13 -6
  39. package/dist/validation/trading.d.ts +17 -42
  40. package/dist/validation/trading.js +51 -42
  41. package/dist/validation/vault.d.ts +8 -0
  42. package/dist/validation/vault.js +3 -0
  43. package/dist/vault/index.d.ts +46 -13
  44. package/dist/vault/responses.d.ts +50 -12
  45. package/dist/websocket/events/balance-events.d.ts +2 -1
  46. package/dist/websocket/events/movement-events.d.ts +2 -1
  47. package/dist/whitelist/index.d.ts +44 -0
  48. package/dist/whitelist/index.js +10 -0
  49. package/dist/wire/assert.d.ts +54 -0
  50. package/dist/wire/assert.js +0 -0
  51. package/dist/wire/audit.d.ts +47 -0
  52. package/dist/wire/audit.js +43 -0
  53. package/dist/wire/coverage.d.ts +1 -0
  54. package/dist/wire/coverage.js +0 -0
  55. package/dist/wire/index.d.ts +21 -0
  56. package/dist/wire/index.js +2 -0
  57. package/dist/wire/operations.d.ts +15 -0
  58. package/dist/wire/operations.js +101 -0
  59. package/dist/wire/schema.d.ts +8930 -0
  60. package/dist/wire/schema.js +4 -0
  61. package/dist/withdrawals/index.d.ts +114 -0
  62. package/dist/withdrawals/index.js +0 -0
  63. package/package.json +6 -2
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Types for user profile operations including fetching user profile data.
5
5
  */
6
+ import type { Address } from "viem";
6
7
  import type { BaseAPI } from "../api";
7
8
  import type { OrderSide, OrderStatus, OrderType, TimeInForce } from "../trading";
8
9
  /**
@@ -15,7 +16,7 @@ export interface ProfileMovement {
15
16
  /** Movement type */
16
17
  type: "deposit" | "withdrawal" | "trade" | "transfer" | string;
17
18
  /** Token address */
18
- token: string;
19
+ token: Address;
19
20
  /** Amount of the movement (as string to preserve precision) */
20
21
  amount: string;
21
22
  /** Movement timestamp (ISO string) */
@@ -35,47 +36,53 @@ export interface LedgerMovement {
35
36
  /** Movement unique identifier */
36
37
  id: string;
37
38
  /** Type of entry (Credit, Debit) */
38
- entry_type: string;
39
+ entryType: string;
39
40
  /** Type of transaction (Deposit, Withdrawal, Trade, etc.) */
40
- transaction_type: string;
41
+ transactionType: string;
41
42
  /** Transaction amount (normalized, human-readable) */
42
43
  amount: string;
43
44
  /** Transaction amount in raw format (wei) */
44
- amount_raw: string;
45
+ amountRaw: string;
45
46
  /** Token contract address */
46
- token: string;
47
+ token: Address;
47
48
  /** Token symbol */
48
49
  symbol: string | null;
49
50
  /** Token decimals */
50
51
  decimals: number;
51
52
  /** Balance before this transaction (normalized) */
52
- balance_before: string | null;
53
+ balanceBefore: string | null;
53
54
  /** Balance before in raw format (wei) */
54
- balance_before_raw: string | null;
55
+ balanceBeforeRaw: string | null;
55
56
  /** Balance after this transaction (normalized) */
56
- balance_after: string | null;
57
+ balanceAfter: string | null;
57
58
  /** Balance after in raw format (wei) */
58
- balance_after_raw: string | null;
59
+ balanceAfterRaw: string | null;
59
60
  /** Locked balance before transaction (normalized) */
60
- locked_before: string | null;
61
+ lockedBefore: string | null;
61
62
  /** Locked balance before in raw format (wei) */
62
- locked_before_raw: string | null;
63
+ lockedBeforeRaw: string | null;
63
64
  /** Locked balance after transaction (normalized) */
64
- locked_after: string | null;
65
+ lockedAfter: string | null;
65
66
  /** Locked balance after in raw format (wei) */
66
- locked_after_raw: string | null;
67
+ lockedAfterRaw: string | null;
67
68
  /** Reference identifier for related operations */
68
- reference_id: string | null;
69
+ referenceId: string | null;
69
70
  /** Reference type */
70
- reference_type: string | null;
71
+ referenceType: string | null;
71
72
  /** Human readable description */
72
73
  description: string | null;
73
74
  /** Blockchain transaction hash */
74
- tx_hash: string | null;
75
+ txHash: string | null;
75
76
  /** Blockchain block number */
76
- block_number: number | null;
77
+ blockNumber: number | null;
77
78
  /** Transaction timestamp */
78
- created_at: string | null;
79
+ createdAt: string | null;
80
+ /** Asset UUID this movement affects */
81
+ assetId?: string | null;
82
+ /** User UUID who owns this movement */
83
+ userId?: string | null;
84
+ /** Balance UUID this movement affects */
85
+ balanceId?: string | null;
79
86
  }
80
87
  /**
81
88
  * Ledger entry type for filtering movements.
@@ -94,13 +101,13 @@ export interface GetUserMovementsParams {
94
101
  /** Page number (starts from 1) */
95
102
  page?: number;
96
103
  /** Number of items per page (max 100) */
97
- page_size?: number;
104
+ pageSize?: number;
98
105
  /** Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE) */
99
- entry_type?: LedgerEntryType;
106
+ entryType?: LedgerEntryType;
100
107
  /** Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD) */
101
- transaction_type?: TransactionType;
108
+ transactionType?: TransactionType;
102
109
  /** Filter by asset ID (UUID) */
103
- asset_id?: string;
110
+ assetId?: string;
104
111
  }
105
112
  /**
106
113
  * Query parameters for getting user balances
@@ -109,7 +116,7 @@ export interface GetUserBalancesParams {
109
116
  /** Page number (starts from 1) */
110
117
  page?: number;
111
118
  /** Number of items per page (max 100) */
112
- page_size?: number;
119
+ pageSize?: number;
113
120
  }
114
121
  /**
115
122
  * Response from getting user movements
@@ -126,11 +133,11 @@ export interface GetPaginatedUserMovementsResponse {
126
133
  /** Current page number */
127
134
  page: number;
128
135
  /** Items per page */
129
- page_size: number;
136
+ pageSize: number;
130
137
  /** Total number of movements in PostgreSQL */
131
138
  total: number;
132
139
  /** Total number of pages */
133
- total_pages: number;
140
+ totalPages: number;
134
141
  }
135
142
  /**
136
143
  * Response from getting user balances
@@ -141,11 +148,11 @@ export interface GetUserBalancesResponse {
141
148
  /** Total number of balances */
142
149
  total: number;
143
150
  /** Items per page */
144
- page_size: number;
151
+ pageSize: number;
145
152
  /** Current page number */
146
153
  page: number;
147
154
  /** Total number of pages */
148
- total_pages: number;
155
+ totalPages: number;
149
156
  }
150
157
  /**
151
158
  * Order information for recent orders.
@@ -159,7 +166,7 @@ export interface ProfileOrder {
159
166
  /** Order side */
160
167
  side: OrderSide;
161
168
  /** Order type */
162
- order_type: OrderType;
169
+ orderType: OrderType;
163
170
  /** Order price (null for market orders) */
164
171
  price: string | null;
165
172
  /** Order quantity */
@@ -167,11 +174,11 @@ export interface ProfileOrder {
167
174
  /** Order status */
168
175
  status: OrderStatus;
169
176
  /** Time in force */
170
- time_in_force?: TimeInForce;
177
+ timeInForce?: TimeInForce;
171
178
  /** Order creation timestamp (ISO string) */
172
- created_at: string;
179
+ createdAt: string;
173
180
  /** Order last update timestamp (ISO string) */
174
- updated_at?: string;
181
+ updatedAt?: string;
175
182
  }
176
183
  /**
177
184
  * Account balance for a specific token.
@@ -179,48 +186,46 @@ export interface ProfileOrder {
179
186
  */
180
187
  export interface AccountBalance {
181
188
  /** Asset ID (UUID for API calls) */
182
- asset_id: string;
189
+ assetId: string;
183
190
  /** Token address */
184
- token: string;
191
+ token: Address;
185
192
  /** Token symbol */
186
193
  symbol: string | null;
187
194
  /** Decimal places for the token */
188
195
  decimals: number;
189
196
  /** Available balance for trading (normalized) */
190
- available_balance: string;
197
+ availableBalance: string;
191
198
  /** Locked balance (in orders or pending operations, normalized) */
192
- locked_balance: string;
193
- /** Collateral posted into margin (perps) accounts (normalized) */
194
- margin_locked: string;
195
- /** Total balance (available + locked + margin_locked, normalized) */
196
- total_balance: string;
199
+ lockedBalance: string;
200
+ /** Total balance (available + locked, normalized) */
201
+ totalBalance: string;
197
202
  /** Available balance in raw format (wei) */
198
- available_balance_raw: string;
203
+ availableBalanceRaw: string;
199
204
  /** Locked balance in raw format (wei) */
200
- locked_balance_raw: string;
201
- /** Margin-locked balance in raw format (wei) */
202
- margin_locked_raw: string;
205
+ lockedBalanceRaw: string;
206
+ /** Total balance (available + locked) in raw format (wei) */
207
+ totalBalanceRaw: string;
203
208
  }
204
209
  /**
205
210
  * A single user trade execution.
206
211
  */
207
212
  export interface UserTrade {
208
213
  /** Trade unique identifier */
209
- trade_id: string;
214
+ tradeId: string;
210
215
  /** Trading pair identifier (UUID) */
211
- trading_pair_id: string;
216
+ tradingPairId: string;
212
217
  /** Execution price (as string to preserve precision) */
213
218
  price: string;
214
219
  /** Executed quantity (as string to preserve precision) */
215
220
  quantity: string;
216
221
  /** Quote volume (price * quantity, as string to preserve precision) */
217
- quote_volume: string;
222
+ quoteVolume: string;
218
223
  /** Side of the trade */
219
224
  side: OrderSide;
220
225
  /** Fee paid for this trade (as string to preserve precision) */
221
226
  fee: string;
222
227
  /** Timestamp when the trade was executed (ISO string) */
223
- executed_at: string;
228
+ executedAt: string;
224
229
  }
225
230
  /**
226
231
  * Query parameters for getting user trades
@@ -229,9 +234,9 @@ export interface GetUserTradesParams {
229
234
  /** Page number (starts from 1) */
230
235
  page?: number;
231
236
  /** Number of items per page (max 100) */
232
- page_size?: number;
237
+ pageSize?: number;
233
238
  /** Filter by trading pair ID (UUID) */
234
- trading_pair_id?: string;
239
+ tradingPairId?: string;
235
240
  }
236
241
  /**
237
242
  * Response from getting user trades
@@ -242,11 +247,72 @@ export interface GetUserTradesResponse {
242
247
  /** Current page number */
243
248
  page: number;
244
249
  /** Items per page */
245
- page_size: number;
250
+ pageSize: number;
246
251
  /** Total number of trades */
247
252
  total: number;
248
253
  /** Total number of pages */
249
- total_pages: number;
254
+ totalPages: number;
255
+ }
256
+ /**
257
+ * Direction of a funding payment from the user's perspective.
258
+ */
259
+ export type FundingDirection = "PAID" | "RECEIVED";
260
+ /**
261
+ * A single funding payment settled against a margin position.
262
+ */
263
+ export interface FundingPayment {
264
+ /** Funding payment unique identifier (UUID) */
265
+ id: string;
266
+ /** Margin position identifier (UUID) */
267
+ positionId: string;
268
+ /** Margin account identifier (UUID) */
269
+ marginAccountId: string;
270
+ /** Trading pair identifier (UUID) */
271
+ tradingPairId: string;
272
+ /** Funding rate applied for the epoch (as string to preserve precision) */
273
+ fundingRate: string;
274
+ /** Absolute position size at settlement (as string to preserve precision) */
275
+ positionSize: string;
276
+ /** Signed funding amount; positive means paid, negative means received (as string) */
277
+ paymentAmount: string;
278
+ /** Funding direction for the user */
279
+ direction: FundingDirection;
280
+ /** Funding window start timestamp (ISO 8601), if known */
281
+ periodStart?: string;
282
+ /** Funding window end timestamp (ISO 8601), if known */
283
+ periodEnd?: string;
284
+ /** Funding payment creation timestamp (ISO 8601), if known */
285
+ createdAt?: string;
286
+ }
287
+ /**
288
+ * Query parameters for listing funding payments.
289
+ */
290
+ export interface ListFundingPaymentsParams {
291
+ /** Page number (starts from 1) */
292
+ page?: number;
293
+ /** Number of items per page (max 100) */
294
+ pageSize?: number;
295
+ /** Filter by trading pair ID (UUID) */
296
+ tradingPairId?: string;
297
+ /** Filter by margin position ID (UUID) */
298
+ positionId?: string;
299
+ /** Filter by margin account ID (UUID) */
300
+ marginAccountId?: string;
301
+ }
302
+ /**
303
+ * Response from listing funding payments.
304
+ */
305
+ export interface ListFundingPaymentsResponse {
306
+ /** List of funding payment records */
307
+ records: FundingPayment[];
308
+ /** Current page number */
309
+ page: number;
310
+ /** Items per page */
311
+ pageSize: number;
312
+ /** Total number of matching records */
313
+ total: number;
314
+ /** Total number of pages */
315
+ totalPages: number;
250
316
  }
251
317
  /**
252
318
  * Time period for portfolio stats and chart queries.
@@ -284,20 +350,20 @@ export interface PortfolioChartResponse {
284
350
  export interface PortfolioStats {
285
351
  /** Realized profit and loss (sum of CREDIT minus DEBIT from TRADE ledger entries) */
286
352
  pnl: string;
287
- /** Total trading volume (sum of quote_volume from trades) */
353
+ /** Total trading volume (sum of quoteVolume from trades) */
288
354
  volume: string;
289
355
  /** Maximum peak-to-trough drawdown on running PnL */
290
- max_drawdown: string;
356
+ maxDrawdown: string;
291
357
  /** Total number of orders placed */
292
- total_orders: number;
358
+ totalOrders: number;
293
359
  /** Total number of trades executed */
294
- total_trades: number;
360
+ totalTrades: number;
295
361
  /** Total fees paid */
296
- fees_paid: string;
362
+ feesPaid: string;
297
363
  /** Ratio of profitable trades to total trades */
298
- win_loss_ratio: string;
364
+ winLossRatio: string;
299
365
  /** Total equity in USDC terms (sum of all spot balances) */
300
- total_equity: string;
366
+ totalEquity: string;
301
367
  }
302
368
  /**
303
369
  * User profile information returned by the /api/v1/accounts/me endpoint.
@@ -306,19 +372,23 @@ export interface UserProfile {
306
372
  /** Unique identifier for the user */
307
373
  id: string;
308
374
  /** Wallet address of the user */
309
- address: string;
375
+ address: Address;
310
376
  /** Username of the user (can be null) */
311
377
  username: string | null;
312
378
  /** Account type (e.g., "master") */
313
- account_type: string;
379
+ accountType: string;
314
380
  /** Whether the user can withdraw funds */
315
- can_withdraw: boolean;
381
+ canWithdraw: boolean;
316
382
  /** Taker fee rate in basis points */
317
- taker_fee_bps: number;
383
+ takerFeeBps: number;
318
384
  /** Maker fee rate in basis points */
319
- maker_fee_bps: number;
385
+ makerFeeBps: number;
320
386
  /** Account creation timestamp (ISO string) */
321
- created_at: string;
387
+ createdAt: string;
388
+ /** Additional taker fee in basis points contributed by the application (if any) */
389
+ applicationTakerFeeBps?: number;
390
+ /** Additional maker fee in basis points contributed by the application (if any) */
391
+ applicationMakerFeeBps?: number;
322
392
  }
323
393
  /**
324
394
  * Profile API interface.
@@ -343,9 +413,9 @@ export interface ProfileAPI extends BaseAPI {
343
413
  * @param params - Optional query parameters for pagination and filtering
344
414
  * @param params.page - Page number (starts from 1)
345
415
  * @param params.limit - Number of items per page (max 100)
346
- * @param params.entry_type - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
347
- * @param params.transaction_type - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
348
- * @param params.asset_id - Filter by asset ID (UUID)
416
+ * @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
417
+ * @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
418
+ * @param params.assetId - Filter by asset ID (UUID)
349
419
  * @returns Promise resolving to paginated movements response
350
420
  */
351
421
  getPaginatedUserMovements(params?: GetUserMovementsParams): Promise<GetPaginatedUserMovementsResponse>;
@@ -364,7 +434,7 @@ export interface ProfileAPI extends BaseAPI {
364
434
  /**
365
435
  * Get the current user's balance for a specific asset.
366
436
  *
367
- * Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{asset_id} endpoint.
437
+ * Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{assetId} endpoint.
368
438
  * Requires a valid access token to be set. If no balance exists for a valid asset, returns zero balances.
369
439
  *
370
440
  * @param assetId - The asset identifier (UUID)
@@ -401,9 +471,25 @@ export interface ProfileAPI extends BaseAPI {
401
471
  * @param params - Optional query parameters for pagination and filtering
402
472
  * @param params.page - Page number (starts from 1)
403
473
  * @param params.limit - Number of items per page (max 100)
404
- * @param params.trading_pair_id - Filter by trading pair ID (UUID)
474
+ * @param params.tradingPairId - Filter by trading pair ID (UUID)
405
475
  * @returns Promise resolving to paginated trades response
406
- * @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.
476
+ * @throws ValidationError If pagination params (page/limit) are invalid or tradingPairId is not a valid UUID; this may occur before any network request.
407
477
  */
408
478
  getUserTrades(params?: GetUserTradesParams): Promise<GetUserTradesResponse>;
479
+ /**
480
+ * List the current user's funding payment history with pagination and filters.
481
+ *
482
+ * Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
483
+ * Requires a valid access token to be set.
484
+ *
485
+ * @param params - Optional query parameters for pagination and filtering
486
+ * @param params.page - Page number (starts from 1)
487
+ * @param params.pageSize - Number of items per page (max 100)
488
+ * @param params.tradingPairId - Filter by trading pair ID (UUID)
489
+ * @param params.positionId - Filter by margin position ID (UUID)
490
+ * @param params.marginAccountId - Filter by margin account ID (UUID)
491
+ * @returns Promise resolving to paginated funding payments response
492
+ * @throws ValidationError If pagination params or a UUID filter are invalid; this may occur before any network request.
493
+ */
494
+ listFundingPayments(params?: ListFundingPaymentsParams): Promise<ListFundingPaymentsResponse>;
409
495
  }
@@ -1,15 +1,19 @@
1
- import type { PublicClient, TransactionReceipt, WalletClient } from "viem";
1
+ import type { Address, 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 */
@@ -94,7 +106,7 @@ export interface MonacoSDK {
94
106
  /** Page number (starts from 1, default: 1) */
95
107
  page?: number;
96
108
  /** Maximum number of records to return (default: 25, max: 100) */
97
- page_size?: number;
109
+ pageSize?: number;
98
110
  }) => Promise<TradeEvent[]>;
99
111
  };
100
112
  /** WebSocket client for real-time data (orders, orderbook, ohlcv) */
@@ -125,6 +137,15 @@ export interface MonacoSDK {
125
137
  login(clientId: string, options?: {
126
138
  connectWebSocket?: boolean;
127
139
  }): Promise<AuthState>;
140
+ /**
141
+ * Create and adopt an owner-scoped delegated session.
142
+ *
143
+ * The current authenticated session must belong to an agent wallet that has
144
+ * an active delegation from `ownerUserId`. On success, the SDK signs
145
+ * subsequent requests with the delegated session keypair, so account reads
146
+ * and trading calls operate on the owner while preserving agent attribution.
147
+ */
148
+ loginAsDelegatedOwner(ownerUserId: string): Promise<AuthState>;
128
149
  /** Log out the user */
129
150
  logout(): Promise<void>;
130
151
  /** Refresh the access token */
@@ -136,7 +157,7 @@ export interface MonacoSDK {
136
157
  /** Check connection status */
137
158
  isConnected(): boolean;
138
159
  /** Get the current account address */
139
- getAccountAddress(): string;
160
+ getAccountAddress(): Address;
140
161
  /** Get the current network ('mainnet' or 'testnet') */
141
162
  getNetwork(): Network;
142
163
  /** Get the current chain ID */
@@ -0,0 +1,146 @@
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 { Address } from "viem";
11
+ import type { BaseAPI } from "../api";
12
+ import type { AccountBalance } from "../profile";
13
+ /**
14
+ * A sub-account owned by the authenticated master account, with its balances.
15
+ */
16
+ export interface SubAccount {
17
+ /** Sub-account UUID */
18
+ id: string;
19
+ /** Sub-account wallet address */
20
+ address: Address;
21
+ /** Sub-account display username */
22
+ username: string | null;
23
+ /** Whether the sub-account is allowed to withdraw */
24
+ canWithdraw: boolean;
25
+ /** Account creation timestamp (ISO 8601) */
26
+ createdAt: string;
27
+ /** Per-asset balances held by the sub-account */
28
+ balances: AccountBalance[];
29
+ }
30
+ /**
31
+ * A per-asset spending limit on a sub-account.
32
+ */
33
+ export interface SubAccountLimit {
34
+ /** Limit UUID */
35
+ id: string;
36
+ /** Sub-account UUID this limit applies to */
37
+ subAccountId: string;
38
+ /** Token contract address */
39
+ token: Address;
40
+ /** Maximum daily spending limit in token units */
41
+ dailyLimit: string | null;
42
+ /** Amount used today against the limit */
43
+ usedToday: string;
44
+ /** Limit creation timestamp (ISO 8601) */
45
+ createdAt: string;
46
+ /** Last update timestamp (ISO 8601) */
47
+ updatedAt: string | null;
48
+ /** Master account UUID that owns this sub-account */
49
+ masterAccountId: string;
50
+ /** Maximum amount allowed in token units */
51
+ maxAmount: string;
52
+ /** Last reset timestamp for the daily limit (ISO 8601) */
53
+ lastResetAt: string | null;
54
+ /** Whether the limit is active */
55
+ isActive: boolean;
56
+ }
57
+ /**
58
+ * Body for creating a sub-account limit.
59
+ */
60
+ export interface CreateSubAccountLimitRequest {
61
+ /** Sub-account UUID to create the limit for */
62
+ subAccountId: string;
63
+ /** Asset UUID to limit */
64
+ assetId: string;
65
+ /** Maximum amount allowed in token units */
66
+ maxAmount: string;
67
+ /** Maximum daily spending limit in token units */
68
+ dailyLimit?: string;
69
+ }
70
+ /**
71
+ * Body for updating a sub-account limit. The sub-account and asset are taken
72
+ * from the path; all body fields are optional (partial update).
73
+ */
74
+ export interface UpdateSubAccountLimitBody {
75
+ /** New maximum amount allowed in token units */
76
+ maxAmount?: string;
77
+ /** New maximum daily spending limit in token units */
78
+ dailyLimit?: string;
79
+ /** Whether the limit is active */
80
+ isActive?: boolean;
81
+ }
82
+ /** Paginated list of the master account's sub-accounts. */
83
+ export interface ListSubAccountsResponse {
84
+ subAccounts: SubAccount[];
85
+ /** Total number of sub-accounts */
86
+ total: number;
87
+ }
88
+ /** Response wrapping a single created limit. */
89
+ export interface CreateSubAccountLimitResponse {
90
+ limit: SubAccountLimit;
91
+ }
92
+ /** Response wrapping a single updated limit. */
93
+ export interface UpdateSubAccountLimitResponse {
94
+ limit: SubAccountLimit;
95
+ }
96
+ /** Response wrapping a sub-account's limits. */
97
+ export interface GetSubAccountLimitsResponse {
98
+ limits: SubAccountLimit[];
99
+ }
100
+ /**
101
+ * Sub-accounts API interface.
102
+ *
103
+ * `list` and `getLimits` need only session auth; `createLimit`, `updateLimit`,
104
+ * and `deleteLimit` additionally require the master account to hold the
105
+ * `ManageSubAccounts` permission (enforced server-side — a non-master or
106
+ * unpermissioned caller gets a 403).
107
+ */
108
+ export interface SubAccountsAPI extends BaseAPI {
109
+ /**
110
+ * Lists the authenticated master account's sub-accounts with balances.
111
+ *
112
+ * @returns Promise resolving to the sub-accounts and total count
113
+ */
114
+ list(): Promise<ListSubAccountsResponse>;
115
+ /**
116
+ * Creates a per-asset spending limit on a sub-account.
117
+ *
118
+ * @param body - Sub-account, asset, max amount, and optional daily limit
119
+ * @returns Promise resolving to the created limit
120
+ */
121
+ createLimit(body: CreateSubAccountLimitRequest): Promise<CreateSubAccountLimitResponse>;
122
+ /**
123
+ * Gets the limits configured for a sub-account.
124
+ *
125
+ * @param subAccountId - Sub-account UUID
126
+ * @returns Promise resolving to the sub-account's limits
127
+ */
128
+ getLimits(subAccountId: string): Promise<GetSubAccountLimitsResponse>;
129
+ /**
130
+ * Updates a sub-account's per-asset limit (partial update).
131
+ *
132
+ * @param subAccountId - Sub-account UUID
133
+ * @param assetId - Asset UUID
134
+ * @param body - Fields to update
135
+ * @returns Promise resolving to the updated limit
136
+ */
137
+ updateLimit(subAccountId: string, assetId: string, body: UpdateSubAccountLimitBody): Promise<UpdateSubAccountLimitResponse>;
138
+ /**
139
+ * Deletes a sub-account's per-asset limit.
140
+ *
141
+ * @param subAccountId - Sub-account UUID
142
+ * @param assetId - Asset UUID
143
+ * @returns Promise resolving when the limit is deleted
144
+ */
145
+ deleteLimit(subAccountId: string, assetId: string): Promise<void>;
146
+ }
@@ -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
+ */