ccxt 4.1.41 → 4.1.44

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