quidax-node 3.0.0
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 +149 -0
- package/dist/index.cjs +767 -0
- package/dist/index.d.cts +772 -0
- package/dist/index.d.mts +772 -0
- package/dist/index.mjs +727 -0
- package/package.json +48 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
var __create = Object.create;
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
//#endregion
|
|
27
|
+
let axios = require("axios");
|
|
28
|
+
axios = __toESM(axios);
|
|
29
|
+
//#region src/errors.ts
|
|
30
|
+
var QuidaxError = class QuidaxError extends Error {
|
|
31
|
+
statusCode;
|
|
32
|
+
status;
|
|
33
|
+
data;
|
|
34
|
+
isQuidaxError = true;
|
|
35
|
+
constructor(statusCode, status, message, data) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = "QuidaxError";
|
|
38
|
+
this.statusCode = statusCode;
|
|
39
|
+
this.status = status;
|
|
40
|
+
this.data = data;
|
|
41
|
+
Object.setPrototypeOf(this, QuidaxError.prototype);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/client.ts
|
|
46
|
+
var BaseClient = class {
|
|
47
|
+
httpClient;
|
|
48
|
+
exchangeBaseURL;
|
|
49
|
+
rampBaseURL;
|
|
50
|
+
constructor(config) {
|
|
51
|
+
if (!config.secretKey) throw new Error("Quidax secretKey is required.");
|
|
52
|
+
this.exchangeBaseURL = config.exchangeBaseURL || "https://openapi.quidax.io/exchange-open-api/api/v1";
|
|
53
|
+
this.rampBaseURL = config.rampBaseURL || "https://ramp-be.quidax.io/api/v1";
|
|
54
|
+
this.httpClient = axios.default.create({
|
|
55
|
+
timeout: config.timeout || 3e4,
|
|
56
|
+
headers: {
|
|
57
|
+
"Authorization": `Bearer ${config.secretKey}`,
|
|
58
|
+
"Content-Type": "application/json"
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
this.httpClient.interceptors.response.use((response) => response, (error) => {
|
|
62
|
+
if (axios.default.isAxiosError(error) && error.response) {
|
|
63
|
+
const status = error.response.status;
|
|
64
|
+
const data = error.response.data || {};
|
|
65
|
+
throw new QuidaxError(status, data.status || "error", data.message || error.message, data.data || data.errors || data);
|
|
66
|
+
}
|
|
67
|
+
if (axios.default.isAxiosError(error) && error.request) throw new QuidaxError(0, "network_error", error.message);
|
|
68
|
+
throw error;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
resolveURL(url, isRamp = false) {
|
|
72
|
+
return `${isRamp ? this.rampBaseURL : this.exchangeBaseURL}${url}`;
|
|
73
|
+
}
|
|
74
|
+
async get(url, config) {
|
|
75
|
+
const { isRamp, ...axiosConfig } = config || {};
|
|
76
|
+
return (await this.httpClient.get(this.resolveURL(url, isRamp), axiosConfig)).data;
|
|
77
|
+
}
|
|
78
|
+
async post(url, data, config) {
|
|
79
|
+
const { isRamp, ...axiosConfig } = config || {};
|
|
80
|
+
return (await this.httpClient.post(this.resolveURL(url, isRamp), data, axiosConfig)).data;
|
|
81
|
+
}
|
|
82
|
+
async put(url, data, config) {
|
|
83
|
+
const { isRamp, ...axiosConfig } = config || {};
|
|
84
|
+
return (await this.httpClient.put(this.resolveURL(url, isRamp), data, axiosConfig)).data;
|
|
85
|
+
}
|
|
86
|
+
async delete(url, config) {
|
|
87
|
+
const { isRamp, ...axiosConfig } = config || {};
|
|
88
|
+
return (await this.httpClient.delete(this.resolveURL(url, isRamp), axiosConfig)).data;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/modules/users.ts
|
|
93
|
+
var UsersModule = class {
|
|
94
|
+
constructor(client) {
|
|
95
|
+
this.client = client;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a new sub-account tethered to the authenticated user.
|
|
99
|
+
*
|
|
100
|
+
* @param data - The details of the user to create.
|
|
101
|
+
* @param data.email - The email of the sub user (must be unique).
|
|
102
|
+
* @param data.first_name - The first name of the sub user.
|
|
103
|
+
* @param data.last_name - The last name of the sub user.
|
|
104
|
+
* @param data.phone_number - Optional phone number.
|
|
105
|
+
* @returns A promise resolving to the created User object.
|
|
106
|
+
* @throws {QuidaxError} If validation fails or email already exists.
|
|
107
|
+
*/
|
|
108
|
+
async create(data) {
|
|
109
|
+
return this.client.post("/users", data);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Fetches the parent (master) account tied to the authenticated secret key.
|
|
113
|
+
*
|
|
114
|
+
* @returns A promise resolving to the Parent User object.
|
|
115
|
+
*/
|
|
116
|
+
async getParentAccount() {
|
|
117
|
+
return this.client.get("/users/me");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Edits the details of an existing sub-account.
|
|
121
|
+
*
|
|
122
|
+
* @param userId - The unique ID or reference of the sub-account.
|
|
123
|
+
* @param data - The data to update.
|
|
124
|
+
* @returns A promise resolving to the updated User object.
|
|
125
|
+
*/
|
|
126
|
+
async edit(userId, data) {
|
|
127
|
+
return this.client.put(`/users/${userId}`, data);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Fetches all sub-accounts tied to the authenticated parent account.
|
|
131
|
+
*
|
|
132
|
+
* @returns A promise resolving to a list of User objects.
|
|
133
|
+
*/
|
|
134
|
+
async getAll() {
|
|
135
|
+
return this.client.get("/users");
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fetches the detailed profile of a specific sub-account.
|
|
139
|
+
*
|
|
140
|
+
* @param userId - The unique ID or reference of the sub-account.
|
|
141
|
+
* @returns A promise resolving to the User object.
|
|
142
|
+
* @throws {QuidaxError} If the user is not found.
|
|
143
|
+
*/
|
|
144
|
+
async getOne(userId) {
|
|
145
|
+
return this.client.get(`/users/${userId}`);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/modules/wallets.ts
|
|
150
|
+
var WalletsModule = class {
|
|
151
|
+
constructor(client) {
|
|
152
|
+
this.client = client;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Fetches all wallets for a given user.
|
|
156
|
+
*
|
|
157
|
+
* @param userId - The unique ID of the user. 'me' can be used for the authenticated user.
|
|
158
|
+
* @returns A promise resolving to an array of Wallet objects.
|
|
159
|
+
*/
|
|
160
|
+
async getAll(userId) {
|
|
161
|
+
return this.client.get(`/users/${userId}/wallets`);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Fetches a specific cryptocurrency wallet for a user.
|
|
165
|
+
*
|
|
166
|
+
* @param userId - The unique ID of the user.
|
|
167
|
+
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
|
|
168
|
+
* @returns A promise resolving to a single Wallet object.
|
|
169
|
+
*/
|
|
170
|
+
async getOne(userId, currency) {
|
|
171
|
+
return this.client.get(`/users/${userId}/wallets/${currency}`);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Fetches the default Payment Address for a specific user's wallet.
|
|
175
|
+
*
|
|
176
|
+
* @param userId - The unique ID of the user.
|
|
177
|
+
* @param currency - The cryptocurrency ticker.
|
|
178
|
+
* @returns A promise resolving to the primary PaymentAddress object.
|
|
179
|
+
*/
|
|
180
|
+
async getPaymentAddress(userId, currency) {
|
|
181
|
+
return this.client.get(`/users/${userId}/wallets/${currency}/address`);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Fetches all generated Payment Addresses for a specific user's wallet.
|
|
185
|
+
*
|
|
186
|
+
* @param userId - The unique ID of the user.
|
|
187
|
+
* @param currency - The cryptocurrency ticker.
|
|
188
|
+
* @returns A promise resolving to an array of PaymentAddress objects.
|
|
189
|
+
*/
|
|
190
|
+
async getAllPaymentAddresses(userId, currency) {
|
|
191
|
+
return this.client.get(`/users/${userId}/wallets/${currency}/addresses`);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Fetches a specific Payment Address by its ID.
|
|
195
|
+
*
|
|
196
|
+
* @param userId - The unique ID of the user.
|
|
197
|
+
* @param currency - The cryptocurrency ticker.
|
|
198
|
+
* @param addressId - The ID of the specific payment address.
|
|
199
|
+
* @returns A promise resolving to the PaymentAddress object.
|
|
200
|
+
*/
|
|
201
|
+
async getPaymentAddressById(userId, currency, addressId) {
|
|
202
|
+
return this.client.get(`/users/${userId}/wallets/${currency}/addresses/${addressId}`);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Generates a new Payment Address for a cryptocurrency wallet.
|
|
206
|
+
*
|
|
207
|
+
* @param userId - The unique ID of the user.
|
|
208
|
+
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'eth').
|
|
209
|
+
* @returns A promise resolving to the newly generated PaymentAddress object.
|
|
210
|
+
*/
|
|
211
|
+
async createPaymentAddress(userId, currency) {
|
|
212
|
+
return this.client.post(`/users/${userId}/wallets/${currency}/addresses`);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/modules/withdrawals.ts
|
|
217
|
+
var WithdrawalsModule = class {
|
|
218
|
+
constructor(client) {
|
|
219
|
+
this.client = client;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Fetches a paginated list of all withdrawals for a user.
|
|
223
|
+
*
|
|
224
|
+
* @param userId - The unique ID of the user.
|
|
225
|
+
* @returns A promise resolving to a paginated list of Withdrawal objects.
|
|
226
|
+
*/
|
|
227
|
+
async getAll(userId) {
|
|
228
|
+
return this.client.get(`/users/${userId}/withdraws`);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Fetches the details of a specific withdrawal.
|
|
232
|
+
*
|
|
233
|
+
* @param userId - The unique ID of the user.
|
|
234
|
+
* @param withdrawalId - The ID of the withdrawal to retrieve.
|
|
235
|
+
* @returns A promise resolving to a single Withdrawal object.
|
|
236
|
+
*/
|
|
237
|
+
async getOne(userId, withdrawalId) {
|
|
238
|
+
return this.client.get(`/users/${userId}/withdraws/${withdrawalId}`);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Fetches a withdrawal by its unique reference string.
|
|
242
|
+
*
|
|
243
|
+
* @param userId - The unique ID of the user.
|
|
244
|
+
* @param reference - The withdrawal reference string.
|
|
245
|
+
* @returns A promise resolving to a single Withdrawal object.
|
|
246
|
+
*/
|
|
247
|
+
async getByReference(userId, reference) {
|
|
248
|
+
return this.client.get(`/users/${userId}/withdraws/reference/${reference}`);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Initiates a new cryptocurrency withdrawal.
|
|
252
|
+
*
|
|
253
|
+
* @param userId - The unique ID of the user.
|
|
254
|
+
* @param data - The withdrawal details.
|
|
255
|
+
* @param data.currency - The cryptocurrency ticker (e.g., 'btc').
|
|
256
|
+
* @param data.amount - The amount to withdraw.
|
|
257
|
+
* @param data.fund_uid - The ID of the destination address/fund.
|
|
258
|
+
* @param data.transaction_note - Optional note for the transaction.
|
|
259
|
+
* @returns A promise resolving to the created Withdrawal object.
|
|
260
|
+
*/
|
|
261
|
+
async create(userId, data) {
|
|
262
|
+
return this.client.post(`/users/${userId}/withdraws`, data);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Cancels a pending withdrawal.
|
|
266
|
+
*
|
|
267
|
+
* @param userId - The unique ID of the user.
|
|
268
|
+
* @param withdrawalId - The ID of the withdrawal to cancel.
|
|
269
|
+
* @returns A promise resolving to the canceled Withdrawal object.
|
|
270
|
+
*/
|
|
271
|
+
async cancel(userId, withdrawalId) {
|
|
272
|
+
return this.client.post(`/users/${userId}/withdraws/${withdrawalId}/cancel`);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/modules/markets.ts
|
|
277
|
+
var MarketsModule = class {
|
|
278
|
+
constructor(client) {
|
|
279
|
+
this.client = client;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Retrieves a list of all active markets on Quidax.
|
|
283
|
+
*
|
|
284
|
+
* @returns A promise resolving to an array of Market objects.
|
|
285
|
+
*/
|
|
286
|
+
async getAll() {
|
|
287
|
+
return this.client.get("/markets");
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Retrieves tickers for all available markets.
|
|
291
|
+
*
|
|
292
|
+
* @returns A promise resolving to a record mapping market pairs to their Ticker data.
|
|
293
|
+
*/
|
|
294
|
+
async getTickers() {
|
|
295
|
+
return this.client.get("/markets/tickers");
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Retrieves the current ticker data for a specific market.
|
|
299
|
+
*
|
|
300
|
+
* @param currency - The market pair (e.g., 'btcngn').
|
|
301
|
+
* @returns A promise resolving to the Ticker data.
|
|
302
|
+
*/
|
|
303
|
+
async getTicker(currency) {
|
|
304
|
+
return this.client.get(`/markets/tickers/${currency}`);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Retrieves candlestick (k-line) data for a specific market.
|
|
308
|
+
*
|
|
309
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
310
|
+
* @param params - Optional query parameters.
|
|
311
|
+
* @param params.limit - The number of data points to return.
|
|
312
|
+
* @param params.period - The time period in minutes.
|
|
313
|
+
* @param params.timestamp - Starting timestamp.
|
|
314
|
+
* @returns A promise resolving to an array of k-line data points.
|
|
315
|
+
*/
|
|
316
|
+
async getKLine(market, params) {
|
|
317
|
+
return this.client.get(`/markets/${market}/k`, { params });
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Retrieves candlestick data including pending trades for a market.
|
|
321
|
+
*
|
|
322
|
+
* @param currency - The market pair (e.g., 'btcngn').
|
|
323
|
+
* @param tradeId - The ID of the pending trade reference.
|
|
324
|
+
* @param params - Optional query parameters.
|
|
325
|
+
* @returns A promise resolving to an array of k-line data points.
|
|
326
|
+
*/
|
|
327
|
+
async getKLineWithPending(currency, tradeId, params) {
|
|
328
|
+
return this.client.get(`/markets/${currency}/k_with_pending_trades/${tradeId}`, { params });
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Retrieves the order book (asks and bids) for a specific market.
|
|
332
|
+
*
|
|
333
|
+
* @param currency - The market pair (e.g., 'btcngn').
|
|
334
|
+
* @param params - Optional query parameters to limit asks and bids.
|
|
335
|
+
* @returns A promise resolving to the OrderBook object.
|
|
336
|
+
*/
|
|
337
|
+
async getOrderBook(currency, params) {
|
|
338
|
+
return this.client.get(`/markets/${currency}/order_book`, { params });
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Retrieves market depth data.
|
|
342
|
+
*
|
|
343
|
+
* @param currency - The market pair (e.g., 'btcngn').
|
|
344
|
+
* @param params - Optional limit parameter.
|
|
345
|
+
* @returns A promise resolving to depth data.
|
|
346
|
+
*/
|
|
347
|
+
async getDepth(currency, params) {
|
|
348
|
+
return this.client.get(`/markets/${currency}/depth`, { params });
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Retrieves a high-level summary of all markets.
|
|
352
|
+
*
|
|
353
|
+
* @returns A promise resolving to an array of market summaries.
|
|
354
|
+
*/
|
|
355
|
+
async getSummary() {
|
|
356
|
+
return this.client.get("/markets/summary/");
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/modules/trades.ts
|
|
361
|
+
var TradesModule = class {
|
|
362
|
+
constructor(client) {
|
|
363
|
+
this.client = client;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Fetches the user's historical trades.
|
|
367
|
+
*
|
|
368
|
+
* @param userId - The unique ID of the user.
|
|
369
|
+
* @returns A promise resolving to a paginated list of Trade objects.
|
|
370
|
+
*/
|
|
371
|
+
async getUserTrades(userId) {
|
|
372
|
+
return this.client.get(`/users/${userId}/trades`);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Fetches recent trades for a given market pair.
|
|
376
|
+
*
|
|
377
|
+
* @param marketPair - The market pair (e.g., 'btcngn').
|
|
378
|
+
* @returns A promise resolving to an array of Trade objects.
|
|
379
|
+
*/
|
|
380
|
+
async getMarketTrades(marketPair) {
|
|
381
|
+
return this.client.get(`/trades/${marketPair}`);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/modules/deposits.ts
|
|
386
|
+
var DepositsModule = class {
|
|
387
|
+
constructor(client) {
|
|
388
|
+
this.client = client;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Fetches all cryptocurrency deposits for a specific user.
|
|
392
|
+
*
|
|
393
|
+
* @param userId - The unique ID of the user.
|
|
394
|
+
* @param params - Optional filters (state, currency).
|
|
395
|
+
* @returns A promise resolving to a paginated list of Deposit objects.
|
|
396
|
+
*/
|
|
397
|
+
async getAll(userId, params) {
|
|
398
|
+
return this.client.get(`/users/${userId}/deposits`, { params });
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Fetches the details of a specific deposit by ID.
|
|
402
|
+
*
|
|
403
|
+
* @param userId - The unique ID of the user.
|
|
404
|
+
* @param depositId - The unique ID of the deposit.
|
|
405
|
+
* @returns A promise resolving to a single Deposit object.
|
|
406
|
+
*/
|
|
407
|
+
async getOne(userId, depositId) {
|
|
408
|
+
return this.client.get(`/users/${userId}/deposits/${depositId}`);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Fetches deposits made by all sub-users across the platform.
|
|
412
|
+
*
|
|
413
|
+
* @param params - Optional filters (state, currency).
|
|
414
|
+
* @returns A promise resolving to a paginated list of Deposit objects.
|
|
415
|
+
*/
|
|
416
|
+
async getSubUsersDeposits(params) {
|
|
417
|
+
return this.client.get("/users/deposits/all", { params });
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/modules/swap.ts
|
|
422
|
+
var SwapModule = class {
|
|
423
|
+
constructor(client) {
|
|
424
|
+
this.client = client;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Generates a temporary swap quotation for previewing a swap before creation.
|
|
428
|
+
*
|
|
429
|
+
* @param userId - The unique ID of the user.
|
|
430
|
+
* @param data - The swap quotation parameters.
|
|
431
|
+
* @returns A promise resolving to the temporary swap quotation details.
|
|
432
|
+
*/
|
|
433
|
+
async getQuotation(userId, data) {
|
|
434
|
+
return this.client.post(`/users/${userId}/temporary_swap_quotation`, data);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Creates an Instant Swap quotation linked to the user account.
|
|
438
|
+
*
|
|
439
|
+
* @param userId - The unique ID of the user.
|
|
440
|
+
* @param data - The swap creation payload.
|
|
441
|
+
* @returns A promise resolving to a SwapTransaction object in an unconfirmed state.
|
|
442
|
+
*/
|
|
443
|
+
async create(userId, data) {
|
|
444
|
+
return this.client.post(`/users/${userId}/swap_quotation`, data);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Confirms a previously created Instant Swap quotation.
|
|
448
|
+
*
|
|
449
|
+
* @param userId - The unique ID of the user.
|
|
450
|
+
* @param quotationId - The ID of the swap quotation to confirm.
|
|
451
|
+
* @returns A promise resolving to the confirmed SwapTransaction.
|
|
452
|
+
*/
|
|
453
|
+
async confirm(userId, quotationId) {
|
|
454
|
+
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/confirm`);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Refreshes an expired Instant Swap quotation to get updated market rates.
|
|
458
|
+
*
|
|
459
|
+
* @param userId - The unique ID of the user.
|
|
460
|
+
* @param quotationId - The ID of the expired swap quotation.
|
|
461
|
+
* @returns A promise resolving to the refreshed SwapTransaction.
|
|
462
|
+
*/
|
|
463
|
+
async refresh(userId, quotationId) {
|
|
464
|
+
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh`);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Fetches the details of a specific Swap Transaction.
|
|
468
|
+
*
|
|
469
|
+
* @param userId - The unique ID of the user.
|
|
470
|
+
* @param swapTransactionId - The ID of the swap transaction.
|
|
471
|
+
* @returns A promise resolving to the SwapTransaction details.
|
|
472
|
+
*/
|
|
473
|
+
async getOne(userId, swapTransactionId) {
|
|
474
|
+
return this.client.get(`/users/${userId}/swap_transactions/${swapTransactionId}`);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Retrieves a paginated list of all swap transactions for a user.
|
|
478
|
+
*
|
|
479
|
+
* @param userId - The unique ID of the user.
|
|
480
|
+
* @returns A promise resolving to a paginated list of SwapTransactions.
|
|
481
|
+
*/
|
|
482
|
+
async getAll(userId) {
|
|
483
|
+
return this.client.get(`/users/${userId}/swap_transactions`);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/modules/orders.ts
|
|
488
|
+
var OrdersModule = class {
|
|
489
|
+
constructor(client) {
|
|
490
|
+
this.client = client;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Places a new limit or market order.
|
|
494
|
+
*
|
|
495
|
+
* @param userId - The unique ID of the user.
|
|
496
|
+
* @param data - The order details.
|
|
497
|
+
* @param data.market - The market pair (e.g., 'btcngn').
|
|
498
|
+
* @param data.side - The side of the order ('buy' or 'sell').
|
|
499
|
+
* @param data.ord_type - The type of order ('limit' or 'market').
|
|
500
|
+
* @param data.price - The price per unit (required for limit orders).
|
|
501
|
+
* @param data.volume - The amount of cryptocurrency to buy or sell.
|
|
502
|
+
* @returns A promise resolving to the created Order object.
|
|
503
|
+
*/
|
|
504
|
+
async create(userId, data) {
|
|
505
|
+
return this.client.post(`/users/${userId}/orders`, data);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Fetches a paginated list of all orders (buy/sell) for a user.
|
|
509
|
+
*
|
|
510
|
+
* @param userId - The unique ID of the user.
|
|
511
|
+
* @param params - Optional filters (market, state, order_by).
|
|
512
|
+
* @returns A promise resolving to a paginated list of Order objects.
|
|
513
|
+
*/
|
|
514
|
+
async getAll(userId, params) {
|
|
515
|
+
return this.client.get(`/users/${userId}/orders`, { params });
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Fetches the details of a specific order.
|
|
519
|
+
*
|
|
520
|
+
* @param userId - The unique ID of the user.
|
|
521
|
+
* @param orderId - The unique ID of the order.
|
|
522
|
+
* @returns A promise resolving to a single Order object.
|
|
523
|
+
*/
|
|
524
|
+
async getOne(userId, orderId) {
|
|
525
|
+
return this.client.get(`/users/${userId}/orders/${orderId}`);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Cancels a pending or open order.
|
|
529
|
+
*
|
|
530
|
+
* @param userId - The unique ID of the user.
|
|
531
|
+
* @param orderId - The unique ID of the order to cancel.
|
|
532
|
+
* @returns A promise resolving to the canceled Order object.
|
|
533
|
+
*/
|
|
534
|
+
async cancel(userId, orderId) {
|
|
535
|
+
return this.client.post(`/users/${userId}/orders/${orderId}/cancel`);
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/modules/fees.ts
|
|
540
|
+
var FeesModule = class {
|
|
541
|
+
constructor(client) {
|
|
542
|
+
this.client = client;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Fetches the current withdrawal fees for all supported cryptocurrencies.
|
|
546
|
+
*
|
|
547
|
+
* @returns A promise resolving to an array of fee information objects.
|
|
548
|
+
*/
|
|
549
|
+
async getCryptoWithdrawalFees() {
|
|
550
|
+
return this.client.get(`/fee`);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/modules/ramp.ts
|
|
555
|
+
var RampModule = class {
|
|
556
|
+
constructor(client) {
|
|
557
|
+
this.client = client;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Fetches available payment methods for Fiat On-ramp or Off-ramp.
|
|
561
|
+
*
|
|
562
|
+
* @returns A promise resolving to the supported payment methods.
|
|
563
|
+
*/
|
|
564
|
+
async getPaymentMethods() {
|
|
565
|
+
return this.client.get("/merchants/payment_methods", { isRamp: true });
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Fetches the minimum and maximum purchase limits for buying cryptocurrency (On-ramp).
|
|
569
|
+
*
|
|
570
|
+
* @returns A promise resolving to the buy limits.
|
|
571
|
+
*/
|
|
572
|
+
async getBuyLimits() {
|
|
573
|
+
return this.client.get("/merchants/purchase_limits/buy", { isRamp: true });
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Fetches the minimum and maximum purchase limits for selling cryptocurrency (Off-ramp).
|
|
577
|
+
*
|
|
578
|
+
* @returns A promise resolving to the sell limits.
|
|
579
|
+
*/
|
|
580
|
+
async getSellLimits() {
|
|
581
|
+
return this.client.get("/merchants/purchase_limits/sell", { isRamp: true });
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Generates a purchase quote for buying cryptocurrency with fiat.
|
|
585
|
+
*
|
|
586
|
+
* @param params - The quote parameters (e.g., fiat, crypto, amount).
|
|
587
|
+
* @returns A promise resolving to the buy quote details.
|
|
588
|
+
*/
|
|
589
|
+
async getBuyQuote(params) {
|
|
590
|
+
return this.client.get("/merchants/purchase_quotes/buy", {
|
|
591
|
+
params,
|
|
592
|
+
isRamp: true
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Generates a purchase quote for selling cryptocurrency for fiat.
|
|
597
|
+
*
|
|
598
|
+
* @param params - The quote parameters.
|
|
599
|
+
* @returns A promise resolving to the sell quote details.
|
|
600
|
+
*/
|
|
601
|
+
async getSellQuote(params) {
|
|
602
|
+
return this.client.get("/merchants/purchase_quotes/sell", {
|
|
603
|
+
params,
|
|
604
|
+
isRamp: true
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Fetches the details of an existing Off-ramp transaction (Crypto -> Fiat).
|
|
609
|
+
*
|
|
610
|
+
* @param reference - The unique reference of the transaction.
|
|
611
|
+
* @returns A promise resolving to the transaction details.
|
|
612
|
+
*/
|
|
613
|
+
async getOffRampTransaction(reference) {
|
|
614
|
+
return this.client.get(`/merchants/off_ramp_transaction/${reference}`, { isRamp: true });
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Fetches the details of an existing On-ramp transaction (Fiat -> Crypto).
|
|
618
|
+
*
|
|
619
|
+
* @param reference - The unique reference of the transaction.
|
|
620
|
+
* @returns A promise resolving to the transaction details.
|
|
621
|
+
*/
|
|
622
|
+
async getOnRampTransaction(reference) {
|
|
623
|
+
return this.client.get(`/merchants/on_ramp_transaction/${reference}`, { isRamp: true });
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Initiates a new Custodial On-ramp transaction (Fiat -> Crypto).
|
|
627
|
+
*
|
|
628
|
+
* @param data - The transaction initiation payload.
|
|
629
|
+
* @returns A promise resolving to the created transaction.
|
|
630
|
+
*/
|
|
631
|
+
async initiateOnRamp(data) {
|
|
632
|
+
return this.client.post("/merchants/custodial/on_ramp_transactions/initiate", data, { isRamp: true });
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Confirms a previously initiated Custodial On-ramp transaction.
|
|
636
|
+
*
|
|
637
|
+
* @param reference - The reference of the transaction.
|
|
638
|
+
* @param data - Optional confirmation payload.
|
|
639
|
+
* @returns A promise resolving to the confirmed transaction.
|
|
640
|
+
*/
|
|
641
|
+
async confirmOnRamp(reference, data) {
|
|
642
|
+
return this.client.post(`/merchants/custodial/on_ramp_transactions/${reference}/confirm`, data, { isRamp: true });
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Initiates a new Custodial Off-ramp transaction (Crypto -> Fiat).
|
|
646
|
+
*
|
|
647
|
+
* @param data - The transaction initiation payload.
|
|
648
|
+
* @returns A promise resolving to the created transaction.
|
|
649
|
+
*/
|
|
650
|
+
async initiateOffRamp(data) {
|
|
651
|
+
return this.client.post("/merchants/custodial/off_ramp_transactions/initiate", data, { isRamp: true });
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Confirms a previously initiated Custodial Off-ramp transaction.
|
|
655
|
+
*
|
|
656
|
+
* @param reference - The reference of the transaction.
|
|
657
|
+
* @param data - Optional confirmation payload.
|
|
658
|
+
* @returns A promise resolving to the confirmed transaction.
|
|
659
|
+
*/
|
|
660
|
+
async confirmOffRamp(reference, data) {
|
|
661
|
+
return this.client.post(`/merchants/custodial/off_ramp_transactions/${reference}/confirm`, data, { isRamp: true });
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Fetches supported banks for Fiat Off-ramp withdrawals.
|
|
665
|
+
*
|
|
666
|
+
* @returns A promise resolving to the list of supported banks.
|
|
667
|
+
*/
|
|
668
|
+
async getBanks() {
|
|
669
|
+
return this.client.get("/merchants/custodial/banks", { isRamp: true });
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Adds a bank account to a specific Off-ramp transaction.
|
|
673
|
+
*
|
|
674
|
+
* @param reference - The reference of the Off-ramp transaction.
|
|
675
|
+
* @param data - The bank account details.
|
|
676
|
+
* @returns A promise resolving to the updated transaction.
|
|
677
|
+
*/
|
|
678
|
+
async addBankAccount(reference, data) {
|
|
679
|
+
return this.client.post(`/merchants/custodial/off_ramp_transactions/${reference}/bank_account`, data, { isRamp: true });
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/index.ts
|
|
684
|
+
/**
|
|
685
|
+
* The main Quidax SDK Client.
|
|
686
|
+
*
|
|
687
|
+
* Provides access to all Quidax v3.0 modules, seamlessly routing between the Exchange API and the Ramp API.
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```typescript
|
|
691
|
+
* import Quidax from 'quidax-node';
|
|
692
|
+
*
|
|
693
|
+
* const quidax = new Quidax({ secretKey: 's_your_secret_key' });
|
|
694
|
+
* const me = await quidax.users.getParentAccount();
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
697
|
+
var Quidax = class {
|
|
698
|
+
/**
|
|
699
|
+
* Manage parent and sub-accounts.
|
|
700
|
+
*/
|
|
701
|
+
users;
|
|
702
|
+
/**
|
|
703
|
+
* Fetch wallets and manage cryptocurrency payment addresses.
|
|
704
|
+
*/
|
|
705
|
+
wallets;
|
|
706
|
+
/**
|
|
707
|
+
* Process and track crypto withdrawals.
|
|
708
|
+
*/
|
|
709
|
+
withdrawals;
|
|
710
|
+
/**
|
|
711
|
+
* Access real-time market data, order books, and tickers.
|
|
712
|
+
*/
|
|
713
|
+
markets;
|
|
714
|
+
/**
|
|
715
|
+
* View recent trades on the exchange.
|
|
716
|
+
*/
|
|
717
|
+
trades;
|
|
718
|
+
/**
|
|
719
|
+
* Track crypto deposits into user wallets.
|
|
720
|
+
*/
|
|
721
|
+
deposits;
|
|
722
|
+
/**
|
|
723
|
+
* Process instant crypto-to-crypto swaps.
|
|
724
|
+
*/
|
|
725
|
+
swap;
|
|
726
|
+
/**
|
|
727
|
+
* Place, manage, and cancel limit and market orders.
|
|
728
|
+
*/
|
|
729
|
+
orders;
|
|
730
|
+
/**
|
|
731
|
+
* Check current network fees for withdrawals.
|
|
732
|
+
*/
|
|
733
|
+
fees;
|
|
734
|
+
/**
|
|
735
|
+
* Access Fiat On-ramp and Off-ramp Custodial services.
|
|
736
|
+
*/
|
|
737
|
+
ramp;
|
|
738
|
+
client;
|
|
739
|
+
constructor(config) {
|
|
740
|
+
this.client = new BaseClient(config);
|
|
741
|
+
this.users = new UsersModule(this.client);
|
|
742
|
+
this.wallets = new WalletsModule(this.client);
|
|
743
|
+
this.withdrawals = new WithdrawalsModule(this.client);
|
|
744
|
+
this.markets = new MarketsModule(this.client);
|
|
745
|
+
this.trades = new TradesModule(this.client);
|
|
746
|
+
this.deposits = new DepositsModule(this.client);
|
|
747
|
+
this.swap = new SwapModule(this.client);
|
|
748
|
+
this.orders = new OrdersModule(this.client);
|
|
749
|
+
this.fees = new FeesModule(this.client);
|
|
750
|
+
this.ramp = new RampModule(this.client);
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
//#endregion
|
|
754
|
+
exports.BaseClient = BaseClient;
|
|
755
|
+
exports.DepositsModule = DepositsModule;
|
|
756
|
+
exports.FeesModule = FeesModule;
|
|
757
|
+
exports.MarketsModule = MarketsModule;
|
|
758
|
+
exports.OrdersModule = OrdersModule;
|
|
759
|
+
exports.Quidax = Quidax;
|
|
760
|
+
exports.default = Quidax;
|
|
761
|
+
exports.QuidaxError = QuidaxError;
|
|
762
|
+
exports.RampModule = RampModule;
|
|
763
|
+
exports.SwapModule = SwapModule;
|
|
764
|
+
exports.TradesModule = TradesModule;
|
|
765
|
+
exports.UsersModule = UsersModule;
|
|
766
|
+
exports.WalletsModule = WalletsModule;
|
|
767
|
+
exports.WithdrawalsModule = WithdrawalsModule;
|