ccxt-ir 4.9.32 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1059) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +7 -1
  4. package/dist/cjs/package.json +1 -1
  5. package/dist/cjs/src/abstract/asretether.js +11 -0
  6. package/dist/cjs/src/abstract/bidarz.js +11 -0
  7. package/dist/cjs/src/asretether.js +325 -0
  8. package/dist/cjs/src/bidarz.js +337 -0
  9. package/dist/cjs/src/bit24.js +4 -3
  10. package/dist/cjs/src/raastin.js +144 -16
  11. package/js/ccxt.d.ts +8 -2
  12. package/js/ccxt.js +6 -2
  13. package/js/src/abstract/asretether.d.ts +8 -0
  14. package/js/src/abstract/asretether.js +11 -0
  15. package/js/src/abstract/bidarz.d.ts +9 -0
  16. package/js/src/abstract/bidarz.js +11 -0
  17. package/js/src/abstract/raastin.d.ts +1 -0
  18. package/js/src/asretether.d.ts +21 -0
  19. package/js/src/asretether.js +324 -0
  20. package/js/src/bidarz.d.ts +22 -0
  21. package/js/src/bidarz.js +336 -0
  22. package/js/src/bit24.js +4 -3
  23. package/js/src/raastin.d.ts +2 -0
  24. package/js/src/raastin.js +144 -16
  25. package/js/src/src/abantether.d.ts +21 -0
  26. package/js/src/src/abantether.js +353 -0
  27. package/js/src/src/abstract/abantether.d.ts +8 -0
  28. package/js/src/src/abstract/abantether.js +11 -0
  29. package/js/src/src/abstract/afratether.d.ts +9 -0
  30. package/js/src/src/abstract/afratether.js +11 -0
  31. package/js/src/src/abstract/alpaca.d.ts +77 -0
  32. package/js/src/src/abstract/alpaca.js +11 -0
  33. package/js/src/src/abstract/apex.d.ts +34 -0
  34. package/js/src/src/abstract/apex.js +11 -0
  35. package/js/src/src/abstract/arzinja.d.ts +8 -0
  36. package/js/src/src/abstract/arzinja.js +11 -0
  37. package/js/src/src/abstract/arzplus.d.ts +11 -0
  38. package/js/src/src/abstract/arzplus.js +11 -0
  39. package/js/src/src/abstract/ascendex.d.ts +80 -0
  40. package/js/src/src/abstract/ascendex.js +11 -0
  41. package/js/src/src/abstract/asretether.d.ts +8 -0
  42. package/js/src/src/abstract/asretether.js +11 -0
  43. package/js/src/src/abstract/bidarz.d.ts +9 -0
  44. package/js/src/src/abstract/bidarz.js +11 -0
  45. package/js/src/src/abstract/bigone.d.ts +48 -0
  46. package/js/src/src/abstract/bigone.js +11 -0
  47. package/js/src/src/abstract/binance.d.ts +773 -0
  48. package/js/src/src/abstract/binance.js +11 -0
  49. package/js/src/src/abstract/bingx.d.ts +165 -0
  50. package/js/src/src/abstract/bingx.js +11 -0
  51. package/js/src/src/abstract/bit24.d.ts +9 -0
  52. package/js/src/src/abstract/bit24.js +11 -0
  53. package/js/src/src/abstract/bit2c.d.ts +30 -0
  54. package/js/src/src/abstract/bit2c.js +11 -0
  55. package/js/src/src/abstract/bitbank.d.ts +35 -0
  56. package/js/src/src/abstract/bitbank.js +11 -0
  57. package/js/src/src/abstract/bitbarg.d.ts +8 -0
  58. package/js/src/src/abstract/bitbarg.js +11 -0
  59. package/js/src/src/abstract/bitbns.d.ts +43 -0
  60. package/js/src/src/abstract/bitbns.js +11 -0
  61. package/js/src/src/abstract/bitfinex.d.ts +143 -0
  62. package/js/src/src/abstract/bitfinex.js +11 -0
  63. package/js/src/src/abstract/bitflyer.d.ts +42 -0
  64. package/js/src/src/abstract/bitflyer.js +11 -0
  65. package/js/src/src/abstract/bitget.d.ts +578 -0
  66. package/js/src/src/abstract/bitget.js +11 -0
  67. package/js/src/src/abstract/bithumb.d.ts +35 -0
  68. package/js/src/src/abstract/bithumb.js +11 -0
  69. package/js/src/src/abstract/bitimen.d.ts +10 -0
  70. package/js/src/src/abstract/bitimen.js +11 -0
  71. package/js/src/src/abstract/bitir.d.ts +10 -0
  72. package/js/src/src/abstract/bitir.js +11 -0
  73. package/js/src/src/abstract/bitmart.d.ts +120 -0
  74. package/js/src/src/abstract/bitmart.js +11 -0
  75. package/js/src/src/abstract/bitmex.d.ts +100 -0
  76. package/js/src/src/abstract/bitmex.js +11 -0
  77. package/js/src/src/abstract/bitopro.d.ts +33 -0
  78. package/js/src/src/abstract/bitopro.js +11 -0
  79. package/js/src/src/abstract/bitpin.d.ts +11 -0
  80. package/js/src/src/abstract/bitpin.js +11 -0
  81. package/js/src/src/abstract/bitrue.d.ts +75 -0
  82. package/js/src/src/abstract/bitrue.js +11 -0
  83. package/js/src/src/abstract/bitso.d.ts +46 -0
  84. package/js/src/src/abstract/bitso.js +11 -0
  85. package/js/src/src/abstract/bitstamp.d.ts +262 -0
  86. package/js/src/src/abstract/bitstamp.js +11 -0
  87. package/js/src/src/abstract/bitteam.d.ts +32 -0
  88. package/js/src/src/abstract/bitteam.js +11 -0
  89. package/js/src/src/abstract/bittrade.d.ts +117 -0
  90. package/js/src/src/abstract/bittrade.js +11 -0
  91. package/js/src/src/abstract/bitunix.d.ts +9 -0
  92. package/js/src/src/abstract/bitunix.js +11 -0
  93. package/js/src/src/abstract/bitvavo.d.ts +30 -0
  94. package/js/src/src/abstract/bitvavo.js +11 -0
  95. package/js/src/src/abstract/blockchaincom.d.ts +31 -0
  96. package/js/src/src/abstract/blockchaincom.js +11 -0
  97. package/js/src/src/abstract/blofin.d.ts +70 -0
  98. package/js/src/src/abstract/blofin.js +11 -0
  99. package/js/src/src/abstract/btcalpha.d.ts +21 -0
  100. package/js/src/src/abstract/btcalpha.js +11 -0
  101. package/js/src/src/abstract/btcbox.d.ts +18 -0
  102. package/js/src/src/abstract/btcbox.js +11 -0
  103. package/js/src/src/abstract/btcmarkets.d.ts +42 -0
  104. package/js/src/src/abstract/btcmarkets.js +11 -0
  105. package/js/src/src/abstract/btcturk.d.ts +23 -0
  106. package/js/src/src/abstract/btcturk.js +11 -0
  107. package/js/src/src/abstract/bybit.d.ts +316 -0
  108. package/js/src/src/abstract/bybit.js +11 -0
  109. package/js/src/src/abstract/bydfi.d.ts +11 -0
  110. package/js/src/src/abstract/bydfi.js +11 -0
  111. package/js/src/src/abstract/cafearz.d.ts +8 -0
  112. package/js/src/src/abstract/cafearz.js +11 -0
  113. package/js/src/src/abstract/cex.d.ts +35 -0
  114. package/js/src/src/abstract/cex.js +11 -0
  115. package/js/src/src/abstract/coinbase.d.ts +97 -0
  116. package/js/src/src/abstract/coinbase.js +11 -0
  117. package/js/src/src/abstract/coinbaseexchange.d.ts +71 -0
  118. package/js/src/src/abstract/coinbaseexchange.js +11 -0
  119. package/js/src/src/abstract/coinbaseinternational.d.ts +42 -0
  120. package/js/src/src/abstract/coinbaseinternational.js +11 -0
  121. package/js/src/src/abstract/coincatch.d.ts +97 -0
  122. package/js/src/src/abstract/coincatch.js +11 -0
  123. package/js/src/src/abstract/coincheck.d.ts +36 -0
  124. package/js/src/src/abstract/coincheck.js +11 -0
  125. package/js/src/src/abstract/coinex.d.ts +240 -0
  126. package/js/src/src/abstract/coinex.js +11 -0
  127. package/js/src/src/abstract/coinmate.d.ts +65 -0
  128. package/js/src/src/abstract/coinmate.js +11 -0
  129. package/js/src/src/abstract/coinmetro.d.ts +37 -0
  130. package/js/src/src/abstract/coinmetro.js +11 -0
  131. package/js/src/src/abstract/coinone.d.ts +70 -0
  132. package/js/src/src/abstract/coinone.js +11 -0
  133. package/js/src/src/abstract/coinsph.d.ts +57 -0
  134. package/js/src/src/abstract/coinsph.js +11 -0
  135. package/js/src/src/abstract/coinspot.d.ts +31 -0
  136. package/js/src/src/abstract/coinspot.js +11 -0
  137. package/js/src/src/abstract/cryptocom.d.ts +126 -0
  138. package/js/src/src/abstract/cryptocom.js +11 -0
  139. package/js/src/src/abstract/cryptomus.d.ts +23 -0
  140. package/js/src/src/abstract/cryptomus.js +11 -0
  141. package/js/src/src/abstract/defx.d.ts +72 -0
  142. package/js/src/src/abstract/defx.js +11 -0
  143. package/js/src/src/abstract/delta.d.ts +53 -0
  144. package/js/src/src/abstract/delta.js +11 -0
  145. package/js/src/src/abstract/deribit.d.ts +129 -0
  146. package/js/src/src/abstract/deribit.js +11 -0
  147. package/js/src/src/abstract/derive.d.ts +120 -0
  148. package/js/src/src/abstract/derive.js +11 -0
  149. package/js/src/src/abstract/digifinex.d.ts +95 -0
  150. package/js/src/src/abstract/digifinex.js +11 -0
  151. package/js/src/src/abstract/ellipx.d.ts +28 -0
  152. package/js/src/src/abstract/ellipx.js +11 -0
  153. package/js/src/src/abstract/eterex.d.ts +8 -0
  154. package/js/src/src/abstract/eterex.js +11 -0
  155. package/js/src/src/abstract/excoino.d.ts +10 -0
  156. package/js/src/src/abstract/excoino.js +11 -0
  157. package/js/src/src/abstract/exir.d.ts +11 -0
  158. package/js/src/src/abstract/exir.js +11 -0
  159. package/js/src/src/abstract/exmo.d.ts +58 -0
  160. package/js/src/src/abstract/exmo.js +11 -0
  161. package/js/src/src/abstract/exnovin.d.ts +9 -0
  162. package/js/src/src/abstract/exnovin.js +11 -0
  163. package/js/src/src/abstract/farhadexchange.d.ts +8 -0
  164. package/js/src/src/abstract/farhadexchange.js +11 -0
  165. package/js/src/src/abstract/foxbit.d.ts +29 -0
  166. package/js/src/src/abstract/foxbit.js +11 -0
  167. package/js/src/src/abstract/gate.d.ts +287 -0
  168. package/js/src/src/abstract/gate.js +11 -0
  169. package/js/src/src/abstract/gemini.d.ts +62 -0
  170. package/js/src/src/abstract/gemini.js +11 -0
  171. package/js/src/src/abstract/hamtapay.d.ts +9 -0
  172. package/js/src/src/abstract/hamtapay.js +11 -0
  173. package/js/src/src/abstract/hashkey.d.ts +70 -0
  174. package/js/src/src/abstract/hashkey.js +11 -0
  175. package/js/src/src/abstract/hibachi.d.ts +29 -0
  176. package/js/src/src/abstract/hibachi.js +11 -0
  177. package/js/src/src/abstract/hitbtc.d.ts +118 -0
  178. package/js/src/src/abstract/hitbtc.js +11 -0
  179. package/js/src/src/abstract/hitobit.d.ts +11 -0
  180. package/js/src/src/abstract/hitobit.js +11 -0
  181. package/js/src/src/abstract/hollaex.d.ts +36 -0
  182. package/js/src/src/abstract/hollaex.js +11 -0
  183. package/js/src/src/abstract/htx.d.ts +551 -0
  184. package/js/src/src/abstract/htx.js +11 -0
  185. package/js/src/src/abstract/hyperliquid.d.ts +9 -0
  186. package/js/src/src/abstract/hyperliquid.js +11 -0
  187. package/js/src/src/abstract/independentreserve.d.ts +46 -0
  188. package/js/src/src/abstract/independentreserve.js +11 -0
  189. package/js/src/src/abstract/indodax.d.ts +29 -0
  190. package/js/src/src/abstract/indodax.js +11 -0
  191. package/js/src/src/abstract/iranexchange.d.ts +9 -0
  192. package/js/src/src/abstract/iranexchange.js +11 -0
  193. package/js/src/src/abstract/jibitex.d.ts +10 -0
  194. package/js/src/src/abstract/jibitex.js +11 -0
  195. package/js/src/src/abstract/kcex.d.ts +10 -0
  196. package/js/src/src/abstract/kcex.js +11 -0
  197. package/js/src/src/abstract/kifpoolme.d.ts +9 -0
  198. package/js/src/src/abstract/kifpoolme.js +11 -0
  199. package/js/src/src/abstract/kraken.d.ts +61 -0
  200. package/js/src/src/abstract/kraken.js +11 -0
  201. package/js/src/src/abstract/krakenfutures.d.ts +45 -0
  202. package/js/src/src/abstract/krakenfutures.js +11 -0
  203. package/js/src/src/abstract/kucoin.d.ts +227 -0
  204. package/js/src/src/abstract/kucoin.js +11 -0
  205. package/js/src/src/abstract/kucoinfutures.d.ts +254 -0
  206. package/js/src/src/abstract/kucoinfutures.js +11 -0
  207. package/js/src/src/abstract/latoken.d.ts +59 -0
  208. package/js/src/src/abstract/latoken.js +11 -0
  209. package/js/src/src/abstract/lbank.d.ts +65 -0
  210. package/js/src/src/abstract/lbank.js +11 -0
  211. package/js/src/src/abstract/luno.d.ts +41 -0
  212. package/js/src/src/abstract/luno.js +11 -0
  213. package/js/src/src/abstract/mazdax.d.ts +11 -0
  214. package/js/src/src/abstract/mazdax.js +11 -0
  215. package/js/src/src/abstract/mercado.d.ts +28 -0
  216. package/js/src/src/abstract/mercado.js +11 -0
  217. package/js/src/src/abstract/mexc.d.ts +183 -0
  218. package/js/src/src/abstract/mexc.js +11 -0
  219. package/js/src/src/abstract/modetrade.d.ts +122 -0
  220. package/js/src/src/abstract/modetrade.js +11 -0
  221. package/js/src/src/abstract/ndax.d.ts +100 -0
  222. package/js/src/src/abstract/ndax.js +11 -0
  223. package/js/src/src/abstract/nobitex.d.ts +10 -0
  224. package/js/src/src/abstract/nobitex.js +11 -0
  225. package/js/src/src/abstract/novadax.d.ts +32 -0
  226. package/js/src/src/abstract/novadax.js +11 -0
  227. package/js/src/src/abstract/oceanex.d.ts +30 -0
  228. package/js/src/src/abstract/oceanex.js +11 -0
  229. package/js/src/src/abstract/okcoin.d.ts +77 -0
  230. package/js/src/src/abstract/okcoin.js +11 -0
  231. package/js/src/src/abstract/okexchange.d.ts +11 -0
  232. package/js/src/src/abstract/okexchange.js +11 -0
  233. package/js/src/src/abstract/okx.d.ts +352 -0
  234. package/js/src/src/abstract/okx.js +11 -0
  235. package/js/src/src/abstract/ompfinex.d.ts +10 -0
  236. package/js/src/src/abstract/ompfinex.js +11 -0
  237. package/js/src/src/abstract/onetrading.d.ts +26 -0
  238. package/js/src/src/abstract/onetrading.js +11 -0
  239. package/js/src/src/abstract/oxfun.d.ts +37 -0
  240. package/js/src/src/abstract/oxfun.js +11 -0
  241. package/js/src/src/abstract/p2b.d.ts +25 -0
  242. package/js/src/src/abstract/p2b.js +11 -0
  243. package/js/src/src/abstract/paradex.d.ts +66 -0
  244. package/js/src/src/abstract/paradex.js +11 -0
  245. package/js/src/src/abstract/paymium.d.ts +31 -0
  246. package/js/src/src/abstract/paymium.js +11 -0
  247. package/js/src/src/abstract/phemex.d.ts +120 -0
  248. package/js/src/src/abstract/phemex.js +11 -0
  249. package/js/src/src/abstract/pingi.d.ts +9 -0
  250. package/js/src/src/abstract/pingi.js +11 -0
  251. package/js/src/src/abstract/poloniex.d.ts +108 -0
  252. package/js/src/src/abstract/poloniex.js +11 -0
  253. package/js/src/src/abstract/pooleno.d.ts +8 -0
  254. package/js/src/src/abstract/pooleno.js +11 -0
  255. package/js/src/src/abstract/probit.d.ts +26 -0
  256. package/js/src/src/abstract/probit.js +11 -0
  257. package/js/src/src/abstract/raastin.d.ts +11 -0
  258. package/js/src/src/abstract/raastin.js +11 -0
  259. package/js/src/src/abstract/ramzinex.d.ts +10 -0
  260. package/js/src/src/abstract/ramzinex.js +11 -0
  261. package/js/src/src/abstract/sarmayex.d.ts +8 -0
  262. package/js/src/src/abstract/sarmayex.js +11 -0
  263. package/js/src/src/abstract/sarrafex.d.ts +10 -0
  264. package/js/src/src/abstract/sarrafex.js +11 -0
  265. package/js/src/src/abstract/tabdeal.d.ts +10 -0
  266. package/js/src/src/abstract/tabdeal.js +11 -0
  267. package/js/src/src/abstract/tehran_exchange.d.ts +9 -0
  268. package/js/src/src/abstract/tehran_exchange.js +11 -0
  269. package/js/src/src/abstract/tetherland.d.ts +8 -0
  270. package/js/src/src/abstract/tetherland.js +11 -0
  271. package/js/src/src/abstract/timex.d.ts +65 -0
  272. package/js/src/src/abstract/timex.js +11 -0
  273. package/js/src/src/abstract/tokocrypto.d.ts +40 -0
  274. package/js/src/src/abstract/tokocrypto.js +11 -0
  275. package/js/src/src/abstract/toobit.d.ts +10 -0
  276. package/js/src/src/abstract/toobit.js +11 -0
  277. package/js/src/src/abstract/tradeogre.d.ts +21 -0
  278. package/js/src/src/abstract/tradeogre.js +11 -0
  279. package/js/src/src/abstract/twox.d.ts +8 -0
  280. package/js/src/src/abstract/twox.js +11 -0
  281. package/js/src/src/abstract/ubitex.d.ts +10 -0
  282. package/js/src/src/abstract/ubitex.js +11 -0
  283. package/js/src/src/abstract/upbit.d.ts +58 -0
  284. package/js/src/src/abstract/upbit.js +11 -0
  285. package/js/src/src/abstract/vertex.d.ts +22 -0
  286. package/js/src/src/abstract/vertex.js +11 -0
  287. package/js/src/src/abstract/wallex.d.ts +11 -0
  288. package/js/src/src/abstract/wallex.js +11 -0
  289. package/js/src/src/abstract/wavesexchange.d.ts +157 -0
  290. package/js/src/src/abstract/wavesexchange.js +11 -0
  291. package/js/src/src/abstract/whitebit.d.ts +117 -0
  292. package/js/src/src/abstract/whitebit.js +11 -0
  293. package/js/src/src/abstract/woo.d.ts +144 -0
  294. package/js/src/src/abstract/woo.js +11 -0
  295. package/js/src/src/abstract/woofipro.d.ts +122 -0
  296. package/js/src/src/abstract/woofipro.js +11 -0
  297. package/js/src/src/abstract/xt.d.ts +160 -0
  298. package/js/src/src/abstract/xt.js +11 -0
  299. package/js/src/src/abstract/yobit.d.ts +19 -0
  300. package/js/src/src/abstract/yobit.js +11 -0
  301. package/js/src/src/abstract/zaif.d.ts +41 -0
  302. package/js/src/src/abstract/zaif.js +11 -0
  303. package/js/src/src/abstract/zonda.d.ts +56 -0
  304. package/js/src/src/abstract/zonda.js +11 -0
  305. package/js/src/src/afratether.d.ts +21 -0
  306. package/js/src/src/afratether.js +356 -0
  307. package/js/src/src/alpaca.d.ts +332 -0
  308. package/js/src/src/alpaca.js +1908 -0
  309. package/js/src/src/apex.d.ts +333 -0
  310. package/js/src/src/apex.js +1942 -0
  311. package/js/src/src/arzinja.d.ts +21 -0
  312. package/js/src/src/arzinja.js +298 -0
  313. package/js/src/src/arzplus.d.ts +26 -0
  314. package/js/src/src/arzplus.js +581 -0
  315. package/js/src/src/ascendex.d.ts +424 -0
  316. package/js/src/src/ascendex.js +3699 -0
  317. package/js/src/src/asretether.d.ts +21 -0
  318. package/js/src/src/asretether.js +324 -0
  319. package/js/src/src/base/Exchange.d.ts +926 -0
  320. package/js/src/src/base/Exchange.js +7399 -0
  321. package/js/src/src/base/Precise.d.ts +42 -0
  322. package/js/src/src/base/Precise.js +275 -0
  323. package/js/src/src/base/errors.d.ts +168 -0
  324. package/js/src/src/base/errors.js +255 -0
  325. package/js/src/src/base/functions/crypto.d.ts +16 -0
  326. package/js/src/src/base/functions/crypto.js +131 -0
  327. package/js/src/src/base/functions/encode.d.ts +4 -0
  328. package/js/src/src/base/functions/encode.js +32 -0
  329. package/js/src/src/base/functions/generic.d.ts +29 -0
  330. package/js/src/src/base/functions/generic.js +203 -0
  331. package/js/src/src/base/functions/misc.d.ts +9 -0
  332. package/js/src/src/base/functions/misc.js +101 -0
  333. package/js/src/src/base/functions/number.d.ts +27 -0
  334. package/js/src/src/base/functions/number.js +313 -0
  335. package/js/src/src/base/functions/platform.d.ts +7 -0
  336. package/js/src/src/base/functions/platform.js +27 -0
  337. package/js/src/src/base/functions/rsa.d.ts +5 -0
  338. package/js/src/src/base/functions/rsa.js +49 -0
  339. package/js/src/src/base/functions/string.d.ts +7 -0
  340. package/js/src/src/base/functions/string.js +44 -0
  341. package/js/src/src/base/functions/throttle.d.ts +6 -0
  342. package/js/src/src/base/functions/throttle.js +67 -0
  343. package/js/src/src/base/functions/time.d.ts +21 -0
  344. package/js/src/src/base/functions/time.js +171 -0
  345. package/js/src/src/base/functions/totp.d.ts +3 -0
  346. package/js/src/src/base/functions/totp.js +25 -0
  347. package/js/src/src/base/functions/type.d.ts +37 -0
  348. package/js/src/src/base/functions/type.js +179 -0
  349. package/js/src/src/base/functions.d.ts +10 -0
  350. package/js/src/src/base/functions.js +18 -0
  351. package/js/src/src/base/types.d.ts +586 -0
  352. package/js/src/src/base/types.js +7 -0
  353. package/js/src/src/base/ws/Cache.d.ts +27 -0
  354. package/js/src/src/base/ws/Cache.js +260 -0
  355. package/js/src/src/base/ws/Client.d.ts +53 -0
  356. package/js/src/src/base/ws/Client.js +307 -0
  357. package/js/src/src/base/ws/Future.d.ts +8 -0
  358. package/js/src/src/base/ws/Future.js +35 -0
  359. package/js/src/src/base/ws/OrderBook.d.ts +25 -0
  360. package/js/src/src/base/ws/OrderBook.js +130 -0
  361. package/js/src/src/base/ws/OrderBookSide.d.ts +40 -0
  362. package/js/src/src/base/ws/OrderBookSide.js +286 -0
  363. package/js/src/src/base/ws/WsClient.d.ts +11 -0
  364. package/js/src/src/base/ws/WsClient.js +69 -0
  365. package/js/src/src/bequant.d.ts +4 -0
  366. package/js/src/src/bequant.js +35 -0
  367. package/js/src/src/bidarz.d.ts +16 -0
  368. package/js/src/src/bidarz.js +327 -0
  369. package/js/src/src/bigone.d.ts +296 -0
  370. package/js/src/src/bigone.js +2340 -0
  371. package/js/src/src/binance.d.ts +1667 -0
  372. package/js/src/src/binance.js +14400 -0
  373. package/js/src/src/binancecoinm.d.ts +6 -0
  374. package/js/src/src/binancecoinm.js +51 -0
  375. package/js/src/src/binanceus.d.ts +4 -0
  376. package/js/src/src/binanceus.js +225 -0
  377. package/js/src/src/binanceusdm.d.ts +6 -0
  378. package/js/src/src/binanceusdm.js +63 -0
  379. package/js/src/src/bingx.d.ts +778 -0
  380. package/js/src/src/bingx.js +6705 -0
  381. package/js/src/src/bit24.d.ts +24 -0
  382. package/js/src/src/bit24.js +520 -0
  383. package/js/src/src/bit2c.d.ts +146 -0
  384. package/js/src/src/bit2c.js +1029 -0
  385. package/js/src/src/bitbank.d.ts +181 -0
  386. package/js/src/src/bitbank.js +1146 -0
  387. package/js/src/src/bitbarg.d.ts +21 -0
  388. package/js/src/src/bitbarg.js +312 -0
  389. package/js/src/src/bitbns.d.ts +184 -0
  390. package/js/src/src/bitbns.js +1288 -0
  391. package/js/src/src/bitfinex.d.ts +516 -0
  392. package/js/src/src/bitfinex.js +3951 -0
  393. package/js/src/src/bitflyer.d.ts +229 -0
  394. package/js/src/src/bitflyer.js +1209 -0
  395. package/js/src/src/bitget.d.ts +1109 -0
  396. package/js/src/src/bitget.js +11033 -0
  397. package/js/src/src/bithumb.d.ts +165 -0
  398. package/js/src/src/bithumb.js +1257 -0
  399. package/js/src/src/bitimen.d.ts +23 -0
  400. package/js/src/src/bitimen.js +424 -0
  401. package/js/src/src/bitir.d.ts +23 -0
  402. package/js/src/src/bitir.js +521 -0
  403. package/js/src/src/bitmart.d.ts +736 -0
  404. package/js/src/src/bitmart.js +5639 -0
  405. package/js/src/src/bitmex.d.ts +395 -0
  406. package/js/src/src/bitmex.js +3088 -0
  407. package/js/src/src/bitopro.d.ts +295 -0
  408. package/js/src/src/bitopro.js +1892 -0
  409. package/js/src/src/bitpin.d.ts +23 -0
  410. package/js/src/src/bitpin.js +487 -0
  411. package/js/src/src/bitrue.d.ts +384 -0
  412. package/js/src/src/bitrue.js +3382 -0
  413. package/js/src/src/bitso.d.ts +270 -0
  414. package/js/src/src/bitso.js +1881 -0
  415. package/js/src/src/bitstamp.d.ts +355 -0
  416. package/js/src/src/bitstamp.js +2445 -0
  417. package/js/src/src/bitteam.d.ts +229 -0
  418. package/js/src/src/bitteam.js +2420 -0
  419. package/js/src/src/bittrade.d.ts +298 -0
  420. package/js/src/src/bittrade.js +2050 -0
  421. package/js/src/src/bitunix.d.ts +21 -0
  422. package/js/src/src/bitunix.js +326 -0
  423. package/js/src/src/bitvavo.d.ts +311 -0
  424. package/js/src/src/bitvavo.js +2204 -0
  425. package/js/src/src/blockchaincom.d.ts +256 -0
  426. package/js/src/src/blockchaincom.js +1259 -0
  427. package/js/src/src/blofin.d.ts +439 -0
  428. package/js/src/src/blofin.js +2576 -0
  429. package/js/src/src/btcalpha.d.ts +209 -0
  430. package/js/src/src/btcalpha.js +1056 -0
  431. package/js/src/src/btcbox.d.ts +144 -0
  432. package/js/src/src/btcbox.js +834 -0
  433. package/js/src/src/btcmarkets.d.ts +253 -0
  434. package/js/src/src/btcmarkets.js +1418 -0
  435. package/js/src/src/btcturk.d.ts +161 -0
  436. package/js/src/src/btcturk.js +1058 -0
  437. package/js/src/src/bybit.d.ts +1097 -0
  438. package/js/src/src/bybit.js +9382 -0
  439. package/js/src/src/bydfi.d.ts +23 -0
  440. package/js/src/src/bydfi.js +434 -0
  441. package/js/src/src/cafearz.d.ts +21 -0
  442. package/js/src/src/cafearz.js +346 -0
  443. package/js/src/src/cex.d.ts +286 -0
  444. package/js/src/src/cex.js +1799 -0
  445. package/js/src/src/coinbase.d.ts +623 -0
  446. package/js/src/src/coinbase.js +5220 -0
  447. package/js/src/src/coinbaseadvanced.d.ts +4 -0
  448. package/js/src/src/coinbaseadvanced.js +18 -0
  449. package/js/src/src/coinbaseexchange.d.ts +334 -0
  450. package/js/src/src/coinbaseexchange.js +2127 -0
  451. package/js/src/src/coinbaseinternational.d.ts +443 -0
  452. package/js/src/src/coinbaseinternational.js +2336 -0
  453. package/js/src/src/coincatch.d.ts +786 -0
  454. package/js/src/src/coincatch.js +5492 -0
  455. package/js/src/src/coincheck.d.ts +147 -0
  456. package/js/src/src/coincheck.js +962 -0
  457. package/js/src/src/coinex.d.ts +719 -0
  458. package/js/src/src/coinex.js +6166 -0
  459. package/js/src/src/coinmate.d.ts +202 -0
  460. package/js/src/src/coinmate.js +1215 -0
  461. package/js/src/src/coinmetro.d.ts +244 -0
  462. package/js/src/src/coinmetro.js +2024 -0
  463. package/js/src/src/coinone.d.ts +158 -0
  464. package/js/src/src/coinone.js +1278 -0
  465. package/js/src/src/coinsph.d.ts +310 -0
  466. package/js/src/src/coinsph.js +2203 -0
  467. package/js/src/src/coinspot.d.ts +108 -0
  468. package/js/src/src/coinspot.js +653 -0
  469. package/js/src/src/cryptocom.d.ts +463 -0
  470. package/js/src/src/cryptocom.js +3549 -0
  471. package/js/src/src/cryptomus.d.ts +158 -0
  472. package/js/src/src/cryptomus.js +1169 -0
  473. package/js/src/src/defx.d.ts +348 -0
  474. package/js/src/src/defx.js +2139 -0
  475. package/js/src/src/delta.d.ts +407 -0
  476. package/js/src/src/delta.js +3654 -0
  477. package/js/src/src/deribit.d.ts +516 -0
  478. package/js/src/src/deribit.js +3790 -0
  479. package/js/src/src/derive.d.ts +324 -0
  480. package/js/src/src/derive.js +2655 -0
  481. package/js/src/src/digifinex.d.ts +544 -0
  482. package/js/src/src/digifinex.js +4453 -0
  483. package/js/src/src/ellipx.d.ts +237 -0
  484. package/js/src/src/ellipx.js +2071 -0
  485. package/js/src/src/eterex.d.ts +21 -0
  486. package/js/src/src/eterex.js +299 -0
  487. package/js/src/src/excoino.d.ts +23 -0
  488. package/js/src/src/excoino.js +426 -0
  489. package/js/src/src/exir.d.ts +23 -0
  490. package/js/src/src/exir.js +403 -0
  491. package/js/src/src/exmo.d.ts +426 -0
  492. package/js/src/src/exmo.js +2825 -0
  493. package/js/src/src/exnovin.d.ts +22 -0
  494. package/js/src/src/exnovin.js +378 -0
  495. package/js/src/src/farhadexchange.d.ts +21 -0
  496. package/js/src/src/farhadexchange.js +280 -0
  497. package/js/src/src/fmfwio.d.ts +4 -0
  498. package/js/src/src/fmfwio.js +35 -0
  499. package/js/src/src/foxbit.d.ts +352 -0
  500. package/js/src/src/foxbit.js +2016 -0
  501. package/js/src/src/gate.d.ts +1071 -0
  502. package/js/src/src/gate.js +8282 -0
  503. package/js/src/src/gateio.d.ts +4 -0
  504. package/js/src/src/gateio.js +17 -0
  505. package/js/src/src/gemini.d.ts +257 -0
  506. package/js/src/src/gemini.js +2006 -0
  507. package/js/src/src/hamtapay.d.ts +21 -0
  508. package/js/src/src/hamtapay.js +303 -0
  509. package/js/src/src/hashkey.d.ts +628 -0
  510. package/js/src/src/hashkey.js +4363 -0
  511. package/js/src/src/hibachi.d.ts +346 -0
  512. package/js/src/src/hibachi.js +2137 -0
  513. package/js/src/src/hitbtc.d.ts +558 -0
  514. package/js/src/src/hitbtc.js +3847 -0
  515. package/js/src/src/hitobit.d.ts +23 -0
  516. package/js/src/src/hitobit.js +412 -0
  517. package/js/src/src/hollaex.d.ts +305 -0
  518. package/js/src/src/hollaex.js +2046 -0
  519. package/js/src/src/htx.d.ts +961 -0
  520. package/js/src/src/htx.js +9668 -0
  521. package/js/src/src/huobi.d.ts +4 -0
  522. package/js/src/src/huobi.js +17 -0
  523. package/js/src/src/hyperliquid.d.ts +651 -0
  524. package/js/src/src/hyperliquid.js +3937 -0
  525. package/js/src/src/independentreserve.d.ts +169 -0
  526. package/js/src/src/independentreserve.js +1115 -0
  527. package/js/src/src/indodax.d.ts +217 -0
  528. package/js/src/src/indodax.js +1454 -0
  529. package/js/src/src/iranexchange.d.ts +21 -0
  530. package/js/src/src/iranexchange.js +399 -0
  531. package/js/src/src/jibitex.d.ts +23 -0
  532. package/js/src/src/jibitex.js +416 -0
  533. package/js/src/src/kcex.d.ts +21 -0
  534. package/js/src/src/kcex.js +335 -0
  535. package/js/src/src/kifpoolme.d.ts +23 -0
  536. package/js/src/src/kifpoolme.js +410 -0
  537. package/js/src/src/kraken.d.ts +484 -0
  538. package/js/src/src/kraken.js +3518 -0
  539. package/js/src/src/krakenfutures.d.ts +362 -0
  540. package/js/src/src/krakenfutures.js +2885 -0
  541. package/js/src/src/kucoin.d.ts +759 -0
  542. package/js/src/src/kucoin.js +5153 -0
  543. package/js/src/src/kucoinfutures.d.ts +521 -0
  544. package/js/src/src/kucoinfutures.js +3381 -0
  545. package/js/src/src/latoken.d.ts +274 -0
  546. package/js/src/src/latoken.js +1824 -0
  547. package/js/src/src/lbank.d.ts +350 -0
  548. package/js/src/src/lbank.js +3146 -0
  549. package/js/src/src/luno.d.ts +252 -0
  550. package/js/src/src/luno.js +1479 -0
  551. package/js/src/src/mazdax.d.ts +23 -0
  552. package/js/src/src/mazdax.js +534 -0
  553. package/js/src/src/mercado.d.ts +160 -0
  554. package/js/src/src/mercado.js +1011 -0
  555. package/js/src/src/mexc.d.ts +768 -0
  556. package/js/src/src/mexc.js +6102 -0
  557. package/js/src/src/modetrade.d.ts +496 -0
  558. package/js/src/src/modetrade.js +2936 -0
  559. package/js/src/src/myokx.d.ts +4 -0
  560. package/js/src/src/myokx.js +54 -0
  561. package/js/src/src/ndax.d.ts +285 -0
  562. package/js/src/src/ndax.js +2598 -0
  563. package/js/src/src/nobitex.d.ts +23 -0
  564. package/js/src/src/nobitex.js +454 -0
  565. package/js/src/src/novadax.d.ts +279 -0
  566. package/js/src/src/novadax.js +1676 -0
  567. package/js/src/src/oceanex.d.ts +231 -0
  568. package/js/src/src/oceanex.js +1123 -0
  569. package/js/src/src/okcoin.d.ts +346 -0
  570. package/js/src/src/okcoin.js +3211 -0
  571. package/js/src/src/okexchange.d.ts +23 -0
  572. package/js/src/src/okexchange.js +373 -0
  573. package/js/src/src/okx.d.ts +1125 -0
  574. package/js/src/src/okx.js +9009 -0
  575. package/js/src/src/okxus.d.ts +4 -0
  576. package/js/src/src/okxus.js +54 -0
  577. package/js/src/src/ompfinex.d.ts +23 -0
  578. package/js/src/src/ompfinex.js +510 -0
  579. package/js/src/src/onetrading.d.ts +228 -0
  580. package/js/src/src/onetrading.js +1769 -0
  581. package/js/src/src/oxfun.d.ts +442 -0
  582. package/js/src/src/oxfun.js +2920 -0
  583. package/js/src/src/p2b.d.ts +189 -0
  584. package/js/src/src/p2b.js +1344 -0
  585. package/js/src/src/paradex.d.ts +389 -0
  586. package/js/src/src/paradex.js +2607 -0
  587. package/js/src/src/paymium.d.ts +133 -0
  588. package/js/src/src/paymium.js +644 -0
  589. package/js/src/src/phemex.d.ts +497 -0
  590. package/js/src/src/phemex.js +5333 -0
  591. package/js/src/src/pingi.d.ts +22 -0
  592. package/js/src/src/pingi.js +446 -0
  593. package/js/src/src/poloniex.d.ts +441 -0
  594. package/js/src/src/poloniex.js +3681 -0
  595. package/js/src/src/pooleno.d.ts +21 -0
  596. package/js/src/src/pooleno.js +347 -0
  597. package/js/src/src/pro/alpaca.d.ts +95 -0
  598. package/js/src/src/pro/alpaca.js +724 -0
  599. package/js/src/src/pro/apex.d.ts +160 -0
  600. package/js/src/src/pro/apex.js +1044 -0
  601. package/js/src/src/pro/ascendex.d.ts +99 -0
  602. package/js/src/src/pro/ascendex.js +1012 -0
  603. package/js/src/src/pro/bequant.d.ts +4 -0
  604. package/js/src/src/pro/bequant.js +42 -0
  605. package/js/src/src/pro/binance.d.ts +796 -0
  606. package/js/src/src/pro/binance.js +4373 -0
  607. package/js/src/src/pro/binancecoinm.d.ts +4 -0
  608. package/js/src/src/pro/binancecoinm.js +32 -0
  609. package/js/src/src/pro/binanceus.d.ts +4 -0
  610. package/js/src/src/pro/binanceus.js +52 -0
  611. package/js/src/src/pro/binanceusdm.d.ts +4 -0
  612. package/js/src/src/pro/binanceusdm.js +37 -0
  613. package/js/src/src/pro/bingx.d.ts +151 -0
  614. package/js/src/src/pro/bingx.js +1568 -0
  615. package/js/src/src/pro/bitfinex.d.ts +99 -0
  616. package/js/src/src/pro/bitfinex.js +1165 -0
  617. package/js/src/src/pro/bitget.d.ts +257 -0
  618. package/js/src/src/pro/bitget.js +2327 -0
  619. package/js/src/src/pro/bithumb.d.ts +59 -0
  620. package/js/src/src/pro/bithumb.js +395 -0
  621. package/js/src/src/pro/bitmart.d.ts +168 -0
  622. package/js/src/src/pro/bitmart.js +1686 -0
  623. package/js/src/src/pro/bitmex.d.ts +170 -0
  624. package/js/src/src/pro/bitmex.js +1760 -0
  625. package/js/src/src/pro/bitopro.d.ts +69 -0
  626. package/js/src/src/pro/bitopro.js +477 -0
  627. package/js/src/src/pro/bitrue.d.ts +40 -0
  628. package/js/src/src/pro/bitrue.js +461 -0
  629. package/js/src/src/pro/bitstamp.d.ts +53 -0
  630. package/js/src/src/pro/bitstamp.js +587 -0
  631. package/js/src/src/pro/bittrade.d.ts +66 -0
  632. package/js/src/src/pro/bittrade.js +606 -0
  633. package/js/src/src/pro/bitvavo.d.ts +321 -0
  634. package/js/src/src/pro/bitvavo.js +1451 -0
  635. package/js/src/src/pro/blockchaincom.d.ts +89 -0
  636. package/js/src/src/pro/blockchaincom.js +777 -0
  637. package/js/src/src/pro/blofin.d.ts +174 -0
  638. package/js/src/src/pro/blofin.js +743 -0
  639. package/js/src/src/pro/bybit.d.ts +397 -0
  640. package/js/src/src/pro/bybit.js +2519 -0
  641. package/js/src/src/pro/cex.d.ts +220 -0
  642. package/js/src/src/pro/cex.js +1535 -0
  643. package/js/src/src/pro/coinbase.d.ts +119 -0
  644. package/js/src/src/pro/coinbase.js +736 -0
  645. package/js/src/src/pro/coinbaseadvanced.d.ts +4 -0
  646. package/js/src/src/pro/coinbaseadvanced.js +18 -0
  647. package/js/src/src/pro/coinbaseexchange.d.ts +133 -0
  648. package/js/src/src/pro/coinbaseexchange.js +969 -0
  649. package/js/src/src/pro/coinbaseinternational.d.ts +143 -0
  650. package/js/src/src/pro/coinbaseinternational.js +804 -0
  651. package/js/src/src/pro/coincatch.d.ts +207 -0
  652. package/js/src/src/pro/coincatch.js +1562 -0
  653. package/js/src/src/pro/coincheck.d.ts +33 -0
  654. package/js/src/src/pro/coincheck.js +210 -0
  655. package/js/src/src/pro/coinex.d.ts +147 -0
  656. package/js/src/src/pro/coinex.js +1426 -0
  657. package/js/src/src/pro/coinone.d.ts +51 -0
  658. package/js/src/src/pro/coinone.js +413 -0
  659. package/js/src/src/pro/cryptocom.d.ts +300 -0
  660. package/js/src/src/pro/cryptocom.js +1414 -0
  661. package/js/src/src/pro/defx.d.ts +236 -0
  662. package/js/src/src/pro/defx.js +865 -0
  663. package/js/src/src/pro/deribit.d.ts +163 -0
  664. package/js/src/src/pro/deribit.js +1066 -0
  665. package/js/src/src/pro/derive.d.ts +100 -0
  666. package/js/src/src/pro/derive.js +753 -0
  667. package/js/src/src/pro/exmo.d.ts +97 -0
  668. package/js/src/src/pro/exmo.js +903 -0
  669. package/js/src/src/pro/gate.d.ts +360 -0
  670. package/js/src/src/pro/gate.js +2119 -0
  671. package/js/src/src/pro/gateio.d.ts +4 -0
  672. package/js/src/src/pro/gateio.js +17 -0
  673. package/js/src/src/pro/gemini.d.ts +106 -0
  674. package/js/src/src/pro/gemini.js +932 -0
  675. package/js/src/src/pro/hashkey.d.ts +121 -0
  676. package/js/src/src/pro/hashkey.js +843 -0
  677. package/js/src/src/pro/hitbtc.d.ts +235 -0
  678. package/js/src/src/pro/hitbtc.js +1400 -0
  679. package/js/src/src/pro/hollaex.d.ts +77 -0
  680. package/js/src/src/pro/hollaex.js +604 -0
  681. package/js/src/src/pro/htx.d.ts +141 -0
  682. package/js/src/src/pro/htx.js +2415 -0
  683. package/js/src/src/pro/huobi.d.ts +4 -0
  684. package/js/src/src/pro/huobi.js +17 -0
  685. package/js/src/src/pro/hyperliquid.d.ts +218 -0
  686. package/js/src/src/pro/hyperliquid.js +1126 -0
  687. package/js/src/src/pro/independentreserve.d.ts +36 -0
  688. package/js/src/src/pro/independentreserve.js +287 -0
  689. package/js/src/src/pro/kraken.d.ts +233 -0
  690. package/js/src/src/pro/kraken.js +1785 -0
  691. package/js/src/src/pro/krakenfutures.d.ts +178 -0
  692. package/js/src/src/pro/krakenfutures.js +1592 -0
  693. package/js/src/src/pro/kucoin.d.ts +221 -0
  694. package/js/src/src/pro/kucoin.js +1430 -0
  695. package/js/src/src/pro/kucoinfutures.d.ts +205 -0
  696. package/js/src/src/pro/kucoinfutures.js +1295 -0
  697. package/js/src/src/pro/lbank.d.ts +134 -0
  698. package/js/src/src/pro/lbank.js +950 -0
  699. package/js/src/src/pro/luno.d.ts +44 -0
  700. package/js/src/src/pro/luno.js +322 -0
  701. package/js/src/src/pro/mexc.d.ts +210 -0
  702. package/js/src/src/pro/mexc.js +2009 -0
  703. package/js/src/src/pro/modetrade.d.ts +155 -0
  704. package/js/src/src/pro/modetrade.js +1335 -0
  705. package/js/src/src/pro/myokx.d.ts +4 -0
  706. package/js/src/src/pro/myokx.js +39 -0
  707. package/js/src/src/pro/ndax.d.ts +60 -0
  708. package/js/src/src/pro/ndax.js +545 -0
  709. package/js/src/src/pro/okcoin.d.ts +91 -0
  710. package/js/src/src/pro/okcoin.js +763 -0
  711. package/js/src/src/pro/okx.d.ts +408 -0
  712. package/js/src/src/pro/okx.js +2479 -0
  713. package/js/src/src/pro/okxus.d.ts +4 -0
  714. package/js/src/src/pro/okxus.js +39 -0
  715. package/js/src/src/pro/onetrading.d.ts +107 -0
  716. package/js/src/src/pro/onetrading.js +1343 -0
  717. package/js/src/src/pro/oxfun.d.ts +234 -0
  718. package/js/src/src/pro/oxfun.js +1112 -0
  719. package/js/src/src/pro/p2b.d.ts +104 -0
  720. package/js/src/src/pro/p2b.js +506 -0
  721. package/js/src/src/pro/paradex.d.ts +54 -0
  722. package/js/src/src/pro/paradex.js +370 -0
  723. package/js/src/src/pro/phemex.d.ts +129 -0
  724. package/js/src/src/pro/phemex.js +1569 -0
  725. package/js/src/src/pro/poloniex.d.ts +214 -0
  726. package/js/src/src/pro/poloniex.js +1318 -0
  727. package/js/src/src/pro/probit.d.ts +91 -0
  728. package/js/src/src/pro/probit.js +593 -0
  729. package/js/src/src/pro/tradeogre.d.ts +49 -0
  730. package/js/src/src/pro/tradeogre.js +284 -0
  731. package/js/src/src/pro/upbit.d.ts +124 -0
  732. package/js/src/src/pro/upbit.js +689 -0
  733. package/js/src/src/pro/vertex.d.ts +104 -0
  734. package/js/src/src/pro/vertex.js +999 -0
  735. package/js/src/src/pro/whitebit.d.ts +123 -0
  736. package/js/src/src/pro/whitebit.js +971 -0
  737. package/js/src/src/pro/woo.d.ts +161 -0
  738. package/js/src/src/pro/woo.js +1351 -0
  739. package/js/src/src/pro/woofipro.d.ts +155 -0
  740. package/js/src/src/pro/woofipro.js +1335 -0
  741. package/js/src/src/pro/xt.d.ts +165 -0
  742. package/js/src/src/pro/xt.js +1230 -0
  743. package/js/src/src/probit.d.ts +283 -0
  744. package/js/src/src/probit.js +1935 -0
  745. package/js/src/src/protobuf/mexc/compiled.cjs +7186 -0
  746. package/js/src/src/protobuf/mexc/compiled.d.cts +8 -0
  747. package/js/src/src/raastin.d.ts +24 -0
  748. package/js/src/src/raastin.js +494 -0
  749. package/js/src/src/ramzinex.d.ts +23 -0
  750. package/js/src/src/ramzinex.js +510 -0
  751. package/js/src/src/sarmayex.d.ts +21 -0
  752. package/js/src/src/sarmayex.js +376 -0
  753. package/js/src/src/sarrafex.d.ts +23 -0
  754. package/js/src/src/sarrafex.js +501 -0
  755. package/js/src/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
  756. package/js/src/src/static_dependencies/ethers/abi-coder.js +148 -0
  757. package/js/src/src/static_dependencies/ethers/address/address.d.ts +55 -0
  758. package/js/src/src/static_dependencies/ethers/address/address.js +162 -0
  759. package/js/src/src/static_dependencies/ethers/address/checks.d.ts +80 -0
  760. package/js/src/src/static_dependencies/ethers/address/checks.js +119 -0
  761. package/js/src/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
  762. package/js/src/src/static_dependencies/ethers/address/contract-address.js +73 -0
  763. package/js/src/src/static_dependencies/ethers/address/index.d.ts +48 -0
  764. package/js/src/src/static_dependencies/ethers/address/index.js +24 -0
  765. package/js/src/src/static_dependencies/ethers/bytes32.d.ts +14 -0
  766. package/js/src/src/static_dependencies/ethers/bytes32.js +45 -0
  767. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
  768. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
  769. package/js/src/src/static_dependencies/ethers/coders/address.d.ts +12 -0
  770. package/js/src/src/static_dependencies/ethers/coders/address.js +34 -0
  771. package/js/src/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
  772. package/js/src/src/static_dependencies/ethers/coders/anonymous.js +27 -0
  773. package/js/src/src/static_dependencies/ethers/coders/array.d.ts +24 -0
  774. package/js/src/src/static_dependencies/ethers/coders/array.js +162 -0
  775. package/js/src/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
  776. package/js/src/src/static_dependencies/ethers/coders/boolean.js +26 -0
  777. package/js/src/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
  778. package/js/src/src/static_dependencies/ethers/coders/bytes.js +39 -0
  779. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
  780. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
  781. package/js/src/src/static_dependencies/ethers/coders/null.d.ts +11 -0
  782. package/js/src/src/static_dependencies/ethers/coders/null.js +29 -0
  783. package/js/src/src/static_dependencies/ethers/coders/number.d.ts +15 -0
  784. package/js/src/src/static_dependencies/ethers/coders/number.js +48 -0
  785. package/js/src/src/static_dependencies/ethers/coders/string.d.ts +12 -0
  786. package/js/src/src/static_dependencies/ethers/coders/string.js +26 -0
  787. package/js/src/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
  788. package/js/src/src/static_dependencies/ethers/coders/tuple.js +67 -0
  789. package/js/src/src/static_dependencies/ethers/fragments.d.ts +458 -0
  790. package/js/src/src/static_dependencies/ethers/fragments.js +1252 -0
  791. package/js/src/src/static_dependencies/ethers/hash/index.d.ts +10 -0
  792. package/js/src/src/static_dependencies/ethers/hash/index.js +15 -0
  793. package/js/src/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
  794. package/js/src/src/static_dependencies/ethers/hash/solidity.js +107 -0
  795. package/js/src/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
  796. package/js/src/src/static_dependencies/ethers/hash/typed-data.js +490 -0
  797. package/js/src/src/static_dependencies/ethers/index.d.ts +19 -0
  798. package/js/src/src/static_dependencies/ethers/index.js +22 -0
  799. package/js/src/src/static_dependencies/ethers/interface.d.ts +380 -0
  800. package/js/src/src/static_dependencies/ethers/interface.js +990 -0
  801. package/js/src/src/static_dependencies/ethers/typed.d.ts +569 -0
  802. package/js/src/src/static_dependencies/ethers/typed.js +608 -0
  803. package/js/src/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
  804. package/js/src/src/static_dependencies/ethers/utils/base58.js +68 -0
  805. package/js/src/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
  806. package/js/src/src/static_dependencies/ethers/utils/base64.js +58 -0
  807. package/js/src/src/static_dependencies/ethers/utils/data.d.ts +92 -0
  808. package/js/src/src/static_dependencies/ethers/utils/data.js +175 -0
  809. package/js/src/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
  810. package/js/src/src/static_dependencies/ethers/utils/errors.js +227 -0
  811. package/js/src/src/static_dependencies/ethers/utils/events.d.ts +76 -0
  812. package/js/src/src/static_dependencies/ethers/utils/events.js +52 -0
  813. package/js/src/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
  814. package/js/src/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
  815. package/js/src/src/static_dependencies/ethers/utils/index.d.ts +30 -0
  816. package/js/src/src/static_dependencies/ethers/utils/index.js +38 -0
  817. package/js/src/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
  818. package/js/src/src/static_dependencies/ethers/utils/maths.js +220 -0
  819. package/js/src/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
  820. package/js/src/src/static_dependencies/ethers/utils/properties.js +59 -0
  821. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
  822. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
  823. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
  824. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
  825. package/js/src/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
  826. package/js/src/src/static_dependencies/ethers/utils/rlp.js +14 -0
  827. package/js/src/src/static_dependencies/ethers/utils/units.d.ts +23 -0
  828. package/js/src/src/static_dependencies/ethers/utils/units.js +88 -0
  829. package/js/src/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
  830. package/js/src/src/static_dependencies/ethers/utils/utf8.js +225 -0
  831. package/js/src/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
  832. package/js/src/src/static_dependencies/ethers/utils/uuid.js +35 -0
  833. package/js/src/src/static_dependencies/fflake/browser.d.ts +222 -0
  834. package/js/src/src/static_dependencies/fflake/browser.js +2578 -0
  835. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.d.ts +116 -0
  836. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.js +194 -0
  837. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +142 -0
  838. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +307 -0
  839. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -0
  840. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +565 -0
  841. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.d.ts +5 -0
  842. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  843. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.d.ts +3 -0
  844. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  845. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.d.ts +9 -0
  846. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  847. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.d.ts +3 -0
  848. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +25 -0
  849. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -0
  850. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1757 -0
  851. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.d.ts +10 -0
  852. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +50 -0
  853. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.d.ts +3 -0
  854. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +80 -0
  855. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.d.ts +23 -0
  856. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +377 -0
  857. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.d.ts +7 -0
  858. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.js +64 -0
  859. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -0
  860. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1627 -0
  861. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.d.ts +60 -0
  862. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.js +22 -0
  863. package/js/src/src/static_dependencies/noble-curves/abstract/curve.d.ts +67 -0
  864. package/js/src/src/static_dependencies/noble-curves/abstract/curve.js +157 -0
  865. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.d.ts +79 -0
  866. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.js +432 -0
  867. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.d.ts +56 -0
  868. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +171 -0
  869. package/js/src/src/static_dependencies/noble-curves/abstract/modular.d.ts +68 -0
  870. package/js/src/src/static_dependencies/noble-curves/abstract/modular.js +351 -0
  871. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.d.ts +25 -0
  872. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.js +162 -0
  873. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.d.ts +29 -0
  874. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.js +115 -0
  875. package/js/src/src/static_dependencies/noble-curves/abstract/utils.d.ts +53 -0
  876. package/js/src/src/static_dependencies/noble-curves/abstract/utils.js +227 -0
  877. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -0
  878. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.js +1016 -0
  879. package/js/src/src/static_dependencies/noble-curves/ed25519.d.ts +53 -0
  880. package/js/src/src/static_dependencies/noble-curves/ed25519.js +402 -0
  881. package/js/src/src/static_dependencies/noble-curves/p256.d.ts +103 -0
  882. package/js/src/src/static_dependencies/noble-curves/p256.js +47 -0
  883. package/js/src/src/static_dependencies/noble-curves/secp256k1.d.ts +91 -0
  884. package/js/src/src/static_dependencies/noble-curves/secp256k1.js +257 -0
  885. package/js/src/src/static_dependencies/noble-hashes/_assert.d.ts +21 -0
  886. package/js/src/src/static_dependencies/noble-hashes/_assert.js +48 -0
  887. package/js/src/src/static_dependencies/noble-hashes/_sha2.d.ts +23 -0
  888. package/js/src/src/static_dependencies/noble-hashes/_sha2.js +119 -0
  889. package/js/src/src/static_dependencies/noble-hashes/_u64.d.ts +35 -0
  890. package/js/src/src/static_dependencies/noble-hashes/_u64.js +66 -0
  891. package/js/src/src/static_dependencies/noble-hashes/crypto.d.ts +1 -0
  892. package/js/src/src/static_dependencies/noble-hashes/crypto.js +7 -0
  893. package/js/src/src/static_dependencies/noble-hashes/hmac.d.ts +26 -0
  894. package/js/src/src/static_dependencies/noble-hashes/hmac.js +82 -0
  895. package/js/src/src/static_dependencies/noble-hashes/md5.d.ts +18 -0
  896. package/js/src/src/static_dependencies/noble-hashes/md5.js +242 -0
  897. package/js/src/src/static_dependencies/noble-hashes/sha1.d.ts +21 -0
  898. package/js/src/src/static_dependencies/noble-hashes/sha1.js +90 -0
  899. package/js/src/src/static_dependencies/noble-hashes/sha256.d.ts +34 -0
  900. package/js/src/src/static_dependencies/noble-hashes/sha256.js +129 -0
  901. package/js/src/src/static_dependencies/noble-hashes/sha3.d.ts +97 -0
  902. package/js/src/src/static_dependencies/noble-hashes/sha3.js +211 -0
  903. package/js/src/src/static_dependencies/noble-hashes/sha512.d.ts +66 -0
  904. package/js/src/src/static_dependencies/noble-hashes/sha512.js +236 -0
  905. package/js/src/src/static_dependencies/noble-hashes/utils.d.ts +77 -0
  906. package/js/src/src/static_dependencies/noble-hashes/utils.js +147 -0
  907. package/js/src/src/static_dependencies/proxies/agent-base/helpers.d.ts +14 -0
  908. package/js/src/src/static_dependencies/proxies/agent-base/helpers.js +42 -0
  909. package/js/src/src/static_dependencies/proxies/agent-base/index.d.ts +33 -0
  910. package/js/src/src/static_dependencies/proxies/agent-base/index.js +82 -0
  911. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.d.ts +40 -0
  912. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.js +119 -0
  913. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.d.ts +45 -0
  914. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.js +150 -0
  915. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.d.ts +15 -0
  916. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  917. package/js/src/src/static_dependencies/qs/formats.cjs +22 -0
  918. package/js/src/src/static_dependencies/qs/formats.d.cts +14 -0
  919. package/js/src/src/static_dependencies/qs/index.cjs +15 -0
  920. package/js/src/src/static_dependencies/qs/index.d.cts +10 -0
  921. package/js/src/src/static_dependencies/qs/parse.cjs +208 -0
  922. package/js/src/src/static_dependencies/qs/parse.d.cts +8 -0
  923. package/js/src/src/static_dependencies/qs/stringify.cjs +192 -0
  924. package/js/src/src/static_dependencies/qs/stringify.d.cts +8 -0
  925. package/js/src/src/static_dependencies/qs/utils.cjs +202 -0
  926. package/js/src/src/static_dependencies/qs/utils.d.cts +15 -0
  927. package/js/src/src/static_dependencies/scure-base/index.d.ts +92 -0
  928. package/js/src/src/static_dependencies/scure-base/index.js +420 -0
  929. package/js/src/src/static_dependencies/scure-starknet/index.d.ts +79 -0
  930. package/js/src/src/static_dependencies/scure-starknet/index.js +323 -0
  931. package/js/src/src/static_dependencies/starknet/constants.d.ts +61 -0
  932. package/js/src/src/static_dependencies/starknet/constants.js +67 -0
  933. package/js/src/src/static_dependencies/starknet/index.d.ts +3 -0
  934. package/js/src/src/static_dependencies/starknet/index.js +9 -0
  935. package/js/src/src/static_dependencies/starknet/types/cairoEnum.d.ts +2 -0
  936. package/js/src/src/static_dependencies/starknet/types/cairoEnum.js +7 -0
  937. package/js/src/src/static_dependencies/starknet/types/calldata.d.ts +19 -0
  938. package/js/src/src/static_dependencies/starknet/types/calldata.js +28 -0
  939. package/js/src/src/static_dependencies/starknet/types/index.d.ts +13 -0
  940. package/js/src/src/static_dependencies/starknet/types/index.js +16 -0
  941. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.d.ts +71 -0
  942. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.js +13 -0
  943. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.d.ts +24 -0
  944. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.js +16 -0
  945. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.d.ts +33 -0
  946. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.js +7 -0
  947. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.d.ts +52 -0
  948. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.js +7 -0
  949. package/js/src/src/static_dependencies/starknet/types/lib/index.d.ts +248 -0
  950. package/js/src/src/static_dependencies/starknet/types/lib/index.js +52 -0
  951. package/js/src/src/static_dependencies/starknet/types/typedData.d.ts +44 -0
  952. package/js/src/src/static_dependencies/starknet/types/typedData.js +19 -0
  953. package/js/src/src/static_dependencies/starknet/utils/assert.d.ts +7 -0
  954. package/js/src/src/static_dependencies/starknet/utils/assert.js +17 -0
  955. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.d.ts +6 -0
  956. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +43 -0
  957. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.d.ts +72 -0
  958. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +117 -0
  959. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.d.ts +76 -0
  960. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +136 -0
  961. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.d.ts +32 -0
  962. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.js +59 -0
  963. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.d.ts +183 -0
  964. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.js +229 -0
  965. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
  966. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
  967. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.d.ts +35 -0
  968. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
  969. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.d.ts +34 -0
  970. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
  971. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.d.ts +3 -0
  972. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.js +9 -0
  973. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.d.ts +9 -0
  974. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.js +67 -0
  975. package/js/src/src/static_dependencies/starknet/utils/calldata/index.d.ts +89 -0
  976. package/js/src/src/static_dependencies/starknet/utils/calldata/index.js +280 -0
  977. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -0
  978. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.js +30 -0
  979. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.d.ts +20 -0
  980. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.js +8 -0
  981. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
  982. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +36 -0
  983. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
  984. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
  985. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.d.ts +2 -0
  986. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +155 -0
  987. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.d.ts +11 -0
  988. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.js +248 -0
  989. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.d.ts +11 -0
  990. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.js +214 -0
  991. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.d.ts +6 -0
  992. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.js +113 -0
  993. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.d.ts +6 -0
  994. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.js +208 -0
  995. package/js/src/src/static_dependencies/starknet/utils/encode.d.ts +207 -0
  996. package/js/src/src/static_dependencies/starknet/utils/encode.js +282 -0
  997. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.d.ts +57 -0
  998. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.js +223 -0
  999. package/js/src/src/static_dependencies/starknet/utils/hash/index.d.ts +6 -0
  1000. package/js/src/src/static_dependencies/starknet/utils/hash/index.js +13 -0
  1001. package/js/src/src/static_dependencies/starknet/utils/merkle.d.ts +35 -0
  1002. package/js/src/src/static_dependencies/starknet/utils/merkle.js +84 -0
  1003. package/js/src/src/static_dependencies/starknet/utils/num.d.ts +182 -0
  1004. package/js/src/src/static_dependencies/starknet/utils/num.js +244 -0
  1005. package/js/src/src/static_dependencies/starknet/utils/selector.d.ts +48 -0
  1006. package/js/src/src/static_dependencies/starknet/utils/selector.js +85 -0
  1007. package/js/src/src/static_dependencies/starknet/utils/shortString.d.ts +57 -0
  1008. package/js/src/src/static_dependencies/starknet/utils/shortString.js +96 -0
  1009. package/js/src/src/static_dependencies/starknet/utils/typedData.d.ts +54 -0
  1010. package/js/src/src/static_dependencies/starknet/utils/typedData.js +321 -0
  1011. package/js/src/src/static_dependencies/watchable/src/types.d.ts +28 -0
  1012. package/js/src/src/static_dependencies/watchable/src/types.js +8 -0
  1013. package/js/src/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
  1014. package/js/src/src/static_dependencies/watchable/src/unpromise.js +297 -0
  1015. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  1016. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  1017. package/js/src/src/tabdeal.d.ts +23 -0
  1018. package/js/src/src/tabdeal.js +387 -0
  1019. package/js/src/src/tehran_exchange.d.ts +21 -0
  1020. package/js/src/src/tehran_exchange.js +333 -0
  1021. package/js/src/src/tetherland.d.ts +21 -0
  1022. package/js/src/src/tetherland.js +367 -0
  1023. package/js/src/src/timex.d.ts +247 -0
  1024. package/js/src/src/timex.js +1792 -0
  1025. package/js/src/src/tokocrypto.d.ts +261 -0
  1026. package/js/src/src/tokocrypto.js +2641 -0
  1027. package/js/src/src/toobit.d.ts +22 -0
  1028. package/js/src/src/toobit.js +445 -0
  1029. package/js/src/src/tradeogre.d.ts +149 -0
  1030. package/js/src/src/tradeogre.js +878 -0
  1031. package/js/src/src/twox.d.ts +21 -0
  1032. package/js/src/src/twox.js +371 -0
  1033. package/js/src/src/ubitex.d.ts +23 -0
  1034. package/js/src/src/ubitex.js +433 -0
  1035. package/js/src/src/upbit.d.ts +377 -0
  1036. package/js/src/src/upbit.js +2340 -0
  1037. package/js/src/src/vertex.d.ts +346 -0
  1038. package/js/src/src/vertex.js +3146 -0
  1039. package/js/src/src/wallex.d.ts +23 -0
  1040. package/js/src/src/wallex.js +467 -0
  1041. package/js/src/src/wavesexchange.d.ts +244 -0
  1042. package/js/src/src/wavesexchange.js +2747 -0
  1043. package/js/src/src/whitebit.d.ts +571 -0
  1044. package/js/src/src/whitebit.js +3437 -0
  1045. package/js/src/src/woo.d.ts +727 -0
  1046. package/js/src/src/woo.js +4183 -0
  1047. package/js/src/src/woofipro.d.ts +497 -0
  1048. package/js/src/src/woofipro.js +2941 -0
  1049. package/js/src/src/xt.d.ts +568 -0
  1050. package/js/src/src/xt.js +5184 -0
  1051. package/js/src/src/yobit.d.ts +197 -0
  1052. package/js/src/src/yobit.js +1453 -0
  1053. package/js/src/src/zaif.d.ts +136 -0
  1054. package/js/src/src/zaif.js +821 -0
  1055. package/js/src/src/zonda.d.ts +214 -0
  1056. package/js/src/src/zonda.js +1984 -0
  1057. package/js/test.d.ts +1 -1
  1058. package/js/test.js +33 -33
  1059. package/package.json +1 -1
@@ -0,0 +1,3518 @@
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/kraken.js';
9
+ import { AccountSuspended, BadSymbol, BadRequest, ExchangeNotAvailable, ArgumentsRequired, PermissionDenied, AuthenticationError, ExchangeError, OrderNotFound, DDoSProtection, InvalidNonce, InsufficientFunds, CancelPending, InvalidOrder, InvalidAddress, RateLimitExceeded, OnMaintenance, NotSupported } from './base/errors.js';
10
+ import { Precise } from './base/Precise.js';
11
+ import { TRUNCATE, TICK_SIZE } from './base/functions/number.js';
12
+ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
+ import { sha512 } from './static_dependencies/noble-hashes/sha512.js';
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * @class kraken
17
+ * @augments Exchange
18
+ * @description Set rateLimit to 1000 if fully verified
19
+ */
20
+ export default class kraken extends Exchange {
21
+ describe() {
22
+ return this.deepExtend(super.describe(), {
23
+ 'id': 'kraken',
24
+ 'name': 'Kraken',
25
+ 'countries': ['US'],
26
+ 'version': '0',
27
+ // rate-limits: https://support.kraken.com/hc/en-us/articles/206548367-What-are-the-API-rate-limits-#1
28
+ // for public: 1 req/s
29
+ // for private: every second 0.33 weight added to your allowed capacity (some private endpoints need 1 weight, some need 2)
30
+ 'rateLimit': 1000,
31
+ 'certified': false,
32
+ 'pro': true,
33
+ 'has': {
34
+ 'CORS': undefined,
35
+ 'spot': true,
36
+ 'margin': true,
37
+ 'swap': false,
38
+ 'future': false,
39
+ 'option': false,
40
+ 'addMargin': false,
41
+ 'cancelAllOrders': true,
42
+ 'cancelAllOrdersAfter': true,
43
+ 'cancelOrder': true,
44
+ 'cancelOrders': true,
45
+ 'createDepositAddress': true,
46
+ 'createMarketBuyOrderWithCost': true,
47
+ 'createMarketOrderWithCost': false,
48
+ 'createMarketSellOrderWithCost': false,
49
+ 'createOrder': true,
50
+ 'createStopLimitOrder': true,
51
+ 'createStopMarketOrder': true,
52
+ 'createStopOrder': true,
53
+ 'createTrailingAmountOrder': true,
54
+ 'createTrailingPercentOrder': true,
55
+ 'editOrder': true,
56
+ 'fetchBalance': true,
57
+ 'fetchBorrowInterest': false,
58
+ 'fetchBorrowRateHistories': false,
59
+ 'fetchBorrowRateHistory': false,
60
+ 'fetchClosedOrders': true,
61
+ 'fetchCrossBorrowRate': false,
62
+ 'fetchCrossBorrowRates': false,
63
+ 'fetchCurrencies': true,
64
+ 'fetchDepositAddress': true,
65
+ 'fetchDepositAddresses': false,
66
+ 'fetchDepositAddressesByNetwork': false,
67
+ 'fetchDeposits': true,
68
+ 'fetchFundingHistory': false,
69
+ 'fetchFundingRate': false,
70
+ 'fetchFundingRateHistory': false,
71
+ 'fetchFundingRates': false,
72
+ 'fetchIndexOHLCV': false,
73
+ 'fetchIsolatedBorrowRate': false,
74
+ 'fetchIsolatedBorrowRates': false,
75
+ 'fetchLedger': true,
76
+ 'fetchLedgerEntry': true,
77
+ 'fetchLeverageTiers': false,
78
+ 'fetchMarkets': true,
79
+ 'fetchMarkOHLCV': false,
80
+ 'fetchMyTrades': true,
81
+ 'fetchOHLCV': true,
82
+ 'fetchOpenInterestHistory': false,
83
+ 'fetchOpenOrders': true,
84
+ 'fetchOrder': true,
85
+ 'fetchOrderBook': true,
86
+ 'fetchOrderTrades': 'emulated',
87
+ 'fetchPositions': true,
88
+ 'fetchPremiumIndexOHLCV': false,
89
+ 'fetchStatus': true,
90
+ 'fetchTicker': true,
91
+ 'fetchTickers': true,
92
+ 'fetchTime': true,
93
+ 'fetchTrades': true,
94
+ 'fetchTradingFee': true,
95
+ 'fetchTradingFees': false,
96
+ 'fetchWithdrawals': true,
97
+ 'setLeverage': false,
98
+ 'setMarginMode': false,
99
+ 'transfer': true,
100
+ 'withdraw': true,
101
+ },
102
+ 'timeframes': {
103
+ '1m': 1,
104
+ '5m': 5,
105
+ '15m': 15,
106
+ '30m': 30,
107
+ '1h': 60,
108
+ '4h': 240,
109
+ '1d': 1440,
110
+ '1w': 10080,
111
+ '2w': 21600,
112
+ },
113
+ 'urls': {
114
+ 'logo': 'https://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpg',
115
+ 'api': {
116
+ 'public': 'https://api.kraken.com',
117
+ 'private': 'https://api.kraken.com',
118
+ 'zendesk': 'https://kraken.zendesk.com/api/v2/help_center/en-us/articles', // use the public zendesk api to receive article bodies and bypass new anti-spam protections
119
+ },
120
+ 'www': 'https://www.kraken.com',
121
+ 'doc': 'https://docs.kraken.com/rest/',
122
+ 'fees': 'https://www.kraken.com/en-us/features/fee-schedule',
123
+ },
124
+ 'fees': {
125
+ 'trading': {
126
+ 'tierBased': true,
127
+ 'percentage': true,
128
+ 'taker': this.parseNumber('0.0026'),
129
+ 'maker': this.parseNumber('0.0016'),
130
+ 'tiers': {
131
+ 'taker': [
132
+ [this.parseNumber('0'), this.parseNumber('0.0026')],
133
+ [this.parseNumber('50000'), this.parseNumber('0.0024')],
134
+ [this.parseNumber('100000'), this.parseNumber('0.0022')],
135
+ [this.parseNumber('250000'), this.parseNumber('0.0020')],
136
+ [this.parseNumber('500000'), this.parseNumber('0.0018')],
137
+ [this.parseNumber('1000000'), this.parseNumber('0.0016')],
138
+ [this.parseNumber('2500000'), this.parseNumber('0.0014')],
139
+ [this.parseNumber('5000000'), this.parseNumber('0.0012')],
140
+ [this.parseNumber('10000000'), this.parseNumber('0.0001')],
141
+ ],
142
+ 'maker': [
143
+ [this.parseNumber('0'), this.parseNumber('0.0016')],
144
+ [this.parseNumber('50000'), this.parseNumber('0.0014')],
145
+ [this.parseNumber('100000'), this.parseNumber('0.0012')],
146
+ [this.parseNumber('250000'), this.parseNumber('0.0010')],
147
+ [this.parseNumber('500000'), this.parseNumber('0.0008')],
148
+ [this.parseNumber('1000000'), this.parseNumber('0.0006')],
149
+ [this.parseNumber('2500000'), this.parseNumber('0.0004')],
150
+ [this.parseNumber('5000000'), this.parseNumber('0.0002')],
151
+ [this.parseNumber('10000000'), this.parseNumber('0.0')],
152
+ ],
153
+ },
154
+ },
155
+ },
156
+ 'handleContentTypeApplicationZip': true,
157
+ 'api': {
158
+ 'zendesk': {
159
+ 'get': [
160
+ // we should really refrain from putting fixed fee numbers and stop hardcoding
161
+ // we will be using their web APIs to scrape all numbers from these articles
162
+ '360000292886',
163
+ '201893608', // -What-are-the-withdrawal-fees-
164
+ ],
165
+ },
166
+ 'public': {
167
+ 'get': {
168
+ // rate-limits explained in comment in the top of this file
169
+ 'Assets': 1,
170
+ 'AssetPairs': 1,
171
+ 'Depth': 1.2,
172
+ 'OHLC': 1.2,
173
+ 'Spread': 1,
174
+ 'SystemStatus': 1,
175
+ 'Ticker': 1,
176
+ 'Time': 1,
177
+ 'Trades': 1.2,
178
+ },
179
+ },
180
+ 'private': {
181
+ 'post': {
182
+ 'AddOrder': 0,
183
+ 'AddOrderBatch': 0,
184
+ 'AddExport': 3,
185
+ 'AmendOrder': 0,
186
+ 'Balance': 3,
187
+ 'CancelAll': 3,
188
+ 'CancelAllOrdersAfter': 3,
189
+ 'CancelOrder': 0,
190
+ 'CancelOrderBatch': 0,
191
+ 'ClosedOrders': 3,
192
+ 'DepositAddresses': 3,
193
+ 'DepositMethods': 3,
194
+ 'DepositStatus': 3,
195
+ 'EditOrder': 0,
196
+ 'ExportStatus': 3,
197
+ 'GetWebSocketsToken': 3,
198
+ 'Ledgers': 6,
199
+ 'OpenOrders': 3,
200
+ 'OpenPositions': 3,
201
+ 'QueryLedgers': 3,
202
+ 'QueryOrders': 3,
203
+ 'QueryTrades': 3,
204
+ 'RetrieveExport': 3,
205
+ 'RemoveExport': 3,
206
+ 'BalanceEx': 3,
207
+ 'TradeBalance': 3,
208
+ 'TradesHistory': 6,
209
+ 'TradeVolume': 3,
210
+ 'Withdraw': 3,
211
+ 'WithdrawCancel': 3,
212
+ 'WithdrawInfo': 3,
213
+ 'WithdrawMethods': 3,
214
+ 'WithdrawAddresses': 3,
215
+ 'WithdrawStatus': 3,
216
+ 'WalletTransfer': 3,
217
+ // sub accounts
218
+ 'CreateSubaccount': 3,
219
+ 'AccountTransfer': 3,
220
+ // earn
221
+ 'Earn/Allocate': 3,
222
+ 'Earn/Deallocate': 3,
223
+ 'Earn/AllocateStatus': 3,
224
+ 'Earn/DeallocateStatus': 3,
225
+ 'Earn/Strategies': 3,
226
+ 'Earn/Allocations': 3,
227
+ },
228
+ },
229
+ },
230
+ 'commonCurrencies': {
231
+ // about X & Z prefixes and .S & .M suffixes, see comment under fetchCurrencies
232
+ 'LUNA': 'LUNC',
233
+ 'LUNA2': 'LUNA',
234
+ 'REPV2': 'REP',
235
+ 'REP': 'REPV1',
236
+ 'UST': 'USTC',
237
+ 'XBT': 'BTC',
238
+ 'XDG': 'DOGE',
239
+ },
240
+ 'options': {
241
+ 'timeDifference': 0,
242
+ 'adjustForTimeDifference': false,
243
+ 'marketsByAltname': {},
244
+ 'delistedMarketsById': {},
245
+ // cannot withdraw/deposit these
246
+ 'inactiveCurrencies': ['CAD', 'USD', 'JPY', 'GBP'],
247
+ 'networks': {
248
+ 'ETH': 'ERC20',
249
+ 'TRX': 'TRC20',
250
+ },
251
+ 'depositMethods': {
252
+ '1INCH': '1inch' + ' ' + '(1INCH)',
253
+ 'AAVE': 'Aave',
254
+ 'ADA': 'ADA',
255
+ 'ALGO': 'Algorand',
256
+ 'ANKR': 'ANKR' + ' ' + '(ANKR)',
257
+ 'ANT': 'Aragon' + ' ' + '(ANT)',
258
+ 'ATOM': 'Cosmos',
259
+ 'AXS': 'Axie Infinity Shards' + ' ' + '(AXS)',
260
+ 'BADGER': 'Bager DAO' + ' ' + '(BADGER)',
261
+ 'BAL': 'Balancer' + ' ' + '(BAL)',
262
+ 'BAND': 'Band Protocol' + ' ' + '(BAND)',
263
+ 'BAT': 'BAT',
264
+ 'BCH': 'Bitcoin Cash',
265
+ 'BNC': 'Bifrost' + ' ' + '(BNC)',
266
+ 'BNT': 'Bancor' + ' ' + '(BNT)',
267
+ 'BTC': 'Bitcoin',
268
+ 'CHZ': 'Chiliz' + ' ' + '(CHZ)',
269
+ 'COMP': 'Compound' + ' ' + '(COMP)',
270
+ 'CQT': '\tCovalent Query Token' + ' ' + '(CQT)',
271
+ 'CRV': 'Curve DAO Token' + ' ' + '(CRV)',
272
+ 'CTSI': 'Cartesi' + ' ' + '(CTSI)',
273
+ 'DAI': 'Dai',
274
+ 'DASH': 'Dash',
275
+ 'DOGE': 'Dogecoin',
276
+ 'DOT': 'Polkadot',
277
+ 'DYDX': 'dYdX' + ' ' + '(DYDX)',
278
+ 'ENJ': 'Enjin Coin' + ' ' + '(ENJ)',
279
+ 'EOS': 'EOS',
280
+ 'ETC': 'Ether Classic' + ' ' + '(Hex)',
281
+ 'ETH': 'Ether' + ' ' + '(Hex)',
282
+ 'EWT': 'Energy Web Token',
283
+ 'FEE': 'Kraken Fee Credit',
284
+ 'FIL': 'Filecoin',
285
+ 'FLOW': 'Flow',
286
+ 'GHST': 'Aavegotchi' + ' ' + '(GHST)',
287
+ 'GNO': 'GNO',
288
+ 'GRT': 'GRT',
289
+ 'ICX': 'Icon',
290
+ 'INJ': 'Injective Protocol' + ' ' + '(INJ)',
291
+ 'KAR': 'Karura' + ' ' + '(KAR)',
292
+ 'KAVA': 'Kava',
293
+ 'KEEP': 'Keep Token' + ' ' + '(KEEP)',
294
+ 'KNC': 'Kyber Network' + ' ' + '(KNC)',
295
+ 'KSM': 'Kusama',
296
+ 'LINK': 'Link',
297
+ 'LPT': 'Livepeer Token' + ' ' + '(LPT)',
298
+ 'LRC': 'Loopring' + ' ' + '(LRC)',
299
+ 'LSK': 'Lisk',
300
+ 'LTC': 'Litecoin',
301
+ 'MANA': 'MANA',
302
+ 'MATIC': 'Polygon' + ' ' + '(MATIC)',
303
+ 'MINA': 'Mina',
304
+ 'MIR': 'Mirror Protocol' + ' ' + '(MIR)',
305
+ 'MKR': 'Maker' + ' ' + '(MKR)',
306
+ 'MLN': 'MLN',
307
+ 'MOVR': 'Moonriver' + ' ' + '(MOVR)',
308
+ 'NANO': 'NANO',
309
+ 'OCEAN': 'OCEAN',
310
+ 'OGN': 'Origin Protocol' + ' ' + '(OGN)',
311
+ 'OMG': 'OMG',
312
+ 'OXT': 'Orchid' + ' ' + '(OXT)',
313
+ 'OXY': 'Oxygen' + ' ' + '(OXY)',
314
+ 'PAXG': 'PAX' + ' ' + '(Gold)',
315
+ 'PERP': 'Perpetual Protocol' + ' ' + '(PERP)',
316
+ 'PHA': 'Phala' + ' ' + '(PHA)',
317
+ 'QTUM': 'QTUM',
318
+ 'RARI': 'Rarible' + ' ' + '(RARI)',
319
+ 'RAY': 'Raydium' + ' ' + '(RAY)',
320
+ 'REN': 'Ren Protocol' + ' ' + '(REN)',
321
+ 'REP': 'REPv2',
322
+ 'REPV1': 'REP',
323
+ 'SAND': 'The Sandbox' + ' ' + '(SAND)',
324
+ 'SC': 'Siacoin',
325
+ 'SDN': 'Shiden' + ' ' + '(SDN)',
326
+ 'SOL': 'Solana',
327
+ 'SNX': 'Synthetix Network' + ' ' + '(SNX)',
328
+ 'SRM': 'Serum',
329
+ 'STORJ': 'Storj' + ' ' + '(STORJ)',
330
+ 'SUSHI': 'Sushiswap' + ' ' + '(SUSHI)',
331
+ 'TBTC': 'tBTC',
332
+ 'TRX': 'Tron',
333
+ 'UNI': 'UNI',
334
+ 'USDC': 'USDC',
335
+ 'USDT': 'Tether USD' + ' ' + '(ERC20)',
336
+ 'USDT-TRC20': 'Tether USD' + ' ' + '(TRC20)',
337
+ 'WAVES': 'Waves',
338
+ 'WBTC': 'Wrapped Bitcoin' + ' ' + '(WBTC)',
339
+ 'XLM': 'Stellar XLM',
340
+ 'XMR': 'Monero',
341
+ 'XRP': 'Ripple XRP',
342
+ 'XTZ': 'XTZ',
343
+ 'YFI': 'YFI',
344
+ 'ZEC': 'Zcash' + ' ' + '(Transparent)',
345
+ 'ZRX': '0x' + ' ' + '(ZRX)',
346
+ },
347
+ 'withdrawMethods': {
348
+ 'Lightning': 'Lightning',
349
+ 'Bitcoin': 'BTC',
350
+ 'Ripple': 'XRP',
351
+ 'Litecoin': 'LTC',
352
+ 'Dogecoin': 'DOGE',
353
+ 'Stellar': 'XLM',
354
+ 'Ethereum': 'ERC20',
355
+ 'Arbitrum One': 'Arbitrum',
356
+ 'Polygon': 'MATIC',
357
+ 'Arbitrum Nova': 'Arbitrum',
358
+ 'Optimism': 'Optimism',
359
+ 'zkSync Era': 'zkSync',
360
+ 'Ethereum Classic': 'ETC',
361
+ 'Zcash': 'ZEC',
362
+ 'Monero': 'XMR',
363
+ 'Tron': 'TRC20',
364
+ 'Solana': 'SOL',
365
+ 'EOS': 'EOS',
366
+ 'Bitcoin Cash': 'BCH',
367
+ 'Cardano': 'ADA',
368
+ 'Qtum': 'QTUM',
369
+ 'Tezos': 'XTZ',
370
+ 'Cosmos': 'ATOM',
371
+ 'Nano': 'NANO',
372
+ 'Siacoin': 'SC',
373
+ 'Lisk': 'LSK',
374
+ 'Waves': 'WAVES',
375
+ 'ICON': 'ICX',
376
+ 'Algorand': 'ALGO',
377
+ 'Polygon - USDC.e': 'MATIC',
378
+ 'Arbitrum One - USDC.e': 'Arbitrum',
379
+ 'Polkadot': 'DOT',
380
+ 'Kava': 'KAVA',
381
+ 'Filecoin': 'FIL',
382
+ 'Kusama': 'KSM',
383
+ 'Flow': 'FLOW',
384
+ 'Energy Web': 'EW',
385
+ 'Mina': 'MINA',
386
+ 'Centrifuge': 'CFG',
387
+ 'Karura': 'KAR',
388
+ 'Moonriver': 'MOVR',
389
+ 'Shiden': 'SDN',
390
+ 'Khala': 'PHA',
391
+ 'Bifrost Kusama': 'BNC',
392
+ 'Songbird': 'SGB',
393
+ 'Terra classic': 'LUNC',
394
+ 'KILT': 'KILT',
395
+ 'Basilisk': 'BSX',
396
+ 'Flare': 'FLR',
397
+ 'Avalanche C-Chain': 'AVAX',
398
+ 'Kintsugi': 'KINT',
399
+ 'Altair': 'AIR',
400
+ 'Moonbeam': 'GLMR',
401
+ 'Acala': 'ACA',
402
+ 'Astar': 'ASTR',
403
+ 'Akash': 'AKT',
404
+ 'Robonomics': 'XRT',
405
+ 'Fantom': 'FTM',
406
+ 'Elrond': 'EGLD',
407
+ 'THORchain': 'RUNE',
408
+ 'Secret': 'SCRT',
409
+ 'Near': 'NEAR',
410
+ 'Internet Computer Protocol': 'ICP',
411
+ 'Picasso': 'PICA',
412
+ 'Crust Shadow': 'CSM',
413
+ 'Integritee': 'TEER',
414
+ 'Parallel Finance': 'PARA',
415
+ 'HydraDX': 'HDX',
416
+ 'Interlay': 'INTR',
417
+ 'Fetch.ai': 'FET',
418
+ 'NYM': 'NYM',
419
+ 'Terra 2.0': 'LUNA2',
420
+ 'Juno': 'JUNO',
421
+ 'Nodle': 'NODL',
422
+ 'Stacks': 'STX',
423
+ 'Ethereum PoW': 'ETHW',
424
+ 'Aptos': 'APT',
425
+ 'Sui': 'SUI',
426
+ 'Genshiro': 'GENS',
427
+ 'Aventus': 'AVT',
428
+ 'Sei': 'SEI',
429
+ 'OriginTrail': 'OTP',
430
+ 'Celestia': 'TIA',
431
+ },
432
+ },
433
+ 'features': {
434
+ 'spot': {
435
+ 'sandbox': false,
436
+ 'createOrder': {
437
+ 'marginMode': false,
438
+ 'triggerPrice': false,
439
+ 'triggerPriceType': undefined,
440
+ 'triggerDirection': false,
441
+ 'stopLossPrice': true,
442
+ 'takeProfitPrice': true,
443
+ 'attachedStopLossTakeProfit': undefined,
444
+ 'timeInForce': {
445
+ 'IOC': true,
446
+ 'FOK': true,
447
+ 'PO': true,
448
+ 'GTD': false,
449
+ },
450
+ 'hedged': false,
451
+ 'trailing': true,
452
+ 'leverage': false,
453
+ 'marketBuyByCost': true,
454
+ 'marketBuyRequiresPrice': false,
455
+ 'selfTradePrevention': true,
456
+ 'iceberg': true, // todo implement
457
+ },
458
+ 'createOrders': undefined,
459
+ 'fetchMyTrades': {
460
+ 'marginMode': false,
461
+ 'limit': undefined,
462
+ 'daysBack': undefined,
463
+ 'untilDays': undefined,
464
+ 'symbolRequired': false,
465
+ },
466
+ 'fetchOrder': {
467
+ 'marginMode': false,
468
+ 'trigger': false,
469
+ 'trailing': false,
470
+ 'symbolRequired': false,
471
+ },
472
+ 'fetchOpenOrders': {
473
+ 'marginMode': false,
474
+ 'limit': undefined,
475
+ 'trigger': false,
476
+ 'trailing': false,
477
+ 'symbolRequired': false,
478
+ },
479
+ 'fetchOrders': undefined,
480
+ 'fetchClosedOrders': {
481
+ 'marginMode': false,
482
+ 'limit': undefined,
483
+ 'daysBack': undefined,
484
+ 'daysBackCanceled': undefined,
485
+ 'untilDays': 100000,
486
+ 'trigger': false,
487
+ 'trailing': false,
488
+ 'symbolRequired': false,
489
+ },
490
+ 'fetchOHLCV': {
491
+ 'limit': 720,
492
+ },
493
+ },
494
+ 'swap': {
495
+ 'linear': undefined,
496
+ 'inverse': undefined,
497
+ },
498
+ 'future': {
499
+ 'linear': undefined,
500
+ 'inverse': undefined,
501
+ },
502
+ },
503
+ 'precisionMode': TICK_SIZE,
504
+ 'exceptions': {
505
+ 'exact': {
506
+ 'EQuery:Invalid asset pair': BadSymbol,
507
+ 'EAPI:Invalid key': AuthenticationError,
508
+ 'EFunding:Unknown withdraw key': InvalidAddress,
509
+ 'EFunding:Invalid amount': InsufficientFunds,
510
+ 'EService:Unavailable': ExchangeNotAvailable,
511
+ 'EDatabase:Internal error': ExchangeNotAvailable,
512
+ 'EService:Busy': ExchangeNotAvailable,
513
+ 'EQuery:Unknown asset': BadSymbol,
514
+ 'EAPI:Rate limit exceeded': DDoSProtection,
515
+ 'EOrder:Rate limit exceeded': DDoSProtection,
516
+ 'EGeneral:Internal error': ExchangeNotAvailable,
517
+ 'EGeneral:Temporary lockout': DDoSProtection,
518
+ 'EGeneral:Permission denied': PermissionDenied,
519
+ 'EGeneral:Invalid arguments:price': InvalidOrder,
520
+ 'EOrder:Unknown order': InvalidOrder,
521
+ 'EOrder:Invalid price:Invalid price argument': InvalidOrder,
522
+ 'EOrder:Order minimum not met': InvalidOrder,
523
+ 'EOrder:Insufficient funds': InsufficientFunds,
524
+ 'EGeneral:Invalid arguments': BadRequest,
525
+ 'ESession:Invalid session': AuthenticationError,
526
+ 'EAPI:Invalid nonce': InvalidNonce,
527
+ 'EFunding:No funding method': BadRequest,
528
+ 'EFunding:Unknown asset': BadSymbol,
529
+ 'EService:Market in post_only mode': OnMaintenance,
530
+ 'EGeneral:Too many requests': DDoSProtection,
531
+ 'ETrade:User Locked': AccountSuspended, // {"error":["ETrade:User Locked"]}
532
+ },
533
+ 'broad': {
534
+ ':Invalid order': InvalidOrder,
535
+ ':Invalid arguments:volume': InvalidOrder,
536
+ ':Invalid arguments:viqc': InvalidOrder,
537
+ ':Invalid nonce': InvalidNonce,
538
+ ':IInsufficient funds': InsufficientFunds,
539
+ ':Cancel pending': CancelPending,
540
+ ':Rate limit exceeded': RateLimitExceeded,
541
+ },
542
+ },
543
+ });
544
+ }
545
+ feeToPrecision(symbol, fee) {
546
+ return this.decimalToPrecision(fee, TRUNCATE, this.markets[symbol]['precision']['amount'], this.precisionMode);
547
+ }
548
+ /**
549
+ * @method
550
+ * @name kraken#fetchMarkets
551
+ * @description retrieves data on all markets for kraken
552
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTradableAssetPairs
553
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
554
+ * @returns {object[]} an array of objects representing market data
555
+ */
556
+ async fetchMarkets(params = {}) {
557
+ const promises = [];
558
+ promises.push(this.publicGetAssetPairs(params));
559
+ if (this.options['adjustForTimeDifference']) {
560
+ promises.push(this.loadTimeDifference());
561
+ }
562
+ const responses = await Promise.all(promises);
563
+ const assetsResponse = responses[0];
564
+ //
565
+ // {
566
+ // "error": [],
567
+ // "result": {
568
+ // "ADAETH": {
569
+ // "altname": "ADAETH",
570
+ // "wsname": "ADA\/ETH",
571
+ // "aclass_base": "currency",
572
+ // "base": "ADA",
573
+ // "aclass_quote": "currency",
574
+ // "quote": "XETH",
575
+ // "lot": "unit",
576
+ // "pair_decimals": 7,
577
+ // "lot_decimals": 8,
578
+ // "lot_multiplier": 1,
579
+ // "leverage_buy": [],
580
+ // "leverage_sell": [],
581
+ // "fees": [
582
+ // [0, 0.26],
583
+ // [50000, 0.24],
584
+ // [100000, 0.22],
585
+ // [250000, 0.2],
586
+ // [500000, 0.18],
587
+ // [1000000, 0.16],
588
+ // [2500000, 0.14],
589
+ // [5000000, 0.12],
590
+ // [10000000, 0.1]
591
+ // ],
592
+ // "fees_maker": [
593
+ // [0, 0.16],
594
+ // [50000, 0.14],
595
+ // [100000, 0.12],
596
+ // [250000, 0.1],
597
+ // [500000, 0.08],
598
+ // [1000000, 0.06],
599
+ // [2500000, 0.04],
600
+ // [5000000, 0.02],
601
+ // [10000000, 0]
602
+ // ],
603
+ // "fee_volume_currency": "ZUSD",
604
+ // "margin_call": 80,
605
+ // "margin_stop": 40,
606
+ // "ordermin": "1"
607
+ // },
608
+ // }
609
+ // }
610
+ //
611
+ const markets = this.safeDict(assetsResponse, 'result', {});
612
+ const cachedCurrencies = this.safeDict(this.options, 'cachedCurrencies', {});
613
+ const keys = Object.keys(markets);
614
+ const result = [];
615
+ for (let i = 0; i < keys.length; i++) {
616
+ const id = keys[i];
617
+ const market = markets[id];
618
+ const baseId = this.safeString(market, 'base');
619
+ const quoteId = this.safeString(market, 'quote');
620
+ const base = this.safeCurrencyCode(baseId);
621
+ const quote = this.safeCurrencyCode(quoteId);
622
+ const makerFees = this.safeList(market, 'fees_maker', []);
623
+ const firstMakerFee = this.safeList(makerFees, 0, []);
624
+ const firstMakerFeeRate = this.safeString(firstMakerFee, 1);
625
+ let maker = undefined;
626
+ if (firstMakerFeeRate !== undefined) {
627
+ maker = this.parseNumber(Precise.stringDiv(firstMakerFeeRate, '100'));
628
+ }
629
+ const takerFees = this.safeList(market, 'fees', []);
630
+ const firstTakerFee = this.safeList(takerFees, 0, []);
631
+ const firstTakerFeeRate = this.safeString(firstTakerFee, 1);
632
+ let taker = undefined;
633
+ if (firstTakerFeeRate !== undefined) {
634
+ taker = this.parseNumber(Precise.stringDiv(firstTakerFeeRate, '100'));
635
+ }
636
+ const leverageBuy = this.safeList(market, 'leverage_buy', []);
637
+ const leverageBuyLength = leverageBuy.length;
638
+ const precisionPrice = this.parseNumber(this.parsePrecision(this.safeString(market, 'pair_decimals')));
639
+ let precisionAmount = this.parseNumber(this.parsePrecision(this.safeString(market, 'lot_decimals')));
640
+ const spot = true;
641
+ // fix https://github.com/freqtrade/freqtrade/issues/11765#issuecomment-2894224103
642
+ if (spot && (base in cachedCurrencies)) {
643
+ const currency = cachedCurrencies[base];
644
+ const currencyPrecision = this.safeNumber(currency, 'precision');
645
+ // if currency precision is greater (e.g. 0.01) than market precision (e.g. 0.001)
646
+ if (currencyPrecision > precisionAmount) {
647
+ precisionAmount = currencyPrecision;
648
+ }
649
+ }
650
+ const status = this.safeString(market, 'status');
651
+ const isActive = status === 'online';
652
+ result.push({
653
+ 'id': id,
654
+ 'wsId': this.safeString(market, 'wsname'),
655
+ 'symbol': base + '/' + quote,
656
+ 'base': base,
657
+ 'quote': quote,
658
+ 'settle': undefined,
659
+ 'baseId': baseId,
660
+ 'quoteId': quoteId,
661
+ 'settleId': undefined,
662
+ 'altname': market['altname'],
663
+ 'type': 'spot',
664
+ 'spot': spot,
665
+ 'margin': (leverageBuyLength > 0),
666
+ 'swap': false,
667
+ 'future': false,
668
+ 'option': false,
669
+ 'active': isActive,
670
+ 'contract': false,
671
+ 'linear': undefined,
672
+ 'inverse': undefined,
673
+ 'taker': taker,
674
+ 'maker': maker,
675
+ 'contractSize': undefined,
676
+ 'expiry': undefined,
677
+ 'expiryDatetime': undefined,
678
+ 'strike': undefined,
679
+ 'optionType': undefined,
680
+ 'precision': {
681
+ 'amount': precisionAmount,
682
+ 'price': precisionPrice,
683
+ },
684
+ 'limits': {
685
+ 'leverage': {
686
+ 'min': this.parseNumber('1'),
687
+ 'max': this.safeNumber(leverageBuy, leverageBuyLength - 1, 1),
688
+ },
689
+ 'amount': {
690
+ 'min': this.safeNumber(market, 'ordermin'),
691
+ 'max': undefined,
692
+ },
693
+ 'price': {
694
+ 'min': undefined,
695
+ 'max': undefined,
696
+ },
697
+ 'cost': {
698
+ 'min': this.safeNumber(market, 'costmin'),
699
+ 'max': undefined,
700
+ },
701
+ },
702
+ 'created': undefined,
703
+ 'info': market,
704
+ });
705
+ }
706
+ this.options['marketsByAltname'] = this.indexBy(result, 'altname');
707
+ return result;
708
+ }
709
+ safeCurrency(currencyId, currency = undefined) {
710
+ if (currencyId !== undefined) {
711
+ if (currencyId.length > 3) {
712
+ if ((currencyId.indexOf('X') === 0) || (currencyId.indexOf('Z') === 0)) {
713
+ if (!(currencyId.indexOf('.') > 0) && (currencyId !== 'ZEUS')) {
714
+ currencyId = currencyId.slice(1);
715
+ }
716
+ }
717
+ }
718
+ }
719
+ return super.safeCurrency(currencyId, currency);
720
+ }
721
+ /**
722
+ * @method
723
+ * @name kraken#fetchStatus
724
+ * @description the latest known information on the availability of the exchange API
725
+ * @see https://docs.kraken.com/api/docs/rest-api/get-system-status/
726
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
727
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
728
+ */
729
+ async fetchStatus(params = {}) {
730
+ const response = await this.publicGetSystemStatus(params);
731
+ //
732
+ // {
733
+ // error: [],
734
+ // result: { status: 'online', timestamp: '2024-07-22T16:34:44Z' }
735
+ // }
736
+ //
737
+ const result = this.safeDict(response, 'result');
738
+ const statusRaw = this.safeString(result, 'status');
739
+ return {
740
+ 'status': (statusRaw === 'online') ? 'ok' : 'maintenance',
741
+ 'updated': undefined,
742
+ 'eta': undefined,
743
+ 'url': undefined,
744
+ 'info': response,
745
+ };
746
+ }
747
+ /**
748
+ * @method
749
+ * @name kraken#fetchCurrencies
750
+ * @description fetches all available currencies on an exchange
751
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getAssetInfo
752
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
753
+ * @returns {object} an associative dictionary of currencies
754
+ */
755
+ async fetchCurrencies(params = {}) {
756
+ const response = await this.publicGetAssets(params);
757
+ //
758
+ // {
759
+ // "error": [],
760
+ // "result": {
761
+ // "ATOM": {
762
+ // "aclass": "currency",
763
+ // "altname": "ATOM",
764
+ // "collateral_value": "0.7",
765
+ // "decimals": 8,
766
+ // "display_decimals": 6,
767
+ // "margin_rate": 0.02,
768
+ // "status": "enabled",
769
+ // },
770
+ // "ATOM.S": {
771
+ // "aclass": "currency",
772
+ // "altname": "ATOM.S",
773
+ // "decimals": 8,
774
+ // "display_decimals": 6,
775
+ // "status": "enabled",
776
+ // },
777
+ // "XXBT": {
778
+ // "aclass": "currency",
779
+ // "altname": "XBT",
780
+ // "decimals": 10,
781
+ // "display_decimals": 5,
782
+ // "margin_rate": 0.01,
783
+ // "status": "enabled",
784
+ // },
785
+ // "XETH": {
786
+ // "aclass": "currency",
787
+ // "altname": "ETH",
788
+ // "decimals": 10,
789
+ // "display_decimals": 5
790
+ // "margin_rate": 0.02,
791
+ // "status": "enabled",
792
+ // },
793
+ // "XBT.M": {
794
+ // "aclass": "currency",
795
+ // "altname": "XBT.M",
796
+ // "decimals": 10,
797
+ // "display_decimals": 5
798
+ // "status": "enabled",
799
+ // },
800
+ // "ETH.M": {
801
+ // "aclass": "currency",
802
+ // "altname": "ETH.M",
803
+ // "decimals": 10,
804
+ // "display_decimals": 5
805
+ // "status": "enabled",
806
+ // },
807
+ // ...
808
+ // },
809
+ // }
810
+ //
811
+ const currencies = this.safeValue(response, 'result', {});
812
+ const ids = Object.keys(currencies);
813
+ const result = {};
814
+ for (let i = 0; i < ids.length; i++) {
815
+ const id = ids[i];
816
+ const currency = currencies[id];
817
+ // todo: will need to rethink the fees
818
+ // see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
819
+ // to add support for multiple withdrawal/deposit methods and
820
+ // differentiated fees for each particular method
821
+ //
822
+ // Notes about abbreviations:
823
+ // Z and X prefixes: https://support.kraken.com/hc/en-us/articles/360001206766-Bitcoin-currency-code-XBT-vs-BTC
824
+ // S and M suffixes: https://support.kraken.com/hc/en-us/articles/360039879471-What-is-Asset-S-and-Asset-M-
825
+ //
826
+ let code = this.safeCurrencyCode(id);
827
+ // the below can not be reliable done in `safeCurrencyCode`, so we have to do it here
828
+ if (id.indexOf('.') < 0) {
829
+ const altName = this.safeString(currency, 'altname');
830
+ // handle cases like below:
831
+ //
832
+ // id | altname
833
+ // ---------------
834
+ // XXBT | XBT
835
+ // ZUSD | USD
836
+ if (id !== altName && (id.startsWith('X') || id.startsWith('Z'))) {
837
+ code = this.safeCurrencyCode(altName);
838
+ // also, add map in commonCurrencies:
839
+ this.commonCurrencies[id] = code;
840
+ }
841
+ else {
842
+ code = this.safeCurrencyCode(id);
843
+ }
844
+ }
845
+ const isFiat = code.indexOf('.HOLD') >= 0;
846
+ result[code] = this.safeCurrencyStructure({
847
+ 'id': id,
848
+ 'code': code,
849
+ 'info': currency,
850
+ 'name': this.safeString(currency, 'altname'),
851
+ 'active': this.safeString(currency, 'status') === 'enabled',
852
+ 'type': isFiat ? 'fiat' : 'crypto',
853
+ 'deposit': undefined,
854
+ 'withdraw': undefined,
855
+ 'fee': undefined,
856
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
857
+ 'limits': {
858
+ 'amount': {
859
+ 'min': undefined,
860
+ 'max': undefined,
861
+ },
862
+ 'withdraw': {
863
+ 'min': undefined,
864
+ 'max': undefined,
865
+ },
866
+ },
867
+ 'networks': {},
868
+ });
869
+ }
870
+ return result;
871
+ }
872
+ safeCurrencyCode(currencyId, currency = undefined) {
873
+ if (currencyId === undefined) {
874
+ return currencyId;
875
+ }
876
+ if (currencyId.indexOf('.') > 0) {
877
+ // if ID contains .M, .S or .F, then it can't contain X or Z prefix. in such case, ID equals to ALTNAME
878
+ const parts = currencyId.split('.');
879
+ const firstPart = this.safeString(parts, 0);
880
+ const secondPart = this.safeString(parts, 1);
881
+ return super.safeCurrencyCode(firstPart, currency) + '.' + secondPart;
882
+ }
883
+ return super.safeCurrencyCode(currencyId, currency);
884
+ }
885
+ /**
886
+ * @method
887
+ * @name kraken#fetchTradingFee
888
+ * @description fetch the trading fees for a market
889
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradeVolume
890
+ * @param {string} symbol unified market symbol
891
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
892
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
893
+ */
894
+ async fetchTradingFee(symbol, params = {}) {
895
+ await this.loadMarkets();
896
+ const market = this.market(symbol);
897
+ const request = {
898
+ 'pair': market['id'],
899
+ 'fee-info': true,
900
+ };
901
+ const response = await this.privatePostTradeVolume(this.extend(request, params));
902
+ //
903
+ // {
904
+ // "error": [],
905
+ // "result": {
906
+ // "currency": 'ZUSD',
907
+ // "volume": '0.0000',
908
+ // "fees": {
909
+ // "XXBTZUSD": {
910
+ // "fee": '0.2600',
911
+ // "minfee": '0.1000',
912
+ // "maxfee": '0.2600',
913
+ // "nextfee": '0.2400',
914
+ // "tiervolume": '0.0000',
915
+ // "nextvolume": '50000.0000'
916
+ // }
917
+ // },
918
+ // "fees_maker": {
919
+ // "XXBTZUSD": {
920
+ // "fee": '0.1600',
921
+ // "minfee": '0.0000',
922
+ // "maxfee": '0.1600',
923
+ // "nextfee": '0.1400',
924
+ // "tiervolume": '0.0000',
925
+ // "nextvolume": '50000.0000'
926
+ // }
927
+ // }
928
+ // }
929
+ // }
930
+ //
931
+ const result = this.safeValue(response, 'result', {});
932
+ return this.parseTradingFee(result, market);
933
+ }
934
+ parseTradingFee(response, market) {
935
+ const makerFees = this.safeValue(response, 'fees_maker', {});
936
+ const takerFees = this.safeValue(response, 'fees', {});
937
+ const symbolMakerFee = this.safeValue(makerFees, market['id'], {});
938
+ const symbolTakerFee = this.safeValue(takerFees, market['id'], {});
939
+ return {
940
+ 'info': response,
941
+ 'symbol': market['symbol'],
942
+ 'maker': this.parseNumber(Precise.stringDiv(this.safeString(symbolMakerFee, 'fee'), '100')),
943
+ 'taker': this.parseNumber(Precise.stringDiv(this.safeString(symbolTakerFee, 'fee'), '100')),
944
+ 'percentage': true,
945
+ 'tierBased': true,
946
+ };
947
+ }
948
+ parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
949
+ const price = this.safeNumber(bidask, priceKey);
950
+ const amount = this.safeNumber(bidask, amountKey);
951
+ const timestamp = this.safeInteger(bidask, 2);
952
+ return [price, amount, timestamp];
953
+ }
954
+ /**
955
+ * @method
956
+ * @name kraken#fetchOrderBook
957
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
958
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOrderBook
959
+ * @param {string} symbol unified symbol of the market to fetch the order book for
960
+ * @param {int} [limit] the maximum amount of order book entries to return
961
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
962
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
963
+ */
964
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
965
+ await this.loadMarkets();
966
+ const market = this.market(symbol);
967
+ const request = {
968
+ 'pair': market['id'],
969
+ };
970
+ if (limit !== undefined) {
971
+ request['count'] = limit; // 100
972
+ }
973
+ const response = await this.publicGetDepth(this.extend(request, params));
974
+ //
975
+ // {
976
+ // "error":[],
977
+ // "result":{
978
+ // "XETHXXBT":{
979
+ // "asks":[
980
+ // ["0.023480","4.000",1586321307],
981
+ // ["0.023490","50.095",1586321306],
982
+ // ["0.023500","28.535",1586321302],
983
+ // ],
984
+ // "bids":[
985
+ // ["0.023470","59.580",1586321307],
986
+ // ["0.023460","20.000",1586321301],
987
+ // ["0.023440","67.832",1586321306],
988
+ // ]
989
+ // }
990
+ // }
991
+ // }
992
+ //
993
+ const result = this.safeValue(response, 'result', {});
994
+ let orderbook = this.safeValue(result, market['id']);
995
+ // sometimes kraken returns wsname instead of market id
996
+ // https://github.com/ccxt/ccxt/issues/8662
997
+ const marketInfo = this.safeValue(market, 'info', {});
998
+ const wsName = this.safeValue(marketInfo, 'wsname');
999
+ if (wsName !== undefined) {
1000
+ orderbook = this.safeValue(result, wsName, orderbook);
1001
+ }
1002
+ return this.parseOrderBook(orderbook, symbol);
1003
+ }
1004
+ parseTicker(ticker, market = undefined) {
1005
+ //
1006
+ // {
1007
+ // "a":["2432.77000","1","1.000"],
1008
+ // "b":["2431.37000","2","2.000"],
1009
+ // "c":["2430.58000","0.04408910"],
1010
+ // "v":["4147.94474901","8896.96086304"],
1011
+ // "p":["2456.22239","2568.63032"],
1012
+ // "t":[3907,10056],
1013
+ // "l":["2302.18000","2302.18000"],
1014
+ // "h":["2621.14000","2860.01000"],
1015
+ // "o":"2571.56000"
1016
+ // }
1017
+ //
1018
+ const symbol = this.safeSymbol(undefined, market);
1019
+ const v = this.safeValue(ticker, 'v', []);
1020
+ const baseVolume = this.safeString(v, 1);
1021
+ const p = this.safeValue(ticker, 'p', []);
1022
+ const vwap = this.safeString(p, 1);
1023
+ const quoteVolume = Precise.stringMul(baseVolume, vwap);
1024
+ const c = this.safeValue(ticker, 'c', []);
1025
+ const last = this.safeString(c, 0);
1026
+ const high = this.safeValue(ticker, 'h', []);
1027
+ const low = this.safeValue(ticker, 'l', []);
1028
+ const bid = this.safeValue(ticker, 'b', []);
1029
+ const ask = this.safeValue(ticker, 'a', []);
1030
+ return this.safeTicker({
1031
+ 'symbol': symbol,
1032
+ 'timestamp': undefined,
1033
+ 'datetime': undefined,
1034
+ 'high': this.safeString(high, 1),
1035
+ 'low': this.safeString(low, 1),
1036
+ 'bid': this.safeString(bid, 0),
1037
+ 'bidVolume': this.safeString(bid, 2),
1038
+ 'ask': this.safeString(ask, 0),
1039
+ 'askVolume': this.safeString(ask, 2),
1040
+ 'vwap': vwap,
1041
+ 'open': this.safeString(ticker, 'o'),
1042
+ 'close': last,
1043
+ 'last': last,
1044
+ 'previousClose': undefined,
1045
+ 'change': undefined,
1046
+ 'percentage': undefined,
1047
+ 'average': undefined,
1048
+ 'baseVolume': baseVolume,
1049
+ 'quoteVolume': quoteVolume,
1050
+ 'info': ticker,
1051
+ }, market);
1052
+ }
1053
+ /**
1054
+ * @method
1055
+ * @name kraken#fetchTickers
1056
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1057
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
1058
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1059
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1060
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1061
+ */
1062
+ async fetchTickers(symbols = undefined, params = {}) {
1063
+ await this.loadMarkets();
1064
+ const request = {};
1065
+ if (symbols !== undefined) {
1066
+ symbols = this.marketSymbols(symbols);
1067
+ const marketIds = [];
1068
+ for (let i = 0; i < symbols.length; i++) {
1069
+ const symbol = symbols[i];
1070
+ const market = this.markets[symbol];
1071
+ if (market['active']) {
1072
+ marketIds.push(market['id']);
1073
+ }
1074
+ }
1075
+ request['pair'] = marketIds.join(',');
1076
+ }
1077
+ const response = await this.publicGetTicker(this.extend(request, params));
1078
+ const tickers = response['result'];
1079
+ const ids = Object.keys(tickers);
1080
+ const result = {};
1081
+ for (let i = 0; i < ids.length; i++) {
1082
+ const id = ids[i];
1083
+ const market = this.safeMarket(id);
1084
+ const symbol = market['symbol'];
1085
+ const ticker = tickers[id];
1086
+ result[symbol] = this.parseTicker(ticker, market);
1087
+ }
1088
+ return this.filterByArrayTickers(result, 'symbol', symbols);
1089
+ }
1090
+ /**
1091
+ * @method
1092
+ * @name kraken#fetchTicker
1093
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1094
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
1095
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1096
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1097
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1098
+ */
1099
+ async fetchTicker(symbol, params = {}) {
1100
+ await this.loadMarkets();
1101
+ const market = this.market(symbol);
1102
+ const request = {
1103
+ 'pair': market['id'],
1104
+ };
1105
+ const response = await this.publicGetTicker(this.extend(request, params));
1106
+ const ticker = response['result'][market['id']];
1107
+ return this.parseTicker(ticker, market);
1108
+ }
1109
+ parseOHLCV(ohlcv, market = undefined) {
1110
+ //
1111
+ // [
1112
+ // 1591475640,
1113
+ // "0.02500",
1114
+ // "0.02500",
1115
+ // "0.02500",
1116
+ // "0.02500",
1117
+ // "0.02500",
1118
+ // "9.12201000",
1119
+ // 5
1120
+ // ]
1121
+ //
1122
+ return [
1123
+ this.safeTimestamp(ohlcv, 0),
1124
+ this.safeNumber(ohlcv, 1),
1125
+ this.safeNumber(ohlcv, 2),
1126
+ this.safeNumber(ohlcv, 3),
1127
+ this.safeNumber(ohlcv, 4),
1128
+ this.safeNumber(ohlcv, 6),
1129
+ ];
1130
+ }
1131
+ /**
1132
+ * @method
1133
+ * @name kraken#fetchOHLCV
1134
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1135
+ * @see https://docs.kraken.com/api/docs/rest-api/get-ohlc-data
1136
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1137
+ * @param {string} timeframe the length of time each candle represents
1138
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1139
+ * @param {int} [limit] the maximum amount of candles to fetch
1140
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1141
+ * @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)
1142
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1143
+ */
1144
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1145
+ await this.loadMarkets();
1146
+ let paginate = false;
1147
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
1148
+ if (paginate) {
1149
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 720);
1150
+ }
1151
+ const market = this.market(symbol);
1152
+ const parsedTimeframe = this.safeInteger(this.timeframes, timeframe);
1153
+ const request = {
1154
+ 'pair': market['id'],
1155
+ };
1156
+ if (parsedTimeframe !== undefined) {
1157
+ request['interval'] = parsedTimeframe;
1158
+ }
1159
+ else {
1160
+ request['interval'] = timeframe;
1161
+ }
1162
+ if (since !== undefined) {
1163
+ const scaledSince = this.parseToInt(since / 1000);
1164
+ const timeFrameInSeconds = parsedTimeframe * 60;
1165
+ request['since'] = this.numberToString(scaledSince - timeFrameInSeconds); // expected to be in seconds
1166
+ }
1167
+ const response = await this.publicGetOHLC(this.extend(request, params));
1168
+ //
1169
+ // {
1170
+ // "error":[],
1171
+ // "result":{
1172
+ // "XETHXXBT":[
1173
+ // [1591475580,"0.02499","0.02499","0.02499","0.02499","0.00000","0.00000000",0],
1174
+ // [1591475640,"0.02500","0.02500","0.02500","0.02500","0.02500","9.12201000",5],
1175
+ // [1591475700,"0.02499","0.02499","0.02499","0.02499","0.02499","1.28681415",2],
1176
+ // [1591475760,"0.02499","0.02499","0.02499","0.02499","0.02499","0.08800000",1],
1177
+ // ],
1178
+ // "last":1591517580
1179
+ // }
1180
+ // }
1181
+ const result = this.safeValue(response, 'result', {});
1182
+ const ohlcvs = this.safeList(result, market['id'], []);
1183
+ return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
1184
+ }
1185
+ parseLedgerEntryType(type) {
1186
+ const types = {
1187
+ 'trade': 'trade',
1188
+ 'withdrawal': 'transaction',
1189
+ 'deposit': 'transaction',
1190
+ 'transfer': 'transfer',
1191
+ 'margin': 'margin',
1192
+ };
1193
+ return this.safeString(types, type, type);
1194
+ }
1195
+ parseLedgerEntry(item, currency = undefined) {
1196
+ //
1197
+ // {
1198
+ // 'LTFK7F-N2CUX-PNY4SX': {
1199
+ // "refid": "TSJTGT-DT7WN-GPPQMJ",
1200
+ // "time": 1520102320.555,
1201
+ // "type": "trade",
1202
+ // "aclass": "currency",
1203
+ // "asset": "XETH",
1204
+ // "amount": "0.1087194600",
1205
+ // "fee": "0.0000000000",
1206
+ // "balance": "0.2855851000"
1207
+ // },
1208
+ // ...
1209
+ // }
1210
+ //
1211
+ const id = this.safeString(item, 'id');
1212
+ let direction = undefined;
1213
+ const account = undefined;
1214
+ const referenceId = this.safeString(item, 'refid');
1215
+ const referenceAccount = undefined;
1216
+ const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
1217
+ const currencyId = this.safeString(item, 'asset');
1218
+ const code = this.safeCurrencyCode(currencyId, currency);
1219
+ currency = this.safeCurrency(currencyId, currency);
1220
+ let amount = this.safeString(item, 'amount');
1221
+ if (Precise.stringLt(amount, '0')) {
1222
+ direction = 'out';
1223
+ amount = Precise.stringAbs(amount);
1224
+ }
1225
+ else {
1226
+ direction = 'in';
1227
+ }
1228
+ const timestamp = this.safeIntegerProduct(item, 'time', 1000);
1229
+ return this.safeLedgerEntry({
1230
+ 'info': item,
1231
+ 'id': id,
1232
+ 'direction': direction,
1233
+ 'account': account,
1234
+ 'referenceId': referenceId,
1235
+ 'referenceAccount': referenceAccount,
1236
+ 'type': type,
1237
+ 'currency': code,
1238
+ 'amount': this.parseNumber(amount),
1239
+ 'before': undefined,
1240
+ 'after': this.safeNumber(item, 'balance'),
1241
+ 'status': 'ok',
1242
+ 'timestamp': timestamp,
1243
+ 'datetime': this.iso8601(timestamp),
1244
+ 'fee': {
1245
+ 'cost': this.safeNumber(item, 'fee'),
1246
+ 'currency': code,
1247
+ },
1248
+ }, currency);
1249
+ }
1250
+ /**
1251
+ * @method
1252
+ * @name kraken#fetchLedger
1253
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1254
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getLedgers
1255
+ * @param {string} [code] unified currency code, default is undefined
1256
+ * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1257
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1258
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1259
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
1260
+ * @param {int} [params.end] timestamp in seconds of the latest ledger entry
1261
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
1262
+ */
1263
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1264
+ // https://www.kraken.com/features/api#get-ledgers-info
1265
+ await this.loadMarkets();
1266
+ const request = {};
1267
+ let currency = undefined;
1268
+ if (code !== undefined) {
1269
+ currency = this.currency(code);
1270
+ request['asset'] = currency['id'];
1271
+ }
1272
+ if (since !== undefined) {
1273
+ request['start'] = this.parseToInt(since / 1000);
1274
+ }
1275
+ const until = this.safeStringN(params, ['until', 'till']);
1276
+ if (until !== undefined) {
1277
+ params = this.omit(params, ['until', 'till']);
1278
+ const untilDivided = Precise.stringDiv(until, '1000');
1279
+ request['end'] = this.parseToInt(Precise.stringAdd(untilDivided, '1'));
1280
+ }
1281
+ const response = await this.privatePostLedgers(this.extend(request, params));
1282
+ // { error: [],
1283
+ // "result": { ledger: { 'LPUAIB-TS774-UKHP7X': { refid: "A2B4HBV-L4MDIE-JU4N3N",
1284
+ // "time": 1520103488.314,
1285
+ // "type": "withdrawal",
1286
+ // "aclass": "currency",
1287
+ // "asset": "XETH",
1288
+ // "amount": "-0.2805800000",
1289
+ // "fee": "0.0050000000",
1290
+ // "balance": "0.0000051000" },
1291
+ const result = this.safeValue(response, 'result', {});
1292
+ const ledger = this.safeValue(result, 'ledger', {});
1293
+ const keys = Object.keys(ledger);
1294
+ const items = [];
1295
+ for (let i = 0; i < keys.length; i++) {
1296
+ const key = keys[i];
1297
+ const value = ledger[key];
1298
+ value['id'] = key;
1299
+ items.push(value);
1300
+ }
1301
+ return this.parseLedger(items, currency, since, limit);
1302
+ }
1303
+ async fetchLedgerEntriesByIds(ids, code = undefined, params = {}) {
1304
+ // https://www.kraken.com/features/api#query-ledgers
1305
+ await this.loadMarkets();
1306
+ ids = ids.join(',');
1307
+ const request = this.extend({
1308
+ 'id': ids,
1309
+ }, params);
1310
+ const response = await this.privatePostQueryLedgers(request);
1311
+ // { error: [],
1312
+ // "result": { 'LPUAIB-TS774-UKHP7X': { refid: "A2B4HBV-L4MDIE-JU4N3N",
1313
+ // "time": 1520103488.314,
1314
+ // "type": "withdrawal",
1315
+ // "aclass": "currency",
1316
+ // "asset": "XETH",
1317
+ // "amount": "-0.2805800000",
1318
+ // "fee": "0.0050000000",
1319
+ // "balance": "0.0000051000" } } }
1320
+ const result = response['result'];
1321
+ const keys = Object.keys(result);
1322
+ const items = [];
1323
+ for (let i = 0; i < keys.length; i++) {
1324
+ const key = keys[i];
1325
+ const value = result[key];
1326
+ value['id'] = key;
1327
+ items.push(value);
1328
+ }
1329
+ return this.parseLedger(items);
1330
+ }
1331
+ async fetchLedgerEntry(id, code = undefined, params = {}) {
1332
+ const items = await this.fetchLedgerEntriesByIds([id], code, params);
1333
+ return items[0];
1334
+ }
1335
+ parseTrade(trade, market = undefined) {
1336
+ //
1337
+ // fetchTrades (public)
1338
+ //
1339
+ // [
1340
+ // "0.032310", // price
1341
+ // "4.28169434", // amount
1342
+ // 1541390792.763, // timestamp
1343
+ // "s", // sell or buy
1344
+ // "l", // limit or market
1345
+ // ""
1346
+ // ]
1347
+ //
1348
+ // fetchOrderTrades (private)
1349
+ //
1350
+ // {
1351
+ // "id": 'TIMIRG-WUNNE-RRJ6GT', // injected from outside
1352
+ // "ordertxid": 'OQRPN2-LRHFY-HIFA7D',
1353
+ // "postxid": 'TKH2SE-M7IF5-CFI7LT',
1354
+ // "pair": 'USDCUSDT',
1355
+ // "time": 1586340086.457,
1356
+ // "type": 'sell',
1357
+ // "ordertype": 'market',
1358
+ // "price": '0.99860000',
1359
+ // "cost": '22.16892001',
1360
+ // "fee": '0.04433784',
1361
+ // "vol": '22.20000000',
1362
+ // "margin": '0.00000000',
1363
+ // "misc": ''
1364
+ // }
1365
+ //
1366
+ // fetchMyTrades
1367
+ //
1368
+ // {
1369
+ // "ordertxid": "OSJVN7-A2AE-63WZV",
1370
+ // "postxid": "TBP7O6-PNXI-CONU",
1371
+ // "pair": "XXBTZUSD",
1372
+ // "time": 1710429248.3052235,
1373
+ // "type": "sell",
1374
+ // "ordertype": "liquidation market",
1375
+ // "price": "72026.50000",
1376
+ // "cost": "7.20265",
1377
+ // "fee": "0.01873",
1378
+ // "vol": "0.00010000",
1379
+ // "margin": "1.44053",
1380
+ // "leverage": "5",
1381
+ // "misc": "closing",
1382
+ // "trade_id": 68230622,
1383
+ // "maker": false
1384
+ // }
1385
+ //
1386
+ // watchTrades
1387
+ //
1388
+ // {
1389
+ // "symbol": "BTC/USD",
1390
+ // "side": "buy",
1391
+ // "price": 109601.2,
1392
+ // "qty": 0.04561994,
1393
+ // "ord_type": "market",
1394
+ // "trade_id": 83449369,
1395
+ // "timestamp": "2025-05-27T11:24:03.847761Z"
1396
+ // }
1397
+ //
1398
+ let timestamp = undefined;
1399
+ let datetime = undefined;
1400
+ let side = undefined;
1401
+ let type = undefined;
1402
+ let price = undefined;
1403
+ let amount = undefined;
1404
+ let id = undefined;
1405
+ let orderId = undefined;
1406
+ let fee = undefined;
1407
+ let symbol = undefined;
1408
+ if (Array.isArray(trade)) {
1409
+ timestamp = this.safeTimestamp(trade, 2);
1410
+ side = (trade[3] === 's') ? 'sell' : 'buy';
1411
+ type = (trade[4] === 'l') ? 'limit' : 'market';
1412
+ price = this.safeString(trade, 0);
1413
+ amount = this.safeString(trade, 1);
1414
+ const tradeLength = trade.length;
1415
+ if (tradeLength > 6) {
1416
+ id = this.safeString(trade, 6); // artificially added as per #1794
1417
+ }
1418
+ }
1419
+ else if (typeof trade === 'string') {
1420
+ id = trade;
1421
+ }
1422
+ else if ('ordertxid' in trade) {
1423
+ const marketId = this.safeString(trade, 'pair');
1424
+ const foundMarket = this.findMarketByAltnameOrId(marketId);
1425
+ if (foundMarket !== undefined) {
1426
+ market = foundMarket;
1427
+ }
1428
+ else if (marketId !== undefined) {
1429
+ // delisted market ids go here
1430
+ market = this.getDelistedMarketById(marketId);
1431
+ }
1432
+ orderId = this.safeString(trade, 'ordertxid');
1433
+ id = this.safeString2(trade, 'id', 'postxid');
1434
+ timestamp = this.safeTimestamp(trade, 'time');
1435
+ side = this.safeString(trade, 'type');
1436
+ type = this.safeString(trade, 'ordertype');
1437
+ price = this.safeString(trade, 'price');
1438
+ amount = this.safeString(trade, 'vol');
1439
+ if ('fee' in trade) {
1440
+ let currency = undefined;
1441
+ if (market !== undefined) {
1442
+ currency = market['quote'];
1443
+ }
1444
+ fee = {
1445
+ 'cost': this.safeString(trade, 'fee'),
1446
+ 'currency': currency,
1447
+ };
1448
+ }
1449
+ }
1450
+ else {
1451
+ symbol = this.safeString(trade, 'symbol');
1452
+ datetime = this.safeString(trade, 'timestamp');
1453
+ id = this.safeString(trade, 'trade_id');
1454
+ side = this.safeString(trade, 'side');
1455
+ type = this.safeString(trade, 'ord_type');
1456
+ price = this.safeString(trade, 'price');
1457
+ amount = this.safeString(trade, 'qty');
1458
+ }
1459
+ if (market !== undefined) {
1460
+ symbol = market['symbol'];
1461
+ }
1462
+ const cost = this.safeString(trade, 'cost');
1463
+ const maker = this.safeBool(trade, 'maker');
1464
+ let takerOrMaker = undefined;
1465
+ if (maker !== undefined) {
1466
+ takerOrMaker = maker ? 'maker' : 'taker';
1467
+ }
1468
+ if (datetime === undefined) {
1469
+ datetime = this.iso8601(timestamp);
1470
+ }
1471
+ else {
1472
+ timestamp = this.parse8601(datetime);
1473
+ }
1474
+ return this.safeTrade({
1475
+ 'id': id,
1476
+ 'order': orderId,
1477
+ 'info': trade,
1478
+ 'timestamp': timestamp,
1479
+ 'datetime': datetime,
1480
+ 'symbol': symbol,
1481
+ 'type': type,
1482
+ 'side': side,
1483
+ 'takerOrMaker': takerOrMaker,
1484
+ 'price': price,
1485
+ 'amount': amount,
1486
+ 'cost': cost,
1487
+ 'fee': fee,
1488
+ }, market);
1489
+ }
1490
+ /**
1491
+ * @method
1492
+ * @name kraken#fetchTrades
1493
+ * @description get the list of most recent trades for a particular symbol
1494
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getRecentTrades
1495
+ * @param {string} symbol unified symbol of the market to fetch trades for
1496
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1497
+ * @param {int} [limit] the maximum amount of trades to fetch
1498
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1499
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1500
+ */
1501
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1502
+ await this.loadMarkets();
1503
+ const market = this.market(symbol);
1504
+ const id = market['id'];
1505
+ const request = {
1506
+ 'pair': id,
1507
+ };
1508
+ // https://support.kraken.com/hc/en-us/articles/218198197-How-to-pull-all-trade-data-using-the-Kraken-REST-API
1509
+ // https://github.com/ccxt/ccxt/issues/5677
1510
+ if (since !== undefined) {
1511
+ request['since'] = this.numberToString(this.parseToInt(since / 1000)); // expected to be in seconds
1512
+ }
1513
+ if (limit !== undefined) {
1514
+ request['count'] = limit;
1515
+ }
1516
+ const response = await this.publicGetTrades(this.extend(request, params));
1517
+ //
1518
+ // {
1519
+ // "error": [],
1520
+ // "result": {
1521
+ // "XETHXXBT": [
1522
+ // ["0.032310","4.28169434",1541390792.763,"s","l",""]
1523
+ // ],
1524
+ // "last": "1541439421200678657"
1525
+ // }
1526
+ // }
1527
+ //
1528
+ const result = response['result'];
1529
+ const trades = result[id];
1530
+ // trades is a sorted array: last (most recent trade) goes last
1531
+ const length = trades.length;
1532
+ if (length <= 0) {
1533
+ return [];
1534
+ }
1535
+ const lastTrade = trades[length - 1];
1536
+ const lastTradeId = this.safeString(result, 'last');
1537
+ lastTrade.push(lastTradeId);
1538
+ trades[length - 1] = lastTrade;
1539
+ return this.parseTrades(trades, market, since, limit);
1540
+ }
1541
+ parseBalance(response) {
1542
+ const balances = this.safeValue(response, 'result', {});
1543
+ const result = {
1544
+ 'info': response,
1545
+ 'timestamp': undefined,
1546
+ 'datetime': undefined,
1547
+ };
1548
+ const currencyIds = Object.keys(balances);
1549
+ for (let i = 0; i < currencyIds.length; i++) {
1550
+ const currencyId = currencyIds[i];
1551
+ const code = this.safeCurrencyCode(currencyId);
1552
+ const balance = this.safeValue(balances, currencyId, {});
1553
+ const account = this.account();
1554
+ account['used'] = this.safeString(balance, 'hold_trade');
1555
+ account['total'] = this.safeString(balance, 'balance');
1556
+ result[code] = account;
1557
+ }
1558
+ return this.safeBalance(result);
1559
+ }
1560
+ /**
1561
+ * @method
1562
+ * @name kraken#fetchBalance
1563
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1564
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getExtendedBalance
1565
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1566
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1567
+ */
1568
+ async fetchBalance(params = {}) {
1569
+ await this.loadMarkets();
1570
+ const response = await this.privatePostBalanceEx(params);
1571
+ //
1572
+ // {
1573
+ // "error": [],
1574
+ // "result": {
1575
+ // "ZUSD": {
1576
+ // "balance": 25435.21,
1577
+ // "hold_trade": 8249.76
1578
+ // },
1579
+ // "XXBT": {
1580
+ // "balance": 1.2435,
1581
+ // "hold_trade": 0.8423
1582
+ // }
1583
+ // }
1584
+ // }
1585
+ //
1586
+ return this.parseBalance(response);
1587
+ }
1588
+ /**
1589
+ * @method
1590
+ * @name kraken#createMarketOrderWithCost
1591
+ * @description create a market order by providing the symbol, side and cost
1592
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/addOrder
1593
+ * @param {string} symbol unified symbol of the market to create an order in (only USD markets are supported)
1594
+ * @param {string} side 'buy' or 'sell'
1595
+ * @param {float} cost how much you want to trade in units of the quote currency
1596
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1597
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1598
+ */
1599
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
1600
+ await this.loadMarkets();
1601
+ // only buy orders are supported by the endpoint
1602
+ const req = {
1603
+ 'cost': cost,
1604
+ };
1605
+ return await this.createOrder(symbol, 'market', side, cost, undefined, this.extend(req, params));
1606
+ }
1607
+ /**
1608
+ * @method
1609
+ * @name kraken#createMarketBuyOrderWithCost
1610
+ * @description create a market buy order by providing the symbol, side and cost
1611
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/addOrder
1612
+ * @param {string} symbol unified symbol of the market to create an order in
1613
+ * @param {float} cost how much you want to trade in units of the quote currency
1614
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1615
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1616
+ */
1617
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1618
+ await this.loadMarkets();
1619
+ return await this.createMarketOrderWithCost(symbol, 'buy', cost, params);
1620
+ }
1621
+ /**
1622
+ * @method
1623
+ * @name kraken#createOrder
1624
+ * @description create a trade order
1625
+ * @see https://docs.kraken.com/api/docs/rest-api/add-order
1626
+ * @param {string} symbol unified symbol of the market to create an order in
1627
+ * @param {string} type 'market' or 'limit'
1628
+ * @param {string} side 'buy' or 'sell'
1629
+ * @param {float} amount how much of currency you want to trade in units of base currency
1630
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1631
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1632
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
1633
+ * @param {bool} [params.reduceOnly] *margin only* indicates if this order is to reduce the size of a position
1634
+ * @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
1635
+ * @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
1636
+ * @param {string} [params.trailingAmount] *margin only* the quote amount to trail away from the current market price
1637
+ * @param {string} [params.trailingPercent] *margin only* the percent to trail away from the current market price
1638
+ * @param {string} [params.trailingLimitAmount] *margin only* the quote amount away from the trailingAmount
1639
+ * @param {string} [params.trailingLimitPercent] *margin only* the percent away from the trailingAmount
1640
+ * @param {string} [params.offset] *margin only* '+' or '-' whether you want the trailingLimitAmount value to be positive or negative, default is negative '-'
1641
+ * @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
1642
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1643
+ */
1644
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1645
+ await this.loadMarkets();
1646
+ const market = this.market(symbol);
1647
+ const request = {
1648
+ 'pair': market['id'],
1649
+ 'type': side,
1650
+ 'ordertype': type,
1651
+ 'volume': this.amountToPrecision(symbol, amount),
1652
+ };
1653
+ const orderRequest = this.orderRequest('createOrder', symbol, type, request, amount, price, params);
1654
+ const flags = this.safeString(orderRequest[0], 'oflags', '');
1655
+ const isUsingCost = flags.indexOf('viqc') > -1;
1656
+ const response = await this.privatePostAddOrder(this.extend(orderRequest[0], orderRequest[1]));
1657
+ //
1658
+ // {
1659
+ // "error": [],
1660
+ // "result": {
1661
+ // "descr": { order: 'buy 0.02100000 ETHUSDT @ limit 330.00' }, // see more examples in "parseOrder"
1662
+ // "txid": [ 'OEKVV2-IH52O-TPL6GZ' ]
1663
+ // }
1664
+ // }
1665
+ //
1666
+ const result = this.safeDict(response, 'result');
1667
+ result['usingCost'] = isUsingCost;
1668
+ // it's impossible to know if the order was created using cost or base currency
1669
+ // becuase kraken only returns something like this: { order: 'buy 10.00000000 LTCUSD @ market' }
1670
+ // this usingCost flag is used to help the parsing but omited from the order
1671
+ return this.parseOrder(result);
1672
+ }
1673
+ findMarketByAltnameOrId(id) {
1674
+ const marketsByAltname = this.safeValue(this.options, 'marketsByAltname', {});
1675
+ if (id in marketsByAltname) {
1676
+ return marketsByAltname[id];
1677
+ }
1678
+ else {
1679
+ return this.safeMarket(id);
1680
+ }
1681
+ }
1682
+ getDelistedMarketById(id) {
1683
+ if (id === undefined) {
1684
+ return id;
1685
+ }
1686
+ let market = this.safeValue(this.options['delistedMarketsById'], id);
1687
+ if (market !== undefined) {
1688
+ return market;
1689
+ }
1690
+ const baseIdStart = 0;
1691
+ let baseIdEnd = 3;
1692
+ let quoteIdStart = 3;
1693
+ let quoteIdEnd = 6;
1694
+ if (id.length === 8) {
1695
+ baseIdEnd = 4;
1696
+ quoteIdStart = 4;
1697
+ quoteIdEnd = 8;
1698
+ }
1699
+ else if (id.length === 7) {
1700
+ baseIdEnd = 4;
1701
+ quoteIdStart = 4;
1702
+ quoteIdEnd = 7;
1703
+ }
1704
+ const baseId = id.slice(baseIdStart, baseIdEnd);
1705
+ const quoteId = id.slice(quoteIdStart, quoteIdEnd);
1706
+ const base = this.safeCurrencyCode(baseId);
1707
+ const quote = this.safeCurrencyCode(quoteId);
1708
+ const symbol = base + '/' + quote;
1709
+ market = {
1710
+ 'symbol': symbol,
1711
+ 'base': base,
1712
+ 'quote': quote,
1713
+ 'baseId': baseId,
1714
+ 'quoteId': quoteId,
1715
+ };
1716
+ this.options['delistedMarketsById'][id] = market;
1717
+ return market;
1718
+ }
1719
+ parseOrderStatus(status) {
1720
+ const statuses = {
1721
+ 'pending': 'open',
1722
+ 'open': 'open',
1723
+ 'closed': 'closed',
1724
+ 'canceled': 'canceled',
1725
+ 'expired': 'expired',
1726
+ };
1727
+ return this.safeString(statuses, status, status);
1728
+ }
1729
+ parseOrderType(status) {
1730
+ const statuses = {
1731
+ // we dont add "space" delimited orders here (eg. stop loss) because they need separate parsing
1732
+ 'take-profit': 'market',
1733
+ 'stop-loss': 'market',
1734
+ 'stop-loss-limit': 'limit',
1735
+ 'take-profit-limit': 'limit',
1736
+ 'trailing-stop-limit': 'limit',
1737
+ };
1738
+ return this.safeString(statuses, status, status);
1739
+ }
1740
+ parseOrder(order, market = undefined) {
1741
+ //
1742
+ // createOrder
1743
+ //
1744
+ // {
1745
+ // "descr": {
1746
+ // "order": "buy 0.02100000 ETHUSDT @ limit 330.00" // limit orders
1747
+ // "buy 0.12345678 ETHUSDT @ market" // market order
1748
+ // "sell 0.28002676 ETHUSDT @ stop loss 0.0123 -> limit 0.0.1222" // stop order
1749
+ // "sell 0.00100000 ETHUSDT @ stop loss 2677.00 -> limit 2577.00 with 5:1 leverage"
1750
+ // "buy 0.10000000 LTCUSDT @ take profit 75.00000 -> limit 74.00000"
1751
+ // "sell 10.00000000 XRPEUR @ trailing stop +50.0000%" // trailing stop
1752
+ // },
1753
+ // "txid": [ 'OEKVV2-IH52O-TPL6GZ' ]
1754
+ // }
1755
+ //
1756
+ // editOrder
1757
+ //
1758
+ // {
1759
+ // "amend_id": "TJSMEH-AA67V-YUSQ6O"
1760
+ // }
1761
+ //
1762
+ // ws - createOrder
1763
+ // {
1764
+ // "order_id": "OXM2QD-EALR2-YBAVEU"
1765
+ // }
1766
+ //
1767
+ // ws - editOrder
1768
+ // {
1769
+ // "amend_id": "TJSMEH-AA67V-YUSQ6O",
1770
+ // "order_id": "OXM2QD-EALR2-YBAVEU"
1771
+ // }
1772
+ //
1773
+ // {
1774
+ // "error": [],
1775
+ // "result": {
1776
+ // "open": {
1777
+ // "OXVPSU-Q726F-L3SDEP": {
1778
+ // "refid": null,
1779
+ // "userref": 0,
1780
+ // "status": "open",
1781
+ // "opentm": 1706893367.4656649,
1782
+ // "starttm": 0,
1783
+ // "expiretm": 0,
1784
+ // "descr": {
1785
+ // "pair": "XRPEUR",
1786
+ // "type": "sell",
1787
+ // "ordertype": "trailing-stop",
1788
+ // "price": "+50.0000%",
1789
+ // "price2": "0",
1790
+ // "leverage": "none",
1791
+ // "order": "sell 10.00000000 XRPEUR @ trailing stop +50.0000%",
1792
+ // "close": ""
1793
+ // },
1794
+ // "vol": "10.00000000",
1795
+ // "vol_exec": "0.00000000",
1796
+ // "cost": "0.00000000",
1797
+ // "fee": "0.00000000",
1798
+ // "price": "0.00000000",
1799
+ // "stopprice": "0.23424000",
1800
+ // "limitprice": "0.46847000",
1801
+ // "misc": "",
1802
+ // "oflags": "fciq",
1803
+ // "trigger": "index"
1804
+ // }
1805
+ // }
1806
+ // }
1807
+ //
1808
+ // fetchOpenOrders
1809
+ //
1810
+ // {
1811
+ // "refid": null,
1812
+ // "userref": null,
1813
+ // "cl_ord_id": "1234",
1814
+ // "status": "open",
1815
+ // "opentm": 1733815269.370054,
1816
+ // "starttm": 0,
1817
+ // "expiretm": 0,
1818
+ // "descr": {
1819
+ // "pair": "XBTUSD",
1820
+ // "type": "buy",
1821
+ // "ordertype": "limit",
1822
+ // "price": "70000.0",
1823
+ // "price2": "0",
1824
+ // "leverage": "none",
1825
+ // "order": "buy 0.00010000 XBTUSD @ limit 70000.0",
1826
+ // "close": ""
1827
+ // },
1828
+ // "vol": "0.00010000",
1829
+ // "vol_exec": "0.00000000",
1830
+ // "cost": "0.00000",
1831
+ // "fee": "0.00000",
1832
+ // "price": "0.00000",
1833
+ // "stopprice": "0.00000",
1834
+ // "limitprice": "0.00000",
1835
+ // "misc": "",
1836
+ // "oflags": "fciq"
1837
+ // }
1838
+ //
1839
+ const isUsingCost = this.safeBool(order, 'usingCost', false);
1840
+ order = this.omit(order, 'usingCost');
1841
+ const description = this.safeDict(order, 'descr', {});
1842
+ const orderDescriptionObj = this.safeDict(order, 'descr'); // can be null
1843
+ let orderDescription = undefined;
1844
+ if (orderDescriptionObj !== undefined) {
1845
+ orderDescription = this.safeString(orderDescriptionObj, 'order');
1846
+ }
1847
+ else {
1848
+ orderDescription = this.safeString(order, 'descr');
1849
+ }
1850
+ let side = undefined;
1851
+ let rawType = undefined;
1852
+ let marketId = undefined;
1853
+ let price = undefined;
1854
+ let amount = undefined;
1855
+ let cost = undefined;
1856
+ let triggerPrice = undefined;
1857
+ if (orderDescription !== undefined) {
1858
+ const parts = orderDescription.split(' ');
1859
+ side = this.safeString(parts, 0);
1860
+ if (!isUsingCost) {
1861
+ amount = this.safeString(parts, 1);
1862
+ }
1863
+ else {
1864
+ cost = this.safeString(parts, 1);
1865
+ }
1866
+ marketId = this.safeString(parts, 2);
1867
+ const part4 = this.safeString(parts, 4);
1868
+ const part5 = this.safeString(parts, 5);
1869
+ if (part4 === 'limit' || part4 === 'market') {
1870
+ rawType = part4; // eg, limit, market
1871
+ }
1872
+ else {
1873
+ rawType = part4 + ' ' + part5; // eg. stop loss, take profit, trailing stop
1874
+ }
1875
+ if (rawType === 'stop loss' || rawType === 'take profit') {
1876
+ triggerPrice = this.safeString(parts, 6);
1877
+ price = this.safeString(parts, 9);
1878
+ }
1879
+ else if (rawType === 'limit') {
1880
+ price = this.safeString(parts, 5);
1881
+ }
1882
+ }
1883
+ side = this.safeString(description, 'type', side);
1884
+ rawType = this.safeString(description, 'ordertype', rawType); // orderType has dash, e.g. trailing-stop
1885
+ marketId = this.safeString(description, 'pair', marketId);
1886
+ const foundMarket = this.findMarketByAltnameOrId(marketId);
1887
+ let symbol = undefined;
1888
+ if (foundMarket !== undefined) {
1889
+ market = foundMarket;
1890
+ }
1891
+ else if (marketId !== undefined) {
1892
+ // delisted market ids go here
1893
+ market = this.getDelistedMarketById(marketId);
1894
+ }
1895
+ const timestamp = this.safeTimestamp(order, 'opentm');
1896
+ amount = this.safeString(order, 'vol', amount);
1897
+ const filled = this.safeString(order, 'vol_exec');
1898
+ let fee = undefined;
1899
+ // kraken truncates the cost in the api response so we will ignore it and calculate it from average & filled
1900
+ // const cost = this.safeString (order, 'cost');
1901
+ price = this.safeString(description, 'price', price);
1902
+ // when type = trailing stop returns price = '+50.0000%'
1903
+ if ((price !== undefined) && (price.endsWith('%') || Precise.stringEquals(price, '0.00000') || Precise.stringEquals(price, '0'))) {
1904
+ price = undefined; // this is not the price we want
1905
+ }
1906
+ if (price === undefined) {
1907
+ price = this.safeString(description, 'price2');
1908
+ price = this.safeString2(order, 'limitprice', 'price', price);
1909
+ }
1910
+ const flags = this.safeString(order, 'oflags', '');
1911
+ let isPostOnly = flags.indexOf('post') > -1;
1912
+ const average = this.safeNumber(order, 'price');
1913
+ if (market !== undefined) {
1914
+ symbol = market['symbol'];
1915
+ if ('fee' in order) {
1916
+ const feeCost = this.safeString(order, 'fee');
1917
+ fee = {
1918
+ 'cost': feeCost,
1919
+ 'rate': undefined,
1920
+ };
1921
+ if (flags.indexOf('fciq') >= 0) {
1922
+ fee['currency'] = market['quote'];
1923
+ }
1924
+ else if (flags.indexOf('fcib') >= 0) {
1925
+ fee['currency'] = market['base'];
1926
+ }
1927
+ }
1928
+ }
1929
+ const status = this.parseOrderStatus(this.safeString(order, 'status'));
1930
+ let id = this.safeStringN(order, ['id', 'txid', 'order_id', 'amend_id']);
1931
+ if ((id === undefined) || (id.startsWith('['))) {
1932
+ const txid = this.safeList(order, 'txid');
1933
+ id = this.safeString(txid, 0);
1934
+ }
1935
+ const userref = this.safeString(order, 'userref');
1936
+ const clientOrderId = this.safeString(order, 'cl_ord_id', userref);
1937
+ const rawTrades = this.safeValue(order, 'trades', []);
1938
+ const trades = [];
1939
+ for (let i = 0; i < rawTrades.length; i++) {
1940
+ const rawTrade = rawTrades[i];
1941
+ if (typeof rawTrade === 'string') {
1942
+ trades.push(this.safeTrade({ 'id': rawTrade, 'orderId': id, 'symbol': symbol, 'info': {} }));
1943
+ }
1944
+ else {
1945
+ trades.push(rawTrade);
1946
+ }
1947
+ }
1948
+ // as mentioned in #24192 PR, this field is not something consistent/actual
1949
+ // triggerPrice = this.omitZero (this.safeString (order, 'stopprice', triggerPrice));
1950
+ let stopLossPrice = undefined;
1951
+ let takeProfitPrice = undefined;
1952
+ // the dashed strings are not provided from fields (eg. fetch order)
1953
+ // while spaced strings from "order" sentence (when other fields not available)
1954
+ if (rawType !== undefined) {
1955
+ if (rawType.startsWith('take-profit')) {
1956
+ takeProfitPrice = this.safeString(description, 'price');
1957
+ price = this.omitZero(this.safeString(description, 'price2'));
1958
+ }
1959
+ else if (rawType.startsWith('stop-loss')) {
1960
+ stopLossPrice = this.safeString(description, 'price');
1961
+ price = this.omitZero(this.safeString(description, 'price2'));
1962
+ }
1963
+ else if (rawType === 'take profit') {
1964
+ takeProfitPrice = triggerPrice;
1965
+ }
1966
+ else if (rawType === 'stop loss') {
1967
+ stopLossPrice = triggerPrice;
1968
+ }
1969
+ }
1970
+ let finalType = this.parseOrderType(rawType);
1971
+ // unlike from endpoints which provide eg: "take-profit-limit"
1972
+ // for "space-delimited" orders we dont have market/limit suffixes, their format is
1973
+ // eg: `stop loss > limit 123`, so we need to parse them manually
1974
+ if (this.inArray(finalType, ['stop loss', 'take profit'])) {
1975
+ finalType = (price === undefined) ? 'market' : 'limit';
1976
+ }
1977
+ const amendId = this.safeString(order, 'amend_id');
1978
+ if (amendId !== undefined) {
1979
+ isPostOnly = undefined;
1980
+ }
1981
+ return this.safeOrder({
1982
+ 'id': id,
1983
+ 'clientOrderId': clientOrderId,
1984
+ 'info': order,
1985
+ 'timestamp': timestamp,
1986
+ 'datetime': this.iso8601(timestamp),
1987
+ 'lastTradeTimestamp': undefined,
1988
+ 'status': status,
1989
+ 'symbol': symbol,
1990
+ 'type': finalType,
1991
+ 'timeInForce': undefined,
1992
+ 'postOnly': isPostOnly,
1993
+ 'side': side,
1994
+ 'price': price,
1995
+ 'triggerPrice': triggerPrice,
1996
+ 'takeProfitPrice': takeProfitPrice,
1997
+ 'stopLossPrice': stopLossPrice,
1998
+ 'cost': cost,
1999
+ 'amount': amount,
2000
+ 'filled': filled,
2001
+ 'average': average,
2002
+ 'remaining': undefined,
2003
+ 'reduceOnly': this.safeBool2(order, 'reduceOnly', 'reduce_only'),
2004
+ 'fee': fee,
2005
+ 'trades': trades,
2006
+ }, market);
2007
+ }
2008
+ orderRequest(method, symbol, type, request, amount, price = undefined, params = {}) {
2009
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2010
+ params = this.omit(params, ['clientOrderId']);
2011
+ if (clientOrderId !== undefined) {
2012
+ request['cl_ord_id'] = clientOrderId;
2013
+ }
2014
+ const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
2015
+ const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
2016
+ const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
2017
+ const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
2018
+ const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
2019
+ const trailingAmount = this.safeString(params, 'trailingAmount');
2020
+ const trailingPercent = this.safeString(params, 'trailingPercent');
2021
+ const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
2022
+ const trailingLimitPercent = this.safeString(params, 'trailingLimitPercent');
2023
+ const isTrailingAmountOrder = trailingAmount !== undefined;
2024
+ const isTrailingPercentOrder = trailingPercent !== undefined;
2025
+ const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
2026
+ const isMarketOrder = type === 'market';
2027
+ const cost = this.safeString(params, 'cost');
2028
+ const flags = this.safeString(params, 'oflags');
2029
+ params = this.omit(params, ['cost', 'oflags']);
2030
+ const isViqcOrder = (flags !== undefined) && (flags.indexOf('viqc') > -1); // volume in quote currency
2031
+ if (isMarketOrder && (cost !== undefined || isViqcOrder)) {
2032
+ if (cost === undefined && (amount !== undefined)) {
2033
+ request['volume'] = this.costToPrecision(symbol, this.numberToString(amount));
2034
+ }
2035
+ else {
2036
+ request['volume'] = this.costToPrecision(symbol, cost);
2037
+ }
2038
+ const extendedOflags = (flags !== undefined) ? flags + ',viqc' : 'viqc';
2039
+ request['oflags'] = extendedOflags;
2040
+ }
2041
+ else if (isLimitOrder && !isTrailingAmountOrder && !isTrailingPercentOrder) {
2042
+ request['price'] = this.priceToPrecision(symbol, price);
2043
+ }
2044
+ const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only');
2045
+ if (isStopLossOrTakeProfitTrigger) {
2046
+ if (isStopLossTriggerOrder) {
2047
+ request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
2048
+ if (isLimitOrder) {
2049
+ request['ordertype'] = 'stop-loss-limit';
2050
+ }
2051
+ else {
2052
+ request['ordertype'] = 'stop-loss';
2053
+ }
2054
+ }
2055
+ else if (isTakeProfitTriggerOrder) {
2056
+ request['price'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
2057
+ if (isLimitOrder) {
2058
+ request['ordertype'] = 'take-profit-limit';
2059
+ }
2060
+ else {
2061
+ request['ordertype'] = 'take-profit';
2062
+ }
2063
+ }
2064
+ if (isLimitOrder) {
2065
+ request['price2'] = this.priceToPrecision(symbol, price);
2066
+ }
2067
+ }
2068
+ else if (isTrailingAmountOrder || isTrailingPercentOrder) {
2069
+ let trailingPercentString = undefined;
2070
+ if (trailingPercent !== undefined) {
2071
+ trailingPercentString = (trailingPercent.endsWith('%')) ? ('+' + trailingPercent) : ('+' + trailingPercent + '%');
2072
+ }
2073
+ const trailingAmountString = (trailingAmount !== undefined) ? '+' + trailingAmount : undefined; // must use + for this
2074
+ const offset = this.safeString(params, 'offset', '-'); // can use + or - for this
2075
+ const trailingLimitAmountString = (trailingLimitAmount !== undefined) ? offset + this.numberToString(trailingLimitAmount) : undefined;
2076
+ const trailingActivationPriceType = this.safeString(params, 'trigger', 'last');
2077
+ request['trigger'] = trailingActivationPriceType;
2078
+ if (isLimitOrder || (trailingLimitAmount !== undefined) || (trailingLimitPercent !== undefined)) {
2079
+ request['ordertype'] = 'trailing-stop-limit';
2080
+ if (trailingLimitPercent !== undefined) {
2081
+ const trailingLimitPercentString = (trailingLimitPercent.endsWith('%')) ? (offset + trailingLimitPercent) : (offset + trailingLimitPercent + '%');
2082
+ request['price'] = trailingPercentString;
2083
+ request['price2'] = trailingLimitPercentString;
2084
+ }
2085
+ else if (trailingLimitAmount !== undefined) {
2086
+ request['price'] = trailingAmountString;
2087
+ request['price2'] = trailingLimitAmountString;
2088
+ }
2089
+ }
2090
+ else {
2091
+ request['ordertype'] = 'trailing-stop';
2092
+ if (trailingPercent !== undefined) {
2093
+ request['price'] = trailingPercentString;
2094
+ }
2095
+ else {
2096
+ request['price'] = trailingAmountString;
2097
+ }
2098
+ }
2099
+ }
2100
+ if (reduceOnly) {
2101
+ if (method === 'createOrderWs') {
2102
+ request['reduce_only'] = true; // ws request can't have stringified bool
2103
+ }
2104
+ else {
2105
+ request['reduce_only'] = 'true'; // not using boolean in this case, because the urlencodedNested transforms it into 'True' string
2106
+ }
2107
+ }
2108
+ let close = this.safeDict(params, 'close');
2109
+ if (close !== undefined) {
2110
+ close = this.extend({}, close);
2111
+ const closePrice = this.safeValue(close, 'price');
2112
+ if (closePrice !== undefined) {
2113
+ close['price'] = this.priceToPrecision(symbol, closePrice);
2114
+ }
2115
+ const closePrice2 = this.safeValue(close, 'price2'); // stopPrice
2116
+ if (closePrice2 !== undefined) {
2117
+ close['price2'] = this.priceToPrecision(symbol, closePrice2);
2118
+ }
2119
+ request['close'] = close;
2120
+ }
2121
+ const timeInForce = this.safeString2(params, 'timeInForce', 'timeinforce');
2122
+ if (timeInForce !== undefined) {
2123
+ request['timeinforce'] = timeInForce;
2124
+ }
2125
+ const isMarket = (type === 'market');
2126
+ let postOnly = undefined;
2127
+ [postOnly, params] = this.handlePostOnly(isMarket, false, params);
2128
+ if (postOnly) {
2129
+ const extendedPostFlags = (flags !== undefined) ? flags + ',post' : 'post';
2130
+ request['oflags'] = extendedPostFlags;
2131
+ }
2132
+ if ((flags !== undefined) && !('oflags' in request)) {
2133
+ request['oflags'] = flags;
2134
+ }
2135
+ params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingLimitAmount', 'trailingLimitPercent', 'offset']);
2136
+ return [request, params];
2137
+ }
2138
+ /**
2139
+ * @method
2140
+ * @name kraken#editOrder
2141
+ * @description edit a trade order
2142
+ * @see https://docs.kraken.com/api/docs/rest-api/amend-order
2143
+ * @param {string} id order id
2144
+ * @param {string} symbol unified symbol of the market to create an order in
2145
+ * @param {string} type 'market' or 'limit'
2146
+ * @param {string} side 'buy' or 'sell'
2147
+ * @param {float} [amount] how much of the currency you want to trade in units of the base currency
2148
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2149
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2150
+ * @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
2151
+ * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
2152
+ * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
2153
+ * @param {string} [params.trailingPercent] the percent to trail away from the current market price
2154
+ * @param {string} [params.trailingLimitAmount] the quote amount away from the trailingAmount
2155
+ * @param {string} [params.trailingLimitPercent] the percent away from the trailingAmount
2156
+ * @param {string} [params.offset] '+' or '-' whether you want the trailingLimitAmount value to be positive or negative
2157
+ * @param {boolean} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
2158
+ * @param {string} [params.clientOrderId] the orders client order id
2159
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2160
+ */
2161
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
2162
+ await this.loadMarkets();
2163
+ const market = this.market(symbol);
2164
+ if (!market['spot']) {
2165
+ throw new NotSupported(this.id + ' editOrder() does not support ' + market['type'] + ' orders, only spot orders are accepted');
2166
+ }
2167
+ let request = {
2168
+ 'txid': id,
2169
+ };
2170
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'cl_ord_id');
2171
+ if (clientOrderId !== undefined) {
2172
+ request['cl_ord_id'] = clientOrderId;
2173
+ params = this.omit(params, ['clientOrderId', 'cl_ord_id']);
2174
+ request = this.omit(request, 'txid');
2175
+ }
2176
+ const isMarket = (type === 'market');
2177
+ let postOnly = undefined;
2178
+ [postOnly, params] = this.handlePostOnly(isMarket, false, params);
2179
+ if (postOnly) {
2180
+ request['post_only'] = 'true'; // not using boolean in this case, because the urlencodedNested transforms it into 'True' string
2181
+ }
2182
+ if (amount !== undefined) {
2183
+ request['order_qty'] = this.amountToPrecision(symbol, amount);
2184
+ }
2185
+ if (price !== undefined) {
2186
+ request['limit_price'] = this.priceToPrecision(symbol, price);
2187
+ }
2188
+ let allTriggerPrices = this.safeStringN(params, ['stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingLimitAmount', 'trailingLimitPercent']);
2189
+ if (allTriggerPrices !== undefined) {
2190
+ const offset = this.safeString(params, 'offset');
2191
+ params = this.omit(params, ['stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingLimitAmount', 'trailingLimitPercent', 'offset']);
2192
+ if (offset !== undefined) {
2193
+ allTriggerPrices = offset + allTriggerPrices;
2194
+ request['trigger_price'] = allTriggerPrices;
2195
+ }
2196
+ else {
2197
+ request['trigger_price'] = this.priceToPrecision(symbol, allTriggerPrices);
2198
+ }
2199
+ }
2200
+ const response = await this.privatePostAmendOrder(this.extend(request, params));
2201
+ //
2202
+ // {
2203
+ // "error": [],
2204
+ // "result": {
2205
+ // "amend_id": "TJSMEH-AA67V-YUSQ6O"
2206
+ // }
2207
+ // }
2208
+ //
2209
+ const result = this.safeDict(response, 'result', {});
2210
+ return this.parseOrder(result, market);
2211
+ }
2212
+ /**
2213
+ * @method
2214
+ * @name kraken#fetchOrder
2215
+ * @description fetches information on an order made by the user
2216
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOrdersInfo
2217
+ * @param {string} id order id
2218
+ * @param {string} symbol not used by kraken fetchOrder
2219
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2220
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2221
+ */
2222
+ async fetchOrder(id, symbol = undefined, params = {}) {
2223
+ await this.loadMarkets();
2224
+ const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId');
2225
+ const request = {
2226
+ 'trades': true,
2227
+ 'txid': id, // do not comma separate a list of ids - use fetchOrdersByIds instead
2228
+ // 'userref': 'optional', // restrict results to given user reference id (optional)
2229
+ };
2230
+ let query = params;
2231
+ if (clientOrderId !== undefined) {
2232
+ request['userref'] = clientOrderId;
2233
+ query = this.omit(params, ['userref', 'clientOrderId']);
2234
+ }
2235
+ const response = await this.privatePostQueryOrders(this.extend(request, query));
2236
+ //
2237
+ // {
2238
+ // "error":[],
2239
+ // "result":{
2240
+ // "OTLAS3-RRHUF-NDWH5A":{
2241
+ // "refid":null,
2242
+ // "userref":null,
2243
+ // "status":"closed",
2244
+ // "reason":null,
2245
+ // "opentm":1586822919.3342,
2246
+ // "closetm":1586822919.365,
2247
+ // "starttm":0,
2248
+ // "expiretm":0,
2249
+ // "descr":{
2250
+ // "pair":"XBTUSDT",
2251
+ // "type":"sell",
2252
+ // "ordertype":"market",
2253
+ // "price":"0",
2254
+ // "price2":"0",
2255
+ // "leverage":"none",
2256
+ // "order":"sell 0.21804000 XBTUSDT @ market",
2257
+ // "close":""
2258
+ // },
2259
+ // "vol":"0.21804000",
2260
+ // "vol_exec":"0.21804000",
2261
+ // "cost":"1493.9",
2262
+ // "fee":"3.8",
2263
+ // "price":"6851.5",
2264
+ // "stopprice":"0.00000",
2265
+ // "limitprice":"0.00000",
2266
+ // "misc":"",
2267
+ // "oflags":"fciq",
2268
+ // "trades":["TT5UC3-GOIRW-6AZZ6R"]
2269
+ // }
2270
+ // }
2271
+ // }
2272
+ //
2273
+ const result = this.safeValue(response, 'result', []);
2274
+ if (!(id in result)) {
2275
+ throw new OrderNotFound(this.id + ' fetchOrder() could not find order id ' + id);
2276
+ }
2277
+ return this.parseOrder(this.extend({ 'id': id }, result[id]));
2278
+ }
2279
+ /**
2280
+ * @method
2281
+ * @name kraken#fetchOrderTrades
2282
+ * @description fetch all the trades made from a single order
2283
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradesInfo
2284
+ * @param {string} id order id
2285
+ * @param {string} symbol unified market symbol
2286
+ * @param {int} [since] the earliest time in ms to fetch trades for
2287
+ * @param {int} [limit] the maximum number of trades to retrieve
2288
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2289
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2290
+ */
2291
+ async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2292
+ const orderTrades = this.safeValue(params, 'trades');
2293
+ const tradeIds = [];
2294
+ if (orderTrades === undefined) {
2295
+ throw new ArgumentsRequired(this.id + " fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)");
2296
+ }
2297
+ else {
2298
+ for (let i = 0; i < orderTrades.length; i++) {
2299
+ const orderTrade = orderTrades[i];
2300
+ if (typeof orderTrade === 'string') {
2301
+ tradeIds.push(orderTrade);
2302
+ }
2303
+ else {
2304
+ tradeIds.push(orderTrade['id']);
2305
+ }
2306
+ }
2307
+ }
2308
+ await this.loadMarkets();
2309
+ if (symbol !== undefined) {
2310
+ symbol = this.symbol(symbol);
2311
+ }
2312
+ const options = this.safeValue(this.options, 'fetchOrderTrades', {});
2313
+ const batchSize = this.safeInteger(options, 'batchSize', 20);
2314
+ const numTradeIds = tradeIds.length;
2315
+ let numBatches = this.parseToInt(numTradeIds / batchSize);
2316
+ numBatches = this.sum(numBatches, 1);
2317
+ let result = [];
2318
+ for (let j = 0; j < numBatches; j++) {
2319
+ const requestIds = [];
2320
+ for (let k = 0; k < batchSize; k++) {
2321
+ const index = this.sum(j * batchSize, k);
2322
+ if (index < numTradeIds) {
2323
+ requestIds.push(tradeIds[index]);
2324
+ }
2325
+ }
2326
+ const request = {
2327
+ 'txid': requestIds.join(','),
2328
+ };
2329
+ const response = await this.privatePostQueryTrades(request);
2330
+ //
2331
+ // {
2332
+ // "error": [],
2333
+ // "result": {
2334
+ // 'TIMIRG-WUNNE-RRJ6GT': {
2335
+ // "ordertxid": 'OQRPN2-LRHFY-HIFA7D',
2336
+ // "postxid": 'TKH2SE-M7IF5-CFI7LT',
2337
+ // "pair": 'USDCUSDT',
2338
+ // "time": 1586340086.457,
2339
+ // "type": 'sell',
2340
+ // "ordertype": 'market',
2341
+ // "price": '0.99860000',
2342
+ // "cost": '22.16892001',
2343
+ // "fee": '0.04433784',
2344
+ // "vol": '22.20000000',
2345
+ // "margin": '0.00000000',
2346
+ // "misc": ''
2347
+ // }
2348
+ // }
2349
+ // }
2350
+ //
2351
+ const rawTrades = this.safeValue(response, 'result');
2352
+ const ids = Object.keys(rawTrades);
2353
+ for (let i = 0; i < ids.length; i++) {
2354
+ rawTrades[ids[i]]['id'] = ids[i];
2355
+ }
2356
+ const trades = this.parseTrades(rawTrades, undefined, since, limit);
2357
+ const tradesFilteredBySymbol = this.filterBySymbol(trades, symbol);
2358
+ result = this.arrayConcat(result, tradesFilteredBySymbol);
2359
+ }
2360
+ return result;
2361
+ }
2362
+ /**
2363
+ * @method
2364
+ * @name kraken#fetchOrdersByIds
2365
+ * @description fetch orders by the list of order id
2366
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
2367
+ * @param {string[]} [ids] list of order id
2368
+ * @param {string} [symbol] unified ccxt market symbol
2369
+ * @param {object} [params] extra parameters specific to the kraken api endpoint
2370
+ * @returns {object[]} a list of [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2371
+ */
2372
+ async fetchOrdersByIds(ids, symbol = undefined, params = {}) {
2373
+ await this.loadMarkets();
2374
+ const response = await this.privatePostQueryOrders(this.extend({
2375
+ 'trades': true,
2376
+ 'txid': ids.join(','), // comma delimited list of transaction ids to query info about (20 maximum)
2377
+ }, params));
2378
+ const result = this.safeValue(response, 'result', {});
2379
+ const orders = [];
2380
+ const orderIds = Object.keys(result);
2381
+ for (let i = 0; i < orderIds.length; i++) {
2382
+ const id = orderIds[i];
2383
+ const item = result[id];
2384
+ const order = this.parseOrder(this.extend({ 'id': id }, item));
2385
+ orders.push(order);
2386
+ }
2387
+ return orders;
2388
+ }
2389
+ /**
2390
+ * @method
2391
+ * @name kraken#fetchMyTrades
2392
+ * @description fetch all trades made by the user
2393
+ * @see https://docs.kraken.com/api/docs/rest-api/get-trade-history
2394
+ * @param {string} symbol unified market symbol
2395
+ * @param {int} [since] the earliest time in ms to fetch trades for
2396
+ * @param {int} [limit] the maximum number of trades structures to retrieve
2397
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2398
+ * @param {int} [params.until] timestamp in ms of the latest trade entry
2399
+ * @param {int} [params.end] timestamp in seconds of the latest trade entry
2400
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2401
+ */
2402
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2403
+ await this.loadMarkets();
2404
+ const request = {
2405
+ // 'type': 'all', // any position, closed position, closing position, no position
2406
+ // 'trades': false, // whether or not to include trades related to position in output
2407
+ // 'start': 1234567890, // starting unix timestamp or trade tx id of results (exclusive)
2408
+ // 'end': 1234567890, // ending unix timestamp or trade tx id of results (inclusive)
2409
+ // 'ofs' = result offset
2410
+ };
2411
+ if (since !== undefined) {
2412
+ request['start'] = this.parseToInt(since / 1000);
2413
+ }
2414
+ const until = this.safeStringN(params, ['until', 'till']);
2415
+ if (until !== undefined) {
2416
+ params = this.omit(params, ['until', 'till']);
2417
+ const untilDivided = Precise.stringDiv(until, '1000');
2418
+ request['end'] = this.parseToInt(Precise.stringAdd(untilDivided, '1'));
2419
+ }
2420
+ const response = await this.privatePostTradesHistory(this.extend(request, params));
2421
+ //
2422
+ // {
2423
+ // "error": [],
2424
+ // "result": {
2425
+ // "trades": {
2426
+ // "GJ3NYQ-XJRTF-THZABF": {
2427
+ // "ordertxid": "TKH2SE-ZIF5E-CFI7LT",
2428
+ // "postxid": "OEN3VX-M7IF5-JNBJAM",
2429
+ // "pair": "XICNXETH",
2430
+ // "time": 1527213229.4491,
2431
+ // "type": "sell",
2432
+ // "ordertype": "limit",
2433
+ // "price": "0.001612",
2434
+ // "cost": "0.025792",
2435
+ // "fee": "0.000026",
2436
+ // "vol": "16.00000000",
2437
+ // "margin": "0.000000",
2438
+ // "leverage": "5",
2439
+ // "misc": ""
2440
+ // "trade_id": 68230622,
2441
+ // "maker": false
2442
+ // },
2443
+ // ...
2444
+ // },
2445
+ // "count": 9760,
2446
+ // },
2447
+ // }
2448
+ //
2449
+ const trades = response['result']['trades'];
2450
+ const ids = Object.keys(trades);
2451
+ for (let i = 0; i < ids.length; i++) {
2452
+ trades[ids[i]]['id'] = ids[i];
2453
+ }
2454
+ let market = undefined;
2455
+ if (symbol !== undefined) {
2456
+ market = this.market(symbol);
2457
+ }
2458
+ return this.parseTrades(trades, market, since, limit);
2459
+ }
2460
+ /**
2461
+ * @method
2462
+ * @name kraken#cancelOrder
2463
+ * @description cancels an open order
2464
+ * @see https://docs.kraken.com/api/docs/rest-api/cancel-order
2465
+ * @param {string} id order id
2466
+ * @param {string} [symbol] unified symbol of the market the order was made in
2467
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2468
+ * @param {string} [params.clientOrderId] the orders client order id
2469
+ * @param {int} [params.userref] the orders user reference id
2470
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2471
+ */
2472
+ async cancelOrder(id, symbol = undefined, params = {}) {
2473
+ await this.loadMarkets();
2474
+ let response = undefined;
2475
+ const requestId = this.safeValue(params, 'userref', id); // string or integer
2476
+ params = this.omit(params, 'userref');
2477
+ let request = {
2478
+ 'txid': requestId, // order id or userref
2479
+ };
2480
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'cl_ord_id');
2481
+ if (clientOrderId !== undefined) {
2482
+ request['cl_ord_id'] = clientOrderId;
2483
+ params = this.omit(params, ['clientOrderId', 'cl_ord_id']);
2484
+ request = this.omit(request, 'txid');
2485
+ }
2486
+ try {
2487
+ response = await this.privatePostCancelOrder(this.extend(request, params));
2488
+ //
2489
+ // {
2490
+ // error: [],
2491
+ // result: {
2492
+ // count: '1'
2493
+ // }
2494
+ // }
2495
+ //
2496
+ }
2497
+ catch (e) {
2498
+ if (this.last_http_response) {
2499
+ if (this.last_http_response.indexOf('EOrder:Unknown order') >= 0) {
2500
+ throw new OrderNotFound(this.id + ' cancelOrder() error ' + this.last_http_response);
2501
+ }
2502
+ }
2503
+ throw e;
2504
+ }
2505
+ return this.safeOrder({
2506
+ 'info': response,
2507
+ });
2508
+ }
2509
+ /**
2510
+ * @method
2511
+ * @name kraken#cancelOrders
2512
+ * @description cancel multiple orders
2513
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/cancelOrderBatch
2514
+ * @param {string[]} ids open orders transaction ID (txid) or user reference (userref)
2515
+ * @param {string} symbol unified market symbol
2516
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2517
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2518
+ */
2519
+ async cancelOrders(ids, symbol = undefined, params = {}) {
2520
+ const request = {
2521
+ 'orders': ids,
2522
+ };
2523
+ const response = await this.privatePostCancelOrderBatch(this.extend(request, params));
2524
+ //
2525
+ // {
2526
+ // "error": [],
2527
+ // "result": {
2528
+ // "count": 2
2529
+ // }
2530
+ // }
2531
+ //
2532
+ return [
2533
+ this.safeOrder({
2534
+ 'info': response,
2535
+ }),
2536
+ ];
2537
+ }
2538
+ /**
2539
+ * @method
2540
+ * @name kraken#cancelAllOrders
2541
+ * @description cancel all open orders
2542
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/cancelAllOrders
2543
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2544
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2545
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2546
+ */
2547
+ async cancelAllOrders(symbol = undefined, params = {}) {
2548
+ await this.loadMarkets();
2549
+ const response = await this.privatePostCancelAll(params);
2550
+ //
2551
+ // {
2552
+ // error: [],
2553
+ // result: {
2554
+ // count: '1'
2555
+ // }
2556
+ // }
2557
+ //
2558
+ return [
2559
+ this.safeOrder({
2560
+ 'info': response,
2561
+ }),
2562
+ ];
2563
+ }
2564
+ /**
2565
+ * @method
2566
+ * @name kraken#cancelAllOrdersAfter
2567
+ * @description dead man's switch, cancel all orders after the given timeout
2568
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/cancelAllOrdersAfter
2569
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
2570
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2571
+ * @returns {object} the api result
2572
+ */
2573
+ async cancelAllOrdersAfter(timeout, params = {}) {
2574
+ if (timeout > 86400000) {
2575
+ throw new BadRequest(this.id + ' cancelAllOrdersAfter timeout should be less than 86400000 milliseconds');
2576
+ }
2577
+ await this.loadMarkets();
2578
+ const request = {
2579
+ 'timeout': (timeout > 0) ? (this.parseToInt(timeout / 1000)) : 0,
2580
+ };
2581
+ const response = await this.privatePostCancelAllOrdersAfter(this.extend(request, params));
2582
+ //
2583
+ // {
2584
+ // "error": [ ],
2585
+ // "result": {
2586
+ // "currentTime": "2023-03-24T17:41:56Z",
2587
+ // "triggerTime": "2023-03-24T17:42:56Z"
2588
+ // }
2589
+ // }
2590
+ //
2591
+ return response;
2592
+ }
2593
+ /**
2594
+ * @method
2595
+ * @name kraken#fetchOpenOrders
2596
+ * @description fetch all unfilled currently open orders
2597
+ * @see https://docs.kraken.com/api/docs/rest-api/get-open-orders
2598
+ * @param {string} [symbol] unified market symbol
2599
+ * @param {int} [since] the earliest time in ms to fetch open orders for
2600
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
2601
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2602
+ * @param {string} [params.clientOrderId] the orders client order id
2603
+ * @param {int} [params.userref] the orders user reference id
2604
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2605
+ */
2606
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2607
+ await this.loadMarkets();
2608
+ const request = {};
2609
+ if (since !== undefined) {
2610
+ request['start'] = this.parseToInt(since / 1000);
2611
+ }
2612
+ const userref = this.safeInteger(params, 'userref');
2613
+ if (userref !== undefined) {
2614
+ request['userref'] = userref;
2615
+ params = this.omit(params, 'userref');
2616
+ }
2617
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2618
+ if (clientOrderId !== undefined) {
2619
+ request['cl_ord_id'] = clientOrderId;
2620
+ params = this.omit(params, 'clientOrderId');
2621
+ }
2622
+ const response = await this.privatePostOpenOrders(this.extend(request, params));
2623
+ //
2624
+ // {
2625
+ // "error": [],
2626
+ // "result": {
2627
+ // "open": {
2628
+ // "O45M52-BFD5S-YXKQOU": {
2629
+ // "refid": null,
2630
+ // "userref": null,
2631
+ // "cl_ord_id": "1234",
2632
+ // "status": "open",
2633
+ // "opentm": 1733815269.370054,
2634
+ // "starttm": 0,
2635
+ // "expiretm": 0,
2636
+ // "descr": {
2637
+ // "pair": "XBTUSD",
2638
+ // "type": "buy",
2639
+ // "ordertype": "limit",
2640
+ // "price": "70000.0",
2641
+ // "price2": "0",
2642
+ // "leverage": "none",
2643
+ // "order": "buy 0.00010000 XBTUSD @ limit 70000.0",
2644
+ // "close": ""
2645
+ // },
2646
+ // "vol": "0.00010000",
2647
+ // "vol_exec": "0.00000000",
2648
+ // "cost": "0.00000",
2649
+ // "fee": "0.00000",
2650
+ // "price": "0.00000",
2651
+ // "stopprice": "0.00000",
2652
+ // "limitprice": "0.00000",
2653
+ // "misc": "",
2654
+ // "oflags": "fciq"
2655
+ // }
2656
+ // }
2657
+ // }
2658
+ // }
2659
+ //
2660
+ let market = undefined;
2661
+ if (symbol !== undefined) {
2662
+ market = this.market(symbol);
2663
+ }
2664
+ const result = this.safeDict(response, 'result', {});
2665
+ const open = this.safeDict(result, 'open', {});
2666
+ const orders = [];
2667
+ const orderIds = Object.keys(open);
2668
+ for (let i = 0; i < orderIds.length; i++) {
2669
+ const id = orderIds[i];
2670
+ const item = open[id];
2671
+ orders.push(this.extend({ 'id': id }, item));
2672
+ }
2673
+ return this.parseOrders(orders, market, since, limit);
2674
+ }
2675
+ /**
2676
+ * @method
2677
+ * @name kraken#fetchClosedOrders
2678
+ * @description fetches information on multiple closed orders made by the user
2679
+ * @see https://docs.kraken.com/api/docs/rest-api/get-closed-orders
2680
+ * @param {string} [symbol] unified market symbol of the market orders were made in
2681
+ * @param {int} [since] the earliest time in ms to fetch orders for
2682
+ * @param {int} [limit] the maximum number of order structures to retrieve
2683
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2684
+ * @param {int} [params.until] timestamp in ms of the latest entry
2685
+ * @param {string} [params.clientOrderId] the orders client order id
2686
+ * @param {int} [params.userref] the orders user reference id
2687
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2688
+ */
2689
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2690
+ await this.loadMarkets();
2691
+ let request = {};
2692
+ if (since !== undefined) {
2693
+ request['start'] = this.parseToInt(since / 1000);
2694
+ }
2695
+ const userref = this.safeInteger(params, 'userref');
2696
+ if (userref !== undefined) {
2697
+ request['userref'] = userref;
2698
+ params = this.omit(params, 'userref');
2699
+ }
2700
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2701
+ if (clientOrderId !== undefined) {
2702
+ request['cl_ord_id'] = clientOrderId;
2703
+ params = this.omit(params, 'clientOrderId');
2704
+ }
2705
+ [request, params] = this.handleUntilOption('end', request, params);
2706
+ const response = await this.privatePostClosedOrders(this.extend(request, params));
2707
+ //
2708
+ // {
2709
+ // "error":[],
2710
+ // "result":{
2711
+ // "closed":{
2712
+ // "OETZYO-UL524-QJMXCT":{
2713
+ // "refid":null,
2714
+ // "userref":null,
2715
+ // "status":"canceled",
2716
+ // "reason":"User requested",
2717
+ // "opentm":1601489313.3898,
2718
+ // "closetm":1601489346.5507,
2719
+ // "starttm":0,
2720
+ // "expiretm":0,
2721
+ // "descr":{
2722
+ // "pair":"ETHUSDT",
2723
+ // "type":"buy",
2724
+ // "ordertype":"limit",
2725
+ // "price":"330.00",
2726
+ // "price2":"0",
2727
+ // "leverage":"none",
2728
+ // "order":"buy 0.02100000 ETHUSDT @ limit 330.00",
2729
+ // "close":""
2730
+ // },
2731
+ // "vol":"0.02100000",
2732
+ // "vol_exec":"0.00000000",
2733
+ // "cost":"0.00000",
2734
+ // "fee":"0.00000",
2735
+ // "price":"0.00000",
2736
+ // "stopprice":"0.00000",
2737
+ // "limitprice":"0.00000",
2738
+ // "misc":"",
2739
+ // "oflags":"fciq"
2740
+ // },
2741
+ // },
2742
+ // "count":16
2743
+ // }
2744
+ // }
2745
+ //
2746
+ let market = undefined;
2747
+ if (symbol !== undefined) {
2748
+ market = this.market(symbol);
2749
+ }
2750
+ const result = this.safeDict(response, 'result', {});
2751
+ const closed = this.safeDict(result, 'closed', {});
2752
+ const orders = [];
2753
+ const orderIds = Object.keys(closed);
2754
+ for (let i = 0; i < orderIds.length; i++) {
2755
+ const id = orderIds[i];
2756
+ const item = closed[id];
2757
+ orders.push(this.extend({ 'id': id }, item));
2758
+ }
2759
+ return this.parseOrders(orders, market, since, limit);
2760
+ }
2761
+ parseTransactionStatus(status) {
2762
+ // IFEX transaction states
2763
+ const statuses = {
2764
+ 'Initial': 'pending',
2765
+ 'Pending': 'pending',
2766
+ 'Success': 'ok',
2767
+ 'Settled': 'pending',
2768
+ 'Failure': 'failed',
2769
+ 'Partial': 'ok',
2770
+ };
2771
+ return this.safeString(statuses, status, status);
2772
+ }
2773
+ parseNetwork(network) {
2774
+ const withdrawMethods = this.safeValue(this.options, 'withdrawMethods', {});
2775
+ return this.safeString(withdrawMethods, network, network);
2776
+ }
2777
+ parseTransaction(transaction, currency = undefined) {
2778
+ //
2779
+ // fetchDeposits
2780
+ //
2781
+ // {
2782
+ // "method": "Ether (Hex)",
2783
+ // "aclass": "currency",
2784
+ // "asset": "XETH",
2785
+ // "refid": "Q2CANKL-LBFVEE-U4Y2WQ",
2786
+ // "txid": "0x57fd704dab1a73c20e24c8696099b695d596924b401b261513cfdab23…",
2787
+ // "info": "0x615f9ba7a9575b0ab4d571b2b36b1b324bd83290",
2788
+ // "amount": "7.9999257900",
2789
+ // "fee": "0.0000000000",
2790
+ // "time": 1529223212,
2791
+ // "status": "Success"
2792
+ // }
2793
+ //
2794
+ // there can be an additional 'status-prop' field present
2795
+ // deposit pending review by exchange => 'on-hold'
2796
+ // the deposit is initiated by the exchange => 'return'
2797
+ //
2798
+ // {
2799
+ // "type": 'deposit',
2800
+ // "method": 'Fidor Bank AG (Wire Transfer)',
2801
+ // "aclass": 'currency',
2802
+ // "asset": 'ZEUR',
2803
+ // "refid": 'xxx-xxx-xxx',
2804
+ // "txid": '12341234',
2805
+ // "info": 'BANKCODEXXX',
2806
+ // "amount": '38769.08',
2807
+ // "fee": '0.0000',
2808
+ // "time": 1644306552,
2809
+ // "status": 'Success',
2810
+ // status-prop: 'on-hold'
2811
+ // }
2812
+ //
2813
+ //
2814
+ // fetchWithdrawals
2815
+ //
2816
+ // {
2817
+ // "method": "Ether",
2818
+ // "aclass": "currency",
2819
+ // "asset": "XETH",
2820
+ // "refid": "A2BF34S-O7LBNQ-UE4Y4O",
2821
+ // "txid": "0x288b83c6b0904d8400ef44e1c9e2187b5c8f7ea3d838222d53f701a15b5c274d",
2822
+ // "info": "0x7cb275a5e07ba943fee972e165d80daa67cb2dd0",
2823
+ // "amount": "9.9950000000",
2824
+ // "fee": "0.0050000000",
2825
+ // "time": 1530481750,
2826
+ // "status": "Success"
2827
+ // "key":"Huobi wallet",
2828
+ // "network":"Tron"
2829
+ // status-prop: 'on-hold' // this field might not be present in some cases
2830
+ // }
2831
+ //
2832
+ // withdraw
2833
+ //
2834
+ // {
2835
+ // "refid": "AGBSO6T-UFMTTQ-I7KGS6"
2836
+ // }
2837
+ //
2838
+ const id = this.safeString(transaction, 'refid');
2839
+ const txid = this.safeString(transaction, 'txid');
2840
+ const timestamp = this.safeTimestamp(transaction, 'time');
2841
+ const currencyId = this.safeString(transaction, 'asset');
2842
+ const code = this.safeCurrencyCode(currencyId, currency);
2843
+ const address = this.safeString(transaction, 'info');
2844
+ const amount = this.safeNumber(transaction, 'amount');
2845
+ let status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
2846
+ const statusProp = this.safeString(transaction, 'status-prop');
2847
+ const isOnHoldDeposit = statusProp === 'on-hold';
2848
+ const isCancellationRequest = statusProp === 'cancel-pending';
2849
+ const isOnHoldWithdrawal = statusProp === 'onhold';
2850
+ if (isOnHoldDeposit || isCancellationRequest || isOnHoldWithdrawal) {
2851
+ status = 'pending';
2852
+ }
2853
+ const type = this.safeString(transaction, 'type'); // injected from the outside
2854
+ let feeCost = this.safeNumber(transaction, 'fee');
2855
+ if (feeCost === undefined) {
2856
+ if (type === 'deposit') {
2857
+ feeCost = 0;
2858
+ }
2859
+ }
2860
+ return {
2861
+ 'info': transaction,
2862
+ 'id': id,
2863
+ 'currency': code,
2864
+ 'amount': amount,
2865
+ 'network': this.parseNetwork(this.safeString(transaction, 'network')),
2866
+ 'address': address,
2867
+ 'addressTo': undefined,
2868
+ 'addressFrom': undefined,
2869
+ 'tag': undefined,
2870
+ 'tagTo': undefined,
2871
+ 'tagFrom': undefined,
2872
+ 'status': status,
2873
+ 'type': type,
2874
+ 'updated': undefined,
2875
+ 'txid': txid,
2876
+ 'timestamp': timestamp,
2877
+ 'datetime': this.iso8601(timestamp),
2878
+ 'comment': undefined,
2879
+ 'internal': undefined,
2880
+ 'fee': {
2881
+ 'currency': code,
2882
+ 'cost': feeCost,
2883
+ },
2884
+ };
2885
+ }
2886
+ parseTransactionsByType(type, transactions, code = undefined, since = undefined, limit = undefined) {
2887
+ const result = [];
2888
+ for (let i = 0; i < transactions.length; i++) {
2889
+ const transaction = this.parseTransaction(this.extend({
2890
+ 'type': type,
2891
+ }, transactions[i]));
2892
+ result.push(transaction);
2893
+ }
2894
+ return this.filterByCurrencySinceLimit(result, code, since, limit);
2895
+ }
2896
+ /**
2897
+ * @method
2898
+ * @name kraken#fetchDeposits
2899
+ * @description fetch all deposits made to an account
2900
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentDeposits
2901
+ * @param {string} code unified currency code
2902
+ * @param {int} [since] the earliest time in ms to fetch deposits for
2903
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
2904
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2905
+ * @param {int} [params.until] timestamp in ms of the latest transaction entry
2906
+ * @param {int} [params.end] timestamp in seconds of the latest transaction entry
2907
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2908
+ */
2909
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
2910
+ // https://www.kraken.com/en-us/help/api#deposit-status
2911
+ await this.loadMarkets();
2912
+ const request = {};
2913
+ if (code !== undefined) {
2914
+ const currency = this.currency(code);
2915
+ request['asset'] = currency['id'];
2916
+ }
2917
+ if (since !== undefined) {
2918
+ const sinceString = this.numberToString(since);
2919
+ request['start'] = Precise.stringDiv(sinceString, '1000');
2920
+ }
2921
+ const until = this.safeStringN(params, ['until', 'till']);
2922
+ if (until !== undefined) {
2923
+ params = this.omit(params, ['until', 'till']);
2924
+ const untilDivided = Precise.stringDiv(until, '1000');
2925
+ request['end'] = Precise.stringAdd(untilDivided, '1');
2926
+ }
2927
+ const response = await this.privatePostDepositStatus(this.extend(request, params));
2928
+ //
2929
+ // { error: [],
2930
+ // "result": [ { "method": "Ether (Hex)",
2931
+ // "aclass": "currency",
2932
+ // "asset": "XETH",
2933
+ // "refid": "Q2CANKL-LBFVEE-U4Y2WQ",
2934
+ // "txid": "0x57fd704dab1a73c20e24c8696099b695d596924b401b261513cfdab23…",
2935
+ // "info": "0x615f9ba7a9575b0ab4d571b2b36b1b324bd83290",
2936
+ // "amount": "7.9999257900",
2937
+ // "fee": "0.0000000000",
2938
+ // "time": 1529223212,
2939
+ // "status": "Success" } ] }
2940
+ //
2941
+ return this.parseTransactionsByType('deposit', response['result'], code, since, limit);
2942
+ }
2943
+ /**
2944
+ * @method
2945
+ * @name kraken#fetchTime
2946
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
2947
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getServerTime
2948
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2949
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
2950
+ */
2951
+ async fetchTime(params = {}) {
2952
+ // https://www.kraken.com/en-us/features/api#get-server-time
2953
+ const response = await this.publicGetTime(params);
2954
+ //
2955
+ // {
2956
+ // "error": [],
2957
+ // "result": {
2958
+ // "unixtime": 1591502873,
2959
+ // "rfc1123": "Sun, 7 Jun 20 04:07:53 +0000"
2960
+ // }
2961
+ // }
2962
+ //
2963
+ const result = this.safeValue(response, 'result', {});
2964
+ return this.safeTimestamp(result, 'unixtime');
2965
+ }
2966
+ /**
2967
+ * @method
2968
+ * @name kraken#fetchWithdrawals
2969
+ * @description fetch all withdrawals made from an account
2970
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentWithdrawals
2971
+ * @param {string} code unified currency code
2972
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
2973
+ * @param {int} [limit] the maximum number of withdrawals structures to retrieve
2974
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2975
+ * @param {int} [params.until] timestamp in ms of the latest transaction entry
2976
+ * @param {int} [params.end] timestamp in seconds of the latest transaction entry
2977
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times
2978
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2979
+ */
2980
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2981
+ await this.loadMarkets();
2982
+ let paginate = false;
2983
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
2984
+ if (paginate) {
2985
+ params['cursor'] = true;
2986
+ return await this.fetchPaginatedCallCursor('fetchWithdrawals', code, since, limit, params, 'next_cursor', 'cursor');
2987
+ }
2988
+ const request = {};
2989
+ if (code !== undefined) {
2990
+ const currency = this.currency(code);
2991
+ request['asset'] = currency['id'];
2992
+ }
2993
+ if (since !== undefined) {
2994
+ const sinceString = this.numberToString(since);
2995
+ request['start'] = Precise.stringDiv(sinceString, '1000');
2996
+ }
2997
+ const until = this.safeStringN(params, ['until', 'till']);
2998
+ if (until !== undefined) {
2999
+ params = this.omit(params, ['until', 'till']);
3000
+ const untilDivided = Precise.stringDiv(until, '1000');
3001
+ request['end'] = Precise.stringAdd(untilDivided, '1');
3002
+ }
3003
+ const response = await this.privatePostWithdrawStatus(this.extend(request, params));
3004
+ //
3005
+ // with no pagination
3006
+ // { error: [],
3007
+ // "result": [ { "method": "Ether",
3008
+ // "aclass": "currency",
3009
+ // "asset": "XETH",
3010
+ // "refid": "A2BF34S-O7LBNQ-UE4Y4O",
3011
+ // "txid": "0x298c83c7b0904d8400ef43e1c9e2287b518f7ea3d838822d53f704a1565c274d",
3012
+ // "info": "0x7cb275a5e07ba943fee972e165d80daa67cb2dd0",
3013
+ // "amount": "9.9950000000",
3014
+ // "fee": "0.0050000000",
3015
+ // "time": 1530481750,
3016
+ // "status": "Success" } ] }
3017
+ // with pagination
3018
+ // {
3019
+ // "error":[],
3020
+ // "result":{
3021
+ // "withdrawals":[
3022
+ // {
3023
+ // "method":"Tether USD (TRC20)",
3024
+ // "aclass":"currency",
3025
+ // "asset":"USDT",
3026
+ // "refid":"BSNFZU2-MEFN4G-J3NEZV",
3027
+ // "txid":"1c7a642fb7387bbc2c6a2c509fd1ae146937f4cf793b4079a4f0715e3a02615a",
3028
+ // "info":"TQmdxSuC16EhFg8FZWtYgrfFRosoRF7bCp",
3029
+ // "amount":"1996.50000000",
3030
+ // "fee":"2.50000000",
3031
+ // "time":1669126657,
3032
+ // "status":"Success",
3033
+ // "key":"poloniex",
3034
+ // "network":"Tron"
3035
+ // },
3036
+ // ...
3037
+ // ],
3038
+ // "next_cursor":"HgAAAAAAAABGVFRSd3k1LVF4Y0JQY05Gd0xRY0NxenFndHpybkwBAQH2AwEBAAAAAQAAAAAAAAABAAAAAAAZAAAAAAAAAA=="
3039
+ // }
3040
+ // }
3041
+ //
3042
+ let rawWithdrawals = undefined;
3043
+ const result = this.safeValue(response, 'result');
3044
+ if (!Array.isArray(result)) {
3045
+ rawWithdrawals = this.addPaginationCursorToResult(result);
3046
+ }
3047
+ else {
3048
+ rawWithdrawals = result;
3049
+ }
3050
+ return this.parseTransactionsByType('withdrawal', rawWithdrawals, code, since, limit);
3051
+ }
3052
+ addPaginationCursorToResult(result) {
3053
+ const cursor = this.safeString(result, 'next_cursor');
3054
+ const data = this.safeValue(result, 'withdrawals');
3055
+ const dataLength = data.length;
3056
+ if (cursor !== undefined && dataLength > 0) {
3057
+ const last = data[dataLength - 1];
3058
+ last['next_cursor'] = cursor;
3059
+ data[dataLength - 1] = last;
3060
+ }
3061
+ return data;
3062
+ }
3063
+ /**
3064
+ * @method
3065
+ * @name kraken#createDepositAddress
3066
+ * @description create a currency deposit address
3067
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
3068
+ * @param {string} code unified currency code of the currency for the deposit address
3069
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3070
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3071
+ */
3072
+ async createDepositAddress(code, params = {}) {
3073
+ const request = {
3074
+ 'new': 'true',
3075
+ };
3076
+ return await this.fetchDepositAddress(code, this.extend(request, params));
3077
+ }
3078
+ /**
3079
+ * @method
3080
+ * @name kraken#fetchDepositMethods
3081
+ * @description fetch deposit methods for a currency associated with this account
3082
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositMethods
3083
+ * @param {string} code unified currency code
3084
+ * @param {object} [params] extra parameters specific to the kraken api endpoint
3085
+ * @returns {object} of deposit methods
3086
+ */
3087
+ async fetchDepositMethods(code, params = {}) {
3088
+ await this.loadMarkets();
3089
+ const currency = this.currency(code);
3090
+ const request = {
3091
+ 'asset': currency['id'],
3092
+ };
3093
+ const response = await this.privatePostDepositMethods(this.extend(request, params));
3094
+ //
3095
+ // {
3096
+ // "error":[],
3097
+ // "result":[
3098
+ // {"method":"Ether (Hex)","limit":false,"gen-address":true}
3099
+ // ]
3100
+ // }
3101
+ //
3102
+ // {
3103
+ // "error":[],
3104
+ // "result":[
3105
+ // {"method":"Tether USD (ERC20)","limit":false,"address-setup-fee":"0.00000000","gen-address":true},
3106
+ // {"method":"Tether USD (TRC20)","limit":false,"address-setup-fee":"0.00000000","gen-address":true}
3107
+ // ]
3108
+ // }
3109
+ //
3110
+ // {
3111
+ // "error":[],
3112
+ // "result":[
3113
+ // {"method":"Bitcoin","limit":false,"fee":"0.0000000000","gen-address":true}
3114
+ // ]
3115
+ // }
3116
+ //
3117
+ return this.safeValue(response, 'result');
3118
+ }
3119
+ /**
3120
+ * @method
3121
+ * @name kraken#fetchDepositAddress
3122
+ * @description fetch the deposit address for a currency associated with this account
3123
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
3124
+ * @param {string} code unified currency code
3125
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3126
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3127
+ */
3128
+ async fetchDepositAddress(code, params = {}) {
3129
+ await this.loadMarkets();
3130
+ const currency = this.currency(code);
3131
+ let network = this.safeStringUpper(params, 'network');
3132
+ const networks = this.safeValue(this.options, 'networks', {});
3133
+ network = this.safeString(networks, network, network); // support ETH > ERC20 aliases
3134
+ params = this.omit(params, 'network');
3135
+ if ((code === 'USDT') && (network === 'TRC20')) {
3136
+ code = code + '-' + network;
3137
+ }
3138
+ const defaultDepositMethods = this.safeValue(this.options, 'depositMethods', {});
3139
+ const defaultDepositMethod = this.safeString(defaultDepositMethods, code);
3140
+ let depositMethod = this.safeString(params, 'method', defaultDepositMethod);
3141
+ // if the user has specified an exchange-specific method in params
3142
+ // we pass it as is, otherwise we take the 'network' unified param
3143
+ if (depositMethod === undefined) {
3144
+ const depositMethods = await this.fetchDepositMethods(code);
3145
+ if (network !== undefined) {
3146
+ // find best matching deposit method, or fallback to the first one
3147
+ for (let i = 0; i < depositMethods.length; i++) {
3148
+ const entry = this.safeString(depositMethods[i], 'method');
3149
+ if (entry.indexOf(network) >= 0) {
3150
+ depositMethod = entry;
3151
+ break;
3152
+ }
3153
+ }
3154
+ }
3155
+ // if depositMethod was not specified, fallback to the first available deposit method
3156
+ if (depositMethod === undefined) {
3157
+ const firstDepositMethod = this.safeValue(depositMethods, 0, {});
3158
+ depositMethod = this.safeString(firstDepositMethod, 'method');
3159
+ }
3160
+ }
3161
+ const request = {
3162
+ 'asset': currency['id'],
3163
+ 'method': depositMethod,
3164
+ };
3165
+ const response = await this.privatePostDepositAddresses(this.extend(request, params));
3166
+ //
3167
+ // {
3168
+ // "error":[],
3169
+ // "result":[
3170
+ // {"address":"0x77b5051f97efa9cc52c9ad5b023a53fc15c200d3","expiretm":"0"}
3171
+ // ]
3172
+ // }
3173
+ //
3174
+ const result = this.safeValue(response, 'result', []);
3175
+ const firstResult = this.safeValue(result, 0, {});
3176
+ if (firstResult === undefined) {
3177
+ throw new InvalidAddress(this.id + ' privatePostDepositAddresses() returned no addresses for ' + code);
3178
+ }
3179
+ return this.parseDepositAddress(firstResult, currency);
3180
+ }
3181
+ parseDepositAddress(depositAddress, currency = undefined) {
3182
+ //
3183
+ // {
3184
+ // "address":"0x77b5051f97efa9cc52c9ad5b023a53fc15c200d3",
3185
+ // "expiretm":"0"
3186
+ // }
3187
+ //
3188
+ const address = this.safeString(depositAddress, 'address');
3189
+ const tag = this.safeString(depositAddress, 'tag');
3190
+ currency = this.safeCurrency(undefined, currency);
3191
+ const code = currency['code'];
3192
+ this.checkAddress(address);
3193
+ return {
3194
+ 'info': depositAddress,
3195
+ 'currency': code,
3196
+ 'network': undefined,
3197
+ 'address': address,
3198
+ 'tag': tag,
3199
+ };
3200
+ }
3201
+ /**
3202
+ * @method
3203
+ * @name kraken#withdraw
3204
+ * @description make a withdrawal
3205
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/withdrawFunds
3206
+ * @param {string} code unified currency code
3207
+ * @param {float} amount the amount to withdraw
3208
+ * @param {string} address the address to withdraw to
3209
+ * @param {string} tag
3210
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3211
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3212
+ */
3213
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
3214
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
3215
+ this.checkAddress(address);
3216
+ if ('key' in params) {
3217
+ await this.loadMarkets();
3218
+ const currency = this.currency(code);
3219
+ const request = {
3220
+ 'asset': currency['id'],
3221
+ 'amount': amount,
3222
+ 'address': address,
3223
+ };
3224
+ const response = await this.privatePostWithdraw(this.extend(request, params));
3225
+ //
3226
+ // {
3227
+ // "error": [],
3228
+ // "result": {
3229
+ // "refid": "AGBSO6T-UFMTTQ-I7KGS6"
3230
+ // }
3231
+ // }
3232
+ //
3233
+ const result = this.safeDict(response, 'result', {});
3234
+ return this.parseTransaction(result, currency);
3235
+ }
3236
+ throw new ExchangeError(this.id + " withdraw() requires a 'key' parameter (withdrawal key name, as set up on your account)");
3237
+ }
3238
+ /**
3239
+ * @method
3240
+ * @name kraken#fetchPositions
3241
+ * @description fetch all open positions
3242
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
3243
+ * @param {string[]} [symbols] not used by kraken fetchPositions ()
3244
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3245
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3246
+ */
3247
+ async fetchPositions(symbols = undefined, params = {}) {
3248
+ await this.loadMarkets();
3249
+ const request = {
3250
+ // 'txid': 'comma delimited list of transaction ids to restrict output to',
3251
+ 'docalcs': 'true',
3252
+ 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair
3253
+ };
3254
+ const response = await this.privatePostOpenPositions(this.extend(request, params));
3255
+ //
3256
+ // no consolidation
3257
+ //
3258
+ // {
3259
+ // "error": [],
3260
+ // "result": {
3261
+ // 'TGUFMY-FLESJ-VYIX3J': {
3262
+ // "ordertxid": "O3LRNU-ZKDG5-XNCDFR",
3263
+ // "posstatus": "open",
3264
+ // "pair": "ETHUSDT",
3265
+ // "time": 1611557231.4584,
3266
+ // "type": "buy",
3267
+ // "ordertype": "market",
3268
+ // "cost": "28.49800",
3269
+ // "fee": "0.07979",
3270
+ // "vol": "0.02000000",
3271
+ // "vol_closed": "0.00000000",
3272
+ // "margin": "14.24900",
3273
+ // "terms": "0.0200% per 4 hours",
3274
+ // "rollovertm": "1611571631",
3275
+ // "misc": "",
3276
+ // "oflags": ""
3277
+ // }
3278
+ // }
3279
+ // }
3280
+ //
3281
+ // consolidation by market
3282
+ //
3283
+ // {
3284
+ // "error": [],
3285
+ // "result": [
3286
+ // {
3287
+ // "pair": "ETHUSDT",
3288
+ // "positions": "1",
3289
+ // "type": "buy",
3290
+ // "leverage": "2.00000",
3291
+ // "cost": "28.49800",
3292
+ // "fee": "0.07979",
3293
+ // "vol": "0.02000000",
3294
+ // "vol_closed": "0.00000000",
3295
+ // "margin": "14.24900"
3296
+ // }
3297
+ // ]
3298
+ // }
3299
+ //
3300
+ symbols = this.marketSymbols(symbols);
3301
+ const result = this.safeList(response, 'result');
3302
+ const results = this.parsePositions(result, symbols);
3303
+ return this.filterByArrayPositions(results, 'symbol', symbols, false);
3304
+ }
3305
+ parsePosition(position, market = undefined) {
3306
+ //
3307
+ // {
3308
+ // "pair": "ETHUSDT",
3309
+ // "positions": "1",
3310
+ // "type": "buy",
3311
+ // "leverage": "2.00000",
3312
+ // "cost": "28.49800",
3313
+ // "fee": "0.07979",
3314
+ // "vol": "0.02000000",
3315
+ // "vol_closed": "0.00000000",
3316
+ // "margin": "14.24900"
3317
+ // }
3318
+ //
3319
+ const marketId = this.safeString(position, 'pair');
3320
+ const rawSide = this.safeString(position, 'type');
3321
+ const side = (rawSide === 'buy') ? 'long' : 'short';
3322
+ return this.safePosition({
3323
+ 'info': position,
3324
+ 'id': undefined,
3325
+ 'symbol': this.safeSymbol(marketId, market),
3326
+ 'notional': undefined,
3327
+ 'marginMode': undefined,
3328
+ 'liquidationPrice': undefined,
3329
+ 'entryPrice': undefined,
3330
+ 'unrealizedPnl': this.safeNumber(position, 'net'),
3331
+ 'realizedPnl': undefined,
3332
+ 'percentage': undefined,
3333
+ 'contracts': this.safeNumber(position, 'vol'),
3334
+ 'contractSize': undefined,
3335
+ 'markPrice': undefined,
3336
+ 'lastPrice': undefined,
3337
+ 'side': side,
3338
+ 'hedged': undefined,
3339
+ 'timestamp': undefined,
3340
+ 'datetime': undefined,
3341
+ 'lastUpdateTimestamp': undefined,
3342
+ 'maintenanceMargin': undefined,
3343
+ 'maintenanceMarginPercentage': undefined,
3344
+ 'collateral': undefined,
3345
+ 'initialMargin': this.safeNumber(position, 'margin'),
3346
+ 'initialMarginPercentage': undefined,
3347
+ 'leverage': this.safeNumber(position, 'leverage'),
3348
+ 'marginRatio': undefined,
3349
+ 'stopLossPrice': undefined,
3350
+ 'takeProfitPrice': undefined,
3351
+ });
3352
+ }
3353
+ parseAccountType(account) {
3354
+ const accountByType = {
3355
+ 'spot': 'Spot Wallet',
3356
+ 'swap': 'Futures Wallet',
3357
+ 'future': 'Futures Wallet',
3358
+ };
3359
+ return this.safeString(accountByType, account, account);
3360
+ }
3361
+ /**
3362
+ * @method
3363
+ * @name kraken#transferOut
3364
+ * @description transfer from spot wallet to futures wallet
3365
+ * @see https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
3366
+ * @param {str} code Unified currency code
3367
+ * @param {float} amount Size of the transfer
3368
+ * @param {dict} [params] Exchange specific parameters
3369
+ * @returns a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
3370
+ */
3371
+ async transferOut(code, amount, params = {}) {
3372
+ return await this.transfer(code, amount, 'spot', 'swap', params);
3373
+ }
3374
+ /**
3375
+ * @method
3376
+ * @name kraken#transfer
3377
+ * @see https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
3378
+ * @description transfers currencies between sub-accounts (only spot->swap direction is supported)
3379
+ * @param {string} code Unified currency code
3380
+ * @param {float} amount Size of the transfer
3381
+ * @param {string} fromAccount 'spot' or 'Spot Wallet'
3382
+ * @param {string} toAccount 'swap' or 'Futures Wallet'
3383
+ * @param {object} [params] Exchange specific parameters
3384
+ * @returns a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
3385
+ */
3386
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
3387
+ await this.loadMarkets();
3388
+ const currency = this.currency(code);
3389
+ fromAccount = this.parseAccountType(fromAccount);
3390
+ toAccount = this.parseAccountType(toAccount);
3391
+ const request = {
3392
+ 'amount': this.currencyToPrecision(code, amount),
3393
+ 'from': fromAccount,
3394
+ 'to': toAccount,
3395
+ 'asset': currency['id'],
3396
+ };
3397
+ if (fromAccount !== 'Spot Wallet') {
3398
+ throw new BadRequest(this.id + ' transfer cannot transfer from ' + fromAccount + ' to ' + toAccount + '. Use krakenfutures instead to transfer from the futures account.');
3399
+ }
3400
+ const response = await this.privatePostWalletTransfer(this.extend(request, params));
3401
+ //
3402
+ // {
3403
+ // "error":[
3404
+ // ],
3405
+ // "result":{
3406
+ // "refid":"BOIUSIF-M7DLMN-UXZ3P5"
3407
+ // }
3408
+ // }
3409
+ //
3410
+ const transfer = this.parseTransfer(response, currency);
3411
+ return this.extend(transfer, {
3412
+ 'amount': amount,
3413
+ 'fromAccount': fromAccount,
3414
+ 'toAccount': toAccount,
3415
+ });
3416
+ }
3417
+ parseTransfer(transfer, currency = undefined) {
3418
+ //
3419
+ // transfer
3420
+ //
3421
+ // {
3422
+ // "error":[
3423
+ // ],
3424
+ // "result":{
3425
+ // "refid":"BOIUSIF-M7DLMN-UXZ3P5"
3426
+ // }
3427
+ // }
3428
+ //
3429
+ const result = this.safeValue(transfer, 'result', {});
3430
+ const refid = this.safeString(result, 'refid');
3431
+ return {
3432
+ 'info': transfer,
3433
+ 'id': refid,
3434
+ 'timestamp': undefined,
3435
+ 'datetime': undefined,
3436
+ 'currency': this.safeString(currency, 'code'),
3437
+ 'amount': undefined,
3438
+ 'fromAccount': undefined,
3439
+ 'toAccount': undefined,
3440
+ 'status': 'sucess',
3441
+ };
3442
+ }
3443
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3444
+ let url = '/' + this.version + '/' + api + '/' + path;
3445
+ if (api === 'public') {
3446
+ if (Object.keys(params).length) {
3447
+ // urlencodeNested is used to address https://github.com/ccxt/ccxt/issues/12872
3448
+ url += '?' + this.urlencodeNested(params);
3449
+ }
3450
+ }
3451
+ else if (api === 'private') {
3452
+ const price = this.safeString(params, 'price');
3453
+ let isTriggerPercent = false;
3454
+ if (price !== undefined) {
3455
+ isTriggerPercent = (price.endsWith('%')) ? true : false;
3456
+ }
3457
+ const isCancelOrderBatch = (path === 'CancelOrderBatch');
3458
+ this.checkRequiredCredentials();
3459
+ const nonce = this.nonce().toString();
3460
+ // urlencodeNested is used to address https://github.com/ccxt/ccxt/issues/12872
3461
+ if (isCancelOrderBatch || isTriggerPercent) {
3462
+ body = this.json(this.extend({ 'nonce': nonce }, params));
3463
+ }
3464
+ else {
3465
+ body = this.urlencodeNested(this.extend({ 'nonce': nonce }, params));
3466
+ }
3467
+ const auth = this.encode(nonce + body);
3468
+ const hash = this.hash(auth, sha256, 'binary');
3469
+ const binary = this.encode(url);
3470
+ const binhash = this.binaryConcat(binary, hash);
3471
+ const secret = this.base64ToBinary(this.secret);
3472
+ const signature = this.hmac(binhash, secret, sha512, 'base64');
3473
+ headers = {
3474
+ 'API-Key': this.apiKey,
3475
+ 'API-Sign': signature,
3476
+ };
3477
+ if (isCancelOrderBatch || isTriggerPercent) {
3478
+ headers['Content-Type'] = 'application/json';
3479
+ }
3480
+ else {
3481
+ headers['Content-Type'] = 'application/x-www-form-urlencoded';
3482
+ }
3483
+ }
3484
+ else {
3485
+ url = '/' + path;
3486
+ }
3487
+ url = this.urls['api'][api] + url;
3488
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3489
+ }
3490
+ nonce() {
3491
+ return this.milliseconds() - this.options['timeDifference'];
3492
+ }
3493
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3494
+ if (code === 520) {
3495
+ throw new ExchangeNotAvailable(this.id + ' ' + code.toString() + ' ' + reason);
3496
+ }
3497
+ if (response === undefined) {
3498
+ return undefined;
3499
+ }
3500
+ if (body[0] === '{') {
3501
+ if (typeof response !== 'string') {
3502
+ if ('error' in response) {
3503
+ const numErrors = response['error'].length;
3504
+ if (numErrors) {
3505
+ const message = this.id + ' ' + body;
3506
+ for (let i = 0; i < response['error'].length; i++) {
3507
+ const error = response['error'][i];
3508
+ this.throwExactlyMatchedException(this.exceptions['exact'], error, message);
3509
+ this.throwBroadlyMatchedException(this.exceptions['broad'], error, message);
3510
+ }
3511
+ throw new ExchangeError(message);
3512
+ }
3513
+ }
3514
+ }
3515
+ }
3516
+ return undefined;
3517
+ }
3518
+ }