ccxt 4.5.29 → 4.5.30

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 (63) hide show
  1. package/README.md +6 -5
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/bydfi.js +11 -0
  5. package/dist/cjs/src/bingx.js +1 -1
  6. package/dist/cjs/src/bullish.js +1 -1
  7. package/dist/cjs/src/bybit.js +2 -0
  8. package/dist/cjs/src/bydfi.js +2907 -0
  9. package/dist/cjs/src/coinbase.js +34 -1
  10. package/dist/cjs/src/dydx.js +3 -3
  11. package/dist/cjs/src/gate.js +3 -2
  12. package/dist/cjs/src/hyperliquid.js +10 -3
  13. package/dist/cjs/src/kucoin.js +112 -4
  14. package/dist/cjs/src/pro/apex.js +5 -3
  15. package/dist/cjs/src/pro/binance.js +10 -6
  16. package/dist/cjs/src/pro/bingx.js +5 -3
  17. package/dist/cjs/src/pro/bitmart.js +5 -3
  18. package/dist/cjs/src/pro/bybit.js +5 -3
  19. package/dist/cjs/src/pro/bydfi.js +1077 -0
  20. package/dist/cjs/src/pro/cryptocom.js +5 -3
  21. package/dist/cjs/src/pro/gate.js +5 -3
  22. package/dist/cjs/src/pro/hashkey.js +5 -3
  23. package/dist/cjs/src/pro/kucoinfutures.js +5 -3
  24. package/dist/cjs/src/pro/modetrade.js +5 -3
  25. package/dist/cjs/src/pro/toobit.js +11 -7
  26. package/dist/cjs/src/pro/woo.js +5 -3
  27. package/dist/cjs/src/pro/woofipro.js +5 -3
  28. package/dist/cjs/src/pro/xt.js +5 -3
  29. package/dist/cjs/src/toobit.js +2 -1
  30. package/js/ccxt.d.ts +8 -2
  31. package/js/ccxt.js +6 -2
  32. package/js/src/abstract/bydfi.d.ts +52 -0
  33. package/js/src/abstract/bydfi.js +11 -0
  34. package/js/src/bingx.js +1 -1
  35. package/js/src/bullish.js +1 -1
  36. package/js/src/bybit.js +2 -0
  37. package/js/src/bydfi.d.ts +472 -0
  38. package/js/src/bydfi.js +2905 -0
  39. package/js/src/coinbase.d.ts +11 -0
  40. package/js/src/coinbase.js +34 -1
  41. package/js/src/dydx.js +3 -3
  42. package/js/src/gate.js +3 -2
  43. package/js/src/hyperliquid.js +10 -3
  44. package/js/src/kucoin.d.ts +14 -0
  45. package/js/src/kucoin.js +112 -4
  46. package/js/src/pro/apex.js +5 -3
  47. package/js/src/pro/binance.js +10 -6
  48. package/js/src/pro/bingx.js +5 -3
  49. package/js/src/pro/bitmart.js +5 -3
  50. package/js/src/pro/bybit.js +5 -3
  51. package/js/src/pro/bydfi.d.ts +206 -0
  52. package/js/src/pro/bydfi.js +1076 -0
  53. package/js/src/pro/cryptocom.js +5 -3
  54. package/js/src/pro/gate.js +5 -3
  55. package/js/src/pro/hashkey.js +5 -3
  56. package/js/src/pro/kucoinfutures.js +5 -3
  57. package/js/src/pro/modetrade.js +5 -3
  58. package/js/src/pro/toobit.js +11 -7
  59. package/js/src/pro/woo.js +5 -3
  60. package/js/src/pro/woofipro.js +5 -3
  61. package/js/src/pro/xt.js +5 -3
  62. package/js/src/toobit.js +2 -1
  63. package/package.json +1 -1
@@ -87,7 +87,7 @@ class coinbase extends coinbase$1["default"] {
87
87
  'fetchCurrencies': true,
88
88
  'fetchDeposit': true,
89
89
  'fetchDepositAddress': 'emulated',
90
- 'fetchDepositAddresses': false,
90
+ 'fetchDepositAddresses': true,
91
91
  'fetchDepositAddressesByNetwork': true,
92
92
  'fetchDepositMethodId': true,
93
93
  'fetchDepositMethodIds': true,
@@ -4301,6 +4301,19 @@ class coinbase extends coinbase$1["default"] {
4301
4301
  // }
4302
4302
  // }
4303
4303
  //
4304
+ // {
4305
+ // "id":"3f2434234943-8c1c-50ef-a5a1-342213bbf45d",
4306
+ // "address":"0x123123126F5921XXXXX",
4307
+ // "currency":"USDC",
4308
+ // "name":"",
4309
+ // "network":"ethereum",
4310
+ // "created_at":"2022-03-17T09:20:17.002Z",
4311
+ // "updated_at":"2022-03-17T09:20:17.002Z",
4312
+ // "resource":"addresses",
4313
+ // "resource_path":"v2/accounts/b1091c6e-9ef2-5e4d-b352-665d0cf8f742/addresses/32fd0943-8c1c-50ef-a5a1-342213bbf45d",
4314
+ // "destination_tag":""
4315
+ // }
4316
+ //
4304
4317
  const address = this.safeString(depositAddress, 'address');
4305
4318
  this.checkAddress(address);
4306
4319
  const networkId = this.safeString(depositAddress, 'network');
@@ -4311,6 +4324,9 @@ class coinbase extends coinbase$1["default"] {
4311
4324
  const splitAddressLabel = addressLabel.split(' ');
4312
4325
  currencyId = this.safeString(splitAddressLabel, 0);
4313
4326
  }
4327
+ else {
4328
+ currencyId = this.safeString(depositAddress, 'currency');
4329
+ }
4314
4330
  const addressInfo = this.safeDict(depositAddress, 'address_info');
4315
4331
  return {
4316
4332
  'info': depositAddress,
@@ -5235,6 +5251,23 @@ class coinbase extends coinbase$1["default"] {
5235
5251
  }
5236
5252
  return undefined;
5237
5253
  }
5254
+ /**
5255
+ * @method
5256
+ * @name coinbase#fetchDepositAddresses
5257
+ * @description fetch deposit addresses for multiple currencies (when available)
5258
+ * @see https://coinbase-migration.mintlify.app/coinbase-app/transfer-apis/onchain-addresses
5259
+ * @param {string[]} [codes] list of unified currency codes, default is undefined (all currencies)
5260
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5261
+ * @param {string} [params.accountId] account ID to fetch deposit addresses for
5262
+ * @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure} indexed by currency code
5263
+ */
5264
+ async fetchDepositAddresses(codes = undefined, params = {}) {
5265
+ await this.loadMarkets();
5266
+ const request = this.prepareAccountRequest(undefined, params);
5267
+ const response = await this.v2PrivateGetAccountsAccountIdAddresses(this.extend(request, params));
5268
+ const data = this.safeList(response, 'data', []);
5269
+ return this.parseDepositAddresses(data, codes, false, {});
5270
+ }
5238
5271
  }
5239
5272
 
5240
5273
  exports["default"] = coinbase;
@@ -505,9 +505,9 @@ class dydx extends dydx$1["default"] {
505
505
  const marketId = this.safeString(market, 'ticker');
506
506
  const parts = marketId.split('-');
507
507
  const baseName = this.safeString(parts, 0);
508
- const base = this.safeCurrencyCode(baseName);
508
+ const baseId = this.safeString(market, 'baseId', baseName); // idk where 'baseId' comes from, but leaving as is
509
+ const base = this.safeCurrencyCode(baseId);
509
510
  const quote = this.safeCurrencyCode(quoteId);
510
- const baseId = this.safeString(market, 'baseId');
511
511
  const settleId = 'USDC';
512
512
  const settle = this.safeCurrencyCode(settleId);
513
513
  const symbol = base + '/' + quote + ':' + settle;
@@ -538,11 +538,11 @@ class dydx extends dydx$1["default"] {
538
538
  'option': false,
539
539
  'active': active,
540
540
  'contract': contract,
541
+ 'contractSize': this.parseNumber('1'),
541
542
  'linear': true,
542
543
  'inverse': false,
543
544
  'taker': undefined,
544
545
  'maker': undefined,
545
- 'contractSize': undefined,
546
546
  'expiry': undefined,
547
547
  'expiryDatetime': undefined,
548
548
  'strike': undefined,
@@ -1040,7 +1040,7 @@ class gate extends gate$1["default"] {
1040
1040
  // https://www.gate.com/docs/developers/apiv4/en/#label-list
1041
1041
  'exceptions': {
1042
1042
  'exact': {
1043
- 'INVALID_PARAM_VALUE': errors.BadRequest,
1043
+ 'INVALID_PARAM_VALUE': errors.InvalidOrder,
1044
1044
  'INVALID_PROTOCOL': errors.BadRequest,
1045
1045
  'INVALID_ARGUMENT': errors.BadRequest,
1046
1046
  'INVALID_REQUEST_BODY': errors.BadRequest,
@@ -1135,7 +1135,8 @@ class gate extends gate$1["default"] {
1135
1135
  'AUTO_TRIGGER_PRICE_GREATE_LAST': errors.InvalidOrder,
1136
1136
  'POSITION_HOLDING': errors.BadRequest,
1137
1137
  'USER_LOAN_EXCEEDED': errors.BadRequest,
1138
- 'NO_CHANGE': errors.InvalidOrder, // {"label":"NO_CHANGE","message":"No change is made"}
1138
+ 'NO_CHANGE': errors.InvalidOrder,
1139
+ 'PRICE_THRESHOLD_EXCEEDED': errors.InvalidOrder, // {"label":"PRICE_THRESHOLD_EXCEEDED","message":": 0.45288"}
1139
1140
  },
1140
1141
  'broad': {},
1141
1142
  },
@@ -578,17 +578,24 @@ class hyperliquid extends hyperliquid$1["default"] {
578
578
  let fetchDexesList = [];
579
579
  const options = this.safeDict(this.options, 'fetchMarkets', {});
580
580
  const hip3 = this.safeDict(options, 'hip3', {});
581
- const dexesProvided = this.safeList(hip3, 'dexes'); // let users provide their own list of dexes to load
581
+ const dexesProvided = this.safeList(hip3, 'dexes', []); // let users provide their own list of dexes to load
582
582
  const maxLimit = this.safeInteger(hip3, 'limit', 10);
583
- if (dexesProvided !== undefined) {
584
- const userProvidedDexesLength = dexesProvided.length;
583
+ const userProvidedDexesLength = dexesProvided.length;
584
+ if (userProvidedDexesLength > 0) {
585
585
  if (userProvidedDexesLength > 0) {
586
586
  fetchDexesList = dexesProvided;
587
587
  }
588
588
  }
589
589
  else {
590
+ const fetchDexesLength = fetchDexes.length;
590
591
  for (let i = 1; i < maxLimit; i++) {
592
+ if (i >= fetchDexesLength) {
593
+ break;
594
+ }
591
595
  const dex = this.safeDict(fetchDexes, i, {});
596
+ if (dex === undefined) {
597
+ continue;
598
+ }
592
599
  const dexName = this.safeString(dex, 'name');
593
600
  fetchDexesList.push(dexName);
594
601
  }
@@ -105,7 +105,7 @@ class kucoin extends kucoin$1["default"] {
105
105
  'fetchTradingFee': true,
106
106
  'fetchTradingFees': false,
107
107
  'fetchTransactionFee': true,
108
- 'fetchTransfers': false,
108
+ 'fetchTransfers': true,
109
109
  'fetchWithdrawals': true,
110
110
  'repayCrossMargin': true,
111
111
  'repayIsolatedMargin': true,
@@ -524,6 +524,8 @@ class kucoin extends kucoin$1["default"] {
524
524
  'Unsuccessful! Exceeded the max. funds out-transfer limit': errors.InsufficientFunds,
525
525
  'The amount increment is invalid.': errors.BadRequest,
526
526
  'The quantity is below the minimum requirement.': errors.InvalidOrder,
527
+ 'not in the given range!': errors.BadRequest,
528
+ 'recAccountType not in the given range': errors.BadRequest,
527
529
  '400': errors.BadRequest,
528
530
  '401': errors.AuthenticationError,
529
531
  '403': errors.NotSupported,
@@ -4707,16 +4709,49 @@ class kucoin extends kucoin$1["default"] {
4707
4709
  // "updatedAt": 1616545569000
4708
4710
  // }
4709
4711
  //
4712
+ // ledger entry - from account ledgers API (for fetchTransfers)
4713
+ //
4714
+ // {
4715
+ // "id": "611a1e7c6a053300067a88d9",
4716
+ // "currency": "USDT",
4717
+ // "amount": "10.00059547",
4718
+ // "fee": "0",
4719
+ // "balance": "0",
4720
+ // "accountType": "MAIN",
4721
+ // "bizType": "Transfer",
4722
+ // "direction": "in",
4723
+ // "createdAt": 1629101692950,
4724
+ // "context": "{\"orderId\":\"611a1e7c6a053300067a88d9\"}"
4725
+ // }
4726
+ //
4710
4727
  const timestamp = this.safeInteger(transfer, 'createdAt');
4711
4728
  const currencyId = this.safeString(transfer, 'currency');
4712
4729
  const rawStatus = this.safeString(transfer, 'status');
4713
- const accountFromRaw = this.safeStringLower(transfer, 'payAccountType');
4714
- const accountToRaw = this.safeStringLower(transfer, 'recAccountType');
4730
+ const bizType = this.safeString(transfer, 'bizType');
4731
+ const isLedgerEntry = (bizType !== undefined);
4732
+ let accountFromRaw = undefined;
4733
+ let accountToRaw = undefined;
4734
+ if (isLedgerEntry) {
4735
+ // Ledger entry format: uses accountType + direction
4736
+ const accountType = this.safeStringLower(transfer, 'accountType');
4737
+ const direction = this.safeString(transfer, 'direction');
4738
+ if (direction === 'out') {
4739
+ accountFromRaw = accountType;
4740
+ }
4741
+ else if (direction === 'in') {
4742
+ accountToRaw = accountType;
4743
+ }
4744
+ }
4745
+ else {
4746
+ // Transfer API format: uses payAccountType/recAccountType
4747
+ accountFromRaw = this.safeStringLower(transfer, 'payAccountType');
4748
+ accountToRaw = this.safeStringLower(transfer, 'recAccountType');
4749
+ }
4715
4750
  const accountsByType = this.safeDict(this.options, 'accountsByType');
4716
4751
  const accountFrom = this.safeString(accountsByType, accountFromRaw, accountFromRaw);
4717
4752
  const accountTo = this.safeString(accountsByType, accountToRaw, accountToRaw);
4718
4753
  return {
4719
- 'id': this.safeString2(transfer, 'applyId', 'orderId'),
4754
+ 'id': this.safeStringN(transfer, ['id', 'applyId', 'orderId']),
4720
4755
  'currency': this.safeCurrencyCode(currencyId, currency),
4721
4756
  'timestamp': timestamp,
4722
4757
  'datetime': this.iso8601(timestamp),
@@ -5809,6 +5844,79 @@ class kucoin extends kucoin$1["default"] {
5809
5844
  }
5810
5845
  return undefined;
5811
5846
  }
5847
+ /**
5848
+ * @method
5849
+ * @name kucoin#fetchTransfers
5850
+ * @description fetch a history of internal transfers made on an account
5851
+ * @see https://www.kucoin.com/docs-new/rest/account-info/account-funding/get-account-ledgers-spot-margin
5852
+ * @param {string} [code] unified currency code of the currency transferred
5853
+ * @param {int} [since] the earliest time in ms to fetch transfers for
5854
+ * @param {int} [limit] the maximum number of transfer structures to retrieve
5855
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5856
+ * @param {int} [params.until] the latest time in ms to fetch transfers for
5857
+ * @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)
5858
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
5859
+ */
5860
+ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
5861
+ await this.loadMarkets();
5862
+ let paginate = false;
5863
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
5864
+ if (paginate) {
5865
+ return await this.fetchPaginatedCallDynamic('fetchTransfers', code, since, limit, params);
5866
+ }
5867
+ let request = {
5868
+ 'bizType': 'TRANSFER',
5869
+ };
5870
+ const until = this.safeInteger(params, 'until');
5871
+ if (until !== undefined) {
5872
+ params = this.omit(params, 'until');
5873
+ request['endAt'] = until;
5874
+ }
5875
+ let currency = undefined;
5876
+ if (code !== undefined) {
5877
+ currency = this.currency(code);
5878
+ request['currency'] = currency['id'];
5879
+ }
5880
+ if (since !== undefined) {
5881
+ request['startAt'] = since;
5882
+ }
5883
+ if (limit !== undefined) {
5884
+ request['pageSize'] = limit;
5885
+ }
5886
+ else {
5887
+ request['pageSize'] = 500;
5888
+ }
5889
+ [request, params] = this.handleUntilOption('endAt', request, params);
5890
+ const response = await this.privateGetAccountsLedgers(this.extend(request, params));
5891
+ //
5892
+ // {
5893
+ // "code": "200000",
5894
+ // "data": {
5895
+ // "currentPage": 1,
5896
+ // "pageSize": 50,
5897
+ // "totalNum": 1,
5898
+ // "totalPage": 1,
5899
+ // "items": [
5900
+ // {
5901
+ // "id": "611a1e7c6a053300067a88d9",
5902
+ // "currency": "USDT",
5903
+ // "amount": "10.00059547",
5904
+ // "fee": "0",
5905
+ // "balance": "0",
5906
+ // "accountType": "MAIN",
5907
+ // "bizType": "Transfer",
5908
+ // "direction": "in",
5909
+ // "createdAt": 1629101692950,
5910
+ // "context": "{\"orderId\":\"611a1e7c6a053300067a88d9\"}"
5911
+ // }
5912
+ // ]
5913
+ // }
5914
+ // }
5915
+ //
5916
+ const data = this.safeDict(response, 'data', {});
5917
+ const items = this.safeList(data, 'items', []);
5918
+ return this.parseTransfers(items, currency, since, limit);
5919
+ }
5812
5920
  }
5813
5921
 
5814
5922
  exports["default"] = kucoin;
@@ -748,9 +748,11 @@ class apex extends apex$1["default"] {
748
748
  }
749
749
  }
750
750
  // don't remove the future from the .futures cache
751
- const future = client.futures[messageHash];
752
- future.resolve(cache);
753
- client.resolve(cache, 'positions');
751
+ if (messageHash in client.futures) {
752
+ const future = client.futures[messageHash];
753
+ future.resolve(cache);
754
+ client.resolve(cache, 'positions');
755
+ }
754
756
  }
755
757
  handlePositions(client, lists) {
756
758
  //
@@ -2594,9 +2594,11 @@ class binance extends binance$1["default"] {
2594
2594
  const response = await this.fetchBalance(params);
2595
2595
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
2596
2596
  // don't remove the future from the .futures cache
2597
- const future = client.futures[messageHash];
2598
- future.resolve();
2599
- client.resolve(this.balance[type], type + ':balance');
2597
+ if (messageHash in client.futures) {
2598
+ const future = client.futures[messageHash];
2599
+ future.resolve();
2600
+ client.resolve(this.balance[type], type + ':balance');
2601
+ }
2600
2602
  }
2601
2603
  /**
2602
2604
  * @method
@@ -4037,9 +4039,11 @@ class binance extends binance$1["default"] {
4037
4039
  }
4038
4040
  }
4039
4041
  // don't remove the future from the .futures cache
4040
- const future = client.futures[messageHash];
4041
- future.resolve(cache);
4042
- client.resolve(cache, type + ':position');
4042
+ if (messageHash in client.futures) {
4043
+ const future = client.futures[messageHash];
4044
+ future.resolve(cache);
4045
+ client.resolve(cache, type + ':position');
4046
+ }
4043
4047
  }
4044
4048
  handlePositions(client, message) {
4045
4049
  //
@@ -1134,9 +1134,11 @@ class bingx extends bingx$1["default"] {
1134
1134
  const response = await this.fetchBalance({ 'type': type, 'subType': subType });
1135
1135
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
1136
1136
  // don't remove the future from the .futures cache
1137
- const future = client.futures[messageHash];
1138
- future.resolve();
1139
- client.resolve(this.balance[type], type + ':balance');
1137
+ if (messageHash in client.futures) {
1138
+ const future = client.futures[messageHash];
1139
+ future.resolve();
1140
+ client.resolve(this.balance[type], type + ':balance');
1141
+ }
1140
1142
  }
1141
1143
  handleErrorMessage(client, message) {
1142
1144
  //
@@ -233,9 +233,11 @@ class bitmart extends bitmart$1["default"] {
233
233
  const response = await this.fetchBalance({ 'type': type });
234
234
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
235
235
  // don't remove the future from the .futures cache
236
- const future = client.futures[messageHash];
237
- future.resolve();
238
- client.resolve(this.balance[type], 'balance:' + type);
236
+ if (messageHash in client.futures) {
237
+ const future = client.futures[messageHash];
238
+ future.resolve();
239
+ client.resolve(this.balance[type], 'balance:' + type);
240
+ }
239
241
  }
240
242
  handleBalance(client, message) {
241
243
  //
@@ -1521,9 +1521,11 @@ class bybit extends bybit$1["default"] {
1521
1521
  }
1522
1522
  }
1523
1523
  // don't remove the future from the .futures cache
1524
- const future = client.futures[messageHash];
1525
- future.resolve(cache);
1526
- client.resolve(cache, 'position');
1524
+ if (messageHash in client.futures) {
1525
+ const future = client.futures[messageHash];
1526
+ future.resolve(cache);
1527
+ client.resolve(cache, 'position');
1528
+ }
1527
1529
  }
1528
1530
  handlePositions(client, message) {
1529
1531
  //