ccxt 4.4.85 → 4.4.87

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 (115) hide show
  1. package/README.md +18 -7
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +16 -9
  4. package/dist/cjs/src/abstract/bittrade.js +9 -0
  5. package/dist/cjs/src/abstract/modetrade.js +9 -0
  6. package/dist/cjs/src/ascendex.js +189 -155
  7. package/dist/cjs/src/base/Exchange.js +10 -8
  8. package/dist/cjs/src/bequant.js +1 -1
  9. package/dist/cjs/src/binance.js +1 -1
  10. package/dist/cjs/src/bitget.js +5 -4
  11. package/dist/cjs/src/bitmart.js +1 -1
  12. package/dist/cjs/src/bitteam.js +31 -0
  13. package/dist/cjs/src/bittrade.js +2049 -0
  14. package/dist/cjs/src/coinbase.js +2 -6
  15. package/dist/cjs/src/coinmetro.js +5 -1
  16. package/dist/cjs/src/deribit.js +4 -5
  17. package/dist/cjs/src/derive.js +4 -5
  18. package/dist/cjs/src/ellipx.js +2 -3
  19. package/dist/cjs/src/gate.js +92 -76
  20. package/dist/cjs/src/hollaex.js +107 -49
  21. package/dist/cjs/src/htx.js +30 -52
  22. package/dist/cjs/src/hyperliquid.js +36 -20
  23. package/dist/cjs/src/kraken.js +5 -8
  24. package/dist/cjs/src/mexc.js +2 -2
  25. package/dist/cjs/src/modetrade.js +2839 -0
  26. package/dist/cjs/src/ndax.js +25 -24
  27. package/dist/cjs/src/okcoin.js +12 -31
  28. package/dist/cjs/src/okx.js +104 -2
  29. package/dist/cjs/src/okxus.js +53 -0
  30. package/dist/cjs/src/onetrading.js +9 -6
  31. package/dist/cjs/src/oxfun.js +42 -114
  32. package/dist/cjs/src/paradex.js +10 -1
  33. package/dist/cjs/src/phemex.js +4 -6
  34. package/dist/cjs/src/poloniex.js +181 -170
  35. package/dist/cjs/src/pro/binance.js +1 -0
  36. package/dist/cjs/src/pro/bittrade.js +605 -0
  37. package/dist/cjs/src/pro/luno.js +6 -5
  38. package/dist/cjs/src/pro/mexc.js +3 -0
  39. package/dist/cjs/src/pro/modetrade.js +1334 -0
  40. package/dist/cjs/src/pro/okxus.js +38 -0
  41. package/dist/cjs/src/probit.js +18 -51
  42. package/dist/cjs/src/timex.js +5 -10
  43. package/dist/cjs/src/vertex.js +3 -4
  44. package/dist/cjs/src/whitebit.js +41 -11
  45. package/dist/cjs/src/woo.js +101 -77
  46. package/dist/cjs/src/woofipro.js +24 -21
  47. package/dist/cjs/src/xt.js +36 -44
  48. package/js/ccxt.d.ts +20 -11
  49. package/js/ccxt.js +14 -8
  50. package/js/src/abstract/modetrade.d.ts +122 -0
  51. package/js/src/abstract/myokx.d.ts +2 -0
  52. package/js/src/abstract/okx.d.ts +2 -0
  53. package/js/src/abstract/okxus.d.ts +352 -0
  54. package/js/src/abstract/okxus.js +11 -0
  55. package/js/src/ascendex.d.ts +2 -0
  56. package/js/src/ascendex.js +189 -155
  57. package/js/src/base/Exchange.js +10 -8
  58. package/js/src/bequant.js +1 -1
  59. package/js/src/binance.js +1 -1
  60. package/js/src/bitget.js +5 -4
  61. package/js/src/bitmart.js +1 -1
  62. package/js/src/bitteam.js +31 -0
  63. package/js/src/{huobijp.d.ts → bittrade.d.ts} +29 -29
  64. package/js/src/{huobijp.js → bittrade.js} +35 -35
  65. package/js/src/coinbase.js +2 -6
  66. package/js/src/coinmetro.js +5 -1
  67. package/js/src/deribit.js +4 -5
  68. package/js/src/derive.js +4 -3
  69. package/js/src/ellipx.d.ts +1 -1
  70. package/js/src/ellipx.js +3 -5
  71. package/js/src/gate.js +92 -76
  72. package/js/src/hollaex.js +107 -49
  73. package/js/src/htx.js +30 -52
  74. package/js/src/hyperliquid.js +36 -20
  75. package/js/src/kraken.js +5 -8
  76. package/js/src/mexc.js +2 -2
  77. package/js/src/modetrade.d.ts +475 -0
  78. package/js/src/modetrade.js +2840 -0
  79. package/js/src/ndax.js +25 -24
  80. package/js/src/okcoin.js +12 -31
  81. package/js/src/okx.d.ts +24 -1
  82. package/js/src/okx.js +104 -2
  83. package/js/src/okxus.d.ts +4 -0
  84. package/js/src/okxus.js +54 -0
  85. package/js/src/onetrading.js +9 -6
  86. package/js/src/oxfun.js +42 -114
  87. package/js/src/paradex.js +10 -1
  88. package/js/src/phemex.js +4 -6
  89. package/js/src/poloniex.d.ts +2 -0
  90. package/js/src/poloniex.js +181 -170
  91. package/js/src/pro/binance.js +1 -0
  92. package/js/src/pro/{huobijp.d.ts → bittrade.d.ts} +6 -6
  93. package/js/src/pro/{huobijp.js → bittrade.js} +7 -7
  94. package/js/src/pro/luno.js +6 -5
  95. package/js/src/pro/mexc.js +3 -0
  96. package/js/src/pro/modetrade.d.ts +155 -0
  97. package/js/src/pro/modetrade.js +1335 -0
  98. package/js/src/pro/okxus.d.ts +4 -0
  99. package/js/src/pro/okxus.js +39 -0
  100. package/js/src/probit.js +18 -51
  101. package/js/src/timex.js +5 -10
  102. package/js/src/vertex.js +3 -4
  103. package/js/src/whitebit.js +42 -11
  104. package/js/src/woo.d.ts +2 -0
  105. package/js/src/woo.js +101 -77
  106. package/js/src/woofipro.d.ts +2 -1
  107. package/js/src/woofipro.js +24 -21
  108. package/js/src/xt.js +36 -44
  109. package/package.json +1 -1
  110. package/js/src/abstract/kuna.d.ts +0 -185
  111. package/js/src/kuna.d.ts +0 -335
  112. package/js/src/kuna.js +0 -2006
  113. /package/js/src/abstract/{huobijp.d.ts → bittrade.d.ts} +0 -0
  114. /package/js/src/abstract/{huobijp.js → bittrade.js} +0 -0
  115. /package/js/src/abstract/{kuna.js → modetrade.js} +0 -0
@@ -309,6 +309,11 @@ export default class poloniex extends Exchange {
309
309
  'BEP20': 'BSC',
310
310
  'ERC20': 'ETH',
311
311
  'TRC20': 'TRON',
312
+ 'TRX': 'TRON',
313
+ },
314
+ 'networksById': {
315
+ 'TRX': 'TRC20',
316
+ 'TRON': 'TRC20',
312
317
  },
313
318
  'limits': {
314
319
  'cost': {
@@ -1151,105 +1156,107 @@ export default class poloniex extends Exchange {
1151
1156
  const response = await this.publicGetCurrencies(this.extend(params, { 'includeMultiChainCurrencies': true }));
1152
1157
  //
1153
1158
  // [
1154
- // {
1155
- // "1CR": {
1156
- // "id": 1,
1157
- // "name": "1CRedit",
1158
- // "description": "BTC Clone",
1159
- // "type": "address",
1160
- // "withdrawalFee": "0.01000000",
1161
- // "minConf": 10000,
1162
- // "depositAddress": null,
1163
- // "blockchain": "1CR",
1164
- // "delisted": false,
1165
- // "tradingState": "NORMAL",
1166
- // "walletState": "DISABLED",
1167
- // "walletDepositState": "DISABLED",
1168
- // "walletWithdrawalState": "DISABLED",
1169
- // "parentChain": null,
1170
- // "isMultiChain": false,
1171
- // "isChildChain": false,
1172
- // "childChains": []
1173
- // }
1174
- // }
1159
+ // {
1160
+ // "USDT": {
1161
+ // "id": 214,
1162
+ // "name": "Tether USD",
1163
+ // "description": "Sweep to Main Account",
1164
+ // "type": "address",
1165
+ // "withdrawalFee": "0.00000000",
1166
+ // "minConf": 2,
1167
+ // "depositAddress": null,
1168
+ // "blockchain": "OMNI",
1169
+ // "delisted": false,
1170
+ // "tradingState": "NORMAL",
1171
+ // "walletState": "DISABLED",
1172
+ // "walletDepositState": "DISABLED",
1173
+ // "walletWithdrawalState": "DISABLED",
1174
+ // "supportCollateral": true,
1175
+ // "supportBorrow": true,
1176
+ // "parentChain": null,
1177
+ // "isMultiChain": true,
1178
+ // "isChildChain": false,
1179
+ // "childChains": [
1180
+ // "USDTBSC",
1181
+ // "USDTETH",
1182
+ // "USDTSOL",
1183
+ // "USDTTRON"
1184
+ // ]
1185
+ // }
1186
+ // },
1187
+ // ...
1188
+ // {
1189
+ // "USDTBSC": {
1190
+ // "id": 582,
1191
+ // "name": "Binance-Peg BSC-USD",
1192
+ // "description": "Sweep to Main Account",
1193
+ // "type": "address",
1194
+ // "withdrawalFee": "0.00000000",
1195
+ // "minConf": 15,
1196
+ // "depositAddress": null,
1197
+ // "blockchain": "BSC",
1198
+ // "delisted": false,
1199
+ // "tradingState": "OFFLINE",
1200
+ // "walletState": "ENABLED",
1201
+ // "walletDepositState": "ENABLED",
1202
+ // "walletWithdrawalState": "DISABLED",
1203
+ // "supportCollateral": false,
1204
+ // "supportBorrow": false,
1205
+ // "parentChain": "USDT",
1206
+ // "isMultiChain": true,
1207
+ // "isChildChain": true,
1208
+ // "childChains": []
1209
+ // }
1210
+ // },
1211
+ // ...
1175
1212
  // ]
1176
1213
  //
1177
1214
  const result = {};
1215
+ // poloniex has a complicated structure of currencies, so we handle them differently
1216
+ // at first, turn the response into a normal dictionary
1217
+ const currenciesDict = {};
1178
1218
  for (let i = 0; i < response.length; i++) {
1179
- const item = this.safeValue(response, i);
1219
+ const item = this.safeDict(response, i);
1180
1220
  const ids = Object.keys(item);
1181
- const id = this.safeValue(ids, 0);
1182
- const currency = this.safeValue(item, id);
1221
+ const id = this.safeString(ids, 0);
1222
+ currenciesDict[id] = item[id];
1223
+ }
1224
+ const keys = Object.keys(currenciesDict);
1225
+ for (let i = 0; i < keys.length; i++) {
1226
+ const id = keys[i];
1227
+ const entry = currenciesDict[id];
1183
1228
  const code = this.safeCurrencyCode(id);
1184
- const name = this.safeString(currency, 'name');
1185
- const networkId = this.safeString(currency, 'blockchain');
1186
- let networkCode = undefined;
1187
- if (networkId !== undefined) {
1188
- networkCode = this.networkIdToCode(networkId, code);
1189
- }
1190
- const delisted = this.safeValue(currency, 'delisted');
1191
- const walletEnabled = this.safeString(currency, 'walletState') === 'ENABLED';
1192
- const depositEnabled = this.safeString(currency, 'walletDepositState') === 'ENABLED';
1193
- const withdrawEnabled = this.safeString(currency, 'walletWithdrawalState') === 'ENABLED';
1194
- const active = !delisted && walletEnabled && depositEnabled && withdrawEnabled;
1195
- const numericId = this.safeInteger(currency, 'id');
1196
- const feeString = this.safeString(currency, 'withdrawalFee');
1197
- const parentChain = this.safeValue(currency, 'parentChain');
1198
- const noParentChain = parentChain === undefined;
1199
- if (this.safeValue(result, code) === undefined) {
1200
- result[code] = {
1201
- 'id': id,
1202
- 'code': code,
1203
- 'info': undefined,
1204
- 'name': name,
1205
- 'active': active,
1206
- 'deposit': depositEnabled,
1207
- 'withdraw': withdrawEnabled,
1208
- 'fee': this.parseNumber(feeString),
1209
- 'precision': undefined,
1210
- 'type': 'crypto',
1211
- 'limits': {
1212
- 'amount': {
1213
- 'min': undefined,
1214
- 'max': undefined,
1215
- },
1216
- 'deposit': {
1217
- 'min': undefined,
1218
- 'max': undefined,
1219
- },
1220
- 'withdraw': {
1221
- 'min': undefined,
1222
- 'max': undefined,
1223
- },
1224
- },
1225
- };
1229
+ // skip childChains, as they are collected in parentChain loop
1230
+ if (this.safeBool(entry, 'isChildChain')) {
1231
+ continue;
1226
1232
  }
1227
- let minFeeString = this.safeString(result[code], 'fee');
1228
- if (feeString !== undefined) {
1229
- minFeeString = (minFeeString === undefined) ? feeString : Precise.stringMin(feeString, minFeeString);
1233
+ const allChainEntries = [];
1234
+ const childChains = this.safeList(entry, 'childChains', []);
1235
+ if (childChains !== undefined) {
1236
+ for (let j = 0; j < childChains.length; j++) {
1237
+ const childChainId = childChains[j];
1238
+ const childNetworkEntry = this.safeDict(currenciesDict, childChainId);
1239
+ allChainEntries.push(childNetworkEntry);
1240
+ }
1230
1241
  }
1231
- let depositAvailable = this.safeValue(result[code], 'deposit');
1232
- depositAvailable = (depositEnabled) ? depositEnabled : depositAvailable;
1233
- let withdrawAvailable = this.safeValue(result[code], 'withdraw');
1234
- withdrawAvailable = (withdrawEnabled) ? withdrawEnabled : withdrawAvailable;
1235
- const networks = this.safeValue(result[code], 'networks', {});
1236
- if (networkCode !== undefined) {
1242
+ allChainEntries.push(entry);
1243
+ const networks = {};
1244
+ for (let j = 0; j < allChainEntries.length; j++) {
1245
+ const chainEntry = allChainEntries[j];
1246
+ const networkName = this.safeString(chainEntry, 'blockchain');
1247
+ const networkCode = this.networkIdToCode(networkName, code);
1248
+ const specialNetworkId = this.safeString(childChains, j, id); // in case it's primary chain, defeault to ID
1237
1249
  networks[networkCode] = {
1238
- 'info': currency,
1239
- 'id': networkId,
1250
+ 'info': chainEntry,
1251
+ 'id': specialNetworkId,
1252
+ 'numericId': this.safeInteger(chainEntry, 'id'),
1240
1253
  'network': networkCode,
1241
- 'currencyId': id,
1242
- 'numericId': numericId,
1243
- 'deposit': depositEnabled,
1244
- 'withdraw': withdrawEnabled,
1245
- 'active': active,
1246
- 'fee': this.parseNumber(feeString),
1254
+ 'active': this.safeBool(chainEntry, 'walletState'),
1255
+ 'deposit': this.safeString(chainEntry, 'walletDepositState') === 'ENABLED',
1256
+ 'withdraw': this.safeString(chainEntry, 'walletWithdrawalState') === 'ENABLED',
1257
+ 'fee': this.safeNumber(chainEntry, 'withdrawalFee'),
1247
1258
  'precision': undefined,
1248
1259
  'limits': {
1249
- 'amount': {
1250
- 'min': undefined,
1251
- 'max': undefined,
1252
- },
1253
1260
  'withdraw': {
1254
1261
  'min': undefined,
1255
1262
  'max': undefined,
@@ -1261,20 +1268,34 @@ export default class poloniex extends Exchange {
1261
1268
  },
1262
1269
  };
1263
1270
  }
1264
- result[code]['networks'] = networks;
1265
- const info = this.safeValue(result[code], 'info', []);
1266
- const rawInfo = {};
1267
- rawInfo[id] = currency;
1268
- info.push(rawInfo);
1269
- result[code]['info'] = info;
1270
- if (noParentChain) {
1271
- result[code]['id'] = id;
1272
- result[code]['name'] = name;
1273
- }
1274
- result[code]['active'] = depositAvailable && withdrawAvailable;
1275
- result[code]['deposit'] = depositAvailable;
1276
- result[code]['withdraw'] = withdrawAvailable;
1277
- result[code]['fee'] = this.parseNumber(minFeeString);
1271
+ result[code] = this.safeCurrencyStructure({
1272
+ 'info': entry,
1273
+ 'code': code,
1274
+ 'id': id,
1275
+ 'numericId': this.safeInteger(entry, 'id'),
1276
+ 'type': 'crypto',
1277
+ 'name': this.safeString(entry, 'name'),
1278
+ 'active': undefined,
1279
+ 'deposit': undefined,
1280
+ 'withdraw': undefined,
1281
+ 'fee': undefined,
1282
+ 'precision': undefined,
1283
+ 'limits': {
1284
+ 'amount': {
1285
+ 'min': undefined,
1286
+ 'max': undefined,
1287
+ },
1288
+ 'withdraw': {
1289
+ 'min': undefined,
1290
+ 'max': undefined,
1291
+ },
1292
+ 'deposit': {
1293
+ 'min': undefined,
1294
+ 'max': undefined,
1295
+ },
1296
+ },
1297
+ 'networks': networks,
1298
+ });
1278
1299
  }
1279
1300
  return result;
1280
1301
  }
@@ -2669,45 +2690,15 @@ export default class poloniex extends Exchange {
2669
2690
  */
2670
2691
  async createDepositAddress(code, params = {}) {
2671
2692
  await this.loadMarkets();
2672
- const currency = this.currency(code);
2673
- const request = {
2674
- 'currency': currency['id'],
2675
- };
2676
- const networks = this.safeValue(this.options, 'networks', {});
2677
- let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
2678
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
2679
- if (network !== undefined) {
2680
- request['currency'] = request['currency'] + network; // when network the currency need to be changed to currency+network https://docs.poloniex.com/#withdraw on MultiChain Currencies section
2681
- params = this.omit(params, 'network');
2682
- }
2683
- else {
2684
- if (currency['id'] === 'USDT') {
2685
- throw new ArgumentsRequired(this.id + ' createDepositAddress requires a network parameter for ' + code + '.');
2686
- }
2687
- }
2693
+ const [request, extraParams, currency, networkEntry] = this.prepareRequestForDepositAddress(code, params);
2694
+ params = extraParams;
2688
2695
  const response = await this.privatePostWalletsAddress(this.extend(request, params));
2689
2696
  //
2690
2697
  // {
2691
2698
  // "address" : "0xfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf"
2692
2699
  // }
2693
2700
  //
2694
- let address = this.safeString(response, 'address');
2695
- let tag = undefined;
2696
- this.checkAddress(address);
2697
- if (currency !== undefined) {
2698
- const depositAddress = this.safeString(currency['info'], 'depositAddress');
2699
- if (depositAddress !== undefined) {
2700
- tag = address;
2701
- address = depositAddress;
2702
- }
2703
- }
2704
- return {
2705
- 'currency': code,
2706
- 'address': address,
2707
- 'tag': tag,
2708
- 'network': network,
2709
- 'info': response,
2710
- };
2701
+ return this.parseDepositAddressSpecial(response, currency, networkEntry);
2711
2702
  }
2712
2703
  /**
2713
2704
  * @method
@@ -2720,33 +2711,55 @@ export default class poloniex extends Exchange {
2720
2711
  */
2721
2712
  async fetchDepositAddress(code, params = {}) {
2722
2713
  await this.loadMarkets();
2723
- const currency = this.currency(code);
2724
- const request = {
2725
- 'currency': currency['id'],
2726
- };
2727
- const networks = this.safeValue(this.options, 'networks', {});
2728
- let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
2729
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
2730
- if (network !== undefined) {
2731
- request['currency'] = request['currency'] + network; // when network the currency need to be changed to currency+network https://docs.poloniex.com/#withdraw on MultiChain Currencies section
2732
- params = this.omit(params, 'network');
2733
- }
2734
- else {
2735
- if (currency['id'] === 'USDT') {
2736
- throw new ArgumentsRequired(this.id + ' fetchDepositAddress requires a network parameter for ' + code + '.');
2737
- }
2738
- }
2714
+ const [request, extraParams, currency, networkEntry] = this.prepareRequestForDepositAddress(code, params);
2715
+ params = extraParams;
2739
2716
  const response = await this.privateGetWalletsAddresses(this.extend(request, params));
2740
2717
  //
2741
2718
  // {
2742
2719
  // "USDTTRON" : "Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxp"
2743
2720
  // }
2744
2721
  //
2745
- let address = this.safeString(response, request['currency']);
2722
+ const keys = Object.keys(response);
2723
+ const length = keys.length;
2724
+ if (length < 1) {
2725
+ throw new ExchangeError(this.id + ' fetchDepositAddress() returned an empty response, you might need to try "createDepositAddress" at first and then use "fetchDepositAddress"');
2726
+ }
2727
+ return this.parseDepositAddressSpecial(response, currency, networkEntry);
2728
+ }
2729
+ prepareRequestForDepositAddress(code, params = {}) {
2730
+ if (!(code in this.currencies)) {
2731
+ throw new BadSymbol(this.id + ' fetchDepositAddress(): can not recognize ' + code + ' currency, you might try using unified currency-code and add provide specific "network" parameter, like: fetchDepositAddress("USDT", { "network": "TRC20" })');
2732
+ }
2733
+ const currency = this.currency(code);
2734
+ let networkCode = undefined;
2735
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
2736
+ if (networkCode === undefined) {
2737
+ // we need to know the network to find out the currency-junction
2738
+ throw new ArgumentsRequired(this.id + ' fetchDepositAddress requires a network parameter for ' + code + '.');
2739
+ }
2740
+ let exchangeNetworkId = undefined;
2741
+ networkCode = this.networkIdToCode(networkCode, code);
2742
+ const networkEntry = this.safeDict(currency['networks'], networkCode);
2743
+ if (networkEntry !== undefined) {
2744
+ exchangeNetworkId = networkEntry['id'];
2745
+ }
2746
+ else {
2747
+ exchangeNetworkId = networkCode;
2748
+ }
2749
+ const request = {
2750
+ 'currency': exchangeNetworkId,
2751
+ };
2752
+ return [request, params, currency, networkEntry];
2753
+ }
2754
+ parseDepositAddressSpecial(response, currency, networkEntry) {
2755
+ let address = this.safeString(response, 'address');
2756
+ if (address === undefined) {
2757
+ address = this.safeString(response, networkEntry['id']);
2758
+ }
2746
2759
  let tag = undefined;
2747
2760
  this.checkAddress(address);
2748
- if (currency !== undefined) {
2749
- const depositAddress = this.safeString(currency['info'], 'depositAddress');
2761
+ if (networkEntry !== undefined) {
2762
+ const depositAddress = this.safeString(networkEntry['info'], 'depositAddress');
2750
2763
  if (depositAddress !== undefined) {
2751
2764
  tag = address;
2752
2765
  address = depositAddress;
@@ -2754,8 +2767,8 @@ export default class poloniex extends Exchange {
2754
2767
  }
2755
2768
  return {
2756
2769
  'info': response,
2757
- 'currency': code,
2758
- 'network': network,
2770
+ 'currency': currency['code'],
2771
+ 'network': this.safeString(networkEntry, 'network'),
2759
2772
  'address': address,
2760
2773
  'tag': tag,
2761
2774
  };
@@ -2825,23 +2838,13 @@ export default class poloniex extends Exchange {
2825
2838
  async withdraw(code, amount, address, tag = undefined, params = {}) {
2826
2839
  [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2827
2840
  this.checkAddress(address);
2828
- await this.loadMarkets();
2829
- const currency = this.currency(code);
2830
- const request = {
2831
- 'currency': currency['id'],
2832
- 'amount': amount,
2833
- 'address': address,
2834
- };
2841
+ const [request, extraParams, currency, networkEntry] = this.prepareRequestForDepositAddress(code, params);
2842
+ params = extraParams;
2843
+ request['amount'] = this.currencyToPrecision(code, amount);
2844
+ request['address'] = address;
2835
2845
  if (tag !== undefined) {
2836
2846
  request['paymentId'] = tag;
2837
2847
  }
2838
- const networks = this.safeValue(this.options, 'networks', {});
2839
- let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
2840
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
2841
- if (network !== undefined) {
2842
- request['currency'] = request['currency'] + network; // when network the currency need to be changed to currency+network https://docs.poloniex.com/#withdraw on MultiChain Currencies section
2843
- params = this.omit(params, 'network');
2844
- }
2845
2848
  const response = await this.privatePostWalletsWithdraw(this.extend(request, params));
2846
2849
  //
2847
2850
  // {
@@ -2850,7 +2853,11 @@ export default class poloniex extends Exchange {
2850
2853
  // "withdrawalNumber": 13449869
2851
2854
  // }
2852
2855
  //
2853
- return this.parseTransaction(response, currency);
2856
+ const withdrawResponse = {
2857
+ 'response': response,
2858
+ 'withdrawNetworkEntry': networkEntry,
2859
+ };
2860
+ return this.parseTransaction(withdrawResponse, currency);
2854
2861
  }
2855
2862
  async fetchTransactionsHelper(code = undefined, since = undefined, limit = undefined, params = {}) {
2856
2863
  await this.loadMarkets();
@@ -3176,6 +3183,10 @@ export default class poloniex extends Exchange {
3176
3183
  // "withdrawalRequestsId": 33485231
3177
3184
  // }
3178
3185
  //
3186
+ // if it's being parsed from "withdraw()" method, get the original response
3187
+ if ('withdrawNetworkEntry' in transaction) {
3188
+ transaction = transaction['response'];
3189
+ }
3179
3190
  const timestamp = this.safeTimestamp(transaction, 'timestamp');
3180
3191
  const currencyId = this.safeString(transaction, 'currency');
3181
3192
  const code = this.safeCurrencyCode(currencyId);
@@ -830,6 +830,7 @@ export default class binance extends binanceRest {
830
830
  orderbook.reset(snapshot);
831
831
  // unroll the accumulated deltas
832
832
  const messages = orderbook.cache;
833
+ orderbook.cache = [];
833
834
  for (let i = 0; i < messages.length; i++) {
834
835
  const messageItem = messages[i];
835
836
  const U = this.safeInteger(messageItem, 'U');
@@ -1,12 +1,12 @@
1
- import huobijpRest from '../huobijp.js';
1
+ import bittradeRest from '../bittrade.js';
2
2
  import type { Int, OrderBook, Trade, Ticker, OHLCV } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
- export default class huobijp extends huobijpRest {
4
+ export default class bittrade extends bittradeRest {
5
5
  describe(): any;
6
6
  requestId(): any;
7
7
  /**
8
8
  * @method
9
- * @name huobijp#watchTicker
9
+ * @name bittrade#watchTicker
10
10
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
11
11
  * @param {string} symbol unified symbol of the market to fetch the ticker for
12
12
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -16,7 +16,7 @@ export default class huobijp extends huobijpRest {
16
16
  handleTicker(client: Client, message: any): any;
17
17
  /**
18
18
  * @method
19
- * @name huobijp#watchTrades
19
+ * @name bittrade#watchTrades
20
20
  * @description get the list of most recent trades for a particular symbol
21
21
  * @param {string} symbol unified symbol of the market to fetch trades for
22
22
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -28,7 +28,7 @@ export default class huobijp extends huobijpRest {
28
28
  handleTrades(client: Client, message: any): any;
29
29
  /**
30
30
  * @method
31
- * @name huobijp#watchOHLCV
31
+ * @name bittrade#watchOHLCV
32
32
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
33
33
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
34
34
  * @param {string} timeframe the length of time each candle represents
@@ -41,7 +41,7 @@ export default class huobijp extends huobijpRest {
41
41
  handleOHLCV(client: Client, message: any): void;
42
42
  /**
43
43
  * @method
44
- * @name huobijp#watchOrderBook
44
+ * @name bittrade#watchOrderBook
45
45
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
46
46
  * @param {string} symbol unified symbol of the market to fetch the order book for
47
47
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -5,11 +5,11 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  // ----------------------------------------------------------------------------
8
- import huobijpRest from '../huobijp.js';
8
+ import bittradeRest from '../bittrade.js';
9
9
  import { ExchangeError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
11
11
  // ----------------------------------------------------------------------------
12
- export default class huobijp extends huobijpRest {
12
+ export default class bittrade extends bittradeRest {
13
13
  describe() {
14
14
  return this.deepExtend(super.describe(), {
15
15
  'has': {
@@ -49,7 +49,7 @@ export default class huobijp extends huobijpRest {
49
49
  }
50
50
  /**
51
51
  * @method
52
- * @name huobijp#watchTicker
52
+ * @name bittrade#watchTicker
53
53
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
54
54
  * @param {string} symbol unified symbol of the market to fetch the ticker for
55
55
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -111,7 +111,7 @@ export default class huobijp extends huobijpRest {
111
111
  }
112
112
  /**
113
113
  * @method
114
- * @name huobijp#watchTrades
114
+ * @name bittrade#watchTrades
115
115
  * @description get the list of most recent trades for a particular symbol
116
116
  * @param {string} symbol unified symbol of the market to fetch trades for
117
117
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -188,7 +188,7 @@ export default class huobijp extends huobijpRest {
188
188
  }
189
189
  /**
190
190
  * @method
191
- * @name huobijp#watchOHLCV
191
+ * @name bittrade#watchOHLCV
192
192
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
193
193
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
194
194
  * @param {string} timeframe the length of time each candle represents
@@ -262,7 +262,7 @@ export default class huobijp extends huobijpRest {
262
262
  }
263
263
  /**
264
264
  * @method
265
- * @name huobijp#watchOrderBook
265
+ * @name bittrade#watchOrderBook
266
266
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
267
267
  * @param {string} symbol unified symbol of the market to fetch the order book for
268
268
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -585,7 +585,7 @@ export default class huobijp extends huobijpRest {
585
585
  //
586
586
  // ________________________
587
587
  //
588
- // sometimes huobijp responds with half of a JSON response like
588
+ // sometimes bittrade responds with half of a JSON response like
589
589
  //
590
590
  // " {"ch":"market.ethbtc.m "
591
591
  //
@@ -198,17 +198,18 @@ export default class luno extends lunoRest {
198
198
  if (!(symbol in this.orderbooks)) {
199
199
  this.orderbooks[symbol] = this.indexedOrderBook({});
200
200
  }
201
- const orderbook = this.orderbooks[symbol];
202
201
  const asks = this.safeValue(message, 'asks');
203
202
  if (asks !== undefined) {
204
203
  const snapshot = this.customParseOrderBook(message, symbol, timestamp, 'bids', 'asks', 'price', 'volume', 'id');
205
- orderbook.reset(snapshot);
204
+ this.orderbooks[symbol] = this.indexedOrderBook(snapshot);
206
205
  }
207
206
  else {
208
- this.handleDelta(orderbook, message);
209
- orderbook['timestamp'] = timestamp;
210
- orderbook['datetime'] = this.iso8601(timestamp);
207
+ const ob = this.orderbooks[symbol];
208
+ this.handleDelta(ob, message);
209
+ ob['timestamp'] = timestamp;
210
+ ob['datetime'] = this.iso8601(timestamp);
211
211
  }
212
+ const orderbook = this.orderbooks[symbol];
212
213
  const nonce = this.safeInteger(message, 'sequence');
213
214
  orderbook['nonce'] = nonce;
214
215
  client.resolve(orderbook, messageHash);
@@ -797,6 +797,9 @@ export default class mexc extends mexcRest {
797
797
  const messageHash = 'orderbook:' + symbol;
798
798
  const subscription = this.safeValue(client.subscriptions, messageHash);
799
799
  const limit = this.safeInteger(subscription, 'limit');
800
+ if (!(symbol in this.orderbooks)) {
801
+ this.orderbooks[symbol] = this.orderBook();
802
+ }
800
803
  const storedOrderBook = this.orderbooks[symbol];
801
804
  const nonce = this.safeInteger(storedOrderBook, 'nonce');
802
805
  if (nonce === undefined) {