ccxt 4.2.11 → 4.2.12

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 (375) hide show
  1. package/README.md +5 -5
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +640 -261
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/_virtual/agent.js +7 -0
  6. package/dist/cjs/_virtual/parse-proxy-response.js +7 -0
  7. package/dist/cjs/_virtual/promisify.js +7 -0
  8. package/dist/cjs/ccxt.js +1 -1
  9. package/dist/cjs/js/ccxt.js +474 -0
  10. package/dist/cjs/js/src/abstract/ace.js +9 -0
  11. package/dist/cjs/js/src/abstract/alpaca.js +9 -0
  12. package/dist/cjs/js/src/abstract/ascendex.js +9 -0
  13. package/dist/cjs/js/src/abstract/bigone.js +9 -0
  14. package/dist/cjs/js/src/abstract/binance.js +9 -0
  15. package/dist/cjs/js/src/abstract/bingx.js +9 -0
  16. package/dist/cjs/js/src/abstract/bit2c.js +9 -0
  17. package/dist/cjs/js/src/abstract/bitbank.js +9 -0
  18. package/dist/cjs/js/src/abstract/bitbns.js +9 -0
  19. package/dist/cjs/js/src/abstract/bitfinex.js +9 -0
  20. package/dist/cjs/js/src/abstract/bitfinex2.js +9 -0
  21. package/dist/cjs/js/src/abstract/bitflyer.js +9 -0
  22. package/dist/cjs/js/src/abstract/bitforex.js +9 -0
  23. package/dist/cjs/js/src/abstract/bitget.js +9 -0
  24. package/dist/cjs/js/src/abstract/bithumb.js +9 -0
  25. package/dist/cjs/js/src/abstract/bitmart.js +9 -0
  26. package/dist/cjs/js/src/abstract/bitmex.js +9 -0
  27. package/dist/cjs/js/src/abstract/bitopro.js +9 -0
  28. package/dist/cjs/js/src/abstract/bitpanda.js +9 -0
  29. package/dist/cjs/js/src/abstract/bitrue.js +9 -0
  30. package/dist/cjs/js/src/abstract/bitso.js +9 -0
  31. package/dist/cjs/js/src/abstract/bitstamp.js +9 -0
  32. package/dist/cjs/js/src/abstract/bitteam.js +9 -0
  33. package/dist/cjs/js/src/abstract/bitvavo.js +9 -0
  34. package/dist/cjs/js/src/abstract/bl3p.js +9 -0
  35. package/dist/cjs/js/src/abstract/blockchaincom.js +9 -0
  36. package/dist/cjs/js/src/abstract/btcalpha.js +9 -0
  37. package/dist/cjs/js/src/abstract/btcbox.js +9 -0
  38. package/dist/cjs/js/src/abstract/btcmarkets.js +9 -0
  39. package/dist/cjs/js/src/abstract/btcturk.js +9 -0
  40. package/dist/cjs/js/src/abstract/bybit.js +9 -0
  41. package/dist/cjs/js/src/abstract/cex.js +9 -0
  42. package/dist/cjs/js/src/abstract/coinbase.js +9 -0
  43. package/dist/cjs/js/src/abstract/coinbasepro.js +9 -0
  44. package/dist/cjs/js/src/abstract/coincheck.js +9 -0
  45. package/dist/cjs/js/src/abstract/coinex.js +9 -0
  46. package/dist/cjs/js/src/abstract/coinlist.js +9 -0
  47. package/dist/cjs/js/src/abstract/coinmate.js +9 -0
  48. package/dist/cjs/js/src/abstract/coinone.js +9 -0
  49. package/dist/cjs/js/src/abstract/coinsph.js +9 -0
  50. package/dist/cjs/js/src/abstract/coinspot.js +9 -0
  51. package/dist/cjs/js/src/abstract/cryptocom.js +9 -0
  52. package/dist/cjs/js/src/abstract/currencycom.js +9 -0
  53. package/dist/cjs/js/src/abstract/delta.js +9 -0
  54. package/dist/cjs/js/src/abstract/deribit.js +9 -0
  55. package/dist/cjs/js/src/abstract/digifinex.js +9 -0
  56. package/dist/cjs/js/src/abstract/exmo.js +9 -0
  57. package/dist/cjs/js/src/abstract/gate.js +9 -0
  58. package/dist/cjs/js/src/abstract/gemini.js +9 -0
  59. package/dist/cjs/js/src/abstract/hitbtc.js +9 -0
  60. package/dist/cjs/js/src/abstract/hollaex.js +9 -0
  61. package/dist/cjs/js/src/abstract/htx.js +9 -0
  62. package/dist/cjs/js/src/abstract/huobijp.js +9 -0
  63. package/dist/cjs/js/src/abstract/idex.js +9 -0
  64. package/dist/cjs/js/src/abstract/independentreserve.js +9 -0
  65. package/dist/cjs/js/src/abstract/indodax.js +9 -0
  66. package/dist/cjs/js/src/abstract/kraken.js +9 -0
  67. package/dist/cjs/js/src/abstract/krakenfutures.js +9 -0
  68. package/dist/cjs/js/src/abstract/kucoin.js +9 -0
  69. package/dist/cjs/js/src/abstract/kucoinfutures.js +9 -0
  70. package/dist/cjs/js/src/abstract/kuna.js +9 -0
  71. package/dist/cjs/js/src/abstract/latoken.js +9 -0
  72. package/dist/cjs/js/src/abstract/lbank.js +9 -0
  73. package/dist/cjs/js/src/abstract/luno.js +9 -0
  74. package/dist/cjs/js/src/abstract/lykke.js +9 -0
  75. package/dist/cjs/js/src/abstract/mercado.js +9 -0
  76. package/dist/cjs/js/src/abstract/mexc.js +9 -0
  77. package/dist/cjs/js/src/abstract/ndax.js +9 -0
  78. package/dist/cjs/js/src/abstract/novadax.js +9 -0
  79. package/dist/cjs/js/src/abstract/oceanex.js +9 -0
  80. package/dist/cjs/js/src/abstract/okcoin.js +9 -0
  81. package/dist/cjs/js/src/abstract/okx.js +9 -0
  82. package/dist/cjs/js/src/abstract/p2b.js +9 -0
  83. package/dist/cjs/js/src/abstract/paymium.js +9 -0
  84. package/dist/cjs/js/src/abstract/phemex.js +9 -0
  85. package/dist/cjs/js/src/abstract/poloniex.js +9 -0
  86. package/dist/cjs/js/src/abstract/poloniexfutures.js +9 -0
  87. package/dist/cjs/js/src/abstract/probit.js +9 -0
  88. package/dist/cjs/js/src/abstract/timex.js +9 -0
  89. package/dist/cjs/js/src/abstract/tokocrypto.js +9 -0
  90. package/dist/cjs/js/src/abstract/upbit.js +9 -0
  91. package/dist/cjs/js/src/abstract/wavesexchange.js +9 -0
  92. package/dist/cjs/js/src/abstract/wazirx.js +9 -0
  93. package/dist/cjs/js/src/abstract/whitebit.js +9 -0
  94. package/dist/cjs/js/src/abstract/woo.js +9 -0
  95. package/dist/cjs/js/src/abstract/yobit.js +9 -0
  96. package/dist/cjs/js/src/abstract/zaif.js +9 -0
  97. package/dist/cjs/js/src/abstract/zonda.js +9 -0
  98. package/dist/cjs/js/src/ace.js +1058 -0
  99. package/dist/cjs/js/src/alpaca.js +1125 -0
  100. package/dist/cjs/js/src/ascendex.js +3360 -0
  101. package/dist/cjs/js/src/base/Exchange.js +5110 -0
  102. package/dist/cjs/js/src/base/Precise.js +263 -0
  103. package/dist/cjs/js/src/base/errors.js +299 -0
  104. package/dist/cjs/js/src/base/functions/crypto.js +78 -0
  105. package/dist/cjs/js/src/base/functions/encode.js +44 -0
  106. package/dist/cjs/js/src/base/functions/generic.js +193 -0
  107. package/dist/cjs/js/src/base/functions/misc.js +96 -0
  108. package/dist/cjs/js/src/base/functions/number.js +297 -0
  109. package/dist/cjs/js/src/base/functions/platform.js +28 -0
  110. package/dist/cjs/js/src/base/functions/rsa.js +34 -0
  111. package/dist/cjs/js/src/base/functions/string.js +48 -0
  112. package/dist/cjs/js/src/base/functions/throttle.js +66 -0
  113. package/dist/cjs/js/src/base/functions/time.js +187 -0
  114. package/dist/cjs/js/src/base/functions/totp.js +24 -0
  115. package/dist/cjs/js/src/base/functions/type.js +162 -0
  116. package/dist/cjs/js/src/base/functions.js +157 -0
  117. package/dist/cjs/js/src/base/ws/Cache.js +254 -0
  118. package/dist/cjs/js/src/base/ws/Client.js +299 -0
  119. package/dist/cjs/js/src/base/ws/Future.js +34 -0
  120. package/dist/cjs/js/src/base/ws/OrderBook.js +107 -0
  121. package/dist/cjs/js/src/base/ws/OrderBookSide.js +281 -0
  122. package/dist/cjs/js/src/base/ws/WsClient.js +69 -0
  123. package/dist/cjs/js/src/bequant.js +33 -0
  124. package/dist/cjs/js/src/bigone.js +2142 -0
  125. package/dist/cjs/js/src/binance.js +9729 -0
  126. package/dist/cjs/js/src/binancecoinm.js +45 -0
  127. package/dist/cjs/js/src/binanceus.js +84 -0
  128. package/dist/cjs/js/src/binanceusdm.js +58 -0
  129. package/dist/cjs/js/src/bingx.js +3737 -0
  130. package/dist/cjs/js/src/bit2c.js +916 -0
  131. package/dist/cjs/js/src/bitbank.js +1000 -0
  132. package/dist/cjs/js/src/bitbay.js +17 -0
  133. package/dist/cjs/js/src/bitbns.js +1220 -0
  134. package/dist/cjs/js/src/bitcoincom.js +17 -0
  135. package/dist/cjs/js/src/bitfinex.js +1670 -0
  136. package/dist/cjs/js/src/bitfinex2.js +2990 -0
  137. package/dist/cjs/js/src/bitflyer.js +1045 -0
  138. package/dist/cjs/js/src/bitforex.js +852 -0
  139. package/dist/cjs/js/src/bitget.js +8284 -0
  140. package/dist/cjs/js/src/bithumb.js +1090 -0
  141. package/dist/cjs/js/src/bitmart.js +4454 -0
  142. package/dist/cjs/js/src/bitmex.js +2884 -0
  143. package/dist/cjs/js/src/bitopro.js +1724 -0
  144. package/dist/cjs/js/src/bitpanda.js +2002 -0
  145. package/dist/cjs/js/src/bitrue.js +3253 -0
  146. package/dist/cjs/js/src/bitso.js +1753 -0
  147. package/dist/cjs/js/src/bitstamp.js +2188 -0
  148. package/dist/cjs/js/src/bitteam.js +2309 -0
  149. package/dist/cjs/js/src/bitvavo.js +1968 -0
  150. package/dist/cjs/js/src/bl3p.js +447 -0
  151. package/dist/cjs/js/src/blockchaincom.js +1160 -0
  152. package/dist/cjs/js/src/btcalpha.js +929 -0
  153. package/dist/cjs/js/src/btcbox.js +565 -0
  154. package/dist/cjs/js/src/btcmarkets.js +1237 -0
  155. package/dist/cjs/js/src/btcturk.js +929 -0
  156. package/dist/cjs/js/src/bybit.js +7646 -0
  157. package/dist/cjs/js/src/cex.js +1693 -0
  158. package/dist/cjs/js/src/coinbase.js +3274 -0
  159. package/dist/cjs/js/src/coinbasepro.js +1866 -0
  160. package/dist/cjs/js/src/coincheck.js +843 -0
  161. package/dist/cjs/js/src/coinex.js +5414 -0
  162. package/dist/cjs/js/src/coinlist.js +2329 -0
  163. package/dist/cjs/js/src/coinmate.js +989 -0
  164. package/dist/cjs/js/src/coinone.js +1185 -0
  165. package/dist/cjs/js/src/coinsph.js +1933 -0
  166. package/dist/cjs/js/src/coinspot.js +548 -0
  167. package/dist/cjs/js/src/cryptocom.js +3007 -0
  168. package/dist/cjs/js/src/currencycom.js +2015 -0
  169. package/dist/cjs/js/src/delta.js +3256 -0
  170. package/dist/cjs/js/src/deribit.js +3306 -0
  171. package/dist/cjs/js/src/digifinex.js +4307 -0
  172. package/dist/cjs/js/src/exmo.js +2645 -0
  173. package/dist/cjs/js/src/fmfwio.js +34 -0
  174. package/dist/cjs/js/src/gate.js +7054 -0
  175. package/dist/cjs/js/src/gateio.js +16 -0
  176. package/dist/cjs/js/src/gemini.js +1801 -0
  177. package/dist/cjs/js/src/hitbtc.js +3660 -0
  178. package/dist/cjs/js/src/hitbtc3.js +19 -0
  179. package/dist/cjs/js/src/hollaex.js +1882 -0
  180. package/dist/cjs/js/src/htx.js +9024 -0
  181. package/dist/cjs/js/src/huobi.js +16 -0
  182. package/dist/cjs/js/src/huobijp.js +1918 -0
  183. package/dist/cjs/js/src/idex.js +1770 -0
  184. package/dist/cjs/js/src/independentreserve.js +759 -0
  185. package/dist/cjs/js/src/indodax.js +1069 -0
  186. package/dist/cjs/js/src/kraken.js +2861 -0
  187. package/dist/cjs/js/src/krakenfutures.js +2407 -0
  188. package/dist/cjs/js/src/kucoin.js +4489 -0
  189. package/dist/cjs/js/src/kucoinfutures.js +2475 -0
  190. package/dist/cjs/js/src/kuna.js +1949 -0
  191. package/dist/cjs/js/src/latoken.js +1729 -0
  192. package/dist/cjs/js/src/lbank.js +2825 -0
  193. package/dist/cjs/js/src/luno.js +1044 -0
  194. package/dist/cjs/js/src/lykke.js +1303 -0
  195. package/dist/cjs/js/src/mercado.js +897 -0
  196. package/dist/cjs/js/src/mexc.js +5407 -0
  197. package/dist/cjs/js/src/ndax.js +2450 -0
  198. package/dist/cjs/js/src/novadax.js +1556 -0
  199. package/dist/cjs/js/src/oceanex.js +964 -0
  200. package/dist/cjs/js/src/okcoin.js +3115 -0
  201. package/dist/cjs/js/src/okx.js +7329 -0
  202. package/dist/cjs/js/src/p2b.js +1243 -0
  203. package/dist/cjs/js/src/paymium.js +597 -0
  204. package/dist/cjs/js/src/phemex.js +4715 -0
  205. package/dist/cjs/js/src/poloniex.js +2356 -0
  206. package/dist/cjs/js/src/poloniexfutures.js +1794 -0
  207. package/dist/cjs/js/src/pro/alpaca.js +714 -0
  208. package/dist/cjs/js/src/pro/ascendex.js +957 -0
  209. package/dist/cjs/js/src/pro/bequant.js +33 -0
  210. package/dist/cjs/js/src/pro/binance.js +2796 -0
  211. package/dist/cjs/js/src/pro/binancecoinm.js +23 -0
  212. package/dist/cjs/js/src/pro/binanceus.js +51 -0
  213. package/dist/cjs/js/src/pro/binanceusdm.js +32 -0
  214. package/dist/cjs/js/src/pro/bingx.js +944 -0
  215. package/dist/cjs/js/src/pro/bitcoincom.js +29 -0
  216. package/dist/cjs/js/src/pro/bitfinex.js +672 -0
  217. package/dist/cjs/js/src/pro/bitfinex2.js +1159 -0
  218. package/dist/cjs/js/src/pro/bitget.js +1733 -0
  219. package/dist/cjs/js/src/pro/bitmart.js +1486 -0
  220. package/dist/cjs/js/src/pro/bitmex.js +1576 -0
  221. package/dist/cjs/js/src/pro/bitopro.js +327 -0
  222. package/dist/cjs/js/src/pro/bitpanda.js +1341 -0
  223. package/dist/cjs/js/src/pro/bitrue.js +462 -0
  224. package/dist/cjs/js/src/pro/bitstamp.js +547 -0
  225. package/dist/cjs/js/src/pro/bitvavo.js +704 -0
  226. package/dist/cjs/js/src/pro/blockchaincom.js +794 -0
  227. package/dist/cjs/js/src/pro/bybit.js +1843 -0
  228. package/dist/cjs/js/src/pro/cex.js +1510 -0
  229. package/dist/cjs/js/src/pro/coinbase.js +561 -0
  230. package/dist/cjs/js/src/pro/coinbasepro.js +968 -0
  231. package/dist/cjs/js/src/pro/coinex.js +1095 -0
  232. package/dist/cjs/js/src/pro/cryptocom.js +1020 -0
  233. package/dist/cjs/js/src/pro/currencycom.js +563 -0
  234. package/dist/cjs/js/src/pro/deribit.js +825 -0
  235. package/dist/cjs/js/src/pro/exmo.js +658 -0
  236. package/dist/cjs/js/src/pro/gate.js +1316 -0
  237. package/dist/cjs/js/src/pro/gateio.js +16 -0
  238. package/dist/cjs/js/src/pro/gemini.js +649 -0
  239. package/dist/cjs/js/src/pro/hitbtc.js +1293 -0
  240. package/dist/cjs/js/src/pro/hollaex.js +597 -0
  241. package/dist/cjs/js/src/pro/htx.js +2383 -0
  242. package/dist/cjs/js/src/pro/huobi.js +16 -0
  243. package/dist/cjs/js/src/pro/huobijp.js +606 -0
  244. package/dist/cjs/js/src/pro/idex.js +714 -0
  245. package/dist/cjs/js/src/pro/independentreserve.js +280 -0
  246. package/dist/cjs/js/src/pro/kraken.js +1364 -0
  247. package/dist/cjs/js/src/pro/krakenfutures.js +1500 -0
  248. package/dist/cjs/js/src/pro/kucoin.js +1052 -0
  249. package/dist/cjs/js/src/pro/kucoinfutures.js +981 -0
  250. package/dist/cjs/js/src/pro/luno.js +322 -0
  251. package/dist/cjs/js/src/pro/mexc.js +1170 -0
  252. package/dist/cjs/js/src/pro/ndax.js +545 -0
  253. package/dist/cjs/js/src/pro/okcoin.js +760 -0
  254. package/dist/cjs/js/src/pro/okx.js +1558 -0
  255. package/dist/cjs/js/src/pro/phemex.js +1511 -0
  256. package/dist/cjs/js/src/pro/poloniex.js +1253 -0
  257. package/dist/cjs/js/src/pro/poloniexfutures.js +1014 -0
  258. package/dist/cjs/js/src/pro/probit.js +586 -0
  259. package/dist/cjs/js/src/pro/upbit.js +234 -0
  260. package/dist/cjs/js/src/pro/wazirx.js +776 -0
  261. package/dist/cjs/js/src/pro/whitebit.js +927 -0
  262. package/dist/cjs/js/src/pro/woo.js +769 -0
  263. package/dist/cjs/js/src/probit.js +1865 -0
  264. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +401 -0
  265. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +195 -0
  266. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +308 -0
  267. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +554 -0
  268. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  269. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  270. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  271. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +16 -0
  272. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1760 -0
  273. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +52 -0
  274. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +81 -0
  275. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +376 -0
  276. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +70 -0
  277. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1580 -0
  278. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +74 -0
  279. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +24 -0
  280. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +158 -0
  281. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +429 -0
  282. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +176 -0
  283. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +324 -0
  284. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +163 -0
  285. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +245 -0
  286. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1018 -0
  287. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +383 -0
  288. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +258 -0
  289. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +53 -0
  290. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +120 -0
  291. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +69 -0
  292. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +7 -0
  293. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +83 -0
  294. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +240 -0
  295. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +91 -0
  296. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +130 -0
  297. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +214 -0
  298. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +239 -0
  299. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +93 -0
  300. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +354 -0
  301. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +16 -0
  302. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +20 -0
  303. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +30 -0
  304. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +239 -0
  305. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +372 -0
  306. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +273 -0
  307. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +139 -0
  308. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +14 -0
  309. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +16 -0
  310. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +81 -0
  311. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +292 -0
  312. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +103 -0
  313. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +140 -0
  314. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +175 -0
  315. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  316. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +7 -0
  317. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +383 -0
  318. package/dist/cjs/js/src/timex.js +1562 -0
  319. package/dist/cjs/js/src/tokocrypto.js +2542 -0
  320. package/dist/cjs/js/src/upbit.js +1844 -0
  321. package/dist/cjs/js/src/wavesexchange.js +2607 -0
  322. package/dist/cjs/js/src/wazirx.js +953 -0
  323. package/dist/cjs/js/src/whitebit.js +2309 -0
  324. package/dist/cjs/js/src/woo.js +2715 -0
  325. package/dist/cjs/js/src/yobit.js +1314 -0
  326. package/dist/cjs/js/src/zaif.js +736 -0
  327. package/dist/cjs/js/src/zonda.js +1883 -0
  328. package/js/ccxt.d.ts +1 -1
  329. package/js/ccxt.js +1 -1
  330. package/js/src/abstract/bigone.d.ts +18 -0
  331. package/js/src/abstract/binance.d.ts +2 -0
  332. package/js/src/abstract/binancecoinm.d.ts +2 -0
  333. package/js/src/abstract/binanceus.d.ts +2 -0
  334. package/js/src/abstract/binanceusdm.d.ts +2 -0
  335. package/js/src/abstract/bybit.d.ts +1 -0
  336. package/js/src/abstract/gate.d.ts +11 -0
  337. package/js/src/abstract/gateio.d.ts +11 -0
  338. package/js/src/alpaca.js +18 -18
  339. package/js/src/base/Exchange.d.ts +5 -1
  340. package/js/src/base/Exchange.js +101 -12
  341. package/js/src/bigone.d.ts +1 -2
  342. package/js/src/bigone.js +340 -145
  343. package/js/src/binance.js +15 -8
  344. package/js/src/bingx.js +9 -2
  345. package/js/src/bitfinex.d.ts +2 -2
  346. package/js/src/bitfinex.js +2 -3
  347. package/js/src/bitget.js +21 -8
  348. package/js/src/bitmart.d.ts +2 -2
  349. package/js/src/bitmart.js +3 -3
  350. package/js/src/bitmex.js +1 -0
  351. package/js/src/bybit.js +2 -0
  352. package/js/src/coinlist.js +2 -3
  353. package/js/src/coinsph.js +2 -3
  354. package/js/src/deribit.js +1 -0
  355. package/js/src/gate.d.ts +4 -4
  356. package/js/src/gate.js +22 -3
  357. package/js/src/hitbtc.d.ts +4 -4
  358. package/js/src/hitbtc.js +2 -3
  359. package/js/src/htx.js +4 -7
  360. package/js/src/huobijp.js +2 -3
  361. package/js/src/kraken.js +1 -0
  362. package/js/src/mexc.js +2 -1
  363. package/js/src/okx.js +13 -3
  364. package/js/src/pro/binance.d.ts +2 -23
  365. package/js/src/pro/binance.js +58 -22
  366. package/js/src/pro/coinbase.d.ts +2 -2
  367. package/js/src/pro/coinbase.js +4 -1
  368. package/js/src/pro/coinbasepro.d.ts +2 -2
  369. package/js/src/pro/hitbtc.d.ts +2 -2
  370. package/js/src/pro/poloniex.d.ts +2 -2
  371. package/js/src/upbit.d.ts +3 -101
  372. package/js/src/upbit.js +12 -12
  373. package/js/src/woo.js +2 -0
  374. package/package.json +1 -1
  375. package/skip-tests.json +5 -0
@@ -0,0 +1,1949 @@
1
+ 'use strict';
2
+
3
+ var kuna$1 = require('./abstract/kuna.js');
4
+ var errors = require('./base/errors.js');
5
+ var number = require('./base/functions/number.js');
6
+ var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
7
+ var sha512 = require('./static_dependencies/noble-hashes/sha512.js');
8
+ var Precise = require('./base/Precise.js');
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // ---------------------------------------------------------------------------
12
+ /**
13
+ * @class kuna
14
+ * @augments Exchange
15
+ * @description Use the public-key as your apiKey
16
+ */
17
+ class kuna extends kuna$1 {
18
+ describe() {
19
+ return this.deepExtend(super.describe(), {
20
+ 'id': 'kuna',
21
+ 'name': 'Kuna',
22
+ 'countries': ['UA'],
23
+ 'rateLimit': 1000,
24
+ 'version': 'v4',
25
+ 'has': {
26
+ 'CORS': undefined,
27
+ 'spot': true,
28
+ 'margin': false,
29
+ 'swap': false,
30
+ 'future': false,
31
+ 'option': false,
32
+ 'addMargin': false,
33
+ 'cancelOrder': true,
34
+ 'cancelOrders': true,
35
+ 'closeAllPositions': false,
36
+ 'closePosition': false,
37
+ 'createDepositAddress': true,
38
+ 'createOrder': true,
39
+ 'createPostOnlyOrder': false,
40
+ 'createReduceOnlyOrder': false,
41
+ 'createStopLimitOrder': true,
42
+ 'createStopMarketOrder': false,
43
+ 'createStopOrder': true,
44
+ 'fetchBalance': true,
45
+ 'fetchBorrowInterest': false,
46
+ 'fetchBorrowRateHistories': false,
47
+ 'fetchBorrowRateHistory': false,
48
+ 'fetchClosedOrders': true,
49
+ 'fetchCrossBorrowRate': false,
50
+ 'fetchCrossBorrowRates': false,
51
+ 'fetchCurrencies': true,
52
+ 'fetchDeposit': true,
53
+ 'fetchDepositAddress': true,
54
+ 'fetchDeposits': true,
55
+ 'fetchDepositsWithdrawals': false,
56
+ 'fetchFundingHistory': false,
57
+ 'fetchFundingRate': false,
58
+ 'fetchFundingRateHistory': false,
59
+ 'fetchFundingRates': false,
60
+ 'fetchIndexOHLCV': false,
61
+ 'fetchIsolatedBorrowRate': false,
62
+ 'fetchIsolatedBorrowRates': false,
63
+ 'fetchIsolatedPositions': false,
64
+ 'fetchL3OrderBook': true,
65
+ 'fetchLeverage': false,
66
+ 'fetchLeverageTiers': false,
67
+ 'fetchMarginMode': false,
68
+ 'fetchMarketLeverageTiers': false,
69
+ 'fetchMarkets': true,
70
+ 'fetchMarkOHLCV': false,
71
+ 'fetchMyTrades': true,
72
+ 'fetchOHLCV': 'emulated',
73
+ 'fetchOpenInterest': false,
74
+ 'fetchOpenInterestHistory': false,
75
+ 'fetchOpenOrders': true,
76
+ 'fetchOrder': true,
77
+ 'fetchOrderBook': true,
78
+ 'fetchOrdersByStatus': true,
79
+ 'fetchPosition': false,
80
+ 'fetchPositionMode': false,
81
+ 'fetchPositions': false,
82
+ 'fetchPositionsForSymbol': false,
83
+ 'fetchPositionsRisk': false,
84
+ 'fetchPremiumIndexOHLCV': false,
85
+ 'fetchTicker': true,
86
+ 'fetchTickers': true,
87
+ 'fetchTime': true,
88
+ 'fetchTrades': true,
89
+ 'fetchTradingFee': false,
90
+ 'fetchTradingFees': false,
91
+ 'fetchTransactions': false,
92
+ 'fetchTransfers': false,
93
+ 'fetchWithdrawAddresses': false,
94
+ 'fetchWithdrawal': true,
95
+ 'fetchWithdrawals': true,
96
+ 'reduceMargin': false,
97
+ 'repayCrossMargin': false,
98
+ 'repayIsolatedMargin': false,
99
+ 'setLeverage': false,
100
+ 'setMargin': false,
101
+ 'setMarginMode': false,
102
+ 'setPositionMode': false,
103
+ 'signIn': false,
104
+ 'transfer': false,
105
+ 'withdraw': true,
106
+ },
107
+ 'timeframes': undefined,
108
+ 'urls': {
109
+ 'extension': '.json',
110
+ 'referral': 'https://kuna.io?r=kunaid-gvfihe8az7o4',
111
+ 'logo': 'https://user-images.githubusercontent.com/51840849/87153927-f0578b80-c2c0-11ea-84b6-74612568e9e1.jpg',
112
+ 'api': {
113
+ 'xreserve': 'https://api.xreserve.fund',
114
+ 'v3': 'https://api.kuna.io',
115
+ 'v4': 'https://api.kuna.io',
116
+ 'public': 'https://kuna.io',
117
+ 'private': 'https://kuna.io', // v2
118
+ },
119
+ 'www': 'https://kuna.io',
120
+ 'doc': 'https://kuna.io/documents/api',
121
+ 'fees': 'https://kuna.io/documents/api',
122
+ },
123
+ 'api': {
124
+ 'xreserve': {
125
+ 'get': {
126
+ 'nonce': 1,
127
+ 'fee': 1,
128
+ 'delegated-transactions': 1,
129
+ },
130
+ 'post': {
131
+ 'delegate-transfer': 1,
132
+ },
133
+ },
134
+ 'v4': {
135
+ 'private': {
136
+ 'get': {
137
+ 'private/me': 1,
138
+ 'private/getBalance': 1,
139
+ 'order/private/active': 1,
140
+ 'order/private/history': 1,
141
+ 'order/private/{id}/trades': 1,
142
+ 'order/private/details/{id}': 1,
143
+ 'trade/private/history': 1,
144
+ 'transaction/private/{hash}': 1,
145
+ 'deposit/private/preRequest': 1,
146
+ 'deposit/private/crypto/address': 1,
147
+ 'deposit/private/crypto/getMerchantAddress': 1,
148
+ 'deposit/private/history': 1,
149
+ 'deposit/private/details/{depositId}': 1,
150
+ 'withdraw/private/preRequest': 1,
151
+ 'withdraw/private/history': 1,
152
+ 'withdraw/private/details/{withdrawId}': 1,
153
+ 'kuna-code/{id}': 1,
154
+ 'kuna-code/{code}/check': 1,
155
+ 'kuna-code/issued-by-me': 1,
156
+ 'kuna-code/redeemed-by-me': 1,
157
+ },
158
+ 'post': {
159
+ 'order/private/create': 1,
160
+ 'order/private/cancel': 1,
161
+ 'order/private/cancel/multi': 1,
162
+ 'deposit/private/crypto/generateAddress': 1,
163
+ 'deposit/private/crypto/generateMerchantAddress': 1,
164
+ 'withdraw/private/create': 1,
165
+ 'kuna-code': 1,
166
+ },
167
+ 'put': {
168
+ 'kuna-code/redeem': 1,
169
+ },
170
+ },
171
+ 'public': {
172
+ 'get': {
173
+ 'public/timestamp': 1,
174
+ 'public/fees': 1,
175
+ 'public/currencies?type={type}': 1,
176
+ 'public/currencies': 1,
177
+ 'markets/public/getAll': 1,
178
+ 'markets/public/tickers?pairs={pairs}': 1,
179
+ 'order/public/book/{pairs}': 1,
180
+ 'trade/public/book/{pairs}': 1,
181
+ },
182
+ },
183
+ },
184
+ 'v3': {
185
+ 'public': {
186
+ 'get': {
187
+ 'timestamp': 1,
188
+ 'currencies': 1,
189
+ 'markets': 1,
190
+ 'tickers': 1,
191
+ 'k': 1,
192
+ 'trades_history': 1,
193
+ 'fees': 1,
194
+ 'exchange-rates': 1,
195
+ 'exchange-rates/currency': 1,
196
+ 'book/market': 1,
197
+ 'kuna_codes/code/check': 1,
198
+ 'landing_page_statistic': 1,
199
+ 'translations/locale': 1,
200
+ 'trades/market/hist': 1,
201
+ },
202
+ 'post': {
203
+ 'http_test': 1,
204
+ 'deposit_channels': 1,
205
+ 'withdraw_channels': 1,
206
+ 'subscription_plans': 1,
207
+ 'send_to': 1,
208
+ 'confirm_token': 1,
209
+ 'kunaid': 1,
210
+ 'withdraw/prerequest': 1,
211
+ 'deposit/prerequest': 1,
212
+ 'deposit/exchange-rates': 1,
213
+ },
214
+ },
215
+ 'sign': {
216
+ 'get': {
217
+ 'reset_password/token': 1,
218
+ },
219
+ 'post': {
220
+ 'signup/google': 1,
221
+ 'signup/resend_confirmation': 1,
222
+ 'signup': 1,
223
+ 'signin': 1,
224
+ 'signin/two_factor': 1,
225
+ 'signin/resend_confirm_device': 1,
226
+ 'signin/confirm_device': 1,
227
+ 'reset_password': 1,
228
+ 'cool-signin': 1,
229
+ },
230
+ 'put': {
231
+ 'reset_password/token': 1,
232
+ 'signup/code/confirm': 1,
233
+ },
234
+ },
235
+ 'private': {
236
+ 'post': {
237
+ 'auth/w/order/submit': 1,
238
+ 'auth/r/orders': 1,
239
+ 'auth/r/orders/market': 1,
240
+ 'auth/r/orders/markets': 1,
241
+ 'auth/api_tokens/delete': 1,
242
+ 'auth/api_tokens/create': 1,
243
+ 'auth/api_tokens': 1,
244
+ 'auth/signin_history/uniq': 1,
245
+ 'auth/signin_history': 1,
246
+ 'auth/disable_withdraw_confirmation': 1,
247
+ 'auth/change_password': 1,
248
+ 'auth/deposit_address': 1,
249
+ 'auth/announcements/accept': 1,
250
+ 'auth/announcements/unaccepted': 1,
251
+ 'auth/otp/deactivate': 1,
252
+ 'auth/otp/activate': 1,
253
+ 'auth/otp/secret': 1,
254
+ 'auth/r/order/market/:order_id/trades': 1,
255
+ 'auth/r/orders/market/hist': 1,
256
+ 'auth/r/orders/hist': 1,
257
+ 'auth/r/orders/hist/markets': 1,
258
+ 'auth/r/orders/details': 1,
259
+ 'auth/assets-history': 1,
260
+ 'auth/assets-history/withdraws': 1,
261
+ 'auth/assets-history/deposits': 1,
262
+ 'auth/r/wallets': 1,
263
+ 'auth/markets/favorites': 1,
264
+ 'auth/markets/favorites/list': 1,
265
+ 'auth/me/update': 1,
266
+ 'auth/me': 1,
267
+ 'auth/fund_sources': 1,
268
+ 'auth/fund_sources/list': 1,
269
+ 'auth/withdraw/resend_confirmation': 1,
270
+ 'auth/withdraw': 1,
271
+ 'auth/withdraw/details': 1,
272
+ 'auth/withdraw/info': 1,
273
+ 'auth/payment_addresses': 1,
274
+ 'auth/deposit/prerequest': 1,
275
+ 'auth/deposit/exchange-rates': 1,
276
+ 'auth/deposit': 1,
277
+ 'auth/deposit/details': 1,
278
+ 'auth/deposit/info': 1,
279
+ 'auth/kuna_codes/count': 1,
280
+ 'auth/kuna_codes/details': 1,
281
+ 'auth/kuna_codes/edit': 1,
282
+ 'auth/kuna_codes/send-pdf': 1,
283
+ 'auth/kuna_codes': 1,
284
+ 'auth/kuna_codes/redeemed-by-me': 1,
285
+ 'auth/kuna_codes/issued-by-me': 1,
286
+ 'auth/payment_requests/invoice': 1,
287
+ 'auth/payment_requests/type': 1,
288
+ 'auth/referral_program/weekly_earnings': 1,
289
+ 'auth/referral_program/stats': 1,
290
+ 'auth/merchant/payout_services': 1,
291
+ 'auth/merchant/withdraw': 1,
292
+ 'auth/merchant/payment_services': 1,
293
+ 'auth/merchant/deposit': 1,
294
+ 'auth/verification/auth_token': 1,
295
+ 'auth/kunaid_purchase/create': 1,
296
+ 'auth/devices/list': 1,
297
+ 'auth/sessions/list': 1,
298
+ 'auth/subscriptions/reactivate': 1,
299
+ 'auth/subscriptions/cancel': 1,
300
+ 'auth/subscriptions/prolong': 1,
301
+ 'auth/subscriptions/create': 1,
302
+ 'auth/subscriptions/list': 1,
303
+ 'auth/kuna_ids/list': 1,
304
+ 'order/cancel/multi': 1,
305
+ 'order/cancel': 1,
306
+ },
307
+ 'put': {
308
+ 'auth/fund_sources/id': 1,
309
+ 'auth/kuna_codes/redeem': 1,
310
+ },
311
+ 'delete': {
312
+ 'auth/markets/favorites': 1,
313
+ 'auth/fund_sources': 1,
314
+ 'auth/devices': 1,
315
+ 'auth/devices/list': 1,
316
+ 'auth/sessions/list': 1,
317
+ 'auth/sessions': 1,
318
+ },
319
+ },
320
+ },
321
+ 'public': {
322
+ 'get': [
323
+ 'depth',
324
+ 'k_with_pending_trades',
325
+ 'k',
326
+ 'markets',
327
+ 'order_book',
328
+ 'order_book/{market}',
329
+ 'tickers',
330
+ 'tickers/{market}',
331
+ 'timestamp',
332
+ 'trades',
333
+ 'trades/{market}',
334
+ ],
335
+ },
336
+ 'private': {
337
+ 'get': [
338
+ 'members/me',
339
+ 'deposits',
340
+ 'deposit',
341
+ 'deposit_address',
342
+ 'orders',
343
+ 'order',
344
+ 'trades/my',
345
+ 'withdraws',
346
+ 'withdraw', // Get your cryptocurrency withdraw
347
+ ],
348
+ 'post': [
349
+ 'orders',
350
+ 'orders/multi',
351
+ 'orders/clear',
352
+ 'order/delete',
353
+ 'withdraw', // Create a withdraw
354
+ ],
355
+ },
356
+ },
357
+ 'fees': {
358
+ 'trading': {
359
+ 'tierBased': false,
360
+ 'percentage': true,
361
+ 'taker': this.parseNumber('0.0025'),
362
+ 'maker': this.parseNumber('0.0025'),
363
+ },
364
+ 'funding': {
365
+ 'withdraw': {
366
+ 'UAH': '1%',
367
+ 'BTC': 0.001,
368
+ 'BCH': 0.001,
369
+ 'ETH': 0.01,
370
+ 'WAVES': 0.01,
371
+ 'GOL': 0.0,
372
+ 'GBG': 0.0,
373
+ // 'RMC': 0.001 BTC
374
+ // 'ARN': 0.01 ETH
375
+ // 'R': 0.01 ETH
376
+ // 'EVR': 0.01 ETH
377
+ },
378
+ 'deposit': {
379
+ // 'UAH': (amount) => amount * 0.001 + 5
380
+ },
381
+ },
382
+ },
383
+ 'commonCurrencies': {
384
+ 'PLA': 'Plair',
385
+ },
386
+ 'precisionMode': number.TICK_SIZE,
387
+ 'exceptions': {
388
+ 'ARGUMENT_VALIDATION_ERROR': errors.BadRequest,
389
+ 'PAYMENT_METHOD_NOT_SUPPORTED': errors.BadRequest,
390
+ 'NOT_FOUND': errors.OrderNotFound,
391
+ 'INVALID:ORDER_SIZE': errors.InvalidOrder,
392
+ 'WrongRequestException': errors.BadRequest,
393
+ 'INSUFFICIENT_FUNDS': errors.InsufficientFunds,
394
+ '2002': errors.InsufficientFunds,
395
+ '2003': errors.OrderNotFound,
396
+ },
397
+ 'options': {
398
+ // 'account': 'pro' // Only for pro accounts
399
+ },
400
+ });
401
+ }
402
+ async fetchTime(params = {}) {
403
+ /**
404
+ * @method
405
+ * @name kuna#fetchTime
406
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
407
+ * @see https://docs.kuna.io/docs/get-time-on-the-server
408
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
409
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
410
+ */
411
+ const response = await this.v4PublicGetPublicTimestamp(params);
412
+ //
413
+ // {
414
+ // "data": {
415
+ // "timestamp": 1686740531,
416
+ // "timestamp_miliseconds": 1686740531725,
417
+ // }
418
+ // }
419
+ //
420
+ const data = this.safeValue(response, 'data', {});
421
+ return this.safeInteger(data, 'timestamp_miliseconds');
422
+ }
423
+ async fetchCurrencies(params = {}) {
424
+ /**
425
+ * @method
426
+ * @name kuna#fetchCurrencies
427
+ * @description fetches all available currencies on an exchange
428
+ * @see https://docs.kuna.io/docs/get-information-about-available-currencies
429
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
430
+ * @returns {object} an associative dictionary of currencies
431
+ */
432
+ const response = await this.v4PublicGetPublicCurrencies(params);
433
+ //
434
+ // {
435
+ // "data": [
436
+ // {
437
+ // "code": "BTC",
438
+ // "name": "Bitcoin",
439
+ // "payload": {
440
+ // "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
441
+ // "icons": {
442
+ // "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
443
+ // "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
444
+ // "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
445
+ // "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
446
+ // },
447
+ // "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
448
+ // },
449
+ // "position": 1,
450
+ // "precision": 8,
451
+ // "tradePrecision": 6,
452
+ // "type": "Crypto"
453
+ // }
454
+ // ]
455
+ // }
456
+ //
457
+ const data = this.safeValue(response, 'data', []);
458
+ return this.parseCurrencies(data);
459
+ }
460
+ parseCurrencies(currencies, params = {}) {
461
+ currencies = this.toArray(currencies);
462
+ const result = {};
463
+ for (let i = 0; i < currencies.length; i++) {
464
+ const currency = this.parseCurrency(currencies[i]);
465
+ result[currency['code']] = currency;
466
+ }
467
+ return result;
468
+ }
469
+ parseCurrency(currency) {
470
+ //
471
+ // {
472
+ // "code": "BTC",
473
+ // "name": "Bitcoin",
474
+ // "payload": {
475
+ // "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
476
+ // "icons": {
477
+ // "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
478
+ // "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
479
+ // "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
480
+ // "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
481
+ // },
482
+ // "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
483
+ // },
484
+ // "position": 1,
485
+ // "precision": 8,
486
+ // "tradePrecision": 6,
487
+ // "type": "Crypto"
488
+ // }
489
+ //
490
+ const currencyId = this.safeString(currency, 'code');
491
+ const precision = this.safeString(currency, 'precision');
492
+ const tradePrecision = this.safeString(currency, 'tradePrecision');
493
+ return {
494
+ 'info': currency,
495
+ 'id': currencyId,
496
+ 'code': this.safeCurrencyCode(currencyId),
497
+ 'type': undefined,
498
+ 'margin': undefined,
499
+ 'name': this.safeString(currency, 'name'),
500
+ 'active': undefined,
501
+ 'deposit': undefined,
502
+ 'withdraw': undefined,
503
+ 'fee': undefined,
504
+ 'precision': Precise["default"].stringMin(precision, tradePrecision),
505
+ 'limits': {
506
+ 'amount': {
507
+ 'min': undefined,
508
+ 'max': undefined,
509
+ },
510
+ 'withdraw': {
511
+ 'min': undefined,
512
+ 'max': undefined,
513
+ },
514
+ },
515
+ 'networks': {},
516
+ };
517
+ }
518
+ async fetchMarkets(params = {}) {
519
+ /**
520
+ * @method
521
+ * @name kuna#fetchMarkets
522
+ * @description retrieves data on all markets for kuna
523
+ * @see https://docs.kuna.io/docs/get-all-traded-markets
524
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
525
+ * @returns {object[]} an array of objects representing market data
526
+ */
527
+ const response = await this.v4PublicGetMarketsPublicGetAll(params);
528
+ //
529
+ // {
530
+ // "data": [
531
+ // {
532
+ // "pair": "BTC_USDT", // Traded pair of assets
533
+ // "baseAsset": { // The base asset of the traded pair, the one to sell or buy as a result of the trade
534
+ // "code": "BTC",
535
+ // "precision": 6 // Maximum amount of digits for the decimal part of a number
536
+ // },
537
+ // "quoteAsset": { // The quoted asset of the traded pair, the one to use to sell or buy the base asset
538
+ // "code": "USDT",
539
+ // "precision": 2 // Maximum amount of digits for the decimal part of a number
540
+ // },
541
+ // "tickerPriceChange": "-0.07" // Relative change compared with the last tick
542
+ // }
543
+ // ]
544
+ // }
545
+ //
546
+ const data = this.safeValue(response, 'data', []);
547
+ const markets = [];
548
+ for (let i = 0; i < data.length; i++) {
549
+ const item = data[i];
550
+ const marketId = this.safeString(item, 'pair');
551
+ const baseAsset = this.safeValue(item, 'baseAsset');
552
+ const quoteAsset = this.safeValue(item, 'quoteAsset');
553
+ const baseId = this.safeString(baseAsset, 'code');
554
+ const quoteId = this.safeString(quoteAsset, 'code');
555
+ const base = this.safeCurrencyCode(baseId);
556
+ const quote = this.safeCurrencyCode(quoteId);
557
+ const basePrecision = this.safeString(baseAsset, 'precision');
558
+ const quotePrecision = this.safeString(quoteAsset, 'precision');
559
+ markets.push({
560
+ 'id': marketId,
561
+ 'symbol': base + '/' + quote,
562
+ 'base': base,
563
+ 'quote': quote,
564
+ 'settle': undefined,
565
+ 'baseId': baseId,
566
+ 'quoteId': quoteId,
567
+ 'settleId': undefined,
568
+ 'type': 'spot',
569
+ 'spot': true,
570
+ 'margin': false,
571
+ 'swap': false,
572
+ 'future': false,
573
+ 'option': false,
574
+ 'active': undefined,
575
+ 'contract': false,
576
+ 'linear': undefined,
577
+ 'inverse': undefined,
578
+ 'contractSize': undefined,
579
+ 'expiry': undefined,
580
+ 'expiryDatetime': undefined,
581
+ 'strike': undefined,
582
+ 'optionType': undefined,
583
+ 'precision': {
584
+ 'amount': this.parseNumber(this.parsePrecision(basePrecision)),
585
+ 'price': this.parseNumber(this.parsePrecision(quotePrecision)),
586
+ },
587
+ 'limits': {
588
+ 'leverage': {
589
+ 'min': undefined,
590
+ 'max': undefined,
591
+ },
592
+ 'amount': {
593
+ 'min': undefined,
594
+ 'max': undefined,
595
+ },
596
+ 'price': {
597
+ 'min': undefined,
598
+ 'max': undefined,
599
+ },
600
+ 'cost': {
601
+ 'min': undefined,
602
+ 'max': undefined,
603
+ },
604
+ },
605
+ 'created': undefined,
606
+ 'info': item,
607
+ });
608
+ }
609
+ return markets;
610
+ }
611
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
612
+ /**
613
+ * @method
614
+ * @name kuna#fetchOrderBook
615
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
616
+ * @see https://docs.kuna.io/docs/get-public-orders-book
617
+ * @param {string} symbol unified symbol of the market to fetch the order book for
618
+ * @param {int} [limit] 5, 10, 20, 50, 100, 500, or 1000 (default)
619
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
620
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
621
+ */
622
+ await this.loadMarkets();
623
+ const market = this.market(symbol);
624
+ const request = {
625
+ 'pairs': market['id'],
626
+ };
627
+ if (limit !== undefined) {
628
+ request['level'] = limit;
629
+ }
630
+ const response = await this.v4PublicGetOrderPublicBookPairs(this.extend(request, params));
631
+ //
632
+ // {
633
+ // "data": {
634
+ // "asks": [ // An array of sell orders
635
+ // [
636
+ // "16950", // Sell price, level 1
637
+ // "0.001" // Sell quantity, level 1
638
+ // ],
639
+ // [
640
+ // "17000", // Sell price, level 2
641
+ // "0.01" // Sell quantity, level 2
642
+ // ]
643
+ // ],
644
+ // "bids": [ // An array of buy orders
645
+ // [
646
+ // "16700", // Sell price, level 1
647
+ // "0.01" // Sell quantity, level 1
648
+ // ],
649
+ // [
650
+ // "16000", // Sell price, level 2
651
+ // "0.001" // Sell quantity, level 2
652
+ // ]
653
+ // ]
654
+ // }
655
+ // }
656
+ //
657
+ const data = this.safeValue(response, 'data', {});
658
+ return this.parseOrderBook(data, market['symbol'], undefined, 'bids', 'asks', 0, 1);
659
+ }
660
+ parseTicker(ticker, market = undefined) {
661
+ //
662
+ // {
663
+ // "pair": "BTC_USDT", // Traded pair
664
+ // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
665
+ // "price": "27900", // Current median price
666
+ // "equivalentPrice": "", // TBD
667
+ // "high": "29059.69", // Highest price
668
+ // "low": "27900", // Lowest price
669
+ // "baseVolume": "2.9008499999999993", // Traded volume as base
670
+ // "quoteVolume": "82251.41477976", // Traded volume as quote
671
+ // "bestBidPrice": "27926.91", // The best bid price now
672
+ // "bestAskPrice": "27970.02", // The best ask price now
673
+ // "priceChange": "-973.9700000000012" // Absolute price change
674
+ // }
675
+ //
676
+ const marketId = this.safeString(ticker, 'pair');
677
+ return this.safeTicker({
678
+ 'info': ticker,
679
+ 'symbol': this.safeSymbol(marketId, market),
680
+ 'timestamp': undefined,
681
+ 'datetime': undefined,
682
+ 'high': this.safeString(ticker, 'high'),
683
+ 'low': this.safeString(ticker, 'low'),
684
+ 'bid': this.safeString(ticker, 'bestBidPrice'),
685
+ 'ask': this.safeString(ticker, 'bestAskPrice'),
686
+ 'vwap': undefined,
687
+ 'open': this.safeString(ticker, 'open'),
688
+ 'close': undefined,
689
+ 'last': undefined,
690
+ 'previousClose': undefined,
691
+ 'change': this.safeString(ticker, 'priceChange'),
692
+ 'percentage': this.safeString(ticker, 'percentagePriceChange'),
693
+ 'average': undefined,
694
+ 'baseVolume': this.safeString(ticker, 'baseVolume'),
695
+ 'quoteVolume': this.safeString(ticker, 'quoteVolume'),
696
+ }, market);
697
+ }
698
+ async fetchTickers(symbols = undefined, params = {}) {
699
+ /**
700
+ * @method
701
+ * @name kuna#fetchTickers
702
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market. The average is not returned in the response, but the median can be accessed via response['info']['price']
703
+ * @see https://docs.kuna.io/docs/get-market-info-by-tickers
704
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
705
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
706
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
707
+ */
708
+ await this.loadMarkets();
709
+ if (symbols === undefined) {
710
+ throw new errors.ArgumentsRequired(this.id + ' fetchTickers () requires a symbols argument');
711
+ }
712
+ symbols = this.marketSymbols(symbols);
713
+ const marketIds = this.marketIds(symbols);
714
+ const request = {
715
+ 'pairs': marketIds.join(','),
716
+ };
717
+ const response = await this.v4PublicGetMarketsPublicTickersPairsPairs(this.extend(request, params));
718
+ //
719
+ // {
720
+ // "data": [
721
+ // {
722
+ // "pair": "BTC_USDT", // Traded pair
723
+ // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
724
+ // "price": "27900", // Current median price
725
+ // "equivalentPrice": "", // TBD
726
+ // "high": "29059.69", // Highest price
727
+ // "low": "27900", // Lowest price
728
+ // "baseVolume": "2.9008499999999993", // Traded volume as base
729
+ // "quoteVolume": "82251.41477976", // Traded volume as quote
730
+ // "bestBidPrice": "27926.91", // The best bid price now
731
+ // "bestAskPrice": "27970.02", // The best ask price now
732
+ // "priceChange": "-973.9700000000012" // Absolute price change
733
+ // }
734
+ // ...
735
+ // ]
736
+ // }
737
+ //
738
+ const data = this.safeValue(response, 'data', []);
739
+ return this.parseTickers(data, symbols, params);
740
+ }
741
+ async fetchTicker(symbol, params = {}) {
742
+ /**
743
+ * @method
744
+ * @name kuna#fetchTicker
745
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
746
+ * @see https://docs.kuna.io/docs/get-market-info-by-tickers
747
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
748
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
749
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
750
+ */
751
+ await this.loadMarkets();
752
+ const market = this.market(symbol);
753
+ const request = {
754
+ 'pairs': market['id'],
755
+ };
756
+ const response = await this.v4PublicGetMarketsPublicTickersPairsPairs(this.extend(request, params));
757
+ //
758
+ // {
759
+ // "data": [
760
+ // {
761
+ // "pair": "BTC_USDT", // Traded pair
762
+ // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
763
+ // "price": "27900", // Current median price
764
+ // "equivalentPrice": "", // TBD
765
+ // "high": "29059.69", // Highest price
766
+ // "low": "27900", // Lowest price
767
+ // "baseVolume": "2.9008499999999993", // Traded volume as base
768
+ // "quoteVolume": "82251.41477976", // Traded volume as quote
769
+ // "bestBidPrice": "27926.91", // The best bid price now
770
+ // "bestAskPrice": "27970.02", // The best ask price now
771
+ // "priceChange": "-973.9700000000012" // Absolute price change
772
+ // }
773
+ // ...
774
+ // ]
775
+ // }
776
+ //
777
+ const data = this.safeValue(response, 'data', []);
778
+ const ticker = this.safeValue(data, 0);
779
+ return this.parseTicker(ticker, market);
780
+ }
781
+ async fetchL3OrderBook(symbol, limit = undefined, params = {}) {
782
+ /**
783
+ * TODO: double check
784
+ * @method
785
+ * @name kuna#fetchL3OrderBook
786
+ * @description fetches level 3 information on open orders with bid (buy) and ask (sell) prices, volumes and other data
787
+ * @param {string} symbol unified market symbol
788
+ * @param {int} [limit] max number of orders to return, default is undefined
789
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
790
+ * @returns {object} an [order book structure]{@link https://docs.ccxt.com/#/?id=order-book-structure}
791
+ */
792
+ return await this.fetchOrderBook(symbol, limit, params);
793
+ }
794
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
795
+ /**
796
+ * @method
797
+ * @name kuna#fetchTrades
798
+ * @description get the list of most recent trades for a particular symbol
799
+ * @see https://docs.kuna.io/docs/get-public-trades-book
800
+ * @param {string} symbol unified symbol of the market to fetch trades for
801
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
802
+ * @param {int} [limit] between 1 and 100, 25 by default
803
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
804
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
805
+ */
806
+ await this.loadMarkets();
807
+ const market = this.market(symbol);
808
+ const request = {
809
+ 'pair': market['id'],
810
+ };
811
+ if (limit !== undefined) {
812
+ request['limit'] = limit;
813
+ }
814
+ const response = await this.v4PublicGetTradePublicBookPairs(this.extend(request, params));
815
+ //
816
+ // {
817
+ // "data": {
818
+ // "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
819
+ // "pair": "BTC_USDT", // Market pair that is being traded
820
+ // "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
821
+ // "matchPrice": "18649", // Exchange price at the moment of execution
822
+ // "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
823
+ // "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
824
+ // "side": "Ask" // Trade type: `Ask` or `Bid`. Bid for buying base asset, Ask for selling base asset (e.g. for BTC_USDT trading pair, BTC is the base asset).
825
+ // }
826
+ // }
827
+ //
828
+ const data = this.safeValue(response, 'data', {});
829
+ return this.parseTrades(data, market, since, limit);
830
+ }
831
+ parseTrade(trade, market = undefined) {
832
+ //
833
+ // fetchTrades (public)
834
+ //
835
+ // {
836
+ // "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
837
+ // "pair": "BTC_USDT", // Market pair that is being traded
838
+ // "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
839
+ // "matchPrice": "18649", // Exchange price at the moment of execution
840
+ // "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
841
+ // "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
842
+ // "side": "Ask" // Trade type: `Ask` or `Bid`. Bid for buying base asset, Ask for selling base asset (e.g. for BTC_USDT trading pair, BTC is the base asset).
843
+ // }
844
+ //
845
+ // fetchMyTrades, fetchOrder (private)
846
+ //
847
+ // {
848
+ // "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
849
+ // "orderId": "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
850
+ // "pair": "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
851
+ // "quantity": "1.5862", // Traded quantity of base asset
852
+ // "price": "19087", // Price of the trade
853
+ // "isTaker": true, // Various fees for Makers and Takers; "Market" orders are always `true`
854
+ // "fee": "0.0039655", // Exchange commission fee
855
+ // "feeCurrency": "BTC", // Currency of the commission
856
+ // "isBuyer": true, // Buy or sell the base asset
857
+ // "quoteQuantity": "30275.7994", // Quote asset quantity spent to fulfill the base amount
858
+ // "createdAt": "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
859
+ // }
860
+ //
861
+ const datetime = this.safeString(trade, 'createdAt');
862
+ const marketId = this.safeString(trade, 'pair');
863
+ const isTaker = this.safeValue(trade, 'isMaker');
864
+ let side = this.safeStringLower(trade, 'side');
865
+ if (side === undefined) {
866
+ const isBuyer = this.safeValue(trade, 'isBuyer');
867
+ side = isBuyer ? 'buy' : 'sell';
868
+ }
869
+ return this.safeTrade({
870
+ 'info': trade,
871
+ 'id': this.safeString(trade, 'id'),
872
+ 'symbol': this.safeSymbol(marketId, market),
873
+ 'timestamp': this.parse8601(datetime),
874
+ 'datetime': datetime,
875
+ 'type': undefined,
876
+ 'side': side,
877
+ 'order': this.safeString(trade, 'orderId'),
878
+ 'takerOrMaker': isTaker ? 'taker' : 'maker',
879
+ 'price': this.safeString2(trade, 'matchPrice', 'price'),
880
+ 'amount': this.safeString2(trade, 'matchQuantity', 'quantity'),
881
+ 'cost': this.safeString(trade, 'quoteQuantity'),
882
+ 'fee': {
883
+ 'cost': this.safeString(trade, 'fee'),
884
+ 'currency': this.safeCurrencyCode(this.safeString(trade, 'feeCurrency')),
885
+ 'rate': undefined,
886
+ },
887
+ }, market);
888
+ }
889
+ parseBalance(response) {
890
+ //
891
+ // [
892
+ // {
893
+ // "currency": "UAH",
894
+ // "balance": "7134.6",
895
+ // "lockBalance": "100"
896
+ // }
897
+ // ...
898
+ // ]
899
+ //
900
+ const result = { 'info': response };
901
+ for (let i = 0; i < response.length; i++) {
902
+ const balance = response[i];
903
+ const currencyId = this.safeString(balance, 'currency');
904
+ const code = this.safeCurrencyCode(currencyId);
905
+ const account = this.account();
906
+ account['free'] = this.safeString(balance, 'balance');
907
+ account['used'] = this.safeString(balance, 'lockBalance');
908
+ result[code] = account;
909
+ }
910
+ return this.safeBalance(result);
911
+ }
912
+ async fetchBalance(params = {}) {
913
+ /**
914
+ * @method
915
+ * @name kuna#fetchBalance
916
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
917
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
918
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
919
+ */
920
+ await this.loadMarkets();
921
+ const response = await this.v4PrivateGetPrivateGetBalance(params);
922
+ //
923
+ // {
924
+ // "data": [{
925
+ // "currency": "UAH", // Wallet currency
926
+ // "balance": "7134.6", // Available balance, precision depends on the currency
927
+ // "lockBalance": "100" // Minimum amount locked on the balance
928
+ // }]
929
+ // }
930
+ //
931
+ const data = this.safeValue(response, 'data', []);
932
+ return this.parseBalance(data);
933
+ }
934
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
935
+ /**
936
+ * @method
937
+ * @name kuna#createOrder
938
+ * @description create a trade order
939
+ * @see https://docs.kuna.io/docs/create-a-new-order-private
940
+ * @param {string} symbol unified symbol of the market to create an order in
941
+ * @param {string} type 'market' or 'limit'
942
+ * @param {string} side 'buy' or 'sell'
943
+ * @param {float} amount how much of currency you want to trade in units of base currency
944
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
945
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
946
+ * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
947
+ *
948
+ * EXCHANGE SPECIFIC PARAMETERS
949
+ * @param {string} [params.id] id must be a UUID format, if you do not specify id, it will be generated automatically.
950
+ * @param {float} [params.quoteQuantity] the max quantity of the quote asset to use for selling/buying
951
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
952
+ */
953
+ await this.loadMarkets();
954
+ const market = this.market(symbol);
955
+ const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
956
+ params = this.omit(params, ['triggerPrice', 'stopPrice']);
957
+ const capitalizedType = this.capitalize(type);
958
+ const request = {
959
+ 'pair': market['id'],
960
+ 'orderSide': (side === 'buy') ? 'Bid' : 'Ask',
961
+ 'quantity': this.numberToString(amount),
962
+ 'type': capitalizedType,
963
+ };
964
+ if (capitalizedType === 'Limit') {
965
+ request['price'] = this.priceToPrecision(market['symbol'], price);
966
+ }
967
+ if (triggerPrice !== undefined) {
968
+ if (capitalizedType === 'Market') {
969
+ throw new errors.BadRequest(this.id + ' createOrder () cannot place trigger market orders, or trigger limit');
970
+ }
971
+ request['stopPrice'] = this.priceToPrecision(market['symbol'], triggerPrice);
972
+ if (capitalizedType !== 'TakeProfitLimit') {
973
+ request['type'] = 'StopLossLimit';
974
+ }
975
+ }
976
+ const response = await this.v4PrivatePostOrderPrivateCreate(this.extend(request, params));
977
+ //
978
+ // {
979
+ // "data": {
980
+ // "id": "b0fcb54c-2278-4f16-a300-02765faad8b0", // ID of your newly created order
981
+ // "type": "Limit", // Type of an order
982
+ // "quantity": "0.06", // Original order quantity
983
+ // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
984
+ // "pair": "BTC_USDT", // Traded pair
985
+ // "price": "26440.46", // Price of the trade
986
+ // "status": "Open", // The status of the order
987
+ // "createdAt": "2023-07-11T08:01:30.550Z", // Date-time of order creation, UTC
988
+ // "updatedAt": "2023-07-11T08:01:30.550Z" // Date-time of the last update of the order, UTC
989
+ // }
990
+ // }
991
+ //
992
+ const data = this.safeValue(response, 'data', {});
993
+ return this.parseOrder(data, market);
994
+ }
995
+ async cancelOrder(id, symbol = undefined, params = {}) {
996
+ /**
997
+ * @method
998
+ * @name kuna#cancelOrder
999
+ * @description cancels an open order
1000
+ * @param {string} id order id
1001
+ * @param {string} symbol unified market symbol
1002
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1003
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1004
+ */
1005
+ await this.loadMarkets();
1006
+ const request = {
1007
+ 'orderId': id,
1008
+ };
1009
+ const response = await this.v4PrivatePostOrderPrivateCancel(this.extend(request, params));
1010
+ //
1011
+ // {
1012
+ // "data": {
1013
+ // "success": true
1014
+ // }
1015
+ // }
1016
+ //
1017
+ const data = this.safeValue(response, 'data', {});
1018
+ let market = undefined;
1019
+ if (symbol !== undefined) {
1020
+ market = this.market(symbol);
1021
+ }
1022
+ const order = this.parseOrder(data, market);
1023
+ order['id'] = id;
1024
+ return order;
1025
+ }
1026
+ async cancelOrders(ids, symbol = undefined, params = {}) {
1027
+ /**
1028
+ * @method
1029
+ * @name kuna#cancelOrder
1030
+ * @description cancels an open order
1031
+ * @param {string} ids order ids
1032
+ * @param {string} symbol not used by kuna cancelOrder
1033
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1034
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1035
+ */
1036
+ await this.loadMarkets();
1037
+ const request = {
1038
+ 'orderIds': ids,
1039
+ };
1040
+ const response = await this.v4PrivatePostOrderPrivateCancelMulti(this.extend(request, params));
1041
+ //
1042
+ // {
1043
+ // "data": [
1044
+ // {
1045
+ // "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order
1046
+ // "success": true // Status for this order
1047
+ // },
1048
+ // ...
1049
+ // ]
1050
+ // }
1051
+ //
1052
+ const data = this.safeValue(response, 'data', []);
1053
+ return this.parseOrders(data);
1054
+ }
1055
+ parseOrderStatus(status) {
1056
+ const statuses = {
1057
+ 'Canceled': 'canceled',
1058
+ 'Closed': 'filled',
1059
+ 'Pending': 'open',
1060
+ 'Open': 'open',
1061
+ 'done': 'closed',
1062
+ 'wait': 'open',
1063
+ 'cancel': 'canceled',
1064
+ };
1065
+ return this.safeString(statuses, status, status);
1066
+ }
1067
+ parseOrder(order, market = undefined) {
1068
+ //
1069
+ // createOrder, fetchOrder, fetchOpenOrders, fetchOrdersByStatus
1070
+ //
1071
+ // {
1072
+ // "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
1073
+ // "type": "Limit", // Type of an order
1074
+ // "quantity": "5", // Original order quantity
1075
+ // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
1076
+ // "cumulativeQuoteQty": "0", // *absent on createOrder* Traded quantity in money (>0 if traded)
1077
+ // "cost": "0.05", // Total amount
1078
+ // "side": "Bid", // *absent on createOrder* Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
1079
+ // "pair": "TRX_USDT", // Traded pair
1080
+ // "price": "0.01", // Price of the trade
1081
+ // "status": "Open", // The status of the order
1082
+ // "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
1083
+ // "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
1084
+ // "closedAt": "2023-05-08T08:53:58.333Z" // *absent on fetchOpenOrders/createOrder* Date-time of order finish time, UTC
1085
+ // "trades": [ // * fetchOrder only *
1086
+ // {
1087
+ // "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
1088
+ // "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
1089
+ // "pair": "BTC_USDT", // Traded pair
1090
+ // "quantity": "0.00054", // Traded quantity
1091
+ // "price": "27770", // Traded price
1092
+ // "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
1093
+ // "fee": "0.000001350", // Exchange commission fee
1094
+ // "feeCurrency": "BTC", // Currency of the commission
1095
+ // "isBuyer": true, // Buy or sell the base asset
1096
+ // "quoteQuantity": "14.9958", // Quote asset quantity
1097
+ // "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
1098
+ // }
1099
+ // ]
1100
+ // }
1101
+ //
1102
+ // cancelOrder, cancelOrders
1103
+ //
1104
+ // {
1105
+ // "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order *absent on cancelOrder*
1106
+ // "success": true // Status for this order
1107
+ // }
1108
+ //
1109
+ const marketId = this.safeString(order, 'pair');
1110
+ const datetime = this.safeString(order, 'createdAt');
1111
+ const triggerPrice = this.safeString(order, 'stopPrice');
1112
+ let side = this.safeString(order, 'side');
1113
+ if (side === 'Bid') {
1114
+ side = 'buy';
1115
+ }
1116
+ else if (side === 'Ask') {
1117
+ side = 'sell';
1118
+ }
1119
+ const trades = this.safeValue(order, 'trades', []);
1120
+ return this.safeOrder({
1121
+ 'info': order,
1122
+ 'id': this.safeString2(order, 'id', 'orderId'),
1123
+ 'clientOrderId': undefined,
1124
+ 'symbol': this.safeSymbol(marketId, market),
1125
+ 'timestamp': this.parse8601(datetime),
1126
+ 'datetime': datetime,
1127
+ 'lastTradeTimestamp': this.parse8601(this.safeString(order, 'updatedAt')),
1128
+ 'status': this.parseOrderStatus(this.safeString(order, 'status')),
1129
+ 'type': this.safeStringLower(order, 'type'),
1130
+ 'timeInForce': undefined,
1131
+ 'postOnly': undefined,
1132
+ 'side': side,
1133
+ 'price': this.safeString(order, 'price'),
1134
+ 'stopPrice': triggerPrice,
1135
+ 'triggerPrice': triggerPrice,
1136
+ 'amount': this.safeString(order, 'quantity'),
1137
+ 'filled': this.safeString(order, 'executedQuantity'),
1138
+ 'remaining': undefined,
1139
+ 'trades': this.parseTrades(trades),
1140
+ 'cost': this.safeString(order, 'cost'),
1141
+ 'average': undefined,
1142
+ 'fee': undefined,
1143
+ }, market);
1144
+ }
1145
+ async fetchOrder(id, symbol = undefined, params = {}) {
1146
+ /**
1147
+ * @method
1148
+ * @name kuna#fetchOrder
1149
+ * @description fetches information on an order made by the user
1150
+ * @see https://docs.kuna.io/docs/get-order-details-by-id
1151
+ * @param {string} symbol not used by kuna fetchOrder
1152
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1153
+ *
1154
+ * EXCHANGE SPECIFIC PARAMETERS
1155
+ * @param {boolean} [params.withTrades] default == true, specify if the response should include trades associated with the order
1156
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1157
+ */
1158
+ await this.loadMarkets();
1159
+ const request = {
1160
+ 'id': id,
1161
+ 'withTrades': true,
1162
+ };
1163
+ const response = await this.v4PrivateGetOrderPrivateDetailsId(this.extend(request, params));
1164
+ //
1165
+ // {
1166
+ // "data": {
1167
+ // "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3",
1168
+ // "type": "Limit",
1169
+ // "quantity": "0.00054",
1170
+ // "executedQuantity": "0.00054",
1171
+ // "cumulativeQuoteQty": "14.99580",
1172
+ // "cost": "14.9958",
1173
+ // "side": "Bid",
1174
+ // "pair": "BTC_USDT",
1175
+ // "price": "27770",
1176
+ // "status": "Closed",
1177
+ // "createdAt": "2023-05-08T08:39:46.708Z",
1178
+ // "updatedAt": "2023-05-08T08:53:58.332Z",
1179
+ // "closedAt": "2023-05-08T08:53:58.333Z",
1180
+ // "trades": [
1181
+ // {
1182
+ // "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
1183
+ // "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
1184
+ // "pair": "BTC_USDT", // Traded pair
1185
+ // "quantity": "0.00054", // Traded quantity
1186
+ // "price": "27770", // Traded price
1187
+ // "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
1188
+ // "fee": "0.000001350", // Exchange commission fee
1189
+ // "feeCurrency": "BTC", // Currency of the commission
1190
+ // "isBuyer": true, // Buy or sell the base asset
1191
+ // "quoteQuantity": "14.9958", // Quote asset quantity
1192
+ // "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
1193
+ // }
1194
+ // ]
1195
+ // }
1196
+ // }
1197
+ //
1198
+ const data = this.safeValue(response, 'data', {});
1199
+ return this.parseOrder(data);
1200
+ }
1201
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1202
+ /**
1203
+ * @method
1204
+ * @name kuna#fetchOpenOrders
1205
+ * @description fetch all unfilled currently open orders
1206
+ * @see https://docs.kuna.io/docs/get-active-client-orders-private
1207
+ * @param {string} symbol unified market symbol
1208
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1209
+ * @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
1210
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1211
+ * @param {int} [params.until] the latest timestamp (ms) to fetch orders for
1212
+ *
1213
+ * EXCHANGE SPECIFIC PARAMETERS
1214
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1215
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1216
+ */
1217
+ await this.loadMarkets();
1218
+ const until = this.safeInteger(params, 'until');
1219
+ params = this.omit(params, ['until']);
1220
+ let market = undefined;
1221
+ const request = {};
1222
+ if (symbol !== undefined) {
1223
+ market = this.market(symbol);
1224
+ request['pairs'] = market['id'];
1225
+ }
1226
+ if (since !== undefined) {
1227
+ request['start'] = this.iso8601(since);
1228
+ }
1229
+ if (limit !== undefined) {
1230
+ request['limit'] = limit;
1231
+ }
1232
+ if (until !== undefined) {
1233
+ request['end'] = this.iso8601(until);
1234
+ }
1235
+ const response = await this.v4PrivateGetOrderPrivateActive(this.extend(request, params));
1236
+ //
1237
+ // {
1238
+ // "data": [
1239
+ // {
1240
+ // "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
1241
+ // "type": "Limit", // Type of an order
1242
+ // "quantity": "5", // Original order quantity
1243
+ // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
1244
+ // "cumulativeQuoteQty": "0", // Traded quantity in money (>0 if traded)
1245
+ // "cost": "0.05", // Total amount
1246
+ // "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
1247
+ // "pair": "TRX_USDT", // Traded pair
1248
+ // "price": "0.01", // Price of the trade
1249
+ // "status": "Open", // The status of the order
1250
+ // "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
1251
+ // "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
1252
+ // }
1253
+ // ...
1254
+ // ]
1255
+ // }
1256
+ //
1257
+ const data = this.safeValue(response, 'data', []);
1258
+ return this.parseOrders(data, market, since, limit);
1259
+ }
1260
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1261
+ /**
1262
+ * @method
1263
+ * @name kuna#fetchClosedOrders
1264
+ * @description fetches information on multiple closed orders made by the user
1265
+ * @see https://docs.kuna.io/docs/get-private-orders-history
1266
+ * @param {string} symbol unified market symbol of the market orders were made in
1267
+ * @param {int} [since] the earliest time in ms to fetch orders for
1268
+ * @param {int} [limit] the maximum number of order structures to retrieve
1269
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1270
+ * @param {int} [params.until] the latest time in ms to fetch orders for
1271
+ *
1272
+ * EXCHANGE SPECIFIC PARAMETERS
1273
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1274
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1275
+ */
1276
+ return await this.fetchOrdersByStatus('closed', symbol, since, limit, params);
1277
+ }
1278
+ async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1279
+ /**
1280
+ * @method
1281
+ * @name kuna#fetchOrdersByStatus
1282
+ * @description fetch a list of orders
1283
+ * @see https://docs.kuna.io/docs/get-private-orders-history
1284
+ * @param {string} status canceled, closed, expired, open, pending, rejected, or waitStop
1285
+ * @param {string} symbol unified market symbol of the market orders were made in
1286
+ * @param {int} [since] the earliest time in ms to fetch orders for
1287
+ * @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
1288
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1289
+ * @param {int} [params.until] the latest timestamp (ms) to fetch orders for
1290
+ *
1291
+ * EXCHANGE SPECIFIC PARAMETERS
1292
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1293
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1294
+ */
1295
+ await this.loadMarkets();
1296
+ if (status === 'open') {
1297
+ return this.fetchOpenOrders(symbol, since, limit, params);
1298
+ }
1299
+ const until = this.safeInteger(params, 'until');
1300
+ params = this.omit(params, ['until']);
1301
+ let market = undefined;
1302
+ const request = {
1303
+ 'status': this.capitalize(status),
1304
+ };
1305
+ if (symbol !== undefined) {
1306
+ market = this.market(symbol);
1307
+ request['pairs'] = market['id'];
1308
+ }
1309
+ if (since !== undefined) {
1310
+ request['start'] = this.iso8601(since);
1311
+ }
1312
+ if (limit !== undefined) {
1313
+ request['limit'] = limit;
1314
+ }
1315
+ if (until !== undefined) {
1316
+ request['end'] = this.iso8601(until);
1317
+ }
1318
+ const response = await this.v4PrivateGetOrderPrivateHistory(request);
1319
+ //
1320
+ // {
1321
+ // "data": [
1322
+ // {
1323
+ // "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an order
1324
+ // "type": "Limit", // Type of an order
1325
+ // "quantity": "0.00054", // Original order quantity
1326
+ // "executedQuantity": "0.00054", // Traded quantity in stock (>0 if traded)
1327
+ // "cumulativeQuoteQty": "14.99580", // Traded quantity in money (>0 if traded)
1328
+ // "cost": "14.9958", // Total amount
1329
+ // "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
1330
+ // "pair": "BTC_USDT", // Traded pair
1331
+ // "price": "27770", // Price of the trade
1332
+ // "status": "Closed", // The status of the order
1333
+ // "createdAt": "2023-05-08T08:39:46.708Z", // Date-time of order creation, UTC
1334
+ // "updatedAt": "2023-05-08T08:53:58.332Z", // Date-time of the last update of the order, UTC
1335
+ // "closedAt": "2023-05-08T08:53:58.333Z" // Date-time of order finish time, UTC
1336
+ // },
1337
+ // ...
1338
+ // ]
1339
+ // }
1340
+ //
1341
+ const data = this.safeValue(response, 'data', []);
1342
+ return this.parseOrders(data, market, since, limit);
1343
+ }
1344
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1345
+ /**
1346
+ * @method
1347
+ * @name kuna#fetchMyTrades
1348
+ * @description fetch all trades made by the user
1349
+ * @see https://docs.kuna.io/docs/get-private-trades-history
1350
+ * @param {string} symbol unified market symbol
1351
+ * @param {int} [since] not used by kuna fetchMyTrades
1352
+ * @param {int} [limit] not used by kuna fetchMyTrades
1353
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1354
+ *
1355
+ * EXCHANGE SPECIFIC PARAMETERS
1356
+ * @param {string} [params.orderId] UUID of an order, to receive trades for this order only
1357
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
1358
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1359
+ */
1360
+ await this.loadMarkets();
1361
+ let market = undefined;
1362
+ const request = {};
1363
+ if (symbol !== undefined) {
1364
+ market = this.market(symbol);
1365
+ request['pair'] = market['id'];
1366
+ }
1367
+ const response = await this.v4PrivateGetTradePrivateHistory(this.extend(request, params));
1368
+ //
1369
+ // {
1370
+ // "data": [
1371
+ // {
1372
+ // "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
1373
+ // "orderId": "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
1374
+ // "pair": "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
1375
+ // "quantity": "1.5862", // Traded quantity of base asset
1376
+ // "price": "19087", // Price of the trade
1377
+ // "isTaker": true, // Various fees for Makers and Takers; "Market" orders are always `true`
1378
+ // "fee": "0.0039655", // Exchange commission fee
1379
+ // "feeCurrency": "BTC", // Currency of the commission
1380
+ // "isBuyer": true, // Buy or sell the base asset
1381
+ // "quoteQuantity": "30275.7994", // Quote asset quantity spent to fulfill the base amount
1382
+ // "createdAt": "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
1383
+ // },
1384
+ // ]
1385
+ // }
1386
+ //
1387
+ const data = this.safeValue(response, 'data');
1388
+ return this.parseTrades(data, market, since, limit);
1389
+ }
1390
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
1391
+ /**
1392
+ * @method
1393
+ * @name kuna#withdraw
1394
+ * @description make a withdrawal
1395
+ * @see https://docs.kuna.io/docs/create-a-withdraw
1396
+ * @param {string} code unified currency code
1397
+ * @param {float} amount the amount to withdraw
1398
+ * @param {string} address the address to withdraw to
1399
+ * @param {string} tag
1400
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1401
+ * @param {string} [params.chain] the chain to withdraw to
1402
+ *
1403
+ * EXCHANGE SPECIFIC PARAMETERS
1404
+ * @param {string} [params.id] id must be a uuid format, if you do not specify id, it will be generated automatically
1405
+ * @param {boolean} [params.withdrawAll] this field says that the amount should also include a fee
1406
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1407
+ */
1408
+ this.checkAddress(address);
1409
+ let chain = this.safeString2(params, 'chain', 'network');
1410
+ params = this.omit(params, ['chain', 'network']);
1411
+ await this.loadMarkets();
1412
+ const currency = this.currency(code);
1413
+ if (chain === undefined) {
1414
+ if (currency['code'].indexOf('USD') > 0) {
1415
+ throw new errors.ArgumentsRequired(this.id + ' withdraw () requires an extra parameter params["network"] to withdraw ' + currency['code']);
1416
+ }
1417
+ else {
1418
+ chain = currency['id'].toUpperCase();
1419
+ }
1420
+ }
1421
+ const networkId = this.networkCodeToId(chain);
1422
+ const request = {
1423
+ 'currency': networkId,
1424
+ 'amount': amount,
1425
+ 'address': address,
1426
+ 'paymentMethod': chain, // TODO: double check, Withdraw method for currency, should be taken from "Get info about withdrawal methods by currency name" endpoint (key field).
1427
+ };
1428
+ if (tag !== undefined) {
1429
+ request['paymentId'] = tag;
1430
+ }
1431
+ const response = await this.v4PrivatePostWithdrawPrivateCreate(this.extend(request, params));
1432
+ //
1433
+ // {
1434
+ // "data": {
1435
+ // "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // unique identifier of a withdraw
1436
+ // "status": "waitingForConfirmation" // status of a withdraw, if you turn off withdrawal confirmation by email, it will return "processing" status, which means that the transaction is already being processed on our side
1437
+ // }
1438
+ // }
1439
+ //
1440
+ const data = this.safeValue(response, 'data', {});
1441
+ return this.parseTransaction(data, currency);
1442
+ }
1443
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1444
+ /**
1445
+ * @method
1446
+ * @name kuna#fetchWithdrawals
1447
+ * @description fetch all withdrawals made to an account
1448
+ * @see https://docs.kuna.io/docs/get-withdraw-history
1449
+ * @param {string} code unified currency code
1450
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
1451
+ * @param {int} [limit] the maximum number of withdrawals structures to retrieve
1452
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1453
+ * @param {int} [params.until] the latest time in ms to fetch deposits for
1454
+ *
1455
+ * EXCHANGE SPECIFIC PARAMETERS
1456
+ * @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
1457
+ * @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
1458
+ * @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
1459
+ * @param {int} [params.skip] 0 - ... Select the number of transactions to skip
1460
+ * @param {string} [params.address]
1461
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1462
+ */
1463
+ await this.loadMarkets();
1464
+ const until = this.safeInteger(params, 'until');
1465
+ params = this.omit(params, 'until');
1466
+ let currency = undefined;
1467
+ if (code !== undefined) {
1468
+ currency = this.currency(code);
1469
+ }
1470
+ const request = {};
1471
+ if (code !== undefined) {
1472
+ request['currency'] = code;
1473
+ }
1474
+ if (since !== undefined) {
1475
+ request['dateFrom'] = this.iso8601(since);
1476
+ }
1477
+ if (limit !== undefined) {
1478
+ request['take'] = limit;
1479
+ }
1480
+ if (until !== undefined) {
1481
+ request['dateTo'] = this.iso8601(until);
1482
+ }
1483
+ const response = await this.v4PrivateGetWithdrawPrivateHistory(this.extend(request, params));
1484
+ //
1485
+ // {
1486
+ // "data": [
1487
+ // {
1488
+ // "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
1489
+ // "amount": "10.75", // Amount deducted from your account
1490
+ // "asset": "USDT", // Withdrawal currency
1491
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1492
+ // "paymentCode": "TRX", // Blockchain name
1493
+ // "status": "Processed", // Withdrawal status
1494
+ // "type": "Withdraw", // Transaction type
1495
+ // "reason": [], // Reason for manual transaction processing
1496
+ // "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
1497
+ // "memo": "", // Withdrawal memo
1498
+ // "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
1499
+ // "fee": "0.75", // Withdrawal fee
1500
+ // "processedAmount": "10", // Withdrawal amount
1501
+ // "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
1502
+ // "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
1503
+ // },
1504
+ // ...
1505
+ // ]
1506
+ // }
1507
+ //
1508
+ const data = this.safeValue(response, 'data', []);
1509
+ return this.parseTransactions(data, currency);
1510
+ }
1511
+ async fetchWithdrawal(id, code = undefined, params = {}) {
1512
+ /**
1513
+ * @method
1514
+ * @name kuna#fetchWithdrawal
1515
+ * @description fetch data on a currency withdrawal via the withdrawal id
1516
+ * @see https://docs.kuna.io/docs/get-withdraw-details-by-id
1517
+ * @param {string} id withdrawal id
1518
+ * @param {string} code not used by kuna.fetchWithdrawal
1519
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1520
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1521
+ */
1522
+ await this.loadMarkets();
1523
+ const request = {
1524
+ 'withdrawId': id,
1525
+ };
1526
+ const response = await this.v4PrivateGetWithdrawPrivateDetailsWithdrawId(this.extend(request, params));
1527
+ //
1528
+ // {
1529
+ // "data": {
1530
+ // "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
1531
+ // "amount": "10.75", // Amount deducted from your account
1532
+ // "asset": "USDT", // Withdrawal currency
1533
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1534
+ // "paymentCode": "TRX", // Blockchain name
1535
+ // "status": "Processed", // Withdrawal status
1536
+ // "type": "Withdraw", // Transaction type
1537
+ // "reason": [], // Reason for manual transaction processing
1538
+ // "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
1539
+ // "memo": "", // Withdrawal memo
1540
+ // "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
1541
+ // "fee": "0.75", // Withdrawal fee
1542
+ // "processedAmount": "10", // Withdrawal amount
1543
+ // "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
1544
+ // "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
1545
+ // }
1546
+ // }
1547
+ //
1548
+ const data = this.safeValue(response, 'data', {});
1549
+ return this.parseTransaction(data);
1550
+ }
1551
+ async createDepositAddress(code, params = {}) {
1552
+ /**
1553
+ * @method
1554
+ * @name kuna#createDepositAddress
1555
+ * @description create a currency deposit address
1556
+ * @see https://docs.kuna.io/docs/generate-a-constant-crypto-address-for-deposit
1557
+ * @param {string} code unified currency code of the currency for the deposit address
1558
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1559
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1560
+ */
1561
+ await this.loadMarkets();
1562
+ const currency = this.currency(code);
1563
+ const request = {
1564
+ 'source': currency['id'],
1565
+ };
1566
+ const response = await this.v4PrivatePostDepositPrivateCryptoGenerateAddress(this.extend(request, params));
1567
+ //
1568
+ // {
1569
+ // "data": {
1570
+ // "id": "1300c2b6-ree4-4f1e-2a9d-e0f7ed0991a7", // ID of your address
1571
+ // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account
1572
+ // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
1573
+ // }
1574
+ // }
1575
+ //
1576
+ const data = this.safeValue(response, 'data', {});
1577
+ return this.parseDepositAddress(data, currency);
1578
+ }
1579
+ async fetchDepositAddress(code, params = {}) {
1580
+ /**
1581
+ * @method
1582
+ * @name kuna#fetchDepositAddress
1583
+ * @description fetch the deposit address for a currency associated with this account
1584
+ * @see https://docs.kuna.io/docs/find-crypto-address-for-deposit
1585
+ * @param {string} code unified currency code
1586
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1587
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1588
+ */
1589
+ await this.loadMarkets();
1590
+ const currency = this.currency(code);
1591
+ const request = {
1592
+ 'source': currency['id'].toUpperCase(),
1593
+ };
1594
+ const response = await this.v4PrivateGetDepositPrivateCryptoAddress(this.extend(request, params));
1595
+ //
1596
+ // {
1597
+ // "data": {
1598
+ // "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
1599
+ // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
1600
+ // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
1601
+ // }
1602
+ // }
1603
+ //
1604
+ const data = this.safeValue(response, 'data', {});
1605
+ return this.parseDepositAddress(data, currency);
1606
+ }
1607
+ parseDepositAddress(depositAddress, currency = undefined) {
1608
+ //
1609
+ // {
1610
+ // "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
1611
+ // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
1612
+ // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
1613
+ // }
1614
+ //
1615
+ const currencyId = this.safeString(depositAddress, 'source');
1616
+ return {
1617
+ 'info': this.safeString(depositAddress, ''),
1618
+ 'currency': this.safeCurrencyCode(currencyId, currency),
1619
+ 'network': undefined,
1620
+ 'address': this.safeString(depositAddress, 'address'),
1621
+ 'tag': undefined,
1622
+ };
1623
+ }
1624
+ parseTransactionStatus(status) {
1625
+ const statuses = {
1626
+ 'Created': 'pending',
1627
+ 'Canceled': 'canceled',
1628
+ 'PartiallyProcessed': 'pending',
1629
+ 'Processing': 'pending',
1630
+ 'Processed': 'ok',
1631
+ 'WaitForConfirmation': 'pending',
1632
+ 'Pending': 'pending',
1633
+ 'AmlChecking': 'pending',
1634
+ };
1635
+ return this.safeString(statuses, status, status);
1636
+ }
1637
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1638
+ /**
1639
+ * @method
1640
+ * @name kuna#fetchDeposits
1641
+ * @description fetch all deposits made to an account
1642
+ * @see https://docs.kuna.io/docs/get-deposit-history
1643
+ * @param {string} code unified currency code
1644
+ * @param {int} [since] the earliest time in ms to fetch deposits for
1645
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
1646
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1647
+ * @param {int} [params.until] the latest time in ms to fetch deposits for
1648
+ *
1649
+ * EXCHANGE SPECIFIC PARAMETERS
1650
+ * @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
1651
+ * @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
1652
+ * @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
1653
+ * @param {int} [params.skip] 0 - ... Select the number of transactions to skip
1654
+ * @param {string} [params.address]
1655
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1656
+ */
1657
+ await this.loadMarkets();
1658
+ const until = this.safeInteger(params, 'until');
1659
+ params = this.omit(params, 'until');
1660
+ let currency = undefined;
1661
+ if (code !== undefined) {
1662
+ currency = this.currency(code);
1663
+ }
1664
+ const request = {};
1665
+ if (code !== undefined) {
1666
+ request['currency'] = code;
1667
+ }
1668
+ if (since !== undefined) {
1669
+ request['dateFrom'] = this.iso8601(since);
1670
+ }
1671
+ if (limit !== undefined) {
1672
+ request['take'] = limit;
1673
+ }
1674
+ if (until !== undefined) {
1675
+ request['dateTo'] = this.iso8601(until);
1676
+ }
1677
+ const response = await this.v4PrivateGetDepositPrivateHistory(this.extend(request, params));
1678
+ //
1679
+ // {
1680
+ // "data": [
1681
+ // {
1682
+ // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
1683
+ // "amount": "9.9", // Amount credited to your account
1684
+ // "asset": "USDT", // Deposit currency
1685
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1686
+ // "paymentCode": "TRX", // Blockchain name
1687
+ // "status": "Processed", // Transactions status
1688
+ // "type": "Deposit", // Transaction type
1689
+ // "reason": [], // Reason for manual transaction processing
1690
+ // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
1691
+ // "memo": "", // Deposit memo
1692
+ // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
1693
+ // "fee": "0.1", // Deposit fee
1694
+ // "processedAmount": "10", // Amount of deposit
1695
+ // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
1696
+ // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
1697
+ // },
1698
+ // ...
1699
+ // ]
1700
+ // }
1701
+ //
1702
+ const data = this.safeValue(response, 'data', []);
1703
+ return this.parseTransactions(data, currency);
1704
+ }
1705
+ async fetchDeposit(id, code = undefined, params = {}) {
1706
+ /**
1707
+ * @method
1708
+ * @name kuna#fetchDeposit
1709
+ * @description fetch data on a currency deposit via the deposit id
1710
+ * @see https://docs.kuna.io/docs/get-deposit-details-by-id
1711
+ * @param {string} id deposit id
1712
+ * @param {string} code filter by currency code
1713
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1714
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1715
+ */
1716
+ await this.loadMarkets();
1717
+ let currency = undefined;
1718
+ if (code !== undefined) {
1719
+ currency = this.currency(code);
1720
+ }
1721
+ const request = {
1722
+ 'depositId': id,
1723
+ };
1724
+ const response = await this.v4PrivateGetDepositPrivateDetailsDepositId(this.extend(request, params));
1725
+ //
1726
+ // {
1727
+ // "data": {
1728
+ // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
1729
+ // "amount": "9.9", // Amount credited to your account
1730
+ // "asset": "USDT", // Deposit currency
1731
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1732
+ // "paymentCode": "TRX", // Blockchain name
1733
+ // "status": "Processed", // Transactions status
1734
+ // "type": "Deposit", // Transaction type
1735
+ // "reason": [], // Reason for manual transaction processing
1736
+ // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
1737
+ // "memo": "", // Deposit memo
1738
+ // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
1739
+ // "fee": "0.1", // Deposit fee
1740
+ // "processedAmount": "10", // Amount of deposit
1741
+ // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
1742
+ // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
1743
+ // }
1744
+ // }
1745
+ //
1746
+ const data = this.safeValue(response, 'data', {});
1747
+ return this.parseTransaction(data, currency);
1748
+ }
1749
+ parseTransaction(transaction, currency = undefined) {
1750
+ //
1751
+ // {
1752
+ // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
1753
+ // "amount": "9.9", // Amount credited to your account
1754
+ // "asset": "USDT", // Deposit currency
1755
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
1756
+ // "paymentCode": "TRX", // Blockchain name
1757
+ // "status": "Processed", // Transactions status
1758
+ // "type": "Deposit", // Transaction type
1759
+ // "reason": [], // Reason for manual transaction processing
1760
+ // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
1761
+ // "memo": "", // Deposit memo
1762
+ // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
1763
+ // "fee": "0.1", // Deposit fee
1764
+ // "processedAmount": "10", // Amount of deposit
1765
+ // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
1766
+ // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
1767
+ // }
1768
+ //
1769
+ const datetime = this.safeString(transaction, 'createdAt');
1770
+ const currencyId = this.safeString(transaction, 'asset');
1771
+ const code = this.safeCurrencyCode(currencyId, currency);
1772
+ const networkId = this.safeString(transaction, 'paymentCode');
1773
+ const type = this.safeStringLower(transaction, 'type');
1774
+ const address = this.safeString(transaction, 'address');
1775
+ const isDeposit = (type === 'deposit');
1776
+ const parsedType = isDeposit ? type : 'withdrawal';
1777
+ return {
1778
+ 'info': transaction,
1779
+ 'id': this.safeString(transaction, 'id'),
1780
+ 'txid': this.safeString(transaction, 'txId'),
1781
+ 'currency': code,
1782
+ 'timestamp': this.parse8601(datetime),
1783
+ 'datetime': datetime,
1784
+ 'network': this.networkIdToCode(networkId),
1785
+ 'addressFrom': undefined,
1786
+ 'address': address,
1787
+ 'addressTo': address,
1788
+ 'amount': this.safeNumber(transaction, 'amount'),
1789
+ 'type': parsedType,
1790
+ 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
1791
+ 'updated': this.parse8601(this.safeString(transaction, 'updatedAt')),
1792
+ 'tagFrom': undefined,
1793
+ 'tag': undefined,
1794
+ 'tagTo': undefined,
1795
+ 'comment': this.safeString(transaction, 'memo'),
1796
+ 'internal': undefined,
1797
+ 'fee': {
1798
+ 'cost': this.safeNumber(transaction, 'fee'),
1799
+ 'currency': code,
1800
+ },
1801
+ };
1802
+ }
1803
+ nonce() {
1804
+ return this.milliseconds();
1805
+ }
1806
+ encodeParams(params) {
1807
+ if ('orders' in params) {
1808
+ const orders = params['orders'];
1809
+ let query = this.urlencode(this.keysort(this.omit(params, 'orders')));
1810
+ for (let i = 0; i < orders.length; i++) {
1811
+ const order = orders[i];
1812
+ const keys = Object.keys(order);
1813
+ for (let k = 0; k < keys.length; k++) {
1814
+ const key = keys[k];
1815
+ const value = order[key];
1816
+ query += '&orders%5B%5D%5B' + key + '%5D=' + value.toString();
1817
+ }
1818
+ }
1819
+ return query;
1820
+ }
1821
+ return this.urlencode(this.keysort(params));
1822
+ }
1823
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1824
+ let url = undefined;
1825
+ if (Array.isArray(api)) {
1826
+ const isGet = method === 'GET';
1827
+ const version = this.safeString(api, 0);
1828
+ const access = this.safeString(api, 1);
1829
+ if (version === 'v3') {
1830
+ url = this.urls['api'][version] + '/' + version + '/' + this.implodeParams(path, params);
1831
+ if (access === 'public') {
1832
+ if (isGet) {
1833
+ if (Object.keys(params).length) {
1834
+ url += '?' + this.urlencode(params);
1835
+ }
1836
+ }
1837
+ else if ((method === 'POST') || (method === 'PUT')) {
1838
+ headers = { 'Content-Type': 'application/json' };
1839
+ body = this.json(params);
1840
+ }
1841
+ }
1842
+ else if (access === 'private') {
1843
+ throw new errors.NotSupported(this.id + ' private v3 API is not supported yet');
1844
+ }
1845
+ }
1846
+ else if (version === 'v4') {
1847
+ const extractedParams = this.extractParams(path);
1848
+ let urlPath = '/' + version + '/' + this.implodeParams(path, params);
1849
+ params = this.omit(params, extractedParams);
1850
+ if (isGet) {
1851
+ const paramsList = Object.keys(params);
1852
+ const numParams = paramsList.length;
1853
+ if (numParams > 0) {
1854
+ urlPath += '?' + this.urlencode(params);
1855
+ }
1856
+ }
1857
+ if (access === 'private') {
1858
+ const nonce = this.nonce().toString();
1859
+ let auth = urlPath + nonce;
1860
+ if (isGet) {
1861
+ auth = auth + this.json({});
1862
+ }
1863
+ else {
1864
+ auth = auth + this.json(params);
1865
+ body = params;
1866
+ }
1867
+ headers = {
1868
+ 'Content-Type': 'application/json',
1869
+ 'accept': 'application/json',
1870
+ 'nonce': nonce,
1871
+ 'public-key': this.apiKey,
1872
+ 'signature': this.hmac(this.encode(auth), this.encode(this.secret), sha512.sha384, 'hex'),
1873
+ };
1874
+ const account = this.safeString(this.options, 'account');
1875
+ if (account === 'pro') {
1876
+ headers['account'] = 'pro';
1877
+ }
1878
+ }
1879
+ url = this.urls['api'][version] + urlPath;
1880
+ }
1881
+ }
1882
+ else {
1883
+ let request = '/api/' + this.version + '/' + this.implodeParams(path, params);
1884
+ if ('extension' in this.urls) {
1885
+ request += this.urls['extension'];
1886
+ }
1887
+ const query = this.omit(params, this.extractParams(path));
1888
+ url = this.urls['api'][api] + request;
1889
+ if (api === 'public') {
1890
+ if (Object.keys(query).length) {
1891
+ url += '?' + this.urlencode(query);
1892
+ }
1893
+ }
1894
+ else {
1895
+ this.checkRequiredCredentials();
1896
+ const nonce = this.nonce().toString();
1897
+ const queryInner = this.encodeParams(this.extend({
1898
+ 'access_key': this.apiKey,
1899
+ 'tonce': nonce,
1900
+ }, params));
1901
+ const auth = method + '|' + request + '|' + queryInner;
1902
+ const signed = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
1903
+ const suffix = query + '&signature=' + signed;
1904
+ if (method === 'GET') {
1905
+ url += '?' + suffix;
1906
+ }
1907
+ else {
1908
+ body = suffix;
1909
+ headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
1910
+ }
1911
+ }
1912
+ }
1913
+ if (body !== undefined) {
1914
+ body = JSON.stringify(body);
1915
+ }
1916
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1917
+ }
1918
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1919
+ //
1920
+ // {
1921
+ // "errors": [
1922
+ // {
1923
+ // "extensions": {
1924
+ // "code": "IP_NOT_IN_WHITE_LIST"
1925
+ // },
1926
+ // "code": "IP_NOT_IN_WHITE_LIST"
1927
+ // }
1928
+ // ]
1929
+ // }
1930
+ //
1931
+ const errors$1 = this.safeValue(response, 'errors');
1932
+ if ((response === undefined) && (errors$1 === undefined)) {
1933
+ return undefined;
1934
+ }
1935
+ if ((errors$1 !== undefined) || (code === 400)) {
1936
+ let error = this.safeValue(errors$1, 0);
1937
+ if (error === undefined) {
1938
+ error = this.safeValue(response, 'error');
1939
+ }
1940
+ const errorCode = this.safeString(error, 'code');
1941
+ const feedback = this.id + ' ' + this.json(response);
1942
+ this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
1943
+ throw new errors.ExchangeError(feedback);
1944
+ }
1945
+ return undefined;
1946
+ }
1947
+ }
1948
+
1949
+ module.exports = kuna;