ccxt 4.2.52 → 4.2.54

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 (49) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +511 -102
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/binance.js +136 -9
  7. package/dist/cjs/src/bingx.js +32 -1
  8. package/dist/cjs/src/bitget.js +1 -0
  9. package/dist/cjs/src/bitvavo.js +1 -1
  10. package/dist/cjs/src/bybit.js +19 -0
  11. package/dist/cjs/src/coinbase.js +186 -12
  12. package/dist/cjs/src/htx.js +10 -4
  13. package/dist/cjs/src/pro/binance.js +92 -38
  14. package/dist/cjs/src/pro/bitvavo.js +1 -1
  15. package/dist/cjs/src/pro/blockchaincom.js +7 -25
  16. package/dist/cjs/src/pro/deribit.js +2 -2
  17. package/dist/cjs/src/pro/gemini.js +1 -1
  18. package/dist/cjs/src/pro/okx.js +18 -4
  19. package/dist/cjs/src/whitebit.js +4 -3
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/binance.d.ts +9 -3
  23. package/js/src/abstract/binancecoinm.d.ts +9 -3
  24. package/js/src/abstract/binanceus.d.ts +9 -3
  25. package/js/src/abstract/binanceusdm.d.ts +9 -3
  26. package/js/src/abstract/coinbase.d.ts +1 -1
  27. package/js/src/binance.d.ts +4 -0
  28. package/js/src/binance.js +136 -9
  29. package/js/src/bingx.d.ts +4 -0
  30. package/js/src/bingx.js +32 -1
  31. package/js/src/bitget.js +1 -0
  32. package/js/src/bitvavo.js +1 -1
  33. package/js/src/bybit.d.ts +5 -0
  34. package/js/src/bybit.js +19 -0
  35. package/js/src/coinbase.d.ts +2 -0
  36. package/js/src/coinbase.js +186 -12
  37. package/js/src/htx.js +10 -4
  38. package/js/src/pro/binance.d.ts +4 -4
  39. package/js/src/pro/binance.js +92 -38
  40. package/js/src/pro/bitvavo.js +1 -1
  41. package/js/src/pro/blockchaincom.d.ts +0 -1
  42. package/js/src/pro/blockchaincom.js +7 -25
  43. package/js/src/pro/deribit.js +2 -2
  44. package/js/src/pro/gemini.js +1 -1
  45. package/js/src/pro/okx.js +18 -4
  46. package/js/src/whitebit.js +4 -3
  47. package/jsdoc2md.js +3 -2
  48. package/package.json +2 -1
  49. package/skip-tests.json +26 -9
package/dist/cjs/ccxt.js CHANGED
@@ -176,7 +176,7 @@ var woo$1 = require('./src/pro/woo.js');
176
176
 
177
177
  //-----------------------------------------------------------------------------
178
178
  // this is updated by vss.js when building
179
- const version = '4.2.52';
179
+ const version = '4.2.54';
180
180
  Exchange["default"].ccxtVersion = version;
181
181
  const exchanges = {
182
182
  'ace': ace,
@@ -41,13 +41,13 @@ class binance extends binance$1 {
41
41
  'closeAllPositions': false,
42
42
  'closePosition': false,
43
43
  'createDepositAddress': false,
44
- 'createMarketBuyOrderWithCost': true,
45
- 'createMarketOrderWithCost': true,
46
- 'createMarketSellOrderWithCost': true,
47
44
  'createLimitBuyOrder': true,
48
45
  'createLimitSellOrder': true,
49
46
  'createMarketBuyOrder': true,
47
+ 'createMarketBuyOrderWithCost': true,
48
+ 'createMarketOrderWithCost': true,
50
49
  'createMarketSellOrder': true,
50
+ 'createMarketSellOrderWithCost': true,
51
51
  'createOrder': true,
52
52
  'createOrders': true,
53
53
  'createOrderWithTakeProfitAndStopLoss': true,
@@ -67,6 +67,7 @@ class binance extends binance$1 {
67
67
  'fetchBorrowInterest': true,
68
68
  'fetchBorrowRateHistories': false,
69
69
  'fetchBorrowRateHistory': true,
70
+ 'fetchCanceledAndClosedOrders': 'emulated',
70
71
  'fetchCanceledOrders': 'emulated',
71
72
  'fetchClosedOrder': false,
72
73
  'fetchClosedOrders': 'emulated',
@@ -92,7 +93,8 @@ class binance extends binance$1 {
92
93
  'fetchL3OrderBook': false,
93
94
  'fetchLastPrices': true,
94
95
  'fetchLedger': true,
95
- 'fetchLeverage': false,
96
+ 'fetchLedgerEntry': true,
97
+ 'fetchLeverage': true,
96
98
  'fetchLeverageTiers': true,
97
99
  'fetchLiquidations': false,
98
100
  'fetchMarketLeverageTiers': 'emulated',
@@ -124,7 +126,7 @@ class binance extends binance$1 {
124
126
  'fetchTrades': true,
125
127
  'fetchTradingFee': true,
126
128
  'fetchTradingFees': true,
127
- 'fetchTradingLimits': undefined,
129
+ 'fetchTradingLimits': 'emulated',
128
130
  'fetchTransactionFee': 'emulated',
129
131
  'fetchTransactionFees': true,
130
132
  'fetchTransactions': false,
@@ -292,8 +294,6 @@ class binance extends binance$1 {
292
294
  'loan/flexible/borrow/history': 40,
293
295
  'loan/flexible/repay/history': 40,
294
296
  'loan/flexible/ltv/adjustment/history': 40,
295
- 'loan/flexible/loanable/data': 40,
296
- 'loan/flexible/collateral/data': 40,
297
297
  'loan/vip/ongoing/orders': 40,
298
298
  'loan/vip/repay/history': 40,
299
299
  'loan/vip/collateral/account': 600,
@@ -585,7 +585,6 @@ class binance extends binance$1 {
585
585
  'loan/repay': 40.002,
586
586
  'loan/adjust/ltv': 40.002,
587
587
  'loan/customize/margin_call': 40.002,
588
- 'loan/flexible/borrow': 40.002,
589
588
  'loan/flexible/repay': 40.002,
590
589
  'loan/flexible/adjust/ltv': 40.002,
591
590
  'loan/vip/repay': 40.002,
@@ -640,10 +639,19 @@ class binance extends binance$1 {
640
639
  'sub-account/futures/account': 0.1,
641
640
  'sub-account/futures/accountSummary': 1,
642
641
  'sub-account/futures/positionRisk': 0.1,
642
+ 'loan/flexible/ongoing/orders': 30,
643
+ 'loan/flexible/borrow/history': 40,
644
+ 'loan/flexible/repay/history': 40,
645
+ 'loan/flexible/ltv/adjustment/history': 40,
646
+ 'loan/flexible/loanable/data': 40,
647
+ 'loan/flexible/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
643
648
  },
644
649
  'post': {
645
650
  'eth-staking/eth/stake': 15,
646
- 'sub-account/subAccountApi/ipRestriction': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
651
+ 'sub-account/subAccountApi/ipRestriction': 20.001,
652
+ 'loan/flexible/borrow': 40.002,
653
+ 'loan/flexible/repay': 40.002,
654
+ 'loan/flexible/adjust/ltv': 40.002, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40.002
647
655
  },
648
656
  },
649
657
  'sapiV3': {
@@ -6823,6 +6831,38 @@ class binance extends binance$1 {
6823
6831
  const filteredOrders = this.filterBy(orders, 'status', 'canceled');
6824
6832
  return this.filterBySinceLimit(filteredOrders, since, limit);
6825
6833
  }
6834
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
6835
+ /**
6836
+ * @method
6837
+ * @name binance#fetchCanceledAndClosedOrders
6838
+ * @description fetches information on multiple canceled orders made by the user
6839
+ * @see https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
6840
+ * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
6841
+ * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
6842
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
6843
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
6844
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
6845
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
6846
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
6847
+ * @param {string} symbol unified market symbol of the market the orders were made in
6848
+ * @param {int} [since] the earliest time in ms to fetch orders for
6849
+ * @param {int} [limit] the maximum number of order structures to retrieve
6850
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6851
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6852
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
6853
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
6854
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
6855
+ */
6856
+ if (symbol === undefined) {
6857
+ throw new errors.ArgumentsRequired(this.id + ' fetchCanceledAndClosedOrders() requires a symbol argument');
6858
+ }
6859
+ const orders = await this.fetchOrders(symbol, since, undefined, params);
6860
+ const canceledOrders = this.filterBy(orders, 'status', 'canceled');
6861
+ const closedOrders = this.filterBy(orders, 'status', 'closed');
6862
+ const filteredOrders = this.arrayConcat(canceledOrders, closedOrders);
6863
+ const sortedOrders = this.sortBy(filteredOrders, 'timestamp');
6864
+ return this.filterBySinceLimit(sortedOrders, since, limit);
6865
+ }
6826
6866
  async cancelOrder(id, symbol = undefined, params = {}) {
6827
6867
  /**
6828
6868
  * @method
@@ -10346,6 +10386,67 @@ class binance extends binance$1 {
10346
10386
  //
10347
10387
  return response;
10348
10388
  }
10389
+ async fetchLeverage(symbol, params = {}) {
10390
+ /**
10391
+ * @method
10392
+ * @name binance#fetchLeverage
10393
+ * @description fetch the set leverage for a market
10394
+ * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
10395
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
10396
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
10397
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
10398
+ * @param {string} symbol unified market symbol
10399
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
10400
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
10401
+ */
10402
+ await this.loadMarkets();
10403
+ await this.loadLeverageBrackets(false, params);
10404
+ const market = this.market(symbol);
10405
+ if (!market['contract']) {
10406
+ throw new errors.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
10407
+ }
10408
+ let type = undefined;
10409
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
10410
+ let subType = undefined;
10411
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
10412
+ let isPortfolioMargin = undefined;
10413
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
10414
+ let response = undefined;
10415
+ if (this.isLinear(type, subType)) {
10416
+ if (isPortfolioMargin) {
10417
+ response = await this.papiGetUmAccount(params);
10418
+ }
10419
+ else {
10420
+ response = await this.fapiPrivateV2GetAccount(params);
10421
+ }
10422
+ }
10423
+ else if (this.isInverse(type, subType)) {
10424
+ if (isPortfolioMargin) {
10425
+ response = await this.papiGetCmAccount(params);
10426
+ }
10427
+ else {
10428
+ response = await this.dapiPrivateGetAccount(params);
10429
+ }
10430
+ }
10431
+ else {
10432
+ throw new errors.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
10433
+ }
10434
+ const positions = this.safeList(response, 'positions', []);
10435
+ for (let i = 0; i < positions.length; i++) {
10436
+ const position = positions[i];
10437
+ const innerSymbol = this.safeString(position, 'symbol');
10438
+ if (innerSymbol === market['id']) {
10439
+ const isolated = this.safeBool(position, 'isolated');
10440
+ const marginMode = isolated ? 'isolated' : 'cross';
10441
+ return {
10442
+ 'info': position,
10443
+ 'marginMode': marginMode,
10444
+ 'leverage': this.safeInteger(position, 'leverage'),
10445
+ };
10446
+ }
10447
+ }
10448
+ return response;
10449
+ }
10349
10450
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10350
10451
  /**
10351
10452
  * @method
@@ -10528,6 +10629,19 @@ class binance extends binance$1 {
10528
10629
  }
10529
10630
  return result;
10530
10631
  }
10632
+ async fetchLedgerEntry(id, code = undefined, params = {}) {
10633
+ await this.loadMarkets();
10634
+ let type = undefined;
10635
+ [type, params] = this.handleMarketTypeAndParams('fetchLedgerEntry', undefined, params);
10636
+ const query = {
10637
+ 'recordId': id,
10638
+ 'type': type,
10639
+ };
10640
+ if (type !== 'option') {
10641
+ throw new errors.BadRequest(this.id + ' fetchLedgerEntry () can only be used for type option');
10642
+ }
10643
+ return await this.fetchLedger(code, undefined, undefined, this.extend(query, params));
10644
+ }
10531
10645
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
10532
10646
  /**
10533
10647
  * @method
@@ -11994,6 +12108,19 @@ class binance extends binance$1 {
11994
12108
  'info': greeks,
11995
12109
  };
11996
12110
  }
12111
+ async fetchTradingLimits(symbols = undefined, params = {}) {
12112
+ // this method should not be called directly, use loadTradingLimits () instead
12113
+ const markets = await this.fetchMarkets();
12114
+ const tradingLimits = {};
12115
+ for (let i = 0; i < markets.length; i++) {
12116
+ const market = markets[i];
12117
+ const symbol = market['symbol'];
12118
+ if ((symbols === undefined) || (this.inArray(symbol, symbols))) {
12119
+ tradingLimits[symbol] = market['limits']['amount'];
12120
+ }
12121
+ }
12122
+ return tradingLimits;
12123
+ }
11997
12124
  async fetchPositionMode(symbol = undefined, params = {}) {
11998
12125
  /**
11999
12126
  * @method
@@ -67,6 +67,7 @@ class bingx extends bingx$1 {
67
67
  'fetchOpenOrders': true,
68
68
  'fetchOrder': true,
69
69
  'fetchOrderBook': true,
70
+ 'fetchPositionMode': true,
70
71
  'fetchPositions': true,
71
72
  'fetchTicker': true,
72
73
  'fetchTickers': true,
@@ -77,6 +78,7 @@ class bingx extends bingx$1 {
77
78
  'setLeverage': true,
78
79
  'setMargin': true,
79
80
  'setMarginMode': true,
81
+ 'setPositionMode': true,
80
82
  'transfer': true,
81
83
  },
82
84
  'hostname': 'bingx.com',
@@ -3503,13 +3505,14 @@ class bingx extends bingx$1 {
3503
3505
  * @param {float} leverage the rate of leverage
3504
3506
  * @param {string} symbol unified market symbol
3505
3507
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3508
+ * @param {string} [params.side] hedged: ['long' or 'short']. one way: ['both']
3506
3509
  * @returns {object} response from the exchange
3507
3510
  */
3508
3511
  if (symbol === undefined) {
3509
3512
  throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
3510
3513
  }
3511
3514
  const side = this.safeStringUpper(params, 'side');
3512
- this.checkRequiredArgument('setLeverage', side, 'side', ['LONG', 'SHORT']);
3515
+ this.checkRequiredArgument('setLeverage', side, 'side', ['LONG', 'SHORT', 'BOTH']);
3513
3516
  await this.loadMarkets();
3514
3517
  const market = this.market(symbol);
3515
3518
  const request = {
@@ -3953,6 +3956,34 @@ class bingx extends bingx$1 {
3953
3956
  }
3954
3957
  return positions;
3955
3958
  }
3959
+ async fetchPositionMode(symbol = undefined, params = {}) {
3960
+ /**
3961
+ * @method
3962
+ * @name bingx#fetchPositionMode
3963
+ * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
3964
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Get%20Position%20Mode
3965
+ * @param {string} symbol unified symbol of the market to fetch the order book for
3966
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3967
+ * @returns {object} an object detailing whether the market is in hedged or one-way mode
3968
+ */
3969
+ const response = await this.swapV1PrivateGetPositionSideDual(params);
3970
+ //
3971
+ // {
3972
+ // "code": "0",
3973
+ // "msg": "",
3974
+ // "timeStamp": "1709002057516",
3975
+ // "data": {
3976
+ // "dualSidePosition": "false"
3977
+ // }
3978
+ // }
3979
+ //
3980
+ const data = this.safeDict(response, 'data', {});
3981
+ const dualSidePosition = this.safeString(data, 'dualSidePosition');
3982
+ return {
3983
+ 'info': response,
3984
+ 'hedged': (dualSidePosition === 'true'),
3985
+ };
3986
+ }
3956
3987
  async setPositionMode(hedged, symbol = undefined, params = {}) {
3957
3988
  /**
3958
3989
  * @method
@@ -3592,6 +3592,7 @@ class bitget extends bitget$1 {
3592
3592
  'not_trigger': 'open',
3593
3593
  'partial_fill': 'open',
3594
3594
  'partially_fill': 'open',
3595
+ 'partially_filled': 'open',
3595
3596
  'triggered': 'closed',
3596
3597
  'full_fill': 'closed',
3597
3598
  'filled': 'closed',
@@ -568,7 +568,7 @@ class bitvavo extends bitvavo$1 {
568
568
  // "market":"ETH-BTC",
569
569
  // "open":"0.022578",
570
570
  // "high":"0.023019",
571
- // "low":"0.022573",
571
+ // "low":"0.022572",
572
572
  // "last":"0.023019",
573
573
  // "volume":"25.16366324",
574
574
  // "volumeQuote":"0.57333305",
@@ -108,6 +108,7 @@ class bybit extends bybit$1 {
108
108
  'fetchUnderlyingAssets': false,
109
109
  'fetchVolatilityHistory': true,
110
110
  'fetchWithdrawals': true,
111
+ 'fetchLeverage': true,
111
112
  'repayCrossMargin': true,
112
113
  'setLeverage': true,
113
114
  'setMarginMode': true,
@@ -6344,6 +6345,24 @@ class bybit extends bybit$1 {
6344
6345
  'takeProfitPrice': this.safeNumber2(position, 'take_profit', 'takeProfit'),
6345
6346
  });
6346
6347
  }
6348
+ async fetchLeverage(symbol, params = {}) {
6349
+ /**
6350
+ * @method
6351
+ * @name bybit#fetchLeverage
6352
+ * @description fetch the set leverage for a market
6353
+ * @see https://bybit-exchange.github.io/docs/v5/position
6354
+ * @param {string} symbol unified market symbol
6355
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6356
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
6357
+ */
6358
+ await this.loadMarkets();
6359
+ const position = await this.fetchPosition(symbol, params);
6360
+ return {
6361
+ 'info': position,
6362
+ 'leverage': this.safeInteger(position, 'leverage'),
6363
+ 'marginMode': this.safeNumber(position, 'marginMode'),
6364
+ };
6365
+ }
6347
6366
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
6348
6367
  /**
6349
6368
  * @method
@@ -51,6 +51,7 @@ class coinbase extends coinbase$1 {
51
51
  'createStopLimitOrder': true,
52
52
  'createStopMarketOrder': false,
53
53
  'createStopOrder': true,
54
+ 'deposit': true,
54
55
  'editOrder': true,
55
56
  'fetchAccounts': true,
56
57
  'fetchBalance': true,
@@ -62,6 +63,7 @@ class coinbase extends coinbase$1 {
62
63
  'fetchCrossBorrowRate': false,
63
64
  'fetchCrossBorrowRates': false,
64
65
  'fetchCurrencies': true,
66
+ 'fetchDeposit': true,
65
67
  'fetchDepositAddress': 'emulated',
66
68
  'fetchDepositAddresses': false,
67
69
  'fetchDepositAddressesByNetwork': true,
@@ -190,6 +192,11 @@ class coinbase extends coinbase$1 {
190
192
  },
191
193
  },
192
194
  'v3': {
195
+ 'public': {
196
+ 'get': [
197
+ 'brokerage/time',
198
+ ],
199
+ },
193
200
  'private': {
194
201
  'get': [
195
202
  'brokerage/accounts',
@@ -207,7 +214,6 @@ class coinbase extends coinbase$1 {
207
214
  'brokerage/product_book',
208
215
  'brokerage/best_bid_ask',
209
216
  'brokerage/convert/trade/{trade_id}',
210
- 'brokerage/time',
211
217
  'brokerage/cfm/balance_summary',
212
218
  'brokerage/cfm/positions',
213
219
  'brokerage/cfm/positions/{product_id}',
@@ -338,6 +344,7 @@ class coinbase extends coinbase$1 {
338
344
  'fetchTickers': 'fetchTickersV3',
339
345
  'fetchAccounts': 'fetchAccountsV3',
340
346
  'fetchBalance': 'v2PrivateGetAccounts',
347
+ 'fetchTime': 'v2PublicGetTime',
341
348
  'user_native_currency': 'USD', // needed to get fees for v3
342
349
  },
343
350
  });
@@ -349,19 +356,36 @@ class coinbase extends coinbase$1 {
349
356
  * @description fetches the current integer timestamp in milliseconds from the exchange server
350
357
  * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-time#http-request
351
358
  * @param {object} [params] extra parameters specific to the exchange API endpoint
359
+ * @param {string} [params.method] 'v2PublicGetTime' or 'v3PublicGetBrokerageTime' default is 'v2PublicGetTime'
352
360
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
353
361
  */
354
- const response = await this.v2PublicGetTime(params);
355
- //
356
- // {
357
- // "data": {
358
- // "epoch": 1589295679,
359
- // "iso": "2020-05-12T15:01:19Z"
360
- // }
361
- // }
362
- //
363
- const data = this.safeValue(response, 'data', {});
364
- return this.safeTimestamp(data, 'epoch');
362
+ const defaultMethod = this.safeString(this.options, 'fetchTime', 'v2PublicGetTime');
363
+ const method = this.safeString(params, 'method', defaultMethod);
364
+ params = this.omit(params, 'method');
365
+ let response = undefined;
366
+ if (method === 'v2PublicGetTime') {
367
+ response = await this.v2PublicGetTime(params);
368
+ //
369
+ // {
370
+ // "data": {
371
+ // "epoch": 1589295679,
372
+ // "iso": "2020-05-12T15:01:19Z"
373
+ // }
374
+ // }
375
+ //
376
+ response = this.safeValue(response, 'data', {});
377
+ }
378
+ else {
379
+ response = await this.v3PublicGetBrokerageTime(params);
380
+ //
381
+ // {
382
+ // "iso": "2024-02-27T03:37:14Z",
383
+ // "epochSeconds": "1709005034",
384
+ // "epochMillis": "1709005034333"
385
+ // }
386
+ //
387
+ }
388
+ return this.safeTimestamp2(response, 'epoch', 'epochSeconds');
365
389
  }
366
390
  async fetchAccounts(params = {}) {
367
391
  /**
@@ -1757,6 +1781,7 @@ class coinbase extends coinbase$1 {
1757
1781
  response = await this.v3PrivateGetBrokerageAccounts(this.extend(request, params));
1758
1782
  }
1759
1783
  else {
1784
+ request['limit'] = 100;
1760
1785
  response = await this.v2PrivateGetAccounts(this.extend(request, params));
1761
1786
  }
1762
1787
  //
@@ -3536,6 +3561,145 @@ class coinbase extends coinbase$1 {
3536
3561
  'network': this.networkIdToCode(networkId, code),
3537
3562
  };
3538
3563
  }
3564
+ async deposit(code, amount, id, params = {}) {
3565
+ /**
3566
+ * @method
3567
+ * @name coinbase#deposit
3568
+ * @description make a deposit
3569
+ * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#deposit-funds
3570
+ * @param {string} code unified currency code
3571
+ * @param {float} amount the amount to deposit
3572
+ * @param {string} id the payment method id to be used for the deposit, can be retrieved from v2PrivateGetPaymentMethods
3573
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3574
+ * @param {string} [params.accountId] the id of the account to deposit into
3575
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3576
+ */
3577
+ await this.loadMarkets();
3578
+ let accountId = this.safeString2(params, 'account_id', 'accountId');
3579
+ params = this.omit(params, ['account_id', 'accountId']);
3580
+ if (accountId === undefined) {
3581
+ if (code === undefined) {
3582
+ throw new errors.ArgumentsRequired(this.id + ' deposit() requires an account_id (or accountId) parameter OR a currency code argument');
3583
+ }
3584
+ accountId = await this.findAccountId(code);
3585
+ if (accountId === undefined) {
3586
+ throw new errors.ExchangeError(this.id + ' deposit() could not find account id for ' + code);
3587
+ }
3588
+ }
3589
+ const request = {
3590
+ 'account_id': accountId,
3591
+ 'amount': this.numberToString(amount),
3592
+ 'currency': code.toUpperCase(),
3593
+ 'payment_method': id,
3594
+ };
3595
+ const response = await this.v2PrivatePostAccountsAccountIdDeposits(this.extend(request, params));
3596
+ //
3597
+ // {
3598
+ // "data": {
3599
+ // "id": "67e0eaec-07d7-54c4-a72c-2e92826897df",
3600
+ // "status": "created",
3601
+ // "payment_method": {
3602
+ // "id": "83562370-3e5c-51db-87da-752af5ab9559",
3603
+ // "resource": "payment_method",
3604
+ // "resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
3605
+ // },
3606
+ // "transaction": {
3607
+ // "id": "441b9494-b3f0-5b98-b9b0-4d82c21c252a",
3608
+ // "resource": "transaction",
3609
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/441b9494-b3f0-5b98-b9b0-4d82c21c252a"
3610
+ // },
3611
+ // "amount": {
3612
+ // "amount": "10.00",
3613
+ // "currency": "USD"
3614
+ // },
3615
+ // "subtotal": {
3616
+ // "amount": "10.00",
3617
+ // "currency": "USD"
3618
+ // },
3619
+ // "created_at": "2015-01-31T20:49:02Z",
3620
+ // "updated_at": "2015-02-11T16:54:02-08:00",
3621
+ // "resource": "deposit",
3622
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/deposits/67e0eaec-07d7-54c4-a72c-2e92826897df",
3623
+ // "committed": true,
3624
+ // "fee": {
3625
+ // "amount": "0.00",
3626
+ // "currency": "USD"
3627
+ // },
3628
+ // "payout_at": "2015-02-18T16:54:00-08:00"
3629
+ // }
3630
+ // }
3631
+ //
3632
+ const data = this.safeDict(response, 'data', {});
3633
+ return this.parseTransaction(data);
3634
+ }
3635
+ async fetchDeposit(id, code = undefined, params = {}) {
3636
+ /**
3637
+ * @method
3638
+ * @name coinbase#fetchDeposit
3639
+ * @description fetch information on a deposit, fiat only, for crypto transactions use fetchLedger
3640
+ * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#show-deposit
3641
+ * @param {string} id deposit id
3642
+ * @param {string} [code] unified currency code
3643
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3644
+ * @param {string} [params.accountId] the id of the account that the funds were deposited into
3645
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3646
+ */
3647
+ await this.loadMarkets();
3648
+ let accountId = this.safeString2(params, 'account_id', 'accountId');
3649
+ params = this.omit(params, ['account_id', 'accountId']);
3650
+ if (accountId === undefined) {
3651
+ if (code === undefined) {
3652
+ throw new errors.ArgumentsRequired(this.id + ' fetchDeposit() requires an account_id (or accountId) parameter OR a currency code argument');
3653
+ }
3654
+ accountId = await this.findAccountId(code);
3655
+ if (accountId === undefined) {
3656
+ throw new errors.ExchangeError(this.id + ' fetchDeposit() could not find account id for ' + code);
3657
+ }
3658
+ }
3659
+ const request = {
3660
+ 'account_id': accountId,
3661
+ 'deposit_id': id,
3662
+ };
3663
+ const response = await this.v2PrivateGetAccountsAccountIdDepositsDepositId(this.extend(request, params));
3664
+ //
3665
+ // {
3666
+ // "data": {
3667
+ // "id": "67e0eaec-07d7-54c4-a72c-2e92826897df",
3668
+ // "status": "completed",
3669
+ // "payment_method": {
3670
+ // "id": "83562370-3e5c-51db-87da-752af5ab9559",
3671
+ // "resource": "payment_method",
3672
+ // "resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
3673
+ // },
3674
+ // "transaction": {
3675
+ // "id": "441b9494-b3f0-5b98-b9b0-4d82c21c252a",
3676
+ // "resource": "transaction",
3677
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/441b9494-b3f0-5b98-b9b0-4d82c21c252a"
3678
+ // },
3679
+ // "amount": {
3680
+ // "amount": "10.00",
3681
+ // "currency": "USD"
3682
+ // },
3683
+ // "subtotal": {
3684
+ // "amount": "10.00",
3685
+ // "currency": "USD"
3686
+ // },
3687
+ // "created_at": "2015-01-31T20:49:02Z",
3688
+ // "updated_at": "2015-02-11T16:54:02-08:00",
3689
+ // "resource": "deposit",
3690
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/deposits/67e0eaec-07d7-54c4-a72c-2e92826897df",
3691
+ // "committed": true,
3692
+ // "fee": {
3693
+ // "amount": "0.00",
3694
+ // "currency": "USD"
3695
+ // },
3696
+ // "payout_at": "2015-02-18T16:54:00-08:00"
3697
+ // }
3698
+ // }
3699
+ //
3700
+ const data = this.safeValue(response, 'data', {});
3701
+ return this.parseTransaction(data);
3702
+ }
3539
3703
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
3540
3704
  const version = api[0];
3541
3705
  const signed = api[1] === 'private';
@@ -3556,6 +3720,11 @@ class coinbase extends coinbase$1 {
3556
3720
  'Authorization': authorization,
3557
3721
  'Content-Type': 'application/json',
3558
3722
  };
3723
+ if (method !== 'GET') {
3724
+ if (Object.keys(query).length) {
3725
+ body = this.json(query);
3726
+ }
3727
+ }
3559
3728
  }
3560
3729
  else if (this.token && !this.checkRequiredCredentials(false)) {
3561
3730
  headers = {
@@ -3578,6 +3747,11 @@ class coinbase extends coinbase$1 {
3578
3747
  payload = body;
3579
3748
  }
3580
3749
  }
3750
+ else {
3751
+ if (Object.keys(query).length) {
3752
+ payload += '?' + this.urlencode(query);
3753
+ }
3754
+ }
3581
3755
  const auth = nonce + method + savedPath + payload;
3582
3756
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
3583
3757
  headers = {
@@ -1231,9 +1231,10 @@ class htx extends htx$1 {
1231
1231
  async fetchStatus(params = {}) {
1232
1232
  await this.loadMarkets();
1233
1233
  let marketType = undefined;
1234
- [marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', undefined, params);
1234
+ [marketType, params] = this.handleMarketTypeAndParams('fetchStatus', undefined, params);
1235
+ const enabledForContracts = this.handleOption('fetchStatus', 'enableForContracts', false); // temp fix for: https://status-linear-swap.huobigroup.com/api/v2/summary.json
1235
1236
  let response = undefined;
1236
- if (marketType !== 'spot') {
1237
+ if (marketType !== 'spot' && enabledForContracts) {
1237
1238
  const subType = this.safeString(params, 'subType', this.options['defaultSubType']);
1238
1239
  if (marketType === 'swap') {
1239
1240
  if (subType === 'linear') {
@@ -1255,7 +1256,7 @@ class htx extends htx$1 {
1255
1256
  response = await this.contractPublicGetHeartbeat();
1256
1257
  }
1257
1258
  }
1258
- else {
1259
+ else if (marketType === 'spot') {
1259
1260
  response = await this.statusPublicSpotGetApiV2SummaryJson();
1260
1261
  }
1261
1262
  //
@@ -1424,7 +1425,12 @@ class htx extends htx$1 {
1424
1425
  let url = undefined;
1425
1426
  if (marketType === 'contract') {
1426
1427
  const statusRaw = this.safeString(response, 'status');
1427
- status = (statusRaw === 'ok') ? 'ok' : 'maintenance'; // 'ok', 'error'
1428
+ if (statusRaw === undefined) {
1429
+ status = undefined;
1430
+ }
1431
+ else {
1432
+ status = (statusRaw === 'ok') ? 'ok' : 'maintenance'; // 'ok', 'error'
1433
+ }
1428
1434
  updated = this.safeString(response, 'ts');
1429
1435
  }
1430
1436
  else {