ccxt 4.3.43 → 4.3.45

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 (45) hide show
  1. package/README.md +7 -5
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +9 -1
  4. package/dist/cjs/src/abstract/oxfun.js +9 -0
  5. package/dist/cjs/src/bitstamp.js +18 -2
  6. package/dist/cjs/src/kucoin.js +28 -1
  7. package/dist/cjs/src/luno.js +9 -1
  8. package/dist/cjs/src/lykke.js +10 -2
  9. package/dist/cjs/src/ndax.js +5 -1
  10. package/dist/cjs/src/oxfun.js +2900 -0
  11. package/dist/cjs/src/poloniexfutures.js +2 -2
  12. package/dist/cjs/src/pro/bitmex.js +9 -0
  13. package/dist/cjs/src/pro/oxfun.js +1034 -0
  14. package/dist/cjs/src/pro/woo.js +1 -1
  15. package/dist/cjs/src/wavesexchange.js +121 -110
  16. package/dist/cjs/src/xt.js +135 -96
  17. package/js/ccxt.d.ts +11 -2
  18. package/js/ccxt.js +8 -2
  19. package/js/src/abstract/bitstamp.d.ts +16 -0
  20. package/js/src/abstract/kucoin.d.ts +14 -0
  21. package/js/src/abstract/kucoinfutures.d.ts +14 -0
  22. package/js/src/abstract/oxfun.d.ts +37 -0
  23. package/js/src/abstract/oxfun.js +11 -0
  24. package/js/src/abstract/xt.d.ts +155 -0
  25. package/js/src/abstract/xt.js +11 -0
  26. package/js/src/bitstamp.js +18 -2
  27. package/js/src/kucoin.js +28 -1
  28. package/js/src/luno.d.ts +1 -1
  29. package/js/src/luno.js +9 -1
  30. package/js/src/lykke.d.ts +2 -2
  31. package/js/src/lykke.js +10 -2
  32. package/js/src/ndax.d.ts +1 -1
  33. package/js/src/ndax.js +5 -1
  34. package/js/src/oxfun.d.ts +129 -0
  35. package/js/src/oxfun.js +2901 -0
  36. package/js/src/poloniexfutures.js +2 -2
  37. package/js/src/pro/bitmex.js +9 -0
  38. package/js/src/pro/oxfun.d.ts +38 -0
  39. package/js/src/pro/oxfun.js +1035 -0
  40. package/js/src/pro/woo.js +1 -1
  41. package/js/src/wavesexchange.d.ts +7 -7
  42. package/js/src/wavesexchange.js +122 -111
  43. package/js/src/xt.d.ts +161 -0
  44. package/js/src/xt.js +4761 -0
  45. package/package.json +1 -1
package/js/src/pro/woo.js CHANGED
@@ -56,7 +56,7 @@ export default class woo extends wooRest {
56
56
  },
57
57
  'streaming': {
58
58
  'ping': this.ping,
59
- 'keepAlive': 10000,
59
+ 'keepAlive': 9000,
60
60
  },
61
61
  'exceptions': {
62
62
  'ws': {
@@ -43,13 +43,12 @@ export default class wavesexchange extends Exchange {
43
43
  getMatcherPublicKey(): Promise<any>;
44
44
  getAssetBytes(currencyId: any): Uint8Array;
45
45
  getAssetId(currencyId: any): any;
46
- customPriceToPrecision(symbol: any, price: any): number;
47
- customAmountToPrecision(symbol: any, amount: any): number;
48
- customCurrencyToPrecision(code: any, amount: any, networkCode?: any): number;
49
- fromPrecision(amount: any, scale: any): string;
50
- toPrecision(amount: any, scale: any): string;
51
- currencyFromPrecision(currency: any, amount: any): string;
52
- priceFromPrecision(symbol: any, price: any): string;
46
+ toRealCurrencyAmount(code: string, amount: number, networkCode?: any): number;
47
+ fromRealCurrencyAmount(code: string, amountString: string): string;
48
+ toRealSymbolPrice(symbol: string, price: number): number;
49
+ fromRealSymbolPrice(symbol: string, priceString: string): string;
50
+ toRealSymbolAmount(symbol: string, amount: number): number;
51
+ fromRealSymbolAmount(symbol: string, amountString: string): string;
53
52
  safeGetDynamic(settings: any): any;
54
53
  safeGetRates(dynamic: any): any;
55
54
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
@@ -63,6 +62,7 @@ export default class wavesexchange extends Exchange {
63
62
  parseOrder(order: Dict, market?: Market): Order;
64
63
  getWavesAddress(): Promise<any>;
65
64
  fetchBalance(params?: {}): Promise<Balances>;
65
+ setUndefinedBalancesToZero(balances: any, key?: string): any;
66
66
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
67
67
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
68
68
  parseTrade(trade: Dict, market?: Market): Trade;
@@ -9,7 +9,7 @@ import Exchange from './abstract/wavesexchange.js';
9
9
  import { AuthenticationError, InsufficientFunds, InvalidOrder, AccountSuspended, ExchangeError, DuplicateOrderId, OrderNotFound, BadSymbol, ExchangeNotAvailable, BadRequest, ArgumentsRequired } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { ed25519 } from './static_dependencies/noble-curves/ed25519.js';
12
- import { DECIMAL_PLACES } from './base/functions/number.js';
12
+ import { TICK_SIZE } from './base/functions/number.js';
13
13
  // ---------------------------------------------------------------------------
14
14
  /**
15
15
  * @class wavesexchange
@@ -318,9 +318,9 @@ export default class wavesexchange extends Exchange {
318
318
  },
319
319
  },
320
320
  'currencies': {
321
- 'WX': this.safeCurrencyStructure({ 'id': 'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc', 'numericId': undefined, 'code': 'WX', 'precision': this.parseToInt('8') }),
321
+ 'WX': this.safeCurrencyStructure({ 'id': 'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc', 'numericId': undefined, 'code': 'WX', 'precision': this.parseNumber('1e-8') }),
322
322
  },
323
- 'precisionMode': DECIMAL_PLACES,
323
+ 'precisionMode': TICK_SIZE,
324
324
  'options': {
325
325
  'allowedCandles': 1440,
326
326
  'accessToken': undefined,
@@ -331,7 +331,7 @@ export default class wavesexchange extends Exchange {
331
331
  'wavesAddress': undefined,
332
332
  'withdrawFeeUSDN': 7420,
333
333
  'withdrawFeeWAVES': 100000,
334
- 'wavesPrecision': 8,
334
+ 'wavesPrecision': 1e-8,
335
335
  'messagePrefix': 'W',
336
336
  'networks': {
337
337
  'ERC20': 'ETH',
@@ -379,8 +379,8 @@ export default class wavesexchange extends Exchange {
379
379
  async getFeesForAsset(symbol, side, amount, price, params = {}) {
380
380
  await this.loadMarkets();
381
381
  const market = this.market(symbol);
382
- amount = this.customAmountToPrecision(symbol, amount);
383
- price = this.customPriceToPrecision(symbol, price);
382
+ amount = this.toRealSymbolAmount(symbol, amount);
383
+ price = this.toRealSymbolPrice(symbol, price);
384
384
  const request = this.extend({
385
385
  'baseId': market['baseId'],
386
386
  'quoteId': market['quoteId'],
@@ -413,7 +413,7 @@ export default class wavesexchange extends Exchange {
413
413
  const matcherFee = this.safeString(mode, 'matcherFee');
414
414
  const feeAssetId = this.safeString(mode, 'feeAssetId');
415
415
  const feeAsset = this.safeCurrencyCode(feeAssetId);
416
- const adjustedMatcherFee = this.currencyFromPrecision(feeAsset, matcherFee);
416
+ const adjustedMatcherFee = this.fromRealCurrencyAmount(feeAsset, matcherFee);
417
417
  const amountAsString = this.numberToString(amount);
418
418
  const priceAsString = this.numberToString(price);
419
419
  const feeCost = this.feeToPrecision(symbol, this.parseNumber(adjustedMatcherFee));
@@ -566,8 +566,8 @@ export default class wavesexchange extends Exchange {
566
566
  'strike': undefined,
567
567
  'optionType': undefined,
568
568
  'precision': {
569
- 'amount': this.safeInteger(entry, 'amountAssetDecimals'),
570
- 'price': this.safeInteger(entry, 'priceAssetDecimals'),
569
+ 'amount': this.parseNumber(this.parsePrecision(this.safeString(entry, 'amountAssetDecimals'))),
570
+ 'price': this.parseNumber(this.parsePrecision(this.safeString(entry, 'priceAssetDecimals'))),
571
571
  },
572
572
  'limits': {
573
573
  'leverage': {
@@ -624,12 +624,11 @@ export default class wavesexchange extends Exchange {
624
624
  }
625
625
  parseOrderBookSide(bookSide, market = undefined, limit = undefined) {
626
626
  const precision = market['precision'];
627
- const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
628
- const amountPrecision = '1e' + this.numberToString(precision['amount']);
629
- const amountPrecisionString = this.numberToString(precision['amount']);
630
- const pricePrecisionString = this.numberToString(precision['price']);
631
- const difference = Precise.stringSub(amountPrecisionString, pricePrecisionString);
632
- const pricePrecision = '1e' + Precise.stringSub(wavesPrecision, difference);
627
+ const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '1e-8');
628
+ const amountPrecisionString = this.safeString(precision, 'amount');
629
+ const pricePrecisionString = this.safeString(precision, 'price');
630
+ const difference = Precise.stringDiv(amountPrecisionString, pricePrecisionString);
631
+ const pricePrecision = Precise.stringDiv(wavesPrecision, difference);
633
632
  const result = [];
634
633
  for (let i = 0; i < bookSide.length; i++) {
635
634
  const entry = bookSide[i];
@@ -638,10 +637,10 @@ export default class wavesexchange extends Exchange {
638
637
  let price = undefined;
639
638
  let amount = undefined;
640
639
  if ((pricePrecision !== undefined) && (entryPrice !== undefined)) {
641
- price = Precise.stringDiv(entryPrice, pricePrecision);
640
+ price = Precise.stringMul(entryPrice, pricePrecision);
642
641
  }
643
- if ((amountPrecision !== undefined) && (entryAmount !== undefined)) {
644
- amount = Precise.stringDiv(entryAmount, amountPrecision);
642
+ if ((amountPrecisionString !== undefined) && (entryAmount !== undefined)) {
643
+ amount = Precise.stringMul(entryAmount, amountPrecisionString);
645
644
  }
646
645
  if ((limit !== undefined) && (i > limit)) {
647
646
  break;
@@ -1227,51 +1226,36 @@ export default class wavesexchange extends Exchange {
1227
1226
  }
1228
1227
  return currencyId;
1229
1228
  }
1230
- customPriceToPrecision(symbol, price) {
1231
- const market = this.markets[symbol];
1232
- const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
1233
- const amount = this.numberToString(market['precision']['amount']);
1234
- const precisionPrice = this.numberToString(market['precision']['price']);
1235
- const difference = Precise.stringSub(amount, precisionPrice);
1236
- const precision = Precise.stringSub(wavesPrecision, difference);
1237
- const pricePrecision = this.toPrecision(price, precision).toString();
1238
- return this.parseToInt(parseFloat(pricePrecision));
1239
- }
1240
- customAmountToPrecision(symbol, amount) {
1241
- const amountPrecision = this.numberToString(this.toPrecision(amount, this.numberToString(this.markets[symbol]['precision']['amount'])));
1242
- return this.parseToInt(parseFloat(amountPrecision));
1229
+ toRealCurrencyAmount(code, amount, networkCode = undefined) {
1230
+ const currency = this.currency(code);
1231
+ const stringValue = Precise.stringDiv(this.numberToString(amount), this.safeString(currency, 'precision'));
1232
+ return parseInt(stringValue);
1243
1233
  }
1244
- customCurrencyToPrecision(code, amount, networkCode = undefined) {
1245
- const amountPrecision = this.numberToString(this.toPrecision(amount, this.currencies[code]['precision']));
1246
- return this.parseToInt(parseFloat(amountPrecision));
1234
+ fromRealCurrencyAmount(code, amountString) {
1235
+ if (!(code in this.currencies)) {
1236
+ return amountString;
1237
+ }
1238
+ const currency = this.currency(code);
1239
+ const precisionAmount = this.safeString(currency, 'precision');
1240
+ return Precise.stringMul(amountString, precisionAmount);
1247
1241
  }
1248
- fromPrecision(amount, scale) {
1249
- if (amount === undefined) {
1250
- return undefined;
1251
- }
1252
- const precise = new Precise(amount);
1253
- precise.decimals = this.sum(precise.decimals, scale);
1254
- precise.reduce();
1255
- return precise.toString();
1242
+ toRealSymbolPrice(symbol, price) {
1243
+ const market = this.market(symbol);
1244
+ const stringValue = Precise.stringDiv(this.numberToString(price), this.safeString(market['precision'], 'price'));
1245
+ return parseInt(stringValue);
1256
1246
  }
1257
- toPrecision(amount, scale) {
1258
- const amountString = this.numberToString(amount);
1259
- const precise = new Precise(amountString);
1260
- // precise.decimals should be integer
1261
- precise.decimals = this.parseToInt(Precise.stringSub(this.numberToString(precise.decimals), this.numberToString(scale)));
1262
- precise.reduce();
1263
- const stringValue = precise.toString();
1264
- return stringValue;
1247
+ fromRealSymbolPrice(symbol, priceString) {
1248
+ const market = this.markets[symbol];
1249
+ return Precise.stringMul(priceString, this.safeString(market['precision'], 'price'));
1265
1250
  }
1266
- currencyFromPrecision(currency, amount) {
1267
- const scale = this.currencies[currency]['precision'];
1268
- return this.fromPrecision(amount, scale);
1251
+ toRealSymbolAmount(symbol, amount) {
1252
+ const market = this.market(symbol);
1253
+ const stringValue = Precise.stringDiv(this.numberToString(amount), this.safeString(market['precision'], 'amount'));
1254
+ return parseInt(stringValue);
1269
1255
  }
1270
- priceFromPrecision(symbol, price) {
1256
+ fromRealSymbolAmount(symbol, amountString) {
1271
1257
  const market = this.markets[symbol];
1272
- const wavesPrecision = this.safeInteger(this.options, 'wavesPrecision', 8);
1273
- const scale = this.sum(wavesPrecision, market['precision']['price']) - market['precision']['amount'];
1274
- return this.fromPrecision(price, scale);
1258
+ return Precise.stringMul(amountString, market['precision']['amount']);
1275
1259
  }
1276
1260
  safeGetDynamic(settings) {
1277
1261
  const orderFee = this.safeValue(settings, 'orderFee');
@@ -1353,7 +1337,7 @@ export default class wavesexchange extends Exchange {
1353
1337
  }
1354
1338
  const matcherFeeAsset = this.safeCurrencyCode(matcherFeeAssetId);
1355
1339
  const rawMatcherFee = (matcherFeeAssetId === baseFeeAssetId) ? baseMatcherFee : discountMatcherFee;
1356
- const floatMatcherFee = parseFloat(this.currencyFromPrecision(matcherFeeAsset, rawMatcherFee));
1340
+ const floatMatcherFee = parseFloat(this.fromRealCurrencyAmount(matcherFeeAsset, rawMatcherFee));
1357
1341
  if ((matcherFeeAsset in balances) && (balances[matcherFeeAsset]['free'] >= floatMatcherFee)) {
1358
1342
  matcherFee = parseInt(rawMatcherFee);
1359
1343
  }
@@ -1361,26 +1345,26 @@ export default class wavesexchange extends Exchange {
1361
1345
  throw new InsufficientFunds(this.id + ' not enough funds of the selected asset fee');
1362
1346
  }
1363
1347
  }
1348
+ const floatBaseMatcherFee = this.fromRealCurrencyAmount(baseFeeAsset, baseMatcherFee);
1349
+ const floatDiscountMatcherFee = this.fromRealCurrencyAmount(discountFeeAsset, discountMatcherFee);
1364
1350
  if (matcherFeeAssetId === undefined) {
1365
1351
  // try to the pay the fee using the base first then discount asset
1366
- const floatBaseMatcherFee = parseFloat(this.currencyFromPrecision(baseFeeAsset, baseMatcherFee));
1367
- if ((baseFeeAsset in balances) && (balances[baseFeeAsset]['free'] >= floatBaseMatcherFee)) {
1352
+ if ((baseFeeAsset in balances) && (balances[baseFeeAsset]['free'] >= parseFloat(floatBaseMatcherFee))) {
1368
1353
  matcherFeeAssetId = baseFeeAssetId;
1369
1354
  matcherFee = parseInt(baseMatcherFee);
1370
1355
  }
1371
1356
  else {
1372
- const floatDiscountMatcherFee = parseFloat(this.currencyFromPrecision(discountFeeAsset, discountMatcherFee));
1373
- if ((discountFeeAsset in balances) && (balances[discountFeeAsset]['free'] >= floatDiscountMatcherFee)) {
1357
+ if ((discountFeeAsset in balances) && (balances[discountFeeAsset]['free'] >= parseFloat(floatDiscountMatcherFee))) {
1374
1358
  matcherFeeAssetId = discountFeeAssetId;
1375
1359
  matcherFee = parseInt(discountMatcherFee);
1376
1360
  }
1377
1361
  }
1378
1362
  }
1379
1363
  if (matcherFeeAssetId === undefined) {
1380
- throw new InsufficientFunds(this.id + ' not enough funds on none of the eligible asset fees');
1364
+ throw new InsufficientFunds(this.id + ' not enough funds on none of the eligible asset fees: ' + baseFeeAsset + ' ' + floatBaseMatcherFee + ' or ' + discountFeeAsset + ' ' + floatDiscountMatcherFee);
1381
1365
  }
1382
- amount = this.customAmountToPrecision(symbol, amount);
1383
- price = this.customPriceToPrecision(symbol, price);
1366
+ amount = this.toRealSymbolAmount(symbol, amount);
1367
+ price = this.toRealSymbolPrice(symbol, price);
1384
1368
  const assetPair = {
1385
1369
  'amountAsset': amountAsset,
1386
1370
  'priceAsset': priceAsset,
@@ -1418,7 +1402,7 @@ export default class wavesexchange extends Exchange {
1418
1402
  'c': {
1419
1403
  't': 'sp',
1420
1404
  'v': {
1421
- 'p': this.customPriceToPrecision(symbol, stopPrice),
1405
+ 'p': this.toRealSymbolPrice(symbol, stopPrice),
1422
1406
  },
1423
1407
  },
1424
1408
  };
@@ -1766,24 +1750,24 @@ export default class wavesexchange extends Exchange {
1766
1750
  symbol = market['symbol'];
1767
1751
  }
1768
1752
  const amountCurrency = this.safeCurrencyCode(this.safeString(assetPair, 'amountAsset', 'WAVES'));
1769
- const price = this.priceFromPrecision(symbol, priceString);
1770
- const amount = this.currencyFromPrecision(amountCurrency, amountString);
1771
- const filled = this.currencyFromPrecision(amountCurrency, filledString);
1772
- const average = this.priceFromPrecision(symbol, this.safeString(order, 'avgWeighedPrice'));
1753
+ const price = this.fromRealSymbolPrice(symbol, priceString);
1754
+ const amount = this.fromRealCurrencyAmount(amountCurrency, amountString);
1755
+ const filled = this.fromRealCurrencyAmount(amountCurrency, filledString);
1756
+ const average = this.fromRealSymbolPrice(symbol, this.safeString(order, 'avgWeighedPrice'));
1773
1757
  const status = this.parseOrderStatus(this.safeString(order, 'status'));
1774
1758
  let fee = undefined;
1775
1759
  if ('type' in order) {
1776
- const currency = this.safeCurrencyCode(this.safeString(order, 'feeAsset'));
1760
+ const code = this.safeCurrencyCode(this.safeString(order, 'feeAsset'));
1777
1761
  fee = {
1778
- 'currency': currency,
1779
- 'fee': this.parseNumber(this.currencyFromPrecision(currency, this.safeString(order, 'filledFee'))),
1762
+ 'currency': code,
1763
+ 'fee': this.parseNumber(this.fromRealCurrencyAmount(code, this.safeString(order, 'filledFee'))),
1780
1764
  };
1781
1765
  }
1782
1766
  else {
1783
- const currency = this.safeCurrencyCode(this.safeString(order, 'matcherFeeAssetId', 'WAVES'));
1767
+ const code = this.safeCurrencyCode(this.safeString(order, 'matcherFeeAssetId', 'WAVES'));
1784
1768
  fee = {
1785
- 'currency': currency,
1786
- 'fee': this.parseNumber(this.currencyFromPrecision(currency, this.safeString(order, 'matcherFee'))),
1769
+ 'currency': code,
1770
+ 'fee': this.parseNumber(this.fromRealCurrencyAmount(code, this.safeString(order, 'matcherFee'))),
1787
1771
  };
1788
1772
  }
1789
1773
  let triggerPrice = undefined;
@@ -1896,7 +1880,7 @@ export default class wavesexchange extends Exchange {
1896
1880
  // ]
1897
1881
  // }
1898
1882
  const balances = this.safeValue(totalBalance, 'balances', []);
1899
- const result = {};
1883
+ let result = {};
1900
1884
  let timestamp = undefined;
1901
1885
  const assetIds = [];
1902
1886
  const nonStandardBalances = [];
@@ -1907,17 +1891,15 @@ export default class wavesexchange extends Exchange {
1907
1891
  const issueTransaction = this.safeValue(entry, 'issueTransaction');
1908
1892
  const currencyId = this.safeString(entry, 'assetId');
1909
1893
  const balance = this.safeString(entry, 'balance');
1910
- if (issueTransaction === undefined) {
1894
+ const currencyExists = (currencyId in this.currencies_by_id);
1895
+ if (currencyExists) {
1896
+ const code = this.safeCurrencyCode(currencyId);
1897
+ result[code] = this.account();
1898
+ result[code]['total'] = this.fromRealCurrencyAmount(code, balance);
1899
+ }
1900
+ else if (issueTransaction === undefined) {
1911
1901
  assetIds.push(currencyId);
1912
1902
  nonStandardBalances.push(balance);
1913
- continue;
1914
- }
1915
- const decimals = this.safeInteger(issueTransaction, 'decimals');
1916
- let code = undefined;
1917
- if (currencyId in this.currencies_by_id) {
1918
- code = this.safeCurrencyCode(currencyId);
1919
- result[code] = this.account();
1920
- result[code]['total'] = this.fromPrecision(balance, decimals);
1921
1903
  }
1922
1904
  }
1923
1905
  const nonStandardAssets = assetIds.length;
@@ -1931,11 +1913,11 @@ export default class wavesexchange extends Exchange {
1931
1913
  const entry = data[i];
1932
1914
  const balance = nonStandardBalances[i];
1933
1915
  const inner = this.safeValue(entry, 'data');
1934
- const decimals = this.safeInteger(inner, 'precision');
1916
+ const precision = this.parsePrecision(this.safeString(inner, 'precision'));
1935
1917
  const ticker = this.safeString(inner, 'ticker');
1936
1918
  const code = this.safeCurrencyCode(ticker);
1937
1919
  result[code] = this.account();
1938
- result[code]['total'] = this.fromPrecision(balance, decimals);
1920
+ result[code]['total'] = Precise.stringMul(balance, precision);
1939
1921
  }
1940
1922
  }
1941
1923
  const currentTimestamp = this.milliseconds();
@@ -1961,12 +1943,7 @@ export default class wavesexchange extends Exchange {
1961
1943
  result[code] = this.account();
1962
1944
  }
1963
1945
  const amount = this.safeString(reservedBalance, currencyId);
1964
- if (code in this.currencies) {
1965
- result[code]['used'] = this.currencyFromPrecision(code, amount);
1966
- }
1967
- else {
1968
- result[code]['used'] = amount;
1969
- }
1946
+ result[code]['used'] = this.fromRealCurrencyAmount(code, amount);
1970
1947
  }
1971
1948
  const wavesRequest = {
1972
1949
  'address': wavesAddress,
@@ -1977,18 +1954,22 @@ export default class wavesexchange extends Exchange {
1977
1954
  // "confirmations": 0,
1978
1955
  // "balance": 909085978
1979
1956
  // }
1980
- result['WAVES'] = this.safeValue(result, 'WAVES', {});
1981
- result['WAVES']['total'] = this.currencyFromPrecision('WAVES', this.safeString(wavesTotal, 'balance'));
1982
- const codes = Object.keys(result);
1957
+ result['WAVES'] = this.safeValue(result, 'WAVES', this.account());
1958
+ result['WAVES']['total'] = this.fromRealCurrencyAmount('WAVES', this.safeString(wavesTotal, 'balance'));
1959
+ result = this.setUndefinedBalancesToZero(result);
1960
+ result['timestamp'] = timestamp;
1961
+ result['datetime'] = this.iso8601(timestamp);
1962
+ return this.safeBalance(result);
1963
+ }
1964
+ setUndefinedBalancesToZero(balances, key = 'used') {
1965
+ const codes = Object.keys(balances);
1983
1966
  for (let i = 0; i < codes.length; i++) {
1984
1967
  const code = codes[i];
1985
- if (this.safeValue(result[code], 'used') === undefined) {
1986
- result[code]['used'] = '0';
1968
+ if (this.safeValue(balances[code], 'used') === undefined) {
1969
+ balances[code][key] = '0';
1987
1970
  }
1988
1971
  }
1989
- result['timestamp'] = timestamp;
1990
- result['datetime'] = this.iso8601(timestamp);
1991
- return this.safeBalance(result);
1972
+ return balances;
1992
1973
  }
1993
1974
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1994
1975
  /**
@@ -2526,7 +2507,7 @@ export default class wavesexchange extends Exchange {
2526
2507
  const feeAssetId = 'WAVES';
2527
2508
  const type = 4; // transfer
2528
2509
  const version = 2;
2529
- const amountInteger = this.customCurrencyToPrecision(code, amount);
2510
+ const amountInteger = this.toRealCurrencyAmount(code, amount);
2530
2511
  const currency = this.currency(code);
2531
2512
  const timestamp = this.milliseconds();
2532
2513
  const byteArray = [
@@ -2586,18 +2567,45 @@ export default class wavesexchange extends Exchange {
2586
2567
  // "amount": 0
2587
2568
  // }
2588
2569
  //
2570
+ // withdraw new:
2571
+ // {
2572
+ // type: "4",
2573
+ // id: "2xnWTqG9ar7jEDrLxfbVyyspPZ6XZNrrw9ai9sQ81Eya",
2574
+ // fee: "100000",
2575
+ // feeAssetId: null,
2576
+ // timestamp: "1715786263807",
2577
+ // version: "2",
2578
+ // sender: "3P81LLX1kk2CSJC9L8C2enxdHB7XvnSGAEE",
2579
+ // senderPublicKey: "DdmzmXf9mty1FBE8AdVGnrncVLEAzP4gR4nWoTFAJoXz",
2580
+ // proofs: [ "RyoKwdSYv3EqotJCYftfFM9JE2j1ZpDRxKwYfiRhLAFeyNp6VfJUXNDS884XfeCeHeNypNmTCZt5NYR1ekyjCX3", ],
2581
+ // recipient: "3P9tXxu38a8tgewNEKFzourVxeqHd11ppOc",
2582
+ // assetId: null,
2583
+ // feeAsset: null,
2584
+ // amount: "2000000",
2585
+ // attachment: "",
2586
+ // }
2587
+ //
2589
2588
  currency = this.safeCurrency(undefined, currency);
2589
+ const code = currency['code'];
2590
+ const typeRaw = this.safeString(transaction, 'type');
2591
+ const type = (typeRaw === '4') ? 'withdraw' : 'deposit';
2592
+ const amount = this.parseNumber(this.fromRealCurrencyAmount(code, this.safeString(transaction, 'amount')));
2593
+ const feeString = this.safeString(transaction, 'fee');
2594
+ const feeAssetId = this.safeString(transaction, 'feeAssetId', 'WAVES');
2595
+ const feeCode = this.safeCurrencyCode(feeAssetId);
2596
+ const feeAmount = this.parseNumber(this.fromRealCurrencyAmount(feeCode, feeString));
2597
+ const timestamp = this.safeInteger(transaction, 'timestamp');
2590
2598
  return {
2591
- 'id': undefined,
2599
+ 'id': this.safeString(transaction, 'id'),
2592
2600
  'txid': undefined,
2593
- 'timestamp': undefined,
2594
- 'datetime': undefined,
2601
+ 'timestamp': timestamp,
2602
+ 'datetime': this.iso8601(timestamp),
2595
2603
  'network': undefined,
2596
- 'addressFrom': undefined,
2604
+ 'addressFrom': this.safeString(transaction, 'sender'),
2597
2605
  'address': undefined,
2598
- 'addressTo': undefined,
2599
- 'amount': undefined,
2600
- 'type': undefined,
2606
+ 'addressTo': this.safeString(transaction, 'recipient'),
2607
+ 'amount': amount,
2608
+ 'type': type,
2601
2609
  'currency': currency['code'],
2602
2610
  'status': undefined,
2603
2611
  'updated': undefined,
@@ -2606,7 +2614,10 @@ export default class wavesexchange extends Exchange {
2606
2614
  'tagTo': undefined,
2607
2615
  'comment': undefined,
2608
2616
  'internal': undefined,
2609
- 'fee': undefined,
2617
+ 'fee': {
2618
+ 'currency': feeCode,
2619
+ 'cost': feeAmount,
2620
+ },
2610
2621
  'info': transaction,
2611
2622
  };
2612
2623
  }
package/js/src/xt.d.ts ADDED
@@ -0,0 +1,161 @@
1
+ import Exchange from './abstract/xt.js';
2
+ import { Currencies, Currency, Dict, FundingHistory, FundingRateHistory, Int, LeverageTier, MarginModification, Market, Num, OHLCV, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry } from './base/types.js';
3
+ export default class xt extends Exchange {
4
+ describe(): any;
5
+ nonce(): number;
6
+ fetchTime(params?: {}): Promise<number>;
7
+ fetchCurrencies(params?: {}): Promise<Currencies>;
8
+ fetchMarkets(params?: {}): Promise<Market[]>;
9
+ fetchSpotMarkets(params?: {}): Promise<any[]>;
10
+ fetchSwapAndFutureMarkets(params?: {}): Promise<any[]>;
11
+ parseMarkets(markets: any): any[];
12
+ parseMarket(market: Dict): Market;
13
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
14
+ parseOHLCV(ohlcv: any, market?: Market): OHLCV;
15
+ fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<import("./base/types.js").OrderBook>;
16
+ fetchTicker(symbol: string, params?: {}): Promise<import("./base/types.js").Ticker>;
17
+ fetchTickers(symbols?: string[], params?: {}): Promise<Tickers>;
18
+ fetchBidsAsks(symbols?: string[], params?: {}): Promise<Tickers>;
19
+ parseTicker(ticker: any, market?: any): import("./base/types.js").Ticker;
20
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
21
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
22
+ parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
23
+ fetchBalance(params?: {}): Promise<import("./base/types.js").Balances>;
24
+ parseBalance(response: any): import("./base/types.js").Balances;
25
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
26
+ createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
27
+ createSpotOrder(symbol: string, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
28
+ createContractOrder(symbol: string, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
29
+ fetchOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
30
+ fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
31
+ fetchOrdersByStatus(status: any, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
32
+ fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
33
+ fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
34
+ fetchCanceledOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
35
+ cancelOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
36
+ cancelAllOrders(symbol?: string, params?: {}): Promise<Order[]>;
37
+ cancelOrders(ids: string[], symbol?: string, params?: {}): Promise<Order[]>;
38
+ parseOrder(order: any, market?: any): Order;
39
+ parseOrderStatus(status: any): string;
40
+ fetchLedger(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
41
+ parseLedgerEntry(item: any, currency?: any): {
42
+ id: string;
43
+ direction: string;
44
+ account: any;
45
+ referenceId: any;
46
+ referenceAccount: any;
47
+ type: string;
48
+ currency: string;
49
+ amount: number;
50
+ timestamp: number;
51
+ datetime: string;
52
+ before: any;
53
+ after: number;
54
+ status: any;
55
+ fee: {
56
+ currency: any;
57
+ cost: any;
58
+ };
59
+ info: any;
60
+ };
61
+ parseLedgerEntryType(type: any): string;
62
+ fetchDepositAddress(code: string, params?: {}): Promise<{
63
+ currency: string;
64
+ address: string;
65
+ tag: string;
66
+ network: any;
67
+ info: any;
68
+ }>;
69
+ parseDepositAddress(depositAddress: any, currency?: any): {
70
+ currency: string;
71
+ address: string;
72
+ tag: string;
73
+ network: any;
74
+ info: any;
75
+ };
76
+ fetchDeposits(code?: string, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
77
+ fetchWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
78
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
79
+ parseTransaction(transaction: Dict, currency?: Currency): Transaction;
80
+ parseTransactionStatus(status: any): string;
81
+ setLeverage(leverage: Int, symbol?: string, params?: {}): Promise<any>;
82
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
83
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
84
+ modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<MarginModification>;
85
+ parseMarginModification(data: any, market?: any): MarginModification;
86
+ fetchLeverageTiers(symbols?: string[], params?: {}): Promise<{}>;
87
+ parseLeverageTiers(response: any, symbols?: any, marketIdKey?: any): {};
88
+ fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<LeverageTier[]>;
89
+ parseMarketLeverageTiers(info: any, market?: any): any[];
90
+ fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
91
+ fetchFundingRate(symbol: string, params?: {}): Promise<{
92
+ info: any;
93
+ symbol: string;
94
+ markPrice: any;
95
+ indexPrice: any;
96
+ interestRate: any;
97
+ estimatedSettlePrice: any;
98
+ timestamp: any;
99
+ datetime: any;
100
+ fundingRate: number;
101
+ fundingTimestamp: number;
102
+ fundingDatetime: string;
103
+ nextFundingRate: any;
104
+ nextFundingTimestamp: any;
105
+ nextFundingDatetime: any;
106
+ previousFundingRate: any;
107
+ previousFundingTimestamp: any;
108
+ previousFundingDatetime: any;
109
+ }>;
110
+ parseFundingRate(contract: any, market?: any): {
111
+ info: any;
112
+ symbol: string;
113
+ markPrice: any;
114
+ indexPrice: any;
115
+ interestRate: any;
116
+ estimatedSettlePrice: any;
117
+ timestamp: any;
118
+ datetime: any;
119
+ fundingRate: number;
120
+ fundingTimestamp: number;
121
+ fundingDatetime: string;
122
+ nextFundingRate: any;
123
+ nextFundingTimestamp: any;
124
+ nextFundingDatetime: any;
125
+ previousFundingRate: any;
126
+ previousFundingTimestamp: any;
127
+ previousFundingDatetime: any;
128
+ };
129
+ fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
130
+ parseFundingHistory(contract: any, market?: any): {
131
+ info: any;
132
+ symbol: string;
133
+ code: string;
134
+ timestamp: number;
135
+ datetime: string;
136
+ id: string;
137
+ amount: number;
138
+ };
139
+ fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
140
+ fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
141
+ parsePosition(position: any, market?: any): import("./base/types.js").Position;
142
+ transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
143
+ parseTransfer(transfer: any, currency?: any): {
144
+ info: any;
145
+ id: string;
146
+ timestamp: any;
147
+ datetime: any;
148
+ currency: any;
149
+ amount: any;
150
+ fromAccount: any;
151
+ toAccount: any;
152
+ status: any;
153
+ };
154
+ handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
155
+ sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
156
+ url: any;
157
+ method: string;
158
+ body: any;
159
+ headers: any;
160
+ };
161
+ }