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,1883 @@
1
+ 'use strict';
2
+
3
+ var zonda$1 = require('./abstract/zonda.js');
4
+ var errors = require('./base/errors.js');
5
+ var number = require('./base/functions/number.js');
6
+ var Precise = require('./base/Precise.js');
7
+ var sha512 = require('./static_dependencies/noble-hashes/sha512.js');
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // ---------------------------------------------------------------------------
11
+ /**
12
+ * @class zonda
13
+ * @augments Exchange
14
+ */
15
+ class zonda extends zonda$1 {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'zonda',
19
+ 'name': 'Zonda',
20
+ 'countries': ['EE'],
21
+ 'rateLimit': 1000,
22
+ 'has': {
23
+ 'CORS': true,
24
+ 'spot': true,
25
+ 'margin': false,
26
+ 'swap': false,
27
+ 'future': false,
28
+ 'option': false,
29
+ 'addMargin': false,
30
+ 'cancelAllOrders': false,
31
+ 'cancelOrder': true,
32
+ 'cancelOrders': false,
33
+ 'closeAllPositions': false,
34
+ 'closePosition': false,
35
+ 'createDepositAddress': false,
36
+ 'createOrder': true,
37
+ 'createReduceOnlyOrder': false,
38
+ 'fetchBalance': true,
39
+ 'fetchBorrowRateHistories': false,
40
+ 'fetchBorrowRateHistory': false,
41
+ 'fetchCrossBorrowRate': false,
42
+ 'fetchCrossBorrowRates': false,
43
+ 'fetchDeposit': false,
44
+ 'fetchDepositAddress': true,
45
+ 'fetchDepositAddresses': true,
46
+ 'fetchDeposits': undefined,
47
+ 'fetchFundingHistory': false,
48
+ 'fetchFundingRate': false,
49
+ 'fetchFundingRateHistory': false,
50
+ 'fetchFundingRates': false,
51
+ 'fetchIndexOHLCV': false,
52
+ 'fetchIsolatedBorrowRate': false,
53
+ 'fetchIsolatedBorrowRates': false,
54
+ 'fetchLedger': true,
55
+ 'fetchLeverage': false,
56
+ 'fetchLeverageTiers': false,
57
+ 'fetchMarginMode': false,
58
+ 'fetchMarkets': true,
59
+ 'fetchMarkOHLCV': false,
60
+ 'fetchMyTrades': true,
61
+ 'fetchOHLCV': true,
62
+ 'fetchOpenInterestHistory': false,
63
+ 'fetchOpenOrder': false,
64
+ 'fetchOpenOrders': true,
65
+ 'fetchOrderBook': true,
66
+ 'fetchOrderBooks': false,
67
+ 'fetchPosition': false,
68
+ 'fetchPositionMode': false,
69
+ 'fetchPositions': false,
70
+ 'fetchPositionsRisk': false,
71
+ 'fetchPremiumIndexOHLCV': false,
72
+ 'fetchTicker': true,
73
+ 'fetchTickers': true,
74
+ 'fetchTime': false,
75
+ 'fetchTrades': true,
76
+ 'fetchTradingFee': false,
77
+ 'fetchTradingFees': false,
78
+ 'fetchTransactionFee': false,
79
+ 'fetchTransactionFees': false,
80
+ 'fetchTransactions': undefined,
81
+ 'fetchTransfer': false,
82
+ 'fetchWithdrawal': false,
83
+ 'fetchWithdrawals': undefined,
84
+ 'reduceMargin': false,
85
+ 'setLeverage': false,
86
+ 'setMargin': false,
87
+ 'setMarginMode': false,
88
+ 'setPositionMode': false,
89
+ 'transfer': true,
90
+ 'withdraw': true,
91
+ },
92
+ 'timeframes': {
93
+ '1m': '60',
94
+ '3m': '180',
95
+ '5m': '300',
96
+ '15m': '900',
97
+ '30m': '1800',
98
+ '1h': '3600',
99
+ '2h': '7200',
100
+ '4h': '14400',
101
+ '6h': '21600',
102
+ '12h': '43200',
103
+ '1d': '86400',
104
+ '3d': '259200',
105
+ '1w': '604800',
106
+ },
107
+ 'hostname': 'zondacrypto.exchange',
108
+ 'urls': {
109
+ 'referral': 'https://auth.zondaglobal.com/ref/jHlbB4mIkdS1',
110
+ 'logo': 'https://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpg',
111
+ 'www': 'https://zondaglobal.com',
112
+ 'api': {
113
+ 'public': 'https://{hostname}/API/Public',
114
+ 'private': 'https://{hostname}/API/Trading/tradingApi.php',
115
+ 'v1_01Public': 'https://api.{hostname}/rest',
116
+ 'v1_01Private': 'https://api.{hostname}/rest',
117
+ },
118
+ 'doc': [
119
+ 'https://docs.zondacrypto.exchange/',
120
+ 'https://github.com/BitBayNet/API',
121
+ ],
122
+ 'support': 'https://zondaglobal.com/en/helpdesk/zonda-exchange',
123
+ 'fees': 'https://zondaglobal.com/legal/zonda-exchange/fees',
124
+ },
125
+ 'api': {
126
+ 'public': {
127
+ 'get': [
128
+ '{id}/all',
129
+ '{id}/market',
130
+ '{id}/orderbook',
131
+ '{id}/ticker',
132
+ '{id}/trades',
133
+ ],
134
+ },
135
+ 'private': {
136
+ 'post': [
137
+ 'info',
138
+ 'trade',
139
+ 'cancel',
140
+ 'orderbook',
141
+ 'orders',
142
+ 'transfer',
143
+ 'withdraw',
144
+ 'history',
145
+ 'transactions',
146
+ ],
147
+ },
148
+ 'v1_01Public': {
149
+ 'get': [
150
+ 'trading/ticker',
151
+ 'trading/ticker/{symbol}',
152
+ 'trading/stats',
153
+ 'trading/stats/{symbol}',
154
+ 'trading/orderbook/{symbol}',
155
+ 'trading/transactions/{symbol}',
156
+ 'trading/candle/history/{symbol}/{resolution}',
157
+ ],
158
+ },
159
+ 'v1_01Private': {
160
+ 'get': [
161
+ 'api_payments/deposits/crypto/addresses',
162
+ 'payments/withdrawal/{detailId}',
163
+ 'payments/deposit/{detailId}',
164
+ 'trading/offer',
165
+ 'trading/stop/offer',
166
+ 'trading/config/{symbol}',
167
+ 'trading/history/transactions',
168
+ 'balances/BITBAY/history',
169
+ 'balances/BITBAY/balance',
170
+ 'fiat_cantor/rate/{baseId}/{quoteId}',
171
+ 'fiat_cantor/history',
172
+ ],
173
+ 'post': [
174
+ 'trading/offer/{symbol}',
175
+ 'trading/stop/offer/{symbol}',
176
+ 'trading/config/{symbol}',
177
+ 'balances/BITBAY/balance',
178
+ 'balances/BITBAY/balance/transfer/{source}/{destination}',
179
+ 'fiat_cantor/exchange',
180
+ 'api_payments/withdrawals/crypto',
181
+ 'api_payments/withdrawals/fiat',
182
+ ],
183
+ 'delete': [
184
+ 'trading/offer/{symbol}/{id}/{side}/{price}',
185
+ 'trading/stop/offer/{symbol}/{id}/{side}/{price}',
186
+ ],
187
+ 'put': [
188
+ 'balances/BITBAY/balance/{id}',
189
+ ],
190
+ },
191
+ },
192
+ 'fees': {
193
+ 'trading': {
194
+ 'maker': this.parseNumber('0.0'),
195
+ 'taker': this.parseNumber('0.001'),
196
+ 'percentage': true,
197
+ 'tierBased': false,
198
+ },
199
+ 'fiat': {
200
+ 'maker': this.parseNumber('0.0030'),
201
+ 'taker': this.parseNumber('0.0043'),
202
+ 'percentage': true,
203
+ 'tierBased': true,
204
+ 'tiers': {
205
+ 'taker': [
206
+ [this.parseNumber('0.0043'), this.parseNumber('0')],
207
+ [this.parseNumber('0.0042'), this.parseNumber('1250')],
208
+ [this.parseNumber('0.0041'), this.parseNumber('3750')],
209
+ [this.parseNumber('0.0040'), this.parseNumber('7500')],
210
+ [this.parseNumber('0.0039'), this.parseNumber('10000')],
211
+ [this.parseNumber('0.0038'), this.parseNumber('15000')],
212
+ [this.parseNumber('0.0037'), this.parseNumber('20000')],
213
+ [this.parseNumber('0.0036'), this.parseNumber('25000')],
214
+ [this.parseNumber('0.0035'), this.parseNumber('37500')],
215
+ [this.parseNumber('0.0034'), this.parseNumber('50000')],
216
+ [this.parseNumber('0.0033'), this.parseNumber('75000')],
217
+ [this.parseNumber('0.0032'), this.parseNumber('100000')],
218
+ [this.parseNumber('0.0031'), this.parseNumber('150000')],
219
+ [this.parseNumber('0.0030'), this.parseNumber('200000')],
220
+ [this.parseNumber('0.0029'), this.parseNumber('250000')],
221
+ [this.parseNumber('0.0028'), this.parseNumber('375000')],
222
+ [this.parseNumber('0.0027'), this.parseNumber('500000')],
223
+ [this.parseNumber('0.0026'), this.parseNumber('625000')],
224
+ [this.parseNumber('0.0025'), this.parseNumber('875000')],
225
+ ],
226
+ 'maker': [
227
+ [this.parseNumber('0.0030'), this.parseNumber('0')],
228
+ [this.parseNumber('0.0029'), this.parseNumber('1250')],
229
+ [this.parseNumber('0.0028'), this.parseNumber('3750')],
230
+ [this.parseNumber('0.0028'), this.parseNumber('7500')],
231
+ [this.parseNumber('0.0027'), this.parseNumber('10000')],
232
+ [this.parseNumber('0.0026'), this.parseNumber('15000')],
233
+ [this.parseNumber('0.0025'), this.parseNumber('20000')],
234
+ [this.parseNumber('0.0025'), this.parseNumber('25000')],
235
+ [this.parseNumber('0.0024'), this.parseNumber('37500')],
236
+ [this.parseNumber('0.0023'), this.parseNumber('50000')],
237
+ [this.parseNumber('0.0023'), this.parseNumber('75000')],
238
+ [this.parseNumber('0.0022'), this.parseNumber('100000')],
239
+ [this.parseNumber('0.0021'), this.parseNumber('150000')],
240
+ [this.parseNumber('0.0021'), this.parseNumber('200000')],
241
+ [this.parseNumber('0.0020'), this.parseNumber('250000')],
242
+ [this.parseNumber('0.0019'), this.parseNumber('375000')],
243
+ [this.parseNumber('0.0018'), this.parseNumber('500000')],
244
+ [this.parseNumber('0.0018'), this.parseNumber('625000')],
245
+ [this.parseNumber('0.0017'), this.parseNumber('875000')],
246
+ ],
247
+ },
248
+ },
249
+ 'funding': {
250
+ 'withdraw': {},
251
+ },
252
+ },
253
+ 'options': {
254
+ 'fetchTickerMethod': 'v1_01PublicGetTradingTickerSymbol',
255
+ 'fetchTickersMethod': 'v1_01PublicGetTradingTicker',
256
+ 'fiatCurrencies': ['EUR', 'USD', 'GBP', 'PLN'],
257
+ 'transfer': {
258
+ 'fillResponseFromRequest': true,
259
+ },
260
+ },
261
+ 'precisionMode': number.TICK_SIZE,
262
+ 'exceptions': {
263
+ '400': errors.ExchangeError,
264
+ '401': errors.InvalidOrder,
265
+ '402': errors.InvalidOrder,
266
+ '403': errors.InvalidOrder,
267
+ '404': errors.InvalidOrder,
268
+ '405': errors.InvalidOrder,
269
+ '406': errors.InsufficientFunds,
270
+ // code 407 not specified are not specified in their docs
271
+ '408': errors.InvalidOrder,
272
+ '501': errors.AuthenticationError,
273
+ '502': errors.AuthenticationError,
274
+ '503': errors.InvalidNonce,
275
+ '504': errors.ExchangeError,
276
+ '505': errors.AuthenticationError,
277
+ '506': errors.AccountSuspended,
278
+ // codes 507 and 508 are not specified in their docs
279
+ '509': errors.ExchangeError,
280
+ '510': errors.BadSymbol,
281
+ 'FUNDS_NOT_SUFFICIENT': errors.InsufficientFunds,
282
+ 'OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS': errors.InvalidOrder,
283
+ 'OFFER_NOT_FOUND': errors.OrderNotFound,
284
+ 'OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLED': errors.OrderImmediatelyFillable,
285
+ 'ACTION_LIMIT_EXCEEDED': errors.RateLimitExceeded,
286
+ 'UNDER_MAINTENANCE': errors.OnMaintenance,
287
+ 'REQUEST_TIMESTAMP_TOO_OLD': errors.InvalidNonce,
288
+ 'PERMISSIONS_NOT_SUFFICIENT': errors.PermissionDenied,
289
+ 'INVALID_STOP_RATE': errors.InvalidOrder,
290
+ 'TIMEOUT': errors.ExchangeError,
291
+ 'RESPONSE_TIMEOUT': errors.ExchangeError,
292
+ 'ACTION_BLOCKED': errors.PermissionDenied,
293
+ 'INVALID_HASH_SIGNATURE': errors.AuthenticationError,
294
+ },
295
+ 'commonCurrencies': {
296
+ 'GGC': 'Global Game Coin',
297
+ },
298
+ });
299
+ }
300
+ async fetchMarkets(params = {}) {
301
+ /**
302
+ * @method
303
+ * @name zonda#fetchMarkets
304
+ * @see https://docs.zondacrypto.exchange/reference/ticker-1
305
+ * @description retrieves data on all markets for zonda
306
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
307
+ * @returns {object[]} an array of objects representing market data
308
+ */
309
+ const response = await this.v1_01PublicGetTradingTicker(params);
310
+ //
311
+ // {
312
+ // "status": "Ok",
313
+ // "items": {
314
+ // "BSV-USD": {
315
+ // "market": {
316
+ // "code": "BSV-USD",
317
+ // "first": { currency: "BSV", minOffer: "0.00035", scale: 8 },
318
+ // "second": { currency: "USD", minOffer: "5", scale: 2 }
319
+ // },
320
+ // "time": "1557569762154",
321
+ // "highestBid": "52.31",
322
+ // "lowestAsk": "62.99",
323
+ // "rate": "63",
324
+ // "previousRate": "51.21",
325
+ // },
326
+ // },
327
+ // }
328
+ //
329
+ const items = this.safeValue(response, 'items', {});
330
+ const markets = Object.values(items);
331
+ return this.parseMarkets(markets);
332
+ }
333
+ parseMarket(item) {
334
+ const market = this.safeValue(item, 'market', {});
335
+ const id = this.safeString(market, 'code');
336
+ const first = this.safeValue(market, 'first', {});
337
+ const second = this.safeValue(market, 'second', {});
338
+ const baseId = this.safeString(first, 'currency');
339
+ const quoteId = this.safeString(second, 'currency');
340
+ const base = this.safeCurrencyCode(baseId);
341
+ const quote = this.safeCurrencyCode(quoteId);
342
+ let fees = this.safeValue(this.fees, 'trading', {});
343
+ const fiatCurrencies = this.safeValue(this.options, 'fiatCurrencies', []);
344
+ if (this.inArray(base, fiatCurrencies) || this.inArray(quote, fiatCurrencies)) {
345
+ fees = this.safeValue(this.fees, 'fiat', {});
346
+ }
347
+ // todo: check that the limits have ben interpreted correctly
348
+ return {
349
+ 'id': id,
350
+ 'symbol': base + '/' + quote,
351
+ 'base': base,
352
+ 'quote': quote,
353
+ 'settle': undefined,
354
+ 'baseId': baseId,
355
+ 'quoteId': quoteId,
356
+ 'settleId': undefined,
357
+ 'type': 'spot',
358
+ 'spot': true,
359
+ 'margin': false,
360
+ 'swap': false,
361
+ 'future': false,
362
+ 'option': false,
363
+ 'active': undefined,
364
+ 'contract': false,
365
+ 'linear': undefined,
366
+ 'inverse': undefined,
367
+ 'taker': this.safeNumber(fees, 'taker'),
368
+ 'maker': this.safeNumber(fees, 'maker'),
369
+ 'contractSize': undefined,
370
+ 'expiry': undefined,
371
+ 'expiryDatetime': undefined,
372
+ 'optionType': undefined,
373
+ 'strike': undefined,
374
+ 'precision': {
375
+ 'amount': this.parseNumber(this.parsePrecision(this.safeString(first, 'scale'))),
376
+ 'price': this.parseNumber(this.parsePrecision(this.safeString(second, 'scale'))),
377
+ },
378
+ 'limits': {
379
+ 'leverage': {
380
+ 'min': undefined,
381
+ 'max': undefined,
382
+ },
383
+ 'amount': {
384
+ 'min': this.safeNumber(first, 'minOffer'),
385
+ 'max': undefined,
386
+ },
387
+ 'price': {
388
+ 'min': undefined,
389
+ 'max': undefined,
390
+ },
391
+ 'cost': {
392
+ 'min': undefined,
393
+ 'max': undefined,
394
+ },
395
+ },
396
+ 'created': undefined,
397
+ 'info': item,
398
+ };
399
+ }
400
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
401
+ /**
402
+ * @method
403
+ * @name zonda#fetchOpenOrders
404
+ * @see https://docs.zondacrypto.exchange/reference/active-orders
405
+ * @description fetch all unfilled currently open orders
406
+ * @param {string} symbol not used by zonda fetchOpenOrders
407
+ * @param {int} [since] the earliest time in ms to fetch open orders for
408
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
409
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
410
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
411
+ */
412
+ await this.loadMarkets();
413
+ const request = {};
414
+ const response = await this.v1_01PrivateGetTradingOffer(this.extend(request, params));
415
+ const items = this.safeValue(response, 'items', []);
416
+ return this.parseOrders(items, undefined, since, limit, { 'status': 'open' });
417
+ }
418
+ parseOrder(order, market = undefined) {
419
+ //
420
+ // {
421
+ // "market": "ETH-EUR",
422
+ // "offerType": "Sell",
423
+ // "id": "93d3657b-d616-11e9-9248-0242ac110005",
424
+ // "currentAmount": "0.04",
425
+ // "lockedAmount": "0.04",
426
+ // "rate": "280",
427
+ // "startAmount": "0.04",
428
+ // "time": "1568372806924",
429
+ // "postOnly": false,
430
+ // "hidden": false,
431
+ // "mode": "limit",
432
+ // "receivedAmount": "0.0",
433
+ // "firstBalanceId": "5b816c3e-437c-4e43-9bef-47814ae7ebfc",
434
+ // "secondBalanceId": "ab43023b-4079-414c-b340-056e3430a3af"
435
+ // }
436
+ //
437
+ const marketId = this.safeString(order, 'market');
438
+ const symbol = this.safeSymbol(marketId, market, '-');
439
+ const timestamp = this.safeInteger(order, 'time');
440
+ const amount = this.safeString(order, 'startAmount');
441
+ const remaining = this.safeString(order, 'currentAmount');
442
+ const postOnly = this.safeValue(order, 'postOnly');
443
+ return this.safeOrder({
444
+ 'id': this.safeString(order, 'id'),
445
+ 'clientOrderId': undefined,
446
+ 'info': order,
447
+ 'timestamp': timestamp,
448
+ 'datetime': this.iso8601(timestamp),
449
+ 'lastTradeTimestamp': undefined,
450
+ 'status': undefined,
451
+ 'symbol': symbol,
452
+ 'type': this.safeString(order, 'mode'),
453
+ 'timeInForce': undefined,
454
+ 'postOnly': postOnly,
455
+ 'side': this.safeStringLower(order, 'offerType'),
456
+ 'price': this.safeString(order, 'rate'),
457
+ 'stopPrice': undefined,
458
+ 'triggerPrice': undefined,
459
+ 'amount': amount,
460
+ 'cost': undefined,
461
+ 'filled': undefined,
462
+ 'remaining': remaining,
463
+ 'average': undefined,
464
+ 'fee': undefined,
465
+ 'trades': undefined,
466
+ }, market);
467
+ }
468
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
469
+ /**
470
+ * @method
471
+ * @name zonda#fetchMyTrades
472
+ * @see https://docs.zondacrypto.exchange/reference/transactions-history
473
+ * @description fetch all trades made by the user
474
+ * @param {string} symbol unified market symbol
475
+ * @param {int} [since] the earliest time in ms to fetch trades for
476
+ * @param {int} [limit] the maximum number of trades structures to retrieve
477
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
478
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
479
+ */
480
+ await this.loadMarkets();
481
+ const request = {};
482
+ if (symbol) {
483
+ const markets = [this.marketId(symbol)];
484
+ symbol = this.symbol(symbol);
485
+ request['markets'] = markets;
486
+ }
487
+ const query = { 'query': this.json(this.extend(request, params)) };
488
+ const response = await this.v1_01PrivateGetTradingHistoryTransactions(query);
489
+ //
490
+ // {
491
+ // "status": "Ok",
492
+ // "totalRows": "67",
493
+ // "items": [
494
+ // {
495
+ // "id": "b54659a0-51b5-42a0-80eb-2ac5357ccee2",
496
+ // "market": "BTC-EUR",
497
+ // "time": "1541697096247",
498
+ // "amount": "0.00003",
499
+ // "rate": "4341.44",
500
+ // "initializedBy": "Sell",
501
+ // "wasTaker": false,
502
+ // "userAction": "Buy",
503
+ // "offerId": "bd19804a-6f89-4a69-adb8-eb078900d006",
504
+ // "commissionValue": null
505
+ // },
506
+ // ]
507
+ // }
508
+ //
509
+ const items = this.safeValue(response, 'items');
510
+ const result = this.parseTrades(items, undefined, since, limit);
511
+ if (symbol === undefined) {
512
+ return result;
513
+ }
514
+ return this.filterBySymbol(result, symbol);
515
+ }
516
+ parseBalance(response) {
517
+ const balances = this.safeValue(response, 'balances');
518
+ if (balances === undefined) {
519
+ throw new errors.ExchangeError(this.id + ' empty balance response ' + this.json(response));
520
+ }
521
+ const result = { 'info': response };
522
+ for (let i = 0; i < balances.length; i++) {
523
+ const balance = balances[i];
524
+ const currencyId = this.safeString(balance, 'currency');
525
+ const code = this.safeCurrencyCode(currencyId);
526
+ const account = this.account();
527
+ account['used'] = this.safeString(balance, 'lockedFunds');
528
+ account['free'] = this.safeString(balance, 'availableFunds');
529
+ result[code] = account;
530
+ }
531
+ return this.safeBalance(result);
532
+ }
533
+ async fetchBalance(params = {}) {
534
+ /**
535
+ * @method
536
+ * @name zonda#fetchBalance
537
+ * @see https://docs.zondacrypto.exchange/reference/list-of-wallets
538
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
539
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
540
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
541
+ */
542
+ await this.loadMarkets();
543
+ const response = await this.v1_01PrivateGetBalancesBITBAYBalance(params);
544
+ return this.parseBalance(response);
545
+ }
546
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
547
+ /**
548
+ * @method
549
+ * @name zonda#fetchOrderBook
550
+ * @see https://docs.zondacrypto.exchange/reference/orderbook-2
551
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
552
+ * @param {string} symbol unified symbol of the market to fetch the order book for
553
+ * @param {int} [limit] the maximum amount of order book entries to return
554
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
555
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
556
+ */
557
+ await this.loadMarkets();
558
+ const market = this.market(symbol);
559
+ const request = {
560
+ 'symbol': market['id'],
561
+ };
562
+ const response = await this.v1_01PublicGetTradingOrderbookSymbol(this.extend(request, params));
563
+ //
564
+ // {
565
+ // "status":"Ok",
566
+ // "sell":[
567
+ // {"ra":"43988.93","ca":"0.00100525","sa":"0.00100525","pa":"0.00100525","co":1},
568
+ // {"ra":"43988.94","ca":"0.00114136","sa":"0.00114136","pa":"0.00114136","co":1},
569
+ // {"ra":"43989","ca":"0.010578","sa":"0.010578","pa":"0.010578","co":1},
570
+ // ],
571
+ // "buy":[
572
+ // {"ra":"42157.33","ca":"2.83147881","sa":"2.83147881","pa":"2.83147881","co":2},
573
+ // {"ra":"42096.0","ca":"0.00011878","sa":"0.00011878","pa":"0.00011878","co":1},
574
+ // {"ra":"42022.0","ca":"0.00011899","sa":"0.00011899","pa":"0.00011899","co":1},
575
+ // ],
576
+ // "timestamp":"1642299886122",
577
+ // "seqNo":"27641254"
578
+ // }
579
+ //
580
+ const rawBids = this.safeValue(response, 'buy', []);
581
+ const rawAsks = this.safeValue(response, 'sell', []);
582
+ const timestamp = this.safeInteger(response, 'timestamp');
583
+ return {
584
+ 'symbol': market['symbol'],
585
+ 'bids': this.parseBidsAsks(rawBids, 'ra', 'ca'),
586
+ 'asks': this.parseBidsAsks(rawAsks, 'ra', 'ca'),
587
+ 'timestamp': timestamp,
588
+ 'datetime': this.iso8601(timestamp),
589
+ 'nonce': this.safeInteger(response, 'seqNo'),
590
+ };
591
+ }
592
+ parseTicker(ticker, market = undefined) {
593
+ //
594
+ // version 1
595
+ //
596
+ // {
597
+ // "m": "ETH-PLN",
598
+ // "h": "13485.13",
599
+ // "l": "13100.01",
600
+ // "v": "126.10710939",
601
+ // "r24h": "13332.72"
602
+ // }
603
+ //
604
+ // version 2
605
+ //
606
+ // {
607
+ // "market": {
608
+ // "code": "ADA-USDT",
609
+ // "first": {
610
+ // "currency": "ADA",
611
+ // "minOffer": "0.2",
612
+ // "scale": "6"
613
+ // },
614
+ // "second": {
615
+ // "currency": "USDT",
616
+ // "minOffer": "0.099",
617
+ // "scale": "6"
618
+ // },
619
+ // "amountPrecision": "6",
620
+ // "pricePrecision": "6",
621
+ // "ratePrecision": "6"
622
+ // },
623
+ // "time": "1655812661202",
624
+ // "highestBid": "0.492",
625
+ // "lowestAsk": "0.499389",
626
+ // "rate": "0.50588",
627
+ // "previousRate": "0.504981"
628
+ // }
629
+ //
630
+ const tickerMarket = this.safeValue(ticker, 'market');
631
+ const marketId = this.safeString2(tickerMarket, 'code', 'm');
632
+ market = this.safeMarket(marketId, market);
633
+ const timestamp = this.safeInteger(ticker, 'time');
634
+ const rate = this.safeValue(ticker, 'rate');
635
+ return this.safeTicker({
636
+ 'symbol': this.safeSymbol(marketId, market),
637
+ 'timestamp': timestamp,
638
+ 'datetime': this.iso8601(timestamp),
639
+ 'high': this.safeString(ticker, 'h'),
640
+ 'low': this.safeString(ticker, 'l'),
641
+ 'bid': this.safeNumber(ticker, 'highestBid'),
642
+ 'bidVolume': undefined,
643
+ 'ask': this.safeNumber(ticker, 'lowestAsk'),
644
+ 'askVolume': undefined,
645
+ 'vwap': undefined,
646
+ 'open': this.safeString(ticker, 'r24h'),
647
+ 'close': rate,
648
+ 'last': rate,
649
+ 'previousClose': this.safeValue(ticker, 'previousRate'),
650
+ 'change': undefined,
651
+ 'percentage': undefined,
652
+ 'average': undefined,
653
+ 'baseVolume': this.safeString(ticker, 'v'),
654
+ 'quoteVolume': undefined,
655
+ 'info': ticker,
656
+ }, market);
657
+ }
658
+ async fetchTicker(symbol, params = {}) {
659
+ /**
660
+ * @method
661
+ * @name zonda#fetchTicker
662
+ * @description v1_01PublicGetTradingTickerSymbol retrieves timestamp, datetime, bid, ask, close, last, previousClose, v1_01PublicGetTradingStatsSymbol retrieves high, low, volume and opening price of an asset
663
+ * @see https://docs.zondacrypto.exchange/reference/market-statistics
664
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
665
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
666
+ * @param {string} [params.method] v1_01PublicGetTradingTickerSymbol (default) or v1_01PublicGetTradingStatsSymbol
667
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
668
+ */
669
+ await this.loadMarkets();
670
+ const market = this.market(symbol);
671
+ const request = {
672
+ 'symbol': market['id'],
673
+ };
674
+ const method = 'v1_01PublicGetTradingTickerSymbol';
675
+ const defaultMethod = this.safeString(this.options, 'fetchTickerMethod', method);
676
+ const fetchTickerMethod = this.safeString2(params, 'method', 'fetchTickerMethod', defaultMethod);
677
+ let response = undefined;
678
+ if (fetchTickerMethod === method) {
679
+ response = await this.v1_01PublicGetTradingTickerSymbol(this.extend(request, params));
680
+ //
681
+ // {
682
+ // "status": "Ok",
683
+ // "ticker": {
684
+ // "market": {
685
+ // "code": "ADA-USDT",
686
+ // "first": {
687
+ // "currency": "ADA",
688
+ // "minOffer": "0.21",
689
+ // "scale": 6
690
+ // },
691
+ // "second": {
692
+ // "currency": "USDT",
693
+ // "minOffer": "0.099",
694
+ // "scale": 6
695
+ // },
696
+ // "amountPrecision": 6,
697
+ // "pricePrecision": 6,
698
+ // "ratePrecision": 6
699
+ // },
700
+ // "time": "1655810976780",
701
+ // "highestBid": "0.498543",
702
+ // "lowestAsk": "0.50684",
703
+ // "rate": "0.50588",
704
+ // "previousRate": "0.504981"
705
+ // }
706
+ // }
707
+ //
708
+ }
709
+ else if (fetchTickerMethod === 'v1_01PublicGetTradingStatsSymbol') {
710
+ response = await this.v1_01PublicGetTradingStatsSymbol(this.extend(request, params));
711
+ //
712
+ // {
713
+ // "status": "Ok",
714
+ // "stats": {
715
+ // "m": "BTC-USDT",
716
+ // "h": "28800",
717
+ // "l": "26703.950101",
718
+ // "v": "6.72932396",
719
+ // "r24h": "27122.2"
720
+ // }
721
+ // }
722
+ //
723
+ }
724
+ else {
725
+ throw new errors.BadRequest(this.id + ' fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"');
726
+ }
727
+ const stats = this.safeValue2(response, 'ticker', 'stats');
728
+ return this.parseTicker(stats, market);
729
+ }
730
+ async fetchTickers(symbols = undefined, params = {}) {
731
+ /**
732
+ * @ignore
733
+ * @method
734
+ * @name zonda#fetchTickersV2
735
+ * @description v1_01PublicGetTradingTicker retrieves timestamp, datetime, bid, ask, close, last, previousClose for each market, v1_01PublicGetTradingStats retrieves high, low, volume and opening price of each market
736
+ * @see https://docs.zondacrypto.exchange/reference/market-statistics
737
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
738
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
739
+ * @param {string} [params.method] v1_01PublicGetTradingTicker (default) or v1_01PublicGetTradingStats
740
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
741
+ */
742
+ await this.loadMarkets();
743
+ const method = 'v1_01PublicGetTradingTicker';
744
+ const defaultMethod = this.safeString(this.options, 'fetchTickersMethod', method);
745
+ const fetchTickersMethod = this.safeString2(params, 'method', 'fetchTickersMethod', defaultMethod);
746
+ let response = undefined;
747
+ if (fetchTickersMethod === method) {
748
+ response = await this.v1_01PublicGetTradingTicker(params);
749
+ //
750
+ // {
751
+ // "status": "Ok",
752
+ // "items": {
753
+ // "DAI-PLN": {
754
+ // "market": {
755
+ // "code": "DAI-PLN",
756
+ // "first": {
757
+ // "currency": "DAI",
758
+ // "minOffer": "0.99",
759
+ // "scale": 8
760
+ // },
761
+ // "second": {
762
+ // "currency": "PLN",
763
+ // "minOffer": "5",
764
+ // "scale": 2
765
+ // },
766
+ // "amountPrecision": 8,
767
+ // "pricePrecision": 2,
768
+ // "ratePrecision": 2
769
+ // },
770
+ // "time": "1655810825137",
771
+ // "highestBid": "4.42",
772
+ // "lowestAsk": "4.44",
773
+ // "rate": "4.44",
774
+ // "previousRate": "4.43"
775
+ // },
776
+ // ...
777
+ // }
778
+ // }
779
+ //
780
+ }
781
+ else if (fetchTickersMethod === 'v1_01PublicGetTradingStats') {
782
+ response = await this.v1_01PublicGetTradingStats(params);
783
+ //
784
+ // {
785
+ // "status": "Ok",
786
+ // "items": {
787
+ // "DAI-PLN": {
788
+ // "m": "DAI-PLN",
789
+ // "h": "4.41",
790
+ // "l": "4.37",
791
+ // "v": "8.71068087",
792
+ // "r24h": "4.36"
793
+ // },
794
+ // ...
795
+ // }
796
+ // }
797
+ //
798
+ }
799
+ else {
800
+ throw new errors.BadRequest(this.id + ' fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"');
801
+ }
802
+ const items = this.safeValue(response, 'items');
803
+ return this.parseTickers(items, symbols);
804
+ }
805
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
806
+ /**
807
+ * @method
808
+ * @name zonda#fetchLedger
809
+ * @see https://docs.zondacrypto.exchange/reference/operations-history
810
+ * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
811
+ * @param {string} code unified currency code, default is undefined
812
+ * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
813
+ * @param {int} [limit] max number of ledger entrys to return, default is undefined
814
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
815
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
816
+ */
817
+ const balanceCurrencies = [];
818
+ if (code !== undefined) {
819
+ const currency = this.currency(code);
820
+ balanceCurrencies.push(currency['id']);
821
+ }
822
+ let request = {
823
+ 'balanceCurrencies': balanceCurrencies,
824
+ };
825
+ if (since !== undefined) {
826
+ request['fromTime'] = since;
827
+ }
828
+ if (limit !== undefined) {
829
+ request['limit'] = limit;
830
+ }
831
+ request = this.extend(request, params);
832
+ const response = await this.v1_01PrivateGetBalancesBITBAYHistory({ 'query': this.json(request) });
833
+ const items = response['items'];
834
+ return this.parseLedger(items, undefined, since, limit);
835
+ }
836
+ parseLedgerEntry(item, currency = undefined) {
837
+ //
838
+ // FUNDS_MIGRATION
839
+ // {
840
+ // "historyId": "84ea7a29-7da5-4de5-b0c0-871e83cad765",
841
+ // "balance": {
842
+ // "id": "821ec166-cb88-4521-916c-f4eb44db98df",
843
+ // "currency": "LTC",
844
+ // "type": "CRYPTO",
845
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
846
+ // "name": "LTC"
847
+ // },
848
+ // "detailId": null,
849
+ // "time": 1506128252968,
850
+ // "type": "FUNDS_MIGRATION",
851
+ // "value": 0.0009957,
852
+ // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
853
+ // "fundsAfter": { "total": 0.0009957, "available": 0.0009957, "locked": 0 },
854
+ // "change": { "total": 0.0009957, "available": 0.0009957, "locked": 0 }
855
+ // }
856
+ //
857
+ // CREATE_BALANCE
858
+ // {
859
+ // "historyId": "d0fabd8d-9107-4b5e-b9a6-3cab8af70d49",
860
+ // "balance": {
861
+ // "id": "653ffcf2-3037-4ebe-8e13-d5ea1a01d60d",
862
+ // "currency": "BTG",
863
+ // "type": "CRYPTO",
864
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
865
+ // "name": "BTG"
866
+ // },
867
+ // "detailId": null,
868
+ // "time": 1508895244751,
869
+ // "type": "CREATE_BALANCE",
870
+ // "value": 0,
871
+ // "fundsBefore": { "total": null, "available": null, "locked": null },
872
+ // "fundsAfter": { "total": 0, "available": 0, "locked": 0 },
873
+ // "change": { "total": 0, "available": 0, "locked": 0 }
874
+ // }
875
+ //
876
+ // BITCOIN_GOLD_FORK
877
+ // {
878
+ // "historyId": "2b4d52d3-611c-473d-b92c-8a8d87a24e41",
879
+ // "balance": {
880
+ // "id": "653ffcf2-3037-4ebe-8e13-d5ea1a01d60d",
881
+ // "currency": "BTG",
882
+ // "type": "CRYPTO",
883
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
884
+ // "name": "BTG"
885
+ // },
886
+ // "detailId": null,
887
+ // "time": 1508895244778,
888
+ // "type": "BITCOIN_GOLD_FORK",
889
+ // "value": 0.00453512,
890
+ // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
891
+ // "fundsAfter": { "total": 0.00453512, "available": 0.00453512, "locked": 0 },
892
+ // "change": { "total": 0.00453512, "available": 0.00453512, "locked": 0 }
893
+ // }
894
+ //
895
+ // ADD_FUNDS
896
+ // {
897
+ // "historyId": "3158236d-dae5-4a5d-81af-c1fa4af340fb",
898
+ // "balance": {
899
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
900
+ // "currency": "BTC",
901
+ // "type": "CRYPTO",
902
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
903
+ // "name": "BTC"
904
+ // },
905
+ // "detailId": "8e83a960-e737-4380-b8bb-259d6e236faa",
906
+ // "time": 1520631178816,
907
+ // "type": "ADD_FUNDS",
908
+ // "value": 0.628405,
909
+ // "fundsBefore": { "total": 0.00453512, "available": 0.00453512, "locked": 0 },
910
+ // "fundsAfter": { "total": 0.63294012, "available": 0.63294012, "locked": 0 },
911
+ // "change": { "total": 0.628405, "available": 0.628405, "locked": 0 }
912
+ // }
913
+ //
914
+ // TRANSACTION_PRE_LOCKING
915
+ // {
916
+ // "historyId": "e7d19e0f-03b3-46a8-bc72-dde72cc24ead",
917
+ // "balance": {
918
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
919
+ // "currency": "BTC",
920
+ // "type": "CRYPTO",
921
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
922
+ // "name": "BTC"
923
+ // },
924
+ // "detailId": null,
925
+ // "time": 1520706403868,
926
+ // "type": "TRANSACTION_PRE_LOCKING",
927
+ // "value": -0.1,
928
+ // "fundsBefore": { "total": 0.63294012, "available": 0.63294012, "locked": 0 },
929
+ // "fundsAfter": { "total": 0.63294012, "available": 0.53294012, "locked": 0.1 },
930
+ // "change": { "total": 0, "available": -0.1, "locked": 0.1 }
931
+ // }
932
+ //
933
+ // TRANSACTION_POST_OUTCOME
934
+ // {
935
+ // "historyId": "c4010825-231d-4a9c-8e46-37cde1f7b63c",
936
+ // "balance": {
937
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
938
+ // "currency": "BTC",
939
+ // "type": "CRYPTO",
940
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
941
+ // "name": "BTC"
942
+ // },
943
+ // "detailId": "bf2876bc-b545-4503-96c8-ef4de8233876",
944
+ // "time": 1520706404032,
945
+ // "type": "TRANSACTION_POST_OUTCOME",
946
+ // "value": -0.01771415,
947
+ // "fundsBefore": { "total": 0.63294012, "available": 0.53294012, "locked": 0.1 },
948
+ // "fundsAfter": { "total": 0.61522597, "available": 0.53294012, "locked": 0.08228585 },
949
+ // "change": { "total": -0.01771415, "available": 0, "locked": -0.01771415 }
950
+ // }
951
+ //
952
+ // TRANSACTION_POST_INCOME
953
+ // {
954
+ // "historyId": "7f18b7af-b676-4125-84fd-042e683046f6",
955
+ // "balance": {
956
+ // "id": "ab43023b-4079-414c-b340-056e3430a3af",
957
+ // "currency": "EUR",
958
+ // "type": "FIAT",
959
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
960
+ // "name": "EUR"
961
+ // },
962
+ // "detailId": "f5fcb274-0cc7-4385-b2d3-bae2756e701f",
963
+ // "time": 1520706404035,
964
+ // "type": "TRANSACTION_POST_INCOME",
965
+ // "value": 628.78,
966
+ // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
967
+ // "fundsAfter": { "total": 628.78, "available": 628.78, "locked": 0 },
968
+ // "change": { "total": 628.78, "available": 628.78, "locked": 0 }
969
+ // }
970
+ //
971
+ // TRANSACTION_COMMISSION_OUTCOME
972
+ // {
973
+ // "historyId": "843177fa-61bc-4cbf-8be5-b029d856c93b",
974
+ // "balance": {
975
+ // "id": "ab43023b-4079-414c-b340-056e3430a3af",
976
+ // "currency": "EUR",
977
+ // "type": "FIAT",
978
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
979
+ // "name": "EUR"
980
+ // },
981
+ // "detailId": "f5fcb274-0cc7-4385-b2d3-bae2756e701f",
982
+ // "time": 1520706404050,
983
+ // "type": "TRANSACTION_COMMISSION_OUTCOME",
984
+ // "value": -2.71,
985
+ // "fundsBefore": { "total": 766.06, "available": 766.06, "locked": 0 },
986
+ // "fundsAfter": { "total": 763.35,"available": 763.35, "locked": 0 },
987
+ // "change": { "total": -2.71, "available": -2.71, "locked": 0 }
988
+ // }
989
+ //
990
+ // TRANSACTION_OFFER_COMPLETED_RETURN
991
+ // {
992
+ // "historyId": "cac69b04-c518-4dc5-9d86-e76e91f2e1d2",
993
+ // "balance": {
994
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
995
+ // "currency": "BTC",
996
+ // "type": "CRYPTO",
997
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
998
+ // "name": "BTC"
999
+ // },
1000
+ // "detailId": null,
1001
+ // "time": 1520714886425,
1002
+ // "type": "TRANSACTION_OFFER_COMPLETED_RETURN",
1003
+ // "value": 0.00000196,
1004
+ // "fundsBefore": { "total": 0.00941208, "available": 0.00941012, "locked": 0.00000196 },
1005
+ // "fundsAfter": { "total": 0.00941208, "available": 0.00941208, "locked": 0 },
1006
+ // "change": { "total": 0, "available": 0.00000196, "locked": -0.00000196 }
1007
+ // }
1008
+ //
1009
+ // WITHDRAWAL_LOCK_FUNDS
1010
+ // {
1011
+ // "historyId": "03de2271-66ab-4960-a786-87ab9551fc14",
1012
+ // "balance": {
1013
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1014
+ // "currency": "BTC",
1015
+ // "type": "CRYPTO",
1016
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1017
+ // "name": "BTC"
1018
+ // },
1019
+ // "detailId": "6ad3dc72-1d6d-4ec2-8436-ca43f85a38a6",
1020
+ // "time": 1522245654481,
1021
+ // "type": "WITHDRAWAL_LOCK_FUNDS",
1022
+ // "value": -0.8,
1023
+ // "fundsBefore": { "total": 0.8, "available": 0.8, "locked": 0 },
1024
+ // "fundsAfter": { "total": 0.8, "available": 0, "locked": 0.8 },
1025
+ // "change": { "total": 0, "available": -0.8, "locked": 0.8 }
1026
+ // }
1027
+ //
1028
+ // WITHDRAWAL_SUBTRACT_FUNDS
1029
+ // {
1030
+ // "historyId": "b0308c89-5288-438d-a306-c6448b1a266d",
1031
+ // "balance": {
1032
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1033
+ // "currency": "BTC",
1034
+ // "type": "CRYPTO",
1035
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1036
+ // "name": "BTC"
1037
+ // },
1038
+ // "detailId": "6ad3dc72-1d6d-4ec2-8436-ca43f85a38a6",
1039
+ // "time": 1522246526186,
1040
+ // "type": "WITHDRAWAL_SUBTRACT_FUNDS",
1041
+ // "value": -0.8,
1042
+ // "fundsBefore": { "total": 0.8, "available": 0, "locked": 0.8 },
1043
+ // "fundsAfter": { "total": 0, "available": 0, "locked": 0 },
1044
+ // "change": { "total": -0.8, "available": 0, "locked": -0.8 }
1045
+ // }
1046
+ //
1047
+ // TRANSACTION_OFFER_ABORTED_RETURN
1048
+ // {
1049
+ // "historyId": "b1a3c075-d403-4e05-8f32-40512cdd88c0",
1050
+ // "balance": {
1051
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1052
+ // "currency": "BTC",
1053
+ // "type": "CRYPTO",
1054
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1055
+ // "name": "BTC"
1056
+ // },
1057
+ // "detailId": null,
1058
+ // "time": 1522512298662,
1059
+ // "type": "TRANSACTION_OFFER_ABORTED_RETURN",
1060
+ // "value": 0.0564931,
1061
+ // "fundsBefore": { "total": 0.44951311, "available": 0.39302001, "locked": 0.0564931 },
1062
+ // "fundsAfter": { "total": 0.44951311, "available": 0.44951311, "locked": 0 },
1063
+ // "change": { "total": 0, "available": 0.0564931, "locked": -0.0564931 }
1064
+ // }
1065
+ //
1066
+ // WITHDRAWAL_UNLOCK_FUNDS
1067
+ // {
1068
+ // "historyId": "0ed569a2-c330-482e-bb89-4cb553fb5b11",
1069
+ // "balance": {
1070
+ // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1071
+ // "currency": "BTC",
1072
+ // "type": "CRYPTO",
1073
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1074
+ // "name": "BTC"
1075
+ // },
1076
+ // "detailId": "0c7be256-c336-4111-bee7-4eb22e339700",
1077
+ // "time": 1527866360785,
1078
+ // "type": "WITHDRAWAL_UNLOCK_FUNDS",
1079
+ // "value": 0.05045,
1080
+ // "fundsBefore": { "total": 0.86001578, "available": 0.80956578, "locked": 0.05045 },
1081
+ // "fundsAfter": { "total": 0.86001578, "available": 0.86001578, "locked": 0 },
1082
+ // "change": { "total": 0, "available": 0.05045, "locked": -0.05045 }
1083
+ // }
1084
+ //
1085
+ // TRANSACTION_COMMISSION_RETURN
1086
+ // {
1087
+ // "historyId": "07c89c27-46f1-4d7a-8518-b73798bf168a",
1088
+ // "balance": {
1089
+ // "id": "ab43023b-4079-414c-b340-056e3430a3af",
1090
+ // "currency": "EUR",
1091
+ // "type": "FIAT",
1092
+ // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1093
+ // "name": "EUR"
1094
+ // },
1095
+ // "detailId": null,
1096
+ // "time": 1528304043063,
1097
+ // "type": "TRANSACTION_COMMISSION_RETURN",
1098
+ // "value": 0.6,
1099
+ // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
1100
+ // "fundsAfter": { "total": 0.6, "available": 0.6, "locked": 0 },
1101
+ // "change": { "total": 0.6, "available": 0.6, "locked": 0 }
1102
+ // }
1103
+ //
1104
+ const timestamp = this.safeInteger(item, 'time');
1105
+ const balance = this.safeValue(item, 'balance', {});
1106
+ const currencyId = this.safeString(balance, 'currency');
1107
+ const change = this.safeValue(item, 'change', {});
1108
+ let amount = this.safeString(change, 'total');
1109
+ let direction = 'in';
1110
+ if (Precise["default"].stringLt(amount, '0')) {
1111
+ direction = 'out';
1112
+ amount = Precise["default"].stringNeg(amount);
1113
+ }
1114
+ // there are 2 undocumented api calls: (v1_01PrivateGetPaymentsDepositDetailId and v1_01PrivateGetPaymentsWithdrawalDetailId)
1115
+ // that can be used to enrich the transfers with txid, address etc (you need to use info.detailId as a parameter)
1116
+ const fundsBefore = this.safeValue(item, 'fundsBefore', {});
1117
+ const fundsAfter = this.safeValue(item, 'fundsAfter', {});
1118
+ return {
1119
+ 'info': item,
1120
+ 'id': this.safeString(item, 'historyId'),
1121
+ 'direction': direction,
1122
+ 'account': undefined,
1123
+ 'referenceId': this.safeString(item, 'detailId'),
1124
+ 'referenceAccount': undefined,
1125
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
1126
+ 'currency': this.safeCurrencyCode(currencyId),
1127
+ 'amount': this.parseNumber(amount),
1128
+ 'before': this.safeNumber(fundsBefore, 'total'),
1129
+ 'after': this.safeNumber(fundsAfter, 'total'),
1130
+ 'status': 'ok',
1131
+ 'timestamp': timestamp,
1132
+ 'datetime': this.iso8601(timestamp),
1133
+ 'fee': undefined,
1134
+ };
1135
+ }
1136
+ parseLedgerEntryType(type) {
1137
+ const types = {
1138
+ 'ADD_FUNDS': 'transaction',
1139
+ 'BITCOIN_GOLD_FORK': 'transaction',
1140
+ 'CREATE_BALANCE': 'transaction',
1141
+ 'FUNDS_MIGRATION': 'transaction',
1142
+ 'WITHDRAWAL_LOCK_FUNDS': 'transaction',
1143
+ 'WITHDRAWAL_SUBTRACT_FUNDS': 'transaction',
1144
+ 'WITHDRAWAL_UNLOCK_FUNDS': 'transaction',
1145
+ 'TRANSACTION_COMMISSION_OUTCOME': 'fee',
1146
+ 'TRANSACTION_COMMISSION_RETURN': 'fee',
1147
+ 'TRANSACTION_OFFER_ABORTED_RETURN': 'trade',
1148
+ 'TRANSACTION_OFFER_COMPLETED_RETURN': 'trade',
1149
+ 'TRANSACTION_POST_INCOME': 'trade',
1150
+ 'TRANSACTION_POST_OUTCOME': 'trade',
1151
+ 'TRANSACTION_PRE_LOCKING': 'trade',
1152
+ };
1153
+ return this.safeString(types, type, type);
1154
+ }
1155
+ parseOHLCV(ohlcv, market = undefined) {
1156
+ //
1157
+ // [
1158
+ // "1582399800000",
1159
+ // {
1160
+ // "o": "0.0001428",
1161
+ // "c": "0.0001428",
1162
+ // "h": "0.0001428",
1163
+ // "l": "0.0001428",
1164
+ // "v": "4",
1165
+ // "co": "1"
1166
+ // }
1167
+ // ]
1168
+ //
1169
+ const first = this.safeValue(ohlcv, 1, {});
1170
+ return [
1171
+ this.safeInteger(ohlcv, 0),
1172
+ this.safeNumber(first, 'o'),
1173
+ this.safeNumber(first, 'h'),
1174
+ this.safeNumber(first, 'l'),
1175
+ this.safeNumber(first, 'c'),
1176
+ this.safeNumber(first, 'v'),
1177
+ ];
1178
+ }
1179
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1180
+ /**
1181
+ * @method
1182
+ * @name zonda#fetchOHLCV
1183
+ * @see https://docs.zondacrypto.exchange/reference/candles-chart
1184
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1185
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1186
+ * @param {string} timeframe the length of time each candle represents
1187
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1188
+ * @param {int} [limit] the maximum amount of candles to fetch
1189
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1190
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1191
+ */
1192
+ await this.loadMarkets();
1193
+ const market = this.market(symbol);
1194
+ const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1195
+ const request = {
1196
+ 'symbol': tradingSymbol,
1197
+ 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
1198
+ // 'from': 1574709092000, // unix timestamp in milliseconds, required
1199
+ // 'to': 1574709092000, // unix timestamp in milliseconds, required
1200
+ };
1201
+ if (limit === undefined) {
1202
+ limit = 100;
1203
+ }
1204
+ const duration = this.parseTimeframe(timeframe);
1205
+ const timerange = limit * duration * 1000;
1206
+ if (since === undefined) {
1207
+ request['to'] = this.milliseconds();
1208
+ request['from'] = request['to'] - timerange;
1209
+ }
1210
+ else {
1211
+ request['from'] = since;
1212
+ request['to'] = this.sum(request['from'], timerange);
1213
+ }
1214
+ const response = await this.v1_01PublicGetTradingCandleHistorySymbolResolution(this.extend(request, params));
1215
+ //
1216
+ // {
1217
+ // "status":"Ok",
1218
+ // "items":[
1219
+ // ["1591503060000",{"o":"0.02509572","c":"0.02509438","h":"0.02509664","l":"0.02509438","v":"0.02082165","co":"17"}],
1220
+ // ["1591503120000",{"o":"0.02509606","c":"0.02509515","h":"0.02509606","l":"0.02509487","v":"0.04971703","co":"13"}],
1221
+ // ["1591503180000",{"o":"0.02509532","c":"0.02509589","h":"0.02509589","l":"0.02509454","v":"0.01332236","co":"7"}],
1222
+ // ]
1223
+ // }
1224
+ //
1225
+ const items = this.safeValue(response, 'items', []);
1226
+ return this.parseOHLCVs(items, market, timeframe, since, limit);
1227
+ }
1228
+ parseTrade(trade, market = undefined) {
1229
+ //
1230
+ // createOrder trades
1231
+ //
1232
+ // {
1233
+ // "rate": "0.02195928",
1234
+ // "amount": "0.00167952"
1235
+ // }
1236
+ //
1237
+ // fetchMyTrades (private)
1238
+ //
1239
+ // {
1240
+ // "amount": "0.29285199",
1241
+ // "commissionValue": "0.00125927",
1242
+ // "id": "11c8203a-a267-11e9-b698-0242ac110007",
1243
+ // "initializedBy": "Buy",
1244
+ // "market": "ETH-EUR",
1245
+ // "offerId": "11c82038-a267-11e9-b698-0242ac110007",
1246
+ // "rate": "277",
1247
+ // "time": "1562689917517",
1248
+ // "userAction": "Buy",
1249
+ // "wasTaker": true,
1250
+ // }
1251
+ //
1252
+ // fetchTrades (public)
1253
+ //
1254
+ // {
1255
+ // "id": "df00b0da-e5e0-11e9-8c19-0242ac11000a",
1256
+ // "t": "1570108958831",
1257
+ // "a": "0.04776653",
1258
+ // "r": "0.02145854",
1259
+ // "ty": "Sell"
1260
+ // }
1261
+ //
1262
+ const timestamp = this.safeInteger2(trade, 'time', 't');
1263
+ const side = this.safeStringLower2(trade, 'userAction', 'ty');
1264
+ const wasTaker = this.safeValue(trade, 'wasTaker');
1265
+ let takerOrMaker = undefined;
1266
+ if (wasTaker !== undefined) {
1267
+ takerOrMaker = wasTaker ? 'taker' : 'maker';
1268
+ }
1269
+ const priceString = this.safeString2(trade, 'rate', 'r');
1270
+ const amountString = this.safeString2(trade, 'amount', 'a');
1271
+ const feeCostString = this.safeString(trade, 'commissionValue');
1272
+ const marketId = this.safeString(trade, 'market');
1273
+ market = this.safeMarket(marketId, market, '-');
1274
+ const symbol = market['symbol'];
1275
+ let fee = undefined;
1276
+ if (feeCostString !== undefined) {
1277
+ const feeCurrency = (side === 'buy') ? market['base'] : market['quote'];
1278
+ fee = {
1279
+ 'currency': feeCurrency,
1280
+ 'cost': feeCostString,
1281
+ };
1282
+ }
1283
+ const order = this.safeString(trade, 'offerId');
1284
+ // todo: check this logic
1285
+ let type = undefined;
1286
+ if (order !== undefined) {
1287
+ type = order ? 'limit' : 'market';
1288
+ }
1289
+ return this.safeTrade({
1290
+ 'id': this.safeString(trade, 'id'),
1291
+ 'order': order,
1292
+ 'timestamp': timestamp,
1293
+ 'datetime': this.iso8601(timestamp),
1294
+ 'symbol': symbol,
1295
+ 'type': type,
1296
+ 'side': side,
1297
+ 'price': priceString,
1298
+ 'amount': amountString,
1299
+ 'cost': undefined,
1300
+ 'takerOrMaker': takerOrMaker,
1301
+ 'fee': fee,
1302
+ 'info': trade,
1303
+ }, market);
1304
+ }
1305
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1306
+ /**
1307
+ * @method
1308
+ * @name zonda#fetchTrades
1309
+ * @see https://docs.zondacrypto.exchange/reference/last-transactions
1310
+ * @description get the list of most recent trades for a particular symbol
1311
+ * @param {string} symbol unified symbol of the market to fetch trades for
1312
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1313
+ * @param {int} [limit] the maximum amount of trades to fetch
1314
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1315
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1316
+ */
1317
+ await this.loadMarkets();
1318
+ const market = this.market(symbol);
1319
+ const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1320
+ const request = {
1321
+ 'symbol': tradingSymbol,
1322
+ };
1323
+ if (since !== undefined) {
1324
+ request['fromTime'] = since - 1; // result does not include exactly `since` time therefore decrease by 1
1325
+ }
1326
+ if (limit !== undefined) {
1327
+ request['limit'] = limit; // default - 10, max - 300
1328
+ }
1329
+ const response = await this.v1_01PublicGetTradingTransactionsSymbol(this.extend(request, params));
1330
+ const items = this.safeValue(response, 'items');
1331
+ return this.parseTrades(items, market, since, limit);
1332
+ }
1333
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1334
+ /**
1335
+ * @method
1336
+ * @name zonda#createOrder
1337
+ * @description create a trade order
1338
+ * @param {string} symbol unified symbol of the market to create an order in
1339
+ * @param {string} type 'market' or 'limit'
1340
+ * @param {string} side 'buy' or 'sell'
1341
+ * @param {float} amount how much of currency you want to trade in units of base currency
1342
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1343
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1344
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1345
+ */
1346
+ await this.loadMarkets();
1347
+ const market = this.market(symbol);
1348
+ const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1349
+ amount = parseFloat(this.amountToPrecision(symbol, amount));
1350
+ const request = {
1351
+ 'symbol': tradingSymbol,
1352
+ 'offerType': side.toUpperCase(),
1353
+ 'amount': amount,
1354
+ };
1355
+ const stopLossPrice = this.safeValue2(params, 'stopPrice', 'stopLossPrice');
1356
+ const isStopLossPrice = stopLossPrice !== undefined;
1357
+ const isLimitOrder = type === 'limit';
1358
+ const isMarketOrder = type === 'market';
1359
+ const isStopLimit = (type === 'stop-limit') || (isLimitOrder && isStopLossPrice);
1360
+ const isStopMarket = type === 'stop-market' || (isMarketOrder && isStopLossPrice);
1361
+ const isStopOrder = isStopLimit || isStopMarket;
1362
+ if (isLimitOrder || isStopLimit) {
1363
+ request['rate'] = this.priceToPrecision(symbol, price);
1364
+ request['mode'] = isStopLimit ? 'stop-limit' : 'limit';
1365
+ }
1366
+ else if (isMarketOrder || isStopMarket) {
1367
+ request['mode'] = isStopMarket ? 'stop-market' : 'market';
1368
+ }
1369
+ else {
1370
+ throw new errors.ExchangeError(this.id + ' createOrder() invalid type');
1371
+ }
1372
+ params = this.omit(params, ['stopPrice', 'stopLossPrice']);
1373
+ let response = undefined;
1374
+ if (isStopOrder) {
1375
+ if (!isStopLossPrice) {
1376
+ throw new errors.ExchangeError(this.id + ' createOrder() zonda requires `triggerPrice` or `stopPrice` parameter for stop-limit or stop-market orders');
1377
+ }
1378
+ request['stopRate'] = this.priceToPrecision(symbol, stopLossPrice);
1379
+ response = await this.v1_01PrivatePostTradingStopOfferSymbol(this.extend(request, params));
1380
+ }
1381
+ else {
1382
+ response = await this.v1_01PrivatePostTradingOfferSymbol(this.extend(request, params));
1383
+ }
1384
+ //
1385
+ // unfilled (open order)
1386
+ //
1387
+ // {
1388
+ // "status": "Ok",
1389
+ // "completed": false, // can deduce status from here
1390
+ // "offerId": "ce9cc72e-d61c-11e9-9248-0242ac110005",
1391
+ // "transactions": [], // can deduce order info from here
1392
+ // }
1393
+ //
1394
+ // filled (closed order)
1395
+ //
1396
+ // {
1397
+ // "status": "Ok",
1398
+ // "offerId": "942a4a3e-e922-11e9-8c19-0242ac11000a",
1399
+ // "completed": true,
1400
+ // "transactions": [
1401
+ // {
1402
+ // "rate": "0.02195928",
1403
+ // "amount": "0.00167952"
1404
+ // },
1405
+ // {
1406
+ // "rate": "0.02195928",
1407
+ // "amount": "0.00167952"
1408
+ // },
1409
+ // {
1410
+ // "rate": "0.02196207",
1411
+ // "amount": "0.27704177"
1412
+ // }
1413
+ // ]
1414
+ // }
1415
+ //
1416
+ // partially-filled (open order)
1417
+ //
1418
+ // {
1419
+ // "status": "Ok",
1420
+ // "offerId": "d0ebefab-f4d7-11e9-8c19-0242ac11000a",
1421
+ // "completed": false,
1422
+ // "transactions": [
1423
+ // {
1424
+ // "rate": "0.02106404",
1425
+ // "amount": "0.0019625"
1426
+ // },
1427
+ // {
1428
+ // "rate": "0.02106404",
1429
+ // "amount": "0.0019625"
1430
+ // },
1431
+ // {
1432
+ // "rate": "0.02105901",
1433
+ // "amount": "0.00975256"
1434
+ // }
1435
+ // ]
1436
+ // }
1437
+ //
1438
+ const id = this.safeString2(response, 'offerId', 'stopOfferId');
1439
+ const completed = this.safeValue(response, 'completed', false);
1440
+ const status = completed ? 'closed' : 'open';
1441
+ const transactions = this.safeValue(response, 'transactions');
1442
+ return this.safeOrder({
1443
+ 'id': id,
1444
+ 'info': response,
1445
+ 'timestamp': undefined,
1446
+ 'datetime': undefined,
1447
+ 'lastTradeTimestamp': undefined,
1448
+ 'status': status,
1449
+ 'symbol': symbol,
1450
+ 'type': type,
1451
+ 'side': side,
1452
+ 'price': price,
1453
+ 'amount': amount,
1454
+ 'cost': undefined,
1455
+ 'filled': undefined,
1456
+ 'remaining': undefined,
1457
+ 'average': undefined,
1458
+ 'fee': undefined,
1459
+ 'trades': transactions,
1460
+ 'clientOrderId': undefined,
1461
+ });
1462
+ }
1463
+ async cancelOrder(id, symbol = undefined, params = {}) {
1464
+ /**
1465
+ * @method
1466
+ * @name zonda#cancelOrder
1467
+ * @see https://docs.zondacrypto.exchange/reference/cancel-order
1468
+ * @description cancels an open order
1469
+ * @param {string} id order id
1470
+ * @param {string} symbol unified symbol of the market the order was made in
1471
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1472
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1473
+ */
1474
+ const side = this.safeString(params, 'side');
1475
+ if (side === undefined) {
1476
+ throw new errors.ExchangeError(this.id + ' cancelOrder() requires a `side` parameter ("buy" or "sell")');
1477
+ }
1478
+ const price = this.safeValue(params, 'price');
1479
+ if (price === undefined) {
1480
+ throw new errors.ExchangeError(this.id + ' cancelOrder() requires a `price` parameter (float or string)');
1481
+ }
1482
+ await this.loadMarkets();
1483
+ const market = this.market(symbol);
1484
+ const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1485
+ const request = {
1486
+ 'symbol': tradingSymbol,
1487
+ 'id': id,
1488
+ 'side': side,
1489
+ 'price': price,
1490
+ };
1491
+ // { status: "Fail", errors: [ "NOT_RECOGNIZED_OFFER_TYPE" ] } -- if required params are missing
1492
+ // { status: "Ok", errors: [] }
1493
+ return await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(request, params));
1494
+ }
1495
+ isFiat(currency) {
1496
+ const fiatCurrencies = {
1497
+ 'USD': true,
1498
+ 'EUR': true,
1499
+ 'PLN': true,
1500
+ };
1501
+ return this.safeValue(fiatCurrencies, currency, false);
1502
+ }
1503
+ parseDepositAddress(depositAddress, currency = undefined) {
1504
+ //
1505
+ // {
1506
+ // "address": "33u5YAEhQbYfjHHPsfMfCoSdEjfwYjVcBE",
1507
+ // "currency": "BTC",
1508
+ // "balanceId": "5d5d19e7-2265-49c7-af9a-047bcf384f21",
1509
+ // "balanceEngine": "BITBAY",
1510
+ // "tag": null
1511
+ // }
1512
+ //
1513
+ const currencyId = this.safeString(depositAddress, 'currency');
1514
+ const address = this.safeString(depositAddress, 'address');
1515
+ this.checkAddress(address);
1516
+ return {
1517
+ 'currency': this.safeCurrencyCode(currencyId, currency),
1518
+ 'address': address,
1519
+ 'tag': this.safeString(depositAddress, 'tag'),
1520
+ 'network': undefined,
1521
+ 'info': depositAddress,
1522
+ };
1523
+ }
1524
+ async fetchDepositAddress(code, params = {}) {
1525
+ /**
1526
+ * @method
1527
+ * @name zonda#fetchDepositAddress
1528
+ * @see https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto
1529
+ * @description fetch the deposit address for a currency associated with this account
1530
+ * @param {string} code unified currency code
1531
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1532
+ * @param {string} [params.walletId] Wallet id to filter deposit adresses.
1533
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1534
+ */
1535
+ await this.loadMarkets();
1536
+ const currency = this.currency(code);
1537
+ const request = {
1538
+ 'currency': currency['id'],
1539
+ };
1540
+ const response = await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(this.extend(request, params));
1541
+ //
1542
+ // {
1543
+ // "status": "Ok",
1544
+ // "data": [{
1545
+ // "address": "33u5YAEhQbYfjHHPsfMfCoSdEjfwYjVcBE",
1546
+ // "currency": "BTC",
1547
+ // "balanceId": "5d5d19e7-2265-49c7-af9a-047bcf384f21",
1548
+ // "balanceEngine": "BITBAY",
1549
+ // "tag": null
1550
+ // }
1551
+ // ]
1552
+ // }
1553
+ //
1554
+ const data = this.safeValue(response, 'data');
1555
+ const first = this.safeValue(data, 0);
1556
+ return this.parseDepositAddress(first, currency);
1557
+ }
1558
+ async fetchDepositAddresses(codes = undefined, params = {}) {
1559
+ /**
1560
+ * @method
1561
+ * @name zonda#fetchDepositAddresses
1562
+ * @see https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto
1563
+ * @description fetch deposit addresses for multiple currencies and chain types
1564
+ * @param {string[]|undefined} codes zonda does not support filtering filtering by multiple codes and will ignore this parameter.
1565
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1566
+ * @returns {object} a list of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}
1567
+ */
1568
+ await this.loadMarkets();
1569
+ const response = await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(params);
1570
+ //
1571
+ // {
1572
+ // "status": "Ok",
1573
+ // "data": [{
1574
+ // "address": "33u5YAEhQbYfjHHPsfMfCoSdEjfwYjVcBE",
1575
+ // "currency": "BTC",
1576
+ // "balanceId": "5d5d19e7-2265-49c7-af9a-047bcf384f21",
1577
+ // "balanceEngine": "BITBAY",
1578
+ // "tag": null
1579
+ // }
1580
+ // ]
1581
+ // }
1582
+ //
1583
+ const data = this.safeValue(response, 'data');
1584
+ return this.parseDepositAddresses(data, codes);
1585
+ }
1586
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
1587
+ /**
1588
+ * @method
1589
+ * @name zonda#transfer
1590
+ * @see https://docs.zondacrypto.exchange/reference/internal-transfer
1591
+ * @description transfer currency internally between wallets on the same account
1592
+ * @param {string} code unified currency code
1593
+ * @param {float} amount amount to transfer
1594
+ * @param {string} fromAccount account to transfer from
1595
+ * @param {string} toAccount account to transfer to
1596
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1597
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1598
+ */
1599
+ await this.loadMarkets();
1600
+ const currency = this.currency(code);
1601
+ const request = {
1602
+ 'source': fromAccount,
1603
+ 'destination': toAccount,
1604
+ 'currency': code,
1605
+ 'funds': this.currencyToPrecision(code, amount),
1606
+ };
1607
+ const response = await this.v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestination(this.extend(request, params));
1608
+ //
1609
+ // {
1610
+ // "status": "Ok",
1611
+ // "from": {
1612
+ // "id": "ad9397c5-3bd9-4372-82ba-22da6a90cb56",
1613
+ // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1614
+ // "availableFunds": 0.01803472,
1615
+ // "totalFunds": 0.01804161,
1616
+ // "lockedFunds": 0.00000689,
1617
+ // "currency": "BTC",
1618
+ // "type": "CRYPTO",
1619
+ // "name": "BTC",
1620
+ // "balanceEngine": "BITBAY"
1621
+ // },
1622
+ // "to": {
1623
+ // "id": "01931d52-536b-4ca5-a9f4-be28c86d0cc3",
1624
+ // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1625
+ // "availableFunds": 0.0001,
1626
+ // "totalFunds": 0.0001,
1627
+ // "lockedFunds": 0,
1628
+ // "currency": "BTC",
1629
+ // "type": "CRYPTO",
1630
+ // "name": "Prowizja",
1631
+ // "balanceEngine": "BITBAY"
1632
+ // },
1633
+ // "errors": null
1634
+ // }
1635
+ //
1636
+ const transfer = this.parseTransfer(response, currency);
1637
+ const transferOptions = this.safeValue(this.options, 'transfer', {});
1638
+ const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
1639
+ if (fillResponseFromRequest) {
1640
+ transfer['amount'] = amount;
1641
+ }
1642
+ return transfer;
1643
+ }
1644
+ parseTransfer(transfer, currency = undefined) {
1645
+ //
1646
+ // {
1647
+ // "status": "Ok",
1648
+ // "from": {
1649
+ // "id": "ad9397c5-3bd9-4372-82ba-22da6a90cb56",
1650
+ // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1651
+ // "availableFunds": 0.01803472,
1652
+ // "totalFunds": 0.01804161,
1653
+ // "lockedFunds": 0.00000689,
1654
+ // "currency": "BTC",
1655
+ // "type": "CRYPTO",
1656
+ // "name": "BTC",
1657
+ // "balanceEngine": "BITBAY"
1658
+ // },
1659
+ // "to": {
1660
+ // "id": "01931d52-536b-4ca5-a9f4-be28c86d0cc3",
1661
+ // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1662
+ // "availableFunds": 0.0001,
1663
+ // "totalFunds": 0.0001,
1664
+ // "lockedFunds": 0,
1665
+ // "currency": "BTC",
1666
+ // "type": "CRYPTO",
1667
+ // "name": "Prowizja",
1668
+ // "balanceEngine": "BITBAY"
1669
+ // },
1670
+ // "errors": null
1671
+ // }
1672
+ //
1673
+ const status = this.safeString(transfer, 'status');
1674
+ const fromAccount = this.safeValue(transfer, 'from', {});
1675
+ const fromId = this.safeString(fromAccount, 'id');
1676
+ const to = this.safeValue(transfer, 'to', {});
1677
+ const toId = this.safeString(to, 'id');
1678
+ const currencyId = this.safeString(fromAccount, 'currency');
1679
+ return {
1680
+ 'info': transfer,
1681
+ 'id': undefined,
1682
+ 'timestamp': undefined,
1683
+ 'datetime': undefined,
1684
+ 'currency': this.safeCurrencyCode(currencyId, currency),
1685
+ 'amount': undefined,
1686
+ 'fromAccount': fromId,
1687
+ 'toAccount': toId,
1688
+ 'status': this.parseTransferStatus(status),
1689
+ };
1690
+ }
1691
+ parseTransferStatus(status) {
1692
+ const statuses = {
1693
+ 'Ok': 'ok',
1694
+ 'Fail': 'failed',
1695
+ };
1696
+ return this.safeString(statuses, status, status);
1697
+ }
1698
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
1699
+ /**
1700
+ * @method
1701
+ * @name zonda#withdraw
1702
+ * @see https://docs.zondacrypto.exchange/reference/crypto-withdrawal-1
1703
+ * @description make a withdrawal
1704
+ * @param {string} code unified currency code
1705
+ * @param {float} amount the amount to withdraw
1706
+ * @param {string} address the address to withdraw to
1707
+ * @param {string} tag
1708
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1709
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1710
+ */
1711
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
1712
+ this.checkAddress(address);
1713
+ await this.loadMarkets();
1714
+ let response = undefined;
1715
+ const currency = this.currency(code);
1716
+ const request = {
1717
+ 'currency': currency['id'],
1718
+ 'amount': amount,
1719
+ 'address': address,
1720
+ // request['balanceId'] = params['balanceId']; // Wallet id used for withdrawal. If not provided, any BITBAY wallet with sufficient funds is used. If BITBAYPAY wallet should be used parameter must be explicitly specified.
1721
+ };
1722
+ if (this.isFiat(code)) {
1723
+ // request['swift'] = params['swift']; // Bank identifier, if required.
1724
+ response = await this.v1_01PrivatePostApiPaymentsWithdrawalsFiat(this.extend(request, params));
1725
+ }
1726
+ else {
1727
+ if (tag !== undefined) {
1728
+ request['tag'] = tag;
1729
+ }
1730
+ response = await this.v1_01PrivatePostApiPaymentsWithdrawalsCrypto(this.extend(request, params));
1731
+ }
1732
+ //
1733
+ // {
1734
+ // "status": "Ok",
1735
+ // "data": {
1736
+ // "id": "65e01087-afb0-4ab2-afdb-cc925e360296"
1737
+ // }
1738
+ // }
1739
+ //
1740
+ const data = this.safeValue(response, 'data');
1741
+ return this.parseTransaction(data, currency);
1742
+ }
1743
+ parseTransaction(transaction, currency = undefined) {
1744
+ //
1745
+ // withdraw
1746
+ //
1747
+ // {
1748
+ // "id": "65e01087-afb0-4ab2-afdb-cc925e360296"
1749
+ // }
1750
+ //
1751
+ currency = this.safeCurrency(undefined, currency);
1752
+ return {
1753
+ 'id': this.safeString(transaction, 'id'),
1754
+ 'txid': undefined,
1755
+ 'timestamp': undefined,
1756
+ 'datetime': undefined,
1757
+ 'network': undefined,
1758
+ 'addressFrom': undefined,
1759
+ 'address': undefined,
1760
+ 'addressTo': undefined,
1761
+ 'amount': undefined,
1762
+ 'type': undefined,
1763
+ 'currency': currency['code'],
1764
+ 'status': undefined,
1765
+ 'updated': undefined,
1766
+ 'tagFrom': undefined,
1767
+ 'tag': undefined,
1768
+ 'tagTo': undefined,
1769
+ 'comment': undefined,
1770
+ 'internal': undefined,
1771
+ 'fee': undefined,
1772
+ 'info': transaction,
1773
+ };
1774
+ }
1775
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1776
+ let url = this.implodeHostname(this.urls['api'][api]);
1777
+ if (api === 'public') {
1778
+ const query = this.omit(params, this.extractParams(path));
1779
+ url += '/' + this.implodeParams(path, params) + '.json';
1780
+ if (Object.keys(query).length) {
1781
+ url += '?' + this.urlencode(query);
1782
+ }
1783
+ }
1784
+ else if (api === 'v1_01Public') {
1785
+ const query = this.omit(params, this.extractParams(path));
1786
+ url += '/' + this.implodeParams(path, params);
1787
+ if (Object.keys(query).length) {
1788
+ url += '?' + this.urlencode(query);
1789
+ }
1790
+ }
1791
+ else if (api === 'v1_01Private') {
1792
+ this.checkRequiredCredentials();
1793
+ const query = this.omit(params, this.extractParams(path));
1794
+ url += '/' + this.implodeParams(path, params);
1795
+ const nonce = this.milliseconds().toString();
1796
+ let payload = undefined;
1797
+ if (method !== 'POST') {
1798
+ if (Object.keys(query).length) {
1799
+ url += '?' + this.urlencode(query);
1800
+ }
1801
+ payload = this.apiKey + nonce;
1802
+ }
1803
+ else if (body === undefined) {
1804
+ body = this.json(query);
1805
+ payload = this.apiKey + nonce + body;
1806
+ }
1807
+ headers = {
1808
+ 'Request-Timestamp': nonce,
1809
+ 'Operation-Id': this.uuid(),
1810
+ 'API-Key': this.apiKey,
1811
+ 'API-Hash': this.hmac(this.encode(payload), this.encode(this.secret), sha512.sha512),
1812
+ 'Content-Type': 'application/json',
1813
+ };
1814
+ }
1815
+ else {
1816
+ this.checkRequiredCredentials();
1817
+ body = this.urlencode(this.extend({
1818
+ 'method': path,
1819
+ 'moment': this.nonce(),
1820
+ }, params));
1821
+ headers = {
1822
+ 'Content-Type': 'application/x-www-form-urlencoded',
1823
+ 'API-Key': this.apiKey,
1824
+ 'API-Hash': this.hmac(this.encode(body), this.encode(this.secret), sha512.sha512),
1825
+ };
1826
+ }
1827
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1828
+ }
1829
+ handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1830
+ if (response === undefined) {
1831
+ return undefined; // fallback to default error handler
1832
+ }
1833
+ if ('code' in response) {
1834
+ //
1835
+ // bitbay returns the integer "success": 1 key from their private API
1836
+ // or an integer "code" value from 0 to 510 and an error message
1837
+ //
1838
+ // { "success": 1, ... }
1839
+ // { 'code': 502, "message": "Invalid sign" }
1840
+ // { 'code': 0, "message": "offer funds not exceeding minimums" }
1841
+ //
1842
+ // 400 At least one parameter wasn't set
1843
+ // 401 Invalid order type
1844
+ // 402 No orders with specified currencies
1845
+ // 403 Invalid payment currency name
1846
+ // 404 Error. Wrong transaction type
1847
+ // 405 Order with this id doesn't exist
1848
+ // 406 No enough money or crypto
1849
+ // 408 Invalid currency name
1850
+ // 501 Invalid public key
1851
+ // 502 Invalid sign
1852
+ // 503 Invalid moment parameter. Request time doesn't match current server time
1853
+ // 504 Invalid method
1854
+ // 505 Key has no permission for this action
1855
+ // 506 Account locked. Please contact with customer service
1856
+ // 509 The BIC/SWIFT is required for this currency
1857
+ // 510 Invalid market name
1858
+ //
1859
+ const code = this.safeString(response, 'code'); // always an integer
1860
+ const feedback = this.id + ' ' + body;
1861
+ this.throwExactlyMatchedException(this.exceptions, code, feedback);
1862
+ throw new errors.ExchangeError(feedback);
1863
+ }
1864
+ else if ('status' in response) {
1865
+ //
1866
+ // {"status":"Fail","errors":["OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS"]}
1867
+ //
1868
+ const status = this.safeString(response, 'status');
1869
+ if (status === 'Fail') {
1870
+ const errors$1 = this.safeValue(response, 'errors');
1871
+ const feedback = this.id + ' ' + body;
1872
+ for (let i = 0; i < errors$1.length; i++) {
1873
+ const error = errors$1[i];
1874
+ this.throwExactlyMatchedException(this.exceptions, error, feedback);
1875
+ }
1876
+ throw new errors.ExchangeError(feedback);
1877
+ }
1878
+ }
1879
+ return undefined;
1880
+ }
1881
+ }
1882
+
1883
+ module.exports = zonda;