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,2329 @@
1
+ 'use strict';
2
+
3
+ var coinlist$1 = require('./abstract/coinlist.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 sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
+
9
+ /**
10
+ * @class coinlist
11
+ * @augments Exchange
12
+ */
13
+ class coinlist extends coinlist$1 {
14
+ describe() {
15
+ return this.deepExtend(super.describe(), {
16
+ 'id': 'coinlist',
17
+ 'name': 'Coinlist',
18
+ 'countries': ['US'],
19
+ 'version': 'v1',
20
+ 'rateLimit': 300,
21
+ 'certified': false,
22
+ 'pro': false,
23
+ 'has': {
24
+ 'CORS': undefined,
25
+ 'spot': true,
26
+ 'margin': false,
27
+ 'swap': false,
28
+ 'future': false,
29
+ 'option': false,
30
+ 'addMargin': false,
31
+ 'cancelAllOrders': true,
32
+ 'cancelOrder': true,
33
+ 'cancelOrders': true,
34
+ 'closeAllPositions': false,
35
+ 'closePosition': false,
36
+ 'createDepositAddress': false,
37
+ 'createOrder': true,
38
+ 'createPostOnlyOrder': true,
39
+ 'createReduceOnlyOrder': false,
40
+ 'createStopLimitOrder': true,
41
+ 'createStopMarketOrder': true,
42
+ 'createStopOrder': true,
43
+ 'deposit': false,
44
+ 'editOrder': true,
45
+ 'fetchAccounts': true,
46
+ 'fetchBalance': true,
47
+ 'fetchBidsAsks': false,
48
+ 'fetchBorrowInterest': false,
49
+ 'fetchBorrowRateHistories': false,
50
+ 'fetchBorrowRateHistory': false,
51
+ 'fetchCanceledOrders': true,
52
+ 'fetchClosedOrder': false,
53
+ 'fetchClosedOrders': true,
54
+ 'fetchCrossBorrowRate': false,
55
+ 'fetchCrossBorrowRates': false,
56
+ 'fetchCurrencies': true,
57
+ 'fetchDeposit': false,
58
+ 'fetchDepositAddress': false,
59
+ 'fetchDepositAddresses': false,
60
+ 'fetchDepositAddressesByNetwork': false,
61
+ 'fetchDeposits': false,
62
+ 'fetchDepositsWithdrawals': true,
63
+ 'fetchDepositWithdrawFee': false,
64
+ 'fetchDepositWithdrawFees': false,
65
+ 'fetchFundingHistory': false,
66
+ 'fetchFundingRate': false,
67
+ 'fetchFundingRateHistory': false,
68
+ 'fetchFundingRates': false,
69
+ 'fetchIndexOHLCV': false,
70
+ 'fetchIsolatedBorrowRate': false,
71
+ 'fetchIsolatedBorrowRates': false,
72
+ 'fetchL3OrderBook': false,
73
+ 'fetchLedger': true,
74
+ 'fetchLeverage': false,
75
+ 'fetchLeverageTiers': false,
76
+ 'fetchMarketLeverageTiers': false,
77
+ 'fetchMarkets': true,
78
+ 'fetchMarkOHLCV': false,
79
+ 'fetchMyTrades': true,
80
+ 'fetchOHLCV': true,
81
+ 'fetchOpenInterestHistory': false,
82
+ 'fetchOpenOrder': false,
83
+ 'fetchOpenOrders': true,
84
+ 'fetchOrder': true,
85
+ 'fetchOrderBook': true,
86
+ 'fetchOrderBooks': false,
87
+ 'fetchOrders': true,
88
+ 'fetchOrderTrades': true,
89
+ 'fetchPosition': false,
90
+ 'fetchPositions': false,
91
+ 'fetchPositionsRisk': false,
92
+ 'fetchPremiumIndexOHLCV': false,
93
+ 'fetchStatus': false,
94
+ 'fetchTicker': true,
95
+ 'fetchTickers': true,
96
+ 'fetchTime': true,
97
+ 'fetchTrades': true,
98
+ 'fetchTradingFee': false,
99
+ 'fetchTradingFees': true,
100
+ 'fetchTradingLimits': false,
101
+ 'fetchTransactionFee': false,
102
+ 'fetchTransactionFees': false,
103
+ 'fetchTransactions': true,
104
+ 'fetchTransfers': true,
105
+ 'fetchWithdrawal': false,
106
+ 'fetchWithdrawals': false,
107
+ 'fetchWithdrawalWhitelist': false,
108
+ 'reduceMargin': false,
109
+ 'repayCrossMargin': false,
110
+ 'repayIsolatedMargin': false,
111
+ 'setLeverage': false,
112
+ 'setMargin': false,
113
+ 'setMarginMode': false,
114
+ 'setPositionMode': false,
115
+ 'signIn': false,
116
+ 'transfer': true,
117
+ 'withdraw': true,
118
+ 'ws': false,
119
+ },
120
+ 'timeframes': {
121
+ '1m': '1m',
122
+ '5m': '5m',
123
+ '30m': '30m',
124
+ },
125
+ 'urls': {
126
+ 'logo': 'https://github-production-user-asset-6210df.s3.amazonaws.com/1294454/281108917-eff2ae1d-ce8a-4b2a-950d-8678b12da965.jpg',
127
+ 'api': {
128
+ 'public': 'https://trade-api.coinlist.co',
129
+ 'private': 'https://trade-api.coinlist.co',
130
+ },
131
+ 'www': 'https://coinlist.co',
132
+ 'doc': [
133
+ 'https://trade-docs.coinlist.co',
134
+ ],
135
+ 'fees': 'https://coinlist.co/fees',
136
+ },
137
+ 'api': {
138
+ 'public': {
139
+ 'get': {
140
+ 'v1/symbols': 1,
141
+ 'v1/symbols/summary': 1,
142
+ 'v1/symbols/{symbol}': 1,
143
+ 'v1/symbols/{symbol}/summary': 1,
144
+ 'v1/symbols/{symbol}/book': 1,
145
+ 'v1/symbols/{symbol}/quote': 1,
146
+ 'v1/symbols/{symbol}/candles': 1,
147
+ 'v1/symbols/{symbol}/auctions': 1,
148
+ 'v1/symbols/{symbol}/auctions/{auction_code}': 1,
149
+ 'v1/time': 1,
150
+ 'v1/assets': 1,
151
+ },
152
+ },
153
+ 'private': {
154
+ 'get': {
155
+ 'v1/fees': 1,
156
+ 'v1/accounts': 1,
157
+ 'v1/accounts/{trader_id}': 1,
158
+ 'v1/accounts/{trader_id}/ledger': 1,
159
+ 'v1/accounts/{trader_id}/wallets': 1,
160
+ 'v1/accounts/{trader_id}/wallet-ledger': 1,
161
+ 'v1/accounts/{trader_id}/ledger-summary': 1,
162
+ 'v1/keys': 1,
163
+ 'v1/fills': 1,
164
+ 'v1/orders': 1,
165
+ 'v1/orders/{order_id}': 1,
166
+ 'v1/reports': 1,
167
+ 'v1/balances': 1,
168
+ 'v1/transfers': 1,
169
+ 'v1/user': 1,
170
+ 'v1/credits': 1, // not unified
171
+ },
172
+ 'post': {
173
+ 'v1/keys': 1,
174
+ 'v1/orders': 1,
175
+ 'v1/orders/cancel-all-after': 1,
176
+ 'v1/reports': 1,
177
+ 'v1/transfers/to-wallet': 1,
178
+ 'v1/transfers/from-wallet': 1,
179
+ 'v1/transfers/internal-transfer': 1,
180
+ 'v1/transfers/withdrawal-request': 1,
181
+ 'v1/orders/bulk': 1, // not unified
182
+ },
183
+ 'patch': {
184
+ 'v1/orders/{order_id}': 1,
185
+ 'v1/orders/bulk': 1, // not unified
186
+ },
187
+ 'delete': {
188
+ 'v1/keys/{key}': 1,
189
+ 'v1/orders': 1,
190
+ 'v1/orders/{order_id}': 1,
191
+ 'v1/orders/bulk': 1,
192
+ },
193
+ },
194
+ },
195
+ 'fees': {
196
+ 'trading': {
197
+ 'feeSide': 'get',
198
+ 'tierBased': true,
199
+ 'percentage': true,
200
+ 'taker': this.parseNumber('0.0045'),
201
+ 'maker': this.parseNumber('0.0025'),
202
+ 'tiers': {
203
+ 'taker': [
204
+ [this.parseNumber('0'), this.parseNumber('0.0045')],
205
+ [this.parseNumber('20000'), this.parseNumber('0.003')],
206
+ [this.parseNumber('50000'), this.parseNumber('0.0025')],
207
+ [this.parseNumber('100000'), this.parseNumber('0.002')],
208
+ [this.parseNumber('500000'), this.parseNumber('0.0018')],
209
+ [this.parseNumber('750000'), this.parseNumber('0.0018')],
210
+ [this.parseNumber('1000000'), this.parseNumber('0.0016')],
211
+ [this.parseNumber('2500000'), this.parseNumber('0.0013')],
212
+ [this.parseNumber('5000000'), this.parseNumber('0.0012')],
213
+ [this.parseNumber('10000000'), this.parseNumber('0.001')],
214
+ [this.parseNumber('50000000'), this.parseNumber('0.0005')],
215
+ [this.parseNumber('100000000'), this.parseNumber('0.0005')],
216
+ ],
217
+ 'maker': [
218
+ [this.parseNumber('0'), this.parseNumber('0.0025')],
219
+ [this.parseNumber('20000'), this.parseNumber('0.0025')],
220
+ [this.parseNumber('50000'), this.parseNumber('0.0025')],
221
+ [this.parseNumber('100000'), this.parseNumber('0.002')],
222
+ [this.parseNumber('500000'), this.parseNumber('0.0015')],
223
+ [this.parseNumber('750000'), this.parseNumber('0.0012')],
224
+ [this.parseNumber('1000000'), this.parseNumber('0.001')],
225
+ [this.parseNumber('2500000'), this.parseNumber('0.0008')],
226
+ [this.parseNumber('5000000'), this.parseNumber('0.0007')],
227
+ [this.parseNumber('10000000'), this.parseNumber('0.0006')],
228
+ [this.parseNumber('50000000'), this.parseNumber('0.0000')],
229
+ [this.parseNumber('100000000'), this.parseNumber('0.00')],
230
+ ],
231
+ },
232
+ },
233
+ },
234
+ 'precisionMode': number.TICK_SIZE,
235
+ // exchange-specific options
236
+ 'options': {
237
+ 'accountsByType': {
238
+ 'CoinList Pro': 'trading',
239
+ 'CoinList Pro trading account': 'trading',
240
+ 'Pro': 'trading',
241
+ 'pro': 'trading',
242
+ 'trade': 'trading',
243
+ 'trading': 'trading',
244
+ 'CoinList': 'funding',
245
+ 'CoinList wallet': 'funding',
246
+ 'Wallet': 'funding',
247
+ 'wallet': 'funding',
248
+ 'fund': 'funding',
249
+ 'funding': 'funding',
250
+ },
251
+ },
252
+ 'exceptions': {
253
+ // https://trade-docs.coinlist.co/?javascript--nodejs#message-codes
254
+ 'exact': {
255
+ 'AUTH_SIG_INVALID': errors.AuthenticationError,
256
+ 'DENIED_MAINTENANCE': errors.OnMaintenance,
257
+ 'ORDER_REJECT_BAD_STATUS': errors.InvalidOrder,
258
+ 'ORDER_REJECT_INVALID_POST_ONLY': errors.InvalidOrder,
259
+ 'ORDER_REJECT_INVALID_CLOSE_ONLY': errors.InvalidOrder,
260
+ 'ORDER_REJECT_POST_ONLY_REQUIRED': errors.InvalidOrder,
261
+ 'ORDER_REJECT_FROZEN_ORDER': errors.InvalidOrder,
262
+ 'ORDER_REJECT_LIMIT_PRICE_PROTECTION_VIOLATION': errors.InvalidOrder,
263
+ 'ORDER_REJECT_CLOSED': errors.NotSupported,
264
+ 'ORDER_REJECT_MAX_ORDERS': errors.BadRequest,
265
+ 'ORDER_REJECT_NOT_FOUND': errors.OrderNotFound,
266
+ 'ORDER_REJECT_PARSE_ERROR': errors.BadRequest,
267
+ 'ORDER_REJECT_PRICE_INVALID': errors.InvalidOrder,
268
+ 'ORDER_REJECT_QUANTITY_ZERO': errors.InvalidOrder,
269
+ 'ORDER_REJECT_TOKEN_LIMIT': errors.InsufficientFunds,
270
+ 'ORDER_REJECT_TOKEN_LIMIT_OTHER': errors.InvalidOrder,
271
+ 'ORDER_REJECT_SELF_TRADE': errors.InvalidOrder,
272
+ 'ORDER_VALIDATE_BAD_SIZE_ALIGNMENT': errors.InvalidOrder,
273
+ 'ORDER_VALIDATE_BAD_TICK_ALIGNMENT': errors.InvalidOrder,
274
+ 'ORDER_VALIDATE_SYMBOL_NOT_FOUND': errors.BadSymbol,
275
+ 'TRANSFERS_WITHDRAWAL_REQUEST_TOO_LARGE': errors.InsufficientFunds,
276
+ 'WITHDRAWAL_REQUEST_NOT_ALLOWED': errors.PermissionDenied, // {"message":"Withdrawal from CoinList not allowed for trader.","message_code":"WITHDRAWAL_REQUEST_NOT_ALLOWED","message_details":{"asset":"USDT","amount":"5","trader_id":"9c6f737e-a829-4843-87b1-b1ce86f2853b","destination_address":"0x9050dfA063D1bE7cA711c750b18D51fDD13e90Ee"}}
277
+ },
278
+ 'broad': {
279
+ 'A destinationAddress is required for non-USD withdrawals': errors.InvalidAddress,
280
+ 'fails to match the JsonSchema date-time format pattern': errors.BadRequest,
281
+ 'is required': errors.ArgumentsRequired,
282
+ 'must be a string': errors.BadRequest,
283
+ 'must be a valid GUID': errors.BadRequest,
284
+ 'must be greater than or equal to': errors.BadRequest,
285
+ 'must be less than or equal to': errors.BadRequest,
286
+ 'must be one of': errors.BadRequest,
287
+ 'Symbol not found': errors.BadSymbol, // {"message":"Symbol not found: {symbol}"}
288
+ },
289
+ },
290
+ });
291
+ }
292
+ calculateRateLimiterCost(api, method, path, params, config = {}) {
293
+ if (Array.isArray(params)) {
294
+ const length = params.length;
295
+ return Math.ceil(length / 2);
296
+ }
297
+ return 1;
298
+ }
299
+ async fetchTime(params = {}) {
300
+ /**
301
+ * @method
302
+ * @name coinlist#fetchTime
303
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
304
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-system-time
305
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
306
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
307
+ */
308
+ const response = await this.publicGetV1Time(params);
309
+ //
310
+ // {
311
+ // "epoch": 1698087996.039,
312
+ // "iso": "2023-10-23T19:06:36.039Z"
313
+ // }
314
+ //
315
+ const string = this.safeString(response, 'iso');
316
+ return this.parse8601(string);
317
+ }
318
+ async fetchCurrencies(params = {}) {
319
+ /**
320
+ * @method
321
+ * @name coinlist#fetchCurrencies
322
+ * @description fetches all available currencies on an exchange
323
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-supported-assets
324
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
325
+ * @returns {object} an associative dictionary of currencies
326
+ */
327
+ const response = await this.publicGetV1Assets(params);
328
+ //
329
+ // {
330
+ // "assets": [
331
+ // {
332
+ // "asset": "AAVE",
333
+ // "index_code": ".AAVEUSD",
334
+ // "decimal_places": 18,
335
+ // "min_withdrawal": "1.0000",
336
+ // "is_transferable": true,
337
+ // "is_visible": true
338
+ // },
339
+ // {
340
+ // "asset": "ALGO",
341
+ // "index_code": ".ALGOUSD",
342
+ // "decimal_places": 6,
343
+ // "min_withdrawal": "1.0000",
344
+ // "is_transferable": true,
345
+ // "is_visible": true
346
+ // }
347
+ // ]
348
+ // }
349
+ //
350
+ const currencies = this.safeValue(response, 'assets', []);
351
+ const result = {};
352
+ for (let i = 0; i < currencies.length; i++) {
353
+ const currency = currencies[i];
354
+ const id = this.safeString(currency, 'asset');
355
+ const code = this.safeCurrencyCode(id);
356
+ const isTransferable = this.safeValue(currency, 'is_transferable', false);
357
+ const withdrawEnabled = isTransferable;
358
+ const depositEnabled = isTransferable;
359
+ const active = isTransferable;
360
+ const decimalPlaces = this.safeString(currency, 'decimal_places');
361
+ const precision = this.parseNumber(this.parsePrecision(decimalPlaces));
362
+ const minWithdrawal = this.safeString(currency, 'min_withdrawal');
363
+ result[code] = {
364
+ 'id': id,
365
+ 'code': code,
366
+ 'name': code,
367
+ 'info': currency,
368
+ 'active': active,
369
+ 'deposit': depositEnabled,
370
+ 'withdraw': withdrawEnabled,
371
+ 'fee': undefined,
372
+ 'precision': precision,
373
+ 'limits': {
374
+ 'amount': { 'min': undefined, 'max': undefined },
375
+ 'withdraw': { 'min': minWithdrawal, 'max': undefined },
376
+ },
377
+ 'networks': {},
378
+ };
379
+ }
380
+ return result;
381
+ }
382
+ async fetchMarkets(params = {}) {
383
+ /**
384
+ * @method
385
+ * @name coinlist#fetchMarkets
386
+ * @description retrieves data on all markets for coinlist
387
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-symbols
388
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
389
+ * @returns {object[]} an array of objects representing market data
390
+ */
391
+ const response = await this.publicGetV1Symbols(params);
392
+ //
393
+ // {
394
+ // "symbols": [
395
+ // {
396
+ // "symbol": "CQT-USDT",
397
+ // "base_currency": "CQT",
398
+ // "is_trader_geofenced": false,
399
+ // "list_time": "2021-06-15T00:00:00.000Z",
400
+ // "type": "spot",
401
+ // "series_code": "CQT-USDT-SPOT",
402
+ // "long_name": "Covalent",
403
+ // "asset_class": "CRYPTO",
404
+ // "minimum_price_increment": "0.0001",
405
+ // "minimum_size_increment": "0.0001",
406
+ // "quote_currency": "USDT",
407
+ // "index_code": null,
408
+ // "price_band_threshold_market": "0.05",
409
+ // "price_band_threshold_limit": "0.25",
410
+ // "last_price": "0.12160000",
411
+ // "fair_price": "0.12300000",
412
+ // "index_price": null
413
+ // },
414
+ // ]
415
+ // }
416
+ //
417
+ const markets = this.safeValue(response, 'symbols', []);
418
+ return this.parseMarkets(markets);
419
+ }
420
+ parseMarket(market) {
421
+ const id = this.safeString(market, 'symbol');
422
+ const baseId = this.safeString(market, 'base_currency');
423
+ const quoteId = this.safeString(market, 'quote_currency');
424
+ const base = this.safeCurrencyCode(baseId);
425
+ const quote = this.safeCurrencyCode(quoteId);
426
+ const amountPrecision = this.safeString(market, 'minimum_size_increment');
427
+ const pricePrecision = this.safeString(market, 'minimum_price_increment');
428
+ const created = this.safeString(market, 'list_time');
429
+ return {
430
+ 'id': id,
431
+ 'symbol': base + '/' + quote,
432
+ 'base': base,
433
+ 'quote': quote,
434
+ 'settle': undefined,
435
+ 'baseId': baseId,
436
+ 'quoteId': quoteId,
437
+ 'settleId': undefined,
438
+ 'type': 'spot',
439
+ 'spot': true,
440
+ 'margin': false,
441
+ 'swap': false,
442
+ 'future': false,
443
+ 'option': false,
444
+ 'active': true,
445
+ 'contract': false,
446
+ 'linear': undefined,
447
+ 'inverse': undefined,
448
+ 'contractSize': undefined,
449
+ 'expiry': undefined,
450
+ 'expiryDatetime': undefined,
451
+ 'strike': undefined,
452
+ 'optionType': undefined,
453
+ 'precision': {
454
+ 'amount': this.parseNumber(amountPrecision),
455
+ 'price': this.parseNumber(pricePrecision),
456
+ },
457
+ 'limits': {
458
+ 'leverage': {
459
+ 'min': undefined,
460
+ 'max': undefined,
461
+ },
462
+ 'amount': {
463
+ 'min': undefined,
464
+ 'max': undefined,
465
+ },
466
+ 'price': {
467
+ 'min': undefined,
468
+ 'max': undefined,
469
+ },
470
+ 'cost': {
471
+ 'min': undefined,
472
+ 'max': undefined,
473
+ },
474
+ },
475
+ 'created': this.parse8601(created),
476
+ 'info': market,
477
+ };
478
+ }
479
+ async fetchTickers(symbols = undefined, params = {}) {
480
+ /**
481
+ * @method
482
+ * @name coinlist#fetchTickers
483
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
484
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-symbol-summaries
485
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
486
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
487
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
488
+ */
489
+ await this.loadMarkets();
490
+ const request = {};
491
+ const tickers = await this.publicGetV1SymbolsSummary(this.extend(request, params));
492
+ //
493
+ // {
494
+ // "MATIC-USD": {
495
+ // "type":"spot",
496
+ // "last_price":"0.60990000",
497
+ // "lowest_ask":"0.61190000",
498
+ // "highest_bid":"0.60790000",
499
+ // "last_trade": {
500
+ // "price":"0.60000000",
501
+ // "volume":"2.0000",
502
+ // "imbalance":"198.0000",
503
+ // "logicalTime":"2023-10-22T23:02:25.000Z",
504
+ // "auctionCode":"MATIC-USD-2023-10-22T23:02:25.000Z"
505
+ // },
506
+ // "volume_base_24h":"34.0555",
507
+ // "volume_quote_24h":"19.9282",
508
+ // "price_change_percent_24h":"7.50925436",
509
+ // "highest_price_24h":"0.68560000",
510
+ // "lowest_price_24h":"0.55500000"
511
+ // },
512
+ // }
513
+ //
514
+ return this.parseTickers(tickers, symbols, params);
515
+ }
516
+ async fetchTicker(symbol, params = {}) {
517
+ /**
518
+ * @method
519
+ * @name coinlist#fetchTicker
520
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
521
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-market-summary
522
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
523
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
524
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
525
+ */
526
+ await this.loadMarkets();
527
+ const market = this.market(symbol);
528
+ const request = {
529
+ 'symbol': market['id'],
530
+ };
531
+ const ticker = await this.publicGetV1SymbolsSymbolSummary(this.extend(request, params));
532
+ //
533
+ // {
534
+ // "type":"spot",
535
+ // "last_price":"31125.00000000",
536
+ // "lowest_ask":"31349.99000000",
537
+ // "highest_bid":"30900.00000000",
538
+ // "last_trade": {
539
+ // "price":"31000.00000000",
540
+ // "volume":"0.0003",
541
+ // "imbalance":"0.0000",
542
+ // "logicalTime":"2023-10-23T16:57:15.000Z",
543
+ // "auctionCode":"BTC-USDT-2023-10-23T16:57:15.000Z"
544
+ // },
545
+ // "volume_base_24h":"0.3752",
546
+ // "volume_quote_24h":"11382.7181",
547
+ // "price_change_percent_24h":"3.66264694",
548
+ // "highest_price_24h":"31225.12000000",
549
+ // "lowest_price_24h":"29792.81000000"
550
+ // }
551
+ //
552
+ return this.parseTicker(ticker, market);
553
+ }
554
+ parseTicker(ticker, market = undefined) {
555
+ //
556
+ // {
557
+ // "type":"spot",
558
+ // "last_price":"0.60990000",
559
+ // "lowest_ask":"0.61190000",
560
+ // "highest_bid":"0.60790000",
561
+ // "last_trade": {
562
+ // "price":"0.60000000",
563
+ // "volume":"2.0000",
564
+ // "imbalance":"198.0000",
565
+ // "logicalTime":"2023-10-22T23:02:25.000Z",
566
+ // "auctionCode":"MATIC-USD-2023-10-22T23:02:25.000Z"
567
+ // },
568
+ // "volume_base_24h":"34.0555",
569
+ // "volume_quote_24h":"19.9282",
570
+ // "price_change_percent_24h":"7.50925436",
571
+ // "highest_price_24h":"0.68560000",
572
+ // "lowest_price_24h":"0.55500000"
573
+ // }
574
+ //
575
+ const lastTrade = this.safeValue(ticker, 'last_trade', {});
576
+ const timestamp = this.parse8601(this.safeString(lastTrade, 'logicalTime'));
577
+ const bid = this.safeString(ticker, 'highest_bid');
578
+ const ask = this.safeString(ticker, 'lowest_ask');
579
+ const baseVolume = this.safeString(ticker, 'volume_base_24h');
580
+ const quoteVolume = this.safeString(ticker, 'volume_quote_24h');
581
+ const high = this.safeString(ticker, 'highest_price_24h');
582
+ const low = this.safeString(ticker, 'lowest_price_24h');
583
+ const close = this.safeString(ticker, 'last_price');
584
+ const changePcnt = this.safeString(ticker, 'price_change_percent_24h');
585
+ return this.safeTicker({
586
+ 'symbol': market['symbol'],
587
+ 'timestamp': timestamp,
588
+ 'datetime': this.iso8601(timestamp),
589
+ 'open': undefined,
590
+ 'high': high,
591
+ 'low': low,
592
+ 'close': close,
593
+ 'bid': bid,
594
+ 'bidVolume': undefined,
595
+ 'ask': ask,
596
+ 'askVolume': undefined,
597
+ 'vwap': undefined,
598
+ 'previousClose': undefined,
599
+ 'change': undefined,
600
+ 'percentage': changePcnt,
601
+ 'average': undefined,
602
+ 'baseVolume': baseVolume,
603
+ 'quoteVolume': quoteVolume,
604
+ 'info': ticker,
605
+ }, market);
606
+ }
607
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
608
+ /**
609
+ * @method
610
+ * @name coinlist#fetchOrderBook
611
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
612
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-order-book-level-2
613
+ * @param {string} symbol unified symbol of the market to fetch the order book for
614
+ * @param {int} [limit] the maximum amount of order book entries to return (default 100, max 200)
615
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
616
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
617
+ */
618
+ await this.loadMarkets();
619
+ const market = this.market(symbol);
620
+ const request = {
621
+ 'symbol': market['id'],
622
+ };
623
+ const response = await this.publicGetV1SymbolsSymbolBook(this.extend(request, params));
624
+ //
625
+ // {
626
+ // "bids": [
627
+ // [ "30900.00000000", "0.0001" ],
628
+ // [ "30664.21000000", "0.0172" ],
629
+ // [ "30664.20000000", "0.0906" ],
630
+ // ],
631
+ // "asks": [
632
+ // [ "31349.99000000", "0.0003" ],
633
+ // [ "31350.00000000", "0.0023" ],
634
+ // [ "31359.33000000", "0.0583" ],
635
+ // ],
636
+ // "after_auction_code": "BTC-USDT-2023-10-23T18:40:51.000Z",
637
+ // "call_time": "2023-10-23T18:40:51.068Z",
638
+ // "logical_time": "2023-10-23T18:40:51.000Z"
639
+ // }
640
+ //
641
+ const logical_time = this.parse8601(this.safeString(response, 'logical_time'));
642
+ const orderbook = this.parseOrderBook(response, symbol, logical_time);
643
+ orderbook['nonce'] = undefined;
644
+ return orderbook;
645
+ }
646
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
647
+ /**
648
+ * @method
649
+ * @name coinlist#fetchOHLCV
650
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
651
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-candles
652
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
653
+ * @param {string} timeframe the length of time each candle represents
654
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
655
+ * @param {int} [limit] the maximum amount of candles to fetch
656
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
657
+ * @param {int} [params.until] the latest time in ms to fetch entries for
658
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
659
+ */
660
+ await this.loadMarkets();
661
+ const market = this.market(symbol);
662
+ const granularity = this.safeString(this.timeframes, timeframe);
663
+ const request = {
664
+ 'symbol': market['id'],
665
+ 'granularity': granularity,
666
+ };
667
+ if (since !== undefined) {
668
+ request['start_time'] = this.iso8601(since);
669
+ if (limit !== undefined) {
670
+ const duration = this.parseTimeframe(timeframe) * 1000;
671
+ request['end_time'] = this.iso8601(this.sum(since, duration * (limit)));
672
+ }
673
+ else {
674
+ request['end_time'] = this.iso8601(this.milliseconds());
675
+ }
676
+ }
677
+ const until = this.safeInteger2(params, 'till', 'until');
678
+ if (until !== undefined) {
679
+ params = this.omit(params, ['till', 'until']);
680
+ request['end_time'] = this.iso8601(until);
681
+ }
682
+ const response = await this.publicGetV1SymbolsSymbolCandles(this.extend(request, params));
683
+ //
684
+ // {
685
+ // "candles": [
686
+ // [
687
+ // "2023-10-17T15:00:00.000Z",
688
+ // "28522.96000000",
689
+ // "28522.96000000",
690
+ // "28522.96000000",
691
+ // "28522.96000000",
692
+ // "0.1881",
693
+ // null
694
+ // ],
695
+ // [
696
+ // "2023-10-17T15:30:00.000Z",
697
+ // "28582.64000000",
698
+ // "28582.64000000",
699
+ // "28582.64000000",
700
+ // "28582.64000000",
701
+ // "0.0050",
702
+ // null
703
+ // ]
704
+ // ]
705
+ // }
706
+ //
707
+ const candles = this.safeValue(response, 'candles', []);
708
+ return this.parseOHLCVs(candles, market, timeframe, since, limit);
709
+ }
710
+ parseOHLCV(ohlcv, market = undefined) {
711
+ //
712
+ // [
713
+ // "2023-10-17T15:30:00.000Z",
714
+ // "28582.64000000",
715
+ // "28582.64000000",
716
+ // "28582.64000000",
717
+ // "28582.64000000",
718
+ // "0.0050",
719
+ // null
720
+ // ]
721
+ //
722
+ return [
723
+ this.parse8601(this.safeString(ohlcv, 0)),
724
+ this.safeNumber(ohlcv, 1),
725
+ this.safeNumber(ohlcv, 2),
726
+ this.safeNumber(ohlcv, 3),
727
+ this.safeNumber(ohlcv, 4),
728
+ this.safeNumber(ohlcv, 5),
729
+ ];
730
+ }
731
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
732
+ /**
733
+ * @method
734
+ * @name coinlist#fetchTrades
735
+ * @description get the list of most recent trades for a particular symbol
736
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-auctions
737
+ * @param {string} symbol unified symbol of the market to fetch trades for
738
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
739
+ * @param {int} [limit] the maximum amount of trades to fetch (default 200, max 500)
740
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
741
+ * @param {int} [params.until] the latest time in ms to fetch entries for
742
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
743
+ */
744
+ await this.loadMarkets();
745
+ const market = this.market(symbol);
746
+ const request = {
747
+ 'symbol': market['id'],
748
+ };
749
+ if (since !== undefined) {
750
+ request['start_time'] = this.iso8601(since);
751
+ }
752
+ if (limit !== undefined) {
753
+ request['count'] = Math.min(limit, 500);
754
+ }
755
+ const until = this.safeInteger2(params, 'till', 'until');
756
+ if (until !== undefined) {
757
+ params = this.omit(params, ['till', 'until']);
758
+ request['end_time'] = this.iso8601(until);
759
+ }
760
+ const response = await this.publicGetV1SymbolsSymbolAuctions(this.extend(request, params));
761
+ //
762
+ // {
763
+ // "auctions": [
764
+ // {
765
+ // "symbol":"BTC-USDT",
766
+ // "auction_code":"BTC-USDT-2023-10-01T08:05:56.000Z",
767
+ // "price":"27241.53000000",
768
+ // "volume":"0.0052",
769
+ // "imbalance":"-1.0983",
770
+ // "logical_time":"2023-10-01T08:05:56.000Z",
771
+ // "call_time":"2023-10-01T08:05:56.068Z"
772
+ // },
773
+ // {
774
+ // "symbol":"BTC-USDT",
775
+ // "auction_code":"BTC-USDT-2023-10-01T08:09:09.000Z",
776
+ // "price":"27236.83000000",
777
+ // "volume":"0.0283",
778
+ // "imbalance":"-1.0754",
779
+ // "logical_time":"2023-10-01T08:09:09.000Z",
780
+ // "call_time":"2023-10-01T08:09:09.078Z"
781
+ // }
782
+ // ]
783
+ // }
784
+ //
785
+ const auctions = this.safeValue(response, 'auctions', []);
786
+ return this.parseTrades(auctions, market, since, limit);
787
+ }
788
+ parseTrade(trade, market = undefined) {
789
+ //
790
+ // fetchTrades
791
+ // {
792
+ // "symbol": "BTC-USDT",
793
+ // "auction_code": "BTC-USDT-2023-10-01T08:05:56.000Z",
794
+ // "price": "27241.53000000",
795
+ // "volume": "0.0052",
796
+ // "imbalance": "-1.0983",
797
+ // "logical_time": "2023-10-01T08:05:56.000Z",
798
+ // "call_time": "2023-10-01T08:05:56.068Z"
799
+ // }
800
+ //
801
+ // fetchMyTrades
802
+ // {
803
+ // "symbol": "ETH-USDT",
804
+ // "auction_code": "ETH-USDT-2023-10-20T13:22:14.000Z",
805
+ // "order_id": "83ed365f-497d-433b-96c1-9d08c1a12842",
806
+ // "quantity": "0.0008",
807
+ // "price": "1615.24000000",
808
+ // "fee": "0.005815",
809
+ // "fee_type": "taker",
810
+ // "fee_currency": "USDT",
811
+ // "logical_time": "2023-10-20T13:22:14.000Z"
812
+ // }
813
+ //
814
+ const marketId = this.safeString(trade, 'symbol');
815
+ market = this.safeMarket(marketId, market);
816
+ const symbol = market['symbol'];
817
+ const id = this.safeString(trade, 'auction_code');
818
+ const timestamp = this.parse8601(this.safeString(trade, 'logical_time'));
819
+ const priceString = this.safeString(trade, 'price');
820
+ let amountString = this.safeString2(trade, 'volume', 'quantity');
821
+ const order = this.safeString(trade, 'order_id');
822
+ let fee = undefined;
823
+ let side = undefined;
824
+ const feeCost = this.safeString(trade, 'fee');
825
+ if (feeCost !== undefined) {
826
+ // only in fetchMyTrades
827
+ const amountIsNegative = Precise["default"].stringLt(amountString, '0');
828
+ if (amountIsNegative) {
829
+ side = 'sell';
830
+ amountString = Precise["default"].stringNeg(amountString);
831
+ }
832
+ else {
833
+ side = 'buy';
834
+ }
835
+ fee = {
836
+ 'cost': feeCost,
837
+ 'currency': this.safeString(trade, 'fee_currency'),
838
+ };
839
+ }
840
+ else {
841
+ const imbalance = this.safeString(trade, 'imbalance');
842
+ if (Precise["default"].stringLt(imbalance, '0')) {
843
+ side = 'buy';
844
+ }
845
+ else {
846
+ side = 'sell';
847
+ }
848
+ }
849
+ const takerOrMaker = this.safeString(trade, 'fee_type');
850
+ return this.safeTrade({
851
+ 'id': id,
852
+ 'order': order,
853
+ 'timestamp': timestamp,
854
+ 'datetime': this.iso8601(timestamp),
855
+ 'symbol': symbol,
856
+ 'type': undefined,
857
+ 'side': side,
858
+ 'takerOrMaker': takerOrMaker,
859
+ 'price': priceString,
860
+ 'amount': amountString,
861
+ 'cost': undefined,
862
+ 'fee': fee,
863
+ 'info': trade,
864
+ }, market);
865
+ }
866
+ async fetchTradingFees(params = {}) {
867
+ /**
868
+ * @method
869
+ * @name coinlist#fetchTradingFees
870
+ * @description fetch the trading fees for multiple markets
871
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-fees
872
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
873
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
874
+ */
875
+ await this.loadMarkets();
876
+ const response = await this.privateGetV1Fees(params);
877
+ //
878
+ // {
879
+ // fees_by_symbols: {
880
+ // 'BTC-USD,BTC-USDT,ETH-USD,ETH-USDT,ETH-BTC,AAVE-USD,AAVE-USDT,ALGO-USD,ALGO-USDT,AVAX-USD,AVAX-USDT,BICO-USD,BICO-USDT,BLD-USD,BLD-USDT,BTRST-USDT,BZZ-USDT,CELO-USD,CELO-BTC,CFG-USD,CFG-USDT,CLV-USDT,COMP-USD,COMP-USDT,CYBER-USDT,CQT-USDT,CSPR-USD,CSPR-USDT,CUSD-USD,CUSD-USDC,DOGE-USD,DOGE-USDT,DOT-USD,DOT-USDT,EFI-USDT,FIL-USD,FIL-USDT,FLOW-USD,FLOW-USDT,GAL-USD,GAL-USDT,GODS-USDT,GOG-USDT,HMT-USD,HMT-USDT,ICP-USD,ICP-USDT,IMX-USD,IMX-USDT,LINK-USD,LINK-USDT,MATIC-USD,MATIC-USDT,MINA-USD,MINA-USDT,MKR-USD,MKR-USDT,NEON-USDT,NYM-USD,NYM-USDT,OCEAN-USD,OXT-USD,ROSE-USD,ROSE-USDT,SKL-USD,SKL-USDT,SOL-USD,SOL-USDT,STX-USDT,SUI-USDT,T-USDT,UNI-USD,UNI-USDT,USDT-USD,VEGA-USDT,WAXL-USD,WAXL-USDT,WBTC-BTC,WCFG-USD,WCFG-USDT,XTZ-USD': {
881
+ // base: {
882
+ // fees: { maker: '0', taker: '0.0045', liquidation: '0' },
883
+ // floors: { maker: null, taker: null }
884
+ // },
885
+ // volume_tier_1: {
886
+ // fees: { maker: '0', taker: '0.003', liquidation: '0' },
887
+ // floors: { maker: null, taker: null }
888
+ // },
889
+ // volume_tier_2: {
890
+ // fees: { maker: '0', taker: '0.0025', liquidation: '0' },
891
+ // floors: { maker: null, taker: null }
892
+ // },
893
+ // volume_tier_3: {
894
+ // fees: { maker: '0', taker: '0.002', liquidation: '0' },
895
+ // floors: { maker: null, taker: null }
896
+ // },
897
+ // volume_tier_4: {
898
+ // fees: { maker: '0', taker: '0.0018', liquidation: '0' },
899
+ // floors: { maker: null, taker: null }
900
+ // },
901
+ // volume_tier_5: {
902
+ // fees: { maker: '0', taker: '0.0018', liquidation: '0' },
903
+ // floors: { maker: null, taker: null }
904
+ // },
905
+ // volume_tier_6: {
906
+ // fees: { maker: '0', taker: '0.0016', liquidation: '0' },
907
+ // floors: { maker: null, taker: null }
908
+ // },
909
+ // volume_tier_7: {
910
+ // fees: { maker: '0', taker: '0.0013', liquidation: '0' },
911
+ // floors: { maker: null, taker: null }
912
+ // },
913
+ // volume_tier_8: {
914
+ // fees: { maker: '0', taker: '0.0012', liquidation: '0' },
915
+ // floors: { maker: null, taker: null }
916
+ // },
917
+ // volume_tier_9: {
918
+ // fees: { maker: '0', taker: '0.001', liquidation: '0' },
919
+ // floors: { maker: null, taker: null }
920
+ // }
921
+ // volume_tier_10: {
922
+ // fees: { maker: '0', taker: '0.0005', liquidation: '0' },
923
+ // floors: { maker: null, taker: null }
924
+ // },
925
+ // volume_tier_11: {
926
+ // fees: { maker: '0', taker: '0.0005', liquidation: '0' },
927
+ // floors: { maker: null, taker: null }
928
+ // },
929
+ // }
930
+ // }
931
+ // }
932
+ //
933
+ const fees = this.safeValue(response, 'fees_by_symbols', {});
934
+ const result = {};
935
+ const groupsOfSymbols = Object.keys(fees);
936
+ for (let i = 0; i < groupsOfSymbols.length; i++) {
937
+ const group = groupsOfSymbols[i];
938
+ const feeTiers = this.safeValue(fees, group, {});
939
+ const tiers = this.parseFeeTiers(feeTiers);
940
+ const firstTier = this.safeValue(feeTiers, 'base', {});
941
+ const firstTierFees = this.safeValue(firstTier, 'fees', {});
942
+ const ids = group.split(',');
943
+ for (let j = 0; j < ids.length; j++) {
944
+ const id = ids[j];
945
+ const market = this.safeMarket(id);
946
+ const symbol = market['symbol'];
947
+ const info = {};
948
+ info[group] = feeTiers;
949
+ result[symbol] = {
950
+ 'info': info,
951
+ 'symbol': symbol,
952
+ 'maker': this.safeNumber(firstTierFees, 'maker'),
953
+ 'taker': this.safeNumber(firstTierFees, 'taker'),
954
+ 'percentage': true,
955
+ 'tierBased': true,
956
+ 'tiers': tiers,
957
+ };
958
+ }
959
+ }
960
+ return result;
961
+ }
962
+ parseFeeTiers(feeTiers, market = undefined) {
963
+ //
964
+ // base: {
965
+ // fees: { maker: '0', taker: '0.0045', liquidation: '0' },
966
+ // floors: { maker: null, taker: null }
967
+ // },
968
+ // volume_tier_1: {
969
+ // fees: { maker: '0', taker: '0.003', liquidation: '0' },
970
+ // floors: { maker: null, taker: null }
971
+ // },
972
+ // volume_tier_2: {
973
+ // fees: { maker: '0', taker: '0.0025', liquidation: '0' },
974
+ // floors: { maker: null, taker: null }
975
+ // },
976
+ // volume_tier_3: {
977
+ // fees: { maker: '0', taker: '0.002', liquidation: '0' },
978
+ // floors: { maker: null, taker: null }
979
+ // },
980
+ // volume_tier_4: {
981
+ // fees: { maker: '0', taker: '0.0018', liquidation: '0' },
982
+ // floors: { maker: null, taker: null }
983
+ // },
984
+ // volume_tier_5: {
985
+ // fees: { maker: '0', taker: '0.0018', liquidation: '0' },
986
+ // floors: { maker: null, taker: null }
987
+ // },
988
+ // volume_tier_6: {
989
+ // fees: { maker: '0', taker: '0.0016', liquidation: '0' },
990
+ // floors: { maker: null, taker: null }
991
+ // },
992
+ // volume_tier_7: {
993
+ // fees: { maker: '0', taker: '0.0013', liquidation: '0' },
994
+ // floors: { maker: null, taker: null }
995
+ // },
996
+ // volume_tier_8: {
997
+ // fees: { maker: '0', taker: '0.0012', liquidation: '0' },
998
+ // floors: { maker: null, taker: null }
999
+ // },
1000
+ // volume_tier_9: {
1001
+ // fees: { maker: '0', taker: '0.001', liquidation: '0' },
1002
+ // floors: { maker: null, taker: null }
1003
+ // }
1004
+ // volume_tier_10: {
1005
+ // fees: { maker: '0', taker: '0.0005', liquidation: '0' },
1006
+ // floors: { maker: null, taker: null }
1007
+ // },
1008
+ // volume_tier_11: {
1009
+ // fees: { maker: '0', taker: '0.0005', liquidation: '0' },
1010
+ // floors: { maker: null, taker: null }
1011
+ // },
1012
+ //
1013
+ let takerFees = [];
1014
+ let makerFees = [];
1015
+ const keys = Object.keys(feeTiers);
1016
+ const keysLength = keys.length;
1017
+ if (keysLength > 0) {
1018
+ for (let i = 0; i < keysLength; i++) {
1019
+ const key = keys[i];
1020
+ const tier = this.safeValue(feeTiers, key, {});
1021
+ const tierFees = this.safeValue(tier, 'fees', {});
1022
+ const taker = this.safeString(tierFees, 'taker');
1023
+ const maker = this.safeString(tierFees, 'maker');
1024
+ makerFees.push([undefined, this.parseNumber(maker)]);
1025
+ takerFees.push([undefined, this.parseNumber(taker)]);
1026
+ }
1027
+ takerFees = this.sortBy(takerFees, 1, true);
1028
+ makerFees = this.sortBy(makerFees, 1, true);
1029
+ const firstTier = this.safeValue(takerFees, 0, []);
1030
+ const exchangeFees = this.safeValue(this, 'fees', {});
1031
+ const exchangeFeesTrading = this.safeValue(exchangeFees, 'trading', {});
1032
+ const exchangeFeesTradingTiers = this.safeValue(exchangeFeesTrading, 'tiers', {});
1033
+ const exchangeFeesTradingTiersTaker = this.safeValue(exchangeFeesTradingTiers, 'taker', []);
1034
+ const exchangeFeesTradingTiersMaker = this.safeValue(exchangeFeesTradingTiers, 'maker', []);
1035
+ if ((keysLength === exchangeFeesTradingTiersTaker.length) && (firstTier.length > 0)) {
1036
+ for (let i = 0; i < keysLength; i++) {
1037
+ takerFees[i][0] = exchangeFeesTradingTiersTaker[i][0];
1038
+ makerFees[i][0] = exchangeFeesTradingTiersMaker[i][0];
1039
+ }
1040
+ }
1041
+ }
1042
+ return {
1043
+ 'maker': makerFees,
1044
+ 'taker': takerFees,
1045
+ };
1046
+ }
1047
+ async fetchAccounts(params = {}) {
1048
+ /**
1049
+ * @method
1050
+ * @name coinlist#fetchAccounts
1051
+ * @description fetch all the accounts associated with a profile
1052
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-accounts
1053
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1054
+ * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
1055
+ */
1056
+ await this.loadMarkets();
1057
+ const response = await this.privateGetV1Accounts(params);
1058
+ //
1059
+ // {
1060
+ // "accounts": [
1061
+ // {
1062
+ // "trader_id": "b18507ce-7d55-4bf1-b12a-0ccca5b90936",
1063
+ // "name": "string"
1064
+ // }
1065
+ // ]
1066
+ // }
1067
+ //
1068
+ const accounts = this.safeValue(response, 'accounts', []);
1069
+ return this.parseAccounts(accounts, params);
1070
+ }
1071
+ parseAccount(account) {
1072
+ //
1073
+ // {
1074
+ // "trader_id": "b18507ce-7d55-4bf1-b12a-0ccca5b90936",
1075
+ // "name": "string"
1076
+ // }
1077
+ //
1078
+ return {
1079
+ 'id': this.safeString(account, 'trader_id'),
1080
+ 'type': 'trading',
1081
+ 'code': undefined,
1082
+ 'info': account,
1083
+ };
1084
+ }
1085
+ async fetchBalance(params = {}) {
1086
+ /**
1087
+ * @method
1088
+ * @name coinlist#fetchBalance
1089
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1090
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-balances
1091
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1092
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1093
+ */
1094
+ await this.loadMarkets();
1095
+ const response = await this.privateGetV1Balances(params);
1096
+ return this.parseBalance(response);
1097
+ }
1098
+ parseBalance(response) {
1099
+ //
1100
+ // {
1101
+ // "asset_balances": {
1102
+ // "BTC": "0.00308696",
1103
+ // "ETH": "20.000000000000000000"
1104
+ // },
1105
+ // "asset_holds": {
1106
+ // "BTC": "0.00000000",
1107
+ // "ETH": "1.000000000000000000"
1108
+ // },
1109
+ // "net_liquidation_value_usd": "string"
1110
+ // }
1111
+ //
1112
+ const result = {
1113
+ 'info': response,
1114
+ 'timestamp': undefined,
1115
+ 'datetime': undefined,
1116
+ };
1117
+ const totalBalances = this.safeValue(response, 'asset_balances', {});
1118
+ const usedBalances = this.safeValue(response, 'asset_holds', {});
1119
+ const currencyIds = Object.keys(totalBalances);
1120
+ for (let i = 0; i < currencyIds.length; i++) {
1121
+ const currencyId = currencyIds[i];
1122
+ const code = this.safeCurrencyCode(currencyId);
1123
+ const account = this.account();
1124
+ account['total'] = this.safeString(totalBalances, currencyId);
1125
+ account['used'] = this.safeString(usedBalances, currencyId, '0');
1126
+ result[code] = account;
1127
+ }
1128
+ return this.safeBalance(result);
1129
+ }
1130
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1131
+ /**
1132
+ * @method
1133
+ * @name coinlist#fetchMyTrades
1134
+ * @description fetch all trades made by the user
1135
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-fills
1136
+ * @param {string} symbol unified market symbol
1137
+ * @param {int} [since] the earliest time in ms to fetch trades for
1138
+ * @param {int} [limit] the maximum number of trades structures to retrieve (default 200, max 500)
1139
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1140
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1141
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1142
+ */
1143
+ await this.loadMarkets();
1144
+ const request = {};
1145
+ let market = undefined;
1146
+ if (symbol !== undefined) {
1147
+ market = this.market(symbol);
1148
+ request['symbol'] = market['id'];
1149
+ }
1150
+ if (since !== undefined) {
1151
+ request['start_time'] = this.iso8601(since);
1152
+ }
1153
+ if (limit !== undefined) {
1154
+ request['count'] = limit;
1155
+ }
1156
+ const until = this.safeInteger2(params, 'till', 'until');
1157
+ if (until !== undefined) {
1158
+ params = this.omit(params, ['till', 'until']);
1159
+ request['end_time'] = this.iso8601(until);
1160
+ }
1161
+ const response = await this.privateGetV1Fills(this.extend(request, params));
1162
+ //
1163
+ // {
1164
+ // "fills": [
1165
+ // {
1166
+ // "symbol": "ETH-USDT",
1167
+ // "auction_code": "ETH-USDT-2023-10-20T13:16:30.000Z",
1168
+ // "order_id": "39911d5f-c789-4a7d-ad34-820a804d1da6",
1169
+ // "quantity": "-0.0009",
1170
+ // "price": "1608.83000000",
1171
+ // "fee": "0.006516",
1172
+ // "fee_type": "taker",
1173
+ // "fee_currency": "USDT",
1174
+ // "logical_time": "2023-10-20T13:16:30.000Z"
1175
+ // },
1176
+ // {
1177
+ // "symbol": "ETH-USDT",
1178
+ // "auction_code": "ETH-USDT-2023-10-20T13:22:14.000Z",
1179
+ // "order_id": "83ed365f-497d-433b-96c1-9d08c1a12842",
1180
+ // "quantity": "0.0008",
1181
+ // "price": "1615.24000000",
1182
+ // "fee": "0.005815",
1183
+ // "fee_type": "taker",
1184
+ // "fee_currency": "USDT",
1185
+ // "logical_time": "2023-10-20T13:22:14.000Z"
1186
+ // },
1187
+ // ]
1188
+ // }
1189
+ //
1190
+ const fills = this.safeValue(response, 'fills', []);
1191
+ return this.parseTrades(fills, market, since, limit);
1192
+ }
1193
+ async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1194
+ /**
1195
+ * @method
1196
+ * @name coinlist#fetchOrderTrades
1197
+ * @description fetch all the trades made from a single order
1198
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-fills
1199
+ * @param {string} id order id
1200
+ * @param {string} symbol unified market symbol
1201
+ * @param {int} [since] the earliest time in ms to fetch trades for
1202
+ * @param {int} [limit] the maximum number of trades to retrieve
1203
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1204
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1205
+ */
1206
+ const request = {
1207
+ 'order_id': id,
1208
+ };
1209
+ return await this.fetchMyTrades(symbol, since, limit, this.extend(request, params));
1210
+ }
1211
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1212
+ /**
1213
+ * @method
1214
+ * @name coinlist#fetchOrders
1215
+ * @description fetches information on multiple orders made by the user
1216
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
1217
+ * @param {string} symbol unified market symbol of the market orders were made in
1218
+ * @param {int} [since] the earliest time in ms to fetch orders for
1219
+ * @param {int} [limit] the maximum number of order structures to retrieve (default 200, max 500)
1220
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1221
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1222
+ * @param {string|string[]} [params.status] the status of the order - 'accepted', 'done', 'canceled', 'rejected', 'pending' (default [ 'accepted', 'done', 'canceled', 'rejected', 'pending' ])
1223
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1224
+ */
1225
+ await this.loadMarkets();
1226
+ let status = this.safeString(params, 'status');
1227
+ if (status === undefined) {
1228
+ status = ['accepted', 'done', 'canceled', 'rejected', 'pending'];
1229
+ }
1230
+ const request = {
1231
+ 'status': status,
1232
+ };
1233
+ let market = undefined;
1234
+ if (symbol !== undefined) {
1235
+ market = this.market(symbol);
1236
+ request['symbol'] = market['id'];
1237
+ }
1238
+ if (since !== undefined) {
1239
+ request['start_time'] = this.iso8601(since);
1240
+ }
1241
+ if (limit !== undefined) {
1242
+ request['count'] = limit;
1243
+ }
1244
+ const until = this.safeInteger2(params, 'till', 'until');
1245
+ if (until !== undefined) {
1246
+ params = this.omit(params, ['till', 'until']);
1247
+ request['end_time'] = this.iso8601(until);
1248
+ }
1249
+ const response = await this.privateGetV1Orders(this.extend(request, params));
1250
+ //
1251
+ // {
1252
+ // "orders":[
1253
+ // {
1254
+ // "order_id":"913ea6e7-9fc9-43fb-9db1-f195d3baa93f",
1255
+ // "price":"35800.00000000",
1256
+ // "stop_price":null,
1257
+ // "cost":"0.00000000",
1258
+ // "fill_fees":"0.00000000",
1259
+ // "trader_id":"9c6f737e-a829-4843-87b1-b1ce86f2853b",
1260
+ // "status":"accepted",
1261
+ // "epoch_timestamp":"2023-10-26T08:20:56.307Z",
1262
+ // "origin":"web",
1263
+ // "self_trade_prevention":null,
1264
+ // "client_id":null,
1265
+ // "created_at":"2023-10-26T08:20:56.307Z",
1266
+ // "symbol":"BTC-USDT",
1267
+ // "size":"0.0003",
1268
+ // "side":"sell",
1269
+ // "type":"limit",
1270
+ // "post_only":false,
1271
+ // "size_filled":"0.0000"
1272
+ // }
1273
+ // ]
1274
+ // }
1275
+ //
1276
+ const orders = this.safeValue(response, 'orders', []);
1277
+ return this.parseOrders(orders, market, since, limit);
1278
+ }
1279
+ async fetchOrder(id, symbol = undefined, params = {}) {
1280
+ /**
1281
+ * @method
1282
+ * @name coinlist#fetchOrder
1283
+ * @description fetches information on an order made by the user
1284
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-specific-order-by-id
1285
+ * @param {int|string} id order id
1286
+ * @param {string} symbol not used by coinlist fetchOrder ()
1287
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1288
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1289
+ */
1290
+ await this.loadMarkets();
1291
+ const request = {
1292
+ 'order_id': id,
1293
+ };
1294
+ const response = await this.privateGetV1OrdersOrderId(this.extend(request, params));
1295
+ //
1296
+ // {
1297
+ // "order_id": "93101167-9065-4b9c-b98b-5d789a3ed9fe",
1298
+ // "client_id": "string",
1299
+ // "symbol": "string",
1300
+ // "type": "market",
1301
+ // "side": "buy",
1302
+ // "size": "string",
1303
+ // "price": "string",
1304
+ // "stop_price": "string",
1305
+ // "stop_trigger": "last",
1306
+ // "self_trade_prevention": "keep-newest",
1307
+ // "average_fill_price": "string",
1308
+ // "fill_fees": "string",
1309
+ // "size_filled": "string",
1310
+ // "created_at": "2019-08-24T14:15:22Z",
1311
+ // "epoch_timestamp": "2019-08-24T14:15:22Z",
1312
+ // "post_only": true,
1313
+ // "peg_price_type": "trailing-stop",
1314
+ // "peg_offset_value": "string",
1315
+ // "origin": "web",
1316
+ // "status": "pending"
1317
+ // }
1318
+ //
1319
+ return this.parseOrder(response);
1320
+ }
1321
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1322
+ /**
1323
+ * @method
1324
+ * @name coinlist#fetchOpenOrders
1325
+ * @description fetch all unfilled currently open orders
1326
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
1327
+ * @param {string} symbol unified market symbol
1328
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1329
+ * @param {int} [limit] the maximum number of open order structures to retrieve (default 200, max 500)
1330
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1331
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1332
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1333
+ */
1334
+ await this.loadMarkets();
1335
+ const request = {
1336
+ 'status': 'accepted',
1337
+ };
1338
+ return this.fetchOrders(symbol, since, limit, this.extend(request, params));
1339
+ }
1340
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1341
+ /**
1342
+ * @method
1343
+ * @name coinlist#fetchClosedOrders
1344
+ * @description fetches information on multiple closed orders made by the user
1345
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
1346
+ * @param {string} symbol unified market symbol of the market orders were made in
1347
+ * @param {int} [since] the earliest time in ms to fetch orders for
1348
+ * @param {int} [limit] the maximum number of closed order structures to retrieve (default 200, max 500)
1349
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1350
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1351
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1352
+ */
1353
+ await this.loadMarkets();
1354
+ const request = {
1355
+ 'status': 'done',
1356
+ };
1357
+ return this.fetchOrders(symbol, since, limit, this.extend(request, params));
1358
+ }
1359
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1360
+ /**
1361
+ * @method
1362
+ * @name coinlist#fetchCanceledOrders
1363
+ * @description fetches information on multiple canceled orders made by the user
1364
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
1365
+ * @param {string} symbol unified market symbol of the market orders were made in
1366
+ * @param {int} [since] the earliest time in ms to fetch orders for
1367
+ * @param {int} [limit] the maximum number of canceled order structures to retrieve (default 200, max 500)
1368
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1369
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1370
+ * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1371
+ */
1372
+ await this.loadMarkets();
1373
+ const request = {
1374
+ 'status': 'canceled',
1375
+ };
1376
+ return this.fetchOrders(symbol, since, limit, this.extend(request, params));
1377
+ }
1378
+ async cancelAllOrders(symbol = undefined, params = {}) {
1379
+ /**
1380
+ * @method
1381
+ * @name coinlist#cancelAllOrders
1382
+ * @description cancel open orders of market
1383
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#cancel-all-orders
1384
+ * @param {string} symbol unified market symbol
1385
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1386
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1387
+ */
1388
+ await this.loadMarkets();
1389
+ let market = undefined;
1390
+ const request = {};
1391
+ if (symbol !== undefined) {
1392
+ market = this.market(symbol);
1393
+ request['symbol'] = market['id'];
1394
+ }
1395
+ const response = await this.privateDeleteV1Orders(this.extend(request, params));
1396
+ //
1397
+ // {
1398
+ // "message": "Order cancellation request received.",
1399
+ // "timestamp": "2023-10-26T10:29:28.652Z"
1400
+ // }
1401
+ //
1402
+ const orders = [response];
1403
+ return this.parseOrders(orders, market);
1404
+ }
1405
+ async cancelOrder(id, symbol = undefined, params = {}) {
1406
+ /**
1407
+ * @method
1408
+ * @name coinlist#cancelOrder
1409
+ * @description cancels an open order
1410
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#cancel-specific-order-by-id
1411
+ * @param {string} id order id
1412
+ * @param {string} symbol not used by coinlist cancelOrder ()
1413
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1414
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1415
+ */
1416
+ await this.loadMarkets();
1417
+ const request = {
1418
+ 'order_id': id,
1419
+ };
1420
+ const response = await this.privateDeleteV1OrdersOrderId(this.extend(request, params));
1421
+ //
1422
+ // {
1423
+ // "message": "Cancel order request received.",
1424
+ // "order_id": "d36e7588-6525-485c-b768-8ad8b3f745f9",
1425
+ // "timestamp": "2023-10-26T14:36:37.559Z"
1426
+ // }
1427
+ //
1428
+ return this.parseOrder(response);
1429
+ }
1430
+ async cancelOrders(ids, symbol = undefined, params = {}) {
1431
+ /**
1432
+ * @method
1433
+ * @name coinlist#cancelOrders
1434
+ * @description cancel multiple orders
1435
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#cancel-specific-orders
1436
+ * @param {string[]} ids order ids
1437
+ * @param {string} symbol not used by coinlist cancelOrders ()
1438
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1439
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1440
+ */
1441
+ await this.loadMarkets();
1442
+ params = ids;
1443
+ const response = await this.privateDeleteV1OrdersBulk(params);
1444
+ return response;
1445
+ }
1446
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1447
+ /**
1448
+ * @method
1449
+ * @name coinlist#createOrder
1450
+ * @description create a trade order
1451
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#create-new-order
1452
+ * @param {string} symbol unified symbol of the market to create an order in
1453
+ * @param {string} type 'market' or 'limit' or 'stop_market' or 'stop_limit' or 'take_market' or 'take_limit'
1454
+ * @param {string} side 'buy' or 'sell'
1455
+ * @param {float} amount how much of currency you want to trade in units of base currency
1456
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1457
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1458
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately (default false)
1459
+ * @param {float} [params.triggerPrice] only for the 'stop_market', 'stop_limit', 'take_market' or 'take_limit' orders (the price at which an order is triggered)
1460
+ * @param {string} [params.clientOrderId] client order id (default undefined)
1461
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1462
+ */
1463
+ await this.loadMarkets();
1464
+ const market = this.market(symbol);
1465
+ const request = {
1466
+ 'symbol': market['id'],
1467
+ 'type': type,
1468
+ 'side': side,
1469
+ 'size': this.amountToPrecision(symbol, amount),
1470
+ };
1471
+ let isMarket = false;
1472
+ if ((type === 'limit') || (type === 'stop_limit') || (type === 'take_limit')) {
1473
+ if (price === undefined) {
1474
+ throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a price argument for a ' + type + ' order');
1475
+ }
1476
+ request['price'] = this.priceToPrecision(symbol, price);
1477
+ }
1478
+ else {
1479
+ isMarket = true;
1480
+ }
1481
+ let postOnly = undefined;
1482
+ [postOnly, params] = this.handlePostOnly(isMarket, false, params);
1483
+ if (postOnly) {
1484
+ request['post_only'] = true;
1485
+ }
1486
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'trigger_price', 'stopPrice', 'stop_price']);
1487
+ if (triggerPrice !== undefined) {
1488
+ params = this.omit(params, ['triggerPrice', 'trigger_price', 'stopPrice']);
1489
+ request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
1490
+ if (type === 'market') {
1491
+ request['type'] = 'stop_market';
1492
+ }
1493
+ else if (type === 'limit') {
1494
+ request['type'] = 'stop_limit';
1495
+ }
1496
+ }
1497
+ else if ((type === 'stop_market') || (type === 'stop_limit') || (type === 'take_market') || (type === 'take_limit')) {
1498
+ throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a stopPrice parameter for stop-loss and take-profit orders');
1499
+ }
1500
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_id');
1501
+ if (clientOrderId !== undefined) {
1502
+ request['client_id'] = clientOrderId;
1503
+ params = this.omit(params, ['clientOrderId', 'client_id']);
1504
+ }
1505
+ const response = await this.privatePostV1Orders(this.extend(request, params));
1506
+ //
1507
+ // {
1508
+ // "message": "New order request received.",
1509
+ // "order": {
1510
+ // "symbol": "BTC-USDT",
1511
+ // "type": "market",
1512
+ // "side": "sell",
1513
+ // "size": "0.0003",
1514
+ // "order_id": "cad67c0f-9aec-4ac8-ac03-aaf5db299ff7",
1515
+ // "trader_id": "9c6f737e-a829-4843-87b1-b1ce86f2853b"
1516
+ // },
1517
+ // "timestamp": "2023-10-26T11:30:55.376Z"
1518
+ // }
1519
+ //
1520
+ const order = this.safeValue(response, 'order', {});
1521
+ return this.parseOrder(order, market);
1522
+ }
1523
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1524
+ /**
1525
+ * @method
1526
+ * @name coinlist#editOrder
1527
+ * @description create a trade order
1528
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#modify-existing-order
1529
+ * @param {string} symbol unified symbol of the market to create an order in
1530
+ * @param {string} type 'market' or 'limit' or 'stop_market' or 'stop_limit' or 'take_market' or 'take_limit'
1531
+ * @param {string} side 'buy' or 'sell'
1532
+ * @param {float} amount how much of currency you want to trade in units of base currency
1533
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1534
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1535
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1536
+ */
1537
+ await this.loadMarkets();
1538
+ if (amount === undefined) {
1539
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() requires an amount argument');
1540
+ }
1541
+ const market = this.market(symbol);
1542
+ const request = {
1543
+ 'order_id': id,
1544
+ 'type': type,
1545
+ 'side': side,
1546
+ 'size': this.amountToPrecision(symbol, amount),
1547
+ };
1548
+ if (price !== undefined) {
1549
+ request['price'] = this.priceToPrecision(symbol, price);
1550
+ }
1551
+ const response = await this.privatePatchV1OrdersOrderId(this.extend(request, params));
1552
+ return this.parseOrder(response, market);
1553
+ }
1554
+ parseOrder(order, market = undefined) {
1555
+ //
1556
+ // fetchOrder
1557
+ // {
1558
+ // "order_id": "913ea6e7-9fc9-43fb-9db1-f195d3baa93f",
1559
+ // "price": "35800.00000000",
1560
+ // "stop_price":null,
1561
+ // "cost": "0.00000000",
1562
+ // "fill_fees": "0.00000000",
1563
+ // "trader_id": "9c6f737e-a829-4843-87b1-b1ce86f2853b",
1564
+ // "status": "canceled",
1565
+ // "epoch_timestamp": "2023-10-26T08:20:56.307Z",
1566
+ // "origin": "web",
1567
+ // "self_trade_prevention":null,
1568
+ // "client_id":null,
1569
+ // "symbol": "BTC-USDT",
1570
+ // "size": "0.0003",
1571
+ // "side": "sell",
1572
+ // "type": "limit",
1573
+ // "post_only":false,
1574
+ // "size_filled": "0.0000"
1575
+ // }
1576
+ //
1577
+ // fetchOrders
1578
+ // {
1579
+ // "order_id":"913ea6e7-9fc9-43fb-9db1-f195d3baa93f",
1580
+ // "price":"35800.00000000",
1581
+ // "stop_price":null,
1582
+ // "cost":"0.00000000",
1583
+ // "fill_fees":"0.00000000",
1584
+ // "trader_id":"9c6f737e-a829-4843-87b1-b1ce86f2853b",
1585
+ // "status":"accepted",
1586
+ // "epoch_timestamp":"2023-10-26T08:20:56.307Z",
1587
+ // "origin":"web",
1588
+ // "self_trade_prevention":null,
1589
+ // "client_id":null,
1590
+ // "created_at":"2023-10-26T08:20:56.307Z",
1591
+ // "symbol":"BTC-USDT",
1592
+ // "size":"0.0003",
1593
+ // "side":"sell",
1594
+ // "type":"limit",
1595
+ // "post_only":false,
1596
+ // "size_filled":"0.0000"
1597
+ // }
1598
+ //
1599
+ // createOrder
1600
+ // {
1601
+ // "symbol": "BTC-USDT",
1602
+ // "type": "market",
1603
+ // "side": "sell",
1604
+ // "size": "0.0003",
1605
+ // "order_id": "cad67c0f-9aec-4ac8-ac03-aaf5db299ff7",
1606
+ // "trader_id": "9c6f737e-a829-4843-87b1-b1ce86f2853b"
1607
+ // },
1608
+ //
1609
+ // cancelOrder
1610
+ // {
1611
+ // "message": "Cancel order request received.",
1612
+ // "order_id": "d36e7588-6525-485c-b768-8ad8b3f745f9",
1613
+ // "timestamp": "2023-10-26T14:36:37.559Z"
1614
+ // }
1615
+ //
1616
+ // cancelOrders
1617
+ // {
1618
+ // "message": "Order cancellation request received.",
1619
+ // "timestamp": "2023-10-26T10:29:28.652Z"
1620
+ // }
1621
+ //
1622
+ // cancelAllOrders
1623
+ // {
1624
+ // "message": "Order cancellation request received.",
1625
+ // "timestamp": "2023-10-26T10:29:28.652Z"
1626
+ // }
1627
+ //
1628
+ const id = this.safeString(order, 'order_id');
1629
+ const marketId = this.safeString(order, 'symbol');
1630
+ market = this.safeMarket(marketId, market);
1631
+ const clientOrderId = this.safeString(order, 'client_id');
1632
+ let timestampString = this.safeString2(order, 'created_at', 'epoch_timestamp');
1633
+ if (timestampString === undefined) {
1634
+ timestampString = this.safeString(order, 'timestamp');
1635
+ }
1636
+ const timestamp = this.parse8601(timestampString);
1637
+ const status = this.parseOrderStatus(this.safeString(order, 'status'));
1638
+ const type = this.parseOrderType(this.safeString(order, 'type'));
1639
+ const side = this.safeString(order, 'side');
1640
+ const price = this.safeString(order, 'price');
1641
+ const stopPrice = this.safeString(order, 'stop_price');
1642
+ const average = this.safeString(order, 'average_fill_price'); // from documentation
1643
+ const amount = this.safeString(order, 'size');
1644
+ const filled = this.safeString(order, 'size_filled');
1645
+ const feeCost = this.safeString(order, 'fill_fees');
1646
+ const postOnly = this.safeValue(order, 'post_only');
1647
+ let fee = undefined;
1648
+ if (feeCost !== undefined) {
1649
+ fee = {
1650
+ 'currency': market['quote'],
1651
+ 'cost': feeCost,
1652
+ 'rate': undefined,
1653
+ };
1654
+ }
1655
+ return this.safeOrder({
1656
+ 'id': id,
1657
+ 'clientOrderId': clientOrderId,
1658
+ 'timestamp': timestamp,
1659
+ 'datetime': this.iso8601(timestamp),
1660
+ 'lastTradeTimestamp': undefined,
1661
+ 'status': status,
1662
+ 'symbol': market['symbol'],
1663
+ 'type': type,
1664
+ 'timeInForce': 'GTC',
1665
+ 'side': side,
1666
+ 'price': price,
1667
+ 'stopPrice': stopPrice,
1668
+ 'triggerPrice': stopPrice,
1669
+ 'average': average,
1670
+ 'amount': amount,
1671
+ 'cost': undefined,
1672
+ 'filled': filled,
1673
+ 'remaining': undefined,
1674
+ 'fee': fee,
1675
+ 'trades': undefined,
1676
+ 'info': order,
1677
+ 'postOnly': postOnly,
1678
+ }, market);
1679
+ }
1680
+ parseOrderStatus(status) {
1681
+ const statuses = {
1682
+ 'pending': 'open',
1683
+ 'accepted': 'open',
1684
+ 'rejected': 'rejected',
1685
+ 'done': 'closed',
1686
+ 'canceled': 'canceled',
1687
+ };
1688
+ return this.safeString(statuses, status, status);
1689
+ }
1690
+ parseOrderType(status) {
1691
+ const statuses = {
1692
+ 'market': 'market',
1693
+ 'limit': 'limit',
1694
+ 'stop_market': 'market',
1695
+ 'stop_limit': 'limit',
1696
+ 'take_market': 'market',
1697
+ 'take_limit': 'limit',
1698
+ };
1699
+ return this.safeString(statuses, status, status);
1700
+ }
1701
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
1702
+ /**
1703
+ * @method
1704
+ * @name coinlist#transfer
1705
+ * @description transfer currency internally between wallets on the same account
1706
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-between-entities
1707
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-from-wallet-to-pro
1708
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-from-pro-to-wallet
1709
+ * @param {string} code unified currency code
1710
+ * @param {float} amount amount to transfer
1711
+ * @param {string} fromAccount account to transfer from
1712
+ * @param {string} toAccount account to transfer to
1713
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1714
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1715
+ */
1716
+ await this.loadMarkets();
1717
+ const currency = this.currency(code);
1718
+ amount = this.currencyToPrecision(code, amount);
1719
+ const request = {
1720
+ 'asset': currency['id'],
1721
+ 'amount': amount,
1722
+ };
1723
+ const accountsByType = this.safeValue(this.options, 'accountsByType', {});
1724
+ const fromAcc = this.safeString(accountsByType, fromAccount, fromAccount);
1725
+ const toAcc = this.safeString(accountsByType, toAccount, toAccount);
1726
+ let response = undefined;
1727
+ if ((fromAcc === 'funding') && (toAcc === 'trading')) {
1728
+ response = await this.privatePostV1TransfersFromWallet(this.extend(request, params));
1729
+ }
1730
+ else if ((fromAcc === 'trading') && (toAcc === 'funding')) {
1731
+ response = await this.privatePostV1TransfersToWallet(this.extend(request, params));
1732
+ }
1733
+ else {
1734
+ request['from_trader_id'] = fromAcc;
1735
+ request['to_trader_id'] = toAcc;
1736
+ response = await this.privatePostV1TransfersInternalTransfer(this.extend(request, params));
1737
+ }
1738
+ //
1739
+ // privatePostV1TransfersInternalTransfer
1740
+ // {
1741
+ // "from_trader_id": "1f494ace-b3ed-4324-b202-55526ed06381",
1742
+ // "to_trader_id": "d32c7a40-cc24-44b0-8597-f9edb3da989f",
1743
+ // "asset": "string",
1744
+ // "amount": "string"
1745
+ // }
1746
+ //
1747
+ // privatePostV1TransfersFromWallet, privatePostV1TransfersToWallet
1748
+ // {
1749
+ // "transfer_id": "bb34f528-d9b0-47c6-b11f-4d4840b86ee3"
1750
+ // }
1751
+ //
1752
+ const transfer = this.parseTransfer(response, currency);
1753
+ return transfer;
1754
+ }
1755
+ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
1756
+ /**
1757
+ * @method
1758
+ * @name coinlist#fetchTransfers
1759
+ * @description fetch a history of internal transfers between CoinList.co and CoinList Pro. It does not return external deposits or withdrawals
1760
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#list-transfers
1761
+ * @param {string} code unified currency code
1762
+ * @param {int} [since] the earliest time in ms to fetch transfers for
1763
+ * @param {int} [limit] the maximum number of transfer structures to retrieve (default 200, max 500)
1764
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1765
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1766
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1767
+ */
1768
+ await this.loadMarkets();
1769
+ let currency = undefined;
1770
+ if (code !== undefined) {
1771
+ currency = this.currency(code);
1772
+ }
1773
+ const request = {};
1774
+ if (since !== undefined) {
1775
+ request['start_time'] = this.iso8601(since);
1776
+ }
1777
+ if (limit !== undefined) {
1778
+ request['count'] = limit;
1779
+ }
1780
+ const until = this.safeInteger2(params, 'till', 'until');
1781
+ if (until !== undefined) {
1782
+ params = this.omit(params, ['till', 'until']);
1783
+ request['end_time'] = this.iso8601(until);
1784
+ }
1785
+ const response = await this.privateGetV1Transfers(this.extend(request, params));
1786
+ //
1787
+ // {
1788
+ // "transfers": [
1789
+ // {
1790
+ // "transfer_id": "2c02db25-e8f2-4271-8222-e110bfd0aa2a",
1791
+ // "created_at": "2023-10-20T13:15:37.000Z",
1792
+ // "confirmed_at": "2023-10-20T13:15:37.000Z",
1793
+ // "asset": "ETH",
1794
+ // "amount": "0.010000000000000000",
1795
+ // "status": "confirmed"
1796
+ // },
1797
+ // {
1798
+ // "transfer_id": "890694db-156c-4e93-a3ef-4db61685aca7",
1799
+ // "created_at": "2023-10-26T14:32:22.000Z",
1800
+ // "confirmed_at": "2023-10-26T14:32:22.000Z",
1801
+ // "asset": "USD",
1802
+ // "amount": "-3.00",
1803
+ // "status": "confirmed"
1804
+ // }
1805
+ // ]
1806
+ // }
1807
+ //
1808
+ const transfers = this.safeValue(response, 'transfers', []);
1809
+ return this.parseTransfers(transfers, currency, since, limit);
1810
+ }
1811
+ parseTransfer(transfer, currency = undefined) {
1812
+ //
1813
+ // fetchTransfers
1814
+ // {
1815
+ // "transfer_id": "890694db-156c-4e93-a3ef-4db61685aca7",
1816
+ // "created_at": "2023-10-26T14:32:22.000Z",
1817
+ // "confirmed_at": "2023-10-26T14:32:22.000Z",
1818
+ // "asset": "USD",
1819
+ // "amount": "-3.00",
1820
+ // "status": "confirmed"
1821
+ // }
1822
+ //
1823
+ // transfer - privatePostV1TransfersInternalTransfer
1824
+ // {
1825
+ // "from_trader_id": "1f494ace-b3ed-4324-b202-55526ed06381",
1826
+ // "to_trader_id": "d32c7a40-cc24-44b0-8597-f9edb3da989f",
1827
+ // "asset": "string",
1828
+ // "amount": "string"
1829
+ // }
1830
+ //
1831
+ // transfer - privatePostV1TransfersFromWallet, privatePostV1TransfersToWallet
1832
+ // {
1833
+ // "transfer_id": "bb34f528-d9b0-47c6-b11f-4d4840b86ee3"
1834
+ // }
1835
+ //
1836
+ const currencyId = this.safeString(transfer, 'asset');
1837
+ const confirmedAt = this.safeString(transfer, 'confirmed_at');
1838
+ const timetstamp = this.parse8601(confirmedAt);
1839
+ const status = this.safeString(transfer, 'status');
1840
+ let amountString = this.safeString(transfer, 'amount');
1841
+ let fromAccount = undefined;
1842
+ let toAccount = undefined;
1843
+ let amount = undefined;
1844
+ if (amountString !== undefined) {
1845
+ const amountIsNegative = Precise["default"].stringLt(amountString, '0');
1846
+ if (amountIsNegative) {
1847
+ fromAccount = 'trading';
1848
+ toAccount = 'funding';
1849
+ amountString = Precise["default"].stringNeg(amountString);
1850
+ }
1851
+ else {
1852
+ fromAccount = 'funding';
1853
+ toAccount = 'trading';
1854
+ }
1855
+ amount = this.parseNumber(amountString);
1856
+ }
1857
+ return {
1858
+ 'info': transfer,
1859
+ 'id': this.safeString(transfer, 'transfer_id'),
1860
+ 'timestamp': timetstamp,
1861
+ 'datetime': this.iso8601(timetstamp),
1862
+ 'currency': this.safeCurrencyCode(currencyId, currency),
1863
+ 'amount': amount,
1864
+ 'fromAccount': fromAccount,
1865
+ 'toAccount': toAccount,
1866
+ 'status': this.parseTransferStatus(status),
1867
+ };
1868
+ }
1869
+ parseTransferStatus(status) {
1870
+ const statuses = {
1871
+ 'confirmed': 'ok',
1872
+ };
1873
+ return this.safeString(statuses, status, status);
1874
+ }
1875
+ async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1876
+ /**
1877
+ * @method
1878
+ * @name coinlist#fetchDepositsWithdrawals
1879
+ * @description fetch history of deposits and withdrawals from external wallets and between CoinList Pro trading account and CoinList wallet
1880
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-coinlist-wallet-ledger
1881
+ * @param {string} [code] unified currency code for the currency of the deposit/withdrawals
1882
+ * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal
1883
+ * @param {int} [limit] max number of deposit/withdrawals to return (default 200, max 500)
1884
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1885
+ * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1886
+ */
1887
+ if (code === undefined) {
1888
+ throw new errors.ArgumentsRequired(this.id + ' fetchDepositsWithdrawals() requires a code argument');
1889
+ }
1890
+ const traderId = this.safeString2(params, 'trader_id', 'traderId');
1891
+ if (traderId === undefined) {
1892
+ throw new errors.ArgumentsRequired(this.id + ' fetchDepositsWithdrawals() requires a traderId argument in the params');
1893
+ }
1894
+ await this.loadMarkets();
1895
+ const currency = this.currency(code);
1896
+ const request = {
1897
+ 'asset': currency['id'],
1898
+ 'trader_id': traderId,
1899
+ };
1900
+ if (limit !== undefined) {
1901
+ request['count'] = limit;
1902
+ }
1903
+ params = this.omit(params, ['trader_id', 'traderId']);
1904
+ const response = await this.privateGetV1AccountsTraderIdWalletLedger(this.extend(request, params));
1905
+ //
1906
+ // [
1907
+ // {
1908
+ // "id": "2c02db25-e8f2-4271-8222-e110bfd0aa2a",
1909
+ // "asset": "ETH",
1910
+ // "amount": "0.01",
1911
+ // "created_at": "2023-10-20T13:15:37.000Z",
1912
+ // "description": "Transfer to CoinList Pro",
1913
+ // "type": "PRO_TRANSFER",
1914
+ // "delta": "-0.010000000000000000"
1915
+ // },
1916
+ // {
1917
+ // "id": "7139384d-6cec-479e-a19c-d498647ccb47",
1918
+ // "asset": "ETH",
1919
+ // "amount": "0.01",
1920
+ // "created_at": "2023-10-20T13:10:55.000Z",
1921
+ // "description": "CRYPTO_DEPOSIT",
1922
+ // "type": "CRYPTO_DEPOSIT",
1923
+ // "delta": "0.010000000000000000"
1924
+ // },
1925
+ //
1926
+ // ...
1927
+ //
1928
+ // {
1929
+ // "id": "91bbbb22-5ede-4e9a-81ef-3f9318aa83d2",
1930
+ // "asset": "USDT",
1931
+ // "amount": "4.169654",
1932
+ // "withdrawal_fee_amount": "8.830346000000000000",
1933
+ // "created_at": "2023-10-27T16:14:11.000Z",
1934
+ // "description": "CRYPTO_WITHDRAWAL",
1935
+ // "type": "CRYPTO_WITHDRAWAL",
1936
+ // "delta": "-4.169654000000000000"
1937
+ // },
1938
+ // {
1939
+ // "id": "830261bd-cda9-401f-b6df-105f4da3b37c",
1940
+ // "asset": "USDT",
1941
+ // "amount": "13",
1942
+ // "created_at": "2023-10-27T14:52:05.000Z",
1943
+ // "description": "Transfer from CoinList Pro",
1944
+ // "type": "PRO_TRANSFER",
1945
+ // "delta": "13.000000000000000000"
1946
+ // }
1947
+ // ]
1948
+ //
1949
+ // coinlist returns both internal transfers and blockchain transactions
1950
+ return this.parseTransactions(response, currency, since, limit);
1951
+ }
1952
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
1953
+ /**
1954
+ * @method
1955
+ * @name coinlist#withdraw
1956
+ * @description request a withdrawal from CoinList wallet. (Disabled by default. Contact CoinList to apply for an exception.)
1957
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#request-withdrawal-from-wallet
1958
+ * @param {string} code unified currency code
1959
+ * @param {float} amount the amount to withdraw
1960
+ * @param {string} address the address to withdraw to
1961
+ * @param {string} tag
1962
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1963
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1964
+ */
1965
+ await this.loadMarkets();
1966
+ const currency = this.currency(code);
1967
+ const request = {
1968
+ 'asset': currency['id'],
1969
+ 'amount': this.currencyToPrecision(code, amount),
1970
+ 'destination_address': address,
1971
+ };
1972
+ const response = await this.privatePostV1TransfersWithdrawalRequest(this.extend(request, params));
1973
+ //
1974
+ // {
1975
+ // "transfer_id": "d4a2d8dd-7def-4545-a062-761683b9aa05"
1976
+ // }
1977
+ //
1978
+ const data = this.safeValue(response, 'data', {});
1979
+ return this.parseTransaction(data, currency);
1980
+ }
1981
+ parseTransaction(transaction, currency = undefined) {
1982
+ // withdraw
1983
+ //
1984
+ // {
1985
+ // "transfer_id": "d4a2d8dd-7def-4545-a062-761683b9aa05"
1986
+ // }
1987
+ //
1988
+ // fetchDepositsWithdrawals
1989
+ // {
1990
+ // "id": "91bbbb22-5ede-4e9a-81ef-3f9318aa83d2",
1991
+ // "asset": "USDT",
1992
+ // "amount": "4.169654",
1993
+ // "withdrawal_fee_amount": "8.830346000000000000",
1994
+ // "created_at": "2023-10-27T16:14:11.000Z",
1995
+ // "description": "CRYPTO_WITHDRAWAL",
1996
+ // "type": "CRYPTO_WITHDRAWAL",
1997
+ // "delta": "-4.169654000000000000"
1998
+ // },
1999
+ //
2000
+ const currencyId = this.safeString(transaction, 'asset');
2001
+ const code = this.safeCurrencyCode(currencyId, currency);
2002
+ const id = this.safeString2(transaction, 'id', 'transfer_id');
2003
+ const amount = this.safeNumber(transaction, 'amount');
2004
+ const timestamp = this.parse8601(this.safeString(transaction, 'created_at'));
2005
+ let type = this.safeString(transaction, 'type', undefined);
2006
+ if (type === undefined) {
2007
+ type = 'withdrawal'; // undefined only in withdraw() method
2008
+ }
2009
+ else {
2010
+ type = this.parseTransactionType(type);
2011
+ }
2012
+ let fee = undefined;
2013
+ const feeCost = this.safeString(transaction, 'withdrawal_fee_amount');
2014
+ if (feeCost !== undefined) {
2015
+ fee = {
2016
+ 'cost': feeCost,
2017
+ 'currency': code,
2018
+ };
2019
+ }
2020
+ return {
2021
+ 'info': transaction,
2022
+ 'id': id,
2023
+ 'txid': undefined,
2024
+ 'timestamp': timestamp,
2025
+ 'datetime': this.iso8601(timestamp),
2026
+ 'network': undefined,
2027
+ 'addressFrom': undefined,
2028
+ 'address': undefined,
2029
+ 'addressTo': undefined,
2030
+ 'tagFrom': undefined,
2031
+ 'tag': undefined,
2032
+ 'tagTo': undefined,
2033
+ 'type': type,
2034
+ 'amount': amount,
2035
+ 'currency': code,
2036
+ 'status': undefined,
2037
+ 'updated': undefined,
2038
+ 'fee': fee,
2039
+ 'comment': this.safeString(transaction, 'description'),
2040
+ 'internal': undefined,
2041
+ };
2042
+ }
2043
+ parseTransactionType(type) {
2044
+ const types = {
2045
+ 'CRYPTO_DEPOSIT': 'deposit',
2046
+ 'CRYPTO_WITHDRAWAL': 'withdrawal',
2047
+ 'PRO_TRANSFER': 'transfer',
2048
+ };
2049
+ return this.safeString(types, type, type);
2050
+ }
2051
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2052
+ /**
2053
+ * @method
2054
+ * @name coinlist#fetchLedger
2055
+ * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2056
+ * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-account-history
2057
+ * @param {string} code unified currency code, default is undefined
2058
+ * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2059
+ * @param {int} [limit] max number of ledger entrys to return (default 200, max 500)
2060
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2061
+ * @param {int} [params.until] the latest time in ms to fetch entries for
2062
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2063
+ */
2064
+ const traderId = this.safeString2(params, 'trader_id', 'traderId');
2065
+ if (traderId === undefined) {
2066
+ throw new errors.ArgumentsRequired(this.id + ' fetchLedger() requires a traderId argument in the params');
2067
+ }
2068
+ await this.loadMarkets();
2069
+ const request = {
2070
+ 'trader_id': traderId,
2071
+ };
2072
+ let currency = undefined;
2073
+ if (code !== undefined) {
2074
+ currency = this.currency(code);
2075
+ }
2076
+ if (since !== undefined) {
2077
+ request['start_time'] = this.iso8601(since);
2078
+ }
2079
+ if (limit !== undefined) {
2080
+ request['count'] = limit;
2081
+ }
2082
+ const until = this.safeInteger2(params, 'till', 'until');
2083
+ if (until !== undefined) {
2084
+ params = this.omit(params, ['till', 'until']);
2085
+ request['end_time'] = this.iso8601(until);
2086
+ }
2087
+ params = this.omit(params, ['trader_id', 'traderId']);
2088
+ const response = await this.privateGetV1AccountsTraderIdLedger(this.extend(request, params));
2089
+ //
2090
+ // {
2091
+ // "transactions": [
2092
+ // {
2093
+ // "transaction_id": "0288634e-49bd-494d-b04a-18fd1832d394",
2094
+ // "transaction_type": "XFER",
2095
+ // "type": "deposit",
2096
+ // "asset": "ETH",
2097
+ // "symbol": null,
2098
+ // "amount": "0.010000000000000000",
2099
+ // "details": null,
2100
+ // "created_at": "2023-10-20T13:15:39.443Z"
2101
+ // },
2102
+ // {
2103
+ // "transaction_id": "47a45928-abcd-4c12-8bd6-587c3028025f",
2104
+ // "transaction_type": "SWAP",
2105
+ // "type": "atomic token swap",
2106
+ // "asset": "USDT",
2107
+ // "symbol": "ETH-USDT",
2108
+ // "amount": "1.447947",
2109
+ // "details": null,
2110
+ // "created_at": "2023-10-20T13:16:30.373Z"
2111
+ // },
2112
+ // {
2113
+ // "transaction_id": "1ffe3a54-916e-41f0-b957-3a01309eb009",
2114
+ // "transaction_type": "FEE",
2115
+ // "type": "fee",
2116
+ // "asset": "USDT",
2117
+ // "symbol": "ETH-USDT",
2118
+ // "amount": "-0.006516",
2119
+ // "details": {
2120
+ // "fee_details": [
2121
+ // {
2122
+ // "insurance_fee": "0",
2123
+ // "order_id": "39911d5f-c789-4a7d-ad34-820a804d1da6",
2124
+ // "fee_type": "taker",
2125
+ // "fee_currency": "USDT"
2126
+ // }
2127
+ // ]
2128
+ // },
2129
+ // "created_at": "2023-10-20T13:16:30.373Z"
2130
+ // },
2131
+ // {
2132
+ // "transaction_id": "3930e8a3-2218-481f-8c3c-2219287e205e",
2133
+ // "transaction_type": "SWAP",
2134
+ // "type": "atomic token swap",
2135
+ // "asset": "ETH",
2136
+ // "symbol": "ETH-USDT",
2137
+ // "amount": "-0.000900000000000000",
2138
+ // "details": null,
2139
+ // "created_at": "2023-10-20T13:16:30.373Z"
2140
+ // },
2141
+ // {
2142
+ // "transaction_id": "a6c65cb3-95d0-44e2-8202-f70581d6e55c",
2143
+ // "transaction_type": "XFER",
2144
+ // "type": "withdrawal",
2145
+ // "asset": "USD",
2146
+ // "symbol": null,
2147
+ // "amount": "-3.00",
2148
+ // "details": null,
2149
+ // "created_at": "2023-10-26T14:32:24.887Z"
2150
+ // }
2151
+ // ]
2152
+ // }
2153
+ //
2154
+ const ledger = this.safeValue(response, 'transactions', []);
2155
+ return this.parseLedger(ledger, currency, since, limit);
2156
+ }
2157
+ parseLedgerEntry(item, currency = undefined) {
2158
+ //
2159
+ // deposit transaction from wallet (funding) to pro (trading)
2160
+ // {
2161
+ // "transaction_id": "0288634e-49bd-494d-b04a-18fd1832d394",
2162
+ // "transaction_type": "XFER",
2163
+ // "type": "deposit",
2164
+ // "asset": "ETH",
2165
+ // "symbol": null,
2166
+ // "amount": "0.010000000000000000",
2167
+ // "details": null,
2168
+ // "created_at": "2023-10-20T13:15:39.443Z"
2169
+ // }
2170
+ //
2171
+ // withdrawal transaction from pro (trading) to wallet (funding)
2172
+ // {
2173
+ // "transaction_id": "a6c65cb3-95d0-44e2-8202-f70581d6e55c",
2174
+ // "transaction_type": "XFER",
2175
+ // "type": "withdrawal",
2176
+ // "asset": "USD",
2177
+ // "symbol": null,
2178
+ // "amount": "-3.00",
2179
+ // "details": null,
2180
+ // "created_at": "2023-10-26T14:32:24.887Z"
2181
+ // }
2182
+ //
2183
+ // sell trade
2184
+ // {
2185
+ // "transaction_id": "47a45928-abcd-4c12-8bd6-587c3028025f",
2186
+ // "transaction_type": "SWAP",
2187
+ // "type": "atomic token swap",
2188
+ // "asset": "USDT",
2189
+ // "symbol": "ETH-USDT",
2190
+ // "amount": "1.447947",
2191
+ // "details": null,
2192
+ // "created_at": "2023-10-20T13:16:30.373Z"
2193
+ // }
2194
+ //
2195
+ // buy trade
2196
+ // {
2197
+ // "transaction_id": "46d20a93-45c4-4441-a238-f89602eb8c8c",
2198
+ // "transaction_type": "SWAP",
2199
+ // "type": "atomic token swap",
2200
+ // "asset": "ETH",
2201
+ // "symbol": "ETH-USDT",
2202
+ // "amount": "0.000800000000000000",
2203
+ // "details": null,
2204
+ // "created_at": "2023-10-20T13:22:14.256Z"
2205
+ // },
2206
+ //
2207
+ // fee
2208
+ // {
2209
+ // "transaction_id": "57fd526c-36b1-4721-83ce-42aadcb1e953",
2210
+ // "transaction_type": "FEE",
2211
+ // "type": "fee",
2212
+ // "asset": "USDT",
2213
+ // "symbol": "BTC-USDT",
2214
+ // "amount": "-0.047176",
2215
+ // "details": {
2216
+ // "fee_details": [
2217
+ // {
2218
+ // "insurance_fee": "0",
2219
+ // "order_id": "c0bc33cd-eeb9-40a0-ab5f-2d99f323ef58",
2220
+ // "fee_type": "taker",
2221
+ // "fee_currency": "USDT"
2222
+ // }
2223
+ // ]
2224
+ // },
2225
+ // "created_at": "2023-10-25T16:46:24.294Z"
2226
+ // }
2227
+ //
2228
+ const id = this.safeString(item, 'transaction_id');
2229
+ const createdAt = this.safeString(item, 'created_at');
2230
+ const timestamp = this.parse8601(createdAt);
2231
+ let amount = this.safeString(item, 'amount');
2232
+ const amountIsNegative = Precise["default"].stringLt(amount, '0');
2233
+ let direction = undefined;
2234
+ if (amountIsNegative) {
2235
+ direction = 'out';
2236
+ amount = Precise["default"].stringNeg(amount);
2237
+ }
2238
+ else {
2239
+ direction = 'in';
2240
+ }
2241
+ const currencyId = this.safeString(item, 'asset');
2242
+ const code = this.safeCurrencyCode(currencyId, currency);
2243
+ const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
2244
+ return {
2245
+ 'info': item,
2246
+ 'id': id,
2247
+ 'timestamp': timestamp,
2248
+ 'datetime': this.iso8601(timestamp),
2249
+ 'direction': direction,
2250
+ 'account': 'trading',
2251
+ 'referenceId': undefined,
2252
+ 'referenceAccount': undefined,
2253
+ 'type': type,
2254
+ 'currency': code,
2255
+ 'amount': this.parseNumber(amount),
2256
+ 'before': undefined,
2257
+ 'after': undefined,
2258
+ 'status': 'ok',
2259
+ 'fee': undefined,
2260
+ };
2261
+ }
2262
+ parseLedgerEntryType(type) {
2263
+ const types = {
2264
+ 'atomic token swap': 'trade',
2265
+ 'fee': 'fee',
2266
+ 'deposit': 'transfer',
2267
+ 'withdrawal': 'transfer',
2268
+ };
2269
+ return this.safeString(types, type, type);
2270
+ }
2271
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2272
+ const request = this.omit(params, this.extractParams(path));
2273
+ const endpoint = '/' + this.implodeParams(path, params);
2274
+ let url = this.urls['api'][api] + endpoint;
2275
+ const query = this.urlencode(request);
2276
+ if (api === 'private') {
2277
+ this.checkRequiredCredentials();
2278
+ const timestamp = this.seconds().toString();
2279
+ let auth = timestamp + method + endpoint;
2280
+ const isBulk = Array.isArray(params);
2281
+ if ((method === 'POST') || (method === 'PATCH') || isBulk) {
2282
+ body = this.json(request);
2283
+ auth += body;
2284
+ }
2285
+ else if (query.length !== 0) {
2286
+ auth += '?' + query;
2287
+ url += '?' + query;
2288
+ }
2289
+ const signature = this.hmac(this.encode(auth), this.base64ToBinary(this.secret), sha256.sha256, 'base64');
2290
+ headers = {
2291
+ 'CL-ACCESS-KEY': this.apiKey,
2292
+ 'CL-ACCESS-SIG': signature,
2293
+ 'CL-ACCESS-TIMESTAMP': timestamp,
2294
+ 'Content-Type': 'application/json',
2295
+ };
2296
+ }
2297
+ else if (query.length !== 0) {
2298
+ url += '?' + query;
2299
+ }
2300
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2301
+ }
2302
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2303
+ if (response === undefined) {
2304
+ // In some cases the exchange returns 202 Accepted for bad orders.
2305
+ // The body of that response contains order_id of the order.
2306
+ // Some bad orders will get status 'rejected' and could be fetched later (by using fetchOrders() or fetchOrder(order_id)).
2307
+ // While others don't get any status, they simply disappear, but the response is still 202 Accepted and contains their order_id.
2308
+ // When using fechOrder(order_id) for such disappeared orders, the exchange returns an empty response with code 404.
2309
+ if ((code === 404) && (url.indexOf('/orders/') >= 0) && (method === 'GET')) {
2310
+ const parts = url.split('/orders/');
2311
+ const orderId = this.safeString(parts, 1);
2312
+ throw new errors.OrderNotFound(this.id + ' order ' + orderId + ' not found (or rejected on the exchange side)');
2313
+ }
2314
+ return undefined;
2315
+ }
2316
+ const responseCode = this.safeString(response, 'status');
2317
+ const messageCode = this.safeString(response, 'message_code');
2318
+ if ((messageCode !== undefined) || ((responseCode !== undefined) && (code !== 200) && (code !== 202) && (responseCode !== '200') && (responseCode !== '202'))) {
2319
+ const feedback = this.id + ' ' + body;
2320
+ const message = this.safeString(response, 'message');
2321
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
2322
+ this.throwExactlyMatchedException(this.exceptions['exact'], messageCode, feedback);
2323
+ throw new errors.ExchangeError(feedback);
2324
+ }
2325
+ return undefined;
2326
+ }
2327
+ }
2328
+
2329
+ module.exports = coinlist;