ccxt-ir 4.10.0 → 4.11.0

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 (1047) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +4 -1
  4. package/dist/cjs/src/abstract/bidarz.js +11 -0
  5. package/dist/cjs/src/bidarz.js +337 -0
  6. package/dist/cjs/src/bit24.js +4 -3
  7. package/js/ccxt.d.ts +5 -2
  8. package/js/ccxt.js +4 -2
  9. package/js/src/abstract/bidarz.d.ts +9 -0
  10. package/js/src/abstract/bidarz.js +11 -0
  11. package/js/src/bidarz.d.ts +22 -0
  12. package/js/src/bidarz.js +336 -0
  13. package/js/src/bit24.js +4 -3
  14. package/js/src/src/abantether.d.ts +21 -0
  15. package/js/src/src/abantether.js +353 -0
  16. package/js/src/src/abstract/abantether.d.ts +8 -0
  17. package/js/src/src/abstract/abantether.js +11 -0
  18. package/js/src/src/abstract/afratether.d.ts +9 -0
  19. package/js/src/src/abstract/afratether.js +11 -0
  20. package/js/src/src/abstract/alpaca.d.ts +77 -0
  21. package/js/src/src/abstract/alpaca.js +11 -0
  22. package/js/src/src/abstract/apex.d.ts +34 -0
  23. package/js/src/src/abstract/apex.js +11 -0
  24. package/js/src/src/abstract/arzinja.d.ts +8 -0
  25. package/js/src/src/abstract/arzinja.js +11 -0
  26. package/js/src/src/abstract/arzplus.d.ts +11 -0
  27. package/js/src/src/abstract/arzplus.js +11 -0
  28. package/js/src/src/abstract/ascendex.d.ts +80 -0
  29. package/js/src/src/abstract/ascendex.js +11 -0
  30. package/js/src/src/abstract/asretether.d.ts +8 -0
  31. package/js/src/src/abstract/asretether.js +11 -0
  32. package/js/src/src/abstract/bidarz.d.ts +9 -0
  33. package/js/src/src/abstract/bidarz.js +11 -0
  34. package/js/src/src/abstract/bigone.d.ts +48 -0
  35. package/js/src/src/abstract/bigone.js +11 -0
  36. package/js/src/src/abstract/binance.d.ts +773 -0
  37. package/js/src/src/abstract/binance.js +11 -0
  38. package/js/src/src/abstract/bingx.d.ts +165 -0
  39. package/js/src/src/abstract/bingx.js +11 -0
  40. package/js/src/src/abstract/bit24.d.ts +9 -0
  41. package/js/src/src/abstract/bit24.js +11 -0
  42. package/js/src/src/abstract/bit2c.d.ts +30 -0
  43. package/js/src/src/abstract/bit2c.js +11 -0
  44. package/js/src/src/abstract/bitbank.d.ts +35 -0
  45. package/js/src/src/abstract/bitbank.js +11 -0
  46. package/js/src/src/abstract/bitbarg.d.ts +8 -0
  47. package/js/src/src/abstract/bitbarg.js +11 -0
  48. package/js/src/src/abstract/bitbns.d.ts +43 -0
  49. package/js/src/src/abstract/bitbns.js +11 -0
  50. package/js/src/src/abstract/bitfinex.d.ts +143 -0
  51. package/js/src/src/abstract/bitfinex.js +11 -0
  52. package/js/src/src/abstract/bitflyer.d.ts +42 -0
  53. package/js/src/src/abstract/bitflyer.js +11 -0
  54. package/js/src/src/abstract/bitget.d.ts +578 -0
  55. package/js/src/src/abstract/bitget.js +11 -0
  56. package/js/src/src/abstract/bithumb.d.ts +35 -0
  57. package/js/src/src/abstract/bithumb.js +11 -0
  58. package/js/src/src/abstract/bitimen.d.ts +10 -0
  59. package/js/src/src/abstract/bitimen.js +11 -0
  60. package/js/src/src/abstract/bitir.d.ts +10 -0
  61. package/js/src/src/abstract/bitir.js +11 -0
  62. package/js/src/src/abstract/bitmart.d.ts +120 -0
  63. package/js/src/src/abstract/bitmart.js +11 -0
  64. package/js/src/src/abstract/bitmex.d.ts +100 -0
  65. package/js/src/src/abstract/bitmex.js +11 -0
  66. package/js/src/src/abstract/bitopro.d.ts +33 -0
  67. package/js/src/src/abstract/bitopro.js +11 -0
  68. package/js/src/src/abstract/bitpin.d.ts +11 -0
  69. package/js/src/src/abstract/bitpin.js +11 -0
  70. package/js/src/src/abstract/bitrue.d.ts +75 -0
  71. package/js/src/src/abstract/bitrue.js +11 -0
  72. package/js/src/src/abstract/bitso.d.ts +46 -0
  73. package/js/src/src/abstract/bitso.js +11 -0
  74. package/js/src/src/abstract/bitstamp.d.ts +262 -0
  75. package/js/src/src/abstract/bitstamp.js +11 -0
  76. package/js/src/src/abstract/bitteam.d.ts +32 -0
  77. package/js/src/src/abstract/bitteam.js +11 -0
  78. package/js/src/src/abstract/bittrade.d.ts +117 -0
  79. package/js/src/src/abstract/bittrade.js +11 -0
  80. package/js/src/src/abstract/bitunix.d.ts +9 -0
  81. package/js/src/src/abstract/bitunix.js +11 -0
  82. package/js/src/src/abstract/bitvavo.d.ts +30 -0
  83. package/js/src/src/abstract/bitvavo.js +11 -0
  84. package/js/src/src/abstract/blockchaincom.d.ts +31 -0
  85. package/js/src/src/abstract/blockchaincom.js +11 -0
  86. package/js/src/src/abstract/blofin.d.ts +70 -0
  87. package/js/src/src/abstract/blofin.js +11 -0
  88. package/js/src/src/abstract/btcalpha.d.ts +21 -0
  89. package/js/src/src/abstract/btcalpha.js +11 -0
  90. package/js/src/src/abstract/btcbox.d.ts +18 -0
  91. package/js/src/src/abstract/btcbox.js +11 -0
  92. package/js/src/src/abstract/btcmarkets.d.ts +42 -0
  93. package/js/src/src/abstract/btcmarkets.js +11 -0
  94. package/js/src/src/abstract/btcturk.d.ts +23 -0
  95. package/js/src/src/abstract/btcturk.js +11 -0
  96. package/js/src/src/abstract/bybit.d.ts +316 -0
  97. package/js/src/src/abstract/bybit.js +11 -0
  98. package/js/src/src/abstract/bydfi.d.ts +11 -0
  99. package/js/src/src/abstract/bydfi.js +11 -0
  100. package/js/src/src/abstract/cafearz.d.ts +8 -0
  101. package/js/src/src/abstract/cafearz.js +11 -0
  102. package/js/src/src/abstract/cex.d.ts +35 -0
  103. package/js/src/src/abstract/cex.js +11 -0
  104. package/js/src/src/abstract/coinbase.d.ts +97 -0
  105. package/js/src/src/abstract/coinbase.js +11 -0
  106. package/js/src/src/abstract/coinbaseexchange.d.ts +71 -0
  107. package/js/src/src/abstract/coinbaseexchange.js +11 -0
  108. package/js/src/src/abstract/coinbaseinternational.d.ts +42 -0
  109. package/js/src/src/abstract/coinbaseinternational.js +11 -0
  110. package/js/src/src/abstract/coincatch.d.ts +97 -0
  111. package/js/src/src/abstract/coincatch.js +11 -0
  112. package/js/src/src/abstract/coincheck.d.ts +36 -0
  113. package/js/src/src/abstract/coincheck.js +11 -0
  114. package/js/src/src/abstract/coinex.d.ts +240 -0
  115. package/js/src/src/abstract/coinex.js +11 -0
  116. package/js/src/src/abstract/coinmate.d.ts +65 -0
  117. package/js/src/src/abstract/coinmate.js +11 -0
  118. package/js/src/src/abstract/coinmetro.d.ts +37 -0
  119. package/js/src/src/abstract/coinmetro.js +11 -0
  120. package/js/src/src/abstract/coinone.d.ts +70 -0
  121. package/js/src/src/abstract/coinone.js +11 -0
  122. package/js/src/src/abstract/coinsph.d.ts +57 -0
  123. package/js/src/src/abstract/coinsph.js +11 -0
  124. package/js/src/src/abstract/coinspot.d.ts +31 -0
  125. package/js/src/src/abstract/coinspot.js +11 -0
  126. package/js/src/src/abstract/cryptocom.d.ts +126 -0
  127. package/js/src/src/abstract/cryptocom.js +11 -0
  128. package/js/src/src/abstract/cryptomus.d.ts +23 -0
  129. package/js/src/src/abstract/cryptomus.js +11 -0
  130. package/js/src/src/abstract/defx.d.ts +72 -0
  131. package/js/src/src/abstract/defx.js +11 -0
  132. package/js/src/src/abstract/delta.d.ts +53 -0
  133. package/js/src/src/abstract/delta.js +11 -0
  134. package/js/src/src/abstract/deribit.d.ts +129 -0
  135. package/js/src/src/abstract/deribit.js +11 -0
  136. package/js/src/src/abstract/derive.d.ts +120 -0
  137. package/js/src/src/abstract/derive.js +11 -0
  138. package/js/src/src/abstract/digifinex.d.ts +95 -0
  139. package/js/src/src/abstract/digifinex.js +11 -0
  140. package/js/src/src/abstract/ellipx.d.ts +28 -0
  141. package/js/src/src/abstract/ellipx.js +11 -0
  142. package/js/src/src/abstract/eterex.d.ts +8 -0
  143. package/js/src/src/abstract/eterex.js +11 -0
  144. package/js/src/src/abstract/excoino.d.ts +10 -0
  145. package/js/src/src/abstract/excoino.js +11 -0
  146. package/js/src/src/abstract/exir.d.ts +11 -0
  147. package/js/src/src/abstract/exir.js +11 -0
  148. package/js/src/src/abstract/exmo.d.ts +58 -0
  149. package/js/src/src/abstract/exmo.js +11 -0
  150. package/js/src/src/abstract/exnovin.d.ts +9 -0
  151. package/js/src/src/abstract/exnovin.js +11 -0
  152. package/js/src/src/abstract/farhadexchange.d.ts +8 -0
  153. package/js/src/src/abstract/farhadexchange.js +11 -0
  154. package/js/src/src/abstract/foxbit.d.ts +29 -0
  155. package/js/src/src/abstract/foxbit.js +11 -0
  156. package/js/src/src/abstract/gate.d.ts +287 -0
  157. package/js/src/src/abstract/gate.js +11 -0
  158. package/js/src/src/abstract/gemini.d.ts +62 -0
  159. package/js/src/src/abstract/gemini.js +11 -0
  160. package/js/src/src/abstract/hamtapay.d.ts +9 -0
  161. package/js/src/src/abstract/hamtapay.js +11 -0
  162. package/js/src/src/abstract/hashkey.d.ts +70 -0
  163. package/js/src/src/abstract/hashkey.js +11 -0
  164. package/js/src/src/abstract/hibachi.d.ts +29 -0
  165. package/js/src/src/abstract/hibachi.js +11 -0
  166. package/js/src/src/abstract/hitbtc.d.ts +118 -0
  167. package/js/src/src/abstract/hitbtc.js +11 -0
  168. package/js/src/src/abstract/hitobit.d.ts +11 -0
  169. package/js/src/src/abstract/hitobit.js +11 -0
  170. package/js/src/src/abstract/hollaex.d.ts +36 -0
  171. package/js/src/src/abstract/hollaex.js +11 -0
  172. package/js/src/src/abstract/htx.d.ts +551 -0
  173. package/js/src/src/abstract/htx.js +11 -0
  174. package/js/src/src/abstract/hyperliquid.d.ts +9 -0
  175. package/js/src/src/abstract/hyperliquid.js +11 -0
  176. package/js/src/src/abstract/independentreserve.d.ts +46 -0
  177. package/js/src/src/abstract/independentreserve.js +11 -0
  178. package/js/src/src/abstract/indodax.d.ts +29 -0
  179. package/js/src/src/abstract/indodax.js +11 -0
  180. package/js/src/src/abstract/iranexchange.d.ts +9 -0
  181. package/js/src/src/abstract/iranexchange.js +11 -0
  182. package/js/src/src/abstract/jibitex.d.ts +10 -0
  183. package/js/src/src/abstract/jibitex.js +11 -0
  184. package/js/src/src/abstract/kcex.d.ts +10 -0
  185. package/js/src/src/abstract/kcex.js +11 -0
  186. package/js/src/src/abstract/kifpoolme.d.ts +9 -0
  187. package/js/src/src/abstract/kifpoolme.js +11 -0
  188. package/js/src/src/abstract/kraken.d.ts +61 -0
  189. package/js/src/src/abstract/kraken.js +11 -0
  190. package/js/src/src/abstract/krakenfutures.d.ts +45 -0
  191. package/js/src/src/abstract/krakenfutures.js +11 -0
  192. package/js/src/src/abstract/kucoin.d.ts +227 -0
  193. package/js/src/src/abstract/kucoin.js +11 -0
  194. package/js/src/src/abstract/kucoinfutures.d.ts +254 -0
  195. package/js/src/src/abstract/kucoinfutures.js +11 -0
  196. package/js/src/src/abstract/latoken.d.ts +59 -0
  197. package/js/src/src/abstract/latoken.js +11 -0
  198. package/js/src/src/abstract/lbank.d.ts +65 -0
  199. package/js/src/src/abstract/lbank.js +11 -0
  200. package/js/src/src/abstract/luno.d.ts +41 -0
  201. package/js/src/src/abstract/luno.js +11 -0
  202. package/js/src/src/abstract/mazdax.d.ts +11 -0
  203. package/js/src/src/abstract/mazdax.js +11 -0
  204. package/js/src/src/abstract/mercado.d.ts +28 -0
  205. package/js/src/src/abstract/mercado.js +11 -0
  206. package/js/src/src/abstract/mexc.d.ts +183 -0
  207. package/js/src/src/abstract/mexc.js +11 -0
  208. package/js/src/src/abstract/modetrade.d.ts +122 -0
  209. package/js/src/src/abstract/modetrade.js +11 -0
  210. package/js/src/src/abstract/ndax.d.ts +100 -0
  211. package/js/src/src/abstract/ndax.js +11 -0
  212. package/js/src/src/abstract/nobitex.d.ts +10 -0
  213. package/js/src/src/abstract/nobitex.js +11 -0
  214. package/js/src/src/abstract/novadax.d.ts +32 -0
  215. package/js/src/src/abstract/novadax.js +11 -0
  216. package/js/src/src/abstract/oceanex.d.ts +30 -0
  217. package/js/src/src/abstract/oceanex.js +11 -0
  218. package/js/src/src/abstract/okcoin.d.ts +77 -0
  219. package/js/src/src/abstract/okcoin.js +11 -0
  220. package/js/src/src/abstract/okexchange.d.ts +11 -0
  221. package/js/src/src/abstract/okexchange.js +11 -0
  222. package/js/src/src/abstract/okx.d.ts +352 -0
  223. package/js/src/src/abstract/okx.js +11 -0
  224. package/js/src/src/abstract/ompfinex.d.ts +10 -0
  225. package/js/src/src/abstract/ompfinex.js +11 -0
  226. package/js/src/src/abstract/onetrading.d.ts +26 -0
  227. package/js/src/src/abstract/onetrading.js +11 -0
  228. package/js/src/src/abstract/oxfun.d.ts +37 -0
  229. package/js/src/src/abstract/oxfun.js +11 -0
  230. package/js/src/src/abstract/p2b.d.ts +25 -0
  231. package/js/src/src/abstract/p2b.js +11 -0
  232. package/js/src/src/abstract/paradex.d.ts +66 -0
  233. package/js/src/src/abstract/paradex.js +11 -0
  234. package/js/src/src/abstract/paymium.d.ts +31 -0
  235. package/js/src/src/abstract/paymium.js +11 -0
  236. package/js/src/src/abstract/phemex.d.ts +120 -0
  237. package/js/src/src/abstract/phemex.js +11 -0
  238. package/js/src/src/abstract/pingi.d.ts +9 -0
  239. package/js/src/src/abstract/pingi.js +11 -0
  240. package/js/src/src/abstract/poloniex.d.ts +108 -0
  241. package/js/src/src/abstract/poloniex.js +11 -0
  242. package/js/src/src/abstract/pooleno.d.ts +8 -0
  243. package/js/src/src/abstract/pooleno.js +11 -0
  244. package/js/src/src/abstract/probit.d.ts +26 -0
  245. package/js/src/src/abstract/probit.js +11 -0
  246. package/js/src/src/abstract/raastin.d.ts +11 -0
  247. package/js/src/src/abstract/raastin.js +11 -0
  248. package/js/src/src/abstract/ramzinex.d.ts +10 -0
  249. package/js/src/src/abstract/ramzinex.js +11 -0
  250. package/js/src/src/abstract/sarmayex.d.ts +8 -0
  251. package/js/src/src/abstract/sarmayex.js +11 -0
  252. package/js/src/src/abstract/sarrafex.d.ts +10 -0
  253. package/js/src/src/abstract/sarrafex.js +11 -0
  254. package/js/src/src/abstract/tabdeal.d.ts +10 -0
  255. package/js/src/src/abstract/tabdeal.js +11 -0
  256. package/js/src/src/abstract/tehran_exchange.d.ts +9 -0
  257. package/js/src/src/abstract/tehran_exchange.js +11 -0
  258. package/js/src/src/abstract/tetherland.d.ts +8 -0
  259. package/js/src/src/abstract/tetherland.js +11 -0
  260. package/js/src/src/abstract/timex.d.ts +65 -0
  261. package/js/src/src/abstract/timex.js +11 -0
  262. package/js/src/src/abstract/tokocrypto.d.ts +40 -0
  263. package/js/src/src/abstract/tokocrypto.js +11 -0
  264. package/js/src/src/abstract/toobit.d.ts +10 -0
  265. package/js/src/src/abstract/toobit.js +11 -0
  266. package/js/src/src/abstract/tradeogre.d.ts +21 -0
  267. package/js/src/src/abstract/tradeogre.js +11 -0
  268. package/js/src/src/abstract/twox.d.ts +8 -0
  269. package/js/src/src/abstract/twox.js +11 -0
  270. package/js/src/src/abstract/ubitex.d.ts +10 -0
  271. package/js/src/src/abstract/ubitex.js +11 -0
  272. package/js/src/src/abstract/upbit.d.ts +58 -0
  273. package/js/src/src/abstract/upbit.js +11 -0
  274. package/js/src/src/abstract/vertex.d.ts +22 -0
  275. package/js/src/src/abstract/vertex.js +11 -0
  276. package/js/src/src/abstract/wallex.d.ts +11 -0
  277. package/js/src/src/abstract/wallex.js +11 -0
  278. package/js/src/src/abstract/wavesexchange.d.ts +157 -0
  279. package/js/src/src/abstract/wavesexchange.js +11 -0
  280. package/js/src/src/abstract/whitebit.d.ts +117 -0
  281. package/js/src/src/abstract/whitebit.js +11 -0
  282. package/js/src/src/abstract/woo.d.ts +144 -0
  283. package/js/src/src/abstract/woo.js +11 -0
  284. package/js/src/src/abstract/woofipro.d.ts +122 -0
  285. package/js/src/src/abstract/woofipro.js +11 -0
  286. package/js/src/src/abstract/xt.d.ts +160 -0
  287. package/js/src/src/abstract/xt.js +11 -0
  288. package/js/src/src/abstract/yobit.d.ts +19 -0
  289. package/js/src/src/abstract/yobit.js +11 -0
  290. package/js/src/src/abstract/zaif.d.ts +41 -0
  291. package/js/src/src/abstract/zaif.js +11 -0
  292. package/js/src/src/abstract/zonda.d.ts +56 -0
  293. package/js/src/src/abstract/zonda.js +11 -0
  294. package/js/src/src/afratether.d.ts +21 -0
  295. package/js/src/src/afratether.js +356 -0
  296. package/js/src/src/alpaca.d.ts +332 -0
  297. package/js/src/src/alpaca.js +1908 -0
  298. package/js/src/src/apex.d.ts +333 -0
  299. package/js/src/src/apex.js +1942 -0
  300. package/js/src/src/arzinja.d.ts +21 -0
  301. package/js/src/src/arzinja.js +298 -0
  302. package/js/src/src/arzplus.d.ts +26 -0
  303. package/js/src/src/arzplus.js +581 -0
  304. package/js/src/src/ascendex.d.ts +424 -0
  305. package/js/src/src/ascendex.js +3699 -0
  306. package/js/src/src/asretether.d.ts +21 -0
  307. package/js/src/src/asretether.js +324 -0
  308. package/js/src/src/base/Exchange.d.ts +926 -0
  309. package/js/src/src/base/Exchange.js +7399 -0
  310. package/js/src/src/base/Precise.d.ts +42 -0
  311. package/js/src/src/base/Precise.js +275 -0
  312. package/js/src/src/base/errors.d.ts +168 -0
  313. package/js/src/src/base/errors.js +255 -0
  314. package/js/src/src/base/functions/crypto.d.ts +16 -0
  315. package/js/src/src/base/functions/crypto.js +131 -0
  316. package/js/src/src/base/functions/encode.d.ts +4 -0
  317. package/js/src/src/base/functions/encode.js +32 -0
  318. package/js/src/src/base/functions/generic.d.ts +29 -0
  319. package/js/src/src/base/functions/generic.js +203 -0
  320. package/js/src/src/base/functions/misc.d.ts +9 -0
  321. package/js/src/src/base/functions/misc.js +101 -0
  322. package/js/src/src/base/functions/number.d.ts +27 -0
  323. package/js/src/src/base/functions/number.js +313 -0
  324. package/js/src/src/base/functions/platform.d.ts +7 -0
  325. package/js/src/src/base/functions/platform.js +27 -0
  326. package/js/src/src/base/functions/rsa.d.ts +5 -0
  327. package/js/src/src/base/functions/rsa.js +49 -0
  328. package/js/src/src/base/functions/string.d.ts +7 -0
  329. package/js/src/src/base/functions/string.js +44 -0
  330. package/js/src/src/base/functions/throttle.d.ts +6 -0
  331. package/js/src/src/base/functions/throttle.js +67 -0
  332. package/js/src/src/base/functions/time.d.ts +21 -0
  333. package/js/src/src/base/functions/time.js +171 -0
  334. package/js/src/src/base/functions/totp.d.ts +3 -0
  335. package/js/src/src/base/functions/totp.js +25 -0
  336. package/js/src/src/base/functions/type.d.ts +37 -0
  337. package/js/src/src/base/functions/type.js +179 -0
  338. package/js/src/src/base/functions.d.ts +10 -0
  339. package/js/src/src/base/functions.js +18 -0
  340. package/js/src/src/base/types.d.ts +586 -0
  341. package/js/src/src/base/types.js +7 -0
  342. package/js/src/src/base/ws/Cache.d.ts +27 -0
  343. package/js/src/src/base/ws/Cache.js +260 -0
  344. package/js/src/src/base/ws/Client.d.ts +53 -0
  345. package/js/src/src/base/ws/Client.js +307 -0
  346. package/js/src/src/base/ws/Future.d.ts +8 -0
  347. package/js/src/src/base/ws/Future.js +35 -0
  348. package/js/src/src/base/ws/OrderBook.d.ts +25 -0
  349. package/js/src/src/base/ws/OrderBook.js +130 -0
  350. package/js/src/src/base/ws/OrderBookSide.d.ts +40 -0
  351. package/js/src/src/base/ws/OrderBookSide.js +286 -0
  352. package/js/src/src/base/ws/WsClient.d.ts +11 -0
  353. package/js/src/src/base/ws/WsClient.js +69 -0
  354. package/js/src/src/bequant.d.ts +4 -0
  355. package/js/src/src/bequant.js +35 -0
  356. package/js/src/src/bidarz.d.ts +16 -0
  357. package/js/src/src/bidarz.js +327 -0
  358. package/js/src/src/bigone.d.ts +296 -0
  359. package/js/src/src/bigone.js +2340 -0
  360. package/js/src/src/binance.d.ts +1667 -0
  361. package/js/src/src/binance.js +14400 -0
  362. package/js/src/src/binancecoinm.d.ts +6 -0
  363. package/js/src/src/binancecoinm.js +51 -0
  364. package/js/src/src/binanceus.d.ts +4 -0
  365. package/js/src/src/binanceus.js +225 -0
  366. package/js/src/src/binanceusdm.d.ts +6 -0
  367. package/js/src/src/binanceusdm.js +63 -0
  368. package/js/src/src/bingx.d.ts +778 -0
  369. package/js/src/src/bingx.js +6705 -0
  370. package/js/src/src/bit24.d.ts +24 -0
  371. package/js/src/src/bit24.js +520 -0
  372. package/js/src/src/bit2c.d.ts +146 -0
  373. package/js/src/src/bit2c.js +1029 -0
  374. package/js/src/src/bitbank.d.ts +181 -0
  375. package/js/src/src/bitbank.js +1146 -0
  376. package/js/src/src/bitbarg.d.ts +21 -0
  377. package/js/src/src/bitbarg.js +312 -0
  378. package/js/src/src/bitbns.d.ts +184 -0
  379. package/js/src/src/bitbns.js +1288 -0
  380. package/js/src/src/bitfinex.d.ts +516 -0
  381. package/js/src/src/bitfinex.js +3951 -0
  382. package/js/src/src/bitflyer.d.ts +229 -0
  383. package/js/src/src/bitflyer.js +1209 -0
  384. package/js/src/src/bitget.d.ts +1109 -0
  385. package/js/src/src/bitget.js +11033 -0
  386. package/js/src/src/bithumb.d.ts +165 -0
  387. package/js/src/src/bithumb.js +1257 -0
  388. package/js/src/src/bitimen.d.ts +23 -0
  389. package/js/src/src/bitimen.js +424 -0
  390. package/js/src/src/bitir.d.ts +23 -0
  391. package/js/src/src/bitir.js +521 -0
  392. package/js/src/src/bitmart.d.ts +736 -0
  393. package/js/src/src/bitmart.js +5639 -0
  394. package/js/src/src/bitmex.d.ts +395 -0
  395. package/js/src/src/bitmex.js +3088 -0
  396. package/js/src/src/bitopro.d.ts +295 -0
  397. package/js/src/src/bitopro.js +1892 -0
  398. package/js/src/src/bitpin.d.ts +23 -0
  399. package/js/src/src/bitpin.js +487 -0
  400. package/js/src/src/bitrue.d.ts +384 -0
  401. package/js/src/src/bitrue.js +3382 -0
  402. package/js/src/src/bitso.d.ts +270 -0
  403. package/js/src/src/bitso.js +1881 -0
  404. package/js/src/src/bitstamp.d.ts +355 -0
  405. package/js/src/src/bitstamp.js +2445 -0
  406. package/js/src/src/bitteam.d.ts +229 -0
  407. package/js/src/src/bitteam.js +2420 -0
  408. package/js/src/src/bittrade.d.ts +298 -0
  409. package/js/src/src/bittrade.js +2050 -0
  410. package/js/src/src/bitunix.d.ts +21 -0
  411. package/js/src/src/bitunix.js +326 -0
  412. package/js/src/src/bitvavo.d.ts +311 -0
  413. package/js/src/src/bitvavo.js +2204 -0
  414. package/js/src/src/blockchaincom.d.ts +256 -0
  415. package/js/src/src/blockchaincom.js +1259 -0
  416. package/js/src/src/blofin.d.ts +439 -0
  417. package/js/src/src/blofin.js +2576 -0
  418. package/js/src/src/btcalpha.d.ts +209 -0
  419. package/js/src/src/btcalpha.js +1056 -0
  420. package/js/src/src/btcbox.d.ts +144 -0
  421. package/js/src/src/btcbox.js +834 -0
  422. package/js/src/src/btcmarkets.d.ts +253 -0
  423. package/js/src/src/btcmarkets.js +1418 -0
  424. package/js/src/src/btcturk.d.ts +161 -0
  425. package/js/src/src/btcturk.js +1058 -0
  426. package/js/src/src/bybit.d.ts +1097 -0
  427. package/js/src/src/bybit.js +9382 -0
  428. package/js/src/src/bydfi.d.ts +23 -0
  429. package/js/src/src/bydfi.js +434 -0
  430. package/js/src/src/cafearz.d.ts +21 -0
  431. package/js/src/src/cafearz.js +346 -0
  432. package/js/src/src/cex.d.ts +286 -0
  433. package/js/src/src/cex.js +1799 -0
  434. package/js/src/src/coinbase.d.ts +623 -0
  435. package/js/src/src/coinbase.js +5220 -0
  436. package/js/src/src/coinbaseadvanced.d.ts +4 -0
  437. package/js/src/src/coinbaseadvanced.js +18 -0
  438. package/js/src/src/coinbaseexchange.d.ts +334 -0
  439. package/js/src/src/coinbaseexchange.js +2127 -0
  440. package/js/src/src/coinbaseinternational.d.ts +443 -0
  441. package/js/src/src/coinbaseinternational.js +2336 -0
  442. package/js/src/src/coincatch.d.ts +786 -0
  443. package/js/src/src/coincatch.js +5492 -0
  444. package/js/src/src/coincheck.d.ts +147 -0
  445. package/js/src/src/coincheck.js +962 -0
  446. package/js/src/src/coinex.d.ts +719 -0
  447. package/js/src/src/coinex.js +6166 -0
  448. package/js/src/src/coinmate.d.ts +202 -0
  449. package/js/src/src/coinmate.js +1215 -0
  450. package/js/src/src/coinmetro.d.ts +244 -0
  451. package/js/src/src/coinmetro.js +2024 -0
  452. package/js/src/src/coinone.d.ts +158 -0
  453. package/js/src/src/coinone.js +1278 -0
  454. package/js/src/src/coinsph.d.ts +310 -0
  455. package/js/src/src/coinsph.js +2203 -0
  456. package/js/src/src/coinspot.d.ts +108 -0
  457. package/js/src/src/coinspot.js +653 -0
  458. package/js/src/src/cryptocom.d.ts +463 -0
  459. package/js/src/src/cryptocom.js +3549 -0
  460. package/js/src/src/cryptomus.d.ts +158 -0
  461. package/js/src/src/cryptomus.js +1169 -0
  462. package/js/src/src/defx.d.ts +348 -0
  463. package/js/src/src/defx.js +2139 -0
  464. package/js/src/src/delta.d.ts +407 -0
  465. package/js/src/src/delta.js +3654 -0
  466. package/js/src/src/deribit.d.ts +516 -0
  467. package/js/src/src/deribit.js +3790 -0
  468. package/js/src/src/derive.d.ts +324 -0
  469. package/js/src/src/derive.js +2655 -0
  470. package/js/src/src/digifinex.d.ts +544 -0
  471. package/js/src/src/digifinex.js +4453 -0
  472. package/js/src/src/ellipx.d.ts +237 -0
  473. package/js/src/src/ellipx.js +2071 -0
  474. package/js/src/src/eterex.d.ts +21 -0
  475. package/js/src/src/eterex.js +299 -0
  476. package/js/src/src/excoino.d.ts +23 -0
  477. package/js/src/src/excoino.js +426 -0
  478. package/js/src/src/exir.d.ts +23 -0
  479. package/js/src/src/exir.js +403 -0
  480. package/js/src/src/exmo.d.ts +426 -0
  481. package/js/src/src/exmo.js +2825 -0
  482. package/js/src/src/exnovin.d.ts +22 -0
  483. package/js/src/src/exnovin.js +378 -0
  484. package/js/src/src/farhadexchange.d.ts +21 -0
  485. package/js/src/src/farhadexchange.js +280 -0
  486. package/js/src/src/fmfwio.d.ts +4 -0
  487. package/js/src/src/fmfwio.js +35 -0
  488. package/js/src/src/foxbit.d.ts +352 -0
  489. package/js/src/src/foxbit.js +2016 -0
  490. package/js/src/src/gate.d.ts +1071 -0
  491. package/js/src/src/gate.js +8282 -0
  492. package/js/src/src/gateio.d.ts +4 -0
  493. package/js/src/src/gateio.js +17 -0
  494. package/js/src/src/gemini.d.ts +257 -0
  495. package/js/src/src/gemini.js +2006 -0
  496. package/js/src/src/hamtapay.d.ts +21 -0
  497. package/js/src/src/hamtapay.js +303 -0
  498. package/js/src/src/hashkey.d.ts +628 -0
  499. package/js/src/src/hashkey.js +4363 -0
  500. package/js/src/src/hibachi.d.ts +346 -0
  501. package/js/src/src/hibachi.js +2137 -0
  502. package/js/src/src/hitbtc.d.ts +558 -0
  503. package/js/src/src/hitbtc.js +3847 -0
  504. package/js/src/src/hitobit.d.ts +23 -0
  505. package/js/src/src/hitobit.js +412 -0
  506. package/js/src/src/hollaex.d.ts +305 -0
  507. package/js/src/src/hollaex.js +2046 -0
  508. package/js/src/src/htx.d.ts +961 -0
  509. package/js/src/src/htx.js +9668 -0
  510. package/js/src/src/huobi.d.ts +4 -0
  511. package/js/src/src/huobi.js +17 -0
  512. package/js/src/src/hyperliquid.d.ts +651 -0
  513. package/js/src/src/hyperliquid.js +3937 -0
  514. package/js/src/src/independentreserve.d.ts +169 -0
  515. package/js/src/src/independentreserve.js +1115 -0
  516. package/js/src/src/indodax.d.ts +217 -0
  517. package/js/src/src/indodax.js +1454 -0
  518. package/js/src/src/iranexchange.d.ts +21 -0
  519. package/js/src/src/iranexchange.js +399 -0
  520. package/js/src/src/jibitex.d.ts +23 -0
  521. package/js/src/src/jibitex.js +416 -0
  522. package/js/src/src/kcex.d.ts +21 -0
  523. package/js/src/src/kcex.js +335 -0
  524. package/js/src/src/kifpoolme.d.ts +23 -0
  525. package/js/src/src/kifpoolme.js +410 -0
  526. package/js/src/src/kraken.d.ts +484 -0
  527. package/js/src/src/kraken.js +3518 -0
  528. package/js/src/src/krakenfutures.d.ts +362 -0
  529. package/js/src/src/krakenfutures.js +2885 -0
  530. package/js/src/src/kucoin.d.ts +759 -0
  531. package/js/src/src/kucoin.js +5153 -0
  532. package/js/src/src/kucoinfutures.d.ts +521 -0
  533. package/js/src/src/kucoinfutures.js +3381 -0
  534. package/js/src/src/latoken.d.ts +274 -0
  535. package/js/src/src/latoken.js +1824 -0
  536. package/js/src/src/lbank.d.ts +350 -0
  537. package/js/src/src/lbank.js +3146 -0
  538. package/js/src/src/luno.d.ts +252 -0
  539. package/js/src/src/luno.js +1479 -0
  540. package/js/src/src/mazdax.d.ts +23 -0
  541. package/js/src/src/mazdax.js +534 -0
  542. package/js/src/src/mercado.d.ts +160 -0
  543. package/js/src/src/mercado.js +1011 -0
  544. package/js/src/src/mexc.d.ts +768 -0
  545. package/js/src/src/mexc.js +6102 -0
  546. package/js/src/src/modetrade.d.ts +496 -0
  547. package/js/src/src/modetrade.js +2936 -0
  548. package/js/src/src/myokx.d.ts +4 -0
  549. package/js/src/src/myokx.js +54 -0
  550. package/js/src/src/ndax.d.ts +285 -0
  551. package/js/src/src/ndax.js +2598 -0
  552. package/js/src/src/nobitex.d.ts +23 -0
  553. package/js/src/src/nobitex.js +454 -0
  554. package/js/src/src/novadax.d.ts +279 -0
  555. package/js/src/src/novadax.js +1676 -0
  556. package/js/src/src/oceanex.d.ts +231 -0
  557. package/js/src/src/oceanex.js +1123 -0
  558. package/js/src/src/okcoin.d.ts +346 -0
  559. package/js/src/src/okcoin.js +3211 -0
  560. package/js/src/src/okexchange.d.ts +23 -0
  561. package/js/src/src/okexchange.js +373 -0
  562. package/js/src/src/okx.d.ts +1125 -0
  563. package/js/src/src/okx.js +9009 -0
  564. package/js/src/src/okxus.d.ts +4 -0
  565. package/js/src/src/okxus.js +54 -0
  566. package/js/src/src/ompfinex.d.ts +23 -0
  567. package/js/src/src/ompfinex.js +510 -0
  568. package/js/src/src/onetrading.d.ts +228 -0
  569. package/js/src/src/onetrading.js +1769 -0
  570. package/js/src/src/oxfun.d.ts +442 -0
  571. package/js/src/src/oxfun.js +2920 -0
  572. package/js/src/src/p2b.d.ts +189 -0
  573. package/js/src/src/p2b.js +1344 -0
  574. package/js/src/src/paradex.d.ts +389 -0
  575. package/js/src/src/paradex.js +2607 -0
  576. package/js/src/src/paymium.d.ts +133 -0
  577. package/js/src/src/paymium.js +644 -0
  578. package/js/src/src/phemex.d.ts +497 -0
  579. package/js/src/src/phemex.js +5333 -0
  580. package/js/src/src/pingi.d.ts +22 -0
  581. package/js/src/src/pingi.js +446 -0
  582. package/js/src/src/poloniex.d.ts +441 -0
  583. package/js/src/src/poloniex.js +3681 -0
  584. package/js/src/src/pooleno.d.ts +21 -0
  585. package/js/src/src/pooleno.js +347 -0
  586. package/js/src/src/pro/alpaca.d.ts +95 -0
  587. package/js/src/src/pro/alpaca.js +724 -0
  588. package/js/src/src/pro/apex.d.ts +160 -0
  589. package/js/src/src/pro/apex.js +1044 -0
  590. package/js/src/src/pro/ascendex.d.ts +99 -0
  591. package/js/src/src/pro/ascendex.js +1012 -0
  592. package/js/src/src/pro/bequant.d.ts +4 -0
  593. package/js/src/src/pro/bequant.js +42 -0
  594. package/js/src/src/pro/binance.d.ts +796 -0
  595. package/js/src/src/pro/binance.js +4373 -0
  596. package/js/src/src/pro/binancecoinm.d.ts +4 -0
  597. package/js/src/src/pro/binancecoinm.js +32 -0
  598. package/js/src/src/pro/binanceus.d.ts +4 -0
  599. package/js/src/src/pro/binanceus.js +52 -0
  600. package/js/src/src/pro/binanceusdm.d.ts +4 -0
  601. package/js/src/src/pro/binanceusdm.js +37 -0
  602. package/js/src/src/pro/bingx.d.ts +151 -0
  603. package/js/src/src/pro/bingx.js +1568 -0
  604. package/js/src/src/pro/bitfinex.d.ts +99 -0
  605. package/js/src/src/pro/bitfinex.js +1165 -0
  606. package/js/src/src/pro/bitget.d.ts +257 -0
  607. package/js/src/src/pro/bitget.js +2327 -0
  608. package/js/src/src/pro/bithumb.d.ts +59 -0
  609. package/js/src/src/pro/bithumb.js +395 -0
  610. package/js/src/src/pro/bitmart.d.ts +168 -0
  611. package/js/src/src/pro/bitmart.js +1686 -0
  612. package/js/src/src/pro/bitmex.d.ts +170 -0
  613. package/js/src/src/pro/bitmex.js +1760 -0
  614. package/js/src/src/pro/bitopro.d.ts +69 -0
  615. package/js/src/src/pro/bitopro.js +477 -0
  616. package/js/src/src/pro/bitrue.d.ts +40 -0
  617. package/js/src/src/pro/bitrue.js +461 -0
  618. package/js/src/src/pro/bitstamp.d.ts +53 -0
  619. package/js/src/src/pro/bitstamp.js +587 -0
  620. package/js/src/src/pro/bittrade.d.ts +66 -0
  621. package/js/src/src/pro/bittrade.js +606 -0
  622. package/js/src/src/pro/bitvavo.d.ts +321 -0
  623. package/js/src/src/pro/bitvavo.js +1451 -0
  624. package/js/src/src/pro/blockchaincom.d.ts +89 -0
  625. package/js/src/src/pro/blockchaincom.js +777 -0
  626. package/js/src/src/pro/blofin.d.ts +174 -0
  627. package/js/src/src/pro/blofin.js +743 -0
  628. package/js/src/src/pro/bybit.d.ts +397 -0
  629. package/js/src/src/pro/bybit.js +2519 -0
  630. package/js/src/src/pro/cex.d.ts +220 -0
  631. package/js/src/src/pro/cex.js +1535 -0
  632. package/js/src/src/pro/coinbase.d.ts +119 -0
  633. package/js/src/src/pro/coinbase.js +736 -0
  634. package/js/src/src/pro/coinbaseadvanced.d.ts +4 -0
  635. package/js/src/src/pro/coinbaseadvanced.js +18 -0
  636. package/js/src/src/pro/coinbaseexchange.d.ts +133 -0
  637. package/js/src/src/pro/coinbaseexchange.js +969 -0
  638. package/js/src/src/pro/coinbaseinternational.d.ts +143 -0
  639. package/js/src/src/pro/coinbaseinternational.js +804 -0
  640. package/js/src/src/pro/coincatch.d.ts +207 -0
  641. package/js/src/src/pro/coincatch.js +1562 -0
  642. package/js/src/src/pro/coincheck.d.ts +33 -0
  643. package/js/src/src/pro/coincheck.js +210 -0
  644. package/js/src/src/pro/coinex.d.ts +147 -0
  645. package/js/src/src/pro/coinex.js +1426 -0
  646. package/js/src/src/pro/coinone.d.ts +51 -0
  647. package/js/src/src/pro/coinone.js +413 -0
  648. package/js/src/src/pro/cryptocom.d.ts +300 -0
  649. package/js/src/src/pro/cryptocom.js +1414 -0
  650. package/js/src/src/pro/defx.d.ts +236 -0
  651. package/js/src/src/pro/defx.js +865 -0
  652. package/js/src/src/pro/deribit.d.ts +163 -0
  653. package/js/src/src/pro/deribit.js +1066 -0
  654. package/js/src/src/pro/derive.d.ts +100 -0
  655. package/js/src/src/pro/derive.js +753 -0
  656. package/js/src/src/pro/exmo.d.ts +97 -0
  657. package/js/src/src/pro/exmo.js +903 -0
  658. package/js/src/src/pro/gate.d.ts +360 -0
  659. package/js/src/src/pro/gate.js +2119 -0
  660. package/js/src/src/pro/gateio.d.ts +4 -0
  661. package/js/src/src/pro/gateio.js +17 -0
  662. package/js/src/src/pro/gemini.d.ts +106 -0
  663. package/js/src/src/pro/gemini.js +932 -0
  664. package/js/src/src/pro/hashkey.d.ts +121 -0
  665. package/js/src/src/pro/hashkey.js +843 -0
  666. package/js/src/src/pro/hitbtc.d.ts +235 -0
  667. package/js/src/src/pro/hitbtc.js +1400 -0
  668. package/js/src/src/pro/hollaex.d.ts +77 -0
  669. package/js/src/src/pro/hollaex.js +604 -0
  670. package/js/src/src/pro/htx.d.ts +141 -0
  671. package/js/src/src/pro/htx.js +2415 -0
  672. package/js/src/src/pro/huobi.d.ts +4 -0
  673. package/js/src/src/pro/huobi.js +17 -0
  674. package/js/src/src/pro/hyperliquid.d.ts +218 -0
  675. package/js/src/src/pro/hyperliquid.js +1126 -0
  676. package/js/src/src/pro/independentreserve.d.ts +36 -0
  677. package/js/src/src/pro/independentreserve.js +287 -0
  678. package/js/src/src/pro/kraken.d.ts +233 -0
  679. package/js/src/src/pro/kraken.js +1785 -0
  680. package/js/src/src/pro/krakenfutures.d.ts +178 -0
  681. package/js/src/src/pro/krakenfutures.js +1592 -0
  682. package/js/src/src/pro/kucoin.d.ts +221 -0
  683. package/js/src/src/pro/kucoin.js +1430 -0
  684. package/js/src/src/pro/kucoinfutures.d.ts +205 -0
  685. package/js/src/src/pro/kucoinfutures.js +1295 -0
  686. package/js/src/src/pro/lbank.d.ts +134 -0
  687. package/js/src/src/pro/lbank.js +950 -0
  688. package/js/src/src/pro/luno.d.ts +44 -0
  689. package/js/src/src/pro/luno.js +322 -0
  690. package/js/src/src/pro/mexc.d.ts +210 -0
  691. package/js/src/src/pro/mexc.js +2009 -0
  692. package/js/src/src/pro/modetrade.d.ts +155 -0
  693. package/js/src/src/pro/modetrade.js +1335 -0
  694. package/js/src/src/pro/myokx.d.ts +4 -0
  695. package/js/src/src/pro/myokx.js +39 -0
  696. package/js/src/src/pro/ndax.d.ts +60 -0
  697. package/js/src/src/pro/ndax.js +545 -0
  698. package/js/src/src/pro/okcoin.d.ts +91 -0
  699. package/js/src/src/pro/okcoin.js +763 -0
  700. package/js/src/src/pro/okx.d.ts +408 -0
  701. package/js/src/src/pro/okx.js +2479 -0
  702. package/js/src/src/pro/okxus.d.ts +4 -0
  703. package/js/src/src/pro/okxus.js +39 -0
  704. package/js/src/src/pro/onetrading.d.ts +107 -0
  705. package/js/src/src/pro/onetrading.js +1343 -0
  706. package/js/src/src/pro/oxfun.d.ts +234 -0
  707. package/js/src/src/pro/oxfun.js +1112 -0
  708. package/js/src/src/pro/p2b.d.ts +104 -0
  709. package/js/src/src/pro/p2b.js +506 -0
  710. package/js/src/src/pro/paradex.d.ts +54 -0
  711. package/js/src/src/pro/paradex.js +370 -0
  712. package/js/src/src/pro/phemex.d.ts +129 -0
  713. package/js/src/src/pro/phemex.js +1569 -0
  714. package/js/src/src/pro/poloniex.d.ts +214 -0
  715. package/js/src/src/pro/poloniex.js +1318 -0
  716. package/js/src/src/pro/probit.d.ts +91 -0
  717. package/js/src/src/pro/probit.js +593 -0
  718. package/js/src/src/pro/tradeogre.d.ts +49 -0
  719. package/js/src/src/pro/tradeogre.js +284 -0
  720. package/js/src/src/pro/upbit.d.ts +124 -0
  721. package/js/src/src/pro/upbit.js +689 -0
  722. package/js/src/src/pro/vertex.d.ts +104 -0
  723. package/js/src/src/pro/vertex.js +999 -0
  724. package/js/src/src/pro/whitebit.d.ts +123 -0
  725. package/js/src/src/pro/whitebit.js +971 -0
  726. package/js/src/src/pro/woo.d.ts +161 -0
  727. package/js/src/src/pro/woo.js +1351 -0
  728. package/js/src/src/pro/woofipro.d.ts +155 -0
  729. package/js/src/src/pro/woofipro.js +1335 -0
  730. package/js/src/src/pro/xt.d.ts +165 -0
  731. package/js/src/src/pro/xt.js +1230 -0
  732. package/js/src/src/probit.d.ts +283 -0
  733. package/js/src/src/probit.js +1935 -0
  734. package/js/src/src/protobuf/mexc/compiled.cjs +7186 -0
  735. package/js/src/src/protobuf/mexc/compiled.d.cts +8 -0
  736. package/js/src/src/raastin.d.ts +24 -0
  737. package/js/src/src/raastin.js +494 -0
  738. package/js/src/src/ramzinex.d.ts +23 -0
  739. package/js/src/src/ramzinex.js +510 -0
  740. package/js/src/src/sarmayex.d.ts +21 -0
  741. package/js/src/src/sarmayex.js +376 -0
  742. package/js/src/src/sarrafex.d.ts +23 -0
  743. package/js/src/src/sarrafex.js +501 -0
  744. package/js/src/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
  745. package/js/src/src/static_dependencies/ethers/abi-coder.js +148 -0
  746. package/js/src/src/static_dependencies/ethers/address/address.d.ts +55 -0
  747. package/js/src/src/static_dependencies/ethers/address/address.js +162 -0
  748. package/js/src/src/static_dependencies/ethers/address/checks.d.ts +80 -0
  749. package/js/src/src/static_dependencies/ethers/address/checks.js +119 -0
  750. package/js/src/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
  751. package/js/src/src/static_dependencies/ethers/address/contract-address.js +73 -0
  752. package/js/src/src/static_dependencies/ethers/address/index.d.ts +48 -0
  753. package/js/src/src/static_dependencies/ethers/address/index.js +24 -0
  754. package/js/src/src/static_dependencies/ethers/bytes32.d.ts +14 -0
  755. package/js/src/src/static_dependencies/ethers/bytes32.js +45 -0
  756. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
  757. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
  758. package/js/src/src/static_dependencies/ethers/coders/address.d.ts +12 -0
  759. package/js/src/src/static_dependencies/ethers/coders/address.js +34 -0
  760. package/js/src/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
  761. package/js/src/src/static_dependencies/ethers/coders/anonymous.js +27 -0
  762. package/js/src/src/static_dependencies/ethers/coders/array.d.ts +24 -0
  763. package/js/src/src/static_dependencies/ethers/coders/array.js +162 -0
  764. package/js/src/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
  765. package/js/src/src/static_dependencies/ethers/coders/boolean.js +26 -0
  766. package/js/src/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
  767. package/js/src/src/static_dependencies/ethers/coders/bytes.js +39 -0
  768. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
  769. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
  770. package/js/src/src/static_dependencies/ethers/coders/null.d.ts +11 -0
  771. package/js/src/src/static_dependencies/ethers/coders/null.js +29 -0
  772. package/js/src/src/static_dependencies/ethers/coders/number.d.ts +15 -0
  773. package/js/src/src/static_dependencies/ethers/coders/number.js +48 -0
  774. package/js/src/src/static_dependencies/ethers/coders/string.d.ts +12 -0
  775. package/js/src/src/static_dependencies/ethers/coders/string.js +26 -0
  776. package/js/src/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
  777. package/js/src/src/static_dependencies/ethers/coders/tuple.js +67 -0
  778. package/js/src/src/static_dependencies/ethers/fragments.d.ts +458 -0
  779. package/js/src/src/static_dependencies/ethers/fragments.js +1252 -0
  780. package/js/src/src/static_dependencies/ethers/hash/index.d.ts +10 -0
  781. package/js/src/src/static_dependencies/ethers/hash/index.js +15 -0
  782. package/js/src/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
  783. package/js/src/src/static_dependencies/ethers/hash/solidity.js +107 -0
  784. package/js/src/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
  785. package/js/src/src/static_dependencies/ethers/hash/typed-data.js +490 -0
  786. package/js/src/src/static_dependencies/ethers/index.d.ts +19 -0
  787. package/js/src/src/static_dependencies/ethers/index.js +22 -0
  788. package/js/src/src/static_dependencies/ethers/interface.d.ts +380 -0
  789. package/js/src/src/static_dependencies/ethers/interface.js +990 -0
  790. package/js/src/src/static_dependencies/ethers/typed.d.ts +569 -0
  791. package/js/src/src/static_dependencies/ethers/typed.js +608 -0
  792. package/js/src/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
  793. package/js/src/src/static_dependencies/ethers/utils/base58.js +68 -0
  794. package/js/src/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
  795. package/js/src/src/static_dependencies/ethers/utils/base64.js +58 -0
  796. package/js/src/src/static_dependencies/ethers/utils/data.d.ts +92 -0
  797. package/js/src/src/static_dependencies/ethers/utils/data.js +175 -0
  798. package/js/src/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
  799. package/js/src/src/static_dependencies/ethers/utils/errors.js +227 -0
  800. package/js/src/src/static_dependencies/ethers/utils/events.d.ts +76 -0
  801. package/js/src/src/static_dependencies/ethers/utils/events.js +52 -0
  802. package/js/src/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
  803. package/js/src/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
  804. package/js/src/src/static_dependencies/ethers/utils/index.d.ts +30 -0
  805. package/js/src/src/static_dependencies/ethers/utils/index.js +38 -0
  806. package/js/src/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
  807. package/js/src/src/static_dependencies/ethers/utils/maths.js +220 -0
  808. package/js/src/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
  809. package/js/src/src/static_dependencies/ethers/utils/properties.js +59 -0
  810. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
  811. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
  812. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
  813. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
  814. package/js/src/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
  815. package/js/src/src/static_dependencies/ethers/utils/rlp.js +14 -0
  816. package/js/src/src/static_dependencies/ethers/utils/units.d.ts +23 -0
  817. package/js/src/src/static_dependencies/ethers/utils/units.js +88 -0
  818. package/js/src/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
  819. package/js/src/src/static_dependencies/ethers/utils/utf8.js +225 -0
  820. package/js/src/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
  821. package/js/src/src/static_dependencies/ethers/utils/uuid.js +35 -0
  822. package/js/src/src/static_dependencies/fflake/browser.d.ts +222 -0
  823. package/js/src/src/static_dependencies/fflake/browser.js +2578 -0
  824. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.d.ts +116 -0
  825. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.js +194 -0
  826. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +142 -0
  827. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +307 -0
  828. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -0
  829. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +565 -0
  830. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.d.ts +5 -0
  831. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  832. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.d.ts +3 -0
  833. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  834. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.d.ts +9 -0
  835. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  836. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.d.ts +3 -0
  837. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +25 -0
  838. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -0
  839. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1757 -0
  840. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.d.ts +10 -0
  841. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +50 -0
  842. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.d.ts +3 -0
  843. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +80 -0
  844. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.d.ts +23 -0
  845. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +377 -0
  846. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.d.ts +7 -0
  847. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.js +64 -0
  848. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -0
  849. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1627 -0
  850. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.d.ts +60 -0
  851. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.js +22 -0
  852. package/js/src/src/static_dependencies/noble-curves/abstract/curve.d.ts +67 -0
  853. package/js/src/src/static_dependencies/noble-curves/abstract/curve.js +157 -0
  854. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.d.ts +79 -0
  855. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.js +432 -0
  856. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.d.ts +56 -0
  857. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +171 -0
  858. package/js/src/src/static_dependencies/noble-curves/abstract/modular.d.ts +68 -0
  859. package/js/src/src/static_dependencies/noble-curves/abstract/modular.js +351 -0
  860. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.d.ts +25 -0
  861. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.js +162 -0
  862. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.d.ts +29 -0
  863. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.js +115 -0
  864. package/js/src/src/static_dependencies/noble-curves/abstract/utils.d.ts +53 -0
  865. package/js/src/src/static_dependencies/noble-curves/abstract/utils.js +227 -0
  866. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -0
  867. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.js +1016 -0
  868. package/js/src/src/static_dependencies/noble-curves/ed25519.d.ts +53 -0
  869. package/js/src/src/static_dependencies/noble-curves/ed25519.js +402 -0
  870. package/js/src/src/static_dependencies/noble-curves/p256.d.ts +103 -0
  871. package/js/src/src/static_dependencies/noble-curves/p256.js +47 -0
  872. package/js/src/src/static_dependencies/noble-curves/secp256k1.d.ts +91 -0
  873. package/js/src/src/static_dependencies/noble-curves/secp256k1.js +257 -0
  874. package/js/src/src/static_dependencies/noble-hashes/_assert.d.ts +21 -0
  875. package/js/src/src/static_dependencies/noble-hashes/_assert.js +48 -0
  876. package/js/src/src/static_dependencies/noble-hashes/_sha2.d.ts +23 -0
  877. package/js/src/src/static_dependencies/noble-hashes/_sha2.js +119 -0
  878. package/js/src/src/static_dependencies/noble-hashes/_u64.d.ts +35 -0
  879. package/js/src/src/static_dependencies/noble-hashes/_u64.js +66 -0
  880. package/js/src/src/static_dependencies/noble-hashes/crypto.d.ts +1 -0
  881. package/js/src/src/static_dependencies/noble-hashes/crypto.js +7 -0
  882. package/js/src/src/static_dependencies/noble-hashes/hmac.d.ts +26 -0
  883. package/js/src/src/static_dependencies/noble-hashes/hmac.js +82 -0
  884. package/js/src/src/static_dependencies/noble-hashes/md5.d.ts +18 -0
  885. package/js/src/src/static_dependencies/noble-hashes/md5.js +242 -0
  886. package/js/src/src/static_dependencies/noble-hashes/sha1.d.ts +21 -0
  887. package/js/src/src/static_dependencies/noble-hashes/sha1.js +90 -0
  888. package/js/src/src/static_dependencies/noble-hashes/sha256.d.ts +34 -0
  889. package/js/src/src/static_dependencies/noble-hashes/sha256.js +129 -0
  890. package/js/src/src/static_dependencies/noble-hashes/sha3.d.ts +97 -0
  891. package/js/src/src/static_dependencies/noble-hashes/sha3.js +211 -0
  892. package/js/src/src/static_dependencies/noble-hashes/sha512.d.ts +66 -0
  893. package/js/src/src/static_dependencies/noble-hashes/sha512.js +236 -0
  894. package/js/src/src/static_dependencies/noble-hashes/utils.d.ts +77 -0
  895. package/js/src/src/static_dependencies/noble-hashes/utils.js +147 -0
  896. package/js/src/src/static_dependencies/proxies/agent-base/helpers.d.ts +14 -0
  897. package/js/src/src/static_dependencies/proxies/agent-base/helpers.js +42 -0
  898. package/js/src/src/static_dependencies/proxies/agent-base/index.d.ts +33 -0
  899. package/js/src/src/static_dependencies/proxies/agent-base/index.js +82 -0
  900. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.d.ts +40 -0
  901. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.js +119 -0
  902. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.d.ts +45 -0
  903. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.js +150 -0
  904. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.d.ts +15 -0
  905. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  906. package/js/src/src/static_dependencies/qs/formats.cjs +22 -0
  907. package/js/src/src/static_dependencies/qs/formats.d.cts +14 -0
  908. package/js/src/src/static_dependencies/qs/index.cjs +15 -0
  909. package/js/src/src/static_dependencies/qs/index.d.cts +10 -0
  910. package/js/src/src/static_dependencies/qs/parse.cjs +208 -0
  911. package/js/src/src/static_dependencies/qs/parse.d.cts +8 -0
  912. package/js/src/src/static_dependencies/qs/stringify.cjs +192 -0
  913. package/js/src/src/static_dependencies/qs/stringify.d.cts +8 -0
  914. package/js/src/src/static_dependencies/qs/utils.cjs +202 -0
  915. package/js/src/src/static_dependencies/qs/utils.d.cts +15 -0
  916. package/js/src/src/static_dependencies/scure-base/index.d.ts +92 -0
  917. package/js/src/src/static_dependencies/scure-base/index.js +420 -0
  918. package/js/src/src/static_dependencies/scure-starknet/index.d.ts +79 -0
  919. package/js/src/src/static_dependencies/scure-starknet/index.js +323 -0
  920. package/js/src/src/static_dependencies/starknet/constants.d.ts +61 -0
  921. package/js/src/src/static_dependencies/starknet/constants.js +67 -0
  922. package/js/src/src/static_dependencies/starknet/index.d.ts +3 -0
  923. package/js/src/src/static_dependencies/starknet/index.js +9 -0
  924. package/js/src/src/static_dependencies/starknet/types/cairoEnum.d.ts +2 -0
  925. package/js/src/src/static_dependencies/starknet/types/cairoEnum.js +7 -0
  926. package/js/src/src/static_dependencies/starknet/types/calldata.d.ts +19 -0
  927. package/js/src/src/static_dependencies/starknet/types/calldata.js +28 -0
  928. package/js/src/src/static_dependencies/starknet/types/index.d.ts +13 -0
  929. package/js/src/src/static_dependencies/starknet/types/index.js +16 -0
  930. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.d.ts +71 -0
  931. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.js +13 -0
  932. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.d.ts +24 -0
  933. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.js +16 -0
  934. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.d.ts +33 -0
  935. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.js +7 -0
  936. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.d.ts +52 -0
  937. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.js +7 -0
  938. package/js/src/src/static_dependencies/starknet/types/lib/index.d.ts +248 -0
  939. package/js/src/src/static_dependencies/starknet/types/lib/index.js +52 -0
  940. package/js/src/src/static_dependencies/starknet/types/typedData.d.ts +44 -0
  941. package/js/src/src/static_dependencies/starknet/types/typedData.js +19 -0
  942. package/js/src/src/static_dependencies/starknet/utils/assert.d.ts +7 -0
  943. package/js/src/src/static_dependencies/starknet/utils/assert.js +17 -0
  944. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.d.ts +6 -0
  945. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +43 -0
  946. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.d.ts +72 -0
  947. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +117 -0
  948. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.d.ts +76 -0
  949. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +136 -0
  950. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.d.ts +32 -0
  951. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.js +59 -0
  952. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.d.ts +183 -0
  953. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.js +229 -0
  954. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
  955. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
  956. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.d.ts +35 -0
  957. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
  958. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.d.ts +34 -0
  959. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
  960. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.d.ts +3 -0
  961. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.js +9 -0
  962. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.d.ts +9 -0
  963. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.js +67 -0
  964. package/js/src/src/static_dependencies/starknet/utils/calldata/index.d.ts +89 -0
  965. package/js/src/src/static_dependencies/starknet/utils/calldata/index.js +280 -0
  966. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -0
  967. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.js +30 -0
  968. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.d.ts +20 -0
  969. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.js +8 -0
  970. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
  971. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +36 -0
  972. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
  973. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
  974. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.d.ts +2 -0
  975. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +155 -0
  976. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.d.ts +11 -0
  977. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.js +248 -0
  978. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.d.ts +11 -0
  979. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.js +214 -0
  980. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.d.ts +6 -0
  981. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.js +113 -0
  982. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.d.ts +6 -0
  983. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.js +208 -0
  984. package/js/src/src/static_dependencies/starknet/utils/encode.d.ts +207 -0
  985. package/js/src/src/static_dependencies/starknet/utils/encode.js +282 -0
  986. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.d.ts +57 -0
  987. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.js +223 -0
  988. package/js/src/src/static_dependencies/starknet/utils/hash/index.d.ts +6 -0
  989. package/js/src/src/static_dependencies/starknet/utils/hash/index.js +13 -0
  990. package/js/src/src/static_dependencies/starknet/utils/merkle.d.ts +35 -0
  991. package/js/src/src/static_dependencies/starknet/utils/merkle.js +84 -0
  992. package/js/src/src/static_dependencies/starknet/utils/num.d.ts +182 -0
  993. package/js/src/src/static_dependencies/starknet/utils/num.js +244 -0
  994. package/js/src/src/static_dependencies/starknet/utils/selector.d.ts +48 -0
  995. package/js/src/src/static_dependencies/starknet/utils/selector.js +85 -0
  996. package/js/src/src/static_dependencies/starknet/utils/shortString.d.ts +57 -0
  997. package/js/src/src/static_dependencies/starknet/utils/shortString.js +96 -0
  998. package/js/src/src/static_dependencies/starknet/utils/typedData.d.ts +54 -0
  999. package/js/src/src/static_dependencies/starknet/utils/typedData.js +321 -0
  1000. package/js/src/src/static_dependencies/watchable/src/types.d.ts +28 -0
  1001. package/js/src/src/static_dependencies/watchable/src/types.js +8 -0
  1002. package/js/src/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
  1003. package/js/src/src/static_dependencies/watchable/src/unpromise.js +297 -0
  1004. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  1005. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  1006. package/js/src/src/tabdeal.d.ts +23 -0
  1007. package/js/src/src/tabdeal.js +387 -0
  1008. package/js/src/src/tehran_exchange.d.ts +21 -0
  1009. package/js/src/src/tehran_exchange.js +333 -0
  1010. package/js/src/src/tetherland.d.ts +21 -0
  1011. package/js/src/src/tetherland.js +367 -0
  1012. package/js/src/src/timex.d.ts +247 -0
  1013. package/js/src/src/timex.js +1792 -0
  1014. package/js/src/src/tokocrypto.d.ts +261 -0
  1015. package/js/src/src/tokocrypto.js +2641 -0
  1016. package/js/src/src/toobit.d.ts +22 -0
  1017. package/js/src/src/toobit.js +445 -0
  1018. package/js/src/src/tradeogre.d.ts +149 -0
  1019. package/js/src/src/tradeogre.js +878 -0
  1020. package/js/src/src/twox.d.ts +21 -0
  1021. package/js/src/src/twox.js +371 -0
  1022. package/js/src/src/ubitex.d.ts +23 -0
  1023. package/js/src/src/ubitex.js +433 -0
  1024. package/js/src/src/upbit.d.ts +377 -0
  1025. package/js/src/src/upbit.js +2340 -0
  1026. package/js/src/src/vertex.d.ts +346 -0
  1027. package/js/src/src/vertex.js +3146 -0
  1028. package/js/src/src/wallex.d.ts +23 -0
  1029. package/js/src/src/wallex.js +467 -0
  1030. package/js/src/src/wavesexchange.d.ts +244 -0
  1031. package/js/src/src/wavesexchange.js +2747 -0
  1032. package/js/src/src/whitebit.d.ts +571 -0
  1033. package/js/src/src/whitebit.js +3437 -0
  1034. package/js/src/src/woo.d.ts +727 -0
  1035. package/js/src/src/woo.js +4183 -0
  1036. package/js/src/src/woofipro.d.ts +497 -0
  1037. package/js/src/src/woofipro.js +2941 -0
  1038. package/js/src/src/xt.d.ts +568 -0
  1039. package/js/src/src/xt.js +5184 -0
  1040. package/js/src/src/yobit.d.ts +197 -0
  1041. package/js/src/src/yobit.js +1453 -0
  1042. package/js/src/src/zaif.d.ts +136 -0
  1043. package/js/src/src/zaif.js +821 -0
  1044. package/js/src/src/zonda.d.ts +214 -0
  1045. package/js/src/src/zonda.js +1984 -0
  1046. package/js/test.js +3 -3
  1047. package/package.json +1 -1
@@ -0,0 +1,3790 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/deribit.js';
9
+ import { TICK_SIZE } from './base/functions/number.js';
10
+ import { AuthenticationError, ExchangeError, ArgumentsRequired, PermissionDenied, InvalidOrder, OrderNotFound, DDoSProtection, NotSupported, ExchangeNotAvailable, InsufficientFunds, BadRequest, InvalidAddress, OnMaintenance } from './base/errors.js';
11
+ import { Precise } from './base/Precise.js';
12
+ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
+ import { totp } from './base/functions/totp.js';
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * @class deribit
17
+ * @augments Exchange
18
+ */
19
+ export default class deribit extends Exchange {
20
+ describe() {
21
+ return this.deepExtend(super.describe(), {
22
+ 'id': 'deribit',
23
+ 'name': 'Deribit',
24
+ 'countries': ['NL'],
25
+ 'version': 'v2',
26
+ 'userAgent': undefined,
27
+ // 20 requests per second for non-matching-engine endpoints, 1000ms / 20 = 50ms between requests
28
+ // 5 requests per second for matching-engine endpoints, cost = (1000ms / rateLimit) / 5 = 4
29
+ 'rateLimit': 50,
30
+ 'pro': true,
31
+ 'has': {
32
+ 'CORS': true,
33
+ 'spot': false,
34
+ 'margin': false,
35
+ 'swap': true,
36
+ 'future': true,
37
+ 'option': true,
38
+ 'cancelAllOrders': true,
39
+ 'cancelOrder': true,
40
+ 'cancelOrders': false,
41
+ 'createDepositAddress': true,
42
+ 'createOrder': true,
43
+ 'createReduceOnlyOrder': true,
44
+ 'createStopLimitOrder': true,
45
+ 'createStopMarketOrder': true,
46
+ 'createStopOrder': true,
47
+ 'createTrailingAmountOrder': true,
48
+ 'editOrder': true,
49
+ 'fetchAccounts': true,
50
+ 'fetchBalance': true,
51
+ 'fetchBorrowRateHistories': false,
52
+ 'fetchBorrowRateHistory': false,
53
+ 'fetchClosedOrders': true,
54
+ 'fetchCrossBorrowRate': false,
55
+ 'fetchCrossBorrowRates': false,
56
+ 'fetchCurrencies': true,
57
+ 'fetchDeposit': false,
58
+ 'fetchDepositAddress': true,
59
+ 'fetchDepositAddresses': false,
60
+ 'fetchDepositAddressesByNetwork': false,
61
+ 'fetchDeposits': true,
62
+ 'fetchDepositWithdrawFees': true,
63
+ 'fetchFundingRate': true,
64
+ 'fetchFundingRateHistory': true,
65
+ 'fetchGreeks': true,
66
+ 'fetchIndexOHLCV': false,
67
+ 'fetchIsolatedBorrowRate': false,
68
+ 'fetchIsolatedBorrowRates': false,
69
+ 'fetchLeverageTiers': false,
70
+ 'fetchLiquidations': true,
71
+ 'fetchMarginMode': false,
72
+ 'fetchMarkets': true,
73
+ 'fetchMarkOHLCV': false,
74
+ 'fetchMyLiquidations': true,
75
+ 'fetchMySettlementHistory': false,
76
+ 'fetchMyTrades': true,
77
+ 'fetchOHLCV': true,
78
+ 'fetchOpenOrders': true,
79
+ 'fetchOption': true,
80
+ 'fetchOptionChain': true,
81
+ 'fetchOrder': true,
82
+ 'fetchOrderBook': true,
83
+ 'fetchOrders': false,
84
+ 'fetchOrderTrades': true,
85
+ 'fetchPosition': true,
86
+ 'fetchPositionMode': false,
87
+ 'fetchPositions': true,
88
+ 'fetchPremiumIndexOHLCV': false,
89
+ 'fetchStatus': true,
90
+ 'fetchTicker': true,
91
+ 'fetchTickers': true,
92
+ 'fetchTime': true,
93
+ 'fetchTrades': true,
94
+ 'fetchTradingFee': false,
95
+ 'fetchTradingFees': true,
96
+ 'fetchTransactions': false,
97
+ 'fetchTransfer': false,
98
+ 'fetchTransfers': true,
99
+ 'fetchUnderlyingAssets': false,
100
+ 'fetchVolatilityHistory': true,
101
+ 'fetchWithdrawal': false,
102
+ 'fetchWithdrawals': true,
103
+ 'sandbox': true,
104
+ 'transfer': true,
105
+ 'withdraw': true,
106
+ },
107
+ 'timeframes': {
108
+ '1m': '1',
109
+ '3m': '3',
110
+ '5m': '5',
111
+ '10m': '10',
112
+ '15m': '15',
113
+ '30m': '30',
114
+ '1h': '60',
115
+ '2h': '120',
116
+ '3h': '180',
117
+ '6h': '360',
118
+ '12h': '720',
119
+ '1d': '1D',
120
+ },
121
+ 'urls': {
122
+ 'test': {
123
+ 'rest': 'https://test.deribit.com',
124
+ },
125
+ 'logo': 'https://user-images.githubusercontent.com/1294454/41933112-9e2dd65a-798b-11e8-8440-5bab2959fcb8.jpg',
126
+ 'api': {
127
+ 'rest': 'https://www.deribit.com',
128
+ },
129
+ 'www': 'https://www.deribit.com',
130
+ 'doc': [
131
+ 'https://docs.deribit.com/v2',
132
+ 'https://github.com/deribit',
133
+ ],
134
+ 'fees': 'https://www.deribit.com/pages/information/fees',
135
+ 'referral': {
136
+ 'url': 'https://www.deribit.com/reg-1189.4038',
137
+ 'discount': 0.1,
138
+ },
139
+ },
140
+ 'api': {
141
+ 'public': {
142
+ 'get': {
143
+ // Authentication
144
+ 'auth': 1,
145
+ 'exchange_token': 1,
146
+ 'fork_token': 1,
147
+ // Session management
148
+ 'set_heartbeat': 1,
149
+ 'disable_heartbeat': 1,
150
+ // Supporting
151
+ 'get_time': 1,
152
+ 'hello': 1,
153
+ 'status': 1,
154
+ 'test': 1,
155
+ // Subscription management
156
+ 'subscribe': 1,
157
+ 'unsubscribe': 1,
158
+ 'unsubscribe_all': 1,
159
+ // Account management
160
+ 'get_announcements': 1,
161
+ // Market data
162
+ 'get_book_summary_by_currency': 1,
163
+ 'get_book_summary_by_instrument': 1,
164
+ 'get_contract_size': 1,
165
+ 'get_currencies': 1,
166
+ 'get_delivery_prices': 1,
167
+ 'get_funding_chart_data': 1,
168
+ 'get_funding_rate_history': 1,
169
+ 'get_funding_rate_value': 1,
170
+ 'get_historical_volatility': 1,
171
+ 'get_index': 1,
172
+ 'get_index_price': 1,
173
+ 'get_index_price_names': 1,
174
+ 'get_instrument': 1,
175
+ 'get_instruments': 1,
176
+ 'get_last_settlements_by_currency': 1,
177
+ 'get_last_settlements_by_instrument': 1,
178
+ 'get_last_trades_by_currency': 1,
179
+ 'get_last_trades_by_currency_and_time': 1,
180
+ 'get_last_trades_by_instrument': 1,
181
+ 'get_last_trades_by_instrument_and_time': 1,
182
+ 'get_mark_price_history': 1,
183
+ 'get_order_book': 1,
184
+ 'get_trade_volumes': 1,
185
+ 'get_tradingview_chart_data': 1,
186
+ 'get_volatility_index_data': 1,
187
+ 'ticker': 1,
188
+ },
189
+ },
190
+ 'private': {
191
+ 'get': {
192
+ // Authentication
193
+ 'logout': 1,
194
+ // Session management
195
+ 'enable_cancel_on_disconnect': 1,
196
+ 'disable_cancel_on_disconnect': 1,
197
+ 'get_cancel_on_disconnect': 1,
198
+ // Subscription management
199
+ 'subscribe': 1,
200
+ 'unsubscribe': 1,
201
+ 'unsubscribe_all': 1,
202
+ // Account management
203
+ 'change_api_key_name': 1,
204
+ 'change_scope_in_api_key': 1,
205
+ 'change_subaccount_name': 1,
206
+ 'create_api_key': 1,
207
+ 'create_subaccount': 1,
208
+ 'disable_api_key': 1,
209
+ 'disable_tfa_for_subaccount': 1,
210
+ 'enable_affiliate_program': 1,
211
+ 'enable_api_key': 1,
212
+ 'get_access_log': 1,
213
+ 'get_account_summary': 1,
214
+ 'get_account_summaries': 1,
215
+ 'get_affiliate_program_info': 1,
216
+ 'get_email_language': 1,
217
+ 'get_new_announcements': 1,
218
+ 'get_portfolio_margins': 1,
219
+ 'get_position': 1,
220
+ 'get_positions': 1,
221
+ 'get_subaccounts': 1,
222
+ 'get_subaccounts_details': 1,
223
+ 'get_transaction_log': 1,
224
+ 'list_api_keys': 1,
225
+ 'remove_api_key': 1,
226
+ 'remove_subaccount': 1,
227
+ 'reset_api_key': 1,
228
+ 'set_announcement_as_read': 1,
229
+ 'set_api_key_as_default': 1,
230
+ 'set_email_for_subaccount': 1,
231
+ 'set_email_language': 1,
232
+ 'set_password_for_subaccount': 1,
233
+ 'toggle_notifications_from_subaccount': 1,
234
+ 'toggle_subaccount_login': 1,
235
+ // Block Trade
236
+ 'execute_block_trade': 4,
237
+ 'get_block_trade': 1,
238
+ 'get_last_block_trades_by_currency': 1,
239
+ 'invalidate_block_trade_signature': 1,
240
+ 'verify_block_trade': 4,
241
+ // Trading
242
+ 'buy': 4,
243
+ 'sell': 4,
244
+ 'edit': 4,
245
+ 'edit_by_label': 4,
246
+ 'cancel': 4,
247
+ 'cancel_all': 4,
248
+ 'cancel_all_by_currency': 4,
249
+ 'cancel_all_by_instrument': 4,
250
+ 'cancel_by_label': 4,
251
+ 'close_position': 4,
252
+ 'get_margins': 1,
253
+ 'get_mmp_config': 1,
254
+ 'get_open_orders_by_currency': 1,
255
+ 'get_open_orders_by_instrument': 1,
256
+ 'get_order_history_by_currency': 1,
257
+ 'get_order_history_by_instrument': 1,
258
+ 'get_order_margin_by_ids': 1,
259
+ 'get_order_state': 1,
260
+ 'get_stop_order_history': 1,
261
+ 'get_trigger_order_history': 1,
262
+ 'get_user_trades_by_currency': 1,
263
+ 'get_user_trades_by_currency_and_time': 1,
264
+ 'get_user_trades_by_instrument': 1,
265
+ 'get_user_trades_by_instrument_and_time': 1,
266
+ 'get_user_trades_by_order': 1,
267
+ 'reset_mmp': 1,
268
+ 'set_mmp_config': 1,
269
+ 'get_settlement_history_by_instrument': 1,
270
+ 'get_settlement_history_by_currency': 1,
271
+ // Wallet
272
+ 'cancel_transfer_by_id': 1,
273
+ 'cancel_withdrawal': 1,
274
+ 'create_deposit_address': 1,
275
+ 'get_current_deposit_address': 1,
276
+ 'get_deposits': 1,
277
+ 'get_transfers': 1,
278
+ 'get_withdrawals': 1,
279
+ 'submit_transfer_to_subaccount': 1,
280
+ 'submit_transfer_to_user': 1,
281
+ 'withdraw': 1,
282
+ },
283
+ },
284
+ },
285
+ 'features': {
286
+ 'default': {
287
+ 'sandbox': true,
288
+ 'createOrder': {
289
+ 'marginMode': false,
290
+ 'triggerPrice': true,
291
+ // todo implement
292
+ 'triggerPriceType': {
293
+ 'last': true,
294
+ 'mark': true,
295
+ 'index': true,
296
+ },
297
+ 'triggerDirection': false,
298
+ 'stopLossPrice': false,
299
+ 'takeProfitPrice': false,
300
+ 'attachedStopLossTakeProfit': undefined,
301
+ 'timeInForce': {
302
+ 'IOC': true,
303
+ 'FOK': true,
304
+ 'PO': true,
305
+ 'GTD': true,
306
+ },
307
+ 'hedged': false,
308
+ 'selfTradePrevention': false,
309
+ 'trailing': true,
310
+ 'leverage': false,
311
+ 'marketBuyByCost': true,
312
+ 'marketBuyRequiresPrice': false,
313
+ 'iceberg': true, // todo
314
+ },
315
+ 'createOrders': undefined,
316
+ 'fetchMyTrades': {
317
+ 'marginMode': false,
318
+ 'limit': 100,
319
+ 'daysBack': 100000,
320
+ 'untilDays': 100000,
321
+ 'symbolRequired': true, // todo
322
+ },
323
+ 'fetchOrder': {
324
+ 'marginMode': false,
325
+ 'trigger': false,
326
+ 'trailing': false,
327
+ 'symbolRequired': true, // todo
328
+ },
329
+ 'fetchOpenOrders': {
330
+ 'marginMode': false,
331
+ 'limit': undefined,
332
+ 'trigger': false,
333
+ 'trailing': false,
334
+ 'symbolRequired': true, // todo
335
+ },
336
+ 'fetchOrders': undefined,
337
+ 'fetchClosedOrders': {
338
+ 'marginMode': false,
339
+ 'limit': 100,
340
+ 'daysBack': 100000,
341
+ 'daysBackCanceled': 1,
342
+ 'untilDays': 100000,
343
+ 'trigger': false,
344
+ 'trailing': false,
345
+ 'symbolRequired': true, // todo
346
+ },
347
+ 'fetchOHLCV': {
348
+ 'limit': 1000, // todo: recheck
349
+ },
350
+ },
351
+ 'spot': {
352
+ 'extends': 'default',
353
+ },
354
+ 'swap': {
355
+ 'linear': {
356
+ 'extends': 'default',
357
+ },
358
+ 'inverse': {
359
+ 'extends': 'default',
360
+ },
361
+ },
362
+ 'future': {
363
+ 'linear': {
364
+ 'extends': 'default',
365
+ },
366
+ 'inverse': {
367
+ 'extends': 'default',
368
+ },
369
+ },
370
+ },
371
+ 'exceptions': {
372
+ // 0 or absent Success, No error.
373
+ '9999': PermissionDenied,
374
+ '10000': AuthenticationError,
375
+ '10001': ExchangeError,
376
+ '10002': InvalidOrder,
377
+ '10003': InvalidOrder,
378
+ '10004': OrderNotFound,
379
+ '10005': InvalidOrder,
380
+ '10006': InvalidOrder,
381
+ '10007': InvalidOrder,
382
+ '10008': InvalidOrder,
383
+ '10009': InsufficientFunds,
384
+ '10010': OrderNotFound,
385
+ '10011': InvalidOrder,
386
+ '10012': InvalidOrder,
387
+ '10013': PermissionDenied,
388
+ '10014': PermissionDenied,
389
+ '10015': PermissionDenied,
390
+ '10016': PermissionDenied,
391
+ '10017': PermissionDenied,
392
+ '10018': PermissionDenied,
393
+ '10019': PermissionDenied,
394
+ '10020': ExchangeError,
395
+ '10021': InvalidOrder,
396
+ '10022': InvalidOrder,
397
+ '10023': InvalidOrder,
398
+ '10024': InvalidOrder,
399
+ '10025': InvalidOrder,
400
+ '10026': InvalidOrder,
401
+ '10027': InvalidOrder,
402
+ '10028': DDoSProtection,
403
+ '10029': OrderNotFound,
404
+ '10030': ExchangeError,
405
+ '10031': ExchangeError,
406
+ '10032': InvalidOrder,
407
+ '10033': NotSupported,
408
+ '10034': InvalidOrder,
409
+ '10035': InvalidOrder,
410
+ '10036': InvalidOrder,
411
+ '10040': ExchangeNotAvailable,
412
+ '10041': OnMaintenance,
413
+ '10043': InvalidOrder,
414
+ '10044': InvalidOrder,
415
+ '10045': InvalidOrder,
416
+ '10046': InvalidOrder,
417
+ '10047': DDoSProtection,
418
+ '10048': ExchangeError,
419
+ '11008': InvalidOrder,
420
+ '11029': BadRequest,
421
+ '11030': ExchangeError,
422
+ '11031': ExchangeError,
423
+ '11035': DDoSProtection,
424
+ '11036': InvalidOrder,
425
+ '11037': BadRequest,
426
+ '11038': InvalidOrder,
427
+ '11039': InvalidOrder,
428
+ '11041': InvalidOrder,
429
+ '11042': PermissionDenied,
430
+ '11043': BadRequest,
431
+ '11044': InvalidOrder,
432
+ '11045': BadRequest,
433
+ '11046': BadRequest,
434
+ '11047': BadRequest,
435
+ '11048': ExchangeError,
436
+ '11049': BadRequest,
437
+ '11050': BadRequest,
438
+ '11051': OnMaintenance,
439
+ '11052': ExchangeError,
440
+ '11053': ExchangeError,
441
+ '11090': InvalidAddress,
442
+ '11091': InvalidAddress,
443
+ '11092': InvalidAddress,
444
+ '11093': DDoSProtection,
445
+ '11094': ExchangeError,
446
+ '11095': ExchangeError,
447
+ '11096': ExchangeError,
448
+ '12000': AuthenticationError,
449
+ '12001': DDoSProtection,
450
+ '12002': ExchangeError,
451
+ '12998': AuthenticationError,
452
+ '12003': AuthenticationError,
453
+ '12004': AuthenticationError,
454
+ '12005': AuthenticationError,
455
+ '12100': ExchangeError,
456
+ '12999': AuthenticationError,
457
+ '13000': AuthenticationError,
458
+ '13001': AuthenticationError,
459
+ '13002': PermissionDenied,
460
+ '13003': AuthenticationError,
461
+ '13004': AuthenticationError,
462
+ '13005': AuthenticationError,
463
+ '13006': AuthenticationError,
464
+ '13007': AuthenticationError,
465
+ '13008': ExchangeError,
466
+ '13009': AuthenticationError,
467
+ '13010': BadRequest,
468
+ '13011': BadRequest,
469
+ '13012': PermissionDenied,
470
+ '13013': BadRequest,
471
+ '13014': BadRequest,
472
+ '13015': BadRequest,
473
+ '13016': BadRequest,
474
+ '13017': ExchangeError,
475
+ '13018': ExchangeError,
476
+ '13019': ExchangeError,
477
+ '13020': ExchangeError,
478
+ '13021': PermissionDenied,
479
+ '13025': ExchangeError,
480
+ '-32602': BadRequest,
481
+ '-32601': BadRequest,
482
+ '-32700': BadRequest,
483
+ '-32000': BadRequest,
484
+ '11054': InvalidOrder, // 'post_only_reject' post order would be filled immediately
485
+ },
486
+ 'precisionMode': TICK_SIZE,
487
+ 'options': {
488
+ 'code': 'BTC',
489
+ 'fetchBalance': {
490
+ 'code': 'BTC',
491
+ },
492
+ 'transfer': {
493
+ 'method': 'privateGetSubmitTransferToSubaccount', // or 'privateGetSubmitTransferToUser'
494
+ },
495
+ },
496
+ });
497
+ }
498
+ createExpiredOptionMarket(symbol) {
499
+ // support expired option contracts
500
+ let quote = 'USD';
501
+ let settle = undefined;
502
+ const optionParts = symbol.split('-');
503
+ const symbolBase = symbol.split('/');
504
+ let base = undefined;
505
+ let expiry = undefined;
506
+ if (symbol.indexOf('/') > -1) {
507
+ base = this.safeString(symbolBase, 0);
508
+ expiry = this.safeString(optionParts, 1);
509
+ if (symbol.indexOf('USDC') > -1) {
510
+ base = base + '_USDC';
511
+ }
512
+ }
513
+ else {
514
+ base = this.safeString(optionParts, 0);
515
+ expiry = this.convertMarketIdExpireDate(this.safeString(optionParts, 1));
516
+ }
517
+ if (symbol.indexOf('USDC') > -1) {
518
+ quote = 'USDC';
519
+ settle = 'USDC';
520
+ }
521
+ else {
522
+ settle = base;
523
+ }
524
+ let splitBase = base;
525
+ if (base.indexOf('_') > -1) {
526
+ const splitSymbol = base.split('_');
527
+ splitBase = this.safeString(splitSymbol, 0);
528
+ }
529
+ const strike = this.safeString(optionParts, 2);
530
+ const optionType = this.safeString(optionParts, 3);
531
+ const datetime = this.convertExpireDate(expiry);
532
+ const timestamp = this.parse8601(datetime);
533
+ return {
534
+ 'id': base + '-' + this.convertExpireDateToMarketIdDate(expiry) + '-' + strike + '-' + optionType,
535
+ 'symbol': splitBase + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
536
+ 'base': base,
537
+ 'quote': quote,
538
+ 'settle': settle,
539
+ 'baseId': base,
540
+ 'quoteId': quote,
541
+ 'settleId': settle,
542
+ 'active': false,
543
+ 'type': 'option',
544
+ 'linear': undefined,
545
+ 'inverse': undefined,
546
+ 'spot': false,
547
+ 'swap': false,
548
+ 'future': false,
549
+ 'option': true,
550
+ 'margin': false,
551
+ 'contract': true,
552
+ 'contractSize': undefined,
553
+ 'expiry': timestamp,
554
+ 'expiryDatetime': datetime,
555
+ 'optionType': (optionType === 'C') ? 'call' : 'put',
556
+ 'strike': this.parseNumber(strike),
557
+ 'precision': {
558
+ 'amount': undefined,
559
+ 'price': undefined,
560
+ },
561
+ 'limits': {
562
+ 'amount': {
563
+ 'min': undefined,
564
+ 'max': undefined,
565
+ },
566
+ 'price': {
567
+ 'min': undefined,
568
+ 'max': undefined,
569
+ },
570
+ 'cost': {
571
+ 'min': undefined,
572
+ 'max': undefined,
573
+ },
574
+ },
575
+ 'info': undefined,
576
+ };
577
+ }
578
+ safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
579
+ const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')));
580
+ if (isOption && !(marketId in this.markets_by_id)) {
581
+ // handle expired option contracts
582
+ return this.createExpiredOptionMarket(marketId);
583
+ }
584
+ return super.safeMarket(marketId, market, delimiter, marketType);
585
+ }
586
+ /**
587
+ * @method
588
+ * @name deribit#fetchTime
589
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
590
+ * @see https://docs.deribit.com/#public-get_time
591
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
592
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
593
+ */
594
+ async fetchTime(params = {}) {
595
+ const response = await this.publicGetGetTime(params);
596
+ //
597
+ // {
598
+ // "jsonrpc": "2.0",
599
+ // "result": 1583922446019,
600
+ // "usIn": 1583922446019955,
601
+ // "usOut": 1583922446019956,
602
+ // "usDiff": 1,
603
+ // "testnet": false
604
+ // }
605
+ //
606
+ return this.safeInteger(response, 'result');
607
+ }
608
+ /**
609
+ * @method
610
+ * @name deribit#fetchCurrencies
611
+ * @description fetches all available currencies on an exchange
612
+ * @see https://docs.deribit.com/#public-get_currencies
613
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
614
+ * @returns {object} an associative dictionary of currencies
615
+ */
616
+ async fetchCurrencies(params = {}) {
617
+ const response = await this.publicGetGetCurrencies(params);
618
+ //
619
+ // {
620
+ // "jsonrpc": "2.0",
621
+ // "result": [
622
+ // {
623
+ // "withdrawal_priorities": [],
624
+ // "withdrawal_fee": 0.01457324,
625
+ // "min_withdrawal_fee": 0.000001,
626
+ // "min_confirmations": 1,
627
+ // "fee_precision": 8,
628
+ // "currency_long": "Solana",
629
+ // "currency": "SOL",
630
+ // "coin_type": "SOL"
631
+ // },
632
+ // ...
633
+ // ],
634
+ // "usIn": 1688652701456124,
635
+ // "usOut": 1688652701456390,
636
+ // "usDiff": 266,
637
+ // "testnet": true
638
+ // }
639
+ //
640
+ const data = this.safeList(response, 'result', []);
641
+ const result = {};
642
+ for (let i = 0; i < data.length; i++) {
643
+ const currency = data[i];
644
+ const currencyId = this.safeString(currency, 'currency');
645
+ const code = this.safeCurrencyCode(currencyId);
646
+ result[code] = this.safeCurrencyStructure({
647
+ 'info': currency,
648
+ 'code': code,
649
+ 'id': currencyId,
650
+ 'name': this.safeString(currency, 'currency_long'),
651
+ 'active': undefined,
652
+ 'deposit': undefined,
653
+ 'withdraw': undefined,
654
+ 'type': 'crypto',
655
+ 'fee': this.safeNumber(currency, 'withdrawal_fee'),
656
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'fee_precision'))),
657
+ 'limits': {
658
+ 'amount': {
659
+ 'min': undefined,
660
+ 'max': undefined,
661
+ },
662
+ 'withdraw': {
663
+ 'min': undefined,
664
+ 'max': undefined,
665
+ },
666
+ 'deposit': {
667
+ 'min': undefined,
668
+ 'max': undefined,
669
+ },
670
+ },
671
+ 'networks': undefined,
672
+ });
673
+ }
674
+ return result;
675
+ }
676
+ codeFromOptions(methodName, params = {}) {
677
+ const defaultCode = this.safeValue(this.options, 'code', 'BTC');
678
+ const options = this.safeValue(this.options, methodName, {});
679
+ const code = this.safeValue(options, 'code', defaultCode);
680
+ return this.safeValue(params, 'code', code);
681
+ }
682
+ /**
683
+ * @method
684
+ * @name deribit#fetchStatus
685
+ * @description the latest known information on the availability of the exchange API
686
+ * @see https://docs.deribit.com/#public-status
687
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
688
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
689
+ */
690
+ async fetchStatus(params = {}) {
691
+ const response = await this.publicGetStatus(params);
692
+ //
693
+ // {
694
+ // "jsonrpc": "2.0",
695
+ // "result": {
696
+ // "locked": "false" // true, partial, false
697
+ // },
698
+ // "usIn": 1650641690226788,
699
+ // "usOut": 1650641690226836,
700
+ // "usDiff": 48,
701
+ // "testnet": false
702
+ // }
703
+ //
704
+ const result = this.safeValue(response, 'result');
705
+ const locked = this.safeString(result, 'locked');
706
+ const updateTime = this.safeIntegerProduct(response, 'usIn', 0.001, this.milliseconds());
707
+ return {
708
+ 'status': (locked === 'false') ? 'ok' : 'maintenance',
709
+ 'updated': updateTime,
710
+ 'eta': undefined,
711
+ 'url': undefined,
712
+ 'info': response,
713
+ };
714
+ }
715
+ /**
716
+ * @method
717
+ * @name deribit#fetchAccounts
718
+ * @description fetch all the accounts associated with a profile
719
+ * @see https://docs.deribit.com/#private-get_subaccounts
720
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
721
+ * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
722
+ */
723
+ async fetchAccounts(params = {}) {
724
+ await this.loadMarkets();
725
+ const response = await this.privateGetGetSubaccounts(params);
726
+ //
727
+ // {
728
+ // "jsonrpc": "2.0",
729
+ // "result": [{
730
+ // "username": "someusername",
731
+ // "type": "main",
732
+ // "system_name": "someusername",
733
+ // "security_keys_enabled": false,
734
+ // "security_keys_assignments": [],
735
+ // "receive_notifications": false,
736
+ // "login_enabled": true,
737
+ // "is_password": true,
738
+ // "id": "238216",
739
+ // "email": "pablo@abcdef.com"
740
+ // },
741
+ // {
742
+ // "username": "someusername_1",
743
+ // "type": "subaccount",
744
+ // "system_name": "someusername_1",
745
+ // "security_keys_enabled": false,
746
+ // "security_keys_assignments": [],
747
+ // "receive_notifications": false,
748
+ // "login_enabled": false,
749
+ // "is_password": false,
750
+ // "id": "245499",
751
+ // "email": "pablo@abcdef.com"
752
+ // }
753
+ // ],
754
+ // "usIn": "1652736468292006",
755
+ // "usOut": "1652736468292377",
756
+ // "usDiff": "371",
757
+ // "testnet": false
758
+ // }
759
+ //
760
+ const result = this.safeValue(response, 'result', []);
761
+ return this.parseAccounts(result);
762
+ }
763
+ parseAccount(account) {
764
+ //
765
+ // {
766
+ // "username": "someusername_1",
767
+ // "type": "subaccount",
768
+ // "system_name": "someusername_1",
769
+ // "security_keys_enabled": false,
770
+ // "security_keys_assignments": [],
771
+ // "receive_notifications": false,
772
+ // "login_enabled": false,
773
+ // "is_password": false,
774
+ // "id": "245499",
775
+ // "email": "pablo@abcdef.com"
776
+ // }
777
+ //
778
+ return {
779
+ 'info': account,
780
+ 'id': this.safeString(account, 'id'),
781
+ 'type': this.safeString(account, 'type'),
782
+ 'code': undefined,
783
+ };
784
+ }
785
+ /**
786
+ * @method
787
+ * @name deribit#fetchMarkets
788
+ * @description retrieves data on all markets for deribit
789
+ * @see https://docs.deribit.com/#public-get_currencies
790
+ * @see https://docs.deribit.com/#public-get_instruments
791
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
792
+ * @returns {object[]} an array of objects representing market data
793
+ */
794
+ async fetchMarkets(params = {}) {
795
+ const instrumentsResponses = [];
796
+ const result = [];
797
+ const parsedMarkets = {};
798
+ let fetchAllMarkets = undefined;
799
+ [fetchAllMarkets, params] = this.handleOptionAndParams(params, 'fetchMarkets', 'fetchAllMarkets', true);
800
+ if (fetchAllMarkets) {
801
+ const instrumentsResponse = await this.publicGetGetInstruments(params);
802
+ instrumentsResponses.push(instrumentsResponse);
803
+ }
804
+ else {
805
+ const currenciesResponse = await this.publicGetGetCurrencies(params);
806
+ //
807
+ // {
808
+ // "jsonrpc": "2.0",
809
+ // "result": [
810
+ // {
811
+ // "withdrawal_priorities": [
812
+ // { value: 0.15, name: "very_low" },
813
+ // { value: 1.5, name: "very_high" },
814
+ // ],
815
+ // "withdrawal_fee": 0.0005,
816
+ // "min_withdrawal_fee": 0.0005,
817
+ // "min_confirmations": 1,
818
+ // "fee_precision": 4,
819
+ // "currency_long": "Bitcoin",
820
+ // "currency": "BTC",
821
+ // "coin_type": "BITCOIN"
822
+ // }
823
+ // ],
824
+ // "usIn": 1583761588590479,
825
+ // "usOut": 1583761588590544,
826
+ // "usDiff": 65,
827
+ // "testnet": false
828
+ // }
829
+ //
830
+ const currenciesResult = this.safeValue(currenciesResponse, 'result', []);
831
+ for (let i = 0; i < currenciesResult.length; i++) {
832
+ const currencyId = this.safeString(currenciesResult[i], 'currency');
833
+ const request = {
834
+ 'currency': currencyId,
835
+ };
836
+ const instrumentsResponse = await this.publicGetGetInstruments(this.extend(request, params));
837
+ //
838
+ // {
839
+ // "jsonrpc":"2.0",
840
+ // "result":[
841
+ // {
842
+ // "tick_size":0.0005,
843
+ // "taker_commission":0.0003,
844
+ // "strike":52000.0,
845
+ // "settlement_period":"month",
846
+ // "settlement_currency":"BTC",
847
+ // "quote_currency":"BTC",
848
+ // "option_type":"put", // put, call
849
+ // "min_trade_amount":0.1,
850
+ // "maker_commission":0.0003,
851
+ // "kind":"option",
852
+ // "is_active":true,
853
+ // "instrument_name":"BTC-24JUN22-52000-P",
854
+ // "expiration_timestamp":1656057600000,
855
+ // "creation_timestamp":1648199543000,
856
+ // "counter_currency":"USD",
857
+ // "contract_size":1.0,
858
+ // "block_trade_commission":0.0003,
859
+ // "base_currency":"BTC"
860
+ // },
861
+ // {
862
+ // "tick_size":0.5,
863
+ // "taker_commission":0.0005,
864
+ // "settlement_period":"month", // month, week
865
+ // "settlement_currency":"BTC",
866
+ // "quote_currency":"USD",
867
+ // "min_trade_amount":10.0,
868
+ // "max_liquidation_commission":0.0075,
869
+ // "max_leverage":50,
870
+ // "maker_commission":0.0,
871
+ // "kind":"future",
872
+ // "is_active":true,
873
+ // "instrument_name":"BTC-27MAY22",
874
+ // "future_type":"reversed",
875
+ // "expiration_timestamp":1653638400000,
876
+ // "creation_timestamp":1648195209000,
877
+ // "counter_currency":"USD",
878
+ // "contract_size":10.0,
879
+ // "block_trade_commission":0.0001,
880
+ // "base_currency":"BTC"
881
+ // },
882
+ // {
883
+ // "tick_size":0.5,
884
+ // "taker_commission":0.0005,
885
+ // "settlement_period":"perpetual",
886
+ // "settlement_currency":"BTC",
887
+ // "quote_currency":"USD",
888
+ // "min_trade_amount":10.0,
889
+ // "max_liquidation_commission":0.0075,
890
+ // "max_leverage":50,
891
+ // "maker_commission":0.0,
892
+ // "kind":"future",
893
+ // "is_active":true,
894
+ // "instrument_name":"BTC-PERPETUAL",
895
+ // "future_type":"reversed",
896
+ // "expiration_timestamp":32503708800000,
897
+ // "creation_timestamp":1534242287000,
898
+ // "counter_currency":"USD",
899
+ // "contract_size":10.0,
900
+ // "block_trade_commission":0.0001,
901
+ // "base_currency":"BTC"
902
+ // },
903
+ // ],
904
+ // "usIn":1648691472831791,
905
+ // "usOut":1648691472831896,
906
+ // "usDiff":105,
907
+ // "testnet":false
908
+ // }
909
+ //
910
+ instrumentsResponses.push(instrumentsResponse);
911
+ }
912
+ }
913
+ for (let i = 0; i < instrumentsResponses.length; i++) {
914
+ const instrumentsResult = this.safeValue(instrumentsResponses[i], 'result', []);
915
+ for (let k = 0; k < instrumentsResult.length; k++) {
916
+ const market = instrumentsResult[k];
917
+ const kind = this.safeString(market, 'kind');
918
+ const isSpot = (kind === 'spot');
919
+ const id = this.safeString(market, 'instrument_name');
920
+ const baseId = this.safeString(market, 'base_currency');
921
+ const quoteId = this.safeString(market, 'counter_currency');
922
+ const settleId = this.safeString(market, 'settlement_currency');
923
+ const base = this.safeCurrencyCode(baseId);
924
+ const quote = this.safeCurrencyCode(quoteId);
925
+ const settle = this.safeCurrencyCode(settleId);
926
+ const settlementPeriod = this.safeValue(market, 'settlement_period');
927
+ const swap = (settlementPeriod === 'perpetual');
928
+ const future = !swap && (kind.indexOf('future') >= 0);
929
+ const option = (kind.indexOf('option') >= 0);
930
+ const isComboMarket = kind.indexOf('combo') >= 0;
931
+ const expiry = this.safeInteger(market, 'expiration_timestamp');
932
+ let strike = undefined;
933
+ let optionType = undefined;
934
+ let symbol = id;
935
+ let type = 'swap';
936
+ if (future) {
937
+ type = 'future';
938
+ }
939
+ else if (option) {
940
+ type = 'option';
941
+ }
942
+ else if (isSpot) {
943
+ type = 'spot';
944
+ }
945
+ let inverse = undefined;
946
+ let linear = undefined;
947
+ if (isSpot) {
948
+ symbol = base + '/' + quote;
949
+ }
950
+ else if (!isComboMarket) {
951
+ symbol = base + '/' + quote + ':' + settle;
952
+ if (option || future) {
953
+ symbol = symbol + '-' + this.yymmdd(expiry, '');
954
+ if (option) {
955
+ strike = this.safeNumber(market, 'strike');
956
+ optionType = this.safeString(market, 'option_type');
957
+ const letter = (optionType === 'call') ? 'C' : 'P';
958
+ symbol = symbol + '-' + this.numberToString(strike) + '-' + letter;
959
+ }
960
+ }
961
+ inverse = (quote !== settle);
962
+ linear = (settle === quote);
963
+ }
964
+ const parsedMarketValue = this.safeValue(parsedMarkets, symbol);
965
+ if (parsedMarketValue) {
966
+ continue;
967
+ }
968
+ parsedMarkets[symbol] = true;
969
+ const minTradeAmount = this.safeNumber(market, 'min_trade_amount');
970
+ const tickSize = this.safeNumber(market, 'tick_size');
971
+ result.push({
972
+ 'id': id,
973
+ 'symbol': symbol,
974
+ 'base': base,
975
+ 'quote': quote,
976
+ 'settle': settle,
977
+ 'baseId': baseId,
978
+ 'quoteId': quoteId,
979
+ 'settleId': settleId,
980
+ 'type': type,
981
+ 'spot': isSpot,
982
+ 'margin': false,
983
+ 'swap': swap,
984
+ 'future': future,
985
+ 'option': option,
986
+ 'active': this.safeValue(market, 'is_active'),
987
+ 'contract': !isSpot,
988
+ 'linear': linear,
989
+ 'inverse': inverse,
990
+ 'taker': this.safeNumber(market, 'taker_commission'),
991
+ 'maker': this.safeNumber(market, 'maker_commission'),
992
+ 'contractSize': this.safeNumber(market, 'contract_size'),
993
+ 'expiry': expiry,
994
+ 'expiryDatetime': this.iso8601(expiry),
995
+ 'strike': strike,
996
+ 'optionType': optionType,
997
+ 'precision': {
998
+ 'amount': minTradeAmount,
999
+ 'price': tickSize,
1000
+ },
1001
+ 'limits': {
1002
+ 'leverage': {
1003
+ 'min': undefined,
1004
+ 'max': undefined,
1005
+ },
1006
+ 'amount': {
1007
+ 'min': minTradeAmount,
1008
+ 'max': undefined,
1009
+ },
1010
+ 'price': {
1011
+ 'min': tickSize,
1012
+ 'max': undefined,
1013
+ },
1014
+ 'cost': {
1015
+ 'min': undefined,
1016
+ 'max': undefined,
1017
+ },
1018
+ },
1019
+ 'created': this.safeInteger(market, 'creation_timestamp'),
1020
+ 'info': market,
1021
+ });
1022
+ }
1023
+ }
1024
+ return result;
1025
+ }
1026
+ parseBalance(balance) {
1027
+ const result = {
1028
+ 'info': balance,
1029
+ };
1030
+ let summaries = [];
1031
+ if ('summaries' in balance) {
1032
+ summaries = this.safeList(balance, 'summaries');
1033
+ }
1034
+ else {
1035
+ summaries = [balance];
1036
+ }
1037
+ for (let i = 0; i < summaries.length; i++) {
1038
+ const data = summaries[i];
1039
+ const currencyId = this.safeString(data, 'currency');
1040
+ const currencyCode = this.safeCurrencyCode(currencyId);
1041
+ const account = this.account();
1042
+ account['free'] = this.safeString(data, 'available_funds');
1043
+ account['used'] = this.safeString(data, 'maintenance_margin');
1044
+ account['total'] = this.safeString(data, 'equity');
1045
+ result[currencyCode] = account;
1046
+ }
1047
+ return this.safeBalance(result);
1048
+ }
1049
+ /**
1050
+ * @method
1051
+ * @name deribit#fetchBalance
1052
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1053
+ * @see https://docs.deribit.com/#private-get_account_summary
1054
+ * @see https://docs.deribit.com/#private-get_account_summaries
1055
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1056
+ * @param {string} [params.code] unified currency code of the currency for the balance, if defined 'privateGetGetAccountSummary' will be used, otherwise 'privateGetGetAccountSummaries' will be used
1057
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1058
+ */
1059
+ async fetchBalance(params = {}) {
1060
+ await this.loadMarkets();
1061
+ const code = this.safeString(params, 'code');
1062
+ params = this.omit(params, 'code');
1063
+ const request = {};
1064
+ if (code !== undefined) {
1065
+ request['currency'] = this.currencyId(code);
1066
+ }
1067
+ let response = undefined;
1068
+ if (code === undefined) {
1069
+ response = await this.privateGetGetAccountSummaries(params);
1070
+ }
1071
+ else {
1072
+ response = await this.privateGetGetAccountSummary(this.extend(request, params));
1073
+ }
1074
+ //
1075
+ // {
1076
+ // "jsonrpc": "2.0",
1077
+ // "result": {
1078
+ // "total_pl": 0,
1079
+ // "session_upl": 0,
1080
+ // "session_rpl": 0,
1081
+ // "session_funding": 0,
1082
+ // "portfolio_margining_enabled": false,
1083
+ // "options_vega": 0,
1084
+ // "options_theta": 0,
1085
+ // "options_session_upl": 0,
1086
+ // "options_session_rpl": 0,
1087
+ // "options_pl": 0,
1088
+ // "options_gamma": 0,
1089
+ // "options_delta": 0,
1090
+ // "margin_balance": 0.00062359,
1091
+ // "maintenance_margin": 0,
1092
+ // "limits": {
1093
+ // "non_matching_engine_burst": 300,
1094
+ // "non_matching_engine": 200,
1095
+ // "matching_engine_burst": 20,
1096
+ // "matching_engine": 2
1097
+ // },
1098
+ // "initial_margin": 0,
1099
+ // "futures_session_upl": 0,
1100
+ // "futures_session_rpl": 0,
1101
+ // "futures_pl": 0,
1102
+ // "equity": 0.00062359,
1103
+ // "deposit_address": "13tUtNsJSZa1F5GeCmwBywVrymHpZispzw",
1104
+ // "delta_total": 0,
1105
+ // "currency": "BTC",
1106
+ // "balance": 0.00062359,
1107
+ // "available_withdrawal_funds": 0.00062359,
1108
+ // "available_funds": 0.00062359
1109
+ // },
1110
+ // "usIn": 1583775838115975,
1111
+ // "usOut": 1583775838116520,
1112
+ // "usDiff": 545,
1113
+ // "testnet": false
1114
+ // }
1115
+ //
1116
+ const result = this.safeDict(response, 'result', {});
1117
+ return this.parseBalance(result);
1118
+ }
1119
+ /**
1120
+ * @method
1121
+ * @name deribit#createDepositAddress
1122
+ * @description create a currency deposit address
1123
+ * @see https://docs.deribit.com/#private-create_deposit_address
1124
+ * @param {string} code unified currency code of the currency for the deposit address
1125
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1126
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1127
+ */
1128
+ async createDepositAddress(code, params = {}) {
1129
+ await this.loadMarkets();
1130
+ const currency = this.currency(code);
1131
+ const request = {
1132
+ 'currency': currency['id'],
1133
+ };
1134
+ const response = await this.privateGetCreateDepositAddress(this.extend(request, params));
1135
+ //
1136
+ // {
1137
+ // "jsonrpc": "2.0",
1138
+ // "id": 7538,
1139
+ // "result": {
1140
+ // "address": "2N8udZGBc1hLRCFsU9kGwMPpmYUwMFTuCwB",
1141
+ // "creation_timestamp": 1550575165170,
1142
+ // "currency": "BTC",
1143
+ // "type": "deposit"
1144
+ // }
1145
+ // }
1146
+ //
1147
+ const result = this.safeValue(response, 'result', {});
1148
+ const address = this.safeString(result, 'address');
1149
+ this.checkAddress(address);
1150
+ return {
1151
+ 'currency': code,
1152
+ 'address': address,
1153
+ 'tag': undefined,
1154
+ 'network': undefined,
1155
+ 'info': response,
1156
+ };
1157
+ }
1158
+ /**
1159
+ * @method
1160
+ * @name deribit#fetchDepositAddress
1161
+ * @description fetch the deposit address for a currency associated with this account
1162
+ * @see https://docs.deribit.com/#private-get_current_deposit_address
1163
+ * @param {string} code unified currency code
1164
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1165
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1166
+ */
1167
+ async fetchDepositAddress(code, params = {}) {
1168
+ await this.loadMarkets();
1169
+ const currency = this.currency(code);
1170
+ const request = {
1171
+ 'currency': currency['id'],
1172
+ };
1173
+ const response = await this.privateGetGetCurrentDepositAddress(this.extend(request, params));
1174
+ //
1175
+ // {
1176
+ // "jsonrpc": "2.0",
1177
+ // "result": {
1178
+ // "type": "deposit",
1179
+ // "status": "ready",
1180
+ // "requires_confirmation": true,
1181
+ // "currency": "BTC",
1182
+ // "creation_timestamp": 1514694684651,
1183
+ // "address": "13tUtNsJSZa1F5GeCmwBywVrymHpZispzw"
1184
+ // },
1185
+ // "usIn": 1583785137274288,
1186
+ // "usOut": 1583785137274454,
1187
+ // "usDiff": 166,
1188
+ // "testnet": false
1189
+ // }
1190
+ //
1191
+ const result = this.safeValue(response, 'result', {});
1192
+ const address = this.safeString(result, 'address');
1193
+ this.checkAddress(address);
1194
+ return {
1195
+ 'info': response,
1196
+ 'currency': code,
1197
+ 'network': undefined,
1198
+ 'address': address,
1199
+ 'tag': undefined,
1200
+ };
1201
+ }
1202
+ parseTicker(ticker, market = undefined) {
1203
+ //
1204
+ // fetchTicker /public/ticker
1205
+ //
1206
+ // {
1207
+ // "timestamp": 1583778859480,
1208
+ // "stats": { volume: 60627.57263769, low: 7631.5, high: 8311.5 },
1209
+ // "state": "open",
1210
+ // "settlement_price": 7903.21,
1211
+ // "open_interest": 111543850,
1212
+ // "min_price": 7634,
1213
+ // "max_price": 7866.51,
1214
+ // "mark_price": 7750.02,
1215
+ // "last_price": 7750.5,
1216
+ // "instrument_name": "BTC-PERPETUAL",
1217
+ // "index_price": 7748.01,
1218
+ // "funding_8h": 0.0000026,
1219
+ // "current_funding": 0,
1220
+ // "best_bid_price": 7750,
1221
+ // "best_bid_amount": 19470,
1222
+ // "best_ask_price": 7750.5,
1223
+ // "best_ask_amount": 343280
1224
+ // }
1225
+ //
1226
+ // fetchTicker /public/get_book_summary_by_instrument
1227
+ // fetchTickers /public/get_book_summary_by_currency
1228
+ //
1229
+ // {
1230
+ // "volume": 124.1,
1231
+ // "underlying_price": 7856.445926872601,
1232
+ // "underlying_index": "SYN.BTC-10MAR20",
1233
+ // "quote_currency": "USD",
1234
+ // "open_interest": 121.8,
1235
+ // "mid_price": 0.01975,
1236
+ // "mark_price": 0.01984559,
1237
+ // "low": 0.0095,
1238
+ // "last": 0.0205,
1239
+ // "interest_rate": 0,
1240
+ // "instrument_name": "BTC-10MAR20-7750-C",
1241
+ // "high": 0.0295,
1242
+ // "estimated_delivery_price": 7856.29,
1243
+ // "creation_timestamp": 1583783678366,
1244
+ // "bid_price": 0.0185,
1245
+ // "base_currency": "BTC",
1246
+ // "ask_price": 0.021
1247
+ // },
1248
+ //
1249
+ const timestamp = this.safeInteger2(ticker, 'timestamp', 'creation_timestamp');
1250
+ const marketId = this.safeString(ticker, 'instrument_name');
1251
+ const symbol = this.safeSymbol(marketId, market);
1252
+ const last = this.safeString2(ticker, 'last_price', 'last');
1253
+ const stats = this.safeValue(ticker, 'stats', ticker);
1254
+ return this.safeTicker({
1255
+ 'symbol': symbol,
1256
+ 'timestamp': timestamp,
1257
+ 'datetime': this.iso8601(timestamp),
1258
+ 'high': this.safeString2(stats, 'high', 'max_price'),
1259
+ 'low': this.safeString2(stats, 'low', 'min_price'),
1260
+ 'bid': this.safeString2(ticker, 'best_bid_price', 'bid_price'),
1261
+ 'bidVolume': this.safeString(ticker, 'best_bid_amount'),
1262
+ 'ask': this.safeString2(ticker, 'best_ask_price', 'ask_price'),
1263
+ 'askVolume': this.safeString(ticker, 'best_ask_amount'),
1264
+ 'vwap': undefined,
1265
+ 'open': undefined,
1266
+ 'close': last,
1267
+ 'last': last,
1268
+ 'previousClose': undefined,
1269
+ 'change': undefined,
1270
+ 'percentage': undefined,
1271
+ 'average': undefined,
1272
+ 'baseVolume': undefined,
1273
+ 'quoteVolume': this.safeString(stats, 'volume'),
1274
+ 'markPrice': this.safeString(ticker, 'mark_price'),
1275
+ 'indexPrice': this.safeString(ticker, 'index_price'),
1276
+ 'info': ticker,
1277
+ }, market);
1278
+ }
1279
+ /**
1280
+ * @method
1281
+ * @name deribit#fetchTicker
1282
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1283
+ * @see https://docs.deribit.com/#public-ticker
1284
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1285
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1286
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1287
+ */
1288
+ async fetchTicker(symbol, params = {}) {
1289
+ await this.loadMarkets();
1290
+ const market = this.market(symbol);
1291
+ const request = {
1292
+ 'instrument_name': market['id'],
1293
+ };
1294
+ const response = await this.publicGetTicker(this.extend(request, params));
1295
+ //
1296
+ // {
1297
+ // "jsonrpc": "2.0",
1298
+ // "result": {
1299
+ // "timestamp": 1583778859480,
1300
+ // "stats": { volume: 60627.57263769, low: 7631.5, high: 8311.5 },
1301
+ // "state": "open",
1302
+ // "settlement_price": 7903.21,
1303
+ // "open_interest": 111543850,
1304
+ // "min_price": 7634,
1305
+ // "max_price": 7866.51,
1306
+ // "mark_price": 7750.02,
1307
+ // "last_price": 7750.5,
1308
+ // "instrument_name": "BTC-PERPETUAL",
1309
+ // "index_price": 7748.01,
1310
+ // "funding_8h": 0.0000026,
1311
+ // "current_funding": 0,
1312
+ // "best_bid_price": 7750,
1313
+ // "best_bid_amount": 19470,
1314
+ // "best_ask_price": 7750.5,
1315
+ // "best_ask_amount": 343280
1316
+ // },
1317
+ // "usIn": 1583778859483941,
1318
+ // "usOut": 1583778859484075,
1319
+ // "usDiff": 134,
1320
+ // "testnet": false
1321
+ // }
1322
+ //
1323
+ const result = this.safeDict(response, 'result');
1324
+ return this.parseTicker(result, market);
1325
+ }
1326
+ /**
1327
+ * @method
1328
+ * @name deribit#fetchTickers
1329
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1330
+ * @see https://docs.deribit.com/#public-get_book_summary_by_currency
1331
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1332
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1333
+ * @param {string} [params.code] *required* the currency code to fetch the tickers for, eg. 'BTC', 'ETH'
1334
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1335
+ */
1336
+ async fetchTickers(symbols = undefined, params = {}) {
1337
+ await this.loadMarkets();
1338
+ symbols = this.marketSymbols(symbols);
1339
+ let code = this.safeString2(params, 'code', 'currency');
1340
+ let type = undefined;
1341
+ params = this.omit(params, ['code']);
1342
+ if (symbols !== undefined) {
1343
+ for (let i = 0; i < symbols.length; i++) {
1344
+ const market = this.market(symbols[i]);
1345
+ if (code !== undefined && code !== market['base']) {
1346
+ throw new BadRequest(this.id + ' fetchTickers the base currency must be the same for all symbols, this endpoint only supports one base currency at a time. Read more about it here: https://docs.deribit.com/#public-get_book_summary_by_currency');
1347
+ }
1348
+ if (code === undefined) {
1349
+ code = market['base'];
1350
+ type = market['type'];
1351
+ }
1352
+ }
1353
+ }
1354
+ if (code === undefined) {
1355
+ throw new ArgumentsRequired(this.id + ' fetchTickers requires a currency/code (eg: BTC/ETH/USDT) parameter to fetch tickers for');
1356
+ }
1357
+ const currency = this.currency(code);
1358
+ const request = {
1359
+ 'currency': currency['id'],
1360
+ };
1361
+ if (type !== undefined) {
1362
+ let requestType = undefined;
1363
+ if (type === 'spot') {
1364
+ requestType = 'spot';
1365
+ }
1366
+ else if (type === 'future' || (type === 'contract')) {
1367
+ requestType = 'future';
1368
+ }
1369
+ else if (type === 'option') {
1370
+ requestType = 'option';
1371
+ }
1372
+ if (requestType !== undefined) {
1373
+ request['kind'] = requestType;
1374
+ }
1375
+ }
1376
+ const response = await this.publicGetGetBookSummaryByCurrency(this.extend(request, params));
1377
+ //
1378
+ // {
1379
+ // "jsonrpc": "2.0",
1380
+ // "result": [
1381
+ // {
1382
+ // "volume": 124.1,
1383
+ // "underlying_price": 7856.445926872601,
1384
+ // "underlying_index": "SYN.BTC-10MAR20",
1385
+ // "quote_currency": "USD",
1386
+ // "open_interest": 121.8,
1387
+ // "mid_price": 0.01975,
1388
+ // "mark_price": 0.01984559,
1389
+ // "low": 0.0095,
1390
+ // "last": 0.0205,
1391
+ // "interest_rate": 0,
1392
+ // "instrument_name": "BTC-10MAR20-7750-C",
1393
+ // "high": 0.0295,
1394
+ // "estimated_delivery_price": 7856.29,
1395
+ // "creation_timestamp": 1583783678366,
1396
+ // "bid_price": 0.0185,
1397
+ // "base_currency": "BTC",
1398
+ // "ask_price": 0.021
1399
+ // },
1400
+ // ],
1401
+ // "usIn": 1583783678361966,
1402
+ // "usOut": 1583783678372069,
1403
+ // "usDiff": 10103,
1404
+ // "testnet": false
1405
+ // }
1406
+ //
1407
+ const result = this.safeList(response, 'result', []);
1408
+ const tickers = {};
1409
+ for (let i = 0; i < result.length; i++) {
1410
+ const ticker = this.parseTicker(result[i]);
1411
+ const symbol = ticker['symbol'];
1412
+ tickers[symbol] = ticker;
1413
+ }
1414
+ return this.filterByArrayTickers(tickers, 'symbol', symbols);
1415
+ }
1416
+ /**
1417
+ * @method
1418
+ * @name deribit#fetchOHLCV
1419
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1420
+ * @see https://docs.deribit.com/#public-get_tradingview_chart_data
1421
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1422
+ * @param {string} timeframe the length of time each candle represents
1423
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1424
+ * @param {int} [limit] the maximum amount of candles to fetch
1425
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1426
+ * @param {boolean} [params.paginate] whether to paginate the results, set to false by default
1427
+ * @param {int} [params.until] the latest time in ms to fetch ohlcv for
1428
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1429
+ */
1430
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1431
+ await this.loadMarkets();
1432
+ let paginate = false;
1433
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
1434
+ if (paginate) {
1435
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 5000);
1436
+ }
1437
+ const market = this.market(symbol);
1438
+ const request = {
1439
+ 'instrument_name': market['id'],
1440
+ 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
1441
+ };
1442
+ const duration = this.parseTimeframe(timeframe);
1443
+ const now = this.milliseconds();
1444
+ if (since === undefined) {
1445
+ if (limit === undefined) {
1446
+ limit = 1000; // at max, it provides 5000 bars, but we set generous default here
1447
+ }
1448
+ request['start_timestamp'] = now - (limit - 1) * duration * 1000;
1449
+ request['end_timestamp'] = now;
1450
+ }
1451
+ else {
1452
+ since = Math.max(since - 1, 0);
1453
+ request['start_timestamp'] = since;
1454
+ if (limit === undefined) {
1455
+ request['end_timestamp'] = now;
1456
+ }
1457
+ else {
1458
+ request['end_timestamp'] = this.sum(since, limit * duration * 1000);
1459
+ }
1460
+ }
1461
+ const until = this.safeInteger(params, 'until');
1462
+ if (until !== undefined) {
1463
+ params = this.omit(params, 'until');
1464
+ request['end_timestamp'] = until;
1465
+ }
1466
+ const response = await this.publicGetGetTradingviewChartData(this.extend(request, params));
1467
+ //
1468
+ // {
1469
+ // "jsonrpc": "2.0",
1470
+ // "result": {
1471
+ // "volume": [ 3.6680847969999992, 22.682721123, 3.011587939, 0 ],
1472
+ // "ticks": [ 1583916960000, 1583917020000, 1583917080000, 1583917140000 ],
1473
+ // "status": "ok",
1474
+ // "open": [ 7834, 7839, 7833.5, 7833 ],
1475
+ // "low": [ 7834, 7833.5, 7832.5, 7833 ],
1476
+ // "high": [ 7839.5, 7839, 7833.5, 7833 ],
1477
+ // "cost": [ 28740, 177740, 23590, 0 ],
1478
+ // "close": [ 7839.5, 7833.5, 7833, 7833 ]
1479
+ // },
1480
+ // "usIn": 1583917166709801,
1481
+ // "usOut": 1583917166710175,
1482
+ // "usDiff": 374,
1483
+ // "testnet": false
1484
+ // }
1485
+ //
1486
+ const result = this.safeValue(response, 'result', {});
1487
+ const ohlcvs = this.convertTradingViewToOHLCV(result, 'ticks', 'open', 'high', 'low', 'close', 'volume', true);
1488
+ return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
1489
+ }
1490
+ parseTrade(trade, market = undefined) {
1491
+ //
1492
+ // fetchTrades (public)
1493
+ //
1494
+ // {
1495
+ // "trade_seq":132564271,
1496
+ // "trade_id":"195402220",
1497
+ // "timestamp":1639684927932,
1498
+ // "tick_direction":0,
1499
+ // "price":47946.5,
1500
+ // "mark_price":47944.13,
1501
+ // "instrument_name":"BTC-PERPETUAL",
1502
+ // "index_price":47925.45,
1503
+ // "direction":"buy",
1504
+ // "amount":580.0
1505
+ // }
1506
+ //
1507
+ //
1508
+ // fetchMyTrades, fetchOrderTrades (private)
1509
+ //
1510
+ // {
1511
+ // "trade_seq": 3,
1512
+ // "trade_id": "ETH-34066",
1513
+ // "timestamp": 1550219814585,
1514
+ // "tick_direction": 1,
1515
+ // "state": "open",
1516
+ // "self_trade": false,
1517
+ // "reduce_only": false,
1518
+ // "price": 0.04,
1519
+ // "post_only": false,
1520
+ // "order_type": "limit",
1521
+ // "order_id": "ETH-334607",
1522
+ // "matching_id": null,
1523
+ // "liquidity": "M",
1524
+ // "iv": 56.83,
1525
+ // "instrument_name": "ETH-22FEB19-120-C",
1526
+ // "index_price": 121.37,
1527
+ // "fee_currency": "ETH",
1528
+ // "fee": 0.0011,
1529
+ // "direction": "buy",
1530
+ // "amount": 11
1531
+ // }
1532
+ //
1533
+ const id = this.safeString(trade, 'trade_id');
1534
+ const marketId = this.safeString(trade, 'instrument_name');
1535
+ const symbol = this.safeSymbol(marketId, market);
1536
+ const timestamp = this.safeInteger(trade, 'timestamp');
1537
+ const side = this.safeString(trade, 'direction');
1538
+ const priceString = this.safeString(trade, 'price');
1539
+ market = this.safeMarket(marketId, market);
1540
+ // Amount for inverse perpetual and futures is in USD which in ccxt is the cost
1541
+ // For options amount and linear is in corresponding cryptocurrency contracts, e.g., BTC or ETH
1542
+ const amount = this.safeString(trade, 'amount');
1543
+ let cost = Precise.stringMul(amount, priceString);
1544
+ if (market['inverse']) {
1545
+ cost = Precise.stringDiv(amount, priceString);
1546
+ }
1547
+ const liquidity = this.safeString(trade, 'liquidity');
1548
+ let takerOrMaker = undefined;
1549
+ if (liquidity !== undefined) {
1550
+ // M = maker, T = taker, MT = both
1551
+ takerOrMaker = (liquidity === 'M') ? 'maker' : 'taker';
1552
+ }
1553
+ const feeCostString = this.safeString(trade, 'fee');
1554
+ let fee = undefined;
1555
+ if (feeCostString !== undefined) {
1556
+ const feeCurrencyId = this.safeString(trade, 'fee_currency');
1557
+ const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
1558
+ fee = {
1559
+ 'cost': feeCostString,
1560
+ 'currency': feeCurrencyCode,
1561
+ };
1562
+ }
1563
+ return this.safeTrade({
1564
+ 'id': id,
1565
+ 'info': trade,
1566
+ 'timestamp': timestamp,
1567
+ 'datetime': this.iso8601(timestamp),
1568
+ 'symbol': symbol,
1569
+ 'order': this.safeString(trade, 'order_id'),
1570
+ 'type': this.safeString(trade, 'order_type'),
1571
+ 'side': side,
1572
+ 'takerOrMaker': takerOrMaker,
1573
+ 'price': priceString,
1574
+ 'amount': amount,
1575
+ 'cost': cost,
1576
+ 'fee': fee,
1577
+ }, market);
1578
+ }
1579
+ /**
1580
+ * @method
1581
+ * @name deribit#fetchTrades
1582
+ * @see https://docs.deribit.com/#public-get_last_trades_by_instrument
1583
+ * @see https://docs.deribit.com/#public-get_last_trades_by_instrument_and_time
1584
+ * @description get the list of most recent trades for a particular symbol.
1585
+ * @param {string} symbol unified symbol of the market to fetch trades for
1586
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1587
+ * @param {int} [limit] the maximum amount of trades to fetch
1588
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1589
+ * @param {int} [params.until] the latest time in ms to fetch trades for
1590
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1591
+ */
1592
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1593
+ await this.loadMarkets();
1594
+ const market = this.market(symbol);
1595
+ const request = {
1596
+ 'instrument_name': market['id'],
1597
+ 'include_old': true,
1598
+ };
1599
+ if (since !== undefined) {
1600
+ request['start_timestamp'] = since;
1601
+ }
1602
+ if (limit !== undefined) {
1603
+ request['count'] = Math.min(limit, 1000); // default 10
1604
+ }
1605
+ const until = this.safeInteger2(params, 'until', 'end_timestamp');
1606
+ if (until !== undefined) {
1607
+ params = this.omit(params, ['until']);
1608
+ request['end_timestamp'] = until;
1609
+ }
1610
+ let response = undefined;
1611
+ if ((since === undefined) && !('end_timestamp' in request)) {
1612
+ response = await this.publicGetGetLastTradesByInstrument(this.extend(request, params));
1613
+ }
1614
+ else {
1615
+ response = await this.publicGetGetLastTradesByInstrumentAndTime(this.extend(request, params));
1616
+ }
1617
+ //
1618
+ // {
1619
+ // "jsonrpc":"2.0",
1620
+ // "result": {
1621
+ // "trades": [
1622
+ // {
1623
+ // "trade_seq":132564271,
1624
+ // "trade_id":"195402220",
1625
+ // "timestamp":1639684927932,
1626
+ // "tick_direction":0,
1627
+ // "price":47946.5,
1628
+ // "mark_price":47944.13,
1629
+ // "instrument_name":"BTC-PERPETUAL",
1630
+ // "index_price":47925.45,
1631
+ // "direction":"buy","amount":580.0
1632
+ // }
1633
+ // ],
1634
+ // "has_more":true
1635
+ // },
1636
+ // "usIn":1639684931934671,
1637
+ // "usOut":1639684931935337,
1638
+ // "usDiff":666,
1639
+ // "testnet":false
1640
+ // }
1641
+ //
1642
+ const result = this.safeValue(response, 'result', {});
1643
+ const trades = this.safeList(result, 'trades', []);
1644
+ return this.parseTrades(trades, market, since, limit);
1645
+ }
1646
+ /**
1647
+ * @method
1648
+ * @name deribit#fetchTradingFees
1649
+ * @description fetch the trading fees for multiple markets
1650
+ * @see https://docs.deribit.com/#private-get_account_summary
1651
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1652
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
1653
+ */
1654
+ async fetchTradingFees(params = {}) {
1655
+ await this.loadMarkets();
1656
+ const code = this.codeFromOptions('fetchTradingFees', params);
1657
+ const currency = this.currency(code);
1658
+ const request = {
1659
+ 'currency': currency['id'],
1660
+ 'extended': true,
1661
+ };
1662
+ const response = await this.privateGetGetAccountSummary(this.extend(request, params));
1663
+ //
1664
+ // {
1665
+ // "jsonrpc": "2.0",
1666
+ // "result": {
1667
+ // "total_pl": 0,
1668
+ // "session_upl": 0,
1669
+ // "session_rpl": 0,
1670
+ // "session_funding": 0,
1671
+ // "portfolio_margining_enabled": false,
1672
+ // "options_vega": 0,
1673
+ // "options_theta": 0,
1674
+ // "options_session_upl": 0,
1675
+ // "options_session_rpl": 0,
1676
+ // "options_pl": 0,
1677
+ // "options_gamma": 0,
1678
+ // "options_delta": 0,
1679
+ // "margin_balance": 0.00062359,
1680
+ // "maintenance_margin": 0,
1681
+ // "limits": {
1682
+ // "non_matching_engine_burst": 300,
1683
+ // "non_matching_engine": 200,
1684
+ // "matching_engine_burst": 20,
1685
+ // "matching_engine": 2
1686
+ // },
1687
+ // "initial_margin": 0,
1688
+ // "futures_session_upl": 0,
1689
+ // "futures_session_rpl": 0,
1690
+ // "futures_pl": 0,
1691
+ // "equity": 0.00062359,
1692
+ // "deposit_address": "13tUtNsJSZa1F5GeCmwBywVrymHpZispzw",
1693
+ // "delta_total": 0,
1694
+ // "currency": "BTC",
1695
+ // "balance": 0.00062359,
1696
+ // "available_withdrawal_funds": 0.00062359,
1697
+ // "available_funds": 0.00062359,
1698
+ // "fees": [
1699
+ // "currency": '',
1700
+ // "instrument_type": "perpetual",
1701
+ // "fee_type": "relative",
1702
+ // "maker_fee": 0,
1703
+ // "taker_fee": 0,
1704
+ // ],
1705
+ // },
1706
+ // "usIn": 1583775838115975,
1707
+ // "usOut": 1583775838116520,
1708
+ // "usDiff": 545,
1709
+ // "testnet": false
1710
+ // }
1711
+ //
1712
+ const result = this.safeValue(response, 'result', {});
1713
+ const fees = this.safeValue(result, 'fees', []);
1714
+ let perpetualFee = {};
1715
+ let futureFee = {};
1716
+ let optionFee = {};
1717
+ for (let i = 0; i < fees.length; i++) {
1718
+ const fee = fees[i];
1719
+ const instrumentType = this.safeString(fee, 'instrument_type');
1720
+ if (instrumentType === 'future') {
1721
+ futureFee = {
1722
+ 'info': fee,
1723
+ 'maker': this.safeNumber(fee, 'maker_fee'),
1724
+ 'taker': this.safeNumber(fee, 'taker_fee'),
1725
+ };
1726
+ }
1727
+ else if (instrumentType === 'perpetual') {
1728
+ perpetualFee = {
1729
+ 'info': fee,
1730
+ 'maker': this.safeNumber(fee, 'maker_fee'),
1731
+ 'taker': this.safeNumber(fee, 'taker_fee'),
1732
+ };
1733
+ }
1734
+ else if (instrumentType === 'option') {
1735
+ optionFee = {
1736
+ 'info': fee,
1737
+ 'maker': this.safeNumber(fee, 'maker_fee'),
1738
+ 'taker': this.safeNumber(fee, 'taker_fee'),
1739
+ };
1740
+ }
1741
+ }
1742
+ const parsedFees = {};
1743
+ for (let i = 0; i < this.symbols.length; i++) {
1744
+ const symbol = this.symbols[i];
1745
+ const market = this.market(symbol);
1746
+ let fee = {
1747
+ 'info': market,
1748
+ 'symbol': symbol,
1749
+ 'percentage': true,
1750
+ 'tierBased': true,
1751
+ 'maker': market['maker'],
1752
+ 'taker': market['taker'],
1753
+ };
1754
+ if (market['swap']) {
1755
+ fee = this.extend(fee, perpetualFee);
1756
+ }
1757
+ else if (market['future']) {
1758
+ fee = this.extend(fee, futureFee);
1759
+ }
1760
+ else if (market['option']) {
1761
+ fee = this.extend(fee, optionFee);
1762
+ }
1763
+ parsedFees[symbol] = fee;
1764
+ }
1765
+ return parsedFees;
1766
+ }
1767
+ /**
1768
+ * @method
1769
+ * @name deribit#fetchOrderBook
1770
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1771
+ * @see https://docs.deribit.com/#public-get_order_book
1772
+ * @param {string} symbol unified symbol of the market to fetch the order book for
1773
+ * @param {int} [limit] the maximum amount of order book entries to return
1774
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1775
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1776
+ */
1777
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
1778
+ await this.loadMarkets();
1779
+ const market = this.market(symbol);
1780
+ const request = {
1781
+ 'instrument_name': market['id'],
1782
+ };
1783
+ if (limit !== undefined) {
1784
+ request['depth'] = limit;
1785
+ }
1786
+ const response = await this.publicGetGetOrderBook(this.extend(request, params));
1787
+ //
1788
+ // {
1789
+ // "jsonrpc": "2.0",
1790
+ // "result": {
1791
+ // "timestamp": 1583781354740,
1792
+ // "stats": { volume: 61249.66735634, low: 7631.5, high: 8311.5 },
1793
+ // "state": "open",
1794
+ // "settlement_price": 7903.21,
1795
+ // "open_interest": 111536690,
1796
+ // "min_price": 7695.13,
1797
+ // "max_price": 7929.49,
1798
+ // "mark_price": 7813.06,
1799
+ // "last_price": 7814.5,
1800
+ // "instrument_name": "BTC-PERPETUAL",
1801
+ // "index_price": 7810.12,
1802
+ // "funding_8h": 0.0000031,
1803
+ // "current_funding": 0,
1804
+ // "change_id": 17538025952,
1805
+ // "bids": [
1806
+ // [7814, 351820],
1807
+ // [7813.5, 207490],
1808
+ // [7813, 32160],
1809
+ // ],
1810
+ // "best_bid_price": 7814,
1811
+ // "best_bid_amount": 351820,
1812
+ // "best_ask_price": 7814.5,
1813
+ // "best_ask_amount": 11880,
1814
+ // "asks": [
1815
+ // [7814.5, 11880],
1816
+ // [7815, 18100],
1817
+ // [7815.5, 2640],
1818
+ // ],
1819
+ // },
1820
+ // "usIn": 1583781354745804,
1821
+ // "usOut": 1583781354745932,
1822
+ // "usDiff": 128,
1823
+ // "testnet": false
1824
+ // }
1825
+ //
1826
+ const result = this.safeValue(response, 'result', {});
1827
+ const timestamp = this.safeInteger(result, 'timestamp');
1828
+ const nonce = this.safeInteger(result, 'change_id');
1829
+ const orderbook = this.parseOrderBook(result, market['symbol'], timestamp);
1830
+ orderbook['nonce'] = nonce;
1831
+ return orderbook;
1832
+ }
1833
+ parseOrderStatus(status) {
1834
+ const statuses = {
1835
+ 'open': 'open',
1836
+ 'cancelled': 'canceled',
1837
+ 'filled': 'closed',
1838
+ 'rejected': 'rejected',
1839
+ 'untriggered': 'open',
1840
+ };
1841
+ return this.safeString(statuses, status, status);
1842
+ }
1843
+ parseTimeInForce(timeInForce) {
1844
+ const timeInForces = {
1845
+ 'good_til_cancelled': 'GTC',
1846
+ 'fill_or_kill': 'FOK',
1847
+ 'immediate_or_cancel': 'IOC',
1848
+ };
1849
+ return this.safeString(timeInForces, timeInForce, timeInForce);
1850
+ }
1851
+ parseOrderType(orderType) {
1852
+ const orderTypes = {
1853
+ 'stop_limit': 'limit',
1854
+ 'take_limit': 'limit',
1855
+ 'stop_market': 'market',
1856
+ 'take_market': 'market',
1857
+ };
1858
+ return this.safeString(orderTypes, orderType, orderType);
1859
+ }
1860
+ parseOrder(order, market = undefined) {
1861
+ //
1862
+ // createOrder
1863
+ //
1864
+ // {
1865
+ // "time_in_force": "good_til_cancelled",
1866
+ // "reduce_only": false,
1867
+ // "profit_loss": 0,
1868
+ // "price": "market_price",
1869
+ // "post_only": false,
1870
+ // "order_type": "market",
1871
+ // "order_state": "filled",
1872
+ // "order_id": "ETH-349249",
1873
+ // "max_show": 40,
1874
+ // "last_update_timestamp": 1550657341322,
1875
+ // "label": "market0000234",
1876
+ // "is_liquidation": false,
1877
+ // "instrument_name": "ETH-PERPETUAL",
1878
+ // "filled_amount": 40,
1879
+ // "direction": "buy",
1880
+ // "creation_timestamp": 1550657341322,
1881
+ // "commission": 0.000139,
1882
+ // "average_price": 143.81,
1883
+ // "api": true,
1884
+ // "amount": 40,
1885
+ // "trades": [], // injected by createOrder
1886
+ // }
1887
+ //
1888
+ const marketId = this.safeString(order, 'instrument_name');
1889
+ market = this.safeMarket(marketId, market);
1890
+ const timestamp = this.safeInteger(order, 'creation_timestamp');
1891
+ const lastUpdate = this.safeInteger(order, 'last_update_timestamp');
1892
+ const id = this.safeString(order, 'order_id');
1893
+ let priceString = this.safeString(order, 'price');
1894
+ if (priceString === 'market_price') {
1895
+ priceString = undefined;
1896
+ }
1897
+ const averageString = this.safeString(order, 'average_price');
1898
+ // Inverse contracts amount is in USD which in ccxt is the cost
1899
+ // For options and Linear contracts amount is in corresponding cryptocurrency, e.g., BTC or ETH
1900
+ const filledString = this.safeString(order, 'filled_amount');
1901
+ const amount = this.safeString(order, 'amount');
1902
+ let cost = Precise.stringMul(filledString, averageString);
1903
+ if (this.safeBool(market, 'inverse')) {
1904
+ if (averageString !== '0') {
1905
+ cost = Precise.stringDiv(amount, averageString);
1906
+ }
1907
+ }
1908
+ let lastTradeTimestamp = undefined;
1909
+ if (filledString !== undefined) {
1910
+ const isFilledPositive = Precise.stringGt(filledString, '0');
1911
+ if (isFilledPositive) {
1912
+ lastTradeTimestamp = lastUpdate;
1913
+ }
1914
+ }
1915
+ const status = this.parseOrderStatus(this.safeString(order, 'order_state'));
1916
+ const side = this.safeStringLower(order, 'direction');
1917
+ let feeCostString = this.safeString(order, 'commission');
1918
+ let fee = undefined;
1919
+ if (feeCostString !== undefined) {
1920
+ feeCostString = Precise.stringAbs(feeCostString);
1921
+ fee = {
1922
+ 'cost': feeCostString,
1923
+ 'currency': market['base'],
1924
+ };
1925
+ }
1926
+ const rawType = this.safeString(order, 'order_type');
1927
+ const type = this.parseOrderType(rawType);
1928
+ // injected in createOrder
1929
+ const trades = this.safeValue(order, 'trades');
1930
+ const timeInForce = this.parseTimeInForce(this.safeString(order, 'time_in_force'));
1931
+ const postOnly = this.safeValue(order, 'post_only');
1932
+ return this.safeOrder({
1933
+ 'info': order,
1934
+ 'id': id,
1935
+ 'clientOrderId': undefined,
1936
+ 'timestamp': timestamp,
1937
+ 'datetime': this.iso8601(timestamp),
1938
+ 'lastTradeTimestamp': lastTradeTimestamp,
1939
+ 'symbol': market['symbol'],
1940
+ 'type': type,
1941
+ 'timeInForce': timeInForce,
1942
+ 'postOnly': postOnly,
1943
+ 'side': side,
1944
+ 'price': priceString,
1945
+ 'triggerPrice': this.safeValue(order, 'stop_price'),
1946
+ 'amount': amount,
1947
+ 'cost': cost,
1948
+ 'average': averageString,
1949
+ 'filled': filledString,
1950
+ 'remaining': undefined,
1951
+ 'status': status,
1952
+ 'fee': fee,
1953
+ 'trades': trades,
1954
+ }, market);
1955
+ }
1956
+ /**
1957
+ * @method
1958
+ * @name deribit#fetchOrder
1959
+ * @description fetches information on an order made by the user
1960
+ * @see https://docs.deribit.com/#private-get_order_state
1961
+ * @param {string} id order id
1962
+ * @param {string} symbol unified symbol of the market the order was made in
1963
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1964
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1965
+ */
1966
+ async fetchOrder(id, symbol = undefined, params = {}) {
1967
+ await this.loadMarkets();
1968
+ const request = {
1969
+ 'order_id': id,
1970
+ };
1971
+ let market = undefined;
1972
+ if (symbol !== undefined) {
1973
+ market = this.market(symbol);
1974
+ }
1975
+ const response = await this.privateGetGetOrderState(this.extend(request, params));
1976
+ //
1977
+ // {
1978
+ // "jsonrpc": "2.0",
1979
+ // "id": 4316,
1980
+ // "result": {
1981
+ // "time_in_force": "good_til_cancelled",
1982
+ // "reduce_only": false,
1983
+ // "profit_loss": 0.051134,
1984
+ // "price": 118.94,
1985
+ // "post_only": false,
1986
+ // "order_type": "limit",
1987
+ // "order_state": "filled",
1988
+ // "order_id": "ETH-331562",
1989
+ // "max_show": 37,
1990
+ // "last_update_timestamp": 1550219810944,
1991
+ // "label": "",
1992
+ // "is_liquidation": false,
1993
+ // "instrument_name": "ETH-PERPETUAL",
1994
+ // "filled_amount": 37,
1995
+ // "direction": "sell",
1996
+ // "creation_timestamp": 1550219749176,
1997
+ // "commission": 0.000031,
1998
+ // "average_price": 118.94,
1999
+ // "api": false,
2000
+ // "amount": 37
2001
+ // }
2002
+ // }
2003
+ //
2004
+ const result = this.safeDict(response, 'result');
2005
+ return this.parseOrder(result, market);
2006
+ }
2007
+ /**
2008
+ * @method
2009
+ * @name deribit#createOrder
2010
+ * @description create a trade order
2011
+ * @see https://docs.deribit.com/#private-buy
2012
+ * @see https://docs.deribit.com/#private-sell
2013
+ * @param {string} symbol unified symbol of the market to create an order in
2014
+ * @param {string} type 'market' or 'limit'
2015
+ * @param {string} side 'buy' or 'sell'
2016
+ * @param {float} amount how much you want to trade in units of the base currency. For perpetual and inverse futures the amount is in USD units. For options it is in the underlying assets base currency.
2017
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2018
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2019
+ * @param {string} [params.trigger] the trigger type 'index_price', 'mark_price', or 'last_price', default is 'last_price'
2020
+ * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
2021
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2022
+ */
2023
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2024
+ await this.loadMarkets();
2025
+ const market = this.market(symbol);
2026
+ const request = {
2027
+ 'instrument_name': market['id'],
2028
+ 'amount': this.amountToPrecision(symbol, amount),
2029
+ 'type': type, // limit, stop_limit, market, stop_market, default is limit
2030
+ // 'label': 'string', // user-defined label for the order (maximum 64 characters)
2031
+ // 'price': this.priceToPrecision (symbol, 123.45), // only for limit and stop_limit orders
2032
+ // 'time_in_force' : 'good_til_cancelled', // fill_or_kill, immediate_or_cancel
2033
+ // 'max_show': 123.45, // max amount within an order to be shown to other customers, 0 for invisible order
2034
+ // 'post_only': false, // if the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below the spread.
2035
+ // 'reject_post_only': false, // if true the order is put to order book unmodified or request is rejected
2036
+ // 'reduce_only': false, // if true, the order is intended to only reduce a current position
2037
+ // 'stop_price': false, // stop price, required for stop_limit orders
2038
+ // 'trigger': 'index_price', // mark_price, last_price, required for stop_limit orders
2039
+ // 'advanced': 'usd', // 'implv', advanced option order type, options only
2040
+ };
2041
+ const trigger = this.safeString(params, 'trigger', 'last_price');
2042
+ const timeInForce = this.safeStringUpper(params, 'timeInForce');
2043
+ const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
2044
+ // only stop loss sell orders are allowed when price crossed from above
2045
+ const stopLossPrice = this.safeValue(params, 'stopLossPrice');
2046
+ // only take profit buy orders are allowed when price crossed from below
2047
+ const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
2048
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
2049
+ const isTrailingAmountOrder = trailingAmount !== undefined;
2050
+ const isStopLimit = type === 'stop_limit';
2051
+ const isStopMarket = type === 'stop_market';
2052
+ const isTakeLimit = type === 'take_limit';
2053
+ const isTakeMarket = type === 'take_market';
2054
+ const isStopLossOrder = isStopLimit || isStopMarket || (stopLossPrice !== undefined);
2055
+ const isTakeProfitOrder = isTakeLimit || isTakeMarket || (takeProfitPrice !== undefined);
2056
+ if (isStopLossOrder && isTakeProfitOrder) {
2057
+ throw new InvalidOrder(this.id + ' createOrder () only allows one of stopLossPrice or takeProfitPrice to be specified');
2058
+ }
2059
+ const isStopOrder = isStopLossOrder || isTakeProfitOrder;
2060
+ const isLimitOrder = (type === 'limit') || isStopLimit || isTakeLimit;
2061
+ const isMarketOrder = (type === 'market') || isStopMarket || isTakeMarket;
2062
+ const exchangeSpecificPostOnly = this.safeValue(params, 'post_only');
2063
+ const postOnly = this.isPostOnly(isMarketOrder, exchangeSpecificPostOnly, params);
2064
+ if (isLimitOrder) {
2065
+ request['type'] = 'limit';
2066
+ request['price'] = this.priceToPrecision(symbol, price);
2067
+ }
2068
+ else {
2069
+ request['type'] = 'market';
2070
+ }
2071
+ if (isTrailingAmountOrder) {
2072
+ request['trigger'] = trigger;
2073
+ request['type'] = 'trailing_stop';
2074
+ request['trigger_offset'] = this.parseToNumeric(trailingAmount);
2075
+ }
2076
+ else if (isStopOrder) {
2077
+ const triggerPrice = (stopLossPrice !== undefined) ? stopLossPrice : takeProfitPrice;
2078
+ request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
2079
+ request['trigger'] = trigger;
2080
+ if (isStopLossOrder) {
2081
+ if (isMarketOrder) {
2082
+ // stop_market (sell only)
2083
+ request['type'] = 'stop_market';
2084
+ }
2085
+ else {
2086
+ // stop_limit (sell only)
2087
+ request['type'] = 'stop_limit';
2088
+ }
2089
+ }
2090
+ else {
2091
+ if (isMarketOrder) {
2092
+ // take_market (buy only)
2093
+ request['type'] = 'take_market';
2094
+ }
2095
+ else {
2096
+ // take_limit (buy only)
2097
+ request['type'] = 'take_limit';
2098
+ }
2099
+ }
2100
+ }
2101
+ if (reduceOnly) {
2102
+ request['reduce_only'] = true;
2103
+ }
2104
+ if (postOnly) {
2105
+ request['post_only'] = true;
2106
+ request['reject_post_only'] = true;
2107
+ }
2108
+ if (timeInForce !== undefined) {
2109
+ if (timeInForce === 'GTC') {
2110
+ request['time_in_force'] = 'good_til_cancelled';
2111
+ }
2112
+ if (timeInForce === 'IOC') {
2113
+ request['time_in_force'] = 'immediate_or_cancel';
2114
+ }
2115
+ if (timeInForce === 'FOK') {
2116
+ request['time_in_force'] = 'fill_or_kill';
2117
+ }
2118
+ }
2119
+ params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly', 'trailingAmount']);
2120
+ let response = undefined;
2121
+ if (this.capitalize(side) === 'Buy') {
2122
+ response = await this.privateGetBuy(this.extend(request, params));
2123
+ }
2124
+ else {
2125
+ response = await this.privateGetSell(this.extend(request, params));
2126
+ }
2127
+ //
2128
+ // {
2129
+ // "jsonrpc": "2.0",
2130
+ // "id": 5275,
2131
+ // "result": {
2132
+ // "trades": [
2133
+ // {
2134
+ // "trade_seq": 14151,
2135
+ // "trade_id": "ETH-37435",
2136
+ // "timestamp": 1550657341322,
2137
+ // "tick_direction": 2,
2138
+ // "state": "closed",
2139
+ // "self_trade": false,
2140
+ // "price": 143.81,
2141
+ // "order_type": "market",
2142
+ // "order_id": "ETH-349249",
2143
+ // "matching_id": null,
2144
+ // "liquidity": "T",
2145
+ // "label": "market0000234",
2146
+ // "instrument_name": "ETH-PERPETUAL",
2147
+ // "index_price": 143.73,
2148
+ // "fee_currency": "ETH",
2149
+ // "fee": 0.000139,
2150
+ // "direction": "buy",
2151
+ // "amount": 40
2152
+ // }
2153
+ // ],
2154
+ // "order": {
2155
+ // "time_in_force": "good_til_cancelled",
2156
+ // "reduce_only": false,
2157
+ // "profit_loss": 0,
2158
+ // "price": "market_price",
2159
+ // "post_only": false,
2160
+ // "order_type": "market",
2161
+ // "order_state": "filled",
2162
+ // "order_id": "ETH-349249",
2163
+ // "max_show": 40,
2164
+ // "last_update_timestamp": 1550657341322,
2165
+ // "label": "market0000234",
2166
+ // "is_liquidation": false,
2167
+ // "instrument_name": "ETH-PERPETUAL",
2168
+ // "filled_amount": 40,
2169
+ // "direction": "buy",
2170
+ // "creation_timestamp": 1550657341322,
2171
+ // "commission": 0.000139,
2172
+ // "average_price": 143.81,
2173
+ // "api": true,
2174
+ // "amount": 40
2175
+ // }
2176
+ // }
2177
+ // }
2178
+ //
2179
+ const result = this.safeValue(response, 'result', {});
2180
+ const order = this.safeValue(result, 'order');
2181
+ const trades = this.safeValue(result, 'trades', []);
2182
+ order['trades'] = trades;
2183
+ return this.parseOrder(order, market);
2184
+ }
2185
+ /**
2186
+ * @method
2187
+ * @name deribit#editOrder
2188
+ * @description edit a trade order
2189
+ * @see https://docs.deribit.com/#private-edit
2190
+ * @param {string} id edit order id
2191
+ * @param {string} [symbol] unified symbol of the market to edit an order in
2192
+ * @param {string} [type] 'market' or 'limit'
2193
+ * @param {string} [side] 'buy' or 'sell'
2194
+ * @param {float} amount how much you want to trade in units of the base currency. For perpetual and inverse futures the amount is in USD units. For options it is in the underlying assets base currency.
2195
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2196
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2197
+ * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
2198
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2199
+ */
2200
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
2201
+ if (amount === undefined) {
2202
+ throw new ArgumentsRequired(this.id + ' editOrder() requires an amount argument');
2203
+ }
2204
+ await this.loadMarkets();
2205
+ const request = {
2206
+ 'order_id': id,
2207
+ 'amount': this.amountToPrecision(symbol, amount),
2208
+ // 'post_only': false, // if the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below the spread.
2209
+ // 'reject_post_only': false, // if true the order is put to order book unmodified or request is rejected
2210
+ // 'reduce_only': false, // if true, the order is intended to only reduce a current position
2211
+ // 'stop_price': false, // stop price, required for stop_limit orders
2212
+ // 'advanced': 'usd', // 'implv', advanced option order type, options only
2213
+ };
2214
+ if (price !== undefined) {
2215
+ request['price'] = this.priceToPrecision(symbol, price);
2216
+ }
2217
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
2218
+ const isTrailingAmountOrder = trailingAmount !== undefined;
2219
+ if (isTrailingAmountOrder) {
2220
+ request['trigger_offset'] = this.parseToNumeric(trailingAmount);
2221
+ params = this.omit(params, 'trigger_offset');
2222
+ }
2223
+ const response = await this.privateGetEdit(this.extend(request, params));
2224
+ const result = this.safeValue(response, 'result', {});
2225
+ const order = this.safeValue(result, 'order');
2226
+ const trades = this.safeValue(result, 'trades', []);
2227
+ order['trades'] = trades;
2228
+ return this.parseOrder(order);
2229
+ }
2230
+ /**
2231
+ * @method
2232
+ * @name deribit#cancelOrder
2233
+ * @description cancels an open order
2234
+ * @see https://docs.deribit.com/#private-cancel
2235
+ * @param {string} id order id
2236
+ * @param {string} symbol not used by deribit cancelOrder ()
2237
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2238
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2239
+ */
2240
+ async cancelOrder(id, symbol = undefined, params = {}) {
2241
+ await this.loadMarkets();
2242
+ const request = {
2243
+ 'order_id': id,
2244
+ };
2245
+ const response = await this.privateGetCancel(this.extend(request, params));
2246
+ const result = this.safeDict(response, 'result', {});
2247
+ return this.parseOrder(result);
2248
+ }
2249
+ /**
2250
+ * @method
2251
+ * @name deribit#cancelAllOrders
2252
+ * @description cancel all open orders
2253
+ * @see https://docs.deribit.com/#private-cancel_all
2254
+ * @see https://docs.deribit.com/#private-cancel_all_by_instrument
2255
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2256
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2257
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2258
+ */
2259
+ async cancelAllOrders(symbol = undefined, params = {}) {
2260
+ await this.loadMarkets();
2261
+ const request = {};
2262
+ let response = undefined;
2263
+ if (symbol === undefined) {
2264
+ response = await this.privateGetCancelAll(this.extend(request, params));
2265
+ }
2266
+ else {
2267
+ const market = this.market(symbol);
2268
+ request['instrument_name'] = market['id'];
2269
+ response = await this.privateGetCancelAllByInstrument(this.extend(request, params));
2270
+ }
2271
+ //
2272
+ // {
2273
+ // jsonrpc: '2.0',
2274
+ // result: '1',
2275
+ // usIn: '1720508354127369',
2276
+ // usOut: '1720508354133603',
2277
+ // usDiff: '6234',
2278
+ // testnet: true
2279
+ // }
2280
+ //
2281
+ return [
2282
+ this.safeOrder({
2283
+ 'info': response,
2284
+ }),
2285
+ ];
2286
+ }
2287
+ /**
2288
+ * @method
2289
+ * @name deribit#fetchOpenOrders
2290
+ * @description fetch all unfilled currently open orders
2291
+ * @see https://docs.deribit.com/#private-get_open_orders_by_currency
2292
+ * @see https://docs.deribit.com/#private-get_open_orders_by_instrument
2293
+ * @param {string} symbol unified market symbol
2294
+ * @param {int} [since] the earliest time in ms to fetch open orders for
2295
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
2296
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2297
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2298
+ */
2299
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2300
+ await this.loadMarkets();
2301
+ const request = {};
2302
+ let market = undefined;
2303
+ let response = undefined;
2304
+ if (symbol === undefined) {
2305
+ const code = this.codeFromOptions('fetchOpenOrders', params);
2306
+ const currency = this.currency(code);
2307
+ request['currency'] = currency['id'];
2308
+ response = await this.privateGetGetOpenOrdersByCurrency(this.extend(request, params));
2309
+ }
2310
+ else {
2311
+ market = this.market(symbol);
2312
+ request['instrument_name'] = market['id'];
2313
+ response = await this.privateGetGetOpenOrdersByInstrument(this.extend(request, params));
2314
+ }
2315
+ const result = this.safeList(response, 'result', []);
2316
+ return this.parseOrders(result, market, since, limit);
2317
+ }
2318
+ /**
2319
+ * @method
2320
+ * @name deribit#fetchClosedOrders
2321
+ * @description fetches information on multiple closed orders made by the user
2322
+ * @see https://docs.deribit.com/#private-get_order_history_by_currency
2323
+ * @see https://docs.deribit.com/#private-get_order_history_by_instrument
2324
+ * @param {string} symbol unified market symbol of the market orders were made in
2325
+ * @param {int} [since] the earliest time in ms to fetch orders for
2326
+ * @param {int} [limit] the maximum number of order structures to retrieve
2327
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2328
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2329
+ */
2330
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2331
+ await this.loadMarkets();
2332
+ const request = {};
2333
+ let market = undefined;
2334
+ let response = undefined;
2335
+ if (symbol === undefined) {
2336
+ const code = this.codeFromOptions('fetchClosedOrders', params);
2337
+ const currency = this.currency(code);
2338
+ request['currency'] = currency['id'];
2339
+ response = await this.privateGetGetOrderHistoryByCurrency(this.extend(request, params));
2340
+ }
2341
+ else {
2342
+ market = this.market(symbol);
2343
+ request['instrument_name'] = market['id'];
2344
+ response = await this.privateGetGetOrderHistoryByInstrument(this.extend(request, params));
2345
+ }
2346
+ const result = this.safeList(response, 'result', []);
2347
+ return this.parseOrders(result, market, since, limit);
2348
+ }
2349
+ /**
2350
+ * @method
2351
+ * @name deribit#fetchOrderTrades
2352
+ * @description fetch all the trades made from a single order
2353
+ * @see https://docs.deribit.com/#private-get_user_trades_by_order
2354
+ * @param {string} id order id
2355
+ * @param {string} symbol unified market symbol
2356
+ * @param {int} [since] the earliest time in ms to fetch trades for
2357
+ * @param {int} [limit] the maximum number of trades to retrieve
2358
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2359
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2360
+ */
2361
+ async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2362
+ await this.loadMarkets();
2363
+ const request = {
2364
+ 'order_id': id,
2365
+ };
2366
+ const response = await this.privateGetGetUserTradesByOrder(this.extend(request, params));
2367
+ //
2368
+ // {
2369
+ // "jsonrpc": "2.0",
2370
+ // "id": 9367,
2371
+ // "result": {
2372
+ // "trades": [
2373
+ // {
2374
+ // "trade_seq": 3,
2375
+ // "trade_id": "ETH-34066",
2376
+ // "timestamp": 1550219814585,
2377
+ // "tick_direction": 1,
2378
+ // "state": "open",
2379
+ // "self_trade": false,
2380
+ // "reduce_only": false,
2381
+ // "price": 0.04,
2382
+ // "post_only": false,
2383
+ // "order_type": "limit",
2384
+ // "order_id": "ETH-334607",
2385
+ // "matching_id": null,
2386
+ // "liquidity": "M",
2387
+ // "iv": 56.83,
2388
+ // "instrument_name": "ETH-22FEB19-120-C",
2389
+ // "index_price": 121.37,
2390
+ // "fee_currency": "ETH",
2391
+ // "fee": 0.0011,
2392
+ // "direction": "buy",
2393
+ // "amount": 11
2394
+ // },
2395
+ // ],
2396
+ // "has_more": true
2397
+ // }
2398
+ // }
2399
+ //
2400
+ const result = this.safeList(response, 'result', []);
2401
+ return this.parseTrades(result, undefined, since, limit);
2402
+ }
2403
+ /**
2404
+ * @method
2405
+ * @name deribit#fetchMyTrades
2406
+ * @description fetch all trades made by the user
2407
+ * @see https://docs.deribit.com/#private-get_user_trades_by_currency
2408
+ * @see https://docs.deribit.com/#private-get_user_trades_by_currency_and_time
2409
+ * @see https://docs.deribit.com/#private-get_user_trades_by_instrument
2410
+ * @see https://docs.deribit.com/#private-get_user_trades_by_instrument_and_time
2411
+ * @param {string} symbol unified market symbol
2412
+ * @param {int} [since] the earliest time in ms to fetch trades for
2413
+ * @param {int} [limit] the maximum number of trades structures to retrieve
2414
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2415
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2416
+ */
2417
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2418
+ await this.loadMarkets();
2419
+ const request = {
2420
+ 'include_old': true,
2421
+ };
2422
+ let market = undefined;
2423
+ if (limit !== undefined) {
2424
+ request['count'] = limit; // default 10
2425
+ }
2426
+ let response = undefined;
2427
+ if (symbol === undefined) {
2428
+ const code = this.codeFromOptions('fetchMyTrades', params);
2429
+ const currency = this.currency(code);
2430
+ request['currency'] = currency['id'];
2431
+ if (since === undefined) {
2432
+ response = await this.privateGetGetUserTradesByCurrency(this.extend(request, params));
2433
+ }
2434
+ else {
2435
+ request['start_timestamp'] = since;
2436
+ response = await this.privateGetGetUserTradesByCurrencyAndTime(this.extend(request, params));
2437
+ }
2438
+ }
2439
+ else {
2440
+ market = this.market(symbol);
2441
+ request['instrument_name'] = market['id'];
2442
+ if (since === undefined) {
2443
+ response = await this.privateGetGetUserTradesByInstrument(this.extend(request, params));
2444
+ }
2445
+ else {
2446
+ request['start_timestamp'] = since;
2447
+ response = await this.privateGetGetUserTradesByInstrumentAndTime(this.extend(request, params));
2448
+ }
2449
+ }
2450
+ //
2451
+ // {
2452
+ // "jsonrpc": "2.0",
2453
+ // "id": 9367,
2454
+ // "result": {
2455
+ // "trades": [
2456
+ // {
2457
+ // "trade_seq": 3,
2458
+ // "trade_id": "ETH-34066",
2459
+ // "timestamp": 1550219814585,
2460
+ // "tick_direction": 1,
2461
+ // "state": "open",
2462
+ // "self_trade": false,
2463
+ // "reduce_only": false,
2464
+ // "price": 0.04,
2465
+ // "post_only": false,
2466
+ // "order_type": "limit",
2467
+ // "order_id": "ETH-334607",
2468
+ // "matching_id": null,
2469
+ // "liquidity": "M",
2470
+ // "iv": 56.83,
2471
+ // "instrument_name": "ETH-22FEB19-120-C",
2472
+ // "index_price": 121.37,
2473
+ // "fee_currency": "ETH",
2474
+ // "fee": 0.0011,
2475
+ // "direction": "buy",
2476
+ // "amount": 11
2477
+ // },
2478
+ // ],
2479
+ // "has_more": true
2480
+ // }
2481
+ // }
2482
+ //
2483
+ const result = this.safeValue(response, 'result', {});
2484
+ const trades = this.safeList(result, 'trades', []);
2485
+ return this.parseTrades(trades, market, since, limit);
2486
+ }
2487
+ /**
2488
+ * @method
2489
+ * @name deribit#fetchDeposits
2490
+ * @description fetch all deposits made to an account
2491
+ * @see https://docs.deribit.com/#private-get_deposits
2492
+ * @param {string} code unified currency code
2493
+ * @param {int} [since] the earliest time in ms to fetch deposits for
2494
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
2495
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2496
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2497
+ */
2498
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
2499
+ if (code === undefined) {
2500
+ throw new ArgumentsRequired(this.id + ' fetchDeposits() requires a currency code argument');
2501
+ }
2502
+ await this.loadMarkets();
2503
+ const currency = this.currency(code);
2504
+ const request = {
2505
+ 'currency': currency['id'],
2506
+ };
2507
+ if (limit !== undefined) {
2508
+ request['count'] = limit;
2509
+ }
2510
+ const response = await this.privateGetGetDeposits(this.extend(request, params));
2511
+ //
2512
+ // {
2513
+ // "jsonrpc": "2.0",
2514
+ // "id": 5611,
2515
+ // "result": {
2516
+ // "count": 1,
2517
+ // "data": [
2518
+ // {
2519
+ // "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax",
2520
+ // "amount": 5,
2521
+ // "currency": "BTC",
2522
+ // "received_timestamp": 1549295017670,
2523
+ // "state": "completed",
2524
+ // "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda",
2525
+ // "updated_timestamp": 1549295130159
2526
+ // }
2527
+ // ]
2528
+ // }
2529
+ // }
2530
+ //
2531
+ const result = this.safeValue(response, 'result', {});
2532
+ const data = this.safeList(result, 'data', []);
2533
+ return this.parseTransactions(data, currency, since, limit, params);
2534
+ }
2535
+ /**
2536
+ * @method
2537
+ * @name deribit#fetchWithdrawals
2538
+ * @description fetch all withdrawals made from an account
2539
+ * @see https://docs.deribit.com/#private-get_withdrawals
2540
+ * @param {string} code unified currency code
2541
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
2542
+ * @param {int} [limit] the maximum number of withdrawals structures to retrieve
2543
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2544
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2545
+ */
2546
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2547
+ if (code === undefined) {
2548
+ throw new ArgumentsRequired(this.id + ' fetchWithdrawals() requires a currency code argument');
2549
+ }
2550
+ await this.loadMarkets();
2551
+ const currency = this.currency(code);
2552
+ const request = {
2553
+ 'currency': currency['id'],
2554
+ };
2555
+ if (limit !== undefined) {
2556
+ request['count'] = limit;
2557
+ }
2558
+ const response = await this.privateGetGetWithdrawals(this.extend(request, params));
2559
+ //
2560
+ // {
2561
+ // "jsonrpc": "2.0",
2562
+ // "id": 2745,
2563
+ // "result": {
2564
+ // "count": 1,
2565
+ // "data": [
2566
+ // {
2567
+ // "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz",
2568
+ // "amount": 0.5,
2569
+ // "confirmed_timestamp": null,
2570
+ // "created_timestamp": 1550571443070,
2571
+ // "currency": "BTC",
2572
+ // "fee": 0.0001,
2573
+ // "id": 1,
2574
+ // "priority": 0.15,
2575
+ // "state": "unconfirmed",
2576
+ // "transaction_id": null,
2577
+ // "updated_timestamp": 1550571443070
2578
+ // }
2579
+ // ]
2580
+ // }
2581
+ // }
2582
+ //
2583
+ const result = this.safeValue(response, 'result', {});
2584
+ const data = this.safeList(result, 'data', []);
2585
+ return this.parseTransactions(data, currency, since, limit, params);
2586
+ }
2587
+ parseTransactionStatus(status) {
2588
+ const statuses = {
2589
+ 'completed': 'ok',
2590
+ 'unconfirmed': 'pending',
2591
+ };
2592
+ return this.safeString(statuses, status, status);
2593
+ }
2594
+ parseTransaction(transaction, currency = undefined) {
2595
+ //
2596
+ // fetchWithdrawals
2597
+ //
2598
+ // {
2599
+ // "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz",
2600
+ // "amount": 0.5,
2601
+ // "confirmed_timestamp": null,
2602
+ // "created_timestamp": 1550571443070,
2603
+ // "currency": "BTC",
2604
+ // "fee": 0.0001,
2605
+ // "id": 1,
2606
+ // "priority": 0.15,
2607
+ // "state": "unconfirmed",
2608
+ // "transaction_id": null,
2609
+ // "updated_timestamp": 1550571443070
2610
+ // }
2611
+ //
2612
+ // fetchDeposits
2613
+ //
2614
+ // {
2615
+ // "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax",
2616
+ // "amount": 5,
2617
+ // "currency": "BTC",
2618
+ // "received_timestamp": 1549295017670,
2619
+ // "state": "completed",
2620
+ // "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda",
2621
+ // "updated_timestamp": 1549295130159
2622
+ // }
2623
+ //
2624
+ const currencyId = this.safeString(transaction, 'currency');
2625
+ const code = this.safeCurrencyCode(currencyId, currency);
2626
+ const timestamp = this.safeInteger2(transaction, 'created_timestamp', 'received_timestamp');
2627
+ const updated = this.safeInteger(transaction, 'updated_timestamp');
2628
+ const status = this.parseTransactionStatus(this.safeString(transaction, 'state'));
2629
+ const address = this.safeString(transaction, 'address');
2630
+ const feeCost = this.safeNumber(transaction, 'fee');
2631
+ let type = 'deposit';
2632
+ let fee = undefined;
2633
+ if (feeCost !== undefined) {
2634
+ type = 'withdrawal';
2635
+ fee = {
2636
+ 'cost': feeCost,
2637
+ 'currency': code,
2638
+ };
2639
+ }
2640
+ return {
2641
+ 'info': transaction,
2642
+ 'id': this.safeString(transaction, 'id'),
2643
+ 'txid': this.safeString(transaction, 'transaction_id'),
2644
+ 'timestamp': timestamp,
2645
+ 'datetime': this.iso8601(timestamp),
2646
+ 'address': address,
2647
+ 'addressTo': address,
2648
+ 'addressFrom': undefined,
2649
+ 'tag': undefined,
2650
+ 'tagTo': undefined,
2651
+ 'tagFrom': undefined,
2652
+ 'type': type,
2653
+ 'amount': this.safeNumber(transaction, 'amount'),
2654
+ 'currency': code,
2655
+ 'status': status,
2656
+ 'updated': updated,
2657
+ 'network': undefined,
2658
+ 'internal': undefined,
2659
+ 'comment': undefined,
2660
+ 'fee': fee,
2661
+ };
2662
+ }
2663
+ parsePosition(position, market = undefined) {
2664
+ //
2665
+ // {
2666
+ // "jsonrpc": "2.0",
2667
+ // "id": 404,
2668
+ // "result": {
2669
+ // "average_price": 0,
2670
+ // "delta": 0,
2671
+ // "direction": "buy",
2672
+ // "estimated_liquidation_price": 0,
2673
+ // "floating_profit_loss": 0,
2674
+ // "index_price": 3555.86,
2675
+ // "initial_margin": 0,
2676
+ // "instrument_name": "BTC-PERPETUAL",
2677
+ // "leverage": 100,
2678
+ // "kind": "future",
2679
+ // "maintenance_margin": 0,
2680
+ // "mark_price": 3556.62,
2681
+ // "open_orders_margin": 0.000165889,
2682
+ // "realized_profit_loss": 0,
2683
+ // "settlement_price": 3555.44,
2684
+ // "size": 0,
2685
+ // "size_currency": 0,
2686
+ // "total_profit_loss": 0
2687
+ // }
2688
+ // }
2689
+ //
2690
+ const contract = this.safeString(position, 'instrument_name');
2691
+ market = this.safeMarket(contract, market);
2692
+ let side = this.safeString(position, 'direction');
2693
+ side = (side === 'buy') ? 'long' : 'short';
2694
+ const unrealizedPnl = this.safeString(position, 'floating_profit_loss');
2695
+ const initialMarginString = this.safeString(position, 'initial_margin');
2696
+ const notionalString = this.safeString(position, 'size_currency');
2697
+ const notionalStringAbs = Precise.stringAbs(notionalString);
2698
+ const maintenanceMarginString = this.safeString(position, 'maintenance_margin');
2699
+ return this.safePosition({
2700
+ 'info': position,
2701
+ 'id': undefined,
2702
+ 'symbol': this.safeString(market, 'symbol'),
2703
+ 'timestamp': undefined,
2704
+ 'datetime': undefined,
2705
+ 'lastUpdateTimestamp': undefined,
2706
+ 'initialMargin': this.parseNumber(initialMarginString),
2707
+ 'initialMarginPercentage': this.parseNumber(Precise.stringMul(Precise.stringDiv(initialMarginString, notionalStringAbs), '100')),
2708
+ 'maintenanceMargin': this.parseNumber(maintenanceMarginString),
2709
+ 'maintenanceMarginPercentage': this.parseNumber(Precise.stringMul(Precise.stringDiv(maintenanceMarginString, notionalStringAbs), '100')),
2710
+ 'entryPrice': this.safeNumber(position, 'average_price'),
2711
+ 'notional': this.parseNumber(notionalStringAbs),
2712
+ 'leverage': this.safeInteger(position, 'leverage'),
2713
+ 'unrealizedPnl': this.parseNumber(unrealizedPnl),
2714
+ 'contracts': undefined,
2715
+ 'contractSize': this.safeNumber(market, 'contractSize'),
2716
+ 'marginRatio': undefined,
2717
+ 'liquidationPrice': this.safeNumber(position, 'estimated_liquidation_price'),
2718
+ 'markPrice': this.safeNumber(position, 'mark_price'),
2719
+ 'lastPrice': undefined,
2720
+ 'collateral': undefined,
2721
+ 'marginMode': undefined,
2722
+ 'side': side,
2723
+ 'percentage': undefined,
2724
+ 'hedged': undefined,
2725
+ 'stopLossPrice': undefined,
2726
+ 'takeProfitPrice': undefined,
2727
+ });
2728
+ }
2729
+ /**
2730
+ * @method
2731
+ * @name deribit#fetchPosition
2732
+ * @description fetch data on a single open contract trade position
2733
+ * @see https://docs.deribit.com/#private-get_position
2734
+ * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
2735
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2736
+ * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2737
+ */
2738
+ async fetchPosition(symbol, params = {}) {
2739
+ await this.loadMarkets();
2740
+ const market = this.market(symbol);
2741
+ const request = {
2742
+ 'instrument_name': market['id'],
2743
+ };
2744
+ const response = await this.privateGetGetPosition(this.extend(request, params));
2745
+ //
2746
+ // {
2747
+ // "jsonrpc": "2.0",
2748
+ // "id": 404,
2749
+ // "result": {
2750
+ // "average_price": 0,
2751
+ // "delta": 0,
2752
+ // "direction": "buy",
2753
+ // "estimated_liquidation_price": 0,
2754
+ // "floating_profit_loss": 0,
2755
+ // "index_price": 3555.86,
2756
+ // "initial_margin": 0,
2757
+ // "instrument_name": "BTC-PERPETUAL",
2758
+ // "leverage": 100,
2759
+ // "kind": "future",
2760
+ // "maintenance_margin": 0,
2761
+ // "mark_price": 3556.62,
2762
+ // "open_orders_margin": 0.000165889,
2763
+ // "realized_profit_loss": 0,
2764
+ // "settlement_price": 3555.44,
2765
+ // "size": 0,
2766
+ // "size_currency": 0,
2767
+ // "total_profit_loss": 0
2768
+ // }
2769
+ // }
2770
+ //
2771
+ const result = this.safeDict(response, 'result');
2772
+ return this.parsePosition(result);
2773
+ }
2774
+ /**
2775
+ * @method
2776
+ * @name deribit#fetchPositions
2777
+ * @description fetch all open positions
2778
+ * @see https://docs.deribit.com/#private-get_positions
2779
+ * @param {string[]|undefined} symbols list of unified market symbols
2780
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2781
+ * @param {string} [params.currency] currency code filter for positions
2782
+ * @param {string} [params.kind] market type filter for positions 'future', 'option', 'spot', 'future_combo' or 'option_combo'
2783
+ * @param {int} [params.subaccount_id] the user id for the subaccount
2784
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2785
+ */
2786
+ async fetchPositions(symbols = undefined, params = {}) {
2787
+ await this.loadMarkets();
2788
+ const code = this.safeString(params, 'currency');
2789
+ const request = {};
2790
+ if (code !== undefined) {
2791
+ params = this.omit(params, 'currency');
2792
+ const currency = this.currency(code);
2793
+ request['currency'] = currency['id'];
2794
+ }
2795
+ const response = await this.privateGetGetPositions(this.extend(request, params));
2796
+ //
2797
+ // {
2798
+ // "jsonrpc": "2.0",
2799
+ // "id": 2236,
2800
+ // "result": [
2801
+ // {
2802
+ // "average_price": 7440.18,
2803
+ // "delta": 0.006687487,
2804
+ // "direction": "buy",
2805
+ // "estimated_liquidation_price": 1.74,
2806
+ // "floating_profit_loss": 0,
2807
+ // "index_price": 7466.79,
2808
+ // "initial_margin": 0.000197283,
2809
+ // "instrument_name": "BTC-PERPETUAL",
2810
+ // "kind": "future",
2811
+ // "leverage": 34,
2812
+ // "maintenance_margin": 0.000143783,
2813
+ // "mark_price": 7476.65,
2814
+ // "open_orders_margin": 0.000197288,
2815
+ // "realized_funding": -1e-8,
2816
+ // "realized_profit_loss": -9e-9,
2817
+ // "settlement_price": 7476.65,
2818
+ // "size": 50,
2819
+ // "size_currency": 0.006687487,
2820
+ // "total_profit_loss": 0.000032781
2821
+ // },
2822
+ // ]
2823
+ // }
2824
+ //
2825
+ const result = this.safeList(response, 'result');
2826
+ return this.parsePositions(result, symbols);
2827
+ }
2828
+ /**
2829
+ * @method
2830
+ * @name deribit#fetchVolatilityHistory
2831
+ * @description fetch the historical volatility of an option market based on an underlying asset
2832
+ * @see https://docs.deribit.com/#public-get_historical_volatility
2833
+ * @param {string} code unified currency code
2834
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2835
+ * @returns {object[]} a list of [volatility history objects]{@link https://docs.ccxt.com/#/?id=volatility-structure}
2836
+ */
2837
+ async fetchVolatilityHistory(code, params = {}) {
2838
+ await this.loadMarkets();
2839
+ const currency = this.currency(code);
2840
+ const request = {
2841
+ 'currency': currency['id'],
2842
+ };
2843
+ const response = await this.publicGetGetHistoricalVolatility(this.extend(request, params));
2844
+ //
2845
+ // {
2846
+ // "jsonrpc": "2.0",
2847
+ // "result": [
2848
+ // [1640142000000,63.828320460740585],
2849
+ // [1640142000000,63.828320460740585],
2850
+ // [1640145600000,64.03821964123213]
2851
+ // ],
2852
+ // "usIn": 1641515379467734,
2853
+ // "usOut": 1641515379468095,
2854
+ // "usDiff": 361,
2855
+ // "testnet": false
2856
+ // }
2857
+ //
2858
+ return this.parseVolatilityHistory(response);
2859
+ }
2860
+ parseVolatilityHistory(volatility) {
2861
+ //
2862
+ // {
2863
+ // "jsonrpc": "2.0",
2864
+ // "result": [
2865
+ // [1640142000000,63.828320460740585],
2866
+ // [1640142000000,63.828320460740585],
2867
+ // [1640145600000,64.03821964123213]
2868
+ // ],
2869
+ // "usIn": 1641515379467734,
2870
+ // "usOut": 1641515379468095,
2871
+ // "usDiff": 361,
2872
+ // "testnet": false
2873
+ // }
2874
+ //
2875
+ const volatilityResult = this.safeValue(volatility, 'result', []);
2876
+ const result = [];
2877
+ for (let i = 0; i < volatilityResult.length; i++) {
2878
+ const timestamp = this.safeInteger(volatilityResult[i], 0);
2879
+ const volatilityObj = this.safeNumber(volatilityResult[i], 1);
2880
+ result.push({
2881
+ 'info': volatilityObj,
2882
+ 'timestamp': timestamp,
2883
+ 'datetime': this.iso8601(timestamp),
2884
+ 'volatility': volatilityObj,
2885
+ });
2886
+ }
2887
+ return result;
2888
+ }
2889
+ /**
2890
+ * @method
2891
+ * @name deribit#fetchTransfers
2892
+ * @description fetch a history of internal transfers made on an account
2893
+ * @see https://docs.deribit.com/#private-get_transfers
2894
+ * @param {string} code unified currency code of the currency transferred
2895
+ * @param {int} [since] the earliest time in ms to fetch transfers for
2896
+ * @param {int} [limit] the maximum number of transfers structures to retrieve
2897
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2898
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2899
+ */
2900
+ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
2901
+ if (code === undefined) {
2902
+ throw new ArgumentsRequired(this.id + ' fetchTransfers() requires a currency code argument');
2903
+ }
2904
+ await this.loadMarkets();
2905
+ const currency = this.currency(code);
2906
+ const request = {
2907
+ 'currency': currency['id'],
2908
+ };
2909
+ if (limit !== undefined) {
2910
+ request['count'] = limit;
2911
+ }
2912
+ const response = await this.privateGetGetTransfers(this.extend(request, params));
2913
+ //
2914
+ // {
2915
+ // "jsonrpc": "2.0",
2916
+ // "id": 7606,
2917
+ // "result": {
2918
+ // "count": 2,
2919
+ // "data": [
2920
+ // {
2921
+ // "amount": 0.2,
2922
+ // "created_timestamp": 1550579457727,
2923
+ // "currency": "BTC",
2924
+ // "direction": "payment",
2925
+ // "id": 2,
2926
+ // "other_side": "2MzyQc5Tkik61kJbEpJV5D5H9VfWHZK9Sgy",
2927
+ // "state": "prepared",
2928
+ // "type": "user",
2929
+ // "updated_timestamp": 1550579457727
2930
+ // },
2931
+ // {
2932
+ // "amount": 0.3,
2933
+ // "created_timestamp": 1550579255800,
2934
+ // "currency": "BTC",
2935
+ // "direction": "payment",
2936
+ // "id": 1,
2937
+ // "other_side": "new_user_1_1",
2938
+ // "state": "confirmed",
2939
+ // "type": "subaccount",
2940
+ // "updated_timestamp": 1550579255800
2941
+ // }
2942
+ // ]
2943
+ // }
2944
+ // }
2945
+ //
2946
+ const result = this.safeValue(response, 'result', {});
2947
+ const transfers = this.safeList(result, 'data', []);
2948
+ return this.parseTransfers(transfers, currency, since, limit, params);
2949
+ }
2950
+ /**
2951
+ * @method
2952
+ * @name deribit#transfer
2953
+ * @description transfer currency internally between wallets on the same account
2954
+ * @see https://docs.deribit.com/#private-submit_transfer_to_user
2955
+ * @see https://docs.deribit.com/#private-submit_transfer_to_subaccount
2956
+ * @param {string} code unified currency code
2957
+ * @param {float} amount amount to transfer
2958
+ * @param {string} fromAccount account to transfer from
2959
+ * @param {string} toAccount account to transfer to
2960
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2961
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2962
+ */
2963
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
2964
+ await this.loadMarkets();
2965
+ const currency = this.currency(code);
2966
+ const request = {
2967
+ 'amount': amount,
2968
+ 'currency': currency['id'],
2969
+ 'destination': toAccount,
2970
+ };
2971
+ let method = this.safeString(params, 'method');
2972
+ params = this.omit(params, 'method');
2973
+ if (method === undefined) {
2974
+ const transferOptions = this.safeValue(this.options, 'transfer', {});
2975
+ method = this.safeString(transferOptions, 'method', 'privateGetSubmitTransferToSubaccount');
2976
+ }
2977
+ let response = undefined;
2978
+ if (method === 'privateGetSubmitTransferToUser') {
2979
+ response = await this.privateGetSubmitTransferToUser(this.extend(request, params));
2980
+ }
2981
+ else {
2982
+ response = await this.privateGetSubmitTransferToSubaccount(this.extend(request, params));
2983
+ }
2984
+ //
2985
+ // {
2986
+ // "jsonrpc": "2.0",
2987
+ // "id": 9421,
2988
+ // "result": {
2989
+ // "updated_timestamp": 1550232862350,
2990
+ // "type": "user",
2991
+ // "state": "prepared",
2992
+ // "other_side": "0x4aa0753d798d668056920094d65321a8e8913e26",
2993
+ // "id": 3,
2994
+ // "direction": "payment",
2995
+ // "currency": "ETH",
2996
+ // "created_timestamp": 1550232862350,
2997
+ // "amount": 13.456
2998
+ // }
2999
+ // }
3000
+ //
3001
+ const result = this.safeDict(response, 'result', {});
3002
+ return this.parseTransfer(result, currency);
3003
+ }
3004
+ parseTransfer(transfer, currency = undefined) {
3005
+ //
3006
+ // {
3007
+ // "updated_timestamp": 1550232862350,
3008
+ // "type": "user",
3009
+ // "state": "prepared",
3010
+ // "other_side": "0x4aa0753d798d668056920094d65321a8e8913e26",
3011
+ // "id": 3,
3012
+ // "direction": "payment",
3013
+ // "currency": "ETH",
3014
+ // "created_timestamp": 1550232862350,
3015
+ // "amount": 13.456
3016
+ // }
3017
+ //
3018
+ const timestamp = this.safeTimestamp(transfer, 'created_timestamp');
3019
+ const status = this.safeString(transfer, 'state');
3020
+ const account = this.safeString(transfer, 'other_side');
3021
+ const direction = this.safeString(transfer, 'direction');
3022
+ const currencyId = this.safeString(transfer, 'currency');
3023
+ return {
3024
+ 'info': transfer,
3025
+ 'id': this.safeString(transfer, 'id'),
3026
+ 'status': this.parseTransferStatus(status),
3027
+ 'amount': this.safeNumber(transfer, 'amount'),
3028
+ 'currency': this.safeCurrencyCode(currencyId, currency),
3029
+ 'fromAccount': direction !== 'payment' ? account : undefined,
3030
+ 'toAccount': direction === 'payment' ? account : undefined,
3031
+ 'timestamp': timestamp,
3032
+ 'datetime': this.iso8601(timestamp),
3033
+ };
3034
+ }
3035
+ parseTransferStatus(status) {
3036
+ const statuses = {
3037
+ 'prepared': 'pending',
3038
+ 'confirmed': 'ok',
3039
+ 'cancelled': 'cancelled',
3040
+ 'waiting_for_admin': 'pending',
3041
+ };
3042
+ return this.safeString(statuses, status, status);
3043
+ }
3044
+ /**
3045
+ * @method
3046
+ * @name deribit#withdraw
3047
+ * @description make a withdrawal
3048
+ * @see https://docs.deribit.com/#private-withdraw
3049
+ * @param {string} code unified currency code
3050
+ * @param {float} amount the amount to withdraw
3051
+ * @param {string} address the address to withdraw to
3052
+ * @param {string} tag
3053
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3054
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3055
+ */
3056
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
3057
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
3058
+ this.checkAddress(address);
3059
+ await this.loadMarkets();
3060
+ const currency = this.currency(code);
3061
+ const request = {
3062
+ 'currency': currency['id'],
3063
+ 'address': address,
3064
+ 'amount': amount,
3065
+ // 'priority': 'high', // low, mid, high, very_high, extreme_high, insane
3066
+ // 'tfa': '123456', // if enabled
3067
+ };
3068
+ if (this.twofa !== undefined) {
3069
+ request['tfa'] = totp(this.twofa);
3070
+ }
3071
+ const response = await this.privateGetWithdraw(this.extend(request, params));
3072
+ return this.parseTransaction(response, currency);
3073
+ }
3074
+ parseDepositWithdrawFee(fee, currency = undefined) {
3075
+ //
3076
+ // {
3077
+ // "withdrawal_priorities": [],
3078
+ // "withdrawal_fee": 0.01457324,
3079
+ // "min_withdrawal_fee": 0.000001,
3080
+ // "min_confirmations": 1,
3081
+ // "fee_precision": 8,
3082
+ // "currency_long": "Solana",
3083
+ // "currency": "SOL",
3084
+ // "coin_type": "SOL"
3085
+ // }
3086
+ //
3087
+ return {
3088
+ 'info': fee,
3089
+ 'withdraw': {
3090
+ 'fee': this.safeNumber(fee, 'withdrawal_fee'),
3091
+ 'percentage': false,
3092
+ },
3093
+ 'deposit': {
3094
+ 'fee': undefined,
3095
+ 'percentage': undefined,
3096
+ },
3097
+ 'networks': {},
3098
+ };
3099
+ }
3100
+ /**
3101
+ * @method
3102
+ * @name deribit#fetchDepositWithdrawFees
3103
+ * @description fetch deposit and withdraw fees
3104
+ * @see https://docs.deribit.com/#public-get_currencies
3105
+ * @param {string[]|undefined} codes list of unified currency codes
3106
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3107
+ * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
3108
+ */
3109
+ async fetchDepositWithdrawFees(codes = undefined, params = {}) {
3110
+ await this.loadMarkets();
3111
+ const response = await this.publicGetGetCurrencies(params);
3112
+ //
3113
+ // {
3114
+ // "jsonrpc": "2.0",
3115
+ // "result": [
3116
+ // {
3117
+ // "withdrawal_priorities": [],
3118
+ // "withdrawal_fee": 0.01457324,
3119
+ // "min_withdrawal_fee": 0.000001,
3120
+ // "min_confirmations": 1,
3121
+ // "fee_precision": 8,
3122
+ // "currency_long": "Solana",
3123
+ // "currency": "SOL",
3124
+ // "coin_type": "SOL"
3125
+ // },
3126
+ // ...
3127
+ // ],
3128
+ // "usIn": 1688652701456124,
3129
+ // "usOut": 1688652701456390,
3130
+ // "usDiff": 266,
3131
+ // "testnet": true
3132
+ // }
3133
+ //
3134
+ const data = this.safeList(response, 'result', []);
3135
+ return this.parseDepositWithdrawFees(data, codes, 'currency');
3136
+ }
3137
+ /**
3138
+ * @method
3139
+ * @name deribit#fetchFundingRate
3140
+ * @description fetch the current funding rate
3141
+ * @see https://docs.deribit.com/#public-get_funding_rate_value
3142
+ * @param {string} symbol unified market symbol
3143
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3144
+ * @param {int} [params.start_timestamp] fetch funding rate starting from this timestamp
3145
+ * @param {int} [params.end_timestamp] fetch funding rate ending at this timestamp
3146
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3147
+ */
3148
+ async fetchFundingRate(symbol, params = {}) {
3149
+ await this.loadMarkets();
3150
+ const market = this.market(symbol);
3151
+ const time = this.milliseconds();
3152
+ const request = {
3153
+ 'instrument_name': market['id'],
3154
+ 'start_timestamp': time - (8 * 60 * 60 * 1000),
3155
+ 'end_timestamp': time,
3156
+ };
3157
+ const response = await this.publicGetGetFundingRateValue(this.extend(request, params));
3158
+ //
3159
+ // {
3160
+ // "jsonrpc":"2.0",
3161
+ // "result":"0",
3162
+ // "usIn":"1691161645596519",
3163
+ // "usOut":"1691161645597149",
3164
+ // "usDiff":"630",
3165
+ // "testnet":false
3166
+ // }
3167
+ //
3168
+ return this.parseFundingRate(response, market);
3169
+ }
3170
+ /**
3171
+ * @method
3172
+ * @name deribit#fetchFundingRateHistory
3173
+ * @description fetch the current funding rate
3174
+ * @see https://docs.deribit.com/#public-get_funding_rate_history
3175
+ * @param {string} symbol unified market symbol
3176
+ * @param {int} [since] the earliest time in ms to fetch funding rate history for
3177
+ * @param {int} [limit] the maximum number of entries to retrieve
3178
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3179
+ * @param {int} [params.until] fetch funding rate ending at this timestamp
3180
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3181
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3182
+ */
3183
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3184
+ await this.loadMarkets();
3185
+ const market = this.market(symbol);
3186
+ let paginate = false;
3187
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
3188
+ const maxEntriesPerRequest = 744; // seems exchange returns max 744 items per request
3189
+ const eachItemDuration = '1h';
3190
+ if (paginate) {
3191
+ // fix for: https://github.com/ccxt/ccxt/issues/25040
3192
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, eachItemDuration, this.extend(params, { 'isDeribitPaginationCall': true }), maxEntriesPerRequest);
3193
+ }
3194
+ const duration = this.parseTimeframe(eachItemDuration) * 1000;
3195
+ let time = this.milliseconds();
3196
+ const month = 30 * 24 * 60 * 60 * 1000;
3197
+ if (since === undefined) {
3198
+ since = time - month;
3199
+ }
3200
+ else {
3201
+ time = since + month;
3202
+ }
3203
+ const request = {
3204
+ 'instrument_name': market['id'],
3205
+ 'start_timestamp': since - 1,
3206
+ };
3207
+ const until = this.safeInteger2(params, 'until', 'end_timestamp');
3208
+ if (until !== undefined) {
3209
+ params = this.omit(params, ['until']);
3210
+ request['end_timestamp'] = until;
3211
+ }
3212
+ else {
3213
+ request['end_timestamp'] = time;
3214
+ }
3215
+ if ('isDeribitPaginationCall' in params) {
3216
+ params = this.omit(params, 'isDeribitPaginationCall');
3217
+ const maxUntil = this.sum(since, limit * duration);
3218
+ request['end_timestamp'] = Math.min(request['end_timestamp'], maxUntil);
3219
+ }
3220
+ const response = await this.publicGetGetFundingRateHistory(this.extend(request, params));
3221
+ //
3222
+ // {
3223
+ // "jsonrpc": "2.0",
3224
+ // "id": 7617,
3225
+ // "result": [
3226
+ // {
3227
+ // "timestamp": 1569891600000,
3228
+ // "index_price": 8222.87,
3229
+ // "prev_index_price": 8305.72,
3230
+ // "interest_8h": -0.00009234260068476106,
3231
+ // "interest_1h": -4.739622041017375e-7
3232
+ // }
3233
+ // ]
3234
+ // }
3235
+ //
3236
+ const rates = [];
3237
+ const result = this.safeValue(response, 'result', []);
3238
+ for (let i = 0; i < result.length; i++) {
3239
+ const fr = result[i];
3240
+ const rate = this.parseFundingRate(fr, market);
3241
+ rates.push(rate);
3242
+ }
3243
+ return this.filterBySymbolSinceLimit(rates, symbol, since, limit);
3244
+ }
3245
+ parseFundingRate(contract, market = undefined) {
3246
+ //
3247
+ // {
3248
+ // "jsonrpc":"2.0",
3249
+ // "result":"0",
3250
+ // "usIn":"1691161645596519",
3251
+ // "usOut":"1691161645597149",
3252
+ // "usDiff":"630",
3253
+ // "testnet":false
3254
+ // }
3255
+ // history
3256
+ // {
3257
+ // "timestamp": 1569891600000,
3258
+ // "index_price": 8222.87,
3259
+ // "prev_index_price": 8305.72,
3260
+ // "interest_8h": -0.00009234260068476106,
3261
+ // "interest_1h": -4.739622041017375e-7
3262
+ // }
3263
+ //
3264
+ const timestamp = this.safeInteger(contract, 'timestamp');
3265
+ const datetime = this.iso8601(timestamp);
3266
+ const result = this.safeNumber2(contract, 'result', 'interest_8h');
3267
+ return {
3268
+ 'info': contract,
3269
+ 'symbol': this.safeSymbol(undefined, market),
3270
+ 'markPrice': undefined,
3271
+ 'indexPrice': this.safeNumber(contract, 'index_price'),
3272
+ 'interestRate': undefined,
3273
+ 'estimatedSettlePrice': undefined,
3274
+ 'timestamp': timestamp,
3275
+ 'datetime': datetime,
3276
+ 'fundingRate': result,
3277
+ 'fundingTimestamp': undefined,
3278
+ 'fundingDatetime': undefined,
3279
+ 'nextFundingRate': undefined,
3280
+ 'nextFundingTimestamp': undefined,
3281
+ 'nextFundingDatetime': undefined,
3282
+ 'previousFundingRate': undefined,
3283
+ 'previousFundingTimestamp': undefined,
3284
+ 'previousFundingDatetime': undefined,
3285
+ 'interval': '8h',
3286
+ };
3287
+ }
3288
+ /**
3289
+ * @method
3290
+ * @name deribit#fetchLiquidations
3291
+ * @description retrieves the public liquidations of a trading pair
3292
+ * @see https://docs.deribit.com/#public-get_last_settlements_by_currency
3293
+ * @param {string} symbol unified CCXT market symbol
3294
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
3295
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
3296
+ * @param {object} [params] exchange specific parameters for the deribit api endpoint
3297
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3298
+ * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
3299
+ */
3300
+ async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
3301
+ await this.loadMarkets();
3302
+ let paginate = false;
3303
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
3304
+ if (paginate) {
3305
+ return await this.fetchPaginatedCallCursor('fetchLiquidations', symbol, since, limit, params, 'continuation', 'continuation', undefined);
3306
+ }
3307
+ const market = this.market(symbol);
3308
+ if (market['spot']) {
3309
+ throw new NotSupported(this.id + ' fetchLiquidations() does not support ' + market['type'] + ' markets');
3310
+ }
3311
+ const request = {
3312
+ 'instrument_name': market['id'],
3313
+ 'type': 'bankruptcy',
3314
+ };
3315
+ if (since !== undefined) {
3316
+ request['search_start_timestamp'] = since;
3317
+ }
3318
+ if (limit !== undefined) {
3319
+ request['count'] = limit;
3320
+ }
3321
+ const response = await this.publicGetGetLastSettlementsByInstrument(this.extend(request, params));
3322
+ //
3323
+ // {
3324
+ // "jsonrpc": "2.0",
3325
+ // "result": {
3326
+ // "settlements": [
3327
+ // {
3328
+ // "type": "bankruptcy",
3329
+ // "timestamp": 1696579200041,
3330
+ // "funded": 10000.0,
3331
+ // "session_bankrupcy": 10000.0
3332
+ // "session_profit_loss": 112951.68715857354,
3333
+ // "session_tax": 0.15,
3334
+ // "session_tax_rate": 0.0015,
3335
+ // "socialized": 0.001,
3336
+ // },
3337
+ // ],
3338
+ // "continuation": "5dHzoGyD8Hs8KURoUhfgXgHpJTA5oyapoudSmNeAfEftqRbjNE6jNNUpo2oCu1khnZL9ao"
3339
+ // },
3340
+ // "usIn": 1696652052254890,
3341
+ // "usOut": 1696652052255733,
3342
+ // "usDiff": 843,
3343
+ // "testnet": false
3344
+ // }
3345
+ //
3346
+ const result = this.safeValue(response, 'result', {});
3347
+ const cursor = this.safeString(result, 'continuation');
3348
+ const settlements = this.safeValue(result, 'settlements', []);
3349
+ const settlementsWithCursor = this.addPaginationCursorToResult(cursor, settlements);
3350
+ return this.parseLiquidations(settlementsWithCursor, market, since, limit);
3351
+ }
3352
+ addPaginationCursorToResult(cursor, data) {
3353
+ if (cursor !== undefined) {
3354
+ const dataLength = data.length;
3355
+ if (dataLength > 0) {
3356
+ const first = data[0];
3357
+ const last = data[dataLength - 1];
3358
+ first['continuation'] = cursor;
3359
+ last['continuation'] = cursor;
3360
+ data[0] = first;
3361
+ data[dataLength - 1] = last;
3362
+ }
3363
+ }
3364
+ return data;
3365
+ }
3366
+ /**
3367
+ * @method
3368
+ * @name deribit#fetchMyLiquidations
3369
+ * @description retrieves the users liquidated positions
3370
+ * @see https://docs.deribit.com/#private-get_settlement_history_by_instrument
3371
+ * @param {string} symbol unified CCXT market symbol
3372
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
3373
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
3374
+ * @param {object} [params] exchange specific parameters for the deribit api endpoint
3375
+ * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
3376
+ */
3377
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3378
+ if (symbol === undefined) {
3379
+ throw new ArgumentsRequired(this.id + ' fetchMyLiquidations() requires a symbol argument');
3380
+ }
3381
+ await this.loadMarkets();
3382
+ const market = this.market(symbol);
3383
+ if (market['spot']) {
3384
+ throw new NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
3385
+ }
3386
+ const request = {
3387
+ 'instrument_name': market['id'],
3388
+ 'type': 'bankruptcy',
3389
+ };
3390
+ if (since !== undefined) {
3391
+ request['search_start_timestamp'] = since;
3392
+ }
3393
+ if (limit !== undefined) {
3394
+ request['count'] = limit;
3395
+ }
3396
+ const response = await this.privateGetGetSettlementHistoryByInstrument(this.extend(request, params));
3397
+ //
3398
+ // {
3399
+ // "jsonrpc": "2.0",
3400
+ // "result": {
3401
+ // "settlements": [
3402
+ // {
3403
+ // "type": "bankruptcy",
3404
+ // "timestamp": 1696579200041,
3405
+ // "funded": 10000.0,
3406
+ // "session_bankrupcy": 10000.0
3407
+ // "session_profit_loss": 112951.68715857354,
3408
+ // "session_tax": 0.15,
3409
+ // "session_tax_rate": 0.0015,
3410
+ // "socialized": 0.001,
3411
+ // },
3412
+ // ],
3413
+ // "continuation": "5dHzoGyD8Hs8KURoUhfgXgHpJTA5oyapoudSmNeAfEftqRbjNE6jNNUpo2oCu1khnZL9ao"
3414
+ // },
3415
+ // "usIn": 1696652052254890,
3416
+ // "usOut": 1696652052255733,
3417
+ // "usDiff": 843,
3418
+ // "testnet": false
3419
+ // }
3420
+ //
3421
+ const result = this.safeValue(response, 'result', {});
3422
+ const settlements = this.safeList(result, 'settlements', []);
3423
+ return this.parseLiquidations(settlements, market, since, limit);
3424
+ }
3425
+ parseLiquidation(liquidation, market = undefined) {
3426
+ //
3427
+ // {
3428
+ // "type": "bankruptcy",
3429
+ // "timestamp": 1696579200041,
3430
+ // "funded": 1,
3431
+ // "session_bankrupcy": 0.001,
3432
+ // "session_profit_loss": 0.001,
3433
+ // "session_tax": 0.0015,
3434
+ // "session_tax_rate": 0.0015,
3435
+ // "socialized": 0.001,
3436
+ // }
3437
+ //
3438
+ const timestamp = this.safeInteger(liquidation, 'timestamp');
3439
+ return this.safeLiquidation({
3440
+ 'info': liquidation,
3441
+ 'symbol': this.safeSymbol(undefined, market),
3442
+ 'contracts': undefined,
3443
+ 'contractSize': this.safeNumber(market, 'contractSize'),
3444
+ 'price': undefined,
3445
+ 'baseValue': this.safeNumber(liquidation, 'session_bankrupcy'),
3446
+ 'quoteValue': undefined,
3447
+ 'timestamp': timestamp,
3448
+ 'datetime': this.iso8601(timestamp),
3449
+ });
3450
+ }
3451
+ /**
3452
+ * @method
3453
+ * @name deribit#fetchGreeks
3454
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
3455
+ * @see https://docs.deribit.com/#public-ticker
3456
+ * @param {string} symbol unified symbol of the market to fetch greeks for
3457
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3458
+ * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
3459
+ */
3460
+ async fetchGreeks(symbol, params = {}) {
3461
+ await this.loadMarkets();
3462
+ const market = this.market(symbol);
3463
+ const request = {
3464
+ 'instrument_name': market['id'],
3465
+ };
3466
+ const response = await this.publicGetTicker(this.extend(request, params));
3467
+ //
3468
+ // {
3469
+ // "jsonrpc": "2.0",
3470
+ // "result": {
3471
+ // "estimated_delivery_price": 36552.72,
3472
+ // "best_bid_amount": 0.2,
3473
+ // "best_ask_amount": 9.1,
3474
+ // "interest_rate": 0.0,
3475
+ // "best_bid_price": 0.214,
3476
+ // "best_ask_price": 0.219,
3477
+ // "open_interest": 368.8,
3478
+ // "settlement_price": 0.22103022,
3479
+ // "last_price": 0.215,
3480
+ // "bid_iv": 60.51,
3481
+ // "ask_iv": 61.88,
3482
+ // "mark_iv": 61.27,
3483
+ // "underlying_index": "BTC-27SEP24",
3484
+ // "underlying_price": 38992.71,
3485
+ // "min_price": 0.1515,
3486
+ // "max_price": 0.326,
3487
+ // "mark_price": 0.2168,
3488
+ // "instrument_name": "BTC-27SEP24-40000-C",
3489
+ // "index_price": 36552.72,
3490
+ // "greeks": {
3491
+ // "rho": 130.63998,
3492
+ // "theta": -13.48784,
3493
+ // "vega": 141.90146,
3494
+ // "gamma": 0.00002,
3495
+ // "delta": 0.59621
3496
+ // },
3497
+ // "stats": {
3498
+ // "volume_usd": 100453.9,
3499
+ // "volume": 12.0,
3500
+ // "price_change": -2.2727,
3501
+ // "low": 0.2065,
3502
+ // "high": 0.238
3503
+ // },
3504
+ // "state": "open",
3505
+ // "timestamp": 1699578548021
3506
+ // },
3507
+ // "usIn": 1699578548308414,
3508
+ // "usOut": 1699578548308606,
3509
+ // "usDiff": 192,
3510
+ // "testnet": false
3511
+ // }
3512
+ //
3513
+ const result = this.safeValue(response, 'result', {});
3514
+ return this.parseGreeks(result, market);
3515
+ }
3516
+ parseGreeks(greeks, market = undefined) {
3517
+ //
3518
+ // {
3519
+ // "estimated_delivery_price": 36552.72,
3520
+ // "best_bid_amount": 0.2,
3521
+ // "best_ask_amount": 9.1,
3522
+ // "interest_rate": 0.0,
3523
+ // "best_bid_price": 0.214,
3524
+ // "best_ask_price": 0.219,
3525
+ // "open_interest": 368.8,
3526
+ // "settlement_price": 0.22103022,
3527
+ // "last_price": 0.215,
3528
+ // "bid_iv": 60.51,
3529
+ // "ask_iv": 61.88,
3530
+ // "mark_iv": 61.27,
3531
+ // "underlying_index": "BTC-27SEP24",
3532
+ // "underlying_price": 38992.71,
3533
+ // "min_price": 0.1515,
3534
+ // "max_price": 0.326,
3535
+ // "mark_price": 0.2168,
3536
+ // "instrument_name": "BTC-27SEP24-40000-C",
3537
+ // "index_price": 36552.72,
3538
+ // "greeks": {
3539
+ // "rho": 130.63998,
3540
+ // "theta": -13.48784,
3541
+ // "vega": 141.90146,
3542
+ // "gamma": 0.00002,
3543
+ // "delta": 0.59621
3544
+ // },
3545
+ // "stats": {
3546
+ // "volume_usd": 100453.9,
3547
+ // "volume": 12.0,
3548
+ // "price_change": -2.2727,
3549
+ // "low": 0.2065,
3550
+ // "high": 0.238
3551
+ // },
3552
+ // "state": "open",
3553
+ // "timestamp": 1699578548021
3554
+ // }
3555
+ //
3556
+ const timestamp = this.safeInteger(greeks, 'timestamp');
3557
+ const marketId = this.safeString(greeks, 'instrument_name');
3558
+ const symbol = this.safeSymbol(marketId, market);
3559
+ const stats = this.safeValue(greeks, 'greeks', {});
3560
+ return {
3561
+ 'symbol': symbol,
3562
+ 'timestamp': timestamp,
3563
+ 'datetime': this.iso8601(timestamp),
3564
+ 'delta': this.safeNumber(stats, 'delta'),
3565
+ 'gamma': this.safeNumber(stats, 'gamma'),
3566
+ 'theta': this.safeNumber(stats, 'theta'),
3567
+ 'vega': this.safeNumber(stats, 'vega'),
3568
+ 'rho': this.safeNumber(stats, 'rho'),
3569
+ 'bidSize': this.safeNumber(greeks, 'best_bid_amount'),
3570
+ 'askSize': this.safeNumber(greeks, 'best_ask_amount'),
3571
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid_iv'),
3572
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask_iv'),
3573
+ 'markImpliedVolatility': this.safeNumber(greeks, 'mark_iv'),
3574
+ 'bidPrice': this.safeNumber(greeks, 'best_bid_price'),
3575
+ 'askPrice': this.safeNumber(greeks, 'best_ask_price'),
3576
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
3577
+ 'lastPrice': this.safeNumber(greeks, 'last_price'),
3578
+ 'underlyingPrice': this.safeNumber(greeks, 'underlying_price'),
3579
+ 'info': greeks,
3580
+ };
3581
+ }
3582
+ /**
3583
+ * @method
3584
+ * @name deribit#fetchOption
3585
+ * @description fetches option data that is commonly found in an option chain
3586
+ * @see https://docs.deribit.com/#public-get_book_summary_by_instrument
3587
+ * @param {string} symbol unified market symbol
3588
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3589
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
3590
+ */
3591
+ async fetchOption(symbol, params = {}) {
3592
+ await this.loadMarkets();
3593
+ const market = this.market(symbol);
3594
+ const request = {
3595
+ 'instrument_name': market['id'],
3596
+ };
3597
+ const response = await this.publicGetGetBookSummaryByInstrument(this.extend(request, params));
3598
+ //
3599
+ // {
3600
+ // "jsonrpc": "2.0",
3601
+ // "result": [
3602
+ // {
3603
+ // "mid_price": 0.04025,
3604
+ // "volume_usd": 11045.12,
3605
+ // "quote_currency": "BTC",
3606
+ // "estimated_delivery_price": 65444.72,
3607
+ // "creation_timestamp": 1711100949273,
3608
+ // "base_currency": "BTC",
3609
+ // "underlying_index": "BTC-27DEC24",
3610
+ // "underlying_price": 73742.14,
3611
+ // "volume": 4.0,
3612
+ // "interest_rate": 0.0,
3613
+ // "price_change": -6.9767,
3614
+ // "open_interest": 274.2,
3615
+ // "ask_price": 0.042,
3616
+ // "bid_price": 0.0385,
3617
+ // "instrument_name": "BTC-27DEC24-240000-C",
3618
+ // "mark_price": 0.04007735,
3619
+ // "last": 0.04,
3620
+ // "low": 0.04,
3621
+ // "high": 0.043
3622
+ // }
3623
+ // ],
3624
+ // "usIn": 1711100949273223,
3625
+ // "usOut": 1711100949273580,
3626
+ // "usDiff": 357,
3627
+ // "testnet": false
3628
+ // }
3629
+ //
3630
+ const result = this.safeList(response, 'result', []);
3631
+ const chain = this.safeDict(result, 0, {});
3632
+ return this.parseOption(chain, undefined, market);
3633
+ }
3634
+ /**
3635
+ * @method
3636
+ * @name deribit#fetchOptionChain
3637
+ * @description fetches data for an underlying asset that is commonly found in an option chain
3638
+ * @see https://docs.deribit.com/#public-get_book_summary_by_currency
3639
+ * @param {string} code base currency to fetch an option chain for
3640
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3641
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
3642
+ */
3643
+ async fetchOptionChain(code, params = {}) {
3644
+ await this.loadMarkets();
3645
+ const currency = this.currency(code);
3646
+ const request = {
3647
+ 'currency': currency['id'],
3648
+ 'kind': 'option',
3649
+ };
3650
+ const response = await this.publicGetGetBookSummaryByCurrency(this.extend(request, params));
3651
+ //
3652
+ // {
3653
+ // "jsonrpc": "2.0",
3654
+ // "result": [
3655
+ // {
3656
+ // "mid_price": 0.4075,
3657
+ // "volume_usd": 2836.83,
3658
+ // "quote_currency": "BTC",
3659
+ // "estimated_delivery_price": 65479.26,
3660
+ // "creation_timestamp": 1711101594477,
3661
+ // "base_currency": "BTC",
3662
+ // "underlying_index": "BTC-28JUN24",
3663
+ // "underlying_price": 68827.27,
3664
+ // "volume": 0.1,
3665
+ // "interest_rate": 0.0,
3666
+ // "price_change": 0.0,
3667
+ // "open_interest": 364.1,
3668
+ // "ask_price": 0.411,
3669
+ // "bid_price": 0.404,
3670
+ // "instrument_name": "BTC-28JUN24-42000-C",
3671
+ // "mark_price": 0.40752052,
3672
+ // "last": 0.423,
3673
+ // "low": 0.423,
3674
+ // "high": 0.423
3675
+ // }
3676
+ // ],
3677
+ // "usIn": 1711101594456388,
3678
+ // "usOut": 1711101594484065,
3679
+ // "usDiff": 27677,
3680
+ // "testnet": false
3681
+ // }
3682
+ //
3683
+ const result = this.safeList(response, 'result', []);
3684
+ return this.parseOptionChain(result, 'base_currency', 'instrument_name');
3685
+ }
3686
+ parseOption(chain, currency = undefined, market = undefined) {
3687
+ //
3688
+ // {
3689
+ // "mid_price": 0.04025,
3690
+ // "volume_usd": 11045.12,
3691
+ // "quote_currency": "BTC",
3692
+ // "estimated_delivery_price": 65444.72,
3693
+ // "creation_timestamp": 1711100949273,
3694
+ // "base_currency": "BTC",
3695
+ // "underlying_index": "BTC-27DEC24",
3696
+ // "underlying_price": 73742.14,
3697
+ // "volume": 4.0,
3698
+ // "interest_rate": 0.0,
3699
+ // "price_change": -6.9767,
3700
+ // "open_interest": 274.2,
3701
+ // "ask_price": 0.042,
3702
+ // "bid_price": 0.0385,
3703
+ // "instrument_name": "BTC-27DEC24-240000-C",
3704
+ // "mark_price": 0.04007735,
3705
+ // "last": 0.04,
3706
+ // "low": 0.04,
3707
+ // "high": 0.043
3708
+ // }
3709
+ //
3710
+ const marketId = this.safeString(chain, 'instrument_name');
3711
+ market = this.safeMarket(marketId, market);
3712
+ const currencyId = this.safeString(chain, 'base_currency');
3713
+ const code = this.safeCurrencyCode(currencyId, currency);
3714
+ const timestamp = this.safeInteger(chain, 'timestamp');
3715
+ return {
3716
+ 'info': chain,
3717
+ 'currency': code,
3718
+ 'symbol': market['symbol'],
3719
+ 'timestamp': timestamp,
3720
+ 'datetime': this.iso8601(timestamp),
3721
+ 'impliedVolatility': undefined,
3722
+ 'openInterest': this.safeNumber(chain, 'open_interest'),
3723
+ 'bidPrice': this.safeNumber(chain, 'bid_price'),
3724
+ 'askPrice': this.safeNumber(chain, 'ask_price'),
3725
+ 'midPrice': this.safeNumber(chain, 'mid_price'),
3726
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
3727
+ 'lastPrice': this.safeNumber(chain, 'last'),
3728
+ 'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
3729
+ 'change': undefined,
3730
+ 'percentage': this.safeNumber(chain, 'price_change'),
3731
+ 'baseVolume': this.safeNumber(chain, 'volume'),
3732
+ 'quoteVolume': this.safeNumber(chain, 'volume_usd'),
3733
+ };
3734
+ }
3735
+ nonce() {
3736
+ return this.milliseconds();
3737
+ }
3738
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3739
+ let request = '/' + 'api/' + this.version + '/' + api + '/' + path;
3740
+ if (api === 'public') {
3741
+ if (Object.keys(params).length) {
3742
+ request += '?' + this.urlencode(params);
3743
+ }
3744
+ }
3745
+ if (api === 'private') {
3746
+ this.checkRequiredCredentials();
3747
+ const nonce = this.nonce().toString();
3748
+ const timestamp = this.milliseconds().toString();
3749
+ const requestBody = '';
3750
+ if (Object.keys(params).length) {
3751
+ request += '?' + this.urlencode(params);
3752
+ }
3753
+ const requestData = method + "\n" + request + "\n" + requestBody + "\n"; // eslint-disable-line quotes
3754
+ const auth = timestamp + "\n" + nonce + "\n" + requestData; // eslint-disable-line quotes
3755
+ const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
3756
+ headers = {
3757
+ 'Authorization': 'deri-hmac-sha256 id=' + this.apiKey + ',ts=' + timestamp + ',sig=' + signature + ',' + 'nonce=' + nonce,
3758
+ };
3759
+ }
3760
+ const url = this.urls['api']['rest'] + request;
3761
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3762
+ }
3763
+ handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3764
+ if (!response) {
3765
+ return undefined; // fallback to default error handler
3766
+ }
3767
+ //
3768
+ // {
3769
+ // "jsonrpc": "2.0",
3770
+ // "error": {
3771
+ // "message": "Invalid params",
3772
+ // "data": { reason: "invalid currency", param: "currency" },
3773
+ // "code": -32602
3774
+ // },
3775
+ // "testnet": false,
3776
+ // "usIn": 1583763842150374,
3777
+ // "usOut": 1583763842150410,
3778
+ // "usDiff": 36
3779
+ // }
3780
+ //
3781
+ const error = this.safeValue(response, 'error');
3782
+ if (error !== undefined) {
3783
+ const errorCode = this.safeString(error, 'code');
3784
+ const feedback = this.id + ' ' + body;
3785
+ this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
3786
+ throw new ExchangeError(feedback); // unknown message
3787
+ }
3788
+ return undefined;
3789
+ }
3790
+ }