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/mexc.js CHANGED
@@ -1146,56 +1146,54 @@ export default class mexc extends Exchange {
1146
1146
  // ]
1147
1147
  // }
1148
1148
  //
1149
- const result = {};
1150
- for (let i = 0; i < response.length; i++) {
1151
- const currency = response[i];
1152
- const id = this.safeString(currency, 'coin');
1153
- const code = this.safeCurrencyCode(id);
1154
- const networks = {};
1155
- const chains = this.safeValue(currency, 'networkList', []);
1156
- for (let j = 0; j < chains.length; j++) {
1157
- const chain = chains[j];
1158
- const networkId = this.safeString2(chain, 'netWork', 'network');
1159
- const network = this.networkIdToCode(networkId);
1160
- networks[network] = {
1161
- 'info': chain,
1162
- 'id': networkId,
1163
- 'network': network,
1164
- 'active': undefined,
1165
- 'deposit': this.safeBool(chain, 'depositEnable', false),
1166
- 'withdraw': this.safeBool(chain, 'withdrawEnable', false),
1167
- 'fee': this.safeNumber(chain, 'withdrawFee'),
1168
- 'precision': undefined,
1169
- 'limits': {
1170
- 'withdraw': {
1171
- 'min': this.safeString(chain, 'withdrawMin'),
1172
- 'max': this.safeString(chain, 'withdrawMax'),
1173
- },
1174
- },
1175
- 'contract': this.safeString(chain, 'contract'),
1176
- };
1177
- }
1178
- result[code] = this.safeCurrencyStructure({
1179
- 'info': currency,
1180
- 'id': id,
1181
- 'code': code,
1182
- 'name': this.safeString(currency, 'name'),
1149
+ return this.parseCurrencies(response);
1150
+ }
1151
+ parseCurrency(rawCurrency) {
1152
+ const id = this.safeString(rawCurrency, 'coin');
1153
+ const code = this.safeCurrencyCode(id);
1154
+ const networks = {};
1155
+ const chains = this.safeValue(rawCurrency, 'networkList', []);
1156
+ for (let j = 0; j < chains.length; j++) {
1157
+ const chain = chains[j];
1158
+ const networkId = this.safeString2(chain, 'netWork', 'network');
1159
+ const network = this.networkIdToCode(networkId, code);
1160
+ networks[network] = {
1161
+ 'info': chain,
1162
+ 'id': networkId,
1163
+ 'network': network,
1183
1164
  'active': undefined,
1184
- 'deposit': undefined,
1185
- 'withdraw': undefined,
1186
- 'fee': undefined,
1165
+ 'deposit': this.safeBool(chain, 'depositEnable', false),
1166
+ 'withdraw': this.safeBool(chain, 'withdrawEnable', false),
1167
+ 'fee': this.safeNumber(chain, 'withdrawFee'),
1187
1168
  'precision': undefined,
1188
1169
  'limits': {
1189
- 'amount': {
1190
- 'min': undefined,
1191
- 'max': undefined,
1170
+ 'withdraw': {
1171
+ 'min': this.safeString(chain, 'withdrawMin'),
1172
+ 'max': this.safeString(chain, 'withdrawMax'),
1192
1173
  },
1193
1174
  },
1194
- 'type': 'crypto',
1195
- 'networks': networks,
1196
- });
1175
+ 'contract': this.safeString(chain, 'contract'),
1176
+ };
1197
1177
  }
1198
- return result;
1178
+ return this.safeCurrencyStructure({
1179
+ 'info': rawCurrency,
1180
+ 'id': id,
1181
+ 'code': code,
1182
+ 'name': this.safeString(rawCurrency, 'name'),
1183
+ 'active': undefined,
1184
+ 'deposit': undefined,
1185
+ 'withdraw': undefined,
1186
+ 'fee': undefined,
1187
+ 'precision': undefined,
1188
+ 'limits': {
1189
+ 'amount': {
1190
+ 'min': undefined,
1191
+ 'max': undefined,
1192
+ },
1193
+ },
1194
+ 'type': 'crypto',
1195
+ 'networks': networks,
1196
+ });
1199
1197
  }
1200
1198
  /**
1201
1199
  * @method
@@ -1533,7 +1531,7 @@ export default class mexc extends Exchange {
1533
1531
  }
1534
1532
  return orderbook;
1535
1533
  }
1536
- parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
1534
+ parseOrderBookBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
1537
1535
  const countKey = 2;
1538
1536
  const price = this.safeNumber(bidask, priceKey);
1539
1537
  const amount = this.safeNumber(bidask, amountKey);
@@ -4763,11 +4761,12 @@ export default class mexc extends Exchange {
4763
4761
  //
4764
4762
  const address = this.safeString(depositAddress, 'address');
4765
4763
  const currencyId = this.safeString(depositAddress, 'coin');
4764
+ const code = this.safeCurrencyCode(currencyId, currency);
4766
4765
  const networkId = this.safeString(depositAddress, 'netWork');
4767
4766
  return {
4768
4767
  'info': depositAddress,
4769
- 'currency': this.safeCurrencyCode(currencyId, currency),
4770
- 'network': this.networkIdToCode(networkId, currencyId),
4768
+ 'currency': code,
4769
+ 'network': this.networkIdToCode(networkId, code),
4771
4770
  'address': address,
4772
4771
  'tag': this.safeString(depositAddress, 'memo'),
4773
4772
  };
@@ -5086,12 +5085,12 @@ export default class mexc extends Exchange {
5086
5085
  if (currencyWithNetwork !== undefined) {
5087
5086
  currencyId = currencyWithNetwork.split('-')[0];
5088
5087
  }
5088
+ const code = this.safeCurrencyCode(currencyId, currency);
5089
5089
  let network = undefined;
5090
5090
  const rawNetwork = this.safeString(transaction, 'network');
5091
5091
  if (rawNetwork !== undefined) {
5092
- network = this.networkIdToCode(rawNetwork);
5092
+ network = this.networkIdToCode(rawNetwork, code);
5093
5093
  }
5094
- const code = this.safeCurrencyCode(currencyId, currency);
5095
5094
  const status = this.parseTransactionStatusByType(this.safeString(transaction, 'status'), type);
5096
5095
  let amountString = this.safeString(transaction, 'amount');
5097
5096
  const address = this.safeString(transaction, 'address');
@@ -50,6 +50,7 @@ export default class modetrade extends Exchange {
50
50
  * @returns {object} an associative dictionary of currencies
51
51
  */
52
52
  fetchCurrencies(params?: {}): Promise<Currencies>;
53
+ parseCurrency(rawCurrency: Dict): Currency;
53
54
  parseTokenAndFeeTemp(item: any, feeTokenKey: any, feeAmountKey: any): any;
54
55
  parseTrade(trade: Dict, market?: Market): Trade;
55
56
  /**
@@ -625,7 +625,6 @@ export default class modetrade extends Exchange {
625
625
  * @returns {object} an associative dictionary of currencies
626
626
  */
627
627
  async fetchCurrencies(params = {}) {
628
- const result = {};
629
628
  const response = await this.v1PublicGetPublicToken(params);
630
629
  //
631
630
  // {
@@ -651,66 +650,65 @@ export default class modetrade extends Exchange {
651
650
  //
652
651
  const data = this.safeDict(response, 'data', {});
653
652
  const tokenRows = this.safeList(data, 'rows', []);
654
- for (let i = 0; i < tokenRows.length; i++) {
655
- const token = tokenRows[i];
656
- const currencyId = this.safeString(token, 'token');
657
- const networks = this.safeList(token, 'chain_details');
658
- const code = this.safeCurrencyCode(currencyId);
659
- let minPrecision = undefined;
660
- const resultingNetworks = {};
661
- for (let j = 0; j < networks.length; j++) {
662
- const network = networks[j];
663
- // TODO: transform chain id to human readable name
664
- const networkId = this.safeString(network, 'chain_id');
665
- const precision = this.parsePrecision(this.safeString(network, 'decimals'));
666
- if (precision !== undefined) {
667
- minPrecision = (minPrecision === undefined) ? precision : Precise.stringMin(precision, minPrecision);
668
- }
669
- resultingNetworks[networkId] = {
670
- 'id': networkId,
671
- 'network': networkId,
672
- 'limits': {
673
- 'withdraw': {
674
- 'min': undefined,
675
- 'max': undefined,
676
- },
677
- 'deposit': {
678
- 'min': undefined,
679
- 'max': undefined,
680
- },
681
- },
682
- 'active': undefined,
683
- 'deposit': undefined,
684
- 'withdraw': undefined,
685
- 'fee': this.safeNumber(network, 'withdrawal_fee'),
686
- 'precision': this.parseNumber(precision),
687
- 'info': network,
688
- };
653
+ return this.parseCurrencies(tokenRows);
654
+ }
655
+ parseCurrency(rawCurrency) {
656
+ const currencyId = this.safeString(rawCurrency, 'token');
657
+ const networks = this.safeList(rawCurrency, 'chain_details');
658
+ const code = this.safeCurrencyCode(currencyId);
659
+ let minPrecision = undefined;
660
+ const resultingNetworks = {};
661
+ for (let j = 0; j < networks.length; j++) {
662
+ const network = networks[j];
663
+ // TODO: transform chain id to human readable name
664
+ const networkId = this.safeString(network, 'chain_id');
665
+ const precision = this.parsePrecision(this.safeString(network, 'decimals'));
666
+ if (precision !== undefined) {
667
+ minPrecision = (minPrecision === undefined) ? precision : Precise.stringMin(precision, minPrecision);
689
668
  }
690
- result[code] = this.safeCurrencyStructure({
691
- 'id': currencyId,
692
- 'name': currencyId,
693
- 'code': code,
694
- 'precision': this.parseNumber(minPrecision),
695
- 'active': undefined,
696
- 'fee': undefined,
697
- 'networks': resultingNetworks,
698
- 'deposit': undefined,
699
- 'withdraw': undefined,
669
+ resultingNetworks[networkId] = {
670
+ 'id': networkId,
671
+ 'network': networkId,
700
672
  'limits': {
701
- 'deposit': {
673
+ 'withdraw': {
702
674
  'min': undefined,
703
675
  'max': undefined,
704
676
  },
705
- 'withdraw': {
706
- 'min': this.safeNumber(token, 'minimum_withdraw_amount'),
677
+ 'deposit': {
678
+ 'min': undefined,
707
679
  'max': undefined,
708
680
  },
709
681
  },
710
- 'info': token,
711
- });
682
+ 'active': undefined,
683
+ 'deposit': undefined,
684
+ 'withdraw': undefined,
685
+ 'fee': this.safeNumber(network, 'withdrawal_fee'),
686
+ 'precision': this.parseNumber(precision),
687
+ 'info': network,
688
+ };
712
689
  }
713
- return result;
690
+ return this.safeCurrencyStructure({
691
+ 'id': currencyId,
692
+ 'name': currencyId,
693
+ 'code': code,
694
+ 'precision': this.parseNumber(minPrecision),
695
+ 'active': undefined,
696
+ 'fee': undefined,
697
+ 'networks': resultingNetworks,
698
+ 'deposit': undefined,
699
+ 'withdraw': undefined,
700
+ 'limits': {
701
+ 'deposit': {
702
+ 'min': undefined,
703
+ 'max': undefined,
704
+ },
705
+ 'withdraw': {
706
+ 'min': this.safeNumber(rawCurrency, 'minimum_withdraw_amount'),
707
+ 'max': undefined,
708
+ },
709
+ },
710
+ 'info': rawCurrency,
711
+ });
714
712
  }
715
713
  parseTokenAndFeeTemp(item, feeTokenKey, feeAmountKey) {
716
714
  const feeCost = this.safeString(item, feeAmountKey);
package/js/src/ndax.d.ts CHANGED
@@ -24,6 +24,7 @@ export default class ndax extends Exchange {
24
24
  * @returns {object} 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 ndax#fetchMarkets
package/js/src/ndax.js CHANGED
@@ -475,43 +475,41 @@ export default class ndax extends Exchange {
475
475
  // },
476
476
  // ...
477
477
  //
478
- const result = {};
479
- for (let i = 0; i < response.length; i++) {
480
- const currency = response[i];
481
- const id = this.safeString(currency, 'ProductId');
482
- const code = this.safeCurrencyCode(this.safeString(currency, 'Product'));
483
- const ProductType = this.safeString(currency, 'ProductType');
484
- let type = (ProductType === 'NationalCurrency') ? 'fiat' : 'crypto';
485
- if (ProductType === 'Unknown') {
486
- // such currency is just a blanket entry
487
- type = 'other';
488
- }
489
- result[code] = this.safeCurrencyStructure({
490
- 'id': id,
491
- 'name': this.safeString(currency, 'ProductFullName'),
492
- 'code': code,
493
- 'type': type,
494
- 'precision': this.safeNumber(currency, 'TickSize'),
495
- 'info': currency,
496
- 'active': !this.safeBool(currency, 'IsDisabled'),
497
- 'deposit': this.safeBool(currency, 'DepositEnabled'),
498
- 'withdraw': this.safeBool(currency, 'WithdrawEnabled'),
499
- 'fee': undefined,
500
- 'limits': {
501
- 'amount': {
502
- 'min': undefined,
503
- 'max': undefined,
504
- },
505
- 'withdraw': {
506
- 'min': undefined,
507
- 'max': undefined,
508
- },
509
- },
510
- 'networks': {},
511
- 'margin': this.safeBool(currency, 'MarginEnabled'),
512
- });
478
+ return this.parseCurrencies(response);
479
+ }
480
+ parseCurrency(rawCurrency) {
481
+ const id = this.safeString(rawCurrency, 'ProductId');
482
+ const code = this.safeCurrencyCode(this.safeString(rawCurrency, 'Product'));
483
+ const ProductType = this.safeString(rawCurrency, 'ProductType');
484
+ let type = (ProductType === 'NationalCurrency') ? 'fiat' : 'crypto';
485
+ if (ProductType === 'Unknown') {
486
+ // such currency is just a blanket entry
487
+ type = 'other';
513
488
  }
514
- return result;
489
+ return this.safeCurrencyStructure({
490
+ 'id': id,
491
+ 'name': this.safeString(rawCurrency, 'ProductFullName'),
492
+ 'code': code,
493
+ 'type': type,
494
+ 'precision': this.safeNumber(rawCurrency, 'TickSize'),
495
+ 'info': rawCurrency,
496
+ 'active': !this.safeBool(rawCurrency, 'IsDisabled'),
497
+ 'deposit': this.safeBool(rawCurrency, 'DepositEnabled'),
498
+ 'withdraw': this.safeBool(rawCurrency, 'WithdrawEnabled'),
499
+ 'fee': undefined,
500
+ 'limits': {
501
+ 'amount': {
502
+ 'min': undefined,
503
+ 'max': undefined,
504
+ },
505
+ 'withdraw': {
506
+ 'min': undefined,
507
+ 'max': undefined,
508
+ },
509
+ },
510
+ 'networks': {},
511
+ 'margin': this.safeBool(rawCurrency, 'MarginEnabled'),
512
+ });
515
513
  }
516
514
  /**
517
515
  * @method
@@ -661,7 +659,7 @@ export default class ndax extends Exchange {
661
659
  const newNonce = this.safeInteger(level, 0);
662
660
  nonce = Math.max(nonce, newNonce);
663
661
  }
664
- const bidask = this.parseBidAsk(level, priceKey, amountKey);
662
+ const bidask = this.parseOrderBookBidAsk(level, priceKey, amountKey);
665
663
  const levelSide = this.safeInteger(level, 9);
666
664
  const side = levelSide ? asksKey : bidsKey;
667
665
  const resultSide = result[side];
package/js/src/okx.js CHANGED
@@ -1512,7 +1512,18 @@ export default class okx extends Exchange {
1512
1512
  };
1513
1513
  }
1514
1514
  safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
1515
- const isOption = (marketId !== undefined) && ((marketId.indexOf('-C') > -1) || (marketId.indexOf('-P') > -1));
1515
+ let isOption = false;
1516
+ if (marketId !== undefined) {
1517
+ const parts = marketId.split('-');
1518
+ const partsLength = parts.length;
1519
+ // a valid OKX option ends with the call/put flag and carries expiry+strike segments,
1520
+ // e.g. the market id BTC-USD-220325-194000-P (5 parts) or the unified symbol
1521
+ // BTC/USD:USD-260611-54000-C (4 parts). Requiring more than 3 dash-separated parts avoids
1522
+ // misclassifying ordinary ids that merely contain "-C"/"-P" (such as a SPOT id like
1523
+ // "PERFTESTA-PERFTESTB") as expired options, which would crash createExpiredOptionMarket
1524
+ // on the missing expiry.
1525
+ isOption = (partsLength > 3) && (marketId.endsWith('-C') || marketId.endsWith('-P'));
1526
+ }
1516
1527
  if (isOption && !(marketId in this.markets_by_id)) {
1517
1528
  // handle expired option contracts
1518
1529
  return this.createExpiredOptionMarket(marketId);
@@ -1933,6 +1944,10 @@ export default class okx extends Exchange {
1933
1944
  const marketsWithoutTest = [];
1934
1945
  for (let i = 0; i < dataResponse.length; i++) {
1935
1946
  const data = dataResponse[i];
1947
+ const instId = this.safeString(data, 'instId', '');
1948
+ if (instId === '') {
1949
+ continue; // skip broken "preopen" placeholder instruments that have no instId
1950
+ }
1936
1951
  if (this.isSandboxModeEnabled) {
1937
1952
  const instFamily = this.safeString(data, 'instFamily', '');
1938
1953
  if (instFamily.startsWith('TEST')) {
@@ -9203,7 +9218,7 @@ export default class okx extends Exchange {
9203
9218
  request['end'] = until;
9204
9219
  }
9205
9220
  if (timeframe !== undefined) {
9206
- request['period'] = timeframe;
9221
+ request['period'] = this.safeString(this.timeframes, timeframe, timeframe);
9207
9222
  }
9208
9223
  if (since !== undefined) {
9209
9224
  request['begin'] = since;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/onetrading.js';
2
- import type { Balances, Currencies, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, int } from './base/types.js';
2
+ import type { Balances, Currencies, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, int } from './base/types.js';
3
3
  /**
4
4
  * @class onetrading
5
5
  * @augments Exchange
@@ -24,6 +24,7 @@ export default class onetrading extends Exchange {
24
24
  * @returns {object} 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 onetrading#fetchMarkets
@@ -430,29 +430,27 @@ export default class onetrading extends Exchange {
430
430
  // },
431
431
  // ]
432
432
  //
433
- const result = {};
434
- for (let i = 0; i < response.length; i++) {
435
- const currency = response[i];
436
- const id = this.safeString(currency, 'code');
437
- const code = this.safeCurrencyCode(id);
438
- result[code] = this.safeCurrencyStructure({
439
- 'id': id,
440
- 'code': code,
441
- 'name': this.safeString(currency, 'name'),
442
- 'info': currency,
443
- 'active': undefined,
444
- 'fee': undefined,
445
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'precision'))),
446
- 'withdraw': undefined,
447
- 'deposit': undefined,
448
- 'limits': {
449
- 'amount': { 'min': undefined, 'max': undefined },
450
- 'withdraw': { 'min': undefined, 'max': undefined },
451
- },
452
- 'networks': {},
453
- });
454
- }
455
- return result;
433
+ return this.parseCurrencies(response);
434
+ }
435
+ parseCurrency(rawCurrency) {
436
+ const id = this.safeString(rawCurrency, 'code');
437
+ const code = this.safeCurrencyCode(id);
438
+ return this.safeCurrencyStructure({
439
+ 'id': id,
440
+ 'code': code,
441
+ 'name': this.safeString(rawCurrency, 'name'),
442
+ 'info': rawCurrency,
443
+ 'active': undefined,
444
+ 'fee': undefined,
445
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(rawCurrency, 'precision'))),
446
+ 'withdraw': undefined,
447
+ 'deposit': undefined,
448
+ 'limits': {
449
+ 'amount': { 'min': undefined, 'max': undefined },
450
+ 'withdraw': { 'min': undefined, 'max': undefined },
451
+ },
452
+ 'networks': {},
453
+ });
456
454
  }
457
455
  /**
458
456
  * @method
@@ -26,6 +26,7 @@ export default class phemex extends Exchange {
26
26
  * @returns {object} an associative dictionary of currencies
27
27
  */
28
28
  fetchCurrencies(params?: {}): Promise<Currencies>;
29
+ parseCurrency(rawCurrency: Dict): Currency;
29
30
  customParseBidAsk(bidask: any, priceKey?: number, amountKey?: number, market?: Market): number[];
30
31
  customParseOrderBook(orderbook: any, symbol: any, timestamp?: any, bidsKey?: string, asksKey?: string, priceKey?: number, amountKey?: number, market?: Market): any;
31
32
  /**
package/js/src/phemex.js CHANGED
@@ -1139,50 +1139,48 @@ export default class phemex extends Exchange {
1139
1139
  // }
1140
1140
  const data = this.safeValue(response, 'data', {});
1141
1141
  const currencies = this.safeValue(data, 'currencies', []);
1142
- const result = {};
1143
- for (let i = 0; i < currencies.length; i++) {
1144
- const currency = currencies[i];
1145
- const id = this.safeString(currency, 'currency');
1146
- const code = this.safeCurrencyCode(id);
1147
- const valueScaleString = this.safeString(currency, 'valueScale');
1148
- const valueScale = parseInt(valueScaleString);
1149
- const minValueEv = this.safeString(currency, 'minValueEv');
1150
- const maxValueEv = this.safeString(currency, 'maxValueEv');
1151
- let minAmount = undefined;
1152
- let maxAmount = undefined;
1153
- let precision = undefined;
1154
- if (valueScale !== undefined) {
1155
- const precisionString = this.parsePrecision(valueScaleString);
1156
- precision = this.parseNumber(precisionString);
1157
- minAmount = this.parseNumber(Precise.stringMul(minValueEv, precisionString));
1158
- maxAmount = this.parseNumber(Precise.stringMul(maxValueEv, precisionString));
1159
- }
1160
- result[code] = this.safeCurrencyStructure({
1161
- 'id': id,
1162
- 'info': currency,
1163
- 'code': code,
1164
- 'name': this.safeString(currency, 'name'),
1165
- 'active': this.safeString(currency, 'status') === 'Listed',
1166
- 'deposit': undefined,
1167
- 'withdraw': undefined,
1168
- 'fee': undefined,
1169
- 'precision': precision,
1170
- 'limits': {
1171
- 'amount': {
1172
- 'min': minAmount,
1173
- 'max': maxAmount,
1174
- },
1175
- 'withdraw': {
1176
- 'min': undefined,
1177
- 'max': undefined,
1178
- },
1142
+ return this.parseCurrencies(currencies);
1143
+ }
1144
+ parseCurrency(rawCurrency) {
1145
+ const id = this.safeString(rawCurrency, 'currency');
1146
+ const code = this.safeCurrencyCode(id);
1147
+ const valueScaleString = this.safeString(rawCurrency, 'valueScale');
1148
+ const valueScale = parseInt(valueScaleString);
1149
+ const minValueEv = this.safeString(rawCurrency, 'minValueEv');
1150
+ const maxValueEv = this.safeString(rawCurrency, 'maxValueEv');
1151
+ let minAmount = undefined;
1152
+ let maxAmount = undefined;
1153
+ let precision = undefined;
1154
+ if (valueScale !== undefined) {
1155
+ const precisionString = this.parsePrecision(valueScaleString);
1156
+ precision = this.parseNumber(precisionString);
1157
+ minAmount = this.parseNumber(Precise.stringMul(minValueEv, precisionString));
1158
+ maxAmount = this.parseNumber(Precise.stringMul(maxValueEv, precisionString));
1159
+ }
1160
+ return this.safeCurrencyStructure({
1161
+ 'id': id,
1162
+ 'info': rawCurrency,
1163
+ 'code': code,
1164
+ 'name': this.safeString(rawCurrency, 'name'),
1165
+ 'active': this.safeString(rawCurrency, 'status') === 'Listed',
1166
+ 'deposit': undefined,
1167
+ 'withdraw': undefined,
1168
+ 'fee': undefined,
1169
+ 'precision': precision,
1170
+ 'limits': {
1171
+ 'amount': {
1172
+ 'min': minAmount,
1173
+ 'max': maxAmount,
1179
1174
  },
1180
- 'valueScale': valueScale,
1181
- 'networks': undefined,
1182
- 'type': 'crypto',
1183
- });
1184
- }
1185
- return result;
1175
+ 'withdraw': {
1176
+ 'min': undefined,
1177
+ 'max': undefined,
1178
+ },
1179
+ },
1180
+ 'valueScale': valueScale,
1181
+ 'networks': undefined,
1182
+ 'type': 'crypto',
1183
+ });
1186
1184
  }
1187
1185
  customParseBidAsk(bidask, priceKey = 0, amountKey = 1, market = undefined) {
1188
1186
  if (market === undefined) {
@@ -3806,7 +3804,7 @@ export default class phemex extends Exchange {
3806
3804
  'txid': txid,
3807
3805
  'timestamp': timestamp,
3808
3806
  'datetime': this.iso8601(timestamp),
3809
- 'network': this.networkIdToCode(networkId),
3807
+ 'network': this.networkIdToCode(networkId, code),
3810
3808
  'address': address,
3811
3809
  'addressTo': address,
3812
3810
  'addressFrom': undefined,
@@ -5079,7 +5077,7 @@ export default class phemex extends Exchange {
5079
5077
  [networkCode, params] = this.handleNetworkCodeAndParams(params);
5080
5078
  let networkId = undefined;
5081
5079
  if (networkCode !== undefined) {
5082
- networkId = this.networkCodeToId(networkCode);
5080
+ networkId = this.networkCodeToId(networkCode, code);
5083
5081
  }
5084
5082
  const stableCoins = this.safeValue(this.options, 'stableCoins');
5085
5083
  if (networkId === undefined) {