@0xmonaco/core 0.7.5 → 0.7.7

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 (77) hide show
  1. package/package.json +3 -3
  2. package/dist/api/applications/api.d.ts +0 -43
  3. package/dist/api/applications/api.js +0 -54
  4. package/dist/api/applications/index.d.ts +0 -4
  5. package/dist/api/applications/index.js +0 -4
  6. package/dist/api/auth/api.d.ts +0 -206
  7. package/dist/api/auth/api.js +0 -305
  8. package/dist/api/auth/index.d.ts +0 -4
  9. package/dist/api/auth/index.js +0 -4
  10. package/dist/api/base.d.ts +0 -123
  11. package/dist/api/base.js +0 -286
  12. package/dist/api/fees/api.d.ts +0 -72
  13. package/dist/api/fees/api.js +0 -90
  14. package/dist/api/fees/index.d.ts +0 -6
  15. package/dist/api/fees/index.js +0 -6
  16. package/dist/api/index.d.ts +0 -18
  17. package/dist/api/index.js +0 -18
  18. package/dist/api/margin-accounts/api.d.ts +0 -12
  19. package/dist/api/margin-accounts/api.js +0 -69
  20. package/dist/api/margin-accounts/index.d.ts +0 -1
  21. package/dist/api/margin-accounts/index.js +0 -1
  22. package/dist/api/market/api.d.ts +0 -20
  23. package/dist/api/market/api.js +0 -97
  24. package/dist/api/market/index.d.ts +0 -1
  25. package/dist/api/market/index.js +0 -1
  26. package/dist/api/orderbook/api.d.ts +0 -15
  27. package/dist/api/orderbook/api.js +0 -37
  28. package/dist/api/orderbook/index.d.ts +0 -1
  29. package/dist/api/orderbook/index.js +0 -1
  30. package/dist/api/perp/index.d.ts +0 -1
  31. package/dist/api/perp/index.js +0 -1
  32. package/dist/api/perp/routes.d.ts +0 -133
  33. package/dist/api/perp/routes.js +0 -85
  34. package/dist/api/positions/api.d.ts +0 -12
  35. package/dist/api/positions/api.js +0 -88
  36. package/dist/api/positions/index.d.ts +0 -1
  37. package/dist/api/positions/index.js +0 -1
  38. package/dist/api/profile/api.d.ts +0 -191
  39. package/dist/api/profile/api.js +0 -259
  40. package/dist/api/profile/index.d.ts +0 -6
  41. package/dist/api/profile/index.js +0 -6
  42. package/dist/api/trades/api.d.ts +0 -44
  43. package/dist/api/trades/api.js +0 -42
  44. package/dist/api/trades/index.d.ts +0 -1
  45. package/dist/api/trades/index.js +0 -1
  46. package/dist/api/trading/api.d.ts +0 -297
  47. package/dist/api/trading/api.js +0 -481
  48. package/dist/api/trading/index.d.ts +0 -4
  49. package/dist/api/trading/index.js +0 -4
  50. package/dist/api/vault/api.d.ts +0 -261
  51. package/dist/api/vault/api.js +0 -506
  52. package/dist/api/vault/index.d.ts +0 -4
  53. package/dist/api/vault/index.js +0 -4
  54. package/dist/api/websocket/index.d.ts +0 -3
  55. package/dist/api/websocket/index.js +0 -3
  56. package/dist/api/websocket/types.d.ts +0 -41
  57. package/dist/api/websocket/types.js +0 -0
  58. package/dist/api/websocket/utils.d.ts +0 -8
  59. package/dist/api/websocket/utils.js +0 -22
  60. package/dist/api/websocket/websocket.d.ts +0 -5
  61. package/dist/api/websocket/websocket.js +0 -556
  62. package/dist/errors/errors.d.ts +0 -381
  63. package/dist/errors/errors.js +0 -815
  64. package/dist/errors/index.d.ts +0 -1
  65. package/dist/errors/index.js +0 -1
  66. package/dist/index.d.ts +0 -5
  67. package/dist/index.js +0 -5
  68. package/dist/networks/index.d.ts +0 -1
  69. package/dist/networks/index.js +0 -1
  70. package/dist/networks/networks.d.ts +0 -21
  71. package/dist/networks/networks.js +0 -46
  72. package/dist/sdk.d.ts +0 -134
  73. package/dist/sdk.js +0 -294
  74. package/dist/utils/index.d.ts +0 -1
  75. package/dist/utils/index.js +0 -1
  76. package/dist/utils/magnitude.d.ts +0 -26
  77. package/dist/utils/magnitude.js +0 -31
@@ -1,123 +0,0 @@
1
- /**
2
- * Base API Implementation
3
- *
4
- * Provides common functionality for all API classes including access token management,
5
- * authenticated request handling, and standardized error responses.
6
- *
7
- * This base class eliminates code duplication across API implementations and provides
8
- * a consistent interface for token-based authentication and HTTP request handling.
9
- *
10
- * @example
11
- * ```typescript
12
- * class MyAPIImpl extends BaseAPI implements MyAPI {
13
- * constructor(apiUrl: string) {
14
- * super(apiUrl);
15
- * }
16
- *
17
- * async getData(): Promise<any> {
18
- * return this.makeAuthenticatedRequest<any>('/api/v1/data');
19
- * }
20
- * }
21
- * ```
22
- */
23
- export interface RetryOptions {
24
- maxRetries?: number;
25
- baseDelayMs?: number;
26
- }
27
- export declare abstract class BaseAPI {
28
- protected readonly apiUrl: string;
29
- protected accessToken?: string;
30
- protected retryOptions: Required<RetryOptions>;
31
- /**
32
- * Creates a new BaseAPI instance.
33
- *
34
- * @param apiUrl - The base URL for the Monaco API Gateway
35
- * @param retryOptions - Configuration for retry behavior on network failures
36
- */
37
- constructor(apiUrl: string, retryOptions?: RetryOptions);
38
- /**
39
- * Set the access token for authenticated requests.
40
- *
41
- * @param token - JWT access token
42
- */
43
- setAccessToken(token: string): void;
44
- /**
45
- * Get the current access token.
46
- *
47
- * @returns The current access token or undefined if not set
48
- */
49
- protected getAccessToken(): string | undefined;
50
- /**
51
- * Parse request body for error logging
52
- *
53
- * Attempts to extract meaningful data from various BodyInit types for debugging.
54
- * Note: Binary data (Blob, ArrayBuffer, ReadableStream) is logged as metadata only
55
- * to avoid performance issues and maintain log readability.
56
- *
57
- * @param body - Request body from fetch options
58
- * @returns Parsed body for logging, or metadata for binary types
59
- */
60
- private parseRequestBody;
61
- /**
62
- * Extract metadata from response headers
63
- */
64
- private extractResponseMetadata;
65
- /**
66
- * Execute HTTP request with error handling
67
- */
68
- private executeRequest;
69
- /**
70
- * Makes an authenticated API request with automatic token handling.
71
- *
72
- * This method automatically includes the Authorization header with the Bearer token
73
- * and provides consistent error handling across all API operations.
74
- *
75
- * @param endpoint - The API endpoint to call (should start with /)
76
- * @param options - Request options (method, body, headers, etc.)
77
- * @returns Promise resolving to the response data
78
- * @throws {APIError} When access token is not set or API request fails
79
- *
80
- * @example
81
- * ```typescript
82
- * // GET request
83
- * const data = await this.makeAuthenticatedRequest<UserProfile>('/api/v1/profile');
84
- *
85
- * // POST request
86
- * const result = await this.makeAuthenticatedRequest<CreateOrderResponse>(
87
- * '/api/v1/orders',
88
- * {
89
- * method: 'POST',
90
- * body: JSON.stringify({ trading_pair: 'ETH-USD', side: 'BUY' })
91
- * }
92
- * );
93
- * ```
94
- */
95
- protected makeAuthenticatedRequest<T>(endpoint: string, options?: RequestInit): Promise<T>;
96
- /**
97
- * Makes an unauthenticated API request.
98
- *
99
- * This method is useful for endpoints that don't require authentication,
100
- * such as public data endpoints or authentication endpoints themselves.
101
- *
102
- * @param endpoint - The API endpoint to call (should start with /)
103
- * @param options - Request options (method, body, headers, etc.)
104
- * @returns Promise resolving to the response data
105
- * @throws {APIError} When API request fails
106
- *
107
- * @example
108
- * ```typescript
109
- * // Public endpoint
110
- * const data = await this.makePublicRequest<PublicData>('/api/v1/public/markets');
111
- *
112
- * // Authentication endpoint
113
- * const challenge = await this.makePublicRequest<ChallengeResponse>(
114
- * '/api/v1/auth/challenge',
115
- * {
116
- * method: 'POST',
117
- * body: JSON.stringify({ address, client_id: clientId })
118
- * }
119
- * );
120
- * ```
121
- */
122
- protected makePublicRequest<T>(endpoint: string, options?: RequestInit): Promise<T>;
123
- }
package/dist/api/base.js DELETED
@@ -1,286 +0,0 @@
1
- /**
2
- * Base API Implementation
3
- *
4
- * Provides common functionality for all API classes including access token management,
5
- * authenticated request handling, and standardized error responses.
6
- *
7
- * This base class eliminates code duplication across API implementations and provides
8
- * a consistent interface for token-based authentication and HTTP request handling.
9
- *
10
- * @example
11
- * ```typescript
12
- * class MyAPIImpl extends BaseAPI implements MyAPI {
13
- * constructor(apiUrl: string) {
14
- * super(apiUrl);
15
- * }
16
- *
17
- * async getData(): Promise<any> {
18
- * return this.makeAuthenticatedRequest<any>('/api/v1/data');
19
- * }
20
- * }
21
- * ```
22
- */
23
- import { StatusCodes } from "http-status-codes";
24
- import { APIError } from "../errors";
25
- export class BaseAPI {
26
- apiUrl;
27
- accessToken;
28
- retryOptions;
29
- /**
30
- * Creates a new BaseAPI instance.
31
- *
32
- * @param apiUrl - The base URL for the Monaco API Gateway
33
- * @param retryOptions - Configuration for retry behavior on network failures
34
- */
35
- constructor(apiUrl, retryOptions) {
36
- this.apiUrl = apiUrl;
37
- this.retryOptions = {
38
- maxRetries: retryOptions?.maxRetries ?? 3,
39
- baseDelayMs: retryOptions?.baseDelayMs ?? 1000,
40
- };
41
- }
42
- /**
43
- * Set the access token for authenticated requests.
44
- *
45
- * @param token - JWT access token
46
- */
47
- setAccessToken(token) {
48
- this.accessToken = token;
49
- }
50
- /**
51
- * Get the current access token.
52
- *
53
- * @returns The current access token or undefined if not set
54
- */
55
- getAccessToken() {
56
- return this.accessToken;
57
- }
58
- /**
59
- * Parse request body for error logging
60
- *
61
- * Attempts to extract meaningful data from various BodyInit types for debugging.
62
- * Note: Binary data (Blob, ArrayBuffer, ReadableStream) is logged as metadata only
63
- * to avoid performance issues and maintain log readability.
64
- *
65
- * @param body - Request body from fetch options
66
- * @returns Parsed body for logging, or metadata for binary types
67
- */
68
- parseRequestBody(body) {
69
- if (!body)
70
- return undefined;
71
- // String bodies (most common case) - parse as JSON if possible
72
- if (typeof body === "string") {
73
- try {
74
- return JSON.parse(body);
75
- }
76
- catch {
77
- return body; // Return as-is if not valid JSON
78
- }
79
- }
80
- // FormData - convert to object for logging
81
- if (body instanceof FormData) {
82
- const formObject = {};
83
- body.forEach((value, key) => {
84
- formObject[key] = value instanceof File ? `[File: ${value.name}]` : value;
85
- });
86
- return formObject;
87
- }
88
- // URLSearchParams - convert to object
89
- if (body instanceof URLSearchParams) {
90
- const params = {};
91
- body.forEach((value, key) => {
92
- params[key] = value;
93
- });
94
- return params;
95
- }
96
- // Blob - log metadata only (avoid reading binary data)
97
- if (body instanceof Blob) {
98
- return { type: "[Blob]", size: body.size, contentType: body.type };
99
- }
100
- // ArrayBuffer/ArrayBufferView - log metadata only
101
- if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
102
- const size = body instanceof ArrayBuffer ? body.byteLength : body.byteLength;
103
- return { type: "[ArrayBuffer]", size };
104
- }
105
- // ReadableStream - log metadata only (cannot read without consuming)
106
- if (typeof ReadableStream !== "undefined" && body instanceof ReadableStream) {
107
- return { type: "[ReadableStream]", note: "Stream body not captured for logging" };
108
- }
109
- // Fallback for unknown types
110
- return { type: "[Unknown]", bodyType: typeof body };
111
- }
112
- /**
113
- * Extract metadata from response headers
114
- */
115
- extractResponseMetadata(headers) {
116
- if (!headers)
117
- return {};
118
- const requestId = headers.get("x-request-id") || headers.get("request-id") || headers.get("x-correlation-id") || undefined;
119
- // Parse Retry-After header with validation
120
- const retryAfterHeader = headers.get("retry-after");
121
- let retryAfter;
122
- if (retryAfterHeader !== null) {
123
- const parsed = Number.parseInt(retryAfterHeader, 10);
124
- retryAfter = Number.isNaN(parsed) ? undefined : parsed;
125
- }
126
- return { requestId, retryAfter };
127
- }
128
- /**
129
- * Execute HTTP request with error handling
130
- */
131
- async executeRequest(url, endpoint, options, requestBody) {
132
- let response;
133
- try {
134
- response = await fetch(url, options);
135
- }
136
- catch (error) {
137
- throw new APIError(`Network request failed for ${endpoint}`, {
138
- endpoint: url,
139
- cause: error instanceof Error ? error : new Error(String(error)),
140
- requestBody,
141
- });
142
- }
143
- // Parse response body with error handling for non-JSON responses
144
- let responseBody;
145
- const contentType = response.headers?.get("content-type") || "unknown";
146
- // Clone the response to avoid consuming the body stream twice (if clone method exists)
147
- const responseClone = response.clone ? response.clone() : response;
148
- try {
149
- responseBody = await response.json();
150
- }
151
- catch (parseError) {
152
- // If JSON parsing fails, try to get response as text for better error messages
153
- let responseText;
154
- try {
155
- responseText = await responseClone.text();
156
- }
157
- catch {
158
- responseText = "[Unable to read response body]";
159
- }
160
- // If response is not OK, and we can't parse JSON, it's likely an error page (HTML, plain text, etc.)
161
- if (!response.ok) {
162
- const errorMessage = `API request failed: ${response.status}. Response is not JSON (Content-Type: ${contentType})`;
163
- const { requestId, retryAfter } = this.extractResponseMetadata(response.headers);
164
- throw new APIError(errorMessage, {
165
- endpoint: url,
166
- statusCode: response.status,
167
- responseBody: {
168
- rawResponse: responseText.substring(0, 500), // Limit to 500 chars to avoid huge error logs
169
- contentType,
170
- parseError: parseError instanceof Error ? parseError.message : String(parseError),
171
- },
172
- cause: parseError instanceof Error ? parseError : undefined,
173
- requestBody,
174
- requestId,
175
- retryAfter,
176
- });
177
- }
178
- // If response is OK but not JSON, throw a more specific error
179
- throw new APIError(`Expected JSON response but received ${contentType}`, {
180
- endpoint: url,
181
- statusCode: response.status,
182
- responseBody: { rawResponse: responseText.substring(0, 500), contentType },
183
- cause: parseError instanceof Error ? parseError : undefined,
184
- requestBody,
185
- });
186
- }
187
- if (!response.ok) {
188
- // Runtime validation before extracting error message from response body
189
- const errorBody = responseBody !== null && typeof responseBody === "object" ? responseBody : undefined;
190
- const errorMessage = (typeof errorBody?.message === "string" ? errorBody.message : undefined) ||
191
- (typeof errorBody?.error === "string" ? errorBody.error : undefined) ||
192
- `API request failed: ${response.status}`;
193
- const { requestId, retryAfter } = this.extractResponseMetadata(response.headers);
194
- throw new APIError(errorMessage, {
195
- endpoint: url,
196
- statusCode: response.status,
197
- responseBody,
198
- requestBody,
199
- requestId,
200
- retryAfter,
201
- });
202
- }
203
- return responseBody;
204
- }
205
- /**
206
- * Makes an authenticated API request with automatic token handling.
207
- *
208
- * This method automatically includes the Authorization header with the Bearer token
209
- * and provides consistent error handling across all API operations.
210
- *
211
- * @param endpoint - The API endpoint to call (should start with /)
212
- * @param options - Request options (method, body, headers, etc.)
213
- * @returns Promise resolving to the response data
214
- * @throws {APIError} When access token is not set or API request fails
215
- *
216
- * @example
217
- * ```typescript
218
- * // GET request
219
- * const data = await this.makeAuthenticatedRequest<UserProfile>('/api/v1/profile');
220
- *
221
- * // POST request
222
- * const result = await this.makeAuthenticatedRequest<CreateOrderResponse>(
223
- * '/api/v1/orders',
224
- * {
225
- * method: 'POST',
226
- * body: JSON.stringify({ trading_pair: 'ETH-USD', side: 'BUY' })
227
- * }
228
- * );
229
- * ```
230
- */
231
- async makeAuthenticatedRequest(endpoint, options = {}) {
232
- if (!this.accessToken) {
233
- throw new APIError("Access token not set. Call setAccessToken() first.", {
234
- endpoint: `${this.apiUrl}${endpoint}`,
235
- statusCode: StatusCodes.UNAUTHORIZED,
236
- });
237
- }
238
- const url = `${this.apiUrl}${endpoint}`;
239
- const requestBody = this.parseRequestBody(options.body);
240
- return this.executeRequest(url, endpoint, {
241
- ...options,
242
- headers: {
243
- "Content-Type": "application/json",
244
- Authorization: `Bearer ${this.accessToken}`,
245
- ...options.headers,
246
- },
247
- }, requestBody);
248
- }
249
- /**
250
- * Makes an unauthenticated API request.
251
- *
252
- * This method is useful for endpoints that don't require authentication,
253
- * such as public data endpoints or authentication endpoints themselves.
254
- *
255
- * @param endpoint - The API endpoint to call (should start with /)
256
- * @param options - Request options (method, body, headers, etc.)
257
- * @returns Promise resolving to the response data
258
- * @throws {APIError} When API request fails
259
- *
260
- * @example
261
- * ```typescript
262
- * // Public endpoint
263
- * const data = await this.makePublicRequest<PublicData>('/api/v1/public/markets');
264
- *
265
- * // Authentication endpoint
266
- * const challenge = await this.makePublicRequest<ChallengeResponse>(
267
- * '/api/v1/auth/challenge',
268
- * {
269
- * method: 'POST',
270
- * body: JSON.stringify({ address, client_id: clientId })
271
- * }
272
- * );
273
- * ```
274
- */
275
- async makePublicRequest(endpoint, options = {}) {
276
- const url = `${this.apiUrl}${endpoint}`;
277
- const requestBody = this.parseRequestBody(options.body);
278
- return this.executeRequest(url, endpoint, {
279
- ...options,
280
- headers: {
281
- "Content-Type": "application/json",
282
- ...options.headers,
283
- },
284
- }, requestBody);
285
- }
286
- }
@@ -1,72 +0,0 @@
1
- /**
2
- * Fees API Implementation
3
- *
4
- * Handles fee simulation and calculation operations.
5
- * All operations use JWT authentication and go through the API Gateway.
6
- *
7
- * This class provides a complete interface for fee-related operations on the Monaco protocol,
8
- * including simulating fees before placing orders.
9
- *
10
- * @example
11
- * ```typescript
12
- * const feesAPI = new FeesAPIImpl(apiUrl);
13
- * feesAPI.setAccessToken(jwtToken);
14
- *
15
- * // Simulate fees for an order
16
- * const feeDetails = await feesAPI.simulateFees({
17
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
18
- * side: "BUY",
19
- * price: "40000.00",
20
- * quantity: "0.5"
21
- * });
22
- * ```
23
- */
24
- import type { FeesAPI, SimulateFeeParams, SimulateFeeResponse } from "@0xmonaco/types";
25
- import { BaseAPI } from "../base";
26
- export declare class FeesAPIImpl extends BaseAPI implements FeesAPI {
27
- /**
28
- * Simulate fees for an order before placing it.
29
- *
30
- * Returns exact fees for that specific order including Monaco protocol fees,
31
- * application fees, and total amounts the taker must pay or maker will receive.
32
- *
33
- * @param params - Parameters for fee simulation
34
- * @param params.trading_pair_id - The trading pair UUID
35
- * @param params.side - The order side ("BUY" or "SELL")
36
- * @param params.price - The price per unit as string
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)
40
- * @returns Promise resolving to SimulateFeeResponse with fee breakdown
41
- *
42
- * @example
43
- * ```typescript
44
- * // Simulate fees for a buy order
45
- * const buyFees = await feesAPI.simulateFees({
46
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
47
- * side: "BUY",
48
- * price: "40000.00",
49
- * quantity: "0.5"
50
- * });
51
- *
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}`);
58
- *
59
- * // Simulate fees for a sell order
60
- * const sellFees = await feesAPI.simulateFees({
61
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
62
- * side: "SELL",
63
- * price: "40000.00",
64
- * quantity: "0.5"
65
- * });
66
- *
67
- * console.log(`Maker rebate: ${sellFees.monaco_maker_rebate}`);
68
- * console.log(`Maker total receipt: ${sellFees.maker_total_receipt}`);
69
- * ```
70
- */
71
- simulateFees(params: SimulateFeeParams): Promise<SimulateFeeResponse>;
72
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * Fees API Implementation
3
- *
4
- * Handles fee simulation and calculation operations.
5
- * All operations use JWT authentication and go through the API Gateway.
6
- *
7
- * This class provides a complete interface for fee-related operations on the Monaco protocol,
8
- * including simulating fees before placing orders.
9
- *
10
- * @example
11
- * ```typescript
12
- * const feesAPI = new FeesAPIImpl(apiUrl);
13
- * feesAPI.setAccessToken(jwtToken);
14
- *
15
- * // Simulate fees for an order
16
- * const feeDetails = await feesAPI.simulateFees({
17
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
18
- * side: "BUY",
19
- * price: "40000.00",
20
- * quantity: "0.5"
21
- * });
22
- * ```
23
- */
24
- import { SimulateFeeParamsSchema, validate } from "@0xmonaco/types";
25
- import { BaseAPI } from "../base";
26
- export class FeesAPIImpl extends BaseAPI {
27
- /**
28
- * Simulate fees for an order before placing it.
29
- *
30
- * Returns exact fees for that specific order including Monaco protocol fees,
31
- * application fees, and total amounts the taker must pay or maker will receive.
32
- *
33
- * @param params - Parameters for fee simulation
34
- * @param params.trading_pair_id - The trading pair UUID
35
- * @param params.side - The order side ("BUY" or "SELL")
36
- * @param params.price - The price per unit as string
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)
40
- * @returns Promise resolving to SimulateFeeResponse with fee breakdown
41
- *
42
- * @example
43
- * ```typescript
44
- * // Simulate fees for a buy order
45
- * const buyFees = await feesAPI.simulateFees({
46
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
47
- * side: "BUY",
48
- * price: "40000.00",
49
- * quantity: "0.5"
50
- * });
51
- *
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}`);
58
- *
59
- * // Simulate fees for a sell order
60
- * const sellFees = await feesAPI.simulateFees({
61
- * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
62
- * side: "SELL",
63
- * price: "40000.00",
64
- * quantity: "0.5"
65
- * });
66
- *
67
- * console.log(`Maker rebate: ${sellFees.monaco_maker_rebate}`);
68
- * console.log(`Maker total receipt: ${sellFees.maker_total_receipt}`);
69
- * ```
70
- */
71
- async simulateFees(params) {
72
- // Validate parameters using the validate helper
73
- const validatedParams = validate(SimulateFeeParamsSchema, params);
74
- const searchParams = new URLSearchParams();
75
- searchParams.append("trading_pair_id", validatedParams.trading_pair_id);
76
- searchParams.append("side", validatedParams.side);
77
- searchParams.append("price", validatedParams.price);
78
- searchParams.append("quantity", validatedParams.quantity);
79
- if (validatedParams.order_type !== undefined) {
80
- searchParams.append("order_type", validatedParams.order_type);
81
- }
82
- if (validatedParams.slippage_tolerance_bps !== undefined) {
83
- searchParams.append("slippage_tolerance_bps", String(validatedParams.slippage_tolerance_bps));
84
- }
85
- const endpoint = `/api/v1/fees/simulate?${searchParams.toString()}`;
86
- return await this.makeAuthenticatedRequest(endpoint, {
87
- method: "GET",
88
- });
89
- }
90
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Fees API Module
3
- *
4
- * Exports fees API implementation.
5
- */
6
- export { FeesAPIImpl } from "./api";
@@ -1,6 +0,0 @@
1
- /**
2
- * Fees API Module
3
- *
4
- * Exports fees API implementation.
5
- */
6
- export { FeesAPIImpl } from "./api";
@@ -1,18 +0,0 @@
1
- /**
2
- * API Module Exports
3
- *
4
- * This module exports the new simplified APIs for the Monaco SDK.
5
- */
6
- export * from "./applications/index";
7
- export * from "./base";
8
- export * from "./fees";
9
- export * from "./margin-accounts";
10
- export * from "./market";
11
- export * from "./orderbook";
12
- export * from "./perp";
13
- export * from "./positions";
14
- export * from "./profile";
15
- export * from "./trades";
16
- export * from "./trading";
17
- export * from "./vault";
18
- export * from "./websocket";
package/dist/api/index.js DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * API Module Exports
3
- *
4
- * This module exports the new simplified APIs for the Monaco SDK.
5
- */
6
- export * from "./applications/index";
7
- export * from "./base";
8
- export * from "./fees";
9
- export * from "./margin-accounts";
10
- export * from "./market";
11
- export * from "./orderbook";
12
- export * from "./perp";
13
- export * from "./positions";
14
- export * from "./profile";
15
- export * from "./trades";
16
- export * from "./trading";
17
- export * from "./vault";
18
- export * from "./websocket";
@@ -1,12 +0,0 @@
1
- import type { CreateMarginAccountRequest, CreateMarginAccountResponse, GetAvailableCollateralParams, GetAvailableCollateralResponse, GetMarginAccountMovementsParams, GetMarginAccountMovementsResponse, ListMarginAccountsParams, ListMarginAccountsResponse, MarginAccountSummary, MarginAccountsAPI, SimulateOrderRiskRequest, SimulateOrderRiskResponse, TransferCollateralRequest, TransferCollateralResponse } from "@0xmonaco/types";
2
- import { BaseAPI } from "../base";
3
- export declare class MarginAccountsAPIImpl extends BaseAPI implements MarginAccountsAPI {
4
- listMarginAccounts(params?: ListMarginAccountsParams): Promise<ListMarginAccountsResponse>;
5
- createMarginAccount(request?: CreateMarginAccountRequest): Promise<CreateMarginAccountResponse>;
6
- getMarginAccountSummary(marginAccountId: string): Promise<MarginAccountSummary>;
7
- getAvailableCollateral(params?: GetAvailableCollateralParams): Promise<GetAvailableCollateralResponse>;
8
- transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
9
- transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
10
- getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
11
- simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
12
- }