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
@@ -620,4 +620,15 @@ export default class coinbase extends Exchange {
620
620
  headers: any;
621
621
  };
622
622
  handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
623
+ /**
624
+ * @method
625
+ * @name coinbase#fetchDepositAddresses
626
+ * @description fetch deposit addresses for multiple currencies (when available)
627
+ * @see https://coinbase-migration.mintlify.app/coinbase-app/transfer-apis/onchain-addresses
628
+ * @param {string[]} [codes] list of unified currency codes, default is undefined (all currencies)
629
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
630
+ * @param {string} [params.accountId] account ID to fetch deposit addresses for
631
+ * @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure} indexed by currency code
632
+ */
633
+ fetchDepositAddresses(codes?: Strings, params?: {}): Promise<DepositAddress[]>;
623
634
  }
@@ -88,7 +88,7 @@ export default class coinbase extends Exchange {
88
88
  'fetchCurrencies': true,
89
89
  'fetchDeposit': true,
90
90
  'fetchDepositAddress': 'emulated',
91
- 'fetchDepositAddresses': false,
91
+ 'fetchDepositAddresses': true,
92
92
  'fetchDepositAddressesByNetwork': true,
93
93
  'fetchDepositMethodId': true,
94
94
  'fetchDepositMethodIds': true,
@@ -4302,6 +4302,19 @@ export default class coinbase extends Exchange {
4302
4302
  // }
4303
4303
  // }
4304
4304
  //
4305
+ // {
4306
+ // "id":"3f2434234943-8c1c-50ef-a5a1-342213bbf45d",
4307
+ // "address":"0x123123126F5921XXXXX",
4308
+ // "currency":"USDC",
4309
+ // "name":"",
4310
+ // "network":"ethereum",
4311
+ // "created_at":"2022-03-17T09:20:17.002Z",
4312
+ // "updated_at":"2022-03-17T09:20:17.002Z",
4313
+ // "resource":"addresses",
4314
+ // "resource_path":"v2/accounts/b1091c6e-9ef2-5e4d-b352-665d0cf8f742/addresses/32fd0943-8c1c-50ef-a5a1-342213bbf45d",
4315
+ // "destination_tag":""
4316
+ // }
4317
+ //
4305
4318
  const address = this.safeString(depositAddress, 'address');
4306
4319
  this.checkAddress(address);
4307
4320
  const networkId = this.safeString(depositAddress, 'network');
@@ -4312,6 +4325,9 @@ export default class coinbase extends Exchange {
4312
4325
  const splitAddressLabel = addressLabel.split(' ');
4313
4326
  currencyId = this.safeString(splitAddressLabel, 0);
4314
4327
  }
4328
+ else {
4329
+ currencyId = this.safeString(depositAddress, 'currency');
4330
+ }
4315
4331
  const addressInfo = this.safeDict(depositAddress, 'address_info');
4316
4332
  return {
4317
4333
  'info': depositAddress,
@@ -5236,4 +5252,21 @@ export default class coinbase extends Exchange {
5236
5252
  }
5237
5253
  return undefined;
5238
5254
  }
5255
+ /**
5256
+ * @method
5257
+ * @name coinbase#fetchDepositAddresses
5258
+ * @description fetch deposit addresses for multiple currencies (when available)
5259
+ * @see https://coinbase-migration.mintlify.app/coinbase-app/transfer-apis/onchain-addresses
5260
+ * @param {string[]} [codes] list of unified currency codes, default is undefined (all currencies)
5261
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5262
+ * @param {string} [params.accountId] account ID to fetch deposit addresses for
5263
+ * @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure} indexed by currency code
5264
+ */
5265
+ async fetchDepositAddresses(codes = undefined, params = {}) {
5266
+ await this.loadMarkets();
5267
+ const request = this.prepareAccountRequest(undefined, params);
5268
+ const response = await this.v2PrivateGetAccountsAccountIdAddresses(this.extend(request, params));
5269
+ const data = this.safeList(response, 'data', []);
5270
+ return this.parseDepositAddresses(data, codes, false, {});
5271
+ }
5239
5272
  }
package/js/src/dydx.js CHANGED
@@ -506,9 +506,9 @@ export default class dydx extends Exchange {
506
506
  const marketId = this.safeString(market, 'ticker');
507
507
  const parts = marketId.split('-');
508
508
  const baseName = this.safeString(parts, 0);
509
- const base = this.safeCurrencyCode(baseName);
509
+ const baseId = this.safeString(market, 'baseId', baseName); // idk where 'baseId' comes from, but leaving as is
510
+ const base = this.safeCurrencyCode(baseId);
510
511
  const quote = this.safeCurrencyCode(quoteId);
511
- const baseId = this.safeString(market, 'baseId');
512
512
  const settleId = 'USDC';
513
513
  const settle = this.safeCurrencyCode(settleId);
514
514
  const symbol = base + '/' + quote + ':' + settle;
@@ -539,11 +539,11 @@ export default class dydx extends Exchange {
539
539
  'option': false,
540
540
  'active': active,
541
541
  'contract': contract,
542
+ 'contractSize': this.parseNumber('1'),
542
543
  'linear': true,
543
544
  'inverse': false,
544
545
  'taker': undefined,
545
546
  'maker': undefined,
546
- 'contractSize': undefined,
547
547
  'expiry': undefined,
548
548
  'expiryDatetime': undefined,
549
549
  'strike': undefined,
package/js/src/gate.js CHANGED
@@ -1041,7 +1041,7 @@ export default class gate extends Exchange {
1041
1041
  // https://www.gate.com/docs/developers/apiv4/en/#label-list
1042
1042
  'exceptions': {
1043
1043
  'exact': {
1044
- 'INVALID_PARAM_VALUE': BadRequest,
1044
+ 'INVALID_PARAM_VALUE': InvalidOrder,
1045
1045
  'INVALID_PROTOCOL': BadRequest,
1046
1046
  'INVALID_ARGUMENT': BadRequest,
1047
1047
  'INVALID_REQUEST_BODY': BadRequest,
@@ -1136,7 +1136,8 @@ export default class gate extends Exchange {
1136
1136
  'AUTO_TRIGGER_PRICE_GREATE_LAST': InvalidOrder,
1137
1137
  'POSITION_HOLDING': BadRequest,
1138
1138
  'USER_LOAN_EXCEEDED': BadRequest,
1139
- 'NO_CHANGE': InvalidOrder, // {"label":"NO_CHANGE","message":"No change is made"}
1139
+ 'NO_CHANGE': InvalidOrder,
1140
+ 'PRICE_THRESHOLD_EXCEEDED': InvalidOrder, // {"label":"PRICE_THRESHOLD_EXCEEDED","message":": 0.45288"}
1140
1141
  },
1141
1142
  'broad': {},
1142
1143
  },
@@ -579,17 +579,24 @@ export default class hyperliquid extends Exchange {
579
579
  let fetchDexesList = [];
580
580
  const options = this.safeDict(this.options, 'fetchMarkets', {});
581
581
  const hip3 = this.safeDict(options, 'hip3', {});
582
- const dexesProvided = this.safeList(hip3, 'dexes'); // let users provide their own list of dexes to load
582
+ const dexesProvided = this.safeList(hip3, 'dexes', []); // let users provide their own list of dexes to load
583
583
  const maxLimit = this.safeInteger(hip3, 'limit', 10);
584
- if (dexesProvided !== undefined) {
585
- const userProvidedDexesLength = dexesProvided.length;
584
+ const userProvidedDexesLength = dexesProvided.length;
585
+ if (userProvidedDexesLength > 0) {
586
586
  if (userProvidedDexesLength > 0) {
587
587
  fetchDexesList = dexesProvided;
588
588
  }
589
589
  }
590
590
  else {
591
+ const fetchDexesLength = fetchDexes.length;
591
592
  for (let i = 1; i < maxLimit; i++) {
593
+ if (i >= fetchDexesLength) {
594
+ break;
595
+ }
592
596
  const dex = this.safeDict(fetchDexes, i, {});
597
+ if (dex === undefined) {
598
+ continue;
599
+ }
593
600
  const dexName = this.safeString(dex, 'name');
594
601
  fetchDexesList.push(dexName);
595
602
  }
@@ -803,4 +803,18 @@ export default class kucoin extends Exchange {
803
803
  headers: any;
804
804
  };
805
805
  handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
806
+ /**
807
+ * @method
808
+ * @name kucoin#fetchTransfers
809
+ * @description fetch a history of internal transfers made on an account
810
+ * @see https://www.kucoin.com/docs-new/rest/account-info/account-funding/get-account-ledgers-spot-margin
811
+ * @param {string} [code] unified currency code of the currency transferred
812
+ * @param {int} [since] the earliest time in ms to fetch transfers for
813
+ * @param {int} [limit] the maximum number of transfer structures to retrieve
814
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
815
+ * @param {int} [params.until] the latest time in ms to fetch transfers for
816
+ * @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)
817
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
818
+ */
819
+ fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
806
820
  }
package/js/src/kucoin.js CHANGED
@@ -106,7 +106,7 @@ export default class kucoin extends Exchange {
106
106
  'fetchTradingFee': true,
107
107
  'fetchTradingFees': false,
108
108
  'fetchTransactionFee': true,
109
- 'fetchTransfers': false,
109
+ 'fetchTransfers': true,
110
110
  'fetchWithdrawals': true,
111
111
  'repayCrossMargin': true,
112
112
  'repayIsolatedMargin': true,
@@ -525,6 +525,8 @@ export default class kucoin extends Exchange {
525
525
  'Unsuccessful! Exceeded the max. funds out-transfer limit': InsufficientFunds,
526
526
  'The amount increment is invalid.': BadRequest,
527
527
  'The quantity is below the minimum requirement.': InvalidOrder,
528
+ 'not in the given range!': BadRequest,
529
+ 'recAccountType not in the given range': BadRequest,
528
530
  '400': BadRequest,
529
531
  '401': AuthenticationError,
530
532
  '403': NotSupported,
@@ -4708,16 +4710,49 @@ export default class kucoin extends Exchange {
4708
4710
  // "updatedAt": 1616545569000
4709
4711
  // }
4710
4712
  //
4713
+ // ledger entry - from account ledgers API (for fetchTransfers)
4714
+ //
4715
+ // {
4716
+ // "id": "611a1e7c6a053300067a88d9",
4717
+ // "currency": "USDT",
4718
+ // "amount": "10.00059547",
4719
+ // "fee": "0",
4720
+ // "balance": "0",
4721
+ // "accountType": "MAIN",
4722
+ // "bizType": "Transfer",
4723
+ // "direction": "in",
4724
+ // "createdAt": 1629101692950,
4725
+ // "context": "{\"orderId\":\"611a1e7c6a053300067a88d9\"}"
4726
+ // }
4727
+ //
4711
4728
  const timestamp = this.safeInteger(transfer, 'createdAt');
4712
4729
  const currencyId = this.safeString(transfer, 'currency');
4713
4730
  const rawStatus = this.safeString(transfer, 'status');
4714
- const accountFromRaw = this.safeStringLower(transfer, 'payAccountType');
4715
- const accountToRaw = this.safeStringLower(transfer, 'recAccountType');
4731
+ const bizType = this.safeString(transfer, 'bizType');
4732
+ const isLedgerEntry = (bizType !== undefined);
4733
+ let accountFromRaw = undefined;
4734
+ let accountToRaw = undefined;
4735
+ if (isLedgerEntry) {
4736
+ // Ledger entry format: uses accountType + direction
4737
+ const accountType = this.safeStringLower(transfer, 'accountType');
4738
+ const direction = this.safeString(transfer, 'direction');
4739
+ if (direction === 'out') {
4740
+ accountFromRaw = accountType;
4741
+ }
4742
+ else if (direction === 'in') {
4743
+ accountToRaw = accountType;
4744
+ }
4745
+ }
4746
+ else {
4747
+ // Transfer API format: uses payAccountType/recAccountType
4748
+ accountFromRaw = this.safeStringLower(transfer, 'payAccountType');
4749
+ accountToRaw = this.safeStringLower(transfer, 'recAccountType');
4750
+ }
4716
4751
  const accountsByType = this.safeDict(this.options, 'accountsByType');
4717
4752
  const accountFrom = this.safeString(accountsByType, accountFromRaw, accountFromRaw);
4718
4753
  const accountTo = this.safeString(accountsByType, accountToRaw, accountToRaw);
4719
4754
  return {
4720
- 'id': this.safeString2(transfer, 'applyId', 'orderId'),
4755
+ 'id': this.safeStringN(transfer, ['id', 'applyId', 'orderId']),
4721
4756
  'currency': this.safeCurrencyCode(currencyId, currency),
4722
4757
  'timestamp': timestamp,
4723
4758
  'datetime': this.iso8601(timestamp),
@@ -5810,4 +5845,77 @@ export default class kucoin extends Exchange {
5810
5845
  }
5811
5846
  return undefined;
5812
5847
  }
5848
+ /**
5849
+ * @method
5850
+ * @name kucoin#fetchTransfers
5851
+ * @description fetch a history of internal transfers made on an account
5852
+ * @see https://www.kucoin.com/docs-new/rest/account-info/account-funding/get-account-ledgers-spot-margin
5853
+ * @param {string} [code] unified currency code of the currency transferred
5854
+ * @param {int} [since] the earliest time in ms to fetch transfers for
5855
+ * @param {int} [limit] the maximum number of transfer structures to retrieve
5856
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5857
+ * @param {int} [params.until] the latest time in ms to fetch transfers for
5858
+ * @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)
5859
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
5860
+ */
5861
+ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
5862
+ await this.loadMarkets();
5863
+ let paginate = false;
5864
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
5865
+ if (paginate) {
5866
+ return await this.fetchPaginatedCallDynamic('fetchTransfers', code, since, limit, params);
5867
+ }
5868
+ let request = {
5869
+ 'bizType': 'TRANSFER',
5870
+ };
5871
+ const until = this.safeInteger(params, 'until');
5872
+ if (until !== undefined) {
5873
+ params = this.omit(params, 'until');
5874
+ request['endAt'] = until;
5875
+ }
5876
+ let currency = undefined;
5877
+ if (code !== undefined) {
5878
+ currency = this.currency(code);
5879
+ request['currency'] = currency['id'];
5880
+ }
5881
+ if (since !== undefined) {
5882
+ request['startAt'] = since;
5883
+ }
5884
+ if (limit !== undefined) {
5885
+ request['pageSize'] = limit;
5886
+ }
5887
+ else {
5888
+ request['pageSize'] = 500;
5889
+ }
5890
+ [request, params] = this.handleUntilOption('endAt', request, params);
5891
+ const response = await this.privateGetAccountsLedgers(this.extend(request, params));
5892
+ //
5893
+ // {
5894
+ // "code": "200000",
5895
+ // "data": {
5896
+ // "currentPage": 1,
5897
+ // "pageSize": 50,
5898
+ // "totalNum": 1,
5899
+ // "totalPage": 1,
5900
+ // "items": [
5901
+ // {
5902
+ // "id": "611a1e7c6a053300067a88d9",
5903
+ // "currency": "USDT",
5904
+ // "amount": "10.00059547",
5905
+ // "fee": "0",
5906
+ // "balance": "0",
5907
+ // "accountType": "MAIN",
5908
+ // "bizType": "Transfer",
5909
+ // "direction": "in",
5910
+ // "createdAt": 1629101692950,
5911
+ // "context": "{\"orderId\":\"611a1e7c6a053300067a88d9\"}"
5912
+ // }
5913
+ // ]
5914
+ // }
5915
+ // }
5916
+ //
5917
+ const data = this.safeDict(response, 'data', {});
5918
+ const items = this.safeList(data, 'items', []);
5919
+ return this.parseTransfers(items, currency, since, limit);
5920
+ }
5813
5921
  }
@@ -749,9 +749,11 @@ export default class apex extends apexRest {
749
749
  }
750
750
  }
751
751
  // don't remove the future from the .futures cache
752
- const future = client.futures[messageHash];
753
- future.resolve(cache);
754
- client.resolve(cache, 'positions');
752
+ if (messageHash in client.futures) {
753
+ const future = client.futures[messageHash];
754
+ future.resolve(cache);
755
+ client.resolve(cache, 'positions');
756
+ }
755
757
  }
756
758
  handlePositions(client, lists) {
757
759
  //
@@ -2595,9 +2595,11 @@ export default class binance extends binanceRest {
2595
2595
  const response = await this.fetchBalance(params);
2596
2596
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
2597
2597
  // don't remove the future from the .futures cache
2598
- const future = client.futures[messageHash];
2599
- future.resolve();
2600
- client.resolve(this.balance[type], type + ':balance');
2598
+ if (messageHash in client.futures) {
2599
+ const future = client.futures[messageHash];
2600
+ future.resolve();
2601
+ client.resolve(this.balance[type], type + ':balance');
2602
+ }
2601
2603
  }
2602
2604
  /**
2603
2605
  * @method
@@ -4038,9 +4040,11 @@ export default class binance extends binanceRest {
4038
4040
  }
4039
4041
  }
4040
4042
  // don't remove the future from the .futures cache
4041
- const future = client.futures[messageHash];
4042
- future.resolve(cache);
4043
- client.resolve(cache, type + ':position');
4043
+ if (messageHash in client.futures) {
4044
+ const future = client.futures[messageHash];
4045
+ future.resolve(cache);
4046
+ client.resolve(cache, type + ':position');
4047
+ }
4044
4048
  }
4045
4049
  handlePositions(client, message) {
4046
4050
  //
@@ -1135,9 +1135,11 @@ export default class bingx extends bingxRest {
1135
1135
  const response = await this.fetchBalance({ 'type': type, 'subType': subType });
1136
1136
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
1137
1137
  // don't remove the future from the .futures cache
1138
- const future = client.futures[messageHash];
1139
- future.resolve();
1140
- client.resolve(this.balance[type], type + ':balance');
1138
+ if (messageHash in client.futures) {
1139
+ const future = client.futures[messageHash];
1140
+ future.resolve();
1141
+ client.resolve(this.balance[type], type + ':balance');
1142
+ }
1141
1143
  }
1142
1144
  handleErrorMessage(client, message) {
1143
1145
  //
@@ -234,9 +234,11 @@ export default class bitmart extends bitmartRest {
234
234
  const response = await this.fetchBalance({ 'type': type });
235
235
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
236
236
  // don't remove the future from the .futures cache
237
- const future = client.futures[messageHash];
238
- future.resolve();
239
- client.resolve(this.balance[type], 'balance:' + type);
237
+ if (messageHash in client.futures) {
238
+ const future = client.futures[messageHash];
239
+ future.resolve();
240
+ client.resolve(this.balance[type], 'balance:' + type);
241
+ }
240
242
  }
241
243
  handleBalance(client, message) {
242
244
  //
@@ -1522,9 +1522,11 @@ export default class bybit extends bybitRest {
1522
1522
  }
1523
1523
  }
1524
1524
  // don't remove the future from the .futures cache
1525
- const future = client.futures[messageHash];
1526
- future.resolve(cache);
1527
- client.resolve(cache, 'position');
1525
+ if (messageHash in client.futures) {
1526
+ const future = client.futures[messageHash];
1527
+ future.resolve(cache);
1528
+ client.resolve(cache, 'position');
1529
+ }
1528
1530
  }
1529
1531
  handlePositions(client, message) {
1530
1532
  //
@@ -0,0 +1,206 @@
1
+ import bydfiRest from '../bydfi.js';
2
+ import type { Balances, Dict, Int, Market, OHLCV, Order, OrderBook, Position, Str, Strings, Ticker, Tickers } from '../base/types.js';
3
+ import Client from '../base/ws/Client.js';
4
+ export default class bydfi extends bydfiRest {
5
+ describe(): any;
6
+ ping(client: Client): {
7
+ id: any;
8
+ method: string;
9
+ };
10
+ requestId(): any;
11
+ watchPublic(messageHashes: any, channels: any, params?: {}, subscription?: {}): Promise<any>;
12
+ watchPrivate(messageHashes: any, params?: {}): Promise<any>;
13
+ /**
14
+ * @method
15
+ * @name bydfi#watchTicker
16
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
17
+ * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
18
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
19
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
20
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
21
+ */
22
+ watchTicker(symbol: string, params?: {}): Promise<Ticker>;
23
+ /**
24
+ * @method
25
+ * @name bydfi#unWatchTicker
26
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
27
+ * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
28
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
29
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
30
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
31
+ */
32
+ unWatchTicker(symbol: string, params?: {}): Promise<any>;
33
+ /**
34
+ * @method
35
+ * @name bydfi#watchTickers
36
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
37
+ * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
38
+ * @see https://developers.bydfi.com/en/swap/websocket-market#market-wide-ticker
39
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
40
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
41
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
42
+ */
43
+ watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
44
+ /**
45
+ * @method
46
+ * @name bydfi#unWatchTickers
47
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
48
+ * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
49
+ * @see https://developers.bydfi.com/en/swap/websocket-market#market-wide-ticker
50
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
51
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
52
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
53
+ */
54
+ unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
55
+ getMessageHashesForTickersUnsubscription(): any[];
56
+ handleTicker(client: Client, message: any): void;
57
+ /**
58
+ * @method
59
+ * @name bydfi#watchOHLCV
60
+ * @description watches historical candlestick data containing the open, high, low, close price, and the volume of a market
61
+ * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
62
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
63
+ * @param {string} timeframe the length of time each candle represents
64
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
65
+ * @param {int} [limit] the maximum amount of candles to fetch
66
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
67
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
68
+ */
69
+ watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
70
+ /**
71
+ * @method
72
+ * @name bydfi#unWatchOHLCV
73
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
74
+ * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
75
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
76
+ * @param {string} timeframe the length of time each candle represents
77
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
78
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
79
+ */
80
+ unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
81
+ /**
82
+ * @method
83
+ * @name bydfi#watchOHLCVForSymbols
84
+ * @description watches historical candlestick data containing the open, high, low, close price, and the volume of a market
85
+ * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
86
+ * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
87
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
88
+ * @param {int} [limit] the maximum amount of candles to fetch
89
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
90
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
91
+ */
92
+ watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").Dictionary<OHLCV[]>>>;
93
+ /**
94
+ * @method
95
+ * @name bydfi#unWatchOHLCVForSymbols
96
+ * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
97
+ * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
98
+ * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
99
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
100
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
101
+ */
102
+ unWatchOHLCVForSymbols(symbolsAndTimeframes: string[][], params?: {}): Promise<any>;
103
+ handleOHLCV(client: Client, message: any): void;
104
+ /**
105
+ * @method
106
+ * @name bydfi#watchOrderBook
107
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
108
+ * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
109
+ * @param {string} symbol unified symbol of the market to fetch the order book for
110
+ * @param {int} [limit] the maximum amount of order book entries to return (default and maxi is 100)
111
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
112
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
113
+ */
114
+ watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
115
+ /**
116
+ * @method
117
+ * @name bydfi#unWatchOrderBook
118
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
119
+ * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
120
+ * @param {string} symbol unified array of symbols
121
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
122
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
123
+ */
124
+ unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
125
+ /**
126
+ * @method
127
+ * @name bydfi#watchOrderBookForSymbols
128
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
129
+ * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
130
+ * @param {string[]} symbols unified array of symbols
131
+ * @param {int} [limit] the maximum amount of order book entries to return (default and max is 100)
132
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
133
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
134
+ */
135
+ watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
136
+ /**
137
+ * @method
138
+ * @name bydfi#unWatchOrderBookForSymbols
139
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
140
+ * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
141
+ * @param {string[]} symbols unified array of symbols
142
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
143
+ * @param {string} [params.method] either '/market/level2' or '/spotMarket/level2Depth5' or '/spotMarket/level2Depth50' default is '/market/level2'
144
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
145
+ */
146
+ unWatchOrderBookForSymbols(symbols: string[], params?: {}): Promise<any>;
147
+ handleOrderBook(client: Client, message: any): void;
148
+ /**
149
+ * @method
150
+ * @name bydfi#watchOrders
151
+ * @description watches information on multiple orders made by the user
152
+ * @see https://developers.bydfi.com/en/swap/websocket-account#order-trade-update-push
153
+ * @param {string} symbol unified market symbol of the market orders were made in
154
+ * @param {int} [since] the earliest time in ms to fetch orders for
155
+ * @param {int} [limit] the maximum number of order structures to retrieve
156
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
157
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
158
+ */
159
+ watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
160
+ /**
161
+ * @method
162
+ * @name bydfi#watchOrdersForSymbols
163
+ * @description watches information on multiple orders made by the user
164
+ * @see https://developers.bydfi.com/en/swap/websocket-account#order-trade-update-push
165
+ * @param {string[]} symbols unified symbol of the market to fetch orders for
166
+ * @param {int} [since] the earliest time in ms to fetch orders for
167
+ * @param {int} [limit] the maximum number of trade structures to retrieve
168
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
169
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
170
+ */
171
+ watchOrdersForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
172
+ handleOrder(client: Client, message: any): void;
173
+ parseWsOrder(order: Dict, market?: Market): Order;
174
+ /**
175
+ * @method
176
+ * @name bydfi#watchPositions
177
+ * @description watch all open positions
178
+ * @see https://developers.bydfi.com/en/swap/websocket-account#balance-and-position-update-push
179
+ * @param {string[]} [symbols] list of unified market symbols
180
+ * @param {int} [since] the earliest time in ms to fetch positions for
181
+ * @param {int} [limit] the maximum number of positions to retrieve
182
+ * @param {object} params extra parameters specific to the exchange API endpoint
183
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
184
+ */
185
+ watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
186
+ handlePositions(client: any, message: any): void;
187
+ parseWsPosition(position: any, market?: any): Position;
188
+ parseWsPositionSide(rawPositionSide: Str): Str;
189
+ /**
190
+ * @method
191
+ * @name bydfi#watchBalance
192
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
193
+ * @see https://developers.bydfi.com/en/swap/websocket-account#balance-and-position-update-push
194
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
195
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
196
+ */
197
+ watchBalance(params?: {}): Promise<Balances>;
198
+ fetchBalanceSnapshot(client: Client): void;
199
+ loadBalanceSnapshot(client: any, messageHash: any): Promise<void>;
200
+ handleBalance(client: Client, message: any): void;
201
+ handleSubscriptionStatus(client: Client, message: any): any;
202
+ handleUnSubscription(client: Client, subscription: Dict): void;
203
+ handlePong(client: Client, message: any): any;
204
+ handleErrorMessage(client: Client, message: any): void;
205
+ handleMessage(client: Client, message: any): void;
206
+ }