ccxt-ir 4.10.0 → 4.12.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 (1059) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +10 -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/dist/cjs/src/changefa.js +342 -0
  8. package/dist/cjs/src/ourbit.js +445 -0
  9. package/js/ccxt.d.ts +11 -2
  10. package/js/ccxt.js +8 -2
  11. package/js/src/abstract/bidarz.d.ts +9 -0
  12. package/js/src/abstract/bidarz.js +11 -0
  13. package/js/src/abstract/changefa.d.ts +8 -0
  14. package/js/src/abstract/changefa.js +11 -0
  15. package/js/src/abstract/ourbit.d.ts +10 -0
  16. package/js/src/abstract/ourbit.js +11 -0
  17. package/js/src/bidarz.d.ts +22 -0
  18. package/js/src/bidarz.js +336 -0
  19. package/js/src/bit24.js +4 -3
  20. package/js/src/changefa.d.ts +20 -0
  21. package/js/src/changefa.js +341 -0
  22. package/js/src/ourbit.d.ts +21 -0
  23. package/js/src/ourbit.js +444 -0
  24. package/js/src/src/abantether.d.ts +21 -0
  25. package/js/src/src/abantether.js +353 -0
  26. package/js/src/src/abstract/abantether.d.ts +8 -0
  27. package/js/src/src/abstract/abantether.js +11 -0
  28. package/js/src/src/abstract/afratether.d.ts +9 -0
  29. package/js/src/src/abstract/afratether.js +11 -0
  30. package/js/src/src/abstract/alpaca.d.ts +77 -0
  31. package/js/src/src/abstract/alpaca.js +11 -0
  32. package/js/src/src/abstract/apex.d.ts +34 -0
  33. package/js/src/src/abstract/apex.js +11 -0
  34. package/js/src/src/abstract/arzinja.d.ts +8 -0
  35. package/js/src/src/abstract/arzinja.js +11 -0
  36. package/js/src/src/abstract/arzplus.d.ts +11 -0
  37. package/js/src/src/abstract/arzplus.js +11 -0
  38. package/js/src/src/abstract/ascendex.d.ts +80 -0
  39. package/js/src/src/abstract/ascendex.js +11 -0
  40. package/js/src/src/abstract/asretether.d.ts +8 -0
  41. package/js/src/src/abstract/asretether.js +11 -0
  42. package/js/src/src/abstract/bidarz.d.ts +9 -0
  43. package/js/src/src/abstract/bidarz.js +11 -0
  44. package/js/src/src/abstract/bigone.d.ts +48 -0
  45. package/js/src/src/abstract/bigone.js +11 -0
  46. package/js/src/src/abstract/binance.d.ts +773 -0
  47. package/js/src/src/abstract/binance.js +11 -0
  48. package/js/src/src/abstract/bingx.d.ts +165 -0
  49. package/js/src/src/abstract/bingx.js +11 -0
  50. package/js/src/src/abstract/bit24.d.ts +9 -0
  51. package/js/src/src/abstract/bit24.js +11 -0
  52. package/js/src/src/abstract/bit2c.d.ts +30 -0
  53. package/js/src/src/abstract/bit2c.js +11 -0
  54. package/js/src/src/abstract/bitbank.d.ts +35 -0
  55. package/js/src/src/abstract/bitbank.js +11 -0
  56. package/js/src/src/abstract/bitbarg.d.ts +8 -0
  57. package/js/src/src/abstract/bitbarg.js +11 -0
  58. package/js/src/src/abstract/bitbns.d.ts +43 -0
  59. package/js/src/src/abstract/bitbns.js +11 -0
  60. package/js/src/src/abstract/bitfinex.d.ts +143 -0
  61. package/js/src/src/abstract/bitfinex.js +11 -0
  62. package/js/src/src/abstract/bitflyer.d.ts +42 -0
  63. package/js/src/src/abstract/bitflyer.js +11 -0
  64. package/js/src/src/abstract/bitget.d.ts +578 -0
  65. package/js/src/src/abstract/bitget.js +11 -0
  66. package/js/src/src/abstract/bithumb.d.ts +35 -0
  67. package/js/src/src/abstract/bithumb.js +11 -0
  68. package/js/src/src/abstract/bitimen.d.ts +10 -0
  69. package/js/src/src/abstract/bitimen.js +11 -0
  70. package/js/src/src/abstract/bitir.d.ts +10 -0
  71. package/js/src/src/abstract/bitir.js +11 -0
  72. package/js/src/src/abstract/bitmart.d.ts +120 -0
  73. package/js/src/src/abstract/bitmart.js +11 -0
  74. package/js/src/src/abstract/bitmex.d.ts +100 -0
  75. package/js/src/src/abstract/bitmex.js +11 -0
  76. package/js/src/src/abstract/bitopro.d.ts +33 -0
  77. package/js/src/src/abstract/bitopro.js +11 -0
  78. package/js/src/src/abstract/bitpin.d.ts +11 -0
  79. package/js/src/src/abstract/bitpin.js +11 -0
  80. package/js/src/src/abstract/bitrue.d.ts +75 -0
  81. package/js/src/src/abstract/bitrue.js +11 -0
  82. package/js/src/src/abstract/bitso.d.ts +46 -0
  83. package/js/src/src/abstract/bitso.js +11 -0
  84. package/js/src/src/abstract/bitstamp.d.ts +262 -0
  85. package/js/src/src/abstract/bitstamp.js +11 -0
  86. package/js/src/src/abstract/bitteam.d.ts +32 -0
  87. package/js/src/src/abstract/bitteam.js +11 -0
  88. package/js/src/src/abstract/bittrade.d.ts +117 -0
  89. package/js/src/src/abstract/bittrade.js +11 -0
  90. package/js/src/src/abstract/bitunix.d.ts +9 -0
  91. package/js/src/src/abstract/bitunix.js +11 -0
  92. package/js/src/src/abstract/bitvavo.d.ts +30 -0
  93. package/js/src/src/abstract/bitvavo.js +11 -0
  94. package/js/src/src/abstract/blockchaincom.d.ts +31 -0
  95. package/js/src/src/abstract/blockchaincom.js +11 -0
  96. package/js/src/src/abstract/blofin.d.ts +70 -0
  97. package/js/src/src/abstract/blofin.js +11 -0
  98. package/js/src/src/abstract/btcalpha.d.ts +21 -0
  99. package/js/src/src/abstract/btcalpha.js +11 -0
  100. package/js/src/src/abstract/btcbox.d.ts +18 -0
  101. package/js/src/src/abstract/btcbox.js +11 -0
  102. package/js/src/src/abstract/btcmarkets.d.ts +42 -0
  103. package/js/src/src/abstract/btcmarkets.js +11 -0
  104. package/js/src/src/abstract/btcturk.d.ts +23 -0
  105. package/js/src/src/abstract/btcturk.js +11 -0
  106. package/js/src/src/abstract/bybit.d.ts +316 -0
  107. package/js/src/src/abstract/bybit.js +11 -0
  108. package/js/src/src/abstract/bydfi.d.ts +11 -0
  109. package/js/src/src/abstract/bydfi.js +11 -0
  110. package/js/src/src/abstract/cafearz.d.ts +8 -0
  111. package/js/src/src/abstract/cafearz.js +11 -0
  112. package/js/src/src/abstract/cex.d.ts +35 -0
  113. package/js/src/src/abstract/cex.js +11 -0
  114. package/js/src/src/abstract/coinbase.d.ts +97 -0
  115. package/js/src/src/abstract/coinbase.js +11 -0
  116. package/js/src/src/abstract/coinbaseexchange.d.ts +71 -0
  117. package/js/src/src/abstract/coinbaseexchange.js +11 -0
  118. package/js/src/src/abstract/coinbaseinternational.d.ts +42 -0
  119. package/js/src/src/abstract/coinbaseinternational.js +11 -0
  120. package/js/src/src/abstract/coincatch.d.ts +97 -0
  121. package/js/src/src/abstract/coincatch.js +11 -0
  122. package/js/src/src/abstract/coincheck.d.ts +36 -0
  123. package/js/src/src/abstract/coincheck.js +11 -0
  124. package/js/src/src/abstract/coinex.d.ts +240 -0
  125. package/js/src/src/abstract/coinex.js +11 -0
  126. package/js/src/src/abstract/coinmate.d.ts +65 -0
  127. package/js/src/src/abstract/coinmate.js +11 -0
  128. package/js/src/src/abstract/coinmetro.d.ts +37 -0
  129. package/js/src/src/abstract/coinmetro.js +11 -0
  130. package/js/src/src/abstract/coinone.d.ts +70 -0
  131. package/js/src/src/abstract/coinone.js +11 -0
  132. package/js/src/src/abstract/coinsph.d.ts +57 -0
  133. package/js/src/src/abstract/coinsph.js +11 -0
  134. package/js/src/src/abstract/coinspot.d.ts +31 -0
  135. package/js/src/src/abstract/coinspot.js +11 -0
  136. package/js/src/src/abstract/cryptocom.d.ts +126 -0
  137. package/js/src/src/abstract/cryptocom.js +11 -0
  138. package/js/src/src/abstract/cryptomus.d.ts +23 -0
  139. package/js/src/src/abstract/cryptomus.js +11 -0
  140. package/js/src/src/abstract/defx.d.ts +72 -0
  141. package/js/src/src/abstract/defx.js +11 -0
  142. package/js/src/src/abstract/delta.d.ts +53 -0
  143. package/js/src/src/abstract/delta.js +11 -0
  144. package/js/src/src/abstract/deribit.d.ts +129 -0
  145. package/js/src/src/abstract/deribit.js +11 -0
  146. package/js/src/src/abstract/derive.d.ts +120 -0
  147. package/js/src/src/abstract/derive.js +11 -0
  148. package/js/src/src/abstract/digifinex.d.ts +95 -0
  149. package/js/src/src/abstract/digifinex.js +11 -0
  150. package/js/src/src/abstract/ellipx.d.ts +28 -0
  151. package/js/src/src/abstract/ellipx.js +11 -0
  152. package/js/src/src/abstract/eterex.d.ts +8 -0
  153. package/js/src/src/abstract/eterex.js +11 -0
  154. package/js/src/src/abstract/excoino.d.ts +10 -0
  155. package/js/src/src/abstract/excoino.js +11 -0
  156. package/js/src/src/abstract/exir.d.ts +11 -0
  157. package/js/src/src/abstract/exir.js +11 -0
  158. package/js/src/src/abstract/exmo.d.ts +58 -0
  159. package/js/src/src/abstract/exmo.js +11 -0
  160. package/js/src/src/abstract/exnovin.d.ts +9 -0
  161. package/js/src/src/abstract/exnovin.js +11 -0
  162. package/js/src/src/abstract/farhadexchange.d.ts +8 -0
  163. package/js/src/src/abstract/farhadexchange.js +11 -0
  164. package/js/src/src/abstract/foxbit.d.ts +29 -0
  165. package/js/src/src/abstract/foxbit.js +11 -0
  166. package/js/src/src/abstract/gate.d.ts +287 -0
  167. package/js/src/src/abstract/gate.js +11 -0
  168. package/js/src/src/abstract/gemini.d.ts +62 -0
  169. package/js/src/src/abstract/gemini.js +11 -0
  170. package/js/src/src/abstract/hamtapay.d.ts +9 -0
  171. package/js/src/src/abstract/hamtapay.js +11 -0
  172. package/js/src/src/abstract/hashkey.d.ts +70 -0
  173. package/js/src/src/abstract/hashkey.js +11 -0
  174. package/js/src/src/abstract/hibachi.d.ts +29 -0
  175. package/js/src/src/abstract/hibachi.js +11 -0
  176. package/js/src/src/abstract/hitbtc.d.ts +118 -0
  177. package/js/src/src/abstract/hitbtc.js +11 -0
  178. package/js/src/src/abstract/hitobit.d.ts +11 -0
  179. package/js/src/src/abstract/hitobit.js +11 -0
  180. package/js/src/src/abstract/hollaex.d.ts +36 -0
  181. package/js/src/src/abstract/hollaex.js +11 -0
  182. package/js/src/src/abstract/htx.d.ts +551 -0
  183. package/js/src/src/abstract/htx.js +11 -0
  184. package/js/src/src/abstract/hyperliquid.d.ts +9 -0
  185. package/js/src/src/abstract/hyperliquid.js +11 -0
  186. package/js/src/src/abstract/independentreserve.d.ts +46 -0
  187. package/js/src/src/abstract/independentreserve.js +11 -0
  188. package/js/src/src/abstract/indodax.d.ts +29 -0
  189. package/js/src/src/abstract/indodax.js +11 -0
  190. package/js/src/src/abstract/iranexchange.d.ts +9 -0
  191. package/js/src/src/abstract/iranexchange.js +11 -0
  192. package/js/src/src/abstract/jibitex.d.ts +10 -0
  193. package/js/src/src/abstract/jibitex.js +11 -0
  194. package/js/src/src/abstract/kcex.d.ts +10 -0
  195. package/js/src/src/abstract/kcex.js +11 -0
  196. package/js/src/src/abstract/kifpoolme.d.ts +9 -0
  197. package/js/src/src/abstract/kifpoolme.js +11 -0
  198. package/js/src/src/abstract/kraken.d.ts +61 -0
  199. package/js/src/src/abstract/kraken.js +11 -0
  200. package/js/src/src/abstract/krakenfutures.d.ts +45 -0
  201. package/js/src/src/abstract/krakenfutures.js +11 -0
  202. package/js/src/src/abstract/kucoin.d.ts +227 -0
  203. package/js/src/src/abstract/kucoin.js +11 -0
  204. package/js/src/src/abstract/kucoinfutures.d.ts +254 -0
  205. package/js/src/src/abstract/kucoinfutures.js +11 -0
  206. package/js/src/src/abstract/latoken.d.ts +59 -0
  207. package/js/src/src/abstract/latoken.js +11 -0
  208. package/js/src/src/abstract/lbank.d.ts +65 -0
  209. package/js/src/src/abstract/lbank.js +11 -0
  210. package/js/src/src/abstract/luno.d.ts +41 -0
  211. package/js/src/src/abstract/luno.js +11 -0
  212. package/js/src/src/abstract/mazdax.d.ts +11 -0
  213. package/js/src/src/abstract/mazdax.js +11 -0
  214. package/js/src/src/abstract/mercado.d.ts +28 -0
  215. package/js/src/src/abstract/mercado.js +11 -0
  216. package/js/src/src/abstract/mexc.d.ts +183 -0
  217. package/js/src/src/abstract/mexc.js +11 -0
  218. package/js/src/src/abstract/modetrade.d.ts +122 -0
  219. package/js/src/src/abstract/modetrade.js +11 -0
  220. package/js/src/src/abstract/ndax.d.ts +100 -0
  221. package/js/src/src/abstract/ndax.js +11 -0
  222. package/js/src/src/abstract/nobitex.d.ts +10 -0
  223. package/js/src/src/abstract/nobitex.js +11 -0
  224. package/js/src/src/abstract/novadax.d.ts +32 -0
  225. package/js/src/src/abstract/novadax.js +11 -0
  226. package/js/src/src/abstract/oceanex.d.ts +30 -0
  227. package/js/src/src/abstract/oceanex.js +11 -0
  228. package/js/src/src/abstract/okcoin.d.ts +77 -0
  229. package/js/src/src/abstract/okcoin.js +11 -0
  230. package/js/src/src/abstract/okexchange.d.ts +11 -0
  231. package/js/src/src/abstract/okexchange.js +11 -0
  232. package/js/src/src/abstract/okx.d.ts +352 -0
  233. package/js/src/src/abstract/okx.js +11 -0
  234. package/js/src/src/abstract/ompfinex.d.ts +10 -0
  235. package/js/src/src/abstract/ompfinex.js +11 -0
  236. package/js/src/src/abstract/onetrading.d.ts +26 -0
  237. package/js/src/src/abstract/onetrading.js +11 -0
  238. package/js/src/src/abstract/oxfun.d.ts +37 -0
  239. package/js/src/src/abstract/oxfun.js +11 -0
  240. package/js/src/src/abstract/p2b.d.ts +25 -0
  241. package/js/src/src/abstract/p2b.js +11 -0
  242. package/js/src/src/abstract/paradex.d.ts +66 -0
  243. package/js/src/src/abstract/paradex.js +11 -0
  244. package/js/src/src/abstract/paymium.d.ts +31 -0
  245. package/js/src/src/abstract/paymium.js +11 -0
  246. package/js/src/src/abstract/phemex.d.ts +120 -0
  247. package/js/src/src/abstract/phemex.js +11 -0
  248. package/js/src/src/abstract/pingi.d.ts +9 -0
  249. package/js/src/src/abstract/pingi.js +11 -0
  250. package/js/src/src/abstract/poloniex.d.ts +108 -0
  251. package/js/src/src/abstract/poloniex.js +11 -0
  252. package/js/src/src/abstract/pooleno.d.ts +8 -0
  253. package/js/src/src/abstract/pooleno.js +11 -0
  254. package/js/src/src/abstract/probit.d.ts +26 -0
  255. package/js/src/src/abstract/probit.js +11 -0
  256. package/js/src/src/abstract/raastin.d.ts +11 -0
  257. package/js/src/src/abstract/raastin.js +11 -0
  258. package/js/src/src/abstract/ramzinex.d.ts +10 -0
  259. package/js/src/src/abstract/ramzinex.js +11 -0
  260. package/js/src/src/abstract/sarmayex.d.ts +8 -0
  261. package/js/src/src/abstract/sarmayex.js +11 -0
  262. package/js/src/src/abstract/sarrafex.d.ts +10 -0
  263. package/js/src/src/abstract/sarrafex.js +11 -0
  264. package/js/src/src/abstract/tabdeal.d.ts +10 -0
  265. package/js/src/src/abstract/tabdeal.js +11 -0
  266. package/js/src/src/abstract/tehran_exchange.d.ts +9 -0
  267. package/js/src/src/abstract/tehran_exchange.js +11 -0
  268. package/js/src/src/abstract/tetherland.d.ts +8 -0
  269. package/js/src/src/abstract/tetherland.js +11 -0
  270. package/js/src/src/abstract/timex.d.ts +65 -0
  271. package/js/src/src/abstract/timex.js +11 -0
  272. package/js/src/src/abstract/tokocrypto.d.ts +40 -0
  273. package/js/src/src/abstract/tokocrypto.js +11 -0
  274. package/js/src/src/abstract/toobit.d.ts +10 -0
  275. package/js/src/src/abstract/toobit.js +11 -0
  276. package/js/src/src/abstract/tradeogre.d.ts +21 -0
  277. package/js/src/src/abstract/tradeogre.js +11 -0
  278. package/js/src/src/abstract/twox.d.ts +8 -0
  279. package/js/src/src/abstract/twox.js +11 -0
  280. package/js/src/src/abstract/ubitex.d.ts +10 -0
  281. package/js/src/src/abstract/ubitex.js +11 -0
  282. package/js/src/src/abstract/upbit.d.ts +58 -0
  283. package/js/src/src/abstract/upbit.js +11 -0
  284. package/js/src/src/abstract/vertex.d.ts +22 -0
  285. package/js/src/src/abstract/vertex.js +11 -0
  286. package/js/src/src/abstract/wallex.d.ts +11 -0
  287. package/js/src/src/abstract/wallex.js +11 -0
  288. package/js/src/src/abstract/wavesexchange.d.ts +157 -0
  289. package/js/src/src/abstract/wavesexchange.js +11 -0
  290. package/js/src/src/abstract/whitebit.d.ts +117 -0
  291. package/js/src/src/abstract/whitebit.js +11 -0
  292. package/js/src/src/abstract/woo.d.ts +144 -0
  293. package/js/src/src/abstract/woo.js +11 -0
  294. package/js/src/src/abstract/woofipro.d.ts +122 -0
  295. package/js/src/src/abstract/woofipro.js +11 -0
  296. package/js/src/src/abstract/xt.d.ts +160 -0
  297. package/js/src/src/abstract/xt.js +11 -0
  298. package/js/src/src/abstract/yobit.d.ts +19 -0
  299. package/js/src/src/abstract/yobit.js +11 -0
  300. package/js/src/src/abstract/zaif.d.ts +41 -0
  301. package/js/src/src/abstract/zaif.js +11 -0
  302. package/js/src/src/abstract/zonda.d.ts +56 -0
  303. package/js/src/src/abstract/zonda.js +11 -0
  304. package/js/src/src/afratether.d.ts +21 -0
  305. package/js/src/src/afratether.js +356 -0
  306. package/js/src/src/alpaca.d.ts +332 -0
  307. package/js/src/src/alpaca.js +1908 -0
  308. package/js/src/src/apex.d.ts +333 -0
  309. package/js/src/src/apex.js +1942 -0
  310. package/js/src/src/arzinja.d.ts +21 -0
  311. package/js/src/src/arzinja.js +298 -0
  312. package/js/src/src/arzplus.d.ts +26 -0
  313. package/js/src/src/arzplus.js +581 -0
  314. package/js/src/src/ascendex.d.ts +424 -0
  315. package/js/src/src/ascendex.js +3699 -0
  316. package/js/src/src/asretether.d.ts +21 -0
  317. package/js/src/src/asretether.js +324 -0
  318. package/js/src/src/base/Exchange.d.ts +926 -0
  319. package/js/src/src/base/Exchange.js +7399 -0
  320. package/js/src/src/base/Precise.d.ts +42 -0
  321. package/js/src/src/base/Precise.js +275 -0
  322. package/js/src/src/base/errors.d.ts +168 -0
  323. package/js/src/src/base/errors.js +255 -0
  324. package/js/src/src/base/functions/crypto.d.ts +16 -0
  325. package/js/src/src/base/functions/crypto.js +131 -0
  326. package/js/src/src/base/functions/encode.d.ts +4 -0
  327. package/js/src/src/base/functions/encode.js +32 -0
  328. package/js/src/src/base/functions/generic.d.ts +29 -0
  329. package/js/src/src/base/functions/generic.js +203 -0
  330. package/js/src/src/base/functions/misc.d.ts +9 -0
  331. package/js/src/src/base/functions/misc.js +101 -0
  332. package/js/src/src/base/functions/number.d.ts +27 -0
  333. package/js/src/src/base/functions/number.js +313 -0
  334. package/js/src/src/base/functions/platform.d.ts +7 -0
  335. package/js/src/src/base/functions/platform.js +27 -0
  336. package/js/src/src/base/functions/rsa.d.ts +5 -0
  337. package/js/src/src/base/functions/rsa.js +49 -0
  338. package/js/src/src/base/functions/string.d.ts +7 -0
  339. package/js/src/src/base/functions/string.js +44 -0
  340. package/js/src/src/base/functions/throttle.d.ts +6 -0
  341. package/js/src/src/base/functions/throttle.js +67 -0
  342. package/js/src/src/base/functions/time.d.ts +21 -0
  343. package/js/src/src/base/functions/time.js +171 -0
  344. package/js/src/src/base/functions/totp.d.ts +3 -0
  345. package/js/src/src/base/functions/totp.js +25 -0
  346. package/js/src/src/base/functions/type.d.ts +37 -0
  347. package/js/src/src/base/functions/type.js +179 -0
  348. package/js/src/src/base/functions.d.ts +10 -0
  349. package/js/src/src/base/functions.js +18 -0
  350. package/js/src/src/base/types.d.ts +586 -0
  351. package/js/src/src/base/types.js +7 -0
  352. package/js/src/src/base/ws/Cache.d.ts +27 -0
  353. package/js/src/src/base/ws/Cache.js +260 -0
  354. package/js/src/src/base/ws/Client.d.ts +53 -0
  355. package/js/src/src/base/ws/Client.js +307 -0
  356. package/js/src/src/base/ws/Future.d.ts +8 -0
  357. package/js/src/src/base/ws/Future.js +35 -0
  358. package/js/src/src/base/ws/OrderBook.d.ts +25 -0
  359. package/js/src/src/base/ws/OrderBook.js +130 -0
  360. package/js/src/src/base/ws/OrderBookSide.d.ts +40 -0
  361. package/js/src/src/base/ws/OrderBookSide.js +286 -0
  362. package/js/src/src/base/ws/WsClient.d.ts +11 -0
  363. package/js/src/src/base/ws/WsClient.js +69 -0
  364. package/js/src/src/bequant.d.ts +4 -0
  365. package/js/src/src/bequant.js +35 -0
  366. package/js/src/src/bidarz.d.ts +16 -0
  367. package/js/src/src/bidarz.js +327 -0
  368. package/js/src/src/bigone.d.ts +296 -0
  369. package/js/src/src/bigone.js +2340 -0
  370. package/js/src/src/binance.d.ts +1667 -0
  371. package/js/src/src/binance.js +14400 -0
  372. package/js/src/src/binancecoinm.d.ts +6 -0
  373. package/js/src/src/binancecoinm.js +51 -0
  374. package/js/src/src/binanceus.d.ts +4 -0
  375. package/js/src/src/binanceus.js +225 -0
  376. package/js/src/src/binanceusdm.d.ts +6 -0
  377. package/js/src/src/binanceusdm.js +63 -0
  378. package/js/src/src/bingx.d.ts +778 -0
  379. package/js/src/src/bingx.js +6705 -0
  380. package/js/src/src/bit24.d.ts +24 -0
  381. package/js/src/src/bit24.js +520 -0
  382. package/js/src/src/bit2c.d.ts +146 -0
  383. package/js/src/src/bit2c.js +1029 -0
  384. package/js/src/src/bitbank.d.ts +181 -0
  385. package/js/src/src/bitbank.js +1146 -0
  386. package/js/src/src/bitbarg.d.ts +21 -0
  387. package/js/src/src/bitbarg.js +312 -0
  388. package/js/src/src/bitbns.d.ts +184 -0
  389. package/js/src/src/bitbns.js +1288 -0
  390. package/js/src/src/bitfinex.d.ts +516 -0
  391. package/js/src/src/bitfinex.js +3951 -0
  392. package/js/src/src/bitflyer.d.ts +229 -0
  393. package/js/src/src/bitflyer.js +1209 -0
  394. package/js/src/src/bitget.d.ts +1109 -0
  395. package/js/src/src/bitget.js +11033 -0
  396. package/js/src/src/bithumb.d.ts +165 -0
  397. package/js/src/src/bithumb.js +1257 -0
  398. package/js/src/src/bitimen.d.ts +23 -0
  399. package/js/src/src/bitimen.js +424 -0
  400. package/js/src/src/bitir.d.ts +23 -0
  401. package/js/src/src/bitir.js +521 -0
  402. package/js/src/src/bitmart.d.ts +736 -0
  403. package/js/src/src/bitmart.js +5639 -0
  404. package/js/src/src/bitmex.d.ts +395 -0
  405. package/js/src/src/bitmex.js +3088 -0
  406. package/js/src/src/bitopro.d.ts +295 -0
  407. package/js/src/src/bitopro.js +1892 -0
  408. package/js/src/src/bitpin.d.ts +23 -0
  409. package/js/src/src/bitpin.js +487 -0
  410. package/js/src/src/bitrue.d.ts +384 -0
  411. package/js/src/src/bitrue.js +3382 -0
  412. package/js/src/src/bitso.d.ts +270 -0
  413. package/js/src/src/bitso.js +1881 -0
  414. package/js/src/src/bitstamp.d.ts +355 -0
  415. package/js/src/src/bitstamp.js +2445 -0
  416. package/js/src/src/bitteam.d.ts +229 -0
  417. package/js/src/src/bitteam.js +2420 -0
  418. package/js/src/src/bittrade.d.ts +298 -0
  419. package/js/src/src/bittrade.js +2050 -0
  420. package/js/src/src/bitunix.d.ts +21 -0
  421. package/js/src/src/bitunix.js +326 -0
  422. package/js/src/src/bitvavo.d.ts +311 -0
  423. package/js/src/src/bitvavo.js +2204 -0
  424. package/js/src/src/blockchaincom.d.ts +256 -0
  425. package/js/src/src/blockchaincom.js +1259 -0
  426. package/js/src/src/blofin.d.ts +439 -0
  427. package/js/src/src/blofin.js +2576 -0
  428. package/js/src/src/btcalpha.d.ts +209 -0
  429. package/js/src/src/btcalpha.js +1056 -0
  430. package/js/src/src/btcbox.d.ts +144 -0
  431. package/js/src/src/btcbox.js +834 -0
  432. package/js/src/src/btcmarkets.d.ts +253 -0
  433. package/js/src/src/btcmarkets.js +1418 -0
  434. package/js/src/src/btcturk.d.ts +161 -0
  435. package/js/src/src/btcturk.js +1058 -0
  436. package/js/src/src/bybit.d.ts +1097 -0
  437. package/js/src/src/bybit.js +9382 -0
  438. package/js/src/src/bydfi.d.ts +23 -0
  439. package/js/src/src/bydfi.js +434 -0
  440. package/js/src/src/cafearz.d.ts +21 -0
  441. package/js/src/src/cafearz.js +346 -0
  442. package/js/src/src/cex.d.ts +286 -0
  443. package/js/src/src/cex.js +1799 -0
  444. package/js/src/src/coinbase.d.ts +623 -0
  445. package/js/src/src/coinbase.js +5220 -0
  446. package/js/src/src/coinbaseadvanced.d.ts +4 -0
  447. package/js/src/src/coinbaseadvanced.js +18 -0
  448. package/js/src/src/coinbaseexchange.d.ts +334 -0
  449. package/js/src/src/coinbaseexchange.js +2127 -0
  450. package/js/src/src/coinbaseinternational.d.ts +443 -0
  451. package/js/src/src/coinbaseinternational.js +2336 -0
  452. package/js/src/src/coincatch.d.ts +786 -0
  453. package/js/src/src/coincatch.js +5492 -0
  454. package/js/src/src/coincheck.d.ts +147 -0
  455. package/js/src/src/coincheck.js +962 -0
  456. package/js/src/src/coinex.d.ts +719 -0
  457. package/js/src/src/coinex.js +6166 -0
  458. package/js/src/src/coinmate.d.ts +202 -0
  459. package/js/src/src/coinmate.js +1215 -0
  460. package/js/src/src/coinmetro.d.ts +244 -0
  461. package/js/src/src/coinmetro.js +2024 -0
  462. package/js/src/src/coinone.d.ts +158 -0
  463. package/js/src/src/coinone.js +1278 -0
  464. package/js/src/src/coinsph.d.ts +310 -0
  465. package/js/src/src/coinsph.js +2203 -0
  466. package/js/src/src/coinspot.d.ts +108 -0
  467. package/js/src/src/coinspot.js +653 -0
  468. package/js/src/src/cryptocom.d.ts +463 -0
  469. package/js/src/src/cryptocom.js +3549 -0
  470. package/js/src/src/cryptomus.d.ts +158 -0
  471. package/js/src/src/cryptomus.js +1169 -0
  472. package/js/src/src/defx.d.ts +348 -0
  473. package/js/src/src/defx.js +2139 -0
  474. package/js/src/src/delta.d.ts +407 -0
  475. package/js/src/src/delta.js +3654 -0
  476. package/js/src/src/deribit.d.ts +516 -0
  477. package/js/src/src/deribit.js +3790 -0
  478. package/js/src/src/derive.d.ts +324 -0
  479. package/js/src/src/derive.js +2655 -0
  480. package/js/src/src/digifinex.d.ts +544 -0
  481. package/js/src/src/digifinex.js +4453 -0
  482. package/js/src/src/ellipx.d.ts +237 -0
  483. package/js/src/src/ellipx.js +2071 -0
  484. package/js/src/src/eterex.d.ts +21 -0
  485. package/js/src/src/eterex.js +299 -0
  486. package/js/src/src/excoino.d.ts +23 -0
  487. package/js/src/src/excoino.js +426 -0
  488. package/js/src/src/exir.d.ts +23 -0
  489. package/js/src/src/exir.js +403 -0
  490. package/js/src/src/exmo.d.ts +426 -0
  491. package/js/src/src/exmo.js +2825 -0
  492. package/js/src/src/exnovin.d.ts +22 -0
  493. package/js/src/src/exnovin.js +378 -0
  494. package/js/src/src/farhadexchange.d.ts +21 -0
  495. package/js/src/src/farhadexchange.js +280 -0
  496. package/js/src/src/fmfwio.d.ts +4 -0
  497. package/js/src/src/fmfwio.js +35 -0
  498. package/js/src/src/foxbit.d.ts +352 -0
  499. package/js/src/src/foxbit.js +2016 -0
  500. package/js/src/src/gate.d.ts +1071 -0
  501. package/js/src/src/gate.js +8282 -0
  502. package/js/src/src/gateio.d.ts +4 -0
  503. package/js/src/src/gateio.js +17 -0
  504. package/js/src/src/gemini.d.ts +257 -0
  505. package/js/src/src/gemini.js +2006 -0
  506. package/js/src/src/hamtapay.d.ts +21 -0
  507. package/js/src/src/hamtapay.js +303 -0
  508. package/js/src/src/hashkey.d.ts +628 -0
  509. package/js/src/src/hashkey.js +4363 -0
  510. package/js/src/src/hibachi.d.ts +346 -0
  511. package/js/src/src/hibachi.js +2137 -0
  512. package/js/src/src/hitbtc.d.ts +558 -0
  513. package/js/src/src/hitbtc.js +3847 -0
  514. package/js/src/src/hitobit.d.ts +23 -0
  515. package/js/src/src/hitobit.js +412 -0
  516. package/js/src/src/hollaex.d.ts +305 -0
  517. package/js/src/src/hollaex.js +2046 -0
  518. package/js/src/src/htx.d.ts +961 -0
  519. package/js/src/src/htx.js +9668 -0
  520. package/js/src/src/huobi.d.ts +4 -0
  521. package/js/src/src/huobi.js +17 -0
  522. package/js/src/src/hyperliquid.d.ts +651 -0
  523. package/js/src/src/hyperliquid.js +3937 -0
  524. package/js/src/src/independentreserve.d.ts +169 -0
  525. package/js/src/src/independentreserve.js +1115 -0
  526. package/js/src/src/indodax.d.ts +217 -0
  527. package/js/src/src/indodax.js +1454 -0
  528. package/js/src/src/iranexchange.d.ts +21 -0
  529. package/js/src/src/iranexchange.js +399 -0
  530. package/js/src/src/jibitex.d.ts +23 -0
  531. package/js/src/src/jibitex.js +416 -0
  532. package/js/src/src/kcex.d.ts +21 -0
  533. package/js/src/src/kcex.js +335 -0
  534. package/js/src/src/kifpoolme.d.ts +23 -0
  535. package/js/src/src/kifpoolme.js +410 -0
  536. package/js/src/src/kraken.d.ts +484 -0
  537. package/js/src/src/kraken.js +3518 -0
  538. package/js/src/src/krakenfutures.d.ts +362 -0
  539. package/js/src/src/krakenfutures.js +2885 -0
  540. package/js/src/src/kucoin.d.ts +759 -0
  541. package/js/src/src/kucoin.js +5153 -0
  542. package/js/src/src/kucoinfutures.d.ts +521 -0
  543. package/js/src/src/kucoinfutures.js +3381 -0
  544. package/js/src/src/latoken.d.ts +274 -0
  545. package/js/src/src/latoken.js +1824 -0
  546. package/js/src/src/lbank.d.ts +350 -0
  547. package/js/src/src/lbank.js +3146 -0
  548. package/js/src/src/luno.d.ts +252 -0
  549. package/js/src/src/luno.js +1479 -0
  550. package/js/src/src/mazdax.d.ts +23 -0
  551. package/js/src/src/mazdax.js +534 -0
  552. package/js/src/src/mercado.d.ts +160 -0
  553. package/js/src/src/mercado.js +1011 -0
  554. package/js/src/src/mexc.d.ts +768 -0
  555. package/js/src/src/mexc.js +6102 -0
  556. package/js/src/src/modetrade.d.ts +496 -0
  557. package/js/src/src/modetrade.js +2936 -0
  558. package/js/src/src/myokx.d.ts +4 -0
  559. package/js/src/src/myokx.js +54 -0
  560. package/js/src/src/ndax.d.ts +285 -0
  561. package/js/src/src/ndax.js +2598 -0
  562. package/js/src/src/nobitex.d.ts +23 -0
  563. package/js/src/src/nobitex.js +454 -0
  564. package/js/src/src/novadax.d.ts +279 -0
  565. package/js/src/src/novadax.js +1676 -0
  566. package/js/src/src/oceanex.d.ts +231 -0
  567. package/js/src/src/oceanex.js +1123 -0
  568. package/js/src/src/okcoin.d.ts +346 -0
  569. package/js/src/src/okcoin.js +3211 -0
  570. package/js/src/src/okexchange.d.ts +23 -0
  571. package/js/src/src/okexchange.js +373 -0
  572. package/js/src/src/okx.d.ts +1125 -0
  573. package/js/src/src/okx.js +9009 -0
  574. package/js/src/src/okxus.d.ts +4 -0
  575. package/js/src/src/okxus.js +54 -0
  576. package/js/src/src/ompfinex.d.ts +23 -0
  577. package/js/src/src/ompfinex.js +510 -0
  578. package/js/src/src/onetrading.d.ts +228 -0
  579. package/js/src/src/onetrading.js +1769 -0
  580. package/js/src/src/oxfun.d.ts +442 -0
  581. package/js/src/src/oxfun.js +2920 -0
  582. package/js/src/src/p2b.d.ts +189 -0
  583. package/js/src/src/p2b.js +1344 -0
  584. package/js/src/src/paradex.d.ts +389 -0
  585. package/js/src/src/paradex.js +2607 -0
  586. package/js/src/src/paymium.d.ts +133 -0
  587. package/js/src/src/paymium.js +644 -0
  588. package/js/src/src/phemex.d.ts +497 -0
  589. package/js/src/src/phemex.js +5333 -0
  590. package/js/src/src/pingi.d.ts +22 -0
  591. package/js/src/src/pingi.js +446 -0
  592. package/js/src/src/poloniex.d.ts +441 -0
  593. package/js/src/src/poloniex.js +3681 -0
  594. package/js/src/src/pooleno.d.ts +21 -0
  595. package/js/src/src/pooleno.js +347 -0
  596. package/js/src/src/pro/alpaca.d.ts +95 -0
  597. package/js/src/src/pro/alpaca.js +724 -0
  598. package/js/src/src/pro/apex.d.ts +160 -0
  599. package/js/src/src/pro/apex.js +1044 -0
  600. package/js/src/src/pro/ascendex.d.ts +99 -0
  601. package/js/src/src/pro/ascendex.js +1012 -0
  602. package/js/src/src/pro/bequant.d.ts +4 -0
  603. package/js/src/src/pro/bequant.js +42 -0
  604. package/js/src/src/pro/binance.d.ts +796 -0
  605. package/js/src/src/pro/binance.js +4373 -0
  606. package/js/src/src/pro/binancecoinm.d.ts +4 -0
  607. package/js/src/src/pro/binancecoinm.js +32 -0
  608. package/js/src/src/pro/binanceus.d.ts +4 -0
  609. package/js/src/src/pro/binanceus.js +52 -0
  610. package/js/src/src/pro/binanceusdm.d.ts +4 -0
  611. package/js/src/src/pro/binanceusdm.js +37 -0
  612. package/js/src/src/pro/bingx.d.ts +151 -0
  613. package/js/src/src/pro/bingx.js +1568 -0
  614. package/js/src/src/pro/bitfinex.d.ts +99 -0
  615. package/js/src/src/pro/bitfinex.js +1165 -0
  616. package/js/src/src/pro/bitget.d.ts +257 -0
  617. package/js/src/src/pro/bitget.js +2327 -0
  618. package/js/src/src/pro/bithumb.d.ts +59 -0
  619. package/js/src/src/pro/bithumb.js +395 -0
  620. package/js/src/src/pro/bitmart.d.ts +168 -0
  621. package/js/src/src/pro/bitmart.js +1686 -0
  622. package/js/src/src/pro/bitmex.d.ts +170 -0
  623. package/js/src/src/pro/bitmex.js +1760 -0
  624. package/js/src/src/pro/bitopro.d.ts +69 -0
  625. package/js/src/src/pro/bitopro.js +477 -0
  626. package/js/src/src/pro/bitrue.d.ts +40 -0
  627. package/js/src/src/pro/bitrue.js +461 -0
  628. package/js/src/src/pro/bitstamp.d.ts +53 -0
  629. package/js/src/src/pro/bitstamp.js +587 -0
  630. package/js/src/src/pro/bittrade.d.ts +66 -0
  631. package/js/src/src/pro/bittrade.js +606 -0
  632. package/js/src/src/pro/bitvavo.d.ts +321 -0
  633. package/js/src/src/pro/bitvavo.js +1451 -0
  634. package/js/src/src/pro/blockchaincom.d.ts +89 -0
  635. package/js/src/src/pro/blockchaincom.js +777 -0
  636. package/js/src/src/pro/blofin.d.ts +174 -0
  637. package/js/src/src/pro/blofin.js +743 -0
  638. package/js/src/src/pro/bybit.d.ts +397 -0
  639. package/js/src/src/pro/bybit.js +2519 -0
  640. package/js/src/src/pro/cex.d.ts +220 -0
  641. package/js/src/src/pro/cex.js +1535 -0
  642. package/js/src/src/pro/coinbase.d.ts +119 -0
  643. package/js/src/src/pro/coinbase.js +736 -0
  644. package/js/src/src/pro/coinbaseadvanced.d.ts +4 -0
  645. package/js/src/src/pro/coinbaseadvanced.js +18 -0
  646. package/js/src/src/pro/coinbaseexchange.d.ts +133 -0
  647. package/js/src/src/pro/coinbaseexchange.js +969 -0
  648. package/js/src/src/pro/coinbaseinternational.d.ts +143 -0
  649. package/js/src/src/pro/coinbaseinternational.js +804 -0
  650. package/js/src/src/pro/coincatch.d.ts +207 -0
  651. package/js/src/src/pro/coincatch.js +1562 -0
  652. package/js/src/src/pro/coincheck.d.ts +33 -0
  653. package/js/src/src/pro/coincheck.js +210 -0
  654. package/js/src/src/pro/coinex.d.ts +147 -0
  655. package/js/src/src/pro/coinex.js +1426 -0
  656. package/js/src/src/pro/coinone.d.ts +51 -0
  657. package/js/src/src/pro/coinone.js +413 -0
  658. package/js/src/src/pro/cryptocom.d.ts +300 -0
  659. package/js/src/src/pro/cryptocom.js +1414 -0
  660. package/js/src/src/pro/defx.d.ts +236 -0
  661. package/js/src/src/pro/defx.js +865 -0
  662. package/js/src/src/pro/deribit.d.ts +163 -0
  663. package/js/src/src/pro/deribit.js +1066 -0
  664. package/js/src/src/pro/derive.d.ts +100 -0
  665. package/js/src/src/pro/derive.js +753 -0
  666. package/js/src/src/pro/exmo.d.ts +97 -0
  667. package/js/src/src/pro/exmo.js +903 -0
  668. package/js/src/src/pro/gate.d.ts +360 -0
  669. package/js/src/src/pro/gate.js +2119 -0
  670. package/js/src/src/pro/gateio.d.ts +4 -0
  671. package/js/src/src/pro/gateio.js +17 -0
  672. package/js/src/src/pro/gemini.d.ts +106 -0
  673. package/js/src/src/pro/gemini.js +932 -0
  674. package/js/src/src/pro/hashkey.d.ts +121 -0
  675. package/js/src/src/pro/hashkey.js +843 -0
  676. package/js/src/src/pro/hitbtc.d.ts +235 -0
  677. package/js/src/src/pro/hitbtc.js +1400 -0
  678. package/js/src/src/pro/hollaex.d.ts +77 -0
  679. package/js/src/src/pro/hollaex.js +604 -0
  680. package/js/src/src/pro/htx.d.ts +141 -0
  681. package/js/src/src/pro/htx.js +2415 -0
  682. package/js/src/src/pro/huobi.d.ts +4 -0
  683. package/js/src/src/pro/huobi.js +17 -0
  684. package/js/src/src/pro/hyperliquid.d.ts +218 -0
  685. package/js/src/src/pro/hyperliquid.js +1126 -0
  686. package/js/src/src/pro/independentreserve.d.ts +36 -0
  687. package/js/src/src/pro/independentreserve.js +287 -0
  688. package/js/src/src/pro/kraken.d.ts +233 -0
  689. package/js/src/src/pro/kraken.js +1785 -0
  690. package/js/src/src/pro/krakenfutures.d.ts +178 -0
  691. package/js/src/src/pro/krakenfutures.js +1592 -0
  692. package/js/src/src/pro/kucoin.d.ts +221 -0
  693. package/js/src/src/pro/kucoin.js +1430 -0
  694. package/js/src/src/pro/kucoinfutures.d.ts +205 -0
  695. package/js/src/src/pro/kucoinfutures.js +1295 -0
  696. package/js/src/src/pro/lbank.d.ts +134 -0
  697. package/js/src/src/pro/lbank.js +950 -0
  698. package/js/src/src/pro/luno.d.ts +44 -0
  699. package/js/src/src/pro/luno.js +322 -0
  700. package/js/src/src/pro/mexc.d.ts +210 -0
  701. package/js/src/src/pro/mexc.js +2009 -0
  702. package/js/src/src/pro/modetrade.d.ts +155 -0
  703. package/js/src/src/pro/modetrade.js +1335 -0
  704. package/js/src/src/pro/myokx.d.ts +4 -0
  705. package/js/src/src/pro/myokx.js +39 -0
  706. package/js/src/src/pro/ndax.d.ts +60 -0
  707. package/js/src/src/pro/ndax.js +545 -0
  708. package/js/src/src/pro/okcoin.d.ts +91 -0
  709. package/js/src/src/pro/okcoin.js +763 -0
  710. package/js/src/src/pro/okx.d.ts +408 -0
  711. package/js/src/src/pro/okx.js +2479 -0
  712. package/js/src/src/pro/okxus.d.ts +4 -0
  713. package/js/src/src/pro/okxus.js +39 -0
  714. package/js/src/src/pro/onetrading.d.ts +107 -0
  715. package/js/src/src/pro/onetrading.js +1343 -0
  716. package/js/src/src/pro/oxfun.d.ts +234 -0
  717. package/js/src/src/pro/oxfun.js +1112 -0
  718. package/js/src/src/pro/p2b.d.ts +104 -0
  719. package/js/src/src/pro/p2b.js +506 -0
  720. package/js/src/src/pro/paradex.d.ts +54 -0
  721. package/js/src/src/pro/paradex.js +370 -0
  722. package/js/src/src/pro/phemex.d.ts +129 -0
  723. package/js/src/src/pro/phemex.js +1569 -0
  724. package/js/src/src/pro/poloniex.d.ts +214 -0
  725. package/js/src/src/pro/poloniex.js +1318 -0
  726. package/js/src/src/pro/probit.d.ts +91 -0
  727. package/js/src/src/pro/probit.js +593 -0
  728. package/js/src/src/pro/tradeogre.d.ts +49 -0
  729. package/js/src/src/pro/tradeogre.js +284 -0
  730. package/js/src/src/pro/upbit.d.ts +124 -0
  731. package/js/src/src/pro/upbit.js +689 -0
  732. package/js/src/src/pro/vertex.d.ts +104 -0
  733. package/js/src/src/pro/vertex.js +999 -0
  734. package/js/src/src/pro/whitebit.d.ts +123 -0
  735. package/js/src/src/pro/whitebit.js +971 -0
  736. package/js/src/src/pro/woo.d.ts +161 -0
  737. package/js/src/src/pro/woo.js +1351 -0
  738. package/js/src/src/pro/woofipro.d.ts +155 -0
  739. package/js/src/src/pro/woofipro.js +1335 -0
  740. package/js/src/src/pro/xt.d.ts +165 -0
  741. package/js/src/src/pro/xt.js +1230 -0
  742. package/js/src/src/probit.d.ts +283 -0
  743. package/js/src/src/probit.js +1935 -0
  744. package/js/src/src/protobuf/mexc/compiled.cjs +7186 -0
  745. package/js/src/src/protobuf/mexc/compiled.d.cts +8 -0
  746. package/js/src/src/raastin.d.ts +24 -0
  747. package/js/src/src/raastin.js +494 -0
  748. package/js/src/src/ramzinex.d.ts +23 -0
  749. package/js/src/src/ramzinex.js +510 -0
  750. package/js/src/src/sarmayex.d.ts +21 -0
  751. package/js/src/src/sarmayex.js +376 -0
  752. package/js/src/src/sarrafex.d.ts +23 -0
  753. package/js/src/src/sarrafex.js +501 -0
  754. package/js/src/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
  755. package/js/src/src/static_dependencies/ethers/abi-coder.js +148 -0
  756. package/js/src/src/static_dependencies/ethers/address/address.d.ts +55 -0
  757. package/js/src/src/static_dependencies/ethers/address/address.js +162 -0
  758. package/js/src/src/static_dependencies/ethers/address/checks.d.ts +80 -0
  759. package/js/src/src/static_dependencies/ethers/address/checks.js +119 -0
  760. package/js/src/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
  761. package/js/src/src/static_dependencies/ethers/address/contract-address.js +73 -0
  762. package/js/src/src/static_dependencies/ethers/address/index.d.ts +48 -0
  763. package/js/src/src/static_dependencies/ethers/address/index.js +24 -0
  764. package/js/src/src/static_dependencies/ethers/bytes32.d.ts +14 -0
  765. package/js/src/src/static_dependencies/ethers/bytes32.js +45 -0
  766. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
  767. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
  768. package/js/src/src/static_dependencies/ethers/coders/address.d.ts +12 -0
  769. package/js/src/src/static_dependencies/ethers/coders/address.js +34 -0
  770. package/js/src/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
  771. package/js/src/src/static_dependencies/ethers/coders/anonymous.js +27 -0
  772. package/js/src/src/static_dependencies/ethers/coders/array.d.ts +24 -0
  773. package/js/src/src/static_dependencies/ethers/coders/array.js +162 -0
  774. package/js/src/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
  775. package/js/src/src/static_dependencies/ethers/coders/boolean.js +26 -0
  776. package/js/src/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
  777. package/js/src/src/static_dependencies/ethers/coders/bytes.js +39 -0
  778. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
  779. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
  780. package/js/src/src/static_dependencies/ethers/coders/null.d.ts +11 -0
  781. package/js/src/src/static_dependencies/ethers/coders/null.js +29 -0
  782. package/js/src/src/static_dependencies/ethers/coders/number.d.ts +15 -0
  783. package/js/src/src/static_dependencies/ethers/coders/number.js +48 -0
  784. package/js/src/src/static_dependencies/ethers/coders/string.d.ts +12 -0
  785. package/js/src/src/static_dependencies/ethers/coders/string.js +26 -0
  786. package/js/src/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
  787. package/js/src/src/static_dependencies/ethers/coders/tuple.js +67 -0
  788. package/js/src/src/static_dependencies/ethers/fragments.d.ts +458 -0
  789. package/js/src/src/static_dependencies/ethers/fragments.js +1252 -0
  790. package/js/src/src/static_dependencies/ethers/hash/index.d.ts +10 -0
  791. package/js/src/src/static_dependencies/ethers/hash/index.js +15 -0
  792. package/js/src/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
  793. package/js/src/src/static_dependencies/ethers/hash/solidity.js +107 -0
  794. package/js/src/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
  795. package/js/src/src/static_dependencies/ethers/hash/typed-data.js +490 -0
  796. package/js/src/src/static_dependencies/ethers/index.d.ts +19 -0
  797. package/js/src/src/static_dependencies/ethers/index.js +22 -0
  798. package/js/src/src/static_dependencies/ethers/interface.d.ts +380 -0
  799. package/js/src/src/static_dependencies/ethers/interface.js +990 -0
  800. package/js/src/src/static_dependencies/ethers/typed.d.ts +569 -0
  801. package/js/src/src/static_dependencies/ethers/typed.js +608 -0
  802. package/js/src/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
  803. package/js/src/src/static_dependencies/ethers/utils/base58.js +68 -0
  804. package/js/src/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
  805. package/js/src/src/static_dependencies/ethers/utils/base64.js +58 -0
  806. package/js/src/src/static_dependencies/ethers/utils/data.d.ts +92 -0
  807. package/js/src/src/static_dependencies/ethers/utils/data.js +175 -0
  808. package/js/src/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
  809. package/js/src/src/static_dependencies/ethers/utils/errors.js +227 -0
  810. package/js/src/src/static_dependencies/ethers/utils/events.d.ts +76 -0
  811. package/js/src/src/static_dependencies/ethers/utils/events.js +52 -0
  812. package/js/src/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
  813. package/js/src/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
  814. package/js/src/src/static_dependencies/ethers/utils/index.d.ts +30 -0
  815. package/js/src/src/static_dependencies/ethers/utils/index.js +38 -0
  816. package/js/src/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
  817. package/js/src/src/static_dependencies/ethers/utils/maths.js +220 -0
  818. package/js/src/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
  819. package/js/src/src/static_dependencies/ethers/utils/properties.js +59 -0
  820. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
  821. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
  822. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
  823. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
  824. package/js/src/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
  825. package/js/src/src/static_dependencies/ethers/utils/rlp.js +14 -0
  826. package/js/src/src/static_dependencies/ethers/utils/units.d.ts +23 -0
  827. package/js/src/src/static_dependencies/ethers/utils/units.js +88 -0
  828. package/js/src/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
  829. package/js/src/src/static_dependencies/ethers/utils/utf8.js +225 -0
  830. package/js/src/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
  831. package/js/src/src/static_dependencies/ethers/utils/uuid.js +35 -0
  832. package/js/src/src/static_dependencies/fflake/browser.d.ts +222 -0
  833. package/js/src/src/static_dependencies/fflake/browser.js +2578 -0
  834. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.d.ts +116 -0
  835. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.js +194 -0
  836. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +142 -0
  837. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +307 -0
  838. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -0
  839. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +565 -0
  840. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.d.ts +5 -0
  841. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  842. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.d.ts +3 -0
  843. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  844. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.d.ts +9 -0
  845. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  846. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.d.ts +3 -0
  847. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +25 -0
  848. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -0
  849. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1757 -0
  850. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.d.ts +10 -0
  851. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +50 -0
  852. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.d.ts +3 -0
  853. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +80 -0
  854. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.d.ts +23 -0
  855. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +377 -0
  856. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.d.ts +7 -0
  857. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.js +64 -0
  858. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -0
  859. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1627 -0
  860. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.d.ts +60 -0
  861. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.js +22 -0
  862. package/js/src/src/static_dependencies/noble-curves/abstract/curve.d.ts +67 -0
  863. package/js/src/src/static_dependencies/noble-curves/abstract/curve.js +157 -0
  864. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.d.ts +79 -0
  865. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.js +432 -0
  866. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.d.ts +56 -0
  867. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +171 -0
  868. package/js/src/src/static_dependencies/noble-curves/abstract/modular.d.ts +68 -0
  869. package/js/src/src/static_dependencies/noble-curves/abstract/modular.js +351 -0
  870. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.d.ts +25 -0
  871. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.js +162 -0
  872. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.d.ts +29 -0
  873. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.js +115 -0
  874. package/js/src/src/static_dependencies/noble-curves/abstract/utils.d.ts +53 -0
  875. package/js/src/src/static_dependencies/noble-curves/abstract/utils.js +227 -0
  876. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -0
  877. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.js +1016 -0
  878. package/js/src/src/static_dependencies/noble-curves/ed25519.d.ts +53 -0
  879. package/js/src/src/static_dependencies/noble-curves/ed25519.js +402 -0
  880. package/js/src/src/static_dependencies/noble-curves/p256.d.ts +103 -0
  881. package/js/src/src/static_dependencies/noble-curves/p256.js +47 -0
  882. package/js/src/src/static_dependencies/noble-curves/secp256k1.d.ts +91 -0
  883. package/js/src/src/static_dependencies/noble-curves/secp256k1.js +257 -0
  884. package/js/src/src/static_dependencies/noble-hashes/_assert.d.ts +21 -0
  885. package/js/src/src/static_dependencies/noble-hashes/_assert.js +48 -0
  886. package/js/src/src/static_dependencies/noble-hashes/_sha2.d.ts +23 -0
  887. package/js/src/src/static_dependencies/noble-hashes/_sha2.js +119 -0
  888. package/js/src/src/static_dependencies/noble-hashes/_u64.d.ts +35 -0
  889. package/js/src/src/static_dependencies/noble-hashes/_u64.js +66 -0
  890. package/js/src/src/static_dependencies/noble-hashes/crypto.d.ts +1 -0
  891. package/js/src/src/static_dependencies/noble-hashes/crypto.js +7 -0
  892. package/js/src/src/static_dependencies/noble-hashes/hmac.d.ts +26 -0
  893. package/js/src/src/static_dependencies/noble-hashes/hmac.js +82 -0
  894. package/js/src/src/static_dependencies/noble-hashes/md5.d.ts +18 -0
  895. package/js/src/src/static_dependencies/noble-hashes/md5.js +242 -0
  896. package/js/src/src/static_dependencies/noble-hashes/sha1.d.ts +21 -0
  897. package/js/src/src/static_dependencies/noble-hashes/sha1.js +90 -0
  898. package/js/src/src/static_dependencies/noble-hashes/sha256.d.ts +34 -0
  899. package/js/src/src/static_dependencies/noble-hashes/sha256.js +129 -0
  900. package/js/src/src/static_dependencies/noble-hashes/sha3.d.ts +97 -0
  901. package/js/src/src/static_dependencies/noble-hashes/sha3.js +211 -0
  902. package/js/src/src/static_dependencies/noble-hashes/sha512.d.ts +66 -0
  903. package/js/src/src/static_dependencies/noble-hashes/sha512.js +236 -0
  904. package/js/src/src/static_dependencies/noble-hashes/utils.d.ts +77 -0
  905. package/js/src/src/static_dependencies/noble-hashes/utils.js +147 -0
  906. package/js/src/src/static_dependencies/proxies/agent-base/helpers.d.ts +14 -0
  907. package/js/src/src/static_dependencies/proxies/agent-base/helpers.js +42 -0
  908. package/js/src/src/static_dependencies/proxies/agent-base/index.d.ts +33 -0
  909. package/js/src/src/static_dependencies/proxies/agent-base/index.js +82 -0
  910. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.d.ts +40 -0
  911. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.js +119 -0
  912. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.d.ts +45 -0
  913. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.js +150 -0
  914. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.d.ts +15 -0
  915. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  916. package/js/src/src/static_dependencies/qs/formats.cjs +22 -0
  917. package/js/src/src/static_dependencies/qs/formats.d.cts +14 -0
  918. package/js/src/src/static_dependencies/qs/index.cjs +15 -0
  919. package/js/src/src/static_dependencies/qs/index.d.cts +10 -0
  920. package/js/src/src/static_dependencies/qs/parse.cjs +208 -0
  921. package/js/src/src/static_dependencies/qs/parse.d.cts +8 -0
  922. package/js/src/src/static_dependencies/qs/stringify.cjs +192 -0
  923. package/js/src/src/static_dependencies/qs/stringify.d.cts +8 -0
  924. package/js/src/src/static_dependencies/qs/utils.cjs +202 -0
  925. package/js/src/src/static_dependencies/qs/utils.d.cts +15 -0
  926. package/js/src/src/static_dependencies/scure-base/index.d.ts +92 -0
  927. package/js/src/src/static_dependencies/scure-base/index.js +420 -0
  928. package/js/src/src/static_dependencies/scure-starknet/index.d.ts +79 -0
  929. package/js/src/src/static_dependencies/scure-starknet/index.js +323 -0
  930. package/js/src/src/static_dependencies/starknet/constants.d.ts +61 -0
  931. package/js/src/src/static_dependencies/starknet/constants.js +67 -0
  932. package/js/src/src/static_dependencies/starknet/index.d.ts +3 -0
  933. package/js/src/src/static_dependencies/starknet/index.js +9 -0
  934. package/js/src/src/static_dependencies/starknet/types/cairoEnum.d.ts +2 -0
  935. package/js/src/src/static_dependencies/starknet/types/cairoEnum.js +7 -0
  936. package/js/src/src/static_dependencies/starknet/types/calldata.d.ts +19 -0
  937. package/js/src/src/static_dependencies/starknet/types/calldata.js +28 -0
  938. package/js/src/src/static_dependencies/starknet/types/index.d.ts +13 -0
  939. package/js/src/src/static_dependencies/starknet/types/index.js +16 -0
  940. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.d.ts +71 -0
  941. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.js +13 -0
  942. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.d.ts +24 -0
  943. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.js +16 -0
  944. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.d.ts +33 -0
  945. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.js +7 -0
  946. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.d.ts +52 -0
  947. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.js +7 -0
  948. package/js/src/src/static_dependencies/starknet/types/lib/index.d.ts +248 -0
  949. package/js/src/src/static_dependencies/starknet/types/lib/index.js +52 -0
  950. package/js/src/src/static_dependencies/starknet/types/typedData.d.ts +44 -0
  951. package/js/src/src/static_dependencies/starknet/types/typedData.js +19 -0
  952. package/js/src/src/static_dependencies/starknet/utils/assert.d.ts +7 -0
  953. package/js/src/src/static_dependencies/starknet/utils/assert.js +17 -0
  954. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.d.ts +6 -0
  955. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +43 -0
  956. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.d.ts +72 -0
  957. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +117 -0
  958. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.d.ts +76 -0
  959. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +136 -0
  960. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.d.ts +32 -0
  961. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.js +59 -0
  962. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.d.ts +183 -0
  963. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.js +229 -0
  964. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
  965. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
  966. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.d.ts +35 -0
  967. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
  968. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.d.ts +34 -0
  969. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
  970. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.d.ts +3 -0
  971. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.js +9 -0
  972. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.d.ts +9 -0
  973. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.js +67 -0
  974. package/js/src/src/static_dependencies/starknet/utils/calldata/index.d.ts +89 -0
  975. package/js/src/src/static_dependencies/starknet/utils/calldata/index.js +280 -0
  976. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -0
  977. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.js +30 -0
  978. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.d.ts +20 -0
  979. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.js +8 -0
  980. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
  981. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +36 -0
  982. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
  983. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
  984. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.d.ts +2 -0
  985. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +155 -0
  986. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.d.ts +11 -0
  987. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.js +248 -0
  988. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.d.ts +11 -0
  989. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.js +214 -0
  990. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.d.ts +6 -0
  991. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.js +113 -0
  992. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.d.ts +6 -0
  993. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.js +208 -0
  994. package/js/src/src/static_dependencies/starknet/utils/encode.d.ts +207 -0
  995. package/js/src/src/static_dependencies/starknet/utils/encode.js +282 -0
  996. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.d.ts +57 -0
  997. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.js +223 -0
  998. package/js/src/src/static_dependencies/starknet/utils/hash/index.d.ts +6 -0
  999. package/js/src/src/static_dependencies/starknet/utils/hash/index.js +13 -0
  1000. package/js/src/src/static_dependencies/starknet/utils/merkle.d.ts +35 -0
  1001. package/js/src/src/static_dependencies/starknet/utils/merkle.js +84 -0
  1002. package/js/src/src/static_dependencies/starknet/utils/num.d.ts +182 -0
  1003. package/js/src/src/static_dependencies/starknet/utils/num.js +244 -0
  1004. package/js/src/src/static_dependencies/starknet/utils/selector.d.ts +48 -0
  1005. package/js/src/src/static_dependencies/starknet/utils/selector.js +85 -0
  1006. package/js/src/src/static_dependencies/starknet/utils/shortString.d.ts +57 -0
  1007. package/js/src/src/static_dependencies/starknet/utils/shortString.js +96 -0
  1008. package/js/src/src/static_dependencies/starknet/utils/typedData.d.ts +54 -0
  1009. package/js/src/src/static_dependencies/starknet/utils/typedData.js +321 -0
  1010. package/js/src/src/static_dependencies/watchable/src/types.d.ts +28 -0
  1011. package/js/src/src/static_dependencies/watchable/src/types.js +8 -0
  1012. package/js/src/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
  1013. package/js/src/src/static_dependencies/watchable/src/unpromise.js +297 -0
  1014. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  1015. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  1016. package/js/src/src/tabdeal.d.ts +23 -0
  1017. package/js/src/src/tabdeal.js +387 -0
  1018. package/js/src/src/tehran_exchange.d.ts +21 -0
  1019. package/js/src/src/tehran_exchange.js +333 -0
  1020. package/js/src/src/tetherland.d.ts +21 -0
  1021. package/js/src/src/tetherland.js +367 -0
  1022. package/js/src/src/timex.d.ts +247 -0
  1023. package/js/src/src/timex.js +1792 -0
  1024. package/js/src/src/tokocrypto.d.ts +261 -0
  1025. package/js/src/src/tokocrypto.js +2641 -0
  1026. package/js/src/src/toobit.d.ts +22 -0
  1027. package/js/src/src/toobit.js +445 -0
  1028. package/js/src/src/tradeogre.d.ts +149 -0
  1029. package/js/src/src/tradeogre.js +878 -0
  1030. package/js/src/src/twox.d.ts +21 -0
  1031. package/js/src/src/twox.js +371 -0
  1032. package/js/src/src/ubitex.d.ts +23 -0
  1033. package/js/src/src/ubitex.js +433 -0
  1034. package/js/src/src/upbit.d.ts +377 -0
  1035. package/js/src/src/upbit.js +2340 -0
  1036. package/js/src/src/vertex.d.ts +346 -0
  1037. package/js/src/src/vertex.js +3146 -0
  1038. package/js/src/src/wallex.d.ts +23 -0
  1039. package/js/src/src/wallex.js +467 -0
  1040. package/js/src/src/wavesexchange.d.ts +244 -0
  1041. package/js/src/src/wavesexchange.js +2747 -0
  1042. package/js/src/src/whitebit.d.ts +571 -0
  1043. package/js/src/src/whitebit.js +3437 -0
  1044. package/js/src/src/woo.d.ts +727 -0
  1045. package/js/src/src/woo.js +4183 -0
  1046. package/js/src/src/woofipro.d.ts +497 -0
  1047. package/js/src/src/woofipro.js +2941 -0
  1048. package/js/src/src/xt.d.ts +568 -0
  1049. package/js/src/src/xt.js +5184 -0
  1050. package/js/src/src/yobit.d.ts +197 -0
  1051. package/js/src/src/yobit.js +1453 -0
  1052. package/js/src/src/zaif.d.ts +136 -0
  1053. package/js/src/src/zaif.js +821 -0
  1054. package/js/src/src/zonda.d.ts +214 -0
  1055. package/js/src/src/zonda.js +1984 -0
  1056. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  1057. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  1058. package/js/test.js +9 -17
  1059. package/package.json +1 -1
@@ -0,0 +1,4363 @@
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/hashkey.js';
9
+ import { AccountNotEnabled, AccountSuspended, ArgumentsRequired, AuthenticationError, BadRequest, BadSymbol, ContractUnavailable, DDoSProtection, DuplicateOrderId, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidAddress, InvalidNonce, InvalidOrder, NotSupported, OperationFailed, OperationRejected, OrderImmediatelyFillable, OrderNotFillable, OrderNotFound, PermissionDenied, RateLimitExceeded, RequestTimeout } from './base/errors.js';
10
+ import { Precise } from './base/Precise.js';
11
+ import { TICK_SIZE } from './base/functions/number.js';
12
+ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
+ // ---------------------------------------------------------------------------
14
+ /**
15
+ * @class hashkey
16
+ * @augments Exchange
17
+ */
18
+ export default class hashkey extends Exchange {
19
+ describe() {
20
+ return this.deepExtend(super.describe(), {
21
+ 'id': 'hashkey',
22
+ 'name': 'HashKey Global',
23
+ 'countries': ['BM'],
24
+ 'rateLimit': 100,
25
+ 'version': 'v1',
26
+ 'certified': true,
27
+ 'pro': true,
28
+ 'has': {
29
+ 'CORS': undefined,
30
+ 'spot': true,
31
+ 'margin': false,
32
+ 'swap': false,
33
+ 'future': false,
34
+ 'option': false,
35
+ 'addMargin': false,
36
+ 'borrowCrossMargin': false,
37
+ 'borrowIsolatedMargin': false,
38
+ 'borrowMargin': false,
39
+ 'cancelAllOrders': true,
40
+ 'cancelAllOrdersAfter': false,
41
+ 'cancelOrder': true,
42
+ 'cancelOrders': true,
43
+ 'cancelWithdraw': false,
44
+ 'closeAllPositions': false,
45
+ 'closePosition': false,
46
+ 'createConvertTrade': false,
47
+ 'createDepositAddress': false,
48
+ 'createMarketBuyOrderWithCost': true,
49
+ 'createMarketOrder': true,
50
+ 'createMarketOrderWithCost': false,
51
+ 'createMarketSellOrderWithCost': false,
52
+ 'createOrder': true,
53
+ 'createOrderWithTakeProfitAndStopLoss': false,
54
+ 'createReduceOnlyOrder': true,
55
+ 'createStopLimitOrder': true,
56
+ 'createStopLossOrder': false,
57
+ 'createStopMarketOrder': true,
58
+ 'createStopOrder': true,
59
+ 'createTakeProfitOrder': false,
60
+ 'createTrailingAmountOrder': false,
61
+ 'createTrailingPercentOrder': false,
62
+ 'createTriggerOrder': true,
63
+ 'fetchAccounts': true,
64
+ 'fetchAllGreeks': false,
65
+ 'fetchBalance': true,
66
+ 'fetchBorrowInterest': false,
67
+ 'fetchBorrowRate': false,
68
+ 'fetchBorrowRateHistories': false,
69
+ 'fetchBorrowRateHistory': false,
70
+ 'fetchBorrowRates': false,
71
+ 'fetchBorrowRatesPerSymbol': false,
72
+ 'fetchCanceledAndClosedOrders': true,
73
+ 'fetchCanceledOrders': true,
74
+ 'fetchClosedOrder': true,
75
+ 'fetchClosedOrders': false,
76
+ 'fetchConvertCurrencies': false,
77
+ 'fetchConvertQuote': false,
78
+ 'fetchConvertTrade': false,
79
+ 'fetchConvertTradeHistory': false,
80
+ 'fetchCrossBorrowRate': false,
81
+ 'fetchCrossBorrowRates': false,
82
+ 'fetchCurrencies': true,
83
+ 'fetchDepositAddress': true,
84
+ 'fetchDepositAddresses': false,
85
+ 'fetchDepositAddressesByNetwork': false,
86
+ 'fetchDeposits': true,
87
+ 'fetchDepositsWithdrawals': false,
88
+ 'fetchFundingHistory': false,
89
+ 'fetchFundingInterval': false,
90
+ 'fetchFundingIntervals': false,
91
+ 'fetchFundingRate': true,
92
+ 'fetchFundingRateHistory': true,
93
+ 'fetchFundingRates': true,
94
+ 'fetchGreeks': false,
95
+ 'fetchIndexOHLCV': false,
96
+ 'fetchIsolatedBorrowRate': false,
97
+ 'fetchIsolatedBorrowRates': false,
98
+ 'fetchIsolatedPositions': false,
99
+ 'fetchLedger': true,
100
+ 'fetchLeverage': true,
101
+ 'fetchLeverages': false,
102
+ 'fetchLeverageTiers': true,
103
+ 'fetchLiquidations': false,
104
+ 'fetchLongShortRatio': false,
105
+ 'fetchLongShortRatioHistory': false,
106
+ 'fetchMarginAdjustmentHistory': false,
107
+ 'fetchMarginMode': false,
108
+ 'fetchMarginModes': false,
109
+ 'fetchMarketLeverageTiers': 'emulated',
110
+ 'fetchMarkets': true,
111
+ 'fetchMarkOHLCV': false,
112
+ 'fetchMarkPrice': false,
113
+ 'fetchMarkPrices': false,
114
+ 'fetchMyLiquidations': false,
115
+ 'fetchMySettlementHistory': false,
116
+ 'fetchMyTrades': true,
117
+ 'fetchOHLCV': true,
118
+ 'fetchOpenInterest': false,
119
+ 'fetchOpenInterestHistory': false,
120
+ 'fetchOpenInterests': false,
121
+ 'fetchOpenOrder': false,
122
+ 'fetchOpenOrders': true,
123
+ 'fetchOption': false,
124
+ 'fetchOptionChain': false,
125
+ 'fetchOrder': true,
126
+ 'fetchOrderBook': true,
127
+ 'fetchOrders': false,
128
+ 'fetchOrderTrades': false,
129
+ 'fetchPosition': false,
130
+ 'fetchPositionHistory': false,
131
+ 'fetchPositionMode': false,
132
+ 'fetchPositions': true,
133
+ 'fetchPositionsForSymbol': true,
134
+ 'fetchPositionsHistory': false,
135
+ 'fetchPositionsRisk': false,
136
+ 'fetchPremiumIndexOHLCV': false,
137
+ 'fetchSettlementHistory': false,
138
+ 'fetchStatus': true,
139
+ 'fetchTicker': true,
140
+ 'fetchTickers': true,
141
+ 'fetchTime': true,
142
+ 'fetchTrades': true,
143
+ 'fetchTradingFee': true,
144
+ 'fetchTradingFees': true,
145
+ 'fetchTransactions': false,
146
+ 'fetchTransfers': false,
147
+ 'fetchUnderlyingAssets': false,
148
+ 'fetchVolatilityHistory': false,
149
+ 'fetchWithdrawals': true,
150
+ 'reduceMargin': false,
151
+ 'repayCrossMargin': false,
152
+ 'repayIsolatedMargin': false,
153
+ 'sandbox': false,
154
+ 'setLeverage': true,
155
+ 'setMargin': false,
156
+ 'setMarginMode': false,
157
+ 'setPositionMode': false,
158
+ 'transfer': true,
159
+ 'withdraw': true,
160
+ },
161
+ 'timeframes': {
162
+ '1m': '1m',
163
+ '3m': '3m',
164
+ '5m': '5m',
165
+ '15m': '15m',
166
+ '30m': '30m',
167
+ '1h': '1h',
168
+ '2h': '2h',
169
+ '4h': '4h',
170
+ '6h': '6h',
171
+ '8h': '8h',
172
+ '12h': '12h',
173
+ '1d': '1d',
174
+ '1w': '1w',
175
+ '1M': '1M',
176
+ },
177
+ 'urls': {
178
+ 'logo': 'https://github.com/user-attachments/assets/6dd6127b-cc19-4a13-9b29-a98d81f80e98',
179
+ 'api': {
180
+ 'public': 'https://api-glb.hashkey.com',
181
+ 'private': 'https://api-glb.hashkey.com',
182
+ },
183
+ 'test': {
184
+ 'public': 'https://api-glb.sim.hashkeydev.com',
185
+ 'private': 'https://api-glb.sim.hashkeydev.com',
186
+ },
187
+ 'www': 'https://global.hashkey.com/',
188
+ 'doc': 'https://hashkeyglobal-apidoc.readme.io/',
189
+ 'fees': 'https://support.global.hashkey.com/hc/en-us/articles/13199900083612-HashKey-Global-Fee-Structure',
190
+ 'referral': 'https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN',
191
+ },
192
+ 'api': {
193
+ 'public': {
194
+ 'get': {
195
+ 'api/v1/exchangeInfo': 5,
196
+ 'quote/v1/depth': 1,
197
+ 'quote/v1/trades': 1,
198
+ 'quote/v1/klines': 1,
199
+ 'quote/v1/ticker/24hr': 1,
200
+ 'quote/v1/ticker/price': 1,
201
+ 'quote/v1/ticker/bookTicker': 1,
202
+ 'quote/v1/depth/merged': 1,
203
+ 'quote/v1/markPrice': 1,
204
+ 'quote/v1/index': 1,
205
+ 'api/v1/futures/fundingRate': 1,
206
+ 'api/v1/futures/historyFundingRate': 1,
207
+ 'api/v1/ping': 1,
208
+ 'api/v1/time': 1,
209
+ },
210
+ },
211
+ 'private': {
212
+ 'get': {
213
+ 'api/v1/spot/order': 1,
214
+ 'api/v1/spot/openOrders': 1,
215
+ 'api/v1/spot/tradeOrders': 5,
216
+ 'api/v1/futures/leverage': 1,
217
+ 'api/v1/futures/order': 1,
218
+ 'api/v1/futures/openOrders': 1,
219
+ 'api/v1/futures/userTrades': 1,
220
+ 'api/v1/futures/positions': 1,
221
+ 'api/v1/futures/historyOrders': 1,
222
+ 'api/v1/futures/balance': 1,
223
+ 'api/v1/futures/liquidationAssignStatus': 1,
224
+ 'api/v1/futures/riskLimit': 1,
225
+ 'api/v1/futures/commissionRate': 1,
226
+ 'api/v1/futures/getBestOrder': 1,
227
+ 'api/v1/account/vipInfo': 1,
228
+ 'api/v1/account': 1,
229
+ 'api/v1/account/trades': 5,
230
+ 'api/v1/account/type': 5,
231
+ 'api/v1/account/checkApiKey': 1,
232
+ 'api/v1/account/balanceFlow': 5,
233
+ 'api/v1/spot/subAccount/openOrders': 1,
234
+ 'api/v1/spot/subAccount/tradeOrders': 1,
235
+ 'api/v1/subAccount/trades': 1,
236
+ 'api/v1/futures/subAccount/openOrders': 1,
237
+ 'api/v1/futures/subAccount/historyOrders': 1,
238
+ 'api/v1/futures/subAccount/userTrades': 1,
239
+ 'api/v1/account/deposit/address': 1,
240
+ 'api/v1/account/depositOrders': 1,
241
+ 'api/v1/account/withdrawOrders': 1,
242
+ },
243
+ 'post': {
244
+ 'api/v1/userDataStream': 1,
245
+ 'api/v1/spot/orderTest': 1,
246
+ 'api/v1/spot/order': 1,
247
+ 'api/v1.1/spot/order': 1,
248
+ 'api/v1/spot/batchOrders': 5,
249
+ 'api/v1/futures/leverage': 1,
250
+ 'api/v1/futures/order': 1,
251
+ 'api/v1/futures/position/trading-stop': 3,
252
+ 'api/v1/futures/batchOrders': 5,
253
+ 'api/v1/account/assetTransfer': 1,
254
+ 'api/v1/account/authAddress': 1,
255
+ 'api/v1/account/withdraw': 1,
256
+ },
257
+ 'put': {
258
+ 'api/v1/userDataStream': 1,
259
+ },
260
+ 'delete': {
261
+ 'api/v1/spot/order': 1,
262
+ 'api/v1/spot/openOrders': 5,
263
+ 'api/v1/spot/cancelOrderByIds': 5,
264
+ 'api/v1/futures/order': 1,
265
+ 'api/v1/futures/batchOrders': 1,
266
+ 'api/v1/futures/cancelOrderByIds': 1,
267
+ 'api/v1/userDataStream': 1,
268
+ },
269
+ },
270
+ },
271
+ 'fees': {
272
+ 'trading': {
273
+ 'spot': {
274
+ 'tierBased': true,
275
+ 'percentage': true,
276
+ 'feeSide': 'get',
277
+ 'maker': this.parseNumber('0.0012'),
278
+ 'taker': this.parseNumber('0.0012'),
279
+ 'tiers': {
280
+ 'maker': [
281
+ [this.parseNumber('0'), this.parseNumber('0.0012')],
282
+ [this.parseNumber('1000000'), this.parseNumber('0.00080')],
283
+ [this.parseNumber('5000000'), this.parseNumber('0.00070')],
284
+ [this.parseNumber('10000000'), this.parseNumber('0.00060')],
285
+ [this.parseNumber('50000000'), this.parseNumber('0.00040')],
286
+ [this.parseNumber('200000000'), this.parseNumber('0.00030')],
287
+ [this.parseNumber('400000000'), this.parseNumber('0.00010')],
288
+ [this.parseNumber('800000000'), this.parseNumber('0.00')],
289
+ ],
290
+ 'taker': [
291
+ [this.parseNumber('0'), this.parseNumber('0.0012')],
292
+ [this.parseNumber('1000000'), this.parseNumber('0.00090')],
293
+ [this.parseNumber('5000000'), this.parseNumber('0.00085')],
294
+ [this.parseNumber('10000000'), this.parseNumber('0.00075')],
295
+ [this.parseNumber('50000000'), this.parseNumber('0.00065')],
296
+ [this.parseNumber('200000000'), this.parseNumber('0.00045')],
297
+ [this.parseNumber('400000000'), this.parseNumber('0.00040')],
298
+ [this.parseNumber('800000000'), this.parseNumber('0.00035')],
299
+ ],
300
+ },
301
+ },
302
+ 'swap': {
303
+ 'tierBased': true,
304
+ 'percentage': true,
305
+ 'feeSide': 'get',
306
+ 'maker': this.parseNumber('0.00025'),
307
+ 'taker': this.parseNumber('0.00060'),
308
+ 'tiers': {
309
+ 'maker': [
310
+ [this.parseNumber('0'), this.parseNumber('0.00025')],
311
+ [this.parseNumber('1000000'), this.parseNumber('0.00016')],
312
+ [this.parseNumber('5000000'), this.parseNumber('0.00014')],
313
+ [this.parseNumber('10000000'), this.parseNumber('0.00012')],
314
+ [this.parseNumber('50000000'), this.parseNumber('0.000080')],
315
+ [this.parseNumber('200000000'), this.parseNumber('0.000060')],
316
+ [this.parseNumber('400000000'), this.parseNumber('0.000020')],
317
+ [this.parseNumber('800000000'), this.parseNumber('0.00')],
318
+ ],
319
+ 'taker': [
320
+ [this.parseNumber('0'), this.parseNumber('0.00060')],
321
+ [this.parseNumber('1000000'), this.parseNumber('0.00050')],
322
+ [this.parseNumber('5000000'), this.parseNumber('0.00045')],
323
+ [this.parseNumber('10000000'), this.parseNumber('0.00040')],
324
+ [this.parseNumber('50000000'), this.parseNumber('0.00035')],
325
+ [this.parseNumber('200000000'), this.parseNumber('0.00030')],
326
+ [this.parseNumber('400000000'), this.parseNumber('0.00025')],
327
+ [this.parseNumber('800000000'), this.parseNumber('0.00020')],
328
+ ],
329
+ },
330
+ },
331
+ },
332
+ },
333
+ 'options': {
334
+ 'broker': '10000700011',
335
+ 'recvWindow': undefined,
336
+ 'sandboxMode': false,
337
+ 'networks': {
338
+ 'BTC': 'BTC',
339
+ 'ERC20': 'ETH',
340
+ 'AVAX': 'AvalancheC',
341
+ 'SOL': 'Solana',
342
+ 'MATIC': 'Polygon',
343
+ 'ATOM': 'Cosmos',
344
+ 'DOT': 'Polkadot',
345
+ 'LTC': 'LTC',
346
+ 'OPTIMISM': 'Optimism',
347
+ 'ARB': 'Arbitrum',
348
+ 'DOGE': 'Dogecoin',
349
+ 'TRC20': 'Tron',
350
+ 'ZKSYNC': 'zkSync',
351
+ 'TON': 'TON',
352
+ 'KLAYTN': 'Klaytn',
353
+ 'MERLINCHAIN': 'Merlin Chain',
354
+ },
355
+ 'networksById': {
356
+ 'BTC': 'BTC',
357
+ 'Bitcoin': 'BTC',
358
+ 'ETH': 'ERC20',
359
+ 'ERC20': 'ERC20',
360
+ 'AvalancheC': 'AVAX',
361
+ 'AVAX C-Chain': 'AVAX',
362
+ 'Solana': 'SOL',
363
+ 'Cosmos': 'ATOM',
364
+ 'Arbitrum': 'ARB',
365
+ 'Polygon': 'MATIC',
366
+ 'Optimism': 'OPTIMISM',
367
+ 'Polkadot': 'DOT',
368
+ 'LTC': 'LTC',
369
+ 'Litecoin': 'LTC',
370
+ 'Dogecoin': 'DOGE',
371
+ 'Merlin Chain': 'MERLINCHAIN',
372
+ 'zkSync': 'ZKSYNC',
373
+ 'TRC20': 'TRC20',
374
+ 'Tron': 'TRC20',
375
+ 'TON': 'TON',
376
+ 'BSC(BEP20)': 'BSC',
377
+ 'Klaytn': 'KLAYTN',
378
+ },
379
+ 'defaultNetwork': 'ERC20',
380
+ },
381
+ 'features': {
382
+ 'default': {
383
+ 'sandbox': true,
384
+ 'createOrder': {
385
+ 'marginMode': false,
386
+ 'triggerPrice': false,
387
+ 'triggerPriceType': undefined,
388
+ 'triggerDirection': false,
389
+ 'stopLossPrice': false,
390
+ 'takeProfitPrice': false,
391
+ 'attachedStopLossTakeProfit': undefined,
392
+ 'timeInForce': {
393
+ 'IOC': true,
394
+ 'FOK': true,
395
+ 'PO': true,
396
+ 'GTD': false,
397
+ },
398
+ 'hedged': false,
399
+ 'trailing': false,
400
+ 'leverage': false,
401
+ 'marketBuyByCost': true,
402
+ 'marketBuyRequiresPrice': true,
403
+ 'selfTradePrevention': true,
404
+ 'iceberg': false,
405
+ },
406
+ 'createOrders': {
407
+ 'max': 20,
408
+ },
409
+ 'fetchMyTrades': {
410
+ 'marginMode': false,
411
+ 'limit': 1000,
412
+ 'daysBack': 30,
413
+ 'untilDays': 30,
414
+ 'symbolRequired': false,
415
+ },
416
+ 'fetchOrder': {
417
+ 'marginMode': false,
418
+ 'trigger': false,
419
+ 'trailing': false,
420
+ 'symbolRequired': false,
421
+ },
422
+ 'fetchOpenOrders': {
423
+ 'marginMode': false,
424
+ 'limit': 1000,
425
+ 'trigger': false,
426
+ 'trailing': false,
427
+ 'symbolRequired': false,
428
+ },
429
+ 'fetchOrders': undefined,
430
+ 'fetchClosedOrders': undefined,
431
+ 'fetchOHLCV': {
432
+ 'limit': 1000,
433
+ },
434
+ },
435
+ 'spot': {
436
+ 'extends': 'default',
437
+ },
438
+ 'forDerivatives': {
439
+ 'extends': 'default',
440
+ 'createOrder': {
441
+ 'triggerPrice': true,
442
+ 'selfTradePrevention': true,
443
+ },
444
+ 'fetchOpenOrders': {
445
+ 'trigger': true,
446
+ 'limit': 500,
447
+ },
448
+ },
449
+ 'swap': {
450
+ 'linear': {
451
+ 'extends': 'forDerivatives',
452
+ },
453
+ 'inverse': undefined,
454
+ },
455
+ 'future': {
456
+ 'linear': undefined,
457
+ 'inverse': undefined,
458
+ },
459
+ },
460
+ 'commonCurrencies': {},
461
+ 'exceptions': {
462
+ 'exact': {
463
+ '0001': BadRequest,
464
+ '0002': AuthenticationError,
465
+ '0003': RateLimitExceeded,
466
+ '0102': AuthenticationError,
467
+ '0103': AuthenticationError,
468
+ '0104': PermissionDenied,
469
+ '0201': ExchangeError,
470
+ '0202': PermissionDenied,
471
+ '0206': BadRequest,
472
+ '0207': BadRequest,
473
+ '0209': BadRequest,
474
+ '0210': BadRequest,
475
+ '0211': OrderNotFound,
476
+ '0401': InsufficientFunds,
477
+ '0402': BadRequest,
478
+ '-1000': ExchangeError,
479
+ '-1001': ExchangeError,
480
+ '-100010': BadSymbol,
481
+ '-100012': BadSymbol,
482
+ '-1002': AuthenticationError,
483
+ '-1004': BadRequest,
484
+ '-1005': PermissionDenied,
485
+ '-1006': ExchangeError,
486
+ '-1007': RequestTimeout,
487
+ '-1014': InvalidOrder,
488
+ '-1015': InvalidOrder,
489
+ '-1020': OperationRejected,
490
+ '-1021': InvalidNonce,
491
+ '-1024': BadRequest,
492
+ '-1101': ExchangeNotAvailable,
493
+ '-1115': InvalidOrder,
494
+ '-1117': InvalidOrder,
495
+ '-1123': InvalidOrder,
496
+ '-1124': InvalidOrder,
497
+ '-1126': InvalidOrder,
498
+ '-1129': BadRequest,
499
+ '-1130': BadRequest,
500
+ '-1132': BadRequest,
501
+ '-1133': BadRequest,
502
+ '-1135': BadRequest,
503
+ '-1136': BadRequest,
504
+ '-1138': InvalidOrder,
505
+ '-1137': InvalidOrder,
506
+ '-1139': OrderImmediatelyFillable,
507
+ '-1140': InvalidOrder,
508
+ '-1141': DuplicateOrderId,
509
+ '-1142': OrderNotFillable,
510
+ '-1143': OrderNotFound,
511
+ '-1144': OperationRejected,
512
+ '-1145': NotSupported,
513
+ '-1146': RequestTimeout,
514
+ '-1147': RequestTimeout,
515
+ '-1148': InvalidOrder,
516
+ '-1149': OperationRejected,
517
+ '-1150': OperationFailed,
518
+ '-1151': OperationRejected,
519
+ '-1152': AccountNotEnabled,
520
+ '-1153': InvalidOrder,
521
+ '-1154': InvalidOrder,
522
+ '-1155': OperationRejected,
523
+ '-1156': OperationFailed,
524
+ '-1157': OperationFailed,
525
+ '-1158': OperationFailed,
526
+ '-1159': AccountNotEnabled,
527
+ '-1160': AccountNotEnabled,
528
+ '-1161': OperationFailed,
529
+ '-1162': ContractUnavailable,
530
+ '-1163': InvalidAddress,
531
+ '-1164': OperationFailed,
532
+ '-1165': ArgumentsRequired,
533
+ '-1166': OperationRejected,
534
+ '-1167': BadRequest,
535
+ '-1168': BadRequest,
536
+ '-1169': PermissionDenied,
537
+ '-1170': PermissionDenied,
538
+ '-1171': PermissionDenied,
539
+ '-1172': BadRequest,
540
+ '-1173': BadRequest,
541
+ '-1174': PermissionDenied,
542
+ '-1175': BadRequest,
543
+ '-1176': BadRequest,
544
+ '-1177': InvalidOrder,
545
+ '-1178': AccountNotEnabled,
546
+ '-1179': AccountSuspended,
547
+ '-1181': ExchangeError,
548
+ '-1193': OperationRejected,
549
+ '-1194': OperationRejected,
550
+ '-1195': BadRequest,
551
+ '-1196': BadRequest,
552
+ '-1200': BadRequest,
553
+ '-1201': BadRequest,
554
+ '-1202': BadRequest,
555
+ '-1203': BadRequest,
556
+ '-1204': BadRequest,
557
+ '-1205': AccountNotEnabled,
558
+ '-1206': BadRequest,
559
+ '-1207': BadRequest,
560
+ '-1208': BadRequest,
561
+ '-1209': BadRequest,
562
+ '-2001': ExchangeNotAvailable,
563
+ '-2002': OperationFailed,
564
+ '-2003': OperationFailed,
565
+ '-2004': OperationFailed,
566
+ '-2005': RequestTimeout,
567
+ '-2010': OperationRejected,
568
+ '-2011': OperationRejected,
569
+ '-2016': OperationRejected,
570
+ '-2017': OperationRejected,
571
+ '-2018': OperationRejected,
572
+ '-2019': PermissionDenied,
573
+ '-2020': PermissionDenied,
574
+ '-2021': PermissionDenied,
575
+ '-2022': OperationRejected,
576
+ '-2023': AuthenticationError,
577
+ '-2024': AccountNotEnabled,
578
+ '-2025': AccountNotEnabled,
579
+ '-2026': BadRequest,
580
+ '-2027': OperationRejected,
581
+ '-2028': OperationRejected,
582
+ '-2029': OperationRejected,
583
+ '-2030': InsufficientFunds,
584
+ '-2031': NotSupported,
585
+ '-2032': OperationRejected,
586
+ '-2033': OperationFailed,
587
+ '-2034': InsufficientFunds,
588
+ '-2035': OperationRejected,
589
+ '-2036': NotSupported,
590
+ '-2037': ExchangeError,
591
+ '-2038': InsufficientFunds,
592
+ '-2039': NotSupported,
593
+ '-2040': ExchangeNotAvailable,
594
+ '-2041': BadRequest,
595
+ '-2042': OperationRejected,
596
+ '-2043': OperationRejected,
597
+ '-2044': BadRequest,
598
+ '-2045': BadRequest,
599
+ '-2046': BadRequest,
600
+ '-2048': BadRequest,
601
+ '-2049': BadRequest,
602
+ '-2050': BadRequest,
603
+ '-2051': OperationRejected,
604
+ '-2052': OperationRejected,
605
+ '-2053': OperationRejected,
606
+ '-2054': BadRequest,
607
+ '-2055': BadRequest,
608
+ '-2056': BadRequest,
609
+ '-2057': BadRequest,
610
+ '-3117': PermissionDenied,
611
+ '-3143': PermissionDenied,
612
+ '-3144': PermissionDenied,
613
+ '-3145': DDoSProtection,
614
+ '-4001': BadRequest,
615
+ '-4002': BadRequest,
616
+ '-4003': InsufficientFunds,
617
+ '-4004': BadRequest,
618
+ '-4005': BadRequest,
619
+ '-4006': AccountNotEnabled,
620
+ '-4007': NotSupported,
621
+ '-4008': AccountNotEnabled,
622
+ '-4009': PermissionDenied,
623
+ '-4010': PermissionDenied,
624
+ '-4011': ExchangeError,
625
+ '-4012': ExchangeError,
626
+ '-4013': OperationFailed, // Withdraw repeatly
627
+ },
628
+ 'broad': {},
629
+ },
630
+ 'precisionMode': TICK_SIZE,
631
+ });
632
+ }
633
+ /**
634
+ * @method
635
+ * @name hashkey#fetchTime
636
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
637
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/check-server-time
638
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
639
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
640
+ */
641
+ async fetchTime(params = {}) {
642
+ const response = await this.publicGetApiV1Time(params);
643
+ //
644
+ // {
645
+ // "serverTime": 1721661553214
646
+ // }
647
+ //
648
+ return this.safeInteger(response, 'serverTime');
649
+ }
650
+ /**
651
+ * @method
652
+ * @name hashkey#fetchStatus
653
+ * @description the latest known information on the availability of the exchange API
654
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/test-connectivity
655
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
656
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
657
+ */
658
+ async fetchStatus(params = {}) {
659
+ const response = await this.publicGetApiV1Ping(params);
660
+ //
661
+ // {}
662
+ //
663
+ return {
664
+ 'status': 'ok',
665
+ 'updated': undefined,
666
+ 'eta': undefined,
667
+ 'url': undefined,
668
+ 'info': response,
669
+ };
670
+ }
671
+ /**
672
+ * @method
673
+ * @name hashkey#fetchMarkets
674
+ * @description retrieves data on all markets for the exchange
675
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/exchangeinfo
676
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
677
+ * @param {string} [params.symbol] the id of the market to fetch
678
+ * @returns {object[]} an array of objects representing market data
679
+ */
680
+ async fetchMarkets(params = {}) {
681
+ const request = {};
682
+ const response = await this.publicGetApiV1ExchangeInfo(this.extend(request, params));
683
+ //
684
+ // {
685
+ // "timezone": "UTC",
686
+ // "serverTime": "1721661653952",
687
+ // "brokerFilters": [],
688
+ // "symbols": [
689
+ // {
690
+ // "symbol": "BTCUSDT",
691
+ // "symbolName": "BTCUSDT",
692
+ // "status": "TRADING",
693
+ // "baseAsset": "BTC",
694
+ // "baseAssetName": "BTC",
695
+ // "baseAssetPrecision": "0.00001",
696
+ // "quoteAsset": "USDT",
697
+ // "quoteAssetName": "USDT",
698
+ // "quotePrecision": "0.0000001",
699
+ // "retailAllowed": true,
700
+ // "piAllowed": true,
701
+ // "corporateAllowed": true,
702
+ // "omnibusAllowed": true,
703
+ // "icebergAllowed": false,
704
+ // "isAggregate": false,
705
+ // "allowMargin": false,
706
+ // "filters": [
707
+ // {
708
+ // "minPrice": "0.01",
709
+ // "maxPrice": "100000.00000000",
710
+ // "tickSize": "0.01",
711
+ // "filterType": "PRICE_FILTER"
712
+ // },
713
+ // {
714
+ // "minQty": "0.00001",
715
+ // "maxQty": "8",
716
+ // "stepSize": "0.00001",
717
+ // "marketOrderMinQty": "0.00001",
718
+ // "marketOrderMaxQty": "4",
719
+ // "filterType": "LOT_SIZE"
720
+ // },
721
+ // {
722
+ // "minNotional": "1",
723
+ // "filterType": "MIN_NOTIONAL"
724
+ // },
725
+ // {
726
+ // "minAmount": "1",
727
+ // "maxAmount": "400000",
728
+ // "minBuyPrice": "0",
729
+ // "marketOrderMinAmount": "1",
730
+ // "marketOrderMaxAmount": "200000",
731
+ // "filterType": "TRADE_AMOUNT"
732
+ // },
733
+ // {
734
+ // "maxSellPrice": "0",
735
+ // "buyPriceUpRate": "0.1",
736
+ // "sellPriceDownRate": "0.1",
737
+ // "filterType": "LIMIT_TRADING"
738
+ // },
739
+ // {
740
+ // "buyPriceUpRate": "0.1",
741
+ // "sellPriceDownRate": "0.1",
742
+ // "filterType": "MARKET_TRADING"
743
+ // },
744
+ // {
745
+ // "noAllowMarketStartTime": "1710485700000",
746
+ // "noAllowMarketEndTime": "1710486000000",
747
+ // "limitOrderStartTime": "0",
748
+ // "limitOrderEndTime": "0",
749
+ // "limitMinPrice": "0",
750
+ // "limitMaxPrice": "0",
751
+ // "filterType": "OPEN_QUOTE"
752
+ // }
753
+ // ]
754
+ // }
755
+ // ],
756
+ // "options": [ ],
757
+ // "contracts": [
758
+ // {
759
+ // "filters": [
760
+ // {
761
+ // "minPrice": "0.1",
762
+ // "maxPrice": "100000.00000000",
763
+ // "tickSize": "0.1",
764
+ // "filterType": "PRICE_FILTER"
765
+ // },
766
+ // {
767
+ // "minQty": "0.001",
768
+ // "maxQty": "10",
769
+ // "stepSize": "0.001",
770
+ // "marketOrderMinQty": "0",
771
+ // "marketOrderMaxQty": "0",
772
+ // "filterType": "LOT_SIZE"
773
+ // },
774
+ // {
775
+ // "minNotional": "0",
776
+ // "filterType": "MIN_NOTIONAL"
777
+ // },
778
+ // {
779
+ // "maxSellPrice": "999999",
780
+ // "buyPriceUpRate": "0.05",
781
+ // "sellPriceDownRate": "0.05",
782
+ // "maxEntrustNum": 200,
783
+ // "maxConditionNum": 200,
784
+ // "filterType": "LIMIT_TRADING"
785
+ // },
786
+ // {
787
+ // "buyPriceUpRate": "0.05",
788
+ // "sellPriceDownRate": "0.05",
789
+ // "filterType": "MARKET_TRADING"
790
+ // },
791
+ // {
792
+ // "noAllowMarketStartTime": "0",
793
+ // "noAllowMarketEndTime": "0",
794
+ // "limitOrderStartTime": "0",
795
+ // "limitOrderEndTime": "0",
796
+ // "limitMinPrice": "0",
797
+ // "limitMaxPrice": "0",
798
+ // "filterType": "OPEN_QUOTE"
799
+ // }
800
+ // ],
801
+ // "exchangeId": "301",
802
+ // "symbol": "BTCUSDT-PERPETUAL",
803
+ // "symbolName": "BTCUSDT-PERPETUAL",
804
+ // "status": "TRADING",
805
+ // "baseAsset": "BTCUSDT-PERPETUAL",
806
+ // "baseAssetPrecision": "0.001",
807
+ // "quoteAsset": "USDT",
808
+ // "quoteAssetPrecision": "0.1",
809
+ // "icebergAllowed": false,
810
+ // "inverse": false,
811
+ // "index": "USDT",
812
+ // "marginToken": "USDT",
813
+ // "marginPrecision": "0.0001",
814
+ // "contractMultiplier": "0.001",
815
+ // "underlying": "BTC",
816
+ // "riskLimits": [
817
+ // {
818
+ // "riskLimitId": "200000722",
819
+ // "quantity": "1000.00",
820
+ // "initialMargin": "0.10",
821
+ // "maintMargin": "0.005",
822
+ // "isWhite": false
823
+ // },
824
+ // {
825
+ // "riskLimitId": "200000723",
826
+ // "quantity": "2000.00",
827
+ // "initialMargin": "0.10",
828
+ // "maintMargin": "0.01",
829
+ // "isWhite": false
830
+ // }
831
+ // ]
832
+ // }
833
+ // ],
834
+ // "coins": [
835
+ // {
836
+ // "orgId": "9001",
837
+ // "coinId": "BTC",
838
+ // "coinName": "BTC",
839
+ // "coinFullName": "Bitcoin",
840
+ // "allowWithdraw": true,
841
+ // "allowDeposit": true,
842
+ // "tokenType": "CHAIN_TOKEN",
843
+ // "chainTypes": [
844
+ // {
845
+ // "chainType": "Bitcoin",
846
+ // "withdrawFee": "0",
847
+ // "minWithdrawQuantity": "0.002",
848
+ // "maxWithdrawQuantity": "0",
849
+ // "minDepositQuantity": "0.0005",
850
+ // "allowDeposit": true,
851
+ // "allowWithdraw": true
852
+ // }
853
+ // ]
854
+ // }
855
+ // ]
856
+ // }
857
+ //
858
+ const spotMarkets = this.safeList(response, 'symbols', []);
859
+ const swapMarkets = this.safeList(response, 'contracts', []);
860
+ let markets = this.arrayConcat(spotMarkets, swapMarkets);
861
+ if (this.isEmpty(markets)) {
862
+ markets = [response]; // if user provides params.symbol the exchange returns a single object insted of list of objects
863
+ }
864
+ return this.parseMarkets(markets);
865
+ }
866
+ parseMarket(market) {
867
+ // spot
868
+ // {
869
+ // "symbol": "BTCUSDT",
870
+ // "symbolName": "BTCUSDT",
871
+ // "status": "TRADING",
872
+ // "baseAsset": "BTC",
873
+ // "baseAssetName": "BTC",
874
+ // "baseAssetPrecision": "0.00001",
875
+ // "quoteAsset": "USDT",
876
+ // "quoteAssetName": "USDT",
877
+ // "quotePrecision": "0.0000001",
878
+ // "retailAllowed": true,
879
+ // "piAllowed": true,
880
+ // "corporateAllowed": true,
881
+ // "omnibusAllowed": true,
882
+ // "icebergAllowed": false,
883
+ // "isAggregate": false,
884
+ // "allowMargin": false,
885
+ // "filters": [
886
+ // {
887
+ // "minPrice": "0.01",
888
+ // "maxPrice": "100000.00000000",
889
+ // "tickSize": "0.01",
890
+ // "filterType": "PRICE_FILTER"
891
+ // },
892
+ // {
893
+ // "minQty": "0.00001",
894
+ // "maxQty": "8",
895
+ // "stepSize": "0.00001",
896
+ // "marketOrderMinQty": "0.00001",
897
+ // "marketOrderMaxQty": "4",
898
+ // "filterType": "LOT_SIZE"
899
+ // },
900
+ // {
901
+ // "minNotional": "1",
902
+ // "filterType": "MIN_NOTIONAL"
903
+ // },
904
+ // {
905
+ // "minAmount": "1",
906
+ // "maxAmount": "400000",
907
+ // "minBuyPrice": "0",
908
+ // "marketOrderMinAmount": "1",
909
+ // "marketOrderMaxAmount": "200000",
910
+ // "filterType": "TRADE_AMOUNT"
911
+ // },
912
+ // {
913
+ // "maxSellPrice": "0",
914
+ // "buyPriceUpRate": "0.1",
915
+ // "sellPriceDownRate": "0.1",
916
+ // "filterType": "LIMIT_TRADING"
917
+ // },
918
+ // {
919
+ // "buyPriceUpRate": "0.1",
920
+ // "sellPriceDownRate": "0.1",
921
+ // "filterType": "MARKET_TRADING"
922
+ // },
923
+ // {
924
+ // "noAllowMarketStartTime": "1710485700000",
925
+ // "noAllowMarketEndTime": "1710486000000",
926
+ // "limitOrderStartTime": "0",
927
+ // "limitOrderEndTime": "0",
928
+ // "limitMinPrice": "0",
929
+ // "limitMaxPrice": "0",
930
+ // "filterType": "OPEN_QUOTE"
931
+ // }
932
+ // ]
933
+ // }
934
+ //
935
+ // swap
936
+ // {
937
+ // "filters": [
938
+ // {
939
+ // "minPrice": "0.1",
940
+ // "maxPrice": "100000.00000000",
941
+ // "tickSize": "0.1",
942
+ // "filterType": "PRICE_FILTER"
943
+ // },
944
+ // {
945
+ // "minQty": "0.001",
946
+ // "maxQty": "10",
947
+ // "stepSize": "0.001",
948
+ // "marketOrderMinQty": "0",
949
+ // "marketOrderMaxQty": "0",
950
+ // "filterType": "LOT_SIZE"
951
+ // },
952
+ // {
953
+ // "minNotional": "0",
954
+ // "filterType": "MIN_NOTIONAL"
955
+ // },
956
+ // {
957
+ // "maxSellPrice": "999999",
958
+ // "buyPriceUpRate": "0.05",
959
+ // "sellPriceDownRate": "0.05",
960
+ // "maxEntrustNum": 200,
961
+ // "maxConditionNum": 200,
962
+ // "filterType": "LIMIT_TRADING"
963
+ // },
964
+ // {
965
+ // "buyPriceUpRate": "0.05",
966
+ // "sellPriceDownRate": "0.05",
967
+ // "filterType": "MARKET_TRADING"
968
+ // },
969
+ // {
970
+ // "noAllowMarketStartTime": "0",
971
+ // "noAllowMarketEndTime": "0",
972
+ // "limitOrderStartTime": "0",
973
+ // "limitOrderEndTime": "0",
974
+ // "limitMinPrice": "0",
975
+ // "limitMaxPrice": "0",
976
+ // "filterType": "OPEN_QUOTE"
977
+ // }
978
+ // ],
979
+ // "exchangeId": "301",
980
+ // "symbol": "BTCUSDT-PERPETUAL",
981
+ // "symbolName": "BTCUSDT-PERPETUAL",
982
+ // "status": "TRADING",
983
+ // "baseAsset": "BTCUSDT-PERPETUAL",
984
+ // "baseAssetPrecision": "0.001",
985
+ // "quoteAsset": "USDT",
986
+ // "quoteAssetPrecision": "0.1",
987
+ // "icebergAllowed": false,
988
+ // "inverse": false,
989
+ // "index": "USDT",
990
+ // "marginToken": "USDT",
991
+ // "marginPrecision": "0.0001",
992
+ // "contractMultiplier": "0.001",
993
+ // "underlying": "BTC",
994
+ // "riskLimits": [
995
+ // {
996
+ // "riskLimitId": "200000722",
997
+ // "quantity": "1000.00",
998
+ // "initialMargin": "0.10",
999
+ // "maintMargin": "0.005",
1000
+ // "isWhite": false
1001
+ // },
1002
+ // {
1003
+ // "riskLimitId": "200000723",
1004
+ // "quantity": "2000.00",
1005
+ // "initialMargin": "0.10",
1006
+ // "maintMargin": "0.01",
1007
+ // "isWhite": false
1008
+ // }
1009
+ // ]
1010
+ // }
1011
+ //
1012
+ const marketId = this.safeString(market, 'symbol');
1013
+ const quoteId = this.safeString(market, 'quoteAsset');
1014
+ const quote = this.safeCurrencyCode(quoteId);
1015
+ const settleId = this.safeString(market, 'marginToken');
1016
+ const settle = this.safeCurrencyCode(settleId);
1017
+ let baseId = this.safeString(market, 'baseAsset');
1018
+ let marketType = 'spot';
1019
+ let isSpot = true;
1020
+ let isSwap = false;
1021
+ let suffix = '';
1022
+ const parts = marketId.split('-');
1023
+ const secondPart = this.safeString(parts, 1);
1024
+ if (secondPart === 'PERPETUAL') {
1025
+ marketType = 'swap';
1026
+ isSpot = false;
1027
+ isSwap = true;
1028
+ baseId = this.safeString(market, 'underlying');
1029
+ suffix += ':' + settleId;
1030
+ }
1031
+ const base = this.safeCurrencyCode(baseId);
1032
+ const symbol = base + '/' + quote + suffix;
1033
+ const status = this.safeString(market, 'status');
1034
+ const active = status === 'TRADING';
1035
+ let isLinear = undefined;
1036
+ let subType = undefined;
1037
+ const isInverse = this.safeBool(market, 'inverse');
1038
+ if (isInverse !== undefined) {
1039
+ if (isInverse) {
1040
+ isLinear = false;
1041
+ subType = 'inverse';
1042
+ }
1043
+ else {
1044
+ isLinear = true;
1045
+ subType = 'linear';
1046
+ }
1047
+ }
1048
+ const filtersList = this.safeList(market, 'filters', []);
1049
+ const filters = this.indexBy(filtersList, 'filterType');
1050
+ const priceFilter = this.safeDict(filters, 'PRICE_FILTER', {});
1051
+ const amountFilter = this.safeDict(filters, 'LOT_SIZE', {});
1052
+ const costFilter = this.safeDict(filters, 'MIN_NOTIONAL', {});
1053
+ const minCostString = this.omitZero(this.safeString(costFilter, 'min_notional'));
1054
+ const contractSizeString = this.safeString(market, 'contractMultiplier');
1055
+ let amountPrecisionString = this.safeString(amountFilter, 'stepSize');
1056
+ let amountMinLimitString = this.safeString(amountFilter, 'minQty');
1057
+ let amountMaxLimitString = this.safeString(amountFilter, 'maxQty');
1058
+ let minLeverage = undefined;
1059
+ let maxLeverage = undefined;
1060
+ if (isSwap) {
1061
+ amountPrecisionString = Precise.stringDiv(amountPrecisionString, contractSizeString);
1062
+ amountMinLimitString = Precise.stringDiv(amountMinLimitString, contractSizeString);
1063
+ amountMaxLimitString = Precise.stringDiv(amountMaxLimitString, contractSizeString);
1064
+ const riskLimits = this.safeList(market, 'riskLimits');
1065
+ if (riskLimits !== undefined) {
1066
+ const first = this.safeDict(riskLimits, 0);
1067
+ const arrayLength = riskLimits.length;
1068
+ const last = this.safeDict(riskLimits, arrayLength - 1);
1069
+ let minInitialMargin = this.safeString(first, 'initialMargin');
1070
+ let maxInitialMargin = this.safeString(last, 'initialMargin');
1071
+ if (Precise.stringGt(minInitialMargin, maxInitialMargin)) {
1072
+ [minInitialMargin, maxInitialMargin] = [maxInitialMargin, minInitialMargin];
1073
+ }
1074
+ minLeverage = this.parseToInt(Precise.stringDiv('1', maxInitialMargin));
1075
+ maxLeverage = this.parseToInt(Precise.stringDiv('1', minInitialMargin));
1076
+ }
1077
+ }
1078
+ const tradingFees = this.safeDict(this.fees, 'trading');
1079
+ const fees = isSpot ? this.safeDict(tradingFees, 'spot') : this.safeDict(tradingFees, 'swap');
1080
+ return this.safeMarketStructure({
1081
+ 'id': marketId,
1082
+ 'symbol': symbol,
1083
+ 'base': base,
1084
+ 'quote': quote,
1085
+ 'baseId': baseId,
1086
+ 'quoteId': quoteId,
1087
+ 'active': active,
1088
+ 'type': marketType,
1089
+ 'subType': subType,
1090
+ 'spot': isSpot,
1091
+ 'margin': this.safeBool(market, 'allowMargin'),
1092
+ 'swap': isSwap,
1093
+ 'future': false,
1094
+ 'option': false,
1095
+ 'contract': isSwap,
1096
+ 'settle': settle,
1097
+ 'settleId': settleId,
1098
+ 'contractSize': this.parseNumber(contractSizeString),
1099
+ 'linear': isLinear,
1100
+ 'inverse': isInverse,
1101
+ 'taker': this.safeNumber(fees, 'taker'),
1102
+ 'maker': this.safeNumber(fees, 'maker'),
1103
+ 'percentage': this.safeBool(fees, 'percentage'),
1104
+ 'tierBased': this.safeBool(fees, 'tierBased'),
1105
+ 'feeSide': this.safeString(fees, 'feeSide'),
1106
+ 'expiry': undefined,
1107
+ 'expiryDatetime': undefined,
1108
+ 'strike': undefined,
1109
+ 'optionType': undefined,
1110
+ 'precision': {
1111
+ 'amount': this.parseNumber(amountPrecisionString),
1112
+ 'price': this.safeNumber(priceFilter, 'tickSize'),
1113
+ },
1114
+ 'limits': {
1115
+ 'amount': {
1116
+ 'min': this.parseNumber(amountMinLimitString),
1117
+ 'max': this.parseNumber(amountMaxLimitString),
1118
+ },
1119
+ 'price': {
1120
+ 'min': this.safeNumber(priceFilter, 'minPrice'),
1121
+ 'max': this.safeNumber(priceFilter, 'maxPrice'),
1122
+ },
1123
+ 'leverage': {
1124
+ 'min': minLeverage,
1125
+ 'max': maxLeverage,
1126
+ },
1127
+ 'cost': {
1128
+ 'min': this.parseNumber(minCostString),
1129
+ 'max': undefined,
1130
+ },
1131
+ },
1132
+ 'created': undefined,
1133
+ 'info': market,
1134
+ });
1135
+ }
1136
+ /**
1137
+ * @method
1138
+ * @name hashkey#fetchCurrencies
1139
+ * @description fetches all available currencies on an exchange
1140
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/exchangeinfo
1141
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1142
+ * @returns {object} an associative dictionary of currencies
1143
+ */
1144
+ async fetchCurrencies(params = {}) {
1145
+ const response = await this.publicGetApiV1ExchangeInfo(params);
1146
+ const coins = this.safeList(response, 'coins');
1147
+ //
1148
+ // {
1149
+ // ...
1150
+ // "coins": [
1151
+ // {
1152
+ // "orgId": "9001",
1153
+ // "coinId": "BTC",
1154
+ // "coinName": "BTC",
1155
+ // "coinFullName": "Bitcoin",
1156
+ // "allowWithdraw": true,
1157
+ // "allowDeposit": true,
1158
+ // "tokenType": "CHAIN_TOKEN",
1159
+ // "chainTypes": [
1160
+ // {
1161
+ // "chainType": "Bitcoin",
1162
+ // "withdrawFee": "0",
1163
+ // "minWithdrawQuantity": "0.002",
1164
+ // "maxWithdrawQuantity": "0",
1165
+ // "minDepositQuantity": "0.0005",
1166
+ // "allowDeposit": true,
1167
+ // "allowWithdraw": true
1168
+ // }
1169
+ // ]
1170
+ // }
1171
+ // ]
1172
+ // }
1173
+ //
1174
+ const result = {};
1175
+ for (let i = 0; i < coins.length; i++) {
1176
+ const currecy = coins[i];
1177
+ const currencyId = this.safeString(currecy, 'coinId');
1178
+ const code = this.safeCurrencyCode(currencyId);
1179
+ const networks = this.safeList(currecy, 'chainTypes');
1180
+ const parsedNetworks = {};
1181
+ for (let j = 0; j < networks.length; j++) {
1182
+ const network = networks[j];
1183
+ const networkId = this.safeString(network, 'chainType');
1184
+ const networkCode = this.networkCodeToId(networkId);
1185
+ parsedNetworks[networkCode] = {
1186
+ 'id': networkId,
1187
+ 'network': networkCode,
1188
+ 'limits': {
1189
+ 'withdraw': {
1190
+ 'min': this.safeNumber(network, 'minWithdrawQuantity'),
1191
+ 'max': this.parseNumber(this.omitZero(this.safeString(network, 'maxWithdrawQuantity'))),
1192
+ },
1193
+ 'deposit': {
1194
+ 'min': this.safeNumber(network, 'minDepositQuantity'),
1195
+ 'max': undefined,
1196
+ },
1197
+ },
1198
+ 'active': undefined,
1199
+ 'deposit': this.safeBool(network, 'allowDeposit'),
1200
+ 'withdraw': this.safeBool(network, 'allowWithdraw'),
1201
+ 'fee': this.safeNumber(network, 'withdrawFee'),
1202
+ 'precision': undefined,
1203
+ 'info': network,
1204
+ };
1205
+ }
1206
+ const rawType = this.safeString(currecy, 'tokenType');
1207
+ const type = (rawType === 'REAL_MONEY') ? 'fiat' : 'crypto';
1208
+ result[code] = this.safeCurrencyStructure({
1209
+ 'id': currencyId,
1210
+ 'code': code,
1211
+ 'precision': undefined,
1212
+ 'type': type,
1213
+ 'name': this.safeString(currecy, 'coinFullName'),
1214
+ 'active': undefined,
1215
+ 'deposit': this.safeBool(currecy, 'allowDeposit'),
1216
+ 'withdraw': this.safeBool(currecy, 'allowWithdraw'),
1217
+ 'fee': undefined,
1218
+ 'limits': {
1219
+ 'deposit': {
1220
+ 'min': undefined,
1221
+ 'max': undefined,
1222
+ },
1223
+ 'withdraw': {
1224
+ 'min': undefined,
1225
+ 'max': undefined,
1226
+ },
1227
+ },
1228
+ 'networks': parsedNetworks,
1229
+ 'info': currecy,
1230
+ });
1231
+ }
1232
+ return result;
1233
+ }
1234
+ /**
1235
+ * @method
1236
+ * @name hashkey#fetchOrderBook
1237
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1238
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-order-book
1239
+ * @param {string} symbol unified symbol of the market to fetch the order book for
1240
+ * @param {int} [limit] the maximum amount of order book entries to return (maximum value is 200)
1241
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1242
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1243
+ */
1244
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
1245
+ await this.loadMarkets();
1246
+ const market = this.market(symbol);
1247
+ const request = {
1248
+ 'symbol': market['id'],
1249
+ };
1250
+ if (limit !== undefined) {
1251
+ request['limit'] = limit;
1252
+ }
1253
+ const response = await this.publicGetQuoteV1Depth(this.extend(request, params));
1254
+ //
1255
+ // {
1256
+ // "t": 1721681436393,
1257
+ // "b": [
1258
+ // ["67902.49", "0.00112"],
1259
+ // ["67901.08", "0.01014"]
1260
+ // ...
1261
+ // ],
1262
+ // "a": [
1263
+ // ["67905.99", "0.87134"],
1264
+ // ["67906", "0.57361"]
1265
+ // ...
1266
+ // ]
1267
+ // }
1268
+ //
1269
+ const timestamp = this.safeInteger(response, 't');
1270
+ return this.parseOrderBook(response, symbol, timestamp, 'b', 'a');
1271
+ }
1272
+ /**
1273
+ * @method
1274
+ * @name hashkey#fetchTrades
1275
+ * @description get the list of most recent trades for a particular symbol
1276
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-recent-trade-list
1277
+ * @param {string} symbol unified symbol of the market to fetch trades for
1278
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1279
+ * @param {int} [limit] the maximum amount of trades to fetch (maximum value is 100)
1280
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1281
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1282
+ */
1283
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1284
+ await this.loadMarkets();
1285
+ const market = this.market(symbol);
1286
+ const request = {
1287
+ 'symbol': market['id'],
1288
+ };
1289
+ if (limit !== undefined) {
1290
+ request['limit'] = limit;
1291
+ }
1292
+ const response = await this.publicGetQuoteV1Trades(this.extend(request, params));
1293
+ //
1294
+ // [
1295
+ // {
1296
+ // "t": 1721682745779,
1297
+ // "p": "67835.99",
1298
+ // "q": "0.00017",
1299
+ // "ibm": true
1300
+ // },
1301
+ // ...
1302
+ // ]
1303
+ //
1304
+ return this.parseTrades(response, market, since, limit);
1305
+ }
1306
+ /**
1307
+ * @method
1308
+ * @name hashkey#fetchMyTrades
1309
+ * @description fetch all trades made by the user
1310
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-account-trade-list
1311
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/query-futures-trades
1312
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-user
1313
+ * @param {string} symbol *is mandatory for swap markets* unified market symbol
1314
+ * @param {int} [since] the earliest time in ms to fetch trades for
1315
+ * @param {int} [limit] the maximum amount of trades to fetch (default 200, max 500)
1316
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1317
+ * @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch trades for (default 'spot')
1318
+ * @param {int} [params.until] the latest time in ms to fetch trades for, only supports the last 30 days timeframe
1319
+ * @param {string} [params.fromId] srarting trade id
1320
+ * @param {string} [params.toId] ending trade id
1321
+ * @param {string} [params.clientOrderId] *spot markets only* filter trades by orderId
1322
+ * @param {string} [params.accountId] account id to fetch the orders from
1323
+ * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1324
+ */
1325
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1326
+ const methodName = 'fetchMyTrades';
1327
+ await this.loadMarkets();
1328
+ const request = {};
1329
+ let market = undefined;
1330
+ if (symbol !== undefined) {
1331
+ market = this.market(symbol);
1332
+ }
1333
+ let marketType = 'spot';
1334
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params);
1335
+ if (since !== undefined) {
1336
+ request['startTime'] = since;
1337
+ }
1338
+ if (limit !== undefined) {
1339
+ request['limit'] = limit;
1340
+ }
1341
+ let until = undefined;
1342
+ [until, params] = this.handleOptionAndParams(params, methodName, 'until');
1343
+ if (until !== undefined) {
1344
+ request['endTime'] = until;
1345
+ }
1346
+ let accountId = undefined;
1347
+ [accountId, params] = this.handleOptionAndParams(params, methodName, 'accountId');
1348
+ let response = undefined;
1349
+ if (marketType === 'spot') {
1350
+ if (market !== undefined) {
1351
+ request['symbol'] = market['id'];
1352
+ }
1353
+ if (accountId !== undefined) {
1354
+ request['accountId'] = accountId;
1355
+ }
1356
+ response = await this.privateGetApiV1AccountTrades(this.extend(request, params));
1357
+ //
1358
+ // [
1359
+ // {
1360
+ // "id": "1739352552862964736",
1361
+ // "clientOrderId": "1722082982086472",
1362
+ // "ticketId": "1739352552795029504",
1363
+ // "symbol": "ETHUSDT",
1364
+ // "symbolName": "ETHUSDT",
1365
+ // "orderId": "1739352552762301440",
1366
+ // "matchOrderId": "0",
1367
+ // "price": "3289.96",
1368
+ // "qty": "0.001",
1369
+ // "commission": "0.0000012",
1370
+ // "commissionAsset": "ETH",
1371
+ // "time": "1722082982097",
1372
+ // "isBuyer": true,
1373
+ // "isMaker": false,
1374
+ // "fee": {
1375
+ // "feeCoinId": "ETH",
1376
+ // "feeCoinName": "ETH",
1377
+ // "fee": "0.0000012"
1378
+ // },
1379
+ // "feeCoinId": "ETH",
1380
+ // "feeAmount": "0.0000012",
1381
+ // "makerRebate": "0"
1382
+ // },
1383
+ // ...
1384
+ // ]
1385
+ //
1386
+ }
1387
+ else if (marketType === 'swap') {
1388
+ if (symbol === undefined) {
1389
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires a symbol argument for swap markets');
1390
+ }
1391
+ request['symbol'] = market['id'];
1392
+ if (accountId !== undefined) {
1393
+ request['subAccountId'] = accountId;
1394
+ response = await this.privateGetApiV1FuturesSubAccountUserTrades(this.extend(request, params));
1395
+ }
1396
+ else {
1397
+ response = await this.privateGetApiV1FuturesUserTrades(this.extend(request, params));
1398
+ //
1399
+ // [
1400
+ // {
1401
+ // "time": "1722429951648",
1402
+ // "tradeId": "1742263144691139328",
1403
+ // "orderId": "1742263144028363776",
1404
+ // "symbol": "ETHUSDT-PERPETUAL",
1405
+ // "price": "3327.54",
1406
+ // "quantity": "4",
1407
+ // "commissionAsset": "USDT",
1408
+ // "commission": "0.00798609",
1409
+ // "makerRebate": "0",
1410
+ // "type": "LIMIT",
1411
+ // "side": "BUY_OPEN",
1412
+ // "realizedPnl": "0",
1413
+ // "isMarker": false
1414
+ // }
1415
+ // ]
1416
+ //
1417
+ }
1418
+ }
1419
+ else {
1420
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + marketType + ' type of markets');
1421
+ }
1422
+ return this.parseTrades(response, market, since, limit);
1423
+ }
1424
+ parseTrade(trade, market = undefined) {
1425
+ //
1426
+ // fetchTrades
1427
+ //
1428
+ // {
1429
+ // "t": 1721682745779,
1430
+ // "p": "67835.99",
1431
+ // "q": "0.00017",
1432
+ // "ibm": true
1433
+ // }
1434
+ //
1435
+ // fetchMyTrades spot
1436
+ //
1437
+ // {
1438
+ // "id": "1739352552862964736",
1439
+ // "clientOrderId": "1722082982086472",
1440
+ // "ticketId": "1739352552795029504",
1441
+ // "symbol": "ETHUSDT",
1442
+ // "symbolName": "ETHUSDT",
1443
+ // "orderId": "1739352552762301440",
1444
+ // "matchOrderId": "0",
1445
+ // "price": "3289.96",
1446
+ // "qty": "0.001",
1447
+ // "commission": "0.0000012",
1448
+ // "commissionAsset": "ETH",
1449
+ // "time": "1722082982097",
1450
+ // "isBuyer": true,
1451
+ // "isMaker": false,
1452
+ // "fee": {
1453
+ // "feeCoinId": "ETH",
1454
+ // "feeCoinName": "ETH",
1455
+ // "fee": "0.0000012"
1456
+ // },
1457
+ // "feeCoinId": "ETH",
1458
+ // "feeAmount": "0.0000012",
1459
+ // "makerRebate": "0"
1460
+ // }
1461
+ //
1462
+ // fetchMyTrades swap
1463
+ // {
1464
+ // "time": "1722429951648",
1465
+ // "tradeId": "1742263144691139328",
1466
+ // "orderId": "1742263144028363776",
1467
+ // "symbol": "ETHUSDT-PERPETUAL",
1468
+ // "price": "3327.54",
1469
+ // "quantity": "4",
1470
+ // "commissionAsset": "USDT",
1471
+ // "commission": "0.00798609",
1472
+ // "makerRebate": "0",
1473
+ // "type": "LIMIT",
1474
+ // "side": "BUY_OPEN",
1475
+ // "realizedPnl": "0",
1476
+ // "isMarker": false
1477
+ // }
1478
+ const timestamp = this.safeInteger2(trade, 't', 'time');
1479
+ const marketId = this.safeString(trade, 'symbol');
1480
+ market = this.safeMarket(marketId, market);
1481
+ let side = this.safeStringLower(trade, 'side'); // swap trades have side param
1482
+ if (side !== undefined) {
1483
+ side = this.safeString(side.split('_'), 0);
1484
+ }
1485
+ const isBuyer = this.safeBool(trade, 'isBuyer');
1486
+ if (isBuyer !== undefined) {
1487
+ side = isBuyer ? 'buy' : 'sell';
1488
+ }
1489
+ let takerOrMaker = undefined;
1490
+ const isMaker = this.safeBoolN(trade, ['isMaker', 'isMarker']);
1491
+ if (isMaker !== undefined) {
1492
+ takerOrMaker = isMaker ? 'maker' : 'taker';
1493
+ }
1494
+ const isBuyerMaker = this.safeBool(trade, 'ibm');
1495
+ // if public trade
1496
+ if (isBuyerMaker !== undefined) {
1497
+ takerOrMaker = 'taker';
1498
+ side = isBuyerMaker ? 'sell' : 'buy';
1499
+ }
1500
+ let feeCost = this.safeString(trade, 'commission');
1501
+ let feeCurrncyId = this.safeString(trade, 'commissionAsset');
1502
+ const feeInfo = this.safeDict(trade, 'fee');
1503
+ let fee = undefined;
1504
+ if (feeInfo !== undefined) {
1505
+ feeCost = this.safeString(feeInfo, 'fee');
1506
+ feeCurrncyId = this.safeString(feeInfo, 'feeCoinId');
1507
+ }
1508
+ if (feeCost !== undefined) {
1509
+ fee = {
1510
+ 'cost': this.parseNumber(feeCost),
1511
+ 'currency': this.safeCurrencyCode(feeCurrncyId),
1512
+ };
1513
+ }
1514
+ return this.safeTrade({
1515
+ 'id': this.safeString2(trade, 'id', 'tradeId'),
1516
+ 'timestamp': timestamp,
1517
+ 'datetime': this.iso8601(timestamp),
1518
+ 'symbol': market['symbol'],
1519
+ 'side': side,
1520
+ 'price': this.safeString2(trade, 'p', 'price'),
1521
+ 'amount': this.safeStringN(trade, ['q', 'qty', 'quantity']),
1522
+ 'cost': undefined,
1523
+ 'takerOrMaker': takerOrMaker,
1524
+ 'type': undefined,
1525
+ 'order': this.safeString(trade, 'orderId'),
1526
+ 'fee': fee,
1527
+ 'info': trade,
1528
+ }, market);
1529
+ }
1530
+ /**
1531
+ * @method
1532
+ * @name hashkey#fetchOHLCV
1533
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-kline
1534
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1535
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1536
+ * @param {string} timeframe the length of time each candle represents
1537
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1538
+ * @param {int} [limit] the maximum amount of candles to fetch
1539
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1540
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch
1541
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1542
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1543
+ */
1544
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1545
+ const methodName = 'fetchOHLCV';
1546
+ await this.loadMarkets();
1547
+ let paginate = false;
1548
+ [paginate, params] = this.handleOptionAndParams(params, methodName, 'paginate');
1549
+ if (paginate) {
1550
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
1551
+ }
1552
+ const market = this.market(symbol);
1553
+ timeframe = this.safeString(this.timeframes, timeframe, timeframe);
1554
+ const request = {
1555
+ 'symbol': market['id'],
1556
+ 'interval': timeframe,
1557
+ };
1558
+ if (since !== undefined) {
1559
+ request['startTime'] = since;
1560
+ }
1561
+ if (limit !== undefined) {
1562
+ request['limit'] = limit;
1563
+ }
1564
+ let until = undefined;
1565
+ [until, params] = this.handleOptionAndParams(params, methodName, 'until');
1566
+ if (until !== undefined) {
1567
+ request['endTime'] = until;
1568
+ }
1569
+ const response = await this.publicGetQuoteV1Klines(this.extend(request, params));
1570
+ //
1571
+ // [
1572
+ // [
1573
+ // 1721684280000,
1574
+ // "67832.49",
1575
+ // "67862.5",
1576
+ // "67832.49",
1577
+ // "67861.44",
1578
+ // "0.01122",0,
1579
+ // "761.2763533",68,
1580
+ // "0.00561",
1581
+ // "380.640643"
1582
+ // ],
1583
+ // ...
1584
+ // ]
1585
+ //
1586
+ return this.parseOHLCVs(response, market, timeframe, since, limit);
1587
+ }
1588
+ parseOHLCV(ohlcv, market = undefined) {
1589
+ //
1590
+ // [
1591
+ // 1721684280000,
1592
+ // "67832.49",
1593
+ // "67862.5",
1594
+ // "67832.49",
1595
+ // "67861.44",
1596
+ // "0.01122",0,
1597
+ // "761.2763533",68,
1598
+ // "0.00561",
1599
+ // "380.640643"
1600
+ // ]
1601
+ //
1602
+ return [
1603
+ this.safeInteger(ohlcv, 0),
1604
+ this.safeNumber(ohlcv, 1),
1605
+ this.safeNumber(ohlcv, 2),
1606
+ this.safeNumber(ohlcv, 3),
1607
+ this.safeNumber(ohlcv, 4),
1608
+ this.safeNumber(ohlcv, 5),
1609
+ ];
1610
+ }
1611
+ /**
1612
+ * @method
1613
+ * @name hashkey#fetchTicker
1614
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1615
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-24hr-ticker-price-change
1616
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1617
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1618
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1619
+ */
1620
+ async fetchTicker(symbol, params = {}) {
1621
+ await this.loadMarkets();
1622
+ const market = this.market(symbol);
1623
+ const request = {
1624
+ 'symbol': market['id'],
1625
+ };
1626
+ const response = await this.publicGetQuoteV1Ticker24hr(this.extend(request, params));
1627
+ //
1628
+ // [
1629
+ // {
1630
+ // "t": 1721685896846,
1631
+ // "s": "BTCUSDT-PERPETUAL",
1632
+ // "c": "67756.7",
1633
+ // "h": "68479.9",
1634
+ // "l": "66594.3",
1635
+ // "o": "68279.7",
1636
+ // "b": "67756.6",
1637
+ // "a": "67756.7",
1638
+ // "v": "1604722",
1639
+ // "qv": "108827258.7761"
1640
+ // }
1641
+ // ]
1642
+ //
1643
+ const ticker = this.safeDict(response, 0, {});
1644
+ return this.parseTicker(ticker, market);
1645
+ }
1646
+ /**
1647
+ * @method
1648
+ * @name hashkey#fetchTickers
1649
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1650
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-24hr-ticker-price-change
1651
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1652
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1653
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1654
+ */
1655
+ async fetchTickers(symbols = undefined, params = {}) {
1656
+ await this.loadMarkets();
1657
+ symbols = this.marketSymbols(symbols);
1658
+ const response = await this.publicGetQuoteV1Ticker24hr(params);
1659
+ return this.parseTickers(response, symbols);
1660
+ }
1661
+ parseTicker(ticker, market = undefined) {
1662
+ //
1663
+ // {
1664
+ // "t": 1721685896846,
1665
+ // "s": "BTCUSDT-PERPETUAL",
1666
+ // "c": "67756.7",
1667
+ // "h": "68479.9",
1668
+ // "l": "66594.3",
1669
+ // "o": "68279.7",
1670
+ // "b": "67756.6",
1671
+ // "a": "67756.7",
1672
+ // "v": "1604722",
1673
+ // "qv": "108827258.7761"
1674
+ // }
1675
+ //
1676
+ const timestamp = this.safeInteger(ticker, 't');
1677
+ const marketId = this.safeString(ticker, 's');
1678
+ market = this.safeMarket(marketId, market);
1679
+ const symbol = market['symbol'];
1680
+ const last = this.safeString(ticker, 'c');
1681
+ return this.safeTicker({
1682
+ 'symbol': symbol,
1683
+ 'timestamp': timestamp,
1684
+ 'datetime': this.iso8601(timestamp),
1685
+ 'high': this.safeString(ticker, 'h'),
1686
+ 'low': this.safeString(ticker, 'l'),
1687
+ 'bid': this.safeString(ticker, 'b'),
1688
+ 'bidVolume': undefined,
1689
+ 'ask': this.safeString(ticker, 'a'),
1690
+ 'askVolume': undefined,
1691
+ 'vwap': undefined,
1692
+ 'open': this.safeString(ticker, 'o'),
1693
+ 'close': last,
1694
+ 'last': last,
1695
+ 'previousClose': undefined,
1696
+ 'change': undefined,
1697
+ 'percentage': undefined,
1698
+ 'average': undefined,
1699
+ 'baseVolume': this.safeString(ticker, 'v'),
1700
+ 'quoteVolume': this.safeString(ticker, 'qv'),
1701
+ 'info': ticker,
1702
+ }, market);
1703
+ }
1704
+ /**
1705
+ * @method
1706
+ * @name hashkey#fetchLastPrices
1707
+ * @description fetches the last price for multiple markets
1708
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-symbol-price-ticker
1709
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the last prices
1710
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1711
+ * @param {string} [params.symbol] the id of the market to fetch last price for
1712
+ * @returns {object} a dictionary of lastprices structures
1713
+ */
1714
+ async fetchLastPrices(symbols = undefined, params = {}) {
1715
+ await this.loadMarkets();
1716
+ symbols = this.marketSymbols(symbols);
1717
+ const request = {};
1718
+ const response = await this.publicGetQuoteV1TickerPrice(this.extend(request, params));
1719
+ //
1720
+ // [
1721
+ // {
1722
+ // "s": "BTCUSDT-PERPETUAL",
1723
+ // "p": "64871"
1724
+ // },
1725
+ // ...
1726
+ // ]
1727
+ //
1728
+ return this.parseLastPrices(response, symbols);
1729
+ }
1730
+ parseLastPrice(entry, market = undefined) {
1731
+ const marketId = this.safeString(entry, 's');
1732
+ market = this.safeMarket(marketId, market);
1733
+ return {
1734
+ 'symbol': market['symbol'],
1735
+ 'timestamp': undefined,
1736
+ 'datetime': undefined,
1737
+ 'price': this.safeNumber(entry, 'p'),
1738
+ 'side': undefined,
1739
+ 'info': entry,
1740
+ };
1741
+ }
1742
+ /**
1743
+ * @method
1744
+ * @name hashkey#fetchBalance
1745
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1746
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-account-information
1747
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1748
+ * @param {string} [params.accountId] account ID, for Master Key only
1749
+ * @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch balance for (default 'spot')
1750
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1751
+ */
1752
+ async fetchBalance(params = {}) {
1753
+ await this.loadMarkets();
1754
+ const request = {};
1755
+ const methodName = 'fetchBalance';
1756
+ let marketType = 'spot';
1757
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, undefined, params, marketType);
1758
+ if (marketType === 'swap') {
1759
+ const response = await this.privateGetApiV1FuturesBalance(params);
1760
+ //
1761
+ // [
1762
+ // {
1763
+ // "balance": "30.63364672",
1764
+ // "availableBalance": "28.85635534",
1765
+ // "positionMargin": "4.3421",
1766
+ // "orderMargin": "0",
1767
+ // "asset": "USDT",
1768
+ // "crossUnRealizedPnl": "2.5649"
1769
+ // }
1770
+ // ]
1771
+ //
1772
+ const balance = this.safeDict(response, 0, {});
1773
+ return this.parseSwapBalance(balance);
1774
+ }
1775
+ else if (marketType === 'spot') {
1776
+ const response = await this.privateGetApiV1Account(this.extend(request, params));
1777
+ //
1778
+ // {
1779
+ // "balances": [
1780
+ // {
1781
+ // "asset":"USDT",
1782
+ // "assetId":"USDT",
1783
+ // "assetName":"USDT",
1784
+ // "total":"40",
1785
+ // "free":"40",
1786
+ // "locked":"0"
1787
+ // },
1788
+ // ...
1789
+ // ],
1790
+ // "userId": "1732885739572845312"
1791
+ // }
1792
+ //
1793
+ return this.parseBalance(response);
1794
+ }
1795
+ else {
1796
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + marketType + ' type of markets');
1797
+ }
1798
+ }
1799
+ parseBalance(balance) {
1800
+ //
1801
+ // {
1802
+ // "balances": [
1803
+ // {
1804
+ // "asset":"USDT",
1805
+ // "assetId":"USDT",
1806
+ // "assetName":"USDT",
1807
+ // "total":"40",
1808
+ // "free":"40",
1809
+ // "locked":"0"
1810
+ // },
1811
+ // ...
1812
+ // ],
1813
+ // "userId": "1732885739572845312"
1814
+ // }
1815
+ //
1816
+ const result = {
1817
+ 'info': balance,
1818
+ };
1819
+ const balances = this.safeList(balance, 'balances', []);
1820
+ for (let i = 0; i < balances.length; i++) {
1821
+ const balanceEntry = balances[i];
1822
+ const currencyId = this.safeString(balanceEntry, 'asset');
1823
+ const code = this.safeCurrencyCode(currencyId);
1824
+ const account = this.account();
1825
+ account['total'] = this.safeString(balanceEntry, 'total');
1826
+ account['free'] = this.safeString(balanceEntry, 'free');
1827
+ account['used'] = this.safeString(balanceEntry, 'locked');
1828
+ result[code] = account;
1829
+ }
1830
+ return this.safeBalance(result);
1831
+ }
1832
+ parseSwapBalance(balance) {
1833
+ //
1834
+ // {
1835
+ // "balance": "30.63364672",
1836
+ // "availableBalance": "28.85635534",
1837
+ // "positionMargin": "4.3421",
1838
+ // "orderMargin": "0",
1839
+ // "asset": "USDT",
1840
+ // "crossUnRealizedPnl": "2.5649"
1841
+ // }
1842
+ //
1843
+ const currencyId = this.safeString(balance, 'asset');
1844
+ const code = this.safeCurrencyCode(currencyId);
1845
+ const account = this.account();
1846
+ account['total'] = this.safeString(balance, 'balance');
1847
+ const positionMargin = this.safeString(balance, 'positionMargin');
1848
+ const orderMargin = this.safeString(balance, 'orderMargin');
1849
+ account['used'] = Precise.stringAdd(positionMargin, orderMargin);
1850
+ const result = {
1851
+ 'info': balance,
1852
+ };
1853
+ result[code] = account;
1854
+ return this.safeBalance(result);
1855
+ }
1856
+ /**
1857
+ * @method
1858
+ * @name hashkey#fetchDepositAddress
1859
+ * @description fetch the deposit address for a currency associated with this account
1860
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-deposit-address
1861
+ * @param {string} code unified currency code (default is 'USDT')
1862
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1863
+ * @param {string} [params.network] network for fetch deposit address (default is 'ETH')
1864
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1865
+ */
1866
+ async fetchDepositAddress(code, params = {}) {
1867
+ await this.loadMarkets();
1868
+ const currency = this.currency(code);
1869
+ const request = {
1870
+ 'coin': currency['id'],
1871
+ };
1872
+ let networkCode = undefined;
1873
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
1874
+ if (networkCode === undefined) {
1875
+ networkCode = this.defaultNetworkCode(code);
1876
+ }
1877
+ request['chainType'] = this.networkCodeToId(networkCode, code);
1878
+ const response = await this.privateGetApiV1AccountDepositAddress(this.extend(request, params));
1879
+ //
1880
+ // {
1881
+ // "canDeposit": true,
1882
+ // "address": "0x61AAd7F763e2C7fF1CC996918740F67f9dC8BF4e",
1883
+ // "addressExt": "",
1884
+ // "minQuantity": "1",
1885
+ // "needAddressTag": false,
1886
+ // "requiredConfirmTimes": 64,
1887
+ // "canWithdrawConfirmTimes": 64,
1888
+ // "coinType": "ERC20_TOKEN"
1889
+ // }
1890
+ //
1891
+ const depositAddress = this.parseDepositAddress(response, currency);
1892
+ depositAddress['network'] = networkCode;
1893
+ return depositAddress;
1894
+ }
1895
+ parseDepositAddress(depositAddress, currency = undefined) {
1896
+ //
1897
+ // {
1898
+ // "canDeposit": true,
1899
+ // "address": "0x61AAd7F763e2C7fF1CC996918740F67f9dC8BF4e",
1900
+ // "addressExt": "",
1901
+ // "minQuantity": "1",
1902
+ // "needAddressTag": false,
1903
+ // "requiredConfirmTimes": 64,
1904
+ // "canWithdrawConfirmTimes": 64,
1905
+ // "coinType": "ERC20_TOKEN"
1906
+ // }
1907
+ //
1908
+ const address = this.safeString(depositAddress, 'address');
1909
+ this.checkAddress(address);
1910
+ let tag = this.safeString(depositAddress, 'addressExt');
1911
+ if (tag === '') {
1912
+ tag = undefined;
1913
+ }
1914
+ return {
1915
+ 'info': depositAddress,
1916
+ 'currency': currency['code'],
1917
+ 'network': undefined,
1918
+ 'address': address,
1919
+ 'tag': tag,
1920
+ };
1921
+ }
1922
+ /**
1923
+ * @method
1924
+ * @name hashkey#fetchDeposits
1925
+ * @description fetch all deposits made to an account
1926
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-deposit-history
1927
+ * @param {string} code unified currency code of the currency transferred
1928
+ * @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
1929
+ * @param {int} [limit] the maximum number of transfer structures to retrieve (default 50, max 200)
1930
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1931
+ * @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
1932
+ * @param {int} [params.fromId] starting ID (To be released)
1933
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1934
+ */
1935
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1936
+ const methodName = 'fetchDeposits';
1937
+ await this.loadMarkets();
1938
+ const request = {};
1939
+ let currency = undefined;
1940
+ if (code !== undefined) {
1941
+ currency = this.currency(code);
1942
+ request['coin'] = currency['id'];
1943
+ }
1944
+ if (since !== undefined) {
1945
+ request['startTime'] = since;
1946
+ }
1947
+ if (limit !== undefined) {
1948
+ request['limit'] = limit;
1949
+ }
1950
+ let until = undefined;
1951
+ [until, params] = this.handleOptionAndParams(params, methodName, 'until');
1952
+ if (until !== undefined) {
1953
+ request['endTime'] = until;
1954
+ }
1955
+ const response = await this.privateGetApiV1AccountDepositOrders(this.extend(request, params));
1956
+ //
1957
+ // [
1958
+ // {
1959
+ // "time": "1721641082163",
1960
+ // "coin": "TRXUSDT",
1961
+ // "coinName": "TRXUSDT",
1962
+ // "address": "TBA6CypYJizwA9XdC7Ubgc5F1bxrQ7SqPt",
1963
+ // "quantity": "86.00000000000000000000",
1964
+ // "status": 4,
1965
+ // "statusCode": "4",
1966
+ // "txId": "0970c14da4d7412295fa7b21c03a08da319e746a0d59ef14462a74183d118da4"
1967
+ // }
1968
+ // ]
1969
+ //
1970
+ return this.parseTransactions(response, currency, since, limit, { 'type': 'deposit' });
1971
+ }
1972
+ /**
1973
+ * @method
1974
+ * @name hashkey#fetchWithdrawals
1975
+ * @description fetch all withdrawals made from an account
1976
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/withdrawal-records
1977
+ * @param {string} code unified currency code of the currency transferred
1978
+ * @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
1979
+ * @param {int} [limit] the maximum number of transfer structures to retrieve (default 50, max 200)
1980
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1981
+ * @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
1982
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1983
+ */
1984
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1985
+ const methodName = 'fetchWithdrawals';
1986
+ await this.loadMarkets();
1987
+ const request = {};
1988
+ let currency = undefined;
1989
+ if (code !== undefined) {
1990
+ currency = this.currency(code);
1991
+ request['coin'] = currency['id'];
1992
+ }
1993
+ if (since !== undefined) {
1994
+ request['startTime'] = since;
1995
+ }
1996
+ if (limit !== undefined) {
1997
+ request['limit'] = limit;
1998
+ }
1999
+ let until = undefined;
2000
+ [until, params] = this.handleOptionAndParams(params, methodName, 'until');
2001
+ if (until !== undefined) {
2002
+ request['endTime'] = until;
2003
+ }
2004
+ const response = await this.privateGetApiV1AccountWithdrawOrders(this.extend(request, params));
2005
+ //
2006
+ // [
2007
+ // {
2008
+ // "time": "1723545505366",
2009
+ // "id": "W611267400947572736",
2010
+ // "coin": "USDT",
2011
+ // "coinId": "USDT",
2012
+ // "coinName": "USDT",
2013
+ // "address": "TQbkBMnWnJNGTAUpFS4kvv4NRLzUAnGAes",
2014
+ // "quantity": "2.00000000",
2015
+ // "arriveQuantity": "2.00000000",
2016
+ // "txId": "f83f94e7d2e81fbec98c66c25d6615872cc2d426145629b6cf22e5e0a0753715",
2017
+ // "addressUrl": "TQbkBMnWnJNGTAUpFS4kvv4NRLzUAnGAes",
2018
+ // "feeCoinId": "USDT",
2019
+ // "feeCoinName": "USDT",
2020
+ // "fee": "1.00000000",
2021
+ // "remark": "",
2022
+ // "platform": ""
2023
+ // }
2024
+ // ]
2025
+ //
2026
+ return this.parseTransactions(response, currency, since, limit, { 'type': 'withdrawal' });
2027
+ }
2028
+ /**
2029
+ * @method
2030
+ * @name hashkey#withdraw
2031
+ * @description make a withdrawal
2032
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/withdraw
2033
+ * @param {string} code unified currency code
2034
+ * @param {float} amount the amount to withdraw
2035
+ * @param {string} address the address to withdraw to
2036
+ * @param {string} tag
2037
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2038
+ * @param {string} [params.network] network for withdraw
2039
+ * @param {string} [params.clientOrderId] client order id
2040
+ * @param {string} [params.platform] the platform to withdraw to (hashkey, HashKey HK)
2041
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2042
+ */
2043
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
2044
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2045
+ await this.loadMarkets();
2046
+ const currency = this.currency(code);
2047
+ const request = {
2048
+ 'coin': currency['id'],
2049
+ 'address': address,
2050
+ 'quantity': amount,
2051
+ };
2052
+ if (tag !== undefined) {
2053
+ request['addressExt'] = tag;
2054
+ }
2055
+ let networkCode = undefined;
2056
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
2057
+ if (networkCode !== undefined) {
2058
+ request['chainType'] = this.networkCodeToId(networkCode);
2059
+ }
2060
+ const response = await this.privatePostApiV1AccountWithdraw(this.extend(request, params));
2061
+ //
2062
+ // {
2063
+ // "success": true,
2064
+ // "id": "0",
2065
+ // "orderId": "W611267400947572736",
2066
+ // "accountId": "1732885739589466115"
2067
+ // }
2068
+ //
2069
+ return this.parseTransaction(response, currency);
2070
+ }
2071
+ parseTransaction(transaction, currency = undefined) {
2072
+ //
2073
+ // fetchDeposits
2074
+ // {
2075
+ // "time": "1721641082163",
2076
+ // "coin": "TRXUSDT", // todo how to parse it?
2077
+ // "coinName": "TRXUSDT",
2078
+ // "address": "TBA6CypYJizwA9XdC7Ubgc5F1bxrQ7SqPt",
2079
+ // "quantity": "86.00000000000000000000",
2080
+ // "status": 4,
2081
+ // "statusCode": "4",
2082
+ // "txId": "0970c14da4d7412295fa7b21c03a08da319e746a0d59ef14462a74183d118da4"
2083
+ // }
2084
+ //
2085
+ // fetchWithdrawals
2086
+ // {
2087
+ // "time": "1723545505366",
2088
+ // "id": "W611267400947572736",
2089
+ // "coin": "USDT",
2090
+ // "coinId": "USDT",
2091
+ // "coinName": "USDT",
2092
+ // "address": "TQbkBMnWnJNGTAUpFS4kvv4NRLzUAnGAes",
2093
+ // "quantity": "2.00000000",
2094
+ // "arriveQuantity": "2.00000000",
2095
+ // "txId": "f83f94e7d2e81fbec98c66c25d6615872cc2d426145629b6cf22e5e0a0753715",
2096
+ // "addressUrl": "TQbkBMnWnJNGTAUpFS4kvv4NRLzUAnGAes",
2097
+ // "feeCoinId": "USDT",
2098
+ // "feeCoinName": "USDT",
2099
+ // "fee": "1.00000000",
2100
+ // "remark": "",
2101
+ // "platform": ""
2102
+ // }
2103
+ //
2104
+ // withdraw
2105
+ // {
2106
+ // "success": true,
2107
+ // "id": "0",
2108
+ // "orderId": "W611267400947572736",
2109
+ // "accountId": "1732885739589466115"
2110
+ // }
2111
+ //
2112
+ const id = this.safeString2(transaction, 'id', 'orderId');
2113
+ const address = this.safeString(transaction, 'address');
2114
+ let status = this.safeString(transaction, 'status'); // for fetchDeposits
2115
+ if (status === undefined) {
2116
+ const success = this.safeBool(transaction, 'success', false); // for withdraw
2117
+ if (success) {
2118
+ status = 'ok';
2119
+ }
2120
+ else {
2121
+ const addressUrl = this.safeString(transaction, 'addressUrl'); // for fetchWithdrawals
2122
+ if (addressUrl !== undefined) {
2123
+ status = 'ok';
2124
+ }
2125
+ }
2126
+ }
2127
+ const txid = this.safeString(transaction, 'txId');
2128
+ const coin = this.safeString(transaction, 'coin');
2129
+ const code = this.safeCurrencyCode(coin, currency);
2130
+ const timestamp = this.safeInteger(transaction, 'time');
2131
+ const amount = this.safeNumber(transaction, 'quantity');
2132
+ const feeCost = this.safeNumber(transaction, 'fee');
2133
+ let fee = undefined;
2134
+ if (feeCost !== undefined) {
2135
+ fee = {
2136
+ 'cost': feeCost,
2137
+ 'currency': code,
2138
+ };
2139
+ }
2140
+ return {
2141
+ 'info': transaction,
2142
+ 'id': id,
2143
+ 'txid': txid,
2144
+ 'timestamp': timestamp,
2145
+ 'datetime': this.iso8601(timestamp),
2146
+ 'network': undefined,
2147
+ 'address': address,
2148
+ 'addressTo': undefined,
2149
+ 'addressFrom': undefined,
2150
+ 'tag': undefined,
2151
+ 'tagTo': undefined,
2152
+ 'tagFrom': undefined,
2153
+ 'type': undefined,
2154
+ 'amount': amount,
2155
+ 'currency': code,
2156
+ 'status': this.parseTransactionStatus(status),
2157
+ 'updated': undefined,
2158
+ 'internal': undefined,
2159
+ 'comment': undefined,
2160
+ 'fee': fee,
2161
+ };
2162
+ }
2163
+ parseTransactionStatus(status) {
2164
+ const statuses = {
2165
+ '1': 'pending',
2166
+ '2': 'pending',
2167
+ '3': 'failed',
2168
+ '4': 'ok',
2169
+ '5': 'pending',
2170
+ '6': 'ok',
2171
+ '7': 'failed',
2172
+ '8': 'cancelled',
2173
+ '9': 'failed',
2174
+ '10': 'failed',
2175
+ 'successful': 'ok',
2176
+ 'success': 'ok',
2177
+ };
2178
+ return this.safeString(statuses, status, status);
2179
+ }
2180
+ /**
2181
+ * @method
2182
+ * @name hashkey#transfer
2183
+ * @description transfer currency internally between wallets on the same account
2184
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/new-account-transfer
2185
+ * @param {string} code unified currency code
2186
+ * @param {float} amount amount to transfer
2187
+ * @param {string} fromAccount account id to transfer from
2188
+ * @param {string} toAccount account id to transfer to
2189
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2190
+ * @param {string} [params.clientOrderId] a unique id for the transfer
2191
+ * @param {string} [params.remark] a note for the transfer
2192
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2193
+ */
2194
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
2195
+ await this.loadMarkets();
2196
+ const currency = this.currency(code);
2197
+ const request = {
2198
+ 'coin': currency['id'],
2199
+ 'quantity': this.currencyToPrecision(code, amount),
2200
+ 'fromAccountId': fromAccount,
2201
+ 'toAccountId': toAccount,
2202
+ };
2203
+ const response = await this.privatePostApiV1AccountAssetTransfer(this.extend(request, params));
2204
+ //
2205
+ // {
2206
+ // "success": true,
2207
+ // "timestamp": 1722260230773,
2208
+ // "clientOrderId": "",
2209
+ // "orderId": "1740839420695806720"
2210
+ // }
2211
+ //
2212
+ return this.parseTransfer(response, currency);
2213
+ }
2214
+ parseTransfer(transfer, currency = undefined) {
2215
+ const timestamp = this.safeInteger(transfer, 'timestamp');
2216
+ const currencyId = this.safeString(currency, 'id');
2217
+ let status = undefined;
2218
+ const success = this.safeBool(transfer, 'success', false);
2219
+ if (success) {
2220
+ status = 'ok';
2221
+ }
2222
+ return {
2223
+ 'id': this.safeString(transfer, 'orderId'),
2224
+ 'timestamp': timestamp,
2225
+ 'datetime': this.iso8601(timestamp),
2226
+ 'currency': this.safeCurrencyCode(currencyId, currency),
2227
+ 'amount': undefined,
2228
+ 'fromAccount': undefined,
2229
+ 'toAccount': undefined,
2230
+ 'status': status,
2231
+ 'info': transfer,
2232
+ };
2233
+ }
2234
+ /**
2235
+ * @method
2236
+ * @name hashkey#fetchAccounts
2237
+ * @description fetch all the accounts associated with a profile
2238
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/query-sub-account
2239
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2240
+ * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
2241
+ */
2242
+ async fetchAccounts(params = {}) {
2243
+ await this.loadMarkets();
2244
+ const response = await this.privateGetApiV1AccountType(params);
2245
+ //
2246
+ // [
2247
+ // {
2248
+ // "accountId": "1732885739589466112",
2249
+ // "accountLabel": "Main Trading Account",
2250
+ // "accountType": 1,
2251
+ // "accountIndex": 0
2252
+ // },
2253
+ // ...
2254
+ // ]
2255
+ //
2256
+ return this.parseAccounts(response, params);
2257
+ }
2258
+ parseAccount(account) {
2259
+ const accountLabel = this.safeString(account, 'accountLabel');
2260
+ let label = '';
2261
+ if (accountLabel === 'Main Trading Account' || accountLabel === 'Main Future Account') {
2262
+ label = 'main';
2263
+ }
2264
+ else if (accountLabel === 'Sub Main Trading Account' || accountLabel === 'Sub Main Future Account') {
2265
+ label = 'sub';
2266
+ }
2267
+ const accountType = this.parseAccountType(this.safeString(account, 'accountType'));
2268
+ const type = label + ' ' + accountType;
2269
+ return {
2270
+ 'id': this.safeString(account, 'accountId'),
2271
+ 'type': type,
2272
+ 'code': undefined,
2273
+ 'info': account,
2274
+ };
2275
+ }
2276
+ parseAccountType(type) {
2277
+ const types = {
2278
+ '1': 'spot account',
2279
+ '3': 'swap account',
2280
+ '5': 'custody account',
2281
+ '6': 'fiat account',
2282
+ };
2283
+ return this.safeString(types, type, type);
2284
+ }
2285
+ encodeAccountType(type) {
2286
+ const types = {
2287
+ 'spot': '1',
2288
+ 'swap': '3',
2289
+ 'custody': '5',
2290
+ };
2291
+ return this.safeInteger(types, type, type);
2292
+ }
2293
+ encodeFlowType(type) {
2294
+ const types = {
2295
+ 'trade': '1',
2296
+ 'fee': '3',
2297
+ 'transfer': '51',
2298
+ 'deposit': '900',
2299
+ 'withdraw': '904',
2300
+ };
2301
+ return this.safeInteger(types, type, type);
2302
+ }
2303
+ /**
2304
+ * @method
2305
+ * @name hashkey#fetchLedger
2306
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2307
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-account-transaction-list
2308
+ * @param {string} [code] unified currency code, default is undefined (not used)
2309
+ * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2310
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2311
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2312
+ * @param {int} [params.until] the latest time in ms to fetch entries for
2313
+ * @param {int} [params.flowType] trade, fee, transfer, deposit, withdrawal
2314
+ * @param {int} [params.accountType] spot, swap, custody
2315
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
2316
+ */
2317
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2318
+ const methodName = 'fetchLedger';
2319
+ if (since === undefined) {
2320
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires a since argument');
2321
+ }
2322
+ let until = undefined;
2323
+ [until, params] = this.handleOptionAndParams(params, methodName, 'until');
2324
+ if (until === undefined) {
2325
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires an until argument');
2326
+ }
2327
+ await this.loadMarkets();
2328
+ const currency = this.currency(code);
2329
+ const request = {};
2330
+ request['startTime'] = since;
2331
+ if (limit !== undefined) {
2332
+ request['limit'] = limit;
2333
+ }
2334
+ request['endTime'] = until;
2335
+ let flowType = undefined;
2336
+ [flowType, params] = this.handleOptionAndParams(params, methodName, 'flowType');
2337
+ if (flowType !== undefined) {
2338
+ request['flowType'] = this.encodeFlowType(flowType);
2339
+ }
2340
+ let accountType = undefined;
2341
+ [accountType, params] = this.handleOptionAndParams(params, methodName, 'accountType');
2342
+ if (accountType !== undefined) {
2343
+ request['accountType'] = this.encodeAccountType(accountType);
2344
+ }
2345
+ const response = await this.privateGetApiV1AccountBalanceFlow(this.extend(request, params));
2346
+ //
2347
+ // [
2348
+ // {
2349
+ // "id": "1740844413612065537",
2350
+ // "accountId": "1732885739589466112",
2351
+ // "coin": "USDT",
2352
+ // "coinId": "USDT",
2353
+ // "coinName": "USDT",
2354
+ // "flowTypeValue": 51,
2355
+ // "flowType": "USER_ACCOUNT_TRANSFER",
2356
+ // "flowName": "",
2357
+ // "change": "-1",
2358
+ // "total": "8.015680088",
2359
+ // "created": "1722260825765"
2360
+ // },
2361
+ // ...
2362
+ // ]
2363
+ //
2364
+ return this.parseLedger(response, currency, since, limit);
2365
+ }
2366
+ parseLedgerEntryType(type) {
2367
+ const types = {
2368
+ '1': 'trade',
2369
+ '2': 'fee',
2370
+ '51': 'transfer',
2371
+ '900': 'deposit',
2372
+ '904': 'withdraw',
2373
+ };
2374
+ return this.safeString(types, type, type);
2375
+ }
2376
+ parseLedgerEntry(item, currency = undefined) {
2377
+ //
2378
+ // {
2379
+ // "id": "1740844413612065537",
2380
+ // "accountId": "1732885739589466112",
2381
+ // "coin": "USDT",
2382
+ // "coinId": "USDT",
2383
+ // "coinName": "USDT",
2384
+ // "flowTypeValue": 51,
2385
+ // "flowType": "USER_ACCOUNT_TRANSFER",
2386
+ // "flowName": "",
2387
+ // "change": "-1",
2388
+ // "total": "8.015680088",
2389
+ // "created": "1722260825765"
2390
+ // }
2391
+ //
2392
+ const id = this.safeString(item, 'id');
2393
+ const account = this.safeString(item, 'accountId');
2394
+ const timestamp = this.safeInteger(item, 'created');
2395
+ const type = this.parseLedgerEntryType(this.safeString(item, 'flowTypeValue'));
2396
+ const currencyId = this.safeString(item, 'coin');
2397
+ const code = this.safeCurrencyCode(currencyId, currency);
2398
+ currency = this.safeCurrency(currencyId, currency);
2399
+ const amountString = this.safeString(item, 'change');
2400
+ const amount = this.parseNumber(amountString);
2401
+ let direction = 'in';
2402
+ if (amountString.indexOf('-') >= 0) {
2403
+ direction = 'out';
2404
+ }
2405
+ const afterString = this.safeString(item, 'total');
2406
+ const after = this.parseNumber(afterString);
2407
+ const status = 'ok';
2408
+ return this.safeLedgerEntry({
2409
+ 'info': item,
2410
+ 'id': id,
2411
+ 'timestamp': timestamp,
2412
+ 'datetime': this.iso8601(timestamp),
2413
+ 'account': account,
2414
+ 'direction': direction,
2415
+ 'referenceId': undefined,
2416
+ 'referenceAccount': undefined,
2417
+ 'type': type,
2418
+ 'currency': code,
2419
+ 'symbol': undefined,
2420
+ 'amount': amount,
2421
+ 'before': undefined,
2422
+ 'after': after,
2423
+ 'status': status,
2424
+ 'fee': undefined,
2425
+ }, currency);
2426
+ }
2427
+ /**
2428
+ * @method
2429
+ * @name hashkey#createOrder
2430
+ * @description create a trade order
2431
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/test-new-order
2432
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/create-order
2433
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/create-new-futures-order
2434
+ * @param {string} symbol unified symbol of the market to create an order in
2435
+ * @param {string} type 'market' or 'limit' or 'LIMIT_MAKER' for spot, 'market' or 'limit' or 'STOP' for swap
2436
+ * @param {string} side 'buy' or 'sell'
2437
+ * @param {float} amount how much of you want to trade in units of the base currency
2438
+ * @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
2439
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2440
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
2441
+ * @param {boolean} [params.test] *spot markets only* whether to use the test endpoint or not, default is false
2442
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2443
+ * @param {string} [params.timeInForce] "GTC" or "IOC" or "PO" for spot, 'GTC' or 'FOK' or 'IOC' or 'LIMIT_MAKER' or 'PO' for swap
2444
+ * @param {string} [params.clientOrderId] a unique id for the order - is mandatory for swap
2445
+ * @param {float} [params.triggerPrice] *swap markets only* The price at which a trigger order is triggered at
2446
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2447
+ */
2448
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2449
+ await this.loadMarkets();
2450
+ const market = this.market(symbol);
2451
+ if (market['spot']) {
2452
+ return await this.createSpotOrder(symbol, type, side, amount, price, params);
2453
+ }
2454
+ else if (market['swap']) {
2455
+ return await this.createSwapOrder(symbol, type, side, amount, price, params);
2456
+ }
2457
+ else {
2458
+ throw new NotSupported(this.id + ' createOrder() is not supported for ' + market['type'] + ' type of markets');
2459
+ }
2460
+ }
2461
+ /**
2462
+ * @method
2463
+ * @name hashkey#createMarketBuyOrderWithCost
2464
+ * @description create a market buy order by providing the symbol and cost
2465
+ * @param {string} symbol unified symbol of the market to create an order in
2466
+ * @param {float} cost how much you want to trade in units of the quote currency
2467
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2468
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2469
+ */
2470
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
2471
+ await this.loadMarkets();
2472
+ const market = this.market(symbol);
2473
+ if (!market['spot']) {
2474
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() is supported for spot markets only');
2475
+ }
2476
+ const req = {
2477
+ 'cost': cost,
2478
+ };
2479
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, this.extend(req, params));
2480
+ }
2481
+ /**
2482
+ * @method
2483
+ * @name hashkey#createSpotOrder
2484
+ * @description create a trade order on spot market
2485
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/test-new-order
2486
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/create-order
2487
+ * @param {string} symbol unified symbol of the market to create an order in
2488
+ * @param {string} type 'market' or 'limit' or 'LIMIT_MAKER'
2489
+ * @param {string} side 'buy' or 'sell'
2490
+ * @param {float} amount how much of you want to trade in units of the base currency
2491
+ * @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
2492
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2493
+ * @param {float} [params.cost] *market buy only* the quote quantity that can be used as an alternative for the amount
2494
+ * @param {bool} [params.test] whether to use the test endpoint or not, default is false
2495
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2496
+ * @param {string} [params.timeInForce] 'GTC', 'IOC', or 'PO'
2497
+ * @param {string} [params.clientOrderId] a unique id for the order
2498
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2499
+ */
2500
+ async createSpotOrder(symbol, type, side, amount, price = undefined, params = {}) {
2501
+ const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
2502
+ if (triggerPrice !== undefined) {
2503
+ throw new NotSupported(this.id + ' trigger orders are not supported for spot markets');
2504
+ }
2505
+ await this.loadMarkets();
2506
+ const market = this.market(symbol);
2507
+ const isMarketBuy = (type === 'market') && (side === 'buy');
2508
+ const cost = this.safeString(params, 'cost');
2509
+ if ((!isMarketBuy) && (cost !== undefined)) {
2510
+ throw new NotSupported(this.id + ' createOrder() supports cost parameter for spot market buy orders only');
2511
+ }
2512
+ const request = this.createSpotOrderRequest(symbol, type, side, amount, price, params);
2513
+ let response = {};
2514
+ const test = this.safeBool(params, 'test');
2515
+ if (test) {
2516
+ params = this.omit(params, 'test');
2517
+ response = await this.privatePostApiV1SpotOrderTest(request);
2518
+ }
2519
+ else if (isMarketBuy && (cost === undefined)) {
2520
+ response = await this.privatePostApiV11SpotOrder(request); // the endpoint for market buy orders by amount
2521
+ //
2522
+ // {
2523
+ // "accountId": "1732885739589466112",
2524
+ // "symbol": "ETHUSDT",
2525
+ // "symbolName": "ETHUSDT",
2526
+ // "clientOrderId": "1722005792096557",
2527
+ // "orderId": "1738705036219839744",
2528
+ // "transactTime": "1722005792106",
2529
+ // "price": "0",
2530
+ // "origQty": "0.006",
2531
+ // "executedQty": "0.0059",
2532
+ // "status": "FILLED",
2533
+ // "timeInForce": "IOC",
2534
+ // "type": "MARKET",
2535
+ // "side": "BUY",
2536
+ // "reqAmount": "0",
2537
+ // "concentration": ""
2538
+ // }
2539
+ //
2540
+ }
2541
+ else {
2542
+ response = await this.privatePostApiV1SpotOrder(request); // the endpoint for market buy orders by cost and other orders
2543
+ //
2544
+ // market buy
2545
+ // {
2546
+ // "accountId": "1732885739589466112",
2547
+ // "symbol": "ETHUSDT",
2548
+ // "symbolName": "ETHUSDT",
2549
+ // "clientOrderId": "1722004623170558",
2550
+ // "orderId": "1738695230608169984",
2551
+ // "transactTime": "1722004623186",
2552
+ // "price": "0",
2553
+ // "origQty": "0",
2554
+ // "executedQty": "0.0061",
2555
+ // "status": "FILLED",
2556
+ // "timeInForce": "IOC",
2557
+ // "type": "MARKET",
2558
+ // "side": "BUY",
2559
+ // "reqAmount": "20",
2560
+ // "concentration": ""
2561
+ // }
2562
+ //
2563
+ // market sell
2564
+ // {
2565
+ // "accountId": "1732885739589466112",
2566
+ // "symbol": "ETHUSDT",
2567
+ // "symbolName": "ETHUSDT",
2568
+ // "clientOrderId": "1722005654516362",
2569
+ // "orderId": "1738703882140316928",
2570
+ // "transactTime": "1722005654529",
2571
+ // "price": "0",
2572
+ // "origQty": "0.006",
2573
+ // "executedQty": "0.006",
2574
+ // "status": "FILLED",
2575
+ // "timeInForce": "IOC",
2576
+ // "type": "MARKET",
2577
+ // "side": "SELL",
2578
+ // "reqAmount": "0",
2579
+ // "concentration": ""
2580
+ // }
2581
+ //
2582
+ // limit
2583
+ // {
2584
+ // "accountId": "1732885739589466112",
2585
+ // "symbol": "ETHUSDT",
2586
+ // "symbolName": "ETHUSDT",
2587
+ // "clientOrderId": "1722006209978370",
2588
+ // "orderId": "1738708541676585728",
2589
+ // "transactTime": "1722006209989",
2590
+ // "price": "5000",
2591
+ // "origQty": "0.005",
2592
+ // "executedQty": "0",
2593
+ // "status": "NEW",
2594
+ // "timeInForce": "GTC",
2595
+ // "type": "LIMIT_MAKER",
2596
+ // "side": "SELL",
2597
+ // "reqAmount": "0",
2598
+ // "concentration": ""
2599
+ // }
2600
+ //
2601
+ }
2602
+ return this.parseOrder(response, market);
2603
+ }
2604
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
2605
+ const market = this.market(symbol);
2606
+ if (market['spot']) {
2607
+ return this.createSpotOrderRequest(symbol, type, side, amount, price, params);
2608
+ }
2609
+ else if (market['swap']) {
2610
+ return this.createSwapOrderRequest(symbol, type, side, amount, price, params);
2611
+ }
2612
+ else {
2613
+ throw new NotSupported(this.id + ' ' + 'createOrderRequest() is not supported for ' + market['type'] + ' type of markets');
2614
+ }
2615
+ }
2616
+ createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
2617
+ /**
2618
+ * @method
2619
+ * @ignore
2620
+ * @name hashkey#createSpotOrderRequest
2621
+ * @description helper function to build request
2622
+ * @param {string} symbol unified symbol of the market to create an order in
2623
+ * @param {string} type 'market' or 'limit' or 'LIMIT_MAKER'
2624
+ * @param {string} side 'buy' or 'sell'
2625
+ * @param {float} amount how much of you want to trade in units of the base currency
2626
+ * @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
2627
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2628
+ * @param {float} [params.cost] *market buy only* the quote quantity that can be used as an alternative for the amount
2629
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2630
+ * @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
2631
+ * @param {string} [params.clientOrderId] a unique id for the order
2632
+ * @returns {object} request to be sent to the exchange
2633
+ */
2634
+ const market = this.market(symbol);
2635
+ type = type.toUpperCase();
2636
+ const request = {
2637
+ 'symbol': market['id'],
2638
+ 'side': side.toUpperCase(),
2639
+ 'type': type,
2640
+ };
2641
+ if (amount !== undefined) {
2642
+ request['quantity'] = this.amountToPrecision(symbol, amount);
2643
+ }
2644
+ let cost = undefined;
2645
+ [cost, params] = this.handleParamString(params, 'cost');
2646
+ if (cost !== undefined) {
2647
+ request['quantity'] = this.costToPrecision(symbol, cost);
2648
+ }
2649
+ if (price !== undefined) {
2650
+ request['price'] = this.priceToPrecision(symbol, price);
2651
+ }
2652
+ const isMarketOrder = type === 'MARKET';
2653
+ let postOnly = false;
2654
+ [postOnly, params] = this.handlePostOnly(isMarketOrder, type === 'LIMIT_MAKER', params);
2655
+ if (postOnly && (type === 'LIMIT')) {
2656
+ request['type'] = 'LIMIT_MAKER';
2657
+ }
2658
+ let clientOrderId = undefined;
2659
+ [clientOrderId, params] = this.handleParamString(params, 'clientOrderId');
2660
+ if (clientOrderId !== undefined) {
2661
+ params['newClientOrderId'] = clientOrderId;
2662
+ }
2663
+ return this.extend(request, params);
2664
+ }
2665
+ createSwapOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
2666
+ /**
2667
+ * @method
2668
+ * @ignore
2669
+ * @name hashkey#createSwapOrderRequest
2670
+ * @description helper function to build request
2671
+ * @param {string} symbol unified symbol of the market to create an order in
2672
+ * @param {string} type 'market' or 'limit' or 'STOP'
2673
+ * @param {string} side 'buy' or 'sell'
2674
+ * @param {float} amount how much of you want to trade in units of the base currency
2675
+ * @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
2676
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2677
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2678
+ * @param {bool} [params.reduceOnly] true or false whether the order is reduce only
2679
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2680
+ * @param {string} [params.timeInForce] 'GTC', 'FOK', 'IOC', 'LIMIT_MAKER' or 'PO'
2681
+ * @param {string} [params.clientOrderId] a unique id for the order
2682
+ * @returns {object} request to be sent to the exchange
2683
+ */
2684
+ const market = this.market(symbol);
2685
+ const request = {
2686
+ 'symbol': market['id'],
2687
+ 'type': 'LIMIT',
2688
+ 'quantity': this.amountToPrecision(symbol, amount),
2689
+ };
2690
+ const isMarketOrder = type === 'market';
2691
+ if (isMarketOrder) {
2692
+ request['priceType'] = 'MARKET';
2693
+ }
2694
+ if (price !== undefined) {
2695
+ request['price'] = this.priceToPrecision(symbol, price);
2696
+ request['priceType'] = 'INPUT';
2697
+ }
2698
+ let reduceOnly = false;
2699
+ [reduceOnly, params] = this.handleParamBool(params, 'reduceOnly', reduceOnly);
2700
+ let suffix = '_OPEN';
2701
+ if (reduceOnly) {
2702
+ suffix = '_CLOSE';
2703
+ }
2704
+ request['side'] = side.toUpperCase() + suffix;
2705
+ let timeInForce = undefined;
2706
+ [timeInForce, params] = this.handleParamString(params, 'timeInForce');
2707
+ let postOnly = false;
2708
+ [postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'LIMIT_MAKER', params);
2709
+ if (postOnly) {
2710
+ timeInForce = 'LIMIT_MAKER';
2711
+ }
2712
+ if (timeInForce !== undefined) {
2713
+ request['timeInForce'] = timeInForce;
2714
+ }
2715
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2716
+ if (clientOrderId === undefined) {
2717
+ request['clientOrderId'] = this.uuid();
2718
+ }
2719
+ const triggerPrice = this.safeString(params, 'triggerPrice');
2720
+ if (triggerPrice !== undefined) {
2721
+ request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
2722
+ request['type'] = 'STOP';
2723
+ params = this.omit(params, 'triggerPrice');
2724
+ }
2725
+ return this.extend(request, params);
2726
+ }
2727
+ /**
2728
+ * @method
2729
+ * @name hashkey#createSwapOrder
2730
+ * @description create a trade order on swap market
2731
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/create-new-futures-order
2732
+ * @param {string} symbol unified symbol of the market to create an order in
2733
+ * @param {string} type 'market' or 'limit' or 'STOP'
2734
+ * @param {string} side 'buy' or 'sell'
2735
+ * @param {float} amount how much of you want to trade in units of the base currency
2736
+ * @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
2737
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2738
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2739
+ * @param {bool} [params.reduceOnly] true or false whether the order is reduce only
2740
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2741
+ * @param {string} [params.timeInForce] 'GTC', 'FOK', 'IOC', 'LIMIT_MAKER' or 'PO'
2742
+ * @param {string} [params.clientOrderId] a unique id for the order
2743
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2744
+ */
2745
+ async createSwapOrder(symbol, type, side, amount, price = undefined, params = {}) {
2746
+ await this.loadMarkets();
2747
+ const market = this.market(symbol);
2748
+ const request = this.createSwapOrderRequest(symbol, type, side, amount, price, params);
2749
+ const response = await this.privatePostApiV1FuturesOrder(this.extend(request, params));
2750
+ //
2751
+ // {
2752
+ // "time": "1722429951611",
2753
+ // "updateTime": "1722429951648",
2754
+ // "orderId": "1742263144028363776",
2755
+ // "clientOrderId": "1722429950315",
2756
+ // "symbol": "ETHUSDT-PERPETUAL",
2757
+ // "price": "3460.62",
2758
+ // "leverage": "5",
2759
+ // "origQty": "10",
2760
+ // "executedQty": "10",
2761
+ // "avgPrice": "0",
2762
+ // "marginLocked": "6.9212",
2763
+ // "type": "LIMIT",
2764
+ // "side": "BUY_OPEN",
2765
+ // "timeInForce": "IOC",
2766
+ // "status": "FILLED",
2767
+ // "priceType": "MARKET",
2768
+ // "contractMultiplier": "0.00100000"
2769
+ // }
2770
+ //
2771
+ return this.parseOrder(response, market);
2772
+ }
2773
+ /**
2774
+ * @method
2775
+ * @name hashkey#createOrders
2776
+ * @description create a list of trade orders (all orders should be of the same symbol)
2777
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/create-multiple-orders
2778
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/batch-create-new-futures-order
2779
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2780
+ * @param {object} [params] extra parameters specific to the api endpoint
2781
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2782
+ */
2783
+ async createOrders(orders, params = {}) {
2784
+ await this.loadMarkets();
2785
+ const ordersRequests = [];
2786
+ for (let i = 0; i < orders.length; i++) {
2787
+ const rawOrder = orders[i];
2788
+ const symbol = this.safeString(rawOrder, 'symbol');
2789
+ const type = this.safeString(rawOrder, 'type');
2790
+ const side = this.safeString(rawOrder, 'side');
2791
+ const amount = this.safeNumber(rawOrder, 'amount');
2792
+ const price = this.safeNumber(rawOrder, 'price');
2793
+ const orderParams = this.safeDict(rawOrder, 'params', {});
2794
+ const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, orderParams);
2795
+ const clientOrderId = this.safeString(orderRequest, 'clientOrderId');
2796
+ if (clientOrderId === undefined) {
2797
+ orderRequest['clientOrderId'] = this.uuid(); // both spot and swap endpoints require clientOrderId
2798
+ }
2799
+ ordersRequests.push(orderRequest);
2800
+ }
2801
+ const firstOrder = ordersRequests[0];
2802
+ const firstSymbol = this.safeString(firstOrder, 'symbol');
2803
+ const market = this.market(firstSymbol);
2804
+ const request = {
2805
+ 'orders': ordersRequests,
2806
+ };
2807
+ let response = undefined;
2808
+ if (market['spot']) {
2809
+ response = await this.privatePostApiV1SpotBatchOrders(this.extend(request, params));
2810
+ //
2811
+ // {
2812
+ // "code": 0,
2813
+ // "result": [
2814
+ // {
2815
+ // "code": "0000",
2816
+ // "order": {
2817
+ // "accountId": "1732885739589466112",
2818
+ // "symbol": "ETHUSDT",
2819
+ // "symbolName": "ETHUSDT",
2820
+ // "clientOrderId": "1722701490163000",
2821
+ // "orderId": "1744540984757258752",
2822
+ // "transactTime": "1722701491385",
2823
+ // "price": "1500",
2824
+ // "origQty": "0.001",
2825
+ // "executedQty": "0",
2826
+ // "status": "NEW",
2827
+ // "timeInForce": "GTC",
2828
+ // "type": "LIMIT",
2829
+ // "side": "BUY",
2830
+ // "reqAmount": "0"
2831
+ // }
2832
+ // }
2833
+ // ],
2834
+ // "concentration": ""
2835
+ // }
2836
+ //
2837
+ }
2838
+ else if (market['swap']) {
2839
+ response = await this.privatePostApiV1FuturesBatchOrders(this.extend(request, params));
2840
+ //
2841
+ // {
2842
+ // "code": "0000",
2843
+ // "result": [
2844
+ // {
2845
+ // "code": "0000",
2846
+ // "order": {
2847
+ // "time": "1722704251911",
2848
+ // "updateTime": "1722704251918",
2849
+ // "orderId": "1744564141727808768",
2850
+ // "clientOrderId": "1722704250648000",
2851
+ // "symbol": "ETHUSDT-PERPETUAL",
2852
+ // "price": "1500",
2853
+ // "leverage": "4",
2854
+ // "origQty": "1",
2855
+ // "executedQty": "0",
2856
+ // "avgPrice": "0",
2857
+ // "marginLocked": "0.375",
2858
+ // "type": "LIMIT",
2859
+ // "side": "BUY_OPEN",
2860
+ // "timeInForce": "GTC",
2861
+ // "status": "NEW",
2862
+ // "priceType": "INPUT",
2863
+ // "isLiquidationOrder": false,
2864
+ // "indexPrice": "0",
2865
+ // "liquidationType": ""
2866
+ // }
2867
+ // },
2868
+ // {
2869
+ // "code": "0207",
2870
+ // "msg": "Create limit order sell price too low"
2871
+ // }
2872
+ // ]
2873
+ // }
2874
+ //
2875
+ }
2876
+ else {
2877
+ throw new NotSupported(this.id + ' ' + 'createOrderRequest() is not supported for ' + market['type'] + ' type of markets');
2878
+ }
2879
+ const result = this.safeList(response, 'result', []);
2880
+ const responseOrders = [];
2881
+ for (let i = 0; i < result.length; i++) {
2882
+ const responseEntry = this.safeDict(result, i, {});
2883
+ const responseOrder = this.safeDict(responseEntry, 'order', {});
2884
+ responseOrders.push(responseOrder);
2885
+ }
2886
+ return this.parseOrders(responseOrders);
2887
+ }
2888
+ /**
2889
+ * @method
2890
+ * @name hashkey#cancelOrder
2891
+ * @description cancels an open order
2892
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/cancel-order
2893
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/cancel-futures-order
2894
+ * @param {string} id order id
2895
+ * @param {string} symbol unified symbol of the market the order was made in
2896
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2897
+ * @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entry for (default 'spot')
2898
+ * @param {string} [params.clientOrderId] a unique id for the order that can be used as an alternative for the id
2899
+ * @param {bool} [params.trigger] *swap markets only* true for canceling a trigger order (default false)
2900
+ * @param {bool} [params.stop] *swap markets only* an alternative for trigger param
2901
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2902
+ */
2903
+ async cancelOrder(id, symbol = undefined, params = {}) {
2904
+ const methodName = 'cancelOrder';
2905
+ this.checkTypeParam(methodName, params);
2906
+ await this.loadMarkets();
2907
+ const request = {};
2908
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2909
+ if (clientOrderId === undefined) {
2910
+ request['orderId'] = id;
2911
+ }
2912
+ let market = undefined;
2913
+ if (symbol !== undefined) {
2914
+ market = this.market(symbol);
2915
+ }
2916
+ let marketType = 'spot';
2917
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params, marketType);
2918
+ let response = undefined;
2919
+ if (marketType === 'spot') {
2920
+ response = await this.privateDeleteApiV1SpotOrder(this.extend(request, params));
2921
+ //
2922
+ // {
2923
+ // "accountId": "1732885739589466112",
2924
+ // "symbol": "ETHUSDT",
2925
+ // "clientOrderId": "1722006209978370",
2926
+ // "orderId": "1738708541676585728",
2927
+ // "transactTime": "1722006209989",
2928
+ // "price": "5000",
2929
+ // "origQty": "0.005",
2930
+ // "executedQty": "0",
2931
+ // "status": "NEW",
2932
+ // "timeInForce": "GTC",
2933
+ // "type": "LIMIT_MAKER",
2934
+ // "side": "SELL"
2935
+ // }
2936
+ //
2937
+ }
2938
+ else if (marketType === 'swap') {
2939
+ let isTrigger = false;
2940
+ [isTrigger, params] = this.handleTriggerOptionAndParams(params, methodName, isTrigger);
2941
+ if (isTrigger) {
2942
+ request['type'] = 'STOP';
2943
+ }
2944
+ else {
2945
+ request['type'] = 'LIMIT';
2946
+ }
2947
+ if (market !== undefined) {
2948
+ request['symbol'] = market['id'];
2949
+ }
2950
+ response = await this.privateDeleteApiV1FuturesOrder(this.extend(request, params));
2951
+ //
2952
+ // {
2953
+ // "time": "1722432302919",
2954
+ // "updateTime": "1722432302925",
2955
+ // "orderId": "1742282868229463040",
2956
+ // "clientOrderId": "1722432301670",
2957
+ // "symbol": "ETHUSDT-PERPETUAL",
2958
+ // "price": "4000",
2959
+ // "leverage": "5",
2960
+ // "origQty": "10",
2961
+ // "executedQty": "0",
2962
+ // "avgPrice": "0",
2963
+ // "marginLocked": "0",
2964
+ // "type": "LIMIT_MAKER",
2965
+ // "side": "SELL_CLOSE",
2966
+ // "timeInForce": "GTC",
2967
+ // "status": "NEW",
2968
+ // "priceType": "INPUT",
2969
+ // "isLiquidationOrder": false,
2970
+ // "indexPrice": "0",
2971
+ // "liquidationType": ""
2972
+ // }
2973
+ //
2974
+ }
2975
+ else {
2976
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + marketType + ' type of markets');
2977
+ }
2978
+ return this.parseOrder(response);
2979
+ }
2980
+ /**
2981
+ * @method
2982
+ * @name hashkey#cancelAllOrders
2983
+ * @description cancel all open orders
2984
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/cancel-all-open-orders
2985
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/batch-cancel-futures-order
2986
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2987
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2988
+ * @param {string} [params.side] 'buy' or 'sell'
2989
+ * @returns {object} response from exchange
2990
+ */
2991
+ async cancelAllOrders(symbol = undefined, params = {}) {
2992
+ // Does not cancel trigger orders. For canceling trigger order use cancelOrder() or cancelOrders()
2993
+ const methodName = 'cancelAllOrders';
2994
+ if (symbol === undefined) {
2995
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires a symbol argument');
2996
+ }
2997
+ await this.loadMarkets();
2998
+ const market = this.market(symbol);
2999
+ const request = {
3000
+ 'symbol': market['id'],
3001
+ };
3002
+ const side = this.safeString(params, 'side');
3003
+ if (side !== undefined) {
3004
+ request['side'] = side;
3005
+ }
3006
+ let response = undefined;
3007
+ if (market['spot']) {
3008
+ response = await this.privateDeleteApiV1SpotOpenOrders(this.extend(request, params));
3009
+ //
3010
+ // { "success": true }
3011
+ //
3012
+ }
3013
+ else if (market['swap']) {
3014
+ response = await this.privateDeleteApiV1FuturesBatchOrders(this.extend(request, params));
3015
+ //
3016
+ // { "message": "success", "timestamp": "1723127222198", "code": "0000" }
3017
+ //
3018
+ }
3019
+ else {
3020
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + market['type'] + ' type of markets');
3021
+ }
3022
+ const order = this.safeOrder(response);
3023
+ order['info'] = response;
3024
+ return [order];
3025
+ }
3026
+ /**
3027
+ * @method
3028
+ * @name hashkey#cancelOrders
3029
+ * @description cancel multiple orders
3030
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/cancel-multiple-orders
3031
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/batch-cancel-futures-order-by-order-id
3032
+ * @param {string[]} ids order ids
3033
+ * @param {string} [symbol] unified market symbol (not used by hashkey)
3034
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3035
+ * @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entry for (default 'spot')
3036
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3037
+ */
3038
+ async cancelOrders(ids, symbol = undefined, params = {}) {
3039
+ const methodName = 'cancelOrders';
3040
+ await this.loadMarkets();
3041
+ const request = {};
3042
+ const orderIds = ids.join(',');
3043
+ request['ids'] = orderIds;
3044
+ let market = undefined;
3045
+ if (symbol !== undefined) {
3046
+ market = this.market(symbol);
3047
+ }
3048
+ let marketType = 'spot';
3049
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params, marketType);
3050
+ let response = undefined;
3051
+ if (marketType === 'spot') {
3052
+ response = await this.privateDeleteApiV1SpotCancelOrderByIds(this.extend(request));
3053
+ //
3054
+ // {
3055
+ // "code": "0000",
3056
+ // "result": []
3057
+ // }
3058
+ //
3059
+ }
3060
+ else if (marketType === 'swap') {
3061
+ response = this.privateDeleteApiV1FuturesCancelOrderByIds(this.extend(request));
3062
+ }
3063
+ else {
3064
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + marketType + ' type of markets');
3065
+ }
3066
+ const order = this.safeOrder(response);
3067
+ order['info'] = response;
3068
+ return [order];
3069
+ }
3070
+ /**
3071
+ * @method
3072
+ * @name hashkey#fetchOrder
3073
+ * @description fetches information on an order made by the user
3074
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/query-order
3075
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-futures-order
3076
+ * @param {string} id the order id
3077
+ * @param {string} symbol unified symbol of the market the order was made in
3078
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3079
+ * @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entry for (default 'spot')
3080
+ * @param {string} [params.clientOrderId] a unique id for the order that can be used as an alternative for the id
3081
+ * @param {string} [params.accountId] *spot markets only* account id to fetch the order from
3082
+ * @param {bool} [params.trigger] *swap markets only* true for fetching a trigger order (default false)
3083
+ * @param {bool} [params.stop] *swap markets only* an alternative for trigger param
3084
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3085
+ */
3086
+ async fetchOrder(id, symbol = undefined, params = {}) {
3087
+ const methodName = 'fetchOrder';
3088
+ this.checkTypeParam(methodName, params);
3089
+ await this.loadMarkets();
3090
+ const request = {};
3091
+ let clientOrderId = undefined;
3092
+ [clientOrderId, params] = this.handleParamString(params, 'clientOrderId');
3093
+ if (clientOrderId === undefined) {
3094
+ request['orderId'] = id;
3095
+ }
3096
+ let market = undefined;
3097
+ if (symbol !== undefined) {
3098
+ market = this.market(symbol);
3099
+ }
3100
+ let marketType = 'spot';
3101
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params, marketType);
3102
+ let response = undefined;
3103
+ if (marketType === 'spot') {
3104
+ if (clientOrderId !== undefined) {
3105
+ request['origClientOrderId'] = clientOrderId;
3106
+ }
3107
+ response = await this.privateGetApiV1SpotOrder(this.extend(request, params));
3108
+ //
3109
+ // {
3110
+ // "accountId": "1732885739589466112",
3111
+ // "exchangeId": "301",
3112
+ // "symbol": "ETHUSDT",
3113
+ // "symbolName": "ETHUSDT",
3114
+ // "clientOrderId": "1722004623170558",
3115
+ // "orderId": "1738695230608169984",
3116
+ // "price": "0",
3117
+ // "origQty": "0",
3118
+ // "executedQty": "0.0061",
3119
+ // "cummulativeQuoteQty": "19.736489",
3120
+ // "cumulativeQuoteQty": "19.736489",
3121
+ // "avgPrice": "3235.49",
3122
+ // "status": "FILLED",
3123
+ // "timeInForce": "IOC",
3124
+ // "type": "MARKET",
3125
+ // "side": "BUY",
3126
+ // "stopPrice": "0.0",
3127
+ // "icebergQty": "0.0",
3128
+ // "time": "1722004623186",
3129
+ // "updateTime": "1722004623406",
3130
+ // "isWorking": true,
3131
+ // "reqAmount": "20",
3132
+ // "feeCoin": "",
3133
+ // "feeAmount": "0",
3134
+ // "sumFeeAmount": "0"
3135
+ // }
3136
+ //
3137
+ }
3138
+ else if (marketType === 'swap') {
3139
+ let isTrigger = false;
3140
+ [isTrigger, params] = this.handleTriggerOptionAndParams(params, methodName, isTrigger);
3141
+ if (isTrigger) {
3142
+ request['type'] = 'STOP';
3143
+ }
3144
+ response = await this.privateGetApiV1FuturesOrder(this.extend(request, params));
3145
+ //
3146
+ // {
3147
+ // "time": "1722429951611",
3148
+ // "updateTime": "1722429951700",
3149
+ // "orderId": "1742263144028363776",
3150
+ // "clientOrderId": "1722429950315",
3151
+ // "symbol": "ETHUSDT-PERPETUAL",
3152
+ // "price": "3460.62",
3153
+ // "leverage": "5",
3154
+ // "origQty": "10",
3155
+ // "executedQty": "10",
3156
+ // "avgPrice": "3327.52",
3157
+ // "marginLocked": "0",
3158
+ // "type": "LIMIT",
3159
+ // "side": "BUY_OPEN",
3160
+ // "timeInForce": "IOC",
3161
+ // "status": "FILLED",
3162
+ // "priceType": "MARKET",
3163
+ // "isLiquidationOrder": false,
3164
+ // "indexPrice": "0",
3165
+ // "liquidationType": ""
3166
+ // }
3167
+ //
3168
+ }
3169
+ else {
3170
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + marketType + ' type of markets');
3171
+ }
3172
+ return this.parseOrder(response);
3173
+ }
3174
+ /**
3175
+ * @method
3176
+ * @name hashkey#fetchOpenOrders
3177
+ * @description fetch all unfilled currently open orders
3178
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-current-open-orders
3179
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-open-orders
3180
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/sub
3181
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/query-open-futures-orders
3182
+ * @param {string} [symbol] unified market symbol of the market orders were made in - is mandatory for swap markets
3183
+ * @param {int} [since] the earliest time in ms to fetch orders for
3184
+ * @param {int} [limit] the maximum number of order structures to retrieve - default 500, maximum 1000
3185
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3186
+ * @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entries for (default 'spot')
3187
+ * @param {string} [params.orderId] *spot markets only* the id of the order to fetch
3188
+ * @param {string} [params.side] *spot markets only* 'buy' or 'sell' - the side of the orders to fetch
3189
+ * @param {string} [params.fromOrderId] *swap markets only* the id of the order to start from
3190
+ * @param {bool} [params.trigger] *swap markets only* true for fetching trigger orders (default false)
3191
+ * @param {bool} [params.stop] *swap markets only* an alternative for trigger param
3192
+ * @param {string} [params.accountId] account id to fetch the orders from
3193
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3194
+ */
3195
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3196
+ const methodName = 'fetchOpenOrders';
3197
+ this.checkTypeParam(methodName, params);
3198
+ await this.loadMarkets();
3199
+ let market = undefined;
3200
+ if (symbol !== undefined) {
3201
+ market = this.market(symbol);
3202
+ }
3203
+ let marketType = 'spot';
3204
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params, marketType);
3205
+ params = this.extend({ 'methodName': methodName }, params);
3206
+ if (marketType === 'spot') {
3207
+ return await this.fetchOpenSpotOrders(symbol, since, limit, params);
3208
+ }
3209
+ else if (marketType === 'swap') {
3210
+ return await this.fetchOpenSwapOrders(symbol, since, limit, params);
3211
+ }
3212
+ else {
3213
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + marketType + ' type of markets');
3214
+ }
3215
+ }
3216
+ /**
3217
+ * @method
3218
+ * @ignore
3219
+ * @name hashkey#fetchOpenSpotOrders
3220
+ * @description fetch all unfilled currently open orders for spot markets
3221
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-current-open-orders
3222
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/sub
3223
+ * @param {string} [symbol] unified market symbol of the market orders were made in
3224
+ * @param {int} [since] the earliest time in ms to fetch orders for
3225
+ * @param {int} [limit] the maximum number of order structures to retrieve - default 500, maximum 1000
3226
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3227
+ * @param {string} [params.orderId] the id of the order to fetch
3228
+ * @param {string} [params.side] 'buy' or 'sell' - the side of the orders to fetch
3229
+ * @param {string} [params.accountId] account id to fetch the orders from
3230
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3231
+ */
3232
+ async fetchOpenSpotOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3233
+ await this.loadMarkets();
3234
+ let methodName = 'fetchOpenSpotOrders';
3235
+ [methodName, params] = this.handleParamString(params, 'methodName', methodName);
3236
+ let market = undefined;
3237
+ const request = {};
3238
+ let response = undefined;
3239
+ let accountId = undefined;
3240
+ [accountId, params] = this.handleOptionAndParams(params, methodName, 'accountId');
3241
+ if (accountId !== undefined) {
3242
+ request['subAccountId'] = accountId;
3243
+ response = await this.privateGetApiV1SpotSubAccountOpenOrders(this.extend(request, params));
3244
+ }
3245
+ else {
3246
+ if (symbol !== undefined) {
3247
+ market = this.market(symbol);
3248
+ request['symbol'] = market['id'];
3249
+ }
3250
+ if (limit !== undefined) {
3251
+ request['limit'] = limit;
3252
+ }
3253
+ response = await this.privateGetApiV1SpotOpenOrders(this.extend(request, params));
3254
+ //
3255
+ // [
3256
+ // {
3257
+ // "accountId": "1732885739589466112",
3258
+ // "exchangeId": "301",
3259
+ // "symbol": "ETHUSDT",
3260
+ // "symbolName": "ETHUSDT",
3261
+ // "clientOrderId": "1",
3262
+ // "orderId": "1739491435386897152",
3263
+ // "price": "2000",
3264
+ // "origQty": "0.001",
3265
+ // "executedQty": "0",
3266
+ // "cummulativeQuoteQty": "0",
3267
+ // "cumulativeQuoteQty": "0",
3268
+ // "avgPrice": "0",
3269
+ // "status": "NEW",
3270
+ // "timeInForce": "GTC",
3271
+ // "type": "LIMIT",
3272
+ // "side": "BUY",
3273
+ // "stopPrice": "0.0",
3274
+ // "icebergQty": "0.0",
3275
+ // "time": "1722099538193",
3276
+ // "updateTime": "1722099538197",
3277
+ // "isWorking": true,
3278
+ // "reqAmount": "0"
3279
+ // }
3280
+ // ]
3281
+ //
3282
+ }
3283
+ return this.parseOrders(response, market, since, limit);
3284
+ }
3285
+ /**
3286
+ * @method
3287
+ * @ignore
3288
+ * @name hashkey#fetchOpenSwapOrders
3289
+ * @description fetch all unfilled currently open orders for swap markets
3290
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/query-open-futures-orders
3291
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-open-orders
3292
+ * @param {string} symbol *is mandatory* unified market symbol of the market orders were made in
3293
+ * @param {int} [since] the earliest time in ms to fetch orders for
3294
+ * @param {int} [limit] the maximum number of order structures to retrieve - maximum 500
3295
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3296
+ * @param {string} [params.fromOrderId] the id of the order to start from
3297
+ * @param {bool} [params.trigger] true for fetching trigger orders (default false)
3298
+ * @param {bool} [params.stop] an alternative for trigger param
3299
+ * @param {string} [params.accountId] account id to fetch the orders from
3300
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3301
+ */
3302
+ async fetchOpenSwapOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3303
+ let methodName = 'fetchOpenSwapOrders';
3304
+ [methodName, params] = this.handleParamString(params, 'methodName', methodName);
3305
+ if (symbol === undefined) {
3306
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires a symbol argument for swap market orders');
3307
+ }
3308
+ const market = this.market(symbol);
3309
+ const request = {
3310
+ 'symbol': market['id'],
3311
+ };
3312
+ let isTrigger = false;
3313
+ [isTrigger, params] = this.handleTriggerOptionAndParams(params, methodName, isTrigger);
3314
+ if (isTrigger) {
3315
+ request['type'] = 'STOP';
3316
+ }
3317
+ else {
3318
+ request['type'] = 'LIMIT';
3319
+ }
3320
+ if (limit !== undefined) {
3321
+ request['limit'] = limit;
3322
+ }
3323
+ let response = undefined;
3324
+ let accountId = undefined;
3325
+ [accountId, params] = this.handleOptionAndParams(params, methodName, 'accountId');
3326
+ if (accountId !== undefined) {
3327
+ request['subAccountId'] = accountId;
3328
+ response = await this.privateGetApiV1FuturesSubAccountOpenOrders(this.extend(request, params));
3329
+ }
3330
+ else {
3331
+ response = await this.privateGetApiV1FuturesOpenOrders(this.extend(request, params));
3332
+ // 'LIMIT'
3333
+ // [
3334
+ // {
3335
+ // "time": "1722432302919",
3336
+ // "updateTime": "1722432302925",
3337
+ // "orderId": "1742282868229463040",
3338
+ // "clientOrderId": "1722432301670",
3339
+ // "symbol": "ETHUSDT-PERPETUAL",
3340
+ // "price": "4000",
3341
+ // "leverage": "5",
3342
+ // "origQty": "10",
3343
+ // "executedQty": "0",
3344
+ // "avgPrice": "0",
3345
+ // "marginLocked": "0",
3346
+ // "type": "LIMIT_MAKER",
3347
+ // "side": "SELL_CLOSE",
3348
+ // "timeInForce": "GTC",
3349
+ // "status": "NEW",
3350
+ // "priceType": "INPUT",
3351
+ // "isLiquidationOrder": false,
3352
+ // "indexPrice": "0",
3353
+ // "liquidationType": ""
3354
+ // }
3355
+ // ]
3356
+ //
3357
+ // 'STOP'
3358
+ // [
3359
+ // {
3360
+ // "time": "1722433095688",
3361
+ // "updateTime": "1722433095688",
3362
+ // "orderId": "1742289518466225664",
3363
+ // "accountId": "1735619524953226496",
3364
+ // "clientOrderId": "1722433094438",
3365
+ // "symbol": "ETHUSDT-PERPETUAL",
3366
+ // "price": "3700",
3367
+ // "leverage": "0",
3368
+ // "origQty": "10",
3369
+ // "type": "STOP",
3370
+ // "side": "SELL_CLOSE",
3371
+ // "status": "ORDER_NEW",
3372
+ // "stopPrice": "3600"
3373
+ // }
3374
+ // ]
3375
+ }
3376
+ return this.parseOrders(response, market, since, limit);
3377
+ }
3378
+ /**
3379
+ * @method
3380
+ * @name hashkey#fetchCanceledAndClosedOrders
3381
+ * @description fetches information on multiple canceled and closed orders made by the user
3382
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-all-orders
3383
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/query-futures-history-orders
3384
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-history-orders
3385
+ * @param {string} symbol *is mandatory for swap markets* unified market symbol of the market orders were made in
3386
+ * @param {int} [since] the earliest time in ms to fetch orders for
3387
+ * @param {int} [limit] the maximum number of order structures to retrieve - default 500, maximum 1000
3388
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3389
+ * @param {int} [params.until] the latest time in ms to fetch entries for - only supports the last 90 days timeframe
3390
+ * @param {string} [params.type] 'spot' or 'swap' - the type of the market to fetch entries for (default 'spot')
3391
+ * @param {string} [params.orderId] *spot markets only* the id of the order to fetch
3392
+ * @param {string} [params.side] *spot markets only* 'buy' or 'sell' - the side of the orders to fetch
3393
+ * @param {string} [params.fromOrderId] *swap markets only* the id of the order to start from
3394
+ * @param {bool} [params.trigger] *swap markets only* the id of the order to start from true for fetching trigger orders (default false)
3395
+ * @param {bool} [params.stop] *swap markets only* the id of the order to start from an alternative for trigger param
3396
+ * @param {string} [params.accountId] account id to fetch the orders from
3397
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3398
+ */
3399
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3400
+ const methodName = 'fetchCanceledAndClosedOrders';
3401
+ this.checkTypeParam(methodName, params);
3402
+ await this.loadMarkets();
3403
+ const request = {};
3404
+ if (limit !== undefined) {
3405
+ request['limit'] = limit;
3406
+ }
3407
+ if (since !== undefined) {
3408
+ request['startTime'] = since;
3409
+ }
3410
+ let until = undefined;
3411
+ [until, params] = this.handleOptionAndParams(params, methodName, 'until');
3412
+ if (until !== undefined) {
3413
+ request['endTime'] = until;
3414
+ }
3415
+ let accountId = undefined;
3416
+ [accountId, params] = this.handleOptionAndParams(params, methodName, 'accountId');
3417
+ let market = undefined;
3418
+ if (symbol !== undefined) {
3419
+ market = this.market(symbol);
3420
+ }
3421
+ let marketType = 'spot';
3422
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params, marketType);
3423
+ let response = undefined;
3424
+ if (marketType === 'spot') {
3425
+ if (market !== undefined) {
3426
+ request['symbol'] = market['id'];
3427
+ }
3428
+ if (accountId !== undefined) {
3429
+ request['accountId'] = accountId;
3430
+ }
3431
+ response = await this.privateGetApiV1SpotTradeOrders(this.extend(request, params));
3432
+ //
3433
+ // [
3434
+ // {
3435
+ // "accountId": "1732885739589466112",
3436
+ // "exchangeId": "301",
3437
+ // "symbol": "ETHUSDT",
3438
+ // "symbolName": "ETHUSDT",
3439
+ // "clientOrderId": "1722082982086472",
3440
+ // "orderId": "1739352552762301440",
3441
+ // "price": "0",
3442
+ // "origQty": "0.001",
3443
+ // "executedQty": "0.001",
3444
+ // "cummulativeQuoteQty": "3.28996",
3445
+ // "cumulativeQuoteQty": "3.28996",
3446
+ // "avgPrice": "3289.96",
3447
+ // "status": "FILLED",
3448
+ // "timeInForce": "IOC",
3449
+ // "type": "MARKET",
3450
+ // "side": "BUY",
3451
+ // "stopPrice": "0.0",
3452
+ // "icebergQty": "0.0",
3453
+ // "time": "1722082982093",
3454
+ // "updateTime": "1722082982097",
3455
+ // "isWorking": true,
3456
+ // "reqAmount": "0"
3457
+ // },
3458
+ // ...
3459
+ // ]
3460
+ //
3461
+ }
3462
+ else if (marketType === 'swap') {
3463
+ if (symbol === undefined) {
3464
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires a symbol argument for swap markets');
3465
+ }
3466
+ request['symbol'] = market['id'];
3467
+ let isTrigger = false;
3468
+ [isTrigger, params] = this.handleTriggerOptionAndParams(params, methodName, isTrigger);
3469
+ if (isTrigger) {
3470
+ request['type'] = 'STOP';
3471
+ }
3472
+ else {
3473
+ request['type'] = 'LIMIT';
3474
+ }
3475
+ if (accountId !== undefined) {
3476
+ request['subAccountId'] = accountId;
3477
+ response = await this.privateGetApiV1FuturesSubAccountHistoryOrders(this.extend(request, params));
3478
+ }
3479
+ else {
3480
+ response = await this.privateGetApiV1FuturesHistoryOrders(this.extend(request, params));
3481
+ //
3482
+ // [
3483
+ // {
3484
+ // "time": "1722429951611",
3485
+ // "updateTime": "1722429951700",
3486
+ // "orderId": "1742263144028363776",
3487
+ // "clientOrderId": "1722429950315",
3488
+ // "symbol": "ETHUSDT-PERPETUAL",
3489
+ // "price": "3460.62",
3490
+ // "leverage": "5",
3491
+ // "origQty": "10",
3492
+ // "executedQty": "10",
3493
+ // "avgPrice": "3327.52",
3494
+ // "marginLocked": "0",
3495
+ // "type": "LIMIT",
3496
+ // "side": "BUY_OPEN",
3497
+ // "timeInForce": "IOC",
3498
+ // "status": "FILLED",
3499
+ // "priceType": "MARKET",
3500
+ // "isLiquidationOrder": false,
3501
+ // "indexPrice": "0",
3502
+ // "liquidationType": ""
3503
+ // }
3504
+ // ]
3505
+ //
3506
+ }
3507
+ }
3508
+ else {
3509
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + marketType + ' type of markets');
3510
+ }
3511
+ return this.parseOrders(response, market, since, limit);
3512
+ }
3513
+ checkTypeParam(methodName, params) {
3514
+ // some hashkey endpoints have a type param for swap markets that defines the type of an order
3515
+ // type param is reserved in ccxt for defining the type of the market
3516
+ // current method warns user if he provides the exchange specific value in type parameter
3517
+ const paramsType = this.safeString(params, 'type');
3518
+ if ((paramsType !== undefined) && (paramsType !== 'spot') && (paramsType !== 'swap')) {
3519
+ throw new BadRequest(this.id + ' ' + methodName + ' () type parameter can not be "' + paramsType + '". It should define the type of the market ("spot" or "swap"). To define the type of an order use the trigger parameter (true for trigger orders)');
3520
+ }
3521
+ }
3522
+ handleTriggerOptionAndParams(params, methodName, defaultValue = undefined) {
3523
+ let isTrigger = defaultValue;
3524
+ [isTrigger, params] = this.handleOptionAndParams2(params, methodName, 'stop', 'trigger', isTrigger);
3525
+ return [isTrigger, params];
3526
+ }
3527
+ parseOrder(order, market = undefined) {
3528
+ //
3529
+ // createOrder spot
3530
+ // {
3531
+ // "accountId": "1732885739589466112",
3532
+ // "symbol": "ETHUSDT",
3533
+ // "symbolName": "ETHUSDT",
3534
+ // "clientOrderId": "1722004623170558",
3535
+ // "orderId": "1738695230608169984",
3536
+ // "transactTime": "1722004623186",
3537
+ // "price": "0",
3538
+ // "origQty": "0",
3539
+ // "executedQty": "0.0061",
3540
+ // "status": "FILLED",
3541
+ // "timeInForce": "IOC",
3542
+ // "type": "MARKET",
3543
+ // "side": "BUY",
3544
+ // "reqAmount": "20",
3545
+ // "concentration": ""
3546
+ // }
3547
+ //
3548
+ // fetchOrder spot
3549
+ // {
3550
+ // "accountId": "1732885739589466112",
3551
+ // "exchangeId": "301",
3552
+ // "symbol": "ETHUSDT",
3553
+ // "symbolName": "ETHUSDT",
3554
+ // "clientOrderId": "1722004623170558",
3555
+ // "orderId": "1738695230608169984",
3556
+ // "price": "0",
3557
+ // "origQty": "0",
3558
+ // "executedQty": "0.0061",
3559
+ // "cummulativeQuoteQty": "19.736489",
3560
+ // "cumulativeQuoteQty": "19.736489",
3561
+ // "avgPrice": "3235.49",
3562
+ // "status": "FILLED",
3563
+ // "timeInForce": "IOC",
3564
+ // "type": "MARKET",
3565
+ // "side": "BUY",
3566
+ // "stopPrice": "0.0",
3567
+ // "icebergQty": "0.0",
3568
+ // "time": "1722004623186",
3569
+ // "updateTime": "1722004623406",
3570
+ // "isWorking": true,
3571
+ // "reqAmount": "20",
3572
+ // "feeCoin": "",
3573
+ // "feeAmount": "0",
3574
+ // "sumFeeAmount": "0"
3575
+ // }
3576
+ //
3577
+ // cancelOrder
3578
+ // {
3579
+ // "accountId": "1732885739589466112",
3580
+ // "symbol": "ETHUSDT",
3581
+ // "clientOrderId": "1722006209978370",
3582
+ // "orderId": "1738708541676585728",
3583
+ // "transactTime": "1722006209989",
3584
+ // "price": "5000",
3585
+ // "origQty": "0.005",
3586
+ // "executedQty": "0",
3587
+ // "status": "NEW",
3588
+ // "timeInForce": "GTC",
3589
+ // "type": "LIMIT_MAKER",
3590
+ // "side": "SELL"
3591
+ // }
3592
+ //
3593
+ // createOrder swap
3594
+ // {
3595
+ // "time": "1722429951611",
3596
+ // "updateTime": "1722429951648",
3597
+ // "orderId": "1742263144028363776",
3598
+ // "clientOrderId": "1722429950315",
3599
+ // "symbol": "ETHUSDT-PERPETUAL",
3600
+ // "price": "3460.62",
3601
+ // "leverage": "5",
3602
+ // "origQty": "10",
3603
+ // "executedQty": "10",
3604
+ // "avgPrice": "0",
3605
+ // "marginLocked": "6.9212",
3606
+ // "type": "LIMIT",
3607
+ // "side": "BUY_OPEN",
3608
+ // "timeInForce": "IOC",
3609
+ // "status": "FILLED",
3610
+ // "priceType": "MARKET",
3611
+ // "contractMultiplier": "0.00100000"
3612
+ // }
3613
+ //
3614
+ // fetchOrder swap
3615
+ // {
3616
+ // "time": "1722429951611",
3617
+ // "updateTime": "1722429951700",
3618
+ // "orderId": "1742263144028363776",
3619
+ // "clientOrderId": "1722429950315",
3620
+ // "symbol": "ETHUSDT-PERPETUAL",
3621
+ // "price": "3460.62",
3622
+ // "leverage": "5",
3623
+ // "origQty": "10",
3624
+ // "executedQty": "10",
3625
+ // "avgPrice": "3327.52",
3626
+ // "marginLocked": "0",
3627
+ // "type": "LIMIT",
3628
+ // "side": "BUY_OPEN",
3629
+ // "timeInForce": "IOC",
3630
+ // "status": "FILLED",
3631
+ // "priceType": "MARKET",
3632
+ // "isLiquidationOrder": false,
3633
+ // "indexPrice": "0",
3634
+ // "liquidationType": ""
3635
+ // }
3636
+ //
3637
+ const marketId = this.safeString(order, 'symbol');
3638
+ market = this.safeMarket(marketId, market);
3639
+ const timestamp = this.safeInteger2(order, 'transactTime', 'time');
3640
+ const status = this.safeString(order, 'status');
3641
+ let type = this.safeString(order, 'type');
3642
+ const priceType = this.safeString(order, 'priceType');
3643
+ if (priceType === 'MARKET') {
3644
+ type = 'market';
3645
+ }
3646
+ let price = this.omitZero(this.safeString(order, 'price'));
3647
+ if (type === 'STOP') {
3648
+ if (price === undefined) {
3649
+ type = 'market';
3650
+ }
3651
+ else {
3652
+ type = 'limit';
3653
+ }
3654
+ }
3655
+ let timeInForce = this.safeString(order, 'timeInForce');
3656
+ let postOnly = undefined;
3657
+ [type, timeInForce, postOnly] = this.parseOrderTypeTimeInForceAndPostOnly(type, timeInForce);
3658
+ const average = this.omitZero(this.safeString(order, 'avgPrice'));
3659
+ if (price === undefined) {
3660
+ price = average;
3661
+ }
3662
+ let side = this.safeStringLower(order, 'side');
3663
+ let reduceOnly = undefined;
3664
+ [side, reduceOnly] = this.parseOrderSideAndReduceOnly(side);
3665
+ let feeCurrncyId = this.safeString(order, 'feeCoin');
3666
+ if (feeCurrncyId === '') {
3667
+ feeCurrncyId = undefined;
3668
+ }
3669
+ return this.safeOrder({
3670
+ 'id': this.safeString(order, 'orderId'),
3671
+ 'clientOrderId': this.safeString(order, 'clientOrderId'),
3672
+ 'datetime': this.iso8601(timestamp),
3673
+ 'timestamp': timestamp,
3674
+ 'lastTradeTimestamp': undefined,
3675
+ 'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
3676
+ 'status': this.parseOrderStatus(status),
3677
+ 'symbol': market['symbol'],
3678
+ 'type': type,
3679
+ 'timeInForce': timeInForce,
3680
+ 'side': side,
3681
+ 'price': price,
3682
+ 'average': average,
3683
+ 'amount': this.omitZero(this.safeString(order, 'origQty')),
3684
+ 'filled': this.safeString(order, 'executedQty'),
3685
+ 'remaining': undefined,
3686
+ 'triggerPrice': this.omitZero(this.safeString(order, 'stopPrice')),
3687
+ 'takeProfitPrice': undefined,
3688
+ 'stopLossPrice': undefined,
3689
+ 'cost': this.omitZero(this.safeString2(order, 'cumulativeQuoteQty', 'cummulativeQuoteQty')),
3690
+ 'trades': undefined,
3691
+ 'fee': {
3692
+ 'currency': this.safeCurrencyCode(feeCurrncyId),
3693
+ 'amount': this.omitZero(this.safeString(order, 'feeAmount')),
3694
+ },
3695
+ 'reduceOnly': reduceOnly,
3696
+ 'postOnly': postOnly,
3697
+ 'info': order,
3698
+ }, market);
3699
+ }
3700
+ parseOrderSideAndReduceOnly(unparsed) {
3701
+ const parts = unparsed.split('_');
3702
+ const side = parts[0];
3703
+ let reduceOnly = undefined;
3704
+ const secondPart = this.safeString(parts, 1);
3705
+ if (secondPart !== undefined) {
3706
+ if (secondPart === 'open') {
3707
+ reduceOnly = false;
3708
+ }
3709
+ else if ((secondPart === 'close')) {
3710
+ reduceOnly = true;
3711
+ }
3712
+ }
3713
+ return [side, reduceOnly];
3714
+ }
3715
+ parseOrderStatus(status) {
3716
+ const statuses = {
3717
+ 'NEW': 'open',
3718
+ 'PARTIALLY_FILLED': 'open',
3719
+ 'PARTIALLY_CANCELED': 'canceled',
3720
+ 'FILLED': 'closed',
3721
+ 'CANCELED': 'canceled',
3722
+ 'ORDER_CANCELED': 'canceled',
3723
+ 'PENDING_CANCEL': 'canceled',
3724
+ 'REJECTED': 'rejected',
3725
+ 'ORDER_NEW': 'open',
3726
+ };
3727
+ return this.safeString(statuses, status, status);
3728
+ }
3729
+ parseOrderTypeTimeInForceAndPostOnly(type, timeInForce) {
3730
+ let postOnly = undefined;
3731
+ if (type === 'LIMIT_MAKER') {
3732
+ postOnly = true;
3733
+ }
3734
+ else if ((timeInForce === 'LIMIT_MAKER') || (timeInForce === 'MAKER')) {
3735
+ postOnly = true;
3736
+ timeInForce = 'PO';
3737
+ }
3738
+ type = this.parseOrderType(type);
3739
+ return [type, timeInForce, postOnly];
3740
+ }
3741
+ parseOrderType(type) {
3742
+ const types = {
3743
+ 'MARKET': 'market',
3744
+ 'LIMIT': 'limit',
3745
+ 'LIMIT_MAKER': 'limit',
3746
+ 'MARKET_OF_BASE': 'market',
3747
+ };
3748
+ return this.safeString(types, type, type);
3749
+ }
3750
+ /**
3751
+ * @method
3752
+ * @name hashkey#fetchFundingRate
3753
+ * @description fetch the current funding rate
3754
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
3755
+ * @param {string} symbol unified market symbol
3756
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3757
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3758
+ */
3759
+ async fetchFundingRate(symbol, params = {}) {
3760
+ await this.loadMarkets();
3761
+ const market = this.market(symbol);
3762
+ const request = {
3763
+ 'symbol': market['id'],
3764
+ 'timestamp': this.milliseconds(),
3765
+ };
3766
+ const response = await this.publicGetApiV1FuturesFundingRate(this.extend(request, params));
3767
+ //
3768
+ // [
3769
+ // { "symbol": "ETHUSDT-PERPETUAL", "rate": "0.0001", "nextSettleTime": "1722297600000" }
3770
+ // ]
3771
+ //
3772
+ const rate = this.safeDict(response, 0, {});
3773
+ return this.parseFundingRate(rate, market);
3774
+ }
3775
+ /**
3776
+ * @method
3777
+ * @name hashkey#fetchFundingRates
3778
+ * @description fetch the funding rate for multiple markets
3779
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
3780
+ * @param {string[]|undefined} symbols list of unified market symbols
3781
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3782
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
3783
+ */
3784
+ async fetchFundingRates(symbols = undefined, params = {}) {
3785
+ await this.loadMarkets();
3786
+ symbols = this.marketSymbols(symbols);
3787
+ const request = {
3788
+ 'timestamp': this.milliseconds(),
3789
+ };
3790
+ const response = await this.publicGetApiV1FuturesFundingRate(this.extend(request, params));
3791
+ //
3792
+ // [
3793
+ // { "symbol": "BTCUSDT-PERPETUAL", "rate": "0.0001", "nextSettleTime": "1722297600000" },
3794
+ // { "symbol": "ETHUSDT-PERPETUAL", "rate": "0.0001", "nextSettleTime": "1722297600000" }
3795
+ // ]
3796
+ //
3797
+ return this.parseFundingRates(response, symbols);
3798
+ }
3799
+ parseFundingRate(contract, market = undefined) {
3800
+ //
3801
+ // {
3802
+ // "symbol": "ETHUSDT-PERPETUAL",
3803
+ // "rate": "0.0001",
3804
+ // "nextSettleTime": "1722297600000"
3805
+ // }
3806
+ //
3807
+ const marketId = this.safeString(contract, 'symbol');
3808
+ market = this.safeMarket(marketId, market, undefined, 'swap');
3809
+ const fundingRate = this.safeNumber(contract, 'rate');
3810
+ const fundingTimestamp = this.safeInteger(contract, 'nextSettleTime');
3811
+ return {
3812
+ 'info': contract,
3813
+ 'symbol': market['symbol'],
3814
+ 'markPrice': undefined,
3815
+ 'indexPrice': undefined,
3816
+ 'interestRate': undefined,
3817
+ 'estimatedSettlePrice': undefined,
3818
+ 'timestamp': undefined,
3819
+ 'datetime': undefined,
3820
+ 'fundingRate': fundingRate,
3821
+ 'fundingTimestamp': undefined,
3822
+ 'fundingDatetime': undefined,
3823
+ 'nextFundingRate': undefined,
3824
+ 'nextFundingTimestamp': fundingTimestamp,
3825
+ 'nextFundingDatetime': this.iso8601(fundingTimestamp),
3826
+ 'previousFundingRate': undefined,
3827
+ 'previousFundingTimestamp': undefined,
3828
+ 'previousFundingDatetime': undefined,
3829
+ 'interval': undefined,
3830
+ };
3831
+ }
3832
+ /**
3833
+ * @method
3834
+ * @name hashkey#fetchFundingRateHistory
3835
+ * @description fetches historical funding rate prices
3836
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-futures-history-funding-rate
3837
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
3838
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
3839
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
3840
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3841
+ * @param {int} [params.fromId] the id of the entry to start from
3842
+ * @param {int} [params.endId] the id of the entry to end with
3843
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
3844
+ */
3845
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3846
+ await this.loadMarkets();
3847
+ if (symbol === undefined) {
3848
+ throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
3849
+ }
3850
+ const market = this.market(symbol);
3851
+ const request = {
3852
+ 'symbol': market['id'],
3853
+ };
3854
+ if (limit !== undefined) {
3855
+ request['limit'] = limit;
3856
+ }
3857
+ const response = await this.publicGetApiV1FuturesHistoryFundingRate(this.extend(request, params));
3858
+ //
3859
+ // [
3860
+ // {
3861
+ // "id": "10698",
3862
+ // "symbol": "ETHUSDT-PERPETUAL",
3863
+ // "settleTime": "1722268800000",
3864
+ // "settleRate": "0.0001"
3865
+ // },
3866
+ // ...
3867
+ // ]
3868
+ //
3869
+ const rates = [];
3870
+ for (let i = 0; i < response.length; i++) {
3871
+ const entry = response[i];
3872
+ const timestamp = this.safeInteger(entry, 'settleTime');
3873
+ rates.push({
3874
+ 'info': entry,
3875
+ 'symbol': this.safeSymbol(this.safeString(entry, 'symbol'), market, undefined, 'swap'),
3876
+ 'fundingRate': this.safeNumber(entry, 'settleRate'),
3877
+ 'timestamp': timestamp,
3878
+ 'datetime': this.iso8601(timestamp),
3879
+ });
3880
+ }
3881
+ const sorted = this.sortBy(rates, 'timestamp');
3882
+ return this.filterBySinceLimit(sorted, since, limit);
3883
+ }
3884
+ /**
3885
+ * @method
3886
+ * @description fetch open positions for a market
3887
+ * @name hashkey#fetchPositions
3888
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-futures-positions
3889
+ * @description fetch all open positions
3890
+ * @param {string[]|undefined} symbols list of unified market symbols
3891
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3892
+ * @param {string} [params.side] 'LONG' or 'SHORT' - the direction of the position (if not provided, positions for both sides will be returned)
3893
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3894
+ */
3895
+ async fetchPositions(symbols = undefined, params = {}) {
3896
+ const methodName = 'fetchPositions';
3897
+ if ((symbols === undefined)) {
3898
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires a symbol argument with one single market symbol');
3899
+ }
3900
+ else {
3901
+ const symbolsLength = symbols.length;
3902
+ if (symbolsLength !== 1) {
3903
+ throw new NotSupported(this.id + ' ' + methodName + '() is supported for a symbol argument with one single market symbol only');
3904
+ }
3905
+ }
3906
+ await this.loadMarkets();
3907
+ return await this.fetchPositionsForSymbol(symbols[0], this.extend({ 'methodName': 'fetchPositions' }, params));
3908
+ }
3909
+ /**
3910
+ * @method
3911
+ * @description fetch open positions for a single market
3912
+ * @name hashkey#fetchPositionsForSymbol
3913
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-futures-positions
3914
+ * @description fetch all open positions for specific symbol
3915
+ * @param {string} symbol unified market symbol
3916
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3917
+ * @param {string} [params.side] 'LONG' or 'SHORT' - the direction of the position (if not provided, positions for both sides will be returned)
3918
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3919
+ */
3920
+ async fetchPositionsForSymbol(symbol, params = {}) {
3921
+ await this.loadMarkets();
3922
+ const market = this.market(symbol);
3923
+ let methodName = 'fetchPosition';
3924
+ [methodName, params] = this.handleParamString(params, 'methodName', methodName);
3925
+ if (!market['swap']) {
3926
+ throw new NotSupported(this.id + ' ' + methodName + '() supports swap markets only');
3927
+ }
3928
+ const request = {
3929
+ 'symbol': market['id'],
3930
+ };
3931
+ const response = await this.privateGetApiV1FuturesPositions(this.extend(request, params));
3932
+ //
3933
+ // [
3934
+ // {
3935
+ // "symbol": "ETHUSDT-PERPETUAL",
3936
+ // "side": "LONG",
3937
+ // "avgPrice": "3327.52",
3938
+ // "position": "10",
3939
+ // "available": "0",
3940
+ // "leverage": "5",
3941
+ // "lastPrice": "3324.44",
3942
+ // "positionValue": "33.2752",
3943
+ // "liquidationPrice": "-953.83",
3944
+ // "margin": "6.9012",
3945
+ // "marginRate": "",
3946
+ // "unrealizedPnL": "-0.0288",
3947
+ // "profitRate": "-0.0041",
3948
+ // "realizedPnL": "-0.0199",
3949
+ // "minMargin": "0.2173"
3950
+ // }
3951
+ // ]
3952
+ //
3953
+ return this.parsePositions(response, [symbol]);
3954
+ }
3955
+ parsePosition(position, market = undefined) {
3956
+ const marketId = this.safeString(position, 'symbol');
3957
+ market = this.safeMarket(marketId, market);
3958
+ const symbol = market['symbol'];
3959
+ return this.safePosition({
3960
+ 'symbol': symbol,
3961
+ 'id': undefined,
3962
+ 'timestamp': undefined,
3963
+ 'datetime': undefined,
3964
+ 'contracts': this.safeNumber(position, 'position'),
3965
+ 'contractSize': undefined,
3966
+ 'side': this.safeStringLower(position, 'side'),
3967
+ 'notional': this.safeNumber(position, 'positionValue'),
3968
+ 'leverage': this.safeInteger(position, 'leverage'),
3969
+ 'unrealizedPnl': this.safeNumber(position, 'unrealizedPnL'),
3970
+ 'realizedPnl': this.safeNumber(position, 'realizedPnL'),
3971
+ 'collateral': undefined,
3972
+ 'entryPrice': this.safeNumber(position, 'avgPrice'),
3973
+ 'markPrice': undefined,
3974
+ 'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
3975
+ 'marginMode': 'cross',
3976
+ 'hedged': true,
3977
+ 'maintenanceMargin': this.safeNumber(position, 'minMargin'),
3978
+ 'maintenanceMarginPercentage': undefined,
3979
+ 'initialMargin': this.safeNumber(position, 'margin'),
3980
+ 'initialMarginPercentage': undefined,
3981
+ 'marginRatio': undefined,
3982
+ 'lastUpdateTimestamp': undefined,
3983
+ 'lastPrice': this.safeNumber(position, 'lastPrice'),
3984
+ 'stopLossPrice': undefined,
3985
+ 'takeProfitPrice': undefined,
3986
+ 'percentage': undefined,
3987
+ 'info': position,
3988
+ });
3989
+ }
3990
+ /**
3991
+ * @method
3992
+ * @name hashkey#fetchLeverage
3993
+ * @description fetch the set leverage for a market
3994
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/query-futures-leverage-trade
3995
+ * @param {string} symbol unified market symbol
3996
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3997
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
3998
+ */
3999
+ async fetchLeverage(symbol, params = {}) {
4000
+ await this.loadMarkets();
4001
+ const market = this.market(symbol);
4002
+ const request = {
4003
+ 'symbol': market['id'],
4004
+ };
4005
+ const response = await this.privateGetApiV1FuturesLeverage(this.extend(request, params));
4006
+ //
4007
+ // [
4008
+ // {
4009
+ // "symbolId": "ETHUSDT-PERPETUAL",
4010
+ // "leverage": "5",
4011
+ // "marginType": "CROSS"
4012
+ // }
4013
+ // ]
4014
+ //
4015
+ const leverage = this.safeDict(response, 0, {});
4016
+ return this.parseLeverage(leverage, market);
4017
+ }
4018
+ parseLeverage(leverage, market = undefined) {
4019
+ const marginMode = this.safeStringLower(leverage, 'marginType');
4020
+ const leverageValue = this.safeNumber(leverage, 'leverage');
4021
+ return {
4022
+ 'info': leverage,
4023
+ 'symbol': market['symbol'],
4024
+ 'marginMode': marginMode,
4025
+ 'longLeverage': leverageValue,
4026
+ 'shortLeverage': leverageValue,
4027
+ };
4028
+ }
4029
+ /**
4030
+ * @method
4031
+ * @name hashkey#setLeverage
4032
+ * @description set the level of leverage for a market
4033
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/change-futures-leverage-trade
4034
+ * @param {float} leverage the rate of leverage
4035
+ * @param {string} symbol unified market symbol
4036
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4037
+ * @returns {object} response from the exchange
4038
+ */
4039
+ async setLeverage(leverage, symbol = undefined, params = {}) {
4040
+ if (symbol === undefined) {
4041
+ throw new ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
4042
+ }
4043
+ await this.loadMarkets();
4044
+ const request = {
4045
+ 'leverage': leverage,
4046
+ };
4047
+ const market = this.market(symbol);
4048
+ request['symbol'] = market['id'];
4049
+ const response = await this.privatePostApiV1FuturesLeverage(this.extend(request, params));
4050
+ //
4051
+ // {
4052
+ // "code": "0000",
4053
+ // "symbolId": "ETHUSDT-PERPETUAL",
4054
+ // "leverage": "3"
4055
+ // }
4056
+ //
4057
+ return this.parseLeverage(response, market);
4058
+ }
4059
+ /**
4060
+ * @method
4061
+ * @name hashkey#fetchLeverageTiers
4062
+ * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
4063
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/exchangeinfo
4064
+ * @param {string[]|undefined} symbols list of unified market symbols
4065
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4066
+ * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
4067
+ */
4068
+ async fetchLeverageTiers(symbols = undefined, params = {}) {
4069
+ await this.loadMarkets();
4070
+ const response = await this.publicGetApiV1ExchangeInfo(params);
4071
+ // response is the same as in fetchMarkets()
4072
+ const data = this.safeList(response, 'contracts', []);
4073
+ symbols = this.marketSymbols(symbols);
4074
+ return this.parseLeverageTiers(data, symbols, 'symbol');
4075
+ }
4076
+ parseMarketLeverageTiers(info, market = undefined) {
4077
+ //
4078
+ // {
4079
+ // "filters": [
4080
+ // {
4081
+ // "minPrice": "0.1",
4082
+ // "maxPrice": "100000.00000000",
4083
+ // "tickSize": "0.1",
4084
+ // "filterType": "PRICE_FILTER"
4085
+ // },
4086
+ // {
4087
+ // "minQty": "0.001",
4088
+ // "maxQty": "10",
4089
+ // "stepSize": "0.001",
4090
+ // "marketOrderMinQty": "0",
4091
+ // "marketOrderMaxQty": "0",
4092
+ // "filterType": "LOT_SIZE"
4093
+ // },
4094
+ // {
4095
+ // "minNotional": "0",
4096
+ // "filterType": "MIN_NOTIONAL"
4097
+ // },
4098
+ // {
4099
+ // "maxSellPrice": "999999",
4100
+ // "buyPriceUpRate": "0.05",
4101
+ // "sellPriceDownRate": "0.05",
4102
+ // "maxEntrustNum": 200,
4103
+ // "maxConditionNum": 200,
4104
+ // "filterType": "LIMIT_TRADING"
4105
+ // },
4106
+ // {
4107
+ // "buyPriceUpRate": "0.05",
4108
+ // "sellPriceDownRate": "0.05",
4109
+ // "filterType": "MARKET_TRADING"
4110
+ // },
4111
+ // {
4112
+ // "noAllowMarketStartTime": "0",
4113
+ // "noAllowMarketEndTime": "0",
4114
+ // "limitOrderStartTime": "0",
4115
+ // "limitOrderEndTime": "0",
4116
+ // "limitMinPrice": "0",
4117
+ // "limitMaxPrice": "0",
4118
+ // "filterType": "OPEN_QUOTE"
4119
+ // }
4120
+ // ],
4121
+ // "exchangeId": "301",
4122
+ // "symbol": "BTCUSDT-PERPETUAL",
4123
+ // "symbolName": "BTCUSDT-PERPETUAL",
4124
+ // "status": "TRADING",
4125
+ // "baseAsset": "BTCUSDT-PERPETUAL",
4126
+ // "baseAssetPrecision": "0.001",
4127
+ // "quoteAsset": "USDT",
4128
+ // "quoteAssetPrecision": "0.1",
4129
+ // "icebergAllowed": false,
4130
+ // "inverse": false,
4131
+ // "index": "USDT",
4132
+ // "marginToken": "USDT",
4133
+ // "marginPrecision": "0.0001",
4134
+ // "contractMultiplier": "0.001",
4135
+ // "underlying": "BTC",
4136
+ // "riskLimits": [
4137
+ // {
4138
+ // "riskLimitId": "200000722",
4139
+ // "quantity": "1000.00",
4140
+ // "initialMargin": "0.10",
4141
+ // "maintMargin": "0.005",
4142
+ // "isWhite": false
4143
+ // },
4144
+ // {
4145
+ // "riskLimitId": "200000723",
4146
+ // "quantity": "2000.00",
4147
+ // "initialMargin": "0.10",
4148
+ // "maintMargin": "0.01",
4149
+ // "isWhite": false
4150
+ // }
4151
+ // ]
4152
+ // }
4153
+ //
4154
+ const riskLimits = this.safeList(info, 'riskLimits', []);
4155
+ const marketId = this.safeString(info, 'symbol');
4156
+ market = this.safeMarket(marketId, market);
4157
+ const tiers = [];
4158
+ for (let i = 0; i < riskLimits.length; i++) {
4159
+ const tier = riskLimits[i];
4160
+ const initialMarginRate = this.safeString(tier, 'initialMargin');
4161
+ tiers.push({
4162
+ 'tier': this.sum(i, 1),
4163
+ 'symbol': this.safeSymbol(marketId, market),
4164
+ 'currency': market['settle'],
4165
+ 'minNotional': undefined,
4166
+ 'maxNotional': this.safeNumber(tier, 'quantity'),
4167
+ 'maintenanceMarginRate': this.safeNumber(tier, 'maintMargin'),
4168
+ 'maxLeverage': this.parseNumber(Precise.stringDiv('1', initialMarginRate)),
4169
+ 'info': tier,
4170
+ });
4171
+ }
4172
+ return tiers;
4173
+ }
4174
+ /**
4175
+ * @method
4176
+ * @name hashkey#fetchTradingFee
4177
+ * @description fetch the trading fees for a market
4178
+ * @see https://developers.binance.com/docs/wallet/asset/trade-fee // spot
4179
+ * @see https://hashkeyglobal-apidoc.readme.io/reference/get-futures-commission-rate-request-weight // swap
4180
+ * @param {string} symbol unified market symbol
4181
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4182
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
4183
+ */
4184
+ async fetchTradingFee(symbol, params = {}) {
4185
+ await this.loadMarkets();
4186
+ const market = this.market(symbol);
4187
+ const methodName = 'fetchTradingFee';
4188
+ let response = undefined;
4189
+ if (market['spot']) {
4190
+ response = await this.fetchTradingFees(params);
4191
+ return this.safeDict(response, symbol);
4192
+ }
4193
+ else if (market['swap']) {
4194
+ response = await this.privateGetApiV1FuturesCommissionRate(this.extend({ 'symbol': market['id'] }, params));
4195
+ return this.parseTradingFee(response, market);
4196
+ //
4197
+ // {
4198
+ // "openMakerFee": "0.00025",
4199
+ // "openTakerFee": "0.0006",
4200
+ // "closeMakerFee": "0.00025",
4201
+ // "closeTakerFee": "0.0006"
4202
+ // }
4203
+ //
4204
+ }
4205
+ else {
4206
+ throw new NotSupported(this.id + ' ' + methodName + '() is not supported for ' + market['type'] + ' type of markets');
4207
+ }
4208
+ }
4209
+ /**
4210
+ * @method
4211
+ * @name hashkey#fetchTradingFees
4212
+ * @description *for spot markets only* fetch the trading fees for multiple markets
4213
+ * @see https://developers.binance.com/docs/wallet/asset/trade-fee
4214
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4215
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
4216
+ */
4217
+ async fetchTradingFees(params = {}) {
4218
+ await this.loadMarkets();
4219
+ const response = await this.privateGetApiV1AccountVipInfo(params);
4220
+ //
4221
+ // {
4222
+ // "code": 0,
4223
+ // "vipLevel": "0",
4224
+ // "tradeVol30Day": "67",
4225
+ // "totalAssetBal": "0",
4226
+ // "data": [
4227
+ // {
4228
+ // "symbol": "UXLINKUSDT",
4229
+ // "productType": "Token-Token",
4230
+ // "buyMakerFeeCurrency": "UXLINK",
4231
+ // "buyTakerFeeCurrency": "UXLINK",
4232
+ // "sellMakerFeeCurrency": "USDT",
4233
+ // "sellTakerFeeCurrency": "USDT",
4234
+ // "actualMakerRate": "0.0012",
4235
+ // "actualTakerRate": "0.0012"
4236
+ // },
4237
+ // ...
4238
+ // ],
4239
+ // "updateTimestamp": "1722320137809"
4240
+ // }
4241
+ //
4242
+ const data = this.safeList(response, 'data', []);
4243
+ const result = {};
4244
+ for (let i = 0; i < data.length; i++) {
4245
+ const fee = this.safeDict(data, i, {});
4246
+ const parsedFee = this.parseTradingFee(fee);
4247
+ result[parsedFee['symbol']] = parsedFee;
4248
+ }
4249
+ return result;
4250
+ }
4251
+ parseTradingFee(fee, market = undefined) {
4252
+ //
4253
+ // spot
4254
+ // {
4255
+ // "symbol": "UXLINKUSDT",
4256
+ // "productType": "Token-Token",
4257
+ // "buyMakerFeeCurrency": "UXLINK",
4258
+ // "buyTakerFeeCurrency": "UXLINK",
4259
+ // "sellMakerFeeCurrency": "USDT",
4260
+ // "sellTakerFeeCurrency": "USDT",
4261
+ // "actualMakerRate": "0.0012",
4262
+ // "actualTakerRate": "0.0012"
4263
+ // }
4264
+ //
4265
+ // swap
4266
+ // {
4267
+ // "openMakerFee": "0.00025",
4268
+ // "openTakerFee": "0.0006",
4269
+ // "closeMakerFee": "0.00025",
4270
+ // "closeTakerFee": "0.0006"
4271
+ // }
4272
+ //
4273
+ const marketId = this.safeString(fee, 'symbol');
4274
+ market = this.safeMarket(marketId, market);
4275
+ return {
4276
+ 'info': fee,
4277
+ 'symbol': market['symbol'],
4278
+ 'maker': this.safeNumber2(fee, 'openMakerFee', 'actualMakerRate'),
4279
+ 'taker': this.safeNumber2(fee, 'openTakerFee', 'actualTakerRate'),
4280
+ 'percentage': true,
4281
+ 'tierBased': true,
4282
+ };
4283
+ }
4284
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
4285
+ let url = this.urls['api'][api] + '/' + path;
4286
+ let query = undefined;
4287
+ if (api === 'private') {
4288
+ this.checkRequiredCredentials();
4289
+ const timestamp = this.milliseconds();
4290
+ const additionalParams = {
4291
+ 'timestamp': timestamp,
4292
+ };
4293
+ const recvWindow = this.safeInteger(this.options, 'recvWindow');
4294
+ if (recvWindow !== undefined) {
4295
+ additionalParams['recvWindow'] = recvWindow;
4296
+ }
4297
+ headers = {
4298
+ 'X-HK-APIKEY': this.apiKey,
4299
+ 'Content-Type': 'application/x-www-form-urlencoded',
4300
+ };
4301
+ let signature = undefined;
4302
+ if ((method === 'POST') && ((path === 'api/v1/spot/batchOrders') || (path === 'api/v1/futures/batchOrders'))) {
4303
+ headers['Content-Type'] = 'application/json';
4304
+ body = this.json(this.safeList(params, 'orders'));
4305
+ signature = this.hmac(this.encode(this.customUrlencode(additionalParams)), this.encode(this.secret), sha256);
4306
+ query = this.customUrlencode(this.extend(additionalParams, { 'signature': signature }));
4307
+ url += '?' + query;
4308
+ }
4309
+ else {
4310
+ const totalParams = this.extend(additionalParams, params);
4311
+ signature = this.hmac(this.encode(this.customUrlencode(totalParams)), this.encode(this.secret), sha256);
4312
+ totalParams['signature'] = signature;
4313
+ query = this.customUrlencode(totalParams);
4314
+ if (method === 'GET') {
4315
+ url += '?' + query;
4316
+ }
4317
+ else {
4318
+ body = query;
4319
+ }
4320
+ }
4321
+ headers['INPUT-SOURCE'] = this.safeString(this.options, 'broker', '10000700011');
4322
+ headers['broker_sign'] = signature;
4323
+ }
4324
+ else {
4325
+ query = this.urlencode(params);
4326
+ if (query.length !== 0) {
4327
+ url += '?' + query;
4328
+ }
4329
+ }
4330
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
4331
+ }
4332
+ customUrlencode(params = {}) {
4333
+ let result = this.urlencode(params);
4334
+ result = result.replace('%2C', ',');
4335
+ return result;
4336
+ }
4337
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
4338
+ if (response === undefined) {
4339
+ return undefined;
4340
+ }
4341
+ let errorInArray = false;
4342
+ let responseCodeString = this.safeString(response, 'code', undefined);
4343
+ const responseCodeInteger = this.safeInteger(response, 'code', undefined); // some codes in response are returned as '0000' others as 0
4344
+ if (responseCodeInteger === 0) {
4345
+ const result = this.safeList(response, 'result', []); // for batch methods
4346
+ for (let i = 0; i < result.length; i++) {
4347
+ const entry = this.safeDict(result, i);
4348
+ const entryCodeInteger = this.safeInteger(entry, 'code');
4349
+ if (entryCodeInteger !== 0) {
4350
+ errorInArray = true;
4351
+ responseCodeString = this.safeString(entry, 'code');
4352
+ }
4353
+ }
4354
+ }
4355
+ if ((code !== 200) || errorInArray) {
4356
+ const feedback = this.id + ' ' + body;
4357
+ this.throwBroadlyMatchedException(this.exceptions['broad'], responseCodeString, feedback);
4358
+ this.throwExactlyMatchedException(this.exceptions['exact'], responseCodeString, feedback);
4359
+ throw new ExchangeError(feedback);
4360
+ }
4361
+ return undefined;
4362
+ }
4363
+ }