ccxt 4.5.51 → 4.5.52

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.
@@ -66,16 +66,16 @@ export default class Exchange {
66
66
  validateClientSsl: boolean;
67
67
  timeout: Int;
68
68
  verbose: boolean;
69
- twofa: string;
70
69
  apiKey: string;
71
70
  secret: string;
72
71
  uid: string;
73
- accountId: string;
74
72
  login: string;
75
73
  password: string;
76
74
  privateKey: string;
77
75
  walletAddress: string;
78
76
  token: string;
77
+ twofa: string;
78
+ accountId: string;
79
79
  balance: any;
80
80
  liquidations: any;
81
81
  orderbooks: Dictionary<Ob>;
@@ -187,11 +187,9 @@ export default class Exchange {
187
187
  exceptions: Dictionary<string>;
188
188
  timeframes: Dictionary<number | string>;
189
189
  version: Str;
190
- marketsByAltname: Dictionary<Market>;
191
190
  name: Str;
192
191
  lastRestRequestTimestamp: int;
193
192
  targetAccount: string;
194
- stablePairs: Dictionary<boolean>;
195
193
  httpProxyAgentModule: any;
196
194
  httpsProxyAgentModule: any;
197
195
  socksProxyAgentModule: any;
@@ -439,6 +437,7 @@ export default class Exchange {
439
437
  safeDict(dictionary: any, key: IndexType, defaultValue?: Dictionary<any>): Dictionary<any> | undefined;
440
438
  safeDict2(dictionary: any, key1: IndexType, key2: string, defaultValue?: Dictionary<any>): Dictionary<any> | undefined;
441
439
  safeListN(dictionaryOrList: any, keys: IndexType[], defaultValue?: any[]): any[] | undefined;
440
+ isDictionary(value: any): boolean;
442
441
  safeList2(dictionaryOrList: any, key1: IndexType, key2: string, defaultValue?: any[]): any[] | undefined;
443
442
  safeList(dictionaryOrList: any, key: IndexType, defaultValue?: any[]): any[] | undefined;
444
443
  handleDeltas(orderbook: any, deltas: any): void;
@@ -82,7 +82,6 @@ export default class Exchange {
82
82
  this.validateClientSsl = false;
83
83
  this.timeout = 10000; // milliseconds
84
84
  this.verbose = false;
85
- this.twofa = undefined; // two-factor authentication (2-FA)
86
85
  this.balance = {};
87
86
  this.liquidations = undefined;
88
87
  this.orderbooks = {};
@@ -110,10 +109,10 @@ export default class Exchange {
110
109
  this.markets = undefined;
111
110
  this.features = undefined;
112
111
  this.status = undefined;
113
- this.rateLimit = undefined; // milliseconds
112
+ this.rateLimit = 2000; // milliseconds
114
113
  this.tokenBucket = undefined;
115
114
  this.throttler = undefined;
116
- this.enableRateLimit = undefined;
115
+ this.enableRateLimit = true;
117
116
  this.rollingWindowSize = 0.0; // set to 0.0 to use leaky bucket rate limiter
118
117
  this.rateLimiterAlgorithm = 'leakyBucket';
119
118
  this.httpExceptions = undefined;
@@ -137,10 +136,8 @@ export default class Exchange {
137
136
  this.exceptions = {};
138
137
  this.timeframes = {};
139
138
  this.version = undefined;
140
- this.marketsByAltname = undefined;
141
139
  this.name = undefined;
142
140
  this.targetAccount = undefined;
143
- this.stablePairs = {};
144
141
  this.httpProxyAgentModule = undefined;
145
142
  this.httpsProxyAgentModule = undefined;
146
143
  this.socksProxyAgentModule = undefined;
@@ -680,7 +677,7 @@ export default class Exchange {
680
677
  if (typeof userAgent === 'string') {
681
678
  headers = this.extend({ 'User-Agent': userAgent }, headers);
682
679
  }
683
- else if ((typeof userAgent === 'object') && ('User-Agent' in userAgent)) {
680
+ else if (this.isDictionary(userAgent) && ('User-Agent' in userAgent)) {
684
681
  headers = this.extend(userAgent, headers);
685
682
  }
686
683
  }
@@ -1776,15 +1773,16 @@ export default class Exchange {
1776
1773
  // METHODS BELOW THIS LINE ARE TRANSPILED FROM TYPESCRIPT
1777
1774
  describe() {
1778
1775
  return {
1779
- 'id': undefined,
1780
- 'name': undefined,
1781
- 'countries': undefined,
1782
- 'enableRateLimit': true,
1783
- 'rateLimit': 2000,
1776
+ 'id': this.id,
1777
+ 'name': this.name,
1778
+ 'countries': this.countries,
1779
+ 'enableRateLimit': this.enableRateLimit,
1780
+ 'rateLimit': this.rateLimit,
1781
+ 'rateLimiterAlgorithm': this.rateLimiterAlgorithm,
1784
1782
  'timeout': this.timeout,
1785
- 'certified': false,
1786
- 'pro': false,
1787
- 'alias': false,
1783
+ 'certified': this.certified,
1784
+ 'pro': this.pro,
1785
+ 'alias': this.alias,
1788
1786
  'dex': false,
1789
1787
  'has': {
1790
1788
  'publicAPI': true,
@@ -2030,9 +2028,12 @@ export default class Exchange {
2030
2028
  'urls': {
2031
2029
  'logo': undefined,
2032
2030
  'api': undefined,
2031
+ 'test': undefined,
2033
2032
  'www': undefined,
2034
2033
  'doc': undefined,
2034
+ 'api_management': undefined,
2035
2035
  'fees': undefined,
2036
+ 'referral': undefined,
2036
2037
  },
2037
2038
  'api': undefined,
2038
2039
  'requiredCredentials': {
@@ -2069,6 +2070,7 @@ export default class Exchange {
2069
2070
  'updated': undefined,
2070
2071
  'eta': undefined,
2071
2072
  'url': undefined,
2073
+ 'info': undefined,
2072
2074
  },
2073
2075
  'exceptions': undefined,
2074
2076
  'httpExceptions': {
@@ -2159,7 +2161,7 @@ export default class Exchange {
2159
2161
  if (value === undefined) {
2160
2162
  return defaultValue;
2161
2163
  }
2162
- if ((typeof value === 'object') && !Array.isArray(value)) {
2164
+ if (this.isDictionary(value)) {
2163
2165
  return value;
2164
2166
  }
2165
2167
  return defaultValue;
@@ -2175,7 +2177,7 @@ export default class Exchange {
2175
2177
  if (value === undefined) {
2176
2178
  return defaultValue;
2177
2179
  }
2178
- if ((typeof value === 'object') && !Array.isArray(value)) {
2180
+ if (this.isDictionary(value)) {
2179
2181
  return value;
2180
2182
  }
2181
2183
  return defaultValue;
@@ -2205,6 +2207,9 @@ export default class Exchange {
2205
2207
  }
2206
2208
  return defaultValue;
2207
2209
  }
2210
+ isDictionary(value) {
2211
+ return (value !== undefined) && (typeof value === 'object') && !Array.isArray(value);
2212
+ }
2208
2213
  safeList2(dictionaryOrList, key1, key2, defaultValue = undefined) {
2209
2214
  /**
2210
2215
  * @ignore
@@ -5957,7 +5962,7 @@ export default class Exchange {
5957
5962
  if (triggerPrice === undefined) {
5958
5963
  throw new ArgumentsRequired(this.id + ' createTriggerOrder() requires a triggerPrice argument');
5959
5964
  }
5960
- params['triggerPrice'] = triggerPrice;
5965
+ params = this.extend(params, { 'triggerPrice': triggerPrice });
5961
5966
  if (this.has['createTriggerOrder']) {
5962
5967
  return await this.createOrder(symbol, type, side, amount, price, params);
5963
5968
  }
@@ -5980,7 +5985,7 @@ export default class Exchange {
5980
5985
  if (triggerPrice === undefined) {
5981
5986
  throw new ArgumentsRequired(this.id + ' createTriggerOrderWs() requires a triggerPrice argument');
5982
5987
  }
5983
- params['triggerPrice'] = triggerPrice;
5988
+ params = this.extend(params, { 'triggerPrice': triggerPrice });
5984
5989
  if (this.has['createTriggerOrderWs']) {
5985
5990
  return await this.createOrderWs(symbol, type, side, amount, price, params);
5986
5991
  }
@@ -6003,7 +6008,7 @@ export default class Exchange {
6003
6008
  if (stopLossPrice === undefined) {
6004
6009
  throw new ArgumentsRequired(this.id + ' createStopLossOrder() requires a stopLossPrice argument');
6005
6010
  }
6006
- params['stopLossPrice'] = stopLossPrice;
6011
+ params = this.extend(params, { 'stopLossPrice': stopLossPrice });
6007
6012
  if (this.has['createStopLossOrder']) {
6008
6013
  return await this.createOrder(symbol, type, side, amount, price, params);
6009
6014
  }
@@ -6026,7 +6031,7 @@ export default class Exchange {
6026
6031
  if (stopLossPrice === undefined) {
6027
6032
  throw new ArgumentsRequired(this.id + ' createStopLossOrderWs() requires a stopLossPrice argument');
6028
6033
  }
6029
- params['stopLossPrice'] = stopLossPrice;
6034
+ params = this.extend(params, { 'stopLossPrice': stopLossPrice });
6030
6035
  if (this.has['createStopLossOrderWs']) {
6031
6036
  return await this.createOrderWs(symbol, type, side, amount, price, params);
6032
6037
  }
@@ -6049,7 +6054,7 @@ export default class Exchange {
6049
6054
  if (takeProfitPrice === undefined) {
6050
6055
  throw new ArgumentsRequired(this.id + ' createTakeProfitOrder() requires a takeProfitPrice argument');
6051
6056
  }
6052
- params['takeProfitPrice'] = takeProfitPrice;
6057
+ params = this.extend(params, { 'takeProfitPrice': takeProfitPrice });
6053
6058
  if (this.has['createTakeProfitOrder']) {
6054
6059
  return await this.createOrder(symbol, type, side, amount, price, params);
6055
6060
  }
@@ -6072,7 +6077,7 @@ export default class Exchange {
6072
6077
  if (takeProfitPrice === undefined) {
6073
6078
  throw new ArgumentsRequired(this.id + ' createTakeProfitOrderWs() requires a takeProfitPrice argument');
6074
6079
  }
6075
- params['takeProfitPrice'] = takeProfitPrice;
6080
+ params = this.extend(params, { 'takeProfitPrice': takeProfitPrice });
6076
6081
  if (this.has['createTakeProfitOrderWs']) {
6077
6082
  return await this.createOrderWs(symbol, type, side, amount, price, params);
6078
6083
  }
@@ -6497,7 +6502,7 @@ export default class Exchange {
6497
6502
  return false;
6498
6503
  }
6499
6504
  handleWithdrawTagAndParams(tag, params) {
6500
- if ((tag !== undefined) && (typeof tag === 'object')) {
6505
+ if (this.isDictionary(tag)) {
6501
6506
  params = this.extend(tag, params);
6502
6507
  tag = undefined;
6503
6508
  }
@@ -6550,7 +6555,7 @@ export default class Exchange {
6550
6555
  return undefined;
6551
6556
  }
6552
6557
  const market = this.market(symbol);
6553
- return this.decimalToPrecision(cost, TRUNCATE, market['precision']['price'], this.precisionMode, this.paddingMode);
6558
+ return this.decimalToPrecision(cost, TRUNCATE, this.safeString2(market['precision'], 'cost', 'price'), this.precisionMode, this.paddingMode);
6554
6559
  }
6555
6560
  priceToPrecision(symbol, price) {
6556
6561
  if (price === undefined) {
package/js/src/bequant.js CHANGED
@@ -8,6 +8,9 @@ export default class bequant extends hitbtc {
8
8
  'name': 'Bequant',
9
9
  'pro': true,
10
10
  'countries': ['MT'],
11
+ 'has': {
12
+ 'swap': false,
13
+ },
11
14
  'urls': {
12
15
  'logo': 'https://github.com/user-attachments/assets/0583ef1f-29fe-4b7c-8189-63565a0e2867',
13
16
  'api': {
package/js/src/binance.js CHANGED
@@ -1491,6 +1491,7 @@ export default class binance extends Exchange {
1491
1491
  'BUSD': 'USD',
1492
1492
  },
1493
1493
  'defaultWithdrawPrecision': 0.00000001,
1494
+ 'defaultFiatWithdrawPrecision': 0.01,
1494
1495
  },
1495
1496
  'features': {
1496
1497
  'spot': {
@@ -3054,29 +3055,33 @@ export default class binance extends Exchange {
3054
3055
  // ]
3055
3056
  // }
3056
3057
  //
3058
+ // some coins (e.g. ETH, BIGTIME, SONIC, etc) return extra fields under network entry
3059
+ //
3060
+ // "specialTips": "",
3061
+ // "specialWithdrawTips": "",
3062
+ // "withdrawInternalMin": "0",
3063
+ // "contractAddressUrl": "https://etherscan.io/address/",
3064
+ // "contractAddress": "0x64bc2ca1be492be7185faa2c8835d9b824c8a194"
3065
+ //
3057
3066
  const entry = responseCurrencies[i];
3058
3067
  const id = this.safeString(entry, 'coin');
3059
3068
  const name = this.safeString(entry, 'name');
3060
3069
  const code = this.safeCurrencyCode(id);
3061
3070
  const isFiat = this.safeBool(entry, 'isLegalMoney');
3062
- let minPrecision = undefined;
3063
- let isWithdrawEnabled = true;
3064
- let isDepositEnabled = true;
3065
3071
  const networkList = this.safeList(entry, 'networkList', []);
3066
3072
  const fees = {};
3067
3073
  let fee = undefined;
3068
3074
  const networks = {};
3075
+ let isETF = false;
3069
3076
  for (let j = 0; j < networkList.length; j++) {
3070
3077
  const networkItem = networkList[j];
3071
3078
  const network = this.safeString(networkItem, 'network');
3072
3079
  const networkCode = this.networkIdToCode(network, code);
3073
- const isETF = (network === 'ETF'); // e.g. BTCUP, ETHDOWN
3080
+ isETF = (network === 'ETF'); // ETF currencies (e.g. BTCUP, ETHDOWN) have only 1 "network" entry and are deterministic to set
3074
3081
  // const name = this.safeString (networkItem, 'name');
3075
3082
  const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
3076
3083
  const depositEnable = this.safeBool(networkItem, 'depositEnable');
3077
3084
  const withdrawEnable = this.safeBool(networkItem, 'withdrawEnable');
3078
- isDepositEnabled = isDepositEnabled || depositEnable;
3079
- isWithdrawEnabled = isWithdrawEnabled || withdrawEnable;
3080
3085
  fees[network] = withdrawFee;
3081
3086
  const isDefault = this.safeBool(networkItem, 'isDefault');
3082
3087
  if (isDefault || (fee === undefined)) {
@@ -3086,27 +3091,16 @@ export default class binance extends Exchange {
3086
3091
  // if (isDefault) {
3087
3092
  // this.options['defaultNetworkCodesForCurrencies'][code] = networkCode;
3088
3093
  // }
3089
- const precisionTick = this.safeString(networkItem, 'withdrawIntegerMultiple');
3090
- let withdrawPrecision = precisionTick;
3091
- // avoid zero values, which are mostly from fiat or leveraged tokens or some abandoned coins : https://github.com/ccxt/ccxt/pull/14902#issuecomment-1271636731
3092
- if (!Precise.stringEq(precisionTick, '0')) {
3093
- minPrecision = (minPrecision === undefined) ? precisionTick : Precise.stringMin(minPrecision, precisionTick);
3094
- }
3095
- else {
3096
- if (!isFiat && !isETF) {
3097
- // non-fiat and non-ETF currency, there are many cases when precision is set to zero (probably bug, we've reported to binance already)
3098
- // in such cases, we can set default precision of 8 (which is in UI for such coins)
3099
- withdrawPrecision = this.omitZero(this.safeString(networkItem, 'withdrawInternalMin'));
3100
- if (withdrawPrecision === undefined) {
3101
- withdrawPrecision = this.safeString(this.options, 'defaultWithdrawPrecision');
3102
- }
3103
- }
3094
+ let withdrawPrecision = this.omitZero(this.safeString2(networkItem, 'withdrawIntegerMultiple', 'withdrawInternalMin'));
3095
+ // zero values happen only on fiat or leveraged(ETF) tokens: https://t.me/binance_api_english/393075
3096
+ if (withdrawPrecision === undefined && isFiat) {
3097
+ withdrawPrecision = this.safeString(this.options, 'defaultFiatWithdrawPrecision');
3104
3098
  }
3105
3099
  networks[networkCode] = {
3106
3100
  'info': networkItem,
3107
3101
  'id': network,
3108
3102
  'network': networkCode,
3109
- 'active': depositEnable && withdrawEnable,
3103
+ 'active': undefined,
3110
3104
  'deposit': depositEnable,
3111
3105
  'withdraw': withdrawEnable,
3112
3106
  'fee': withdrawFee,
@@ -3123,8 +3117,17 @@ export default class binance extends Exchange {
3123
3117
  },
3124
3118
  };
3125
3119
  }
3120
+ let type = undefined;
3121
+ if (isETF) {
3122
+ type = 'other';
3123
+ }
3124
+ else if (isFiat) {
3125
+ type = 'fiat';
3126
+ }
3127
+ else {
3128
+ type = 'crypto';
3129
+ }
3126
3130
  const trading = this.safeBool(entry, 'trading');
3127
- const active = (isWithdrawEnabled && isDepositEnabled && trading);
3128
3131
  const marginEntry = this.safeDict(marginablesById, id, {});
3129
3132
  //
3130
3133
  // {
@@ -3136,22 +3139,22 @@ export default class binance extends Exchange {
3136
3139
  // userMinRepay: "0",
3137
3140
  // }
3138
3141
  //
3139
- result[code] = {
3142
+ result[code] = this.safeCurrencyStructure({
3140
3143
  'id': id,
3141
3144
  'name': name,
3142
3145
  'code': code,
3143
- 'type': isFiat ? 'fiat' : 'crypto',
3144
- 'precision': this.parseNumber(minPrecision),
3146
+ 'type': type,
3147
+ 'precision': undefined,
3145
3148
  'info': entry,
3146
- 'active': active,
3147
- 'deposit': isDepositEnabled,
3148
- 'withdraw': isWithdrawEnabled,
3149
+ 'active': trading,
3150
+ 'deposit': undefined,
3151
+ 'withdraw': undefined,
3149
3152
  'networks': networks,
3150
- 'fee': fee,
3153
+ 'fee': undefined,
3151
3154
  'fees': fees,
3152
- 'limits': this.limits,
3155
+ 'limits': undefined,
3153
3156
  'margin': this.safeBool(marginEntry, 'isBorrowable'),
3154
- };
3157
+ });
3155
3158
  }
3156
3159
  return result;
3157
3160
  }
@@ -28,6 +28,7 @@ export default class binanceusdm extends binance {
28
28
  'fetchMarkets': {
29
29
  'types': ['linear'],
30
30
  },
31
+ 'defaultType': 'swap',
31
32
  'defaultSubType': 'linear',
32
33
  // https://www.binance.com/en/support/faq/360033162192
33
34
  // tier amount, maintenance margin, initial margin,
package/js/src/grvt.js CHANGED
@@ -482,13 +482,17 @@ export default class grvt extends Exchange {
482
482
  * @returns response from exchange
483
483
  */
484
484
  async signIn(params = {}) {
485
- if (this.usesPrivateKey()) {
486
- await this.signInWithPrivateKey(params);
487
- await this.initializeClient(params);
488
- }
489
- else {
490
- await this.signInWithApiKey(params);
485
+ // if (this.usesPrivateKey ()) {
486
+ // await this.signInWithPrivateKey (params);
487
+ // await this.initializeClient (params);
488
+ // } else {
489
+ // await this.signInWithApiKey (params);
490
+ // }
491
+ if (this.privateKey === undefined || this.privateKey === '') {
492
+ throw new PermissionDenied('Private key is required for this operation. If you used joined GRVT through email registration instead of Web3 wallet, then read: https://github.com/ccxt/ccxt/wiki/FAQ#how-to-use-the-grvt-exchange-in-ccxt');
491
493
  }
494
+ await this.signInWithPrivateKey(params);
495
+ await this.initializeClient(params);
492
496
  await this.loadAccountInfos();
493
497
  return true;
494
498
  }
@@ -1961,7 +1965,10 @@ export default class grvt extends Exchange {
1961
1965
  else {
1962
1966
  throw new InvalidOrder(this.id + ' createOrder(): order side must be either "buy" or "sell"');
1963
1967
  }
1964
- const clientOrderId = this.safeString(params, 'clientOrderId');
1968
+ let clientOrderId = this.safeString(params, 'clientOrderId');
1969
+ if (clientOrderId === undefined) {
1970
+ clientOrderId = this.nonce().toString() + '000' + this.requestId().toString();
1971
+ }
1965
1972
  params = this.omit(params, ['clientOrderId']);
1966
1973
  const isMarketOrder = (type === 'market');
1967
1974
  const orderRequest = {
@@ -1970,7 +1977,7 @@ export default class grvt extends Exchange {
1970
1977
  'legs': [orderLeg],
1971
1978
  'signature': this.defaultSignature(),
1972
1979
  'metadata': {
1973
- 'client_order_id': clientOrderId !== undefined ? clientOrderId : this.nonce().toString() + '000' + this.requestId().toString(),
1980
+ 'client_order_id': clientOrderId,
1974
1981
  },
1975
1982
  'is_market': isMarketOrder,
1976
1983
  'post_only': false,
package/js/src/kraken.js CHANGED
@@ -644,6 +644,10 @@ export default class kraken extends Exchange {
644
644
  const result = [];
645
645
  for (let i = 0; i < keys.length; i++) {
646
646
  const id = keys[i];
647
+ let isSynthetic = false;
648
+ if (id.indexOf(':BTNL') >= 0) {
649
+ isSynthetic = true;
650
+ }
647
651
  const market = markets[id];
648
652
  const baseIdRaw = this.safeString(market, 'base');
649
653
  const quoteIdRaw = this.safeString(market, 'quote');
@@ -681,10 +685,11 @@ export default class kraken extends Exchange {
681
685
  }
682
686
  const status = this.safeString(market, 'status');
683
687
  const isActive = status === 'online';
688
+ const symbol = (!isSynthetic) ? (base + '/' + quote) : id;
684
689
  result.push({
685
690
  'id': id,
686
691
  'wsId': this.safeString(market, 'wsname'),
687
- 'symbol': base + '/' + quote,
692
+ 'symbol': symbol,
688
693
  'base': base,
689
694
  'quote': quote,
690
695
  'settle': undefined,