ccxt 4.4.21 → 4.4.23

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 (86) hide show
  1. package/README.md +112 -111
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/coincatch.js +9 -0
  5. package/dist/cjs/src/alpaca.js +1 -0
  6. package/dist/cjs/src/base/Exchange.js +21 -0
  7. package/dist/cjs/src/bigone.js +3 -0
  8. package/dist/cjs/src/binance.js +172 -44
  9. package/dist/cjs/src/bitfinex.js +4 -0
  10. package/dist/cjs/src/bitflyer.js +58 -0
  11. package/dist/cjs/src/bitget.js +77 -0
  12. package/dist/cjs/src/bitrue.js +3 -0
  13. package/dist/cjs/src/bybit.js +80 -2
  14. package/dist/cjs/src/cex.js +1307 -1381
  15. package/dist/cjs/src/coinbase.js +1 -1
  16. package/dist/cjs/src/coinbaseexchange.js +3 -0
  17. package/dist/cjs/src/coincatch.js +5370 -0
  18. package/dist/cjs/src/coinex.js +63 -1
  19. package/dist/cjs/src/cryptocom.js +1 -1
  20. package/dist/cjs/src/gate.js +103 -3
  21. package/dist/cjs/src/htx.js +1 -7
  22. package/dist/cjs/src/hyperliquid.js +10 -8
  23. package/dist/cjs/src/kucoin.js +27 -59
  24. package/dist/cjs/src/latoken.js +6 -0
  25. package/dist/cjs/src/mexc.js +1 -1
  26. package/dist/cjs/src/oceanex.js +2 -0
  27. package/dist/cjs/src/okcoin.js +1 -0
  28. package/dist/cjs/src/okx.js +74 -0
  29. package/dist/cjs/src/poloniex.js +5 -0
  30. package/dist/cjs/src/pro/coincatch.js +1554 -0
  31. package/js/ccxt.d.ts +9 -3
  32. package/js/ccxt.js +6 -2
  33. package/js/src/abstract/binance.d.ts +21 -0
  34. package/js/src/abstract/binancecoinm.d.ts +21 -0
  35. package/js/src/abstract/binanceus.d.ts +21 -0
  36. package/js/src/abstract/binanceusdm.d.ts +21 -0
  37. package/js/src/abstract/bitflyer.d.ts +1 -0
  38. package/js/src/abstract/bitget.d.ts +3 -0
  39. package/js/src/abstract/cex.d.ts +28 -29
  40. package/js/src/abstract/coincatch.d.ts +97 -0
  41. package/js/src/abstract/coincatch.js +11 -0
  42. package/js/src/abstract/gate.d.ts +5 -0
  43. package/js/src/abstract/gateio.d.ts +5 -0
  44. package/js/src/abstract/kucoin.d.ts +1 -0
  45. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  46. package/js/src/abstract/okx.d.ts +1 -0
  47. package/js/src/alpaca.js +1 -0
  48. package/js/src/base/Exchange.d.ts +8 -2
  49. package/js/src/base/Exchange.js +21 -0
  50. package/js/src/base/types.d.ts +8 -0
  51. package/js/src/bigone.js +3 -0
  52. package/js/src/binance.d.ts +3 -1
  53. package/js/src/binance.js +172 -44
  54. package/js/src/bitfinex.js +4 -0
  55. package/js/src/bitflyer.d.ts +3 -1
  56. package/js/src/bitflyer.js +58 -0
  57. package/js/src/bitget.d.ts +3 -1
  58. package/js/src/bitget.js +77 -0
  59. package/js/src/bitrue.js +3 -0
  60. package/js/src/bybit.d.ts +3 -1
  61. package/js/src/bybit.js +80 -2
  62. package/js/src/cex.d.ts +34 -20
  63. package/js/src/cex.js +1308 -1382
  64. package/js/src/coinbase.js +1 -1
  65. package/js/src/coinbaseexchange.js +3 -0
  66. package/js/src/coincatch.d.ts +130 -0
  67. package/js/src/coincatch.js +5371 -0
  68. package/js/src/coinex.d.ts +1 -0
  69. package/js/src/coinex.js +63 -1
  70. package/js/src/cryptocom.js +1 -1
  71. package/js/src/gate.d.ts +2 -0
  72. package/js/src/gate.js +103 -3
  73. package/js/src/htx.js +1 -7
  74. package/js/src/hyperliquid.js +10 -8
  75. package/js/src/kucoin.d.ts +0 -1
  76. package/js/src/kucoin.js +27 -59
  77. package/js/src/latoken.js +6 -0
  78. package/js/src/mexc.js +1 -1
  79. package/js/src/oceanex.js +2 -0
  80. package/js/src/okcoin.js +1 -0
  81. package/js/src/okx.d.ts +3 -1
  82. package/js/src/okx.js +74 -0
  83. package/js/src/poloniex.js +5 -0
  84. package/js/src/pro/coincatch.d.ts +57 -0
  85. package/js/src/pro/coincatch.js +1555 -0
  86. package/package.json +1 -1
@@ -104,6 +104,7 @@ export default class coinex extends Exchange {
104
104
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
105
105
  parseLeverage(leverage: Dict, market?: Market): Leverage;
106
106
  fetchPositionHistory(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
107
+ closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
107
108
  handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
108
109
  nonce(): number;
109
110
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
package/js/src/coinex.js CHANGED
@@ -48,6 +48,8 @@ export default class coinex extends Exchange {
48
48
  'cancelAllOrders': true,
49
49
  'cancelOrder': true,
50
50
  'cancelOrders': true,
51
+ 'closeAllPositions': false,
52
+ 'closePosition': true,
51
53
  'createDepositAddress': true,
52
54
  'createMarketBuyOrderWithCost': true,
53
55
  'createMarketOrderWithCost': false,
@@ -1775,7 +1777,7 @@ export default class coinex extends Exchange {
1775
1777
  // "stop_id": 117180138153
1776
1778
  // }
1777
1779
  //
1778
- // Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders
1780
+ // Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders, closePosition
1779
1781
  //
1780
1782
  // {
1781
1783
  // "amount": "0.0001",
@@ -5698,6 +5700,66 @@ export default class coinex extends Exchange {
5698
5700
  const positions = this.parsePositions(records);
5699
5701
  return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
5700
5702
  }
5703
+ async closePosition(symbol, side = undefined, params = {}) {
5704
+ /**
5705
+ * @method
5706
+ * @name coinex#closePosition
5707
+ * @description closes an open position for a market
5708
+ * @see https://docs.coinex.com/api/v2/futures/position/http/close-position
5709
+ * @param {string} symbol unified CCXT market symbol
5710
+ * @param {string} [side] buy or sell, not used by coinex
5711
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5712
+ * @param {string} params.type required by coinex, one of: limit, market, maker_only, ioc or fok, default is *market*
5713
+ * @param {string} [params.price] the price to fulfill the order, ignored in market orders
5714
+ * @param {string} [params.amount] the amount to trade in units of the base currency
5715
+ * @param {string} [params.clientOrderId] the client id of the order
5716
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5717
+ */
5718
+ await this.loadMarkets();
5719
+ const market = this.market(symbol);
5720
+ const type = this.safeString(params, 'type', 'market');
5721
+ const request = {
5722
+ 'market': market['id'],
5723
+ 'market_type': 'FUTURES',
5724
+ 'type': type,
5725
+ };
5726
+ const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
5727
+ if (clientOrderId !== undefined) {
5728
+ request['client_id'] = clientOrderId;
5729
+ }
5730
+ params = this.omit(params, 'clientOrderId');
5731
+ const response = await this.v2PrivatePostFuturesClosePosition(this.extend(request, params));
5732
+ //
5733
+ // {
5734
+ // "code": 0,
5735
+ // "data": {
5736
+ // "amount": "0.0001",
5737
+ // "client_id": "",
5738
+ // "created_at": 1729666043969,
5739
+ // "fee": "0.00335858",
5740
+ // "fee_ccy": "USDT",
5741
+ // "filled_amount": "0.0001",
5742
+ // "filled_value": "6.717179",
5743
+ // "last_filled_amount": "0.0001",
5744
+ // "last_filled_price": "67171.79",
5745
+ // "maker_fee_rate": "0",
5746
+ // "market": "BTCUSDT",
5747
+ // "market_type": "FUTURES",
5748
+ // "order_id": 155477479761,
5749
+ // "price": "0",
5750
+ // "realized_pnl": "-0.001823",
5751
+ // "side": "sell",
5752
+ // "taker_fee_rate": "0.0005",
5753
+ // "type": "market",
5754
+ // "unfilled_amount": "0",
5755
+ // "updated_at": 1729666043969
5756
+ // },
5757
+ // "message": "OK"
5758
+ // }
5759
+ //
5760
+ const data = this.safeDict(response, 'data', {});
5761
+ return this.parseOrder(data, market);
5762
+ }
5701
5763
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
5702
5764
  /**
5703
5765
  * @ignore
@@ -1618,7 +1618,7 @@ export default class cryptocom extends Exchange {
1618
1618
  let paginate = false;
1619
1619
  [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1620
1620
  if (paginate) {
1621
- return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
1621
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, 100);
1622
1622
  }
1623
1623
  const request = {};
1624
1624
  let market = undefined;
package/js/src/gate.d.ts CHANGED
@@ -7,6 +7,8 @@ import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenI
7
7
  export default class gate extends Exchange {
8
8
  describe(): any;
9
9
  setSandboxMode(enable: boolean): void;
10
+ loadUnifiedStatus(params?: {}): Promise<void>;
11
+ upgradeUnifiedTradeAccount(params?: {}): Promise<any>;
10
12
  createExpiredOptionMarket(symbol: string): MarketInterface;
11
13
  safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
12
14
  fetchMarkets(params?: {}): Promise<Market[]>;
package/js/src/gate.js CHANGED
@@ -324,10 +324,17 @@ export default class gate extends Exchange {
324
324
  'interest_records': 20 / 15,
325
325
  'estimate_rate': 20 / 15,
326
326
  'currency_discount_tiers': 20 / 15,
327
+ 'risk_units': 20 / 15,
328
+ 'unified_mode': 20 / 15,
329
+ 'loan_margin_tiers': 20 / 15,
327
330
  },
328
331
  'post': {
329
332
  'account_mode': 20 / 15,
330
- 'loans': 200 / 15, // 15r/10s cost = 20 / 1.5 = 13.33
333
+ 'loans': 200 / 15,
334
+ 'portfolio_calculator': 20 / 15,
335
+ },
336
+ 'put': {
337
+ 'unified_mode': 20 / 15,
331
338
  },
332
339
  },
333
340
  'spot': {
@@ -629,6 +636,7 @@ export default class gate extends Exchange {
629
636
  },
630
637
  'options': {
631
638
  'sandboxMode': false,
639
+ 'unifiedAccount': undefined,
632
640
  'createOrder': {
633
641
  'expiration': 86400, // for conditional orders
634
642
  },
@@ -890,6 +898,37 @@ export default class gate extends Exchange {
890
898
  super.setSandboxMode(enable);
891
899
  this.options['sandboxMode'] = enable;
892
900
  }
901
+ async loadUnifiedStatus(params = {}) {
902
+ /**
903
+ * @method
904
+ * @name gate#isUnifiedEnabled
905
+ * @description returns unifiedAccount so the user can check if the unified account is enabled
906
+ * @see https://www.gate.io/docs/developers/apiv4/#get-account-detail
907
+ * @returns {boolean} true or false if the enabled unified account is enabled or not and sets the unifiedAccount option if it is undefined
908
+ */
909
+ const unifiedAccount = this.safeBool(this.options, 'unifiedAccount');
910
+ if (unifiedAccount === undefined) {
911
+ const response = await this.privateAccountGetDetail(params);
912
+ //
913
+ // {
914
+ // "user_id": 10406147,
915
+ // "ip_whitelist": [],
916
+ // "currency_pairs": [],
917
+ // "key": {
918
+ // "mode": 1
919
+ // },
920
+ // "tier": 0,
921
+ // "tier_expire_time": "0001-01-01T00:00:00Z",
922
+ // "copy_trading_role": 0
923
+ // }
924
+ //
925
+ const result = this.safeDict(response, 'key', {});
926
+ this.options['unifiedAccount'] = this.safeInteger(result, 'mode') === 2;
927
+ }
928
+ }
929
+ async upgradeUnifiedTradeAccount(params = {}) {
930
+ return await this.privateUnifiedPutUnifiedMode(params);
931
+ }
893
932
  createExpiredOptionMarket(symbol) {
894
933
  // support expired option contracts
895
934
  const quote = 'USDT';
@@ -1579,6 +1618,9 @@ export default class gate extends Exchange {
1579
1618
  if (apiBackup !== undefined) {
1580
1619
  return undefined;
1581
1620
  }
1621
+ if (this.checkRequiredCredentials(false)) {
1622
+ await this.loadUnifiedStatus();
1623
+ }
1582
1624
  const response = await this.publicSpotGetCurrencies(params);
1583
1625
  //
1584
1626
  // {
@@ -2681,10 +2723,14 @@ export default class gate extends Exchange {
2681
2723
  * @param {string} [params.settle] 'btc' or 'usdt' - settle currency for perpetual swap and future - default="usdt" for swap and "btc" for future
2682
2724
  * @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
2683
2725
  * @param {string} [params.symbol] margin only - unified ccxt symbol
2726
+ * @param {boolean} [params.unifiedAccount] default false, set to true for fetching the unified account balance
2684
2727
  */
2685
2728
  await this.loadMarkets();
2729
+ await this.loadUnifiedStatus();
2686
2730
  const symbol = this.safeString(params, 'symbol');
2687
2731
  params = this.omit(params, 'symbol');
2732
+ let isUnifiedAccount = false;
2733
+ [isUnifiedAccount, params] = this.handleOptionAndParams(params, 'fetchBalance', 'unifiedAccount');
2688
2734
  const [type, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
2689
2735
  const [request, requestParams] = this.prepareRequest(undefined, type, query);
2690
2736
  const [marginMode, requestQuery] = this.getMarginMode(false, requestParams);
@@ -2693,7 +2739,10 @@ export default class gate extends Exchange {
2693
2739
  request['currency_pair'] = market['id'];
2694
2740
  }
2695
2741
  let response = undefined;
2696
- if (type === 'spot') {
2742
+ if (isUnifiedAccount) {
2743
+ response = await this.privateUnifiedGetAccounts(this.extend(request, params));
2744
+ }
2745
+ else if (type === 'spot') {
2697
2746
  if (marginMode === 'spot') {
2698
2747
  response = await this.privateSpotGetAccounts(this.extend(request, requestQuery));
2699
2748
  }
@@ -2867,12 +2916,63 @@ export default class gate extends Exchange {
2867
2916
  // "orders_limit": 10
2868
2917
  // }
2869
2918
  //
2919
+ // unified
2920
+ //
2921
+ // {
2922
+ // "user_id": 10001,
2923
+ // "locked": false,
2924
+ // "balances": {
2925
+ // "ETH": {
2926
+ // "available": "0",
2927
+ // "freeze": "0",
2928
+ // "borrowed": "0.075393666654",
2929
+ // "negative_liab": "0",
2930
+ // "futures_pos_liab": "0",
2931
+ // "equity": "1016.1",
2932
+ // "total_freeze": "0",
2933
+ // "total_liab": "0"
2934
+ // },
2935
+ // "POINT": {
2936
+ // "available": "9999999999.017023138734",
2937
+ // "freeze": "0",
2938
+ // "borrowed": "0",
2939
+ // "negative_liab": "0",
2940
+ // "futures_pos_liab": "0",
2941
+ // "equity": "12016.1",
2942
+ // "total_freeze": "0",
2943
+ // "total_liab": "0"
2944
+ // },
2945
+ // "USDT": {
2946
+ // "available": "0.00000062023",
2947
+ // "freeze": "0",
2948
+ // "borrowed": "0",
2949
+ // "negative_liab": "0",
2950
+ // "futures_pos_liab": "0",
2951
+ // "equity": "16.1",
2952
+ // "total_freeze": "0",
2953
+ // "total_liab": "0"
2954
+ // }
2955
+ // },
2956
+ // "total": "230.94621713",
2957
+ // "borrowed": "161.66395521",
2958
+ // "total_initial_margin": "1025.0524665088",
2959
+ // "total_margin_balance": "3382495.944473949183",
2960
+ // "total_maintenance_margin": "205.01049330176",
2961
+ // "total_initial_margin_rate": "3299.827135672679",
2962
+ // "total_maintenance_margin_rate": "16499.135678363399",
2963
+ // "total_available_margin": "3381470.892007440383",
2964
+ // "unified_account_total": "3381470.892007440383",
2965
+ // "unified_account_total_liab": "0",
2966
+ // "unified_account_total_equity": "100016.1",
2967
+ // "leverage": "2"
2968
+ // }
2969
+ //
2870
2970
  const result = {
2871
2971
  'info': response,
2872
2972
  };
2873
2973
  const isolated = marginMode === 'margin';
2874
2974
  let data = response;
2875
- if ('balances' in data) { // True for cross_margin
2975
+ if ('balances' in data) { // True for cross_margin and unified
2876
2976
  const flatBalances = [];
2877
2977
  const balances = this.safeValue(data, 'balances', []);
2878
2978
  // inject currency and create an artificial balance object
package/js/src/htx.js CHANGED
@@ -5116,13 +5116,7 @@ export default class htx extends Exchange {
5116
5116
  let cost = undefined;
5117
5117
  let amount = undefined;
5118
5118
  if ((type !== undefined) && (type.indexOf('market') >= 0)) {
5119
- // for market orders amount is in quote currency, meaning it is the cost
5120
- if (side === 'sell') {
5121
- cost = this.safeString(order, 'field-cash-amount');
5122
- }
5123
- else {
5124
- cost = this.safeString(order, 'amount');
5125
- }
5119
+ cost = this.safeString(order, 'field-cash-amount');
5126
5120
  }
5127
5121
  else {
5128
5122
  amount = this.safeString2(order, 'volume', 'amount');
@@ -2230,15 +2230,17 @@ export default class hyperliquid extends Exchange {
2230
2230
  const leverage = this.safeDict(entry, 'leverage', {});
2231
2231
  const marginMode = this.safeString(leverage, 'type');
2232
2232
  const isIsolated = (marginMode === 'isolated');
2233
- let size = this.safeString(entry, 'szi');
2233
+ const rawSize = this.safeString(entry, 'szi');
2234
+ let size = rawSize;
2234
2235
  let side = undefined;
2235
2236
  if (size !== undefined) {
2236
- side = Precise.stringGt(size, '0') ? 'long' : 'short';
2237
+ side = Precise.stringGt(rawSize, '0') ? 'long' : 'short';
2237
2238
  size = Precise.stringAbs(size);
2238
2239
  }
2239
- const unrealizedPnl = this.safeNumber(entry, 'unrealizedPnl');
2240
- const initialMargin = this.safeNumber(entry, 'marginUsed');
2241
- const percentage = unrealizedPnl / initialMargin * 100;
2240
+ const rawUnrealizedPnl = this.safeString(entry, 'unrealizedPnl');
2241
+ const absRawUnrealizedPnl = Precise.stringAbs(rawUnrealizedPnl);
2242
+ const initialMargin = this.safeString(entry, 'marginUsed');
2243
+ const percentage = Precise.stringMul(Precise.stringDiv(absRawUnrealizedPnl, initialMargin), '100');
2242
2244
  return this.safePosition({
2243
2245
  'info': position,
2244
2246
  'id': undefined,
@@ -2248,7 +2250,7 @@ export default class hyperliquid extends Exchange {
2248
2250
  'isolated': isIsolated,
2249
2251
  'hedged': undefined,
2250
2252
  'side': side,
2251
- 'contracts': size,
2253
+ 'contracts': this.parseNumber(size),
2252
2254
  'contractSize': undefined,
2253
2255
  'entryPrice': this.safeNumber(entry, 'entryPx'),
2254
2256
  'markPrice': undefined,
@@ -2259,10 +2261,10 @@ export default class hyperliquid extends Exchange {
2259
2261
  'maintenanceMargin': undefined,
2260
2262
  'initialMarginPercentage': undefined,
2261
2263
  'maintenanceMarginPercentage': undefined,
2262
- 'unrealizedPnl': unrealizedPnl,
2264
+ 'unrealizedPnl': this.parseNumber(rawUnrealizedPnl),
2263
2265
  'liquidationPrice': this.safeNumber(entry, 'liquidationPx'),
2264
2266
  'marginMode': marginMode,
2265
- 'percentage': percentage,
2267
+ 'percentage': this.parseNumber(percentage),
2266
2268
  });
2267
2269
  }
2268
2270
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -62,7 +62,6 @@ export default class kucoin extends Exchange {
62
62
  parseTrade(trade: Dict, market?: Market): Trade;
63
63
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
64
64
  withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
65
- loadCurrencyPrecision(currency: any, networkCode?: Str): Promise<void>;
66
65
  parseTransactionStatus(status: Str): string;
67
66
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
68
67
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
package/js/src/kucoin.js CHANGED
@@ -291,6 +291,7 @@ export default class kucoin extends Exchange {
291
291
  // ws
292
292
  'bullet-private': 10,
293
293
  'position/update-user-leverage': 5,
294
+ 'deposit-address/create': 20,
294
295
  },
295
296
  'delete': {
296
297
  // account
@@ -710,6 +711,7 @@ export default class kucoin extends Exchange {
710
711
  'accounts/sub-transfer': 'v2',
711
712
  'accounts/inner-transfer': 'v2',
712
713
  'transfer-out': 'v3',
714
+ 'deposit-address/create': 'v3',
713
715
  // spot trading
714
716
  'oco/order': 'v3',
715
717
  // margin trading
@@ -721,6 +723,7 @@ export default class kucoin extends Exchange {
721
723
  'redeem': 'v3',
722
724
  'lend/purchase/update': 'v3',
723
725
  'position/update-user-leverage': 'v3',
726
+ 'withdrawals': 'v3',
724
727
  },
725
728
  'DELETE': {
726
729
  // account
@@ -786,7 +789,7 @@ export default class kucoin extends Exchange {
786
789
  'TLOS': 'tlos',
787
790
  'CFX': 'cfx',
788
791
  'ACA': 'aca',
789
- 'OPTIMISM': 'optimism',
792
+ 'OP': 'optimism',
790
793
  'ONT': 'ont',
791
794
  'GLMR': 'glmr',
792
795
  'CSPR': 'cspr',
@@ -1897,7 +1900,7 @@ export default class kucoin extends Exchange {
1897
1900
  /**
1898
1901
  * @method
1899
1902
  * @name kucoin#createDepositAddress
1900
- * @see https://docs.kucoin.com/#create-deposit-address
1903
+ * @see https://www.kucoin.com/docs/rest/funding/deposit/create-deposit-address-v3-
1901
1904
  * @description create a currency deposit address
1902
1905
  * @param {string} code unified currency code of the currency for the deposit address
1903
1906
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1912,12 +1915,24 @@ export default class kucoin extends Exchange {
1912
1915
  let networkCode = undefined;
1913
1916
  [networkCode, params] = this.handleNetworkCodeAndParams(params);
1914
1917
  if (networkCode !== undefined) {
1915
- request['chain'] = this.networkCodeToId(networkCode).toLowerCase();
1918
+ request['chain'] = this.networkCodeToId(networkCode); // docs mention "chain-name", but seems "chain-id" is used, like in "fetchDepositAddress"
1916
1919
  }
1917
- const response = await this.privatePostDepositAddresses(this.extend(request, params));
1920
+ const response = await this.privatePostDepositAddressCreate(this.extend(request, params));
1918
1921
  // {"code":"260000","msg":"Deposit address already exists."}
1919
- // BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}}
1920
- // BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}}
1922
+ //
1923
+ // {
1924
+ // "code": "200000",
1925
+ // "data": {
1926
+ // "address": "0x2336d1834faab10b2dac44e468f2627138417431",
1927
+ // "memo": null,
1928
+ // "chainId": "bsc",
1929
+ // "to": "MAIN",
1930
+ // "expirationDate": 0,
1931
+ // "currency": "BNB",
1932
+ // "chainName": "BEP20"
1933
+ // }
1934
+ // }
1935
+ //
1921
1936
  const data = this.safeDict(response, 'data', {});
1922
1937
  return this.parseDepositAddress(data, currency);
1923
1938
  }
@@ -1974,7 +1989,7 @@ export default class kucoin extends Exchange {
1974
1989
  return {
1975
1990
  'info': depositAddress,
1976
1991
  'currency': code,
1977
- 'network': this.networkIdToCode(this.safeString(depositAddress, 'chain')),
1992
+ 'network': this.networkIdToCode(this.safeString(depositAddress, 'chainId')),
1978
1993
  'address': address,
1979
1994
  'tag': this.safeString(depositAddress, 'memo'),
1980
1995
  };
@@ -3436,7 +3451,7 @@ export default class kucoin extends Exchange {
3436
3451
  * @method
3437
3452
  * @name kucoin#withdraw
3438
3453
  * @description make a withdrawal
3439
- * @see https://www.kucoin.com/docs/rest/funding/withdrawals/apply-withdraw
3454
+ * @see https://www.kucoin.com/docs/rest/funding/withdrawals/apply-withdraw-v3-
3440
3455
  * @param {string} code unified currency code
3441
3456
  * @param {float} amount the amount to withdraw
3442
3457
  * @param {string} address the address to withdraw to
@@ -3450,7 +3465,8 @@ export default class kucoin extends Exchange {
3450
3465
  const currency = this.currency(code);
3451
3466
  const request = {
3452
3467
  'currency': currency['id'],
3453
- 'address': address,
3468
+ 'toAddress': address,
3469
+ 'withdrawType': 'ADDRESS',
3454
3470
  // 'memo': tag,
3455
3471
  // 'isInner': false, // internal transfer or external withdrawal
3456
3472
  // 'remark': 'optional',
@@ -3464,8 +3480,7 @@ export default class kucoin extends Exchange {
3464
3480
  if (networkCode !== undefined) {
3465
3481
  request['chain'] = this.networkCodeToId(networkCode).toLowerCase();
3466
3482
  }
3467
- await this.loadCurrencyPrecision(currency, networkCode);
3468
- request['amount'] = this.currencyToPrecision(code, amount, networkCode);
3483
+ request['amount'] = parseFloat(this.currencyToPrecision(code, amount, networkCode));
3469
3484
  let includeFee = undefined;
3470
3485
  [includeFee, params] = this.handleOptionAndParams(params, 'withdraw', 'includeFee', false);
3471
3486
  if (includeFee) {
@@ -3473,7 +3488,7 @@ export default class kucoin extends Exchange {
3473
3488
  }
3474
3489
  const response = await this.privatePostWithdrawals(this.extend(request, params));
3475
3490
  //
3476
- // https://github.com/ccxt/ccxt/issues/5558
3491
+ // the id is inside "data"
3477
3492
  //
3478
3493
  // {
3479
3494
  // "code": 200000,
@@ -3485,53 +3500,6 @@ export default class kucoin extends Exchange {
3485
3500
  const data = this.safeDict(response, 'data', {});
3486
3501
  return this.parseTransaction(data, currency);
3487
3502
  }
3488
- async loadCurrencyPrecision(currency, networkCode = undefined) {
3489
- // as kucoin might not have network specific precisions defined in fetchCurrencies (because of webapi failure)
3490
- // we should check and refetch precision once-per-instance for that specific currency & network
3491
- // so avoids thorwing exceptions and burden to users
3492
- // Note: this needs to be executed only if networkCode was provided
3493
- if (networkCode !== undefined) {
3494
- const networks = currency['networks'];
3495
- const network = this.safeDict(networks, networkCode);
3496
- if (this.safeNumber(network, 'precision') !== undefined) {
3497
- // if precision exists, no need to refetch
3498
- return;
3499
- }
3500
- // otherwise try to fetch and store in instance
3501
- const request = {
3502
- 'currency': currency['id'],
3503
- 'chain': this.networkCodeToId(networkCode).toLowerCase(),
3504
- };
3505
- const response = await this.privateGetWithdrawalsQuotas(request);
3506
- //
3507
- // {
3508
- // "code": "200000",
3509
- // "data": {
3510
- // "currency": "USDT",
3511
- // "limitBTCAmount": "14.24094850",
3512
- // "usedBTCAmount": "0.00000000",
3513
- // "quotaCurrency": "USDT",
3514
- // "limitQuotaCurrencyAmount": "999999.00000000",
3515
- // "usedQuotaCurrencyAmount": "0",
3516
- // "remainAmount": "999999.0000",
3517
- // "availableAmount": "10.77545071",
3518
- // "withdrawMinFee": "1",
3519
- // "innerWithdrawMinFee": "0",
3520
- // "withdrawMinSize": "10",
3521
- // "isWithdrawEnabled": true,
3522
- // "precision": 4,
3523
- // "chain": "EOS",
3524
- // "reason": null,
3525
- // "lockedAmount": "0"
3526
- // }
3527
- // }
3528
- //
3529
- const data = this.safeDict(response, 'data', {});
3530
- const precision = this.parseNumber(this.parsePrecision(this.safeString(data, 'precision')));
3531
- const code = currency['code'];
3532
- this.currencies[code]['networks'][networkCode]['precision'] = precision;
3533
- }
3534
- }
3535
3503
  parseTransactionStatus(status) {
3536
3504
  const statuses = {
3537
3505
  'SUCCESS': 'ok',
package/js/src/latoken.js CHANGED
@@ -49,6 +49,12 @@ export default class latoken extends Exchange {
49
49
  'fetchDepositAddressesByNetwork': false,
50
50
  'fetchDepositsWithdrawals': true,
51
51
  'fetchDepositWithdrawFees': false,
52
+ 'fetchFundingHistory': false,
53
+ 'fetchFundingInterval': false,
54
+ 'fetchFundingIntervals': false,
55
+ 'fetchFundingRate': false,
56
+ 'fetchFundingRateHistory': false,
57
+ 'fetchFundingRates': false,
52
58
  'fetchIsolatedBorrowRate': false,
53
59
  'fetchIsolatedBorrowRates': false,
54
60
  'fetchMarginMode': false,
package/js/src/mexc.js CHANGED
@@ -82,7 +82,7 @@ export default class mexc extends Exchange {
82
82
  'fetchFundingIntervals': false,
83
83
  'fetchFundingRate': true,
84
84
  'fetchFundingRateHistory': true,
85
- 'fetchFundingRates': undefined,
85
+ 'fetchFundingRates': false,
86
86
  'fetchIndexOHLCV': true,
87
87
  'fetchIsolatedBorrowRate': false,
88
88
  'fetchIsolatedBorrowRates': false,
package/js/src/oceanex.js CHANGED
@@ -53,6 +53,8 @@ export default class oceanex extends Exchange {
53
53
  'fetchDepositAddress': 'emulated',
54
54
  'fetchDepositAddresses': undefined,
55
55
  'fetchDepositAddressesByNetwork': true,
56
+ 'fetchFundingRateHistory': false,
57
+ 'fetchFundingRates': false,
56
58
  'fetchIsolatedBorrowRate': false,
57
59
  'fetchIsolatedBorrowRates': false,
58
60
  'fetchMarkets': true,
package/js/src/okcoin.js CHANGED
@@ -54,6 +54,7 @@ export default class okcoin extends Exchange {
54
54
  'fetchFundingHistory': false,
55
55
  'fetchFundingRate': false,
56
56
  'fetchFundingRateHistory': false,
57
+ 'fetchFundingRates': false,
57
58
  'fetchLedger': true,
58
59
  'fetchMarkets': true,
59
60
  'fetchMyTrades': true,
package/js/src/okx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/okx.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option, MarginModification, TradingFeeInterface, Currencies, Conversion, CancellationRequest, Dict, Position, CrossBorrowRate, CrossBorrowRates, LeverageTier, int, LedgerEntry, FundingRate, DepositAddress } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option, MarginModification, TradingFeeInterface, Currencies, Conversion, CancellationRequest, Dict, Position, CrossBorrowRate, CrossBorrowRates, LeverageTier, int, LedgerEntry, FundingRate, DepositAddress, LongShortRatio } from './base/types.js';
3
3
  /**
4
4
  * @class okx
5
5
  * @augments Exchange
@@ -185,4 +185,6 @@ export default class okx extends Exchange {
185
185
  handleErrors(httpCode: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
186
186
  fetchMarginAdjustmentHistory(symbol?: Str, type?: Str, since?: Num, limit?: Num, params?: {}): Promise<MarginModification[]>;
187
187
  fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
188
+ fetchLongShortRatioHistory(symbol?: Str, timeframe?: Str, since?: Int, limit?: Int, params?: {}): Promise<LongShortRatio[]>;
189
+ parseLongShortRatio(info: Dict, market?: Market): LongShortRatio;
188
190
  }