ccxt 4.5.47 → 4.5.49

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 (1004) hide show
  1. package/README.md +121 -118
  2. package/dist/ccxt.browser.min.js +5 -5
  3. package/dist/cjs/ccxt.js +11 -1
  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/arkham.js +1 -1
  8. package/dist/cjs/src/abstract/ascendex.js +1 -1
  9. package/dist/cjs/src/abstract/aster.js +1 -1
  10. package/dist/cjs/src/abstract/backpack.js +1 -1
  11. package/dist/cjs/src/abstract/bigone.js +1 -1
  12. package/dist/cjs/src/abstract/binance.js +1 -1
  13. package/dist/cjs/src/abstract/bingx.js +1 -1
  14. package/dist/cjs/src/abstract/bit2c.js +1 -1
  15. package/dist/cjs/src/abstract/bitbank.js +1 -1
  16. package/dist/cjs/src/abstract/bitbns.js +1 -1
  17. package/dist/cjs/src/abstract/bitfinex.js +1 -1
  18. package/dist/cjs/src/abstract/bitflyer.js +1 -1
  19. package/dist/cjs/src/abstract/bitget.js +1 -1
  20. package/dist/cjs/src/abstract/bithumb.js +1 -1
  21. package/dist/cjs/src/abstract/bitmart.js +1 -1
  22. package/dist/cjs/src/abstract/bitmex.js +1 -1
  23. package/dist/cjs/src/abstract/bitopro.js +1 -1
  24. package/dist/cjs/src/abstract/bitrue.js +1 -1
  25. package/dist/cjs/src/abstract/bitso.js +1 -1
  26. package/dist/cjs/src/abstract/bitstamp.js +1 -1
  27. package/dist/cjs/src/abstract/bitteam.js +1 -1
  28. package/dist/cjs/src/abstract/bittrade.js +1 -1
  29. package/dist/cjs/src/abstract/bitvavo.js +1 -1
  30. package/dist/cjs/src/abstract/blockchaincom.js +1 -1
  31. package/dist/cjs/src/abstract/blofin.js +1 -1
  32. package/dist/cjs/src/abstract/btcbox.js +1 -1
  33. package/dist/cjs/src/abstract/btcmarkets.js +1 -1
  34. package/dist/cjs/src/abstract/btcturk.js +1 -1
  35. package/dist/cjs/src/abstract/bullish.js +1 -1
  36. package/dist/cjs/src/abstract/bybit.js +1 -1
  37. package/dist/cjs/src/abstract/bydfi.js +1 -1
  38. package/dist/cjs/src/abstract/cex.js +1 -1
  39. package/dist/cjs/src/abstract/coinbase.js +1 -1
  40. package/dist/cjs/src/abstract/coinbaseexchange.js +1 -1
  41. package/dist/cjs/src/abstract/coinbaseinternational.js +1 -1
  42. package/dist/cjs/src/abstract/coincheck.js +1 -1
  43. package/dist/cjs/src/abstract/coinex.js +1 -1
  44. package/dist/cjs/src/abstract/coinmate.js +1 -1
  45. package/dist/cjs/src/abstract/coinmetro.js +1 -1
  46. package/dist/cjs/src/abstract/coinone.js +1 -1
  47. package/dist/cjs/src/abstract/coinsph.js +1 -1
  48. package/dist/cjs/src/abstract/coinspot.js +1 -1
  49. package/dist/cjs/src/abstract/cryptocom.js +1 -1
  50. package/dist/cjs/src/abstract/cryptomus.js +1 -1
  51. package/dist/cjs/src/abstract/deepcoin.js +1 -1
  52. package/dist/cjs/src/abstract/delta.js +1 -1
  53. package/dist/cjs/src/abstract/deribit.js +1 -1
  54. package/dist/cjs/src/abstract/derive.js +1 -1
  55. package/dist/cjs/src/abstract/digifinex.js +1 -1
  56. package/dist/cjs/src/abstract/dydx.js +1 -1
  57. package/dist/cjs/src/abstract/exmo.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/oxfun.js +1 -1
  85. package/dist/cjs/src/abstract/p2b.js +1 -1
  86. package/dist/cjs/src/abstract/pacifica.js +11 -0
  87. package/dist/cjs/src/abstract/paradex.js +1 -1
  88. package/dist/cjs/src/abstract/paymium.js +1 -1
  89. package/dist/cjs/src/abstract/phemex.js +1 -1
  90. package/dist/cjs/src/abstract/poloniex.js +1 -1
  91. package/dist/cjs/src/abstract/tokocrypto.js +1 -1
  92. package/dist/cjs/src/abstract/toobit.js +1 -1
  93. package/dist/cjs/src/abstract/upbit.js +1 -1
  94. package/dist/cjs/src/abstract/wavesexchange.js +1 -1
  95. package/dist/cjs/src/abstract/weex.js +11 -0
  96. package/dist/cjs/src/abstract/whitebit.js +1 -1
  97. package/dist/cjs/src/abstract/woo.js +1 -1
  98. package/dist/cjs/src/abstract/woofipro.js +1 -1
  99. package/dist/cjs/src/abstract/xt.js +1 -1
  100. package/dist/cjs/src/abstract/yobit.js +1 -1
  101. package/dist/cjs/src/abstract/zaif.js +1 -1
  102. package/dist/cjs/src/abstract/zebpay.js +1 -1
  103. package/dist/cjs/src/abstract/zonda.js +1 -1
  104. package/dist/cjs/src/aftermath.js +1 -0
  105. package/dist/cjs/src/alpaca.js +1 -1
  106. package/dist/cjs/src/apex.js +1 -1
  107. package/dist/cjs/src/arkham.js +1 -1
  108. package/dist/cjs/src/ascendex.js +1 -1
  109. package/dist/cjs/src/aster.js +53 -1
  110. package/dist/cjs/src/backpack.js +1 -1
  111. package/dist/cjs/src/base/Exchange.js +7 -0
  112. package/dist/cjs/src/base/Precise.js +6 -0
  113. package/dist/cjs/src/base/errors.js +6 -0
  114. package/dist/cjs/src/base/functions/crypto.js +1 -1
  115. package/dist/cjs/src/base/functions/encode.js +1 -1
  116. package/dist/cjs/src/base/functions/io.js +1 -1
  117. package/dist/cjs/src/base/functions/misc.js +1 -0
  118. package/dist/cjs/src/base/functions/number.js +6 -0
  119. package/dist/cjs/src/base/functions/platform.js +6 -0
  120. package/dist/cjs/src/base/functions/rsa.js +1 -0
  121. package/dist/cjs/src/base/functions/string.js +6 -0
  122. package/dist/cjs/src/base/functions/throttle.js +1 -1
  123. package/dist/cjs/src/base/functions/time.js +6 -0
  124. package/dist/cjs/src/base/functions/totp.js +1 -0
  125. package/dist/cjs/src/base/functions/type.js +6 -0
  126. package/dist/cjs/src/base/functions.js +1 -1
  127. package/dist/cjs/src/base/ws/Cache.js +6 -0
  128. package/dist/cjs/src/base/ws/Client.js +1 -0
  129. package/dist/cjs/src/base/ws/Future.js +1 -1
  130. package/dist/cjs/src/base/ws/OrderBook.js +1 -1
  131. package/dist/cjs/src/base/ws/OrderBookSide.js +6 -0
  132. package/dist/cjs/src/base/ws/WsClient.js +1 -1
  133. package/dist/cjs/src/bequant.js +1 -1
  134. package/dist/cjs/src/bigone.js +1 -1
  135. package/dist/cjs/src/binance.js +2 -4
  136. package/dist/cjs/src/binancecoinm.js +1 -1
  137. package/dist/cjs/src/binanceus.js +1 -1
  138. package/dist/cjs/src/binanceusdm.js +1 -1
  139. package/dist/cjs/src/bingx.js +1 -1
  140. package/dist/cjs/src/bit2c.js +1 -1
  141. package/dist/cjs/src/bitbank.js +1 -1
  142. package/dist/cjs/src/bitbns.js +1 -1
  143. package/dist/cjs/src/bitfinex.js +39 -43
  144. package/dist/cjs/src/bitflyer.js +1 -1
  145. package/dist/cjs/src/bitget.js +1 -1
  146. package/dist/cjs/src/bithumb.js +1 -1
  147. package/dist/cjs/src/bitmart.js +1 -1
  148. package/dist/cjs/src/bitmex.js +1 -1
  149. package/dist/cjs/src/bitopro.js +1 -1
  150. package/dist/cjs/src/bitrue.js +1 -1
  151. package/dist/cjs/src/bitso.js +1 -1
  152. package/dist/cjs/src/bitstamp.js +1 -1
  153. package/dist/cjs/src/bitteam.js +1 -1
  154. package/dist/cjs/src/bittrade.js +2 -2
  155. package/dist/cjs/src/blockchaincom.js +1 -1
  156. package/dist/cjs/src/blofin.js +16 -3
  157. package/dist/cjs/src/btcbox.js +2 -2
  158. package/dist/cjs/src/btcmarkets.js +1 -1
  159. package/dist/cjs/src/btcturk.js +1 -1
  160. package/dist/cjs/src/bullish.js +3 -2
  161. package/dist/cjs/src/bybit.js +1 -1
  162. package/dist/cjs/src/bydfi.js +1 -1
  163. package/dist/cjs/src/cex.js +1 -1
  164. package/dist/cjs/src/coinbaseadvanced.js +1 -1
  165. package/dist/cjs/src/coincheck.js +1 -1
  166. package/dist/cjs/src/coinex.js +1 -1
  167. package/dist/cjs/src/coinmate.js +1 -1
  168. package/dist/cjs/src/coinmetro.js +1 -1
  169. package/dist/cjs/src/coinone.js +1 -1
  170. package/dist/cjs/src/coinsph.js +5 -0
  171. package/dist/cjs/src/coinspot.js +1 -1
  172. package/dist/cjs/src/cryptocom.js +1 -1
  173. package/dist/cjs/src/cryptomus.js +1 -1
  174. package/dist/cjs/src/deepcoin.js +1 -1
  175. package/dist/cjs/src/delta.js +1 -1
  176. package/dist/cjs/src/deribit.js +1 -1
  177. package/dist/cjs/src/derive.js +1 -1
  178. package/dist/cjs/src/digifinex.js +1 -1
  179. package/dist/cjs/src/dydx.js +1 -1
  180. package/dist/cjs/src/exmo.js +1 -1
  181. package/dist/cjs/src/fmfwio.js +1 -1
  182. package/dist/cjs/src/foxbit.js +1 -1
  183. package/dist/cjs/src/gate.js +1 -1
  184. package/dist/cjs/src/gateio.js +1 -1
  185. package/dist/cjs/src/gemini.js +1 -1
  186. package/dist/cjs/src/grvt.js +1 -1
  187. package/dist/cjs/src/hashkey.js +1 -1
  188. package/dist/cjs/src/hibachi.js +1 -1
  189. package/dist/cjs/src/hitbtc.js +1 -0
  190. package/dist/cjs/src/hollaex.js +1 -1
  191. package/dist/cjs/src/htx.js +1 -1
  192. package/dist/cjs/src/huobi.js +1 -1
  193. package/dist/cjs/src/hyperliquid.js +1 -1
  194. package/dist/cjs/src/independentreserve.js +1 -1
  195. package/dist/cjs/src/indodax.js +1 -1
  196. package/dist/cjs/src/kraken.js +2 -1
  197. package/dist/cjs/src/krakenfutures.js +11 -2
  198. package/dist/cjs/src/kucoin.js +6 -2
  199. package/dist/cjs/src/kucoinfutures.js +1 -1
  200. package/dist/cjs/src/latoken.js +1 -1
  201. package/dist/cjs/src/lbank.js +1 -1
  202. package/dist/cjs/src/lighter.js +203 -75
  203. package/dist/cjs/src/luno.js +1 -1
  204. package/dist/cjs/src/mercado.js +1 -1
  205. package/dist/cjs/src/mexc.js +57 -13
  206. package/dist/cjs/src/modetrade.js +1 -1
  207. package/dist/cjs/src/myokx.js +1 -1
  208. package/dist/cjs/src/ndax.js +1 -1
  209. package/dist/cjs/src/novadax.js +1 -1
  210. package/dist/cjs/src/okx.js +7 -5
  211. package/dist/cjs/src/okxus.js +1 -1
  212. package/dist/cjs/src/onetrading.js +1 -1
  213. package/dist/cjs/src/oxfun.js +1 -1
  214. package/dist/cjs/src/p2b.js +1 -1
  215. package/dist/cjs/src/pacifica.js +3254 -0
  216. package/dist/cjs/src/paradex.js +6 -3
  217. package/dist/cjs/src/paymium.js +1 -1
  218. package/dist/cjs/src/poloniex.js +1 -1
  219. package/dist/cjs/src/pro/alpaca.js +1 -1
  220. package/dist/cjs/src/pro/apex.js +1 -1
  221. package/dist/cjs/src/pro/arkham.js +1 -1
  222. package/dist/cjs/src/pro/ascendex.js +1 -1
  223. package/dist/cjs/src/pro/aster.js +1 -1
  224. package/dist/cjs/src/pro/backpack.js +1 -1
  225. package/dist/cjs/src/pro/bequant.js +1 -1
  226. package/dist/cjs/src/pro/binance.js +13 -2
  227. package/dist/cjs/src/pro/binancecoinm.js +1 -1
  228. package/dist/cjs/src/pro/binanceus.js +1 -1
  229. package/dist/cjs/src/pro/binanceusdm.js +1 -1
  230. package/dist/cjs/src/pro/bingx.js +2 -2
  231. package/dist/cjs/src/pro/bitfinex.js +1 -1
  232. package/dist/cjs/src/pro/bitget.js +1 -1
  233. package/dist/cjs/src/pro/bithumb.js +1 -1
  234. package/dist/cjs/src/pro/bitmart.js +5 -4
  235. package/dist/cjs/src/pro/bitmex.js +1 -1
  236. package/dist/cjs/src/pro/bitrue.js +1 -1
  237. package/dist/cjs/src/pro/bitstamp.js +1 -1
  238. package/dist/cjs/src/pro/bitvavo.js +9 -1
  239. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  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 +1 -1
  243. package/dist/cjs/src/pro/bydfi.js +1 -1
  244. package/dist/cjs/src/pro/cex.js +2 -2
  245. package/dist/cjs/src/pro/coinbase.js +2 -2
  246. package/dist/cjs/src/pro/coinbaseadvanced.js +1 -1
  247. package/dist/cjs/src/pro/coinbaseexchange.js +1 -1
  248. package/dist/cjs/src/pro/coinbaseinternational.js +1 -1
  249. package/dist/cjs/src/pro/coincheck.js +1 -1
  250. package/dist/cjs/src/pro/coinex.js +1 -1
  251. package/dist/cjs/src/pro/coinone.js +1 -1
  252. package/dist/cjs/src/pro/cryptocom.js +1 -1
  253. package/dist/cjs/src/pro/deepcoin.js +1 -1
  254. package/dist/cjs/src/pro/deribit.js +1 -1
  255. package/dist/cjs/src/pro/dydx.js +1 -1
  256. package/dist/cjs/src/pro/exmo.js +1 -1
  257. package/dist/cjs/src/pro/gate.js +4 -1
  258. package/dist/cjs/src/pro/gateio.js +1 -1
  259. package/dist/cjs/src/pro/gemini.js +1 -1
  260. package/dist/cjs/src/pro/grvt.js +1 -1
  261. package/dist/cjs/src/pro/hashkey.js +1 -1
  262. package/dist/cjs/src/pro/hitbtc.js +1 -1
  263. package/dist/cjs/src/pro/hollaex.js +1 -1
  264. package/dist/cjs/src/pro/htx.js +1 -1
  265. package/dist/cjs/src/pro/huobi.js +1 -1
  266. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  267. package/dist/cjs/src/pro/independentreserve.js +1 -1
  268. package/dist/cjs/src/pro/kraken.js +1 -1
  269. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  270. package/dist/cjs/src/pro/kucoin.js +1 -1
  271. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  272. package/dist/cjs/src/pro/lbank.js +1 -0
  273. package/dist/cjs/src/pro/lighter.js +373 -34
  274. package/dist/cjs/src/pro/luno.js +1 -1
  275. package/dist/cjs/src/pro/mexc.js +1 -1
  276. package/dist/cjs/src/pro/myokx.js +1 -1
  277. package/dist/cjs/src/pro/ndax.js +1 -1
  278. package/dist/cjs/src/pro/okx.js +1 -1
  279. package/dist/cjs/src/pro/okxus.js +1 -1
  280. package/dist/cjs/src/pro/onetrading.js +1 -1
  281. package/dist/cjs/src/pro/oxfun.js +1 -1
  282. package/dist/cjs/src/pro/p2b.js +1 -1
  283. package/dist/cjs/src/pro/pacifica.js +1397 -0
  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 +1 -1
  288. package/dist/cjs/src/pro/upbit.js +1 -1
  289. package/dist/cjs/src/pro/weex.js +1906 -0
  290. package/dist/cjs/src/pro/whitebit.js +1 -1
  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 +1 -3
  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 +1 -1
  439. package/dist/cjs/src/toobit.js +1 -1
  440. package/dist/cjs/src/upbit.js +1 -1
  441. package/dist/cjs/src/wavesexchange.js +1 -1
  442. package/dist/cjs/src/weex.js +3823 -0
  443. package/dist/cjs/src/whitebit.js +1 -1
  444. package/dist/cjs/src/woo.js +1 -1
  445. package/dist/cjs/src/woofipro.js +1 -1
  446. package/dist/cjs/src/xt.js +1 -1
  447. package/dist/cjs/src/yobit.js +1 -1
  448. package/dist/cjs/src/zaif.js +1 -1
  449. package/dist/cjs/src/zebpay.js +1 -1
  450. package/dist/cjs/src/zonda.js +1 -1
  451. package/js/ccxt.d.ts +14 -2
  452. package/js/ccxt.js +16 -2
  453. package/js/src/abstract/aftermath.js +6 -0
  454. package/js/src/abstract/alpaca.js +6 -0
  455. package/js/src/abstract/apex.js +6 -0
  456. package/js/src/abstract/arkham.js +6 -0
  457. package/js/src/abstract/ascendex.js +6 -0
  458. package/js/src/abstract/aster.d.ts +52 -0
  459. package/js/src/abstract/aster.js +6 -0
  460. package/js/src/abstract/backpack.js +6 -0
  461. package/js/src/abstract/bequant.js +6 -0
  462. package/js/src/abstract/bigone.js +6 -0
  463. package/js/src/abstract/binance.d.ts +1 -0
  464. package/js/src/abstract/binance.js +6 -0
  465. package/js/src/abstract/binancecoinm.d.ts +1 -0
  466. package/js/src/abstract/binancecoinm.js +6 -0
  467. package/js/src/abstract/binanceus.d.ts +1 -0
  468. package/js/src/abstract/binanceus.js +6 -0
  469. package/js/src/abstract/binanceusdm.d.ts +1 -0
  470. package/js/src/abstract/binanceusdm.js +6 -0
  471. package/js/src/abstract/bingx.js +6 -0
  472. package/js/src/abstract/bit2c.js +6 -0
  473. package/js/src/abstract/bitbank.js +6 -0
  474. package/js/src/abstract/bitbns.js +6 -0
  475. package/js/src/abstract/bitfinex.js +6 -0
  476. package/js/src/abstract/bitflyer.js +6 -0
  477. package/js/src/abstract/bitget.js +6 -0
  478. package/js/src/abstract/bithumb.js +6 -0
  479. package/js/src/abstract/bitmart.js +6 -0
  480. package/js/src/abstract/bitmex.js +6 -0
  481. package/js/src/abstract/bitopro.js +6 -0
  482. package/js/src/abstract/bitrue.js +6 -0
  483. package/js/src/abstract/bitso.js +6 -0
  484. package/js/src/abstract/bitstamp.js +6 -0
  485. package/js/src/abstract/bitteam.js +6 -0
  486. package/js/src/abstract/bittrade.js +6 -0
  487. package/js/src/abstract/bitvavo.js +6 -0
  488. package/js/src/abstract/blockchaincom.js +6 -0
  489. package/js/src/abstract/blofin.js +6 -0
  490. package/js/src/abstract/btcbox.js +6 -0
  491. package/js/src/abstract/btcmarkets.js +6 -0
  492. package/js/src/abstract/btcturk.js +6 -0
  493. package/js/src/abstract/bullish.js +6 -0
  494. package/js/src/abstract/bybit.js +6 -0
  495. package/js/src/abstract/bydfi.js +6 -0
  496. package/js/src/abstract/cex.js +6 -0
  497. package/js/src/abstract/coinbase.js +6 -0
  498. package/js/src/abstract/coinbaseadvanced.js +6 -0
  499. package/js/src/abstract/coinbaseexchange.js +6 -0
  500. package/js/src/abstract/coinbaseinternational.js +6 -0
  501. package/js/src/abstract/coincheck.js +6 -0
  502. package/js/src/abstract/coinex.js +6 -0
  503. package/js/src/abstract/coinmate.js +6 -0
  504. package/js/src/abstract/coinmetro.js +6 -0
  505. package/js/src/abstract/coinone.js +6 -0
  506. package/js/src/abstract/coinsph.js +6 -0
  507. package/js/src/abstract/coinspot.js +6 -0
  508. package/js/src/abstract/cryptocom.js +6 -0
  509. package/js/src/abstract/cryptomus.js +6 -0
  510. package/js/src/abstract/deepcoin.js +6 -0
  511. package/js/src/abstract/delta.js +6 -0
  512. package/js/src/abstract/deribit.js +6 -0
  513. package/js/src/abstract/derive.js +6 -0
  514. package/js/src/abstract/digifinex.js +6 -0
  515. package/js/src/abstract/dydx.js +6 -0
  516. package/js/src/abstract/exmo.js +6 -0
  517. package/js/src/abstract/fmfwio.js +6 -0
  518. package/js/src/abstract/foxbit.js +6 -0
  519. package/js/src/abstract/gate.js +6 -0
  520. package/js/src/abstract/gateio.js +6 -0
  521. package/js/src/abstract/gemini.js +6 -0
  522. package/js/src/abstract/grvt.js +6 -0
  523. package/js/src/abstract/hashkey.js +6 -0
  524. package/js/src/abstract/hibachi.js +6 -0
  525. package/js/src/abstract/hitbtc.js +6 -0
  526. package/js/src/abstract/hollaex.js +6 -0
  527. package/js/src/abstract/htx.js +6 -0
  528. package/js/src/abstract/huobi.js +6 -0
  529. package/js/src/abstract/hyperliquid.js +6 -0
  530. package/js/src/abstract/independentreserve.js +6 -0
  531. package/js/src/abstract/indodax.js +6 -0
  532. package/js/src/abstract/kraken.js +6 -0
  533. package/js/src/abstract/krakenfutures.js +6 -0
  534. package/js/src/abstract/kucoin.js +6 -0
  535. package/js/src/abstract/kucoinfutures.js +6 -0
  536. package/js/src/abstract/latoken.js +6 -0
  537. package/js/src/abstract/lbank.js +6 -0
  538. package/js/src/abstract/lighter.js +6 -0
  539. package/js/src/abstract/luno.js +6 -0
  540. package/js/src/abstract/mercado.js +6 -0
  541. package/js/src/abstract/mexc.d.ts +49 -0
  542. package/js/src/abstract/mexc.js +6 -0
  543. package/js/src/abstract/modetrade.js +6 -0
  544. package/js/src/abstract/myokx.js +6 -0
  545. package/js/src/abstract/ndax.js +6 -0
  546. package/js/src/abstract/novadax.js +6 -0
  547. package/js/src/abstract/okx.js +6 -0
  548. package/js/src/abstract/okxus.js +6 -0
  549. package/js/src/abstract/onetrading.js +6 -0
  550. package/js/src/abstract/oxfun.js +6 -0
  551. package/js/src/abstract/p2b.js +6 -0
  552. package/js/src/abstract/pacifica.d.ts +46 -0
  553. package/js/src/abstract/pacifica.js +11 -0
  554. package/js/src/abstract/paradex.js +6 -0
  555. package/js/src/abstract/paymium.js +6 -0
  556. package/js/src/abstract/phemex.js +6 -0
  557. package/js/src/abstract/poloniex.js +6 -0
  558. package/js/src/abstract/tokocrypto.js +6 -0
  559. package/js/src/abstract/toobit.js +6 -0
  560. package/js/src/abstract/upbit.js +6 -0
  561. package/js/src/abstract/wavesexchange.js +6 -0
  562. package/js/src/abstract/weex.d.ts +83 -0
  563. package/js/src/abstract/weex.js +11 -0
  564. package/js/src/abstract/whitebit.js +6 -0
  565. package/js/src/abstract/woo.js +6 -0
  566. package/js/src/abstract/woofipro.js +6 -0
  567. package/js/src/abstract/xt.js +6 -0
  568. package/js/src/abstract/yobit.js +6 -0
  569. package/js/src/abstract/zaif.js +6 -0
  570. package/js/src/abstract/zebpay.js +6 -0
  571. package/js/src/abstract/zonda.js +6 -0
  572. package/js/src/aftermath.js +6 -0
  573. package/js/src/alpaca.js +6 -0
  574. package/js/src/apex.js +6 -0
  575. package/js/src/arkham.js +6 -0
  576. package/js/src/ascendex.js +6 -0
  577. package/js/src/aster.js +58 -0
  578. package/js/src/backpack.js +6 -0
  579. package/js/src/base/Exchange.d.ts +2 -0
  580. package/js/src/base/Exchange.js +13 -0
  581. package/js/src/base/Precise.js +6 -0
  582. package/js/src/base/errorHierarchy.js +6 -0
  583. package/js/src/base/errors.js +6 -0
  584. package/js/src/base/functions/crypto.js +6 -0
  585. package/js/src/base/functions/encode.js +6 -0
  586. package/js/src/base/functions/generic.js +6 -0
  587. package/js/src/base/functions/io.js +6 -0
  588. package/js/src/base/functions/misc.js +6 -0
  589. package/js/src/base/functions/number.js +6 -0
  590. package/js/src/base/functions/platform.js +6 -0
  591. package/js/src/base/functions/rsa.js +6 -0
  592. package/js/src/base/functions/string.js +6 -0
  593. package/js/src/base/functions/throttle.js +6 -0
  594. package/js/src/base/functions/time.js +6 -0
  595. package/js/src/base/functions/totp.js +6 -0
  596. package/js/src/base/functions/type.js +6 -0
  597. package/js/src/base/functions.js +6 -0
  598. package/js/src/base/types.js +6 -0
  599. package/js/src/base/ws/Cache.js +6 -0
  600. package/js/src/base/ws/Client.js +6 -0
  601. package/js/src/base/ws/Future.js +6 -0
  602. package/js/src/base/ws/OrderBook.js +6 -0
  603. package/js/src/base/ws/OrderBookSide.js +6 -0
  604. package/js/src/base/ws/WsClient.js +6 -0
  605. package/js/src/base/ws/functions.js +6 -0
  606. package/js/src/bequant.js +6 -0
  607. package/js/src/bigone.js +6 -0
  608. package/js/src/binance.d.ts +0 -1
  609. package/js/src/binance.js +7 -3
  610. package/js/src/binancecoinm.js +6 -0
  611. package/js/src/binanceus.js +6 -0
  612. package/js/src/binanceusdm.js +6 -0
  613. package/js/src/bingx.js +6 -0
  614. package/js/src/bit2c.js +6 -0
  615. package/js/src/bitbank.js +6 -0
  616. package/js/src/bitbns.js +6 -0
  617. package/js/src/bitfinex.js +44 -42
  618. package/js/src/bitflyer.js +6 -0
  619. package/js/src/bitget.js +6 -0
  620. package/js/src/bithumb.js +6 -0
  621. package/js/src/bitmart.js +6 -0
  622. package/js/src/bitmex.js +6 -0
  623. package/js/src/bitopro.js +6 -0
  624. package/js/src/bitrue.js +6 -0
  625. package/js/src/bitso.js +6 -0
  626. package/js/src/bitstamp.js +6 -0
  627. package/js/src/bitteam.js +6 -0
  628. package/js/src/bittrade.js +7 -1
  629. package/js/src/bitvavo.js +6 -0
  630. package/js/src/blockchaincom.js +6 -0
  631. package/js/src/blofin.d.ts +2 -1
  632. package/js/src/blofin.js +21 -2
  633. package/js/src/btcbox.js +7 -1
  634. package/js/src/btcmarkets.js +6 -0
  635. package/js/src/btcturk.js +6 -0
  636. package/js/src/bullish.js +8 -1
  637. package/js/src/bybit.js +6 -0
  638. package/js/src/bydfi.js +6 -0
  639. package/js/src/cex.js +6 -0
  640. package/js/src/coinbase.js +6 -0
  641. package/js/src/coinbaseadvanced.js +6 -0
  642. package/js/src/coinbaseexchange.js +6 -0
  643. package/js/src/coinbaseinternational.js +6 -0
  644. package/js/src/coincheck.js +6 -0
  645. package/js/src/coinex.js +6 -0
  646. package/js/src/coinmate.js +6 -0
  647. package/js/src/coinmetro.js +6 -0
  648. package/js/src/coinone.js +6 -0
  649. package/js/src/coinsph.js +10 -0
  650. package/js/src/coinspot.js +6 -0
  651. package/js/src/cryptocom.js +6 -0
  652. package/js/src/cryptomus.js +6 -0
  653. package/js/src/deepcoin.js +6 -0
  654. package/js/src/delta.js +6 -0
  655. package/js/src/deribit.js +6 -0
  656. package/js/src/derive.js +6 -0
  657. package/js/src/digifinex.js +6 -0
  658. package/js/src/dydx.js +6 -0
  659. package/js/src/exmo.js +6 -0
  660. package/js/src/fmfwio.js +6 -0
  661. package/js/src/foxbit.js +6 -0
  662. package/js/src/gate.js +6 -0
  663. package/js/src/gateio.js +6 -0
  664. package/js/src/gemini.js +6 -0
  665. package/js/src/grvt.js +6 -0
  666. package/js/src/hashkey.js +6 -0
  667. package/js/src/hibachi.js +6 -0
  668. package/js/src/hitbtc.js +6 -0
  669. package/js/src/hollaex.js +6 -0
  670. package/js/src/htx.js +6 -0
  671. package/js/src/huobi.js +6 -0
  672. package/js/src/hyperliquid.js +6 -0
  673. package/js/src/independentreserve.js +6 -0
  674. package/js/src/indodax.js +6 -0
  675. package/js/src/kraken.js +7 -0
  676. package/js/src/krakenfutures.js +16 -1
  677. package/js/src/kucoin.d.ts +4 -0
  678. package/js/src/kucoin.js +11 -1
  679. package/js/src/kucoinfutures.js +6 -0
  680. package/js/src/latoken.js +6 -0
  681. package/js/src/lbank.js +6 -0
  682. package/js/src/lighter.d.ts +5 -2
  683. package/js/src/lighter.js +208 -74
  684. package/js/src/luno.js +6 -0
  685. package/js/src/mercado.js +6 -0
  686. package/js/src/mexc.d.ts +2 -0
  687. package/js/src/mexc.js +62 -12
  688. package/js/src/modetrade.js +6 -0
  689. package/js/src/myokx.js +6 -0
  690. package/js/src/ndax.js +6 -0
  691. package/js/src/novadax.js +6 -0
  692. package/js/src/okx.js +12 -4
  693. package/js/src/okxus.js +6 -0
  694. package/js/src/onetrading.js +6 -0
  695. package/js/src/oxfun.js +6 -0
  696. package/js/src/p2b.js +6 -0
  697. package/js/src/pacifica.d.ts +531 -0
  698. package/js/src/pacifica.js +3257 -0
  699. package/js/src/paradex.js +11 -2
  700. package/js/src/paymium.js +6 -0
  701. package/js/src/phemex.js +6 -0
  702. package/js/src/poloniex.js +6 -0
  703. package/js/src/pro/aftermath.js +6 -0
  704. package/js/src/pro/alpaca.js +6 -0
  705. package/js/src/pro/apex.js +6 -0
  706. package/js/src/pro/arkham.js +6 -0
  707. package/js/src/pro/ascendex.js +6 -0
  708. package/js/src/pro/aster.js +6 -0
  709. package/js/src/pro/backpack.js +6 -0
  710. package/js/src/pro/bequant.js +6 -0
  711. package/js/src/pro/binance.js +19 -2
  712. package/js/src/pro/binancecoinm.js +6 -0
  713. package/js/src/pro/binanceus.js +6 -0
  714. package/js/src/pro/binanceusdm.js +6 -0
  715. package/js/src/pro/bingx.js +7 -1
  716. package/js/src/pro/bitfinex.js +6 -0
  717. package/js/src/pro/bitget.js +6 -0
  718. package/js/src/pro/bithumb.js +6 -0
  719. package/js/src/pro/bitmart.js +10 -3
  720. package/js/src/pro/bitmex.js +6 -0
  721. package/js/src/pro/bitopro.js +6 -0
  722. package/js/src/pro/bitrue.js +6 -0
  723. package/js/src/pro/bitstamp.js +6 -0
  724. package/js/src/pro/bittrade.js +6 -0
  725. package/js/src/pro/bitvavo.js +14 -0
  726. package/js/src/pro/blockchaincom.js +6 -0
  727. package/js/src/pro/blofin.js +6 -0
  728. package/js/src/pro/bullish.js +6 -0
  729. package/js/src/pro/bybit.js +6 -0
  730. package/js/src/pro/bydfi.js +6 -0
  731. package/js/src/pro/cex.js +7 -1
  732. package/js/src/pro/coinbase.js +7 -1
  733. package/js/src/pro/coinbaseadvanced.js +6 -0
  734. package/js/src/pro/coinbaseexchange.js +6 -0
  735. package/js/src/pro/coinbaseinternational.js +6 -0
  736. package/js/src/pro/coincheck.js +6 -0
  737. package/js/src/pro/coinex.js +6 -0
  738. package/js/src/pro/coinone.js +6 -0
  739. package/js/src/pro/cryptocom.js +6 -0
  740. package/js/src/pro/deepcoin.js +6 -0
  741. package/js/src/pro/deribit.js +6 -0
  742. package/js/src/pro/derive.js +6 -0
  743. package/js/src/pro/dydx.js +6 -0
  744. package/js/src/pro/exmo.js +6 -0
  745. package/js/src/pro/gate.js +9 -0
  746. package/js/src/pro/gateio.js +6 -0
  747. package/js/src/pro/gemini.js +6 -0
  748. package/js/src/pro/grvt.js +6 -0
  749. package/js/src/pro/hashkey.js +6 -0
  750. package/js/src/pro/hitbtc.js +6 -0
  751. package/js/src/pro/hollaex.js +6 -0
  752. package/js/src/pro/htx.js +6 -0
  753. package/js/src/pro/huobi.js +6 -0
  754. package/js/src/pro/hyperliquid.js +6 -0
  755. package/js/src/pro/independentreserve.js +6 -0
  756. package/js/src/pro/kraken.js +6 -0
  757. package/js/src/pro/krakenfutures.js +6 -0
  758. package/js/src/pro/kucoin.js +6 -0
  759. package/js/src/pro/kucoinfutures.js +6 -0
  760. package/js/src/pro/lbank.js +6 -0
  761. package/js/src/pro/lighter.d.ts +37 -2
  762. package/js/src/pro/lighter.js +378 -33
  763. package/js/src/pro/luno.js +6 -0
  764. package/js/src/pro/mexc.js +6 -0
  765. package/js/src/pro/modetrade.js +6 -0
  766. package/js/src/pro/myokx.js +6 -0
  767. package/js/src/pro/ndax.js +6 -0
  768. package/js/src/pro/okx.js +6 -0
  769. package/js/src/pro/okxus.js +6 -0
  770. package/js/src/pro/onetrading.js +6 -0
  771. package/js/src/pro/oxfun.js +6 -0
  772. package/js/src/pro/p2b.js +6 -0
  773. package/js/src/pro/pacifica.d.ts +267 -0
  774. package/js/src/pro/pacifica.js +1396 -0
  775. package/js/src/pro/paradex.js +6 -0
  776. package/js/src/pro/phemex.js +6 -0
  777. package/js/src/pro/poloniex.js +6 -0
  778. package/js/src/pro/toobit.js +6 -0
  779. package/js/src/pro/upbit.js +6 -0
  780. package/js/src/pro/weex.d.ts +330 -0
  781. package/js/src/pro/weex.js +1905 -0
  782. package/js/src/pro/whitebit.js +6 -0
  783. package/js/src/pro/woo.js +6 -0
  784. package/js/src/pro/woofipro.js +6 -0
  785. package/js/src/pro/xt.js +6 -0
  786. package/js/src/protobuf/mexc/compiled.cjs +6 -0
  787. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +6 -0
  788. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +6 -0
  789. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +6 -0
  790. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +6 -0
  791. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +6 -0
  792. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +6 -0
  793. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +6 -0
  794. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +6 -0
  795. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +6 -0
  796. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +6 -0
  797. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +6 -0
  798. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +6 -0
  799. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +6 -0
  800. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +6 -0
  801. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +6 -0
  802. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +6 -0
  803. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +6 -0
  804. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +6 -0
  805. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +6 -0
  806. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +6 -0
  807. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +6 -0
  808. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +6 -0
  809. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +6 -0
  810. package/js/src/static_dependencies/dydx-v4-client/helpers.js +6 -0
  811. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +6 -0
  812. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +6 -0
  813. package/js/src/static_dependencies/dydx-v4-client/registry.js +6 -0
  814. package/js/src/static_dependencies/ethers/abi-coder.js +6 -0
  815. package/js/src/static_dependencies/ethers/address/address.js +6 -0
  816. package/js/src/static_dependencies/ethers/address/checks.js +6 -0
  817. package/js/src/static_dependencies/ethers/address/contract-address.js +6 -0
  818. package/js/src/static_dependencies/ethers/address/index.js +6 -0
  819. package/js/src/static_dependencies/ethers/bytes32.js +6 -0
  820. package/js/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
  821. package/js/src/static_dependencies/ethers/coders/address.js +6 -0
  822. package/js/src/static_dependencies/ethers/coders/anonymous.js +6 -0
  823. package/js/src/static_dependencies/ethers/coders/array.js +6 -0
  824. package/js/src/static_dependencies/ethers/coders/boolean.js +6 -0
  825. package/js/src/static_dependencies/ethers/coders/bytes.js +6 -0
  826. package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +6 -0
  827. package/js/src/static_dependencies/ethers/coders/null.js +6 -0
  828. package/js/src/static_dependencies/ethers/coders/number.js +6 -0
  829. package/js/src/static_dependencies/ethers/coders/string.js +6 -0
  830. package/js/src/static_dependencies/ethers/coders/tuple.js +6 -0
  831. package/js/src/static_dependencies/ethers/fragments.js +6 -0
  832. package/js/src/static_dependencies/ethers/hash/index.js +6 -0
  833. package/js/src/static_dependencies/ethers/hash/solidity.js +6 -0
  834. package/js/src/static_dependencies/ethers/hash/typed-data.js +6 -0
  835. package/js/src/static_dependencies/ethers/index.js +6 -0
  836. package/js/src/static_dependencies/ethers/interface.js +6 -0
  837. package/js/src/static_dependencies/ethers/typed.js +6 -0
  838. package/js/src/static_dependencies/ethers/utils/base58.js +6 -0
  839. package/js/src/static_dependencies/ethers/utils/base64-browser.js +6 -0
  840. package/js/src/static_dependencies/ethers/utils/base64.js +6 -0
  841. package/js/src/static_dependencies/ethers/utils/data.js +6 -0
  842. package/js/src/static_dependencies/ethers/utils/errors.js +6 -0
  843. package/js/src/static_dependencies/ethers/utils/events.js +6 -0
  844. package/js/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
  845. package/js/src/static_dependencies/ethers/utils/index.js +6 -0
  846. package/js/src/static_dependencies/ethers/utils/maths.js +6 -0
  847. package/js/src/static_dependencies/ethers/utils/properties.js +6 -0
  848. package/js/src/static_dependencies/ethers/utils/rlp-decode.js +6 -0
  849. package/js/src/static_dependencies/ethers/utils/rlp-encode.js +6 -0
  850. package/js/src/static_dependencies/ethers/utils/rlp.js +6 -0
  851. package/js/src/static_dependencies/ethers/utils/units.js +6 -0
  852. package/js/src/static_dependencies/ethers/utils/utf8.js +6 -0
  853. package/js/src/static_dependencies/ethers/utils/uuid.js +6 -0
  854. package/js/src/static_dependencies/fflake/browser.js +6 -0
  855. package/js/src/static_dependencies/jsencrypt/JSEncrypt.js +6 -0
  856. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +6 -0
  857. package/js/src/static_dependencies/jsencrypt/index.js +6 -0
  858. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +6 -0
  859. package/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
  860. package/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
  861. package/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
  862. package/js/src/static_dependencies/jsencrypt/lib/asn1js/oids.js +6 -0
  863. package/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +6 -0
  864. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +6 -0
  865. package/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
  866. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +6 -0
  867. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +6 -0
  868. package/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
  869. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +6 -0
  870. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
  871. package/js/src/static_dependencies/messagepack/msgpack.js +6 -0
  872. package/js/src/static_dependencies/noble-curves/_shortw_utils.js +6 -0
  873. package/js/src/static_dependencies/noble-curves/abstract/curve.js +6 -0
  874. package/js/src/static_dependencies/noble-curves/abstract/edwards.js +6 -0
  875. package/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +6 -0
  876. package/js/src/static_dependencies/noble-curves/abstract/modular.js +6 -0
  877. package/js/src/static_dependencies/noble-curves/abstract/montgomery.js +6 -0
  878. package/js/src/static_dependencies/noble-curves/abstract/poseidon.js +6 -0
  879. package/js/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
  880. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +6 -0
  881. package/js/src/static_dependencies/noble-curves/bn.js +6 -0
  882. package/js/src/static_dependencies/noble-curves/ed25519.js +6 -0
  883. package/js/src/static_dependencies/noble-curves/ed448.js +6 -0
  884. package/js/src/static_dependencies/noble-curves/index.js +6 -0
  885. package/js/src/static_dependencies/noble-curves/jubjub.js +6 -0
  886. package/js/src/static_dependencies/noble-curves/p256.js +6 -0
  887. package/js/src/static_dependencies/noble-curves/p384.js +6 -0
  888. package/js/src/static_dependencies/noble-curves/p521.js +6 -0
  889. package/js/src/static_dependencies/noble-curves/pasta.js +6 -0
  890. package/js/src/static_dependencies/noble-curves/secp256k1.js +6 -0
  891. package/js/src/static_dependencies/noble-hashes/_assert.js +6 -0
  892. package/js/src/static_dependencies/noble-hashes/_blake2.js +6 -0
  893. package/js/src/static_dependencies/noble-hashes/_sha2.js +6 -0
  894. package/js/src/static_dependencies/noble-hashes/_u64.js +6 -0
  895. package/js/src/static_dependencies/noble-hashes/argon2.js +6 -0
  896. package/js/src/static_dependencies/noble-hashes/blake2b.js +6 -0
  897. package/js/src/static_dependencies/noble-hashes/blake2s.js +6 -0
  898. package/js/src/static_dependencies/noble-hashes/blake3.js +6 -0
  899. package/js/src/static_dependencies/noble-hashes/crypto.js +6 -0
  900. package/js/src/static_dependencies/noble-hashes/cryptoNode.js +6 -0
  901. package/js/src/static_dependencies/noble-hashes/eskdf.js +6 -0
  902. package/js/src/static_dependencies/noble-hashes/hkdf.js +6 -0
  903. package/js/src/static_dependencies/noble-hashes/hmac.js +6 -0
  904. package/js/src/static_dependencies/noble-hashes/index.js +6 -0
  905. package/js/src/static_dependencies/noble-hashes/md5.js +6 -0
  906. package/js/src/static_dependencies/noble-hashes/pbkdf2.js +6 -0
  907. package/js/src/static_dependencies/noble-hashes/ripemd160.js +6 -0
  908. package/js/src/static_dependencies/noble-hashes/scrypt.js +6 -0
  909. package/js/src/static_dependencies/noble-hashes/sha1.js +6 -0
  910. package/js/src/static_dependencies/noble-hashes/sha256.js +6 -0
  911. package/js/src/static_dependencies/noble-hashes/sha3-addons.js +6 -0
  912. package/js/src/static_dependencies/noble-hashes/sha3.js +6 -0
  913. package/js/src/static_dependencies/noble-hashes/sha512.js +6 -0
  914. package/js/src/static_dependencies/noble-hashes/utils.js +6 -0
  915. package/js/src/static_dependencies/node-fetch/body.js +6 -0
  916. package/js/src/static_dependencies/node-fetch/errors/abort-error.js +6 -0
  917. package/js/src/static_dependencies/node-fetch/errors/base.js +6 -0
  918. package/js/src/static_dependencies/node-fetch/errors/fetch-error.js +6 -0
  919. package/js/src/static_dependencies/node-fetch/headers.js +6 -0
  920. package/js/src/static_dependencies/node-fetch/index.js +6 -0
  921. package/js/src/static_dependencies/node-fetch/request.js +6 -0
  922. package/js/src/static_dependencies/node-fetch/response.js +6 -0
  923. package/js/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
  924. package/js/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
  925. package/js/src/static_dependencies/node-fetch/utils/is.js +6 -0
  926. package/js/src/static_dependencies/node-fetch/utils/referrer.js +6 -0
  927. package/js/src/static_dependencies/proxies/agent-base/helpers.js +6 -0
  928. package/js/src/static_dependencies/proxies/agent-base/index.js +6 -0
  929. package/js/src/static_dependencies/proxies/http-proxy-agent/index.js +6 -0
  930. package/js/src/static_dependencies/proxies/https-proxy-agent/index.js +6 -0
  931. package/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
  932. package/js/src/static_dependencies/qs/formats.js +6 -0
  933. package/js/src/static_dependencies/qs/index.js +6 -0
  934. package/js/src/static_dependencies/qs/parse.js +6 -0
  935. package/js/src/static_dependencies/qs/stringify.js +6 -0
  936. package/js/src/static_dependencies/qs/utils.js +6 -0
  937. package/js/src/static_dependencies/scure-base/index.js +6 -0
  938. package/js/src/static_dependencies/scure-bip32/index.js +6 -0
  939. package/js/src/static_dependencies/scure-bip39/index.js +6 -0
  940. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +6 -0
  941. package/js/src/static_dependencies/scure-starknet/index.js +6 -0
  942. package/js/src/static_dependencies/starknet/constants.js +6 -0
  943. package/js/src/static_dependencies/starknet/index.js +6 -0
  944. package/js/src/static_dependencies/starknet/types/cairoEnum.js +6 -0
  945. package/js/src/static_dependencies/starknet/types/calldata.js +6 -0
  946. package/js/src/static_dependencies/starknet/types/index.js +6 -0
  947. package/js/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
  948. package/js/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
  949. package/js/src/static_dependencies/starknet/types/lib/contract/legacy.js +6 -0
  950. package/js/src/static_dependencies/starknet/types/lib/contract/sierra.js +6 -0
  951. package/js/src/static_dependencies/starknet/types/lib/index.js +6 -0
  952. package/js/src/static_dependencies/starknet/types/typedData.js +6 -0
  953. package/js/src/static_dependencies/starknet/utils/address.js +6 -0
  954. package/js/src/static_dependencies/starknet/utils/assert.js +6 -0
  955. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +6 -0
  956. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +6 -0
  957. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +6 -0
  958. package/js/src/static_dependencies/starknet/utils/calldata/byteArray.js +6 -0
  959. package/js/src/static_dependencies/starknet/utils/calldata/cairo.js +6 -0
  960. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
  961. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
  962. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
  963. package/js/src/static_dependencies/starknet/utils/calldata/enum/index.js +6 -0
  964. package/js/src/static_dependencies/starknet/utils/calldata/formatter.js +6 -0
  965. package/js/src/static_dependencies/starknet/utils/calldata/index.js +6 -0
  966. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.js +6 -0
  967. package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.js +6 -0
  968. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +6 -0
  969. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
  970. package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +6 -0
  971. package/js/src/static_dependencies/starknet/utils/calldata/requestParser.js +6 -0
  972. package/js/src/static_dependencies/starknet/utils/calldata/responseParser.js +6 -0
  973. package/js/src/static_dependencies/starknet/utils/calldata/tuple.js +6 -0
  974. package/js/src/static_dependencies/starknet/utils/calldata/validate.js +6 -0
  975. package/js/src/static_dependencies/starknet/utils/encode.js +6 -0
  976. package/js/src/static_dependencies/starknet/utils/hash/classHash.js +6 -0
  977. package/js/src/static_dependencies/starknet/utils/hash/index.js +6 -0
  978. package/js/src/static_dependencies/starknet/utils/merkle.js +6 -0
  979. package/js/src/static_dependencies/starknet/utils/num.js +6 -0
  980. package/js/src/static_dependencies/starknet/utils/selector.js +6 -0
  981. package/js/src/static_dependencies/starknet/utils/shortString.js +6 -0
  982. package/js/src/static_dependencies/starknet/utils/starknetId.js +6 -0
  983. package/js/src/static_dependencies/starknet/utils/typedData.js +6 -0
  984. package/js/src/static_dependencies/starknet/utils/uint256.js +6 -0
  985. package/js/src/static_dependencies/starknet/utils/url.js +6 -0
  986. package/js/src/static_dependencies/watchable/src/index.js +6 -0
  987. package/js/src/static_dependencies/watchable/src/types.js +6 -0
  988. package/js/src/static_dependencies/watchable/src/unpromise.js +6 -0
  989. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +6 -0
  990. package/js/src/tokocrypto.js +6 -0
  991. package/js/src/toobit.js +6 -0
  992. package/js/src/upbit.js +6 -0
  993. package/js/src/wavesexchange.js +6 -0
  994. package/js/src/weex.d.ts +675 -0
  995. package/js/src/weex.js +3822 -0
  996. package/js/src/whitebit.js +6 -0
  997. package/js/src/woo.js +6 -0
  998. package/js/src/woofipro.js +6 -0
  999. package/js/src/xt.js +6 -0
  1000. package/js/src/yobit.js +6 -0
  1001. package/js/src/zaif.js +6 -0
  1002. package/js/src/zebpay.js +6 -0
  1003. package/js/src/zonda.js +6 -0
  1004. package/package.json +1 -1
package/js/src/weex.js ADDED
@@ -0,0 +1,3822 @@
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/weex.js';
9
+ import { ArgumentsRequired, AuthenticationError, BadRequest, BadSymbol, ExchangeError, InsufficientFunds, InvalidOrder, NotSupported, OrderNotFound, PermissionDenied } from './base/errors.js';
10
+ import { Precise } from './base/Precise.js';
11
+ import { TICK_SIZE } from './base/functions/number.js';
12
+ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
+ // ---------------------------------------------------------------------------
14
+ /**
15
+ * @class weex
16
+ * @augments Exchange
17
+ */
18
+ export default class weex extends Exchange {
19
+ describe() {
20
+ return this.deepExtend(super.describe(), {
21
+ 'id': 'weex',
22
+ 'name': 'Weex',
23
+ 'countries': ['SG'],
24
+ 'rateLimit': 20,
25
+ 'version': 'v3',
26
+ 'certified': false,
27
+ 'pro': true,
28
+ 'has': {
29
+ 'CORS': undefined,
30
+ 'spot': true,
31
+ 'margin': false,
32
+ 'swap': true,
33
+ 'future': false,
34
+ 'option': false,
35
+ 'addMargin': true,
36
+ 'borrowCrossMargin': false,
37
+ 'borrowIsolatedMargin': false,
38
+ 'borrowMargin': false,
39
+ 'cancelAllOrders': true,
40
+ 'cancelOrder': true,
41
+ 'cancelOrders': true,
42
+ 'cancelOrdersWithClientOrderId': true,
43
+ 'cancelOrderWithClientOrderId': true,
44
+ 'closeAllPositions': true,
45
+ 'closePosition': true,
46
+ 'createDepositAddress': false,
47
+ 'createLimitBuyOrder': true,
48
+ 'createLimitOrder': true,
49
+ 'createLimitSellOrder': true,
50
+ 'createMarketBuyOrder': true,
51
+ 'createMarketBuyOrderWithCost': false,
52
+ 'createMarketOrder': true,
53
+ 'createMarketOrderWithCost': false,
54
+ 'createMarketSellOrder': true,
55
+ 'createMarketSellOrderWithCost': false,
56
+ 'createOrder': true,
57
+ 'createOrders': false,
58
+ 'createOrderWithTakeProfitAndStopLoss': true,
59
+ 'createPostOnlyOrder': false,
60
+ 'createReduceOnlyOrder': true,
61
+ 'createStopLimitOrder': false,
62
+ 'createStopLossOrder': true,
63
+ 'createTakeProfitOrder': true,
64
+ 'createTrailingAmountOrder': false,
65
+ 'createTrailingPercentOrder': false,
66
+ 'createTriggerOrder': false,
67
+ 'deposit': false,
68
+ 'editOrder': false,
69
+ 'editOrders': false,
70
+ 'editOrderWithClientOrderId': false,
71
+ 'fetchAccounts': false,
72
+ 'fetchADLRank': false,
73
+ 'fetchBalance': true,
74
+ 'fetchBidsAsks': true,
75
+ 'fetchBorrowInterest': false,
76
+ 'fetchBorrowRate': false,
77
+ 'fetchBorrowRateHistories': false,
78
+ 'fetchBorrowRateHistory': false,
79
+ 'fetchBorrowRates': false,
80
+ 'fetchBorrowRatesPerSymbol': false,
81
+ 'fetchCanceledAndClosedOrders': true,
82
+ 'fetchCanceledOrders': true,
83
+ 'fetchClosedOrder': false,
84
+ 'fetchClosedOrders': true,
85
+ 'fetchConvertCurrencies': false,
86
+ 'fetchConvertQuote': false,
87
+ 'fetchConvertTrade': false,
88
+ 'fetchConvertTradeHistory': false,
89
+ 'fetchCrossBorrowRate': false,
90
+ 'fetchCrossBorrowRates': false,
91
+ 'fetchCurrencies': true,
92
+ 'fetchDeposit': false,
93
+ 'fetchDepositAddress': false,
94
+ 'fetchDepositAddresses': false,
95
+ 'fetchDepositAddressesByNetwork': false,
96
+ 'fetchDeposits': false,
97
+ 'fetchDepositsWithdrawals': false,
98
+ 'fetchDepositWithdrawFee': false,
99
+ 'fetchDepositWithdrawFees': false,
100
+ 'fetchFundingHistory': false,
101
+ 'fetchFundingInterval': false,
102
+ 'fetchFundingIntervals': false,
103
+ 'fetchFundingRate': true,
104
+ 'fetchFundingRateHistory': true,
105
+ 'fetchFundingRates': true,
106
+ 'fetchGreeks': false,
107
+ 'fetchIndexOHLCV': true,
108
+ 'fetchIsolatedBorrowRate': false,
109
+ 'fetchIsolatedBorrowRates': false,
110
+ 'fetchIsolatedPositions': false,
111
+ 'fetchL2OrderBook': false,
112
+ 'fetchL3OrderBook': false,
113
+ 'fetchLastPrices': false,
114
+ 'fetchLedger': true,
115
+ 'fetchLedgerEntry': false,
116
+ 'fetchLeverage': true,
117
+ 'fetchLeverages': true,
118
+ 'fetchLeverageTiers': false,
119
+ 'fetchLiquidations': false,
120
+ 'fetchLongShortRatio': false,
121
+ 'fetchLongShortRatioHistory': false,
122
+ 'fetchMarginAdjustmentHistory': false,
123
+ 'fetchMarginMode': true,
124
+ 'fetchMarginModes': true,
125
+ 'fetchMarketLeverageTiers': false,
126
+ 'fetchMarkets': true,
127
+ 'fetchMarkOHLCV': true,
128
+ 'fetchMarkPrices': false,
129
+ 'fetchMyLiquidations': false,
130
+ 'fetchMySettlementHistory': false,
131
+ 'fetchMyTrades': true,
132
+ 'fetchOHLCV': true,
133
+ 'fetchOpenInterest': true,
134
+ 'fetchOpenInterestHistory': false,
135
+ 'fetchOpenInterests': false,
136
+ 'fetchOpenOrder': false,
137
+ 'fetchOpenOrders': true,
138
+ 'fetchOption': false,
139
+ 'fetchOptionChain': false,
140
+ 'fetchOrder': true,
141
+ 'fetchOrderBook': true,
142
+ 'fetchOrderBooks': false,
143
+ 'fetchOrders': true,
144
+ 'fetchOrdersByStatus': false,
145
+ 'fetchOrderTrades': true,
146
+ 'fetchOrderWithClientOrderId': true,
147
+ 'fetchPosition': true,
148
+ 'fetchPositionADLRank': false,
149
+ 'fetchPositionHistory': false,
150
+ 'fetchPositionMode': true,
151
+ 'fetchPositions': true,
152
+ 'fetchPositionsADLRank': false,
153
+ 'fetchPositionsForSymbol': true,
154
+ 'fetchPositionsHistory': false,
155
+ 'fetchPositionsRisk': false,
156
+ 'fetchPremiumIndexOHLCV': false,
157
+ 'fetchSettlementHistory': false,
158
+ 'fetchStatus': true,
159
+ 'fetchTicker': true,
160
+ 'fetchTickers': true,
161
+ 'fetchTime': true,
162
+ 'fetchTrades': true,
163
+ 'fetchTradingFee': true,
164
+ 'fetchTradingFees': false,
165
+ 'fetchTradingLimits': false,
166
+ 'fetchTransactionFee': false,
167
+ 'fetchTransactionFees': false,
168
+ 'fetchTransactions': false,
169
+ 'fetchTransfer': false,
170
+ 'fetchTransfers': true,
171
+ 'fetchUnderlyingAssets': false,
172
+ 'fetchVolatilityHistory': false,
173
+ 'fetchWithdrawAddresses': false,
174
+ 'fetchWithdrawal': false,
175
+ 'fetchWithdrawals': false,
176
+ 'fetchWithdrawalWhitelist': false,
177
+ 'privateAPI': false,
178
+ 'publicAPI': false,
179
+ 'reduceMargin': true,
180
+ 'repayCrossMargin': false,
181
+ 'repayIsolatedMargin': false,
182
+ 'sandbox': false,
183
+ 'setLeverage': true,
184
+ 'setMargin': false,
185
+ 'setMarginMode': true,
186
+ 'setPositionMode': true,
187
+ 'signIn': false,
188
+ 'transfer': false,
189
+ 'withdraw': false,
190
+ },
191
+ 'urls': {
192
+ 'logo': 'https://github.com/user-attachments/assets/ccbadb2d-5035-403d-898f-dce831bdc936',
193
+ 'api': {
194
+ 'public': 'https://api-spot.weex.com',
195
+ 'private': 'https://api-spot.weex.com',
196
+ 'contract': 'https://api-contract.weex.com',
197
+ 'contractPrivate': 'https://api-contract.weex.com',
198
+ },
199
+ 'www': 'https://www.weex.com',
200
+ 'doc': [
201
+ 'https://www.weex.com/api-doc',
202
+ ],
203
+ 'referral': 'https://weex.com/register?vipCode=4lvdl',
204
+ },
205
+ 'api': {
206
+ 'public': {
207
+ // multiply public endpoints weight by 5
208
+ 'get': {
209
+ 'api/v3/time': 5,
210
+ 'api/v3/coins': 25,
211
+ 'api/v3/exchangeInfo': 100,
212
+ 'api/v3/ping': 5,
213
+ 'api/v3/apiTradingSymbols': 25,
214
+ 'api/v3/market/ticker/price': 20,
215
+ 'api/v3/market/ticker/24hr': 10,
216
+ 'api/v3/market/trades': 125,
217
+ 'api/v3/market/klines': 10,
218
+ 'api/v3/market/depth': 25,
219
+ 'api/v3/market/ticker/bookTicker': 20, // done
220
+ },
221
+ },
222
+ 'private': {
223
+ 'get': {
224
+ 'api/v3/account/': 5,
225
+ 'api/v3/account/transferRecords': 3,
226
+ 'api/v3/order': 2,
227
+ 'api/v3/openOrders': 3,
228
+ 'api/v3/allOrders': 10,
229
+ 'api/v3/myTrades': 5,
230
+ 'api/v3/rebate/affiliate/getAffiliateUIDs': 20,
231
+ 'api/v3/rebate/affiliate/getChannelUserTradeAndAsset': 20,
232
+ 'api/v3/rebate/affiliate/getAffiliateCommission': 20,
233
+ 'api/v3/rebate/affiliate/getInternalWithdrawalStatus': 100,
234
+ 'api/v3/rebate/affiliate/querySubChannelTransactions': 10,
235
+ 'api/v3/agency/verifyReferrals': 20,
236
+ 'api/v3/agency/getAssert': 20,
237
+ 'api/v3/agency/getDealData': 20, // not unified
238
+ },
239
+ 'post': {
240
+ 'api/v3/account/bills': 5,
241
+ 'api/v3/account/fundingBills': 5,
242
+ 'api/v3/order': 5,
243
+ 'api/v3/order/batch': 50,
244
+ 'api/v3/rebate/affiliate/internalWithdrawal': 100, // not unified
245
+ },
246
+ 'delete': {
247
+ 'api/v3/order': 1,
248
+ 'api/v3/openOrders': 1,
249
+ 'api/v3/order/batch': 10, // done
250
+ },
251
+ },
252
+ 'contract': {
253
+ // multiply public endpoints weight by 5
254
+ 'get': {
255
+ 'capi/v3/market/time': 5,
256
+ 'capi/v3/market/exchangeInfo': 5,
257
+ 'capi/v3/market/depth': 5,
258
+ 'capi/v3/market/ticker/24hr': 200,
259
+ 'capi/v3/market/ticker/bookTicker': 5,
260
+ 'capi/v3/market/trades': 25,
261
+ 'capi/v3/market/klines': 5,
262
+ 'capi/v3/market/indexPriceKlines': 5,
263
+ 'capi/v3/market/markPriceKlines': 5,
264
+ 'capi/v3/market/historyKlines': 25,
265
+ 'capi/v3/market/symbolPrice': 5,
266
+ 'capi/v3/market/openInterest': 10,
267
+ 'capi/v3/market/premiumIndex': 5,
268
+ 'capi/v3/market/fundingRate': 25,
269
+ 'capi/v3/market/apiTradingSymbols': 25, // not unified
270
+ },
271
+ },
272
+ 'contractPrivate': {
273
+ 'get': {
274
+ 'capi/v3/account/balance': 10,
275
+ 'capi/v3/account/commissionRate': 10,
276
+ 'capi/v3/account/accountConfig': 10,
277
+ 'capi/v3/account/symbolConfig': 10,
278
+ 'capi/v3/account/position/allPosition': 15,
279
+ 'capi/v3/account/position/singlePosition': 3,
280
+ 'capi/v3/order': 3,
281
+ 'capi/v3/openOrders': 5,
282
+ 'capi/v3/order/history': 10,
283
+ 'capi/v3/userTrades': 5,
284
+ 'capi/v3/openAlgoOrders': 3,
285
+ 'capi/v3/allAlgoOrders': 10, // not unified - capi/v3/order/history returns both regular and algo orders
286
+ },
287
+ 'post': {
288
+ 'capi/v3/account/income': 5,
289
+ 'capi/v3/account/marginType': 50,
290
+ 'capi/v3/account/leverage': 20,
291
+ 'capi/v3/account/positionMargin': 30,
292
+ 'capi/v3/account/modifyAutoAppendMargin': 30,
293
+ 'capi/v3/order': 5,
294
+ 'capi/v3/batchOrders': 10,
295
+ 'capi/v3/closePositions': 50,
296
+ 'capi/v3/algoOrder': 5,
297
+ 'capi/v3/placeTpSlOrder': 5,
298
+ 'capi/v3/modifyTpSlOrder': 5, // not unified
299
+ },
300
+ 'delete': {
301
+ 'capi/v3/order': 3,
302
+ 'capi/v3/batchOrders': 10,
303
+ 'capi/v3/allOpenOrders': 10,
304
+ 'capi/v3/algoOrder': 3,
305
+ 'capi/v3/algoOpenOrders': 10, // done
306
+ },
307
+ },
308
+ },
309
+ 'requiredCredentials': {
310
+ 'apiKey': true,
311
+ 'secret': true,
312
+ 'password': true,
313
+ },
314
+ 'timeframes': {
315
+ '1m': '1m',
316
+ '5m': '5m',
317
+ '15m': '15m',
318
+ '30m': '30m',
319
+ '1h': '1h',
320
+ '2h': '2h',
321
+ '4h': '4h',
322
+ '6h': '6h',
323
+ '8h': '8h',
324
+ '12h': '12h',
325
+ '1d': '1d',
326
+ '1w': '1w',
327
+ '1M': '1M',
328
+ },
329
+ 'precisionMode': TICK_SIZE,
330
+ 'exceptions': {
331
+ 'exact': {
332
+ '-1000': ExchangeError,
333
+ '-1054': ExchangeError,
334
+ '-1040': AuthenticationError,
335
+ '-1041': AuthenticationError,
336
+ '-1042': AuthenticationError,
337
+ '-1043': AuthenticationError,
338
+ '-1044': AuthenticationError,
339
+ '-1045': BadRequest,
340
+ '-1046': BadRequest,
341
+ '-1047': AuthenticationError,
342
+ '-1049': AuthenticationError,
343
+ '-1050': PermissionDenied,
344
+ '-1051': PermissionDenied,
345
+ '-1052': PermissionDenied,
346
+ '-1053': PermissionDenied,
347
+ '-1055': PermissionDenied,
348
+ '-1056': PermissionDenied,
349
+ '-1057': PermissionDenied,
350
+ '-1058': PermissionDenied,
351
+ '-1115': InvalidOrder,
352
+ '-1116': InvalidOrder,
353
+ '-1117': InvalidOrder,
354
+ '-1121': BadSymbol,
355
+ '-1128': BadRequest,
356
+ '-1135': BadRequest,
357
+ '-1140': BadRequest,
358
+ '-1141': ArgumentsRequired,
359
+ '-1142': BadRequest,
360
+ '-1150': BadRequest,
361
+ '-1160': BadRequest,
362
+ '-1170': BadRequest,
363
+ '-1171': BadRequest,
364
+ '-1180': InvalidOrder,
365
+ '-1190': PermissionDenied,
366
+ '-2007': BadSymbol,
367
+ '-2200': OrderNotFound,
368
+ '-3006': InvalidOrder,
369
+ '-3007': InvalidOrder,
370
+ '-3200': InvalidOrder,
371
+ '-3235': PermissionDenied,
372
+ '-3236': PermissionDenied,
373
+ '-3313': InvalidOrder,
374
+ '-3613': ExchangeError,
375
+ 'FAILED_ORDER_NOT_FOUND': OrderNotFound, // {"orderId":121231,"status":"FAILED","errorMsg":"FAILED_ORDER_NOT_FOUND"}
376
+ },
377
+ 'broad': {
378
+ 'amount not enough': InsufficientFunds,
379
+ 'INVALID_ARGUMENT': BadRequest, // {"result":false,"id":1,"msg":"INVALID_ARGUMENT: invalid symbol : ASDFS_SPBL"}
380
+ },
381
+ },
382
+ 'fees': {
383
+ 'trading': {
384
+ 'feeSide': 'get',
385
+ 'tierBased': true,
386
+ 'percentage': true,
387
+ 'taker': this.parseNumber('0.1'),
388
+ 'maker': this.parseNumber('0.1'),
389
+ 'tiers': {
390
+ 'taker': [
391
+ [this.parseNumber('0'), this.parseNumber('0.1')],
392
+ [this.parseNumber('500000'), this.parseNumber('0.09')],
393
+ [this.parseNumber('1000000'), this.parseNumber('0.08')],
394
+ [this.parseNumber('2000000'), this.parseNumber('0.06')],
395
+ [this.parseNumber('5000000'), this.parseNumber('0.05')],
396
+ [this.parseNumber('10000000'), this.parseNumber('0.04')],
397
+ [this.parseNumber('25000000'), this.parseNumber('0.03')],
398
+ [this.parseNumber('50000000'), this.parseNumber('0.02')],
399
+ [this.parseNumber('100000000'), this.parseNumber('0')],
400
+ ],
401
+ 'maker': [
402
+ [this.parseNumber('0'), this.parseNumber('0.1')],
403
+ [this.parseNumber('500000'), this.parseNumber('0.08')],
404
+ [this.parseNumber('1000000'), this.parseNumber('0.07')],
405
+ [this.parseNumber('2000000'), this.parseNumber('0.05')],
406
+ [this.parseNumber('5000000'), this.parseNumber('0.04')],
407
+ [this.parseNumber('10000000'), this.parseNumber('0.03')],
408
+ [this.parseNumber('25000000'), this.parseNumber('0.02')],
409
+ [this.parseNumber('50000000'), this.parseNumber('0.01')],
410
+ [this.parseNumber('100000000'), this.parseNumber('0')],
411
+ ],
412
+ },
413
+ },
414
+ 'spot': {
415
+ 'feeSide': 'get',
416
+ 'tierBased': true,
417
+ 'percentage': true,
418
+ 'taker': this.parseNumber('0.1'),
419
+ 'maker': this.parseNumber('0.1'),
420
+ 'tiers': {
421
+ 'taker': [
422
+ [this.parseNumber('0'), this.parseNumber('0.1')],
423
+ [this.parseNumber('500000'), this.parseNumber('0.09')],
424
+ [this.parseNumber('1000000'), this.parseNumber('0.08')],
425
+ [this.parseNumber('2000000'), this.parseNumber('0.06')],
426
+ [this.parseNumber('5000000'), this.parseNumber('0.05')],
427
+ [this.parseNumber('10000000'), this.parseNumber('0.04')],
428
+ [this.parseNumber('25000000'), this.parseNumber('0.03')],
429
+ [this.parseNumber('50000000'), this.parseNumber('0.02')],
430
+ [this.parseNumber('100000000'), this.parseNumber('0')],
431
+ ],
432
+ 'maker': [
433
+ [this.parseNumber('0'), this.parseNumber('0.1')],
434
+ [this.parseNumber('500000'), this.parseNumber('0.08')],
435
+ [this.parseNumber('1000000'), this.parseNumber('0.07')],
436
+ [this.parseNumber('2000000'), this.parseNumber('0.05')],
437
+ [this.parseNumber('5000000'), this.parseNumber('0.04')],
438
+ [this.parseNumber('10000000'), this.parseNumber('0.03')],
439
+ [this.parseNumber('25000000'), this.parseNumber('0.02')],
440
+ [this.parseNumber('50000000'), this.parseNumber('0.01')],
441
+ [this.parseNumber('100000000'), this.parseNumber('0')],
442
+ ],
443
+ },
444
+ },
445
+ 'contract': {
446
+ 'feeSide': 'quote',
447
+ 'tierBased': true,
448
+ 'percentage': true,
449
+ 'taker': this.parseNumber('0.08'),
450
+ 'maker': this.parseNumber('0.02'),
451
+ 'tiers': {
452
+ 'taker': [
453
+ [this.parseNumber('0'), this.parseNumber('0.08')],
454
+ [this.parseNumber('1000000'), this.parseNumber('0.075')],
455
+ [this.parseNumber('5000000'), this.parseNumber('0.06')],
456
+ [this.parseNumber('10000000'), this.parseNumber('0.055')],
457
+ [this.parseNumber('30000000'), this.parseNumber('0.05')],
458
+ [this.parseNumber('50000000'), this.parseNumber('0.048')],
459
+ [this.parseNumber('100000000'), this.parseNumber('0.045')],
460
+ [this.parseNumber('300000000'), this.parseNumber('0.042')],
461
+ [this.parseNumber('500000000'), this.parseNumber('0.04')],
462
+ ],
463
+ 'maker': [
464
+ [this.parseNumber('0'), this.parseNumber('0.02')],
465
+ [this.parseNumber('1000000'), this.parseNumber('0.02')],
466
+ [this.parseNumber('5000000'), this.parseNumber('0.018')],
467
+ [this.parseNumber('10000000'), this.parseNumber('0.018')],
468
+ [this.parseNumber('30000000'), this.parseNumber('0.016')],
469
+ [this.parseNumber('50000000'), this.parseNumber('0.016')],
470
+ [this.parseNumber('100000000'), this.parseNumber('0.014')],
471
+ [this.parseNumber('300000000'), this.parseNumber('0.012')],
472
+ [this.parseNumber('500000000'), this.parseNumber('0.01')],
473
+ ],
474
+ },
475
+ },
476
+ },
477
+ 'commonCurrencies': {
478
+ 'XBT': 'XBT',
479
+ },
480
+ 'options': {
481
+ 'partner': 'b-WEEX111125',
482
+ 'timeDifference': 0,
483
+ 'adjustForTimeDifference': false,
484
+ 'accountsByType': {
485
+ 'spot': 'spot',
486
+ 'trading': 'spot',
487
+ 'fund': 'funding',
488
+ 'funding': 'funding',
489
+ 'swap': 'contract',
490
+ 'contract': 'contract',
491
+ 'futures': 'contract',
492
+ },
493
+ 'networks': {
494
+ 'BEP20': 'BEP20(BSC)',
495
+ 'BSC': 'BEP20(BSC)',
496
+ 'ERC20': 'ERC20',
497
+ 'ETH': 'ERC20',
498
+ 'POLYGON': 'POLYGON(MATIC)',
499
+ 'MATIC': 'POLYGON(MATIC)',
500
+ 'ARBITRUM': 'ARBITRUM(ARB)',
501
+ 'ARB': 'ARBITRUM(ARB)',
502
+ 'SOLANA': 'SOLANA(SOL)',
503
+ 'SOL': 'SOLANA(SOL)',
504
+ 'OP': 'OPTIMISM(OP)',
505
+ 'OPTIMISM': 'OPTIMISM(OP)',
506
+ 'AVALANCHEC': 'AVALANCHE_C(AVAX_C)',
507
+ 'AVAXC': 'AVALANCHE_C(AVAX_C)',
508
+ },
509
+ 'networksById': {
510
+ 'BEP20(BSC)': 'BEP20',
511
+ 'ERC20': 'ERC20',
512
+ 'POLYGON(MATIC)': 'MATIC',
513
+ 'ARBITRUM(ARB)': 'ARB',
514
+ 'SOLANA(SOL)': 'SOL',
515
+ 'OPTIMISM(OP)': 'OP',
516
+ 'AVALANCHE_C(AVAX_C)': 'AVAXC',
517
+ },
518
+ 'timeframes': {
519
+ 'spot': {
520
+ '1m': '1m',
521
+ '5m': '5m',
522
+ '15m': '15m',
523
+ '30m': '30m',
524
+ '1h': '1h',
525
+ '2h': '2h',
526
+ '4h': '4h',
527
+ '6h': '6h',
528
+ '8h': '8h',
529
+ '12h': '12h',
530
+ '1d': '1d',
531
+ '1w': '1w',
532
+ '1M': '1M',
533
+ },
534
+ 'contract': {
535
+ '1m': '1m',
536
+ '5m': '5m',
537
+ '15m': '15m',
538
+ '30m': '30m',
539
+ '1h': '1h',
540
+ '4h': '4h',
541
+ '12h': '12h',
542
+ '1d': '1d',
543
+ '1w': '1w',
544
+ },
545
+ },
546
+ },
547
+ 'features': {
548
+ 'spot': {
549
+ 'sandbox': false,
550
+ 'createOrder': {
551
+ 'test': false,
552
+ 'marginMode': false,
553
+ 'triggerPrice': false,
554
+ 'triggerPriceType': undefined,
555
+ 'triggerDirection': undefined,
556
+ 'stopLossPrice': false,
557
+ 'takeProfitPrice': false,
558
+ 'attachedStopLossTakeProfit': undefined,
559
+ 'timeInForce': {
560
+ 'IOC': true,
561
+ 'FOK': true,
562
+ 'PO': false,
563
+ 'GTD': false,
564
+ },
565
+ 'hedged': false,
566
+ 'trailing': false,
567
+ 'leverage': false,
568
+ 'marketBuyByCost': false,
569
+ 'marketBuyRequiresPrice': false,
570
+ 'selfTradePrevention': false,
571
+ 'iceberg': false,
572
+ },
573
+ 'createOrders': {
574
+ 'max': 10,
575
+ },
576
+ 'fetchMyTrades': {
577
+ 'marginMode': false,
578
+ 'limit': 100,
579
+ 'daysBack': undefined,
580
+ 'untilDays': undefined,
581
+ 'symbolRequired': true,
582
+ },
583
+ 'fetchOrder': {
584
+ 'marginMode': false,
585
+ 'trigger': false,
586
+ 'trailing': false,
587
+ 'symbolRequired': false,
588
+ },
589
+ 'fetchOpenOrders': {
590
+ 'marginMode': false,
591
+ 'limit': 100,
592
+ 'trigger': false,
593
+ 'trailing': false,
594
+ 'symbolRequired': false,
595
+ },
596
+ 'fetchOrders': {
597
+ 'marginMode': false,
598
+ 'limit': 1000,
599
+ 'daysBack': 100000,
600
+ 'untilDays': 100000,
601
+ 'trigger': false,
602
+ 'trailing': false,
603
+ 'symbolRequired': true,
604
+ },
605
+ 'fetchClosedOrders': undefined,
606
+ 'fetchOHLCV': {
607
+ 'limit': 300,
608
+ },
609
+ },
610
+ 'forDerivs': {
611
+ 'sandbox': false,
612
+ 'createOrder': {
613
+ 'marginMode': true,
614
+ 'triggerPrice': false,
615
+ 'triggerPriceType': undefined,
616
+ 'triggerDirection': false,
617
+ 'stopLossPrice': true,
618
+ 'takeProfitPrice': true,
619
+ 'attachedStopLossTakeProfit': {
620
+ 'triggerPriceType': {
621
+ 'last': true,
622
+ 'mark': true,
623
+ 'index': false,
624
+ },
625
+ 'price': false,
626
+ },
627
+ 'timeInForce': {
628
+ 'IOC': true,
629
+ 'FOK': true,
630
+ 'PO': false,
631
+ 'GTD': false,
632
+ },
633
+ 'hedged': false,
634
+ 'trailing': false,
635
+ 'leverage': false,
636
+ 'marketBuyByCost': false,
637
+ 'marketBuyRequiresPrice': false,
638
+ 'selfTradePrevention': false,
639
+ 'iceberg': false,
640
+ },
641
+ 'createOrders': {
642
+ 'max': 10,
643
+ },
644
+ 'fetchMyTrades': {
645
+ 'marginMode': false,
646
+ 'limit': 100,
647
+ 'daysBack': undefined,
648
+ 'untilDays': undefined,
649
+ 'symbolRequired': false,
650
+ },
651
+ 'fetchOrder': {
652
+ 'marginMode': false,
653
+ 'trigger': false,
654
+ 'trailing': false,
655
+ 'symbolRequired': false,
656
+ },
657
+ 'fetchOpenOrders': {
658
+ 'marginMode': false,
659
+ 'limit': 100,
660
+ 'trigger': true,
661
+ 'trailing': false,
662
+ 'symbolRequired': false,
663
+ },
664
+ 'fetchOrders': undefined,
665
+ 'fetchCanceledAndClosedOrders': {
666
+ 'marginMode': false,
667
+ 'limit': 1000,
668
+ 'daysBack': 100000,
669
+ 'untilDays': 100000,
670
+ 'trigger': false,
671
+ 'trailing': false,
672
+ 'symbolRequired': false,
673
+ },
674
+ 'fetchClosedOrders': undefined,
675
+ 'fetchOHLCV': {
676
+ 'limit': 1000, // 100 for historical
677
+ },
678
+ },
679
+ 'swap': {
680
+ 'linear': {
681
+ 'extends': 'forDerivs',
682
+ },
683
+ 'inverse': undefined,
684
+ },
685
+ },
686
+ });
687
+ }
688
+ nonce() {
689
+ return this.milliseconds() - this.options['timeDifference'];
690
+ }
691
+ /**
692
+ * @method
693
+ * @name weex#fetchStatus
694
+ * @description the latest known information on the availability of the exchange API
695
+ * @see https://www.weex.com/api-doc/spot/ConfigAPI/Ping
696
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
697
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/?id=exchange-status-structure}
698
+ */
699
+ async fetchStatus(params = {}) {
700
+ const response = await this.publicGetApiV3Ping(params);
701
+ // reutns an empty response if the exchange is alive, otherwise will trigger an error
702
+ return {
703
+ 'status': 'ok',
704
+ 'updated': undefined,
705
+ 'eta': undefined,
706
+ 'url': undefined,
707
+ 'info': response,
708
+ };
709
+ }
710
+ /**
711
+ * @method
712
+ * @name weex#fetchTime
713
+ * @description fetches the current integer timestamp in milliseconds from the exchange server
714
+ * @see https://www.weex.com/api-doc/spot/ConfigAPI/GetServerTime
715
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetServerTime
716
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
717
+ * @param {string} [params.type] 'spot' or 'swap', default is 'spot'
718
+ * @returns {int} the current integer timestamp in milliseconds from the exchange server
719
+ */
720
+ async fetchTime(params = {}) {
721
+ let type = undefined;
722
+ [type, params] = this.handleMarketTypeAndParams('fetchTime', undefined, params);
723
+ let response = undefined;
724
+ if (type !== 'spot') {
725
+ response = await this.contractGetCapiV3MarketTime(params);
726
+ }
727
+ else {
728
+ response = await this.publicGetApiV3Time(params);
729
+ }
730
+ //
731
+ // {
732
+ // "serverTime": 1764505776347
733
+ // }
734
+ //
735
+ return this.safeInteger(response, 'serverTime');
736
+ }
737
+ /**
738
+ * @method
739
+ * @name weex#fetchCurrencies
740
+ * @description fetches all available currencies on an exchange
741
+ * @see https://www.weex.com/api-doc/spot/ConfigAPI/CurrencyInfo
742
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
743
+ * @returns {object} an associative dictionary of currencies
744
+ */
745
+ async fetchCurrencies(params = {}) {
746
+ const response = await this.publicGetApiV3Coins(params);
747
+ //
748
+ // [
749
+ // {
750
+ // "coin": "BTC",
751
+ // "depositAllEnable": true,
752
+ // "withdrawAllEnable": true,
753
+ // "name": "BTC",
754
+ // "networkList": [
755
+ // {
756
+ // "network": "BTC",
757
+ // "coin": "BTC",
758
+ // "withdrawIntegerMultiple": 1E-8,
759
+ // "isDefault": true,
760
+ // "depositEnable": true,
761
+ // "withdrawEnable": true,
762
+ // "depositDesc": null,
763
+ // "withdrawDesc": null,
764
+ // "name": "BTC",
765
+ // "withdrawFee": "0.00016",
766
+ // "withdrawMin": "0.002",
767
+ // "depositDust": "0.00001",
768
+ // "minConfirm": 3,
769
+ // "withdrawTag": false,
770
+ // "contractAddressUrl": "https://www.blockchain.com/explorer/mempool/",
771
+ // "contractAddress": "btc"
772
+ // },
773
+ // {
774
+ // "network": "BEP20(BSC)",
775
+ // "coin": "BTC",
776
+ // "withdrawIntegerMultiple": 1E-8,
777
+ // "isDefault": false,
778
+ // "depositEnable": true,
779
+ // "withdrawEnable": false,
780
+ // "depositDesc": null,
781
+ // "withdrawDesc": null,
782
+ // "name": "BEP20(BSC)",
783
+ // "withdrawFee": "0.00001",
784
+ // "withdrawMin": "0.00006",
785
+ // "depositDust": "0.00003",
786
+ // "minConfirm": 61,
787
+ // "withdrawTag": false,
788
+ // "contractAddressUrl": "",
789
+ // "contractAddress": ""
790
+ // }
791
+ // ]
792
+ // },
793
+ // {
794
+ // "coin": "USDT",
795
+ // "depositAllEnable": true,
796
+ // "withdrawAllEnable": true,
797
+ // "name": "USDT",
798
+ // "networkList": [
799
+ // {
800
+ // "network": "TRC20",
801
+ // "coin": "USDT",
802
+ // "withdrawIntegerMultiple": 1E-8,
803
+ // "isDefault": true,
804
+ // "depositEnable": true,
805
+ // "withdrawEnable": true,
806
+ // "depositDesc": null,
807
+ // "withdrawDesc": null,
808
+ // "name": "TRC20",
809
+ // "withdrawFee": "1.5",
810
+ // "withdrawMin": "10",
811
+ // "depositDust": "0.1",
812
+ // "minConfirm": 20,
813
+ // "withdrawTag": false,
814
+ // "contractAddressUrl": "https://tronscan.org/#/token20/",
815
+ // "contractAddress": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
816
+ // },
817
+ // {
818
+ // "network": "ERC20",
819
+ // "coin": "USDT",
820
+ // "withdrawIntegerMultiple": 1E-8,
821
+ // "isDefault": false,
822
+ // "depositEnable": true,
823
+ // "withdrawEnable": true,
824
+ // "depositDesc": null,
825
+ // "withdrawDesc": null,
826
+ // "name": "ERC20",
827
+ // "withdrawFee": "1",
828
+ // "withdrawMin": "20",
829
+ // "depositDust": "0.1",
830
+ // "minConfirm": 12,
831
+ // "withdrawTag": false,
832
+ // "contractAddressUrl": "https://etherscan.io/token/",
833
+ // "contractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7"
834
+ // },
835
+ // {
836
+ // "network": "AVALANCHE_C(AVAX_C)",
837
+ // "coin": "USDT",
838
+ // "withdrawIntegerMultiple": 1E-8,
839
+ // "isDefault": false,
840
+ // "depositEnable": true,
841
+ // "withdrawEnable": true,
842
+ // "depositDesc": null,
843
+ // "withdrawDesc": null,
844
+ // "name": "AVALANCHE_C(AVAX_C)",
845
+ // "withdrawFee": "0.5",
846
+ // "withdrawMin": "10",
847
+ // "depositDust": "0.1",
848
+ // "minConfirm": 35,
849
+ // "withdrawTag": false,
850
+ // "contractAddressUrl": "https://avascan.info/blockchain/c/token/",
851
+ // "contractAddress": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"
852
+ // }
853
+ // ]
854
+ // }
855
+ // ]
856
+ //
857
+ const result = {};
858
+ for (let i = 0; i < response.length; i++) {
859
+ const currency = this.safeDict(response, i);
860
+ const currencyId = this.safeString(currency, 'coin');
861
+ const code = this.safeCurrencyCode(currencyId);
862
+ const name = this.safeString(currency, 'name');
863
+ const networks = {};
864
+ const chains = this.safeList(currency, 'networkList', []);
865
+ for (let j = 0; j < chains.length; j++) {
866
+ const chain = this.safeDict(chains, j);
867
+ const networkId = this.safeString(chain, 'network');
868
+ const networkCode = this.networkIdToCode(networkId);
869
+ networks[networkCode] = {
870
+ 'info': chain,
871
+ 'id': networkId,
872
+ 'network': networkCode,
873
+ 'active': undefined,
874
+ 'deposit': this.safeBool(chain, 'depositEnable'),
875
+ 'withdraw': this.safeBool(chain, 'withdrawEnable'),
876
+ 'fee': this.safeNumber(chain, 'withdrawFee'),
877
+ 'precision': this.safeNumber(chain, 'withdrawIntegerMultiple'),
878
+ 'isDefault': this.safeBool(chain, 'isDefault', false),
879
+ 'limits': {
880
+ 'withdraw': {
881
+ 'min': this.safeNumber(chain, 'withdrawMin'),
882
+ 'max': undefined,
883
+ },
884
+ 'deposit': {
885
+ 'min': this.safeNumber(chain, 'depositDust'),
886
+ 'max': undefined,
887
+ },
888
+ },
889
+ };
890
+ }
891
+ const networkKeys = Object.keys(networks);
892
+ const networksLength = networkKeys.length;
893
+ const emptyChains = networksLength === 0; // non-functional coins
894
+ const valueForEmpty = emptyChains ? false : undefined;
895
+ result[code] = this.safeCurrencyStructure({
896
+ 'info': currency,
897
+ 'code': code,
898
+ 'id': currencyId,
899
+ 'type': 'crypto',
900
+ 'name': name,
901
+ 'active': undefined,
902
+ 'deposit': valueForEmpty,
903
+ 'withdraw': valueForEmpty,
904
+ 'fee': undefined,
905
+ 'precision': undefined,
906
+ 'limits': {
907
+ 'amount': {
908
+ 'min': undefined,
909
+ 'max': undefined,
910
+ },
911
+ 'withdraw': {
912
+ 'min': undefined,
913
+ 'max': undefined,
914
+ },
915
+ 'deposit': {
916
+ 'min': undefined,
917
+ 'max': undefined,
918
+ },
919
+ },
920
+ 'networks': networks,
921
+ });
922
+ }
923
+ return result;
924
+ }
925
+ /**
926
+ * @method
927
+ * @name weex#fetchMarkets
928
+ * @description retrieves data on all markets for exchagne
929
+ * @see https://www.weex.com/api-doc/spot/ConfigAPI/GetProductInfo // spot
930
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetContractInfo // contract
931
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
932
+ * @returns {object[]} an array of objects representing market data
933
+ */
934
+ async fetchMarkets(params = {}) {
935
+ if (this.options['adjustForTimeDifference']) {
936
+ await this.loadTimeDifference();
937
+ }
938
+ const promises = [
939
+ this.publicGetApiV3ExchangeInfo(params),
940
+ this.contractGetCapiV3MarketExchangeInfo(params),
941
+ ];
942
+ const [spotResponse, contractResponse] = await Promise.all(promises);
943
+ const spotArray = this.safeList(spotResponse, 'symbols', []);
944
+ const contractArray = this.safeList(contractResponse, 'symbols', []);
945
+ const result = this.arrayConcat(spotArray, contractArray);
946
+ return this.parseMarkets(result);
947
+ }
948
+ parseMarket(market) {
949
+ //
950
+ // spot
951
+ // {
952
+ // "symbol": "ETHUSDT",
953
+ // "status": "TRADING",
954
+ // "baseAsset": "ETH",
955
+ // "baseAssetPrecision": "8",
956
+ // "quoteAsset": "USDT",
957
+ // "quoteAssetPrecision": "8",
958
+ // "tickSize": "0.01",
959
+ // "stepSize": "0.00001",
960
+ // "minTradeAmount": "0.0001",
961
+ // "maxTradeAmount": "99999",
962
+ // "takerFeeRate": "0.001",
963
+ // "makerFeeRate": "0.001",
964
+ // "buyLimitPriceRatio": "0.1",
965
+ // "sellLimitPriceRatio": "0.1",
966
+ // "marketBuyLimitSize": "99999",
967
+ // "marketSellLimitSize": "99999",
968
+ // "marketFallbackPriceRatio": "0",
969
+ // "enableTrade": true,
970
+ // "enableDisplay": true,
971
+ // "displayDigitMerge": "0.01,0.1,0.5,1,5",
972
+ // "displayNew": false,
973
+ // "displayHot": false
974
+ // }
975
+ //
976
+ // contract
977
+ // {
978
+ // "symbol": "ETHUSDT",
979
+ // "baseAsset": "ETH",
980
+ // "quoteAsset": "USDT",
981
+ // "marginAsset": "USDT",
982
+ // "pricePrecision": "2",
983
+ // "quantityPrecision": "3",
984
+ // "baseAssetPrecision": "2",
985
+ // "quotePrecision": "8",
986
+ // "contractVal": "0.001",
987
+ // "delivery": [
988
+ // "00:00:00",
989
+ // "08:00:00",
990
+ // "16:00:00"
991
+ // ],
992
+ // "forwardContractFlag": true,
993
+ // "minLeverage": "1",
994
+ // "maxLeverage": "400",
995
+ // "buyLimitPriceRatio": "0.01",
996
+ // "sellLimitPriceRatio": "0.01",
997
+ // "makerFeeRate": "0.0002",
998
+ // "takerFeeRate": "0.0008",
999
+ // "minOrderSize": "0.001",
1000
+ // "maxOrderSize": "1000000",
1001
+ // "maxPositionSize": "5000000",
1002
+ // "marketOpenLimitSize": "2300"
1003
+ // }
1004
+ //
1005
+ const id = this.safeString(market, 'symbol');
1006
+ const baseId = this.safeString(market, 'baseAsset');
1007
+ const quoteId = this.safeString(market, 'quoteAsset');
1008
+ const settleId = this.safeString(market, 'marginAsset');
1009
+ const base = this.safeCurrencyCode(baseId);
1010
+ const quote = this.safeCurrencyCode(quoteId);
1011
+ const settle = this.safeCurrencyCode(settleId);
1012
+ let active = true;
1013
+ let symbol = base + '/' + quote;
1014
+ let isSpot = true;
1015
+ let isLinear = undefined;
1016
+ let isInverse = undefined;
1017
+ if (settle !== undefined) {
1018
+ symbol += ':' + settle;
1019
+ isSpot = false;
1020
+ if (settle === quote) {
1021
+ isLinear = true;
1022
+ isInverse = false;
1023
+ }
1024
+ else if (settle === base) {
1025
+ isLinear = false;
1026
+ isInverse = true;
1027
+ }
1028
+ }
1029
+ else {
1030
+ active = this.safeBool(market, 'enableTrade');
1031
+ }
1032
+ let amountPrecision = this.safeNumber(market, 'stepSize');
1033
+ let pricePrecision = this.safeNumber(market, 'tickSize');
1034
+ if (amountPrecision === undefined) {
1035
+ const amountPrecisionString = this.parsePrecision(this.safeString(market, 'quantityPrecision'));
1036
+ const pricePrecisionString = this.parsePrecision(this.safeString(market, 'pricePrecision'));
1037
+ amountPrecision = this.parseNumber(amountPrecisionString);
1038
+ pricePrecision = this.parseNumber(pricePrecisionString);
1039
+ }
1040
+ const fees = this.safeDict(this.fees, isSpot ? 'spot' : 'contract', {});
1041
+ return this.safeMarketStructure({
1042
+ 'id': id,
1043
+ 'lowercaseId': id.toLowerCase(),
1044
+ 'numericId': this.safeInteger(market, 'contractId'),
1045
+ 'symbol': symbol,
1046
+ 'base': base,
1047
+ 'quote': quote,
1048
+ 'settle': settle,
1049
+ 'baseId': baseId,
1050
+ 'quoteId': quoteId,
1051
+ 'settleId': settleId,
1052
+ 'type': isSpot ? 'spot' : 'swap',
1053
+ 'spot': isSpot,
1054
+ 'margin': false,
1055
+ 'swap': !isSpot,
1056
+ 'future': false,
1057
+ 'option': false,
1058
+ 'active': active,
1059
+ 'contract': !isSpot,
1060
+ 'linear': isLinear,
1061
+ 'inverse': isInverse,
1062
+ 'taker': this.safeNumber(market, 'takerFeeRate'),
1063
+ 'maker': this.safeNumber(market, 'makerFeeRate'),
1064
+ 'feeSide': fees['feeSide'],
1065
+ 'contractSize': this.safeNumber(market, 'contractVal'),
1066
+ 'expiry': undefined,
1067
+ 'expiryDatetime': undefined,
1068
+ 'strike': undefined,
1069
+ 'optionType': undefined,
1070
+ 'precision': {
1071
+ 'amount': amountPrecision,
1072
+ 'price': pricePrecision,
1073
+ },
1074
+ 'limits': {
1075
+ 'leverage': {
1076
+ 'min': this.safeNumber(market, 'minLeverage'),
1077
+ 'max': this.safeNumber(market, 'maxLeverage'),
1078
+ },
1079
+ 'amount': {
1080
+ 'min': this.safeNumber2(market, 'minTradeAmount', 'minOrderSize'),
1081
+ 'max': this.safeNumber2(market, 'maxTradeAmount', 'maxOrderSize'),
1082
+ },
1083
+ 'price': {
1084
+ 'min': undefined,
1085
+ 'max': undefined,
1086
+ },
1087
+ 'cost': {
1088
+ 'min': undefined,
1089
+ 'max': undefined,
1090
+ },
1091
+ },
1092
+ 'created': undefined,
1093
+ 'percentage': fees['percentage'],
1094
+ 'tierBased': fees['tierBased'],
1095
+ 'tiers': fees['tiers'],
1096
+ 'info': market,
1097
+ });
1098
+ }
1099
+ /**
1100
+ * @method
1101
+ * @name weex#fetchTickers
1102
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1103
+ * @see https://www.weex.com/api-doc/spot/MarketDataAPI/GetAllTickerInfo // spot
1104
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetTicker24h // contract
1105
+ * @param {string} symbols unified symbol of the market to fetch the ticker for
1106
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1107
+ * @param {string} [params.type] 'spot' or 'swap', default is 'spot' (used if symbols are not provided)
1108
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
1109
+ */
1110
+ async fetchTickers(symbols = undefined, params = {}) {
1111
+ await this.loadMarkets();
1112
+ symbols = this.marketSymbols(symbols, undefined, true, true);
1113
+ const market = this.getMarketFromSymbols(symbols);
1114
+ let marketType = undefined;
1115
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
1116
+ let symbolsLength = 0;
1117
+ if (symbols !== undefined) {
1118
+ symbolsLength = symbols.length;
1119
+ }
1120
+ const request = {};
1121
+ if (symbolsLength === 1) {
1122
+ request['symbol'] = market['id'];
1123
+ }
1124
+ let response = undefined;
1125
+ if (marketType === 'spot') {
1126
+ //
1127
+ // [
1128
+ // {
1129
+ // "symbol": "ETHUSDT",
1130
+ // "priceChange": "-72.98",
1131
+ // "priceChangePercent": "-0.033811",
1132
+ // "lastPrice": "2085.46",
1133
+ // "bidPrice": "2085.44",
1134
+ // "bidQty": "1.53848",
1135
+ // "askPrice": "2085.47",
1136
+ // "askQty": "1.87504",
1137
+ // "openPrice": "2158.44",
1138
+ // "highPrice": "2168.40",
1139
+ // "lowPrice": "2061.12",
1140
+ // "volume": "157359.56105",
1141
+ // "quoteVolume": "331284305.7193626",
1142
+ // "openTime": 1775493000000,
1143
+ // "closeTime": 1775579400000,
1144
+ // "count": 59727
1145
+ // }
1146
+ // ]
1147
+ //
1148
+ response = await this.publicGetApiV3MarketTicker24hr(this.extend(request, params));
1149
+ }
1150
+ else {
1151
+ //
1152
+ // [
1153
+ // {
1154
+ // "symbol": "ETHUSDT",
1155
+ // "priceChange": "-75.49",
1156
+ // "priceChangePercent": "-0.034992",
1157
+ // "lastPrice": "2081.80",
1158
+ // "openPrice": "2157.29",
1159
+ // "highPrice": "2167.51",
1160
+ // "lowPrice": "2059.17",
1161
+ // "volume": "623160.426",
1162
+ // "quoteVolume": "1310647345.19346",
1163
+ // "openTime": 1775493000000,
1164
+ // "closeTime": 1775579400000,
1165
+ // "markPrice": "2081.8",
1166
+ // "indexPrice": "2082.75"
1167
+ // }
1168
+ // ]
1169
+ //
1170
+ response = await this.contractGetCapiV3MarketTicker24hr(this.extend(request, params));
1171
+ }
1172
+ if (!Array.isArray(response)) {
1173
+ response = [response];
1174
+ }
1175
+ return this.parseTickers(response, symbols);
1176
+ }
1177
+ /**
1178
+ * @method
1179
+ * @name weex#fetchBidsAsks
1180
+ * @description fetches the bid and ask price and volume for multiple markets
1181
+ * @see https://www.weex.com/api-doc/spot/MarketDataAPI/GetBookTicker // spot
1182
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetBookTicker // contract
1183
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
1184
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1185
+ * @param {string} [params.type] 'spot' or 'swap', default is 'spot' (used if symbols are not provided)
1186
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
1187
+ */
1188
+ async fetchBidsAsks(symbols = undefined, params = {}) {
1189
+ symbols = this.marketSymbols(symbols, undefined, true, true);
1190
+ const market = this.getMarketFromSymbols(symbols);
1191
+ let marketType = undefined;
1192
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
1193
+ let response = undefined;
1194
+ if (marketType === 'spot') {
1195
+ response = await this.publicGetApiV3MarketTickerBookTicker(params);
1196
+ }
1197
+ else {
1198
+ response = await this.contractGetCapiV3MarketTickerBookTicker(params);
1199
+ }
1200
+ if (!Array.isArray(response)) {
1201
+ response = [response];
1202
+ }
1203
+ return this.parseTickers(response, symbols);
1204
+ }
1205
+ parseTicker(ticker, market = undefined) {
1206
+ //
1207
+ // spot
1208
+ // {
1209
+ // "symbol": "ETHUSDT",
1210
+ // "priceChange": "-72.98",
1211
+ // "priceChangePercent": "-0.033811",
1212
+ // "lastPrice": "2085.46",
1213
+ // "bidPrice": "2085.44",
1214
+ // "bidQty": "1.53848",
1215
+ // "askPrice": "2085.47",
1216
+ // "askQty": "1.87504",
1217
+ // "openPrice": "2158.44",
1218
+ // "highPrice": "2168.40",
1219
+ // "lowPrice": "2061.12",
1220
+ // "volume": "157359.56105",
1221
+ // "quoteVolume": "331284305.7193626",
1222
+ // "openTime": 1775493000000,
1223
+ // "closeTime": 1775579400000,
1224
+ // "count": 59727
1225
+ // }
1226
+ //
1227
+ // swap
1228
+ // {
1229
+ // "symbol": "ETHUSDT",
1230
+ // "priceChange": "-75.49",
1231
+ // "priceChangePercent": "-0.034992",
1232
+ // "lastPrice": "2081.80",
1233
+ // "openPrice": "2157.29",
1234
+ // "highPrice": "2167.51",
1235
+ // "lowPrice": "2059.17",
1236
+ // "volume": "623160.426",
1237
+ // "quoteVolume": "1310647345.19346",
1238
+ // "openTime": 1775493000000,
1239
+ // "closeTime": 1775579400000,
1240
+ // "markPrice": "2081.8",
1241
+ // "indexPrice": "2082.75"
1242
+ // }
1243
+ //
1244
+ const marketId = this.safeString(ticker, 'symbol');
1245
+ const markPrice = this.safeString(ticker, 'markPrice');
1246
+ let marketType = 'spot';
1247
+ if (markPrice !== undefined) {
1248
+ marketType = 'swap';
1249
+ }
1250
+ market = this.safeMarket(marketId, market, undefined, marketType);
1251
+ const timestamp = this.safeInteger2(ticker, 'closeTime', 'time');
1252
+ return this.safeTicker({
1253
+ 'symbol': market['symbol'],
1254
+ 'timestamp': timestamp,
1255
+ 'datetime': this.iso8601(timestamp),
1256
+ 'high': this.safeString(ticker, 'highPrice'),
1257
+ 'low': this.safeString(ticker, 'lowPrice'),
1258
+ 'bid': this.safeString(ticker, 'bidPrice'),
1259
+ 'bidVolume': this.safeString(ticker, 'bidQty'),
1260
+ 'ask': this.safeString(ticker, 'askPrice'),
1261
+ 'askVolume': this.safeString(ticker, 'askQty'),
1262
+ 'vwap': undefined,
1263
+ 'open': this.safeString(ticker, 'openPrice'),
1264
+ 'close': this.safeString(ticker, 'lastPrice'),
1265
+ 'last': this.safeString(ticker, 'lastPrice'),
1266
+ 'previousClose': undefined,
1267
+ 'change': this.safeString(ticker, 'priceChange'),
1268
+ 'percentage': this.safeString(ticker, 'priceChangePercent'),
1269
+ 'average': undefined,
1270
+ 'baseVolume': this.safeString(ticker, 'volume'),
1271
+ 'quoteVolume': this.safeString(ticker, 'quoteVolume'),
1272
+ 'markPrice': markPrice,
1273
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
1274
+ 'info': ticker,
1275
+ }, market);
1276
+ }
1277
+ /**
1278
+ * @method
1279
+ * @name weex#fetchOrderBook
1280
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1281
+ * @see https://www.weex.com/api-doc/spot/MarketDataAPI/GetDepthData // spot
1282
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetDepthData // contract
1283
+ * @param {string} symbol unified symbol of the market to fetch the order book for
1284
+ * @param {int} [limit] the maximum amount of order book entries to return (default 15, max 200)
1285
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1286
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
1287
+ */
1288
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
1289
+ await this.loadMarkets();
1290
+ const market = this.market(symbol);
1291
+ const request = {
1292
+ 'symbol': market['id'],
1293
+ };
1294
+ if ((limit !== undefined) && (limit > 15)) {
1295
+ request['limit'] = 200; // default is 15, max is 200
1296
+ }
1297
+ let response = undefined;
1298
+ if (market['spot']) {
1299
+ response = await this.publicGetApiV3MarketDepth(this.extend(request, params));
1300
+ }
1301
+ else {
1302
+ response = await this.contractGetCapiV3MarketDepth(this.extend(request, params));
1303
+ }
1304
+ //
1305
+ // {
1306
+ // "asks": [
1307
+ // [
1308
+ // "2096.77",
1309
+ // "45.592"
1310
+ // ]
1311
+ // ],
1312
+ // "bids": [
1313
+ // [
1314
+ // "2096.76",
1315
+ // "49.162"
1316
+ // ]
1317
+ // ],
1318
+ // "lastUpdateId": 14138610208
1319
+ // }
1320
+ //
1321
+ const orderbook = this.parseOrderBook(response, symbol);
1322
+ orderbook['nonce'] = this.safeInteger(response, 'lastUpdateId');
1323
+ return orderbook;
1324
+ }
1325
+ /**
1326
+ * @method
1327
+ * @name weex#fetchOHLCV
1328
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1329
+ * @see https://www.weex.com/api-doc/spot/MarketDataAPI/GetKLineData // spot
1330
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetKlines // contract last price
1331
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetIndexPriceKlines // contract index price
1332
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetMarkPriceKlines // contract mark price
1333
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetHistoryKlines // contract historical klines
1334
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1335
+ * @param {string} timeframe the length of time each candle represents
1336
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1337
+ * @param {int} [limit] the maximum amount of candles to fetch (default 100, max 300)
1338
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1339
+ * Check fetchSpotOHLCV() and fetchContractOHLCV() for more details on the extra parameters that can be used in params
1340
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1341
+ */
1342
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1343
+ await this.loadMarkets();
1344
+ const market = this.market(symbol);
1345
+ if (market['spot']) {
1346
+ return await this.fetchSpotOHLCV(symbol, timeframe, since, limit, params);
1347
+ }
1348
+ else {
1349
+ return await this.fetchContractOHLCV(symbol, timeframe, since, limit, params);
1350
+ }
1351
+ }
1352
+ /**
1353
+ * @method
1354
+ * @ignore
1355
+ * @name weex#fetchSpotOHLCV
1356
+ * @description helper method for fetchOHLCV
1357
+ * @see https://www.weex.com/api-doc/spot/MarketDataAPI/GetKLineData
1358
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1359
+ * @param {string} timeframe the length of time each candle represents
1360
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1361
+ * @param {int} [limit] the maximum amount of candles to fetch
1362
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1363
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1364
+ */
1365
+ async fetchSpotOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1366
+ await this.loadMarkets();
1367
+ const market = this.market(symbol);
1368
+ const request = {
1369
+ 'symbol': market['id'],
1370
+ 'interval': this.safeString(this.timeframes, timeframe, timeframe),
1371
+ };
1372
+ const response = await this.publicGetApiV3MarketKlines(this.extend(request, params));
1373
+ return this.parseOHLCVs(response, market, timeframe, since, limit);
1374
+ }
1375
+ /**
1376
+ * @method
1377
+ * @ignore
1378
+ * @name weex#fetchContractOHLCV
1379
+ * @description helper method for fetchOHLCV
1380
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetKlines // contract last price
1381
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetIndexPriceKlines // contract index price
1382
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetMarkPriceKlines // contract mark price
1383
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetHistoryKlines // contract historical klines
1384
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1385
+ * @param {string} timeframe the length of time each candle represents
1386
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1387
+ * @param {int} [limit] the maximum amount of candles to fetch (default 100, max 100 for historical klines, max 1000 for other contract klines)
1388
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1389
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch
1390
+ * @param {boolean} [params.paginate] whether to automatically paginate requests until the required number of candles is returned
1391
+ * @param {boolean} [params.historical] whether to fetch historical klines (default is false). If false, will fetch last price klines
1392
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1393
+ */
1394
+ async fetchContractOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1395
+ await this.loadMarkets();
1396
+ const maxHistoricalLimit = 100;
1397
+ let paginate = false;
1398
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
1399
+ if (paginate) {
1400
+ params = this.extend(params, { 'historical': true });
1401
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxHistoricalLimit);
1402
+ }
1403
+ const until = this.safeInteger(params, 'until');
1404
+ let historical = false;
1405
+ [historical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'historical');
1406
+ const timeframeOption = this.safeDict(this.options, 'timeframes', {});
1407
+ const contractTimeframes = this.safeDict(timeframeOption, 'contract', {});
1408
+ const market = this.market(symbol);
1409
+ const request = {
1410
+ 'symbol': market['id'],
1411
+ 'interval': this.safeString(contractTimeframes, timeframe, timeframe),
1412
+ };
1413
+ const priceType = this.safeStringUpper(params, 'price');
1414
+ params = this.omit(params, ['historical', 'until', 'price']);
1415
+ let response = undefined;
1416
+ if (historical) {
1417
+ if (priceType !== undefined) {
1418
+ request['priceType'] = priceType;
1419
+ }
1420
+ let startTime = since;
1421
+ let endTime = until;
1422
+ if ((since === undefined) || (until === undefined)) {
1423
+ const now = this.milliseconds();
1424
+ const duration = this.parseTimeframe(timeframe) * 1000;
1425
+ const numberOfCandles = limit ? limit : maxHistoricalLimit;
1426
+ const timeDelta = numberOfCandles * duration;
1427
+ if ((since === undefined) && (until === undefined)) {
1428
+ endTime = now;
1429
+ startTime = now - timeDelta;
1430
+ }
1431
+ else if (since === undefined) {
1432
+ startTime = until - timeDelta;
1433
+ }
1434
+ else {
1435
+ endTime = since + timeDelta;
1436
+ }
1437
+ }
1438
+ request['startTime'] = startTime;
1439
+ request['endTime'] = endTime;
1440
+ response = await this.contractGetCapiV3MarketHistoryKlines(this.extend(request, params));
1441
+ }
1442
+ else {
1443
+ if (limit !== undefined) {
1444
+ request['limit'] = limit;
1445
+ }
1446
+ if (priceType === 'MARK') {
1447
+ response = await this.contractGetCapiV3MarketMarkPriceKlines(this.extend(request, params));
1448
+ }
1449
+ else if (priceType === 'INDEX') {
1450
+ response = await this.contractGetCapiV3MarketIndexPriceKlines(this.extend(request, params));
1451
+ }
1452
+ else {
1453
+ response = await this.contractGetCapiV3MarketKlines(this.extend(request, params));
1454
+ }
1455
+ }
1456
+ return this.parseOHLCVs(response, market, timeframe, since, limit);
1457
+ }
1458
+ parseOHLCV(ohlcv, market = undefined) {
1459
+ return [
1460
+ this.safeInteger(ohlcv, 0),
1461
+ this.safeNumber(ohlcv, 1),
1462
+ this.safeNumber(ohlcv, 2),
1463
+ this.safeNumber(ohlcv, 3),
1464
+ this.safeNumber(ohlcv, 4),
1465
+ this.safeNumber(ohlcv, 5),
1466
+ ];
1467
+ }
1468
+ /**
1469
+ * @method
1470
+ * @name weex#fetchTrades
1471
+ * @description get the list of most recent trades for a particular symbol
1472
+ * @see https://www.weex.com/api-doc/spot/MarketDataAPI/GetTradeData // spot
1473
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetRecentTrades // contract
1474
+ * @param {string} symbol unified symbol of the market to fetch trades for
1475
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1476
+ * @param {int} [limit] the maximum amount of trades to fetch (default 100, max 1000)
1477
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1478
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
1479
+ */
1480
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1481
+ await this.loadMarkets();
1482
+ const market = this.market(symbol);
1483
+ const request = {
1484
+ 'symbol': market['id'],
1485
+ };
1486
+ if (limit !== undefined) {
1487
+ request['limit'] = limit;
1488
+ }
1489
+ let response = undefined;
1490
+ if (market['spot']) {
1491
+ response = await this.publicGetApiV3MarketTrades(this.extend(request, params));
1492
+ }
1493
+ else {
1494
+ response = await this.contractGetCapiV3MarketTrades(this.extend(request, params));
1495
+ }
1496
+ //
1497
+ // [
1498
+ // {
1499
+ // "id": "875fba11-f8a1-42ad-915d-012ccb375e8a",
1500
+ // "price": "2114.77",
1501
+ // "qty": "0.01000",
1502
+ // "quoteQty": "21.1477000",
1503
+ // "time": 1775594995485,
1504
+ // "isBuyerMaker": false,
1505
+ // "isBestMatch": true
1506
+ // }
1507
+ // ]
1508
+ //
1509
+ return this.parseTrades(response, market, since, limit);
1510
+ }
1511
+ parseTrade(trade, market = undefined) {
1512
+ //
1513
+ // fetchTrades
1514
+ // {
1515
+ // "id": "875fba11-f8a1-42ad-915d-012ccb375e8a",
1516
+ // "price": "2114.77",
1517
+ // "qty": "0.01000",
1518
+ // "quoteQty": "21.1477000",
1519
+ // "time": 1775594995485,
1520
+ // "isBuyerMaker": false,
1521
+ // "isBestMatch": true
1522
+ // }
1523
+ //
1524
+ // fetchMyTrades (spot)
1525
+ // {
1526
+ // "symbol": "DOGEUSDT",
1527
+ // "id": 736825748291060702,
1528
+ // "orderId": 736825748215563230,
1529
+ // "price": "0.09349",
1530
+ // "qty": "250.0",
1531
+ // "quoteQty": "23.3725",
1532
+ // "commission": "0.0233725",
1533
+ // "time": 1775672947953,
1534
+ // "isBuyer": false
1535
+ // }
1536
+ //
1537
+ // fetchMyTrades (contract)
1538
+ // {
1539
+ // "id": 737074389731770728,
1540
+ // "orderId": 737074043320009064,
1541
+ // "symbol": "DOGEUSDT",
1542
+ // "buyer": true,
1543
+ // "commission": "0.00183500",
1544
+ // "commissionAsset": "USDT",
1545
+ // "maker": true,
1546
+ // "price": "0.09175",
1547
+ // "qty": "100",
1548
+ // "quoteQty": "9.17500",
1549
+ // "realizedPnl": "0",
1550
+ // "side": "BUY",
1551
+ // "positionSide": "LONG",
1552
+ // "time": 1775732228692
1553
+ // }
1554
+ //
1555
+ const timestamp = this.safeInteger(trade, 'time');
1556
+ const isBuyer = this.safeBool(trade, 'isBuyer');
1557
+ let side = this.safeStringLower(trade, 'side');
1558
+ if (isBuyer !== undefined) {
1559
+ side = isBuyer ? 'buy' : 'sell';
1560
+ }
1561
+ let isSpot = true;
1562
+ if (market === undefined) {
1563
+ const marketId = this.safeString(trade, 'symbol');
1564
+ const realizedPnl = this.safeString(trade, 'realizedPnl');
1565
+ const marketType = (realizedPnl !== undefined) ? 'swap' : 'spot';
1566
+ market = this.safeMarket(marketId, undefined, undefined, marketType);
1567
+ isSpot = marketType === 'spot';
1568
+ }
1569
+ else {
1570
+ isSpot = market['spot'];
1571
+ }
1572
+ let fee = undefined;
1573
+ const commission = this.safeString(trade, 'commission');
1574
+ if (commission !== undefined) {
1575
+ const commissionAsset = this.safeString(trade, 'commissionAsset');
1576
+ let feeCurrency = this.safeCurrencyCode(commissionAsset);
1577
+ if (isSpot) {
1578
+ if (side === 'buy') {
1579
+ feeCurrency = market['base'];
1580
+ }
1581
+ else {
1582
+ feeCurrency = market['quote'];
1583
+ }
1584
+ }
1585
+ fee = {
1586
+ 'cost': commission,
1587
+ 'currency': feeCurrency,
1588
+ };
1589
+ }
1590
+ const isMaker = this.safeBool(trade, 'maker');
1591
+ let takerOrMaker = undefined;
1592
+ if (isMaker !== undefined) {
1593
+ takerOrMaker = isMaker ? 'maker' : 'taker';
1594
+ }
1595
+ return this.safeTrade({
1596
+ 'info': trade,
1597
+ 'id': this.safeString(trade, 'id'),
1598
+ 'order': this.safeString(trade, 'orderId'),
1599
+ 'timestamp': timestamp,
1600
+ 'datetime': this.iso8601(timestamp),
1601
+ 'symbol': market['symbol'],
1602
+ 'type': undefined,
1603
+ 'takerOrMaker': takerOrMaker,
1604
+ 'side': side,
1605
+ 'price': this.safeString(trade, 'price'),
1606
+ 'amount': this.safeString(trade, 'qty'),
1607
+ 'cost': this.safeString(trade, 'quoteQty'),
1608
+ 'fee': fee,
1609
+ }, market);
1610
+ }
1611
+ /**
1612
+ * @method
1613
+ * @name weex#fetchOpenInterest
1614
+ * @description retrieves the open interest of a contract trading pair
1615
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetOpenInterest
1616
+ * @param {string} symbol unified CCXT market symbol
1617
+ * @param {object} [params] exchange specific parameters
1618
+ * @returns {object} an open interest structure{@link https://docs.ccxt.com/?id=open-interest-structure}
1619
+ */
1620
+ async fetchOpenInterest(symbol, params = {}) {
1621
+ await this.loadMarkets();
1622
+ const market = this.market(symbol);
1623
+ const request = {
1624
+ 'symbol': market['id'],
1625
+ };
1626
+ const response = await this.contractGetCapiV3MarketOpenInterest(this.extend(request, params));
1627
+ return this.parseOpenInterest(response, market);
1628
+ }
1629
+ parseOpenInterest(interest, market = undefined) {
1630
+ //
1631
+ // {
1632
+ // "symbol": "ETHUSDT",
1633
+ // "openInterest": "1772356.352",
1634
+ // "time": 1775595582598
1635
+ // }
1636
+ //
1637
+ const marketId = this.safeString(interest, 'symbol');
1638
+ const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
1639
+ const timestamp = this.safeInteger(interest, 'time');
1640
+ return this.safeOpenInterest({
1641
+ 'symbol': symbol,
1642
+ 'openInterestAmount': this.safeString(interest, 'openInterest'),
1643
+ 'openInterestValue': undefined,
1644
+ 'timestamp': timestamp,
1645
+ 'datetime': this.iso8601(timestamp),
1646
+ 'info': interest,
1647
+ }, market);
1648
+ }
1649
+ /**
1650
+ * @method
1651
+ * @name weex#fetchFundingRates
1652
+ * @description fetch the funding rate for multiple markets
1653
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetCurrentFundingRate
1654
+ * @param {string[]|undefined} symbols list of unified market symbols
1655
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1656
+ * @param {string} [params.subType] "linear" or "inverse"
1657
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
1658
+ */
1659
+ async fetchFundingRates(symbols = undefined, params = {}) {
1660
+ await this.loadMarkets();
1661
+ symbols = this.marketSymbols(symbols);
1662
+ let symbolsLength = 0;
1663
+ if (symbols !== undefined) {
1664
+ symbolsLength = symbols.length;
1665
+ }
1666
+ const request = {};
1667
+ if (symbolsLength === 1) {
1668
+ const market = this.getMarketFromSymbols(symbols);
1669
+ request['symbol'] = market['id'];
1670
+ }
1671
+ const response = await this.contractGetCapiV3MarketPremiumIndex(this.extend(request, params));
1672
+ //
1673
+ // [
1674
+ // {
1675
+ // "symbol": "ETHUSDT",
1676
+ // "markPrice": "2133.71",
1677
+ // "indexPrice": "2134.44",
1678
+ // "forecastFundingRate": "0.00005618",
1679
+ // "lastFundingRate": "0.00001031",
1680
+ // "interestRate": "0.001",
1681
+ // "nextFundingTime": 1775606400000,
1682
+ // "time": 1775597594265,
1683
+ // "collectCycle": 480
1684
+ // }
1685
+ // ]
1686
+ //
1687
+ return this.parseFundingRates(response, symbols);
1688
+ }
1689
+ parseFundingRate(contract, market = undefined) {
1690
+ const marketId = this.safeString(contract, 'symbol');
1691
+ const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
1692
+ const timestamp = this.safeInteger(contract, 'time');
1693
+ const nextFundingTimestamp = this.safeInteger(contract, 'nextFundingTime');
1694
+ let interval = undefined;
1695
+ const collectCycle = this.safeString(contract, 'collectCycle');
1696
+ if (collectCycle !== undefined) {
1697
+ interval = Precise.stringDiv(collectCycle, '60');
1698
+ interval = interval + 'h';
1699
+ }
1700
+ return {
1701
+ 'info': contract,
1702
+ 'symbol': symbol,
1703
+ 'markPrice': this.safeNumber(contract, 'markPrice'),
1704
+ 'indexPrice': this.safeNumber(contract, 'indexPrice'),
1705
+ 'interestRate': this.safeNumber(contract, 'interestRate'),
1706
+ 'estimatedSettlePrice': undefined,
1707
+ 'timestamp': timestamp,
1708
+ 'datetime': this.iso8601(timestamp),
1709
+ 'fundingRate': this.safeNumber(contract, 'lastFundingRate'),
1710
+ 'fundingTimestamp': timestamp,
1711
+ 'fundingDatetime': this.iso8601(timestamp),
1712
+ 'nextFundingRate': this.safeNumber(contract, 'forecastFundingRate'),
1713
+ 'nextFundingTimestamp': nextFundingTimestamp,
1714
+ 'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
1715
+ 'previousFundingRate': undefined,
1716
+ 'previousFundingTimestamp': undefined,
1717
+ 'previousFundingDatetime': undefined,
1718
+ 'interval': interval,
1719
+ };
1720
+ }
1721
+ /**
1722
+ * @method
1723
+ * @name weex#fetchFundingRateHistory
1724
+ * @description fetches historical funding rate prices
1725
+ * @see https://www.weex.com/api-doc/contract/Market_API/GetFundingRateHistory
1726
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
1727
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1728
+ * @param {int} [limit] the maximum amount of funding rate records to fetch (default 100, max 1000)
1729
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1730
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
1731
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure}
1732
+ */
1733
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1734
+ if (symbol === undefined) {
1735
+ throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
1736
+ }
1737
+ await this.loadMarkets();
1738
+ const market = this.market(symbol);
1739
+ let request = {
1740
+ 'symbol': market['id'],
1741
+ };
1742
+ if (since !== undefined) {
1743
+ request['startTime'] = since;
1744
+ }
1745
+ if (limit !== undefined) {
1746
+ request['limit'] = limit;
1747
+ }
1748
+ [request, params] = this.handleUntilOption('endTime', request, params);
1749
+ const response = await this.contractGetCapiV3MarketFundingRate(this.extend(request, params));
1750
+ return this.parseFundingRateHistories(response, market, since, limit);
1751
+ }
1752
+ parseFundingRateHistory(contract, market = undefined) {
1753
+ //
1754
+ // {
1755
+ // "symbol": "ETHUSDT",
1756
+ // "fundingRate": "0.00001031",
1757
+ // "fundingTime": 1775577600000,
1758
+ // "markPrice": "2079.26"
1759
+ // }
1760
+ //
1761
+ const marketId = this.safeString(contract, 'symbol');
1762
+ const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
1763
+ const timestamp = this.safeInteger(contract, 'fundingTime');
1764
+ return {
1765
+ 'info': contract,
1766
+ 'symbol': symbol,
1767
+ 'fundingRate': this.safeNumber(contract, 'fundingRate'),
1768
+ 'timestamp': timestamp,
1769
+ 'datetime': this.iso8601(timestamp),
1770
+ };
1771
+ }
1772
+ /**
1773
+ * @method
1774
+ * @name weex#fetchBalance
1775
+ * @see https://www.weex.com/api-doc/spot/AccountAPI/GetAccountBalance // spot
1776
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetAccountBalance // contract
1777
+ * @description query for balance and get the amount of funds available for trading or funds locked in positions
1778
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1779
+ * @param {string} [params.type] 'spot' or 'swap' (default is 'spot')
1780
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1781
+ */
1782
+ async fetchBalance(params = {}) {
1783
+ let type = undefined;
1784
+ [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1785
+ let response = undefined;
1786
+ if (type === 'spot') {
1787
+ //
1788
+ // {
1789
+ // "makerCommission": 0,
1790
+ // "takerCommission": 0,
1791
+ // "commissionRates": {
1792
+ // "maker": "0.00000000",
1793
+ // "taker": "0.00000000"
1794
+ // },
1795
+ // "canTrade": true,
1796
+ // "canWithdraw": true,
1797
+ // "canDeposit": true,
1798
+ // "updateTime": 1775601317093,
1799
+ // "accountType": "SPOT",
1800
+ // "balances": [
1801
+ // {
1802
+ // "asset": "USDT",
1803
+ // "free": "20.00000000",
1804
+ // "locked": "0"
1805
+ // }
1806
+ // ],
1807
+ // "permissions": [
1808
+ // "SPOT"
1809
+ // ],
1810
+ // "uid": 8886281669
1811
+ // }
1812
+ //
1813
+ response = await this.privateGetApiV3Account(params);
1814
+ }
1815
+ else {
1816
+ //
1817
+ // [
1818
+ // {
1819
+ // "asset": "USDT",
1820
+ // "balance": "20.00000000",
1821
+ // "availableBalance": "20.00000000",
1822
+ // "frozen": "0",
1823
+ // "unrealizePnl": "0"
1824
+ // }
1825
+ // ]
1826
+ //
1827
+ response = await this.contractPrivateGetCapiV3AccountBalance(params);
1828
+ }
1829
+ return this.parseBalance(response);
1830
+ }
1831
+ parseBalance(response) {
1832
+ const result = {
1833
+ 'info': response,
1834
+ };
1835
+ const balances = this.safeList(response, 'balances', response);
1836
+ for (let i = 0; i < balances.length; i++) {
1837
+ const entry = this.safeDict(balances, i);
1838
+ const id = this.safeString(entry, 'asset');
1839
+ const code = this.safeCurrencyCode(id);
1840
+ const account = this.account();
1841
+ account['free'] = this.safeString2(entry, 'availableBalance', 'free');
1842
+ account['used'] = this.safeString2(entry, 'frozen', 'locked');
1843
+ account['total'] = this.safeString(entry, 'balance');
1844
+ result[code] = account;
1845
+ }
1846
+ return this.safeBalance(result);
1847
+ }
1848
+ /**
1849
+ * @method
1850
+ * @name weex#fetchTransfers
1851
+ * @description fetch a history of internal transfers made on an account
1852
+ * @see https://www.weex.com/api-doc/spot/AccountAPI/TransferRecords
1853
+ * @param {string} [code] unified currency code of the currency transferred
1854
+ * @param {int} [since] the earliest time in ms to fetch transfers for
1855
+ * @param {int} [limit] the maximum number of transfers structures to retrieve (default 10, max 100)
1856
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1857
+ * @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)
1858
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
1859
+ */
1860
+ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
1861
+ await this.loadMarkets();
1862
+ let request = {};
1863
+ let currency = undefined;
1864
+ if (code !== undefined) {
1865
+ currency = this.currency(code);
1866
+ }
1867
+ const maxLimit = 100;
1868
+ let paginate = false;
1869
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate', false);
1870
+ if (paginate) {
1871
+ return await this.fetchPaginatedCallDynamic('fetchTransfers', code, since, limit, params, maxLimit);
1872
+ }
1873
+ if (since !== undefined) {
1874
+ request['after'] = since;
1875
+ }
1876
+ if (limit !== undefined) {
1877
+ request['limit'] = limit;
1878
+ }
1879
+ [request, params] = this.handleUntilOption('before', request, params);
1880
+ const response = await this.privateGetApiV3AccountTransferRecords(this.extend(request, params));
1881
+ //
1882
+ // [
1883
+ // {
1884
+ // "coinName": "USDT",
1885
+ // "status": "Successful",
1886
+ // "toType": "",
1887
+ // "toSymbol": "",
1888
+ // "fromType": "",
1889
+ // "fromSymbol": "",
1890
+ // "amount": "20.00000000",
1891
+ // "tradeTime": "1775605824252"
1892
+ // }
1893
+ // ]
1894
+ //
1895
+ return this.parseTransfers(response, currency, since, limit);
1896
+ }
1897
+ parseTransfer(transfer, currency = undefined) {
1898
+ const timestamp = this.safeInteger(transfer, 'tradeTime');
1899
+ const currencyId = this.safeString(transfer, 'coinName');
1900
+ const currencyCode = this.safeCurrencyCode(currencyId, currency);
1901
+ const status = this.safeString(transfer, 'status');
1902
+ return {
1903
+ 'info': transfer,
1904
+ 'id': undefined,
1905
+ 'timestamp': timestamp,
1906
+ 'datetime': this.iso8601(timestamp),
1907
+ 'currency': currencyCode,
1908
+ 'amount': this.safeNumber(transfer, 'amount'),
1909
+ 'fromAccount': this.safeStringLower(transfer, 'fromType'),
1910
+ 'toAccount': this.safeStringLower(transfer, 'toType'),
1911
+ 'status': this.parseTransferStatus(status),
1912
+ };
1913
+ }
1914
+ parseTransferStatus(status) {
1915
+ const statuses = {
1916
+ 'Successful': 'ok',
1917
+ };
1918
+ return this.safeString(statuses, status, status);
1919
+ }
1920
+ /**
1921
+ * @method
1922
+ * @name weex#createOrder
1923
+ * @description Create an order on the exchange
1924
+ * @see https://www.weex.com/api-doc/spot/orderApi/PlaceOrder // spot
1925
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/PlaceOrder // contract
1926
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/PlacePendingOrder // contract trigger
1927
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/PlaceTpSlOrder // contract take profit / stop loss
1928
+ * @param {string} symbol Unified CCXT market symbol
1929
+ * @param {string} type 'limit' or 'market'
1930
+ * @param {string} side 'buy' or 'sell'
1931
+ * @param {float} amount the amount of currency to trade
1932
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1933
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1934
+ * Check createSpotOrder() and createContractOrder() for more details on the extra parameters that can be used in params
1935
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1936
+ */
1937
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1938
+ await this.loadMarkets();
1939
+ const market = this.market(symbol);
1940
+ if (market['contract']) {
1941
+ return await this.createContractOrder(symbol, type, side, amount, price, params);
1942
+ }
1943
+ else {
1944
+ return await this.createSpotOrder(symbol, type, side, amount, price, params);
1945
+ }
1946
+ }
1947
+ /**
1948
+ * @method
1949
+ * @name weex#createSpotOrder
1950
+ * @description helper method for creating spot orders
1951
+ * @see https://www.weex.com/api-doc/spot/orderApi/PlaceOrder
1952
+ * @param {string} symbol Unified CCXT market symbol
1953
+ * @param {string} type 'limit' or 'market'
1954
+ * @param {string} side 'buy' or 'sell'
1955
+ * @param {float} amount the amount of currency to trade
1956
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1957
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1958
+ * @param {string} [params.clientOrderId] client order id
1959
+ * @param {string} [params.timeInForce] 'GTC', 'IOC', or 'FOK'
1960
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1961
+ */
1962
+ async createSpotOrder(symbol, type, side, amount, price = undefined, params = {}) {
1963
+ await this.loadMarkets();
1964
+ const market = this.market(symbol);
1965
+ const request = this.createSpotOrderRequest(symbol, type, side, amount, price, params);
1966
+ const response = await this.privatePostApiV3Order(request);
1967
+ //
1968
+ // {
1969
+ // "symbol": "DOGEUSDT",
1970
+ // "orderId": 736557215397183592,
1971
+ // "clientOrderId": "c4551206d34641efbeb64abaa066946d",
1972
+ // "transactTime": 1775608924724
1973
+ // }
1974
+ //
1975
+ return this.parseOrder(response, market);
1976
+ }
1977
+ createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1978
+ const market = this.market(symbol);
1979
+ const request = {
1980
+ 'symbol': market['id'],
1981
+ 'side': side.toUpperCase(),
1982
+ 'type': type.toUpperCase(),
1983
+ 'quantity': this.amountToPrecision(symbol, amount),
1984
+ };
1985
+ if (type === 'limit') {
1986
+ request['price'] = this.priceToPrecision(symbol, price);
1987
+ }
1988
+ let clientOrderId = this.safeString(params, 'clientOrderId');
1989
+ params = this.omit(params, 'clientOrderId');
1990
+ if (clientOrderId === undefined) {
1991
+ const partner = this.safeString(params, 'partner', 'b-WEEX111125');
1992
+ clientOrderId = partner + '-' + this.uuid22();
1993
+ }
1994
+ request['newClientOrderId'] = clientOrderId;
1995
+ // timeInForce is passed directly from params
1996
+ return this.extend(request, params);
1997
+ }
1998
+ /**
1999
+ * @method
2000
+ * @name weex#createContractOrder
2001
+ * @description helper method for creating contract orders
2002
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/PlaceOrder
2003
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/PlacePendingOrder
2004
+ * @param {string} symbol Unified CCXT market symbol
2005
+ * @param {string} type 'limit' or 'market'
2006
+ * @param {string} side 'buy' or 'sell'
2007
+ * @param {float} amount the amount of currency to trade
2008
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2009
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2010
+ * @param {string} [params.clientOrderId] client order id
2011
+ * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered and the triggerPriceType
2012
+ * @param {float} [params.takeProfit.triggerPrice] The price at which the take profit order will be triggered
2013
+ * @param {string} [params.takeProfit.triggerPriceType] The type of the trigger price for the take profit order, either 'last' or 'mark' (default is 'last')
2014
+ * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered and the triggerPriceType
2015
+ * @param {float} [params.stopLoss.triggerPrice] The price at which the stop loss order will be triggered
2016
+ * @param {string} [params.stopLoss.triggerPriceType] The type of the trigger price for the stop loss order, either 'last' or 'mark' (default is 'last')
2017
+ * @param {float} [params.stopLossPrice] price to trigger stop-loss orders
2018
+ * @param {string} [params.stopLossPriceType] The type of the trigger price for the stop loss order, either 'last' or 'mark' (default is 'last')
2019
+ * @param {float} [params.takeProfitPrice] price to trigger take-profit orders
2020
+ * @param {string} [params.takeProfitPriceType] The type of the trigger price for the take profit order, either 'last' or 'mark' (default is 'last')
2021
+ * @param {bool} [params.reduceOnly] A mark to reduce the position size only. Set to false by default. Need to set the position size when reduceOnly is true.
2022
+ * @param {string} [params.timeInForce] GTC, IOC, or FOK (default is GTC for limit orders)
2023
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2024
+ */
2025
+ async createContractOrder(symbol, type, side, amount, price = undefined, params = {}) {
2026
+ await this.loadMarkets();
2027
+ const market = this.market(symbol);
2028
+ const request = this.createContractOrderRequest(symbol, type, side, amount, price, params);
2029
+ const triggerPrice = this.safeString(request, 'triggerPrice');
2030
+ let response = undefined;
2031
+ if (triggerPrice !== undefined) {
2032
+ response = await this.contractPrivatePostCapiV3AlgoOrder(request);
2033
+ }
2034
+ else {
2035
+ response = await this.contractPrivatePostCapiV3Order(request);
2036
+ }
2037
+ return this.parseOrder(response, market);
2038
+ }
2039
+ createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
2040
+ const market = this.market(symbol);
2041
+ const request = {
2042
+ 'symbol': market['id'],
2043
+ 'side': side.toUpperCase(),
2044
+ 'quantity': this.amountToPrecision(symbol, amount),
2045
+ 'type': type.toUpperCase(),
2046
+ };
2047
+ const isMarketOrder = (type === 'market');
2048
+ if (!isMarketOrder) {
2049
+ request['price'] = this.priceToPrecision(symbol, price);
2050
+ }
2051
+ const [triggerPrice, stopLossPrice, takeProfitPrice, query] = this.handleTriggerPricesAndParams(symbol, params);
2052
+ if (triggerPrice !== undefined) {
2053
+ throw new NotSupported(this.id + ' createOrder() does not support the triggerPrice parameter');
2054
+ }
2055
+ const isStopLoss = (stopLossPrice !== undefined);
2056
+ const isTakeProfit = (takeProfitPrice !== undefined);
2057
+ let reduceOnly = this.safeBool(query, 'reduceOnly');
2058
+ if (isStopLoss || isTakeProfit) {
2059
+ reduceOnly = true;
2060
+ }
2061
+ const isReduceOnly = (reduceOnly === true);
2062
+ let positionSide = 'LONG';
2063
+ if (isReduceOnly) {
2064
+ if (side === 'buy') {
2065
+ positionSide = 'SHORT';
2066
+ }
2067
+ }
2068
+ else if (side === 'sell') {
2069
+ positionSide = 'SHORT';
2070
+ }
2071
+ request['positionSide'] = positionSide;
2072
+ const takeProfit = this.safeDict(params, 'takeProfit');
2073
+ const hasTakeProfit = (takeProfit !== undefined);
2074
+ const stopLoss = this.safeDict(params, 'stopLoss');
2075
+ const hasStopLoss = (stopLoss !== undefined);
2076
+ const timeInForce = this.safeString(params, 'timeInForce');
2077
+ let clientOrderId = this.safeString(params, 'clientOrderId');
2078
+ if (clientOrderId === undefined) {
2079
+ const partner = this.safeString(params, 'partner', 'b-WEEX111125');
2080
+ clientOrderId = partner + '-' + this.uuid22();
2081
+ }
2082
+ const callerMethodName = this.safeString(params, 'callerMethodName');
2083
+ if (isStopLoss || isTakeProfit) {
2084
+ if (callerMethodName === 'createOrders') {
2085
+ throw new NotSupported(this.id + ' createOrders() does not support stop loss and take profit orders');
2086
+ }
2087
+ if (timeInForce !== undefined) {
2088
+ throw new BadRequest(this.id + ' createOrder() cannot use timeInForce parameter with stopLoss and takeProfit orders');
2089
+ }
2090
+ if (hasStopLoss || hasTakeProfit) {
2091
+ throw new BadRequest(this.id + ' createOrder() cannot use both stopLossPrice/takeProfitPrice parameters and stopLoss/takeProfit objects in params at the same time');
2092
+ }
2093
+ if (isStopLoss && isTakeProfit) {
2094
+ throw new BadRequest(this.id + ' createOrder() cannot use both stopLossPrice and takeProfitPrice parameters at the same time');
2095
+ }
2096
+ request['clientAlgoId'] = clientOrderId;
2097
+ let orderType = undefined;
2098
+ if (isStopLoss) {
2099
+ const stopLossPriceType = this.safeString2(params, 'stopLossPriceType', 'triggerPriceType');
2100
+ if (stopLossPriceType !== undefined) {
2101
+ params['SlWorkingType'] = this.encodeTriggerPriceType(stopLossPriceType);
2102
+ }
2103
+ params['triggerPrice'] = this.priceToPrecision(symbol, stopLossPrice);
2104
+ if (isMarketOrder) {
2105
+ orderType = 'STOP_MARKET';
2106
+ }
2107
+ else {
2108
+ orderType = 'STOP';
2109
+ }
2110
+ }
2111
+ else if (isTakeProfit) {
2112
+ const takeProfitPriceType = this.safeString2(params, 'takeProfitPriceType', 'triggerPriceType');
2113
+ if (takeProfitPriceType !== undefined) {
2114
+ params['TpWorkingType'] = this.encodeTriggerPriceType(takeProfitPriceType);
2115
+ }
2116
+ params['triggerPrice'] = this.priceToPrecision(symbol, takeProfitPrice);
2117
+ if (isMarketOrder) {
2118
+ orderType = 'TAKE_PROFIT_MARKET';
2119
+ }
2120
+ else {
2121
+ orderType = 'TAKE_PROFIT';
2122
+ }
2123
+ }
2124
+ params['type'] = orderType;
2125
+ }
2126
+ else {
2127
+ if (!isMarketOrder && timeInForce === undefined) {
2128
+ request['timeInForce'] = 'GTC';
2129
+ }
2130
+ request['newClientOrderId'] = clientOrderId;
2131
+ if (hasStopLoss) {
2132
+ const stopLossTriggerPrice = this.safeNumber(stopLoss, 'triggerPrice');
2133
+ request['slTriggerPrice'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
2134
+ const stopLossPriceType = this.safeString(stopLoss, 'triggerPriceType');
2135
+ if (stopLossPriceType !== undefined) {
2136
+ params['SlWorkingType'] = this.encodeTriggerPriceType(stopLossPriceType);
2137
+ }
2138
+ }
2139
+ if (hasTakeProfit) {
2140
+ const takeProfitTriggerPrice = this.safeNumber(takeProfit, 'triggerPrice');
2141
+ request['tpTriggerPrice'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
2142
+ const takeProfitPriceType = this.safeString(takeProfit, 'triggerPriceType');
2143
+ if (takeProfitPriceType !== undefined) {
2144
+ params['TpWorkingType'] = this.encodeTriggerPriceType(takeProfitPriceType);
2145
+ }
2146
+ }
2147
+ }
2148
+ params = this.omit(params, ['takeProfit', 'stopLoss', 'stopLossPrice', 'takeProfitPrice', 'triggerPriceType', 'stopLossPriceType', 'takeProfitPriceType', 'clientOrderId', 'callerMethodName']);
2149
+ return this.extend(request, params);
2150
+ }
2151
+ encodeTriggerPriceType(triggerPriceType) {
2152
+ const types = {
2153
+ 'mark': 'MARK_PRICE',
2154
+ 'last': 'CONTRACT_PRICE',
2155
+ };
2156
+ return this.safeString(types, triggerPriceType, triggerPriceType);
2157
+ }
2158
+ /**
2159
+ * @method
2160
+ * @name weex#cancelOrder
2161
+ * @description cancels an open order
2162
+ * @see https://www.weex.com/api-doc/spot/orderApi/CancelOrder // spot
2163
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/CancelOrder // contract
2164
+ * @param {string} id order id
2165
+ * @param {string} [symbol] unified symbol of the market the order was made in
2166
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2167
+ * @param {string} [params.type] 'spot' or 'swap' (default is 'spot')
2168
+ * @param {boolean} [params.trigger] *contract orders only* whether the order to cancel is a trigger order
2169
+ * @param {string} [params.clientOrderId] *non-trigger orders only* a unique id for the order
2170
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2171
+ */
2172
+ async cancelOrder(id, symbol = undefined, params = {}) {
2173
+ await this.loadMarkets();
2174
+ let market = undefined;
2175
+ if (symbol !== undefined) {
2176
+ market = this.market(symbol);
2177
+ }
2178
+ let type = undefined;
2179
+ [type, params] = this.handleMarketTypeAndParams('cancelOrder', market, params);
2180
+ const trigger = this.safeBool(params, 'trigger', false);
2181
+ if (trigger && id === undefined) {
2182
+ throw new ArgumentsRequired(this.id + ' cancelOrder() requires an id argument for trigger orders');
2183
+ }
2184
+ const request = {};
2185
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2186
+ params = this.omit(params, ['clientOrderId', 'trigger']);
2187
+ if (clientOrderId !== undefined) {
2188
+ request['origClientOrderId'] = clientOrderId;
2189
+ }
2190
+ else if (id === undefined) {
2191
+ throw new ArgumentsRequired(this.id + ' cancelOrder() requires an id argument or clientOrderId parameter');
2192
+ }
2193
+ else {
2194
+ request['orderId'] = id;
2195
+ }
2196
+ let response = undefined;
2197
+ if (type === 'spot') {
2198
+ // by orderId
2199
+ // {
2200
+ // "orderId": 736775987680772200,
2201
+ // "status": "CANCELED"
2202
+ // }
2203
+ //
2204
+ // by clientOrderId
2205
+ // {
2206
+ // "origClientOrderId": "test_cancel_order",
2207
+ // "status": "CANCELED"
2208
+ // }
2209
+ //
2210
+ response = await this.privateDeleteApiV3Order(this.extend(request, params));
2211
+ }
2212
+ else if (trigger) {
2213
+ response = await this.contractPrivateDeleteCapiV3AlgoOrder(this.extend(request, params));
2214
+ }
2215
+ else {
2216
+ response = await this.contractPrivateDeleteCapiV3Order(this.extend(request, params));
2217
+ }
2218
+ const order = this.parseOrder(response, market);
2219
+ order['status'] = 'canceled';
2220
+ return order;
2221
+ }
2222
+ /**
2223
+ * @method
2224
+ * @name weex#cancelAllOrders
2225
+ * @description cancel all open orders
2226
+ * @see https://www.weex.com/api-doc/spot/orderApi/Cancel-Symbol-Orders // spot
2227
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/CancelAllOrders // contract
2228
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/CancelAllPendingOrders // contract trigger
2229
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2230
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2231
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2232
+ * @param {boolean} [params.trigger] *swap only* true for cancelling trigger orders (default is false)
2233
+ * @returns Response from the exchange
2234
+ */
2235
+ async cancelAllOrders(symbol = undefined, params = {}) {
2236
+ await this.loadMarkets();
2237
+ const request = {};
2238
+ let market = undefined;
2239
+ if (symbol !== undefined) {
2240
+ market = this.market(symbol);
2241
+ request['symbol'] = market['id'];
2242
+ }
2243
+ let marketType = undefined;
2244
+ [marketType, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
2245
+ const trigger = this.safeBool(params, 'trigger', false);
2246
+ params = this.omit(params, 'trigger');
2247
+ let response = undefined;
2248
+ if (marketType === 'spot') {
2249
+ if (symbol === undefined) {
2250
+ throw new ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument for spot markets');
2251
+ }
2252
+ response = await this.privateDeleteApiV3OpenOrders(this.extend(request, params));
2253
+ }
2254
+ else if (trigger) {
2255
+ response = await this.contractPrivateDeleteCapiV3AlgoOpenOrders(this.extend(request, params));
2256
+ }
2257
+ else {
2258
+ response = await this.contractPrivateDeleteCapiV3AllOpenOrders(this.extend(request, params));
2259
+ }
2260
+ const extendedParams = {
2261
+ 'status': 'canceled',
2262
+ };
2263
+ return this.parseOrders(response, market, undefined, undefined, extendedParams);
2264
+ }
2265
+ /**
2266
+ * @method
2267
+ * @name weex#cancelOrders
2268
+ * @description cancel multiple orders
2269
+ * @see https://www.weex.com/api-doc/spot/orderApi/BulkCancel // spot
2270
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/CancelOrdersBatch // contract
2271
+ * @param {string[]} ids order ids
2272
+ * @param {string} [symbol] unified market symbol, default is undefined
2273
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2274
+ * @param {string[]} [params.clientOrderIds] client order ids (could be an alternative to ids)
2275
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2276
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2277
+ */
2278
+ async cancelOrders(ids, symbol = undefined, params = {}) {
2279
+ await this.loadMarkets();
2280
+ const request = {};
2281
+ let market = undefined;
2282
+ if (symbol !== undefined) {
2283
+ market = this.market(symbol);
2284
+ }
2285
+ let marketType = undefined;
2286
+ [marketType, params] = this.handleMarketTypeAndParams('cancelOrders', market, params);
2287
+ const isSpot = (marketType === 'spot');
2288
+ const clientOrderIds = this.safeList(params, 'clientOrderIds');
2289
+ params = this.omit(params, 'clientOrderIds');
2290
+ if (clientOrderIds !== undefined) {
2291
+ if (isSpot) {
2292
+ request['origClientOrderIds'] = clientOrderIds;
2293
+ }
2294
+ else {
2295
+ request['origClientOrderIdList'] = clientOrderIds;
2296
+ }
2297
+ }
2298
+ else if (ids !== undefined) {
2299
+ if (isSpot) {
2300
+ request['orderIds'] = ids;
2301
+ }
2302
+ else {
2303
+ request['orderIdList'] = ids;
2304
+ }
2305
+ }
2306
+ else {
2307
+ throw new ArgumentsRequired(this.id + ' cancelOrders() requires an ids argument or clientOrderIds parameter');
2308
+ }
2309
+ let response = undefined;
2310
+ if (isSpot) {
2311
+ response = await this.privateDeleteApiV3OrderBatch(this.extend(request, params));
2312
+ }
2313
+ else {
2314
+ response = await this.contractPrivateDeleteCapiV3BatchOrders(this.extend(request, params));
2315
+ }
2316
+ const ordersResponse = this.safeList(response, 'orderList', []);
2317
+ const extendedParams = {
2318
+ 'status': 'canceled',
2319
+ };
2320
+ return this.parseOrders(ordersResponse, market, undefined, undefined, extendedParams);
2321
+ }
2322
+ /**
2323
+ * @method
2324
+ * @name weex#fetchOrder
2325
+ * @description fetches information on an order made by the user
2326
+ * @see https://www.weex.com/api-doc/spot/orderApi/OrderDetails // spot
2327
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetSingleOrderInfo // contract
2328
+ * @param {string} id order id
2329
+ * @param {string} symbol unified symbol of the market the order was made in
2330
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2331
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2332
+ * @param {string} [params.clientOrderId] *spot only* a unique id for the order, used if id is not provided
2333
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2334
+ */
2335
+ async fetchOrder(id, symbol = undefined, params = {}) {
2336
+ await this.loadMarkets();
2337
+ let market = undefined;
2338
+ if (symbol !== undefined) {
2339
+ market = this.market(symbol);
2340
+ }
2341
+ let marketType = undefined;
2342
+ [marketType, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
2343
+ const isSpot = (marketType === 'spot');
2344
+ const request = {};
2345
+ if ((id === undefined) && !isSpot) {
2346
+ throw new ArgumentsRequired(this.id + ' fetchOrder() requires an id argument for non-spot markets');
2347
+ }
2348
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2349
+ params = this.omit(params, 'clientOrderId');
2350
+ if (clientOrderId !== undefined) {
2351
+ request['origClientOrderId'] = clientOrderId;
2352
+ }
2353
+ else if (id === undefined) {
2354
+ throw new ArgumentsRequired(this.id + ' fetchOrder() requires an id argument or clientOrderId parameter for spot markets');
2355
+ }
2356
+ else {
2357
+ request['orderId'] = id;
2358
+ }
2359
+ let response = undefined;
2360
+ if (isSpot) {
2361
+ //
2362
+ // {
2363
+ // "symbol": "DOGEUSDT",
2364
+ // "orderId": 736800333186991070,
2365
+ // "clientOrderId": "082007092f624a18bb7af2ab42e7c8e8",
2366
+ // "price": "0.08500",
2367
+ // "origQty": "300.0",
2368
+ // "executedQty": "0",
2369
+ // "cummulativeQuoteQty": "0",
2370
+ // "status": "NEW",
2371
+ // "timeInForce": "GTC",
2372
+ // "type": "LIMIT",
2373
+ // "side": "BUY",
2374
+ // "time": 1775666888520,
2375
+ // "updateTime": 1775666888536,
2376
+ // "isWorking": true
2377
+ // }
2378
+ //
2379
+ response = await this.privateGetApiV3Order(this.extend(request, params));
2380
+ }
2381
+ else {
2382
+ response = await this.contractPrivateGetCapiV3Order(this.extend(request, params));
2383
+ }
2384
+ return this.parseOrder(response, market);
2385
+ }
2386
+ /**
2387
+ * @method
2388
+ * @name weex#fetchOpenOrders
2389
+ * @see https://www.weex.com/api-doc/spot/orderApi/UnfinishedOrders // spot
2390
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetCurrentOrderStatus // contract
2391
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetCurrentPendingOrders // contract trigger
2392
+ * @description fetch all unfilled currently open orders
2393
+ * @param {string} symbol unified market symbol
2394
+ * @param {int} [since] the earliest time in ms to fetch open orders for
2395
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
2396
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2397
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2398
+ * @param {boolean} [params.trigger] *swap only* whether to fetch trigger orders (default is false)
2399
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2400
+ */
2401
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2402
+ await this.loadMarkets();
2403
+ let market = undefined;
2404
+ if (symbol !== undefined) {
2405
+ market = this.market(symbol);
2406
+ }
2407
+ let marketType = undefined;
2408
+ [marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
2409
+ const isSpot = (marketType === 'spot');
2410
+ let paginate = false;
2411
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate', false);
2412
+ const maxLimit = 100;
2413
+ if (paginate) {
2414
+ if (isSpot) {
2415
+ throw new NotSupported(this.id + ' fetchOpenOrders() pagination is not supported for spot markets');
2416
+ }
2417
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params, maxLimit);
2418
+ }
2419
+ let request = {};
2420
+ if (symbol !== undefined) {
2421
+ request['symbol'] = market['id'];
2422
+ }
2423
+ let response = undefined;
2424
+ if (isSpot) {
2425
+ //
2426
+ // [
2427
+ // {
2428
+ // "symbol": "DOGEUSDT",
2429
+ // "orderId": 736807745679786974,
2430
+ // "clientOrderId": "e6dc41082bf342f580a19264d82dab31",
2431
+ // "price": "0.12000",
2432
+ // "origQty": "299.0",
2433
+ // "executedQty": "0",
2434
+ // "cummulativeQuoteQty": "0",
2435
+ // "status": "NEW",
2436
+ // "timeInForce": "GTC",
2437
+ // "type": "LIMIT",
2438
+ // "side": "SELL",
2439
+ // "time": 1775668655796,
2440
+ // "updateTime": 1775668655810,
2441
+ // "isWorking": true
2442
+ // }
2443
+ // ]
2444
+ //
2445
+ response = await this.privateGetApiV3OpenOrders(this.extend(request, params));
2446
+ }
2447
+ else {
2448
+ if (since !== undefined) {
2449
+ request['startTime'] = since;
2450
+ }
2451
+ if (limit !== undefined) {
2452
+ request['limit'] = limit;
2453
+ }
2454
+ [request, params] = this.handleUntilOption('endTime', request, params);
2455
+ const trigger = this.safeBool(params, 'trigger', false);
2456
+ if (trigger) {
2457
+ params = this.omit(params, 'trigger');
2458
+ //
2459
+ // [
2460
+ // {
2461
+ // "algoId": 737074389748547944,
2462
+ // "clientAlgoId": "d574f517-cea5-433e-b029-415590d3bb80",
2463
+ // "algoType": "CONDITIONAL",
2464
+ // "orderType": "STOP_MARKET",
2465
+ // "symbol": "DOGEUSDT",
2466
+ // "side": "SELL",
2467
+ // "positionSide": "LONG",
2468
+ // "timeInForce": "IOC",
2469
+ // "quantity": "100",
2470
+ // "algoStatus": "UNTRIGGERED",
2471
+ // "actualOrderId": 737074043320009064,
2472
+ // "actualPrice": "0.00000",
2473
+ // "triggerPrice": "0.02000",
2474
+ // "price": "0.00000",
2475
+ // "tpTriggerPrice": null,
2476
+ // "tpPrice": null,
2477
+ // "slTriggerPrice": null,
2478
+ // "slPrice": null,
2479
+ // "tpOrderType": null,
2480
+ // "workingType": "CONTRACT_PRICE",
2481
+ // "closePosition": false,
2482
+ // "reduceOnly": true,
2483
+ // "createTime": 1775732228695,
2484
+ // "updateTime": 1775732228695,
2485
+ // "triggerTime": 0
2486
+ // }
2487
+ // ]
2488
+ //
2489
+ response = await this.contractPrivateGetCapiV3OpenAlgoOrders(this.extend(request, params));
2490
+ }
2491
+ else {
2492
+ //
2493
+ // [
2494
+ // {
2495
+ // "avgPrice": "0.00000",
2496
+ // "clientOrderId": "857e1482-3225-44ce-bc0a-947714c5cabc",
2497
+ // "cumQuote": "0",
2498
+ // "executedQty": "0",
2499
+ // "orderId": 737185556881998184,
2500
+ // "origQty": "1400",
2501
+ // "price": "0.05000",
2502
+ // "reduceOnly": false,
2503
+ // "side": "BUY",
2504
+ // "positionSide": "LONG",
2505
+ // "status": "NEW",
2506
+ // "stopPrice": "0",
2507
+ // "symbol": "DOGEUSDT",
2508
+ // "time": 1775758733006,
2509
+ // "timeInForce": "GTC",
2510
+ // "type": "LIMIT",
2511
+ // "updateTime": 1775758733006,
2512
+ // "workingType": "UNKNOWN_PRICE_TYPE"
2513
+ // }
2514
+ // ]
2515
+ //
2516
+ response = await this.contractPrivateGetCapiV3OpenOrders(this.extend(request, params));
2517
+ }
2518
+ }
2519
+ const extendedParams = {
2520
+ 'status': 'open',
2521
+ };
2522
+ return this.parseOrders(response, market, since, limit, extendedParams);
2523
+ }
2524
+ /**
2525
+ * @method
2526
+ * @name weex#fetchClosedOrders
2527
+ * @description fetches information on multiple closed orders made by the user
2528
+ * @see https://www.weex.com/api-doc/spot/orderApi/HistoryOrders // spot
2529
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetOrderHistory // contract
2530
+ * @param {string} symbol unified market symbol of the market orders were made in
2531
+ * @param {int} [since] the earliest time in ms to fetch orders for
2532
+ * @param {int} [limit] the maximum number of order structures to retrieve
2533
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2534
+ * @param {int} [params.until] the latest time in ms to fetch orders for
2535
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2536
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2537
+ */
2538
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2539
+ await this.loadMarkets();
2540
+ let market = undefined;
2541
+ if (symbol !== undefined) {
2542
+ market = this.market(symbol);
2543
+ }
2544
+ let marketType = undefined;
2545
+ [marketType, params] = this.handleMarketTypeAndParams('fetchClosedOrders', market, params);
2546
+ let orders = undefined;
2547
+ if (marketType === 'spot') {
2548
+ if (symbol === undefined) {
2549
+ throw new ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument for spot markets');
2550
+ }
2551
+ orders = await this.fetchOrders(symbol, since, undefined, params);
2552
+ }
2553
+ else {
2554
+ orders = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
2555
+ }
2556
+ return this.filterBy(orders, 'status', 'closed');
2557
+ }
2558
+ /**
2559
+ * @method
2560
+ * @name weex#fetchCanceledOrders
2561
+ * @description fetches information on multiple canceled orders made by the user
2562
+ * @see https://www.weex.com/api-doc/spot/orderApi/HistoryOrders // spot
2563
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetOrderHistory // contract
2564
+ * @param {string} symbol unified market symbol of the market orders were made in
2565
+ * @param {int} [since] the earliest time in ms to fetch orders for
2566
+ * @param {int} [limit] the maximum number of order structures to retrieve
2567
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2568
+ * @param {int} [params.until] the latest time in ms to fetch orders for
2569
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2570
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2571
+ */
2572
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2573
+ await this.loadMarkets();
2574
+ let market = undefined;
2575
+ if (symbol !== undefined) {
2576
+ market = this.market(symbol);
2577
+ }
2578
+ let marketType = undefined;
2579
+ [marketType, params] = this.handleMarketTypeAndParams('fetchCanceledOrders', market, params);
2580
+ let orders = undefined;
2581
+ if (marketType === 'spot') {
2582
+ if (symbol === undefined) {
2583
+ throw new ArgumentsRequired(this.id + ' fetchCanceledOrders() requires a symbol argument for spot markets');
2584
+ }
2585
+ orders = await this.fetchOrders(symbol, since, undefined, params);
2586
+ }
2587
+ else {
2588
+ orders = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
2589
+ }
2590
+ return this.filterBy(orders, 'status', 'canceled');
2591
+ }
2592
+ /**
2593
+ * @method
2594
+ * @name weex#fetchOrders
2595
+ * @description fetches information on multiple spot orders made by the user
2596
+ * @see https://www.weex.com/api-doc/spot/orderApi/HistoryOrders // spot
2597
+ * @param {string} symbol unified market symbol of the market orders were made in (required for spot orders)
2598
+ * @param {int} [since] the earliest time in ms to fetch orders for
2599
+ * @param {int} [limit] the maximum number of order structures to retrieve
2600
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2601
+ * @param {object} [params.until] end time, ms
2602
+ * @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)
2603
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2604
+ */
2605
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2606
+ if (symbol === undefined) {
2607
+ throw new ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
2608
+ }
2609
+ await this.loadMarkets();
2610
+ const market = this.market(symbol);
2611
+ if (!market['spot']) {
2612
+ throw new NotSupported(this.id + ' fetchOrders() supports spot markets only');
2613
+ }
2614
+ const maxLimit = 1000;
2615
+ let paginate = false;
2616
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate', false);
2617
+ if (paginate) {
2618
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params, maxLimit);
2619
+ }
2620
+ let request = {
2621
+ 'symbol': market['id'],
2622
+ };
2623
+ if (since !== undefined) {
2624
+ request['startTime'] = since;
2625
+ }
2626
+ if (limit !== undefined) {
2627
+ request['limit'] = Math.min(limit, maxLimit);
2628
+ }
2629
+ [request, params] = this.handleUntilOption('endTime', request, params);
2630
+ const response = await this.privateGetApiV3AllOrders(this.extend(request, params));
2631
+ //
2632
+ // [
2633
+ // {
2634
+ // "symbol": "DOGEUSDT",
2635
+ // "orderId": 736806838401500126,
2636
+ // "clientOrderId": "e93fcb1423fc4b4982fd02eb3bc4955c",
2637
+ // "price": "0.09365",
2638
+ // "origQty": "300.0",
2639
+ // "executedQty": "300.0",
2640
+ // "cummulativeQuoteQty": "28.095",
2641
+ // "status": "FILLED",
2642
+ // "timeInForce": "IOC",
2643
+ // "type": "MARKET",
2644
+ // "side": "BUY",
2645
+ // "time": 1775668439484,
2646
+ // "updateTime": 1775668439498,
2647
+ // "isWorking": false
2648
+ // }
2649
+ // ]
2650
+ //
2651
+ return this.parseOrders(response, market, since, limit);
2652
+ }
2653
+ /**
2654
+ * @method
2655
+ * @name weex#fetchCanceledAndClosedOrders
2656
+ * @description fetches information on multiple closed and canceled orders made by the user
2657
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetOrderHistory // contract
2658
+ * @param {string} [symbol] unified market symbol of the market orders were made in (required for spot orders)
2659
+ * @param {int} [since] the earliest time in ms to fetch orders for
2660
+ * @param {int} [limit] the maximum number of order structures to retrieve
2661
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2662
+ * @param {object} [params.until] end time, ms
2663
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2664
+ * @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)
2665
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2666
+ */
2667
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2668
+ await this.loadMarkets();
2669
+ let market = undefined;
2670
+ if (symbol !== undefined) {
2671
+ market = this.market(symbol);
2672
+ }
2673
+ let marketType = undefined;
2674
+ [marketType, params] = this.handleMarketTypeAndParams('fetchOrders', market, params);
2675
+ if (marketType === 'spot') {
2676
+ throw new NotSupported(this.id + ' fetchCanceledAndClosedOrders() does not support spot markets. Use fetchOrders() instead and filter by status "canceled" or "closed"');
2677
+ }
2678
+ let paginate = false;
2679
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate', false);
2680
+ const maxLimit = 1000;
2681
+ if (paginate) {
2682
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params, maxLimit);
2683
+ }
2684
+ let request = {};
2685
+ if (symbol !== undefined) {
2686
+ request['symbol'] = market['id'];
2687
+ }
2688
+ if (since !== undefined) {
2689
+ request['startTime'] = since;
2690
+ }
2691
+ if (limit !== undefined) {
2692
+ request['limit'] = limit;
2693
+ }
2694
+ [request, params] = this.handleUntilOption('endTime', request, params);
2695
+ const response = await this.contractPrivateGetCapiV3OrderHistory(this.extend(request, params));
2696
+ //
2697
+ // [
2698
+ // {
2699
+ // "avgPrice": "0.00000",
2700
+ // "clientOrderId": "7bd80776-0c3f-4ed9-ab9c-a616d66fac5e",
2701
+ // "cumQuote": "0",
2702
+ // "executedQty": "0",
2703
+ // "orderId": 737074389744353640,
2704
+ // "origQty": "100",
2705
+ // "price": "0.00000",
2706
+ // "reduceOnly": true,
2707
+ // "side": "SELL",
2708
+ // "positionSide": "LONG",
2709
+ // "status": "CANCELED",
2710
+ // "stopPrice": "1.00000",
2711
+ // "symbol": "DOGEUSDT",
2712
+ // "time": 1775732228695,
2713
+ // "timeInForce": "IOC",
2714
+ // "type": "TAKE_PROFIT_MARKET",
2715
+ // "updateTime": 1775732228695,
2716
+ // "workingType": "CONTRACT_PRICE"
2717
+ // }
2718
+ // ]
2719
+ //
2720
+ return this.parseOrders(response, market, since, limit);
2721
+ }
2722
+ parseOrder(order, market = undefined) {
2723
+ //
2724
+ // createOrder (spot)
2725
+ // {
2726
+ // "symbol": "DOGEUSDT",
2727
+ // "orderId": 736557215397183592,
2728
+ // "clientOrderId": "c4551206d34641efbeb64abaa066946d",
2729
+ // "transactTime": 1775608924724
2730
+ // }
2731
+ //
2732
+ // fetchOpenOrders / fetchOrders / fetchOrder (spot)
2733
+ // {
2734
+ // "symbol": "DOGEUSDT",
2735
+ // "orderId": 736800333186991070,
2736
+ // "clientOrderId": "082007092f624a18bb7af2ab42e7c8e8",
2737
+ // "price": "0.08500",
2738
+ // "origQty": "300.0",
2739
+ // "executedQty": "0",
2740
+ // "cummulativeQuoteQty": "0",
2741
+ // "status": "NEW",
2742
+ // "timeInForce": "GTC",
2743
+ // "type": "LIMIT",
2744
+ // "side": "BUY",
2745
+ // "time": 1775666888520,
2746
+ // "updateTime": 1775666888536,
2747
+ // "isWorking": true
2748
+ // }
2749
+ //
2750
+ // fetchOpenOrders (contract)
2751
+ // {
2752
+ // "avgPrice": "0.00000",
2753
+ // "clientOrderId": "857e1482-3225-44ce-bc0a-947714c5cabc",
2754
+ // "cumQuote": "0",
2755
+ // "executedQty": "0",
2756
+ // "orderId": 737185556881998184,
2757
+ // "origQty": "1400",
2758
+ // "price": "0.05000",
2759
+ // "reduceOnly": false,
2760
+ // "side": "BUY",
2761
+ // "positionSide": "LONG",
2762
+ // "status": "NEW",
2763
+ // "stopPrice": "0",
2764
+ // "symbol": "DOGEUSDT",
2765
+ // "time": 1775758733006,
2766
+ // "timeInForce": "GTC",
2767
+ // "type": "LIMIT",
2768
+ // "updateTime": 1775758733006,
2769
+ // "workingType": "UNKNOWN_PRICE_TYPE"
2770
+ // }
2771
+ //
2772
+ // fetchOpenOrders (contract-trigger)
2773
+ // {
2774
+ // "algoId": 737074389748547944,
2775
+ // "clientAlgoId": "d574f517-cea5-433e-b029-415590d3bb80",
2776
+ // "algoType": "CONDITIONAL",
2777
+ // "orderType": "STOP_MARKET",
2778
+ // "symbol": "DOGEUSDT",
2779
+ // "side": "SELL",
2780
+ // "positionSide": "LONG",
2781
+ // "timeInForce": "IOC",
2782
+ // "quantity": "100",
2783
+ // "algoStatus": "UNTRIGGERED",
2784
+ // "actualOrderId": 737074043320009064,
2785
+ // "actualPrice": "0.00000",
2786
+ // "triggerPrice": "0.02000",
2787
+ // "price": "0.00000",
2788
+ // "tpTriggerPrice": null,
2789
+ // "tpPrice": null,
2790
+ // "slTriggerPrice": null,
2791
+ // "slPrice": null,
2792
+ // "tpOrderType": null,
2793
+ // "workingType": "CONTRACT_PRICE",
2794
+ // "closePosition": false,
2795
+ // "reduceOnly": true,
2796
+ // "createTime": 1775732228695,
2797
+ // "updateTime": 1775732228695,
2798
+ // "triggerTime": 0
2799
+ // }
2800
+ //
2801
+ // fetchCanceledAndClosedOrders (swap only)
2802
+ // {
2803
+ // "avgPrice": "0.00000",
2804
+ // "clientOrderId": "7bd80776-0c3f-4ed9-ab9c-a616d66fac5e",
2805
+ // "cumQuote": "0",
2806
+ // "executedQty": "0",
2807
+ // "orderId": 737074389744353640,
2808
+ // "origQty": "100",
2809
+ // "price": "0.00000",
2810
+ // "reduceOnly": true,
2811
+ // "side": "SELL",
2812
+ // "positionSide": "LONG",
2813
+ // "status": "CANCELED",
2814
+ // "stopPrice": "1.00000",
2815
+ // "symbol": "DOGEUSDT",
2816
+ // "time": 1775732228695,
2817
+ // "timeInForce": "IOC",
2818
+ // "type": "TAKE_PROFIT_MARKET",
2819
+ // "updateTime": 1775732228695,
2820
+ // "workingType": "CONTRACT_PRICE"
2821
+ // }
2822
+ //
2823
+ const errorCode = this.safeString(order, 'errorCode');
2824
+ const errorMessage = this.safeString(order, 'errorMsg');
2825
+ if ((errorCode !== undefined) || (errorMessage !== undefined)) {
2826
+ this.handleOrderOrPositionError(errorCode, errorMessage, order);
2827
+ }
2828
+ if (market === undefined) {
2829
+ const marketId = this.safeString(order, 'symbol');
2830
+ const positionSide = this.safeString(order, 'positionSide');
2831
+ const marketType = (positionSide === undefined) ? 'spot' : 'swap';
2832
+ market = this.safeMarket(marketId, undefined, undefined, marketType);
2833
+ }
2834
+ const timestamp = this.safeIntegerN(order, ['transactTime', 'time', 'createTime']);
2835
+ const rawStatus = this.safeStringLower(order, 'status');
2836
+ const triggerPrice = this.omitZero(this.safeString2(order, 'triggerPrice', 'stopPrice'));
2837
+ const rawType = this.safeStringUpper2(order, 'type', 'orderType');
2838
+ let takeProfitPrice = undefined;
2839
+ let stopLossPrice = undefined;
2840
+ if (rawType === 'TAKE_PROFIT_MARKET' || rawType === 'TAKE_PROFIT') {
2841
+ takeProfitPrice = triggerPrice;
2842
+ }
2843
+ else if (rawType === 'STOP_LOSS' || rawType === 'STOP' || rawType === 'STOP_MARKET') {
2844
+ stopLossPrice = triggerPrice;
2845
+ }
2846
+ return this.safeOrder({
2847
+ 'id': this.safeStringN(order, ['orderId', 'algoId', 'successOrderId']),
2848
+ 'clientOrderId': this.safeStringN(order, ['clientOrderId', 'origClientOrderId', 'clientAlgoId']),
2849
+ 'symbol': this.safeString(market, 'symbol'),
2850
+ 'type': this.parseOrderType(rawType),
2851
+ 'timeInForce': this.safeString(order, 'timeInForce'),
2852
+ 'postOnly': undefined,
2853
+ 'reduceOnly': this.safeBool(order, 'reduceOnly'),
2854
+ 'side': this.safeStringLower(order, 'side'),
2855
+ 'amount': this.safeString2(order, 'origQty', 'quantity'),
2856
+ 'price': this.safeString(order, 'price'),
2857
+ 'triggerPrice': triggerPrice,
2858
+ 'cost': this.safeString2(order, 'cummulativeQuoteQty', 'cumQuote'),
2859
+ 'filled': this.safeString(order, 'executedQty'),
2860
+ 'remaining': undefined,
2861
+ 'timestamp': timestamp,
2862
+ 'datetime': this.iso8601(timestamp),
2863
+ 'fee': undefined,
2864
+ 'status': this.parseOrderStatus(rawStatus),
2865
+ 'lastTradeTimestamp': undefined,
2866
+ 'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
2867
+ 'average': this.safeString(order, 'avgPrice'),
2868
+ 'trades': undefined,
2869
+ 'stopLossPrice': stopLossPrice,
2870
+ 'takeProfitPrice': takeProfitPrice,
2871
+ 'info': order,
2872
+ }, market);
2873
+ }
2874
+ parseOrderStatus(status) {
2875
+ const statuses = {
2876
+ 'new': 'open',
2877
+ 'partial_fill': 'closed',
2878
+ 'full_fill': 'closed',
2879
+ 'filled': 'closed',
2880
+ 'cancelled': 'canceled',
2881
+ 'canceled': 'canceled',
2882
+ 'rejected': 'rejected',
2883
+ 'untriggered': 'open',
2884
+ };
2885
+ return this.safeString(statuses, status, status);
2886
+ }
2887
+ parseOrderType(type) {
2888
+ const types = {
2889
+ 'LIMIT': 'limit',
2890
+ 'MARKET': 'market',
2891
+ 'STOP_LOSS': 'limit',
2892
+ 'STOP': 'limit',
2893
+ 'TAKE_PROFIT': 'limit',
2894
+ 'TAKE_PROFIT_MARKET': 'market',
2895
+ 'STOP_MARKET': 'market',
2896
+ };
2897
+ return this.safeString(types, type, type);
2898
+ }
2899
+ handleOrderOrPositionError(errorCode, errorMessage, order) {
2900
+ if (errorCode === undefined) {
2901
+ errorCode = '';
2902
+ }
2903
+ if (errorMessage === undefined) {
2904
+ errorMessage = '';
2905
+ }
2906
+ if ((errorCode === '') && (errorMessage === '')) {
2907
+ // some endpoints could return an empty string if there is no error
2908
+ return;
2909
+ }
2910
+ const feedback = this.id + ' ' + this.json(order);
2911
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorMessage, feedback);
2912
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
2913
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
2914
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorCode, feedback);
2915
+ throw new InvalidOrder(feedback);
2916
+ }
2917
+ /**
2918
+ * @method
2919
+ * @name weex#fetchOrderTrades
2920
+ * @description fetch all the trades made from a single order
2921
+ * @see https://www.weex.com/api-doc/spot/orderApi/TransactionDetails // spot
2922
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetTradeDetails // contract
2923
+ * @param {string} id order id
2924
+ * @param {string} [symbol] unified market symbol
2925
+ * @param {int} [since] the earliest time in ms to fetch trades for
2926
+ * @param {int} [limit] the maximum number of trades to retrieve
2927
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2928
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
2929
+ */
2930
+ async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2931
+ await this.loadMarkets();
2932
+ const request = {
2933
+ 'orderId': id,
2934
+ };
2935
+ return await this.fetchMyTrades(symbol, since, limit, this.extend(request, params));
2936
+ }
2937
+ /**
2938
+ * @method
2939
+ * @name weex#fetchMyTrades
2940
+ * @see https://www.weex.com/api-doc/spot/orderApi/TransactionDetails // spot
2941
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/GetTradeDetails // contract
2942
+ * @description fetch all trades made by the user
2943
+ * @param {string} symbol unified market symbol
2944
+ * @param {int} [since] the earliest time in ms to fetch trades for
2945
+ * @param {int} [limit] the maximum number of trades structures to retrieve
2946
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2947
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2948
+ * @param {string} [params.type] 'spot' or 'swap', used if symbol is not provided (default is 'spot')
2949
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
2950
+ */
2951
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2952
+ await this.loadMarkets();
2953
+ let market = undefined;
2954
+ if (symbol !== undefined) {
2955
+ market = this.market(symbol);
2956
+ }
2957
+ let marketType = undefined;
2958
+ [marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
2959
+ const isSpot = (marketType === 'spot');
2960
+ if (isSpot && (symbol === undefined)) {
2961
+ throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument for spot markets');
2962
+ }
2963
+ let paginate = false;
2964
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate', false);
2965
+ const maxLimit = 100;
2966
+ if (paginate) {
2967
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, maxLimit);
2968
+ }
2969
+ let request = {};
2970
+ if (symbol !== undefined) {
2971
+ request['symbol'] = market['id'];
2972
+ }
2973
+ if (since !== undefined) {
2974
+ request['startTime'] = since;
2975
+ }
2976
+ if (limit !== undefined) {
2977
+ request['limit'] = limit;
2978
+ }
2979
+ [request, params] = this.handleUntilOption('endTime', request, params);
2980
+ let response = undefined;
2981
+ if (isSpot) {
2982
+ //
2983
+ // [
2984
+ // {
2985
+ // "symbol": "DOGEUSDT",
2986
+ // "id": 736825748291060702,
2987
+ // "orderId": 736825748215563230,
2988
+ // "price": "0.09349",
2989
+ // "qty": "250.0",
2990
+ // "quoteQty": "23.3725",
2991
+ // "commission": "0.0233725",
2992
+ // "time": 1775672947953,
2993
+ // "isBuyer": false
2994
+ // }
2995
+ // ]
2996
+ //
2997
+ response = await this.privateGetApiV3MyTrades(this.extend(request, params));
2998
+ }
2999
+ else {
3000
+ //
3001
+ // [
3002
+ // {
3003
+ // "id": 737074389731770728,
3004
+ // "orderId": 737074043320009064,
3005
+ // "symbol": "DOGEUSDT",
3006
+ // "buyer": true,
3007
+ // "commission": "0.00183500",
3008
+ // "commissionAsset": "USDT",
3009
+ // "maker": true,
3010
+ // "price": "0.09175",
3011
+ // "qty": "100",
3012
+ // "quoteQty": "9.17500",
3013
+ // "realizedPnl": "0",
3014
+ // "side": "BUY",
3015
+ // "positionSide": "LONG",
3016
+ // "time": 1775732228692
3017
+ // }
3018
+ // ]
3019
+ //
3020
+ response = await this.contractPrivateGetCapiV3UserTrades(this.extend(request, params));
3021
+ }
3022
+ return this.parseTrades(response, market, since, limit);
3023
+ }
3024
+ /**
3025
+ * @method
3026
+ * @name weex#fetchLedger
3027
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
3028
+ * @see https://www.weex.com/api-doc/spot/AccountAPI/GetBillRecords // spot
3029
+ * @see https://www.weex.com/api-doc/spot/AccountAPI/GetFundBillRecords // funding
3030
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetContractBills // contract
3031
+ * @param {string} [code] unified currency code, default is undefined
3032
+ * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
3033
+ * @param {int} [limit] max number of ledger entries to return, default is undefined, max is 100
3034
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3035
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
3036
+ * @param {string} [params.type] 'spot', 'funding' or 'swap' (default is 'spot')
3037
+ * @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)
3038
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
3039
+ */
3040
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
3041
+ await this.loadMarkets();
3042
+ let paginate = false;
3043
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate', false);
3044
+ const maxLimit = 100;
3045
+ if (paginate) {
3046
+ return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params, maxLimit);
3047
+ }
3048
+ let accountType = undefined;
3049
+ [accountType, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
3050
+ const accountsByType = this.safeDict(this.options, 'accountsByType', {});
3051
+ accountType = this.safeString(accountsByType, accountType, accountType);
3052
+ let request = {};
3053
+ let items = undefined;
3054
+ let currency = undefined;
3055
+ if (code !== undefined) {
3056
+ currency = this.currency(code);
3057
+ }
3058
+ if (accountType === 'contract') {
3059
+ if (code !== undefined) {
3060
+ request['currency'] = currency['id'];
3061
+ }
3062
+ if (since !== undefined) {
3063
+ request['startTime'] = since;
3064
+ }
3065
+ if (limit !== undefined) {
3066
+ request['limit'] = limit;
3067
+ }
3068
+ [request, params] = this.handleUntilOption('endTime', request, params);
3069
+ const contractResponse = await this.contractPrivatePostCapiV3AccountIncome(this.extend(request, params));
3070
+ items = this.safeList(contractResponse, 'items', []);
3071
+ }
3072
+ else if (accountType === 'funding') {
3073
+ if (since !== undefined) {
3074
+ request['startTime'] = since;
3075
+ }
3076
+ if (limit !== undefined) {
3077
+ request['pageSize'] = limit;
3078
+ }
3079
+ [request, params] = this.handleUntilOption('endTime', request, params);
3080
+ const fundingResponse = await this.privatePostApiV3AccountFundingBills(this.extend(request, params));
3081
+ items = this.safeList(fundingResponse, 'items', []);
3082
+ }
3083
+ else {
3084
+ if (since !== undefined) {
3085
+ request['after'] = since;
3086
+ }
3087
+ if (limit !== undefined) {
3088
+ request['limit'] = limit;
3089
+ }
3090
+ [request, params] = this.handleUntilOption('before', request, params);
3091
+ items = await this.privatePostApiV3AccountBills(this.extend(request, params));
3092
+ }
3093
+ return this.parseLedger(items, currency, since, limit);
3094
+ }
3095
+ parseLedgerEntry(item, currency = undefined) {
3096
+ //
3097
+ // spot
3098
+ // {
3099
+ // "billId": "736825748291061726",
3100
+ // "coinId": 82,
3101
+ // "coinName": "DOGE",
3102
+ // "bizType": "trade_out",
3103
+ // "fillSize": "250.0",
3104
+ // "fillValue": "23.372500",
3105
+ // "deltaAmount": "-250.0",
3106
+ // "afterAmount": "49.70000000",
3107
+ // "fees": "0",
3108
+ // "cTime": "1775672947953"
3109
+ // }
3110
+ //
3111
+ // contract
3112
+ // {
3113
+ // "billId": 736791763716407518,
3114
+ // "asset": "USDT",
3115
+ // "symbol": null,
3116
+ // "income": "-90.00000000",
3117
+ // "incomeType": "withdraw",
3118
+ // "balance": "106.00000000",
3119
+ // "fillFee": "0",
3120
+ // "time": 1775664845399,
3121
+ // "transferReason": "UNKNOWN_TRANSFER_REASON"
3122
+ // }
3123
+ //
3124
+ // funding
3125
+ // {
3126
+ // "billId": "16502414",
3127
+ // "coinId": 2,
3128
+ // "coinName": "USDT",
3129
+ // "bizType": "transfer_out",
3130
+ // "fillSize": null,
3131
+ // "fillValue": null,
3132
+ // "deltaAmount": "-100.00000000",
3133
+ // "afterAmount": "0.00000000",
3134
+ // "fees": "0.00000000",
3135
+ // "cTime": "1775664588931"
3136
+ // }
3137
+ //
3138
+ const currencyId = this.safeString2(item, 'coinName', 'asset');
3139
+ const code = this.safeCurrencyCode(currencyId, currency);
3140
+ currency = this.safeCurrency(currencyId, currency);
3141
+ const timestamp = this.safeInteger2(item, 'cTime', 'time');
3142
+ const amountRaw = this.safeString2(item, 'deltaAmount', 'income');
3143
+ const after = this.safeString2(item, 'afterAmount', 'balance');
3144
+ const before = Precise.stringSub(after, amountRaw);
3145
+ const amount = this.parseNumber(Precise.stringAbs(amountRaw));
3146
+ let direction = 'in';
3147
+ if (amountRaw.indexOf('-') >= 0) {
3148
+ direction = 'out';
3149
+ }
3150
+ let rawType = this.safeString2(item, 'bizType', 'incomeType');
3151
+ const transferReason = this.safeString(item, 'transferReason');
3152
+ const isContractEntry = (transferReason !== undefined);
3153
+ if (isContractEntry) {
3154
+ if ((rawType === 'withdraw') || (rawType === 'deposit')) {
3155
+ rawType = 'transfer';
3156
+ }
3157
+ }
3158
+ return this.safeLedgerEntry({
3159
+ 'info': item,
3160
+ 'id': this.safeString(item, 'billId'),
3161
+ 'timestamp': timestamp,
3162
+ 'datetime': this.iso8601(timestamp),
3163
+ 'direction': direction,
3164
+ 'account': undefined,
3165
+ 'referenceId': undefined,
3166
+ 'referenceAccount': undefined,
3167
+ 'type': this.parseLedgerType(rawType),
3168
+ 'currency': code,
3169
+ 'amount': amount,
3170
+ 'before': this.parseNumber(before),
3171
+ 'after': this.parseNumber(after),
3172
+ 'status': undefined,
3173
+ 'fee': {
3174
+ 'currency': code,
3175
+ 'cost': this.safeNumber2(item, 'fees', 'fillFee'),
3176
+ },
3177
+ }, currency);
3178
+ }
3179
+ parseLedgerType(type) {
3180
+ const types = {
3181
+ 'transfer_in': 'transfer',
3182
+ 'transfer_out': 'transfer',
3183
+ 'deposit': 'deposit',
3184
+ 'withdraw': 'withdrawal',
3185
+ 'trade_in': 'trade',
3186
+ 'trade_out': 'trade',
3187
+ 'position_open_long': 'trade',
3188
+ 'position_open_short': 'trade',
3189
+ 'position_close_long': 'trade',
3190
+ 'position_close_short': 'trade',
3191
+ };
3192
+ return this.safeString(types, type, type);
3193
+ }
3194
+ /**
3195
+ * @method
3196
+ * @name weex#fetchPositions
3197
+ * @description fetch all open positions
3198
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetAllPositions
3199
+ * @param {string[]} [symbols] list of unified market symbols
3200
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3201
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
3202
+ */
3203
+ async fetchPositions(symbols = undefined, params = {}) {
3204
+ await this.loadMarkets();
3205
+ symbols = this.marketSymbols(symbols);
3206
+ const response = await this.contractPrivateGetCapiV3AccountPositionAllPosition(params);
3207
+ return this.parsePositions(response, symbols);
3208
+ }
3209
+ /**
3210
+ * @method
3211
+ * @name weex#fetchPosition
3212
+ * @description fetch data on an open position
3213
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetSinglePosition
3214
+ * @param {string} symbol unified market symbol of the market the position is held in
3215
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3216
+ * @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
3217
+ */
3218
+ async fetchPosition(symbol, params = {}) {
3219
+ const positions = await this.fetchPositionsForSymbol(symbol, params);
3220
+ return this.safeDict(positions, 0);
3221
+ }
3222
+ /**
3223
+ * @method
3224
+ * @description fetch open positions for a single market
3225
+ * @name weex#fetchPositionsForSymbol
3226
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetSinglePosition
3227
+ * @description fetch all open positions for specific symbol
3228
+ * @param {string} symbol unified market symbol
3229
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3230
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
3231
+ */
3232
+ async fetchPositionsForSymbol(symbol, params = {}) {
3233
+ await this.loadMarkets();
3234
+ const market = this.market(symbol);
3235
+ const request = {
3236
+ 'symbol': market['id'],
3237
+ };
3238
+ const response = await this.contractPrivateGetCapiV3AccountPositionSinglePosition(this.extend(request, params));
3239
+ return this.parsePositions(response, [market['symbol']]);
3240
+ }
3241
+ parsePosition(position, market = undefined) {
3242
+ //
3243
+ // {
3244
+ // "id": 737191855967437160,
3245
+ // "asset": "USDT",
3246
+ // "symbol": "DOGEUSDT",
3247
+ // "side": "LONG",
3248
+ // "marginType": "CROSSED",
3249
+ // "separatedMode": "COMBINED",
3250
+ // "separatedOpenOrderId": 0,
3251
+ // "leverage": "20.00",
3252
+ // "size": "300",
3253
+ // "openValue": "27.96900",
3254
+ // "openFee": "0.02237520",
3255
+ // "fundingFee": "0",
3256
+ // "marginSize": "100",
3257
+ // "isolatedMargin": "0",
3258
+ // "isAutoAppendIsolatedMargin": false,
3259
+ // "cumOpenSize": "300",
3260
+ // "cumOpenValue": "27.96900",
3261
+ // "cumOpenFee": "0.02237520",
3262
+ // "cumCloseSize": "0",
3263
+ // "cumCloseValue": "0",
3264
+ // "cumCloseFee": "0",
3265
+ // "cumFundingFee": "0",
3266
+ // "cumLiquidateFee": "0",
3267
+ // "createdMatchSequenceId": 5762536243,
3268
+ // "updatedMatchSequenceId": 5762741613,
3269
+ // "createdTime": 1775760234825,
3270
+ // "updatedTime": 1775763170789,
3271
+ // "unrealizePnl": "0.00600",
3272
+ // "liquidatePrice": "0"
3273
+ // }
3274
+ //
3275
+ // watchPoisions
3276
+ // {
3277
+ // "id": "739004481374519656",
3278
+ // "coin": "USDT",
3279
+ // "symbol": "DOGEUSDT",
3280
+ // "side": "LONG",
3281
+ // "marginMode": "CROSSED",
3282
+ // "separatedMode": "COMBINED",
3283
+ // "separatedOpenOrderId": "0",
3284
+ // "leverage": "11",
3285
+ // "size": "100",
3286
+ // "openValue": "9.31100",
3287
+ // "openFee": "0.00744880",
3288
+ // "fundingFee": "0",
3289
+ // "isolatedMargin": "0",
3290
+ // "autoAppendIsolatedMargin": false,
3291
+ // "cumOpenSize": "100",
3292
+ // "cumOpenValue": "9.31100",
3293
+ // "cumOpenFee": "0.00744880",
3294
+ // "cumCloseSize": "0",
3295
+ // "cumCloseValue": "0",
3296
+ // "cumCloseFee": "0",
3297
+ // "cumFundingFee": "0",
3298
+ // "cumLiquidateFee": "0",
3299
+ // "createdMatchSequenceId": "5792711540",
3300
+ // "updatedMatchSequenceId": "5792711540",
3301
+ // "createdTime": "1776192398399",
3302
+ // "updatedTime": "1776192398399"
3303
+ // }
3304
+ //
3305
+ const errorMessage = this.safeString(position, 'errorMsg');
3306
+ const errorCode = this.safeString(position, 'errorCode');
3307
+ if (errorMessage !== undefined) {
3308
+ this.handleOrderOrPositionError(errorCode, errorMessage, position);
3309
+ }
3310
+ const marketId = this.safeString(position, 'symbol');
3311
+ market = this.safeMarket(marketId, market, undefined, 'contract');
3312
+ const timestamp = this.safeInteger(position, 'createdTime');
3313
+ const marginType = this.safeString2(position, 'marginType', 'marginMode');
3314
+ let marginMode = 'cross';
3315
+ if (marginType === 'ISOLATED') {
3316
+ marginMode = 'isolated';
3317
+ }
3318
+ const separatedMode = this.safeString(position, 'separatedMode');
3319
+ let hedged = undefined;
3320
+ if (separatedMode === 'COMBINED') {
3321
+ hedged = false;
3322
+ }
3323
+ else if (separatedMode === 'SEPARATED') {
3324
+ hedged = true;
3325
+ }
3326
+ return this.safePosition({
3327
+ 'symbol': market['symbol'],
3328
+ 'id': this.safeString2(position, 'id', 'positionId'),
3329
+ 'timestamp': timestamp,
3330
+ 'datetime': this.iso8601(timestamp),
3331
+ 'contracts': this.safeNumber(position, 'size'),
3332
+ 'contractSize': undefined,
3333
+ 'side': this.safeStringLower(position, 'side'),
3334
+ 'notional': this.safeNumber(position, 'openValue'),
3335
+ 'leverage': this.safeNumber(position, 'leverage'),
3336
+ 'unrealizedPnl': this.safeNumber(position, 'unrealizePnl'),
3337
+ 'realizedPnl': undefined,
3338
+ 'collateral': undefined,
3339
+ 'entryPrice': undefined,
3340
+ 'markPrice': undefined,
3341
+ 'liquidationPrice': this.safeNumber(position, 'liquidatePrice'),
3342
+ 'marginMode': marginMode,
3343
+ 'hedged': hedged,
3344
+ 'maintenanceMargin': undefined,
3345
+ 'maintenanceMarginPercentage': undefined,
3346
+ 'initialMargin': this.safeNumber(position, 'marginSize'),
3347
+ 'initialMarginPercentage': undefined,
3348
+ 'marginRatio': undefined,
3349
+ 'lastUpdateTimestamp': this.safeInteger(position, 'updatedTime'),
3350
+ 'lastPrice': undefined,
3351
+ 'stopLossPrice': undefined,
3352
+ 'takeProfitPrice': undefined,
3353
+ 'percentage': undefined,
3354
+ 'info': undefined,
3355
+ });
3356
+ }
3357
+ /**
3358
+ * @method
3359
+ * @name weex#closeAllPositions
3360
+ * @description closes all open positions for a market type
3361
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/ClosePositions
3362
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3363
+ * @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
3364
+ */
3365
+ async closeAllPositions(params = {}) {
3366
+ await this.loadMarkets();
3367
+ const response = await this.contractPrivatePostCapiV3ClosePositions(params);
3368
+ //
3369
+ // [
3370
+ // {
3371
+ // "positionId": 737191855967437160,
3372
+ // "successOrderId": 737215340433375592,
3373
+ // "errorMessage": "",
3374
+ // "success": true
3375
+ // }
3376
+ // ]
3377
+ //
3378
+ return this.parsePositions(response);
3379
+ }
3380
+ /**
3381
+ * @method
3382
+ * @name weex#closePosition
3383
+ * @description closes open positions for a market
3384
+ * @see https://www.weex.com/api-doc/contract/Transaction_API/ClosePositions
3385
+ * @param {string} symbol Unified CCXT market symbol
3386
+ * @param {string} [side] not used by current exchange
3387
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3388
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
3389
+ */
3390
+ async closePosition(symbol, side = undefined, params = {}) {
3391
+ await this.loadMarkets();
3392
+ const market = this.market(symbol);
3393
+ const request = {
3394
+ 'symbol': market['id'],
3395
+ };
3396
+ const response = await this.contractPrivatePostCapiV3ClosePositions(this.extend(request, params));
3397
+ const orders = this.parseOrders(response, market);
3398
+ return this.safeDict(orders, 0);
3399
+ }
3400
+ /**
3401
+ * @method
3402
+ * @name weex#fetchTradingFee
3403
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetCommissionRate // contract
3404
+ * @description fetch the trading fees for a contract market
3405
+ * @param {string} symbol unified market symbol
3406
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3407
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
3408
+ */
3409
+ async fetchTradingFee(symbol, params = {}) {
3410
+ await this.loadMarkets();
3411
+ const market = this.market(symbol);
3412
+ if (market['spot']) {
3413
+ // spot markets return 0 for fees
3414
+ throw new NotSupported(this.id + ' fetchTradingFee() is not supported for spot markets');
3415
+ }
3416
+ const request = {
3417
+ 'symbol': market['id'],
3418
+ };
3419
+ const response = await this.contractPrivateGetCapiV3AccountCommissionRate(this.extend(request, params));
3420
+ //
3421
+ // {
3422
+ // "symbol": "DOGEUSDT",
3423
+ // "makerCommissionRate": "0.0002",
3424
+ // "takerCommissionRate": "0.0008"
3425
+ // }
3426
+ //
3427
+ return this.parseTradingFee(response, market);
3428
+ }
3429
+ parseTradingFee(fee, market = undefined) {
3430
+ //
3431
+ // contract
3432
+ // {
3433
+ // "symbol": "DOGEUSDT",
3434
+ // "makerCommissionRate": "0.0002",
3435
+ // "takerCommissionRate": "0.0008"
3436
+ // }
3437
+ //
3438
+ const marketId = this.safeString(fee, 'symbol');
3439
+ return {
3440
+ 'info': fee,
3441
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
3442
+ 'maker': this.safeNumber(fee, 'makerCommissionRate'),
3443
+ 'taker': this.safeNumber(fee, 'takerCommissionRate'),
3444
+ 'percentage': true,
3445
+ 'tierBased': true,
3446
+ };
3447
+ }
3448
+ /**
3449
+ * @method
3450
+ * @name weex#fetchMarginMode
3451
+ * @description fetches the margin mode of a specific symbol
3452
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetSymbolConfig
3453
+ * @param {string} symbol unified symbol of the market the order was made in
3454
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3455
+ * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/?id=margin-mode-structure}
3456
+ */
3457
+ async fetchMarginMode(symbol, params = {}) {
3458
+ await this.loadMarkets();
3459
+ const market = this.market(symbol);
3460
+ const request = {
3461
+ 'symbol': market['id'],
3462
+ };
3463
+ const response = await this.contractPrivateGetCapiV3AccountSymbolConfig(this.extend(request, params));
3464
+ //
3465
+ // [
3466
+ // {
3467
+ // "symbol": "DOGEUSDT",
3468
+ // "marginType": "CROSSED",
3469
+ // "separatedType": "COMBINED",
3470
+ // "crossLeverage": "20.00",
3471
+ // "isolatedLongLeverage": "20.00",
3472
+ // "isolatedShortLeverage": "20.00"
3473
+ // }
3474
+ // ]
3475
+ //
3476
+ const marginMode = this.safeDict(response, 0, {});
3477
+ return this.parseMarginMode(marginMode, market);
3478
+ }
3479
+ /**
3480
+ * @method
3481
+ * @name weex#fetchMarginModes
3482
+ * @description fetches margin modes the symbols, with symbols=undefined all markets are returned
3483
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetSymbolConfig
3484
+ * @param {string[]} symbols unified market symbols
3485
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3486
+ * @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/?id=margin-mode-structure}
3487
+ */
3488
+ async fetchMarginModes(symbols = undefined, params = {}) {
3489
+ await this.loadMarkets();
3490
+ symbols = this.marketSymbols(symbols);
3491
+ const response = await this.contractPrivateGetCapiV3AccountSymbolConfig(params);
3492
+ return this.parseMarginModes(response, symbols, 'symbol', 'swap');
3493
+ }
3494
+ parseMarginMode(marginMode, market = undefined) {
3495
+ const marketId = this.safeString(marginMode, 'symbol');
3496
+ const marginType = this.safeString(marginMode, 'marginType');
3497
+ return {
3498
+ 'info': marginMode,
3499
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
3500
+ 'marginMode': this.parseMarginType(marginType),
3501
+ };
3502
+ }
3503
+ parseMarginType(marginType) {
3504
+ const marginTypes = {
3505
+ 'CROSSED': 'cross',
3506
+ 'ISOLATED': 'isolated',
3507
+ };
3508
+ return this.safeString(marginTypes, marginType, marginType);
3509
+ }
3510
+ /**
3511
+ * @method
3512
+ * @name weex#setMarginMode
3513
+ * @description set margin mode to 'cross' or 'isolated'
3514
+ * @see https://www.weex.com/api-doc/contract/Account_API/ChangeMarginModeTRADE
3515
+ * @param {string} marginMode 'cross' or 'isolated'
3516
+ * @param {string} symbol unified market symbol
3517
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3518
+ * @returns {object} response from the exchange
3519
+ */
3520
+ async setMarginMode(marginMode, symbol = undefined, params = {}) {
3521
+ if (symbol === undefined) {
3522
+ throw new ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
3523
+ }
3524
+ await this.loadMarkets();
3525
+ const market = this.market(symbol);
3526
+ const request = {
3527
+ 'symbol': market['id'],
3528
+ 'marginType': this.encodeMarginMode(marginMode),
3529
+ };
3530
+ return await this.contractPrivatePostCapiV3AccountMarginType(this.extend(request, params));
3531
+ }
3532
+ encodeMarginMode(marginMode) {
3533
+ const marginTypes = {
3534
+ 'cross': 'CROSSED',
3535
+ 'isolated': 'ISOLATED',
3536
+ };
3537
+ const result = this.safeString(marginTypes, marginMode);
3538
+ if (result === undefined) {
3539
+ throw new ArgumentsRequired(this.id + ' marginMode must be either cross or isolated');
3540
+ }
3541
+ return result;
3542
+ }
3543
+ /**
3544
+ * @method
3545
+ * @name weex#fetchLeverage
3546
+ * @description fetch the set leverage for a market
3547
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetSymbolConfig
3548
+ * @param {string} symbol unified market symbol
3549
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3550
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/?id=leverage-structure}
3551
+ */
3552
+ async fetchLeverage(symbol, params = {}) {
3553
+ await this.loadMarkets();
3554
+ const market = this.market(symbol);
3555
+ const request = {
3556
+ 'symbol': market['id'],
3557
+ };
3558
+ const response = await this.contractPrivateGetCapiV3AccountSymbolConfig(this.extend(request, params));
3559
+ const marginMode = this.safeDict(response, 0, {});
3560
+ return this.parseLeverage(marginMode, market);
3561
+ }
3562
+ /**
3563
+ * @method
3564
+ * @name weex#fetchLeverages
3565
+ * @description fetch the set leverage for all markets
3566
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetSymbolConfig
3567
+ * @param {string[]} [symbols] a list of unified market symbols
3568
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3569
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
3570
+ */
3571
+ async fetchLeverages(symbols = undefined, params = {}) {
3572
+ await this.loadMarkets();
3573
+ symbols = this.marketSymbols(symbols);
3574
+ const response = await this.contractPrivateGetCapiV3AccountSymbolConfig(params);
3575
+ return this.parseLeverages(response, symbols, 'symbol', 'swap');
3576
+ }
3577
+ parseLeverage(leverage, market = undefined) {
3578
+ const marketId = this.safeString(leverage, 'symbol');
3579
+ const marginType = this.safeString(leverage, 'marginType');
3580
+ const marginMode = this.parseMarginType(marginType);
3581
+ const crossLeverage = this.safeNumber(leverage, 'crossLeverage');
3582
+ let longLeverage = this.safeNumber(leverage, 'isolatedLongLeverage');
3583
+ let shortLeverage = this.safeNumber(leverage, 'isolatedShortLeverage');
3584
+ if (marginMode === 'cross') {
3585
+ longLeverage = crossLeverage;
3586
+ shortLeverage = crossLeverage;
3587
+ }
3588
+ return {
3589
+ 'info': leverage,
3590
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
3591
+ 'marginMode': marginMode,
3592
+ 'longLeverage': longLeverage,
3593
+ 'shortLeverage': shortLeverage,
3594
+ };
3595
+ }
3596
+ /**
3597
+ * @method
3598
+ * @name weex#setLeverage
3599
+ * @description set the level of leverage for a market
3600
+ * @see https://www.weex.com/api-doc/contract/Account_API/UpdateLeverageTRADE
3601
+ * @param {float} leverage the rate of leverage
3602
+ * @param {string} symbol unified market symbol
3603
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3604
+ * @param {string} [params.marginMode] 'cross' or 'isolated' (default is 'cross' if specific leverage parameters are not provided)
3605
+ * @param {number} [params.crossLeverage] *cross margin mode only* leverage for cross margin mode when marginMode is 'cross'
3606
+ * @param {number} [params.isolatedLongLeverage] *isolated margin mode only* leverage for long positions when marginMode is 'isolated'
3607
+ * @param {number} [params.isolatedShortLeverage] *isolated margin mode only* leverage for short positions when marginMode is 'isolated'
3608
+ * If specific leverage parameters are not provided
3609
+ * the leverage value will be applied to both long and short positions if marginMode is 'isolated'
3610
+ * or to cross margin mode if marginMode is 'cross'
3611
+ * If marginMode is not provided and specific leverage parameters are not provided too
3612
+ * the leverage value will be applied to cross leverage
3613
+ * @returns {object} response from the exchange
3614
+ */
3615
+ async setLeverage(leverage, symbol = undefined, params = {}) {
3616
+ if (symbol === undefined) {
3617
+ throw new ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
3618
+ }
3619
+ await this.loadMarkets();
3620
+ const market = this.market(symbol);
3621
+ const request = {
3622
+ 'symbol': market['id'],
3623
+ };
3624
+ let marginMode = undefined;
3625
+ [marginMode, params] = this.handleMarginModeAndParams('setLeverage', params);
3626
+ if (marginMode !== undefined) {
3627
+ request['marginType'] = this.encodeMarginMode(marginMode);
3628
+ }
3629
+ const isolatedLongLeverage = this.safeNumber(params, 'isolatedLongLeverage');
3630
+ const isolatedShortLeverage = this.safeNumber(params, 'isolatedShortLeverage');
3631
+ const crossLeverage = this.safeNumber(params, 'crossLeverage');
3632
+ if ((isolatedLongLeverage === undefined) && (isolatedShortLeverage === undefined) && (crossLeverage === undefined)) {
3633
+ if (marginMode === 'isolated') {
3634
+ request['isolatedLongLeverage'] = leverage;
3635
+ request['isolatedShortLeverage'] = leverage;
3636
+ }
3637
+ else {
3638
+ request['crossLeverage'] = leverage;
3639
+ }
3640
+ }
3641
+ return await this.contractPrivatePostCapiV3AccountLeverage(this.extend(request, params));
3642
+ }
3643
+ /**
3644
+ * @method
3645
+ * @name weex#fetchPositionMode
3646
+ * @description fetchs the position mode, hedged or one way
3647
+ * @see https://www.weex.com/api-doc/contract/Account_API/GetSymbolConfig
3648
+ * @param {string} symbol unified symbol of the market to fetch the order book for
3649
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3650
+ * @returns {object} an object detailing whether the market is in hedged or one-way mode
3651
+ */
3652
+ async fetchPositionMode(symbol = undefined, params = {}) {
3653
+ await this.loadMarkets();
3654
+ const market = this.market(symbol);
3655
+ const request = {
3656
+ 'symbol': market['id'],
3657
+ };
3658
+ const response = await this.contractPrivateGetCapiV3AccountSymbolConfig(this.extend(request, params));
3659
+ const entry = this.safeDict(response, 0, {});
3660
+ const separatedType = this.safeString(entry, 'separatedType');
3661
+ return {
3662
+ 'info': response,
3663
+ 'hedged': (separatedType === 'SEPARATED'),
3664
+ };
3665
+ }
3666
+ /**
3667
+ * @method
3668
+ * @name weex#setPositionMode
3669
+ * @description set hedged to true or false for a market
3670
+ * @see https://www.weex.com/api-doc/contract/Account_API/ChangeMarginModeTRADE
3671
+ * @param {bool} hedged set to true to use dualSidePosition
3672
+ * @param {string} symbol unified market symbol
3673
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3674
+ * @param {string} params.marginMode 'cross' or 'isolated' (default is 'cross')
3675
+ * @returns {object} response from the exchange
3676
+ */
3677
+ async setPositionMode(hedged, symbol = undefined, params = {}) {
3678
+ if (symbol === undefined) {
3679
+ throw new ArgumentsRequired(this.id + ' setPositionMode() requires a symbol argument');
3680
+ }
3681
+ await this.loadMarkets();
3682
+ const market = this.market(symbol);
3683
+ let marginMode = undefined;
3684
+ [marginMode, params] = this.handleMarginModeAndParams('setPositionMode', params);
3685
+ if (marginMode === undefined) {
3686
+ throw new ArgumentsRequired(this.id + ' setPositionMode() also sets marginMode, so a marginMode parameter is required');
3687
+ }
3688
+ const separatedType = hedged ? 'SEPARATED' : 'COMBINED';
3689
+ const request = {
3690
+ 'symbol': market['id'],
3691
+ 'marginType': this.encodeMarginMode(marginMode),
3692
+ 'separatedType': separatedType,
3693
+ };
3694
+ return await this.contractPrivatePostCapiV3AccountMarginType(this.extend(request, params));
3695
+ }
3696
+ async modifyMarginHelper(symbol, amount, type, params = {}) {
3697
+ await this.loadMarkets();
3698
+ const isolatedPositionId = this.safeStringN(params, ['positionId', 'id', 'isolatedPositionId']);
3699
+ if (isolatedPositionId === undefined) {
3700
+ throw new ArgumentsRequired(this.id + ' modifyMarginHelper() requires a positionId parameter');
3701
+ }
3702
+ params = this.omit(params, ['positionId', 'id']);
3703
+ const market = this.market(symbol);
3704
+ const request = {
3705
+ 'isolatedPositionId': isolatedPositionId,
3706
+ 'amount': this.costToPrecision(symbol, amount),
3707
+ 'type': type,
3708
+ };
3709
+ const parsedType = (type === 1) ? 'add' : 'reduce';
3710
+ const response = await this.contractPrivatePostCapiV3AccountPositionMargin(this.extend(request, params));
3711
+ return this.extend(this.parseMarginModification(response, market), {
3712
+ 'amount': this.parseNumber(amount),
3713
+ 'type': parsedType,
3714
+ });
3715
+ }
3716
+ parseMarginModification(data, market = undefined) {
3717
+ //
3718
+ // {
3719
+ // "code": "200",
3720
+ // "msg": "success",
3721
+ // "requestTime": 1764505776347
3722
+ // }
3723
+ //
3724
+ const msg = this.safeString(data, 'msg');
3725
+ const status = (msg === 'success') ? 'ok' : 'failed';
3726
+ const timestamp = this.safeInteger(data, 'requestTime');
3727
+ return {
3728
+ 'info': data,
3729
+ 'symbol': market['symbol'],
3730
+ 'type': undefined,
3731
+ 'marginMode': 'isolated',
3732
+ 'amount': undefined,
3733
+ 'total': undefined,
3734
+ 'code': market['settle'],
3735
+ 'status': status,
3736
+ 'timestamp': timestamp,
3737
+ 'datetime': this.iso8601(timestamp),
3738
+ };
3739
+ }
3740
+ /**
3741
+ * @method
3742
+ * @name weex#reduceMargin
3743
+ * @description remove margin from a position
3744
+ * @see https://www.weex.com/api-doc/contract/Account_API/AdjustPositionMarginTRADE
3745
+ * @param {string} symbol unified market symbol
3746
+ * @param {float} amount the amount of margin to remove
3747
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3748
+ * @param {string} params.positionId the id of the position to reduce margin from, required
3749
+ * @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
3750
+ */
3751
+ async reduceMargin(symbol, amount, params = {}) {
3752
+ return await this.modifyMarginHelper(symbol, amount, 2, params);
3753
+ }
3754
+ /**
3755
+ * @method
3756
+ * @name weex#addMargin
3757
+ * @description add margin
3758
+ * @see https://www.weex.com/api-doc/contract/Account_API/AdjustPositionMarginTRADE
3759
+ * @param {string} symbol unified market symbol
3760
+ * @param {float} amount amount of margin to add
3761
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3762
+ * @param {string} params.positionId the id of the position to add margin to, required
3763
+ * @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
3764
+ */
3765
+ async addMargin(symbol, amount, params = {}) {
3766
+ return await this.modifyMarginHelper(symbol, amount, 1, params);
3767
+ }
3768
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3769
+ let endpoint = this.implodeParams(path, params);
3770
+ const query = this.omit(params, this.extractParams(path));
3771
+ const isBatch = (path.indexOf('batch') >= 0);
3772
+ if (!isBatch && ((method === 'GET') || (method === 'DELETE'))) {
3773
+ if (Object.keys(query).length) {
3774
+ endpoint += '?' + this.urlencode(query);
3775
+ }
3776
+ }
3777
+ if ((api === 'private') || (api === 'contractPrivate')) {
3778
+ this.checkRequiredCredentials();
3779
+ const timestamp = this.numberToString(this.nonce());
3780
+ let payload = timestamp + method + '/' + endpoint;
3781
+ if ((method === 'POST') || isBatch) {
3782
+ body = this.json(query);
3783
+ payload += body;
3784
+ }
3785
+ const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha256, 'base64');
3786
+ headers = {
3787
+ 'ACCESS-KEY': this.apiKey,
3788
+ 'ACCESS-SIGN': signature,
3789
+ 'ACCESS-PASSPHRASE': this.password,
3790
+ 'ACCESS-TIMESTAMP': timestamp,
3791
+ };
3792
+ if ((method === 'POST') || (method === 'DELETE')) {
3793
+ headers['Content-Type'] = 'application/json';
3794
+ }
3795
+ }
3796
+ else {
3797
+ headers = {
3798
+ 'User-Agent': 'ccxt',
3799
+ };
3800
+ }
3801
+ const url = this.urls['api'][api] + '/' + endpoint;
3802
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3803
+ }
3804
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3805
+ //
3806
+ // {
3807
+ // "code": -1140,
3808
+ // "msg": "Either orderId or origClientOrderId must be sent."
3809
+ // }
3810
+ //
3811
+ const message = this.safeString(response, 'msg');
3812
+ if (message !== undefined) {
3813
+ const errorCode = this.safeString(response, 'code');
3814
+ const feedback = this.id + ' ' + body;
3815
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
3816
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
3817
+ this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
3818
+ throw new ExchangeError(this.id + ' ' + body);
3819
+ }
3820
+ return undefined;
3821
+ }
3822
+ }