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
@@ -1125,9 +1125,7 @@ class phemex extends phemex$1 {
1125
1125
  for (let i = 0; i < currencies.length; i++) {
1126
1126
  const currency = currencies[i];
1127
1127
  const id = this.safeString(currency, 'currency');
1128
- const name = this.safeString(currency, 'name');
1129
1128
  const code = this.safeCurrencyCode(id);
1130
- const status = this.safeString(currency, 'status');
1131
1129
  const valueScaleString = this.safeString(currency, 'valueScale');
1132
1130
  const valueScale = parseInt(valueScaleString);
1133
1131
  const minValueEv = this.safeString(currency, 'minValueEv');
@@ -1141,12 +1139,12 @@ class phemex extends phemex$1 {
1141
1139
  minAmount = this.parseNumber(Precise["default"].stringMul(minValueEv, precisionString));
1142
1140
  maxAmount = this.parseNumber(Precise["default"].stringMul(maxValueEv, precisionString));
1143
1141
  }
1144
- result[code] = {
1142
+ result[code] = this.safeCurrencyStructure({
1145
1143
  'id': id,
1146
1144
  'info': currency,
1147
1145
  'code': code,
1148
- 'name': name,
1149
- 'active': status === 'Listed',
1146
+ 'name': this.safeString(currency, 'name'),
1147
+ 'active': this.safeString(currency, 'status') === 'Listed',
1150
1148
  'deposit': undefined,
1151
1149
  'withdraw': undefined,
1152
1150
  'fee': undefined,
@@ -1164,7 +1162,7 @@ class phemex extends phemex$1 {
1164
1162
  'valueScale': valueScale,
1165
1163
  'networks': undefined,
1166
1164
  'type': 'crypto',
1167
- };
1165
+ });
1168
1166
  }
1169
1167
  return result;
1170
1168
  }
@@ -306,6 +306,11 @@ class poloniex extends poloniex$1 {
306
306
  'BEP20': 'BSC',
307
307
  'ERC20': 'ETH',
308
308
  'TRC20': 'TRON',
309
+ 'TRX': 'TRON',
310
+ },
311
+ 'networksById': {
312
+ 'TRX': 'TRC20',
313
+ 'TRON': 'TRC20',
309
314
  },
310
315
  'limits': {
311
316
  'cost': {
@@ -1148,105 +1153,107 @@ class poloniex extends poloniex$1 {
1148
1153
  const response = await this.publicGetCurrencies(this.extend(params, { 'includeMultiChainCurrencies': true }));
1149
1154
  //
1150
1155
  // [
1151
- // {
1152
- // "1CR": {
1153
- // "id": 1,
1154
- // "name": "1CRedit",
1155
- // "description": "BTC Clone",
1156
- // "type": "address",
1157
- // "withdrawalFee": "0.01000000",
1158
- // "minConf": 10000,
1159
- // "depositAddress": null,
1160
- // "blockchain": "1CR",
1161
- // "delisted": false,
1162
- // "tradingState": "NORMAL",
1163
- // "walletState": "DISABLED",
1164
- // "walletDepositState": "DISABLED",
1165
- // "walletWithdrawalState": "DISABLED",
1166
- // "parentChain": null,
1167
- // "isMultiChain": false,
1168
- // "isChildChain": false,
1169
- // "childChains": []
1170
- // }
1171
- // }
1156
+ // {
1157
+ // "USDT": {
1158
+ // "id": 214,
1159
+ // "name": "Tether USD",
1160
+ // "description": "Sweep to Main Account",
1161
+ // "type": "address",
1162
+ // "withdrawalFee": "0.00000000",
1163
+ // "minConf": 2,
1164
+ // "depositAddress": null,
1165
+ // "blockchain": "OMNI",
1166
+ // "delisted": false,
1167
+ // "tradingState": "NORMAL",
1168
+ // "walletState": "DISABLED",
1169
+ // "walletDepositState": "DISABLED",
1170
+ // "walletWithdrawalState": "DISABLED",
1171
+ // "supportCollateral": true,
1172
+ // "supportBorrow": true,
1173
+ // "parentChain": null,
1174
+ // "isMultiChain": true,
1175
+ // "isChildChain": false,
1176
+ // "childChains": [
1177
+ // "USDTBSC",
1178
+ // "USDTETH",
1179
+ // "USDTSOL",
1180
+ // "USDTTRON"
1181
+ // ]
1182
+ // }
1183
+ // },
1184
+ // ...
1185
+ // {
1186
+ // "USDTBSC": {
1187
+ // "id": 582,
1188
+ // "name": "Binance-Peg BSC-USD",
1189
+ // "description": "Sweep to Main Account",
1190
+ // "type": "address",
1191
+ // "withdrawalFee": "0.00000000",
1192
+ // "minConf": 15,
1193
+ // "depositAddress": null,
1194
+ // "blockchain": "BSC",
1195
+ // "delisted": false,
1196
+ // "tradingState": "OFFLINE",
1197
+ // "walletState": "ENABLED",
1198
+ // "walletDepositState": "ENABLED",
1199
+ // "walletWithdrawalState": "DISABLED",
1200
+ // "supportCollateral": false,
1201
+ // "supportBorrow": false,
1202
+ // "parentChain": "USDT",
1203
+ // "isMultiChain": true,
1204
+ // "isChildChain": true,
1205
+ // "childChains": []
1206
+ // }
1207
+ // },
1208
+ // ...
1172
1209
  // ]
1173
1210
  //
1174
1211
  const result = {};
1212
+ // poloniex has a complicated structure of currencies, so we handle them differently
1213
+ // at first, turn the response into a normal dictionary
1214
+ const currenciesDict = {};
1175
1215
  for (let i = 0; i < response.length; i++) {
1176
- const item = this.safeValue(response, i);
1216
+ const item = this.safeDict(response, i);
1177
1217
  const ids = Object.keys(item);
1178
- const id = this.safeValue(ids, 0);
1179
- const currency = this.safeValue(item, id);
1218
+ const id = this.safeString(ids, 0);
1219
+ currenciesDict[id] = item[id];
1220
+ }
1221
+ const keys = Object.keys(currenciesDict);
1222
+ for (let i = 0; i < keys.length; i++) {
1223
+ const id = keys[i];
1224
+ const entry = currenciesDict[id];
1180
1225
  const code = this.safeCurrencyCode(id);
1181
- const name = this.safeString(currency, 'name');
1182
- const networkId = this.safeString(currency, 'blockchain');
1183
- let networkCode = undefined;
1184
- if (networkId !== undefined) {
1185
- networkCode = this.networkIdToCode(networkId, code);
1186
- }
1187
- const delisted = this.safeValue(currency, 'delisted');
1188
- const walletEnabled = this.safeString(currency, 'walletState') === 'ENABLED';
1189
- const depositEnabled = this.safeString(currency, 'walletDepositState') === 'ENABLED';
1190
- const withdrawEnabled = this.safeString(currency, 'walletWithdrawalState') === 'ENABLED';
1191
- const active = !delisted && walletEnabled && depositEnabled && withdrawEnabled;
1192
- const numericId = this.safeInteger(currency, 'id');
1193
- const feeString = this.safeString(currency, 'withdrawalFee');
1194
- const parentChain = this.safeValue(currency, 'parentChain');
1195
- const noParentChain = parentChain === undefined;
1196
- if (this.safeValue(result, code) === undefined) {
1197
- result[code] = {
1198
- 'id': id,
1199
- 'code': code,
1200
- 'info': undefined,
1201
- 'name': name,
1202
- 'active': active,
1203
- 'deposit': depositEnabled,
1204
- 'withdraw': withdrawEnabled,
1205
- 'fee': this.parseNumber(feeString),
1206
- 'precision': undefined,
1207
- 'type': 'crypto',
1208
- 'limits': {
1209
- 'amount': {
1210
- 'min': undefined,
1211
- 'max': undefined,
1212
- },
1213
- 'deposit': {
1214
- 'min': undefined,
1215
- 'max': undefined,
1216
- },
1217
- 'withdraw': {
1218
- 'min': undefined,
1219
- 'max': undefined,
1220
- },
1221
- },
1222
- };
1226
+ // skip childChains, as they are collected in parentChain loop
1227
+ if (this.safeBool(entry, 'isChildChain')) {
1228
+ continue;
1223
1229
  }
1224
- let minFeeString = this.safeString(result[code], 'fee');
1225
- if (feeString !== undefined) {
1226
- minFeeString = (minFeeString === undefined) ? feeString : Precise["default"].stringMin(feeString, minFeeString);
1230
+ const allChainEntries = [];
1231
+ const childChains = this.safeList(entry, 'childChains', []);
1232
+ if (childChains !== undefined) {
1233
+ for (let j = 0; j < childChains.length; j++) {
1234
+ const childChainId = childChains[j];
1235
+ const childNetworkEntry = this.safeDict(currenciesDict, childChainId);
1236
+ allChainEntries.push(childNetworkEntry);
1237
+ }
1227
1238
  }
1228
- let depositAvailable = this.safeValue(result[code], 'deposit');
1229
- depositAvailable = (depositEnabled) ? depositEnabled : depositAvailable;
1230
- let withdrawAvailable = this.safeValue(result[code], 'withdraw');
1231
- withdrawAvailable = (withdrawEnabled) ? withdrawEnabled : withdrawAvailable;
1232
- const networks = this.safeValue(result[code], 'networks', {});
1233
- if (networkCode !== undefined) {
1239
+ allChainEntries.push(entry);
1240
+ const networks = {};
1241
+ for (let j = 0; j < allChainEntries.length; j++) {
1242
+ const chainEntry = allChainEntries[j];
1243
+ const networkName = this.safeString(chainEntry, 'blockchain');
1244
+ const networkCode = this.networkIdToCode(networkName, code);
1245
+ const specialNetworkId = this.safeString(childChains, j, id); // in case it's primary chain, defeault to ID
1234
1246
  networks[networkCode] = {
1235
- 'info': currency,
1236
- 'id': networkId,
1247
+ 'info': chainEntry,
1248
+ 'id': specialNetworkId,
1249
+ 'numericId': this.safeInteger(chainEntry, 'id'),
1237
1250
  'network': networkCode,
1238
- 'currencyId': id,
1239
- 'numericId': numericId,
1240
- 'deposit': depositEnabled,
1241
- 'withdraw': withdrawEnabled,
1242
- 'active': active,
1243
- 'fee': this.parseNumber(feeString),
1251
+ 'active': this.safeBool(chainEntry, 'walletState'),
1252
+ 'deposit': this.safeString(chainEntry, 'walletDepositState') === 'ENABLED',
1253
+ 'withdraw': this.safeString(chainEntry, 'walletWithdrawalState') === 'ENABLED',
1254
+ 'fee': this.safeNumber(chainEntry, 'withdrawalFee'),
1244
1255
  'precision': undefined,
1245
1256
  'limits': {
1246
- 'amount': {
1247
- 'min': undefined,
1248
- 'max': undefined,
1249
- },
1250
1257
  'withdraw': {
1251
1258
  'min': undefined,
1252
1259
  'max': undefined,
@@ -1258,20 +1265,34 @@ class poloniex extends poloniex$1 {
1258
1265
  },
1259
1266
  };
1260
1267
  }
1261
- result[code]['networks'] = networks;
1262
- const info = this.safeValue(result[code], 'info', []);
1263
- const rawInfo = {};
1264
- rawInfo[id] = currency;
1265
- info.push(rawInfo);
1266
- result[code]['info'] = info;
1267
- if (noParentChain) {
1268
- result[code]['id'] = id;
1269
- result[code]['name'] = name;
1270
- }
1271
- result[code]['active'] = depositAvailable && withdrawAvailable;
1272
- result[code]['deposit'] = depositAvailable;
1273
- result[code]['withdraw'] = withdrawAvailable;
1274
- result[code]['fee'] = this.parseNumber(minFeeString);
1268
+ result[code] = this.safeCurrencyStructure({
1269
+ 'info': entry,
1270
+ 'code': code,
1271
+ 'id': id,
1272
+ 'numericId': this.safeInteger(entry, 'id'),
1273
+ 'type': 'crypto',
1274
+ 'name': this.safeString(entry, 'name'),
1275
+ 'active': undefined,
1276
+ 'deposit': undefined,
1277
+ 'withdraw': undefined,
1278
+ 'fee': undefined,
1279
+ 'precision': undefined,
1280
+ 'limits': {
1281
+ 'amount': {
1282
+ 'min': undefined,
1283
+ 'max': undefined,
1284
+ },
1285
+ 'withdraw': {
1286
+ 'min': undefined,
1287
+ 'max': undefined,
1288
+ },
1289
+ 'deposit': {
1290
+ 'min': undefined,
1291
+ 'max': undefined,
1292
+ },
1293
+ },
1294
+ 'networks': networks,
1295
+ });
1275
1296
  }
1276
1297
  return result;
1277
1298
  }
@@ -2666,45 +2687,15 @@ class poloniex extends poloniex$1 {
2666
2687
  */
2667
2688
  async createDepositAddress(code, params = {}) {
2668
2689
  await this.loadMarkets();
2669
- const currency = this.currency(code);
2670
- const request = {
2671
- 'currency': currency['id'],
2672
- };
2673
- const networks = this.safeValue(this.options, 'networks', {});
2674
- let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
2675
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
2676
- if (network !== undefined) {
2677
- 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
2678
- params = this.omit(params, 'network');
2679
- }
2680
- else {
2681
- if (currency['id'] === 'USDT') {
2682
- throw new errors.ArgumentsRequired(this.id + ' createDepositAddress requires a network parameter for ' + code + '.');
2683
- }
2684
- }
2690
+ const [request, extraParams, currency, networkEntry] = this.prepareRequestForDepositAddress(code, params);
2691
+ params = extraParams;
2685
2692
  const response = await this.privatePostWalletsAddress(this.extend(request, params));
2686
2693
  //
2687
2694
  // {
2688
2695
  // "address" : "0xfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf"
2689
2696
  // }
2690
2697
  //
2691
- let address = this.safeString(response, 'address');
2692
- let tag = undefined;
2693
- this.checkAddress(address);
2694
- if (currency !== undefined) {
2695
- const depositAddress = this.safeString(currency['info'], 'depositAddress');
2696
- if (depositAddress !== undefined) {
2697
- tag = address;
2698
- address = depositAddress;
2699
- }
2700
- }
2701
- return {
2702
- 'currency': code,
2703
- 'address': address,
2704
- 'tag': tag,
2705
- 'network': network,
2706
- 'info': response,
2707
- };
2698
+ return this.parseDepositAddressSpecial(response, currency, networkEntry);
2708
2699
  }
2709
2700
  /**
2710
2701
  * @method
@@ -2717,33 +2708,55 @@ class poloniex extends poloniex$1 {
2717
2708
  */
2718
2709
  async fetchDepositAddress(code, params = {}) {
2719
2710
  await this.loadMarkets();
2720
- const currency = this.currency(code);
2721
- const request = {
2722
- 'currency': currency['id'],
2723
- };
2724
- const networks = this.safeValue(this.options, 'networks', {});
2725
- let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
2726
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
2727
- if (network !== undefined) {
2728
- 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
2729
- params = this.omit(params, 'network');
2730
- }
2731
- else {
2732
- if (currency['id'] === 'USDT') {
2733
- throw new errors.ArgumentsRequired(this.id + ' fetchDepositAddress requires a network parameter for ' + code + '.');
2734
- }
2735
- }
2711
+ const [request, extraParams, currency, networkEntry] = this.prepareRequestForDepositAddress(code, params);
2712
+ params = extraParams;
2736
2713
  const response = await this.privateGetWalletsAddresses(this.extend(request, params));
2737
2714
  //
2738
2715
  // {
2739
2716
  // "USDTTRON" : "Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxp"
2740
2717
  // }
2741
2718
  //
2742
- let address = this.safeString(response, request['currency']);
2719
+ const keys = Object.keys(response);
2720
+ const length = keys.length;
2721
+ if (length < 1) {
2722
+ throw new errors.ExchangeError(this.id + ' fetchDepositAddress() returned an empty response, you might need to try "createDepositAddress" at first and then use "fetchDepositAddress"');
2723
+ }
2724
+ return this.parseDepositAddressSpecial(response, currency, networkEntry);
2725
+ }
2726
+ prepareRequestForDepositAddress(code, params = {}) {
2727
+ if (!(code in this.currencies)) {
2728
+ throw new errors.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" })');
2729
+ }
2730
+ const currency = this.currency(code);
2731
+ let networkCode = undefined;
2732
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
2733
+ if (networkCode === undefined) {
2734
+ // we need to know the network to find out the currency-junction
2735
+ throw new errors.ArgumentsRequired(this.id + ' fetchDepositAddress requires a network parameter for ' + code + '.');
2736
+ }
2737
+ let exchangeNetworkId = undefined;
2738
+ networkCode = this.networkIdToCode(networkCode, code);
2739
+ const networkEntry = this.safeDict(currency['networks'], networkCode);
2740
+ if (networkEntry !== undefined) {
2741
+ exchangeNetworkId = networkEntry['id'];
2742
+ }
2743
+ else {
2744
+ exchangeNetworkId = networkCode;
2745
+ }
2746
+ const request = {
2747
+ 'currency': exchangeNetworkId,
2748
+ };
2749
+ return [request, params, currency, networkEntry];
2750
+ }
2751
+ parseDepositAddressSpecial(response, currency, networkEntry) {
2752
+ let address = this.safeString(response, 'address');
2753
+ if (address === undefined) {
2754
+ address = this.safeString(response, networkEntry['id']);
2755
+ }
2743
2756
  let tag = undefined;
2744
2757
  this.checkAddress(address);
2745
- if (currency !== undefined) {
2746
- const depositAddress = this.safeString(currency['info'], 'depositAddress');
2758
+ if (networkEntry !== undefined) {
2759
+ const depositAddress = this.safeString(networkEntry['info'], 'depositAddress');
2747
2760
  if (depositAddress !== undefined) {
2748
2761
  tag = address;
2749
2762
  address = depositAddress;
@@ -2751,8 +2764,8 @@ class poloniex extends poloniex$1 {
2751
2764
  }
2752
2765
  return {
2753
2766
  'info': response,
2754
- 'currency': code,
2755
- 'network': network,
2767
+ 'currency': currency['code'],
2768
+ 'network': this.safeString(networkEntry, 'network'),
2756
2769
  'address': address,
2757
2770
  'tag': tag,
2758
2771
  };
@@ -2822,23 +2835,13 @@ class poloniex extends poloniex$1 {
2822
2835
  async withdraw(code, amount, address, tag = undefined, params = {}) {
2823
2836
  [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2824
2837
  this.checkAddress(address);
2825
- await this.loadMarkets();
2826
- const currency = this.currency(code);
2827
- const request = {
2828
- 'currency': currency['id'],
2829
- 'amount': amount,
2830
- 'address': address,
2831
- };
2838
+ const [request, extraParams, currency, networkEntry] = this.prepareRequestForDepositAddress(code, params);
2839
+ params = extraParams;
2840
+ request['amount'] = this.currencyToPrecision(code, amount);
2841
+ request['address'] = address;
2832
2842
  if (tag !== undefined) {
2833
2843
  request['paymentId'] = tag;
2834
2844
  }
2835
- const networks = this.safeValue(this.options, 'networks', {});
2836
- let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
2837
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
2838
- if (network !== undefined) {
2839
- 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
2840
- params = this.omit(params, 'network');
2841
- }
2842
2845
  const response = await this.privatePostWalletsWithdraw(this.extend(request, params));
2843
2846
  //
2844
2847
  // {
@@ -2847,7 +2850,11 @@ class poloniex extends poloniex$1 {
2847
2850
  // "withdrawalNumber": 13449869
2848
2851
  // }
2849
2852
  //
2850
- return this.parseTransaction(response, currency);
2853
+ const withdrawResponse = {
2854
+ 'response': response,
2855
+ 'withdrawNetworkEntry': networkEntry,
2856
+ };
2857
+ return this.parseTransaction(withdrawResponse, currency);
2851
2858
  }
2852
2859
  async fetchTransactionsHelper(code = undefined, since = undefined, limit = undefined, params = {}) {
2853
2860
  await this.loadMarkets();
@@ -3173,6 +3180,10 @@ class poloniex extends poloniex$1 {
3173
3180
  // "withdrawalRequestsId": 33485231
3174
3181
  // }
3175
3182
  //
3183
+ // if it's being parsed from "withdraw()" method, get the original response
3184
+ if ('withdrawNetworkEntry' in transaction) {
3185
+ transaction = transaction['response'];
3186
+ }
3176
3187
  const timestamp = this.safeTimestamp(transaction, 'timestamp');
3177
3188
  const currencyId = this.safeString(transaction, 'currency');
3178
3189
  const code = this.safeCurrencyCode(currencyId);
@@ -827,6 +827,7 @@ class binance extends binance$1 {
827
827
  orderbook.reset(snapshot);
828
828
  // unroll the accumulated deltas
829
829
  const messages = orderbook.cache;
830
+ orderbook.cache = [];
830
831
  for (let i = 0; i < messages.length; i++) {
831
832
  const messageItem = messages[i];
832
833
  const U = this.safeInteger(messageItem, 'U');