ccxt-ir 4.3.46.0.1__py2.py3-none-any.whl

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 (772) hide show
  1. ccxt/__init__.py +358 -0
  2. ccxt/abantether.py +316 -0
  3. ccxt/abstract/__init__.py +0 -0
  4. ccxt/abstract/abantether.py +5 -0
  5. ccxt/abstract/ace.py +15 -0
  6. ccxt/abstract/afratether.py +6 -0
  7. ccxt/abstract/alpaca.py +70 -0
  8. ccxt/abstract/arzinja.py +5 -0
  9. ccxt/abstract/arzplus.py +7 -0
  10. ccxt/abstract/ascendex.py +77 -0
  11. ccxt/abstract/bequant.py +115 -0
  12. ccxt/abstract/bigone.py +45 -0
  13. ccxt/abstract/binance.py +712 -0
  14. ccxt/abstract/binancecoinm.py +712 -0
  15. ccxt/abstract/binanceus.py +764 -0
  16. ccxt/abstract/binanceusdm.py +712 -0
  17. ccxt/abstract/bingx.py +113 -0
  18. ccxt/abstract/bit2c.py +27 -0
  19. ccxt/abstract/bitbank.py +27 -0
  20. ccxt/abstract/bitbay.py +53 -0
  21. ccxt/abstract/bitbns.py +40 -0
  22. ccxt/abstract/bitcoincom.py +115 -0
  23. ccxt/abstract/bitfinex.py +69 -0
  24. ccxt/abstract/bitfinex2.py +139 -0
  25. ccxt/abstract/bitflyer.py +38 -0
  26. ccxt/abstract/bitget.py +508 -0
  27. ccxt/abstract/bithumb.py +32 -0
  28. ccxt/abstract/bitimen.py +7 -0
  29. ccxt/abstract/bitir.py +7 -0
  30. ccxt/abstract/bitmart.py +99 -0
  31. ccxt/abstract/bitmex.py +97 -0
  32. ccxt/abstract/bitopro.py +29 -0
  33. ccxt/abstract/bitpanda.py +35 -0
  34. ccxt/abstract/bitpin.py +7 -0
  35. ccxt/abstract/bitrue.py +72 -0
  36. ccxt/abstract/bitso.py +43 -0
  37. ccxt/abstract/bitstamp.py +258 -0
  38. ccxt/abstract/bitteam.py +29 -0
  39. ccxt/abstract/bitvavo.py +27 -0
  40. ccxt/abstract/bl3p.py +19 -0
  41. ccxt/abstract/blockchaincom.py +28 -0
  42. ccxt/abstract/blofin.py +37 -0
  43. ccxt/abstract/btcalpha.py +18 -0
  44. ccxt/abstract/btcbox.py +13 -0
  45. ccxt/abstract/btcmarkets.py +39 -0
  46. ccxt/abstract/btcturk.py +20 -0
  47. ccxt/abstract/bybit.py +298 -0
  48. ccxt/abstract/cex.py +33 -0
  49. ccxt/abstract/coinbase.py +94 -0
  50. ccxt/abstract/coinbaseadvanced.py +94 -0
  51. ccxt/abstract/coinbaseexchange.py +67 -0
  52. ccxt/abstract/coinbaseinternational.py +39 -0
  53. ccxt/abstract/coincatch.py +94 -0
  54. ccxt/abstract/coincheck.py +33 -0
  55. ccxt/abstract/coinex.py +237 -0
  56. ccxt/abstract/coinlist.py +54 -0
  57. ccxt/abstract/coinmate.py +62 -0
  58. ccxt/abstract/coinmetro.py +34 -0
  59. ccxt/abstract/coinone.py +67 -0
  60. ccxt/abstract/coinsph.py +54 -0
  61. ccxt/abstract/coinspot.py +28 -0
  62. ccxt/abstract/cryptocom.py +107 -0
  63. ccxt/abstract/currencycom.py +68 -0
  64. ccxt/abstract/delta.py +50 -0
  65. ccxt/abstract/deribit.py +125 -0
  66. ccxt/abstract/digifinex.py +91 -0
  67. ccxt/abstract/eterex.py +5 -0
  68. ccxt/abstract/excoino.py +7 -0
  69. ccxt/abstract/exir.py +8 -0
  70. ccxt/abstract/exmo.py +55 -0
  71. ccxt/abstract/exnovin.py +6 -0
  72. ccxt/abstract/farhadexchange.py +5 -0
  73. ccxt/abstract/fmfwio.py +115 -0
  74. ccxt/abstract/gate.py +265 -0
  75. ccxt/abstract/gateio.py +265 -0
  76. ccxt/abstract/gemini.py +58 -0
  77. ccxt/abstract/hashkey.py +67 -0
  78. ccxt/abstract/hitbtc.py +115 -0
  79. ccxt/abstract/hitbtc3.py +115 -0
  80. ccxt/abstract/hitobit.py +8 -0
  81. ccxt/abstract/hollaex.py +33 -0
  82. ccxt/abstract/htx.py +548 -0
  83. ccxt/abstract/huobi.py +548 -0
  84. ccxt/abstract/huobijp.py +114 -0
  85. ccxt/abstract/hyperliquid.py +6 -0
  86. ccxt/abstract/idex.py +26 -0
  87. ccxt/abstract/independentreserve.py +37 -0
  88. ccxt/abstract/indodax.py +26 -0
  89. ccxt/abstract/jibitex.py +7 -0
  90. ccxt/abstract/kraken.py +57 -0
  91. ccxt/abstract/krakenfutures.py +38 -0
  92. ccxt/abstract/kucoin.py +214 -0
  93. ccxt/abstract/kucoinfutures.py +233 -0
  94. ccxt/abstract/kuna.py +182 -0
  95. ccxt/abstract/latoken.py +56 -0
  96. ccxt/abstract/lbank.py +61 -0
  97. ccxt/abstract/luno.py +37 -0
  98. ccxt/abstract/lykke.py +29 -0
  99. ccxt/abstract/mercado.py +25 -0
  100. ccxt/abstract/mexc.py +178 -0
  101. ccxt/abstract/ndax.py +97 -0
  102. ccxt/abstract/nobitex.py +7 -0
  103. ccxt/abstract/novadax.py +29 -0
  104. ccxt/abstract/oceanex.py +22 -0
  105. ccxt/abstract/okcoin.py +74 -0
  106. ccxt/abstract/okexchange.py +8 -0
  107. ccxt/abstract/okx.py +324 -0
  108. ccxt/abstract/ompfinex.py +7 -0
  109. ccxt/abstract/onetrading.py +35 -0
  110. ccxt/abstract/oxfun.py +34 -0
  111. ccxt/abstract/p2b.py +22 -0
  112. ccxt/abstract/paradex.py +40 -0
  113. ccxt/abstract/paymium.py +28 -0
  114. ccxt/abstract/phemex.py +115 -0
  115. ccxt/abstract/poloniex.py +69 -0
  116. ccxt/abstract/poloniexfutures.py +48 -0
  117. ccxt/abstract/probit.py +23 -0
  118. ccxt/abstract/ramzinex.py +7 -0
  119. ccxt/abstract/sarmayex.py +5 -0
  120. ccxt/abstract/sarrafex.py +7 -0
  121. ccxt/abstract/tabdeal.py +7 -0
  122. ccxt/abstract/tetherland.py +5 -0
  123. ccxt/abstract/timex.py +62 -0
  124. ccxt/abstract/tokocrypto.py +37 -0
  125. ccxt/abstract/tradeogre.py +16 -0
  126. ccxt/abstract/twox.py +5 -0
  127. ccxt/abstract/ubitex.py +7 -0
  128. ccxt/abstract/upbit.py +38 -0
  129. ccxt/abstract/vertex.py +19 -0
  130. ccxt/abstract/wallex.py +8 -0
  131. ccxt/abstract/wavesexchange.py +154 -0
  132. ccxt/abstract/wazirx.py +30 -0
  133. ccxt/abstract/whitebit.py +98 -0
  134. ccxt/abstract/woo.py +83 -0
  135. ccxt/abstract/woofipro.py +119 -0
  136. ccxt/abstract/xt.py +152 -0
  137. ccxt/abstract/yobit.py +16 -0
  138. ccxt/abstract/zaif.py +38 -0
  139. ccxt/abstract/zonda.py +53 -0
  140. ccxt/ace.py +1012 -0
  141. ccxt/afratether.py +293 -0
  142. ccxt/alpaca.py +1083 -0
  143. ccxt/arzinja.py +285 -0
  144. ccxt/arzplus.py +412 -0
  145. ccxt/ascendex.py +3330 -0
  146. ccxt/async_support/__init__.py +337 -0
  147. ccxt/async_support/abantether.py +316 -0
  148. ccxt/async_support/ace.py +1012 -0
  149. ccxt/async_support/afratether.py +293 -0
  150. ccxt/async_support/alpaca.py +1083 -0
  151. ccxt/async_support/arzinja.py +285 -0
  152. ccxt/async_support/arzplus.py +412 -0
  153. ccxt/async_support/ascendex.py +3330 -0
  154. ccxt/async_support/base/__init__.py +1 -0
  155. ccxt/async_support/base/exchange.py +1966 -0
  156. ccxt/async_support/base/throttler.py +50 -0
  157. ccxt/async_support/base/ws/__init__.py +38 -0
  158. ccxt/async_support/base/ws/aiohttp_client.py +125 -0
  159. ccxt/async_support/base/ws/cache.py +212 -0
  160. ccxt/async_support/base/ws/client.py +193 -0
  161. ccxt/async_support/base/ws/fast_client.py +96 -0
  162. ccxt/async_support/base/ws/functions.py +59 -0
  163. ccxt/async_support/base/ws/future.py +58 -0
  164. ccxt/async_support/base/ws/order_book.py +78 -0
  165. ccxt/async_support/base/ws/order_book_side.py +174 -0
  166. ccxt/async_support/bequant.py +33 -0
  167. ccxt/async_support/bigone.py +2113 -0
  168. ccxt/async_support/binance.py +12234 -0
  169. ccxt/async_support/binancecoinm.py +45 -0
  170. ccxt/async_support/binanceus.py +211 -0
  171. ccxt/async_support/binanceusdm.py +58 -0
  172. ccxt/async_support/bingx.py +4325 -0
  173. ccxt/async_support/bit2c.py +866 -0
  174. ccxt/async_support/bitbank.py +1001 -0
  175. ccxt/async_support/bitbay.py +17 -0
  176. ccxt/async_support/bitbns.py +1154 -0
  177. ccxt/async_support/bitcoincom.py +17 -0
  178. ccxt/async_support/bitfinex.py +1617 -0
  179. ccxt/async_support/bitfinex2.py +3552 -0
  180. ccxt/async_support/bitflyer.py +995 -0
  181. ccxt/async_support/bitget.py +8273 -0
  182. ccxt/async_support/bithumb.py +1061 -0
  183. ccxt/async_support/bitimen.py +401 -0
  184. ccxt/async_support/bitir.py +490 -0
  185. ccxt/async_support/bitmart.py +4415 -0
  186. ccxt/async_support/bitmex.py +2756 -0
  187. ccxt/async_support/bitopro.py +1630 -0
  188. ccxt/async_support/bitpanda.py +16 -0
  189. ccxt/async_support/bitpin.py +454 -0
  190. ccxt/async_support/bitrue.py +3027 -0
  191. ccxt/async_support/bitso.py +1670 -0
  192. ccxt/async_support/bitstamp.py +2203 -0
  193. ccxt/async_support/bitteam.py +2239 -0
  194. ccxt/async_support/bitvavo.py +1968 -0
  195. ccxt/async_support/bl3p.py +485 -0
  196. ccxt/async_support/blockchaincom.py +1104 -0
  197. ccxt/async_support/blofin.py +2066 -0
  198. ccxt/async_support/btcalpha.py +891 -0
  199. ccxt/async_support/btcbox.py +544 -0
  200. ccxt/async_support/btcmarkets.py +1221 -0
  201. ccxt/async_support/btcturk.py +911 -0
  202. ccxt/async_support/bybit.py +8159 -0
  203. ccxt/async_support/cex.py +1605 -0
  204. ccxt/async_support/coinbase.py +4475 -0
  205. ccxt/async_support/coinbaseadvanced.py +17 -0
  206. ccxt/async_support/coinbaseexchange.py +1734 -0
  207. ccxt/async_support/coinbaseinternational.py +1899 -0
  208. ccxt/async_support/coincatch.py +5069 -0
  209. ccxt/async_support/coincheck.py +815 -0
  210. ccxt/async_support/coinex.py +5526 -0
  211. ccxt/async_support/coinlist.py +2243 -0
  212. ccxt/async_support/coinmate.py +1067 -0
  213. ccxt/async_support/coinmetro.py +1797 -0
  214. ccxt/async_support/coinone.py +1127 -0
  215. ccxt/async_support/coinsph.py +1850 -0
  216. ccxt/async_support/coinspot.py +534 -0
  217. ccxt/async_support/cryptocom.py +2822 -0
  218. ccxt/async_support/currencycom.py +1950 -0
  219. ccxt/async_support/delta.py +3376 -0
  220. ccxt/async_support/deribit.py +3437 -0
  221. ccxt/async_support/digifinex.py +3960 -0
  222. ccxt/async_support/eterex.py +286 -0
  223. ccxt/async_support/excoino.py +399 -0
  224. ccxt/async_support/exir.py +375 -0
  225. ccxt/async_support/exmo.py +2462 -0
  226. ccxt/async_support/exnovin.py +360 -0
  227. ccxt/async_support/farhadexchange.py +266 -0
  228. ccxt/async_support/fmfwio.py +34 -0
  229. ccxt/async_support/gate.py +6976 -0
  230. ccxt/async_support/gateio.py +16 -0
  231. ccxt/async_support/gemini.py +1825 -0
  232. ccxt/async_support/hashkey.py +4150 -0
  233. ccxt/async_support/hitbtc.py +3423 -0
  234. ccxt/async_support/hitbtc3.py +16 -0
  235. ccxt/async_support/hitobit.py +391 -0
  236. ccxt/async_support/hollaex.py +1813 -0
  237. ccxt/async_support/htx.py +8506 -0
  238. ccxt/async_support/huobi.py +16 -0
  239. ccxt/async_support/huobijp.py +1801 -0
  240. ccxt/async_support/hyperliquid.py +2431 -0
  241. ccxt/async_support/idex.py +1766 -0
  242. ccxt/async_support/independentreserve.py +784 -0
  243. ccxt/async_support/indodax.py +1247 -0
  244. ccxt/async_support/jibitex.py +395 -0
  245. ccxt/async_support/kraken.py +2894 -0
  246. ccxt/async_support/krakenfutures.py +2601 -0
  247. ccxt/async_support/kucoin.py +4602 -0
  248. ccxt/async_support/kucoinfutures.py +2698 -0
  249. ccxt/async_support/kuna.py +1841 -0
  250. ccxt/async_support/latoken.py +1664 -0
  251. ccxt/async_support/lbank.py +2683 -0
  252. ccxt/async_support/luno.py +1067 -0
  253. ccxt/async_support/lykke.py +1270 -0
  254. ccxt/async_support/mercado.py +842 -0
  255. ccxt/async_support/mexc.py +5369 -0
  256. ccxt/async_support/ndax.py +2354 -0
  257. ccxt/async_support/nobitex.py +419 -0
  258. ccxt/async_support/novadax.py +1484 -0
  259. ccxt/async_support/oceanex.py +903 -0
  260. ccxt/async_support/okcoin.py +2936 -0
  261. ccxt/async_support/okexchange.py +349 -0
  262. ccxt/async_support/okx.py +7827 -0
  263. ccxt/async_support/ompfinex.py +472 -0
  264. ccxt/async_support/onetrading.py +1911 -0
  265. ccxt/async_support/oxfun.py +2773 -0
  266. ccxt/async_support/p2b.py +1194 -0
  267. ccxt/async_support/paradex.py +2015 -0
  268. ccxt/async_support/paymium.py +564 -0
  269. ccxt/async_support/phemex.py +4473 -0
  270. ccxt/async_support/poloniex.py +2232 -0
  271. ccxt/async_support/poloniexfutures.py +1717 -0
  272. ccxt/async_support/probit.py +1734 -0
  273. ccxt/async_support/ramzinex.py +476 -0
  274. ccxt/async_support/sarmayex.py +357 -0
  275. ccxt/async_support/sarrafex.py +478 -0
  276. ccxt/async_support/tabdeal.py +364 -0
  277. ccxt/async_support/tetherland.py +349 -0
  278. ccxt/async_support/timex.py +1593 -0
  279. ccxt/async_support/tokocrypto.py +2405 -0
  280. ccxt/async_support/tradeogre.py +608 -0
  281. ccxt/async_support/twox.py +326 -0
  282. ccxt/async_support/ubitex.py +409 -0
  283. ccxt/async_support/upbit.py +1833 -0
  284. ccxt/async_support/vertex.py +2922 -0
  285. ccxt/async_support/wallex.py +445 -0
  286. ccxt/async_support/wavesexchange.py +2473 -0
  287. ccxt/async_support/wazirx.py +1224 -0
  288. ccxt/async_support/whitebit.py +2469 -0
  289. ccxt/async_support/woo.py +3114 -0
  290. ccxt/async_support/woofipro.py +2533 -0
  291. ccxt/async_support/xt.py +4454 -0
  292. ccxt/async_support/yobit.py +1283 -0
  293. ccxt/async_support/zaif.py +725 -0
  294. ccxt/async_support/zonda.py +1828 -0
  295. ccxt/base/__init__.py +27 -0
  296. ccxt/base/decimal_to_precision.py +174 -0
  297. ccxt/base/errors.py +242 -0
  298. ccxt/base/exchange.py +5941 -0
  299. ccxt/base/precise.py +287 -0
  300. ccxt/base/types.py +502 -0
  301. ccxt/bequant.py +33 -0
  302. ccxt/bigone.py +2112 -0
  303. ccxt/binance.py +12233 -0
  304. ccxt/binancecoinm.py +45 -0
  305. ccxt/binanceus.py +211 -0
  306. ccxt/binanceusdm.py +58 -0
  307. ccxt/bingx.py +4324 -0
  308. ccxt/bit2c.py +866 -0
  309. ccxt/bitbank.py +1001 -0
  310. ccxt/bitbay.py +17 -0
  311. ccxt/bitbns.py +1154 -0
  312. ccxt/bitcoincom.py +17 -0
  313. ccxt/bitfinex.py +1617 -0
  314. ccxt/bitfinex2.py +3552 -0
  315. ccxt/bitflyer.py +995 -0
  316. ccxt/bitget.py +8272 -0
  317. ccxt/bithumb.py +1061 -0
  318. ccxt/bitimen.py +401 -0
  319. ccxt/bitir.py +490 -0
  320. ccxt/bitmart.py +4415 -0
  321. ccxt/bitmex.py +2756 -0
  322. ccxt/bitopro.py +1630 -0
  323. ccxt/bitpanda.py +16 -0
  324. ccxt/bitpin.py +454 -0
  325. ccxt/bitrue.py +3026 -0
  326. ccxt/bitso.py +1670 -0
  327. ccxt/bitstamp.py +2203 -0
  328. ccxt/bitteam.py +2239 -0
  329. ccxt/bitvavo.py +1968 -0
  330. ccxt/bl3p.py +485 -0
  331. ccxt/blockchaincom.py +1104 -0
  332. ccxt/blofin.py +2066 -0
  333. ccxt/btcalpha.py +891 -0
  334. ccxt/btcbox.py +544 -0
  335. ccxt/btcmarkets.py +1221 -0
  336. ccxt/btcturk.py +911 -0
  337. ccxt/bybit.py +8158 -0
  338. ccxt/cex.py +1605 -0
  339. ccxt/coinbase.py +4474 -0
  340. ccxt/coinbaseadvanced.py +17 -0
  341. ccxt/coinbaseexchange.py +1734 -0
  342. ccxt/coinbaseinternational.py +1899 -0
  343. ccxt/coincatch.py +5069 -0
  344. ccxt/coincheck.py +815 -0
  345. ccxt/coinex.py +5525 -0
  346. ccxt/coinlist.py +2243 -0
  347. ccxt/coinmate.py +1067 -0
  348. ccxt/coinmetro.py +1797 -0
  349. ccxt/coinone.py +1127 -0
  350. ccxt/coinsph.py +1850 -0
  351. ccxt/coinspot.py +534 -0
  352. ccxt/cryptocom.py +2822 -0
  353. ccxt/currencycom.py +1950 -0
  354. ccxt/delta.py +3376 -0
  355. ccxt/deribit.py +3437 -0
  356. ccxt/digifinex.py +3959 -0
  357. ccxt/eterex.py +286 -0
  358. ccxt/excoino.py +399 -0
  359. ccxt/exir.py +375 -0
  360. ccxt/exmo.py +2462 -0
  361. ccxt/exnovin.py +360 -0
  362. ccxt/farhadexchange.py +266 -0
  363. ccxt/fmfwio.py +34 -0
  364. ccxt/gate.py +6975 -0
  365. ccxt/gateio.py +16 -0
  366. ccxt/gemini.py +1824 -0
  367. ccxt/hashkey.py +4150 -0
  368. ccxt/hitbtc.py +3423 -0
  369. ccxt/hitbtc3.py +16 -0
  370. ccxt/hitobit.py +391 -0
  371. ccxt/hollaex.py +1813 -0
  372. ccxt/htx.py +8505 -0
  373. ccxt/huobi.py +16 -0
  374. ccxt/huobijp.py +1801 -0
  375. ccxt/hyperliquid.py +2430 -0
  376. ccxt/idex.py +1766 -0
  377. ccxt/independentreserve.py +784 -0
  378. ccxt/indodax.py +1247 -0
  379. ccxt/jibitex.py +395 -0
  380. ccxt/kraken.py +2894 -0
  381. ccxt/krakenfutures.py +2601 -0
  382. ccxt/kucoin.py +4601 -0
  383. ccxt/kucoinfutures.py +2698 -0
  384. ccxt/kuna.py +1841 -0
  385. ccxt/latoken.py +1664 -0
  386. ccxt/lbank.py +2682 -0
  387. ccxt/luno.py +1067 -0
  388. ccxt/lykke.py +1270 -0
  389. ccxt/mercado.py +842 -0
  390. ccxt/mexc.py +5369 -0
  391. ccxt/ndax.py +2354 -0
  392. ccxt/nobitex.py +419 -0
  393. ccxt/novadax.py +1484 -0
  394. ccxt/oceanex.py +903 -0
  395. ccxt/okcoin.py +2936 -0
  396. ccxt/okexchange.py +349 -0
  397. ccxt/okx.py +7826 -0
  398. ccxt/ompfinex.py +472 -0
  399. ccxt/onetrading.py +1911 -0
  400. ccxt/oxfun.py +2772 -0
  401. ccxt/p2b.py +1194 -0
  402. ccxt/paradex.py +2015 -0
  403. ccxt/paymium.py +564 -0
  404. ccxt/phemex.py +4473 -0
  405. ccxt/poloniex.py +2232 -0
  406. ccxt/poloniexfutures.py +1717 -0
  407. ccxt/pro/__init__.py +149 -0
  408. ccxt/pro/alpaca.py +685 -0
  409. ccxt/pro/ascendex.py +916 -0
  410. ccxt/pro/bequant.py +38 -0
  411. ccxt/pro/binance.py +3488 -0
  412. ccxt/pro/binancecoinm.py +28 -0
  413. ccxt/pro/binanceus.py +48 -0
  414. ccxt/pro/binanceusdm.py +31 -0
  415. ccxt/pro/bingx.py +1264 -0
  416. ccxt/pro/bitcoincom.py +34 -0
  417. ccxt/pro/bitfinex.py +621 -0
  418. ccxt/pro/bitfinex2.py +1083 -0
  419. ccxt/pro/bitget.py +1692 -0
  420. ccxt/pro/bithumb.py +368 -0
  421. ccxt/pro/bitmart.py +1449 -0
  422. ccxt/pro/bitmex.py +1656 -0
  423. ccxt/pro/bitopro.py +445 -0
  424. ccxt/pro/bitpanda.py +15 -0
  425. ccxt/pro/bitrue.py +447 -0
  426. ccxt/pro/bitstamp.py +522 -0
  427. ccxt/pro/bitvavo.py +1270 -0
  428. ccxt/pro/blockchaincom.py +738 -0
  429. ccxt/pro/blofin.py +692 -0
  430. ccxt/pro/bybit.py +2000 -0
  431. ccxt/pro/cex.py +1440 -0
  432. ccxt/pro/coinbase.py +678 -0
  433. ccxt/pro/coinbaseadvanced.py +16 -0
  434. ccxt/pro/coinbaseexchange.py +895 -0
  435. ccxt/pro/coinbaseinternational.py +620 -0
  436. ccxt/pro/coincatch.py +1464 -0
  437. ccxt/pro/coincheck.py +199 -0
  438. ccxt/pro/coinex.py +1061 -0
  439. ccxt/pro/coinone.py +395 -0
  440. ccxt/pro/cryptocom.py +947 -0
  441. ccxt/pro/currencycom.py +536 -0
  442. ccxt/pro/deribit.py +892 -0
  443. ccxt/pro/exmo.py +629 -0
  444. ccxt/pro/gate.py +1416 -0
  445. ccxt/pro/gateio.py +15 -0
  446. ccxt/pro/gemini.py +865 -0
  447. ccxt/pro/hashkey.py +802 -0
  448. ccxt/pro/hitbtc.py +1216 -0
  449. ccxt/pro/hollaex.py +563 -0
  450. ccxt/pro/htx.py +2215 -0
  451. ccxt/pro/huobi.py +15 -0
  452. ccxt/pro/huobijp.py +570 -0
  453. ccxt/pro/hyperliquid.py +525 -0
  454. ccxt/pro/idex.py +672 -0
  455. ccxt/pro/independentreserve.py +270 -0
  456. ccxt/pro/kraken.py +1356 -0
  457. ccxt/pro/krakenfutures.py +1492 -0
  458. ccxt/pro/kucoin.py +1133 -0
  459. ccxt/pro/kucoinfutures.py +1081 -0
  460. ccxt/pro/lbank.py +843 -0
  461. ccxt/pro/luno.py +303 -0
  462. ccxt/pro/mexc.py +1122 -0
  463. ccxt/pro/ndax.py +506 -0
  464. ccxt/pro/okcoin.py +698 -0
  465. ccxt/pro/okx.py +1851 -0
  466. ccxt/pro/onetrading.py +1275 -0
  467. ccxt/pro/oxfun.py +950 -0
  468. ccxt/pro/p2b.py +419 -0
  469. ccxt/pro/paradex.py +352 -0
  470. ccxt/pro/phemex.py +1441 -0
  471. ccxt/pro/poloniex.py +1166 -0
  472. ccxt/pro/poloniexfutures.py +990 -0
  473. ccxt/pro/probit.py +551 -0
  474. ccxt/pro/upbit.py +520 -0
  475. ccxt/pro/vertex.py +943 -0
  476. ccxt/pro/wazirx.py +749 -0
  477. ccxt/pro/whitebit.py +864 -0
  478. ccxt/pro/woo.py +1078 -0
  479. ccxt/pro/woofipro.py +1183 -0
  480. ccxt/pro/xt.py +1067 -0
  481. ccxt/probit.py +1734 -0
  482. ccxt/ramzinex.py +476 -0
  483. ccxt/sarmayex.py +357 -0
  484. ccxt/sarrafex.py +478 -0
  485. ccxt/static_dependencies/__init__.py +1 -0
  486. ccxt/static_dependencies/ecdsa/__init__.py +14 -0
  487. ccxt/static_dependencies/ecdsa/_version.py +520 -0
  488. ccxt/static_dependencies/ecdsa/curves.py +56 -0
  489. ccxt/static_dependencies/ecdsa/der.py +221 -0
  490. ccxt/static_dependencies/ecdsa/ecdsa.py +310 -0
  491. ccxt/static_dependencies/ecdsa/ellipticcurve.py +197 -0
  492. ccxt/static_dependencies/ecdsa/keys.py +332 -0
  493. ccxt/static_dependencies/ecdsa/numbertheory.py +531 -0
  494. ccxt/static_dependencies/ecdsa/rfc6979.py +100 -0
  495. ccxt/static_dependencies/ecdsa/util.py +266 -0
  496. ccxt/static_dependencies/ethereum/__init__.py +7 -0
  497. ccxt/static_dependencies/ethereum/abi/__init__.py +16 -0
  498. ccxt/static_dependencies/ethereum/abi/abi.py +19 -0
  499. ccxt/static_dependencies/ethereum/abi/base.py +152 -0
  500. ccxt/static_dependencies/ethereum/abi/codec.py +217 -0
  501. ccxt/static_dependencies/ethereum/abi/constants.py +3 -0
  502. ccxt/static_dependencies/ethereum/abi/decoding.py +565 -0
  503. ccxt/static_dependencies/ethereum/abi/encoding.py +720 -0
  504. ccxt/static_dependencies/ethereum/abi/exceptions.py +139 -0
  505. ccxt/static_dependencies/ethereum/abi/grammar.py +443 -0
  506. ccxt/static_dependencies/ethereum/abi/packed.py +13 -0
  507. ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
  508. ccxt/static_dependencies/ethereum/abi/registry.py +643 -0
  509. ccxt/static_dependencies/ethereum/abi/tools/__init__.py +3 -0
  510. ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +230 -0
  511. ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
  512. ccxt/static_dependencies/ethereum/abi/utils/numeric.py +83 -0
  513. ccxt/static_dependencies/ethereum/abi/utils/padding.py +27 -0
  514. ccxt/static_dependencies/ethereum/abi/utils/string.py +19 -0
  515. ccxt/static_dependencies/ethereum/account/__init__.py +3 -0
  516. ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +4 -0
  517. ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +239 -0
  518. ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +40 -0
  519. ccxt/static_dependencies/ethereum/account/messages.py +263 -0
  520. ccxt/static_dependencies/ethereum/account/py.typed +0 -0
  521. ccxt/static_dependencies/ethereum/hexbytes/__init__.py +5 -0
  522. ccxt/static_dependencies/ethereum/hexbytes/_utils.py +54 -0
  523. ccxt/static_dependencies/ethereum/hexbytes/main.py +65 -0
  524. ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
  525. ccxt/static_dependencies/ethereum/typing/__init__.py +63 -0
  526. ccxt/static_dependencies/ethereum/typing/abi.py +6 -0
  527. ccxt/static_dependencies/ethereum/typing/bls.py +7 -0
  528. ccxt/static_dependencies/ethereum/typing/discovery.py +5 -0
  529. ccxt/static_dependencies/ethereum/typing/encoding.py +7 -0
  530. ccxt/static_dependencies/ethereum/typing/enums.py +17 -0
  531. ccxt/static_dependencies/ethereum/typing/ethpm.py +9 -0
  532. ccxt/static_dependencies/ethereum/typing/evm.py +20 -0
  533. ccxt/static_dependencies/ethereum/typing/networks.py +1122 -0
  534. ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
  535. ccxt/static_dependencies/ethereum/utils/__init__.py +115 -0
  536. ccxt/static_dependencies/ethereum/utils/abi.py +72 -0
  537. ccxt/static_dependencies/ethereum/utils/address.py +171 -0
  538. ccxt/static_dependencies/ethereum/utils/applicators.py +151 -0
  539. ccxt/static_dependencies/ethereum/utils/conversions.py +190 -0
  540. ccxt/static_dependencies/ethereum/utils/currency.py +107 -0
  541. ccxt/static_dependencies/ethereum/utils/curried/__init__.py +269 -0
  542. ccxt/static_dependencies/ethereum/utils/debug.py +20 -0
  543. ccxt/static_dependencies/ethereum/utils/decorators.py +132 -0
  544. ccxt/static_dependencies/ethereum/utils/encoding.py +6 -0
  545. ccxt/static_dependencies/ethereum/utils/exceptions.py +4 -0
  546. ccxt/static_dependencies/ethereum/utils/functional.py +75 -0
  547. ccxt/static_dependencies/ethereum/utils/hexadecimal.py +74 -0
  548. ccxt/static_dependencies/ethereum/utils/humanize.py +188 -0
  549. ccxt/static_dependencies/ethereum/utils/logging.py +159 -0
  550. ccxt/static_dependencies/ethereum/utils/module_loading.py +31 -0
  551. ccxt/static_dependencies/ethereum/utils/numeric.py +43 -0
  552. ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
  553. ccxt/static_dependencies/ethereum/utils/toolz.py +76 -0
  554. ccxt/static_dependencies/ethereum/utils/types.py +54 -0
  555. ccxt/static_dependencies/ethereum/utils/typing/__init__.py +18 -0
  556. ccxt/static_dependencies/ethereum/utils/typing/misc.py +14 -0
  557. ccxt/static_dependencies/ethereum/utils/units.py +31 -0
  558. ccxt/static_dependencies/keccak/__init__.py +3 -0
  559. ccxt/static_dependencies/keccak/keccak.py +197 -0
  560. ccxt/static_dependencies/lark/__init__.py +38 -0
  561. ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
  562. ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
  563. ccxt/static_dependencies/lark/ast_utils.py +59 -0
  564. ccxt/static_dependencies/lark/common.py +86 -0
  565. ccxt/static_dependencies/lark/exceptions.py +292 -0
  566. ccxt/static_dependencies/lark/grammar.py +130 -0
  567. ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
  568. ccxt/static_dependencies/lark/indenter.py +143 -0
  569. ccxt/static_dependencies/lark/lark.py +658 -0
  570. ccxt/static_dependencies/lark/lexer.py +678 -0
  571. ccxt/static_dependencies/lark/load_grammar.py +1428 -0
  572. ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
  573. ccxt/static_dependencies/lark/parser_frontends.py +257 -0
  574. ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
  575. ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
  576. ccxt/static_dependencies/lark/parsers/earley.py +314 -0
  577. ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
  578. ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
  579. ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
  580. ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
  581. ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
  582. ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
  583. ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
  584. ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
  585. ccxt/static_dependencies/lark/reconstruct.py +107 -0
  586. ccxt/static_dependencies/lark/tools/__init__.py +70 -0
  587. ccxt/static_dependencies/lark/tools/nearley.py +202 -0
  588. ccxt/static_dependencies/lark/tools/serialize.py +32 -0
  589. ccxt/static_dependencies/lark/tools/standalone.py +196 -0
  590. ccxt/static_dependencies/lark/tree.py +267 -0
  591. ccxt/static_dependencies/lark/tree_matcher.py +186 -0
  592. ccxt/static_dependencies/lark/tree_templates.py +180 -0
  593. ccxt/static_dependencies/lark/utils.py +343 -0
  594. ccxt/static_dependencies/lark/visitors.py +596 -0
  595. ccxt/static_dependencies/marshmallow/__init__.py +81 -0
  596. ccxt/static_dependencies/marshmallow/base.py +65 -0
  597. ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
  598. ccxt/static_dependencies/marshmallow/decorators.py +231 -0
  599. ccxt/static_dependencies/marshmallow/error_store.py +60 -0
  600. ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
  601. ccxt/static_dependencies/marshmallow/fields.py +2114 -0
  602. ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
  603. ccxt/static_dependencies/marshmallow/schema.py +1228 -0
  604. ccxt/static_dependencies/marshmallow/types.py +12 -0
  605. ccxt/static_dependencies/marshmallow/utils.py +378 -0
  606. ccxt/static_dependencies/marshmallow/validate.py +678 -0
  607. ccxt/static_dependencies/marshmallow/warnings.py +2 -0
  608. ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
  609. ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
  610. ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
  611. ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
  612. ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
  613. ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
  614. ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
  615. ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
  616. ccxt/static_dependencies/msgpack/__init__.py +55 -0
  617. ccxt/static_dependencies/msgpack/exceptions.py +48 -0
  618. ccxt/static_dependencies/msgpack/ext.py +168 -0
  619. ccxt/static_dependencies/msgpack/fallback.py +951 -0
  620. ccxt/static_dependencies/parsimonious/__init__.py +10 -0
  621. ccxt/static_dependencies/parsimonious/exceptions.py +105 -0
  622. ccxt/static_dependencies/parsimonious/expressions.py +479 -0
  623. ccxt/static_dependencies/parsimonious/grammar.py +487 -0
  624. ccxt/static_dependencies/parsimonious/nodes.py +325 -0
  625. ccxt/static_dependencies/parsimonious/utils.py +40 -0
  626. ccxt/static_dependencies/starknet/__init__.py +0 -0
  627. ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
  628. ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
  629. ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
  630. ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
  631. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
  632. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
  633. ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
  634. ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
  635. ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
  636. ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
  637. ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
  638. ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
  639. ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
  640. ccxt/static_dependencies/starknet/common.py +15 -0
  641. ccxt/static_dependencies/starknet/constants.py +39 -0
  642. ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
  643. ccxt/static_dependencies/starknet/hash/address.py +79 -0
  644. ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
  645. ccxt/static_dependencies/starknet/hash/selector.py +16 -0
  646. ccxt/static_dependencies/starknet/hash/storage.py +12 -0
  647. ccxt/static_dependencies/starknet/hash/utils.py +78 -0
  648. ccxt/static_dependencies/starknet/models/__init__.py +0 -0
  649. ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
  650. ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
  651. ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
  652. ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
  653. ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
  654. ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
  655. ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
  656. ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
  657. ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
  658. ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
  659. ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
  660. ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
  661. ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
  662. ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
  663. ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
  664. ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
  665. ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
  666. ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
  667. ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
  668. ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
  669. ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
  670. ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
  671. ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
  672. ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
  673. ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
  674. ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
  675. ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
  676. ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
  677. ccxt/static_dependencies/starknet/utils/schema.py +13 -0
  678. ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
  679. ccxt/static_dependencies/starkware/__init__.py +0 -0
  680. ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
  681. ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
  682. ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
  683. ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
  684. ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
  685. ccxt/static_dependencies/sympy/__init__.py +0 -0
  686. ccxt/static_dependencies/sympy/core/__init__.py +0 -0
  687. ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
  688. ccxt/static_dependencies/sympy/external/__init__.py +0 -0
  689. ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
  690. ccxt/static_dependencies/sympy/external/importtools.py +187 -0
  691. ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
  692. ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
  693. ccxt/static_dependencies/toolz/__init__.py +26 -0
  694. ccxt/static_dependencies/toolz/_signatures.py +784 -0
  695. ccxt/static_dependencies/toolz/_version.py +520 -0
  696. ccxt/static_dependencies/toolz/compatibility.py +30 -0
  697. ccxt/static_dependencies/toolz/curried/__init__.py +101 -0
  698. ccxt/static_dependencies/toolz/curried/exceptions.py +22 -0
  699. ccxt/static_dependencies/toolz/curried/operator.py +22 -0
  700. ccxt/static_dependencies/toolz/dicttoolz.py +339 -0
  701. ccxt/static_dependencies/toolz/functoolz.py +1049 -0
  702. ccxt/static_dependencies/toolz/itertoolz.py +1057 -0
  703. ccxt/static_dependencies/toolz/recipes.py +46 -0
  704. ccxt/static_dependencies/toolz/utils.py +9 -0
  705. ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
  706. ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
  707. ccxt/tabdeal.py +364 -0
  708. ccxt/test/__init__.py +3 -0
  709. ccxt/test/base/__init__.py +29 -0
  710. ccxt/test/base/test_account.py +26 -0
  711. ccxt/test/base/test_balance.py +56 -0
  712. ccxt/test/base/test_borrow_interest.py +35 -0
  713. ccxt/test/base/test_borrow_rate.py +32 -0
  714. ccxt/test/base/test_calculate_fee.py +51 -0
  715. ccxt/test/base/test_crypto.py +127 -0
  716. ccxt/test/base/test_currency.py +76 -0
  717. ccxt/test/base/test_datetime.py +109 -0
  718. ccxt/test/base/test_decimal_to_precision.py +392 -0
  719. ccxt/test/base/test_deep_extend.py +68 -0
  720. ccxt/test/base/test_deposit_withdrawal.py +50 -0
  721. ccxt/test/base/test_exchange_datetime_functions.py +76 -0
  722. ccxt/test/base/test_funding_rate_history.py +29 -0
  723. ccxt/test/base/test_last_price.py +31 -0
  724. ccxt/test/base/test_ledger_entry.py +45 -0
  725. ccxt/test/base/test_ledger_item.py +48 -0
  726. ccxt/test/base/test_leverage_tier.py +33 -0
  727. ccxt/test/base/test_liquidation.py +50 -0
  728. ccxt/test/base/test_margin_mode.py +24 -0
  729. ccxt/test/base/test_margin_modification.py +35 -0
  730. ccxt/test/base/test_market.py +193 -0
  731. ccxt/test/base/test_number.py +411 -0
  732. ccxt/test/base/test_ohlcv.py +33 -0
  733. ccxt/test/base/test_open_interest.py +32 -0
  734. ccxt/test/base/test_order.py +64 -0
  735. ccxt/test/base/test_order_book.py +69 -0
  736. ccxt/test/base/test_position.py +60 -0
  737. ccxt/test/base/test_shared_methods.py +353 -0
  738. ccxt/test/base/test_status.py +24 -0
  739. ccxt/test/base/test_throttle.py +126 -0
  740. ccxt/test/base/test_ticker.py +92 -0
  741. ccxt/test/base/test_trade.py +47 -0
  742. ccxt/test/base/test_trading_fee.py +26 -0
  743. ccxt/test/base/test_transaction.py +39 -0
  744. ccxt/test/test_async.py +1649 -0
  745. ccxt/test/test_sync.py +1648 -0
  746. ccxt/test/tests_async.py +1558 -0
  747. ccxt/test/tests_helpers.py +287 -0
  748. ccxt/test/tests_init.py +39 -0
  749. ccxt/test/tests_sync.py +1555 -0
  750. ccxt/tetherland.py +349 -0
  751. ccxt/timex.py +1593 -0
  752. ccxt/tokocrypto.py +2405 -0
  753. ccxt/tradeogre.py +608 -0
  754. ccxt/twox.py +326 -0
  755. ccxt/ubitex.py +409 -0
  756. ccxt/upbit.py +1833 -0
  757. ccxt/vertex.py +2922 -0
  758. ccxt/wallex.py +445 -0
  759. ccxt/wavesexchange.py +2472 -0
  760. ccxt/wazirx.py +1224 -0
  761. ccxt/whitebit.py +2469 -0
  762. ccxt/woo.py +3114 -0
  763. ccxt/woofipro.py +2533 -0
  764. ccxt/xt.py +4453 -0
  765. ccxt/yobit.py +1283 -0
  766. ccxt/zaif.py +725 -0
  767. ccxt/zonda.py +1828 -0
  768. ccxt_ir-4.3.46.0.1.dist-info/LICENSE.txt +21 -0
  769. ccxt_ir-4.3.46.0.1.dist-info/METADATA +655 -0
  770. ccxt_ir-4.3.46.0.1.dist-info/RECORD +772 -0
  771. ccxt_ir-4.3.46.0.1.dist-info/WHEEL +6 -0
  772. ccxt_ir-4.3.46.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,2922 @@
1
+ # -*- coding: utf-8 -*-
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
+
6
+ from ccxt.async_support.base.exchange import Exchange
7
+ from ccxt.abstract.vertex import ImplicitAPI
8
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction
9
+ from typing import List
10
+ from ccxt.base.errors import ExchangeError
11
+ from ccxt.base.errors import AuthenticationError
12
+ from ccxt.base.errors import PermissionDenied
13
+ from ccxt.base.errors import ArgumentsRequired
14
+ from ccxt.base.errors import BadRequest
15
+ from ccxt.base.errors import InsufficientFunds
16
+ from ccxt.base.errors import InvalidOrder
17
+ from ccxt.base.errors import NotSupported
18
+ from ccxt.base.errors import RateLimitExceeded
19
+ from ccxt.base.decimal_to_precision import TICK_SIZE
20
+ from ccxt.base.precise import Precise
21
+
22
+
23
+ class vertex(Exchange, ImplicitAPI):
24
+
25
+ def describe(self):
26
+ return self.deep_extend(super(vertex, self).describe(), {
27
+ 'id': 'vertex',
28
+ 'name': 'Vertex',
29
+ 'countries': [],
30
+ 'version': 'v1',
31
+ 'rateLimit': 50,
32
+ 'certified': False,
33
+ 'pro': True,
34
+ 'dex': True,
35
+ 'has': {
36
+ 'CORS': None,
37
+ 'spot': True,
38
+ 'margin': False,
39
+ 'swap': True,
40
+ 'future': True,
41
+ 'option': False,
42
+ 'addMargin': False,
43
+ 'borrowCrossMargin': False,
44
+ 'borrowIsolatedMargin': False,
45
+ 'cancelAllOrders': True,
46
+ 'cancelAllOrdersAfter': False,
47
+ 'cancelOrder': True,
48
+ 'cancelOrders': True,
49
+ 'cancelOrdersForSymbols': False,
50
+ 'closeAllPositions': False,
51
+ 'closePosition': False,
52
+ 'createMarketBuyOrderWithCost': False,
53
+ 'createMarketOrderWithCost': False,
54
+ 'createMarketSellOrderWithCost': False,
55
+ 'createOrder': True,
56
+ 'createOrders': True,
57
+ 'createReduceOnlyOrder': True,
58
+ 'editOrder': False,
59
+ 'fetchAccounts': False,
60
+ 'fetchBalance': True,
61
+ 'fetchBorrowInterest': False,
62
+ 'fetchBorrowRateHistories': False,
63
+ 'fetchBorrowRateHistory': False,
64
+ 'fetchCanceledOrders': False,
65
+ 'fetchClosedOrders': False,
66
+ 'fetchCrossBorrowRate': False,
67
+ 'fetchCrossBorrowRates': False,
68
+ 'fetchCurrencies': True,
69
+ 'fetchDepositAddress': False,
70
+ 'fetchDepositAddresses': False,
71
+ 'fetchDeposits': False,
72
+ 'fetchDepositWithdrawFee': False,
73
+ 'fetchDepositWithdrawFees': False,
74
+ 'fetchFundingHistory': False,
75
+ 'fetchFundingRate': True,
76
+ 'fetchFundingRateHistory': False,
77
+ 'fetchFundingRates': True,
78
+ 'fetchIndexOHLCV': False,
79
+ 'fetchIsolatedBorrowRate': False,
80
+ 'fetchIsolatedBorrowRates': False,
81
+ 'fetchLedger': False,
82
+ 'fetchLeverage': False,
83
+ 'fetchLeverageTiers': False,
84
+ 'fetchLiquidations': False,
85
+ 'fetchMarginMode': None,
86
+ 'fetchMarketLeverageTiers': False,
87
+ 'fetchMarkets': True,
88
+ 'fetchMarkOHLCV': False,
89
+ 'fetchMyLiquidations': False,
90
+ 'fetchMyTrades': True,
91
+ 'fetchOHLCV': True,
92
+ 'fetchOpenInterest': True,
93
+ 'fetchOpenInterestHistory': False,
94
+ 'fetchOpenOrders': True,
95
+ 'fetchOrder': True,
96
+ 'fetchOrderBook': True,
97
+ 'fetchOrders': True,
98
+ 'fetchOrderTrades': False,
99
+ 'fetchPosition': False,
100
+ 'fetchPositionMode': False,
101
+ 'fetchPositions': True,
102
+ 'fetchPositionsRisk': False,
103
+ 'fetchPremiumIndexOHLCV': False,
104
+ 'fetchStatus': True,
105
+ 'fetchTicker': False,
106
+ 'fetchTickers': True,
107
+ 'fetchTime': True,
108
+ 'fetchTrades': True,
109
+ 'fetchTradingFee': False,
110
+ 'fetchTradingFees': True,
111
+ 'fetchTransfer': False,
112
+ 'fetchTransfers': False,
113
+ 'fetchWithdrawal': False,
114
+ 'fetchWithdrawals': False,
115
+ 'reduceMargin': False,
116
+ 'repayCrossMargin': False,
117
+ 'repayIsolatedMargin': False,
118
+ 'sandbox': True,
119
+ 'setLeverage': False,
120
+ 'setMarginMode': False,
121
+ 'setPositionMode': False,
122
+ 'transfer': False,
123
+ 'withdraw': True,
124
+ },
125
+ 'timeframes': {
126
+ '1m': 60,
127
+ '5m': 300,
128
+ '15m': 900,
129
+ '1h': 3600,
130
+ '2h': 7200,
131
+ '4h': 14400,
132
+ '1d': 86400,
133
+ '1w': 604800,
134
+ '1M': 604800,
135
+ },
136
+ 'hostname': 'vertexprotocol.com',
137
+ 'urls': {
138
+ 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/bd04a0fa-3b48-47b6-9d8b-124954d520a8',
139
+ 'api': {
140
+ 'v1': {
141
+ 'archive': 'https://archive.prod.{hostname}/v1',
142
+ 'gateway': 'https://gateway.prod.{hostname}/v1',
143
+ 'trigger': 'https://trigger.prod.{hostname}/v1',
144
+ },
145
+ 'v2': {
146
+ 'archive': 'https://archive.prod.{hostname}/v2',
147
+ 'gateway': 'https://gateway.prod.{hostname}/v2',
148
+ },
149
+ },
150
+ 'test': {
151
+ 'v1': {
152
+ 'archive': 'https://archive.sepolia-test.{hostname}/v1',
153
+ 'gateway': 'https://gateway.sepolia-test.{hostname}/v1',
154
+ 'trigger': 'https://trigger.sepolia-test.{hostname}/v1',
155
+ },
156
+ 'v2': {
157
+ 'archive': 'https://archive.sepolia-test.{hostname}/v2',
158
+ 'gateway': 'https://gateway.sepolia-test.{hostname}/v2',
159
+ },
160
+ },
161
+ 'www': 'https://vertexprotocol.com/',
162
+ 'doc': 'https://docs.vertexprotocol.com/',
163
+ 'fees': 'https://docs.vertexprotocol.com/basics/fees',
164
+ 'referral': 'https://app.vertexprotocol.com?referrer=0xCfC9BaB96a2eA3d3c3F031c005e82E1D9F295aC1',
165
+ },
166
+ 'api': {
167
+ 'v1': {
168
+ 'archive': {
169
+ 'post': {
170
+ '': 1,
171
+ },
172
+ },
173
+ 'gateway': {
174
+ 'get': {
175
+ 'query': 1,
176
+ 'symbols': 1,
177
+ 'time': 1,
178
+ },
179
+ 'post': {
180
+ 'query': 1,
181
+ 'execute': 1,
182
+ },
183
+ },
184
+ 'trigger': {
185
+ 'post': {
186
+ 'execute': 1,
187
+ 'query': 1,
188
+ },
189
+ },
190
+ },
191
+ 'v2': {
192
+ 'archive': {
193
+ 'get': {
194
+ 'tickers': 1,
195
+ 'contracts': 1,
196
+ 'trades': 1,
197
+ 'vrtx': 1,
198
+ },
199
+ },
200
+ 'gateway': {
201
+ 'get': {
202
+ 'assets': 0.6667,
203
+ 'pairs': 1,
204
+ 'orderbook': 1,
205
+ },
206
+ },
207
+ },
208
+ },
209
+ 'fees': {
210
+ 'swap': {
211
+ 'taker': self.parse_number('0.0002'),
212
+ 'maker': self.parse_number('0.0002'),
213
+ },
214
+ 'spot': {
215
+ 'taker': self.parse_number('0.0002'),
216
+ 'maker': self.parse_number('0.0002'),
217
+ },
218
+ },
219
+ 'requiredCredentials': {
220
+ 'apiKey': False,
221
+ 'secret': False,
222
+ 'walletAddress': True,
223
+ 'privateKey': True,
224
+ },
225
+ 'exceptions': {
226
+ 'exact': {
227
+ '1000': RateLimitExceeded,
228
+ '1015': RateLimitExceeded,
229
+ '1001': PermissionDenied,
230
+ '1002': PermissionDenied,
231
+ '1003': PermissionDenied,
232
+ '2000': InvalidOrder,
233
+ '2001': InvalidOrder,
234
+ '2002': InvalidOrder,
235
+ '2003': InvalidOrder,
236
+ '2004': InvalidOrder,
237
+ '2005': InvalidOrder,
238
+ '2006': InvalidOrder,
239
+ '2007': InvalidOrder,
240
+ '2008': InvalidOrder,
241
+ '2009': InvalidOrder,
242
+ '2010': InvalidOrder,
243
+ '2011': BadRequest,
244
+ '2012': BadRequest,
245
+ '2013': InvalidOrder,
246
+ '2014': PermissionDenied,
247
+ '2015': InvalidOrder,
248
+ '2016': InvalidOrder,
249
+ '2017': InvalidOrder,
250
+ '2019': InvalidOrder,
251
+ '2020': InvalidOrder,
252
+ '2021': InvalidOrder,
253
+ '2022': InvalidOrder,
254
+ '2023': InvalidOrder,
255
+ '2024': InsufficientFunds,
256
+ '2025': InsufficientFunds,
257
+ '2026': BadRequest,
258
+ '2027': AuthenticationError,
259
+ '2028': AuthenticationError,
260
+ '2029': AuthenticationError,
261
+ '2030': BadRequest,
262
+ '2031': InvalidOrder,
263
+ '2033': InvalidOrder,
264
+ '2034': InvalidOrder,
265
+ '2035': InvalidOrder,
266
+ '2036': InvalidOrder,
267
+ '2037': InvalidOrder,
268
+ '2038': InvalidOrder,
269
+ '2039': InvalidOrder,
270
+ '2040': InvalidOrder,
271
+ '2041': InvalidOrder,
272
+ '2042': InvalidOrder,
273
+ '2043': InvalidOrder,
274
+ '2044': InvalidOrder,
275
+ '2045': InvalidOrder,
276
+ '2046': InvalidOrder,
277
+ '2047': InvalidOrder,
278
+ '2048': InvalidOrder,
279
+ '2049': ExchangeError,
280
+ '2050': PermissionDenied,
281
+ '2051': InvalidOrder,
282
+ '2052': InvalidOrder,
283
+ '2053': InvalidOrder,
284
+ '2054': InvalidOrder,
285
+ '2055': InvalidOrder,
286
+ '2056': InvalidOrder,
287
+ '2057': InvalidOrder,
288
+ '2058': InvalidOrder,
289
+ '2059': InvalidOrder,
290
+ '2060': InvalidOrder,
291
+ '2061': InvalidOrder,
292
+ '2062': InvalidOrder,
293
+ '2063': InvalidOrder,
294
+ '2064': InvalidOrder,
295
+ '2065': InvalidOrder,
296
+ '2066': InvalidOrder,
297
+ '2067': InvalidOrder,
298
+ '2068': InvalidOrder,
299
+ '2069': InvalidOrder,
300
+ '2070': InvalidOrder,
301
+ '2071': InvalidOrder,
302
+ '2072': InvalidOrder,
303
+ '2073': InvalidOrder,
304
+ '2074': InvalidOrder,
305
+ '2075': InvalidOrder,
306
+ '2076': InvalidOrder,
307
+ '3000': BadRequest,
308
+ '3001': BadRequest,
309
+ '3002': BadRequest,
310
+ '3003': BadRequest,
311
+ '4000': BadRequest,
312
+ '4001': ExchangeError,
313
+ '4002': ExchangeError,
314
+ '4003': ExchangeError,
315
+ '4004': InvalidOrder,
316
+ '5000': ExchangeError,
317
+ },
318
+ 'broad': {
319
+ },
320
+ },
321
+ 'precisionMode': TICK_SIZE,
322
+ 'commonCurrencies': {
323
+ },
324
+ 'options': {
325
+ 'defaultType': 'swap',
326
+ 'sandboxMode': False,
327
+ 'timeDifference': 0, # the difference between system clock and exchange server clock
328
+ 'brokerId': 5930043274845996,
329
+ },
330
+ })
331
+
332
+ def set_sandbox_mode(self, enabled):
333
+ super(vertex, self).set_sandbox_mode(enabled)
334
+ self.options['sandboxMode'] = enabled
335
+
336
+ def convert_to_x18(self, num):
337
+ if isinstance(num, str):
338
+ return Precise.string_mul(num, '1000000000000000000')
339
+ numStr = self.number_to_string(num)
340
+ return Precise.string_mul(numStr, '1000000000000000000')
341
+
342
+ def convert_from_x18(self, num):
343
+ if isinstance(num, str):
344
+ return Precise.string_div(num, '1000000000000000000')
345
+ numStr = self.number_to_string(num)
346
+ return Precise.string_div(numStr, '1000000000000000000')
347
+
348
+ async def fetch_currencies(self, params={}) -> Currencies:
349
+ """
350
+ fetches all available currencies on an exchange
351
+
352
+ https://docs.vertexprotocol.com/developer-resources/api/v2/assets
353
+
354
+ :param dict [params]: extra parameters specific to the exchange API endpoint
355
+ :returns dict: an associative dictionary of currencies
356
+ """
357
+ request = {}
358
+ response = await self.v2GatewayGetAssets(self.extend(request, params))
359
+ #
360
+ # [
361
+ # {
362
+ # "product_id": 2,
363
+ # "ticker_id": "BTC-PERP_USDC",
364
+ # "market_type": "perp",
365
+ # "name": "Bitcoin Perp",
366
+ # "symbol": "BTC-PERP",
367
+ # "maker_fee": 0.0002,
368
+ # "taker_fee": 0,
369
+ # "can_withdraw": False,
370
+ # "can_deposit": False
371
+ # },
372
+ # {
373
+ # "product_id": 1,
374
+ # "ticker_id": "BTC_USDC",
375
+ # "market_type": "spot",
376
+ # "name": "Bitcoin",
377
+ # "symbol": "BTC",
378
+ # "taker_fee": 0.0003,
379
+ # "maker_fee": 0,
380
+ # "can_withdraw": True,
381
+ # "can_deposit": True
382
+ # }
383
+ # ]
384
+ #
385
+ result = {}
386
+ for i in range(0, len(response)):
387
+ data = self.safe_dict(response, i, {})
388
+ tickerId = self.safe_string(data, 'ticker_id')
389
+ if (tickerId is not None) and (tickerId.find('PERP') > 0):
390
+ continue
391
+ id = self.safe_string(data, 'product_id')
392
+ name = self.safe_string(data, 'symbol')
393
+ code = self.safe_currency_code(name)
394
+ result[code] = {
395
+ 'id': id,
396
+ 'name': name,
397
+ 'code': code,
398
+ 'precision': None,
399
+ 'info': data,
400
+ 'active': None,
401
+ 'deposit': self.safe_bool(data, 'can_deposit'),
402
+ 'withdraw': self.safe_bool(data, 'can_withdraw'),
403
+ 'networks': None,
404
+ 'fee': None,
405
+ 'limits': {
406
+ 'amount': {
407
+ 'min': None,
408
+ 'max': None,
409
+ },
410
+ 'withdraw': {
411
+ 'min': None,
412
+ 'max': None,
413
+ },
414
+ },
415
+ }
416
+ return result
417
+
418
+ def parse_market(self, market) -> Market:
419
+ #
420
+ # {
421
+ # "type": "spot",
422
+ # "product_id": 3,
423
+ # "symbol": "WETH",
424
+ # "price_increment_x18": "100000000000000000",
425
+ # "size_increment": "10000000000000000",
426
+ # "min_size": "100000000000000000",
427
+ # "min_depth_x18": "5000000000000000000000",
428
+ # "max_spread_rate_x18": "2000000000000000",
429
+ # "maker_fee_rate_x18": "0",
430
+ # "taker_fee_rate_x18": "300000000000000",
431
+ # "long_weight_initial_x18": "900000000000000000",
432
+ # "long_weight_maintenance_x18": "950000000000000000"
433
+ # }
434
+ #
435
+ marketType = self.safe_string(market, 'type')
436
+ quoteId = 'USDC'
437
+ quote = self.safe_currency_code(quoteId)
438
+ baseId = self.safe_string(market, 'symbol')
439
+ base = self.safe_currency_code(baseId)
440
+ settleId = quoteId
441
+ settle = self.safe_currency_code(settleId)
442
+ symbol = base + '/' + quote
443
+ spot = marketType == 'spot'
444
+ contract = not spot
445
+ swap = not spot
446
+ if swap:
447
+ splitSymbol = base.split('-')
448
+ symbol = splitSymbol[0] + '/' + quote + ':' + settle
449
+ priceIncrementX18 = self.safe_string(market, 'price_increment_x18')
450
+ sizeIncrementX18 = self.safe_string(market, 'size_increment')
451
+ minSizeX18 = self.safe_string(market, 'min_size')
452
+ takerX18 = self.safe_number(market, 'taker_fee_rate_x18')
453
+ makerX18 = self.safe_number(market, 'maker_fee_rate_x18')
454
+ isInverse = None if (spot) else False
455
+ isLinear = None if (spot) else True
456
+ contractSize = None if (spot) else self.parse_number('1')
457
+ return {
458
+ 'id': self.safe_string(market, 'product_id'),
459
+ 'symbol': symbol,
460
+ 'base': base,
461
+ 'quote': quote,
462
+ 'settle': None if (spot) else settle,
463
+ 'baseId': baseId,
464
+ 'quoteId': quoteId,
465
+ 'settleId': None if (spot) else settleId,
466
+ 'type': 'spot' if (spot) else 'swap',
467
+ 'spot': spot,
468
+ 'margin': None,
469
+ 'swap': swap,
470
+ 'future': False,
471
+ 'option': False,
472
+ 'active': True,
473
+ 'contract': contract,
474
+ 'linear': isLinear,
475
+ 'inverse': isInverse,
476
+ 'taker': self.parse_number(self.convert_from_x18(takerX18)),
477
+ 'maker': self.parse_number(self.convert_from_x18(makerX18)),
478
+ 'contractSize': contractSize,
479
+ 'expiry': None,
480
+ 'expiryDatetime': None,
481
+ 'strike': None,
482
+ 'optionType': None,
483
+ 'precision': {
484
+ 'amount': self.parse_number(self.convert_from_x18(sizeIncrementX18)),
485
+ 'price': self.parse_number(self.convert_from_x18(priceIncrementX18)),
486
+ },
487
+ 'limits': {
488
+ 'leverage': {
489
+ 'min': None,
490
+ 'max': None,
491
+ },
492
+ 'amount': {
493
+ 'min': self.parse_number(self.convert_from_x18(minSizeX18)),
494
+ 'max': None,
495
+ },
496
+ 'price': {
497
+ 'min': None,
498
+ 'max': None,
499
+ },
500
+ 'cost': {
501
+ 'min': None,
502
+ 'max': None,
503
+ },
504
+ },
505
+ 'created': None,
506
+ 'info': market,
507
+ }
508
+
509
+ async def fetch_markets(self, params={}) -> List[Market]:
510
+ """
511
+ retrieves data on all markets for vertex
512
+
513
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/symbols
514
+
515
+ :param dict [params]: extra parameters specific to the exchange API endpoint
516
+ :returns dict[]: an array of objects representing market data
517
+ """
518
+ request = {
519
+ 'type': 'symbols',
520
+ }
521
+ response = await self.v1GatewayGetQuery(self.extend(request, params))
522
+ #
523
+ # {
524
+ # "status": "success",
525
+ # "data": {
526
+ # "symbols": {
527
+ # "WETH": {
528
+ # "type": "spot",
529
+ # "product_id": 3,
530
+ # "symbol": "WETH",
531
+ # "price_increment_x18": "100000000000000000",
532
+ # "size_increment": "10000000000000000",
533
+ # "min_size": "100000000000000000",
534
+ # "min_depth_x18": "5000000000000000000000",
535
+ # "max_spread_rate_x18": "2000000000000000",
536
+ # "maker_fee_rate_x18": "0",
537
+ # "taker_fee_rate_x18": "300000000000000",
538
+ # "long_weight_initial_x18": "900000000000000000",
539
+ # "long_weight_maintenance_x18": "950000000000000000"
540
+ # }
541
+ # }
542
+ # },
543
+ # "request_type": "query_symbols"
544
+ # }
545
+ #
546
+ data = self.safe_dict(response, 'data', {})
547
+ markets = self.safe_dict(data, 'symbols', {})
548
+ symbols = list(markets.keys())
549
+ result = []
550
+ for i in range(0, len(symbols)):
551
+ symbol = symbols[i]
552
+ rawMarket = self.safe_dict(markets, symbol, {})
553
+ result.append(self.parse_market(rawMarket))
554
+ return result
555
+
556
+ async def fetch_time(self, params={}):
557
+ """
558
+ fetches the current integer timestamp in milliseconds from the exchange server
559
+ :param dict [params]: extra parameters specific to the exchange API endpoint
560
+ :returns int: the current integer timestamp in milliseconds from the exchange server
561
+ """
562
+ response = await self.v1GatewayGetTime(params)
563
+ # 1717481623452
564
+ return self.parse_number(response)
565
+
566
+ async def fetch_status(self, params={}):
567
+ """
568
+ the latest known information on the availability of the exchange API
569
+
570
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/status
571
+
572
+ :param dict [params]: extra parameters specific to the exchange API endpoint
573
+ :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
574
+ """
575
+ request = {
576
+ 'type': 'status',
577
+ }
578
+ response = await self.v1GatewayGetQuery(self.extend(request, params))
579
+ #
580
+ # {
581
+ # "status": "success",
582
+ # "data": "active",
583
+ # "request_type": "query_status",
584
+ # }
585
+ #
586
+ status = self.safe_string(response, 'data')
587
+ if status == 'active':
588
+ status = 'ok'
589
+ else:
590
+ status = 'error'
591
+ return {
592
+ 'status': status,
593
+ 'updated': None,
594
+ 'eta': None,
595
+ 'url': None,
596
+ 'info': response,
597
+ }
598
+
599
+ def parse_trade(self, trade, market: Market = None) -> Trade:
600
+ #
601
+ # {
602
+ # "ticker_id": "ARB_USDC",
603
+ # "trade_id": 999994,
604
+ # "price": 1.1366122408151016,
605
+ # "base_filled": 175,
606
+ # "quote_filled": -198.90714214264278,
607
+ # "timestamp": 1691068943,
608
+ # "trade_type": "buy"
609
+ # }
610
+ # fetchMytrades
611
+ # {
612
+ # "digest": "0x80ce789702b670b7d33f2aa67e12c85f124395c3f9acdb422dde3b4973ccd50c",
613
+ # "order": {
614
+ # "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
615
+ # "priceX18": "27544000000000000000000",
616
+ # "amount": "2000000000000000000",
617
+ # "expiration": "4611686020107119633",
618
+ # "nonce": "1761322608857448448"
619
+ # },
620
+ # "base_filled": "736000000000000000",
621
+ # "quote_filled": "-20276464287857571514302",
622
+ # "fee": "4055287857571514302",
623
+ # "sequencer_fee": "0"
624
+ # "cumulative_fee": "4055287857571514302",
625
+ # "cumulative_base_filled": "736000000000000000",
626
+ # "cumulative_quote_filled": "-20276464287857571514302",
627
+ # "submission_idx": "563012",
628
+ # "pre_balance": {
629
+ # "base": {
630
+ # "perp": {
631
+ # "product_id": 2,
632
+ # "lp_balance": {
633
+ # "amount": "0",
634
+ # "last_cumulative_funding_x18": "1823351297710837"
635
+ # },
636
+ # "balance": {
637
+ # "amount": "2686684000000000000000",
638
+ # "v_quote_balance": "-76348662407149297671587247",
639
+ # "last_cumulative_funding_x18": "134999841911604906604576"
640
+ # }
641
+ # }
642
+ # },
643
+ # "quote": null
644
+ # },
645
+ # "post_balance": {
646
+ # "base": {
647
+ # "perp": {
648
+ # "product_id": 2,
649
+ # "lp_balance": {
650
+ # "amount": "0",
651
+ # "last_cumulative_funding_x18": "1823351297710837"
652
+ # },
653
+ # "balance": {
654
+ # "amount": "2686013000000000000000",
655
+ # "v_quote_balance": "-76328351274188497671587247",
656
+ # "last_cumulative_funding_x18": "134999841911604906604576"
657
+ # }
658
+ # }
659
+ # },
660
+ # "quote": null
661
+ # }
662
+ # }
663
+ price = None
664
+ amount = None
665
+ side = None
666
+ fee = None
667
+ feeCost = self.convert_from_x18(self.safe_string(trade, 'fee'))
668
+ if feeCost is not None:
669
+ fee = {
670
+ 'cost': feeCost,
671
+ 'currency': None,
672
+ }
673
+ id = self.safe_string_2(trade, 'trade_id', 'submission_idx')
674
+ order = self.safe_string(trade, 'digest')
675
+ timestamp = self.safe_timestamp(trade, 'timestamp')
676
+ if timestamp is None:
677
+ # fetchMyTrades
678
+ baseBalance = self.safe_dict(self.safe_dict(trade, 'pre_balance', {}), 'base', {})
679
+ marketId = None
680
+ if 'perp' in baseBalance:
681
+ marketId = self.safe_string(self.safe_dict(baseBalance, 'perp', {}), 'product_id')
682
+ else:
683
+ marketId = self.safe_string(self.safe_dict(baseBalance, 'spot', {}), 'product_id')
684
+ market = self.safe_market(marketId)
685
+ subOrder = self.safe_dict(trade, 'order', {})
686
+ price = self.convert_from_x18(self.safe_string(subOrder, 'priceX18'))
687
+ amount = self.convert_from_x18(self.safe_string(trade, 'base_filled'))
688
+ if Precise.string_lt(amount, '0'):
689
+ side = 'sell'
690
+ else:
691
+ side = 'buy'
692
+ else:
693
+ tickerId = self.safe_string(trade, 'ticker_id')
694
+ splitTickerId = tickerId.split('_')
695
+ splitSymbol = splitTickerId[0].split('-')
696
+ marketId = splitSymbol[0] + splitTickerId[1]
697
+ market = self.safe_market(marketId, market)
698
+ price = self.safe_string(trade, 'price')
699
+ amount = self.safe_string(trade, 'base_filled')
700
+ side = self.safe_string_lower(trade, 'trade_type')
701
+ amount = Precise.string_abs(amount)
702
+ symbol = market['symbol']
703
+ return self.safe_trade({
704
+ 'id': id,
705
+ 'timestamp': timestamp,
706
+ 'datetime': self.iso8601(timestamp),
707
+ 'symbol': symbol,
708
+ 'side': side,
709
+ 'price': price,
710
+ 'amount': amount,
711
+ 'cost': None,
712
+ 'order': order,
713
+ 'takerOrMaker': None,
714
+ 'type': None,
715
+ 'fee': fee,
716
+ 'info': trade,
717
+ }, market)
718
+
719
+ async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
720
+ """
721
+ get the list of most recent trades for a particular symbol
722
+
723
+ https://docs.vertexprotocol.com/developer-resources/api/v2/trades
724
+
725
+ :param str symbol: unified symbol of the market to fetch trades for
726
+ :param int [since]: timestamp in ms of the earliest trade to fetch
727
+ :param int [limit]: the maximum amount of trades to fetch
728
+ :param dict [params]: extra parameters specific to the exchange API endpoint
729
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
730
+ """
731
+ await self.load_markets()
732
+ market = self.market(symbol)
733
+ marketId = market['baseId'] + '_USDC'
734
+ request = {
735
+ 'ticker_id': marketId,
736
+ }
737
+ if limit is not None:
738
+ request['limit'] = limit
739
+ response = await self.v2ArchiveGetTrades(self.extend(request, params))
740
+ #
741
+ # [
742
+ # {
743
+ # "ticker_id": "ARB_USDC",
744
+ # "trade_id": 999994,
745
+ # "price": 1.1366122408151016,
746
+ # "base_filled": 175,
747
+ # "quote_filled": -198.90714214264278,
748
+ # "timestamp": 1691068943,
749
+ # "trade_type": "buy"
750
+ # },
751
+ # {
752
+ # "ticker_id": "ARB_USDC",
753
+ # "trade_id": 999978,
754
+ # "price": 1.136512210806099,
755
+ # "base_filled": 175,
756
+ # "quote_filled": -198.8896368910673,
757
+ # "timestamp": 1691068882,
758
+ # "trade_type": "buy"
759
+ # }
760
+ # ]
761
+ #
762
+ return self.parse_trades(response, market, since, limit)
763
+
764
+ async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
765
+ """
766
+ fetch all trades made by the user
767
+
768
+ https://docs.vertexprotocol.com/developer-resources/api/archive-indexer/matches
769
+
770
+ :param str symbol: unified market symbol
771
+ :param int [since]: the earliest time in ms to fetch trades for
772
+ :param int [limit]: the maximum number of trades structures to retrieve
773
+ :param dict [params]: extra parameters specific to the exchange API endpoint
774
+ :param str [params.user]: user address, will default to self.walletAddress if not provided
775
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
776
+ """
777
+ await self.load_markets()
778
+ userAddress = None
779
+ userAddress, params = self.handle_public_address('fetchMyTrades', params)
780
+ market: Market = None
781
+ matchesRequest = {
782
+ 'subaccount': self.convert_address_to_sender(userAddress),
783
+ }
784
+ if symbol is not None:
785
+ market = self.market(symbol)
786
+ matchesRequest['product_ids'] = [self.parse_to_numeric(market['id'])]
787
+ until = self.safe_integer(params, 'until')
788
+ if until is not None:
789
+ params = self.omit(params, 'until')
790
+ matchesRequest['max_time'] = until
791
+ if limit is not None:
792
+ matchesRequest['limit'] = limit
793
+ request = {
794
+ 'matches': matchesRequest,
795
+ }
796
+ response = await self.v1ArchivePost(self.extend(request, params))
797
+ #
798
+ # {
799
+ # "matches": [
800
+ # {
801
+ # "digest": "0x80ce789702b670b7d33f2aa67e12c85f124395c3f9acdb422dde3b4973ccd50c",
802
+ # "order": {
803
+ # "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
804
+ # "priceX18": "27544000000000000000000",
805
+ # "amount": "2000000000000000000",
806
+ # "expiration": "4611686020107119633",
807
+ # "nonce": "1761322608857448448"
808
+ # },
809
+ # "base_filled": "736000000000000000",
810
+ # "quote_filled": "-20276464287857571514302",
811
+ # "fee": "4055287857571514302",
812
+ # "sequencer_fee": "0"
813
+ # "cumulative_fee": "4055287857571514302",
814
+ # "cumulative_base_filled": "736000000000000000",
815
+ # "cumulative_quote_filled": "-20276464287857571514302",
816
+ # "submission_idx": "563012",
817
+ # "pre_balance": {
818
+ # "base": {
819
+ # "perp": {
820
+ # "product_id": 2,
821
+ # "lp_balance": {
822
+ # "amount": "0",
823
+ # "last_cumulative_funding_x18": "1823351297710837"
824
+ # },
825
+ # "balance": {
826
+ # "amount": "2686684000000000000000",
827
+ # "v_quote_balance": "-76348662407149297671587247",
828
+ # "last_cumulative_funding_x18": "134999841911604906604576"
829
+ # }
830
+ # }
831
+ # },
832
+ # "quote": null
833
+ # },
834
+ # "post_balance": {
835
+ # "base": {
836
+ # "perp": {
837
+ # "product_id": 2,
838
+ # "lp_balance": {
839
+ # "amount": "0",
840
+ # "last_cumulative_funding_x18": "1823351297710837"
841
+ # },
842
+ # "balance": {
843
+ # "amount": "2686013000000000000000",
844
+ # "v_quote_balance": "-76328351274188497671587247",
845
+ # "last_cumulative_funding_x18": "134999841911604906604576"
846
+ # }
847
+ # }
848
+ # },
849
+ # "quote": null
850
+ # }
851
+ # },
852
+ # {
853
+ # "digest": "0x0f6e5a0434e36d8e6d4fed950d3624b0d8c91a8a84efd156bb25c1382561c0c2",
854
+ # "order": {
855
+ # "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
856
+ # "priceX18": "27540000000000000000000",
857
+ # "amount": "2000000000000000000",
858
+ # "expiration": "4611686020107119623",
859
+ # "nonce": "1761322602510417920"
860
+ # },
861
+ # "base_filled": "723999999999999999",
862
+ # "quote_filled": "-19944943483044913474043",
863
+ # "fee": "5983483044913474042",
864
+ # "cumulative_fee": "11958484645393618085",
865
+ # "cumulative_base_filled": "1446999999999999998",
866
+ # "cumulative_quote_filled": "-39861640484645393618087",
867
+ # "submission_idx": "563011",
868
+ # "pre_balance": {
869
+ # "base": {
870
+ # "perp": {
871
+ # "product_id": 2,
872
+ # "lp_balance": {
873
+ # "amount": "0",
874
+ # "last_cumulative_funding_x18": "1823351297710837"
875
+ # },
876
+ # "balance": {
877
+ # "amount": "2686684000000000000000",
878
+ # "v_quote_balance": "-76348662407149297671587247",
879
+ # "last_cumulative_funding_x18": "134999841911604906604576"
880
+ # }
881
+ # }
882
+ # },
883
+ # "quote": null
884
+ # },
885
+ # "post_balance": {
886
+ # "base": {
887
+ # "perp": {
888
+ # "product_id": 2,
889
+ # "lp_balance": {
890
+ # "amount": "0",
891
+ # "last_cumulative_funding_x18": "1823351297710837"
892
+ # },
893
+ # "balance": {
894
+ # "amount": "2686013000000000000000",
895
+ # "v_quote_balance": "-76328351274188497671587247",
896
+ # "last_cumulative_funding_x18": "134999841911604906604576"
897
+ # }
898
+ # }
899
+ # },
900
+ # "quote": null
901
+ # }
902
+ # }
903
+ # ],
904
+ # "txs": [
905
+ # {
906
+ # "tx": {
907
+ # "match_orders": {
908
+ # "product_id": 2,
909
+ # "amm": True,
910
+ # "taker": {
911
+ # "order": {
912
+ # "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
913
+ # "price_x18": "27544000000000000000000",
914
+ # "amount": "2000000000000000000",
915
+ # "expiration": 4611686020107120000,
916
+ # "nonce": 1761322608857448400
917
+ # },
918
+ # "signature": "0xe8fa7151bde348afa3b46dc52798046b7c8318f1b0a7f689710debbc094658cc1bf5a7e478ccc8278b625da0b9402c86b580d2e31e13831337dfd6153f4b37811b"
919
+ # },
920
+ # "maker": {
921
+ # "order": {
922
+ # "sender": "0xebdbbcdbd2646c5f23a1e0806027eee5f71b074664656661756c740000000000",
923
+ # "price_x18": "27544000000000000000000",
924
+ # "amount": "-736000000000000000",
925
+ # "expiration": 1679731669,
926
+ # "nonce": 1761322585591644200
927
+ # },
928
+ # "signature": "0x47f9d47f0777f3ca0b13f07b7682dbeea098c0e377b87dcb025754fe34c900e336b8c7744e021fb9c46a4f8c6a1478bafa28bf0d023ae496aa3efa4d8e81df181c"
929
+ # }
930
+ # }
931
+ # },
932
+ # "submission_idx": "563012",
933
+ # "timestamp": "1679728133"
934
+ # },
935
+ # {
936
+ # "tx": {
937
+ # "match_orders": {
938
+ # "product_id": 1,
939
+ # "amm": True,
940
+ # "taker": {
941
+ # "order": {
942
+ # "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
943
+ # "price_x18": "27540000000000000000000",
944
+ # "amount": "2000000000000000000",
945
+ # "expiration": 4611686020107120000,
946
+ # "nonce": 1761322602510418000
947
+ # },
948
+ # "signature": "0x826c68f1a3f76d9ffbe8041f8d45e969d31f1ab6f2ae2f6379d1493e479e56436091d6cf4c72e212dd2f1d2fa17c627c4c21bd6d281c77172b8af030488478b71c"
949
+ # },
950
+ # "maker": {
951
+ # "order": {
952
+ # "sender": "0xf8d240d9514c9a4715d66268d7af3b53d619642564656661756c740000000000",
953
+ # "price_x18": "27540000000000000000000",
954
+ # "amount": "-724000000000000000",
955
+ # "expiration": 1679731656,
956
+ # "nonce": 1761322565506171000
957
+ # },
958
+ # "signature": "0xd8b6505b8d9b8c3cbfe793080976388035682c02a27893fb26b48a5b2bfe943f4162dea3a42e24e0dff5e2f74fbf77e33d83619140a2a581117c55e6cc236bdb1c"
959
+ # }
960
+ # }
961
+ # },
962
+ # "submission_idx": "563011",
963
+ # "timestamp": "1679728127"
964
+ # }
965
+ # ]
966
+ # }
967
+ #
968
+ trades = self.safe_list(response, 'matches', [])
969
+ return self.parse_trades(trades, market, since, limit, params)
970
+
971
+ async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
972
+ """
973
+ fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
974
+
975
+ https://docs.vertexprotocol.com/developer-resources/api/v2/orderbook
976
+
977
+ :param str symbol: unified symbol of the market to fetch the order book for
978
+ :param int [limit]: the maximum amount of order book entries to return
979
+ :param dict [params]: extra parameters specific to the exchange API endpoint
980
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
981
+ """
982
+ await self.load_markets()
983
+ market = self.market(symbol)
984
+ marketId = market['baseId'] + '_USDC'
985
+ if limit is None:
986
+ limit = 100
987
+ request = {
988
+ 'ticker_id': marketId,
989
+ 'depth': limit,
990
+ }
991
+ response = await self.v2GatewayGetOrderbook(self.extend(request, params))
992
+ #
993
+ # {
994
+ # "ticker_id": "ETH-PERP_USDC",
995
+ # "bids": [
996
+ # [
997
+ # 1612.3,
998
+ # 0.31
999
+ # ],
1000
+ # [
1001
+ # 1612.0,
1002
+ # 0.93
1003
+ # ],
1004
+ # [
1005
+ # 1611.5,
1006
+ # 1.55
1007
+ # ],
1008
+ # [
1009
+ # 1610.8,
1010
+ # 2.17
1011
+ # ]
1012
+ # ],
1013
+ # "asks": [
1014
+ # [
1015
+ # 1612.9,
1016
+ # 0.93
1017
+ # ],
1018
+ # [
1019
+ # 1613.4,
1020
+ # 1.55
1021
+ # ],
1022
+ # [
1023
+ # 1614.1,
1024
+ # 2.17
1025
+ # ]
1026
+ # ],
1027
+ # "timestamp": 1694375362016
1028
+ # }
1029
+ #
1030
+ timestamp = self.safe_integer(response, 'timestamp')
1031
+ return self.parse_order_book(response, symbol, timestamp, 'bids', 'asks')
1032
+
1033
+ async def fetch_trading_fees(self, params={}) -> TradingFees:
1034
+ """
1035
+ fetch the trading fees for multiple markets
1036
+
1037
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/fee-rates
1038
+
1039
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1040
+ :param str [params.user]: user address, will default to self.walletAddress if not provided
1041
+ :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
1042
+ """
1043
+ await self.load_markets()
1044
+ userAddress = None
1045
+ userAddress, params = self.handle_public_address('fetchTradingFees', params)
1046
+ request = {
1047
+ 'type': 'fee_rates',
1048
+ 'sender': self.convert_address_to_sender(userAddress),
1049
+ }
1050
+ response = await self.v1GatewayGetQuery(self.extend(request, params))
1051
+ #
1052
+ # {
1053
+ # "status": "success",
1054
+ # "data": {
1055
+ # "taker_fee_rates_x18": [
1056
+ # "0",
1057
+ # "300000000000000",
1058
+ # "200000000000000",
1059
+ # "300000000000000",
1060
+ # "200000000000000"
1061
+ # ],
1062
+ # "maker_fee_rates_x18": [
1063
+ # "0",
1064
+ # "0",
1065
+ # "0",
1066
+ # "0",
1067
+ # "0"
1068
+ # ],
1069
+ # "liquidation_sequencer_fee": "250000000000000000",
1070
+ # "health_check_sequencer_fee": "100000000000000000",
1071
+ # "taker_sequencer_fee": "25000000000000000",
1072
+ # "withdraw_sequencer_fees": [
1073
+ # "10000000000000000",
1074
+ # "40000000000000",
1075
+ # "0",
1076
+ # "600000000000000",
1077
+ # "0"
1078
+ # ]
1079
+ # },
1080
+ # "request_type": "query_fee_rates",
1081
+ # }
1082
+ #
1083
+ data = self.safe_dict(response, 'data', {})
1084
+ maker = self.safe_list(data, 'maker_fee_rates_x18', [])
1085
+ taker = self.safe_list(data, 'taker_fee_rates_x18', [])
1086
+ result = {}
1087
+ for i in range(0, len(taker)):
1088
+ market = self.safe_market(self.number_to_string(i))
1089
+ if market['id'] is None:
1090
+ continue
1091
+ symbol = market['symbol']
1092
+ result[symbol] = {
1093
+ 'info': response,
1094
+ 'symbol': symbol,
1095
+ 'maker': self.parse_number(self.convert_from_x18(maker[i])),
1096
+ 'taker': self.parse_number(self.convert_from_x18(taker[i])),
1097
+ 'percentage': True,
1098
+ 'tierBased': False,
1099
+ }
1100
+ return result
1101
+
1102
+ def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
1103
+ # example response in fetchOHLCV
1104
+ return [
1105
+ self.safe_timestamp(ohlcv, 'timestamp'),
1106
+ self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'open_x18'))),
1107
+ self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'high_x18'))),
1108
+ self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'low_x18'))),
1109
+ self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'close_x18'))),
1110
+ self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'volume'))),
1111
+ ]
1112
+
1113
+ async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1114
+ """
1115
+
1116
+ https://docs.vertexprotocol.com/developer-resources/api/archive-indexer/candlesticks
1117
+
1118
+ fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1119
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
1120
+ :param str timeframe: the length of time each candle represents
1121
+ :param int [since]: timestamp in ms of the earliest candle to fetch
1122
+ :param int [limit]: max=1000, max=100 when since is defined and is less than(now - (999 * (timeframe in ms)))
1123
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1124
+ :returns int[][]: A list of candles ordered, open, high, low, close, volume
1125
+ """
1126
+ await self.load_markets()
1127
+ market = self.market(symbol)
1128
+ ohlcvRequest = {
1129
+ 'product_id': self.parse_to_int(market['id']),
1130
+ 'granularity': self.safe_integer(self.timeframes, timeframe),
1131
+ }
1132
+ until = self.safe_integer(params, 'until')
1133
+ if until is not None:
1134
+ params = self.omit(params, 'until')
1135
+ ohlcvRequest['max_time'] = until
1136
+ if limit is not None:
1137
+ ohlcvRequest['limit'] = min(limit, 1000)
1138
+ request = {
1139
+ 'candlesticks': ohlcvRequest,
1140
+ }
1141
+ response = await self.v1ArchivePost(self.extend(request, params))
1142
+ #
1143
+ # {
1144
+ # "candlesticks": [
1145
+ # {
1146
+ # "product_id": 1,
1147
+ # "granularity": 60,
1148
+ # "submission_idx": "627709",
1149
+ # "timestamp": "1680118140",
1150
+ # "open_x18": "27235000000000000000000",
1151
+ # "high_x18": "27298000000000000000000",
1152
+ # "low_x18": "27235000000000000000000",
1153
+ # "close_x18": "27298000000000000000000",
1154
+ # "volume": "1999999999999999998"
1155
+ # },
1156
+ # {
1157
+ # "product_id": 1,
1158
+ # "granularity": 60,
1159
+ # "submission_idx": "627699",
1160
+ # "timestamp": "1680118080",
1161
+ # "open_x18": "27218000000000000000000",
1162
+ # "high_x18": "27245000000000000000000",
1163
+ # "low_x18": "27218000000000000000000",
1164
+ # "close_x18": "27245000000000000000000",
1165
+ # "volume": "11852999999999999995"
1166
+ # }
1167
+ # ]
1168
+ # }
1169
+ #
1170
+ rows = self.safe_list(response, 'candlesticks', [])
1171
+ return self.parse_ohlcvs(rows, market, timeframe, since, limit)
1172
+
1173
+ def parse_funding_rate(self, ticker, market: Market = None) -> FundingRate:
1174
+ #
1175
+ # {
1176
+ # "product_id": 4,
1177
+ # "funding_rate_x18": "2447900598160952",
1178
+ # "update_time": "1680116326"
1179
+ # }
1180
+ #
1181
+ # {
1182
+ # "ETH-PERP_USDC": {
1183
+ # "ticker_id": "ETH-PERP_USDC",
1184
+ # "base_currency": "ETH-PERP",
1185
+ # "quote_currency": "USDC",
1186
+ # "last_price": 1620.3,
1187
+ # "base_volume": 1309.2,
1188
+ # "quote_volume": 2117828.093867611,
1189
+ # "product_type": "perpetual",
1190
+ # "contract_price": 1620.372642114429,
1191
+ # "contract_price_currency": "USD",
1192
+ # "open_interest": 1635.2,
1193
+ # "open_interest_usd": 2649633.3443855145,
1194
+ # "index_price": 1623.293496279935,
1195
+ # "mark_price": 1623.398589416731,
1196
+ # "funding_rate": 0.000068613217104332,
1197
+ # "next_funding_rate_timestamp": 1694379600,
1198
+ # "price_change_percent_24h": -0.6348599635253989
1199
+ # }
1200
+ # }
1201
+ #
1202
+ fundingRate = self.safe_number(ticker, 'funding_rate')
1203
+ if fundingRate is None:
1204
+ fundingRateX18 = self.safe_string(ticker, 'funding_rate_x18')
1205
+ fundingRate = self.parse_number(self.convert_from_x18(fundingRateX18))
1206
+ fundingTimestamp = self.safe_timestamp_2(ticker, 'update_time', 'next_funding_rate_timestamp')
1207
+ markPrice = self.safe_number(ticker, 'mark_price')
1208
+ indexPrice = self.safe_number(ticker, 'index_price')
1209
+ return {
1210
+ 'info': ticker,
1211
+ 'symbol': market['symbol'],
1212
+ 'markPrice': markPrice,
1213
+ 'indexPrice': indexPrice,
1214
+ 'interestRate': None,
1215
+ 'estimatedSettlePrice': None,
1216
+ 'timestamp': None,
1217
+ 'datetime': None,
1218
+ 'fundingRate': fundingRate,
1219
+ 'fundingTimestamp': fundingTimestamp,
1220
+ 'fundingDatetime': self.iso8601(fundingTimestamp),
1221
+ 'nextFundingRate': None,
1222
+ 'nextFundingTimestamp': None,
1223
+ 'nextFundingDatetime': None,
1224
+ 'previousFundingRate': None,
1225
+ 'previousFundingTimestamp': None,
1226
+ 'previousFundingDatetime': None,
1227
+ 'interval': None,
1228
+ }
1229
+
1230
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
1231
+ """
1232
+ fetch the current funding rate
1233
+
1234
+ https://docs.vertexprotocol.com/developer-resources/api/archive-indexer/funding-rate
1235
+
1236
+ :param str symbol: unified market symbol
1237
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1238
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
1239
+ """
1240
+ await self.load_markets()
1241
+ market = self.market(symbol)
1242
+ request = {
1243
+ 'funding_rate': {
1244
+ 'product_id': self.parse_to_int(market['id']),
1245
+ },
1246
+ }
1247
+ response = await self.v1ArchivePost(self.extend(request, params))
1248
+ #
1249
+ # {
1250
+ # "product_id": 4,
1251
+ # "funding_rate_x18": "2447900598160952",
1252
+ # "update_time": "1680116326"
1253
+ # }
1254
+ #
1255
+ return self.parse_funding_rate(response, market)
1256
+
1257
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
1258
+ """
1259
+ fetches funding rates for multiple markets
1260
+
1261
+ https://docs.vertexprotocol.com/developer-resources/api/v2/contracts
1262
+
1263
+ :param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
1264
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1265
+ :returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
1266
+ """
1267
+ await self.load_markets()
1268
+ request = {}
1269
+ if symbols is not None:
1270
+ symbols = self.market_symbols(symbols)
1271
+ response = await self.v2ArchiveGetContracts(self.extend(request, params))
1272
+ #
1273
+ # {
1274
+ # "ETH-PERP_USDC": {
1275
+ # "ticker_id": "ETH-PERP_USDC",
1276
+ # "base_currency": "ETH-PERP",
1277
+ # "quote_currency": "USDC",
1278
+ # "last_price": 1620.3,
1279
+ # "base_volume": 1309.2,
1280
+ # "quote_volume": 2117828.093867611,
1281
+ # "product_type": "perpetual",
1282
+ # "contract_price": 1620.372642114429,
1283
+ # "contract_price_currency": "USD",
1284
+ # "open_interest": 1635.2,
1285
+ # "open_interest_usd": 2649633.3443855145,
1286
+ # "index_price": 1623.293496279935,
1287
+ # "mark_price": 1623.398589416731,
1288
+ # "funding_rate": 0.000068613217104332,
1289
+ # "next_funding_rate_timestamp": 1694379600,
1290
+ # "price_change_percent_24h": -0.6348599635253989
1291
+ # }
1292
+ # }
1293
+ #
1294
+ keys = list(response.keys())
1295
+ fundingRates = {}
1296
+ for i in range(0, len(keys)):
1297
+ tickerId = keys[i]
1298
+ parsedTickerId = tickerId.split('-')
1299
+ data = response[tickerId]
1300
+ marketId = parsedTickerId[0] + '/USDC:USDC'
1301
+ market = self.market(marketId)
1302
+ ticker = self.parse_funding_rate(data, market)
1303
+ symbol = ticker['symbol']
1304
+ fundingRates[symbol] = ticker
1305
+ return self.filter_by_array(fundingRates, 'symbol', symbols)
1306
+
1307
+ def parse_open_interest(self, interest, market: Market = None):
1308
+ #
1309
+ # {
1310
+ # "ETH-PERP_USDC": {
1311
+ # "ticker_id": "ETH-PERP_USDC",
1312
+ # "base_currency": "ETH-PERP",
1313
+ # "quote_currency": "USDC",
1314
+ # "last_price": 1620.3,
1315
+ # "base_volume": 1309.2,
1316
+ # "quote_volume": 2117828.093867611,
1317
+ # "product_type": "perpetual",
1318
+ # "contract_price": 1620.372642114429,
1319
+ # "contract_price_currency": "USD",
1320
+ # "open_interest": 1635.2,
1321
+ # "open_interest_usd": 2649633.3443855145,
1322
+ # "index_price": 1623.293496279935,
1323
+ # "mark_price": 1623.398589416731,
1324
+ # "funding_rate": 0.000068613217104332,
1325
+ # "next_funding_rate_timestamp": 1694379600,
1326
+ # "price_change_percent_24h": -0.6348599635253989
1327
+ # }
1328
+ # }
1329
+ #
1330
+ value = self.safe_number(interest, 'open_interest_usd')
1331
+ return self.safe_open_interest({
1332
+ 'symbol': market['symbol'],
1333
+ 'openInterestAmount': None,
1334
+ 'openInterestValue': value,
1335
+ 'timestamp': None,
1336
+ 'datetime': None,
1337
+ 'info': interest,
1338
+ }, market)
1339
+
1340
+ async def fetch_open_interest(self, symbol: str, params={}):
1341
+ """
1342
+ Retrieves the open interest of a derivative trading pair
1343
+
1344
+ https://docs.vertexprotocol.com/developer-resources/api/v2/contracts
1345
+
1346
+ :param str symbol: Unified CCXT market symbol
1347
+ :param dict [params]: exchange specific parameters
1348
+ :returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
1349
+ """
1350
+ await self.load_markets()
1351
+ market = self.market(symbol)
1352
+ if not market['contract']:
1353
+ raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
1354
+ request = {}
1355
+ response = await self.v2ArchiveGetContracts(self.extend(request, params))
1356
+ #
1357
+ # {
1358
+ # "ETH-PERP_USDC": {
1359
+ # "ticker_id": "ETH-PERP_USDC",
1360
+ # "base_currency": "ETH-PERP",
1361
+ # "quote_currency": "USDC",
1362
+ # "last_price": 1620.3,
1363
+ # "base_volume": 1309.2,
1364
+ # "quote_volume": 2117828.093867611,
1365
+ # "product_type": "perpetual",
1366
+ # "contract_price": 1620.372642114429,
1367
+ # "contract_price_currency": "USD",
1368
+ # "open_interest": 1635.2,
1369
+ # "open_interest_usd": 2649633.3443855145,
1370
+ # "index_price": 1623.293496279935,
1371
+ # "mark_price": 1623.398589416731,
1372
+ # "funding_rate": 0.000068613217104332,
1373
+ # "next_funding_rate_timestamp": 1694379600,
1374
+ # "price_change_percent_24h": -0.6348599635253989
1375
+ # }
1376
+ # }
1377
+ #
1378
+ tickerId = market['base'] + '_USDC'
1379
+ openInterest = self.safe_dict(response, tickerId, {})
1380
+ return self.parse_open_interest(openInterest, market)
1381
+
1382
+ def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
1383
+ #
1384
+ # {
1385
+ # "ticker_id": "BTC_USDC",
1386
+ # "base_currency": "BTC",
1387
+ # "quote_currency": "USDC",
1388
+ # "last_price": 25728.0,
1389
+ # "base_volume": 552.048,
1390
+ # "quote_volume": 14238632.207250029,
1391
+ # "price_change_percent_24h": -0.6348599635253989
1392
+ # }
1393
+ #
1394
+ base = self.safe_string(ticker, 'base_currency')
1395
+ quote = self.safe_string(ticker, 'quote_currency')
1396
+ marketId = base + '/' + quote
1397
+ if base.find('PERP') > 0:
1398
+ marketId = marketId.replace('-PERP', '') + ':USDC'
1399
+ market = self.market(marketId)
1400
+ last = self.safe_string(ticker, 'last_price')
1401
+ return self.safe_ticker({
1402
+ 'symbol': market['symbol'],
1403
+ 'timestamp': None,
1404
+ 'datetime': None,
1405
+ 'high': None,
1406
+ 'low': None,
1407
+ 'bid': None,
1408
+ 'bidVolume': None,
1409
+ 'ask': None,
1410
+ 'askVolume': None,
1411
+ 'vwap': None,
1412
+ 'open': None,
1413
+ 'close': last,
1414
+ 'last': last,
1415
+ 'previousClose': None,
1416
+ 'change': None,
1417
+ 'percentage': self.safe_string(ticker, 'price_change_percent_24h'),
1418
+ 'average': None,
1419
+ 'baseVolume': self.safe_string(ticker, 'base_volume'),
1420
+ 'quoteVolume': self.safe_string(ticker, 'quote_volume'),
1421
+ 'info': ticker,
1422
+ }, market)
1423
+
1424
+ async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1425
+ """
1426
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1427
+
1428
+ https://docs.vertexprotocol.com/developer-resources/api/v2/tickers
1429
+
1430
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1431
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1432
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
1433
+ """
1434
+ await self.load_markets()
1435
+ symbols = self.market_symbols(symbols, None, True, True, True)
1436
+ request = {}
1437
+ response = await self.v2ArchiveGetTickers(self.extend(request, params))
1438
+ #
1439
+ # {
1440
+ # "ETH_USDC": {
1441
+ # "ticker_id": "ETH_USDC",
1442
+ # "base_currency": "ETH",
1443
+ # "quote_currency": "USDC",
1444
+ # "last_price": 1619.1,
1445
+ # "base_volume": 1428.32,
1446
+ # "quote_volume": 2310648.316391866,
1447
+ # "price_change_percent_24h": -1.0509394462969588
1448
+ # },
1449
+ # "BTC_USDC": {
1450
+ # "ticker_id": "BTC_USDC",
1451
+ # "base_currency": "BTC",
1452
+ # "quote_currency": "USDC",
1453
+ # "last_price": 25728.0,
1454
+ # "base_volume": 552.048,
1455
+ # "quote_volume": 14238632.207250029,
1456
+ # "price_change_percent_24h": -0.6348599635253989
1457
+ # }
1458
+ # }
1459
+ #
1460
+ tickers = list(response.values())
1461
+ return self.parse_tickers(tickers, symbols)
1462
+
1463
+ async def query_contracts(self, params={}) -> Currencies:
1464
+ # query contract addresses for sending order
1465
+ cachedContracts = self.safe_dict(self.options, 'v1contracts')
1466
+ if cachedContracts is not None:
1467
+ return cachedContracts
1468
+ request = {
1469
+ 'type': 'contracts',
1470
+ }
1471
+ response = await self.v1GatewayGetQuery(self.extend(request, params))
1472
+ data = self.safe_dict(response, 'data', {})
1473
+ self.options['v1contracts'] = data
1474
+ return data
1475
+
1476
+ def nonce(self):
1477
+ return self.milliseconds() - self.options['timeDifference']
1478
+
1479
+ def hash_message(self, message):
1480
+ return '0x' + self.hash(message, 'keccak', 'hex')
1481
+
1482
+ def sign_hash(self, hash, privateKey):
1483
+ signature = self.ecdsa(hash[-64:], privateKey[-64:], 'secp256k1', None)
1484
+ r = signature['r']
1485
+ s = signature['s']
1486
+ v = self.int_to_base16(self.sum(27, signature['v']))
1487
+ return '0x' + r.rjust(64, '0') + s.rjust(64, '0') + v
1488
+
1489
+ def sign_message(self, message, privateKey):
1490
+ return self.sign_hash(self.hash_message(message), privateKey[-64:])
1491
+
1492
+ def build_sig(self, chainId, messageTypes, message, verifyingContractAddress=''):
1493
+ domain = {
1494
+ 'chainId': chainId,
1495
+ 'name': 'Vertex',
1496
+ 'verifyingContract': verifyingContractAddress,
1497
+ 'version': '0.0.1',
1498
+ }
1499
+ msg = self.eth_encode_structured_data(domain, messageTypes, message)
1500
+ signature = self.sign_message(msg, self.privateKey)
1501
+ return signature
1502
+
1503
+ def build_create_order_sig(self, message, chainId, verifyingContractAddress):
1504
+ messageTypes = {
1505
+ 'Order': [
1506
+ {'name': 'sender', 'type': 'bytes32'},
1507
+ {'name': 'priceX18', 'type': 'int128'},
1508
+ {'name': 'amount', 'type': 'int128'},
1509
+ {'name': 'expiration', 'type': 'uint64'},
1510
+ {'name': 'nonce', 'type': 'uint64'},
1511
+ ],
1512
+ }
1513
+ return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
1514
+
1515
+ def build_list_trigger_tx_sig(self, message, chainId, verifyingContractAddress):
1516
+ messageTypes = {
1517
+ 'ListTriggerOrders': [
1518
+ {'name': 'sender', 'type': 'bytes32'},
1519
+ {'name': 'recvTime', 'type': 'uint64'},
1520
+ ],
1521
+ }
1522
+ return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
1523
+
1524
+ def build_cancel_all_orders_sig(self, message, chainId, verifyingContractAddress):
1525
+ messageTypes = {
1526
+ 'CancellationProducts': [
1527
+ {'name': 'sender', 'type': 'bytes32'},
1528
+ {'name': 'productIds', 'type': 'uint32[]'},
1529
+ {'name': 'nonce', 'type': 'uint64'},
1530
+ ],
1531
+ }
1532
+ return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
1533
+
1534
+ def build_cancel_orders_sig(self, message, chainId, verifyingContractAddress):
1535
+ messageTypes = {
1536
+ 'Cancellation': [
1537
+ {'name': 'sender', 'type': 'bytes32'},
1538
+ {'name': 'productIds', 'type': 'uint32[]'},
1539
+ {'name': 'digests', 'type': 'bytes32[]'},
1540
+ {'name': 'nonce', 'type': 'uint64'},
1541
+ ],
1542
+ }
1543
+ return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
1544
+
1545
+ def build_withdraw_sig(self, message, chainId, verifyingContractAddress):
1546
+ messageTypes = {
1547
+ 'WithdrawCollateral': [
1548
+ {'name': 'sender', 'type': 'bytes32'},
1549
+ {'name': 'productId', 'type': 'uint32'},
1550
+ {'name': 'amount', 'type': 'uint128'},
1551
+ {'name': 'nonce', 'type': 'uint64'},
1552
+ ],
1553
+ }
1554
+ return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
1555
+
1556
+ def convert_address_to_sender(self, address: str):
1557
+ sender = address + '64656661756c74'
1558
+ return sender.ljust(66, '0')
1559
+
1560
+ def get_nonce(self, now, expiration):
1561
+ if now is None:
1562
+ now = self.nonce()
1563
+ # nonce = ((now + expiration) << 20) + 1000
1564
+ # 1 << 20 = 1048576
1565
+ return Precise.string_add(Precise.string_mul(Precise.string_add(self.number_to_string(now), self.number_to_string(expiration)), '1048576'), '1000')
1566
+
1567
+ def get_expiration(self, now, timeInForce, postOnly, reduceOnly):
1568
+ expiration = Precise.string_add(self.number_to_string(now), '86400')
1569
+ if timeInForce == 'ioc':
1570
+ # 1 << 62 = 4611686018427387904
1571
+ expiration = Precise.string_or(expiration, '4611686018427387904')
1572
+ elif timeInForce == 'fok':
1573
+ # 2 << 62 = 9223372036854775808
1574
+ expiration = Precise.string_or(expiration, '9223372036854775808')
1575
+ elif postOnly:
1576
+ # 3 << 62 = 13835058055282163712
1577
+ expiration = Precise.string_or(expiration, '13835058055282163712')
1578
+ if reduceOnly:
1579
+ # 1 << 61 = 2305843009213693952
1580
+ expiration = Precise.string_or(expiration, '2305843009213693952')
1581
+ return expiration
1582
+
1583
+ def get_amount(self, amount, side):
1584
+ amountString = self.number_to_string(amount)
1585
+ if side == 'sell':
1586
+ if amount > 0:
1587
+ # amount *= -1
1588
+ amountString = Precise.string_mul(amountString, '-1')
1589
+ else:
1590
+ if amount < 0:
1591
+ # amount *= -1
1592
+ amountString = Precise.string_mul(amountString, '-1')
1593
+ return amountString
1594
+
1595
+ async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1596
+ """
1597
+ create a trade order
1598
+
1599
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/place-order
1600
+ https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/place-order
1601
+
1602
+ :param str symbol: unified symbol of the market to create an order in
1603
+ :param str type: 'market' or 'limit'
1604
+ :param str side: 'buy' or 'sell'
1605
+ :param float amount: how much of currency you want to trade in units of base currency
1606
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1607
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1608
+ :param str [params.timeInForce]: ioc, fok
1609
+ :param bool [params.postOnly]: True or False whether the order is post-only
1610
+ :param bool [params.reduceOnly]: True or False whether the order is reduce-only, only works for ioc and fok order
1611
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
1612
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1613
+ """
1614
+ self.check_required_credentials()
1615
+ marketType = type.lower()
1616
+ isMarketOrder = marketType == 'market'
1617
+ if isMarketOrder and price is None:
1618
+ raise ArgumentsRequired(self.id + ' createOrder() requires a price argument for market order')
1619
+ await self.load_markets()
1620
+ market = self.market(symbol)
1621
+ marketId = self.parse_to_int(market['id'])
1622
+ contracts = await self.query_contracts()
1623
+ chainId = self.safe_string(contracts, 'chain_id')
1624
+ bookAddresses = self.safe_list(contracts, 'book_addrs', [])
1625
+ verifyingContractAddress = self.safe_string(bookAddresses, marketId)
1626
+ defaultTimeInForce = 'fok' if (isMarketOrder) else None
1627
+ timeInForce = self.safe_string_lower(params, 'timeInForce', defaultTimeInForce)
1628
+ postOnly = self.safe_bool(params, 'postOnly', False)
1629
+ reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1630
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1631
+ stopLossPrice = self.safe_string(params, 'stopLossPrice', triggerPrice)
1632
+ takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1633
+ isTrigger = (stopLossPrice or takeProfitPrice)
1634
+ now = self.nonce()
1635
+ nonce = self.get_nonce(now, 90000)
1636
+ if postOnly and reduceOnly:
1637
+ raise NotSupported(self.id + ' reduceOnly not supported when postOnly is enabled')
1638
+ expiration = self.get_expiration(now, timeInForce, postOnly, reduceOnly)
1639
+ if isTrigger:
1640
+ # 1 << 63 = 9223372036854775808
1641
+ nonce = Precise.string_or(nonce, '9223372036854775808')
1642
+ amountString = self.get_amount(amount, side)
1643
+ order = {
1644
+ 'sender': self.convert_address_to_sender(self.walletAddress),
1645
+ 'priceX18': self.convert_to_x18(self.price_to_precision(symbol, price)),
1646
+ 'amount': self.convert_to_x18(self.amount_to_precision(symbol, amountString)),
1647
+ 'expiration': expiration,
1648
+ 'nonce': nonce,
1649
+ }
1650
+ request = {
1651
+ 'place_order': {
1652
+ 'product_id': marketId,
1653
+ 'order': {
1654
+ 'sender': order['sender'],
1655
+ 'priceX18': order['priceX18'],
1656
+ 'amount': order['amount'],
1657
+ 'expiration': self.number_to_string(order['expiration']),
1658
+ 'nonce': order['nonce'],
1659
+ },
1660
+ 'signature': self.build_create_order_sig(order, chainId, verifyingContractAddress),
1661
+ 'id': self.safe_integer(self.options, 'brokerId', 5930043274845996),
1662
+ },
1663
+ }
1664
+ params = self.omit(params, ['timeInForce', 'reduceOnly', 'postOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice'])
1665
+ response = None
1666
+ if isTrigger:
1667
+ trigger = {}
1668
+ if stopLossPrice is not None:
1669
+ trigger['last_price_below'] = self.convert_to_x18(stopLossPrice)
1670
+ elif takeProfitPrice is not None:
1671
+ trigger['last_price_above'] = self.convert_to_x18(takeProfitPrice)
1672
+ request['place_order']['trigger'] = trigger
1673
+ response = await self.v1TriggerPostExecute(self.extend(request, params))
1674
+ else:
1675
+ response = await self.v1GatewayPostExecute(self.extend(request, params))
1676
+ #
1677
+ # {
1678
+ # "status": "success",
1679
+ # "signature": {signature},
1680
+ # "data": {
1681
+ # "digest": {order digest}
1682
+ # },
1683
+ # "request_type": "execute_place_order"
1684
+ # "id": 100
1685
+ # }
1686
+ #
1687
+ data = self.safe_dict(response, 'data', {})
1688
+ return self.safe_order({
1689
+ 'id': self.safe_string(data, 'digest'),
1690
+ })
1691
+
1692
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
1693
+ """
1694
+ edit a trade order
1695
+
1696
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-and-place
1697
+
1698
+ :param str id: cancel order id
1699
+ :param str symbol: unified symbol of the market to create an order in
1700
+ :param str type: 'market' or 'limit'
1701
+ :param str side: 'buy' or 'sell'
1702
+ :param float amount: how much of currency you want to trade in units of base currency
1703
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1704
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1705
+ :param str [params.timeInForce]: ioc, fok
1706
+ :param bool [params.postOnly]: True or False whether the order is post-only
1707
+ :param bool [params.reduceOnly]: True or False whether the order is reduce-only, only works for ioc and fok order
1708
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
1709
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1710
+ """
1711
+ self.check_required_credentials()
1712
+ marketType = type.lower()
1713
+ isMarketOrder = marketType == 'market'
1714
+ if isMarketOrder and price is None:
1715
+ raise ArgumentsRequired(self.id + ' editOrder() requires a price argument for market order')
1716
+ await self.load_markets()
1717
+ market = self.market(symbol)
1718
+ marketId = self.parse_to_int(market['id'])
1719
+ defaultTimeInForce = 'fok' if (isMarketOrder) else None
1720
+ timeInForce = self.safe_string_lower(params, 'timeInForce', defaultTimeInForce)
1721
+ postOnly = self.safe_bool(params, 'postOnly', False)
1722
+ reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1723
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1724
+ stopLossPrice = self.safe_string(params, 'stopLossPrice', triggerPrice)
1725
+ takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1726
+ isTrigger = (stopLossPrice or takeProfitPrice)
1727
+ contracts = await self.query_contracts()
1728
+ chainId = self.safe_string(contracts, 'chain_id')
1729
+ bookAddresses = self.safe_list(contracts, 'book_addrs', [])
1730
+ verifyingContractAddressOrder = self.safe_string(bookAddresses, marketId)
1731
+ verifyingContractAddressCancel = self.safe_string(contracts, 'endpoint_addr')
1732
+ now = self.nonce()
1733
+ nonce = self.get_nonce(now, 90000)
1734
+ sender = self.convert_address_to_sender(self.walletAddress)
1735
+ if postOnly and reduceOnly:
1736
+ raise NotSupported(self.id + ' reduceOnly not supported when postOnly is enabled')
1737
+ if isTrigger:
1738
+ raise NotSupported(self.id + ' editOrder() not supported for trigger order')
1739
+ expiration = self.get_expiration(now, timeInForce, postOnly, reduceOnly)
1740
+ amountString = self.get_amount(amount, side)
1741
+ order = {
1742
+ 'sender': sender,
1743
+ 'priceX18': self.convert_to_x18(self.price_to_precision(symbol, price)),
1744
+ 'amount': self.convert_to_x18(self.amount_to_precision(symbol, amountString)),
1745
+ 'expiration': expiration,
1746
+ 'nonce': nonce,
1747
+ }
1748
+ cancels = {
1749
+ 'sender': sender,
1750
+ 'productIds': [marketId],
1751
+ 'digests': [id],
1752
+ 'nonce': nonce,
1753
+ }
1754
+ request = {
1755
+ 'cancel_and_place': {
1756
+ 'cancel_tx': {
1757
+ 'sender': cancels['sender'],
1758
+ 'productIds': cancels['productIds'],
1759
+ 'digests': cancels['digests'],
1760
+ 'nonce': self.number_to_string(cancels['nonce']),
1761
+ },
1762
+ 'cancel_signature': self.build_cancel_orders_sig(cancels, chainId, verifyingContractAddressCancel),
1763
+ 'place_order': {
1764
+ 'product_id': marketId,
1765
+ 'order': {
1766
+ 'sender': order['sender'],
1767
+ 'priceX18': order['priceX18'],
1768
+ 'amount': order['amount'],
1769
+ 'expiration': self.number_to_string(order['expiration']),
1770
+ 'nonce': order['nonce'],
1771
+ },
1772
+ 'signature': self.build_create_order_sig(order, chainId, verifyingContractAddressOrder),
1773
+ 'id': self.safe_integer(self.options, 'brokerId', 5930043274845996),
1774
+ },
1775
+ },
1776
+ }
1777
+ params = self.omit(params, ['timeInForce', 'reduceOnly', 'postOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice'])
1778
+ response = await self.v1GatewayPostExecute(self.extend(request, params))
1779
+ #
1780
+ # {
1781
+ # "status": "success",
1782
+ # "signature": {signature},
1783
+ # "data": {
1784
+ # "digest": {order digest}
1785
+ # },
1786
+ # "request_type": "execute_cancel_and_place"
1787
+ # }
1788
+ #
1789
+ data = self.safe_dict(response, 'data', {})
1790
+ return self.safe_order({
1791
+ 'id': self.safe_string(data, 'digest'),
1792
+ })
1793
+
1794
+ def parse_order_status(self, status):
1795
+ if status is not None:
1796
+ statuses = {
1797
+ 'pending': 'open',
1798
+ }
1799
+ if isinstance(status, str):
1800
+ return self.safe_string(statuses, status, status)
1801
+ statusCancelled = self.safe_dict(status, 'cancelled')
1802
+ if statusCancelled is not None:
1803
+ return 'canceled'
1804
+ statusTriggered = self.safe_dict(status, 'triggered', {})
1805
+ triggeredStatus = self.safe_string(statusTriggered, 'status', 'failure')
1806
+ if triggeredStatus == 'success':
1807
+ return 'closed'
1808
+ return 'canceled'
1809
+ return status
1810
+
1811
+ def parse_order(self, order, market: Market = None) -> Order:
1812
+ #
1813
+ # {
1814
+ # "product_id": 1,
1815
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
1816
+ # "price_x18": "1000000000000000000",
1817
+ # "amount": "1000000000000000000",
1818
+ # "expiration": "2000000000",
1819
+ # "nonce": "1",
1820
+ # "unfilled_amount": "1000000000000000000",
1821
+ # "digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
1822
+ # "placed_at": 1681951347,
1823
+ # "order_type": "ioc"
1824
+ # }
1825
+ # stop order
1826
+ # {
1827
+ # "order": {
1828
+ # "order": {
1829
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
1830
+ # "priceX18": "1000000000000000000",
1831
+ # "amount": "1000000000000000000",
1832
+ # "expiration": "2000000000",
1833
+ # "nonce": "1",
1834
+ # },
1835
+ # "signature": "0x...",
1836
+ # "product_id": 1,
1837
+ # "spot_leverage": True,
1838
+ # "trigger": {
1839
+ # "price_above": "1000000000000000000"
1840
+ # },
1841
+ # "digest": "0x..."
1842
+ # },
1843
+ # "status": "pending",
1844
+ # "updated_at": 1688768157050
1845
+ # }
1846
+ #
1847
+ marketId = self.safe_string(order, 'product_id')
1848
+ timestamp = self.safe_timestamp(order, 'placed_at')
1849
+ amount = self.safe_string(order, 'amount')
1850
+ price = self.safe_string(order, 'price_x18')
1851
+ remaining = self.safe_string(order, 'unfilled_amount')
1852
+ triggerPriceNum = None
1853
+ status = self.safe_value(order, 'status')
1854
+ if status is not None:
1855
+ # trigger order
1856
+ outerOrder = self.safe_dict(order, 'order', {})
1857
+ innerOrder = self.safe_dict(outerOrder, 'order', {})
1858
+ marketId = self.safe_string(outerOrder, 'product_id')
1859
+ amount = self.safe_string(innerOrder, 'amount')
1860
+ price = self.safe_string(innerOrder, 'priceX18')
1861
+ timestamp = self.safe_timestamp(order, 'updated_at')
1862
+ trigger = self.safe_dict(outerOrder, 'trigger', {})
1863
+ triggerPrice = self.safe_string_n(trigger, ['price_above', 'price_below', 'last_price_above', 'last_price_below'])
1864
+ if triggerPrice is not None:
1865
+ triggerPriceNum = self.parse_to_numeric(self.convert_from_x18(triggerPrice))
1866
+ market = self.safe_market(marketId, market)
1867
+ symbol = market['symbol']
1868
+ priceNum = None
1869
+ if price is not None:
1870
+ priceNum = self.parse_to_numeric(self.convert_from_x18(price))
1871
+ amountNum = None
1872
+ if amount is not None:
1873
+ amountNum = self.parse_to_numeric(self.convert_from_x18(amount))
1874
+ remainingNum = None
1875
+ if remaining is not None:
1876
+ remainingNum = self.parse_to_numeric(self.convert_from_x18(remaining))
1877
+ side = None
1878
+ if amountNum is not None and remainingNum is not None:
1879
+ side = 'sell' if (amountNum < 0 or remainingNum < 0) else 'buy'
1880
+ tif = self.parse_time_in_force(self.safe_string(order, 'order_type'))
1881
+ isPostOnly = (tif == 'PO')
1882
+ return self.safe_order({
1883
+ 'info': order,
1884
+ 'id': self.safe_string(order, 'digest'),
1885
+ 'clientOrderId': None,
1886
+ 'timestamp': timestamp,
1887
+ 'datetime': self.iso8601(timestamp),
1888
+ 'lastTradeTimestamp': None,
1889
+ 'lastUpdateTimestamp': None,
1890
+ 'symbol': symbol,
1891
+ 'type': None,
1892
+ 'timeInForce': tif,
1893
+ 'postOnly': isPostOnly,
1894
+ 'reduceOnly': None,
1895
+ 'side': side,
1896
+ 'price': priceNum,
1897
+ 'triggerPrice': triggerPriceNum,
1898
+ 'amount': amountNum,
1899
+ 'cost': None,
1900
+ 'average': None,
1901
+ 'filled': None,
1902
+ 'remaining': remainingNum,
1903
+ 'status': self.parse_order_status(status),
1904
+ 'fee': None,
1905
+ 'trades': None,
1906
+ }, market)
1907
+
1908
+ def parse_time_in_force(self, timeInForce):
1909
+ timeInForces = {
1910
+ 'POST_ONLY': 'PO',
1911
+ }
1912
+ return self.safe_string_upper(timeInForces, timeInForce, timeInForce)
1913
+
1914
+ async def fetch_order(self, id: str, symbol: Str = None, params={}):
1915
+ """
1916
+ fetches information on an order made by the user
1917
+
1918
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/order
1919
+
1920
+ :param str id: the order id
1921
+ :param str symbol: unified symbol of the market the order was made in
1922
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1923
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1924
+ """
1925
+ await self.load_markets()
1926
+ market = self.market(symbol)
1927
+ request = {
1928
+ 'type': 'order',
1929
+ 'product_id': self.parse_to_int(market['id']),
1930
+ 'digest': id,
1931
+ }
1932
+ response = await self.v1GatewayGetQuery(self.extend(request, params))
1933
+ #
1934
+ # {
1935
+ # "status": "success",
1936
+ # "data": {
1937
+ # "product_id": 1,
1938
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
1939
+ # "price_x18": "1000000000000000000",
1940
+ # "amount": "1000000000000000000",
1941
+ # "expiration": "2000000000",
1942
+ # "nonce": "1",
1943
+ # "unfilled_amount": "1000000000000000000",
1944
+ # "digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
1945
+ # "placed_at": 1681951347,
1946
+ # "order_type": "ioc"
1947
+ # },
1948
+ # "request_type": "query_order",
1949
+ # }
1950
+ #
1951
+ data = self.safe_dict(response, 'data')
1952
+ return self.parse_order(data, market)
1953
+
1954
+ async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1955
+ """
1956
+ fetch all unfilled currently open orders
1957
+
1958
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/orders
1959
+ https://docs.vertexprotocol.com/developer-resources/api/trigger/queries/list-trigger-orders
1960
+
1961
+ :param str symbol: unified market symbol
1962
+ :param int [since]: the earliest time in ms to fetch open orders for
1963
+ :param int [limit]: the maximum number of open orders structures to retrieve
1964
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1965
+ :param boolean [params.stop]: whether the order is a stop/algo order
1966
+ :param str [params.user]: user address, will default to self.walletAddress if not provided
1967
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1968
+ """
1969
+ self.check_required_credentials()
1970
+ await self.load_markets()
1971
+ userAddress = None
1972
+ userAddress, params = self.handle_public_address('fetchOpenOrders', params)
1973
+ request = {}
1974
+ market: Market = None
1975
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
1976
+ params = self.omit(params, ['stop', 'trigger'])
1977
+ if symbol is not None:
1978
+ market = self.market(symbol)
1979
+ request['product_id'] = self.parse_to_numeric(market['id'])
1980
+ response = None
1981
+ if stop:
1982
+ contracts = await self.query_contracts()
1983
+ chainId = self.safe_string(contracts, 'chain_id')
1984
+ verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
1985
+ tx = {
1986
+ 'sender': self.convert_address_to_sender(userAddress),
1987
+ 'recvTime': self.nonce() + 90000,
1988
+ }
1989
+ request['signature'] = self.build_list_trigger_tx_sig(tx, chainId, verifyingContractAddress)
1990
+ request['tx'] = {
1991
+ 'sender': tx['sender'],
1992
+ 'recvTime': self.number_to_string(tx['recvTime']),
1993
+ }
1994
+ request['type'] = 'list_trigger_orders'
1995
+ request['pending'] = True
1996
+ until = self.safe_integer(params, 'until')
1997
+ params = self.omit(params, 'until')
1998
+ if until is not None:
1999
+ request['max_update_time'] = until
2000
+ if limit is not None:
2001
+ request['limit'] = limit
2002
+ response = await self.v1TriggerPostQuery(self.extend(request, params))
2003
+ #
2004
+ # {
2005
+ # "status": "success",
2006
+ # "data": {
2007
+ # "orders": [
2008
+ # {
2009
+ # "order": {
2010
+ # "order": {
2011
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
2012
+ # "priceX18": "1000000000000000000",
2013
+ # "amount": "1000000000000000000",
2014
+ # "expiration": "2000000000",
2015
+ # "nonce": "1",
2016
+ # },
2017
+ # "signature": "0x...",
2018
+ # "product_id": 1,
2019
+ # "spot_leverage": True,
2020
+ # "trigger": {
2021
+ # "price_above": "1000000000000000000"
2022
+ # },
2023
+ # "digest": "0x..."
2024
+ # },
2025
+ # "status": "pending",
2026
+ # "updated_at": 1688768157050
2027
+ # }
2028
+ # ]
2029
+ # },
2030
+ # "request_type": "query_list_trigger_orders"
2031
+ # }
2032
+ #
2033
+ else:
2034
+ self.check_required_argument('fetchOpenOrders', symbol, 'symbol')
2035
+ request['type'] = 'subaccount_orders'
2036
+ request['sender'] = self.convert_address_to_sender(userAddress)
2037
+ response = await self.v1GatewayPostQuery(self.extend(request, params))
2038
+ #
2039
+ # {
2040
+ # "status": "success",
2041
+ # "data": {
2042
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
2043
+ # "product_id": 1,
2044
+ # "orders": [
2045
+ # {
2046
+ # "product_id": 1,
2047
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
2048
+ # "price_x18": "1000000000000000000",
2049
+ # "amount": "1000000000000000000",
2050
+ # "expiration": "2000000000",
2051
+ # "nonce": "1",
2052
+ # "order_type": "default",
2053
+ # "unfilled_amount": "1000000000000000000",
2054
+ # "digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
2055
+ # "placed_at": 1682437739,
2056
+ # "order_type": "ioc"
2057
+ # }
2058
+ # ]
2059
+ # },
2060
+ # "request_type": "query_subaccount_orders"
2061
+ # }
2062
+ #
2063
+ data = self.safe_dict(response, 'data', {})
2064
+ orders = self.safe_list(data, 'orders')
2065
+ return self.parse_orders(orders, market, since, limit)
2066
+
2067
+ async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2068
+ """
2069
+ fetches information on multiple orders made by the user
2070
+
2071
+ https://docs.vertexprotocol.com/developer-resources/api/trigger/queries/list-trigger-orders
2072
+
2073
+ :param str symbol: unified market symbol
2074
+ :param int [since]: the earliest time in ms to fetch open orders for
2075
+ :param int [limit]: the maximum number of open orders structures to retrieve
2076
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2077
+ :param boolean [params.stop]: whether the order is a stop/algo order
2078
+ :param str [params.user]: user address, will default to self.walletAddress if not provided
2079
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2080
+ """
2081
+ self.check_required_credentials()
2082
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
2083
+ params = self.omit(params, ['stop', 'trigger'])
2084
+ if not stop:
2085
+ raise NotSupported(self.id + ' fetchOrders only support trigger orders')
2086
+ userAddress = None
2087
+ userAddress, params = self.handle_public_address('fetchOrders', params)
2088
+ await self.load_markets()
2089
+ market: Market = None
2090
+ request = {
2091
+ 'type': 'list_trigger_orders',
2092
+ 'pending': False,
2093
+ }
2094
+ if symbol is not None:
2095
+ market = self.market(symbol)
2096
+ request['product_id'] = self.parse_to_numeric(market['id'])
2097
+ contracts = await self.query_contracts()
2098
+ chainId = self.safe_string(contracts, 'chain_id')
2099
+ verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
2100
+ tx = {
2101
+ 'sender': self.convert_address_to_sender(userAddress),
2102
+ 'recvTime': self.nonce() + 90000,
2103
+ }
2104
+ request['signature'] = self.build_list_trigger_tx_sig(tx, chainId, verifyingContractAddress)
2105
+ request['tx'] = {
2106
+ 'sender': tx['sender'],
2107
+ 'recvTime': self.number_to_string(tx['recvTime']),
2108
+ }
2109
+ until = self.safe_integer(params, 'until')
2110
+ params = self.omit(params, 'until')
2111
+ if until is not None:
2112
+ request['max_update_time'] = until
2113
+ if limit is not None:
2114
+ request['limit'] = limit
2115
+ response = await self.v1TriggerPostQuery(self.extend(request, params))
2116
+ #
2117
+ # {
2118
+ # "status": "success",
2119
+ # "data": {
2120
+ # "orders": [
2121
+ # {
2122
+ # "order": {
2123
+ # "order": {
2124
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
2125
+ # "priceX18": "1000000000000000000",
2126
+ # "amount": "1000000000000000000",
2127
+ # "expiration": "2000000000",
2128
+ # "nonce": "1",
2129
+ # },
2130
+ # "signature": "0x...",
2131
+ # "product_id": 1,
2132
+ # "spot_leverage": True,
2133
+ # "trigger": {
2134
+ # "price_above": "1000000000000000000"
2135
+ # },
2136
+ # "digest": "0x..."
2137
+ # },
2138
+ # "status": "pending",
2139
+ # "updated_at": 1688768157050
2140
+ # }
2141
+ # ]
2142
+ # },
2143
+ # "request_type": "query_list_trigger_orders"
2144
+ # }
2145
+ #
2146
+ data = self.safe_dict(response, 'data', {})
2147
+ orders = self.safe_list(data, 'orders')
2148
+ return self.parse_orders(orders, market, since, limit)
2149
+
2150
+ async def cancel_all_orders(self, symbol: Str = None, params={}):
2151
+ """
2152
+
2153
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-product-orders
2154
+ https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/cancel-product-orders
2155
+
2156
+ cancel all open orders in a market
2157
+ :param str symbol: unified market symbol
2158
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2159
+ :param boolean [params.stop]: whether the order is a stop/algo order
2160
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2161
+ """
2162
+ self.check_required_credentials()
2163
+ await self.load_markets()
2164
+ if symbol is None:
2165
+ raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
2166
+ market = self.market(symbol)
2167
+ marketId = market['id']
2168
+ contracts = await self.query_contracts()
2169
+ chainId = self.safe_string(contracts, 'chain_id')
2170
+ verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
2171
+ now = self.nonce()
2172
+ nonce = self.get_nonce(now, 90000)
2173
+ cancels = {
2174
+ 'sender': self.convert_address_to_sender(self.walletAddress),
2175
+ 'productIds': [
2176
+ self.parse_to_numeric(marketId),
2177
+ ],
2178
+ 'nonce': nonce,
2179
+ }
2180
+ request = {
2181
+ 'cancel_product_orders': {
2182
+ 'tx': {
2183
+ 'sender': cancels['sender'],
2184
+ 'productIds': cancels['productIds'],
2185
+ 'nonce': self.number_to_string(cancels['nonce']),
2186
+ },
2187
+ 'signature': self.build_cancel_all_orders_sig(cancels, chainId, verifyingContractAddress),
2188
+ },
2189
+ }
2190
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
2191
+ params = self.omit(params, ['stop', 'trigger'])
2192
+ response = None
2193
+ if stop:
2194
+ response = await self.v1TriggerPostExecute(self.extend(request, params))
2195
+ #
2196
+ # {
2197
+ # "status": "success",
2198
+ # "signature": {signature},
2199
+ # "request_type": "execute_cancel_product_orders"
2200
+ # }
2201
+ #
2202
+ else:
2203
+ response = await self.v1GatewayPostExecute(self.extend(request, params))
2204
+ #
2205
+ # {
2206
+ # "status": "success",
2207
+ # "signature": {signature},
2208
+ # "data": {
2209
+ # "cancelled_orders": [
2210
+ # {
2211
+ # "product_id": 2,
2212
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
2213
+ # "price_x18": "20000000000000000000000",
2214
+ # "amount": "-100000000000000000",
2215
+ # "expiration": "1686332748",
2216
+ # "order_type": "post_only",
2217
+ # "nonce": "1768248100142339392",
2218
+ # "unfilled_amount": "-100000000000000000",
2219
+ # "digest": "0x3195a7929feb8307edecf9c045j5ced68925108f0aa305f0ee5773854159377c",
2220
+ # "placed_at": 1686332708
2221
+ # },
2222
+ # ...
2223
+ # ]
2224
+ # },
2225
+ # "request_type": "execute_cancel_product_orders"
2226
+ # }
2227
+ #
2228
+ return response
2229
+
2230
+ async def cancel_order(self, id: str, symbol: Str = None, params={}):
2231
+ """
2232
+ cancels an open order
2233
+
2234
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-orders
2235
+ https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/cancel-orders
2236
+
2237
+ :param str id: order id
2238
+ :param str symbol: unified symbol of the market the order was made in
2239
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2240
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2241
+ """
2242
+ return await self.cancel_orders([id], symbol, params)
2243
+
2244
+ async def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
2245
+ """
2246
+ cancel multiple orders
2247
+
2248
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-orders
2249
+ https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/cancel-orders
2250
+
2251
+ :param str[] ids: order ids
2252
+ :param str [symbol]: unified market symbol
2253
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2254
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2255
+ """
2256
+ self.check_required_credentials()
2257
+ if symbol is None:
2258
+ raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
2259
+ await self.load_markets()
2260
+ market = self.market(symbol)
2261
+ marketId = market['id']
2262
+ contracts = await self.query_contracts()
2263
+ chainId = self.safe_string(contracts, 'chain_id')
2264
+ verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
2265
+ now = self.nonce()
2266
+ nonce = self.get_nonce(now, 90000)
2267
+ cancels = {
2268
+ 'sender': self.convert_address_to_sender(self.walletAddress),
2269
+ 'productIds': [],
2270
+ 'digests': ids,
2271
+ 'nonce': nonce,
2272
+ }
2273
+ marketIdNum = self.parse_to_numeric(marketId)
2274
+ for i in range(0, len(ids)):
2275
+ cancels['productIds'].append(marketIdNum)
2276
+ request = {
2277
+ 'cancel_orders': {
2278
+ 'tx': {
2279
+ 'sender': cancels['sender'],
2280
+ 'productIds': cancels['productIds'],
2281
+ 'digests': cancels['digests'],
2282
+ 'nonce': self.number_to_string(cancels['nonce']),
2283
+ },
2284
+ 'signature': self.build_cancel_orders_sig(cancels, chainId, verifyingContractAddress),
2285
+ },
2286
+ }
2287
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
2288
+ params = self.omit(params, ['stop', 'trigger'])
2289
+ response = None
2290
+ if stop:
2291
+ response = await self.v1TriggerPostExecute(self.extend(request, params))
2292
+ #
2293
+ # {
2294
+ # "status": "success",
2295
+ # "signature": {signature},
2296
+ # "request_type": "execute_cancel_orders"
2297
+ # }
2298
+ #
2299
+ else:
2300
+ response = await self.v1GatewayPostExecute(self.extend(request, params))
2301
+ #
2302
+ # {
2303
+ # "status": "success",
2304
+ # "signature": {signature},
2305
+ # "data": {
2306
+ # "cancelled_orders": [
2307
+ # {
2308
+ # "product_id": 2,
2309
+ # "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
2310
+ # "price_x18": "20000000000000000000000",
2311
+ # "amount": "-100000000000000000",
2312
+ # "expiration": "1686332748",
2313
+ # "order_type": "post_only",
2314
+ # "nonce": "1768248100142339392",
2315
+ # "unfilled_amount": "-100000000000000000",
2316
+ # "digest": "0x3195a7929feb8307edecf9c045j5ced68925108f0aa305f0ee5773854159377c",
2317
+ # "placed_at": 1686332708
2318
+ # },
2319
+ # ...
2320
+ # ]
2321
+ # },
2322
+ # "request_type": "execute_cancel_orders"
2323
+ # }
2324
+ #
2325
+ return response
2326
+
2327
+ async def fetch_balance(self, params={}) -> Balances:
2328
+ """
2329
+ query for balance and get the amount of funds available for trading or funds locked in orders
2330
+
2331
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/subaccount-info
2332
+
2333
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2334
+ :param str [params.user]: user address, will default to self.walletAddress if not provided
2335
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
2336
+ """
2337
+ userAddress = None
2338
+ userAddress, params = self.handle_public_address('fetchBalance', params)
2339
+ request = {
2340
+ 'type': 'subaccount_info',
2341
+ 'subaccount': self.convert_address_to_sender(userAddress),
2342
+ }
2343
+ response = await self.v1GatewayGetQuery(self.extend(request, params))
2344
+ #
2345
+ # {
2346
+ # "status": "success",
2347
+ # "data": {
2348
+ # "subaccount": "0x265167ddfac55365d6ff07fc5943276319aa6b9f64656661756c740000000000",
2349
+ # "exists": True,
2350
+ # "healths": [
2351
+ # {
2352
+ # "assets": "75323297691833342306",
2353
+ # "liabilities": "46329556869051092241",
2354
+ # "health": "28993740822782250065"
2355
+ # },
2356
+ # {
2357
+ # "assets": "75323297691833342306",
2358
+ # "liabilities": "35968911700887320741",
2359
+ # "health": "39354385990946021565"
2360
+ # },
2361
+ # {
2362
+ # "assets": "80796966663601107565",
2363
+ # "liabilities": "0",
2364
+ # "health": "80796966663601107565"
2365
+ # }
2366
+ # ],
2367
+ # "health_contributions": [
2368
+ # [
2369
+ # "75323297691833340000",
2370
+ # "75323297691833340000",
2371
+ # "75323297691833340000"
2372
+ # ],
2373
+ # [
2374
+ # "0",
2375
+ # "0",
2376
+ # "0"
2377
+ # ],
2378
+ # [
2379
+ # "0",
2380
+ # "0",
2381
+ # "0"
2382
+ # ],
2383
+ # [
2384
+ # "0",
2385
+ # "0",
2386
+ # "0"
2387
+ # ],
2388
+ # [
2389
+ # "-46329556869051090000",
2390
+ # "-35968911700887323000",
2391
+ # "5473668971767765000"
2392
+ # ]
2393
+ # ],
2394
+ # "spot_count": 3,
2395
+ # "perp_count": 2,
2396
+ # "spot_balances": [
2397
+ # {
2398
+ # "product_id": 1,
2399
+ # "lp_balance": {
2400
+ # "amount": "0"
2401
+ # },
2402
+ # "balance": {
2403
+ # "amount": "0",
2404
+ # "last_cumulative_multiplier_x18": "1003419811982007193"
2405
+ # }
2406
+ # },
2407
+ # {
2408
+ # "product_id": 3,
2409
+ # "lp_balance": {
2410
+ # "amount": "0"
2411
+ # },
2412
+ # "balance": {
2413
+ # "amount": "0",
2414
+ # "last_cumulative_multiplier_x18": "1007584195035969404"
2415
+ # }
2416
+ # },
2417
+ # {
2418
+ # "product_id": 0,
2419
+ # "lp_balance": {
2420
+ # "amount": "0"
2421
+ # },
2422
+ # "balance": {
2423
+ # "amount": "75323297691833342306",
2424
+ # "last_cumulative_multiplier_x18": "1000000002391497578"
2425
+ # }
2426
+ # }
2427
+ # ],
2428
+ # "perp_balances": [
2429
+ # {
2430
+ # "product_id": 2,
2431
+ # "lp_balance": {
2432
+ # "amount": "0",
2433
+ # "last_cumulative_funding_x18": "-284321955122859921"
2434
+ # },
2435
+ # "balance": {
2436
+ # "amount": "0",
2437
+ # "v_quote_balance": "0",
2438
+ # "last_cumulative_funding_x18": "6363466629611946777168"
2439
+ # }
2440
+ # },
2441
+ # {
2442
+ # "product_id": 4,
2443
+ # "lp_balance": {
2444
+ # "amount": "0",
2445
+ # "last_cumulative_funding_x18": "-90979748449893411"
2446
+ # },
2447
+ # "balance": {
2448
+ # "amount": "-200000000000000000",
2449
+ # "v_quote_balance": "419899475698318625259",
2450
+ # "last_cumulative_funding_x18": "141182516563970577208"
2451
+ # }
2452
+ # }
2453
+ # ],
2454
+ # "spot_products": [
2455
+ # {
2456
+ # "product_id": 1,
2457
+ # "oracle_price_x18": "30217830336443750750000",
2458
+ # "risk": {
2459
+ # "long_weight_initial_x18": "750000000000000000",
2460
+ # "short_weight_initial_x18": "1250000000000000000",
2461
+ # "long_weight_maintenance_x18": "800000000000000000",
2462
+ # "short_weight_maintenance_x18": "1200000000000000000",
2463
+ # "large_position_penalty_x18": "0"
2464
+ # },
2465
+ # "config": {
2466
+ # "token": "0x5cc7c91690b2cbaee19a513473d73403e13fb431",
2467
+ # "interest_inflection_util_x18": "800000000000000000",
2468
+ # "interest_floor_x18": "10000000000000000",
2469
+ # "interest_small_cap_x18": "40000000000000000",
2470
+ # "interest_large_cap_x18": "1000000000000000000"
2471
+ # },
2472
+ # "state": {
2473
+ # "cumulative_deposits_multiplier_x18": "1001304691727847318",
2474
+ # "cumulative_borrows_multiplier_x18": "1003419811982007193",
2475
+ # "total_deposits_normalized": "213107447159798397806318",
2476
+ # "total_borrows_normalized": "4907820740150097483532"
2477
+ # },
2478
+ # "lp_state": {
2479
+ # "supply": "1304981417419495030893348",
2480
+ # "quote": {
2481
+ # "amount": "2048495687410669565222259",
2482
+ # "last_cumulative_multiplier_x18": "1000000002391497578"
2483
+ # },
2484
+ # "base": {
2485
+ # "amount": "67623029247538886515",
2486
+ # "last_cumulative_multiplier_x18": "1001304691727847318"
2487
+ # }
2488
+ # },
2489
+ # "book_info": {
2490
+ # "size_increment": "1000000000000000",
2491
+ # "price_increment_x18": "1000000000000000000",
2492
+ # "min_size": "10000000000000000",
2493
+ # "collected_fees": "8865582805773573662738183",
2494
+ # "lp_spread_x18": "3000000000000000"
2495
+ # }
2496
+ # },
2497
+ # {
2498
+ # "product_id": 3,
2499
+ # "oracle_price_x18": "2075217009708333333333",
2500
+ # "risk": {
2501
+ # "long_weight_initial_x18": "750000000000000000",
2502
+ # "short_weight_initial_x18": "1250000000000000000",
2503
+ # "long_weight_maintenance_x18": "800000000000000000",
2504
+ # "short_weight_maintenance_x18": "1200000000000000000",
2505
+ # "large_position_penalty_x18": "0"
2506
+ # },
2507
+ # "config": {
2508
+ # "token": "0xcc59686e3a32fb104c8ff84dd895676265efb8a6",
2509
+ # "interest_inflection_util_x18": "800000000000000000",
2510
+ # "interest_floor_x18": "10000000000000000",
2511
+ # "interest_small_cap_x18": "40000000000000000",
2512
+ # "interest_large_cap_x18": "1000000000000000000"
2513
+ # },
2514
+ # "state": {
2515
+ # "cumulative_deposits_multiplier_x18": "1003722507760089346",
2516
+ # "cumulative_borrows_multiplier_x18": "1007584195035969404",
2517
+ # "total_deposits_normalized": "232750303205807326418622",
2518
+ # "total_borrows_normalized": "110730726549469855171025"
2519
+ # },
2520
+ # "lp_state": {
2521
+ # "supply": "902924999999999999774268",
2522
+ # "quote": {
2523
+ # "amount": "1165328092090344104989049",
2524
+ # "last_cumulative_multiplier_x18": "1000000002391497578"
2525
+ # },
2526
+ # "base": {
2527
+ # "amount": "563265647183403990588",
2528
+ # "last_cumulative_multiplier_x18": "1003722507760089346"
2529
+ # }
2530
+ # },
2531
+ # "book_info": {
2532
+ # "size_increment": "10000000000000000",
2533
+ # "price_increment_x18": "100000000000000000",
2534
+ # "min_size": "100000000000000000",
2535
+ # "collected_fees": "1801521329724633001446457",
2536
+ # "lp_spread_x18": "3000000000000000"
2537
+ # }
2538
+ # },
2539
+ # {
2540
+ # "product_id": 0,
2541
+ # "oracle_price_x18": "1000000000000000000",
2542
+ # "risk": {
2543
+ # "long_weight_initial_x18": "1000000000000000000",
2544
+ # "short_weight_initial_x18": "1000000000000000000",
2545
+ # "long_weight_maintenance_x18": "1000000000000000000",
2546
+ # "short_weight_maintenance_x18": "1000000000000000000",
2547
+ # "large_position_penalty_x18": "0"
2548
+ # },
2549
+ # "config": {
2550
+ # "token": "0x179522635726710dd7d2035a81d856de4aa7836c",
2551
+ # "interest_inflection_util_x18": "800000000000000000",
2552
+ # "interest_floor_x18": "10000000000000000",
2553
+ # "interest_small_cap_x18": "40000000000000000",
2554
+ # "interest_large_cap_x18": "1000000000000000000"
2555
+ # },
2556
+ # "state": {
2557
+ # "cumulative_deposits_multiplier_x18": "1000000002391497578",
2558
+ # "cumulative_borrows_multiplier_x18": "1001593395547514024",
2559
+ # "total_deposits_normalized": "60000256267437588885818752247843",
2560
+ # "total_borrows_normalized": "391445043137305055810336885"
2561
+ # },
2562
+ # "lp_state": {
2563
+ # "supply": "0",
2564
+ # "quote": {
2565
+ # "amount": "0",
2566
+ # "last_cumulative_multiplier_x18": "0"
2567
+ # },
2568
+ # "base": {
2569
+ # "amount": "0",
2570
+ # "last_cumulative_multiplier_x18": "0"
2571
+ # }
2572
+ # },
2573
+ # "book_info": {
2574
+ # "size_increment": "0",
2575
+ # "price_increment_x18": "0",
2576
+ # "min_size": "0",
2577
+ # "collected_fees": "0",
2578
+ # "lp_spread_x18": "0"
2579
+ # }
2580
+ # }
2581
+ # ],
2582
+ # "perp_products": [
2583
+ # {
2584
+ # "product_id": 2,
2585
+ # "oracle_price_x18": "30219079716463070000000",
2586
+ # "risk": {
2587
+ # "long_weight_initial_x18": "875000000000000000",
2588
+ # "short_weight_initial_x18": "1125000000000000000",
2589
+ # "long_weight_maintenance_x18": "900000000000000000",
2590
+ # "short_weight_maintenance_x18": "1100000000000000000",
2591
+ # "large_position_penalty_x18": "0"
2592
+ # },
2593
+ # "state": {
2594
+ # "cumulative_funding_long_x18": "6363466629611946777168",
2595
+ # "cumulative_funding_short_x18": "6363466629611946777168",
2596
+ # "available_settle": "100612314098927536086702448",
2597
+ # "open_interest": "57975708279961875623240"
2598
+ # },
2599
+ # "lp_state": {
2600
+ # "supply": "783207415944433511804197",
2601
+ # "last_cumulative_funding_x18": "6363466629611946777168",
2602
+ # "cumulative_funding_per_lp_x18": "-284321955122859921",
2603
+ # "base": "37321000000000000000",
2604
+ # "quote": "1150991638943862165224593"
2605
+ # },
2606
+ # "book_info": {
2607
+ # "size_increment": "1000000000000000",
2608
+ # "price_increment_x18": "1000000000000000000",
2609
+ # "min_size": "10000000000000000",
2610
+ # "collected_fees": "7738341933653651206856235",
2611
+ # "lp_spread_x18": "3000000000000000"
2612
+ # }
2613
+ # },
2614
+ # {
2615
+ # "product_id": 4,
2616
+ # "oracle_price_x18": "2072129033632754300000",
2617
+ # "risk": {
2618
+ # "long_weight_initial_x18": "875000000000000000",
2619
+ # "short_weight_initial_x18": "1125000000000000000",
2620
+ # "long_weight_maintenance_x18": "900000000000000000",
2621
+ # "short_weight_maintenance_x18": "1100000000000000000",
2622
+ # "large_position_penalty_x18": "0"
2623
+ # },
2624
+ # "state": {
2625
+ # "cumulative_funding_long_x18": "141182516563970577208",
2626
+ # "cumulative_funding_short_x18": "141182516563970577208",
2627
+ # "available_settle": "33807443862986950288685582",
2628
+ # "open_interest": "316343836992291503987611"
2629
+ # },
2630
+ # "lp_state": {
2631
+ # "supply": "541756546038144467864559",
2632
+ # "last_cumulative_funding_x18": "141182516563970577208",
2633
+ # "cumulative_funding_per_lp_x18": "-90979748449893411",
2634
+ # "base": "362320000000000000000",
2635
+ # "quote": "750080187685127907834038"
2636
+ # },
2637
+ # "book_info": {
2638
+ # "size_increment": "10000000000000000",
2639
+ # "price_increment_x18": "100000000000000000",
2640
+ # "min_size": "100000000000000000",
2641
+ # "collected_fees": "1893278317732551619694831",
2642
+ # "lp_spread_x18": "3000000000000000"
2643
+ # }
2644
+ # }
2645
+ # ]
2646
+ # },
2647
+ # "request_type": "query_subaccount_info"
2648
+ # }
2649
+ #
2650
+ data = self.safe_dict(response, 'data', {})
2651
+ balances = self.safe_list(data, 'spot_balances', [])
2652
+ result = {'info': response}
2653
+ for i in range(0, len(balances)):
2654
+ balance = balances[i]
2655
+ marketId = self.safe_string(balance, 'product_id')
2656
+ market = self.safe_market(marketId)
2657
+ isUsdcMarketId = marketId == '0'
2658
+ if market['id'] is None and not isUsdcMarketId:
2659
+ continue
2660
+ baseId = 'USDC' if (isUsdcMarketId) else self.safe_string(market, 'baseId')
2661
+ code = self.safe_currency_code(baseId)
2662
+ account = self.account()
2663
+ tokenBalance = self.safe_dict(balance, 'balance', {})
2664
+ total = self.convert_from_x18(self.safe_string(tokenBalance, 'amount'))
2665
+ account['total'] = total
2666
+ result[code] = account
2667
+ return self.safe_balance(result)
2668
+
2669
+ def parse_position(self, position, market: Market = None):
2670
+ #
2671
+ # {
2672
+ # "product_id": 2,
2673
+ # "lp_balance": {
2674
+ # "amount": "0",
2675
+ # "last_cumulative_funding_x18": "-284321955122859921"
2676
+ # },
2677
+ # "balance": {
2678
+ # "amount": "0",
2679
+ # "v_quote_balance": "0",
2680
+ # "last_cumulative_funding_x18": "6363466629611946777168"
2681
+ # }
2682
+ # },
2683
+ # {
2684
+ # "product_id": 4,
2685
+ # "lp_balance": {
2686
+ # "amount": "0",
2687
+ # "last_cumulative_funding_x18": "-90979748449893411"
2688
+ # },
2689
+ # "balance": {
2690
+ # "amount": "-200000000000000000",
2691
+ # "v_quote_balance": "419899475698318625259",
2692
+ # "last_cumulative_funding_x18": "141182516563970577208"
2693
+ # }
2694
+ # }
2695
+ #
2696
+ marketId = self.safe_string(position, 'product_id')
2697
+ market = self.safe_market(marketId)
2698
+ balance = self.safe_dict(position, 'balance', {})
2699
+ contractSize = self.convert_from_x18(self.safe_string(balance, 'amount'))
2700
+ side = 'buy'
2701
+ if Precise.string_lt(contractSize, '1'):
2702
+ side = 'sell'
2703
+ return self.safe_position({
2704
+ 'info': position,
2705
+ 'id': None,
2706
+ 'symbol': self.safe_string(market, 'symbol'),
2707
+ 'timestamp': None,
2708
+ 'datetime': None,
2709
+ 'lastUpdateTimestamp': None,
2710
+ 'initialMargin': None,
2711
+ 'initialMarginPercentage': None,
2712
+ 'maintenanceMargin': None,
2713
+ 'maintenanceMarginPercentage': None,
2714
+ 'entryPrice': None,
2715
+ 'notional': None,
2716
+ 'leverage': None,
2717
+ 'unrealizedPnl': None,
2718
+ 'contracts': None,
2719
+ 'contractSize': self.parse_to_numeric(contractSize),
2720
+ 'marginRatio': None,
2721
+ 'liquidationPrice': None,
2722
+ 'markPrice': None,
2723
+ 'lastPrice': None,
2724
+ 'collateral': None,
2725
+ 'marginMode': 'cross',
2726
+ 'marginType': None,
2727
+ 'side': side,
2728
+ 'percentage': None,
2729
+ 'hedged': None,
2730
+ 'stopLossPrice': None,
2731
+ 'takeProfitPrice': None,
2732
+ })
2733
+
2734
+ async def fetch_positions(self, symbols: Strings = None, params={}):
2735
+ """
2736
+ fetch all open positions
2737
+
2738
+ https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/subaccount-info
2739
+
2740
+ :param str[] [symbols]: list of unified market symbols
2741
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2742
+ :param str [params.user]: user address, will default to self.walletAddress if not provided
2743
+ :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
2744
+ """
2745
+ userAddress = None
2746
+ userAddress, params = self.handle_public_address('fetchPositions', params)
2747
+ request = {
2748
+ 'type': 'subaccount_info',
2749
+ 'subaccount': self.convert_address_to_sender(userAddress),
2750
+ }
2751
+ response = await self.v1GatewayGetQuery(self.extend(request, params))
2752
+ # the response is the same
2753
+ data = self.safe_dict(response, 'data', {})
2754
+ positions = self.safe_list(data, 'perp_balances', [])
2755
+ symbols = self.market_symbols(symbols)
2756
+ result = []
2757
+ for i in range(0, len(positions)):
2758
+ position = self.extend(self.parse_position(positions[i], None), params)
2759
+ if position['contractSize'] == 0:
2760
+ continue
2761
+ result.append(position)
2762
+ return self.filter_by_array_positions(result, 'symbol', symbols, False)
2763
+
2764
+ async def query_nonces(self):
2765
+ request = {
2766
+ 'type': 'nonces',
2767
+ 'address': self.walletAddress,
2768
+ }
2769
+ response = await self.v1GatewayGetQuery(request)
2770
+ #
2771
+ # {
2772
+ # "status":"success",
2773
+ # "data":{
2774
+ # "tx_nonce": 0,
2775
+ # "order_nonce": 1753048133299863552
2776
+ # },
2777
+ # "request_type": "query_nonces",
2778
+ # }
2779
+ #
2780
+ return self.safe_dict(response, 'data', {})
2781
+
2782
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
2783
+ """
2784
+ make a withdrawal
2785
+
2786
+ https://docs.vertexprotocol.com/developer-resources/api/withdrawing-on-chain
2787
+
2788
+ :param str code: unified currency code
2789
+ :param float amount: the amount to withdraw
2790
+ :param str address: the address to withdraw to
2791
+ :param str tag:
2792
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2793
+ :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
2794
+ """
2795
+ self.check_required_credentials()
2796
+ await self.load_markets()
2797
+ currency = self.currency(code)
2798
+ contracts = await self.query_contracts()
2799
+ chainId = self.safe_string(contracts, 'chain_id')
2800
+ verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
2801
+ nonces = await self.query_nonces()
2802
+ nonce = self.safe_number(nonces, 'tx_nonce')
2803
+ withdraw = {
2804
+ 'sender': self.convert_address_to_sender(self.walletAddress),
2805
+ 'productId': self.parse_to_numeric(currency['id']),
2806
+ 'amount': str(amount),
2807
+ 'nonce': nonce,
2808
+ }
2809
+ request = {
2810
+ 'withdraw_collateral': {
2811
+ 'tx': {
2812
+ 'sender': withdraw['sender'],
2813
+ 'productId': withdraw['productId'],
2814
+ 'amount': withdraw['amount'],
2815
+ 'nonce': self.number_to_string(withdraw['nonce']),
2816
+ },
2817
+ 'signature': self.build_withdraw_sig(withdraw, chainId, verifyingContractAddress),
2818
+ },
2819
+ }
2820
+ response = await self.v1GatewayPostExecute(self.extend(request, params))
2821
+ #
2822
+ # {
2823
+ # "status": "success",
2824
+ # "signature": {signature},
2825
+ # "request_type": "execute_withdraw_collateral"
2826
+ # }
2827
+ #
2828
+ transaction = self.parse_transaction(response, currency)
2829
+ return self.extend(transaction, {
2830
+ 'amount': amount,
2831
+ 'address': address,
2832
+ })
2833
+
2834
+ def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
2835
+ #
2836
+ # {
2837
+ # "status": "success",
2838
+ # "signature": {signature},
2839
+ # "request_type": "execute_withdraw_collateral"
2840
+ # }
2841
+ #
2842
+ code = None
2843
+ if currency is not None:
2844
+ code = currency['code']
2845
+ return {
2846
+ 'info': transaction,
2847
+ 'id': None,
2848
+ 'txid': None,
2849
+ 'timestamp': None,
2850
+ 'datetime': None,
2851
+ 'addressFrom': None,
2852
+ 'address': None,
2853
+ 'addressTo': None,
2854
+ 'tagFrom': None,
2855
+ 'tag': None,
2856
+ 'tagTo': None,
2857
+ 'type': 'withdrawal',
2858
+ 'amount': None,
2859
+ 'currency': code,
2860
+ 'status': self.parse_transaction_status(self.safe_string(transaction, 'status')),
2861
+ 'updated': None,
2862
+ 'network': None,
2863
+ 'comment': None,
2864
+ 'internal': None,
2865
+ 'fee': None,
2866
+ }
2867
+
2868
+ def parse_transaction_status(self, status: Str):
2869
+ statuses: dict = {
2870
+ 'success': 'ok',
2871
+ }
2872
+ return self.safe_string(statuses, status, status)
2873
+
2874
+ def handle_public_address(self, methodName: str, params: dict):
2875
+ userAux = None
2876
+ userAux, params = self.handle_option_and_params(params, methodName, 'user')
2877
+ user = userAux
2878
+ user, params = self.handle_option_and_params(params, methodName, 'address', userAux)
2879
+ if (user is not None) and (user != ''):
2880
+ return [user, params]
2881
+ if (self.walletAddress is not None) and (self.walletAddress != ''):
2882
+ return [self.walletAddress, params]
2883
+ raise ArgumentsRequired(self.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set')
2884
+
2885
+ def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
2886
+ if not response:
2887
+ return None # fallback to default error handler
2888
+ #
2889
+ #
2890
+ status = self.safe_string(response, 'status', '')
2891
+ if status == 'failure':
2892
+ message = self.safe_string(response, 'error')
2893
+ feedback = self.id + ' ' + body
2894
+ errorCode = self.safe_string(response, 'error_code')
2895
+ self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
2896
+ self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
2897
+ raise ExchangeError(feedback)
2898
+ return None
2899
+
2900
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
2901
+ version = self.safe_string(api, 0)
2902
+ type = self.safe_string(api, 1)
2903
+ url = self.implode_hostname(self.urls['api'][version][type])
2904
+ if version != 'v1' or type != 'archive':
2905
+ url = url + '/' + path
2906
+ if method == 'POST':
2907
+ headers = {
2908
+ 'Content-Type': 'application/json',
2909
+ }
2910
+ body = self.json(params)
2911
+ else:
2912
+ if params:
2913
+ url += '?' + self.urlencode(params)
2914
+ if path != 'execute':
2915
+ # required encoding for public methods
2916
+ if headers is not None:
2917
+ headers['Accept-Encoding'] = 'gzip'
2918
+ else:
2919
+ headers = {
2920
+ 'Accept-Encoding': 'gzip',
2921
+ }
2922
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}