ccxt 4.2.11 → 4.2.13

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 (392) hide show
  1. package/README.md +5 -5
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +1347 -490
  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 +2209 -0
  125. package/dist/cjs/js/src/binance.js +9736 -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 +3807 -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 +8291 -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 +3424 -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 +7072 -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 +9049 -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 +761 -0
  185. package/dist/cjs/js/src/indodax.js +1069 -0
  186. package/dist/cjs/js/src/kraken.js +2857 -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 +2851 -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 +7330 -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 +4722 -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 +1608 -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 +1867 -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 +2765 -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/bingx.d.ts +2 -0
  336. package/js/src/abstract/bybit.d.ts +1 -0
  337. package/js/src/abstract/gate.d.ts +11 -0
  338. package/js/src/abstract/gateio.d.ts +11 -0
  339. package/js/src/abstract/okx.d.ts +1 -0
  340. package/js/src/alpaca.js +18 -18
  341. package/js/src/base/Exchange.d.ts +5 -1
  342. package/js/src/base/Exchange.js +101 -12
  343. package/js/src/bigone.d.ts +3 -2
  344. package/js/src/bigone.js +429 -167
  345. package/js/src/binance.js +48 -34
  346. package/js/src/bingx.js +115 -38
  347. package/js/src/bitfinex.d.ts +2 -2
  348. package/js/src/bitfinex.js +2 -3
  349. package/js/src/bitget.js +33 -13
  350. package/js/src/bitmart.d.ts +2 -2
  351. package/js/src/bitmart.js +5 -5
  352. package/js/src/bitmex.js +1 -0
  353. package/js/src/bybit.js +2 -0
  354. package/js/src/coinbase.d.ts +26 -3
  355. package/js/src/coinbase.js +176 -26
  356. package/js/src/coinlist.js +3 -4
  357. package/js/src/coinone.js +1 -1
  358. package/js/src/coinsph.js +2 -3
  359. package/js/src/deribit.js +1 -0
  360. package/js/src/gate.d.ts +4 -4
  361. package/js/src/gate.js +96 -59
  362. package/js/src/gemini.js +1 -1
  363. package/js/src/hitbtc.d.ts +4 -4
  364. package/js/src/hitbtc.js +2 -3
  365. package/js/src/htx.d.ts +1 -0
  366. package/js/src/htx.js +29 -7
  367. package/js/src/huobijp.js +2 -3
  368. package/js/src/independentreserve.js +7 -5
  369. package/js/src/kraken.js +3 -6
  370. package/js/src/lbank.js +59 -33
  371. package/js/src/mexc.js +2 -1
  372. package/js/src/oceanex.js +1 -1
  373. package/js/src/okx.js +14 -3
  374. package/js/src/phemex.js +9 -2
  375. package/js/src/pro/binance.d.ts +2 -23
  376. package/js/src/pro/binance.js +58 -22
  377. package/js/src/pro/coinbase.d.ts +2 -2
  378. package/js/src/pro/coinbase.js +4 -1
  379. package/js/src/pro/coinbasepro.d.ts +2 -2
  380. package/js/src/pro/hitbtc.d.ts +2 -2
  381. package/js/src/pro/kraken.js +1 -1
  382. package/js/src/pro/okx.d.ts +1 -0
  383. package/js/src/pro/okx.js +52 -2
  384. package/js/src/pro/poloniex.d.ts +2 -2
  385. package/js/src/probit.js +4 -2
  386. package/js/src/upbit.d.ts +3 -101
  387. package/js/src/upbit.js +12 -12
  388. package/js/src/wavesexchange.js +1 -1
  389. package/js/src/woo.d.ts +2 -0
  390. package/js/src/woo.js +52 -0
  391. package/package.json +1 -1
  392. package/skip-tests.json +5 -0
@@ -0,0 +1,1303 @@
1
+ 'use strict';
2
+
3
+ var lykke$1 = require('./abstract/lykke.js');
4
+ var errors = require('./base/errors.js');
5
+ var Precise = require('./base/Precise.js');
6
+ var number = require('./base/functions/number.js');
7
+
8
+ // ---------------------------------------------------------------------------
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class lykke
12
+ * @augments Exchange
13
+ */
14
+ class lykke extends lykke$1 {
15
+ describe() {
16
+ return this.deepExtend(super.describe(), {
17
+ 'id': 'lykke',
18
+ 'name': 'Lykke',
19
+ 'countries': ['UK'],
20
+ 'version': '2',
21
+ // 300 requests per minute per method => 60000ms / 300 = 200 (/api/orders/*)
22
+ // 120 requests per minute per method => ( 60000ms / rateLimit ) / 120 = cost = 2.5 (/api/*)
23
+ 'rateLimit': 200,
24
+ 'has': {
25
+ 'CORS': undefined,
26
+ 'spot': true,
27
+ 'margin': false,
28
+ 'swap': false,
29
+ 'future': false,
30
+ 'option': false,
31
+ 'cancelAllOrders': true,
32
+ 'cancelOrder': true,
33
+ 'createOrder': true,
34
+ 'createStopLimitOrder': false,
35
+ 'createStopMarketOrder': false,
36
+ 'createStopOrder': false,
37
+ 'editOrder': false,
38
+ 'fetchBalance': true,
39
+ 'fetchBorrowRateHistories': false,
40
+ 'fetchBorrowRateHistory': false,
41
+ 'fetchClosedOrders': true,
42
+ 'fetchCrossBorrowRate': false,
43
+ 'fetchCrossBorrowRates': false,
44
+ 'fetchCurrencies': true,
45
+ 'fetchDepositAddress': true,
46
+ 'fetchDeposits': false,
47
+ 'fetchDepositsWithdrawals': true,
48
+ 'fetchFundingHistory': false,
49
+ 'fetchFundingRate': false,
50
+ 'fetchFundingRateHistory': false,
51
+ 'fetchFundingRates': false,
52
+ 'fetchIndexOHLCV': false,
53
+ 'fetchIsolatedBorrowRate': false,
54
+ 'fetchIsolatedBorrowRates': false,
55
+ 'fetchMarginMode': false,
56
+ 'fetchMarkets': true,
57
+ 'fetchMarkOHLCV': false,
58
+ 'fetchMyTrades': true,
59
+ 'fetchOHLCV': undefined,
60
+ 'fetchOpenInterestHistory': false,
61
+ 'fetchOpenOrders': true,
62
+ 'fetchOrder': true,
63
+ 'fetchOrderBook': true,
64
+ 'fetchOrders': false,
65
+ 'fetchOrderTrades': false,
66
+ 'fetchPositionMode': false,
67
+ 'fetchPositions': false,
68
+ 'fetchPremiumIndexOHLCV': false,
69
+ 'fetchTicker': true,
70
+ 'fetchTickers': true,
71
+ 'fetchTime': false,
72
+ 'fetchTrades': true,
73
+ 'fetchTradingFee': false,
74
+ 'fetchTradingFees': false,
75
+ 'fetchTransactionFees': false,
76
+ 'fetchTransactions': 'emulated',
77
+ 'fetchWithdrawals': false,
78
+ 'setLeverage': false,
79
+ 'setMarginMode': false,
80
+ 'withdraw': true,
81
+ },
82
+ 'requiredCredentials': {
83
+ 'apiKey': true,
84
+ 'secret': false,
85
+ },
86
+ 'urls': {
87
+ 'logo': 'https://user-images.githubusercontent.com/1294454/155840500-1ea4fdf0-47c0-4daa-9597-c6c1cd51b9ec.jpg',
88
+ 'api': {
89
+ 'public': 'https://hft-apiv2.lykke.com/api',
90
+ 'private': 'https://hft-apiv2.lykke.com/api',
91
+ },
92
+ 'www': 'https://www.lykke.com',
93
+ 'doc': [
94
+ 'https://hft-apiv2.lykke.com/swagger/ui/index.html',
95
+ 'https://lykkecity.github.io/Trading-API',
96
+ ],
97
+ 'fees': 'https://support.lykke.com/hc/en-us/articles/115002141125-What-are-the-fees-and-charges-', // zero fee
98
+ },
99
+ 'api': {
100
+ 'public': {
101
+ 'get': {
102
+ 'assetpairs': 2.5,
103
+ 'assetpairs/{id}': 2.5,
104
+ 'assets': 2.5,
105
+ 'assets/{id}': 2.5,
106
+ 'isalive': 2.5,
107
+ 'orderbooks': 2.5,
108
+ 'tickers': 2.5,
109
+ 'prices': 2.5,
110
+ 'trades/public/{assetPairId}': 2.5,
111
+ },
112
+ },
113
+ 'private': {
114
+ 'get': {
115
+ 'balance': 2.5,
116
+ 'trades': 2.5,
117
+ 'trades/order/{orderId}': 2.5,
118
+ 'orders/active': 1,
119
+ 'orders/closed': 1,
120
+ 'orders/{orderId}': 1,
121
+ 'operations': 2.5,
122
+ 'operations/deposits/addresses': 2.5,
123
+ 'operations/deposits/addresses/{assetId}': 2.5,
124
+ },
125
+ 'post': {
126
+ 'orders/limit': 1,
127
+ 'orders/market': 1,
128
+ 'orders/bulk': 1,
129
+ 'operations/withdrawals': 2.5,
130
+ 'operations/deposits/addresses': 2.5,
131
+ },
132
+ 'delete': {
133
+ 'orders': 1,
134
+ 'orders/{orderId}': 1,
135
+ },
136
+ },
137
+ },
138
+ 'fees': {
139
+ 'trading': {
140
+ 'tierBased': false,
141
+ 'percentage': true,
142
+ 'maker': 0,
143
+ 'taker': 0,
144
+ },
145
+ },
146
+ 'precisionMode': number.TICK_SIZE,
147
+ 'exceptions': {
148
+ 'exact': {
149
+ '1001': errors.ExchangeError,
150
+ '1100': errors.ExchangeError,
151
+ '1101': errors.ExchangeError,
152
+ '2000': errors.BadRequest,
153
+ '2001': errors.InsufficientFunds,
154
+ '2202': errors.DuplicateOrderId,
155
+ '2003': errors.ExchangeError,
156
+ '2004': errors.NotSupported,
157
+ '2005': errors.ExchangeError,
158
+ '2006': errors.InsufficientFunds,
159
+ '2007': errors.InsufficientFunds,
160
+ '2008': errors.InsufficientFunds,
161
+ '2009': errors.ExchangeError,
162
+ '2010': errors.InsufficientFunds,
163
+ '2011': errors.InvalidOrder,
164
+ '2012': errors.InvalidOrder,
165
+ '2013': errors.InvalidOrder,
166
+ '2014': errors.InvalidOrder,
167
+ '2015': errors.InvalidOrder,
168
+ '2016': errors.InvalidOrder,
169
+ '2017': errors.InvalidOrder,
170
+ '2018': errors.InvalidOrder,
171
+ '2019': errors.InvalidOrder,
172
+ '2020': errors.InvalidOrder,
173
+ '2021': errors.InvalidOrder,
174
+ '2022': errors.InvalidOrder,
175
+ '2023': errors.ExchangeError,
176
+ },
177
+ 'broad': {},
178
+ },
179
+ 'commonCurrencies': {},
180
+ });
181
+ }
182
+ async fetchCurrencies(params = {}) {
183
+ /**
184
+ * @method
185
+ * @name lykke#fetchCurrencies
186
+ * @description fetches all available currencies on an exchange
187
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
188
+ * @returns {object} an associative dictionary of currencies
189
+ */
190
+ const response = await this.publicGetAssets(params);
191
+ const currencies = this.safeValue(response, 'payload', []);
192
+ //
193
+ // {
194
+ // "payload":[
195
+ // {
196
+ // "assetId":"115a60c2-0da1-40f9-a7f2-41da723b9074",
197
+ // "name":"Monaco Token",
198
+ // "symbol":"MCO",
199
+ // "accuracy":6,
200
+ // "multiplierPower":8,
201
+ // "assetAddress":"",
202
+ // "blockchainIntegrationLayerId":"",
203
+ // "blockchain":"ethereum",
204
+ // "type":"erc20Token",
205
+ // "isTradable":true,
206
+ // "isTrusted":true,
207
+ // "kycNeeded":false,
208
+ // "blockchainWithdrawal":true,
209
+ // "cashoutMinimalAmount":0.1,
210
+ // "lowVolumeAmount":null,
211
+ // "lykkeEntityId":"LYKKE NL",
212
+ // "siriusAssetId":0,
213
+ // "siriusBlockchainId":null,
214
+ // "blockchainIntegrationType":"none",
215
+ // "blockchainDepositEnabled":false,
216
+ // "isDisabled":false
217
+ // }
218
+ // ],
219
+ // "error":null
220
+ // }
221
+ //
222
+ const result = {};
223
+ for (let i = 0; i < currencies.length; i++) {
224
+ const currency = currencies[i];
225
+ const id = this.safeString(currency, 'assetId');
226
+ const code = this.safeString(currency, 'symbol');
227
+ const name = this.safeString(currency, 'name');
228
+ const rawType = this.safeString(currency, 'type');
229
+ const type = (rawType === 'erc20Token') ? 'crypto' : 'other';
230
+ const deposit = this.safeValue(currency, 'blockchainDepositEnabled');
231
+ const withdraw = this.safeValue(currency, 'blockchainWithdrawal');
232
+ const isDisabled = this.safeValue(currency, 'isDisabled');
233
+ const active = !isDisabled;
234
+ result[code] = {
235
+ 'id': id,
236
+ 'code': code,
237
+ 'info': currency,
238
+ 'type': type,
239
+ 'name': name,
240
+ 'active': active,
241
+ 'deposit': deposit,
242
+ 'withdraw': withdraw,
243
+ 'fee': undefined,
244
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'accuracy'))),
245
+ 'limits': {
246
+ 'withdraw': {
247
+ 'min': this.safeValue(currency, 'cashoutMinimalAmount'),
248
+ 'max': undefined,
249
+ },
250
+ 'amount': {
251
+ 'min': this.safeValue(currency, 'lowVolumeAmount'),
252
+ 'max': undefined,
253
+ },
254
+ },
255
+ 'networks': {},
256
+ };
257
+ }
258
+ return result;
259
+ }
260
+ async fetchMarkets(params = {}) {
261
+ /**
262
+ * @method
263
+ * @name lykke#fetchMarkets
264
+ * @description retrieves data on all markets for lykke
265
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
266
+ * @returns {object[]} an array of objects representing market data
267
+ */
268
+ const response = await this.publicGetAssetpairs(params);
269
+ const markets = this.safeValue(response, 'payload', []);
270
+ //
271
+ // {
272
+ // "payload":[
273
+ // {
274
+ // "assetPairId":"AAVEBTC",
275
+ // "baseAssetId":"c9e55548-dae5-44fc-bebd-e72249cb19f3",
276
+ // "quoteAssetId":"BTC",
277
+ // "name":"AAVE/BTC",
278
+ // "priceAccuracy":6,
279
+ // "baseAssetAccuracy":6,
280
+ // "quoteAssetAccuracy":8,
281
+ // "minVolume":0.001,
282
+ // "minOppositeVolume":0.0001
283
+ // }
284
+ // ],
285
+ // "error":null
286
+ // }
287
+ //
288
+ const result = [];
289
+ for (let i = 0; i < markets.length; i++) {
290
+ const market = markets[i];
291
+ const id = this.safeString(market, 'assetPairId');
292
+ const name = this.safeString(market, 'name');
293
+ const baseAssetId = this.safeString(market, 'baseAssetId');
294
+ const quoteAssetId = this.safeString(market, 'quoteAssetId');
295
+ const [baseId, quoteId] = name.split('/');
296
+ const base = this.safeCurrencyCode(baseId);
297
+ const quote = this.safeCurrencyCode(quoteId);
298
+ const symbol = base + '/' + quote;
299
+ result.push({
300
+ 'id': id,
301
+ 'symbol': symbol,
302
+ 'base': base,
303
+ 'quote': quote,
304
+ 'baseId': baseAssetId,
305
+ 'quoteId': quoteAssetId,
306
+ 'settle': undefined,
307
+ 'settleId': undefined,
308
+ 'type': 'spot',
309
+ 'spot': true,
310
+ 'margin': false,
311
+ 'swap': false,
312
+ 'future': false,
313
+ 'option': false,
314
+ 'contract': false,
315
+ 'active': true,
316
+ 'linear': undefined,
317
+ 'inverse': undefined,
318
+ 'contractSize': undefined,
319
+ 'expiry': undefined,
320
+ 'expiryDatetime': undefined,
321
+ 'strike': undefined,
322
+ 'optionType': undefined,
323
+ 'precision': {
324
+ 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'baseAssetAccuracy'))),
325
+ 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'priceAccuracy'))),
326
+ },
327
+ 'limits': {
328
+ 'amount': {
329
+ 'min': this.safeNumber(market, 'minVolume'),
330
+ 'max': undefined,
331
+ },
332
+ 'price': {
333
+ 'min': undefined,
334
+ 'max': undefined,
335
+ },
336
+ 'cost': {
337
+ 'min': this.safeNumber(market, 'minOppositeVolume'),
338
+ 'max': undefined,
339
+ },
340
+ 'leverage': {
341
+ 'min': undefined,
342
+ 'max': undefined,
343
+ },
344
+ },
345
+ 'created': undefined,
346
+ 'info': market,
347
+ });
348
+ }
349
+ return result;
350
+ }
351
+ parseTicker(ticker, market = undefined) {
352
+ //
353
+ // fetchTickers
354
+ //
355
+ // publicGetTickers
356
+ //
357
+ // {
358
+ // "assetPairId":"BTCUSD",
359
+ // "volumeBase":2.56905016,
360
+ // "volumeQuote":95653.8730,
361
+ // "priceChange":-0.0367945778541765034194707584,
362
+ // "lastPrice":36840.0,
363
+ // "high":38371.645,
364
+ // "low":35903.356,
365
+ // "timestamp":1643295740729
366
+ // }
367
+ //
368
+ // fetchTicker
369
+ //
370
+ // publicGetTickers
371
+ //
372
+ // {
373
+ // "assetPairId":"BTCUSD",
374
+ // "volumeBase":2.56905016,
375
+ // "volumeQuote":95653.8730,
376
+ // "priceChange":-0.0367945778541765034194707584,
377
+ // "lastPrice":36840.0,
378
+ // "high":38371.645,
379
+ // "low":35903.356,
380
+ // "timestamp":1643295740729
381
+ // }
382
+ //
383
+ // publicGetPrices
384
+ //
385
+ // {
386
+ // "assetPairId":"BTCUSD",
387
+ // "bid":36181.521,
388
+ // "ask":36244.492,
389
+ // "timestamp":1643305510990
390
+ // }
391
+ //
392
+ const timestamp = undefined; // temporary bug in lykke api, returns unrealistic numbers
393
+ const marketId = this.safeString(ticker, 'assetPairId');
394
+ market = this.safeMarket(marketId, market);
395
+ const close = this.safeString(ticker, 'lastPrice');
396
+ return this.safeTicker({
397
+ 'symbol': this.safeString(market, 'symbol'),
398
+ 'timestamp': timestamp,
399
+ 'datetime': this.iso8601(timestamp),
400
+ 'high': this.safeString(ticker, 'high'),
401
+ 'low': this.safeString(ticker, 'low'),
402
+ 'bid': this.safeString(ticker, 'bid'),
403
+ 'bidVolume': undefined,
404
+ 'ask': this.safeString(ticker, 'ask'),
405
+ 'askVolume': undefined,
406
+ 'vwap': undefined,
407
+ 'open': undefined,
408
+ 'close': close,
409
+ 'last': close,
410
+ 'previousClose': undefined,
411
+ 'change': this.safeString(ticker, 'priceChange'),
412
+ 'percentage': undefined,
413
+ 'average': undefined,
414
+ 'baseVolume': this.safeString(ticker, 'volumeBase'),
415
+ 'quoteVolume': this.safeString(ticker, 'volumeQuote'),
416
+ 'info': ticker,
417
+ }, market);
418
+ }
419
+ async fetchTicker(symbol, params = {}) {
420
+ /**
421
+ * @method
422
+ * @name lykke#fetchTicker
423
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
424
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
425
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
426
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
427
+ */
428
+ await this.loadMarkets();
429
+ const market = this.market(symbol);
430
+ const request = {
431
+ 'assetPairIds': market['id'],
432
+ };
433
+ // publicGetTickers or publicGetPrices
434
+ const method = this.safeString(this.options, 'fetchTickerMethod', 'publicGetTickers');
435
+ let response = undefined;
436
+ if (method === 'publicGetPrices') {
437
+ response = await this.publicGetPrices(this.extend(request, params));
438
+ }
439
+ else {
440
+ response = await this.publicGetTickers(this.extend(request, params));
441
+ }
442
+ const ticker = this.safeValue(response, 'payload', []);
443
+ //
444
+ // publicGetTickers
445
+ //
446
+ // {
447
+ // "payload":[
448
+ // {
449
+ // "assetPairId":"BTCUSD",
450
+ // "volumeBase":0.78056880,
451
+ // "volumeQuote":29782.5169,
452
+ // "priceChange":0.0436602362590968619931324699,
453
+ // "lastPrice":38626.885,
454
+ // "high":38742.896,
455
+ // "low":36872.498,
456
+ // "timestamp":1643687822840
457
+ // }
458
+ // ],
459
+ // "error":null
460
+ // }
461
+ //
462
+ // publicGetPrices
463
+ //
464
+ // {
465
+ // "payload":[
466
+ // {
467
+ // "assetPairId":"BTCUSD",
468
+ // "bid":38597.936,
469
+ // "ask":38640.311,
470
+ // "timestamp":1643688350847
471
+ // }
472
+ // ],
473
+ // "error":null
474
+ // }
475
+ //
476
+ return this.parseTicker(this.safeValue(ticker, 0, {}), market);
477
+ }
478
+ async fetchTickers(symbols = undefined, params = {}) {
479
+ /**
480
+ * @method
481
+ * @name lykke#fetchTickers
482
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
483
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
484
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
485
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
486
+ */
487
+ await this.loadMarkets();
488
+ const response = await this.publicGetTickers(params);
489
+ const tickers = this.safeValue(response, 'payload', []);
490
+ //
491
+ // {
492
+ // "payload":[
493
+ // {
494
+ // "assetPairId":"BTCUSD",
495
+ // "volumeBase":0.78056880,
496
+ // "volumeQuote":29782.5169,
497
+ // "priceChange":0.0436602362590968619931324699,
498
+ // "lastPrice":38626.885,
499
+ // "high":38742.896,
500
+ // "low":36872.498,
501
+ // "timestamp":1643687822840
502
+ // }
503
+ // ],
504
+ // "error":null
505
+ // }
506
+ //
507
+ return this.parseTickers(tickers, symbols);
508
+ }
509
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
510
+ /**
511
+ * @method
512
+ * @name lykke#fetchOrderBook
513
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
514
+ * @param {string} symbol unified symbol of the market to fetch the order book for
515
+ * @param {int} [limit] the maximum amount of order book entries to return
516
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
517
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
518
+ */
519
+ await this.loadMarkets();
520
+ const market = this.market(symbol);
521
+ const request = {
522
+ 'assetPairId': market['id'],
523
+ };
524
+ if (limit !== undefined) {
525
+ request['depth'] = limit; // default 0
526
+ }
527
+ const response = await this.publicGetOrderbooks(this.extend(request, params));
528
+ const payload = this.safeValue(response, 'payload', []);
529
+ //
530
+ // {
531
+ // "payload":[
532
+ // {
533
+ // "assetPairId": "BTCUSD",
534
+ // "timestamp": "1643298038203",
535
+ // "bids": [
536
+ // {
537
+ // "v":0.59034382,
538
+ // "p":36665.329
539
+ // }
540
+ // ],
541
+ // "asks": [
542
+ // {
543
+ // "v":-0.003,
544
+ // "p":36729.686
545
+ // }
546
+ // ]
547
+ // }
548
+ // ],
549
+ // "error":null
550
+ // }
551
+ //
552
+ const orderbook = this.safeValue(payload, 0, {});
553
+ const timestamp = this.safeInteger(orderbook, 'timestamp');
554
+ return this.parseOrderBook(orderbook, market['symbol'], timestamp, 'bids', 'asks', 'p', 'v');
555
+ }
556
+ parseTrade(trade, market = undefined) {
557
+ //
558
+ // public fetchTrades
559
+ //
560
+ // {
561
+ // "id":"71df1f0c-be4e-4d45-b809-c108fad5f2a8",
562
+ // "assetPairId":"BTCUSD",
563
+ // "timestamp":1643345958414,
564
+ // "volume":0.00010996,
565
+ // "price":37205.723,
566
+ // "side":"buy"
567
+ // }
568
+ //
569
+ // private fetchMyTrades
570
+ // {
571
+ // "id":"813a3ffa-1c4b-45cb-b13f-1c077ea2748b",
572
+ // "timestamp":1644155923357,
573
+ // "assetPairId":"BCHEUR",
574
+ // "orderId":"1b367978-7e4f-454b-b870-64040d484443",
575
+ // "role":"Taker",
576
+ // "side":"sell",
577
+ // "price":280.569,
578
+ // "baseVolume":0.01,
579
+ // "quoteVolume":2.8056,
580
+ // "baseAssetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
581
+ // "quoteAssetId":"EUR",
582
+ // "fee":null
583
+ // }
584
+ //
585
+ const marketId = this.safeString(trade, 'assetPairId');
586
+ market = this.safeMarket(marketId, market);
587
+ const symbol = market['symbol'];
588
+ const id = this.safeString2(trade, 'id', 'id');
589
+ const orderId = this.safeString(trade, 'orderId');
590
+ const timestamp = this.safeInteger(trade, 'timestamp');
591
+ const price = this.safeString2(trade, 'price', 'price');
592
+ let amount = this.safeString2(trade, 'volume', 'amount');
593
+ if (amount === undefined) {
594
+ amount = this.safeString2(trade, 'baseVolume', 'amount');
595
+ }
596
+ const side = this.safeStringLower(trade, 'side');
597
+ return this.safeTrade({
598
+ 'id': id,
599
+ 'info': trade,
600
+ 'timestamp': timestamp,
601
+ 'datetime': this.iso8601(timestamp),
602
+ 'symbol': symbol,
603
+ 'type': undefined,
604
+ 'order': orderId,
605
+ 'side': side,
606
+ 'takerOrMaker': undefined,
607
+ 'price': price,
608
+ 'amount': amount,
609
+ 'cost': undefined,
610
+ 'fee': undefined,
611
+ }, market);
612
+ }
613
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
614
+ /**
615
+ * @method
616
+ * @name lykke#fetchTrades
617
+ * @description get the list of most recent trades for a particular symbol
618
+ * @param {string} symbol unified symbol of the market to fetch trades for
619
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
620
+ * @param {int} [limit] the maximum amount of trades to fetch
621
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
622
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
623
+ */
624
+ await this.loadMarkets();
625
+ const market = this.market(symbol);
626
+ const request = {
627
+ 'assetPairId': market['id'],
628
+ // 'offset': 0,
629
+ };
630
+ if (limit !== undefined) {
631
+ request['take'] = limit;
632
+ }
633
+ const response = await this.publicGetTradesPublicAssetPairId(this.extend(request, params));
634
+ const result = this.safeValue(response, 'payload', []);
635
+ //
636
+ // {
637
+ // "payload":[
638
+ // {
639
+ // "id":"71df1f0c-be4e-4d45-b809-c108fad5f2a8",
640
+ // "assetPairId":"BTCUSD",
641
+ // "timestamp":1643345958414,
642
+ // "volume":0.00010996,
643
+ // "price":37205.723,
644
+ // "side":"buy"
645
+ // }
646
+ // ],
647
+ // "error":null
648
+ // }
649
+ //
650
+ return this.parseTrades(result, market, since, limit);
651
+ }
652
+ parseBalance(response) {
653
+ //
654
+ // [
655
+ // {
656
+ // "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
657
+ // "available":0.1,
658
+ // "reserved":0.0,
659
+ // "timestamp":1644146723620
660
+ // }
661
+ // ]
662
+ //
663
+ const result = { 'info': response };
664
+ for (let i = 0; i < response.length; i++) {
665
+ const balance = response[i];
666
+ const currencyId = this.safeString(balance, 'assetId');
667
+ const code = this.safeCurrencyCode(currencyId);
668
+ const account = this.account();
669
+ const free = this.safeString(balance, 'available');
670
+ const used = this.safeString(balance, 'reserved');
671
+ account['free'] = free;
672
+ account['used'] = used;
673
+ result[code] = account;
674
+ }
675
+ return this.safeBalance(result);
676
+ }
677
+ async fetchBalance(params = {}) {
678
+ /**
679
+ * @method
680
+ * @name lykke#fetchBalance
681
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
682
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
683
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
684
+ */
685
+ await this.loadMarkets();
686
+ const response = await this.privateGetBalance(params);
687
+ const payload = this.safeValue(response, 'payload', []);
688
+ //
689
+ // {
690
+ // "payload":[
691
+ // {
692
+ // "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
693
+ // "available":0.1,
694
+ // "reserved":0.0,
695
+ // "timestamp":1644146723620
696
+ // }
697
+ // ],
698
+ // "error":null
699
+ // }
700
+ //
701
+ return this.parseBalance(payload);
702
+ }
703
+ parseOrderStatus(status) {
704
+ const statuses = {
705
+ 'Open': 'open',
706
+ 'Pending': 'open',
707
+ 'InOrderBook': 'open',
708
+ 'Processing': 'open',
709
+ 'Matched': 'closed',
710
+ 'Cancelled': 'canceled',
711
+ 'Rejected': 'rejected',
712
+ 'Replaced': 'canceled',
713
+ 'Placed': 'open',
714
+ };
715
+ return this.safeString(statuses, status, status);
716
+ }
717
+ parseOrder(order, market = undefined) {
718
+ //
719
+ // {
720
+ // "id":"1b367978-7e4f-454b-b870-64040d484443",
721
+ // "timestamp":1644155923357,
722
+ // "lastTradeTimestamp":1644155923357,
723
+ // "status":"Matched",
724
+ // "assetPairId":"BCHEUR",
725
+ // "type":"Market",
726
+ // "side":"Sell",
727
+ // "price":280.569,
728
+ // "volume":0.01,
729
+ // "filledVolume":0.01,
730
+ // "remainingVolume":0.0,
731
+ // "cost":2.80569
732
+ // }
733
+ //
734
+ const id = this.safeString(order, 'id');
735
+ const status = this.parseOrderStatus(this.safeString(order, 'status'));
736
+ const marketId = this.safeString(order, 'assetPairId');
737
+ const symbol = this.safeSymbol(marketId, market);
738
+ const type = this.safeStringLower(order, 'type');
739
+ const lastTradeTimestamp = this.safeInteger(order, 'lastTradeTimestamp');
740
+ const timestamp = this.safeInteger(order, 'timestamp');
741
+ const price = this.safeString(order, 'price');
742
+ const side = this.safeStringLower(order, 'side');
743
+ const amount = this.safeString(order, 'volume');
744
+ const remaining = this.safeString(order, 'remainingVolume');
745
+ const filled = this.safeString(order, 'filledVolume');
746
+ const cost = this.safeString(order, 'cost');
747
+ return this.safeOrder({
748
+ 'info': order,
749
+ 'id': id,
750
+ 'clientOrderId': undefined,
751
+ 'timestamp': timestamp,
752
+ 'datetime': this.iso8601(timestamp),
753
+ 'lastTradeTimestamp': lastTradeTimestamp,
754
+ 'symbol': symbol,
755
+ 'type': type,
756
+ 'timeInForce': undefined,
757
+ 'postOnly': undefined,
758
+ 'side': side,
759
+ 'price': price,
760
+ 'stopPrice': undefined,
761
+ 'triggerPrice': undefined,
762
+ 'amount': amount,
763
+ 'cost': cost,
764
+ 'average': undefined,
765
+ 'filled': filled,
766
+ 'remaining': remaining,
767
+ 'status': status,
768
+ 'fee': undefined,
769
+ 'trades': undefined,
770
+ }, market);
771
+ }
772
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
773
+ /**
774
+ * @method
775
+ * @name lykke#createOrder
776
+ * @description create a trade order
777
+ * @param {string} symbol unified symbol of the market to create an order in
778
+ * @param {string} type 'market' or 'limit'
779
+ * @param {string} side 'buy' or 'sell'
780
+ * @param {float} amount how much of currency you want to trade in units of base currency
781
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
782
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
783
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
784
+ */
785
+ await this.loadMarkets();
786
+ const market = this.market(symbol);
787
+ const query = {
788
+ 'assetPairId': market['id'],
789
+ 'side': this.capitalize(side),
790
+ 'volume': parseFloat(this.amountToPrecision(market['symbol'], amount)),
791
+ };
792
+ if (type === 'limit') {
793
+ query['price'] = parseFloat(this.priceToPrecision(market['symbol'], price));
794
+ }
795
+ let result = undefined;
796
+ if (this.capitalize(type) === 'Market') {
797
+ result = await this.privatePostOrdersMarket(this.extend(query, params));
798
+ }
799
+ else {
800
+ result = await this.privatePostOrdersLimit(this.extend(query, params));
801
+ }
802
+ //
803
+ // market
804
+ //
805
+ // {
806
+ // "payload":{
807
+ // "orderId":"2b98ec26-8410-49b6-9f37-1fb2150e2299",
808
+ // "price":280.699
809
+ // },
810
+ // "error":null
811
+ // }
812
+ //
813
+ // limit
814
+ //
815
+ // {
816
+ // "payload":{
817
+ // "orderId":"27be8802-30be-40ca-bf40-ec886b309c5b"
818
+ // },
819
+ // "error":null
820
+ // }
821
+ //
822
+ const payload = this.safeValue(result, 'payload');
823
+ const id = this.safeString(payload, 'orderId');
824
+ if (type === 'market') {
825
+ price = this.safeNumber(payload, 'price');
826
+ }
827
+ return this.safeOrder({
828
+ 'id': id,
829
+ 'info': result,
830
+ 'clientOrderId': undefined,
831
+ 'timestamp': undefined,
832
+ 'datetime': undefined,
833
+ 'lastTradeTimestamp': undefined,
834
+ 'symbol': market['symbol'],
835
+ 'type': type,
836
+ 'side': side,
837
+ 'price': price,
838
+ 'amount': amount,
839
+ 'cost': undefined,
840
+ 'average': undefined,
841
+ 'filled': undefined,
842
+ 'remaining': undefined,
843
+ 'status': undefined,
844
+ 'fee': undefined,
845
+ 'trades': undefined,
846
+ }, market);
847
+ }
848
+ async cancelOrder(id, symbol = undefined, params = {}) {
849
+ /**
850
+ * @method
851
+ * @name lykke#cancelOrder
852
+ * @description cancels an open order
853
+ * @param {string} id order id
854
+ * @param {string} symbol unified symbol of the market the order was made in
855
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
856
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
857
+ */
858
+ const request = {
859
+ 'orderId': id,
860
+ };
861
+ //
862
+ // {
863
+ // "payload":null,
864
+ // "error":null
865
+ // }
866
+ //
867
+ return await this.privateDeleteOrdersOrderId(this.extend(request, params));
868
+ }
869
+ async cancelAllOrders(symbol = undefined, params = {}) {
870
+ /**
871
+ * @method
872
+ * @name lykke#cancelAllOrders
873
+ * @description cancel all open orders
874
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
875
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
876
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
877
+ */
878
+ await this.loadMarkets();
879
+ const request = {
880
+ // 'side': 'Buy',
881
+ };
882
+ let market = undefined;
883
+ if (symbol !== undefined) {
884
+ market = this.market(symbol);
885
+ request['assetPairId'] = market['id'];
886
+ }
887
+ //
888
+ // {
889
+ // "payload":null,
890
+ // "error":null
891
+ // }
892
+ //
893
+ return await this.privateDeleteOrders(this.extend(request, params));
894
+ }
895
+ async fetchOrder(id, symbol = undefined, params = {}) {
896
+ /**
897
+ * @method
898
+ * @name lykke#fetchOrder
899
+ * @description fetches information on an order made by the user
900
+ * @param {string} symbol not used by lykke fetchOrder
901
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
902
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
903
+ */
904
+ await this.loadMarkets();
905
+ const request = {
906
+ 'orderId': id,
907
+ };
908
+ const response = await this.privateGetOrdersOrderId(this.extend(request, params));
909
+ const payload = this.safeValue(response, 'payload');
910
+ //
911
+ // {
912
+ // "payload":{
913
+ // "id":"1b367978-7e4f-454b-b870-64040d484443",
914
+ // "timestamp":1644155923357,
915
+ // "lastTradeTimestamp":1644155923357,
916
+ // "status":"Matched",
917
+ // "assetPairId":"BCHEUR",
918
+ // "type":"Market",
919
+ // "side":"Sell",
920
+ // "price":280.569,
921
+ // "volume":0.01,
922
+ // "filledVolume":0.01,
923
+ // "remainingVolume":0.0,
924
+ // "cost":2.80569
925
+ // },
926
+ // "error":null
927
+ // }
928
+ //
929
+ return this.parseOrder(payload);
930
+ }
931
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
932
+ /**
933
+ * @method
934
+ * @name lykke#fetchOpenOrders
935
+ * @description fetch all unfilled currently open orders
936
+ * @param {string} symbol unified market symbol
937
+ * @param {int} [since] the earliest time in ms to fetch open orders for
938
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
939
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
940
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
941
+ */
942
+ await this.loadMarkets();
943
+ let market = undefined;
944
+ if (symbol !== undefined) {
945
+ market = this.market(symbol);
946
+ }
947
+ const request = {
948
+ // 'offset': 0,
949
+ // 'take': 1,
950
+ };
951
+ if (limit !== undefined) {
952
+ request['take'] = limit;
953
+ }
954
+ const response = await this.privateGetOrdersActive(this.extend(request, params));
955
+ const payload = this.safeValue(response, 'payload');
956
+ //
957
+ // {
958
+ // "payload":[
959
+ // {
960
+ // "id":"b26f58f5-8542-4b4c-9815-91562b523cc3",
961
+ // "timestamp":1644157177155,
962
+ // "lastTradeTimestamp":null,
963
+ // "status":"Placed",
964
+ // "assetPairId":"BCHEUR",
965
+ // "type":"Limit",
966
+ // "side":"Sell",
967
+ // "price":666.666,
968
+ // "volume":0.01,
969
+ // "filledVolume":0.00,
970
+ // "remainingVolume":0.01,
971
+ // "cost":0.00000
972
+ // }
973
+ // ],
974
+ // "error":null
975
+ // }
976
+ //
977
+ return this.parseOrders(payload, market, since, limit);
978
+ }
979
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
980
+ /**
981
+ * @method
982
+ * @name lykke#fetchClosedOrders
983
+ * @description fetches information on multiple closed orders made by the user
984
+ * @param {string} symbol unified market symbol of the market orders were made in
985
+ * @param {int} [since] the earliest time in ms to fetch orders for
986
+ * @param {int} [limit] the maximum number of order structures to retrieve
987
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
988
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
989
+ */
990
+ await this.loadMarkets();
991
+ let market = undefined;
992
+ if (symbol !== undefined) {
993
+ market = this.market(symbol);
994
+ }
995
+ const request = {
996
+ // 'offset': 0,
997
+ // 'take': 1,
998
+ };
999
+ if (limit !== undefined) {
1000
+ request['take'] = limit;
1001
+ }
1002
+ const response = await this.privateGetOrdersClosed(this.extend(request, params));
1003
+ const payload = this.safeValue(response, 'payload');
1004
+ //
1005
+ // {
1006
+ // "payload":[
1007
+ // {
1008
+ // "id":"1b367978-7e4f-454b-b870-64040d484443",
1009
+ // "timestamp":1644155923357,
1010
+ // "lastTradeTimestamp":1644155923357,
1011
+ // "status":"Matched",
1012
+ // "assetPairId":"BCHEUR",
1013
+ // "type":"Market",
1014
+ // "side":"Sell",
1015
+ // "price":280.569,
1016
+ // "volume":0.01,
1017
+ // "filledVolume":0.01,
1018
+ // "remainingVolume":0.0,
1019
+ // "cost":2.80569
1020
+ // }
1021
+ // ],
1022
+ // "error":null
1023
+ // }
1024
+ //
1025
+ return this.parseOrders(payload, market, since, limit);
1026
+ }
1027
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1028
+ /**
1029
+ * @method
1030
+ * @name lykke#fetchMyTrades
1031
+ * @description fetch all trades made by the user
1032
+ * @param {string} symbol unified market symbol
1033
+ * @param {int} [since] the earliest time in ms to fetch trades for
1034
+ * @param {int} [limit] the maximum number of trades structures to retrieve
1035
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1036
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1037
+ */
1038
+ await this.loadMarkets();
1039
+ const request = {
1040
+ // 'side': 'buy',
1041
+ // 'offset': 0,
1042
+ // 'take': 1,
1043
+ // 'to': 0,
1044
+ };
1045
+ let market = undefined;
1046
+ if (limit !== undefined) {
1047
+ request['take'] = limit; // How many maximum items have to be returned, max 1000 default 100.
1048
+ }
1049
+ if (symbol !== undefined) {
1050
+ market = this.market(symbol);
1051
+ request['assetPairId'] = market['id'];
1052
+ }
1053
+ if (since !== undefined) {
1054
+ request['from'] = since;
1055
+ }
1056
+ const response = await this.privateGetTrades(this.extend(request, params));
1057
+ const payload = this.safeValue(response, 'payload');
1058
+ //
1059
+ // {
1060
+ // "payload":[
1061
+ // {
1062
+ // "id":"813a3ffa-1c4b-45cb-b13f-1c077ea2748b",
1063
+ // "timestamp":1644155923357,
1064
+ // "assetPairId":"BCHEUR",
1065
+ // "orderId":"1b367978-7e4f-454b-b870-64040d484443",
1066
+ // "role":"Taker",
1067
+ // "side":"sell",
1068
+ // "price":280.569,
1069
+ // "baseVolume":0.01,
1070
+ // "quoteVolume":2.8056,
1071
+ // "baseAssetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
1072
+ // "quoteAssetId":"EUR",
1073
+ // "fee":null
1074
+ // }
1075
+ // ],
1076
+ // "error":null
1077
+ // }
1078
+ //
1079
+ return this.parseTrades(payload, market, since, limit);
1080
+ }
1081
+ parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
1082
+ const price = this.safeString(bidask, priceKey);
1083
+ const amount = Precise["default"].stringAbs(this.safeString(bidask, amountKey));
1084
+ return [this.parseNumber(price), this.parseNumber(amount)];
1085
+ }
1086
+ async fetchDepositAddress(code, params = {}) {
1087
+ /**
1088
+ * @method
1089
+ * @name lykke#fetchDepositAddress
1090
+ * @description fetch the deposit address for a currency associated with this account
1091
+ * @param {string} code unified currency code
1092
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1093
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1094
+ */
1095
+ await this.loadMarkets();
1096
+ const currency = this.currency(code);
1097
+ const request = {
1098
+ 'assetId': this.safeString(currency, 'id'),
1099
+ };
1100
+ const response = await this.privateGetOperationsDepositsAddressesAssetId(this.extend(request, params));
1101
+ //
1102
+ // {
1103
+ // "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
1104
+ // "symbol":"BCH",
1105
+ // "address":null,
1106
+ // "baseAddress":null,
1107
+ // "addressExtension":null,
1108
+ // "state":"Active"
1109
+ // }
1110
+ //
1111
+ const address = this.safeString(response, 'baseAddress');
1112
+ const tag = this.safeString(response, 'addressExtension');
1113
+ this.checkAddress(address);
1114
+ return {
1115
+ 'currency': code,
1116
+ 'address': address,
1117
+ 'tag': tag,
1118
+ 'network': undefined,
1119
+ 'info': response,
1120
+ };
1121
+ }
1122
+ parseTransaction(transaction, currency = undefined) {
1123
+ //
1124
+ // withdraw
1125
+ // "3035b1ad-2005-4587-a986-1f7966be78e0"
1126
+ //
1127
+ // fetchDepositsWithdrawals
1128
+ // {
1129
+ // "operationId":"787201c8-f1cc-45c0-aec1-fa06eeea426b",
1130
+ // "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
1131
+ // "totalVolume":0.1,
1132
+ // "fee":0.0,
1133
+ // "type":"deposit",
1134
+ // "timestamp":1644146723620
1135
+ // }
1136
+ //
1137
+ let id = undefined;
1138
+ let assetId = undefined;
1139
+ let code = undefined;
1140
+ let amount = undefined;
1141
+ let fee = undefined;
1142
+ let type = undefined;
1143
+ let timestamp = undefined;
1144
+ if (typeof transaction === 'string') {
1145
+ id = transaction;
1146
+ }
1147
+ else {
1148
+ id = this.safeString(transaction, 'operationId');
1149
+ assetId = this.safeString(transaction, 'assetId');
1150
+ code = this.safeCurrencyCode(assetId, currency);
1151
+ amount = this.safeNumber(transaction, 'totalVolume');
1152
+ type = this.safeString(transaction, 'type');
1153
+ timestamp = this.safeInteger(transaction, 'timestamp');
1154
+ const feeCost = this.safeNumber(transaction, 'fee');
1155
+ fee = {
1156
+ 'currency': code,
1157
+ 'cost': feeCost,
1158
+ };
1159
+ }
1160
+ return {
1161
+ 'info': transaction,
1162
+ 'id': id,
1163
+ 'txid': undefined,
1164
+ 'timestamp': timestamp,
1165
+ 'datetime': this.iso8601(timestamp),
1166
+ 'network': undefined,
1167
+ 'addressFrom': undefined,
1168
+ 'address': undefined,
1169
+ 'addressTo': undefined,
1170
+ 'tagFrom': undefined,
1171
+ 'tag': undefined,
1172
+ 'tagTo': undefined,
1173
+ 'type': type,
1174
+ 'amount': amount,
1175
+ 'currency': code,
1176
+ 'status': undefined,
1177
+ 'updated': undefined,
1178
+ 'internal': undefined,
1179
+ 'comment': undefined,
1180
+ 'fee': fee,
1181
+ };
1182
+ }
1183
+ async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1184
+ /**
1185
+ * @method
1186
+ * @name lykke#fetchDepositsWithdrawals
1187
+ * @description fetch history of deposits and withdrawals
1188
+ * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1189
+ * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1190
+ * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
1191
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1192
+ * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1193
+ */
1194
+ await this.loadMarkets();
1195
+ const request = {
1196
+ // 'offset': 0,
1197
+ // 'take': 1,
1198
+ };
1199
+ if (limit !== undefined) {
1200
+ request['take'] = limit;
1201
+ }
1202
+ const response = await this.privateGetOperations(this.extend(request, params));
1203
+ const payload = this.safeValue(response, 'payload', []);
1204
+ //
1205
+ // {
1206
+ // "payload":[
1207
+ // {
1208
+ // "operationId":"787201c8-f1cc-45c0-aec1-fa06eeea426b",
1209
+ // "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
1210
+ // "totalVolume":0.1,
1211
+ // "fee":0.0,
1212
+ // "type":"deposit",
1213
+ // "timestamp":1644146723620
1214
+ // }
1215
+ // ],
1216
+ // "error":null
1217
+ // }
1218
+ //
1219
+ let currency = undefined;
1220
+ if (code !== undefined) {
1221
+ currency = this.currency(code);
1222
+ }
1223
+ return this.parseTransactions(payload, currency, since, limit);
1224
+ }
1225
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
1226
+ /**
1227
+ * @method
1228
+ * @name lykke#withdraw
1229
+ * @description make a withdrawal
1230
+ * @param {string} code unified currency code
1231
+ * @param {float} amount the amount to withdraw
1232
+ * @param {string} address the address to withdraw to
1233
+ * @param {string} tag
1234
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1235
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1236
+ */
1237
+ await this.loadMarkets();
1238
+ this.checkAddress(address);
1239
+ const currency = this.currency(code);
1240
+ const request = {
1241
+ 'assetId': currency['id'],
1242
+ 'volume': parseFloat(this.currencyToPrecision(code, amount)),
1243
+ 'destinationAddress': address,
1244
+ // 'destinationAddressExtension': tag,
1245
+ };
1246
+ if (tag !== undefined) {
1247
+ request['destinationAddressExtension'] = tag;
1248
+ }
1249
+ const response = await this.privatePostOperationsWithdrawals(this.extend(request, params));
1250
+ //
1251
+ // "3035b1ad-2005-4587-a986-1f7966be78e0"
1252
+ //
1253
+ return this.parseTransaction(response, currency);
1254
+ }
1255
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1256
+ let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
1257
+ const query = this.omit(params, this.extractParams(path));
1258
+ headers = {
1259
+ 'Accept': 'application/json',
1260
+ 'Content-Type': 'application/json',
1261
+ };
1262
+ if (api === 'public') {
1263
+ if (Object.keys(query).length) {
1264
+ url += '?' + this.urlencode(query);
1265
+ }
1266
+ }
1267
+ else if (api === 'private') {
1268
+ if ((method === 'GET') || (method === 'DELETE')) {
1269
+ if (Object.keys(query).length) {
1270
+ url += '?' + this.urlencode(query);
1271
+ }
1272
+ }
1273
+ this.checkRequiredCredentials();
1274
+ headers['Authorization'] = 'Bearer ' + this.apiKey;
1275
+ if (method === 'POST') {
1276
+ if (Object.keys(params).length) {
1277
+ body = this.json(params);
1278
+ }
1279
+ }
1280
+ if (path === 'operations/withdrawals') {
1281
+ headers['X-Request-ID'] = this.uuid();
1282
+ }
1283
+ }
1284
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1285
+ }
1286
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1287
+ if (response === undefined) {
1288
+ return undefined;
1289
+ }
1290
+ const error = this.safeValue(response, 'error', {});
1291
+ const errorCode = this.safeString(error, 'code');
1292
+ if ((errorCode !== undefined) && (errorCode !== '0')) {
1293
+ const feedback = this.id + ' ' + body;
1294
+ const message = this.safeString(error, 'message');
1295
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
1296
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1297
+ throw new errors.ExchangeError(feedback);
1298
+ }
1299
+ return undefined;
1300
+ }
1301
+ }
1302
+
1303
+ module.exports = lykke;