ccxt 4.3.41 → 4.3.43

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 (52) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/binance.js +169 -44
  5. package/dist/cjs/src/bitmart.js +196 -100
  6. package/dist/cjs/src/blockchaincom.js +11 -7
  7. package/dist/cjs/src/btcmarkets.js +31 -2
  8. package/dist/cjs/src/coinex.js +107 -108
  9. package/dist/cjs/src/kraken.js +30 -3
  10. package/dist/cjs/src/krakenfutures.js +56 -1
  11. package/dist/cjs/src/kucoin.js +59 -2
  12. package/dist/cjs/src/phemex.js +5 -4
  13. package/dist/cjs/src/pro/bitget.js +36 -22
  14. package/dist/cjs/src/pro/bybit.js +1 -1
  15. package/dist/cjs/src/pro/mexc.js +2 -2
  16. package/dist/cjs/src/pro/upbit.js +8 -4
  17. package/dist/cjs/src/pro/woo.js +2 -2
  18. package/dist/cjs/src/tradeogre.js +11 -5
  19. package/dist/cjs/src/wavesexchange.js +2 -2
  20. package/dist/cjs/src/wazirx.js +38 -15
  21. package/dist/cjs/src/zonda.js +9 -1
  22. package/js/ccxt.d.ts +3 -3
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/coinex.d.ts +2 -1
  25. package/js/src/binance.js +169 -44
  26. package/js/src/bitmart.js +196 -100
  27. package/js/src/blockchaincom.d.ts +2 -8
  28. package/js/src/blockchaincom.js +11 -7
  29. package/js/src/btcmarkets.d.ts +2 -2
  30. package/js/src/btcmarkets.js +31 -2
  31. package/js/src/coinex.js +107 -108
  32. package/js/src/kraken.d.ts +3 -3
  33. package/js/src/kraken.js +30 -3
  34. package/js/src/krakenfutures.d.ts +1 -1
  35. package/js/src/krakenfutures.js +56 -1
  36. package/js/src/kucoin.d.ts +1 -1
  37. package/js/src/kucoin.js +59 -2
  38. package/js/src/phemex.js +6 -5
  39. package/js/src/pro/bitget.js +36 -22
  40. package/js/src/pro/bybit.js +1 -1
  41. package/js/src/pro/mexc.js +2 -2
  42. package/js/src/pro/upbit.js +8 -4
  43. package/js/src/pro/woo.js +2 -2
  44. package/js/src/tradeogre.d.ts +1 -1
  45. package/js/src/tradeogre.js +12 -6
  46. package/js/src/wavesexchange.d.ts +1 -20
  47. package/js/src/wavesexchange.js +2 -2
  48. package/js/src/wazirx.d.ts +1 -1
  49. package/js/src/wazirx.js +38 -15
  50. package/js/src/zonda.d.ts +1 -1
  51. package/js/src/zonda.js +9 -1
  52. package/package.json +1 -1
@@ -229,17 +229,21 @@ class upbit extends upbit$1 {
229
229
  }
230
230
  async authenticate(params = {}) {
231
231
  this.checkRequiredCredentials();
232
- const authenticated = this.options['ws']['token'];
232
+ const wsOptions = this.safeDict(this.options, 'ws', {});
233
+ const authenticated = this.safeString(wsOptions, 'token');
233
234
  if (authenticated === undefined) {
234
235
  const auth = {
235
236
  'access_key': this.apiKey,
236
237
  'nonce': this.uuid(),
237
238
  };
238
239
  const token = rsa.jwt(auth, this.encode(this.secret), sha256.sha256, false);
239
- this.options['ws']['token'] = token;
240
- this.options['ws']['options']['headers'] = {
241
- 'authorization': 'Bearer ' + token,
240
+ wsOptions['token'] = token;
241
+ wsOptions['options'] = {
242
+ 'headers': {
243
+ 'authorization': 'Bearer ' + token,
244
+ },
242
245
  };
246
+ this.options['ws'] = wsOptions;
243
247
  }
244
248
  const url = this.urls['api']['ws'] + '/private';
245
249
  const client = this.client(url);
@@ -595,7 +595,7 @@ class woo extends woo$1 {
595
595
  async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
596
596
  /**
597
597
  * @method
598
- * @name woo#watchOrders
598
+ * @name woo#watchMyTrades
599
599
  * @see https://docs.woo.org/#executionreport
600
600
  * @see https://docs.woo.org/#algoexecutionreportv2
601
601
  * @description watches information on multiple trades made by the user
@@ -604,7 +604,7 @@ class woo extends woo$1 {
604
604
  * @param {int} [limit] the maximum number of order structures to retrieve
605
605
  * @param {object} [params] extra parameters specific to the exchange API endpoint
606
606
  * @param {bool} [params.trigger] true if trigger order
607
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
607
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
608
608
  */
609
609
  await this.loadMarkets();
610
610
  const trigger = this.safeBool2(params, 'stop', 'trigger', false);
@@ -449,7 +449,7 @@ class tradeogre extends tradeogre$1 {
449
449
  * @name tradeogre#createOrder
450
450
  * @description create a trade order
451
451
  * @param {string} symbol unified symbol of the market to create an order in
452
- * @param {string} type not used by tradeogre
452
+ * @param {string} type must be 'limit'
453
453
  * @param {string} side 'buy' or 'sell'
454
454
  * @param {float} amount how much of currency you want to trade in units of base currency
455
455
  * @param {float} price the price at which the order is to be fullfilled, in units of the quote currency
@@ -458,14 +458,17 @@ class tradeogre extends tradeogre$1 {
458
458
  */
459
459
  await this.loadMarkets();
460
460
  const market = this.market(symbol);
461
+ if (type === 'market') {
462
+ throw new errors.BadRequest(this.id + ' createOrder does not support market orders');
463
+ }
464
+ if (price === undefined) {
465
+ throw new errors.ArgumentsRequired(this.id + ' createOrder requires a limit parameter');
466
+ }
461
467
  const request = {
462
468
  'market': market['id'],
463
469
  'quantity': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
464
470
  'price': this.parseToNumeric(this.priceToPrecision(symbol, price)),
465
471
  };
466
- if (type === 'market') {
467
- throw new errors.BadRequest(this.id + ' createOrder does not support market orders');
468
- }
469
472
  let response = undefined;
470
473
  if (side === 'buy') {
471
474
  response = await this.privatePostOrderBuy(this.extend(request, params));
@@ -502,7 +505,10 @@ class tradeogre extends tradeogre$1 {
502
505
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
503
506
  */
504
507
  await this.loadMarkets();
505
- return await this.cancelOrder('all', symbol, params);
508
+ const response = await this.cancelOrder('all', symbol, params);
509
+ return [
510
+ response,
511
+ ];
506
512
  }
507
513
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
508
514
  /**
@@ -1499,7 +1499,7 @@ class wavesexchange extends wavesexchange$1 {
1499
1499
  const firstMessage = this.safeValue(message, 0);
1500
1500
  const firstOrder = this.safeValue(firstMessage, 0);
1501
1501
  const returnedId = this.safeString(firstOrder, 'orderId');
1502
- return {
1502
+ return this.safeOrder({
1503
1503
  'info': response,
1504
1504
  'id': returnedId,
1505
1505
  'clientOrderId': undefined,
@@ -1518,7 +1518,7 @@ class wavesexchange extends wavesexchange$1 {
1518
1518
  'status': undefined,
1519
1519
  'fee': undefined,
1520
1520
  'trades': undefined,
1521
- };
1521
+ });
1522
1522
  }
1523
1523
  async fetchOrder(id, symbol = undefined, params = {}) {
1524
1524
  /**
@@ -792,7 +792,26 @@ class wazirx extends wazirx$1 {
792
792
  const request = {
793
793
  'symbol': market['id'],
794
794
  };
795
- return await this.privateDeleteOpenOrders(this.extend(request, params));
795
+ const response = await this.privateDeleteOpenOrders(this.extend(request, params));
796
+ //
797
+ // [
798
+ // {
799
+ // id: "4565421197",
800
+ // symbol: "adausdt",
801
+ // type: "limit",
802
+ // side: "buy",
803
+ // status: "wait",
804
+ // price: "0.41",
805
+ // origQty: "11.00",
806
+ // executedQty: "0.00",
807
+ // avgPrice: "0.00",
808
+ // createdTime: "1718089507000",
809
+ // updatedTime: "1718089507000",
810
+ // clientOrderId: "93d2a838-e272-405d-91e7-3a7bc6d3a003"
811
+ // }
812
+ // ]
813
+ //
814
+ return this.parseOrders(response);
796
815
  }
797
816
  async cancelOrder(id, symbol = undefined, params = {}) {
798
817
  /**
@@ -868,18 +887,22 @@ class wazirx extends wazirx$1 {
868
887
  return this.parseOrder(response, market);
869
888
  }
870
889
  parseOrder(order, market = undefined) {
871
- // {
872
- // "id":1949417813,
873
- // "symbol":"ltcusdt",
874
- // "type":"limit",
875
- // "side":"sell",
876
- // "status":"done",
877
- // "price":"146.2",
878
- // "origQty":"0.05",
879
- // "executedQty":"0.05",
880
- // "createdTime":1641252564000,
881
- // "updatedTime":1641252564000
882
- // },
890
+ //
891
+ // {
892
+ // "id": 1949417813,
893
+ // "symbol": "ltcusdt",
894
+ // "type": "limit",
895
+ // "side": "sell",
896
+ // "status": "done",
897
+ // "price": "146.2",
898
+ // "origQty": "0.05",
899
+ // "executedQty": "0.05",
900
+ // "avgPrice": "0.00",
901
+ // "createdTime": 1641252564000,
902
+ // "updatedTime": 1641252564000
903
+ // "clientOrderId": "93d2a838-e272-405d-91e7-3a7bc6d3a003"
904
+ // }
905
+ //
883
906
  const created = this.safeInteger(order, 'createdTime');
884
907
  const updated = this.safeInteger(order, 'updatedTime');
885
908
  const marketId = this.safeString(order, 'symbol');
@@ -894,7 +917,7 @@ class wazirx extends wazirx$1 {
894
917
  return this.safeOrder({
895
918
  'info': order,
896
919
  'id': id,
897
- 'clientOrderId': undefined,
920
+ 'clientOrderId': this.safeString(order, 'clientOrderId'),
898
921
  'timestamp': created,
899
922
  'datetime': this.iso8601(created),
900
923
  'lastTradeTimestamp': updated,
@@ -910,7 +933,7 @@ class wazirx extends wazirx$1 {
910
933
  'remaining': undefined,
911
934
  'cost': undefined,
912
935
  'fee': undefined,
913
- 'average': undefined,
936
+ 'average': this.safeString(order, 'avgPrice'),
914
937
  'trades': [],
915
938
  }, market);
916
939
  }
@@ -440,6 +440,13 @@ class zonda extends zonda$1 {
440
440
  // "secondBalanceId": "ab43023b-4079-414c-b340-056e3430a3af"
441
441
  // }
442
442
  //
443
+ // cancelOrder
444
+ //
445
+ // {
446
+ // status: "Ok",
447
+ // errors: []
448
+ // }
449
+ //
443
450
  const marketId = this.safeString(order, 'market');
444
451
  const symbol = this.safeSymbol(marketId, market, '-');
445
452
  const timestamp = this.safeInteger(order, 'time');
@@ -1497,9 +1504,10 @@ class zonda extends zonda$1 {
1497
1504
  'side': side,
1498
1505
  'price': price,
1499
1506
  };
1507
+ const response = await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(request, params));
1500
1508
  // { status: "Fail", errors: [ "NOT_RECOGNIZED_OFFER_TYPE" ] } -- if required params are missing
1501
1509
  // { status: "Ok", errors: [] }
1502
- return await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(request, params));
1510
+ return this.parseOrder(response);
1503
1511
  }
1504
1512
  isFiat(currency) {
1505
1513
  const fiatCurrencies = {
package/js/ccxt.d.ts CHANGED
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
2
2
  import { Precise } from './src/base/Precise.js';
3
3
  import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
- import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
5
+ import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, TransferEntries, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.40";
7
+ declare const version = "4.3.42";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -528,5 +528,5 @@ declare const ccxt: {
528
528
  zaif: typeof zaif;
529
529
  zonda: typeof zonda;
530
530
  } & typeof functions & typeof errors;
531
- export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, wavesexchange, wazirx, whitebit, woo, woofipro, yobit, zaif, zonda, };
531
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, TransferEntries, LeverageTiers, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, wavesexchange, wazirx, whitebit, woo, woofipro, yobit, zaif, zonda, };
532
532
  export default ccxt;
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.41';
41
+ const version = '4.3.43';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -144,6 +144,8 @@ interface Exchange {
144
144
  v2PublicGetFuturesPositionLevel(params?: {}): Promise<implicitReturnType>;
145
145
  v2PublicGetFuturesLiquidationHistory(params?: {}): Promise<implicitReturnType>;
146
146
  v2PublicGetFuturesBasisHistory(params?: {}): Promise<implicitReturnType>;
147
+ v2PublicGetAssetsDepositWithdrawConfig(params?: {}): Promise<implicitReturnType>;
148
+ v2PublicGetAssetsAllDepositWithdrawConfig(params?: {}): Promise<implicitReturnType>;
147
149
  v2PrivateGetAccountSubs(params?: {}): Promise<implicitReturnType>;
148
150
  v2PrivateGetAccountSubsApiDetail(params?: {}): Promise<implicitReturnType>;
149
151
  v2PrivateGetAccountSubsInfo(params?: {}): Promise<implicitReturnType>;
@@ -162,7 +164,6 @@ interface Exchange {
162
164
  v2PrivateGetAssetsDepositAddress(params?: {}): Promise<implicitReturnType>;
163
165
  v2PrivateGetAssetsDepositHistory(params?: {}): Promise<implicitReturnType>;
164
166
  v2PrivateGetAssetsWithdraw(params?: {}): Promise<implicitReturnType>;
165
- v2PrivateGetAssetsDepositWithdrawConfig(params?: {}): Promise<implicitReturnType>;
166
167
  v2PrivateGetAssetsTransferHistory(params?: {}): Promise<implicitReturnType>;
167
168
  v2PrivateGetSpotOrderStatus(params?: {}): Promise<implicitReturnType>;
168
169
  v2PrivateGetSpotBatchOrderStatus(params?: {}): Promise<implicitReturnType>;
package/js/src/binance.js CHANGED
@@ -8111,8 +8111,56 @@ export default class binance extends Exchange {
8111
8111
  // "tranId": 43000126248
8112
8112
  // }
8113
8113
  //
8114
- const id = this.safeString(transfer, 'tranId');
8115
- const currencyId = this.safeString(transfer, 'asset');
8114
+ // {
8115
+ // "orderType": "C2C", // Enum:PAY(C2B Merchant Acquiring Payment), PAY_REFUND(C2B Merchant Acquiring Payment,refund), C2C(C2C Transfer Payment),CRYPTO_BOX(Crypto box), CRYPTO_BOX_RF(Crypto Box, refund), C2C_HOLDING(Transfer to new Binance user), C2C_HOLDING_RF(Transfer to new Binance user,refund), PAYOUT(B2C Disbursement Payment), REMITTANCE(Send cash)
8116
+ // "transactionId": "M_P_71505104267788288",
8117
+ // "transactionTime": 1610090460133, //trade timestamp
8118
+ // "amount": "23.72469206", //order amount(up to 8 decimal places), positive is income, negative is expenditure
8119
+ // "currency": "BNB",
8120
+ // "walletType": 1, //main wallet type, 1 for funding wallet, 2 for spot wallet, 3 for fiat wallet, 4 or 6 for card payment, 5 for earn wallet
8121
+ // "walletTypes": [1,2], //array format,there are multiple values when using combination payment
8122
+ // "fundsDetail": [ // details
8123
+ // {
8124
+ // "currency": "USDT", //asset
8125
+ // "amount": "1.2",
8126
+ // "walletAssetCost":[ //details of asset cost per wallet
8127
+ // {"1":"0.6"},
8128
+ // {"2":"0.6"}
8129
+ // ]
8130
+ // },
8131
+ // {
8132
+ // "currency": "ETH",
8133
+ // "amount": "0.0001",
8134
+ // "walletAssetCost":[
8135
+ // {"1":"0.00005"},
8136
+ // {"2":"0.00005"}
8137
+ // ]
8138
+ // }
8139
+ // ],
8140
+ // "payerInfo":{
8141
+ // "name":"Jack", //nickname or merchant name
8142
+ // "type":"USER", //account type,USER for personal,MERCHANT for merchant
8143
+ // "binanceId":"12345678", //binance uid
8144
+ // "accountId":"67736251" //binance pay id
8145
+ // },
8146
+ // "receiverInfo":{
8147
+ // "name":"Alan", //nickname or merchant name
8148
+ // "type":"MERCHANT", //account type,USER for personal,MERCHANT for merchant
8149
+ // "email":"alan@binance.com", //email
8150
+ // "binanceId":"34355667", //binance uid
8151
+ // "accountId":"21326891", //binance pay id
8152
+ // "countryCode":"1", //International area code
8153
+ // "phoneNumber":"8057651210",
8154
+ // "mobileCode":"US", //country code
8155
+ // "extend":[ //extension field
8156
+ // "institutionName": "",
8157
+ // "cardNumber": "",
8158
+ // "digitalWalletId": ""
8159
+ // ]
8160
+ // }
8161
+ // }
8162
+ const id = this.safeString2(transfer, 'tranId', 'transactionId');
8163
+ const currencyId = this.safeString2(transfer, 'asset', 'currency');
8116
8164
  const code = this.safeCurrencyCode(currencyId, currency);
8117
8165
  const amount = this.safeNumber(transfer, 'amount');
8118
8166
  const type = this.safeString(transfer, 'type');
@@ -8126,7 +8174,14 @@ export default class binance extends Exchange {
8126
8174
  fromAccount = this.safeString(accountsById, fromAccount, fromAccount);
8127
8175
  toAccount = this.safeString(accountsById, toAccount, toAccount);
8128
8176
  }
8129
- const timestamp = this.safeInteger(transfer, 'timestamp');
8177
+ const walletType = this.safeInteger(transfer, 'walletType');
8178
+ if (walletType !== undefined) {
8179
+ const payer = this.safeDict(transfer, 'payerInfo', {});
8180
+ const receiver = this.safeDict(transfer, 'receiverInfo', {});
8181
+ fromAccount = this.safeString(payer, 'accountId');
8182
+ toAccount = this.safeString(receiver, 'accountId');
8183
+ }
8184
+ const timestamp = this.safeInteger2(transfer, 'timestamp', 'transactionTime');
8130
8185
  const status = this.parseTransferStatus(this.safeString(transfer, 'status'));
8131
8186
  return {
8132
8187
  'info': transfer,
@@ -8278,74 +8333,144 @@ export default class binance extends Exchange {
8278
8333
  * @name binance#fetchTransfers
8279
8334
  * @description fetch a history of internal transfers made on an account
8280
8335
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data
8336
+ * @see https://binance-docs.github.io/apidocs/spot/en/#pay-endpoints
8281
8337
  * @param {string} code unified currency code of the currency transferred
8282
8338
  * @param {int} [since] the earliest time in ms to fetch transfers for
8283
8339
  * @param {int} [limit] the maximum number of transfers structures to retrieve
8284
8340
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8285
8341
  * @param {int} [params.until] the latest time in ms to fetch transfers for
8286
8342
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
8343
+ * @param {boolean} [params.internal] default false, when true will fetch pay trade history
8287
8344
  * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
8288
8345
  */
8289
8346
  await this.loadMarkets();
8347
+ const internal = this.safeBool(params, 'internal');
8348
+ params = this.omit(params, 'internal');
8290
8349
  let paginate = false;
8291
8350
  [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
8292
- if (paginate) {
8351
+ if (paginate && !internal) {
8293
8352
  return await this.fetchPaginatedCallDynamic('fetchTransfers', code, since, limit, params);
8294
8353
  }
8295
8354
  let currency = undefined;
8296
8355
  if (code !== undefined) {
8297
8356
  currency = this.currency(code);
8298
8357
  }
8299
- const defaultType = this.safeString2(this.options, 'fetchTransfers', 'defaultType', 'spot');
8300
- const fromAccount = this.safeString(params, 'fromAccount', defaultType);
8301
- const defaultTo = (fromAccount === 'future') ? 'spot' : 'future';
8302
- const toAccount = this.safeString(params, 'toAccount', defaultTo);
8303
- let type = this.safeString(params, 'type');
8304
- const accountsByType = this.safeDict(this.options, 'accountsByType', {});
8305
- const fromId = this.safeString(accountsByType, fromAccount);
8306
- const toId = this.safeString(accountsByType, toAccount);
8307
- if (type === undefined) {
8308
- if (fromId === undefined) {
8309
- const keys = Object.keys(accountsByType);
8310
- throw new ExchangeError(this.id + ' fromAccount parameter must be one of ' + keys.join(', '));
8311
- }
8312
- if (toId === undefined) {
8313
- const keys = Object.keys(accountsByType);
8314
- throw new ExchangeError(this.id + ' toAccount parameter must be one of ' + keys.join(', '));
8358
+ const request = {};
8359
+ let limitKey = 'limit';
8360
+ if (!internal) {
8361
+ const defaultType = this.safeString2(this.options, 'fetchTransfers', 'defaultType', 'spot');
8362
+ const fromAccount = this.safeString(params, 'fromAccount', defaultType);
8363
+ const defaultTo = (fromAccount === 'future') ? 'spot' : 'future';
8364
+ const toAccount = this.safeString(params, 'toAccount', defaultTo);
8365
+ let type = this.safeString(params, 'type');
8366
+ const accountsByType = this.safeDict(this.options, 'accountsByType', {});
8367
+ const fromId = this.safeString(accountsByType, fromAccount);
8368
+ const toId = this.safeString(accountsByType, toAccount);
8369
+ if (type === undefined) {
8370
+ if (fromId === undefined) {
8371
+ const keys = Object.keys(accountsByType);
8372
+ throw new ExchangeError(this.id + ' fromAccount parameter must be one of ' + keys.join(', '));
8373
+ }
8374
+ if (toId === undefined) {
8375
+ const keys = Object.keys(accountsByType);
8376
+ throw new ExchangeError(this.id + ' toAccount parameter must be one of ' + keys.join(', '));
8377
+ }
8378
+ type = fromId + '_' + toId;
8315
8379
  }
8316
- type = fromId + '_' + toId;
8380
+ request['type'] = type;
8381
+ limitKey = 'size';
8382
+ }
8383
+ if (limit !== undefined) {
8384
+ request[limitKey] = limit;
8317
8385
  }
8318
- const request = {
8319
- 'type': type,
8320
- };
8321
8386
  if (since !== undefined) {
8322
8387
  request['startTime'] = since;
8323
8388
  }
8324
- if (limit !== undefined) {
8325
- request['size'] = limit;
8326
- }
8327
8389
  const until = this.safeInteger(params, 'until');
8328
8390
  if (until !== undefined) {
8329
8391
  params = this.omit(params, 'until');
8330
8392
  request['endTime'] = until;
8331
8393
  }
8332
- const response = await this.sapiGetAssetTransfer(this.extend(request, params));
8333
- //
8334
- // {
8335
- // "total": 3,
8336
- // "rows": [
8337
- // {
8338
- // "timestamp": 1614640878000,
8339
- // "asset": "USDT",
8340
- // "amount": "25",
8341
- // "type": "MAIN_UMFUTURE",
8342
- // "status": "CONFIRMED",
8343
- // "tranId": 43000126248
8344
- // },
8345
- // ]
8346
- // }
8347
- //
8348
- const rows = this.safeList(response, 'rows', []);
8394
+ let response = undefined;
8395
+ if (internal) {
8396
+ response = await this.sapiGetPayTransactions(this.extend(request, params));
8397
+ //
8398
+ // {
8399
+ // "code": "000000",
8400
+ // "message": "success",
8401
+ // "data": [
8402
+ // {
8403
+ // "orderType": "C2C", // Enum:PAY(C2B Merchant Acquiring Payment), PAY_REFUND(C2B Merchant Acquiring Payment,refund), C2C(C2C Transfer Payment),CRYPTO_BOX(Crypto box), CRYPTO_BOX_RF(Crypto Box, refund), C2C_HOLDING(Transfer to new Binance user), C2C_HOLDING_RF(Transfer to new Binance user,refund), PAYOUT(B2C Disbursement Payment), REMITTANCE(Send cash)
8404
+ // "transactionId": "M_P_71505104267788288",
8405
+ // "transactionTime": 1610090460133, //trade timestamp
8406
+ // "amount": "23.72469206", //order amount(up to 8 decimal places), positive is income, negative is expenditure
8407
+ // "currency": "BNB",
8408
+ // "walletType": 1, //main wallet type, 1 for funding wallet, 2 for spot wallet, 3 for fiat wallet, 4 or 6 for card payment, 5 for earn wallet
8409
+ // "walletTypes": [1,2], //array format,there are multiple values when using combination payment
8410
+ // "fundsDetail": [ // details
8411
+ // {
8412
+ // "currency": "USDT", //asset
8413
+ // "amount": "1.2",
8414
+ // "walletAssetCost":[ //details of asset cost per wallet
8415
+ // {"1":"0.6"},
8416
+ // {"2":"0.6"}
8417
+ // ]
8418
+ // },
8419
+ // {
8420
+ // "currency": "ETH",
8421
+ // "amount": "0.0001",
8422
+ // "walletAssetCost":[
8423
+ // {"1":"0.00005"},
8424
+ // {"2":"0.00005"}
8425
+ // ]
8426
+ // }
8427
+ // ],
8428
+ // "payerInfo":{
8429
+ // "name":"Jack", //nickname or merchant name
8430
+ // "type":"USER", //account type,USER for personal,MERCHANT for merchant
8431
+ // "binanceId":"12345678", //binance uid
8432
+ // "accountId":"67736251" //binance pay id
8433
+ // },
8434
+ // "receiverInfo":{
8435
+ // "name":"Alan", //nickname or merchant name
8436
+ // "type":"MERCHANT", //account type,USER for personal,MERCHANT for merchant
8437
+ // "email":"alan@binance.com", //email
8438
+ // "binanceId":"34355667", //binance uid
8439
+ // "accountId":"21326891", //binance pay id
8440
+ // "countryCode":"1", //International area code
8441
+ // "phoneNumber":"8057651210",
8442
+ // "mobileCode":"US", //country code
8443
+ // "extend":[ //extension field
8444
+ // "institutionName": "",
8445
+ // "cardNumber": "",
8446
+ // "digitalWalletId": ""
8447
+ // ]
8448
+ // }
8449
+ // }
8450
+ // ],
8451
+ // "success": true
8452
+ // }
8453
+ //
8454
+ }
8455
+ else {
8456
+ response = await this.sapiGetAssetTransfer(this.extend(request, params));
8457
+ //
8458
+ // {
8459
+ // "total": 3,
8460
+ // "rows": [
8461
+ // {
8462
+ // "timestamp": 1614640878000,
8463
+ // "asset": "USDT",
8464
+ // "amount": "25",
8465
+ // "type": "MAIN_UMFUTURE",
8466
+ // "status": "CONFIRMED",
8467
+ // "tranId": 43000126248
8468
+ // },
8469
+ // ]
8470
+ // }
8471
+ //
8472
+ }
8473
+ const rows = this.safeList2(response, 'rows', 'data', []);
8349
8474
  return this.parseTransfers(rows, currency, since, limit);
8350
8475
  }
8351
8476
  async fetchDepositAddress(code, params = {}) {