ccxt 4.4.82 → 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 (145) hide show
  1. package/README.md +6 -9
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +6 -17
  4. package/dist/cjs/src/abstract/bittrade.js +9 -0
  5. package/dist/cjs/src/apex.js +2 -1
  6. package/dist/cjs/src/ascendex.js +189 -155
  7. package/dist/cjs/src/base/Exchange.js +15 -2
  8. package/dist/cjs/src/bequant.js +1 -1
  9. package/dist/cjs/src/bitget.js +6 -7
  10. package/dist/cjs/src/bitmart.js +1 -1
  11. package/dist/cjs/src/bitrue.js +14 -35
  12. package/dist/cjs/src/bitso.js +33 -0
  13. package/dist/cjs/src/bitstamp.js +33 -0
  14. package/dist/cjs/src/bittrade.js +2049 -0
  15. package/dist/cjs/src/blofin.js +154 -13
  16. package/dist/cjs/src/btcbox.js +25 -5
  17. package/dist/cjs/src/bybit.js +16 -40
  18. package/dist/cjs/src/cex.js +2 -4
  19. package/dist/cjs/src/coinbase.js +58 -46
  20. package/dist/cjs/src/coinbaseexchange.js +142 -32
  21. package/dist/cjs/src/coincatch.js +14 -67
  22. package/dist/cjs/src/coinex.js +29 -32
  23. package/dist/cjs/src/coinlist.js +16 -15
  24. package/dist/cjs/src/coinmetro.js +22 -11
  25. package/dist/cjs/src/coinone.js +8 -10
  26. package/dist/cjs/src/coinsph.js +126 -1
  27. package/dist/cjs/src/cryptocom.js +111 -1
  28. package/dist/cjs/src/cryptomus.js +43 -89
  29. package/dist/cjs/src/delta.js +76 -36
  30. package/dist/cjs/src/deribit.js +4 -5
  31. package/dist/cjs/src/derive.js +46 -10
  32. package/dist/cjs/src/ellipx.js +175 -79
  33. package/dist/cjs/src/gate.js +1 -1
  34. package/dist/cjs/src/gemini.js +3 -5
  35. package/dist/cjs/src/hitbtc.js +56 -69
  36. package/dist/cjs/src/hollaex.js +107 -49
  37. package/dist/cjs/src/htx.js +20 -44
  38. package/dist/cjs/src/hyperliquid.js +6 -6
  39. package/dist/cjs/src/kraken.js +29 -24
  40. package/dist/cjs/src/kucoinfutures.js +6 -0
  41. package/dist/cjs/src/lbank.js +1 -1
  42. package/dist/cjs/src/mexc.js +2 -2
  43. package/dist/cjs/src/ndax.js +25 -24
  44. package/dist/cjs/src/okcoin.js +12 -31
  45. package/dist/cjs/src/okx.js +9 -0
  46. package/dist/cjs/src/onetrading.js +9 -6
  47. package/dist/cjs/src/oxfun.js +42 -114
  48. package/dist/cjs/src/paradex.js +124 -4
  49. package/dist/cjs/src/pro/binance.js +32 -33
  50. package/dist/cjs/src/pro/bithumb.js +5 -3
  51. package/dist/cjs/src/pro/bittrade.js +605 -0
  52. package/dist/cjs/src/pro/kraken.js +289 -79
  53. package/dist/cjs/src/pro/luno.js +6 -5
  54. package/dist/cjs/src/pro/mexc.js +304 -7
  55. package/dist/cjs/src/pro/poloniex.js +6 -2
  56. package/examples/js/cli.js +127 -13
  57. package/js/ccxt.d.ts +8 -20
  58. package/js/ccxt.js +6 -14
  59. package/js/src/abstract/blofin.d.ts +8 -0
  60. package/js/src/abstract/btcbox.d.ts +1 -0
  61. package/js/src/abstract/myokx.d.ts +2 -0
  62. package/js/src/abstract/okx.d.ts +2 -0
  63. package/js/src/apex.js +2 -1
  64. package/js/src/ascendex.d.ts +2 -0
  65. package/js/src/ascendex.js +189 -155
  66. package/js/src/base/Exchange.d.ts +15 -1
  67. package/js/src/base/Exchange.js +15 -2
  68. package/js/src/base/types.d.ts +3 -0
  69. package/js/src/bequant.js +1 -1
  70. package/js/src/bitget.js +6 -7
  71. package/js/src/bitmart.js +1 -1
  72. package/js/src/bitrue.js +14 -35
  73. package/js/src/bitso.js +33 -0
  74. package/js/src/bitstamp.js +33 -0
  75. package/js/src/{huobijp.d.ts → bittrade.d.ts} +29 -29
  76. package/js/src/{huobijp.js → bittrade.js} +35 -35
  77. package/js/src/blofin.d.ts +42 -2
  78. package/js/src/blofin.js +154 -13
  79. package/js/src/btcbox.js +25 -5
  80. package/js/src/bybit.js +16 -40
  81. package/js/src/cex.js +2 -4
  82. package/js/src/coinbase.js +58 -46
  83. package/js/src/coinbaseexchange.js +142 -32
  84. package/js/src/coincatch.js +14 -67
  85. package/js/src/coinex.js +28 -29
  86. package/js/src/coinlist.js +16 -15
  87. package/js/src/coinmetro.js +22 -11
  88. package/js/src/coinone.js +8 -10
  89. package/js/src/coinsph.d.ts +10 -1
  90. package/js/src/coinsph.js +126 -1
  91. package/js/src/cryptocom.d.ts +10 -1
  92. package/js/src/cryptocom.js +111 -1
  93. package/js/src/cryptomus.js +43 -89
  94. package/js/src/delta.js +76 -36
  95. package/js/src/deribit.js +4 -5
  96. package/js/src/derive.js +46 -10
  97. package/js/src/ellipx.d.ts +2 -3
  98. package/js/src/ellipx.js +175 -80
  99. package/js/src/gate.js +1 -1
  100. package/js/src/gemini.js +3 -5
  101. package/js/src/hitbtc.js +56 -69
  102. package/js/src/hollaex.js +107 -49
  103. package/js/src/htx.js +20 -44
  104. package/js/src/hyperliquid.js +6 -6
  105. package/js/src/kraken.js +29 -24
  106. package/js/src/kucoinfutures.d.ts +1 -0
  107. package/js/src/kucoinfutures.js +6 -0
  108. package/js/src/lbank.js +1 -1
  109. package/js/src/mexc.js +2 -2
  110. package/js/src/ndax.js +25 -24
  111. package/js/src/okcoin.js +12 -31
  112. package/js/src/okx.js +9 -0
  113. package/js/src/onetrading.js +9 -6
  114. package/js/src/oxfun.js +42 -114
  115. package/js/src/paradex.d.ts +12 -1
  116. package/js/src/paradex.js +124 -4
  117. package/js/src/pro/binance.d.ts +26 -26
  118. package/js/src/pro/binance.js +32 -33
  119. package/js/src/pro/bithumb.js +5 -3
  120. package/js/src/pro/{huobijp.d.ts → bittrade.d.ts} +6 -6
  121. package/js/src/pro/{huobijp.js → bittrade.js} +7 -7
  122. package/js/src/pro/kraken.d.ts +7 -6
  123. package/js/src/pro/kraken.js +290 -80
  124. package/js/src/pro/luno.js +6 -5
  125. package/js/src/pro/mexc.d.ts +58 -0
  126. package/js/src/pro/mexc.js +304 -7
  127. package/js/src/pro/poloniex.d.ts +1 -1
  128. package/js/src/pro/poloniex.js +6 -2
  129. package/package.json +1 -1
  130. package/js/src/abstract/bl3p.d.ts +0 -22
  131. package/js/src/abstract/huobijp.js +0 -11
  132. package/js/src/abstract/idex.d.ts +0 -29
  133. package/js/src/abstract/idex.js +0 -11
  134. package/js/src/abstract/kuna.d.ts +0 -185
  135. package/js/src/abstract/kuna.js +0 -11
  136. package/js/src/bl3p.d.ts +0 -116
  137. package/js/src/bl3p.js +0 -552
  138. package/js/src/idex.d.ts +0 -312
  139. package/js/src/idex.js +0 -1961
  140. package/js/src/kuna.d.ts +0 -335
  141. package/js/src/kuna.js +0 -2006
  142. package/js/src/pro/idex.d.ts +0 -81
  143. package/js/src/pro/idex.js +0 -720
  144. /package/js/src/abstract/{huobijp.d.ts → bittrade.d.ts} +0 -0
  145. /package/js/src/abstract/{bl3p.js → bittrade.js} +0 -0
@@ -380,24 +380,35 @@ export default class coinmetro extends Exchange {
380
380
  const currency = response[i];
381
381
  const id = this.safeString(currency, 'symbol');
382
382
  const code = this.safeCurrencyCode(id);
383
- const withdraw = this.safeValue(currency, 'canWithdraw');
384
- const deposit = this.safeValue(currency, 'canDeposit');
385
- const canTrade = this.safeValue(currency, 'canTrade');
386
- const active = canTrade ? withdraw : true;
387
- const minAmount = this.safeNumber(currency, 'minQty');
383
+ const typeRaw = this.safeString(currency, 'type');
384
+ let type = undefined;
385
+ if (typeRaw === 'coin' || typeRaw === 'token' || typeRaw === 'erc20') {
386
+ type = 'crypto';
387
+ }
388
+ else if (typeRaw === 'fiat') {
389
+ type = 'fiat';
390
+ }
391
+ const precisionDigits = this.safeString2(currency, 'digits', 'notabeneDecimals');
388
392
  result[code] = this.safeCurrencyStructure({
389
393
  'id': id,
390
394
  'code': code,
391
395
  'name': code,
396
+ 'type': type,
392
397
  'info': currency,
393
- 'active': active,
394
- 'deposit': deposit,
395
- 'withdraw': withdraw,
398
+ 'active': this.safeBool(currency, 'canTrade'),
399
+ 'deposit': this.safeBool(currency, 'canDeposit'),
400
+ 'withdraw': this.safeBool(currency, 'canWithdraw'),
396
401
  'fee': undefined,
397
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'digits'))),
402
+ 'precision': this.parseNumber(this.parsePrecision(precisionDigits)),
398
403
  'limits': {
399
- 'amount': { 'min': minAmount, 'max': undefined },
400
- 'withdraw': { 'min': undefined, 'max': undefined },
404
+ 'amount': {
405
+ 'min': this.safeNumber(currency, 'minQty'),
406
+ 'max': undefined,
407
+ },
408
+ 'withdraw': {
409
+ 'min': undefined,
410
+ 'max': undefined,
411
+ },
401
412
  },
402
413
  'networks': {},
403
414
  });
package/js/src/coinone.js CHANGED
@@ -299,18 +299,16 @@ export default class coinone extends Exchange {
299
299
  for (let i = 0; i < currencies.length; i++) {
300
300
  const entry = currencies[i];
301
301
  const id = this.safeString(entry, 'symbol');
302
- const name = this.safeString(entry, 'name');
303
302
  const code = this.safeCurrencyCode(id);
304
- const withdrawStatus = this.safeString(entry, 'withdraw_status', '');
305
- const depositStatus = this.safeString(entry, 'deposit_status', '');
306
- const isWithdrawEnabled = withdrawStatus === 'normal';
307
- const isDepositEnabled = depositStatus === 'normal';
308
- result[code] = {
303
+ const isWithdrawEnabled = this.safeString(entry, 'withdraw_status', '') === 'normal';
304
+ const isDepositEnabled = this.safeString(entry, 'deposit_status', '') === 'normal';
305
+ const type = (code !== 'KRW') ? 'crypto' : 'fiat';
306
+ result[code] = this.safeCurrencyStructure({
309
307
  'id': id,
310
308
  'code': code,
311
309
  'info': entry,
312
- 'name': name,
313
- 'active': isWithdrawEnabled && isDepositEnabled,
310
+ 'name': this.safeString(entry, 'name'),
311
+ 'active': undefined,
314
312
  'deposit': isDepositEnabled,
315
313
  'withdraw': isWithdrawEnabled,
316
314
  'fee': this.safeNumber(entry, 'withdrawal_fee'),
@@ -326,8 +324,8 @@ export default class coinone extends Exchange {
326
324
  },
327
325
  },
328
326
  'networks': {},
329
- 'type': 'crypto',
330
- };
327
+ 'type': type,
328
+ });
331
329
  }
332
330
  return result;
333
331
  }
@@ -1,11 +1,20 @@
1
1
  import Exchange from './abstract/coinsph.js';
2
- import type { Balances, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, int, DepositAddress } from './base/types.js';
2
+ import type { Balances, Currency, Currencies, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, int, DepositAddress } from './base/types.js';
3
3
  /**
4
4
  * @class coinsph
5
5
  * @augments Exchange
6
6
  */
7
7
  export default class coinsph extends Exchange {
8
8
  describe(): any;
9
+ /**
10
+ * @method
11
+ * @name coinsph#fetchCurrencies
12
+ * @description fetches all available currencies on an exchange
13
+ * @see https://docs.coins.ph/rest-api/#all-coins-information-user_data
14
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
15
+ * @returns {object} an associative dictionary of currencies
16
+ */
17
+ fetchCurrencies(params?: {}): Promise<Currencies>;
9
18
  calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
10
19
  /**
11
20
  * @method
package/js/src/coinsph.js CHANGED
@@ -59,7 +59,7 @@ export default class coinsph extends Exchange {
59
59
  'fetchClosedOrders': true,
60
60
  'fetchCrossBorrowRate': false,
61
61
  'fetchCrossBorrowRates': false,
62
- 'fetchCurrencies': false,
62
+ 'fetchCurrencies': true,
63
63
  'fetchDeposit': undefined,
64
64
  'fetchDepositAddress': true,
65
65
  'fetchDepositAddresses': false,
@@ -485,6 +485,131 @@ export default class coinsph extends Exchange {
485
485
  },
486
486
  });
487
487
  }
488
+ /**
489
+ * @method
490
+ * @name coinsph#fetchCurrencies
491
+ * @description fetches all available currencies on an exchange
492
+ * @see https://docs.coins.ph/rest-api/#all-coins-information-user_data
493
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
494
+ * @returns {object} an associative dictionary of currencies
495
+ */
496
+ async fetchCurrencies(params = {}) {
497
+ if (!this.checkRequiredCredentials(false)) {
498
+ return undefined;
499
+ }
500
+ const response = await this.privateGetOpenapiWalletV1ConfigGetall(params);
501
+ //
502
+ // [
503
+ // {
504
+ // "coin": "PHP",
505
+ // "name": "PHP",
506
+ // "depositAllEnable": false,
507
+ // "withdrawAllEnable": false,
508
+ // "free": "0",
509
+ // "locked": "0",
510
+ // "transferPrecision": "2",
511
+ // "transferMinQuantity": "0",
512
+ // "networkList": [],
513
+ // "legalMoney": true
514
+ // },
515
+ // {
516
+ // "coin": "USDT",
517
+ // "name": "USDT",
518
+ // "depositAllEnable": true,
519
+ // "withdrawAllEnable": true,
520
+ // "free": "0",
521
+ // "locked": "0",
522
+ // "transferPrecision": "8",
523
+ // "transferMinQuantity": "0",
524
+ // "networkList": [
525
+ // {
526
+ // "addressRegex": "^0x[0-9a-fA-F]{40}$",
527
+ // "memoRegex": " ",
528
+ // "network": "ETH",
529
+ // "name": "Ethereum (ERC20)",
530
+ // "depositEnable": true,
531
+ // "minConfirm": "12",
532
+ // "unLockConfirm": "-1",
533
+ // "withdrawDesc": "",
534
+ // "withdrawEnable": true,
535
+ // "withdrawFee": "6",
536
+ // "withdrawIntegerMultiple": "0.000001",
537
+ // "withdrawMax": "500000",
538
+ // "withdrawMin": "10",
539
+ // "sameAddress": false
540
+ // },
541
+ // {
542
+ // "addressRegex": "^T[0-9a-zA-Z]{33}$",
543
+ // "memoRegex": "",
544
+ // "network": "TRX",
545
+ // "name": "TRON",
546
+ // "depositEnable": true,
547
+ // "minConfirm": "19",
548
+ // "unLockConfirm": "-1",
549
+ // "withdrawDesc": "",
550
+ // "withdrawEnable": true,
551
+ // "withdrawFee": "3",
552
+ // "withdrawIntegerMultiple": "0.000001",
553
+ // "withdrawMax": "1000000",
554
+ // "withdrawMin": "20",
555
+ // "sameAddress": false
556
+ // }
557
+ // ],
558
+ // "legalMoney": false
559
+ // }
560
+ // ]
561
+ //
562
+ const result = {};
563
+ for (let i = 0; i < response.length; i++) {
564
+ const entry = response[i];
565
+ const id = this.safeString(entry, 'coin');
566
+ const code = this.safeCurrencyCode(id);
567
+ const isFiat = this.safeBool(entry, 'isLegalMoney');
568
+ const networkList = this.safeList(entry, 'networkList', []);
569
+ const networks = {};
570
+ for (let j = 0; j < networkList.length; j++) {
571
+ const networkItem = networkList[j];
572
+ const network = this.safeString(networkItem, 'network');
573
+ const networkCode = this.networkIdToCode(network);
574
+ networks[networkCode] = {
575
+ 'info': networkItem,
576
+ 'id': network,
577
+ 'network': networkCode,
578
+ 'active': undefined,
579
+ 'deposit': this.safeBool(networkItem, 'depositEnable'),
580
+ 'withdraw': this.safeBool(networkItem, 'withdrawEnable'),
581
+ 'fee': this.safeNumber(networkItem, 'withdrawFee'),
582
+ 'precision': this.safeNumber(networkItem, 'withdrawIntegerMultiple'),
583
+ 'limits': {
584
+ 'withdraw': {
585
+ 'min': this.safeNumber(networkItem, 'withdrawMin'),
586
+ 'max': this.safeNumber(networkItem, 'withdrawMax'),
587
+ },
588
+ 'deposit': {
589
+ 'min': undefined,
590
+ 'max': undefined,
591
+ },
592
+ },
593
+ };
594
+ }
595
+ result[code] = this.safeCurrencyStructure({
596
+ 'id': id,
597
+ 'name': this.safeString(entry, 'name'),
598
+ 'code': code,
599
+ 'type': isFiat ? 'fiat' : 'crypto',
600
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(entry, 'transferPrecision'))),
601
+ 'info': entry,
602
+ 'active': undefined,
603
+ 'deposit': this.safeBool(entry, 'depositAllEnable'),
604
+ 'withdraw': this.safeBool(entry, 'withdrawAllEnable'),
605
+ 'networks': networks,
606
+ 'fee': undefined,
607
+ 'fees': undefined,
608
+ 'limits': {},
609
+ });
610
+ }
611
+ return result;
612
+ }
488
613
  calculateRateLimiterCost(api, method, path, params, config = {}) {
489
614
  if (('noSymbol' in config) && !('symbol' in params)) {
490
615
  return config['noSymbol'];
@@ -1,11 +1,20 @@
1
1
  import Exchange from './abstract/cryptocom.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, Str, Ticker, OrderRequest, Balances, Transaction, OrderBook, Tickers, Strings, Currency, Market, Num, Account, CancellationRequest, Dict, int, TradingFeeInterface, TradingFees, LedgerEntry, DepositAddress, Position } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, Str, Ticker, OrderRequest, Balances, Transaction, OrderBook, Tickers, Strings, Currency, Currencies, Market, Num, Account, CancellationRequest, Dict, int, TradingFeeInterface, TradingFees, LedgerEntry, DepositAddress, Position } from './base/types.js';
3
3
  /**
4
4
  * @class cryptocom
5
5
  * @augments Exchange
6
6
  */
7
7
  export default class cryptocom extends Exchange {
8
8
  describe(): any;
9
+ /**
10
+ * @method
11
+ * @name cryptocom#fetchCurrencies
12
+ * @description fetches all available currencies on an exchange
13
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-currency-networks
14
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
15
+ * @returns {object} an associative dictionary of currencies
16
+ */
17
+ fetchCurrencies(params?: {}): Promise<Currencies>;
9
18
  /**
10
19
  * @method
11
20
  * @name cryptocom#fetchMarkets
@@ -54,7 +54,7 @@ export default class cryptocom extends Exchange {
54
54
  'fetchClosedOrders': 'emulated',
55
55
  'fetchCrossBorrowRate': false,
56
56
  'fetchCrossBorrowRates': false,
57
- 'fetchCurrencies': false,
57
+ 'fetchCurrencies': true,
58
58
  'fetchDepositAddress': true,
59
59
  'fetchDepositAddresses': false,
60
60
  'fetchDepositAddressesByNetwork': true,
@@ -511,6 +511,116 @@ export default class cryptocom extends Exchange {
511
511
  },
512
512
  });
513
513
  }
514
+ /**
515
+ * @method
516
+ * @name cryptocom#fetchCurrencies
517
+ * @description fetches all available currencies on an exchange
518
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-currency-networks
519
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
520
+ * @returns {object} an associative dictionary of currencies
521
+ */
522
+ async fetchCurrencies(params = {}) {
523
+ // this endpoint requires authentication
524
+ if (!this.checkRequiredCredentials(false)) {
525
+ return undefined;
526
+ }
527
+ const response = await this.v1PrivatePostPrivateGetCurrencyNetworks(params);
528
+ //
529
+ // {
530
+ // "id": "1747502328559",
531
+ // "method": "private/get-currency-networks",
532
+ // "code": "0",
533
+ // "result": {
534
+ // "update_time": "1747502281000",
535
+ // "currency_map": {
536
+ // "USDT": {
537
+ // "full_name": "Tether USD",
538
+ // "default_network": "ETH",
539
+ // "network_list": [
540
+ // {
541
+ // "network_id": "ETH",
542
+ // "withdrawal_fee": "10.00000000",
543
+ // "withdraw_enabled": true,
544
+ // "min_withdrawal_amount": "20.0",
545
+ // "deposit_enabled": true,
546
+ // "confirmation_required": "32"
547
+ // },
548
+ // {
549
+ // "network_id": "CRONOS",
550
+ // "withdrawal_fee": "0.18000000",
551
+ // "withdraw_enabled": true,
552
+ // "min_withdrawal_amount": "0.36",
553
+ // "deposit_enabled": true,
554
+ // "confirmation_required": "15"
555
+ // },
556
+ // {
557
+ // "network_id": "SOL",
558
+ // "withdrawal_fee": "5.31000000",
559
+ // "withdraw_enabled": true,
560
+ // "min_withdrawal_amount": "10.62",
561
+ // "deposit_enabled": true,
562
+ // "confirmation_required": "1"
563
+ // }
564
+ // ]
565
+ // }
566
+ // }
567
+ // }
568
+ // }
569
+ //
570
+ const resultData = this.safeDict(response, 'result', {});
571
+ const currencyMap = this.safeDict(resultData, 'currency_map', {});
572
+ const keys = Object.keys(currencyMap);
573
+ const result = {};
574
+ for (let i = 0; i < keys.length; i++) {
575
+ const key = keys[i];
576
+ const currency = currencyMap[key];
577
+ const id = key;
578
+ const code = this.safeCurrencyCode(id);
579
+ const networks = {};
580
+ const chains = this.safeList(currency, 'network_list', []);
581
+ for (let j = 0; j < chains.length; j++) {
582
+ const chain = chains[j];
583
+ const networkId = this.safeString(chain, 'network_id');
584
+ const network = this.networkIdToCode(networkId);
585
+ networks[network] = {
586
+ 'info': chain,
587
+ 'id': networkId,
588
+ 'network': network,
589
+ 'active': undefined,
590
+ 'deposit': this.safeBool(chain, 'deposit_enabled', false),
591
+ 'withdraw': this.safeBool(chain, 'withdraw_enabled', false),
592
+ 'fee': this.safeNumber(chain, 'withdrawal_fee'),
593
+ 'precision': undefined,
594
+ 'limits': {
595
+ 'withdraw': {
596
+ 'min': this.safeNumber(chain, 'min_withdrawal_amount'),
597
+ 'max': undefined,
598
+ },
599
+ },
600
+ };
601
+ }
602
+ result[code] = this.safeCurrencyStructure({
603
+ 'info': currency,
604
+ 'id': id,
605
+ 'code': code,
606
+ 'name': this.safeString(currency, 'full_name'),
607
+ 'active': undefined,
608
+ 'deposit': undefined,
609
+ 'withdraw': undefined,
610
+ 'fee': undefined,
611
+ 'precision': undefined,
612
+ 'limits': {
613
+ 'amount': {
614
+ 'min': undefined,
615
+ 'max': undefined,
616
+ },
617
+ },
618
+ 'type': 'crypto',
619
+ 'networks': networks,
620
+ });
621
+ }
622
+ return result;
623
+ }
514
624
  /**
515
625
  * @method
516
626
  * @name cryptocom#fetchMarkets
@@ -368,41 +368,9 @@ export default class cryptomus extends Exchange {
368
368
  const coins = this.safeList(response, 'result');
369
369
  const result = {};
370
370
  for (let i = 0; i < coins.length; i++) {
371
- const currency = coins[i];
372
- const currencyId = this.safeString(currency, 'currency_code');
371
+ const networkEntry = coins[i];
372
+ const currencyId = this.safeString(networkEntry, 'currency_code');
373
373
  const code = this.safeCurrencyCode(currencyId);
374
- const allowWithdraw = this.safeBool(currency, 'can_withdraw');
375
- const allowDeposit = this.safeBool(currency, 'can_deposit');
376
- const isActive = allowWithdraw && allowDeposit;
377
- const networkId = this.safeString(currency, 'network_code');
378
- const networksById = this.safeDict(this.options, 'networksById');
379
- const networkName = this.safeString(networksById, networkId, networkId);
380
- const minWithdraw = this.safeNumber(currency, 'min_withdraw');
381
- const maxWithdraw = this.safeNumber(currency, 'max_withdraw');
382
- const minDeposit = this.safeNumber(currency, 'min_deposit');
383
- const maxDeposit = this.safeNumber(currency, 'max_deposit');
384
- const network = {
385
- 'id': networkId,
386
- 'network': networkName,
387
- 'limits': {
388
- 'withdraw': {
389
- 'min': minWithdraw,
390
- 'max': maxWithdraw,
391
- },
392
- 'deposit': {
393
- 'min': minDeposit,
394
- 'max': maxDeposit,
395
- },
396
- },
397
- 'active': isActive,
398
- 'deposit': allowDeposit,
399
- 'withdraw': allowWithdraw,
400
- 'fee': undefined,
401
- 'precision': undefined,
402
- 'info': currency,
403
- };
404
- const networks = {};
405
- networks[networkName] = network;
406
374
  if (!(code in result)) {
407
375
  result[code] = {
408
376
  'id': currencyId,
@@ -410,70 +378,56 @@ export default class cryptomus extends Exchange {
410
378
  'precision': undefined,
411
379
  'type': undefined,
412
380
  'name': undefined,
413
- 'active': isActive,
414
- 'deposit': allowDeposit,
415
- 'withdraw': allowWithdraw,
381
+ 'active': undefined,
382
+ 'deposit': undefined,
383
+ 'withdraw': undefined,
416
384
  'fee': undefined,
417
385
  'limits': {
418
386
  'withdraw': {
419
- 'min': minWithdraw,
420
- 'max': maxWithdraw,
387
+ 'min': undefined,
388
+ 'max': undefined,
421
389
  },
422
390
  'deposit': {
423
- 'min': minDeposit,
424
- 'max': maxDeposit,
391
+ 'min': undefined,
392
+ 'max': undefined,
425
393
  },
426
394
  },
427
- 'networks': networks,
428
- 'info': currency,
395
+ 'networks': {},
396
+ 'info': {},
429
397
  };
430
398
  }
431
- else {
432
- const parsed = result[code];
433
- const parsedNetworks = this.safeDict(parsed, 'networks');
434
- parsed['networks'] = this.extend(parsedNetworks, networks);
435
- if (isActive) {
436
- parsed['active'] = true;
437
- parsed['deposit'] = true;
438
- parsed['withdraw'] = true;
439
- }
440
- else {
441
- if (allowWithdraw) {
442
- parsed['withdraw'] = true;
443
- }
444
- if (allowDeposit) {
445
- parsed['deposit'] = true;
446
- }
447
- }
448
- const parsedLimits = this.safeDict(parsed, 'limits');
449
- const withdrawLimits = {
450
- 'min': undefined,
451
- 'max': undefined,
452
- };
453
- const parsedWithdrawLimits = this.safeDict(parsedLimits, 'withdraw', withdrawLimits);
454
- const depositLimits = {
455
- 'min': undefined,
456
- 'max': undefined,
457
- };
458
- const parsedDepositLimits = this.safeDict(parsedLimits, 'deposit', depositLimits);
459
- if (minWithdraw) {
460
- withdrawLimits['min'] = parsedWithdrawLimits['min'] ? Math.min(parsedWithdrawLimits['min'], minWithdraw) : minWithdraw;
461
- }
462
- if (maxWithdraw) {
463
- withdrawLimits['max'] = parsedWithdrawLimits['max'] ? Math.max(parsedWithdrawLimits['max'], maxWithdraw) : maxWithdraw;
464
- }
465
- if (minDeposit) {
466
- depositLimits['min'] = parsedDepositLimits['min'] ? Math.min(parsedDepositLimits['min'], minDeposit) : minDeposit;
467
- }
468
- if (maxDeposit) {
469
- depositLimits['max'] = parsedDepositLimits['max'] ? Math.max(parsedDepositLimits['max'], maxDeposit) : maxDeposit;
470
- }
471
- const limits = {
472
- 'withdraw': withdrawLimits,
473
- 'deposit': depositLimits,
474
- };
475
- parsed['limits'] = limits;
476
- }
399
+ const networkId = this.safeString(networkEntry, 'network_code');
400
+ const networkCode = this.networkIdToCode(networkId);
401
+ result[code]['networks'][networkCode] = {
402
+ 'id': networkId,
403
+ 'network': networkCode,
404
+ 'limits': {
405
+ 'withdraw': {
406
+ 'min': this.safeNumber(networkEntry, 'min_withdraw'),
407
+ 'max': this.safeNumber(networkEntry, 'max_withdraw'),
408
+ },
409
+ 'deposit': {
410
+ 'min': this.safeNumber(networkEntry, 'min_deposit'),
411
+ 'max': this.safeNumber(networkEntry, 'max_deposit'),
412
+ },
413
+ },
414
+ 'active': undefined,
415
+ 'deposit': this.safeBool(networkEntry, 'can_withdraw'),
416
+ 'withdraw': this.safeBool(networkEntry, 'can_deposit'),
417
+ 'fee': undefined,
418
+ 'precision': undefined,
419
+ 'info': networkEntry,
420
+ };
421
+ // add entry in info
422
+ const info = this.safeList(result[code], 'info', []);
423
+ info.push(networkEntry);
424
+ result[code]['info'] = info;
425
+ }
426
+ // only after all entries are formed in currencies, restructure each entry
427
+ const allKeys = Object.keys(result);
428
+ for (let i = 0; i < allKeys.length; i++) {
429
+ const code = allKeys[i];
430
+ result[code] = this.safeCurrencyStructure(result[code]); // this is needed after adding network entry
477
431
  }
478
432
  return result;
479
433
  }