ccxt 4.4.67 → 4.4.69

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.
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.4.67';
203
+ const version = '4.4.69';
204
204
  Exchange["default"].ccxtVersion = version;
205
205
  const exchanges = {
206
206
  'ace': ace,
@@ -4231,7 +4231,7 @@ class Exchange {
4231
4231
  return await this.fetch(request['url'], request['method'], request['headers'], request['body']);
4232
4232
  }
4233
4233
  catch (e) {
4234
- if (e instanceof errors.NetworkError) {
4234
+ if (e instanceof errors.OperationFailed) {
4235
4235
  if (i < retries) {
4236
4236
  if (this.verbose) {
4237
4237
  this.log('Request failed with the error: ' + e.toString() + ', retrying ' + (i + 1).toString() + ' of ' + retries.toString() + '...');
@@ -4239,10 +4239,12 @@ class Exchange {
4239
4239
  if ((retryDelay !== undefined) && (retryDelay !== 0)) {
4240
4240
  await this.sleep(retryDelay);
4241
4241
  }
4242
- // continue; //check this
4242
+ }
4243
+ else {
4244
+ throw e;
4243
4245
  }
4244
4246
  }
4245
- if (i >= retries) {
4247
+ else {
4246
4248
  throw e;
4247
4249
  }
4248
4250
  }
@@ -12116,8 +12116,25 @@ class binance extends binance$1 {
12116
12116
  let query = undefined;
12117
12117
  // handle batchOrders
12118
12118
  if ((path === 'batchOrders') && ((method === 'POST') || (method === 'PUT'))) {
12119
- const batchOrders = this.safeValue(params, 'batchOrders');
12120
- const queryBatch = (this.json(batchOrders));
12119
+ const batchOrders = this.safeList(params, 'batchOrders');
12120
+ let checkedBatchOrders = batchOrders;
12121
+ if (method === 'POST' && api === 'fapiPrivate') {
12122
+ // check broker id if batchOrders are called with fapiPrivatePostBatchOrders
12123
+ checkedBatchOrders = [];
12124
+ for (let i = 0; i < batchOrders.length; i++) {
12125
+ const batchOrder = batchOrders[i];
12126
+ let newClientOrderId = this.safeString(batchOrder, 'newClientOrderId');
12127
+ if (newClientOrderId === undefined) {
12128
+ const defaultId = 'x-xcKtGhcu'; // batchOrders can not be spot or margin
12129
+ const broker = this.safeDict(this.options, 'broker', {});
12130
+ const brokerId = this.safeString(broker, 'future', defaultId);
12131
+ newClientOrderId = brokerId + this.uuid22();
12132
+ batchOrder['newClientOrderId'] = newClientOrderId;
12133
+ }
12134
+ checkedBatchOrders.push(batchOrder);
12135
+ }
12136
+ }
12137
+ const queryBatch = (this.json(checkedBatchOrders));
12121
12138
  params['batchOrders'] = queryBatch;
12122
12139
  }
12123
12140
  const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
@@ -1675,7 +1675,7 @@ class bitrue extends bitrue$1 {
1675
1675
  const tickers = {};
1676
1676
  for (let i = 0; i < data.length; i++) {
1677
1677
  const ticker = this.safeDict(data, i, {});
1678
- const market = this.market(this.safeValue(ticker, 'symbol'));
1678
+ const market = this.safeMarket(this.safeString(ticker, 'symbol'));
1679
1679
  tickers[market['id']] = ticker;
1680
1680
  }
1681
1681
  return this.parseTickers(tickers, symbols);
@@ -1307,10 +1307,9 @@ class bitstamp extends bitstamp$1 {
1307
1307
  }
1308
1308
  parseTradingFees(fees) {
1309
1309
  const result = { 'info': fees };
1310
- const symbols = this.symbols;
1311
- for (let i = 0; i < symbols.length; i++) {
1312
- const symbol = symbols[i];
1310
+ for (let i = 0; i < fees.length; i++) {
1313
1311
  const fee = this.parseTradingFee(fees[i]);
1312
+ const symbol = fee['symbol'];
1314
1313
  result[symbol] = fee;
1315
1314
  }
1316
1315
  return result;
@@ -9304,7 +9304,7 @@ class bybit extends bybit$1 {
9304
9304
  else {
9305
9305
  feedback = this.id + ' ' + body;
9306
9306
  }
9307
- if (body.indexOf('Withdraw address chain or destination tag are not equal')) {
9307
+ if (body.indexOf('Withdraw address chain or destination tag are not equal') > -1) {
9308
9308
  feedback = feedback + '; You might also need to ensure the address is whitelisted';
9309
9309
  }
9310
9310
  this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
@@ -4267,6 +4267,7 @@ class coinbase extends coinbase$1 {
4267
4267
  'amount': this.numberToString(amount),
4268
4268
  'currency': code.toUpperCase(),
4269
4269
  'payment_method': id,
4270
+ 'commit': true, // otheriwse the deposit does not go through
4270
4271
  };
4271
4272
  const response = await this.v2PrivatePostAccountsAccountIdDeposits(this.extend(request, params));
4272
4273
  //
@@ -4305,7 +4306,8 @@ class coinbase extends coinbase$1 {
4305
4306
  // }
4306
4307
  // }
4307
4308
  //
4308
- const data = this.safeDict(response, 'data', {});
4309
+ // https://github.com/ccxt/ccxt/issues/25484
4310
+ const data = this.safeDict2(response, 'data', 'transfer', {});
4309
4311
  return this.parseTransaction(data);
4310
4312
  }
4311
4313
  /**
@@ -4373,7 +4375,8 @@ class coinbase extends coinbase$1 {
4373
4375
  // }
4374
4376
  // }
4375
4377
  //
4376
- const data = this.safeDict(response, 'data', {});
4378
+ // https://github.com/ccxt/ccxt/issues/25484
4379
+ const data = this.safeDict2(response, 'data', 'transfer', {});
4377
4380
  return this.parseTransaction(data);
4378
4381
  }
4379
4382
  /**
@@ -4867,6 +4870,71 @@ class coinbase extends coinbase$1 {
4867
4870
  }
4868
4871
  return result;
4869
4872
  }
4873
+ /**
4874
+ * @method
4875
+ * @name coinbase#fetchPortfolioDetails
4876
+ * @description Fetch details for a specific portfolio by UUID
4877
+ * @see https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getportfolios
4878
+ * @param {string} portfolioUuid The unique identifier of the portfolio to fetch
4879
+ * @param {Dict} [params] Extra parameters specific to the exchange API endpoint
4880
+ * @returns {any[]} An account structure <https://docs.ccxt.com/#/?id=account-structure>
4881
+ */
4882
+ async fetchPortfolioDetails(portfolioUuid, params = {}) {
4883
+ await this.loadMarkets();
4884
+ const request = {
4885
+ 'portfolio_uuid': portfolioUuid,
4886
+ };
4887
+ const response = await this.v3PrivateGetBrokeragePortfoliosPortfolioUuid(this.extend(request, params));
4888
+ const result = this.parsePortfolioDetails(response);
4889
+ return result;
4890
+ }
4891
+ parsePortfolioDetails(portfolioData) {
4892
+ const breakdown = portfolioData['breakdown'];
4893
+ const portfolioInfo = this.safeDict(breakdown, 'portfolio', {});
4894
+ const portfolioName = this.safeString(portfolioInfo, 'name', 'Unknown');
4895
+ const portfolioUuid = this.safeString(portfolioInfo, 'uuid', '');
4896
+ const spotPositions = this.safeList(breakdown, 'spot_positions', []);
4897
+ const parsedPositions = [];
4898
+ for (let i = 0; i < spotPositions.length; i++) {
4899
+ const position = spotPositions[i];
4900
+ const currencyCode = this.safeString(position, 'asset', 'Unknown');
4901
+ const availableBalanceStr = this.safeString(position, 'available_to_trade_fiat', '0');
4902
+ const availableBalance = this.parseNumber(availableBalanceStr);
4903
+ const totalBalanceFiatStr = this.safeString(position, 'total_balance_fiat', '0');
4904
+ const totalBalanceFiat = this.parseNumber(totalBalanceFiatStr);
4905
+ const holdAmount = totalBalanceFiat - availableBalance;
4906
+ const costBasisDict = this.safeDict(position, 'cost_basis', {});
4907
+ const costBasisStr = this.safeString(costBasisDict, 'value', '0');
4908
+ const averageEntryPriceDict = this.safeDict(position, 'average_entry_price', {});
4909
+ const averageEntryPriceStr = this.safeString(averageEntryPriceDict, 'value', '0');
4910
+ const positionData = {
4911
+ 'currency': currencyCode,
4912
+ 'available_balance': availableBalance,
4913
+ 'hold_amount': holdAmount > 0 ? holdAmount : 0,
4914
+ 'wallet_name': portfolioName,
4915
+ 'account_id': portfolioUuid,
4916
+ 'account_uuid': this.safeString(position, 'account_uuid', ''),
4917
+ 'total_balance_fiat': totalBalanceFiat,
4918
+ 'total_balance_crypto': this.parseNumber(this.safeString(position, 'total_balance_crypto', '0')),
4919
+ 'available_to_trade_fiat': this.parseNumber(this.safeString(position, 'available_to_trade_fiat', '0')),
4920
+ 'available_to_trade_crypto': this.parseNumber(this.safeString(position, 'available_to_trade_crypto', '0')),
4921
+ 'available_to_transfer_fiat': this.parseNumber(this.safeString(position, 'available_to_transfer_fiat', '0')),
4922
+ 'available_to_transfer_crypto': this.parseNumber(this.safeString(position, 'available_to_trade_crypto', '0')),
4923
+ 'allocation': this.parseNumber(this.safeString(position, 'allocation', '0')),
4924
+ 'cost_basis': this.parseNumber(costBasisStr),
4925
+ 'cost_basis_currency': this.safeString(costBasisDict, 'currency', 'USD'),
4926
+ 'is_cash': this.safeBool(position, 'is_cash', false),
4927
+ 'average_entry_price': this.parseNumber(averageEntryPriceStr),
4928
+ 'average_entry_price_currency': this.safeString(averageEntryPriceDict, 'currency', 'USD'),
4929
+ 'asset_uuid': this.safeString(position, 'asset_uuid', ''),
4930
+ 'unrealized_pnl': this.parseNumber(this.safeString(position, 'unrealized_pnl', '0')),
4931
+ 'asset_color': this.safeString(position, 'asset_color', ''),
4932
+ 'account_type': this.safeString(position, 'account_type', ''),
4933
+ };
4934
+ parsedPositions.push(positionData);
4935
+ }
4936
+ return parsedPositions;
4937
+ }
4870
4938
  createAuthToken(seconds, method = undefined, url = undefined) {
4871
4939
  // it may not work for v2
4872
4940
  let uri = undefined;
@@ -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');