ccxt 4.4.85 → 4.4.86

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 (60) hide show
  1. package/README.md +6 -7
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +6 -9
  4. package/dist/cjs/src/abstract/bittrade.js +9 -0
  5. package/dist/cjs/src/ascendex.js +189 -155
  6. package/dist/cjs/src/bequant.js +1 -1
  7. package/dist/cjs/src/bitget.js +5 -4
  8. package/dist/cjs/src/bitmart.js +1 -1
  9. package/dist/cjs/src/bittrade.js +2049 -0
  10. package/dist/cjs/src/coinbase.js +2 -6
  11. package/dist/cjs/src/deribit.js +4 -5
  12. package/dist/cjs/src/hollaex.js +107 -49
  13. package/dist/cjs/src/htx.js +20 -44
  14. package/dist/cjs/src/hyperliquid.js +4 -4
  15. package/dist/cjs/src/mexc.js +2 -2
  16. package/dist/cjs/src/ndax.js +25 -24
  17. package/dist/cjs/src/okcoin.js +12 -31
  18. package/dist/cjs/src/okx.js +9 -0
  19. package/dist/cjs/src/onetrading.js +9 -6
  20. package/dist/cjs/src/oxfun.js +42 -114
  21. package/dist/cjs/src/paradex.js +5 -1
  22. package/dist/cjs/src/pro/binance.js +1 -0
  23. package/dist/cjs/src/pro/bittrade.js +605 -0
  24. package/dist/cjs/src/pro/luno.js +6 -5
  25. package/dist/cjs/src/pro/mexc.js +3 -0
  26. package/js/ccxt.d.ts +8 -11
  27. package/js/ccxt.js +6 -8
  28. package/js/src/abstract/myokx.d.ts +2 -0
  29. package/js/src/abstract/okx.d.ts +2 -0
  30. package/js/src/ascendex.d.ts +2 -0
  31. package/js/src/ascendex.js +189 -155
  32. package/js/src/bequant.js +1 -1
  33. package/js/src/bitget.js +5 -4
  34. package/js/src/bitmart.js +1 -1
  35. package/js/src/{huobijp.d.ts → bittrade.d.ts} +29 -29
  36. package/js/src/{huobijp.js → bittrade.js} +35 -35
  37. package/js/src/coinbase.js +2 -6
  38. package/js/src/deribit.js +4 -5
  39. package/js/src/hollaex.js +107 -49
  40. package/js/src/htx.js +20 -44
  41. package/js/src/hyperliquid.js +4 -4
  42. package/js/src/mexc.js +2 -2
  43. package/js/src/ndax.js +25 -24
  44. package/js/src/okcoin.js +12 -31
  45. package/js/src/okx.js +9 -0
  46. package/js/src/onetrading.js +9 -6
  47. package/js/src/oxfun.js +42 -114
  48. package/js/src/paradex.js +5 -1
  49. package/js/src/pro/binance.js +1 -0
  50. package/js/src/pro/{huobijp.d.ts → bittrade.d.ts} +6 -6
  51. package/js/src/pro/{huobijp.js → bittrade.js} +7 -7
  52. package/js/src/pro/luno.js +6 -5
  53. package/js/src/pro/mexc.js +3 -0
  54. package/package.json +1 -1
  55. package/js/src/abstract/kuna.d.ts +0 -185
  56. package/js/src/abstract/kuna.js +0 -11
  57. package/js/src/kuna.d.ts +0 -335
  58. package/js/src/kuna.js +0 -2006
  59. /package/js/src/abstract/{huobijp.d.ts → bittrade.d.ts} +0 -0
  60. /package/js/src/abstract/{huobijp.js → bittrade.js} +0 -0
package/js/src/kuna.js DELETED
@@ -1,2006 +0,0 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
- // ---------------------------------------------------------------------------
8
- import Exchange from './abstract/kuna.js';
9
- import { ArgumentsRequired, InsufficientFunds, OrderNotFound, NotSupported, BadRequest, ExchangeError, InvalidOrder } from './base/errors.js';
10
- import { TICK_SIZE } from './base/functions/number.js';
11
- import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
- import { sha384 } from './static_dependencies/noble-hashes/sha512.js';
13
- import { Precise } from './base/Precise.js';
14
- // ---------------------------------------------------------------------------
15
- /**
16
- * @class kuna
17
- * @augments Exchange
18
- * @description Use the public-key as your apiKey
19
- */
20
- export default class kuna extends Exchange {
21
- describe() {
22
- return this.deepExtend(super.describe(), {
23
- 'id': 'kuna',
24
- 'name': 'Kuna',
25
- 'countries': ['UA'],
26
- 'rateLimit': 1000,
27
- 'version': 'v4',
28
- 'has': {
29
- 'CORS': undefined,
30
- 'spot': true,
31
- 'margin': false,
32
- 'swap': false,
33
- 'future': false,
34
- 'option': false,
35
- 'addMargin': false,
36
- 'cancelOrder': true,
37
- 'cancelOrders': true,
38
- 'closeAllPositions': false,
39
- 'closePosition': false,
40
- 'createDepositAddress': true,
41
- 'createOrder': true,
42
- 'createPostOnlyOrder': false,
43
- 'createReduceOnlyOrder': false,
44
- 'createStopLimitOrder': true,
45
- 'createStopMarketOrder': false,
46
- 'createStopOrder': true,
47
- 'fetchBalance': true,
48
- 'fetchBorrowInterest': false,
49
- 'fetchBorrowRateHistories': false,
50
- 'fetchBorrowRateHistory': false,
51
- 'fetchClosedOrders': true,
52
- 'fetchCrossBorrowRate': false,
53
- 'fetchCrossBorrowRates': false,
54
- 'fetchCurrencies': true,
55
- 'fetchDeposit': true,
56
- 'fetchDepositAddress': true,
57
- 'fetchDepositAddresses': false,
58
- 'fetchDepositAddressesByNetwork': false,
59
- 'fetchDeposits': true,
60
- 'fetchDepositsWithdrawals': false,
61
- 'fetchFundingHistory': false,
62
- 'fetchFundingRate': false,
63
- 'fetchFundingRateHistory': false,
64
- 'fetchFundingRates': false,
65
- 'fetchIndexOHLCV': false,
66
- 'fetchIsolatedBorrowRate': false,
67
- 'fetchIsolatedBorrowRates': false,
68
- 'fetchIsolatedPositions': false,
69
- 'fetchL3OrderBook': true,
70
- 'fetchLeverage': false,
71
- 'fetchLeverageTiers': false,
72
- 'fetchMarginMode': false,
73
- 'fetchMarketLeverageTiers': false,
74
- 'fetchMarkets': true,
75
- 'fetchMarkOHLCV': false,
76
- 'fetchMyTrades': true,
77
- 'fetchOHLCV': false,
78
- 'fetchOpenInterest': false,
79
- 'fetchOpenInterestHistory': false,
80
- 'fetchOpenOrders': true,
81
- 'fetchOrder': true,
82
- 'fetchOrderBook': true,
83
- 'fetchOrdersByStatus': true,
84
- 'fetchPosition': false,
85
- 'fetchPositionMode': false,
86
- 'fetchPositions': false,
87
- 'fetchPositionsForSymbol': false,
88
- 'fetchPositionsRisk': false,
89
- 'fetchPremiumIndexOHLCV': false,
90
- 'fetchTicker': true,
91
- 'fetchTickers': true,
92
- 'fetchTime': true,
93
- 'fetchTrades': true,
94
- 'fetchTradingFee': false,
95
- 'fetchTradingFees': false,
96
- 'fetchTransactions': false,
97
- 'fetchTransfers': false,
98
- 'fetchWithdrawAddresses': false,
99
- 'fetchWithdrawal': true,
100
- 'fetchWithdrawals': true,
101
- 'reduceMargin': false,
102
- 'repayCrossMargin': false,
103
- 'repayIsolatedMargin': false,
104
- 'setLeverage': false,
105
- 'setMargin': false,
106
- 'setMarginMode': false,
107
- 'setPositionMode': false,
108
- 'signIn': false,
109
- 'transfer': false,
110
- 'withdraw': true,
111
- },
112
- 'timeframes': undefined,
113
- 'urls': {
114
- 'extension': '.json',
115
- 'referral': 'https://kuna.io?r=kunaid-gvfihe8az7o4',
116
- 'logo': 'https://user-images.githubusercontent.com/51840849/87153927-f0578b80-c2c0-11ea-84b6-74612568e9e1.jpg',
117
- 'api': {
118
- 'xreserve': 'https://api.xreserve.fund',
119
- 'v3': 'https://api.kuna.io',
120
- 'v4': 'https://api.kuna.io',
121
- 'public': 'https://kuna.io',
122
- 'private': 'https://kuna.io', // v2
123
- },
124
- 'www': 'https://kuna.io',
125
- 'doc': 'https://kuna.io/documents/api',
126
- 'fees': 'https://kuna.io/documents/api',
127
- },
128
- 'api': {
129
- 'xreserve': {
130
- 'get': {
131
- 'nonce': 1,
132
- 'fee': 1,
133
- 'delegated-transactions': 1,
134
- },
135
- 'post': {
136
- 'delegate-transfer': 1,
137
- },
138
- },
139
- 'v4': {
140
- 'private': {
141
- 'get': {
142
- 'private/me': 1,
143
- 'private/getBalance': 1,
144
- 'order/private/active': 1,
145
- 'order/private/history': 1,
146
- 'order/private/{id}/trades': 1,
147
- 'order/private/details/{id}': 1,
148
- 'trade/private/history': 1,
149
- 'transaction/private/{hash}': 1,
150
- 'deposit/private/preRequest': 1,
151
- 'deposit/private/crypto/address': 1,
152
- 'deposit/private/crypto/getMerchantAddress': 1,
153
- 'deposit/private/history': 1,
154
- 'deposit/private/details/{depositId}': 1,
155
- 'withdraw/private/preRequest': 1,
156
- 'withdraw/private/history': 1,
157
- 'withdraw/private/details/{withdrawId}': 1,
158
- 'kuna-code/{id}': 1,
159
- 'kuna-code/{code}/check': 1,
160
- 'kuna-code/issued-by-me': 1,
161
- 'kuna-code/redeemed-by-me': 1,
162
- },
163
- 'post': {
164
- 'order/private/create': 1,
165
- 'order/private/cancel': 1,
166
- 'order/private/cancel/multi': 1,
167
- 'deposit/private/crypto/generateAddress': 1,
168
- 'deposit/private/crypto/generateMerchantAddress': 1,
169
- 'withdraw/private/create': 1,
170
- 'kuna-code': 1,
171
- },
172
- 'put': {
173
- 'kuna-code/redeem': 1,
174
- },
175
- },
176
- 'public': {
177
- 'get': {
178
- 'public/timestamp': 1,
179
- 'public/fees': 1,
180
- 'public/currencies?type={type}': 1,
181
- 'public/currencies': 1,
182
- 'markets/public/getAll': 1,
183
- 'markets/public/tickers?pairs={pairs}': 1,
184
- 'order/public/book/{pairs}': 1,
185
- 'trade/public/book/{pairs}': 1,
186
- },
187
- },
188
- },
189
- 'v3': {
190
- 'public': {
191
- 'get': {
192
- 'timestamp': 1,
193
- 'currencies': 1,
194
- 'markets': 1,
195
- 'tickers': 1,
196
- 'k': 1,
197
- 'trades_history': 1,
198
- 'fees': 1,
199
- 'exchange-rates': 1,
200
- 'exchange-rates/currency': 1,
201
- 'book/market': 1,
202
- 'kuna_codes/code/check': 1,
203
- 'landing_page_statistic': 1,
204
- 'translations/locale': 1,
205
- 'trades/market/hist': 1,
206
- },
207
- 'post': {
208
- 'http_test': 1,
209
- 'deposit_channels': 1,
210
- 'withdraw_channels': 1,
211
- 'subscription_plans': 1,
212
- 'send_to': 1,
213
- 'confirm_token': 1,
214
- 'kunaid': 1,
215
- 'withdraw/prerequest': 1,
216
- 'deposit/prerequest': 1,
217
- 'deposit/exchange-rates': 1,
218
- },
219
- },
220
- 'sign': {
221
- 'get': {
222
- 'reset_password/token': 1,
223
- },
224
- 'post': {
225
- 'signup/google': 1,
226
- 'signup/resend_confirmation': 1,
227
- 'signup': 1,
228
- 'signin': 1,
229
- 'signin/two_factor': 1,
230
- 'signin/resend_confirm_device': 1,
231
- 'signin/confirm_device': 1,
232
- 'reset_password': 1,
233
- 'cool-signin': 1,
234
- },
235
- 'put': {
236
- 'reset_password/token': 1,
237
- 'signup/code/confirm': 1,
238
- },
239
- },
240
- 'private': {
241
- 'post': {
242
- 'auth/w/order/submit': 1,
243
- 'auth/r/orders': 1,
244
- 'auth/r/orders/market': 1,
245
- 'auth/r/orders/markets': 1,
246
- 'auth/api_tokens/delete': 1,
247
- 'auth/api_tokens/create': 1,
248
- 'auth/api_tokens': 1,
249
- 'auth/signin_history/uniq': 1,
250
- 'auth/signin_history': 1,
251
- 'auth/disable_withdraw_confirmation': 1,
252
- 'auth/change_password': 1,
253
- 'auth/deposit_address': 1,
254
- 'auth/announcements/accept': 1,
255
- 'auth/announcements/unaccepted': 1,
256
- 'auth/otp/deactivate': 1,
257
- 'auth/otp/activate': 1,
258
- 'auth/otp/secret': 1,
259
- 'auth/r/order/market/:order_id/trades': 1,
260
- 'auth/r/orders/market/hist': 1,
261
- 'auth/r/orders/hist': 1,
262
- 'auth/r/orders/hist/markets': 1,
263
- 'auth/r/orders/details': 1,
264
- 'auth/assets-history': 1,
265
- 'auth/assets-history/withdraws': 1,
266
- 'auth/assets-history/deposits': 1,
267
- 'auth/r/wallets': 1,
268
- 'auth/markets/favorites': 1,
269
- 'auth/markets/favorites/list': 1,
270
- 'auth/me/update': 1,
271
- 'auth/me': 1,
272
- 'auth/fund_sources': 1,
273
- 'auth/fund_sources/list': 1,
274
- 'auth/withdraw/resend_confirmation': 1,
275
- 'auth/withdraw': 1,
276
- 'auth/withdraw/details': 1,
277
- 'auth/withdraw/info': 1,
278
- 'auth/payment_addresses': 1,
279
- 'auth/deposit/prerequest': 1,
280
- 'auth/deposit/exchange-rates': 1,
281
- 'auth/deposit': 1,
282
- 'auth/deposit/details': 1,
283
- 'auth/deposit/info': 1,
284
- 'auth/kuna_codes/count': 1,
285
- 'auth/kuna_codes/details': 1,
286
- 'auth/kuna_codes/edit': 1,
287
- 'auth/kuna_codes/send-pdf': 1,
288
- 'auth/kuna_codes': 1,
289
- 'auth/kuna_codes/redeemed-by-me': 1,
290
- 'auth/kuna_codes/issued-by-me': 1,
291
- 'auth/payment_requests/invoice': 1,
292
- 'auth/payment_requests/type': 1,
293
- 'auth/referral_program/weekly_earnings': 1,
294
- 'auth/referral_program/stats': 1,
295
- 'auth/merchant/payout_services': 1,
296
- 'auth/merchant/withdraw': 1,
297
- 'auth/merchant/payment_services': 1,
298
- 'auth/merchant/deposit': 1,
299
- 'auth/verification/auth_token': 1,
300
- 'auth/kunaid_purchase/create': 1,
301
- 'auth/devices/list': 1,
302
- 'auth/sessions/list': 1,
303
- 'auth/subscriptions/reactivate': 1,
304
- 'auth/subscriptions/cancel': 1,
305
- 'auth/subscriptions/prolong': 1,
306
- 'auth/subscriptions/create': 1,
307
- 'auth/subscriptions/list': 1,
308
- 'auth/kuna_ids/list': 1,
309
- 'order/cancel/multi': 1,
310
- 'order/cancel': 1,
311
- },
312
- 'put': {
313
- 'auth/fund_sources/id': 1,
314
- 'auth/kuna_codes/redeem': 1,
315
- },
316
- 'delete': {
317
- 'auth/markets/favorites': 1,
318
- 'auth/fund_sources': 1,
319
- 'auth/devices': 1,
320
- 'auth/devices/list': 1,
321
- 'auth/sessions/list': 1,
322
- 'auth/sessions': 1,
323
- },
324
- },
325
- },
326
- 'public': {
327
- 'get': [
328
- 'depth',
329
- 'k_with_pending_trades',
330
- 'k',
331
- 'markets',
332
- 'order_book',
333
- 'order_book/{market}',
334
- 'tickers',
335
- 'tickers/{market}',
336
- 'timestamp',
337
- 'trades',
338
- 'trades/{market}',
339
- ],
340
- },
341
- 'private': {
342
- 'get': [
343
- 'members/me',
344
- 'deposits',
345
- 'deposit',
346
- 'deposit_address',
347
- 'orders',
348
- 'order',
349
- 'trades/my',
350
- 'withdraws',
351
- 'withdraw', // Get your cryptocurrency withdraw
352
- ],
353
- 'post': [
354
- 'orders',
355
- 'orders/multi',
356
- 'orders/clear',
357
- 'order/delete',
358
- 'withdraw', // Create a withdraw
359
- ],
360
- },
361
- },
362
- 'features': {
363
- 'spot': {
364
- 'sandbox': false,
365
- 'createOrder': {
366
- 'marginMode': false,
367
- 'triggerPrice': true,
368
- 'triggerPriceType': undefined,
369
- 'triggerDirection': false,
370
- 'stopLossPrice': false,
371
- 'takeProfitPrice': false,
372
- 'attachedStopLossTakeProfit': undefined,
373
- 'timeInForce': {
374
- 'IOC': false,
375
- 'FOK': false,
376
- 'PO': false,
377
- 'GTD': false,
378
- },
379
- 'hedged': false,
380
- 'selfTradePrevention': false,
381
- 'trailing': false,
382
- 'leverage': false,
383
- 'marketBuyByCost': true,
384
- 'marketBuyRequiresPrice': false,
385
- 'iceberg': false,
386
- },
387
- 'createOrders': undefined,
388
- 'fetchMyTrades': undefined,
389
- 'fetchOrder': {
390
- 'marginMode': false,
391
- 'trigger': false,
392
- 'trailing': false,
393
- 'symbolRequired': false,
394
- },
395
- 'fetchOpenOrders': {
396
- 'marginMode': false,
397
- 'limit': 100,
398
- 'trigger': false,
399
- 'trailing': false,
400
- 'symbolRequired': false,
401
- },
402
- 'fetchOrders': undefined,
403
- 'fetchClosedOrders': {
404
- 'marginMode': false,
405
- 'limit': 100,
406
- 'daysBack': 100000,
407
- 'daysBackCanceled': 1,
408
- 'untilDays': 14,
409
- 'trigger': false,
410
- 'trailing': false,
411
- 'symbolRequired': false,
412
- },
413
- 'fetchOHLCV': undefined,
414
- },
415
- 'swap': {
416
- 'linear': undefined,
417
- 'inverse': undefined,
418
- },
419
- 'future': {
420
- 'linear': undefined,
421
- 'inverse': undefined,
422
- },
423
- },
424
- 'fees': {
425
- 'trading': {
426
- 'tierBased': false,
427
- 'percentage': true,
428
- 'taker': this.parseNumber('0.0025'),
429
- 'maker': this.parseNumber('0.0025'),
430
- },
431
- 'funding': {
432
- 'withdraw': {
433
- 'UAH': '1%',
434
- 'BTC': 0.001,
435
- 'BCH': 0.001,
436
- 'ETH': 0.01,
437
- 'WAVES': 0.01,
438
- 'GOL': 0.0,
439
- 'GBG': 0.0,
440
- // 'RMC': 0.001 BTC
441
- // 'ARN': 0.01 ETH
442
- // 'R': 0.01 ETH
443
- // 'EVR': 0.01 ETH
444
- },
445
- 'deposit': {
446
- // 'UAH': (amount) => amount * 0.001 + 5
447
- },
448
- },
449
- },
450
- 'commonCurrencies': {
451
- 'PLA': 'Plair',
452
- },
453
- 'precisionMode': TICK_SIZE,
454
- 'exceptions': {
455
- 'ARGUMENT_VALIDATION_ERROR': BadRequest,
456
- 'PAYMENT_METHOD_NOT_SUPPORTED': BadRequest,
457
- 'NOT_FOUND': OrderNotFound,
458
- 'INVALID:ORDER_SIZE': InvalidOrder,
459
- 'WrongRequestException': BadRequest,
460
- 'INSUFFICIENT_FUNDS': InsufficientFunds,
461
- '2002': InsufficientFunds,
462
- '2003': OrderNotFound,
463
- },
464
- 'options': {
465
- // 'account': 'pro' // Only for pro accounts
466
- },
467
- });
468
- }
469
- /**
470
- * @method
471
- * @name kuna#fetchTime
472
- * @description fetches the current integer timestamp in milliseconds from the exchange server
473
- * @see https://docs.kuna.io/docs/get-time-on-the-server
474
- * @param {object} [params] extra parameters specific to the exchange API endpoint
475
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
476
- */
477
- async fetchTime(params = {}) {
478
- const response = await this.v4PublicGetPublicTimestamp(params);
479
- //
480
- // {
481
- // "data": {
482
- // "timestamp": 1686740531,
483
- // "timestamp_miliseconds": 1686740531725,
484
- // }
485
- // }
486
- //
487
- const data = this.safeValue(response, 'data', {});
488
- return this.safeInteger(data, 'timestamp_miliseconds');
489
- }
490
- /**
491
- * @method
492
- * @name kuna#fetchCurrencies
493
- * @description fetches all available currencies on an exchange
494
- * @see https://docs.kuna.io/docs/get-information-about-available-currencies
495
- * @param {object} [params] extra parameters specific to the exchange API endpoint
496
- * @returns {object} an associative dictionary of currencies
497
- */
498
- async fetchCurrencies(params = {}) {
499
- const response = await this.v4PublicGetPublicCurrencies(params);
500
- //
501
- // {
502
- // "data": [
503
- // {
504
- // "code": "BTC",
505
- // "name": "Bitcoin",
506
- // "payload": {
507
- // "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
508
- // "icons": {
509
- // "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
510
- // "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
511
- // "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
512
- // "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
513
- // },
514
- // "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
515
- // },
516
- // "position": 1,
517
- // "precision": 8,
518
- // "tradePrecision": 6,
519
- // "type": "Crypto"
520
- // }
521
- // ]
522
- // }
523
- //
524
- const data = this.safeValue(response, 'data', []);
525
- return this.parseCurrencies(data);
526
- }
527
- parseCurrency(currency) {
528
- //
529
- // {
530
- // "code": "BTC",
531
- // "name": "Bitcoin",
532
- // "payload": {
533
- // "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
534
- // "icons": {
535
- // "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
536
- // "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
537
- // "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
538
- // "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
539
- // },
540
- // "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
541
- // },
542
- // "position": 1,
543
- // "precision": 8,
544
- // "tradePrecision": 6,
545
- // "type": "Crypto"
546
- // }
547
- //
548
- const currencyId = this.safeString(currency, 'code');
549
- const precision = this.safeString(currency, 'precision');
550
- const tradePrecision = this.safeString(currency, 'tradePrecision');
551
- return this.safeCurrencyStructure({
552
- 'info': currency,
553
- 'id': currencyId,
554
- 'code': this.safeCurrencyCode(currencyId),
555
- 'type': undefined,
556
- 'margin': undefined,
557
- 'name': this.safeString(currency, 'name'),
558
- 'active': undefined,
559
- 'deposit': undefined,
560
- 'withdraw': undefined,
561
- 'fee': undefined,
562
- 'precision': this.parseNumber(Precise.stringMin(precision, tradePrecision)),
563
- 'limits': {
564
- 'amount': {
565
- 'min': undefined,
566
- 'max': undefined,
567
- },
568
- 'withdraw': {
569
- 'min': undefined,
570
- 'max': undefined,
571
- },
572
- },
573
- 'networks': {},
574
- });
575
- }
576
- /**
577
- * @method
578
- * @name kuna#fetchMarkets
579
- * @description retrieves data on all markets for kuna
580
- * @see https://docs.kuna.io/docs/get-all-traded-markets
581
- * @param {object} [params] extra parameters specific to the exchange API endpoint
582
- * @returns {object[]} an array of objects representing market data
583
- */
584
- async fetchMarkets(params = {}) {
585
- const response = await this.v4PublicGetMarketsPublicGetAll(params);
586
- //
587
- // {
588
- // "data": [
589
- // {
590
- // "pair": "BTC_USDT", // Traded pair of assets
591
- // "baseAsset": { // The base asset of the traded pair, the one to sell or buy as a result of the trade
592
- // "code": "BTC",
593
- // "precision": 6 // Maximum amount of digits for the decimal part of a number
594
- // },
595
- // "quoteAsset": { // The quoted asset of the traded pair, the one to use to sell or buy the base asset
596
- // "code": "USDT",
597
- // "precision": 2 // Maximum amount of digits for the decimal part of a number
598
- // },
599
- // "tickerPriceChange": "-0.07" // Relative change compared with the last tick
600
- // }
601
- // ]
602
- // }
603
- //
604
- const data = this.safeValue(response, 'data', []);
605
- const markets = [];
606
- for (let i = 0; i < data.length; i++) {
607
- const item = data[i];
608
- const marketId = this.safeString(item, 'pair');
609
- const baseAsset = this.safeValue(item, 'baseAsset');
610
- const quoteAsset = this.safeValue(item, 'quoteAsset');
611
- const baseId = this.safeString(baseAsset, 'code');
612
- const quoteId = this.safeString(quoteAsset, 'code');
613
- const base = this.safeCurrencyCode(baseId);
614
- const quote = this.safeCurrencyCode(quoteId);
615
- const basePrecision = this.safeString(baseAsset, 'precision');
616
- const quotePrecision = this.safeString(quoteAsset, 'precision');
617
- markets.push({
618
- 'id': marketId,
619
- 'symbol': base + '/' + quote,
620
- 'base': base,
621
- 'quote': quote,
622
- 'settle': undefined,
623
- 'baseId': baseId,
624
- 'quoteId': quoteId,
625
- 'settleId': undefined,
626
- 'type': 'spot',
627
- 'spot': true,
628
- 'margin': false,
629
- 'swap': false,
630
- 'future': false,
631
- 'option': false,
632
- 'active': undefined,
633
- 'contract': false,
634
- 'linear': undefined,
635
- 'inverse': undefined,
636
- 'contractSize': undefined,
637
- 'expiry': undefined,
638
- 'expiryDatetime': undefined,
639
- 'strike': undefined,
640
- 'optionType': undefined,
641
- 'precision': {
642
- 'amount': this.parseNumber(this.parsePrecision(basePrecision)),
643
- 'price': this.parseNumber(this.parsePrecision(quotePrecision)),
644
- },
645
- 'limits': {
646
- 'leverage': {
647
- 'min': undefined,
648
- 'max': undefined,
649
- },
650
- 'amount': {
651
- 'min': undefined,
652
- 'max': undefined,
653
- },
654
- 'price': {
655
- 'min': undefined,
656
- 'max': undefined,
657
- },
658
- 'cost': {
659
- 'min': undefined,
660
- 'max': undefined,
661
- },
662
- },
663
- 'created': undefined,
664
- 'info': item,
665
- });
666
- }
667
- return markets;
668
- }
669
- /**
670
- * @method
671
- * @name kuna#fetchOrderBook
672
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
673
- * @see https://docs.kuna.io/docs/get-public-orders-book
674
- * @param {string} symbol unified symbol of the market to fetch the order book for
675
- * @param {int} [limit] 5, 10, 20, 50, 100, 500, or 1000 (default)
676
- * @param {object} [params] extra parameters specific to the exchange API endpoint
677
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
678
- */
679
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
680
- await this.loadMarkets();
681
- const market = this.market(symbol);
682
- const request = {
683
- 'pairs': market['id'],
684
- };
685
- if (limit !== undefined) {
686
- request['level'] = limit;
687
- }
688
- const response = await this.v4PublicGetOrderPublicBookPairs(this.extend(request, params));
689
- //
690
- // {
691
- // "data": {
692
- // "asks": [ // An array of sell orders
693
- // [
694
- // "16950", // Sell price, level 1
695
- // "0.001" // Sell quantity, level 1
696
- // ],
697
- // [
698
- // "17000", // Sell price, level 2
699
- // "0.01" // Sell quantity, level 2
700
- // ]
701
- // ],
702
- // "bids": [ // An array of buy orders
703
- // [
704
- // "16700", // Sell price, level 1
705
- // "0.01" // Sell quantity, level 1
706
- // ],
707
- // [
708
- // "16000", // Sell price, level 2
709
- // "0.001" // Sell quantity, level 2
710
- // ]
711
- // ]
712
- // }
713
- // }
714
- //
715
- const data = this.safeDict(response, 'data', {});
716
- return this.parseOrderBook(data, market['symbol'], undefined, 'bids', 'asks', 0, 1);
717
- }
718
- parseTicker(ticker, market = undefined) {
719
- //
720
- // {
721
- // "pair": "BTC_USDT", // Traded pair
722
- // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
723
- // "price": "27900", // Current median price
724
- // "equivalentPrice": "", // TBD
725
- // "high": "29059.69", // Highest price
726
- // "low": "27900", // Lowest price
727
- // "baseVolume": "2.9008499999999993", // Traded volume as base
728
- // "quoteVolume": "82251.41477976", // Traded volume as quote
729
- // "bestBidPrice": "27926.91", // The best bid price now
730
- // "bestAskPrice": "27970.02", // The best ask price now
731
- // "priceChange": "-973.9700000000012" // Absolute price change
732
- // }
733
- //
734
- const marketId = this.safeString(ticker, 'pair');
735
- return this.safeTicker({
736
- 'info': ticker,
737
- 'symbol': this.safeSymbol(marketId, market),
738
- 'timestamp': undefined,
739
- 'datetime': undefined,
740
- 'high': this.safeString(ticker, 'high'),
741
- 'low': this.safeString(ticker, 'low'),
742
- 'bid': this.safeString(ticker, 'bestBidPrice'),
743
- 'ask': this.safeString(ticker, 'bestAskPrice'),
744
- 'vwap': undefined,
745
- 'open': this.safeString(ticker, 'open'),
746
- 'close': undefined,
747
- 'last': undefined,
748
- 'previousClose': undefined,
749
- 'change': this.safeString(ticker, 'priceChange'),
750
- 'percentage': this.safeString(ticker, 'percentagePriceChange'),
751
- 'average': undefined,
752
- 'baseVolume': this.safeString(ticker, 'baseVolume'),
753
- 'quoteVolume': this.safeString(ticker, 'quoteVolume'),
754
- }, market);
755
- }
756
- /**
757
- * @method
758
- * @name kuna#fetchTickers
759
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market. The average is not returned in the response, but the median can be accessed via response['info']['price']
760
- * @see https://docs.kuna.io/docs/get-market-info-by-tickers
761
- * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
762
- * @param {object} [params] extra parameters specific to the exchange API endpoint
763
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
764
- */
765
- async fetchTickers(symbols = undefined, params = {}) {
766
- await this.loadMarkets();
767
- if (symbols === undefined) {
768
- throw new ArgumentsRequired(this.id + ' fetchTickers () requires a symbols argument');
769
- }
770
- symbols = this.marketSymbols(symbols);
771
- const marketIds = this.marketIds(symbols);
772
- const request = {
773
- 'pairs': marketIds.join(','),
774
- };
775
- const response = await this.v4PublicGetMarketsPublicTickersPairsPairs(this.extend(request, params));
776
- //
777
- // {
778
- // "data": [
779
- // {
780
- // "pair": "BTC_USDT", // Traded pair
781
- // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
782
- // "price": "27900", // Current median price
783
- // "equivalentPrice": "", // TBD
784
- // "high": "29059.69", // Highest price
785
- // "low": "27900", // Lowest price
786
- // "baseVolume": "2.9008499999999993", // Traded volume as base
787
- // "quoteVolume": "82251.41477976", // Traded volume as quote
788
- // "bestBidPrice": "27926.91", // The best bid price now
789
- // "bestAskPrice": "27970.02", // The best ask price now
790
- // "priceChange": "-973.9700000000012" // Absolute price change
791
- // }
792
- // ...
793
- // ]
794
- // }
795
- //
796
- const data = this.safeList(response, 'data', []);
797
- return this.parseTickers(data, symbols, params);
798
- }
799
- /**
800
- * @method
801
- * @name kuna#fetchTicker
802
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
803
- * @see https://docs.kuna.io/docs/get-market-info-by-tickers
804
- * @param {string} symbol unified symbol of the market to fetch the ticker for
805
- * @param {object} [params] extra parameters specific to the exchange API endpoint
806
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
807
- */
808
- async fetchTicker(symbol, params = {}) {
809
- await this.loadMarkets();
810
- const market = this.market(symbol);
811
- const request = {
812
- 'pairs': market['id'],
813
- };
814
- const response = await this.v4PublicGetMarketsPublicTickersPairsPairs(this.extend(request, params));
815
- //
816
- // {
817
- // "data": [
818
- // {
819
- // "pair": "BTC_USDT", // Traded pair
820
- // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
821
- // "price": "27900", // Current median price
822
- // "equivalentPrice": "", // TBD
823
- // "high": "29059.69", // Highest price
824
- // "low": "27900", // Lowest price
825
- // "baseVolume": "2.9008499999999993", // Traded volume as base
826
- // "quoteVolume": "82251.41477976", // Traded volume as quote
827
- // "bestBidPrice": "27926.91", // The best bid price now
828
- // "bestAskPrice": "27970.02", // The best ask price now
829
- // "priceChange": "-973.9700000000012" // Absolute price change
830
- // }
831
- // ...
832
- // ]
833
- // }
834
- //
835
- const data = this.safeValue(response, 'data', []);
836
- const ticker = this.safeDict(data, 0);
837
- return this.parseTicker(ticker, market);
838
- }
839
- /**
840
- * TODO: double check
841
- * @method
842
- * @name kuna#fetchL3OrderBook
843
- * @description fetches level 3 information on open orders with bid (buy) and ask (sell) prices, volumes and other data
844
- * @param {string} symbol unified market symbol
845
- * @param {int} [limit] max number of orders to return, default is undefined
846
- * @param {object} [params] extra parameters specific to the exchange API endpoint
847
- * @returns {object} an [order book structure]{@link https://docs.ccxt.com/#/?id=order-book-structure}
848
- */
849
- async fetchL3OrderBook(symbol, limit = undefined, params = {}) {
850
- return await this.fetchOrderBook(symbol, limit, params);
851
- }
852
- /**
853
- * @method
854
- * @name kuna#fetchTrades
855
- * @description get the list of most recent trades for a particular symbol
856
- * @see https://docs.kuna.io/docs/get-public-trades-book
857
- * @param {string} symbol unified symbol of the market to fetch trades for
858
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
859
- * @param {int} [limit] between 1 and 100, 25 by default
860
- * @param {object} [params] extra parameters specific to the exchange API endpoint
861
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
862
- */
863
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
864
- await this.loadMarkets();
865
- const market = this.market(symbol);
866
- const request = {
867
- 'pairs': market['id'],
868
- };
869
- if (limit !== undefined) {
870
- request['limit'] = limit;
871
- }
872
- const response = await this.v4PublicGetTradePublicBookPairs(this.extend(request, params));
873
- //
874
- // {
875
- // 'data': [
876
- // {
877
- // 'createdAt': '2024-03-02T00:10:49.385Z',
878
- // 'id': '3b42878a-3688-4bc1-891e-5cc2fc902142',
879
- // 'matchPrice': '62181.31',
880
- // 'matchQuantity': '0.00568',
881
- // 'pair': 'BTC_USDT',
882
- // 'quoteQuantity': '353.1898408',
883
- // 'side': 'Bid'
884
- // },
885
- // ...
886
- // ]
887
- // }
888
- //
889
- const data = this.safeList(response, 'data', []);
890
- return this.parseTrades(data, market, since, limit);
891
- }
892
- parseTrade(trade, market = undefined) {
893
- //
894
- // fetchTrades (public)
895
- //
896
- // {
897
- // "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
898
- // "pair": "BTC_USDT", // Market pair that is being traded
899
- // "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
900
- // "matchPrice": "18649", // Exchange price at the moment of execution
901
- // "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
902
- // "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
903
- // "side": "Ask" // Trade type: `Ask` or `Bid`. Bid for buying base asset, Ask for selling base asset (e.g. for BTC_USDT trading pair, BTC is the base asset).
904
- // }
905
- //
906
- // fetchMyTrades, fetchOrder (private)
907
- //
908
- // {
909
- // "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
910
- // "orderId": "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
911
- // "pair": "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
912
- // "quantity": "1.5862", // Traded quantity of base asset
913
- // "price": "19087", // Price of the trade
914
- // "isTaker": true, // Various fees for Makers and Takers; "Market" orders are always `true`
915
- // "fee": "0.0039655", // Exchange commission fee
916
- // "feeCurrency": "BTC", // Currency of the commission
917
- // "isBuyer": true, // Buy or sell the base asset
918
- // "quoteQuantity": "30275.7994", // Quote asset quantity spent to fulfill the base amount
919
- // "createdAt": "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
920
- // }
921
- //
922
- const datetime = this.safeString(trade, 'createdAt');
923
- const marketId = this.safeString(trade, 'pair');
924
- const isTaker = this.safeValue(trade, 'isMaker');
925
- let side = this.safeStringLower(trade, 'side');
926
- if (side === undefined) {
927
- const isBuyer = this.safeValue(trade, 'isBuyer');
928
- side = isBuyer ? 'buy' : 'sell';
929
- }
930
- return this.safeTrade({
931
- 'info': trade,
932
- 'id': this.safeString(trade, 'id'),
933
- 'symbol': this.safeSymbol(marketId, market),
934
- 'timestamp': this.parse8601(datetime),
935
- 'datetime': datetime,
936
- 'type': undefined,
937
- 'side': side,
938
- 'order': this.safeString(trade, 'orderId'),
939
- 'takerOrMaker': isTaker ? 'taker' : 'maker',
940
- 'price': this.safeString2(trade, 'matchPrice', 'price'),
941
- 'amount': this.safeString2(trade, 'matchQuantity', 'quantity'),
942
- 'cost': this.safeString(trade, 'quoteQuantity'),
943
- 'fee': {
944
- 'cost': this.safeString(trade, 'fee'),
945
- 'currency': this.safeCurrencyCode(this.safeString(trade, 'feeCurrency')),
946
- },
947
- }, market);
948
- }
949
- parseBalance(response) {
950
- //
951
- // [
952
- // {
953
- // "currency": "UAH",
954
- // "balance": "7134.6",
955
- // "lockBalance": "100"
956
- // }
957
- // ...
958
- // ]
959
- //
960
- const result = { 'info': response };
961
- for (let i = 0; i < response.length; i++) {
962
- const balance = response[i];
963
- const currencyId = this.safeString(balance, 'currency');
964
- const code = this.safeCurrencyCode(currencyId);
965
- const account = this.account();
966
- account['free'] = this.safeString(balance, 'balance');
967
- account['used'] = this.safeString(balance, 'lockBalance');
968
- result[code] = account;
969
- }
970
- return this.safeBalance(result);
971
- }
972
- /**
973
- * @method
974
- * @name kuna#fetchBalance
975
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
976
- * @param {object} [params] extra parameters specific to the exchange API endpoint
977
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
978
- */
979
- async fetchBalance(params = {}) {
980
- await this.loadMarkets();
981
- const response = await this.v4PrivateGetPrivateGetBalance(params);
982
- //
983
- // {
984
- // "data": [{
985
- // "currency": "UAH", // Wallet currency
986
- // "balance": "7134.6", // Available balance, precision depends on the currency
987
- // "lockBalance": "100" // Minimum amount locked on the balance
988
- // }]
989
- // }
990
- //
991
- const data = this.safeValue(response, 'data', []);
992
- return this.parseBalance(data);
993
- }
994
- /**
995
- * @method
996
- * @name kuna#createOrder
997
- * @description create a trade order
998
- * @see https://docs.kuna.io/docs/create-a-new-order-private
999
- * @param {string} symbol unified symbol of the market to create an order in
1000
- * @param {string} type 'market' or 'limit'
1001
- * @param {string} side 'buy' or 'sell'
1002
- * @param {float} amount how much of currency you want to trade in units of base currency
1003
- * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1004
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1005
- * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
1006
- *
1007
- * EXCHANGE SPECIFIC PARAMETERS
1008
- * @param {string} [params.id] id must be a UUID format, if you do not specify id, it will be generated automatically.
1009
- * @param {float} [params.quoteQuantity] the max quantity of the quote asset to use for selling/buying
1010
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1011
- */
1012
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1013
- await this.loadMarkets();
1014
- const market = this.market(symbol);
1015
- const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
1016
- params = this.omit(params, ['triggerPrice', 'stopPrice']);
1017
- const capitalizedType = this.capitalize(type);
1018
- const request = {
1019
- 'pair': market['id'],
1020
- 'orderSide': (side === 'buy') ? 'Bid' : 'Ask',
1021
- 'quantity': this.numberToString(amount),
1022
- 'type': capitalizedType,
1023
- };
1024
- if (capitalizedType === 'Limit') {
1025
- request['price'] = this.priceToPrecision(market['symbol'], price);
1026
- }
1027
- if (triggerPrice !== undefined) {
1028
- if (capitalizedType === 'Market') {
1029
- throw new BadRequest(this.id + ' createOrder () cannot place trigger market orders, or trigger limit');
1030
- }
1031
- request['stopPrice'] = this.priceToPrecision(market['symbol'], triggerPrice);
1032
- if (capitalizedType !== 'TakeProfitLimit') {
1033
- request['type'] = 'StopLossLimit';
1034
- }
1035
- }
1036
- const response = await this.v4PrivatePostOrderPrivateCreate(this.extend(request, params));
1037
- //
1038
- // {
1039
- // "data": {
1040
- // "id": "b0fcb54c-2278-4f16-a300-02765faad8b0", // ID of your newly created order
1041
- // "type": "Limit", // Type of an order
1042
- // "quantity": "0.06", // Original order quantity
1043
- // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
1044
- // "pair": "BTC_USDT", // Traded pair
1045
- // "price": "26440.46", // Price of the trade
1046
- // "status": "Open", // The status of the order
1047
- // "createdAt": "2023-07-11T08:01:30.550Z", // Date-time of order creation, UTC
1048
- // "updatedAt": "2023-07-11T08:01:30.550Z" // Date-time of the last update of the order, UTC
1049
- // }
1050
- // }
1051
- //
1052
- const data = this.safeDict(response, 'data', {});
1053
- return this.parseOrder(data, market);
1054
- }
1055
- /**
1056
- * @method
1057
- * @name kuna#cancelOrder
1058
- * @description cancels an open order
1059
- * @param {string} id order id
1060
- * @param {string} symbol unified market symbol
1061
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1062
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1063
- */
1064
- async cancelOrder(id, symbol = undefined, params = {}) {
1065
- await this.loadMarkets();
1066
- const request = {
1067
- 'orderId': id,
1068
- };
1069
- const response = await this.v4PrivatePostOrderPrivateCancel(this.extend(request, params));
1070
- //
1071
- // {
1072
- // "data": {
1073
- // "success": true
1074
- // }
1075
- // }
1076
- //
1077
- const data = this.safeValue(response, 'data', {});
1078
- let market = undefined;
1079
- if (symbol !== undefined) {
1080
- market = this.market(symbol);
1081
- }
1082
- const order = this.parseOrder(data, market);
1083
- order['id'] = id;
1084
- return order;
1085
- }
1086
- /**
1087
- * @method
1088
- * @name kuna#cancelOrders
1089
- * @description cancels an open order
1090
- * @param {string} ids order ids
1091
- * @param {string} symbol not used by kuna cancelOrder
1092
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1093
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1094
- */
1095
- async cancelOrders(ids, symbol = undefined, params = {}) {
1096
- await this.loadMarkets();
1097
- const request = {
1098
- 'orderIds': ids,
1099
- };
1100
- const response = await this.v4PrivatePostOrderPrivateCancelMulti(this.extend(request, params));
1101
- //
1102
- // {
1103
- // "data": [
1104
- // {
1105
- // "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order
1106
- // "success": true // Status for this order
1107
- // },
1108
- // ...
1109
- // ]
1110
- // }
1111
- //
1112
- const data = this.safeList(response, 'data', []);
1113
- return this.parseOrders(data);
1114
- }
1115
- parseOrderStatus(status) {
1116
- const statuses = {
1117
- 'Canceled': 'canceled',
1118
- 'Closed': 'filled',
1119
- 'Pending': 'open',
1120
- 'Open': 'open',
1121
- 'done': 'closed',
1122
- 'wait': 'open',
1123
- 'cancel': 'canceled',
1124
- };
1125
- return this.safeString(statuses, status, status);
1126
- }
1127
- parseOrder(order, market = undefined) {
1128
- //
1129
- // createOrder, fetchOrder, fetchOpenOrders, fetchOrdersByStatus
1130
- //
1131
- // {
1132
- // "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
1133
- // "type": "Limit", // Type of an order
1134
- // "quantity": "5", // Original order quantity
1135
- // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
1136
- // "cumulativeQuoteQty": "0", // *absent on createOrder* Traded quantity in money (>0 if traded)
1137
- // "cost": "0.05", // Total amount
1138
- // "side": "Bid", // *absent on createOrder* Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
1139
- // "pair": "TRX_USDT", // Traded pair
1140
- // "price": "0.01", // Price of the trade
1141
- // "status": "Open", // The status of the order
1142
- // "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
1143
- // "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
1144
- // "closedAt": "2023-05-08T08:53:58.333Z" // *absent on fetchOpenOrders/createOrder* Date-time of order finish time, UTC
1145
- // "trades": [ // * fetchOrder only *
1146
- // {
1147
- // "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
1148
- // "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
1149
- // "pair": "BTC_USDT", // Traded pair
1150
- // "quantity": "0.00054", // Traded quantity
1151
- // "price": "27770", // Traded price
1152
- // "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
1153
- // "fee": "0.000001350", // Exchange commission fee
1154
- // "feeCurrency": "BTC", // Currency of the commission
1155
- // "isBuyer": true, // Buy or sell the base asset
1156
- // "quoteQuantity": "14.9958", // Quote asset quantity
1157
- // "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
1158
- // }
1159
- // ]
1160
- // }
1161
- //
1162
- // cancelOrder, cancelOrders
1163
- //
1164
- // {
1165
- // "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order *absent on cancelOrder*
1166
- // "success": true // Status for this order
1167
- // }
1168
- //
1169
- const marketId = this.safeString(order, 'pair');
1170
- const datetime = this.safeString(order, 'createdAt');
1171
- let side = this.safeString(order, 'side');
1172
- if (side === 'Bid') {
1173
- side = 'buy';
1174
- }
1175
- else if (side === 'Ask') {
1176
- side = 'sell';
1177
- }
1178
- const trades = this.safeValue(order, 'trades', []);
1179
- return this.safeOrder({
1180
- 'info': order,
1181
- 'id': this.safeString2(order, 'id', 'orderId'),
1182
- 'clientOrderId': undefined,
1183
- 'symbol': this.safeSymbol(marketId, market),
1184
- 'timestamp': this.parse8601(datetime),
1185
- 'datetime': datetime,
1186
- 'lastTradeTimestamp': this.parse8601(this.safeString(order, 'updatedAt')),
1187
- 'status': this.parseOrderStatus(this.safeString(order, 'status')),
1188
- 'type': this.safeStringLower(order, 'type'),
1189
- 'timeInForce': undefined,
1190
- 'postOnly': undefined,
1191
- 'side': side,
1192
- 'price': this.safeString(order, 'price'),
1193
- 'triggerPrice': this.safeString(order, 'stopPrice'),
1194
- 'amount': this.safeString(order, 'quantity'),
1195
- 'filled': this.safeString(order, 'executedQuantity'),
1196
- 'remaining': undefined,
1197
- 'trades': this.parseTrades(trades),
1198
- 'cost': this.safeString(order, 'cost'),
1199
- 'average': undefined,
1200
- 'fee': undefined,
1201
- }, market);
1202
- }
1203
- /**
1204
- * @method
1205
- * @name kuna#fetchOrder
1206
- * @description fetches information on an order made by the user
1207
- * @see https://docs.kuna.io/docs/get-order-details-by-id
1208
- * @param {string} id order id
1209
- * @param {string} symbol not used by kuna fetchOrder
1210
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1211
- *
1212
- * EXCHANGE SPECIFIC PARAMETERS
1213
- * @param {boolean} [params.withTrades] default == true, specify if the response should include trades associated with the order
1214
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1215
- */
1216
- async fetchOrder(id, symbol = undefined, params = {}) {
1217
- await this.loadMarkets();
1218
- const request = {
1219
- 'id': id,
1220
- 'withTrades': true,
1221
- };
1222
- const response = await this.v4PrivateGetOrderPrivateDetailsId(this.extend(request, params));
1223
- //
1224
- // {
1225
- // "data": {
1226
- // "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3",
1227
- // "type": "Limit",
1228
- // "quantity": "0.00054",
1229
- // "executedQuantity": "0.00054",
1230
- // "cumulativeQuoteQty": "14.99580",
1231
- // "cost": "14.9958",
1232
- // "side": "Bid",
1233
- // "pair": "BTC_USDT",
1234
- // "price": "27770",
1235
- // "status": "Closed",
1236
- // "createdAt": "2023-05-08T08:39:46.708Z",
1237
- // "updatedAt": "2023-05-08T08:53:58.332Z",
1238
- // "closedAt": "2023-05-08T08:53:58.333Z",
1239
- // "trades": [
1240
- // {
1241
- // "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
1242
- // "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
1243
- // "pair": "BTC_USDT", // Traded pair
1244
- // "quantity": "0.00054", // Traded quantity
1245
- // "price": "27770", // Traded price
1246
- // "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
1247
- // "fee": "0.000001350", // Exchange commission fee
1248
- // "feeCurrency": "BTC", // Currency of the commission
1249
- // "isBuyer": true, // Buy or sell the base asset
1250
- // "quoteQuantity": "14.9958", // Quote asset quantity
1251
- // "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
1252
- // }
1253
- // ]
1254
- // }
1255
- // }
1256
- //
1257
- const data = this.safeDict(response, 'data', {});
1258
- return this.parseOrder(data);
1259
- }
1260
- /**
1261
- * @method
1262
- * @name kuna#fetchOpenOrders
1263
- * @description fetch all unfilled currently open orders
1264
- * @see https://docs.kuna.io/docs/get-active-client-orders-private
1265
- * @param {string} symbol unified market symbol
1266
- * @param {int} [since] the earliest time in ms to fetch open orders for
1267
- * @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
1268
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1269
- * @param {int} [params.until] the latest timestamp (ms) to fetch orders for
1270
- *
1271
- * EXCHANGE SPECIFIC PARAMETERS
1272
- * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1273
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1274
- */
1275
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1276
- await this.loadMarkets();
1277
- const until = this.safeInteger(params, 'until');
1278
- params = this.omit(params, ['until']);
1279
- let market = undefined;
1280
- const request = {};
1281
- if (symbol !== undefined) {
1282
- market = this.market(symbol);
1283
- request['pairs'] = market['id'];
1284
- }
1285
- if (since !== undefined) {
1286
- request['start'] = this.iso8601(since);
1287
- }
1288
- if (limit !== undefined) {
1289
- request['limit'] = limit;
1290
- }
1291
- if (until !== undefined) {
1292
- request['end'] = this.iso8601(until);
1293
- }
1294
- const response = await this.v4PrivateGetOrderPrivateActive(this.extend(request, params));
1295
- //
1296
- // {
1297
- // "data": [
1298
- // {
1299
- // "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
1300
- // "type": "Limit", // Type of an order
1301
- // "quantity": "5", // Original order quantity
1302
- // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
1303
- // "cumulativeQuoteQty": "0", // Traded quantity in money (>0 if traded)
1304
- // "cost": "0.05", // Total amount
1305
- // "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
1306
- // "pair": "TRX_USDT", // Traded pair
1307
- // "price": "0.01", // Price of the trade
1308
- // "status": "Open", // The status of the order
1309
- // "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
1310
- // "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
1311
- // }
1312
- // ...
1313
- // ]
1314
- // }
1315
- //
1316
- const data = this.safeList(response, 'data', []);
1317
- return this.parseOrders(data, market, since, limit);
1318
- }
1319
- /**
1320
- * @method
1321
- * @name kuna#fetchClosedOrders
1322
- * @description fetches information on multiple closed orders made by the user
1323
- * @see https://docs.kuna.io/docs/get-private-orders-history
1324
- * @param {string} symbol unified market symbol of the market orders were made in
1325
- * @param {int} [since] the earliest time in ms to fetch orders for
1326
- * @param {int} [limit] the maximum number of order structures to retrieve
1327
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1328
- * @param {int} [params.until] the latest time in ms to fetch orders for
1329
- *
1330
- * EXCHANGE SPECIFIC PARAMETERS
1331
- * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1332
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1333
- */
1334
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1335
- return await this.fetchOrdersByStatus('closed', symbol, since, limit, params);
1336
- }
1337
- /**
1338
- * @method
1339
- * @name kuna#fetchOrdersByStatus
1340
- * @description fetch a list of orders
1341
- * @see https://docs.kuna.io/docs/get-private-orders-history
1342
- * @param {string} status canceled, closed, expired, open, pending, rejected, or waitStop
1343
- * @param {string} symbol unified market symbol of the market orders were made in
1344
- * @param {int} [since] the earliest time in ms to fetch orders for
1345
- * @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
1346
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1347
- * @param {int} [params.until] the latest timestamp (ms) to fetch orders for
1348
- *
1349
- * EXCHANGE SPECIFIC PARAMETERS
1350
- * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1351
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1352
- */
1353
- async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1354
- await this.loadMarkets();
1355
- if (status === 'open') {
1356
- return this.fetchOpenOrders(symbol, since, limit, params);
1357
- }
1358
- const until = this.safeInteger(params, 'until');
1359
- params = this.omit(params, ['until']);
1360
- let market = undefined;
1361
- const request = {
1362
- 'status': this.capitalize(status),
1363
- };
1364
- if (symbol !== undefined) {
1365
- market = this.market(symbol);
1366
- request['pairs'] = market['id'];
1367
- }
1368
- if (since !== undefined) {
1369
- request['start'] = this.iso8601(since);
1370
- }
1371
- if (limit !== undefined) {
1372
- request['limit'] = limit;
1373
- }
1374
- if (until !== undefined) {
1375
- request['end'] = this.iso8601(until);
1376
- }
1377
- const response = await this.v4PrivateGetOrderPrivateHistory(request);
1378
- //
1379
- // {
1380
- // "data": [
1381
- // {
1382
- // "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an order
1383
- // "type": "Limit", // Type of an order
1384
- // "quantity": "0.00054", // Original order quantity
1385
- // "executedQuantity": "0.00054", // Traded quantity in stock (>0 if traded)
1386
- // "cumulativeQuoteQty": "14.99580", // Traded quantity in money (>0 if traded)
1387
- // "cost": "14.9958", // Total amount
1388
- // "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
1389
- // "pair": "BTC_USDT", // Traded pair
1390
- // "price": "27770", // Price of the trade
1391
- // "status": "Closed", // The status of the order
1392
- // "createdAt": "2023-05-08T08:39:46.708Z", // Date-time of order creation, UTC
1393
- // "updatedAt": "2023-05-08T08:53:58.332Z", // Date-time of the last update of the order, UTC
1394
- // "closedAt": "2023-05-08T08:53:58.333Z" // Date-time of order finish time, UTC
1395
- // },
1396
- // ...
1397
- // ]
1398
- // }
1399
- //
1400
- const data = this.safeList(response, 'data', []);
1401
- return this.parseOrders(data, market, since, limit);
1402
- }
1403
- /**
1404
- * @method
1405
- * @name kuna#fetchMyTrades
1406
- * @description fetch all trades made by the user
1407
- * @see https://docs.kuna.io/docs/get-private-trades-history
1408
- * @param {string} symbol unified market symbol
1409
- * @param {int} [since] not used by kuna fetchMyTrades
1410
- * @param {int} [limit] not used by kuna fetchMyTrades
1411
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1412
- *
1413
- * EXCHANGE SPECIFIC PARAMETERS
1414
- * @param {string} [params.orderId] UUID of an order, to receive trades for this order only
1415
- * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1416
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1417
- */
1418
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1419
- await this.loadMarkets();
1420
- let market = undefined;
1421
- const request = {};
1422
- if (symbol !== undefined) {
1423
- market = this.market(symbol);
1424
- request['pair'] = market['id'];
1425
- }
1426
- const response = await this.v4PrivateGetTradePrivateHistory(this.extend(request, params));
1427
- //
1428
- // {
1429
- // "data": [
1430
- // {
1431
- // "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
1432
- // "orderId": "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
1433
- // "pair": "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
1434
- // "quantity": "1.5862", // Traded quantity of base asset
1435
- // "price": "19087", // Price of the trade
1436
- // "isTaker": true, // Various fees for Makers and Takers; "Market" orders are always `true`
1437
- // "fee": "0.0039655", // Exchange commission fee
1438
- // "feeCurrency": "BTC", // Currency of the commission
1439
- // "isBuyer": true, // Buy or sell the base asset
1440
- // "quoteQuantity": "30275.7994", // Quote asset quantity spent to fulfill the base amount
1441
- // "createdAt": "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
1442
- // },
1443
- // ]
1444
- // }
1445
- //
1446
- const data = this.safeList(response, 'data');
1447
- return this.parseTrades(data, market, since, limit);
1448
- }
1449
- /**
1450
- * @method
1451
- * @name kuna#withdraw
1452
- * @description make a withdrawal
1453
- * @see https://docs.kuna.io/docs/create-a-withdraw
1454
- * @param {string} code unified currency code
1455
- * @param {float} amount the amount to withdraw
1456
- * @param {string} address the address to withdraw to
1457
- * @param {string} tag
1458
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1459
- * @param {string} [params.chain] the chain to withdraw to
1460
- *
1461
- * EXCHANGE SPECIFIC PARAMETERS
1462
- * @param {string} [params.id] id must be a uuid format, if you do not specify id, it will be generated automatically
1463
- * @param {boolean} [params.withdrawAll] this field says that the amount should also include a fee
1464
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1465
- */
1466
- async withdraw(code, amount, address, tag = undefined, params = {}) {
1467
- this.checkAddress(address);
1468
- let chain = this.safeString2(params, 'chain', 'network');
1469
- params = this.omit(params, ['chain', 'network']);
1470
- await this.loadMarkets();
1471
- const currency = this.currency(code);
1472
- if (chain === undefined) {
1473
- if (currency['code'].indexOf('USD') > 0) {
1474
- throw new ArgumentsRequired(this.id + ' withdraw () requires an extra parameter params["network"] to withdraw ' + currency['code']);
1475
- }
1476
- else {
1477
- chain = currency['id'].toUpperCase();
1478
- }
1479
- }
1480
- const networkId = this.networkCodeToId(chain);
1481
- const request = {
1482
- 'currency': networkId,
1483
- 'amount': amount,
1484
- 'address': address,
1485
- 'paymentMethod': chain, // TODO: double check, Withdraw method for currency, should be taken from "Get info about withdrawal methods by currency name" endpoint (key field).
1486
- };
1487
- if (tag !== undefined) {
1488
- request['paymentId'] = tag;
1489
- }
1490
- const response = await this.v4PrivatePostWithdrawPrivateCreate(this.extend(request, params));
1491
- //
1492
- // {
1493
- // "data": {
1494
- // "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // unique identifier of a withdraw
1495
- // "status": "waitingForConfirmation" // status of a withdraw, if you turn off withdrawal confirmation by email, it will return "processing" status, which means that the transaction is already being processed on our side
1496
- // }
1497
- // }
1498
- //
1499
- const data = this.safeDict(response, 'data', {});
1500
- return this.parseTransaction(data, currency);
1501
- }
1502
- /**
1503
- * @method
1504
- * @name kuna#fetchWithdrawals
1505
- * @description fetch all withdrawals made to an account
1506
- * @see https://docs.kuna.io/docs/get-withdraw-history
1507
- * @param {string} code unified currency code
1508
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
1509
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
1510
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1511
- * @param {int} [params.until] the latest time in ms to fetch deposits for
1512
- *
1513
- * EXCHANGE SPECIFIC PARAMETERS
1514
- * @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
1515
- * @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
1516
- * @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
1517
- * @param {int} [params.skip] 0 - ... Select the number of transactions to skip
1518
- * @param {string} [params.address]
1519
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1520
- */
1521
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1522
- await this.loadMarkets();
1523
- const until = this.safeInteger(params, 'until');
1524
- params = this.omit(params, 'until');
1525
- let currency = undefined;
1526
- if (code !== undefined) {
1527
- currency = this.currency(code);
1528
- }
1529
- const request = {};
1530
- if (code !== undefined) {
1531
- request['currency'] = code;
1532
- }
1533
- if (since !== undefined) {
1534
- request['dateFrom'] = this.iso8601(since);
1535
- }
1536
- if (limit !== undefined) {
1537
- request['take'] = limit;
1538
- }
1539
- if (until !== undefined) {
1540
- request['dateTo'] = this.iso8601(until);
1541
- }
1542
- const response = await this.v4PrivateGetWithdrawPrivateHistory(this.extend(request, params));
1543
- //
1544
- // {
1545
- // "data": [
1546
- // {
1547
- // "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
1548
- // "amount": "10.75", // Amount deducted from your account
1549
- // "asset": "USDT", // Withdrawal currency
1550
- // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1551
- // "paymentCode": "TRX", // Blockchain name
1552
- // "status": "Processed", // Withdrawal status
1553
- // "type": "Withdraw", // Transaction type
1554
- // "reason": [], // Reason for manual transaction processing
1555
- // "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
1556
- // "memo": "", // Withdrawal memo
1557
- // "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
1558
- // "fee": "0.75", // Withdrawal fee
1559
- // "processedAmount": "10", // Withdrawal amount
1560
- // "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
1561
- // "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
1562
- // },
1563
- // ...
1564
- // ]
1565
- // }
1566
- //
1567
- const data = this.safeList(response, 'data', []);
1568
- return this.parseTransactions(data, currency);
1569
- }
1570
- /**
1571
- * @method
1572
- * @name kuna#fetchWithdrawal
1573
- * @description fetch data on a currency withdrawal via the withdrawal id
1574
- * @see https://docs.kuna.io/docs/get-withdraw-details-by-id
1575
- * @param {string} id withdrawal id
1576
- * @param {string} code not used by kuna.fetchWithdrawal
1577
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1578
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1579
- */
1580
- async fetchWithdrawal(id, code = undefined, params = {}) {
1581
- await this.loadMarkets();
1582
- const request = {
1583
- 'withdrawId': id,
1584
- };
1585
- const response = await this.v4PrivateGetWithdrawPrivateDetailsWithdrawId(this.extend(request, params));
1586
- //
1587
- // {
1588
- // "data": {
1589
- // "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
1590
- // "amount": "10.75", // Amount deducted from your account
1591
- // "asset": "USDT", // Withdrawal currency
1592
- // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1593
- // "paymentCode": "TRX", // Blockchain name
1594
- // "status": "Processed", // Withdrawal status
1595
- // "type": "Withdraw", // Transaction type
1596
- // "reason": [], // Reason for manual transaction processing
1597
- // "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
1598
- // "memo": "", // Withdrawal memo
1599
- // "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
1600
- // "fee": "0.75", // Withdrawal fee
1601
- // "processedAmount": "10", // Withdrawal amount
1602
- // "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
1603
- // "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
1604
- // }
1605
- // }
1606
- //
1607
- const data = this.safeDict(response, 'data', {});
1608
- return this.parseTransaction(data);
1609
- }
1610
- /**
1611
- * @method
1612
- * @name kuna#createDepositAddress
1613
- * @description create a currency deposit address
1614
- * @see https://docs.kuna.io/docs/generate-a-constant-crypto-address-for-deposit
1615
- * @param {string} code unified currency code of the currency for the deposit address
1616
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1617
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1618
- */
1619
- async createDepositAddress(code, params = {}) {
1620
- await this.loadMarkets();
1621
- const currency = this.currency(code);
1622
- const request = {
1623
- 'source': currency['id'],
1624
- };
1625
- const response = await this.v4PrivatePostDepositPrivateCryptoGenerateAddress(this.extend(request, params));
1626
- //
1627
- // {
1628
- // "data": {
1629
- // "id": "1300c2b6-ree4-4f1e-2a9d-e0f7ed0991a7", // ID of your address
1630
- // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account
1631
- // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
1632
- // }
1633
- // }
1634
- //
1635
- const data = this.safeDict(response, 'data', {});
1636
- return this.parseDepositAddress(data, currency);
1637
- }
1638
- /**
1639
- * @method
1640
- * @name kuna#fetchDepositAddress
1641
- * @description fetch the deposit address for a currency associated with this account
1642
- * @see https://docs.kuna.io/docs/find-crypto-address-for-deposit
1643
- * @param {string} code unified currency code
1644
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1645
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1646
- */
1647
- async fetchDepositAddress(code, params = {}) {
1648
- await this.loadMarkets();
1649
- const currency = this.currency(code);
1650
- const request = {
1651
- 'source': currency['id'].toUpperCase(),
1652
- };
1653
- const response = await this.v4PrivateGetDepositPrivateCryptoAddress(this.extend(request, params));
1654
- //
1655
- // {
1656
- // "data": {
1657
- // "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
1658
- // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
1659
- // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
1660
- // }
1661
- // }
1662
- //
1663
- const data = this.safeDict(response, 'data', {});
1664
- return this.parseDepositAddress(data, currency);
1665
- }
1666
- parseDepositAddress(depositAddress, currency = undefined) {
1667
- //
1668
- // {
1669
- // "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
1670
- // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
1671
- // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
1672
- // }
1673
- //
1674
- const currencyId = this.safeString(depositAddress, 'source');
1675
- return {
1676
- 'info': this.safeString(depositAddress, ''),
1677
- 'currency': this.safeCurrencyCode(currencyId, currency),
1678
- 'network': undefined,
1679
- 'address': this.safeString(depositAddress, 'address'),
1680
- 'tag': undefined,
1681
- };
1682
- }
1683
- parseTransactionStatus(status) {
1684
- const statuses = {
1685
- 'Created': 'pending',
1686
- 'Canceled': 'canceled',
1687
- 'PartiallyProcessed': 'pending',
1688
- 'Processing': 'pending',
1689
- 'Processed': 'ok',
1690
- 'WaitForConfirmation': 'pending',
1691
- 'Pending': 'pending',
1692
- 'AmlChecking': 'pending',
1693
- };
1694
- return this.safeString(statuses, status, status);
1695
- }
1696
- /**
1697
- * @method
1698
- * @name kuna#fetchDeposits
1699
- * @description fetch all deposits made to an account
1700
- * @see https://docs.kuna.io/docs/get-deposit-history
1701
- * @param {string} code unified currency code
1702
- * @param {int} [since] the earliest time in ms to fetch deposits for
1703
- * @param {int} [limit] the maximum number of deposits structures to retrieve
1704
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1705
- * @param {int} [params.until] the latest time in ms to fetch deposits for
1706
- *
1707
- * EXCHANGE SPECIFIC PARAMETERS
1708
- * @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
1709
- * @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
1710
- * @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
1711
- * @param {int} [params.skip] 0 - ... Select the number of transactions to skip
1712
- * @param {string} [params.address]
1713
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1714
- */
1715
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1716
- await this.loadMarkets();
1717
- const until = this.safeInteger(params, 'until');
1718
- params = this.omit(params, 'until');
1719
- let currency = undefined;
1720
- if (code !== undefined) {
1721
- currency = this.currency(code);
1722
- }
1723
- const request = {};
1724
- if (code !== undefined) {
1725
- request['currency'] = code;
1726
- }
1727
- if (since !== undefined) {
1728
- request['dateFrom'] = this.iso8601(since);
1729
- }
1730
- if (limit !== undefined) {
1731
- request['take'] = limit;
1732
- }
1733
- if (until !== undefined) {
1734
- request['dateTo'] = this.iso8601(until);
1735
- }
1736
- const response = await this.v4PrivateGetDepositPrivateHistory(this.extend(request, params));
1737
- //
1738
- // {
1739
- // "data": [
1740
- // {
1741
- // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
1742
- // "amount": "9.9", // Amount credited to your account
1743
- // "asset": "USDT", // Deposit currency
1744
- // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1745
- // "paymentCode": "TRX", // Blockchain name
1746
- // "status": "Processed", // Transactions status
1747
- // "type": "Deposit", // Transaction type
1748
- // "reason": [], // Reason for manual transaction processing
1749
- // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
1750
- // "memo": "", // Deposit memo
1751
- // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
1752
- // "fee": "0.1", // Deposit fee
1753
- // "processedAmount": "10", // Amount of deposit
1754
- // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
1755
- // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
1756
- // },
1757
- // ...
1758
- // ]
1759
- // }
1760
- //
1761
- const data = this.safeList(response, 'data', []);
1762
- return this.parseTransactions(data, currency);
1763
- }
1764
- /**
1765
- * @method
1766
- * @name kuna#fetchDeposit
1767
- * @description fetch data on a currency deposit via the deposit id
1768
- * @see https://docs.kuna.io/docs/get-deposit-details-by-id
1769
- * @param {string} id deposit id
1770
- * @param {string} code filter by currency code
1771
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1772
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1773
- */
1774
- async fetchDeposit(id, code = undefined, params = {}) {
1775
- await this.loadMarkets();
1776
- let currency = undefined;
1777
- if (code !== undefined) {
1778
- currency = this.currency(code);
1779
- }
1780
- const request = {
1781
- 'depositId': id,
1782
- };
1783
- const response = await this.v4PrivateGetDepositPrivateDetailsDepositId(this.extend(request, params));
1784
- //
1785
- // {
1786
- // "data": {
1787
- // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
1788
- // "amount": "9.9", // Amount credited to your account
1789
- // "asset": "USDT", // Deposit currency
1790
- // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1791
- // "paymentCode": "TRX", // Blockchain name
1792
- // "status": "Processed", // Transactions status
1793
- // "type": "Deposit", // Transaction type
1794
- // "reason": [], // Reason for manual transaction processing
1795
- // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
1796
- // "memo": "", // Deposit memo
1797
- // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
1798
- // "fee": "0.1", // Deposit fee
1799
- // "processedAmount": "10", // Amount of deposit
1800
- // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
1801
- // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
1802
- // }
1803
- // }
1804
- //
1805
- const data = this.safeDict(response, 'data', {});
1806
- return this.parseTransaction(data, currency);
1807
- }
1808
- parseTransaction(transaction, currency = undefined) {
1809
- //
1810
- // {
1811
- // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
1812
- // "amount": "9.9", // Amount credited to your account
1813
- // "asset": "USDT", // Deposit currency
1814
- // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1815
- // "paymentCode": "TRX", // Blockchain name
1816
- // "status": "Processed", // Transactions status
1817
- // "type": "Deposit", // Transaction type
1818
- // "reason": [], // Reason for manual transaction processing
1819
- // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
1820
- // "memo": "", // Deposit memo
1821
- // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
1822
- // "fee": "0.1", // Deposit fee
1823
- // "processedAmount": "10", // Amount of deposit
1824
- // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
1825
- // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
1826
- // }
1827
- //
1828
- const datetime = this.safeString(transaction, 'createdAt');
1829
- const currencyId = this.safeString(transaction, 'asset');
1830
- const code = this.safeCurrencyCode(currencyId, currency);
1831
- const networkId = this.safeString(transaction, 'paymentCode');
1832
- const type = this.safeStringLower(transaction, 'type');
1833
- const address = this.safeString(transaction, 'address');
1834
- const isDeposit = (type === 'deposit');
1835
- const parsedType = isDeposit ? type : 'withdrawal';
1836
- return {
1837
- 'info': transaction,
1838
- 'id': this.safeString(transaction, 'id'),
1839
- 'txid': this.safeString(transaction, 'txId'),
1840
- 'currency': code,
1841
- 'timestamp': this.parse8601(datetime),
1842
- 'datetime': datetime,
1843
- 'network': this.networkIdToCode(networkId),
1844
- 'addressFrom': undefined,
1845
- 'address': address,
1846
- 'addressTo': address,
1847
- 'amount': this.safeNumber(transaction, 'amount'),
1848
- 'type': parsedType,
1849
- 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
1850
- 'updated': this.parse8601(this.safeString(transaction, 'updatedAt')),
1851
- 'tagFrom': undefined,
1852
- 'tag': undefined,
1853
- 'tagTo': undefined,
1854
- 'comment': this.safeString(transaction, 'memo'),
1855
- 'internal': undefined,
1856
- 'fee': {
1857
- 'cost': this.safeNumber(transaction, 'fee'),
1858
- 'currency': code,
1859
- },
1860
- };
1861
- }
1862
- nonce() {
1863
- return this.milliseconds();
1864
- }
1865
- encodeParams(params) {
1866
- if ('orders' in params) {
1867
- const orders = params['orders'];
1868
- let query = this.urlencode(this.keysort(this.omit(params, 'orders')));
1869
- for (let i = 0; i < orders.length; i++) {
1870
- const order = orders[i];
1871
- const keys = Object.keys(order);
1872
- for (let k = 0; k < keys.length; k++) {
1873
- const key = keys[k];
1874
- const value = order[key];
1875
- query += '&orders%5B%5D%5B' + key + '%5D=' + value.toString();
1876
- }
1877
- }
1878
- return query;
1879
- }
1880
- return this.urlencode(this.keysort(params));
1881
- }
1882
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1883
- let url = undefined;
1884
- if (Array.isArray(api)) {
1885
- const isGet = method === 'GET';
1886
- const version = this.safeString(api, 0);
1887
- const access = this.safeString(api, 1);
1888
- if (version === 'v3') {
1889
- url = this.urls['api'][version] + '/' + version + '/' + this.implodeParams(path, params);
1890
- if (access === 'public') {
1891
- if (isGet) {
1892
- if (Object.keys(params).length) {
1893
- url += '?' + this.urlencode(params);
1894
- }
1895
- }
1896
- else if ((method === 'POST') || (method === 'PUT')) {
1897
- headers = { 'Content-Type': 'application/json' };
1898
- body = this.json(params);
1899
- }
1900
- }
1901
- else if (access === 'private') {
1902
- throw new NotSupported(this.id + ' private v3 API is not supported yet');
1903
- }
1904
- }
1905
- else if (version === 'v4') {
1906
- const extractedParams = this.extractParams(path);
1907
- let urlPath = '/' + version + '/' + this.implodeParams(path, params);
1908
- params = this.omit(params, extractedParams);
1909
- if (isGet) {
1910
- const paramsList = Object.keys(params);
1911
- const numParams = paramsList.length;
1912
- if (numParams > 0) {
1913
- urlPath += '?' + this.urlencode(params);
1914
- }
1915
- }
1916
- if (access === 'private') {
1917
- const nonce = this.nonce().toString();
1918
- let auth = urlPath + nonce;
1919
- if (isGet) {
1920
- auth = auth + this.json({});
1921
- }
1922
- else {
1923
- auth = auth + this.json(params);
1924
- body = params;
1925
- }
1926
- headers = {
1927
- 'Content-Type': 'application/json',
1928
- 'accept': 'application/json',
1929
- 'nonce': nonce,
1930
- 'public-key': this.apiKey,
1931
- 'signature': this.hmac(this.encode(auth), this.encode(this.secret), sha384, 'hex'),
1932
- };
1933
- const account = this.safeString(this.options, 'account');
1934
- if (account === 'pro') {
1935
- headers['account'] = 'pro';
1936
- }
1937
- }
1938
- url = this.urls['api'][version] + urlPath;
1939
- }
1940
- }
1941
- else {
1942
- let request = '/api/' + this.version + '/' + this.implodeParams(path, params);
1943
- if ('extension' in this.urls) {
1944
- request += this.urls['extension'];
1945
- }
1946
- const query = this.omit(params, this.extractParams(path));
1947
- url = this.urls['api'][api] + request;
1948
- if (api === 'public') {
1949
- if (Object.keys(query).length) {
1950
- url += '?' + this.urlencode(query);
1951
- }
1952
- }
1953
- else {
1954
- this.checkRequiredCredentials();
1955
- const nonce = this.nonce().toString();
1956
- const queryInner = this.encodeParams(this.extend({
1957
- 'access_key': this.apiKey,
1958
- 'tonce': nonce,
1959
- }, params));
1960
- const auth = method + '|' + request + '|' + queryInner;
1961
- const signed = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
1962
- const suffix = query + '&signature=' + signed;
1963
- if (method === 'GET') {
1964
- url += '?' + suffix;
1965
- }
1966
- else {
1967
- body = suffix;
1968
- headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
1969
- }
1970
- }
1971
- }
1972
- if (body !== undefined) {
1973
- body = JSON.stringify(body);
1974
- }
1975
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1976
- }
1977
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1978
- //
1979
- // {
1980
- // "errors": [
1981
- // {
1982
- // "extensions": {
1983
- // "code": "IP_NOT_IN_WHITE_LIST"
1984
- // },
1985
- // "code": "IP_NOT_IN_WHITE_LIST"
1986
- // }
1987
- // ]
1988
- // }
1989
- //
1990
- const errors = this.safeValue(response, 'errors');
1991
- if ((response === undefined) && (errors === undefined)) {
1992
- return undefined;
1993
- }
1994
- if ((errors !== undefined) || (code === 400)) {
1995
- let error = this.safeValue(errors, 0);
1996
- if (error === undefined) {
1997
- error = this.safeValue(response, 'error');
1998
- }
1999
- const errorCode = this.safeString(error, 'code');
2000
- const feedback = this.id + ' ' + this.json(response);
2001
- this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
2002
- throw new ExchangeError(feedback);
2003
- }
2004
- return undefined;
2005
- }
2006
- }