ccxt 4.5.45 → 4.5.46

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 (52) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +3 -0
  5. package/dist/cjs/src/binance.js +11 -2
  6. package/dist/cjs/src/bitget.js +3 -1
  7. package/dist/cjs/src/bitmart.js +144 -21
  8. package/dist/cjs/src/bybit.js +58 -56
  9. package/dist/cjs/src/bydfi.js +102 -100
  10. package/dist/cjs/src/gate.js +37 -2
  11. package/dist/cjs/src/kraken.js +2 -0
  12. package/dist/cjs/src/kucoin.js +4 -2
  13. package/dist/cjs/src/okx.js +75 -57
  14. package/dist/cjs/src/paradex.js +2 -6
  15. package/dist/cjs/src/pro/bydfi.js +19 -19
  16. package/dist/cjs/src/pro/gate.js +79 -54
  17. package/dist/cjs/src/pro/grvt.js +5 -3
  18. package/dist/cjs/src/pro/htx.js +4 -4
  19. package/dist/cjs/src/pro/okx.js +1 -1
  20. package/index.d.cts +2 -0
  21. package/js/ccxt.d.ts +1 -1
  22. package/js/ccxt.js +1 -1
  23. package/js/src/abstract/bitmart.d.ts +7 -0
  24. package/js/src/abstract/bydfi.d.ts +29 -29
  25. package/js/src/abstract/kraken.d.ts +1 -0
  26. package/js/src/abstract/kucoin.d.ts +1 -0
  27. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  28. package/js/src/base/Exchange.d.ts +1 -0
  29. package/js/src/base/Exchange.js +3 -0
  30. package/js/src/binance.js +11 -2
  31. package/js/src/bitget.js +3 -1
  32. package/js/src/bitmart.d.ts +18 -4
  33. package/js/src/bitmart.js +144 -21
  34. package/js/src/bybit.d.ts +1 -0
  35. package/js/src/bybit.js +58 -56
  36. package/js/src/bydfi.d.ts +31 -31
  37. package/js/src/bydfi.js +102 -100
  38. package/js/src/gate.js +37 -2
  39. package/js/src/kraken.js +2 -0
  40. package/js/src/kucoin.js +4 -2
  41. package/js/src/okx.d.ts +1 -0
  42. package/js/src/okx.js +75 -57
  43. package/js/src/paradex.d.ts +0 -1
  44. package/js/src/paradex.js +2 -6
  45. package/js/src/pro/bydfi.d.ts +18 -18
  46. package/js/src/pro/bydfi.js +19 -19
  47. package/js/src/pro/gate.d.ts +2 -2
  48. package/js/src/pro/gate.js +79 -54
  49. package/js/src/pro/grvt.js +5 -3
  50. package/js/src/pro/htx.js +4 -4
  51. package/js/src/pro/okx.js +1 -1
  52. package/package.json +2 -2
package/dist/cjs/ccxt.js CHANGED
@@ -200,7 +200,7 @@ var xt$1 = require('./src/pro/xt.js');
200
200
 
201
201
  //-----------------------------------------------------------------------------
202
202
  // this is updated by vss.js when building
203
- const version = '4.5.45';
203
+ const version = '4.5.46';
204
204
  Exchange["default"].ccxtVersion = version;
205
205
  const exchanges = {
206
206
  'aftermath': aftermath["default"],
@@ -4073,6 +4073,9 @@ class Exchange {
4073
4073
  }
4074
4074
  return reversed;
4075
4075
  }
4076
+ stringToBase16(str) {
4077
+ return '0x' + this.binaryToBase16(this.base64ToBinary(this.stringToBase64(str)));
4078
+ }
4076
4079
  reduceFeesByCurrency(fees) {
4077
4080
  //
4078
4081
  // this function takes a list of fee structures having the following format
@@ -1384,8 +1384,11 @@ class binance extends binance$1["default"] {
1384
1384
  },
1385
1385
  'networks': {
1386
1386
  'ERC20': 'ETH',
1387
+ 'ETH': 'ETH',
1387
1388
  'TRC20': 'TRX',
1389
+ 'TRX': 'TRX',
1388
1390
  'BEP2': 'BNB',
1391
+ 'BSC': 'BSC',
1389
1392
  'BEP20': 'BSC',
1390
1393
  'EOS': 'EOS',
1391
1394
  'SPL': 'SOL',
@@ -1398,6 +1401,7 @@ class binance extends binance$1["default"] {
1398
1401
  'MATIC': 'MATIC',
1399
1402
  'BASE': 'BASE',
1400
1403
  'SUI': 'SUI',
1404
+ 'OP': 'OPTIMISM',
1401
1405
  'OPTIMISM': 'OPTIMISM',
1402
1406
  'NEAR': 'NEAR',
1403
1407
  'APT': 'APT',
@@ -1443,7 +1447,11 @@ class binance extends binance$1["default"] {
1443
1447
  'ONT': 'ONT', // ontology
1444
1448
  },
1445
1449
  'networksById': {
1446
- 'SOL': 'SOL', // temporary fix for SPL definition
1450
+ 'TRX': 'TRC20',
1451
+ 'BSC': 'BEP20',
1452
+ 'ETH': 'ERC20',
1453
+ 'SOL': 'SOL',
1454
+ 'OPTIMISM': 'OP',
1447
1455
  },
1448
1456
  'impliedNetworks': {
1449
1457
  'ETH': { 'ERC20': 'ETH' },
@@ -8964,7 +8972,8 @@ class binance extends binance$1["default"] {
8964
8972
  if (internalInteger !== undefined) {
8965
8973
  internal = (internalInteger !== 0) ? true : false;
8966
8974
  }
8967
- const network = this.safeString(transaction, 'network');
8975
+ const networkId = this.safeString(transaction, 'network');
8976
+ const network = this.networkIdToCode(networkId, code);
8968
8977
  return {
8969
8978
  'info': transaction,
8970
8979
  'id': id,
@@ -1457,7 +1457,9 @@ class bitget extends bitget$1["default"] {
1457
1457
  '20003': errors.ExchangeError,
1458
1458
  '01001': errors.ExchangeError,
1459
1459
  '40024': errors.RestrictedLocation,
1460
- '43111': errors.PermissionDenied, // {"code":"43111","msg":"参数错误 address not in address book","requestTime":1665394201164,"data":null}
1460
+ '41117': errors.InvalidOrder,
1461
+ '43111': errors.PermissionDenied,
1462
+ '45113': errors.InvalidOrder, // {"code":"45113","msg":"Maximum order value limit triggered","requestTime":1774884278712,"data":null}
1461
1463
  },
1462
1464
  'broad': {
1463
1465
  'invalid size, valid range': errors.ExchangeError,
@@ -244,6 +244,13 @@ class bitmart extends bitmart$1["default"] {
244
244
  'spot/v4/cancel_orders': 3,
245
245
  'spot/v4/cancel_all': 90,
246
246
  'spot/v4/batch_orders': 3,
247
+ 'spot/v4/algo/submit_order': 6,
248
+ 'spot/v4/algo/cancel_order': 6,
249
+ 'spot/v4/algo/cancel_all': 12,
250
+ 'spot/v4/query/algo/order': 1.5,
251
+ 'spot/v4/query/algo/client-order': 1.5,
252
+ 'spot/v4/query/algo/open-orders': 3,
253
+ 'spot/v4/query/algo/history-orders': 3,
247
254
  // newer endpoint
248
255
  'spot/v3/cancel_order': 1,
249
256
  'spot/v2/batch_orders': 1,
@@ -931,7 +938,7 @@ class bitmart extends bitmart$1["default"] {
931
938
  if (type === 'swap') {
932
939
  type = 'contract';
933
940
  }
934
- const service = this.safeString(servicesByType, type);
941
+ const service = this.safeDict(servicesByType, type);
935
942
  let status = undefined;
936
943
  let eta = undefined;
937
944
  if (service !== undefined) {
@@ -2769,6 +2776,7 @@ class bitmart extends bitmart$1["default"] {
2769
2776
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
2770
2777
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-tp-sl-order-signed
2771
2778
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-trail-order-signed
2779
+ * @see https://developer-pro.bitmart.com/en/spot/#new-algo-order-v4-signed
2772
2780
  * @param {string} symbol unified symbol of the market to create an order in
2773
2781
  * @param {string} type 'market', 'limit' or 'trailing' for swap markets only
2774
2782
  * @param {string} side 'buy' or 'sell'
@@ -2806,7 +2814,10 @@ class bitmart extends bitmart$1["default"] {
2806
2814
  let response = undefined;
2807
2815
  if (market['spot']) {
2808
2816
  const spotRequest = this.createSpotOrderRequest(symbol, type, side, amount, price, params);
2809
- if (marginMode === 'isolated') {
2817
+ if (isStopLoss || isTakeProfit || isTriggerOrder) {
2818
+ response = await this.privatePostSpotV4AlgoSubmitOrder(spotRequest);
2819
+ }
2820
+ else if (marginMode === 'isolated') {
2810
2821
  response = await this.privatePostSpotV1MarginSubmitOrder(spotRequest);
2811
2822
  }
2812
2823
  else {
@@ -3086,6 +3097,7 @@ class bitmart extends bitmart$1["default"] {
3086
3097
  * @description create a spot order request
3087
3098
  * @see https://developer-pro.bitmart.com/en/spot/#new-order-v2-signed
3088
3099
  * @see https://developer-pro.bitmart.com/en/spot/#new-margin-order-v1-signed
3100
+ * @see https://developer-pro.bitmart.com/en/spot/#new-algo-order-v4-signed
3089
3101
  * @param {string} symbol unified symbol of the market to create an order in
3090
3102
  * @param {string} type 'market' or 'limit'
3091
3103
  * @param {string} side 'buy' or 'sell'
@@ -3093,13 +3105,23 @@ class bitmart extends bitmart$1["default"] {
3093
3105
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
3094
3106
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3095
3107
  * @param {string} [params.marginMode] 'cross' or 'isolated'
3108
+ * @param {string} [params.clientOrderId] client order id of the order
3109
+ * @param {string} [params.triggerPrice] the price to trigger a stop order
3110
+ * @param {string} [params.stopLossPrice] the price to trigger a stop-loss order
3111
+ * @param {string} [params.takeProfitPrice] the price to trigger a take-profit order
3096
3112
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
3097
3113
  */
3098
3114
  const market = this.market(symbol);
3115
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
3116
+ const stopLossPrice = this.safeString(params, 'stopLossPrice');
3117
+ const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
3118
+ const isStopLoss = stopLossPrice !== undefined;
3119
+ const isTakeProfit = takeProfitPrice !== undefined;
3120
+ const isTriggerOrder = triggerPrice !== undefined;
3121
+ const isAlgoOrder = isStopLoss || isTakeProfit || isTriggerOrder;
3099
3122
  const request = {
3100
3123
  'symbol': market['id'],
3101
3124
  'side': side,
3102
- 'type': type,
3103
3125
  };
3104
3126
  const timeInForce = this.safeString(params, 'timeInForce');
3105
3127
  if (timeInForce === 'FOK') {
@@ -3113,7 +3135,32 @@ class bitmart extends bitmart$1["default"] {
3113
3135
  params = this.omit(params, ['timeInForce', 'postOnly']);
3114
3136
  const ioc = ((timeInForce === 'IOC') || (type === 'ioc'));
3115
3137
  const isLimitOrder = (type === 'limit') || postOnly || ioc;
3116
- // method = 'privatePostSpotV2SubmitOrder';
3138
+ if (isAlgoOrder) {
3139
+ if (isTriggerOrder) {
3140
+ request['type'] = 'trigger';
3141
+ }
3142
+ else {
3143
+ request['type'] = 'tp/sl';
3144
+ }
3145
+ if (isLimitOrder) {
3146
+ request['trigger_type'] = 'limit';
3147
+ }
3148
+ else {
3149
+ request['trigger_type'] = 'market';
3150
+ }
3151
+ if (isStopLoss) {
3152
+ request['trigger_price'] = this.priceToPrecision(symbol, stopLossPrice);
3153
+ }
3154
+ else if (isTakeProfit) {
3155
+ request['trigger_price'] = this.priceToPrecision(symbol, takeProfitPrice);
3156
+ }
3157
+ else if (isTriggerOrder) {
3158
+ request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
3159
+ }
3160
+ }
3161
+ else {
3162
+ request['type'] = type;
3163
+ }
3117
3164
  if (isLimitOrder) {
3118
3165
  request['size'] = this.amountToPrecision(symbol, amount);
3119
3166
  request['price'] = this.priceToPrecision(symbol, price);
@@ -3166,12 +3213,14 @@ class bitmart extends bitmart$1["default"] {
3166
3213
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-plan-order-signed
3167
3214
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-order-signed
3168
3215
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-trail-order-signed
3216
+ * @see https://developer-pro.bitmart.com/en/spot/#cancel-algo-order-v4-signed
3169
3217
  * @param {string} id order id
3170
3218
  * @param {string} symbol unified symbol of the market the order was made in
3171
3219
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3172
3220
  * @param {string} [params.clientOrderId] *spot only* the client order id of the order to cancel
3173
- * @param {boolean} [params.trigger] *swap only* whether the order is a trigger order
3174
3221
  * @param {boolean} [params.trailing] *swap only* whether the order is a stop order
3222
+ * @param {boolean} [params.trigger] whether the order is a trigger order
3223
+ * @param {boolean} [params.stopLossTakeProfit] whether the order is a stopLossPrice or takeProfitPrice order
3175
3224
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
3176
3225
  */
3177
3226
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -3190,15 +3239,26 @@ class bitmart extends bitmart$1["default"] {
3190
3239
  else {
3191
3240
  request['order_id'] = id.toString();
3192
3241
  }
3193
- params = this.omit(params, ['clientOrderId']);
3242
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
3243
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3244
+ const trailing = this.safeBool(params, 'trailing');
3245
+ params = this.omit(params, ['clientOrderId', 'stop', 'trigger', 'trailing', 'stopLossTakeProfit']);
3194
3246
  let response = undefined;
3195
3247
  if (market['spot']) {
3196
- response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
3248
+ if (trigger || stopLossTakeProfit) {
3249
+ if (stopLossTakeProfit) {
3250
+ request['type'] = 'tp/sl';
3251
+ }
3252
+ else if (trigger) {
3253
+ request['type'] = 'trigger';
3254
+ }
3255
+ response = await this.privatePostSpotV4AlgoCancelOrder(this.extend(request, params));
3256
+ }
3257
+ else {
3258
+ response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
3259
+ }
3197
3260
  }
3198
3261
  else {
3199
- const trigger = this.safeBool2(params, 'stop', 'trigger');
3200
- const trailing = this.safeBool(params, 'trailing');
3201
- params = this.omit(params, ['stop', 'trigger']);
3202
3262
  if (trigger) {
3203
3263
  response = await this.privatePostContractPrivateCancelPlanOrder(this.extend(request, params));
3204
3264
  }
@@ -3323,9 +3383,12 @@ class bitmart extends bitmart$1["default"] {
3323
3383
  * @description cancel all open orders in a market
3324
3384
  * @see https://developer-pro.bitmart.com/en/spot/#cancel-all-order-v4-signed
3325
3385
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-all-orders-signed
3386
+ * @see https://developer-pro.bitmart.com/en/spot/#cancel-all-algo-order-v4-signed
3326
3387
  * @param {string} symbol unified market symbol of the market to cancel orders in
3327
3388
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3328
3389
  * @param {string} [params.side] *spot only* 'buy' or 'sell'
3390
+ * @param {boolean} [params.trigger] whether the orders are trigger orders
3391
+ * @param {boolean} [params.stopLossTakeProfit] whether the orders are stopLossPrice or takeProfitPrice orders
3329
3392
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
3330
3393
  */
3331
3394
  async cancelAllOrders(symbol = undefined, params = {}) {
@@ -3340,7 +3403,21 @@ class bitmart extends bitmart$1["default"] {
3340
3403
  let type = undefined;
3341
3404
  [type, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
3342
3405
  if (type === 'spot') {
3343
- response = await this.privatePostSpotV4CancelAll(this.extend(request, params));
3406
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
3407
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3408
+ params = this.omit(params, ['stop', 'trigger', 'stopLossTakeProfit']);
3409
+ if (trigger || stopLossTakeProfit) {
3410
+ if (stopLossTakeProfit) {
3411
+ request['type'] = 'tp/sl';
3412
+ }
3413
+ else if (trigger) {
3414
+ request['type'] = 'trigger';
3415
+ }
3416
+ response = await this.privatePostSpotV4AlgoCancelAll(this.extend(request, params));
3417
+ }
3418
+ else {
3419
+ response = await this.privatePostSpotV4CancelAll(this.extend(request, params));
3420
+ }
3344
3421
  }
3345
3422
  else if (type === 'swap') {
3346
3423
  if (symbol === undefined) {
@@ -3430,10 +3507,11 @@ class bitmart extends bitmart$1["default"] {
3430
3507
  /**
3431
3508
  * @method
3432
3509
  * @name bitmart#fetchOpenOrders
3510
+ * @description fetch all unfilled currently open orders
3433
3511
  * @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
3434
3512
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-all-open-orders-keyed
3435
3513
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-all-current-plan-orders-keyed
3436
- * @description fetch all unfilled currently open orders
3514
+ * @see https://developer-pro.bitmart.com/en/spot/#current-algo-open-orders-v4-signed
3437
3515
  * @param {string} symbol unified market symbol
3438
3516
  * @param {int} [since] the earliest time in ms to fetch open orders for
3439
3517
  * @param {int} [limit] the maximum number of open order structures to retrieve
@@ -3444,7 +3522,8 @@ class bitmart extends bitmart$1["default"] {
3444
3522
  * @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
3445
3523
  * @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
3446
3524
  * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
3447
- * @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
3525
+ * @param {boolean} [params.trigger] set to true if you want to fetch trigger orders
3526
+ * @param {boolean} [params.stopLossTakeProfit] set to true if you want to fetch stopLossPrice or takeProfitPrice orders
3448
3527
  * @param {string} [params.stpMode] self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3449
3528
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
3450
3529
  */
@@ -3459,6 +3538,9 @@ class bitmart extends bitmart$1["default"] {
3459
3538
  let type = undefined;
3460
3539
  let response = undefined;
3461
3540
  [type, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
3541
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger');
3542
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3543
+ params = this.omit(params, ['stop', 'trigger', 'stopLossTakeProfit']);
3462
3544
  if (type === 'spot') {
3463
3545
  if (limit !== undefined) {
3464
3546
  request['limit'] = Math.min(limit, 200);
@@ -3476,14 +3558,23 @@ class bitmart extends bitmart$1["default"] {
3476
3558
  params = this.omit(params, ['endTime']);
3477
3559
  request['endTime'] = until;
3478
3560
  }
3479
- response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
3561
+ if (isTrigger || stopLossTakeProfit) {
3562
+ if (isTrigger) {
3563
+ request['orderMode'] = 'trigger';
3564
+ }
3565
+ else if (stopLossTakeProfit) {
3566
+ request['orderMode'] = 'tp/sl';
3567
+ }
3568
+ response = await this.privatePostSpotV4QueryAlgoOpenOrders(this.extend(request, params));
3569
+ }
3570
+ else {
3571
+ response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
3572
+ }
3480
3573
  }
3481
3574
  else if (type === 'swap') {
3482
3575
  if (limit !== undefined) {
3483
3576
  request['limit'] = Math.min(limit, 100);
3484
3577
  }
3485
- const isTrigger = this.safeBool2(params, 'stop', 'trigger');
3486
- params = this.omit(params, ['stop', 'trigger']);
3487
3578
  if (isTrigger) {
3488
3579
  response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
3489
3580
  }
@@ -3563,9 +3654,10 @@ class bitmart extends bitmart$1["default"] {
3563
3654
  /**
3564
3655
  * @method
3565
3656
  * @name bitmart#fetchClosedOrders
3657
+ * @description fetches information on multiple closed orders made by the user
3566
3658
  * @see https://developer-pro.bitmart.com/en/spot/#account-orders-v4-signed
3567
3659
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-order-history-keyed
3568
- * @description fetches information on multiple closed orders made by the user
3660
+ * @see https://developer-pro.bitmart.com/en/spot/#account-algo-orders-v4-signed
3569
3661
  * @param {string} symbol unified market symbol of the market orders were made in
3570
3662
  * @param {int} [since] the earliest time in ms to fetch orders for
3571
3663
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -3573,6 +3665,8 @@ class bitmart extends bitmart$1["default"] {
3573
3665
  * @param {int} [params.until] timestamp in ms of the latest entry
3574
3666
  * @param {string} [params.marginMode] *spot only* 'cross' or 'isolated', for margin trading
3575
3667
  * @param {string} [params.stpMode] self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3668
+ * @param {boolean} [params.trigger] set to true if you want to fetch trigger orders
3669
+ * @param {boolean} [params.stopLossTakeProfit] set to true if you want to fetch stopLossPrice or takeProfitPrice orders
3576
3670
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
3577
3671
  */
3578
3672
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3600,6 +3694,9 @@ class bitmart extends bitmart$1["default"] {
3600
3694
  params = this.omit(params, ['until']);
3601
3695
  request[endTimeKey] = until;
3602
3696
  }
3697
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger');
3698
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3699
+ params = this.omit(params, ['stop', 'trigger', 'stopLossTakeProfit']);
3603
3700
  let response = undefined;
3604
3701
  if (type === 'spot') {
3605
3702
  let marginMode = undefined;
@@ -3607,7 +3704,18 @@ class bitmart extends bitmart$1["default"] {
3607
3704
  if (marginMode === 'isolated') {
3608
3705
  request['orderMode'] = 'iso_margin';
3609
3706
  }
3610
- response = await this.privatePostSpotV4QueryHistoryOrders(this.extend(request, params));
3707
+ if (isTrigger || stopLossTakeProfit) {
3708
+ if (isTrigger) {
3709
+ request['orderMode'] = 'trigger';
3710
+ }
3711
+ else if (stopLossTakeProfit) {
3712
+ request['orderMode'] = 'tp/sl';
3713
+ }
3714
+ response = await this.privatePostSpotV4QueryAlgoHistoryOrders(this.extend(request, params));
3715
+ }
3716
+ else {
3717
+ response = await this.privatePostSpotV4QueryHistoryOrders(this.extend(request, params));
3718
+ }
3611
3719
  }
3612
3720
  else {
3613
3721
  response = await this.privateGetContractPrivateOrderHistory(this.extend(request, params));
@@ -3635,6 +3743,8 @@ class bitmart extends bitmart$1["default"] {
3635
3743
  * @see https://developer-pro.bitmart.com/en/spot/#query-order-by-id-v4-signed
3636
3744
  * @see https://developer-pro.bitmart.com/en/spot/#query-order-by-clientorderid-v4-signed
3637
3745
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-order-detail-keyed
3746
+ * @see https://developer-pro.bitmart.com/en/spot/#query-algo-order-by-id-v4-signed
3747
+ * @see https://developer-pro.bitmart.com/en/spot/#query-algo-order-by-clientorderid-v4-signed
3638
3748
  * @param {string} id the id of the order
3639
3749
  * @param {string} symbol unified symbol of the market the order was made in
3640
3750
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3642,6 +3752,7 @@ class bitmart extends bitmart$1["default"] {
3642
3752
  * @param {string} [params.orderType] *swap only* 'limit', 'market', 'liquidate', 'bankruptcy', 'adl' or 'trailing'
3643
3753
  * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch a trailing order
3644
3754
  * @param {string} [params.stpMode] self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3755
+ * @param {boolean} [params.trigger] whether the orders is a trigger, stopLossPrice or takeProfitPrice order
3645
3756
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
3646
3757
  */
3647
3758
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -3656,14 +3767,26 @@ class bitmart extends bitmart$1["default"] {
3656
3767
  [type, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
3657
3768
  if (type === 'spot') {
3658
3769
  const clientOrderId = this.safeString(params, 'clientOrderId');
3770
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
3771
+ params = this.omit(params, ['stop', 'trigger']);
3659
3772
  if (!clientOrderId) {
3660
3773
  request['orderId'] = id;
3661
3774
  }
3662
- if (clientOrderId !== undefined) {
3663
- response = await this.privatePostSpotV4QueryClientOrder(this.extend(request, params));
3775
+ if (trigger) {
3776
+ if (clientOrderId !== undefined) {
3777
+ response = await this.privatePostSpotV4QueryAlgoClientOrder(this.extend(request, params));
3778
+ }
3779
+ else {
3780
+ response = await this.privatePostSpotV4QueryAlgoOrder(this.extend(request, params));
3781
+ }
3664
3782
  }
3665
3783
  else {
3666
- response = await this.privatePostSpotV4QueryOrder(this.extend(request, params));
3784
+ if (clientOrderId !== undefined) {
3785
+ response = await this.privatePostSpotV4QueryClientOrder(this.extend(request, params));
3786
+ }
3787
+ else {
3788
+ response = await this.privatePostSpotV4QueryOrder(this.extend(request, params));
3789
+ }
3667
3790
  }
3668
3791
  }
3669
3792
  else if (type === 'swap') {
@@ -1130,8 +1130,12 @@ class bybit extends bybit$1["default"] {
1130
1130
  'FUND': 'fund',
1131
1131
  },
1132
1132
  'networks': {
1133
+ 'BTC': 'BTC',
1134
+ 'ETH': 'ETH',
1133
1135
  'ERC20': 'ETH',
1136
+ 'TRX': 'TRX',
1134
1137
  'TRC20': 'TRX',
1138
+ 'BSC': 'BSC',
1135
1139
  'BEP20': 'BSC',
1136
1140
  'SOL': 'SOL',
1137
1141
  'ACA': 'ACA',
@@ -1180,6 +1184,7 @@ class bybit extends bybit$1["default"] {
1180
1184
  'OASIS': 'ROSE',
1181
1185
  'OMNI': 'OMNI',
1182
1186
  'ONE': 'ONE',
1187
+ 'OP': 'OP',
1183
1188
  'OPTIMISM': 'OP',
1184
1189
  'POKT': 'POKT',
1185
1190
  'QTUM': 'QTUM',
@@ -1210,8 +1215,7 @@ class bybit extends bybit$1["default"] {
1210
1215
  'ETH': 'ERC20',
1211
1216
  'TRX': 'TRC20',
1212
1217
  'BSC': 'BEP20',
1213
- 'OMNI': 'OMNI',
1214
- 'SPL': 'SOL',
1218
+ 'OP': 'OP',
1215
1219
  },
1216
1220
  'defaultNetwork': 'ERC20',
1217
1221
  'defaultNetworks': {
@@ -1707,68 +1711,66 @@ class bybit extends bybit$1["default"] {
1707
1711
  //
1708
1712
  const data = this.safeDict(response, 'result', {});
1709
1713
  const rows = this.safeList(data, 'rows', []);
1710
- const result = {};
1711
- for (let i = 0; i < rows.length; i++) {
1712
- const currency = rows[i];
1713
- const currencyId = this.safeString(currency, 'coin');
1714
- const code = this.safeCurrencyCode(currencyId);
1715
- const name = this.safeString(currency, 'name');
1716
- const chains = this.safeList(currency, 'chains', []);
1717
- const networks = {};
1718
- for (let j = 0; j < chains.length; j++) {
1719
- const chain = chains[j];
1720
- const networkId = this.safeString(chain, 'chain');
1721
- const networkCode = this.networkIdToCode(networkId);
1722
- networks[networkCode] = {
1723
- 'info': chain,
1724
- 'id': networkId,
1725
- 'network': networkCode,
1726
- 'active': undefined,
1727
- 'deposit': this.safeInteger(chain, 'chainDeposit') === 1,
1728
- 'withdraw': this.safeInteger(chain, 'chainWithdraw') === 1,
1729
- 'fee': this.safeNumber(chain, 'withdrawFee'),
1730
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'minAccuracy'))),
1731
- 'limits': {
1732
- 'withdraw': {
1733
- 'min': this.safeNumber(chain, 'withdrawMin'),
1734
- 'max': undefined,
1735
- },
1736
- 'deposit': {
1737
- 'min': this.safeNumber(chain, 'depositMin'),
1738
- 'max': undefined,
1739
- },
1740
- },
1741
- };
1742
- }
1743
- result[code] = this.safeCurrencyStructure({
1744
- 'info': currency,
1745
- 'code': code,
1746
- 'id': currencyId,
1747
- 'name': name,
1714
+ return this.parseCurrencies(rows);
1715
+ }
1716
+ parseCurrency(currency) {
1717
+ const currencyId = this.safeString(currency, 'coin');
1718
+ const code = this.safeCurrencyCode(currencyId);
1719
+ const name = this.safeString(currency, 'name');
1720
+ const chains = this.safeList(currency, 'chains', []);
1721
+ const networks = {};
1722
+ for (let j = 0; j < chains.length; j++) {
1723
+ const chain = chains[j];
1724
+ const networkId = this.safeString(chain, 'chain');
1725
+ const networkCode = this.networkIdToCode(networkId, code);
1726
+ networks[networkCode] = {
1727
+ 'info': chain,
1728
+ 'id': networkId,
1729
+ 'network': networkCode,
1748
1730
  'active': undefined,
1749
- 'deposit': undefined,
1750
- 'withdraw': undefined,
1751
- 'fee': undefined,
1752
- 'precision': undefined,
1731
+ 'deposit': this.safeInteger(chain, 'chainDeposit') === 1,
1732
+ 'withdraw': this.safeInteger(chain, 'chainWithdraw') === 1,
1733
+ 'fee': this.safeNumber(chain, 'withdrawFee'),
1734
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'minAccuracy'))),
1753
1735
  'limits': {
1754
- 'amount': {
1755
- 'min': undefined,
1756
- 'max': undefined,
1757
- },
1758
1736
  'withdraw': {
1759
- 'min': undefined,
1737
+ 'min': this.safeNumber(chain, 'withdrawMin'),
1760
1738
  'max': undefined,
1761
1739
  },
1762
1740
  'deposit': {
1763
- 'min': undefined,
1741
+ 'min': this.safeNumber(chain, 'depositMin'),
1764
1742
  'max': undefined,
1765
1743
  },
1766
1744
  },
1767
- 'networks': networks,
1768
- 'type': 'crypto', // atm exchange api provides only cryptos
1769
- });
1745
+ };
1770
1746
  }
1771
- return result;
1747
+ return this.safeCurrencyStructure({
1748
+ 'info': currency,
1749
+ 'code': code,
1750
+ 'id': currencyId,
1751
+ 'name': name,
1752
+ 'active': undefined,
1753
+ 'deposit': undefined,
1754
+ 'withdraw': undefined,
1755
+ 'fee': undefined,
1756
+ 'precision': undefined,
1757
+ 'limits': {
1758
+ 'amount': {
1759
+ 'min': undefined,
1760
+ 'max': undefined,
1761
+ },
1762
+ 'withdraw': {
1763
+ 'min': undefined,
1764
+ 'max': undefined,
1765
+ },
1766
+ 'deposit': {
1767
+ 'min': undefined,
1768
+ 'max': undefined,
1769
+ },
1770
+ },
1771
+ 'networks': networks,
1772
+ 'type': 'crypto', // atm exchange api provides only cryptos
1773
+ });
1772
1774
  }
1773
1775
  /**
1774
1776
  * @method
@@ -6077,7 +6079,7 @@ class bybit extends bybit$1["default"] {
6077
6079
  'txid': this.safeString(transaction, 'txID'),
6078
6080
  'timestamp': timestamp,
6079
6081
  'datetime': this.iso8601(timestamp),
6080
- 'network': this.networkIdToCode(this.safeString(transaction, 'chain')),
6082
+ 'network': this.networkIdToCode(this.safeString(transaction, 'chain'), code),
6081
6083
  'address': undefined,
6082
6084
  'addressTo': toAddress,
6083
6085
  'addressFrom': undefined,
@@ -6414,7 +6416,7 @@ class bybit extends bybit$1["default"] {
6414
6416
  request['tag'] = tag;
6415
6417
  }
6416
6418
  const [networkCode, query] = this.handleNetworkCodeAndParams(params);
6417
- const networkId = this.networkCodeToId(networkCode);
6419
+ const networkId = this.networkCodeToId(networkCode, code);
6418
6420
  if (networkId !== undefined) {
6419
6421
  request['chain'] = networkId.toUpperCase();
6420
6422
  }