ccxt 4.5.56 → 4.5.58

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 (1055) hide show
  1. package/README.md +11 -13
  2. package/dist/ccxt.browser.min.js +34 -14
  3. package/dist/cjs/ccxt.js +6 -22
  4. package/dist/cjs/src/abstract/aftermath.js +1 -1
  5. package/dist/cjs/src/abstract/alpaca.js +1 -1
  6. package/dist/cjs/src/abstract/apex.js +1 -1
  7. package/dist/cjs/src/abstract/ascendex.js +1 -1
  8. package/dist/cjs/src/abstract/aster.js +1 -1
  9. package/dist/cjs/src/abstract/backpack.js +1 -1
  10. package/dist/cjs/src/abstract/bigone.js +1 -1
  11. package/dist/cjs/src/abstract/binance.js +1 -1
  12. package/dist/cjs/src/abstract/bingx.js +1 -1
  13. package/dist/cjs/src/abstract/bit2c.js +1 -1
  14. package/dist/cjs/src/abstract/bitbank.js +1 -1
  15. package/dist/cjs/src/abstract/bitbns.js +1 -1
  16. package/dist/cjs/src/abstract/bitfinex.js +1 -1
  17. package/dist/cjs/src/abstract/bitflyer.js +1 -1
  18. package/dist/cjs/src/abstract/bitget.js +1 -1
  19. package/dist/cjs/src/abstract/bithumb.js +1 -1
  20. package/dist/cjs/src/abstract/bitmart.js +1 -1
  21. package/dist/cjs/src/abstract/bitmex.js +1 -1
  22. package/dist/cjs/src/abstract/bitopro.js +1 -1
  23. package/dist/cjs/src/abstract/bitrue.js +1 -1
  24. package/dist/cjs/src/abstract/bitso.js +1 -1
  25. package/dist/cjs/src/abstract/bitstamp.js +1 -1
  26. package/dist/cjs/src/abstract/bitteam.js +1 -1
  27. package/dist/cjs/src/abstract/bittrade.js +1 -1
  28. package/dist/cjs/src/abstract/bitvavo.js +1 -1
  29. package/dist/cjs/src/abstract/blockchaincom.js +1 -1
  30. package/dist/cjs/src/abstract/blofin.js +1 -1
  31. package/dist/cjs/src/abstract/btcbox.js +1 -1
  32. package/dist/cjs/src/abstract/btcmarkets.js +1 -1
  33. package/dist/cjs/src/abstract/btcturk.js +1 -1
  34. package/dist/cjs/src/abstract/bullish.js +1 -1
  35. package/dist/cjs/src/abstract/bybit.js +1 -1
  36. package/dist/cjs/src/abstract/bydfi.js +1 -1
  37. package/dist/cjs/src/abstract/cex.js +1 -1
  38. package/dist/cjs/src/abstract/coinbase.js +1 -1
  39. package/dist/cjs/src/abstract/coinbaseexchange.js +1 -1
  40. package/dist/cjs/src/abstract/coinbaseinternational.js +1 -1
  41. package/dist/cjs/src/abstract/coincheck.js +1 -1
  42. package/dist/cjs/src/abstract/coinex.js +1 -1
  43. package/dist/cjs/src/abstract/coinmate.js +1 -1
  44. package/dist/cjs/src/abstract/coinmetro.js +1 -1
  45. package/dist/cjs/src/abstract/coinone.js +1 -1
  46. package/dist/cjs/src/abstract/coinsph.js +1 -1
  47. package/dist/cjs/src/abstract/coinspot.js +1 -1
  48. package/dist/cjs/src/abstract/cryptocom.js +1 -1
  49. package/dist/cjs/src/abstract/cryptomus.js +1 -1
  50. package/dist/cjs/src/abstract/deepcoin.js +1 -1
  51. package/dist/cjs/src/abstract/delta.js +1 -1
  52. package/dist/cjs/src/abstract/deribit.js +1 -1
  53. package/dist/cjs/src/abstract/derive.js +1 -1
  54. package/dist/cjs/src/abstract/digifinex.js +1 -1
  55. package/dist/cjs/src/abstract/dydx.js +1 -1
  56. package/dist/cjs/src/abstract/exmo.js +1 -1
  57. package/dist/cjs/src/abstract/{arkham.js → extended.js} +1 -1
  58. package/dist/cjs/src/abstract/foxbit.js +1 -1
  59. package/dist/cjs/src/abstract/gate.js +1 -1
  60. package/dist/cjs/src/abstract/gemini.js +1 -1
  61. package/dist/cjs/src/abstract/grvt.js +1 -1
  62. package/dist/cjs/src/abstract/hashkey.js +1 -1
  63. package/dist/cjs/src/abstract/hibachi.js +1 -1
  64. package/dist/cjs/src/abstract/hitbtc.js +1 -1
  65. package/dist/cjs/src/abstract/hollaex.js +1 -1
  66. package/dist/cjs/src/abstract/htx.js +1 -1
  67. package/dist/cjs/src/abstract/hyperliquid.js +1 -1
  68. package/dist/cjs/src/abstract/independentreserve.js +1 -1
  69. package/dist/cjs/src/abstract/indodax.js +1 -1
  70. package/dist/cjs/src/abstract/kraken.js +1 -1
  71. package/dist/cjs/src/abstract/krakenfutures.js +1 -1
  72. package/dist/cjs/src/abstract/kucoin.js +1 -1
  73. package/dist/cjs/src/abstract/latoken.js +1 -1
  74. package/dist/cjs/src/abstract/lbank.js +1 -1
  75. package/dist/cjs/src/abstract/lighter.js +1 -1
  76. package/dist/cjs/src/abstract/luno.js +1 -1
  77. package/dist/cjs/src/abstract/mercado.js +1 -1
  78. package/dist/cjs/src/abstract/mexc.js +1 -1
  79. package/dist/cjs/src/abstract/modetrade.js +1 -1
  80. package/dist/cjs/src/abstract/ndax.js +1 -1
  81. package/dist/cjs/src/abstract/novadax.js +1 -1
  82. package/dist/cjs/src/abstract/okx.js +1 -1
  83. package/dist/cjs/src/abstract/onetrading.js +1 -1
  84. package/dist/cjs/src/abstract/p2b.js +1 -1
  85. package/dist/cjs/src/abstract/pacifica.js +1 -1
  86. package/dist/cjs/src/abstract/paradex.js +1 -1
  87. package/dist/cjs/src/abstract/paymium.js +1 -1
  88. package/dist/cjs/src/abstract/phemex.js +1 -1
  89. package/dist/cjs/src/abstract/poloniex.js +1 -1
  90. package/dist/cjs/src/abstract/tokocrypto.js +1 -1
  91. package/dist/cjs/src/abstract/toobit.js +1 -1
  92. package/dist/cjs/src/abstract/upbit.js +1 -1
  93. package/dist/cjs/src/abstract/weex.js +1 -1
  94. package/dist/cjs/src/abstract/whitebit.js +1 -1
  95. package/dist/cjs/src/abstract/woo.js +1 -1
  96. package/dist/cjs/src/abstract/woofipro.js +1 -1
  97. package/dist/cjs/src/abstract/xt.js +1 -1
  98. package/dist/cjs/src/abstract/zaif.js +1 -1
  99. package/dist/cjs/src/abstract/zebpay.js +1 -1
  100. package/dist/cjs/src/aftermath.js +1 -0
  101. package/dist/cjs/src/alpaca.js +1 -1
  102. package/dist/cjs/src/apex.js +2 -2
  103. package/dist/cjs/src/ascendex.js +3 -3
  104. package/dist/cjs/src/aster.js +8 -5
  105. package/dist/cjs/src/backpack.js +15 -7
  106. package/dist/cjs/src/base/Exchange.js +69 -32
  107. package/dist/cjs/src/base/Precise.js +7 -7
  108. package/dist/cjs/src/base/errors.js +6 -0
  109. package/dist/cjs/src/base/functions/crypto.js +1 -1
  110. package/dist/cjs/src/base/functions/encode.js +1 -1
  111. package/dist/cjs/src/base/functions/io.js +26 -1
  112. package/dist/cjs/src/base/functions/misc.js +1 -0
  113. package/dist/cjs/src/base/functions/number.js +6 -0
  114. package/dist/cjs/src/base/functions/platform.js +6 -0
  115. package/dist/cjs/src/base/functions/rsa.js +1 -0
  116. package/dist/cjs/src/base/functions/string.js +6 -0
  117. package/dist/cjs/src/base/functions/throttle.js +1 -1
  118. package/dist/cjs/src/base/functions/time.js +6 -0
  119. package/dist/cjs/src/base/functions/totp.js +1 -0
  120. package/dist/cjs/src/base/functions/type.js +6 -0
  121. package/dist/cjs/src/base/functions.js +2 -1
  122. package/dist/cjs/src/base/ws/Cache.js +6 -0
  123. package/dist/cjs/src/base/ws/Client.js +1 -0
  124. package/dist/cjs/src/base/ws/Future.js +3 -7
  125. package/dist/cjs/src/base/ws/OrderBook.js +1 -1
  126. package/dist/cjs/src/base/ws/OrderBookSide.js +6 -0
  127. package/dist/cjs/src/base/ws/WsClient.js +5 -1
  128. package/dist/cjs/src/bequant.js +1 -1
  129. package/dist/cjs/src/bigone.js +4 -4
  130. package/dist/cjs/src/binance.js +193 -195
  131. package/dist/cjs/src/binancecoinm.js +1 -1
  132. package/dist/cjs/src/binanceus.js +1 -1
  133. package/dist/cjs/src/binanceusdm.js +1 -1
  134. package/dist/cjs/src/bingx.js +4 -4
  135. package/dist/cjs/src/bit2c.js +1 -1
  136. package/dist/cjs/src/bitbank.js +1 -1
  137. package/dist/cjs/src/bitbns.js +1 -1
  138. package/dist/cjs/src/bitfinex.js +72 -59
  139. package/dist/cjs/src/bitflyer.js +1 -1
  140. package/dist/cjs/src/bitget.js +3 -3
  141. package/dist/cjs/src/bithumb.js +1 -1
  142. package/dist/cjs/src/bitmart.js +14 -7
  143. package/dist/cjs/src/bitmex.js +2 -2
  144. package/dist/cjs/src/bitopro.js +2 -2
  145. package/dist/cjs/src/bitrue.js +3 -3
  146. package/dist/cjs/src/bitso.js +2 -2
  147. package/dist/cjs/src/bitstamp.js +3 -2
  148. package/dist/cjs/src/bitteam.js +2 -2
  149. package/dist/cjs/src/bittrade.js +1 -2
  150. package/dist/cjs/src/bitvavo.js +457 -34
  151. package/dist/cjs/src/blockchaincom.js +1 -1
  152. package/dist/cjs/src/blofin.js +27 -4
  153. package/dist/cjs/src/btcbox.js +2 -2
  154. package/dist/cjs/src/btcmarkets.js +1 -1
  155. package/dist/cjs/src/btcturk.js +1 -1
  156. package/dist/cjs/src/bullish.js +7 -6
  157. package/dist/cjs/src/bybit.js +1 -1
  158. package/dist/cjs/src/bybiteu.js +1 -1
  159. package/dist/cjs/src/bydfi.js +2 -2
  160. package/dist/cjs/src/cex.js +4 -4
  161. package/dist/cjs/src/coinbase.js +75 -65
  162. package/dist/cjs/src/coinbaseadvanced.js +1 -1
  163. package/dist/cjs/src/coinbaseexchange.js +2 -2
  164. package/dist/cjs/src/coinbaseinternational.js +2 -1
  165. package/dist/cjs/src/coincheck.js +1 -1
  166. package/dist/cjs/src/coinex.js +75 -75
  167. package/dist/cjs/src/coinmate.js +1 -1
  168. package/dist/cjs/src/coinmetro.js +2 -2
  169. package/dist/cjs/src/coinone.js +1 -1
  170. package/dist/cjs/src/coinsph.js +2 -1
  171. package/dist/cjs/src/coinspot.js +1 -1
  172. package/dist/cjs/src/cryptocom.js +47 -49
  173. package/dist/cjs/src/cryptomus.js +44 -40
  174. package/dist/cjs/src/deepcoin.js +5 -4
  175. package/dist/cjs/src/delta.js +52 -53
  176. package/dist/cjs/src/deribit.js +32 -34
  177. package/dist/cjs/src/derive.js +27 -29
  178. package/dist/cjs/src/digifinex.js +44 -45
  179. package/dist/cjs/src/dydx.js +1 -1
  180. package/dist/cjs/src/exmo.js +93 -84
  181. package/dist/cjs/src/extended.js +3497 -0
  182. package/dist/cjs/src/fmfwio.js +1 -1
  183. package/dist/cjs/src/foxbit.js +72 -76
  184. package/dist/cjs/src/gate.js +54 -54
  185. package/dist/cjs/src/gemini.js +42 -44
  186. package/dist/cjs/src/grvt.js +5 -5
  187. package/dist/cjs/src/hashkey.js +53 -55
  188. package/dist/cjs/src/hibachi.js +1 -1
  189. package/dist/cjs/src/hitbtc.js +4 -13
  190. package/dist/cjs/src/hollaex.js +52 -55
  191. package/dist/cjs/src/htx.js +76 -68
  192. package/dist/cjs/src/huobi.js +1 -1
  193. package/dist/cjs/src/hyperliquid.js +42 -43
  194. package/dist/cjs/src/independentreserve.js +1 -1
  195. package/dist/cjs/src/indodax.js +3 -3
  196. package/dist/cjs/src/kraken.js +58 -59
  197. package/dist/cjs/src/krakenfutures.js +1 -1
  198. package/dist/cjs/src/kucoin.js +4 -3
  199. package/dist/cjs/src/kucoinfutures.js +1 -1
  200. package/dist/cjs/src/latoken.js +31 -33
  201. package/dist/cjs/src/lbank.js +57 -57
  202. package/dist/cjs/src/lighter.js +42 -42
  203. package/dist/cjs/src/luno.js +36 -44
  204. package/dist/cjs/src/mercado.js +1 -1
  205. package/dist/cjs/src/mexc.js +49 -50
  206. package/dist/cjs/src/modetrade.js +51 -53
  207. package/dist/cjs/src/myokx.js +1 -1
  208. package/dist/cjs/src/ndax.js +36 -38
  209. package/dist/cjs/src/novadax.js +1 -1
  210. package/dist/cjs/src/okx.js +18 -3
  211. package/dist/cjs/src/okxus.js +1 -1
  212. package/dist/cjs/src/onetrading.js +22 -24
  213. package/dist/cjs/src/p2b.js +1 -1
  214. package/dist/cjs/src/pacifica.js +1 -1
  215. package/dist/cjs/src/paradex.js +1 -1
  216. package/dist/cjs/src/paymium.js +1 -1
  217. package/dist/cjs/src/phemex.js +43 -45
  218. package/dist/cjs/src/poloniex.js +18 -13
  219. package/dist/cjs/src/pro/alpaca.js +2 -2
  220. package/dist/cjs/src/pro/apex.js +2 -2
  221. package/dist/cjs/src/pro/ascendex.js +1 -1
  222. package/dist/cjs/src/pro/aster.js +1 -1
  223. package/dist/cjs/src/pro/backpack.js +2 -2
  224. package/dist/cjs/src/pro/bequant.js +1 -1
  225. package/dist/cjs/src/pro/binance.js +3 -3
  226. package/dist/cjs/src/pro/binancecoinm.js +1 -1
  227. package/dist/cjs/src/pro/binanceus.js +1 -1
  228. package/dist/cjs/src/pro/binanceusdm.js +1 -1
  229. package/dist/cjs/src/pro/bingx.js +1 -1
  230. package/dist/cjs/src/pro/bitfinex.js +1 -1
  231. package/dist/cjs/src/pro/bitget.js +2 -2
  232. package/dist/cjs/src/pro/bithumb.js +2 -2
  233. package/dist/cjs/src/pro/bitmart.js +1 -1
  234. package/dist/cjs/src/pro/bitmex.js +1 -1
  235. package/dist/cjs/src/pro/bitrue.js +1 -1
  236. package/dist/cjs/src/pro/bitstamp.js +2 -2
  237. package/dist/cjs/src/pro/bittrade.js +1 -1
  238. package/dist/cjs/src/pro/bitvavo.js +1 -1
  239. package/dist/cjs/src/pro/blockchaincom.js +2 -2
  240. package/dist/cjs/src/pro/blofin.js +1 -1
  241. package/dist/cjs/src/pro/bullish.js +1 -1
  242. package/dist/cjs/src/pro/bybit.js +2 -2
  243. package/dist/cjs/src/pro/bybiteu.js +1 -1
  244. package/dist/cjs/src/pro/bydfi.js +1 -1
  245. package/dist/cjs/src/pro/cex.js +2 -2
  246. package/dist/cjs/src/pro/coinbase.js +1 -1
  247. package/dist/cjs/src/pro/coinbaseadvanced.js +1 -1
  248. package/dist/cjs/src/pro/coinbaseexchange.js +1 -1
  249. package/dist/cjs/src/pro/coinbaseinternational.js +1 -1
  250. package/dist/cjs/src/pro/coincheck.js +1 -1
  251. package/dist/cjs/src/pro/coinex.js +2 -2
  252. package/dist/cjs/src/pro/coinone.js +2 -2
  253. package/dist/cjs/src/pro/cryptocom.js +4 -2
  254. package/dist/cjs/src/pro/deepcoin.js +1 -1
  255. package/dist/cjs/src/pro/deribit.js +1 -1
  256. package/dist/cjs/src/pro/dydx.js +2 -2
  257. package/dist/cjs/src/pro/exmo.js +2 -2
  258. package/dist/cjs/src/pro/extended.js +865 -0
  259. package/dist/cjs/src/pro/gate.js +2 -2
  260. package/dist/cjs/src/pro/gemini.js +1 -1
  261. package/dist/cjs/src/pro/grvt.js +1 -1
  262. package/dist/cjs/src/pro/hashkey.js +8 -7
  263. package/dist/cjs/src/pro/hitbtc.js +1 -1
  264. package/dist/cjs/src/pro/hollaex.js +2 -2
  265. package/dist/cjs/src/pro/htx.js +1 -1
  266. package/dist/cjs/src/pro/huobi.js +1 -1
  267. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  268. package/dist/cjs/src/pro/independentreserve.js +2 -2
  269. package/dist/cjs/src/pro/kraken.js +1 -1
  270. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  271. package/dist/cjs/src/pro/kucoin.js +2 -2
  272. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  273. package/dist/cjs/src/pro/lbank.js +1 -0
  274. package/dist/cjs/src/pro/lighter.js +1 -1
  275. package/dist/cjs/src/pro/luno.js +4 -4
  276. package/dist/cjs/src/pro/mexc.js +1 -1
  277. package/dist/cjs/src/pro/myokx.js +1 -1
  278. package/dist/cjs/src/pro/ndax.js +1 -1
  279. package/dist/cjs/src/pro/okx.js +1 -1
  280. package/dist/cjs/src/pro/okxus.js +1 -1
  281. package/dist/cjs/src/pro/onetrading.js +2 -2
  282. package/dist/cjs/src/pro/p2b.js +1 -1
  283. package/dist/cjs/src/pro/pacifica.js +1 -1
  284. package/dist/cjs/src/pro/paradex.js +1 -1
  285. package/dist/cjs/src/pro/phemex.js +1 -1
  286. package/dist/cjs/src/pro/poloniex.js +1 -1
  287. package/dist/cjs/src/pro/toobit.js +2 -2
  288. package/dist/cjs/src/pro/upbit.js +1 -1
  289. package/dist/cjs/src/pro/weex.js +2 -2
  290. package/dist/cjs/src/pro/whitebit.js +2 -2
  291. package/dist/cjs/src/pro/xt.js +1 -1
  292. package/dist/cjs/src/protobuf/mexc/compiled.cjs.js +0 -1
  293. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +1 -0
  294. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +1 -0
  295. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +1 -0
  296. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +1 -0
  297. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +1 -0
  298. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +1 -0
  299. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +1 -0
  300. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +1 -0
  301. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +1 -0
  302. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +1 -0
  303. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +1 -0
  304. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +1 -0
  305. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +1 -0
  306. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +1 -0
  307. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +6 -0
  308. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +1 -0
  309. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +1 -0
  310. package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +6 -0
  311. package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -1
  312. package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
  313. package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
  314. package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +1 -0
  315. package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
  316. package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +1 -0
  317. package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
  318. package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
  319. package/dist/cjs/src/static_dependencies/ethers/coders/null.js +1 -0
  320. package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
  321. package/dist/cjs/src/static_dependencies/ethers/coders/string.js +1 -0
  322. package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +1 -0
  323. package/dist/cjs/src/static_dependencies/ethers/fragments.js +6 -0
  324. package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +6 -0
  325. package/dist/cjs/src/static_dependencies/ethers/index.js +1 -10
  326. package/dist/cjs/src/static_dependencies/ethers/interface.js +6 -0
  327. package/dist/cjs/src/static_dependencies/ethers/typed.js +6 -0
  328. package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +1 -13
  329. package/dist/cjs/src/static_dependencies/ethers/utils/data.js +1 -6
  330. package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +1 -9
  331. package/dist/cjs/src/static_dependencies/ethers/utils/events.js +6 -0
  332. package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
  333. package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -7
  334. package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +1 -5
  335. package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +6 -0
  336. package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +1 -8
  337. package/dist/cjs/src/static_dependencies/fflake/browser.js +1 -1
  338. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -0
  339. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +1 -0
  340. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +1 -1
  341. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
  342. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
  343. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
  344. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +1 -0
  345. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1 -1
  346. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
  347. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +1 -1
  348. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +1 -1
  349. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
  350. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1 -1
  351. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
  352. package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +6 -0
  353. package/dist/cjs/src/static_dependencies/noble-curves/_shortw_utils.js +1 -1
  354. package/dist/cjs/src/static_dependencies/noble-curves/abstract/curve.js +1 -1
  355. package/dist/cjs/src/static_dependencies/noble-curves/abstract/edwards.js +1 -1
  356. package/dist/cjs/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +1 -0
  357. package/dist/cjs/src/static_dependencies/noble-curves/abstract/modular.js +1 -1
  358. package/dist/cjs/src/static_dependencies/noble-curves/abstract/montgomery.js +1 -1
  359. package/dist/cjs/src/static_dependencies/noble-curves/abstract/poseidon.js +1 -1
  360. package/dist/cjs/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
  361. package/dist/cjs/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -1
  362. package/dist/cjs/src/static_dependencies/noble-curves/ed25519.js +1 -1
  363. package/dist/cjs/src/static_dependencies/noble-curves/p256.js +1 -1
  364. package/dist/cjs/src/static_dependencies/noble-curves/secp256k1.js +1 -1
  365. package/dist/cjs/src/static_dependencies/noble-hashes/_assert.js +6 -0
  366. package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -0
  367. package/dist/cjs/src/static_dependencies/noble-hashes/_u64.js +6 -0
  368. package/dist/cjs/src/static_dependencies/noble-hashes/crypto.js +6 -0
  369. package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -0
  370. package/dist/cjs/src/static_dependencies/noble-hashes/md5.js +1 -0
  371. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +1 -0
  372. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +1 -0
  373. package/dist/cjs/src/static_dependencies/noble-hashes/sha1.js +1 -0
  374. package/dist/cjs/src/static_dependencies/noble-hashes/sha256.js +1 -0
  375. package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -0
  376. package/dist/cjs/src/static_dependencies/noble-hashes/sha512.js +1 -0
  377. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +1 -1
  378. package/dist/cjs/src/static_dependencies/node-fetch/body.js +1 -5
  379. package/dist/cjs/src/static_dependencies/node-fetch/errors/abort-error.js +1 -0
  380. package/dist/cjs/src/static_dependencies/node-fetch/errors/base.js +6 -0
  381. package/dist/cjs/src/static_dependencies/node-fetch/errors/fetch-error.js +1 -0
  382. package/dist/cjs/src/static_dependencies/node-fetch/headers.js +1 -5
  383. package/dist/cjs/src/static_dependencies/node-fetch/index.js +1 -7
  384. package/dist/cjs/src/static_dependencies/node-fetch/request.js +1 -7
  385. package/dist/cjs/src/static_dependencies/node-fetch/response.js +1 -5
  386. package/dist/cjs/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
  387. package/dist/cjs/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
  388. package/dist/cjs/src/static_dependencies/node-fetch/utils/is.js +6 -0
  389. package/dist/cjs/src/static_dependencies/node-fetch/utils/referrer.js +1 -0
  390. package/dist/cjs/src/static_dependencies/proxies/agent-base/index.js +1 -0
  391. package/dist/cjs/src/static_dependencies/proxies/http-proxy-agent/index.js +1 -0
  392. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/index.js +1 -0
  393. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
  394. package/dist/cjs/src/static_dependencies/qs/formats.js +6 -0
  395. package/dist/cjs/src/static_dependencies/qs/index.js +1 -0
  396. package/dist/cjs/src/static_dependencies/qs/parse.js +1 -0
  397. package/dist/cjs/src/static_dependencies/qs/stringify.js +1 -0
  398. package/dist/cjs/src/static_dependencies/qs/utils.js +6 -0
  399. package/dist/cjs/src/static_dependencies/scure-base/index.js +6 -0
  400. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +1 -19
  401. package/dist/cjs/src/static_dependencies/scure-bip39/index.js +1 -1
  402. package/dist/cjs/src/static_dependencies/scure-bip39/wordlists/english.js +6 -0
  403. package/dist/cjs/src/static_dependencies/scure-starknet/index.js +1 -1
  404. package/dist/cjs/src/static_dependencies/starknet/constants.js +1 -1
  405. package/dist/cjs/src/static_dependencies/starknet/types/calldata.js +6 -0
  406. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
  407. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
  408. package/dist/cjs/src/static_dependencies/starknet/types/lib/index.js +6 -0
  409. package/dist/cjs/src/static_dependencies/starknet/types/typedData.js +6 -0
  410. package/dist/cjs/src/static_dependencies/starknet/utils/assert.js +6 -0
  411. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +1 -1
  412. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +1 -1
  413. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +1 -1
  414. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/byteArray.js +1 -0
  415. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/cairo.js +1 -0
  416. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
  417. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
  418. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
  419. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/formatter.js +1 -0
  420. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/index.js +1 -1
  421. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/index.js +1 -0
  422. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +1 -0
  423. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
  424. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +1 -0
  425. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/requestParser.js +1 -0
  426. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/responseParser.js +1 -0
  427. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/tuple.js +1 -1
  428. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/validate.js +1 -4
  429. package/dist/cjs/src/static_dependencies/starknet/utils/encode.js +1 -0
  430. package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +8 -10
  431. package/dist/cjs/src/static_dependencies/starknet/utils/merkle.js +1 -0
  432. package/dist/cjs/src/static_dependencies/starknet/utils/num.js +1 -0
  433. package/dist/cjs/src/static_dependencies/starknet/utils/selector.js +1 -0
  434. package/dist/cjs/src/static_dependencies/starknet/utils/shortString.js +1 -0
  435. package/dist/cjs/src/static_dependencies/starknet/utils/typedData.js +1 -1
  436. package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +6 -0
  437. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +6 -0
  438. package/dist/cjs/src/tokocrypto.js +2 -2
  439. package/dist/cjs/src/toobit.js +3 -3
  440. package/dist/cjs/src/upbit.js +4 -4
  441. package/dist/cjs/src/weex.js +65 -63
  442. package/dist/cjs/src/whitebit.js +62 -64
  443. package/dist/cjs/src/woo.js +66 -55
  444. package/dist/cjs/src/woofipro.js +54 -48
  445. package/dist/cjs/src/xt.js +2 -3
  446. package/dist/cjs/src/zaif.js +1 -1
  447. package/dist/cjs/src/zebpay.js +71 -73
  448. package/js/ccxt.d.ts +8 -26
  449. package/js/ccxt.js +12 -18
  450. package/js/src/abstract/aftermath.js +6 -0
  451. package/js/src/abstract/alpaca.js +6 -0
  452. package/js/src/abstract/apex.js +6 -0
  453. package/js/src/abstract/ascendex.js +6 -0
  454. package/js/src/abstract/aster.js +6 -0
  455. package/js/src/abstract/backpack.js +6 -0
  456. package/js/src/abstract/bequant.js +6 -0
  457. package/js/src/abstract/bigone.js +6 -0
  458. package/js/src/abstract/binance.js +6 -0
  459. package/js/src/abstract/binancecoinm.js +6 -0
  460. package/js/src/abstract/binanceus.js +6 -0
  461. package/js/src/abstract/binanceusdm.js +6 -0
  462. package/js/src/abstract/bingx.js +6 -0
  463. package/js/src/abstract/bit2c.js +6 -0
  464. package/js/src/abstract/bitbank.js +6 -0
  465. package/js/src/abstract/bitbns.js +6 -0
  466. package/js/src/abstract/bitfinex.js +6 -0
  467. package/js/src/abstract/bitflyer.js +6 -0
  468. package/js/src/abstract/bitget.js +6 -0
  469. package/js/src/abstract/bithumb.js +6 -0
  470. package/js/src/abstract/bitmart.js +6 -0
  471. package/js/src/abstract/bitmex.js +6 -0
  472. package/js/src/abstract/bitopro.js +6 -0
  473. package/js/src/abstract/bitrue.js +6 -0
  474. package/js/src/abstract/bitso.js +6 -0
  475. package/js/src/abstract/bitstamp.js +6 -0
  476. package/js/src/abstract/bitteam.js +6 -0
  477. package/js/src/abstract/bittrade.js +6 -0
  478. package/js/src/abstract/bitvavo.d.ts +15 -7
  479. package/js/src/abstract/bitvavo.js +6 -0
  480. package/js/src/abstract/blockchaincom.js +6 -0
  481. package/js/src/abstract/blofin.js +6 -0
  482. package/js/src/abstract/btcbox.js +6 -0
  483. package/js/src/abstract/btcmarkets.js +6 -0
  484. package/js/src/abstract/btcturk.js +6 -0
  485. package/js/src/abstract/bullish.js +6 -0
  486. package/js/src/abstract/bybit.js +6 -0
  487. package/js/src/abstract/bybiteu.js +6 -0
  488. package/js/src/abstract/bydfi.js +6 -0
  489. package/js/src/abstract/cex.js +6 -0
  490. package/js/src/abstract/coinbase.js +6 -0
  491. package/js/src/abstract/coinbaseadvanced.js +6 -0
  492. package/js/src/abstract/coinbaseexchange.js +6 -0
  493. package/js/src/abstract/coinbaseinternational.js +6 -0
  494. package/js/src/abstract/coincheck.js +6 -0
  495. package/js/src/abstract/coinex.js +6 -0
  496. package/js/src/abstract/coinmate.js +6 -0
  497. package/js/src/abstract/coinmetro.js +6 -0
  498. package/js/src/abstract/coinone.js +6 -0
  499. package/js/src/abstract/coinsph.js +6 -0
  500. package/js/src/abstract/coinspot.js +6 -0
  501. package/js/src/abstract/cryptocom.js +6 -0
  502. package/js/src/abstract/cryptomus.js +6 -0
  503. package/js/src/abstract/deepcoin.js +6 -0
  504. package/js/src/abstract/delta.js +6 -0
  505. package/js/src/abstract/deribit.js +6 -0
  506. package/js/src/abstract/derive.js +6 -0
  507. package/js/src/abstract/digifinex.js +6 -0
  508. package/js/src/abstract/dydx.js +6 -0
  509. package/js/src/abstract/exmo.js +6 -0
  510. package/js/src/abstract/extended.d.ts +58 -0
  511. package/js/src/abstract/extended.js +11 -0
  512. package/js/src/abstract/fmfwio.js +6 -0
  513. package/js/src/abstract/foxbit.js +6 -0
  514. package/js/src/abstract/gate.js +6 -0
  515. package/js/src/abstract/gemini.js +6 -0
  516. package/js/src/abstract/grvt.js +6 -0
  517. package/js/src/abstract/hashkey.js +6 -0
  518. package/js/src/abstract/hibachi.js +6 -0
  519. package/js/src/abstract/hitbtc.js +6 -0
  520. package/js/src/abstract/hollaex.js +6 -0
  521. package/js/src/abstract/htx.js +6 -0
  522. package/js/src/abstract/huobi.js +6 -0
  523. package/js/src/abstract/hyperliquid.js +6 -0
  524. package/js/src/abstract/independentreserve.js +6 -0
  525. package/js/src/abstract/indodax.js +6 -0
  526. package/js/src/abstract/kraken.js +6 -0
  527. package/js/src/abstract/krakenfutures.js +6 -0
  528. package/js/src/abstract/kucoin.js +6 -0
  529. package/js/src/abstract/kucoinfutures.js +6 -0
  530. package/js/src/abstract/latoken.js +6 -0
  531. package/js/src/abstract/lbank.js +6 -0
  532. package/js/src/abstract/lighter.js +6 -0
  533. package/js/src/abstract/luno.js +6 -0
  534. package/js/src/abstract/mercado.js +6 -0
  535. package/js/src/abstract/mexc.js +6 -0
  536. package/js/src/abstract/modetrade.js +6 -0
  537. package/js/src/abstract/myokx.js +6 -0
  538. package/js/src/abstract/ndax.js +6 -0
  539. package/js/src/abstract/novadax.js +6 -0
  540. package/js/src/abstract/okx.js +6 -0
  541. package/js/src/abstract/okxus.js +6 -0
  542. package/js/src/abstract/onetrading.js +6 -0
  543. package/js/src/abstract/p2b.js +6 -0
  544. package/js/src/abstract/pacifica.js +6 -0
  545. package/js/src/abstract/paradex.js +6 -0
  546. package/js/src/abstract/paymium.js +6 -0
  547. package/js/src/abstract/phemex.js +6 -0
  548. package/js/src/abstract/poloniex.js +6 -0
  549. package/js/src/abstract/tokocrypto.js +6 -0
  550. package/js/src/abstract/toobit.js +6 -0
  551. package/js/src/abstract/upbit.js +6 -0
  552. package/js/src/abstract/weex.js +6 -0
  553. package/js/src/abstract/whitebit.js +6 -0
  554. package/js/src/abstract/woo.js +6 -0
  555. package/js/src/abstract/woofipro.js +6 -0
  556. package/js/src/abstract/xt.js +6 -0
  557. package/js/src/abstract/zaif.js +6 -0
  558. package/js/src/abstract/zebpay.js +6 -0
  559. package/js/src/aftermath.js +6 -0
  560. package/js/src/alpaca.js +6 -0
  561. package/js/src/apex.js +7 -1
  562. package/js/src/ascendex.js +8 -2
  563. package/js/src/aster.js +13 -4
  564. package/js/src/backpack.js +20 -6
  565. package/js/src/base/Exchange.d.ts +10 -6
  566. package/js/src/base/Exchange.js +75 -32
  567. package/js/src/base/Precise.js +7 -7
  568. package/js/src/base/errorHierarchy.js +6 -0
  569. package/js/src/base/errors.js +6 -0
  570. package/js/src/base/functions/crypto.js +6 -0
  571. package/js/src/base/functions/encode.js +6 -0
  572. package/js/src/base/functions/generic.js +6 -0
  573. package/js/src/base/functions/io.d.ts +7 -0
  574. package/js/src/base/functions/io.js +30 -0
  575. package/js/src/base/functions/misc.js +6 -0
  576. package/js/src/base/functions/number.js +6 -0
  577. package/js/src/base/functions/platform.js +6 -0
  578. package/js/src/base/functions/rsa.js +6 -0
  579. package/js/src/base/functions/string.js +6 -0
  580. package/js/src/base/functions/throttle.js +6 -0
  581. package/js/src/base/functions/time.js +6 -0
  582. package/js/src/base/functions/totp.js +6 -0
  583. package/js/src/base/functions/type.js +6 -0
  584. package/js/src/base/functions.js +6 -0
  585. package/js/src/base/types.js +6 -0
  586. package/js/src/base/ws/Cache.js +6 -0
  587. package/js/src/base/ws/Client.js +6 -0
  588. package/js/src/base/ws/Future.js +8 -6
  589. package/js/src/base/ws/OrderBook.js +6 -0
  590. package/js/src/base/ws/OrderBookSide.js +6 -0
  591. package/js/src/base/ws/WsClient.js +10 -0
  592. package/js/src/base/ws/functions.js +6 -0
  593. package/js/src/bequant.js +6 -0
  594. package/js/src/bigone.js +9 -3
  595. package/js/src/binance.d.ts +2 -0
  596. package/js/src/binance.js +202 -198
  597. package/js/src/binancecoinm.js +6 -0
  598. package/js/src/binanceus.js +6 -0
  599. package/js/src/binanceusdm.js +6 -0
  600. package/js/src/bingx.js +9 -3
  601. package/js/src/bit2c.js +6 -0
  602. package/js/src/bitbank.js +6 -0
  603. package/js/src/bitbns.js +6 -0
  604. package/js/src/bitfinex.d.ts +2 -0
  605. package/js/src/bitfinex.js +77 -58
  606. package/js/src/bitflyer.js +6 -0
  607. package/js/src/bitget.js +8 -2
  608. package/js/src/bithumb.js +6 -0
  609. package/js/src/bitmart.js +19 -6
  610. package/js/src/bitmex.js +7 -1
  611. package/js/src/bitopro.js +7 -1
  612. package/js/src/bitrue.js +8 -2
  613. package/js/src/bitso.js +7 -1
  614. package/js/src/bitstamp.js +8 -1
  615. package/js/src/bitteam.js +7 -1
  616. package/js/src/bittrade.js +6 -1
  617. package/js/src/bitvavo.d.ts +114 -21
  618. package/js/src/bitvavo.js +463 -34
  619. package/js/src/blockchaincom.js +6 -0
  620. package/js/src/blofin.d.ts +1 -0
  621. package/js/src/blofin.js +32 -3
  622. package/js/src/btcbox.js +7 -1
  623. package/js/src/btcmarkets.js +6 -0
  624. package/js/src/btcturk.js +6 -0
  625. package/js/src/bullish.js +12 -5
  626. package/js/src/bybit.js +6 -0
  627. package/js/src/bybiteu.js +6 -0
  628. package/js/src/bydfi.js +7 -1
  629. package/js/src/cex.js +9 -3
  630. package/js/src/coinbase.d.ts +63 -56
  631. package/js/src/coinbase.js +81 -65
  632. package/js/src/coinbaseadvanced.js +6 -0
  633. package/js/src/coinbaseexchange.js +8 -2
  634. package/js/src/coinbaseinternational.js +8 -1
  635. package/js/src/coincheck.js +6 -0
  636. package/js/src/coinex.d.ts +1 -0
  637. package/js/src/coinex.js +80 -74
  638. package/js/src/coinmate.js +6 -0
  639. package/js/src/coinmetro.d.ts +1 -1
  640. package/js/src/coinmetro.js +7 -1
  641. package/js/src/coinone.js +6 -0
  642. package/js/src/coinsph.js +7 -1
  643. package/js/src/coinspot.js +6 -0
  644. package/js/src/cryptocom.d.ts +1 -0
  645. package/js/src/cryptocom.js +52 -48
  646. package/js/src/cryptomus.d.ts +2 -1
  647. package/js/src/cryptomus.js +49 -39
  648. package/js/src/deepcoin.js +10 -3
  649. package/js/src/delta.d.ts +1 -0
  650. package/js/src/delta.js +57 -52
  651. package/js/src/deribit.d.ts +1 -0
  652. package/js/src/deribit.js +37 -33
  653. package/js/src/derive.d.ts +1 -0
  654. package/js/src/derive.js +32 -28
  655. package/js/src/digifinex.d.ts +1 -0
  656. package/js/src/digifinex.js +49 -44
  657. package/js/src/dydx.js +6 -0
  658. package/js/src/exmo.d.ts +1 -0
  659. package/js/src/exmo.js +98 -83
  660. package/js/src/extended.d.ts +554 -0
  661. package/js/src/extended.js +3496 -0
  662. package/js/src/fmfwio.js +6 -0
  663. package/js/src/foxbit.d.ts +1 -0
  664. package/js/src/foxbit.js +77 -75
  665. package/js/src/gate.d.ts +1 -0
  666. package/js/src/gate.js +59 -53
  667. package/js/src/gemini.d.ts +2 -1
  668. package/js/src/gemini.js +47 -43
  669. package/js/src/grvt.js +10 -4
  670. package/js/src/hashkey.d.ts +1 -0
  671. package/js/src/hashkey.js +58 -54
  672. package/js/src/hibachi.js +6 -0
  673. package/js/src/hitbtc.d.ts +0 -1
  674. package/js/src/hitbtc.js +9 -13
  675. package/js/src/hollaex.d.ts +1 -0
  676. package/js/src/hollaex.js +57 -54
  677. package/js/src/htx.d.ts +1 -0
  678. package/js/src/htx.js +81 -67
  679. package/js/src/huobi.js +6 -0
  680. package/js/src/hyperliquid.d.ts +1 -0
  681. package/js/src/hyperliquid.js +47 -42
  682. package/js/src/independentreserve.js +6 -0
  683. package/js/src/indodax.js +8 -2
  684. package/js/src/kraken.d.ts +2 -1
  685. package/js/src/kraken.js +63 -58
  686. package/js/src/krakenfutures.js +6 -0
  687. package/js/src/kucoin.js +9 -2
  688. package/js/src/kucoinfutures.js +6 -0
  689. package/js/src/latoken.d.ts +1 -0
  690. package/js/src/latoken.js +36 -32
  691. package/js/src/lbank.d.ts +1 -0
  692. package/js/src/lbank.js +62 -56
  693. package/js/src/lighter.d.ts +1 -0
  694. package/js/src/lighter.js +47 -41
  695. package/js/src/luno.d.ts +1 -0
  696. package/js/src/luno.js +41 -43
  697. package/js/src/mercado.js +6 -0
  698. package/js/src/mexc.d.ts +2 -1
  699. package/js/src/mexc.js +54 -49
  700. package/js/src/modetrade.d.ts +1 -0
  701. package/js/src/modetrade.js +56 -52
  702. package/js/src/myokx.js +6 -0
  703. package/js/src/ndax.d.ts +1 -0
  704. package/js/src/ndax.js +41 -37
  705. package/js/src/novadax.js +6 -0
  706. package/js/src/okx.js +23 -2
  707. package/js/src/okxus.js +6 -0
  708. package/js/src/onetrading.d.ts +2 -1
  709. package/js/src/onetrading.js +27 -23
  710. package/js/src/p2b.js +6 -0
  711. package/js/src/pacifica.js +6 -0
  712. package/js/src/paradex.js +6 -0
  713. package/js/src/paymium.js +6 -0
  714. package/js/src/phemex.d.ts +1 -0
  715. package/js/src/phemex.js +49 -45
  716. package/js/src/poloniex.js +23 -12
  717. package/js/src/pro/aftermath.js +6 -0
  718. package/js/src/pro/alpaca.js +7 -1
  719. package/js/src/pro/apex.js +7 -1
  720. package/js/src/pro/ascendex.js +6 -0
  721. package/js/src/pro/aster.js +6 -0
  722. package/js/src/pro/backpack.js +7 -1
  723. package/js/src/pro/bequant.js +6 -0
  724. package/js/src/pro/binance.js +9 -3
  725. package/js/src/pro/binancecoinm.js +6 -0
  726. package/js/src/pro/binanceus.js +6 -0
  727. package/js/src/pro/binanceusdm.js +6 -0
  728. package/js/src/pro/bingx.js +6 -0
  729. package/js/src/pro/bitfinex.js +6 -0
  730. package/js/src/pro/bitget.js +7 -1
  731. package/js/src/pro/bithumb.js +7 -1
  732. package/js/src/pro/bitmart.js +6 -0
  733. package/js/src/pro/bitmex.js +6 -0
  734. package/js/src/pro/bitopro.js +6 -0
  735. package/js/src/pro/bitrue.js +6 -0
  736. package/js/src/pro/bitstamp.js +7 -1
  737. package/js/src/pro/bittrade.js +7 -1
  738. package/js/src/pro/bitvavo.js +6 -0
  739. package/js/src/pro/blockchaincom.js +7 -1
  740. package/js/src/pro/blofin.js +6 -0
  741. package/js/src/pro/bullish.js +6 -0
  742. package/js/src/pro/bybit.js +7 -1
  743. package/js/src/pro/bybiteu.js +6 -0
  744. package/js/src/pro/bydfi.js +6 -0
  745. package/js/src/pro/cex.js +7 -1
  746. package/js/src/pro/coinbase.js +6 -0
  747. package/js/src/pro/coinbaseadvanced.js +6 -0
  748. package/js/src/pro/coinbaseexchange.js +6 -0
  749. package/js/src/pro/coinbaseinternational.js +6 -0
  750. package/js/src/pro/coincheck.js +6 -0
  751. package/js/src/pro/coinex.js +7 -1
  752. package/js/src/pro/coinone.js +7 -1
  753. package/js/src/pro/cryptocom.js +9 -1
  754. package/js/src/pro/deepcoin.js +6 -0
  755. package/js/src/pro/deribit.js +6 -0
  756. package/js/src/pro/derive.js +6 -0
  757. package/js/src/pro/dydx.js +7 -1
  758. package/js/src/pro/exmo.js +7 -1
  759. package/js/src/pro/extended.d.ts +126 -0
  760. package/js/src/pro/extended.js +864 -0
  761. package/js/src/pro/gate.js +7 -1
  762. package/js/src/pro/gemini.js +6 -0
  763. package/js/src/pro/grvt.js +6 -0
  764. package/js/src/pro/hashkey.js +13 -6
  765. package/js/src/pro/hitbtc.js +6 -0
  766. package/js/src/pro/hollaex.js +7 -1
  767. package/js/src/pro/htx.js +6 -0
  768. package/js/src/pro/huobi.js +6 -0
  769. package/js/src/pro/hyperliquid.js +6 -0
  770. package/js/src/pro/independentreserve.js +7 -1
  771. package/js/src/pro/kraken.js +6 -0
  772. package/js/src/pro/krakenfutures.js +6 -0
  773. package/js/src/pro/kucoin.js +7 -1
  774. package/js/src/pro/kucoinfutures.js +6 -0
  775. package/js/src/pro/lbank.js +6 -0
  776. package/js/src/pro/lighter.js +6 -0
  777. package/js/src/pro/luno.d.ts +1 -1
  778. package/js/src/pro/luno.js +9 -3
  779. package/js/src/pro/mexc.js +6 -0
  780. package/js/src/pro/modetrade.js +6 -0
  781. package/js/src/pro/myokx.js +6 -0
  782. package/js/src/pro/ndax.js +6 -0
  783. package/js/src/pro/okx.js +6 -0
  784. package/js/src/pro/okxus.js +6 -0
  785. package/js/src/pro/onetrading.js +7 -1
  786. package/js/src/pro/p2b.js +6 -0
  787. package/js/src/pro/pacifica.js +6 -0
  788. package/js/src/pro/paradex.js +6 -0
  789. package/js/src/pro/phemex.js +6 -0
  790. package/js/src/pro/poloniex.js +6 -0
  791. package/js/src/pro/toobit.js +7 -1
  792. package/js/src/pro/upbit.js +6 -0
  793. package/js/src/pro/weex.js +7 -1
  794. package/js/src/pro/whitebit.js +7 -1
  795. package/js/src/pro/woo.js +6 -0
  796. package/js/src/pro/woofipro.js +6 -0
  797. package/js/src/pro/xt.js +6 -0
  798. package/js/src/protobuf/mexc/compiled.cjs +6 -0
  799. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +6 -0
  800. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +6 -0
  801. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +6 -0
  802. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +6 -0
  803. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +6 -0
  804. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +6 -0
  805. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +6 -0
  806. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +6 -0
  807. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +6 -0
  808. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +6 -0
  809. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +6 -0
  810. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +6 -0
  811. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +6 -0
  812. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +6 -0
  813. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +6 -0
  814. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +6 -0
  815. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +6 -0
  816. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +6 -0
  817. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +6 -0
  818. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +6 -0
  819. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +6 -0
  820. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +6 -0
  821. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +6 -0
  822. package/js/src/static_dependencies/dydx-v4-client/helpers.js +6 -0
  823. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +6 -0
  824. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +6 -0
  825. package/js/src/static_dependencies/dydx-v4-client/registry.js +6 -0
  826. package/js/src/static_dependencies/ethers/abi-coder.js +6 -0
  827. package/js/src/static_dependencies/ethers/address/address.js +6 -0
  828. package/js/src/static_dependencies/ethers/address/checks.js +6 -0
  829. package/js/src/static_dependencies/ethers/address/contract-address.js +6 -0
  830. package/js/src/static_dependencies/ethers/address/index.js +6 -0
  831. package/js/src/static_dependencies/ethers/bytes32.js +6 -0
  832. package/js/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
  833. package/js/src/static_dependencies/ethers/coders/address.js +6 -0
  834. package/js/src/static_dependencies/ethers/coders/anonymous.js +6 -0
  835. package/js/src/static_dependencies/ethers/coders/array.js +6 -0
  836. package/js/src/static_dependencies/ethers/coders/boolean.js +6 -0
  837. package/js/src/static_dependencies/ethers/coders/bytes.js +6 -0
  838. package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +6 -0
  839. package/js/src/static_dependencies/ethers/coders/null.js +6 -0
  840. package/js/src/static_dependencies/ethers/coders/number.js +6 -0
  841. package/js/src/static_dependencies/ethers/coders/string.js +6 -0
  842. package/js/src/static_dependencies/ethers/coders/tuple.js +6 -0
  843. package/js/src/static_dependencies/ethers/fragments.js +6 -0
  844. package/js/src/static_dependencies/ethers/hash/index.js +6 -0
  845. package/js/src/static_dependencies/ethers/hash/solidity.js +6 -0
  846. package/js/src/static_dependencies/ethers/hash/typed-data.js +6 -0
  847. package/js/src/static_dependencies/ethers/index.js +6 -0
  848. package/js/src/static_dependencies/ethers/interface.js +6 -0
  849. package/js/src/static_dependencies/ethers/typed.js +6 -0
  850. package/js/src/static_dependencies/ethers/utils/base58.js +6 -0
  851. package/js/src/static_dependencies/ethers/utils/base64-browser.js +6 -0
  852. package/js/src/static_dependencies/ethers/utils/base64.js +6 -0
  853. package/js/src/static_dependencies/ethers/utils/data.js +6 -0
  854. package/js/src/static_dependencies/ethers/utils/errors.js +6 -0
  855. package/js/src/static_dependencies/ethers/utils/events.js +6 -0
  856. package/js/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
  857. package/js/src/static_dependencies/ethers/utils/index.js +6 -0
  858. package/js/src/static_dependencies/ethers/utils/maths.js +6 -0
  859. package/js/src/static_dependencies/ethers/utils/properties.js +6 -0
  860. package/js/src/static_dependencies/ethers/utils/rlp-decode.js +6 -0
  861. package/js/src/static_dependencies/ethers/utils/rlp-encode.js +6 -0
  862. package/js/src/static_dependencies/ethers/utils/rlp.js +6 -0
  863. package/js/src/static_dependencies/ethers/utils/units.js +6 -0
  864. package/js/src/static_dependencies/ethers/utils/utf8.js +6 -0
  865. package/js/src/static_dependencies/ethers/utils/uuid.js +6 -0
  866. package/js/src/static_dependencies/fflake/browser.js +6 -0
  867. package/js/src/static_dependencies/jsencrypt/JSEncrypt.js +6 -0
  868. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +6 -0
  869. package/js/src/static_dependencies/jsencrypt/index.js +6 -0
  870. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +6 -0
  871. package/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
  872. package/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
  873. package/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
  874. package/js/src/static_dependencies/jsencrypt/lib/asn1js/oids.js +6 -0
  875. package/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +6 -0
  876. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +6 -0
  877. package/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
  878. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +6 -0
  879. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +6 -0
  880. package/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
  881. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +6 -0
  882. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
  883. package/js/src/static_dependencies/messagepack/msgpack.js +6 -0
  884. package/js/src/static_dependencies/noble-curves/_shortw_utils.js +6 -0
  885. package/js/src/static_dependencies/noble-curves/abstract/curve.js +6 -0
  886. package/js/src/static_dependencies/noble-curves/abstract/edwards.js +6 -0
  887. package/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +6 -0
  888. package/js/src/static_dependencies/noble-curves/abstract/modular.js +6 -0
  889. package/js/src/static_dependencies/noble-curves/abstract/montgomery.js +6 -0
  890. package/js/src/static_dependencies/noble-curves/abstract/poseidon.js +6 -0
  891. package/js/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
  892. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +1 -1
  893. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +6 -0
  894. package/js/src/static_dependencies/noble-curves/bn.js +6 -0
  895. package/js/src/static_dependencies/noble-curves/ed25519.js +6 -0
  896. package/js/src/static_dependencies/noble-curves/ed448.js +6 -0
  897. package/js/src/static_dependencies/noble-curves/index.js +6 -0
  898. package/js/src/static_dependencies/noble-curves/jubjub.js +6 -0
  899. package/js/src/static_dependencies/noble-curves/p256.js +6 -0
  900. package/js/src/static_dependencies/noble-curves/p384.js +6 -0
  901. package/js/src/static_dependencies/noble-curves/p521.js +6 -0
  902. package/js/src/static_dependencies/noble-curves/pasta.js +6 -0
  903. package/js/src/static_dependencies/noble-curves/secp256k1.js +6 -0
  904. package/js/src/static_dependencies/noble-hashes/_assert.js +6 -0
  905. package/js/src/static_dependencies/noble-hashes/_blake2.js +6 -0
  906. package/js/src/static_dependencies/noble-hashes/_sha2.js +6 -0
  907. package/js/src/static_dependencies/noble-hashes/_u64.js +6 -0
  908. package/js/src/static_dependencies/noble-hashes/argon2.js +6 -0
  909. package/js/src/static_dependencies/noble-hashes/blake2b.js +6 -0
  910. package/js/src/static_dependencies/noble-hashes/blake2s.js +6 -0
  911. package/js/src/static_dependencies/noble-hashes/blake3.js +6 -0
  912. package/js/src/static_dependencies/noble-hashes/crypto.js +6 -0
  913. package/js/src/static_dependencies/noble-hashes/cryptoNode.js +6 -0
  914. package/js/src/static_dependencies/noble-hashes/eskdf.js +6 -0
  915. package/js/src/static_dependencies/noble-hashes/hkdf.js +6 -0
  916. package/js/src/static_dependencies/noble-hashes/hmac.js +6 -0
  917. package/js/src/static_dependencies/noble-hashes/index.js +6 -0
  918. package/js/src/static_dependencies/noble-hashes/md5.js +6 -0
  919. package/js/src/static_dependencies/noble-hashes/pbkdf2.js +6 -0
  920. package/js/src/static_dependencies/noble-hashes/ripemd160.js +6 -0
  921. package/js/src/static_dependencies/noble-hashes/scrypt.js +6 -0
  922. package/js/src/static_dependencies/noble-hashes/sha1.js +6 -0
  923. package/js/src/static_dependencies/noble-hashes/sha256.js +6 -0
  924. package/js/src/static_dependencies/noble-hashes/sha3-addons.js +6 -0
  925. package/js/src/static_dependencies/noble-hashes/sha3.js +6 -0
  926. package/js/src/static_dependencies/noble-hashes/sha512.js +6 -0
  927. package/js/src/static_dependencies/noble-hashes/utils.js +6 -0
  928. package/js/src/static_dependencies/node-fetch/body.js +6 -0
  929. package/js/src/static_dependencies/node-fetch/errors/abort-error.js +6 -0
  930. package/js/src/static_dependencies/node-fetch/errors/base.js +6 -0
  931. package/js/src/static_dependencies/node-fetch/errors/fetch-error.js +6 -0
  932. package/js/src/static_dependencies/node-fetch/headers.js +6 -0
  933. package/js/src/static_dependencies/node-fetch/index.js +6 -0
  934. package/js/src/static_dependencies/node-fetch/request.js +6 -0
  935. package/js/src/static_dependencies/node-fetch/response.js +6 -0
  936. package/js/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
  937. package/js/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
  938. package/js/src/static_dependencies/node-fetch/utils/is.js +6 -0
  939. package/js/src/static_dependencies/node-fetch/utils/referrer.js +6 -0
  940. package/js/src/static_dependencies/proxies/agent-base/helpers.js +6 -0
  941. package/js/src/static_dependencies/proxies/agent-base/index.js +6 -0
  942. package/js/src/static_dependencies/proxies/http-proxy-agent/index.js +6 -0
  943. package/js/src/static_dependencies/proxies/https-proxy-agent/index.js +6 -0
  944. package/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
  945. package/js/src/static_dependencies/qs/formats.js +6 -0
  946. package/js/src/static_dependencies/qs/index.js +6 -0
  947. package/js/src/static_dependencies/qs/parse.js +6 -0
  948. package/js/src/static_dependencies/qs/stringify.js +6 -0
  949. package/js/src/static_dependencies/qs/utils.js +6 -0
  950. package/js/src/static_dependencies/scure-base/index.js +6 -0
  951. package/js/src/static_dependencies/scure-bip32/index.js +6 -0
  952. package/js/src/static_dependencies/scure-bip39/index.js +6 -0
  953. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +6 -0
  954. package/js/src/static_dependencies/scure-starknet/index.js +6 -0
  955. package/js/src/static_dependencies/starknet/constants.js +6 -0
  956. package/js/src/static_dependencies/starknet/index.js +6 -0
  957. package/js/src/static_dependencies/starknet/types/cairoEnum.js +6 -0
  958. package/js/src/static_dependencies/starknet/types/calldata.js +6 -0
  959. package/js/src/static_dependencies/starknet/types/index.js +6 -0
  960. package/js/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
  961. package/js/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
  962. package/js/src/static_dependencies/starknet/types/lib/contract/legacy.js +6 -0
  963. package/js/src/static_dependencies/starknet/types/lib/contract/sierra.js +6 -0
  964. package/js/src/static_dependencies/starknet/types/lib/index.js +6 -0
  965. package/js/src/static_dependencies/starknet/types/typedData.js +6 -0
  966. package/js/src/static_dependencies/starknet/utils/address.js +6 -0
  967. package/js/src/static_dependencies/starknet/utils/assert.js +6 -0
  968. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +6 -0
  969. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +6 -0
  970. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +6 -0
  971. package/js/src/static_dependencies/starknet/utils/calldata/byteArray.js +6 -0
  972. package/js/src/static_dependencies/starknet/utils/calldata/cairo.js +6 -0
  973. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
  974. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
  975. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
  976. package/js/src/static_dependencies/starknet/utils/calldata/enum/index.js +6 -0
  977. package/js/src/static_dependencies/starknet/utils/calldata/formatter.js +6 -0
  978. package/js/src/static_dependencies/starknet/utils/calldata/index.js +6 -0
  979. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.js +6 -0
  980. package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.js +6 -0
  981. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +6 -0
  982. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
  983. package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +6 -0
  984. package/js/src/static_dependencies/starknet/utils/calldata/requestParser.js +6 -0
  985. package/js/src/static_dependencies/starknet/utils/calldata/responseParser.js +6 -0
  986. package/js/src/static_dependencies/starknet/utils/calldata/tuple.js +6 -0
  987. package/js/src/static_dependencies/starknet/utils/calldata/validate.js +6 -0
  988. package/js/src/static_dependencies/starknet/utils/encode.js +6 -0
  989. package/js/src/static_dependencies/starknet/utils/hash/classHash.js +6 -0
  990. package/js/src/static_dependencies/starknet/utils/hash/index.js +6 -0
  991. package/js/src/static_dependencies/starknet/utils/merkle.js +6 -0
  992. package/js/src/static_dependencies/starknet/utils/num.js +6 -0
  993. package/js/src/static_dependencies/starknet/utils/selector.js +6 -0
  994. package/js/src/static_dependencies/starknet/utils/shortString.js +6 -0
  995. package/js/src/static_dependencies/starknet/utils/starknetId.js +6 -0
  996. package/js/src/static_dependencies/starknet/utils/typedData.js +6 -0
  997. package/js/src/static_dependencies/starknet/utils/uint256.js +6 -0
  998. package/js/src/static_dependencies/starknet/utils/url.js +6 -0
  999. package/js/src/static_dependencies/watchable/src/index.js +6 -0
  1000. package/js/src/static_dependencies/watchable/src/types.js +6 -0
  1001. package/js/src/static_dependencies/watchable/src/unpromise.js +6 -0
  1002. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +6 -0
  1003. package/js/src/tokocrypto.js +7 -1
  1004. package/js/src/toobit.js +8 -2
  1005. package/js/src/upbit.js +9 -3
  1006. package/js/src/weex.d.ts +1 -0
  1007. package/js/src/weex.js +70 -62
  1008. package/js/src/whitebit.d.ts +1 -0
  1009. package/js/src/whitebit.js +67 -63
  1010. package/js/src/woo.d.ts +1 -0
  1011. package/js/src/woo.js +71 -54
  1012. package/js/src/woofipro.d.ts +1 -0
  1013. package/js/src/woofipro.js +59 -47
  1014. package/js/src/xt.js +7 -2
  1015. package/js/src/zaif.js +6 -0
  1016. package/js/src/zebpay.d.ts +2 -1
  1017. package/js/src/zebpay.js +76 -72
  1018. package/package.json +21 -9
  1019. package/dist/cjs/src/abstract/oxfun.js +0 -11
  1020. package/dist/cjs/src/abstract/wavesexchange.js +0 -11
  1021. package/dist/cjs/src/abstract/yobit.js +0 -11
  1022. package/dist/cjs/src/arkham.js +0 -2485
  1023. package/dist/cjs/src/gateio.js +0 -18
  1024. package/dist/cjs/src/oxfun.js +0 -2933
  1025. package/dist/cjs/src/pro/arkham.js +0 -715
  1026. package/dist/cjs/src/pro/gateio.js +0 -18
  1027. package/dist/cjs/src/pro/oxfun.js +0 -1113
  1028. package/dist/cjs/src/wavesexchange.js +0 -2783
  1029. package/dist/cjs/src/yobit.js +0 -1466
  1030. package/js/src/abstract/arkham.d.ts +0 -121
  1031. package/js/src/abstract/arkham.js +0 -5
  1032. package/js/src/abstract/gateio.d.ts +0 -346
  1033. package/js/src/abstract/gateio.js +0 -5
  1034. package/js/src/abstract/oxfun.d.ts +0 -37
  1035. package/js/src/abstract/oxfun.js +0 -5
  1036. package/js/src/abstract/wavesexchange.d.ts +0 -157
  1037. package/js/src/abstract/wavesexchange.js +0 -5
  1038. package/js/src/abstract/yobit.d.ts +0 -19
  1039. package/js/src/abstract/yobit.js +0 -5
  1040. package/js/src/arkham.d.ts +0 -358
  1041. package/js/src/arkham.js +0 -2478
  1042. package/js/src/gateio.d.ts +0 -4
  1043. package/js/src/gateio.js +0 -11
  1044. package/js/src/oxfun.d.ts +0 -442
  1045. package/js/src/oxfun.js +0 -2926
  1046. package/js/src/pro/arkham.d.ts +0 -105
  1047. package/js/src/pro/arkham.js +0 -708
  1048. package/js/src/pro/gateio.d.ts +0 -4
  1049. package/js/src/pro/gateio.js +0 -11
  1050. package/js/src/pro/oxfun.d.ts +0 -234
  1051. package/js/src/pro/oxfun.js +0 -1106
  1052. package/js/src/wavesexchange.d.ts +0 -244
  1053. package/js/src/wavesexchange.js +0 -2776
  1054. package/js/src/yobit.d.ts +0 -197
  1055. package/js/src/yobit.js +0 -1459
@@ -0,0 +1,3496 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/extended.js';
9
+ import { Precise } from './base/Precise.js';
10
+ import { ArgumentsRequired, BadRequest, InsufficientFunds, InvalidOrder, ExchangeError, AuthenticationError } from './base/errors.js';
11
+ import { DECIMAL_PLACES, NO_PADDING, TICK_SIZE, TRUNCATE } from './base/functions/number.js';
12
+ // ---------------------------------------------------------------------------
13
+ /**
14
+ * @class extended
15
+ * @augments Exchange
16
+ */
17
+ export default class extended extends Exchange {
18
+ describe() {
19
+ return this.deepExtend(super.describe(), {
20
+ 'id': 'extended',
21
+ 'name': 'Extended',
22
+ 'countries': ['SG'],
23
+ 'version': 'v2',
24
+ 'rateLimit': 600,
25
+ 'precisionMode': TICK_SIZE,
26
+ 'certified': false,
27
+ 'pro': true,
28
+ 'dex': true,
29
+ 'has': {
30
+ 'CORS': undefined,
31
+ 'spot': false,
32
+ 'margin': false,
33
+ 'swap': true,
34
+ 'future': false,
35
+ 'option': false,
36
+ 'addMargin': false,
37
+ 'borrowCrossMargin': false,
38
+ 'borrowIsolatedMargin': false,
39
+ 'cancelAllOrders': true,
40
+ 'cancelAllOrdersAfter': true,
41
+ 'cancelOrder': true,
42
+ 'cancelOrders': true,
43
+ 'closeAllPositions': false,
44
+ 'closePosition': false,
45
+ 'createConvertTrade': false,
46
+ 'createDepositAddress': false,
47
+ 'createMarketBuyOrderWithCost': false,
48
+ 'createMarketOrderWithCost': false,
49
+ 'createMarketSellOrderWithCost': false,
50
+ 'createOrder': true,
51
+ 'createOrders': false,
52
+ 'createOrderWithTakeProfitAndStopLoss': false,
53
+ 'createPostOnlyOrder': false,
54
+ 'createReduceOnlyOrder': false,
55
+ 'createStopLimitOrder': false,
56
+ 'createStopLossOrder': false,
57
+ 'createStopMarketOrder': false,
58
+ 'createStopOrder': false,
59
+ 'createTakeProfitOrder': false,
60
+ 'createTrailingAmountOrder': false,
61
+ 'createTrailingPercentOrder': false,
62
+ 'createTriggerOrder': false,
63
+ 'editOrder': true,
64
+ 'fetchAccounts': true,
65
+ 'fetchBalance': true,
66
+ 'fetchBorrowInterest': false,
67
+ 'fetchBorrowRateHistories': false,
68
+ 'fetchBorrowRateHistory': false,
69
+ 'fetchCanceledAndClosedOrders': false,
70
+ 'fetchCanceledOrders': true,
71
+ 'fetchClosedOrders': true,
72
+ 'fetchConvertCurrencies': false,
73
+ 'fetchConvertQuote': false,
74
+ 'fetchConvertTrade': false,
75
+ 'fetchConvertTradeHistory': false,
76
+ 'fetchCrossBorrowRate': false,
77
+ 'fetchCrossBorrowRates': false,
78
+ 'fetchCurrencies': true,
79
+ 'fetchDeposit': false,
80
+ 'fetchDepositAddress': false,
81
+ 'fetchDepositAddresses': false,
82
+ 'fetchDepositAddressesByNetwork': false,
83
+ 'fetchDeposits': true,
84
+ 'fetchDepositsWithdrawals': false,
85
+ 'fetchDepositWithdrawFee': false,
86
+ 'fetchDepositWithdrawFees': false,
87
+ 'fetchFundingHistory': true,
88
+ 'fetchFundingInterval': false,
89
+ 'fetchFundingIntervals': false,
90
+ 'fetchFundingRate': false,
91
+ 'fetchFundingRateHistory': true,
92
+ 'fetchFundingRates': false,
93
+ 'fetchIndexOHLCV': true,
94
+ 'fetchIsolatedBorrowRate': false,
95
+ 'fetchIsolatedBorrowRates': false,
96
+ 'fetchLedger': true,
97
+ 'fetchLeverage': true,
98
+ 'fetchLeverageTiers': false,
99
+ 'fetchLiquidations': false,
100
+ 'fetchLongShortRatio': false,
101
+ 'fetchLongShortRatioHistory': false,
102
+ 'fetchMarginAdjustmentHistory': false,
103
+ 'fetchMarginMode': false,
104
+ 'fetchMarketLeverageTiers': false,
105
+ 'fetchMarkets': true,
106
+ 'fetchMarkOHLCV': true,
107
+ 'fetchMarkPrice': false,
108
+ 'fetchMyLiquidations': false,
109
+ 'fetchMyTrades': true,
110
+ 'fetchOHLCV': true,
111
+ 'fetchOpenInterest': false,
112
+ 'fetchOpenInterestHistory': true,
113
+ 'fetchOpenOrders': true,
114
+ 'fetchOrder': true,
115
+ 'fetchOrderBook': true,
116
+ 'fetchOrderBooks': false,
117
+ 'fetchOrders': true,
118
+ 'fetchOrderTrades': false,
119
+ 'fetchPosition': true,
120
+ 'fetchPositionHistory': false,
121
+ 'fetchPositionMode': false,
122
+ 'fetchPositions': true,
123
+ 'fetchPositionsHistory': true,
124
+ 'fetchPositionsRisk': false,
125
+ 'fetchPremiumIndexOHLCV': false,
126
+ 'fetchStatus': false,
127
+ 'fetchTicker': true,
128
+ 'fetchTickers': true,
129
+ 'fetchTime': false,
130
+ 'fetchTrades': true,
131
+ 'fetchTradingFee': true,
132
+ 'fetchTradingFees': true,
133
+ 'fetchTransactions': true,
134
+ 'fetchTransfer': false,
135
+ 'fetchTransfers': true,
136
+ 'fetchWithdrawAddresses': false,
137
+ 'fetchWithdrawal': false,
138
+ 'fetchWithdrawals': true,
139
+ 'reduceMargin': false,
140
+ 'repayCrossMargin': false,
141
+ 'repayIsolatedMargin': false,
142
+ 'setLeverage': true,
143
+ 'setMargin': false,
144
+ 'setMarginMode': false,
145
+ 'setPositionMode': false,
146
+ 'signIn': false,
147
+ 'transfer': true,
148
+ 'withdraw': true,
149
+ },
150
+ 'features': {},
151
+ 'timeframes': {
152
+ '1m': 'PT1M',
153
+ '5m': 'PT5M',
154
+ '15m': 'PT15M',
155
+ '30m': 'PT30M',
156
+ '1h': 'PT1H',
157
+ '2h': 'PT2H',
158
+ '4h': 'PT4H',
159
+ '8h': 'PT8H',
160
+ '12h': 'PT12H',
161
+ '1d': 'PT24H',
162
+ '1w': 'P7D',
163
+ '1M': 'P30D',
164
+ },
165
+ 'hostname': 'extended.exchange',
166
+ 'urls': {
167
+ 'logo': 'https://github.com/user-attachments/assets/309d44db-2a50-4529-a27f-8f4492aec299',
168
+ 'api': {
169
+ 'rest': 'https://api.starknet.{hostname}',
170
+ },
171
+ 'test': {
172
+ 'rest': 'https://api.starknet.sepolia.{hostname}',
173
+ },
174
+ 'www': 'https://app.{hostname}',
175
+ 'doc': 'https://api.docs.{hostname}',
176
+ 'fees': 'https://docs.{hostname}/extended-resources/trading/trading-fees-and-rebates',
177
+ 'referral': '',
178
+ },
179
+ 'api': {
180
+ 'v1': {
181
+ 'public': {
182
+ 'get': [
183
+ 'info/markets',
184
+ 'info/assets',
185
+ 'info/assets/{asset}/price',
186
+ 'info/markets/{market}/stats',
187
+ 'info/markets/{market}/orderbook',
188
+ 'info/markets/{market}/trades',
189
+ 'info/candles/{market}/{candleType}',
190
+ 'info/{market}/funding',
191
+ 'info/{market}/open-interests',
192
+ 'info/builder/dashboard',
193
+ ],
194
+ },
195
+ 'private': {
196
+ 'get': [
197
+ 'user/accounts',
198
+ 'user/account/info',
199
+ 'user/balance',
200
+ 'user/spot/balances',
201
+ 'user/assetOperations',
202
+ 'user/positions',
203
+ 'user/positions/history',
204
+ 'user/orders',
205
+ 'user/orders/history',
206
+ 'user/orders/{id}',
207
+ 'user/orders/external/{externalId}',
208
+ 'user/trades',
209
+ 'user/funding/history',
210
+ 'user/rebates/stats',
211
+ 'user/leverage',
212
+ 'user/fees',
213
+ 'user/bridge/config',
214
+ 'user/bridge/quote',
215
+ 'user/affiliate',
216
+ 'user/referrals/status',
217
+ 'user/referrals/links',
218
+ 'user/referrals/dashboard',
219
+ 'user/rewards/earned',
220
+ 'user/rewards/leaderboard/stats',
221
+ 'portfolio/charts/equities',
222
+ 'portfolio/charts/pnl',
223
+ 'vault/public/performance',
224
+ 'vault/public/summary',
225
+ 'builder/trades',
226
+ ],
227
+ 'post': [
228
+ 'user/order',
229
+ 'user/order/massCancel',
230
+ 'user/deadmanswitch',
231
+ 'user/bridge/quote',
232
+ 'user/withdrawal',
233
+ 'user/transfer',
234
+ 'user/referrals/use',
235
+ 'user/referrals',
236
+ ],
237
+ 'put': [
238
+ 'user/referrals',
239
+ ],
240
+ 'patch': [
241
+ 'user/leverage',
242
+ ],
243
+ 'delete': [
244
+ 'user/order/{id}',
245
+ 'user/order',
246
+ ],
247
+ },
248
+ },
249
+ },
250
+ 'fees': {
251
+ 'taker': this.parseNumber('0.002'),
252
+ 'maker': this.parseNumber('0.002'),
253
+ },
254
+ 'requiredCredentials': {
255
+ 'apiKey': true,
256
+ 'secret': false,
257
+ 'privateKey': true,
258
+ },
259
+ 'exceptions': {
260
+ 'exact': {
261
+ '1000': InvalidOrder,
262
+ '1001': InvalidOrder,
263
+ '1002': InvalidOrder,
264
+ '1003': InvalidOrder,
265
+ '1004': InvalidOrder,
266
+ '1005': InvalidOrder,
267
+ '1006': ExchangeError,
268
+ '1008': InvalidOrder,
269
+ '1009': InvalidOrder,
270
+ '1010': ExchangeError,
271
+ '1011': InvalidOrder,
272
+ '1012': InvalidOrder,
273
+ '1013': InvalidOrder,
274
+ '1014': InvalidOrder,
275
+ '1049': InvalidOrder,
276
+ '1050': InvalidOrder,
277
+ '10501': InvalidOrder,
278
+ '1052': InvalidOrder,
279
+ '1053': InvalidOrder,
280
+ '1100': InvalidOrder,
281
+ '1101': InvalidOrder,
282
+ '1102': InvalidOrder,
283
+ '1120': InvalidOrder,
284
+ '1121': InvalidOrder,
285
+ '1122': InvalidOrder,
286
+ '1123': InvalidOrder,
287
+ '1124': InvalidOrder,
288
+ '1125': InvalidOrder,
289
+ '1126': InvalidOrder,
290
+ '1127': InvalidOrder,
291
+ '1128': InvalidOrder,
292
+ '1129': InvalidOrder,
293
+ '1130': InvalidOrder,
294
+ '1131': InvalidOrder,
295
+ '1132': InvalidOrder,
296
+ '1133': InvalidOrder,
297
+ '1134': InvalidOrder,
298
+ '1135': InvalidOrder,
299
+ '1136': InvalidOrder,
300
+ '1137': InvalidOrder,
301
+ '1138': InvalidOrder,
302
+ '1139': InvalidOrder,
303
+ '1140': InsufficientFunds,
304
+ '1141': InvalidOrder,
305
+ '1142': InvalidOrder,
306
+ '1143': InvalidOrder,
307
+ '1144': InvalidOrder,
308
+ '1145': InvalidOrder,
309
+ '1146': InvalidOrder,
310
+ '1147': InvalidOrder,
311
+ '1148': InvalidOrder,
312
+ '1500': InvalidOrder,
313
+ '1600': BadRequest,
314
+ '1601': BadRequest,
315
+ '1602': BadRequest,
316
+ '1604': BadRequest,
317
+ '1605': BadRequest,
318
+ '1607': BadRequest,
319
+ '1608': BadRequest,
320
+ '1650': BadRequest,
321
+ '1700': BadRequest,
322
+ '1701': BadRequest,
323
+ '1703': BadRequest,
324
+ '1704': BadRequest, // Referral code already applied.
325
+ },
326
+ 'broad': {},
327
+ },
328
+ 'options': {
329
+ 'builderFee': true,
330
+ 'builderFeeRate': '0.0001',
331
+ 'builderId': '257624',
332
+ },
333
+ });
334
+ }
335
+ async loadMarkets(reload = false, params = {}) {
336
+ const markets = await super.loadMarkets(reload, params);
337
+ const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId');
338
+ if ((currenciesByNumericId === undefined) || reload) {
339
+ this.options['currenciesByNumericId'] = this.indexByStringifiedNumericId(this.currencies);
340
+ }
341
+ return markets;
342
+ }
343
+ indexByStringifiedNumericId(input) {
344
+ const result = {};
345
+ if (input === undefined) {
346
+ return undefined;
347
+ }
348
+ const keys = Object.keys(input);
349
+ for (let i = 0; i < keys.length; i++) {
350
+ const key = keys[i];
351
+ const item = input[key];
352
+ const numericIdString = this.safeString(item, 'numericId');
353
+ if (numericIdString === undefined) {
354
+ continue;
355
+ }
356
+ result[numericIdString] = item;
357
+ }
358
+ return result;
359
+ }
360
+ /**
361
+ * @method
362
+ * @name extended#fetchMarkets
363
+ * @description retrieves data on all markets for extended
364
+ * @see https://api.docs.extended.exchange/#get-markets
365
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
366
+ * @returns {object[]} an array of objects representing market data
367
+ */
368
+ async fetchMarkets(params = {}) {
369
+ const response = await this.v1PublicGetInfoMarkets(params);
370
+ //
371
+ // {
372
+ // "status": "OK",
373
+ // "data": [
374
+ // {
375
+ // "name": "BTC-USD",
376
+ // "uiName": "BTC-USD",
377
+ // "category": "Crypto",
378
+ // "subCategory": "L1",
379
+ // "assetName": "BTC",
380
+ // "assetPrecision": 5,
381
+ // "collateralAssetName": "USD",
382
+ // "collateralAssetPrecision": 6,
383
+ // "description": "Bitcoin",
384
+ // "active": true,
385
+ // "status": "ACTIVE",
386
+ // "marketStats": {
387
+ // "dailyVolume": "231016077.512960",
388
+ // "dailyVolumeBase": "3025.00058",
389
+ // "dailyPriceChange": "420",
390
+ // "dailyPriceChangePercentage": "0.0055",
391
+ // "dailyLow": "75635",
392
+ // "dailyHigh": "77399",
393
+ // "lastPrice": "77259",
394
+ // "askPrice": "77260",
395
+ // "bidPrice": "77259",
396
+ // "markPrice": "77259.680250000004",
397
+ // "indexPrice": "77299.020412500001",
398
+ // "fundingRate": "0.000013",
399
+ // "nextFundingRate": 1777442400000,
400
+ // "openInterest": "115861923.311902",
401
+ // "openInterestBase": "1500.40958",
402
+ // "deleverageLevels": {
403
+ // "shortPositions": [
404
+ // {
405
+ // "level": 1,
406
+ // "rankingLowerBound": "-815.7788"
407
+ // },
408
+ // {
409
+ // "level": 2,
410
+ // "rankingLowerBound": "-2.1328"
411
+ // },
412
+ // {
413
+ // "level": 3,
414
+ // "rankingLowerBound": "-0.9297"
415
+ // },
416
+ // {
417
+ // "level": 4,
418
+ // "rankingLowerBound": "0.0000"
419
+ // }
420
+ // ],
421
+ // "longPositions": [
422
+ // {
423
+ // "level": 1,
424
+ // "rankingLowerBound": "-47234.9095"
425
+ // },
426
+ // {
427
+ // "level": 2,
428
+ // "rankingLowerBound": "-0.0030"
429
+ // },
430
+ // {
431
+ // "level": 3,
432
+ // "rankingLowerBound": "0.0020"
433
+ // },
434
+ // {
435
+ // "level": 4,
436
+ // "rankingLowerBound": "0.0033"
437
+ // }
438
+ // ]
439
+ // }
440
+ // },
441
+ // "tradingConfig": {
442
+ // "minOrderSize": "0.0001",
443
+ // "minOrderSizeChange": "0.00001",
444
+ // "minPriceChange": "1",
445
+ // "maxMarketOrderValue": "3000000",
446
+ // "maxLimitOrderValue": "15000000",
447
+ // "maxPositionValue": "60000000",
448
+ // "maxLeverage": "50.00",
449
+ // "hourlyFundingRateCap": "0.25",
450
+ // "maxNumOrders": "200",
451
+ // "limitPriceCap": "0.05",
452
+ // "limitPriceFloor": "0.05",
453
+ // "riskFactorConfig": [
454
+ // {
455
+ // "upperBound": "4000000",
456
+ // "riskFactor": "0.02",
457
+ // "isAvailableForUsers": true
458
+ // }
459
+ // ]
460
+ // },
461
+ // "l2Config": {
462
+ // "type": "STARKX",
463
+ // "collateralId": "0x1",
464
+ // "syntheticId": "0x4254432d3600000000000000000000",
465
+ // "syntheticResolution": 1000000,
466
+ // "collateralResolution": 1000000
467
+ // },
468
+ // "visibleOnUi": true,
469
+ // "createdAt": 1752829532673
470
+ // }
471
+ // ]
472
+ // }
473
+ //
474
+ const data = this.safeList(response, 'data', []);
475
+ return this.parseMarkets(data);
476
+ }
477
+ parseMarket(market) {
478
+ //
479
+ // {
480
+ // "name": "BTC-USD",
481
+ // "uiName": "BTC-USD",
482
+ // "category": "Crypto",
483
+ // "subCategory": "L1",
484
+ // "assetName": "BTC",
485
+ // "assetPrecision": 5,
486
+ // "collateralAssetName": "USD",
487
+ // "collateralAssetPrecision": 6,
488
+ // "description": "Bitcoin",
489
+ // "active": true,
490
+ // "status": "ACTIVE",
491
+ // "marketStats": { ... },
492
+ // "tradingConfig": {
493
+ // "minOrderSize": "0.0001",
494
+ // "minOrderSizeChange": "0.00001",
495
+ // "minPriceChange": "1",
496
+ // "maxMarketOrderValue": "3000000",
497
+ // "maxLimitOrderValue": "15000000",
498
+ // "maxPositionValue": "60000000",
499
+ // "maxLeverage": "50.00",
500
+ // "hourlyFundingRateCap": "0.25",
501
+ // "maxNumOrders": "200",
502
+ // "limitPriceCap": "0.05",
503
+ // "limitPriceFloor": "0.05",
504
+ // "riskFactorConfig": [
505
+ // {
506
+ // "upperBound": "4000000",
507
+ // "riskFactor": "0.02",
508
+ // "isAvailableForUsers": true
509
+ // }
510
+ // ]
511
+ // },
512
+ // "l2Config": { ... },
513
+ // "visibleOnUi": true,
514
+ // "createdAt": 1752829532673
515
+ // }
516
+ //
517
+ const tradingConfig = this.safeDict(market, 'tradingConfig', {});
518
+ const marketId = this.safeString(market, 'name');
519
+ let baseId = this.safeString(market, 'assetName');
520
+ if (baseId.indexOf('SPOT') >= 0) {
521
+ baseId = baseId.replace('SPOT', '');
522
+ }
523
+ const quoteId = this.safeString(market, 'collateralAssetName');
524
+ const base = this.safeCurrencyCode(baseId);
525
+ let quote = this.safeCurrencyCode(quoteId);
526
+ if (quoteId === 'USD') {
527
+ quote = 'USDC';
528
+ }
529
+ const status = this.safeString(market, 'status');
530
+ const active = (status === 'ACTIVE');
531
+ const amountPrecision = this.safeNumber(tradingConfig, 'minOrderSizeChange');
532
+ const pricePrecision = this.safeNumber(tradingConfig, 'minPriceChange');
533
+ const maxLeverage = this.safeNumber(tradingConfig, 'maxLeverage');
534
+ const minAmount = this.safeNumber(tradingConfig, 'minOrderSize');
535
+ const maxCost = this.safeNumber(tradingConfig, 'maxLimitOrderValue');
536
+ const created = this.safeInteger(market, 'createdAt');
537
+ let settleId = undefined;
538
+ let settle = undefined;
539
+ let symbol = base + '/' + quote;
540
+ let isSpot = false;
541
+ let type = this.safeStringLower(market, 'type');
542
+ let contractSize = undefined;
543
+ let linear = undefined;
544
+ let inverse = undefined;
545
+ if (type === 'spot') {
546
+ isSpot = true;
547
+ }
548
+ else {
549
+ type = 'swap';
550
+ settleId = quoteId;
551
+ settle = quote;
552
+ symbol += ':' + settle;
553
+ contractSize = this.parseNumber('1');
554
+ linear = true;
555
+ inverse = false;
556
+ }
557
+ return this.safeMarketStructure({
558
+ 'id': marketId,
559
+ 'symbol': symbol,
560
+ 'base': base,
561
+ 'quote': quote,
562
+ 'settle': settle,
563
+ 'baseId': baseId,
564
+ 'quoteId': quoteId,
565
+ 'settleId': settleId,
566
+ 'type': type,
567
+ 'spot': isSpot,
568
+ 'margin': false,
569
+ 'swap': !isSpot,
570
+ 'future': false,
571
+ 'option': false,
572
+ 'active': active,
573
+ 'contract': !isSpot,
574
+ 'linear': linear,
575
+ 'inverse': inverse,
576
+ 'taker': this.safeNumber(this.fees, 'taker'),
577
+ 'maker': this.safeNumber(this.fees, 'maker'),
578
+ 'contractSize': contractSize,
579
+ 'expiry': undefined,
580
+ 'expiryDatetime': undefined,
581
+ 'strike': undefined,
582
+ 'optionType': undefined,
583
+ 'precision': {
584
+ 'amount': amountPrecision,
585
+ 'price': pricePrecision,
586
+ },
587
+ 'limits': {
588
+ 'leverage': {
589
+ 'min': this.parseNumber('1'),
590
+ 'max': maxLeverage,
591
+ },
592
+ 'amount': {
593
+ 'min': minAmount,
594
+ 'max': undefined,
595
+ },
596
+ 'price': {
597
+ 'min': undefined,
598
+ 'max': undefined,
599
+ },
600
+ 'cost': {
601
+ 'min': undefined,
602
+ 'max': maxCost,
603
+ },
604
+ },
605
+ 'created': created,
606
+ 'info': market,
607
+ });
608
+ }
609
+ /**
610
+ * @method
611
+ * @name extended#fetchCurrencies
612
+ * @description fetches all available currencies on an exchange
613
+ * @see https://api.docs.extended.exchange/#get-assets
614
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
615
+ * @returns {object} an associative dictionary of currencies
616
+ */
617
+ async fetchCurrencies(params = {}) {
618
+ const response = await this.v1PublicGetInfoAssets(params);
619
+ //
620
+ // {
621
+ // "status": "OK",
622
+ // "data": [
623
+ // {
624
+ // "id": 1,
625
+ // "name": "USD",
626
+ // "symbol": "USD",
627
+ // "description": "USD Collateral",
628
+ // "precision": 6,
629
+ // "isActive": true,
630
+ // "isCollateral": true,
631
+ // "starkexId": "0x1",
632
+ // "starkexResolution": 1000000,
633
+ // "l1Id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
634
+ // "l1Resolution": 1000000,
635
+ // "version": 3,
636
+ // "createdAt": 1752829532673,
637
+ // "type": "SPOT",
638
+ // "canBeUsedAsCollateral": true,
639
+ // "riskFactors": [],
640
+ // "availableForTradeFactors": []
641
+ // }
642
+ // ]
643
+ // }
644
+ //
645
+ const data = this.safeList(response, 'data', []);
646
+ return this.parseCurrencies(data);
647
+ }
648
+ parseCurrency(currency) {
649
+ //
650
+ // {
651
+ // "id": 1,
652
+ // "name": "USD",
653
+ // "symbol": "USD",
654
+ // "description": "USD Collateral",
655
+ // "precision": 6,
656
+ // "isActive": true,
657
+ // "isCollateral": true,
658
+ // "starkexId": "0x1",
659
+ // "starkexResolution": 1000000,
660
+ // "l1Id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
661
+ // "l1Resolution": 1000000,
662
+ // "version": 3,
663
+ // "createdAt": 1752829532673,
664
+ // "type": "SPOT",
665
+ // "canBeUsedAsCollateral": true,
666
+ // "riskFactors": [],
667
+ // "availableForTradeFactors": []
668
+ // }
669
+ //
670
+ let currencyId = this.safeString(currency, 'symbol');
671
+ if ((currencyId !== undefined) && (currencyId.indexOf('SPOT') >= 0)) {
672
+ currencyId = currencyId.replace('SPOT', '');
673
+ }
674
+ let code = this.safeCurrencyCode(currencyId);
675
+ if (currencyId === 'USD') {
676
+ code = 'USDC';
677
+ }
678
+ const name = this.safeString(currency, 'name');
679
+ const precision = this.safeInteger(currency, 'precision');
680
+ const isActive = this.safeBool(currency, 'isActive');
681
+ return this.safeCurrencyStructure({
682
+ 'id': currencyId,
683
+ 'code': code,
684
+ 'numericId': this.safeInteger(currency, 'id'),
685
+ 'name': name,
686
+ 'active': isActive,
687
+ 'deposit': true,
688
+ 'withdraw': true,
689
+ 'precision': Math.pow(10, precision * -1),
690
+ 'type': 'other',
691
+ 'margin': this.safeBool(currency, 'canBeUsedAsCollateral'),
692
+ 'info': currency,
693
+ });
694
+ }
695
+ /**
696
+ * @method
697
+ * @name extended#fetchTicker
698
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
699
+ * @see https://api.docs.extended.exchange/#get-market-statistics
700
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
701
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
702
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
703
+ */
704
+ async fetchTicker(symbol, params = {}) {
705
+ await this.loadMarkets();
706
+ const market = this.market(symbol);
707
+ const request = {
708
+ 'market': market['id'],
709
+ };
710
+ const response = await this.v1PublicGetInfoMarketsMarketStats(this.extend(request, params));
711
+ //
712
+ // {
713
+ // "status": "OK",
714
+ // "data": {
715
+ // "dailyVolume": "231216165.666600",
716
+ // "dailyVolumeBase": "3027.36710",
717
+ // "dailyPriceChange": "181",
718
+ // "dailyPriceChangePercentage": "0.0024",
719
+ // "dailyLow": "75635",
720
+ // "dailyHigh": "77399",
721
+ // "lastPrice": "77026",
722
+ // "askPrice": "77026",
723
+ // "bidPrice": "77025",
724
+ // "markPrice": "77006.091897999984",
725
+ // "indexPrice": "77050.739529925005",
726
+ // "fundingRate": "0.000012",
727
+ // "nextFundingRate": 1777446000000,
728
+ // "openInterest": "114851569.088316",
729
+ // "openInterestBase": "1491.33012",
730
+ // "deleverageLevels": {
731
+ // "shortPositions": [
732
+ // { "level": 1, "rankingLowerBound": "-784.2884" },
733
+ // { "level": 2, "rankingLowerBound": "-2.1078" },
734
+ // { "level": 3, "rankingLowerBound": "-0.8754" },
735
+ // { "level": 4, "rankingLowerBound": "0.0000" }
736
+ // ],
737
+ // "longPositions": [
738
+ // { "level": 1, "rankingLowerBound": "-47747.2010" },
739
+ // { "level": 2, "rankingLowerBound": "-0.0131" },
740
+ // { "level": 3, "rankingLowerBound": "0.0019" },
741
+ // { "level": 4, "rankingLowerBound": "0.0032" }
742
+ // ]
743
+ // }
744
+ // }
745
+ // }
746
+ //
747
+ const data = this.safeDict(response, 'data', {});
748
+ return this.parseTicker(data, market);
749
+ }
750
+ /**
751
+ * @method
752
+ * @name extended#fetchTickers
753
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for all markets
754
+ * @see https://api.docs.extended.exchange/#get-markets
755
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
756
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
757
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
758
+ */
759
+ async fetchTickers(symbols = undefined, params = {}) {
760
+ await this.loadMarkets();
761
+ symbols = this.marketSymbols(symbols);
762
+ const request = {};
763
+ if (symbols !== undefined) {
764
+ const marketIds = [];
765
+ for (let i = 0; i < symbols.length; i++) {
766
+ const market = this.market(symbols[i]);
767
+ marketIds.push(market['id']);
768
+ }
769
+ request['market'] = marketIds;
770
+ }
771
+ const response = await this.v1PublicGetInfoMarkets(this.extend(request, params));
772
+ //
773
+ // {
774
+ // "status": "OK",
775
+ // "data": [
776
+ // {
777
+ // "name": "BTC-USD",
778
+ // "assetName": "BTC",
779
+ // "collateralAssetName": "USD",
780
+ // "marketStats": {
781
+ // "dailyVolume": "231016077.512960",
782
+ // ...
783
+ // },
784
+ // ...
785
+ // }
786
+ // ]
787
+ // }
788
+ //
789
+ const data = this.safeList(response, 'data', []);
790
+ const tickers = {};
791
+ for (let i = 0; i < data.length; i++) {
792
+ const marketData = data[i];
793
+ const marketId = this.safeString(marketData, 'name');
794
+ const market = this.safeMarket(marketId);
795
+ const stats = this.safeDict(marketData, 'marketStats', {});
796
+ const ticker = this.parseTicker(stats, market);
797
+ const symbol = ticker['symbol'];
798
+ tickers[symbol] = ticker;
799
+ }
800
+ return this.filterByArrayTickers(tickers, 'symbol', symbols);
801
+ }
802
+ parseTicker(ticker, market = undefined) {
803
+ //
804
+ // {
805
+ // "dailyVolume": "231216165.666600",
806
+ // "dailyVolumeBase": "3027.36710",
807
+ // "dailyPriceChange": "181",
808
+ // "dailyPriceChangePercentage": "0.0024",
809
+ // "dailyLow": "75635",
810
+ // "dailyHigh": "77399",
811
+ // "lastPrice": "77026",
812
+ // "askPrice": "77026",
813
+ // "bidPrice": "77025",
814
+ // "markPrice": "77006.091897999984",
815
+ // "indexPrice": "77050.739529925005",
816
+ // "fundingRate": "0.000012",
817
+ // "nextFundingRate": 1777446000000,
818
+ // "openInterest": "114851569.088316",
819
+ // "openInterestBase": "1491.33012",
820
+ // "deleverageLevels": {
821
+ // "shortPositions": [
822
+ // { "level": 1, "rankingLowerBound": "-784.2884" },
823
+ // { "level": 2, "rankingLowerBound": "-2.1078" },
824
+ // { "level": 3, "rankingLowerBound": "-0.8754" },
825
+ // { "level": 4, "rankingLowerBound": "0.0000" }
826
+ // ],
827
+ // "longPositions": [
828
+ // { "level": 1, "rankingLowerBound": "-47747.2010" },
829
+ // { "level": 2, "rankingLowerBound": "-0.0131" },
830
+ // { "level": 3, "rankingLowerBound": "0.0019" },
831
+ // { "level": 4, "rankingLowerBound": "0.0032" }
832
+ // ]
833
+ // }
834
+ // }
835
+ //
836
+ const symbol = this.safeSymbol(undefined, market);
837
+ const last = this.safeNumber(ticker, 'lastPrice');
838
+ const percentageRaw = this.safeString(ticker, 'dailyPriceChangePercentage');
839
+ const percentage = (percentageRaw !== undefined) ? Precise.stringMul(percentageRaw, '100') : undefined;
840
+ return this.safeTicker({
841
+ 'symbol': symbol,
842
+ 'timestamp': undefined,
843
+ 'datetime': undefined,
844
+ 'high': this.safeNumber(ticker, 'dailyHigh'),
845
+ 'low': this.safeNumber(ticker, 'dailyLow'),
846
+ 'bid': this.safeNumber(ticker, 'bidPrice'),
847
+ 'bidVolume': undefined,
848
+ 'ask': this.safeNumber(ticker, 'askPrice'),
849
+ 'askVolume': undefined,
850
+ 'vwap': undefined,
851
+ 'open': undefined,
852
+ 'close': last,
853
+ 'last': last,
854
+ 'previousClose': undefined,
855
+ 'change': this.safeNumber(ticker, 'dailyPriceChange'),
856
+ 'percentage': percentage,
857
+ 'average': undefined,
858
+ 'baseVolume': this.safeNumber(ticker, 'dailyVolumeBase'),
859
+ 'quoteVolume': this.safeNumber(ticker, 'dailyVolume'),
860
+ 'markPrice': this.safeNumber(ticker, 'markPrice'),
861
+ 'indexPrice': this.safeNumber(ticker, 'indexPrice'),
862
+ 'info': ticker,
863
+ }, market);
864
+ }
865
+ /**
866
+ * @method
867
+ * @name extended#fetchOrderBook
868
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
869
+ * @see https://api.docs.extended.exchange/#get-market-order-book
870
+ * @param {string} symbol unified symbol of the market to fetch the order book for
871
+ * @param {int} [limit] the maximum amount of order book entries to return
872
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
873
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
874
+ */
875
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
876
+ await this.loadMarkets();
877
+ const market = this.market(symbol);
878
+ const request = {
879
+ 'market': market['id'],
880
+ };
881
+ const response = await this.v1PublicGetInfoMarketsMarketOrderbook(this.extend(request, params));
882
+ //
883
+ // {
884
+ // "status": "OK",
885
+ // "data": {
886
+ // "market": "BTC-USD",
887
+ // "bid": [
888
+ // {
889
+ // "qty": "14.46084",
890
+ // "price": "76214"
891
+ // }
892
+ // ],
893
+ // "ask": [
894
+ // {
895
+ // "qty": "0.11585",
896
+ // "price": "76215"
897
+ // }
898
+ // ]
899
+ // }
900
+ // }
901
+ //
902
+ const data = this.safeDict(response, 'data', {});
903
+ const timestamp = this.milliseconds();
904
+ const orderbook = this.parseOrderBook(data, market['symbol'], timestamp, 'bid', 'ask', 'price', 'qty');
905
+ if (limit !== undefined) {
906
+ orderbook['bids'] = this.arraySlice(orderbook['bids'], 0, limit);
907
+ orderbook['asks'] = this.arraySlice(orderbook['asks'], 0, limit);
908
+ }
909
+ return orderbook;
910
+ }
911
+ /**
912
+ * @method
913
+ * @name extended#fetchTrades
914
+ * @description get the list of most recent trades for a particular symbol
915
+ * @see https://api.docs.extended.exchange/#get-market-last-trades
916
+ * @param {string} symbol unified symbol of the market to fetch trades for
917
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
918
+ * @param {int} [limit] the maximum amount of trades to fetch
919
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
920
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
921
+ */
922
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
923
+ await this.loadMarkets();
924
+ const market = this.market(symbol);
925
+ const request = {
926
+ 'market': market['id'],
927
+ };
928
+ const response = await this.v1PublicGetInfoMarketsMarketTrades(this.extend(request, params));
929
+ //
930
+ // {
931
+ // "status": "OK",
932
+ // "data": [
933
+ // {
934
+ // "i": 2.049676905958871e+18,
935
+ // "m": "BTC-USD",
936
+ // "S": "SELL",
937
+ // "tT": "TRADE",
938
+ // "T": 1777516030193,
939
+ // "p": "76140",
940
+ // "q": "0.00165"
941
+ // }
942
+ // ]
943
+ // }
944
+ //
945
+ const data = this.safeList(response, 'data', []);
946
+ return this.parseTrades(data, market, since, limit);
947
+ }
948
+ /**
949
+ * @method
950
+ * @name extended#fetchMyTrades
951
+ * @description fetch all trades made by the user
952
+ * @see https://api.docs.extended.exchange/#get-trades
953
+ * @param {string} [symbol] unified market symbol of the trades
954
+ * @param {int} [since] the earliest time in ms to fetch trades for
955
+ * @param {int} [limit] the maximum number of trade structures to retrieve
956
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
957
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
958
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
959
+ */
960
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
961
+ await this.loadMarkets();
962
+ let paginate = false;
963
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
964
+ if (paginate) {
965
+ return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
966
+ }
967
+ let market = undefined;
968
+ const request = {};
969
+ if (symbol !== undefined) {
970
+ market = this.market(symbol);
971
+ request['market'] = market['id'];
972
+ }
973
+ if (limit !== undefined) {
974
+ request['limit'] = limit;
975
+ }
976
+ const response = await this.v1PrivateGetUserTrades(this.extend(params, request));
977
+ //
978
+ // {
979
+ // "status": "OK",
980
+ // "data": [
981
+ // {
982
+ // "id": 1,
983
+ // "orderId": 1784980437895231232,
984
+ // "externalId": "ExtId-1",
985
+ // "accountId": 1,
986
+ // "market": "BTC-USD",
987
+ // "side": "BUY",
988
+ // "price": "39000",
989
+ // "qty": "0.2",
990
+ // "value": "7800",
991
+ // "fee": "1.3",
992
+ // "tradeType": "TRADE",
993
+ // "isTaker": true,
994
+ // "createdTime": 1701563440000
995
+ // }
996
+ // ],
997
+ // "pagination": {
998
+ // "cursor": 1784963886257016832,
999
+ // "count": 1
1000
+ // }
1001
+ // }
1002
+ //
1003
+ const data = this.safeList(response, 'data', []);
1004
+ const pagination = this.safeDict(response, 'pagination', {});
1005
+ const cursor = this.safeString(pagination, 'cursor');
1006
+ const result = [];
1007
+ const dataLength = data.length;
1008
+ for (let i = 0; i < dataLength; i++) {
1009
+ let entry = data[i];
1010
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
1011
+ entry = this.extend(entry, { 'cursor': cursor });
1012
+ }
1013
+ result.push(entry);
1014
+ }
1015
+ return this.parseTrades(result, market, since, limit);
1016
+ }
1017
+ /**
1018
+ * @method
1019
+ * @name extended#fetchFundingHistory
1020
+ * @description fetch the funding payments history
1021
+ * @see https://api.docs.extended.exchange/#get-funding-payments
1022
+ * @param {string} [symbol] unified market symbol
1023
+ * @param {int} [since] the earliest time in ms to fetch funding history for
1024
+ * @param {int} [limit] the maximum number of funding history structures to retrieve
1025
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1026
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1027
+ * @returns {FundingHistory[]} a list of [funding history structures]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
1028
+ */
1029
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1030
+ await this.loadMarkets();
1031
+ let paginate = false;
1032
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate');
1033
+ if (paginate) {
1034
+ return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
1035
+ }
1036
+ let market = undefined;
1037
+ const request = {};
1038
+ if (symbol !== undefined) {
1039
+ market = this.market(symbol);
1040
+ request['market'] = market['id'];
1041
+ }
1042
+ if (since !== undefined) {
1043
+ request['startTime'] = since;
1044
+ }
1045
+ if (limit !== undefined) {
1046
+ request['limit'] = limit;
1047
+ }
1048
+ const response = await this.v1PrivateGetUserFundingHistory(this.extend(params, request));
1049
+ //
1050
+ // {
1051
+ // "status": "OK",
1052
+ // "data": [
1053
+ // {
1054
+ // "id": 8341,
1055
+ // "accountId": 3137,
1056
+ // "market": "BNB-USD",
1057
+ // "positionId": 1821237954501148672,
1058
+ // "side": "LONG",
1059
+ // "size": "1.116",
1060
+ // "value": "560.77401888",
1061
+ // "markPrice": "502.48568",
1062
+ // "fundingFee": "0",
1063
+ // "fundingRate": "0",
1064
+ // "paidTime": 1723147241346
1065
+ // }
1066
+ // ],
1067
+ // "pagination": {
1068
+ // "cursor": 8341,
1069
+ // "count": 1
1070
+ // }
1071
+ // }
1072
+ //
1073
+ const data = this.safeList(response, 'data', []);
1074
+ const pagination = this.safeDict(response, 'pagination', {});
1075
+ const cursor = this.safeString(pagination, 'cursor');
1076
+ const result = [];
1077
+ const dataLength = data.length;
1078
+ for (let i = 0; i < dataLength; i++) {
1079
+ let entry = data[i];
1080
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
1081
+ entry = this.extend(entry, { 'cursor': cursor });
1082
+ }
1083
+ result.push(entry);
1084
+ }
1085
+ return this.parseFundingHistories(result, market, since, limit);
1086
+ }
1087
+ parseFundingHistory(history, market = undefined) {
1088
+ //
1089
+ // {
1090
+ // "id": 8341,
1091
+ // "accountId": 3137,
1092
+ // "market": "BNB-USD",
1093
+ // "positionId": 1821237954501148672,
1094
+ // "side": "LONG",
1095
+ // "size": "1.116",
1096
+ // "value": "560.77401888",
1097
+ // "markPrice": "502.48568",
1098
+ // "fundingFee": "0",
1099
+ // "fundingRate": "0",
1100
+ // "paidTime": 1723147241346
1101
+ // }
1102
+ //
1103
+ const marketId = this.safeString(history, 'market');
1104
+ market = this.safeMarket(marketId, market);
1105
+ const timestamp = this.safeInteger(history, 'paidTime');
1106
+ return {
1107
+ 'info': history,
1108
+ 'symbol': market['symbol'],
1109
+ 'code': market['settle'],
1110
+ 'timestamp': timestamp,
1111
+ 'datetime': this.iso8601(timestamp),
1112
+ 'id': this.safeString(history, 'id'),
1113
+ 'amount': this.safeNumber(history, 'fundingFee'),
1114
+ 'rate': this.safeNumber(history, 'fundingRate'),
1115
+ };
1116
+ }
1117
+ parseFundingHistories(histories, market = undefined, since = undefined, limit = undefined) {
1118
+ const result = [];
1119
+ for (let i = 0; i < histories.length; i++) {
1120
+ result.push(this.parseFundingHistory(histories[i], market));
1121
+ }
1122
+ const symbol = (market === undefined) ? undefined : market['symbol'];
1123
+ return this.filterBySymbolSinceLimit(result, symbol, since, limit);
1124
+ }
1125
+ parseTrade(trade, market = undefined) {
1126
+ //
1127
+ // fetchTrades
1128
+ //
1129
+ // {
1130
+ // "i": 2.049676905958871e+18,
1131
+ // "m": "BTC-USD",
1132
+ // "S": "SELL",
1133
+ // "tT": "TRADE",
1134
+ // "T": 1777516030193,
1135
+ // "p": "76140",
1136
+ // "q": "0.00165"
1137
+ // }
1138
+ //
1139
+ // fetchMyTrades
1140
+ //
1141
+ // {
1142
+ // "id": 1,
1143
+ // "orderId": 1784980437895231232,
1144
+ // "externalId": "ExtId-1",
1145
+ // "accountId": 1,
1146
+ // "market": "BTC-USD",
1147
+ // "side": "BUY",
1148
+ // "price": "39000",
1149
+ // "qty": "0.2",
1150
+ // "value": "7800",
1151
+ // "fee": "1.3",
1152
+ // "tradeType": "TRADE",
1153
+ // "isTaker": true,
1154
+ // "createdTime": 1701563440000
1155
+ // }
1156
+ //
1157
+ const marketId = this.safeString2(trade, 'm', 'market');
1158
+ market = this.safeMarket(marketId, market);
1159
+ const timestamp = this.safeInteger2(trade, 'T', 'createdTime');
1160
+ const priceString = this.safeString2(trade, 'p', 'price');
1161
+ const amountString = this.safeString2(trade, 'q', 'qty');
1162
+ const sideRaw = this.safeString2(trade, 'S', 'side');
1163
+ const side = (sideRaw !== undefined) ? sideRaw.toLowerCase() : undefined;
1164
+ const feeCost = this.safeString(trade, 'fee');
1165
+ const fee = (feeCost === undefined) ? undefined : {
1166
+ 'cost': feeCost,
1167
+ 'currency': (market === undefined) ? undefined : market['settle'],
1168
+ };
1169
+ const isTaker = this.safeBool(trade, 'isTaker');
1170
+ let takerOrMaker = undefined;
1171
+ if (isTaker !== undefined) {
1172
+ takerOrMaker = isTaker ? 'taker' : 'maker';
1173
+ }
1174
+ return this.safeTrade({
1175
+ 'id': this.safeString2(trade, 'i', 'id'),
1176
+ 'info': trade,
1177
+ 'timestamp': timestamp,
1178
+ 'datetime': this.iso8601(timestamp),
1179
+ 'symbol': market['symbol'],
1180
+ 'order': this.safeString(trade, 'orderId'),
1181
+ 'type': undefined,
1182
+ 'side': side,
1183
+ 'takerOrMaker': takerOrMaker,
1184
+ 'price': priceString,
1185
+ 'amount': amountString,
1186
+ 'cost': this.safeString(trade, 'value'),
1187
+ 'fee': fee,
1188
+ }, market);
1189
+ }
1190
+ /**
1191
+ * @method
1192
+ * @name extended#fetchOHLCV
1193
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1194
+ * @see https://api.docs.extended.exchange/#get-candles-history
1195
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1196
+ * @param {string} timeframe the length of time each candle represents
1197
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1198
+ * @param {int} [limit] the maximum amount of candles to fetch, default 100
1199
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1200
+ * @param {string} [params.candleType] candle type: 'trades' (default), 'mark-prices', or 'index-prices'
1201
+ * @param {string} [params.price] *ignored if params.candleType is set* 'mark' or 'index' for mark price and index price candles
1202
+ * @param {int} [params.until] end timestamp in ms for the requested period
1203
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1204
+ */
1205
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1206
+ await this.loadMarkets();
1207
+ const market = this.market(symbol);
1208
+ const price = this.safeString(params, 'price');
1209
+ let candleType = this.safeString(params, 'candleType');
1210
+ if (candleType === undefined) {
1211
+ if (price === 'mark') {
1212
+ candleType = 'mark-prices';
1213
+ }
1214
+ else if (price === 'index') {
1215
+ candleType = 'index-prices';
1216
+ }
1217
+ else {
1218
+ candleType = 'trades';
1219
+ }
1220
+ }
1221
+ const until = this.safeInteger(params, 'until');
1222
+ params = this.omit(params, ['candleType', 'price', 'until']);
1223
+ const request = {
1224
+ 'market': market['id'],
1225
+ 'candleType': candleType,
1226
+ 'interval': this.safeString(this.timeframes, timeframe, timeframe),
1227
+ 'limit': (limit !== undefined) ? limit : 100,
1228
+ };
1229
+ if (until !== undefined) {
1230
+ request['endTime'] = until;
1231
+ }
1232
+ const response = await this.v1PublicGetInfoCandlesMarketCandleType(this.extend(request, params));
1233
+ //
1234
+ // {
1235
+ // "status": "OK",
1236
+ // "data": [
1237
+ // {
1238
+ // "o": "75657.5",
1239
+ // "l": "75657.5",
1240
+ // "h": "75657.5",
1241
+ // "c": "75657.5",
1242
+ // "v": "0",
1243
+ // "T": 1777517880000
1244
+ // }
1245
+ // ]
1246
+ // }
1247
+ //
1248
+ const data = this.safeList(response, 'data', []);
1249
+ return this.parseOHLCVs(data, market, timeframe, since, limit);
1250
+ }
1251
+ parseOHLCV(ohlcv, market = undefined) {
1252
+ //
1253
+ // {
1254
+ // "o": "75657.5",
1255
+ // "l": "75657.5",
1256
+ // "h": "75657.5",
1257
+ // "c": "75657.5",
1258
+ // "v": "0",
1259
+ // "T": 1777517880000
1260
+ // }
1261
+ //
1262
+ return [
1263
+ this.safeInteger(ohlcv, 'T'),
1264
+ this.safeNumber(ohlcv, 'o'),
1265
+ this.safeNumber(ohlcv, 'h'),
1266
+ this.safeNumber(ohlcv, 'l'),
1267
+ this.safeNumber(ohlcv, 'c'),
1268
+ this.safeNumber(ohlcv, 'v'),
1269
+ ];
1270
+ }
1271
+ /**
1272
+ * @method
1273
+ * @name extended#fetchFundingRateHistory
1274
+ * @description fetches historical funding rate prices
1275
+ * @see https://api.docs.extended.exchange/#get-funding-rates-history
1276
+ * @param {string} symbol unified symbol of the market to fetch funding rate history for
1277
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1278
+ * @param {int} [limit] the maximum amount of entries to fetch
1279
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1280
+ * @param {int} [params.until] timestamp in ms of the latest funding rate to fetch
1281
+ * @param {int} [params.endTime] exchange-specific end timestamp in ms of the latest funding rate to fetch
1282
+ * @param {int} [params.cursor] offset of the result set
1283
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1284
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
1285
+ */
1286
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1287
+ if (symbol === undefined) {
1288
+ throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
1289
+ }
1290
+ await this.loadMarkets();
1291
+ let paginate = false;
1292
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
1293
+ if (paginate) {
1294
+ return await this.fetchPaginatedCallCursor('fetchFundingRateHistory', symbol, since, limit, params, 'cursor', 'cursor', undefined, 10000);
1295
+ }
1296
+ const market = this.market(symbol);
1297
+ symbol = market['symbol'];
1298
+ if (limit === undefined) {
1299
+ limit = 100;
1300
+ }
1301
+ const until = this.safeInteger(params, 'until', this.milliseconds());
1302
+ const endTime = this.safeInteger(params, 'endTime', until);
1303
+ params = this.omit(params, ['endTime', 'until']);
1304
+ if (since === undefined) {
1305
+ since = endTime - (limit * 60 * 60 * 1000);
1306
+ }
1307
+ const request = {
1308
+ 'market': market['id'],
1309
+ 'startTime': since,
1310
+ 'endTime': endTime,
1311
+ 'limit': limit,
1312
+ };
1313
+ const response = await this.v1PublicGetInfoMarketFunding(this.extend(request, params));
1314
+ //
1315
+ // {
1316
+ // "status": "OK",
1317
+ // "data": [
1318
+ // {
1319
+ // "m": "BTC-USD",
1320
+ // "f": "0.000008",
1321
+ // "T": 1777507201028
1322
+ // }
1323
+ // ],
1324
+ // "pagination": {
1325
+ // "cursor": 1784963886257016832,
1326
+ // "count": 1
1327
+ // }
1328
+ // }
1329
+ //
1330
+ const data = this.safeList(response, 'data', []);
1331
+ const pagination = this.safeDict(response, 'pagination', {});
1332
+ const cursor = this.safeString(pagination, 'cursor');
1333
+ const result = [];
1334
+ const dataLength = data.length;
1335
+ for (let i = 0; i < dataLength; i++) {
1336
+ let entry = data[i];
1337
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
1338
+ entry = this.extend(entry, { 'cursor': cursor });
1339
+ }
1340
+ result.push(this.parseFundingRateHistory(entry, market));
1341
+ }
1342
+ const sorted = this.sortBy(result, 'timestamp');
1343
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
1344
+ }
1345
+ parseFundingRateHistory(info, market = undefined) {
1346
+ //
1347
+ // {
1348
+ // "m": "BTC-USD",
1349
+ // "f": "0.000008",
1350
+ // "T": 1777507201028
1351
+ // }
1352
+ //
1353
+ const marketId = this.safeString(info, 'm');
1354
+ market = this.safeMarket(marketId, market);
1355
+ const timestamp = this.safeInteger(info, 'T');
1356
+ return {
1357
+ 'info': info,
1358
+ 'symbol': market['symbol'],
1359
+ 'fundingRate': this.safeNumber(info, 'f'),
1360
+ 'timestamp': timestamp,
1361
+ 'datetime': this.iso8601(timestamp),
1362
+ };
1363
+ }
1364
+ /**
1365
+ * @method
1366
+ * @name extended#fetchOpenInterestHistory
1367
+ * @description Retrieves the open interest history of a currency
1368
+ * @see https://api.docs.extended.exchange/#get-open-interest-history
1369
+ * @param {string} symbol unified CCXT market symbol
1370
+ * @param {string} timeframe '1h' or '1d'
1371
+ * @param {int} [since] the time(ms) of the earliest record to retrieve as a unix timestamp
1372
+ * @param {int} [limit] the maximum amount of open interest structures to retrieve
1373
+ * @param {object} [params] exchange specific parameters
1374
+ * @param {int} [params.until] timestamp in ms of the latest open interest record to fetch
1375
+ * @returns {object[]} an array of [open interest structures]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
1376
+ */
1377
+ async fetchOpenInterestHistory(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
1378
+ await this.loadMarkets();
1379
+ const market = this.market(symbol);
1380
+ const interval = this.safeString(this.timeframes, timeframe);
1381
+ if (!this.inArray(interval, ['PT1H', 'P1D'])) {
1382
+ throw new BadRequest(this.id + ' fetchOpenInterestHistory() supports 1h and 1d timeframes only');
1383
+ }
1384
+ if (limit === undefined) {
1385
+ limit = 100;
1386
+ }
1387
+ const until = this.safeInteger(params, 'until', this.milliseconds());
1388
+ const endTime = this.safeInteger(params, 'endTime', until);
1389
+ params = this.omit(params, ['endTime', 'until']);
1390
+ if (since === undefined) {
1391
+ since = endTime - (limit * this.parseTimeframe(timeframe) * 1000);
1392
+ }
1393
+ const request = {
1394
+ 'market': market['id'],
1395
+ 'interval': interval,
1396
+ 'startTime': since,
1397
+ 'endTime': endTime,
1398
+ 'limit': limit,
1399
+ };
1400
+ const response = await this.v1PublicGetInfoMarketOpenInterests(this.extend(request, params));
1401
+ //
1402
+ // {
1403
+ // "status": "OK",
1404
+ // "data": [
1405
+ // {
1406
+ // "i": "112620590.6060360000000000",
1407
+ // "I": "1473.1408400000000000",
1408
+ // "t": 1777420800000
1409
+ // }
1410
+ // ]
1411
+ // }
1412
+ //
1413
+ const data = this.safeList(response, 'data', []);
1414
+ return this.parseOpenInterestsHistory(data, market, since, limit);
1415
+ }
1416
+ parseOpenInterest(interest, market = undefined) {
1417
+ //
1418
+ // {
1419
+ // "i": "112620590.6060360000000000",
1420
+ // "I": "1473.1408400000000000",
1421
+ // "t": 1777420800000
1422
+ // }
1423
+ //
1424
+ const timestamp = this.safeInteger(interest, 't');
1425
+ return this.safeOpenInterest({
1426
+ 'symbol': market['symbol'],
1427
+ 'openInterestAmount': this.safeNumber(interest, 'I'),
1428
+ 'openInterestValue': this.safeNumber(interest, 'i'),
1429
+ 'baseVolume': this.safeNumber(interest, 'I'),
1430
+ 'quoteVolume': this.safeNumber(interest, 'i'),
1431
+ 'timestamp': timestamp,
1432
+ 'datetime': this.iso8601(timestamp),
1433
+ 'info': interest,
1434
+ }, market);
1435
+ }
1436
+ /**
1437
+ * @method
1438
+ * @name extended#fetchBalance
1439
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1440
+ * @see https://api.docs.extended.exchange/#get-spot-balances
1441
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1442
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
1443
+ */
1444
+ async fetchBalance(params = {}) {
1445
+ await this.loadMarkets();
1446
+ const response = await this.v1PrivateGetUserSpotBalances(params);
1447
+ //
1448
+ // {
1449
+ // "status": "OK",
1450
+ // "data": [
1451
+ // {
1452
+ // "accountId": 123,
1453
+ // "asset": "USDC",
1454
+ // "balance": "13500",
1455
+ // "indexPrice": "1",
1456
+ // "notionalValue": "13500",
1457
+ // "contributionFactor": "1",
1458
+ // "equityContribution": "13500",
1459
+ // "availableToWithdraw": "100",
1460
+ // "updatedAt": 1701563440
1461
+ // },
1462
+ // {
1463
+ // "accountId": 123,
1464
+ // "asset": "BTC",
1465
+ // "balance": "0.5",
1466
+ // "indexPrice": "65000",
1467
+ // "notionalValue": "32500",
1468
+ // "contributionFactor": "0.95",
1469
+ // "equityContribution": "30875",
1470
+ // "availableToWithdraw": "0.5",
1471
+ // "updatedAt": 1701563440
1472
+ // }
1473
+ // ]
1474
+ // }
1475
+ //
1476
+ const data = this.safeList(response, 'data', []);
1477
+ return this.parseBalance(data);
1478
+ }
1479
+ parseBalance(response) {
1480
+ const result = { 'info': response };
1481
+ for (let i = 0; i < response.length; i++) {
1482
+ const balance = this.safeDict(response, i, {});
1483
+ const currencyId = this.safeString(balance, 'asset');
1484
+ const code = this.safeCurrencyCode(currencyId);
1485
+ const account = this.account();
1486
+ account['free'] = this.safeString(balance, 'availableToWithdraw');
1487
+ account['total'] = this.safeString(balance, 'balance');
1488
+ result[code] = account;
1489
+ }
1490
+ return this.safeBalance(result);
1491
+ }
1492
+ /**
1493
+ * @method
1494
+ * @name extended#fetchAccount
1495
+ * @description fetch the current authenticated sub-account
1496
+ * @see https://api.docs.extended.exchange/#get-account-details
1497
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1498
+ * @returns {object} an [account structure]{@link https://docs.ccxt.com/#/?id=account-structure}
1499
+ */
1500
+ async fetchAccount(params = {}) {
1501
+ const response = await this.v1PrivateGetUserAccountInfo(params);
1502
+ //
1503
+ // {
1504
+ // "status": "OK",
1505
+ // "data": {
1506
+ // "accountId": 3342,
1507
+ // "description": "Main account",
1508
+ // "accountIndex": 0,
1509
+ // "status": "ACTIVE",
1510
+ // "l2Key": "0x...",
1511
+ // "l2Vault": "500343",
1512
+ // "bridgeStarknetAddress": "0x...",
1513
+ // "apiKeys": [
1514
+ // "..."
1515
+ // ],
1516
+ // "accountIndexForKeyGeneration": 0
1517
+ // }
1518
+ // }
1519
+ //
1520
+ const data = this.safeDict(response, 'data', {});
1521
+ return this.parseAccount(data);
1522
+ }
1523
+ /**
1524
+ * @method
1525
+ * @name extended#fetchAccounts
1526
+ * @description fetch the current authenticated sub-account, extended private endpoints only return records for the authenticated sub-account
1527
+ * @see https://api.docs.extended.exchange/#get-sub-accounts
1528
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1529
+ * @returns {object[]} a list of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure}
1530
+ */
1531
+ async fetchAccounts(params = {}) {
1532
+ const response = await this.v1PrivateGetUserAccounts(params);
1533
+ //
1534
+ // {
1535
+ // "status": "OK",
1536
+ // "data": [{
1537
+ // "accountId": 123,
1538
+ // "description": "Main",
1539
+ // "accountIndex": 0,
1540
+ // "status": "ACTIVE",
1541
+ // "l2Key": "0x123",
1542
+ // "l2Vault": "321",
1543
+ // "bridgeStarknetAddress": "0xabc",
1544
+ // "accountIndexForKeyGeneration": 0
1545
+ // }, {
1546
+ // "accountId": 999,
1547
+ // "description": "Vault Balance",
1548
+ // "accountIndex": 1001,
1549
+ // "status": "ACTIVE",
1550
+ // "l2Key": "0x123",
1551
+ // "l2Vault": "999",
1552
+ // "bridgeStarknetAddress": "0xabc",
1553
+ // "accountIndexForKeyGeneration": 0
1554
+ // }
1555
+ // ]}
1556
+ //
1557
+ const data = this.safeList(response, 'data', []);
1558
+ return this.parseAccounts(data);
1559
+ }
1560
+ parseAccount(account) {
1561
+ const accountIndex = this.safeInteger(account, 'accountIndex');
1562
+ let type = undefined;
1563
+ if (accountIndex !== undefined) {
1564
+ type = (accountIndex === 0) ? 'main' : 'subaccount';
1565
+ }
1566
+ return {
1567
+ 'id': this.safeString2(account, 'accountId', 'id'),
1568
+ 'type': type,
1569
+ 'code': undefined,
1570
+ 'info': account,
1571
+ };
1572
+ }
1573
+ /**
1574
+ * @method
1575
+ * @name extended#fetchLedger
1576
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1577
+ * @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
1578
+ * @param {string} [code] unified currency code
1579
+ * @param {int} [since] timestamp in ms of the earliest ledger entry
1580
+ * @param {int} [limit] max number of ledger entries to return
1581
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1582
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1583
+ * @returns {object[]} a list of [ledger structures]{@link https://docs.ccxt.com/#/?id=ledger}
1584
+ */
1585
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1586
+ await this.loadMarkets();
1587
+ let paginate = false;
1588
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
1589
+ if (paginate) {
1590
+ return await this.fetchPaginatedCallCursor('fetchLedger', code, since, limit, params, 'cursor', 'cursor', undefined, 50);
1591
+ }
1592
+ let currency = undefined;
1593
+ if (code !== undefined) {
1594
+ currency = this.currency(code);
1595
+ }
1596
+ const request = {};
1597
+ if (limit !== undefined) {
1598
+ request['limit'] = limit;
1599
+ }
1600
+ const response = await this.v1PrivateGetUserAssetOperations(this.extend(request, params));
1601
+ const data = this.safeList(response, 'data', []);
1602
+ const pagination = this.safeDict(response, 'pagination', {});
1603
+ const cursor = this.safeString(pagination, 'cursor');
1604
+ const result = [];
1605
+ const dataLength = data.length;
1606
+ for (let i = 0; i < dataLength; i++) {
1607
+ let entry = data[i];
1608
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
1609
+ entry = this.extend(entry, { 'cursor': cursor });
1610
+ }
1611
+ result.push(entry);
1612
+ }
1613
+ return this.parseLedger(result, currency, since, limit);
1614
+ }
1615
+ parseLedgerEntry(item, currency = undefined) {
1616
+ //
1617
+ // {
1618
+ // "id": "1951255127004282880",
1619
+ // "type": "TRANSFER",
1620
+ // "status": "COMPLETED",
1621
+ // "amount": "-3.0000000000000000",
1622
+ // "fee": "0",
1623
+ // "asset": 1,
1624
+ // "time": 1754050449502,
1625
+ // "accountId": 100009,
1626
+ // "counterpartyAccountId": 100023
1627
+ // }
1628
+ //
1629
+ const timestamp = this.safeInteger(item, 'time');
1630
+ const assetId = this.safeString(item, 'asset');
1631
+ const code = this.getExtendedCurrencyCodeById(assetId, currency);
1632
+ const ledgerCurrency = this.safeCurrency(code, currency);
1633
+ const amountString = this.safeString(item, 'amount');
1634
+ let direction = undefined;
1635
+ if (amountString !== undefined) {
1636
+ direction = Precise.stringLt(amountString, '0') ? 'out' : 'in';
1637
+ }
1638
+ let fee = undefined;
1639
+ const feeCost = this.safeString(item, 'fee');
1640
+ if (feeCost !== undefined) {
1641
+ fee = {
1642
+ 'currency': code,
1643
+ 'cost': this.parseNumber(Precise.stringAbs(feeCost)),
1644
+ };
1645
+ }
1646
+ return this.safeLedgerEntry({
1647
+ 'info': item,
1648
+ 'id': this.safeString(item, 'id'),
1649
+ 'timestamp': timestamp,
1650
+ 'datetime': this.iso8601(timestamp),
1651
+ 'direction': direction,
1652
+ 'account': this.safeString(item, 'accountId'),
1653
+ 'referenceId': this.safeString(item, 'transactionHash'),
1654
+ 'referenceAccount': this.safeString(item, 'counterpartyAccountId'),
1655
+ 'type': this.parseTransactionType(this.safeString(item, 'type')),
1656
+ 'currency': code,
1657
+ 'amount': (amountString === undefined) ? undefined : this.parseNumber(Precise.stringAbs(amountString)),
1658
+ 'before': undefined,
1659
+ 'after': undefined,
1660
+ 'status': this.parseTransactionStatus(this.safeString(item, 'status')),
1661
+ 'fee': fee,
1662
+ }, ledgerCurrency);
1663
+ }
1664
+ /**
1665
+ * @method
1666
+ * @name extended#fetchTransactions
1667
+ * @description fetch history of deposits, withdrawals, and transfers
1668
+ * @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
1669
+ * @param {string} [code] unified currency code
1670
+ * @param {int} [since] the earliest time in ms to fetch transactions for
1671
+ * @param {int} [limit] the maximum number of transaction structures to retrieve
1672
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1673
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1674
+ * @returns {Transaction[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1675
+ */
1676
+ async fetchTransactions(code = undefined, since = undefined, limit = undefined, params = {}) {
1677
+ await this.loadMarkets();
1678
+ let paginate = false;
1679
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransactions', 'paginate');
1680
+ if (paginate) {
1681
+ return await this.fetchPaginatedCallCursor('fetchTransactions', code, since, limit, params, 'cursor', 'cursor', undefined, 50);
1682
+ }
1683
+ let currency = undefined;
1684
+ if (code !== undefined) {
1685
+ currency = this.currency(code);
1686
+ }
1687
+ const request = {};
1688
+ if (limit !== undefined) {
1689
+ request['limit'] = limit;
1690
+ }
1691
+ const response = await this.v1PrivateGetUserAssetOperations(this.extend(request, params));
1692
+ //
1693
+ // {
1694
+ // "status": "OK",
1695
+ // "data": [
1696
+ // {
1697
+ // "id": "1951255127004282880",
1698
+ // "type": "TRANSFER",
1699
+ // "status": "COMPLETED",
1700
+ // "amount": "-3.0000000000000000",
1701
+ // "fee": "0",
1702
+ // "asset": 1,
1703
+ // "time": 1754050449502,
1704
+ // "accountId": 100009,
1705
+ // "counterpartyAccountId": 100023
1706
+ // }
1707
+ // ],
1708
+ // "pagination": {
1709
+ // "cursor": 1951255127004282880,
1710
+ // "count": 1
1711
+ // }
1712
+ // }
1713
+ //
1714
+ const data = this.safeList(response, 'data', []);
1715
+ const pagination = this.safeDict(response, 'pagination', {});
1716
+ const cursor = this.safeString(pagination, 'cursor');
1717
+ const result = [];
1718
+ const dataLength = data.length;
1719
+ for (let i = 0; i < dataLength; i++) {
1720
+ let entry = data[i];
1721
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
1722
+ entry = this.extend(entry, { 'cursor': cursor });
1723
+ }
1724
+ result.push(entry);
1725
+ }
1726
+ return this.parseTransactions(result, currency, since, limit);
1727
+ }
1728
+ /**
1729
+ * @method
1730
+ * @name extended#fetchDeposits
1731
+ * @description fetch all deposits made to an account
1732
+ * @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
1733
+ * @param {string} [code] unified currency code
1734
+ * @param {int} [since] the earliest time in ms to fetch deposits for
1735
+ * @param {int} [limit] the maximum number of deposit structures to retrieve
1736
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1737
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1738
+ * @returns {Transaction[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1739
+ */
1740
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1741
+ return await this.fetchTransactions(code, since, limit, this.extend({ 'type': 'DEPOSIT' }, params));
1742
+ }
1743
+ /**
1744
+ * @method
1745
+ * @name extended#fetchWithdrawals
1746
+ * @description fetch all withdrawals made from an account
1747
+ * @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
1748
+ * @param {string} [code] unified currency code
1749
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
1750
+ * @param {int} [limit] the maximum number of withdrawal structures to retrieve
1751
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1752
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1753
+ * @returns {Transaction[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1754
+ */
1755
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1756
+ return await this.fetchTransactions(code, since, limit, this.extend({ 'type': 'WITHDRAWAL' }, params));
1757
+ }
1758
+ /**
1759
+ * @method
1760
+ * @name extended#withdraw
1761
+ * @description make a Starknet withdrawal
1762
+ * @see https://api.docs.extended.exchange/#withdrawals
1763
+ * @param {string} code unified currency code
1764
+ * @param {float} amount the amount to withdraw
1765
+ * @param {string} address the Starknet address to withdraw to
1766
+ * @param {string} tag unused
1767
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1768
+ * @param {string} [params.chainId] only STRK is supported
1769
+ * @param {int} [params.settlementExpiration] settlement expiration timestamp in seconds, defaults to now + 14 days + 60 seconds
1770
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
1771
+ */
1772
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
1773
+ this.checkRequiredCredentials();
1774
+ await this.loadMarkets();
1775
+ const currency = this.currency(code);
1776
+ const chainId = this.safeStringUpper2(params, 'chainId', 'network', 'STRK');
1777
+ if (chainId !== 'STRK') {
1778
+ throw new BadRequest(this.id + ' withdraw() only supports Starknet withdrawals with chainId STRK');
1779
+ }
1780
+ if (address.length <= 42) {
1781
+ throw new BadRequest(this.id + ' withdraw() requires a Starknet address for STRK withdrawals, EVM withdrawals require the bridge quote flow');
1782
+ }
1783
+ const account = await this.fetchExtendedAccount();
1784
+ const amountString = this.currencyToPrecision(code, amount);
1785
+ const accountId = this.safeString(account, 'accountId');
1786
+ const settlement = this.createWithdrawalSettlementData(address, amountString, currency, account, params);
1787
+ const request = {
1788
+ 'accountId': accountId,
1789
+ 'amount': amountString,
1790
+ 'chainId': chainId,
1791
+ 'asset': currency['id'],
1792
+ 'settlement': settlement,
1793
+ };
1794
+ params = this.omit(params, ['chainId', 'network', 'settlementExpiration', 'nonce', 'recipient', 'positionId', 'l2Vault', 'collateralId', 'resolution']);
1795
+ const response = await this.v1PrivatePostUserWithdrawal(this.extend(request, params));
1796
+ //
1797
+ // {
1798
+ // "status": "OK",
1799
+ // "data": 1820796462590083072
1800
+ // }
1801
+ //
1802
+ const now = this.milliseconds();
1803
+ return {
1804
+ 'info': response,
1805
+ 'id': this.safeString(response, 'data'),
1806
+ 'txid': undefined,
1807
+ 'timestamp': now,
1808
+ 'datetime': this.iso8601(now),
1809
+ 'address': address,
1810
+ 'addressFrom': undefined,
1811
+ 'addressTo': address,
1812
+ 'tag': tag,
1813
+ 'tagFrom': undefined,
1814
+ 'tagTo': tag,
1815
+ 'type': 'withdrawal',
1816
+ 'amount': this.parseNumber(amountString),
1817
+ 'currency': currency['code'],
1818
+ 'status': 'pending',
1819
+ 'updated': now,
1820
+ 'fee': undefined,
1821
+ 'network': chainId,
1822
+ 'comment': undefined,
1823
+ 'internal': false,
1824
+ };
1825
+ }
1826
+ /**
1827
+ * @method
1828
+ * @name extended#fetchTransfers
1829
+ * @description fetch a history of internal transfers made on an account
1830
+ * @see https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history
1831
+ * @param {string} [code] unified currency code
1832
+ * @param {int} [since] the earliest time in ms to fetch transfers for
1833
+ * @param {int} [limit] the maximum number of transfer structures to retrieve
1834
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1835
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1836
+ * @returns {TransferEntry[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1837
+ */
1838
+ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
1839
+ await this.loadMarkets();
1840
+ let paginate = false;
1841
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
1842
+ if (paginate) {
1843
+ return await this.fetchPaginatedCallCursor('fetchTransfers', code, since, limit, params, 'cursor', 'cursor', undefined, 50);
1844
+ }
1845
+ let currency = undefined;
1846
+ if (code !== undefined) {
1847
+ currency = this.currency(code);
1848
+ }
1849
+ const request = {
1850
+ 'type': 'TRANSFER',
1851
+ };
1852
+ if (limit !== undefined) {
1853
+ request['limit'] = limit;
1854
+ }
1855
+ const response = await this.v1PrivateGetUserAssetOperations(this.extend(request, params));
1856
+ const data = this.safeList(response, 'data', []);
1857
+ const pagination = this.safeDict(response, 'pagination', {});
1858
+ const cursor = this.safeString(pagination, 'cursor');
1859
+ const result = [];
1860
+ const dataLength = data.length;
1861
+ for (let i = 0; i < dataLength; i++) {
1862
+ let entry = data[i];
1863
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
1864
+ entry = this.extend(entry, { 'cursor': cursor });
1865
+ }
1866
+ result.push(entry);
1867
+ }
1868
+ return this.parseTransfers(result, currency, since, limit);
1869
+ }
1870
+ /**
1871
+ * @method
1872
+ * @name extended#transfer
1873
+ * @description transfer collateral between sub-accounts associated with the same wallet
1874
+ * @see https://api.docs.extended.exchange/#create-transfer
1875
+ * @param {string} code unified currency code
1876
+ * @param {float} amount the amount to transfer
1877
+ * @param {string} fromAccount source account id, defaults to the authenticated account id
1878
+ * @param {string} toAccount destination account id
1879
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1880
+ * @param {string} params.toVault destination account L2 vault
1881
+ * @param {string} params.toL2Key destination account L2 public key
1882
+ * @param {int} [params.settlementExpiration] settlement expiration timestamp in seconds, defaults to now + 21 days
1883
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1884
+ */
1885
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
1886
+ this.checkRequiredCredentials();
1887
+ await this.loadMarkets();
1888
+ const currency = this.currency(code);
1889
+ const account = await this.fetchExtendedAccount();
1890
+ const currentAccountId = this.safeString(account, 'accountId');
1891
+ if (fromAccount === undefined) {
1892
+ fromAccount = currentAccountId;
1893
+ }
1894
+ else if (fromAccount !== currentAccountId) {
1895
+ throw new BadRequest(this.id + ' transfer() can only transfer from the authenticated account');
1896
+ }
1897
+ const toVault = this.safeString2(params, 'toVault', 'receiverPositionId');
1898
+ const toL2Key = this.safeString2(params, 'toL2Key', 'receiverPublicKey');
1899
+ if ((toAccount === undefined) || (toVault === undefined) || (toL2Key === undefined)) {
1900
+ throw new ArgumentsRequired(this.id + ' transfer() requires a toAccount argument and params["toVault"] and params["toL2Key"]');
1901
+ }
1902
+ const amountString = this.currencyToPrecision(code, amount);
1903
+ const settlement = this.createTransferSettlementData(amountString, currency, account, toVault, toL2Key, params);
1904
+ const request = {
1905
+ 'fromAccount': fromAccount,
1906
+ 'toAccount': toAccount,
1907
+ 'amount': amountString,
1908
+ 'transferredAsset': currency['id'],
1909
+ 'settlement': settlement,
1910
+ };
1911
+ params = this.omit(params, ['fromVault', 'senderPositionId', 'fromL2Key', 'senderPublicKey', 'toVault', 'receiverPositionId', 'toL2Key', 'receiverPublicKey', 'settlementExpiration', 'nonce', 'assetId', 'collateralId', 'resolution']);
1912
+ const response = await this.v1PrivatePostUserTransfer(this.extend(request, params));
1913
+ //
1914
+ // {
1915
+ // "status": "OK",
1916
+ // "data": {
1917
+ // "validSignature": true,
1918
+ // "id": 1820778187672010752
1919
+ // }
1920
+ // }
1921
+ //
1922
+ const data = this.safeDict(response, 'data', {});
1923
+ const validSignature = this.safeBool(data, 'validSignature');
1924
+ const now = this.milliseconds();
1925
+ let status = 'pending';
1926
+ if (validSignature !== undefined) {
1927
+ status = validSignature ? 'ok' : 'failed';
1928
+ }
1929
+ return {
1930
+ 'info': response,
1931
+ 'id': this.safeString(data, 'id'),
1932
+ 'timestamp': now,
1933
+ 'datetime': this.iso8601(now),
1934
+ 'currency': currency['code'],
1935
+ 'amount': this.parseNumber(amountString),
1936
+ 'fromAccount': fromAccount,
1937
+ 'toAccount': toAccount,
1938
+ 'status': status,
1939
+ };
1940
+ }
1941
+ parseTransfer(transfer, currency = undefined) {
1942
+ const timestamp = this.safeInteger(transfer, 'time');
1943
+ const assetId = this.safeString(transfer, 'asset');
1944
+ const code = this.getExtendedCurrencyCodeById(assetId, currency);
1945
+ const amountString = this.safeString(transfer, 'amount');
1946
+ const amount = (amountString === undefined) ? undefined : this.parseNumber(Precise.stringAbs(amountString));
1947
+ const accountId = this.safeString(transfer, 'accountId');
1948
+ const counterpartyAccountId = this.safeString(transfer, 'counterpartyAccountId');
1949
+ let fromAccount = accountId;
1950
+ let toAccount = counterpartyAccountId;
1951
+ if ((amountString !== undefined) && !Precise.stringLt(amountString, '0')) {
1952
+ fromAccount = counterpartyAccountId;
1953
+ toAccount = accountId;
1954
+ }
1955
+ const validSignature = this.safeBool(transfer, 'validSignature');
1956
+ let status = undefined;
1957
+ if (validSignature !== undefined) {
1958
+ status = validSignature ? 'ok' : 'failed';
1959
+ }
1960
+ else {
1961
+ status = this.parseTransactionStatus(this.safeString(transfer, 'status'));
1962
+ }
1963
+ return {
1964
+ 'info': transfer,
1965
+ 'id': this.safeString(transfer, 'id'),
1966
+ 'timestamp': timestamp,
1967
+ 'datetime': this.iso8601(timestamp),
1968
+ 'currency': code,
1969
+ 'amount': amount,
1970
+ 'fromAccount': fromAccount,
1971
+ 'toAccount': toAccount,
1972
+ 'status': status,
1973
+ };
1974
+ }
1975
+ getExtendedCurrencyCodeById(assetId, currency = undefined) {
1976
+ if (assetId === undefined) {
1977
+ return this.safeString(currency, 'code');
1978
+ }
1979
+ const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId', {});
1980
+ const currencyByNumericId = this.safeDict(currenciesByNumericId, assetId);
1981
+ if (currencyByNumericId !== undefined) {
1982
+ return this.safeString(currencyByNumericId, 'code');
1983
+ }
1984
+ if (currency !== undefined) {
1985
+ return currency['code'];
1986
+ }
1987
+ let code = this.safeCurrencyCode(assetId);
1988
+ if (code === 'USD') {
1989
+ code = 'USDC';
1990
+ }
1991
+ return code;
1992
+ }
1993
+ parseTransactionStatus(status) {
1994
+ const statuses = {
1995
+ 'CREATED': 'pending',
1996
+ 'IN_PROGRESS': 'pending',
1997
+ 'COMPLETED': 'ok',
1998
+ 'REJECTED': 'failed',
1999
+ };
2000
+ return this.safeString(statuses, status, status);
2001
+ }
2002
+ parseTransactionType(type) {
2003
+ const types = {
2004
+ 'DEPOSIT': 'deposit',
2005
+ 'WITHDRAWAL': 'withdrawal',
2006
+ 'TRANSFER': 'transfer',
2007
+ 'CLAIM': 'claim',
2008
+ };
2009
+ return this.safeString(types, type, type);
2010
+ }
2011
+ parseTransaction(transaction, currency = undefined) {
2012
+ //
2013
+ // {
2014
+ // "id": "1951255127004282880",
2015
+ // "type": "TRANSFER",
2016
+ // "status": "COMPLETED",
2017
+ // "amount": "-3.0000000000000000",
2018
+ // "fee": "0",
2019
+ // "asset": 1,
2020
+ // "time": 1754050449502,
2021
+ // "accountId": 100009,
2022
+ // "counterpartyAccountId": 100023
2023
+ // }
2024
+ //
2025
+ const timestamp = this.safeInteger(transaction, 'time');
2026
+ const assetId = this.safeString(transaction, 'asset');
2027
+ const code = this.getExtendedCurrencyCodeById(assetId, currency);
2028
+ const amountString = this.safeString(transaction, 'amount');
2029
+ const amount = (amountString === undefined) ? undefined : this.parseNumber(Precise.stringAbs(amountString));
2030
+ let fee = undefined;
2031
+ const feeCost = this.safeString(transaction, 'fee');
2032
+ if (feeCost !== undefined) {
2033
+ fee = {
2034
+ 'currency': code,
2035
+ 'cost': this.parseNumber(Precise.stringAbs(feeCost)),
2036
+ };
2037
+ }
2038
+ const transactionType = this.parseTransactionType(this.safeString(transaction, 'type'));
2039
+ const network = this.safeString(transaction, 'chain');
2040
+ return {
2041
+ 'info': transaction,
2042
+ 'id': this.safeString(transaction, 'id'),
2043
+ 'txid': this.safeString(transaction, 'transactionHash'),
2044
+ 'timestamp': timestamp,
2045
+ 'datetime': this.iso8601(timestamp),
2046
+ 'address': undefined,
2047
+ 'addressFrom': undefined,
2048
+ 'addressTo': undefined,
2049
+ 'tag': undefined,
2050
+ 'tagFrom': undefined,
2051
+ 'tagTo': undefined,
2052
+ 'type': transactionType,
2053
+ 'amount': amount,
2054
+ 'currency': code,
2055
+ 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
2056
+ 'updated': timestamp,
2057
+ 'fee': fee,
2058
+ 'network': network,
2059
+ 'comment': undefined,
2060
+ 'internal': (transactionType === 'transfer'),
2061
+ };
2062
+ }
2063
+ /**
2064
+ * @method
2065
+ * @name extended#fetchTradingFee
2066
+ * @description fetch the trading fees for a market
2067
+ * @see https://api.docs.extended.exchange/#get-fees
2068
+ * @param {string} symbol unified market symbol
2069
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2070
+ * @param {string} [params.builderId] builder client id
2071
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
2072
+ */
2073
+ async fetchTradingFee(symbol, params = {}) {
2074
+ await this.loadMarkets();
2075
+ const market = this.market(symbol);
2076
+ const request = {
2077
+ 'market': market['id'],
2078
+ };
2079
+ const response = await this.v1PrivateGetUserFees(this.extend(request, params));
2080
+ //
2081
+ // {
2082
+ // "status": "OK",
2083
+ // "data": [
2084
+ // {
2085
+ // "market": "BTC-USD",
2086
+ // "makerFeeRate": "0.00000",
2087
+ // "takerFeeRate": "0.00025",
2088
+ // "builderFeeRate": "0.0001"
2089
+ // }
2090
+ // ]
2091
+ // }
2092
+ //
2093
+ const data = this.safeList(response, 'data', []);
2094
+ const first = this.safeDict(data, 0, {});
2095
+ return this.parseTradingFee(first, market);
2096
+ }
2097
+ /**
2098
+ * @method
2099
+ * @name extended#fetchTradingFees
2100
+ * @description fetch the trading fees for multiple markets
2101
+ * @see https://api.docs.extended.exchange/#get-fees
2102
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2103
+ * @param {string} [params.market] exchange market id
2104
+ * @param {string} [params.builderId] builder client id
2105
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
2106
+ */
2107
+ async fetchTradingFees(params = {}) {
2108
+ await this.loadMarkets();
2109
+ const response = await this.v1PrivateGetUserFees(params);
2110
+ //
2111
+ // {
2112
+ // "status": "OK",
2113
+ // "data": [
2114
+ // {
2115
+ // "market": "BTC-USD",
2116
+ // "makerFeeRate": "0.00000",
2117
+ // "takerFeeRate": "0.00025",
2118
+ // "builderFeeRate": "0.0001"
2119
+ // }
2120
+ // ]
2121
+ // }
2122
+ //
2123
+ const data = this.safeList(response, 'data', []);
2124
+ const result = {};
2125
+ for (let i = 0; i < data.length; i++) {
2126
+ const fee = this.safeDict(data, i, {});
2127
+ const parsed = this.parseTradingFee(fee);
2128
+ const symbol = this.safeString(parsed, 'symbol');
2129
+ result[symbol] = parsed;
2130
+ }
2131
+ return result;
2132
+ }
2133
+ parseTradingFee(fee, market = undefined) {
2134
+ //
2135
+ // {
2136
+ // "market": "BTC-USD",
2137
+ // "makerFeeRate": "0.00000",
2138
+ // "takerFeeRate": "0.00025",
2139
+ // "builderFeeRate": "0.0001"
2140
+ // }
2141
+ //
2142
+ const marketId = this.safeString(fee, 'market');
2143
+ market = this.safeMarket(marketId, market);
2144
+ return {
2145
+ 'info': fee,
2146
+ 'symbol': market['symbol'],
2147
+ 'maker': this.safeNumber(fee, 'makerFeeRate'),
2148
+ 'taker': this.safeNumber(fee, 'takerFeeRate'),
2149
+ 'percentage': true,
2150
+ 'tierBased': undefined,
2151
+ };
2152
+ }
2153
+ /**
2154
+ * @method
2155
+ * @name extended#fetchLeverage
2156
+ * @description fetch the set leverage for a market
2157
+ * @see https://api.docs.extended.exchange/#get-leverage
2158
+ * @param {string} symbol unified market symbol
2159
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2160
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2161
+ */
2162
+ async fetchLeverage(symbol, params = {}) {
2163
+ await this.loadMarkets();
2164
+ const market = this.market(symbol);
2165
+ const request = {
2166
+ 'market': market['id'],
2167
+ };
2168
+ const response = await this.v1PrivateGetUserLeverage(this.extend(request, params));
2169
+ //
2170
+ // {
2171
+ // "status": "OK",
2172
+ // "data": [
2173
+ // {
2174
+ // "market": "SOL-USD",
2175
+ // "leverage": "10"
2176
+ // }
2177
+ // ]
2178
+ // }
2179
+ //
2180
+ const data = this.safeList(response, 'data', []);
2181
+ return this.parseLeverage(this.safeDict(data, 0), market);
2182
+ }
2183
+ /**
2184
+ * @method
2185
+ * @name extended#setLeverage
2186
+ * @description set the level of leverage for a market
2187
+ * @see https://api.docs.extended.exchange/#update-leverage
2188
+ * @param {int} leverage the rate of leverage
2189
+ * @param {string} symbol unified market symbol
2190
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2191
+ * @returns {object} response from the exchange
2192
+ */
2193
+ async setLeverage(leverage, symbol = undefined, params = {}) {
2194
+ if (symbol === undefined) {
2195
+ throw new ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
2196
+ }
2197
+ await this.loadMarkets();
2198
+ const market = this.market(symbol);
2199
+ const request = {
2200
+ 'market': market['id'],
2201
+ 'leverage': this.numberToString(leverage),
2202
+ };
2203
+ const response = await this.v1PrivatePatchUserLeverage(this.extend(request, params));
2204
+ //
2205
+ // {
2206
+ // "status": "OK",
2207
+ // "data": {}
2208
+ // }
2209
+ //
2210
+ const data = this.safeDict(response, 'data', {});
2211
+ return this.parseLeverage(data, market);
2212
+ }
2213
+ parseLeverage(leverage, market = undefined) {
2214
+ //
2215
+ // {
2216
+ // "market": "BTC-USD",
2217
+ // "leverage": "10"
2218
+ // }
2219
+ //
2220
+ const marketId = this.safeString(leverage, 'market');
2221
+ market = this.safeMarket(marketId, market);
2222
+ const leverageValue = this.safeNumber(leverage, 'leverage');
2223
+ return {
2224
+ 'info': leverage,
2225
+ 'symbol': market['symbol'],
2226
+ 'marginMode': undefined,
2227
+ 'longLeverage': leverageValue,
2228
+ 'shortLeverage': leverageValue,
2229
+ };
2230
+ }
2231
+ /**
2232
+ * @method
2233
+ * @name extended#fetchPositions
2234
+ * @description fetch all open positions
2235
+ * @see https://api.docs.extended.exchange/#get-positions
2236
+ * @param {string[]|undefined} symbols list of unified market symbols
2237
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2238
+ * @returns {Position[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
2239
+ */
2240
+ async fetchPositions(symbols = undefined, params = {}) {
2241
+ await this.loadMarkets();
2242
+ const request = {};
2243
+ if (symbols !== undefined) {
2244
+ const marketIds = this.marketIds(symbols);
2245
+ request['market'] = marketIds;
2246
+ }
2247
+ const response = await this.v1PrivateGetUserPositions(this.extend(request, params));
2248
+ //
2249
+ // {
2250
+ // "status": "OK",
2251
+ // "data": [
2252
+ // {
2253
+ // "id": 1,
2254
+ // "accountId": 1,
2255
+ // "market": "BTC-USD",
2256
+ // "side": "LONG",
2257
+ // "leverage": "10",
2258
+ // "size": "0.1",
2259
+ // "value": "4000",
2260
+ // "openPrice": "39000",
2261
+ // "markPrice": "40000",
2262
+ // "liquidationPrice": "38200",
2263
+ // "margin": "20",
2264
+ // "unrealisedPnl": "1000",
2265
+ // "realisedPnl": "1.2",
2266
+ // "tpTriggerPrice": "41000",
2267
+ // "tpLimitPrice": "41500",
2268
+ // "slTriggerPrice": "39500",
2269
+ // "slLimitPrice": "39000",
2270
+ // "adl": "2.5",
2271
+ // "maxPositionSize": "0.2",
2272
+ // "createdAt": 1701563440000,
2273
+ // "updatedAt": 1701563440000
2274
+ // }
2275
+ // ]
2276
+ // }
2277
+ //
2278
+ const data = this.safeList(response, 'data', []);
2279
+ return this.parsePositions(data, symbols);
2280
+ }
2281
+ /**
2282
+ * @method
2283
+ * @name extended#fetchPosition
2284
+ * @description fetch data on an open position
2285
+ * @see https://api.docs.extended.exchange/#get-positions
2286
+ * @param {string} symbol unified market symbol of the market the position is held in
2287
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2288
+ * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2289
+ */
2290
+ async fetchPosition(symbol, params = {}) {
2291
+ const positions = await this.fetchPositions([symbol], params);
2292
+ return this.safeDict(positions, 0);
2293
+ }
2294
+ /**
2295
+ * @method
2296
+ * @name extended#fetchPositionsHistory
2297
+ * @description fetch historical positions
2298
+ * @see https://api.docs.extended.exchange/#get-positions-history
2299
+ * @param {string[]|undefined} symbols list of unified market symbols
2300
+ * @param {int} [since] the earliest time in ms to fetch positions for
2301
+ * @param {int} [limit] the maximum number of position structures to retrieve
2302
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2303
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2304
+ * @returns {Position[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
2305
+ */
2306
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
2307
+ await this.loadMarkets();
2308
+ if (typeof symbols === 'string') {
2309
+ symbols = [symbols];
2310
+ }
2311
+ let paginate = false;
2312
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchPositionsHistory', 'paginate');
2313
+ if (paginate) {
2314
+ return await this.fetchPaginatedCallCursor('fetchPositionsHistory', symbols, since, limit, params, 'cursor', 'cursor', undefined, 10000);
2315
+ }
2316
+ const request = {};
2317
+ if (symbols !== undefined) {
2318
+ const marketIds = this.marketIds(symbols);
2319
+ request['market'] = marketIds;
2320
+ }
2321
+ const response = await this.v1PrivateGetUserPositionsHistory(this.extend(request, params));
2322
+ //
2323
+ // {
2324
+ // "status": "OK",
2325
+ // "data": [
2326
+ // {
2327
+ // "id": 1784963886257016832,
2328
+ // "accountId": 1,
2329
+ // "market": "BTC-USD",
2330
+ // "side": "LONG",
2331
+ // "exitType": "TRADE",
2332
+ // "leverage": "10",
2333
+ // "size": "0.1",
2334
+ // "maxPositionSize": "0.2",
2335
+ // "openPrice": "39000",
2336
+ // "exitPrice": "40000",
2337
+ // "realisedPnl": "10",
2338
+ // "createdTime": 1701563440000,
2339
+ // "closedTime": 1701567040000
2340
+ // }
2341
+ // ],
2342
+ // "pagination": {
2343
+ // "cursor": 1784963886257016832,
2344
+ // "count": 1
2345
+ // }
2346
+ // }
2347
+ //
2348
+ const data = this.safeList(response, 'data', []);
2349
+ const pagination = this.safeDict(response, 'pagination', {});
2350
+ const cursor = this.safeString(pagination, 'cursor');
2351
+ const result = [];
2352
+ const dataLength = data.length;
2353
+ for (let i = 0; i < dataLength; i++) {
2354
+ let entry = data[i];
2355
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
2356
+ entry = this.extend(entry, { 'cursor': cursor });
2357
+ }
2358
+ result.push(entry);
2359
+ }
2360
+ const positions = this.parsePositions(result, symbols);
2361
+ return this.filterBySinceLimit(positions, since, limit, 'timestamp');
2362
+ }
2363
+ parsePosition(position, market = undefined) {
2364
+ //
2365
+ // {
2366
+ // "id": 1,
2367
+ // "accountId": 1,
2368
+ // "market": "BTC-USD",
2369
+ // "side": "LONG",
2370
+ // "leverage": "10",
2371
+ // "size": "0.1",
2372
+ // "value": "4000",
2373
+ // "openPrice": "39000",
2374
+ // "markPrice": "40000",
2375
+ // "liquidationPrice": "38200",
2376
+ // "margin": "20",
2377
+ // "unrealisedPnl": "1000",
2378
+ // "realisedPnl": "1.2",
2379
+ // "tpTriggerPrice": "41000",
2380
+ // "tpLimitPrice": "41500",
2381
+ // "slTriggerPrice": "39500",
2382
+ // "slLimitPrice": "39000",
2383
+ // "adl": "2.5",
2384
+ // "maxPositionSize": "0.2",
2385
+ // "createdAt": 1701563440000,
2386
+ // "updatedAt": 1701563440000
2387
+ // }
2388
+ //
2389
+ const marketId = this.safeString(position, 'market');
2390
+ market = this.safeMarket(marketId, market);
2391
+ const timestamp = this.safeInteger2(position, 'createdAt', 'createdTime');
2392
+ let lastUpdateTimestamp = this.safeInteger2(position, 'updatedAt', 'updatedTime');
2393
+ lastUpdateTimestamp = this.safeInteger(position, 'closedTime', lastUpdateTimestamp);
2394
+ const side = this.safeStringLower(position, 'side');
2395
+ const margin = this.safeString(position, 'margin');
2396
+ return this.safePosition({
2397
+ 'info': position,
2398
+ 'id': this.safeString(position, 'id'),
2399
+ 'symbol': market['symbol'],
2400
+ 'timestamp': timestamp,
2401
+ 'datetime': this.iso8601(timestamp),
2402
+ 'lastUpdateTimestamp': lastUpdateTimestamp,
2403
+ 'initialMargin': margin,
2404
+ 'initialMarginPercentage': undefined,
2405
+ 'maintenanceMargin': undefined,
2406
+ 'maintenanceMarginPercentage': undefined,
2407
+ 'entryPrice': this.safeString(position, 'openPrice'),
2408
+ 'notional': this.safeString(position, 'value'),
2409
+ 'leverage': this.safeString(position, 'leverage'),
2410
+ 'unrealizedPnl': this.safeString(position, 'unrealisedPnl'),
2411
+ 'realizedPnl': this.safeString(position, 'realisedPnl'),
2412
+ 'contracts': this.safeString(position, 'size'),
2413
+ 'contractSize': this.safeString(market, 'contractSize'),
2414
+ 'marginRatio': undefined,
2415
+ 'liquidationPrice': this.safeString(position, 'liquidationPrice'),
2416
+ 'markPrice': this.safeString(position, 'markPrice'),
2417
+ 'lastPrice': this.safeString(position, 'exitPrice'),
2418
+ 'collateral': margin,
2419
+ 'marginMode': undefined,
2420
+ 'side': side,
2421
+ 'percentage': undefined,
2422
+ 'hedged': undefined,
2423
+ 'stopLossPrice': this.safeString(position, 'slTriggerPrice'),
2424
+ 'takeProfitPrice': this.safeString(position, 'tpTriggerPrice'),
2425
+ });
2426
+ }
2427
+ getExtendedStarkAmount(amount, resolution, roundUp = false) {
2428
+ const resolutionString = this.numberToString(resolution);
2429
+ const precise = Precise.stringMul(amount, resolutionString);
2430
+ let result = this.decimalToPrecision(precise, TRUNCATE, 0, DECIMAL_PLACES, NO_PADDING);
2431
+ if (roundUp && Precise.stringGt(precise, result)) {
2432
+ result = Precise.stringAdd(result, '1');
2433
+ }
2434
+ return result;
2435
+ }
2436
+ async fetchExtendedAccount(params = {}) {
2437
+ let account = this.safeDict(this.options, 'account');
2438
+ if (account !== undefined) {
2439
+ return account;
2440
+ }
2441
+ const accountData = await this.fetchAccount(params);
2442
+ account = accountData['info'];
2443
+ this.options['account'] = account;
2444
+ return account;
2445
+ }
2446
+ createOrderSettlementData(isBuy, amountString, priceString, params = {}) {
2447
+ const totalFee = this.safeString(params, 'totalFee');
2448
+ const settlementExpiration = this.safeInteger(params, 'settlementExpiration');
2449
+ const nonce = this.safeInteger(params, 'nonce');
2450
+ const starkKey = this.safeString(params, 'starkKey');
2451
+ const collateralPosition = this.safeString(params, 'collateralPosition');
2452
+ const syntheticId = this.safeString(params, 'syntheticId');
2453
+ const collateralId = this.safeString(params, 'collateralId');
2454
+ const syntheticResolution = this.safeInteger(params, 'syntheticResolution');
2455
+ const collateralResolution = this.safeInteger(params, 'collateralResolution');
2456
+ const quoteAmount = Precise.stringMul(amountString, priceString);
2457
+ const baseRoundUp = isBuy;
2458
+ const quoteRoundUp = isBuy;
2459
+ let baseAmount = this.getExtendedStarkAmount(amountString, syntheticResolution, baseRoundUp);
2460
+ let collateralAmount = this.getExtendedStarkAmount(quoteAmount, collateralResolution, quoteRoundUp);
2461
+ if (isBuy) {
2462
+ collateralAmount = Precise.stringNeg(collateralAmount);
2463
+ }
2464
+ else {
2465
+ baseAmount = Precise.stringNeg(baseAmount);
2466
+ }
2467
+ const feeAmount = this.getExtendedStarkAmount(Precise.stringMul(totalFee, quoteAmount), collateralResolution, true);
2468
+ const settlement = {
2469
+ 'starkKey': starkKey,
2470
+ 'collateralPosition': collateralPosition,
2471
+ 'baseAssetId': syntheticId,
2472
+ 'baseAmount': baseAmount,
2473
+ 'quoteAssetId': collateralId,
2474
+ 'quoteAmount': collateralAmount,
2475
+ 'feeAssetId': collateralId,
2476
+ 'feeAmount': feeAmount,
2477
+ 'expiration': this.numberToString(settlementExpiration),
2478
+ 'salt': nonce,
2479
+ };
2480
+ const msgHash = this.getExtendedOrderMsgHash(settlement);
2481
+ const sig = JSON.parse(this.extendedStarknetSign(msgHash, this.privateKey));
2482
+ const r = this.getExtendedSignatureHex(sig[0]);
2483
+ const s = this.getExtendedSignatureHex(sig[1]);
2484
+ settlement['r'] = r;
2485
+ settlement['s'] = s;
2486
+ return settlement;
2487
+ }
2488
+ createWithdrawalSettlementData(address, amountString, currency, account, params = {}) {
2489
+ const now = this.milliseconds();
2490
+ const settlementExpiration = this.safeInteger(params, 'settlementExpiration', this.parseToInt((now + 999) / 1000) + 1209600 + 60);
2491
+ const nonce = this.safeInteger(params, 'nonce', this.nonce());
2492
+ const positionId = this.safeString2(params, 'positionId', 'l2Vault', this.safeString(account, 'l2Vault'));
2493
+ const recipient = this.safeString(params, 'recipient', address);
2494
+ const currencyInfo = this.safeDict(currency, 'info', {});
2495
+ const collateralId = this.safeString(params, 'collateralId', this.safeString2(currencyInfo, 'starkexId', 'l1Id'));
2496
+ const resolution = this.safeInteger(params, 'resolution', this.safeValue2(currencyInfo, 'starkexResolution', 'l1Resolution'));
2497
+ const starkKey = this.safeString(account, 'l2Key');
2498
+ if ((positionId === undefined) || (collateralId === undefined) || (resolution === undefined) || (starkKey === undefined)) {
2499
+ throw new BadRequest(this.id + ' withdraw() requires currency starkexId/starkexResolution, account l2Vault and account l2Key');
2500
+ }
2501
+ const amount = this.getExtendedStarkAmount(amountString, resolution);
2502
+ const settlement = {
2503
+ 'recipient': recipient,
2504
+ 'positionId': positionId,
2505
+ 'collateralId': collateralId,
2506
+ 'amount': amount,
2507
+ 'expiration': {
2508
+ 'seconds': settlementExpiration,
2509
+ },
2510
+ 'salt': nonce,
2511
+ };
2512
+ const msgHash = this.getExtendedWithdrawalMsgHash(settlement, starkKey);
2513
+ const sig = JSON.parse(this.extendedStarknetSign(msgHash, this.privateKey));
2514
+ settlement['signature'] = {
2515
+ 'r': this.getExtendedSignatureHex(sig[0]),
2516
+ 's': this.getExtendedSignatureHex(sig[1]),
2517
+ };
2518
+ return settlement;
2519
+ }
2520
+ createTransferSettlementData(amountString, currency, account, toVault, toL2Key, params = {}) {
2521
+ const now = this.milliseconds();
2522
+ const settlementExpiration = this.safeInteger(params, 'settlementExpiration', this.parseToInt((now + 999) / 1000) + 1814400);
2523
+ const nonce = this.safeInteger(params, 'nonce', this.nonce());
2524
+ const fromVault = this.safeString2(params, 'fromVault', 'senderPositionId', this.safeString(account, 'l2Vault'));
2525
+ const fromL2Key = this.safeString2(params, 'fromL2Key', 'senderPublicKey', this.safeString(account, 'l2Key'));
2526
+ const currencyInfo = this.safeDict(currency, 'info', {});
2527
+ const collateralId = this.safeString2(params, 'assetId', 'collateralId', this.safeString2(currencyInfo, 'starkexId', 'l1Id'));
2528
+ const resolution = this.safeInteger(params, 'resolution', this.safeValue2(currencyInfo, 'starkexResolution', 'l1Resolution'));
2529
+ if ((fromVault === undefined) || (fromL2Key === undefined) || (collateralId === undefined) || (resolution === undefined)) {
2530
+ throw new BadRequest(this.id + ' transfer() requires currency starkexId/starkexResolution, account l2Vault and account l2Key');
2531
+ }
2532
+ const transferAmount = this.getExtendedStarkAmount(amountString, resolution);
2533
+ const settlement = {
2534
+ 'amount': transferAmount,
2535
+ 'assetId': collateralId,
2536
+ 'expirationTimestamp': settlementExpiration,
2537
+ 'nonce': nonce,
2538
+ 'receiverPositionId': toVault,
2539
+ 'receiverPublicKey': toL2Key,
2540
+ 'senderPositionId': fromVault,
2541
+ 'senderPublicKey': fromL2Key,
2542
+ };
2543
+ const msgHash = this.getExtendedTransferMsgHash(settlement);
2544
+ const sig = JSON.parse(this.extendedStarknetSign(msgHash, this.privateKey));
2545
+ settlement['signature'] = {
2546
+ 'r': this.getExtendedSignatureHex(sig[0]),
2547
+ 's': this.getExtendedSignatureHex(sig[1]),
2548
+ };
2549
+ return settlement;
2550
+ }
2551
+ async createExtendedOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
2552
+ await this.loadMarkets();
2553
+ const market = this.market(symbol);
2554
+ const uppercaseType = type.toUpperCase();
2555
+ const uppercaseSide = side.toUpperCase();
2556
+ if (market['spot'] && uppercaseType !== 'LIMIT') {
2557
+ throw new BadRequest(this.id + ' createOrder() supports limit orders for spot markets only');
2558
+ }
2559
+ if (!this.inArray(uppercaseType, ['LIMIT', 'MARKET', 'CONDITIONAL', 'TPSL'])) {
2560
+ throw new BadRequest(this.id + ' createOrder() supports limit, market, conditional and tpsl orders only');
2561
+ }
2562
+ if (price === undefined) {
2563
+ throw new ArgumentsRequired(this.id + ' createOrder() requires a price argument');
2564
+ }
2565
+ const amountString = this.amountToPrecision(symbol, amount);
2566
+ const priceString = this.priceToPrecision(symbol, price);
2567
+ const postOnly = this.isPostOnly(uppercaseType === 'MARKET', undefined, params);
2568
+ const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only', false);
2569
+ let timeInForce = this.safeStringUpper(params, 'timeInForce');
2570
+ if (timeInForce === undefined) {
2571
+ timeInForce = (uppercaseType === 'MARKET') ? 'IOC' : 'GTT';
2572
+ }
2573
+ const fee = this.safeString(params, 'fee', '0.0005');
2574
+ let builderFeeRate = undefined;
2575
+ let builderId = undefined;
2576
+ if (this.isSandboxModeEnabled) {
2577
+ builderFeeRate = this.safeString2(params, 'builderFeeRate', 'defaultBuilderFeeRate');
2578
+ builderId = this.safeString2(params, 'builderId', 'defaultBuilderId');
2579
+ params = this.omit(params, ['builderFeeRate', 'defaultBuilderFeeRate', 'builderId', 'defaultBuilderId']);
2580
+ }
2581
+ else {
2582
+ [builderFeeRate, params] = this.handleOptionAndParams(params, 'createOrder', 'builderFeeRate', '0.0001');
2583
+ [builderId, params] = this.handleOptionAndParams(params, 'createOrder', 'builderId');
2584
+ }
2585
+ let totalFee = fee;
2586
+ if (builderFeeRate !== undefined) {
2587
+ totalFee = Precise.stringAdd(fee, builderFeeRate);
2588
+ }
2589
+ const now = this.milliseconds();
2590
+ const expiryEpochMillis = this.safeInteger(params, 'expiryEpochMillis', now + 3600000);
2591
+ const settlementExpiration = this.safeInteger(params, 'settlementExpiration', this.parseToInt((expiryEpochMillis + 999) / 1000) + 1209600);
2592
+ const nonce = this.numberToString(this.nonce());
2593
+ const account = await this.fetchExtendedAccount();
2594
+ const starkKey = this.safeString(account, 'l2Key');
2595
+ const collateralPosition = this.safeString(account, 'l2Vault');
2596
+ const info = this.safeDict(market, 'info', {});
2597
+ const l2Config = this.safeDict(info, 'l2Config', {});
2598
+ const syntheticId = this.safeString(l2Config, 'syntheticId');
2599
+ const collateralId = this.safeString(l2Config, 'collateralId');
2600
+ const syntheticResolution = this.safeInteger(l2Config, 'syntheticResolution');
2601
+ const collateralResolution = this.safeInteger(l2Config, 'collateralResolution');
2602
+ if ((syntheticId === undefined) || (collateralId === undefined) || (syntheticResolution === undefined) || (collateralResolution === undefined)) {
2603
+ throw new BadRequest(this.id + ' createOrder() requires l2Config in market info');
2604
+ }
2605
+ const settlementParams = {
2606
+ 'totalFee': totalFee,
2607
+ 'starkKey': starkKey,
2608
+ 'syntheticId': syntheticId,
2609
+ 'syntheticResolution': syntheticResolution,
2610
+ 'collateralId': collateralId,
2611
+ 'collateralResolution': collateralResolution,
2612
+ 'settlementExpiration': settlementExpiration,
2613
+ 'nonce': nonce,
2614
+ 'collateralPosition': collateralPosition,
2615
+ };
2616
+ const isBuy = (uppercaseSide === 'BUY');
2617
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_id', this.uuid());
2618
+ const request = {
2619
+ 'id': clientOrderId,
2620
+ 'market': market['id'],
2621
+ 'type': uppercaseType,
2622
+ 'side': uppercaseSide,
2623
+ 'qty': amountString,
2624
+ 'price': priceString,
2625
+ 'timeInForce': timeInForce,
2626
+ 'expiryEpochMillis': expiryEpochMillis,
2627
+ 'fee': fee,
2628
+ 'nonce': nonce,
2629
+ 'postOnly': postOnly,
2630
+ 'reduceOnly': reduceOnly,
2631
+ 'selfTradeProtectionLevel': 'ACCOUNT',
2632
+ };
2633
+ if (builderFeeRate !== undefined) {
2634
+ request['builderFee'] = builderFeeRate;
2635
+ }
2636
+ if (builderId !== undefined) {
2637
+ request['builderId'] = builderId;
2638
+ }
2639
+ const cancelId = this.safeString2(params, 'cancelId', 'previousOrderId');
2640
+ if (cancelId !== undefined) {
2641
+ request['cancelId'] = cancelId;
2642
+ }
2643
+ const settlement = this.createOrderSettlementData(isBuy, amountString, priceString, settlementParams);
2644
+ request['settlement'] = {
2645
+ 'signature': { 'r': settlement['r'], 's': settlement['s'] },
2646
+ 'starkKey': starkKey,
2647
+ 'collateralPosition': collateralPosition,
2648
+ };
2649
+ let triggerPriceStr = this.safeString2(params, 'triggerPrice', 'stopPrice');
2650
+ const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
2651
+ const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
2652
+ const isStopLossOrder = stopLossTriggerPrice !== undefined;
2653
+ const isTakeProfitOrder = takeProfitTriggerPrice !== undefined;
2654
+ const stopLoss = this.safeDict(params, 'stopLoss');
2655
+ const takeProfit = this.safeDict(params, 'takeProfit');
2656
+ const hasStopLoss = (stopLoss !== undefined);
2657
+ const hasTakeProfit = (takeProfit !== undefined);
2658
+ if (hasStopLoss || hasTakeProfit) {
2659
+ request['tpSlType'] = 'ORDER';
2660
+ if (hasStopLoss) {
2661
+ const stopLossTrigger = this.safeString(stopLoss, 'triggerPrice');
2662
+ const stopLossTriggerPriceType = this.safeString(stopLoss, 'triggerPriceType');
2663
+ const stopLossExecutionPrice = this.safeString(stopLoss, 'price');
2664
+ const stopLossType = this.safeString(stopLoss, 'type');
2665
+ const stopLossSettlement = this.createOrderSettlementData(!isBuy, amountString, stopLossExecutionPrice, settlementParams);
2666
+ const requestStopLoss = {
2667
+ 'triggerPrice': this.priceToPrecision(symbol, stopLossTrigger),
2668
+ 'price': this.priceToPrecision(symbol, stopLossExecutionPrice),
2669
+ 'settlement': {
2670
+ 'signature': { 'r': stopLossSettlement['r'], 's': stopLossSettlement['s'] },
2671
+ 'starkKey': starkKey,
2672
+ 'collateralPosition': collateralPosition,
2673
+ },
2674
+ };
2675
+ if (stopLossTriggerPriceType !== undefined) {
2676
+ requestStopLoss['triggerPriceType'] = stopLossTriggerPriceType;
2677
+ }
2678
+ if (stopLossType !== undefined) {
2679
+ requestStopLoss['priceType'] = stopLossType;
2680
+ }
2681
+ request['stopLoss'] = requestStopLoss;
2682
+ }
2683
+ if (hasTakeProfit) {
2684
+ const takeProfitTrigger = this.safeString(takeProfit, 'triggerPrice');
2685
+ const takeProfitTriggerPriceType = this.safeString(takeProfit, 'triggerPriceType');
2686
+ const takeProfitExecutionPrice = this.safeString(takeProfit, 'price');
2687
+ const takeProfitType = this.safeString(takeProfit, 'type');
2688
+ const takeProfitSettlement = this.createOrderSettlementData(!isBuy, amountString, takeProfitExecutionPrice, settlementParams);
2689
+ const requestTakeProfit = {
2690
+ 'triggerPrice': this.priceToPrecision(symbol, takeProfitTrigger),
2691
+ 'price': this.priceToPrecision(symbol, takeProfitExecutionPrice),
2692
+ 'settlement': {
2693
+ 'signature': { 'r': takeProfitSettlement['r'], 's': takeProfitSettlement['s'] },
2694
+ 'starkKey': starkKey,
2695
+ 'collateralPosition': collateralPosition,
2696
+ },
2697
+ };
2698
+ if (takeProfitTriggerPriceType !== undefined) {
2699
+ requestTakeProfit['triggerPriceType'] = takeProfitTriggerPriceType;
2700
+ }
2701
+ if (takeProfitType !== undefined) {
2702
+ requestTakeProfit['priceType'] = takeProfitType;
2703
+ }
2704
+ request['takeProfit'] = requestTakeProfit;
2705
+ }
2706
+ }
2707
+ else {
2708
+ if (triggerPriceStr !== undefined) {
2709
+ const triggerDirection = this.safeStringUpper(params, 'triggerDirection');
2710
+ if (triggerDirection === undefined) {
2711
+ throw new ArgumentsRequired(this.id + ' createOrder() requires triggerDirection for trigger order');
2712
+ }
2713
+ const trigger = {
2714
+ 'triggerPrice': this.priceToPrecision(symbol, triggerPriceStr),
2715
+ };
2716
+ trigger['direction'] = triggerDirection;
2717
+ request['type'] = 'CONDITIONAL';
2718
+ request['trigger'] = trigger;
2719
+ }
2720
+ else if (isStopLossOrder || isTakeProfitOrder) {
2721
+ triggerPriceStr = isStopLossOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
2722
+ const trigger = {
2723
+ 'triggerPrice': this.priceToPrecision(symbol, triggerPriceStr),
2724
+ };
2725
+ if (isBuy) {
2726
+ trigger['direction'] = isStopLossOrder ? 'UP' : 'DOWN';
2727
+ }
2728
+ else {
2729
+ trigger['direction'] = isStopLossOrder ? 'DOWN' : 'UP';
2730
+ }
2731
+ request['type'] = 'CONDITIONAL';
2732
+ request['trigger'] = trigger;
2733
+ }
2734
+ }
2735
+ params = this.omit(params, ['clientOrderId', 'client_id', 'timeInForce', 'postOnly', 'reduceOnly', 'reduce_only', 'fee', 'nonce', 'expiryEpochMillis', 'settlementExpiration', 'cancelId', 'previousOrderId', 'brokerId', 'referralCode', 'triggerPrice', 'stopPrice', 'triggerDirection', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit']);
2736
+ return {
2737
+ 'request': this.extend(request, params),
2738
+ 'market': market,
2739
+ 'timestamp': now,
2740
+ 'clientOrderId': clientOrderId,
2741
+ 'price': priceString,
2742
+ 'amount': amountString,
2743
+ };
2744
+ }
2745
+ /**
2746
+ * @method
2747
+ * @name extended#createOrder
2748
+ * @description create a trade order
2749
+ * @see https://api.docs.extended.exchange/#create-or-edit-order
2750
+ * @param {string} symbol unified symbol of the market to create an order in
2751
+ * @param {string} type 'limit' or 'market'
2752
+ * @param {string} side 'buy' or 'sell'
2753
+ * @param {float} amount how much of currency you want to trade in units of base currency
2754
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, required for all order types
2755
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2756
+ * @param {string} [params.clientOrderId] client order id, sent as the exchange order id
2757
+ * @param {string} [params.cancelId] previous external order id to replace
2758
+ * @param {string} [params.timeInForce] 'GTT' or 'IOC'
2759
+ * @param {boolean} [params.postOnly] true if the order should only make liquidity
2760
+ * @param {boolean} [params.reduceOnly] true if the order should only reduce a position
2761
+ * @param {string} [params.fee] max fee rate for the order, default is 0.0005
2762
+ * @param {int} [params.expiryEpochMillis] order expiration timestamp in milliseconds, default is now + 1 hour
2763
+ * @param {float} [params.triggerPrice] *swap only* The price at which a trigger order is triggered at
2764
+ * @param {float} [params.stopLossPrice] *swap only* The price at which a stop loss order is triggered at
2765
+ * @param {float} [params.takeProfitPrice] *swap only* The price at which a take profit order is triggered at
2766
+ * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
2767
+ * @param {float} [params.takeProfit.triggerPrice] *swap only* take profit trigger price
2768
+ * @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
2769
+ * @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'LAST', 'MARK' or 'INDEX', default is ''
2770
+ * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
2771
+ * @param {float} [params.stopLoss.triggerPrice] *swap only* stop loss trigger price
2772
+ * @param {float} [params.stopLoss.price] *swap only* the execution price for a stop loss attached to a trigger order
2773
+ * @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'LAST', 'MARK' or 'INDEX', default is ''
2774
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2775
+ */
2776
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2777
+ this.checkRequiredCredentials();
2778
+ const extendedOrderRequest = await this.createExtendedOrderRequest(symbol, type, side, amount, price, params);
2779
+ const request = this.safeDict(extendedOrderRequest, 'request', {});
2780
+ const response = await this.v1PrivatePostUserOrder(request);
2781
+ //
2782
+ // {
2783
+ // "status": "OK",
2784
+ // "data": {
2785
+ // "id": "2051479786538188800",
2786
+ // "externalId": "3480985089570526249141260266819446928410958787024864860785196119336740291620"
2787
+ // }
2788
+ // }
2789
+ //
2790
+ const data = this.safeDict(response, 'data', {});
2791
+ const market = extendedOrderRequest['market'];
2792
+ const now = this.safeInteger(extendedOrderRequest, 'timestamp');
2793
+ data['timestamp'] = now;
2794
+ data['status'] = 'NEW';
2795
+ return this.parseOrder(this.extend(request, data), market);
2796
+ }
2797
+ /**
2798
+ * @method
2799
+ * @name extended#editOrder
2800
+ * @description edit a trade order
2801
+ * @see https://api.docs.extended.exchange/#create-or-edit-order
2802
+ * @param {string} id order id assigned by Extended
2803
+ * @param {string} symbol unified symbol of the market to edit an order in
2804
+ * @param {string} type 'limit' or 'market'
2805
+ * @param {string} side 'buy' or 'sell'
2806
+ * @param {float} [amount] how much of currency you want to trade in units of base currency
2807
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency
2808
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2809
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2810
+ */
2811
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
2812
+ if (id === undefined) {
2813
+ throw new ArgumentsRequired(this.id + ' editOrder() requires an id argument');
2814
+ }
2815
+ let expiryEpochMillis = this.safeInteger(params, 'expiryEpochMillis');
2816
+ let postOnly = this.safeBool(params, 'postOnly');
2817
+ let reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only');
2818
+ let cancelId = this.safeString2(params, 'cancelId', 'previousOrderId');
2819
+ if ((amount === undefined) || (price === undefined) || (expiryEpochMillis === undefined) || (postOnly === undefined) || (reduceOnly === undefined) || (cancelId === undefined)) {
2820
+ const response = await this.v1PrivateGetUserOrdersId({ 'id': id });
2821
+ const order = this.safeDict(response, 'data', {});
2822
+ if (amount === undefined) {
2823
+ amount = this.safeNumber(order, 'qty');
2824
+ }
2825
+ if (price === undefined) {
2826
+ price = this.safeNumber(order, 'price');
2827
+ }
2828
+ if (expiryEpochMillis === undefined) {
2829
+ expiryEpochMillis = this.safeInteger(order, 'expireTime');
2830
+ }
2831
+ if (postOnly === undefined) {
2832
+ postOnly = this.safeBool(order, 'postOnly', false);
2833
+ }
2834
+ if (reduceOnly === undefined) {
2835
+ reduceOnly = this.safeBool(order, 'reduceOnly', false);
2836
+ }
2837
+ if (cancelId === undefined) {
2838
+ cancelId = this.safeString(order, 'externalId');
2839
+ }
2840
+ }
2841
+ if (amount === undefined) {
2842
+ throw new ArgumentsRequired(this.id + ' editOrder() requires an amount argument or an existing order with qty');
2843
+ }
2844
+ if (price === undefined) {
2845
+ throw new ArgumentsRequired(this.id + ' editOrder() requires a price argument or an existing order with price');
2846
+ }
2847
+ params = this.extend({
2848
+ 'postOnly': postOnly,
2849
+ 'reduceOnly': reduceOnly,
2850
+ }, params);
2851
+ const requestParams = this.extend(params, {
2852
+ 'cancelId': cancelId,
2853
+ 'expiryEpochMillis': expiryEpochMillis,
2854
+ });
2855
+ const extendedOrderRequest = await this.createExtendedOrderRequest(symbol, type, side, amount, price, requestParams);
2856
+ const request = this.safeDict(extendedOrderRequest, 'request', {});
2857
+ const editResponse = await this.v1PrivatePostUserOrder(request);
2858
+ //
2859
+ // {
2860
+ // "status": "OK",
2861
+ // "data": {
2862
+ // "id": "2051479786538188800",
2863
+ // "externalId": "3480985089570526249141260266819446928410958787024864860785196119336740291620"
2864
+ // }
2865
+ // }
2866
+ //
2867
+ const responseData = this.safeDict(editResponse, 'data', {});
2868
+ const market = extendedOrderRequest['market'];
2869
+ const now = this.safeInteger(extendedOrderRequest, 'timestamp');
2870
+ responseData['timestamp'] = now;
2871
+ responseData['status'] = 'NEW';
2872
+ return this.parseOrder(this.extend(request, responseData), market);
2873
+ }
2874
+ /**
2875
+ * @method
2876
+ * @name extended#cancelOrder
2877
+ * @description cancels an open order
2878
+ * @see https://api.docs.extended.exchange/#cancel-order-by-id
2879
+ * @see https://api.docs.extended.exchange/#cancel-order-by-external-id
2880
+ * @param {string} id order id assigned by Extended
2881
+ * @param {string} [symbol] unified symbol of the market the order was made in
2882
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2883
+ * @param {string} [params.clientOrderId] user-defined order id, cancels by external id
2884
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2885
+ */
2886
+ async cancelOrder(id, symbol = undefined, params = {}) {
2887
+ await this.loadMarkets();
2888
+ let market = undefined;
2889
+ if (symbol !== undefined) {
2890
+ market = this.market(symbol);
2891
+ }
2892
+ let response = undefined;
2893
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_id');
2894
+ params = this.omit(params, ['clientOrderId', 'client_id']);
2895
+ if (clientOrderId !== undefined) {
2896
+ const request = {
2897
+ 'externalId': clientOrderId,
2898
+ };
2899
+ response = await this.v1PrivateDeleteUserOrder(this.extend(request, params));
2900
+ }
2901
+ else {
2902
+ if (id === undefined) {
2903
+ throw new ArgumentsRequired(this.id + ' cancelOrder() requires an id argument');
2904
+ }
2905
+ const request = {
2906
+ 'id': id,
2907
+ };
2908
+ response = await this.v1PrivateDeleteUserOrderId(this.extend(request, params));
2909
+ }
2910
+ //
2911
+ // {
2912
+ // "status": "OK"
2913
+ // }
2914
+ //
2915
+ const orderId = (clientOrderId === undefined) ? id : undefined;
2916
+ const orderSymbol = (market === undefined) ? symbol : market['symbol'];
2917
+ return this.safeOrder({
2918
+ 'info': response,
2919
+ 'id': orderId,
2920
+ 'clientOrderId': clientOrderId,
2921
+ 'timestamp': undefined,
2922
+ 'datetime': undefined,
2923
+ 'symbol': orderSymbol,
2924
+ 'status': 'canceled',
2925
+ }, market);
2926
+ }
2927
+ /**
2928
+ * @method
2929
+ * @name extended#cancelOrders
2930
+ * @description cancel multiple orders by order ids or client order ids
2931
+ * @see https://api.docs.extended.exchange/#mass-cancel
2932
+ * @param {string[]} ids order ids
2933
+ * @param {string} [symbol] unified market symbol, only used to populate the returned orders
2934
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2935
+ * @param {string[]} [params.clientOrderIds] client order ids
2936
+ * @param {string} [params.clientOrderId] single client order id
2937
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2938
+ */
2939
+ async cancelOrders(ids, symbol = undefined, params = {}) {
2940
+ await this.loadMarkets();
2941
+ let clientOrderIds = this.safeListN(params, ['clientOrderIds', 'client_order_ids', 'externalOrderIds', 'external_order_ids']);
2942
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_id');
2943
+ params = this.omit(params, ['clientOrderIds', 'client_order_ids', 'clientOrderId', 'client_id', 'externalOrderIds', 'external_order_ids', 'orderIds', 'order_ids', 'markets', 'cancelAll', 'cancel_all']);
2944
+ const request = {};
2945
+ const hasOrderIds = ids !== undefined;
2946
+ if (hasOrderIds) {
2947
+ const idsLength = ids.length;
2948
+ if (idsLength > 0) {
2949
+ request['orderIds'] = ids;
2950
+ }
2951
+ }
2952
+ if (clientOrderIds === undefined && clientOrderId !== undefined) {
2953
+ clientOrderIds = [clientOrderId];
2954
+ }
2955
+ const hasClientOrderIds = clientOrderIds !== undefined;
2956
+ if (hasClientOrderIds) {
2957
+ const clientOrderIdsLength = clientOrderIds.length;
2958
+ if (clientOrderIdsLength > 0) {
2959
+ request['externalOrderIds'] = clientOrderIds;
2960
+ }
2961
+ }
2962
+ if (!hasOrderIds && !hasClientOrderIds) {
2963
+ throw new ArgumentsRequired(this.id + ' cancelOrders() requires an ids argument or clientOrderIds parameter');
2964
+ }
2965
+ await this.v1PrivatePostUserOrderMassCancel(this.extend(request, params));
2966
+ //
2967
+ // {
2968
+ // "status": "OK",
2969
+ // "data": {}
2970
+ // }
2971
+ //
2972
+ return [];
2973
+ }
2974
+ /**
2975
+ * @method
2976
+ * @name extended#cancelAllOrders
2977
+ * @description cancels all open orders, optionally filtered by symbol
2978
+ * @see https://api.docs.extended.exchange/#mass-cancel
2979
+ * @param {string} [symbol] unified market symbol of the market to cancel orders in
2980
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2981
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2982
+ */
2983
+ async cancelAllOrders(symbol = undefined, params = {}) {
2984
+ await this.loadMarkets();
2985
+ const request = {
2986
+ 'cancelAll': true,
2987
+ };
2988
+ let market = undefined;
2989
+ if (symbol !== undefined) {
2990
+ market = this.market(symbol);
2991
+ request['markets'] = [market['id']];
2992
+ }
2993
+ await this.v1PrivatePostUserOrderMassCancel(this.extend(request, params));
2994
+ //
2995
+ // {
2996
+ // "status": "OK",
2997
+ // "data": {}
2998
+ // }
2999
+ //
3000
+ return [];
3001
+ }
3002
+ /**
3003
+ * @method
3004
+ * @name extended#cancelAllOrdersAfter
3005
+ * @description dead man's switch, cancel all orders after the given timeout
3006
+ * @see https://api.docs.extended.exchange/#mass-auto-cancel-dead-man-39-s-switch
3007
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
3008
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3009
+ * @returns {object} the api result
3010
+ */
3011
+ async cancelAllOrdersAfter(timeout, params = {}) {
3012
+ await this.loadMarkets();
3013
+ const request = {
3014
+ 'countdownTime': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
3015
+ };
3016
+ return await this.v1PrivatePostUserDeadmanswitch(this.extend(request, params));
3017
+ }
3018
+ /**
3019
+ * @method
3020
+ * @name extended#fetchOrder
3021
+ * @description fetches information on an order made by the user
3022
+ * @see https://api.docs.extended.exchange/#get-order-by-id
3023
+ * @see https://api.docs.extended.exchange/#get-orders-by-external-id
3024
+ * @param {string} id order id assigned by Extended
3025
+ * @param {string} [symbol] unified symbol of the market the order was made in
3026
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3027
+ * @param {string} [params.clientOrderId] user-defined order id, fetches by external id
3028
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3029
+ */
3030
+ async fetchOrder(id, symbol = undefined, params = {}) {
3031
+ await this.loadMarkets();
3032
+ let market = undefined;
3033
+ if (symbol !== undefined) {
3034
+ market = this.market(symbol);
3035
+ }
3036
+ let response = undefined;
3037
+ let order = undefined;
3038
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_id');
3039
+ params = this.omit(params, ['clientOrderId', 'client_id']);
3040
+ if (clientOrderId !== undefined) {
3041
+ const request = {
3042
+ 'externalId': clientOrderId,
3043
+ };
3044
+ response = await this.v1PrivateGetUserOrdersExternalExternalId(this.extend(request, params));
3045
+ const data = this.safeList(response, 'data', []);
3046
+ order = this.safeDict(data, 0, {});
3047
+ }
3048
+ else {
3049
+ if (id === undefined) {
3050
+ throw new ArgumentsRequired(this.id + ' fetchOrder() requires an id argument');
3051
+ }
3052
+ const request = {
3053
+ 'id': id,
3054
+ };
3055
+ response = await this.v1PrivateGetUserOrdersId(this.extend(request, params));
3056
+ order = this.safeDict(response, 'data', {});
3057
+ }
3058
+ return this.parseOrder(order, market);
3059
+ }
3060
+ /**
3061
+ * @method
3062
+ * @name extended#fetchOpenOrders
3063
+ * @description fetch all unfilled currently open orders
3064
+ * @see https://api.docs.extended.exchange/#get-open-orders
3065
+ * @param {string} [symbol] unified market symbol of the orders
3066
+ * @param {int} [since] the earliest time in ms to fetch orders for
3067
+ * @param {int} [limit] the maximum number of open order structures to retrieve
3068
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3069
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3070
+ */
3071
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3072
+ await this.loadMarkets();
3073
+ let market = undefined;
3074
+ const request = {};
3075
+ if (symbol !== undefined) {
3076
+ market = this.market(symbol);
3077
+ request['market'] = market['id'];
3078
+ }
3079
+ const response = await this.v1PrivateGetUserOrders(this.extend(request, params));
3080
+ //
3081
+ // {
3082
+ // "status": "OK",
3083
+ // "data": [
3084
+ // {
3085
+ // "id": 1775511783722512384,
3086
+ // "accountId": 3017,
3087
+ // "externalId": "2554612759479898620327573136214120486511160383028978112799136270841501275076",
3088
+ // "market": "ETH-USD",
3089
+ // "type": "LIMIT",
3090
+ // "side": "BUY",
3091
+ // "status": "PARTIALLY_FILLED",
3092
+ // "price": "3300",
3093
+ // "averagePrice": "3297.00",
3094
+ // "qty": "0.2",
3095
+ // "filledQty": "0.1",
3096
+ // "payedFee": "0.0120000000000000",
3097
+ // "reduceOnly": false,
3098
+ // "postOnly": false,
3099
+ // "createdTime": 1701563440000,
3100
+ // "updatedTime": 1701563440000,
3101
+ // "timeInForce": "IOC",
3102
+ // "expireTime": 1712754771819
3103
+ // }
3104
+ // ]
3105
+ // }
3106
+ //
3107
+ const data = this.safeList(response, 'data', []);
3108
+ const orders = this.parseOrders(data, market, since, limit);
3109
+ return this.filterBySymbolSinceLimit(orders, symbol, since, limit);
3110
+ }
3111
+ /**
3112
+ * @method
3113
+ * @name extended#fetchOrders
3114
+ * @description fetches information on multiple orders made by the user
3115
+ * @see https://api.docs.extended.exchange/#get-orders-history
3116
+ * @param {string} [symbol] unified market symbol of the orders
3117
+ * @param {int} [since] the earliest time in ms to fetch orders for
3118
+ * @param {int} [limit] the maximum number of order structures to retrieve
3119
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3120
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3121
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3122
+ */
3123
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3124
+ await this.loadMarkets();
3125
+ let paginate = false;
3126
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
3127
+ if (paginate) {
3128
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
3129
+ }
3130
+ let market = undefined;
3131
+ const request = {};
3132
+ if (symbol !== undefined) {
3133
+ market = this.market(symbol);
3134
+ request['market'] = market['id'];
3135
+ }
3136
+ if (limit !== undefined) {
3137
+ request['limit'] = limit;
3138
+ }
3139
+ const response = await this.v1PrivateGetUserOrdersHistory(this.extend(params, request));
3140
+ //
3141
+ // {
3142
+ // "status": "OK",
3143
+ // "data": [
3144
+ // {
3145
+ // "id": 1784963886257016832,
3146
+ // "externalId": "ExtId-1",
3147
+ // "accountId": 1,
3148
+ // "market": "BTC-USD",
3149
+ // "status": "FILLED",
3150
+ // "type": "LIMIT",
3151
+ // "side": "BUY",
3152
+ // "price": "39000",
3153
+ // "averagePrice": "39000",
3154
+ // "qty": "0.2",
3155
+ // "filledQty": "0.1",
3156
+ // "payedFee": "0.0120000000000000",
3157
+ // "reduceOnly": false,
3158
+ // "postOnly": false,
3159
+ // "createdTime": 1701563440000,
3160
+ // "updatedTime": 1701563440000,
3161
+ // "timeInForce": "IOC",
3162
+ // "expireTime": 1706563440
3163
+ // }
3164
+ // ],
3165
+ // "pagination": {
3166
+ // "cursor": 1784963886257016832,
3167
+ // "count": 1
3168
+ // }
3169
+ // }
3170
+ //
3171
+ const data = this.safeList(response, 'data', []);
3172
+ const pagination = this.safeDict(response, 'pagination', {});
3173
+ const cursor = this.safeString(pagination, 'cursor');
3174
+ const result = [];
3175
+ const dataLength = data.length;
3176
+ for (let i = 0; i < dataLength; i++) {
3177
+ let entry = data[i];
3178
+ if ((cursor !== undefined) && (i === dataLength - 1)) {
3179
+ entry = this.extend(entry, { 'cursor': cursor });
3180
+ }
3181
+ result.push(entry);
3182
+ }
3183
+ const orders = this.parseOrders(result, market, since, limit);
3184
+ return this.filterBySymbolSinceLimit(orders, symbol, since, limit);
3185
+ }
3186
+ /**
3187
+ * @method
3188
+ * @name extended#fetchClosedOrders
3189
+ * @description fetches information on multiple closed orders made by the user
3190
+ * @see https://api.docs.extended.exchange/#get-orders-history
3191
+ * @param {string} [symbol] unified market symbol of the orders
3192
+ * @param {int} [since] the earliest time in ms to fetch orders for
3193
+ * @param {int} [limit] the maximum number of order structures to retrieve
3194
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3195
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3196
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3197
+ */
3198
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3199
+ const orders = await this.fetchOrders(symbol, since, undefined, params);
3200
+ const closedOrders = this.filterBy(orders, 'status', 'closed');
3201
+ return this.filterBySymbolSinceLimit(closedOrders, symbol, since, limit);
3202
+ }
3203
+ /**
3204
+ * @method
3205
+ * @name extended#fetchCanceledOrders
3206
+ * @description fetches information on multiple canceled orders made by the user
3207
+ * @see https://api.docs.extended.exchange/#get-orders-history
3208
+ * @param {string} [symbol] unified market symbol of the orders
3209
+ * @param {int} [since] the earliest time in ms to fetch orders for
3210
+ * @param {int} [limit] the maximum number of order structures to retrieve
3211
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3212
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3213
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3214
+ */
3215
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3216
+ const orders = await this.fetchOrders(symbol, since, undefined, params);
3217
+ const canceledOrders = this.filterBy(orders, 'status', 'canceled');
3218
+ return this.filterBySymbolSinceLimit(canceledOrders, symbol, since, limit);
3219
+ }
3220
+ parseOrderStatus(status) {
3221
+ const statuses = {
3222
+ 'NEW': 'open',
3223
+ 'PARTIALLY_FILLED': 'open',
3224
+ 'UNTRIGGERED': 'open',
3225
+ 'TRIGGERED': 'open',
3226
+ 'FILLED': 'closed',
3227
+ 'CANCELLED': 'canceled',
3228
+ 'REJECTED': 'rejected',
3229
+ 'EXPIRED': 'expired',
3230
+ };
3231
+ return this.safeString(statuses, status, status);
3232
+ }
3233
+ parseOrder(order, market = undefined) {
3234
+ //
3235
+ // {
3236
+ // "id": 1784963886257016832,
3237
+ // "externalId": "ExtId-1",
3238
+ // "accountId": 1,
3239
+ // "market": "BTC-USD",
3240
+ // "status": "FILLED",
3241
+ // "type": "LIMIT",
3242
+ // "side": "BUY",
3243
+ // "price": "39000",
3244
+ // "averagePrice": "39000",
3245
+ // "qty": "0.2",
3246
+ // "filledQty": "0.1",
3247
+ // "payedFee": "0.0120000000000000",
3248
+ // "reduceOnly": false,
3249
+ // "postOnly": false,
3250
+ // "trigger": {
3251
+ // "triggerPrice": "34000",
3252
+ // "triggerPriceType": "LAST",
3253
+ // "triggerPriceDirection": "UP",
3254
+ // "executionPriceType": "MARKET"
3255
+ // },
3256
+ // "takeProfit": {
3257
+ // "triggerPrice": "34000",
3258
+ // "triggerPriceType": "LAST",
3259
+ // "price": "35000",
3260
+ // "priceType": "MARKET"
3261
+ // },
3262
+ // "stopLoss": {
3263
+ // "triggerPrice": "34000",
3264
+ // "triggerPriceType": "LAST",
3265
+ // "price": "35000",
3266
+ // "priceType": "MARKET"
3267
+ // },
3268
+ // "createdTime": 1701563440000,
3269
+ // "updatedTime": 1701563440000,
3270
+ // "timeInForce": "IOC",
3271
+ // "expireTime": 1706563440
3272
+ // }
3273
+ //
3274
+ const marketId = this.safeString(order, 'market');
3275
+ market = this.safeMarket(marketId, market);
3276
+ const timestamp = this.safeInteger2(order, 'createdTime', 'timestamp');
3277
+ const lastUpdateTimestamp = this.safeInteger(order, 'updatedTime');
3278
+ const status = this.parseOrderStatus(this.safeString(order, 'status'));
3279
+ const side = this.safeStringLower(order, 'side');
3280
+ const type = this.safeStringLower(order, 'type');
3281
+ const amount = this.safeString(order, 'qty');
3282
+ const filled = this.safeString(order, 'filledQty');
3283
+ const feeCost = this.safeString(order, 'payedFee');
3284
+ const trigger = this.safeDict(order, 'trigger', {});
3285
+ const takeProfit = this.safeDict(order, 'takeProfit', {});
3286
+ const stopLoss = this.safeDict(order, 'stopLoss', {});
3287
+ const fee = {
3288
+ 'cost': feeCost,
3289
+ 'currency': (market === undefined) ? undefined : market['settle'],
3290
+ };
3291
+ return this.safeOrder({
3292
+ 'info': order,
3293
+ 'id': this.safeString(order, 'id'),
3294
+ 'clientOrderId': this.safeString(order, 'externalId'),
3295
+ 'timestamp': timestamp,
3296
+ 'datetime': this.iso8601(timestamp),
3297
+ 'lastTradeTimestamp': undefined,
3298
+ 'lastUpdateTimestamp': lastUpdateTimestamp,
3299
+ 'symbol': market['symbol'],
3300
+ 'type': type,
3301
+ 'timeInForce': this.safeString(order, 'timeInForce'),
3302
+ 'postOnly': this.safeBool(order, 'postOnly'),
3303
+ 'reduceOnly': this.safeBool(order, 'reduceOnly'),
3304
+ 'side': side,
3305
+ 'price': this.safeString(order, 'price'),
3306
+ 'triggerPrice': this.safeString(trigger, 'triggerPrice'),
3307
+ 'takeProfitPrice': this.safeString(takeProfit, 'triggerPrice'),
3308
+ 'stopLossPrice': this.safeString(stopLoss, 'triggerPrice'),
3309
+ 'amount': amount,
3310
+ 'cost': undefined,
3311
+ 'average': this.safeString(order, 'averagePrice'),
3312
+ 'filled': filled,
3313
+ 'remaining': undefined,
3314
+ 'status': status,
3315
+ 'fee': fee,
3316
+ 'trades': undefined,
3317
+ }, market);
3318
+ }
3319
+ getExtendedStringToFelt(value) {
3320
+ return this.convertToBigInt(this.stringToBase16(value));
3321
+ }
3322
+ getExtendedEncodeI64(value) {
3323
+ // Cairo prime offset for i64 negative encoding.
3324
+ const prime = '3618502788666131213697322783095070105623107215331596699973092056135872020481';
3325
+ const valueString = this.numberToString(value);
3326
+ if (Precise.stringLt(valueString, '0')) {
3327
+ return Precise.stringAdd(prime, valueString);
3328
+ }
3329
+ return value;
3330
+ }
3331
+ getExtendedDecimalToBase16(value) {
3332
+ let decimalString = '';
3333
+ if (typeof value === 'string') {
3334
+ decimalString = value;
3335
+ }
3336
+ else {
3337
+ decimalString = this.numberToString(value);
3338
+ }
3339
+ const hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
3340
+ let result = '';
3341
+ while (Precise.stringGt(decimalString, '0')) {
3342
+ const remainder = this.parseToInt(Precise.stringMod(decimalString, '16'));
3343
+ result = hexChars[remainder] + result;
3344
+ decimalString = Precise.stringDiv(decimalString, '16', 0);
3345
+ }
3346
+ if (result === '') {
3347
+ return '0';
3348
+ }
3349
+ return result;
3350
+ }
3351
+ getExtendedSignatureHex(signature) {
3352
+ if (typeof signature === 'string') {
3353
+ if (signature.indexOf('0x') === 0) {
3354
+ return signature;
3355
+ }
3356
+ return '0x' + this.getExtendedDecimalToBase16(signature);
3357
+ }
3358
+ const signatureString = this.numberToString(signature);
3359
+ if (signatureString.indexOf('0x') === 0) {
3360
+ return signatureString;
3361
+ }
3362
+ return '0x' + this.getExtendedDecimalToBase16(signatureString);
3363
+ }
3364
+ getExtendedDomainHash() {
3365
+ const domainTypeHash = this.convertToBigInt(this.extendedStarknetGetSelectorFromName('"StarknetDomain"("name":"shortstring","version":"shortstring","chainId":"shortstring","revision":"shortstring")'));
3366
+ const isTestnet = this.urls['api']['rest'].indexOf('sepolia') >= 0;
3367
+ const defaultChainId = isTestnet ? 'SN_SEPOLIA' : 'SN_MAIN';
3368
+ const chainId = this.safeString(this.options, 'chainId', defaultChainId);
3369
+ return this.convertToBigInt(this.extendedStarknetComputePoseidonHashOnElements([
3370
+ domainTypeHash,
3371
+ this.getExtendedStringToFelt('Perpetuals'),
3372
+ this.getExtendedStringToFelt('v0'),
3373
+ this.getExtendedStringToFelt(chainId),
3374
+ this.convertToBigInt('1'),
3375
+ ]));
3376
+ }
3377
+ getExtendedOrderMsgHash(settlement) {
3378
+ const orderTypeHash = this.convertToBigInt(this.extendedStarknetGetSelectorFromName('"Order"("position_id":"felt","base_asset_id":"AssetId","base_amount":"i64","quote_asset_id":"AssetId","quote_amount":"i64","fee_asset_id":"AssetId","fee_amount":"u64","expiration":"Timestamp","salt":"felt")"PositionId"("value":"u32")"AssetId"("value":"felt")"Timestamp"("seconds":"u64")'));
3379
+ const domainHash = this.getExtendedDomainHash();
3380
+ // Order fields
3381
+ const positionId = this.convertToBigInt(this.safeString(settlement, 'collateralPosition'));
3382
+ const baseAssetId = this.safeString(settlement, 'baseAssetId');
3383
+ const baseAmount = this.convertToBigInt(this.safeString(settlement, 'baseAmount'));
3384
+ const quoteAssetId = this.safeString(settlement, 'quoteAssetId');
3385
+ const quoteAmount = this.convertToBigInt(this.safeString(settlement, 'quoteAmount'));
3386
+ const feeAssetId = this.safeString(settlement, 'feeAssetId');
3387
+ const feeAmount = this.convertToBigInt(this.safeString(settlement, 'feeAmount'));
3388
+ const expiration = this.convertToBigInt(this.safeString2(settlement, 'expiration', 'expirationTimestamp'));
3389
+ const salt = this.convertToBigInt(this.safeString2(settlement, 'salt', 'nonce'));
3390
+ const starkKey = this.convertToBigInt(this.safeString(settlement, 'starkKey'));
3391
+ // Order struct hash
3392
+ const orderHash = this.convertToBigInt(this.extendedStarknetComputePoseidonHashOnElements([
3393
+ orderTypeHash,
3394
+ positionId,
3395
+ this.convertToBigInt(baseAssetId),
3396
+ this.getExtendedEncodeI64(baseAmount),
3397
+ this.convertToBigInt(quoteAssetId),
3398
+ this.getExtendedEncodeI64(quoteAmount),
3399
+ this.convertToBigInt(feeAssetId),
3400
+ feeAmount,
3401
+ expiration,
3402
+ salt,
3403
+ ]));
3404
+ // SNIP-12 final message hash: poseidon('StarkNet Message', domainHash, starkKey, orderHash)
3405
+ return this.extendedStarknetComputePoseidonHashOnElements([
3406
+ this.getExtendedStringToFelt('StarkNet Message'),
3407
+ domainHash,
3408
+ starkKey,
3409
+ orderHash,
3410
+ ]);
3411
+ }
3412
+ getExtendedWithdrawalMsgHash(settlement, starkKey) {
3413
+ const withdrawalTypeHash = this.convertToBigInt(this.extendedStarknetGetSelectorFromName('"Withdrawal"("recipient":"felt","position_id":"PositionId","collateral_id":"AssetId","amount":"u64","expiration":"Timestamp","salt":"felt")"PositionId"("value":"u32")"AssetId"("value":"felt")"Timestamp"("seconds":"u64")'));
3414
+ const domainHash = this.getExtendedDomainHash();
3415
+ const expiration = this.safeDict(settlement, 'expiration', {});
3416
+ const withdrawalHash = this.convertToBigInt(this.extendedStarknetComputePoseidonHashOnElements([
3417
+ withdrawalTypeHash,
3418
+ this.convertToBigInt(this.safeString(settlement, 'recipient')),
3419
+ this.convertToBigInt(this.safeString(settlement, 'positionId')),
3420
+ this.convertToBigInt(this.safeString(settlement, 'collateralId')),
3421
+ this.convertToBigInt(this.safeString(settlement, 'amount')),
3422
+ this.convertToBigInt(this.safeString(expiration, 'seconds')),
3423
+ this.convertToBigInt(this.safeString(settlement, 'salt')),
3424
+ ]));
3425
+ return this.extendedStarknetComputePoseidonHashOnElements([
3426
+ this.getExtendedStringToFelt('StarkNet Message'),
3427
+ domainHash,
3428
+ this.convertToBigInt(starkKey),
3429
+ withdrawalHash,
3430
+ ]);
3431
+ }
3432
+ getExtendedTransferMsgHash(settlement) {
3433
+ const transferTypeHash = this.convertToBigInt(this.extendedStarknetGetSelectorFromName('"Transfer"("sender_position_id":"PositionId","receiver_position_id":"PositionId","asset_id":"AssetId","amount":"u64","expiration":"Timestamp","salt":"felt")"PositionId"("value":"u32")"AssetId"("value":"felt")"Timestamp"("seconds":"u64")'));
3434
+ const domainHash = this.getExtendedDomainHash();
3435
+ const senderPublicKey = this.convertToBigInt(this.safeString(settlement, 'senderPublicKey'));
3436
+ const transferHash = this.convertToBigInt(this.extendedStarknetComputePoseidonHashOnElements([
3437
+ transferTypeHash,
3438
+ this.convertToBigInt(this.safeString(settlement, 'senderPositionId')),
3439
+ this.convertToBigInt(this.safeString(settlement, 'receiverPositionId')),
3440
+ this.convertToBigInt(this.safeString(settlement, 'assetId')),
3441
+ this.convertToBigInt(this.safeString(settlement, 'amount')),
3442
+ this.convertToBigInt(this.safeString(settlement, 'expirationTimestamp')),
3443
+ this.convertToBigInt(this.safeString(settlement, 'nonce')),
3444
+ ]));
3445
+ return this.extendedStarknetComputePoseidonHashOnElements([
3446
+ this.getExtendedStringToFelt('StarkNet Message'),
3447
+ domainHash,
3448
+ senderPublicKey,
3449
+ transferHash,
3450
+ ]);
3451
+ }
3452
+ handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3453
+ if (!response) {
3454
+ return undefined; // fallback to default error handler
3455
+ }
3456
+ //
3457
+ // {"status":"ERROR","error":{"code":1140,"message":"New order cost exceeds available balance","debugInfo":"Order cost 2.000000 exceeds available for trade 0\nOrder price = 200, mark price = 95.2147597125 estimated market price = 94.81"}}
3458
+ //
3459
+ const status = this.safeStringLower(response, 'status');
3460
+ if (status === 'error') {
3461
+ const error = this.safeDict(response, 'error');
3462
+ const errorCode = this.safeString(error, 'code');
3463
+ const feedback = this.id + ' ' + this.json(response);
3464
+ this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
3465
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
3466
+ throw new ExchangeError(feedback);
3467
+ }
3468
+ return undefined;
3469
+ }
3470
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3471
+ const version = this.safeString(api, 0);
3472
+ const accessibility = this.safeString(api, 1);
3473
+ const endpoint = '/' + this.implodeParams(path, params);
3474
+ const query = this.omit(params, this.extractParams(path));
3475
+ const queryPost = (path === 'user/deadmanswitch');
3476
+ let url = this.implodeHostname(this.urls['api']['rest']);
3477
+ if (accessibility === 'private') {
3478
+ // this.checkRequiredCredentials ();
3479
+ if (this.apiKey === undefined) {
3480
+ throw new AuthenticationError(this.id + ' sign() requires an apiKey for private endpoints');
3481
+ }
3482
+ headers = {
3483
+ 'X-Api-Key': this.apiKey,
3484
+ };
3485
+ if (((method === 'POST') || (method === 'PATCH')) && !queryPost) {
3486
+ body = this.json(query);
3487
+ headers['Content-Type'] = 'application/json';
3488
+ }
3489
+ }
3490
+ url = url + '/api/' + version + endpoint;
3491
+ if ((method === 'GET' || method === 'DELETE' || queryPost) && Object.keys(query).length) {
3492
+ url += '?' + this.urlencodeWithArrayRepeat(query);
3493
+ }
3494
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3495
+ }
3496
+ }