ccxt 4.3.24 → 4.3.28

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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/ascendex.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +24 -25
  5. package/dist/cjs/src/base/functions/number.js +10 -5
  6. package/dist/cjs/src/bingx.js +43 -7
  7. package/dist/cjs/src/bitget.js +1 -0
  8. package/dist/cjs/src/bitmart.js +65 -2
  9. package/dist/cjs/src/bybit.js +3 -3
  10. package/dist/cjs/src/coinbase.js +1 -1
  11. package/dist/cjs/src/coinex.js +44 -75
  12. package/dist/cjs/src/kraken.js +60 -7
  13. package/dist/cjs/src/krakenfutures.js +1 -1
  14. package/dist/cjs/src/phemex.js +18 -2
  15. package/dist/cjs/src/pro/binance.js +1 -1
  16. package/dist/cjs/src/pro/coinbase.js +5 -1
  17. package/dist/cjs/src/pro/cryptocom.js +9 -7
  18. package/dist/cjs/src/pro/kraken.js +6 -4
  19. package/dist/cjs/src/pro/okx.js +1 -1
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/bitget.d.ts +1 -0
  23. package/js/src/abstract/bitmart.d.ts +1 -0
  24. package/js/src/ascendex.js +1 -1
  25. package/js/src/base/Exchange.d.ts +4 -2
  26. package/js/src/base/Exchange.js +24 -25
  27. package/js/src/base/functions/number.js +10 -5
  28. package/js/src/bingx.js +43 -7
  29. package/js/src/bitget.js +1 -0
  30. package/js/src/bitmart.d.ts +1 -0
  31. package/js/src/bitmart.js +65 -2
  32. package/js/src/bybit.js +3 -3
  33. package/js/src/coinbase.js +1 -1
  34. package/js/src/coinex.js +44 -75
  35. package/js/src/kraken.d.ts +3 -1
  36. package/js/src/kraken.js +60 -7
  37. package/js/src/krakenfutures.js +1 -1
  38. package/js/src/phemex.js +18 -2
  39. package/js/src/pro/binance.d.ts +1 -1
  40. package/js/src/pro/binance.js +1 -1
  41. package/js/src/pro/coinbase.js +5 -1
  42. package/js/src/pro/cryptocom.js +9 -7
  43. package/js/src/pro/kraken.d.ts +1 -1
  44. package/js/src/pro/kraken.js +6 -4
  45. package/js/src/pro/okx.d.ts +1 -1
  46. package/js/src/pro/okx.js +1 -1
  47. package/package.json +1 -1
package/README.md CHANGED
@@ -215,13 +215,13 @@ console.log(version, Object.keys(exchanges));
215
215
 
216
216
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
217
217
 
218
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.24/dist/ccxt.browser.js
219
- * unpkg: https://unpkg.com/ccxt@4.3.24/dist/ccxt.browser.js
218
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.28/dist/ccxt.browser.js
219
+ * unpkg: https://unpkg.com/ccxt@4.3.28/dist/ccxt.browser.js
220
220
 
221
221
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
222
222
 
223
223
  ```HTML
224
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.24/dist/ccxt.browser.js"></script>
224
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.28/dist/ccxt.browser.js"></script>
225
225
  ```
226
226
 
227
227
  Creates a global `ccxt` object:
package/dist/cjs/ccxt.js CHANGED
@@ -185,7 +185,7 @@ var woofipro$1 = require('./src/pro/woofipro.js');
185
185
 
186
186
  //-----------------------------------------------------------------------------
187
187
  // this is updated by vss.js when building
188
- const version = '4.3.24';
188
+ const version = '4.3.28';
189
189
  Exchange["default"].ccxtVersion = version;
190
190
  const exchanges = {
191
191
  'ace': ace,
@@ -1403,7 +1403,7 @@ class ascendex extends ascendex$1 {
1403
1403
  'currency': feeCurrencyCode,
1404
1404
  };
1405
1405
  }
1406
- const stopPrice = this.safeNumber(order, 'stopPrice');
1406
+ const stopPrice = this.omitZero(this.safeString(order, 'stopPrice'));
1407
1407
  let reduceOnly = undefined;
1408
1408
  const execInst = this.safeString(order, 'execInst');
1409
1409
  if (execInst === 'reduceOnly') {
@@ -2506,6 +2506,7 @@ class Exchange {
2506
2506
  const shouldParseFees = parseFee || parseFees;
2507
2507
  const fees = this.safeList(order, 'fees', []);
2508
2508
  let trades = [];
2509
+ const isTriggerOrSLTpOrder = ((this.safeString(order, 'triggerPrice') !== undefined || (this.safeString(order, 'stopLossPrice') !== undefined)) || (this.safeString(order, 'takeProfitPrice') !== undefined));
2509
2510
  if (parseFilled || parseCost || shouldParseFees) {
2510
2511
  const rawTrades = this.safeValue(order, 'trades', trades);
2511
2512
  const oldNumber = this.number;
@@ -2708,7 +2709,7 @@ class Exchange {
2708
2709
  let postOnly = this.safeValue(order, 'postOnly');
2709
2710
  // timeInForceHandling
2710
2711
  if (timeInForce === undefined) {
2711
- if (this.safeString(order, 'type') === 'market') {
2712
+ if (!isTriggerOrSLTpOrder && (this.safeString(order, 'type') === 'market')) {
2712
2713
  timeInForce = 'IOC';
2713
2714
  }
2714
2715
  // allow postOnly override
@@ -3674,6 +3675,13 @@ class Exchange {
3674
3675
  }
3675
3676
  return [value, params];
3676
3677
  }
3678
+ handleParamString2(params, paramName1, paramName2, defaultValue = undefined) {
3679
+ const value = this.safeString2(params, paramName1, paramName2, defaultValue);
3680
+ if (value !== undefined) {
3681
+ params = this.omit(params, [paramName1, paramName2]);
3682
+ }
3683
+ return [value, params];
3684
+ }
3677
3685
  handleParamInteger(params, paramName, defaultValue = undefined) {
3678
3686
  const value = this.safeInteger(params, paramName, defaultValue);
3679
3687
  if (value !== undefined) {
@@ -3681,6 +3689,13 @@ class Exchange {
3681
3689
  }
3682
3690
  return [value, params];
3683
3691
  }
3692
+ handleParamInteger2(params, paramName1, paramName2, defaultValue = undefined) {
3693
+ const value = this.safeInteger2(params, paramName1, paramName2, defaultValue);
3694
+ if (value !== undefined) {
3695
+ params = this.omit(params, [paramName1, paramName2]);
3696
+ }
3697
+ return [value, params];
3698
+ }
3684
3699
  resolvePath(path, params) {
3685
3700
  return [
3686
3701
  this.implodeParams(path, params),
@@ -3824,7 +3839,7 @@ class Exchange {
3824
3839
  await this.cancelOrder(id, symbol);
3825
3840
  return await this.createOrder(symbol, type, side, amount, price, params);
3826
3841
  }
3827
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
3842
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
3828
3843
  await this.cancelOrderWs(id, symbol);
3829
3844
  return await this.createOrderWs(symbol, type, side, amount, price, params);
3830
3845
  }
@@ -4100,29 +4115,13 @@ class Exchange {
4100
4115
  }
4101
4116
  return [value, params];
4102
4117
  }
4103
- handleOptionAndParams2(params, methodName, methodName2, optionName, defaultValue = undefined) {
4104
- // This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
4105
- const defaultOptionName = 'default' + this.capitalize(optionName); // we also need to check the 'defaultXyzWhatever'
4106
- // check if params contain the key
4107
- let value = this.safeValue2(params, optionName, defaultOptionName);
4108
- if (value !== undefined) {
4109
- params = this.omit(params, [optionName, defaultOptionName]);
4110
- }
4111
- else {
4112
- // check if exchange has properties for this method
4113
- const exchangeWideMethodOptions = this.safeValue2(this.options, methodName, methodName2);
4114
- if (exchangeWideMethodOptions !== undefined) {
4115
- // check if the option is defined inside this method's props
4116
- value = this.safeValue2(exchangeWideMethodOptions, optionName, defaultOptionName);
4117
- }
4118
- if (value === undefined) {
4119
- // if it's still undefined, check if global exchange-wide option exists
4120
- value = this.safeValue2(this.options, optionName, defaultOptionName);
4121
- }
4122
- // if it's still undefined, use the default value
4123
- value = (value !== undefined) ? value : defaultValue;
4124
- }
4125
- return [value, params];
4118
+ handleOptionAndParams2(params, methodName1, optionName1, optionName2, defaultValue = undefined) {
4119
+ let value = undefined;
4120
+ [value, params] = this.handleOptionAndParams(params, methodName1, optionName1, defaultValue);
4121
+ // if still undefined, try optionName2
4122
+ let value2 = undefined;
4123
+ [value2, params] = this.handleOptionAndParams(params, methodName1, optionName2, value);
4124
+ return [value2, params];
4126
4125
  }
4127
4126
  handleOption(methodName, optionName, defaultValue = undefined) {
4128
4127
  // eslint-disable-next-line no-unused-vars
@@ -272,13 +272,18 @@ const _decimalToPrecision = (x, roundingMode, numPrecisionDigits, countingMode =
272
272
  return String.fromCharCode(...out);
273
273
  };
274
274
  function omitZero(stringNumber) {
275
- if (stringNumber === undefined || stringNumber === '') {
276
- return undefined;
275
+ try {
276
+ if (stringNumber === undefined || stringNumber === '') {
277
+ return undefined;
278
+ }
279
+ if (parseFloat(stringNumber) === 0) {
280
+ return undefined;
281
+ }
282
+ return stringNumber;
277
283
  }
278
- if (parseFloat(stringNumber) === 0) {
279
- return undefined;
284
+ catch (e) {
285
+ return stringNumber;
280
286
  }
281
- return stringNumber;
282
287
  }
283
288
  /* ------------------------------------------------------------------------ */
284
289
 
@@ -2214,6 +2214,10 @@ class bingx extends bingx$1 {
2214
2214
  const types = {
2215
2215
  'trigger_market': 'market',
2216
2216
  'trigger_limit': 'limit',
2217
+ 'stop_limit': 'limit',
2218
+ 'stop_market': 'market',
2219
+ 'take_profit_market': 'market',
2220
+ 'stop': 'limit',
2217
2221
  };
2218
2222
  return this.safeString(types, type, type);
2219
2223
  }
@@ -2417,6 +2421,25 @@ class bingx extends bingx$1 {
2417
2421
  // side: 'SELL'
2418
2422
  // }
2419
2423
  // }
2424
+ // stop loss order
2425
+ // {
2426
+ // "symbol": "ETH-USDT",
2427
+ // "orderId": "1792461744476422144",
2428
+ // "price": "2775.65",
2429
+ // "StopPrice": "2778.42",
2430
+ // "origQty": "0.032359",
2431
+ // "executedQty": "0",
2432
+ // "cummulativeQuoteQty": "0",
2433
+ // "status": "NEW",
2434
+ // "type": "TAKE_STOP_LIMIT",
2435
+ // "side": "SELL",
2436
+ // "time": "1716191156868",
2437
+ // "updateTime": "1716191156868",
2438
+ // "origQuoteOrderQty": "0",
2439
+ // "fee": "0",
2440
+ // "feeAsset": "USDT",
2441
+ // "clientOrderID": ""
2442
+ // }
2420
2443
  //
2421
2444
  const info = order;
2422
2445
  const newOrder = this.safeDict2(order, 'newOrderResponse', 'orderOpenResponse');
@@ -2451,26 +2474,39 @@ class bingx extends bingx$1 {
2451
2474
  let stopLoss = this.safeValue(order, 'stopLoss');
2452
2475
  let stopLossPrice = undefined;
2453
2476
  if ((stopLoss !== undefined) && (stopLoss !== '')) {
2454
- stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
2477
+ stopLossPrice = this.omitZero(this.safeString(stopLoss, 'stopLoss'));
2455
2478
  }
2456
2479
  if ((stopLoss !== undefined) && (typeof stopLoss !== 'number') && (stopLoss !== '')) {
2457
2480
  // stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
2458
2481
  if (typeof stopLoss === 'string') {
2459
2482
  stopLoss = this.parseJson(stopLoss);
2460
2483
  }
2461
- stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
2484
+ stopLossPrice = this.omitZero(this.safeString(stopLoss, 'stopPrice'));
2462
2485
  }
2463
2486
  let takeProfit = this.safeValue(order, 'takeProfit');
2464
2487
  let takeProfitPrice = undefined;
2465
2488
  if (takeProfit !== undefined && (takeProfit !== '')) {
2466
- takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
2489
+ takeProfitPrice = this.omitZero(this.safeString(takeProfit, 'takeProfit'));
2467
2490
  }
2468
2491
  if ((takeProfit !== undefined) && (typeof takeProfit !== 'number') && (takeProfit !== '')) {
2469
2492
  // takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
2470
2493
  if (typeof takeProfit === 'string') {
2471
2494
  takeProfit = this.parseJson(takeProfit);
2472
2495
  }
2473
- takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
2496
+ takeProfitPrice = this.omitZero(this.safeString(takeProfit, 'stopPrice'));
2497
+ }
2498
+ const rawType = this.safeStringLower2(order, 'type', 'o');
2499
+ const stopPrice = this.omitZero(this.safeString2(order, 'StopPrice', 'stopPrice'));
2500
+ let triggerPrice = stopPrice;
2501
+ if (stopPrice !== undefined) {
2502
+ if ((rawType.indexOf('stop') > -1) && (stopLossPrice === undefined)) {
2503
+ stopLossPrice = stopPrice;
2504
+ triggerPrice = undefined;
2505
+ }
2506
+ if ((rawType.indexOf('take') > -1) && (takeProfitPrice === undefined)) {
2507
+ takeProfitPrice = stopPrice;
2508
+ triggerPrice = undefined;
2509
+ }
2474
2510
  }
2475
2511
  return this.safeOrder({
2476
2512
  'info': info,
@@ -2481,13 +2517,13 @@ class bingx extends bingx$1 {
2481
2517
  'datetime': this.iso8601(timestamp),
2482
2518
  'lastTradeTimestamp': lastTradeTimestamp,
2483
2519
  'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
2484
- 'type': this.parseOrderType(this.safeStringLower2(order, 'type', 'o')),
2520
+ 'type': this.parseOrderType(rawType),
2485
2521
  'timeInForce': this.safeString(order, 'timeInForce'),
2486
2522
  'postOnly': undefined,
2487
2523
  'side': this.parseOrderSide(side),
2488
2524
  'price': this.safeString2(order, 'price', 'p'),
2489
- 'stopPrice': this.safeNumber(order, 'stopPrice'),
2490
- 'triggerPrice': this.safeNumber(order, 'stopPrice'),
2525
+ 'stopPrice': triggerPrice,
2526
+ 'triggerPrice': triggerPrice,
2491
2527
  'stopLossPrice': stopLossPrice,
2492
2528
  'takeProfitPrice': takeProfitPrice,
2493
2529
  'average': this.safeString2(order, 'avgPrice', 'ap'),
@@ -757,6 +757,7 @@ class bitget extends bitget$1 {
757
757
  'v2/earn/loan/borrow-history': 2,
758
758
  'v2/earn/loan/debts': 2,
759
759
  'v2/earn/loan/reduces': 2,
760
+ 'v2/earn/account/assets': 2,
760
761
  },
761
762
  'post': {
762
763
  'v2/earn/savings/subscribe': 2,
@@ -35,7 +35,7 @@ class bitmart extends bitmart$1 {
35
35
  'borrowIsolatedMargin': true,
36
36
  'cancelAllOrders': true,
37
37
  'cancelOrder': true,
38
- 'cancelOrders': false,
38
+ 'cancelOrders': true,
39
39
  'createMarketBuyOrderWithCost': true,
40
40
  'createMarketOrderWithCost': false,
41
41
  'createMarketSellOrderWithCost': false,
@@ -179,7 +179,7 @@ class bitmart extends bitmart$1 {
179
179
  'spot/v2/orders': 5,
180
180
  'spot/v1/trades': 5,
181
181
  // newer order endpoint
182
- 'spot/v2/trades': 5,
182
+ 'spot/v2/trades': 4,
183
183
  'spot/v3/orders': 5,
184
184
  'spot/v2/order_detail': 1,
185
185
  // margin
@@ -223,6 +223,7 @@ class bitmart extends bitmart$1 {
223
223
  'spot/v4/query/history-orders': 5,
224
224
  'spot/v4/query/trades': 5,
225
225
  'spot/v4/query/order-trades': 5,
226
+ 'spot/v4/cancel_orders': 3,
226
227
  // newer endpoint
227
228
  'spot/v3/cancel_order': 1,
228
229
  'spot/v2/batch_orders': 1,
@@ -2672,6 +2673,68 @@ class bitmart extends bitmart$1 {
2672
2673
  const order = this.parseOrder(id, market);
2673
2674
  return this.extend(order, { 'id': id });
2674
2675
  }
2676
+ async cancelOrders(ids, symbol = undefined, params = {}) {
2677
+ /**
2678
+ * @method
2679
+ * @name bitmart#cancelOrders
2680
+ * @description cancel multiple orders
2681
+ * @see https://developer-pro.bitmart.com/en/spot/#cancel-batch-order-v4-signed
2682
+ * @param {string[]} ids order ids
2683
+ * @param {string} symbol unified symbol of the market the order was made in
2684
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2685
+ * @param {string[]} [params.clientOrderIds] client order ids
2686
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2687
+ */
2688
+ if (symbol === undefined) {
2689
+ throw new errors.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
2690
+ }
2691
+ await this.loadMarkets();
2692
+ const market = this.market(symbol);
2693
+ if (!market['spot']) {
2694
+ throw new errors.NotSupported(this.id + ' cancelOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted');
2695
+ }
2696
+ const clientOrderIds = this.safeList(params, 'clientOrderIds');
2697
+ params = this.omit(params, ['clientOrderIds']);
2698
+ const request = {
2699
+ 'symbol': market['id'],
2700
+ };
2701
+ if (clientOrderIds !== undefined) {
2702
+ request['clientOrderIds'] = clientOrderIds;
2703
+ }
2704
+ else {
2705
+ request['orderIds'] = ids;
2706
+ }
2707
+ const response = await this.privatePostSpotV4CancelOrders(this.extend(request, params));
2708
+ //
2709
+ // {
2710
+ // "message": "OK",
2711
+ // "code": 1000,
2712
+ // "trace": "c4edbce860164203954f7c3c81d60fc6.309.17022669632770001",
2713
+ // "data": {
2714
+ // "successIds": [
2715
+ // "213055379155243012"
2716
+ // ],
2717
+ // "failIds": [],
2718
+ // "totalCount": 1,
2719
+ // "successCount": 1,
2720
+ // "failedCount": 0
2721
+ // }
2722
+ // }
2723
+ //
2724
+ const data = this.safeDict(response, 'data', {});
2725
+ const allOrders = [];
2726
+ const successIds = this.safeList(data, 'successIds', []);
2727
+ for (let i = 0; i < successIds.length; i++) {
2728
+ const id = successIds[i];
2729
+ allOrders.push(this.safeOrder({ 'id': id, 'status': 'canceled' }, market));
2730
+ }
2731
+ const failIds = this.safeList(data, 'failIds', []);
2732
+ for (let i = 0; i < failIds.length; i++) {
2733
+ const id = failIds[i];
2734
+ allOrders.push(this.safeOrder({ 'id': id, 'status': 'failed' }, market));
2735
+ }
2736
+ return allOrders;
2737
+ }
2675
2738
  async cancelAllOrders(symbol = undefined, params = {}) {
2676
2739
  /**
2677
2740
  * @method
@@ -2486,14 +2486,14 @@ class bybit extends bybit$1 {
2486
2486
  throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
2487
2487
  }
2488
2488
  await this.loadMarkets();
2489
- if (limit === undefined) {
2490
- limit = 200;
2491
- }
2492
2489
  let paginate = false;
2493
2490
  [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2494
2491
  if (paginate) {
2495
2492
  return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 200);
2496
2493
  }
2494
+ if (limit === undefined) {
2495
+ limit = 200;
2496
+ }
2497
2497
  const request = {
2498
2498
  // 'category': '', // Product type. linear,inverse
2499
2499
  // 'symbol': '', // Symbol name
@@ -2978,7 +2978,7 @@ class coinbase extends coinbase$1 {
2978
2978
  const marketId = this.safeString(order, 'product_id');
2979
2979
  const symbol = this.safeSymbol(marketId, market, '-');
2980
2980
  if (symbol !== undefined) {
2981
- market = this.market(symbol);
2981
+ market = this.safeMarket(symbol, market);
2982
2982
  }
2983
2983
  const orderConfiguration = this.safeDict(order, 'order_configuration', {});
2984
2984
  const limitGTC = this.safeDict(orderConfiguration, 'limit_limit_gtc');
@@ -444,11 +444,16 @@ class coinex extends coinex$1 {
444
444
  'fetchDepositAddress': {
445
445
  'fillResponseFromRequest': true,
446
446
  },
447
- 'accountsById': {
447
+ 'accountsByType': {
448
448
  'spot': 'SPOT',
449
449
  'margin': 'MARGIN',
450
450
  'swap': 'FUTURES',
451
451
  },
452
+ 'accountsById': {
453
+ 'SPOT': 'spot',
454
+ 'MARGIN': 'margin',
455
+ 'FUTURES': 'swap',
456
+ },
452
457
  'networks': {
453
458
  'BEP20': 'BSC',
454
459
  'TRX': 'TRC20',
@@ -4901,9 +4906,9 @@ class coinex extends coinex$1 {
4901
4906
  await this.loadMarkets();
4902
4907
  const currency = this.currency(code);
4903
4908
  const amountToPrecision = this.currencyToPrecision(code, amount);
4904
- const accountsById = this.safeDict(this.options, 'accountsById', {});
4905
- const fromId = this.safeString(accountsById, fromAccount, fromAccount);
4906
- const toId = this.safeString(accountsById, toAccount, toAccount);
4909
+ const accountsByType = this.safeDict(this.options, 'accountsById', {});
4910
+ const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
4911
+ const toId = this.safeString(accountsByType, toAccount, toAccount);
4907
4912
  const request = {
4908
4913
  'ccy': currency['id'],
4909
4914
  'amount': amountToPrecision,
@@ -4940,6 +4945,8 @@ class coinex extends coinex$1 {
4940
4945
  '0': 'ok',
4941
4946
  'SUCCESS': 'ok',
4942
4947
  'OK': 'ok',
4948
+ 'finished': 'ok',
4949
+ 'FINISHED': 'ok',
4943
4950
  };
4944
4951
  return this.safeString(statuses, status, status);
4945
4952
  }
@@ -4965,31 +4972,29 @@ class coinex extends coinex$1 {
4965
4972
  * @method
4966
4973
  * @name coinex#fetchTransfers
4967
4974
  * @description fetch a history of internal transfers made on an account
4968
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account025_margin_transfer_history
4969
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account024_contract_transfer_history
4975
+ * @see https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
4970
4976
  * @param {string} code unified currency code of the currency transferred
4971
4977
  * @param {int} [since] the earliest time in ms to fetch transfers for
4972
- * @param {int} [limit] the maximum number of transfers structures to retrieve
4978
+ * @param {int} [limit] the maximum number of transfer structures to retrieve
4973
4979
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4980
+ * @param {string} [params.marginMode] 'cross' or 'isolated' for fetching transfers to and from your margin account
4974
4981
  * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
4975
4982
  */
4976
4983
  await this.loadMarkets();
4977
- let currency = undefined;
4978
- const request = {
4979
- 'page': 1,
4980
- // 'limit': limit,
4981
- // 'asset': 'USDT',
4982
- // 'start_time': since,
4983
- // 'end_time': 1515806440,
4984
- // 'transfer_type': 'transfer_in', // transfer_in: from Spot to Swap Account, transfer_out: from Swap to Spot Account
4984
+ if (code === undefined) {
4985
+ throw new errors.ArgumentsRequired(this.id + ' fetchTransfers() requires a code argument');
4986
+ }
4987
+ const currency = this.currency(code);
4988
+ let request = {
4989
+ 'ccy': currency['id'],
4985
4990
  };
4986
- const page = this.safeInteger(params, 'page');
4987
- if (page !== undefined) {
4988
- request['page'] = page;
4991
+ let marginMode = undefined;
4992
+ [marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
4993
+ if (marginMode !== undefined) {
4994
+ request['transfer_type'] = 'MARGIN';
4989
4995
  }
4990
- if (code !== undefined) {
4991
- currency = this.currency(code);
4992
- request['asset'] = currency['id'];
4996
+ else {
4997
+ request['transfer_type'] = 'FUTURES';
4993
4998
  }
4994
4999
  if (since !== undefined) {
4995
5000
  request['start_time'] = since;
@@ -4997,66 +5002,30 @@ class coinex extends coinex$1 {
4997
5002
  if (limit !== undefined) {
4998
5003
  request['limit'] = limit;
4999
5004
  }
5000
- else {
5001
- request['limit'] = 100;
5002
- }
5003
- params = this.omit(params, 'page');
5004
- let marginMode = undefined;
5005
- [marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
5006
- let response = undefined;
5007
- if (marginMode !== undefined) {
5008
- response = await this.v1PrivateGetMarginTransferHistory(this.extend(request, params));
5009
- }
5010
- else {
5011
- response = await this.v1PrivateGetContractTransferHistory(this.extend(request, params));
5012
- }
5013
- //
5014
- // Swap
5005
+ [request, params] = this.handleUntilOption('end_time', request, params);
5006
+ const response = await this.v2PrivateGetAssetsTransferHistory(this.extend(request, params));
5015
5007
  //
5016
5008
  // {
5017
- // "code": 0,
5018
- // "data": {
5019
- // "records": [
5020
- // {
5021
- // "amount": "10",
5022
- // "asset": "USDT",
5023
- // "transfer_type": "transfer_out",
5024
- // "created_at": 1651633422
5025
- // },
5026
- // ],
5027
- // "total": 5
5009
+ // "data": [
5010
+ // {
5011
+ // "created_at": 1715848480646,
5012
+ // "from_account_type": "SPOT",
5013
+ // "to_account_type": "FUTURES",
5014
+ // "ccy": "USDT",
5015
+ // "amount": "10",
5016
+ // "status": "finished"
5017
+ // },
5018
+ // ],
5019
+ // "pagination": {
5020
+ // "total": 8,
5021
+ // "has_next": false
5028
5022
  // },
5029
- // "message": "Success"
5030
- // }
5031
- //
5032
- // Margin
5033
- //
5034
- // {
5035
5023
  // "code": 0,
5036
- // "data": {
5037
- // "records": [
5038
- // {
5039
- // "id": 7580062,
5040
- // "updated_at": 1653684379,
5041
- // "user_id": 3620173,
5042
- // "from_account_id": 0,
5043
- // "to_account_id": 1,
5044
- // "asset": "BTC",
5045
- // "amount": "0.00160829",
5046
- // "balance": "0.00160829",
5047
- // "transfer_type": "IN",
5048
- // "status": "SUCCESS",
5049
- // "created_at": 1653684379
5050
- // }
5051
- // ],
5052
- // "total": 1
5053
- // },
5054
- // "message": "Success"
5024
+ // "message": "OK"
5055
5025
  // }
5056
5026
  //
5057
- const data = this.safeValue(response, 'data', {});
5058
- const transfers = this.safeList(data, 'records', []);
5059
- return this.parseTransfers(transfers, currency, since, limit);
5027
+ const data = this.safeList(response, 'data', []);
5028
+ return this.parseTransfers(data, currency, since, limit);
5060
5029
  }
5061
5030
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
5062
5031
  /**