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/binance.js CHANGED
@@ -1642,7 +1642,7 @@ export default class binance extends Exchange {
1642
1642
  'symbolRequired': true,
1643
1643
  },
1644
1644
  'fetchOHLCV': {
1645
- 'limit': 1500,
1645
+ 'limit': 500,
1646
1646
  },
1647
1647
  },
1648
1648
  'swap': {
@@ -2958,206 +2958,204 @@ export default class binance extends Exchange {
2958
2958
  const responseMarginables = results[1];
2959
2959
  marginablesById = this.indexBy(responseMarginables, 'assetName');
2960
2960
  }
2961
+ return this.parseCurrenciesCustom(responseCurrencies, marginablesById);
2962
+ }
2963
+ parseCurrenciesCustom(responseCurrencies, marginablesById) {
2961
2964
  const result = {};
2962
2965
  for (let i = 0; i < responseCurrencies.length; i++) {
2963
- //
2964
- // {
2965
- // "coin": "LINK",
2966
- // "depositAllEnable": true,
2967
- // "withdrawAllEnable": true,
2968
- // "name": "ChainLink",
2969
- // "free": "0",
2970
- // "locked": "0",
2971
- // "freeze": "0",
2972
- // "withdrawing": "0",
2973
- // "ipoing": "0",
2974
- // "ipoable": "0",
2975
- // "storage": "0",
2976
- // "isLegalMoney": false,
2977
- // "trading": true,
2978
- // "networkList": [
2979
- // {
2980
- // "network": "BSC",
2981
- // "coin": "LINK",
2982
- // "withdrawIntegerMultiple": "0.00000001",
2983
- // "isDefault": false,
2984
- // "depositEnable": true,
2985
- // "withdrawEnable": true,
2986
- // "depositDesc": "",
2987
- // "withdrawDesc": "",
2988
- // "specialTips": "",
2989
- // "specialWithdrawTips": "The network you have selected is BSC. Please ensure that the withdrawal address supports the Binance Smart Chain network. You will lose your assets if the chosen platform does not support retrievals.",
2990
- // "name": "BNB Smart Chain (BEP20)",
2991
- // "resetAddressStatus": false,
2992
- // "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
2993
- // "addressRule": "",
2994
- // "memoRegex": "",
2995
- // "withdrawFee": "0.012",
2996
- // "withdrawMin": "0.024",
2997
- // "withdrawMax": "9999999999.99999999",
2998
- // "minConfirm": "15",
2999
- // "unLockConfirm": "0",
3000
- // "sameAddress": false,
3001
- // "estimatedArrivalTime": "5",
3002
- // "busy": false,
3003
- // "country": "AE,BINANCE_BAHRAIN_BSC"
3004
- // },
3005
- // {
3006
- // "network": "BNB",
3007
- // "coin": "LINK",
3008
- // "withdrawIntegerMultiple": "0.00000001",
3009
- // "isDefault": false,
3010
- // "depositEnable": true,
3011
- // "withdrawEnable": true,
3012
- // "depositDesc": "",
3013
- // "withdrawDesc": "",
3014
- // "specialTips": "Both a MEMO and an Address are required to successfully deposit your LINK BEP2 tokens to Binance.",
3015
- // "specialWithdrawTips": "",
3016
- // "name": "BNB Beacon Chain (BEP2)",
3017
- // "resetAddressStatus": false,
3018
- // "addressRegex": "^(bnb1)[0-9a-z]{38}$",
3019
- // "addressRule": "",
3020
- // "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
3021
- // "withdrawFee": "0.003",
3022
- // "withdrawMin": "0.01",
3023
- // "withdrawMax": "10000000000",
3024
- // "minConfirm": "1",
3025
- // "unLockConfirm": "0",
3026
- // "sameAddress": true,
3027
- // "estimatedArrivalTime": "5",
3028
- // "busy": false,
3029
- // "country": "AE,BINANCE_BAHRAIN_BSC"
3030
- // },
3031
- // {
3032
- // "network": "ETH",
3033
- // "coin": "LINK",
3034
- // "withdrawIntegerMultiple": "0.00000001",
3035
- // "isDefault": true,
3036
- // "depositEnable": true,
3037
- // "withdrawEnable": true,
3038
- // "depositDesc": "",
3039
- // "withdrawDesc": "",
3040
- // "name": "Ethereum (ERC20)",
3041
- // "resetAddressStatus": false,
3042
- // "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
3043
- // "addressRule": "",
3044
- // "memoRegex": "",
3045
- // "withdrawFee": "0.55",
3046
- // "withdrawMin": "1.1",
3047
- // "withdrawMax": "10000000000",
3048
- // "minConfirm": "12",
3049
- // "unLockConfirm": "0",
3050
- // "sameAddress": false,
3051
- // "estimatedArrivalTime": "5",
3052
- // "busy": false,
3053
- // "country": "AE,BINANCE_BAHRAIN_BSC"
3054
- // }
3055
- // ]
3056
- // }
3057
- //
3058
- // some coins (e.g. ETH, BIGTIME, SONIC, etc) return extra fields under network entry
3059
- //
3060
- // "specialTips": "",
3061
- // "specialWithdrawTips": "",
3062
- // "withdrawInternalMin": "0",
3063
- // "contractAddressUrl": "https://etherscan.io/address/",
3064
- // "contractAddress": "0x64bc2ca1be492be7185faa2c8835d9b824c8a194"
3065
- //
3066
- const entry = responseCurrencies[i];
3067
- const id = this.safeString(entry, 'coin');
3068
- const name = this.safeString(entry, 'name');
3069
- const code = this.safeCurrencyCode(id);
3070
- const isFiat = this.safeBool(entry, 'isLegalMoney');
3071
- const networkList = this.safeList(entry, 'networkList', []);
3072
- const fees = {};
3073
- let fee = undefined;
3074
- const networks = {};
3075
- let isETF = false;
3076
- for (let j = 0; j < networkList.length; j++) {
3077
- const networkItem = networkList[j];
3078
- const network = this.safeString(networkItem, 'network');
3079
- const networkCode = this.networkIdToCode(network, code);
3080
- isETF = (network === 'ETF'); // ETF currencies (e.g. BTCUP, ETHDOWN) have only 1 "network" entry and are deterministic to set
3081
- // const name = this.safeString (networkItem, 'name');
3082
- const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
3083
- const depositEnable = this.safeBool(networkItem, 'depositEnable');
3084
- const withdrawEnable = this.safeBool(networkItem, 'withdrawEnable');
3085
- fees[network] = withdrawFee;
3086
- const isDefault = this.safeBool(networkItem, 'isDefault');
3087
- if (isDefault || (fee === undefined)) {
3088
- fee = withdrawFee;
3089
- }
3090
- // todo: default networks in "setMarkets" overload
3091
- // if (isDefault) {
3092
- // this.options['defaultNetworkCodesForCurrencies'][code] = networkCode;
3093
- // }
3094
- let withdrawPrecision = this.omitZero(this.safeString2(networkItem, 'withdrawIntegerMultiple', 'withdrawInternalMin'));
3095
- // zero values happen only on fiat or leveraged(ETF) tokens: https://t.me/binance_api_english/393075
3096
- if (withdrawPrecision === undefined && isFiat) {
3097
- withdrawPrecision = this.safeString(this.options, 'defaultFiatWithdrawPrecision');
3098
- }
3099
- networks[networkCode] = {
3100
- 'info': networkItem,
3101
- 'id': network,
3102
- 'network': networkCode,
3103
- 'active': undefined,
3104
- 'deposit': depositEnable,
3105
- 'withdraw': withdrawEnable,
3106
- 'fee': withdrawFee,
3107
- 'precision': this.parseNumber(withdrawPrecision),
3108
- 'limits': {
3109
- 'withdraw': {
3110
- 'min': this.safeNumber(networkItem, 'withdrawMin'),
3111
- 'max': this.safeNumber(networkItem, 'withdrawMax'),
3112
- },
3113
- 'deposit': {
3114
- 'min': this.safeNumber(networkItem, 'depositDust'),
3115
- 'max': undefined,
3116
- },
3117
- },
3118
- };
3119
- }
3120
- let type = undefined;
3121
- if (isETF) {
3122
- type = 'other';
3123
- }
3124
- else if (isFiat) {
3125
- type = 'fiat';
3126
- }
3127
- else {
3128
- type = 'crypto';
3129
- }
3130
- const trading = this.safeBool(entry, 'trading');
3131
- const marginEntry = this.safeDict(marginablesById, id, {});
3132
- //
3133
- // {
3134
- // assetName: "BTC",
3135
- // assetFullName: "Bitcoin",
3136
- // isBorrowable: true,
3137
- // isMortgageable: true,
3138
- // userMinBorrow: "0",
3139
- // userMinRepay: "0",
3140
- // }
3141
- //
3142
- result[code] = this.safeCurrencyStructure({
3143
- 'id': id,
3144
- 'name': name,
3145
- 'code': code,
3146
- 'type': type,
3147
- 'precision': undefined,
3148
- 'info': entry,
3149
- 'active': trading,
3150
- 'deposit': undefined,
3151
- 'withdraw': undefined,
3152
- 'networks': networks,
3153
- 'fee': undefined,
3154
- 'fees': fees,
3155
- 'limits': undefined,
3156
- 'margin': this.safeBool(marginEntry, 'isBorrowable'),
3157
- });
2966
+ const parsed = this.parseCurrency(responseCurrencies[i]);
2967
+ const code = parsed['code'];
2968
+ const marginEntry = this.safeDict(marginablesById, parsed['id']);
2969
+ parsed['margin'] = this.safeBool(marginEntry, 'isBorrowable');
2970
+ result[code] = parsed;
3158
2971
  }
3159
2972
  return result;
3160
2973
  }
2974
+ parseCurrency(rawCurrency) {
2975
+ //
2976
+ // {
2977
+ // "coin": "LINK",
2978
+ // "depositAllEnable": true,
2979
+ // "withdrawAllEnable": true,
2980
+ // "name": "ChainLink",
2981
+ // "free": "0",
2982
+ // "locked": "0",
2983
+ // "freeze": "0",
2984
+ // "withdrawing": "0",
2985
+ // "ipoing": "0",
2986
+ // "ipoable": "0",
2987
+ // "storage": "0",
2988
+ // "isLegalMoney": false,
2989
+ // "trading": true,
2990
+ // "networkList": [
2991
+ // {
2992
+ // "network": "BSC",
2993
+ // "coin": "LINK",
2994
+ // "withdrawIntegerMultiple": "0.00000001",
2995
+ // "isDefault": false,
2996
+ // "depositEnable": true,
2997
+ // "withdrawEnable": true,
2998
+ // "depositDesc": "",
2999
+ // "withdrawDesc": "",
3000
+ // "specialTips": "",
3001
+ // "specialWithdrawTips": "The network you have selected is BSC. Please ensure that the withdrawal address supports the Binance Smart Chain network. You will lose your assets if the chosen platform does not support retrievals.",
3002
+ // "name": "BNB Smart Chain (BEP20)",
3003
+ // "resetAddressStatus": false,
3004
+ // "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
3005
+ // "addressRule": "",
3006
+ // "memoRegex": "",
3007
+ // "withdrawFee": "0.012",
3008
+ // "withdrawMin": "0.024",
3009
+ // "withdrawMax": "9999999999.99999999",
3010
+ // "minConfirm": "15",
3011
+ // "unLockConfirm": "0",
3012
+ // "sameAddress": false,
3013
+ // "estimatedArrivalTime": "5",
3014
+ // "busy": false,
3015
+ // "country": "AE,BINANCE_BAHRAIN_BSC"
3016
+ // },
3017
+ // {
3018
+ // "network": "BNB",
3019
+ // "coin": "LINK",
3020
+ // "withdrawIntegerMultiple": "0.00000001",
3021
+ // "isDefault": false,
3022
+ // "depositEnable": true,
3023
+ // "withdrawEnable": true,
3024
+ // "depositDesc": "",
3025
+ // "withdrawDesc": "",
3026
+ // "specialTips": "Both a MEMO and an Address are required to successfully deposit your LINK BEP2 tokens to Binance.",
3027
+ // "specialWithdrawTips": "",
3028
+ // "name": "BNB Beacon Chain (BEP2)",
3029
+ // "resetAddressStatus": false,
3030
+ // "addressRegex": "^(bnb1)[0-9a-z]{38}$",
3031
+ // "addressRule": "",
3032
+ // "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
3033
+ // "withdrawFee": "0.003",
3034
+ // "withdrawMin": "0.01",
3035
+ // "withdrawMax": "10000000000",
3036
+ // "minConfirm": "1",
3037
+ // "unLockConfirm": "0",
3038
+ // "sameAddress": true,
3039
+ // "estimatedArrivalTime": "5",
3040
+ // "busy": false,
3041
+ // "country": "AE,BINANCE_BAHRAIN_BSC"
3042
+ // },
3043
+ // {
3044
+ // "network": "ETH",
3045
+ // "coin": "LINK",
3046
+ // "withdrawIntegerMultiple": "0.00000001",
3047
+ // "isDefault": true,
3048
+ // "depositEnable": true,
3049
+ // "withdrawEnable": true,
3050
+ // "depositDesc": "",
3051
+ // "withdrawDesc": "",
3052
+ // "name": "Ethereum (ERC20)",
3053
+ // "resetAddressStatus": false,
3054
+ // "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
3055
+ // "addressRule": "",
3056
+ // "memoRegex": "",
3057
+ // "withdrawFee": "0.55",
3058
+ // "withdrawMin": "1.1",
3059
+ // "withdrawMax": "10000000000",
3060
+ // "minConfirm": "12",
3061
+ // "unLockConfirm": "0",
3062
+ // "sameAddress": false,
3063
+ // "estimatedArrivalTime": "5",
3064
+ // "busy": false,
3065
+ // "country": "AE,BINANCE_BAHRAIN_BSC"
3066
+ // }
3067
+ // ]
3068
+ // }
3069
+ //
3070
+ // some coins (e.g. ETH, BIGTIME, SONIC, etc) return extra fields under network entry
3071
+ //
3072
+ // "specialTips": "",
3073
+ // "specialWithdrawTips": "",
3074
+ // "withdrawInternalMin": "0",
3075
+ // "contractAddressUrl": "https://etherscan.io/address/",
3076
+ // "contractAddress": "0x64bc2ca1be492be7185faa2c8835d9b824c8a194"
3077
+ //
3078
+ const entry = rawCurrency;
3079
+ const id = this.safeString(entry, 'coin');
3080
+ const name = this.safeString(entry, 'name');
3081
+ const code = this.safeCurrencyCode(id);
3082
+ const isFiat = this.safeBool(entry, 'isLegalMoney');
3083
+ const networkList = this.safeList(entry, 'networkList', []);
3084
+ const fees = {};
3085
+ let fee = undefined;
3086
+ const networks = {};
3087
+ let isETF = false;
3088
+ for (let j = 0; j < networkList.length; j++) {
3089
+ const networkItem = networkList[j];
3090
+ const network = this.safeString(networkItem, 'network');
3091
+ const networkCode = this.networkIdToCode(network, code);
3092
+ isETF = (network === 'ETF'); // ETF currencies (e.g. BTCUP, ETHDOWN) have only 1 "network" entry and are deterministic to set
3093
+ // const name = this.safeString (networkItem, 'name');
3094
+ const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
3095
+ const depositEnable = this.safeBool(networkItem, 'depositEnable');
3096
+ const withdrawEnable = this.safeBool(networkItem, 'withdrawEnable');
3097
+ fees[network] = withdrawFee;
3098
+ const isDefault = this.safeBool(networkItem, 'isDefault');
3099
+ if (isDefault || (fee === undefined)) {
3100
+ fee = withdrawFee;
3101
+ }
3102
+ // todo: default networks in "setMarkets" overload
3103
+ // if (isDefault) {
3104
+ // this.options['defaultNetworkCodesForCurrencies'][code] = networkCode;
3105
+ // }
3106
+ let withdrawPrecision = this.omitZero(this.safeString2(networkItem, 'withdrawIntegerMultiple', 'withdrawInternalMin'));
3107
+ // zero values happen only on fiat or leveraged(ETF) tokens: https://t.me/binance_api_english/393075
3108
+ if (withdrawPrecision === undefined && isFiat) {
3109
+ withdrawPrecision = this.safeString(this.options, 'defaultFiatWithdrawPrecision');
3110
+ }
3111
+ networks[networkCode] = {
3112
+ 'info': networkItem,
3113
+ 'id': network,
3114
+ 'network': networkCode,
3115
+ 'active': undefined,
3116
+ 'deposit': depositEnable,
3117
+ 'withdraw': withdrawEnable,
3118
+ 'fee': withdrawFee,
3119
+ 'precision': this.parseNumber(withdrawPrecision),
3120
+ 'limits': {
3121
+ 'withdraw': {
3122
+ 'min': this.safeNumber(networkItem, 'withdrawMin'),
3123
+ 'max': this.safeNumber(networkItem, 'withdrawMax'),
3124
+ },
3125
+ 'deposit': {
3126
+ 'min': this.safeNumber(networkItem, 'depositDust'),
3127
+ 'max': undefined,
3128
+ },
3129
+ },
3130
+ };
3131
+ }
3132
+ let type = undefined;
3133
+ if (isETF) {
3134
+ type = 'other';
3135
+ }
3136
+ else if (isFiat) {
3137
+ type = 'fiat';
3138
+ }
3139
+ else {
3140
+ type = 'crypto';
3141
+ }
3142
+ const trading = this.safeBool(entry, 'trading');
3143
+ return this.safeCurrencyStructure({
3144
+ 'id': id,
3145
+ 'name': name,
3146
+ 'code': code,
3147
+ 'type': type,
3148
+ 'precision': undefined,
3149
+ 'info': entry,
3150
+ 'active': trading,
3151
+ 'deposit': undefined,
3152
+ 'withdraw': undefined,
3153
+ 'networks': networks,
3154
+ 'fee': undefined,
3155
+ 'fees': fees,
3156
+ 'limits': undefined,
3157
+ });
3158
+ }
3161
3159
  /**
3162
3160
  * @method
3163
3161
  * @name binance#fetchMarkets
@@ -4156,7 +4154,7 @@ export default class binance extends Exchange {
4156
4154
  //
4157
4155
  // {
4158
4156
  // "symbol": "BTCUSDT",
4159
- // "markPrice": "11793.63104562", // mark price
4157
+ // "markPrice": "11793.63104563", // mark price
4160
4158
  // "indexPrice": "11781.80495970", // index price
4161
4159
  // "estimatedSettlePrice": "11781.16138815", // Estimated Settle Price, only useful in the last hour before the settlement starts
4162
4160
  // "lastFundingRate": "0.00038246", // This is the lastest estimated funding rate
@@ -10522,7 +10520,7 @@ export default class binance extends Exchange {
10522
10520
  const rounderString = rounder.toString();
10523
10521
  const liquidationPriceRoundedString = Precise.stringAdd(rounderString, liquidationPriceStringRaw);
10524
10522
  let truncatedLiquidationPrice = Precise.stringDiv(liquidationPriceRoundedString, '1', pricePrecision);
10525
- if (truncatedLiquidationPrice[0] === '-') {
10523
+ if (truncatedLiquidationPrice !== undefined && truncatedLiquidationPrice[0] === '-') {
10526
10524
  // user cannot be liquidated
10527
10525
  // since he has more collateral than the size of the position
10528
10526
  truncatedLiquidationPrice = undefined;
package/js/src/bingx.js CHANGED
@@ -875,7 +875,7 @@ export default class bingx extends Exchange {
875
875
  for (let j = 0; j < networkList.length; j++) {
876
876
  const rawNetwork = networkList[j];
877
877
  const network = this.safeString(rawNetwork, 'network');
878
- const networkCode = this.networkIdToCode(network);
878
+ const networkCode = this.networkIdToCode(network, code);
879
879
  const limits = {
880
880
  'withdraw': {
881
881
  'min': this.safeNumber(rawNetwork, 'withdrawMin'),
@@ -5502,7 +5502,7 @@ export default class bingx extends Exchange {
5502
5502
  'txid': this.safeString(transaction, 'txId'),
5503
5503
  'type': type,
5504
5504
  'currency': code,
5505
- 'network': this.networkIdToCode(network),
5505
+ 'network': this.networkIdToCode(network, code),
5506
5506
  'amount': this.safeNumber(transaction, 'amount'),
5507
5507
  'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
5508
5508
  'timestamp': timestamp,
@@ -6053,7 +6053,7 @@ export default class bingx extends Exchange {
6053
6053
  };
6054
6054
  const network = this.safeStringUpper(params, 'network');
6055
6055
  if (network !== undefined) {
6056
- request['network'] = this.networkCodeToId(network);
6056
+ request['network'] = this.networkCodeToId(network, currency['code']);
6057
6057
  }
6058
6058
  if (tag !== undefined) {
6059
6059
  request['addressTag'] = tag;
@@ -43,6 +43,8 @@ export default class bitfinex extends Exchange {
43
43
  * @returns {object} an associative dictionary of currencies
44
44
  */
45
45
  fetchCurrencies(params?: {}): Promise<Currencies>;
46
+ parseCurrenciesCustom(ids: any, indexed: any, indexedNetworks: any): {};
47
+ parseCurrencyCustom(id: any, indexed: any, indexedNetworks: any): Currency;
46
48
  /**
47
49
  * @method
48
50
  * @name bitfinex#fetchBalance
@@ -846,74 +846,87 @@ export default class bitfinex extends Exchange {
846
846
  indexedNetworks[networkName] = networksList;
847
847
  }
848
848
  const ids = this.safeList(response, 0, []);
849
- const result = {};
849
+ return this.parseCurrenciesCustom(ids, indexed, indexedNetworks);
850
+ }
851
+ parseCurrenciesCustom(ids, indexed, indexedNetworks) {
852
+ const allowedIds = [];
850
853
  for (let i = 0; i < ids.length; i++) {
851
854
  const id = ids[i];
852
855
  if (id.endsWith('F0')) {
853
856
  // we get a lot of F0 currencies, skip those
854
857
  continue;
855
858
  }
856
- const code = this.safeCurrencyCode(id);
857
- const label = this.safeList(indexed['label'], id, []);
858
- const name = this.safeString(label, 1);
859
- const pool = this.safeList(indexed['pool'], id, []);
860
- const rawType = this.safeString(pool, 1);
861
- const isCryptoCoin = (rawType !== undefined) || (id in indexed['explorer']); // "hacky" solution
862
- const type = isCryptoCoin ? 'crypto' : undefined;
863
- const feeValues = this.safeList(indexed['fees'], id, []);
864
- const fees = this.safeList(feeValues, 1, []);
865
- const fee = this.safeNumber(fees, 1);
866
- const undl = this.safeList(indexed['undl'], id, []);
867
- const precision = this.safeString(this.options, 'defaultCurrencyPrecision', '8');
868
- const networks = {};
869
- const netwokIds = this.safeList(indexedNetworks, id, []);
870
- for (let j = 0; j < netwokIds.length; j++) {
871
- const networkId = netwokIds[j];
872
- const network = this.networkIdToCode(networkId);
873
- const dwStatuses = this.safeList(indexed['statuses'], networkId, []);
874
- networks[network] = {
875
- 'info': networkId,
876
- 'id': networkId.toLowerCase(),
877
- 'network': networkId,
878
- 'active': undefined,
879
- 'deposit': this.safeInteger(dwStatuses, 1) === 1,
880
- 'withdraw': this.safeInteger(dwStatuses, 2) === 1,
881
- 'fee': undefined,
882
- 'precision': undefined,
883
- 'limits': {
884
- 'withdraw': {
885
- 'min': undefined,
886
- 'max': undefined,
887
- },
888
- },
889
- };
890
- }
891
- result[code] = this.safeCurrencyStructure({
892
- 'id': id,
893
- 'code': code,
894
- 'info': [id, label, pool, feeValues, undl],
895
- 'type': type,
896
- 'name': name,
897
- 'active': true,
898
- 'deposit': undefined,
899
- 'withdraw': undefined,
900
- 'fee': fee,
901
- 'precision': this.parseNumber(precision),
859
+ allowedIds.push(id);
860
+ }
861
+ const result = {};
862
+ const arr = this.toArray(allowedIds);
863
+ for (let i = 0; i < arr.length; i++) {
864
+ const parsed = this.parseCurrencyCustom(arr[i], indexed, indexedNetworks);
865
+ const code = parsed['code'];
866
+ result[code] = parsed;
867
+ }
868
+ return result;
869
+ }
870
+ parseCurrencyCustom(id, indexed, indexedNetworks) {
871
+ const code = this.safeCurrencyCode(id);
872
+ const label = this.safeList(indexed['label'], id, []);
873
+ const name = this.safeString(label, 1);
874
+ const pool = this.safeList(indexed['pool'], id, []);
875
+ const rawType = this.safeString(pool, 1);
876
+ const isCryptoCoin = (rawType !== undefined) || (id in indexed['explorer']); // "hacky" solution
877
+ const type = isCryptoCoin ? 'crypto' : undefined;
878
+ const feeValues = this.safeList(indexed['fees'], id, []);
879
+ const fees = this.safeList(feeValues, 1, []);
880
+ const fee = this.safeNumber(fees, 1);
881
+ const undl = this.safeList(indexed['undl'], id, []);
882
+ const precision = this.safeString(this.options, 'defaultCurrencyPrecision', '8');
883
+ const networks = {};
884
+ const networkIds = this.safeList(indexedNetworks, id, []);
885
+ for (let j = 0; j < networkIds.length; j++) {
886
+ const networkId = networkIds[j];
887
+ const network = this.networkIdToCode(networkId, code);
888
+ const dwStatuses = this.safeList(indexed['statuses'], networkId, []);
889
+ networks[network] = {
890
+ 'info': networkId,
891
+ 'id': networkId.toLowerCase(),
892
+ 'network': networkId,
893
+ 'active': undefined,
894
+ 'deposit': this.safeInteger(dwStatuses, 1) === 1,
895
+ 'withdraw': this.safeInteger(dwStatuses, 2) === 1,
896
+ 'fee': undefined,
897
+ 'precision': undefined,
902
898
  'limits': {
903
- 'amount': {
904
- 'min': undefined,
905
- 'max': undefined,
906
- },
907
899
  'withdraw': {
908
- 'min': fee,
900
+ 'min': undefined,
909
901
  'max': undefined,
910
902
  },
911
903
  },
912
- 'networks': networks,
913
- 'margin': this.inArray(id, indexed['marginables']),
914
- });
904
+ };
915
905
  }
916
- return result;
906
+ return this.safeCurrencyStructure({
907
+ 'id': id,
908
+ 'code': code,
909
+ 'info': [id, label, pool, feeValues, undl],
910
+ 'type': type,
911
+ 'name': name,
912
+ 'active': true,
913
+ 'deposit': undefined,
914
+ 'withdraw': undefined,
915
+ 'fee': fee,
916
+ 'precision': this.parseNumber(precision),
917
+ 'limits': {
918
+ 'amount': {
919
+ 'min': undefined,
920
+ 'max': undefined,
921
+ },
922
+ 'withdraw': {
923
+ 'min': fee,
924
+ 'max': undefined,
925
+ },
926
+ },
927
+ 'networks': networks,
928
+ 'margin': this.inArray(id, indexed['marginables']),
929
+ });
917
930
  }
918
931
  /**
919
932
  * @method
@@ -2482,14 +2495,14 @@ export default class bitfinex extends Exchange {
2482
2495
  tag = this.safeString(data, 3);
2483
2496
  type = 'withdrawal';
2484
2497
  const networkId = this.safeString(data, 2);
2485
- network = this.networkIdToCode(networkId.toUpperCase()); // withdraw returns in lowercase
2498
+ network = this.networkIdToCode(networkId.toUpperCase(), code); // withdraw returns in lowercase
2486
2499
  }
2487
2500
  else if (transactionLength === 22) {
2488
2501
  id = this.safeString(transaction, 0);
2489
2502
  const currencyId = this.safeString(transaction, 1);
2490
2503
  code = this.safeCurrencyCode(currencyId, currency);
2491
2504
  const networkId = this.safeString(transaction, 2);
2492
- network = this.networkIdToCode(networkId);
2505
+ network = this.networkIdToCode(networkId, code);
2493
2506
  timestamp = this.safeInteger(transaction, 5);
2494
2507
  updated = this.safeInteger(transaction, 6);
2495
2508
  status = this.parseTransactionStatus(this.safeString(transaction, 9));
package/js/src/bitget.js CHANGED
@@ -2891,7 +2891,7 @@ export default class bitget extends Exchange {
2891
2891
  }
2892
2892
  await this.loadMarkets();
2893
2893
  const currency = this.currency(code);
2894
- const networkId = this.networkCodeToId(networkCode);
2894
+ const networkId = this.networkCodeToId(networkCode, code);
2895
2895
  const request = {
2896
2896
  'coin': currency['id'],
2897
2897
  'address': address,
@@ -3060,7 +3060,7 @@ export default class bitget extends Exchange {
3060
3060
  'txid': this.safeString(transaction, 'tradeId'),
3061
3061
  'timestamp': timestamp,
3062
3062
  'datetime': this.iso8601(timestamp),
3063
- 'network': this.networkIdToCode(networkId),
3063
+ 'network': this.networkIdToCode(networkId, code),
3064
3064
  'addressFrom': this.safeString(transaction, 'fromAddress'),
3065
3065
  'address': this.safeString(transaction, 'toAddress'),
3066
3066
  'addressTo': this.safeString(transaction, 'toAddress'),