ccxt 4.4.68 → 4.4.70

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 (51) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +0 -1
  5. package/dist/cjs/src/binance.js +20 -3
  6. package/dist/cjs/src/bitget.js +49 -335
  7. package/dist/cjs/src/bitstamp.js +2 -3
  8. package/dist/cjs/src/bybit.js +7 -0
  9. package/dist/cjs/src/coinbase.js +25 -9
  10. package/dist/cjs/src/cryptomus.js +214 -116
  11. package/dist/cjs/src/hyperliquid.js +19 -8
  12. package/dist/cjs/src/okx.js +4 -0
  13. package/dist/cjs/src/paradex.js +172 -4
  14. package/dist/cjs/src/phemex.js +2 -2
  15. package/dist/cjs/src/pro/bitget.js +40 -7
  16. package/dist/cjs/src/pro/bybit.js +86 -38
  17. package/dist/cjs/src/tradeogre.js +34 -11
  18. package/dist/cjs/src/whitebit.js +211 -1
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/bybit.d.ts +4 -0
  22. package/js/src/abstract/myokx.d.ts +3 -0
  23. package/js/src/abstract/okx.d.ts +3 -0
  24. package/js/src/abstract/paradex.d.ts +23 -0
  25. package/js/src/abstract/tradeogre.d.ts +2 -1
  26. package/js/src/base/Exchange.js +0 -1
  27. package/js/src/base/types.d.ts +2 -2
  28. package/js/src/binance.js +20 -3
  29. package/js/src/bitget.d.ts +0 -1
  30. package/js/src/bitget.js +49 -335
  31. package/js/src/bitstamp.js +2 -3
  32. package/js/src/bybit.js +7 -0
  33. package/js/src/coinbase.d.ts +0 -5
  34. package/js/src/coinbase.js +25 -9
  35. package/js/src/cryptomus.d.ts +127 -1
  36. package/js/src/cryptomus.js +214 -116
  37. package/js/src/hyperliquid.js +19 -8
  38. package/js/src/okx.d.ts +1 -0
  39. package/js/src/okx.js +4 -0
  40. package/js/src/paradex.d.ts +48 -1
  41. package/js/src/paradex.js +172 -4
  42. package/js/src/phemex.d.ts +1 -1
  43. package/js/src/phemex.js +2 -2
  44. package/js/src/pro/bitget.js +40 -7
  45. package/js/src/pro/bybit.d.ts +1 -0
  46. package/js/src/pro/bybit.js +86 -38
  47. package/js/src/tradeogre.d.ts +1 -0
  48. package/js/src/tradeogre.js +34 -11
  49. package/js/src/whitebit.d.ts +35 -1
  50. package/js/src/whitebit.js +211 -1
  51. package/package.json +1 -1
@@ -249,6 +249,8 @@ class bybit extends bybit$1 {
249
249
  // institutional lending
250
250
  'v5/ins-loan/product-infos': 5,
251
251
  'v5/ins-loan/ensure-tokens-convert': 5,
252
+ // earn
253
+ 'v5/earn/product': 5,
252
254
  },
253
255
  },
254
256
  'private': {
@@ -407,6 +409,9 @@ class bybit extends bybit$1 {
407
409
  'v5/broker/earnings-info': 5,
408
410
  'v5/broker/account-info': 5,
409
411
  'v5/broker/asset/query-sub-member-deposit-record': 10,
412
+ // earn
413
+ 'v5/earn/order': 5,
414
+ 'v5/earn/position': 5,
410
415
  },
411
416
  'post': {
412
417
  // spot
@@ -542,6 +547,8 @@ class bybit extends bybit$1 {
542
547
  'v5/broker/award/info': 5,
543
548
  'v5/broker/award/distribute-award': 5,
544
549
  'v5/broker/award/distribution-record': 5,
550
+ // earn
551
+ 'v5/earn/place-order': 5,
545
552
  },
546
553
  },
547
554
  },
@@ -325,6 +325,7 @@ class coinbase extends coinbase$1 {
325
325
  'INSUFFICIENT_FUND': errors.BadRequest,
326
326
  'PERMISSION_DENIED': errors.PermissionDenied,
327
327
  'INVALID_ARGUMENT': errors.BadRequest,
328
+ 'PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE': errors.InvalidOrder,
328
329
  },
329
330
  'broad': {
330
331
  'request timestamp expired': errors.InvalidNonce,
@@ -4267,6 +4268,7 @@ class coinbase extends coinbase$1 {
4267
4268
  'amount': this.numberToString(amount),
4268
4269
  'currency': code.toUpperCase(),
4269
4270
  'payment_method': id,
4271
+ 'commit': true, // otheriwse the deposit does not go through
4270
4272
  };
4271
4273
  const response = await this.v2PrivatePostAccountsAccountIdDeposits(this.extend(request, params));
4272
4274
  //
@@ -4887,11 +4889,6 @@ class coinbase extends coinbase$1 {
4887
4889
  const result = this.parsePortfolioDetails(response);
4888
4890
  return result;
4889
4891
  }
4890
- /**
4891
- * Parse a Coinbase portfolio JSON object and extract relevant trading information.
4892
- * @param {Dict} portfolioData The JSON response containing portfolio details
4893
- * @returns {any[]} List of dictionaries with parsed portfolio position data
4894
- */
4895
4892
  parsePortfolioDetails(portfolioData) {
4896
4893
  const breakdown = portfolioData['breakdown'];
4897
4894
  const portfolioInfo = this.safeDict(breakdown, 'portfolio', {});
@@ -5087,20 +5084,39 @@ class coinbase extends coinbase$1 {
5087
5084
  // ]
5088
5085
  // }
5089
5086
  // or
5090
- // {
5087
+ // {
5088
+ // "success": false,
5089
+ // "error_response": {
5091
5090
  // "error": "UNKNOWN_FAILURE_REASON",
5092
5091
  // "message": "",
5093
5092
  // "error_details": "",
5094
- // "preview_failure_reason": "PREVIEW_STOP_PRICE_BELOW_LAST_TRADE_PRICE"
5095
- // }
5093
+ // "preview_failure_reason": "PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE"
5094
+ // },
5095
+ // "order_configuration": {
5096
+ // "stop_limit_stop_limit_gtc": {
5097
+ // "base_size": "0.0001",
5098
+ // "limit_price": "2000",
5099
+ // "stop_price": "2005",
5100
+ // "stop_direction": "STOP_DIRECTION_STOP_DOWN",
5101
+ // "reduce_only": false
5102
+ // }
5103
+ // }
5104
+ // }
5096
5105
  //
5097
5106
  let errorCode = this.safeString(response, 'error');
5098
5107
  if (errorCode !== undefined) {
5099
- const errorMessage = this.safeString2(response, 'error_description', 'preview_failure_reason');
5108
+ const errorMessage = this.safeString2(response, 'error_description', 'error');
5100
5109
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
5101
5110
  this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
5102
5111
  throw new errors.ExchangeError(feedback);
5103
5112
  }
5113
+ const errorResponse = this.safeDict(response, 'error_response');
5114
+ if (errorResponse !== undefined) {
5115
+ const errorMessageInner = this.safeString2(errorResponse, 'preview_failure_reason', 'preview_failure_reason');
5116
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorMessageInner, feedback);
5117
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessageInner, feedback);
5118
+ throw new errors.ExchangeError(feedback);
5119
+ }
5104
5120
  const errors$1 = this.safeList(response, 'errors');
5105
5121
  if (errors$1 !== undefined) {
5106
5122
  if (Array.isArray(errors$1)) {
@@ -19,7 +19,7 @@ class cryptomus extends cryptomus$1 {
19
19
  'name': 'Cryptomus',
20
20
  'countries': ['CA'],
21
21
  'rateLimit': 100,
22
- 'version': 'v1',
22
+ 'version': 'v2',
23
23
  'certified': false,
24
24
  'pro': false,
25
25
  'has': {
@@ -101,7 +101,7 @@ class cryptomus extends cryptomus$1 {
101
101
  'fetchTime': false,
102
102
  'fetchTrades': true,
103
103
  'fetchTradingFee': false,
104
- 'fetchTradingFees': false,
104
+ 'fetchTradingFees': true,
105
105
  'fetchTransactions': false,
106
106
  'fetchTransfers': false,
107
107
  'fetchWithdrawals': false,
@@ -224,15 +224,15 @@ class cryptomus extends cryptomus$1 {
224
224
  'features': {},
225
225
  });
226
226
  }
227
+ /**
228
+ * @method
229
+ * @name cryptomus#fetchMarkets
230
+ * @description retrieves data on all markets for the exchange
231
+ * @see https://doc.cryptomus.com/personal/market-cap/tickers
232
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
233
+ * @returns {object[]} an array of objects representing market data
234
+ */
227
235
  async fetchMarkets(params = {}) {
228
- /**
229
- * @method
230
- * @name cryptomus#fetchMarkets
231
- * @description retrieves data on all markets for the exchange
232
- * @see https://doc.cryptomus.com/personal/market-cap/tickers
233
- * @param {object} [params] extra parameters specific to the exchange API endpoint
234
- * @returns {object[]} an array of objects representing market data
235
- */
236
236
  const response = await this.publicGetV2UserApiExchangeMarkets(params);
237
237
  //
238
238
  // {
@@ -334,15 +334,15 @@ class cryptomus extends cryptomus$1 {
334
334
  'info': market,
335
335
  });
336
336
  }
337
+ /**
338
+ * @method
339
+ * @name cryptomus#fetchCurrencies
340
+ * @description fetches all available currencies on an exchange
341
+ * @see https://doc.cryptomus.com/personal/market-cap/assets
342
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
343
+ * @returns {object} an associative dictionary of currencies
344
+ */
337
345
  async fetchCurrencies(params = {}) {
338
- /**
339
- * @method
340
- * @name cryptomus#fetchCurrencies
341
- * @description fetches all available currencies on an exchange
342
- * @see https://doc.cryptomus.com/personal/market-cap/assets
343
- * @param {object} [params] extra parameters specific to the exchange API endpoint
344
- * @returns {object} an associative dictionary of currencies
345
- */
346
346
  const response = await this.publicGetV1ExchangeMarketAssets(params);
347
347
  //
348
348
  // {
@@ -474,16 +474,16 @@ class cryptomus extends cryptomus$1 {
474
474
  }
475
475
  return result;
476
476
  }
477
+ /**
478
+ * @method
479
+ * @name cryptomus#fetchTickers
480
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
481
+ * @see https://doc.cryptomus.com/personal/market-cap/tickers
482
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
483
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
484
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
485
+ */
477
486
  async fetchTickers(symbols = undefined, params = {}) {
478
- /**
479
- * @method
480
- * @name cryptomus#fetchTickers
481
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
482
- * @see https://doc.cryptomus.com/personal/market-cap/tickers
483
- * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
484
- * @param {object} [params] extra parameters specific to the exchange API endpoint
485
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
486
- */
487
487
  await this.loadMarkets();
488
488
  symbols = this.marketSymbols(symbols);
489
489
  const response = await this.publicGetV1ExchangeMarketTickers(params);
@@ -538,18 +538,18 @@ class cryptomus extends cryptomus$1 {
538
538
  'info': ticker,
539
539
  }, market);
540
540
  }
541
+ /**
542
+ * @method
543
+ * @name cryptomus#fetchOrderBook
544
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
545
+ * @see https://doc.cryptomus.com/personal/market-cap/orderbook
546
+ * @param {string} symbol unified symbol of the market to fetch the order book for
547
+ * @param {int} [limit] the maximum amount of order book entries to return
548
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
549
+ * @param {int} [params.level] 0 or 1 or 2 or 3 or 4 or 5 - the level of volume
550
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
551
+ */
541
552
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
542
- /**
543
- * @method
544
- * @name cryptomus#fetchOrderBook
545
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
546
- * @see https://doc.cryptomus.com/personal/market-cap/orderbook
547
- * @param {string} symbol unified symbol of the market to fetch the order book for
548
- * @param {int} [limit] the maximum amount of order book entries to return
549
- * @param {object} [params] extra parameters specific to the exchange API endpoint
550
- * @param {int} [params.level] 0 or 1 or 2 or 3 or 4 or 5 - the level of volume
551
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
552
- */
553
553
  await this.loadMarkets();
554
554
  const market = this.market(symbol);
555
555
  const request = {
@@ -582,18 +582,18 @@ class cryptomus extends cryptomus$1 {
582
582
  const timestamp = this.safeTimestamp(data, 'timestamp');
583
583
  return this.parseOrderBook(data, symbol, timestamp, 'bids', 'asks', 'price', 'quantity');
584
584
  }
585
+ /**
586
+ * @method
587
+ * @name cryptomus#fetchTrades
588
+ * @description get the list of most recent trades for a particular symbol
589
+ * @see https://doc.cryptomus.com/personal/market-cap/trades
590
+ * @param {string} symbol unified symbol of the market to fetch trades for
591
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
592
+ * @param {int} [limit] the maximum amount of trades to fetch (maximum value is 100)
593
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
594
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
595
+ */
585
596
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
586
- /**
587
- * @method
588
- * @name cryptomus#fetchTrades
589
- * @description get the list of most recent trades for a particular symbol
590
- * @see https://doc.cryptomus.com/personal/market-cap/trades
591
- * @param {string} symbol unified symbol of the market to fetch trades for
592
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
593
- * @param {int} [limit] the maximum amount of trades to fetch (maximum value is 100)
594
- * @param {object} [params] extra parameters specific to the exchange API endpoint
595
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
596
- */
597
597
  await this.loadMarkets();
598
598
  const market = this.market(symbol);
599
599
  const request = {
@@ -648,15 +648,15 @@ class cryptomus extends cryptomus$1 {
648
648
  'info': trade,
649
649
  }, market);
650
650
  }
651
+ /**
652
+ * @method
653
+ * @name cryptomus#fetchBalance
654
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
655
+ * @see https://doc.cryptomus.com/personal/converts/balance
656
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
657
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
658
+ */
651
659
  async fetchBalance(params = {}) {
652
- /**
653
- * @method
654
- * @name cryptomus#fetchBalance
655
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
656
- * @see https://doc.cryptomus.com/personal/converts/balance
657
- * @param {object} [params] extra parameters specific to the exchange API endpoint
658
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
659
- */
660
660
  await this.loadMarkets();
661
661
  const request = {};
662
662
  const response = await this.privateGetV2UserApiExchangeAccountBalance(this.extend(request, params));
@@ -696,24 +696,23 @@ class cryptomus extends cryptomus$1 {
696
696
  }
697
697
  return this.safeBalance(result);
698
698
  }
699
+ /**
700
+ * @method
701
+ * @name cryptomus#createOrder
702
+ * @description create a trade order
703
+ * @see https://doc.cryptomus.com/personal/exchange/market-order-creation
704
+ * @see https://doc.cryptomus.com/personal/exchange/limit-order-creation
705
+ * @param {string} symbol unified symbol of the market to create an order in
706
+ * @param {string} type 'market' or 'limit' or for spot
707
+ * @param {string} side 'buy' or 'sell'
708
+ * @param {float} amount how much of you want to trade in units of the base currency
709
+ * @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders (only for limit orders)
710
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
711
+ * @param {float} [params.cost] *market buy only* the quote quantity that can be used as an alternative for the amount
712
+ * @param {string} [params.clientOrderId] a unique identifier for the order (optional)
713
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
714
+ */
699
715
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
700
- /**
701
- * @method
702
- * @name cryptomus#createOrder
703
- * @description create a trade order
704
- * @see https://doc.cryptomus.com/personal/exchange/market-order-creation
705
- * @see https://doc.cryptomus.com/personal/exchange/limit-order-creation
706
- * @param {string} symbol unified symbol of the market to create an order in
707
- * @param {string} type 'market' or 'limit' or for spot
708
- * @param {string} side 'buy' or 'sell'
709
- * @param {float} amount how much of you want to trade in units of the base currency
710
- * @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders (only for limit orders)
711
- * @param {object} [params] extra parameters specific to the exchange API endpoint
712
- * @param {float} [params.cost] *market buy only* the quote quantity that can be used as an alternative for the amount
713
- * @param {object} [params] extra parameters specific to the exchange API endpoint
714
- * @param {string} [params.clientOrderId] a unique identifier for the order (optional)
715
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
716
- */
717
716
  await this.loadMarkets();
718
717
  const market = this.market(symbol);
719
718
  const request = {
@@ -772,17 +771,17 @@ class cryptomus extends cryptomus$1 {
772
771
  //
773
772
  return this.parseOrder(response, market);
774
773
  }
774
+ /**
775
+ * @method
776
+ * @name cryptomus#cancelOrder
777
+ * @description cancels an open limit order
778
+ * @see https://doc.cryptomus.com/personal/exchange/limit-order-cancellation
779
+ * @param {string} id order id
780
+ * @param {string} symbol unified symbol of the market the order was made in (not used in cryptomus)
781
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
782
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
783
+ */
775
784
  async cancelOrder(id, symbol = undefined, params = {}) {
776
- /**
777
- * @method
778
- * @name cryptomus#cancelOrder
779
- * @description cancels an open limit order
780
- * @see https://doc.cryptomus.com/personal/exchange/limit-order-cancellation
781
- * @param {string} id order id
782
- * @param {string} symbol unified symbol of the market the order was made in (not used in cryptomus)
783
- * @param {object} [params] extra parameters specific to the exchange API endpoint
784
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
785
- */
786
785
  await this.loadMarkets();
787
786
  const request = {};
788
787
  request['orderId'] = id;
@@ -794,23 +793,23 @@ class cryptomus extends cryptomus$1 {
794
793
  //
795
794
  return response;
796
795
  }
796
+ /**
797
+ * @method
798
+ * @name cryptomus#fetchOrders
799
+ * @description fetches information on multiple orders made by the user
800
+ * @see https://doc.cryptomus.com/personal/exchange/history-of-completed-orders
801
+ * @param {string} symbol unified market symbol of the market orders were made in (not used in cryptomus)
802
+ * @param {int} [since] the earliest time in ms to fetch orders for (not used in cryptomus)
803
+ * @param {int} [limit] the maximum number of order structures to retrieve (not used in cryptomus)
804
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
805
+ * @param {string} [params.direction] order direction 'buy' or 'sell'
806
+ * @param {string} [params.order_id] order id
807
+ * @param {string} [params.client_order_id] client order id
808
+ * @param {string} [params.limit] A special parameter that sets the maximum number of records the request will return
809
+ * @param {string} [params.offset] A special parameter that sets the number of records from the beginning of the list
810
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
811
+ */
797
812
  async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
798
- /**
799
- * @method
800
- * @name cryptomus#fetchOrders
801
- * @description fetches information on multiple orders made by the user
802
- * @see https://doc.cryptomus.com/personal/exchange/history-of-completed-orders
803
- * @param {string} symbol unified market symbol of the market orders were made in (not used in cryptomus)
804
- * @param {int} [since] the earliest time in ms to fetch orders for (not used in cryptomus)
805
- * @param {int} [limit] the maximum number of order structures to retrieve (not used in cryptomus)
806
- * @param {object} [params] extra parameters specific to the exchange API endpoint
807
- * @param {string} [params.direction] order direction 'buy' or 'sell'
808
- * @param {string} [params.order_id] order id
809
- * @param {string} [params.client_order_id] client order id
810
- * @param {string} [params.limit] A special parameter that sets the maximum number of records the request will return
811
- * @param {string} [params.offset] A special parameter that sets the number of records from the beginning of the list
812
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
813
- */
814
813
  await this.loadMarkets();
815
814
  const request = {};
816
815
  let market = undefined;
@@ -869,23 +868,23 @@ class cryptomus extends cryptomus$1 {
869
868
  }
870
869
  return orders;
871
870
  }
871
+ /**
872
+ * @method
873
+ * @name cryptomus#fetchOpenOrders
874
+ * @description fetch all unfilled currently open orders
875
+ * @see https://doc.cryptomus.com/personal/exchange/list-of-active-orders
876
+ * @param {string} symbol unified market symbol
877
+ * @param {int} [since] the earliest time in ms to fetch open orders for (not used in cryptomus)
878
+ * @param {int} [limit] the maximum number of open orders structures to retrieve (not used in cryptomus)
879
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
880
+ * @param {string} [params.direction] order direction 'buy' or 'sell'
881
+ * @param {string} [params.order_id] order id
882
+ * @param {string} [params.client_order_id] client order id
883
+ * @param {string} [params.limit] A special parameter that sets the maximum number of records the request will return
884
+ * @param {string} [params.offset] A special parameter that sets the number of records from the beginning of the list
885
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
886
+ */
872
887
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
873
- /**
874
- * @method
875
- * @name cryptomus#fetchOpenOrders
876
- * @description fetch all unfilled currently open orders
877
- * @see https://doc.cryptomus.com/personal/exchange/list-of-active-orders
878
- * @param {string} symbol unified market symbol
879
- * @param {int} [since] the earliest time in ms to fetch open orders for (not used in cryptomus)
880
- * @param {int} [limit] the maximum number of open orders structures to retrieve (not used in cryptomus)
881
- * @param {object} [params] extra parameters specific to the exchange API endpoint
882
- * @param {string} [params.direction] order direction 'buy' or 'sell'
883
- * @param {string} [params.order_id] order id
884
- * @param {string} [params.client_order_id] client order id
885
- * @param {string} [params.limit] A special parameter that sets the maximum number of records the request will return
886
- * @param {string} [params.offset] A special parameter that sets the number of records from the beginning of the list
887
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
888
- */
889
888
  await this.loadMarkets();
890
889
  let market = undefined;
891
890
  if (symbol !== undefined) {
@@ -1038,6 +1037,105 @@ class cryptomus extends cryptomus$1 {
1038
1037
  };
1039
1038
  return this.safeString(statuses, status, status);
1040
1039
  }
1040
+ /**
1041
+ * @method
1042
+ * @name cryptomus#fetchTradingFees
1043
+ * @description fetch the trading fees for multiple markets
1044
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-fees
1045
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1046
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
1047
+ */
1048
+ async fetchTradingFees(params = {}) {
1049
+ const response = await this.privateGetV2UserApiExchangeAccountTariffs(params);
1050
+ //
1051
+ // {
1052
+ // result: {
1053
+ // equivalent_currency_code: 'USD',
1054
+ // current_tariff_step: {
1055
+ // step: '0',
1056
+ // from_turnover: '0.00000000',
1057
+ // maker_percent: '0.08',
1058
+ // taker_percent: '0.1'
1059
+ // },
1060
+ // tariff_steps: [
1061
+ // {
1062
+ // step: '0',
1063
+ // from_turnover: '0.00000000',
1064
+ // maker_percent: '0.08',
1065
+ // taker_percent: '0.1'
1066
+ // },
1067
+ // {
1068
+ // step: '1',
1069
+ // from_turnover: '100001.00000000',
1070
+ // maker_percent: '0.06',
1071
+ // taker_percent: '0.095'
1072
+ // },
1073
+ // {
1074
+ // step: '2',
1075
+ // from_turnover: '250001.00000000',
1076
+ // maker_percent: '0.055',
1077
+ // taker_percent: '0.085'
1078
+ // },
1079
+ // {
1080
+ // step: '3',
1081
+ // from_turnover: '500001.00000000',
1082
+ // maker_percent: '0.05',
1083
+ // taker_percent: '0.075'
1084
+ // },
1085
+ // {
1086
+ // step: '4',
1087
+ // from_turnover: '2500001.00000000',
1088
+ // maker_percent: '0.04',
1089
+ // taker_percent: '0.07'
1090
+ // }
1091
+ // ],
1092
+ // daily_turnover: '0.00000000',
1093
+ // monthly_turnover: '77.52062617',
1094
+ // circulation_funds: '25.48900443'
1095
+ // }
1096
+ // }
1097
+ //
1098
+ const data = this.safeDict(response, 'result', {});
1099
+ const currentFeeTier = this.safeDict(data, 'current_tariff_step', {});
1100
+ let makerFee = this.safeString(currentFeeTier, 'maker_percent');
1101
+ let takerFee = this.safeString(currentFeeTier, 'taker_percent');
1102
+ makerFee = Precise["default"].stringDiv(makerFee, '100');
1103
+ takerFee = Precise["default"].stringDiv(takerFee, '100');
1104
+ const feeTiers = this.safeList(data, 'tariff_steps', []);
1105
+ const result = {};
1106
+ const tiers = this.parseFeeTiers(feeTiers);
1107
+ for (let i = 0; i < this.symbols.length; i++) {
1108
+ const symbol = this.symbols[i];
1109
+ result[symbol] = {
1110
+ 'info': response,
1111
+ 'symbol': symbol,
1112
+ 'maker': this.parseNumber(makerFee),
1113
+ 'taker': this.parseNumber(takerFee),
1114
+ 'percentage': true,
1115
+ 'tierBased': true,
1116
+ 'tiers': tiers,
1117
+ };
1118
+ }
1119
+ return result;
1120
+ }
1121
+ parseFeeTiers(feeTiers, market = undefined) {
1122
+ const takerFees = [];
1123
+ const makerFees = [];
1124
+ for (let i = 0; i < feeTiers.length; i++) {
1125
+ const tier = feeTiers[i];
1126
+ const turnover = this.safeNumber(tier, 'from_turnover');
1127
+ let taker = this.safeString(tier, 'taker_percent');
1128
+ let maker = this.safeString(tier, 'maker_percent');
1129
+ maker = Precise["default"].stringDiv(maker, '100');
1130
+ taker = Precise["default"].stringDiv(taker, '100');
1131
+ makerFees.push([turnover, this.parseNumber(maker)]);
1132
+ takerFees.push([turnover, this.parseNumber(taker)]);
1133
+ }
1134
+ return {
1135
+ 'maker': makerFees,
1136
+ 'taker': takerFees,
1137
+ };
1138
+ }
1041
1139
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1042
1140
  const endpoint = this.implodeParams(path, params);
1043
1141
  params = this.omit(params, this.extractParams(path));
@@ -840,7 +840,7 @@ class hyperliquid extends hyperliquid$1 {
840
840
  'info': response,
841
841
  'USDC': {
842
842
  'total': this.safeNumber(data, 'accountValue'),
843
- 'free': this.safeNumber(response, 'withdrawable'),
843
+ 'used': this.safeNumber(data, 'totalMarginUsed'),
844
844
  },
845
845
  };
846
846
  const timestamp = this.safeInteger(response, 'time');
@@ -1810,12 +1810,13 @@ class hyperliquid extends hyperliquid$1 {
1810
1810
  const isTrigger = (stopLossPrice || takeProfitPrice);
1811
1811
  const reduceOnly = this.safeBool(orderParams, 'reduceOnly', false);
1812
1812
  orderParams = this.omit(orderParams, ['slippage', 'timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'clientOrderId', 'client_id', 'postOnly', 'reduceOnly']);
1813
- let px = price.toString();
1813
+ let px = this.numberToString(price);
1814
1814
  if (isMarket) {
1815
- px = (isBuy) ? Precise["default"].stringMul(price.toString(), Precise["default"].stringAdd('1', slippage)) : Precise["default"].stringMul(price.toString(), Precise["default"].stringSub('1', slippage));
1815
+ px = (isBuy) ? Precise["default"].stringMul(px, Precise["default"].stringAdd('1', slippage)) : Precise["default"].stringMul(px, Precise["default"].stringSub('1', slippage));
1816
+ px = this.priceToPrecision(symbol, px);
1816
1817
  }
1817
1818
  else {
1818
- px = this.priceToPrecision(symbol, price.toString());
1819
+ px = this.priceToPrecision(symbol, px);
1819
1820
  }
1820
1821
  const sz = this.amountToPrecision(symbol, amount);
1821
1822
  const orderType = {};
@@ -2327,6 +2328,11 @@ class hyperliquid extends hyperliquid$1 {
2327
2328
  }
2328
2329
  const totalAmount = this.safeString2(entry, 'origSz', 'totalSz');
2329
2330
  const remaining = this.safeString(entry, 'sz');
2331
+ const tif = this.safeStringUpper(entry, 'tif');
2332
+ let postOnly = undefined;
2333
+ if (tif !== undefined) {
2334
+ postOnly = (tif === 'ALO');
2335
+ }
2330
2336
  return this.safeOrder({
2331
2337
  'info': order,
2332
2338
  'id': this.safeString(entry, 'oid'),
@@ -2337,8 +2343,8 @@ class hyperliquid extends hyperliquid$1 {
2337
2343
  'lastUpdateTimestamp': this.safeInteger(order, 'statusTimestamp'),
2338
2344
  'symbol': symbol,
2339
2345
  'type': this.parseOrderType(this.safeStringLower(entry, 'orderType')),
2340
- 'timeInForce': this.safeStringUpper(entry, 'tif'),
2341
- 'postOnly': undefined,
2346
+ 'timeInForce': tif,
2347
+ 'postOnly': postOnly,
2342
2348
  'reduceOnly': this.safeBool(entry, 'reduceOnly'),
2343
2349
  'side': side,
2344
2350
  'price': this.safeString(entry, 'limitPx'),
@@ -2460,6 +2466,11 @@ class hyperliquid extends hyperliquid$1 {
2460
2466
  side = (side === 'A') ? 'sell' : 'buy';
2461
2467
  }
2462
2468
  const fee = this.safeString(trade, 'fee');
2469
+ let takerOrMaker = undefined;
2470
+ const crossed = this.safeBool(trade, 'crossed');
2471
+ if (crossed !== undefined) {
2472
+ takerOrMaker = crossed ? 'taker' : 'maker';
2473
+ }
2463
2474
  return this.safeTrade({
2464
2475
  'info': trade,
2465
2476
  'timestamp': timestamp,
@@ -2469,7 +2480,7 @@ class hyperliquid extends hyperliquid$1 {
2469
2480
  'order': this.safeString(trade, 'oid'),
2470
2481
  'type': undefined,
2471
2482
  'side': side,
2472
- 'takerOrMaker': undefined,
2483
+ 'takerOrMaker': takerOrMaker,
2473
2484
  'price': price,
2474
2485
  'amount': amount,
2475
2486
  'cost': undefined,
@@ -3043,7 +3054,7 @@ class hyperliquid extends hyperliquid$1 {
3043
3054
  'tagTo': undefined,
3044
3055
  'tagFrom': undefined,
3045
3056
  'type': undefined,
3046
- 'amount': this.safeInteger(delta, 'usdc'),
3057
+ 'amount': this.safeNumber(delta, 'usdc'),
3047
3058
  'currency': undefined,
3048
3059
  'status': this.safeString(transaction, 'status'),
3049
3060
  'updated': undefined,
@@ -307,7 +307,9 @@ class okx extends okx$1 {
307
307
  'trade/easy-convert-currency-list': 20,
308
308
  'trade/easy-convert-history': 20,
309
309
  'trade/one-click-repay-currency-list': 20,
310
+ 'trade/one-click-repay-currency-list-v2': 20,
310
311
  'trade/one-click-repay-history': 20,
312
+ 'trade/one-click-repay-history-v2': 20,
311
313
  'trade/account-rate-limit': 1,
312
314
  // asset
313
315
  'asset/currencies': 5 / 3,
@@ -464,6 +466,7 @@ class okx extends okx$1 {
464
466
  'trade/cancel-advance-algos': 1,
465
467
  'trade/easy-convert': 20,
466
468
  'trade/one-click-repay': 20,
469
+ 'trade/one-click-repay-v2': 20,
467
470
  'trade/mass-cancel': 4,
468
471
  'trade/cancel-all-after': 10,
469
472
  // asset
@@ -3159,6 +3162,7 @@ class okx extends okx$1 {
3159
3162
  * @param {string} [params.trailingPercent] the percent to trail away from the current market price
3160
3163
  * @param {string} [params.tpOrdKind] 'condition' or 'limit', the default is 'condition'
3161
3164
  * @param {bool} [params.hedged] *swap and future only* true for hedged mode, false for one way mode
3165
+ * @param {string} [params.marginMode] 'cross' or 'isolated', the default is 'cross'
3162
3166
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3163
3167
  */
3164
3168
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {