ccxt 4.2.18 → 4.2.19

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