ccxt 4.4.35 → 4.4.36

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 (43) hide show
  1. package/README.md +6 -5
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/defx.js +9 -0
  5. package/dist/cjs/src/bitfinex2.js +20 -12
  6. package/dist/cjs/src/bitmex.js +103 -1
  7. package/dist/cjs/src/bitopro.js +22 -4
  8. package/dist/cjs/src/bitso.js +2 -1
  9. package/dist/cjs/src/bybit.js +20 -0
  10. package/dist/cjs/src/defx.js +2048 -0
  11. package/dist/cjs/src/deribit.js +34 -14
  12. package/dist/cjs/src/gate.js +15 -1
  13. package/dist/cjs/src/hashkey.js +1 -1
  14. package/dist/cjs/src/htx.js +14 -2
  15. package/dist/cjs/src/kraken.js +39 -48
  16. package/dist/cjs/src/pro/defx.js +864 -0
  17. package/js/ccxt.d.ts +8 -2
  18. package/js/ccxt.js +6 -2
  19. package/js/src/abstract/bitopro.d.ts +1 -0
  20. package/js/src/abstract/bybit.d.ts +15 -0
  21. package/js/src/abstract/defx.d.ts +72 -0
  22. package/js/src/abstract/defx.js +11 -0
  23. package/js/src/abstract/deribit.d.ts +1 -0
  24. package/js/src/abstract/gate.d.ts +14 -0
  25. package/js/src/abstract/gateio.d.ts +14 -0
  26. package/js/src/bitfinex2.js +21 -13
  27. package/js/src/bitmex.js +103 -1
  28. package/js/src/bitopro.d.ts +11 -0
  29. package/js/src/bitopro.js +22 -4
  30. package/js/src/bitso.js +2 -1
  31. package/js/src/bybit.js +20 -0
  32. package/js/src/defx.d.ts +349 -0
  33. package/js/src/defx.js +2049 -0
  34. package/js/src/deribit.d.ts +2 -0
  35. package/js/src/deribit.js +34 -14
  36. package/js/src/gate.js +15 -1
  37. package/js/src/hashkey.js +1 -1
  38. package/js/src/htx.d.ts +3 -0
  39. package/js/src/htx.js +14 -2
  40. package/js/src/kraken.js +39 -48
  41. package/js/src/pro/defx.d.ts +236 -0
  42. package/js/src/pro/defx.js +865 -0
  43. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -64,6 +64,7 @@ var coinsph = require('./src/coinsph.js');
64
64
  var coinspot = require('./src/coinspot.js');
65
65
  var cryptocom = require('./src/cryptocom.js');
66
66
  var currencycom = require('./src/currencycom.js');
67
+ var defx = require('./src/defx.js');
67
68
  var delta = require('./src/delta.js');
68
69
  var deribit = require('./src/deribit.js');
69
70
  var digifinex = require('./src/digifinex.js');
@@ -156,6 +157,7 @@ var coinex$1 = require('./src/pro/coinex.js');
156
157
  var coinone$1 = require('./src/pro/coinone.js');
157
158
  var cryptocom$1 = require('./src/pro/cryptocom.js');
158
159
  var currencycom$1 = require('./src/pro/currencycom.js');
160
+ var defx$1 = require('./src/pro/defx.js');
159
161
  var deribit$1 = require('./src/pro/deribit.js');
160
162
  var exmo$1 = require('./src/pro/exmo.js');
161
163
  var gate$1 = require('./src/pro/gate.js');
@@ -198,7 +200,7 @@ var xt$1 = require('./src/pro/xt.js');
198
200
 
199
201
  //-----------------------------------------------------------------------------
200
202
  // this is updated by vss.js when building
201
- const version = '4.4.35';
203
+ const version = '4.4.36';
202
204
  Exchange["default"].ccxtVersion = version;
203
205
  const exchanges = {
204
206
  'ace': ace,
@@ -253,6 +255,7 @@ const exchanges = {
253
255
  'coinspot': coinspot,
254
256
  'cryptocom': cryptocom,
255
257
  'currencycom': currencycom,
258
+ 'defx': defx,
256
259
  'delta': delta,
257
260
  'deribit': deribit,
258
261
  'digifinex': digifinex,
@@ -347,6 +350,7 @@ const pro = {
347
350
  'coinone': coinone$1,
348
351
  'cryptocom': cryptocom$1,
349
352
  'currencycom': currencycom$1,
353
+ 'defx': defx$1,
350
354
  'deribit': deribit$1,
351
355
  'exmo': exmo$1,
352
356
  'gate': gate$1,
@@ -489,6 +493,7 @@ exports.coinsph = coinsph;
489
493
  exports.coinspot = coinspot;
490
494
  exports.cryptocom = cryptocom;
491
495
  exports.currencycom = currencycom;
496
+ exports.defx = defx;
492
497
  exports.delta = delta;
493
498
  exports.deribit = deribit;
494
499
  exports.digifinex = digifinex;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var Exchange$1 = require('../base/Exchange.js');
4
+
5
+ // -------------------------------------------------------------------------------
6
+ class Exchange extends Exchange$1["default"] {
7
+ }
8
+
9
+ module.exports = Exchange;
@@ -413,12 +413,10 @@ class bitfinex2 extends bitfinex2$1 {
413
413
  'temporarily_unavailable': errors.ExchangeNotAvailable,
414
414
  },
415
415
  'broad': {
416
- 'address': errors.InvalidAddress,
417
416
  'available balance is only': errors.InsufficientFunds,
418
417
  'not enough exchange balance': errors.InsufficientFunds,
419
418
  'Order not found': errors.OrderNotFound,
420
419
  'symbol: invalid': errors.BadSymbol,
421
- 'Invalid order': errors.InvalidOrder,
422
420
  },
423
421
  },
424
422
  'commonCurrencies': {
@@ -770,7 +768,11 @@ class bitfinex2 extends bitfinex2$1 {
770
768
  const name = this.safeString(label, 1);
771
769
  const pool = this.safeValue(indexed['pool'], id, []);
772
770
  const rawType = this.safeString(pool, 1);
773
- const type = (rawType === undefined) ? 'other' : 'crypto';
771
+ const isCryptoCoin = (rawType !== undefined) || (id in indexed['explorer']); // "hacky" solution
772
+ let type = undefined;
773
+ if (isCryptoCoin) {
774
+ type = 'crypto';
775
+ }
774
776
  const feeValues = this.safeValue(indexed['fees'], id, []);
775
777
  const fees = this.safeValue(feeValues, 1, []);
776
778
  const fee = this.safeNumber(fees, 1);
@@ -1724,7 +1726,8 @@ class bitfinex2 extends bitfinex2$1 {
1724
1726
  }
1725
1727
  const orders = this.safeList(response, 4, []);
1726
1728
  const order = this.safeList(orders, 0);
1727
- return this.parseOrder(this.extend({ 'result': order }), market);
1729
+ const newOrder = { 'result': order };
1730
+ return this.parseOrder(newOrder, market);
1728
1731
  }
1729
1732
  /**
1730
1733
  * @method
@@ -1823,6 +1826,10 @@ class bitfinex2 extends bitfinex2$1 {
1823
1826
  await this.loadMarkets();
1824
1827
  const cid = this.safeValue2(params, 'cid', 'clientOrderId'); // client order id
1825
1828
  let request = undefined;
1829
+ let market = undefined;
1830
+ if (symbol !== undefined) {
1831
+ market = this.market(symbol);
1832
+ }
1826
1833
  if (cid !== undefined) {
1827
1834
  const cidDate = this.safeValue(params, 'cidDate'); // client order id date
1828
1835
  if (cidDate === undefined) {
@@ -1841,8 +1848,8 @@ class bitfinex2 extends bitfinex2$1 {
1841
1848
  }
1842
1849
  const response = await this.privatePostAuthWOrderCancel(this.extend(request, params));
1843
1850
  const order = this.safeValue(response, 4);
1844
- const orderObject = { 'result': order };
1845
- return this.parseOrder(orderObject);
1851
+ const newOrder = { 'result': order };
1852
+ return this.parseOrder(newOrder, market);
1846
1853
  }
1847
1854
  /**
1848
1855
  * @method
@@ -2368,6 +2375,8 @@ class bitfinex2 extends bitfinex2$1 {
2368
2375
  }
2369
2376
  tag = this.safeString(data, 3);
2370
2377
  type = 'withdrawal';
2378
+ const networkId = this.safeString(data, 2);
2379
+ network = this.networkIdToCode(networkId.toUpperCase()); // withdraw returns in lowercase
2371
2380
  }
2372
2381
  else if (transactionLength === 22) {
2373
2382
  id = this.safeString(transaction, 0);
@@ -2683,10 +2692,7 @@ class bitfinex2 extends bitfinex2$1 {
2683
2692
  if (text !== 'success') {
2684
2693
  this.throwBroadlyMatchedException(this.exceptions['broad'], text, text);
2685
2694
  }
2686
- const transaction = this.parseTransaction(response, currency);
2687
- return this.extend(transaction, {
2688
- 'address': address,
2689
- });
2695
+ return this.parseTransaction(response, currency);
2690
2696
  }
2691
2697
  /**
2692
2698
  * @method
@@ -3636,7 +3642,8 @@ class bitfinex2 extends bitfinex2$1 {
3636
3642
  // ]
3637
3643
  //
3638
3644
  const order = this.safeList(response, 0);
3639
- return this.parseOrder(order, market);
3645
+ const newOrder = { 'result': order };
3646
+ return this.parseOrder(newOrder, market);
3640
3647
  }
3641
3648
  /**
3642
3649
  * @method
@@ -3762,7 +3769,8 @@ class bitfinex2 extends bitfinex2$1 {
3762
3769
  throw new errors.ExchangeError(this.id + ' ' + response[6] + ': ' + errorText + ' (#' + errorCode + ')');
3763
3770
  }
3764
3771
  const order = this.safeList(response, 4, []);
3765
- return this.parseOrder(order, market);
3772
+ const newOrder = { 'result': order };
3773
+ return this.parseOrder(newOrder, market);
3766
3774
  }
3767
3775
  }
3768
3776
 
@@ -275,6 +275,108 @@ class bitmex extends bitmex$1 {
275
275
  'SOL': 'sol',
276
276
  'ADA': 'ada',
277
277
  },
278
+ 'features': {
279
+ 'default': {
280
+ 'sandbox': true,
281
+ 'createOrder': {
282
+ 'marginMode': true,
283
+ 'triggerPrice': true,
284
+ 'triggerPriceType': {
285
+ 'last': true,
286
+ 'mark': true,
287
+ },
288
+ 'triggerDirection': true,
289
+ 'stopLossPrice': false,
290
+ 'takeProfitPrice': false,
291
+ 'attachedStopLossTakeProfit': undefined,
292
+ 'timeInForce': {
293
+ 'IOC': true,
294
+ 'FOK': true,
295
+ 'PO': true,
296
+ 'GTD': false,
297
+ },
298
+ 'hedged': false,
299
+ 'trailing': true,
300
+ 'marketBuyRequiresPrice': false,
301
+ 'marketBuyByCost': false,
302
+ // exchange-supported features
303
+ // 'selfTradePrevention': true,
304
+ // 'twap': false,
305
+ // 'iceberg': false,
306
+ // 'oco': false,
307
+ },
308
+ 'createOrders': undefined,
309
+ 'fetchMyTrades': {
310
+ 'marginMode': false,
311
+ 'limit': 500,
312
+ 'daysBack': undefined,
313
+ 'untilDays': 1000000,
314
+ },
315
+ 'fetchOrder': {
316
+ 'marginMode': false,
317
+ 'trigger': false,
318
+ 'trailing': false,
319
+ },
320
+ 'fetchOpenOrders': {
321
+ 'marginMode': false,
322
+ 'limit': 500,
323
+ 'trigger': false,
324
+ 'trailing': false,
325
+ },
326
+ 'fetchOrders': {
327
+ 'marginMode': false,
328
+ 'limit': 500,
329
+ 'daysBack': undefined,
330
+ 'untilDays': 1000000,
331
+ 'trigger': false,
332
+ 'trailing': false,
333
+ },
334
+ 'fetchClosedOrders': {
335
+ 'marginMode': false,
336
+ 'limit': 500,
337
+ 'daysBackClosed': undefined,
338
+ 'daysBackCanceled': undefined,
339
+ 'untilDays': 1000000,
340
+ 'trigger': false,
341
+ 'trailing': false,
342
+ },
343
+ 'fetchOHLCV': {
344
+ 'limit': 10000,
345
+ },
346
+ },
347
+ 'spot': {
348
+ 'extends': 'default',
349
+ 'createOrder': {
350
+ 'triggerPriceType': {
351
+ 'index': false,
352
+ },
353
+ },
354
+ },
355
+ 'forDeriv': {
356
+ 'extends': 'default',
357
+ 'createOrder': {
358
+ 'triggerPriceType': {
359
+ 'index': true,
360
+ },
361
+ },
362
+ },
363
+ 'swap': {
364
+ 'linear': {
365
+ 'extends': 'forDeriv',
366
+ },
367
+ 'inverse': {
368
+ 'extends': 'forDeriv',
369
+ },
370
+ },
371
+ 'future': {
372
+ 'linear': {
373
+ 'extends': 'forDeriv',
374
+ },
375
+ 'inverse': {
376
+ 'extends': 'forDeriv',
377
+ },
378
+ },
379
+ },
278
380
  },
279
381
  'commonCurrencies': {
280
382
  'USDt': 'USDT',
@@ -1014,7 +1116,7 @@ class bitmex extends bitmex$1 {
1014
1116
  request['startTime'] = this.iso8601(since);
1015
1117
  }
1016
1118
  if (limit !== undefined) {
1017
- request['count'] = limit;
1119
+ request['count'] = Math.min(500, limit);
1018
1120
  }
1019
1121
  const until = this.safeInteger2(params, 'until', 'endTime');
1020
1122
  if (until !== undefined) {
@@ -145,6 +145,7 @@ class bitopro extends bitopro$1 {
145
145
  'wallet/withdraw/{currency}/id/{id}': 1,
146
146
  'wallet/depositHistory/{currency}': 1,
147
147
  'wallet/withdrawHistory/{currency}': 1,
148
+ 'orders/open': 1,
148
149
  },
149
150
  'post': {
150
151
  'orders/{pair}': 1 / 2,
@@ -1282,11 +1283,28 @@ class bitopro extends bitopro$1 {
1282
1283
  //
1283
1284
  return this.parseOrders(orders, market, since, limit);
1284
1285
  }
1286
+ /**
1287
+ * @method
1288
+ * @name bitopro#fetchOpenOrders
1289
+ * @description fetch all unfilled currently open orders
1290
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_open_orders_data.md
1291
+ * @param {string} symbol unified market symbol
1292
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1293
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1294
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1295
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1296
+ */
1285
1297
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1286
- const request = {
1287
- 'statusKind': 'OPEN',
1288
- };
1289
- return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
1298
+ await this.loadMarkets();
1299
+ const request = {};
1300
+ let market = undefined;
1301
+ if (symbol !== undefined) {
1302
+ market = this.market(symbol);
1303
+ request['pair'] = market['id'];
1304
+ }
1305
+ const response = await this.privateGetOrdersOpen(this.extend(request, params));
1306
+ const orders = this.safeList(response, 'data', []);
1307
+ return this.parseOrders(orders, market, since, limit);
1290
1308
  }
1291
1309
  /**
1292
1310
  * @method
@@ -1734,6 +1734,7 @@ class bitso extends bitso$1 {
1734
1734
  if (api === 'private') {
1735
1735
  this.checkRequiredCredentials();
1736
1736
  const nonce = this.nonce().toString();
1737
+ endpoint = '/api' + endpoint;
1737
1738
  let request = [nonce, method, endpoint].join('');
1738
1739
  if (method !== 'GET' && method !== 'DELETE') {
1739
1740
  if (Object.keys(query).length) {
@@ -1745,7 +1746,7 @@ class bitso extends bitso$1 {
1745
1746
  const auth = this.apiKey + ':' + nonce + ':' + signature;
1746
1747
  headers = {
1747
1748
  'Authorization': 'Bitso ' + auth,
1748
- 'Content-Type': 'application/json',
1749
+ // 'Content-Type': 'application/json',
1749
1750
  };
1750
1751
  }
1751
1752
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
@@ -240,6 +240,9 @@ class bybit extends bybit$1 {
240
240
  'v5/spot-cross-margin-trade/data': 5,
241
241
  'v5/spot-cross-margin-trade/pledge-token': 5,
242
242
  'v5/spot-cross-margin-trade/borrow-token': 5,
243
+ // crypto loan
244
+ 'v5/crypto-loan/collateral-data': 5,
245
+ 'v5/crypto-loan/loanable-data': 5,
243
246
  // institutional lending
244
247
  'v5/ins-loan/product-infos': 5,
245
248
  'v5/ins-loan/ensure-tokens-convert': 5,
@@ -367,6 +370,8 @@ class bybit extends bybit$1 {
367
370
  'v5/user/aff-customer-info': 5,
368
371
  'v5/user/del-submember': 5,
369
372
  'v5/user/submembers': 5,
373
+ // affilate
374
+ 'v5/affiliate/aff-user-list': 5,
370
375
  // spot leverage token
371
376
  'v5/spot-lever-token/order-record': 1,
372
377
  // spot margin trade
@@ -376,6 +381,13 @@ class bybit extends bybit$1 {
376
381
  'v5/spot-cross-margin-trade/account': 1,
377
382
  'v5/spot-cross-margin-trade/orders': 1,
378
383
  'v5/spot-cross-margin-trade/repay-history': 1,
384
+ // crypto loan
385
+ 'v5/crypto-loan/borrowable-collateralisable-number': 5,
386
+ 'v5/crypto-loan/ongoing-orders': 5,
387
+ 'v5/crypto-loan/repayment-history': 5,
388
+ 'v5/crypto-loan/borrow-history': 5,
389
+ 'v5/crypto-loan/max-collateral-amount': 5,
390
+ 'v5/crypto-loan/adjustment-history': 5,
379
391
  // institutional lending
380
392
  'v5/ins-loan/product-infos': 5,
381
393
  'v5/ins-loan/ensure-tokens-convert': 5,
@@ -508,6 +520,10 @@ class bybit extends bybit$1 {
508
520
  'v5/spot-cross-margin-trade/loan': 2.5,
509
521
  'v5/spot-cross-margin-trade/repay': 2.5,
510
522
  'v5/spot-cross-margin-trade/switch': 2.5,
523
+ // crypto loan
524
+ 'v5/crypto-loan/borrow': 5,
525
+ 'v5/crypto-loan/repay': 5,
526
+ 'v5/crypto-loan/adjust-ltv': 5,
511
527
  // institutional lending
512
528
  'v5/ins-loan/association-uid': 5,
513
529
  // c2c lending
@@ -518,6 +534,10 @@ class bybit extends bybit$1 {
518
534
  'v5/account/set-collateral-switch-batch': 5,
519
535
  // demo trading
520
536
  'v5/account/demo-apply-money': 5,
537
+ // broker
538
+ 'v5/broker/award/info': 5,
539
+ 'v5/broker/award/distribute-award': 5,
540
+ 'v5/broker/award/distribution-record': 5,
521
541
  },
522
542
  },
523
543
  },