
    E#i                    $   S SK Jr  S SKJ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  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\\5      r+g)    )Exchange)ImplicitAPI)AnyBalances
CurrenciesCurrencyIntLedgerEntryLeverageMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsFundingRateFundingRatesTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)NotSupported)NetworkError)RateLimitExceeded)	TICK_SIZE)Precisec                   |  ^  \ rS rSrS\4U 4S jjrS\4U 4S jjr0 4S jr0 4S\	4S jjr
S\S\4S	 jr0 4S\\   4S
 jjr0 4S\4S jjrS rShS\S\S\4S jjrSS0 4S\S\	S\	S\\   4S jjrShS\S\4S jjrS r0 4S\S\4S jjr0 4S\S\4S jjrS0 4S\S\4S jjrSSS0 4S\S\	S\	4S jjr ShS\4S jjr!SSS0 4S\S\	S\	4S jjr"0 4S\#4S jjr$S0 4S\S\	S\%4S jjr&ShS\S\'4S jjr(S SS0 4S\S!\S\	S\	S\\'   4
S" jjr)ShS#\S\S\*4S$ jjr+S%\4S& jr,S'\4S( jr-S)\4S* jr.S0 4S\S)\/S+\0S,\1S-\24
S. jjr3S0 4S\S)\/S+\0S,\1S-\24
S/ jjr40 4S0\\5   4S1 jjr6SS0 4S2\S\S)\/S+\0S,\2S-\24S3 jjr7S0 4S2\S\4S4 jjr8S0 4S5\\   S\4S6 jjr9S0 4S\4S7 jjr:S0 4S2\S\4S8 jjr;SSS0 4S\S\	S\	S\\*   4S9 jjr<SSS0 4S\S\	S\	S\\*   4S: jjr=SSS0 4S\S\	S\	S\\*   4S; jjr>SSS0 4S2\S\S\	S\	4S< jjr?SSS0 4S\S\	S\	4S= jjr@S\A4S> jrB0 4S\A4S? jjrCSSS0 4S@\S\	S\	S\4SA jjrDShSB\SC\ES\F4SD jjrGSE rHSSS0 4S@\S\	S\	S\\F   4SF jjrIShSG\SC\ES\J4SH jjrKS'\4SI jrLSSS0 4S@\S\	S\	S\\J   4SJ jjrMSSS0 4S@\S\	S\	S\\J   4SK jjrNSSS0 4S@\S\	S\	S\\J   4SL jjrO0 4SM jrPSN rQSO rRSP rSS0 4S@\S,\1SQ\SR\S\J4
SS jjrTShS\U4ST jjrV0 4S\S\U4SU jjrWS0 4SV\XS\4SW jjrYShSX\S\4SY jjrZ0 4S\4SZ jjr[S0 4S\S\\\   4S[ jjr]S\ r^S]S^0 SS4S_ jr_S`\XSa\Sb\Sc\Sd\Se\4Sf jr`SgraU =rb$ )iwoofipro   returnc                   > U R                  [        [        U ]  5       0 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_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_S0S_S1S_S2S_S3S_S4S_E0 S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_SCS_SDS_SES_E0 SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_SUS_SVS_ESSSSSSSWSSSSSSSSSX.E_SYSZS[S\S]S^S_S`SaSbScSdSe._SfSgShShSi.SjSjSi.SkSl/Sm/SnSoSp.Sq._SrS
0 SsSt_SuSt_SvSt_SwSt_SxSt_SySt_SzSt_S{St_S|St_S}St_S~St_SSt_SSt_SSt_SSt_SS_SS_0 SS_SS_SS_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_EStStStStSStStStStStStStS.ESSt0S.0 SS_SS_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SSt_SS_SSt_SSt_SSt_0 SSt_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSt_SSt_E0 SSt_SS_SS_SSt_SS_SSt_SSt_SSt_SSt_SSt_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSS.EStStS.StStStStStStStStS.S.Si.0_SSSSSS._SSSSU R	                  S5      U R	                  S5      S.0_SSSSS._SSSSS SSSS SSSSS.SSSSSSSS.SS0SSS SSS.SSSSS.SSSSSS.S SSS S SSSSS.SS0S.	SS0SS S SS.S.S.SS0S S.S S S.S._0 0 S[
        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _GS [        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _[        [        [        [        [        [        [        GS.E0 GS.[        GS	.E5      $ (
  Nidr(   namez	WOOFI PRO	countriesKY	rateLimitd   versionv1	certifiedTprodexhostnamezdex.woo.orghasCORSspotFmarginswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscancelWithdrawcloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLosscreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchBalancefetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLedgerfetchLeveragefetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionModefetchPositionsfetchPremiumIndexOHLCVfetchStatusemulated)fetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransfersfetchWithdrawalsreduceMarginsetLeverage	setMarginsetPositionModetransferwithdraw
timeframes1m5m15m30m1h4h12h1d1w1mon1y)r   r   r   r   r   r   r   r   r   1Mr   urlszOhttps://github.com/user-attachments/assets/9ba21b8a-a9c7-4770-b7f1-ce3bcbde68c1zhttps://api-evm.orderly.org)publicprivatez#https://testnet-api-evm.orderly.orgzhttps://dex.woo.orgz9https://orderly.network/docs/build-on-evm/building-on-evmzhttps://dex.woo.org/en/orderlyz%https://dex.woo.org/en/trade?ref=CCXTg?)urldiscount)logoapitestwwwdocfeesreferralr   zpublic/volume/stats   zpublic/broker/namezpublic/chain_info/{broker_id}zpublic/system_infozpublic/vault_balancezpublic/insurancefundzpublic/chain_infozfaucet/usdczpublic/accountget_accountregistration_nonceget_orderly_keyzpublic/liquidationzpublic/liquidated_positionszpublic/configzpublic/campaign/ranking
   zpublic/campaign/statszpublic/campaign/userzpublic/campaign/stats/detailszpublic/campaignszpublic/points/leaderboardzclient/pointszpublic/points/epochzpublic/points/epoch_dateszpublic/referral/check_ref_codezpublic/referral/verify_ref_codezreferral/admin_infozreferral/infozreferral/referee_infozreferral/referee_rebate_summaryzreferral/referee_historyzreferral/referral_historyzreferral/rebate_summaryzclient/distribution_historygQ?)z	tv/configz
tv/historyztv/symbol_infozpublic/funding_rate_historyzpublic/funding_rate/{symbol}zpublic/funding_rateszpublic/infozpublic/info/{symbol}zpublic/market_tradeszpublic/tokenzpublic/futureszpublic/futures/{symbol}register_account)getpostzclient/key_info   z!client/orderly_key_ip_restrictionzorder/{oid}zclient/order/{client_order_id}zalgo/order/{oid}z#algo/client/order/{client_order_id}ordersalgo/ordersztrade/{tid}tradeszorder/{oid}/tradeszclient/liquidator_liquidationsliquidationszasset/history<   zclient/holdingwithdraw_noncesettle_noncezpnl_settlement/historyzvolume/user/dailyzvolume/user/statszclient/statisticszclient/infozclient/statistics/daily	positionsgp=
ף
@zposition/{symbol}zfunding_fee/history   z notification/inbox/notificationsznotification/inbox/unreadzvolume/broker/dailybroker/fee_rate/defaultzbroker/user_infozorderbook/{symbol}klineorderly_keyz%client/set_orderly_key_ip_restrictionz'client/reset_orderly_key_ip_restrictionorderbatch-order
algo/orderliquidationclaim_insurance_fundwithdraw_request
settle_pnlznotification/inbox/mark_readz notification/inbox/mark_read_allzclient/leveragex   zclient/maintenance_configdelegate_signerdelegate_orderly_keydelegate_settle_pnl)delegate_withdraw_requestzbroker/fee_rate/setzbroker/fee_rate/set_defaultr   zreferral/createzreferral/updatezreferral/bindzreferral/edit_split)r   r   )r   r   zclient/orderzalgo/client/orderr   r   r   zclient/batch-order)r   r   putdeleterequiredCredentials)apiKeysecret	accountId
privateKeyr   tradingz0.0002z0.0005)	tierBased
percentagemakertakeroptionsCCXT*0x6F7a338F2aA472838dEFD3283eB360d4Dff5D203)sandboxModebrokerIdverifyingContractAddressfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergmax  i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   r     )	sandboxrL   createOrdersro   rt   rs   rv   r[   rp   extendsdefault)r   price)r   r   )r   rL   forDerivatives)linearinverse)r   r:   r   r<   r=   z-1000z-1001z-1002z-1003z-1004z-1005z-1006z-1007z-1008z-1009z-1011z-1012z-1101z-1102z-1103z-1104z-1105)z-1201z-12022993215)exactbroad)commonCurrencies
exceptionsprecisionMode)deep_extendsuperr(   describeparse_numberr   r   r$   r   r!   r    r#   r%   )self	__class__s    G/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/woofipro.pyr
  woofipro.describe   s   h > @ UC
*UC
KUC
 $UC
 	UC

 tUC
 UC
 4UC
 4UC
 UC
  TTT %T 	T
 %T %T UT "4T tT T !%T $UT  T %eT 'T  /!T" $U#T$ ,U%T& 0'T( t)T* 7+T, (-T. '/T0 &t1T2 (3T4 "55T6 (7T8 ,U9T: -e;T< %d=T>  ?T@ ATB &uCTD #EETF $TGTH )%ITJ $UKTL "4MTN &uOTP  QTR +DSTT &tUTV 'WTX (YTZ #D[T\ *4]T^ $T_T` "5aTb tcTd  eTf /gTh "5iTj kTl !%mTn  oTp dqTr +EsTt !%uTv "4wTx dyTz !${T| t}T~ #DT@  ATB $UCTD !$ETF )%GTH tITJ  % %!##($(%/"'$( %#"#(! gTUC
~ UC
X i;<
 DD -O 5 C $#YUC
D / 11/ 0!/  <Q/  1!	/ 
 3A/  3A/  0/  *1/  -a/  *1/  1!/  .q/  1!/  :1/  ,Q/   6r!/ " 4R#/ $ 3B%/ & <R'/ ( /)/ * 8+/ , ,Q-/ . 21// 0 81/ 2 =a3/ 4 >q5/ 6 217/ 8 ,Q9/ : 4Q;/ < >q=/ > 7?/ @ 8A/ B 6qC/ D :1E/ F *+*+./;<<@45+,4545,-./78]/ b /!c4l" -q" ?"  *1"  =a	" 
 /"  B1"  %a"  *1"  *1"  %a"  1!"  =a"  +A"  ,R"  -a"   -a!" " +A#" $ 5a%" & 0'" ( 0)" * 0+" , *2-" . 6r/" 0 (1" 2 03" 4 225" 6 ?7" 8 89" : 22;" < 6r=" > /?" @ 1!A" B $QC" F!)1!CQ! Fq! $Q	!
 *2! )!! *1! 3A! /! )!! ;B! ?! .s! 8! .r!  3B!!" 22#!$ :<35;=79/1/1-/353!8 &'*+ 
 &'*+,-12+,&'+,23	#GM mDFEUC
R "!#	$SUC
^ !%"&!..x8!..x8	_UC
n $",XoUC
x #&+(,,0,1).+06:#'#'"&#(	( #($($(+027/4#')$. r% ',!$$(%+*/& ',#'$)*/	# ',!$#'$)*/( $(&+!$$(,0%+#'$)*/	*  #u=~ y  ) -1 15%*7$# "#3  $	 ##iXyUC
j !#]0 0 .	
 Z Z \ Z \ . \ Z . \ \  \!" \#$ ('$,,#$147< 'iUC
 U U	    enablec                 H   > [         [        U ]  U5        XR                  S'   g )Nr   )r	  r(   set_sandbox_moder   )r  r  r  s     r  r  woofipro.set_sandbox_mode  s    h.v6&,]#r  c                     U R                  U5      nU R                  US0 5      nU R                  US5      nUc  SnOUS:X  a  SnOSnUSSSUS.$ )	aT  
the latest known information on the availability of the exchange API

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-system-maintenance-status

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
datastatusNerror0okmaintenance)r  updatedetar   info)v1PublicGetPublicSystemInfo	safe_dictsafe_string)r  paramsresponser  r  s        r  fetch_statuswoofipro.fetch_status  sn     33F; ~~h3!!$1>Fs]F"F
 	
r  c                 H    U R                  U5      nU R                  US5      $ )aW  
fetches the current integer timestamp in milliseconds from the exchange server

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-system-maintenance-status

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
	timestamp)r  safe_integer)r  r"  r#  s      r  
fetch_timewoofipro.fetch_time  s)     33F;   ;77r  marketc                    U R                  US5      nUR                  S5      nSnU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US5      n	U R                  U	5      n
US-   U-   S-   U
-   n0 SU_SU_S	U_S
U_SU
_SU_SU_SU	_SU_SS_SS_SS_SS_SS_SS _SS_SS_SU R                  S5      S S S S U R	                  US5      U R	                  US5      S.S S S.U R	                  US5      U R	                  US5      S.U R	                  US 5      U R	                  US!5      S.U R	                  US"5      S S.S#.U R                  US$5      US%.
E$ )&Nsymbol_r<   r      /:r,   basequotesettlebaseIdquoteIdsettleIdtyper:   Fr;   Tr=   r>   activecontractr   1	base_tick
quote_tick)amountr   minr   base_minbase_max	quote_min	quote_maxmin_notional)r   r>  r   costcreated_time)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedr  )r!  splitsafe_currency_coder  safe_numberr(  )r  r+  marketIdparts
marketTyper5  r6  r2  r3  r7  r4  r-  s               r  parse_marketwoofipro.parse_market  sR   8 ##FH5s#
!!%+""5!,&&v.''0((2--h7e#c)F20
(0
f0
 D0
 U	0

 f0
 f0
 w0
 0
 J0
 E0
 e0
 D0
 e0
 e0
 d0
  !0
" d#0
$  --c2"**6;?))&,?  
  ++FJ?++FJ?
  ++FK@++FK@
  ++FNC$ ((@_0
 0	
r  c                     U R                  U5      nU R                  US0 5      nU R                  US/ 5      nU R                  U5      $ )a  
retrieves data on all markets for woofipro

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-available-symbols

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r  rows)v1PublicGetPublicInfor   	safe_listparse_markets)r  r"  r#  r  rY  s        r  fetch_marketswoofipro.fetch_marketsG  sL     --f5H ~~h3~~dFB/!!$''r  c                    0 nU R                  U5      nU R                  U5      nX4/u  pVU R                  US0 5      nU R                  US/ 5      nU R                  US0 5      n	U R                  U	S/ 5      n
U R	                  U
S5      n[        S[        U5      5       GH9  nX   nU R                  US5      nU R                  US5      nU R                  U5      n0 n[        S[        U5      5       H  nUU   nU R                  US5      nU R                  UU5      nU R                  US5      nU R                  UU5      nUUSSS	.SSS	.S
.SSSU R                  US5      U R                  U R                  U R                  US5      5      5      UU/S.	UU'   M     U R                  USUSSSUSSSSS	.U R                  US5      SS	.S.US.5      UU'   GM<     U$ )a  
fetches all available currencies on an exchange

https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/public/get-supported-collateral-info#get-supported-collateral-info
https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/public/get-supported-chains-per-builder#get-supported-chains-per-builder

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
r  rY  chain_idr   tokenchain_detailsr-   Nr?  )r   depositwithdrawal_feedecimals)	r,   networkrN  r9  rc  r   feerM  r  minimum_withdraw_amount)rc  r   )r,   r-   coderM  r9  rg  networksrc  r   rN  r  )v1PublicGetPublicTokenv1PublicGetPublicChainInfor   r[  index_byrangelenr!  rQ  network_id_to_coderR  r  parse_precisionsafe_currency_structure)r  r"  resulttokenPromisechainPromisetokenResponsechainResponse	tokenData	tokenRows	chainData	chainRowsindexedChainsira  
currencyIdrj  ri  resultingNetworksjnetworkEntry	networkId
networkRownetworkNamenetworkCodes                           r  fetch_currencieswoofipro.fetch_currenciesx  s5    226:. 66v>(4'C$NN=&"=	NN9fb9	NN=&"=	NN9fb9	i<q#i.)ALE))%9J~~e_=H**:6D&(1c(m,'{ ,,\:F	!^^M9E
"..z6B"55k4H#* $(#'%
 $(#'$	 ## $++L:JK!%!2!243G3GHXHXYegqHr3s!t):6%2!+. -4  77 !-   $# 
  $//7PQ#!	 )9 F4LA *l r  c                     U R                  X5      nS nUb'  U R                  X5      nU R                  U5      nUUS.nU$ )NrF  currency)r!  rQ  )r  itemfeeTokenKeyfeeAmountKeyfeeCostrg  feeCurrencyIdfeeCurrencyCodes           r  parse_token_and_fee_temp!woofipro.parse_token_and_fee_temp  sQ    ""46 ,,T?M"55mDO+C 
r  Ntradec                 h   SU;   nU R                  US5      nU R                  US5      nU R                  XR5      nUS   nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  USS5      n
U R                  U
S	5      nUb  XS	'   [        R
                  " Xx5      nU R                  US
5      nU R                  US5      nS nU(       a   U R                  US5      S:H  nU(       a  SOSnU R                  UUU R                  U5      UUUUUU	US U
US.U5      $ )Nr,   executed_timestampr-  executed_priceexecuted_quantityorder_id	fee_assetrg  rF  sideis_makerr;  r   r   )r,   r'  datetimer-  r  r   r>  rF  r   takerOrMakerr8  rg  r  )	r(  r!  safe_marketr  r&   
string_mulsafe_string_lower
safe_tradeiso8601)r  r  r+  isFromFetchOrderr'  rS  r-  r   r>  r  rg  r  rF  r  r,   r  isMakers                    r  parse_tradewoofipro.parse_trade  s_   8 !EM%%e-AB	##E84!!(3!  (89!!%)<=##E:6++E;F""3/!K!!%0%%eV4eT* &&uj9S@G&-77L"Y/( 
  	r  r-  sincer   c                    U R                  5         U R                  U5      nSUS   0nUb  X6S'   U R                  U R                  Xd5      5      nU R	                  US0 5      nU R                  US/ 5      n	U R                  XX#5      $ )a  
get the list of most recent trades for a particular symbol

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-market-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
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
r-  r,   r   r  rY  )load_marketsr+  v1PublicGetPublicMarketTradesextendr   r[  parse_trades)
r  r-  r  r   r"  r+  requestr#  r  rY  s
             r  fetch_tradeswoofipro.fetch_trades$  s     	V$fTl
 $G55dkk'6RS  ~~h3~~dFB/  u<<r  c                 v   U R                  US5      nU R                  U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5      n[        R                  " X5      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U_SU R                  U5      _SS _SS _SS _SU R                  US5      _SU_SU R                  U5      _SU R                  U	5      0E$ )Nr-  next_funding_timeest_funding_rate_timestamplast_funding_rate_timestampr  	markPrice
indexPriceinterestRater  estimatedSettlePricer'  r  fundingRateest_funding_ratefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatelast_funding_ratepreviousFundingTimestamppreviousFundingDatetimeinterval)	r!  r+  r(  r&   
string_subr  r  rR  parse_funding_interval)
r  r  r+  r-  r  estFundingRateTimestamplastFundingRateTimestampfundingTimeStringnextFundingTimeStringmillisecondsIntervals
             r  parse_funding_ratewoofipro.parse_funding_rateK  s    !!+x8V$#00>QR"&"3"3KA]"^#'#4#4[B_#`  ,,[:WX $ 0 0>Q R&112G[
K
fX&
 
 $	

 D--c2
 #D
 0
 %<=
 4++K9KL
  4
 t||,@A
 t
 #D
 "4
 "4#3#3KAT#U
  '(@!
" &t||4L'M#
$ 334HI%
 	
r  c                 6    SSSSSS.nU R                  X!U5      $ )Nr   r   8h16h24h)360000014400000288000005760000086400000r!  )r  r  	intervalss      r  r  woofipro.parse_funding_intervalt  s-    
	 	X>>r  c                 $    U R                  X5      $ )ao  
fetch the current funding rate interval

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-predicted-funding-rate-for-one-market

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
)fetch_funding_rate)r  r-  r"  s      r  fetch_funding_intervalwoofipro.fetch_funding_interval~  s     &&v66r  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  Xc5      $ )af  
fetch the current funding rate

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-predicted-funding-rate-for-one-market

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
r-  r,   r  )r  r+  "v1PublicGetPublicFundingRateSymbolr  r   r  r  r-  r"  r+  r  r#  r  s          r  r  woofipro.fetch_funding_rate  sn     	V$fTl
 ::4;;w;WX  ~~h3&&t44r  symbolsc                     U R                  5         U R                  U5      nU R                  U5      nU R                  US0 5      nU R	                  US/ 5      nU R                  XQ5      $ )a  
fetch the current funding rate for multiple markets

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-predicted-funding-rates-for-all-markets

:param str[] symbols: unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
r  rY  )r  market_symbolsv1PublicGetPublicFundingRatesr   r[  parse_funding_rates)r  r  r"  r#  r  rY  s         r  fetch_funding_rateswoofipro.fetch_funding_rates  sg     	%%g.55f=$ ~~h3~~dFB/''66r  c           
         U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      $ 0 nUb  U R                  U5      nUS   nUS   US'   Ub  X&S'   U R	                  S	XdS
5      u  pdU R                  U R                  Xd5      5      nU R                  US0 5      n	U R                  U	S/ 5      n
/ n[        S[        U
5      5       Hp  nX   nU R                  US5      nU R                  US5      nUR                  UU R                  U5      U R                  US5      UU R!                  U5      S.5        Mr     U R#                  US5      nU R%                  UXU5      $ )a  
fetches historical funding rate prices

https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-funding-rate-history-for-one-market

:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: timestamp in ms of the earliest funding rate to fetch
:param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest funding rate
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
Frf   paginatepage   r-  r,   start_tend_tgMbP?r  rY  r   funding_rate_timestampfunding_rate)r  r-  r  r'  r  r'  )r  handle_option_and_params fetch_paginated_call_incrementalr+  handle_until_option#v1PublicGetPublicFundingRateHistoryr  r   r[  rn  ro  r!  r(  appendsafe_symbolrR  r  sort_byfilter_by_symbol_since_limit)r  r-  r  r   r"  r  r  r+  r#  r  rs  ratesr}  entryrS  r'  sorteds                    r  fetch_funding_rate_history#woofipro.fetch_funding_rate_history  s    	88AZ\fg889RTZchrxz|}}[[(FH%F &tGH!&I227GUS;;DKK<XY( ~~h3fb1q#f+&AIE''x8H))%1IJILL**84#//~F& LL3 	 ' e[100NNr  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	S:X  a  [
        R                  " U5      OUnUUUUU R                  U5      S U R                  U5      US.$ )	Nr-  funding_feeUSDCupdated_timer  payment_typePay)r  r-  ri  r'  r  r,   r>  rate)	r!  r  rQ  r(  rR  r&   
string_negr  r  )
r  incomer+  rS  r-  r>  ri  r'  r  paymentTypes
             r  parse_incomewoofipro.parse_income  s     ##FH5!!(3!!&-8&&v.%%fn=	7&&v~>0;u0D##F+6"Y/''/	
 		
r  c           	         U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      $ 0 nSnUb  U R                  U5      nUS   US'   Ub  X&S	'   U R	                  US
5      nU R                  US
/5      nUb  XS'   Ub  [        US5      US'   U R                  U R                  Xd5      5      n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  XX#5      $ )a  
fetch the history of funding payments paid and received on self account

https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/get-funding-fee-history

:param str [symbol]: unified market symbol
:param int [since]: the earliest time in ms to fetch funding history for
:param int [limit]: the maximum number of funding history structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
Frb   r  r  r   Nr,   r-  r  untilr  sizer  rY  )r  r  r  r+  r(  omitr@  v1PrivateGetFundingFeeHistoryr  r   r[  parse_incomes)r  r-  r  r   r"  r  r  r+  r
  r#  r  rY  s               r  fetch_funding_historywoofipro.fetch_funding_history.  s"    	88AVXbc889NPV_dntvyzz[[(F &tGH!&I!!&'26G9-$G!%oGFO55dkk'6RS0 ~~h3~~dFB/!!$==r  c           
         U R                  5         U R                  U5      nU R                  US0 5      nU R                  US5      nU R                  US5      n0 n[	        S[        U R                  5      5       He  nU R                  U   nUUU R                  [        R                  " US5      5      U R                  [        R                  " US5      5      SSS.Xh'   Mg     U$ )aP  
fetch the trading fees for multiple markets

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-account-information

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
r  futures_maker_fee_ratefutures_taker_fee_rater   10000T)r  r-  r   r   r   r   )
r  v1PrivateGetClientInfor   r!  rn  ro  r  r  r&   
string_div)	r  r"  r#  r  r   r   rs  r}  r-  s	            r  fetch_trading_feeswoofipro.fetch_trading_feesi  s     	..v68 ~~h3  '?@  '?@q#dll+,A\\!_F  **7+=+=eW+MN**7+=+=eW+MN"!FN - r  c           	      .   U R                  5         U R                  U5      nSUS   0nUb  [        US5      nX%S'   U R                  U R	                  XS5      5      nU R                  US0 5      nU R                  US5      nU R                  XqUSSS	S
5      $ )a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/orderbook-snapshot

: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
: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
r-  r,   r   	max_levelr  r'  bidsasksr   quantity)r  r+  r@  v1PrivateGetOrderbookSymbolr  r   r(  parse_order_book)	r  r-  r   r"  r+  r  r#  r  r'  s	            r  fetch_order_bookwoofipro.fetch_order_book  s     	V$fTl
 t$E#(K 33DKK4PQ$ ~~h3%%dK8	$$T9ffgWabbr  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start_timestampopenhighlowclosevolume)r(  rR  )r  ohlcvr+  s      r  parse_ohlcvwoofipro.parse_ohlcv  sm    e%67UF+UF+UE*UG,UH-
 	
r  r   	timeframec                 ^   U R                  5         U R                  U5      nUS   U R                  U R                  X"5      S.nUb  [	        US5      US'   U R                  U R                  Xu5      5      nU R                  US0 5      n	U R                  U	S/ 5      n
U R                  XX#U5      $ )a  

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-kline

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
: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
:param int [limit]: max=1000, max=100 when since is defined and is less than(now - (999 * (timeframe in ms)))
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
r,   )r-  r8  r   r   r  rY  )
r  r+  r!  r   r@  v1PrivateGetKliner  r   r[  parse_ohlcvs)r  r-  r,  r  r   r"  r+  r  r#  r  rY  s              r  fetch_ohlcvwoofipro.fetch_ohlcv  s     	V$Tl$$T__iK
 "5$/GG))$++g*FG~~h3* ~~dFB/  yGGr  r   c                    U R                  U/ SQ5      nU R                  U/ SQ5      nU R                  U R                  USS5      5      nU R	                  US5      nU R                  Xb5      nUS   nU R                  USS5      nU R                  USS	5      n	U R                  US
S5      n
U R                  USS5      nU R                  USS5      nU R                  US5      nUb  U(       a  SOSnU R                  US5      nU R                  U R                  USS5      5      nU R                  U R                  USS5      5      n[        R                  " X5      nU R                  USS5      nU R                  USS5      nU R                  US5      nU R                  US5      nS nS nU R                  US5      nUb~  U R                  US5      nU R                  US/ 5      n[        U5      nUS:  aH  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!S"5      nU R!                  0 S#U_SU_S$U_S%U R#                  U5      _S&S _S'U_SU R%                  U5      _SU_SU R'                  U5      _S(U R)                  U5      _S)S _S*U R                  US+5      _SU_SU_SU_S,U_S-U_UU	UUU
UUUS..US/.EU5      $ )0N)r'  rG  createdTime)r  orderIdalgoOrderIdclient_order_idclientOrderIdr-  order_pricer   order_quantityr  order_amountr>  
order_typer8  r  
algoStatussuccessNEWREJECTEDr  executedtotalExecutedQuantityaverage_executed_priceaverageExecutedPrice	total_feetotalFeer  feeAssetTransactionsr   childOrdersr   r   updatedTimer   r,   r'  r  lastTradeTimestamplastUpdateTimestampr   postOnly
reduceOnlyreduce_onlyr   r   r  )averager>  filled	remainingrF  r   rg  r  )safe_integer_nsafe_string_n	omit_zerosafe_string_2r!  r  safe_string_lower_2safe_value_2	safe_boolr  r&   r  
safe_valuerR  ro  safe_integer_2
safe_orderr  parse_order_statusparse_order_typeparse_time_in_force)r  r   r+  r'  r4  r7  rS  r-  r   r>  rF  	orderTyper  r=  r  rP  rO  rQ  rg  feeCurrencytransactionsr   r   r   rH  firstinnerChildOrdersinnerChildOrdersLengthtakeProfitOrderstopLossOrderrK  s                                  r  parse_orderwoofipro.parse_order   s   \ ''/[\	$$U,RSt'9'9%ARTc'de##E84!!(3!""5-A##E+;ZH!!%B,,UL&I	""5(LA..	2&UZF%%eV4 1 1%E\ ]^..!3!3E;SUk!lm&&t4	{J?((ZHun=''~>#!ooe];"OOK3E#umRH%()9%:"%)"&//2BA"F $0@! D"&"2"2?N"S $ 0 0 O"11%W  
' 
] 
  
 Y/	 

 !$ 
 "#6 
 d--f5 
 f 
 D)))4 
 433I> 
  
 $..> 
 D 
 U 
 L 
  ! 
" ]# 
$ ""' 9 
: ; 	r  r   c                 2    SSSS.nU R                  X!S 5      $ )Nr   r   r   )iocfok	post_onlyr  )r  r   timeInForcess      r  r^  woofipro.parse_time_in_forcep  s'    

 4@@r  r  c           
      H    Ub  SSSSSSSSSS.	nU R                  X!U5      $ U$ )Nr$  closedcanceledrejected)	r>  FILLEDCANCEL_SENTCANCEL_ALL_SENT	CANCELLEDPARTIAL_FILLEDr?  
INCOMPLETE	COMPLETEDr  r  r  statusess      r  r\  woofipro.parse_order_statusx  sD    ")#-'"(&$%
H ##Hf==r  r8  c                 2    SSSS.nU R                  X!U5      $ )Nr   r+  )LIMITMARKET	POST_ONLY)r  r  r8  typess      r  r]  woofipro.parse_order_type  s'     

 %%e488r  r  r>  r   c                 X   U R                  USS5      nUR                  5       nU R                  U5      n	UR                  5       n
U	S   U
S.nU R                  USS5      nU R	                  US5      nU R	                  US5      nU R                  US	5      nUS
L=(       d*    US
L=(       d    US
L=(       d    U R	                  US5      S
LnUS:H  nU R                  US5      nU R                  US
U5      nU(       a  SOSnU(       a  SOSnU(       a  SOSnXU'   U(       d$  U(       a  SUS'   OUS:X  a  SUS'   OUS:X  a  SUS'   U(       a  X{S'   Ub  U R                  X5      UU'   U(       a  U(       d  U R                  X5      UU'   OUS:w  a  U R                  X5      UU'   U R                  U/ SQ5      nUb  UUS'   Ub  U R                  X5      US'   SUS'   OUc  Ub  SUS'   U	S   S S/ S!.nUS"   nU
S#:X  a  S$OS#nUb=  U R                  USSU5      nUSU R                  UU5      S%S&S'.nUR                  U5        Ub=  U R                  USSU5      nUSU R                  UU5      S%S&S'.nUR                  U5        U/US"'   U R                  U/ S(Q5      nU R                  X5      $ ))aB  
@ignore
       helper function to build the request
       :param str symbol: unified symbol of the market to create an order in
       :param str type: 'market' or 'limit'
       :param str side: 'buy' or 'sell'
       :param float amount: how much you want to trade in units of the base currency
       :param float [price]: the price that 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
       :returns dict: request to be sent to the exchange
       rM  rN  r,   )r-  r  r   	stopPricestopLoss
takeProfitalgoTypeNrH  r  r   r  r9  r   r8  r8  r;  r  rk  r   rj  r   POSITIONAL_TP_SLclOrdIDr7  r6  r6  trigger_priceSTOP	algo_typeTP_SLF)r-  rN  r  child_ordersr  BUYSELLr~  T)r  r  r  r8  rN  )rM  rN  r  r7  r6  rL  r   r  r   r  r  )safe_bool_2upperr+  rU  rY  r!  r  is_post_onlyprice_to_precisionamount_to_precisionrS  safe_number_2r  r  r  )r  r-  r8  r  r>  r   r"  rM  r_  r+  	orderSider  r   r  r  r  isConditionalisMarketr   rL  orderQtyKeypriceKeytypeKeyr7  outterOrderrH  	closeSider   rf  r   re  s                                  r  create_order_requestwoofipro.create_order_request  s0    %%flMJ
JJL	V$JJL	Tl
 ))&.+N??6:6__V\:
##FJ7$D0  [HD4H  [J^bLb  [gkgvgvw}  @M  hN  VZ  hZ(,,V]C$$XtV<$1j7G+7)&|$(3%%(-%%(-%%/M" $ 7 7 FGHM#'#;#;F#KGK ++#'#;#;F#KGK **63bc$)6G%&#'+'>'>v'TGO$#)GK "
(>#*GK  ,$/ "	!K &n5K#,#5EI# $ 2 28^WV^ _%!(%)%<%<V]%S##'' ""=1%"&"4"4ZQXZd"e%!(%)%<%<V_%U##') ""?3'2mGN#6  $B  C{{7++r  c                    U R                  5         U R                  U5      nU R                  XX4XV5      nU R                  USS5      n	U R	                  US5      n
U R	                  US5      nU	SL=(       d*    U
SL=(       d    USL=(       d    U R	                  US5      SLnSnU(       a  U R                  U5      nOU R                  U5      nU R                  US5      nU R                  US5      US'   U R                  X5      nX/S	'   U$ )
a  
create a trade order

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/create-order
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/create-algo-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
: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 float [params.triggerPrice]: The price a trigger order is triggered at
:param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
:param float [params.takeProfit.triggerPrice]: take profit trigger price
:param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
:param float [params.stopLoss.triggerPrice]: stop loss trigger price
:param float [params.algoType]: 'STOP'or 'TP_SL' or 'POSITIONAL_TP_SL'
:param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
:param str [params.clientOrderId]: a unique id for the order
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r   r  r  r  NrH  r  r'  r8  )
r  r+  r  rU  rY  v1PrivatePostAlgoOrderv1PrivatePostOrderr   r(  rg  )r  r-  r8  r  r>  r   r"  r+  r  r   r  r  r  r#  r  r   s                   r  create_orderwoofipro.create_order  s(   . 	V$++F$V))&.+N??6:6__V\:
$D0  [HD4H  [J^bLb  [gkgvgvw}  @M  hN  VZ  hZ227;H ..w7H  ~~h/ --hD[  .fr  r   c           	      Z   U R                  5         / n[        S[        U5      5       G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                  USS	5      nU R	                  US
5      nU R	                  US5      nUSL=(       d*    USL=(       d    USL=(       d    U R	                  US5      SLnU(       a  [        U R                  S-   5      eU R                  XgXX5      nUR                  U5        GM'     SU0nU R                  U R                  UU5      5      nU R                  US0 5      nU R                  US/ 5      nU R                  U5      $ )a  
*contract only* create a list of trade orders

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/batch-create-order

: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
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r   r-  r8  r  r>  r   r"  r   r  r  r  NrH  z+ createOrders() only support non-stop orderr   r  rY  )r  rn  ro  r!  rY  r   rU  r"   r,   r  r  v1PrivatePostBatchOrderr  r[  parse_orders)r  r   r"  ordersRequestsr}  rawOrderrS  r8  r  r>  r   orderParamsr   r  r  r  orderRequestr  r#  r  rY  s                        r  create_orderswoofipro.create_orders+  s    	q#f+&AyH''(;H##Hf5D##Hf5D__Xx8FOOHg6E..8R@K--k>;WL{J?HlCJ(4  d8L  dPZbfPf  dkokzkz  |G  IV  lW  _c  lcM"477-Z#Z[[44XTSXfL!!,/ '" n
 //GV0LM$ ~~h3~~dFB/  &&r  r,   c                    U R                  5         U R                  U5      nSU0n	U R                  U/ SQ5      n
U
b  U R                  X*5      U	S'   U
SL=(       d    U R	                  US5      SLnU(       a  SOSnU(       a  SOS	nUb  U R                  X&5      X'   Ub  U R                  X%5      X'   U R                  U/ S
Q5      nSnU(       a!  U R                  U R                  X5      5      nOUS   U	S'   UR                  5       U	S'   UR                  5       nU R                  US5      nUS:H  nU R                  USU5      nU(       a  SU	S'   OUS:X  a  SU	S'   OUS:X  a  SU	S'   OXS'   U R                  U/ SQ5      nU R                  U/ SQ5      nUb  UU	S'   U R                  U R                  X5      5      nU R                  US0 5      nU R                  US5      US'   U R                  UU5      $ )a  
edit a trade order

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/edit-order
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/edit-algo-order

:param str id: order id
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
: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 float [params.triggerPrice]: The price a trigger order is triggered at
:param float [params.stopLossPrice]: price to trigger stop-loss orders
:param float [params.takeProfitPrice]: price to trigger take-profit orders
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r  )r   r  r   r   Nr   rH  r  r9  r   r8  )r  r   r   r   trailingTriggerPricetrailingAmounttrailingPercentr,   r-  r  r   r  r  r;  rk  r   rj  r   r  )r  r7  r6  rL  r   r6  r  r'  )r  r+  rS  r  rY  r  r  v1PrivatePutAlgoOrderr  r  r  r  v1PrivatePutOrderr   r(  rg  )r  r,   r-  r8  r  r>  r   r"  r+  r  r   r  r  r  r#  r_  r   r  rL  r7  r  s                        r  
edit_orderwoofipro.edit_order`  s   & 	V$
 ))&2st#&*&=&=f&SGN#%T1jtv}7]ei7i$1j7G+7 $ 7 7 FG#'#;#;F#KG 6  $b  c11$++g2NOH &tGH"jjlGFO

I00GK H,H((4@H(3%%(-%%(-%(1% ..v7fgMYYv'qrF(-:)* --dkk'.JKH ~~h3 --hD[f--r  c                    U R                  USSS5      nU R                  USS/5      nU(       d  Uc  [        U R                  S-   5      eU R	                  5         SnUb  U R                  U5      nSUS   0nU R                  USS	5      nU R                  US
U5      nUSLn	Sn
U(       ae  U	(       a9  XS
'   U R                  U/ SQ5      nU R                  U R                  Xc5      5      n
OXS'   U R                  U R                  Xc5      5      n
OdU	(       a9  XS
'   U R                  U/ SQ5      nU R                  U R                  Xc5      5      n
O$XS'   U R                  U R                  Xc5      5      n
SU0nU	(       a  XS
'   OXS'   U(       a!  U R                  U R                  U
5      U5      $ U R                  U
S0 5      nU R                  U R                  U5      U5      $ )a  

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/cancel-order
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/cancel-order-by-client_order_id
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/cancel-algo-order
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/cancel-algo-order-by-client_order_id

cancels an open order
: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 boolean [params.trigger]: whether the order is a stop/algo order
:param str [params.clientOrderId]: a unique id for the order
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
stopr   FNz) cancelOrder() requires a symbol argumentr-  r,   r  r7  r6  r  r  r  )r  r  r   r,   r  r+  rU  r!  v1PrivateDeleteAlgoClientOrderr  v1PrivateDeleteAlgoOrderv1PrivateDeleteClientOrderv1PrivateDeleteOrderrg  r   )r  r,   r-  r"  r   r+  r  clientOrderIdUnifiedclientOrderIdExchangeSpecificisByClientOrderr#  extendParamsr  s                r  cancel_orderwoofipro.cancel_order  s     ""669eD6FI#67FN#DGG.Y$YZZ[[(FfTl
  $11&)_U(,(8(8ARTh(i%7tC-J)*6+Z[>>t{{7?[\&(
#88W9UV-J)*6+Z[::4;;w;WX&(
#44T[[5QR  '/.K*+!#;;t//9<HH~~h3{{4++D1<@@r  idsc                    U R                  5         U R                  U/ SQ5      nU R                  U/ SQ5      n0 nSnU(       a5  SR                  U5      US'   U R	                  U R                  XS5      5      nO4SR                  U5      US'   U R                  U R                  XS5      5      nU R                  SU05      /$ )aQ  
cancel multiple orders

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/batch-cancel-orders
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/batch-cancel-orders-by-client_order_id

:param str[] ids: order ids
:param str [symbol]: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str[] [params.client_order_ids]: max length 10 e.g. ["my_id_1","my_id_2"], encode the double quotes. No space after comma
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
)clOrdIDsclientOrderIdsclient_order_idsN,r  	order_idsr  )r  safe_list_nr  joinv1PrivateDeleteClientBatchOrderr  v1PrivateDeleteBatchOrderr[  )r  r  r-  r"  r  r  r#  s          r  cancel_orderswoofipro.cancel_orders  s     	))&2de6#UV*-((>*BG&';;DKK<XYH#&88C=GK 55dkk'6RSH H!
   	r  c                 h   U R                  5         U R                  USS5      nU R                  USS/5      n0 nUb  U R                  U5      nUS   US'   SnU(       a!  U R	                  U R                  XB5      5      nO U R                  U R                  XB5      5      nU R                  SU05      /$ )a   

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/cancel-all-pending-algo-orders
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/cancel-orders-in-bulk

cancel all open orders in a market
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: whether the order is a stop/algo order
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r  r   Nr,   r-  r  )r  r  r  r+  v1PrivateDeleteAlgoOrdersr  v1PrivateDeleteOrdersr[  )r  r-  r"  r   r  r+  r#  s          r  cancel_all_orderswoofipro.cancel_all_orders  s     	""669=6FI#67[[(F &tGH55dkk'6RSH11$++g2NOH" OO 
 	
r  c                 f   U R                  5         SnUb  U R                  U5      nU R                  USSS5      n0 nU R                  U/ SQ5      nU R	                  U/ SQ5      nSnU(       aQ  U(       a%  XvS'   U R                  U R                  Xc5      5      nOuXS'   U R                  U R                  Xc5      5      nOPU(       a%  XvS'   U R                  U R                  Xc5      5      nO$XS'   U R                  U R                  Xc5      5      nU R                  US	U5      n	U R                  X5      $ )
aB  

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-order-by-order_id
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-order-by-client_order_id
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-algo-order-by-order_id
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-algo-order-by-client_order_id

fetches information on an order made by the user
:param str id: the 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 boolean [params.trigger]: whether the order is a stop/algo order
:param str [params.clientOrderId]: a unique id for the order
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r   Fr  )r  r   r  r7  r6  r6  oidr  )r  r+  r  rS  r  (v1PrivateGetAlgoClientOrderClientOrderIdr  v1PrivateGetAlgoOrderOid$v1PrivateGetClientOrderClientOrderIdv1PrivateGetOrderOidr   rg  )
r  r,   r-  r"  r+  r   r  r7  r#  r   s
             r  fetch_orderwoofipro.fetch_orderC  s!     	[[(F""669eD**63bc6#ef-:)*HHU\Ief!#88W9UV-:)*DDT[[QXEab!#44T[[5QR8 &(;//r  c           	         U R                  5         SnU R                  USSS5      nU(       a  SOSnU R                  USS5      u  pTU(       a  U R                  SXX4SU5      $ 0 nS	n	U R	                  USS/5      nUb  U R                  U5      n	U	S
   US'   Ub  X(S'   Ub  X8S'   OXxS'   U(       a  SUS'   U R                  SX5      u  pS	n
U(       a!  U R                  U R                  X5      5      n
O U R                  U R                  X5      5      n
U R                  U
SU
5      nU R                  US5      nU R                  XX#5      $ )a  
fetches information on multiple orders made by the user

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-orders
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-algo-orders

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: whether the order is a stop/algo order
:param boolean [params.is_triggered]: whether the order has been triggered(False by default)
:param str [params.side]: 'buy' or 'sell'
:param boolean [params.paginate]: set to True if you want to fetch orders with pagination
:param int params['until']: timestamp in ms of the latest order to fetch
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Fr  r   r1   r   rv   r  r  Nr,   r-  r  r  r  r  r  r  rY  )r  r  r  r  r  r+  r  v1PrivateGetAlgoOrdersr  v1PrivateGetOrdersrY  r[  r  )r  r-  r  r   r"  r  	isTriggermaxLimitr  r+  r#  r  r   s                r  fetch_orderswoofipro.fetch_orders  sa   $ 	$$VVYF	$3388PZ[88W\flnvww6FI#67[[(F &tGH!&I#FO&FO#)GK 227GL224;;w3OPH..t{{7/KLHF x:f-  >>r  c                 n    U R                  5         U R                  USS05      nU R                  XX55      $ )  
fetches information on multiple orders made by the user

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-orders
https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-algo-orders

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: whether the order is a stop/algo order
:param boolean [params.is_triggered]: whether the order has been triggered(False by default)
:param str [params.side]: 'buy' or 'sell'
:param int params['until']: timestamp in ms of the latest order to fetch
:param boolean [params.paginate]: set to True if you want to fetch orders with pagination
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r  rx  r  r  r  r  r-  r  r   r"  extendedParamss         r  fetch_open_orderswoofipro.fetch_open_orders  s8    $ 	Vh-EF  FFr  c                 n    U R                  5         U R                  USS05      nU R                  XX55      $ )r  r  ry  r  r  s         r  fetch_closed_orderswoofipro.fetch_closed_orders  s8    $ 	Vh-DE  FFr  c                    U R                  5         SnUb  U R                  U5      nSU0nU R                  U R                  Xu5      5      nU R	                  US0 5      n	U R                  U	S/ 5      n
U R                  XX4U5      $ )a  
fetch all the trades made from a single order

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-all-trades-of-specific-order

:param str id: order id
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nr  r  rY  )r  r+  v1PrivateGetOrderOidTradesr  r   r[  r  )r  r,   r-  r  r   r"  r+  r  r#  r  r   s              r  fetch_order_tradeswoofipro.fetch_order_trades  s     	[[(F2
 224;;w3OP, ~~h3fb1  vFFr  c           	         U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4SS5      $ 0 nSnUb  U R                  U5      nUS   US'   Ub  X&S	'   Ub  X6S
'   OSUS
'   U R	                  SXd5      u  pdU R                  U R                  Xd5      5      nU R                  US0 5      n	U R                  U	S/ 5      n
U R                  XX#U5      $ )at  

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-trades

fetch all trades made by the user
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: set to True if you want to fetch trades with pagination
:param int params['until']: timestamp in ms of the latest trade to fetch
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Fro   r  r  r   Nr,   r-  r  r  r  r  rY  )
r  r  r  r+  r  v1PrivateGetTradesr  r   r[  r  )r  r-  r  r   r"  r  r  r+  r#  r  r   s              r  fetch_my_tradeswoofipro.fetch_my_trades5  s    	88R\]88&Y^hnpstt[[(F &tGH!&I#FO!GFO227GL**4;;w+GH6 ~~h3fb1  vFFr  c                 P   SU0nU R                  US/ 5      n[        S[        U5      5       Hf  nX4   nU R                  U R	                  US5      5      nU R                  5       nU R	                  US5      US'   U R	                  US5      US'   XrU'   Mh     U R                  U5      $ )Nr  holdingr   ra  totalfrozen)r[  rn  ro  rQ  r!  accountsafe_balance)r  r#  rs  balancesr}  balanceri  r  s           r  parse_balancewoofipro.parse_balances  s    H
 >>(Ir:q#h-(AkG**4+;+;GW+MNDllnG#//CGG $ 0 0( CGH"4L )   ((r  c                     U R                  5         U R                  U5      nU R                  US5      nU R                  U5      $ )a]  
query for balance and get the amount of funds available for trading or funds locked in orders

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-current-holding

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
r  )r  v1PrivateGetClientHoldingr   r   r  r"  r#  r  s       r  fetch_balancewoofipro.fetch_balance  sC     	11&9  ~~h/!!$''r  ri  c                 b   U R                  5         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 R                  US5      nUb  XuS'   U R	                  U R                  XT5      5      nU R                  US0 5      n	X`R                  U	S/ 5      /$ )Nr,   balance_tokenr  pageSizer8  r  rY  )r  r  r!  r  v1PrivateGetAssetHistoryr  r   r[  )
r  ri  r  r   r"  r  r  transactionTyper#  r  s
             r  get_asset_history_rowswoofipro.get_asset_history_rows  s    !}}T*H'/~GO$!&I"'J**66:66*&-FO00W1MN4 ~~h3..vr:;;r  r  r  c                 N   U R                  US5      nU R                  X25      nU R                  X25      nU R                  US5      nU R                  US5      nUS:X  a  SOSnU R	                  US5      nU R                  USS	5      n	U R                  U R                  US
5      UU R                  US5      S U R                  US5      U R                  U R                  US5      5      US S U	UUU R                  U5      U R                  U R                  US5      5      US.U5      $ )Nra  r>  
token_sideDEPOSITinoutrG  	fee_token
fee_amountr,   r  tx_idr  r8  )r,   r  r  referenceAccountreferenceIdr  r>  beforeafterrg  	directionr'  r  r8  r  )
r!  rQ  safe_currencyrR  r(  r  safe_ledger_entryparse_transaction_statusr  parse_ledger_entry_type)
r  r  r  r~  ri  r>  r  r  r'  rg  s
             r  parse_ledger_entrywoofipro.parse_ledger_entry  s6   %%dG4
&&z<%%j;!!$1l3!Y.DU	%%dN;	++D+|L%%""4.''i8 $++D':33D4D4DT84TU""Y/001A1A$1OP'
  ! 	r  c                 0    SSS.nU R                  X!U5      $ )Ntransactionr   )BALANCE
COLLATERALr  r  s      r  r   woofipro.parse_ledger_entry_type  s$    $$
 T22r  c                     U R                  XX45      nU R                  US5      nU R                  US5      nU R                  XvX#U5      $ )a3  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-asset-history

:param str [code]: unified currency code, default is None
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
:param int [limit]: max number of ledger entries to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
r   r   )r  rY  r[  parse_ledger)r  ri  r  r   r"  currencyRowsr  rY  s           r  fetch_ledgerwoofipro.fetch_ledger  sK     224N??<3~~lA.  vFFr  r"  c                 `   U R                  US5      nU R                  US5      nUS:X  a  SnU R                  USS5      nU R                  US5      nU R                  US5      nU R                  US	5      n0 S
U_SU R	                  USS5      _SU R                  US5      _SU_SU R                  U5      _SS _SU_SU_SU R                  US5      _SS _SS _SU_SU R                  US5      _SU_SU R                  U R                  US5      5      _SU R                  US5      _SS _S US S.E$ ) Nra  r  r   
withdrawalr  r  target_addresssource_addressrG  r  r,   withdraw_idtxidr  r'  r  addressaddressFrom	addressTotagextratagFromtagTor8  r>  r  r  r  r   comment)internalrg  rf  )r!  r  r  r(  rU  r  rR  r  )	r  r"  r  ri  movementDirectionrg  r3  r2  r'  s	            r  parse_transactionwoofipro.parse_transaction  s   W5 22;M
* ,++KlS$$[2BC	&&{4DE%%k>B	
K
$$$[$F
 D$$[':
 	

 Y/
 t
 ;
 
 4##K9
 t
 T
 %
 d&&{H=
 
 d33D4D4D[RZ4[\
  t((nE!
" t#
$ )
 	
r  c                 6    SSSSSS.nU R                  X!U5      $ )Npendingr  rq  )r>  
CONFIRMING
PROCESSINGry  CANCELEDr  rz  s      r  r  !woofipro.parse_transaction_status	  s-    ##"
 &99r  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )a  
fetch all deposits made to an account

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-asset-history

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
r  r  fetch_deposits_withdrawalsr  r  ri  r  r   r"  r  s         r  fetch_depositswoofipro.fetch_deposits(	  s.     I
 ..tE;;wC_``r  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )a  
fetch all withdrawals made from an account

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-asset-history

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
r  WITHDRAWrD  rF  s         r  fetch_withdrawalswoofipro.fetch_withdrawals9	  s.     J
 ..tE;;wC_``r  c           	          0 nU R                  XX0R                  XT5      5      nU R                  US5      nU R                  US5      nU R	                  XX#U5      $ )aF  
fetch history of deposits and withdrawals

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-asset-history

:param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
:param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
:param int [limit]: max number of deposit/withdrawals to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
r   r   )r  r  rY  r[  parse_transactions)	r  ri  r  r   r"  r  r(  r  rY  s	            r  rE  #woofipro.fetch_deposits_withdrawalsJ	  s\     224{{SZGcd??<3~~lA. &&tuVLLr  c                 n    U R                  U5      nU R                  US0 5      nU R                  US5      $ )Nr  r   )v1PrivateGetWithdrawNoncer   rR  r  s       r  get_withdraw_noncewoofipro.get_withdraw_nonceg	  s:    11&9 ~~h3&677r  c                 .    SU R                  USS5      -   $ )N0xkeccakhex)hash)r  messages     r  hash_messagewoofipro.hash_messageu	  s    dii5999r  c                     U R                  USS  USS  SS 5      nUS   nUS   nU R                  U R                  SUS   5      5      nSUR                  SS	5      -   UR                  SS	5      -   U-   $ )
N	secp256k1rs   vrU  @   r  )ecdsaint_to_base16sumrjust)r  rX  r   	signaturer_  r`  rb  s          r  	sign_hashwoofipro.sign_hashx	  s    JJtCDz:cd+;[$O	cNcNtxxIcN;<aggb#&&S)99A==r  c                 J    U R                  U R                  U5      USS  5      $ )Nr]  )ri  rZ  )r  rY  r   s      r  sign_messagewoofipro.sign_message	  s%    ~~d//8*ST:JKKr  r1  r4  c           
         U R                  5         U R                  U5        Ub.  UR                  5       nUS:w  a  [        U R                  S-   5      eU R                  U5      nU R                  U R                  S5      nU R                  US5      nU R                  US0 5      n	U R                  X0 5      n
U R                  U
S5      nUc  [        U R                  S-   5      eU R                  U5      nU R                  5       nUSUS	S
.nSSSS.SSS.SSS.SSS.SSS.SSS.SSS./0nU R                  U R                  SS5      U R                  U5      UU[        U5      UUS.nU R                  XU5      nU R!                  UU R"                  5      nUUUUS.nU R%                  US5      nU R'                  U R)                  UU5      5      nU R                  US0 5      nU R+                  UU5      $ )a  
make a withdrawal

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/create-withdraw-request

: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
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
r  z withdraw() only support USDCr   chainIdrj  r,   z% withdraw() require chainId parameterOrderlyr;  )ro  r-   verifyingContractr2   Withdrawr   string)r-   r8  uint256receiverr1  ra  r>  withdrawNonceuint64r'  keyBrokerId	woofi_pro)r   ro  ru  ra  r>  rv  r'  )rh  userAddressrq  rY  r  )r  check_addressr  r"   r,   r  r!  r   r   rR  r   rR  nonceparse_to_intstreth_encode_structured_datarl  r   r  v1PrivatePostWithdrawRequestr  r;  )r  ri  r>  r1  r4  r"  r  r   ro  currencyNetworkscoinNetworkcoinNetworkIdrv  r|  domainmessageTypeswithdrawRequestmsgrh  r  r#  r  s                         r  r   woofipro.withdraw	  s    	7#::<Dv~"477-L#LMM==&#'#3#3DLLB\#] ""695>>(JCnn%5C((d; TWW'NNOO//7

!9	
 #X6"I6#Y7 (3!95((;$h7

 ((}kR((1&k*!
 --fOT%%c4??;	""!9&	
 69-44T[[&5QR ~~h3%%dH55r  c                 <    U R                  US5      nUUS   S UUS.$ )Nmax_leverager-  )r  r-  r   longLeverageshortLeverage)r(  )r  r   r+  leverageValues       r  parse_leveragewoofipro.parse_leverage	  s2    ))(NCX&)*
 	
r  c                     U R                  5         U R                  U5      nU R                  U5      nU R                  US0 5      nU R	                  XS5      $ )aR  
fetch the set leverage for a market

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-account-information

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
r  )r  r+  r  r   r  )r  r-  r"  r+  r#  r  s         r  fetch_leveragewoofipro.fetch_leverage	  sS     	V$..v68 ~~h3""400r  r   c                     U R                  5         US:  d  US:  a  [        U R                  S-   5      eSU0nU R                  U R	                  XC5      5      $ )aV  
set the level of leverage for a market

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/update-leverage-setting

:param int [leverage]: the rate of leverage
:param str [symbol]: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
r   2   z$ leverage should be between 1 and 50r   )r  r   r,   v1PrivatePostClientLeverager  )r  r   r-  r"  r  s        r  set_leveragewoofipro.set_leverage
  sZ     	qLhmTWW'MMNN
 //G0LMMr  positionc                 t   U R                  US5      nU R                  X25      nU R                  US5      nS n[        R                  " US5      (       a  SnOS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
[        R
                  " U5      n[        R                  " XG5      nU R                  0 SU_SS _SU R                  US5      _SU_SU R                  U5      _SS _SS _SS _SS _SS _SU R                  U	5      _SU R                  U5      _SS _SU R                  U
5      _SU R                  U5      _SU R                  U5      _SS _U R                  US5      U R                  U5      S S SS US S S S S.E5      $ )Nr-  position_qtyr  longshortrH  
mark_pricer'  average_open_priceunsettled_pnlr  r,   r  rK  initialMargininitialMarginPercentagemaintenanceMarginmaintenanceMarginPercentage
entryPricenotionalr   unrealizedPnl	contractsmarginRatioest_liq_pricecross)liquidationPricer  	lastPrice
collateralr   
marginTyper  r   r   r   r   )r!  r  r&   	string_gtr(  
string_absr  safe_positionr  r  rR  )r  r  r+  r:  r  r  rH  r  r'  r  unrealisedPnlr  s               r  parse_positionwoofipro.parse_position
  sB   . ##Hh7!!(3.9T3''DD''?$$X|<	%%h<	%%h0DE
((?C!!$'%%d6!! #
H#
$#
 d&&vx8#
 	#

 Y/#
 "4#
 T#
 &t#
  #
 *4#
 $++J7#
 ))(3#
 #
 T..}=#
 **40#
  D--l;!#
" 4##
$ !% 0 0? K**95!!#9#
  	r  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US5      nU R                  Xc5      $ )aq  

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-one-position-info

fetch data on an open position
:param str symbol: unified market symbol of the market the position is held in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
r-  r,   r  )r  r+  v1PrivateGetPositionSymbolr  r   r  r  s          r  fetch_positionwoofipro.fetch_position\
  sl     	V$fTl
 224;;w3OP6 ~~h/""400r  c                     U R                  5         U R                  U5      nU R                  US0 5      nU R                  US/ 5      nU R	                  XQ5      $ )a^  
fetch all open positions

https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-all-positions-info

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
r  rY  )r  v1PrivateGetPositionsr   r[  parse_positions)r  r  r"  r#  rs  r   s         r  fetch_positionswoofipro.fetch_positions
  sX     	--f5N &"5NN6626	##I77r  c                 "    U R                  5       $ N)milliseconds)r  s    r  r|  woofipro.nonce
  s      ""r  r   GETc                    US   nUS   nU R                  X5      n	U R                  U R                  S   U   5      n
U
SU-   S-   -  n
U R                  X@R	                  U5      5      nU R                  U5      nUS:X  a$  X-  n
U(       a  U
SU R                  U5      -   -  n
GOU R                  5         US:X  d  US:X  a  US	:X  d  US
:X  d  US:X  a  U R                  U R                  SS5      nU(       da  U R                  U R                  SS5      nUS:X  a:  U R                  US/ 5      n[        S[        U5      5       H  nXS   U   S'   M     OXS'   U R                  U5      nSn[        U R                  5       5      nX-  n
U R                   nUR#                  S5      S:  a  SU-   nU R$                  UUS.nUU-   S-   U-   S-   U	-   nUS:X  d  US:X  a  U R'                  U5      nX-  nSUS'   OBU(       a.  U
SU R                  U5      -   -  n
USU R)                  U5      -   -  nSUS'   US:X  a  SnU R*                  nUR#                  S5      S:  a  UR-                  S5      nUS   nU R/                  U R1                  U5      U R3                  U5      S5      nU R5                  U R7                  U5      5      US'   XXeS.$ )Nr   r   r   r0  r   ?POSTPUTr   r   r   r   Fr   r   r   	order_tag zed25519:)zorderly-account-idzorderly-keyzorderly-timestampzapplication/jsonzcontent-typez!application/x-www-form-urlencodedDELETEed25519zorderly-signature)r   methodbodyheaders)implode_paramsimplode_hostnamer   r  extract_paramskeysort	urlencodecheck_required_credentialsrX  r   r!  r[  rn  ro  r~  r|  r   findr   json	rawencoder   rP  eddsaencodebase58_to_binaryurlencode_base64base64_to_binary)r  pathsectionr  r"  r  r  r2   accesspathWithParamsr   isSandboxModer   
ordersListr}  authtsr   r   rT  rh  s                        r  signwoofipro.sign
  s   !*,,T:##DIIe$4V$<=sW}s""6#6#6t#<=f%X!CsT^^F333++-& FeO$,:NRVZaRaeimzez $t||]E R$#//j&QH},%)^^FHb%I
!&q#j/!:A?G8,Q/< "; /7{+f-DTZZ\"B!C[[F{{:&*#f,&*nn%%'G
 ;$w.4~ED6U?yy(*<'3!777CC$.."888D*M'X%D[[F{{:&!+Z0q

4;;t#4d6K6KF6SU^_I+/+@+@AVAVW`Aa+bG'(dOOr  httpCodereasonr   r  r  r  c
                 >   U(       d  g U R                  US5      n
U R                  US5      nU
(       dj  U R                  S-   U R                  U5      -   nU R	                  U R
                  S   Xl5        U R                  U R
                  S   X5        [        U5      eg )Nr=  ri   r  r  )rX  r!  r,   r  throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr   )r  r  r  r   r  r  r  r#  requestHeadersrequestBodyr=  	errorCodefeedbacks                r  handle_errorswoofipro.handle_errors
  s    
 ..95$$Xv6	ww}tyy'::H001I4Z001I9_))r   r  )c__name__
__module____qualname____firstlineno__r   r
  boolr  r$  r	   r)  dictr   rV  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   listr*  r0  r   rg  r^  r\  r]  r   r   floatr   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  rG  rK  rE  rR  rZ  ri  rl  r   r   r  r  intr  r  r  r   r  r|  r  r  __static_attributes____classcell__)r  s   @r  r(   r(      ss   V# Vp-t - #% "
H !# 8s 8,V
4 V
F V
p $& /($v, /(b ') _Z _B
= =v = =~ 6:UW %=3 %=s %=# %=\`af\g %=N'
f '
 '
R? :< 
7S 
7 
7 68  5  5K  5D 6:"  77  7  7D 8<$]ajl >O >OC >OWZ >O@
6 
@ 37TX\eg 9>C 9>s 9>RU 9>v )+ 4{ 4l :>b 'cs 'c3 'cY 'cR
 
4 
 9=4^bkm ,H# ,H# ,HS ,HX[ ,Hrvw{r| ,H\n nv n n`As A  9S 9 os{} U,3 U,i U,y U,Z_ U,hk U,n gksu B3 Bi By BRW B`c BH @B 3'D$6 3'j `drv  @B G.S G.# G.Y G.i G.Y\ G.lo G.R 37r FAs FAC FAP ;?r #c #C #J /32 +
 +
Z 26b C0c C03 C0J *.Dt\^ Q?3 Q?c Q? Q?cghmcn Q?f /3TXac G G3 Gc Ghlmrhs G, 154VZce G# GS GPS Gjnotju G, 9=4^bkm ,GS ,G# ,GS ,GX[ ,G\ -1tRV_a <Gc <G <GC <G|) ) $& (( (: 26DW[df *<3 *<c *<QT *<kn *<Xt x ; 63 (,$TZ\ G GC Gs Gaefqar G"
T 
X 
Q\ 
B:s : *.Dt\^ a3 ac a acghsct a" -1tRV_a ac a aC afjkvfw a" 6:[_hj Ms M# MUX Most  pA M: )+ 8:>L KOWY K6S K6% K6# K6C K6^i K6Z
x 
 24 )1S )1 )1V 9=R NS N# N&Ct CV CJ 24 +1S +1Z 26b 48w 48T(^ 48l# "*%DW[ 6Ppc 3 S # X\ dg  r  r(   N),ccxt.base.exchanger   ccxt.abstract.woofipror   ccxt.base.typesr   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$   ccxt.base.decimal_to_precisionr%   ccxt.base.preciser&   r(   r  r  r  <module>r     se    ( . s  s  s  s  s  s  * 0 . ' . ) ) ) . 4 %q+x q+r  