@0xmonaco/core 0.8.14 → 0.8.16

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.
package/README.md CHANGED
@@ -1,17 +1,6 @@
1
1
  # Monaco Core SDK
2
2
 
3
- ⚠️ **EARLY DEVELOPMENT WARNING** ⚠️
4
-
5
- This package is currently in **early development**.
6
-
7
- **Breaking changes are expected** and may occur without notice. This version is intended for:
8
- - Early adopters and testing
9
- - Development and experimentation
10
- - Feedback collection
11
-
12
- ---
13
-
14
- Core SDK implementation for interacting with Monaco Protocol. This SDK provides a comprehensive implementation with Authentication, Vault, Trading, Market, and Profile APIs, featuring JWT authentication and secure API Gateway integration.
3
+ Core SDK implementation for interacting with Monaco Protocol. This SDK provides a comprehensive implementation with Authentication, Vault, Trading, Market, and Profile APIs, featuring noncustodial session-key authentication and secure API Gateway integration.
15
4
 
16
5
  ## Installation
17
6
 
@@ -27,10 +16,10 @@ npm install viem@^2.31.7
27
16
  ## Features
28
17
 
29
18
  ### 🔐 **Authentication**
30
- - **JWT-based Authentication**: Secure token-based authentication
31
- - **Wallet Signature Verification**: EIP-712 signature-based login
32
- - **Token Refresh**: Automatic token refresh and management
33
- - **Session Management**: Secure session handling
19
+ - **Session-key Authentication**: Noncustodial ed25519 session keys — the server never holds a credential that can impersonate you
20
+ - **Wallet Signature Verification**: EIP-712 signature authorizes each session key
21
+ - **Session Refresh**: Extend session expiry without re-prompting the wallet
22
+ - **Server-key Auth**: Optional `sk_...` application key for backend/service access
34
23
 
35
24
  ### 🏦 **Vault Operations**
36
25
  - **Token Approvals**: ERC20 token approvals for vault usage
@@ -55,8 +44,8 @@ npm install viem@^2.31.7
55
44
  - **Balance Tracking**: Cross-platform balance monitoring
56
45
 
57
46
  ### 🔐 **Security Features**
58
- - **JWT Authentication**: Secure API access with token validation
59
- - **EIP-712 Signatures**: Type-safe, structured data signing for authentication
47
+ - **Session-key Signing**: Every authenticated request is signed with a locally held ed25519 key
48
+ - **EIP-712 Signatures**: Type-safe, structured data signing for session authorization
60
49
  - **API Gateway Integration**: Secure communication with Monaco backend
61
50
  - **TLS Encryption**: Secure API communications
62
51
 
@@ -114,9 +103,9 @@ async function authExample() {
114
103
  // Login with client ID and auto-connect authenticated WebSocket channels (Orders)
115
104
  const authState = await monaco.login("your-client-id", { connectWebSocket: true });
116
105
  console.log("Authenticated:", authState.user);
117
- console.log("Tokens:", {
118
- accessToken: authState.accessToken,
119
- refreshToken: authState.refreshToken,
106
+ console.log("Session:", {
107
+ sessionPublicKey: authState.sessionPublicKey,
108
+ expiresAt: authState.expiresAt,
120
109
  });
121
110
 
122
111
  // Authenticated WebSocket channels are now connected - start receiving real-time updates
@@ -128,11 +117,11 @@ async function authExample() {
128
117
  // Check authentication status
129
118
  console.log("Is authenticated:", monaco.isAuthenticated());
130
119
 
131
- // Logout (revokes the refresh token and disconnects authenticated WebSockets)
120
+ // Logout (revokes the session and disconnects authenticated WebSockets)
132
121
  await monaco.logout();
133
122
 
134
- // Or manually revoke the token
135
- await monaco.auth.revokeToken();
123
+ // Or manually revoke the session
124
+ await monaco.auth.revokeSession();
136
125
  }
137
126
 
138
127
  // Market Data
@@ -250,9 +239,9 @@ interface SDKConfig {
250
239
  }
251
240
  ```
252
241
 
253
- ### Authentication & Token Management
242
+ ### Authentication & Session Management
254
243
 
255
- The SDK uses JWT tokens for authentication. Understanding the token structure is important:
244
+ The SDK uses a noncustodial session-key scheme. On login it generates an ed25519 keypair locally, has your wallet authorize it via an EIP-712 signature, and signs every subsequent request with the private key — the server never holds a credential that can impersonate you.
256
245
 
257
246
  ```typescript
258
247
  // After login, you receive an AuthState object
@@ -260,35 +249,40 @@ const authState = await sdk.login(clientId);
260
249
 
261
250
  // AuthState structure:
262
251
  interface AuthState {
263
- accessToken: string; // For making authenticated API requests
264
- refreshToken: string; // For refreshing tokens AND revoking (logout)
265
- expiresAt: number; // When the access token expires
266
- user: User; // User information
252
+ sessionPublicKey: string; // ed25519 public key registered with the server
253
+ sessionPrivateKey: string; // ed25519 private key used to sign requests (the long-lived credential)
254
+ expiresAt: number; // Unix timestamp (seconds) when the session expires
255
+ user: User; // User information
267
256
  }
268
257
  ```
269
258
 
259
+ > The private key is the long-lived credential. Persist it (e.g. `localStorage`, same risk profile as a JWT) to survive page reloads without re-prompting the wallet. When the session expires, call `refreshAuth()` or re-`login()`.
260
+
270
261
  ```typescript
271
- // Revoke the current session's token
272
- await sdk.auth.revokeToken();
262
+ // Revoke the current session
263
+ await sdk.auth.revokeSession();
273
264
 
274
265
  // 💡 TIP: Use the built-in logout method
275
- await sdk.logout(); // Automatically calls revokeToken internally
266
+ await sdk.logout(); // Automatically calls revokeSession internally
276
267
  ```
277
268
 
278
- **Token Management Methods:**
279
- - `login(clientId, options?)` - Authenticate and get tokens
269
+ **Session Management Methods:**
270
+ - `login(clientId, options?)` - Authorize a session key and authenticate
280
271
  - `clientId`: Your application's client ID
281
272
  - `options.connectWebSocket`: (optional) Auto-connect WebSocket after login (default: `false`)
282
- - Returns `AuthState` with access token, refresh token, expiration, and user info
283
- - `logout()` - Revoke token, disconnect WebSocket, and clear state
284
- - Calls `auth.revokeToken()` internally
273
+ - Returns `AuthState` with the session keypair, expiration, and user info
274
+ - `logout()` - Revoke the session, disconnect WebSocket, and clear state
275
+ - Calls `auth.revokeSession()` internally
285
276
  - Disconnects authenticated WebSocket channels
286
277
  - Clears local auth state
287
- - `refreshAuth()` - Refresh the access token using the stored refresh token
288
- - `isAuthenticated()` - Check if user is authenticated
289
- - `getAuthState()` - Get current auth state with tokens
278
+ - `refreshAuth()` - Extend the current session's expiry
279
+ - `isAuthenticated()` - Check if a session is active
280
+ - `getAuthState()` - Get current auth state with the session keypair
290
281
  - `setAuthState(authState)` - Set auth state directly (useful for sharing across SDK instances)
291
282
 
283
+ **Server-key Auth (backend/service access):**
284
+ - `setServerKey(serverKey)` - Authenticate with an application secret key (`sk_...`) instead of, or alongside, a session. Useful for server-side integrations.
285
+
292
286
  ### Vault API
293
287
 
294
288
  The vault API provides secure token management operations:
@@ -391,7 +385,7 @@ monaco.websocket.orderbook.subscribeToOrderbookEvents("BTC/USDC", "SPOT", (event
391
385
 
392
386
  #### Authenticated WebSockets (Orders)
393
387
 
394
- Requires JWT authentication for personal order updates. You can either auto-connect during login or connect manually:
388
+ Requires an authenticated session for personal order updates. You can either auto-connect during login or connect manually:
395
389
 
396
390
  **Option 1: Auto-connect (recommended for authenticated channels)**
397
391
  ```typescript
@@ -515,15 +509,15 @@ bun run lint --filter @0xmonaco/core
515
509
 
516
510
  ## Security Features
517
511
 
518
- ### JWT Authentication
519
- - **Token-based security**: Secure JWT tokens for API access
520
- - **EIP-712 login**: Wallet signature-based authentication
521
- - **Automatic refresh**: Seamless token renewal
522
- - **Session management**: Secure session handling
512
+ ### Session-key Authentication
513
+ - **Noncustodial**: ed25519 session keys are generated locally; the server never holds a credential that can impersonate you
514
+ - **EIP-712 login**: Wallet signature authorizes each session key
515
+ - **Session refresh**: Extend expiry without re-prompting the wallet
516
+ - **Server-key auth**: Optional `sk_...` application key for backend/service access
523
517
 
524
518
  ### API Gateway Integration
525
519
  - **Secure communication**: TLS encryption for all API calls
526
- - **Token validation**: Backend validates all JWT tokens
520
+ - **Request signing**: Backend verifies the session signature on every authenticated request
527
521
  - **Rate limiting**: Protection against abuse
528
522
  - **Audit logging**: Complete transaction history
529
523
 
@@ -48,10 +48,10 @@ export class ApplicationsAPIImpl extends BaseAPI {
48
48
  return {
49
49
  id: data.id,
50
50
  name: data.name,
51
- allowedOrigins: data.allowed_origins,
52
- webhookUrl: data.webhook_url,
53
- vaultContractAddress: data.vault_contract_address,
54
- clientId: data.client_id,
51
+ allowedOrigins: data.allowedOrigins,
52
+ webhookUrl: data.webhookUrl,
53
+ vaultContractAddress: data.vaultContractAddress,
54
+ clientId: data.clientId,
55
55
  };
56
56
  }
57
57
  /**
@@ -142,7 +142,7 @@ export declare class AuthAPIImpl extends BaseAPI implements AuthAPI {
142
142
  * Extends the current session's expiry.
143
143
  *
144
144
  * The request is signed with the active session key (set via
145
- * {@link setSessionKeypair}); the server bumps the session's `expires_at`.
145
+ * {@link setSessionKeypair}); the server bumps the session's `expiresAt`.
146
146
  * No new credential is issued — the same keypair keeps working.
147
147
  *
148
148
  * @returns Promise resolving to the new expiry
@@ -157,15 +157,15 @@ export class AuthAPIImpl extends BaseAPI {
157
157
  method: "POST",
158
158
  body: JSON.stringify({
159
159
  address,
160
- client_id: clientId,
161
- chain_id: this.chain.id,
162
- session_public_key: sessionPublicKey,
160
+ clientId: clientId,
161
+ chainId: this.chain.id,
162
+ sessionPublicKey: sessionPublicKey,
163
163
  }),
164
164
  });
165
165
  return {
166
166
  nonce: responseBody.nonce,
167
167
  message: responseBody.message,
168
- expiresAt: responseBody.expires_at,
168
+ expiresAt: responseBody.expiresAt,
169
169
  };
170
170
  }
171
171
  /**
@@ -199,15 +199,15 @@ export class AuthAPIImpl extends BaseAPI {
199
199
  address,
200
200
  signature,
201
201
  nonce,
202
- client_id: clientId,
203
- chain_id: this.chain.id,
204
- session_public_key: session.publicKey,
202
+ clientId: clientId,
203
+ chainId: this.chain.id,
204
+ sessionPublicKey: session.publicKey,
205
205
  }),
206
206
  });
207
207
  return {
208
208
  sessionPublicKey: session.publicKey,
209
209
  sessionPrivateKey: session.privateKey,
210
- expiresAt: responseBody.expires_at,
210
+ expiresAt: responseBody.expiresAt,
211
211
  user: {
212
212
  id: responseBody.user.id,
213
213
  address: responseBody.user.address,
@@ -219,7 +219,7 @@ export class AuthAPIImpl extends BaseAPI {
219
219
  * Extends the current session's expiry.
220
220
  *
221
221
  * The request is signed with the active session key (set via
222
- * {@link setSessionKeypair}); the server bumps the session's `expires_at`.
222
+ * {@link setSessionKeypair}); the server bumps the session's `expiresAt`.
223
223
  * No new credential is issued — the same keypair keeps working.
224
224
  *
225
225
  * @returns Promise resolving to the new expiry
@@ -236,7 +236,7 @@ export class AuthAPIImpl extends BaseAPI {
236
236
  method: "POST",
237
237
  });
238
238
  return {
239
- expiresAt: responseBody.expires_at,
239
+ expiresAt: responseBody.expiresAt,
240
240
  };
241
241
  }
242
242
  /**
@@ -99,7 +99,7 @@ export declare abstract class BaseAPI {
99
99
  * '/api/v1/orders',
100
100
  * {
101
101
  * method: 'POST',
102
- * body: JSON.stringify({ trading_pair: 'ETH-USD', side: 'BUY' })
102
+ * body: JSON.stringify({ tradingPair: 'ETH-USD', side: 'BUY' })
103
103
  * }
104
104
  * );
105
105
  * ```
@@ -155,7 +155,7 @@ export declare abstract class BaseAPI {
155
155
  * '/api/v1/auth/challenge',
156
156
  * {
157
157
  * method: 'POST',
158
- * body: JSON.stringify({ address, client_id: clientId })
158
+ * body: JSON.stringify({ address, clientId: clientId })
159
159
  * }
160
160
  * );
161
161
  * ```
package/dist/api/base.js CHANGED
@@ -241,7 +241,7 @@ export class BaseAPI {
241
241
  * '/api/v1/orders',
242
242
  * {
243
243
  * method: 'POST',
244
- * body: JSON.stringify({ trading_pair: 'ETH-USD', side: 'BUY' })
244
+ * body: JSON.stringify({ tradingPair: 'ETH-USD', side: 'BUY' })
245
245
  * }
246
246
  * );
247
247
  * ```
@@ -350,7 +350,7 @@ export class BaseAPI {
350
350
  * '/api/v1/auth/challenge',
351
351
  * {
352
352
  * method: 'POST',
353
- * body: JSON.stringify({ address, client_id: clientId })
353
+ * body: JSON.stringify({ address, clientId: clientId })
354
354
  * }
355
355
  * );
356
356
  * ```
@@ -5,17 +5,17 @@ export class DelegatedAgentsAPIImpl extends BaseAPI {
5
5
  return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.list(), {
6
6
  method: "POST",
7
7
  body: JSON.stringify({
8
- agent_address: request.agentAddress,
8
+ agentAddress: request.agentAddress,
9
9
  name: request.name,
10
- expires_at: request.expiresAt,
11
- allowed_actions: request.allowedActions,
12
- allowed_trading_pair_ids: request.allowedTradingPairIds,
13
- allowed_margin_account_ids: request.allowedMarginAccountIds,
14
- allowed_order_types: request.allowedOrderTypes,
15
- allowed_time_in_force: request.allowedTimeInForce,
16
- max_leverage: request.maxLeverage,
17
- max_order_notional: request.maxOrderNotional,
18
- max_open_orders: request.maxOpenOrders,
10
+ expiresAt: request.expiresAt,
11
+ allowedActions: request.allowedActions,
12
+ allowedTradingPairIds: request.allowedTradingPairIds,
13
+ allowedMarginAccountIds: request.allowedMarginAccountIds,
14
+ allowedOrderTypes: request.allowedOrderTypes,
15
+ allowedTimeInForce: request.allowedTimeInForce,
16
+ maxLeverage: request.maxLeverage,
17
+ maxOrderNotional: request.maxOrderNotional,
18
+ maxOpenOrders: request.maxOpenOrders,
19
19
  }),
20
20
  });
21
21
  }
@@ -34,8 +34,8 @@ export class DelegatedAgentsAPIImpl extends BaseAPI {
34
34
  return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.sessions(), {
35
35
  method: "POST",
36
36
  body: JSON.stringify({
37
- owner_user_id: request.ownerUserId,
38
- session_public_key: request.sessionPublicKey,
37
+ ownerUserId: request.ownerUserId,
38
+ sessionPublicKey: request.sessionPublicKey,
39
39
  }),
40
40
  });
41
41
  }
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @example
10
10
  * ```typescript
11
- * const { minted, failed, remaining_requests_24h } = await sdk.faucet.mint();
11
+ * const { minted, failed, remainingRequests24h } = await sdk.faucet.mint();
12
12
  * ```
13
13
  */
14
14
  import type { FaucetAPI, MintTokensResponse } from "@0xmonaco/types";
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @example
10
10
  * ```typescript
11
- * const { minted, failed, remaining_requests_24h } = await sdk.faucet.mint();
11
+ * const { minted, failed, remainingRequests24h } = await sdk.faucet.mint();
12
12
  * ```
13
13
  */
14
14
  import { BaseAPI } from "../base";
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * // Simulate fees for an order
16
16
  * const feeDetails = await feesAPI.simulateFees({
17
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
17
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
18
18
  * side: "BUY",
19
19
  * price: "40000.00",
20
20
  * quantity: "0.5"
@@ -31,41 +31,41 @@ export declare class FeesAPIImpl extends BaseAPI implements FeesAPI {
31
31
  * application fees, and total amounts the taker must pay or maker will receive.
32
32
  *
33
33
  * @param params - Parameters for fee simulation
34
- * @param params.trading_pair_id - The trading pair UUID
34
+ * @param params.tradingPairId - The trading pair UUID
35
35
  * @param params.side - The order side ("BUY" or "SELL")
36
36
  * @param params.price - The price per unit as string
37
37
  * @param params.quantity - The quantity to trade as string
38
- * @param params.order_type - Order type: "LIMIT" (default) or "MARKET"
39
- * @param params.slippage_tolerance_bps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
38
+ * @param params.orderType - Order type: "LIMIT" (default) or "MARKET"
39
+ * @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
40
40
  * @returns Promise resolving to SimulateFeeResponse with fee breakdown
41
41
  *
42
42
  * @example
43
43
  * ```typescript
44
44
  * // Simulate fees for a buy order
45
45
  * const buyFees = await feesAPI.simulateFees({
46
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
46
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
47
47
  * side: "BUY",
48
48
  * price: "40000.00",
49
49
  * quantity: "0.5"
50
50
  * });
51
51
  *
52
52
  * console.log(`Notional value: ${buyFees.notional}`);
53
- * console.log(`Monaco taker fee: ${buyFees.monaco_taker_fee}`);
54
- * console.log(`Application taker fee: ${buyFees.application_taker_fee}`);
55
- * console.log(`Total taker fees: ${buyFees.total_taker_fees}`);
56
- * console.log(`Total payment required: ${buyFees.taker_total_payment}`);
57
- * console.log(`Lock amount for BUY: ${buyFees.buy_order_lock_amount}`);
53
+ * console.log(`Monaco taker fee: ${buyFees.monacoTakerFee}`);
54
+ * console.log(`Application taker fee: ${buyFees.applicationTakerFee}`);
55
+ * console.log(`Total taker fees: ${buyFees.totalTakerFees}`);
56
+ * console.log(`Total payment required: ${buyFees.takerTotalPayment}`);
57
+ * console.log(`Lock amount for BUY: ${buyFees.buyOrderLockAmount}`);
58
58
  *
59
59
  * // Simulate fees for a sell order
60
60
  * const sellFees = await feesAPI.simulateFees({
61
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
61
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
62
62
  * side: "SELL",
63
63
  * price: "40000.00",
64
64
  * quantity: "0.5"
65
65
  * });
66
66
  *
67
- * console.log(`Maker rebate: ${sellFees.monaco_maker_rebate}`);
68
- * console.log(`Maker total receipt: ${sellFees.maker_total_receipt}`);
67
+ * console.log(`Maker rebate: ${sellFees.monacoMakerRebate}`);
68
+ * console.log(`Maker total receipt: ${sellFees.makerTotalReceipt}`);
69
69
  * ```
70
70
  */
71
71
  simulateFees(params: SimulateFeeParams): Promise<SimulateFeeResponse>;
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * // Simulate fees for an order
16
16
  * const feeDetails = await feesAPI.simulateFees({
17
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
17
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
18
18
  * side: "BUY",
19
19
  * price: "40000.00",
20
20
  * quantity: "0.5"
@@ -31,56 +31,56 @@ export class FeesAPIImpl extends BaseAPI {
31
31
  * application fees, and total amounts the taker must pay or maker will receive.
32
32
  *
33
33
  * @param params - Parameters for fee simulation
34
- * @param params.trading_pair_id - The trading pair UUID
34
+ * @param params.tradingPairId - The trading pair UUID
35
35
  * @param params.side - The order side ("BUY" or "SELL")
36
36
  * @param params.price - The price per unit as string
37
37
  * @param params.quantity - The quantity to trade as string
38
- * @param params.order_type - Order type: "LIMIT" (default) or "MARKET"
39
- * @param params.slippage_tolerance_bps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
38
+ * @param params.orderType - Order type: "LIMIT" (default) or "MARKET"
39
+ * @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
40
40
  * @returns Promise resolving to SimulateFeeResponse with fee breakdown
41
41
  *
42
42
  * @example
43
43
  * ```typescript
44
44
  * // Simulate fees for a buy order
45
45
  * const buyFees = await feesAPI.simulateFees({
46
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
46
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
47
47
  * side: "BUY",
48
48
  * price: "40000.00",
49
49
  * quantity: "0.5"
50
50
  * });
51
51
  *
52
52
  * console.log(`Notional value: ${buyFees.notional}`);
53
- * console.log(`Monaco taker fee: ${buyFees.monaco_taker_fee}`);
54
- * console.log(`Application taker fee: ${buyFees.application_taker_fee}`);
55
- * console.log(`Total taker fees: ${buyFees.total_taker_fees}`);
56
- * console.log(`Total payment required: ${buyFees.taker_total_payment}`);
57
- * console.log(`Lock amount for BUY: ${buyFees.buy_order_lock_amount}`);
53
+ * console.log(`Monaco taker fee: ${buyFees.monacoTakerFee}`);
54
+ * console.log(`Application taker fee: ${buyFees.applicationTakerFee}`);
55
+ * console.log(`Total taker fees: ${buyFees.totalTakerFees}`);
56
+ * console.log(`Total payment required: ${buyFees.takerTotalPayment}`);
57
+ * console.log(`Lock amount for BUY: ${buyFees.buyOrderLockAmount}`);
58
58
  *
59
59
  * // Simulate fees for a sell order
60
60
  * const sellFees = await feesAPI.simulateFees({
61
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
61
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
62
62
  * side: "SELL",
63
63
  * price: "40000.00",
64
64
  * quantity: "0.5"
65
65
  * });
66
66
  *
67
- * console.log(`Maker rebate: ${sellFees.monaco_maker_rebate}`);
68
- * console.log(`Maker total receipt: ${sellFees.maker_total_receipt}`);
67
+ * console.log(`Maker rebate: ${sellFees.monacoMakerRebate}`);
68
+ * console.log(`Maker total receipt: ${sellFees.makerTotalReceipt}`);
69
69
  * ```
70
70
  */
71
71
  async simulateFees(params) {
72
72
  // Validate parameters using the validate helper
73
73
  const validatedParams = validate(SimulateFeeParamsSchema, params);
74
74
  const searchParams = new URLSearchParams();
75
- searchParams.append("trading_pair_id", validatedParams.trading_pair_id);
75
+ searchParams.append("tradingPairId", validatedParams.tradingPairId);
76
76
  searchParams.append("side", validatedParams.side);
77
77
  searchParams.append("price", validatedParams.price);
78
78
  searchParams.append("quantity", validatedParams.quantity);
79
- if (validatedParams.order_type !== undefined) {
80
- searchParams.append("order_type", validatedParams.order_type);
79
+ if (validatedParams.orderType !== undefined) {
80
+ searchParams.append("orderType", validatedParams.orderType);
81
81
  }
82
- if (validatedParams.slippage_tolerance_bps !== undefined) {
83
- searchParams.append("slippage_tolerance_bps", String(validatedParams.slippage_tolerance_bps));
82
+ if (validatedParams.slippageToleranceBps !== undefined) {
83
+ searchParams.append("slippageToleranceBps", String(validatedParams.slippageToleranceBps));
84
84
  }
85
85
  const endpoint = `/api/v1/fees/simulate?${searchParams.toString()}`;
86
86
  return await this.makeAuthenticatedRequest(endpoint, {
@@ -9,19 +9,19 @@ export class MarginAccountsAPIImpl extends BaseAPI {
9
9
  return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.list(params
10
10
  ? {
11
11
  page: params.page,
12
- page_size: params.page_size,
12
+ pageSize: params.pageSize,
13
13
  state: params.state,
14
- trading_pair_id: params.tradingPairId,
14
+ tradingPairId: params.tradingPairId,
15
15
  }
16
16
  : undefined));
17
17
  }
18
18
  async getMarginAccountSummary(marginAccountId, params) {
19
19
  validate(GetMarginAccountSummarySchema, { marginAccountId, ...params });
20
- return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.summary(marginAccountId, { trading_pair_id: params?.tradingPairId }));
20
+ return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.summary(marginAccountId, { tradingPairId: params?.tradingPairId }));
21
21
  }
22
22
  async getParentMarginAccountSummary(params) {
23
23
  validate(GetParentMarginAccountSummarySchema, params);
24
- return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.parentSummary({ trading_pair_id: params?.tradingPairId }));
24
+ return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.parentSummary({ tradingPairId: params?.tradingPairId }));
25
25
  }
26
26
  async getAvailableCollateral(params) {
27
27
  validate(GetAvailableCollateralSchema, params);
@@ -34,8 +34,8 @@ export class MarginAccountsAPIImpl extends BaseAPI {
34
34
  body: JSON.stringify({
35
35
  asset: request.asset,
36
36
  amount: request.amount,
37
- trading_pair_id: request.tradingPairId,
38
- strategy_key: request.strategyKey,
37
+ tradingPairId: request.tradingPairId,
38
+ strategyKey: request.strategyKey,
39
39
  }),
40
40
  });
41
41
  }
@@ -56,8 +56,8 @@ export class MarginAccountsAPIImpl extends BaseAPI {
56
56
  body: JSON.stringify({
57
57
  asset: request.asset,
58
58
  amount: request.amount,
59
- trading_pair_id: request.tradingPairId,
60
- strategy_key: request.strategyKey,
59
+ tradingPairId: request.tradingPairId,
60
+ strategyKey: request.strategyKey,
61
61
  }),
62
62
  });
63
63
  }
@@ -68,8 +68,8 @@ export class MarginAccountsAPIImpl extends BaseAPI {
68
68
  body: JSON.stringify({
69
69
  asset: request.asset,
70
70
  amount: request.amount,
71
- trading_pair_id: request.tradingPairId,
72
- strategy_key: request.strategyKey,
71
+ tradingPairId: request.tradingPairId,
72
+ strategyKey: request.strategyKey,
73
73
  }),
74
74
  });
75
75
  }
@@ -96,14 +96,14 @@ export class MarginAccountsAPIImpl extends BaseAPI {
96
96
  return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateOrderRisk(marginAccountId), {
97
97
  method: "POST",
98
98
  body: JSON.stringify({
99
- trading_pair_id: request.tradingPairId,
99
+ tradingPairId: request.tradingPairId,
100
100
  side: request.side,
101
- position_side: request.positionSide,
102
- order_type: request.orderType,
101
+ positionSide: request.positionSide,
102
+ orderType: request.orderType,
103
103
  price: request.price,
104
104
  quantity: request.quantity,
105
105
  leverage: request.leverage,
106
- reduce_only: request.reduceOnly,
106
+ reduceOnly: request.reduceOnly,
107
107
  }),
108
108
  });
109
109
  }
@@ -112,14 +112,14 @@ export class MarginAccountsAPIImpl extends BaseAPI {
112
112
  return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateParentMarginOrderRisk(), {
113
113
  method: "POST",
114
114
  body: JSON.stringify({
115
- trading_pair_id: request.tradingPairId,
115
+ tradingPairId: request.tradingPairId,
116
116
  side: request.side,
117
- position_side: request.positionSide,
118
- order_type: request.orderType,
117
+ positionSide: request.positionSide,
118
+ orderType: request.orderType,
119
119
  price: request.price,
120
120
  quantity: request.quantity,
121
121
  leverage: request.leverage,
122
- reduce_only: request.reduceOnly,
122
+ reduceOnly: request.reduceOnly,
123
123
  }),
124
124
  });
125
125
  }
@@ -128,15 +128,15 @@ export class MarginAccountsAPIImpl extends BaseAPI {
128
128
  return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateRiskBucketOrderRisk(), {
129
129
  method: "POST",
130
130
  body: JSON.stringify({
131
- trading_pair_id: request.tradingPairId,
132
- strategy_key: request.strategyKey,
131
+ tradingPairId: request.tradingPairId,
132
+ strategyKey: request.strategyKey,
133
133
  side: request.side,
134
- position_side: request.positionSide,
135
- order_type: request.orderType,
134
+ positionSide: request.positionSide,
135
+ orderType: request.orderType,
136
136
  price: request.price,
137
137
  quantity: request.quantity,
138
138
  leverage: request.leverage,
139
- reduce_only: request.reduceOnly,
139
+ reduceOnly: request.reduceOnly,
140
140
  }),
141
141
  });
142
142
  }