@0xmonaco/core 0.0.0-develop-20260412233650 → 0.0.0-develop-20260415185155
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/dist/api/market/api.js +4 -4
- package/dist/api/orderbook/api.js +1 -1
- package/dist/api/profile/api.d.ts +10 -10
- package/dist/api/profile/api.js +18 -18
- package/dist/api/trades/api.d.ts +4 -4
- package/dist/api/trades/api.js +8 -8
- package/dist/api/trading/api.d.ts +2 -2
- package/dist/api/trading/api.js +5 -5
- package/dist/api/websocket/websocket.js +4 -4
- package/package.json +3 -3
package/dist/api/market/api.js
CHANGED
|
@@ -11,8 +11,8 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
11
11
|
if (params?.page !== undefined) {
|
|
12
12
|
searchParams.append("page", params.page.toString());
|
|
13
13
|
}
|
|
14
|
-
if (params?.
|
|
15
|
-
searchParams.append("
|
|
14
|
+
if (params?.page_size !== undefined) {
|
|
15
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
16
16
|
}
|
|
17
17
|
if (params?.market_type) {
|
|
18
18
|
searchParams.append("market_type", params.market_type);
|
|
@@ -32,8 +32,8 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
32
32
|
}
|
|
33
33
|
async getTradingPairBySymbol(symbol) {
|
|
34
34
|
// Backend endpoint expects UUID, not symbol, so we fetch all pairs and filter
|
|
35
|
-
const response = await this.getPaginatedTradingPairs({
|
|
36
|
-
return response.
|
|
35
|
+
const response = await this.getPaginatedTradingPairs({ page_size: 100 });
|
|
36
|
+
return response.trading_pairs.find((pair) => pair.symbol === symbol);
|
|
37
37
|
}
|
|
38
38
|
async getCandlesticks(tradingPairId, interval, params) {
|
|
39
39
|
// Validate inputs using the trading pair ID schema
|
|
@@ -12,7 +12,7 @@ export class OrderbookAPIImpl extends BaseAPI {
|
|
|
12
12
|
params.set("denomination", denomination.toLowerCase());
|
|
13
13
|
const response = await this.makePublicRequest(`/api/v1/orderbook/${encodeURIComponent(tradingPairId)}?${params.toString()}`);
|
|
14
14
|
return {
|
|
15
|
-
tradingPairId: response.
|
|
15
|
+
tradingPairId: response.symbol,
|
|
16
16
|
tradingMode: response.trading_mode,
|
|
17
17
|
bids: response.data.bids.map((level) => ({
|
|
18
18
|
price: level.price,
|
|
@@ -61,12 +61,12 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
64
|
-
* // Get first page with default
|
|
64
|
+
* // Get first page with default page_size (20)
|
|
65
65
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
66
|
-
* console.log(`Total movements: ${movements.
|
|
66
|
+
* console.log(`Total movements: ${movements.total}`);
|
|
67
67
|
*
|
|
68
|
-
* // Get second page with custom
|
|
69
|
-
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2,
|
|
68
|
+
* // Get second page with custom page_size
|
|
69
|
+
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, page_size: 50 });
|
|
70
70
|
* console.log(`Page ${page2.page} of ${page2.total_pages}`);
|
|
71
71
|
*
|
|
72
72
|
* // Filter by entry type and transaction type
|
|
@@ -84,8 +84,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
84
84
|
* Requires a valid access token to be set.
|
|
85
85
|
*
|
|
86
86
|
* @param params - Optional query parameters for pagination
|
|
87
|
-
* @param params.
|
|
88
|
-
* @param params.
|
|
87
|
+
* @param params.page - Page number (starts from 1, default: 1)
|
|
88
|
+
* @param params.page_size - Number of items per page (default: 20, max: 100)
|
|
89
89
|
* @returns Promise resolving to paginated balances response
|
|
90
90
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
91
91
|
*
|
|
@@ -98,8 +98,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
98
98
|
* console.log(`${balance.symbol}: ${balance.available_balance}`);
|
|
99
99
|
* });
|
|
100
100
|
*
|
|
101
|
-
* // Get
|
|
102
|
-
* const nextBalances = await profileAPI.getUserBalances({
|
|
101
|
+
* // Get page 2 with 50 items per page
|
|
102
|
+
* const nextBalances = await profileAPI.getUserBalances({ page: 2, page_size: 50 });
|
|
103
103
|
* console.log(`Returned ${nextBalances.balances.length} balances`);
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
@@ -171,7 +171,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
171
171
|
*
|
|
172
172
|
* @param params - Optional query parameters for pagination and filtering
|
|
173
173
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
174
|
-
* @param params.
|
|
174
|
+
* @param params.page_size - Number of items per page (default: 20, max: 100)
|
|
175
175
|
* @param params.trading_pair_id - Filter by trading pair ID (UUID)
|
|
176
176
|
* @returns Promise resolving to paginated trades response
|
|
177
177
|
* @throws {ValidationError} When the provided params fail client-side validation
|
|
@@ -181,7 +181,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
181
181
|
* ```typescript
|
|
182
182
|
* // Get first page of trades
|
|
183
183
|
* const trades = await profileAPI.getUserTrades();
|
|
184
|
-
* console.log(`Total trades: ${trades.
|
|
184
|
+
* console.log(`Total trades: ${trades.total}`);
|
|
185
185
|
*
|
|
186
186
|
* // Filter by trading pair
|
|
187
187
|
* const pairTrades = await profileAPI.getUserTrades({ trading_pair_id: "550e8400-e29b-41d4-a716-446655440000" });
|
package/dist/api/profile/api.js
CHANGED
|
@@ -64,12 +64,12 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
64
64
|
*
|
|
65
65
|
* @example
|
|
66
66
|
* ```typescript
|
|
67
|
-
* // Get first page with default
|
|
67
|
+
* // Get first page with default page_size (20)
|
|
68
68
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
69
|
-
* console.log(`Total movements: ${movements.
|
|
69
|
+
* console.log(`Total movements: ${movements.total}`);
|
|
70
70
|
*
|
|
71
|
-
* // Get second page with custom
|
|
72
|
-
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2,
|
|
71
|
+
* // Get second page with custom page_size
|
|
72
|
+
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, page_size: 50 });
|
|
73
73
|
* console.log(`Page ${page2.page} of ${page2.total_pages}`);
|
|
74
74
|
*
|
|
75
75
|
* // Filter by entry type and transaction type
|
|
@@ -87,8 +87,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
87
87
|
if (params?.page !== undefined) {
|
|
88
88
|
searchParams.append("page", params.page.toString());
|
|
89
89
|
}
|
|
90
|
-
if (params?.
|
|
91
|
-
searchParams.append("
|
|
90
|
+
if (params?.page_size !== undefined) {
|
|
91
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
92
92
|
}
|
|
93
93
|
if (params?.entry_type !== undefined) {
|
|
94
94
|
searchParams.append("entry_type", params.entry_type);
|
|
@@ -110,8 +110,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
110
110
|
* Requires a valid access token to be set.
|
|
111
111
|
*
|
|
112
112
|
* @param params - Optional query parameters for pagination
|
|
113
|
-
* @param params.
|
|
114
|
-
* @param params.
|
|
113
|
+
* @param params.page - Page number (starts from 1, default: 1)
|
|
114
|
+
* @param params.page_size - Number of items per page (default: 20, max: 100)
|
|
115
115
|
* @returns Promise resolving to paginated balances response
|
|
116
116
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
117
117
|
*
|
|
@@ -124,18 +124,18 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
124
124
|
* console.log(`${balance.symbol}: ${balance.available_balance}`);
|
|
125
125
|
* });
|
|
126
126
|
*
|
|
127
|
-
* // Get
|
|
128
|
-
* const nextBalances = await profileAPI.getUserBalances({
|
|
127
|
+
* // Get page 2 with 50 items per page
|
|
128
|
+
* const nextBalances = await profileAPI.getUserBalances({ page: 2, page_size: 50 });
|
|
129
129
|
* console.log(`Returned ${nextBalances.balances.length} balances`);
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
132
|
async getUserBalances(params) {
|
|
133
133
|
const searchParams = new URLSearchParams();
|
|
134
|
-
if (params?.
|
|
135
|
-
searchParams.append("
|
|
134
|
+
if (params?.page !== undefined) {
|
|
135
|
+
searchParams.append("page", params.page.toString());
|
|
136
136
|
}
|
|
137
|
-
if (params?.
|
|
138
|
-
searchParams.append("
|
|
137
|
+
if (params?.page_size !== undefined) {
|
|
138
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
139
139
|
}
|
|
140
140
|
const queryString = searchParams.toString();
|
|
141
141
|
const url = queryString ? `/api/v1/accounts/balances?${queryString}` : "/api/v1/accounts/balances";
|
|
@@ -222,7 +222,7 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
222
222
|
*
|
|
223
223
|
* @param params - Optional query parameters for pagination and filtering
|
|
224
224
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
225
|
-
* @param params.
|
|
225
|
+
* @param params.page_size - Number of items per page (default: 20, max: 100)
|
|
226
226
|
* @param params.trading_pair_id - Filter by trading pair ID (UUID)
|
|
227
227
|
* @returns Promise resolving to paginated trades response
|
|
228
228
|
* @throws {ValidationError} When the provided params fail client-side validation
|
|
@@ -232,7 +232,7 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
232
232
|
* ```typescript
|
|
233
233
|
* // Get first page of trades
|
|
234
234
|
* const trades = await profileAPI.getUserTrades();
|
|
235
|
-
* console.log(`Total trades: ${trades.
|
|
235
|
+
* console.log(`Total trades: ${trades.total}`);
|
|
236
236
|
*
|
|
237
237
|
* // Filter by trading pair
|
|
238
238
|
* const pairTrades = await profileAPI.getUserTrades({ trading_pair_id: "550e8400-e29b-41d4-a716-446655440000" });
|
|
@@ -246,8 +246,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
246
246
|
if (params?.page !== undefined) {
|
|
247
247
|
searchParams.append("page", params.page.toString());
|
|
248
248
|
}
|
|
249
|
-
if (params?.
|
|
250
|
-
searchParams.append("
|
|
249
|
+
if (params?.page_size !== undefined) {
|
|
250
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
251
251
|
}
|
|
252
252
|
if (params?.trading_pair_id !== undefined) {
|
|
253
253
|
searchParams.append("trading_pair_id", params.trading_pair_id);
|
package/dist/api/trades/api.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseAPI } from "../base";
|
|
|
5
5
|
*/
|
|
6
6
|
interface RawTradeEvent {
|
|
7
7
|
event_type: string;
|
|
8
|
-
|
|
8
|
+
trading_pair_id: string;
|
|
9
9
|
trading_mode: string;
|
|
10
10
|
data: {
|
|
11
11
|
trade_id: string;
|
|
@@ -23,10 +23,10 @@ export declare function parseRawTradeEvent(raw: RawTradeEvent): TradeEvent;
|
|
|
23
23
|
* Options for fetching trades
|
|
24
24
|
*/
|
|
25
25
|
export interface GetTradesOptions {
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** Page number (starts from 1, default: 1) */
|
|
27
|
+
page?: number;
|
|
28
28
|
/** Maximum number of records to return (default: 25, max: 100) */
|
|
29
|
-
|
|
29
|
+
page_size?: number;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Trades API for fetching historical trade data
|
package/dist/api/trades/api.js
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseAPI } from "../base";
|
|
|
5
5
|
export function parseRawTradeEvent(raw) {
|
|
6
6
|
return {
|
|
7
7
|
eventType: "trade",
|
|
8
|
-
tradingPairId: raw.
|
|
8
|
+
tradingPairId: raw.trading_pair_id,
|
|
9
9
|
tradingMode: raw.trading_mode.toUpperCase(),
|
|
10
10
|
data: {
|
|
11
11
|
tradeId: raw.data.trade_id,
|
|
@@ -28,15 +28,15 @@ export class TradesAPIImpl extends BaseAPI {
|
|
|
28
28
|
* @returns Array of TradeEvent records sorted by executed_at descending (newest first)
|
|
29
29
|
*/
|
|
30
30
|
async getTrades(tradingPairId, options = {}) {
|
|
31
|
-
const {
|
|
32
|
-
// Ensure
|
|
33
|
-
const
|
|
31
|
+
const { page = 1 } = options;
|
|
32
|
+
// Ensure page_size is a positive number between 1 and 100, defaulting to 25
|
|
33
|
+
const page_size = options.page_size != null && options.page_size > 0 ? Math.min(options.page_size, 100) : 25;
|
|
34
34
|
const params = new URLSearchParams();
|
|
35
|
-
if (
|
|
36
|
-
params.set("
|
|
35
|
+
if (page > 1) {
|
|
36
|
+
params.set("page", String(page));
|
|
37
37
|
}
|
|
38
|
-
params.set("
|
|
38
|
+
params.set("page_size", String(page_size));
|
|
39
39
|
const response = await this.makePublicRequest(`/api/v1/trades/${encodeURIComponent(tradingPairId)}?${params.toString()}`);
|
|
40
|
-
return response.
|
|
40
|
+
return response.trades.map(parseRawTradeEvent);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -242,7 +242,7 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
242
242
|
*
|
|
243
243
|
* @param params - Query parameters for filtering orders
|
|
244
244
|
* @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED") (optional)
|
|
245
|
-
* @param params.
|
|
245
|
+
* @param params.trading_pair_id - Filter by trading pair UUID (optional)
|
|
246
246
|
* @param params.page - Page number for pagination (defaults to 1, must be > 0)
|
|
247
247
|
* @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
|
|
248
248
|
* @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
|
|
@@ -253,7 +253,7 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
253
253
|
* // Get submitted orders for a specific trading pair with custom pagination
|
|
254
254
|
* const orders = await tradingAPI.getPaginatedOrders({
|
|
255
255
|
* status: "SUBMITTED",
|
|
256
|
-
*
|
|
256
|
+
* trading_pair_id: "456e7890-e12b-12d3-a456-426614174000",
|
|
257
257
|
* page: 1,
|
|
258
258
|
* page_size: 20
|
|
259
259
|
* });
|
package/dist/api/trading/api.js
CHANGED
|
@@ -348,7 +348,7 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
348
348
|
*
|
|
349
349
|
* @param params - Query parameters for filtering orders
|
|
350
350
|
* @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED") (optional)
|
|
351
|
-
* @param params.
|
|
351
|
+
* @param params.trading_pair_id - Filter by trading pair UUID (optional)
|
|
352
352
|
* @param params.page - Page number for pagination (defaults to 1, must be > 0)
|
|
353
353
|
* @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
|
|
354
354
|
* @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
|
|
@@ -359,7 +359,7 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
359
359
|
* // Get submitted orders for a specific trading pair with custom pagination
|
|
360
360
|
* const orders = await tradingAPI.getPaginatedOrders({
|
|
361
361
|
* status: "SUBMITTED",
|
|
362
|
-
*
|
|
362
|
+
* trading_pair_id: "456e7890-e12b-12d3-a456-426614174000",
|
|
363
363
|
* page: 1,
|
|
364
364
|
* page_size: 20
|
|
365
365
|
* });
|
|
@@ -375,7 +375,7 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
375
375
|
validate(GetPaginatedOrdersSchema, params);
|
|
376
376
|
}
|
|
377
377
|
// Set pagination defaults with destructuring and validation
|
|
378
|
-
const { page = 1, page_size = 10, status,
|
|
378
|
+
const { page = 1, page_size = 10, status, trading_pair_id } = params || {};
|
|
379
379
|
const validPage = page > 0 ? page : 1;
|
|
380
380
|
const validPageSize = page_size > 0 ? page_size : 10;
|
|
381
381
|
const pageSize = Math.min(validPageSize, 100);
|
|
@@ -386,8 +386,8 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
386
386
|
if (status) {
|
|
387
387
|
searchParams.append("status", status);
|
|
388
388
|
}
|
|
389
|
-
if (
|
|
390
|
-
searchParams.append("
|
|
389
|
+
if (trading_pair_id) {
|
|
390
|
+
searchParams.append("trading_pair_id", trading_pair_id);
|
|
391
391
|
}
|
|
392
392
|
const endpoint = `/api/v1/orders?${searchParams.toString()}`;
|
|
393
393
|
return await this.makeAuthenticatedRequest(endpoint, {
|
|
@@ -207,7 +207,7 @@ export function createMonacoWebSocket(baseUrl, options = {}) {
|
|
|
207
207
|
const data = rawData;
|
|
208
208
|
const orderbookData = data.data;
|
|
209
209
|
const event = {
|
|
210
|
-
tradingPairId: data.
|
|
210
|
+
tradingPairId: data.symbol,
|
|
211
211
|
tradingMode: data.trading_mode,
|
|
212
212
|
bids: (orderbookData?.bids || []).map((level) => ({
|
|
213
213
|
price: level.price,
|
|
@@ -251,7 +251,7 @@ export function createMonacoWebSocket(baseUrl, options = {}) {
|
|
|
251
251
|
const data = rawData;
|
|
252
252
|
const ohlcvData = data.data;
|
|
253
253
|
const event = {
|
|
254
|
-
tradingPairId: data.
|
|
254
|
+
tradingPairId: data.symbol,
|
|
255
255
|
tradingMode: data.trading_mode,
|
|
256
256
|
interval: data.interval,
|
|
257
257
|
candlestick: {
|
|
@@ -262,7 +262,7 @@ export function createMonacoWebSocket(baseUrl, options = {}) {
|
|
|
262
262
|
l: ohlcvData.low || "0",
|
|
263
263
|
c: ohlcvData.close || "0",
|
|
264
264
|
v: ohlcvData.volume || "0",
|
|
265
|
-
s: data.
|
|
265
|
+
s: data.symbol,
|
|
266
266
|
i: data.interval,
|
|
267
267
|
n: ohlcvData.trades_count || 0,
|
|
268
268
|
},
|
|
@@ -282,7 +282,7 @@ export function createMonacoWebSocket(baseUrl, options = {}) {
|
|
|
282
282
|
const tradeData = data.data;
|
|
283
283
|
const event = {
|
|
284
284
|
eventType: "trade",
|
|
285
|
-
tradingPairId: data.
|
|
285
|
+
tradingPairId: data.trading_pair_id,
|
|
286
286
|
tradingMode: data.trading_mode.toUpperCase(),
|
|
287
287
|
data: {
|
|
288
288
|
tradeId: tradeData.trade_id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "0.0.0-develop-
|
|
3
|
+
"version": "0.0.0-develop-20260415185155",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"viem": "^2.45.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@0xmonaco/contracts": "0.0.0-develop-
|
|
27
|
-
"@0xmonaco/types": "0.0.0-develop-
|
|
26
|
+
"@0xmonaco/contracts": "0.0.0-develop-20260415185155",
|
|
27
|
+
"@0xmonaco/types": "0.0.0-develop-20260415185155",
|
|
28
28
|
"http-status-codes": "^2.3.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|