ccxt 4.2.87 → 4.2.89

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 (131) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +4 -5
  3. package/dist/ccxt.browser.js +311 -167
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +6 -1
  6. package/dist/cjs/src/ascendex.js +2 -0
  7. package/dist/cjs/src/base/Exchange.js +41 -9
  8. package/dist/cjs/src/binance.js +12 -6
  9. package/dist/cjs/src/bitflyer.js +2 -0
  10. package/dist/cjs/src/bitget.js +24 -17
  11. package/dist/cjs/src/bitmart.js +2 -0
  12. package/dist/cjs/src/bitstamp.js +83 -99
  13. package/dist/cjs/src/blofin.js +2 -0
  14. package/dist/cjs/src/bybit.js +2 -0
  15. package/dist/cjs/src/coinsph.js +2 -0
  16. package/dist/cjs/src/cryptocom.js +1 -1
  17. package/dist/cjs/src/digifinex.js +2 -0
  18. package/dist/cjs/src/gate.js +10 -8
  19. package/dist/cjs/src/hitbtc.js +2 -0
  20. package/dist/cjs/src/htx.js +2 -0
  21. package/dist/cjs/src/krakenfutures.js +2 -1
  22. package/dist/cjs/src/kucoin.js +46 -19
  23. package/dist/cjs/src/latoken.js +4 -0
  24. package/dist/cjs/src/lbank.js +3 -1
  25. package/dist/cjs/src/luno.js +2 -0
  26. package/dist/cjs/src/mexc.js +55 -7
  27. package/dist/cjs/src/okx.js +2 -0
  28. package/dist/cjs/src/pro/bitget.js +2 -0
  29. package/dist/cjs/src/timex.js +2 -0
  30. package/examples/js/cli.js +0 -2
  31. package/examples/ts/cli.ts +0 -2
  32. package/js/ccxt.d.ts +3 -3
  33. package/js/ccxt.js +3 -3
  34. package/js/src/ascendex.d.ts +3 -3
  35. package/js/src/ascendex.js +2 -0
  36. package/js/src/base/Exchange.d.ts +9 -8
  37. package/js/src/base/Exchange.js +41 -9
  38. package/js/src/base/types.d.ts +35 -2
  39. package/js/src/bigone.d.ts +2 -2
  40. package/js/src/binance.d.ts +6 -16
  41. package/js/src/binance.js +12 -6
  42. package/js/src/bingx.d.ts +2 -2
  43. package/js/src/bit2c.d.ts +2 -2
  44. package/js/src/bitbank.d.ts +2 -2
  45. package/js/src/bitfinex.d.ts +2 -2
  46. package/js/src/bitfinex2.d.ts +3 -3
  47. package/js/src/bitflyer.d.ts +2 -7
  48. package/js/src/bitflyer.js +2 -0
  49. package/js/src/bitget.d.ts +6 -9
  50. package/js/src/bitget.js +24 -17
  51. package/js/src/bitmart.d.ts +4 -14
  52. package/js/src/bitmart.js +2 -0
  53. package/js/src/bitmex.d.ts +2 -2
  54. package/js/src/bitopro.d.ts +3 -3
  55. package/js/src/bitrue.d.ts +2 -2
  56. package/js/src/bitso.d.ts +2 -2
  57. package/js/src/bitstamp.d.ts +7 -19
  58. package/js/src/bitstamp.js +83 -99
  59. package/js/src/bitteam.d.ts +2 -2
  60. package/js/src/bitvavo.d.ts +3 -3
  61. package/js/src/bl3p.d.ts +2 -2
  62. package/js/src/blockchaincom.d.ts +2 -2
  63. package/js/src/blofin.d.ts +2 -7
  64. package/js/src/blofin.js +2 -0
  65. package/js/src/bybit.d.ts +5 -15
  66. package/js/src/bybit.js +2 -0
  67. package/js/src/cex.d.ts +3 -3
  68. package/js/src/coinbase.d.ts +2 -2
  69. package/js/src/coinbaseinternational.d.ts +2 -2
  70. package/js/src/coinbasepro.d.ts +3 -3
  71. package/js/src/coincheck.d.ts +2 -2
  72. package/js/src/coinex.d.ts +5 -19
  73. package/js/src/coinlist.d.ts +3 -3
  74. package/js/src/coinmate.d.ts +2 -9
  75. package/js/src/coinmetro.d.ts +2 -2
  76. package/js/src/coinone.d.ts +2 -2
  77. package/js/src/coinsph.d.ts +4 -14
  78. package/js/src/coinsph.js +2 -0
  79. package/js/src/cryptocom.js +1 -1
  80. package/js/src/currencycom.d.ts +3 -3
  81. package/js/src/delta.d.ts +2 -2
  82. package/js/src/deribit.d.ts +3 -3
  83. package/js/src/digifinex.d.ts +4 -14
  84. package/js/src/digifinex.js +2 -0
  85. package/js/src/exmo.d.ts +3 -3
  86. package/js/src/gate.d.ts +6 -9
  87. package/js/src/gate.js +10 -8
  88. package/js/src/gemini.d.ts +3 -3
  89. package/js/src/hitbtc.d.ts +5 -15
  90. package/js/src/hitbtc.js +2 -0
  91. package/js/src/hollaex.d.ts +3 -3
  92. package/js/src/htx.d.ts +4 -14
  93. package/js/src/htx.js +2 -0
  94. package/js/src/huobijp.d.ts +2 -2
  95. package/js/src/hyperliquid.d.ts +2 -2
  96. package/js/src/idex.d.ts +3 -3
  97. package/js/src/independentreserve.d.ts +2 -2
  98. package/js/src/kraken.d.ts +3 -10
  99. package/js/src/krakenfutures.js +2 -1
  100. package/js/src/kucoin.d.ts +3 -10
  101. package/js/src/kucoin.js +46 -19
  102. package/js/src/kuna.d.ts +2 -2
  103. package/js/src/latoken.d.ts +7 -8
  104. package/js/src/latoken.js +4 -0
  105. package/js/src/lbank.d.ts +4 -9
  106. package/js/src/lbank.js +3 -1
  107. package/js/src/luno.d.ts +2 -7
  108. package/js/src/luno.js +2 -0
  109. package/js/src/lykke.d.ts +2 -2
  110. package/js/src/mexc.d.ts +3 -3
  111. package/js/src/mexc.js +55 -7
  112. package/js/src/ndax.d.ts +2 -2
  113. package/js/src/oceanex.d.ts +2 -2
  114. package/js/src/okcoin.d.ts +2 -2
  115. package/js/src/okx.d.ts +4 -14
  116. package/js/src/okx.js +2 -0
  117. package/js/src/onetrading.d.ts +3 -3
  118. package/js/src/phemex.d.ts +2 -2
  119. package/js/src/poloniex.d.ts +3 -3
  120. package/js/src/pro/bitget.js +2 -0
  121. package/js/src/pro/bitvavo.d.ts +2 -2
  122. package/js/src/probit.d.ts +2 -2
  123. package/js/src/timex.d.ts +4 -14
  124. package/js/src/timex.js +2 -0
  125. package/js/src/upbit.d.ts +2 -9
  126. package/js/src/wazirx.d.ts +2 -2
  127. package/js/src/whitebit.d.ts +3 -3
  128. package/js/src/woo.d.ts +3 -3
  129. package/js/src/yobit.d.ts +2 -2
  130. package/package.json +1 -1
  131. package/skip-tests.json +6 -1
@@ -88,7 +88,7 @@ export default class Exchange {
88
88
  this.markets_by_id = undefined;
89
89
  this.symbols = undefined;
90
90
  this.ids = undefined;
91
- this.currencies = undefined;
91
+ this.currencies = {};
92
92
  this.baseCurrencies = undefined;
93
93
  this.quoteCurrencies = undefined;
94
94
  this.currencies_by_id = undefined;
@@ -3775,11 +3775,11 @@ export default class Exchange {
3775
3775
  if (currencyId !== undefined) {
3776
3776
  code = this.commonCurrencyCode(currencyId.toUpperCase());
3777
3777
  }
3778
- return {
3778
+ return this.safeCurrencyStructure({
3779
3779
  'id': currencyId,
3780
3780
  'code': code,
3781
3781
  'precision': undefined,
3782
- };
3782
+ });
3783
3783
  }
3784
3784
  safeMarket(marketId, market = undefined, delimiter = undefined, marketType = undefined) {
3785
3785
  const result = this.safeMarketStructure({
@@ -4548,11 +4548,18 @@ export default class Exchange {
4548
4548
  'total': undefined,
4549
4549
  };
4550
4550
  }
4551
- commonCurrencyCode(currency) {
4551
+ commonCurrencyCode(code) {
4552
4552
  if (!this.substituteCommonCurrencyCodes) {
4553
- return currency;
4553
+ return code;
4554
+ }
4555
+ // if the provided code already exists as a value in commonCurrencies dict, then we should not again transform it
4556
+ // more details at: https://github.com/ccxt/ccxt/issues/21112#issuecomment-2031293691
4557
+ const commonCurrencies = Object.values(this.commonCurrencies);
4558
+ const exists = this.inArray(code, commonCurrencies);
4559
+ if (exists) {
4560
+ return code;
4554
4561
  }
4555
- return this.safeString(this.commonCurrencies, currency, currency);
4562
+ return this.safeString(this.commonCurrencies, code, code);
4556
4563
  }
4557
4564
  currency(code) {
4558
4565
  if (this.currencies === undefined) {
@@ -4707,6 +4714,30 @@ export default class Exchange {
4707
4714
  }
4708
4715
  return parsedPrecision + '1';
4709
4716
  }
4717
+ integerPrecisionToAmount(precision) {
4718
+ /**
4719
+ * @ignore
4720
+ * @method
4721
+ * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
4722
+ * @param {string} precision The number of digits to the right of the decimal
4723
+ * @returns {string} a string number equal to 1e-precision
4724
+ */
4725
+ if (precision === undefined) {
4726
+ return undefined;
4727
+ }
4728
+ if (Precise.stringGe(precision, '0')) {
4729
+ return this.parsePrecision(precision);
4730
+ }
4731
+ else {
4732
+ const positivePrecisionString = Precise.stringAbs(precision);
4733
+ const positivePrecision = parseInt(positivePrecisionString);
4734
+ let parsedPrecision = '1';
4735
+ for (let i = 0; i < positivePrecision - 1; i++) {
4736
+ parsedPrecision = parsedPrecision + '0';
4737
+ }
4738
+ return parsedPrecision + '0';
4739
+ }
4740
+ }
4710
4741
  async loadTimeDifference(params = {}) {
4711
4742
  const serverTime = await this.fetchTime(params);
4712
4743
  const after = this.milliseconds();
@@ -4991,7 +5022,8 @@ export default class Exchange {
4991
5022
  if (!this.has['fetchTradingFees']) {
4992
5023
  throw new NotSupported(this.id + ' fetchTradingFee() is not supported yet');
4993
5024
  }
4994
- return await this.fetchTradingFees(params);
5025
+ const fees = await this.fetchTradingFees(params);
5026
+ return this.safeDict(fees, symbol);
4995
5027
  }
4996
5028
  parseOpenInterest(interest, market = undefined) {
4997
5029
  throw new NotSupported(this.id + ' parseOpenInterest () is not supported yet');
@@ -5187,8 +5219,8 @@ export default class Exchange {
5187
5219
  const entry = responseKeys[i];
5188
5220
  const dictionary = isArray ? entry : response[entry];
5189
5221
  const currencyId = isArray ? this.safeString(dictionary, currencyIdKey) : entry;
5190
- const currency = this.safeValue(this.currencies_by_id, currencyId);
5191
- const code = this.safeString(currency, 'code', currencyId);
5222
+ const currency = this.safeCurrency(currencyId);
5223
+ const code = this.safeString(currency, 'code');
5192
5224
  if ((codes === undefined) || (this.inArray(code, codes))) {
5193
5225
  depositWithdrawFees[code] = this.parseDepositWithdrawFee(dictionary, currency);
5194
5226
  }
@@ -25,6 +25,14 @@ export interface FeeInterface {
25
25
  cost: Num;
26
26
  rate?: Num;
27
27
  }
28
+ export interface TradingFeeInterface {
29
+ info: any;
30
+ symbol: Str;
31
+ maker: Num;
32
+ taker: Num;
33
+ percentage: Bool;
34
+ tierBased: Bool;
35
+ }
28
36
  export declare type Fee = FeeInterface | undefined;
29
37
  export interface MarketInterface {
30
38
  id: string;
@@ -171,8 +179,29 @@ export interface Tickers extends Dictionary<Ticker> {
171
179
  export interface CurrencyInterface {
172
180
  id: string;
173
181
  code: string;
174
- numericId?: number;
182
+ numericId?: Int;
175
183
  precision: number;
184
+ type?: Str;
185
+ margin?: Bool;
186
+ name?: Str;
187
+ active?: Bool;
188
+ deposit?: Bool;
189
+ withdraw?: Bool;
190
+ fee?: Num;
191
+ limits: {
192
+ amount: {
193
+ min?: Num;
194
+ max?: Num;
195
+ };
196
+ withdraw: {
197
+ min?: Num;
198
+ max?: Num;
199
+ };
200
+ };
201
+ networks: {
202
+ string: any;
203
+ };
204
+ info: any;
176
205
  }
177
206
  export interface Balance {
178
207
  free: Num;
@@ -252,7 +281,7 @@ export interface Position {
252
281
  liquidationPrice?: number;
253
282
  marginMode?: Str;
254
283
  hedged?: boolean;
255
- maintenenceMargin?: number;
284
+ maintenanceMargin?: number;
256
285
  maintenanceMarginPercentage?: number;
257
286
  initialMargin?: number;
258
287
  initialMarginPercentage?: number;
@@ -447,6 +476,10 @@ export interface Leverages extends Dictionary<Leverage> {
447
476
  }
448
477
  export interface LastPrices extends Dictionary<LastPrice> {
449
478
  }
479
+ export interface Currencies extends Dictionary<CurrencyInterface> {
480
+ }
481
+ export interface TradingFees extends Dictionary<TradingFeeInterface> {
482
+ }
450
483
  export interface MarginModes extends Dictionary<MarginMode> {
451
484
  }
452
485
  export interface OptionChain extends Dictionary<Option> {
@@ -1,12 +1,12 @@
1
1
  import Exchange from './abstract/bigone.js';
2
- import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num } from './base/types.js';
2
+ import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num, Currencies } from './base/types.js';
3
3
  /**
4
4
  * @class bigone
5
5
  * @augments Exchange
6
6
  */
7
7
  export default class bigone extends Exchange {
8
8
  describe(): any;
9
- fetchCurrencies(params?: {}): Promise<{}>;
9
+ fetchCurrencies(params?: {}): Promise<Currencies>;
10
10
  fetchMarkets(params?: {}): Promise<Market[]>;
11
11
  parseTicker(ticker: any, market?: Market): Ticker;
12
12
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/binance.js';
2
- import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification, TradingFeeInterface, Currencies, TradingFees } from './base/types.js';
3
3
  /**
4
4
  * @class binance
5
5
  * @augments Exchange
@@ -16,7 +16,7 @@ export default class binance extends Exchange {
16
16
  currencyToPrecision(code: any, fee: any, networkCode?: any): any;
17
17
  nonce(): number;
18
18
  fetchTime(params?: {}): Promise<number>;
19
- fetchCurrencies(params?: {}): Promise<{}>;
19
+ fetchCurrencies(params?: {}): Promise<Currencies>;
20
20
  fetchMarkets(params?: {}): Promise<Market[]>;
21
21
  parseMarket(market: any): Market;
22
22
  parseBalanceHelper(entry: any): import("./base/types.js").BalanceAccount;
@@ -132,19 +132,9 @@ export default class binance extends Exchange {
132
132
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
133
133
  parseDepositWithdrawFee(fee: any, currency?: Currency): any;
134
134
  withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
135
- parseTradingFee(fee: any, market?: Market): {
136
- info: any;
137
- symbol: string;
138
- maker: number;
139
- taker: number;
140
- };
141
- fetchTradingFee(symbol: string, params?: {}): Promise<{
142
- info: any;
143
- symbol: string;
144
- maker: number;
145
- taker: number;
146
- }>;
147
- fetchTradingFees(params?: {}): Promise<{}>;
135
+ parseTradingFee(fee: any, market?: Market): TradingFeeInterface;
136
+ fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
137
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
148
138
  futuresTransfer(code: string, amount: any, type: any, params?: {}): Promise<{
149
139
  info: any;
150
140
  id: string;
@@ -196,7 +186,7 @@ export default class binance extends Exchange {
196
186
  previousFundingTimestamp: any;
197
187
  previousFundingDatetime: any;
198
188
  };
199
- parseAccountPositions(account: any): any[];
189
+ parseAccountPositions(account: any, filterClosed?: boolean): any[];
200
190
  parseAccountPosition(position: any, market?: Market): {
201
191
  info: any;
202
192
  id: any;
package/js/src/binance.js CHANGED
@@ -1863,7 +1863,7 @@ export default class binance extends Exchange {
1863
1863
  '-4140': BadRequest,
1864
1864
  '-4141': OperationRejected,
1865
1865
  '-4144': BadSymbol,
1866
- '-4164': OperationRejected,
1866
+ '-4164': InvalidOrder,
1867
1867
  '-4165': BadRequest,
1868
1868
  '-4167': BadRequest,
1869
1869
  '-4168': BadRequest,
@@ -8656,6 +8656,8 @@ export default class binance extends Exchange {
8656
8656
  'symbol': symbol,
8657
8657
  'maker': this.safeNumber2(fee, 'makerCommission', 'makerCommissionRate'),
8658
8658
  'taker': this.safeNumber2(fee, 'takerCommission', 'takerCommissionRate'),
8659
+ 'percentage': undefined,
8660
+ 'tierBased': undefined,
8659
8661
  };
8660
8662
  }
8661
8663
  async fetchTradingFee(symbol, params = {}) {
@@ -9143,7 +9145,7 @@ export default class binance extends Exchange {
9143
9145
  'previousFundingDatetime': undefined,
9144
9146
  };
9145
9147
  }
9146
- parseAccountPositions(account) {
9148
+ parseAccountPositions(account, filterClosed = false) {
9147
9149
  const positions = this.safeList(account, 'positions');
9148
9150
  const assets = this.safeList(account, 'assets', []);
9149
9151
  const balances = {};
@@ -9166,7 +9168,8 @@ export default class binance extends Exchange {
9166
9168
  const code = market['linear'] ? market['quote'] : market['base'];
9167
9169
  const maintenanceMargin = this.safeString(position, 'maintMargin');
9168
9170
  // check for maintenance margin so empty positions are not returned
9169
- if ((maintenanceMargin !== '0') && (maintenanceMargin !== '0.00000000')) {
9171
+ const isPositionOpen = (maintenanceMargin !== '0') && (maintenanceMargin !== '0.00000000');
9172
+ if (!filterClosed || isPositionOpen) {
9170
9173
  // sometimes not all the codes are correctly returned...
9171
9174
  if (code in balances) {
9172
9175
  const parsed = this.parseAccountPosition(this.extend(position, {
@@ -10008,10 +10011,11 @@ export default class binance extends Exchange {
10008
10011
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
10009
10012
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
10010
10013
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
10011
- * @param {string[]|undefined} symbols list of unified market symbols
10014
+ * @param {string[]} [symbols] list of unified market symbols
10012
10015
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10013
10016
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
10014
10017
  * @param {string} [params.subType] "linear" or "inverse"
10018
+ * @param {boolean} [params.filterClosed] set to true if you would like to filter out closed positions, default is false
10015
10019
  * @returns {object} data on account positions
10016
10020
  */
10017
10021
  if (symbols !== undefined) {
@@ -10048,7 +10052,9 @@ export default class binance extends Exchange {
10048
10052
  else {
10049
10053
  throw new NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
10050
10054
  }
10051
- const result = this.parseAccountPositions(response);
10055
+ let filterClosed = undefined;
10056
+ [filterClosed, params] = this.handleOptionAndParams(params, 'fetchAccountPositions', 'filterClosed', false);
10057
+ const result = this.parseAccountPositions(response, filterClosed);
10052
10058
  symbols = this.marketSymbols(symbols);
10053
10059
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
10054
10060
  }
@@ -11186,7 +11192,7 @@ export default class binance extends Exchange {
11186
11192
  }
11187
11193
  await this.loadMarkets();
11188
11194
  const market = this.market(symbol);
11189
- amount = this.costToPrecision(symbol, amount);
11195
+ amount = this.amountToPrecision(symbol, amount);
11190
11196
  const request = {
11191
11197
  'type': addOrReduce,
11192
11198
  'symbol': market['id'],
package/js/src/bingx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bingx.js';
2
- import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Dict, Leverage, MarginMode, Num, MarginModification } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Dict, Leverage, MarginMode, Num, MarginModification, Currencies } from './base/types.js';
3
3
  /**
4
4
  * @class bingx
5
5
  * @augments Exchange
@@ -7,7 +7,7 @@ import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, O
7
7
  export default class bingx extends Exchange {
8
8
  describe(): any;
9
9
  fetchTime(params?: {}): Promise<number>;
10
- fetchCurrencies(params?: {}): Promise<{}>;
10
+ fetchCurrencies(params?: {}): Promise<Currencies>;
11
11
  fetchSpotMarkets(params: any): Promise<import("./base/types.js").MarketInterface[]>;
12
12
  fetchSwapMarkets(params: any): Promise<import("./base/types.js").MarketInterface[]>;
13
13
  parseMarket(market: any): Market;
package/js/src/bit2c.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bit2c.js';
2
- import type { Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade } from './base/types.js';
2
+ import type { Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, TradingFees } from './base/types.js';
3
3
  /**
4
4
  * @class bit2c
5
5
  * @augments Exchange
@@ -12,7 +12,7 @@ export default class bit2c extends Exchange {
12
12
  parseTicker(ticker: any, market?: Market): Ticker;
13
13
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
14
14
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
15
- fetchTradingFees(params?: {}): Promise<{}>;
15
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
16
16
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
17
17
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
18
18
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitbank.js';
2
- import type { Balances, Currency, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, Transaction } from './base/types.js';
2
+ import type { Balances, Currency, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, TradingFees, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class bitbank
5
5
  * @augments Exchange
@@ -13,7 +13,7 @@ export default class bitbank extends Exchange {
13
13
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
14
14
  parseTrade(trade: any, market?: Market): Trade;
15
15
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
16
- fetchTradingFees(params?: {}): Promise<{}>;
16
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
17
17
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
18
18
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
19
19
  parseBalance(response: any): Balances;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitfinex.js';
2
- import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num } from './base/types.js';
2
+ import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num, TradingFees } from './base/types.js';
3
3
  /**
4
4
  * @class bitfinex
5
5
  * @augments Exchange
@@ -20,7 +20,7 @@ export default class bitfinex extends Exchange {
20
20
  networks: {};
21
21
  info: any;
22
22
  };
23
- fetchTradingFees(params?: {}): Promise<{}>;
23
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
24
24
  fetchMarkets(params?: {}): Promise<Market[]>;
25
25
  amountToPrecision(symbol: any, amount: any): any;
26
26
  priceToPrecision(symbol: any, price: any): any;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitfinex2.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num, MarginModification } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num, MarginModification, Currencies, TradingFees } from './base/types.js';
3
3
  /**
4
4
  * @class bitfinex2
5
5
  * @augments Exchange
@@ -19,7 +19,7 @@ export default class bitfinex2 extends Exchange {
19
19
  info: any;
20
20
  }>;
21
21
  fetchMarkets(params?: {}): Promise<Market[]>;
22
- fetchCurrencies(params?: {}): Promise<{}>;
22
+ fetchCurrencies(params?: {}): Promise<Currencies>;
23
23
  safeNetwork(networkId: any): string;
24
24
  fetchBalance(params?: {}): Promise<Balances>;
25
25
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
@@ -76,7 +76,7 @@ export default class bitfinex2 extends Exchange {
76
76
  }>;
77
77
  parseTransactionStatus(status: any): string;
78
78
  parseTransaction(transaction: any, currency?: Currency): Transaction;
79
- fetchTradingFees(params?: {}): Promise<{}>;
79
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
80
80
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
81
81
  withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<any>;
82
82
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitflyer.js';
2
- import type { Balances, Currency, Int, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, Transaction } from './base/types.js';
2
+ import type { Balances, Currency, Int, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFeeInterface, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class bitflyer
5
5
  * @augments Exchange
@@ -16,12 +16,7 @@ export default class bitflyer extends Exchange {
16
16
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
17
17
  parseTrade(trade: any, market?: Market): Trade;
18
18
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
19
- fetchTradingFee(symbol: string, params?: {}): Promise<{
20
- info: any;
21
- symbol: string;
22
- maker: number;
23
- taker: number;
24
- }>;
19
+ fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
25
20
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
26
21
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
27
22
  parseOrderStatus(status: any): string;
@@ -543,6 +543,8 @@ export default class bitflyer extends Exchange {
543
543
  'symbol': market['symbol'],
544
544
  'maker': fee,
545
545
  'taker': fee,
546
+ 'percentage': undefined,
547
+ 'tierBased': undefined,
546
548
  };
547
549
  }
548
550
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitget.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees } from './base/types.js';
3
3
  /**
4
4
  * @class bitget
5
5
  * @augments Exchange
@@ -13,7 +13,7 @@ export default class bitget extends Exchange {
13
13
  fetchMarkets(params?: {}): Promise<Market[]>;
14
14
  parseMarket(market: any): Market;
15
15
  fetchMarketsByType(type: any, params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
16
- fetchCurrencies(params?: {}): Promise<{}>;
16
+ fetchCurrencies(params?: {}): Promise<Currencies>;
17
17
  fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any[]>;
18
18
  parseMarketLeverageTiers(info: any, market?: Market): any[];
19
19
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -41,18 +41,15 @@ export default class bitget extends Exchange {
41
41
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
42
42
  parseTrade(trade: any, market?: Market): Trade;
43
43
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
44
- fetchTradingFee(symbol: string, params?: {}): Promise<{
45
- info: any;
46
- symbol: string;
47
- maker: number;
48
- taker: number;
49
- }>;
50
- fetchTradingFees(params?: {}): Promise<{}>;
44
+ fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
45
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
51
46
  parseTradingFee(data: any, market?: Market): {
52
47
  info: any;
53
48
  symbol: string;
54
49
  maker: number;
55
50
  taker: number;
51
+ percentage: any;
52
+ tierBased: any;
56
53
  };
57
54
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
58
55
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
package/js/src/bitget.js CHANGED
@@ -1298,6 +1298,7 @@ export default class bitget extends Exchange {
1298
1298
  'commonCurrencies': {
1299
1299
  'JADE': 'Jade Protocol',
1300
1300
  'DEGEN': 'DegenReborn',
1301
+ 'TONCOIN': 'TON',
1301
1302
  },
1302
1303
  'options': {
1303
1304
  'timeframes': {
@@ -1877,8 +1878,8 @@ export default class bitget extends Exchange {
1877
1878
  const data = this.safeValue(response, 'data', []);
1878
1879
  for (let i = 0; i < data.length; i++) {
1879
1880
  const entry = data[i];
1880
- const id = this.safeString(entry, 'coinId');
1881
- const code = this.safeCurrencyCode(this.safeString(entry, 'coin'));
1881
+ const id = this.safeString(entry, 'coin'); // we don't use 'coinId' as it has no use. it is 'coin' field that needs to be used in currency related endpoints (deposit, withdraw, etc..)
1882
+ const code = this.safeCurrencyCode(id);
1882
1883
  const chains = this.safeValue(entry, 'chains', []);
1883
1884
  const networks = {};
1884
1885
  let deposit = false;
@@ -2007,7 +2008,7 @@ export default class bitget extends Exchange {
2007
2008
  }
2008
2009
  params = this.omit(params, 'code');
2009
2010
  const currency = this.currency(code);
2010
- request['coin'] = currency['code'];
2011
+ request['coin'] = currency['id'];
2011
2012
  response = await this.privateMarginGetV2MarginCrossedTierData(this.extend(request, params));
2012
2013
  }
2013
2014
  else {
@@ -2163,7 +2164,7 @@ export default class bitget extends Exchange {
2163
2164
  since = this.milliseconds() - 7776000000; // 90 days
2164
2165
  }
2165
2166
  let request = {
2166
- 'coin': currency['code'],
2167
+ 'coin': currency['id'],
2167
2168
  'startTime': since,
2168
2169
  'endTime': this.milliseconds(),
2169
2170
  };
@@ -2222,7 +2223,7 @@ export default class bitget extends Exchange {
2222
2223
  const currency = this.currency(code);
2223
2224
  const networkId = this.networkCodeToId(chain);
2224
2225
  const request = {
2225
- 'coin': currency['code'],
2226
+ 'coin': currency['id'],
2226
2227
  'address': address,
2227
2228
  'chain': networkId,
2228
2229
  'size': amount,
@@ -2308,7 +2309,7 @@ export default class bitget extends Exchange {
2308
2309
  since = this.milliseconds() - 7776000000; // 90 days
2309
2310
  }
2310
2311
  let request = {
2311
- 'coin': currency['code'],
2312
+ 'coin': currency['id'],
2312
2313
  'startTime': since,
2313
2314
  'endTime': this.milliseconds(),
2314
2315
  };
@@ -2451,7 +2452,7 @@ export default class bitget extends Exchange {
2451
2452
  }
2452
2453
  const currency = this.currency(code);
2453
2454
  const request = {
2454
- 'coin': currency['code'],
2455
+ 'coin': currency['id'],
2455
2456
  };
2456
2457
  if (networkId !== undefined) {
2457
2458
  request['chain'] = networkId;
@@ -2626,7 +2627,11 @@ export default class bitget extends Exchange {
2626
2627
  //
2627
2628
  const marketId = this.safeString(ticker, 'symbol');
2628
2629
  const close = this.safeString(ticker, 'lastPr');
2629
- const timestamp = this.safeInteger(ticker, 'ts');
2630
+ const timestampString = this.omitZero(this.safeString(ticker, 'ts')); // exchange sometimes provided 0
2631
+ let timestamp = undefined;
2632
+ if (timestampString !== undefined) {
2633
+ timestamp = this.parseToInt(timestampString);
2634
+ }
2630
2635
  const change = this.safeString(ticker, 'change24h');
2631
2636
  const open24 = this.safeString(ticker, 'open24');
2632
2637
  const open = this.safeString(ticker, 'open');
@@ -3279,6 +3284,8 @@ export default class bitget extends Exchange {
3279
3284
  'symbol': this.safeSymbol(marketId, market),
3280
3285
  'maker': this.safeNumber(data, 'makerFeeRate'),
3281
3286
  'taker': this.safeNumber(data, 'takerFeeRate'),
3287
+ 'percentage': undefined,
3288
+ 'tierBased': undefined,
3282
3289
  };
3283
3290
  }
3284
3291
  parseOHLCV(ohlcv, market = undefined) {
@@ -5904,7 +5911,7 @@ export default class bitget extends Exchange {
5904
5911
  let request = {};
5905
5912
  if (code !== undefined) {
5906
5913
  currency = this.currency(code);
5907
- request['coin'] = currency['code'];
5914
+ request['coin'] = currency['id'];
5908
5915
  }
5909
5916
  [request, params] = this.handleUntilOption('endTime', request, params);
5910
5917
  if (since !== undefined) {
@@ -7343,7 +7350,7 @@ export default class bitget extends Exchange {
7343
7350
  type = this.safeString(accountsByType, fromAccount);
7344
7351
  const currency = this.currency(code);
7345
7352
  let request = {
7346
- 'coin': currency['code'],
7353
+ 'coin': currency['id'],
7347
7354
  'fromType': type,
7348
7355
  };
7349
7356
  if (since !== undefined) {
@@ -7402,7 +7409,7 @@ export default class bitget extends Exchange {
7402
7409
  'fromType': fromType,
7403
7410
  'toType': toType,
7404
7411
  'amount': amount,
7405
- 'coin': currency['code'],
7412
+ 'coin': currency['id'],
7406
7413
  };
7407
7414
  const symbol = this.safeString(params, 'symbol');
7408
7415
  params = this.omit(params, 'symbol');
@@ -7589,7 +7596,7 @@ export default class bitget extends Exchange {
7589
7596
  await this.loadMarkets();
7590
7597
  const currency = this.currency(code);
7591
7598
  const request = {
7592
- 'coin': currency['code'],
7599
+ 'coin': currency['id'],
7593
7600
  'borrowAmount': this.currencyToPrecision(code, amount),
7594
7601
  };
7595
7602
  const response = await this.privateMarginPostV2MarginCrossedAccountBorrow(this.extend(request, params));
@@ -7624,7 +7631,7 @@ export default class bitget extends Exchange {
7624
7631
  const currency = this.currency(code);
7625
7632
  const market = this.market(symbol);
7626
7633
  const request = {
7627
- 'coin': currency['code'],
7634
+ 'coin': currency['id'],
7628
7635
  'borrowAmount': this.currencyToPrecision(code, amount),
7629
7636
  'symbol': market['id'],
7630
7637
  };
@@ -7661,7 +7668,7 @@ export default class bitget extends Exchange {
7661
7668
  const currency = this.currency(code);
7662
7669
  const market = this.market(symbol);
7663
7670
  const request = {
7664
- 'coin': currency['code'],
7671
+ 'coin': currency['id'],
7665
7672
  'repayAmount': this.currencyToPrecision(code, amount),
7666
7673
  'symbol': market['id'],
7667
7674
  };
@@ -7697,7 +7704,7 @@ export default class bitget extends Exchange {
7697
7704
  await this.loadMarkets();
7698
7705
  const currency = this.currency(code);
7699
7706
  const request = {
7700
- 'coin': currency['code'],
7707
+ 'coin': currency['id'],
7701
7708
  'repayAmount': this.currencyToPrecision(code, amount),
7702
7709
  };
7703
7710
  const response = await this.privateMarginPostV2MarginCrossedAccountRepay(this.extend(request, params));
@@ -8059,7 +8066,7 @@ export default class bitget extends Exchange {
8059
8066
  await this.loadMarkets();
8060
8067
  const currency = this.currency(code);
8061
8068
  const request = {
8062
- 'coin': currency['code'],
8069
+ 'coin': currency['id'],
8063
8070
  };
8064
8071
  const response = await this.privateMarginGetV2MarginCrossedInterestRateAndLimit(this.extend(request, params));
8065
8072
  //
@@ -8154,7 +8161,7 @@ export default class bitget extends Exchange {
8154
8161
  let currency = undefined;
8155
8162
  if (code !== undefined) {
8156
8163
  currency = this.currency(code);
8157
- request['coin'] = currency['code'];
8164
+ request['coin'] = currency['id'];
8158
8165
  }
8159
8166
  if (since !== undefined) {
8160
8167
  request['startTime'] = since;