@0xmonaco/types 0.8.7 → 0.8.10

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 (48) hide show
  1. package/dist/api/index.d.ts +13 -5
  2. package/dist/api/index.js +1 -1
  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 +211 -1
  8. package/dist/applications/responses.js +3 -1
  9. package/dist/auth/index.d.ts +29 -31
  10. package/dist/auth/index.js +2 -2
  11. package/dist/auth/responses.d.ts +23 -20
  12. package/dist/delegated-agents/index.d.ts +17 -1
  13. package/dist/faucet/index.d.ts +54 -0
  14. package/dist/faucet/index.js +10 -0
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.js +4 -0
  17. package/dist/margin-accounts/index.d.ts +11 -14
  18. package/dist/market/index.d.ts +83 -0
  19. package/dist/positions/index.d.ts +1 -0
  20. package/dist/profile/index.d.ts +88 -1
  21. package/dist/sdk/index.d.ts +40 -2
  22. package/dist/sub-accounts/index.d.ts +145 -0
  23. package/dist/sub-accounts/index.js +9 -0
  24. package/dist/trading/index.d.ts +6 -6
  25. package/dist/trading/responses.d.ts +8 -27
  26. package/dist/validation/margin-accounts.d.ts +7 -9
  27. package/dist/validation/margin-accounts.js +7 -9
  28. package/dist/validation/profile.d.ts +7 -0
  29. package/dist/validation/profile.js +7 -0
  30. package/dist/validation/trading.d.ts +8 -33
  31. package/dist/validation/trading.js +42 -33
  32. package/dist/whitelist/index.d.ts +44 -0
  33. package/dist/whitelist/index.js +10 -0
  34. package/dist/wire/assert.d.ts +54 -0
  35. package/dist/wire/assert.js +0 -0
  36. package/dist/wire/audit.d.ts +47 -0
  37. package/dist/wire/audit.js +43 -0
  38. package/dist/wire/coverage.d.ts +1 -0
  39. package/dist/wire/coverage.js +0 -0
  40. package/dist/wire/index.d.ts +21 -0
  41. package/dist/wire/index.js +2 -0
  42. package/dist/wire/operations.d.ts +15 -0
  43. package/dist/wire/operations.js +93 -0
  44. package/dist/wire/schema.d.ts +8352 -0
  45. package/dist/wire/schema.js +4 -0
  46. package/dist/withdrawals/index.d.ts +43 -0
  47. package/dist/withdrawals/index.js +0 -0
  48. package/package.json +6 -2
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Faucet Types
3
+ *
4
+ * Types for the testnet token faucet. Wire shapes are snake_case.
5
+ *
6
+ * NOTE: The faucet is **testnet-only** and performs real on-chain mints from a
7
+ * backend-operator-funded signer. It is disabled (returns an error) if the
8
+ * gateway operator has not configured a signer; the SDK caller has no control
9
+ * over that. It is rate-limited per user (default 1 request / 24h).
10
+ */
11
+ import type { BaseAPI } from "../api";
12
+ /** A token successfully minted by the faucet. */
13
+ export interface MintedToken {
14
+ /** Asset UUID */
15
+ asset_id: string;
16
+ /** Token symbol */
17
+ symbol: string;
18
+ /** Amount minted in token units */
19
+ amount: string;
20
+ /** On-chain transaction hash */
21
+ tx_hash: string;
22
+ }
23
+ /** A token the faucet failed to mint. */
24
+ export interface FailedMint {
25
+ /** Asset UUID */
26
+ asset_id: string;
27
+ /** Token symbol */
28
+ symbol: string;
29
+ /** Error message describing why the mint failed */
30
+ error: string;
31
+ }
32
+ /** Result of a faucet mint request. */
33
+ export interface MintTokensResponse {
34
+ /** Tokens that were successfully minted */
35
+ minted: MintedToken[];
36
+ /** Tokens that failed to mint */
37
+ failed: FailedMint[];
38
+ /** Remaining faucet requests in the next 24h */
39
+ remaining_requests_24h: number;
40
+ }
41
+ /**
42
+ * Faucet API interface. Session-authenticated.
43
+ */
44
+ export interface FaucetAPI extends BaseAPI {
45
+ /**
46
+ * Mints the full set of testnet tokens to the authenticated user.
47
+ *
48
+ * Testnet-only and rate-limited; see the module note. Partial success is
49
+ * possible — inspect `minted` and `failed` in the response.
50
+ *
51
+ * @returns Promise resolving to the minted/failed tokens and remaining quota
52
+ */
53
+ mint(): Promise<MintTokensResponse>;
54
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Faucet Types
3
+ *
4
+ * Types for the testnet token faucet. Wire shapes are snake_case.
5
+ *
6
+ * NOTE: The faucet is **testnet-only** and performs real on-chain mints from a
7
+ * backend-operator-funded signer. It is disabled (returns an error) if the
8
+ * gateway operator has not configured a signer; the SDK caller has no control
9
+ * over that. It is rate-limited per user (default 1 request / 24h).
10
+ */
package/dist/index.d.ts CHANGED
@@ -9,13 +9,17 @@ export * from "./applications";
9
9
  export * from "./auth";
10
10
  export * from "./contracts";
11
11
  export * from "./delegated-agents";
12
+ export * from "./faucet";
12
13
  export * from "./fees";
13
14
  export * from "./margin-accounts";
14
15
  export * from "./market";
15
16
  export * from "./positions";
16
17
  export * from "./profile";
17
18
  export * from "./sdk";
19
+ export * from "./sub-accounts";
18
20
  export * from "./trading";
19
21
  export * from "./validation";
20
22
  export * from "./vault";
21
23
  export * from "./websocket";
24
+ export * from "./whitelist";
25
+ export * from "./withdrawals";
package/dist/index.js CHANGED
@@ -10,13 +10,17 @@ export * from "./applications";
10
10
  export * from "./auth";
11
11
  export * from "./contracts";
12
12
  export * from "./delegated-agents";
13
+ export * from "./faucet";
13
14
  export * from "./fees";
14
15
  export * from "./margin-accounts";
15
16
  export * from "./market";
16
17
  export * from "./positions";
17
18
  export * from "./profile";
18
19
  export * from "./sdk";
20
+ export * from "./sub-accounts";
19
21
  export * from "./trading";
20
22
  export * from "./validation";
21
23
  export * from "./vault";
22
24
  export * from "./websocket";
25
+ export * from "./whitelist";
26
+ export * from "./withdrawals";
@@ -3,6 +3,8 @@ import type { OrderSide, OrderType, PositionSide } from "../trading";
3
3
  export interface MarginAccountSummary {
4
4
  margin_account_id: string;
5
5
  label?: string;
6
+ margin_bucket_id?: string;
7
+ margin_mode?: "ISOLATED" | "CROSS";
6
8
  trading_pair_id?: string;
7
9
  strategy_key?: string;
8
10
  account_state: string;
@@ -28,16 +30,8 @@ export interface ListMarginAccountsResponse {
28
30
  page: number;
29
31
  page_size: number;
30
32
  }
31
- export interface CreateMarginAccountRequest {
32
- label?: string;
33
- collateralAsset?: string;
34
- }
35
- export interface CreateMarginAccountResponse {
36
- margin_account_id: string;
37
- label?: string;
38
- account_state: string;
39
- collateral_asset: string;
40
- created_at: string;
33
+ export interface GetMarginAccountSummaryParams {
34
+ tradingPairId?: string;
41
35
  }
42
36
  export interface GetAvailableCollateralParams {
43
37
  asset?: string;
@@ -51,6 +45,8 @@ export interface GetAvailableCollateralResponse {
51
45
  export interface TransferCollateralRequest {
52
46
  asset: string;
53
47
  amount: string;
48
+ tradingPairId?: string;
49
+ strategyKey?: string;
54
50
  }
55
51
  export interface TransferCollateralToAutoMarginAccountRequest extends TransferCollateralRequest {
56
52
  tradingPairId: string;
@@ -88,7 +84,6 @@ export interface GetMarginAccountMovementsResponse {
88
84
  }
89
85
  export interface SimulateOrderRiskRequest {
90
86
  tradingPairId: string;
91
- strategyKey?: string;
92
87
  side: OrderSide;
93
88
  positionSide: PositionSide;
94
89
  orderType: OrderType;
@@ -97,6 +92,9 @@ export interface SimulateOrderRiskRequest {
97
92
  leverage: string;
98
93
  reduceOnly?: boolean;
99
94
  }
95
+ export interface SimulateAutoMarginOrderRiskRequest extends SimulateOrderRiskRequest {
96
+ strategyKey?: string;
97
+ }
100
98
  export interface SimulateOrderRiskResponse {
101
99
  accepted: boolean;
102
100
  reject_reason?: string;
@@ -111,13 +109,12 @@ export interface SimulateOrderRiskResponse {
111
109
  }
112
110
  export interface MarginAccountsAPI extends BaseAPI {
113
111
  listMarginAccounts(params?: ListMarginAccountsParams): Promise<ListMarginAccountsResponse>;
114
- createMarginAccount(request?: CreateMarginAccountRequest): Promise<CreateMarginAccountResponse>;
115
- getMarginAccountSummary(marginAccountId: string): Promise<MarginAccountSummary>;
112
+ getMarginAccountSummary(marginAccountId: string, params?: GetMarginAccountSummaryParams): Promise<MarginAccountSummary>;
116
113
  getAvailableCollateral(params?: GetAvailableCollateralParams): Promise<GetAvailableCollateralResponse>;
117
114
  transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
118
115
  transferCollateralToAutoMarginAccount(request: TransferCollateralToAutoMarginAccountRequest): Promise<TransferCollateralResponse>;
119
116
  transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
120
117
  getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
121
118
  simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
122
- simulateAutoMarginOrderRisk(request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
119
+ simulateAutoMarginOrderRisk(request: SimulateAutoMarginOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
123
120
  }
@@ -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
  }
@@ -1,15 +1,19 @@
1
1
  import type { PublicClient, TransactionReceipt, WalletClient } from "viem";
2
2
  import type { ApplicationsAPI } from "../applications";
3
- import type { AuthAPI, AuthState } from "../auth/index";
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.
@@ -29,10 +33,27 @@ export interface SDKConfig {
29
33
  * - "mainnet": https://api.monaco.xyz
30
34
  *
31
35
  * Only "mainnet" uses the Sei mainnet chain. All other networks use Sei testnet.
36
+ * `network` always selects the chain; supply {@link apiUrl} / {@link wsUrl}
37
+ * to point the SDK at a gateway that the preset URL doesn't cover.
32
38
  */
33
39
  network: Network;
34
40
  /** RPC URL for Sei blockchain interactions */
35
41
  seiRpcUrl: string;
42
+ /**
43
+ * Override the API gateway base URL. When set, the SDK sends all HTTP
44
+ * requests here instead of the {@link network} preset's default URL. Use for
45
+ * self-hosted gateways or e2e/dev stacks reachable only by a custom host
46
+ * (e.g. Docker DNS `http://api-gateway:8080`). `network` still selects the
47
+ * chain. Must be a valid absolute URL.
48
+ */
49
+ apiUrl?: string;
50
+ /**
51
+ * Override the WebSocket base URL. When set, the SDK connects here instead of
52
+ * the {@link network} preset's default WS URL. Pair with {@link apiUrl} when
53
+ * the WS service is reachable at a different host than the API gateway
54
+ * (e.g. Docker DNS `ws://ws-api:8080/ws`). Must be a valid absolute URL.
55
+ */
56
+ wsUrl?: string;
36
57
  }
37
58
  /**
38
59
  * Core SDK interface providing access to all Monaco functionality.
@@ -48,6 +69,8 @@ export interface MonacoSDK {
48
69
  delegatedAgents: DelegatedAgentsAPI;
49
70
  /** Vault operations API */
50
71
  vault: VaultAPI;
72
+ /** Low-level withdrawals API (initiate + fetch signed calldata) */
73
+ withdrawals: WithdrawalsAPI;
51
74
  /** Trading operations API */
52
75
  trading: TradingAPI;
53
76
  /** Market metadata API */
@@ -56,6 +79,12 @@ export interface MonacoSDK {
56
79
  marginAccounts: MarginAccountsAPI;
57
80
  /** Perp position operations API */
58
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;
59
88
  /** Profile operations API */
60
89
  profile: ProfileAPI;
61
90
  /** Orderbook REST API for fetching orderbook snapshots */
@@ -86,7 +115,7 @@ export interface MonacoSDK {
86
115
  disconnect: () => void;
87
116
  isConnected: () => boolean;
88
117
  getStatus: () => "connected" | "connecting" | "disconnected" | "reconnecting";
89
- setToken: (token: string) => void;
118
+ setSessionKeypair: (credentials: SessionCredentials | undefined) => void;
90
119
  orders: (tradingPairId: string, tradingMode: TradingMode, handler: (event: OrderEvent) => void) => () => void;
91
120
  orderbook: (tradingPairId: string, tradingMode: TradingMode, magnitude: number, quotationMode: OrderbookQuotationMode, handler: (event: OrderbookEvent) => void) => () => void;
92
121
  ohlcv: (tradingPairId: string, tradingMode: TradingMode, interval: Interval, handler: (event: OHLCVEvent) => void) => () => void;
@@ -108,6 +137,15 @@ export interface MonacoSDK {
108
137
  login(clientId: string, options?: {
109
138
  connectWebSocket?: boolean;
110
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>;
111
149
  /** Log out the user */
112
150
  logout(): Promise<void>;
113
151
  /** Refresh the access token */
@@ -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
+ */