
    E#iS                       S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!  S SK"J#r#  S SK$J%r%  S SK$J&r&  S SK$J'r'  S S	K$J(r(  S S
K$J)r)  S SK$J*r*  S SK$J+r+  S SK$J,r,  S SK$J-r-  S SK$J.r.  S SK$J/r/  S SK$J0r0  S SK$J1r1  S SK$J2r2  S SK$J3r3  S SK4J5r5   " S S\\5      r6g)    )Exchange)ImplicitAPIN)AccountAnyBalancesBool
CurrenciesCurrencyDepositAddressIntLeverageTierLeverageTiersMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)AccountNotEnabled)ArgumentsRequired)
BadRequest)	BadSymbol)MarketClosed)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)OperationFailed)NetworkError)RateLimitExceeded)RequestTimeout)	TICK_SIZEc                     ^  \ rS rSrS\4U 4S jjr0 4S\\   4S jjrS\\   4S jr	S\4S jr
0 4S\4S jjrS0 4S	\S\4S
 jjr0 4S\S\4S jjrSUS\S\4S jjrSSS0 4S\S\S\S\S\\   4
S jjrSUS\S\4S jjrS0 4S\S\S\4S jjrS0 4S	\S\4S jjr0 4S\S\4S jjrSUS\S\4S jjrSSS0 4S\S\S\4S jjr SUS\4S jjr!SSS0 4S\S\S\4S jjr"SUS\4S jjr#S0 4S	\S\$4S jjr%SUS\S\\&   4S jjr'SS0 4S\S\S\S\\(   4S jjr)SSS0 4S\S\S\4S  jjr*SUS\S\(4S! jjr+0 4S\,4S" jjr-S\,4S# jr.0 4S\\/   4S$ jjr0S% r10 4S&\S'\2S(\S)\S\34
S* jjr4SSS0 4S&\S\S\4S+ jjr5SUS,\64S- jjr7S. r80 4S&\S\94S/ jjr:SUS,\6S\94S0 jjr;SSS0 4S&\S\S\S\\<   4S1 jjr=SSS0 4S&\S\S\S\\<   4S2 jjr>SSS0 4S,\6S\S\S\\<   4S3 jjr?SUS,\6S\<4S4 jjr@S5 rAS6 rBS0 4S&\S'\2S7\S8\S\<4
S9 jjrCS0 4S	\S\\D   4S: jjrESUS\4S; jjrFS0 4S\S<\GS=\HS'\2S>\IS\J4S? jjrK0 4S@\\L   S\\J   4SA jjrMS0 4S\S<\S=\4SB jjrN0 4S\SC\24SD jjrOS0 4SE\S\S\J4SF jjrPSSS0 4S\S\S\S\\J   4SG jjrQS0 4SE\S\4SH jjrRS0 4S\4SI jjrSS0 4SJ\\   S\4SK jjrTSUS\S\J4SL jjrUSM rVSN rWSO rXSPSQ0 SS4SR jrYSS rZSTr[U =r\$ )Voxfun   returnc           #      d	  > U R                  [        [        U ]  5       SSS/SSS0 SS _SS_S	S
_SS_SS
_SS
_SS
_SS_SS_SS_SS
_SS
_SS
_SS_SS
_SS
_SS_0 SS_SS_SS
_SS_SS_SS_SS
_S S
_S!S_S"S_S#S
_S$S
_S%S
_S&S
_S'S
_S(S
_S)S
_E0 S*S
_S+S
_S,S_S-S
_S.S_S/S
_S0S
_S1S_S2S
_S3S
_S4S_S5S_S6S_S7S_S8S
_S9S
_S:S
_E0 S;S
_S<S
_S=S
_S>S_S?S@_SAS_SBS
_SCS_SDS_SES
_SFS
_SGS_SHS_SIS_SJS
_SKS
_SLS
_E0 SMS
_SNS
_SOS
_SPS_SQS
_SRS
_SSS
_STS
_SUS
_SVS_SWS_SXS
_SYS_SZS
_S[S
_S\S
_S]S
_E0 S^S
_S_S
_S`S_SaS
_SbS_ScS
_SdS
_SeS
_SfS
_SgS_ShS
_SiS
_SjS
_SkS
_SlS
_SmS_SnS_ESoS0ESpSqSrSsStSuSvSwSx.SySzS{S{S|.S}S}S|.S~SSS.SSSSSSSSSSSS.
0SSSSSSSSSSSSSSSS.SSSS.SSS.S.S|.SSSU R	                  S5      U R	                  S5      U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //S.S.0[
        S
SSSSSSSSSS.	SSSSSSSSSSS.
S.SS
SS
S S
S
S SSSS
S.S
S
S
SS
SSSSS.SS.SS0S
SSSS
S.S
S
S
S
S.S
S S
S
S
S.S S SS0S.	SS0SS0S S.S S S.S.0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _E0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[         _S["        _S["        _S[$        _S["        _S[        _S[        _E[        [        [        [        [&        [&        [&        [        [        S.	E[        [(        S.S.S.5      $ )Nr2   OXFUNPAv3x   TCORSspotmarginFswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchMarketLeverageTiersemulatedfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchWithdrawalfetchWithdrawalsfetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdrawws60s300s900s1800s3600s7200s14400s86400s)1m5m15m30m1h2h4h1dzQhttps://github.com/ccxt/ccxt/assets/43336371/6a196124-c1ee-4fae-8573-962071b61a85z/https://ox.fun/register?shareAccountId=5ZUD4a7Gzhttps://api.ox.fun)publicprivatezhttps://stgapi.ox.funzhttps://ox.fun/zhttps://docs.ox.fun/z7https://support.ox.fun/en/articles/8819866-trading-fees)logoreferralapitestwwwdocfeesget   )
z
v3/marketsz	v3/assetsz
v3/tickerszv3/funding/estimatesz
v3/candleszv3/depthzv3/markets/operationalzv3/exchange-tradeszv3/funding/rateszv3/leverage/tiers)z
v3/accountzv3/account/namesz	v3/walletv3/transferzv3/balanceszv3/positionsz
v3/fundingzv3/deposit-addressesz
v3/depositzv3/withdrawal-addressesv3/withdrawalzv3/withdrawal-feeszv3/orders/statuszv3/orders/workingz	v3/trades)r   r   zv3/orders/place)zv3/orders/cancelzv3/orders/cancel-all)r   postdeletetradingz0.00020z0.0007002500000z0.0001025000000z0.00050z0.00040)makertaker)	tierBased
percentager   r   tiersBitcoinEthereum	AvalancheSolanaArbitrumPolygonFantomBNBSmartChainOptimism)	BTCERC20AVAXSOLARBMATICFTMBNBOPTIMISMr   r   r   r   r   r   r   BASEr   r   )
r   r   r   r   r   r   r   Baser   r   )sandboxModenetworksnetworksById)IOCFOKPOGTD)EXPIRE_MAKEREXPIRE_TAKEREXPIRE_BOTHNONE)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergmax
   i  i    )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   r   )	r   rJ   rK   ru   rz   ry   r}   r[   rv   extendsdefault)linearinverse)r  r;   r=   r>   z-0010z-429z-05001z-10001z-20000-20001z-20002z-20003z-20005z-20006z-20007z-20008z-20009z-20010z-20011z-20012z-20013z-20014z-20015z-20016z-20017z-20018z-20019z-20020z-20021z-20022z-20023z-20024z-20025z-20026z-20027z-20028z-20029z-20030z-20031z-20032z-20033z-20034z-20050z-30001z-35034z-35046z-40001z-50001z-300001z-300011z-300012z-100005z-100006z-100008z-100015)	z-710001z-710002z-710003z-710004z-710005z-710006z-710007z-000101z-000201)r  z-200050)exactbroad)idname	countriesversion	rateLimitprohas
timeframesurlsr   r   precisionModeoptionsfeatures
exceptions)deep_extendsuperr2   describeparse_numberr0   r,   r.   r"   r!   r%   r+   r$   r&   r'   r-   r#   r)   r*   r(   r/   )self	__class__s    R/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/oxfun.pyr  oxfun.describe    s   eT ; =hhh %h 	h
 %h %h Uh "4h th h $Uh  h 'h /h ,Uh  0!h" t#h$ %h& &t'h( ()h* '+h, (-h. "4/h0 51h2 U3h4  5h6 7h8  9h: &u;h< +E=h> )%?h@ &uAhB #EChD $UEhF 'GhH (IhJ "4KhL MhN &tOhP (QhR 1%ShT  UhV *5WhX +EYhZ &t[h\ #D]h^ *4_h` $Tahb "5chd *5ehf +Eghh #Eihj ukhl  mhn %dohp +Jqhr sht !%uhv  whx dyhz +E{h| !%}h~ "4h@ dAhB !$ChD "5EhF uGhH #EIhJ  KhL 'MhN $UOhP !$QhR *5ShT (UhV %eWhX )%YhZ u[h\ t]h^ _h` Uahb tchd "5ehf #Eghh %eihj &ukhl 'mhn $Uohp !$qhr "5sht #Duhv +Ewhx yhz #E{h| &u}h~ 4h@ uAhB UChD  EhF "5GhH %IhJ DKhL DMhN dOhT 	 lM23
 66 )-Q" &'%&&'01&'$%23./,--.  '(,-%&'('(()&'01&'34)*./,--.%&$ ())*+, -.01/+Z !%"&!..y9!..y9 "..s3T5F5Fy5QR!..y94;L;LY;WX!..z:D<M<Mc<RS" "..s3T5F5Fy5QR!..y94;L;LY;WX!..z:D<M<Mi<XY"( '  %$''#%&#* *
  % '!'# %&#"%* *!8  $&+(,,1,0).+06:#'#'"&#(	( #($)$)+/27,0,0+/$(	0 $(3$8 r% ',!$$*%&*/& ',#($)*/	# ',!%#($)*/( $()-#m9v y
 "9  $	 ##IHT=_=-= 1= m	=
 j= j= j= l= 1= j= 1= j= j= /= /=  /!=" /#=$ j%=& i'=( j)=* j+=, j-=. j/=0 j1=2 j3=4 /5=6 /7=8 m9=: 1;=< j==> j?=@ jA=B jC=D jE=F lG=H lI=J jK=L jM=N mO=P jQ=R 1S=T 1U=V mW=X mY=Z 0[=\ |]=^ |_=` }a=b |c=d ze=f |g=h  -)))000++y=~ .-C]	r@
 r r	    c                   #    [         R                  " U R                  U5      U R                  U5      /6 I Sh  vN u  p#U R	                  US/ 5      nU R	                  US/ 5      nU R                  XE5      nU R                  U5      $  NN7f)z
retrieves data on all markets for bitmex

https://docs.ox.fun/?json#get-v3-markets

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Ndata)asynciogatherpublicGetV3MarketspublicGetV3Tickers	safe_listarray_concatparse_markets)r  paramsresponseFromMarketsresponseFromTickersmarketsFromMarketsmarketsFromTickersmarketss          r  fetch_marketsoxfun.fetch_markets  s      :A$JaJabhJiko  lC  lC  DJ  lK  JL  :M  4M0!^^,?Lr "^^,?L, ##$6K!!'**c 4Ms   7B
BAB
c                    / n/ n[        S[        U5      5       Hb  nX   nU R                  US5      nU R                  Xb5      (       a  M1  UR	                  U5        UR	                  U R                  U5      5        Md     U$ )Nr   
marketCode)rangelensafe_stringin_arrayappendparse_market)r  r+  	marketIdsresultimarketmarketIds          r  r%  oxfun.parse_markets  su    	q#g,'AZF''=HMM(66  *d//78 ( r  c                    U R                  USS5      nUR                  S5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nUS-   U-   nU R                  USS5      n	S n
S nU	S	:H  nU(       a  S
n	Sn
U R                  S5      nUS-   U-   nU	S:H  nU R	                  0 SU_SS _SU_SU_SU_SU_SU_SU_SU
_SU	_SU_SS_S
U_S	S_SS_SS_SU_U(       a  SOS U(       a  SOS U R
                  S   S   U R
                  S   S   U(       a  SOS S S S S S U R                  US5      S .S S S!.U R                  US"5      S S!.S S S!.S S S!.S#.U R                  US$5      S US%.E5      $ )&Nr/   -r   r   /typer;   r>   r=   OX:r  	numericIdsymbolbasequotesettlebaseIdquoteIdsettleIdr<   Fr?   activeTcontractr   r   r   tickSize)amountpriceminr   minSize)r   rN  rO  costlistedAt)r  r  r   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedindexinfo)r2  splitsafe_currency_codesafe_string_lowersafe_market_structurer   safe_numbersafe_integer)r  r9  r  partsrH  rI  rE  rF  rD  r@  rJ  rG  isFutureisSpots                 r  r5  oxfun.parse_market  sr   flB7!!%+""5!,&&v.''0e#%%fff=H$DH,,T2Fc\F*F)) 4+
"4+
4+
 f4+
 D	4+

 U4+
 f4+
 f4+
 w4+
 4+
 D4+
 F4+
 e4+
 H4+
 e4+
 e4+
  d!4+
" #4+
$ 'dD (udYYy)'2YYy)'2!)At"))&*=  
  ++FI>
  
  $ ((<g4+
 4 4	r  c                 "  #    U R                  U5      I Sh  vN nU R                  US/ 5      n0 n[        S[        U5      5       GHp  nX5   nU R	                  USS5      nUR                  S5      nUS   n	U R                  U	5      n
X;  a  U	U
SSSSSSSSSS.SSS.S.0 / S	.XJ'   U R                  US
/ 5      n[        S[        U5      5       H  nX   nU R	                  US5      nU R                  U5      nUUSU R                  US5      U R                  US5      SSU R                  U R                  U R	                  US5      5      5      U R                  US5      SS.U R                  US5      SS.S.US.
XJ   S   U'   M     U R                  XJ   S/ 5      nUR                  U5        UXJ   S'   GMs     [        UR                  5       5      n[        S[        U5      5       H  nUU   n
U R                  XJ   5      XJ'   M     U$  GN7f)z
fetches all available currencies on an exchange

https://docs.ox.fun/?json#get-v3-assets

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr  r   assetr=  .rP  )r   rQ   )r  coderZ  r@  r  rK  rQ   r   feer[  r   r^  networkListnetwork
canDepositcanWithdrawtransactionPrecision
minDepositminWithdrawal)rQ   r   )
r  ro  r<   rQ   r   rK  rm  rZ  r[  r^  r   r^  )publicGetV3Assetsr#  r0  r1  r2  r_  r`  network_id_to_code	safe_boolr  parse_precisionrc  r4  listkeyssafe_currency_structure)r  r&  responser  r7  r8  currencyfullIdre  r  rl  chainsjchain	networkIdnetworkCodeinfosallKeyss                     r  fetch_currenciesoxfun.fetch_currenciesD  sR     //77R ~~h3q#d)$AwH%%h<FLL%EqB**2.DN !%  "# $ $(#'%
 $(#'$	 !#+ . ^^HmR@F1c&k*	 ,,UI>	"55i@#*"#~~e\B $um D"!%!2!243G3GHXHXY^`vHw3x!y $(#3#3E<#H#'$
 $(#3#3E?#K#'%	 "'9Z(5	 +2 NN6<<ELL"#(FL u %x v{{}%q#g,'A1:D77EFL ( W 8s   HHG5HNsymbolsc                    #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      I Sh  vN nU R                  US/ 5      nU R	                  XA5      $  NR N*7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://docs.ox.fun/?json#get-v3-tickers

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr  )load_marketsmarket_symbolsr"  r#  parse_tickers)r  r  r&  r|  tickerss        r  fetch_tickersoxfun.fetch_tickers  sk      !!!%%g.0088` ..626!!'33g 	"8!   A-A))A- A+)A-+A-rD  c                 0  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US/ 5      nU R                  US0 5      nU R                  Xs5      $  N{ N=7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs.ox.fun/?json#get-v3-tickers

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr/  r  r  r   )r  r9  r"  extendr#  	safe_dictparse_ticker)r  rD  r&  r9  requestr|  r  tickers           r  fetch_tickeroxfun.fetch_ticker  s      !!!V$&,
 00W1MNN* ~~h3a,  009 	"
 Os!   BB?BB<BBr9  c           	         U R                  US5      nU R                  US5      nU R                  XB5      nUS   nU R                  US5      nU R                  0 SU_SU_SU R	                  U5      _SU R                  US5      _S	U R                  US
5      _SS _SS _SS _SS _SS _SU R                  US5      _SU_SU_SS _SS _SS _SS _U R                  US5      S U R                  US5      US.EU5      $ )NlastUpdatedAtr/  rD  lastTradedPrice	timestampdatetimehighhigh24hlowlow24hbid	bidVolumeask	askVolumevwapopenopen24hcloselastpreviousClosechanger   averagecurrencyVolume24h	markPrice)
baseVolumequoteVolumer  r^  )rd  r2  safe_marketsafe_tickeriso8601)r  r  r9  r  r:  rD  r  s          r  r  oxfun.parse_tickerA  s     %%fo>	##FL9!!(3!(9: !
f!
!
 Y/!
 D$$VY7	!

 4##FH5!
 4!
 !
 4!
 !
 D!
 D$$VY7!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **63FG))&+>+!
, - 	r  r   	timeframesincer   c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  X"5      nUS   US.nUb  X7S'   Ub  XGS'   U R	                  US5      nUb  XS'   U R                  US5      nOUb  U R                  US5      US'   U R                  U R                  Xu5      5      I Sh  vN n	U R                  U	S	/ 5      n
U R                  XX#U5      $  N N,7f)
a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://docs.ox.fun/?json#get-v3-candles

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch(default 24 hours ago)
:param int [limit]: the maximum amount of candles to fetch(default 200, max 500)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest candle to fetch(default now)
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr  )r/  r  	startTimer   untilendTime $r  )r  r9  r2  r  rd  omitsumpublicGetV3Candlesr  r#  parse_ohlcvs)r  rD  r  r  r   r&  r9  r  r  r|  r7  s              r  fetch_ohlcvoxfun.fetch_ohlcvn  s	     !!!V$$$T__iK	 ,"
 #(K $G!!&'2!&IYYvw/F!%%1H!IGI00W1MNN8 &"5  5II] 	"" Os"   C4C0B.C4C2+C42C4c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )NopenedAtr  r  r  r  currencyVolume)rd  rc  )r  ohlcvr9  s      r  parse_ohlcvoxfun.parse_ohlcv  so     eZ0UF+UF+UE*UG,U$45
 	
r  c                 D  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      I Sh  vN nU R	                  US0 5      nU R                  US5      nU R                  XtS   U5      $  N N@7f)a   
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.ox.fun/?json#get-v3-depth

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return(default 5, max 100)
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr/  r  levelr  r  rD  )r  r9  publicGetV3Depthr  r  rd  parse_order_book)	r  rD  r   r&  r9  r  r|  r  r  s	            r  fetch_order_bookoxfun.fetch_order_book  s      !!!V$&,
 $G..t{{7/KLL2 ~~h3%%dO<	$$T(+;YGGE 	" Ms"   B BAB B?B B c                    #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      I Sh  vN nU R                  US/ 5      nU R	                  XA5      $  NR N*7f)aR  
fetch the current funding rates for multiple markets

https://docs.ox.fun/?json#get-v3-funding-estimates

:param str[] symbols: unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr  )r  r  publicGetV3FundingEstimatesr#  parse_funding_ratesr  r  r&  r|  r  s        r  fetch_funding_ratesoxfun.fetch_funding_rates  si      !!!%%g.99&AA& ~~h3''66- 	"Ar  c                 D  #    U R                  5       I Sh  vN   SU R                  U5      0nU R                  U R                  X25      5      I Sh  vN nU R	                  US/ 5      nU R                  US0 5      nU R                  X`R                  U5      5      $  N NL7f)aG  
fetch the current funding rates for a symbol

https://docs.ox.fun/?json#get-v3-funding-estimates

:param str symbol: unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr/  r  r   )r  	market_idr  r  r#  r  parse_funding_rater9  )r  rD  r&  r  r|  r  firsts          r  fetch_funding_rateoxfun.fetch_funding_rate  s      !!!$..0
 99$++g:VWW~~h3tQ+&&ukk&.ABB 	" Xs"   B B:B BAB B c                 @   U R                  US5      nU R                  U5      nU R                  US5      n0 SU_SUS   _SS _SS _SU R                  S5      _S	S _S
U_SU R	                  U5      _SU R                  US5      _SS _SS _SS _SS _SS _SS _SS _SS _SS 0E$ )Nr/  	fundingAtr^  rD  r  
indexPriceinterestRater   estimatedSettlePricer  r  fundingRateestFundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r2  r9  rd  r  r  rc  )r  r  r9  rD  estFundingRateTimestamps        r  r  oxfun.parse_funding_rate&  s>    !!+|<V$"&"3"3K"M
K
fX&
 
 $	

 D--c2
 #D
 0
 %<=
 4++K9IJ
 
 t
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 	
r  c                 ~  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X&S'   Ub  X6S'   U R                  US5      nUb  XvS'   U R                  US5      nU R	                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#5      $  N N+7f)	aA  
Fetches the history of funding rates

https://docs.ox.fun/?json#get-v3-funding-rates

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
:param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nr/  r  r  r   r  r  r  )r  r9  rd  r  publicGetV3FundingRatesr  r#  parse_funding_rate_histories
r  rD  r  r   r&  r9  r  r  r|  r  s
             r  fetch_funding_rate_history oxfun.fetch_funding_rate_historyF  s      !!!V$&,
 #(K $G!!&'2!&IYYvw/F55dkk'6RSS$ ~~h300uLLA 	" T"   B=B9A8B=B;*B=;B=c                     U R                  US5      nU R                  X25      nUS   nU R                  US5      nUUU R                  US5      UU R	                  U5      S.$ )Nr/  rD  	createdAtr  )r^  rD  r  r  r  )r2  r  rd  rc  r  )r  r^  r9  r:  rD  r  s         r  parse_funding_rate_history oxfun.parse_funding_rate_historyu  sq    $ ##D,7!!(3!%%dK8	++D-@"Y/
 	
r  c                 ~  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X&S'   Ub  X6S'   U R                  US5      nUb  XvS'   U R                  US5      nU R	                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#5      $  N N+7f)	a>  
fetches the history of funding payments

https://docs.ox.fun/?json#get-v3-funding

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
:param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nr/  r  r  r   r  r  r  )r  r9  rd  r  privateGetV3Fundingr  r#  parse_incomes)
r  rD  r  r   r&  r9  r  r  r|  r7  s
             r  fetch_funding_historyoxfun.fetch_funding_history  s      !!!V$&,
 #(K $G!!&'2!&IYYvw/F11$++g2NOO6 &"5!!&%??S 	" Pr  c           	      .   U R                  US5      nU R                  X25      nU R                  US5      nU R                  S5      nU R                  US5      nU R	                  US5      nU R                  US5      n	UUUUU R                  U5      UUU	S.$ )Nr/  paymentrA  r  r  r  )r^  rD  rl  r  r  r  rN  rate)r2  safe_symbolrc  r`  safe_timestampr  )
r  incomer9  r:  rD  rN  rl  r  r  r  s
             r  parse_incomeoxfun.parse_income  s     ##FL9!!(3!!&)4&&t,fd+''<	6"Y/	
 		
r  c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  XAS5      $  NB N+7f)a  
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 self market

https://docs.ox.fun/?json#get-v3-leverage-tiers

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
Nr  r/  )r  publicGetV3LeverageTiersr#  parse_leverage_tiersr  s        r  fetch_leverage_tiersoxfun.fetch_leverage_tiers  s]      !!!66v>>T ~~h3((EEY 	">s   AAAA*AAc                    U R                  US5      nU R                  X25      nU R                  US/ 5      n/ n[        S[	        U5      5       H  nXF   nUR                  U R                  US5      U R                  X25      US   U R                  US5      U R                  US5      U R                  US5      U R                  US	5      US
.5        M     U$ )Nr/  r   r   tierrG  positionFloorpositionCapmaintenanceMarginr   )r  rD  r}  minNotionalmaxNotionalmaintenanceMarginRatemaxLeverager^  )r2  r  r#  r0  r1  r4  rc  r   )r  r^  r9  r:  listOfTiersr   r  r  s           r  parse_market_leverage_tiers!oxfun.parse_market_leverage_tiers!  s    " ##D,7!!(3nnT7B7q#k*+A>DLL((v6**8<"8,#//oF#//mD)-)9)9$@S)T#//jA	 	 , r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X&S'   Ub  X6S'   U R                  US5      nUb  XvS'   U R                  US5      nOUb  U R	                  US5      US'   U R                  U R                  Xd5      5      I Sh  vN nU R                  US	/ 5      n	U R                  XX#5      $  N N+7f)
aY  
get the list of most recent trades for a particular symbol

https://docs.ox.fun/?json#get-v3-exchange-trades

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch(default 24 hours ago)
:param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nr/  r  r  r   r  r  r  r  )	r  r9  rd  r  r  publicGetV3ExchangeTradesr  r#  parse_tradesr  s
             r  fetch_tradesoxfun.fetch_tradesD  s      !!!V$&,
 #(K $G!!&'2!&IYYvw/F!%%1H!IGI77G8TUU" ~~h3  u<<C 	" Vs"   CCBC(C)*CCc                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X%S'   Ub  X5S'   U R                  US5      nUb  XuS'   U R                  US5      nOUb  U R	                  US5      US'   U R                  U R                  XT5      5      I Sh  vN nU R                  US	/ 5      n	U R                  XX#5      $  N N+7f)
a  
fetch all trades made by the user

https://docs.ox.fun/?json#get-v3-trades

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest trade to fetch(default now)
:returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
Nr  r/  r  r   r  r  r  r  )	r  r9  rd  r  r  privateGetV3Tradesr  r#  r  )
r  rD  r  r   r&  r  r9  r  r|  r7  s
             r  fetch_my_tradesoxfun.fetch_my_tradest  s      !!![[(F$*4LGL!#(K $G!!&'2!&IYYvw/F!%%1H!IGI00W1MNN. &"5  >>Q 	"  O"   CCBC0C1*CCc                     U R                  US5      nU R                  X25      nUS   nU R                  US5      nU R                  US5      U R                  U R                  US5      5      S.nU R	                  U R                  US5      UU R                  U5      US U R                  US5      U R                  US	5      U R                  US
S5      U R                  US5      U R                  USS5      S UUS.U5      $ )Nr/  rD  	matchedAtrm  feeAssetrS  r}  matchIdorderIdside	matchTypeorderMatchType
matchPricematchQuantitymatchedQuantity)r  r  r  rD  r@  orderr&  takerOrMakerrO  rN  rS  rm  r^  )	r2  r  rd  r`  
safe_trader  ra  safe_string_lower_2safe_string_2)r  trader9  r:  rD  r  rm  s          r  parse_tradeoxfun.parse_trade  s   @ ##E<8!!(3!%%e[9	$$UE2//0@0@
0ST
 ""5)4"Y/%%eY7**5&9 44UKIYZ%%e\:((ARS 
  	r  c                 f  #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nUS   nU R                  US5      nUb;  [	        S[        U5      5       H"  nX6   nU R                  US5      nX:X  d  M   Un  O   U R                  U5      $  N N7f)a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://docs.ox.fun/?json#get-v3-balances

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.asset]: currency id, if empty the exchange returns info about all currencies
:param str [params.subAcc]: Name of sub account. If no subAcc is given, then the response contains only the account linked to the API-Key.
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nr  r   subAccr  )r  privateGetV3Balancesr#  r2  r0  r1  parse_balance)	r  r&  r|  r  balancer5  r8  br  s	            r  fetch_balanceoxfun.fetch_balance  s      !!!226::< ~~h3q'!!&(31c$i(G''62>G ) !!'**S 	":s&   B1B-B1B/A"B1B1/B1c                 ~   SU0nU R                  US/ 5      n[        S[        U5      5       H}  nX4   nU R                  US5      nU R	                  U5      nU R                  5       nU R                  US5      US'   U R                  US5      US'   U R                  US5      US	'   XU'   M     U R                  U5      $ )
Nr^  balancesr   rj  total	availablefreereservedused)r#  r0  r1  r2  r`  accountsafe_balance)	r  r8  r7  r=  r8  balanceEntry
currencyIdrl  rC  s	            r  r7  oxfun.parse_balance  s    2 G
 >>':r:q#h-(A#;L)),@J**:6DllnG#//gFGG"..|[IGFO"..|ZHGFO"4L )   ((r  c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  X15      $  NA N*7f)a+  
fetch subaccounts associated with a profile

https://docs.ox.fun/?json#get-v3-account-names

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
Nr  )r  privateGetV3AccountNamesr#  parse_accounts)r  r&  r|  r  s       r  fetch_accountsoxfun.fetch_accounts@  sY      !!!66v>> ~~h3""400! 	">s   AAAA)AAc                 0    U R                  US5      S S US.$ )N	accountId)r  r@  rl  r^  r2  )r  rC  s     r  parse_accountoxfun.parse_account[  s'     ""7K8	
 	
r  rl  rN  fromAccount	toAccountc                 .  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      UUS.nU R                  U R	                  Xu5      5      I Sh  vN nU R                  US0 5      n	U R                  X5      $  Nz N*7f)a  
transfer currency internally between wallets on the same account

https://docs.ox.fun/?json#post-v3-transfer

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: account id to transfer from
:param str toAccount: account id to transfer to
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr  )rj  quantityrR  rS  r  )r  r}  currency_to_precisionprivatePostV3Transferr  r  parse_transfer)
r  rl  rN  rR  rS  r&  r}  r  r|  r  s
             r  r   oxfun.transferi  s      !!!==&d^224@&"	
 33DKK4PQQ$ ~~h3""4227 	" Rs"   BBAB(B))BBc                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X%S'   Ub  X5S'   U R                  US5      nUb  XuS'   U R                  US5      nOUb  U R	                  US5      US'   U R                  U R                  XT5      5      I Sh  vN nU R                  US	/ 5      n	U R                  XX#5      $  N N+7f)
aj  
fetch a history of internal transfers made on an account

https://docs.ox.fun/?json#get-v3-transfer

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
:param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch transfers for(default time now)
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr  rj  r  r   r  r  r  r  )	r  r}  rd  r  r  privateGetV3Transferr  r#  parse_transfers)
r  rl  r  r   r&  r  r}  r  r|  r  s
             r  fetch_transfersoxfun.fetch_transfers  s      !!!!}}T*H'~GG#(K $G!!&'2!&IYYvw/F!%%1H!IGI224;;w3OPP$ ~~h3##DEAAG 	"  Qr  r}  c                 \   U R                  US5      nU R                  US5      nU R                  US5      UU R                  U5      U R                  XB5      U R	                  US5      U R                  US5      U R                  US5      U R                  U R                  US5      5      US.	$ )	NtransferredAtrj  r  rU  rR  rS  status)	r  r  r  r}  rN  rR  rS  ra  r^  )rd  r2  r  r`  rc  parse_transfer_status)r  r   r}  r  rF  s        r  rX  oxfun.parse_transfer  s     %%h@	%%h8
""8T2"Y///
E&&x<++HmD))(K@001A1A(H1UV

 
	
r  c                 .    SS0nU R                  X!U5      $ N	COMPLETEDokrO  r  ra  statusess      r  rb  oxfun.parse_transfer_status  #    
 &99r  c                   #    U R                  US5      nU R                  X15      nUc  [        U R                  S-   5      eU R	                  5       I Sh  vN   U R                  U5      nUS   US.nU R                  US5      nU R                  U R                  Xb5      5      I Sh  vN nU R                  US0 5      nU R                  X5      $  N{ N*7f)a  
fetch the deposit address for a currency associated with self account

https://docs.ox.fun/?json#get-v3-deposit-addresses

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network]: network for fetch deposit address
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
ro  Nz0 fetchDepositAddress() require network parameterr  )rj  ro  r  )r2  network_code_to_idr%   r  r  r}  r  privateGetV3DepositAddressesr  r  parse_deposit_address)	r  rl  r&  r  r  r}  r  r|  r  s	            r  fetch_deposit_addressoxfun.fetch_deposit_address  s      &&vy9++K>	TWW'YYZZ!!!==&d^ 
 69-::4;;w;WXX ~~h3))$99 	" Ys%   ACCAC'C()CCc                 ^    U R                  US5      nU R                  U5        UUS   S US S.$ )Naddressrl  )r^  r}  ro  rs  tag)r2  check_address)r  depositAddressr}  rs  s       r  ro  oxfun.parse_deposit_address  sB     "">9=7#" (
 	
r  c                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X%S'   Ub  X5S'   U R                  US5      nUb  XuS'   U R                  US5      nU R	                  U R                  XT5      5      I Sh  vN nU R                  US/ 5      n	[        S	[        U	5      5       H
  n
S
X   S'   M     U R                  XX#5      $  N NN7f)aV  
fetch all deposits made to an account

https://docs.ox.fun/?json#get-v3-deposit

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
:param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch transfers for(default time now)
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr  rj  r  r   r  r  r  r   rQ   r@  )
r  r}  rd  r  privateGetV3Depositr  r#  r0  r1  parse_transactionsr  rl  r  r   r&  r  r}  r  r|  r  r8  s              r  fetch_depositsoxfun.fetch_deposits  s      !!!!}}T*H'~GG#(K $G!!&'2!&IYYvw/F11$++g2NOO$ ~~h3q#d)$A'DGFO %&&tuDDG 	" P#   C(C$B C(C&AC(&C(c                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X%S'   Ub  X5S'   U R                  US5      nUb  XuS'   U R                  US5      nU R	                  U R                  XT5      5      I Sh  vN nU R                  US/ 5      n	[        S	[        U	5      5       H
  n
S
X   S'   M     U R                  XX#5      $  N NN7f)ad  
fetch all withdrawals made from an account

https://docs.ox.fun/?json#get-v3-withdrawal

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
:param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch transfers for(default time now)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr  rj  r  r   r  r  r  r   
withdrawalr@  )
r  r}  rd  r  privateGetV3Withdrawalr  r#  r0  r1  rz  r{  s              r  fetch_withdrawalsoxfun.fetch_withdrawalsF  s      !!!!}}T*H'~GG#(K $G!!&'2!&IYYvw/F44T[[5QRR( ~~h3q#d)$A*DGFO %&&tuDDK 	" Sr~  c                    / n[        S[        U5      5       H>  nU R                  X   U5      X'   U R                  X   U5      nUR	                  U5        M@     U R                  US5      nUb  US   OS n	U R                  XiX45      $ )Nr   r  rl  )r0  r1  r  parse_transactionr4  sort_byfilter_by_currency_since_limit)
r  transactionsr}  r  r   r&  r7  r8  transactionrl  s
             r  rz  oxfun.parse_transactionsz  s    q#l+,A"kk,/6BLO00(KKMM+& - fk2$,$8xt226NNr  c                 &   U R                  US5      nU R                  US5      nU R                  US5      nS nS nS nUS:X  a4  U R                  US5      nU R                  U R                  US5      5      nO9US:X  a3  U R                  US5      nU R                  U R                  US5      5      nU R                  US5      nU R                  US5      n	U R	                  X5      n
U R                  US	5      nU R                  U5      nU R                  US
S5      nU R                  US5      nU R                  US5      nS nUb  UU
S.n0 SU_SU_SU_SU_SU R                  U5      _S	U_SU_SU_SS _SS _SS _SS _SU_SU_SU
_SU_SS _S S US.E$ )Nr  r@  rQ   rs  ra  r  txIdrj  ro  
creditedAtrequestedAtrU  rm  r#  r^  txidr  r  	addressToaddressFromrt  tagTotagFromrN  r}  updated)internalcommentrm  )	r2  r  parse_deposit_statusparse_withdrawal_statusr`  rv  safe_integer_2rc  r  )r  r  r}  r  r@  rs  r  ra  r  rF  rl  ro  r  r  rN  feeCostrm  s                    r  r  oxfun.parse_transaction  sH   R k40V4iiV4	9&&{I>G..t/?/?X/VWF\!((i@I11$2B2B;PX2YZFV4%%k7;
&&z<"";	:--g6''\=Q	!!+z:"";6 C
K
"
 D
 	

 Y/
 {
 w
 
 4
 4
 T
 t
 D
 f
 
  f!
" t#
$ )
 	
r  c                 .    SS0nU R                  X!U5      $ re  rO  rh  s      r  r  oxfun.parse_deposit_status  rk  r  c                 :    SSSSSSSS.nU R                  X!U5      $ )Nrg  pendingcanceledfailed)rf  
PROCESSINGzIN SWEEPINGPENDINGzON HOLDCANCELEDFAILEDrO  rh  s      r  r  oxfun.parse_withdrawal_status  s3    #$  "
 &99r  rs  rt  c                   #    U R                  XE5      u  pEU R                  5       I Sh  vN   U R                  U5      nU R                  X5      nUS   UUS.nUb  XHS'   Sn	U R	                  U5      u  pU	b  U R                  U	5      US'   SUS'   U R                  U R                  X5      5      I Sh  vN n
U R                  U
S0 5      nS	US
'   U R                  X5      $  N N/7f)a  
       make a withdrawal

       https://docs.ox.fun/?json#post-v3-withdrawal

       :param str code: unified currency code
       :param float amount: the amount to withdraw
       :param str address: the address to withdraw to
       :param str tag:
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param str [params.network]: network for withdraw
       :param bool [params.externalFee]: if False, then the fee is taken from the quantity, also with the burn fee for asset SOLO

EXCHANGE SPECIFIC PARAMETERS
       :param str [params.tfaType]: GOOGLE, or AUTHY_SECRET, or YUBIKEY, for 2FA
       :param str [params.code]: 2FA code
       :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
       Nr  )rj  rs  rU  memoro  FexternalFeer  r  r@  )
handle_withdraw_tag_and_paramsr  r}  rV  handle_network_code_and_paramsrm  privatePostV3Withdrawalr  r  r  )r  rl  rN  rs  rt  r&  r}  stringAmountr  r  r|  r  s               r  r   oxfun.withdraw  s     & 99#F!!!==&11$?d^$

 ?!FO"AA&I"!%!8!8!EGI!&55dkk'6RSS" ~~h3#V%%d55E 	" Ts"   'C&C"B
C&4C$5.C&$C&c                 j  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      I Sh  vN nU R                  US/ 5      n/ n[	        S[        U5      5       H+  nXF   nU R                  US/ 5      nU R                  XX5      nM-     U R                  XQ5      $  N Np7f)aO  
fetch all open positions

https://docs.ox.fun/?json#get-v3-positions

:param str[]|None symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.subAcc]:
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr  r   	positions)r  r  privateGetV3Positionsr#  r0  r1  r$  parse_positions)	r  r  r&  r|  r  allPositionsr8  rC  r  s	            r  fetch_positionsoxfun.fetch_positions(  s      !!!%%g.33F;;X ~~h3q#d)$AgGwR@I,,\EL % ##L::i 	";s"   B3B/)B3 B1A/B31B3c                    U R                  US5      nU R                  X25      nU R                  0 SU_SS _SUS   _SS _SS_SU R                  US	5      _S
U R                  US
5      _SU R                  US5      _SS _SS _SU R                  US5      _SS _SU R                  US5      _SS _SS _SS _SS _S U R	                  US5      S S S S S S S S S S.E5      $ )Nr/  r^  r  rD  notionalr   crossliquidationPriceestLiquidationPrice
entryPriceunrealizedPnlpositionPnlrealizedPnlr   	contractspositionrU  r  	lastPricer&  r   r  r  )r  lastUpdateTimestampr  maintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager   marginRatior   r   )r2  r  safe_positionrc  rd  )r  r  r9  r:  s       r  parse_positionoxfun.parse_positionl  s    ##Hl;!!(3!! #
H#
$#
 fX&#
 	#

 '#
  0 0;P Q#
 $**8\B#
 T--hF#
 4#
 $#
 ))(J?#
 D#
 ))(K@#
 #
 D#
  d!#
" ##
$ #'#4#4X#O!%+/!'+!#9#
  	r  r@  r&  rO  c                   #    U R                  5       I Sh  vN   U R                  USS5      U R                  USU R                  5       5      S.nU R	                  USS/5      nU R                  US5      nUb  XS'   U R	                  US5      nU R                  XX4XV5      n	U	/US'   U R                  U5      I Sh  vN n
U R                  U
S/ 5      nU R                  US	0 5      nU R                  U5      $  N N=7f)
a  
create a trade order

https://docs.ox.fun/?json#post-v3-orders-place

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.clientOrderId]: a unique id for the order
: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.
: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.
:param str [params.responseType]: FULL or ACK
:param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
:param float [params.limitPrice]: Limit price for the STOP_LIMIT order
:param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
:param str [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)
:param str [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}
:param str [params.displayQuantity]: for an iceberg order, pass both quantity and displayQuantity fields in the order request
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NresponseTypeFULLr  )r  r  
recvWindowordersr  r   )
r  r2  rd  millisecondsr  create_order_requestprivatePostV3OrdersPlacer#  r  parse_order)r  rD  r@  r&  rN  rO  r&  r  r  orderRequestr|  r  r,  s                r  create_orderoxfun.create_order  s    2 !!! ,,V^VL**6;@Q@Q@ST
 6NK#@A&&v|<
!$.L!YYv|4F00tU[)N66w??j ~~h3tQ+&&G 	" @s"   C<C8B%C<<C:=<C<:C<r  c           	      j  #    U R                  5       I Sh  vN   / n[        S[        U5      5       H  nX   nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  US5      n	U R	                  US5      n
U R                  US0 5      nU R                  XgXX5      nUR                  U5        M     S	U R                  5       US
.nU R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nU R                  U5      $  GN N+7f)a  
create a list of trade orders

https://docs.ox.fun/?json#post-v3-orders-place

: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
:param dict [params]: extra parameters specific to the exchange API endpoint
: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.
: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.
:param str [params.responseType]: *for all orders* FULL or ACK
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   rD  r@  r&  rN  rO  r&  r  )r  r  r  r  )r  r0  r1  r2  rc  r  r  r4  r  r  r  r#  parse_orders)r  r  r&  ordersRequestsr8  rawOrderrD  r@  r&  rN  rO  orderParamsr  r  r|  r  s                   r  create_ordersoxfun.create_orders9	  s0     !!!q#f+&AyH%%h9F##Hf5D##Hf5D%%h9F$$Xw7E..8R@K44V4QVdL!!,/ ' #**,$

 66t{{77STT~~h3  &&' 	"" Us"   D3D.C.D3D1)D31D3c                    U R                  U5      nUS   UR                  5       SS.nU R                  USS5      n	U	b  XS'   U R                  USS/5      nOXHS'   U R                  USS	5      n
UR                  5       nU
b)  US
:X  a  SnOUS:X  a  SnXS	'   U R                  USS	/5      nXS'   US:X  a  XXS'   OUb  XXS'   SnUS
:H  =(       d    US:H  nU R	                  USU5      u  pU R                  US5      nU(       a  US:w  a  SUS'   SnU R                  USS5      u  pUb  UR                  5       US'   U R                  X5      $ )ai  
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market', 'limit', 'STOP_LIMIT' or 'STOP_MARKET'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.clientOrderId]: a unique id for the order
:param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
:param float [params.limitPrice]: Limit price for the STOP_LIMIT order
:param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
:param str [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)
:param str [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}
:param str [params.displayQuantity]: for an iceberg order, pass both quantity and displayQuantity fields in the order request
r  i  )r/  r&  sourcerS  rN  NrU  r   	stopPriceMARKETSTOP_MARKETLIMIT
STOP_LIMIT	orderType
limitPricerO  Fr   MAKER_ONLY_REPRICE
MAKER_ONLYrJ   r   selfTradePreventionMode)r9  upperr0  r  handle_post_onlysafe_string_upperhandle_option_and_paramsr  )r  rD  r@  r&  rN  rO  r&  r9  r  rS  r   r  postOnlyisMarketOrderr   r   s                   r  r  oxfun.create_order_request[	  s   " V$ ,JJL

 !!&&(; $HYYv'9:F"(J))&.+NJJL	#H$)	g%(	#/K YYv'DEF($$)L!$G"h.OI4N00vN,,V]C(<<%1GM""&*&C&CFM[p&q#*1D1J1J1LG-.{{7++r  rS  c                 
  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSU0nU R	                  USSSSU R                  XS5      5      I Sh  vN $  Nh N7f)a  
create a market buy order by providing the symbol and cost

https://open.big.one/docs/spot_orders.html#create-order

:param str symbol: unified symbol of the market to create an order in
:param float cost: how much you want to trade in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr;   z9 createMarketBuyOrderWithCost() supports spot orders onlyrS  r9  buy)r  r9  r+   r  r  r  )r  rD  rS  r&  r9  r  s         r  !create_market_buy_order_with_cost'oxfun.create_market_buy_order_with_cost	  s      !!!V$f~tww)ddeeD
 &&vxdDKKX_Lhiii 	" js"   BA?A#B:B;BBr  c                    #    U R                  5       I Sh  vN   SU0nU R                  U R                  XC5      5      I Sh  vN nU R                  US0 5      nU R	                  U5      $  NT N*7f)a  

https://docs.ox.fun/?json#get-v3-orders-status

fetches information on an order made by the user
:param str id: a unique id for the order
:param str [symbol]: not used by oxfun fetchOrder
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.clientOrderId]: the client order id of the order
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr%  r  )r  privateGetV3OrdersStatusr  r  r  )r  r  rD  r&  r  r|  r  s          r  fetch_orderoxfun.fetch_order	  ss      !!!r
 66t{{77STT0 ~~h3%%; 	" Us!   A/A++A/A-)A/-A/c                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nU R                  U R                  XT5      5      I Sh  vN nU R	                  US/ 5      nU R                  XX#5      $  Ni N+7f)a=  
fetch all unfilled currently open orders

https://docs.ox.fun/?json#get-v3-orders-working

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of  open orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.orderId]: a unique id for the order
:param int [params.clientOrderId]: the client order id of the order
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  )r  r9  privateGetV3OrdersWorkingr  r#  r  )	r  rD  r  r   r&  r  r9  r|  r  s	            r  fetch_open_ordersoxfun.fetch_open_orders	  s      !!![[(F77G8TUU~~h3  u<< 	"
 Vs!   BB ?BB*BBc                   #    Uc  [        U R                  S-   5      eU R                  U5      nUS   nU R                  5       SS.nUUS.nU R	                  US5      nUb  XS'   U/US'   U R                  U R                  Xc5      5      I Sh  vN n	U R                  U	S	/ 5      n
U R                  U
S
0 5      nU R                  U5      $  N;7f)a  
cancels an open order

https://docs.ox.fun/?json#delete-v3-orders-cancel

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.clientOrderId]: a unique id for the order
:param int [params.timestamp]: in milliseconds
:param int [params.recvWindow]: in milliseconds
:param str [params.responseType]: 'FULL' or 'ACK'
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz) cancelOrder() requires a symbol argumentr  r  r  r  r/  r%  clientOrderIdr  r  r   )
r$   r  r9  r  rd  privateDeleteV3OrdersCancelr  r#  r  r  )r  r  rD  r&  r9  r:  r  r  r   r|  r  r,  s               r  cancel_orderoxfun.cancel_order	  s      >#DGG.Y$YZZV$$<**,"

 #
 ))&/B$,9))N99$++g:VWW~~h3tQ+&& Xs   BCC
<Cc                    #    0 nUb  U R                  U5      nUS   US'   U R                  U R                  X25      5      I Sh  vN nU R                  SU05      /$  N7f)a<  
cancel all open orders

https://docs.ox.fun/?json#delete-v3-orders-cancel-all

:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from exchange
Nr  r/  r^  )r9  privateDeleteV3OrdersCancelAllr  
safe_order)r  rD  r&  r  r9  r|  s         r  cancel_all_ordersoxfun.cancel_all_orders
  si      [[(F$*4LGL! <<T[[=YZZ 2344 [s   AAAAidsc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   nU R	                  5       SS.n/ n[        S[        U5      5       H  nUX   S.n	UR                  U	5        M     XvS'   U R                  U R                  Xc5      5      I Sh  vN n
U R                  U
S	/ 5      nU R                  X5      $  N N*7f)
a  
cancel multiple orders

https://docs.ox.fun/?json#delete-v3-orders-cancel

:param str[] ids: order ids
:param str [symbol]: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.timestamp]: in milliseconds
:param int [params.recvWindow]: in milliseconds
:param str [params.responseType]: 'FULL' or 'ACK'
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz* cancelOrders() requires a symbol argumentr  r  r  r   r  r  r  )r$   r  r  r9  r  r0  r1  r4  r  r  r#  r  )r  r	  rD  r&  r9  r:  r  r  r8  r,  r|  r  s               r  cancel_ordersoxfun.cancel_orders(
  s      >#DGG.Z$Z[[!!!V$$<**,"
 q#c(#A&6E MM%  $ #99$++g:VWW~~h3  ..# 	" Xs"   /C)C%B
C)<C'=)C)'C)c           
         U R                  US5      nU R                  X25      nU R                  US5      nS nU R                  US5      nUb$  U R                  U5      U R	                  US5      S.nU R                  US5      nU R                  US5      nUb  SnU R                  US	5      n	U R                  0 S
U R                  US5      _SU R                  US5      _SU_SU R                  U5      _SU R                  US5      _SU R                  US5      _SU R                  U5      _SUS   _SU R                  U R                  US5      5      _SU R                  U R                  US5      5      _SU R                  US5      _SU R                  U/ SQ5      _SS _SU R                  USS5      _SU R                  USS 5      _S!U R                  US"5      _S#U	_U	U R                  U R                  US5      5      S UUS$.EU5      $ )%Nr/  r  feeInstrumentIdr   )r}  rS  ra  rl  rejectedr  r  r%  r   r  r  lastTradeTimestamplastMatchedAtr  lastModifiedAtrD  r@  r  r   r&  rO  )rO  r)  r  r  rN  totalQuantityrU  filledcumulativeMatchedQuantityr*  	remainingremainQuantityr   )r   rS  tradesrm  r^  )r2  r  rd  r`  rc  r  r  parse_order_statusparse_order_typeparse_order_time_in_forcera  safe_string_nr0  	omit_zero)
r  r,  r9  r:  r  rm  feeCurrencyra  rl  r   s
             r  r  oxfun.parse_orderK
  s   ` ##E<8!!(3%%e[9	&&u.?@" 33K@((7C !!%2  /F''{;  
$""5)4 
T--e_E 
  
 Y/	 

 !$"3"3E?"K 
 "4#4#4U<L#M 
 d--f5 
 fX& 
 D))$*:*:5+*NO 
 499$:J:J5R_:`a 
 D**5&9 
 T''/TU 
 t 
 d((L 
 d((0K_] 
  ))%1AB! 
" L# 
$ *NN4#3#3E8#DE- 
. / 	r  c                 B    SSSSSSSSSSSS.nU R                  X!U5      $ )Nr  closedr  r  )OPENPARTIALLY_FILLEDPARTIAL_FILLFILLEDr  CANCELED_BY_USERCANCELED_BY_MAKER_ONLYCANCELED_BY_FOKCANCELED_ALL_BY_IOCCANCELED_PARTIAL_BY_IOC!CANCELED_BY_SELF_TRADE_PROTECTIONrO  rh  s      r  r  oxfun.parse_order_status
  s?     &"" *&0)#-'11;
 &99r  c                 4    SSSSS.nU R                  X!U5      $ )Nr   r9  )r  r  r  r  rO  r  r@  typess      r  r  oxfun.parse_order_type
  s*    !#	
 T22r  c                 6    SSSSSS.nU R                  X!U5      $ )NGTCr   r   r   )r2  r   r   r  r  rO  r.  s      r  r  oxfun.parse_order_time_in_force
  s-    "&
 T22r  r   GETc                    U R                   S   U   nUS-   U-   nSn	US:X  a(  U R                  U5      n	[        U	5      S:w  a  USU	-   -  nUS:X  Ga  U R                  5         U R	                  5       n
U R                  U
5      nUR                  S5      nUS   nU R                  5       nUR                  S	5      nUS
:X  d  US:X  a  U R                  U5      nUn	US-   [        U5      -   S-   U-   S-   US   -   S-   U-   S-   U	-   nU R                  U R                  U5      U R                  U R                  5      [        R                  S5      nSU R                  UU[        U5      S.nXXeS.$ )Nr   r?  r=  r4  r   ?r   rk  z//POSTDELETE
r   z
/base64zapplication/json)zContent-Type	AccessKey	Timestamp	SignatureNonce)urlmethodbodyheaders)r  	urlencoder1  check_required_credentialsr  r  r_  noncejsonstrhmacencodesecrethashlibsha256apiKey)r  pathr   r@  r&  rB  rA  baseUrlr?  queryStringr  isoDatetimedatetimePartsr  rE  urlParts	msgString	signatures                     r  sign
oxfun.sign  s~   ))E"3'md"U?..0K;1$s[(()++-))+I,,y1K'--c2M$Q'HJJLE}}T*H& f&8yy(" 4#e*4t;fDtKhWXkY\aadhhkoor}}I		$++i"8$++dkk:RT[TbTbdlmI 2![[%&UG dOOr  c
                     Uc  g US:w  an  U R                  USS 5      n
U R                  S-   U-   nU R                  U R                  S   Xk5        U R	                  U R                  S   X5        [        U5      eg )N   rl   r  r  )r2  r  throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr!   )r  rl  reasonr?  r@  rB  rA  r|  requestHeadersrequestBodyresponseCodefeedbacks               r  handle_errorsoxfun.handle_errors$  sx    3;++HfdCLww}t+H001I4Z001I<b))r   )N)]__name__
__module____qualname____firstlineno__r   r  r    r   r,  r%  r5  r	   r  r   r   r  rG  r   r  r  r   ry  r  r  r   r  r   r  r   r  r  r   r  r  r  r  r   r  r   r  r   r  r  r2  r   r:  r7  r   rK  rP  floatr   r   r]  r
   rX  rb  r   rp  ro  r   r|  r  rz  r  r  r  r   r   r  r  r   r   r   r   r  r   r  r  r  r  r  r  r  r  r  r  r  r  rV  rb  __static_attributes____classcell__)r  s   @r  r2   r2      sN   s# sj *, Z+V Z+x	V 	Ff FP -/ T: Tl 6:" =47 =4 =4~ 68 &1 &1F &1P+6 +V +Z ?CQUdhqs <J <J <J3 <J^a <Jx|  ~B  yC <J|
 
4 
* @DB -HS -H -HS\ -H^ <@  7  7|  7D <> Cs C+ C(
f 
 
@ >BPTcgpr -Ms -M# -M]` -M^
v 
< 9=4^bkm 6@# 6@S 6@X[ 6@p
6 
< =A 6F' 6FP] 6Fp! !$|J\ !F <@d[] .= .=S .= .=bfglbm .=` 37TX\eg 5?C 5?s 5?RU 5?n6 65 6p *, 4+ 4+l%) %)N +- 1g 16
 ac )33 )3 )3C )3TW )3gt )3V 154VZce 1B# 1BS 1BPS 1Bf
 
8: =? : :> ::
h 
R` 
 04$UYbd 0E 0EC 0Es 0Eimnyiz 0Ed 37TX\eg 2EC 2Es 2ERU 2Elpq|l} 2Eh EIW[jnwy O OQT Odg O  C  DO  P OX
x X
; X
t:
: QU]_ 663 66 66 66# 66do 66p 8<B B;W B;4PX> B;H-v -^ mqy{ \' \'I \'Y \'X] \'fi \'  AF \'| FH  '$|*<  'DQVK  'D UYac 5,3 5,c 5, 5,n XZ jc j j( 8<B )&C )& )&5 )&V 59tZ^gi =c = =TW =nrsxny =. 9=R "'S "'# "'H 59 5c 58 AER !/tCy !/# !/FV V5 Vp: 33 &eBSW P<	 	r  r2   )7 ccxt.async_support.base.exchanger   ccxt.abstract.oxfunr   r  rK  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr    ccxt.base.errorsr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   ccxt.base.decimal_to_precisionr0   r2   rd  r  r  <module>rr     s    6 +   k  k  k  k  k  k  k  k  * 0 . . ' & ) . ) * ) , ) . + 4O,Hk O,r  