ccxt-ir 4.10.0 → 4.11.0

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 (1047) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +4 -1
  4. package/dist/cjs/src/abstract/bidarz.js +11 -0
  5. package/dist/cjs/src/bidarz.js +337 -0
  6. package/dist/cjs/src/bit24.js +4 -3
  7. package/js/ccxt.d.ts +5 -2
  8. package/js/ccxt.js +4 -2
  9. package/js/src/abstract/bidarz.d.ts +9 -0
  10. package/js/src/abstract/bidarz.js +11 -0
  11. package/js/src/bidarz.d.ts +22 -0
  12. package/js/src/bidarz.js +336 -0
  13. package/js/src/bit24.js +4 -3
  14. package/js/src/src/abantether.d.ts +21 -0
  15. package/js/src/src/abantether.js +353 -0
  16. package/js/src/src/abstract/abantether.d.ts +8 -0
  17. package/js/src/src/abstract/abantether.js +11 -0
  18. package/js/src/src/abstract/afratether.d.ts +9 -0
  19. package/js/src/src/abstract/afratether.js +11 -0
  20. package/js/src/src/abstract/alpaca.d.ts +77 -0
  21. package/js/src/src/abstract/alpaca.js +11 -0
  22. package/js/src/src/abstract/apex.d.ts +34 -0
  23. package/js/src/src/abstract/apex.js +11 -0
  24. package/js/src/src/abstract/arzinja.d.ts +8 -0
  25. package/js/src/src/abstract/arzinja.js +11 -0
  26. package/js/src/src/abstract/arzplus.d.ts +11 -0
  27. package/js/src/src/abstract/arzplus.js +11 -0
  28. package/js/src/src/abstract/ascendex.d.ts +80 -0
  29. package/js/src/src/abstract/ascendex.js +11 -0
  30. package/js/src/src/abstract/asretether.d.ts +8 -0
  31. package/js/src/src/abstract/asretether.js +11 -0
  32. package/js/src/src/abstract/bidarz.d.ts +9 -0
  33. package/js/src/src/abstract/bidarz.js +11 -0
  34. package/js/src/src/abstract/bigone.d.ts +48 -0
  35. package/js/src/src/abstract/bigone.js +11 -0
  36. package/js/src/src/abstract/binance.d.ts +773 -0
  37. package/js/src/src/abstract/binance.js +11 -0
  38. package/js/src/src/abstract/bingx.d.ts +165 -0
  39. package/js/src/src/abstract/bingx.js +11 -0
  40. package/js/src/src/abstract/bit24.d.ts +9 -0
  41. package/js/src/src/abstract/bit24.js +11 -0
  42. package/js/src/src/abstract/bit2c.d.ts +30 -0
  43. package/js/src/src/abstract/bit2c.js +11 -0
  44. package/js/src/src/abstract/bitbank.d.ts +35 -0
  45. package/js/src/src/abstract/bitbank.js +11 -0
  46. package/js/src/src/abstract/bitbarg.d.ts +8 -0
  47. package/js/src/src/abstract/bitbarg.js +11 -0
  48. package/js/src/src/abstract/bitbns.d.ts +43 -0
  49. package/js/src/src/abstract/bitbns.js +11 -0
  50. package/js/src/src/abstract/bitfinex.d.ts +143 -0
  51. package/js/src/src/abstract/bitfinex.js +11 -0
  52. package/js/src/src/abstract/bitflyer.d.ts +42 -0
  53. package/js/src/src/abstract/bitflyer.js +11 -0
  54. package/js/src/src/abstract/bitget.d.ts +578 -0
  55. package/js/src/src/abstract/bitget.js +11 -0
  56. package/js/src/src/abstract/bithumb.d.ts +35 -0
  57. package/js/src/src/abstract/bithumb.js +11 -0
  58. package/js/src/src/abstract/bitimen.d.ts +10 -0
  59. package/js/src/src/abstract/bitimen.js +11 -0
  60. package/js/src/src/abstract/bitir.d.ts +10 -0
  61. package/js/src/src/abstract/bitir.js +11 -0
  62. package/js/src/src/abstract/bitmart.d.ts +120 -0
  63. package/js/src/src/abstract/bitmart.js +11 -0
  64. package/js/src/src/abstract/bitmex.d.ts +100 -0
  65. package/js/src/src/abstract/bitmex.js +11 -0
  66. package/js/src/src/abstract/bitopro.d.ts +33 -0
  67. package/js/src/src/abstract/bitopro.js +11 -0
  68. package/js/src/src/abstract/bitpin.d.ts +11 -0
  69. package/js/src/src/abstract/bitpin.js +11 -0
  70. package/js/src/src/abstract/bitrue.d.ts +75 -0
  71. package/js/src/src/abstract/bitrue.js +11 -0
  72. package/js/src/src/abstract/bitso.d.ts +46 -0
  73. package/js/src/src/abstract/bitso.js +11 -0
  74. package/js/src/src/abstract/bitstamp.d.ts +262 -0
  75. package/js/src/src/abstract/bitstamp.js +11 -0
  76. package/js/src/src/abstract/bitteam.d.ts +32 -0
  77. package/js/src/src/abstract/bitteam.js +11 -0
  78. package/js/src/src/abstract/bittrade.d.ts +117 -0
  79. package/js/src/src/abstract/bittrade.js +11 -0
  80. package/js/src/src/abstract/bitunix.d.ts +9 -0
  81. package/js/src/src/abstract/bitunix.js +11 -0
  82. package/js/src/src/abstract/bitvavo.d.ts +30 -0
  83. package/js/src/src/abstract/bitvavo.js +11 -0
  84. package/js/src/src/abstract/blockchaincom.d.ts +31 -0
  85. package/js/src/src/abstract/blockchaincom.js +11 -0
  86. package/js/src/src/abstract/blofin.d.ts +70 -0
  87. package/js/src/src/abstract/blofin.js +11 -0
  88. package/js/src/src/abstract/btcalpha.d.ts +21 -0
  89. package/js/src/src/abstract/btcalpha.js +11 -0
  90. package/js/src/src/abstract/btcbox.d.ts +18 -0
  91. package/js/src/src/abstract/btcbox.js +11 -0
  92. package/js/src/src/abstract/btcmarkets.d.ts +42 -0
  93. package/js/src/src/abstract/btcmarkets.js +11 -0
  94. package/js/src/src/abstract/btcturk.d.ts +23 -0
  95. package/js/src/src/abstract/btcturk.js +11 -0
  96. package/js/src/src/abstract/bybit.d.ts +316 -0
  97. package/js/src/src/abstract/bybit.js +11 -0
  98. package/js/src/src/abstract/bydfi.d.ts +11 -0
  99. package/js/src/src/abstract/bydfi.js +11 -0
  100. package/js/src/src/abstract/cafearz.d.ts +8 -0
  101. package/js/src/src/abstract/cafearz.js +11 -0
  102. package/js/src/src/abstract/cex.d.ts +35 -0
  103. package/js/src/src/abstract/cex.js +11 -0
  104. package/js/src/src/abstract/coinbase.d.ts +97 -0
  105. package/js/src/src/abstract/coinbase.js +11 -0
  106. package/js/src/src/abstract/coinbaseexchange.d.ts +71 -0
  107. package/js/src/src/abstract/coinbaseexchange.js +11 -0
  108. package/js/src/src/abstract/coinbaseinternational.d.ts +42 -0
  109. package/js/src/src/abstract/coinbaseinternational.js +11 -0
  110. package/js/src/src/abstract/coincatch.d.ts +97 -0
  111. package/js/src/src/abstract/coincatch.js +11 -0
  112. package/js/src/src/abstract/coincheck.d.ts +36 -0
  113. package/js/src/src/abstract/coincheck.js +11 -0
  114. package/js/src/src/abstract/coinex.d.ts +240 -0
  115. package/js/src/src/abstract/coinex.js +11 -0
  116. package/js/src/src/abstract/coinmate.d.ts +65 -0
  117. package/js/src/src/abstract/coinmate.js +11 -0
  118. package/js/src/src/abstract/coinmetro.d.ts +37 -0
  119. package/js/src/src/abstract/coinmetro.js +11 -0
  120. package/js/src/src/abstract/coinone.d.ts +70 -0
  121. package/js/src/src/abstract/coinone.js +11 -0
  122. package/js/src/src/abstract/coinsph.d.ts +57 -0
  123. package/js/src/src/abstract/coinsph.js +11 -0
  124. package/js/src/src/abstract/coinspot.d.ts +31 -0
  125. package/js/src/src/abstract/coinspot.js +11 -0
  126. package/js/src/src/abstract/cryptocom.d.ts +126 -0
  127. package/js/src/src/abstract/cryptocom.js +11 -0
  128. package/js/src/src/abstract/cryptomus.d.ts +23 -0
  129. package/js/src/src/abstract/cryptomus.js +11 -0
  130. package/js/src/src/abstract/defx.d.ts +72 -0
  131. package/js/src/src/abstract/defx.js +11 -0
  132. package/js/src/src/abstract/delta.d.ts +53 -0
  133. package/js/src/src/abstract/delta.js +11 -0
  134. package/js/src/src/abstract/deribit.d.ts +129 -0
  135. package/js/src/src/abstract/deribit.js +11 -0
  136. package/js/src/src/abstract/derive.d.ts +120 -0
  137. package/js/src/src/abstract/derive.js +11 -0
  138. package/js/src/src/abstract/digifinex.d.ts +95 -0
  139. package/js/src/src/abstract/digifinex.js +11 -0
  140. package/js/src/src/abstract/ellipx.d.ts +28 -0
  141. package/js/src/src/abstract/ellipx.js +11 -0
  142. package/js/src/src/abstract/eterex.d.ts +8 -0
  143. package/js/src/src/abstract/eterex.js +11 -0
  144. package/js/src/src/abstract/excoino.d.ts +10 -0
  145. package/js/src/src/abstract/excoino.js +11 -0
  146. package/js/src/src/abstract/exir.d.ts +11 -0
  147. package/js/src/src/abstract/exir.js +11 -0
  148. package/js/src/src/abstract/exmo.d.ts +58 -0
  149. package/js/src/src/abstract/exmo.js +11 -0
  150. package/js/src/src/abstract/exnovin.d.ts +9 -0
  151. package/js/src/src/abstract/exnovin.js +11 -0
  152. package/js/src/src/abstract/farhadexchange.d.ts +8 -0
  153. package/js/src/src/abstract/farhadexchange.js +11 -0
  154. package/js/src/src/abstract/foxbit.d.ts +29 -0
  155. package/js/src/src/abstract/foxbit.js +11 -0
  156. package/js/src/src/abstract/gate.d.ts +287 -0
  157. package/js/src/src/abstract/gate.js +11 -0
  158. package/js/src/src/abstract/gemini.d.ts +62 -0
  159. package/js/src/src/abstract/gemini.js +11 -0
  160. package/js/src/src/abstract/hamtapay.d.ts +9 -0
  161. package/js/src/src/abstract/hamtapay.js +11 -0
  162. package/js/src/src/abstract/hashkey.d.ts +70 -0
  163. package/js/src/src/abstract/hashkey.js +11 -0
  164. package/js/src/src/abstract/hibachi.d.ts +29 -0
  165. package/js/src/src/abstract/hibachi.js +11 -0
  166. package/js/src/src/abstract/hitbtc.d.ts +118 -0
  167. package/js/src/src/abstract/hitbtc.js +11 -0
  168. package/js/src/src/abstract/hitobit.d.ts +11 -0
  169. package/js/src/src/abstract/hitobit.js +11 -0
  170. package/js/src/src/abstract/hollaex.d.ts +36 -0
  171. package/js/src/src/abstract/hollaex.js +11 -0
  172. package/js/src/src/abstract/htx.d.ts +551 -0
  173. package/js/src/src/abstract/htx.js +11 -0
  174. package/js/src/src/abstract/hyperliquid.d.ts +9 -0
  175. package/js/src/src/abstract/hyperliquid.js +11 -0
  176. package/js/src/src/abstract/independentreserve.d.ts +46 -0
  177. package/js/src/src/abstract/independentreserve.js +11 -0
  178. package/js/src/src/abstract/indodax.d.ts +29 -0
  179. package/js/src/src/abstract/indodax.js +11 -0
  180. package/js/src/src/abstract/iranexchange.d.ts +9 -0
  181. package/js/src/src/abstract/iranexchange.js +11 -0
  182. package/js/src/src/abstract/jibitex.d.ts +10 -0
  183. package/js/src/src/abstract/jibitex.js +11 -0
  184. package/js/src/src/abstract/kcex.d.ts +10 -0
  185. package/js/src/src/abstract/kcex.js +11 -0
  186. package/js/src/src/abstract/kifpoolme.d.ts +9 -0
  187. package/js/src/src/abstract/kifpoolme.js +11 -0
  188. package/js/src/src/abstract/kraken.d.ts +61 -0
  189. package/js/src/src/abstract/kraken.js +11 -0
  190. package/js/src/src/abstract/krakenfutures.d.ts +45 -0
  191. package/js/src/src/abstract/krakenfutures.js +11 -0
  192. package/js/src/src/abstract/kucoin.d.ts +227 -0
  193. package/js/src/src/abstract/kucoin.js +11 -0
  194. package/js/src/src/abstract/kucoinfutures.d.ts +254 -0
  195. package/js/src/src/abstract/kucoinfutures.js +11 -0
  196. package/js/src/src/abstract/latoken.d.ts +59 -0
  197. package/js/src/src/abstract/latoken.js +11 -0
  198. package/js/src/src/abstract/lbank.d.ts +65 -0
  199. package/js/src/src/abstract/lbank.js +11 -0
  200. package/js/src/src/abstract/luno.d.ts +41 -0
  201. package/js/src/src/abstract/luno.js +11 -0
  202. package/js/src/src/abstract/mazdax.d.ts +11 -0
  203. package/js/src/src/abstract/mazdax.js +11 -0
  204. package/js/src/src/abstract/mercado.d.ts +28 -0
  205. package/js/src/src/abstract/mercado.js +11 -0
  206. package/js/src/src/abstract/mexc.d.ts +183 -0
  207. package/js/src/src/abstract/mexc.js +11 -0
  208. package/js/src/src/abstract/modetrade.d.ts +122 -0
  209. package/js/src/src/abstract/modetrade.js +11 -0
  210. package/js/src/src/abstract/ndax.d.ts +100 -0
  211. package/js/src/src/abstract/ndax.js +11 -0
  212. package/js/src/src/abstract/nobitex.d.ts +10 -0
  213. package/js/src/src/abstract/nobitex.js +11 -0
  214. package/js/src/src/abstract/novadax.d.ts +32 -0
  215. package/js/src/src/abstract/novadax.js +11 -0
  216. package/js/src/src/abstract/oceanex.d.ts +30 -0
  217. package/js/src/src/abstract/oceanex.js +11 -0
  218. package/js/src/src/abstract/okcoin.d.ts +77 -0
  219. package/js/src/src/abstract/okcoin.js +11 -0
  220. package/js/src/src/abstract/okexchange.d.ts +11 -0
  221. package/js/src/src/abstract/okexchange.js +11 -0
  222. package/js/src/src/abstract/okx.d.ts +352 -0
  223. package/js/src/src/abstract/okx.js +11 -0
  224. package/js/src/src/abstract/ompfinex.d.ts +10 -0
  225. package/js/src/src/abstract/ompfinex.js +11 -0
  226. package/js/src/src/abstract/onetrading.d.ts +26 -0
  227. package/js/src/src/abstract/onetrading.js +11 -0
  228. package/js/src/src/abstract/oxfun.d.ts +37 -0
  229. package/js/src/src/abstract/oxfun.js +11 -0
  230. package/js/src/src/abstract/p2b.d.ts +25 -0
  231. package/js/src/src/abstract/p2b.js +11 -0
  232. package/js/src/src/abstract/paradex.d.ts +66 -0
  233. package/js/src/src/abstract/paradex.js +11 -0
  234. package/js/src/src/abstract/paymium.d.ts +31 -0
  235. package/js/src/src/abstract/paymium.js +11 -0
  236. package/js/src/src/abstract/phemex.d.ts +120 -0
  237. package/js/src/src/abstract/phemex.js +11 -0
  238. package/js/src/src/abstract/pingi.d.ts +9 -0
  239. package/js/src/src/abstract/pingi.js +11 -0
  240. package/js/src/src/abstract/poloniex.d.ts +108 -0
  241. package/js/src/src/abstract/poloniex.js +11 -0
  242. package/js/src/src/abstract/pooleno.d.ts +8 -0
  243. package/js/src/src/abstract/pooleno.js +11 -0
  244. package/js/src/src/abstract/probit.d.ts +26 -0
  245. package/js/src/src/abstract/probit.js +11 -0
  246. package/js/src/src/abstract/raastin.d.ts +11 -0
  247. package/js/src/src/abstract/raastin.js +11 -0
  248. package/js/src/src/abstract/ramzinex.d.ts +10 -0
  249. package/js/src/src/abstract/ramzinex.js +11 -0
  250. package/js/src/src/abstract/sarmayex.d.ts +8 -0
  251. package/js/src/src/abstract/sarmayex.js +11 -0
  252. package/js/src/src/abstract/sarrafex.d.ts +10 -0
  253. package/js/src/src/abstract/sarrafex.js +11 -0
  254. package/js/src/src/abstract/tabdeal.d.ts +10 -0
  255. package/js/src/src/abstract/tabdeal.js +11 -0
  256. package/js/src/src/abstract/tehran_exchange.d.ts +9 -0
  257. package/js/src/src/abstract/tehran_exchange.js +11 -0
  258. package/js/src/src/abstract/tetherland.d.ts +8 -0
  259. package/js/src/src/abstract/tetherland.js +11 -0
  260. package/js/src/src/abstract/timex.d.ts +65 -0
  261. package/js/src/src/abstract/timex.js +11 -0
  262. package/js/src/src/abstract/tokocrypto.d.ts +40 -0
  263. package/js/src/src/abstract/tokocrypto.js +11 -0
  264. package/js/src/src/abstract/toobit.d.ts +10 -0
  265. package/js/src/src/abstract/toobit.js +11 -0
  266. package/js/src/src/abstract/tradeogre.d.ts +21 -0
  267. package/js/src/src/abstract/tradeogre.js +11 -0
  268. package/js/src/src/abstract/twox.d.ts +8 -0
  269. package/js/src/src/abstract/twox.js +11 -0
  270. package/js/src/src/abstract/ubitex.d.ts +10 -0
  271. package/js/src/src/abstract/ubitex.js +11 -0
  272. package/js/src/src/abstract/upbit.d.ts +58 -0
  273. package/js/src/src/abstract/upbit.js +11 -0
  274. package/js/src/src/abstract/vertex.d.ts +22 -0
  275. package/js/src/src/abstract/vertex.js +11 -0
  276. package/js/src/src/abstract/wallex.d.ts +11 -0
  277. package/js/src/src/abstract/wallex.js +11 -0
  278. package/js/src/src/abstract/wavesexchange.d.ts +157 -0
  279. package/js/src/src/abstract/wavesexchange.js +11 -0
  280. package/js/src/src/abstract/whitebit.d.ts +117 -0
  281. package/js/src/src/abstract/whitebit.js +11 -0
  282. package/js/src/src/abstract/woo.d.ts +144 -0
  283. package/js/src/src/abstract/woo.js +11 -0
  284. package/js/src/src/abstract/woofipro.d.ts +122 -0
  285. package/js/src/src/abstract/woofipro.js +11 -0
  286. package/js/src/src/abstract/xt.d.ts +160 -0
  287. package/js/src/src/abstract/xt.js +11 -0
  288. package/js/src/src/abstract/yobit.d.ts +19 -0
  289. package/js/src/src/abstract/yobit.js +11 -0
  290. package/js/src/src/abstract/zaif.d.ts +41 -0
  291. package/js/src/src/abstract/zaif.js +11 -0
  292. package/js/src/src/abstract/zonda.d.ts +56 -0
  293. package/js/src/src/abstract/zonda.js +11 -0
  294. package/js/src/src/afratether.d.ts +21 -0
  295. package/js/src/src/afratether.js +356 -0
  296. package/js/src/src/alpaca.d.ts +332 -0
  297. package/js/src/src/alpaca.js +1908 -0
  298. package/js/src/src/apex.d.ts +333 -0
  299. package/js/src/src/apex.js +1942 -0
  300. package/js/src/src/arzinja.d.ts +21 -0
  301. package/js/src/src/arzinja.js +298 -0
  302. package/js/src/src/arzplus.d.ts +26 -0
  303. package/js/src/src/arzplus.js +581 -0
  304. package/js/src/src/ascendex.d.ts +424 -0
  305. package/js/src/src/ascendex.js +3699 -0
  306. package/js/src/src/asretether.d.ts +21 -0
  307. package/js/src/src/asretether.js +324 -0
  308. package/js/src/src/base/Exchange.d.ts +926 -0
  309. package/js/src/src/base/Exchange.js +7399 -0
  310. package/js/src/src/base/Precise.d.ts +42 -0
  311. package/js/src/src/base/Precise.js +275 -0
  312. package/js/src/src/base/errors.d.ts +168 -0
  313. package/js/src/src/base/errors.js +255 -0
  314. package/js/src/src/base/functions/crypto.d.ts +16 -0
  315. package/js/src/src/base/functions/crypto.js +131 -0
  316. package/js/src/src/base/functions/encode.d.ts +4 -0
  317. package/js/src/src/base/functions/encode.js +32 -0
  318. package/js/src/src/base/functions/generic.d.ts +29 -0
  319. package/js/src/src/base/functions/generic.js +203 -0
  320. package/js/src/src/base/functions/misc.d.ts +9 -0
  321. package/js/src/src/base/functions/misc.js +101 -0
  322. package/js/src/src/base/functions/number.d.ts +27 -0
  323. package/js/src/src/base/functions/number.js +313 -0
  324. package/js/src/src/base/functions/platform.d.ts +7 -0
  325. package/js/src/src/base/functions/platform.js +27 -0
  326. package/js/src/src/base/functions/rsa.d.ts +5 -0
  327. package/js/src/src/base/functions/rsa.js +49 -0
  328. package/js/src/src/base/functions/string.d.ts +7 -0
  329. package/js/src/src/base/functions/string.js +44 -0
  330. package/js/src/src/base/functions/throttle.d.ts +6 -0
  331. package/js/src/src/base/functions/throttle.js +67 -0
  332. package/js/src/src/base/functions/time.d.ts +21 -0
  333. package/js/src/src/base/functions/time.js +171 -0
  334. package/js/src/src/base/functions/totp.d.ts +3 -0
  335. package/js/src/src/base/functions/totp.js +25 -0
  336. package/js/src/src/base/functions/type.d.ts +37 -0
  337. package/js/src/src/base/functions/type.js +179 -0
  338. package/js/src/src/base/functions.d.ts +10 -0
  339. package/js/src/src/base/functions.js +18 -0
  340. package/js/src/src/base/types.d.ts +586 -0
  341. package/js/src/src/base/types.js +7 -0
  342. package/js/src/src/base/ws/Cache.d.ts +27 -0
  343. package/js/src/src/base/ws/Cache.js +260 -0
  344. package/js/src/src/base/ws/Client.d.ts +53 -0
  345. package/js/src/src/base/ws/Client.js +307 -0
  346. package/js/src/src/base/ws/Future.d.ts +8 -0
  347. package/js/src/src/base/ws/Future.js +35 -0
  348. package/js/src/src/base/ws/OrderBook.d.ts +25 -0
  349. package/js/src/src/base/ws/OrderBook.js +130 -0
  350. package/js/src/src/base/ws/OrderBookSide.d.ts +40 -0
  351. package/js/src/src/base/ws/OrderBookSide.js +286 -0
  352. package/js/src/src/base/ws/WsClient.d.ts +11 -0
  353. package/js/src/src/base/ws/WsClient.js +69 -0
  354. package/js/src/src/bequant.d.ts +4 -0
  355. package/js/src/src/bequant.js +35 -0
  356. package/js/src/src/bidarz.d.ts +16 -0
  357. package/js/src/src/bidarz.js +327 -0
  358. package/js/src/src/bigone.d.ts +296 -0
  359. package/js/src/src/bigone.js +2340 -0
  360. package/js/src/src/binance.d.ts +1667 -0
  361. package/js/src/src/binance.js +14400 -0
  362. package/js/src/src/binancecoinm.d.ts +6 -0
  363. package/js/src/src/binancecoinm.js +51 -0
  364. package/js/src/src/binanceus.d.ts +4 -0
  365. package/js/src/src/binanceus.js +225 -0
  366. package/js/src/src/binanceusdm.d.ts +6 -0
  367. package/js/src/src/binanceusdm.js +63 -0
  368. package/js/src/src/bingx.d.ts +778 -0
  369. package/js/src/src/bingx.js +6705 -0
  370. package/js/src/src/bit24.d.ts +24 -0
  371. package/js/src/src/bit24.js +520 -0
  372. package/js/src/src/bit2c.d.ts +146 -0
  373. package/js/src/src/bit2c.js +1029 -0
  374. package/js/src/src/bitbank.d.ts +181 -0
  375. package/js/src/src/bitbank.js +1146 -0
  376. package/js/src/src/bitbarg.d.ts +21 -0
  377. package/js/src/src/bitbarg.js +312 -0
  378. package/js/src/src/bitbns.d.ts +184 -0
  379. package/js/src/src/bitbns.js +1288 -0
  380. package/js/src/src/bitfinex.d.ts +516 -0
  381. package/js/src/src/bitfinex.js +3951 -0
  382. package/js/src/src/bitflyer.d.ts +229 -0
  383. package/js/src/src/bitflyer.js +1209 -0
  384. package/js/src/src/bitget.d.ts +1109 -0
  385. package/js/src/src/bitget.js +11033 -0
  386. package/js/src/src/bithumb.d.ts +165 -0
  387. package/js/src/src/bithumb.js +1257 -0
  388. package/js/src/src/bitimen.d.ts +23 -0
  389. package/js/src/src/bitimen.js +424 -0
  390. package/js/src/src/bitir.d.ts +23 -0
  391. package/js/src/src/bitir.js +521 -0
  392. package/js/src/src/bitmart.d.ts +736 -0
  393. package/js/src/src/bitmart.js +5639 -0
  394. package/js/src/src/bitmex.d.ts +395 -0
  395. package/js/src/src/bitmex.js +3088 -0
  396. package/js/src/src/bitopro.d.ts +295 -0
  397. package/js/src/src/bitopro.js +1892 -0
  398. package/js/src/src/bitpin.d.ts +23 -0
  399. package/js/src/src/bitpin.js +487 -0
  400. package/js/src/src/bitrue.d.ts +384 -0
  401. package/js/src/src/bitrue.js +3382 -0
  402. package/js/src/src/bitso.d.ts +270 -0
  403. package/js/src/src/bitso.js +1881 -0
  404. package/js/src/src/bitstamp.d.ts +355 -0
  405. package/js/src/src/bitstamp.js +2445 -0
  406. package/js/src/src/bitteam.d.ts +229 -0
  407. package/js/src/src/bitteam.js +2420 -0
  408. package/js/src/src/bittrade.d.ts +298 -0
  409. package/js/src/src/bittrade.js +2050 -0
  410. package/js/src/src/bitunix.d.ts +21 -0
  411. package/js/src/src/bitunix.js +326 -0
  412. package/js/src/src/bitvavo.d.ts +311 -0
  413. package/js/src/src/bitvavo.js +2204 -0
  414. package/js/src/src/blockchaincom.d.ts +256 -0
  415. package/js/src/src/blockchaincom.js +1259 -0
  416. package/js/src/src/blofin.d.ts +439 -0
  417. package/js/src/src/blofin.js +2576 -0
  418. package/js/src/src/btcalpha.d.ts +209 -0
  419. package/js/src/src/btcalpha.js +1056 -0
  420. package/js/src/src/btcbox.d.ts +144 -0
  421. package/js/src/src/btcbox.js +834 -0
  422. package/js/src/src/btcmarkets.d.ts +253 -0
  423. package/js/src/src/btcmarkets.js +1418 -0
  424. package/js/src/src/btcturk.d.ts +161 -0
  425. package/js/src/src/btcturk.js +1058 -0
  426. package/js/src/src/bybit.d.ts +1097 -0
  427. package/js/src/src/bybit.js +9382 -0
  428. package/js/src/src/bydfi.d.ts +23 -0
  429. package/js/src/src/bydfi.js +434 -0
  430. package/js/src/src/cafearz.d.ts +21 -0
  431. package/js/src/src/cafearz.js +346 -0
  432. package/js/src/src/cex.d.ts +286 -0
  433. package/js/src/src/cex.js +1799 -0
  434. package/js/src/src/coinbase.d.ts +623 -0
  435. package/js/src/src/coinbase.js +5220 -0
  436. package/js/src/src/coinbaseadvanced.d.ts +4 -0
  437. package/js/src/src/coinbaseadvanced.js +18 -0
  438. package/js/src/src/coinbaseexchange.d.ts +334 -0
  439. package/js/src/src/coinbaseexchange.js +2127 -0
  440. package/js/src/src/coinbaseinternational.d.ts +443 -0
  441. package/js/src/src/coinbaseinternational.js +2336 -0
  442. package/js/src/src/coincatch.d.ts +786 -0
  443. package/js/src/src/coincatch.js +5492 -0
  444. package/js/src/src/coincheck.d.ts +147 -0
  445. package/js/src/src/coincheck.js +962 -0
  446. package/js/src/src/coinex.d.ts +719 -0
  447. package/js/src/src/coinex.js +6166 -0
  448. package/js/src/src/coinmate.d.ts +202 -0
  449. package/js/src/src/coinmate.js +1215 -0
  450. package/js/src/src/coinmetro.d.ts +244 -0
  451. package/js/src/src/coinmetro.js +2024 -0
  452. package/js/src/src/coinone.d.ts +158 -0
  453. package/js/src/src/coinone.js +1278 -0
  454. package/js/src/src/coinsph.d.ts +310 -0
  455. package/js/src/src/coinsph.js +2203 -0
  456. package/js/src/src/coinspot.d.ts +108 -0
  457. package/js/src/src/coinspot.js +653 -0
  458. package/js/src/src/cryptocom.d.ts +463 -0
  459. package/js/src/src/cryptocom.js +3549 -0
  460. package/js/src/src/cryptomus.d.ts +158 -0
  461. package/js/src/src/cryptomus.js +1169 -0
  462. package/js/src/src/defx.d.ts +348 -0
  463. package/js/src/src/defx.js +2139 -0
  464. package/js/src/src/delta.d.ts +407 -0
  465. package/js/src/src/delta.js +3654 -0
  466. package/js/src/src/deribit.d.ts +516 -0
  467. package/js/src/src/deribit.js +3790 -0
  468. package/js/src/src/derive.d.ts +324 -0
  469. package/js/src/src/derive.js +2655 -0
  470. package/js/src/src/digifinex.d.ts +544 -0
  471. package/js/src/src/digifinex.js +4453 -0
  472. package/js/src/src/ellipx.d.ts +237 -0
  473. package/js/src/src/ellipx.js +2071 -0
  474. package/js/src/src/eterex.d.ts +21 -0
  475. package/js/src/src/eterex.js +299 -0
  476. package/js/src/src/excoino.d.ts +23 -0
  477. package/js/src/src/excoino.js +426 -0
  478. package/js/src/src/exir.d.ts +23 -0
  479. package/js/src/src/exir.js +403 -0
  480. package/js/src/src/exmo.d.ts +426 -0
  481. package/js/src/src/exmo.js +2825 -0
  482. package/js/src/src/exnovin.d.ts +22 -0
  483. package/js/src/src/exnovin.js +378 -0
  484. package/js/src/src/farhadexchange.d.ts +21 -0
  485. package/js/src/src/farhadexchange.js +280 -0
  486. package/js/src/src/fmfwio.d.ts +4 -0
  487. package/js/src/src/fmfwio.js +35 -0
  488. package/js/src/src/foxbit.d.ts +352 -0
  489. package/js/src/src/foxbit.js +2016 -0
  490. package/js/src/src/gate.d.ts +1071 -0
  491. package/js/src/src/gate.js +8282 -0
  492. package/js/src/src/gateio.d.ts +4 -0
  493. package/js/src/src/gateio.js +17 -0
  494. package/js/src/src/gemini.d.ts +257 -0
  495. package/js/src/src/gemini.js +2006 -0
  496. package/js/src/src/hamtapay.d.ts +21 -0
  497. package/js/src/src/hamtapay.js +303 -0
  498. package/js/src/src/hashkey.d.ts +628 -0
  499. package/js/src/src/hashkey.js +4363 -0
  500. package/js/src/src/hibachi.d.ts +346 -0
  501. package/js/src/src/hibachi.js +2137 -0
  502. package/js/src/src/hitbtc.d.ts +558 -0
  503. package/js/src/src/hitbtc.js +3847 -0
  504. package/js/src/src/hitobit.d.ts +23 -0
  505. package/js/src/src/hitobit.js +412 -0
  506. package/js/src/src/hollaex.d.ts +305 -0
  507. package/js/src/src/hollaex.js +2046 -0
  508. package/js/src/src/htx.d.ts +961 -0
  509. package/js/src/src/htx.js +9668 -0
  510. package/js/src/src/huobi.d.ts +4 -0
  511. package/js/src/src/huobi.js +17 -0
  512. package/js/src/src/hyperliquid.d.ts +651 -0
  513. package/js/src/src/hyperliquid.js +3937 -0
  514. package/js/src/src/independentreserve.d.ts +169 -0
  515. package/js/src/src/independentreserve.js +1115 -0
  516. package/js/src/src/indodax.d.ts +217 -0
  517. package/js/src/src/indodax.js +1454 -0
  518. package/js/src/src/iranexchange.d.ts +21 -0
  519. package/js/src/src/iranexchange.js +399 -0
  520. package/js/src/src/jibitex.d.ts +23 -0
  521. package/js/src/src/jibitex.js +416 -0
  522. package/js/src/src/kcex.d.ts +21 -0
  523. package/js/src/src/kcex.js +335 -0
  524. package/js/src/src/kifpoolme.d.ts +23 -0
  525. package/js/src/src/kifpoolme.js +410 -0
  526. package/js/src/src/kraken.d.ts +484 -0
  527. package/js/src/src/kraken.js +3518 -0
  528. package/js/src/src/krakenfutures.d.ts +362 -0
  529. package/js/src/src/krakenfutures.js +2885 -0
  530. package/js/src/src/kucoin.d.ts +759 -0
  531. package/js/src/src/kucoin.js +5153 -0
  532. package/js/src/src/kucoinfutures.d.ts +521 -0
  533. package/js/src/src/kucoinfutures.js +3381 -0
  534. package/js/src/src/latoken.d.ts +274 -0
  535. package/js/src/src/latoken.js +1824 -0
  536. package/js/src/src/lbank.d.ts +350 -0
  537. package/js/src/src/lbank.js +3146 -0
  538. package/js/src/src/luno.d.ts +252 -0
  539. package/js/src/src/luno.js +1479 -0
  540. package/js/src/src/mazdax.d.ts +23 -0
  541. package/js/src/src/mazdax.js +534 -0
  542. package/js/src/src/mercado.d.ts +160 -0
  543. package/js/src/src/mercado.js +1011 -0
  544. package/js/src/src/mexc.d.ts +768 -0
  545. package/js/src/src/mexc.js +6102 -0
  546. package/js/src/src/modetrade.d.ts +496 -0
  547. package/js/src/src/modetrade.js +2936 -0
  548. package/js/src/src/myokx.d.ts +4 -0
  549. package/js/src/src/myokx.js +54 -0
  550. package/js/src/src/ndax.d.ts +285 -0
  551. package/js/src/src/ndax.js +2598 -0
  552. package/js/src/src/nobitex.d.ts +23 -0
  553. package/js/src/src/nobitex.js +454 -0
  554. package/js/src/src/novadax.d.ts +279 -0
  555. package/js/src/src/novadax.js +1676 -0
  556. package/js/src/src/oceanex.d.ts +231 -0
  557. package/js/src/src/oceanex.js +1123 -0
  558. package/js/src/src/okcoin.d.ts +346 -0
  559. package/js/src/src/okcoin.js +3211 -0
  560. package/js/src/src/okexchange.d.ts +23 -0
  561. package/js/src/src/okexchange.js +373 -0
  562. package/js/src/src/okx.d.ts +1125 -0
  563. package/js/src/src/okx.js +9009 -0
  564. package/js/src/src/okxus.d.ts +4 -0
  565. package/js/src/src/okxus.js +54 -0
  566. package/js/src/src/ompfinex.d.ts +23 -0
  567. package/js/src/src/ompfinex.js +510 -0
  568. package/js/src/src/onetrading.d.ts +228 -0
  569. package/js/src/src/onetrading.js +1769 -0
  570. package/js/src/src/oxfun.d.ts +442 -0
  571. package/js/src/src/oxfun.js +2920 -0
  572. package/js/src/src/p2b.d.ts +189 -0
  573. package/js/src/src/p2b.js +1344 -0
  574. package/js/src/src/paradex.d.ts +389 -0
  575. package/js/src/src/paradex.js +2607 -0
  576. package/js/src/src/paymium.d.ts +133 -0
  577. package/js/src/src/paymium.js +644 -0
  578. package/js/src/src/phemex.d.ts +497 -0
  579. package/js/src/src/phemex.js +5333 -0
  580. package/js/src/src/pingi.d.ts +22 -0
  581. package/js/src/src/pingi.js +446 -0
  582. package/js/src/src/poloniex.d.ts +441 -0
  583. package/js/src/src/poloniex.js +3681 -0
  584. package/js/src/src/pooleno.d.ts +21 -0
  585. package/js/src/src/pooleno.js +347 -0
  586. package/js/src/src/pro/alpaca.d.ts +95 -0
  587. package/js/src/src/pro/alpaca.js +724 -0
  588. package/js/src/src/pro/apex.d.ts +160 -0
  589. package/js/src/src/pro/apex.js +1044 -0
  590. package/js/src/src/pro/ascendex.d.ts +99 -0
  591. package/js/src/src/pro/ascendex.js +1012 -0
  592. package/js/src/src/pro/bequant.d.ts +4 -0
  593. package/js/src/src/pro/bequant.js +42 -0
  594. package/js/src/src/pro/binance.d.ts +796 -0
  595. package/js/src/src/pro/binance.js +4373 -0
  596. package/js/src/src/pro/binancecoinm.d.ts +4 -0
  597. package/js/src/src/pro/binancecoinm.js +32 -0
  598. package/js/src/src/pro/binanceus.d.ts +4 -0
  599. package/js/src/src/pro/binanceus.js +52 -0
  600. package/js/src/src/pro/binanceusdm.d.ts +4 -0
  601. package/js/src/src/pro/binanceusdm.js +37 -0
  602. package/js/src/src/pro/bingx.d.ts +151 -0
  603. package/js/src/src/pro/bingx.js +1568 -0
  604. package/js/src/src/pro/bitfinex.d.ts +99 -0
  605. package/js/src/src/pro/bitfinex.js +1165 -0
  606. package/js/src/src/pro/bitget.d.ts +257 -0
  607. package/js/src/src/pro/bitget.js +2327 -0
  608. package/js/src/src/pro/bithumb.d.ts +59 -0
  609. package/js/src/src/pro/bithumb.js +395 -0
  610. package/js/src/src/pro/bitmart.d.ts +168 -0
  611. package/js/src/src/pro/bitmart.js +1686 -0
  612. package/js/src/src/pro/bitmex.d.ts +170 -0
  613. package/js/src/src/pro/bitmex.js +1760 -0
  614. package/js/src/src/pro/bitopro.d.ts +69 -0
  615. package/js/src/src/pro/bitopro.js +477 -0
  616. package/js/src/src/pro/bitrue.d.ts +40 -0
  617. package/js/src/src/pro/bitrue.js +461 -0
  618. package/js/src/src/pro/bitstamp.d.ts +53 -0
  619. package/js/src/src/pro/bitstamp.js +587 -0
  620. package/js/src/src/pro/bittrade.d.ts +66 -0
  621. package/js/src/src/pro/bittrade.js +606 -0
  622. package/js/src/src/pro/bitvavo.d.ts +321 -0
  623. package/js/src/src/pro/bitvavo.js +1451 -0
  624. package/js/src/src/pro/blockchaincom.d.ts +89 -0
  625. package/js/src/src/pro/blockchaincom.js +777 -0
  626. package/js/src/src/pro/blofin.d.ts +174 -0
  627. package/js/src/src/pro/blofin.js +743 -0
  628. package/js/src/src/pro/bybit.d.ts +397 -0
  629. package/js/src/src/pro/bybit.js +2519 -0
  630. package/js/src/src/pro/cex.d.ts +220 -0
  631. package/js/src/src/pro/cex.js +1535 -0
  632. package/js/src/src/pro/coinbase.d.ts +119 -0
  633. package/js/src/src/pro/coinbase.js +736 -0
  634. package/js/src/src/pro/coinbaseadvanced.d.ts +4 -0
  635. package/js/src/src/pro/coinbaseadvanced.js +18 -0
  636. package/js/src/src/pro/coinbaseexchange.d.ts +133 -0
  637. package/js/src/src/pro/coinbaseexchange.js +969 -0
  638. package/js/src/src/pro/coinbaseinternational.d.ts +143 -0
  639. package/js/src/src/pro/coinbaseinternational.js +804 -0
  640. package/js/src/src/pro/coincatch.d.ts +207 -0
  641. package/js/src/src/pro/coincatch.js +1562 -0
  642. package/js/src/src/pro/coincheck.d.ts +33 -0
  643. package/js/src/src/pro/coincheck.js +210 -0
  644. package/js/src/src/pro/coinex.d.ts +147 -0
  645. package/js/src/src/pro/coinex.js +1426 -0
  646. package/js/src/src/pro/coinone.d.ts +51 -0
  647. package/js/src/src/pro/coinone.js +413 -0
  648. package/js/src/src/pro/cryptocom.d.ts +300 -0
  649. package/js/src/src/pro/cryptocom.js +1414 -0
  650. package/js/src/src/pro/defx.d.ts +236 -0
  651. package/js/src/src/pro/defx.js +865 -0
  652. package/js/src/src/pro/deribit.d.ts +163 -0
  653. package/js/src/src/pro/deribit.js +1066 -0
  654. package/js/src/src/pro/derive.d.ts +100 -0
  655. package/js/src/src/pro/derive.js +753 -0
  656. package/js/src/src/pro/exmo.d.ts +97 -0
  657. package/js/src/src/pro/exmo.js +903 -0
  658. package/js/src/src/pro/gate.d.ts +360 -0
  659. package/js/src/src/pro/gate.js +2119 -0
  660. package/js/src/src/pro/gateio.d.ts +4 -0
  661. package/js/src/src/pro/gateio.js +17 -0
  662. package/js/src/src/pro/gemini.d.ts +106 -0
  663. package/js/src/src/pro/gemini.js +932 -0
  664. package/js/src/src/pro/hashkey.d.ts +121 -0
  665. package/js/src/src/pro/hashkey.js +843 -0
  666. package/js/src/src/pro/hitbtc.d.ts +235 -0
  667. package/js/src/src/pro/hitbtc.js +1400 -0
  668. package/js/src/src/pro/hollaex.d.ts +77 -0
  669. package/js/src/src/pro/hollaex.js +604 -0
  670. package/js/src/src/pro/htx.d.ts +141 -0
  671. package/js/src/src/pro/htx.js +2415 -0
  672. package/js/src/src/pro/huobi.d.ts +4 -0
  673. package/js/src/src/pro/huobi.js +17 -0
  674. package/js/src/src/pro/hyperliquid.d.ts +218 -0
  675. package/js/src/src/pro/hyperliquid.js +1126 -0
  676. package/js/src/src/pro/independentreserve.d.ts +36 -0
  677. package/js/src/src/pro/independentreserve.js +287 -0
  678. package/js/src/src/pro/kraken.d.ts +233 -0
  679. package/js/src/src/pro/kraken.js +1785 -0
  680. package/js/src/src/pro/krakenfutures.d.ts +178 -0
  681. package/js/src/src/pro/krakenfutures.js +1592 -0
  682. package/js/src/src/pro/kucoin.d.ts +221 -0
  683. package/js/src/src/pro/kucoin.js +1430 -0
  684. package/js/src/src/pro/kucoinfutures.d.ts +205 -0
  685. package/js/src/src/pro/kucoinfutures.js +1295 -0
  686. package/js/src/src/pro/lbank.d.ts +134 -0
  687. package/js/src/src/pro/lbank.js +950 -0
  688. package/js/src/src/pro/luno.d.ts +44 -0
  689. package/js/src/src/pro/luno.js +322 -0
  690. package/js/src/src/pro/mexc.d.ts +210 -0
  691. package/js/src/src/pro/mexc.js +2009 -0
  692. package/js/src/src/pro/modetrade.d.ts +155 -0
  693. package/js/src/src/pro/modetrade.js +1335 -0
  694. package/js/src/src/pro/myokx.d.ts +4 -0
  695. package/js/src/src/pro/myokx.js +39 -0
  696. package/js/src/src/pro/ndax.d.ts +60 -0
  697. package/js/src/src/pro/ndax.js +545 -0
  698. package/js/src/src/pro/okcoin.d.ts +91 -0
  699. package/js/src/src/pro/okcoin.js +763 -0
  700. package/js/src/src/pro/okx.d.ts +408 -0
  701. package/js/src/src/pro/okx.js +2479 -0
  702. package/js/src/src/pro/okxus.d.ts +4 -0
  703. package/js/src/src/pro/okxus.js +39 -0
  704. package/js/src/src/pro/onetrading.d.ts +107 -0
  705. package/js/src/src/pro/onetrading.js +1343 -0
  706. package/js/src/src/pro/oxfun.d.ts +234 -0
  707. package/js/src/src/pro/oxfun.js +1112 -0
  708. package/js/src/src/pro/p2b.d.ts +104 -0
  709. package/js/src/src/pro/p2b.js +506 -0
  710. package/js/src/src/pro/paradex.d.ts +54 -0
  711. package/js/src/src/pro/paradex.js +370 -0
  712. package/js/src/src/pro/phemex.d.ts +129 -0
  713. package/js/src/src/pro/phemex.js +1569 -0
  714. package/js/src/src/pro/poloniex.d.ts +214 -0
  715. package/js/src/src/pro/poloniex.js +1318 -0
  716. package/js/src/src/pro/probit.d.ts +91 -0
  717. package/js/src/src/pro/probit.js +593 -0
  718. package/js/src/src/pro/tradeogre.d.ts +49 -0
  719. package/js/src/src/pro/tradeogre.js +284 -0
  720. package/js/src/src/pro/upbit.d.ts +124 -0
  721. package/js/src/src/pro/upbit.js +689 -0
  722. package/js/src/src/pro/vertex.d.ts +104 -0
  723. package/js/src/src/pro/vertex.js +999 -0
  724. package/js/src/src/pro/whitebit.d.ts +123 -0
  725. package/js/src/src/pro/whitebit.js +971 -0
  726. package/js/src/src/pro/woo.d.ts +161 -0
  727. package/js/src/src/pro/woo.js +1351 -0
  728. package/js/src/src/pro/woofipro.d.ts +155 -0
  729. package/js/src/src/pro/woofipro.js +1335 -0
  730. package/js/src/src/pro/xt.d.ts +165 -0
  731. package/js/src/src/pro/xt.js +1230 -0
  732. package/js/src/src/probit.d.ts +283 -0
  733. package/js/src/src/probit.js +1935 -0
  734. package/js/src/src/protobuf/mexc/compiled.cjs +7186 -0
  735. package/js/src/src/protobuf/mexc/compiled.d.cts +8 -0
  736. package/js/src/src/raastin.d.ts +24 -0
  737. package/js/src/src/raastin.js +494 -0
  738. package/js/src/src/ramzinex.d.ts +23 -0
  739. package/js/src/src/ramzinex.js +510 -0
  740. package/js/src/src/sarmayex.d.ts +21 -0
  741. package/js/src/src/sarmayex.js +376 -0
  742. package/js/src/src/sarrafex.d.ts +23 -0
  743. package/js/src/src/sarrafex.js +501 -0
  744. package/js/src/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
  745. package/js/src/src/static_dependencies/ethers/abi-coder.js +148 -0
  746. package/js/src/src/static_dependencies/ethers/address/address.d.ts +55 -0
  747. package/js/src/src/static_dependencies/ethers/address/address.js +162 -0
  748. package/js/src/src/static_dependencies/ethers/address/checks.d.ts +80 -0
  749. package/js/src/src/static_dependencies/ethers/address/checks.js +119 -0
  750. package/js/src/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
  751. package/js/src/src/static_dependencies/ethers/address/contract-address.js +73 -0
  752. package/js/src/src/static_dependencies/ethers/address/index.d.ts +48 -0
  753. package/js/src/src/static_dependencies/ethers/address/index.js +24 -0
  754. package/js/src/src/static_dependencies/ethers/bytes32.d.ts +14 -0
  755. package/js/src/src/static_dependencies/ethers/bytes32.js +45 -0
  756. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
  757. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
  758. package/js/src/src/static_dependencies/ethers/coders/address.d.ts +12 -0
  759. package/js/src/src/static_dependencies/ethers/coders/address.js +34 -0
  760. package/js/src/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
  761. package/js/src/src/static_dependencies/ethers/coders/anonymous.js +27 -0
  762. package/js/src/src/static_dependencies/ethers/coders/array.d.ts +24 -0
  763. package/js/src/src/static_dependencies/ethers/coders/array.js +162 -0
  764. package/js/src/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
  765. package/js/src/src/static_dependencies/ethers/coders/boolean.js +26 -0
  766. package/js/src/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
  767. package/js/src/src/static_dependencies/ethers/coders/bytes.js +39 -0
  768. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
  769. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
  770. package/js/src/src/static_dependencies/ethers/coders/null.d.ts +11 -0
  771. package/js/src/src/static_dependencies/ethers/coders/null.js +29 -0
  772. package/js/src/src/static_dependencies/ethers/coders/number.d.ts +15 -0
  773. package/js/src/src/static_dependencies/ethers/coders/number.js +48 -0
  774. package/js/src/src/static_dependencies/ethers/coders/string.d.ts +12 -0
  775. package/js/src/src/static_dependencies/ethers/coders/string.js +26 -0
  776. package/js/src/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
  777. package/js/src/src/static_dependencies/ethers/coders/tuple.js +67 -0
  778. package/js/src/src/static_dependencies/ethers/fragments.d.ts +458 -0
  779. package/js/src/src/static_dependencies/ethers/fragments.js +1252 -0
  780. package/js/src/src/static_dependencies/ethers/hash/index.d.ts +10 -0
  781. package/js/src/src/static_dependencies/ethers/hash/index.js +15 -0
  782. package/js/src/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
  783. package/js/src/src/static_dependencies/ethers/hash/solidity.js +107 -0
  784. package/js/src/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
  785. package/js/src/src/static_dependencies/ethers/hash/typed-data.js +490 -0
  786. package/js/src/src/static_dependencies/ethers/index.d.ts +19 -0
  787. package/js/src/src/static_dependencies/ethers/index.js +22 -0
  788. package/js/src/src/static_dependencies/ethers/interface.d.ts +380 -0
  789. package/js/src/src/static_dependencies/ethers/interface.js +990 -0
  790. package/js/src/src/static_dependencies/ethers/typed.d.ts +569 -0
  791. package/js/src/src/static_dependencies/ethers/typed.js +608 -0
  792. package/js/src/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
  793. package/js/src/src/static_dependencies/ethers/utils/base58.js +68 -0
  794. package/js/src/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
  795. package/js/src/src/static_dependencies/ethers/utils/base64.js +58 -0
  796. package/js/src/src/static_dependencies/ethers/utils/data.d.ts +92 -0
  797. package/js/src/src/static_dependencies/ethers/utils/data.js +175 -0
  798. package/js/src/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
  799. package/js/src/src/static_dependencies/ethers/utils/errors.js +227 -0
  800. package/js/src/src/static_dependencies/ethers/utils/events.d.ts +76 -0
  801. package/js/src/src/static_dependencies/ethers/utils/events.js +52 -0
  802. package/js/src/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
  803. package/js/src/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
  804. package/js/src/src/static_dependencies/ethers/utils/index.d.ts +30 -0
  805. package/js/src/src/static_dependencies/ethers/utils/index.js +38 -0
  806. package/js/src/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
  807. package/js/src/src/static_dependencies/ethers/utils/maths.js +220 -0
  808. package/js/src/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
  809. package/js/src/src/static_dependencies/ethers/utils/properties.js +59 -0
  810. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
  811. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
  812. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
  813. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
  814. package/js/src/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
  815. package/js/src/src/static_dependencies/ethers/utils/rlp.js +14 -0
  816. package/js/src/src/static_dependencies/ethers/utils/units.d.ts +23 -0
  817. package/js/src/src/static_dependencies/ethers/utils/units.js +88 -0
  818. package/js/src/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
  819. package/js/src/src/static_dependencies/ethers/utils/utf8.js +225 -0
  820. package/js/src/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
  821. package/js/src/src/static_dependencies/ethers/utils/uuid.js +35 -0
  822. package/js/src/src/static_dependencies/fflake/browser.d.ts +222 -0
  823. package/js/src/src/static_dependencies/fflake/browser.js +2578 -0
  824. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.d.ts +116 -0
  825. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.js +194 -0
  826. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +142 -0
  827. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +307 -0
  828. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -0
  829. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +565 -0
  830. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.d.ts +5 -0
  831. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  832. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.d.ts +3 -0
  833. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  834. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.d.ts +9 -0
  835. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  836. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.d.ts +3 -0
  837. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +25 -0
  838. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -0
  839. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1757 -0
  840. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.d.ts +10 -0
  841. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +50 -0
  842. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.d.ts +3 -0
  843. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +80 -0
  844. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.d.ts +23 -0
  845. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +377 -0
  846. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.d.ts +7 -0
  847. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.js +64 -0
  848. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -0
  849. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1627 -0
  850. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.d.ts +60 -0
  851. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.js +22 -0
  852. package/js/src/src/static_dependencies/noble-curves/abstract/curve.d.ts +67 -0
  853. package/js/src/src/static_dependencies/noble-curves/abstract/curve.js +157 -0
  854. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.d.ts +79 -0
  855. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.js +432 -0
  856. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.d.ts +56 -0
  857. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +171 -0
  858. package/js/src/src/static_dependencies/noble-curves/abstract/modular.d.ts +68 -0
  859. package/js/src/src/static_dependencies/noble-curves/abstract/modular.js +351 -0
  860. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.d.ts +25 -0
  861. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.js +162 -0
  862. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.d.ts +29 -0
  863. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.js +115 -0
  864. package/js/src/src/static_dependencies/noble-curves/abstract/utils.d.ts +53 -0
  865. package/js/src/src/static_dependencies/noble-curves/abstract/utils.js +227 -0
  866. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -0
  867. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.js +1016 -0
  868. package/js/src/src/static_dependencies/noble-curves/ed25519.d.ts +53 -0
  869. package/js/src/src/static_dependencies/noble-curves/ed25519.js +402 -0
  870. package/js/src/src/static_dependencies/noble-curves/p256.d.ts +103 -0
  871. package/js/src/src/static_dependencies/noble-curves/p256.js +47 -0
  872. package/js/src/src/static_dependencies/noble-curves/secp256k1.d.ts +91 -0
  873. package/js/src/src/static_dependencies/noble-curves/secp256k1.js +257 -0
  874. package/js/src/src/static_dependencies/noble-hashes/_assert.d.ts +21 -0
  875. package/js/src/src/static_dependencies/noble-hashes/_assert.js +48 -0
  876. package/js/src/src/static_dependencies/noble-hashes/_sha2.d.ts +23 -0
  877. package/js/src/src/static_dependencies/noble-hashes/_sha2.js +119 -0
  878. package/js/src/src/static_dependencies/noble-hashes/_u64.d.ts +35 -0
  879. package/js/src/src/static_dependencies/noble-hashes/_u64.js +66 -0
  880. package/js/src/src/static_dependencies/noble-hashes/crypto.d.ts +1 -0
  881. package/js/src/src/static_dependencies/noble-hashes/crypto.js +7 -0
  882. package/js/src/src/static_dependencies/noble-hashes/hmac.d.ts +26 -0
  883. package/js/src/src/static_dependencies/noble-hashes/hmac.js +82 -0
  884. package/js/src/src/static_dependencies/noble-hashes/md5.d.ts +18 -0
  885. package/js/src/src/static_dependencies/noble-hashes/md5.js +242 -0
  886. package/js/src/src/static_dependencies/noble-hashes/sha1.d.ts +21 -0
  887. package/js/src/src/static_dependencies/noble-hashes/sha1.js +90 -0
  888. package/js/src/src/static_dependencies/noble-hashes/sha256.d.ts +34 -0
  889. package/js/src/src/static_dependencies/noble-hashes/sha256.js +129 -0
  890. package/js/src/src/static_dependencies/noble-hashes/sha3.d.ts +97 -0
  891. package/js/src/src/static_dependencies/noble-hashes/sha3.js +211 -0
  892. package/js/src/src/static_dependencies/noble-hashes/sha512.d.ts +66 -0
  893. package/js/src/src/static_dependencies/noble-hashes/sha512.js +236 -0
  894. package/js/src/src/static_dependencies/noble-hashes/utils.d.ts +77 -0
  895. package/js/src/src/static_dependencies/noble-hashes/utils.js +147 -0
  896. package/js/src/src/static_dependencies/proxies/agent-base/helpers.d.ts +14 -0
  897. package/js/src/src/static_dependencies/proxies/agent-base/helpers.js +42 -0
  898. package/js/src/src/static_dependencies/proxies/agent-base/index.d.ts +33 -0
  899. package/js/src/src/static_dependencies/proxies/agent-base/index.js +82 -0
  900. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.d.ts +40 -0
  901. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.js +119 -0
  902. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.d.ts +45 -0
  903. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.js +150 -0
  904. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.d.ts +15 -0
  905. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  906. package/js/src/src/static_dependencies/qs/formats.cjs +22 -0
  907. package/js/src/src/static_dependencies/qs/formats.d.cts +14 -0
  908. package/js/src/src/static_dependencies/qs/index.cjs +15 -0
  909. package/js/src/src/static_dependencies/qs/index.d.cts +10 -0
  910. package/js/src/src/static_dependencies/qs/parse.cjs +208 -0
  911. package/js/src/src/static_dependencies/qs/parse.d.cts +8 -0
  912. package/js/src/src/static_dependencies/qs/stringify.cjs +192 -0
  913. package/js/src/src/static_dependencies/qs/stringify.d.cts +8 -0
  914. package/js/src/src/static_dependencies/qs/utils.cjs +202 -0
  915. package/js/src/src/static_dependencies/qs/utils.d.cts +15 -0
  916. package/js/src/src/static_dependencies/scure-base/index.d.ts +92 -0
  917. package/js/src/src/static_dependencies/scure-base/index.js +420 -0
  918. package/js/src/src/static_dependencies/scure-starknet/index.d.ts +79 -0
  919. package/js/src/src/static_dependencies/scure-starknet/index.js +323 -0
  920. package/js/src/src/static_dependencies/starknet/constants.d.ts +61 -0
  921. package/js/src/src/static_dependencies/starknet/constants.js +67 -0
  922. package/js/src/src/static_dependencies/starknet/index.d.ts +3 -0
  923. package/js/src/src/static_dependencies/starknet/index.js +9 -0
  924. package/js/src/src/static_dependencies/starknet/types/cairoEnum.d.ts +2 -0
  925. package/js/src/src/static_dependencies/starknet/types/cairoEnum.js +7 -0
  926. package/js/src/src/static_dependencies/starknet/types/calldata.d.ts +19 -0
  927. package/js/src/src/static_dependencies/starknet/types/calldata.js +28 -0
  928. package/js/src/src/static_dependencies/starknet/types/index.d.ts +13 -0
  929. package/js/src/src/static_dependencies/starknet/types/index.js +16 -0
  930. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.d.ts +71 -0
  931. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.js +13 -0
  932. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.d.ts +24 -0
  933. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.js +16 -0
  934. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.d.ts +33 -0
  935. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.js +7 -0
  936. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.d.ts +52 -0
  937. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.js +7 -0
  938. package/js/src/src/static_dependencies/starknet/types/lib/index.d.ts +248 -0
  939. package/js/src/src/static_dependencies/starknet/types/lib/index.js +52 -0
  940. package/js/src/src/static_dependencies/starknet/types/typedData.d.ts +44 -0
  941. package/js/src/src/static_dependencies/starknet/types/typedData.js +19 -0
  942. package/js/src/src/static_dependencies/starknet/utils/assert.d.ts +7 -0
  943. package/js/src/src/static_dependencies/starknet/utils/assert.js +17 -0
  944. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.d.ts +6 -0
  945. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +43 -0
  946. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.d.ts +72 -0
  947. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +117 -0
  948. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.d.ts +76 -0
  949. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +136 -0
  950. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.d.ts +32 -0
  951. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.js +59 -0
  952. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.d.ts +183 -0
  953. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.js +229 -0
  954. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
  955. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
  956. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.d.ts +35 -0
  957. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
  958. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.d.ts +34 -0
  959. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
  960. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.d.ts +3 -0
  961. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.js +9 -0
  962. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.d.ts +9 -0
  963. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.js +67 -0
  964. package/js/src/src/static_dependencies/starknet/utils/calldata/index.d.ts +89 -0
  965. package/js/src/src/static_dependencies/starknet/utils/calldata/index.js +280 -0
  966. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -0
  967. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.js +30 -0
  968. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.d.ts +20 -0
  969. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.js +8 -0
  970. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
  971. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +36 -0
  972. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
  973. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
  974. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.d.ts +2 -0
  975. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +155 -0
  976. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.d.ts +11 -0
  977. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.js +248 -0
  978. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.d.ts +11 -0
  979. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.js +214 -0
  980. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.d.ts +6 -0
  981. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.js +113 -0
  982. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.d.ts +6 -0
  983. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.js +208 -0
  984. package/js/src/src/static_dependencies/starknet/utils/encode.d.ts +207 -0
  985. package/js/src/src/static_dependencies/starknet/utils/encode.js +282 -0
  986. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.d.ts +57 -0
  987. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.js +223 -0
  988. package/js/src/src/static_dependencies/starknet/utils/hash/index.d.ts +6 -0
  989. package/js/src/src/static_dependencies/starknet/utils/hash/index.js +13 -0
  990. package/js/src/src/static_dependencies/starknet/utils/merkle.d.ts +35 -0
  991. package/js/src/src/static_dependencies/starknet/utils/merkle.js +84 -0
  992. package/js/src/src/static_dependencies/starknet/utils/num.d.ts +182 -0
  993. package/js/src/src/static_dependencies/starknet/utils/num.js +244 -0
  994. package/js/src/src/static_dependencies/starknet/utils/selector.d.ts +48 -0
  995. package/js/src/src/static_dependencies/starknet/utils/selector.js +85 -0
  996. package/js/src/src/static_dependencies/starknet/utils/shortString.d.ts +57 -0
  997. package/js/src/src/static_dependencies/starknet/utils/shortString.js +96 -0
  998. package/js/src/src/static_dependencies/starknet/utils/typedData.d.ts +54 -0
  999. package/js/src/src/static_dependencies/starknet/utils/typedData.js +321 -0
  1000. package/js/src/src/static_dependencies/watchable/src/types.d.ts +28 -0
  1001. package/js/src/src/static_dependencies/watchable/src/types.js +8 -0
  1002. package/js/src/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
  1003. package/js/src/src/static_dependencies/watchable/src/unpromise.js +297 -0
  1004. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  1005. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  1006. package/js/src/src/tabdeal.d.ts +23 -0
  1007. package/js/src/src/tabdeal.js +387 -0
  1008. package/js/src/src/tehran_exchange.d.ts +21 -0
  1009. package/js/src/src/tehran_exchange.js +333 -0
  1010. package/js/src/src/tetherland.d.ts +21 -0
  1011. package/js/src/src/tetherland.js +367 -0
  1012. package/js/src/src/timex.d.ts +247 -0
  1013. package/js/src/src/timex.js +1792 -0
  1014. package/js/src/src/tokocrypto.d.ts +261 -0
  1015. package/js/src/src/tokocrypto.js +2641 -0
  1016. package/js/src/src/toobit.d.ts +22 -0
  1017. package/js/src/src/toobit.js +445 -0
  1018. package/js/src/src/tradeogre.d.ts +149 -0
  1019. package/js/src/src/tradeogre.js +878 -0
  1020. package/js/src/src/twox.d.ts +21 -0
  1021. package/js/src/src/twox.js +371 -0
  1022. package/js/src/src/ubitex.d.ts +23 -0
  1023. package/js/src/src/ubitex.js +433 -0
  1024. package/js/src/src/upbit.d.ts +377 -0
  1025. package/js/src/src/upbit.js +2340 -0
  1026. package/js/src/src/vertex.d.ts +346 -0
  1027. package/js/src/src/vertex.js +3146 -0
  1028. package/js/src/src/wallex.d.ts +23 -0
  1029. package/js/src/src/wallex.js +467 -0
  1030. package/js/src/src/wavesexchange.d.ts +244 -0
  1031. package/js/src/src/wavesexchange.js +2747 -0
  1032. package/js/src/src/whitebit.d.ts +571 -0
  1033. package/js/src/src/whitebit.js +3437 -0
  1034. package/js/src/src/woo.d.ts +727 -0
  1035. package/js/src/src/woo.js +4183 -0
  1036. package/js/src/src/woofipro.d.ts +497 -0
  1037. package/js/src/src/woofipro.js +2941 -0
  1038. package/js/src/src/xt.d.ts +568 -0
  1039. package/js/src/src/xt.js +5184 -0
  1040. package/js/src/src/yobit.d.ts +197 -0
  1041. package/js/src/src/yobit.js +1453 -0
  1042. package/js/src/src/zaif.d.ts +136 -0
  1043. package/js/src/src/zaif.js +821 -0
  1044. package/js/src/src/zonda.d.ts +214 -0
  1045. package/js/src/src/zonda.js +1984 -0
  1046. package/js/test.js +3 -3
  1047. package/package.json +1 -1
@@ -0,0 +1,3437 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/whitebit.js';
9
+ import { ExchangeNotAvailable, ExchangeError, DDoSProtection, BadSymbol, InvalidOrder, ArgumentsRequired, AuthenticationError, OrderNotFound, PermissionDenied, InsufficientFunds, BadRequest, NotSupported } from './base/errors.js';
10
+ import { Precise } from './base/Precise.js';
11
+ import { TICK_SIZE } from './base/functions/number.js';
12
+ import { sha512 } from './static_dependencies/noble-hashes/sha512.js';
13
+ // ---------------------------------------------------------------------------
14
+ /**
15
+ * @class whitebit
16
+ * @augments Exchange
17
+ */
18
+ export default class whitebit extends Exchange {
19
+ describe() {
20
+ return this.deepExtend(super.describe(), {
21
+ 'id': 'whitebit',
22
+ 'name': 'WhiteBit',
23
+ 'version': 'v4',
24
+ 'countries': ['EE'],
25
+ 'rateLimit': 50,
26
+ 'pro': true,
27
+ 'has': {
28
+ 'CORS': undefined,
29
+ 'spot': true,
30
+ 'margin': true,
31
+ 'swap': true,
32
+ 'future': false,
33
+ 'option': false,
34
+ 'cancelAllOrders': true,
35
+ 'cancelAllOrdersAfter': true,
36
+ 'cancelOrder': true,
37
+ 'cancelOrders': false,
38
+ 'createConvertTrade': true,
39
+ 'createDepositAddress': true,
40
+ 'createMarketBuyOrderWithCost': true,
41
+ 'createMarketOrderWithCost': false,
42
+ 'createMarketSellOrderWithCost': false,
43
+ 'createOrder': true,
44
+ 'createPostOnlyOrder': true,
45
+ 'createStopLimitOrder': true,
46
+ 'createStopMarketOrder': true,
47
+ 'createStopOrder': true,
48
+ 'createTriggerOrder': true,
49
+ 'editOrder': false,
50
+ 'fetchBalance': true,
51
+ 'fetchBorrowRateHistories': false,
52
+ 'fetchBorrowRateHistory': false,
53
+ 'fetchClosedOrders': true,
54
+ 'fetchConvertQuote': true,
55
+ 'fetchConvertTrade': false,
56
+ 'fetchConvertTradeHistory': true,
57
+ 'fetchCrossBorrowRate': true,
58
+ 'fetchCrossBorrowRates': false,
59
+ 'fetchCurrencies': true,
60
+ 'fetchDeposit': true,
61
+ 'fetchDepositAddress': true,
62
+ 'fetchDepositAddresses': false,
63
+ 'fetchDepositAddressesByNetwork': false,
64
+ 'fetchDeposits': true,
65
+ 'fetchDepositsWithdrawals': true,
66
+ 'fetchDepositWithdrawFee': 'emulated',
67
+ 'fetchDepositWithdrawFees': true,
68
+ 'fetchFundingHistory': true,
69
+ 'fetchFundingRate': true,
70
+ 'fetchFundingRateHistory': false,
71
+ 'fetchFundingRates': true,
72
+ 'fetchIndexOHLCV': false,
73
+ 'fetchIsolatedBorrowRate': false,
74
+ 'fetchIsolatedBorrowRates': false,
75
+ 'fetchMarginMode': false,
76
+ 'fetchMarkets': true,
77
+ 'fetchMarkOHLCV': false,
78
+ 'fetchMyTrades': true,
79
+ 'fetchOHLCV': true,
80
+ 'fetchOpenInterestHistory': false,
81
+ 'fetchOpenOrders': true,
82
+ 'fetchOrderBook': true,
83
+ 'fetchOrderTrades': true,
84
+ 'fetchPosition': true,
85
+ 'fetchPositionHistory': true,
86
+ 'fetchPositionMode': false,
87
+ 'fetchPositions': true,
88
+ 'fetchPremiumIndexOHLCV': false,
89
+ 'fetchStatus': true,
90
+ 'fetchTicker': true,
91
+ 'fetchTickers': true,
92
+ 'fetchTime': true,
93
+ 'fetchTrades': true,
94
+ 'fetchTradingFee': false,
95
+ 'fetchTradingFees': true,
96
+ 'fetchTransactionFees': true,
97
+ 'repayCrossMargin': false,
98
+ 'repayIsolatedMargin': false,
99
+ 'setLeverage': true,
100
+ 'transfer': true,
101
+ 'withdraw': true,
102
+ },
103
+ 'timeframes': {
104
+ '1m': '1m',
105
+ '3m': '3m',
106
+ '5m': '5m',
107
+ '15m': '15m',
108
+ '30m': '30m',
109
+ '1h': '1h',
110
+ '2h': '2h',
111
+ '4h': '4h',
112
+ '6h': '6h',
113
+ '8h': '8h',
114
+ '12h': '12h',
115
+ '1d': '1d',
116
+ '3d': '3d',
117
+ '1w': '1w',
118
+ '1M': '1M',
119
+ },
120
+ 'urls': {
121
+ 'logo': 'https://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpg',
122
+ 'api': {
123
+ 'v1': {
124
+ 'public': 'https://whitebit.com/api/v1/public',
125
+ 'private': 'https://whitebit.com/api/v1',
126
+ },
127
+ 'v2': {
128
+ 'public': 'https://whitebit.com/api/v2/public',
129
+ },
130
+ 'v4': {
131
+ 'public': 'https://whitebit.com/api/v4/public',
132
+ 'private': 'https://whitebit.com/api/v4',
133
+ },
134
+ },
135
+ 'www': 'https://www.whitebit.com',
136
+ 'doc': 'https://github.com/whitebit-exchange/api-docs',
137
+ 'fees': 'https://whitebit.com/fee-schedule',
138
+ 'referral': 'https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963',
139
+ },
140
+ 'api': {
141
+ 'web': {
142
+ 'get': [
143
+ 'v1/healthcheck',
144
+ ],
145
+ },
146
+ 'v1': {
147
+ 'public': {
148
+ 'get': [
149
+ 'markets',
150
+ 'tickers',
151
+ 'ticker',
152
+ 'symbols',
153
+ 'depth/result',
154
+ 'history',
155
+ 'kline',
156
+ ],
157
+ },
158
+ 'private': {
159
+ 'post': [
160
+ 'account/balance',
161
+ 'order/new',
162
+ 'order/cancel',
163
+ 'orders',
164
+ 'account/order_history',
165
+ 'account/executed_history',
166
+ 'account/executed_history/all',
167
+ 'account/order',
168
+ ],
169
+ },
170
+ },
171
+ 'v2': {
172
+ 'public': {
173
+ 'get': [
174
+ 'markets',
175
+ 'ticker',
176
+ 'assets',
177
+ 'fee',
178
+ 'depth/{market}',
179
+ 'trades/{market}',
180
+ ],
181
+ },
182
+ },
183
+ 'v4': {
184
+ 'public': {
185
+ 'get': [
186
+ 'assets',
187
+ 'collateral/markets',
188
+ 'fee',
189
+ 'orderbook/depth/{market}',
190
+ 'orderbook/{market}',
191
+ 'ticker',
192
+ 'trades/{market}',
193
+ 'time',
194
+ 'ping',
195
+ 'markets',
196
+ 'futures',
197
+ 'platform/status',
198
+ 'mining-pool',
199
+ ],
200
+ },
201
+ 'private': {
202
+ 'post': [
203
+ 'collateral-account/balance',
204
+ 'collateral-account/balance-summary',
205
+ 'collateral-account/positions/history',
206
+ 'collateral-account/leverage',
207
+ 'collateral-account/positions/open',
208
+ 'collateral-account/summary',
209
+ 'collateral-account/funding-history',
210
+ 'main-account/address',
211
+ 'main-account/balance',
212
+ 'main-account/create-new-address',
213
+ 'main-account/codes',
214
+ 'main-account/codes/apply',
215
+ 'main-account/codes/my',
216
+ 'main-account/codes/history',
217
+ 'main-account/fiat-deposit-url',
218
+ 'main-account/history',
219
+ 'main-account/withdraw',
220
+ 'main-account/withdraw-pay',
221
+ 'main-account/transfer',
222
+ 'main-account/smart/plans',
223
+ 'main-account/smart/investment',
224
+ 'main-account/smart/investment/close',
225
+ 'main-account/smart/investments',
226
+ 'main-account/fee',
227
+ 'main-account/smart/interest-payment-history',
228
+ 'trade-account/balance',
229
+ 'trade-account/executed-history',
230
+ 'trade-account/order',
231
+ 'trade-account/order/history',
232
+ 'order/collateral/limit',
233
+ 'order/collateral/market',
234
+ 'order/collateral/stop-limit',
235
+ 'order/collateral/trigger-market',
236
+ 'order/collateral/bulk',
237
+ 'order/new',
238
+ 'order/market',
239
+ 'order/stock_market',
240
+ 'order/stop_limit',
241
+ 'order/stop_market',
242
+ 'order/cancel',
243
+ 'order/cancel/all',
244
+ 'order/kill-switch',
245
+ 'order/kill-switch/status',
246
+ 'order/bulk',
247
+ 'order/modify',
248
+ 'order/conditional-cancel',
249
+ 'orders',
250
+ 'oco-orders',
251
+ 'order/collateral/oco',
252
+ 'order/oco-cancel',
253
+ 'order/oto-cancel',
254
+ 'profile/websocket_token',
255
+ 'convert/estimate',
256
+ 'convert/confirm',
257
+ 'convert/history',
258
+ 'sub-account/create',
259
+ 'sub-account/delete',
260
+ 'sub-account/edit',
261
+ 'sub-account/list',
262
+ 'sub-account/transfer',
263
+ 'sub-account/block',
264
+ 'sub-account/unblock',
265
+ 'sub-account/balances',
266
+ 'sub-account/transfer/history',
267
+ 'sub-account/api-key/create',
268
+ 'sub-account/api-key/edit',
269
+ 'sub-account/api-key/delete',
270
+ 'sub-account/api-key/list',
271
+ 'sub-account/api-key/reset',
272
+ 'sub-account/api-key/ip-address/list',
273
+ 'sub-account/api-key/ip-address/create',
274
+ 'sub-account/api-key/ip-address/delete',
275
+ 'mining/rewards',
276
+ 'market/fee',
277
+ 'conditional-orders',
278
+ ],
279
+ },
280
+ },
281
+ },
282
+ 'fees': {
283
+ 'trading': {
284
+ 'tierBased': false,
285
+ 'percentage': true,
286
+ 'taker': this.parseNumber('0.001'),
287
+ 'maker': this.parseNumber('0.001'),
288
+ },
289
+ },
290
+ 'options': {
291
+ 'timeDifference': 0,
292
+ 'adjustForTimeDifference': false,
293
+ 'fiatCurrencies': ['EUR', 'USD', 'RUB', 'UAH'],
294
+ 'fetchBalance': {
295
+ 'account': 'spot',
296
+ },
297
+ 'accountsByType': {
298
+ 'funding': 'main',
299
+ 'main': 'main',
300
+ 'spot': 'spot',
301
+ 'margin': 'collateral',
302
+ 'trade': 'spot',
303
+ },
304
+ 'networksById': {
305
+ 'BEP20': 'BSC',
306
+ },
307
+ 'defaultType': 'spot',
308
+ 'brokerId': 'ccxt',
309
+ },
310
+ 'features': {
311
+ 'default': {
312
+ 'sandbox': false,
313
+ 'createOrder': {
314
+ 'marginMode': true,
315
+ 'triggerPrice': true,
316
+ 'triggerDirection': false,
317
+ 'triggerPriceType': undefined,
318
+ 'stopLossPrice': false,
319
+ 'takeProfitPrice': false,
320
+ 'attachedStopLossTakeProfit': undefined,
321
+ 'timeInForce': {
322
+ 'IOC': true,
323
+ 'FOK': false,
324
+ 'PO': true,
325
+ 'GTD': false,
326
+ },
327
+ 'hedged': false,
328
+ 'trailing': false,
329
+ 'leverage': false,
330
+ 'marketBuyByCost': true,
331
+ 'marketBuyRequiresPrice': false,
332
+ 'selfTradePrevention': false,
333
+ 'iceberg': false,
334
+ },
335
+ 'createOrders': undefined,
336
+ 'fetchMyTrades': {
337
+ 'marginMode': false,
338
+ 'limit': 100,
339
+ 'daysBack': undefined,
340
+ 'untilDays': undefined,
341
+ 'symbolRequired': false,
342
+ },
343
+ 'fetchOrder': undefined,
344
+ 'fetchOpenOrders': {
345
+ 'marginMode': false,
346
+ 'limit': 100,
347
+ 'trigger': false,
348
+ 'trailing': false,
349
+ 'symbolRequired': false,
350
+ },
351
+ 'fetchOrders': undefined,
352
+ 'fetchClosedOrders': {
353
+ 'marginMode': false,
354
+ 'limit': 100,
355
+ 'daysBack': undefined,
356
+ 'daysBackCanceled': undefined,
357
+ 'untilDays': undefined,
358
+ 'trigger': false,
359
+ 'trailing': false,
360
+ 'symbolRequired': false,
361
+ },
362
+ 'fetchOHLCV': {
363
+ 'limit': 1440,
364
+ },
365
+ },
366
+ 'spot': {
367
+ 'extends': 'default',
368
+ },
369
+ 'swap': {
370
+ 'linear': {
371
+ 'extends': 'default',
372
+ },
373
+ 'inverse': {
374
+ 'extends': 'default',
375
+ },
376
+ },
377
+ 'future': {
378
+ 'linear': undefined,
379
+ 'inverse': undefined,
380
+ },
381
+ },
382
+ 'precisionMode': TICK_SIZE,
383
+ 'exceptions': {
384
+ 'exact': {
385
+ 'Unauthorized request.': AuthenticationError,
386
+ 'The market format is invalid.': BadSymbol,
387
+ 'Market is not available': BadSymbol,
388
+ 'Invalid payload.': BadRequest,
389
+ 'Amount must be greater than 0': InvalidOrder,
390
+ 'Not enough balance.': InsufficientFunds,
391
+ 'The order id field is required.': InvalidOrder,
392
+ 'Not enough balance': InsufficientFunds,
393
+ 'This action is unauthorized.': PermissionDenied,
394
+ 'This API Key is not authorized to perform this action.': PermissionDenied,
395
+ 'Unexecuted order was not found.': OrderNotFound,
396
+ 'The selected from is invalid.': BadRequest,
397
+ '503': ExchangeNotAvailable,
398
+ '422': OrderNotFound, // {"response":null,"status":422,"errors":{"orderId":["Finished order id 1295772653 not found on your account"]},"notification":null,"warning":"Finished order id 1295772653 not found on your account","_token":null}
399
+ },
400
+ 'broad': {
401
+ 'This action is unauthorized': PermissionDenied,
402
+ 'Given amount is less than min amount': InvalidOrder,
403
+ 'Min amount step': InvalidOrder,
404
+ 'Total is less than': InvalidOrder,
405
+ 'fee must be no less than': InvalidOrder,
406
+ 'Enable your key in API settings': PermissionDenied,
407
+ 'You don\'t have such amount for transfer': InsufficientFunds, // {"code":3,"message":"Inner validation failed","errors":{"amount":["You don't have such amount for transfer (available 0.44523433, in amount: 2)"]}}
408
+ },
409
+ },
410
+ });
411
+ }
412
+ /**
413
+ * @method
414
+ * @name whitebit#fetchMarkets
415
+ * @description retrieves data on all markets for whitebit
416
+ * @see https://docs.whitebit.com/public/http-v4/#market-info
417
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
418
+ * @returns {object[]} an array of objects representing market data
419
+ */
420
+ async fetchMarkets(params = {}) {
421
+ if (this.options['adjustForTimeDifference']) {
422
+ await this.loadTimeDifference();
423
+ }
424
+ const markets = await this.v4PublicGetMarkets();
425
+ //
426
+ // [
427
+ // {
428
+ // "name": "SON_USD", // Market pair name
429
+ // "stock": "SON", // Ticker of stock currency
430
+ // "money": "USD", // Ticker of money currency
431
+ // "stockPrec": "3", // Stock currency precision
432
+ // "moneyPrec": "2", // Precision of money currency
433
+ // "feePrec": "4", // Fee precision
434
+ // "makerFee": "0.1", // Default maker fee ratio
435
+ // "takerFee": "0.1", // Default taker fee ratio
436
+ // "minAmount": "0.001", // Minimal amount of stock to trade
437
+ // "minTotal": "0.001", // Minimal amount of money to trade
438
+ // "tradesEnabled": true, // Is trading enabled
439
+ // "isCollateral": true, // Is margin trading enabled
440
+ // "type": "spot", // Market type. Possible values: "spot", "futures"
441
+ // "maxTotal": "1000000000" // Maximum total(amount * price) of money to trade
442
+ // },
443
+ // {
444
+ // ...
445
+ // }
446
+ // ]
447
+ //
448
+ return this.parseMarkets(markets);
449
+ }
450
+ parseMarket(market) {
451
+ const id = this.safeString(market, 'name');
452
+ const baseId = this.safeString(market, 'stock');
453
+ let quoteId = this.safeString(market, 'money');
454
+ quoteId = (quoteId === 'PERP') ? 'USDT' : quoteId;
455
+ const base = this.safeCurrencyCode(baseId);
456
+ const quote = this.safeCurrencyCode(quoteId);
457
+ const active = this.safeValue(market, 'tradesEnabled');
458
+ const isCollateral = this.safeValue(market, 'isCollateral');
459
+ const typeId = this.safeString(market, 'type');
460
+ let type;
461
+ let settle = undefined;
462
+ let settleId = undefined;
463
+ let symbol = base + '/' + quote;
464
+ const swap = typeId === 'futures';
465
+ const margin = isCollateral && !swap;
466
+ let contract = false;
467
+ const amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'stockPrec')));
468
+ const contractSize = amountPrecision;
469
+ let linear = undefined;
470
+ let inverse = undefined;
471
+ if (swap) {
472
+ settleId = quoteId;
473
+ settle = this.safeCurrencyCode(settleId);
474
+ symbol = symbol + ':' + settle;
475
+ type = 'swap';
476
+ contract = true;
477
+ linear = true;
478
+ inverse = false;
479
+ }
480
+ else {
481
+ type = 'spot';
482
+ }
483
+ const takerFeeRate = this.safeString(market, 'takerFee');
484
+ const taker = Precise.stringDiv(takerFeeRate, '100');
485
+ const makerFeeRate = this.safeString(market, 'makerFee');
486
+ const maker = Precise.stringDiv(makerFeeRate, '100');
487
+ return {
488
+ 'id': id,
489
+ 'symbol': symbol,
490
+ 'base': base,
491
+ 'quote': quote,
492
+ 'settle': settle,
493
+ 'baseId': baseId,
494
+ 'quoteId': quoteId,
495
+ 'settleId': settleId,
496
+ 'type': type,
497
+ 'spot': !swap,
498
+ 'margin': margin,
499
+ 'swap': swap,
500
+ 'future': false,
501
+ 'option': false,
502
+ 'active': active,
503
+ 'contract': contract,
504
+ 'linear': linear,
505
+ 'inverse': inverse,
506
+ 'taker': this.parseNumber(taker),
507
+ 'maker': this.parseNumber(maker),
508
+ 'contractSize': contractSize,
509
+ 'expiry': undefined,
510
+ 'expiryDatetime': undefined,
511
+ 'strike': undefined,
512
+ 'optionType': undefined,
513
+ 'precision': {
514
+ 'amount': amountPrecision,
515
+ 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'moneyPrec'))),
516
+ },
517
+ 'limits': {
518
+ 'leverage': {
519
+ 'min': undefined,
520
+ 'max': undefined,
521
+ },
522
+ 'amount': {
523
+ 'min': this.safeNumber(market, 'minAmount'),
524
+ 'max': undefined,
525
+ },
526
+ 'price': {
527
+ 'min': undefined,
528
+ 'max': undefined,
529
+ },
530
+ 'cost': {
531
+ 'min': this.safeNumber(market, 'minTotal'),
532
+ 'max': this.safeNumber(market, 'maxTotal'),
533
+ },
534
+ },
535
+ 'created': undefined,
536
+ 'info': market,
537
+ };
538
+ }
539
+ /**
540
+ * @method
541
+ * @name whitebit#fetchCurrencies
542
+ * @description fetches all available currencies on an exchange
543
+ * @see https://docs.whitebit.com/public/http-v4/#asset-status-list
544
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
545
+ * @returns {object} an associative dictionary of currencies
546
+ */
547
+ async fetchCurrencies(params = {}) {
548
+ const response = await this.v4PublicGetAssets(params);
549
+ //
550
+ // {
551
+ // BTC: {
552
+ // name: "Bitcoin",
553
+ // unified_cryptoasset_id: "1",
554
+ // can_withdraw: true,
555
+ // can_deposit: true,
556
+ // min_withdraw: "0.0003",
557
+ // max_withdraw: "0",
558
+ // maker_fee: "0.1",
559
+ // taker_fee: "0.1",
560
+ // min_deposit: "0.0001",
561
+ // max_deposit: "0",
562
+ // networks: {
563
+ // deposits: [ "BTC", ],
564
+ // withdraws: [ "BTC", ],
565
+ // default: "BTC",
566
+ // },
567
+ // confirmations: {
568
+ // BTC: "2",
569
+ // },
570
+ // limits: {
571
+ // deposit: {
572
+ // BTC: { min: "0.0001", },
573
+ // },
574
+ // withdraw: {
575
+ // BTC: { min: "0.0003", },
576
+ // },
577
+ // },
578
+ // currency_precision: "8",
579
+ // is_memo: false,
580
+ // },
581
+ // USD: {
582
+ // name: "United States Dollar",
583
+ // unified_cryptoasset_id: "6955",
584
+ // can_withdraw: true,
585
+ // can_deposit: true,
586
+ // min_withdraw: "10",
587
+ // max_withdraw: "10000",
588
+ // maker_fee: "0.1",
589
+ // taker_fee: "0.1",
590
+ // min_deposit: "10",
591
+ // max_deposit: "10000",
592
+ // networks: {
593
+ // deposits: [ "USD", ],
594
+ // withdraws: [ "USD", ],
595
+ // default: "USD",
596
+ // },
597
+ // providers: {
598
+ // deposits: [ "ADVCASH", ],
599
+ // withdraws: [ "ADVCASH", ],
600
+ // },
601
+ // limits: {
602
+ // deposit: {
603
+ // USD: { max: "10000", min: "10", },
604
+ // },
605
+ // withdraw: {
606
+ // USD: { max: "10000", min: "10", },
607
+ // },
608
+ // },
609
+ // currency_precision: "2",
610
+ // is_memo: false,
611
+ // }
612
+ // }
613
+ //
614
+ const ids = Object.keys(response);
615
+ const result = {};
616
+ for (let i = 0; i < ids.length; i++) {
617
+ const id = ids[i];
618
+ const currency = response[id];
619
+ // const name = this.safeString (currency, 'name'); // breaks down in Python due to utf8 encoding issues on the exchange side
620
+ const code = this.safeCurrencyCode(id);
621
+ const hasProvider = ('providers' in currency);
622
+ const networks = {};
623
+ const rawNetworks = this.safeDict(currency, 'networks', {});
624
+ const depositsNetworks = this.safeList(rawNetworks, 'deposits', []);
625
+ const withdrawsNetworks = this.safeList(rawNetworks, 'withdraws', []);
626
+ const networkLimits = this.safeDict(currency, 'limits', {});
627
+ const depositLimits = this.safeDict(networkLimits, 'deposit', {});
628
+ const withdrawLimits = this.safeDict(networkLimits, 'withdraw', {});
629
+ const allNetworks = this.arrayConcat(depositsNetworks, withdrawsNetworks);
630
+ for (let j = 0; j < allNetworks.length; j++) {
631
+ const networkId = allNetworks[j];
632
+ const networkCode = this.networkIdToCode(networkId);
633
+ networks[networkCode] = {
634
+ 'id': networkId,
635
+ 'network': networkCode,
636
+ 'active': undefined,
637
+ 'deposit': this.inArray(networkId, depositsNetworks),
638
+ 'withdraw': this.inArray(networkId, withdrawsNetworks),
639
+ 'fee': undefined,
640
+ 'precision': undefined,
641
+ 'limits': {
642
+ 'deposit': {
643
+ 'min': this.safeNumber(depositLimits, 'min', undefined),
644
+ 'max': this.safeNumber(depositLimits, 'max', undefined),
645
+ },
646
+ 'withdraw': {
647
+ 'min': this.safeNumber(withdrawLimits, 'min', undefined),
648
+ 'max': this.safeNumber(withdrawLimits, 'max', undefined),
649
+ },
650
+ },
651
+ };
652
+ }
653
+ result[code] = this.safeCurrencyStructure({
654
+ 'id': id,
655
+ 'code': code,
656
+ 'info': currency,
657
+ 'name': undefined,
658
+ 'active': undefined,
659
+ 'deposit': this.safeBool(currency, 'can_deposit'),
660
+ 'withdraw': this.safeBool(currency, 'can_withdraw'),
661
+ 'fee': undefined,
662
+ 'networks': undefined,
663
+ 'type': hasProvider ? 'fiat' : 'crypto',
664
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'currency_precision'))),
665
+ 'limits': {
666
+ 'amount': {
667
+ 'min': undefined,
668
+ 'max': undefined,
669
+ },
670
+ 'withdraw': {
671
+ 'min': this.safeNumber(currency, 'min_withdraw'),
672
+ 'max': this.safeNumber(currency, 'max_withdraw'),
673
+ },
674
+ 'deposit': {
675
+ 'min': this.safeNumber(currency, 'min_deposit'),
676
+ 'max': this.safeNumber(currency, 'max_deposit'),
677
+ },
678
+ },
679
+ });
680
+ }
681
+ return result;
682
+ }
683
+ /**
684
+ * @method
685
+ * @name whitebit#fetchTransactionFees
686
+ * @deprecated
687
+ * @description please use fetchDepositWithdrawFees instead
688
+ * @see https://docs.whitebit.com/public/http-v4/#fee
689
+ * @param {string[]|undefined} codes not used by fetchTransactionFees ()
690
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
691
+ * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
692
+ */
693
+ async fetchTransactionFees(codes = undefined, params = {}) {
694
+ await this.loadMarkets();
695
+ const response = await this.v4PublicGetFee(params);
696
+ //
697
+ // {
698
+ // "1INCH":{
699
+ // "is_depositable":true,
700
+ // "is_withdrawal":true,
701
+ // "ticker":"1INCH",
702
+ // "name":"1inch",
703
+ // "providers":[
704
+ // ],
705
+ // "withdraw":{
706
+ // "max_amount":"0",
707
+ // "min_amount":"21.5",
708
+ // "fixed":"17.5",
709
+ // "flex":null
710
+ // },
711
+ // "deposit":{
712
+ // "max_amount":"0",
713
+ // "min_amount":"19.5",
714
+ // "fixed":null,
715
+ // "flex":null
716
+ // }
717
+ // },
718
+ // {...}
719
+ // }
720
+ //
721
+ const currenciesIds = Object.keys(response);
722
+ const withdrawFees = {};
723
+ const depositFees = {};
724
+ for (let i = 0; i < currenciesIds.length; i++) {
725
+ const currency = currenciesIds[i];
726
+ const data = response[currency];
727
+ const code = this.safeCurrencyCode(currency);
728
+ const withdraw = this.safeValue(data, 'withdraw', {});
729
+ withdrawFees[code] = this.safeString(withdraw, 'fixed');
730
+ const deposit = this.safeValue(data, 'deposit', {});
731
+ depositFees[code] = this.safeString(deposit, 'fixed');
732
+ }
733
+ return {
734
+ 'withdraw': withdrawFees,
735
+ 'deposit': depositFees,
736
+ 'info': response,
737
+ };
738
+ }
739
+ /**
740
+ * @method
741
+ * @name whitebit#fetchDepositWithdrawFees
742
+ * @description fetch deposit and withdraw fees
743
+ * @see https://docs.whitebit.com/public/http-v4/#fee
744
+ * @param {string[]|undefined} codes not used by fetchDepositWithdrawFees ()
745
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
746
+ * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
747
+ */
748
+ async fetchDepositWithdrawFees(codes = undefined, params = {}) {
749
+ await this.loadMarkets();
750
+ const response = await this.v4PublicGetFee(params);
751
+ //
752
+ // {
753
+ // "1INCH": {
754
+ // "is_depositable": true,
755
+ // "is_withdrawal": true,
756
+ // "ticker": "1INCH",
757
+ // "name": "1inch",
758
+ // "providers": [],
759
+ // "withdraw": {
760
+ // "max_amount": "0",
761
+ // "min_amount": "21.5",
762
+ // "fixed": "17.5",
763
+ // "flex": null
764
+ // },
765
+ // "deposit": {
766
+ // "max_amount": "0",
767
+ // "min_amount": "19.5",
768
+ // "fixed": null,
769
+ // "flex": null
770
+ // }
771
+ // },
772
+ // "WBT (ERC20)": {
773
+ // "is_depositable": true,
774
+ // "is_withdrawal": true,
775
+ // "ticker": "WBT",
776
+ // "name": "WhiteBIT Token",
777
+ // "providers": [],
778
+ // "withdraw": { max_amount: "0", min_amount: '0.7', fixed: "0.253", flex: null },
779
+ // "deposit": { max_amount: "0", min_amount: "0.35", fixed: null, flex: null }
780
+ // },
781
+ // "WBT (TRC20)": {
782
+ // "is_depositable": true,
783
+ // "is_withdrawal": true,
784
+ // "ticker": "WBT",
785
+ // "name": "WhiteBIT Token",
786
+ // "providers": [],
787
+ // "withdraw": { max_amount: "0", min_amount: "1.5", fixed: "0.075", flex: null },
788
+ // "deposit": { max_amount: "0", min_amount: "0.75", fixed: null, flex: null }
789
+ // },
790
+ // ...
791
+ // }
792
+ //
793
+ return this.parseDepositWithdrawFees(response, codes);
794
+ }
795
+ parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
796
+ //
797
+ // {
798
+ // "1INCH": {
799
+ // "is_depositable": true,
800
+ // "is_withdrawal": true,
801
+ // "ticker": "1INCH",
802
+ // "name": "1inch",
803
+ // "providers": [],
804
+ // "withdraw": {
805
+ // "max_amount": "0",
806
+ // "min_amount": "21.5",
807
+ // "fixed": "17.5",
808
+ // "flex": null
809
+ // },
810
+ // "deposit": {
811
+ // "max_amount": "0",
812
+ // "min_amount": "19.5",
813
+ // "fixed": null,
814
+ // "flex": null
815
+ // }
816
+ // },
817
+ // "WBT (ERC20)": {
818
+ // "is_depositable": true,
819
+ // "is_withdrawal": true,
820
+ // "ticker": "WBT",
821
+ // "name": "WhiteBIT Token",
822
+ // "providers": [],
823
+ // "withdraw": { max_amount: "0", min_amount: "0.7", fixed: "0.253", flex: null },
824
+ // "deposit": { max_amount: "0", min_amount: "0.35", fixed: null, flex: null }
825
+ // },
826
+ // "WBT (TRC20)": {
827
+ // "is_depositable": true,
828
+ // "is_withdrawal": true,
829
+ // "ticker": "WBT",
830
+ // "name": "WhiteBIT Token",
831
+ // "providers": [],
832
+ // "withdraw": { max_amount: "0", min_amount: "1.5", fixed: "0.075", flex: null },
833
+ // "deposit": { max_amount: "0", min_amount: "0.75", fixed: null, flex: null }
834
+ // },
835
+ // ...
836
+ // }
837
+ //
838
+ const depositWithdrawFees = {};
839
+ codes = this.marketCodes(codes);
840
+ const currencyIds = Object.keys(response);
841
+ for (let i = 0; i < currencyIds.length; i++) {
842
+ const entry = currencyIds[i];
843
+ const splitEntry = entry.split(' ');
844
+ const currencyId = splitEntry[0];
845
+ const feeInfo = response[entry];
846
+ const code = this.safeCurrencyCode(currencyId);
847
+ if ((codes === undefined) || (this.inArray(code, codes))) {
848
+ const depositWithdrawFee = this.safeValue(depositWithdrawFees, code);
849
+ if (depositWithdrawFee === undefined) {
850
+ depositWithdrawFees[code] = this.depositWithdrawFee({});
851
+ }
852
+ depositWithdrawFees[code]['info'][entry] = feeInfo;
853
+ let networkId = this.safeString(splitEntry, 1);
854
+ const withdraw = this.safeValue(feeInfo, 'withdraw');
855
+ const deposit = this.safeValue(feeInfo, 'deposit');
856
+ const withdrawFee = this.safeNumber(withdraw, 'fixed');
857
+ const depositFee = this.safeNumber(deposit, 'fixed');
858
+ const withdrawResult = {
859
+ 'fee': withdrawFee,
860
+ 'percentage': (withdrawFee !== undefined) ? false : undefined,
861
+ };
862
+ const depositResult = {
863
+ 'fee': depositFee,
864
+ 'percentage': (depositFee !== undefined) ? false : undefined,
865
+ };
866
+ if (networkId !== undefined) {
867
+ const networkLength = networkId.length;
868
+ networkId = networkId.slice(1, networkLength - 1);
869
+ const networkCode = this.networkIdToCode(networkId);
870
+ depositWithdrawFees[code]['networks'][networkCode] = {
871
+ 'withdraw': withdrawResult,
872
+ 'deposit': depositResult,
873
+ };
874
+ }
875
+ else {
876
+ depositWithdrawFees[code]['withdraw'] = withdrawResult;
877
+ depositWithdrawFees[code]['deposit'] = depositResult;
878
+ }
879
+ }
880
+ }
881
+ const depositWithdrawCodes = Object.keys(depositWithdrawFees);
882
+ for (let i = 0; i < depositWithdrawCodes.length; i++) {
883
+ const code = depositWithdrawCodes[i];
884
+ const currency = this.currency(code);
885
+ depositWithdrawFees[code] = this.assignDefaultDepositWithdrawFees(depositWithdrawFees[code], currency);
886
+ }
887
+ return depositWithdrawFees;
888
+ }
889
+ /**
890
+ * @method
891
+ * @name whitebit#fetchTradingFees
892
+ * @description fetch the trading fees for multiple markets
893
+ * @see https://docs.whitebit.com/public/http-v4/#asset-status-list
894
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
895
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
896
+ */
897
+ async fetchTradingFees(params = {}) {
898
+ await this.loadMarkets();
899
+ const response = await this.v4PublicGetAssets(params);
900
+ //
901
+ // {
902
+ // "1INCH": {
903
+ // "name": "1inch",
904
+ // "unified_cryptoasset_id": "8104",
905
+ // "can_withdraw": true,
906
+ // "can_deposit": true,
907
+ // "min_withdraw": "33",
908
+ // "max_withdraw": "0",
909
+ // "maker_fee": "0.1",
910
+ // "taker_fee": "0.1",
911
+ // "min_deposit": "30",
912
+ // "max_deposit": "0"
913
+ // },
914
+ // ...
915
+ // }
916
+ //
917
+ const result = {};
918
+ for (let i = 0; i < this.symbols.length; i++) {
919
+ const symbol = this.symbols[i];
920
+ const market = this.market(symbol);
921
+ const fee = this.safeValue(response, market['baseId'], {});
922
+ let makerFee = this.safeString(fee, 'maker_fee');
923
+ let takerFee = this.safeString(fee, 'taker_fee');
924
+ makerFee = Precise.stringDiv(makerFee, '100');
925
+ takerFee = Precise.stringDiv(takerFee, '100');
926
+ result[symbol] = {
927
+ 'info': fee,
928
+ 'symbol': market['symbol'],
929
+ 'percentage': true,
930
+ 'tierBased': false,
931
+ 'maker': this.parseNumber(makerFee),
932
+ 'taker': this.parseNumber(takerFee),
933
+ };
934
+ }
935
+ return result;
936
+ }
937
+ /**
938
+ * @method
939
+ * @name whitebit#fetchTicker
940
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
941
+ * @see https://docs.whitebit.com/public/http-v4/#market-activity
942
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
943
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
944
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
945
+ */
946
+ async fetchTicker(symbol, params = {}) {
947
+ await this.loadMarkets();
948
+ const market = this.market(symbol);
949
+ const request = {
950
+ 'market': market['id'],
951
+ };
952
+ const response = await this.v1PublicGetTicker(this.extend(request, params));
953
+ //
954
+ // {
955
+ // "success":true,
956
+ // "message":"",
957
+ // "result": {
958
+ // "bid":"0.021979",
959
+ // "ask":"0.021996",
960
+ // "open":"0.02182",
961
+ // "high":"0.022039",
962
+ // "low":"0.02161",
963
+ // "last":"0.021987",
964
+ // "volume":"2810.267",
965
+ // "deal":"61.383565474",
966
+ // "change":"0.76",
967
+ // },
968
+ // }
969
+ //
970
+ const ticker = this.safeDict(response, 'result', {});
971
+ return this.parseTicker(ticker, market);
972
+ }
973
+ parseTicker(ticker, market = undefined) {
974
+ //
975
+ // FetchTicker (v1)
976
+ //
977
+ // {
978
+ // "bid": "0.021979",
979
+ // "ask": "0.021996",
980
+ // "open": "0.02182",
981
+ // "high": "0.022039",
982
+ // "low": "0.02161",
983
+ // "last": "0.021987",
984
+ // "volume": "2810.267",
985
+ // "deal": "61.383565474",
986
+ // "change": "0.76",
987
+ // }
988
+ //
989
+ // FetchTickers (v4)
990
+ //
991
+ // "BCH_RUB": {
992
+ // "base_id": 1831,
993
+ // "quote_id": 0,
994
+ // "last_price": "32830.21",
995
+ // "quote_volume": "1494659.8024096",
996
+ // "base_volume": "46.1083",
997
+ // "isFrozen": false,
998
+ // "change": "2.12" // in percent
999
+ // }
1000
+ //
1001
+ // WS market_update
1002
+ //
1003
+ // {
1004
+ // "open": "52853.04",
1005
+ // "close": "55913.88",
1006
+ // "high": "56272",
1007
+ // "low": "49549.67",
1008
+ // "volume": "57331.067185",
1009
+ // "deal": "3063860382.42985338",
1010
+ // "last": "55913.88",
1011
+ // "period": 86400
1012
+ // }
1013
+ // v2
1014
+ // {
1015
+ // lastUpdateTimestamp: '2025-01-02T09:16:36.000Z',
1016
+ // tradingPairs: 'ARB_USDC',
1017
+ // lastPrice: '0.7727',
1018
+ // lowestAsk: '0.7735',
1019
+ // highestBid: '0.7732',
1020
+ // baseVolume24h: '1555793.74',
1021
+ // quoteVolume24h: '1157602.622406',
1022
+ // tradesEnabled: true
1023
+ // }
1024
+ //
1025
+ const marketId = this.safeString(ticker, 'tradingPairs');
1026
+ market = this.safeMarket(marketId, market);
1027
+ // last price is provided as "last" or "last_price"
1028
+ const last = this.safeStringN(ticker, ['last', 'last_price', 'lastPrice']);
1029
+ // if "close" is provided, use it, otherwise use <last>
1030
+ const close = this.safeString(ticker, 'close', last);
1031
+ return this.safeTicker({
1032
+ 'symbol': market['symbol'],
1033
+ 'timestamp': undefined,
1034
+ 'datetime': undefined,
1035
+ 'high': this.safeString(ticker, 'high'),
1036
+ 'low': this.safeString(ticker, 'low'),
1037
+ 'bid': this.safeString2(ticker, 'bid', 'highestBid'),
1038
+ 'bidVolume': undefined,
1039
+ 'ask': this.safeString2(ticker, 'ask', 'lowestAsk'),
1040
+ 'askVolume': undefined,
1041
+ 'vwap': undefined,
1042
+ 'open': this.safeString(ticker, 'open'),
1043
+ 'close': close,
1044
+ 'last': last,
1045
+ 'previousClose': undefined,
1046
+ 'change': undefined,
1047
+ 'percentage': this.safeString(ticker, 'change'),
1048
+ 'average': undefined,
1049
+ 'baseVolume': this.safeStringN(ticker, ['base_volume', 'volume', 'baseVolume24h']),
1050
+ 'quoteVolume': this.safeStringN(ticker, ['quote_volume', 'deal', 'quoteVolume24h']),
1051
+ 'info': ticker,
1052
+ }, market);
1053
+ }
1054
+ /**
1055
+ * @method
1056
+ * @name whitebit#fetchTickers
1057
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1058
+ * @see https://docs.whitebit.com/public/http-v4/#market-activity
1059
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1060
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1061
+ * @param {string} [params.method] either v2PublicGetTicker or v4PublicGetTicker default is v4PublicGetTicker
1062
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1063
+ */
1064
+ async fetchTickers(symbols = undefined, params = {}) {
1065
+ await this.loadMarkets();
1066
+ symbols = this.marketSymbols(symbols);
1067
+ let method = 'v4PublicGetTicker';
1068
+ [method, params] = this.handleOptionAndParams(params, 'fetchTickers', 'method', method);
1069
+ let response = undefined;
1070
+ if (method === 'v4PublicGetTicker') {
1071
+ response = await this.v4PublicGetTicker(params);
1072
+ }
1073
+ else {
1074
+ response = await this.v2PublicGetTicker(params);
1075
+ }
1076
+ //
1077
+ // "BCH_RUB": {
1078
+ // "base_id":1831,
1079
+ // "quote_id":0,
1080
+ // "last_price":"32830.21",
1081
+ // "quote_volume":"1494659.8024096",
1082
+ // "base_volume":"46.1083",
1083
+ // "isFrozen":false,
1084
+ // "change":"2.12"
1085
+ // },
1086
+ //
1087
+ const resultList = this.safeList(response, 'result');
1088
+ if (resultList !== undefined) {
1089
+ return this.parseTickers(resultList, symbols);
1090
+ }
1091
+ const marketIds = Object.keys(response);
1092
+ const result = {};
1093
+ for (let i = 0; i < marketIds.length; i++) {
1094
+ const marketId = marketIds[i];
1095
+ const market = this.safeMarket(marketId);
1096
+ const ticker = this.parseTicker(response[marketId], market);
1097
+ const symbol = ticker['symbol'];
1098
+ result[symbol] = ticker;
1099
+ }
1100
+ return this.filterByArrayTickers(result, 'symbol', symbols);
1101
+ }
1102
+ /**
1103
+ * @method
1104
+ * @name whitebit#fetchOrderBook
1105
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1106
+ * @see https://docs.whitebit.com/public/http-v4/#orderbook
1107
+ * @param {string} symbol unified symbol of the market to fetch the order book for
1108
+ * @param {int} [limit] the maximum amount of order book entries to return
1109
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1110
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1111
+ */
1112
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
1113
+ await this.loadMarkets();
1114
+ const market = this.market(symbol);
1115
+ const request = {
1116
+ 'market': market['id'],
1117
+ };
1118
+ if (limit !== undefined) {
1119
+ request['limit'] = limit; // default = 100, maximum = 100
1120
+ }
1121
+ const response = await this.v4PublicGetOrderbookMarket(this.extend(request, params));
1122
+ //
1123
+ // {
1124
+ // "timestamp": 1594391413,
1125
+ // "asks": [
1126
+ // [
1127
+ // "9184.41",
1128
+ // "0.773162"
1129
+ // ],
1130
+ // [ ... ]
1131
+ // ],
1132
+ // "bids": [
1133
+ // [
1134
+ // "9181.19",
1135
+ // "0.010873"
1136
+ // ],
1137
+ // [ ... ]
1138
+ // ]
1139
+ // }
1140
+ //
1141
+ const timestamp = this.safeTimestamp(response, 'timestamp');
1142
+ return this.parseOrderBook(response, symbol, timestamp);
1143
+ }
1144
+ /**
1145
+ * @method
1146
+ * @name whitebit#fetchTrades
1147
+ * @description get the list of most recent trades for a particular symbol
1148
+ * @see https://docs.whitebit.com/public/http-v4/#recent-trades
1149
+ * @param {string} symbol unified symbol of the market to fetch trades for
1150
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1151
+ * @param {int} [limit] the maximum amount of trades to fetch
1152
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1153
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1154
+ */
1155
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1156
+ await this.loadMarkets();
1157
+ const market = this.market(symbol);
1158
+ const request = {
1159
+ 'market': market['id'],
1160
+ };
1161
+ const response = await this.v4PublicGetTradesMarket(this.extend(request, params));
1162
+ //
1163
+ // [
1164
+ // {
1165
+ // "tradeID": 158056419,
1166
+ // "price": "9186.13",
1167
+ // "quote_volume": "0.0021",
1168
+ // "base_volume": "9186.13",
1169
+ // "trade_timestamp": 1594391747,
1170
+ // "type": "sell"
1171
+ // },
1172
+ // ],
1173
+ //
1174
+ return this.parseTrades(response, market, since, limit);
1175
+ }
1176
+ /**
1177
+ * @method
1178
+ * @name whitebit#fetchMyTrades
1179
+ * @description fetch all trades made by the user
1180
+ * @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-history
1181
+ * @param {string} symbol unified symbol of the market to fetch trades for
1182
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1183
+ * @param {int} [limit] the maximum amount of trades to fetch
1184
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1185
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1186
+ */
1187
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1188
+ await this.loadMarkets();
1189
+ let market = undefined;
1190
+ const request = {};
1191
+ if (symbol !== undefined) {
1192
+ market = this.market(symbol);
1193
+ request['market'] = market['id'];
1194
+ }
1195
+ const response = await this.v4PrivatePostTradeAccountExecutedHistory(this.extend(request, params));
1196
+ //
1197
+ // when no symbol is provided
1198
+ //
1199
+ // {
1200
+ // "USDC_USDT":[
1201
+ // {
1202
+ // "id":"1343815269",
1203
+ // "clientOrderId":"",
1204
+ // "time":"1641051917.532965",
1205
+ // "side":"sell",
1206
+ // "role":"2",
1207
+ // "amount":"9.986",
1208
+ // "price":"0.9995",
1209
+ // "deal":"9.981007",
1210
+ // "fee":"0.009981007",
1211
+ // "orderId":"58166729555"
1212
+ // },
1213
+ // ]
1214
+ // }
1215
+ //
1216
+ // when a symbol is provided
1217
+ //
1218
+ // [
1219
+ // {
1220
+ // "id": 1343815269,
1221
+ // "clientOrderId": '',
1222
+ // "time": 1641051917.532965,
1223
+ // "side": "sell",
1224
+ // "role": 2,
1225
+ // "amount": "9.986",
1226
+ // "price": "0.9995",
1227
+ // "deal": "9.981007",
1228
+ // "fee": "0.009981007",
1229
+ // "orderId": 58166729555,
1230
+ // },
1231
+ // ]
1232
+ //
1233
+ if (Array.isArray(response)) {
1234
+ return this.parseTrades(response, market, since, limit);
1235
+ }
1236
+ else {
1237
+ let results = [];
1238
+ const keys = Object.keys(response);
1239
+ for (let i = 0; i < keys.length; i++) {
1240
+ const marketId = keys[i];
1241
+ const marketNew = this.safeMarket(marketId, undefined, '_');
1242
+ const rawTrades = this.safeValue(response, marketId, []);
1243
+ const parsed = this.parseTrades(rawTrades, marketNew, since, limit);
1244
+ results = this.arrayConcat(results, parsed);
1245
+ }
1246
+ results = this.sortBy2(results, 'timestamp', 'id');
1247
+ return this.filterBySinceLimit(results, since, limit, 'timestamp');
1248
+ }
1249
+ }
1250
+ parseTrade(trade, market = undefined) {
1251
+ //
1252
+ // fetchTradesV4
1253
+ //
1254
+ // {
1255
+ // "tradeID": 158056419,
1256
+ // "price": "9186.13",
1257
+ // "quote_volume": "0.0021",
1258
+ // "base_volume": "9186.13",
1259
+ // "trade_timestamp": 1594391747,
1260
+ // "type": "sell"
1261
+ // }
1262
+ //
1263
+ // orderTrades (v4Private)
1264
+ //
1265
+ // {
1266
+ // "time": 1593342324.613711,
1267
+ // "fee": "0.00000419198",
1268
+ // "price": "0.00000701",
1269
+ // "amount": "598",
1270
+ // "id": 149156519, // trade id
1271
+ // "dealOrderId": 3134995325, // orderId
1272
+ // "clientOrderId": "customId11",
1273
+ // "role": 2, // 1 = maker, 2 = taker
1274
+ // "deal": "0.00419198" // amount in money
1275
+ // "feeAsset": "USDT"
1276
+ // }
1277
+ //
1278
+ // fetchMyTrades
1279
+ //
1280
+ // {
1281
+ // "id": 1343815269,
1282
+ // "clientOrderId": '',
1283
+ // "time": 1641051917.532965,
1284
+ // "side": "sell",
1285
+ // "role": 2,
1286
+ // "amount": "9.986",
1287
+ // "price": "0.9995",
1288
+ // "deal": "9.981007",
1289
+ // "fee": "0.009981007",
1290
+ // "orderId": 58166729555,
1291
+ // "feeAsset": "USDT"
1292
+ // }
1293
+ //
1294
+ market = this.safeMarket(undefined, market);
1295
+ const timestamp = this.safeTimestamp2(trade, 'time', 'trade_timestamp');
1296
+ const orderId = this.safeString2(trade, 'dealOrderId', 'orderId');
1297
+ const cost = this.safeString(trade, 'deal');
1298
+ const price = this.safeString(trade, 'price');
1299
+ const amount = this.safeString2(trade, 'amount', 'quote_volume');
1300
+ const id = this.safeString2(trade, 'id', 'tradeID');
1301
+ const side = this.safeString2(trade, 'type', 'side');
1302
+ const symbol = market['symbol'];
1303
+ const role = this.safeInteger(trade, 'role');
1304
+ let takerOrMaker = undefined;
1305
+ if (role !== undefined) {
1306
+ takerOrMaker = (role === 1) ? 'maker' : 'taker';
1307
+ }
1308
+ let fee = undefined;
1309
+ const feeCost = this.safeString(trade, 'fee');
1310
+ if (feeCost !== undefined) {
1311
+ fee = {
1312
+ 'cost': feeCost,
1313
+ 'currency': this.safeCurrencyCode(this.safeString(trade, 'feeAsset')),
1314
+ };
1315
+ }
1316
+ return this.safeTrade({
1317
+ 'info': trade,
1318
+ 'timestamp': timestamp,
1319
+ 'datetime': this.iso8601(timestamp),
1320
+ 'symbol': symbol,
1321
+ 'id': id,
1322
+ 'order': orderId,
1323
+ 'type': undefined,
1324
+ 'takerOrMaker': takerOrMaker,
1325
+ 'side': side,
1326
+ 'price': price,
1327
+ 'amount': amount,
1328
+ 'cost': cost,
1329
+ 'fee': fee,
1330
+ }, market);
1331
+ }
1332
+ /**
1333
+ * @method
1334
+ * @name whitebit#fetchOHLCV
1335
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1336
+ * @see https://docs.whitebit.com/public/http-v1/#kline
1337
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1338
+ * @param {string} timeframe the length of time each candle represents
1339
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1340
+ * @param {int} [limit] the maximum amount of candles to fetch
1341
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1342
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1343
+ */
1344
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1345
+ await this.loadMarkets();
1346
+ const market = this.market(symbol);
1347
+ const request = {
1348
+ 'market': market['id'],
1349
+ 'interval': this.safeString(this.timeframes, timeframe, timeframe),
1350
+ };
1351
+ if (since !== undefined) {
1352
+ const maxLimit = 1440;
1353
+ if (limit === undefined) {
1354
+ limit = maxLimit;
1355
+ }
1356
+ limit = Math.min(limit, maxLimit);
1357
+ const start = this.parseToInt(since / 1000);
1358
+ request['start'] = start;
1359
+ }
1360
+ if (limit !== undefined) {
1361
+ request['limit'] = Math.min(limit, 1440);
1362
+ }
1363
+ const response = await this.v1PublicGetKline(this.extend(request, params));
1364
+ //
1365
+ // {
1366
+ // "success":true,
1367
+ // "message":"",
1368
+ // "result":[
1369
+ // [1591488000,"0.025025","0.025025","0.025029","0.025023","6.181","0.154686629"],
1370
+ // [1591488060,"0.025028","0.025033","0.025035","0.025026","8.067","0.201921167"],
1371
+ // [1591488120,"0.025034","0.02505","0.02505","0.025034","20.089","0.503114696"],
1372
+ // ]
1373
+ // }
1374
+ //
1375
+ const result = this.safeList(response, 'result', []);
1376
+ return this.parseOHLCVs(result, market, timeframe, since, limit);
1377
+ }
1378
+ parseOHLCV(ohlcv, market = undefined) {
1379
+ //
1380
+ // [
1381
+ // 1591488000,
1382
+ // "0.025025",
1383
+ // "0.025025",
1384
+ // "0.025029",
1385
+ // "0.025023",
1386
+ // "6.181",
1387
+ // "0.154686629"
1388
+ // ]
1389
+ //
1390
+ return [
1391
+ this.safeTimestamp(ohlcv, 0),
1392
+ this.safeNumber(ohlcv, 1),
1393
+ this.safeNumber(ohlcv, 3),
1394
+ this.safeNumber(ohlcv, 4),
1395
+ this.safeNumber(ohlcv, 2),
1396
+ this.safeNumber(ohlcv, 5), // volume
1397
+ ];
1398
+ }
1399
+ /**
1400
+ * @method
1401
+ * @name whitebit#fetchStatus
1402
+ * @description the latest known information on the availability of the exchange API
1403
+ * @see https://docs.whitebit.com/public/http-v4/#server-status
1404
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1405
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
1406
+ */
1407
+ async fetchStatus(params = {}) {
1408
+ const response = await this.v4PublicGetPing(params);
1409
+ //
1410
+ // [
1411
+ // "pong"
1412
+ // ]
1413
+ //
1414
+ const status = this.safeString(response, 0);
1415
+ return {
1416
+ 'status': (status === 'pong') ? 'ok' : status,
1417
+ 'updated': undefined,
1418
+ 'eta': undefined,
1419
+ 'url': undefined,
1420
+ 'info': response,
1421
+ };
1422
+ }
1423
+ /**
1424
+ * @method
1425
+ * @name whitebit#fetchTime
1426
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
1427
+ * @see https://docs.whitebit.com/public/http-v4/#server-time
1428
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1429
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
1430
+ */
1431
+ async fetchTime(params = {}) {
1432
+ const response = await this.v4PublicGetTime(params);
1433
+ //
1434
+ // {
1435
+ // "time":1737380046
1436
+ // }
1437
+ //
1438
+ return this.safeInteger(response, 'time');
1439
+ }
1440
+ /**
1441
+ * @method
1442
+ * @name whitebit#createMarketOrderWithCost
1443
+ * @description create a market order by providing the symbol, side and cost
1444
+ * @param {string} symbol unified symbol of the market to create an order in
1445
+ * @param {string} side 'buy' or 'sell'
1446
+ * @param {float} cost how much you want to trade in units of the quote currency
1447
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1448
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1449
+ */
1450
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
1451
+ const req = {
1452
+ 'cost': cost,
1453
+ };
1454
+ // only buy side is supported
1455
+ return await this.createOrder(symbol, 'market', side, 0, undefined, this.extend(req, params));
1456
+ }
1457
+ /**
1458
+ * @method
1459
+ * @name whitebit#createMarketBuyOrderWithCost
1460
+ * @description create a market buy order by providing the symbol and cost
1461
+ * @param {string} symbol unified symbol of the market to create an order in
1462
+ * @param {float} cost how much you want to trade in units of the quote currency
1463
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1464
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1465
+ */
1466
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1467
+ return await this.createMarketOrderWithCost(symbol, 'buy', cost, params);
1468
+ }
1469
+ /**
1470
+ * @method
1471
+ * @name whitebit#createOrder
1472
+ * @description create a trade order
1473
+ * @see https://docs.whitebit.com/private/http-trade-v4/#create-limit-order
1474
+ * @see https://docs.whitebit.com/private/http-trade-v4/#create-market-order
1475
+ * @see https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order
1476
+ * @see https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order
1477
+ * @see https://docs.whitebit.com/private/http-trade-v4/#create-stop-market-order
1478
+ * @param {string} symbol unified symbol of the market to create an order in
1479
+ * @param {string} type 'market' or 'limit'
1480
+ * @param {string} side 'buy' or 'sell'
1481
+ * @param {float} amount how much of currency you want to trade in units of base currency
1482
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1483
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1484
+ * @param {float} [params.cost] *market orders only* the cost of the order in units of the base currency
1485
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
1486
+ * @param {bool} [params.postOnly] If true, the order will only be posted to the order book and not executed immediately
1487
+ * @param {string} [params.clientOrderId] a unique id for the order
1488
+ * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
1489
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1490
+ */
1491
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1492
+ await this.loadMarkets();
1493
+ const market = this.market(symbol);
1494
+ const request = {
1495
+ 'market': market['id'],
1496
+ 'side': side,
1497
+ };
1498
+ let cost = undefined;
1499
+ [cost, params] = this.handleParamString(params, 'cost');
1500
+ if (cost !== undefined) {
1501
+ if ((side !== 'buy') || (type !== 'market')) {
1502
+ throw new InvalidOrder(this.id + ' createOrder() cost is only supported for market buy orders');
1503
+ }
1504
+ request['amount'] = this.costToPrecision(symbol, cost);
1505
+ }
1506
+ else {
1507
+ request['amount'] = this.amountToPrecision(symbol, amount);
1508
+ }
1509
+ const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
1510
+ if (clientOrderId === undefined) {
1511
+ const brokerId = this.safeString(this.options, 'brokerId');
1512
+ if (brokerId !== undefined) {
1513
+ request['clientOrderId'] = brokerId + this.uuid16();
1514
+ }
1515
+ }
1516
+ else {
1517
+ request['clientOrderId'] = clientOrderId;
1518
+ params = this.omit(params, ['clientOrderId']);
1519
+ }
1520
+ const marketType = this.safeString(market, 'type');
1521
+ const isLimitOrder = type === 'limit';
1522
+ const isMarketOrder = type === 'market';
1523
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'activation_price']);
1524
+ const isStopOrder = (triggerPrice !== undefined);
1525
+ const postOnly = this.isPostOnly(isMarketOrder, false, params);
1526
+ const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
1527
+ if (postOnly) {
1528
+ request['postOnly'] = true;
1529
+ }
1530
+ if (marginMode !== undefined && marginMode !== 'cross') {
1531
+ throw new NotSupported(this.id + ' createOrder() is only available for cross margin');
1532
+ }
1533
+ params = this.omit(query, ['postOnly', 'triggerPrice', 'stopPrice']);
1534
+ const useCollateralEndpoint = marginMode !== undefined || marketType === 'swap';
1535
+ let response = undefined;
1536
+ if (isStopOrder) {
1537
+ request['activation_price'] = this.priceToPrecision(symbol, triggerPrice);
1538
+ if (isLimitOrder) {
1539
+ // stop limit order
1540
+ request['price'] = this.priceToPrecision(symbol, price);
1541
+ response = await this.v4PrivatePostOrderStopLimit(this.extend(request, params));
1542
+ }
1543
+ else {
1544
+ // stop market order
1545
+ if (useCollateralEndpoint) {
1546
+ response = await this.v4PrivatePostOrderCollateralTriggerMarket(this.extend(request, params));
1547
+ }
1548
+ else {
1549
+ response = await this.v4PrivatePostOrderStopMarket(this.extend(request, params));
1550
+ }
1551
+ }
1552
+ }
1553
+ else {
1554
+ if (isLimitOrder) {
1555
+ // limit order
1556
+ request['price'] = this.priceToPrecision(symbol, price);
1557
+ if (useCollateralEndpoint) {
1558
+ response = await this.v4PrivatePostOrderCollateralLimit(this.extend(request, params));
1559
+ }
1560
+ else {
1561
+ response = await this.v4PrivatePostOrderNew(this.extend(request, params));
1562
+ }
1563
+ }
1564
+ else {
1565
+ // market order
1566
+ if (useCollateralEndpoint) {
1567
+ response = await this.v4PrivatePostOrderCollateralMarket(this.extend(request, params));
1568
+ }
1569
+ else {
1570
+ if (cost !== undefined) {
1571
+ response = await this.v4PrivatePostOrderMarket(this.extend(request, params));
1572
+ }
1573
+ else {
1574
+ response = await this.v4PrivatePostOrderStockMarket(this.extend(request, params));
1575
+ }
1576
+ }
1577
+ }
1578
+ }
1579
+ return this.parseOrder(response);
1580
+ }
1581
+ /**
1582
+ * @method
1583
+ * @name whitebit#editOrder
1584
+ * @description edit a trade order
1585
+ * @see https://docs.whitebit.com/private/http-trade-v4/#modify-order
1586
+ * @param {string} id cancel order id
1587
+ * @param {string} symbol unified symbol of the market to create an order in
1588
+ * @param {string} type 'market' or 'limit'
1589
+ * @param {string} side 'buy' or 'sell'
1590
+ * @param {float} amount how much of currency you want to trade in units of base currency
1591
+ * @param {float} price the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1592
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1593
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1594
+ */
1595
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1596
+ if (id === undefined) {
1597
+ throw new ArgumentsRequired(this.id + ' editOrder() requires a id argument');
1598
+ }
1599
+ if (symbol === undefined) {
1600
+ throw new ArgumentsRequired(this.id + ' editOrder() requires a symbol argument');
1601
+ }
1602
+ await this.loadMarkets();
1603
+ const market = this.market(symbol);
1604
+ const request = {
1605
+ 'orderId': id,
1606
+ 'market': market['id'],
1607
+ };
1608
+ const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
1609
+ if (clientOrderId !== undefined) {
1610
+ // Update clientOrderId of the order
1611
+ request['clientOrderId'] = clientOrderId;
1612
+ }
1613
+ const isLimitOrder = type === 'limit';
1614
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'activation_price']);
1615
+ const isStopOrder = (triggerPrice !== undefined);
1616
+ params = this.omit(params, ['clOrdId', 'clientOrderId', 'triggerPrice', 'stopPrice']);
1617
+ if (isStopOrder) {
1618
+ request['activation_price'] = this.priceToPrecision(symbol, triggerPrice);
1619
+ if (isLimitOrder) {
1620
+ // stop limit order
1621
+ request['amount'] = this.amountToPrecision(symbol, amount);
1622
+ request['price'] = this.priceToPrecision(symbol, price);
1623
+ }
1624
+ else {
1625
+ // stop market order
1626
+ if (side === 'buy') {
1627
+ // Use total parameter instead of amount for modify buy stop market order
1628
+ request['total'] = this.amountToPrecision(symbol, amount);
1629
+ }
1630
+ else {
1631
+ request['amount'] = this.amountToPrecision(symbol, amount);
1632
+ }
1633
+ }
1634
+ }
1635
+ else {
1636
+ request['amount'] = this.amountToPrecision(symbol, amount);
1637
+ if (isLimitOrder) {
1638
+ // limit order
1639
+ request['price'] = this.priceToPrecision(symbol, price);
1640
+ }
1641
+ }
1642
+ const response = await this.v4PrivatePostOrderModify(this.extend(request, params));
1643
+ return this.parseOrder(response);
1644
+ }
1645
+ /**
1646
+ * @method
1647
+ * @name whitebit#cancelOrder
1648
+ * @description cancels an open order
1649
+ * @see https://docs.whitebit.com/private/http-trade-v4/#cancel-order
1650
+ * @param {string} id order id
1651
+ * @param {string} symbol unified symbol of the market the order was made in
1652
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1653
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1654
+ */
1655
+ async cancelOrder(id, symbol = undefined, params = {}) {
1656
+ if (symbol === undefined) {
1657
+ throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
1658
+ }
1659
+ await this.loadMarkets();
1660
+ const market = this.market(symbol);
1661
+ const request = {
1662
+ 'market': market['id'],
1663
+ 'orderId': parseInt(id),
1664
+ };
1665
+ const response = await this.v4PrivatePostOrderCancel(this.extend(request, params));
1666
+ //
1667
+ // {
1668
+ // "orderId": 4180284841, // order id
1669
+ // "clientOrderId": "customId11", // custom order identifier; "clientOrderId": "" - if not specified.
1670
+ // "market": "BTC_USDT", // deal market
1671
+ // "side": "buy", // order side
1672
+ // "type": "stop market", // order type
1673
+ // "timestamp": 1595792396.165973, // current timestamp
1674
+ // "dealMoney": "0", // if order finished - amount in money currency that is finished
1675
+ // "dealStock": "0", // if order finished - amount in stock currency that is finished
1676
+ // "amount": "0.001", // amount
1677
+ // "takerFee": "0.001", // maker fee ratio. If the number less than 0.0001 - it will be rounded to zero
1678
+ // "makerFee": "0.001", // maker fee ratio. If the number less than 0.0001 - it will be rounded to zero
1679
+ // "left": "0.001", // if order not finished - rest of the amount that must be finished
1680
+ // "dealFee": "0", // fee in money that you pay if order is finished
1681
+ // "price": "40000", // price if price isset
1682
+ // "activation_price": "40000" // activation price if activation price is set
1683
+ // }
1684
+ //
1685
+ return this.parseOrder(response);
1686
+ }
1687
+ /**
1688
+ * @method
1689
+ * @name whitebit#cancelAllOrders
1690
+ * @description cancel all open orders
1691
+ * @see https://docs.whitebit.com/private/http-trade-v4/#cancel-all-orders
1692
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1693
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1694
+ * @param {string} [params.type] market type, ['swap', 'spot']
1695
+ * @param {boolean} [params.isMargin] cancel all margin orders
1696
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1697
+ */
1698
+ async cancelAllOrders(symbol = undefined, params = {}) {
1699
+ await this.loadMarkets();
1700
+ let market = undefined;
1701
+ const request = {};
1702
+ if (symbol !== undefined) {
1703
+ market = this.market(symbol);
1704
+ request['market'] = market['id'];
1705
+ }
1706
+ let type = undefined;
1707
+ [type, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
1708
+ const requestType = [];
1709
+ if (type === 'spot') {
1710
+ let isMargin = undefined;
1711
+ [isMargin, params] = this.handleOptionAndParams(params, 'cancelAllOrders', 'isMargin', false);
1712
+ if (isMargin) {
1713
+ requestType.push('margin');
1714
+ }
1715
+ else {
1716
+ requestType.push('spot');
1717
+ }
1718
+ }
1719
+ else if (type === 'swap') {
1720
+ requestType.push('futures');
1721
+ }
1722
+ else {
1723
+ throw new NotSupported(this.id + ' cancelAllOrders() does not support ' + type + ' type');
1724
+ }
1725
+ request['type'] = requestType;
1726
+ const response = await this.v4PrivatePostOrderCancelAll(this.extend(request, params));
1727
+ //
1728
+ // []
1729
+ //
1730
+ return this.parseOrders(response, market);
1731
+ }
1732
+ /**
1733
+ * @method
1734
+ * @name whitebit#cancelAllOrdersAfter
1735
+ * @description dead man's switch, cancel all orders after the given timeout
1736
+ * @see https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer
1737
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
1738
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1739
+ * @param {string} [params.types] Order types value. Example: "spot", "margin", "futures" or null
1740
+ * @param {string} [params.symbol] symbol unified symbol of the market the order was made in
1741
+ * @returns {object} the api result
1742
+ */
1743
+ async cancelAllOrdersAfter(timeout, params = {}) {
1744
+ await this.loadMarkets();
1745
+ const symbol = this.safeString(params, 'symbol');
1746
+ if (symbol === undefined) {
1747
+ throw new ArgumentsRequired(this.id + ' cancelAllOrdersAfter() requires a symbol argument in params');
1748
+ }
1749
+ const market = this.market(symbol);
1750
+ params = this.omit(params, 'symbol');
1751
+ const isBiggerThanZero = (timeout > 0);
1752
+ const request = {
1753
+ 'market': market['id'],
1754
+ // 'timeout': (timeout > 0) ? this.numberToString (timeout / 1000) : null,
1755
+ };
1756
+ if (isBiggerThanZero) {
1757
+ request['timeout'] = this.numberToString(timeout / 1000);
1758
+ }
1759
+ else {
1760
+ request['timeout'] = 'null';
1761
+ }
1762
+ const response = await this.v4PrivatePostOrderKillSwitch(this.extend(request, params));
1763
+ //
1764
+ // {
1765
+ // "market": "BTC_USDT", // currency market,
1766
+ // "startTime": 1662478154, // now timestamp,
1767
+ // "cancellationTime": 1662478154, // now + timer_value,
1768
+ // "types": ["spot", "margin"]
1769
+ // }
1770
+ //
1771
+ return response;
1772
+ }
1773
+ parseBalance(response) {
1774
+ const balanceKeys = Object.keys(response);
1775
+ const result = {};
1776
+ for (let i = 0; i < balanceKeys.length; i++) {
1777
+ const id = balanceKeys[i];
1778
+ const code = this.safeCurrencyCode(id);
1779
+ const balance = response[id];
1780
+ if (typeof balance === 'object' && balance !== undefined) {
1781
+ const account = this.account();
1782
+ account['free'] = this.safeString2(balance, 'available', 'main_balance');
1783
+ account['used'] = this.safeString(balance, 'freeze');
1784
+ account['total'] = this.safeString(balance, 'main_balance');
1785
+ result[code] = account;
1786
+ }
1787
+ else {
1788
+ const account = this.account();
1789
+ account['total'] = balance;
1790
+ result[code] = account;
1791
+ }
1792
+ }
1793
+ return this.safeBalance(result);
1794
+ }
1795
+ /**
1796
+ * @method
1797
+ * @name whitebit#fetchBalance
1798
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1799
+ * @see https://docs.whitebit.com/private/http-main-v4/#main-balance
1800
+ * @see https://docs.whitebit.com/private/http-trade-v4/#trading-balance
1801
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1802
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1803
+ */
1804
+ async fetchBalance(params = {}) {
1805
+ await this.loadMarkets();
1806
+ let marketType = undefined;
1807
+ [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1808
+ let response = undefined;
1809
+ if (marketType === 'swap') {
1810
+ response = await this.v4PrivatePostCollateralAccountBalance(params);
1811
+ }
1812
+ else {
1813
+ const options = this.safeValue(this.options, 'fetchBalance', {});
1814
+ const defaultAccount = this.safeString(options, 'account');
1815
+ const account = this.safeString2(params, 'account', 'type', defaultAccount);
1816
+ params = this.omit(params, ['account', 'type']);
1817
+ if (account === 'main' || account === 'funding') {
1818
+ response = await this.v4PrivatePostMainAccountBalance(params);
1819
+ }
1820
+ else {
1821
+ response = await this.v4PrivatePostTradeAccountBalance(params);
1822
+ }
1823
+ }
1824
+ //
1825
+ // main account
1826
+ //
1827
+ // {
1828
+ // "BTC":{"main_balance":"0.0013929494020316"},
1829
+ // "ETH":{"main_balance":"0.001398289308"},
1830
+ // }
1831
+ //
1832
+ // spot trade account
1833
+ //
1834
+ // {
1835
+ // "BTC": { "available": "0.123", "freeze": "1" },
1836
+ // "XMR": { "available": "3013", "freeze": "100" },
1837
+ // }
1838
+ //
1839
+ // swap
1840
+ //
1841
+ // {
1842
+ // "BTC": 1,
1843
+ // "USDT": 1000
1844
+ // }
1845
+ //
1846
+ return this.parseBalance(response);
1847
+ }
1848
+ /**
1849
+ * @method
1850
+ * @name whitebit#fetchOpenOrders
1851
+ * @description fetch all unfilled currently open orders
1852
+ * @see https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
1853
+ * @param {string} [symbol] unified market symbol
1854
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1855
+ * @param {int} [limit] the maximum number of open order structures to retrieve
1856
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1857
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1858
+ */
1859
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1860
+ await this.loadMarkets();
1861
+ let market = undefined;
1862
+ const request = {};
1863
+ if (symbol !== undefined) {
1864
+ market = this.market(symbol);
1865
+ request['market'] = market['id'];
1866
+ }
1867
+ if (limit !== undefined) {
1868
+ request['limit'] = Math.min(limit, 100);
1869
+ }
1870
+ const response = await this.v4PrivatePostOrders(this.extend(request, params));
1871
+ //
1872
+ // [
1873
+ // {
1874
+ // "orderId": 3686033640,
1875
+ // "clientOrderId": "customId11",
1876
+ // "market": "BTC_USDT",
1877
+ // "side": "buy",
1878
+ // "type": "limit",
1879
+ // "timestamp": 1594605801.49815, // current timestamp of unexecuted order
1880
+ // "dealMoney": "0", // executed amount in money
1881
+ // "dealStock": "0", // executed amount in stock
1882
+ // "amount": "2.241379", // active order amount
1883
+ // "takerFee": "0.001",
1884
+ // "makerFee": "0.001",
1885
+ // "left": "2.241379", // unexecuted amount in stock
1886
+ // "dealFee": "0", // executed fee by deal
1887
+ // "price": "40000"
1888
+ // },
1889
+ // ]
1890
+ //
1891
+ return this.parseOrders(response, market, since, limit, { 'status': 'open' });
1892
+ }
1893
+ /**
1894
+ * @method
1895
+ * @name whitebit#fetchClosedOrders
1896
+ * @description fetches information on multiple closed orders made by the user
1897
+ * @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders
1898
+ * @param {string} symbol unified market symbol of the market orders were made in
1899
+ * @param {int} [since] the earliest time in ms to fetch orders for
1900
+ * @param {int} [limit] the maximum number of order structures to retrieve
1901
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1902
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1903
+ */
1904
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1905
+ await this.loadMarkets();
1906
+ const request = {};
1907
+ let market = undefined;
1908
+ if (symbol !== undefined) {
1909
+ market = this.market(symbol);
1910
+ symbol = market['symbol'];
1911
+ request['market'] = market['id'];
1912
+ }
1913
+ if (limit !== undefined) {
1914
+ request['limit'] = Math.min(limit, 100); // default 50 max 100
1915
+ }
1916
+ const response = await this.v4PrivatePostTradeAccountOrderHistory(this.extend(request, params));
1917
+ //
1918
+ // {
1919
+ // "BTC_USDT": [
1920
+ // {
1921
+ // "id": 160305483,
1922
+ // "clientOrderId": "customId11",
1923
+ // "time": 1594667731.724403,
1924
+ // "side": "sell",
1925
+ // "role": 2, // 1 = maker, 2 = taker
1926
+ // "amount": "0.000076",
1927
+ // "price": "9264.21",
1928
+ // "deal": "0.70407996",
1929
+ // "fee": "0.00070407996"
1930
+ // },
1931
+ // ],
1932
+ // }
1933
+ //
1934
+ const marketIds = Object.keys(response);
1935
+ let results = [];
1936
+ for (let i = 0; i < marketIds.length; i++) {
1937
+ const marketId = marketIds[i];
1938
+ const marketNew = this.safeMarket(marketId, undefined, '_');
1939
+ const orders = response[marketId];
1940
+ for (let j = 0; j < orders.length; j++) {
1941
+ const order = this.parseOrder(orders[j], marketNew);
1942
+ results.push(this.extend(order, { 'status': 'closed' }));
1943
+ }
1944
+ }
1945
+ results = this.sortBy(results, 'timestamp');
1946
+ results = this.filterBySymbolSinceLimit(results, symbol, since, limit);
1947
+ return results;
1948
+ }
1949
+ parseOrderType(type) {
1950
+ const types = {
1951
+ 'limit': 'limit',
1952
+ 'market': 'market',
1953
+ 'stop market': 'market',
1954
+ 'stop limit': 'limit',
1955
+ 'stock market': 'market',
1956
+ 'margin limit': 'limit',
1957
+ 'margin market': 'market',
1958
+ };
1959
+ return this.safeString(types, type, type);
1960
+ }
1961
+ parseOrder(order, market = undefined) {
1962
+ //
1963
+ // createOrder, fetchOpenOrders, cancelOrder
1964
+ //
1965
+ // {
1966
+ // "orderId":105687928629,
1967
+ // "clientOrderId":"",
1968
+ // "market":"DOGE_USDT",
1969
+ // "side":"sell",
1970
+ // "type":"stop market",
1971
+ // "timestamp":1659091079.729576,
1972
+ // "dealMoney":"0", // executed amount in quote
1973
+ // "dealStock":"0", // base filled amount
1974
+ // "amount":"100",
1975
+ // "takerFee":"0.001",
1976
+ // "makerFee":"0",
1977
+ // "left":"100",
1978
+ // "price": "40000", // price if price isset
1979
+ // "dealFee":"0",
1980
+ // "activation_price":"0.065" // stop price (if stop limit or stop market)
1981
+ // }
1982
+ //
1983
+ // fetchClosedOrders
1984
+ //
1985
+ // {
1986
+ // "id":105531094719,
1987
+ // "clientOrderId":"",
1988
+ // "ctime":1659045334.550127,
1989
+ // "ftime":1659045334.550127,
1990
+ // "side":"buy",
1991
+ // "amount":"5.9940059", // cost in terms of quote for regular market orders, amount in terms or base for all other order types
1992
+ // "price":"0",
1993
+ // "type":"market",
1994
+ // "takerFee":"0.001",
1995
+ // "makerFee":"0",
1996
+ // "dealFee":"0.0059375815",
1997
+ // "dealStock":"85", // base filled amount
1998
+ // "dealMoney":"5.9375815", // executed amount in quote
1999
+ // }
2000
+ //
2001
+ const marketId = this.safeString(order, 'market');
2002
+ market = this.safeMarket(marketId, market, '_');
2003
+ const symbol = market['symbol'];
2004
+ const side = this.safeString(order, 'side');
2005
+ const filled = this.safeString(order, 'dealStock');
2006
+ let remaining = this.safeString(order, 'left');
2007
+ let clientOrderId = this.safeString(order, 'clientOrderId');
2008
+ if (clientOrderId === '') {
2009
+ clientOrderId = undefined;
2010
+ }
2011
+ const price = this.safeString(order, 'price');
2012
+ const triggerPrice = this.safeNumber(order, 'activation_price');
2013
+ const orderId = this.safeString2(order, 'orderId', 'id');
2014
+ const type = this.safeString(order, 'type');
2015
+ const orderType = this.parseOrderType(type);
2016
+ if (orderType === 'market') {
2017
+ remaining = undefined;
2018
+ }
2019
+ let amount = this.safeString(order, 'amount');
2020
+ const cost = this.safeString(order, 'dealMoney');
2021
+ if ((side === 'buy') && ((type === 'market') || (type === 'stop market'))) {
2022
+ amount = filled;
2023
+ }
2024
+ const dealFee = this.safeString(order, 'dealFee');
2025
+ let fee = undefined;
2026
+ if (dealFee !== undefined) {
2027
+ fee = {
2028
+ 'cost': this.parseNumber(dealFee),
2029
+ 'currency': market['quote'],
2030
+ };
2031
+ }
2032
+ const timestamp = this.safeTimestamp2(order, 'ctime', 'timestamp');
2033
+ const lastTradeTimestamp = this.safeTimestamp(order, 'ftime');
2034
+ return this.safeOrder({
2035
+ 'info': order,
2036
+ 'id': orderId,
2037
+ 'symbol': symbol,
2038
+ 'clientOrderId': clientOrderId,
2039
+ 'timestamp': timestamp,
2040
+ 'datetime': this.iso8601(timestamp),
2041
+ 'lastTradeTimestamp': lastTradeTimestamp,
2042
+ 'timeInForce': undefined,
2043
+ 'postOnly': undefined,
2044
+ 'status': undefined,
2045
+ 'side': side,
2046
+ 'price': price,
2047
+ 'type': orderType,
2048
+ 'triggerPrice': triggerPrice,
2049
+ 'amount': amount,
2050
+ 'filled': filled,
2051
+ 'remaining': remaining,
2052
+ 'average': undefined,
2053
+ 'cost': cost,
2054
+ 'fee': fee,
2055
+ 'trades': undefined,
2056
+ }, market);
2057
+ }
2058
+ /**
2059
+ * @method
2060
+ * @name whitebit#fetchOrderTrades
2061
+ * @description fetch all the trades made from a single order
2062
+ * @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-deals
2063
+ * @param {string} id order id
2064
+ * @param {string} symbol unified market symbol
2065
+ * @param {int} [since] the earliest time in ms to fetch trades for
2066
+ * @param {int} [limit] the maximum number of trades to retrieve
2067
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2068
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2069
+ */
2070
+ async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2071
+ await this.loadMarkets();
2072
+ const request = {
2073
+ 'orderId': parseInt(id),
2074
+ };
2075
+ let market = undefined;
2076
+ if (symbol !== undefined) {
2077
+ market = this.market(symbol);
2078
+ request['market'] = market['id'];
2079
+ }
2080
+ if (limit !== undefined) {
2081
+ request['limit'] = Math.min(limit, 100);
2082
+ }
2083
+ const response = await this.v4PrivatePostTradeAccountOrder(this.extend(request, params));
2084
+ //
2085
+ // {
2086
+ // "records": [
2087
+ // {
2088
+ // "time": 1593342324.613711,
2089
+ // "fee": "0.00000419198",
2090
+ // "price": "0.00000701",
2091
+ // "amount": "598",
2092
+ // "id": 149156519, // trade id
2093
+ // "dealOrderId": 3134995325, // orderId
2094
+ // "clientOrderId": "customId11", // empty string if not specified
2095
+ // "role": 2, // 1 = maker, 2 = taker
2096
+ // "deal": "0.00419198"
2097
+ // }
2098
+ // ],
2099
+ // "offset": 0,
2100
+ // "limit": 100
2101
+ // }
2102
+ //
2103
+ const data = this.safeList(response, 'records', []);
2104
+ return this.parseTrades(data, market);
2105
+ }
2106
+ /**
2107
+ * @method
2108
+ * @name whitebit#fetchDepositAddress
2109
+ * @description fetch the deposit address for a currency associated with this account
2110
+ * @see https://docs.whitebit.com/private/http-main-v4/#get-fiat-deposit-address
2111
+ * @see https://docs.whitebit.com/private/http-main-v4/#get-cryptocurrency-deposit-address
2112
+ * @param {string} code unified currency code
2113
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2114
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2115
+ */
2116
+ async fetchDepositAddress(code, params = {}) {
2117
+ await this.loadMarkets();
2118
+ const currency = this.currency(code);
2119
+ const request = {
2120
+ 'ticker': currency['id'],
2121
+ };
2122
+ let response = undefined;
2123
+ if (this.isFiat(code)) {
2124
+ const provider = this.safeString(params, 'provider');
2125
+ if (provider === undefined) {
2126
+ throw new ArgumentsRequired(this.id + ' fetchDepositAddress() requires a provider when the ticker is fiat');
2127
+ }
2128
+ request['provider'] = provider;
2129
+ const amount = this.safeNumber(params, 'amount');
2130
+ if (amount === undefined) {
2131
+ throw new ArgumentsRequired(this.id + ' fetchDepositAddress() requires an amount when the ticker is fiat');
2132
+ }
2133
+ request['amount'] = amount;
2134
+ const uniqueId = this.safeValue(params, 'uniqueId');
2135
+ if (uniqueId === undefined) {
2136
+ throw new ArgumentsRequired(this.id + ' fetchDepositAddress() requires an uniqueId when the ticker is fiat');
2137
+ }
2138
+ response = await this.v4PrivatePostMainAccountFiatDepositUrl(this.extend(request, params));
2139
+ }
2140
+ else {
2141
+ response = await this.v4PrivatePostMainAccountAddress(this.extend(request, params));
2142
+ }
2143
+ //
2144
+ // fiat
2145
+ //
2146
+ // {
2147
+ // "url": "https://someaddress.com"
2148
+ // }
2149
+ //
2150
+ // crypto
2151
+ //
2152
+ // {
2153
+ // "account": {
2154
+ // "address": "GDTSOI56XNVAKJNJBLJGRNZIVOCIZJRBIDKTWSCYEYNFAZEMBLN75RMN",
2155
+ // "memo": "48565488244493"
2156
+ // },
2157
+ // "required": {
2158
+ // "fixedFee": "0",
2159
+ // "flexFee": {
2160
+ // "maxFee": "0",
2161
+ // "minFee": "0",
2162
+ // "percent": "0"
2163
+ // },
2164
+ // "maxAmount": "0",
2165
+ // "minAmount": "1"
2166
+ // }
2167
+ // }
2168
+ //
2169
+ const url = this.safeString(response, 'url');
2170
+ const account = this.safeValue(response, 'account', {});
2171
+ const address = this.safeString(account, 'address', url);
2172
+ const tag = this.safeString(account, 'memo');
2173
+ this.checkAddress(address);
2174
+ return {
2175
+ 'info': response,
2176
+ 'currency': code,
2177
+ 'network': undefined,
2178
+ 'address': address,
2179
+ 'tag': tag,
2180
+ };
2181
+ }
2182
+ /**
2183
+ * @method
2184
+ * @name whitebit#createDepositAddress
2185
+ * @description create a currency deposit address
2186
+ * @see https://docs.whitebit.com/private/http-main-v4/#create-new-address-for-deposit
2187
+ * @param {string} code unified currency code of the currency for the deposit address
2188
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2189
+ * @param {string} [params.network] the blockchain network to create a deposit address on
2190
+ * @param {string} [params.type] address type, available for specific currencies
2191
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2192
+ */
2193
+ async createDepositAddress(code, params = {}) {
2194
+ await this.loadMarkets();
2195
+ const currency = this.currency(code);
2196
+ const request = {
2197
+ 'ticker': currency['id'],
2198
+ };
2199
+ const response = await this.v4PrivatePostMainAccountCreateNewAddress(this.extend(request, params));
2200
+ //
2201
+ // {
2202
+ // "account": {
2203
+ // "address": "GDTSOI56XNVAKJNJBLJGRNZIVOCIZJRBIDKTWSCYEYNFAZEMBLN75RMN",
2204
+ // "memo": "48565488244493"
2205
+ // },
2206
+ // "required": {
2207
+ // "maxAmount": "0",
2208
+ // "minAmount": "1",
2209
+ // "fixedFee": "0",
2210
+ // "flexFee": {
2211
+ // "maxFee": "0",
2212
+ // "minFee": "0",
2213
+ // "percent": "0"
2214
+ // }
2215
+ // }
2216
+ // }
2217
+ //
2218
+ const data = this.safeDict(response, 'account', {});
2219
+ return this.parseDepositAddress(data, currency);
2220
+ }
2221
+ parseDepositAddress(depositAddress, currency = undefined) {
2222
+ //
2223
+ // {
2224
+ // "address": "GDTSOI56XNVAKJNJBLJGRNZIVOCIZJRBIDKTWSCYEYNFAZEMBLN75RMN",
2225
+ // "memo": "48565488244493"
2226
+ // },
2227
+ //
2228
+ return {
2229
+ 'info': depositAddress,
2230
+ 'currency': this.safeCurrencyCode(undefined, currency),
2231
+ 'network': undefined,
2232
+ 'address': this.safeString(depositAddress, 'address'),
2233
+ 'tag': this.safeString(depositAddress, 'memo'),
2234
+ };
2235
+ }
2236
+ /**
2237
+ * @method
2238
+ * @name whitebit#setLeverage
2239
+ * @description set the level of leverage for a market
2240
+ * @see https://docs.whitebit.com/private/http-trade-v4/#change-collateral-account-leverage
2241
+ * @param {float} leverage the rate of leverage
2242
+ * @param {string} symbol unified market symbol
2243
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2244
+ * @returns {object} response from the exchange
2245
+ */
2246
+ async setLeverage(leverage, symbol = undefined, params = {}) {
2247
+ await this.loadMarkets();
2248
+ if (symbol !== undefined) {
2249
+ throw new NotSupported(this.id + ' setLeverage() does not allow to set per symbol');
2250
+ }
2251
+ if ((leverage < 1) || (leverage > 20)) {
2252
+ throw new BadRequest(this.id + ' setLeverage() leverage should be between 1 and 20');
2253
+ }
2254
+ const request = {
2255
+ 'leverage': leverage,
2256
+ };
2257
+ return await this.v4PrivatePostCollateralAccountLeverage(this.extend(request, params));
2258
+ // {
2259
+ // "leverage": 5
2260
+ // }
2261
+ }
2262
+ /**
2263
+ * @method
2264
+ * @name whitebit#transfer
2265
+ * @description transfer currency internally between wallets on the same account
2266
+ * @see https://docs.whitebit.com/private/http-main-v4/#transfer-between-main-and-trade-balances
2267
+ * @param {string} code unified currency code
2268
+ * @param {float} amount amount to transfer
2269
+ * @param {string} fromAccount account to transfer from - main, spot, collateral
2270
+ * @param {string} toAccount account to transfer to - main, spot, collateral
2271
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2272
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2273
+ */
2274
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
2275
+ await this.loadMarkets();
2276
+ const currency = this.currency(code);
2277
+ const accountsByType = this.safeValue(this.options, 'accountsByType');
2278
+ const fromAccountId = this.safeString(accountsByType, fromAccount, fromAccount);
2279
+ const toAccountId = this.safeString(accountsByType, toAccount, toAccount);
2280
+ const amountString = this.currencyToPrecision(code, amount);
2281
+ const request = {
2282
+ 'ticker': currency['id'],
2283
+ 'amount': amountString,
2284
+ 'from': fromAccountId,
2285
+ 'to': toAccountId,
2286
+ };
2287
+ const response = await this.v4PrivatePostMainAccountTransfer(this.extend(request, params));
2288
+ //
2289
+ // []
2290
+ //
2291
+ return this.parseTransfer(response, currency);
2292
+ }
2293
+ parseTransfer(transfer, currency = undefined) {
2294
+ //
2295
+ // []
2296
+ //
2297
+ return {
2298
+ 'info': transfer,
2299
+ 'id': undefined,
2300
+ 'timestamp': undefined,
2301
+ 'datetime': undefined,
2302
+ 'currency': this.safeCurrencyCode(undefined, currency),
2303
+ 'amount': undefined,
2304
+ 'fromAccount': undefined,
2305
+ 'toAccount': undefined,
2306
+ 'status': undefined,
2307
+ };
2308
+ }
2309
+ /**
2310
+ * @method
2311
+ * @name whitebit#withdraw
2312
+ * @description make a withdrawal
2313
+ * @see https://docs.whitebit.com/private/http-main-v4/#create-withdraw-request
2314
+ * @param {string} code unified currency code
2315
+ * @param {float} amount the amount to withdraw
2316
+ * @param {string} address the address to withdraw to
2317
+ * @param {string} tag
2318
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2319
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2320
+ */
2321
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
2322
+ await this.loadMarkets();
2323
+ const currency = this.currency(code); // check if it has canDeposit
2324
+ const request = {
2325
+ 'ticker': currency['id'],
2326
+ 'amount': this.currencyToPrecision(code, amount),
2327
+ 'address': address,
2328
+ };
2329
+ let uniqueId = this.safeValue(params, 'uniqueId');
2330
+ if (uniqueId === undefined) {
2331
+ uniqueId = this.uuid22();
2332
+ }
2333
+ request['uniqueId'] = uniqueId;
2334
+ if (tag !== undefined) {
2335
+ request['memo'] = tag;
2336
+ }
2337
+ if (this.isFiat(code)) {
2338
+ const provider = this.safeValue(params, 'provider');
2339
+ if (provider === undefined) {
2340
+ throw new ArgumentsRequired(this.id + ' withdraw() requires a provider when the ticker is fiat');
2341
+ }
2342
+ request['provider'] = provider;
2343
+ }
2344
+ const response = await this.v4PrivatePostMainAccountWithdraw(this.extend(request, params));
2345
+ //
2346
+ // empty array with a success status
2347
+ // go to deposit/withdraw history and check you request status by uniqueId
2348
+ //
2349
+ // []
2350
+ //
2351
+ return this.extend({ 'id': uniqueId }, this.parseTransaction(response, currency));
2352
+ }
2353
+ parseTransaction(transaction, currency = undefined) {
2354
+ //
2355
+ // {
2356
+ // "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
2357
+ // "uniqueId": null, // unique Id of deposit
2358
+ // "transactionId": "a6d71d69-2b17-4ad8-8b15-2d686c54a1a5",
2359
+ // "createdAt": 1593437922, // timestamp of deposit
2360
+ // "currency": "Bitcoin", // deposit currency
2361
+ // "ticker": "BTC", // deposit currency ticker
2362
+ // "method": 1, // called method 1 - deposit, 2 - withdraw
2363
+ // "amount": "0.0006", // amount of deposit
2364
+ // "description": "", // deposit description
2365
+ // "memo": "", // deposit memo
2366
+ // "fee": "0", // deposit fee
2367
+ // "status": 15, // transactions status
2368
+ // "network": null, // if currency is multinetwork
2369
+ // "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
2370
+ // "details": {
2371
+ // "partial": { // details about partially successful withdrawals
2372
+ // "requestAmount": "50000", // requested withdrawal amount
2373
+ // "processedAmount": "39000", // processed withdrawal amount
2374
+ // "processedFee": "273", // fee for processed withdrawal amount
2375
+ // "normalizeTransaction": "" // deposit id
2376
+ // }
2377
+ // },
2378
+ // "confirmations": { // if transaction status == 15 you can see this object
2379
+ // "actual": 1, // current block confirmations
2380
+ // "required": 2 // required block confirmation for successful deposit
2381
+ // }
2382
+ // "centralized": false,
2383
+ // }
2384
+ //
2385
+ currency = this.safeCurrency(undefined, currency);
2386
+ const address = this.safeString(transaction, 'address');
2387
+ const timestamp = this.safeTimestamp(transaction, 'createdAt');
2388
+ const currencyId = this.safeString(transaction, 'ticker');
2389
+ const status = this.safeString(transaction, 'status');
2390
+ const method = this.safeString(transaction, 'method');
2391
+ return {
2392
+ 'id': this.safeString(transaction, 'uniqueId'),
2393
+ 'txid': this.safeString(transaction, 'transactionId'),
2394
+ 'timestamp': timestamp,
2395
+ 'datetime': this.iso8601(timestamp),
2396
+ 'network': this.safeString(transaction, 'network'),
2397
+ 'addressFrom': (method === '1') ? address : undefined,
2398
+ 'address': address,
2399
+ 'addressTo': (method === '2') ? address : undefined,
2400
+ 'amount': this.safeNumber(transaction, 'amount'),
2401
+ 'type': (method === '1') ? 'deposit' : 'withdrawal',
2402
+ 'currency': this.safeCurrencyCode(currencyId, currency),
2403
+ 'status': this.parseTransactionStatus(status),
2404
+ 'updated': undefined,
2405
+ 'tagFrom': undefined,
2406
+ 'tag': undefined,
2407
+ 'tagTo': undefined,
2408
+ 'comment': this.safeString(transaction, 'description'),
2409
+ 'internal': undefined,
2410
+ 'fee': {
2411
+ 'cost': this.safeNumber(transaction, 'fee'),
2412
+ 'currency': this.safeCurrencyCode(currencyId, currency),
2413
+ },
2414
+ 'info': transaction,
2415
+ };
2416
+ }
2417
+ parseTransactionStatus(status) {
2418
+ const statuses = {
2419
+ '1': 'pending',
2420
+ '2': 'pending',
2421
+ '3': 'ok',
2422
+ '4': 'canceled',
2423
+ '5': 'pending',
2424
+ '6': 'pending',
2425
+ '7': 'ok',
2426
+ '9': 'canceled',
2427
+ '10': 'pending',
2428
+ '11': 'pending',
2429
+ '12': 'pending',
2430
+ '13': 'pending',
2431
+ '14': 'pending',
2432
+ '15': 'pending',
2433
+ '16': 'pending',
2434
+ '17': 'pending',
2435
+ };
2436
+ return this.safeString(statuses, status, status);
2437
+ }
2438
+ /**
2439
+ * @method
2440
+ * @name whitebit#fetchDeposit
2441
+ * @description fetch information on a deposit
2442
+ * @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
2443
+ * @param {string} id deposit id
2444
+ * @param {string} code not used by whitebit fetchDeposit ()
2445
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2446
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2447
+ */
2448
+ async fetchDeposit(id, code = undefined, params = {}) {
2449
+ await this.loadMarkets();
2450
+ let currency = undefined;
2451
+ const request = {
2452
+ 'transactionMethod': 1,
2453
+ 'uniqueId': id,
2454
+ 'limit': 1,
2455
+ 'offset': 0,
2456
+ };
2457
+ if (code !== undefined) {
2458
+ currency = this.currency(code);
2459
+ request['ticker'] = currency['id'];
2460
+ }
2461
+ const response = await this.v4PrivatePostMainAccountHistory(this.extend(request, params));
2462
+ //
2463
+ // {
2464
+ // "limit": 100,
2465
+ // "offset": 0,
2466
+ // "records": [
2467
+ // {
2468
+ // "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
2469
+ // "uniqueId": null, // unique Id of deposit
2470
+ // "createdAt": 1593437922, // timestamp of deposit
2471
+ // "currency": "Bitcoin", // deposit currency
2472
+ // "ticker": "BTC", // deposit currency ticker
2473
+ // "method": 1, // called method 1 - deposit, 2 - withdraw
2474
+ // "amount": "0.0006", // amount of deposit
2475
+ // "description": "", // deposit description
2476
+ // "memo": "", // deposit memo
2477
+ // "fee": "0", // deposit fee
2478
+ // "status": 15, // transactions status
2479
+ // "network": null, // if currency is multinetwork
2480
+ // "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
2481
+ // "details": {
2482
+ // "partial": { // details about partially successful withdrawals
2483
+ // "requestAmount": "50000", // requested withdrawal amount
2484
+ // "processedAmount": "39000", // processed withdrawal amount
2485
+ // "processedFee": "273", // fee for processed withdrawal amount
2486
+ // "normalizeTransaction": "" // deposit id
2487
+ // }
2488
+ // },
2489
+ // "confirmations": { // if transaction status == 15 you can see this object
2490
+ // "actual": 1, // current block confirmations
2491
+ // "required": 2 // required block confirmation for successful deposit
2492
+ // }
2493
+ // },
2494
+ // {...},
2495
+ // ],
2496
+ // "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
2497
+ // }
2498
+ //
2499
+ const records = this.safeValue(response, 'records', []);
2500
+ const first = this.safeDict(records, 0, {});
2501
+ return this.parseTransaction(first, currency);
2502
+ }
2503
+ /**
2504
+ * @method
2505
+ * @name whitebit#fetchDeposits
2506
+ * @description fetch all deposits made to an account
2507
+ * @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
2508
+ * @param {string} code unified currency code
2509
+ * @param {int} [since] the earliest time in ms to fetch deposits for
2510
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
2511
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2512
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2513
+ */
2514
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
2515
+ await this.loadMarkets();
2516
+ let currency = undefined;
2517
+ const request = {
2518
+ 'transactionMethod': 1,
2519
+ 'limit': 100,
2520
+ 'offset': 0,
2521
+ };
2522
+ if (code !== undefined) {
2523
+ currency = this.currency(code);
2524
+ request['ticker'] = currency['id'];
2525
+ }
2526
+ if (limit !== undefined) {
2527
+ request['limit'] = Math.min(limit, 100);
2528
+ }
2529
+ const response = await this.v4PrivatePostMainAccountHistory(this.extend(request, params));
2530
+ //
2531
+ // {
2532
+ // "limit": 100,
2533
+ // "offset": 0,
2534
+ // "records": [
2535
+ // {
2536
+ // "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
2537
+ // "uniqueId": null, // unique Id of deposit
2538
+ // "createdAt": 1593437922, // timestamp of deposit
2539
+ // "currency": "Bitcoin", // deposit currency
2540
+ // "ticker": "BTC", // deposit currency ticker
2541
+ // "method": 1, // called method 1 - deposit, 2 - withdraw
2542
+ // "amount": "0.0006", // amount of deposit
2543
+ // "description": "", // deposit description
2544
+ // "memo": "", // deposit memo
2545
+ // "fee": "0", // deposit fee
2546
+ // "status": 15, // transactions status
2547
+ // "network": null, // if currency is multinetwork
2548
+ // "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
2549
+ // "details": {
2550
+ // "partial": { // details about partially successful withdrawals
2551
+ // "requestAmount": "50000", // requested withdrawal amount
2552
+ // "processedAmount": "39000", // processed withdrawal amount
2553
+ // "processedFee": "273", // fee for processed withdrawal amount
2554
+ // "normalizeTransaction": "" // deposit id
2555
+ // }
2556
+ // },
2557
+ // "confirmations": { // if transaction status == 15 you can see this object
2558
+ // "actual": 1, // current block confirmations
2559
+ // "required": 2 // required block confirmation for successful deposit
2560
+ // }
2561
+ // },
2562
+ // {...},
2563
+ // ],
2564
+ // "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
2565
+ // }
2566
+ //
2567
+ const records = this.safeList(response, 'records', []);
2568
+ return this.parseTransactions(records, currency, since, limit);
2569
+ }
2570
+ /**
2571
+ * @method
2572
+ * @name whitebit#fetchBorrowInterest
2573
+ * @description fetch the interest owed by the user for borrowing currency for margin trading
2574
+ * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
2575
+ * @param {string} code unified currency code
2576
+ * @param {string} symbol unified market symbol
2577
+ * @param {int} [since] the earliest time in ms to fetch borrrow interest for
2578
+ * @param {int} [limit] the maximum number of structures to retrieve
2579
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2580
+ * @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
2581
+ */
2582
+ async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2583
+ await this.loadMarkets();
2584
+ const request = {};
2585
+ let market = undefined;
2586
+ if (symbol !== undefined) {
2587
+ market = this.market(symbol);
2588
+ request['market'] = market['id'];
2589
+ }
2590
+ const response = await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(request, params));
2591
+ //
2592
+ // [
2593
+ // {
2594
+ // "positionId": 191823,
2595
+ // "market": "BTC_USDT",
2596
+ // "openDate": 1660340344.027163,
2597
+ // "modifyDate": 1660340344.027163,
2598
+ // "amount": "0.003075",
2599
+ // "basePrice": "24149.24512",
2600
+ // "liquidationPrice": "7059.02",
2601
+ // "leverage": "5",
2602
+ // "pnl": "-0.15",
2603
+ // "pnlPercent": "-0.20",
2604
+ // "margin": "14.86",
2605
+ // "freeMargin": "44.99",
2606
+ // "funding": "0",
2607
+ // "unrealizedFunding": "0.0000307828284903",
2608
+ // "liquidationState": null
2609
+ // }
2610
+ // ]
2611
+ //
2612
+ const interest = this.parseBorrowInterests(response, market);
2613
+ return this.filterByCurrencySinceLimit(interest, code, since, limit);
2614
+ }
2615
+ parseBorrowInterest(info, market = undefined) {
2616
+ //
2617
+ // {
2618
+ // "positionId": 191823,
2619
+ // "market": "BTC_USDT",
2620
+ // "openDate": 1660340344.027163,
2621
+ // "modifyDate": 1660340344.027163,
2622
+ // "amount": "0.003075",
2623
+ // "basePrice": "24149.24512",
2624
+ // "liquidationPrice": "7059.02",
2625
+ // "leverage": "5",
2626
+ // "pnl": "-0.15",
2627
+ // "pnlPercent": "-0.20",
2628
+ // "margin": "14.86",
2629
+ // "freeMargin": "44.99",
2630
+ // "funding": "0",
2631
+ // "unrealizedFunding": "0.0000307828284903",
2632
+ // "liquidationState": null
2633
+ // }
2634
+ //
2635
+ const marketId = this.safeString(info, 'market');
2636
+ const symbol = this.safeSymbol(marketId, market, '_');
2637
+ const timestamp = this.safeTimestamp(info, 'modifyDate');
2638
+ return {
2639
+ 'info': info,
2640
+ 'symbol': symbol,
2641
+ 'currency': 'USDT',
2642
+ 'interest': this.safeNumber(info, 'unrealizedFunding'),
2643
+ 'interestRate': 0.00098,
2644
+ 'amountBorrowed': this.safeNumber(info, 'amount'),
2645
+ 'marginMode': 'cross',
2646
+ 'timestamp': timestamp,
2647
+ 'datetime': this.iso8601(timestamp),
2648
+ };
2649
+ }
2650
+ /**
2651
+ * @method
2652
+ * @name whitebit#fetchFundingRate
2653
+ * @description fetch the current funding rate
2654
+ * @see https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2655
+ * @param {string} symbol unified market symbol
2656
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2657
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2658
+ */
2659
+ async fetchFundingRate(symbol, params = {}) {
2660
+ await this.loadMarkets();
2661
+ symbol = this.symbol(symbol);
2662
+ const response = await this.fetchFundingRates([symbol], params);
2663
+ return this.safeValue(response, symbol);
2664
+ }
2665
+ /**
2666
+ * @method
2667
+ * @name whitebit#fetchFundingRates
2668
+ * @description fetch the funding rate for multiple markets
2669
+ * @see https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2670
+ * @param {string[]|undefined} symbols list of unified market symbols
2671
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2672
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
2673
+ */
2674
+ async fetchFundingRates(symbols = undefined, params = {}) {
2675
+ await this.loadMarkets();
2676
+ symbols = this.marketSymbols(symbols);
2677
+ const response = await this.v4PublicGetFutures(params);
2678
+ //
2679
+ // [
2680
+ // {
2681
+ // "name": "BTC_USDT",
2682
+ // "type": "direct",
2683
+ // "quanto_multiplier": "0.0001",
2684
+ // "ref_discount_rate": "0",
2685
+ // "order_price_deviate": "0.5",
2686
+ // "maintenance_rate": "0.005",
2687
+ // "mark_type": "index",
2688
+ // "last_price": "38026",
2689
+ // "mark_price": "37985.6",
2690
+ // "index_price": "37954.92",
2691
+ // "funding_rate_indicative": "0.000219",
2692
+ // "mark_price_round": "0.01",
2693
+ // "funding_offset": 0,
2694
+ // "in_delisting": false,
2695
+ // "risk_limit_base": "1000000",
2696
+ // "interest_rate": "0.0003",
2697
+ // "order_price_round": "0.1",
2698
+ // "order_size_min": 1,
2699
+ // "ref_rebate_rate": "0.2",
2700
+ // "funding_interval": 28800,
2701
+ // "risk_limit_step": "1000000",
2702
+ // "leverage_min": "1",
2703
+ // "leverage_max": "100",
2704
+ // "risk_limit_max": "8000000",
2705
+ // "maker_fee_rate": "-0.00025",
2706
+ // "taker_fee_rate": "0.00075",
2707
+ // "funding_rate": "0.002053",
2708
+ // "order_size_max": 1000000,
2709
+ // "funding_next_apply": 1610035200,
2710
+ // "short_users": 977,
2711
+ // "config_change_time": 1609899548,
2712
+ // "trade_size": 28530850594,
2713
+ // "position_size": 5223816,
2714
+ // "long_users": 455,
2715
+ // "funding_impact_value": "60000",
2716
+ // "orders_limit": 50,
2717
+ // "trade_id": 10851092,
2718
+ // "orderbook_id": 2129638396
2719
+ // }
2720
+ // ]
2721
+ //
2722
+ const data = this.safeList(response, 'result', []);
2723
+ return this.parseFundingRates(data, symbols);
2724
+ }
2725
+ parseFundingRate(contract, market = undefined) {
2726
+ //
2727
+ // {
2728
+ // "ticker_id":"ADA_PERP",
2729
+ // "stock_currency":"ADA",
2730
+ // "money_currency":"USDT",
2731
+ // "last_price":"0.296708",
2732
+ // "stock_volume":"7982130",
2733
+ // "money_volume":"2345758.29189",
2734
+ // "bid":"0.296608",
2735
+ // "ask":"0.296758",
2736
+ // "high":"0.298338",
2737
+ // "low":"0.290171",
2738
+ // "product_type":"Perpetual",
2739
+ // "open_interest":"46533000",
2740
+ // "index_price":"0.29659",
2741
+ // "index_name":"Cardano",
2742
+ // "index_currency":"ADA",
2743
+ // "funding_rate":"0.0001",
2744
+ // "next_funding_rate_timestamp":"1691193600000",
2745
+ // "brackets":{
2746
+ // "1":"0",
2747
+ // "2":"0",
2748
+ // "3":"0",
2749
+ // "5":"0",
2750
+ // "10":"0",
2751
+ // "20":"0",
2752
+ // "50":"-10000",
2753
+ // "100":"-5000"
2754
+ // },
2755
+ // "max_leverage":"100"
2756
+ // }
2757
+ //
2758
+ const marketId = this.safeString(contract, 'ticker_id');
2759
+ const symbol = this.safeSymbol(marketId, market);
2760
+ const markPrice = this.safeNumber(contract, 'markPrice');
2761
+ const indexPrice = this.safeNumber(contract, 'indexPrice');
2762
+ const interestRate = this.safeNumber(contract, 'interestRate');
2763
+ const fundingRate = this.safeNumber(contract, 'funding_rate');
2764
+ const fundingTime = this.safeInteger(contract, 'next_funding_rate_timestamp');
2765
+ return {
2766
+ 'info': contract,
2767
+ 'symbol': symbol,
2768
+ 'markPrice': markPrice,
2769
+ 'indexPrice': indexPrice,
2770
+ 'interestRate': interestRate,
2771
+ 'timestamp': undefined,
2772
+ 'datetime': undefined,
2773
+ 'fundingRate': fundingRate,
2774
+ 'fundingTimestamp': fundingTime,
2775
+ 'fundingDatetime': this.iso8601(fundingTime),
2776
+ 'nextFundingRate': undefined,
2777
+ 'nextFundingTimestamp': undefined,
2778
+ 'nextFundingDatetime': undefined,
2779
+ 'previousFundingRate': undefined,
2780
+ 'previousFundingTimestamp': undefined,
2781
+ 'previousFundingDatetime': undefined,
2782
+ 'interval': undefined,
2783
+ };
2784
+ }
2785
+ /**
2786
+ * @method
2787
+ * @name whitebit#fetchFundingHistory
2788
+ * @description fetch the history of funding payments paid and received on this account
2789
+ * @see https://docs.whitebit.com/private/http-trade-v4/#funding-history
2790
+ * @param {string} [symbol] unified market symbol
2791
+ * @param {int} [since] the starting timestamp in milliseconds
2792
+ * @param {int} [limit] the number of entries to return
2793
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2794
+ * @param {int} [params.until] the latest time in ms to fetch funding history for
2795
+ * @returns {object[]} a list of [funding history structures]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
2796
+ */
2797
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2798
+ await this.loadMarkets();
2799
+ if (symbol === undefined) {
2800
+ throw new ArgumentsRequired(this.id + ' fetchFundingHistory() requires a symbol argument');
2801
+ }
2802
+ const market = this.market(symbol);
2803
+ let request = {
2804
+ 'market': market['id'],
2805
+ };
2806
+ if (since !== undefined) {
2807
+ request['startDate'] = since;
2808
+ }
2809
+ if (limit !== undefined) {
2810
+ request['limit'] = since;
2811
+ }
2812
+ [request, params] = this.handleUntilOption('endDate', request, params);
2813
+ const response = await this.v4PrivatePostCollateralAccountFundingHistory(request);
2814
+ //
2815
+ // {
2816
+ // "records": [
2817
+ // {
2818
+ // "market": "BTC_PERP",
2819
+ // "fundingTime": "1708704000000",
2820
+ // "fundingRate": "0.00017674",
2821
+ // "fundingAmount": "-0.171053531892",
2822
+ // "positionAmount": "0.019",
2823
+ // "settlementPrice": "50938.2",
2824
+ // "rateCalculatedTime": "1708675200000"
2825
+ // },
2826
+ // ],
2827
+ // "limit": 100,
2828
+ // "offset": 0
2829
+ // }
2830
+ //
2831
+ const data = this.safeList(response, 'records', []);
2832
+ return this.parseFundingHistories(data, market, since, limit);
2833
+ }
2834
+ parseFundingHistory(contract, market = undefined) {
2835
+ //
2836
+ // {
2837
+ // "market": "BTC_PERP",
2838
+ // "fundingTime": "1708704000000",
2839
+ // "fundingRate": "0.00017674",
2840
+ // "fundingAmount": "-0.171053531892",
2841
+ // "positionAmount": "0.019",
2842
+ // "settlementPrice": "50938.2",
2843
+ // "rateCalculatedTime": "1708675200000"
2844
+ // }
2845
+ //
2846
+ const marketId = this.safeString(contract, 'market');
2847
+ const timestamp = this.safeInteger(contract, 'fundingTime');
2848
+ return {
2849
+ 'info': contract,
2850
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
2851
+ 'code': undefined,
2852
+ 'timestamp': timestamp,
2853
+ 'datetime': this.iso8601(timestamp),
2854
+ 'id': undefined,
2855
+ 'amount': this.safeNumber(contract, 'fundingAmount'),
2856
+ };
2857
+ }
2858
+ parseFundingHistories(contracts, market = undefined, since = undefined, limit = undefined) {
2859
+ const result = [];
2860
+ for (let i = 0; i < contracts.length; i++) {
2861
+ const contract = contracts[i];
2862
+ result.push(this.parseFundingHistory(contract, market));
2863
+ }
2864
+ const sorted = this.sortBy(result, 'timestamp');
2865
+ return this.filterBySinceLimit(sorted, since, limit);
2866
+ }
2867
+ /**
2868
+ * @method
2869
+ * @name whitebit#fetchDepositsWithdrawals
2870
+ * @description fetch history of deposits and withdrawals
2871
+ * @see https://github.com/whitebit-exchange/api-docs/blob/main/pages/private/http-main-v4.md#get-depositwithdraw-history
2872
+ * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
2873
+ * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
2874
+ * @param {int} [limit] max number of deposit/withdrawals to return, default = 50, Min: 1, Max: 100
2875
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2876
+ *
2877
+ * EXCHANGE SPECIFIC PARAMETERS
2878
+ * @param {number} [params.transactionMethod] Method. Example: 1 to display deposits / 2 to display withdraws. Do not send this parameter in order to receive both deposits and withdraws.
2879
+ * @param {string} [params.address] Can be used for filtering transactions by specific address or memo.
2880
+ * @param {string[]} [params.addresses] Can be used for filtering transactions by specific addresses or memos (max: 20).
2881
+ * @param {string} [params.uniqueId] Can be used for filtering transactions by specific unique id
2882
+ * @param {int} [params.offset] If you want the request to return entries starting from a particular line, you can use OFFSET clause to tell it where it should start. Default: 0, Min: 0, Max: 10000
2883
+ * @param {string[]} [params.status] Can be used for filtering transactions by status codes. Caution: You must use this parameter with appropriate transactionMethod and use valid status codes for this method. You can find them below. Example: "status": [3,7]
2884
+ * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2885
+ */
2886
+ async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2887
+ await this.loadMarkets();
2888
+ const request = {};
2889
+ let currency = undefined;
2890
+ if (code !== undefined) {
2891
+ currency = this.currency(code);
2892
+ request['ticker'] = currency['id'];
2893
+ }
2894
+ if (limit !== undefined) {
2895
+ request['limit'] = limit; // default 1000
2896
+ }
2897
+ const response = await this.v4PrivatePostMainAccountHistory(this.extend(request, params));
2898
+ //
2899
+ // {
2900
+ // "limit": 100,
2901
+ // "offset": 0,
2902
+ // "records": [
2903
+ // {
2904
+ // "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
2905
+ // "uniqueId": null, // unique Id of deposit
2906
+ // "createdAt": 1593437922, // timestamp of deposit
2907
+ // "currency": "Bitcoin", // deposit currency
2908
+ // "ticker": "BTC", // deposit currency ticker
2909
+ // "method": 1, // called method 1 - deposit, 2 - withdraw
2910
+ // "amount": "0.0006", // amount of deposit
2911
+ // "description": "", // deposit description
2912
+ // "memo": "", // deposit memo
2913
+ // "fee": "0", // deposit fee
2914
+ // "status": 15, // transactions status
2915
+ // "network": null, // if currency is multinetwork
2916
+ // "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
2917
+ // "transactionId": "5e112b38-9652-11ed-a1eb-0242ac120002", // transaction id
2918
+ // "details": {
2919
+ // "partial": { // details about partially successful withdrawals
2920
+ // "requestAmount": "50000", // requested withdrawal amount
2921
+ // "processedAmount": "39000", // processed withdrawal amount
2922
+ // "processedFee": "273", // fee for processed withdrawal amount
2923
+ // "normalizeTransaction": "" // deposit id
2924
+ // }
2925
+ // },
2926
+ // "confirmations": { // if transaction status == 15 (Pending) you can see this object
2927
+ // "actual": 1, // current block confirmations
2928
+ // "required": 2 // required block confirmation for successful deposit
2929
+ // }
2930
+ // },
2931
+ // {...},
2932
+ // ],
2933
+ // "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
2934
+ // }
2935
+ //
2936
+ const records = this.safeList(response, 'records');
2937
+ return this.parseTransactions(records, currency, since, limit);
2938
+ }
2939
+ /**
2940
+ * @method
2941
+ * @name whitebit#fetchConvertQuote
2942
+ * @description fetch a quote for converting from one currency to another
2943
+ * @see https://docs.whitebit.com/private/http-trade-v4/#convert-estimate
2944
+ * @param {string} fromCode the currency that you want to sell and convert from
2945
+ * @param {string} toCode the currency that you want to buy and convert into
2946
+ * @param {float} amount how much you want to trade in units of the from currency
2947
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2948
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
2949
+ */
2950
+ async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
2951
+ await this.loadMarkets();
2952
+ const fromCurrency = this.currency(fromCode);
2953
+ const toCurrency = this.currency(toCode);
2954
+ const request = {
2955
+ 'from': fromCode,
2956
+ 'to': toCode,
2957
+ 'amount': this.numberToString(amount),
2958
+ 'direction': 'from',
2959
+ };
2960
+ const response = await this.v4PrivatePostConvertEstimate(this.extend(request, params));
2961
+ //
2962
+ // {
2963
+ // "give": "4",
2964
+ // "receive": "0.00004762",
2965
+ // "rate": "0.0000119",
2966
+ // "id": "1740889",
2967
+ // "expireAt": 1741090147,
2968
+ // "from": "USDT",
2969
+ // "to": "BTC"
2970
+ // }
2971
+ //
2972
+ return this.parseConversion(response, fromCurrency, toCurrency);
2973
+ }
2974
+ /**
2975
+ * @method
2976
+ * @name whitebit#createConvertTrade
2977
+ * @description convert from one currency to another
2978
+ * @see https://docs.whitebit.com/private/http-trade-v4/#convert-confirm
2979
+ * @param {string} id the id of the trade that you want to make
2980
+ * @param {string} fromCode the currency that you want to sell and convert from
2981
+ * @param {string} toCode the currency that you want to buy and convert into
2982
+ * @param {float} [amount] how much you want to trade in units of the from currency
2983
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2984
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
2985
+ */
2986
+ async createConvertTrade(id, fromCode, toCode, amount = undefined, params = {}) {
2987
+ await this.loadMarkets();
2988
+ const fromCurrency = this.currency(fromCode);
2989
+ const toCurrency = this.currency(toCode);
2990
+ const request = {
2991
+ 'quoteId': id,
2992
+ };
2993
+ const response = await this.v4PrivatePostConvertConfirm(this.extend(request, params));
2994
+ //
2995
+ // {
2996
+ // "finalGive": "4",
2997
+ // "finalReceive": "0.00004772"
2998
+ // }
2999
+ //
3000
+ return this.parseConversion(response, fromCurrency, toCurrency);
3001
+ }
3002
+ /**
3003
+ * @method
3004
+ * @name whitebit#fetchConvertTradeHistory
3005
+ * @description fetch the users history of conversion trades
3006
+ * @see https://docs.whitebit.com/private/http-trade-v4/#convert-history
3007
+ * @param {string} [code] the unified currency code
3008
+ * @param {int} [since] the earliest time in ms to fetch conversions for
3009
+ * @param {int} [limit] the maximum number of conversion structures to retrieve, default 20, max 200
3010
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3011
+ * @param {string} [params.until] the end time in ms
3012
+ * @param {string} [params.fromTicker] the currency that you sold and converted from
3013
+ * @param {string} [params.toTicker] the currency that you bought and converted into
3014
+ * @param {string} [params.quoteId] the quote id of the conversion
3015
+ * @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
3016
+ */
3017
+ async fetchConvertTradeHistory(code = undefined, since = undefined, limit = undefined, params = {}) {
3018
+ await this.loadMarkets();
3019
+ let request = {};
3020
+ if (code !== undefined) {
3021
+ request['fromTicker'] = code;
3022
+ }
3023
+ if (since !== undefined) {
3024
+ const start = this.parseToInt(since / 1000);
3025
+ request['from'] = this.numberToString(start);
3026
+ }
3027
+ if (limit !== undefined) {
3028
+ request['limit'] = limit;
3029
+ }
3030
+ [request, params] = this.handleUntilOption('to', request, params, 0.001);
3031
+ const response = await this.v4PrivatePostConvertHistory(this.extend(request, params));
3032
+ //
3033
+ // {
3034
+ // "records": [
3035
+ // {
3036
+ // "id": "1741105",
3037
+ // "path": [
3038
+ // {
3039
+ // "from": "USDT",
3040
+ // "to": "BTC",
3041
+ // "rate": "0.00001193"
3042
+ // }
3043
+ // ],
3044
+ // "date": 1741090757,
3045
+ // "give": "4",
3046
+ // "receive": "0.00004772",
3047
+ // "rate": "0.00001193"
3048
+ // }
3049
+ // ],
3050
+ // "total": 1,
3051
+ // "limit": 100,
3052
+ // "offset": 0
3053
+ // }
3054
+ //
3055
+ const rows = this.safeList(response, 'records', []);
3056
+ return this.parseConversions(rows, code, 'fromCurrency', 'toCurrency', since, limit);
3057
+ }
3058
+ parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
3059
+ //
3060
+ // fetchConvertQuote
3061
+ //
3062
+ // {
3063
+ // "give": "4",
3064
+ // "receive": "0.00004762",
3065
+ // "rate": "0.0000119",
3066
+ // "id": "1740889",
3067
+ // "expireAt": 1741090147,
3068
+ // "from": "USDT",
3069
+ // "to": "BTC"
3070
+ // }
3071
+ //
3072
+ // createConvertTrade
3073
+ //
3074
+ // {
3075
+ // "finalGive": "4",
3076
+ // "finalReceive": "0.00004772"
3077
+ // }
3078
+ //
3079
+ // fetchConvertTradeHistory
3080
+ //
3081
+ // {
3082
+ // "id": "1741105",
3083
+ // "path": [
3084
+ // {
3085
+ // "from": "USDT",
3086
+ // "to": "BTC",
3087
+ // "rate": "0.00001193"
3088
+ // }
3089
+ // ],
3090
+ // "date": 1741090757,
3091
+ // "give": "4",
3092
+ // "receive": "0.00004772",
3093
+ // "rate": "0.00001193"
3094
+ // }
3095
+ //
3096
+ const path = this.safeList(conversion, 'path', []);
3097
+ const first = this.safeDict(path, 0, {});
3098
+ const fromPath = this.safeString(first, 'from');
3099
+ const toPath = this.safeString(first, 'to');
3100
+ const timestamp = this.safeTimestamp2(conversion, 'date', 'expireAt');
3101
+ const fromCoin = this.safeString(conversion, 'from', fromPath);
3102
+ const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
3103
+ const toCoin = this.safeString(conversion, 'to', toPath);
3104
+ const toCode = this.safeCurrencyCode(toCoin, toCurrency);
3105
+ return {
3106
+ 'info': conversion,
3107
+ 'timestamp': timestamp,
3108
+ 'datetime': this.iso8601(timestamp),
3109
+ 'id': this.safeString(conversion, 'id'),
3110
+ 'fromCurrency': fromCode,
3111
+ 'fromAmount': this.safeNumber2(conversion, 'give', 'finalGive'),
3112
+ 'toCurrency': toCode,
3113
+ 'toAmount': this.safeNumber2(conversion, 'receive', 'finalReceive'),
3114
+ 'price': this.safeNumber(conversion, 'rate'),
3115
+ 'fee': undefined,
3116
+ };
3117
+ }
3118
+ /**
3119
+ * @method
3120
+ * @name whitebit#fetchPositionHistory
3121
+ * @description fetches historical positions
3122
+ * @see https://docs.whitebit.com/private/http-trade-v4/#positions-history
3123
+ * @param {string} symbol unified contract symbol
3124
+ * @param {int} [since] the earliest time in ms to fetch positions for
3125
+ * @param {int} [limit] the maximum amount of records to fetch
3126
+ * @param {object} [params] extra parameters specific to the exchange api endpoint
3127
+ * @param {int} [params.positionId] the id of the requested position
3128
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
3129
+ */
3130
+ async fetchPositionHistory(symbol, since = undefined, limit = undefined, params = {}) {
3131
+ await this.loadMarkets();
3132
+ const market = this.market(symbol);
3133
+ let request = {
3134
+ 'market': market['id'],
3135
+ };
3136
+ if (since !== undefined) {
3137
+ request['startDate'] = since;
3138
+ }
3139
+ if (limit !== undefined) {
3140
+ request['limit'] = since;
3141
+ }
3142
+ [request, params] = this.handleUntilOption('endDate', request, params);
3143
+ const response = await this.v4PrivatePostCollateralAccountPositionsHistory(this.extend(request, params));
3144
+ //
3145
+ // [
3146
+ // {
3147
+ // "positionId": 479975679,
3148
+ // "market": "BTC_PERP",
3149
+ // "openDate": 1741941025.309887,
3150
+ // "modifyDate": 1741941025.309887,
3151
+ // "amount": "0.001",
3152
+ // "basePrice": "82498.7",
3153
+ // "realizedFunding": "0",
3154
+ // "liquidationPrice": "0",
3155
+ // "liquidationState": null,
3156
+ // "orderDetail": {
3157
+ // "id": 1224727949521,
3158
+ // "tradeAmount": "0.001",
3159
+ // "price": "82498.7",
3160
+ // "tradeFee": "0.028874545",
3161
+ // "fundingFee": "0",
3162
+ // "realizedPnl": "-0.028874545"
3163
+ // }
3164
+ // }
3165
+ // ]
3166
+ //
3167
+ const positions = this.parsePositions(response);
3168
+ return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
3169
+ }
3170
+ /**
3171
+ * @method
3172
+ * @name whitebit#fetchPositions
3173
+ * @description fetch all open positions
3174
+ * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
3175
+ * @param {string[]} [symbols] list of unified market symbols
3176
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3177
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
3178
+ */
3179
+ async fetchPositions(symbols = undefined, params = {}) {
3180
+ await this.loadMarkets();
3181
+ symbols = this.marketSymbols(symbols);
3182
+ const response = await this.v4PrivatePostCollateralAccountPositionsOpen(params);
3183
+ //
3184
+ // [
3185
+ // {
3186
+ // "positionId": 479975679,
3187
+ // "market": "BTC_PERP",
3188
+ // "openDate": 1741941025.3098869,
3189
+ // "modifyDate": 1741941025.3098869,
3190
+ // "amount": "0.001",
3191
+ // "basePrice": "82498.7",
3192
+ // "liquidationPrice": "70177.2",
3193
+ // "pnl": "0",
3194
+ // "pnlPercent": "0.00",
3195
+ // "margin": "4.2",
3196
+ // "freeMargin": "9.9",
3197
+ // "funding": "0",
3198
+ // "unrealizedFunding": "0",
3199
+ // "liquidationState": null,
3200
+ // "tpsl": null
3201
+ // }
3202
+ // ]
3203
+ //
3204
+ return this.parsePositions(response, symbols);
3205
+ }
3206
+ /**
3207
+ * @method
3208
+ * @name whitebit#fetchPosition
3209
+ * @description fetch data on a single open contract trade position
3210
+ * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
3211
+ * @param {string} symbol unified market symbol of the market the position is held in
3212
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3213
+ * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3214
+ */
3215
+ async fetchPosition(symbol, params = {}) {
3216
+ await this.loadMarkets();
3217
+ const market = this.market(symbol);
3218
+ const request = {
3219
+ 'symbol': market['id'],
3220
+ };
3221
+ const response = await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(request, params));
3222
+ //
3223
+ // [
3224
+ // {
3225
+ // "positionId": 479975679,
3226
+ // "market": "BTC_PERP",
3227
+ // "openDate": 1741941025.3098869,
3228
+ // "modifyDate": 1741941025.3098869,
3229
+ // "amount": "0.001",
3230
+ // "basePrice": "82498.7",
3231
+ // "liquidationPrice": "70177.2",
3232
+ // "pnl": "0",
3233
+ // "pnlPercent": "0.00",
3234
+ // "margin": "4.2",
3235
+ // "freeMargin": "9.9",
3236
+ // "funding": "0",
3237
+ // "unrealizedFunding": "0",
3238
+ // "liquidationState": null,
3239
+ // "tpsl": null
3240
+ // }
3241
+ // ]
3242
+ //
3243
+ const data = this.safeDict(response, 0, {});
3244
+ return this.parsePosition(data, market);
3245
+ }
3246
+ parsePosition(position, market = undefined) {
3247
+ //
3248
+ // fetchPosition, fetchPositions
3249
+ //
3250
+ // {
3251
+ // "positionId": 479975679,
3252
+ // "market": "BTC_PERP",
3253
+ // "openDate": 1741941025.3098869,
3254
+ // "modifyDate": 1741941025.3098869,
3255
+ // "amount": "0.001",
3256
+ // "basePrice": "82498.7",
3257
+ // "liquidationPrice": "70177.2",
3258
+ // "pnl": "0",
3259
+ // "pnlPercent": "0.00",
3260
+ // "margin": "4.2",
3261
+ // "freeMargin": "9.9",
3262
+ // "funding": "0",
3263
+ // "unrealizedFunding": "0",
3264
+ // "liquidationState": null,
3265
+ // "tpsl": null
3266
+ // }
3267
+ //
3268
+ // fetchPositionHistory
3269
+ //
3270
+ // {
3271
+ // "positionId": 479975679,
3272
+ // "market": "BTC_PERP",
3273
+ // "openDate": 1741941025.309887,
3274
+ // "modifyDate": 1741941025.309887,
3275
+ // "amount": "0.001",
3276
+ // "basePrice": "82498.7",
3277
+ // "realizedFunding": "0",
3278
+ // "liquidationPrice": "0",
3279
+ // "liquidationState": null,
3280
+ // "orderDetail": {
3281
+ // "id": 1224727949521,
3282
+ // "tradeAmount": "0.001",
3283
+ // "price": "82498.7",
3284
+ // "tradeFee": "0.028874545",
3285
+ // "fundingFee": "0",
3286
+ // "realizedPnl": "-0.028874545"
3287
+ // }
3288
+ // }
3289
+ //
3290
+ const marketId = this.safeString(position, 'market');
3291
+ const timestamp = this.safeTimestamp(position, 'openDate');
3292
+ const tpsl = this.safeDict(position, 'tpsl', {});
3293
+ const orderDetail = this.safeDict(position, 'orderDetail', {});
3294
+ return this.safePosition({
3295
+ 'info': position,
3296
+ 'id': this.safeString(position, 'positionId'),
3297
+ 'symbol': this.safeSymbol(marketId, market),
3298
+ 'notional': undefined,
3299
+ 'marginMode': undefined,
3300
+ 'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
3301
+ 'entryPrice': this.safeNumber(position, 'basePrice'),
3302
+ 'unrealizedPnl': this.safeNumber(position, 'pnl'),
3303
+ 'realizedPnl': this.safeNumber(orderDetail, 'realizedPnl'),
3304
+ 'percentage': this.safeNumber(position, 'pnlPercent'),
3305
+ 'contracts': undefined,
3306
+ 'contractSize': undefined,
3307
+ 'markPrice': undefined,
3308
+ 'lastPrice': undefined,
3309
+ 'side': undefined,
3310
+ 'hedged': undefined,
3311
+ 'timestamp': timestamp,
3312
+ 'datetime': this.iso8601(timestamp),
3313
+ 'lastUpdateTimestamp': this.safeTimestamp(position, 'modifyDate'),
3314
+ 'maintenanceMargin': undefined,
3315
+ 'maintenanceMarginPercentage': undefined,
3316
+ 'collateral': this.safeNumber(position, 'margin'),
3317
+ 'initialMargin': undefined,
3318
+ 'initialMarginPercentage': undefined,
3319
+ 'leverage': undefined,
3320
+ 'marginRatio': undefined,
3321
+ 'stopLossPrice': this.safeNumber(tpsl, 'stopLoss'),
3322
+ 'takeProfitPrice': this.safeNumber(tpsl, 'takeProfit'),
3323
+ });
3324
+ }
3325
+ /**
3326
+ * @method
3327
+ * @name whitebit#fetchCrossBorrowRate
3328
+ * @description fetch the rate of interest to borrow a currency for margin trading
3329
+ * @see https://docs.whitebit.com/private/http-main-v4/#get-plans
3330
+ * @param {string} code unified currency code
3331
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3332
+ * @returns {object} a [borrow rate structure]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
3333
+ */
3334
+ async fetchCrossBorrowRate(code, params = {}) {
3335
+ await this.loadMarkets();
3336
+ const currency = this.currency(code);
3337
+ const request = {
3338
+ 'ticker': currency['id'],
3339
+ };
3340
+ const response = await this.v4PrivatePostMainAccountSmartPlans(this.extend(request, params));
3341
+ //
3342
+ //
3343
+ const data = this.safeList(response, 0, []);
3344
+ return this.parseBorrowRate(data, currency);
3345
+ }
3346
+ parseBorrowRate(info, currency = undefined) {
3347
+ //
3348
+ //
3349
+ const currencyId = this.safeString(info, 'ticker');
3350
+ const percent = this.safeString(info, 'percent');
3351
+ return {
3352
+ 'currency': this.safeCurrencyCode(currencyId, currency),
3353
+ 'rate': this.parseNumber(Precise.stringDiv(percent, '100')),
3354
+ 'period': this.safeInteger(info, 'duration'),
3355
+ 'timestamp': undefined,
3356
+ 'datetime': undefined,
3357
+ 'info': info,
3358
+ };
3359
+ }
3360
+ isFiat(currency) {
3361
+ const fiatCurrencies = this.safeValue(this.options, 'fiatCurrencies', []);
3362
+ return this.inArray(currency, fiatCurrencies);
3363
+ }
3364
+ nonce() {
3365
+ return this.milliseconds() - this.options['timeDifference'];
3366
+ }
3367
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3368
+ const query = this.omit(params, this.extractParams(path));
3369
+ const version = this.safeValue(api, 0);
3370
+ const accessibility = this.safeValue(api, 1);
3371
+ const pathWithParams = '/' + this.implodeParams(path, params);
3372
+ let url = this.urls['api'][version][accessibility] + pathWithParams;
3373
+ if (accessibility === 'public') {
3374
+ if (Object.keys(query).length) {
3375
+ url += '?' + this.urlencode(query);
3376
+ }
3377
+ }
3378
+ if (accessibility === 'private') {
3379
+ this.checkRequiredCredentials();
3380
+ const nonce = this.nonce().toString();
3381
+ const secret = this.encode(this.secret);
3382
+ const request = '/' + 'api' + '/' + version + pathWithParams;
3383
+ body = this.json(this.extend({ 'request': request, 'nonce': nonce }, params));
3384
+ const payload = this.stringToBase64(body);
3385
+ const signature = this.hmac(this.encode(payload), secret, sha512);
3386
+ headers = {
3387
+ 'Content-Type': 'application/json',
3388
+ 'X-TXC-APIKEY': this.apiKey,
3389
+ 'X-TXC-PAYLOAD': payload,
3390
+ 'X-TXC-SIGNATURE': signature,
3391
+ };
3392
+ }
3393
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3394
+ }
3395
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3396
+ if ((code === 418) || (code === 429)) {
3397
+ throw new DDoSProtection(this.id + ' ' + code.toString() + ' ' + reason + ' ' + body);
3398
+ }
3399
+ if (code === 404) {
3400
+ throw new ExchangeError(this.id + ' ' + code.toString() + ' endpoint not found');
3401
+ }
3402
+ if (response !== undefined) {
3403
+ // For cases where we have a meaningful status
3404
+ // {"response":null,"status":422,"errors":{"orderId":["Finished order id 435453454535 not found on your account"]},"notification":null,"warning":"Finished order id 435453454535 not found on your account","_token":null}
3405
+ const status = this.safeString(response, 'status');
3406
+ const errors = this.safeValue(response, 'errors');
3407
+ // {"code":10,"message":"Unauthorized request."}
3408
+ const message = this.safeString(response, 'message');
3409
+ // For these cases where we have a generic code variable error key
3410
+ // {"code":0,"message":"Validation failed","errors":{"amount":["Amount must be greater than 0"]}}
3411
+ const codeNew = this.safeInteger(response, 'code');
3412
+ const hasErrorStatus = status !== undefined && status !== '200' && errors !== undefined;
3413
+ if (hasErrorStatus || codeNew !== undefined) {
3414
+ const feedback = this.id + ' ' + body;
3415
+ let errorInfo = message;
3416
+ if (hasErrorStatus) {
3417
+ errorInfo = status;
3418
+ }
3419
+ else {
3420
+ const errorObject = this.safeDict(response, 'errors', {});
3421
+ const errorKeys = Object.keys(errorObject);
3422
+ const errorsLength = errorKeys.length;
3423
+ if (errorsLength > 0) {
3424
+ const errorKey = errorKeys[0];
3425
+ const errorMessageArray = this.safeValue(errorObject, errorKey, []);
3426
+ const errorMessageLength = errorMessageArray.length;
3427
+ errorInfo = (errorMessageLength > 0) ? errorMessageArray[0] : body;
3428
+ }
3429
+ }
3430
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorInfo, feedback);
3431
+ this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
3432
+ throw new ExchangeError(feedback);
3433
+ }
3434
+ }
3435
+ return undefined;
3436
+ }
3437
+ }