ccxt 4.5.46 → 4.5.48

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 (1009) hide show
  1. package/README.md +117 -116
  2. package/dist/ccxt.browser.min.js +10 -10
  3. package/dist/cjs/ccxt.js +6 -6
  4. package/dist/cjs/src/abstract/aftermath.js +1 -1
  5. package/dist/cjs/src/abstract/alpaca.js +1 -1
  6. package/dist/cjs/src/abstract/apex.js +1 -1
  7. package/dist/cjs/src/abstract/arkham.js +1 -1
  8. package/dist/cjs/src/abstract/ascendex.js +1 -1
  9. package/dist/cjs/src/abstract/aster.js +1 -1
  10. package/dist/cjs/src/abstract/backpack.js +1 -1
  11. package/dist/cjs/src/abstract/bigone.js +1 -1
  12. package/dist/cjs/src/abstract/binance.js +1 -1
  13. package/dist/cjs/src/abstract/bingx.js +1 -1
  14. package/dist/cjs/src/abstract/bit2c.js +1 -1
  15. package/dist/cjs/src/abstract/bitbank.js +1 -1
  16. package/dist/cjs/src/abstract/bitbns.js +1 -1
  17. package/dist/cjs/src/abstract/bitfinex.js +1 -1
  18. package/dist/cjs/src/abstract/bitflyer.js +1 -1
  19. package/dist/cjs/src/abstract/bitget.js +1 -1
  20. package/dist/cjs/src/abstract/bithumb.js +1 -1
  21. package/dist/cjs/src/abstract/bitmart.js +1 -1
  22. package/dist/cjs/src/abstract/bitmex.js +1 -1
  23. package/dist/cjs/src/abstract/bitopro.js +1 -1
  24. package/dist/cjs/src/abstract/bitrue.js +1 -1
  25. package/dist/cjs/src/abstract/bitso.js +1 -1
  26. package/dist/cjs/src/abstract/bitstamp.js +1 -1
  27. package/dist/cjs/src/abstract/bitteam.js +1 -1
  28. package/dist/cjs/src/abstract/bittrade.js +1 -1
  29. package/dist/cjs/src/abstract/bitvavo.js +1 -1
  30. package/dist/cjs/src/abstract/blockchaincom.js +1 -1
  31. package/dist/cjs/src/abstract/blofin.js +1 -1
  32. package/dist/cjs/src/abstract/btcbox.js +1 -1
  33. package/dist/cjs/src/abstract/btcmarkets.js +1 -1
  34. package/dist/cjs/src/abstract/btcturk.js +1 -1
  35. package/dist/cjs/src/abstract/bullish.js +1 -1
  36. package/dist/cjs/src/abstract/bybit.js +1 -1
  37. package/dist/cjs/src/abstract/bydfi.js +1 -1
  38. package/dist/cjs/src/abstract/cex.js +1 -1
  39. package/dist/cjs/src/abstract/coinbase.js +1 -1
  40. package/dist/cjs/src/abstract/coinbaseexchange.js +1 -1
  41. package/dist/cjs/src/abstract/coinbaseinternational.js +1 -1
  42. package/dist/cjs/src/abstract/coincheck.js +1 -1
  43. package/dist/cjs/src/abstract/coinex.js +1 -1
  44. package/dist/cjs/src/abstract/coinmate.js +1 -1
  45. package/dist/cjs/src/abstract/coinmetro.js +1 -1
  46. package/dist/cjs/src/abstract/coinone.js +1 -1
  47. package/dist/cjs/src/abstract/coinsph.js +1 -1
  48. package/dist/cjs/src/abstract/coinspot.js +1 -1
  49. package/dist/cjs/src/abstract/cryptocom.js +1 -1
  50. package/dist/cjs/src/abstract/cryptomus.js +1 -1
  51. package/dist/cjs/src/abstract/deepcoin.js +1 -1
  52. package/dist/cjs/src/abstract/delta.js +1 -1
  53. package/dist/cjs/src/abstract/deribit.js +1 -1
  54. package/dist/cjs/src/abstract/derive.js +1 -1
  55. package/dist/cjs/src/abstract/digifinex.js +1 -1
  56. package/dist/cjs/src/abstract/dydx.js +1 -1
  57. package/dist/cjs/src/abstract/exmo.js +1 -1
  58. package/dist/cjs/src/abstract/foxbit.js +1 -1
  59. package/dist/cjs/src/abstract/gate.js +1 -1
  60. package/dist/cjs/src/abstract/gemini.js +1 -1
  61. package/dist/cjs/src/abstract/grvt.js +1 -1
  62. package/dist/cjs/src/abstract/hashkey.js +1 -1
  63. package/dist/cjs/src/abstract/hibachi.js +1 -1
  64. package/dist/cjs/src/abstract/hitbtc.js +1 -1
  65. package/dist/cjs/src/abstract/hollaex.js +1 -1
  66. package/dist/cjs/src/abstract/htx.js +1 -1
  67. package/dist/cjs/src/abstract/hyperliquid.js +1 -1
  68. package/dist/cjs/src/abstract/independentreserve.js +1 -1
  69. package/dist/cjs/src/abstract/indodax.js +1 -1
  70. package/dist/cjs/src/abstract/kraken.js +1 -1
  71. package/dist/cjs/src/abstract/krakenfutures.js +1 -1
  72. package/dist/cjs/src/abstract/kucoin.js +1 -1
  73. package/dist/cjs/src/abstract/latoken.js +1 -1
  74. package/dist/cjs/src/abstract/lbank.js +1 -1
  75. package/dist/cjs/src/abstract/lighter.js +1 -1
  76. package/dist/cjs/src/abstract/luno.js +1 -1
  77. package/dist/cjs/src/abstract/mercado.js +1 -1
  78. package/dist/cjs/src/abstract/mexc.js +1 -1
  79. package/dist/cjs/src/abstract/modetrade.js +1 -1
  80. package/dist/cjs/src/abstract/ndax.js +1 -1
  81. package/dist/cjs/src/abstract/novadax.js +1 -1
  82. package/dist/cjs/src/abstract/okx.js +1 -1
  83. package/dist/cjs/src/abstract/onetrading.js +1 -1
  84. package/dist/cjs/src/abstract/oxfun.js +1 -1
  85. package/dist/cjs/src/abstract/p2b.js +1 -1
  86. package/dist/cjs/src/abstract/{coincatch.js → pacifica.js} +1 -1
  87. package/dist/cjs/src/abstract/paradex.js +1 -1
  88. package/dist/cjs/src/abstract/paymium.js +1 -1
  89. package/dist/cjs/src/abstract/phemex.js +1 -1
  90. package/dist/cjs/src/abstract/poloniex.js +1 -1
  91. package/dist/cjs/src/abstract/tokocrypto.js +1 -1
  92. package/dist/cjs/src/abstract/toobit.js +1 -1
  93. package/dist/cjs/src/abstract/upbit.js +1 -1
  94. package/dist/cjs/src/abstract/wavesexchange.js +1 -1
  95. package/dist/cjs/src/abstract/whitebit.js +1 -1
  96. package/dist/cjs/src/abstract/woo.js +1 -1
  97. package/dist/cjs/src/abstract/woofipro.js +1 -1
  98. package/dist/cjs/src/abstract/xt.js +1 -1
  99. package/dist/cjs/src/abstract/yobit.js +1 -1
  100. package/dist/cjs/src/abstract/zaif.js +1 -1
  101. package/dist/cjs/src/abstract/zebpay.js +1 -1
  102. package/dist/cjs/src/abstract/zonda.js +1 -1
  103. package/dist/cjs/src/aftermath.js +2 -1
  104. package/dist/cjs/src/alpaca.js +1 -1
  105. package/dist/cjs/src/apex.js +1 -1
  106. package/dist/cjs/src/arkham.js +1 -1
  107. package/dist/cjs/src/ascendex.js +1 -1
  108. package/dist/cjs/src/aster.js +53 -1
  109. package/dist/cjs/src/backpack.js +2 -2
  110. package/dist/cjs/src/base/Exchange.js +31 -0
  111. package/dist/cjs/src/base/Precise.js +6 -0
  112. package/dist/cjs/src/base/errors.js +6 -0
  113. package/dist/cjs/src/base/functions/crypto.js +1 -1
  114. package/dist/cjs/src/base/functions/encode.js +1 -1
  115. package/dist/cjs/src/base/functions/io.js +1 -1
  116. package/dist/cjs/src/base/functions/misc.js +1 -0
  117. package/dist/cjs/src/base/functions/number.js +6 -0
  118. package/dist/cjs/src/base/functions/platform.js +6 -0
  119. package/dist/cjs/src/base/functions/rsa.js +1 -0
  120. package/dist/cjs/src/base/functions/string.js +6 -0
  121. package/dist/cjs/src/base/functions/throttle.js +1 -1
  122. package/dist/cjs/src/base/functions/time.js +6 -0
  123. package/dist/cjs/src/base/functions/totp.js +1 -0
  124. package/dist/cjs/src/base/functions/type.js +6 -0
  125. package/dist/cjs/src/base/functions.js +1 -1
  126. package/dist/cjs/src/base/ws/Cache.js +6 -0
  127. package/dist/cjs/src/base/ws/Client.js +1 -0
  128. package/dist/cjs/src/base/ws/Future.js +1 -1
  129. package/dist/cjs/src/base/ws/OrderBook.js +1 -1
  130. package/dist/cjs/src/base/ws/OrderBookSide.js +6 -0
  131. package/dist/cjs/src/base/ws/WsClient.js +1 -1
  132. package/dist/cjs/src/bequant.js +1 -1
  133. package/dist/cjs/src/bigone.js +1 -1
  134. package/dist/cjs/src/binance.js +14 -19
  135. package/dist/cjs/src/binancecoinm.js +1 -1
  136. package/dist/cjs/src/binanceus.js +1 -1
  137. package/dist/cjs/src/binanceusdm.js +1 -1
  138. package/dist/cjs/src/bingx.js +1 -1
  139. package/dist/cjs/src/bit2c.js +1 -1
  140. package/dist/cjs/src/bitbank.js +1 -1
  141. package/dist/cjs/src/bitbns.js +1 -1
  142. package/dist/cjs/src/bitfinex.js +45 -54
  143. package/dist/cjs/src/bitflyer.js +1 -1
  144. package/dist/cjs/src/bitget.js +7 -4
  145. package/dist/cjs/src/bithumb.js +1 -1
  146. package/dist/cjs/src/bitmart.js +1 -1
  147. package/dist/cjs/src/bitmex.js +47 -1
  148. package/dist/cjs/src/bitopro.js +1 -1
  149. package/dist/cjs/src/bitrue.js +1 -1
  150. package/dist/cjs/src/bitso.js +1 -1
  151. package/dist/cjs/src/bitstamp.js +15 -2
  152. package/dist/cjs/src/bitteam.js +1 -1
  153. package/dist/cjs/src/bittrade.js +2 -2
  154. package/dist/cjs/src/blockchaincom.js +1 -1
  155. package/dist/cjs/src/blofin.js +153 -32
  156. package/dist/cjs/src/btcbox.js +1 -1
  157. package/dist/cjs/src/btcmarkets.js +1 -1
  158. package/dist/cjs/src/btcturk.js +1 -1
  159. package/dist/cjs/src/bullish.js +1 -1
  160. package/dist/cjs/src/bybit.js +1 -1
  161. package/dist/cjs/src/bydfi.js +1 -1
  162. package/dist/cjs/src/cex.js +1 -1
  163. package/dist/cjs/src/coinbaseadvanced.js +1 -1
  164. package/dist/cjs/src/coincheck.js +1 -1
  165. package/dist/cjs/src/coinex.js +1 -1
  166. package/dist/cjs/src/coinmate.js +1 -1
  167. package/dist/cjs/src/coinmetro.js +1 -1
  168. package/dist/cjs/src/coinone.js +1 -1
  169. package/dist/cjs/src/coinsph.js +5 -0
  170. package/dist/cjs/src/coinspot.js +1 -1
  171. package/dist/cjs/src/cryptocom.js +1 -1
  172. package/dist/cjs/src/cryptomus.js +1 -1
  173. package/dist/cjs/src/deepcoin.js +1 -1
  174. package/dist/cjs/src/delta.js +1 -1
  175. package/dist/cjs/src/deribit.js +1 -1
  176. package/dist/cjs/src/derive.js +1 -1
  177. package/dist/cjs/src/digifinex.js +1 -1
  178. package/dist/cjs/src/dydx.js +1 -1
  179. package/dist/cjs/src/exmo.js +1 -1
  180. package/dist/cjs/src/fmfwio.js +1 -1
  181. package/dist/cjs/src/foxbit.js +1 -1
  182. package/dist/cjs/src/gate.js +1 -1
  183. package/dist/cjs/src/gateio.js +1 -1
  184. package/dist/cjs/src/gemini.js +1 -1
  185. package/dist/cjs/src/grvt.js +1 -1
  186. package/dist/cjs/src/hashkey.js +1 -1
  187. package/dist/cjs/src/hibachi.js +1 -1
  188. package/dist/cjs/src/hitbtc.js +1 -0
  189. package/dist/cjs/src/hollaex.js +2 -2
  190. package/dist/cjs/src/htx.js +1 -1
  191. package/dist/cjs/src/huobi.js +1 -1
  192. package/dist/cjs/src/hyperliquid.js +1 -1
  193. package/dist/cjs/src/independentreserve.js +1 -1
  194. package/dist/cjs/src/indodax.js +1 -1
  195. package/dist/cjs/src/kraken.js +40 -32
  196. package/dist/cjs/src/krakenfutures.js +1 -1
  197. package/dist/cjs/src/kucoin.js +2112 -415
  198. package/dist/cjs/src/kucoinfutures.js +1 -1
  199. package/dist/cjs/src/latoken.js +1 -1
  200. package/dist/cjs/src/lbank.js +1 -1
  201. package/dist/cjs/src/lighter.js +199 -74
  202. package/dist/cjs/src/luno.js +1 -1
  203. package/dist/cjs/src/mercado.js +1 -1
  204. package/dist/cjs/src/mexc.js +50 -1
  205. package/dist/cjs/src/modetrade.js +1 -1
  206. package/dist/cjs/src/myokx.js +1 -1
  207. package/dist/cjs/src/ndax.js +1 -1
  208. package/dist/cjs/src/novadax.js +1 -1
  209. package/dist/cjs/src/okx.js +7 -6
  210. package/dist/cjs/src/okxus.js +1 -1
  211. package/dist/cjs/src/onetrading.js +1 -1
  212. package/dist/cjs/src/oxfun.js +1 -1
  213. package/dist/cjs/src/p2b.js +1 -1
  214. package/dist/cjs/src/pacifica.js +3254 -0
  215. package/dist/cjs/src/paradex.js +1 -1
  216. package/dist/cjs/src/paymium.js +1 -1
  217. package/dist/cjs/src/poloniex.js +1 -1
  218. package/dist/cjs/src/pro/alpaca.js +1 -1
  219. package/dist/cjs/src/pro/apex.js +1 -1
  220. package/dist/cjs/src/pro/arkham.js +1 -1
  221. package/dist/cjs/src/pro/ascendex.js +1 -1
  222. package/dist/cjs/src/pro/aster.js +1 -1
  223. package/dist/cjs/src/pro/backpack.js +1 -1
  224. package/dist/cjs/src/pro/bequant.js +1 -1
  225. package/dist/cjs/src/pro/binance.js +12 -1
  226. package/dist/cjs/src/pro/binancecoinm.js +1 -1
  227. package/dist/cjs/src/pro/binanceus.js +1 -1
  228. package/dist/cjs/src/pro/binanceusdm.js +1 -1
  229. package/dist/cjs/src/pro/bingx.js +2 -2
  230. package/dist/cjs/src/pro/bitfinex.js +1 -1
  231. package/dist/cjs/src/pro/bitget.js +1 -1
  232. package/dist/cjs/src/pro/bithumb.js +1 -1
  233. package/dist/cjs/src/pro/bitmart.js +5 -4
  234. package/dist/cjs/src/pro/bitmex.js +1 -1
  235. package/dist/cjs/src/pro/bitrue.js +1 -1
  236. package/dist/cjs/src/pro/bitstamp.js +1 -1
  237. package/dist/cjs/src/pro/bittrade.js +4 -0
  238. package/dist/cjs/src/pro/bitvavo.js +9 -1
  239. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  240. package/dist/cjs/src/pro/blofin.js +1 -1
  241. package/dist/cjs/src/pro/bullish.js +1 -1
  242. package/dist/cjs/src/pro/bybit.js +1 -1
  243. package/dist/cjs/src/pro/bydfi.js +1 -1
  244. package/dist/cjs/src/pro/cex.js +1 -1
  245. package/dist/cjs/src/pro/coinbase.js +1 -1
  246. package/dist/cjs/src/pro/coinbaseadvanced.js +1 -1
  247. package/dist/cjs/src/pro/coinbaseexchange.js +1 -1
  248. package/dist/cjs/src/pro/coinbaseinternational.js +1 -1
  249. package/dist/cjs/src/pro/coincheck.js +1 -1
  250. package/dist/cjs/src/pro/coinex.js +1 -1
  251. package/dist/cjs/src/pro/coinone.js +1 -1
  252. package/dist/cjs/src/pro/cryptocom.js +1 -1
  253. package/dist/cjs/src/pro/deepcoin.js +1 -1
  254. package/dist/cjs/src/pro/deribit.js +1 -1
  255. package/dist/cjs/src/pro/dydx.js +1 -1
  256. package/dist/cjs/src/pro/exmo.js +1 -1
  257. package/dist/cjs/src/pro/gate.js +4 -1
  258. package/dist/cjs/src/pro/gateio.js +1 -1
  259. package/dist/cjs/src/pro/gemini.js +1 -1
  260. package/dist/cjs/src/pro/grvt.js +2 -2
  261. package/dist/cjs/src/pro/hashkey.js +1 -1
  262. package/dist/cjs/src/pro/hitbtc.js +1 -1
  263. package/dist/cjs/src/pro/hollaex.js +1 -1
  264. package/dist/cjs/src/pro/htx.js +1 -1
  265. package/dist/cjs/src/pro/huobi.js +1 -1
  266. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  267. package/dist/cjs/src/pro/independentreserve.js +1 -1
  268. package/dist/cjs/src/pro/kraken.js +1 -1
  269. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  270. package/dist/cjs/src/pro/kucoin.js +1 -1
  271. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  272. package/dist/cjs/src/pro/lbank.js +1 -0
  273. package/dist/cjs/src/pro/lighter.js +37 -18
  274. package/dist/cjs/src/pro/luno.js +1 -1
  275. package/dist/cjs/src/pro/mexc.js +1 -1
  276. package/dist/cjs/src/pro/myokx.js +1 -1
  277. package/dist/cjs/src/pro/ndax.js +1 -1
  278. package/dist/cjs/src/pro/okx.js +1 -1
  279. package/dist/cjs/src/pro/okxus.js +1 -1
  280. package/dist/cjs/src/pro/onetrading.js +1 -1
  281. package/dist/cjs/src/pro/oxfun.js +1 -1
  282. package/dist/cjs/src/pro/p2b.js +1 -1
  283. package/dist/cjs/src/pro/pacifica.js +1397 -0
  284. package/dist/cjs/src/pro/paradex.js +1 -1
  285. package/dist/cjs/src/pro/phemex.js +1 -1
  286. package/dist/cjs/src/pro/poloniex.js +1 -1
  287. package/dist/cjs/src/pro/toobit.js +1 -1
  288. package/dist/cjs/src/pro/upbit.js +1 -1
  289. package/dist/cjs/src/pro/whitebit.js +1 -1
  290. package/dist/cjs/src/pro/xt.js +1 -1
  291. package/dist/cjs/src/protobuf/mexc/compiled.cjs.js +0 -1
  292. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +1 -0
  293. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +1 -0
  294. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +1 -0
  295. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +1 -0
  296. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +1 -0
  297. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +1 -0
  298. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +1 -0
  299. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +1 -0
  300. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +1 -0
  301. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +1 -0
  302. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +1 -0
  303. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +1 -0
  304. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +1 -0
  305. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +1 -0
  306. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +6 -0
  307. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +1 -0
  308. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +1 -0
  309. package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +6 -0
  310. package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -1
  311. package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
  312. package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
  313. package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +1 -0
  314. package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
  315. package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +1 -0
  316. package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
  317. package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
  318. package/dist/cjs/src/static_dependencies/ethers/coders/null.js +1 -0
  319. package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
  320. package/dist/cjs/src/static_dependencies/ethers/coders/string.js +1 -0
  321. package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +1 -0
  322. package/dist/cjs/src/static_dependencies/ethers/fragments.js +6 -0
  323. package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +6 -0
  324. package/dist/cjs/src/static_dependencies/ethers/index.js +1 -10
  325. package/dist/cjs/src/static_dependencies/ethers/interface.js +6 -0
  326. package/dist/cjs/src/static_dependencies/ethers/typed.js +6 -0
  327. package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +1 -13
  328. package/dist/cjs/src/static_dependencies/ethers/utils/data.js +1 -6
  329. package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +1 -9
  330. package/dist/cjs/src/static_dependencies/ethers/utils/events.js +6 -0
  331. package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
  332. package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -7
  333. package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +1 -5
  334. package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +6 -0
  335. package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +1 -8
  336. package/dist/cjs/src/static_dependencies/fflake/browser.js +1 -1
  337. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -0
  338. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +1 -0
  339. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +1 -1
  340. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
  341. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
  342. package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
  343. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +1 -0
  344. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1 -1
  345. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
  346. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +1 -1
  347. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +1 -1
  348. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
  349. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1 -1
  350. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
  351. package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +6 -0
  352. package/dist/cjs/src/static_dependencies/noble-curves/_shortw_utils.js +1 -1
  353. package/dist/cjs/src/static_dependencies/noble-curves/abstract/curve.js +1 -1
  354. package/dist/cjs/src/static_dependencies/noble-curves/abstract/edwards.js +1 -1
  355. package/dist/cjs/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +1 -0
  356. package/dist/cjs/src/static_dependencies/noble-curves/abstract/modular.js +1 -1
  357. package/dist/cjs/src/static_dependencies/noble-curves/abstract/montgomery.js +1 -1
  358. package/dist/cjs/src/static_dependencies/noble-curves/abstract/poseidon.js +1 -1
  359. package/dist/cjs/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
  360. package/dist/cjs/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -1
  361. package/dist/cjs/src/static_dependencies/noble-curves/ed25519.js +1 -1
  362. package/dist/cjs/src/static_dependencies/noble-curves/p256.js +1 -1
  363. package/dist/cjs/src/static_dependencies/noble-curves/secp256k1.js +1 -1
  364. package/dist/cjs/src/static_dependencies/noble-hashes/_assert.js +6 -0
  365. package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -0
  366. package/dist/cjs/src/static_dependencies/noble-hashes/_u64.js +6 -0
  367. package/dist/cjs/src/static_dependencies/noble-hashes/crypto.js +6 -0
  368. package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -0
  369. package/dist/cjs/src/static_dependencies/noble-hashes/md5.js +1 -0
  370. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +1 -0
  371. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +1 -0
  372. package/dist/cjs/src/static_dependencies/noble-hashes/sha1.js +1 -0
  373. package/dist/cjs/src/static_dependencies/noble-hashes/sha256.js +1 -0
  374. package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -0
  375. package/dist/cjs/src/static_dependencies/noble-hashes/sha512.js +1 -0
  376. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +1 -1
  377. package/dist/cjs/src/static_dependencies/node-fetch/body.js +1 -5
  378. package/dist/cjs/src/static_dependencies/node-fetch/errors/abort-error.js +1 -0
  379. package/dist/cjs/src/static_dependencies/node-fetch/errors/base.js +6 -0
  380. package/dist/cjs/src/static_dependencies/node-fetch/errors/fetch-error.js +1 -0
  381. package/dist/cjs/src/static_dependencies/node-fetch/headers.js +1 -5
  382. package/dist/cjs/src/static_dependencies/node-fetch/index.js +1 -7
  383. package/dist/cjs/src/static_dependencies/node-fetch/request.js +1 -7
  384. package/dist/cjs/src/static_dependencies/node-fetch/response.js +1 -5
  385. package/dist/cjs/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
  386. package/dist/cjs/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
  387. package/dist/cjs/src/static_dependencies/node-fetch/utils/is.js +6 -0
  388. package/dist/cjs/src/static_dependencies/node-fetch/utils/referrer.js +1 -0
  389. package/dist/cjs/src/static_dependencies/proxies/agent-base/index.js +1 -0
  390. package/dist/cjs/src/static_dependencies/proxies/http-proxy-agent/index.js +1 -0
  391. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/index.js +1 -0
  392. package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
  393. package/dist/cjs/src/static_dependencies/qs/formats.js +6 -0
  394. package/dist/cjs/src/static_dependencies/qs/index.js +1 -0
  395. package/dist/cjs/src/static_dependencies/qs/parse.js +1 -0
  396. package/dist/cjs/src/static_dependencies/qs/stringify.js +1 -0
  397. package/dist/cjs/src/static_dependencies/qs/utils.js +6 -0
  398. package/dist/cjs/src/static_dependencies/scure-base/index.js +6 -0
  399. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +1 -19
  400. package/dist/cjs/src/static_dependencies/scure-bip39/index.js +1 -1
  401. package/dist/cjs/src/static_dependencies/scure-bip39/wordlists/english.js +6 -0
  402. package/dist/cjs/src/static_dependencies/scure-starknet/index.js +1 -1
  403. package/dist/cjs/src/static_dependencies/starknet/constants.js +1 -1
  404. package/dist/cjs/src/static_dependencies/starknet/types/calldata.js +6 -0
  405. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
  406. package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
  407. package/dist/cjs/src/static_dependencies/starknet/types/lib/index.js +6 -0
  408. package/dist/cjs/src/static_dependencies/starknet/types/typedData.js +6 -0
  409. package/dist/cjs/src/static_dependencies/starknet/utils/assert.js +6 -0
  410. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +1 -1
  411. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +1 -1
  412. package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +1 -1
  413. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/byteArray.js +1 -0
  414. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/cairo.js +1 -0
  415. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
  416. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
  417. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
  418. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/formatter.js +1 -0
  419. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/index.js +1 -1
  420. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/index.js +1 -0
  421. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +1 -0
  422. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
  423. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +1 -0
  424. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/requestParser.js +1 -0
  425. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/responseParser.js +1 -0
  426. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/tuple.js +1 -1
  427. package/dist/cjs/src/static_dependencies/starknet/utils/calldata/validate.js +1 -4
  428. package/dist/cjs/src/static_dependencies/starknet/utils/encode.js +1 -0
  429. package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +1 -3
  430. package/dist/cjs/src/static_dependencies/starknet/utils/merkle.js +1 -0
  431. package/dist/cjs/src/static_dependencies/starknet/utils/num.js +1 -0
  432. package/dist/cjs/src/static_dependencies/starknet/utils/selector.js +1 -0
  433. package/dist/cjs/src/static_dependencies/starknet/utils/shortString.js +1 -0
  434. package/dist/cjs/src/static_dependencies/starknet/utils/typedData.js +1 -1
  435. package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +6 -0
  436. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +6 -0
  437. package/dist/cjs/src/tokocrypto.js +1 -1
  438. package/dist/cjs/src/toobit.js +1 -1
  439. package/dist/cjs/src/upbit.js +1 -1
  440. package/dist/cjs/src/wavesexchange.js +1 -1
  441. package/dist/cjs/src/whitebit.js +22 -3
  442. package/dist/cjs/src/woo.js +1 -1
  443. package/dist/cjs/src/woofipro.js +1 -1
  444. package/dist/cjs/src/xt.js +1 -1
  445. package/dist/cjs/src/yobit.js +1 -1
  446. package/dist/cjs/src/zaif.js +1 -1
  447. package/dist/cjs/src/zebpay.js +1 -1
  448. package/dist/cjs/src/zonda.js +1 -1
  449. package/js/ccxt.d.ts +8 -8
  450. package/js/ccxt.js +12 -6
  451. package/js/src/abstract/aftermath.js +6 -0
  452. package/js/src/abstract/alpaca.js +6 -0
  453. package/js/src/abstract/apex.js +6 -0
  454. package/js/src/abstract/arkham.js +6 -0
  455. package/js/src/abstract/ascendex.js +6 -0
  456. package/js/src/abstract/aster.d.ts +52 -0
  457. package/js/src/abstract/aster.js +6 -0
  458. package/js/src/abstract/backpack.js +6 -0
  459. package/js/src/abstract/bequant.js +6 -0
  460. package/js/src/abstract/bigone.js +6 -0
  461. package/js/src/abstract/binance.d.ts +1 -0
  462. package/js/src/abstract/binance.js +6 -0
  463. package/js/src/abstract/binancecoinm.d.ts +1 -0
  464. package/js/src/abstract/binancecoinm.js +6 -0
  465. package/js/src/abstract/binanceus.d.ts +1 -0
  466. package/js/src/abstract/binanceus.js +6 -0
  467. package/js/src/abstract/binanceusdm.d.ts +1 -0
  468. package/js/src/abstract/binanceusdm.js +6 -0
  469. package/js/src/abstract/bingx.js +6 -0
  470. package/js/src/abstract/bit2c.js +6 -0
  471. package/js/src/abstract/bitbank.js +6 -0
  472. package/js/src/abstract/bitbns.js +6 -0
  473. package/js/src/abstract/bitfinex.js +6 -0
  474. package/js/src/abstract/bitflyer.js +6 -0
  475. package/js/src/abstract/bitget.js +6 -0
  476. package/js/src/abstract/bithumb.js +6 -0
  477. package/js/src/abstract/bitmart.js +6 -0
  478. package/js/src/abstract/bitmex.js +6 -0
  479. package/js/src/abstract/bitopro.js +6 -0
  480. package/js/src/abstract/bitrue.js +6 -0
  481. package/js/src/abstract/bitso.js +6 -0
  482. package/js/src/abstract/bitstamp.js +6 -0
  483. package/js/src/abstract/bitteam.js +6 -0
  484. package/js/src/abstract/bittrade.js +6 -0
  485. package/js/src/abstract/bitvavo.js +6 -0
  486. package/js/src/abstract/blockchaincom.js +6 -0
  487. package/js/src/abstract/blofin.d.ts +28 -12
  488. package/js/src/abstract/blofin.js +6 -0
  489. package/js/src/abstract/btcbox.js +6 -0
  490. package/js/src/abstract/btcmarkets.js +6 -0
  491. package/js/src/abstract/btcturk.js +6 -0
  492. package/js/src/abstract/bullish.js +6 -0
  493. package/js/src/abstract/bybit.js +6 -0
  494. package/js/src/abstract/bydfi.js +6 -0
  495. package/js/src/abstract/cex.js +6 -0
  496. package/js/src/abstract/coinbase.js +6 -0
  497. package/js/src/abstract/coinbaseadvanced.js +6 -0
  498. package/js/src/abstract/coinbaseexchange.js +6 -0
  499. package/js/src/abstract/coinbaseinternational.js +6 -0
  500. package/js/src/abstract/coincheck.js +6 -0
  501. package/js/src/abstract/coinex.js +6 -0
  502. package/js/src/abstract/coinmate.js +6 -0
  503. package/js/src/abstract/coinmetro.js +6 -0
  504. package/js/src/abstract/coinone.js +6 -0
  505. package/js/src/abstract/coinsph.js +6 -0
  506. package/js/src/abstract/coinspot.js +6 -0
  507. package/js/src/abstract/cryptocom.js +6 -0
  508. package/js/src/abstract/cryptomus.js +6 -0
  509. package/js/src/abstract/deepcoin.js +6 -0
  510. package/js/src/abstract/delta.js +6 -0
  511. package/js/src/abstract/deribit.js +6 -0
  512. package/js/src/abstract/derive.js +6 -0
  513. package/js/src/abstract/digifinex.js +6 -0
  514. package/js/src/abstract/dydx.js +6 -0
  515. package/js/src/abstract/exmo.js +6 -0
  516. package/js/src/abstract/fmfwio.js +6 -0
  517. package/js/src/abstract/foxbit.js +6 -0
  518. package/js/src/abstract/gate.js +6 -0
  519. package/js/src/abstract/gateio.js +6 -0
  520. package/js/src/abstract/gemini.js +6 -0
  521. package/js/src/abstract/grvt.js +6 -0
  522. package/js/src/abstract/hashkey.js +6 -0
  523. package/js/src/abstract/hibachi.js +6 -0
  524. package/js/src/abstract/hitbtc.js +6 -0
  525. package/js/src/abstract/hollaex.js +6 -0
  526. package/js/src/abstract/htx.js +6 -0
  527. package/js/src/abstract/huobi.js +6 -0
  528. package/js/src/abstract/hyperliquid.js +6 -0
  529. package/js/src/abstract/independentreserve.js +6 -0
  530. package/js/src/abstract/indodax.js +6 -0
  531. package/js/src/abstract/kraken.d.ts +36 -30
  532. package/js/src/abstract/kraken.js +6 -0
  533. package/js/src/abstract/krakenfutures.js +6 -0
  534. package/js/src/abstract/kucoin.d.ts +1 -0
  535. package/js/src/abstract/kucoin.js +6 -0
  536. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  537. package/js/src/abstract/kucoinfutures.js +6 -0
  538. package/js/src/abstract/latoken.js +6 -0
  539. package/js/src/abstract/lbank.js +6 -0
  540. package/js/src/abstract/lighter.js +6 -0
  541. package/js/src/abstract/luno.js +6 -0
  542. package/js/src/abstract/mercado.js +6 -0
  543. package/js/src/abstract/mexc.d.ts +49 -0
  544. package/js/src/abstract/mexc.js +6 -0
  545. package/js/src/abstract/modetrade.js +6 -0
  546. package/js/src/abstract/myokx.js +6 -0
  547. package/js/src/abstract/ndax.js +6 -0
  548. package/js/src/abstract/novadax.js +6 -0
  549. package/js/src/abstract/okx.js +6 -0
  550. package/js/src/abstract/okxus.js +6 -0
  551. package/js/src/abstract/onetrading.js +6 -0
  552. package/js/src/abstract/oxfun.js +6 -0
  553. package/js/src/abstract/p2b.js +6 -0
  554. package/js/src/abstract/pacifica.d.ts +46 -0
  555. package/js/src/abstract/pacifica.js +11 -0
  556. package/js/src/abstract/paradex.js +6 -0
  557. package/js/src/abstract/paymium.js +6 -0
  558. package/js/src/abstract/phemex.js +6 -0
  559. package/js/src/abstract/poloniex.js +6 -0
  560. package/js/src/abstract/tokocrypto.js +6 -0
  561. package/js/src/abstract/toobit.js +6 -0
  562. package/js/src/abstract/upbit.js +6 -0
  563. package/js/src/abstract/wavesexchange.js +6 -0
  564. package/js/src/abstract/whitebit.js +6 -0
  565. package/js/src/abstract/woo.js +6 -0
  566. package/js/src/abstract/woofipro.js +6 -0
  567. package/js/src/abstract/xt.js +6 -0
  568. package/js/src/abstract/yobit.js +6 -0
  569. package/js/src/abstract/zaif.js +6 -0
  570. package/js/src/abstract/zebpay.js +6 -0
  571. package/js/src/abstract/zonda.js +6 -0
  572. package/js/src/aftermath.js +7 -1
  573. package/js/src/alpaca.js +6 -0
  574. package/js/src/apex.js +6 -0
  575. package/js/src/arkham.js +6 -0
  576. package/js/src/ascendex.js +6 -0
  577. package/js/src/aster.js +58 -0
  578. package/js/src/backpack.js +7 -1
  579. package/js/src/base/Exchange.d.ts +3 -0
  580. package/js/src/base/Exchange.js +37 -0
  581. package/js/src/base/Precise.js +6 -0
  582. package/js/src/base/errorHierarchy.js +6 -0
  583. package/js/src/base/errors.js +6 -0
  584. package/js/src/base/functions/crypto.js +6 -0
  585. package/js/src/base/functions/encode.js +6 -0
  586. package/js/src/base/functions/generic.js +6 -0
  587. package/js/src/base/functions/io.js +6 -0
  588. package/js/src/base/functions/misc.js +6 -0
  589. package/js/src/base/functions/number.js +6 -0
  590. package/js/src/base/functions/platform.js +6 -0
  591. package/js/src/base/functions/rsa.js +6 -0
  592. package/js/src/base/functions/string.js +6 -0
  593. package/js/src/base/functions/throttle.js +6 -0
  594. package/js/src/base/functions/time.js +6 -0
  595. package/js/src/base/functions/totp.js +6 -0
  596. package/js/src/base/functions/type.js +6 -0
  597. package/js/src/base/functions.js +6 -0
  598. package/js/src/base/types.js +6 -0
  599. package/js/src/base/ws/Cache.js +6 -0
  600. package/js/src/base/ws/Client.js +6 -0
  601. package/js/src/base/ws/Future.js +6 -0
  602. package/js/src/base/ws/OrderBook.js +6 -0
  603. package/js/src/base/ws/OrderBookSide.js +6 -0
  604. package/js/src/base/ws/WsClient.js +6 -0
  605. package/js/src/base/ws/functions.js +6 -0
  606. package/js/src/bequant.js +6 -0
  607. package/js/src/bigone.js +6 -0
  608. package/js/src/binance.d.ts +0 -1
  609. package/js/src/binance.js +19 -18
  610. package/js/src/binancecoinm.js +6 -0
  611. package/js/src/binanceus.js +6 -0
  612. package/js/src/binanceusdm.js +6 -0
  613. package/js/src/bingx.js +6 -0
  614. package/js/src/bit2c.js +6 -0
  615. package/js/src/bitbank.js +6 -0
  616. package/js/src/bitbns.js +6 -0
  617. package/js/src/bitfinex.js +50 -53
  618. package/js/src/bitflyer.js +6 -0
  619. package/js/src/bitget.d.ts +1 -1
  620. package/js/src/bitget.js +12 -3
  621. package/js/src/bithumb.js +6 -0
  622. package/js/src/bitmart.js +6 -0
  623. package/js/src/bitmex.d.ts +12 -0
  624. package/js/src/bitmex.js +52 -0
  625. package/js/src/bitopro.js +6 -0
  626. package/js/src/bitrue.js +6 -0
  627. package/js/src/bitso.js +6 -0
  628. package/js/src/bitstamp.js +20 -1
  629. package/js/src/bitteam.js +6 -0
  630. package/js/src/bittrade.js +7 -1
  631. package/js/src/bitvavo.js +6 -0
  632. package/js/src/blockchaincom.js +6 -0
  633. package/js/src/blofin.d.ts +4 -1
  634. package/js/src/blofin.js +158 -31
  635. package/js/src/btcbox.js +6 -0
  636. package/js/src/btcmarkets.js +6 -0
  637. package/js/src/btcturk.js +6 -0
  638. package/js/src/bullish.js +6 -0
  639. package/js/src/bybit.js +6 -0
  640. package/js/src/bydfi.js +6 -0
  641. package/js/src/cex.js +6 -0
  642. package/js/src/coinbase.js +6 -0
  643. package/js/src/coinbaseadvanced.js +6 -0
  644. package/js/src/coinbaseexchange.js +6 -0
  645. package/js/src/coinbaseinternational.js +6 -0
  646. package/js/src/coincheck.js +6 -0
  647. package/js/src/coinex.js +6 -0
  648. package/js/src/coinmate.js +6 -0
  649. package/js/src/coinmetro.js +6 -0
  650. package/js/src/coinone.js +6 -0
  651. package/js/src/coinsph.js +10 -0
  652. package/js/src/coinspot.js +6 -0
  653. package/js/src/cryptocom.js +6 -0
  654. package/js/src/cryptomus.js +6 -0
  655. package/js/src/deepcoin.js +6 -0
  656. package/js/src/delta.js +6 -0
  657. package/js/src/deribit.js +6 -0
  658. package/js/src/derive.js +6 -0
  659. package/js/src/digifinex.js +6 -0
  660. package/js/src/dydx.js +6 -0
  661. package/js/src/exmo.js +6 -0
  662. package/js/src/fmfwio.js +6 -0
  663. package/js/src/foxbit.js +6 -0
  664. package/js/src/gate.js +6 -0
  665. package/js/src/gateio.js +6 -0
  666. package/js/src/gemini.js +6 -0
  667. package/js/src/grvt.js +6 -0
  668. package/js/src/hashkey.js +6 -0
  669. package/js/src/hibachi.js +6 -0
  670. package/js/src/hitbtc.js +6 -0
  671. package/js/src/hollaex.js +7 -1
  672. package/js/src/htx.js +6 -0
  673. package/js/src/huobi.js +6 -0
  674. package/js/src/hyperliquid.js +6 -0
  675. package/js/src/independentreserve.js +6 -0
  676. package/js/src/indodax.js +6 -0
  677. package/js/src/kraken.js +45 -31
  678. package/js/src/krakenfutures.js +6 -0
  679. package/js/src/kucoin.d.ts +249 -8
  680. package/js/src/kucoin.js +2164 -461
  681. package/js/src/kucoinfutures.js +6 -0
  682. package/js/src/latoken.js +6 -0
  683. package/js/src/lbank.js +6 -0
  684. package/js/src/lighter.d.ts +4 -2
  685. package/js/src/lighter.js +204 -73
  686. package/js/src/luno.js +6 -0
  687. package/js/src/mercado.js +6 -0
  688. package/js/src/mexc.js +55 -0
  689. package/js/src/modetrade.js +6 -0
  690. package/js/src/myokx.js +6 -0
  691. package/js/src/ndax.js +6 -0
  692. package/js/src/novadax.js +6 -0
  693. package/js/src/okx.js +12 -5
  694. package/js/src/okxus.js +6 -0
  695. package/js/src/onetrading.js +6 -0
  696. package/js/src/oxfun.js +6 -0
  697. package/js/src/p2b.js +6 -0
  698. package/js/src/pacifica.d.ts +531 -0
  699. package/js/src/pacifica.js +3257 -0
  700. package/js/src/paradex.js +6 -0
  701. package/js/src/paymium.js +6 -0
  702. package/js/src/phemex.js +6 -0
  703. package/js/src/poloniex.js +6 -0
  704. package/js/src/pro/aftermath.js +6 -0
  705. package/js/src/pro/alpaca.js +6 -0
  706. package/js/src/pro/apex.js +6 -0
  707. package/js/src/pro/arkham.js +6 -0
  708. package/js/src/pro/ascendex.js +6 -0
  709. package/js/src/pro/aster.js +6 -0
  710. package/js/src/pro/backpack.js +6 -0
  711. package/js/src/pro/bequant.js +6 -0
  712. package/js/src/pro/binance.js +18 -1
  713. package/js/src/pro/binancecoinm.js +6 -0
  714. package/js/src/pro/binanceus.js +6 -0
  715. package/js/src/pro/binanceusdm.js +6 -0
  716. package/js/src/pro/bingx.js +7 -1
  717. package/js/src/pro/bitfinex.js +6 -0
  718. package/js/src/pro/bitget.js +6 -0
  719. package/js/src/pro/bithumb.js +6 -0
  720. package/js/src/pro/bitmart.js +10 -3
  721. package/js/src/pro/bitmex.js +6 -0
  722. package/js/src/pro/bitopro.js +6 -0
  723. package/js/src/pro/bitrue.js +6 -0
  724. package/js/src/pro/bitstamp.js +6 -0
  725. package/js/src/pro/bittrade.js +10 -0
  726. package/js/src/pro/bitvavo.js +14 -0
  727. package/js/src/pro/blockchaincom.js +6 -0
  728. package/js/src/pro/blofin.js +6 -0
  729. package/js/src/pro/bullish.js +6 -0
  730. package/js/src/pro/bybit.js +6 -0
  731. package/js/src/pro/bydfi.js +6 -0
  732. package/js/src/pro/cex.js +6 -0
  733. package/js/src/pro/coinbase.js +6 -0
  734. package/js/src/pro/coinbaseadvanced.js +6 -0
  735. package/js/src/pro/coinbaseexchange.js +6 -0
  736. package/js/src/pro/coinbaseinternational.js +6 -0
  737. package/js/src/pro/coincheck.js +6 -0
  738. package/js/src/pro/coinex.js +6 -0
  739. package/js/src/pro/coinone.js +6 -0
  740. package/js/src/pro/cryptocom.js +6 -0
  741. package/js/src/pro/deepcoin.js +6 -0
  742. package/js/src/pro/deribit.js +6 -0
  743. package/js/src/pro/derive.js +6 -0
  744. package/js/src/pro/dydx.js +6 -0
  745. package/js/src/pro/exmo.js +6 -0
  746. package/js/src/pro/gate.js +9 -0
  747. package/js/src/pro/gateio.js +6 -0
  748. package/js/src/pro/gemini.js +6 -0
  749. package/js/src/pro/grvt.js +7 -1
  750. package/js/src/pro/hashkey.js +6 -0
  751. package/js/src/pro/hitbtc.js +6 -0
  752. package/js/src/pro/hollaex.js +6 -0
  753. package/js/src/pro/htx.js +6 -0
  754. package/js/src/pro/huobi.js +6 -0
  755. package/js/src/pro/hyperliquid.js +6 -0
  756. package/js/src/pro/independentreserve.js +6 -0
  757. package/js/src/pro/kraken.js +6 -0
  758. package/js/src/pro/krakenfutures.js +6 -0
  759. package/js/src/pro/kucoin.js +6 -0
  760. package/js/src/pro/kucoinfutures.js +6 -0
  761. package/js/src/pro/lbank.js +6 -0
  762. package/js/src/pro/lighter.js +42 -17
  763. package/js/src/pro/luno.js +6 -0
  764. package/js/src/pro/mexc.js +6 -0
  765. package/js/src/pro/modetrade.js +6 -0
  766. package/js/src/pro/myokx.js +6 -0
  767. package/js/src/pro/ndax.js +6 -0
  768. package/js/src/pro/okx.js +6 -0
  769. package/js/src/pro/okxus.js +6 -0
  770. package/js/src/pro/onetrading.js +6 -0
  771. package/js/src/pro/oxfun.js +6 -0
  772. package/js/src/pro/p2b.js +6 -0
  773. package/js/src/pro/pacifica.d.ts +267 -0
  774. package/js/src/pro/pacifica.js +1396 -0
  775. package/js/src/pro/paradex.js +6 -0
  776. package/js/src/pro/phemex.js +6 -0
  777. package/js/src/pro/poloniex.js +6 -0
  778. package/js/src/pro/toobit.js +6 -0
  779. package/js/src/pro/upbit.js +6 -0
  780. package/js/src/pro/whitebit.js +6 -0
  781. package/js/src/pro/woo.js +6 -0
  782. package/js/src/pro/woofipro.js +6 -0
  783. package/js/src/pro/xt.js +6 -0
  784. package/js/src/protobuf/mexc/compiled.cjs +6 -0
  785. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +6 -0
  786. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +6 -0
  787. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +6 -0
  788. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +6 -0
  789. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +6 -0
  790. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +6 -0
  791. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +6 -0
  792. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +6 -0
  793. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +6 -0
  794. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +6 -0
  795. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +6 -0
  796. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +6 -0
  797. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +6 -0
  798. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +6 -0
  799. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +6 -0
  800. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +6 -0
  801. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +6 -0
  802. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +6 -0
  803. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +6 -0
  804. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +6 -0
  805. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +6 -0
  806. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +6 -0
  807. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +6 -0
  808. package/js/src/static_dependencies/dydx-v4-client/helpers.js +6 -0
  809. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +6 -0
  810. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +6 -0
  811. package/js/src/static_dependencies/dydx-v4-client/registry.js +6 -0
  812. package/js/src/static_dependencies/ethers/abi-coder.js +6 -0
  813. package/js/src/static_dependencies/ethers/address/address.js +6 -0
  814. package/js/src/static_dependencies/ethers/address/checks.js +6 -0
  815. package/js/src/static_dependencies/ethers/address/contract-address.js +6 -0
  816. package/js/src/static_dependencies/ethers/address/index.js +6 -0
  817. package/js/src/static_dependencies/ethers/bytes32.js +6 -0
  818. package/js/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
  819. package/js/src/static_dependencies/ethers/coders/address.js +6 -0
  820. package/js/src/static_dependencies/ethers/coders/anonymous.js +6 -0
  821. package/js/src/static_dependencies/ethers/coders/array.js +6 -0
  822. package/js/src/static_dependencies/ethers/coders/boolean.js +6 -0
  823. package/js/src/static_dependencies/ethers/coders/bytes.js +6 -0
  824. package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +6 -0
  825. package/js/src/static_dependencies/ethers/coders/null.js +6 -0
  826. package/js/src/static_dependencies/ethers/coders/number.js +6 -0
  827. package/js/src/static_dependencies/ethers/coders/string.js +6 -0
  828. package/js/src/static_dependencies/ethers/coders/tuple.js +6 -0
  829. package/js/src/static_dependencies/ethers/fragments.js +6 -0
  830. package/js/src/static_dependencies/ethers/hash/index.js +6 -0
  831. package/js/src/static_dependencies/ethers/hash/solidity.js +6 -0
  832. package/js/src/static_dependencies/ethers/hash/typed-data.js +6 -0
  833. package/js/src/static_dependencies/ethers/index.js +6 -0
  834. package/js/src/static_dependencies/ethers/interface.js +6 -0
  835. package/js/src/static_dependencies/ethers/typed.js +6 -0
  836. package/js/src/static_dependencies/ethers/utils/base58.js +6 -0
  837. package/js/src/static_dependencies/ethers/utils/base64-browser.js +6 -0
  838. package/js/src/static_dependencies/ethers/utils/base64.js +6 -0
  839. package/js/src/static_dependencies/ethers/utils/data.js +6 -0
  840. package/js/src/static_dependencies/ethers/utils/errors.js +6 -0
  841. package/js/src/static_dependencies/ethers/utils/events.js +6 -0
  842. package/js/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
  843. package/js/src/static_dependencies/ethers/utils/index.js +6 -0
  844. package/js/src/static_dependencies/ethers/utils/maths.js +6 -0
  845. package/js/src/static_dependencies/ethers/utils/properties.js +6 -0
  846. package/js/src/static_dependencies/ethers/utils/rlp-decode.js +6 -0
  847. package/js/src/static_dependencies/ethers/utils/rlp-encode.js +6 -0
  848. package/js/src/static_dependencies/ethers/utils/rlp.js +6 -0
  849. package/js/src/static_dependencies/ethers/utils/units.js +6 -0
  850. package/js/src/static_dependencies/ethers/utils/utf8.js +6 -0
  851. package/js/src/static_dependencies/ethers/utils/uuid.js +6 -0
  852. package/js/src/static_dependencies/fflake/browser.js +6 -0
  853. package/js/src/static_dependencies/jsencrypt/JSEncrypt.js +6 -0
  854. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +6 -0
  855. package/js/src/static_dependencies/jsencrypt/index.js +6 -0
  856. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +6 -0
  857. package/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
  858. package/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
  859. package/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
  860. package/js/src/static_dependencies/jsencrypt/lib/asn1js/oids.js +6 -0
  861. package/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +6 -0
  862. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +6 -0
  863. package/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
  864. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +6 -0
  865. package/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +6 -0
  866. package/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
  867. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +6 -0
  868. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
  869. package/js/src/static_dependencies/messagepack/msgpack.js +6 -0
  870. package/js/src/static_dependencies/noble-curves/_shortw_utils.js +6 -0
  871. package/js/src/static_dependencies/noble-curves/abstract/curve.js +6 -0
  872. package/js/src/static_dependencies/noble-curves/abstract/edwards.js +6 -0
  873. package/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +6 -0
  874. package/js/src/static_dependencies/noble-curves/abstract/modular.js +6 -0
  875. package/js/src/static_dependencies/noble-curves/abstract/montgomery.js +6 -0
  876. package/js/src/static_dependencies/noble-curves/abstract/poseidon.js +6 -0
  877. package/js/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
  878. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +6 -0
  879. package/js/src/static_dependencies/noble-curves/bn.js +6 -0
  880. package/js/src/static_dependencies/noble-curves/ed25519.js +6 -0
  881. package/js/src/static_dependencies/noble-curves/ed448.js +6 -0
  882. package/js/src/static_dependencies/noble-curves/index.js +6 -0
  883. package/js/src/static_dependencies/noble-curves/jubjub.js +6 -0
  884. package/js/src/static_dependencies/noble-curves/p256.js +6 -0
  885. package/js/src/static_dependencies/noble-curves/p384.js +6 -0
  886. package/js/src/static_dependencies/noble-curves/p521.js +6 -0
  887. package/js/src/static_dependencies/noble-curves/pasta.js +6 -0
  888. package/js/src/static_dependencies/noble-curves/secp256k1.js +6 -0
  889. package/js/src/static_dependencies/noble-hashes/_assert.js +6 -0
  890. package/js/src/static_dependencies/noble-hashes/_blake2.js +6 -0
  891. package/js/src/static_dependencies/noble-hashes/_sha2.js +6 -0
  892. package/js/src/static_dependencies/noble-hashes/_u64.js +6 -0
  893. package/js/src/static_dependencies/noble-hashes/argon2.js +6 -0
  894. package/js/src/static_dependencies/noble-hashes/blake2b.js +6 -0
  895. package/js/src/static_dependencies/noble-hashes/blake2s.js +6 -0
  896. package/js/src/static_dependencies/noble-hashes/blake3.js +6 -0
  897. package/js/src/static_dependencies/noble-hashes/crypto.js +6 -0
  898. package/js/src/static_dependencies/noble-hashes/cryptoNode.js +6 -0
  899. package/js/src/static_dependencies/noble-hashes/eskdf.js +6 -0
  900. package/js/src/static_dependencies/noble-hashes/hkdf.js +6 -0
  901. package/js/src/static_dependencies/noble-hashes/hmac.js +6 -0
  902. package/js/src/static_dependencies/noble-hashes/index.js +6 -0
  903. package/js/src/static_dependencies/noble-hashes/md5.js +6 -0
  904. package/js/src/static_dependencies/noble-hashes/pbkdf2.js +6 -0
  905. package/js/src/static_dependencies/noble-hashes/ripemd160.js +6 -0
  906. package/js/src/static_dependencies/noble-hashes/scrypt.js +6 -0
  907. package/js/src/static_dependencies/noble-hashes/sha1.js +6 -0
  908. package/js/src/static_dependencies/noble-hashes/sha256.js +6 -0
  909. package/js/src/static_dependencies/noble-hashes/sha3-addons.js +6 -0
  910. package/js/src/static_dependencies/noble-hashes/sha3.js +6 -0
  911. package/js/src/static_dependencies/noble-hashes/sha512.js +6 -0
  912. package/js/src/static_dependencies/noble-hashes/utils.js +6 -0
  913. package/js/src/static_dependencies/node-fetch/body.js +6 -0
  914. package/js/src/static_dependencies/node-fetch/errors/abort-error.js +6 -0
  915. package/js/src/static_dependencies/node-fetch/errors/base.js +6 -0
  916. package/js/src/static_dependencies/node-fetch/errors/fetch-error.js +6 -0
  917. package/js/src/static_dependencies/node-fetch/headers.js +6 -0
  918. package/js/src/static_dependencies/node-fetch/index.js +6 -0
  919. package/js/src/static_dependencies/node-fetch/request.js +6 -0
  920. package/js/src/static_dependencies/node-fetch/response.js +6 -0
  921. package/js/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
  922. package/js/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
  923. package/js/src/static_dependencies/node-fetch/utils/is.js +6 -0
  924. package/js/src/static_dependencies/node-fetch/utils/referrer.js +6 -0
  925. package/js/src/static_dependencies/proxies/agent-base/helpers.js +6 -0
  926. package/js/src/static_dependencies/proxies/agent-base/index.js +6 -0
  927. package/js/src/static_dependencies/proxies/http-proxy-agent/index.js +6 -0
  928. package/js/src/static_dependencies/proxies/https-proxy-agent/index.js +6 -0
  929. package/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
  930. package/js/src/static_dependencies/qs/formats.js +6 -0
  931. package/js/src/static_dependencies/qs/index.js +6 -0
  932. package/js/src/static_dependencies/qs/parse.js +6 -0
  933. package/js/src/static_dependencies/qs/stringify.js +6 -0
  934. package/js/src/static_dependencies/qs/utils.js +6 -0
  935. package/js/src/static_dependencies/scure-base/index.js +6 -0
  936. package/js/src/static_dependencies/scure-bip32/index.js +6 -0
  937. package/js/src/static_dependencies/scure-bip39/index.js +6 -0
  938. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +6 -0
  939. package/js/src/static_dependencies/scure-starknet/index.js +6 -0
  940. package/js/src/static_dependencies/starknet/constants.js +6 -0
  941. package/js/src/static_dependencies/starknet/index.js +6 -0
  942. package/js/src/static_dependencies/starknet/types/cairoEnum.js +6 -0
  943. package/js/src/static_dependencies/starknet/types/calldata.js +6 -0
  944. package/js/src/static_dependencies/starknet/types/index.js +6 -0
  945. package/js/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
  946. package/js/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
  947. package/js/src/static_dependencies/starknet/types/lib/contract/legacy.js +6 -0
  948. package/js/src/static_dependencies/starknet/types/lib/contract/sierra.js +6 -0
  949. package/js/src/static_dependencies/starknet/types/lib/index.js +6 -0
  950. package/js/src/static_dependencies/starknet/types/typedData.js +6 -0
  951. package/js/src/static_dependencies/starknet/utils/address.js +6 -0
  952. package/js/src/static_dependencies/starknet/utils/assert.js +6 -0
  953. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +6 -0
  954. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +6 -0
  955. package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +6 -0
  956. package/js/src/static_dependencies/starknet/utils/calldata/byteArray.js +6 -0
  957. package/js/src/static_dependencies/starknet/utils/calldata/cairo.js +6 -0
  958. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
  959. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
  960. package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
  961. package/js/src/static_dependencies/starknet/utils/calldata/enum/index.js +6 -0
  962. package/js/src/static_dependencies/starknet/utils/calldata/formatter.js +6 -0
  963. package/js/src/static_dependencies/starknet/utils/calldata/index.js +6 -0
  964. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.js +6 -0
  965. package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.js +6 -0
  966. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +6 -0
  967. package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
  968. package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +6 -0
  969. package/js/src/static_dependencies/starknet/utils/calldata/requestParser.js +6 -0
  970. package/js/src/static_dependencies/starknet/utils/calldata/responseParser.js +6 -0
  971. package/js/src/static_dependencies/starknet/utils/calldata/tuple.js +6 -0
  972. package/js/src/static_dependencies/starknet/utils/calldata/validate.js +6 -0
  973. package/js/src/static_dependencies/starknet/utils/encode.js +6 -0
  974. package/js/src/static_dependencies/starknet/utils/hash/classHash.js +6 -0
  975. package/js/src/static_dependencies/starknet/utils/hash/index.js +6 -0
  976. package/js/src/static_dependencies/starknet/utils/merkle.js +6 -0
  977. package/js/src/static_dependencies/starknet/utils/num.js +6 -0
  978. package/js/src/static_dependencies/starknet/utils/selector.js +6 -0
  979. package/js/src/static_dependencies/starknet/utils/shortString.js +6 -0
  980. package/js/src/static_dependencies/starknet/utils/starknetId.js +6 -0
  981. package/js/src/static_dependencies/starknet/utils/typedData.js +6 -0
  982. package/js/src/static_dependencies/starknet/utils/uint256.js +6 -0
  983. package/js/src/static_dependencies/starknet/utils/url.js +6 -0
  984. package/js/src/static_dependencies/watchable/src/index.js +6 -0
  985. package/js/src/static_dependencies/watchable/src/types.js +6 -0
  986. package/js/src/static_dependencies/watchable/src/unpromise.js +6 -0
  987. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +6 -0
  988. package/js/src/tokocrypto.js +6 -0
  989. package/js/src/toobit.js +6 -0
  990. package/js/src/upbit.js +6 -0
  991. package/js/src/wavesexchange.js +6 -0
  992. package/js/src/whitebit.d.ts +1 -1
  993. package/js/src/whitebit.js +27 -2
  994. package/js/src/woo.js +6 -0
  995. package/js/src/woofipro.js +6 -0
  996. package/js/src/xt.js +6 -0
  997. package/js/src/yobit.js +6 -0
  998. package/js/src/zaif.js +6 -0
  999. package/js/src/zebpay.js +6 -0
  1000. package/js/src/zonda.js +6 -0
  1001. package/package.json +1 -1
  1002. package/dist/cjs/src/coincatch.js +0 -5495
  1003. package/dist/cjs/src/pro/coincatch.js +0 -1563
  1004. package/js/src/abstract/coincatch.d.ts +0 -97
  1005. package/js/src/abstract/coincatch.js +0 -5
  1006. package/js/src/coincatch.d.ts +0 -788
  1007. package/js/src/coincatch.js +0 -5488
  1008. package/js/src/pro/coincatch.d.ts +0 -207
  1009. package/js/src/pro/coincatch.js +0 -1556
@@ -0,0 +1,3254 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var pacifica$1 = require('./abstract/pacifica.js');
6
+ var errors = require('./base/errors.js');
7
+ var Precise = require('./base/Precise.js');
8
+ var number = require('./base/functions/number.js');
9
+ var crypto = require('./base/functions/crypto.js');
10
+ var ed25519 = require('./static_dependencies/noble-curves/ed25519.js');
11
+
12
+ // ----------------------------------------------------------------------------
13
+ // ---------------------------------------------------------------------------
14
+ /**
15
+ * @class pacifica
16
+ * @augments Exchange
17
+ */
18
+ class pacifica extends pacifica$1["default"] {
19
+ describe() {
20
+ return this.deepExtend(super.describe(), {
21
+ 'id': 'pacifica',
22
+ 'name': 'Pacifica',
23
+ 'countries': [],
24
+ 'version': 'v1',
25
+ 'isSandboxModeEnabled': false,
26
+ 'rateLimit': 50,
27
+ 'certified': false,
28
+ 'pro': true,
29
+ 'dex': true,
30
+ 'has': {
31
+ 'CORS': undefined,
32
+ 'spot': false,
33
+ 'margin': false,
34
+ 'swap': true,
35
+ 'future': true,
36
+ 'option': false,
37
+ 'addMargin': false,
38
+ 'borrowCrossMargin': false,
39
+ 'borrowIsolatedMargin': false,
40
+ 'cancelAllOrders': true,
41
+ 'cancelAllOrdersAfter': false,
42
+ 'cancelOrder': true,
43
+ 'cancelOrders': true,
44
+ 'cancelOrdersForSymbols': undefined,
45
+ 'closeAllPositions': false,
46
+ 'closePosition': false,
47
+ 'createMarketBuyOrderWithCost': false,
48
+ 'createMarketOrderWithCost': false,
49
+ 'createMarketSellOrderWithCost': false,
50
+ 'createOrder': true,
51
+ 'createOrders': true,
52
+ 'createOrderWithTakeProfitAndStopLoss': true,
53
+ 'createReduceOnlyOrder': true,
54
+ 'createStopOrder': true,
55
+ 'editOrder': true,
56
+ 'editOrders': false,
57
+ 'fetchAccounts': true,
58
+ 'fetchBalance': true,
59
+ 'fetchBorrowInterest': false,
60
+ 'fetchBorrowRateHistories': false,
61
+ 'fetchBorrowRateHistory': false,
62
+ 'fetchCanceledAndClosedOrders': true,
63
+ 'fetchCanceledOrders': true,
64
+ 'fetchClosedOrders': true,
65
+ 'fetchCrossBorrowRate': false,
66
+ 'fetchCrossBorrowRates': false,
67
+ 'fetchCurrencies': false,
68
+ 'fetchDepositAddress': false,
69
+ 'fetchDepositAddresses': false,
70
+ 'fetchDeposits': false,
71
+ 'fetchDepositWithdrawFee': 'emulated',
72
+ 'fetchDepositWithdrawFees': false,
73
+ 'fetchFundingHistory': true,
74
+ 'fetchFundingRate': false,
75
+ 'fetchFundingRateHistory': true,
76
+ 'fetchFundingRates': true,
77
+ 'fetchIndexOHLCV': false,
78
+ 'fetchIsolatedBorrowRate': false,
79
+ 'fetchIsolatedBorrowRates': false,
80
+ 'fetchLedger': true,
81
+ 'fetchLeverage': true,
82
+ 'fetchLeverageTiers': false,
83
+ 'fetchLiquidations': false,
84
+ 'fetchMarginMode': true,
85
+ 'fetchMarketLeverageTiers': false,
86
+ 'fetchMarkets': true,
87
+ 'fetchMarkOHLCV': false,
88
+ 'fetchMyLiquidations': false,
89
+ 'fetchMyTrades': true,
90
+ 'fetchOHLCV': true,
91
+ 'fetchOpenInterest': true,
92
+ 'fetchOpenInterestHistory': false,
93
+ 'fetchOpenInterests': true,
94
+ 'fetchOpenOrders': true,
95
+ 'fetchOrder': true,
96
+ 'fetchOrderBook': true,
97
+ 'fetchOrders': true,
98
+ 'fetchOrderTrades': false,
99
+ 'fetchPosition': true,
100
+ 'fetchPositionMode': false,
101
+ 'fetchPositions': true,
102
+ 'fetchPositionsRisk': false,
103
+ 'fetchPremiumIndexOHLCV': false,
104
+ 'fetchStatus': undefined,
105
+ 'fetchTicker': 'emulated',
106
+ 'fetchTickers': true,
107
+ 'fetchTime': undefined,
108
+ 'fetchTrades': true,
109
+ 'fetchTradingFee': true,
110
+ 'fetchTradingFees': false,
111
+ 'fetchTransfer': false,
112
+ 'fetchTransfers': false,
113
+ 'fetchWithdrawal': false,
114
+ 'fetchWithdrawals': false,
115
+ 'reduceMargin': false,
116
+ 'repayCrossMargin': false,
117
+ 'repayIsolatedMargin': false,
118
+ 'sandbox': true,
119
+ 'setLeverage': true,
120
+ 'setMarginMode': true,
121
+ 'setPositionMode': false,
122
+ 'transfer': true,
123
+ 'withdraw': true,
124
+ },
125
+ 'timeframes': {
126
+ '1m': '1m',
127
+ '3m': '3m',
128
+ '5m': '5m',
129
+ '15m': '15m',
130
+ '30m': '30m',
131
+ '1h': '1h',
132
+ '2h': '2h',
133
+ '4h': '4h',
134
+ '8h': '8h',
135
+ '12h': '12h',
136
+ '1d': '1d',
137
+ },
138
+ 'hostname': 'pacifica.fi',
139
+ 'urls': {
140
+ 'logo': 'https://github.com/user-attachments/assets/f795515a-828e-4a04-8fca-bf19fcf17ea4',
141
+ 'api': {
142
+ 'public': 'https://api.{hostname}',
143
+ 'private': 'https://api.{hostname}',
144
+ },
145
+ 'test': {
146
+ 'public': 'https://test-api.{hostname}',
147
+ 'private': 'https://test-api.{hostname}',
148
+ },
149
+ 'www': 'https://www.pacifica.fi',
150
+ 'doc': 'https://docs.pacifica.fi/api-documentation/api/rest-api',
151
+ 'fees': 'https://docs.pacifica.fi/trading-on-pacifica/trading-fees',
152
+ 'referral': 'https://app.pacifica.fi?referral=ccxt',
153
+ },
154
+ 'api': {
155
+ 'public': {
156
+ 'get': {
157
+ // ~12 weight depends on the limit 3 max for api-key, but min without api-key
158
+ 'info': 1,
159
+ 'info/prices': 1,
160
+ 'kline': 12,
161
+ 'kline/mark': 12,
162
+ 'book': 1,
163
+ 'trades': 1,
164
+ 'funding_rate/history': 1,
165
+ 'account': 1,
166
+ 'account/settings': 1,
167
+ 'positions': 1,
168
+ 'trades/history': 12,
169
+ 'funding/history': 1,
170
+ 'portfolio': 1,
171
+ 'account/balance/history': 12,
172
+ 'orders': 1,
173
+ 'orders/history': 12,
174
+ 'orders/history_by_id': 1,
175
+ 'account/builder_codes/approvals': 1,
176
+ },
177
+ },
178
+ 'private': {
179
+ 'post': {
180
+ 'account/leverage': 1,
181
+ 'account/margin': 1,
182
+ 'account/withdraw': 1,
183
+ 'account/subaccount/create': 1,
184
+ 'account/subaccount/list': 1,
185
+ 'account/subaccount/transfer': 1,
186
+ 'orders/create': 1,
187
+ 'orders/create_market': 1,
188
+ 'orders/stop/create': 1,
189
+ 'positions/tpsl': 1,
190
+ 'orders/cancel': 0.5,
191
+ 'orders/cancel_all': 0.5,
192
+ 'orders/stop/cancel': 0.5,
193
+ 'orders/edit': 1,
194
+ 'orders/batch': 1,
195
+ 'account/builder_codes/approve': 1,
196
+ 'account/builder_codes/revoke': 1,
197
+ 'agent/bind': 1,
198
+ 'account/api_keys/create': 1,
199
+ 'account/api_keys/revoke': 1,
200
+ 'account/api_keys': 1,
201
+ },
202
+ },
203
+ },
204
+ 'fees': {
205
+ 'swap': {
206
+ 'taker': this.parseNumber('0.0004'),
207
+ 'maker': this.parseNumber('0.00015'),
208
+ },
209
+ },
210
+ //
211
+ // Reminder:
212
+ // If you're using an agent wallet, its private key must also be in the privateKey field in requiredCredentials.
213
+ // However, walletAddress must ALWAYS be equal to the main address. For the agent wallet address, there's a field in options: agentAddress
214
+ //
215
+ 'requiredCredentials': {
216
+ 'apiKey': false,
217
+ 'secret': false,
218
+ 'walletAddress': false,
219
+ 'privateKey': true, // base58 solana private key
220
+ },
221
+ 'exceptions': {
222
+ 'exact': {
223
+ '400': errors.BadRequest,
224
+ '403': errors.PermissionDenied,
225
+ '404': errors.BadRequest,
226
+ '409': errors.ExchangeError,
227
+ '422': errors.ExchangeError,
228
+ '429': errors.RateLimitExceeded,
229
+ '500': errors.ExchangeError,
230
+ '503': errors.ExchangeNotAvailable,
231
+ '504': errors.RequestTimeout,
232
+ },
233
+ 'broad': {
234
+ 'UNKNOWN': errors.ExchangeError,
235
+ 'ACCOUNT_NOT_FOUND': errors.ExchangeError,
236
+ 'BOOK_NOT_FOUND': errors.ExchangeError,
237
+ 'INVALID_TICK_LEVEL': errors.InvalidOrder,
238
+ 'INSUFFICIENT_BALANCE': errors.InsufficientFunds,
239
+ 'ORDER_NOT_FOUND': errors.OrderNotFound,
240
+ 'OVER_WITHDRAWAL': errors.InsufficientFunds,
241
+ 'INVALID_LEVERAGE': errors.ExchangeError,
242
+ 'CANNOT_UPDATE_MARGIN': errors.ExchangeError,
243
+ 'POSITION_NOT_FOUND': errors.ExchangeError,
244
+ 'POSITION_TPSL_LIMIT_EXCEEDED': errors.InvalidOrder,
245
+ },
246
+ },
247
+ 'precisionMode': number.TICK_SIZE,
248
+ 'commonCurrencies': {},
249
+ 'options': {
250
+ 'agentAddress': undefined,
251
+ 'apiKey': undefined,
252
+ 'builderCode': 'CCXT',
253
+ 'feeRate': '0.01',
254
+ 'builderFee': true,
255
+ 'batchOrdersMax': 10,
256
+ 'defaultType': 'swap',
257
+ 'defaultSlippage': '0.5',
258
+ 'expiryWindow': 5000,
259
+ 'maxCostHugeWithApiKey': 3,
260
+ 'marketHelperProps': [],
261
+ 'defaultMarginMode': 'cross',
262
+ 'builderSupportOperations': {
263
+ 'create_market_order': true,
264
+ 'create_limit_order': true,
265
+ 'create_stop_order': true,
266
+ 'set_position_tpsl': true,
267
+ },
268
+ },
269
+ 'features': {
270
+ 'default': {
271
+ 'sandbox': true,
272
+ 'createOrder': {
273
+ 'marginMode': false,
274
+ 'triggerPrice': false,
275
+ 'triggerPriceType': undefined,
276
+ 'triggerDirection': false,
277
+ 'stopLossPrice': false,
278
+ 'takeProfitPrice': false,
279
+ 'attachedStopLossTakeProfit': {
280
+ 'triggerPriceType': {
281
+ 'last': false,
282
+ 'mark': false,
283
+ 'index': false,
284
+ },
285
+ 'triggerPrice': true,
286
+ 'type': true,
287
+ 'price': true,
288
+ },
289
+ 'timeInForce': {
290
+ 'IOC': true,
291
+ 'FOK': false,
292
+ 'PO': true,
293
+ 'GTD': false,
294
+ },
295
+ 'hedged': false,
296
+ 'trailing': false,
297
+ 'leverage': false,
298
+ 'marketBuyByCost': false,
299
+ 'marketBuyRequiresPrice': false,
300
+ 'selfTradePrevention': false,
301
+ 'iceberg': false,
302
+ },
303
+ 'createOrders': {
304
+ 'max': 10,
305
+ },
306
+ 'editOrder': {
307
+ 'side': false,
308
+ 'type': false,
309
+ },
310
+ 'fetchMyTrades': {
311
+ 'marginMode': false,
312
+ 'limit': 100,
313
+ 'daysBack': undefined,
314
+ 'untilDays': undefined,
315
+ 'symbolRequired': false,
316
+ },
317
+ 'fetchOrder': {
318
+ 'marginMode': false,
319
+ 'trigger': false,
320
+ 'trailing': false,
321
+ 'symbolRequired': false,
322
+ },
323
+ 'fetchOpenOrders': {
324
+ 'marginMode': false,
325
+ 'limit': 100,
326
+ 'trigger': false,
327
+ 'trailing': false,
328
+ 'symbolRequired': false,
329
+ },
330
+ 'fetchOrders': {
331
+ 'marginMode': false,
332
+ 'limit': 100,
333
+ 'daysBack': undefined,
334
+ 'untilDays': undefined,
335
+ 'trigger': false,
336
+ 'trailing': false,
337
+ 'symbolRequired': false,
338
+ },
339
+ 'fetchClosedOrders': {
340
+ 'marginMode': false,
341
+ 'limit': 100,
342
+ 'daysBack': undefined,
343
+ 'daysBackCanceled': undefined,
344
+ 'untilDays': undefined,
345
+ 'trigger': false,
346
+ 'trailing': false,
347
+ 'symbolRequired': false,
348
+ },
349
+ 'fetchOHLCV': {
350
+ 'limit': 3950,
351
+ },
352
+ 'fetchLedger': {
353
+ 'code': false,
354
+ },
355
+ },
356
+ 'forPerps': {
357
+ 'extends': 'default',
358
+ 'createOrder': {
359
+ 'stopLossPrice': true,
360
+ 'takeProfitPrice': true,
361
+ 'attachedStopLossTakeProfit': undefined,
362
+ },
363
+ },
364
+ 'spot': undefined,
365
+ 'swap': {
366
+ 'linear': {
367
+ 'extends': 'forPerps',
368
+ },
369
+ 'inverse': {
370
+ 'extends': 'forPerps',
371
+ },
372
+ },
373
+ 'future': {
374
+ 'linear': {
375
+ 'extends': 'forPerps',
376
+ },
377
+ 'inverse': {
378
+ 'extends': 'forPerps',
379
+ },
380
+ },
381
+ },
382
+ });
383
+ }
384
+ async initializeClient() {
385
+ try {
386
+ await this.handleBuilderFeeApproval();
387
+ }
388
+ catch (e) {
389
+ return false;
390
+ }
391
+ return true;
392
+ }
393
+ async handleBuilderFeeApproval() {
394
+ if (this.isSandboxModeEnabled) { // At this stage, building codes are mostly only on the mainnet.
395
+ return false;
396
+ }
397
+ const buildFee = this.safeBool(this.options, 'builderFee', true);
398
+ if (!buildFee) {
399
+ return false; // skip if builder fee is not enabled
400
+ }
401
+ const approvedBuilderFee = this.safeBool(this.options, 'approvedBuilderFee', false);
402
+ if (approvedBuilderFee) {
403
+ return true; // skip if builder fee is already approved
404
+ }
405
+ try {
406
+ const builder = this.safeString(this.options, 'builderCode', 'CCXT'); // case sensitive
407
+ const maxFeeRate = this.safeString(this.options, 'feeRate', '0.01');
408
+ await this.approveBuilderCode(builder, maxFeeRate);
409
+ this.options['approvedBuilderFee'] = true;
410
+ }
411
+ catch (e) {
412
+ this.options['builderFee'] = false; // disable builder fee if an error occurs
413
+ }
414
+ return true;
415
+ }
416
+ /**
417
+ * @method
418
+ * @name pacifica#fetchMarkets
419
+ * @description retrieves data on all markets for pacifica
420
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
421
+ * @returns {object[]} an array of objects representing market data
422
+ */
423
+ async fetchMarkets(params = {}) {
424
+ if (this.checkRequiredCredentials(false)) {
425
+ await this.initializeClient();
426
+ await this.loadAccountSettings();
427
+ }
428
+ const swapMarkets = await this.fetchSwapMarkets(params);
429
+ return swapMarkets;
430
+ }
431
+ /**
432
+ * @method
433
+ * @name pacifica#fetchSwapMarkets
434
+ * @description retrieves data on all swap markets for pacifica
435
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-market-info
436
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
437
+ * @returns {object[]} an array of objects representing market data
438
+ */
439
+ async fetchSwapMarkets(params = {}) {
440
+ const response = await this.publicGetInfo(params); // meta
441
+ // {
442
+ // "success": true,
443
+ // "data": [
444
+ // {
445
+ // "symbol": "ETH",
446
+ // "tick_size": "0.1",
447
+ // "min_tick": "0",
448
+ // "max_tick": "1000000",
449
+ // "lot_size": "0.0001",
450
+ // "max_leverage": 50,
451
+ // "isolated_only": false,
452
+ // "min_order_size": "10",
453
+ // "max_order_size": "5000000",
454
+ // "funding_rate": "0.0000125",
455
+ // "next_funding_rate": "0.0000125",
456
+ // "created_at": 1748881333944
457
+ // },
458
+ // {
459
+ // "symbol": "BTC",
460
+ // "tick_size": "1",
461
+ // "min_tick": "0",
462
+ // "max_tick": "1000000",
463
+ // "lot_size": "0.00001",
464
+ // "max_leverage": 50,
465
+ // "isolated_only": false,
466
+ // "min_order_size": "10",
467
+ // "max_order_size": "5000000",
468
+ // "funding_rate": "0.0000125",
469
+ // "next_funding_rate": "0.0000125",
470
+ // "created_at": 1748881333944
471
+ // },
472
+ // ....
473
+ // ],
474
+ // "error": null,
475
+ // "code": null
476
+ // }
477
+ const meta = this.safeList(response, 'data', []);
478
+ const results = [];
479
+ for (let i = 0; i < meta.length; i++) {
480
+ results.push(meta[i]);
481
+ }
482
+ return this.parseMarkets(results);
483
+ }
484
+ parseMarket(market) {
485
+ // {
486
+ // "symbol": "ETH",
487
+ // "tick_size": "0.1",
488
+ // "min_tick": "0",
489
+ // "max_tick": "1000000",
490
+ // "lot_size": "0.0001",
491
+ // "max_leverage": 50,
492
+ // "isolated_only": false,
493
+ // "min_order_size": "10",
494
+ // "max_order_size": "5000000",
495
+ // "funding_rate": "0.0000125",
496
+ // "next_funding_rate": "0.0000125",
497
+ // "created_at": 1748881333944
498
+ // },
499
+ // {
500
+ // "symbol": "BTC",
501
+ // "tick_size": "1",
502
+ // "min_tick": "0",
503
+ // "max_tick": "1000000",
504
+ // "lot_size": "0.00001",
505
+ // "max_leverage": 50,
506
+ // "isolated_only": false,
507
+ // "min_order_size": "10",
508
+ // "max_order_size": "5000000",
509
+ // "funding_rate": "0.0000125",
510
+ // "next_funding_rate": "0.0000125",
511
+ // "created_at": 1748881333944
512
+ // },
513
+ const quoteId = 'usdc';
514
+ const settleId = 'usdc';
515
+ const id = this.safeString(market, 'symbol');
516
+ const baseId = id.toLowerCase();
517
+ const baseName = id.toUpperCase();
518
+ const base = this.safeCurrencyCode(baseName);
519
+ const quote = this.safeCurrencyCode(quoteId);
520
+ const settle = this.safeCurrencyCode(settleId);
521
+ let symbol = base + '/' + quote;
522
+ const contract = true;
523
+ const swap = true;
524
+ {
525
+ {
526
+ symbol = symbol + ':' + settle;
527
+ }
528
+ }
529
+ const fees = this.safeDict(this.fees, 'swap', {});
530
+ const taker = this.safeNumber(fees, 'taker');
531
+ const maker = this.safeNumber(fees, 'maker');
532
+ const amountPrecisionStr = this.safeString(market, 'lot_size');
533
+ const pricePrecisionStr = this.safeString(market, 'tick_size');
534
+ const active = true; // there is no non-active markets comes from endpoint market info
535
+ return this.safeMarketStructure({
536
+ 'id': id,
537
+ 'symbol': symbol,
538
+ 'base': base,
539
+ 'quote': quote,
540
+ 'settle': settle,
541
+ 'baseId': baseId,
542
+ 'baseName': baseName,
543
+ 'quoteId': quoteId,
544
+ 'settleId': settleId,
545
+ 'type': 'swap',
546
+ 'spot': false,
547
+ 'margin': undefined,
548
+ 'swap': swap,
549
+ 'future': false,
550
+ 'option': false,
551
+ 'active': active,
552
+ 'contract': contract,
553
+ 'linear': true,
554
+ 'inverse': false,
555
+ 'taker': taker,
556
+ 'maker': maker,
557
+ 'contractSize': this.parseNumber('1'),
558
+ 'expiry': undefined,
559
+ 'expiryDatetime': undefined,
560
+ 'strike': undefined,
561
+ 'optionType': undefined,
562
+ 'precision': {
563
+ 'amount': this.parseNumber(amountPrecisionStr),
564
+ 'price': this.parseNumber(pricePrecisionStr),
565
+ },
566
+ 'limits': {
567
+ 'leverage': {
568
+ 'min': 1,
569
+ 'max': this.safeInteger(market, 'max_leverage'),
570
+ },
571
+ 'amount': {
572
+ 'min': undefined,
573
+ 'max': undefined,
574
+ },
575
+ 'price': {
576
+ 'min': this.safeString(market, 'min_tick'),
577
+ 'max': this.safeString(market, 'max_tick'),
578
+ },
579
+ 'cost': {
580
+ 'min': undefined,
581
+ 'max': undefined,
582
+ },
583
+ },
584
+ 'created': undefined,
585
+ 'marginModes': { 'cross': true, 'isolated': true },
586
+ 'info': market,
587
+ });
588
+ }
589
+ /**
590
+ * @method
591
+ * @name pacifica#fetchBalance
592
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
593
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-info
594
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
595
+ * @param {string} [params.account] will default to walletAddress if not provided
596
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
597
+ */
598
+ async fetchBalance(params = {}) {
599
+ let userAccount = undefined;
600
+ [userAccount, params] = this.handleOriginAndSingleAddress('fetchBalance', params);
601
+ const request = {
602
+ 'account': userAccount,
603
+ };
604
+ const response = await this.publicGetAccount(this.extend(request, params));
605
+ // {
606
+ // "success": true,
607
+ // "data": {
608
+ // "balance": "2000.000000",
609
+ // "fee_level": 0,
610
+ // "maker_fee": "0.00015",
611
+ // "taker_fee": "0.0004",
612
+ // "account_equity": "2150.250000",
613
+ // "available_to_spend": "1800.750000",
614
+ // "available_to_withdraw": "1500.850000",
615
+ // "pending_balance": "0.000000",
616
+ // "total_margin_used": "349.500000",
617
+ // "cross_mmr": "420.690000",
618
+ // "positions_count": 2,
619
+ // "orders_count": 3,
620
+ // "stop_orders_count": 1,
621
+ // "updated_at": 1716200000000,
622
+ // "use_ltp_for_stop_orders": false
623
+ // },
624
+ // "error": null,
625
+ // "code": null
626
+ // }
627
+ const data = this.safeDict(response, 'data', {});
628
+ const result = {
629
+ 'info': data,
630
+ };
631
+ result['free'] = {};
632
+ result['used'] = {};
633
+ result['total'] = {};
634
+ const totalBalance = this.safeNumber(data, 'account_equity');
635
+ const usedMargin = this.safeNumber(data, 'total_margin_used');
636
+ const freeBalance = this.safeNumber(data, 'available_to_spend');
637
+ result['total']['USDC'] = totalBalance;
638
+ result['used']['USDC'] = usedMargin;
639
+ result['free']['USDC'] = freeBalance;
640
+ const timestamp = this.safeInteger(data, 'updated_at');
641
+ result['timestamp'] = timestamp;
642
+ result['datetime'] = this.iso8601(timestamp);
643
+ return this.safeBalance(result);
644
+ }
645
+ /**
646
+ * @method
647
+ * @name pacifica#fetchLeverage
648
+ * @description fetch the set leverage for a market
649
+ * @param {string} symbol unified symbol of the market
650
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
651
+ * @param {string} [params.account] will default to walletAddress if not provided
652
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/?id=leverage-structure}
653
+ */
654
+ async fetchLeverage(symbol, params = {}) {
655
+ await this.loadAccountSettings();
656
+ await this.loadMarkets();
657
+ const market = this.market(symbol);
658
+ let userAccount = undefined;
659
+ [userAccount, params] = this.handleOriginAndSingleAddress('fetchLeverage', params);
660
+ const cacheAddress = this.walletAddress;
661
+ let settings = undefined;
662
+ if (userAccount === cacheAddress) {
663
+ settings = this.handleOption('fetchLeverage', 'settings', undefined);
664
+ }
665
+ else {
666
+ const request = {
667
+ 'account': userAccount,
668
+ };
669
+ settings = await this.fetchAccountSettings(this.extend(request, params));
670
+ }
671
+ const setting = this.safeDict(settings, symbol, undefined);
672
+ if (setting === undefined) {
673
+ // NOTE: Upon account creation, all markets have margin settings default to cross margin and leverage default to max.
674
+ // When querying this endpoint, all markets with default margin and leverage settings on this account will return blank.
675
+ return this.parseLeverageFromMarket(market);
676
+ }
677
+ else {
678
+ return this.parseLeverageFromSetting(symbol, setting);
679
+ }
680
+ }
681
+ parseLeverageFromSetting(symbol, setting) {
682
+ // {
683
+ // "WLFI/USDC:USDC": {
684
+ // "symbol": "WLFI",
685
+ // "isolated": false,
686
+ // "leverage": 5,
687
+ // "created_at": 1758085929703,
688
+ // "updated_at": 1758086074002
689
+ // },
690
+ // }
691
+ const isIsolated = this.safeBool(setting, 'isolated', false);
692
+ const leverage = this.safeInteger(setting, 'leverage');
693
+ const marginMode = isIsolated ? 'isolated' : 'cross';
694
+ return {
695
+ 'info': setting,
696
+ 'symbol': symbol,
697
+ 'marginMode': marginMode,
698
+ 'longLeverage': leverage,
699
+ 'shortLeverage': leverage,
700
+ };
701
+ }
702
+ parseLeverageFromMarket(market) {
703
+ const marketLimits = this.safeDict(market, 'limits', {});
704
+ const leverageLimits = this.safeDict(marketLimits, 'leverage', {});
705
+ return {
706
+ 'info': market,
707
+ 'symbol': this.safeString(market, 'symbol'),
708
+ 'marginMode': this.handleOption('fetchLeverage', 'defaultMarginMode', 'cross'),
709
+ 'longLeverage': this.safeInteger(leverageLimits, 'max'),
710
+ 'shortLeverage': this.safeInteger(leverageLimits, 'max'),
711
+ };
712
+ }
713
+ /**
714
+ * @method
715
+ * @name pacifica#fetchAccountSettings
716
+ * @description fetch account's market settings. Settings are cached for walletAddress. To refresh the cache, call loadAccountSettings with refresh=true
717
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-settings
718
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
719
+ * @param {string} [params.account] will default to walletAddress if not provided
720
+ * @returns {object} Dict repacked from list by symbol key
721
+ */
722
+ async fetchAccountSettings(params = {}) {
723
+ let userAccount = undefined;
724
+ [userAccount, params] = this.handleOriginAndSingleAddress('fetchAccountSettings', params);
725
+ const request = {
726
+ 'account': userAccount,
727
+ };
728
+ const response = await this.publicGetAccountSettings(this.extend(request, params));
729
+ // {
730
+ // "success": true,
731
+ // "data": [
732
+ // {
733
+ // "symbol": "WLFI",
734
+ // "isolated": false,
735
+ // "leverage": 5,
736
+ // "created_at": 1758085929703,
737
+ // "updated_at": 1758086074002
738
+ // }
739
+ // ],
740
+ // "error": null,
741
+ // "code": null
742
+ // }
743
+ return this.parseAccountSettings(this.safeList(response, 'data', []));
744
+ }
745
+ async loadAccountSettings(refresh = false, params = {}) {
746
+ let settings = this.handleOption('loadAccountSettings', 'settings', undefined);
747
+ if ((settings === undefined) || (refresh === true)) {
748
+ this.options['settings'] = this.createSafeDictionary();
749
+ settings = await this.fetchAccountSettings(params);
750
+ this.options['settings'] = settings;
751
+ }
752
+ }
753
+ parseAccountSettings(settings) {
754
+ const settingsLen = settings.length;
755
+ if (settingsLen === 0) {
756
+ return {};
757
+ }
758
+ const settingsBySymbol = {};
759
+ for (let i = 0; i < settings.length; i++) {
760
+ const marketId = settings[i]['symbol'];
761
+ const market = this.safeMarket(marketId);
762
+ const symbol = market['symbol'];
763
+ settingsBySymbol[symbol] = settings[i];
764
+ }
765
+ return settingsBySymbol;
766
+ }
767
+ /**
768
+ * @method
769
+ * @name pacifica#fetchMarginMode
770
+ * @description fetches the margin mode of the trading pair
771
+ * @param {string} symbol unified symbol of the market to fetch the margin mode for
772
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
773
+ * @param {string} [params.account] will default to walletAddress if not provided
774
+ * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/?id=margin-mode-structure}
775
+ */
776
+ async fetchMarginMode(symbol, params = {}) {
777
+ await this.loadAccountSettings();
778
+ let userAccount = undefined;
779
+ [userAccount, params] = this.handleOriginAndSingleAddress('fetchMarginMode', params);
780
+ const cacheAddress = this.walletAddress;
781
+ let settings = undefined;
782
+ if (userAccount === cacheAddress) {
783
+ settings = this.handleOption('fetchMarginMode', 'settings', undefined);
784
+ }
785
+ else {
786
+ const request = {
787
+ 'account': userAccount,
788
+ };
789
+ settings = await this.fetchAccountSettings(this.extend(request, params));
790
+ }
791
+ // {
792
+ // "WLFI/USDC:USDC": {
793
+ // "symbol": "WLFI",
794
+ // "isolated": false,
795
+ // "leverage": 5,
796
+ // "created_at": 1758085929703,
797
+ // "updated_at": 1758086074002
798
+ // },
799
+ // }
800
+ const setting = this.safeDict(settings, symbol, undefined);
801
+ if (setting === undefined) {
802
+ // NOTE: Upon account creation, all markets have margin settings default to cross margin and leverage default to max.
803
+ // When querying this endpoint, all markets with default margin and leverage settings on this account will return blank.
804
+ return {
805
+ 'symbol': symbol,
806
+ 'marginMode': this.handleOption('fetchMarginMode', 'defaultMarginMode', 'cross'),
807
+ };
808
+ }
809
+ else {
810
+ return this.parseMarginModeFromSetting(symbol, setting);
811
+ }
812
+ }
813
+ parseMarginModeFromSetting(symbol, setting) {
814
+ // {
815
+ // "symbol": "WLFI",
816
+ // "isolated": false,
817
+ // "leverage": 5,
818
+ // "created_at": 1758085929703,
819
+ // "updated_at": 1758086074002
820
+ //
821
+ // }
822
+ const isIsolated = this.safeBool(setting, 'isolated', false);
823
+ const marginMode = isIsolated ? 'isolated' : 'cross';
824
+ return {
825
+ 'symbol': symbol,
826
+ 'marginMode': marginMode,
827
+ 'info': setting,
828
+ };
829
+ }
830
+ /**
831
+ * @method
832
+ * @name pacifica#fetchOrderBook
833
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
834
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-orderbook
835
+ * @param {string} symbol unified symbol of the market to fetch the order book for
836
+ * @param {int} [limit] the maximum amount of order book entries to return
837
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
838
+ * @param {int} [params.aggLevel] aggregation level for price grouping. Defaults to 1. Can be 1, 10, 100, 1000, 10000
839
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
840
+ */
841
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
842
+ await this.loadMarkets();
843
+ const market = this.market(symbol);
844
+ let aggLevel = undefined;
845
+ [aggLevel, params] = this.handleOptionAndParams(params, 'fetchOrderBook', 'aggLevel', 1);
846
+ const request = {
847
+ 'symbol': market['id'],
848
+ 'agg_level': aggLevel,
849
+ };
850
+ const response = await this.publicGetBook(this.extend(request, params));
851
+ // {
852
+ // "success": true,
853
+ // "data": {
854
+ // "s": "BTC",
855
+ // "l": [
856
+ // [
857
+ // {
858
+ // "p": "106504",
859
+ // "a": "0.26203",
860
+ // "n": 1
861
+ // },
862
+ // {
863
+ // "p": "106498",
864
+ // "a": "0.29281",
865
+ // "n": 1
866
+ // }
867
+ // ],
868
+ // [
869
+ // {
870
+ // "p": "106559",
871
+ // "a": "0.26802",
872
+ // "n": 1
873
+ // },
874
+ // {
875
+ // "p": "106564",
876
+ // "a": "0.3002",
877
+ // "n": 1
878
+ // },
879
+ // ]
880
+ // ],
881
+ // "t": 1751370536325
882
+ // },
883
+ // "error": null,
884
+ // "code": null
885
+ // }
886
+ const data = this.safeDict(response, 'data', {});
887
+ const levels = this.safeList(data, 'l', []);
888
+ const result = {
889
+ 'bids': this.safeList(levels, 0, []),
890
+ 'asks': this.safeList(levels, 1, []),
891
+ };
892
+ const timestamp = this.safeInteger(data, 't');
893
+ return this.parseOrderBook(result, this.safeSymbol(undefined, market), timestamp, 'bids', 'asks', 'p', 'a');
894
+ }
895
+ /**
896
+ * @method
897
+ * @name pacifica#fetchFundingRates
898
+ * @description retrieves data on all swap markets for pacifica
899
+ * @param {string[]} [symbols] list of unified market symbols
900
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
901
+ * @returns {object[]} an array of objects representing market data
902
+ */
903
+ async fetchFundingRates(symbols = undefined, params = {}) {
904
+ const response = await this.publicGetInfoPrices(params);
905
+ //
906
+ // {
907
+ // "success": true,
908
+ // "data": [
909
+ // {
910
+ // "funding": "0.00010529",
911
+ // "mark": "1.084819",
912
+ // "mid": "1.08615",
913
+ // "next_funding": "0.00011096",
914
+ // "open_interest": "3634796",
915
+ // "oracle": "1.084524",
916
+ // "symbol": "XPL",
917
+ // "timestamp": 1759222967974,
918
+ // "volume_24h": "20896698.0672",
919
+ // "yesterday_price": "1.3412"
920
+ // }
921
+ // ],
922
+ // "error": null,
923
+ // "code": null
924
+ // }
925
+ //
926
+ const result = this.safeList(response, 'data', []);
927
+ return this.parseFundingRates(result, symbols);
928
+ }
929
+ parseFundingRate(info, market = undefined) {
930
+ //
931
+ // {
932
+ // "funding": "0.00010529",
933
+ // "mark": "1.084819",
934
+ // "mid": "1.08615",
935
+ // "next_funding": "0.00011096",
936
+ // "open_interest": "3634796",
937
+ // "oracle": "1.084524",
938
+ // "symbol": "XPL",
939
+ // "timestamp": 1759222967974,
940
+ // "volume_24h": "20896698.0672",
941
+ // "yesterday_price": "1.3412"
942
+ // }
943
+ //
944
+ const marketId = this.safeString(info, 'symbol');
945
+ market = this.safeMarket(marketId, market);
946
+ const symbol = market['symbol'];
947
+ const funding = this.safeNumber(info, 'funding');
948
+ const markPx = this.safeNumber(info, 'mark');
949
+ const oraclePx = this.safeNumber(info, 'oracle');
950
+ const nextFundingRate = this.safeNumber(info, 'next_funding');
951
+ const timestamp = this.safeInteger(info, 'timestamp');
952
+ const fundingTimestamp = (Math.floor(this.milliseconds() / 60 / 60 / 1000) + 1) * 60 * 60 * 1000;
953
+ return {
954
+ 'info': info,
955
+ 'symbol': symbol,
956
+ 'markPrice': markPx,
957
+ 'indexPrice': oraclePx,
958
+ 'interestRate': undefined,
959
+ 'estimatedSettlePrice': undefined,
960
+ 'timestamp': timestamp,
961
+ 'datetime': this.iso8601(timestamp),
962
+ 'fundingRate': funding,
963
+ 'fundingTimestamp': fundingTimestamp,
964
+ 'fundingDatetime': this.iso8601(fundingTimestamp),
965
+ 'nextFundingRate': nextFundingRate,
966
+ 'nextFundingTimestamp': undefined,
967
+ 'nextFundingDatetime': undefined,
968
+ 'previousFundingRate': undefined,
969
+ 'previousFundingTimestamp': undefined,
970
+ 'previousFundingDatetime': undefined,
971
+ 'interval': '1h',
972
+ };
973
+ }
974
+ /**
975
+ * @method
976
+ * @name pacifica#fetchOHLCV
977
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
978
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-candle-data
979
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
980
+ * @param {string} timeframe the length of time each candle represents, support '1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '8h', '12h', '1d'
981
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
982
+ * @param {int} [limit] the maximum amount of candles to fetch
983
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
984
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch. 'limit' is priority
985
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params
986
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
987
+ */
988
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
989
+ if (since === undefined) {
990
+ throw new errors.ArgumentsRequired(this.id + ' fetchOHLCV() requires a "since" argument');
991
+ }
992
+ if (symbol === undefined) {
993
+ throw new errors.ArgumentsRequired(this.id + ' fetchOHLCV() requires a "symbol" argument');
994
+ }
995
+ const defaultMaxLimit = 3950; // 4000 by docs, but in fact >~3960 returns error
996
+ await this.loadMarkets();
997
+ const market = this.market(symbol);
998
+ let paginate = false;
999
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
1000
+ if (paginate) {
1001
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, defaultMaxLimit);
1002
+ }
1003
+ else {
1004
+ const tf = this.safeString(this.timeframes, timeframe, timeframe);
1005
+ let request = {
1006
+ 'symbol': market['id'],
1007
+ 'interval': tf,
1008
+ 'start_time': since,
1009
+ };
1010
+ [request, params] = this.handleUntilOption('end_time', request, params);
1011
+ const nowMillis = this.milliseconds();
1012
+ let until = this.safeInteger(request, 'end_time');
1013
+ if (until === undefined) {
1014
+ if (limit !== undefined) {
1015
+ until = since + (limit * (this.parseTimeframe(tf) * 1000)) - 1;
1016
+ }
1017
+ if (until === undefined) {
1018
+ until = since + (defaultMaxLimit * (this.parseTimeframe(tf) * 1000)) - 1;
1019
+ }
1020
+ if (until > nowMillis) {
1021
+ until = nowMillis;
1022
+ }
1023
+ request['end_time'] = until;
1024
+ }
1025
+ const response = await this.publicGetKline(this.extend(request, params));
1026
+ //
1027
+ // {
1028
+ // "success": true,
1029
+ // "data": [
1030
+ // {
1031
+ // "t": 1748954160000,
1032
+ // "T": 1748954220000,
1033
+ // "s": "BTC",
1034
+ // "i": "1m",
1035
+ // "o": "105376",
1036
+ // "c": "105376",
1037
+ // "h": "105376",
1038
+ // "l": "105376",
1039
+ // "v": "0.00022",
1040
+ // "n": 2
1041
+ // }
1042
+ // ],
1043
+ // "error": null,
1044
+ // "code": null
1045
+ // }
1046
+ //
1047
+ const candles = this.safeList(response, 'data', []);
1048
+ return this.parseOHLCVs(candles, market, timeframe, since, limit);
1049
+ }
1050
+ }
1051
+ parseOHLCV(ohlcv, market = undefined) {
1052
+ //
1053
+ // {
1054
+ // "t": 1748954160000,
1055
+ // "T": 1748954220000,
1056
+ // "s": "BTC",
1057
+ // "i": "1m",
1058
+ // "o": "105376",
1059
+ // "c": "105376",
1060
+ // "h": "105376",
1061
+ // "l": "105376",
1062
+ // "v": "0.00022",
1063
+ // "n": 2
1064
+ // }
1065
+ //
1066
+ return [
1067
+ this.safeInteger(ohlcv, 't'),
1068
+ this.safeNumber(ohlcv, 'o'),
1069
+ this.safeNumber(ohlcv, 'h'),
1070
+ this.safeNumber(ohlcv, 'l'),
1071
+ this.safeNumber(ohlcv, 'c'),
1072
+ this.safeNumber(ohlcv, 'v'),
1073
+ ];
1074
+ }
1075
+ /**
1076
+ * @method
1077
+ * @name pacifica#fetchTrades
1078
+ * @description get the list of most recent trades for a particular symbol
1079
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-recent-trades
1080
+ * @param {string} symbol unified market symbol
1081
+ * @param {int} [since] the earliest time in ms to fetch trades for
1082
+ * @param {int} [limit] the maximum number of trades structures to retrieve
1083
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1084
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
1085
+ */
1086
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1087
+ await this.loadMarkets();
1088
+ const market = this.market(symbol);
1089
+ const request = {
1090
+ 'symbol': market['id'],
1091
+ };
1092
+ const response = await this.publicGetTrades(this.extend(request, params));
1093
+ //
1094
+ // {
1095
+ // "success": true,
1096
+ // "data": [
1097
+ // {
1098
+ // "event_type": "fulfill_taker",
1099
+ // "price": "104721",
1100
+ // "amount": "0.0001",
1101
+ // "side": "close_long",
1102
+ // "cause": "normal",
1103
+ // "created_at": 1765006315306
1104
+ // }
1105
+ // ],
1106
+ // "error": null,
1107
+ // "code": null,
1108
+ // "last_order_id": 1557404170
1109
+ // }
1110
+ //
1111
+ const recentTrades = this.safeList(response, 'data', []);
1112
+ return this.parseTrades(recentTrades, market, since, limit);
1113
+ }
1114
+ /**
1115
+ * @method
1116
+ * @name pacifica#fetchMyTrades
1117
+ * @description fetch all trades made by the user
1118
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-trade-history
1119
+ * @param {string} [symbol] unified market symbol
1120
+ * @param {int} [since] the earliest time in ms to fetch trades for
1121
+ * @param {int} [limit] the maximum number of trades structures to retrieve
1122
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1123
+ * @param {int} [params.until] timestamp in ms of the latest trade
1124
+ * @param {string} [params.account] will default to walletAddress if not provided
1125
+ * @param {string} [params.cursor] pagination cursor from prev request (manual use)
1126
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1127
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
1128
+ */
1129
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1130
+ await this.loadMarkets();
1131
+ let market = undefined;
1132
+ if (symbol !== undefined) {
1133
+ market = this.market(symbol);
1134
+ }
1135
+ let paginate = false;
1136
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate', false);
1137
+ let userAddress = undefined;
1138
+ [userAddress, params] = this.handleOriginAndSingleAddress('fetchMyTrades', params);
1139
+ const defaultLimit = 100; // Default max limit
1140
+ if (paginate) {
1141
+ return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'next_cursor', 'cursor', undefined, defaultLimit);
1142
+ }
1143
+ let request = {};
1144
+ [request, params] = this.handleUntilOption('end_time', request, params);
1145
+ request['account'] = userAddress;
1146
+ if (symbol !== undefined) {
1147
+ request['symbol'] = market['id'];
1148
+ }
1149
+ if (limit !== undefined) {
1150
+ request['limit'] = limit;
1151
+ }
1152
+ if (since !== undefined) {
1153
+ request['start_time'] = since;
1154
+ }
1155
+ const response = await this.publicGetTradesHistory(this.extend(request, params));
1156
+ //
1157
+ // {
1158
+ // "success": true,
1159
+ // "data": [
1160
+ // {
1161
+ // "history_id": 19329801,
1162
+ // "order_id": 315293920,
1163
+ // "client_order_id": "acf...",
1164
+ // "symbol": "LDO",
1165
+ // "amount": "0.1",
1166
+ // "price": "1.1904",
1167
+ // "entry_price": "1.176247",
1168
+ // "fee": "0",
1169
+ // "pnl": "-0.001415",
1170
+ // "event_type": "fulfill_maker",
1171
+ // "side": "close_short",
1172
+ // "created_at": 1759215599188,
1173
+ // "cause": "normal"
1174
+ // },
1175
+ // ...
1176
+ // ],
1177
+ // "next_cursor": "11111Z5RK", // not included to info!
1178
+ // "has_more": true // not included to info!
1179
+ // }
1180
+ //
1181
+ const data = this.addPaginationCursorToResult(response);
1182
+ return this.parseTrades(data, market, since, limit);
1183
+ }
1184
+ parseTrade(trade, market = undefined) {
1185
+ //
1186
+ // user trades:
1187
+ // {
1188
+ // "history_id": 19329801,
1189
+ // "order_id": 315293920,
1190
+ // "client_order_id": "acf...",
1191
+ // "symbol": "LDO",
1192
+ // "amount": "0.1",
1193
+ // "price": "1.1904",
1194
+ // "entry_price": "1.176247",
1195
+ // "fee": "0",
1196
+ // "pnl": "-0.001415",
1197
+ // "event_type": "fulfill_maker",
1198
+ // "side": "close_short",
1199
+ // "created_at": 1759215599188,
1200
+ // "cause": "normal"
1201
+ // },
1202
+ // recent public trades:
1203
+ // {
1204
+ // "event_type": "fulfill_taker",
1205
+ // "price": "104721",
1206
+ // "amount": "0.0001",
1207
+ // "side": "close_long",
1208
+ // "cause": "normal",
1209
+ // "created_at": 1765006315306
1210
+ // }
1211
+ //
1212
+ const eventType = this.safeString(trade, 'event_type');
1213
+ const timestamp = this.safeInteger(trade, 'created_at');
1214
+ const price = this.safeString(trade, 'price');
1215
+ const amount = this.safeString(trade, 'amount');
1216
+ const symbol = this.safeSymbol(undefined, market);
1217
+ const id = this.safeString(trade, 'history_id');
1218
+ let side = this.safeString(trade, 'side');
1219
+ if (side === 'open_long') {
1220
+ side = 'buy';
1221
+ }
1222
+ else if (side === 'close_long') {
1223
+ side = 'sell';
1224
+ }
1225
+ else if (side === 'open_short') {
1226
+ side = 'sell';
1227
+ }
1228
+ else if (side === 'close_short') {
1229
+ side = 'buy';
1230
+ }
1231
+ const fee = this.safeString(trade, 'fee');
1232
+ const orderId = this.safeString(trade, 'order_id');
1233
+ let takerOrMaker = undefined;
1234
+ if (eventType !== undefined) {
1235
+ takerOrMaker = (eventType === 'fulfill_maker') ? 'maker' : 'taker';
1236
+ }
1237
+ // public trades have no orderId
1238
+ if (orderId === undefined) {
1239
+ takerOrMaker = undefined;
1240
+ }
1241
+ return this.safeTrade({
1242
+ 'info': trade,
1243
+ 'timestamp': timestamp,
1244
+ 'datetime': this.iso8601(timestamp),
1245
+ 'symbol': symbol,
1246
+ 'id': id,
1247
+ 'order': orderId,
1248
+ 'type': undefined,
1249
+ 'side': side,
1250
+ 'takerOrMaker': takerOrMaker,
1251
+ 'price': price,
1252
+ 'amount': amount,
1253
+ 'cost': undefined,
1254
+ 'fee': {
1255
+ 'cost': fee,
1256
+ 'currency': 'USDC',
1257
+ 'rate': undefined,
1258
+ },
1259
+ }, market);
1260
+ }
1261
+ /**
1262
+ * @method
1263
+ * @name pacifica#createOrder
1264
+ * @description create a trade order
1265
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-limit-order
1266
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-market-order
1267
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-stop-order
1268
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-position-tp-sl
1269
+ * @param {string} symbol unified symbol of the market to create an order in
1270
+ * @param {string} type 'market' or 'limit'
1271
+ * @param {string} side 'buy' or 'sell'
1272
+ * @param {float} amount how much of currency you want to trade in units of base currency. Not used for set tpsl order!
1273
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1274
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1275
+ * @param {float} [params.triggerPrice] The price a trigger order is triggered at
1276
+ * @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at (optional provide stopLossCloid)
1277
+ * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at (optional provide takeProfitCloid)
1278
+ * @param {string} [params.timeInForce] "GTC", "IOC", or "PO" or "ALO" or "PO_TOB" (or "TOB" - PO by top of book)
1279
+ * @param {boolean} [params.reduceOnly] Ensures that the executed order does not flip the opened position.
1280
+ * @param {string} [params.clientOrderId] client order id, (optional uuid v4 e.g.: f47ac10b-58cc-4372-a567-0e02b2c3d479)
1281
+ * @param {int} [params.expiryWindow] time to live in milliseconds
1282
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1283
+ */
1284
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1285
+ await this.loadMarkets();
1286
+ await this.initializeClient();
1287
+ const [request, operationType] = this.createOrderRequest(symbol, type, side, amount, price, params);
1288
+ params = this.omit(params, [
1289
+ 'reduceOnly', 'clientOrderId', 'stopLimitPrice', 'timeInForce', 'triggerPrice', 'stopLossCloid',
1290
+ 'stopLossPrice', 'stopLossLimitPrice', 'takeProfitCloid', 'takeProfitPrice', 'takeProfitLimitPrice', 'expiryWindow',
1291
+ ]);
1292
+ let response = undefined;
1293
+ if (operationType === 'create_market_order') {
1294
+ response = await this.privatePostOrdersCreateMarket(this.extend(request, params));
1295
+ }
1296
+ else if (operationType === 'create_stop_order') {
1297
+ response = await this.privatePostOrdersStopCreate(this.extend(request, params));
1298
+ }
1299
+ else if (operationType === 'set_position_tpsl') {
1300
+ response = await this.privatePostPositionsTpsl(this.extend(request, params));
1301
+ }
1302
+ else { // create_order
1303
+ response = await this.privatePostOrdersCreate(this.extend(request, params));
1304
+ }
1305
+ //
1306
+ // {
1307
+ // 'success': true,
1308
+ // 'data': {
1309
+ // "order_id": 12345
1310
+ // },
1311
+ // }
1312
+ //
1313
+ const success = this.safeBool(response, 'success', false);
1314
+ let status = undefined;
1315
+ if (!success) {
1316
+ status = 'rejected';
1317
+ }
1318
+ else {
1319
+ status = 'open';
1320
+ }
1321
+ const order = this.safeDict(response, 'data', {});
1322
+ const orderId = this.safeString(order, 'order_id');
1323
+ return this.safeOrder({ 'id': orderId, 'status': status, 'info': response, 'symbol': symbol });
1324
+ }
1325
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1326
+ /**
1327
+ * @method
1328
+ * @ignore
1329
+ * @name pacifica#createOrderRequest
1330
+ * @description create a trade order
1331
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-limit-order
1332
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-market-order
1333
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-stop-order
1334
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-position-tp-sl
1335
+ * @param {string} symbol unified symbol of the market to create an order in
1336
+ * @param {string} type 'market' or 'limit'
1337
+ * @param {string} side 'buy' or 'sell'
1338
+ * @param {float} amount how much of currency you want to trade in units of base currency
1339
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders, but can be used as limit_price of Trigger Order.
1340
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1341
+ * @param {float} [params.triggerPrice] The price a trigger order is triggered at
1342
+ * @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at (optional provide stopLossCloid)
1343
+ * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at (optional provide takeProfitCloid)
1344
+ * @param {string} [params.timeInForce] "GTC", "IOC", or "PO" or "ALO" or "PO_TOB" (or "TOB" - PO by top of book)
1345
+ * @param {boolean} [params.reduceOnly] Ensures that the executed order does not flip the opened position.
1346
+ * @param {string} [params.clientOrderId] client order id, (optional uuid v4 e.g.: f47ac10b-58cc-4372-a567-0e02b2c3d479)
1347
+ * @param {int} [params.expiryWindow] time to live in milliseconds
1348
+ * @returns {object} an [order structure]
1349
+ */
1350
+ const market = this.market(symbol);
1351
+ const sigPayload = {
1352
+ 'symbol': market['id'],
1353
+ 'side': this.mapSide(side),
1354
+ };
1355
+ let operationType = undefined;
1356
+ const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only', false);
1357
+ const orderType = type.toUpperCase();
1358
+ const triggerPrice = this.safeString(params, 'triggerPrice');
1359
+ const stopLossPrice = this.safeString(params, 'stopLossPrice');
1360
+ const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
1361
+ const tifRaw = this.safeStringUpper(params, 'timeInForce');
1362
+ const isMarket = orderType === 'MARKET';
1363
+ const isTakeProfitOrder = (takeProfitPrice !== undefined);
1364
+ const isStopLossOrder = (stopLossPrice !== undefined);
1365
+ const isStopOrder = (triggerPrice !== undefined);
1366
+ const timeInForce = this.mapTimeInForce(tifRaw);
1367
+ if (isMarket) {
1368
+ operationType = 'create_market_order';
1369
+ sigPayload['reduce_only'] = reduceOnly;
1370
+ const defaultSlippage = this.handleOption('createOrder', 'defaultSlippage', '0.5');
1371
+ const slippage = this.safeString2(params, 'slippage', 'slippage_percent', defaultSlippage);
1372
+ sigPayload['slippage_percent'] = slippage;
1373
+ }
1374
+ else if ((isTakeProfitOrder || isStopLossOrder) && (price === undefined)) { // the tpsl endpoint does not accept a 'price' parameter
1375
+ operationType = 'set_position_tpsl';
1376
+ }
1377
+ else if (isStopOrder) {
1378
+ operationType = 'create_stop_order';
1379
+ sigPayload['reduce_only'] = reduceOnly;
1380
+ const stopClientOrderId = this.safeString(params, 'clientOrderId');
1381
+ params = this.omit(params, ['clientOrderId']);
1382
+ const stopPayload = {
1383
+ 'amount': this.amountToPrecision(symbol, amount),
1384
+ 'stop_price': this.priceToPrecision(symbol, triggerPrice),
1385
+ };
1386
+ if (stopClientOrderId !== undefined) {
1387
+ stopPayload['client_order_id'] = stopClientOrderId;
1388
+ }
1389
+ if (price !== undefined) {
1390
+ stopPayload['limit_price'] = this.priceToPrecision(symbol, price);
1391
+ }
1392
+ sigPayload['stop_order'] = stopPayload;
1393
+ }
1394
+ else {
1395
+ operationType = 'create_order';
1396
+ sigPayload['reduce_only'] = reduceOnly;
1397
+ if (timeInForce === undefined) {
1398
+ sigPayload['tif'] = 'GTC';
1399
+ }
1400
+ else {
1401
+ sigPayload['tif'] = timeInForce;
1402
+ }
1403
+ }
1404
+ if (isTakeProfitOrder) {
1405
+ const tpPayload = {
1406
+ 'stop_price': this.priceToPrecision(symbol, takeProfitPrice),
1407
+ };
1408
+ if (price !== undefined) {
1409
+ tpPayload['limit_price'] = this.priceToPrecision(symbol, price);
1410
+ }
1411
+ sigPayload['take_profit'] = tpPayload;
1412
+ }
1413
+ if (isStopLossOrder) {
1414
+ const slPayload = {
1415
+ 'stop_price': this.priceToPrecision(symbol, stopLossPrice),
1416
+ };
1417
+ if (price !== undefined) {
1418
+ slPayload['limit_price'] = this.priceToPrecision(symbol, price);
1419
+ }
1420
+ sigPayload['stop_loss'] = slPayload;
1421
+ }
1422
+ if (price !== undefined && operationType === 'create_order') {
1423
+ sigPayload['price'] = this.priceToPrecision(symbol, price);
1424
+ }
1425
+ if (amount !== undefined && (operationType !== 'create_stop_order' && operationType !== 'set_position_tpsl')) {
1426
+ sigPayload['amount'] = this.amountToPrecision(symbol, amount);
1427
+ }
1428
+ const clientOrderId = this.safeStringN(params, ['clientOrderId']);
1429
+ if (clientOrderId !== undefined) {
1430
+ sigPayload['client_order_id'] = clientOrderId;
1431
+ }
1432
+ const request = this.postActionRequest(operationType, sigPayload, params);
1433
+ return [request, operationType];
1434
+ }
1435
+ batchOrdersRequest(actions) {
1436
+ //
1437
+ // [
1438
+ // {
1439
+ // "type":"Create",
1440
+ // "data":{
1441
+ // "account":"42trU9A5...",
1442
+ // "signature":"5UpRZ14Q...",
1443
+ // "timestamp":1749190500355,
1444
+ // "expiry_window":5000,
1445
+ // "symbol":"BTC",
1446
+ // "price":"100000",
1447
+ // "reduce_only":false,
1448
+ // "amount":"0.1",
1449
+ // "side":"bid",
1450
+ // "tif":"GTC",
1451
+ // "client_order_id":"57a5efb1-bb96-49a5-8bfd-f25d5f22bc7e"
1452
+ // }
1453
+ // },
1454
+ // {
1455
+ // "type":"Cancel",
1456
+ // "data":{
1457
+ // "account":"42trU9A5...",
1458
+ // "signature":"4NDFHyTG...",
1459
+ // "timestamp":1749190500355,
1460
+ // "expiry_window":5000,
1461
+ // "symbol":"BTC",
1462
+ // "order_id":42069
1463
+ // }
1464
+ // }
1465
+ // ]
1466
+ //
1467
+ // Create (Only Limit or Market, never stop order or tpsl order)
1468
+ // Cancel (Only common (limit) orders)
1469
+ //
1470
+ const lenActions = actions.length;
1471
+ const maxLen = this.handleOption('batchOrdersRequest', 'batchOrdersMax');
1472
+ if (maxLen !== undefined) {
1473
+ if (lenActions > maxLen) {
1474
+ throw new errors.ExchangeError(this.id + ' batchOrdersRequest() too many orders to create/cancel. Limit is ' + maxLen);
1475
+ }
1476
+ }
1477
+ return {
1478
+ 'actions': actions,
1479
+ };
1480
+ }
1481
+ createOrdersRequest(orders, params = {}) {
1482
+ const actions = [];
1483
+ const timestamp = this.milliseconds(); // unified sequence
1484
+ for (let i = 0; i < orders.length; i++) {
1485
+ const order = orders[i];
1486
+ const symbol = this.safeString(order, 'symbol');
1487
+ const side = this.safeString(order, 'side');
1488
+ const price = this.safeString(order, 'price');
1489
+ const type = this.safeString(order, 'type', 'limit');
1490
+ const orderParams = this.safeDict(order, 'params', {});
1491
+ orderParams['timestamp'] = timestamp;
1492
+ const amount = this.safeString(order, 'amount');
1493
+ const amountNumber = this.parseNumber(amount);
1494
+ const priceNumber = this.parseNumber(price);
1495
+ if (type !== 'limit') {
1496
+ throw new errors.NotSupported(this.id + ' createOrders() supports only type = "limit"! Your value type=' + type);
1497
+ }
1498
+ const requestList = this.createOrderRequest(symbol, type, side, amountNumber, priceNumber, orderParams);
1499
+ const action = {
1500
+ 'type': 'Create',
1501
+ 'data': requestList[0],
1502
+ };
1503
+ actions.push(action);
1504
+ }
1505
+ return this.batchOrdersRequest(actions);
1506
+ }
1507
+ /**
1508
+ * @method
1509
+ * @name pacifica#createOrders
1510
+ * @description create a list of trade orders. It is supports only limit orders and have a random jitter ~100-300ms!
1511
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/batch-order
1512
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type (optional or 'limit'), side, amount, price and params
1513
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1514
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1515
+ */
1516
+ async createOrders(orders, params = {}) {
1517
+ await this.loadMarkets();
1518
+ await this.initializeClient();
1519
+ const request = this.createOrdersRequest(orders);
1520
+ const response = await this.privatePostOrdersBatch(this.extend(request, params));
1521
+ // {
1522
+ // "success": true,
1523
+ // "data": {
1524
+ // "results": [
1525
+ // {
1526
+ // "success": true,
1527
+ // "order_id": 470506,
1528
+ // "error": null
1529
+ // },
1530
+ // {
1531
+ // "success": true,
1532
+ // }
1533
+ // ]
1534
+ // },
1535
+ // "error": null,
1536
+ // "code": null
1537
+ // }
1538
+ //
1539
+ const data = this.safeDict(response, 'data', {});
1540
+ const results = this.safeList(data, 'results', []);
1541
+ const ordersToReturn = [];
1542
+ for (let i = 0; i < results.length; i++) {
1543
+ const order = results[i];
1544
+ const error = this.safeString(order, 'error', undefined);
1545
+ const success = this.safeBool(order, 'success', false);
1546
+ let status = undefined;
1547
+ if ((error !== undefined) || (!success)) {
1548
+ status = 'rejected';
1549
+ }
1550
+ else {
1551
+ status = 'open';
1552
+ }
1553
+ const orderId = this.safeString(order, 'order_id');
1554
+ ordersToReturn.push(this.safeOrder({ 'info': order, 'id': orderId, 'status': status }));
1555
+ }
1556
+ return ordersToReturn;
1557
+ }
1558
+ /**
1559
+ * @method
1560
+ * @name pacifica#cancelOrders
1561
+ * @description cancel multiple orders
1562
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/batch-order
1563
+ * @param {string[]} ids order ids. An ids list is always required (can be empty). Both ids and clientOrderIds can be passed simultaneously.
1564
+ * @param {string} [symbol] unified market symbol
1565
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1566
+ * @param {string|string[]} [params.clientOrderIds] client order ids, (optional uuid v4 e.g.: f47ac10b-58cc-4372-a567-0e02b2c3d479)
1567
+ * @param {int} [params.expiryWindow] time to live in milliseconds
1568
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1569
+ */
1570
+ async cancelOrders(ids, symbol = undefined, params = {}) {
1571
+ await this.loadMarkets();
1572
+ await this.initializeClient();
1573
+ if (symbol === undefined) {
1574
+ throw new errors.ArgumentsRequired(this.id + ' cancelOrders() requires a "symbol" argument!');
1575
+ }
1576
+ const request = this.cancelOrdersRequest(ids, symbol, params);
1577
+ params = this.omit(params, ['expiryWindow', 'clientOrderIds']);
1578
+ const response = await this.privatePostOrdersBatch(this.extend(request, params));
1579
+ //
1580
+ // {
1581
+ // "success": true,
1582
+ // "data": {
1583
+ // "results": [
1584
+ // {
1585
+ // "success": true,
1586
+ // "order_id": 470506,
1587
+ // "error": null
1588
+ // },
1589
+ // {
1590
+ // "success": true,
1591
+ // }
1592
+ // ]
1593
+ // },
1594
+ // "error": null,
1595
+ // "code": null
1596
+ // }
1597
+ //
1598
+ const data = this.safeDict(response, 'data', {});
1599
+ const results = this.safeList(data, 'results', []);
1600
+ const ordersToReturn = [];
1601
+ for (let i = 0; i < results.length; i++) {
1602
+ const order = results[i];
1603
+ const error = this.safeString(order, 'error', undefined);
1604
+ const success = this.safeBool(order, 'success', false);
1605
+ let status = undefined;
1606
+ if ((error !== undefined) || (!success)) {
1607
+ status = 'closed';
1608
+ }
1609
+ else {
1610
+ status = 'canceled';
1611
+ }
1612
+ ordersToReturn.push(this.safeOrder({ 'info': order, 'status': status, 'symbol': symbol }));
1613
+ }
1614
+ return ordersToReturn;
1615
+ }
1616
+ cancelOrdersRequest(ids, symbol = undefined, params = {}) {
1617
+ const actions = [];
1618
+ for (let i = 0; i < ids.length; i++) {
1619
+ const id = ids[i];
1620
+ const request = this.cancelOrderRequest(id, symbol, params);
1621
+ const action = {
1622
+ 'type': 'Cancel',
1623
+ 'data': request,
1624
+ };
1625
+ actions.push(action);
1626
+ }
1627
+ const clientOrderIds = this.safeList(params, 'clientOrderIds', []);
1628
+ params = this.omit(params, 'clientOrderIds');
1629
+ for (let i = 0; i < clientOrderIds.length; i++) {
1630
+ const cloid = clientOrderIds[i];
1631
+ const cloidParams = {
1632
+ 'clientOrderId': cloid,
1633
+ };
1634
+ const request = this.cancelOrderRequest(cloid, symbol, this.extend(cloidParams, params));
1635
+ const action = {
1636
+ 'type': 'Cancel',
1637
+ 'data': request,
1638
+ };
1639
+ actions.push(action);
1640
+ }
1641
+ return this.batchOrdersRequest(actions);
1642
+ }
1643
+ /**
1644
+ * @method
1645
+ * @name pacifica#cancelAllOrders
1646
+ * @description cancel all open orders in a market
1647
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/cancel-all-orders
1648
+ * @param {string} symbol (optional) unified market symbol of the market to cancel orders in.
1649
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1650
+ * @param {boolean} [params.excludeReduceOnly] whether to exclude reduce-only orders
1651
+ * @param {int} [params.expiryWindow] time to live in milliseconds
1652
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1653
+ */
1654
+ async cancelAllOrders(symbol = undefined, params = {}) {
1655
+ await this.loadMarkets();
1656
+ await this.initializeClient();
1657
+ const request = this.cancelAllOrdersRequest(symbol, params);
1658
+ params = this.omit(params, ['excludeReduceOnly', 'expiryWindow']);
1659
+ const response = await this.privatePostOrdersCancelAll(this.extend(request, params));
1660
+ //
1661
+ // {
1662
+ // success: true,
1663
+ // data: {
1664
+ // "cancelled_count": 5,
1665
+ // },
1666
+ // code: null,
1667
+ // error: null
1668
+ // }
1669
+ //
1670
+ return [
1671
+ this.safeOrder({
1672
+ 'info': response,
1673
+ }),
1674
+ ];
1675
+ }
1676
+ cancelAllOrdersRequest(symbol, params = {}) {
1677
+ const operationType = 'cancel_all_orders';
1678
+ const sigPayload = {};
1679
+ const excludeReduceOnly = this.safeBool(params, 'excludeReduceOnly', false);
1680
+ sigPayload['exclude_reduce_only'] = excludeReduceOnly;
1681
+ if (symbol !== undefined) {
1682
+ const market = this.market(symbol);
1683
+ sigPayload['all_symbols'] = false;
1684
+ sigPayload['symbol'] = market['id'];
1685
+ }
1686
+ else {
1687
+ sigPayload['all_symbols'] = true;
1688
+ }
1689
+ const request = this.postActionRequest(operationType, sigPayload, params);
1690
+ return request;
1691
+ }
1692
+ /**
1693
+ * @method
1694
+ * @name pacifica#cancelOrder
1695
+ * @description cancels an open order
1696
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/cancel-stop-order#response
1697
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/cancel-order
1698
+ * @param {string} id order id
1699
+ * @param {string} symbol unified symbol of the market the order was made in
1700
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1701
+ * @param {boolean} [params.stop] necessary if this is to cancel a stop order.
1702
+ * @param {string} [params.clientOrderId] client order id, (optional uuid v4 e.g.: f47ac10b-58cc-4372-a567-0e02b2c3d479)
1703
+ * @param {int} [params.expiryWindow] time to live in milliseconds
1704
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1705
+ */
1706
+ async cancelOrder(id, symbol = undefined, params = {}) {
1707
+ await this.loadMarkets();
1708
+ await this.initializeClient();
1709
+ if (symbol === undefined) {
1710
+ throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
1711
+ }
1712
+ const request = this.cancelOrderRequest(id, symbol, params);
1713
+ const isStopOrder = this.safeBool2(params, 'trigger', 'stop', false);
1714
+ params = this.omit(params, ['expiryWindow', 'trigger', 'stop', 'clientOrderId']);
1715
+ let response = undefined;
1716
+ if (isStopOrder) {
1717
+ response = await this.privatePostOrdersStopCancel(this.extend(request, params));
1718
+ }
1719
+ else {
1720
+ response = await this.privatePostOrdersCancel(this.extend(request, params));
1721
+ }
1722
+ //
1723
+ // response:
1724
+ // {
1725
+ // "success": true,
1726
+ // "data": null
1727
+ // }
1728
+ //
1729
+ const success = this.safeBool(response, 'success', false);
1730
+ const status = success ? 'canceled' : 'closed';
1731
+ return this.safeOrder({ 'id': id, 'status': status, 'info': response, 'symbol': symbol });
1732
+ }
1733
+ cancelOrderRequest(id, symbol = undefined, params = {}) {
1734
+ const market = this.market(symbol);
1735
+ const isStopOrder = this.safeBool2(params, 'trigger', 'stop', false);
1736
+ let operationType = undefined;
1737
+ if (isStopOrder) {
1738
+ operationType = 'cancel_stop_order';
1739
+ }
1740
+ else {
1741
+ operationType = 'cancel_order';
1742
+ }
1743
+ const clientOrderId = this.safeString(params, 'clientOrderId');
1744
+ const sigPayload = {
1745
+ 'symbol': market['id'],
1746
+ };
1747
+ if (clientOrderId !== undefined) {
1748
+ sigPayload['client_order_id'] = clientOrderId;
1749
+ }
1750
+ else {
1751
+ sigPayload['order_id'] = this.parseToInt(id);
1752
+ }
1753
+ const request = this.postActionRequest(operationType, sigPayload, params);
1754
+ return request;
1755
+ }
1756
+ /**
1757
+ * @method
1758
+ * @name pacifica#editOrder
1759
+ * @description edit a trade order
1760
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/edit-order
1761
+ * @param {string} id edit order id
1762
+ * @param {string} symbol unified symbol of the market to edit an order in
1763
+ * @param {string} type 'market' or 'limit' WARN is not usable!
1764
+ * @param {string} side 'buy' or 'sell' WARN is not usable!
1765
+ * @param {float} amount how much of currency you want to trade in units of base currency
1766
+ * @param {float} price the price at which the order is to be fulfilled, in units of the quote currency
1767
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1768
+ * @param {string} [params.clientOrderId] client order id, (optional uuid v4 e.g.: f47ac10b-58cc-4372-a567-0e02b2c3d479)
1769
+ * @param {int} [params.expiryWindow] time to live in milliseconds
1770
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1771
+ */
1772
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1773
+ await this.loadMarkets();
1774
+ await this.initializeClient();
1775
+ const market = this.market(symbol);
1776
+ const request = this.editOrderRequest(id, symbol, type, side, amount, price, market, params);
1777
+ params = this.omit(params, ['expiryWindow', 'clientOrderId']);
1778
+ const response = await this.privatePostOrdersEdit(this.extend(request, params));
1779
+ //
1780
+ // {
1781
+ // 'data': {
1782
+ // "order_id": 123498765
1783
+ // }
1784
+ // }
1785
+ //
1786
+ const data = this.safeDict(response, 'data', {});
1787
+ const orderId = this.safeString(data, 'order_id');
1788
+ return this.safeOrder({ 'id': orderId, 'info': response, 'symbol': symbol });
1789
+ }
1790
+ editOrderRequest(id, symbol, type, side, amount, price, market, params = {}) {
1791
+ if (amount === undefined) {
1792
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() requires an amount!');
1793
+ }
1794
+ if (price === undefined) {
1795
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a price');
1796
+ }
1797
+ const operationType = 'edit_order';
1798
+ const clientOrderId = this.safeString(params, 'clientOrderId');
1799
+ const priceNormalized = this.priceToPrecision(symbol, price);
1800
+ const amountNormalized = this.amountToPrecision(symbol, amount);
1801
+ const sigPayload = {
1802
+ 'symbol': market['id'],
1803
+ 'price': priceNormalized,
1804
+ 'amount': amountNormalized,
1805
+ };
1806
+ if ((clientOrderId === undefined) && (id === undefined)) {
1807
+ throw new errors.ArgumentsRequired('this.id' + 'editOrder() requires either "id" or "clientOrderId"');
1808
+ }
1809
+ if (clientOrderId !== undefined) {
1810
+ sigPayload['client_order_id'] = clientOrderId;
1811
+ }
1812
+ else {
1813
+ sigPayload['order_id'] = this.parseToInt(id);
1814
+ }
1815
+ const request = this.postActionRequest(operationType, sigPayload, params);
1816
+ return request;
1817
+ }
1818
+ /**
1819
+ * @method
1820
+ * @name pacifica#fetchFundingRateHistory
1821
+ * @description fetches historical funding rate prices
1822
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-historical-funding
1823
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
1824
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1825
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
1826
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1827
+ * @param {string} [params.cursor] pagination cursor from prev request (manual use)
1828
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1829
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure}
1830
+ */
1831
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1832
+ await this.loadMarkets();
1833
+ if (symbol === undefined) {
1834
+ throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
1835
+ }
1836
+ const market = this.market(symbol);
1837
+ let paginate = false;
1838
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate', false);
1839
+ const defaultLimit = 100; // Default max limit
1840
+ if (paginate) {
1841
+ return await this.fetchPaginatedCallCursor('fetchFundingRateHistory', symbol, since, limit, params, 'next_cursor', 'cursor', undefined, defaultLimit);
1842
+ }
1843
+ const request = {
1844
+ 'symbol': market['id'],
1845
+ };
1846
+ if (limit !== undefined) {
1847
+ request['limit'] = limit;
1848
+ }
1849
+ const response = await this.publicGetFundingRateHistory(this.extend(request, params));
1850
+ //
1851
+ // {
1852
+ // "success": true,
1853
+ // "data": [
1854
+ // {
1855
+ // "oracle_price": "117170.410304",
1856
+ // "bid_impact_price": "117126",
1857
+ // "ask_impact_price": "117142",
1858
+ // "funding_rate": "0.0000125",
1859
+ // "next_funding_rate": "0.0000125",
1860
+ // "created_at": 1753806934249
1861
+ // },
1862
+ // ...
1863
+ // ],
1864
+ // "next_cursor": "11114Lz77",
1865
+ // "has_more": true
1866
+ // }
1867
+ //
1868
+ const data = this.addPaginationCursorToResult(response);
1869
+ const result = [];
1870
+ for (let i = 0; i < data.length; i++) {
1871
+ const entry = data[i];
1872
+ const timestamp = this.safeInteger(entry, 'created_at');
1873
+ result.push({
1874
+ 'info': entry,
1875
+ 'symbol': market['symbol'],
1876
+ 'fundingRate': this.safeNumber(entry, 'funding_rate'),
1877
+ 'timestamp': timestamp,
1878
+ 'datetime': this.iso8601(timestamp),
1879
+ });
1880
+ }
1881
+ const sorted = this.sortBy(result, 'timestamp');
1882
+ return this.filterBySinceLimit(sorted, since, limit, 'timestamp');
1883
+ }
1884
+ /**
1885
+ * @method
1886
+ * @name pacifica#fetchTickers
1887
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1888
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-prices
1889
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1890
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1891
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
1892
+ */
1893
+ async fetchTickers(symbols = undefined, params = {}) {
1894
+ await this.loadMarkets();
1895
+ symbols = this.marketSymbols(symbols);
1896
+ const response = await this.publicGetInfoPrices(params);
1897
+ //
1898
+ // {
1899
+ // "success": true,
1900
+ // "data": [
1901
+ // {
1902
+ // "funding": "0.00010529",
1903
+ // "mark": "1.084819",
1904
+ // "mid": "1.08615",
1905
+ // "next_funding": "0.00011096",
1906
+ // "open_interest": "3634796",
1907
+ // "oracle": "1.084524",
1908
+ // "symbol": "XPL",
1909
+ // "timestamp": 1759222967974,
1910
+ // "volume_24h": "20896698.0672",
1911
+ // "yesterday_price": "1.3412"
1912
+ // }
1913
+ // ],
1914
+ // "error": null,
1915
+ // "code": null
1916
+ // }
1917
+ //
1918
+ const data = this.safeList(response, 'data', []);
1919
+ const result = {};
1920
+ for (let i = 0; i < data.length; i++) {
1921
+ const info = data[i];
1922
+ const ticker = this.parseTicker(info);
1923
+ const symbol = this.safeString(ticker, 'symbol');
1924
+ result[symbol] = ticker;
1925
+ }
1926
+ return this.filterByArrayTickers(result, 'symbol', symbols);
1927
+ }
1928
+ parseTicker(ticker, market = undefined) {
1929
+ //
1930
+ // {
1931
+ // "funding": "0.00010529",
1932
+ // "mark": "1.084819",
1933
+ // "mid": "1.08615",
1934
+ // "next_funding": "0.00011096",
1935
+ // "open_interest": "3634796",
1936
+ // "oracle": "1.084524",
1937
+ // "symbol": "XPL",
1938
+ // "timestamp": 1759222967974,
1939
+ // "volume_24h": "20896698.0672",
1940
+ // "yesterday_price": "1.3412"
1941
+ // }
1942
+ //
1943
+ const marketId = this.safeString(ticker, 'symbol');
1944
+ market = this.safeMarket(marketId, market);
1945
+ const symbol = market['symbol'];
1946
+ const timestamp = this.safeInteger(ticker, 'timestamp');
1947
+ return this.safeTicker({
1948
+ 'symbol': symbol,
1949
+ 'timestamp': timestamp,
1950
+ 'datetime': this.iso8601(timestamp),
1951
+ 'previousClose': this.safeNumber(ticker, 'yesterday_price'),
1952
+ 'close': this.safeNumber(ticker, 'mid'),
1953
+ 'bid': undefined,
1954
+ 'ask': undefined,
1955
+ 'quoteVolume': this.safeNumber(ticker, 'volume_24h'),
1956
+ 'info': ticker,
1957
+ }, market);
1958
+ }
1959
+ /**
1960
+ * @method
1961
+ * @name pacifica#fetchClosedOrders
1962
+ * @description fetch all unfilled currently closed orders
1963
+ * @param {string} symbol unified market symbol
1964
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1965
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1966
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1967
+ * @param {string} [params.account] will default to walletAddress if not provided
1968
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1969
+ */
1970
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1971
+ await this.loadMarkets();
1972
+ const orders = await this.fetchOrders(symbol, undefined, undefined, params); // don't filter here because we don't want to catch open orders
1973
+ const closedOrders = this.filterByArray(orders, 'status', ['closed'], false);
1974
+ return this.filterBySymbolSinceLimit(closedOrders, symbol, since, limit);
1975
+ }
1976
+ /**
1977
+ * @method
1978
+ * @name pacifica#fetchCanceledOrders
1979
+ * @description fetch all canceled orders
1980
+ * @param {string} symbol unified market symbol
1981
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1982
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1983
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1984
+ * @param {string} [params.account] will default to walletAddress if not provided
1985
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1986
+ */
1987
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1988
+ await this.loadMarkets();
1989
+ const orders = await this.fetchOrders(symbol, undefined, undefined, params); // don't filter here because we don't want to catch open orders
1990
+ const closedOrders = this.filterByArray(orders, 'status', ['canceled'], false);
1991
+ return this.filterBySymbolSinceLimit(closedOrders, symbol, since, limit);
1992
+ }
1993
+ /**
1994
+ * @method
1995
+ * @name pacifica#fetchCanceledAndClosedOrders
1996
+ * @description fetch all closed and canceled orders
1997
+ * @param {string} symbol unified market symbol
1998
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1999
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
2000
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2001
+ * @param {string} [params.account] will default to walletAddress if not provided
2002
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2003
+ */
2004
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2005
+ await this.loadMarkets();
2006
+ const orders = await this.fetchOrders(symbol, undefined, undefined, params); // don't filter here because we don't want to catch open orders
2007
+ const closedOrders = this.filterByArray(orders, 'status', ['canceled', 'closed', 'rejected'], false);
2008
+ return this.filterBySymbolSinceLimit(closedOrders, symbol, since, limit);
2009
+ }
2010
+ /**
2011
+ * @method
2012
+ * @name pacifica#fetchOpenOrders
2013
+ * @description fetch all unfilled currently open orders
2014
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/get-open-orders
2015
+ * @param {string} symbol unified market symbol
2016
+ * @param {int} [since] the earliest time in ms to fetch open orders for
2017
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
2018
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2019
+ * @param {string} [params.account] will default to walletAddress if not provided
2020
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2021
+ */
2022
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2023
+ await this.loadMarkets();
2024
+ let userAddress = undefined;
2025
+ [userAddress, params] = this.handleOriginAndSingleAddress('fetchOpenOrders', params);
2026
+ const request = {
2027
+ 'account': userAddress,
2028
+ };
2029
+ let market = undefined;
2030
+ if (symbol !== undefined) {
2031
+ market = this.market(symbol);
2032
+ }
2033
+ const response = await this.publicGetOrders(this.extend(request, params));
2034
+ //
2035
+ // {
2036
+ // "success": true,
2037
+ // "data": [
2038
+ // {
2039
+ // "order_id": 315979358,
2040
+ // "client_order_id": "add9a4b5-c7f7-4124-b57f-86982d86d479",
2041
+ // "symbol": "ASTER",
2042
+ // "side": "ask",
2043
+ // "price": "1.836",
2044
+ // "initial_amount": "85.33",
2045
+ // "filled_amount": "0",
2046
+ // "cancelled_amount": "0",
2047
+ // "stop_price": null,
2048
+ // "order_type": "limit",
2049
+ // "stop_parent_order_id": null,
2050
+ // "reduce_only": false,
2051
+ // "created_at": 1759224706737,
2052
+ // "updated_at": 1759224706737
2053
+ // }
2054
+ // ],
2055
+ // "error": null,
2056
+ // "code": null,
2057
+ // "last_order_id": 1557370337
2058
+ // }
2059
+ //
2060
+ const data = this.safeList(response, 'data', []);
2061
+ return this.parseOrders(data, market, since, limit);
2062
+ }
2063
+ /**
2064
+ * @method
2065
+ * @name pacifica#fetchOrders
2066
+ * @description fetch all orders
2067
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/get-order-history
2068
+ * @param {string} symbol unified market symbol
2069
+ * @param {int} [since] the earliest time in ms to fetch open orders for
2070
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
2071
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2072
+ * @param {string} [params.account] will default to walletAddress if not provided
2073
+ * @param {string} [params.cursor] pagination cursor from prev request (manual use)
2074
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2075
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2076
+ */
2077
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2078
+ await this.loadMarkets();
2079
+ let paginate = false;
2080
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate', false);
2081
+ const defaultLimit = 100; // max default 100
2082
+ if (paginate) {
2083
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'next_cursor', 'cursor', undefined, defaultLimit);
2084
+ }
2085
+ let userAddress = undefined;
2086
+ [userAddress, params] = this.handleOriginAndSingleAddress('fetchOrders', params);
2087
+ let market = undefined;
2088
+ if (symbol !== undefined) {
2089
+ market = this.market(symbol);
2090
+ }
2091
+ const request = {
2092
+ 'account': userAddress,
2093
+ };
2094
+ if (limit !== undefined) {
2095
+ request['limit'] = limit;
2096
+ }
2097
+ const response = await this.publicGetOrdersHistory(this.extend(request, params));
2098
+ //
2099
+ // {
2100
+ // "success": true,
2101
+ // "data": [
2102
+ // {
2103
+ // "order_id": 315992721,
2104
+ // "client_order_id": "ade",
2105
+ // "symbol": "XPL",
2106
+ // "side": "ask",
2107
+ // "initial_price": "1.0865",
2108
+ // "average_filled_price": "0",
2109
+ // "amount": "984",
2110
+ // "filled_amount": "0",
2111
+ // "order_status": "open",
2112
+ // "order_type": "limit",
2113
+ // "stop_price": null,
2114
+ // "stop_parent_order_id": null,
2115
+ // "reduce_only": false,
2116
+ // "reason": null,
2117
+ // "created_at": 1759224893638,
2118
+ // "updated_at": 1759224893638
2119
+ // },
2120
+ // ...
2121
+ // ],
2122
+ // "next_cursor": "1111Hyd74",
2123
+ // "has_more": true
2124
+ // }
2125
+ //
2126
+ const data = this.addPaginationCursorToResult(response);
2127
+ const orders = this.parseOrders(data, market, since, limit);
2128
+ return orders;
2129
+ }
2130
+ addPaginationCursorToResult(response) {
2131
+ const data = this.safeList(response, 'data', []);
2132
+ const paginationCursor = this.safeString(response, 'next_cursor');
2133
+ const hasMore = this.safeBool(response, 'has_more', false);
2134
+ const dataLength = data.length;
2135
+ if (hasMore) {
2136
+ if ((paginationCursor !== undefined) && (dataLength > 0)) {
2137
+ const first = data[0];
2138
+ first['next_cursor'] = paginationCursor;
2139
+ first['has_more'] = hasMore;
2140
+ data[0] = first;
2141
+ }
2142
+ }
2143
+ return data;
2144
+ }
2145
+ /**
2146
+ * @method
2147
+ * @name pacifica#fetchOrder
2148
+ * @description fetches information on an order made by the user
2149
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/get-order-history-by-id
2150
+ * @param {string} id order id
2151
+ * @param {string} symbol (optional) unified symbol of the market the order was made in
2152
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2153
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2154
+ */
2155
+ async fetchOrder(id, symbol = undefined, params = {}) {
2156
+ await this.loadMarkets();
2157
+ let market = undefined;
2158
+ if (symbol !== undefined) {
2159
+ market = this.market(symbol);
2160
+ }
2161
+ const request = {
2162
+ 'order_id': id,
2163
+ };
2164
+ const response = await this.publicGetOrdersHistoryById(this.extend(request, params));
2165
+ //
2166
+ // {
2167
+ // "success": true,
2168
+ // "data": [
2169
+ // {
2170
+ // "history_id": 641452639,
2171
+ // "order_id": 315992721,
2172
+ // "client_order_id": "ade1aa6...",
2173
+ // "symbol": "XPL",
2174
+ // "side": "ask",
2175
+ // "price": "1.0865",
2176
+ // "initial_amount": "984",
2177
+ // "filled_amount": "0",
2178
+ // "cancelled_amount": "984",
2179
+ // "event_type": "cancel",
2180
+ // "order_type": "limit",
2181
+ // "order_status": "cancelled",
2182
+ // "stop_price": null,
2183
+ // "stop_parent_order_id": null,
2184
+ // "reduce_only": false,
2185
+ // "created_at": 1759224895038
2186
+ // },
2187
+ // {
2188
+ // "history_id": 641452513,
2189
+ // "order_id": 315992721,
2190
+ // "client_order_id": "ade1aa6...",
2191
+ // "symbol": "XPL",
2192
+ // "side": "ask",
2193
+ // "price": "1.0865",
2194
+ // "initial_amount": "984",
2195
+ // "filled_amount": "0",
2196
+ // "cancelled_amount": "0",
2197
+ // "event_type": "make",
2198
+ // "order_type": "limit",
2199
+ // "order_status": "open",
2200
+ // "stop_price": null,
2201
+ // "stop_parent_order_id": null,
2202
+ // "reduce_only": false,
2203
+ // "created_at": 1759224893638
2204
+ // }
2205
+ // ],
2206
+ // "error": null,
2207
+ // "code": null
2208
+ // }
2209
+ //
2210
+ const data = this.safeList(response, 'data', []);
2211
+ // return last state
2212
+ const sorted = this.sortBy(data, 'created_at');
2213
+ const lastIdx = sorted.length;
2214
+ let lastInfo = {};
2215
+ if (lastIdx > 0) {
2216
+ lastInfo = sorted[0];
2217
+ }
2218
+ return this.parseOrder(lastInfo, market);
2219
+ }
2220
+ parseOrderStatus(status) {
2221
+ const statuses = {
2222
+ 'open': 'open',
2223
+ 'partially_filled': 'open',
2224
+ 'filled': 'closed',
2225
+ 'cancelled': 'canceled',
2226
+ 'rejected': 'failed',
2227
+ };
2228
+ return this.safeString(statuses, status, status);
2229
+ }
2230
+ mapTimeInForce(tifRaw) {
2231
+ const tifMap = {
2232
+ 'GTC': 'GTC',
2233
+ 'IOC': 'IOC',
2234
+ 'PO': 'ALO',
2235
+ 'POST_ONLY': 'ALO',
2236
+ 'PO_TOB': 'TOB',
2237
+ 'TOB': 'TOB',
2238
+ 'ALO': 'ALO',
2239
+ };
2240
+ let tif = undefined;
2241
+ if (tifRaw !== undefined) {
2242
+ tif = tifRaw.toUpperCase();
2243
+ }
2244
+ return this.safeString(tifMap, tif, undefined);
2245
+ }
2246
+ mapSide(sideRaw) {
2247
+ const sideMap = {
2248
+ 'sell': 'ask',
2249
+ 'buy': 'bid',
2250
+ };
2251
+ return this.safeString(sideMap, sideRaw, sideRaw);
2252
+ }
2253
+ parseOrderType(status) {
2254
+ const statuses = {
2255
+ 'stop_limit': 'limit',
2256
+ 'stop_market': 'market',
2257
+ 'take_profit_limit': 'limit',
2258
+ 'stop_loss_limit': 'limit',
2259
+ 'take_profit_market': 'market',
2260
+ 'stop_loss_market': 'market',
2261
+ };
2262
+ return this.safeString(statuses, status, status);
2263
+ }
2264
+ parseOrder(order, market = undefined) {
2265
+ //
2266
+ // fetchOpenOrders
2267
+ // [
2268
+ // {
2269
+ // "order_id": 315979358,
2270
+ // "client_order_id": "add9a4b5-c7f7-4124-b57f-86982d86d479",
2271
+ // "symbol": "ASTER",
2272
+ // "side": "ask",
2273
+ // "price": "1.836",
2274
+ // "initial_amount": "85.33",
2275
+ // "filled_amount": "0",
2276
+ // "cancelled_amount": "0",
2277
+ // "stop_price": null,
2278
+ // "order_type": "limit",
2279
+ // "stop_parent_order_id": null,
2280
+ // "reduce_only": false,
2281
+ // "created_at": 1759224706737,
2282
+ // "updated_at": 1759224706737
2283
+ // }
2284
+ // ],
2285
+ //
2286
+ // fetchOrders
2287
+ // [
2288
+ // {
2289
+ // "order_id": 315992721,
2290
+ // "client_order_id": "ade",
2291
+ // "symbol": "XPL",
2292
+ // "side": "ask",
2293
+ // "initial_price": "1.0865",
2294
+ // "average_filled_price": "0",
2295
+ // "amount": "984",
2296
+ // "filled_amount": "0",
2297
+ // "order_status": "open",
2298
+ // "order_type": "limit",
2299
+ // "stop_price": null,
2300
+ // "stop_parent_order_id": null,
2301
+ // "reduce_only": false,
2302
+ // "reason": null,
2303
+ // "created_at": 1759224893638,
2304
+ // "updated_at": 1759224893638
2305
+ // },
2306
+ // ]
2307
+ //
2308
+ // fetchOrder
2309
+ // {
2310
+ // "history_id": 641452639,
2311
+ // "order_id": 315992721,
2312
+ // "client_order_id": "ade1aa6...",
2313
+ // "symbol": "XPL",
2314
+ // "side": "ask",
2315
+ // "price": "1.0865",
2316
+ // "initial_amount": "984",
2317
+ // "filled_amount": "0",
2318
+ // "cancelled_amount": "984",
2319
+ // "event_type": "cancel",
2320
+ // "order_type": "limit",
2321
+ // "order_status": "cancelled",
2322
+ // "stop_price": null,
2323
+ // "stop_parent_order_id": null,
2324
+ // "reduce_only": false,
2325
+ // "created_at": 1759224895038
2326
+ // }
2327
+ //
2328
+ // websocket watchOrders
2329
+ // {
2330
+ // "i": 1559665358,
2331
+ // "I": null,
2332
+ // "u": "BrZp5bidJ3WUvceSq7X78bhjTfZXeezzGvGEV4hAYKTa",
2333
+ // "s": "BTC",
2334
+ // "d": "bid",
2335
+ // "p": "89501",
2336
+ // "ip": "89501",
2337
+ // "lp": "89501",
2338
+ // "a": "0.00012",
2339
+ // "f": "0.00012",
2340
+ // "oe": "fulfill_limit",
2341
+ // "os": "filled",
2342
+ // "ot": "limit",
2343
+ // "sp": null,
2344
+ // "si": null,
2345
+ // "r": false,
2346
+ // "ct": 1765017049008,
2347
+ // "ut": 1765017219639,
2348
+ // "li": 1559696133
2349
+ // }
2350
+ //
2351
+ this.safeString2(order, 'symbol', 's');
2352
+ let symbol = undefined;
2353
+ const timestamp = this.safeInteger2(order, 'created_at', 'ct');
2354
+ const status = this.safeString2(order, 'order_status', 'os', 'open'); // open if method is fetchOpenOrders
2355
+ let side = this.safeString(order, 'side', 'd');
2356
+ if (side !== undefined) {
2357
+ side = (side === 'bid') ? 'buy' : 'sell';
2358
+ }
2359
+ const totalAmount = this.safeString2(order, 'initial_amount', 'a');
2360
+ const filledAmount = this.safeString2(order, 'filled_amount', 'f');
2361
+ const remaining = Precise["default"].stringSub(totalAmount, filledAmount);
2362
+ return this.safeOrder({
2363
+ 'info': order,
2364
+ 'id': this.safeString2(order, 'order_id', 'i'),
2365
+ 'clientOrderId': this.safeString2(order, 'client_order_id', 'I'),
2366
+ 'timestamp': timestamp,
2367
+ 'datetime': this.iso8601(timestamp),
2368
+ 'lastTradeTimestamp': undefined,
2369
+ 'lastUpdateTimestamp': this.safeInteger2(order, 'updated_at', 'ut'),
2370
+ 'symbol': symbol,
2371
+ 'type': this.parseOrderType(this.safeStringLower2(order, 'order_type', 'ot')),
2372
+ 'timeInForce': undefined,
2373
+ 'postOnly': undefined,
2374
+ 'reduceOnly': this.safeBool2(order, 'reduce_only', 'r'),
2375
+ 'side': side,
2376
+ 'price': this.safeString2(order, 'price', 'lp'),
2377
+ 'triggerPrice': this.safeNumber2(order, 'stop_price', 'sp'),
2378
+ 'amount': totalAmount,
2379
+ 'cost': undefined,
2380
+ 'average': this.safeString2(order, 'average_filled_price', 'p'),
2381
+ 'filled': filledAmount,
2382
+ 'remaining': remaining,
2383
+ 'status': this.parseOrderStatus(status),
2384
+ 'fee': undefined,
2385
+ 'trades': undefined,
2386
+ }, market);
2387
+ }
2388
+ /**
2389
+ * @method
2390
+ * @name pacifica#fetchPosition
2391
+ * @description fetch data on an open position
2392
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-positions
2393
+ * @param {string} symbol unified market symbol of the market the position is held in
2394
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2395
+ * @param {string} [params.account] will default to walletAddress if not provided
2396
+ * @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
2397
+ */
2398
+ async fetchPosition(symbol, params = {}) {
2399
+ const positions = await this.fetchPositions([symbol], params);
2400
+ return this.safeDict(positions, 0, {});
2401
+ }
2402
+ /**
2403
+ * @method
2404
+ * @name pacifica#fetchPositions
2405
+ * @description fetch all open positions
2406
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-positions
2407
+ * @param {string[]} [symbols] list of unified market symbols
2408
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2409
+ * @param {string} [params.account] will default to walletAddress if not provided
2410
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
2411
+ */
2412
+ async fetchPositions(symbols = undefined, params = {}) {
2413
+ await this.loadMarkets();
2414
+ let userAddress = undefined;
2415
+ [userAddress, params] = this.handleOriginAndSingleAddress('fetchPositions', params);
2416
+ symbols = this.marketSymbols(symbols);
2417
+ const request = {
2418
+ 'account': userAddress,
2419
+ };
2420
+ const response = await this.publicGetPositions(this.extend(request, params));
2421
+ // {
2422
+ // "success": true,
2423
+ // "data": [
2424
+ // {
2425
+ // "symbol": "AAVE",
2426
+ // "side": "ask",
2427
+ // "amount": "223.72",
2428
+ // "entry_price": "279.283134",
2429
+ // "margin": "0", // only shown for isolated margin
2430
+ // "funding": "13.159593",
2431
+ // "isolated": false,
2432
+ // "created_at": 1754928414996,
2433
+ // "updated_at": 1759223365538
2434
+ // }
2435
+ // ],
2436
+ // "error": null,
2437
+ // "code": null,
2438
+ // "last_order_id": 1557431179
2439
+ // }
2440
+ const data = this.safeList(response, 'data', []);
2441
+ const result = [];
2442
+ for (let i = 0; i < data.length; i++) {
2443
+ result.push(this.parsePosition(data[i], undefined));
2444
+ }
2445
+ return this.filterByArrayPositions(result, 'symbol', symbols, false);
2446
+ }
2447
+ parsePosition(position, market = undefined) {
2448
+ //
2449
+ // {
2450
+ // "symbol": "AAVE",
2451
+ // "side": "ask",
2452
+ // "amount": "223.72",
2453
+ // "entry_price": "279.283134",
2454
+ // "margin": "0", // only shown for isolated margin
2455
+ // "funding": "13.159593",
2456
+ // "isolated": false,
2457
+ // "created_at": 1754928414996,
2458
+ // "updated_at": 1759223365538
2459
+ // }
2460
+ //
2461
+ const marketId = this.safeString(position, 'symbol');
2462
+ market = this.safeMarket(marketId, market);
2463
+ const symbol = market['symbol'];
2464
+ const margin = this.safeString(position, 'margin');
2465
+ const marginMode = (margin !== undefined && margin !== '0') ? 'isolated' : 'cross';
2466
+ const isIsolated = (marginMode === 'isolated');
2467
+ let side = this.safeString(position, 'side');
2468
+ if (side !== undefined) {
2469
+ side = (side === 'bid') ? 'long' : 'short';
2470
+ }
2471
+ const createdAt = this.safeInteger(position, 'created_at');
2472
+ return this.safePosition({
2473
+ 'info': position,
2474
+ 'id': undefined,
2475
+ 'symbol': symbol,
2476
+ 'timestamp': createdAt,
2477
+ 'datetime': this.iso8601(createdAt),
2478
+ 'isolated': isIsolated,
2479
+ 'hedged': undefined,
2480
+ 'side': side,
2481
+ 'contracts': this.safeNumber(position, 'amount'),
2482
+ 'contractSize': undefined,
2483
+ 'entryPrice': this.safeNumber(position, 'entry_price'),
2484
+ 'markPrice': undefined,
2485
+ 'notional': undefined,
2486
+ 'leverage': undefined,
2487
+ 'collateral': margin,
2488
+ 'initialMargin': undefined,
2489
+ 'maintenanceMargin': undefined,
2490
+ 'initialMarginPercentage': undefined,
2491
+ 'maintenanceMarginPercentage': undefined,
2492
+ 'unrealizedPnl': undefined,
2493
+ 'liquidationPrice': undefined,
2494
+ 'marginMode': marginMode,
2495
+ 'percentage': undefined,
2496
+ });
2497
+ }
2498
+ /**
2499
+ * @method
2500
+ * @name pacifica#setMarginMode
2501
+ * @description set margin mode (symbol)
2502
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/update-margin-mode
2503
+ * @param {string} marginMode margin mode must be either [isolated, cross]
2504
+ * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
2505
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2506
+ * @param {int} [params.expiryWindow] time to live in milliseconds
2507
+ * @returns {object} response from the exchange
2508
+ */
2509
+ async setMarginMode(marginMode, symbol = undefined, params = {}) {
2510
+ const operationType = 'update_margin_mode';
2511
+ if (symbol === undefined) {
2512
+ throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
2513
+ }
2514
+ await this.loadMarkets();
2515
+ const market = this.market(symbol);
2516
+ const isIsolated = (marginMode === 'isolated');
2517
+ const sigPayload = {
2518
+ 'symbol': market['id'],
2519
+ 'is_isolated': isIsolated,
2520
+ };
2521
+ const request = this.postActionRequest(operationType, sigPayload, params);
2522
+ params = this.omit(params, ['expiryWindow']);
2523
+ const response = await this.privatePostAccountMargin(request);
2524
+ // {
2525
+ // "success": true
2526
+ // }
2527
+ return response;
2528
+ }
2529
+ /**
2530
+ * @method
2531
+ * @name pacifica#setLeverage
2532
+ * @description set the level of leverage for a market
2533
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/update-leverage
2534
+ * @param {float} leverage the rate of leverage
2535
+ * @param {string} symbol unified market symbol
2536
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2537
+ * @param {int} [params.expiryWindow] time to live in milliseconds
2538
+ * @returns {object} response from the exchange
2539
+ */
2540
+ async setLeverage(leverage, symbol = undefined, params = {}) {
2541
+ const operationType = 'update_leverage';
2542
+ if (symbol === undefined) {
2543
+ throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
2544
+ }
2545
+ await this.loadMarkets();
2546
+ const market = this.market(symbol);
2547
+ const sigPayload = {
2548
+ 'symbol': market['id'],
2549
+ 'leverage': leverage,
2550
+ };
2551
+ const request = this.postActionRequest(operationType, sigPayload, params);
2552
+ params = this.omit(params, ['expiryWindow']);
2553
+ const response = await this.privatePostAccountLeverage(request);
2554
+ // {
2555
+ // "success": true
2556
+ // }
2557
+ return response;
2558
+ }
2559
+ /**
2560
+ * @method
2561
+ * @name pacifica#withdraw
2562
+ * @description make a withdrawal (only support native USDC)
2563
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/request-withdrawal
2564
+ * @param {string} code unified currency code
2565
+ * @param {float} amount the amount to withdraw
2566
+ * @param {string} address the address to withdraw to
2567
+ * @param {string} tag
2568
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2569
+ * @param {int} [params.expiryWindow] time to live in milliseconds
2570
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
2571
+ */
2572
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
2573
+ const operationType = 'withdraw';
2574
+ await this.loadMarkets();
2575
+ this.checkAddress(address);
2576
+ const sigPayload = {
2577
+ 'amount': amount.toString(),
2578
+ };
2579
+ const request = this.postActionRequest(operationType, sigPayload, params);
2580
+ params = this.omit(params, ['expiryWindow']);
2581
+ const response = await this.privatePostAccountWithdraw(this.extend(request, params));
2582
+ return { 'info': response };
2583
+ }
2584
+ /**
2585
+ * @method
2586
+ * @name pacifica#fetchTradingFee
2587
+ * @description fetch the trading fees for a market
2588
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-info
2589
+ * @param {string} symbol unified market symbol
2590
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2591
+ * @param {string} [params.account] will default to walletAddress if not provided
2592
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
2593
+ */
2594
+ async fetchTradingFee(symbol, params = {}) {
2595
+ await this.loadMarkets();
2596
+ let userAddress = undefined;
2597
+ [userAddress, params] = this.handleOriginAndSingleAddress('fetchTradingFee', params);
2598
+ const market = this.market(symbol);
2599
+ const request = {
2600
+ 'account': userAddress,
2601
+ };
2602
+ const response = await this.publicGetAccount(this.extend(request, params));
2603
+ // {
2604
+ // "success": true,
2605
+ // "data": {
2606
+ // "balance": "2000.000000",
2607
+ // "fee_level": 0,
2608
+ // "maker_fee": "0.00015",
2609
+ // "taker_fee": "0.0004",
2610
+ // "account_equity": "2150.250000",
2611
+ // "available_to_spend": "1800.750000",
2612
+ // "available_to_withdraw": "1500.850000",
2613
+ // "pending_balance": "0.000000",
2614
+ // "total_margin_used": "349.500000",
2615
+ // "cross_mmr": "420.690000",
2616
+ // "positions_count": 2,
2617
+ // "orders_count": 3,
2618
+ // "stop_orders_count": 1,
2619
+ // "updated_at": 1716200000000,
2620
+ // "use_ltp_for_stop_orders": false
2621
+ // },
2622
+ // "error": null,
2623
+ // "code": null
2624
+ // }
2625
+ const data = this.safeDict(response, 'data', {});
2626
+ return this.parseTradingFee(data, market);
2627
+ }
2628
+ parseTradingFee(fee, market = undefined) {
2629
+ //
2630
+ // {
2631
+ // "balance": "2000.000000",
2632
+ // "fee_level": 0,
2633
+ // "maker_fee": "0.00015",
2634
+ // "taker_fee": "0.0004",
2635
+ // "account_equity": "2150.250000",
2636
+ // "available_to_spend": "1800.750000",
2637
+ // "available_to_withdraw": "1500.850000",
2638
+ // "pending_balance": "0.000000",
2639
+ // "total_margin_used": "349.500000",
2640
+ // "cross_mmr": "420.690000",
2641
+ // "positions_count": 2,
2642
+ // "orders_count": 3,
2643
+ // "stop_orders_count": 1,
2644
+ // "updated_at": 1716200000000,
2645
+ // "use_ltp_for_stop_orders": false
2646
+ // }
2647
+ //
2648
+ //
2649
+ const symbol = this.safeSymbol(undefined, market);
2650
+ return {
2651
+ 'info': fee,
2652
+ 'symbol': symbol,
2653
+ 'maker': this.safeNumber(fee, 'maker_fee'),
2654
+ 'taker': this.safeNumber(fee, 'taker_fee'),
2655
+ 'percentage': undefined,
2656
+ 'tierBased': undefined,
2657
+ };
2658
+ }
2659
+ /**
2660
+ * @method
2661
+ * @name pacifica#fetchOpenInterests
2662
+ * @description Retrieves the open interest for a list of symbols
2663
+ * @param {string[]} [symbols] Unified CCXT market symbol
2664
+ * @param {object} [params] exchange specific parameters
2665
+ * @returns {object} an open interest structure{@link https://docs.ccxt.com/?id=open-interest-structure}
2666
+ */
2667
+ async fetchOpenInterests(symbols = undefined, params = {}) {
2668
+ await this.loadMarkets();
2669
+ symbols = this.marketSymbols(symbols);
2670
+ const swapMarkets = await this.fetchSwapMarkets();
2671
+ return this.parseOpenInterests(swapMarkets, symbols);
2672
+ }
2673
+ /**
2674
+ * @method
2675
+ * @name pacifica#fetchOpenInterest
2676
+ * @description retrieves the open interest of a contract trading pair
2677
+ * @param {string} symbol unified CCXT market symbol
2678
+ * @param {object} [params] exchange specific parameters
2679
+ * @returns {object} an [open interest structure]{@link https://docs.ccxt.com/?id=open-interest-structure}
2680
+ */
2681
+ async fetchOpenInterest(symbol, params = {}) {
2682
+ symbol = this.symbol(symbol);
2683
+ await this.loadMarkets();
2684
+ const ois = await this.fetchOpenInterests([symbol], params);
2685
+ return ois[symbol];
2686
+ }
2687
+ parseOpenInterest(interest, market = undefined) {
2688
+ //
2689
+ // {
2690
+ // "funding": "0.00010529",
2691
+ // "mark": "1.084819",
2692
+ // "mid": "1.08615",
2693
+ // "next_funding": "0.00011096",
2694
+ // "open_interest": "3634796",
2695
+ // "oracle": "1.084524",
2696
+ // "symbol": "XPL",
2697
+ // "timestamp": 1759222967974,
2698
+ // "volume_24h": "20896698.0672",
2699
+ // "yesterday_price": "1.3412"
2700
+ // }
2701
+ //
2702
+ const marketId = this.safeString(interest, 'symbol');
2703
+ let symbol = undefined;
2704
+ if (marketId !== undefined) {
2705
+ market = this.safeMarket(marketId, market);
2706
+ symbol = market['symbol'];
2707
+ }
2708
+ let interestValue = undefined;
2709
+ const markPrice = this.safeString(interest, 'mark');
2710
+ const openInterest = this.safeString(interest, 'open_interest');
2711
+ if ((openInterest !== undefined) && (markPrice !== undefined)) {
2712
+ interestValue = Precise["default"].stringMul(openInterest, markPrice);
2713
+ }
2714
+ const timestamp = this.safeInteger(interest, 'timestamp');
2715
+ return this.safeOpenInterest({
2716
+ 'symbol': this.safeSymbol(symbol),
2717
+ 'openInterestAmount': this.parseNumber(openInterest),
2718
+ 'openInterestValue': this.parseNumber(interestValue),
2719
+ 'timestamp': timestamp,
2720
+ 'datetime': this.iso8601(timestamp),
2721
+ 'info': interest,
2722
+ }, market);
2723
+ }
2724
+ /**
2725
+ * @method
2726
+ * @name pacifica#fetchLedger
2727
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2728
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-balance-history
2729
+ * @param {string} [code] unified currency code
2730
+ * @param {int} [since] timestamp in ms of the earliest ledger entry
2731
+ * @param {int} [limit] max number of ledger entries to return
2732
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2733
+ * @param {string} [params.account] will default to walletAddress if not provided
2734
+ * @param {string} [params.cursor] pagination cursor from prev request (manual use)
2735
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2736
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
2737
+ */
2738
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2739
+ await this.loadMarkets();
2740
+ let paginate = false;
2741
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate', false);
2742
+ let userAddress = undefined;
2743
+ [userAddress, params] = this.handleOriginAndSingleAddress('fetchLedger', params);
2744
+ const defaultLimit = 100; // Default max limit
2745
+ if (paginate) {
2746
+ return await this.fetchPaginatedCallCursor('fetchLedger', code, since, limit, params, 'next_cursor', 'cursor', undefined, defaultLimit);
2747
+ }
2748
+ const request = {
2749
+ 'account': userAddress,
2750
+ };
2751
+ if (limit !== undefined) {
2752
+ request['limit'] = limit;
2753
+ }
2754
+ const response = await this.publicGetAccountBalanceHistory(this.extend(request, params));
2755
+ // {
2756
+ // "success": true,
2757
+ // "data": [
2758
+ // {
2759
+ // "amount": "100.000000",
2760
+ // "balance": "1200.000000",
2761
+ // "pending_balance": "0.000000",
2762
+ // "event_type": "deposit",
2763
+ // "created_at": 1716200000000
2764
+ // }
2765
+ // ...
2766
+ // ],
2767
+ // "next_cursor": "11114Lz77",
2768
+ // "has_more": true
2769
+ // }
2770
+ const data = this.addPaginationCursorToResult(response);
2771
+ return this.parseLedger(data, undefined, since, limit);
2772
+ }
2773
+ parseLedgerEntry(item, currency = undefined) {
2774
+ //
2775
+ // {
2776
+ // "amount": "100.000000",
2777
+ // "balance": "1200.000000",
2778
+ // "pending_balance": "0.000000",
2779
+ // "event_type": "deposit",
2780
+ // "created_at": 1716200000000
2781
+ // }
2782
+ //
2783
+ const timestamp = this.safeInteger(item, 'created_at');
2784
+ const type = this.safeString(item, 'event_type');
2785
+ const amount = this.safeString(item, 'amount');
2786
+ const balance = this.safeString(item, 'balance');
2787
+ return this.safeLedgerEntry({
2788
+ 'info': item,
2789
+ 'id': undefined,
2790
+ 'direction': undefined,
2791
+ 'account': undefined,
2792
+ 'referenceAccount': undefined,
2793
+ 'referenceId': undefined,
2794
+ 'type': this.parseLedgerEntryType(type),
2795
+ 'currency': undefined,
2796
+ 'amount': this.parseNumber(amount),
2797
+ 'timestamp': timestamp,
2798
+ 'datetime': this.iso8601(timestamp),
2799
+ 'before': undefined,
2800
+ 'after': this.parseNumber(balance),
2801
+ 'status': undefined,
2802
+ 'fee': undefined,
2803
+ }, currency);
2804
+ }
2805
+ parseLedgerEntryType(type) {
2806
+ const ledgerType = {
2807
+ 'subaccount_transfer': 'transfer',
2808
+ 'deposit': 'transaction',
2809
+ 'deposit_release': 'transaction',
2810
+ 'withdraw': 'transaction',
2811
+ 'trade': 'trade',
2812
+ 'market_liquidation': 'trade',
2813
+ 'backstop_liquidation': 'trade',
2814
+ 'adl_liquidation': 'trade',
2815
+ 'funding': 'funding',
2816
+ 'fee': 'fee',
2817
+ 'rebate': 'rebate',
2818
+ 'cashback': 'cashback',
2819
+ 'referral': 'referral',
2820
+ 'airdrop': 'airdrop',
2821
+ 'payout': 'payout',
2822
+ };
2823
+ return this.safeString(ledgerType, type, type);
2824
+ }
2825
+ /**
2826
+ * @method
2827
+ * @name pacifica#fetchFundingHistory
2828
+ * @description fetch the history of funding payments paid and received on this account
2829
+ * @param {string} [symbol] unified market symbol
2830
+ * @param {int} [since] the earliest time in ms to fetch funding history for
2831
+ * @param {int} [limit] the maximum number of funding history structures to retrieve
2832
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2833
+ * @param {string} [params.account] will default to walletAddress if not provided
2834
+ * @param {string} [params.cursor] pagination cursor from prev request
2835
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2836
+ * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/?id=funding-history-structure}
2837
+ */
2838
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2839
+ await this.loadMarkets();
2840
+ let market = undefined;
2841
+ if (symbol !== undefined) {
2842
+ market = this.market(symbol);
2843
+ }
2844
+ let paginate = false;
2845
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate', false);
2846
+ let userAddress = undefined;
2847
+ [userAddress, params] = this.handleOriginAndSingleAddress('fetchFundingHistory', params);
2848
+ const request = {
2849
+ 'account': userAddress,
2850
+ };
2851
+ if (limit !== undefined) {
2852
+ request['limit'] = limit;
2853
+ }
2854
+ const defaultLimit = 100;
2855
+ if (paginate) {
2856
+ return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'next_cursor', 'cursor', undefined, defaultLimit);
2857
+ }
2858
+ const response = await this.publicGetFundingHistory(this.extend(request, params));
2859
+ // {
2860
+ // "success": true,
2861
+ // "data": [
2862
+ // {
2863
+ // "history_id": 2287920,
2864
+ // "symbol": "PUMP",
2865
+ // "side": "ask",
2866
+ // "amount": "39033804",
2867
+ // "payout": "2.617479",
2868
+ // "rate": "0.0000125",
2869
+ // "created_at": 1759222804122
2870
+ // },
2871
+ // ...
2872
+ // ],
2873
+ // "next_cursor": "11114Lz77",
2874
+ // "has_more": true
2875
+ // }
2876
+ const data = this.addPaginationCursorToResult(response);
2877
+ return this.parseIncomes(data, market, since, limit);
2878
+ }
2879
+ parseIncome(income, market = undefined) {
2880
+ //
2881
+ // {
2882
+ // "history_id": 2287920,
2883
+ // "symbol": "PUMP",
2884
+ // "side": "ask",
2885
+ // "amount": "39033804",
2886
+ // "payout": "2.617479",
2887
+ // "rate": "0.0000125",
2888
+ // "created_at": 1759222804122
2889
+ // }
2890
+ //
2891
+ const id = this.safeString(income, 'history_id');
2892
+ const timestamp = this.safeInteger(income, 'created_at');
2893
+ const marketId = this.safeString(income, 'symbol');
2894
+ market = this.safeMarket(marketId, market);
2895
+ const symbol = market['symbol'];
2896
+ const amount = this.safeString(income, 'amount');
2897
+ const code = this.safeCurrencyCode('USDC');
2898
+ const rate = this.safeNumber(income, 'rate');
2899
+ return {
2900
+ 'info': income,
2901
+ 'symbol': symbol,
2902
+ 'code': code,
2903
+ 'timestamp': timestamp,
2904
+ 'datetime': this.iso8601(timestamp),
2905
+ 'id': id,
2906
+ 'amount': this.parseNumber(amount),
2907
+ 'rate': rate,
2908
+ };
2909
+ }
2910
+ /**
2911
+ * @method
2912
+ * @name pacifica#transfer
2913
+ * @description transfer currency internally between wallets on the same account
2914
+ * @see https://docs.pacifica.fi/api-documentation/api/rest-api/subaccounts/subaccount-fund-transfer
2915
+ * @param {string} code unified currency code
2916
+ * @param {float} amount amount to transfer
2917
+ * @param {string} fromAccount account to transfer from *spot, swap*
2918
+ * @param {string} toAccount account to transfer to *swap, spot or address*
2919
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2920
+ * @param {int} [params.expiryWindow] time to live in milliseconds
2921
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
2922
+ */
2923
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
2924
+ const operationType = 'transfer_funds';
2925
+ const sigPayload = {
2926
+ 'to_account': toAccount,
2927
+ 'amount': amount,
2928
+ };
2929
+ const request = this.postActionRequest(operationType, sigPayload, params);
2930
+ params = this.omit(params, ['expiryWindow']);
2931
+ const response = this.privatePostAccountSubaccountTransfer(this.extend(request, params));
2932
+ //
2933
+ // {
2934
+ // "success": true,
2935
+ // "data": {
2936
+ // "success": true,
2937
+ // "error": null
2938
+ // },
2939
+ // "error": null,
2940
+ // "code": null
2941
+ // }
2942
+ //
2943
+ const data = this.safeDict(response, 'data', {});
2944
+ return this.parseTransfer(data);
2945
+ }
2946
+ parseTransfer(transfer, currency = undefined) {
2947
+ //
2948
+ // {
2949
+ // "success": true,
2950
+ // "data": {
2951
+ // "success": true,
2952
+ // "error": null
2953
+ // },
2954
+ // "error": null,
2955
+ // "code": null
2956
+ // }
2957
+ //
2958
+ return {
2959
+ 'info': transfer,
2960
+ 'id': undefined,
2961
+ 'timestamp': undefined,
2962
+ 'datetime': undefined,
2963
+ 'currency': undefined,
2964
+ 'amount': undefined,
2965
+ 'fromAccount': undefined,
2966
+ 'toAccount': undefined,
2967
+ 'status': 'ok',
2968
+ };
2969
+ }
2970
+ /**
2971
+ * @method
2972
+ * @name pacifica#createSubAccount
2973
+ * @description creates a sub-account under the main account
2974
+ * @param {string} name unused argument
2975
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2976
+ * @param {int} [params.expiryWindow] time to live in milliseconds
2977
+ * @param {string} [params.subAccountAddress] - The public key (address) of the sub-account to use for creation
2978
+ * @param {string} [params.subAccountPrivateKey] - The private key of the sub-account to use for creation
2979
+ * @returns {object} a response object
2980
+ */
2981
+ async createSubAccount(name, params = {}) {
2982
+ const finalHeaders = {};
2983
+ let agentAddress = undefined;
2984
+ [agentAddress, params] = this.handleOption('createSubAccount', 'agentAddress', undefined);
2985
+ let originAddress = undefined;
2986
+ [originAddress, params] = this.handleOriginAndSingleAddress('createSubAccount', params);
2987
+ if (originAddress === undefined) {
2988
+ throw new errors.ArgumentsRequired(this.id + ' createSubAccount() requires "originAddress" in params or "walletAddress" in requiredCredentials');
2989
+ }
2990
+ if (agentAddress !== undefined) {
2991
+ finalHeaders['agent_wallet'] = agentAddress;
2992
+ }
2993
+ let subAccountAddress = undefined;
2994
+ [subAccountAddress, params] = this.handleOptionAndParams(params, 'createSubAccount', 'subAccountAddress');
2995
+ let subAccountPrivateKey = undefined;
2996
+ [subAccountPrivateKey, params] = this.handleOptionAndParams(params, 'createSubAccount', 'subAccountPrivateKey');
2997
+ if (subAccountAddress === undefined) {
2998
+ throw new errors.ArgumentsRequired(this.id + ' createSubAccount() requires a "subAccountAddress"!');
2999
+ }
3000
+ if (subAccountPrivateKey === undefined) {
3001
+ throw new errors.ArgumentsRequired(this.id + ' createSubAccount() requires a "subAccountPrivateKey"!');
3002
+ }
3003
+ const timestamp = this.milliseconds();
3004
+ let expiryWindow = undefined;
3005
+ [expiryWindow, params] = this.handleOptionAndParams2(params, 'createSubAccount', 'expiryWindow', 'expiry_window', 5000);
3006
+ const subaccountSignatureHeader = {
3007
+ 'timestamp': timestamp,
3008
+ 'expiry_window': expiryWindow,
3009
+ 'type': 'subaccount_initiate',
3010
+ };
3011
+ const subSigPayload = {
3012
+ 'account': originAddress,
3013
+ };
3014
+ const subaccountSignature = this.signMessage(subaccountSignatureHeader, subSigPayload, subAccountPrivateKey);
3015
+ const mainSignatureHeader = {
3016
+ 'timestamp': timestamp,
3017
+ 'expiry_window': expiryWindow,
3018
+ 'type': 'subaccount_confirm',
3019
+ };
3020
+ const mainSigPayload = {
3021
+ 'signature': subaccountSignature,
3022
+ };
3023
+ const main_signature = this.signMessage(mainSignatureHeader, mainSigPayload, this.privateKey);
3024
+ finalHeaders['main_account'] = originAddress;
3025
+ finalHeaders['subaccount'] = subAccountAddress;
3026
+ finalHeaders['sub_signature'] = subaccountSignature;
3027
+ finalHeaders['main_signature'] = main_signature;
3028
+ finalHeaders['timestamp'] = timestamp;
3029
+ finalHeaders['expiry_window'] = expiryWindow;
3030
+ const request = finalHeaders;
3031
+ const response = await this.privatePostAccountSubaccountCreate(request);
3032
+ //
3033
+ // {
3034
+ // "success": true,
3035
+ // "data": null,
3036
+ // "error": null,
3037
+ // "code": null,
3038
+ // }
3039
+ //
3040
+ return response;
3041
+ }
3042
+ async bindAgentWallet(agentAddress, params = {}) {
3043
+ const operationType = 'bind_agent_wallet';
3044
+ const sigPayload = {
3045
+ 'agent_wallet': agentAddress,
3046
+ };
3047
+ const request = this.postActionRequest(operationType, sigPayload, params);
3048
+ return await this.privatePostAgentBind(this.extend(request, params));
3049
+ }
3050
+ async createApiKey(params = {}) {
3051
+ const operationType = 'create_api_key';
3052
+ const sigPayload = {};
3053
+ const request = this.postActionRequest(operationType, sigPayload, params);
3054
+ return await this.privatePostAccountApiKeysCreate(this.extend(request, params));
3055
+ }
3056
+ async revokeApiKey(apiKey, params = {}) {
3057
+ const operationType = 'revoke_api_key';
3058
+ const sigPayload = {
3059
+ 'api_key': apiKey,
3060
+ };
3061
+ const request = this.postActionRequest(operationType, sigPayload, params);
3062
+ return await this.privatePostAccountApiKeysRevoke(this.extend(request, params));
3063
+ }
3064
+ async fetchApiKeys(params = {}) {
3065
+ const operationType = 'list_api_keys';
3066
+ const sigPayload = {};
3067
+ const request = this.postActionRequest(operationType, sigPayload, params);
3068
+ return await this.privatePostAccountApiKeys(this.extend(request, params));
3069
+ }
3070
+ async approveBuilderCode(builderCode, maxFeeRate, params = {}) {
3071
+ const operationType = 'approve_builder_code';
3072
+ const sigPayload = {
3073
+ 'builder_code': builderCode,
3074
+ 'max_fee_rate': maxFeeRate,
3075
+ };
3076
+ const request = this.postActionRequest(operationType, sigPayload, params);
3077
+ return await this.privatePostAccountBuilderCodesApprove(this.extend(request, params));
3078
+ }
3079
+ async fetchBuilderApprovals(address) {
3080
+ const request = {
3081
+ 'account': address,
3082
+ };
3083
+ return await this.publicGetAccountBuilderCodesApprovals(this.extend(request));
3084
+ }
3085
+ async revokeBuilderCode(builderCode, params = {}) {
3086
+ const operationType = 'revoke_builder_code';
3087
+ const sigPayload = {
3088
+ 'builder_code': builderCode,
3089
+ };
3090
+ const request = this.postActionRequest(operationType, sigPayload, params);
3091
+ return await this.privatePostAccountBuilderCodesRevoke(this.extend(request, params));
3092
+ }
3093
+ handleOriginAndSingleAddress(methodName, params) {
3094
+ let address = undefined;
3095
+ [address, params] = this.handleParamString2(params, 'account', 'address', undefined); // this is for get endpoints that accept account or address
3096
+ if (address !== undefined) {
3097
+ return [address, params];
3098
+ }
3099
+ const address1 = this.walletAddress;
3100
+ if (address1 !== undefined) {
3101
+ return [address1, params];
3102
+ }
3103
+ throw new errors.ArgumentsRequired(this.id + ' ' + methodName + '() requires address either as "exchange.walletAddress = ..." or as parameter or "address" in params');
3104
+ }
3105
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3106
+ if (response === undefined) {
3107
+ return undefined; // fallback to default error handler
3108
+ }
3109
+ //
3110
+ // {"success":false,"data":null,"error":"Beta access required. Signer must redeem a valid beta code.","code":403}
3111
+ // {"success":false,"data":null,"error":"Agent not authorized for account","code":400}
3112
+ // {"success":false,"data":null,"error":"Internal server error","code":500}
3113
+ //
3114
+ const inCode = this.safeInteger(response, 'code'); // actually if all ok -> code = undefined or code = 200
3115
+ const message = this.safeString(response, 'error');
3116
+ let error = undefined;
3117
+ if (inCode === undefined || inCode === 200) {
3118
+ error = false;
3119
+ }
3120
+ else {
3121
+ error = true;
3122
+ }
3123
+ const nonEmptyMessage = ((message !== undefined) && (message !== ''));
3124
+ if (error || nonEmptyMessage) {
3125
+ const feedback = this.id + ' ' + body;
3126
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback); // Try deeper catch first
3127
+ this.throwExactlyMatchedException(this.exceptions['exact'], inCode, feedback);
3128
+ this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
3129
+ throw new errors.ExchangeError(feedback); // unknown message
3130
+ }
3131
+ return undefined;
3132
+ }
3133
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3134
+ const isTestnet = this.isSandboxModeEnabled;
3135
+ const urlKey = (isTestnet) ? 'test' : 'api';
3136
+ const host = this.implodeHostname(this.urls[urlKey][api]);
3137
+ let url = host + '/api/' + this.version + '/' + this.implodeParams(path, params);
3138
+ params = this.omit(params, this.extractParams(path));
3139
+ const paramsLen = Object.keys(params).length;
3140
+ headers = {
3141
+ 'Content-Type': 'application/json',
3142
+ };
3143
+ if (method === 'GET' && paramsLen) {
3144
+ url += '?' + this.urlencode(params);
3145
+ headers['Accept'] = '*/*';
3146
+ }
3147
+ if (method === 'POST') {
3148
+ body = this.json(params);
3149
+ }
3150
+ if (this.handleOption('sign', 'apiKey', undefined) !== undefined) {
3151
+ headers['PF-API-KEY'] = this.options['apiKey'];
3152
+ }
3153
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3154
+ }
3155
+ calculateRateLimiterCost(api, method, path, params, config = {}) {
3156
+ const cost = this.safeString(config, 'cost', '1');
3157
+ const costNumber = this.parseNumber(cost);
3158
+ // 1 is normal POST/GET, 0.5 is cancels, 3-12 is heavy GET
3159
+ if (costNumber > 1) {
3160
+ if (this.handleOption(method, 'apiKey', undefined) !== undefined) {
3161
+ const costWithKey = this.handleOption(method, 'maxCostHugeWithApiKey', 3);
3162
+ return costWithKey;
3163
+ }
3164
+ }
3165
+ return costNumber;
3166
+ }
3167
+ sortJsonKeys(value) {
3168
+ if (typeof value === 'object') {
3169
+ const result = {};
3170
+ const keys = Object.keys(value);
3171
+ const sortedKeys = this.sort(keys);
3172
+ for (let i = 0; i < sortedKeys.length; i++) {
3173
+ const key = sortedKeys[i];
3174
+ result[key] = this.sortJsonKeys(value[key]);
3175
+ }
3176
+ return result;
3177
+ }
3178
+ else if (Array.isArray(value)) {
3179
+ const result = [];
3180
+ for (let i = 0; i < value.length; i++) {
3181
+ result.push(this.sortJsonKeys(value[i]));
3182
+ }
3183
+ return result;
3184
+ }
3185
+ else {
3186
+ return value;
3187
+ }
3188
+ }
3189
+ prepareMessage(header, payload) {
3190
+ if (header['type'] === undefined || header['timestamp'] === undefined || header['expiry_window'] === undefined) {
3191
+ throw new errors.ArgumentsRequired(this.id + ' prepareMessage() requires type, timestamp, expiry_window in header');
3192
+ }
3193
+ const data = this.extend(header, { 'data': payload });
3194
+ const sorted = this.sortJsonKeys(data);
3195
+ return this.json(sorted);
3196
+ }
3197
+ signMessage(header, payload, privateKey) {
3198
+ const message = this.prepareMessage(header, payload);
3199
+ const messageBytes = this.encode(message);
3200
+ const secretBytes = this.base58ToBinary(privateKey);
3201
+ const seed = this.arraySlice(secretBytes, 0, 32);
3202
+ const signatureBase64 = crypto.eddsa(messageBytes, seed, ed25519.ed25519);
3203
+ const signatureBinary = this.base64ToBinary(signatureBase64);
3204
+ const signatureBase58 = this.binaryToBase58(signatureBinary);
3205
+ return signatureBase58;
3206
+ }
3207
+ postActionRequest(operationType, sigPayload, params) {
3208
+ this.checkRequiredCredentials(); // check credentials every post action
3209
+ if (operationType === 'undefined') {
3210
+ throw new errors.ArgumentsRequired(this.id + ' action: ' + operationType + ' postActionRequest() requires "operationType"');
3211
+ }
3212
+ if (!this.isSandboxModeEnabled) { // At this stage, building codes are mostly only on the mainnet.
3213
+ const useBuilder = this.handleOption('postActionRequest', 'builderFee', true);
3214
+ let builderCode = undefined;
3215
+ if (useBuilder) {
3216
+ builderCode = this.handleOption('postActionRequest', 'builderCode');
3217
+ }
3218
+ if (builderCode !== undefined) {
3219
+ const isOperationSupportBuilder = this.safeBool(this.options['builderSupportOperations'], operationType, false);
3220
+ if (isOperationSupportBuilder) {
3221
+ sigPayload['builder_code'] = builderCode;
3222
+ }
3223
+ }
3224
+ }
3225
+ let expiryWindow = undefined;
3226
+ [expiryWindow, params] = this.handleOptionAndParams2(params, 'postActionRequest', 'expiryWindow', 'expiry_window', 5000);
3227
+ const timestamp = this.safeInteger(params, 'timestamp', this.milliseconds());
3228
+ const signatureHeader = {
3229
+ 'timestamp': timestamp,
3230
+ 'expiry_window': expiryWindow,
3231
+ 'type': operationType,
3232
+ };
3233
+ const signature = this.signMessage(signatureHeader, sigPayload, this.privateKey);
3234
+ const finalHeaders = {};
3235
+ let agentAddress = undefined;
3236
+ [agentAddress, params] = this.handleOptionAndParams(params, 'postActionRequest', 'agentAddress');
3237
+ let originAddress = undefined;
3238
+ [originAddress, params] = this.handleOriginAndSingleAddress('postActionRequest', params);
3239
+ if (originAddress === undefined) {
3240
+ throw new errors.ArgumentsRequired(this.id + ' action: ' + operationType + ' postActionRequest() requires "originAddress" in params or "walletAddress" in requiredCredentials');
3241
+ }
3242
+ finalHeaders['account'] = originAddress;
3243
+ if (agentAddress !== undefined) {
3244
+ finalHeaders['agent_wallet'] = agentAddress;
3245
+ }
3246
+ finalHeaders['signature'] = signature;
3247
+ finalHeaders['timestamp'] = this.safeInteger(signatureHeader, 'timestamp');
3248
+ finalHeaders['expiry_window'] = this.safeInteger(signatureHeader, 'expiry_window');
3249
+ const request = this.extend(finalHeaders, sigPayload);
3250
+ return request;
3251
+ }
3252
+ }
3253
+
3254
+ exports["default"] = pacifica;