ccxt 4.4.95 → 4.4.97

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 (502) hide show
  1. package/README.md +18 -18
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +4 -1
  4. package/dist/cjs/src/abstract/alpaca.js +1 -1
  5. package/dist/cjs/src/abstract/apex.js +1 -1
  6. package/dist/cjs/src/abstract/ascendex.js +1 -1
  7. package/dist/cjs/src/abstract/bigone.js +1 -1
  8. package/dist/cjs/src/abstract/binance.js +1 -1
  9. package/dist/cjs/src/abstract/bingx.js +1 -1
  10. package/dist/cjs/src/abstract/bit2c.js +1 -1
  11. package/dist/cjs/src/abstract/bitbank.js +1 -1
  12. package/dist/cjs/src/abstract/bitbns.js +1 -1
  13. package/dist/cjs/src/abstract/bitfinex.js +1 -1
  14. package/dist/cjs/src/abstract/bitflyer.js +1 -1
  15. package/dist/cjs/src/abstract/bitget.js +1 -1
  16. package/dist/cjs/src/abstract/bithumb.js +1 -1
  17. package/dist/cjs/src/abstract/bitmart.js +1 -1
  18. package/dist/cjs/src/abstract/bitmex.js +1 -1
  19. package/dist/cjs/src/abstract/bitopro.js +1 -1
  20. package/dist/cjs/src/abstract/bitrue.js +1 -1
  21. package/dist/cjs/src/abstract/bitso.js +1 -1
  22. package/dist/cjs/src/abstract/bitstamp.js +1 -1
  23. package/dist/cjs/src/abstract/bitteam.js +1 -1
  24. package/dist/cjs/src/abstract/bittrade.js +1 -1
  25. package/dist/cjs/src/abstract/bitvavo.js +1 -1
  26. package/dist/cjs/src/abstract/blockchaincom.js +1 -1
  27. package/dist/cjs/src/abstract/blofin.js +1 -1
  28. package/dist/cjs/src/abstract/btcalpha.js +1 -1
  29. package/dist/cjs/src/abstract/btcbox.js +1 -1
  30. package/dist/cjs/src/abstract/btcmarkets.js +1 -1
  31. package/dist/cjs/src/abstract/btcturk.js +1 -1
  32. package/dist/cjs/src/abstract/bybit.js +1 -1
  33. package/dist/cjs/src/abstract/cex.js +1 -1
  34. package/dist/cjs/src/abstract/coinbase.js +1 -1
  35. package/dist/cjs/src/abstract/coinbaseexchange.js +1 -1
  36. package/dist/cjs/src/abstract/coinbaseinternational.js +1 -1
  37. package/dist/cjs/src/abstract/coincatch.js +1 -1
  38. package/dist/cjs/src/abstract/coincheck.js +1 -1
  39. package/dist/cjs/src/abstract/coinex.js +1 -1
  40. package/dist/cjs/src/abstract/coinmate.js +1 -1
  41. package/dist/cjs/src/abstract/coinmetro.js +1 -1
  42. package/dist/cjs/src/abstract/coinone.js +1 -1
  43. package/dist/cjs/src/abstract/coinsph.js +1 -1
  44. package/dist/cjs/src/abstract/coinspot.js +1 -1
  45. package/dist/cjs/src/abstract/cryptocom.js +1 -1
  46. package/dist/cjs/src/abstract/cryptomus.js +1 -1
  47. package/dist/cjs/src/abstract/defx.js +1 -1
  48. package/dist/cjs/src/abstract/delta.js +1 -1
  49. package/dist/cjs/src/abstract/deribit.js +1 -1
  50. package/dist/cjs/src/abstract/derive.js +1 -1
  51. package/dist/cjs/src/abstract/digifinex.js +1 -1
  52. package/dist/cjs/src/abstract/ellipx.js +1 -1
  53. package/dist/cjs/src/abstract/exmo.js +1 -1
  54. package/dist/cjs/src/abstract/foxbit.js +9 -0
  55. package/dist/cjs/src/abstract/gate.js +1 -1
  56. package/dist/cjs/src/abstract/gemini.js +1 -1
  57. package/dist/cjs/src/abstract/hashkey.js +1 -1
  58. package/dist/cjs/src/abstract/hitbtc.js +1 -1
  59. package/dist/cjs/src/abstract/hollaex.js +1 -1
  60. package/dist/cjs/src/abstract/htx.js +1 -1
  61. package/dist/cjs/src/abstract/hyperliquid.js +1 -1
  62. package/dist/cjs/src/abstract/independentreserve.js +1 -1
  63. package/dist/cjs/src/abstract/indodax.js +1 -1
  64. package/dist/cjs/src/abstract/kraken.js +1 -1
  65. package/dist/cjs/src/abstract/krakenfutures.js +1 -1
  66. package/dist/cjs/src/abstract/kucoin.js +1 -1
  67. package/dist/cjs/src/abstract/kucoinfutures.js +1 -1
  68. package/dist/cjs/src/abstract/latoken.js +1 -1
  69. package/dist/cjs/src/abstract/lbank.js +1 -1
  70. package/dist/cjs/src/abstract/luno.js +1 -1
  71. package/dist/cjs/src/abstract/mercado.js +1 -1
  72. package/dist/cjs/src/abstract/mexc.js +1 -1
  73. package/dist/cjs/src/abstract/modetrade.js +1 -1
  74. package/dist/cjs/src/abstract/ndax.js +1 -1
  75. package/dist/cjs/src/abstract/novadax.js +1 -1
  76. package/dist/cjs/src/abstract/oceanex.js +1 -1
  77. package/dist/cjs/src/abstract/okcoin.js +1 -1
  78. package/dist/cjs/src/abstract/okx.js +1 -1
  79. package/dist/cjs/src/abstract/onetrading.js +1 -1
  80. package/dist/cjs/src/abstract/oxfun.js +1 -1
  81. package/dist/cjs/src/abstract/p2b.js +1 -1
  82. package/dist/cjs/src/abstract/paradex.js +1 -1
  83. package/dist/cjs/src/abstract/paymium.js +1 -1
  84. package/dist/cjs/src/abstract/phemex.js +1 -1
  85. package/dist/cjs/src/abstract/poloniex.js +1 -1
  86. package/dist/cjs/src/abstract/probit.js +1 -1
  87. package/dist/cjs/src/abstract/timex.js +1 -1
  88. package/dist/cjs/src/abstract/tokocrypto.js +1 -1
  89. package/dist/cjs/src/abstract/tradeogre.js +1 -1
  90. package/dist/cjs/src/abstract/upbit.js +1 -1
  91. package/dist/cjs/src/abstract/vertex.js +1 -1
  92. package/dist/cjs/src/abstract/wavesexchange.js +1 -1
  93. package/dist/cjs/src/abstract/whitebit.js +1 -1
  94. package/dist/cjs/src/abstract/woo.js +1 -1
  95. package/dist/cjs/src/abstract/woofipro.js +1 -1
  96. package/dist/cjs/src/abstract/xt.js +1 -1
  97. package/dist/cjs/src/abstract/yobit.js +1 -1
  98. package/dist/cjs/src/abstract/zaif.js +1 -1
  99. package/dist/cjs/src/abstract/zonda.js +1 -1
  100. package/dist/cjs/src/alpaca.js +1 -1
  101. package/dist/cjs/src/apex.js +3 -3
  102. package/dist/cjs/src/ascendex.js +4 -4
  103. package/dist/cjs/src/base/Exchange.js +69 -17
  104. package/dist/cjs/src/base/Precise.js +6 -0
  105. package/dist/cjs/src/base/errors.js +6 -0
  106. package/dist/cjs/src/base/functions/crypto.js +1 -1
  107. package/dist/cjs/src/base/functions/encode.js +1 -1
  108. package/dist/cjs/src/base/functions/misc.js +1 -0
  109. package/dist/cjs/src/base/functions/number.js +36 -9
  110. package/dist/cjs/src/base/functions/platform.js +6 -0
  111. package/dist/cjs/src/base/functions/rsa.js +1 -0
  112. package/dist/cjs/src/base/functions/string.js +6 -0
  113. package/dist/cjs/src/base/functions/throttle.js +1 -1
  114. package/dist/cjs/src/base/functions/time.js +6 -0
  115. package/dist/cjs/src/base/functions/totp.js +1 -0
  116. package/dist/cjs/src/base/functions/type.js +6 -0
  117. package/dist/cjs/src/base/functions.js +1 -1
  118. package/dist/cjs/src/base/ws/Cache.js +6 -0
  119. package/dist/cjs/src/base/ws/Client.js +1 -0
  120. package/dist/cjs/src/base/ws/Future.js +1 -1
  121. package/dist/cjs/src/base/ws/OrderBook.js +1 -1
  122. package/dist/cjs/src/base/ws/OrderBookSide.js +6 -0
  123. package/dist/cjs/src/base/ws/WsClient.js +1 -1
  124. package/dist/cjs/src/bequant.js +1 -1
  125. package/dist/cjs/src/bigone.js +1 -1
  126. package/dist/cjs/src/binance.js +96 -35
  127. package/dist/cjs/src/binancecoinm.js +6 -2
  128. package/dist/cjs/src/binanceus.js +4 -2
  129. package/dist/cjs/src/binanceusdm.js +4 -2
  130. package/dist/cjs/src/bingx.js +2 -2
  131. package/dist/cjs/src/bit2c.js +1 -1
  132. package/dist/cjs/src/bitbank.js +1 -1
  133. package/dist/cjs/src/bitbns.js +1 -1
  134. package/dist/cjs/src/bitfinex.js +1 -1
  135. package/dist/cjs/src/bitflyer.js +1 -1
  136. package/dist/cjs/src/bitget.js +32 -144
  137. package/dist/cjs/src/bithumb.js +1 -1
  138. package/dist/cjs/src/bitmart.js +3 -3
  139. package/dist/cjs/src/bitmex.js +1 -1
  140. package/dist/cjs/src/bitopro.js +1 -1
  141. package/dist/cjs/src/bitrue.js +16 -9
  142. package/dist/cjs/src/bitso.js +1 -1
  143. package/dist/cjs/src/bitstamp.js +1 -1
  144. package/dist/cjs/src/bitteam.js +1 -1
  145. package/dist/cjs/src/bittrade.js +1 -1
  146. package/dist/cjs/src/blockchaincom.js +1 -1
  147. package/dist/cjs/src/blofin.js +1 -1
  148. package/dist/cjs/src/btcalpha.js +1 -1
  149. package/dist/cjs/src/btcbox.js +1 -1
  150. package/dist/cjs/src/btcmarkets.js +1 -1
  151. package/dist/cjs/src/btcturk.js +1 -1
  152. package/dist/cjs/src/bybit.js +17 -6
  153. package/dist/cjs/src/cex.js +1 -1
  154. package/dist/cjs/src/coinbaseadvanced.js +1 -1
  155. package/dist/cjs/src/coinbaseexchange.js +4 -2
  156. package/dist/cjs/src/coincatch.js +1 -1
  157. package/dist/cjs/src/coincheck.js +1 -1
  158. package/dist/cjs/src/coinex.js +1 -1
  159. package/dist/cjs/src/coinmate.js +1 -1
  160. package/dist/cjs/src/coinmetro.js +1 -1
  161. package/dist/cjs/src/coinone.js +1 -1
  162. package/dist/cjs/src/coinsph.js +1 -0
  163. package/dist/cjs/src/coinspot.js +37 -2
  164. package/dist/cjs/src/cryptocom.js +79 -3
  165. package/dist/cjs/src/cryptomus.js +42 -2
  166. package/dist/cjs/src/defx.js +2 -2
  167. package/dist/cjs/src/delta.js +1 -1
  168. package/dist/cjs/src/deribit.js +1 -1
  169. package/dist/cjs/src/derive.js +2 -2
  170. package/dist/cjs/src/digifinex.js +1 -1
  171. package/dist/cjs/src/ellipx.js +41 -1
  172. package/dist/cjs/src/exmo.js +2 -2
  173. package/dist/cjs/src/fmfwio.js +1 -1
  174. package/dist/cjs/src/foxbit.js +2016 -0
  175. package/dist/cjs/src/gate.js +2 -3
  176. package/dist/cjs/src/gateio.js +1 -1
  177. package/dist/cjs/src/gemini.js +1 -1
  178. package/dist/cjs/src/hashkey.js +40 -1
  179. package/dist/cjs/src/hitbtc.js +1 -0
  180. package/dist/cjs/src/hollaex.js +1 -1
  181. package/dist/cjs/src/htx.js +1 -1
  182. package/dist/cjs/src/huobi.js +1 -1
  183. package/dist/cjs/src/hyperliquid.js +45 -30
  184. package/dist/cjs/src/independentreserve.js +36 -1
  185. package/dist/cjs/src/indodax.js +35 -1
  186. package/dist/cjs/src/kraken.js +1 -1
  187. package/dist/cjs/src/krakenfutures.js +1 -1
  188. package/dist/cjs/src/kucoin.js +4 -3
  189. package/dist/cjs/src/kucoinfutures.js +4 -3
  190. package/dist/cjs/src/latoken.js +43 -1
  191. package/dist/cjs/src/lbank.js +1 -1
  192. package/dist/cjs/src/luno.js +37 -1
  193. package/dist/cjs/src/mercado.js +35 -1
  194. package/dist/cjs/src/mexc.js +32 -39
  195. package/dist/cjs/src/modetrade.js +4 -4
  196. package/dist/cjs/src/myokx.js +1 -1
  197. package/dist/cjs/src/ndax.js +1 -1
  198. package/dist/cjs/src/novadax.js +1 -1
  199. package/dist/cjs/src/oceanex.js +1 -1
  200. package/dist/cjs/src/okcoin.js +2 -2
  201. package/dist/cjs/src/okx.js +13 -4
  202. package/dist/cjs/src/okxus.js +1 -1
  203. package/dist/cjs/src/onetrading.js +2 -2
  204. package/dist/cjs/src/oxfun.js +3 -2
  205. package/dist/cjs/src/p2b.js +1 -1
  206. package/dist/cjs/src/paradex.js +3 -3
  207. package/dist/cjs/src/paymium.js +1 -1
  208. package/dist/cjs/src/phemex.js +36 -31
  209. package/dist/cjs/src/poloniex.js +1 -1
  210. package/dist/cjs/src/pro/alpaca.js +1 -1
  211. package/dist/cjs/src/pro/apex.js +1 -1
  212. package/dist/cjs/src/pro/ascendex.js +1 -1
  213. package/dist/cjs/src/pro/bequant.js +1 -1
  214. package/dist/cjs/src/pro/binancecoinm.js +4 -2
  215. package/dist/cjs/src/pro/binanceus.js +4 -2
  216. package/dist/cjs/src/pro/binanceusdm.js +4 -2
  217. package/dist/cjs/src/pro/bingx.js +1 -1
  218. package/dist/cjs/src/pro/bitfinex.js +1 -1
  219. package/dist/cjs/src/pro/bitget.js +1 -1
  220. package/dist/cjs/src/pro/bithumb.js +1 -1
  221. package/dist/cjs/src/pro/bitmart.js +1 -1
  222. package/dist/cjs/src/pro/bitmex.js +1 -1
  223. package/dist/cjs/src/pro/bitrue.js +1 -1
  224. package/dist/cjs/src/pro/bitstamp.js +1 -1
  225. package/dist/cjs/src/pro/bitvavo.js +1 -1
  226. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  227. package/dist/cjs/src/pro/blofin.js +1 -1
  228. package/dist/cjs/src/pro/bybit.js +34 -1
  229. package/dist/cjs/src/pro/cex.js +1 -1
  230. package/dist/cjs/src/pro/coinbase.js +1 -1
  231. package/dist/cjs/src/pro/coinbaseadvanced.js +1 -1
  232. package/dist/cjs/src/pro/coinbaseexchange.js +1 -1
  233. package/dist/cjs/src/pro/coinbaseinternational.js +1 -1
  234. package/dist/cjs/src/pro/coincatch.js +1 -1
  235. package/dist/cjs/src/pro/coincheck.js +1 -1
  236. package/dist/cjs/src/pro/coinex.js +1 -1
  237. package/dist/cjs/src/pro/coinone.js +1 -1
  238. package/dist/cjs/src/pro/cryptocom.js +1 -1
  239. package/dist/cjs/src/pro/defx.js +1 -1
  240. package/dist/cjs/src/pro/deribit.js +1 -1
  241. package/dist/cjs/src/pro/exmo.js +1 -1
  242. package/dist/cjs/src/pro/gate.js +1 -1
  243. package/dist/cjs/src/pro/gateio.js +1 -1
  244. package/dist/cjs/src/pro/gemini.js +1 -1
  245. package/dist/cjs/src/pro/hashkey.js +1 -1
  246. package/dist/cjs/src/pro/hitbtc.js +1 -1
  247. package/dist/cjs/src/pro/hollaex.js +1 -1
  248. package/dist/cjs/src/pro/htx.js +1 -1
  249. package/dist/cjs/src/pro/huobi.js +1 -1
  250. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  251. package/dist/cjs/src/pro/independentreserve.js +1 -1
  252. package/dist/cjs/src/pro/kraken.js +1 -1
  253. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  254. package/dist/cjs/src/pro/kucoin.js +1 -1
  255. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  256. package/dist/cjs/src/pro/lbank.js +1 -0
  257. package/dist/cjs/src/pro/luno.js +1 -1
  258. package/dist/cjs/src/pro/mexc.js +1 -1
  259. package/dist/cjs/src/pro/myokx.js +1 -1
  260. package/dist/cjs/src/pro/ndax.js +1 -1
  261. package/dist/cjs/src/pro/okcoin.js +1 -1
  262. package/dist/cjs/src/pro/okx.js +1 -1
  263. package/dist/cjs/src/pro/okxus.js +1 -1
  264. package/dist/cjs/src/pro/onetrading.js +1 -1
  265. package/dist/cjs/src/pro/oxfun.js +1 -1
  266. package/dist/cjs/src/pro/p2b.js +1 -1
  267. package/dist/cjs/src/pro/paradex.js +1 -1
  268. package/dist/cjs/src/pro/phemex.js +1 -1
  269. package/dist/cjs/src/pro/poloniex.js +1 -1
  270. package/dist/cjs/src/pro/probit.js +1 -1
  271. package/dist/cjs/src/pro/tradeogre.js +1 -1
  272. package/dist/cjs/src/pro/upbit.js +1 -1
  273. package/dist/cjs/src/pro/whitebit.js +1 -1
  274. package/dist/cjs/src/pro/xt.js +1 -1
  275. package/dist/cjs/src/probit.js +1 -1
  276. package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +6 -0
  277. package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -1
  278. package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
  279. package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
  280. package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +1 -0
  281. package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
  282. package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +1 -0
  283. package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
  284. package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
  285. package/dist/cjs/src/static_dependencies/ethers/coders/null.js +1 -0
  286. package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
  287. package/dist/cjs/src/static_dependencies/ethers/coders/string.js +1 -0
  288. package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +1 -0
  289. package/dist/cjs/src/static_dependencies/ethers/fragments.js +6 -0
  290. package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +6 -0
  291. package/dist/cjs/src/static_dependencies/ethers/index.js +1 -10
  292. package/dist/cjs/src/static_dependencies/ethers/interface.js +6 -0
  293. package/dist/cjs/src/static_dependencies/ethers/typed.js +6 -0
  294. package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +1 -13
  295. package/dist/cjs/src/static_dependencies/ethers/utils/data.js +1 -6
  296. package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +1 -9
  297. package/dist/cjs/src/static_dependencies/ethers/utils/events.js +6 -0
  298. package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
  299. package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -7
  300. package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +1 -5
  301. package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +6 -0
  302. package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +1 -8
  303. package/dist/cjs/src/static_dependencies/fflake/browser.js +1 -1
  304. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -0
  305. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +1 -0
  306. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +1 -1
  307. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
  308. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
  309. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
  310. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +1 -0
  311. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1 -1
  312. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
  313. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +1 -1
  314. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +1 -1
  315. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
  316. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1 -1
  317. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
  318. package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +6 -0
  319. package/dist/cjs/src/static_dependencies/noble-curves/_shortw_utils.js +1 -1
  320. package/dist/cjs/src/static_dependencies/noble-curves/abstract/curve.js +1 -1
  321. package/dist/cjs/src/static_dependencies/noble-curves/abstract/edwards.js +1 -1
  322. package/dist/cjs/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +1 -0
  323. package/dist/cjs/src/static_dependencies/noble-curves/abstract/modular.js +1 -1
  324. package/dist/cjs/src/static_dependencies/noble-curves/abstract/montgomery.js +1 -1
  325. package/dist/cjs/src/static_dependencies/noble-curves/abstract/poseidon.js +1 -1
  326. package/dist/cjs/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
  327. package/dist/cjs/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -1
  328. package/dist/cjs/src/static_dependencies/noble-curves/ed25519.js +1 -1
  329. package/dist/cjs/src/static_dependencies/noble-curves/p256.js +1 -1
  330. package/dist/cjs/src/static_dependencies/noble-curves/secp256k1.js +1 -1
  331. package/dist/cjs/src/static_dependencies/noble-hashes/_assert.js +6 -0
  332. package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -0
  333. package/dist/cjs/src/static_dependencies/noble-hashes/_u64.js +6 -0
  334. package/dist/cjs/src/static_dependencies/noble-hashes/crypto.js +6 -0
  335. package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -0
  336. package/dist/cjs/src/static_dependencies/noble-hashes/md5.js +1 -0
  337. package/dist/cjs/src/static_dependencies/noble-hashes/sha1.js +1 -0
  338. package/dist/cjs/src/static_dependencies/noble-hashes/sha256.js +1 -0
  339. package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -0
  340. package/dist/cjs/src/static_dependencies/noble-hashes/sha512.js +1 -0
  341. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +1 -1
  342. package/dist/cjs/src/static_dependencies/node-fetch/body.js +1 -5
  343. package/dist/cjs/src/static_dependencies/node-fetch/errors/abort-error.js +1 -0
  344. package/dist/cjs/src/static_dependencies/node-fetch/errors/base.js +6 -0
  345. package/dist/cjs/src/static_dependencies/node-fetch/errors/fetch-error.js +1 -0
  346. package/dist/cjs/src/static_dependencies/node-fetch/headers.js +1 -5
  347. package/dist/cjs/src/static_dependencies/node-fetch/index.js +1 -7
  348. package/dist/cjs/src/static_dependencies/node-fetch/request.js +1 -7
  349. package/dist/cjs/src/static_dependencies/node-fetch/response.js +1 -5
  350. package/dist/cjs/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
  351. package/dist/cjs/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
  352. package/dist/cjs/src/static_dependencies/node-fetch/utils/is.js +6 -0
  353. package/dist/cjs/src/static_dependencies/node-fetch/utils/referrer.js +1 -0
  354. package/dist/cjs/src/static_dependencies/proxies/agent-base/index.js +1 -0
  355. package/dist/cjs/src/static_dependencies/proxies/http-proxy-agent/index.js +1 -0
  356. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/index.js +1 -0
  357. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
  358. package/dist/cjs/src/static_dependencies/scure-base/index.js +6 -0
  359. package/dist/cjs/src/static_dependencies/scure-starknet/index.js +1 -1
  360. package/dist/cjs/src/static_dependencies/starknet/constants.js +1 -1
  361. package/dist/cjs/src/static_dependencies/starknet/types/calldata.js +6 -0
  362. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
  363. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
  364. package/dist/cjs/src/static_dependencies/starknet/types/lib/index.js +6 -0
  365. package/dist/cjs/src/static_dependencies/starknet/types/typedData.js +6 -0
  366. package/dist/cjs/src/static_dependencies/starknet/utils/assert.js +6 -0
  367. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +1 -1
  368. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +1 -1
  369. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +1 -1
  370. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/byteArray.js +1 -0
  371. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/cairo.js +1 -0
  372. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
  373. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
  374. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
  375. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/formatter.js +1 -0
  376. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/index.js +1 -1
  377. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/index.js +1 -0
  378. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +1 -0
  379. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
  380. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +1 -0
  381. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/requestParser.js +1 -0
  382. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/responseParser.js +1 -0
  383. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/tuple.js +1 -1
  384. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/validate.js +1 -4
  385. package/dist/cjs/src/static_dependencies/starknet/utils/encode.js +1 -0
  386. package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +1 -3
  387. package/dist/cjs/src/static_dependencies/starknet/utils/merkle.js +1 -0
  388. package/dist/cjs/src/static_dependencies/starknet/utils/num.js +1 -0
  389. package/dist/cjs/src/static_dependencies/starknet/utils/selector.js +1 -0
  390. package/dist/cjs/src/static_dependencies/starknet/utils/shortString.js +1 -0
  391. package/dist/cjs/src/static_dependencies/starknet/utils/typedData.js +1 -1
  392. package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +6 -0
  393. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +6 -0
  394. package/dist/cjs/src/timex.js +1 -0
  395. package/dist/cjs/src/tokocrypto.js +1 -1
  396. package/dist/cjs/src/tradeogre.js +1 -1
  397. package/dist/cjs/src/upbit.js +1 -1
  398. package/dist/cjs/src/vertex.js +4 -3
  399. package/dist/cjs/src/wavesexchange.js +1 -1
  400. package/dist/cjs/src/whitebit.js +1 -1
  401. package/dist/cjs/src/woo.js +9 -4
  402. package/dist/cjs/src/woofipro.js +3 -3
  403. package/dist/cjs/src/xt.js +1 -1
  404. package/dist/cjs/src/yobit.js +1 -1
  405. package/dist/cjs/src/zaif.js +1 -1
  406. package/dist/cjs/src/zonda.js +1 -1
  407. package/js/ccxt.d.ts +5 -2
  408. package/js/ccxt.js +4 -2
  409. package/js/src/abstract/binance.d.ts +3 -0
  410. package/js/src/abstract/binancecoinm.d.ts +3 -0
  411. package/js/src/abstract/binanceus.d.ts +3 -0
  412. package/js/src/abstract/binanceusdm.d.ts +3 -0
  413. package/js/src/abstract/foxbit.d.ts +29 -0
  414. package/js/src/abstract/foxbit.js +5 -0
  415. package/js/src/abstract/phemex.d.ts +1 -0
  416. package/js/src/apex.d.ts +2 -2
  417. package/js/src/apex.js +2 -2
  418. package/js/src/ascendex.d.ts +1 -1
  419. package/js/src/ascendex.js +3 -3
  420. package/js/src/base/Exchange.d.ts +20 -11
  421. package/js/src/base/Exchange.js +69 -17
  422. package/js/src/base/functions/number.js +30 -9
  423. package/js/src/binance.d.ts +1 -0
  424. package/js/src/binance.js +95 -34
  425. package/js/src/binancecoinm.js +5 -1
  426. package/js/src/binanceus.js +3 -1
  427. package/js/src/binanceusdm.js +3 -1
  428. package/js/src/bingx.js +1 -1
  429. package/js/src/bitget.js +31 -143
  430. package/js/src/bitmart.d.ts +2 -2
  431. package/js/src/bitmart.js +2 -2
  432. package/js/src/bitrue.js +15 -8
  433. package/js/src/bittrade.d.ts +1 -1
  434. package/js/src/blofin.d.ts +1 -1
  435. package/js/src/bybit.d.ts +1 -1
  436. package/js/src/bybit.js +16 -5
  437. package/js/src/coinbaseexchange.d.ts +3 -3
  438. package/js/src/coinbaseexchange.js +4 -2
  439. package/js/src/coinbaseinternational.d.ts +2 -2
  440. package/js/src/coinspot.d.ts +1 -1
  441. package/js/src/coinspot.js +36 -1
  442. package/js/src/cryptocom.d.ts +13 -2
  443. package/js/src/cryptocom.js +78 -2
  444. package/js/src/cryptomus.d.ts +1 -1
  445. package/js/src/cryptomus.js +41 -1
  446. package/js/src/defx.d.ts +2 -2
  447. package/js/src/defx.js +1 -1
  448. package/js/src/derive.d.ts +2 -2
  449. package/js/src/derive.js +1 -1
  450. package/js/src/digifinex.d.ts +1 -1
  451. package/js/src/ellipx.js +40 -0
  452. package/js/src/exmo.js +1 -1
  453. package/js/src/foxbit.d.ts +352 -0
  454. package/js/src/foxbit.js +2010 -0
  455. package/js/src/gate.js +1 -2
  456. package/js/src/hashkey.js +39 -0
  457. package/js/src/htx.d.ts +2 -2
  458. package/js/src/hyperliquid.d.ts +2 -2
  459. package/js/src/hyperliquid.js +44 -29
  460. package/js/src/independentreserve.js +35 -0
  461. package/js/src/indodax.js +34 -0
  462. package/js/src/krakenfutures.d.ts +1 -1
  463. package/js/src/kucoin.d.ts +1 -1
  464. package/js/src/kucoin.js +3 -2
  465. package/js/src/kucoinfutures.d.ts +3 -3
  466. package/js/src/kucoinfutures.js +3 -2
  467. package/js/src/latoken.js +42 -0
  468. package/js/src/luno.js +36 -0
  469. package/js/src/mercado.js +34 -0
  470. package/js/src/mexc.d.ts +1 -2
  471. package/js/src/mexc.js +31 -38
  472. package/js/src/modetrade.d.ts +2 -4
  473. package/js/src/modetrade.js +3 -3
  474. package/js/src/ndax.d.ts +1 -1
  475. package/js/src/okcoin.d.ts +1 -1
  476. package/js/src/okcoin.js +1 -1
  477. package/js/src/okx.d.ts +1 -1
  478. package/js/src/okx.js +12 -3
  479. package/js/src/onetrading.d.ts +1 -1
  480. package/js/src/onetrading.js +1 -1
  481. package/js/src/oxfun.d.ts +1 -1
  482. package/js/src/oxfun.js +2 -1
  483. package/js/src/paradex.d.ts +1 -1
  484. package/js/src/paradex.js +2 -2
  485. package/js/src/phemex.js +36 -31
  486. package/js/src/pro/binancecoinm.js +3 -1
  487. package/js/src/pro/binanceus.js +3 -1
  488. package/js/src/pro/binanceusdm.js +3 -1
  489. package/js/src/pro/bybit.d.ts +11 -1
  490. package/js/src/pro/bybit.js +33 -0
  491. package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
  492. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  493. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +1 -0
  494. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  495. package/js/src/timex.d.ts +1 -1
  496. package/js/src/vertex.d.ts +2 -2
  497. package/js/src/vertex.js +3 -2
  498. package/js/src/woo.d.ts +1 -1
  499. package/js/src/woo.js +8 -3
  500. package/js/src/woofipro.d.ts +2 -4
  501. package/js/src/woofipro.js +2 -2
  502. package/package.json +1 -2
@@ -0,0 +1,2010 @@
1
+ // ---------------------------------------------------------------------------
2
+ import { Precise } from '../ccxt.js';
3
+ import Exchange from './abstract/foxbit.js';
4
+ import { AccountSuspended, ArgumentsRequired, AuthenticationError, BadRequest, BadSymbol, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OnMaintenance, PermissionDenied, RateLimitExceeded } from './base/errors.js';
5
+ import { DECIMAL_PLACES } from './base/functions/number.js';
6
+ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
7
+ // ---------------------------------------------------------------------------
8
+ /**
9
+ * @class foxbit
10
+ * @augments Exchange
11
+ */
12
+ export default class foxbit extends Exchange {
13
+ describe() {
14
+ return this.deepExtend(super.describe(), {
15
+ 'id': 'foxbit',
16
+ 'name': 'Foxbit',
17
+ 'countries': ['pt-BR'],
18
+ // 300 requests per 10 seconds = 30 requests per second
19
+ // rateLimit = 1000 ms / 30 requests ~= 33.334
20
+ 'rateLimit': 33.334,
21
+ 'version': '1',
22
+ 'comment': 'Foxbit Exchange',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'has': {
26
+ 'CORS': true,
27
+ 'spot': true,
28
+ 'margin': undefined,
29
+ 'swap': undefined,
30
+ 'future': undefined,
31
+ 'option': undefined,
32
+ 'cancelAllOrders': true,
33
+ 'cancelOrder': true,
34
+ 'createLimitBuyOrder': true,
35
+ 'createLimitSellOrder': true,
36
+ 'createMarketBuyOrder': true,
37
+ 'createMarketSellOrder': true,
38
+ 'createOrder': true,
39
+ 'fecthOrderBook': true,
40
+ 'fetchBalance': true,
41
+ 'fetchCanceledOrders': true,
42
+ 'fetchClosedOrders': true,
43
+ 'fetchCurrencies': true,
44
+ 'fetchDepositAddress': true,
45
+ 'fetchDeposits': true,
46
+ 'fetchL2OrderBook': true,
47
+ 'fetchLedger': true,
48
+ 'fetchMarkets': true,
49
+ 'fetchMyTrades': true,
50
+ 'fetchOHLCV': true,
51
+ 'fetchOpenOrders': true,
52
+ 'fetchOrder': true,
53
+ 'fetchOrders': true,
54
+ 'fetchTicker': true,
55
+ 'fetchTickers': true,
56
+ 'fetchTrades': true,
57
+ 'fetchTradingFee': true,
58
+ 'fetchTradingFees': true,
59
+ 'fetchTransactions': true,
60
+ 'fetchWithdrawals': true,
61
+ 'loadMarkets': true,
62
+ 'sandbox': false,
63
+ 'withdraw': true,
64
+ 'ws': false,
65
+ },
66
+ 'timeframes': {
67
+ '1m': '1m',
68
+ '5m': '5m',
69
+ '15m': '15m',
70
+ '30m': '30m',
71
+ '1h': '1h',
72
+ '2h': '2h',
73
+ '4h': '4h',
74
+ '6h': '6h',
75
+ '12h': '12h',
76
+ '1d': '1d',
77
+ '1w': '1w',
78
+ '2w': '2w',
79
+ '1M': '1M',
80
+ },
81
+ 'urls': {
82
+ 'logo': 'https://github.com/user-attachments/assets/ba1435eb-1d59-4393-8de7-0db10a002fb3',
83
+ 'api': {
84
+ 'public': 'https://api.foxbit.com.br',
85
+ 'private': 'https://api.foxbit.com.br',
86
+ 'status': 'https://metadata-v2.foxbit.com.br/api',
87
+ },
88
+ 'www': 'https://app.foxbit.com.br',
89
+ 'doc': [
90
+ 'https://docs.foxbit.com.br',
91
+ ],
92
+ },
93
+ 'precisionMode': DECIMAL_PLACES,
94
+ 'exceptions': {
95
+ 'exact': {
96
+ // https://docs.foxbit.com.br/rest/v3/#tag/API-Codes/Errors
97
+ '400': BadRequest,
98
+ '429': RateLimitExceeded,
99
+ '404': BadRequest,
100
+ '500': ExchangeError,
101
+ '2001': AuthenticationError,
102
+ '2002': AuthenticationError,
103
+ '2003': AuthenticationError,
104
+ '2004': BadRequest,
105
+ '2005': PermissionDenied,
106
+ '3001': PermissionDenied,
107
+ '3002': PermissionDenied,
108
+ '3003': AccountSuspended,
109
+ '4001': BadRequest,
110
+ '4002': InsufficientFunds,
111
+ '4003': InvalidOrder,
112
+ '4004': BadSymbol,
113
+ '4005': BadRequest,
114
+ '4007': ExchangeError,
115
+ '4008': InvalidOrder,
116
+ '4009': PermissionDenied,
117
+ '4011': RateLimitExceeded,
118
+ '4012': ExchangeError,
119
+ '5001': ExchangeNotAvailable,
120
+ '5002': OnMaintenance,
121
+ '5003': OnMaintenance,
122
+ '5004': InvalidOrder,
123
+ '5005': InvalidOrder,
124
+ '5006': InvalidOrder, // Significant price deviation detected, exceeding acceptable limits. The order price is exceeding acceptable limits from market to complete your request.
125
+ },
126
+ 'broad': {
127
+ // todo: add details messages that can be usefull here, like when market is not found
128
+ },
129
+ },
130
+ 'requiredCredentials': {
131
+ 'apiKey': true,
132
+ 'secret': true,
133
+ },
134
+ 'api': {
135
+ 'v3': {
136
+ 'public': {
137
+ 'get': {
138
+ 'currencies': 5,
139
+ 'markets': 5,
140
+ 'markets/ticker/24hr': 60,
141
+ 'markets/{market}/orderbook': 6,
142
+ 'markets/{market}/candlesticks': 12,
143
+ 'markets/{market}/trades/history': 12,
144
+ 'markets/{market}/ticker/24hr': 15, // 4 requests per 2 seconds
145
+ },
146
+ },
147
+ 'private': {
148
+ 'get': {
149
+ 'accounts': 2,
150
+ 'accounts/{symbol}/transactions': 60,
151
+ 'orders': 2,
152
+ 'orders/by-order-id/{id}': 2,
153
+ 'trades': 6,
154
+ 'deposits/address': 10,
155
+ 'deposits': 10,
156
+ 'withdrawals': 10,
157
+ 'me/fees/trading': 60, // 1 requests per 2 seconds
158
+ },
159
+ 'post': {
160
+ 'orders': 2,
161
+ 'orders/batch': 7.5,
162
+ 'orders/cancel-replace': 3,
163
+ 'withdrawals': 10, // 3 requests per second
164
+ },
165
+ 'put': {
166
+ 'orders/cancel': 2, // 30 requests per 2 seconds
167
+ },
168
+ },
169
+ },
170
+ 'status': {
171
+ 'public': {
172
+ 'get': {
173
+ 'status': 30, // 1 request per second
174
+ },
175
+ },
176
+ },
177
+ },
178
+ 'fees': {
179
+ 'trading': {
180
+ 'feeSide': 'get',
181
+ 'tierBased': false,
182
+ 'percentage': true,
183
+ 'taker': this.parseNumber('0.005'),
184
+ 'maker': this.parseNumber('0.0025'),
185
+ },
186
+ },
187
+ 'options': {
188
+ 'sandboxMode': false,
189
+ 'networksById': {
190
+ 'algorand': 'ALGO',
191
+ 'arbitrum': 'ARBITRUM',
192
+ 'avalanchecchain': 'AVAX',
193
+ 'bitcoin': 'BTC',
194
+ 'bitcoincash': 'BCH',
195
+ 'bsc': 'BEP20',
196
+ 'cardano': 'ADA',
197
+ 'cosmos': 'ATOM',
198
+ 'dogecoin': 'DOGE',
199
+ 'erc20': 'ETH',
200
+ 'hedera': 'HBAR',
201
+ 'litecoin': 'LTC',
202
+ 'near': 'NEAR',
203
+ 'optimism': 'OPTIMISM',
204
+ 'polkadot': 'DOT',
205
+ 'polygon': 'MATIC',
206
+ 'ripple': 'XRP',
207
+ 'solana': 'SOL',
208
+ 'stacks': 'STX',
209
+ 'stellar': 'XLM',
210
+ 'tezos': 'XTZ',
211
+ 'trc20': 'TRC20',
212
+ },
213
+ 'networks': {
214
+ 'ALGO': 'algorand',
215
+ 'ARBITRUM': 'arbitrum',
216
+ 'AVAX': 'avalanchecchain',
217
+ 'BTC': 'bitcoin',
218
+ 'BCH': 'bitcoincash',
219
+ 'BEP20': 'bsc',
220
+ 'ADA': 'cardano',
221
+ 'ATOM': 'cosmos',
222
+ 'DOGE': 'dogecoin',
223
+ 'ETH': 'erc20',
224
+ 'HBAR': 'hedera',
225
+ 'LTC': 'litecoin',
226
+ 'NEAR': 'near',
227
+ 'OPTIMISM': 'optimism',
228
+ 'DOT': 'polkadot',
229
+ 'MATIC': 'polygon',
230
+ 'XRP': 'ripple',
231
+ 'SOL': 'solana',
232
+ 'STX': 'stacks',
233
+ 'XLM': 'stellar',
234
+ 'XTZ': 'tezos',
235
+ 'TRC20': 'trc20',
236
+ },
237
+ },
238
+ 'features': {
239
+ 'spot': {
240
+ 'sandbox': false,
241
+ 'createOrder': {
242
+ 'marginMode': false,
243
+ 'triggerPrice': true,
244
+ 'triggerPriceType': {
245
+ 'last': true,
246
+ 'mark': false,
247
+ 'index': false,
248
+ },
249
+ 'triggerDirection': false,
250
+ 'stopLossPrice': false,
251
+ 'takeProfitPrice': false,
252
+ 'attachedStopLossTakeProfit': undefined,
253
+ 'timeInForce': {
254
+ 'GTC': true,
255
+ 'FOK': true,
256
+ 'IOC': true,
257
+ 'PO': true,
258
+ 'GTD': false,
259
+ },
260
+ 'hedged': false,
261
+ 'leverage': false,
262
+ 'marketBuyByCost': false,
263
+ 'marketBuyRequiresPrice': false,
264
+ 'selfTradePrevention': {
265
+ 'expire_maker': true,
266
+ 'expire_taker': true,
267
+ 'expire_both': true,
268
+ 'none': true, // foxbit prevents self trading by default, no params can change this
269
+ },
270
+ 'trailing': false,
271
+ 'icebergAmount': false,
272
+ },
273
+ 'createOrders': {
274
+ 'max': 5,
275
+ },
276
+ 'fetchMyTrades': {
277
+ 'marginMode': false,
278
+ 'limit': 100,
279
+ 'daysBack': 90,
280
+ 'untilDays': 10000,
281
+ 'symbolRequired': true,
282
+ },
283
+ 'fetchOrder': {
284
+ 'marginMode': false,
285
+ 'limit': 1,
286
+ 'daysBack': 90,
287
+ 'trigger': false,
288
+ 'trailing': false,
289
+ 'symbolRequired': false,
290
+ },
291
+ 'fetchOpenOrders': {
292
+ 'marginMode': false,
293
+ 'limit': 100,
294
+ 'daysBack': 90,
295
+ 'trigger': false,
296
+ 'trailing': false,
297
+ 'symbolRequired': false,
298
+ },
299
+ 'fetchOrders': {
300
+ 'marginMode': true,
301
+ 'limit': 100,
302
+ 'daysBack': 90,
303
+ 'untilDays': 10000,
304
+ 'trigger': false,
305
+ 'trailing': false,
306
+ 'symbolRequired': false,
307
+ },
308
+ 'fetchClosedOrders': {
309
+ 'marginMode': true,
310
+ 'limit': 100,
311
+ 'daysBack': 90,
312
+ 'daysBackCanceled': 90,
313
+ 'untilDays': 10000,
314
+ 'trigger': false,
315
+ 'trailing': false,
316
+ 'symbolRequired': false,
317
+ },
318
+ 'fetchOHLCV': {
319
+ 'limit': 500,
320
+ },
321
+ },
322
+ },
323
+ });
324
+ }
325
+ async fetchCurrencies(params = {}) {
326
+ const response = await this.v3PublicGetCurrencies(params);
327
+ // {
328
+ // "data": [
329
+ // {
330
+ // "symbol": "btc",
331
+ // "name": "Bitcoin",
332
+ // "type": "CRYPTO",
333
+ // "precision": 8,
334
+ // "deposit_info": {
335
+ // "min_to_confirm": "1",
336
+ // "min_amount": "0.0001"
337
+ // },
338
+ // "withdraw_info": {
339
+ // "enabled": true,
340
+ // "min_amount": "0.0001",
341
+ // "fee": "0.0001"
342
+ // },
343
+ // "category": {
344
+ // "code": "cripto",
345
+ // "name": "Cripto"
346
+ // },
347
+ // "networks": [
348
+ // {
349
+ // "name": "Bitcoin",
350
+ // "code": "btc",
351
+ // "deposit_info": {
352
+ // status: "ENABLED",
353
+ // },
354
+ // "withdraw_info": {
355
+ // "status": "ENABLED",
356
+ // "fee": "0.0001",
357
+ // },
358
+ // "has_destination_tag": false
359
+ // }
360
+ // ]
361
+ // }
362
+ // ]
363
+ // }
364
+ const data = this.safeList(response, 'data', []);
365
+ const result = {};
366
+ for (let i = 0; i < data.length; i++) {
367
+ const currency = data[i];
368
+ const precision = this.safeInteger(currency, 'precision');
369
+ const currencyId = this.safeString(currency, 'symbol');
370
+ const name = this.safeString(currency, 'name');
371
+ const code = this.safeCurrencyCode(currencyId);
372
+ const depositInfo = this.safeDict(currency, 'deposit_info');
373
+ const withdrawInfo = this.safeDict(currency, 'withdraw_info');
374
+ const networks = this.safeList(currency, 'networks', []);
375
+ const type = this.safeStringLower(currency, 'type');
376
+ const parsedNetworks = {};
377
+ for (let j = 0; j < networks.length; j++) {
378
+ const network = networks[j];
379
+ const networkId = this.safeString(network, 'code');
380
+ const networkCode = this.networkIdToCode(networkId, code);
381
+ const networkWithdrawInfo = this.safeDict(network, 'withdraw_info');
382
+ const networkDepositInfo = this.safeDict(network, 'deposit_info');
383
+ const isWithdrawEnabled = this.safeString(networkWithdrawInfo, 'status') === 'ENABLED';
384
+ const isDepositEnabled = this.safeString(networkDepositInfo, 'status') === 'ENABLED';
385
+ parsedNetworks[networkCode] = {
386
+ 'info': currency,
387
+ 'id': networkId,
388
+ 'network': networkCode,
389
+ 'name': this.safeString(network, 'name'),
390
+ 'deposit': isDepositEnabled,
391
+ 'withdraw': isWithdrawEnabled,
392
+ 'active': true,
393
+ 'precision': precision,
394
+ 'fee': this.safeNumber(networkWithdrawInfo, 'fee'),
395
+ 'limits': {
396
+ 'amount': {
397
+ 'min': undefined,
398
+ 'max': undefined,
399
+ },
400
+ 'deposit': {
401
+ 'min': this.safeNumber(depositInfo, 'min_amount'),
402
+ 'max': undefined,
403
+ },
404
+ 'withdraw': {
405
+ 'min': this.safeNumber(withdrawInfo, 'min_amount'),
406
+ 'max': undefined,
407
+ },
408
+ },
409
+ };
410
+ }
411
+ if (this.safeDict(result, code) === undefined) {
412
+ result[code] = this.safeCurrencyStructure({
413
+ 'id': currencyId,
414
+ 'code': code,
415
+ 'info': currency,
416
+ 'name': name,
417
+ 'active': true,
418
+ 'type': type,
419
+ 'deposit': this.safeBool(depositInfo, 'enabled', false),
420
+ 'withdraw': this.safeBool(withdrawInfo, 'enabled', false),
421
+ 'fee': this.safeNumber(withdrawInfo, 'fee'),
422
+ 'precision': precision,
423
+ 'limits': {
424
+ 'amount': {
425
+ 'min': undefined,
426
+ 'max': undefined,
427
+ },
428
+ 'deposit': {
429
+ 'min': this.safeNumber(depositInfo, 'min_amount'),
430
+ 'max': undefined,
431
+ },
432
+ 'withdraw': {
433
+ 'min': this.safeNumber(withdrawInfo, 'min_amount'),
434
+ 'max': undefined,
435
+ },
436
+ },
437
+ 'networks': parsedNetworks,
438
+ });
439
+ }
440
+ }
441
+ return result;
442
+ }
443
+ /**
444
+ * @method
445
+ * @name foxbit#fetchMarkets
446
+ * @description Retrieves data on all markets for foxbit.
447
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_index
448
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
449
+ * @returns {object[]} an array of objects representing market data
450
+ */
451
+ async fetchMarkets(params = {}) {
452
+ const response = await this.v3PublicGetMarkets(params);
453
+ // {
454
+ // "data": [
455
+ // {
456
+ // "symbol": "btcbrl",
457
+ // "quantity_min": "0.00000236",
458
+ // "quantity_increment": "0.00000001",
459
+ // "quantity_precision": 8,
460
+ // "price_min": "0.0001",
461
+ // "price_increment": "0.0001",
462
+ // "price_precision": 4,
463
+ // "default_fees": {
464
+ // "maker": "0.001",
465
+ // "taker": "0.001"
466
+ // },
467
+ // "base": {
468
+ // "symbol": "btc",
469
+ // "name": "Bitcoin",
470
+ // "type": "CRYPTO",
471
+ // "precision": 8,
472
+ // "category": {
473
+ // "code": "cripto",
474
+ // "name": "Cripto"
475
+ // },
476
+ // "deposit_info": {
477
+ // "min_to_confirm": "1",
478
+ // "min_amount": "0.0001",
479
+ // "enabled": true
480
+ // },
481
+ // "withdraw_info": {
482
+ // "enabled": true,
483
+ // "min_amount": "0.0001",
484
+ // "fee": "0.0001"
485
+ // },
486
+ // "networks": [
487
+ // {
488
+ // "name": "Bitcoin",
489
+ // "code": "bitcoin",
490
+ // "deposit_info": {
491
+ // "status": "ENABLED"
492
+ // },
493
+ // "withdraw_info": {
494
+ // "status": "ENABLED",
495
+ // "fee": "0.0001"
496
+ // },
497
+ // "has_destination_tag": false
498
+ // }
499
+ // ],
500
+ // "default_network_code": "bitcoin"
501
+ // },
502
+ // "quote": {
503
+ // "symbol": "btc",
504
+ // "name": "Bitcoin",
505
+ // "type": "CRYPTO",
506
+ // "precision": 8,
507
+ // "category": {
508
+ // "code": "cripto",
509
+ // "name": "Cripto"
510
+ // },
511
+ // "deposit_info": {
512
+ // "min_to_confirm": "1",
513
+ // "min_amount": "0.0001",
514
+ // "enabled": true
515
+ // },
516
+ // "withdraw_info": {
517
+ // "enabled": true,
518
+ // "min_amount": "0.0001",
519
+ // "fee": "0.0001"
520
+ // },
521
+ // "networks": [
522
+ // {
523
+ // "name": "Bitcoin",
524
+ // "code": "bitcoin",
525
+ // "deposit_info": {
526
+ // "status": "ENABLED"
527
+ // },
528
+ // "withdraw_info": {
529
+ // "status": "ENABLED",
530
+ // "fee": "0.0001"
531
+ // },
532
+ // "has_destination_tag": false
533
+ // }
534
+ // ],
535
+ // "default_network_code": "bitcoin"
536
+ // },
537
+ // "order_type": [
538
+ // "LIMIT",
539
+ // "MARKET",
540
+ // "INSTANT",
541
+ // "STOP_LIMIT",
542
+ // "STOP_MARKET"
543
+ // ]
544
+ // }
545
+ // ]
546
+ // }
547
+ const markets = this.safeList(response, 'data', []);
548
+ return this.parseMarkets(markets);
549
+ }
550
+ /**
551
+ * @method
552
+ * @name foxbit#fetchTicker
553
+ * @description Get last 24 hours ticker information, in real-time, for given market.
554
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_ticker
555
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
556
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
557
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
558
+ */
559
+ async fetchTicker(symbol, params = {}) {
560
+ await this.loadMarkets();
561
+ const market = this.market(symbol);
562
+ const request = {
563
+ 'market': market['id'],
564
+ };
565
+ const response = await this.v3PublicGetMarketsMarketTicker24hr(this.extend(request, params));
566
+ // {
567
+ // "data": [
568
+ // {
569
+ // "market_symbol": "btcbrl",
570
+ // "last_trade": {
571
+ // "price": "358504.69340000",
572
+ // "volume": "0.00027893",
573
+ // "date": "2024-01-01T00:00:00.000Z"
574
+ // },
575
+ // "rolling_24h": {
576
+ // "price_change": "3211.87290000",
577
+ // "price_change_percent": "0.90400726",
578
+ // "volume": "20.03206866",
579
+ // "trades_count": "4376",
580
+ // "open": "355292.82050000",
581
+ // "high": "362999.99990000",
582
+ // "low": "355002.88880000"
583
+ // },
584
+ // "best": {
585
+ // "ask": {
586
+ // "price": "358504.69340000",
587
+ // "volume": "0.00027893"
588
+ // },
589
+ // "bid": {
590
+ // "price": "358504.69340000",
591
+ // "volume": "0.00027893"
592
+ // }
593
+ // }
594
+ // }
595
+ // ]
596
+ // }
597
+ const data = this.safeList(response, 'data', []);
598
+ const result = this.safeDict(data, 0, {});
599
+ return this.parseTicker(result, market);
600
+ }
601
+ /**
602
+ * @method
603
+ * @name foxbit#fetchTickers
604
+ * @description Retrieve the ticker data of all markets.
605
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_tickers
606
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
607
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
608
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
609
+ */
610
+ async fetchTickers(symbols = undefined, params = {}) {
611
+ await this.loadMarkets();
612
+ symbols = this.marketSymbols(symbols);
613
+ const response = await this.v3PublicGetMarketsTicker24hr(params);
614
+ // {
615
+ // "data": [
616
+ // {
617
+ // "market_symbol": "btcbrl",
618
+ // "last_trade": {
619
+ // "price": "358504.69340000",
620
+ // "volume": "0.00027893",
621
+ // "date": "2024-01-01T00:00:00.000Z"
622
+ // },
623
+ // "rolling_24h": {
624
+ // "price_change": "3211.87290000",
625
+ // "price_change_percent": "0.90400726",
626
+ // "volume": "20.03206866",
627
+ // "trades_count": "4376",
628
+ // "open": "355292.82050000",
629
+ // "high": "362999.99990000",
630
+ // "low": "355002.88880000"
631
+ // },
632
+ // }
633
+ // ]
634
+ // }
635
+ const data = this.safeList(response, 'data', []);
636
+ return this.parseTickers(data, symbols);
637
+ }
638
+ /**
639
+ * @method
640
+ * @name foxbit#fetchTradingFees
641
+ * @description fetch the trading fees for multiple markets
642
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Member-Info/operation/MembersController_listTradingFees
643
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
644
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
645
+ */
646
+ async fetchTradingFees(params = {}) {
647
+ await this.loadMarkets();
648
+ const response = await this.v3PrivateGetMeFeesTrading(params);
649
+ // [
650
+ // {
651
+ // "market_symbol": "btcbrl",
652
+ // "maker": "0.0025",
653
+ // "taker": "0.005"
654
+ // }
655
+ // ]
656
+ const data = this.safeList(response, 'data', []);
657
+ const result = {};
658
+ for (let i = 0; i < data.length; i++) {
659
+ const entry = data[i];
660
+ const marketId = this.safeString(entry, 'market_symbol');
661
+ const market = this.safeMarket(marketId);
662
+ const symbol = market['symbol'];
663
+ result[symbol] = this.parseTradingFee(entry, market);
664
+ }
665
+ return result;
666
+ }
667
+ /**
668
+ * @method
669
+ * @name foxbit#fetchOrderBook
670
+ * @description Exports a copy of the order book of a specific market.
671
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_findOrderbook
672
+ * @param {string} symbol unified symbol of the market to fetch the order book for
673
+ * @param {int} [limit] the maximum amount of order book entries to return, the maximum is 100
674
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
675
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
676
+ */
677
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
678
+ await this.loadMarkets();
679
+ const market = this.market(symbol);
680
+ const defaultLimit = 20;
681
+ const request = {
682
+ 'market': market['id'],
683
+ 'depth': (limit === undefined) ? defaultLimit : limit,
684
+ };
685
+ const response = await this.v3PublicGetMarketsMarketOrderbook(this.extend(request, params));
686
+ // {
687
+ // "sequence_id": 1234567890,
688
+ // "timestamp": 1713187921336,
689
+ // "bids": [
690
+ // [
691
+ // "3.00000000",
692
+ // "300.00000000"
693
+ // ],
694
+ // [
695
+ // "1.70000000",
696
+ // "310.00000000"
697
+ // ]
698
+ // ],
699
+ // "asks": [
700
+ // [
701
+ // "3.00000000",
702
+ // "300.00000000"
703
+ // ],
704
+ // [
705
+ // "2.00000000",
706
+ // "321.00000000"
707
+ // ]
708
+ // ]
709
+ // }
710
+ const timestamp = this.safeInteger(response, 'timestamp');
711
+ return this.parseOrderBook(response, symbol, timestamp);
712
+ }
713
+ /**
714
+ * @method
715
+ * @name foxbit#fetchTrades
716
+ * @description Retrieve the trades of a specific market.
717
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_publicTrades
718
+ * @param {string} symbol unified symbol of the market to fetch trades for
719
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
720
+ * @param {int} [limit] the maximum amount of trades to fetch
721
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
722
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
723
+ */
724
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
725
+ await this.loadMarkets();
726
+ const market = this.market(symbol);
727
+ const request = {
728
+ 'market': market['id'],
729
+ };
730
+ if (limit !== undefined) {
731
+ request['page_size'] = limit;
732
+ if (limit > 200) {
733
+ request['page_size'] = 200;
734
+ }
735
+ }
736
+ // [
737
+ // {
738
+ // "id": 1,
739
+ // "price": "329248.74700000",
740
+ // "volume": "0.00100000",
741
+ // "taker_side": "BUY",
742
+ // "created_at": "2024-01-01T00:00:00Z"
743
+ // }
744
+ // ]
745
+ const response = await this.v3PublicGetMarketsMarketTradesHistory(this.extend(request, params));
746
+ const data = this.safeList(response, 'data', []);
747
+ return this.parseTrades(data, market, since, limit);
748
+ }
749
+ /**
750
+ * @method
751
+ * @name foxbit#fetchOHLCV
752
+ * @description Fetch historical candlestick data containing the open, high, low, and close price, and the volume of a market.
753
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_findCandlesticks
754
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
755
+ * @param {string} timeframe the length of time each candle represents
756
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
757
+ * @param {int} [limit] the maximum amount of candles to fetch
758
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
759
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
760
+ */
761
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
762
+ await this.loadMarkets();
763
+ const market = this.market(symbol);
764
+ const interval = this.safeString(this.timeframes, timeframe, timeframe);
765
+ const request = {
766
+ 'market': market['id'],
767
+ 'interval': interval,
768
+ };
769
+ if (since !== undefined) {
770
+ request['start_time'] = this.iso8601(since);
771
+ }
772
+ if (limit !== undefined) {
773
+ request['limit'] = limit;
774
+ if (limit > 500) {
775
+ request['limit'] = 500;
776
+ }
777
+ }
778
+ const response = await this.v3PublicGetMarketsMarketCandlesticks(this.extend(request, params));
779
+ // [
780
+ // [
781
+ // "1692918000000", // timestamp
782
+ // "127772.05150000", // open
783
+ // "128467.99980000", // high
784
+ // "127750.01000000", // low
785
+ // "128353.99990000", // close
786
+ // "1692918060000", // close timestamp
787
+ // "0.17080431", // base volume
788
+ // "21866.35948786", // quote volume
789
+ // 66, // number of trades
790
+ // "0.12073605", // taker buy base volume
791
+ // "15466.34096391" // taker buy quote volume
792
+ // ]
793
+ // ]
794
+ return this.parseOHLCVs(response, market, interval, since, limit);
795
+ }
796
+ /**
797
+ * @method
798
+ * @name foxbit#fetchBalance
799
+ * @description Query for balance and get the amount of funds available for trading or funds locked in orders.
800
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Account/operation/AccountsController_all
801
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
802
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
803
+ */
804
+ async fetchBalance(params = {}) {
805
+ await this.loadMarkets();
806
+ const response = await this.v3PrivateGetAccounts(params);
807
+ // {
808
+ // "data": [
809
+ // {
810
+ // "currency_symbol": "btc",
811
+ // "balance": "10000.0",
812
+ // "balance_available": "9000.0",
813
+ // "balance_locked": "1000.0"
814
+ // }
815
+ // ]
816
+ // }
817
+ const accounts = this.safeList(response, 'data', []);
818
+ const result = {
819
+ 'info': response,
820
+ };
821
+ for (let i = 0; i < accounts.length; i++) {
822
+ const account = accounts[i];
823
+ const currencyId = this.safeString(account, 'currency_symbol');
824
+ const currencyCode = this.safeCurrencyCode(currencyId);
825
+ const total = this.safeString(account, 'balance');
826
+ const used = this.safeString(account, 'balance_locked');
827
+ const free = this.safeString(account, 'balance_available');
828
+ const balanceObj = {
829
+ 'free': free,
830
+ 'used': used,
831
+ 'total': total,
832
+ };
833
+ result[currencyCode] = balanceObj;
834
+ }
835
+ return this.safeBalance(result);
836
+ }
837
+ /**
838
+ * @method
839
+ * @name foxbit#fetchOpenOrders
840
+ * @description Fetch all unfilled currently open orders.
841
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders
842
+ * @param {string} symbol unified market symbol
843
+ * @param {int} [since] the earliest time in ms to fetch open orders for
844
+ * @param {int} [limit] the maximum number of open order structures to retrieve
845
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
846
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
847
+ */
848
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
849
+ return await this.fetchOrdersByStatus('ACTIVE', symbol, since, limit, params);
850
+ }
851
+ /**
852
+ * @method
853
+ * @name foxbit#fetchClosedOrders
854
+ * @description Fetch all currently closed orders.
855
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders
856
+ * @param {string} symbol unified market symbol of the market orders were made in
857
+ * @param {int} [since] the earliest time in ms to fetch orders for
858
+ * @param {int} [limit] the maximum number of order structures to retrieve
859
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
860
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
861
+ */
862
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
863
+ return await this.fetchOrdersByStatus('FILLED', symbol, since, limit, params);
864
+ }
865
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
866
+ return await this.fetchOrdersByStatus('CANCELED', symbol, since, limit, params);
867
+ }
868
+ async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
869
+ await this.loadMarkets();
870
+ let market = undefined;
871
+ const request = {
872
+ 'state': status,
873
+ };
874
+ if (symbol !== undefined) {
875
+ market = this.market(symbol);
876
+ request['market_symbol'] = market['id'];
877
+ }
878
+ if (since !== undefined) {
879
+ request['start_time'] = this.iso8601(since);
880
+ }
881
+ if (limit !== undefined) {
882
+ request['page_size'] = limit;
883
+ if (limit > 100) {
884
+ request['page_size'] = 100;
885
+ }
886
+ }
887
+ const response = await this.v3PrivateGetOrders(this.extend(request, params));
888
+ const data = this.safeList(response, 'data', []);
889
+ return this.parseOrders(data);
890
+ }
891
+ /**
892
+ * @method
893
+ * @name foxbit#createOrder
894
+ * @description Create an order with the specified characteristics
895
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_create
896
+ * @param {string} symbol unified symbol of the market to create an order in
897
+ * @param {string} type 'market', 'limit', 'stop_market', 'stop_limit', 'instant'
898
+ * @param {string} side 'buy' or 'sell'
899
+ * @param {float} amount how much you want to trade in units of the base currency
900
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
901
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
902
+ * @param {string} [params.timeInForce] "GTC", "FOK", "IOC", "PO"
903
+ * @param {float} [params.triggerPrice] The time in force for the order. One of GTC, FOK, IOC, PO. See .features or foxbit's doc to see more details.
904
+ * @param {bool} [params.postOnly] true or false whether the order is post-only
905
+ * @param {string} [params.clientOrderId] a unique identifier for the order
906
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
907
+ */
908
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
909
+ await this.loadMarkets();
910
+ const market = this.market(symbol);
911
+ type = type.toUpperCase();
912
+ if (type !== 'LIMIT' && type !== 'MARKET' && type !== 'STOP_MARKET' && type !== 'STOP_LIMIT' && type !== 'INSTANT') {
913
+ throw new InvalidOrder('Invalid order type: ' + type + '. Must be one of: limit, market, stop_market, stop_limit, instant.');
914
+ }
915
+ const timeInForce = this.safeStringUpper(params, 'timeInForce');
916
+ const postOnly = this.safeBool(params, 'postOnly', false);
917
+ const triggerPrice = this.safeNumber(params, 'triggerPrice');
918
+ const request = {
919
+ 'market_symbol': market['id'],
920
+ 'side': side.toUpperCase(),
921
+ 'type': type,
922
+ };
923
+ if (type === 'STOP_MARKET' || type === 'STOP_LIMIT') {
924
+ if (triggerPrice === undefined) {
925
+ throw new InvalidOrder('Invalid order type: ' + type + '. Must have triggerPrice.');
926
+ }
927
+ }
928
+ if (timeInForce !== undefined) {
929
+ if (timeInForce === 'PO') {
930
+ request['post_only'] = true;
931
+ }
932
+ else {
933
+ request['time_in_force'] = timeInForce;
934
+ }
935
+ }
936
+ if (postOnly) {
937
+ request['post_only'] = true;
938
+ }
939
+ if (triggerPrice !== undefined) {
940
+ request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
941
+ }
942
+ if (type === 'INSTANT') {
943
+ request['amount'] = this.priceToPrecision(symbol, amount);
944
+ }
945
+ else {
946
+ request['quantity'] = this.amountToPrecision(symbol, amount);
947
+ }
948
+ if (type === 'LIMIT' || type === 'STOP_LIMIT') {
949
+ request['price'] = this.priceToPrecision(symbol, price);
950
+ }
951
+ const clientOrderId = this.safeString(params, 'clientOrderId');
952
+ if (clientOrderId !== undefined) {
953
+ request['client_order_id'] = clientOrderId;
954
+ }
955
+ params = this.omit(params, ['timeInForce', 'postOnly', 'triggerPrice', 'clientOrderId']);
956
+ const response = await this.v3PrivatePostOrders(this.extend(request, params));
957
+ // {
958
+ // "id": 1234567890,
959
+ // "sn": "OKMAKSDHRVVREK",
960
+ // "client_order_id": "451637946501"
961
+ // }
962
+ return this.parseOrder(response, market);
963
+ }
964
+ /**
965
+ * @method
966
+ * @name foxbit#createOrders
967
+ * @description create a list of trade orders
968
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/createBatch
969
+ * @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
970
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
971
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
972
+ */
973
+ async createOrders(orders, params = {}) {
974
+ await this.loadMarkets();
975
+ const ordersRequests = [];
976
+ for (let i = 0; i < orders.length; i++) {
977
+ const order = this.safeDict(orders, i);
978
+ const symbol = this.safeString(order, 'symbol');
979
+ const market = this.market(symbol);
980
+ const type = this.safeStringUpper(order, 'type');
981
+ const orderParams = this.safeDict(order, 'params', {});
982
+ if (type !== 'LIMIT' && type !== 'MARKET' && type !== 'STOP_MARKET' && type !== 'STOP_LIMIT' && type !== 'INSTANT') {
983
+ throw new InvalidOrder('Invalid order type: ' + type + '. Must be one of: limit, market, stop_market, stop_limit, instant.');
984
+ }
985
+ const timeInForce = this.safeStringUpper(orderParams, 'timeInForce');
986
+ const postOnly = this.safeBool(orderParams, 'postOnly', false);
987
+ const triggerPrice = this.safeNumber(orderParams, 'triggerPrice');
988
+ const request = {
989
+ 'market_symbol': market['id'],
990
+ 'side': this.safeStringUpper(order, 'side'),
991
+ 'type': type,
992
+ };
993
+ if (type === 'STOP_MARKET' || type === 'STOP_LIMIT') {
994
+ if (triggerPrice === undefined) {
995
+ throw new InvalidOrder('Invalid order type: ' + type + '. Must have triggerPrice.');
996
+ }
997
+ }
998
+ if (timeInForce !== undefined) {
999
+ if (timeInForce === 'PO') {
1000
+ request['post_only'] = true;
1001
+ }
1002
+ else {
1003
+ request['time_in_force'] = timeInForce;
1004
+ }
1005
+ delete orderParams['timeInForce'];
1006
+ }
1007
+ if (postOnly) {
1008
+ request['post_only'] = true;
1009
+ delete orderParams['postOnly'];
1010
+ }
1011
+ if (triggerPrice !== undefined) {
1012
+ request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
1013
+ delete orderParams['triggerPrice'];
1014
+ }
1015
+ if (type === 'INSTANT') {
1016
+ request['amount'] = this.priceToPrecision(symbol, this.safeString(order, 'amount'));
1017
+ }
1018
+ else {
1019
+ request['quantity'] = this.amountToPrecision(symbol, this.safeString(order, 'amount'));
1020
+ }
1021
+ if (type === 'LIMIT' || type === 'STOP_LIMIT') {
1022
+ request['price'] = this.priceToPrecision(symbol, this.safeString(order, 'price'));
1023
+ }
1024
+ ordersRequests.push(this.extend(request, orderParams));
1025
+ }
1026
+ const createOrdersRequest = { 'data': ordersRequests };
1027
+ const response = await this.v3PrivatePostOrdersBatch(this.extend(createOrdersRequest, params));
1028
+ // {
1029
+ // "data": [
1030
+ // {
1031
+ // "side": "BUY",
1032
+ // "type": "LIMIT",
1033
+ // "market_symbol": "btcbrl",
1034
+ // "client_order_id": "451637946501",
1035
+ // "remark": "A remarkable note for the order.",
1036
+ // "quantity": "0.42",
1037
+ // "price": "250000.0",
1038
+ // "post_only": true,
1039
+ // "time_in_force": "GTC"
1040
+ // }
1041
+ // ]
1042
+ // }
1043
+ const data = this.safeList(response, 'data', []);
1044
+ return this.parseOrders(data);
1045
+ }
1046
+ /**
1047
+ * @method
1048
+ * @name foxbit#cancelOrder
1049
+ * @description Cancel open orders.
1050
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancel
1051
+ * @param {string} id order id
1052
+ * @param {string} symbol unified symbol of the market the order was made in
1053
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1054
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1055
+ */
1056
+ async cancelOrder(id, symbol = undefined, params = {}) {
1057
+ await this.loadMarkets();
1058
+ const request = {
1059
+ 'id': this.parseNumber(id),
1060
+ 'type': 'ID',
1061
+ };
1062
+ const response = await this.v3PrivatePutOrdersCancel(this.extend(request, params));
1063
+ // {
1064
+ // "data": [
1065
+ // {
1066
+ // "sn": "OKMAKSDHRVVREK",
1067
+ // "id": 123456789
1068
+ // }
1069
+ // ]
1070
+ // }
1071
+ const data = this.safeList(response, 'data', []);
1072
+ const result = this.safeDict(data, 0, {});
1073
+ return this.parseOrder(result);
1074
+ }
1075
+ /**
1076
+ * @method
1077
+ * @name foxbit#cancelAllOrders
1078
+ * @description Cancel all open orders or all open orders for a specific market.
1079
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancel
1080
+ * @param {string} symbol unified market symbol of the market to cancel orders in
1081
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1082
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1083
+ */
1084
+ async cancelAllOrders(symbol = undefined, params = {}) {
1085
+ await this.loadMarkets();
1086
+ const request = {
1087
+ 'type': 'ALL',
1088
+ };
1089
+ if (symbol !== undefined) {
1090
+ const market = this.market(symbol);
1091
+ request['type'] = 'MARKET';
1092
+ request['market_symbol'] = market['id'];
1093
+ }
1094
+ const response = await this.v3PrivatePutOrdersCancel(this.extend(request, params));
1095
+ // {
1096
+ // "data": [
1097
+ // {
1098
+ // "sn": "OKMAKSDHRVVREK",
1099
+ // "id": 123456789
1100
+ // }
1101
+ // ]
1102
+ // }
1103
+ return [this.safeOrder({
1104
+ 'info': response,
1105
+ })];
1106
+ }
1107
+ /**
1108
+ * @method
1109
+ * @name foxbit#fetchOrder
1110
+ * @description Get an order by ID.
1111
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_findByOrderId
1112
+ * @param id
1113
+ * @param {string} symbol it is not used in the foxbit API
1114
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1115
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1116
+ */
1117
+ async fetchOrder(id, symbol = undefined, params = {}) {
1118
+ await this.loadMarkets();
1119
+ const request = {
1120
+ 'id': id,
1121
+ };
1122
+ const response = await this.v3PrivateGetOrdersByOrderIdId(this.extend(request, params));
1123
+ // {
1124
+ // "id": "1234567890",
1125
+ // "sn": "OKMAKSDHRVVREK",
1126
+ // "client_order_id": "451637946501",
1127
+ // "market_symbol": "btcbrl",
1128
+ // "side": "BUY",
1129
+ // "type": "LIMIT",
1130
+ // "state": "ACTIVE",
1131
+ // "price": "290000.0",
1132
+ // "price_avg": "295333.3333",
1133
+ // "quantity": "0.42",
1134
+ // "quantity_executed": "0.41",
1135
+ // "instant_amount": "290.0",
1136
+ // "instant_amount_executed": "290.0",
1137
+ // "created_at": "2021-02-15T22:06:32.999Z",
1138
+ // "trades_count": "2",
1139
+ // "remark": "A remarkable note for the order.",
1140
+ // "funds_received": "290.0"
1141
+ // }
1142
+ return this.parseOrder(response, undefined);
1143
+ }
1144
+ /**
1145
+ * @method
1146
+ * @name foxbit#fetchOrders
1147
+ * @description fetches information on multiple orders made by the user
1148
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders
1149
+ * @param {string} symbol unified market symbol of the market orders were made in
1150
+ * @param {int} [since] the earliest time in ms to fetch orders for
1151
+ * @param {int} [limit] the maximum number of order structures to retrieve
1152
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1153
+ * @param {string} [params.state] Enum: ACTIVE, CANCELED, FILLED, PARTIALLY_CANCELED, PARTIALLY_FILLED
1154
+ * @param {string} [params.side] Enum: BUY, SELL
1155
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1156
+ */
1157
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1158
+ await this.loadMarkets();
1159
+ let market = undefined;
1160
+ const request = {};
1161
+ if (symbol !== undefined) {
1162
+ market = this.market(symbol);
1163
+ request['market_symbol'] = market['id'];
1164
+ }
1165
+ if (since !== undefined) {
1166
+ request['start_time'] = this.iso8601(since);
1167
+ }
1168
+ if (limit !== undefined) {
1169
+ request['page_size'] = limit;
1170
+ if (limit > 100) {
1171
+ request['page_size'] = 100;
1172
+ }
1173
+ }
1174
+ const response = await this.v3PrivateGetOrders(this.extend(request, params));
1175
+ // {
1176
+ // "data": [
1177
+ // {
1178
+ // "id": "1234567890",
1179
+ // "sn": "OKMAKSDHRVVREK",
1180
+ // "client_order_id": "451637946501",
1181
+ // "market_symbol": "btcbrl",
1182
+ // "side": "BUY",
1183
+ // "type": "LIMIT",
1184
+ // "state": "ACTIVE",
1185
+ // "price": "290000.0",
1186
+ // "price_avg": "295333.3333",
1187
+ // "quantity": "0.42",
1188
+ // "quantity_executed": "0.41",
1189
+ // "instant_amount": "290.0",
1190
+ // "instant_amount_executed": "290.0",
1191
+ // "created_at": "2021-02-15T22:06:32.999Z",
1192
+ // "trades_count": "2",
1193
+ // "remark": "A remarkable note for the order.",
1194
+ // "funds_received": "290.0"
1195
+ // }
1196
+ // ]
1197
+ // }
1198
+ const list = this.safeList(response, 'data', []);
1199
+ return this.parseOrders(list, market, since, limit);
1200
+ }
1201
+ /**
1202
+ * @method
1203
+ * @name foxbit#fetchMyTrades
1204
+ * @description Trade history queries will only have data available for the last 3 months, in descending order (most recents trades first).
1205
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/TradesController_all
1206
+ * @param {string} symbol unified market symbol
1207
+ * @param {int} [since] the earliest time in ms to fetch trades for
1208
+ * @param {int} [limit] the maximum number of trade structures to retrieve
1209
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1210
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1211
+ */
1212
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1213
+ if (symbol === undefined) {
1214
+ throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
1215
+ }
1216
+ await this.loadMarkets();
1217
+ const market = this.market(symbol);
1218
+ const request = {
1219
+ 'market_symbol': market['id'],
1220
+ };
1221
+ if (since !== undefined) {
1222
+ request['start_time'] = this.iso8601(since);
1223
+ }
1224
+ if (limit !== undefined) {
1225
+ request['page_size'] = limit;
1226
+ if (limit > 100) {
1227
+ request['page_size'] = 100;
1228
+ }
1229
+ }
1230
+ const response = await this.v3PrivateGetTrades(this.extend(request, params));
1231
+ // {
1232
+ // "data": [
1233
+ // "id": 1234567890,
1234
+ // "sn": "TC5JZVW2LLJ3IW",
1235
+ // "order_id": 1234567890,
1236
+ // "market_symbol": "btcbrl",
1237
+ // "side": "BUY",
1238
+ // "price": "290000.0",
1239
+ // "quantity": "1.0",
1240
+ // "fee": "0.01",
1241
+ // "fee_currency_symbol": "btc",
1242
+ // "created_at": "2021-02-15T22:06:32.999Z"
1243
+ // ]
1244
+ // }
1245
+ const data = this.safeList(response, 'data', []);
1246
+ return this.parseTrades(data, market, since, limit);
1247
+ }
1248
+ /**
1249
+ * @method
1250
+ * @name foxbit#fetchDepositAddress
1251
+ * @description Fetch the deposit address for a currency associated with this account.
1252
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_depositAddress
1253
+ * @param {string} code unified currency code
1254
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1255
+ * @param {string} [params.networkCode] the blockchain network to create a deposit address on
1256
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1257
+ */
1258
+ async fetchDepositAddress(code, params = {}) {
1259
+ await this.loadMarkets();
1260
+ const currency = this.currency(code);
1261
+ const request = {
1262
+ 'currency_symbol': currency['id'],
1263
+ };
1264
+ const [networkCode, paramsOmited] = this.handleNetworkCodeAndParams(params);
1265
+ if (networkCode !== undefined) {
1266
+ request['network_code'] = this.networkCodeToId(networkCode, code);
1267
+ }
1268
+ const response = await this.v3PrivateGetDepositsAddress(this.extend(request, paramsOmited));
1269
+ // {
1270
+ // "currency_symbol": "btc",
1271
+ // "address": "2N9sS8LgrY19rvcCWDmE1ou1tTVmqk4KQAB",
1272
+ // "message": "Address was retrieved successfully",
1273
+ // "destination_tag": "string",
1274
+ // "network": {
1275
+ // "name": "Bitcoin Network",
1276
+ // "code": "btc"
1277
+ // }
1278
+ // }
1279
+ return this.parseDepositAddress(response, currency);
1280
+ }
1281
+ /**
1282
+ * @method
1283
+ * @name foxbit#fetchDeposits
1284
+ * @description Fetch all deposits made to an account.
1285
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_listOrders
1286
+ * @param {string} [code] unified currency code
1287
+ * @param {int} [since] the earliest time in ms to fetch deposits for
1288
+ * @param {int} [limit] the maximum number of deposit structures to retrieve
1289
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1290
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1291
+ */
1292
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1293
+ await this.loadMarkets();
1294
+ const request = {};
1295
+ let currency = undefined;
1296
+ if (code !== undefined) {
1297
+ currency = this.currency(code);
1298
+ }
1299
+ if (limit !== undefined) {
1300
+ request['page_size'] = limit;
1301
+ if (limit > 100) {
1302
+ request['page_size'] = 100;
1303
+ }
1304
+ }
1305
+ if (since !== undefined) {
1306
+ request['start_time'] = this.iso8601(since);
1307
+ }
1308
+ const response = await this.v3PrivateGetDeposits(this.extend(request, params));
1309
+ // {
1310
+ // "data": [
1311
+ // {
1312
+ // "sn": "OKMAKSDHRVVREK",
1313
+ // "state": "ACCEPTED",
1314
+ // "currency_symbol": "btc",
1315
+ // "amount": "1.0",
1316
+ // "fee": "0.1",
1317
+ // "created_at": "2022-02-18T22:06:32.999Z",
1318
+ // "details_crypto": {
1319
+ // "transaction_id": "e20f035387020c5d5ea18ad53244f09f3",
1320
+ // "receiving_address": "2N2rTrnKEFcyJjEJqvVjgWZ3bKvKT7Aij61"
1321
+ // }
1322
+ // }
1323
+ // ]
1324
+ // }
1325
+ const data = this.safeList(response, 'data', []);
1326
+ return this.parseTransactions(data, currency, since, limit);
1327
+ }
1328
+ /**
1329
+ * @method
1330
+ * @name foxbit#fetchWithdrawals
1331
+ * @description Fetch all withdrawals made from an account.
1332
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_listWithdrawals
1333
+ * @param {string} [code] unified currency code
1334
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
1335
+ * @param {int} [limit] the maximum number of withdrawal structures to retrieve
1336
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1337
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1338
+ */
1339
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1340
+ await this.loadMarkets();
1341
+ const request = {};
1342
+ let currency = undefined;
1343
+ if (code !== undefined) {
1344
+ currency = this.currency(code);
1345
+ }
1346
+ if (limit !== undefined) {
1347
+ request['page_size'] = limit;
1348
+ if (limit > 100) {
1349
+ request['page_size'] = 100;
1350
+ }
1351
+ }
1352
+ if (since !== undefined) {
1353
+ request['start_time'] = this.iso8601(since);
1354
+ }
1355
+ const response = await this.v3PrivateGetWithdrawals(this.extend(request, params));
1356
+ // {
1357
+ // "data": [
1358
+ // {
1359
+ // "sn": "OKMAKSDHRVVREK",
1360
+ // "state": "ACCEPTED",
1361
+ // "rejection_reason": "monthly_limit_exceeded",
1362
+ // "currency_symbol": "btc",
1363
+ // "amount": "1.0",
1364
+ // "fee": "0.1",
1365
+ // "created_at": "2022-02-18T22:06:32.999Z",
1366
+ // "details_crypto": {
1367
+ // "transaction_id": "e20f035387020c5d5ea18ad53244f09f3",
1368
+ // "destination_address": "2N2rTrnKEFcyJjEJqvVjgWZ3bKvKT7Aij61"
1369
+ // },
1370
+ // "details_fiat": {
1371
+ // "bank": {
1372
+ // "code": "1",
1373
+ // "branch": {
1374
+ // "number": "1234567890",
1375
+ // "digit": "1"
1376
+ // },
1377
+ // "account": {
1378
+ // "number": "1234567890",
1379
+ // "digit": "1",
1380
+ // "type": "CHECK"
1381
+ // }
1382
+ // }
1383
+ // }
1384
+ // }
1385
+ // ]
1386
+ // }
1387
+ const data = this.safeList(response, 'data', []);
1388
+ return this.parseTransactions(data, currency, since, limit);
1389
+ }
1390
+ /**
1391
+ * @method
1392
+ * @name foxbit#fetchTransactions
1393
+ * @description Fetch all transactions (deposits and withdrawals) made from an account.
1394
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_listWithdrawals
1395
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_listOrders
1396
+ * @param {string} [code] unified currency code
1397
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
1398
+ * @param {int} [limit] the maximum number of withdrawal structures to retrieve
1399
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1400
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1401
+ */
1402
+ async fetchTransactions(code = undefined, since = undefined, limit = undefined, params = {}) {
1403
+ const withdrawals = await this.fetchWithdrawals(code, since, limit, params);
1404
+ const deposits = await this.fetchDeposits(code, since, limit, params);
1405
+ const allTransactions = this.arrayConcat(withdrawals, deposits);
1406
+ const result = this.sortBy(allTransactions, 'timestamp');
1407
+ return result;
1408
+ }
1409
+ /**
1410
+ * @method
1411
+ * @name foxbit#fetchStatus
1412
+ * @description The latest known information on the availability of the exchange API.
1413
+ * @see https://status.foxbit.com/
1414
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1415
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
1416
+ */
1417
+ async fetchStatus(params = {}) {
1418
+ const response = await this.statusPublicGetStatus(params);
1419
+ // {
1420
+ // "data": {
1421
+ // "id": 1,
1422
+ // "attributes": {
1423
+ // "status": "NORMAL",
1424
+ // "createdAt": "2023-05-17T18:37:05.934Z",
1425
+ // "updatedAt": "2024-04-17T02:33:50.945Z",
1426
+ // "publishedAt": "2023-05-17T18:37:07.653Z",
1427
+ // "locale": "pt-BR"
1428
+ // }
1429
+ // },
1430
+ // "meta": {
1431
+ // }
1432
+ // }
1433
+ const data = this.safeDict(response, 'data', {});
1434
+ const attributes = this.safeDict(data, 'attributes', {});
1435
+ const statusRaw = this.safeString(attributes, 'status');
1436
+ const statusMap = {
1437
+ 'NORMAL': 'ok',
1438
+ 'UNDER_MAINTENANCE': 'maintenance',
1439
+ };
1440
+ return {
1441
+ 'status': this.safeString(statusMap, statusRaw, statusRaw),
1442
+ 'updated': this.safeString(attributes, 'updatedAt'),
1443
+ 'eta': undefined,
1444
+ 'url': undefined,
1445
+ 'info': response,
1446
+ };
1447
+ }
1448
+ /**
1449
+ * @method
1450
+ * @name foxbit#editOrder
1451
+ * @description Simultaneously cancel an existing order and create a new one.
1452
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancelReplace
1453
+ * @param {string} id order id
1454
+ * @param {string} symbol unified symbol of the market to create an order in
1455
+ * @param {string} type 'market' or 'limit'
1456
+ * @param {string} side 'buy' or 'sell'
1457
+ * @param {float} amount how much of the currency you want to trade in units of the base currency
1458
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders, used as stop_price on stop market orders
1459
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1460
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1461
+ */
1462
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1463
+ if (symbol === undefined) {
1464
+ throw new ArgumentsRequired(this.id + ' editOrder() requires a symbol argument');
1465
+ }
1466
+ type = type.toUpperCase();
1467
+ if (type !== 'LIMIT' && type !== 'MARKET' && type !== 'STOP_MARKET' && type !== 'INSTANT') {
1468
+ throw new InvalidOrder('Invalid order type: ' + type + '. Must be one of: LIMIT, MARKET, STOP_MARKET, INSTANT.');
1469
+ }
1470
+ await this.loadMarkets();
1471
+ const market = this.market(symbol);
1472
+ const request = {
1473
+ 'mode': 'ALLOW_FAILURE',
1474
+ 'cancel': {
1475
+ 'type': 'ID',
1476
+ 'id': this.parseNumber(id),
1477
+ },
1478
+ 'create': {
1479
+ 'type': type,
1480
+ 'side': side.toUpperCase(),
1481
+ 'market_symbol': market['id'],
1482
+ },
1483
+ };
1484
+ if (type === 'LIMIT' || type === 'MARKET') {
1485
+ request['create']['quantity'] = this.amountToPrecision(symbol, amount);
1486
+ if (type === 'LIMIT') {
1487
+ request['create']['price'] = this.priceToPrecision(symbol, price);
1488
+ }
1489
+ }
1490
+ if (type === 'STOP_MARKET') {
1491
+ request['create']['stop_price'] = this.priceToPrecision(symbol, price);
1492
+ request['create']['quantity'] = this.amountToPrecision(symbol, amount);
1493
+ }
1494
+ if (type === 'INSTANT') {
1495
+ request['create']['amount'] = this.priceToPrecision(symbol, amount);
1496
+ }
1497
+ const response = await this.v3PrivatePostOrdersCancelReplace(this.extend(request, params));
1498
+ // {
1499
+ // "cancel": {
1500
+ // "id": 123456789
1501
+ // },
1502
+ // "create": {
1503
+ // "id": 1234567890,
1504
+ // "client_order_id": "451637946501"
1505
+ // }
1506
+ // }
1507
+ return this.parseOrder(response['create'], market);
1508
+ }
1509
+ /**
1510
+ * @method
1511
+ * @name foxbit#withdraw
1512
+ * @description Make a withdrawal.
1513
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_createWithdrawal
1514
+ * @param {string} code unified currency code
1515
+ * @param {float} amount the amount to withdraw
1516
+ * @param {string} address the address to withdraw to
1517
+ * @param {string} tag
1518
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1519
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1520
+ */
1521
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
1522
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
1523
+ await this.loadMarkets();
1524
+ const currency = this.currency(code);
1525
+ const request = {
1526
+ 'currency_symbol': currency['id'],
1527
+ 'amount': this.numberToString(amount),
1528
+ 'destination_address': address,
1529
+ };
1530
+ if (tag !== undefined) {
1531
+ request['destination_tag'] = tag;
1532
+ }
1533
+ let networkCode = undefined;
1534
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
1535
+ if (networkCode !== undefined) {
1536
+ request['network_code'] = this.networkCodeToId(networkCode);
1537
+ }
1538
+ const response = await this.v3PrivatePostWithdrawals(this.extend(request, params));
1539
+ // {
1540
+ // "amount": "1",
1541
+ // "currency_symbol": "xrp",
1542
+ // "network_code": "ripple",
1543
+ // "destination_address": "0x1234567890123456789012345678",
1544
+ // "destination_tag": "123456"
1545
+ // }
1546
+ return this.parseTransaction(response);
1547
+ }
1548
+ /**
1549
+ * @method
1550
+ * @name foxbit#fetchLedger
1551
+ * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1552
+ * @see https://docs.foxbit.com.br/rest/v3/#tag/Account/operation/AccountsController_getTransactions
1553
+ * @param {string} code unified currency code, default is undefined
1554
+ * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1555
+ * @param {int} [limit] max number of ledger entrys to return, default is undefined
1556
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1557
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1558
+ */
1559
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1560
+ await this.loadMarkets();
1561
+ const request = {};
1562
+ if (code === undefined) {
1563
+ throw new ArgumentsRequired(this.id + ' fetchLedger() requires a code argument');
1564
+ }
1565
+ if (limit !== undefined) {
1566
+ request['page_size'] = limit;
1567
+ if (limit > 100) {
1568
+ request['page_size'] = 100;
1569
+ }
1570
+ }
1571
+ if (since !== undefined) {
1572
+ request['start_time'] = this.iso8601(since);
1573
+ }
1574
+ const currency = this.currency(code);
1575
+ request['symbol'] = currency['id'];
1576
+ const response = await this.v3PrivateGetAccountsSymbolTransactions(this.extend(request, params));
1577
+ const data = this.safeList(response, 'data', []);
1578
+ return this.parseLedger(data, currency, since, limit);
1579
+ }
1580
+ parseMarket(market) {
1581
+ const id = this.safeString(market, 'symbol');
1582
+ const baseAssets = this.safeDict(market, 'base');
1583
+ const baseId = this.safeString(baseAssets, 'symbol');
1584
+ const quoteAssets = this.safeDict(market, 'quote');
1585
+ const quoteId = this.safeString(quoteAssets, 'symbol');
1586
+ const base = this.safeCurrencyCode(baseId);
1587
+ const quote = this.safeCurrencyCode(quoteId);
1588
+ const symbol = base + '/' + quote;
1589
+ const fees = this.safeDict(market, 'default_fees');
1590
+ return this.safeMarketStructure({
1591
+ 'id': id,
1592
+ 'symbol': symbol,
1593
+ 'base': base,
1594
+ 'quote': quote,
1595
+ 'baseId': baseId,
1596
+ 'quoteId': quoteId,
1597
+ 'active': true,
1598
+ 'type': 'spot',
1599
+ 'spot': true,
1600
+ 'margin': false,
1601
+ 'future': false,
1602
+ 'swap': false,
1603
+ 'option': false,
1604
+ 'contract': false,
1605
+ 'settle': undefined,
1606
+ 'settleId': undefined,
1607
+ 'contractSize': undefined,
1608
+ 'linear': undefined,
1609
+ 'inverse': undefined,
1610
+ 'expiry': undefined,
1611
+ 'expiryDatetime': undefined,
1612
+ 'strike': undefined,
1613
+ 'optionType': undefined,
1614
+ 'taker': this.safeNumber(fees, 'taker'),
1615
+ 'maker': this.safeNumber(fees, 'maker'),
1616
+ 'percentage': true,
1617
+ 'tierBased': false,
1618
+ 'feeSide': 'get',
1619
+ 'precision': {
1620
+ 'price': this.safeInteger(quoteAssets, 'precision'),
1621
+ 'amount': this.safeInteger(baseAssets, 'precision'),
1622
+ 'cost': this.safeInteger(quoteAssets, 'precision'),
1623
+ },
1624
+ 'limits': {
1625
+ 'amount': {
1626
+ 'min': this.safeNumber(market, 'quantity_min'),
1627
+ 'max': undefined,
1628
+ },
1629
+ 'price': {
1630
+ 'min': this.safeNumber(market, 'price_min'),
1631
+ 'max': undefined,
1632
+ },
1633
+ 'cost': {
1634
+ 'min': undefined,
1635
+ 'max': undefined,
1636
+ },
1637
+ 'leverage': {
1638
+ 'min': undefined,
1639
+ 'max': undefined,
1640
+ },
1641
+ },
1642
+ 'info': market,
1643
+ });
1644
+ }
1645
+ parseTradingFee(entry, market = undefined) {
1646
+ return {
1647
+ 'info': entry,
1648
+ 'symbol': market['symbol'],
1649
+ 'maker': this.safeNumber(entry, 'maker'),
1650
+ 'taker': this.safeNumber(entry, 'taker'),
1651
+ 'percentage': true,
1652
+ 'tierBased': true,
1653
+ };
1654
+ }
1655
+ parseTicker(ticker, market = undefined) {
1656
+ const marketId = this.safeString(ticker, 'market_symbol');
1657
+ const symbol = this.safeSymbol(marketId, market, undefined, 'spot');
1658
+ const rolling_24h = ticker['rolling_24h'];
1659
+ const best = this.safeDict(ticker, 'best');
1660
+ const bestAsk = this.safeDict(best, 'ask');
1661
+ const bestBid = this.safeDict(best, 'bid');
1662
+ const lastTrade = ticker['last_trade'];
1663
+ const lastPrice = this.safeString(lastTrade, 'price');
1664
+ return this.safeTicker({
1665
+ 'symbol': symbol,
1666
+ 'timestamp': this.parseDate(this.safeString(lastTrade, 'date')),
1667
+ 'datetime': this.iso8601(this.parseDate(this.safeString(lastTrade, 'date'))),
1668
+ 'high': this.safeNumber(rolling_24h, 'high'),
1669
+ 'low': this.safeNumber(rolling_24h, 'low'),
1670
+ 'bid': this.safeNumber(bestBid, 'price'),
1671
+ 'bidVolume': this.safeNumber(bestBid, 'volume'),
1672
+ 'ask': this.safeNumber(bestAsk, 'price'),
1673
+ 'askVolume': this.safeNumber(bestAsk, 'volume'),
1674
+ 'vwap': undefined,
1675
+ 'open': this.safeNumber(rolling_24h, 'open'),
1676
+ 'close': lastPrice,
1677
+ 'last': lastPrice,
1678
+ 'previousClose': undefined,
1679
+ 'change': this.safeString(rolling_24h, 'price_change'),
1680
+ 'percentage': this.safeString(rolling_24h, 'price_change_percent'),
1681
+ 'average': undefined,
1682
+ 'baseVolume': this.safeString(rolling_24h, 'volume'),
1683
+ 'quoteVolume': undefined,
1684
+ 'info': ticker,
1685
+ }, market);
1686
+ }
1687
+ parseOHLCV(ohlcv, market = undefined) {
1688
+ return [
1689
+ this.safeInteger(ohlcv, 0),
1690
+ this.safeNumber(ohlcv, 1),
1691
+ this.safeNumber(ohlcv, 2),
1692
+ this.safeNumber(ohlcv, 3),
1693
+ this.safeNumber(ohlcv, 4),
1694
+ this.safeNumber(ohlcv, 6),
1695
+ ];
1696
+ }
1697
+ parseTrade(trade, market = undefined) {
1698
+ const timestamp = this.parseDate(this.safeString(trade, 'created_at'));
1699
+ const price = this.safeString(trade, 'price');
1700
+ const amount = this.safeString(trade, 'volume', this.safeString(trade, 'quantity'));
1701
+ const privateSideField = this.safeStringLower(trade, 'side');
1702
+ const side = this.safeStringLower(trade, 'taker_side', privateSideField);
1703
+ const cost = Precise.stringMul(price, amount);
1704
+ const fee = {
1705
+ 'currency': this.safeSymbol(this.safeString(trade, 'fee_currency_symbol')),
1706
+ 'cost': this.safeNumber(trade, 'fee'),
1707
+ 'rate': undefined,
1708
+ };
1709
+ return this.safeTrade({
1710
+ 'id': this.safeString(trade, 'id'),
1711
+ 'info': trade,
1712
+ 'timestamp': timestamp,
1713
+ 'datetime': this.iso8601(timestamp),
1714
+ 'symbol': market['symbol'],
1715
+ 'order': undefined,
1716
+ 'type': undefined,
1717
+ 'side': side,
1718
+ 'takerOrMaker': undefined,
1719
+ 'price': price,
1720
+ 'amount': amount,
1721
+ 'cost': cost,
1722
+ 'fee': fee,
1723
+ }, market);
1724
+ }
1725
+ parseOrderStatus(status) {
1726
+ const statuses = {
1727
+ 'PARTIALLY_CANCELED': 'open',
1728
+ 'ACTIVE': 'open',
1729
+ 'PARTIALLY_FILLED': 'open',
1730
+ 'FILLED': 'closed',
1731
+ 'PENDING_CANCEL': 'canceled',
1732
+ 'CANCELED': 'canceled',
1733
+ };
1734
+ return this.safeString(statuses, status, status);
1735
+ }
1736
+ parseOrder(order, market = undefined) {
1737
+ let symbol = this.safeString(order, 'market_symbol');
1738
+ if (market === undefined && symbol !== undefined) {
1739
+ market = this.market(symbol);
1740
+ }
1741
+ if (market !== undefined) {
1742
+ symbol = market['symbol'];
1743
+ }
1744
+ const timestamp = this.parseDate(this.safeString(order, 'created_at'));
1745
+ const price = this.safeString(order, 'price');
1746
+ const filled = this.safeString(order, 'quantity_executed');
1747
+ const remaining = this.safeString(order, 'quantity');
1748
+ // TODO: validate logic of amount here, should this be calculated?
1749
+ let amount = undefined;
1750
+ if (remaining !== undefined && filled !== undefined) {
1751
+ amount = Precise.stringAdd(remaining, filled);
1752
+ }
1753
+ let cost = this.safeString(order, 'funds_received');
1754
+ if (!cost) {
1755
+ const priceAverage = this.safeString(order, 'price_avg');
1756
+ const priceToCalculate = this.safeString(order, 'price', priceAverage);
1757
+ cost = Precise.stringMul(priceToCalculate, amount);
1758
+ }
1759
+ const side = this.safeStringLower(order, 'side');
1760
+ let feeCurrency = this.safeStringUpper(market, 'quoteId');
1761
+ if (side === 'buy') {
1762
+ feeCurrency = this.safeStringUpper(market, 'baseId');
1763
+ }
1764
+ return this.safeOrder({
1765
+ 'id': this.safeString(order, 'id'),
1766
+ 'info': order,
1767
+ 'clientOrderId': this.safeString(order, 'client_order_id'),
1768
+ 'timestamp': timestamp,
1769
+ 'datetime': this.iso8601(timestamp),
1770
+ 'lastTradeTimestamp': undefined,
1771
+ 'status': this.parseOrderStatus(this.safeString(order, 'state')),
1772
+ 'symbol': this.safeString(market, 'symbol'),
1773
+ 'type': this.safeString(order, 'type'),
1774
+ 'timeInForce': this.safeString(order, 'time_in_force'),
1775
+ 'postOnly': this.safeBool(order, 'post_only'),
1776
+ 'reduceOnly': undefined,
1777
+ 'side': side,
1778
+ 'price': this.parseNumber(price),
1779
+ 'triggerPrice': this.safeNumber(order, 'stop_price'),
1780
+ 'takeProfitPrice': undefined,
1781
+ 'stopLossPrice': undefined,
1782
+ 'cost': this.parseNumber(cost),
1783
+ 'average': this.safeNumber(order, 'price_avg'),
1784
+ 'amount': this.parseNumber(amount),
1785
+ 'filled': this.parseNumber(filled),
1786
+ 'remaining': this.parseNumber(remaining),
1787
+ 'trades': undefined,
1788
+ 'fee': {
1789
+ 'currency': feeCurrency,
1790
+ 'cost': this.safeNumber(order, 'fee_paid'),
1791
+ },
1792
+ });
1793
+ }
1794
+ parseDepositAddress(depositAddress, currency = undefined) {
1795
+ const network = this.safeDict(depositAddress, 'network');
1796
+ const networkId = this.safeString(network, 'code');
1797
+ const currencyCode = this.safeCurrencyCode(undefined, currency);
1798
+ const unifiedNetwork = this.networkIdToCode(networkId, currencyCode);
1799
+ return {
1800
+ 'address': this.safeString(depositAddress, 'address'),
1801
+ 'tag': this.safeString(depositAddress, 'tag'),
1802
+ 'currency': currencyCode,
1803
+ 'network': unifiedNetwork,
1804
+ 'info': depositAddress,
1805
+ };
1806
+ }
1807
+ parseTransactionStatus(status) {
1808
+ const statuses = {
1809
+ // BOTH
1810
+ 'SUBMITTING': 'pending',
1811
+ 'SUBMITTED': 'pending',
1812
+ 'REJECTED': 'failed',
1813
+ // DEPOSIT-SPECIFIC
1814
+ 'CANCELLED': 'canceled',
1815
+ 'ACCEPTED': 'ok',
1816
+ 'WARNING': 'pending',
1817
+ 'UNBLOCKED': 'pending',
1818
+ 'BLOCKED': 'pending',
1819
+ // WITHDRAWAL-SPECIFIC
1820
+ 'PROCESSING': 'pending',
1821
+ 'CANCELED': 'canceled',
1822
+ 'FAILED': 'failed',
1823
+ 'DONE': 'ok',
1824
+ };
1825
+ return this.safeString(statuses, status, status);
1826
+ }
1827
+ parseTransaction(transaction, currency = undefined, since = undefined, limit = undefined) {
1828
+ const cryptoDetails = this.safeDict(transaction, 'details_crypto');
1829
+ const address = this.safeString2(cryptoDetails, 'receiving_address', 'destination_address');
1830
+ const sn = this.safeString(transaction, 'sn');
1831
+ let type = 'withdrawal';
1832
+ if (sn !== undefined && sn[0] === 'D') {
1833
+ type = 'deposit';
1834
+ }
1835
+ const fee = this.safeString(transaction, 'fee', '0');
1836
+ const amount = this.safeString(transaction, 'amount');
1837
+ const currencySymbol = this.safeString(transaction, 'currency_symbol');
1838
+ let actualAmount = amount;
1839
+ const currencyCode = this.safeCurrencyCode(currencySymbol);
1840
+ const status = this.parseTransactionStatus(this.safeString(transaction, 'state'));
1841
+ const created_at = this.safeString(transaction, 'created_at');
1842
+ const timestamp = this.parseDate(created_at);
1843
+ const datetime = this.iso8601(timestamp);
1844
+ if (fee !== undefined && amount !== undefined) {
1845
+ // actualAmount = amount - fee;
1846
+ actualAmount = Precise.stringSub(amount, fee);
1847
+ }
1848
+ const feeRate = Precise.stringDiv(fee, actualAmount);
1849
+ const feeObj = {
1850
+ 'cost': this.parseNumber(fee),
1851
+ 'currency': currencyCode,
1852
+ 'rate': this.parseNumber(feeRate),
1853
+ };
1854
+ return {
1855
+ 'info': transaction,
1856
+ 'id': this.safeString(transaction, 'sn'),
1857
+ 'txid': this.safeString(cryptoDetails, 'transaction_id'),
1858
+ 'timestamp': timestamp,
1859
+ 'datetime': datetime,
1860
+ 'network': this.safeString(transaction, 'network_code'),
1861
+ 'address': address,
1862
+ 'addressTo': address,
1863
+ 'addressFrom': undefined,
1864
+ 'tag': this.safeString(transaction, 'destination_tag'),
1865
+ 'tagTo': this.safeString(transaction, 'destination_tag'),
1866
+ 'tagFrom': undefined,
1867
+ 'type': type,
1868
+ 'amount': this.parseNumber(amount),
1869
+ 'currency': currencyCode,
1870
+ 'status': status,
1871
+ 'updated': undefined,
1872
+ 'fee': feeObj,
1873
+ 'comment': undefined,
1874
+ 'internal': undefined,
1875
+ };
1876
+ }
1877
+ parseLedgerEntryType(type) {
1878
+ const types = {
1879
+ 'DEPOSITING': 'transaction',
1880
+ 'WITHDRAWING': 'transaction',
1881
+ 'TRADING': 'trade',
1882
+ 'INTERNAL_TRANSFERING': 'transfer',
1883
+ 'OTHERS': 'transaction',
1884
+ };
1885
+ return this.safeString(types, type, type);
1886
+ }
1887
+ parseLedgerEntry(item, currency = undefined) {
1888
+ // {
1889
+ // "uuid": "f8e9f2d6-3c1e-4f2d-8f8e-9f2d6c1e4f2d",
1890
+ // "amount": "0.0001",
1891
+ // "balance": "0.0002",
1892
+ // "created_at": "2021-07-01T12:00:00Z",
1893
+ // "currency_symbol": "btc",
1894
+ // "fee": "0.0001",
1895
+ // "locked": "0.0001",
1896
+ // "locked_amount": "0.0001",
1897
+ // "reason_type": "DEPOSITING"
1898
+ // }
1899
+ const id = this.safeString(item, 'uuid');
1900
+ const createdAt = this.safeString(item, 'created_at');
1901
+ const timestamp = this.parse8601(createdAt);
1902
+ const reasonType = this.safeString(item, 'reason_type');
1903
+ const type = this.parseLedgerEntryType(reasonType);
1904
+ const exchangeSymbol = this.safeString(item, 'currency_symbol');
1905
+ const currencySymbol = this.safeCurrencyCode(exchangeSymbol);
1906
+ let direction = 'in';
1907
+ const amount = this.safeNumber(item, 'amount');
1908
+ let realAmount = amount;
1909
+ const balance = this.safeNumber(item, 'balance');
1910
+ const fee = {
1911
+ 'cost': this.safeNumber(item, 'fee'),
1912
+ 'currency': currencySymbol,
1913
+ };
1914
+ if (amount < 0) {
1915
+ direction = 'out';
1916
+ realAmount = amount * -1;
1917
+ }
1918
+ return {
1919
+ 'id': id,
1920
+ 'info': item,
1921
+ 'timestamp': timestamp,
1922
+ 'datetime': this.iso8601(timestamp),
1923
+ 'direction': direction,
1924
+ 'account': undefined,
1925
+ 'referenceId': undefined,
1926
+ 'referenceAccount': undefined,
1927
+ 'type': type,
1928
+ 'currency': currencySymbol,
1929
+ 'amount': realAmount,
1930
+ 'before': balance - amount,
1931
+ 'after': balance,
1932
+ 'status': 'ok',
1933
+ 'fee': fee,
1934
+ };
1935
+ }
1936
+ sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
1937
+ const version = api[0];
1938
+ let urlPath = api[1];
1939
+ let fullPath = '/rest/' + version + '/' + this.implodeParams(path, params);
1940
+ if (version === 'status') {
1941
+ fullPath = '/status';
1942
+ urlPath = 'status';
1943
+ }
1944
+ let url = this.urls['api'][urlPath] + fullPath;
1945
+ params = this.omit(params, this.extractParams(path));
1946
+ const timestamp = this.milliseconds();
1947
+ let query = '';
1948
+ let signatureQuery = '';
1949
+ if (method === 'GET') {
1950
+ const paramKeys = Object.keys(params);
1951
+ const paramKeysLength = paramKeys.length;
1952
+ if (paramKeysLength > 0) {
1953
+ query = this.urlencode(params);
1954
+ url += '?' + query;
1955
+ }
1956
+ for (let i = 0; i < paramKeys.length; i++) {
1957
+ const key = paramKeys[i];
1958
+ const value = this.safeString(params, key);
1959
+ if (value !== undefined) {
1960
+ signatureQuery += key + '=' + value;
1961
+ }
1962
+ if (i < paramKeysLength - 1) {
1963
+ signatureQuery += '&';
1964
+ }
1965
+ }
1966
+ }
1967
+ if (method === 'POST' || method === 'PUT') {
1968
+ body = this.json(params);
1969
+ }
1970
+ let bodyToSignature = '';
1971
+ if (body !== undefined) {
1972
+ bodyToSignature = body;
1973
+ }
1974
+ headers = {
1975
+ 'Content-Type': 'application/json',
1976
+ };
1977
+ if (urlPath === 'private') {
1978
+ this.checkRequiredCredentials();
1979
+ const preHash = this.numberToString(timestamp) + method + fullPath + signatureQuery + bodyToSignature;
1980
+ const signature = this.hmac(this.encode(preHash), this.encode(this.secret), sha256, 'hex');
1981
+ headers['X-FB-ACCESS-KEY'] = this.apiKey;
1982
+ headers['X-FB-ACCESS-TIMESTAMP'] = this.numberToString(timestamp);
1983
+ headers['X-FB-ACCESS-SIGNATURE'] = signature;
1984
+ }
1985
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1986
+ }
1987
+ handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1988
+ if (response === undefined) {
1989
+ return undefined;
1990
+ }
1991
+ const error = this.safeDict(response, 'error');
1992
+ const code = this.safeString(error, 'code');
1993
+ const details = this.safeList(error, 'details');
1994
+ const message = this.safeString(error, 'message');
1995
+ let detailsString = '';
1996
+ if (details) {
1997
+ for (let i = 0; i < details.length; i++) {
1998
+ detailsString = detailsString + details[i] + ' ';
1999
+ }
2000
+ }
2001
+ if (error !== undefined) {
2002
+ const feedback = this.id + ' ' + message + ' details: ' + detailsString;
2003
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
2004
+ this.throwBroadlyMatchedException(this.exceptions['broad'], detailsString, feedback);
2005
+ this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
2006
+ throw new ExchangeError(feedback);
2007
+ }
2008
+ return undefined;
2009
+ }
2010
+ }