ccxt 4.5.56 → 4.5.57

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 (261) hide show
  1. package/README.md +10 -9
  2. package/dist/ccxt.browser.min.js +10 -10
  3. package/dist/cjs/ccxt.js +6 -11
  4. package/dist/cjs/src/apex.js +1 -1
  5. package/dist/cjs/src/arkham.js +3 -3
  6. package/dist/cjs/src/ascendex.js +2 -2
  7. package/dist/cjs/src/aster.js +7 -4
  8. package/dist/cjs/src/backpack.js +4 -4
  9. package/dist/cjs/src/base/Exchange.js +69 -32
  10. package/dist/cjs/src/base/functions/io.js +25 -0
  11. package/dist/cjs/src/base/functions.js +1 -0
  12. package/dist/cjs/src/bigone.js +3 -3
  13. package/dist/cjs/src/binance.js +192 -194
  14. package/dist/cjs/src/bingx.js +3 -3
  15. package/dist/cjs/src/bitfinex.js +71 -58
  16. package/dist/cjs/src/bitget.js +2 -2
  17. package/dist/cjs/src/bitmart.js +13 -6
  18. package/dist/cjs/src/bitmex.js +1 -1
  19. package/dist/cjs/src/bitopro.js +1 -1
  20. package/dist/cjs/src/bitrue.js +2 -2
  21. package/dist/cjs/src/bitso.js +1 -1
  22. package/dist/cjs/src/bitstamp.js +2 -1
  23. package/dist/cjs/src/bitteam.js +1 -1
  24. package/dist/cjs/src/bittrade.js +0 -1
  25. package/dist/cjs/src/bitvavo.js +457 -34
  26. package/dist/cjs/src/blofin.js +26 -3
  27. package/dist/cjs/src/bullish.js +6 -5
  28. package/dist/cjs/src/bydfi.js +1 -1
  29. package/dist/cjs/src/cex.js +3 -3
  30. package/dist/cjs/src/coinbase.js +75 -65
  31. package/dist/cjs/src/coinbaseexchange.js +2 -2
  32. package/dist/cjs/src/coinbaseinternational.js +2 -1
  33. package/dist/cjs/src/coinex.js +74 -74
  34. package/dist/cjs/src/coinmetro.js +1 -1
  35. package/dist/cjs/src/coinsph.js +1 -1
  36. package/dist/cjs/src/cryptocom.js +46 -48
  37. package/dist/cjs/src/cryptomus.js +43 -39
  38. package/dist/cjs/src/deepcoin.js +3 -2
  39. package/dist/cjs/src/delta.js +51 -52
  40. package/dist/cjs/src/deribit.js +31 -33
  41. package/dist/cjs/src/derive.js +26 -28
  42. package/dist/cjs/src/digifinex.js +43 -44
  43. package/dist/cjs/src/exmo.js +92 -83
  44. package/dist/cjs/src/extended.js +3497 -0
  45. package/dist/cjs/src/foxbit.js +71 -75
  46. package/dist/cjs/src/gate.js +53 -53
  47. package/dist/cjs/src/gemini.js +41 -43
  48. package/dist/cjs/src/grvt.js +4 -4
  49. package/dist/cjs/src/hashkey.js +52 -54
  50. package/dist/cjs/src/hitbtc.js +3 -13
  51. package/dist/cjs/src/hollaex.js +51 -54
  52. package/dist/cjs/src/htx.js +75 -67
  53. package/dist/cjs/src/hyperliquid.js +41 -42
  54. package/dist/cjs/src/indodax.js +2 -2
  55. package/dist/cjs/src/kraken.js +57 -58
  56. package/dist/cjs/src/kucoin.js +3 -2
  57. package/dist/cjs/src/latoken.js +30 -32
  58. package/dist/cjs/src/lbank.js +56 -56
  59. package/dist/cjs/src/lighter.js +35 -37
  60. package/dist/cjs/src/luno.js +35 -43
  61. package/dist/cjs/src/mexc.js +48 -49
  62. package/dist/cjs/src/modetrade.js +50 -52
  63. package/dist/cjs/src/ndax.js +35 -37
  64. package/dist/cjs/src/okx.js +17 -2
  65. package/dist/cjs/src/onetrading.js +21 -23
  66. package/dist/cjs/src/phemex.js +43 -45
  67. package/dist/cjs/src/poloniex.js +17 -12
  68. package/dist/cjs/src/pro/alpaca.js +1 -1
  69. package/dist/cjs/src/pro/apex.js +1 -1
  70. package/dist/cjs/src/pro/arkham.js +1 -1
  71. package/dist/cjs/src/pro/backpack.js +1 -1
  72. package/dist/cjs/src/pro/binance.js +3 -3
  73. package/dist/cjs/src/pro/bitget.js +1 -1
  74. package/dist/cjs/src/pro/bithumb.js +1 -1
  75. package/dist/cjs/src/pro/bitstamp.js +1 -1
  76. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  77. package/dist/cjs/src/pro/bybit.js +1 -1
  78. package/dist/cjs/src/pro/cex.js +1 -1
  79. package/dist/cjs/src/pro/coinex.js +1 -1
  80. package/dist/cjs/src/pro/coinone.js +1 -1
  81. package/dist/cjs/src/pro/cryptocom.js +3 -1
  82. package/dist/cjs/src/pro/dydx.js +1 -1
  83. package/dist/cjs/src/pro/exmo.js +1 -1
  84. package/dist/cjs/src/pro/extended.js +865 -0
  85. package/dist/cjs/src/pro/gate.js +1 -1
  86. package/dist/cjs/src/pro/independentreserve.js +1 -1
  87. package/dist/cjs/src/pro/kucoin.js +1 -1
  88. package/dist/cjs/src/pro/luno.js +3 -3
  89. package/dist/cjs/src/pro/onetrading.js +1 -1
  90. package/dist/cjs/src/pro/toobit.js +1 -1
  91. package/dist/cjs/src/pro/weex.js +1 -1
  92. package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +7 -7
  93. package/dist/cjs/src/tokocrypto.js +1 -1
  94. package/dist/cjs/src/toobit.js +2 -2
  95. package/dist/cjs/src/upbit.js +3 -3
  96. package/dist/cjs/src/weex.js +57 -62
  97. package/dist/cjs/src/whitebit.js +61 -63
  98. package/dist/cjs/src/woo.js +65 -54
  99. package/dist/cjs/src/woofipro.js +53 -47
  100. package/dist/cjs/src/xt.js +1 -1
  101. package/dist/cjs/src/zebpay.js +70 -72
  102. package/js/ccxt.d.ts +8 -14
  103. package/js/ccxt.js +6 -10
  104. package/js/src/abstract/bitvavo.d.ts +15 -7
  105. package/js/src/abstract/extended.d.ts +58 -0
  106. package/js/src/apex.js +1 -1
  107. package/js/src/arkham.js +3 -3
  108. package/js/src/ascendex.js +2 -2
  109. package/js/src/aster.js +7 -4
  110. package/js/src/backpack.js +4 -4
  111. package/js/src/base/Exchange.d.ts +10 -6
  112. package/js/src/base/Exchange.js +69 -32
  113. package/js/src/base/functions/io.d.ts +7 -0
  114. package/js/src/base/functions/io.js +24 -0
  115. package/js/src/bigone.js +3 -3
  116. package/js/src/binance.d.ts +2 -0
  117. package/js/src/binance.js +196 -198
  118. package/js/src/bingx.js +3 -3
  119. package/js/src/bitfinex.d.ts +2 -0
  120. package/js/src/bitfinex.js +71 -58
  121. package/js/src/bitget.js +2 -2
  122. package/js/src/bitmart.js +13 -6
  123. package/js/src/bitmex.js +1 -1
  124. package/js/src/bitopro.js +1 -1
  125. package/js/src/bitrue.js +2 -2
  126. package/js/src/bitso.js +1 -1
  127. package/js/src/bitstamp.js +2 -1
  128. package/js/src/bitteam.js +1 -1
  129. package/js/src/bittrade.js +0 -1
  130. package/js/src/bitvavo.d.ts +114 -21
  131. package/js/src/bitvavo.js +457 -34
  132. package/js/src/blofin.d.ts +1 -0
  133. package/js/src/blofin.js +26 -3
  134. package/js/src/bullish.js +6 -5
  135. package/js/src/bydfi.js +1 -1
  136. package/js/src/cex.js +3 -3
  137. package/js/src/coinbase.d.ts +63 -56
  138. package/js/src/coinbase.js +75 -65
  139. package/js/src/coinbaseexchange.js +2 -2
  140. package/js/src/coinbaseinternational.js +2 -1
  141. package/js/src/coinex.d.ts +1 -0
  142. package/js/src/coinex.js +74 -74
  143. package/js/src/coinmetro.d.ts +1 -1
  144. package/js/src/coinmetro.js +1 -1
  145. package/js/src/coinsph.js +1 -1
  146. package/js/src/cryptocom.d.ts +1 -0
  147. package/js/src/cryptocom.js +46 -48
  148. package/js/src/cryptomus.d.ts +2 -1
  149. package/js/src/cryptomus.js +43 -39
  150. package/js/src/deepcoin.js +3 -2
  151. package/js/src/delta.d.ts +1 -0
  152. package/js/src/delta.js +51 -52
  153. package/js/src/deribit.d.ts +1 -0
  154. package/js/src/deribit.js +31 -33
  155. package/js/src/derive.d.ts +1 -0
  156. package/js/src/derive.js +26 -28
  157. package/js/src/digifinex.d.ts +1 -0
  158. package/js/src/digifinex.js +43 -44
  159. package/js/src/exmo.d.ts +1 -0
  160. package/js/src/exmo.js +92 -83
  161. package/js/src/extended.d.ts +554 -0
  162. package/js/src/extended.js +3490 -0
  163. package/js/src/foxbit.d.ts +1 -0
  164. package/js/src/foxbit.js +71 -75
  165. package/js/src/gate.d.ts +1 -0
  166. package/js/src/gate.js +53 -53
  167. package/js/src/gemini.d.ts +2 -1
  168. package/js/src/gemini.js +41 -43
  169. package/js/src/grvt.js +4 -4
  170. package/js/src/hashkey.d.ts +1 -0
  171. package/js/src/hashkey.js +52 -54
  172. package/js/src/hitbtc.d.ts +0 -1
  173. package/js/src/hitbtc.js +3 -13
  174. package/js/src/hollaex.d.ts +1 -0
  175. package/js/src/hollaex.js +51 -54
  176. package/js/src/htx.d.ts +1 -0
  177. package/js/src/htx.js +75 -67
  178. package/js/src/hyperliquid.d.ts +1 -0
  179. package/js/src/hyperliquid.js +41 -42
  180. package/js/src/indodax.js +2 -2
  181. package/js/src/kraken.d.ts +2 -1
  182. package/js/src/kraken.js +57 -58
  183. package/js/src/kucoin.js +3 -2
  184. package/js/src/latoken.d.ts +1 -0
  185. package/js/src/latoken.js +30 -32
  186. package/js/src/lbank.d.ts +1 -0
  187. package/js/src/lbank.js +56 -56
  188. package/js/src/lighter.d.ts +1 -0
  189. package/js/src/lighter.js +35 -37
  190. package/js/src/luno.d.ts +1 -0
  191. package/js/src/luno.js +35 -43
  192. package/js/src/mexc.d.ts +2 -1
  193. package/js/src/mexc.js +48 -49
  194. package/js/src/modetrade.d.ts +1 -0
  195. package/js/src/modetrade.js +50 -52
  196. package/js/src/ndax.d.ts +1 -0
  197. package/js/src/ndax.js +35 -37
  198. package/js/src/okx.js +17 -2
  199. package/js/src/onetrading.d.ts +2 -1
  200. package/js/src/onetrading.js +21 -23
  201. package/js/src/phemex.d.ts +1 -0
  202. package/js/src/phemex.js +43 -45
  203. package/js/src/poloniex.js +17 -12
  204. package/js/src/pro/alpaca.js +1 -1
  205. package/js/src/pro/apex.js +1 -1
  206. package/js/src/pro/arkham.js +1 -1
  207. package/js/src/pro/backpack.js +1 -1
  208. package/js/src/pro/binance.js +3 -3
  209. package/js/src/pro/bitget.js +1 -1
  210. package/js/src/pro/bithumb.js +1 -1
  211. package/js/src/pro/bitstamp.js +1 -1
  212. package/js/src/pro/blockchaincom.js +1 -1
  213. package/js/src/pro/bybit.js +1 -1
  214. package/js/src/pro/cex.js +1 -1
  215. package/js/src/pro/coinex.js +1 -1
  216. package/js/src/pro/coinone.js +1 -1
  217. package/js/src/pro/cryptocom.js +3 -1
  218. package/js/src/pro/dydx.js +1 -1
  219. package/js/src/pro/exmo.js +1 -1
  220. package/js/src/pro/extended.d.ts +126 -0
  221. package/js/src/pro/extended.js +858 -0
  222. package/js/src/pro/gate.js +1 -1
  223. package/js/src/pro/independentreserve.js +1 -1
  224. package/js/src/pro/kucoin.js +1 -1
  225. package/js/src/pro/luno.d.ts +1 -1
  226. package/js/src/pro/luno.js +3 -3
  227. package/js/src/pro/onetrading.js +1 -1
  228. package/js/src/pro/toobit.js +1 -1
  229. package/js/src/pro/weex.js +1 -1
  230. package/js/src/tokocrypto.js +1 -1
  231. package/js/src/toobit.js +2 -2
  232. package/js/src/upbit.js +3 -3
  233. package/js/src/weex.d.ts +1 -0
  234. package/js/src/weex.js +57 -62
  235. package/js/src/whitebit.d.ts +1 -0
  236. package/js/src/whitebit.js +61 -63
  237. package/js/src/woo.d.ts +1 -0
  238. package/js/src/woo.js +65 -54
  239. package/js/src/woofipro.d.ts +1 -0
  240. package/js/src/woofipro.js +53 -47
  241. package/js/src/xt.js +1 -1
  242. package/js/src/zebpay.d.ts +2 -1
  243. package/js/src/zebpay.js +70 -72
  244. package/package.json +7 -7
  245. package/dist/cjs/src/gateio.js +0 -18
  246. package/dist/cjs/src/oxfun.js +0 -2933
  247. package/dist/cjs/src/pro/gateio.js +0 -18
  248. package/dist/cjs/src/pro/oxfun.js +0 -1113
  249. package/js/src/abstract/gateio.d.ts +0 -346
  250. package/js/src/abstract/gateio.js +0 -5
  251. package/js/src/abstract/oxfun.d.ts +0 -37
  252. package/js/src/gateio.d.ts +0 -4
  253. package/js/src/gateio.js +0 -11
  254. package/js/src/oxfun.d.ts +0 -442
  255. package/js/src/oxfun.js +0 -2926
  256. package/js/src/pro/gateio.d.ts +0 -4
  257. package/js/src/pro/gateio.js +0 -11
  258. package/js/src/pro/oxfun.d.ts +0 -234
  259. package/js/src/pro/oxfun.js +0 -1106
  260. /package/dist/cjs/src/abstract/{oxfun.js → extended.js} +0 -0
  261. /package/js/src/abstract/{oxfun.js → extended.js} +0 -0
package/js/src/oxfun.js DELETED
@@ -1,2926 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- import Exchange from './abstract/oxfun.js';
3
- import { AccountNotEnabled, ArgumentsRequired, AuthenticationError, BadRequest, BadSymbol, ExchangeError, InvalidOrder, InsufficientFunds, OrderNotFound, MarketClosed, NetworkError, NotSupported, OperationFailed, RateLimitExceeded, RequestTimeout } from './base/errors.js';
4
- import { TICK_SIZE } from './base/functions/number.js';
5
- import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
6
- // ---------------------------------------------------------------------------
7
- /**
8
- * @class oxfun
9
- * @augments Exchange
10
- */
11
- export default class oxfun extends Exchange {
12
- describe() {
13
- return this.deepExtend(super.describe(), {
14
- 'id': 'oxfun',
15
- 'name': 'OXFUN',
16
- 'countries': ['PA'],
17
- 'version': 'v3',
18
- 'rateLimit': 120,
19
- 'pro': true,
20
- 'has': {
21
- 'CORS': undefined,
22
- 'spot': true,
23
- 'margin': false,
24
- 'swap': true,
25
- 'future': false,
26
- 'option': false,
27
- 'addMargin': false,
28
- 'cancelAllOrders': true,
29
- 'cancelOrder': true,
30
- 'cancelOrders': true,
31
- 'closeAllPositions': false,
32
- 'closePosition': false,
33
- 'createDepositAddress': false,
34
- 'createMarketBuyOrderWithCost': true,
35
- 'createMarketOrderWithCost': false,
36
- 'createMarketSellOrderWithCost': false,
37
- 'createOrder': true,
38
- 'createOrders': true,
39
- 'createPostOnlyOrder': true,
40
- 'createReduceOnlyOrder': false,
41
- 'createStopLimitOrder': true,
42
- 'createStopMarketOrder': true,
43
- 'createStopOrder': true,
44
- 'deposit': false,
45
- 'editOrder': false,
46
- 'fetchAccounts': true,
47
- 'fetchBalance': true,
48
- 'fetchBidsAsks': false,
49
- 'fetchBorrowInterest': false,
50
- 'fetchBorrowRateHistories': false,
51
- 'fetchBorrowRateHistory': false,
52
- 'fetchCanceledOrders': false,
53
- 'fetchClosedOrder': false,
54
- 'fetchClosedOrders': false,
55
- 'fetchCrossBorrowRate': false,
56
- 'fetchCrossBorrowRates': false,
57
- 'fetchCurrencies': true,
58
- 'fetchDeposit': false,
59
- 'fetchDepositAddress': true,
60
- 'fetchDepositAddresses': false,
61
- 'fetchDepositAddressesByNetwork': false,
62
- 'fetchDeposits': true,
63
- 'fetchDepositWithdrawFee': false,
64
- 'fetchDepositWithdrawFees': false,
65
- 'fetchFundingHistory': true,
66
- 'fetchFundingRate': true,
67
- 'fetchFundingRateHistory': true,
68
- 'fetchFundingRates': true,
69
- 'fetchIndexOHLCV': false,
70
- 'fetchIsolatedBorrowRate': false,
71
- 'fetchIsolatedBorrowRates': false,
72
- 'fetchL3OrderBook': false,
73
- 'fetchLedger': false,
74
- 'fetchLeverage': false,
75
- 'fetchLeverageTiers': true,
76
- 'fetchMarketLeverageTiers': 'emulated',
77
- 'fetchMarkets': true,
78
- 'fetchMarkOHLCV': false,
79
- 'fetchMyTrades': true,
80
- 'fetchOHLCV': true,
81
- 'fetchOpenInterestHistory': false,
82
- 'fetchOpenOrder': false,
83
- 'fetchOpenOrders': true,
84
- 'fetchOrder': true,
85
- 'fetchOrderBook': true,
86
- 'fetchOrderBooks': false,
87
- 'fetchOrders': false,
88
- 'fetchOrderTrades': false,
89
- 'fetchPosition': false,
90
- 'fetchPositionHistory': false,
91
- 'fetchPositionMode': false,
92
- 'fetchPositions': true,
93
- 'fetchPositionsForSymbol': false,
94
- 'fetchPositionsHistory': false,
95
- 'fetchPositionsRisk': false,
96
- 'fetchPremiumIndexOHLCV': false,
97
- 'fetchStatus': false,
98
- 'fetchTicker': true,
99
- 'fetchTickers': true,
100
- 'fetchTime': false,
101
- 'fetchTrades': true,
102
- 'fetchTradingFee': false,
103
- 'fetchTradingFees': false,
104
- 'fetchTradingLimits': false,
105
- 'fetchTransactionFee': false,
106
- 'fetchTransactionFees': false,
107
- 'fetchTransactions': false,
108
- 'fetchTransfers': true,
109
- 'fetchWithdrawal': false,
110
- 'fetchWithdrawals': true,
111
- 'fetchWithdrawalWhitelist': false,
112
- 'reduceMargin': false,
113
- 'repayCrossMargin': false,
114
- 'repayIsolatedMargin': false,
115
- 'sandbox': true,
116
- 'setLeverage': false,
117
- 'setMargin': false,
118
- 'setMarginMode': false,
119
- 'setPositionMode': false,
120
- 'signIn': false,
121
- 'transfer': true,
122
- 'withdraw': true,
123
- 'ws': true,
124
- },
125
- 'timeframes': {
126
- '1m': '60s',
127
- '5m': '300s',
128
- '15m': '900s',
129
- '30m': '1800s',
130
- '1h': '3600s',
131
- '2h': '7200s',
132
- '4h': '14400s',
133
- '1d': '86400s',
134
- },
135
- 'urls': {
136
- 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/6a196124-c1ee-4fae-8573-962071b61a85',
137
- 'referral': 'https://ox.fun/register?shareAccountId=5ZUD4a7G',
138
- 'api': {
139
- 'public': 'https://api.ox.fun',
140
- 'private': 'https://api.ox.fun',
141
- },
142
- 'test': {
143
- 'public': 'https://stgapi.ox.fun',
144
- 'private': 'https://stgapi.ox.fun',
145
- },
146
- 'www': 'https://ox.fun/',
147
- 'doc': 'https://docs.ox.fun/',
148
- 'fees': 'https://support.ox.fun/en/articles/8819866-trading-fees',
149
- },
150
- 'api': {
151
- 'public': {
152
- 'get': {
153
- 'v3/markets': 1,
154
- 'v3/assets': 1,
155
- 'v3/tickers': 1,
156
- 'v3/funding/estimates': 1,
157
- 'v3/candles': 1,
158
- 'v3/depth': 1,
159
- 'v3/markets/operational': 1,
160
- 'v3/exchange-trades': 1,
161
- 'v3/funding/rates': 1,
162
- 'v3/leverage/tiers': 1,
163
- },
164
- },
165
- 'private': {
166
- 'get': {
167
- 'v3/account': 1,
168
- 'v3/account/names': 1,
169
- 'v3/wallet': 1,
170
- 'v3/transfer': 1,
171
- 'v3/balances': 1,
172
- 'v3/positions': 1,
173
- 'v3/funding': 1,
174
- 'v3/deposit-addresses': 1,
175
- 'v3/deposit': 1,
176
- 'v3/withdrawal-addresses': 1,
177
- 'v3/withdrawal': 1,
178
- 'v3/withdrawal-fees': 1,
179
- 'v3/orders/status': 1,
180
- 'v3/orders/working': 1,
181
- 'v3/trades': 1,
182
- },
183
- 'post': {
184
- 'v3/transfer': 1,
185
- 'v3/withdrawal': 1,
186
- 'v3/orders/place': 1,
187
- },
188
- 'delete': {
189
- 'v3/orders/cancel': 1,
190
- 'v3/orders/cancel-all': 1,
191
- },
192
- },
193
- },
194
- 'fees': {
195
- 'trading': {
196
- 'tierBased': true,
197
- 'percentage': true,
198
- 'maker': this.parseNumber('0.00020'),
199
- 'taker': this.parseNumber('0.00070'),
200
- 'tiers': {
201
- 'maker': [
202
- [this.parseNumber('0'), this.parseNumber('0.00020')],
203
- [this.parseNumber('2500000'), this.parseNumber('0.00010')],
204
- [this.parseNumber('25000000'), this.parseNumber('0')],
205
- ],
206
- 'taker': [
207
- [this.parseNumber('0'), this.parseNumber('0.00070')],
208
- [this.parseNumber('2500000'), this.parseNumber('0.00050')],
209
- [this.parseNumber('25000000'), this.parseNumber('0.00040')],
210
- ],
211
- },
212
- },
213
- },
214
- 'precisionMode': TICK_SIZE,
215
- // exchange-specific options
216
- 'options': {
217
- 'sandboxMode': false,
218
- 'networks': {
219
- 'BTC': 'Bitcoin',
220
- 'ERC20': 'Ethereum',
221
- 'AVAX': 'Avalanche',
222
- 'SOL': 'Solana',
223
- 'ARB': 'Arbitrum',
224
- 'MATIC': 'Polygon',
225
- 'FTM': 'Fantom',
226
- 'BNB': 'BNBSmartChain',
227
- 'OPTIMISM': 'Optimism',
228
- },
229
- 'networksById': {
230
- 'Bitcoin': 'BTC',
231
- 'Ethereum': 'ERC20',
232
- 'Avalanche': 'AVAX',
233
- 'Solana': 'SOL',
234
- 'Arbitrum': 'ARB',
235
- 'Polygon': 'MATIC',
236
- 'Fantom': 'FTM',
237
- 'Base': 'BASE',
238
- 'BNBSmartChain': 'BNB',
239
- 'Optimism': 'OPTIMISM',
240
- },
241
- },
242
- 'features': {
243
- 'default': {
244
- 'sandbox': true,
245
- 'createOrder': {
246
- 'marginMode': false,
247
- 'triggerPrice': true,
248
- 'triggerDirection': false,
249
- 'triggerPriceType': undefined,
250
- 'stopLossPrice': false,
251
- 'takeProfitPrice': false,
252
- 'attachedStopLossTakeProfit': undefined,
253
- 'timeInForce': {
254
- 'IOC': true,
255
- 'FOK': true,
256
- 'PO': true,
257
- 'GTD': false,
258
- },
259
- 'hedged': false,
260
- 'trailing': false,
261
- 'leverage': false,
262
- 'marketBuyByCost': true,
263
- 'marketBuyRequiresPrice': false,
264
- 'selfTradePrevention': {
265
- 'EXPIRE_MAKER': true,
266
- 'EXPIRE_TAKER': true,
267
- 'EXPIRE_BOTH': true,
268
- 'NONE': true,
269
- },
270
- 'iceberg': true, // todo
271
- },
272
- 'createOrders': {
273
- 'max': 10, // todo
274
- },
275
- 'fetchMyTrades': {
276
- 'marginMode': false,
277
- 'limit': 500,
278
- 'daysBack': 100000,
279
- 'untilDays': 7,
280
- 'symbolRequired': false,
281
- },
282
- 'fetchOrder': {
283
- 'marginMode': false,
284
- 'trigger': false,
285
- 'trailing': false,
286
- 'symbolRequired': false,
287
- },
288
- 'fetchOpenOrders': {
289
- 'marginMode': false,
290
- 'limit': undefined,
291
- 'trigger': false,
292
- 'trailing': false,
293
- 'symbolRequired': false,
294
- },
295
- 'fetchOrders': undefined,
296
- 'fetchClosedOrders': undefined,
297
- 'fetchOHLCV': {
298
- 'limit': 500,
299
- },
300
- },
301
- 'spot': {
302
- 'extends': 'default',
303
- },
304
- 'swap': {
305
- 'linear': {
306
- 'extends': 'default',
307
- },
308
- 'inverse': undefined,
309
- },
310
- 'future': {
311
- 'linear': undefined,
312
- 'inverse': undefined,
313
- },
314
- },
315
- 'exceptions': {
316
- 'exact': {
317
- '-0010': OperationFailed,
318
- '-429': RateLimitExceeded,
319
- '-05001': AuthenticationError,
320
- '-10001': ExchangeError,
321
- '-20000': BadRequest,
322
- '-20001': BadRequest,
323
- '-20002': BadRequest,
324
- '-20003': NotSupported,
325
- '-20005': AuthenticationError,
326
- '-20006': BadRequest,
327
- '-20007': AuthenticationError,
328
- '-20008': BadRequest,
329
- '-20009': BadRequest,
330
- '-20010': ArgumentsRequired,
331
- '-20011': ArgumentsRequired,
332
- '-20012': ArgumentsRequired,
333
- '-20013': ArgumentsRequired,
334
- '-20014': BadRequest,
335
- '-20015': BadSymbol,
336
- '-20016': BadRequest,
337
- '-20017': BadRequest,
338
- '-20018': BadRequest,
339
- '-20019': BadRequest,
340
- '-20020': BadRequest,
341
- '-20021': BadRequest,
342
- '-20022': ArgumentsRequired,
343
- '-20023': ArgumentsRequired,
344
- '-20024': ExchangeError,
345
- '-20025': AuthenticationError,
346
- '-20026': BadRequest,
347
- '-20027': BadRequest,
348
- '-20028': BadRequest,
349
- '-20029': BadRequest,
350
- '-20030': BadRequest,
351
- '-20031': MarketClosed,
352
- '-20032': NetworkError,
353
- '-20033': BadRequest,
354
- '-20034': BadRequest,
355
- '-20050': ExchangeError,
356
- '-30001': BadRequest,
357
- '-35034': AuthenticationError,
358
- '-35046': AuthenticationError,
359
- '-40001': ExchangeError,
360
- '-50001': ExchangeError,
361
- '-300001': AccountNotEnabled,
362
- '-300011': InvalidOrder,
363
- '-300012': InvalidOrder,
364
- '-100005': OrderNotFound,
365
- '-100006': InvalidOrder,
366
- '-100008': BadRequest,
367
- '-100015': NetworkError,
368
- '-710001': ExchangeError,
369
- '-710002': BadRequest,
370
- '-710003': BadRequest,
371
- '-710004': BadRequest,
372
- '-710005': InsufficientFunds,
373
- '-710006': InsufficientFunds,
374
- '-710007': InsufficientFunds,
375
- '-000101': NetworkError,
376
- '-000201': NetworkError, // Trade service is busy, try again later
377
- },
378
- 'broad': {
379
- '-20001': OperationFailed,
380
- '-200050': RequestTimeout, // The market is not active
381
- },
382
- },
383
- });
384
- }
385
- /**
386
- * @method
387
- * @name oxfun#fetchMarkets
388
- * @description retrieves data on all markets for bitmex
389
- * @see https://docs.ox.fun/?json#get-v3-markets
390
- * @param {object} [params] extra parameters specific to the exchange API endpoint
391
- * @returns {object[]} an array of objects representing market data
392
- */
393
- async fetchMarkets(params = {}) {
394
- const [responseFromMarkets, responseFromTickers] = await Promise.all([this.publicGetV3Markets(params), this.publicGetV3Tickers(params)]);
395
- const marketsFromMarkets = this.safeList(responseFromMarkets, 'data', []);
396
- //
397
- // {
398
- // success: true,
399
- // data: [
400
- // {
401
- // marketCode: 'OX-USD-SWAP-LIN',
402
- // name: 'OX/USD Perp',
403
- // referencePair: 'OX/USDT',
404
- // base: 'OX',
405
- // counter: 'USD',
406
- // type: 'FUTURE',
407
- // tickSize: '0.00001',
408
- // minSize: '1',
409
- // listedAt: '1704766320000',
410
- // upperPriceBound: '0.02122',
411
- // lowerPriceBound: '0.01142',
412
- // markPrice: '0.01632',
413
- // indexPrice: '0.01564',
414
- // lastUpdatedAt: '1714762235569'
415
- // },
416
- // {
417
- // marketCode: 'BTC-USD-SWAP-LIN',
418
- // name: 'BTC/USD Perp',
419
- // referencePair: 'BTC/USDT',
420
- // base: 'BTC',
421
- // counter: 'USD',
422
- // type: 'FUTURE',
423
- // tickSize: '1',
424
- // minSize: '0.0001',
425
- // listedAt: '1704686640000',
426
- // upperPriceBound: '67983',
427
- // lowerPriceBound: '55621',
428
- // markPrice: '61802',
429
- // indexPrice: '61813',
430
- // lastUpdatedAt: '1714762234765'
431
- // },
432
- // {
433
- // "marketCode": "MILK-OX",
434
- // "name": "MILK/OX",
435
- // "referencePair": "MILK/OX",
436
- // "base": "MILK",
437
- // "counter": "OX",
438
- // "type": "SPOT",
439
- // "tickSize": "0.0001",
440
- // "minSize": "1",
441
- // "listedAt": "1706608500000",
442
- // "upperPriceBound": "1.0000",
443
- // "lowerPriceBound": "-1.0000",
444
- // "markPrice": "0.0269",
445
- // "indexPrice": "0.0269",
446
- // "lastUpdatedAt": "1714757402185"
447
- // },
448
- // ...
449
- // ]
450
- // }
451
- //
452
- const marketsFromTickers = this.safeList(responseFromTickers, 'data', []);
453
- //
454
- // {
455
- // "success": true,
456
- // "data": [
457
- // {
458
- // "marketCode": "DYM-USD-SWAP-LIN",
459
- // "markPrice": "3.321",
460
- // "open24h": "3.315",
461
- // "high24h": "3.356",
462
- // "low24h": "3.255",
463
- // "volume24h": "0",
464
- // "currencyVolume24h": "0",
465
- // "openInterest": "1768.1",
466
- // "lastTradedPrice": "3.543",
467
- // "lastTradedQuantity": "1.0",
468
- // "lastUpdatedAt": "1714853388102"
469
- // },
470
- // ...
471
- // ]
472
- // }
473
- //
474
- const markets = this.arrayConcat(marketsFromMarkets, marketsFromTickers);
475
- return this.parseMarkets(markets);
476
- }
477
- parseMarkets(markets) {
478
- const marketIds = [];
479
- const result = [];
480
- for (let i = 0; i < markets.length; i++) {
481
- const market = markets[i];
482
- const marketId = this.safeString(market, 'marketCode');
483
- if (!(this.inArray(marketId, marketIds))) {
484
- marketIds.push(marketId);
485
- result.push(this.parseMarket(market));
486
- }
487
- }
488
- return result;
489
- }
490
- parseMarket(market) {
491
- const id = this.safeString(market, 'marketCode', '');
492
- const parts = id.split('-');
493
- const baseId = this.safeString(parts, 0);
494
- const quoteId = this.safeString(parts, 1);
495
- const base = this.safeCurrencyCode(baseId);
496
- const quote = this.safeCurrencyCode(quoteId);
497
- let symbol = base + '/' + quote;
498
- let type = this.safeStringLower(market, 'type', 'spot'); // markets from v3/tickers are spot and have no type
499
- let settleId = undefined;
500
- let settle = undefined;
501
- const isFuture = (type === 'future'); // the exchange has only perpetual futures
502
- if (isFuture) {
503
- type = 'swap';
504
- settleId = 'OX';
505
- settle = this.safeCurrencyCode('OX');
506
- symbol = symbol + ':' + settle;
507
- }
508
- const isSpot = type === 'spot';
509
- return this.safeMarketStructure({
510
- 'id': id,
511
- 'numericId': undefined,
512
- 'symbol': symbol,
513
- 'base': base,
514
- 'quote': quote,
515
- 'settle': settle,
516
- 'baseId': baseId,
517
- 'quoteId': quoteId,
518
- 'settleId': settleId,
519
- 'type': type,
520
- 'spot': isSpot,
521
- 'margin': false,
522
- 'swap': isFuture,
523
- 'future': false,
524
- 'option': false,
525
- 'active': true,
526
- 'contract': isFuture,
527
- 'linear': isFuture ? true : undefined,
528
- 'inverse': isFuture ? false : undefined,
529
- 'taker': this.fees['trading']['taker'],
530
- 'maker': this.fees['trading']['maker'],
531
- 'contractSize': isFuture ? 1 : undefined,
532
- 'expiry': undefined,
533
- 'expiryDatetime': undefined,
534
- 'strike': undefined,
535
- 'optionType': undefined,
536
- 'precision': {
537
- 'amount': undefined,
538
- 'price': this.safeNumber(market, 'tickSize'),
539
- },
540
- 'limits': {
541
- 'leverage': {
542
- 'min': undefined,
543
- 'max': undefined,
544
- },
545
- 'amount': {
546
- 'min': this.safeNumber(market, 'minSize'),
547
- 'max': undefined,
548
- },
549
- 'price': {
550
- 'min': undefined,
551
- 'max': undefined,
552
- },
553
- 'cost': {
554
- 'min': undefined,
555
- 'max': undefined,
556
- },
557
- },
558
- 'created': this.safeInteger(market, 'listedAt'),
559
- 'index': undefined,
560
- 'info': market,
561
- });
562
- }
563
- /**
564
- * @method
565
- * @name oxfun#fetchCurrencies
566
- * @description fetches all available currencies on an exchange
567
- * @see https://docs.ox.fun/?json#get-v3-assets
568
- * @param {dict} [params] extra parameters specific to the exchange API endpoint
569
- * @returns {dict} an associative dictionary of currencies
570
- */
571
- async fetchCurrencies(params = {}) {
572
- const response = await this.publicGetV3Assets(params);
573
- //
574
- // {
575
- // "success": true,
576
- // "data": [
577
- // {
578
- // "asset": "OX",
579
- // "isCollateral": true,
580
- // "loanToValue": "1.000000000",
581
- // "loanToValueFactor": "0.000000000",
582
- // "networkList": [
583
- // {
584
- // "network": "BNBSmartChain",
585
- // "tokenId": "0x78a0A62Fba6Fb21A83FE8a3433d44C73a4017A6f",
586
- // "transactionPrecision": "18",
587
- // "isWithdrawalFeeChargedToUser": true,
588
- // "canDeposit": true,
589
- // "canWithdraw": false,
590
- // "minDeposit": "0.00010",
591
- // "minWithdrawal": "0.00010"
592
- // },
593
- // {
594
- // "network": "Polygon",
595
- // "tokenId": "0x78a0A62Fba6Fb21A83FE8a3433d44C73a4017A6f",
596
- // "transactionPrecision": "18",
597
- // "isWithdrawalFeeChargedToUser": true,
598
- // "canDeposit": true,
599
- // "canWithdraw": false,
600
- // "minDeposit": "0.00010",
601
- // "minWithdrawal": "0.00010"
602
- // },
603
- // ...
604
- // ]
605
- // },
606
- // {
607
- // "asset": "BTC",
608
- // "isCollateral": true,
609
- // "loanToValue": "0.950000000",
610
- // "loanToValueFactor": "0.000000000",
611
- // "networkList": [
612
- // {
613
- // "network": "Bitcoin",
614
- // "transactionPrecision": "8",
615
- // "isWithdrawalFeeChargedToUser": true,
616
- // "canDeposit": true,
617
- // "canWithdraw": true,
618
- // "minDeposit": "0.00010",
619
- // "minWithdrawal": "0.00010"
620
- // }
621
- // ]
622
- // },
623
- // {
624
- // "asset": "USDT.ARB",
625
- // "isCollateral": true,
626
- // "loanToValue": "0.950000000",
627
- // "loanToValueFactor": "0.000000000",
628
- // "networkList": [
629
- // {
630
- // "network": "Arbitrum",
631
- // "tokenId": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
632
- // "transactionPrecision": "18",
633
- // "isWithdrawalFeeChargedToUser": true,
634
- // "canDeposit": true,
635
- // "canWithdraw": true,
636
- // "minDeposit": "0.00010",
637
- // "minWithdrawal": "0.00010"
638
- // }
639
- // ]
640
- // },
641
- // ...
642
- // ]
643
- // }
644
- //
645
- const data = this.safeList(response, 'data', []);
646
- const result = {};
647
- for (let i = 0; i < data.length; i++) {
648
- const currency = data[i];
649
- const fullId = this.safeString(currency, 'asset', '');
650
- const parts = fullId.split('.');
651
- const id = parts[0];
652
- const code = this.safeCurrencyCode(id);
653
- if (!(code in result)) {
654
- result[code] = {
655
- 'id': id,
656
- 'code': code,
657
- 'precision': undefined,
658
- 'type': undefined,
659
- 'name': undefined,
660
- 'active': undefined,
661
- 'deposit': undefined,
662
- 'withdraw': undefined,
663
- 'fee': undefined,
664
- 'limits': {
665
- 'withdraw': {
666
- 'min': undefined,
667
- 'max': undefined,
668
- },
669
- 'deposit': {
670
- 'min': undefined,
671
- 'max': undefined,
672
- },
673
- },
674
- 'networks': {},
675
- 'info': [],
676
- };
677
- }
678
- const chains = this.safeList(currency, 'networkList', []);
679
- for (let j = 0; j < chains.length; j++) {
680
- const chain = chains[j];
681
- const networkId = this.safeString(chain, 'network');
682
- const networkCode = this.networkIdToCode(networkId);
683
- result[code]['networks'][networkCode] = {
684
- 'id': networkId,
685
- 'network': networkCode,
686
- 'margin': undefined,
687
- 'deposit': this.safeBool(chain, 'canDeposit'),
688
- 'withdraw': this.safeBool(chain, 'canWithdraw'),
689
- 'active': undefined,
690
- 'fee': undefined,
691
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'transactionPrecision'))),
692
- 'limits': {
693
- 'deposit': {
694
- 'min': this.safeNumber(chain, 'minDeposit'),
695
- 'max': undefined,
696
- },
697
- 'withdraw': {
698
- 'min': this.safeNumber(chain, 'minWithdrawal'),
699
- 'max': undefined,
700
- },
701
- },
702
- 'info': chain,
703
- };
704
- }
705
- const infos = this.safeList(result[code], 'info', []);
706
- infos.push(currency);
707
- result[code]['info'] = infos;
708
- }
709
- // only after all entries are formed in currencies, restructure each entry
710
- const allKeys = Object.keys(result);
711
- for (let i = 0; i < allKeys.length; i++) {
712
- const code = allKeys[i];
713
- result[code] = this.safeCurrencyStructure(result[code]); // this is needed after adding network entry
714
- }
715
- return result;
716
- }
717
- /**
718
- * @method
719
- * @name oxfun#fetchTickers
720
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
721
- * @see https://docs.ox.fun/?json#get-v3-tickers
722
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
723
- * @param {object} [params] extra parameters specific to the exchange API endpoint
724
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
725
- */
726
- async fetchTickers(symbols = undefined, params = {}) {
727
- await this.loadMarkets();
728
- symbols = this.marketSymbols(symbols);
729
- const response = await this.publicGetV3Tickers(params);
730
- //
731
- // {
732
- // "success": true,
733
- // "data": [
734
- // {
735
- // "marketCode": "NII-USDT",
736
- // "markPrice": "0",
737
- // "open24h": "0",
738
- // "high24h": "0",
739
- // "low24h": "0",
740
- // "volume24h": "0",
741
- // "currencyVolume24h": "0",
742
- // "openInterest": "0",
743
- // "lastTradedPrice": "0",
744
- // "lastTradedQuantity": "0",
745
- // "lastUpdatedAt": "1714853388621"
746
- // },
747
- // {
748
- // "marketCode": "GEC-USDT",
749
- // "markPrice": "0",
750
- // "open24h": "0",
751
- // "high24h": "0",
752
- // "low24h": "0",
753
- // "volume24h": "0",
754
- // "currencyVolume24h": "0",
755
- // "openInterest": "0",
756
- // "lastTradedPrice": "0",
757
- // "lastTradedQuantity": "0",
758
- // "lastUpdatedAt": "1714853388621"
759
- // },
760
- // {
761
- // "marketCode": "DYM-USD-SWAP-LIN",
762
- // "markPrice": "3.321",
763
- // "open24h": "3.315",
764
- // "high24h": "3.356",
765
- // "low24h": "3.255",
766
- // "volume24h": "0",
767
- // "currencyVolume24h": "0",
768
- // "openInterest": "1768.1",
769
- // "lastTradedPrice": "3.543",
770
- // "lastTradedQuantity": "1.0",
771
- // "lastUpdatedAt": "1714853388102"
772
- // },
773
- // ...
774
- // ]
775
- // }
776
- //
777
- const tickers = this.safeList(response, 'data', []);
778
- return this.parseTickers(tickers, symbols);
779
- }
780
- /**
781
- * @method
782
- * @name oxfun#fetchTicker
783
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
784
- * @see https://docs.ox.fun/?json#get-v3-tickers
785
- * @param {string} symbol unified symbol of the market to fetch the ticker for
786
- * @param {object} [params] extra parameters specific to the exchange API endpoint
787
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
788
- */
789
- async fetchTicker(symbol, params = {}) {
790
- await this.loadMarkets();
791
- const market = this.market(symbol);
792
- const request = {
793
- 'marketCode': market['id'],
794
- };
795
- const response = await this.publicGetV3Tickers(this.extend(request, params));
796
- //
797
- // {
798
- // "success": true,
799
- // "data": [
800
- // {
801
- // "marketCode": "BTC-USD-SWAP-LIN",
802
- // "markPrice": "64276",
803
- // "open24h": "63674",
804
- // "high24h": "64607",
805
- // "low24h": "62933",
806
- // "volume24h": "306317655.80000",
807
- // "currencyVolume24h": "48.06810",
808
- // "openInterest": "72.39250",
809
- // "lastTradedPrice": "64300.0",
810
- // "lastTradedQuantity": "1.0",
811
- // "lastUpdatedAt": "1714925196034"
812
- // }
813
- // ]
814
- // }
815
- //
816
- const data = this.safeList(response, 'data', []);
817
- const ticker = this.safeDict(data, 0, {});
818
- return this.parseTicker(ticker, market);
819
- }
820
- parseTicker(ticker, market = undefined) {
821
- //
822
- // {
823
- // "marketCode": "BTC-USD-SWAP-LIN",
824
- // "markPrice": "64276",
825
- // "open24h": "63674",
826
- // "high24h": "64607",
827
- // "low24h": "62933",
828
- // "volume24h": "306317655.80000",
829
- // "currencyVolume24h": "48.06810",
830
- // "openInterest": "72.39250",
831
- // "lastTradedPrice": "64300.0",
832
- // "lastTradedQuantity": "1.0",
833
- // "lastUpdatedAt": "1714925196034"
834
- // }
835
- //
836
- const timestamp = this.safeInteger(ticker, 'lastUpdatedAt');
837
- const marketId = this.safeString(ticker, 'marketCode');
838
- market = this.safeMarket(marketId, market);
839
- const symbol = market['symbol'];
840
- const last = this.safeString(ticker, 'lastTradedPrice');
841
- return this.safeTicker({
842
- 'symbol': symbol,
843
- 'timestamp': timestamp,
844
- 'datetime': this.iso8601(timestamp),
845
- 'high': this.safeString(ticker, 'high24h'),
846
- 'low': this.safeString(ticker, 'low24h'),
847
- 'bid': undefined,
848
- 'bidVolume': undefined,
849
- 'ask': undefined,
850
- 'askVolume': undefined,
851
- 'vwap': undefined,
852
- 'open': this.safeString(ticker, 'open24h'),
853
- 'close': last,
854
- 'last': last,
855
- 'previousClose': undefined,
856
- 'change': undefined,
857
- 'percentage': undefined,
858
- 'average': undefined,
859
- 'baseVolume': this.safeString(ticker, 'currencyVolume24h'),
860
- 'quoteVolume': undefined,
861
- 'markPrice': this.safeString(ticker, 'markPrice'),
862
- 'info': ticker,
863
- }, market);
864
- }
865
- /**
866
- * @method
867
- * @name oxfun#fetchOHLCV
868
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
869
- * @see https://docs.ox.fun/?json#get-v3-candles
870
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
871
- * @param {string} timeframe the length of time each candle represents
872
- * @param {int} [since] timestamp in ms of the earliest candle to fetch (default 24 hours ago)
873
- * @param {int} [limit] the maximum amount of candles to fetch (default 200, max 500)
874
- * @param {object} [params] extra parameters specific to the exchange API endpoint
875
- * @param {int} [params.until] timestamp in ms of the latest candle to fetch (default now)
876
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
877
- */
878
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
879
- await this.loadMarkets();
880
- const market = this.market(symbol);
881
- timeframe = this.safeString(this.timeframes, timeframe, timeframe);
882
- const request = {
883
- 'marketCode': market['id'],
884
- 'timeframe': timeframe,
885
- };
886
- if (since !== undefined) {
887
- request['startTime'] = since; // startTime and endTime must be within 7 days of each other
888
- }
889
- if (limit !== undefined) {
890
- request['limit'] = limit;
891
- }
892
- const until = this.safeInteger(params, 'until');
893
- if (until !== undefined) {
894
- request['endTime'] = until;
895
- params = this.omit(params, 'until');
896
- }
897
- else if (since !== undefined) {
898
- request['endTime'] = this.sum(since, 7 * 24 * 60 * 60 * 1000); // for the exchange not to throw an exception if since is younger than 7 days
899
- }
900
- const response = await this.publicGetV3Candles(this.extend(request, params));
901
- //
902
- // {
903
- // "success": true,
904
- // "timeframe": "3600s",
905
- // "data": [
906
- // {
907
- // "open": "0.03240000",
908
- // "high": "0.03240000",
909
- // "low": "0.03240000",
910
- // "close": "0.03240000",
911
- // "volume": "0",
912
- // "currencyVolume": "0",
913
- // "openedAt": "1714906800000"
914
- // },
915
- // {
916
- // "open": "0.03240000",
917
- // "high": "0.03240000",
918
- // "low": "0.03240000",
919
- // "close": "0.03240000",
920
- // "volume": "0",
921
- // "currencyVolume": "0",
922
- // "openedAt": "1714903200000"
923
- // },
924
- // ...
925
- // ]
926
- // }
927
- //
928
- const result = this.safeList(response, 'data', []);
929
- return this.parseOHLCVs(result, market, timeframe, since, limit);
930
- }
931
- parseOHLCV(ohlcv, market = undefined) {
932
- //
933
- // {
934
- // "open": "0.03240000",
935
- // "high": "0.03240000",
936
- // "low": "0.03240000",
937
- // "close": "0.03240000",
938
- // "volume": "0",
939
- // "currencyVolume": "0",
940
- // "openedAt": "1714906800000"
941
- // }
942
- //
943
- return [
944
- this.safeInteger(ohlcv, 'openedAt'),
945
- this.safeNumber(ohlcv, 'open'),
946
- this.safeNumber(ohlcv, 'high'),
947
- this.safeNumber(ohlcv, 'low'),
948
- this.safeNumber(ohlcv, 'close'),
949
- this.safeNumber(ohlcv, 'currencyVolume'),
950
- ];
951
- }
952
- /**
953
- * @method
954
- * @name oxfun#fetchOrderBook
955
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
956
- * @see https://docs.ox.fun/?json#get-v3-depth
957
- * @param {string} symbol unified symbol of the market to fetch the order book for
958
- * @param {int} [limit] the maximum amount of order book entries to return (default 5, max 100)
959
- * @param {object} [params] extra parameters specific to the exchange API endpoint
960
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
961
- */
962
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
963
- await this.loadMarkets();
964
- const market = this.market(symbol);
965
- const request = {
966
- 'marketCode': market['id'],
967
- };
968
- if (limit !== undefined) {
969
- request['level'] = limit;
970
- }
971
- const response = await this.publicGetV3Depth(this.extend(request, params));
972
- //
973
- // {
974
- // "success": true,
975
- // "level": "5",
976
- // "data": {
977
- // "marketCode": "BTC-USD-SWAP-LIN",
978
- // "lastUpdatedAt": "1714933499266",
979
- // "asks": [
980
- // [ 64073.0, 8.4622 ],
981
- // [ 64092.0, 8.1912 ],
982
- // [ 64111.0, 8.0669 ],
983
- // [ 64130.0, 11.7195 ],
984
- // [ 64151.0, 10.1798 ]
985
- // ],
986
- // "bids": [
987
- // [ 64022.0, 10.1292 ],
988
- // [ 64003.0, 8.1619 ],
989
- // [ 64000.0, 1.0 ],
990
- // [ 63984.0, 12.7724 ],
991
- // [ 63963.0, 11.0073 ]
992
- // ]
993
- // }
994
- // }
995
- //
996
- const data = this.safeDict(response, 'data', {});
997
- const timestamp = this.safeInteger(data, 'lastUpdatedAt');
998
- return this.parseOrderBook(data, market['symbol'], timestamp);
999
- }
1000
- /**
1001
- * @method
1002
- * @name oxfun#fetchFundingRates
1003
- * @description fetch the current funding rates for multiple markets
1004
- * @see https://docs.ox.fun/?json#get-v3-funding-estimates
1005
- * @param {string[]} symbols unified market symbols
1006
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1007
- * @returns {Order[]} an array of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-structure}
1008
- */
1009
- async fetchFundingRates(symbols = undefined, params = {}) {
1010
- await this.loadMarkets();
1011
- symbols = this.marketSymbols(symbols);
1012
- const response = await this.publicGetV3FundingEstimates(params);
1013
- //
1014
- // {
1015
- // "success": true,
1016
- // "data": [
1017
- // {
1018
- // "marketCode": "OX-USD-SWAP-LIN",
1019
- // "fundingAt": "1715515200000",
1020
- // "estFundingRate": "0.000200000"
1021
- // },
1022
- // {
1023
- // "marketCode": "BTC-USD-SWAP-LIN",
1024
- // "fundingAt": "1715515200000",
1025
- // "estFundingRate": "0.000003"
1026
- // },
1027
- // ...
1028
- // ]
1029
- // }
1030
- //
1031
- const data = this.safeList(response, 'data', []);
1032
- return this.parseFundingRates(data, symbols);
1033
- }
1034
- /**
1035
- * @method
1036
- * @name oxfun#fetchFundingRate
1037
- * @description fetch the current funding rates for a symbol
1038
- * @see https://docs.ox.fun/?json#get-v3-funding-estimates
1039
- * @param {string} symbol unified market symbols
1040
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1041
- * @returns {Order[]} an array of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-structure}
1042
- */
1043
- async fetchFundingRate(symbol, params = {}) {
1044
- await this.loadMarkets();
1045
- const request = {
1046
- 'marketCode': this.marketId(symbol),
1047
- };
1048
- const response = await this.publicGetV3FundingEstimates(this.extend(request, params));
1049
- //
1050
- const data = this.safeList(response, 'data', []);
1051
- const first = this.safeDict(data, 0, {});
1052
- return this.parseFundingRate(first, this.market(symbol));
1053
- }
1054
- parseFundingRate(fundingRate, market = undefined) {
1055
- //
1056
- // {
1057
- // "marketCode": "OX-USD-SWAP-LIN",
1058
- // "fundingAt": "1715515200000",
1059
- // "estFundingRate": "0.000200000"
1060
- // }
1061
- //
1062
- const symbol = this.safeString(fundingRate, 'marketCode');
1063
- market = this.market(symbol);
1064
- const estFundingRateTimestamp = this.safeInteger(fundingRate, 'fundingAt');
1065
- return {
1066
- 'info': fundingRate,
1067
- 'symbol': market['symbol'],
1068
- 'markPrice': undefined,
1069
- 'indexPrice': undefined,
1070
- 'interestRate': this.parseNumber('0'),
1071
- 'estimatedSettlePrice': undefined,
1072
- 'timestamp': estFundingRateTimestamp,
1073
- 'datetime': this.iso8601(estFundingRateTimestamp),
1074
- 'fundingRate': this.safeNumber(fundingRate, 'estFundingRate'),
1075
- 'fundingTimestamp': undefined,
1076
- 'fundingDatetime': undefined,
1077
- 'nextFundingRate': undefined,
1078
- 'nextFundingTimestamp': undefined,
1079
- 'nextFundingDatetime': undefined,
1080
- 'previousFundingRate': undefined,
1081
- 'previousFundingTimestamp': undefined,
1082
- 'previousFundingDatetime': undefined,
1083
- 'interval': undefined,
1084
- };
1085
- }
1086
- /**
1087
- * @method
1088
- * @name oxfun#fetchFundingRateHistory
1089
- * @description Fetches the history of funding rates
1090
- * @see https://docs.ox.fun/?json#get-v3-funding-rates
1091
- * @param {string} symbol unified symbol of the market to fetch trades for
1092
- * @param {int} [since] timestamp in ms of the earliest trade to fetch (default 24 hours ago)
1093
- * @param {int} [limit] the maximum amount of trades to fetch (default 200, max 500)
1094
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1095
- * @param {int} [params.until] timestamp in ms of the latest trade to fetch (default now)
1096
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
1097
- */
1098
- async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1099
- await this.loadMarkets();
1100
- const market = this.market(symbol);
1101
- const request = {
1102
- 'marketCode': market['id'],
1103
- };
1104
- if (since !== undefined) {
1105
- request['startTime'] = since; // startTime and endTime must be within 7 days of each other
1106
- }
1107
- if (limit !== undefined) {
1108
- request['limit'] = limit;
1109
- }
1110
- const until = this.safeInteger(params, 'until');
1111
- if (until !== undefined) {
1112
- request['endTime'] = until;
1113
- params = this.omit(params, 'until');
1114
- }
1115
- const response = await this.publicGetV3FundingRates(this.extend(request, params));
1116
- //
1117
- // {
1118
- // success: true,
1119
- // data: [
1120
- // {
1121
- // marketCode: 'NEAR-USD-SWAP-LIN',
1122
- // fundingRate: '-0.000010000',
1123
- // createdAt: '1715428870755'
1124
- // },
1125
- // {
1126
- // marketCode: 'ENA-USD-SWAP-LIN',
1127
- // fundingRate: '0.000150000',
1128
- // createdAt: '1715428868616'
1129
- // },
1130
- // ...
1131
- // }
1132
- //
1133
- const data = this.safeList(response, 'data', []);
1134
- return this.parseFundingRateHistories(data, market, since, limit);
1135
- }
1136
- parseFundingRateHistory(info, market = undefined) {
1137
- //
1138
- // {
1139
- // success: true,
1140
- // data: [
1141
- // {
1142
- // marketCode: 'NEAR-USD-SWAP-LIN',
1143
- // fundingRate: '-0.000010000',
1144
- // createdAt: '1715428870755'
1145
- // },
1146
- // {
1147
- // marketCode: 'ENA-USD-SWAP-LIN',
1148
- // fundingRate: '0.000150000',
1149
- // createdAt: '1715428868616'
1150
- // },
1151
- // ...
1152
- // }
1153
- //
1154
- const marketId = this.safeString(info, 'marketCode');
1155
- market = this.safeMarket(marketId, market);
1156
- const symbol = market['symbol'];
1157
- const timestamp = this.safeInteger(info, 'createdAt');
1158
- return {
1159
- 'info': info,
1160
- 'symbol': symbol,
1161
- 'fundingRate': this.safeNumber(info, 'fundingRate'),
1162
- 'timestamp': timestamp,
1163
- 'datetime': this.iso8601(timestamp),
1164
- };
1165
- }
1166
- /**
1167
- * @method
1168
- * @name oxfun#fetchFundingHistory
1169
- * @description fetches the history of funding payments
1170
- * @see https://docs.ox.fun/?json#get-v3-funding
1171
- * @param {string} symbol unified symbol of the market to fetch trades for
1172
- * @param {int} [since] timestamp in ms of the earliest trade to fetch (default 24 hours ago)
1173
- * @param {int} [limit] the maximum amount of trades to fetch (default 200, max 500)
1174
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1175
- * @param {int} [params.until] timestamp in ms of the latest trade to fetch (default now)
1176
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
1177
- */
1178
- async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1179
- await this.loadMarkets();
1180
- const market = this.market(symbol);
1181
- const request = {
1182
- 'marketCode': market['id'],
1183
- };
1184
- if (since !== undefined) {
1185
- request['startTime'] = since; // startTime and endTime must be within 7 days of each other
1186
- }
1187
- if (limit !== undefined) {
1188
- request['limit'] = limit;
1189
- }
1190
- const until = this.safeInteger(params, 'until');
1191
- if (until !== undefined) {
1192
- request['endTime'] = until;
1193
- params = this.omit(params, 'until');
1194
- }
1195
- const response = await this.privateGetV3Funding(this.extend(request, params));
1196
- //
1197
- // {
1198
- // success: true,
1199
- // data: [
1200
- // {
1201
- // id: '966709913041305605',
1202
- // marketCode: 'ETH-USD-SWAP-LIN',
1203
- // payment: '-0.00430822',
1204
- // fundingRate: '0.000014',
1205
- // position: '0.001',
1206
- // indexPrice: '3077.3',
1207
- // createdAt: '1715086852890'
1208
- // },
1209
- // {
1210
- // id: '966698111997509637',
1211
- // marketCode: 'ETH-USD-SWAP-LIN',
1212
- // payment: '-0.0067419',
1213
- // fundingRate: '0.000022',
1214
- // position: '0.001',
1215
- // indexPrice: '3064.5',
1216
- // createdAt: '1715083251516'
1217
- // },
1218
- // ...
1219
- // ]
1220
- // }
1221
- //
1222
- const result = this.safeList(response, 'data', []);
1223
- return this.parseIncomes(result, market, since, limit);
1224
- }
1225
- parseIncome(income, market = undefined) {
1226
- //
1227
- // {
1228
- // id: '966709913041305605',
1229
- // marketCode: 'ETH-USD-SWAP-LIN',
1230
- // payment: '-0.00430822',
1231
- // fundingRate: '0.000014',
1232
- // position: '0.001',
1233
- // indexPrice: '3077.3',
1234
- // createdAt: '1715086852890'
1235
- // },
1236
- //
1237
- const marketId = this.safeString(income, 'marketCode');
1238
- const symbol = this.safeSymbol(marketId, market);
1239
- const amount = this.safeNumber(income, 'payment');
1240
- const code = this.safeCurrencyCode('OX');
1241
- const id = this.safeString(income, 'id');
1242
- const timestamp = this.safeTimestamp(income, 'createdAt');
1243
- const rate = this.safeNumber(income, 'fundingRate');
1244
- return {
1245
- 'info': income,
1246
- 'symbol': symbol,
1247
- 'code': code,
1248
- 'timestamp': timestamp,
1249
- 'datetime': this.iso8601(timestamp),
1250
- 'id': id,
1251
- 'amount': amount,
1252
- 'rate': rate,
1253
- };
1254
- }
1255
- /**
1256
- * @method
1257
- * @name oxfun#fetchLeverageTiers
1258
- * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for this market
1259
- * @see https://docs.ox.fun/?json#get-v3-leverage-tiers
1260
- * @param {string[]} [symbols] list of unified market symbols
1261
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1262
- * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/?id=leverage-tiers-structure}, indexed by market symbols
1263
- */
1264
- async fetchLeverageTiers(symbols = undefined, params = {}) {
1265
- await this.loadMarkets();
1266
- const response = await this.publicGetV3LeverageTiers(params);
1267
- //
1268
- // {
1269
- // success: true,
1270
- // data: [
1271
- // {
1272
- // marketCode: 'SOL-USD-SWAP-LIN',
1273
- // tiers: [
1274
- // {
1275
- // tier: '1',
1276
- // leverage: '10',
1277
- // positionFloor: '0',
1278
- // positionCap: '200000000',
1279
- // initialMargin: '0.1',
1280
- // maintenanceMargin: '0.05',
1281
- // maintenanceAmount: '0'
1282
- // },
1283
- // {
1284
- // tier: '2',
1285
- // leverage: '5',
1286
- // positionFloor: '200000000',
1287
- // positionCap: '280000000',
1288
- // initialMargin: '0.2',
1289
- // maintenanceMargin: '0.1',
1290
- // maintenanceAmount: '7000000'
1291
- // },
1292
- // {
1293
- // tier: '3',
1294
- // leverage: '4',
1295
- // positionFloor: '280000000',
1296
- // positionCap: '460000000',
1297
- // initialMargin: '0.25',
1298
- // maintenanceMargin: '0.125',
1299
- // maintenanceAmount: '14000000'
1300
- // },
1301
- // ...
1302
- // ]
1303
- // },
1304
- // ...
1305
- // ]
1306
- // }
1307
- //
1308
- const data = this.safeList(response, 'data', []);
1309
- return this.parseLeverageTiers(data, symbols, 'marketCode');
1310
- }
1311
- parseMarketLeverageTiers(info, market = undefined) {
1312
- //
1313
- // {
1314
- // marketCode: 'SOL-USD-SWAP-LIN',
1315
- // tiers: [
1316
- // {
1317
- // tier: '1',
1318
- // leverage: '10',
1319
- // positionFloor: '0',
1320
- // positionCap: '200000000',
1321
- // initialMargin: '0.1',
1322
- // maintenanceMargin: '0.05',
1323
- // maintenanceAmount: '0'
1324
- // ...
1325
- // ]
1326
- // },
1327
- //
1328
- const marketId = this.safeString(info, 'marketCode');
1329
- market = this.safeMarket(marketId, market);
1330
- const listOfTiers = this.safeList(info, 'tiers', []);
1331
- const tiers = [];
1332
- for (let j = 0; j < listOfTiers.length; j++) {
1333
- const tier = listOfTiers[j];
1334
- tiers.push({
1335
- 'tier': this.safeNumber(tier, 'tier'),
1336
- 'symbol': this.safeSymbol(marketId, market),
1337
- 'currency': market['settle'],
1338
- 'minNotional': this.safeNumber(tier, 'positionFloor'),
1339
- 'maxNotional': this.safeNumber(tier, 'positionCap'),
1340
- 'maintenanceMarginRate': this.safeNumber(tier, 'maintenanceMargin'),
1341
- 'maxLeverage': this.safeNumber(tier, 'leverage'),
1342
- 'info': tier,
1343
- });
1344
- }
1345
- return tiers;
1346
- }
1347
- /**
1348
- * @method
1349
- * @name oxfun#fetchTrades
1350
- * @description get the list of most recent trades for a particular symbol
1351
- * @see https://docs.ox.fun/?json#get-v3-exchange-trades
1352
- * @param {string} symbol unified symbol of the market to fetch trades for
1353
- * @param {int} [since] timestamp in ms of the earliest trade to fetch (default 24 hours ago)
1354
- * @param {int} [limit] the maximum amount of trades to fetch (default 200, max 500)
1355
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1356
- * @param {int} [params.until] timestamp in ms of the latest trade to fetch (default now)
1357
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
1358
- */
1359
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1360
- await this.loadMarkets();
1361
- const market = this.market(symbol);
1362
- const request = {
1363
- 'marketCode': market['id'],
1364
- };
1365
- if (since !== undefined) {
1366
- request['startTime'] = since; // startTime and endTime must be within 7 days of each other
1367
- }
1368
- if (limit !== undefined) {
1369
- request['limit'] = limit;
1370
- }
1371
- const until = this.safeInteger(params, 'until');
1372
- if (until !== undefined) {
1373
- request['endTime'] = until;
1374
- params = this.omit(params, 'until');
1375
- }
1376
- else if (since !== undefined) {
1377
- request['endTime'] = this.sum(since, 7 * 24 * 60 * 60 * 1000); // for the exchange not to throw an exception if since is younger than 7 days
1378
- }
1379
- const response = await this.publicGetV3ExchangeTrades(this.extend(request, params));
1380
- //
1381
- // {
1382
- // "success": true,
1383
- // "data": [
1384
- // {
1385
- // "marketCode": "BTC-USD-SWAP-LIN",
1386
- // "matchPrice": "63900",
1387
- // "matchQuantity": "1",
1388
- // "side": "SELL",
1389
- // "matchType": "TAKER",
1390
- // "matchedAt": "1714934112352"
1391
- // },
1392
- // ...
1393
- // ]
1394
- // }
1395
- //
1396
- const data = this.safeList(response, 'data', []);
1397
- return this.parseTrades(data, market, since, limit);
1398
- }
1399
- /**
1400
- * @method
1401
- * @name oxfun#fetchMyTrades
1402
- * @description fetch all trades made by the user
1403
- * @see https://docs.ox.fun/?json#get-v3-trades
1404
- * @param {string} symbol unified market symbol
1405
- * @param {int} [since] the earliest time in ms to fetch trades for
1406
- * @param {int} [limit] the maximum amount of trades to fetch (default 200, max 500)
1407
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1408
- * @param {int} [params.until] timestamp in ms of the latest trade to fetch (default now)
1409
- * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1410
- */
1411
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1412
- await this.loadMarkets();
1413
- const request = {};
1414
- let market = undefined;
1415
- if (symbol !== undefined) {
1416
- market = this.market(symbol);
1417
- request['marketCode'] = market['id'];
1418
- }
1419
- if (since !== undefined) { // startTime and endTime must be within 7 days of each other
1420
- request['startTime'] = since;
1421
- }
1422
- if (limit !== undefined) {
1423
- request['limit'] = limit;
1424
- }
1425
- const until = this.safeInteger(params, 'until');
1426
- if (until !== undefined) {
1427
- request['endTime'] = until;
1428
- params = this.omit(params, 'until');
1429
- }
1430
- else if (since !== undefined) {
1431
- request['endTime'] = this.sum(since, 7 * 24 * 60 * 60 * 1000); // for the exchange not to throw an exception if since is younger than 7 days
1432
- }
1433
- const response = await this.privateGetV3Trades(this.extend(request, params));
1434
- //
1435
- // {
1436
- // "success": true,
1437
- // "data": [
1438
- // {
1439
- // "orderId": "1000104903698",
1440
- // "clientOrderId": "1715000260094",
1441
- // "matchId": "400017129522773178",
1442
- // "marketCode": "ETH-USD-SWAP-LIN",
1443
- // "side": "BUY",
1444
- // "matchedQuantity": "0.001",
1445
- // "matchPrice": "3100.2",
1446
- // "total": "310.02",
1447
- // "orderMatchType": "MAKER",
1448
- // "feeAsset": "OX",
1449
- // "fee": "0.062004",
1450
- // "source": "0",
1451
- // "matchedAt": "1715000267420"
1452
- // }
1453
- // ]
1454
- // }
1455
- //
1456
- const result = this.safeList(response, 'data', []);
1457
- return this.parseTrades(result, market, since, limit);
1458
- }
1459
- parseTrade(trade, market = undefined) {
1460
- //
1461
- // public fetchTrades
1462
- //
1463
- // {
1464
- // "marketCode": "BTC-USD-SWAP-LIN",
1465
- // "matchPrice": "63900",
1466
- // "matchQuantity": "1",
1467
- // "side": "SELL",
1468
- // "matchType": "TAKER",
1469
- // "matchedAt": "1714934112352"
1470
- // }
1471
- //
1472
- //
1473
- // private fetchMyTrades
1474
- //
1475
- // {
1476
- // "orderId": "1000104903698",
1477
- // "clientOrderId": "1715000260094",
1478
- // "matchId": "400017129522773178",
1479
- // "marketCode": "ETH-USD-SWAP-LIN",
1480
- // "side": "BUY",
1481
- // "matchedQuantity": "0.001",
1482
- // "matchPrice": "3100.2",
1483
- // "total": "310.02",
1484
- // "orderMatchType": "MAKER",
1485
- // "feeAsset": "OX",
1486
- // "fee": "0.062004",
1487
- // "source": "0",
1488
- // "matchedAt": "1715000267420"
1489
- // }
1490
- //
1491
- const marketId = this.safeString(trade, 'marketCode');
1492
- market = this.safeMarket(marketId, market);
1493
- const symbol = market['symbol'];
1494
- const timestamp = this.safeInteger(trade, 'matchedAt');
1495
- const fee = {
1496
- 'cost': this.safeString(trade, 'fee'),
1497
- 'currency': this.safeCurrencyCode(this.safeString(trade, 'feeAsset')),
1498
- };
1499
- return this.safeTrade({
1500
- 'id': this.safeString(trade, 'matchId'),
1501
- 'timestamp': timestamp,
1502
- 'datetime': this.iso8601(timestamp),
1503
- 'symbol': symbol,
1504
- 'type': undefined,
1505
- 'order': this.safeString(trade, 'orderId'),
1506
- 'side': this.safeStringLower(trade, 'side'),
1507
- 'takerOrMaker': this.safeStringLower2(trade, 'matchType', 'orderMatchType'),
1508
- 'price': this.safeString(trade, 'matchPrice'),
1509
- 'amount': this.safeString2(trade, 'matchQuantity', 'matchedQuantity'),
1510
- 'cost': undefined,
1511
- 'fee': fee,
1512
- 'info': trade,
1513
- }, market);
1514
- }
1515
- /**
1516
- * @method
1517
- * @name oxfun#fetchBalance
1518
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
1519
- * @see https://docs.ox.fun/?json#get-v3-balances
1520
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1521
- * @param {string} [params.asset] currency id, if empty the exchange returns info about all currencies
1522
- * @param {string} [params.subAcc] Name of sub account. If no subAcc is given, then the response contains only the account linked to the API-Key.
1523
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
1524
- */
1525
- async fetchBalance(params = {}) {
1526
- await this.loadMarkets();
1527
- const response = await this.privateGetV3Balances(params);
1528
- //
1529
- // {
1530
- // "success": true,
1531
- // "data": [
1532
- // {
1533
- // "accountId": "106490",
1534
- // "name": "main",
1535
- // "balances": [
1536
- // {
1537
- // "asset": "OX",
1538
- // "total": "-7.55145065000",
1539
- // "available": "-71.16445065000",
1540
- // "reserved": "0",
1541
- // "lastUpdatedAt": "1715000448946"
1542
- // },
1543
- // {
1544
- // "asset": "ETH",
1545
- // "total": "0.01",
1546
- // "available": "0.01",
1547
- // "reserved": "0",
1548
- // "lastUpdatedAt": "1714914512750"
1549
- // },
1550
- // ...
1551
- // ]
1552
- // },
1553
- // ...
1554
- // ]
1555
- // }
1556
- //
1557
- const data = this.safeList(response, 'data', []);
1558
- let balance = data[0];
1559
- const subAcc = this.safeString(params, 'subAcc');
1560
- if (subAcc !== undefined) {
1561
- for (let i = 0; i < data.length; i++) {
1562
- const b = data[i];
1563
- const name = this.safeString(b, 'name');
1564
- if (name === subAcc) {
1565
- balance = b;
1566
- break;
1567
- }
1568
- }
1569
- }
1570
- return this.parseBalance(balance);
1571
- }
1572
- parseBalance(balance) {
1573
- //
1574
- // {
1575
- // "accountId": "106490",
1576
- // "name": "main",
1577
- // "balances": [
1578
- // {
1579
- // "asset": "OX",
1580
- // "total": "-7.55145065000",
1581
- // "available": "-71.16445065000",
1582
- // "reserved": "0",
1583
- // "lastUpdatedAt": "1715000448946"
1584
- // },
1585
- // {
1586
- // "asset": "ETH",
1587
- // "total": "0.01",
1588
- // "available": "0.01",
1589
- // "reserved": "0",
1590
- // "lastUpdatedAt": "1714914512750"
1591
- // },
1592
- // ...
1593
- // ]
1594
- // }
1595
- //
1596
- const result = {
1597
- 'info': balance,
1598
- };
1599
- const balances = this.safeList(balance, 'balances', []);
1600
- for (let i = 0; i < balances.length; i++) {
1601
- const balanceEntry = balances[i];
1602
- const currencyId = this.safeString(balanceEntry, 'asset');
1603
- const code = this.safeCurrencyCode(currencyId);
1604
- const account = this.account();
1605
- account['total'] = this.safeString(balanceEntry, 'total');
1606
- account['free'] = this.safeString(balanceEntry, 'available');
1607
- account['used'] = this.safeString(balanceEntry, 'reserved');
1608
- result[code] = account;
1609
- }
1610
- return this.safeBalance(result);
1611
- }
1612
- /**
1613
- * @method
1614
- * @name oxfun#fetchAccounts
1615
- * @description fetch subaccounts associated with a profile
1616
- * @see https://docs.ox.fun/?json#get-v3-account-names
1617
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1618
- * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/?id=account-structure} indexed by the account type
1619
- */
1620
- async fetchAccounts(params = {}) {
1621
- await this.loadMarkets();
1622
- // this endpoint can only be called using API keys paired with the parent account! Returns all active subaccounts.
1623
- const response = await this.privateGetV3AccountNames(params);
1624
- //
1625
- // {
1626
- // "success": true,
1627
- // "data": [
1628
- // {
1629
- // "accountId": "106526",
1630
- // "name": "testSubAccount"
1631
- // },
1632
- // ...
1633
- // ]
1634
- // }
1635
- //
1636
- const data = this.safeList(response, 'data', []);
1637
- return this.parseAccounts(data, params);
1638
- }
1639
- parseAccount(account) {
1640
- //
1641
- // {
1642
- // "accountId": "106526",
1643
- // "name": "testSubAccount"
1644
- // },
1645
- //
1646
- return {
1647
- 'id': this.safeString(account, 'accountId'),
1648
- 'type': undefined,
1649
- 'code': undefined,
1650
- 'info': account,
1651
- };
1652
- }
1653
- /**
1654
- * @method
1655
- * @name oxfun#transfer
1656
- * @description transfer currency internally between wallets on the same account
1657
- * @see https://docs.ox.fun/?json#post-v3-transfer
1658
- * @param {string} code unified currency code
1659
- * @param {float} amount amount to transfer
1660
- * @param {string} fromAccount account id to transfer from
1661
- * @param {string} toAccount account id to transfer to
1662
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1663
- * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
1664
- */
1665
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
1666
- // transferring funds between sub-accounts is restricted to API keys linked to the parent account.
1667
- await this.loadMarkets();
1668
- const currency = this.currency(code);
1669
- const request = {
1670
- 'asset': currency['id'],
1671
- 'quantity': this.currencyToPrecision(code, amount),
1672
- 'fromAccount': fromAccount,
1673
- 'toAccount': toAccount,
1674
- };
1675
- const response = await this.privatePostV3Transfer(this.extend(request, params));
1676
- //
1677
- // {
1678
- // timestamp: 1715430036267,
1679
- // datetime: '2024-05-11T12:20:36.267Z',
1680
- // currency: 'OX',
1681
- // amount: 10,
1682
- // fromAccount: '106464',
1683
- // toAccount: '106570',
1684
- // info: {
1685
- // asset: 'OX',
1686
- // quantity: '10',
1687
- // fromAccount: '106464',
1688
- // toAccount: '106570',
1689
- // transferredAt: '1715430036267'
1690
- // }
1691
- // }
1692
- //
1693
- const data = this.safeDict(response, 'data', {});
1694
- return this.parseTransfer(data, currency);
1695
- }
1696
- /**
1697
- * @method
1698
- * @name oxfun#fetchTransfers
1699
- * @description fetch a history of internal transfers made on an account
1700
- * @see https://docs.ox.fun/?json#get-v3-transfer
1701
- * @param {string} code unified currency code of the currency transferred
1702
- * @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
1703
- * @param {int} [limit] the maximum number of transfer structures to retrieve (default 50, max 200)
1704
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1705
- * @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
1706
- * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
1707
- */
1708
- async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
1709
- // API keys linked to the parent account can get all account transfers, while API keys linked to a sub-account can only see transfers where the sub-account is either the "fromAccount" or "toAccount"
1710
- await this.loadMarkets();
1711
- const request = {};
1712
- let currency = undefined;
1713
- if (code !== undefined) {
1714
- currency = this.currency(code);
1715
- request['asset'] = currency['id'];
1716
- }
1717
- if (since !== undefined) {
1718
- request['startTime'] = since; // startTime and endTime must be within 7 days of each other
1719
- }
1720
- if (limit !== undefined) {
1721
- request['limit'] = limit;
1722
- }
1723
- const until = this.safeInteger(params, 'until');
1724
- if (until !== undefined) {
1725
- request['endTime'] = until;
1726
- params = this.omit(params, 'until');
1727
- }
1728
- else if (since !== undefined) {
1729
- request['endTime'] = this.sum(since, 7 * 24 * 60 * 60 * 1000); // for the exchange not to throw an exception if since is younger than 7 days
1730
- }
1731
- const response = await this.privateGetV3Transfer(this.extend(request, params));
1732
- //
1733
- // {
1734
- // "success": true,
1735
- // "data": [
1736
- // {
1737
- // "asset": "USDT",
1738
- // "quantity": "5",
1739
- // "fromAccount": "106490",
1740
- // "toAccount": "106526",
1741
- // "id": "966706320886267905",
1742
- // "status": "COMPLETED",
1743
- // "transferredAt": "1715085756708"
1744
- // },
1745
- // ...
1746
- // ]
1747
- // }
1748
- //
1749
- const data = this.safeList(response, 'data', []);
1750
- return this.parseTransfers(data, currency, since, limit);
1751
- }
1752
- parseTransfer(transfer, currency = undefined) {
1753
- //
1754
- // fetchTransfers
1755
- //
1756
- // {
1757
- // "asset": "USDT",
1758
- // "quantity": "5",
1759
- // "fromAccount": "106490",
1760
- // "toAccount": "106526",
1761
- // "id": "966706320886267905",
1762
- // "status": "COMPLETED",
1763
- // "transferredAt": "1715085756708"
1764
- // }
1765
- //
1766
- const timestamp = this.safeInteger(transfer, 'transferredAt');
1767
- const currencyId = this.safeString(transfer, 'asset');
1768
- return {
1769
- 'id': this.safeString(transfer, 'id'),
1770
- 'timestamp': timestamp,
1771
- 'datetime': this.iso8601(timestamp),
1772
- 'currency': this.safeCurrencyCode(currencyId, currency),
1773
- 'amount': this.safeNumber(transfer, 'quantity'),
1774
- 'fromAccount': this.safeString(transfer, 'fromAccount'),
1775
- 'toAccount': this.safeString(transfer, 'toAccount'),
1776
- 'status': this.parseTransferStatus(this.safeString(transfer, 'status')),
1777
- 'info': transfer,
1778
- };
1779
- }
1780
- parseTransferStatus(status) {
1781
- const statuses = {
1782
- 'COMPLETED': 'ok',
1783
- };
1784
- return this.safeString(statuses, status, status);
1785
- }
1786
- /**
1787
- * @method
1788
- * @name oxfun#fetchDepositAddress
1789
- * @description fetch the deposit address for a currency associated with this account
1790
- * @see https://docs.ox.fun/?json#get-v3-deposit-addresses
1791
- * @param {string} code unified currency code
1792
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1793
- * @param {string} [params.network] network for fetch deposit address
1794
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
1795
- */
1796
- async fetchDepositAddress(code, params = {}) {
1797
- const networkCode = this.safeString(params, 'network');
1798
- const networkId = this.networkCodeToId(networkCode, code);
1799
- if (networkId === undefined) {
1800
- throw new BadRequest(this.id + ' fetchDepositAddress() require network parameter');
1801
- }
1802
- await this.loadMarkets();
1803
- const currency = this.currency(code);
1804
- const request = {
1805
- 'asset': currency['id'],
1806
- 'network': networkId,
1807
- };
1808
- params = this.omit(params, 'network');
1809
- const response = await this.privateGetV3DepositAddresses(this.extend(request, params));
1810
- //
1811
- // {"success":true,"data":{"address":"0x998dEc76151FB723963Bd8AFD517687b38D33dE8"}}
1812
- //
1813
- const data = this.safeDict(response, 'data', {});
1814
- return this.parseDepositAddress(data, currency);
1815
- }
1816
- parseDepositAddress(depositAddress, currency = undefined) {
1817
- //
1818
- // {"address":"0x998dEc76151FB723963Bd8AFD517687b38D33dE8"}
1819
- //
1820
- const address = this.safeString(depositAddress, 'address');
1821
- this.checkAddress(address);
1822
- return {
1823
- 'info': depositAddress,
1824
- 'currency': currency['code'],
1825
- 'network': undefined,
1826
- 'address': address,
1827
- 'tag': undefined,
1828
- };
1829
- }
1830
- /**
1831
- * @method
1832
- * @name oxfun#fetchDeposits
1833
- * @description fetch all deposits made to an account
1834
- * @see https://docs.ox.fun/?json#get-v3-deposit
1835
- * @param {string} code unified currency code of the currency transferred
1836
- * @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
1837
- * @param {int} [limit] the maximum number of transfer structures to retrieve (default 50, max 200)
1838
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1839
- * @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
1840
- * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
1841
- */
1842
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1843
- await this.loadMarkets();
1844
- const request = {};
1845
- let currency = undefined;
1846
- if (code !== undefined) {
1847
- currency = this.currency(code);
1848
- request['asset'] = currency['id'];
1849
- }
1850
- if (since !== undefined) {
1851
- request['startTime'] = since; // startTime and endTime must be within 7 days of each other
1852
- }
1853
- if (limit !== undefined) {
1854
- request['limit'] = limit;
1855
- }
1856
- const until = this.safeInteger(params, 'until');
1857
- if (until !== undefined) {
1858
- request['endTime'] = until;
1859
- params = this.omit(params, 'until');
1860
- }
1861
- const response = await this.privateGetV3Deposit(this.extend(request, params));
1862
- //
1863
- // {
1864
- // "success": true,
1865
- // "data": [
1866
- // {
1867
- // "asset":"USDC",
1868
- // "network":"Ethereum",
1869
- // "address": "0x998dEc76151FB723963Bd8AFD517687b38D33dE8",
1870
- // "quantity":"50",
1871
- // "id":"5914",
1872
- // "status": "COMPLETED",
1873
- // "txId":"0xf5e79663830a0c6f94d46638dcfbc134566c12facf1832396f81ecb55d3c75dc",
1874
- // "creditedAt":"1714821645154"
1875
- // }
1876
- // ]
1877
- // }
1878
- //
1879
- const data = this.safeList(response, 'data', []);
1880
- for (let i = 0; i < data.length; i++) {
1881
- data[i]['type'] = 'deposit';
1882
- }
1883
- return this.parseTransactions(data, currency, since, limit);
1884
- }
1885
- /**
1886
- * @method
1887
- * @name oxfun#fetchWithdrawals
1888
- * @description fetch all withdrawals made from an account
1889
- * @see https://docs.ox.fun/?json#get-v3-withdrawal
1890
- * @param {string} code unified currency code of the currency transferred
1891
- * @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
1892
- * @param {int} [limit] the maximum number of transfer structures to retrieve (default 50, max 200)
1893
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1894
- * @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
1895
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
1896
- */
1897
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1898
- await this.loadMarkets();
1899
- const request = {};
1900
- let currency = undefined;
1901
- if (code !== undefined) {
1902
- currency = this.currency(code);
1903
- request['asset'] = currency['id'];
1904
- }
1905
- if (since !== undefined) {
1906
- request['startTime'] = since; // startTime and endTime must be within 7 days of each other
1907
- }
1908
- if (limit !== undefined) {
1909
- request['limit'] = limit;
1910
- }
1911
- const until = this.safeInteger(params, 'until');
1912
- if (until !== undefined) {
1913
- request['endTime'] = until;
1914
- params = this.omit(params, 'until');
1915
- }
1916
- const response = await this.privateGetV3Withdrawal(this.extend(request, params));
1917
- //
1918
- // {
1919
- // success: true,
1920
- // data: [
1921
- // {
1922
- // id: '968163212989431811',
1923
- // asset: 'OX',
1924
- // network: 'Arbitrum',
1925
- // address: '0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9',
1926
- // quantity: '11.7444',
1927
- // fee: '1.744400000',
1928
- // status: 'COMPLETED',
1929
- // txId: '0xe96b2d128b737fdbca927edf355cff42202e65b0fb960e64ffb9bd68c121f69f',
1930
- // requestedAt: '1715530365450',
1931
- // completedAt: '1715530527000'
1932
- // }
1933
- // ]
1934
- // }
1935
- //
1936
- const data = this.safeList(response, 'data', []);
1937
- for (let i = 0; i < data.length; i++) {
1938
- data[i]['type'] = 'withdrawal';
1939
- }
1940
- return this.parseTransactions(data, currency, since, limit);
1941
- }
1942
- parseTransactions(transactions, currency = undefined, since = undefined, limit = undefined, params = {}) {
1943
- let result = [];
1944
- for (let i = 0; i < transactions.length; i++) {
1945
- transactions[i] = this.extend(transactions[i], params);
1946
- const transaction = this.parseTransaction(transactions[i], currency);
1947
- result.push(transaction);
1948
- }
1949
- result = this.sortBy(result, 'timestamp');
1950
- const code = (currency !== undefined) ? currency['code'] : undefined;
1951
- return this.filterByCurrencySinceLimit(result, code, since, limit);
1952
- }
1953
- parseTransaction(transaction, currency = undefined) {
1954
- //
1955
- // fetchDeposits
1956
- // {
1957
- // "asset":"USDC",
1958
- // "network":"Ethereum",
1959
- // "address": "0x998dEc76151FB723963Bd8AFD517687b38D33dE8",
1960
- // "quantity":"50",
1961
- // "id":"5914",
1962
- // "status": "COMPLETED",
1963
- // "txId":"0xf5e79663830a0c6f94d46638dcfbc134566c12facf1832396f81ecb55d3c75dc",
1964
- // "creditedAt":"1714821645154"
1965
- // }
1966
- //
1967
- // fetchWithdrawals
1968
- // {
1969
- // id: '968163212989431811',
1970
- // asset: 'OX',
1971
- // network: 'Arbitrum',
1972
- // address: '0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9',
1973
- // quantity: '11.7444',
1974
- // fee: '1.744400000',
1975
- // status: 'COMPLETED',
1976
- // txId: '0xe96b2d128b737fdbca927edf355cff42202e65b0fb960e64ffb9bd68c121f69f',
1977
- // requestedAt: '1715530365450',
1978
- // completedAt: '1715530527000'
1979
- // }
1980
- //
1981
- // withdraw
1982
- // {
1983
- // "id": "968364664449302529",
1984
- // "asset": "OX",
1985
- // "network": "Arbitrum",
1986
- // "address": "0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9",
1987
- // "quantity": "10",
1988
- // "externalFee": false,
1989
- // "fee": "1.6728",
1990
- // "status": "PENDING",
1991
- // "requestedAt": "1715591843616"
1992
- // }
1993
- //
1994
- const id = this.safeString(transaction, 'id');
1995
- const type = this.safeString(transaction, 'type');
1996
- transaction = this.omit(transaction, 'type');
1997
- let address = undefined;
1998
- let addressTo = undefined;
1999
- let status = undefined;
2000
- if (type === 'deposit') {
2001
- address = this.safeString(transaction, 'address');
2002
- status = this.parseDepositStatus(this.safeString(transaction, 'status'));
2003
- }
2004
- else if (type === 'withdrawal') {
2005
- addressTo = this.safeString(transaction, 'address');
2006
- status = this.parseWithdrawalStatus(this.safeString(transaction, 'status'));
2007
- }
2008
- const txid = this.safeString(transaction, 'txId');
2009
- const currencyId = this.safeString(transaction, 'asset');
2010
- const code = this.safeCurrencyCode(currencyId, currency);
2011
- const network = this.safeString(transaction, 'network');
2012
- const networkCode = this.networkIdToCode(network);
2013
- const timestamp = this.safeInteger2(transaction, 'creditedAt', 'requestedAt');
2014
- const amount = this.safeNumber(transaction, 'quantity');
2015
- const feeCost = this.safeNumber(transaction, 'fee');
2016
- let fee = undefined;
2017
- if (feeCost !== undefined) {
2018
- fee = {
2019
- 'cost': feeCost,
2020
- 'currency': code,
2021
- };
2022
- }
2023
- return {
2024
- 'info': transaction,
2025
- 'id': id,
2026
- 'txid': txid,
2027
- 'timestamp': timestamp,
2028
- 'datetime': this.iso8601(timestamp),
2029
- 'network': networkCode,
2030
- 'address': address,
2031
- 'addressTo': addressTo,
2032
- 'addressFrom': undefined,
2033
- 'tag': undefined,
2034
- 'tagTo': undefined,
2035
- 'tagFrom': undefined,
2036
- 'type': type,
2037
- 'amount': amount,
2038
- 'currency': code,
2039
- 'status': status,
2040
- 'updated': undefined,
2041
- 'internal': undefined,
2042
- 'comment': undefined,
2043
- 'fee': fee,
2044
- };
2045
- }
2046
- parseDepositStatus(status) {
2047
- const statuses = {
2048
- 'COMPLETED': 'ok',
2049
- };
2050
- return this.safeString(statuses, status, status);
2051
- }
2052
- parseWithdrawalStatus(status) {
2053
- const statuses = {
2054
- 'COMPLETED': 'ok',
2055
- 'PROCESSING': 'pending',
2056
- 'IN SWEEPING': 'pending',
2057
- 'PENDING': 'pending',
2058
- 'ON HOLD': 'pending',
2059
- 'CANCELED': 'canceled',
2060
- 'FAILED': 'failed',
2061
- };
2062
- return this.safeString(statuses, status, status);
2063
- }
2064
- /**
2065
- * @method
2066
- * @name oxfun#withdraw
2067
- * @description make a withdrawal
2068
- * @see https://docs.ox.fun/?json#post-v3-withdrawal
2069
- * @param {string} code unified currency code
2070
- * @param {float} amount the amount to withdraw
2071
- * @param {string} address the address to withdraw to
2072
- * @param {string} tag
2073
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2074
- * @param {string} [params.network] network for withdraw
2075
- * @param {bool} [params.externalFee] if false, then the fee is taken from the quantity, also with the burn fee for asset SOLO
2076
- *
2077
- * EXCHANGE SPECIFIC PARAMETERS
2078
- * @param {string} [params.tfaType] GOOGLE, or AUTHY_SECRET, or YUBIKEY, for 2FA
2079
- * @param {string} [params.code] 2FA code
2080
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
2081
- */
2082
- async withdraw(code, amount, address, tag = undefined, params = {}) {
2083
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2084
- await this.loadMarkets();
2085
- const currency = this.currency(code);
2086
- const stringAmount = this.currencyToPrecision(code, amount);
2087
- const request = {
2088
- 'asset': currency['id'],
2089
- 'address': address,
2090
- 'quantity': stringAmount,
2091
- };
2092
- if (tag !== undefined) {
2093
- request['memo'] = tag;
2094
- }
2095
- let networkCode = undefined;
2096
- [networkCode, params] = this.handleNetworkCodeAndParams(params);
2097
- if (networkCode !== undefined) {
2098
- request['network'] = this.networkCodeToId(networkCode);
2099
- }
2100
- request['externalFee'] = false;
2101
- const response = await this.privatePostV3Withdrawal(this.extend(request, params));
2102
- //
2103
- // {
2104
- // "success": true,
2105
- // "data": {
2106
- // "id": "968364664449302529",
2107
- // "asset": "OX",
2108
- // "network": "Arbitrum",
2109
- // "address": "0x90fc1fB49a4ED8f485dd02A2a1Cf576897f6Bfc9",
2110
- // "quantity": "10",
2111
- // "externalFee": false,
2112
- // "fee": "1.6728",
2113
- // "status": "PENDING",
2114
- // "requestedAt": "1715591843616"
2115
- // }
2116
- // }
2117
- //
2118
- const data = this.safeDict(response, 'data', {});
2119
- data['type'] = 'withdrawal';
2120
- return this.parseTransaction(data, currency);
2121
- }
2122
- /**
2123
- * @method
2124
- * @name oxfun#fetchPositions
2125
- * @description fetch all open positions
2126
- * @see https://docs.ox.fun/?json#get-v3-positions
2127
- * @param {string[]|undefined} symbols list of unified market symbols
2128
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2129
- * @param {boolean} [params.subAcc]
2130
- * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
2131
- */
2132
- async fetchPositions(symbols = undefined, params = {}) {
2133
- // Calling this endpoint using an API key pair linked to the parent account with the parameter "subAcc"
2134
- // allows the caller to include positions of additional sub-accounts in the response.
2135
- // This feature does not work when using API key pairs linked to a sub-account
2136
- await this.loadMarkets();
2137
- symbols = this.marketSymbols(symbols);
2138
- const response = await this.privateGetV3Positions(params);
2139
- //
2140
- // {
2141
- // "success": true,
2142
- // "data": [
2143
- // {
2144
- // "accountId": "106490",
2145
- // "name": "main",
2146
- // "positions": [
2147
- // {
2148
- // "marketCode": "BTC-USD-SWAP-LIN",
2149
- // "baseAsset": "BTC",
2150
- // "counterAsset": "USD",
2151
- // "position": "0.00010",
2152
- // "entryPrice": "64300.0",
2153
- // "markPrice": "63278",
2154
- // "positionPnl": "-10.1900",
2155
- // "estLiquidationPrice": "0",
2156
- // "lastUpdatedAt": "1714915841448"
2157
- // },
2158
- // ...
2159
- // ]
2160
- // },
2161
- // {
2162
- // "accountId": "106526",
2163
- // "name": "testSubAccount",
2164
- // "positions": [
2165
- // {
2166
- // "marketCode": "ETH-USD-SWAP-LIN",
2167
- // "baseAsset": "ETH",
2168
- // "counterAsset": "USD",
2169
- // "position": "0.001",
2170
- // "entryPrice": "3080.5",
2171
- // "markPrice": "3062.0",
2172
- // "positionPnl": "-1.8500",
2173
- // "estLiquidationPrice": "0",
2174
- // "lastUpdatedAt": "1715089678013"
2175
- // },
2176
- // ...
2177
- // ]
2178
- // }
2179
- // ]
2180
- // }
2181
- //
2182
- const data = this.safeList(response, 'data', []);
2183
- let allPositions = [];
2184
- for (let i = 0; i < data.length; i++) {
2185
- const account = data[i];
2186
- const positions = this.safeList(account, 'positions', []);
2187
- allPositions = this.arrayConcat(allPositions, positions);
2188
- }
2189
- return this.parsePositions(allPositions, symbols);
2190
- }
2191
- parsePosition(position, market = undefined) {
2192
- //
2193
- // {
2194
- // "marketCode": "ETH-USD-SWAP-LIN",
2195
- // "baseAsset": "ETH",
2196
- // "counterAsset": "USD",
2197
- // "position": "0.001",
2198
- // "entryPrice": "3080.5",
2199
- // "markPrice": "3062.0",
2200
- // "positionPnl": "-1.8500",
2201
- // "estLiquidationPrice": "0",
2202
- // "lastUpdatedAt": "1715089678013"
2203
- // }
2204
- //
2205
- const marketId = this.safeString(position, 'marketCode');
2206
- market = this.safeMarket(marketId, market);
2207
- return this.safePosition({
2208
- 'info': position,
2209
- 'id': undefined,
2210
- 'symbol': market['symbol'],
2211
- 'notional': undefined,
2212
- 'marginMode': 'cross',
2213
- 'liquidationPrice': this.safeNumber(position, 'estLiquidationPrice'),
2214
- 'entryPrice': this.safeNumber(position, 'entryPrice'),
2215
- 'unrealizedPnl': this.safeNumber(position, 'positionPnl'),
2216
- 'realizedPnl': undefined,
2217
- 'percentage': undefined,
2218
- 'contracts': this.safeNumber(position, 'position'),
2219
- 'contractSize': undefined,
2220
- 'markPrice': this.safeNumber(position, 'markPrice'),
2221
- 'lastPrice': undefined,
2222
- 'side': undefined,
2223
- 'hedged': undefined,
2224
- 'timestamp': undefined,
2225
- 'datetime': undefined,
2226
- 'lastUpdateTimestamp': this.safeInteger(position, 'lastUpdatedAt'),
2227
- 'maintenanceMargin': undefined,
2228
- 'maintenanceMarginPercentage': undefined,
2229
- 'collateral': undefined,
2230
- 'initialMargin': undefined,
2231
- 'initialMarginPercentage': undefined,
2232
- 'leverage': undefined,
2233
- 'marginRatio': undefined,
2234
- 'stopLossPrice': undefined,
2235
- 'takeProfitPrice': undefined,
2236
- });
2237
- }
2238
- /**
2239
- * @method
2240
- * @name oxfun#createOrder
2241
- * @description create a trade order
2242
- * @see https://docs.ox.fun/?json#post-v3-orders-place
2243
- * @param {string} symbol unified symbol of the market to create an order in
2244
- * @param {string} type 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
2245
- * @param {string} side 'buy' or 'sell'
2246
- * @param {float} amount how much of currency you want to trade in units of base currency
2247
- * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2248
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2249
- * @param {int} [params.clientOrderId] a unique id for the order
2250
- * @param {int} [params.timestamp] in milliseconds. If an order reaches the matching engine and the current timestamp exceeds timestamp + recvWindow, then the order will be rejected.
2251
- * @param {int} [params.recvWindow] in milliseconds. If an order reaches the matching engine and the current timestamp exceeds timestamp + recvWindow, then the order will be rejected. If timestamp is provided without recvWindow, then a default recvWindow of 1000ms is used.
2252
- * @param {string} [params.responseType] FULL or ACK
2253
- * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
2254
- * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2255
- * @param {float} [params.limitPrice] Limit price for the STOP_LIMIT order
2256
- * @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
2257
- * @param {string} [params.timeInForce] GTC (default), IOC, FOK, PO, MAKER_ONLY or MAKER_ONLY_REPRICE (reprices order to the best maker only price if the specified price were to lead to a taker trade)
2258
- * @param {string} [params.selfTradePrevention] NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH for more info check here {@link https://docs.ox.fun/?json#self-trade-prevention-modes}
2259
- * @param {string} [params.displayQuantity] for an iceberg order, pass both quantity and displayQuantity fields in the order request
2260
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2261
- */
2262
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2263
- await this.loadMarkets();
2264
- const responseType = this.safeString(params, 'responseType', 'FULL');
2265
- const timestamp = this.safeInteger(params, 'timestamp', this.milliseconds());
2266
- const request = {
2267
- 'responseType': responseType,
2268
- 'timestamp': timestamp,
2269
- };
2270
- params = this.omit(params, ['responseType', 'timestamp']);
2271
- const recvWindow = this.safeInteger(params, 'recvWindow');
2272
- if (recvWindow !== undefined) {
2273
- request['recvWindow'] = recvWindow;
2274
- params = this.omit(params, 'recvWindow');
2275
- }
2276
- const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
2277
- request['orders'] = [orderRequest];
2278
- const response = await this.privatePostV3OrdersPlace(request);
2279
- //
2280
- // accepted market order responseType FULL
2281
- // {
2282
- // "success": true,
2283
- // "data": [
2284
- // {
2285
- // "notice": "OrderMatched",
2286
- // "accountId": "106490",
2287
- // "orderId": "1000109901865",
2288
- // "submitted": true,
2289
- // "clientOrderId": "0",
2290
- // "marketCode": "OX-USDT",
2291
- // "status": "FILLED",
2292
- // "side": "SELL",
2293
- // "isTriggered": false,
2294
- // "quantity": "150.0",
2295
- // "amount": "0.0",
2296
- // "remainQuantity": "0.0",
2297
- // "matchId": "100017047880451399",
2298
- // "matchPrice": "0.01465",
2299
- // "matchQuantity": "150.0",
2300
- // "feeInstrumentId": "USDT",
2301
- // "fees": "0.0015382500",
2302
- // "orderType": "MARKET",
2303
- // "createdAt": "1715592472236",
2304
- // "lastMatchedAt": "1715592472200",
2305
- // "displayQuantity": "150.0"
2306
- // }
2307
- // ]
2308
- // }
2309
- //
2310
- // accepted limit order responseType FULL
2311
- // {
2312
- // "success": true,
2313
- // "data": [
2314
- // {
2315
- // "notice": "OrderOpened",
2316
- // "accountId": "106490",
2317
- // "orderId": "1000111482406",
2318
- // "submitted": true,
2319
- // "clientOrderId": "0",
2320
- // "marketCode": "ETH-USD-SWAP-LIN",
2321
- // "status": "OPEN",
2322
- // "side": "SELL",
2323
- // "price": "4000.0",
2324
- // "isTriggered": false,
2325
- // "quantity": "0.01",
2326
- // "amount": "0.0",
2327
- // "orderType": "LIMIT",
2328
- // "timeInForce": "GTC",
2329
- // "createdAt": "1715763507682",
2330
- // "displayQuantity": "0.01"
2331
- // }
2332
- // ]
2333
- // }
2334
- //
2335
- // accepted order responseType ACK
2336
- // {
2337
- // "success": true,
2338
- // "data": [
2339
- // {
2340
- // "accountId": "106490",
2341
- // "orderId": "1000109892193",
2342
- // "submitted": true,
2343
- // "marketCode": "OX-USDT",
2344
- // "side": "BUY",
2345
- // "price": "0.01961",
2346
- // "isTriggered": false,
2347
- // "quantity": "100",
2348
- // "orderType": "MARKET",
2349
- // "timeInForce": "IOC",
2350
- // "createdAt": "1715591529057",
2351
- // "selfTradePreventionMode": "NONE"
2352
- // }
2353
- // ]
2354
- // }
2355
- //
2356
- // rejected order (balance insufficient)
2357
- // {
2358
- // "success": true,
2359
- // "data": [
2360
- // {
2361
- // "code": "710001",
2362
- // "message": "System failure, exception thrown -> null",
2363
- // "submitted": false,
2364
- // "marketCode": "OX-USDT",
2365
- // "side": "BUY",
2366
- // "price": "0.01961",
2367
- // "amount": "100",
2368
- // "orderType": "MARKET",
2369
- // "timeInForce": "IOC",
2370
- // "createdAt": "1715591678835",
2371
- // "source": 11,
2372
- // "selfTradePreventionMode": "NONE"
2373
- // }
2374
- // ]
2375
- // }
2376
- //
2377
- // rejected order (bad request)
2378
- // {
2379
- // "success": true,
2380
- // "data": [
2381
- // {
2382
- // "code": "20044",
2383
- // "message": "Amount is not supported for this order type",
2384
- // "submitted": false,
2385
- // "marketCode": "OX-USDT",
2386
- // "side": "SELL",
2387
- // "amount": "200",
2388
- // "orderType": "MARKET",
2389
- // "createdAt": "1715592079986",
2390
- // "source": 11
2391
- // }
2392
- // ]
2393
- // }
2394
- //
2395
- const data = this.safeList(response, 'data', []);
2396
- const order = this.safeDict(data, 0, {});
2397
- return this.parseOrder(order);
2398
- }
2399
- /**
2400
- * @method
2401
- * @name oxfun#createOrders
2402
- * @description create a list of trade orders
2403
- * @see https://docs.ox.fun/?json#post-v3-orders-place
2404
- * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2405
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2406
- * @param {int} [params.timestamp] *for all orders* in milliseconds. If orders reach the matching engine and the current timestamp exceeds timestamp + recvWindow, then all orders will be rejected.
2407
- * @param {int} [params.recvWindow] *for all orders* in milliseconds. If orders reach the matching engine and the current timestamp exceeds timestamp + recvWindow, then all orders will be rejected. If timestamp is provided without recvWindow, then a default recvWindow of 1000ms is used.
2408
- * @param {string} [params.responseType] *for all orders* FULL or ACK
2409
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2410
- */
2411
- async createOrders(orders, params = {}) {
2412
- await this.loadMarkets();
2413
- const ordersRequests = [];
2414
- for (let i = 0; i < orders.length; i++) {
2415
- const rawOrder = orders[i];
2416
- const symbol = this.safeString(rawOrder, 'symbol');
2417
- const type = this.safeString(rawOrder, 'type');
2418
- const side = this.safeString(rawOrder, 'side');
2419
- const amount = this.safeNumber(rawOrder, 'amount');
2420
- const price = this.safeNumber(rawOrder, 'price');
2421
- const orderParams = this.safeDict(rawOrder, 'params', {});
2422
- const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, orderParams);
2423
- ordersRequests.push(orderRequest);
2424
- }
2425
- const request = {
2426
- 'responseType': 'FULL',
2427
- 'timestamp': this.milliseconds(),
2428
- 'orders': ordersRequests,
2429
- };
2430
- const response = await this.privatePostV3OrdersPlace(this.extend(request, params));
2431
- const data = this.safeList(response, 'data', []);
2432
- return this.parseOrders(data);
2433
- }
2434
- createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
2435
- /**
2436
- * @param {string} symbol unified symbol of the market to create an order in
2437
- * @param {string} type 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
2438
- * @param {string} side 'buy' or 'sell'
2439
- * @param {float} amount how much of currency you want to trade in units of base currency
2440
- * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2441
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2442
- * @param {int} [params.clientOrderId] a unique id for the order
2443
- * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
2444
- * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2445
- * @param {float} [params.limitPrice] Limit price for the STOP_LIMIT order
2446
- * @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
2447
- * @param {string} [params.timeInForce] GTC (default), IOC, FOK, PO, MAKER_ONLY or MAKER_ONLY_REPRICE (reprices order to the best maker only price if the specified price were to lead to a taker trade)
2448
- * @param {string} [params.selfTradePrevention] NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH for more info check here {@link https://docs.ox.fun/?json#self-trade-prevention-modes}
2449
- * @param {string} [params.displayQuantity] for an iceberg order, pass both quantity and displayQuantity fields in the order request
2450
- */
2451
- const market = this.market(symbol);
2452
- const request = {
2453
- 'marketCode': market['id'],
2454
- 'side': side.toUpperCase(),
2455
- 'source': 1000,
2456
- };
2457
- const cost = this.safeString2(params, 'cost', 'amount');
2458
- if (cost !== undefined) {
2459
- request['amount'] = cost; // todo costToPrecision
2460
- params = this.omit(params, ['cost', 'amount']);
2461
- }
2462
- else {
2463
- request['quantity'] = amount; // todo amountToPrecision
2464
- }
2465
- const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
2466
- let orderType = type.toUpperCase();
2467
- if (triggerPrice !== undefined) {
2468
- if (orderType === 'MARKET') {
2469
- orderType = 'STOP_MARKET';
2470
- }
2471
- else if (orderType === 'LIMIT') {
2472
- orderType = 'STOP_LIMIT';
2473
- }
2474
- request['stopPrice'] = triggerPrice; // todo priceToPrecision
2475
- params = this.omit(params, ['triggerPrice', 'stopPrice']);
2476
- }
2477
- request['orderType'] = orderType;
2478
- if (orderType === 'STOP_LIMIT') {
2479
- request['limitPrice'] = price; // todo priceToPrecision
2480
- }
2481
- else if (price !== undefined) {
2482
- request['price'] = price; // todo priceToPrecision
2483
- }
2484
- let postOnly = undefined;
2485
- const isMarketOrder = (orderType === 'MARKET') || (orderType === 'STOP_MARKET');
2486
- [postOnly, params] = this.handlePostOnly(isMarketOrder, false, params);
2487
- const timeInForce = this.safeStringUpper(params, 'timeInForce');
2488
- if (postOnly && (timeInForce !== 'MAKER_ONLY_REPRICE')) {
2489
- request['timeInForce'] = 'MAKER_ONLY';
2490
- }
2491
- let selfTradePrevention = undefined;
2492
- [selfTradePrevention, params] = this.handleOptionAndParams(params, 'createOrder', 'selfTradePrevention');
2493
- if (selfTradePrevention !== undefined) {
2494
- request['selfTradePreventionMode'] = selfTradePrevention.toUpperCase();
2495
- }
2496
- return this.extend(request, params);
2497
- }
2498
- /**
2499
- * @method
2500
- * @name oxfun#createMarketBuyOrderWithCost
2501
- * @description create a market buy order by providing the symbol and cost
2502
- * @see https://open.big.one/docs/spot_orders.html#create-order
2503
- * @param {string} symbol unified symbol of the market to create an order in
2504
- * @param {float} cost how much you want to trade in units of the quote currency
2505
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2506
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2507
- */
2508
- async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
2509
- await this.loadMarkets();
2510
- const market = this.market(symbol);
2511
- if (!market['spot']) {
2512
- throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
2513
- }
2514
- const request = {
2515
- 'cost': cost,
2516
- };
2517
- return await this.createOrder(symbol, 'market', 'buy', undefined, undefined, this.extend(request, params));
2518
- }
2519
- /**
2520
- * @method
2521
- * @name oxfun#fetchOrder
2522
- * @see https://docs.ox.fun/?json#get-v3-orders-status
2523
- * @description fetches information on an order made by the user
2524
- * @param {string} id a unique id for the order
2525
- * @param {string} [symbol] not used by oxfun fetchOrder
2526
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2527
- * @param {int} [params.clientOrderId] the client order id of the order
2528
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2529
- */
2530
- async fetchOrder(id, symbol = undefined, params = {}) {
2531
- await this.loadMarkets();
2532
- const request = {
2533
- 'orderId': id,
2534
- };
2535
- const response = await this.privateGetV3OrdersStatus(this.extend(request, params));
2536
- //
2537
- // {
2538
- // "success": true,
2539
- // "data": {
2540
- // "orderId": "1000111762980",
2541
- // "clientOrderId": "0",
2542
- // "marketCode": "ETH-USD-SWAP-LIN",
2543
- // "status": "OPEN",
2544
- // "side": "BUY",
2545
- // "price": "2700.0",
2546
- // "isTriggered": false,
2547
- // "remainQuantity": "0.01",
2548
- // "totalQuantity": "0.01",
2549
- // "amount": "0",
2550
- // "displayQuantity": "0.01",
2551
- // "cumulativeMatchedQuantity": "0",
2552
- // "orderType": "STOP_LIMIT",
2553
- // "timeInForce": "GTC",
2554
- // "source": "11",
2555
- // "createdAt": "1715794191277"
2556
- // }
2557
- // }
2558
- //
2559
- const data = this.safeDict(response, 'data', {});
2560
- return this.parseOrder(data);
2561
- }
2562
- /**
2563
- * @method
2564
- * @name oxfun#fetchOpenOrders
2565
- * @description fetch all unfilled currently open orders
2566
- * @see https://docs.ox.fun/?json#get-v3-orders-working
2567
- * @param {string} symbol unified market symbol
2568
- * @param {int} [since] the earliest time in ms to fetch open orders for
2569
- * @param {int} [limit] the maximum number of open orders structures to retrieve
2570
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2571
- * @param {int} [params.orderId] a unique id for the order
2572
- * @param {int} [params.clientOrderId] the client order id of the order
2573
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2574
- */
2575
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2576
- await this.loadMarkets();
2577
- const request = {};
2578
- let market = undefined;
2579
- if (symbol !== undefined) {
2580
- market = this.market(symbol);
2581
- }
2582
- const response = await this.privateGetV3OrdersWorking(this.extend(request, params));
2583
- const data = this.safeList(response, 'data', []);
2584
- return this.parseOrders(data, market, since, limit);
2585
- }
2586
- /**
2587
- * @method
2588
- * @name oxfun#cancelOrder
2589
- * @description cancels an open order
2590
- * @see https://docs.ox.fun/?json#delete-v3-orders-cancel
2591
- * @param {string} id order id
2592
- * @param {string} symbol unified symbol of the market the order was made in
2593
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2594
- * @param {int} [params.clientOrderId] a unique id for the order
2595
- * @param {int} [params.timestamp] in milliseconds
2596
- * @param {int} [params.recvWindow] in milliseconds
2597
- * @param {string} [params.responseType] 'FULL' or 'ACK'
2598
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2599
- */
2600
- async cancelOrder(id, symbol = undefined, params = {}) {
2601
- if (symbol === undefined) {
2602
- throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
2603
- }
2604
- const market = this.market(symbol);
2605
- const marketId = market['id'];
2606
- const request = {
2607
- 'timestamp': this.milliseconds(),
2608
- 'responseType': 'FULL',
2609
- };
2610
- const orderRequest = {
2611
- 'marketCode': marketId,
2612
- 'orderId': id,
2613
- };
2614
- const clientOrderId = this.safeInteger(params, 'clientOrderId');
2615
- if (clientOrderId !== undefined) {
2616
- orderRequest['clientOrderId'] = clientOrderId;
2617
- }
2618
- request['orders'] = [orderRequest];
2619
- const response = await this.privateDeleteV3OrdersCancel(this.extend(request, params));
2620
- const data = this.safeList(response, 'data', []);
2621
- const order = this.safeDict(data, 0, {});
2622
- return this.parseOrder(order);
2623
- }
2624
- /**
2625
- * @method
2626
- * @name oxfun#cancelAllOrders
2627
- * @description cancel all open orders
2628
- * @see https://docs.ox.fun/?json#delete-v3-orders-cancel-all
2629
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2630
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2631
- * @returns {object} response from exchange
2632
- */
2633
- async cancelAllOrders(symbol = undefined, params = {}) {
2634
- const request = {};
2635
- if (symbol !== undefined) {
2636
- const market = this.market(symbol);
2637
- request['marketCode'] = market['id'];
2638
- }
2639
- //
2640
- // {
2641
- // "success": true,
2642
- // "data": { "notice": "Orders queued for cancelation" }
2643
- // }
2644
- //
2645
- // {
2646
- // "success": true,
2647
- // "data": { "notice": "No working orders found" }
2648
- // }
2649
- //
2650
- const response = await this.privateDeleteV3OrdersCancelAll(this.extend(request, params));
2651
- return [this.safeOrder({ 'info': response })];
2652
- }
2653
- /**
2654
- * @method
2655
- * @name oxfun#cancelOrders
2656
- * @description cancel multiple orders
2657
- * @see https://docs.ox.fun/?json#delete-v3-orders-cancel
2658
- * @param {string[]} ids order ids
2659
- * @param {string} [symbol] unified market symbol
2660
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2661
- * @param {int} [params.timestamp] in milliseconds
2662
- * @param {int} [params.recvWindow] in milliseconds
2663
- * @param {string} [params.responseType] 'FULL' or 'ACK'
2664
- * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
2665
- */
2666
- async cancelOrders(ids, symbol = undefined, params = {}) {
2667
- if (symbol === undefined) {
2668
- throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
2669
- }
2670
- await this.loadMarkets();
2671
- const market = this.market(symbol);
2672
- const marketId = market['id'];
2673
- const request = {
2674
- 'timestamp': this.milliseconds(),
2675
- 'responseType': 'FULL',
2676
- };
2677
- const orders = [];
2678
- for (let i = 0; i < ids.length; i++) {
2679
- const order = {
2680
- 'marketCode': marketId,
2681
- 'orderId': ids[i],
2682
- };
2683
- orders.push(order);
2684
- }
2685
- request['orders'] = orders;
2686
- const response = await this.privateDeleteV3OrdersCancel(this.extend(request, params));
2687
- const data = this.safeList(response, 'data', []);
2688
- return this.parseOrders(data, market);
2689
- }
2690
- parseOrder(order, market = undefined) {
2691
- //
2692
- // accepted market order responseType FULL
2693
- // {
2694
- // "notice": "OrderMatched",
2695
- // "accountId": "106490",
2696
- // "orderId": "1000109901865",
2697
- // "submitted": true,
2698
- // "clientOrderId": "0",
2699
- // "marketCode": "OX-USDT",
2700
- // "status": "FILLED",
2701
- // "side": "SELL",
2702
- // "isTriggered": false,
2703
- // "quantity": "150.0",
2704
- // "amount": "0.0",
2705
- // "remainQuantity": "0.0",
2706
- // "matchId": "100017047880451399",
2707
- // "matchPrice": "0.01465",
2708
- // "matchQuantity": "150.0",
2709
- // "feeInstrumentId": "USDT",
2710
- // "fees": "0.0015382500",
2711
- // "orderType": "MARKET",
2712
- // "createdAt": "1715592472236",
2713
- // "lastMatchedAt": "1715592472200",
2714
- // "displayQuantity": "150.0"
2715
- // }
2716
- //
2717
- // accepted limit order responseType FULL
2718
- // {
2719
- // "notice": "OrderOpened",
2720
- // "accountId": "106490",
2721
- // "orderId": "1000111482406",
2722
- // "submitted": true,
2723
- // "clientOrderId": "0",
2724
- // "marketCode": "ETH-USD-SWAP-LIN",
2725
- // "status": "OPEN",
2726
- // "side": "SELL",
2727
- // "price": "4000.0",
2728
- // "isTriggered": false,
2729
- // "quantity": "0.01",
2730
- // "amount": "0.0",
2731
- // "orderType": "LIMIT",
2732
- // "timeInForce": "GTC",
2733
- // "createdAt": "1715763507682",
2734
- // "displayQuantity": "0.01"
2735
- // }
2736
- //
2737
- // accepted order responseType ACK
2738
- // {
2739
- // "accountId": "106490",
2740
- // "orderId": "1000109892193",
2741
- // "submitted": true,
2742
- // "marketCode": "OX-USDT",
2743
- // "side": "BUY",
2744
- // "price": "0.01961",
2745
- // "isTriggered": false,
2746
- // "quantity": "100",
2747
- // "orderType": "MARKET",
2748
- // "timeInForce": "IOC",
2749
- // "createdAt": "1715591529057",
2750
- // "selfTradePreventionMode": "NONE"
2751
- // }
2752
- //
2753
- // rejected order (balance insufficient)
2754
- // {
2755
- // "code": "710001",
2756
- // "message": "System failure, exception thrown -> null",
2757
- // "submitted": false,
2758
- // "marketCode": "OX-USDT",
2759
- // "side": "BUY",
2760
- // "price": "0.01961",
2761
- // "amount": "100",
2762
- // "orderType": "MARKET",
2763
- // "timeInForce": "IOC",
2764
- // "createdAt": "1715591678835",
2765
- // "source": 11,
2766
- // "selfTradePreventionMode": "NONE"
2767
- // }
2768
- //
2769
- // rejected order (bad request)
2770
- // {
2771
- // "code": "20044",
2772
- // "message": "Amount is not supported for this order type",
2773
- // "submitted": false,
2774
- // "marketCode": "OX-USDT",
2775
- // "side": "SELL",
2776
- // "amount": "200",
2777
- // "orderType": "MARKET",
2778
- // "createdAt": "1715592079986",
2779
- // "source": 11
2780
- // }
2781
- //
2782
- // fetchOrder
2783
- // {
2784
- // "orderId": "1000111762980",
2785
- // "clientOrderId": "0",
2786
- // "marketCode": "ETH-USD-SWAP-LIN",
2787
- // "status": "OPEN",
2788
- // "side": "BUY",
2789
- // "price": "2700.0",
2790
- // "isTriggered": false,
2791
- // "remainQuantity": "0.01",
2792
- // "totalQuantity": "0.01",
2793
- // "amount": "0",
2794
- // "displayQuantity": "0.01",
2795
- // "cumulativeMatchedQuantity": "0",
2796
- // "orderType": "STOP_LIMIT",
2797
- // "timeInForce": "GTC",
2798
- // "source": "11",
2799
- // "createdAt": "1715794191277"
2800
- // }
2801
- //
2802
- const marketId = this.safeString(order, 'marketCode');
2803
- market = this.safeMarket(marketId, market);
2804
- const timestamp = this.safeInteger(order, 'createdAt');
2805
- let fee = undefined;
2806
- const feeCurrency = this.safeString(order, 'feeInstrumentId');
2807
- if (feeCurrency !== undefined) {
2808
- fee = {
2809
- 'currency': this.safeCurrencyCode(feeCurrency),
2810
- 'cost': this.safeNumber(order, 'fees'),
2811
- };
2812
- }
2813
- let status = this.safeString(order, 'status');
2814
- const code = this.safeInteger(order, 'code'); // rejected orders have code of the error
2815
- if (code !== undefined) {
2816
- status = 'rejected';
2817
- }
2818
- const triggerPrice = this.safeString(order, 'stopPrice');
2819
- return this.safeOrder({
2820
- 'id': this.safeString(order, 'orderId'),
2821
- 'clientOrderId': this.safeString(order, 'clientOrderId'),
2822
- 'timestamp': timestamp,
2823
- 'datetime': this.iso8601(timestamp),
2824
- 'lastTradeTimestamp': this.safeInteger(order, 'lastMatchedAt'),
2825
- 'lastUpdateTimestamp': this.safeInteger(order, 'lastModifiedAt'),
2826
- 'status': this.parseOrderStatus(status),
2827
- 'symbol': market['symbol'],
2828
- 'type': this.parseOrderType(this.safeString(order, 'orderType')),
2829
- 'timeInForce': this.parseOrderTimeInForce(this.safeString(order, 'timeInForce')),
2830
- 'side': this.safeStringLower(order, 'side'),
2831
- 'price': this.safeStringN(order, ['price', 'matchPrice', 'limitPrice']),
2832
- 'average': undefined,
2833
- 'amount': this.safeString2(order, 'totalQuantity', 'quantity'),
2834
- 'filled': this.safeString2(order, 'cumulativeMatchedQuantity', 'matchQuantity'),
2835
- 'remaining': this.safeString(order, 'remainQuantity'),
2836
- 'triggerPrice': triggerPrice,
2837
- 'stopLossPrice': triggerPrice,
2838
- 'cost': this.omitZero(this.safeString(order, 'amount')),
2839
- 'trades': undefined,
2840
- 'fee': fee,
2841
- 'info': order,
2842
- }, market);
2843
- }
2844
- parseOrderStatus(status) {
2845
- const statuses = {
2846
- 'OPEN': 'open',
2847
- 'PARTIALLY_FILLED': 'open',
2848
- 'PARTIAL_FILL': 'open',
2849
- 'FILLED': 'closed',
2850
- 'CANCELED': 'canceled',
2851
- 'CANCELED_BY_USER': 'canceled',
2852
- 'CANCELED_BY_MAKER_ONLY': 'rejected',
2853
- 'CANCELED_BY_FOK': 'rejected',
2854
- 'CANCELED_ALL_BY_IOC': 'rejected',
2855
- 'CANCELED_PARTIAL_BY_IOC': 'canceled',
2856
- 'CANCELED_BY_SELF_TRADE_PROTECTION': 'rejected',
2857
- };
2858
- return this.safeString(statuses, status, status);
2859
- }
2860
- parseOrderType(type) {
2861
- const types = {
2862
- 'LIMIT': 'limit',
2863
- 'STOP_LIMIT': 'limit',
2864
- 'MARKET': 'market',
2865
- 'STOP_MARKET': 'market',
2866
- };
2867
- return this.safeString(types, type, type);
2868
- }
2869
- parseOrderTimeInForce(type) {
2870
- const types = {
2871
- 'GTC': 'GTC',
2872
- 'IOC': 'IOC',
2873
- 'FOK': 'FOK',
2874
- 'MAKER_ONLY': 'PO',
2875
- 'MAKER_ONLY_REPRICE': 'PO',
2876
- };
2877
- return this.safeString(types, type, type);
2878
- }
2879
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2880
- const baseUrl = this.urls['api'][api];
2881
- let url = baseUrl + '/' + path;
2882
- let queryString = '';
2883
- if (method === 'GET') {
2884
- queryString = this.urlencode(params);
2885
- if (queryString.length !== 0) {
2886
- url += '?' + queryString;
2887
- }
2888
- }
2889
- if (api === 'private') {
2890
- this.checkRequiredCredentials();
2891
- const timestamp = this.milliseconds();
2892
- const isoDatetime = this.iso8601(timestamp);
2893
- const datetimeParts = isoDatetime.split('.');
2894
- const datetime = datetimeParts[0];
2895
- const nonce = this.nonce();
2896
- const urlParts = baseUrl.split('//');
2897
- if ((method === 'POST') || (method === 'DELETE')) {
2898
- body = this.json(params);
2899
- queryString = body;
2900
- }
2901
- const msgString = datetime + '\n' + nonce.toString() + '\n' + method + '\n' + urlParts[1] + '\n/' + path + '\n' + queryString;
2902
- const signature = this.hmac(this.encode(msgString), this.encode(this.secret), sha256, 'base64');
2903
- headers = {
2904
- 'Content-Type': 'application/json',
2905
- 'AccessKey': this.apiKey,
2906
- 'Timestamp': datetime,
2907
- 'Signature': signature,
2908
- 'Nonce': nonce.toString(),
2909
- };
2910
- }
2911
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2912
- }
2913
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2914
- if (response === undefined) {
2915
- return undefined;
2916
- }
2917
- if (code !== 200) {
2918
- const responseCode = this.safeString(response, 'code');
2919
- const feedback = this.id + ' ' + body;
2920
- this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
2921
- this.throwExactlyMatchedException(this.exceptions['exact'], responseCode, feedback);
2922
- throw new ExchangeError(feedback);
2923
- }
2924
- return undefined;
2925
- }
2926
- }