ccxt 4.4.57 → 4.4.59

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 (109) hide show
  1. package/README.md +29 -32
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -6
  4. package/dist/cjs/src/alpaca.js +1 -1
  5. package/dist/cjs/src/ascendex.js +2 -0
  6. package/dist/cjs/src/base/Exchange.js +4 -3
  7. package/dist/cjs/src/bigone.js +2 -2
  8. package/dist/cjs/src/binance.js +22 -3
  9. package/dist/cjs/src/bit2c.js +7 -7
  10. package/dist/cjs/src/bitget.js +7 -0
  11. package/dist/cjs/src/bitmart.js +161 -97
  12. package/dist/cjs/src/blofin.js +1 -2
  13. package/dist/cjs/src/bybit.js +16 -3
  14. package/dist/cjs/src/coinbase.js +9 -2
  15. package/dist/cjs/src/coinbaseinternational.js +1 -1
  16. package/dist/cjs/src/hitbtc.js +1 -1
  17. package/dist/cjs/src/hyperliquid.js +96 -4
  18. package/dist/cjs/src/pro/binanceus.js +1 -1
  19. package/dist/cjs/src/pro/bybit.js +6 -1
  20. package/dist/cjs/src/pro/mexc.js +4 -1
  21. package/dist/cjs/src/timex.js +15 -2
  22. package/dist/cjs/src/vertex.js +2 -2
  23. package/dist/cjs/src/whitebit.js +2 -1
  24. package/dist/cjs/src/xt.js +62 -3
  25. package/js/ccxt.d.ts +2 -8
  26. package/js/ccxt.js +2 -6
  27. package/js/src/abstract/xt.d.ts +1 -0
  28. package/js/src/alpaca.d.ts +1 -1
  29. package/js/src/alpaca.js +1 -1
  30. package/js/src/ascendex.d.ts +1 -1
  31. package/js/src/ascendex.js +2 -0
  32. package/js/src/base/Exchange.d.ts +1 -331
  33. package/js/src/base/Exchange.js +4 -3
  34. package/js/src/base/types.d.ts +2 -2
  35. package/js/src/bigone.d.ts +1 -1
  36. package/js/src/bigone.js +2 -2
  37. package/js/src/binance.d.ts +1 -1
  38. package/js/src/binance.js +22 -3
  39. package/js/src/bingx.d.ts +1 -1
  40. package/js/src/bit2c.js +7 -7
  41. package/js/src/bitget.d.ts +1 -1
  42. package/js/src/bitget.js +7 -0
  43. package/js/src/bitmart.d.ts +5 -1
  44. package/js/src/bitmart.js +161 -97
  45. package/js/src/bitrue.d.ts +1 -1
  46. package/js/src/bitvavo.d.ts +1 -1
  47. package/js/src/blofin.js +1 -2
  48. package/js/src/btcmarkets.d.ts +1 -1
  49. package/js/src/bybit.d.ts +1 -1
  50. package/js/src/bybit.js +16 -3
  51. package/js/src/cex.d.ts +1 -1
  52. package/js/src/coinbase.d.ts +1 -1
  53. package/js/src/coinbase.js +9 -2
  54. package/js/src/coinbaseexchange.d.ts +2 -2
  55. package/js/src/coinbaseinternational.js +1 -1
  56. package/js/src/coincatch.d.ts +1 -1
  57. package/js/src/coinex.d.ts +1 -1
  58. package/js/src/coinlist.d.ts +1 -1
  59. package/js/src/coinsph.d.ts +1 -1
  60. package/js/src/currencycom.d.ts +1 -1
  61. package/js/src/defx.d.ts +1 -1
  62. package/js/src/delta.d.ts +1 -1
  63. package/js/src/deribit.d.ts +1 -1
  64. package/js/src/digifinex.d.ts +1 -1
  65. package/js/src/gate.d.ts +1 -1
  66. package/js/src/hitbtc.js +1 -1
  67. package/js/src/htx.d.ts +1 -1
  68. package/js/src/huobijp.d.ts +1 -1
  69. package/js/src/hyperliquid.d.ts +21 -0
  70. package/js/src/hyperliquid.js +96 -4
  71. package/js/src/idex.d.ts +1 -1
  72. package/js/src/indodax.d.ts +1 -1
  73. package/js/src/kraken.d.ts +1 -1
  74. package/js/src/kucoin.d.ts +1 -1
  75. package/js/src/kucoinfutures.d.ts +1 -1
  76. package/js/src/kuna.d.ts +1 -1
  77. package/js/src/latoken.d.ts +1 -1
  78. package/js/src/lbank.d.ts +1 -1
  79. package/js/src/mexc.d.ts +1 -1
  80. package/js/src/novadax.d.ts +1 -1
  81. package/js/src/oceanex.d.ts +1 -1
  82. package/js/src/okcoin.d.ts +1 -1
  83. package/js/src/okx.d.ts +1 -1
  84. package/js/src/onetrading.d.ts +1 -1
  85. package/js/src/paradex.d.ts +1 -1
  86. package/js/src/poloniex.d.ts +1 -1
  87. package/js/src/poloniexfutures.d.ts +1 -1
  88. package/js/src/pro/binanceus.js +1 -1
  89. package/js/src/pro/bybit.js +6 -1
  90. package/js/src/pro/mexc.js +4 -1
  91. package/js/src/probit.d.ts +1 -1
  92. package/js/src/timex.d.ts +2 -1
  93. package/js/src/timex.js +15 -2
  94. package/js/src/tokocrypto.d.ts +1 -1
  95. package/js/src/vertex.d.ts +1 -1
  96. package/js/src/vertex.js +2 -2
  97. package/js/src/whitebit.d.ts +1 -1
  98. package/js/src/whitebit.js +2 -1
  99. package/js/src/woo.d.ts +1 -1
  100. package/js/src/woofipro.d.ts +1 -1
  101. package/js/src/xt.d.ts +13 -1
  102. package/js/src/xt.js +62 -3
  103. package/package.json +1 -1
  104. package/js/src/bitbay.d.ts +0 -4
  105. package/js/src/bitbay.js +0 -18
  106. package/js/src/bitfinex2.d.ts +0 -506
  107. package/js/src/bitfinex2.js +0 -3778
  108. package/js/src/wazirx.d.ts +0 -216
  109. package/js/src/wazirx.js +0 -1368
package/js/src/bitmart.js CHANGED
@@ -512,7 +512,10 @@ export default class bitmart extends Exchange {
512
512
  '40049': InvalidOrder,
513
513
  '40050': InvalidOrder, // 403, Client OrderId duplicated with existing orders
514
514
  },
515
- 'broad': {},
515
+ 'broad': {
516
+ 'You contract account available balance not enough': InsufficientFunds,
517
+ 'you contract account available balance not enough': InsufficientFunds,
518
+ },
516
519
  },
517
520
  'commonCurrencies': {
518
521
  '$GM': 'GOLDMINER',
@@ -525,9 +528,10 @@ export default class bitmart extends Exchange {
525
528
  'TRU': 'Truebit', // conflict with TrueFi
526
529
  },
527
530
  'options': {
528
- 'defaultNetwork': 'ERC20',
529
531
  'defaultNetworks': {
530
- 'USDT': 'ERC20',
532
+ 'USDT': 'TRC20',
533
+ 'BTC': 'BTC',
534
+ 'ETH': 'ERC20',
531
535
  },
532
536
  'timeDifference': 0,
533
537
  'adjustForTimeDifference': false,
@@ -569,7 +573,7 @@ export default class bitmart extends Exchange {
569
573
  'KSM': 'KSM',
570
574
  'ZEC': 'ZEC',
571
575
  'NAS': 'NAS',
572
- // 'POLYGON': [ 'MATIC', 'Polygon', 'POLYGON' ], // todo: after unification
576
+ 'POLYGON': 'MATIC',
573
577
  'HRC20': 'HECO',
574
578
  'XDC': 'XDC',
575
579
  'ONE': 'ONE',
@@ -578,7 +582,7 @@ export default class bitmart extends Exchange {
578
582
  'ICP': 'Computer',
579
583
  'XTZ': 'XTZ',
580
584
  'MINA': 'MINA',
581
- // 'BEP20': [ 'BEP20', 'BSC_BNB', 'bep20' ], // todo: after unification
585
+ 'BEP20': 'BSC_BNB',
582
586
  'THETA': 'THETA',
583
587
  'AKT': 'AKT',
584
588
  'AR': 'AR',
@@ -682,6 +686,12 @@ export default class bitmart extends Exchange {
682
686
  // undetermined chains:
683
687
  // LEX (for LexThum), TAYCAN (for TRICE), SFL (probably TAYCAN), OMNIA (for APEX), NAC (for NAC), KAG (Kinesis), CEM (crypto emergency), XVM (for Venidium), NEVM (for NEVM), IGT20 (for IGNITE), FILM (FILMCredits), CC (CloudCoin), MERGE (MERGE), LTNM (Bitcoin latinum), PLUGCN ( PlugChain), DINGO (dingo), LED (LEDGIS), AVAT (AVAT), VSOL (Vsolidus), EPIC (EPIC cash), NFC (netflowcoin), mrx (Metrix Coin), Idena (idena network), PKT (PKT Cash), BondDex (BondDex), XBN (XBN), KALAM (Kalamint), REV (RChain), KRC20 (MyDeFiPet), ARC20 (Hurricane Token), GMD (Coop network), BERS (Berith), ZEBI (Zebi), BRC (Baer Chain), DAPS (DAPS Coin), APL (Gold Secured Currency), NDAU (NDAU), WICC (WICC), UPG (Unipay God), TSL (TreasureSL), MXW (Maxonrow), CLC (Cifculation), SMH (SMH Coin), XIN (CPCoin), RDD (ReddCoin), OK (Okcash), KAR (KAR), CCX (ConcealNetwork),
684
688
  },
689
+ 'networksById': {
690
+ 'ETH': 'ERC20',
691
+ 'Ethereum': 'ERC20',
692
+ 'USDT': 'OMNI',
693
+ 'Bitcoin': 'BTC',
694
+ },
685
695
  'defaultType': 'spot',
686
696
  'fetchBalance': {
687
697
  'type': 'spot', // 'spot', 'swap', 'account'
@@ -960,6 +970,7 @@ export default class bitmart extends Exchange {
960
970
  const data = this.safeDict(response, 'data', {});
961
971
  const symbols = this.safeList(data, 'symbols', []);
962
972
  const result = [];
973
+ const fees = this.fees['trading'];
963
974
  for (let i = 0; i < symbols.length; i++) {
964
975
  const market = symbols[i];
965
976
  const id = this.safeString(market, 'symbol');
@@ -998,6 +1009,8 @@ export default class bitmart extends Exchange {
998
1009
  'expiryDatetime': undefined,
999
1010
  'strike': undefined,
1000
1011
  'optionType': undefined,
1012
+ 'maker': fees['maker'],
1013
+ 'taker': fees['taker'],
1001
1014
  'precision': {
1002
1015
  'amount': baseMinSize,
1003
1016
  'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'price_max_precision'))),
@@ -1070,6 +1083,7 @@ export default class bitmart extends Exchange {
1070
1083
  const data = this.safeDict(response, 'data', {});
1071
1084
  const symbols = this.safeList(data, 'symbols', []);
1072
1085
  const result = [];
1086
+ const fees = this.fees['trading'];
1073
1087
  for (let i = 0; i < symbols.length; i++) {
1074
1088
  const market = symbols[i];
1075
1089
  const id = this.safeString(market, 'symbol');
@@ -1112,6 +1126,8 @@ export default class bitmart extends Exchange {
1112
1126
  'expiryDatetime': this.iso8601(expiry),
1113
1127
  'strike': undefined,
1114
1128
  'optionType': undefined,
1129
+ 'maker': fees['maker'],
1130
+ 'taker': fees['taker'],
1115
1131
  'precision': {
1116
1132
  'amount': this.safeNumber(market, 'vol_precision'),
1117
1133
  'price': this.safeNumber(market, 'price_precision'),
@@ -1164,17 +1180,24 @@ export default class bitmart extends Exchange {
1164
1180
  * @returns {object} an associative dictionary of currencies
1165
1181
  */
1166
1182
  async fetchCurrencies(params = {}) {
1167
- const response = await this.publicGetSpotV1Currencies(params);
1183
+ const response = await this.publicGetAccountV1Currencies(params);
1168
1184
  //
1169
1185
  // {
1170
- // "message":"OK",
1186
+ // "message": "OK",
1171
1187
  // "code":1000,
1172
- // "trace":"8c768b3c-025f-413f-bec5-6d6411d46883",
1173
- // "data":{
1174
- // "currencies":[
1175
- // {"currency":"MATIC","name":"Matic Network","withdraw_enabled":true,"deposit_enabled":true},
1176
- // {"currency":"KTN","name":"Kasoutuuka News","withdraw_enabled":true,"deposit_enabled":false},
1177
- // {"currency":"BRT","name":"Berith","withdraw_enabled":true,"deposit_enabled":true},
1188
+ // "trace": "9eaec51cd80d46d48a1c6b447206c4d6.71.17392193317851454",
1189
+ // "data": {
1190
+ // "currencies": [
1191
+ // {
1192
+ // "currency": "BTC",
1193
+ // "name": "Bitcoin",
1194
+ // "contract_address": null,
1195
+ // "network": "BTC",
1196
+ // "withdraw_enabled": true,
1197
+ // "deposit_enabled": true,
1198
+ // "withdraw_minsize": "0.0003",
1199
+ // "withdraw_minfee": "9.74"
1200
+ // }
1178
1201
  // ]
1179
1202
  // }
1180
1203
  // }
@@ -1184,30 +1207,99 @@ export default class bitmart extends Exchange {
1184
1207
  const result = {};
1185
1208
  for (let i = 0; i < currencies.length; i++) {
1186
1209
  const currency = currencies[i];
1187
- const id = this.safeString(currency, 'id');
1188
- const code = this.safeCurrencyCode(id);
1189
- const name = this.safeString(currency, 'name');
1190
- const withdrawEnabled = this.safeBool(currency, 'withdraw_enabled');
1191
- const depositEnabled = this.safeBool(currency, 'deposit_enabled');
1192
- const active = withdrawEnabled && depositEnabled;
1193
- result[code] = {
1194
- 'id': id,
1195
- 'code': code,
1196
- 'name': name,
1210
+ const fullId = this.safeString(currency, 'currency');
1211
+ let currencyId = fullId;
1212
+ let networkId = this.safeString(currency, 'network');
1213
+ if (fullId.indexOf('NFT') < 0) {
1214
+ const parts = fullId.split('-');
1215
+ currencyId = this.safeString(parts, 0);
1216
+ const second = this.safeString(parts, 1);
1217
+ if (second !== undefined) {
1218
+ networkId = second.toUpperCase();
1219
+ }
1220
+ }
1221
+ const currencyCode = this.safeCurrencyCode(currencyId);
1222
+ let entry = this.safeDict(result, currencyCode);
1223
+ if (entry === undefined) {
1224
+ entry = {
1225
+ 'info': currency,
1226
+ 'id': currencyId,
1227
+ 'code': currencyCode,
1228
+ 'precision': undefined,
1229
+ 'name': this.safeString(currency, 'name'),
1230
+ 'deposit': undefined,
1231
+ 'withdraw': undefined,
1232
+ 'active': undefined,
1233
+ 'networks': {},
1234
+ };
1235
+ }
1236
+ const networkCode = this.networkIdToCode(networkId);
1237
+ const withdraw = this.safeBool(currency, 'withdraw_enabled');
1238
+ const deposit = this.safeBool(currency, 'deposit_enabled');
1239
+ entry['networks'][networkCode] = {
1197
1240
  'info': currency,
1198
- 'active': active,
1199
- 'deposit': depositEnabled,
1200
- 'withdraw': withdrawEnabled,
1201
- 'fee': undefined,
1202
- 'precision': undefined,
1241
+ 'id': networkId,
1242
+ 'code': networkCode,
1243
+ 'withdraw': withdraw,
1244
+ 'deposit': deposit,
1245
+ 'active': withdraw && deposit,
1246
+ 'fee': this.safeNumber(currency, 'withdraw_minfee'),
1203
1247
  'limits': {
1204
- 'amount': { 'min': undefined, 'max': undefined },
1205
- 'withdraw': { 'min': undefined, 'max': undefined },
1248
+ 'withdraw': {
1249
+ 'min': this.safeNumber(currency, 'withdraw_minsize'),
1250
+ 'max': undefined,
1251
+ },
1252
+ 'deposit': {
1253
+ 'min': undefined,
1254
+ 'max': undefined,
1255
+ },
1206
1256
  },
1207
1257
  };
1258
+ result[currencyCode] = entry;
1259
+ }
1260
+ const keys = Object.keys(result);
1261
+ for (let i = 0; i < keys.length; i++) {
1262
+ const key = keys[i];
1263
+ const currency = result[key];
1264
+ result[key] = this.safeCurrencyStructure(currency);
1208
1265
  }
1209
1266
  return result;
1210
1267
  }
1268
+ getCurrencyIdFromCodeAndNetwork(currencyCode, networkCode) {
1269
+ if (networkCode === undefined) {
1270
+ networkCode = this.defaultNetworkCode(currencyCode); // use default network code if not provided
1271
+ }
1272
+ const currency = this.currency(currencyCode);
1273
+ let id = currency['id'];
1274
+ let idFromNetwork = undefined;
1275
+ const networks = this.safeDict(currency, 'networks', {});
1276
+ let networkInfo = {};
1277
+ if (networkCode === undefined) {
1278
+ // network code is not provided and there is no default network code
1279
+ let network = this.safeDict(networks, currencyCode); // trying to find network that has the same code as currency
1280
+ if (network === undefined) {
1281
+ // use the first network in the networks list if there is no network code with the same code as currency
1282
+ const keys = Object.keys(networks);
1283
+ const length = keys.length;
1284
+ if (length > 0) {
1285
+ network = this.safeValue(networks, keys[0]);
1286
+ }
1287
+ }
1288
+ networkInfo = this.safeDict(network, 'info', {});
1289
+ idFromNetwork = this.safeString(networkInfo, 'currency'); // use currency name from network
1290
+ }
1291
+ else {
1292
+ const providedOrDefaultNetwork = this.safeDict(networks, networkCode);
1293
+ if (providedOrDefaultNetwork !== undefined) {
1294
+ networkInfo = this.safeDict(providedOrDefaultNetwork, 'info', {});
1295
+ idFromNetwork = this.safeString(networkInfo, 'currency'); // use currency name from network
1296
+ }
1297
+ else {
1298
+ id += '-' + this.networkCodeToId(networkCode, currencyCode); // use concatenated currency id and network code if network is not found
1299
+ }
1300
+ }
1301
+ return (idFromNetwork !== undefined) ? idFromNetwork : id;
1302
+ }
1211
1303
  /**
1212
1304
  * @method
1213
1305
  * @name bitmart#fetchTransactionFee
@@ -1215,13 +1307,16 @@ export default class bitmart extends Exchange {
1215
1307
  * @description please use fetchDepositWithdrawFee instead
1216
1308
  * @param {string} code unified currency code
1217
1309
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1310
+ * @param {string} [params.network] the network code of the currency
1218
1311
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
1219
1312
  */
1220
1313
  async fetchTransactionFee(code, params = {}) {
1221
1314
  await this.loadMarkets();
1222
1315
  const currency = this.currency(code);
1316
+ let network = undefined;
1317
+ [network, params] = this.handleNetworkCodeAndParams(params);
1223
1318
  const request = {
1224
- 'currency': currency['id'],
1319
+ 'currency': this.getCurrencyIdFromCodeAndNetwork(currency['code'], network),
1225
1320
  };
1226
1321
  const response = await this.privateGetAccountV1WithdrawCharge(this.extend(request, params));
1227
1322
  //
@@ -1274,13 +1369,15 @@ export default class bitmart extends Exchange {
1274
1369
  * @description fetch the fee for deposits and withdrawals
1275
1370
  * @param {string} code unified currency code
1276
1371
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1372
+ * @param {string} [params.network] the network code of the currency
1277
1373
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
1278
1374
  */
1279
1375
  async fetchDepositWithdrawFee(code, params = {}) {
1280
1376
  await this.loadMarkets();
1281
- const currency = this.currency(code);
1377
+ let network = undefined;
1378
+ [network, params] = this.handleNetworkCodeAndParams(params);
1282
1379
  const request = {
1283
- 'currency': currency['id'],
1380
+ 'currency': this.getCurrencyIdFromCodeAndNetwork(code, network),
1284
1381
  };
1285
1382
  const response = await this.privateGetAccountV1WithdrawCharge(this.extend(request, params));
1286
1383
  //
@@ -3607,28 +3704,11 @@ export default class bitmart extends Exchange {
3607
3704
  async fetchDepositAddress(code, params = {}) {
3608
3705
  await this.loadMarkets();
3609
3706
  const currency = this.currency(code);
3610
- const currencyId = currency['id'];
3707
+ let network = undefined;
3708
+ [network, params] = this.handleNetworkCodeAndParams(params);
3611
3709
  const request = {
3612
- 'currency': currencyId,
3710
+ 'currency': this.getCurrencyIdFromCodeAndNetwork(code, network),
3613
3711
  };
3614
- if (code === 'USDT') {
3615
- const defaultNetworks = this.safeValue(this.options, 'defaultNetworks');
3616
- const defaultNetwork = this.safeStringUpper(defaultNetworks, code);
3617
- const networks = this.safeDict(this.options, 'networks', {});
3618
- let networkInner = this.safeStringUpper(params, 'network', defaultNetwork); // this line allows the user to specify either ERC20 or ETH
3619
- networkInner = this.safeString(networks, networkInner, networkInner); // handle ERC20>ETH alias
3620
- if (networkInner !== undefined) {
3621
- request['currency'] = currencyId + '-' + networkInner; // when network the currency need to be changed to currency + '-' + network https://developer-pro.bitmart.com/en/account/withdraw_apply.html on the end of page
3622
- params = this.omit(params, 'network');
3623
- }
3624
- }
3625
- else {
3626
- let networkCode = undefined;
3627
- [networkCode, params] = this.handleNetworkCodeAndParams(params);
3628
- if (networkCode !== undefined) {
3629
- request['currency'] = currencyId + '-' + this.networkCodeToId(networkCode);
3630
- }
3631
- }
3632
3712
  const response = await this.privateGetAccountV1DepositAddress(this.extend(request, params));
3633
3713
  //
3634
3714
  // {
@@ -3655,27 +3735,23 @@ export default class bitmart extends Exchange {
3655
3735
  // address_memo: ''
3656
3736
  // }
3657
3737
  //
3658
- const currencyId = this.safeString(depositAddress, 'currency');
3659
- const address = this.safeString(depositAddress, 'address');
3660
- const chain = this.safeString(depositAddress, 'chain');
3661
- let network = undefined;
3662
- currency = this.safeCurrency(currencyId, currency);
3663
- if (chain !== undefined) {
3664
- const parts = chain.split('-');
3665
- const partsLength = parts.length;
3666
- const networkId = this.safeString(parts, partsLength - 1);
3667
- if (networkId === this.safeString(currency, 'name')) {
3668
- network = this.safeString(currency, 'code');
3669
- }
3670
- else {
3671
- network = this.networkIdToCode(networkId);
3738
+ let currencyId = this.safeString(depositAddress, 'currency');
3739
+ let network = this.safeString(depositAddress, 'chain');
3740
+ if (currencyId.indexOf('NFT') < 0) {
3741
+ const parts = currencyId.split('-');
3742
+ currencyId = this.safeString(parts, 0);
3743
+ const secondPart = this.safeString(parts, 1);
3744
+ if (secondPart !== undefined) {
3745
+ network = secondPart;
3672
3746
  }
3673
3747
  }
3748
+ const address = this.safeString(depositAddress, 'address');
3749
+ currency = this.safeCurrency(currencyId, currency);
3674
3750
  this.checkAddress(address);
3675
3751
  return {
3676
3752
  'info': depositAddress,
3677
3753
  'currency': this.safeString(currency, 'code'),
3678
- 'network': network,
3754
+ 'network': this.networkIdToCode(network),
3679
3755
  'address': address,
3680
3756
  'tag': this.safeString(depositAddress, 'address_memo'),
3681
3757
  };
@@ -3689,6 +3765,7 @@ export default class bitmart extends Exchange {
3689
3765
  * @param {string} address the address to withdraw to
3690
3766
  * @param {string} tag
3691
3767
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3768
+ * @param {string} [params.network] the network name for this withdrawal
3692
3769
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3693
3770
  */
3694
3771
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -3696,8 +3773,10 @@ export default class bitmart extends Exchange {
3696
3773
  this.checkAddress(address);
3697
3774
  await this.loadMarkets();
3698
3775
  const currency = this.currency(code);
3776
+ let network = undefined;
3777
+ [network, params] = this.handleNetworkCodeAndParams(params);
3699
3778
  const request = {
3700
- 'currency': currency['id'],
3779
+ 'currency': this.getCurrencyIdFromCodeAndNetwork(code, network),
3701
3780
  'amount': amount,
3702
3781
  'destination': 'To Digital Address',
3703
3782
  'address': address,
@@ -3705,17 +3784,6 @@ export default class bitmart extends Exchange {
3705
3784
  if (tag !== undefined) {
3706
3785
  request['address_memo'] = tag;
3707
3786
  }
3708
- if (code === 'USDT') {
3709
- const defaultNetworks = this.safeValue(this.options, 'defaultNetworks');
3710
- const defaultNetwork = this.safeStringUpper(defaultNetworks, code);
3711
- const networks = this.safeDict(this.options, 'networks', {});
3712
- let network = this.safeStringUpper(params, 'network', defaultNetwork); // this line allows the user to specify either ERC20 or ETH
3713
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
3714
- if (network !== undefined) {
3715
- request['currency'] = request['currency'] + '-' + network; // when network the currency need to be changed to currency + '-' + network https://developer-pro.bitmart.com/en/account/withdraw_apply.html on the end of page
3716
- params = this.omit(params, 'network');
3717
- }
3718
- }
3719
3787
  const response = await this.privatePostAccountV1WithdrawApply(this.extend(request, params));
3720
3788
  //
3721
3789
  // {
@@ -3750,18 +3818,6 @@ export default class bitmart extends Exchange {
3750
3818
  currency = this.currency(code);
3751
3819
  request['currency'] = currency['id'];
3752
3820
  }
3753
- if (code === 'USDT') {
3754
- const defaultNetworks = this.safeValue(this.options, 'defaultNetworks');
3755
- const defaultNetwork = this.safeStringUpper(defaultNetworks, code);
3756
- const networks = this.safeDict(this.options, 'networks', {});
3757
- let network = this.safeStringUpper(params, 'network', defaultNetwork); // this line allows the user to specify either ERC20 or ETH
3758
- network = this.safeString(networks, network, network); // handle ERC20>ETH alias
3759
- if (network !== undefined) {
3760
- request['currency'] = request['currency'] + '-' + network; // when network the currency need to be changed to currency + '-' + network https://developer-pro.bitmart.com/en/account/withdraw_apply.html on the end of page
3761
- currency['code'] = request['currency']; // update currency code to filter
3762
- params = this.omit(params, 'network');
3763
- }
3764
- }
3765
3821
  const response = await this.privateGetAccountV2DepositWithdrawHistory(this.extend(request, params));
3766
3822
  //
3767
3823
  // {
@@ -3948,7 +4004,13 @@ export default class bitmart extends Exchange {
3948
4004
  }
3949
4005
  const amount = this.safeNumber(transaction, 'arrival_amount');
3950
4006
  const timestamp = this.safeInteger(transaction, 'apply_time');
3951
- const currencyId = this.safeString(transaction, 'currency');
4007
+ let currencyId = this.safeString(transaction, 'currency');
4008
+ let networkId = undefined;
4009
+ if (currencyId.indexOf('NFT') < 0) {
4010
+ const parts = currencyId.split('-');
4011
+ currencyId = this.safeString(parts, 0);
4012
+ networkId = this.safeString(parts, 1);
4013
+ }
3952
4014
  const code = this.safeCurrencyCode(currencyId, currency);
3953
4015
  const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
3954
4016
  const feeCost = this.safeNumber(transaction, 'fee');
@@ -3967,7 +4029,7 @@ export default class bitmart extends Exchange {
3967
4029
  'id': id,
3968
4030
  'currency': code,
3969
4031
  'amount': amount,
3970
- 'network': undefined,
4032
+ 'network': this.networkIdToCode(networkId),
3971
4033
  'address': address,
3972
4034
  'addressFrom': undefined,
3973
4035
  'addressTo': undefined,
@@ -5193,6 +5255,7 @@ export default class bitmart extends Exchange {
5193
5255
  direction = 'in';
5194
5256
  }
5195
5257
  const currencyId = this.safeString(item, 'asset');
5258
+ currency = this.safeCurrency(currencyId, currency);
5196
5259
  const timestamp = this.safeInteger(item, 'time');
5197
5260
  const type = this.safeString(item, 'type');
5198
5261
  return this.safeLedgerEntry({
@@ -5203,7 +5266,7 @@ export default class bitmart extends Exchange {
5203
5266
  'referenceAccount': undefined,
5204
5267
  'referenceId': this.safeString(item, 'tradeId'),
5205
5268
  'type': this.parseLedgerEntryType(type),
5206
- 'currency': this.safeCurrencyCode(currencyId, currency),
5269
+ 'currency': currency['code'],
5207
5270
  'amount': this.parseNumber(amount),
5208
5271
  'timestamp': timestamp,
5209
5272
  'datetime': this.iso8601(timestamp),
@@ -5369,6 +5432,7 @@ export default class bitmart extends Exchange {
5369
5432
  // {"message":"Bad Request [from is empty]","code":50000,"trace":"579986f7-c93a-4559-926b-06ba9fa79d76","data":{}}
5370
5433
  // {"message":"Kline size over 500","code":50004,"trace":"d625caa8-e8ca-4bd2-b77c-958776965819","data":{}}
5371
5434
  // {"message":"Balance not enough","code":50020,"trace":"7c709d6a-3292-462c-98c5-32362540aeef","data":{}}
5435
+ // {"code":40012,"message":"You contract account available balance not enough.","trace":"..."}
5372
5436
  //
5373
5437
  // contract
5374
5438
  //
@@ -5380,10 +5444,10 @@ export default class bitmart extends Exchange {
5380
5444
  const isErrorCode = (errorCode !== undefined) && (errorCode !== '1000');
5381
5445
  if (isErrorCode || isErrorMessage) {
5382
5446
  const feedback = this.id + ' ' + body;
5383
- this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
5384
- this.throwBroadlyMatchedException(this.exceptions['broad'], errorCode, feedback);
5385
5447
  this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
5386
5448
  this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
5449
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
5450
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorCode, feedback);
5387
5451
  throw new ExchangeError(feedback); // unknown message
5388
5452
  }
5389
5453
  return undefined;
@@ -30,7 +30,7 @@ export default class bitrue extends Exchange {
30
30
  * @param {object} [params] extra parameters specific to the exchange API endpoint
31
31
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
32
32
  */
33
- fetchTime(params?: {}): Promise<number>;
33
+ fetchTime(params?: {}): Promise<Int>;
34
34
  /**
35
35
  * @method
36
36
  * @name bitrue#fetchCurrencies
@@ -15,7 +15,7 @@ export default class bitvavo extends Exchange {
15
15
  * @param {object} [params] extra parameters specific to the exchange API endpoint
16
16
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
17
17
  */
18
- fetchTime(params?: {}): Promise<number>;
18
+ fetchTime(params?: {}): Promise<Int>;
19
19
  /**
20
20
  * @method
21
21
  * @name bitvavo#fetchMarkets
package/js/src/blofin.js CHANGED
@@ -322,8 +322,7 @@ export default class blofin extends Exchange {
322
322
  'takeProfitPrice': true,
323
323
  'attachedStopLossTakeProfit': {
324
324
  'triggerPriceType': undefined,
325
- 'limit': true,
326
- 'price': undefined,
325
+ 'price': true,
327
326
  },
328
327
  'hedged': true,
329
328
  },
@@ -64,7 +64,7 @@ export default class btcmarkets extends Exchange {
64
64
  * @param {object} [params] extra parameters specific to the exchange API endpoint
65
65
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
66
66
  */
67
- fetchTime(params?: {}): Promise<number>;
67
+ fetchTime(params?: {}): Promise<Int>;
68
68
  parseBalance(response: any): Balances;
69
69
  /**
70
70
  * @method
package/js/src/bybit.d.ts CHANGED
@@ -42,7 +42,7 @@ export default class bybit extends Exchange {
42
42
  * @param {object} [params] extra parameters specific to the exchange API endpoint
43
43
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
44
44
  */
45
- fetchTime(params?: {}): Promise<number>;
45
+ fetchTime(params?: {}): Promise<Int>;
46
46
  /**
47
47
  * @method
48
48
  * @name bybit#fetchCurrencies
package/js/src/bybit.js CHANGED
@@ -1414,8 +1414,8 @@ export default class bybit extends Exchange {
1414
1414
  }
1415
1415
  createExpiredOptionMarket(symbol) {
1416
1416
  // support expired option contracts
1417
- const quote = 'USD';
1418
- const settle = 'USDC';
1417
+ let quote = undefined;
1418
+ let settle = undefined;
1419
1419
  const optionParts = symbol.split('-');
1420
1420
  const symbolBase = symbol.split('/');
1421
1421
  let base = undefined;
@@ -1423,10 +1423,23 @@ export default class bybit extends Exchange {
1423
1423
  if (symbol.indexOf('/') > -1) {
1424
1424
  base = this.safeString(symbolBase, 0);
1425
1425
  expiry = this.safeString(optionParts, 1);
1426
+ const symbolQuoteAndSettle = this.safeString(symbolBase, 1);
1427
+ const splitQuote = symbolQuoteAndSettle.split(':');
1428
+ const quoteAndSettle = this.safeString(splitQuote, 0);
1429
+ quote = quoteAndSettle;
1430
+ settle = quoteAndSettle;
1426
1431
  }
1427
1432
  else {
1428
1433
  base = this.safeString(optionParts, 0);
1429
1434
  expiry = this.convertMarketIdExpireDate(this.safeString(optionParts, 1));
1435
+ if (symbol.endsWith('-USDT')) {
1436
+ quote = 'USDT';
1437
+ settle = 'USDT';
1438
+ }
1439
+ else {
1440
+ quote = 'USDC';
1441
+ settle = 'USDC';
1442
+ }
1430
1443
  }
1431
1444
  const strike = this.safeString(optionParts, 2);
1432
1445
  const optionType = this.safeString(optionParts, 3);
@@ -4097,7 +4110,7 @@ export default class bybit extends Exchange {
4097
4110
  request['qty'] = this.getCost(symbol, Precise.stringMul(amountString, priceString));
4098
4111
  }
4099
4112
  else {
4100
- request['qty'] = this.getCost(symbol, this.numberToString(amount));
4113
+ request['qty'] = amountString;
4101
4114
  }
4102
4115
  }
4103
4116
  }
package/js/src/cex.d.ts CHANGED
@@ -33,7 +33,7 @@ export default class cex extends Exchange {
33
33
  * @param {object} [params] extra parameters specific to the exchange API endpoint
34
34
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
35
35
  */
36
- fetchTime(params?: {}): Promise<number>;
36
+ fetchTime(params?: {}): Promise<Int>;
37
37
  /**
38
38
  * @method
39
39
  * @name cex#fetchTicker
@@ -15,7 +15,7 @@ export default class coinbase extends Exchange {
15
15
  * @param {string} [params.method] 'v2PublicGetTime' or 'v3PublicGetBrokerageTime' default is 'v2PublicGetTime'
16
16
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
17
17
  */
18
- fetchTime(params?: {}): Promise<number>;
18
+ fetchTime(params?: {}): Promise<Int>;
19
19
  /**
20
20
  * @method
21
21
  * @name coinbase#fetchAccounts
@@ -23,7 +23,7 @@ export default class coinbase extends Exchange {
23
23
  'name': 'Coinbase Advanced',
24
24
  'countries': ['US'],
25
25
  'pro': true,
26
- 'certified': true,
26
+ 'certified': false,
27
27
  // rate-limits:
28
28
  // ADVANCED API: https://docs.cloud.coinbase.com/advanced-trade/docs/rest-api-rate-limits
29
29
  // - max 30 req/second for private data, 10 req/s for public data
@@ -5017,10 +5017,17 @@ export default class coinbase extends Exchange {
5017
5017
  // }
5018
5018
  // ]
5019
5019
  // }
5020
+ // or
5021
+ // {
5022
+ // "error": "UNKNOWN_FAILURE_REASON",
5023
+ // "message": "",
5024
+ // "error_details": "",
5025
+ // "preview_failure_reason": "PREVIEW_STOP_PRICE_BELOW_LAST_TRADE_PRICE"
5026
+ // }
5020
5027
  //
5021
5028
  let errorCode = this.safeString(response, 'error');
5022
5029
  if (errorCode !== undefined) {
5023
- const errorMessage = this.safeString(response, 'error_description');
5030
+ const errorMessage = this.safeString2(response, 'error_description', 'preview_failure_reason');
5024
5031
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
5025
5032
  this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
5026
5033
  throw new ExchangeError(feedback);
@@ -140,7 +140,7 @@ export default class coinbaseexchange extends Exchange {
140
140
  * @param {object} [params] extra parameters specific to the exchange API endpoint
141
141
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
142
142
  */
143
- fetchTime(params?: {}): Promise<number>;
143
+ fetchTime(params?: {}): Promise<Int>;
144
144
  parseOrderStatus(status: Str): string;
145
145
  parseOrder(order: Dict, market?: Market): Order;
146
146
  /**
@@ -311,7 +311,7 @@ export default class coinbaseexchange extends Exchange {
311
311
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
312
312
  */
313
313
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
314
- parseTransactionStatus(transaction: any): "ok" | "canceled" | "pending" | "failed";
314
+ parseTransactionStatus(transaction: any): "canceled" | "pending" | "ok" | "failed";
315
315
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
316
316
  /**
317
317
  * @method
@@ -21,7 +21,7 @@ export default class coinbaseinternational extends Exchange {
21
21
  'id': 'coinbaseinternational',
22
22
  'name': 'Coinbase International',
23
23
  'countries': ['US'],
24
- 'certified': true,
24
+ 'certified': false,
25
25
  'pro': true,
26
26
  'rateLimit': 100,
27
27
  'version': 'v1',
@@ -15,7 +15,7 @@ export default class coincatch extends Exchange {
15
15
  * @param {object} [params] extra parameters specific to the exchange API endpoint
16
16
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
17
17
  */
18
- fetchTime(params?: {}): Promise<number>;
18
+ fetchTime(params?: {}): Promise<Int>;
19
19
  /**
20
20
  * @method
21
21
  * @name coincatch#fetchCurrencies