ccxt 4.5.50 → 4.5.52

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 (995) hide show
  1. package/README.md +10 -9
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -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 +1 -1
  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 +1 -1
  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 +0 -1
  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 +1533 -1073
  110. package/dist/cjs/src/backpack.js +1 -1
  111. package/dist/cjs/src/base/Exchange.js +44 -36
  112. package/dist/cjs/src/base/Precise.js +0 -6
  113. package/dist/cjs/src/base/errors.js +0 -6
  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 +0 -1
  118. package/dist/cjs/src/base/functions/number.js +0 -6
  119. package/dist/cjs/src/base/functions/platform.js +0 -6
  120. package/dist/cjs/src/base/functions/rsa.js +0 -1
  121. package/dist/cjs/src/base/functions/string.js +0 -6
  122. package/dist/cjs/src/base/functions/throttle.js +1 -1
  123. package/dist/cjs/src/base/functions/time.js +0 -6
  124. package/dist/cjs/src/base/functions/totp.js +0 -1
  125. package/dist/cjs/src/base/functions/type.js +0 -6
  126. package/dist/cjs/src/base/functions.js +1 -1
  127. package/dist/cjs/src/base/ws/Cache.js +0 -6
  128. package/dist/cjs/src/base/ws/Client.js +0 -1
  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 +0 -6
  132. package/dist/cjs/src/base/ws/WsClient.js +1 -1
  133. package/dist/cjs/src/bequant.js +4 -1
  134. package/dist/cjs/src/bigone.js +1 -1
  135. package/dist/cjs/src/binance.js +59 -48
  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 +2 -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 +1 -1
  144. package/dist/cjs/src/bitflyer.js +1 -1
  145. package/dist/cjs/src/bitget.js +6 -4
  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 +1 -1
  155. package/dist/cjs/src/blockchaincom.js +1 -1
  156. package/dist/cjs/src/blofin.js +26 -31
  157. package/dist/cjs/src/btcbox.js +1 -1
  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 +1 -1
  161. package/dist/cjs/src/bybit.js +1 -1
  162. package/dist/cjs/src/bydfi.js +2 -3
  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 +0 -1
  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 -2
  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 +28 -21
  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 +0 -1
  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 +7 -2
  197. package/dist/cjs/src/krakenfutures.js +1 -1
  198. package/dist/cjs/src/kucoin.js +246 -111
  199. package/dist/cjs/src/kucoinfutures.js +1 -2
  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 +9 -3
  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 +1 -1
  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 +1 -1
  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 +1 -1
  216. package/dist/cjs/src/paradex.js +1 -1
  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 +154 -181
  224. package/dist/cjs/src/pro/backpack.js +1 -1
  225. package/dist/cjs/src/pro/bequant.js +5 -4
  226. package/dist/cjs/src/pro/binance.js +4 -1
  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 +7 -2
  230. package/dist/cjs/src/pro/bingx.js +1 -1
  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 +1 -1
  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 +1 -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 +1 -1
  245. package/dist/cjs/src/pro/coinbase.js +1 -1
  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 +78 -7
  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 +8 -9
  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 +1191 -104
  271. package/dist/cjs/src/pro/kucoinfutures.js +1 -2
  272. package/dist/cjs/src/pro/lbank.js +0 -1
  273. package/dist/cjs/src/pro/lighter.js +1 -1
  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 +1 -1
  284. package/dist/cjs/src/pro/paradex.js +1 -1
  285. package/dist/cjs/src/pro/phemex.js +1 -1
  286. package/dist/cjs/src/pro/poloniex.js +1 -1
  287. package/dist/cjs/src/pro/toobit.js +1 -1
  288. package/dist/cjs/src/pro/upbit.js +1 -1
  289. package/dist/cjs/src/pro/weex.js +1 -1
  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 +1 -0
  293. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +0 -1
  294. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +0 -1
  295. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +0 -1
  296. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +0 -1
  297. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +0 -1
  298. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +0 -1
  299. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +0 -1
  300. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +0 -1
  301. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +0 -1
  302. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +0 -1
  303. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +0 -1
  304. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +0 -1
  305. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +0 -1
  306. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +0 -1
  307. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +0 -6
  308. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +0 -1
  309. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +0 -1
  310. package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +0 -6
  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 +0 -6
  313. package/dist/cjs/src/static_dependencies/ethers/coders/address.js +0 -1
  314. package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +0 -1
  315. package/dist/cjs/src/static_dependencies/ethers/coders/array.js +0 -1
  316. package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +0 -1
  317. package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +0 -1
  318. package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +0 -1
  319. package/dist/cjs/src/static_dependencies/ethers/coders/null.js +0 -1
  320. package/dist/cjs/src/static_dependencies/ethers/coders/number.js +0 -1
  321. package/dist/cjs/src/static_dependencies/ethers/coders/string.js +0 -1
  322. package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +0 -1
  323. package/dist/cjs/src/static_dependencies/ethers/fragments.js +0 -6
  324. package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +0 -6
  325. package/dist/cjs/src/static_dependencies/ethers/index.js +10 -1
  326. package/dist/cjs/src/static_dependencies/ethers/interface.js +0 -6
  327. package/dist/cjs/src/static_dependencies/ethers/typed.js +0 -6
  328. package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +13 -1
  329. package/dist/cjs/src/static_dependencies/ethers/utils/data.js +6 -1
  330. package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +9 -1
  331. package/dist/cjs/src/static_dependencies/ethers/utils/events.js +0 -6
  332. package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +0 -6
  333. package/dist/cjs/src/static_dependencies/ethers/utils/index.js +7 -1
  334. package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +5 -1
  335. package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +0 -6
  336. package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +8 -1
  337. package/dist/cjs/src/static_dependencies/fflake/browser.js +1 -1
  338. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -1
  339. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -1
  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 +0 -6
  342. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -6
  343. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -6
  344. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -1
  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 +0 -6
  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 +0 -6
  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 +0 -6
  352. package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +0 -6
  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 +0 -1
  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 +0 -6
  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 +0 -6
  366. package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +0 -1
  367. package/dist/cjs/src/static_dependencies/noble-hashes/_u64.js +0 -6
  368. package/dist/cjs/src/static_dependencies/noble-hashes/crypto.js +0 -6
  369. package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +0 -1
  370. package/dist/cjs/src/static_dependencies/noble-hashes/md5.js +0 -1
  371. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +0 -1
  372. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +0 -1
  373. package/dist/cjs/src/static_dependencies/noble-hashes/sha1.js +0 -1
  374. package/dist/cjs/src/static_dependencies/noble-hashes/sha256.js +0 -1
  375. package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +0 -1
  376. package/dist/cjs/src/static_dependencies/noble-hashes/sha512.js +0 -1
  377. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +1 -1
  378. package/dist/cjs/src/static_dependencies/node-fetch/body.js +5 -1
  379. package/dist/cjs/src/static_dependencies/node-fetch/errors/abort-error.js +0 -1
  380. package/dist/cjs/src/static_dependencies/node-fetch/errors/base.js +0 -6
  381. package/dist/cjs/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -1
  382. package/dist/cjs/src/static_dependencies/node-fetch/headers.js +5 -1
  383. package/dist/cjs/src/static_dependencies/node-fetch/index.js +7 -1
  384. package/dist/cjs/src/static_dependencies/node-fetch/request.js +7 -1
  385. package/dist/cjs/src/static_dependencies/node-fetch/response.js +5 -1
  386. package/dist/cjs/src/static_dependencies/node-fetch/utils/get-search.js +0 -6
  387. package/dist/cjs/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -6
  388. package/dist/cjs/src/static_dependencies/node-fetch/utils/is.js +0 -6
  389. package/dist/cjs/src/static_dependencies/node-fetch/utils/referrer.js +0 -1
  390. package/dist/cjs/src/static_dependencies/proxies/agent-base/index.js +0 -1
  391. package/dist/cjs/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -1
  392. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -1
  393. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -6
  394. package/dist/cjs/src/static_dependencies/qs/formats.js +0 -6
  395. package/dist/cjs/src/static_dependencies/qs/index.js +0 -1
  396. package/dist/cjs/src/static_dependencies/qs/parse.js +0 -1
  397. package/dist/cjs/src/static_dependencies/qs/stringify.js +0 -1
  398. package/dist/cjs/src/static_dependencies/qs/utils.js +0 -6
  399. package/dist/cjs/src/static_dependencies/scure-base/index.js +0 -6
  400. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +19 -1
  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 +0 -6
  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 +0 -6
  406. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/abi.js +0 -6
  407. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/index.js +0 -6
  408. package/dist/cjs/src/static_dependencies/starknet/types/lib/index.js +0 -6
  409. package/dist/cjs/src/static_dependencies/starknet/types/typedData.js +0 -6
  410. package/dist/cjs/src/static_dependencies/starknet/utils/assert.js +0 -6
  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 +0 -1
  415. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/cairo.js +0 -1
  416. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +0 -6
  417. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +0 -6
  418. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +0 -6
  419. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/formatter.js +0 -1
  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 +0 -1
  422. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +0 -1
  423. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +0 -6
  424. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +0 -1
  425. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/requestParser.js +0 -1
  426. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/responseParser.js +0 -1
  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 +4 -1
  429. package/dist/cjs/src/static_dependencies/starknet/utils/encode.js +0 -1
  430. package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +3 -1
  431. package/dist/cjs/src/static_dependencies/starknet/utils/merkle.js +0 -1
  432. package/dist/cjs/src/static_dependencies/starknet/utils/num.js +0 -1
  433. package/dist/cjs/src/static_dependencies/starknet/utils/selector.js +0 -1
  434. package/dist/cjs/src/static_dependencies/starknet/utils/shortString.js +0 -1
  435. package/dist/cjs/src/static_dependencies/starknet/utils/typedData.js +1 -1
  436. package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +0 -6
  437. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +0 -6
  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 +1 -1
  443. package/dist/cjs/src/whitebit.js +3 -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 +1 -1
  452. package/js/ccxt.js +1 -7
  453. package/js/src/abstract/aftermath.js +0 -6
  454. package/js/src/abstract/alpaca.js +0 -6
  455. package/js/src/abstract/apex.js +0 -6
  456. package/js/src/abstract/arkham.js +0 -6
  457. package/js/src/abstract/ascendex.js +0 -6
  458. package/js/src/abstract/aster.d.ts +43 -9
  459. package/js/src/abstract/aster.js +0 -6
  460. package/js/src/abstract/backpack.js +0 -6
  461. package/js/src/abstract/bequant.js +0 -6
  462. package/js/src/abstract/bigone.js +0 -6
  463. package/js/src/abstract/binance.js +0 -6
  464. package/js/src/abstract/binancecoinm.js +0 -6
  465. package/js/src/abstract/binanceus.js +0 -6
  466. package/js/src/abstract/binanceusdm.js +0 -6
  467. package/js/src/abstract/bingx.js +0 -6
  468. package/js/src/abstract/bit2c.js +0 -6
  469. package/js/src/abstract/bitbank.js +0 -6
  470. package/js/src/abstract/bitbns.js +0 -6
  471. package/js/src/abstract/bitfinex.js +0 -6
  472. package/js/src/abstract/bitflyer.js +0 -6
  473. package/js/src/abstract/bitget.js +0 -6
  474. package/js/src/abstract/bithumb.js +0 -6
  475. package/js/src/abstract/bitmart.js +0 -6
  476. package/js/src/abstract/bitmex.js +0 -6
  477. package/js/src/abstract/bitopro.js +0 -6
  478. package/js/src/abstract/bitrue.js +0 -6
  479. package/js/src/abstract/bitso.js +0 -6
  480. package/js/src/abstract/bitstamp.js +0 -6
  481. package/js/src/abstract/bitteam.js +0 -6
  482. package/js/src/abstract/bittrade.js +0 -6
  483. package/js/src/abstract/bitvavo.js +0 -6
  484. package/js/src/abstract/blockchaincom.js +0 -6
  485. package/js/src/abstract/blofin.js +0 -6
  486. package/js/src/abstract/btcbox.js +0 -6
  487. package/js/src/abstract/btcmarkets.js +0 -6
  488. package/js/src/abstract/btcturk.js +0 -6
  489. package/js/src/abstract/bullish.js +0 -6
  490. package/js/src/abstract/bybit.js +0 -6
  491. package/js/src/abstract/bydfi.js +0 -6
  492. package/js/src/abstract/cex.js +0 -6
  493. package/js/src/abstract/coinbase.js +0 -6
  494. package/js/src/abstract/coinbaseadvanced.js +0 -6
  495. package/js/src/abstract/coinbaseexchange.js +0 -6
  496. package/js/src/abstract/coinbaseinternational.js +0 -6
  497. package/js/src/abstract/coincheck.js +0 -6
  498. package/js/src/abstract/coinex.js +0 -6
  499. package/js/src/abstract/coinmate.js +0 -6
  500. package/js/src/abstract/coinmetro.js +0 -6
  501. package/js/src/abstract/coinone.js +0 -6
  502. package/js/src/abstract/coinsph.js +0 -6
  503. package/js/src/abstract/coinspot.js +0 -6
  504. package/js/src/abstract/cryptocom.js +0 -6
  505. package/js/src/abstract/cryptomus.js +0 -6
  506. package/js/src/abstract/deepcoin.js +0 -6
  507. package/js/src/abstract/delta.js +0 -6
  508. package/js/src/abstract/deribit.js +0 -6
  509. package/js/src/abstract/derive.js +0 -6
  510. package/js/src/abstract/digifinex.js +0 -6
  511. package/js/src/abstract/dydx.js +0 -6
  512. package/js/src/abstract/exmo.js +0 -6
  513. package/js/src/abstract/fmfwio.js +0 -6
  514. package/js/src/abstract/foxbit.js +0 -6
  515. package/js/src/abstract/gate.js +0 -6
  516. package/js/src/abstract/gateio.js +0 -6
  517. package/js/src/abstract/gemini.js +0 -6
  518. package/js/src/abstract/grvt.js +0 -6
  519. package/js/src/abstract/hashkey.js +0 -6
  520. package/js/src/abstract/hibachi.js +0 -6
  521. package/js/src/abstract/hitbtc.js +0 -6
  522. package/js/src/abstract/hollaex.js +0 -6
  523. package/js/src/abstract/htx.js +0 -6
  524. package/js/src/abstract/huobi.js +0 -6
  525. package/js/src/abstract/hyperliquid.js +0 -6
  526. package/js/src/abstract/independentreserve.js +0 -6
  527. package/js/src/abstract/indodax.js +0 -6
  528. package/js/src/abstract/kraken.js +0 -6
  529. package/js/src/abstract/krakenfutures.js +0 -6
  530. package/js/src/abstract/kucoin.d.ts +5 -0
  531. package/js/src/abstract/kucoin.js +0 -6
  532. package/js/src/abstract/kucoinfutures.d.ts +5 -0
  533. package/js/src/abstract/kucoinfutures.js +0 -6
  534. package/js/src/abstract/latoken.js +0 -6
  535. package/js/src/abstract/lbank.js +0 -6
  536. package/js/src/abstract/lighter.js +0 -6
  537. package/js/src/abstract/luno.js +0 -6
  538. package/js/src/abstract/mercado.js +0 -6
  539. package/js/src/abstract/mexc.js +0 -6
  540. package/js/src/abstract/modetrade.js +0 -6
  541. package/js/src/abstract/myokx.js +0 -6
  542. package/js/src/abstract/ndax.js +0 -6
  543. package/js/src/abstract/novadax.js +0 -6
  544. package/js/src/abstract/okx.js +0 -6
  545. package/js/src/abstract/okxus.js +0 -6
  546. package/js/src/abstract/onetrading.js +0 -6
  547. package/js/src/abstract/oxfun.js +0 -6
  548. package/js/src/abstract/p2b.js +0 -6
  549. package/js/src/abstract/pacifica.js +0 -6
  550. package/js/src/abstract/paradex.js +0 -6
  551. package/js/src/abstract/paymium.js +0 -6
  552. package/js/src/abstract/phemex.js +0 -6
  553. package/js/src/abstract/poloniex.js +0 -6
  554. package/js/src/abstract/tokocrypto.js +0 -6
  555. package/js/src/abstract/toobit.js +0 -6
  556. package/js/src/abstract/upbit.js +0 -6
  557. package/js/src/abstract/wavesexchange.js +0 -6
  558. package/js/src/abstract/weex.js +0 -6
  559. package/js/src/abstract/whitebit.js +0 -6
  560. package/js/src/abstract/woo.js +0 -6
  561. package/js/src/abstract/woofipro.js +0 -6
  562. package/js/src/abstract/xt.js +0 -6
  563. package/js/src/abstract/yobit.js +0 -6
  564. package/js/src/abstract/zaif.js +0 -6
  565. package/js/src/abstract/zebpay.js +0 -6
  566. package/js/src/abstract/zonda.js +0 -6
  567. package/js/src/aftermath.js +0 -6
  568. package/js/src/alpaca.js +0 -6
  569. package/js/src/apex.js +0 -6
  570. package/js/src/arkham.js +0 -6
  571. package/js/src/ascendex.js +0 -6
  572. package/js/src/aster.d.ts +136 -71
  573. package/js/src/aster.js +1532 -1078
  574. package/js/src/backpack.js +0 -6
  575. package/js/src/base/Exchange.d.ts +4 -4
  576. package/js/src/base/Exchange.js +44 -42
  577. package/js/src/base/Precise.js +0 -6
  578. package/js/src/base/errorHierarchy.js +0 -6
  579. package/js/src/base/errors.js +0 -6
  580. package/js/src/base/functions/crypto.js +0 -6
  581. package/js/src/base/functions/encode.js +0 -6
  582. package/js/src/base/functions/generic.js +0 -6
  583. package/js/src/base/functions/io.js +0 -6
  584. package/js/src/base/functions/misc.js +0 -6
  585. package/js/src/base/functions/number.js +0 -6
  586. package/js/src/base/functions/platform.js +0 -6
  587. package/js/src/base/functions/rsa.js +0 -6
  588. package/js/src/base/functions/string.js +0 -6
  589. package/js/src/base/functions/throttle.js +0 -6
  590. package/js/src/base/functions/time.js +0 -6
  591. package/js/src/base/functions/totp.js +0 -6
  592. package/js/src/base/functions/type.js +0 -6
  593. package/js/src/base/functions.js +0 -6
  594. package/js/src/base/types.js +0 -6
  595. package/js/src/base/ws/Cache.js +0 -6
  596. package/js/src/base/ws/Client.js +0 -6
  597. package/js/src/base/ws/Future.js +0 -6
  598. package/js/src/base/ws/OrderBook.js +0 -6
  599. package/js/src/base/ws/OrderBookSide.js +0 -6
  600. package/js/src/base/ws/WsClient.js +0 -6
  601. package/js/src/base/ws/functions.js +0 -6
  602. package/js/src/bequant.js +3 -6
  603. package/js/src/bigone.js +0 -6
  604. package/js/src/binance.d.ts +1 -1
  605. package/js/src/binance.js +57 -48
  606. package/js/src/binancecoinm.js +0 -6
  607. package/js/src/binanceus.js +0 -6
  608. package/js/src/binanceusdm.js +1 -6
  609. package/js/src/bingx.js +0 -6
  610. package/js/src/bit2c.js +0 -6
  611. package/js/src/bitbank.js +0 -6
  612. package/js/src/bitbns.js +0 -6
  613. package/js/src/bitfinex.js +0 -6
  614. package/js/src/bitflyer.js +0 -6
  615. package/js/src/bitget.js +5 -9
  616. package/js/src/bithumb.js +0 -6
  617. package/js/src/bitmart.js +0 -6
  618. package/js/src/bitmex.js +0 -6
  619. package/js/src/bitopro.js +0 -6
  620. package/js/src/bitrue.js +0 -6
  621. package/js/src/bitso.js +0 -6
  622. package/js/src/bitstamp.js +0 -6
  623. package/js/src/bitteam.js +0 -6
  624. package/js/src/bittrade.js +0 -6
  625. package/js/src/bitvavo.js +0 -6
  626. package/js/src/blockchaincom.js +0 -6
  627. package/js/src/blofin.js +25 -36
  628. package/js/src/btcbox.js +0 -6
  629. package/js/src/btcmarkets.js +0 -6
  630. package/js/src/btcturk.js +0 -6
  631. package/js/src/bullish.js +0 -6
  632. package/js/src/bybit.js +0 -6
  633. package/js/src/bydfi.js +1 -7
  634. package/js/src/cex.js +0 -6
  635. package/js/src/coinbase.js +0 -6
  636. package/js/src/coinbaseadvanced.js +0 -6
  637. package/js/src/coinbaseexchange.js +0 -6
  638. package/js/src/coinbaseinternational.js +0 -6
  639. package/js/src/coincheck.js +0 -6
  640. package/js/src/coinex.js +0 -6
  641. package/js/src/coinmate.js +0 -6
  642. package/js/src/coinmetro.js +0 -6
  643. package/js/src/coinone.js +0 -6
  644. package/js/src/coinsph.js +0 -6
  645. package/js/src/coinspot.js +0 -6
  646. package/js/src/cryptocom.js +0 -6
  647. package/js/src/cryptomus.js +0 -6
  648. package/js/src/deepcoin.js +1 -7
  649. package/js/src/delta.js +0 -6
  650. package/js/src/deribit.js +0 -6
  651. package/js/src/derive.js +0 -6
  652. package/js/src/digifinex.js +0 -6
  653. package/js/src/dydx.js +0 -6
  654. package/js/src/exmo.js +0 -6
  655. package/js/src/fmfwio.js +0 -6
  656. package/js/src/foxbit.js +0 -6
  657. package/js/src/gate.js +0 -6
  658. package/js/src/gateio.js +0 -6
  659. package/js/src/gemini.js +0 -6
  660. package/js/src/grvt.js +27 -26
  661. package/js/src/hashkey.js +0 -6
  662. package/js/src/hibachi.js +0 -6
  663. package/js/src/hitbtc.js +0 -6
  664. package/js/src/hollaex.js +0 -6
  665. package/js/src/htx.js +0 -6
  666. package/js/src/huobi.js +0 -6
  667. package/js/src/hyperliquid.js +0 -6
  668. package/js/src/independentreserve.js +0 -6
  669. package/js/src/indodax.js +0 -6
  670. package/js/src/kraken.js +6 -7
  671. package/js/src/krakenfutures.js +0 -6
  672. package/js/src/kucoin.d.ts +27 -11
  673. package/js/src/kucoin.js +245 -116
  674. package/js/src/kucoinfutures.js +0 -7
  675. package/js/src/latoken.js +0 -6
  676. package/js/src/lbank.js +0 -6
  677. package/js/src/lighter.js +8 -8
  678. package/js/src/luno.js +0 -6
  679. package/js/src/mercado.js +0 -6
  680. package/js/src/mexc.js +0 -6
  681. package/js/src/modetrade.js +0 -6
  682. package/js/src/myokx.js +0 -6
  683. package/js/src/ndax.js +0 -6
  684. package/js/src/novadax.js +0 -6
  685. package/js/src/okx.js +0 -6
  686. package/js/src/okxus.js +0 -6
  687. package/js/src/onetrading.js +0 -6
  688. package/js/src/oxfun.js +0 -6
  689. package/js/src/p2b.js +0 -6
  690. package/js/src/pacifica.js +0 -6
  691. package/js/src/paradex.js +0 -6
  692. package/js/src/paymium.js +0 -6
  693. package/js/src/phemex.js +0 -6
  694. package/js/src/poloniex.js +0 -6
  695. package/js/src/pro/aftermath.js +0 -6
  696. package/js/src/pro/alpaca.js +0 -6
  697. package/js/src/pro/apex.js +0 -6
  698. package/js/src/pro/arkham.js +0 -6
  699. package/js/src/pro/ascendex.js +0 -6
  700. package/js/src/pro/aster.d.ts +82 -46
  701. package/js/src/pro/aster.js +153 -186
  702. package/js/src/pro/backpack.js +0 -6
  703. package/js/src/pro/bequant.js +4 -9
  704. package/js/src/pro/binance.js +4 -7
  705. package/js/src/pro/binancecoinm.js +0 -6
  706. package/js/src/pro/binanceus.js +0 -6
  707. package/js/src/pro/binanceusdm.js +6 -7
  708. package/js/src/pro/bingx.js +0 -6
  709. package/js/src/pro/bitfinex.js +0 -6
  710. package/js/src/pro/bitget.js +0 -6
  711. package/js/src/pro/bithumb.js +0 -6
  712. package/js/src/pro/bitmart.js +0 -6
  713. package/js/src/pro/bitmex.js +0 -6
  714. package/js/src/pro/bitopro.js +0 -6
  715. package/js/src/pro/bitrue.js +0 -6
  716. package/js/src/pro/bitstamp.js +0 -6
  717. package/js/src/pro/bittrade.js +0 -6
  718. package/js/src/pro/bitvavo.js +0 -6
  719. package/js/src/pro/blockchaincom.js +0 -6
  720. package/js/src/pro/blofin.js +0 -6
  721. package/js/src/pro/bullish.js +0 -6
  722. package/js/src/pro/bybit.js +0 -6
  723. package/js/src/pro/bydfi.js +0 -6
  724. package/js/src/pro/cex.js +0 -6
  725. package/js/src/pro/coinbase.js +0 -6
  726. package/js/src/pro/coinbaseadvanced.js +0 -6
  727. package/js/src/pro/coinbaseexchange.js +0 -6
  728. package/js/src/pro/coinbaseinternational.js +0 -6
  729. package/js/src/pro/coincheck.js +0 -6
  730. package/js/src/pro/coinex.js +0 -6
  731. package/js/src/pro/coinone.js +0 -6
  732. package/js/src/pro/cryptocom.js +0 -6
  733. package/js/src/pro/deepcoin.js +0 -6
  734. package/js/src/pro/deribit.js +0 -6
  735. package/js/src/pro/derive.js +0 -6
  736. package/js/src/pro/dydx.js +0 -6
  737. package/js/src/pro/exmo.js +0 -6
  738. package/js/src/pro/gate.d.ts +1 -0
  739. package/js/src/pro/gate.js +77 -12
  740. package/js/src/pro/gateio.js +0 -6
  741. package/js/src/pro/gemini.js +0 -6
  742. package/js/src/pro/grvt.js +7 -14
  743. package/js/src/pro/hashkey.js +0 -6
  744. package/js/src/pro/hitbtc.js +0 -6
  745. package/js/src/pro/hollaex.js +0 -6
  746. package/js/src/pro/htx.js +0 -6
  747. package/js/src/pro/huobi.js +0 -6
  748. package/js/src/pro/hyperliquid.js +0 -6
  749. package/js/src/pro/independentreserve.js +0 -6
  750. package/js/src/pro/kraken.js +0 -6
  751. package/js/src/pro/krakenfutures.js +0 -6
  752. package/js/src/pro/kucoin.d.ts +65 -6
  753. package/js/src/pro/kucoin.js +1190 -109
  754. package/js/src/pro/kucoinfutures.js +0 -7
  755. package/js/src/pro/lbank.js +0 -6
  756. package/js/src/pro/lighter.js +0 -6
  757. package/js/src/pro/luno.js +0 -6
  758. package/js/src/pro/mexc.js +0 -6
  759. package/js/src/pro/modetrade.js +0 -6
  760. package/js/src/pro/myokx.js +0 -6
  761. package/js/src/pro/ndax.js +0 -6
  762. package/js/src/pro/okx.js +0 -6
  763. package/js/src/pro/okxus.js +0 -6
  764. package/js/src/pro/onetrading.js +0 -6
  765. package/js/src/pro/oxfun.js +0 -6
  766. package/js/src/pro/p2b.js +0 -6
  767. package/js/src/pro/pacifica.js +0 -6
  768. package/js/src/pro/paradex.js +0 -6
  769. package/js/src/pro/phemex.js +0 -6
  770. package/js/src/pro/poloniex.js +0 -6
  771. package/js/src/pro/toobit.js +0 -6
  772. package/js/src/pro/upbit.js +0 -6
  773. package/js/src/pro/weex.js +0 -6
  774. package/js/src/pro/whitebit.js +0 -6
  775. package/js/src/pro/woo.js +0 -6
  776. package/js/src/pro/woofipro.js +0 -6
  777. package/js/src/pro/xt.js +0 -6
  778. package/js/src/protobuf/mexc/compiled.cjs +0 -6
  779. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +0 -6
  780. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +0 -6
  781. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +0 -6
  782. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +0 -6
  783. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +0 -6
  784. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +0 -6
  785. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +0 -6
  786. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +0 -6
  787. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +0 -6
  788. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +0 -6
  789. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +0 -6
  790. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +0 -6
  791. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +0 -6
  792. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +0 -6
  793. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +0 -6
  794. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +0 -6
  795. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +0 -6
  796. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +0 -6
  797. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +0 -6
  798. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +0 -6
  799. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +0 -6
  800. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +0 -6
  801. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +0 -6
  802. package/js/src/static_dependencies/dydx-v4-client/helpers.js +0 -6
  803. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +0 -6
  804. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +0 -6
  805. package/js/src/static_dependencies/dydx-v4-client/registry.js +0 -6
  806. package/js/src/static_dependencies/ethers/abi-coder.js +0 -6
  807. package/js/src/static_dependencies/ethers/address/address.js +0 -6
  808. package/js/src/static_dependencies/ethers/address/checks.js +0 -6
  809. package/js/src/static_dependencies/ethers/address/contract-address.js +0 -6
  810. package/js/src/static_dependencies/ethers/address/index.js +0 -6
  811. package/js/src/static_dependencies/ethers/bytes32.js +0 -6
  812. package/js/src/static_dependencies/ethers/coders/abstract-coder.js +0 -6
  813. package/js/src/static_dependencies/ethers/coders/address.js +0 -6
  814. package/js/src/static_dependencies/ethers/coders/anonymous.js +0 -6
  815. package/js/src/static_dependencies/ethers/coders/array.js +0 -6
  816. package/js/src/static_dependencies/ethers/coders/boolean.js +0 -6
  817. package/js/src/static_dependencies/ethers/coders/bytes.js +0 -6
  818. package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +0 -6
  819. package/js/src/static_dependencies/ethers/coders/null.js +0 -6
  820. package/js/src/static_dependencies/ethers/coders/number.js +0 -6
  821. package/js/src/static_dependencies/ethers/coders/string.js +0 -6
  822. package/js/src/static_dependencies/ethers/coders/tuple.js +0 -6
  823. package/js/src/static_dependencies/ethers/fragments.js +0 -6
  824. package/js/src/static_dependencies/ethers/hash/index.js +0 -6
  825. package/js/src/static_dependencies/ethers/hash/solidity.js +0 -6
  826. package/js/src/static_dependencies/ethers/hash/typed-data.js +0 -6
  827. package/js/src/static_dependencies/ethers/index.js +0 -6
  828. package/js/src/static_dependencies/ethers/interface.js +0 -6
  829. package/js/src/static_dependencies/ethers/typed.js +0 -6
  830. package/js/src/static_dependencies/ethers/utils/base58.js +0 -6
  831. package/js/src/static_dependencies/ethers/utils/base64-browser.js +0 -6
  832. package/js/src/static_dependencies/ethers/utils/base64.js +0 -6
  833. package/js/src/static_dependencies/ethers/utils/data.js +0 -6
  834. package/js/src/static_dependencies/ethers/utils/errors.js +0 -6
  835. package/js/src/static_dependencies/ethers/utils/events.js +0 -6
  836. package/js/src/static_dependencies/ethers/utils/fixednumber.js +0 -6
  837. package/js/src/static_dependencies/ethers/utils/index.js +0 -6
  838. package/js/src/static_dependencies/ethers/utils/maths.js +0 -6
  839. package/js/src/static_dependencies/ethers/utils/properties.js +0 -6
  840. package/js/src/static_dependencies/ethers/utils/rlp-decode.js +0 -6
  841. package/js/src/static_dependencies/ethers/utils/rlp-encode.js +0 -6
  842. package/js/src/static_dependencies/ethers/utils/rlp.js +0 -6
  843. package/js/src/static_dependencies/ethers/utils/units.js +0 -6
  844. package/js/src/static_dependencies/ethers/utils/utf8.js +0 -6
  845. package/js/src/static_dependencies/ethers/utils/uuid.js +0 -6
  846. package/js/src/static_dependencies/fflake/browser.js +0 -6
  847. package/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -6
  848. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -6
  849. package/js/src/static_dependencies/jsencrypt/index.js +0 -6
  850. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -6
  851. package/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -6
  852. package/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -6
  853. package/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -6
  854. package/js/src/static_dependencies/jsencrypt/lib/asn1js/oids.js +0 -6
  855. package/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -6
  856. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -6
  857. package/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -6
  858. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -6
  859. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -6
  860. package/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -6
  861. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -6
  862. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -6
  863. package/js/src/static_dependencies/messagepack/msgpack.js +0 -6
  864. package/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -6
  865. package/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -6
  866. package/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -6
  867. package/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -6
  868. package/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -6
  869. package/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -6
  870. package/js/src/static_dependencies/noble-curves/abstract/poseidon.js +0 -6
  871. package/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -6
  872. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -6
  873. package/js/src/static_dependencies/noble-curves/bn.js +0 -6
  874. package/js/src/static_dependencies/noble-curves/ed25519.js +0 -6
  875. package/js/src/static_dependencies/noble-curves/ed448.js +0 -6
  876. package/js/src/static_dependencies/noble-curves/index.js +0 -6
  877. package/js/src/static_dependencies/noble-curves/jubjub.js +0 -6
  878. package/js/src/static_dependencies/noble-curves/p256.js +0 -6
  879. package/js/src/static_dependencies/noble-curves/p384.js +0 -6
  880. package/js/src/static_dependencies/noble-curves/p521.js +0 -6
  881. package/js/src/static_dependencies/noble-curves/pasta.js +0 -6
  882. package/js/src/static_dependencies/noble-curves/secp256k1.js +0 -6
  883. package/js/src/static_dependencies/noble-hashes/_assert.js +0 -6
  884. package/js/src/static_dependencies/noble-hashes/_blake2.js +0 -6
  885. package/js/src/static_dependencies/noble-hashes/_sha2.js +0 -6
  886. package/js/src/static_dependencies/noble-hashes/_u64.js +0 -6
  887. package/js/src/static_dependencies/noble-hashes/argon2.js +0 -6
  888. package/js/src/static_dependencies/noble-hashes/blake2b.js +0 -6
  889. package/js/src/static_dependencies/noble-hashes/blake2s.js +0 -6
  890. package/js/src/static_dependencies/noble-hashes/blake3.js +0 -6
  891. package/js/src/static_dependencies/noble-hashes/crypto.js +0 -6
  892. package/js/src/static_dependencies/noble-hashes/cryptoNode.js +0 -6
  893. package/js/src/static_dependencies/noble-hashes/eskdf.js +0 -6
  894. package/js/src/static_dependencies/noble-hashes/hkdf.js +0 -6
  895. package/js/src/static_dependencies/noble-hashes/hmac.js +0 -6
  896. package/js/src/static_dependencies/noble-hashes/index.js +0 -6
  897. package/js/src/static_dependencies/noble-hashes/md5.js +0 -6
  898. package/js/src/static_dependencies/noble-hashes/pbkdf2.js +0 -6
  899. package/js/src/static_dependencies/noble-hashes/ripemd160.js +0 -6
  900. package/js/src/static_dependencies/noble-hashes/scrypt.js +0 -6
  901. package/js/src/static_dependencies/noble-hashes/sha1.js +0 -6
  902. package/js/src/static_dependencies/noble-hashes/sha256.js +0 -6
  903. package/js/src/static_dependencies/noble-hashes/sha3-addons.js +0 -6
  904. package/js/src/static_dependencies/noble-hashes/sha3.js +0 -6
  905. package/js/src/static_dependencies/noble-hashes/sha512.js +0 -6
  906. package/js/src/static_dependencies/noble-hashes/utils.js +0 -6
  907. package/js/src/static_dependencies/node-fetch/body.js +0 -6
  908. package/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -6
  909. package/js/src/static_dependencies/node-fetch/errors/base.js +0 -6
  910. package/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -6
  911. package/js/src/static_dependencies/node-fetch/headers.js +0 -6
  912. package/js/src/static_dependencies/node-fetch/index.js +0 -6
  913. package/js/src/static_dependencies/node-fetch/request.js +0 -6
  914. package/js/src/static_dependencies/node-fetch/response.js +0 -6
  915. package/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -6
  916. package/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -6
  917. package/js/src/static_dependencies/node-fetch/utils/is.js +0 -6
  918. package/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -6
  919. package/js/src/static_dependencies/proxies/agent-base/helpers.js +0 -6
  920. package/js/src/static_dependencies/proxies/agent-base/index.js +0 -6
  921. package/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -6
  922. package/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -6
  923. package/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -6
  924. package/js/src/static_dependencies/qs/formats.js +0 -6
  925. package/js/src/static_dependencies/qs/index.js +0 -6
  926. package/js/src/static_dependencies/qs/parse.js +0 -6
  927. package/js/src/static_dependencies/qs/stringify.js +0 -6
  928. package/js/src/static_dependencies/qs/utils.js +0 -6
  929. package/js/src/static_dependencies/scure-base/index.js +0 -6
  930. package/js/src/static_dependencies/scure-bip32/index.js +0 -6
  931. package/js/src/static_dependencies/scure-bip39/index.js +0 -6
  932. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +0 -6
  933. package/js/src/static_dependencies/scure-starknet/index.js +0 -6
  934. package/js/src/static_dependencies/starknet/constants.js +0 -6
  935. package/js/src/static_dependencies/starknet/index.js +0 -6
  936. package/js/src/static_dependencies/starknet/types/cairoEnum.js +0 -6
  937. package/js/src/static_dependencies/starknet/types/calldata.js +0 -6
  938. package/js/src/static_dependencies/starknet/types/index.js +0 -6
  939. package/js/src/static_dependencies/starknet/types/lib/contract/abi.js +0 -6
  940. package/js/src/static_dependencies/starknet/types/lib/contract/index.js +0 -6
  941. package/js/src/static_dependencies/starknet/types/lib/contract/legacy.js +0 -6
  942. package/js/src/static_dependencies/starknet/types/lib/contract/sierra.js +0 -6
  943. package/js/src/static_dependencies/starknet/types/lib/index.js +0 -6
  944. package/js/src/static_dependencies/starknet/types/typedData.js +0 -6
  945. package/js/src/static_dependencies/starknet/utils/address.js +0 -6
  946. package/js/src/static_dependencies/starknet/utils/assert.js +0 -6
  947. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +0 -6
  948. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +0 -6
  949. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +0 -6
  950. package/js/src/static_dependencies/starknet/utils/calldata/byteArray.js +0 -6
  951. package/js/src/static_dependencies/starknet/utils/calldata/cairo.js +0 -6
  952. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +0 -6
  953. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +0 -6
  954. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +0 -6
  955. package/js/src/static_dependencies/starknet/utils/calldata/enum/index.js +0 -6
  956. package/js/src/static_dependencies/starknet/utils/calldata/formatter.js +0 -6
  957. package/js/src/static_dependencies/starknet/utils/calldata/index.js +0 -6
  958. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.js +0 -6
  959. package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.js +0 -6
  960. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +0 -6
  961. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +0 -6
  962. package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +0 -6
  963. package/js/src/static_dependencies/starknet/utils/calldata/requestParser.js +0 -6
  964. package/js/src/static_dependencies/starknet/utils/calldata/responseParser.js +0 -6
  965. package/js/src/static_dependencies/starknet/utils/calldata/tuple.js +0 -6
  966. package/js/src/static_dependencies/starknet/utils/calldata/validate.js +0 -6
  967. package/js/src/static_dependencies/starknet/utils/encode.js +0 -6
  968. package/js/src/static_dependencies/starknet/utils/hash/classHash.js +0 -6
  969. package/js/src/static_dependencies/starknet/utils/hash/index.js +0 -6
  970. package/js/src/static_dependencies/starknet/utils/merkle.js +0 -6
  971. package/js/src/static_dependencies/starknet/utils/num.js +0 -6
  972. package/js/src/static_dependencies/starknet/utils/selector.js +0 -6
  973. package/js/src/static_dependencies/starknet/utils/shortString.js +0 -6
  974. package/js/src/static_dependencies/starknet/utils/starknetId.js +0 -6
  975. package/js/src/static_dependencies/starknet/utils/typedData.js +0 -6
  976. package/js/src/static_dependencies/starknet/utils/uint256.js +0 -6
  977. package/js/src/static_dependencies/starknet/utils/url.js +0 -6
  978. package/js/src/static_dependencies/watchable/src/index.js +0 -6
  979. package/js/src/static_dependencies/watchable/src/types.js +0 -6
  980. package/js/src/static_dependencies/watchable/src/unpromise.js +0 -6
  981. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +0 -6
  982. package/js/src/tokocrypto.js +0 -6
  983. package/js/src/toobit.js +0 -6
  984. package/js/src/upbit.js +0 -6
  985. package/js/src/wavesexchange.js +0 -6
  986. package/js/src/weex.js +0 -6
  987. package/js/src/whitebit.js +2 -6
  988. package/js/src/woo.js +0 -6
  989. package/js/src/woofipro.js +0 -6
  990. package/js/src/xt.js +0 -6
  991. package/js/src/yobit.js +0 -6
  992. package/js/src/zaif.js +0 -6
  993. package/js/src/zebpay.js +0 -6
  994. package/js/src/zonda.js +0 -6
  995. package/package.json +2 -1
package/js/src/aster.js CHANGED
@@ -1,15 +1,8 @@
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
1
  // ---------------------------------------------------------------------------
8
2
  import Exchange from './abstract/aster.js';
9
3
  import { AccountNotEnabled, AccountSuspended, ArgumentsRequired, AuthenticationError, BadRequest, BadResponse, BadSymbol, DuplicateOrderId, ExchangeClosedByUser, ExchangeError, InsufficientFunds, InvalidNonce, InvalidOrder, MarketClosed, NetworkError, NoChange, NotSupported, OperationFailed, OperationRejected, OrderImmediatelyFillable, OrderNotFillable, OrderNotFound, PermissionDenied, RateLimitExceeded, RequestTimeout } from './base/errors.js';
10
4
  import { TRUNCATE, TICK_SIZE } from './base/functions/number.js';
11
5
  import Precise from './base/Precise.js';
12
- import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
6
  import { ecdsa } from './base/functions/crypto.js';
14
7
  import { keccak_256 as keccak } from './static_dependencies/noble-hashes/sha3.js';
15
8
  import { secp256k1 } from './static_dependencies/noble-curves/secp256k1.js';
@@ -189,169 +182,217 @@ export default class aster extends Exchange {
189
182
  'setMargin': false,
190
183
  'setMarginMode': true,
191
184
  'setPositionMode': true,
192
- 'signIn': false,
185
+ 'signIn': true,
193
186
  'transfer': true,
194
187
  'withdraw': true,
195
188
  },
196
189
  'api': {
197
190
  'fapiPublic': {
198
- 'get': [
199
- 'v1/ping',
200
- 'v3/ping',
201
- 'v1/time',
202
- 'v3/time',
203
- 'v1/exchangeInfo',
204
- 'v3/exchangeInfo',
205
- 'v1/depth',
206
- 'v3/depth',
207
- 'v1/trades',
208
- 'v3/trades',
209
- 'v1/historicalTrades',
210
- 'v3/historicalTrades',
211
- 'v1/aggTrades',
212
- 'v3/aggTrades',
213
- 'v1/klines',
214
- 'v3/klines',
215
- 'v1/indexPriceKlines',
216
- 'v3/indexPriceKlines',
217
- 'v1/markPriceKlines',
218
- 'v3/markPriceKlines',
219
- 'v1/premiumIndex',
220
- 'v3/premiumIndex',
221
- 'v1/fundingRate',
222
- 'v3/fundingRate',
223
- 'v1/fundingInfo',
224
- 'v3/fundingInfo',
225
- 'v1/ticker/24hr',
226
- 'v3/ticker/24hr',
227
- 'v1/ticker/price',
228
- 'v3/ticker/price',
229
- 'v1/ticker/bookTicker',
230
- 'v3/ticker/bookTicker',
231
- 'v3/indexreferences',
232
- 'v1/adlQuantile',
233
- 'v1/forceOrders',
234
- ],
191
+ 'get': {
192
+ 'v1/ping': 1,
193
+ 'v3/ping': 1,
194
+ 'v1/time': 1,
195
+ 'v3/time': 1,
196
+ 'v1/exchangeInfo': 1,
197
+ 'v3/exchangeInfo': 1,
198
+ 'v1/depth': 1,
199
+ 'v3/depth': 2,
200
+ 'v1/trades': 1,
201
+ 'v3/trades': 1,
202
+ 'v1/historicalTrades': 1,
203
+ 'v3/historicalTrades': 20,
204
+ 'v1/aggTrades': 1,
205
+ 'v3/aggTrades': 20,
206
+ 'v1/klines': 1,
207
+ 'v3/klines': 1,
208
+ 'v1/indexPriceKlines': 1,
209
+ 'v3/indexPriceKlines': 1,
210
+ 'v1/markPriceKlines': 1,
211
+ 'v3/markPriceKlines': 1,
212
+ 'v1/premiumIndex': 1,
213
+ 'v3/premiumIndex': 1,
214
+ 'v1/fundingRate': 1,
215
+ 'v3/fundingRate': 1,
216
+ 'v1/fundingInfo': 1,
217
+ 'v3/fundingInfo': 1,
218
+ 'v1/ticker/24hr': 1,
219
+ 'v3/ticker/24hr': 1,
220
+ 'v1/ticker/price': 1,
221
+ 'v3/ticker/price': 1,
222
+ 'v1/ticker/bookTicker': 1,
223
+ 'v3/ticker/bookTicker': 1,
224
+ // different endpoints
225
+ 'v1/adlQuantile': 1,
226
+ 'v1/forceOrders': 1,
227
+ 'v3/indexreferences': 1,
228
+ },
235
229
  },
236
230
  'fapiPrivate': {
237
- 'get': [
238
- 'v1/positionSide/dual',
239
- 'v3/positionSide/dual',
240
- 'v1/multiAssetsMargin',
241
- 'v3/multiAssetsMargin',
242
- 'v1/order',
243
- 'v3/order',
244
- 'v1/openOrder',
245
- 'v3/openOrder',
246
- 'v1/openOrders',
247
- 'v3/openOrders',
248
- 'v1/allOrders',
249
- 'v3/allOrders',
250
- 'v2/balance',
251
- 'v3/balance',
252
- 'v3/account',
253
- 'v3/accountWithJoinMargin',
254
- 'v4/account',
255
- 'v1/positionMargin/history',
256
- 'v3/positionMargin/history',
257
- 'v2/positionRisk',
258
- 'v3/positionRisk',
259
- 'v1/userTrades',
260
- 'v3/userTrades',
261
- 'v1/income',
262
- 'v3/income',
263
- 'v1/leverageBracket',
264
- 'v3/leverageBracket',
265
- 'v3/adlQuantile',
266
- 'v3/forceOrders',
267
- 'v1/commissionRate',
268
- 'v3/commissionRate',
269
- 'v3/mmp',
270
- ],
271
- 'post': [
272
- 'v3/noop',
273
- 'v1/positionSide/dual',
274
- 'v3/positionSide/dual',
275
- 'v1/multiAssetsMargin',
276
- 'v3/multiAssetsMargin',
277
- 'v1/order',
278
- 'v3/order',
279
- 'v1/order/test',
280
- 'v3/order/test',
281
- 'v1/batchOrders',
282
- 'v3/batchOrders',
283
- 'v1/asset/wallet/transfer',
284
- 'v3/asset/wallet/transfer',
285
- 'v1/countdownCancelAll',
286
- 'v3/countdownCancelAll',
287
- 'v1/leverage',
288
- 'v3/leverage',
289
- 'v1/marginType',
290
- 'v3/marginType',
291
- 'v1/positionMargin',
292
- 'v3/positionMargin',
293
- 'v3/mmp',
294
- 'v3/mmpReset',
295
- 'v1/listenKey',
296
- 'v3/listenKey',
297
- ],
298
- 'put': [
299
- 'v1/listenKey',
300
- 'v3/listenKey',
301
- ],
302
- 'delete': [
303
- 'v1/order',
304
- 'v3/order',
305
- 'v1/allOpenOrders',
306
- 'v3/allOpenOrders',
307
- 'v1/batchOrders',
308
- 'v3/batchOrders',
309
- 'v3/mmp',
310
- 'v1/listenKey',
311
- 'v3/listenKey',
312
- ],
231
+ 'get': {
232
+ 'v1/positionSide/dual': 1,
233
+ 'v3/positionSide/dual': 30,
234
+ 'v1/multiAssetsMargin': 1,
235
+ 'v3/multiAssetsMargin': 1,
236
+ 'v1/order': 1,
237
+ 'v3/order': 1,
238
+ 'v1/openOrder': 1,
239
+ 'v3/openOrder': 1,
240
+ 'v1/openOrders': 1,
241
+ 'v3/openOrders': 1,
242
+ 'v1/allOrders': 1,
243
+ 'v3/allOrders': 1,
244
+ 'v2/balance': 1,
245
+ 'v3/balance': 1,
246
+ 'v3/account': 1,
247
+ 'v1/positionMargin/history': 1,
248
+ 'v3/positionMargin/history': 1,
249
+ 'v2/positionRisk': 1,
250
+ 'v3/positionRisk': 1,
251
+ 'v1/userTrades': 1,
252
+ 'v3/userTrades': 5,
253
+ 'v1/income': 1,
254
+ 'v3/income': 1,
255
+ 'v1/leverageBracket': 1,
256
+ 'v3/leverageBracket': 1,
257
+ 'v1/commissionRate': 1,
258
+ 'v3/commissionRate': 1,
259
+ // others
260
+ 'v3/adlQuantile': 1,
261
+ 'v3/forceOrders': 1,
262
+ 'v3/mmp': 1,
263
+ 'v3/accountWithJoinMargin': 1,
264
+ 'v4/account': 1,
265
+ // builder
266
+ 'v3/agent': 1,
267
+ 'v3/builder': 1,
268
+ },
269
+ 'post': {
270
+ 'v1/positionSide/dual': 1,
271
+ 'v3/positionSide/dual': 1,
272
+ 'v1/multiAssetsMargin': 1,
273
+ 'v3/multiAssetsMargin': 1,
274
+ 'v1/order': 1,
275
+ 'v3/order': 1,
276
+ 'v1/order/test': 1,
277
+ 'v3/order/test': 1,
278
+ 'v1/batchOrders': 1,
279
+ 'v3/batchOrders': 1,
280
+ 'v1/asset/wallet/transfer': 1,
281
+ 'v3/asset/wallet/transfer': 1,
282
+ 'v1/countdownCancelAll': 1,
283
+ 'v3/countdownCancelAll': 1,
284
+ 'v1/leverage': 1,
285
+ 'v3/leverage': 1,
286
+ 'v1/marginType': 1,
287
+ 'v3/marginType': 1,
288
+ 'v1/positionMargin': 1,
289
+ 'v3/positionMargin': 1,
290
+ 'v1/listenKey': 1,
291
+ 'v3/listenKey': 1,
292
+ // others
293
+ 'v3/mmp': 1,
294
+ 'v3/mmpReset': 1,
295
+ 'v3/noop': 1,
296
+ // builder
297
+ 'v3/approveAgent': 1,
298
+ 'v3/updateAgent': 1,
299
+ 'v3/approveBuilder': 1,
300
+ 'v3/updateBuilder': 1,
301
+ },
302
+ 'put': {
303
+ 'v1/listenKey': 1,
304
+ 'v3/listenKey': 1,
305
+ },
306
+ 'delete': {
307
+ 'v1/order': 1,
308
+ 'v3/order': 1,
309
+ 'v1/allOpenOrders': 1,
310
+ 'v3/allOpenOrders': 1,
311
+ 'v1/batchOrders': 1,
312
+ 'v3/batchOrders': 1,
313
+ 'v3/mmp': 1,
314
+ 'v1/listenKey': 1,
315
+ 'v3/listenKey': 1,
316
+ // builder
317
+ 'v3/agent': 1,
318
+ 'v3/builder': 1,
319
+ },
313
320
  },
314
321
  'sapiPublic': {
315
- 'get': [
316
- 'v1/ping',
317
- 'v1/time',
318
- 'v1/exchangeInfo',
319
- 'v1/depth',
320
- 'v1/trades',
321
- 'v1/historicalTrades',
322
- 'v1/aggTrades',
323
- 'v1/klines',
324
- 'v1/ticker/24hr',
325
- 'v1/ticker/price',
326
- 'v1/ticker/bookTicker',
327
- 'v1/aster/withdraw/estimateFee',
328
- ],
322
+ 'get': {
323
+ // v1
324
+ 'v1/ping': 1,
325
+ 'v1/time': 1,
326
+ 'v1/exchangeInfo': 1,
327
+ 'v1/depth': 1,
328
+ 'v1/trades': 1,
329
+ 'v1/historicalTrades': 1,
330
+ 'v1/aggTrades': 1,
331
+ 'v1/klines': 1,
332
+ 'v1/ticker/24hr': 1,
333
+ 'v1/ticker/price': 1,
334
+ 'v1/ticker/bookTicker': 1,
335
+ 'v1/aster/withdraw/estimateFee': 1,
336
+ // v3
337
+ 'v3/ping': 1,
338
+ 'v3/time': 1,
339
+ 'v3/exchangeInfo': 1,
340
+ 'v3/depth': { 'cost': 2, 'byLimit': [[50, 2], [100, 5], [500, 10], [1000, 20]] },
341
+ 'v3/trades': 1,
342
+ 'v3/historicalTrades': 20,
343
+ 'v3/aggTrades': 20,
344
+ 'v3/klines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
345
+ 'v3/ticker/24hr': { 'cost': 1, 'noSymbol': 40 },
346
+ 'v3/ticker/price': { 'cost': 1, 'noSymbol': 2 },
347
+ 'v3/ticker/bookTicker': { 'cost': 1, 'noSymbol': 2 },
348
+ 'v3/aster/withdraw/estimateFee': 1,
349
+ },
329
350
  },
330
351
  'sapiPrivate': {
331
- 'get': [
332
- 'v1/commissionRate',
333
- 'v1/order',
334
- 'v1/openOrders',
335
- 'v1/allOrders',
336
- 'v1/transactionHistory',
337
- 'v1/account',
338
- 'v1/userTrades',
339
- ],
340
- 'post': [
341
- 'v1/order',
342
- 'v1/asset/wallet/transfer',
343
- 'v1/asset/sendToAddress',
344
- 'v1/aster/user-withdraw',
345
- 'v1/listenKey',
346
- ],
352
+ 'get': {
353
+ // v1
354
+ 'v1/commissionRate': 1,
355
+ 'v1/order': 1,
356
+ 'v1/openOrders': 1,
357
+ 'v1/allOrders': 1,
358
+ 'v1/transactionHistory': 1,
359
+ 'v1/account': 1,
360
+ 'v1/userTrades': 1,
361
+ // v3
362
+ 'v3/commissionRate': { 'cost': 1, 'noSymbol': 2 },
363
+ 'v3/order': 1,
364
+ 'v3/openOrders': 1,
365
+ 'v3/allOrders': 5,
366
+ 'v3/account': 5,
367
+ 'v3/userTrades': 5,
368
+ 'v3/openOrder': 1,
369
+ },
370
+ 'post': {
371
+ // v1
372
+ 'v1/order': 1,
373
+ 'v1/asset/wallet/transfer': 5,
374
+ 'v1/asset/sendToAddress': 1,
375
+ 'v1/listenKey': 1,
376
+ // v3
377
+ 'v3/order': 1,
378
+ 'v3/asset/wallet/transfer': 5,
379
+ 'v3/aster/user-withdraw': 1,
380
+ 'v3/listenKey': 1,
381
+ },
347
382
  'put': [
348
383
  'v1/listenKey',
384
+ 'v3/listenKey',
349
385
  ],
350
- 'delete': [
351
- 'v1/order',
352
- 'v1/allOpenOrders',
353
- 'v1/listenKey',
354
- ],
386
+ 'delete': {
387
+ // v1
388
+ 'v1/order': 1,
389
+ 'v1/allOpenOrders': 1,
390
+ 'v1/listenKey': 1,
391
+ // v3
392
+ 'v3/allOpenOrders': 1,
393
+ 'v3/order': 1,
394
+ 'v3/listenKey': 1,
395
+ },
355
396
  },
356
397
  },
357
398
  'timeframes': {
@@ -373,8 +414,9 @@ export default class aster extends Exchange {
373
414
  },
374
415
  'precisionMode': TICK_SIZE,
375
416
  'requiredCredentials': {
376
- 'apiKey': true,
377
- 'secret': true,
417
+ 'apiKey': false,
418
+ 'secret': false,
419
+ 'privateKey': true,
378
420
  },
379
421
  'fees': {
380
422
  'trading': {
@@ -389,28 +431,35 @@ export default class aster extends Exchange {
389
431
  'recvWindow': 10 * 1000,
390
432
  'defaultTimeInForce': 'GTC',
391
433
  'zeroAddress': '0x0000000000000000000000000000000000000000',
434
+ 'v3ChainId': 1666,
392
435
  'quoteOrderQty': true,
393
436
  'accountsByType': {
394
437
  'spot': 'SPOT',
438
+ 'swap': 'FUTURE',
395
439
  'future': 'FUTURE',
396
440
  'linear': 'FUTURE',
397
- 'swap': 'FUTURE',
398
441
  },
399
442
  'networks': {
400
443
  'ERC20': 'ETH',
401
444
  'BEP20': 'BSC',
402
- 'ARB': 'Arbitrum',
445
+ 'ARBONE': 'Arbitrum',
403
446
  },
404
447
  'networksToChainId': {
405
448
  'ETH': 1,
406
449
  'BSC': 56,
407
450
  'Arbitrum': 42161,
408
451
  },
452
+ 'fetchOpenOrders': {
453
+ 'warnIfNoSymbol': true, // set to false to suppress warning when calling fetchOpenOrders without symbol
454
+ },
455
+ 'builderFee': true,
456
+ 'builder': '0x1F5877C19e3777Cfd15F9d57253eA4aA5254Ec39',
457
+ 'builderRate': '0.001',
409
458
  },
410
459
  'exceptions': {
411
460
  'exact': {
412
461
  // 10xx - General Server or Network issues
413
- '-1000': OperationFailed,
462
+ '-1000': OperationRejected,
414
463
  '-1001': NetworkError,
415
464
  '-1002': AuthenticationError,
416
465
  '-1003': RateLimitExceeded,
@@ -418,7 +467,7 @@ export default class aster extends Exchange {
418
467
  '-1005': BadRequest,
419
468
  '-1006': BadResponse,
420
469
  '-1007': RequestTimeout,
421
- '-1010': OperationFailed,
470
+ '-1010': OperationRejected,
422
471
  '-1011': PermissionDenied,
423
472
  '-1013': BadRequest,
424
473
  '-1014': OrderNotFillable,
@@ -572,7 +621,9 @@ export default class aster extends Exchange {
572
621
  '-4183': InvalidOrder,
573
622
  '-4184': InvalidOrder,
574
623
  '-5060': OperationRejected,
575
- '-5076': OperationRejected, // {"code":-5076,"msg":"Total order value should be more than 5 USDT"}
624
+ '-5076': OperationRejected,
625
+ // occured errors:
626
+ '-4168': OperationRejected, // Unable to adjust to isolated-margin mode under the Multi-Assets mode.
576
627
  },
577
628
  'broad': {},
578
629
  },
@@ -598,15 +649,15 @@ export default class aster extends Exchange {
598
649
  * @method
599
650
  * @name aster#fetchCurrencies
600
651
  * @description fetches all available currencies on an exchange
601
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#trading-specification-information
602
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#exchange-information
652
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#trading-specification-information
653
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#exchange-information
603
654
  * @param {object} [params] extra parameters specific to the exchange API endpoint
604
655
  * @returns {object} an associative dictionary of currencies
605
656
  */
606
657
  async fetchCurrencies(params = {}) {
607
658
  const promises = [
608
- this.sapiPublicGetV1ExchangeInfo(params),
609
- this.fapiPublicGetV1ExchangeInfo(params),
659
+ this.sapiPublicGetV3ExchangeInfo(params),
660
+ this.fapiPublicGetV3ExchangeInfo(params),
610
661
  ];
611
662
  const results = await Promise.all(promises);
612
663
  const sapiResult = this.safeDict(results, 0, {});
@@ -618,8 +669,8 @@ export default class aster extends Exchange {
618
669
  // [
619
670
  // {
620
671
  // "asset": "USDT",
621
- // "marginAvailable": true,
622
- // "autoAssetExchange": "-10000"
672
+ // "marginAvailable": true, // only in PERP
673
+ // "autoAssetExchange": "-10000" // only in PERP
623
674
  // }
624
675
  // ]
625
676
  //
@@ -662,263 +713,267 @@ export default class aster extends Exchange {
662
713
  * @method
663
714
  * @name aster#fetchMarkets
664
715
  * @description retrieves data on all markets for bigone
665
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#trading-specification-information
666
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#exchange-information
716
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#trading-specification-information
717
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#exchange-information
667
718
  * @param {object} [params] extra parameters specific to the exchange API endpoint
668
719
  * @returns {object[]} an array of objects representing market data
669
720
  */
670
721
  async fetchMarkets(params = {}) {
671
722
  const promises = [
672
- this.sapiPublicGetV1ExchangeInfo(params),
673
- this.fapiPublicGetV1ExchangeInfo(params),
723
+ this.sapiPublicGetV3ExchangeInfo(params),
724
+ this.fapiPublicGetV3ExchangeInfo(params),
674
725
  ];
726
+ promises.push(this.signIn());
675
727
  const results = await Promise.all(promises);
676
728
  const sapiResult = this.safeDict(results, 0, {});
677
729
  const sapiRows = this.safeList(sapiResult, 'symbols', []);
678
730
  const fapiResult = this.safeDict(results, 1, {});
679
731
  const fapiRows = this.safeList(fapiResult, 'symbols', []);
680
- const rows = this.arrayConcat(sapiRows, fapiRows);
732
+ //
733
+ // example:
681
734
  //
682
735
  // [
683
- // {
684
- // "symbol": "BTCUSDT",
685
- // "pair": "BTCUSDT",
686
- // "contractType": "PERPETUAL",
687
- // "deliveryDate": 4133404800000,
688
- // "onboardDate": 1627628400000,
689
- // "status": "TRADING",
690
- // "maintMarginPercent": "2.5000",
691
- // "requiredMarginPercent": "5.0000",
692
- // "baseAsset": "BTC",
693
- // "quoteAsset": "USDT",
694
- // "marginAsset": "USDT",
695
- // "pricePrecision": 1,
696
- // "quantityPrecision": 3,
697
- // "baseAssetPrecision": 8,
698
- // "quotePrecision": 8,
699
- // "underlyingType": "COIN",
700
- // "underlyingSubType": [],
701
- // "settlePlan": 0,
702
- // "triggerProtect": "0.0200",
703
- // "liquidationFee": "0.025000",
704
- // "marketTakeBound": "0.02",
705
- // "filters": [
706
- // {
707
- // "minPrice": "1",
708
- // "maxPrice": "1000000",
709
- // "filterType": "PRICE_FILTER",
710
- // "tickSize": "0.1"
711
- // },
712
- // {
713
- // "stepSize": "0.001",
714
- // "filterType": "LOT_SIZE",
715
- // "maxQty": "100",
716
- // "minQty": "0.001"
717
- // },
718
- // {
719
- // "stepSize": "0.001",
720
- // "filterType": "MARKET_LOT_SIZE",
721
- // "maxQty": "10",
722
- // "minQty": "0.001"
723
- // },
724
- // {
725
- // "limit": 200,
726
- // "filterType": "MAX_NUM_ORDERS"
727
- // },
728
- // {
729
- // "limit": 10,
730
- // "filterType": "MAX_NUM_ALGO_ORDERS"
731
- // },
732
- // {
733
- // "notional": "5",
734
- // "filterType": "MIN_NOTIONAL"
735
- // },
736
- // {
737
- // "multiplierDown": "0.9800",
738
- // "multiplierUp": "1.0200",
739
- // "multiplierDecimal": "4",
740
- // "filterType": "PERCENT_PRICE"
741
- // }
742
- // ],
743
- // "orderTypes": [
744
- // "LIMIT",
745
- // "MARKET",
746
- // "STOP",
747
- // "STOP_MARKET",
748
- // "TAKE_PROFIT",
749
- // "TAKE_PROFIT_MARKET",
750
- // "TRAILING_STOP_MARKET"
751
- // ],
752
- // "timeInForce": [
753
- // "GTC",
754
- // "IOC",
755
- // "FOK",
756
- // "GTX",
757
- // "RPI"
758
- // ]
759
- // }
736
+ // {
737
+ // symbol: "TESTUSDT",
738
+ // status: "TRADING",
739
+ // baseAsset: "TEST",
740
+ // quoteAsset: "USDT",
741
+ // pricePrecision: "2",
742
+ // quantityPrecision: "5",
743
+ // baseAssetPrecision: "8",
744
+ // quotePrecision: "8",
745
+ // listingTime: "1756289680210", // only in SPOT
746
+ // baseAssetAddress: null, // only in SPOT
747
+ // ocoAllowed: false, // only in SPOT
748
+ // pair: "ASTERUSDT", // only in PERP
749
+ // contractType: "PERPETUAL", // only in PERP
750
+ // deliveryDate: "4133404800000", // only in PERP
751
+ // onboardDate: "1758178800000", // only in PERP
752
+ // maintMarginPercent: "12.5000", // only in PERP
753
+ // requiredMarginPercent: "25.0000", // only in PERP
754
+ // marginAsset: "USDT", // only in PERP
755
+ // underlyingType: "COIN", // only in PERP
756
+ // underlyingSubType: [ "Top", ], // only in PERP
757
+ // symbolType: "0", // only in PERP
758
+ // tradingMode: "0", // only in PERP
759
+ // name: "", // only in PERP
760
+ // channel: "{}", // only in PERP
761
+ // sequenceNo: "100", // only in PERP
762
+ // twapMinNotional: "1000", // only in PERP
763
+ // imn: "4000.00", // only in PERP
764
+ // tags: [], // only in PERP
765
+ // settlePlan: "0", // only in PERP
766
+ // triggerProtect: "0.1500", // only in PERP
767
+ // liquidationFee: "0.025000", // only in PERP
768
+ // marketTakeBound: "0.05", // only in PERP
769
+ // createTime: "1758215451058", // only in PERP
770
+ // filters: [
771
+ // {
772
+ // minPrice: "0.01",
773
+ // maxPrice: "1000000",
774
+ // filterType: "PRICE_FILTER",
775
+ // tickSize: "0.01",
776
+ // },
777
+ // {
778
+ // stepSize: "0.00001",
779
+ // filterType: "LOT_SIZE",
780
+ // maxQty: "9000",
781
+ // minQty: "0.00001",
782
+ // },
783
+ // {
784
+ // stepSize: "0.00001",
785
+ // filterType: "MARKET_LOT_SIZE",
786
+ // maxQty: "9000",
787
+ // minQty: "0.00001",
788
+ // },
789
+ // {
790
+ // limit: "200",
791
+ // filterType: "MAX_NUM_ORDERS",
792
+ // },
793
+ // {
794
+ // minNotional: "5",
795
+ // filterType: "MIN_NOTIONAL",
796
+ // },
797
+ // {
798
+ // minNotional: "5",
799
+ // avgPriceMins: "5",
800
+ // applyMinToMarket: true,
801
+ // filterType: "NOTIONAL", // only in SPOT
802
+ // applyMaxToMarket: true,
803
+ // },
804
+ // {
805
+ // multiplierDown: "0.2",
806
+ // multiplierUp: "5",
807
+ // multiplierDecimal: "1",
808
+ // filterType: "PERCENT_PRICE",
809
+ // },
810
+ // {
811
+ // bidMultiplierUp: "5",
812
+ // askMultiplierUp: "5",
813
+ // bidMultiplierDown: "0.2",
814
+ // avgPriceMins: "5",
815
+ // multiplierDecimal: "1",
816
+ // filterType: "PERCENT_PRICE_BY_SIDE", // only in SPOT
817
+ // askMultiplierDown: "0.2",
818
+ // },
819
+ // ],
820
+ // orderTypes: [ "LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET", ],
821
+ // timeInForce: [ "GTC", "IOC", "FOK", "GTX", "HIDDEN", ],
822
+ // }
760
823
  // ]
761
824
  //
762
- const fees = this.fees;
763
- const result = [];
764
- for (let i = 0; i < rows.length; i++) {
765
- let swap = false;
766
- const market = rows[i];
767
- const id = this.safeString(market, 'symbol');
768
- const baseId = this.safeString(market, 'baseAsset');
769
- const quoteId = this.safeString(market, 'quoteAsset');
770
- const base = this.safeCurrencyCode(baseId);
771
- const quote = this.safeCurrencyCode(quoteId);
772
- const contractType = this.safeString(market, 'contractType');
773
- const contract = contractType !== undefined;
774
- let spot = true;
775
- if (contractType === 'PERPETUAL') {
776
- swap = true;
777
- spot = false;
778
- }
779
- let contractSize = undefined;
780
- let linear = undefined;
781
- let inverse = undefined;
782
- let symbol = base + '/' + quote;
783
- let settle = undefined;
784
- let settleId = undefined;
785
- if (contract) {
786
- settleId = this.safeString(market, 'marginAsset');
787
- settle = this.safeCurrencyCode(settleId);
788
- if (swap) {
789
- symbol = symbol + ':' + settle;
790
- }
791
- linear = settle === quote;
792
- inverse = settle === base;
793
- contractSize = this.safeNumber2(market, 'contractSize', 'unit', this.parseNumber('1'));
794
- }
795
- let unifiedType = undefined;
796
- if (spot) {
797
- unifiedType = 'spot';
798
- }
799
- else if (swap) {
800
- unifiedType = 'swap';
801
- }
802
- const status = this.safeString(market, 'status');
803
- const active = status === 'TRADING';
804
- const filters = this.safeList(market, 'filters', []);
805
- const filtersByType = this.indexBy(filters, 'filterType');
806
- const entry = this.safeMarketStructure({
807
- 'id': id,
808
- 'symbol': symbol,
809
- 'base': base,
810
- 'quote': quote,
811
- 'settle': settle,
812
- 'baseId': baseId,
813
- 'quoteId': quoteId,
814
- 'settleId': settleId,
815
- 'type': unifiedType,
816
- 'spot': spot,
817
- 'margin': false,
818
- 'swap': swap,
819
- 'future': false,
820
- 'option': false,
821
- 'active': active,
822
- 'contract': contract,
823
- 'linear': linear,
824
- 'inverse': inverse,
825
- 'taker': fees['trading']['taker'],
826
- 'maker': fees['trading']['maker'],
827
- 'contractSize': contractSize,
828
- 'expiry': undefined,
829
- 'expiryDatetime': undefined,
830
- 'strike': undefined,
831
- 'optionType': undefined,
832
- 'precision': {
833
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision'))),
834
- 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision'))),
835
- 'base': this.parseNumber(this.parsePrecision(this.safeString(market, 'baseAssetPrecision'))),
836
- 'quote': this.parseNumber(this.parsePrecision(this.safeString(market, 'quotePrecision'))),
825
+ //
826
+ const rows = this.arrayConcat(sapiRows, fapiRows);
827
+ return this.parseMarkets(rows);
828
+ }
829
+ parseMarket(market) {
830
+ const id = this.safeString(market, 'symbol');
831
+ const baseId = this.safeString(market, 'baseAsset');
832
+ const quoteId = this.safeString(market, 'quoteAsset');
833
+ const base = this.safeCurrencyCode(baseId);
834
+ const quote = this.safeCurrencyCode(quoteId);
835
+ const active = this.safeString(market, 'status') === 'TRADING';
836
+ let spot = undefined;
837
+ let symbol = undefined;
838
+ let settle = undefined;
839
+ let settleId = undefined;
840
+ let swap = undefined;
841
+ let linear = undefined;
842
+ let inverse = undefined;
843
+ let contractSize = undefined;
844
+ const contractType = this.safeString(market, 'contractType');
845
+ const isContract = contractType !== undefined;
846
+ if (isContract) {
847
+ // currently, there is only perpetuals, not futures
848
+ spot = false;
849
+ swap = true;
850
+ settleId = this.safeString(market, 'marginAsset');
851
+ settle = this.safeCurrencyCode(settleId);
852
+ symbol = base + '/' + quote + ':' + settle;
853
+ linear = settle === quote;
854
+ inverse = settle === base;
855
+ contractSize = this.safeNumber2(market, 'contractSize', 'unit', this.parseNumber('1'));
856
+ }
857
+ else {
858
+ spot = true;
859
+ swap = false;
860
+ symbol = base + '/' + quote;
861
+ }
862
+ // filters
863
+ const filters = this.safeList(market, 'filters', []);
864
+ const filtersByType = this.indexBy(filters, 'filterType');
865
+ const filterNotional = this.safeDict2(filtersByType, 'MIN_NOTIONAL', 'NOTIONAL');
866
+ const filterPrice = this.safeDict(filtersByType, 'PRICE_FILTER');
867
+ const filterLotSize = this.safeDict(filtersByType, 'LOT_SIZE');
868
+ const filterMarketLotSize = this.safeDict(filtersByType, 'MARKET_LOT_SIZE', {});
869
+ let pricePrecision = this.safeNumber(filterPrice, 'tickSize');
870
+ if (pricePrecision === undefined) {
871
+ pricePrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision')));
872
+ }
873
+ const amountPrecision = (filterLotSize !== undefined) ? this.safeNumber(filterLotSize, 'stepSize') : this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision')));
874
+ return this.safeMarketStructure({
875
+ 'id': id,
876
+ 'symbol': symbol,
877
+ 'base': base,
878
+ 'quote': quote,
879
+ 'settle': settle,
880
+ 'baseId': baseId,
881
+ 'quoteId': quoteId,
882
+ 'settleId': settleId,
883
+ 'type': isContract ? 'swap' : 'spot',
884
+ 'spot': spot,
885
+ 'margin': false,
886
+ 'swap': swap,
887
+ 'future': false,
888
+ 'option': false,
889
+ 'active': active,
890
+ 'contract': isContract,
891
+ 'linear': linear,
892
+ 'inverse': inverse,
893
+ 'taker': this.fees['trading']['taker'],
894
+ 'maker': this.fees['trading']['maker'],
895
+ 'contractSize': contractSize,
896
+ 'expiry': undefined,
897
+ 'expiryDatetime': undefined,
898
+ 'strike': undefined,
899
+ 'optionType': undefined,
900
+ 'precision': {
901
+ 'amount': amountPrecision,
902
+ 'price': pricePrecision,
903
+ 'base': this.parseNumber(this.parsePrecision(this.safeString(market, 'baseAssetPrecision'))),
904
+ 'quote': this.parseNumber(this.parsePrecision(this.safeString(market, 'quotePrecision'))),
905
+ },
906
+ 'limits': {
907
+ 'leverage': {
908
+ 'min': undefined,
909
+ 'max': undefined,
837
910
  },
838
- 'limits': {
839
- 'leverage': {
840
- 'min': undefined,
841
- 'max': undefined,
842
- },
843
- 'amount': {
844
- 'min': undefined,
845
- 'max': undefined,
846
- },
847
- 'price': {
848
- 'min': undefined,
849
- 'max': undefined,
850
- },
851
- 'cost': {
852
- 'min': undefined,
853
- 'max': undefined,
854
- },
911
+ 'amount': {
912
+ 'min': this.safeNumber(filterLotSize, 'minQty'),
913
+ 'max': this.safeNumber(filterLotSize, 'maxQty'),
855
914
  },
856
- 'created': this.safeInteger(market, 'onboardDate'),
857
- 'info': market,
858
- });
859
- if ('PRICE_FILTER' in filtersByType) {
860
- const filter = this.safeDict(filtersByType, 'PRICE_FILTER', {});
861
- entry['limits']['price'] = {
862
- 'min': this.safeNumber(filter, 'minPrice'),
863
- 'max': this.safeNumber(filter, 'maxPrice'),
864
- };
865
- entry['precision']['price'] = this.safeNumber(filter, 'tickSize');
866
- }
867
- if ('LOT_SIZE' in filtersByType) {
868
- const filter = this.safeDict(filtersByType, 'LOT_SIZE', {});
869
- entry['precision']['amount'] = this.safeNumber(filter, 'stepSize');
870
- entry['limits']['amount'] = {
871
- 'min': this.safeNumber(filter, 'minQty'),
872
- 'max': this.safeNumber(filter, 'maxQty'),
873
- };
874
- }
875
- if ('MARKET_LOT_SIZE' in filtersByType) {
876
- const filter = this.safeDict(filtersByType, 'MARKET_LOT_SIZE', {});
877
- entry['limits']['market'] = {
878
- 'min': this.safeNumber(filter, 'minQty'),
879
- 'max': this.safeNumber(filter, 'maxQty'),
880
- };
881
- }
882
- if (('MIN_NOTIONAL' in filtersByType) || ('NOTIONAL' in filtersByType)) {
883
- const filter = this.safeDict2(filtersByType, 'MIN_NOTIONAL', 'NOTIONAL', {});
884
- entry['limits']['cost']['min'] = this.safeNumber(filter, 'notional');
885
- }
886
- result.push(entry);
887
- }
888
- return result;
915
+ 'price': {
916
+ 'min': this.safeNumber(filterPrice, 'minPrice'),
917
+ 'max': this.safeNumber(filterPrice, 'maxPrice'),
918
+ },
919
+ 'cost': {
920
+ 'min': this.safeNumber2(filterNotional, 'notional', 'minNotional'),
921
+ 'max': undefined,
922
+ },
923
+ 'market': {
924
+ 'min': this.safeNumber(filterMarketLotSize, 'minQty'),
925
+ 'max': this.safeNumber(filterMarketLotSize, 'maxQty'),
926
+ },
927
+ },
928
+ 'created': this.safeInteger2(market, 'listingTime', 'createTime'),
929
+ 'info': market,
930
+ });
889
931
  }
890
932
  /**
891
933
  * @method
892
934
  * @name aster#fetchTime
893
935
  * @description fetches the current integer timestamp in milliseconds from the exchange server
894
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#check-server-time
936
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#get-server-time
937
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#check-server-time
895
938
  * @param {object} [params] extra parameters specific to the exchange API endpoint
896
939
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
897
940
  */
898
941
  async fetchTime(params = {}) {
899
- const response = await this.fapiPublicGetV1Time(params);
942
+ let marketType = undefined;
943
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTime', undefined, params);
944
+ let response = undefined;
945
+ if (marketType === 'swap') {
946
+ response = await this.fapiPublicGetV3Time(params);
947
+ }
948
+ else {
949
+ response = await this.sapiPublicGetV3Time(params);
950
+ }
900
951
  //
901
- // {
902
- // "serverTime": 1499827319559
903
- // }
952
+ // both SPOT & PERP has same format
953
+ //
954
+ // {
955
+ // "serverTime": 1499827319559
956
+ // }
904
957
  //
905
958
  return this.safeInteger(response, 'serverTime');
906
959
  }
907
960
  parseOHLCV(ohlcv, market = undefined) {
961
+ //
962
+ // spot:
908
963
  //
909
964
  // [
910
- // 1631158560000,
911
- // "208.1850",
912
- // "208.1850",
913
- // "208.1850",
914
- // "208.1850",
915
- // "11.84",
916
- // 1631158619999,
917
- // "2464.910400",
918
- // 1,
919
- // "11.84",
920
- // "2464.910400",
921
- // "0"
965
+ // 1499040000000, // Open time
966
+ // "0.01634790", // Open
967
+ // "0.80000000", // High
968
+ // "0.01575800", // Low
969
+ // "0.01577100", // Close
970
+ // "148976.11427815", // Volume
971
+ // 1499644799999, // Close time
972
+ // "2434.19055334", // Quote asset volume
973
+ // 308, // Number of trades
974
+ // "1756.87402397", // Taker buy base asset volume
975
+ // "28.46694368", // Taker buy quote asset volume
976
+ // "0" // ??
922
977
  // ]
923
978
  //
924
979
  return [
@@ -934,8 +989,10 @@ export default class aster extends Exchange {
934
989
  * @method
935
990
  * @name aster#fetchOHLCV
936
991
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
937
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#k-line-data
938
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#klinecandlestick-data
992
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#k-line-data
993
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#klinecandlestick-data
994
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#index-price-klinecandlestick-data
995
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#mark-price-klinecandlestick-data
939
996
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
940
997
  * @param {string} timeframe the length of time each candle represents
941
998
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -946,9 +1003,6 @@ export default class aster extends Exchange {
946
1003
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
947
1004
  */
948
1005
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
949
- if (symbol === undefined) {
950
- throw new ArgumentsRequired(this.id + ' fetchOHLCV() requires a symbol argument');
951
- }
952
1006
  await this.loadMarkets();
953
1007
  const market = this.market(symbol);
954
1008
  let request = {};
@@ -956,10 +1010,7 @@ export default class aster extends Exchange {
956
1010
  request['startTime'] = since;
957
1011
  }
958
1012
  if (limit !== undefined) {
959
- if (limit > 1500) {
960
- limit = 1500; // Default 500; max 1500.
961
- }
962
- request['limit'] = limit;
1013
+ request['limit'] = Math.min(limit, 1500);
963
1014
  }
964
1015
  [request, params] = this.handleUntilOption('endTime', request, params);
965
1016
  request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
@@ -970,97 +1021,116 @@ export default class aster extends Exchange {
970
1021
  let response = undefined;
971
1022
  if (isMark) {
972
1023
  request['symbol'] = market['id'];
973
- response = await this.fapiPublicGetV1MarkPriceKlines(this.extend(request, params));
1024
+ response = await this.fapiPublicGetV3MarkPriceKlines(this.extend(request, params));
974
1025
  }
975
1026
  else if (isIndex) {
976
1027
  request['pair'] = market['id'];
977
- response = await this.fapiPublicGetV1IndexPriceKlines(this.extend(request, params));
1028
+ response = await this.fapiPublicGetV3IndexPriceKlines(this.extend(request, params));
978
1029
  }
979
1030
  else {
980
1031
  request['symbol'] = market['id'];
981
1032
  if (market['linear']) {
982
- response = await this.fapiPublicGetV1Klines(this.extend(request, params));
1033
+ response = await this.fapiPublicGetV3Klines(this.extend(request, params));
983
1034
  }
984
1035
  else {
985
- response = await this.sapiPublicGetV1Klines(this.extend(request, params));
1036
+ response = await this.sapiPublicGetV3Klines(this.extend(request, params));
986
1037
  }
1038
+ //
1039
+ // both SPOT & PERP has same format
1040
+ //
1041
+ // [
1042
+ // [
1043
+ // 1499040000000, // Open time
1044
+ // "0.01634790", // Open
1045
+ // "0.80000000", // High
1046
+ // "0.01575800", // Low
1047
+ // "0.01577100", // Close
1048
+ // "148976.11427815", // Volume
1049
+ // 1499644799999, // Close time
1050
+ // "2434.19055334", // Quote asset volume
1051
+ // 308, // Number of trades
1052
+ // "1756.87402397", // Taker buy base asset volume
1053
+ // "28.46694368", // Taker buy quote asset volume,
1054
+ // "0"
1055
+ // ]
1056
+ // ]
1057
+ //
987
1058
  }
988
- //
989
- // [
990
- // [
991
- // 1631158560000,
992
- // "208.1850",
993
- // "208.1850",
994
- // "208.1850",
995
- // "208.1850",
996
- // "11.84",
997
- // 1631158619999,
998
- // "2464.910400",
999
- // 1,
1000
- // "11.84",
1001
- // "2464.910400",
1002
- // "0"
1003
- // ]
1004
- // ]
1005
- //
1006
1059
  return this.parseOHLCVs(response, market, timeframe, since, limit);
1007
1060
  }
1008
1061
  parseTrade(trade, market = undefined) {
1009
1062
  //
1010
1063
  // fetchTrades
1011
1064
  //
1065
+ // recent trades:
1066
+ //
1012
1067
  // {
1013
1068
  // "id": 3913206,
1014
1069
  // "price": "644.100",
1015
1070
  // "qty": "0.08",
1016
- // "quoteQty": "51.528",
1071
+ // "quoteQty": "51.528", // present in PERP
1072
+ // "baseQty": "4.95049505", // present in SPOT
1017
1073
  // "time": 1749784506633,
1018
1074
  // "isBuyerMaker": true
1019
1075
  // }
1020
1076
  //
1077
+ // aggrTrades
1078
+ //
1021
1079
  // {
1022
- // "id": 657,
1023
- // "price": "1.01000000",
1024
- // "qty": "5.00000000",
1025
- // "baseQty": "4.95049505",
1026
- // "time": 1755156533943,
1027
- // "isBuyerMaker": false
1080
+ // "a": 26129, // Aggregate tradeId
1081
+ // "p": "0.01633102", // Price
1082
+ // "q": "4.70443515", // Quantity
1083
+ // "f": 27781, // First tradeId
1084
+ // "l": 27781, // Last tradeId
1085
+ // "T": 1498793709153, // Timestamp
1086
+ // "m": true, // Was the buyer the maker?
1028
1087
  // }
1029
1088
  //
1030
- // fetchMyTrades
1089
+ // fetchMyTrades (SPOT & PERP have similar format)
1031
1090
  //
1032
- // {
1033
- // "buyer": false,
1034
- // "commission": "-0.07819010",
1035
- // "commissionAsset": "USDT",
1036
- // "id": 698759,
1037
- // "maker": false,
1038
- // "orderId": 25851813,
1039
- // "price": "7819.01",
1040
- // "qty": "0.002",
1041
- // "quoteQty": "15.63802",
1042
- // "realizedPnl": "-0.91539999",
1043
- // "side": "SELL",
1044
- // "positionSide": "SHORT",
1045
- // "symbol": "BTCUSDT",
1046
- // "time": 1569514978020
1047
- // }
1091
+ // {
1092
+ // "symbol": "ETHUSDT",
1093
+ // "id": 2583152,
1094
+ // "orderId": 418588675,
1095
+ // "side": "SELL",
1096
+ // "price": "2330.04",
1097
+ // "qty": "0.0030",
1098
+ // "quoteQty": "6.99000000",
1099
+ // "commission": "0.00279605",
1100
+ // "commissionAsset": "USDT",
1101
+ // "time": 1776409179230,
1102
+ // "counterpartyId": 5143150, // only in SPOT
1103
+ // "createUpdateId": null, // only in SPOT
1104
+ // "maker": false, // only in SPOT
1105
+ // "buyer": false, // only in SPOT
1106
+ // "realizedPnl": "0.00029999", // only in PERP
1107
+ // "marginAsset": "USDT", // only in PERP
1108
+ // "positionSide": "BOTH", // only in PERP
1109
+ // }
1048
1110
  //
1049
- const id = this.safeString(trade, 'id');
1050
- const symbol = market['symbol'];
1051
- const currencyId = this.safeString(trade, 'commissionAsset');
1111
+ const id = this.safeString2(trade, 'id', 'a');
1112
+ const marketId = this.safeString(trade, 'symbol');
1113
+ const marketType = ('positionSide' in trade) ? 'swap' : 'spot';
1114
+ market = this.safeMarket(marketId, market, undefined, marketType);
1115
+ const currencyId = this.safeString2(trade, 'commissionAsset', 'marginAsset');
1052
1116
  const currencyCode = this.safeCurrencyCode(currencyId);
1053
- const amountString = this.safeString(trade, 'qty');
1054
- const priceString = this.safeString(trade, 'price');
1117
+ const amountString = this.safeString2(trade, 'qty', 'q');
1118
+ const priceString = this.safeString2(trade, 'price', 'p');
1055
1119
  const costString = this.safeString2(trade, 'quoteQty', 'baseQty');
1056
- const timestamp = this.safeInteger(trade, 'time');
1120
+ const timestamp = this.safeInteger2(trade, 'time', 'T');
1057
1121
  let side = this.safeStringLower(trade, 'side');
1058
1122
  const isMaker = this.safeBool(trade, 'maker');
1059
1123
  let takerOrMaker = undefined;
1060
1124
  if (isMaker !== undefined) {
1061
1125
  takerOrMaker = isMaker ? 'maker' : 'taker';
1126
+ if (side === undefined) {
1127
+ const isBuyer = this.safeBool(trade, 'buyer');
1128
+ if (isBuyer !== undefined) {
1129
+ side = isBuyer ? 'buy' : 'sell';
1130
+ }
1131
+ }
1062
1132
  }
1063
- const isBuyerMaker = this.safeBool(trade, 'isBuyerMaker');
1133
+ const isBuyerMaker = this.safeBool2(trade, 'isBuyerMaker', 'm');
1064
1134
  if (isBuyerMaker !== undefined) {
1065
1135
  side = isBuyerMaker ? 'sell' : 'buy';
1066
1136
  }
@@ -1069,7 +1139,7 @@ export default class aster extends Exchange {
1069
1139
  'info': trade,
1070
1140
  'timestamp': timestamp,
1071
1141
  'datetime': this.iso8601(timestamp),
1072
- 'symbol': symbol,
1142
+ 'symbol': market['symbol'],
1073
1143
  'order': this.safeString(trade, 'orderId'),
1074
1144
  'type': undefined,
1075
1145
  'side': side,
@@ -1087,8 +1157,10 @@ export default class aster extends Exchange {
1087
1157
  * @method
1088
1158
  * @name aster#fetchTrades
1089
1159
  * @description get the list of most recent trades for a particular symbol
1090
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#recent-trades-list
1091
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#recent-trades-list
1160
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#recent-trades-list
1161
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#recent-trades-aggregated
1162
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#recent-trades-list
1163
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#compressedaggregate-trades-list
1092
1164
  * @param {string} symbol unified symbol of the market to fetch trades for
1093
1165
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1094
1166
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -1096,48 +1168,68 @@ export default class aster extends Exchange {
1096
1168
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1097
1169
  */
1098
1170
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1099
- if (symbol === undefined) {
1100
- throw new ArgumentsRequired(this.id + ' fetchTrades() requires a symbol argument');
1101
- }
1102
1171
  await this.loadMarkets();
1103
1172
  const market = this.market(symbol);
1104
- const request = {
1173
+ let request = {
1105
1174
  'symbol': market['id'],
1106
1175
  };
1107
1176
  if (limit !== undefined) {
1108
- if (limit > 1000) {
1109
- limit = 1000; // Default 500; max 1000.
1110
- }
1111
- request['limit'] = limit;
1177
+ request['limit'] = Math.min(limit, 1000);
1112
1178
  }
1113
1179
  let response = undefined;
1114
- if (market['swap']) {
1115
- response = await this.fapiPublicGetV1Trades(this.extend(request, params));
1180
+ const sinceDefined = since !== undefined;
1181
+ const untilDefined = ('until' in params);
1182
+ if (sinceDefined) {
1183
+ request['startTime'] = since;
1184
+ }
1185
+ if (untilDefined) {
1186
+ request = this.handleUntilOption('endTime', request, params);
1187
+ }
1188
+ // use historical endpoint for targeted requests
1189
+ if ('startTime' in request) {
1190
+ if (market['swap']) {
1191
+ response = await this.fapiPublicGetV3AggTrades(this.extend(request, params));
1192
+ }
1193
+ else {
1194
+ response = await this.sapiPublicGetV3AggTrades(this.extend(request, params));
1195
+ }
1116
1196
  //
1117
- // [
1118
- // {
1119
- // "id": 3913206,
1120
- // "price": "644.100",
1121
- // "qty": "0.08",
1122
- // "quoteQty": "51.528",
1123
- // "time": 1749784506633,
1124
- // "isBuyerMaker": true
1125
- // }
1126
- // ]
1197
+ // both FAPI and SAPI have same response format
1198
+ //
1199
+ // [
1200
+ // {
1201
+ // "a": 26129, // Aggregate tradeId
1202
+ // "p": "0.01633102", // Price
1203
+ // "q": "4.70443515", // Quantity
1204
+ // "f": 27781, // First tradeId
1205
+ // "l": 27781, // Last tradeId
1206
+ // "T": 1498793709153, // Timestamp
1207
+ // "m": true, // Was the buyer the maker?
1208
+ // }
1209
+ // ]
1127
1210
  //
1128
1211
  }
1129
1212
  else {
1130
- response = await this.sapiPublicGetV1Trades(this.extend(request, params));
1131
- // [
1132
- // {
1133
- // "id": 657,
1134
- // "price": "1.01000000",
1135
- // "qty": "5.00000000",
1136
- // "baseQty": "4.95049505",
1137
- // "time": 1755156533943,
1138
- // "isBuyerMaker": false
1139
- // }
1140
- // ]
1213
+ if (market['swap']) {
1214
+ response = await this.fapiPublicGetV3Trades(this.extend(request, params));
1215
+ }
1216
+ else {
1217
+ response = await this.sapiPublicGetV3Trades(this.extend(request, params));
1218
+ }
1219
+ //
1220
+ // SAPI & FAPI have only one field difference
1221
+ //
1222
+ // [
1223
+ // {
1224
+ // "id": "73620768",
1225
+ // "price": "2324.07",
1226
+ // "qty": "0.430",
1227
+ // "quoteQty": "999.35", // only in PERP
1228
+ // "baseQty": "4.95049505", // only in SPOT
1229
+ // "time": "1776407252900",
1230
+ // "isBuyerMaker": false
1231
+ // }, ...
1232
+ //
1141
1233
  }
1142
1234
  return this.parseTrades(response, market, since, limit);
1143
1235
  }
@@ -1145,8 +1237,8 @@ export default class aster extends Exchange {
1145
1237
  * @method
1146
1238
  * @name aster#fetchMyTrades
1147
1239
  * @description fetch all trades made by the user
1148
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#account-trade-history-user_data
1149
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#account-trade-list-user_data
1240
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#account-trade-history-user_data
1241
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#account-trade-list-user_data
1150
1242
  * @param {string} [symbol] unified market symbol
1151
1243
  * @param {int} [since] the earliest time in ms to fetch trades for
1152
1244
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -1155,50 +1247,51 @@ export default class aster extends Exchange {
1155
1247
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1156
1248
  */
1157
1249
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1158
- if (symbol === undefined) {
1159
- throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
1250
+ await this.loadMarketsAndSignIn();
1251
+ let request = {};
1252
+ let market = undefined;
1253
+ if (symbol !== undefined) {
1254
+ market = this.market(symbol);
1255
+ request['symbol'] = market['id'];
1160
1256
  }
1161
- await this.loadMarkets();
1162
- const market = this.market(symbol);
1163
- let request = {
1164
- 'symbol': market['id'],
1165
- };
1257
+ let marketType = undefined;
1258
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
1166
1259
  if (since !== undefined) {
1167
1260
  request['startTime'] = since;
1168
1261
  }
1169
1262
  if (limit !== undefined) {
1170
- if (limit > 1000) {
1171
- limit = 1000; // Default 500; max 1000.
1172
- }
1173
- request['limit'] = limit;
1263
+ request['limit'] = Math.min(limit, 1000);
1174
1264
  }
1175
1265
  [request, params] = this.handleUntilOption('endTime', request, params);
1176
1266
  let response = undefined;
1177
- if (market['swap']) {
1178
- response = await this.fapiPrivateGetV1UserTrades(this.extend(request, params));
1267
+ if (marketType === 'swap') {
1268
+ response = await this.fapiPrivateGetV3UserTrades(this.extend(request, params));
1179
1269
  }
1180
1270
  else {
1181
- response = await this.sapiPrivateGetV1UserTrades(this.extend(request, params));
1271
+ response = await this.sapiPrivateGetV3UserTrades(this.extend(request, params));
1182
1272
  }
1183
1273
  //
1184
- // [
1185
- // {
1186
- // "buyer": false,
1187
- // "commission": "-0.07819010",
1188
- // "commissionAsset": "USDT",
1189
- // "id": 698759,
1190
- // "maker": false,
1191
- // "orderId": 25851813,
1192
- // "price": "7819.01",
1193
- // "qty": "0.002",
1194
- // "quoteQty": "15.63802",
1195
- // "realizedPnl": "-0.91539999",
1196
- // "side": "SELL",
1197
- // "positionSide": "SHORT",
1198
- // "symbol": "BTCUSDT",
1199
- // "time": 1569514978020
1200
- // }
1201
- // ]
1274
+ // SPOT & PERP have similar format
1275
+ //
1276
+ // {
1277
+ // "symbol": "ETHUSDT",
1278
+ // "id": 2583152,
1279
+ // "orderId": 418588675,
1280
+ // "side": "SELL",
1281
+ // "price": "2330.04",
1282
+ // "qty": "0.0030",
1283
+ // "quoteQty": "6.99000000",
1284
+ // "commission": "0.00279605",
1285
+ // "commissionAsset": "USDT",
1286
+ // "time": 1776409179230,
1287
+ // "counterpartyId": 5143150, // only in PERP
1288
+ // "createUpdateId": null, // only in PERP
1289
+ // "maker": false, // only in PERP
1290
+ // "buyer": false, // only in PERP
1291
+ // "realizedPnl": "0.00029999", // only in SPOT
1292
+ // "marginAsset": "USDT", // only in SPOT
1293
+ // "positionSide": "BOTH", // only in SPOT
1294
+ // }
1202
1295
  //
1203
1296
  return this.parseTrades(response, market, since, limit, params);
1204
1297
  }
@@ -1206,37 +1299,32 @@ export default class aster extends Exchange {
1206
1299
  * @method
1207
1300
  * @name aster#fetchOrderBook
1208
1301
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1209
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#depth-information
1210
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#order-book
1302
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#depth-information
1303
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#order-book
1211
1304
  * @param {string} symbol unified symbol of the market to fetch the order book for
1212
1305
  * @param {int} [limit] the maximum amount of order book entries to return
1213
1306
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1214
1307
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1215
1308
  */
1216
1309
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
1217
- if (symbol === undefined) {
1218
- throw new ArgumentsRequired(this.id + ' fetchOrderBook() requires a symbol argument');
1219
- }
1220
1310
  await this.loadMarkets();
1221
1311
  const market = this.market(symbol);
1222
1312
  const request = {
1223
1313
  'symbol': market['id'],
1224
1314
  };
1315
+ let response = undefined;
1225
1316
  if (limit !== undefined) {
1226
- // limit: [5, 10, 20, 50, 100, 500, 1000]. Default: 500
1227
- if (limit > 1000) {
1228
- limit = 1000; // Default 500; max 1000.
1229
- }
1230
- request['limit'] = limit;
1317
+ request['limit'] = this.findNearestCeiling([5, 10, 20, 50, 100, 500, 1000], limit);
1231
1318
  }
1232
- let response = undefined;
1233
1319
  if (market['swap']) {
1234
- response = await this.fapiPublicGetV1Depth(this.extend(request, params));
1320
+ response = await this.fapiPublicGetV3Depth(this.extend(request, params));
1235
1321
  }
1236
1322
  else {
1237
- response = await this.sapiPublicGetV1Depth(this.extend(request, params));
1323
+ response = await this.sapiPublicGetV3Depth(this.extend(request, params));
1238
1324
  }
1239
1325
  //
1326
+ // both SPOT & PERP has same format
1327
+ //
1240
1328
  // {
1241
1329
  // "lastUpdateId": 1027024,
1242
1330
  // "E": 1589436922972, // Message output time
@@ -1258,118 +1346,50 @@ export default class aster extends Exchange {
1258
1346
  const timestamp = this.safeInteger(response, 'T');
1259
1347
  return this.parseOrderBook(response, symbol, timestamp, 'bids', 'asks');
1260
1348
  }
1261
- /**
1262
- * @method
1263
- * @name aster#fetchFundingRateHistory
1264
- * @description fetches historical funding rate prices
1265
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#get-funding-rate-history
1266
- * @param {string} symbol unified symbol of the market to fetch the funding rate history for
1267
- * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1268
- * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
1269
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1270
- * @param {int} [params.until] timestamp in ms of the latest funding rate
1271
- * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
1272
- */
1273
- async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1274
- await this.loadMarkets();
1275
- let request = {};
1276
- if (symbol !== undefined) {
1277
- const market = this.market(symbol);
1278
- request['symbol'] = market['id'];
1279
- }
1280
- if (since !== undefined) {
1281
- request['startTime'] = since;
1282
- }
1283
- if (limit !== undefined) {
1284
- if (limit > 1000) {
1285
- limit = 1000; // Default 100; max 1000
1286
- }
1287
- request['limit'] = limit;
1288
- }
1289
- [request, params] = this.handleUntilOption('endTime', request, params);
1290
- const response = await this.fapiPublicGetV1FundingRate(this.extend(request, params));
1349
+ parseTicker(ticker, market = undefined) {
1291
1350
  //
1292
- // [
1293
- // {
1294
- // "symbol": "BTCUSDT",
1295
- // "fundingTime": 1747209600000,
1296
- // "fundingRate": "0.00010000"
1297
- // }
1298
- // ]
1351
+ // fetchTicker & fetchTickers: both SPOT & PERP has similar format
1299
1352
  //
1300
- const rates = [];
1301
- for (let i = 0; i < response.length; i++) {
1302
- const entry = response[i];
1303
- const timestamp = this.safeInteger(entry, 'fundingTime');
1304
- rates.push({
1305
- 'info': entry,
1306
- 'symbol': this.safeSymbol(this.safeString(entry, 'symbol'), undefined, undefined, 'swap'),
1307
- 'fundingRate': this.safeNumber(entry, 'fundingRate'),
1308
- 'timestamp': timestamp,
1309
- 'datetime': this.iso8601(timestamp),
1310
- });
1311
- }
1312
- const sorted = this.sortBy(rates, 'timestamp');
1313
- return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
1314
- }
1315
- parseTicker(ticker, market = undefined) {
1353
+ // {
1354
+ // "symbol": "ETHUSDT",
1355
+ // "priceChange": "6.54",
1356
+ // "priceChangePercent": "0.279",
1357
+ // "weightedAvgPrice": "2330.70",
1358
+ // "lastPrice": "2350.00",
1359
+ // "lastQty": "4.437",
1360
+ // "openPrice": "2343.46",
1361
+ // "highPrice": "2363.20",
1362
+ // "lowPrice": "2283.86",
1363
+ // "volume": "267154.248",
1364
+ // "quoteVolume": "622657018.70",
1365
+ // "openTime": "1776329400000",
1366
+ // "closeTime": "1776415832593",
1367
+ // "firstId": "73520536",
1368
+ // "lastId": "73630176",
1369
+ // "count": "109640",
1370
+ // "baseAsset": "BTC", // only in SPOT
1371
+ // "quoteAsset": "USDT", // only in SPOT
1372
+ // "bidPrice": "71125.98", // only in SPOT
1373
+ // "bidQty": "0.00737", // only in SPOT
1374
+ // "askPrice": "71152.10", // only in SPOT
1375
+ // "askQty": "0.32399" // only in SPOT
1376
+ // }
1316
1377
  //
1317
- // spot
1318
- // {
1319
- // "symbol": "BTCUSDT",
1320
- // "priceChange": "-2274.38",
1321
- // "priceChangePercent": "-2.049",
1322
- // "weightedAvgPrice": "109524.37084136",
1323
- // "lastPrice": "108738.78",
1324
- // "lastQty": "0.00034",
1325
- // "openPrice": "111013.16",
1326
- // "highPrice": "111975.81",
1327
- // "lowPrice": "107459.25",
1328
- // "volume": "28.67876",
1329
- // "quoteVolume": "3141023.14551030",
1330
- // "openTime": "1760578800000",
1331
- // "closeTime": "1760665024749",
1332
- // "firstId": "37447",
1333
- // "lastId": "39698",
1334
- // "count": "2252",
1335
- // "baseAsset": "BTC",
1336
- // "quoteAsset": "USDT",
1337
- // "bidPrice": "108705.11",
1338
- // "bidQty": "0.03351",
1339
- // "askPrice": "108725.99",
1340
- // "askQty": "0.08724"
1341
- // }
1342
- // swap
1343
- // {
1344
- // "symbol": "BTCUSDT",
1345
- // "priceChange": "1845.7",
1346
- // "priceChangePercent": "1.755",
1347
- // "weightedAvgPrice": "105515.5",
1348
- // "lastPrice": "107037.7",
1349
- // "lastQty": "0.004",
1350
- // "openPrice": "105192.0",
1351
- // "highPrice": "107223.5",
1352
- // "lowPrice": "104431.6",
1353
- // "volume": "8753.286",
1354
- // "quoteVolume": "923607368.61",
1355
- // "openTime": 1749976620000,
1356
- // "closeTime": 1750063053754,
1357
- // "firstId": 24195078,
1358
- // "lastId": 24375783,
1359
- // "count": 180706
1360
- // }
1378
+ //
1379
+ // fetchBidsAsks: SPOT & PERP have only one field difference
1380
+ //
1381
+ // [
1382
+ // {
1383
+ // "symbol": "BMTUSDT",
1384
+ // "bidPrice": "0.004000",
1385
+ // "bidQty": "1250.0",
1386
+ // "askPrice": "0.000000",
1387
+ // "askQty": "0.0",
1388
+ // "time": "1776411276072",
1389
+ // "lastUpdateId": "453174307613" // only in PERP
1390
+ // }, ...
1361
1391
  //
1362
1392
  const timestamp = this.safeInteger(ticker, 'closeTime');
1363
- let marketType = undefined;
1364
- if ('bidQty' in ticker) {
1365
- marketType = 'spot';
1366
- }
1367
- else {
1368
- marketType = 'contract';
1369
- }
1370
- const marketId = this.safeString(ticker, 'symbol');
1371
- market = this.safeMarket(marketId, market, undefined, marketType);
1372
- const symbol = market['symbol'];
1373
1393
  const last = this.safeString(ticker, 'lastPrice');
1374
1394
  const open = this.safeString(ticker, 'openPrice');
1375
1395
  let percentage = this.safeString(ticker, 'priceChangePercent');
@@ -1378,8 +1398,18 @@ export default class aster extends Exchange {
1378
1398
  const baseVolume = this.safeString(ticker, 'volume');
1379
1399
  const high = this.safeString(ticker, 'highPrice');
1380
1400
  const low = this.safeString(ticker, 'lowPrice');
1401
+ const isTickerResponse = ('priceChange' in ticker);
1402
+ let marketType = undefined;
1403
+ if (isTickerResponse) {
1404
+ marketType = ('baseAsset' in ticker) ? 'spot' : 'swap';
1405
+ }
1406
+ else {
1407
+ marketType = ('lastUpdateId' in ticker) ? 'swap' : 'spot';
1408
+ }
1409
+ const marketId = this.safeString(ticker, 'symbol');
1410
+ market = this.safeMarket(marketId, market, undefined, marketType);
1381
1411
  return this.safeTicker({
1382
- 'symbol': symbol,
1412
+ 'symbol': market['symbol'],
1383
1413
  'timestamp': timestamp,
1384
1414
  'datetime': this.iso8601(timestamp),
1385
1415
  'high': high,
@@ -1407,16 +1437,13 @@ export default class aster extends Exchange {
1407
1437
  * @method
1408
1438
  * @name aster#fetchTicker
1409
1439
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1410
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#24h-price-change
1411
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#24hr-ticker-price-change-statistics
1440
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#24h-price-change
1441
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#24hr-ticker-price-change-statistics
1412
1442
  * @param {string} symbol unified symbol of the market to fetch the ticker for
1413
1443
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1414
1444
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1415
1445
  */
1416
1446
  async fetchTicker(symbol, params = {}) {
1417
- if (symbol === undefined) {
1418
- throw new ArgumentsRequired(this.id + ' fetchTicker() requires a symbol argument');
1419
- }
1420
1447
  await this.loadMarkets();
1421
1448
  const market = this.market(symbol);
1422
1449
  const request = {
@@ -1424,63 +1451,47 @@ export default class aster extends Exchange {
1424
1451
  };
1425
1452
  let response = undefined;
1426
1453
  if (market['swap']) {
1427
- response = await this.fapiPublicGetV1Ticker24hr(this.extend(request, params));
1428
- //
1429
- // {
1430
- // "symbol": "BTCUSDT",
1431
- // "priceChange": "1845.7",
1432
- // "priceChangePercent": "1.755",
1433
- // "weightedAvgPrice": "105515.5",
1434
- // "lastPrice": "107037.7",
1435
- // "lastQty": "0.004",
1436
- // "openPrice": "105192.0",
1437
- // "highPrice": "107223.5",
1438
- // "lowPrice": "104431.6",
1439
- // "volume": "8753.286",
1440
- // "quoteVolume": "923607368.61",
1441
- // "openTime": 1749976620000,
1442
- // "closeTime": 1750063053754,
1443
- // "firstId": 24195078,
1444
- // "lastId": 24375783,
1445
- // "count": 180706
1446
- // }
1447
- //
1454
+ response = await this.fapiPublicGetV3Ticker24hr(this.extend(request, params));
1448
1455
  }
1449
1456
  else {
1450
- response = await this.sapiPublicGetV1Ticker24hr(this.extend(request, params));
1451
- // {
1452
- // "symbol": "BTCUSDT",
1453
- // "priceChange": "-2274.38",
1454
- // "priceChangePercent": "-2.049",
1455
- // "weightedAvgPrice": "109524.37084136",
1456
- // "lastPrice": "108738.78",
1457
- // "lastQty": "0.00034",
1458
- // "openPrice": "111013.16",
1459
- // "highPrice": "111975.81",
1460
- // "lowPrice": "107459.25",
1461
- // "volume": "28.67876",
1462
- // "quoteVolume": "3141023.14551030",
1463
- // "openTime": "1760578800000",
1464
- // "closeTime": "1760665024749",
1465
- // "firstId": "37447",
1466
- // "lastId": "39698",
1467
- // "count": "2252",
1468
- // "baseAsset": "BTC",
1469
- // "quoteAsset": "USDT",
1470
- // "bidPrice": "108705.11",
1471
- // "bidQty": "0.03351",
1472
- // "askPrice": "108725.99",
1473
- // "askQty": "0.08724"
1474
- // }
1457
+ response = await this.sapiPublicGetV3Ticker24hr(this.extend(request, params));
1475
1458
  }
1459
+ //
1460
+ // both SPOT & PERP has same format
1461
+ //
1462
+ // {
1463
+ // "symbol": "ETHUSDT",
1464
+ // "priceChange": "6.54",
1465
+ // "priceChangePercent": "0.279",
1466
+ // "weightedAvgPrice": "2330.70",
1467
+ // "lastPrice": "2350.00",
1468
+ // "lastQty": "4.437",
1469
+ // "openPrice": "2343.46",
1470
+ // "highPrice": "2363.20",
1471
+ // "lowPrice": "2283.86",
1472
+ // "volume": "267154.248",
1473
+ // "quoteVolume": "622657018.70",
1474
+ // "openTime": "1776329400000",
1475
+ // "closeTime": "1776415832593",
1476
+ // "firstId": "73520536",
1477
+ // "lastId": "73630176",
1478
+ // "count": "109640",
1479
+ // "baseAsset": "BTC", // only in SPOT
1480
+ // "quoteAsset": "USDT", // only in SPOT
1481
+ // "bidPrice": "71125.98", // only in SPOT
1482
+ // "bidQty": "0.00737", // only in SPOT
1483
+ // "askPrice": "71152.10", // only in SPOT
1484
+ // "askQty": "0.32399" // only in SPOT
1485
+ // }
1486
+ //
1476
1487
  return this.parseTicker(response, market);
1477
1488
  }
1478
1489
  /**
1479
1490
  * @method
1480
1491
  * @name aster#fetchTickers
1481
1492
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1482
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#24h-price-change
1483
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#24hr-ticker-price-change-statistics
1493
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#24h-price-change
1494
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#24hr-ticker-price-change-statistics
1484
1495
  * @param {string[]} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1485
1496
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1486
1497
  * @param {string} [params.subType] "linear" or "inverse"
@@ -1491,19 +1502,14 @@ export default class aster extends Exchange {
1491
1502
  await this.loadMarkets();
1492
1503
  symbols = this.marketSymbols(symbols, undefined, true, true, true);
1493
1504
  const market = this.getMarketFromSymbols(symbols);
1494
- let type = undefined;
1495
- [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
1496
- let subType = undefined;
1497
- [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
1505
+ let marketType = undefined;
1506
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
1498
1507
  let response = undefined;
1499
- if (this.isLinear(type, subType)) {
1500
- response = await this.fapiPublicGetV1Ticker24hr(params);
1501
- }
1502
- else if (type === 'spot') {
1503
- response = await this.sapiPublicGetV1Ticker24hr(params);
1508
+ if (marketType === 'swap') {
1509
+ response = await this.fapiPublicGetV3Ticker24hr(params);
1504
1510
  }
1505
- else {
1506
- throw new NotSupported(this.id + ' fetchTickers() does not support ' + type + ' markets yet');
1511
+ else if (marketType === 'spot') {
1512
+ response = await this.sapiPublicGetV3Ticker24hr(params);
1507
1513
  }
1508
1514
  //
1509
1515
  // [
@@ -1523,13 +1529,127 @@ export default class aster extends Exchange {
1523
1529
  // "closeTime": 1750063053754,
1524
1530
  // "firstId": 24195078,
1525
1531
  // "lastId": 24375783,
1526
- // "count": 180706
1532
+ // "count": 180706,
1533
+ // "baseAsset": "BTC", // only in SPOT
1534
+ // "quoteAsset": "USDT", // only in SPOT
1535
+ // "bidPrice": "71125.98", // only in SPOT
1536
+ // "bidQty": "0.00737", // only in SPOT
1537
+ // "askPrice": "71152.10", // only in SPOT
1538
+ // "askQty": "0.32399" // only in SPOT
1527
1539
  // }
1528
1540
  // ]
1529
1541
  //
1530
1542
  return this.parseTickers(response, symbols);
1531
1543
  }
1544
+ /**
1545
+ * @method
1546
+ * @name aster#fetchLastPrices
1547
+ * @description fetches the last price for multiple markets
1548
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#latest-price
1549
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-price-ticker
1550
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
1551
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1552
+ * @param {string} [params.subType] "linear" or "inverse"
1553
+ * @returns {object} a dictionary of lastprices structures
1554
+ */
1555
+ async fetchLastPrices(symbols = undefined, params = {}) {
1556
+ await this.loadMarkets();
1557
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
1558
+ const market = this.getMarketFromSymbols(symbols);
1559
+ let marketType = undefined;
1560
+ [marketType, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
1561
+ let response = undefined;
1562
+ if (marketType === 'swap') {
1563
+ response = await this.fapiPublicGetV3TickerPrice(params);
1564
+ }
1565
+ else if (marketType === 'spot') {
1566
+ response = await this.sapiPublicGetV3TickerPrice(params);
1567
+ }
1568
+ //
1569
+ // both SPOT & SWAP has same format
1570
+ //
1571
+ // [
1572
+ // {
1573
+ // "symbol": "LTCBTC",
1574
+ // "price": "4.00000200"
1575
+ // "time": "1649666690902"
1576
+ // },
1577
+ // ...
1578
+ // ]
1579
+ //
1580
+ const results = [];
1581
+ for (let i = 0; i < response.length; i++) {
1582
+ const marketId = this.safeString(response[i], 'symbol');
1583
+ const safeMarket = this.safeMarket(marketId, undefined, undefined, marketType);
1584
+ const priceData = this.extend(this.parseLastPrice(response[i], safeMarket), params);
1585
+ results.push(priceData);
1586
+ }
1587
+ symbols = this.marketSymbols(symbols);
1588
+ return this.filterByArray(results, 'symbol', symbols);
1589
+ }
1590
+ parseLastPrice(entry, market = undefined) {
1591
+ //
1592
+ // spot & swap
1593
+ //
1594
+ // {
1595
+ // "symbol": "LTCBTC",
1596
+ // "price": "4.00000200"
1597
+ // "time": "1649666690902"
1598
+ // }
1599
+ //
1600
+ const timestamp = this.safeInteger(entry, 'time');
1601
+ return {
1602
+ 'symbol': market['symbol'],
1603
+ 'timestamp': timestamp,
1604
+ 'datetime': this.iso8601(timestamp),
1605
+ 'price': this.safeNumberOmitZero(entry, 'price'),
1606
+ 'side': undefined,
1607
+ 'info': entry,
1608
+ };
1609
+ }
1610
+ /**
1611
+ * @method
1612
+ * @name aster#fetchBidsAsks
1613
+ * @description fetches the bid and ask price and volume for multiple markets
1614
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#current-best-order
1615
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-order-book-ticker
1616
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
1617
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1618
+ * @param {string} [params.subType] "linear" or "inverse"
1619
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
1620
+ */
1621
+ async fetchBidsAsks(symbols = undefined, params = {}) {
1622
+ await this.loadMarkets();
1623
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
1624
+ const market = this.getMarketFromSymbols(symbols);
1625
+ let marketType = undefined;
1626
+ [marketType, params] = this.handleMarketTypeAndParams('fetchBidsAsks', market, params);
1627
+ let response = undefined;
1628
+ if (marketType === 'swap') {
1629
+ response = await this.fapiPublicGetV3TickerBookTicker(params);
1630
+ }
1631
+ else if (marketType === 'spot') {
1632
+ response = await this.sapiPublicGetV3TickerBookTicker(params);
1633
+ }
1634
+ //
1635
+ // SPOT & PERP have only one field difference
1636
+ //
1637
+ // [
1638
+ // {
1639
+ // "symbol": "BMTUSDT",
1640
+ // "bidPrice": "0.004000",
1641
+ // "bidQty": "1250.0",
1642
+ // "askPrice": "0.000000",
1643
+ // "askQty": "0.0",
1644
+ // "time": "1776411276072",
1645
+ // "lastUpdateId": "453174307613" // only in PERP
1646
+ // }, ...
1647
+ //
1648
+ return this.parseTickers(response, symbols);
1649
+ }
1532
1650
  parseFundingRate(contract, market = undefined) {
1651
+ //
1652
+ // fundingRate
1533
1653
  //
1534
1654
  // {
1535
1655
  // "symbol": "BTCUSDT",
@@ -1541,6 +1661,9 @@ export default class aster extends Exchange {
1541
1661
  // "nextFundingTime": 1750147200000,
1542
1662
  // "time": 1750146970000
1543
1663
  // }
1664
+ //
1665
+ // funding interval
1666
+ //
1544
1667
  // {
1545
1668
  // "symbol": "INJUSDT",
1546
1669
  // "interestRate": "0.00010000",
@@ -1583,7 +1706,7 @@ export default class aster extends Exchange {
1583
1706
  * @method
1584
1707
  * @name aster#fetchFundingRate
1585
1708
  * @description fetch the current funding rate
1586
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#mark-price
1709
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-price-ticker
1587
1710
  * @param {string} symbol unified market symbol
1588
1711
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1589
1712
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -1597,7 +1720,7 @@ export default class aster extends Exchange {
1597
1720
  const request = {
1598
1721
  'symbol': market['id'],
1599
1722
  };
1600
- const response = await this.fapiPublicGetV1PremiumIndex(this.extend(request, params));
1723
+ const response = await this.fapiPublicGetV3PremiumIndex(this.extend(request, params));
1601
1724
  //
1602
1725
  // {
1603
1726
  // "symbol": "BTCUSDT",
@@ -1616,7 +1739,7 @@ export default class aster extends Exchange {
1616
1739
  * @method
1617
1740
  * @name aster#fetchFundingRates
1618
1741
  * @description fetch the current funding rate for multiple symbols
1619
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#24hr-ticker-price-change-statistics
1742
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-price-ticker
1620
1743
  * @param {string[]} [symbols] list of unified market symbols
1621
1744
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1622
1745
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -1624,7 +1747,7 @@ export default class aster extends Exchange {
1624
1747
  async fetchFundingRates(symbols = undefined, params = {}) {
1625
1748
  await this.loadMarkets();
1626
1749
  symbols = this.marketSymbols(symbols);
1627
- const response = await this.fapiPublicGetV1PremiumIndex(this.extend(params));
1750
+ const response = await this.fapiPublicGetV3PremiumIndex(this.extend(params));
1628
1751
  //
1629
1752
  // [
1630
1753
  // {
@@ -1645,7 +1768,7 @@ export default class aster extends Exchange {
1645
1768
  * @method
1646
1769
  * @name aster#fetchFundingIntervals
1647
1770
  * @description fetch the funding rate interval for multiple markets
1648
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#get-funding-rate-config
1771
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#get-funding-rate-config
1649
1772
  * @param {string[]} [symbols] list of unified market symbols
1650
1773
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1651
1774
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -1655,7 +1778,7 @@ export default class aster extends Exchange {
1655
1778
  if (symbols !== undefined) {
1656
1779
  symbols = this.marketSymbols(symbols);
1657
1780
  }
1658
- const response = await this.fapiPublicGetV1FundingInfo(params);
1781
+ const response = await this.fapiPublicGetV3FundingInfo(params);
1659
1782
  //
1660
1783
  // [
1661
1784
  // {
@@ -1670,64 +1793,98 @@ export default class aster extends Exchange {
1670
1793
  //
1671
1794
  return this.parseFundingRates(response, symbols);
1672
1795
  }
1673
- parseBalance(response) {
1674
- const result = { 'info': response };
1675
- for (let i = 0; i < response.length; i++) {
1676
- const balance = response[i];
1677
- const currencyId = this.safeString(balance, 'asset');
1678
- const code = this.safeCurrencyCode(currencyId);
1679
- const account = this.account();
1680
- account['free'] = this.safeString2(balance, 'free', 'maxWithdrawAmount');
1681
- account['used'] = this.safeString(balance, 'locked');
1682
- account['total'] = this.safeString(balance, 'walletBalance');
1683
- result[code] = account;
1796
+ /**
1797
+ * @method
1798
+ * @name aster#fetchFundingRateHistory
1799
+ * @description fetches historical funding rate prices
1800
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#get-funding-rate-history
1801
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
1802
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1803
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
1804
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1805
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
1806
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
1807
+ */
1808
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1809
+ await this.loadMarkets();
1810
+ let request = {};
1811
+ let market = undefined;
1812
+ if (symbol !== undefined) {
1813
+ market = this.market(symbol);
1814
+ request['symbol'] = market['id'];
1684
1815
  }
1685
- return this.safeBalance(result);
1816
+ if (since !== undefined) {
1817
+ request['startTime'] = since;
1818
+ }
1819
+ if (limit !== undefined) {
1820
+ request['limit'] = Math.min(limit, 1000);
1821
+ }
1822
+ [request, params] = this.handleUntilOption('endTime', request, params);
1823
+ const response = await this.fapiPublicGetV3FundingRate(this.extend(request, params));
1824
+ //
1825
+ // [
1826
+ // {
1827
+ // "symbol": "BTCUSDT",
1828
+ // "fundingTime": 1747209600000,
1829
+ // "fundingRate": "0.00010000"
1830
+ // }
1831
+ // ]
1832
+ //
1833
+ return this.parseFundingRateHistories(response, market);
1834
+ }
1835
+ parseFundingRateHistory(contract, market = undefined) {
1836
+ //
1837
+ // {
1838
+ // "symbol": "BTCUSDT",
1839
+ // "fundingRate": "0.00063521",
1840
+ // "fundingTime": "1621267200000",
1841
+ // }
1842
+ //
1843
+ const timestamp = this.safeInteger(contract, 'fundingTime');
1844
+ return {
1845
+ 'info': contract,
1846
+ 'symbol': this.safeSymbol(this.safeString(contract, 'symbol'), undefined, undefined, 'swap'),
1847
+ 'fundingRate': this.safeNumber(contract, 'fundingRate'),
1848
+ 'timestamp': timestamp,
1849
+ 'datetime': this.iso8601(timestamp),
1850
+ };
1686
1851
  }
1687
1852
  /**
1688
1853
  * @method
1689
1854
  * @name aster#fetchBalance
1690
1855
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
1691
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#account-information-v4-user_data
1692
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#account-information-user_data
1856
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#account-information-user_data
1857
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#futures-account-balance-v3-user_data
1693
1858
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1694
1859
  * @param {string} [params.subType] "linear" or "inverse"
1695
1860
  * @param {string} [params.type] 'spot', 'option', use params["subType"] for swap and future markets
1696
1861
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1697
1862
  */
1698
1863
  async fetchBalance(params = {}) {
1699
- let type = undefined;
1700
- [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1701
- let subType = undefined;
1702
- [subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
1864
+ await this.loadMarketsAndSignIn();
1865
+ let marketType = undefined;
1866
+ [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1703
1867
  let response = undefined;
1704
1868
  let data = undefined;
1705
- if (this.isLinear(type, subType)) {
1706
- response = await this.fapiPrivateGetV4Account(params);
1707
- data = this.safeList(response, 'assets', []);
1869
+ if (marketType === 'swap') {
1870
+ data = await this.fapiPrivateGetV3Balance(params);
1708
1871
  //
1709
- // [
1710
- // {
1711
- // "asset": "USDT", // asset name
1712
- // "walletBalance": "23.72469206", // wallet balance
1713
- // "unrealizedProfit": "0.00000000", // unrealized profit
1714
- // "marginBalance": "23.72469206", // margin balance
1715
- // "maintMargin": "0.00000000", // maintenance margin required
1716
- // "initialMargin": "0.00000000", // total initial margin required with current mark price
1717
- // "positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
1718
- // "openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
1719
- // "crossWalletBalance": "23.72469206", // crossed wallet balance
1720
- // "crossUnPnl": "0.00000000", // unrealized profit of crossed positions
1721
- // "availableBalance": "23.72469206", // available balance
1722
- // "maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
1723
- // "marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
1724
- // "updateTime": 1625474304765 // last update time
1725
- // }
1726
- // ]
1872
+ // [
1873
+ // {
1874
+ // "accountAlias": "FzXquXsRFzXqAufW",
1875
+ // "asset": "CDL",
1876
+ // "balance": "0.00000000",
1877
+ // "crossWalletBalance": "0.00000000",
1878
+ // "crossUnPnl": "0.00000000",
1879
+ // "availableBalance": "878.90500233",
1880
+ // "maxWithdrawAmount": "0.00000000",
1881
+ // "marginAvailable": true,
1882
+ // "updateTime": "0"
1883
+ // }, ...
1727
1884
  //
1728
1885
  }
1729
- else if (type === 'spot') {
1730
- response = await this.sapiPrivateGetV1Account(params);
1886
+ else if (marketType === 'spot') {
1887
+ response = await this.sapiPrivateGetV3Account(params);
1731
1888
  data = this.safeList(response, 'balances', []);
1732
1889
  //
1733
1890
  // [
@@ -1739,16 +1896,27 @@ export default class aster extends Exchange {
1739
1896
  // ]
1740
1897
  //
1741
1898
  }
1742
- else {
1743
- throw new NotSupported(this.id + ' fetchBalance() does not support ' + type + ' markets yet');
1744
- }
1745
1899
  return this.parseBalance(data);
1746
1900
  }
1901
+ parseBalance(response) {
1902
+ const result = { 'info': response };
1903
+ for (let i = 0; i < response.length; i++) {
1904
+ const balance = response[i];
1905
+ const currencyId = this.safeString(balance, 'asset');
1906
+ const code = this.safeCurrencyCode(currencyId);
1907
+ const account = this.account();
1908
+ account['free'] = this.safeString2(balance, 'free', 'availableBalance');
1909
+ account['used'] = this.safeString(balance, 'locked');
1910
+ account['total'] = this.safeString(balance, 'balance');
1911
+ result[code] = account;
1912
+ }
1913
+ return this.safeBalance(result);
1914
+ }
1747
1915
  /**
1748
1916
  * @method
1749
1917
  * @name aster#setMarginMode
1750
1918
  * @description set margin mode to 'cross' or 'isolated'
1751
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#change-margin-type-trade
1919
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#change-margin-type-trade
1752
1920
  * @param {string} marginMode 'cross' or 'isolated'
1753
1921
  * @param {string} symbol unified market symbol
1754
1922
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1765,20 +1933,15 @@ export default class aster extends Exchange {
1765
1933
  if ((marginMode !== 'ISOLATED') && (marginMode !== 'CROSSED')) {
1766
1934
  throw new BadRequest(this.id + ' marginMode must be either isolated or cross');
1767
1935
  }
1768
- await this.loadMarkets();
1936
+ await this.loadMarketsAndSignIn();
1769
1937
  const market = this.market(symbol);
1770
1938
  const request = {
1771
1939
  'symbol': market['id'],
1772
1940
  'marginType': marginMode,
1773
1941
  };
1774
- const response = await this.fapiPrivatePostV1MarginType(this.extend(request, params));
1942
+ const response = await this.fapiPrivatePostV3MarginType(this.extend(request, params));
1775
1943
  //
1776
- // {
1777
- // "amount": 100.0,
1778
- // "code": 200,
1779
- // "msg": "Successfully modify position margin.",
1780
- // "type": 1
1781
- // }
1944
+ // { "code": 200,"msg": "success" }
1782
1945
  //
1783
1946
  return response;
1784
1947
  }
@@ -1786,37 +1949,37 @@ export default class aster extends Exchange {
1786
1949
  * @method
1787
1950
  * @name aster#fetchPositionMode
1788
1951
  * @description fetchs the position mode, hedged or one way, hedged for aster is set identically for all linear markets or all inverse markets
1789
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#get-current-position-modeuser_data
1952
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-current-position-modeuser_data
1790
1953
  * @param {string} symbol unified symbol of the market to fetch the order book for
1791
1954
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1792
1955
  * @returns {object} an object detailing whether the market is in hedged or one-way mode
1793
1956
  */
1794
1957
  async fetchPositionMode(symbol = undefined, params = {}) {
1795
- const response = await this.fapiPrivateGetV1PositionSideDual(params);
1958
+ const response = await this.fapiPrivateGetV3PositionSideDual(params);
1796
1959
  //
1797
1960
  // {
1798
1961
  // "dualSidePosition": true // "true": Hedge Mode; "false": One-way Mode
1799
1962
  // }
1800
1963
  //
1801
- const dualSidePosition = this.safeBool(response, 'dualSidePosition');
1802
1964
  return {
1803
1965
  'info': response,
1804
- 'hedged': (dualSidePosition === true),
1966
+ 'hedged': this.safeBool(response, 'dualSidePosition'),
1805
1967
  };
1806
1968
  }
1807
1969
  /**
1808
1970
  * @method
1809
1971
  * @name aster#setPositionMode
1810
1972
  * @description set hedged to true or false for a market
1811
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#change-position-modetrade
1973
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#change-position-modetrade
1812
1974
  * @param {bool} hedged set to true to use dualSidePosition
1813
1975
  * @param {string} symbol not used by bingx setPositionMode ()
1814
1976
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1815
1977
  * @returns {object} response from the exchange
1816
1978
  */
1817
1979
  async setPositionMode(hedged, symbol = undefined, params = {}) {
1980
+ const strValue = hedged ? 'true' : 'false';
1818
1981
  const request = {
1819
- 'dualSidePosition': hedged,
1982
+ 'dualSidePosition': strValue,
1820
1983
  };
1821
1984
  //
1822
1985
  // {
@@ -1824,7 +1987,7 @@ export default class aster extends Exchange {
1824
1987
  // "msg": "success"
1825
1988
  // }
1826
1989
  //
1827
- return await this.fapiPrivatePostV1PositionSideDual(this.extend(request, params));
1990
+ return await this.fapiPrivatePostV3PositionSideDual(this.extend(request, params));
1828
1991
  }
1829
1992
  parseTradingFee(fee, market = undefined) {
1830
1993
  const marketId = this.safeString(fee, 'symbol');
@@ -1843,26 +2006,28 @@ export default class aster extends Exchange {
1843
2006
  * @method
1844
2007
  * @name aster#fetchTradingFee
1845
2008
  * @description fetch the trading fees for a market
1846
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#get-symbol-fees
1847
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#user-commission-rate-user_data
2009
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#get-symbol-fees
2010
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#user-commission-rate-user_data
1848
2011
  * @param {string} symbol unified market symbol
1849
2012
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1850
2013
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
1851
2014
  */
1852
2015
  async fetchTradingFee(symbol, params = {}) {
1853
- await this.loadMarkets();
2016
+ await this.loadMarketsAndSignIn();
1854
2017
  const market = this.market(symbol);
1855
2018
  const request = {
1856
2019
  'symbol': market['id'],
1857
2020
  };
1858
2021
  let response = undefined;
1859
2022
  if (market['swap']) {
1860
- response = await this.fapiPrivateGetV1CommissionRate(this.extend(request, params));
2023
+ response = await this.fapiPrivateGetV3CommissionRate(this.extend(request, params));
1861
2024
  }
1862
2025
  else {
1863
- response = await this.sapiPrivateGetV1CommissionRate(this.extend(request, params));
2026
+ response = await this.sapiPrivateGetV3CommissionRate(this.extend(request, params));
1864
2027
  }
1865
2028
  //
2029
+ // both SPOT & SWAP has same format
2030
+ //
1866
2031
  // {
1867
2032
  // "symbol": "BTCUSDT",
1868
2033
  // "makerCommissionRate": "0.0002",
@@ -1922,32 +2087,36 @@ export default class aster extends Exchange {
1922
2087
  // "workingType": "CONTRACT_PRICE",
1923
2088
  // "priceProtect": false
1924
2089
  // }
2090
+ //
1925
2091
  // spot
1926
- // {
1927
- // "orderId": 38,
1928
- // "symbol": "ADA25SLP25",
1929
- // "status": "FILLED",
1930
- // "clientOrderId": "afMd4GBQyHkHpGWdiy34Li",
1931
- // "price": "20",
1932
- // "avgPrice": "12.0000000000000000",
1933
- // "origQty": "10",
1934
- // "executedQty": "10",
1935
- // "cumQuote": "120",
1936
- // "timeInForce": "GTC",
1937
- // "type": "LIMIT",
1938
- // "side": "BUY",
1939
- // "stopPrice": "0",
1940
- // "origType": "LIMIT",
1941
- // "time": 1649913186270,
1942
- // "updateTime": 1649913186297
1943
- // }
2092
+ //
2093
+ // fetchOrders, fetchOpenOrders, fetchOpenOrder, fetchOrder, cancelOrder, createOrder
2094
+ //
2095
+ // {
2096
+ // "orderId": "417594542",
2097
+ // "symbol": "ETHUSDT",
2098
+ // "status": "FILLED",
2099
+ // "clientOrderId": "web_qnvMAhOJsiVbSyu0BdKG",
2100
+ // "price": "0", // value set for unfilled
2101
+ // "avgPrice": "2351.580000", // value zero for unfilled
2102
+ // "origQty": "0.0054",
2103
+ // "executedQty": "0.0054", // value zero for unfilled
2104
+ // "cumQuote": "12.69853200", // value zero for unfilled
2105
+ // "timeInForce": "GTC",
2106
+ // "type": "MARKET",
2107
+ // "side": "SELL",
2108
+ // "stopPrice": "0",
2109
+ // "origType": "MARKET",
2110
+ // "time": "1776274219582",
2111
+ // "updateTime": "1776274219609",
2112
+ // "orderListId": "-1"
2113
+ // }
1944
2114
  //
1945
2115
  const info = order;
1946
2116
  const marketId = this.safeString(order, 'symbol');
1947
2117
  market = this.safeMarket(marketId, market);
1948
2118
  const side = this.safeStringLower(order, 'side');
1949
2119
  const timestamp = this.safeInteger(order, 'time');
1950
- const lastTradeTimestamp = this.safeInteger(order, 'updateTime');
1951
2120
  const statusId = this.safeStringUpper(order, 'status');
1952
2121
  const rawType = this.safeStringUpper(order, 'type');
1953
2122
  const stopPriceString = this.safeString(order, 'stopPrice');
@@ -1959,7 +2128,7 @@ export default class aster extends Exchange {
1959
2128
  'symbol': this.safeSymbol(marketId, market),
1960
2129
  'timestamp': timestamp,
1961
2130
  'datetime': this.iso8601(timestamp),
1962
- 'lastTradeTimestamp': lastTradeTimestamp,
2131
+ 'lastTradeTimestamp': undefined,
1963
2132
  'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
1964
2133
  'type': this.parseOrderType(rawType),
1965
2134
  'timeInForce': this.safeString(order, 'timeInForce'),
@@ -1982,8 +2151,8 @@ export default class aster extends Exchange {
1982
2151
  * @method
1983
2152
  * @name aster#fetchOrder
1984
2153
  * @description fetches information on an order made by the user
1985
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#query-order-user_data
1986
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#query-order-user_data
2154
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#query-order-user_data
2155
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#query-order-user_data
1987
2156
  * @param {string} id the order id
1988
2157
  * @param {string} symbol unified symbol of the market the order was made in
1989
2158
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1994,7 +2163,7 @@ export default class aster extends Exchange {
1994
2163
  if (symbol === undefined) {
1995
2164
  throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
1996
2165
  }
1997
- await this.loadMarkets();
2166
+ await this.loadMarketsAndSignIn();
1998
2167
  const market = this.market(symbol);
1999
2168
  const request = {
2000
2169
  'symbol': market['id'],
@@ -2009,18 +2178,48 @@ export default class aster extends Exchange {
2009
2178
  }
2010
2179
  let response = undefined;
2011
2180
  if (market['swap']) {
2012
- response = await this.fapiPrivateGetV1Order(this.extend(request, params));
2181
+ response = await this.fapiPrivateGetV3Order(this.extend(request, params));
2013
2182
  }
2014
2183
  else {
2015
- response = await this.sapiPrivateGetV1Order(this.extend(request, params));
2184
+ response = await this.sapiPrivateGetV3Order(this.extend(request, params));
2016
2185
  }
2186
+ //
2187
+ // SPOT & SWAP has similar formats
2188
+ //
2189
+ // {
2190
+ // "orderId": "17338441758",
2191
+ // "symbol": "ETHUSDT",
2192
+ // "status": "FILLED",
2193
+ // "clientOrderId": "727Wt3TIUgkUCxXp20E543",
2194
+ // "price": "0",
2195
+ // "avgPrice": "2304.56000",
2196
+ // "origQty": "0.010",
2197
+ // "executedQty": "0.010",
2198
+ // "cumQuote": "23.04560",
2199
+ // "timeInForce": "GTC",
2200
+ // "type": "MARKET",
2201
+ // "side": "BUY",
2202
+ // "stopPrice": "0",
2203
+ // "origType": "MARKET",
2204
+ // "time": "1776800300736",
2205
+ // "updateTime": "1776800300700",
2206
+ // "orderListId": "-1" // only in SPOT
2207
+ // "positionSide": "BOTH", // only in SWAP
2208
+ // "reduceOnly": false, // only in SWAP
2209
+ // "closePosition": false, // only in SWAP
2210
+ // "workingType": "CONTRACT_PRICE", // only in SWAP
2211
+ // "priceProtect": false, // only in SWAP
2212
+ // "newChainData": { "hash": "0x46aed5...67bdbec8ba" } // only in SWAP
2213
+ // }
2214
+ //
2017
2215
  return this.parseOrder(response, market);
2018
2216
  }
2019
2217
  /**
2020
2218
  * @method
2021
2219
  * @name aster#fetchOpenOrder
2022
2220
  * @description fetch an open order by the id
2023
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#query-current-open-order-user_data
2221
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#query-current-open-order-user_data
2222
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#query-current-open-order-user_data
2024
2223
  * @param {string} id order id
2025
2224
  * @param {string} symbol unified market symbol
2026
2225
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2030,7 +2229,7 @@ export default class aster extends Exchange {
2030
2229
  if (symbol === undefined) {
2031
2230
  throw new ArgumentsRequired(this.id + ' fetchOpenOrder() requires a symbol argument');
2032
2231
  }
2033
- await this.loadMarkets();
2232
+ await this.loadMarketsAndSignIn();
2034
2233
  const market = this.market(symbol);
2035
2234
  const request = {
2036
2235
  'symbol': market['id'],
@@ -2043,15 +2242,50 @@ export default class aster extends Exchange {
2043
2242
  else {
2044
2243
  request['orderId'] = id;
2045
2244
  }
2046
- const response = await this.fapiPrivateGetV1OpenOrder(this.extend(request, params));
2245
+ let response = undefined;
2246
+ if (market['spot']) {
2247
+ response = await this.sapiPrivateGetV3OpenOrder(this.extend(request, params));
2248
+ }
2249
+ else {
2250
+ response = await this.fapiPrivateGetV3OpenOrder(this.extend(request, params));
2251
+ }
2252
+ //
2253
+ // SPOT & SWAP has similar formats
2254
+ //
2255
+ // {
2256
+ // "orderId": "17338441758",
2257
+ // "symbol": "ETHUSDT",
2258
+ // "status": "FILLED",
2259
+ // "clientOrderId": "727Wt3TIUgkUCxXp20E543",
2260
+ // "price": "0",
2261
+ // "avgPrice": "2304.56000",
2262
+ // "origQty": "0.010",
2263
+ // "executedQty": "0.010",
2264
+ // "cumQuote": "23.04560",
2265
+ // "timeInForce": "GTC",
2266
+ // "type": "MARKET",
2267
+ // "side": "BUY",
2268
+ // "stopPrice": "0",
2269
+ // "origType": "MARKET",
2270
+ // "time": "1776800300736",
2271
+ // "updateTime": "1776800300700",
2272
+ // "orderListId": "-1" // only in SPOT
2273
+ // "positionSide": "BOTH", // only in SWAP
2274
+ // "reduceOnly": false, // only in SWAP
2275
+ // "closePosition": false, // only in SWAP
2276
+ // "workingType": "CONTRACT_PRICE", // only in SWAP
2277
+ // "priceProtect": false, // only in SWAP
2278
+ // "newChainData": { "hash": "0x46aed5...67bdbec8ba" } // only in SWAP
2279
+ // }
2280
+ //
2047
2281
  return this.parseOrder(response, market);
2048
2282
  }
2049
2283
  /**
2050
2284
  * @method
2051
2285
  * @name aster#fetchOrders
2052
2286
  * @description fetches information on multiple orders made by the user
2053
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#query-all-orders-user_data
2054
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#all-orders-user_data
2287
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#query-all-orders-user_data
2288
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#all-orders-user_data
2055
2289
  * @param {string} symbol unified market symbol of the market orders were made in
2056
2290
  * @param {int} [since] the earliest time in ms to fetch orders for
2057
2291
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -2060,39 +2294,66 @@ export default class aster extends Exchange {
2060
2294
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2061
2295
  */
2062
2296
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2063
- await this.loadMarkets();
2064
2297
  if (symbol === undefined) {
2065
2298
  throw new ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
2066
2299
  }
2300
+ await this.loadMarketsAndSignIn();
2067
2301
  const market = this.market(symbol);
2068
2302
  let request = {
2069
2303
  'symbol': market['id'],
2070
2304
  };
2305
+ if (limit !== undefined) {
2306
+ request['limit'] = Math.min(limit, 1000);
2307
+ }
2071
2308
  if (since !== undefined) {
2072
2309
  request['startTime'] = since;
2073
2310
  }
2074
- if (limit !== undefined) {
2075
- if (limit > 1000) {
2076
- limit = 1000; // Default 500; max 1000
2077
- }
2078
- request['limit'] = limit;
2079
- }
2080
2311
  [request, params] = this.handleUntilOption('endTime', request, params);
2081
2312
  let response = undefined;
2082
2313
  if (market['swap']) {
2083
- response = await this.fapiPrivateGetV1AllOrders(this.extend(request, params));
2314
+ response = await this.fapiPrivateGetV3AllOrders(this.extend(request, params));
2084
2315
  }
2085
2316
  else {
2086
- response = await this.sapiPrivateGetV1AllOrders(this.extend(request, params));
2317
+ response = await this.sapiPrivateGetV3AllOrders(this.extend(request, params));
2087
2318
  }
2319
+ //
2320
+ // SPOT & SWAP has similar responses
2321
+ //
2322
+ // [
2323
+ // {
2324
+ // "orderId": "417594542",
2325
+ // "symbol": "ETHUSDT",
2326
+ // "status": "FILLED",
2327
+ // "clientOrderId": "web_qnvMAhOJsiVbSyu0BdKG",
2328
+ // "price": "0", // value set for unfilled
2329
+ // "avgPrice": "2351.580000", // value zero for unfilled
2330
+ // "origQty": "0.0054",
2331
+ // "executedQty": "0.0054", // value zero for unfilled
2332
+ // "cumQuote": "12.69853200", // value zero for unfilled
2333
+ // "timeInForce": "GTC",
2334
+ // "type": "MARKET",
2335
+ // "side": "SELL",
2336
+ // "stopPrice": "0",
2337
+ // "origType": "MARKET",
2338
+ // "time": "1776274219582",
2339
+ // "updateTime": "1776274219609",
2340
+ // "orderListId": "-1", // only in SPOT
2341
+ // "reduceOnly": false, // only in PERP
2342
+ // "closePosition": false, // only in PERP
2343
+ // "positionSide": "BOTH", // only in PERP
2344
+ // "workingType": "CONTRACT_PRICE", // only in PERP
2345
+ // "priceProtect": false, // only in PERP
2346
+ // "newChainData": { "hash": "0xe17d3d5b...dbca8b01" } // only in PERP
2347
+ // }, ...
2348
+ //
2088
2349
  return this.parseOrders(response, market, since, limit);
2089
2350
  }
2090
2351
  /**
2091
2352
  * @method
2092
2353
  * @name aster#fetchOpenOrders
2093
2354
  * @description fetch all unfilled currently open orders
2094
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#current-open-orders-user_data
2095
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#current-all-open-orders-user_data
2355
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#current-open-orders-user_data
2356
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#current-all-open-orders-user_data
2096
2357
  * @param {string} symbol unified market symbol
2097
2358
  * @param {int} [since] the earliest time in ms to fetch open orders for
2098
2359
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -2102,55 +2363,63 @@ export default class aster extends Exchange {
2102
2363
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2103
2364
  */
2104
2365
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2105
- await this.loadMarkets();
2366
+ await this.loadMarketsAndSignIn();
2106
2367
  const request = {};
2107
2368
  let market = undefined;
2108
- let type = undefined;
2109
- let subType = undefined;
2110
- [subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
2369
+ let marketType = undefined;
2111
2370
  if (symbol !== undefined) {
2112
2371
  market = this.market(symbol);
2113
2372
  request['symbol'] = market['id'];
2114
2373
  }
2115
- [type, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
2116
- let response = undefined;
2117
- if (this.isLinear(type, subType)) {
2118
- response = await this.fapiPrivateGetV1OpenOrders(this.extend(request, params));
2119
- }
2120
- else if (type === 'spot') {
2121
- response = await this.sapiPrivateGetV1OpenOrders(this.extend(request, params));
2374
+ if (symbol === undefined) {
2375
+ if (this.options['fetchOpenOrders']['warnIfNoSymbol']) {
2376
+ throw new ExchangeError(this.id + ' fetchOpenOrders(): WARNING - this method without providing "symbol" argument uses 40 times more rate-limit quota. If you acknowledge this warning, set ' + this.id + '.options["fetchOpenOrders"]["warnIfNoSymbol"] = false to suppress this warning message.');
2377
+ }
2122
2378
  }
2123
2379
  else {
2124
- throw new NotSupported(this.id + ' fetchOpenOrders() does not support ' + type + ' markets yet');
2380
+ market = this.market(symbol);
2381
+ request['symbol'] = market['id'];
2382
+ }
2383
+ [marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
2384
+ let subType = undefined;
2385
+ [subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
2386
+ let response = undefined;
2387
+ if (this.isLinear(marketType, subType)) {
2388
+ response = await this.fapiPrivateGetV3OpenOrders(this.extend(request, params));
2389
+ }
2390
+ else if (marketType === 'spot') {
2391
+ response = await this.sapiPrivateGetV3OpenOrders(this.extend(request, params));
2125
2392
  }
2126
2393
  //
2127
- // [
2128
- // {
2129
- // "avgPrice": "0.00000",
2130
- // "clientOrderId": "abc",
2131
- // "cumQuote": "0",
2132
- // "executedQty": "0",
2133
- // "orderId": 1917641,
2134
- // "origQty": "0.40",
2135
- // "origType": "TRAILING_STOP_MARKET",
2136
- // "price": "0",
2137
- // "reduceOnly": false,
2138
- // "side": "BUY",
2139
- // "positionSide": "SHORT",
2140
- // "status": "NEW",
2141
- // "stopPrice": "9300",
2142
- // "closePosition": false,
2143
- // "symbol": "BTCUSDT",
2144
- // "time": 1579276756075,
2145
- // "timeInForce": "GTC",
2146
- // "type": "TRAILING_STOP_MARKET",
2147
- // "activatePrice": "9020",
2148
- // "priceRate": "0.3",
2149
- // "updateTime": 1579276756075,
2150
- // "workingType": "CONTRACT_PRICE",
2151
- // "priceProtect": false
2152
- // }
2153
- // ]
2394
+ // SPOT & SWAP has similar responses
2395
+ //
2396
+ // [
2397
+ // {
2398
+ // "orderId": "17338239315",
2399
+ // "symbol": "ETHUSDT",
2400
+ // "status": "NEW",
2401
+ // "clientOrderId": "web_AD_mbhgla7k15gptmwyr_x",
2402
+ // "price": "2216.62",
2403
+ // "avgPrice": "0",
2404
+ // "origQty": "0.012",
2405
+ // "executedQty": "0",
2406
+ // "cumQuote": "0",
2407
+ // "timeInForce": "GTC",
2408
+ // "type": "LIMIT",
2409
+ // "side": "BUY",
2410
+ // "stopPrice": "0",
2411
+ // "origType": "LIMIT",
2412
+ // "time": "1776798208476",
2413
+ // "updateTime": "1776798208450",
2414
+ // "orderListId": "-1" // only in SPOT
2415
+ // "reduceOnly": false, // only in PERP
2416
+ // "closePosition": false, // only in PERP
2417
+ // "positionSide": "BOTH", // only in PERP
2418
+ // "workingType": "CONTRACT_PRICE", // only in PERP
2419
+ // "priceProtect": false, // only in PERP
2420
+ // "newChainData": { "hash": "0xf8a496....a7fd5" } // only in PERP
2421
+ // }
2422
+ // ]
2154
2423
  //
2155
2424
  return this.parseOrders(response, market, since, limit);
2156
2425
  }
@@ -2158,8 +2427,8 @@ export default class aster extends Exchange {
2158
2427
  * @method
2159
2428
  * @name aster#createOrder
2160
2429
  * @description create a trade order
2161
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#place-order-trade
2162
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#new-order--trade
2430
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#place-order-trade
2431
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#new-order-trade
2163
2432
  * @param {string} symbol unified symbol of the market to create an order in
2164
2433
  * @param {string} type 'market' or 'limit' or 'STOP' or 'STOP_MARKET' or 'TAKE_PROFIT' or 'TAKE_PROFIT_MARKET' or 'TRAILING_STOP_MARKET'
2165
2434
  * @param {string} side 'buy' or 'sell'
@@ -2177,36 +2446,59 @@ export default class aster extends Exchange {
2177
2446
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2178
2447
  */
2179
2448
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2180
- await this.loadMarkets();
2449
+ await this.loadMarketsAndSignIn();
2181
2450
  const market = this.market(symbol);
2182
- const test = this.safeBool(params, 'test', false);
2183
- params = this.omit(params, 'test');
2184
2451
  const request = this.createOrderRequest(symbol, type, side, amount, price, params);
2185
2452
  let response = undefined;
2186
2453
  if (market['swap']) {
2187
- if (test) {
2188
- response = await this.fapiPrivatePostV1OrderTest(request);
2189
- }
2190
- else {
2191
- response = await this.fapiPrivatePostV1Order(request);
2192
- }
2454
+ response = await this.fapiPrivatePostV3Order(request);
2193
2455
  }
2194
2456
  else {
2195
- response = await this.sapiPrivatePostV1Order(request);
2457
+ response = await this.sapiPrivatePostV3Order(request);
2196
2458
  }
2459
+ //
2460
+ // SPOT & SWAP has similar responses
2461
+ //
2462
+ // {
2463
+ // "orderId": "17338441758",
2464
+ // "symbol": "ETHUSDT",
2465
+ // "status": "NEW",
2466
+ // "clientOrderId": "727Wt3TIUgkUCxXp20E543",
2467
+ // "price": "0",
2468
+ // "avgPrice": "0.00000",
2469
+ // "origQty": "0.010",
2470
+ // "executedQty": "0",
2471
+ // "cumQty": "0",
2472
+ // "cumQuote": "0",
2473
+ // "timeInForce": "GTC",
2474
+ // "type": "MARKET",
2475
+ // "side": "BUY",
2476
+ // "stopPrice": "0",
2477
+ // "origType": "MARKET",
2478
+ // "time": "1776800300700",
2479
+ // "updateTime": "1776800300700",
2480
+ // "orderListId": "-1", // only in SPOT
2481
+ // "workingType": "CONTRACT_PRICE", // only in PERP
2482
+ // "positionSide": "BOTH", // only in PERP
2483
+ // "reduceOnly": false, // only in PERP
2484
+ // "closePosition": false, // only in PERP
2485
+ // "priceProtect": false, // only in PERP
2486
+ // "newChainData": { "hash": "0x46ae....c8ba" } // only in PERP
2487
+ // }
2488
+ //
2197
2489
  return this.parseOrder(response, market);
2198
2490
  }
2199
2491
  /**
2200
2492
  * @method
2201
2493
  * @name aster#createOrders
2202
2494
  * @description create a list of trade orders
2203
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#place-multiple-orders--trade
2495
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#new-order-trade
2204
2496
  * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2205
2497
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2206
2498
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2207
2499
  */
2208
2500
  async createOrders(orders, params = {}) {
2209
- await this.loadMarkets();
2501
+ await this.loadMarketsAndSignIn();
2210
2502
  const ordersRequests = [];
2211
2503
  let orderSymbols = [];
2212
2504
  if (orders.length > 5) {
@@ -2215,6 +2507,8 @@ export default class aster extends Exchange {
2215
2507
  for (let i = 0; i < orders.length; i++) {
2216
2508
  const rawOrder = orders[i];
2217
2509
  const marketId = this.safeString(rawOrder, 'symbol');
2510
+ const currentMarket = this.market(marketId);
2511
+ orderSymbols.push(currentMarket['symbol']);
2218
2512
  const type = this.safeString(rawOrder, 'type');
2219
2513
  const side = this.safeString(rawOrder, 'side');
2220
2514
  const amount = this.safeValue(rawOrder, 'amount');
@@ -2231,7 +2525,37 @@ export default class aster extends Exchange {
2231
2525
  const request = {
2232
2526
  'batchOrders': ordersRequests,
2233
2527
  };
2234
- const response = await this.fapiPrivatePostV1BatchOrders(this.extend(request, params));
2528
+ const response = await this.fapiPrivatePostV3BatchOrders(this.extend(request, params));
2529
+ //
2530
+ // [
2531
+ // {
2532
+ // "orderId": 17338699853,
2533
+ // "symbol": "ETHUSDT",
2534
+ // "status": "NEW",
2535
+ // "clientOrderId": "NxMWPvOEyiF6TWh5UB8BQf0",
2536
+ // "price": "0",
2537
+ // "avgPrice": "0.00000",
2538
+ // "origQty": "0.010",
2539
+ // "executedQty": "0",
2540
+ // "cumQty": "0",
2541
+ // "cumQuote": "0",
2542
+ // "timeInForce": "GTC",
2543
+ // "type": "MARKET",
2544
+ // "reduceOnly": false,
2545
+ // "closePosition": false,
2546
+ // "side": "BUY",
2547
+ // "positionSide": "BOTH",
2548
+ // "stopPrice": "0",
2549
+ // "workingType": "CONTRACT_PRICE",
2550
+ // "priceProtect": false,
2551
+ // "origType": "MARKET",
2552
+ // "updateTime": 1776802276050,
2553
+ // "newChainData": {
2554
+ // "hash": "0x5e569d9794cf726f72c2d000d401d20315e78e4df7b58023a489864624527dfe"
2555
+ // }
2556
+ // }
2557
+ // ]
2558
+ //
2235
2559
  return this.parseOrders(response);
2236
2560
  }
2237
2561
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
@@ -2406,14 +2730,18 @@ export default class aster extends Exchange {
2406
2730
  request['timeInForce'] = this.safeString(this.options, 'defaultTimeInForce'); // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
2407
2731
  }
2408
2732
  const requestParams = this.omit(params, ['newClientOrderId', 'clientOrderId', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'trailingDelta', 'stopPrice', 'stopLossPrice', 'takeProfitPrice']);
2733
+ if (this.safeBool(this.options, 'builderFee') && market['swap']) {
2734
+ request['builder'] = this.safeString(this.options, 'builder');
2735
+ request['feeRate'] = this.safeString(this.options, 'builderRate');
2736
+ }
2409
2737
  return this.extend(request, requestParams);
2410
2738
  }
2411
2739
  /**
2412
2740
  * @method
2413
2741
  * @name aster#cancelAllOrders
2414
2742
  * @description cancel all open orders in a market
2415
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#cancel-all-open-orders-trade
2416
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#cancel-all-open-orders-trade
2743
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#cancel-all-open-orders-trade
2744
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#current-all-open-orders-user_data
2417
2745
  * @param {string} symbol unified market symbol of the market to cancel orders in
2418
2746
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2419
2747
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -2422,19 +2750,21 @@ export default class aster extends Exchange {
2422
2750
  if (symbol === undefined) {
2423
2751
  throw new ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
2424
2752
  }
2425
- await this.loadMarkets();
2753
+ await this.loadMarketsAndSignIn();
2426
2754
  const market = this.market(symbol);
2427
2755
  const request = {
2428
2756
  'symbol': market['id'],
2429
2757
  };
2430
2758
  let response = undefined;
2431
2759
  if (market['swap']) {
2432
- response = await this.fapiPrivateDeleteV1AllOpenOrders(this.extend(request, params));
2760
+ response = await this.fapiPrivateDeleteV3AllOpenOrders(this.extend(request, params));
2433
2761
  }
2434
2762
  else {
2435
- response = await this.sapiPrivateDeleteV1AllOpenOrders(this.extend(request, params));
2763
+ response = await this.sapiPrivateDeleteV3AllOpenOrders(this.extend(request, params));
2436
2764
  }
2437
2765
  //
2766
+ // SPOT & SWAP has same response
2767
+ //
2438
2768
  // {
2439
2769
  // "code": "200",
2440
2770
  // "msg": "The operation of cancel all open order is done."
@@ -2450,8 +2780,8 @@ export default class aster extends Exchange {
2450
2780
  * @method
2451
2781
  * @name aster#cancelOrder
2452
2782
  * @description cancels an open order
2453
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#cancel-order-trade
2454
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#cancel-order-trade
2783
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#cancel-order-trade
2784
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#cancel-order-trade
2455
2785
  * @param {string} id order id
2456
2786
  * @param {string} symbol unified symbol of the market the order was made in
2457
2787
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2461,25 +2791,25 @@ export default class aster extends Exchange {
2461
2791
  if (symbol === undefined) {
2462
2792
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
2463
2793
  }
2464
- await this.loadMarkets();
2794
+ await this.loadMarketsAndSignIn();
2465
2795
  const market = this.market(symbol);
2466
2796
  const request = {
2467
2797
  'symbol': market['id'],
2468
2798
  };
2469
- const clientOrderId = this.safeStringN(params, ['origClientOrderId', 'clientOrderId', 'newClientStrategyId']);
2799
+ const clientOrderId = this.safeStringN(params, ['origClientOrderId', 'clientOrderId']);
2470
2800
  if (clientOrderId !== undefined) {
2471
2801
  request['origClientOrderId'] = clientOrderId;
2472
2802
  }
2473
2803
  else {
2474
2804
  request['orderId'] = id;
2475
2805
  }
2476
- params = this.omit(params, ['origClientOrderId', 'clientOrderId', 'newClientStrategyId']);
2806
+ params = this.omit(params, ['origClientOrderId', 'clientOrderId']);
2477
2807
  let response = undefined;
2478
2808
  if (market['swap']) {
2479
- response = await this.fapiPrivateDeleteV1Order(this.extend(request, params));
2809
+ response = await this.fapiPrivateDeleteV3Order(this.extend(request, params));
2480
2810
  }
2481
2811
  else {
2482
- response = await this.sapiPrivateDeleteV1Order(this.extend(request, params));
2812
+ response = await this.sapiPrivateDeleteV3Order(this.extend(request, params));
2483
2813
  }
2484
2814
  return this.parseOrder(response, market);
2485
2815
  }
@@ -2487,7 +2817,8 @@ export default class aster extends Exchange {
2487
2817
  * @method
2488
2818
  * @name aster#cancelOrders
2489
2819
  * @description cancel multiple orders
2490
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#cancel-multiple-orders-trade
2820
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#cancel-all-open-orders-trade
2821
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#cancel-multiple-orders-trade
2491
2822
  * @param {string[]} ids order ids
2492
2823
  * @param {string} [symbol] unified market symbol
2493
2824
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2501,11 +2832,8 @@ export default class aster extends Exchange {
2501
2832
  if (symbol === undefined) {
2502
2833
  throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
2503
2834
  }
2504
- await this.loadMarkets();
2835
+ await this.loadMarketsAndSignIn();
2505
2836
  const market = this.market(symbol);
2506
- if (market['spot']) {
2507
- throw new NotSupported(this.id + ' cancelOrders() does not support ' + market['type'] + ' orders');
2508
- }
2509
2837
  const request = {
2510
2838
  'symbol': market['id'],
2511
2839
  };
@@ -2516,46 +2844,55 @@ export default class aster extends Exchange {
2516
2844
  else {
2517
2845
  request['orderIdList'] = ids;
2518
2846
  }
2519
- const response = await this.fapiPrivateDeleteV1BatchOrders(this.extend(request, params));
2520
- //
2521
- // [
2522
- // {
2523
- // "clientOrderId": "myOrder1",
2524
- // "cumQty": "0",
2525
- // "cumQuote": "0",
2526
- // "executedQty": "0",
2527
- // "orderId": 283194212,
2528
- // "origQty": "11",
2529
- // "origType": "TRAILING_STOP_MARKET",
2530
- // "price": "0",
2531
- // "reduceOnly": false,
2532
- // "side": "BUY",
2533
- // "positionSide": "SHORT",
2534
- // "status": "CANCELED",
2535
- // "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
2536
- // "closePosition": false, // if Close-All
2537
- // "symbol": "BTCUSDT",
2538
- // "timeInForce": "GTC",
2539
- // "type": "TRAILING_STOP_MARKET",
2540
- // "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
2541
- // "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
2542
- // "updateTime": 1571110484038,
2543
- // "workingType": "CONTRACT_PRICE",
2544
- // "priceProtect": false, // if conditional order trigger is protected
2545
- // },
2546
- // {
2547
- // "code": -2011,
2548
- // "msg": "Unknown order sent."
2549
- // }
2550
- // ]
2551
- //
2847
+ let response = undefined;
2848
+ if (market['swap']) {
2849
+ response = await this.fapiPrivateDeleteV3BatchOrders(this.extend(request, params));
2850
+ //
2851
+ // [
2852
+ // {
2853
+ // "clientOrderId": "myOrder1",
2854
+ // "cumQty": "0",
2855
+ // "cumQuote": "0",
2856
+ // "executedQty": "0",
2857
+ // "orderId": 283194212,
2858
+ // "origQty": "11",
2859
+ // "origType": "TRAILING_STOP_MARKET",
2860
+ // "price": "0",
2861
+ // "reduceOnly": false,
2862
+ // "side": "BUY",
2863
+ // "positionSide": "SHORT",
2864
+ // "status": "CANCELED",
2865
+ // "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
2866
+ // "closePosition": false, // if Close-All
2867
+ // "symbol": "BTCUSDT",
2868
+ // "timeInForce": "GTC",
2869
+ // "type": "TRAILING_STOP_MARKET",
2870
+ // "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
2871
+ // "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
2872
+ // "updateTime": 1571110484038,
2873
+ // "workingType": "CONTRACT_PRICE",
2874
+ // "priceProtect": false, // if conditional order trigger is protected
2875
+ // },
2876
+ // {
2877
+ // "code": -2011,
2878
+ // "msg": "Unknown order sent."
2879
+ // }
2880
+ // ]
2881
+ //
2882
+ }
2883
+ else {
2884
+ response = await this.sapiPrivateDeleteV3AllOpenOrders(this.extend(request, params));
2885
+ //
2886
+ // {"code": 200,"msg": "The operation of cancel all open order is done."}
2887
+ //
2888
+ }
2552
2889
  return this.parseOrders(response, market);
2553
2890
  }
2554
2891
  /**
2555
2892
  * @method
2556
2893
  * @name aster#setLeverage
2557
2894
  * @description set the level of leverage for a market
2558
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#change-initial-leverage-trade
2895
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#change-initial-leverage-trade
2559
2896
  * @param {float} leverage the rate of leverage
2560
2897
  * @param {string} symbol unified market symbol
2561
2898
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2568,13 +2905,13 @@ export default class aster extends Exchange {
2568
2905
  if ((leverage < 1) || (leverage > 125)) {
2569
2906
  throw new BadRequest(this.id + ' leverage should be between 1 and 125');
2570
2907
  }
2571
- await this.loadMarkets();
2908
+ await this.loadMarketsAndSignIn();
2572
2909
  const market = this.market(symbol);
2573
2910
  const request = {
2574
2911
  'symbol': market['id'],
2575
2912
  'leverage': leverage,
2576
2913
  };
2577
- const response = await this.fapiPrivatePostV1Leverage(this.extend(request, params));
2914
+ const response = await this.fapiPrivatePostV3Leverage(this.extend(request, params));
2578
2915
  //
2579
2916
  // {
2580
2917
  // "leverage": 21,
@@ -2588,14 +2925,14 @@ export default class aster extends Exchange {
2588
2925
  * @method
2589
2926
  * @name aster#fetchLeverages
2590
2927
  * @description fetch the set leverage for all markets
2591
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#position-information-v2-user_data
2928
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
2592
2929
  * @param {string[]} [symbols] a list of unified market symbols
2593
2930
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2594
2931
  * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2595
2932
  */
2596
2933
  async fetchLeverages(symbols = undefined, params = {}) {
2597
- await this.loadMarkets();
2598
- const response = await this.fapiPrivateGetV2PositionRisk(params);
2934
+ await this.loadMarketsAndSignIn();
2935
+ const response = await this.fapiPrivateGetV3PositionRisk(params);
2599
2936
  //
2600
2937
  // [
2601
2938
  // {
@@ -2667,14 +3004,14 @@ export default class aster extends Exchange {
2667
3004
  * @method
2668
3005
  * @name aster#fetchMarginModes
2669
3006
  * @description fetches margin mode of the user
2670
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#position-information-v2-user_data
3007
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
2671
3008
  * @param {string[]} symbols unified market symbols
2672
3009
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2673
3010
  * @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
2674
3011
  */
2675
3012
  async fetchMarginModes(symbols = undefined, params = {}) {
2676
- await this.loadMarkets();
2677
- const response = await this.fapiPrivateGetV2PositionRisk(params);
3013
+ await this.loadMarketsAndSignIn();
3014
+ const response = await this.fapiPrivateGetV3PositionRisk(params);
2678
3015
  //
2679
3016
  //
2680
3017
  // [
@@ -2732,7 +3069,7 @@ export default class aster extends Exchange {
2732
3069
  * @method
2733
3070
  * @name aster#fetchMarginAdjustmentHistory
2734
3071
  * @description fetches the history of margin added or reduced from contract isolated positions
2735
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#get-position-margin-change-history-trade
3072
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-position-margin-change-history-trade
2736
3073
  * @param {string} symbol unified market symbol
2737
3074
  * @param {string} [type] "add" or "reduce"
2738
3075
  * @param {int} [since] timestamp in ms of the earliest change to fetch
@@ -2742,10 +3079,10 @@ export default class aster extends Exchange {
2742
3079
  * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
2743
3080
  */
2744
3081
  async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
2745
- await this.loadMarkets();
2746
3082
  if (symbol === undefined) {
2747
3083
  throw new ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory () requires a symbol argument');
2748
3084
  }
3085
+ await this.loadMarketsAndSignIn();
2749
3086
  const market = this.market(symbol);
2750
3087
  const until = this.safeInteger(params, 'until');
2751
3088
  params = this.omit(params, 'until');
@@ -2755,16 +3092,16 @@ export default class aster extends Exchange {
2755
3092
  if (type !== undefined) {
2756
3093
  request['type'] = (type === 'add') ? 1 : 2;
2757
3094
  }
3095
+ if (limit !== undefined) {
3096
+ request['limit'] = Math.min(limit, 1000);
3097
+ }
2758
3098
  if (since !== undefined) {
2759
3099
  request['startTime'] = since;
2760
3100
  }
2761
- if (limit !== undefined) {
2762
- request['limit'] = limit;
2763
- }
2764
3101
  if (until !== undefined) {
2765
3102
  request['endTime'] = until;
2766
3103
  }
2767
- const response = await this.fapiPrivateGetV1PositionMarginHistory(this.extend(request, params));
3104
+ const response = await this.fapiPrivateGetV3PositionMarginHistory(this.extend(request, params));
2768
3105
  //
2769
3106
  // [
2770
3107
  // {
@@ -2819,7 +3156,7 @@ export default class aster extends Exchange {
2819
3156
  };
2820
3157
  }
2821
3158
  async modifyMarginHelper(symbol, amount, addOrReduce, params = {}) {
2822
- await this.loadMarkets();
3159
+ await this.loadMarketsAndSignIn();
2823
3160
  const market = this.market(symbol);
2824
3161
  amount = this.amountToPrecision(symbol, amount);
2825
3162
  const request = {
@@ -2828,7 +3165,7 @@ export default class aster extends Exchange {
2828
3165
  'amount': amount,
2829
3166
  };
2830
3167
  const code = market['quote'];
2831
- const response = await this.fapiPrivatePostV1PositionMargin(this.extend(request, params));
3168
+ const response = await this.fapiPrivatePostV3PositionMargin(this.extend(request, params));
2832
3169
  //
2833
3170
  // {
2834
3171
  // "amount": 100.0,
@@ -2837,15 +3174,13 @@ export default class aster extends Exchange {
2837
3174
  // "type": 1
2838
3175
  // }
2839
3176
  //
2840
- return this.extend(this.parseMarginModification(response, market), {
2841
- 'code': code,
2842
- });
3177
+ return this.extend(this.parseMarginModification(response, market), { 'code': code });
2843
3178
  }
2844
3179
  /**
2845
3180
  * @method
2846
3181
  * @name aster#reduceMargin
2847
3182
  * @description remove margin from a position
2848
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#modify-isolated-position-margin-trade
3183
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#modify-isolated-position-margin-trade
2849
3184
  * @param {string} symbol unified market symbol
2850
3185
  * @param {float} amount the amount of margin to remove
2851
3186
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2858,7 +3193,7 @@ export default class aster extends Exchange {
2858
3193
  * @method
2859
3194
  * @name aster#addMargin
2860
3195
  * @description add margin
2861
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#modify-isolated-position-margin-trade
3196
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#modify-isolated-position-margin-trade
2862
3197
  * @param {string} symbol unified market symbol
2863
3198
  * @param {float} amount amount of margin to add
2864
3199
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2897,7 +3232,7 @@ export default class aster extends Exchange {
2897
3232
  * @method
2898
3233
  * @name aster#fetchFundingHistory
2899
3234
  * @description fetch the history of funding payments paid and received on this account
2900
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#get-income-historyuser_data
3235
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-income-historyuser_data
2901
3236
  * @param {string} symbol unified market symbol
2902
3237
  * @param {int} [since] the earliest time in ms to fetch funding history for
2903
3238
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -2908,7 +3243,7 @@ export default class aster extends Exchange {
2908
3243
  * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
2909
3244
  */
2910
3245
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2911
- await this.loadMarkets();
3246
+ await this.loadMarketsAndSignIn();
2912
3247
  let market = undefined;
2913
3248
  let request = {
2914
3249
  'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION", "INSURANCE_CLEAR", and "MARKET_MERCHANT_RETURN_REWARD"
@@ -2924,7 +3259,7 @@ export default class aster extends Exchange {
2924
3259
  if (limit !== undefined) {
2925
3260
  request['limit'] = Math.min(limit, 1000); // max 1000
2926
3261
  }
2927
- const response = await this.fapiPrivateGetV1Income(this.extend(request, params));
3262
+ const response = await this.fapiPrivateGetV3Income(this.extend(request, params));
2928
3263
  return this.parseIncomes(response, market, since, limit);
2929
3264
  }
2930
3265
  parseLedgerEntry(item, currency = undefined) {
@@ -2988,7 +3323,7 @@ export default class aster extends Exchange {
2988
3323
  * @method
2989
3324
  * @name aster#fetchLedger
2990
3325
  * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2991
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#get-income-historyuser_data
3326
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-income-historyuser_data
2992
3327
  * @param {string} [code] unified currency code
2993
3328
  * @param {int} [since] timestamp in ms of the earliest ledger entry
2994
3329
  * @param {int} [limit] max number of ledger entries to return
@@ -2997,7 +3332,7 @@ export default class aster extends Exchange {
2997
3332
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
2998
3333
  */
2999
3334
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
3000
- await this.loadMarkets();
3335
+ await this.loadMarketsAndSignIn();
3001
3336
  let currency = undefined;
3002
3337
  if (code !== undefined) {
3003
3338
  currency = this.currency(code);
@@ -3014,7 +3349,7 @@ export default class aster extends Exchange {
3014
3349
  params = this.omit(params, 'until');
3015
3350
  request['endTime'] = until;
3016
3351
  }
3017
- const response = await this.fapiPrivateGetV1Income(this.extend(request, params));
3352
+ const response = await this.fapiPrivateGetV3Income(this.extend(request, params));
3018
3353
  //
3019
3354
  // [
3020
3355
  // {
@@ -3210,7 +3545,7 @@ export default class aster extends Exchange {
3210
3545
  * @method
3211
3546
  * @name aster#fetchPositionsRisk
3212
3547
  * @description fetch positions risk
3213
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#position-information-v2-user_data
3548
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
3214
3549
  * @param {string[]|undefined} symbols list of unified market symbols
3215
3550
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3216
3551
  * @returns {object} data on the positions risk
@@ -3221,10 +3556,10 @@ export default class aster extends Exchange {
3221
3556
  throw new ArgumentsRequired(this.id + ' fetchPositionsRisk() requires an array argument for symbols');
3222
3557
  }
3223
3558
  }
3224
- await this.loadMarkets();
3559
+ await this.loadMarketsAndSignIn();
3225
3560
  await this.loadLeverageBrackets(false, params);
3226
3561
  const request = {};
3227
- const response = await this.fapiPrivateGetV2PositionRisk(this.extend(request, params));
3562
+ const response = await this.fapiPrivateGetV3PositionRisk(this.extend(request, params));
3228
3563
  //
3229
3564
  // [
3230
3565
  // {
@@ -3259,7 +3594,7 @@ export default class aster extends Exchange {
3259
3594
  * @method
3260
3595
  * @name aster#fetchPositions
3261
3596
  * @description fetch all open positions
3262
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#position-information-v2-user_data
3597
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
3263
3598
  * @param {string[]} [symbols] list of unified market symbols
3264
3599
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3265
3600
  * @param {string} [params.method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
@@ -3496,7 +3831,7 @@ export default class aster extends Exchange {
3496
3831
  * @name aster#fetchAccountPositions
3497
3832
  * @ignore
3498
3833
  * @description fetch account positions
3499
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#position-information-v2-user_data
3834
+ https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
3500
3835
  * @param {string[]} [symbols] list of unified market symbols
3501
3836
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3502
3837
  * @returns {object} data on account positions
@@ -3507,7 +3842,7 @@ export default class aster extends Exchange {
3507
3842
  throw new ArgumentsRequired(this.id + ' fetchPositions() requires an array argument for symbols');
3508
3843
  }
3509
3844
  }
3510
- await this.loadMarkets();
3845
+ await this.loadMarketsAndSignIn();
3511
3846
  await this.loadLeverageBrackets(false, params);
3512
3847
  const response = await this.fapiPrivateGetV4Account(params);
3513
3848
  let filterClosed = undefined;
@@ -3517,12 +3852,35 @@ export default class aster extends Exchange {
3517
3852
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
3518
3853
  }
3519
3854
  async loadLeverageBrackets(reload = false, params = {}) {
3520
- await this.loadMarkets();
3855
+ await this.loadMarketsAndSignIn();
3521
3856
  // by default cache the leverage bracket
3522
3857
  // it contains useful stuff like the maintenance margin and initial margin for positions
3523
3858
  const leverageBrackets = this.safeDict(this.options, 'leverageBrackets');
3524
3859
  if ((leverageBrackets === undefined) || (reload)) {
3525
- const response = await this.fapiPrivateGetV1LeverageBracket(params);
3860
+ const response = await this.fapiPrivateGetV3LeverageBracket(params);
3861
+ //
3862
+ // [
3863
+ // {
3864
+ // "symbol": "TRUTHUSDT",
3865
+ // "brackets": [
3866
+ // {
3867
+ // "bracket": "1",
3868
+ // "initialLeverage": "50",
3869
+ // "notionalCap": "5000",
3870
+ // "notionalFloor": "0",
3871
+ // "maintMarginRatio": "0.01",
3872
+ // "cum": "0.0"
3873
+ // },
3874
+ // {
3875
+ // "bracket": "2",
3876
+ // "initialLeverage": "20",
3877
+ // "notionalCap": "10000",
3878
+ // "notionalFloor": "5000",
3879
+ // "maintMarginRatio": "0.025",
3880
+ // "cum": "75.0"
3881
+ // },
3882
+ // ...
3883
+ //
3526
3884
  this.options['leverageBrackets'] = this.createSafeDictionary();
3527
3885
  for (let i = 0; i < response.length; i++) {
3528
3886
  const entry = response[i];
@@ -3548,12 +3906,11 @@ export default class aster extends Exchange {
3548
3906
  return this.signHash(this.keccakMessage(message), privateKey.slice(-64));
3549
3907
  }
3550
3908
  signWithdrawPayload(withdrawPayload, network) {
3551
- const zeroAddress = this.safeString(this.options, 'zeroAddress');
3552
3909
  const chainId = this.safeInteger(withdrawPayload, 'chainId');
3553
3910
  const domain = {
3554
3911
  'chainId': chainId,
3555
3912
  'name': 'Aster',
3556
- 'verifyingContract': zeroAddress,
3913
+ 'verifyingContract': this.safeString(this.options, 'zeroAddress'),
3557
3914
  'version': '1',
3558
3915
  };
3559
3916
  const messageTypes = {
@@ -3568,17 +3925,17 @@ export default class aster extends Exchange {
3568
3925
  { 'name': 'aster chain', 'type': 'string' },
3569
3926
  ],
3570
3927
  };
3571
- const withdraw = {
3928
+ const request = {
3572
3929
  'type': 'Withdraw',
3573
3930
  'destination': this.safeString(withdrawPayload, 'receiver'),
3574
3931
  'destination Chain': network,
3575
3932
  'token': this.safeString(withdrawPayload, 'asset'),
3576
3933
  'amount': this.safeString(withdrawPayload, 'amount'),
3577
3934
  'fee': this.safeString(withdrawPayload, 'fee'),
3578
- 'nonce': this.safeInteger(withdrawPayload, 'nonce'),
3935
+ 'nonce': this.safeInteger(withdrawPayload, 'userNonce'),
3579
3936
  'aster chain': 'Mainnet',
3580
3937
  };
3581
- const msg = this.ethEncodeStructuredData(domain, messageTypes, withdraw);
3938
+ const msg = this.ethEncodeStructuredData(domain, messageTypes, request);
3582
3939
  const signature = this.signMessage(msg, this.privateKey);
3583
3940
  return signature;
3584
3941
  }
@@ -3586,7 +3943,9 @@ export default class aster extends Exchange {
3586
3943
  * @method
3587
3944
  * @name aster#withdraw
3588
3945
  * @description make a withdrawal
3589
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#withdraw-user_data
3946
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#withdraw-user_data
3947
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/deposit%26withdrawal/#withdraw-by-fapiv3-evm-futures
3948
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/deposit%26withdrawal/#withdraw-by-fapiv3-evm-spot
3590
3949
  * @param {string} code unified currency code
3591
3950
  * @param {float} amount the amount to withdraw
3592
3951
  * @param {string} address the address to withdraw to
@@ -3597,12 +3956,13 @@ export default class aster extends Exchange {
3597
3956
  async withdraw(code, amount, address, tag = undefined, params = {}) {
3598
3957
  [tag, params] = this.handleWithdrawTagAndParams(tag, params);
3599
3958
  this.checkAddress(address);
3600
- await this.loadMarkets();
3959
+ await this.loadMarketsAndSignIn();
3601
3960
  const currency = this.currency(code);
3961
+ const nonce = this.milliseconds() * 1000;
3602
3962
  const request = {
3603
3963
  'asset': currency['id'],
3604
3964
  'receiver': address,
3605
- 'nonce': this.milliseconds() * 1000,
3965
+ 'userNonce': nonce.toString(),
3606
3966
  };
3607
3967
  let chainId = this.safeInteger(params, 'chainId');
3608
3968
  // TODO: check how ARBI signature would work
@@ -3625,23 +3985,32 @@ export default class aster extends Exchange {
3625
3985
  params = this.omit(params, ['chainId', 'network', 'fee']);
3626
3986
  request['amount'] = this.currencyToPrecision(code, amount, network);
3627
3987
  request['userSignature'] = this.signWithdrawPayload(request, network);
3628
- const response = await this.sapiPrivatePostV1AsterUserWithdraw(this.extend(request, params));
3988
+ const response = await this.sapiPrivatePostV3AsterUserWithdraw(this.extend(request, params));
3989
+ //
3990
+ // {
3991
+ // "withdrawId": "1097219372504338432",
3992
+ // "hash": "0x9e6baa3eb75d92a1164eef51a0cc97b9591930518ba3e8e5ab40ce524ba4e463"
3993
+ // }
3994
+ //
3995
+ return this.parseTransaction(response, currency);
3996
+ }
3997
+ parseTransaction(transaction, currency = undefined) {
3629
3998
  return {
3630
- 'info': response,
3631
- 'id': this.safeString(response, 'withdrawId'),
3632
- 'txid': this.safeString(response, 'hash'),
3999
+ 'info': transaction,
4000
+ 'id': this.safeString(transaction, 'withdrawId'),
4001
+ 'txid': this.safeString(transaction, 'hash'),
3633
4002
  'timestamp': undefined,
3634
4003
  'datetime': undefined,
3635
- 'network': network,
3636
- 'address': address,
3637
- 'addressTo': address,
4004
+ 'network': undefined,
4005
+ 'address': undefined,
4006
+ 'addressTo': undefined,
3638
4007
  'addressFrom': undefined,
3639
- 'tag': tag,
3640
- 'tagTo': tag,
4008
+ 'tag': undefined,
4009
+ 'tagTo': undefined,
3641
4010
  'tagFrom': undefined,
3642
4011
  'type': 'withdrawal',
3643
- 'amount': amount,
3644
- 'currency': code,
4012
+ 'amount': undefined,
4013
+ 'currency': undefined,
3645
4014
  'status': undefined,
3646
4015
  'updated': undefined,
3647
4016
  'internal': undefined,
@@ -3653,8 +4022,8 @@ export default class aster extends Exchange {
3653
4022
  * @method
3654
4023
  * @name aster#transfer
3655
4024
  * @description transfer currency internally between wallets on the same account
3656
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#transfer-asset-to-other-address-trade
3657
- * @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#transfer-between-futures-and-spot-user_data
4025
+ * @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#perp-spot-transfer-trade
4026
+ * @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#transfer-between-futures-and-spot-transfer
3658
4027
  * @param {string} code unified currency code
3659
4028
  * @param {float} amount amount to transfer
3660
4029
  * @param {string} fromAccount account to transfer from
@@ -3663,7 +4032,7 @@ export default class aster extends Exchange {
3663
4032
  * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
3664
4033
  */
3665
4034
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
3666
- await this.loadMarkets();
4035
+ await this.loadMarketsAndSignIn();
3667
4036
  const currency = this.currency(code);
3668
4037
  const request = {
3669
4038
  'asset': currency['id'],
@@ -3684,47 +4053,36 @@ export default class aster extends Exchange {
3684
4053
  else if (fromId === 'FUTURE' && toId === 'SPOT') {
3685
4054
  type = 'FUTURE_SPOT';
3686
4055
  }
3687
- let response = undefined;
3688
- if (type !== undefined) {
3689
- const defaultClientTranId = this.numberToString(this.milliseconds());
3690
- const clientTranId = this.safeString(params, 'clientTranId', defaultClientTranId);
3691
- request['kindType'] = type;
3692
- request['clientTranId'] = clientTranId;
3693
- response = await this.fapiPrivatePostV1AssetWalletTransfer(this.extend(request, params));
3694
- }
3695
- else {
3696
- // transfer asset to other address
3697
- request['toAddress'] = toAccount;
3698
- response = await this.sapiPrivatePostV1AssetSendToAddress(this.extend(request, params));
4056
+ if (type === undefined) {
4057
+ throw new ArgumentsRequired(this.id + ' transfer() requires fromAccount and toAccount parameters to be either SPOT or FUTURE');
3699
4058
  }
3700
- //
3701
- // {
3702
- // "tranId":13526853623,
3703
- // "status": "SUCCESS"
3704
- // }
3705
- //
4059
+ let response = undefined;
4060
+ const defaultClientTranId = this.numberToString(this.milliseconds());
4061
+ const clientTranId = this.safeString(params, 'clientTranId', defaultClientTranId);
4062
+ request['kindType'] = type;
4063
+ request['clientTranId'] = clientTranId;
4064
+ response = await this.sapiPrivatePostV3AssetWalletTransfer(this.extend(request, params));
4065
+ return this.parseTransfer(response, currency);
4066
+ }
4067
+ parseTransfer(transfer, currency = undefined) {
4068
+ const currencyId = this.safeString(transfer, 'code');
3706
4069
  return {
3707
- 'info': response,
3708
- 'id': this.safeString(response, 'tranId'),
3709
- 'txid': undefined,
4070
+ 'info': transfer,
4071
+ 'id': this.safeString(transfer, 'tranId'),
3710
4072
  'timestamp': undefined,
3711
4073
  'datetime': undefined,
3712
- 'network': undefined,
3713
- 'address': undefined,
3714
- 'addressTo': fromAccount,
3715
- 'addressFrom': toAccount,
3716
- 'tag': undefined,
3717
- 'tagTo': undefined,
3718
- 'tagFrom': undefined,
3719
- 'type': 'transfer',
3720
- 'amount': amount,
3721
- 'currency': code,
3722
- 'status': undefined,
3723
- 'updated': undefined,
3724
- 'internal': undefined,
3725
- 'comment': undefined,
3726
- 'fee': undefined,
4074
+ 'currency': this.safeCurrencyCode(currencyId, currency),
4075
+ 'amount': undefined,
4076
+ 'fromAccount': undefined,
4077
+ 'toAccount': undefined,
4078
+ 'status': this.parseTransferStatus(this.safeString(transfer, 'status')),
4079
+ };
4080
+ }
4081
+ parseTransferStatus(status) {
4082
+ const statuses = {
4083
+ 'SUCCESS': 'ok',
3727
4084
  };
4085
+ return this.safeString(statuses, status, status);
3728
4086
  }
3729
4087
  hashMessage(binaryMessage) {
3730
4088
  // const binaryMessage = this.encode (message);
@@ -3751,78 +4109,174 @@ export default class aster extends Exchange {
3751
4109
  }
3752
4110
  else if (api === 'fapiPrivate' || api === 'sapiPrivate') {
3753
4111
  this.checkRequiredCredentials();
3754
- headers = {
3755
- 'X-MBX-APIKEY': this.apiKey,
4112
+ const nonce = this.milliseconds() * 1000;
4113
+ // Sign using EIP-712 typed data per the AsterSignTransaction spec
4114
+ const zeroAddress = this.safeString(this.options, 'zeroAddress', '0x0000000000000000000000000000000000000000');
4115
+ const v3ChainId = this.safeInteger(this.options, 'v3ChainId', 1666);
4116
+ const signerAddress = this.safeString(this.options, 'signerAddress');
4117
+ if (signerAddress === undefined) {
4118
+ throw new ArgumentsRequired(this.id + ' requires signerAddress in options when use v3 api');
4119
+ }
4120
+ const domain = {
4121
+ 'name': 'AsterSignTransaction',
4122
+ 'version': '1',
4123
+ 'chainId': v3ChainId,
4124
+ 'verifyingContract': zeroAddress,
3756
4125
  };
3757
- const timestamp = this.milliseconds();
3758
- // Nonce is in microseconds
3759
- const nonce = this.microseconds();
3760
- const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
3761
- let extendedParams = this.extend({
3762
- 'timestamp': timestamp,
4126
+ let messageTypes = {
4127
+ 'Message': [
4128
+ { 'name': 'msg', 'type': 'string' },
4129
+ ],
4130
+ };
4131
+ // Build v3 params: original endpoint params + nonce (macroseconds) + user + signer
4132
+ // Note: timestamp and recvWindow are not used for v3; nonce replaces timestamp
4133
+ const finalParams = this.extend({
4134
+ 'nonce': nonce.toString(),
4135
+ 'user': this.walletAddress,
4136
+ 'signer': signerAddress,
3763
4137
  }, params);
3764
- if (defaultRecvWindow !== undefined) {
3765
- extendedParams['recvWindow'] = defaultRecvWindow;
3766
- }
3767
- const recvWindow = this.safeInteger(params, 'recvWindow');
3768
- if (recvWindow !== undefined) {
3769
- extendedParams['recvWindow'] = recvWindow;
3770
- }
3771
- let query = undefined;
3772
- if ((method === 'DELETE') && (path === 'v1/batchOrders')) {
3773
- const orderidlist = this.safeList(extendedParams, 'orderIdList', []);
3774
- const origclientorderidlist = this.safeList(extendedParams, 'origClientOrderIdList', []);
3775
- extendedParams = this.omit(extendedParams, ['orderIdList', 'origClientOrderIdList']);
3776
- query = this.rawencode(extendedParams);
3777
- const orderidlistLength = orderidlist.length;
3778
- const origclientorderidlistLength = origclientorderidlist.length;
3779
- if (orderidlistLength > 0) {
3780
- query = query + '&' + 'orderidlist=%5B' + orderidlist.join('%2C') + '%5D';
3781
- }
3782
- if (origclientorderidlistLength > 0) {
3783
- query = query + '&' + 'origclientorderidlist=%5B' + origclientorderidlist.join('%2C') + '%5D';
3784
- }
3785
- }
3786
- else {
3787
- query = this.rawencode(extendedParams);
3788
- }
3789
- let signature = '';
3790
- if (path.indexOf('v3') >= 0) {
3791
- const signerAddress = this.options['signerAddress'];
3792
- if (signerAddress === undefined) {
3793
- throw new ArgumentsRequired(this.id + ' requires signerAddress in options when use v3 api');
3794
- }
3795
- // the keys order matter
3796
- const keys = Object.keys(extendedParams);
3797
- const sortedKeys = this.sort(keys);
3798
- const signingPayload = {};
3799
- for (let i = 0; i < sortedKeys.length; i++) {
3800
- const key = sortedKeys[i];
3801
- signingPayload[key] = extendedParams[key].toString();
3802
- }
3803
- const signingHash = this.hashMessage(this.hash(this.ethAbiEncode([
3804
- 'string', 'address', 'address', 'uint256',
3805
- ], [this.json(signingPayload), this.walletAddress, signerAddress, nonce]), keccak, 'binary'));
3806
- signature = this.signHash(signingHash, this.privateKey);
3807
- extendedParams['user'] = this.walletAddress;
3808
- extendedParams['signer'] = signerAddress;
3809
- extendedParams['nonce'] = nonce;
3810
- query = this.rawencode(extendedParams);
4138
+ let paramString = undefined;
4139
+ let paramsToEncode = undefined;
4140
+ const isApproveBuilder = (path.indexOf('/approveBuilder') >= 0);
4141
+ if (isApproveBuilder) {
4142
+ // domain['name'] = 'Aster';
4143
+ messageTypes = {
4144
+ 'ApproveBuilder': [
4145
+ { 'name': 'Builder', 'type': 'string' },
4146
+ { 'name': 'MaxFeeRate', 'type': 'string' },
4147
+ { 'name': 'BuilderName', 'type': 'string' },
4148
+ { 'name': 'AsterChain', 'type': 'string' },
4149
+ { 'name': 'User', 'type': 'string' },
4150
+ { 'name': 'Nonce', 'type': 'uint256' },
4151
+ ],
4152
+ };
4153
+ delete finalParams['signer']; // signer is not needed for approveBuilder endpoint
4154
+ paramString = this.encodeValuesWithJson(finalParams);
4155
+ paramsToEncode = this.capitalizeKeys(finalParams);
3811
4156
  }
3812
4157
  else {
3813
- signature = this.hmac(this.encode(query), this.encode(this.secret), sha256);
4158
+ paramString = this.encodeValuesWithJson(finalParams);
4159
+ paramsToEncode = { 'msg': paramString };
3814
4160
  }
3815
- query += '&' + 'signature=' + signature;
4161
+ const encodedMessage = this.ethEncodeStructuredData(domain, messageTypes, paramsToEncode);
4162
+ const signature = this.signMessage(encodedMessage, this.privateKey);
4163
+ const queryString = paramString + '&' + 'signature=' + signature;
3816
4164
  if (method === 'GET') {
3817
- url += '?' + query;
4165
+ url += '?' + queryString;
3818
4166
  }
3819
4167
  else {
3820
- body = query;
4168
+ headers = {};
3821
4169
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
4170
+ body = queryString;
3822
4171
  }
3823
4172
  }
3824
4173
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3825
4174
  }
4175
+ encodeValuesWithJson(values) {
4176
+ let encodedString = '';
4177
+ const keys = Object.keys(values);
4178
+ for (let i = 0; i < keys.length; i++) {
4179
+ const key = keys[i];
4180
+ const value = values[key];
4181
+ const isObj = Array.isArray(value) || this.isDictionary(value);
4182
+ const valueJsonified = isObj ? this.json(value) : value.toString();
4183
+ const encoded = this.encodeURIComponent(valueJsonified);
4184
+ encodedString += key + '=' + encoded + '&';
4185
+ }
4186
+ return encodedString.slice(0, -1);
4187
+ }
4188
+ capitalizeKeys(dict) {
4189
+ const capitalized = {};
4190
+ const keys = Object.keys(dict);
4191
+ for (let i = 0; i < keys.length; i++) {
4192
+ const key = keys[i];
4193
+ const value = dict[key];
4194
+ const capitalizedKey = this.capitalize(key);
4195
+ capitalized[capitalizedKey] = value;
4196
+ }
4197
+ return capitalized;
4198
+ }
4199
+ async loadMarketsAndSignIn() {
4200
+ await Promise.all([this.loadMarkets(), this.signIn()]);
4201
+ }
4202
+ /**
4203
+ * @method
4204
+ * @name aster#signIn
4205
+ * @description sign in, must be called prior to using other authenticated methods
4206
+ * @see https://asterdex.github.io/aster-api-website/asterCode/integration-flow/
4207
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4208
+ * @returns response from exchange
4209
+ */
4210
+ async signIn(params = {}) {
4211
+ if (this.isEmptyString(this.privateKey)) {
4212
+ if (!this.isEmptyString(this.apiKey) || !this.isEmptyString(this.secret)) {
4213
+ throw new NotSupported(this.id + 'after the latest upgrade (v4.5.52), CCXT now expects the l1 private key to be provided in the credentials.');
4214
+ }
4215
+ return false;
4216
+ }
4217
+ if (this.privateKey.length > 66) {
4218
+ throw new NotSupported(this.id + ' after the latest update (v4.5.52), CCXT now expects the l1 private key to be provided in the credentials.');
4219
+ }
4220
+ await this.initializeClient(params);
4221
+ return true;
4222
+ }
4223
+ async initializeClient(params = {}) {
4224
+ const builderFee = this.safeBool(params, 'builderFee', this.safeBool(this.options, 'builderFee', true)); // we shouldn't omit here
4225
+ if (!builderFee) {
4226
+ return false; // skip if builder fee is not enabled
4227
+ }
4228
+ const approvedBuilderFee = this.safeBool(this.options, 'approvedBuilderFee', false);
4229
+ if (approvedBuilderFee) {
4230
+ return true; // skip if builder fee is already approved
4231
+ }
4232
+ const result = await this.fapiPrivateGetV3Builder();
4233
+ //
4234
+ // [
4235
+ // {
4236
+ // "userAddress": "0x35a5B33Be664B09F78b5089eb6185f71c8a7f11f",
4237
+ // "builderAddress": "0x1F5877C19e3777Cfd15F9d57253eA4aA5254Ec39",
4238
+ // "maxFeeRate": "0.001",
4239
+ // "builderName": "ccxt"
4240
+ // }
4241
+ // ]
4242
+ //
4243
+ const approvedBuilders = result;
4244
+ const length = approvedBuilders.length;
4245
+ let found = false;
4246
+ for (let i = 0; i < length; i++) {
4247
+ const builderInfo = this.safeDict(approvedBuilders, i, {});
4248
+ const builderAccountId = this.safeString(builderInfo, 'builderAddress');
4249
+ if (builderAccountId === this.safeString(this.options, 'builder')) {
4250
+ found = true;
4251
+ break;
4252
+ }
4253
+ }
4254
+ if (!found) {
4255
+ this.options['approvedBuilderFee'] = true;
4256
+ try {
4257
+ const request = {
4258
+ 'builder': this.safeString(this.options, 'builder'),
4259
+ 'builderName': this.safeString(this.options, 'builderName', 'ccxt'),
4260
+ 'maxFeeRate': this.safeString(this.options, 'builderRate'),
4261
+ 'signatureChainId': this.safeInteger(this.options, 'v3ChainId', 1666),
4262
+ 'asterChain': 'Mainnet',
4263
+ };
4264
+ const authResponse = await this.fapiPrivatePostV3ApproveBuilder(this.extend(request, params));
4265
+ //
4266
+ // {"code": 200,"msg": "success"}
4267
+ //
4268
+ const codeRes = this.safeInteger(authResponse, 'code');
4269
+ if (codeRes !== 200) {
4270
+ throw new ExchangeError('Builder authorization failed, ' + this.json(authResponse));
4271
+ }
4272
+ }
4273
+ catch (e) {
4274
+ this.options['approvedBuilderFee'] = false;
4275
+ this.options['builderFee'] = false; // disable if err
4276
+ }
4277
+ }
4278
+ return undefined; // just c#
4279
+ }
3826
4280
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3827
4281
  if (response === undefined) {
3828
4282
  return undefined; // fallback to default error handler