ccxt 4.5.56 → 4.5.57

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 (261) hide show
  1. package/README.md +10 -9
  2. package/dist/ccxt.browser.min.js +10 -10
  3. package/dist/cjs/ccxt.js +6 -11
  4. package/dist/cjs/src/apex.js +1 -1
  5. package/dist/cjs/src/arkham.js +3 -3
  6. package/dist/cjs/src/ascendex.js +2 -2
  7. package/dist/cjs/src/aster.js +7 -4
  8. package/dist/cjs/src/backpack.js +4 -4
  9. package/dist/cjs/src/base/Exchange.js +69 -32
  10. package/dist/cjs/src/base/functions/io.js +25 -0
  11. package/dist/cjs/src/base/functions.js +1 -0
  12. package/dist/cjs/src/bigone.js +3 -3
  13. package/dist/cjs/src/binance.js +192 -194
  14. package/dist/cjs/src/bingx.js +3 -3
  15. package/dist/cjs/src/bitfinex.js +71 -58
  16. package/dist/cjs/src/bitget.js +2 -2
  17. package/dist/cjs/src/bitmart.js +13 -6
  18. package/dist/cjs/src/bitmex.js +1 -1
  19. package/dist/cjs/src/bitopro.js +1 -1
  20. package/dist/cjs/src/bitrue.js +2 -2
  21. package/dist/cjs/src/bitso.js +1 -1
  22. package/dist/cjs/src/bitstamp.js +2 -1
  23. package/dist/cjs/src/bitteam.js +1 -1
  24. package/dist/cjs/src/bittrade.js +0 -1
  25. package/dist/cjs/src/bitvavo.js +457 -34
  26. package/dist/cjs/src/blofin.js +26 -3
  27. package/dist/cjs/src/bullish.js +6 -5
  28. package/dist/cjs/src/bydfi.js +1 -1
  29. package/dist/cjs/src/cex.js +3 -3
  30. package/dist/cjs/src/coinbase.js +75 -65
  31. package/dist/cjs/src/coinbaseexchange.js +2 -2
  32. package/dist/cjs/src/coinbaseinternational.js +2 -1
  33. package/dist/cjs/src/coinex.js +74 -74
  34. package/dist/cjs/src/coinmetro.js +1 -1
  35. package/dist/cjs/src/coinsph.js +1 -1
  36. package/dist/cjs/src/cryptocom.js +46 -48
  37. package/dist/cjs/src/cryptomus.js +43 -39
  38. package/dist/cjs/src/deepcoin.js +3 -2
  39. package/dist/cjs/src/delta.js +51 -52
  40. package/dist/cjs/src/deribit.js +31 -33
  41. package/dist/cjs/src/derive.js +26 -28
  42. package/dist/cjs/src/digifinex.js +43 -44
  43. package/dist/cjs/src/exmo.js +92 -83
  44. package/dist/cjs/src/extended.js +3497 -0
  45. package/dist/cjs/src/foxbit.js +71 -75
  46. package/dist/cjs/src/gate.js +53 -53
  47. package/dist/cjs/src/gemini.js +41 -43
  48. package/dist/cjs/src/grvt.js +4 -4
  49. package/dist/cjs/src/hashkey.js +52 -54
  50. package/dist/cjs/src/hitbtc.js +3 -13
  51. package/dist/cjs/src/hollaex.js +51 -54
  52. package/dist/cjs/src/htx.js +75 -67
  53. package/dist/cjs/src/hyperliquid.js +41 -42
  54. package/dist/cjs/src/indodax.js +2 -2
  55. package/dist/cjs/src/kraken.js +57 -58
  56. package/dist/cjs/src/kucoin.js +3 -2
  57. package/dist/cjs/src/latoken.js +30 -32
  58. package/dist/cjs/src/lbank.js +56 -56
  59. package/dist/cjs/src/lighter.js +35 -37
  60. package/dist/cjs/src/luno.js +35 -43
  61. package/dist/cjs/src/mexc.js +48 -49
  62. package/dist/cjs/src/modetrade.js +50 -52
  63. package/dist/cjs/src/ndax.js +35 -37
  64. package/dist/cjs/src/okx.js +17 -2
  65. package/dist/cjs/src/onetrading.js +21 -23
  66. package/dist/cjs/src/phemex.js +43 -45
  67. package/dist/cjs/src/poloniex.js +17 -12
  68. package/dist/cjs/src/pro/alpaca.js +1 -1
  69. package/dist/cjs/src/pro/apex.js +1 -1
  70. package/dist/cjs/src/pro/arkham.js +1 -1
  71. package/dist/cjs/src/pro/backpack.js +1 -1
  72. package/dist/cjs/src/pro/binance.js +3 -3
  73. package/dist/cjs/src/pro/bitget.js +1 -1
  74. package/dist/cjs/src/pro/bithumb.js +1 -1
  75. package/dist/cjs/src/pro/bitstamp.js +1 -1
  76. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  77. package/dist/cjs/src/pro/bybit.js +1 -1
  78. package/dist/cjs/src/pro/cex.js +1 -1
  79. package/dist/cjs/src/pro/coinex.js +1 -1
  80. package/dist/cjs/src/pro/coinone.js +1 -1
  81. package/dist/cjs/src/pro/cryptocom.js +3 -1
  82. package/dist/cjs/src/pro/dydx.js +1 -1
  83. package/dist/cjs/src/pro/exmo.js +1 -1
  84. package/dist/cjs/src/pro/extended.js +865 -0
  85. package/dist/cjs/src/pro/gate.js +1 -1
  86. package/dist/cjs/src/pro/independentreserve.js +1 -1
  87. package/dist/cjs/src/pro/kucoin.js +1 -1
  88. package/dist/cjs/src/pro/luno.js +3 -3
  89. package/dist/cjs/src/pro/onetrading.js +1 -1
  90. package/dist/cjs/src/pro/toobit.js +1 -1
  91. package/dist/cjs/src/pro/weex.js +1 -1
  92. package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +7 -7
  93. package/dist/cjs/src/tokocrypto.js +1 -1
  94. package/dist/cjs/src/toobit.js +2 -2
  95. package/dist/cjs/src/upbit.js +3 -3
  96. package/dist/cjs/src/weex.js +57 -62
  97. package/dist/cjs/src/whitebit.js +61 -63
  98. package/dist/cjs/src/woo.js +65 -54
  99. package/dist/cjs/src/woofipro.js +53 -47
  100. package/dist/cjs/src/xt.js +1 -1
  101. package/dist/cjs/src/zebpay.js +70 -72
  102. package/js/ccxt.d.ts +8 -14
  103. package/js/ccxt.js +6 -10
  104. package/js/src/abstract/bitvavo.d.ts +15 -7
  105. package/js/src/abstract/extended.d.ts +58 -0
  106. package/js/src/apex.js +1 -1
  107. package/js/src/arkham.js +3 -3
  108. package/js/src/ascendex.js +2 -2
  109. package/js/src/aster.js +7 -4
  110. package/js/src/backpack.js +4 -4
  111. package/js/src/base/Exchange.d.ts +10 -6
  112. package/js/src/base/Exchange.js +69 -32
  113. package/js/src/base/functions/io.d.ts +7 -0
  114. package/js/src/base/functions/io.js +24 -0
  115. package/js/src/bigone.js +3 -3
  116. package/js/src/binance.d.ts +2 -0
  117. package/js/src/binance.js +196 -198
  118. package/js/src/bingx.js +3 -3
  119. package/js/src/bitfinex.d.ts +2 -0
  120. package/js/src/bitfinex.js +71 -58
  121. package/js/src/bitget.js +2 -2
  122. package/js/src/bitmart.js +13 -6
  123. package/js/src/bitmex.js +1 -1
  124. package/js/src/bitopro.js +1 -1
  125. package/js/src/bitrue.js +2 -2
  126. package/js/src/bitso.js +1 -1
  127. package/js/src/bitstamp.js +2 -1
  128. package/js/src/bitteam.js +1 -1
  129. package/js/src/bittrade.js +0 -1
  130. package/js/src/bitvavo.d.ts +114 -21
  131. package/js/src/bitvavo.js +457 -34
  132. package/js/src/blofin.d.ts +1 -0
  133. package/js/src/blofin.js +26 -3
  134. package/js/src/bullish.js +6 -5
  135. package/js/src/bydfi.js +1 -1
  136. package/js/src/cex.js +3 -3
  137. package/js/src/coinbase.d.ts +63 -56
  138. package/js/src/coinbase.js +75 -65
  139. package/js/src/coinbaseexchange.js +2 -2
  140. package/js/src/coinbaseinternational.js +2 -1
  141. package/js/src/coinex.d.ts +1 -0
  142. package/js/src/coinex.js +74 -74
  143. package/js/src/coinmetro.d.ts +1 -1
  144. package/js/src/coinmetro.js +1 -1
  145. package/js/src/coinsph.js +1 -1
  146. package/js/src/cryptocom.d.ts +1 -0
  147. package/js/src/cryptocom.js +46 -48
  148. package/js/src/cryptomus.d.ts +2 -1
  149. package/js/src/cryptomus.js +43 -39
  150. package/js/src/deepcoin.js +3 -2
  151. package/js/src/delta.d.ts +1 -0
  152. package/js/src/delta.js +51 -52
  153. package/js/src/deribit.d.ts +1 -0
  154. package/js/src/deribit.js +31 -33
  155. package/js/src/derive.d.ts +1 -0
  156. package/js/src/derive.js +26 -28
  157. package/js/src/digifinex.d.ts +1 -0
  158. package/js/src/digifinex.js +43 -44
  159. package/js/src/exmo.d.ts +1 -0
  160. package/js/src/exmo.js +92 -83
  161. package/js/src/extended.d.ts +554 -0
  162. package/js/src/extended.js +3490 -0
  163. package/js/src/foxbit.d.ts +1 -0
  164. package/js/src/foxbit.js +71 -75
  165. package/js/src/gate.d.ts +1 -0
  166. package/js/src/gate.js +53 -53
  167. package/js/src/gemini.d.ts +2 -1
  168. package/js/src/gemini.js +41 -43
  169. package/js/src/grvt.js +4 -4
  170. package/js/src/hashkey.d.ts +1 -0
  171. package/js/src/hashkey.js +52 -54
  172. package/js/src/hitbtc.d.ts +0 -1
  173. package/js/src/hitbtc.js +3 -13
  174. package/js/src/hollaex.d.ts +1 -0
  175. package/js/src/hollaex.js +51 -54
  176. package/js/src/htx.d.ts +1 -0
  177. package/js/src/htx.js +75 -67
  178. package/js/src/hyperliquid.d.ts +1 -0
  179. package/js/src/hyperliquid.js +41 -42
  180. package/js/src/indodax.js +2 -2
  181. package/js/src/kraken.d.ts +2 -1
  182. package/js/src/kraken.js +57 -58
  183. package/js/src/kucoin.js +3 -2
  184. package/js/src/latoken.d.ts +1 -0
  185. package/js/src/latoken.js +30 -32
  186. package/js/src/lbank.d.ts +1 -0
  187. package/js/src/lbank.js +56 -56
  188. package/js/src/lighter.d.ts +1 -0
  189. package/js/src/lighter.js +35 -37
  190. package/js/src/luno.d.ts +1 -0
  191. package/js/src/luno.js +35 -43
  192. package/js/src/mexc.d.ts +2 -1
  193. package/js/src/mexc.js +48 -49
  194. package/js/src/modetrade.d.ts +1 -0
  195. package/js/src/modetrade.js +50 -52
  196. package/js/src/ndax.d.ts +1 -0
  197. package/js/src/ndax.js +35 -37
  198. package/js/src/okx.js +17 -2
  199. package/js/src/onetrading.d.ts +2 -1
  200. package/js/src/onetrading.js +21 -23
  201. package/js/src/phemex.d.ts +1 -0
  202. package/js/src/phemex.js +43 -45
  203. package/js/src/poloniex.js +17 -12
  204. package/js/src/pro/alpaca.js +1 -1
  205. package/js/src/pro/apex.js +1 -1
  206. package/js/src/pro/arkham.js +1 -1
  207. package/js/src/pro/backpack.js +1 -1
  208. package/js/src/pro/binance.js +3 -3
  209. package/js/src/pro/bitget.js +1 -1
  210. package/js/src/pro/bithumb.js +1 -1
  211. package/js/src/pro/bitstamp.js +1 -1
  212. package/js/src/pro/blockchaincom.js +1 -1
  213. package/js/src/pro/bybit.js +1 -1
  214. package/js/src/pro/cex.js +1 -1
  215. package/js/src/pro/coinex.js +1 -1
  216. package/js/src/pro/coinone.js +1 -1
  217. package/js/src/pro/cryptocom.js +3 -1
  218. package/js/src/pro/dydx.js +1 -1
  219. package/js/src/pro/exmo.js +1 -1
  220. package/js/src/pro/extended.d.ts +126 -0
  221. package/js/src/pro/extended.js +858 -0
  222. package/js/src/pro/gate.js +1 -1
  223. package/js/src/pro/independentreserve.js +1 -1
  224. package/js/src/pro/kucoin.js +1 -1
  225. package/js/src/pro/luno.d.ts +1 -1
  226. package/js/src/pro/luno.js +3 -3
  227. package/js/src/pro/onetrading.js +1 -1
  228. package/js/src/pro/toobit.js +1 -1
  229. package/js/src/pro/weex.js +1 -1
  230. package/js/src/tokocrypto.js +1 -1
  231. package/js/src/toobit.js +2 -2
  232. package/js/src/upbit.js +3 -3
  233. package/js/src/weex.d.ts +1 -0
  234. package/js/src/weex.js +57 -62
  235. package/js/src/whitebit.d.ts +1 -0
  236. package/js/src/whitebit.js +61 -63
  237. package/js/src/woo.d.ts +1 -0
  238. package/js/src/woo.js +65 -54
  239. package/js/src/woofipro.d.ts +1 -0
  240. package/js/src/woofipro.js +53 -47
  241. package/js/src/xt.js +1 -1
  242. package/js/src/zebpay.d.ts +2 -1
  243. package/js/src/zebpay.js +70 -72
  244. package/package.json +7 -7
  245. package/dist/cjs/src/gateio.js +0 -18
  246. package/dist/cjs/src/oxfun.js +0 -2933
  247. package/dist/cjs/src/pro/gateio.js +0 -18
  248. package/dist/cjs/src/pro/oxfun.js +0 -1113
  249. package/js/src/abstract/gateio.d.ts +0 -346
  250. package/js/src/abstract/gateio.js +0 -5
  251. package/js/src/abstract/oxfun.d.ts +0 -37
  252. package/js/src/gateio.d.ts +0 -4
  253. package/js/src/gateio.js +0 -11
  254. package/js/src/oxfun.d.ts +0 -442
  255. package/js/src/oxfun.js +0 -2926
  256. package/js/src/pro/gateio.d.ts +0 -4
  257. package/js/src/pro/gateio.js +0 -11
  258. package/js/src/pro/oxfun.d.ts +0 -234
  259. package/js/src/pro/oxfun.js +0 -1106
  260. /package/dist/cjs/src/abstract/{oxfun.js → extended.js} +0 -0
  261. /package/js/src/abstract/{oxfun.js → extended.js} +0 -0
package/js/src/kraken.js CHANGED
@@ -833,66 +833,65 @@ export default class kraken extends Exchange {
833
833
  // },
834
834
  // }
835
835
  //
836
- const currencies = this.safeValue(response, 'result', {});
837
- const ids = Object.keys(currencies);
838
- const result = {};
839
- for (let i = 0; i < ids.length; i++) {
840
- const id = ids[i];
841
- const currency = currencies[id];
842
- // todo: will need to rethink the fees
843
- // see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
844
- // to add support for multiple withdrawal/deposit methods and
845
- // differentiated fees for each particular method
846
- //
847
- // Notes about abbreviations:
848
- // Z and X prefixes: https://support.kraken.com/hc/en-us/articles/360001206766-Bitcoin-currency-code-XBT-vs-BTC
849
- // S and M suffixes: https://support.kraken.com/hc/en-us/articles/360039879471-What-is-Asset-S-and-Asset-M-
836
+ const currencies = this.safeDict(response, 'result', {});
837
+ const enhancedArray = this.addKeyInArrayItems(currencies, '_coin_id');
838
+ return this.parseCurrencies(enhancedArray);
839
+ }
840
+ parseCurrency(rawCurrency) {
841
+ // todo: will need to rethink the fees
842
+ // see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
843
+ // to add support for multiple withdrawal/deposit methods and
844
+ // differentiated fees for each particular method
845
+ //
846
+ // Notes about abbreviations:
847
+ // Z and X prefixes: https://support.kraken.com/hc/en-us/articles/360001206766-Bitcoin-currency-code-XBT-vs-BTC
848
+ // S and M suffixes: https://support.kraken.com/hc/en-us/articles/360039879471-What-is-Asset-S-and-Asset-M-
849
+ //
850
+ const id = this.safeString(rawCurrency, '_coin_id');
851
+ let code = this.safeCurrencyCode(id);
852
+ // the below cannot be reliably done in `safeCurrencyCode`, so we have to do it here
853
+ if (id.indexOf('.') < 0) {
854
+ const altName = this.safeString(rawCurrency, 'altname');
855
+ // handle cases like below:
850
856
  //
851
- let code = this.safeCurrencyCode(id);
852
- // the below can not be reliable done in `safeCurrencyCode`, so we have to do it here
853
- if (id.indexOf('.') < 0) {
854
- const altName = this.safeString(currency, 'altname');
855
- // handle cases like below:
856
- //
857
- // id | altname
858
- // ---------------
859
- // XXBT | XBT
860
- // ZUSD | USD
861
- if (id !== altName && (id.startsWith('X') || id.startsWith('Z'))) {
862
- code = this.safeCurrencyCode(altName);
863
- // also, add map in commonCurrencies:
864
- this.commonCurrencies[id] = code;
865
- }
866
- else {
867
- code = this.safeCurrencyCode(id);
868
- }
857
+ // id | altname
858
+ // ---------------
859
+ // XXBT | XBT
860
+ // ZUSD | USD
861
+ if (id !== altName && (id.startsWith('X') || id.startsWith('Z'))) {
862
+ code = this.safeCurrencyCode(altName);
863
+ // also, add map in commonCurrencies:
864
+ this.commonCurrencies[id] = code;
865
+ }
866
+ else {
867
+ code = this.safeCurrencyCode(id);
869
868
  }
870
- const isFiat = code.indexOf('.HOLD') >= 0;
871
- result[code] = this.safeCurrencyStructure({
872
- 'id': id,
873
- 'code': code,
874
- 'info': currency,
875
- 'name': this.safeString(currency, 'altname'),
876
- 'active': this.safeString(currency, 'status') === 'enabled',
877
- 'type': isFiat ? 'fiat' : 'crypto',
878
- 'deposit': undefined,
879
- 'withdraw': undefined,
880
- 'fee': undefined,
881
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
882
- 'limits': {
883
- 'amount': {
884
- 'min': undefined,
885
- 'max': undefined,
886
- },
887
- 'withdraw': {
888
- 'min': undefined,
889
- 'max': undefined,
890
- },
891
- },
892
- 'networks': {},
893
- });
894
869
  }
895
- return result;
870
+ const isFiat = code.indexOf('.HOLD') >= 0;
871
+ rawCurrency = this.omit(rawCurrency, '_coin_id');
872
+ return this.safeCurrencyStructure({
873
+ 'id': id,
874
+ 'code': code,
875
+ 'info': rawCurrency,
876
+ 'name': this.safeString(rawCurrency, 'altname'),
877
+ 'active': this.safeString(rawCurrency, 'status') === 'enabled',
878
+ 'type': isFiat ? 'fiat' : 'crypto',
879
+ 'deposit': undefined,
880
+ 'withdraw': undefined,
881
+ 'fee': undefined,
882
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(rawCurrency, 'decimals'))),
883
+ 'limits': {
884
+ 'amount': {
885
+ 'min': undefined,
886
+ 'max': undefined,
887
+ },
888
+ 'withdraw': {
889
+ 'min': undefined,
890
+ 'max': undefined,
891
+ },
892
+ },
893
+ 'networks': {},
894
+ });
896
895
  }
897
896
  safeCurrencyCode(currencyId, currency = undefined) {
898
897
  if (currencyId === undefined) {
@@ -970,7 +969,7 @@ export default class kraken extends Exchange {
970
969
  'tierBased': true,
971
970
  };
972
971
  }
973
- parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
972
+ parseOrderBookBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
974
973
  const price = this.safeNumber(bidask, priceKey);
975
974
  const amount = this.safeNumber(bidask, amountKey);
976
975
  const timestamp = this.safeInteger(bidask, 2);
package/js/src/kucoin.js CHANGED
@@ -3609,7 +3609,7 @@ export default class kucoin extends Exchange {
3609
3609
  let networkCode = undefined;
3610
3610
  [networkCode, params] = this.handleNetworkCodeAndParams(params);
3611
3611
  if (networkCode !== undefined) {
3612
- request['chain'] = this.networkCodeToId(networkCode).toLowerCase();
3612
+ request['chain'] = this.networkCodeToId(networkCode, code).toLowerCase();
3613
3613
  }
3614
3614
  //
3615
3615
  // {
@@ -4287,6 +4287,7 @@ export default class kucoin extends Exchange {
4287
4287
  */
4288
4288
  async createUtaOrder(symbol, type, side, amount, price = undefined, params = {}) {
4289
4289
  await this.loadMarkets();
4290
+ const market = this.market(symbol);
4290
4291
  const request = this.createUtaOrderRequest(symbol, type, side, amount, price, params);
4291
4292
  const response = await this.utaPrivatePostAccountModeOrderPlace(request);
4292
4293
  //
@@ -4301,7 +4302,7 @@ export default class kucoin extends Exchange {
4301
4302
  // }
4302
4303
  //
4303
4304
  const data = this.safeDict(response, 'data', {});
4304
- return this.parseOrder(data);
4305
+ return this.parseOrder(data, market);
4305
4306
  }
4306
4307
  createUtaOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
4307
4308
  const market = this.market(symbol);
@@ -33,6 +33,7 @@ export default class latoken extends Exchange {
33
33
  * @returns {object} an associative dictionary of currencies
34
34
  */
35
35
  fetchCurrencies(params?: {}): Promise<Currencies>;
36
+ parseCurrency(currency: Dict): Currency;
36
37
  /**
37
38
  * @method
38
39
  * @name latoken#fetchBalance
package/js/src/latoken.js CHANGED
@@ -511,39 +511,37 @@ export default class latoken extends Exchange {
511
511
  // },
512
512
  // ]
513
513
  //
514
- const result = {};
515
- for (let i = 0; i < response.length; i++) {
516
- const currency = response[i];
517
- const id = this.safeString(currency, 'id');
518
- const tag = this.safeString(currency, 'tag');
519
- const code = this.safeCurrencyCode(tag);
520
- const currencyType = this.safeString(currency, 'type');
521
- const isCrypto = (currencyType === 'CURRENCY_TYPE_CRYPTO' || currencyType === 'CURRENCY_TYPE_IEO');
522
- result[code] = this.safeCurrencyStructure({
523
- 'id': id,
524
- 'code': code,
525
- 'info': currency,
526
- 'name': this.safeString(currency, 'name'),
527
- 'type': isCrypto ? 'crypto' : 'other',
528
- 'active': this.safeString(currency, 'status') === 'CURRENCY_STATUS_ACTIVE',
529
- 'deposit': undefined,
530
- 'withdraw': undefined,
531
- 'fee': this.safeNumber(currency, 'fee'),
532
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
533
- 'limits': {
534
- 'amount': {
535
- 'min': this.safeNumber(currency, 'minTransferAmount'),
536
- 'max': undefined,
537
- },
538
- 'withdraw': {
539
- 'min': undefined,
540
- 'max': undefined,
541
- },
514
+ return this.parseCurrencies(response);
515
+ }
516
+ parseCurrency(currency) {
517
+ const id = this.safeString(currency, 'id');
518
+ const tag = this.safeString(currency, 'tag');
519
+ const code = this.safeCurrencyCode(tag);
520
+ const currencyType = this.safeString(currency, 'type');
521
+ const isCrypto = (currencyType === 'CURRENCY_TYPE_CRYPTO' || currencyType === 'CURRENCY_TYPE_IEO');
522
+ return this.safeCurrencyStructure({
523
+ 'id': id,
524
+ 'code': code,
525
+ 'info': currency,
526
+ 'name': this.safeString(currency, 'name'),
527
+ 'type': isCrypto ? 'crypto' : 'other',
528
+ 'active': this.safeString(currency, 'status') === 'CURRENCY_STATUS_ACTIVE',
529
+ 'deposit': undefined,
530
+ 'withdraw': undefined,
531
+ 'fee': this.safeNumber(currency, 'fee'),
532
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
533
+ 'limits': {
534
+ 'amount': {
535
+ 'min': this.safeNumber(currency, 'minTransferAmount'),
536
+ 'max': undefined,
542
537
  },
543
- 'networks': {},
544
- });
545
- }
546
- return result;
538
+ 'withdraw': {
539
+ 'min': undefined,
540
+ 'max': undefined,
541
+ },
542
+ },
543
+ 'networks': {},
544
+ });
547
545
  }
548
546
  /**
549
547
  * @method
package/js/src/lbank.d.ts CHANGED
@@ -24,6 +24,7 @@ export default class lbank extends Exchange {
24
24
  * @returns {dict} an associative dictionary of currencies
25
25
  */
26
26
  fetchCurrencies(params?: {}): Promise<Currencies>;
27
+ parseCurrency(rawCurrency: Dict): Currency;
27
28
  /**
28
29
  * @method
29
30
  * @name lbank#fetchMarkets
package/js/src/lbank.js CHANGED
@@ -448,66 +448,65 @@ export default class lbank extends Exchange {
448
448
  //
449
449
  const currenciesData = this.safeList(response, 'data', []);
450
450
  const grouped = this.groupBy(currenciesData, 'assetCode');
451
- const groupedKeys = Object.keys(grouped);
452
- const result = {};
453
- for (let i = 0; i < groupedKeys.length; i++) {
454
- const id = (groupedKeys[i]).toString(); // some currencies are numeric
455
- const code = this.safeCurrencyCode(id);
456
- const networksRaw = grouped[id];
457
- const networks = {};
458
- for (let j = 0; j < networksRaw.length; j++) {
459
- const networkEntry = networksRaw[j];
460
- let networkId = this.safeString(networkEntry, 'chain');
461
- if (networkId === undefined) {
462
- networkId = this.safeString(networkEntry, 'assetCode'); // use type as fallback if networkId is not present
463
- }
464
- const networkCode = this.networkIdToCode(networkId);
465
- networks[networkCode] = {
466
- 'id': networkId,
467
- 'network': networkCode,
468
- 'limits': {
469
- 'withdraw': {
470
- 'min': this.safeNumber(networkEntry, 'min'),
471
- 'max': undefined,
472
- },
473
- 'deposit': {
474
- 'min': this.safeNumber(networkEntry, 'minTransfer'),
475
- 'max': undefined,
476
- },
477
- },
478
- 'active': undefined,
479
- 'deposit': undefined,
480
- 'withdraw': this.safeBool(networkEntry, 'canWithDraw'),
481
- 'fee': this.safeNumber(networkEntry, 'fee'),
482
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(networkEntry, 'transferAmtScale'))),
483
- 'info': networkEntry,
484
- };
451
+ const values = Object.values(grouped);
452
+ return this.parseCurrencies(values);
453
+ }
454
+ parseCurrency(rawCurrency) {
455
+ const id = this.safeString(rawCurrency[0], 'assetCode'); // first member is guaranteed
456
+ const code = this.safeCurrencyCode(id);
457
+ const networksRaw = rawCurrency;
458
+ const networks = {};
459
+ for (let j = 0; j < networksRaw.length; j++) {
460
+ const networkEntry = networksRaw[j];
461
+ let networkId = this.safeString(networkEntry, 'chain');
462
+ if (networkId === undefined) {
463
+ networkId = this.safeString(networkEntry, 'assetCode'); // use type as fallback if networkId is not present
485
464
  }
486
- result[code] = this.safeCurrencyStructure({
487
- 'id': id,
488
- 'code': code,
489
- 'precision': undefined,
490
- 'type': undefined,
491
- 'name': undefined,
492
- 'active': undefined,
493
- 'deposit': undefined,
494
- 'withdraw': undefined,
495
- 'fee': undefined,
465
+ const networkCode = this.networkIdToCode(networkId, code);
466
+ networks[networkCode] = {
467
+ 'id': networkId,
468
+ 'network': networkCode,
496
469
  'limits': {
497
470
  'withdraw': {
498
- 'min': undefined,
471
+ 'min': this.safeNumber(networkEntry, 'min'),
499
472
  'max': undefined,
500
473
  },
501
474
  'deposit': {
502
- 'min': undefined,
475
+ 'min': this.safeNumber(networkEntry, 'minTransfer'),
503
476
  'max': undefined,
504
477
  },
505
478
  },
506
- 'networks': networks,
507
- 'info': networksRaw,
508
- });
479
+ 'active': undefined,
480
+ 'deposit': undefined,
481
+ 'withdraw': this.safeBool(networkEntry, 'canWithDraw'),
482
+ 'fee': this.safeNumber(networkEntry, 'fee'),
483
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(networkEntry, 'transferAmtScale'))),
484
+ 'info': networkEntry,
485
+ };
509
486
  }
510
- return result;
487
+ return this.safeCurrencyStructure({
488
+ 'id': id,
489
+ 'code': code,
490
+ 'precision': undefined,
491
+ 'type': undefined,
492
+ 'name': undefined,
493
+ 'active': undefined,
494
+ 'deposit': undefined,
495
+ 'withdraw': undefined,
496
+ 'fee': undefined,
497
+ 'limits': {
498
+ 'withdraw': {
499
+ 'min': undefined,
500
+ 'max': undefined,
501
+ },
502
+ 'deposit': {
503
+ 'min': undefined,
504
+ 'max': undefined,
505
+ },
506
+ },
507
+ 'networks': networks,
508
+ 'info': networksRaw,
509
+ });
511
510
  }
512
511
  /**
513
512
  * @method
@@ -2270,7 +2269,7 @@ export default class lbank extends Exchange {
2270
2269
  return {
2271
2270
  'info': response,
2272
2271
  'currency': code,
2273
- 'network': this.networkIdToCode(this.safeString(result, 'netWork')),
2272
+ 'network': this.networkIdToCode(this.safeString(result, 'netWork'), code),
2274
2273
  'address': address,
2275
2274
  'tag': tag,
2276
2275
  };
@@ -2459,7 +2458,7 @@ export default class lbank extends Exchange {
2459
2458
  'txid': txid,
2460
2459
  'timestamp': timestamp,
2461
2460
  'datetime': this.iso8601(timestamp),
2462
- 'network': this.networkIdToCode(this.safeString(transaction, 'networkName')),
2461
+ 'network': this.networkIdToCode(this.safeString(transaction, 'networkName'), code),
2463
2462
  'address': address,
2464
2463
  'addressTo': addressTo,
2465
2464
  'addressFrom': addressFrom,
@@ -2664,7 +2663,7 @@ export default class lbank extends Exchange {
2664
2663
  const networkEntry = networkList[j];
2665
2664
  const fee = this.safeNumber(networkEntry, 'withdrawFee');
2666
2665
  if (fee !== undefined) {
2667
- const networkCode = this.networkIdToCode(this.safeString(networkEntry, 'name'));
2666
+ const networkCode = this.networkIdToCode(this.safeString(networkEntry, 'name'), code);
2668
2667
  withdrawFees[code][networkCode] = fee;
2669
2668
  }
2670
2669
  }
@@ -2716,7 +2715,7 @@ export default class lbank extends Exchange {
2716
2715
  if (canWithdraw === 'true') {
2717
2716
  const currencyId = this.safeString(item, 'assetCode');
2718
2717
  const codeInner = this.safeCurrencyCode(currencyId);
2719
- let network = this.networkIdToCode(this.safeString(item, 'chain'));
2718
+ let network = this.networkIdToCode(this.safeString(item, 'chain'), codeInner);
2720
2719
  if (network === undefined) {
2721
2720
  network = codeInner;
2722
2721
  }
@@ -2867,7 +2866,7 @@ export default class lbank extends Exchange {
2867
2866
  const resultCodeInfo = result[code]['info'];
2868
2867
  resultCodeInfo.push(fee);
2869
2868
  }
2870
- const networkCode = this.networkIdToCode(this.safeString(fee, 'chain'));
2869
+ const networkCode = this.networkIdToCode(this.safeString(fee, 'chain'), code);
2871
2870
  if (networkCode !== undefined) {
2872
2871
  result[code]['networks'][networkCode] = {
2873
2872
  'withdraw': {
@@ -2920,10 +2919,11 @@ export default class lbank extends Exchange {
2920
2919
  // }
2921
2920
  //
2922
2921
  const result = this.depositWithdrawFee(fee);
2922
+ const code = this.safeString(currency, 'code');
2923
2923
  const networkList = this.safeValue(fee, 'networkList', []);
2924
2924
  for (let j = 0; j < networkList.length; j++) {
2925
2925
  const networkEntry = networkList[j];
2926
- const networkCode = this.networkIdToCode(this.safeString(networkEntry, 'name'));
2926
+ const networkCode = this.networkIdToCode(this.safeString(networkEntry, 'name'), code);
2927
2927
  const withdrawFee = this.safeNumber(networkEntry, 'withdrawFee');
2928
2928
  const isDefault = this.safeValue(networkEntry, 'isDefault');
2929
2929
  if (withdrawFee !== undefined) {
@@ -110,6 +110,7 @@ export default class lighter extends Exchange {
110
110
  * @returns {object} an associative dictionary of currencies
111
111
  */
112
112
  fetchCurrencies(params?: {}): Promise<Currencies>;
113
+ parseCurrency(rawCurrency: Dict): Currency;
113
114
  /**
114
115
  * @method
115
116
  * @name lighter#fetchOrderBook
package/js/src/lighter.js CHANGED
@@ -1270,44 +1270,42 @@ export default class lighter extends Exchange {
1270
1270
  // }
1271
1271
  //
1272
1272
  const data = this.safeList(response, 'asset_details', []);
1273
- const result = {};
1274
- for (let i = 0; i < data.length; i++) {
1275
- const entry = data[i];
1276
- const id = this.safeString(entry, 'asset_id');
1277
- const code = this.safeCurrencyCode(this.safeString(entry, 'symbol'));
1278
- const decimals = this.safeString(entry, 'decimals');
1279
- const isUSDC = (code === 'USDC');
1280
- let depositMin = undefined;
1281
- let withdrawMin = undefined;
1282
- if (isUSDC) {
1283
- depositMin = this.safeNumber(entry, 'min_transfer_amount');
1284
- withdrawMin = this.safeNumber(entry, 'min_withdrawal_amount');
1285
- }
1286
- result[code] = this.safeCurrencyStructure({
1287
- 'id': id,
1288
- 'name': code,
1289
- 'code': code,
1290
- 'precision': this.parseNumber('1e-' + decimals),
1291
- 'active': true,
1292
- 'fee': undefined,
1293
- 'networks': {},
1294
- 'deposit': isUSDC,
1295
- 'withdraw': isUSDC,
1296
- 'type': 'crypto',
1297
- 'limits': {
1298
- 'deposit': {
1299
- 'min': depositMin,
1300
- 'max': undefined,
1301
- },
1302
- 'withdraw': {
1303
- 'min': withdrawMin,
1304
- 'max': undefined,
1305
- },
1273
+ return this.parseCurrencies(data);
1274
+ }
1275
+ parseCurrency(rawCurrency) {
1276
+ const id = this.safeString(rawCurrency, 'asset_id');
1277
+ const code = this.safeCurrencyCode(this.safeString(rawCurrency, 'symbol'));
1278
+ const decimals = this.safeString(rawCurrency, 'decimals');
1279
+ const isUSDC = (code === 'USDC');
1280
+ let depositMin = undefined;
1281
+ let withdrawMin = undefined;
1282
+ if (isUSDC) {
1283
+ depositMin = this.safeNumber(rawCurrency, 'min_transfer_amount');
1284
+ withdrawMin = this.safeNumber(rawCurrency, 'min_withdrawal_amount');
1285
+ }
1286
+ return this.safeCurrencyStructure({
1287
+ 'id': id,
1288
+ 'name': code,
1289
+ 'code': code,
1290
+ 'precision': this.parseNumber('1e-' + decimals),
1291
+ 'active': true,
1292
+ 'fee': undefined,
1293
+ 'networks': {},
1294
+ 'deposit': isUSDC,
1295
+ 'withdraw': isUSDC,
1296
+ 'type': 'crypto',
1297
+ 'limits': {
1298
+ 'deposit': {
1299
+ 'min': depositMin,
1300
+ 'max': undefined,
1306
1301
  },
1307
- 'info': entry,
1308
- });
1309
- }
1310
- return result;
1302
+ 'withdraw': {
1303
+ 'min': withdrawMin,
1304
+ 'max': undefined,
1305
+ },
1306
+ },
1307
+ 'info': rawCurrency,
1308
+ });
1311
1309
  }
1312
1310
  /**
1313
1311
  * @method
package/js/src/luno.d.ts CHANGED
@@ -14,6 +14,7 @@ export default class luno extends Exchange {
14
14
  * @returns {dict} an associative dictionary of currencies
15
15
  */
16
16
  fetchCurrencies(params?: {}): Promise<Currencies>;
17
+ parseCurrency(rawCurrency: Dict): Currency;
17
18
  /**
18
19
  * @method
19
20
  * @name luno#fetchMarkets
package/js/src/luno.js CHANGED
@@ -326,39 +326,19 @@ export default class luno extends Exchange {
326
326
  // }
327
327
  //
328
328
  const currenciesData = this.safeList(response, 'data', []);
329
- const result = {};
330
- for (let i = 0; i < currenciesData.length; i++) {
331
- const networkEntry = currenciesData[i];
332
- const id = this.safeString(networkEntry, 'native_currency');
333
- const code = this.safeCurrencyCode(id);
334
- if (!(code in result)) {
335
- result[code] = {
336
- 'id': id,
337
- 'code': code,
338
- 'precision': undefined,
339
- 'type': undefined,
340
- 'name': undefined,
341
- 'active': undefined,
342
- 'deposit': undefined,
343
- 'withdraw': undefined,
344
- 'fee': undefined,
345
- 'limits': {
346
- 'withdraw': {
347
- 'min': undefined,
348
- 'max': undefined,
349
- },
350
- 'deposit': {
351
- 'min': undefined,
352
- 'max': undefined,
353
- },
354
- },
355
- 'networks': {},
356
- 'info': {},
357
- };
358
- }
329
+ const grouped = this.groupBy(currenciesData, 'native_currency');
330
+ const values = Object.values(grouped);
331
+ return this.parseCurrencies(values);
332
+ }
333
+ parseCurrency(rawCurrency) {
334
+ const id = this.safeString(rawCurrency[0], 'native_currency'); // first item is guaranteed
335
+ const code = this.safeCurrencyCode(id);
336
+ const networks = {};
337
+ for (let i = 0; i < rawCurrency.length; i++) {
338
+ const networkEntry = rawCurrency[i];
359
339
  const networkId = this.safeString(networkEntry, 'name');
360
- const networkCode = this.networkIdToCode(networkId);
361
- result[code]['networks'][networkCode] = {
340
+ const networkCode = this.networkIdToCode(networkId, code);
341
+ networks[networkCode] = {
362
342
  'id': networkId,
363
343
  'network': networkCode,
364
344
  'limits': {
@@ -378,18 +358,30 @@ export default class luno extends Exchange {
378
358
  'precision': undefined,
379
359
  'info': networkEntry,
380
360
  };
381
- // add entry in info
382
- const info = this.safeList(result[code], 'info', []);
383
- info.push(networkEntry);
384
- result[code]['info'] = info;
385
361
  }
386
- // only after all entries are formed in currencies, restructure each entry
387
- const allKeys = Object.keys(result);
388
- for (let i = 0; i < allKeys.length; i++) {
389
- const code = allKeys[i];
390
- result[code] = this.safeCurrencyStructure(result[code]); // this is needed after adding network entry
391
- }
392
- return result;
362
+ return this.safeCurrencyStructure({
363
+ 'id': id,
364
+ 'code': code,
365
+ 'precision': undefined,
366
+ 'type': undefined,
367
+ 'name': undefined,
368
+ 'active': undefined,
369
+ 'deposit': undefined,
370
+ 'withdraw': undefined,
371
+ 'fee': undefined,
372
+ 'limits': {
373
+ 'withdraw': {
374
+ 'min': undefined,
375
+ 'max': undefined,
376
+ },
377
+ 'deposit': {
378
+ 'min': undefined,
379
+ 'max': undefined,
380
+ },
381
+ },
382
+ 'networks': networks,
383
+ 'info': rawCurrency,
384
+ });
393
385
  }
394
386
  /**
395
387
  * @method
package/js/src/mexc.d.ts CHANGED
@@ -41,6 +41,7 @@ export default class mexc extends Exchange {
41
41
  * @returns {object} an associative dictionary of currencies
42
42
  */
43
43
  fetchCurrencies(params?: {}): Promise<Currencies>;
44
+ parseCurrency(rawCurrency: Dict): Currency;
44
45
  /**
45
46
  * @method
46
47
  * @name mexc#fetchMarkets
@@ -83,7 +84,7 @@ export default class mexc extends Exchange {
83
84
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
84
85
  */
85
86
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
86
- parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
87
+ parseOrderBookBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
87
88
  /**
88
89
  * @method
89
90
  * @name mexc#fetchTrades