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