
    ei                    4   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d d	lm"Z" d d
lm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dl(m)Z) d dl*m+Z+  G d dee          Z,dS )    )Exchange)ImplicitAPIN)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                       e Zd Zdef fdZdef fdZi fdZi fdefdZ	de
defdZi fdee         fd	Zi fdefd
Zd Zdfde
dedefdZddi fdedededee         fdZdfdedefdZd Zi fdedefdZi fdedefdZdi fdedefdZdddi fdededefdZdfdefdZ dddi fdededefdZ!i fde"fdZ#di fdedede$fdZ%dfdede&fdZ'dddi fded edededee&         f
d!Z(dfd"e
dede)fd#Z*d$efd%Z+d&efd'Z,d(efd)Z-di fded(e.d*e/d+e0d,e1f
d-Z2di fded(e.d*e/d+e0d,e1f
d.Z3i fd/ee4         fd0Z5ddi fd1eded(e.d*e/d+e1d,e1fd2Z6di fd1edefd3Z7di fd4ee         defd5Z8di fdefd6Z9di fd1edefd7Z:dddi fdedededee)         fd8Z;dddi fdedededee)         fd9Z<dddi fdedededee)         fd:Z=dddi fd1edededefd;Z>dddi fdededefd<Z?de@fd=ZAi fde@fd>ZBdddi fd?edededefd@ZCdfdAe
dBeDdeEfdCZFdD ZGdddi fd?edededeeE         fdEZHdfdFe
dBeDdeIfdGZJd&efdHZKdddi fd?edededeeI         fdIZLdddi fd?edededeeI         fdJZMdddi fd?edededeeI         fdKZNi fdLZOdM ZPdN ZQdO ZRdi fd?ed+e0dPedQedeIf
dRZSdfdeTfdSZUi fdedeTfdTZVdi fdUeWdefdVZXdfdWe
defdXZYi fdefdYZZdi fdedee[         fdZZ\d[ Z]d\d]i ddfd^Z^d_eWd`edaedbedce
ddefdeZ_ xZ`S )gwoofiproreturnc                 	   |                      t          t          |                                           i ddddddgddd	d
dddddddddi dd ddddddddddddddddddddddddd dd!dd"dd#di d$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4di d5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBddCddDddEdi dFddGddHddIddJddKddLddMddNddOddPddQddRddSddTddUddVdi dWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddeddfddgdi dhddiddjddkddlddmddndodpddqddrddsddtdduddvddwddxddyddzdid{d|d}d~dddddddddddddddddddgdgdddddd
i ddddddddddddddddddddddddddddddddddi dddddddddddddddddddddddddddddddddddddddddddddddddidi dddddddddddddddddddddddddddd̓ddddddi dddd̓dd̓dd̓dd̓dd̓ddדddדddړdd̓dd̓dd̓ddddddddi dddddddddddddddddddddd̓dd̓dddd̓dddddddddddddddddddddddddddddidddddddddd|                     d          |                     d          diddd ddddddd dddd dddddddddddddddiddd ddd	ddddd
ddddddd ddd d dddddddid	ddidd d ddddddid dd d ddi i dt
          dt          dt          dt          dt          dt          dt          dt          d t          d!t          d"t          d#t          d$t          d%t          d&t          d't          d(t          t          t          t          t          t          t          t          d)i d*t          d+          S (,  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borrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercancelOrderscancelWithdrawcloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLosscreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchLeveragefetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionModefetchPositionsfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchTransfersfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMargin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.orgz?https://orderly.network/docs/build-on-omnichain/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    )	sandboxrN   createOrdersr}   r   r   r   rd   r~   extendsdefault)r   price)r   r   )r  rN   forDerivatives)linearinverse)r  r9   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    Y/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/woofipro.pyr  zwoofipro.describe   s   h 5 5 > > @ @ iC
*iC
KiC
 $iC
 	iC

 tiC
 iC
 4iC
 4iC
 iC
  hhh %h 	h
 %h %h Uh $Uh 'h h "4h th h !%h $Uh   !h" %e#h h$ '%h& /'h( $U)h* ,U+h, 0-h. t/h0 71h2 (3h4 '5h6 &t7h8 (9h: "5;h< (=h> ,U?h@ -eAhB %dChD  Eh h hF !%GhH IhJ &uKhL "5MhN +EOhP )%QhR #EShT ,UUhV &uWhX #EYhZ $T[h\ )%]h^ $U_h` 'ahb (chd "4ehf &ugh h hh  ihj +Dkhl &tmhn 'ohp (qhr #Dsht *4uhv $Twhx uyhz "5{h| *5}h~ +Eh@ tAhB  ChD /EhF "5GhH Ih h hJ !%KhL  MhN dOhP +EQhR !%ShT "4UhV uWhX #EYhZ d[h\ !$]h^ t_h` #Dahb  chd $Uehf !$ghh )%ihj tkh h hl umhn ohp Tqhr tsht "5uhv #Dwhx $Zyhz !%{h| )%}h~ #Dh@ AhB #EChD &uEhF tGhH UIhJ "5KhL EMh hN DOh hiC
f  giC
@ i;< 
 DD  -U 5 C $ # AiC
l / 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 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 mD DFmiC
z "!#	$ ${iC
F	 !%"&!..x88!..x88	 G	iC
V	 $",X W	iC
`	 #&+(,,0,1).+06:#'#'"&#(	( ( #($($(+027/4#')$ $. r% ',!$$(%+*/& & ',#'$)*/	# # ',!$#'$)*/( ( $(&+!$$(,0%+#'$)*/	* 	*  #u= =~ y  ) -1 15%*7 7$ $# # "#3  $	  ## iX Xa	iC
R !#]0 0 .	
 Z Z \ Z \ . \ Z . \ \  \!" \#$ ('$,,#$1  47 < 'QiC
 iC
 iC
 i i i	    enablec                 l    t          t          |                               |           || j        d<   d S )Nr   )r  r(   set_sandbox_moder   )r  r#  r   s     r!  r%  zwoofipro.set_sandbox_mode  s3    h..v666&,]###r"  c                    K   |                      |           d{V }|                     |di           }|                     |d          }|d}n|dk    rd}nd}|ddd|dS )	a  
        the latest known information on the availability of the exchange API

        https://orderly.network/docs/build-on-omnichain/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>`
        Ndatastatuserror0okmaintenance)r(  updatedetar   info)v1PublicGetPublicSystemInfo	safe_dictsafe_string)r  paramsresponser'  r(  s        r!  fetch_statuszwoofipro.fetch_status  s       99&AAAAAAAA ~~h33!!$11>FFs]]FF"F
 
 	
r"  c                 h   K   |                      |           d{V }|                     |d          S )a  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://orderly.network/docs/build-on-omnichain/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
        N	timestamp)r0  safe_integer)r  r3  r4  s      r!  
fetch_timezwoofipro.fetch_time  sE       99&AAAAAAAA   ;777r"  marketc                    |                      |d          }|                    d          }d}|                      |d          }|                      |d          }|                     |          }|                     |          }|                      |d          }	|                     |	          }
|dz   |z   dz   |
z   }i d|d|d	|d
|d|
d|d|d|	d|dddddddddddd ddddd|                     d          d d d d |                     |d          |                     |d          dd d d|                     |d          |                     |d          d|                     |d           |                     |d!          d|                     |d"          d dd#|                     |d$          |d%
S )&Nsymbol_r;   r      /:r+   basequotesettlebaseIdquoteIdsettleIdtyper9   Fr:   Tr<   r=   activecontractr  1	base_tick
quote_tick)amountr  minr   base_minbase_max	quote_min	quote_maxmin_notional)r   rM  r  costcreated_time)
r  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedr/  )r2  splitsafe_currency_coder  safe_numberr8  )r  r:  marketIdparts
marketTyperD  rE  rA  rB  rF  rC  r<  s               r!  parse_marketzwoofipro.parse_market  s   8 ##FH55s##
!!%++""5!,,&&v..''00((22--h7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2"**6;??))&,??    
  ++FJ??++FJ?? 
  ++FK@@++FK@@ 
  ++FNCC  $ ((@@_0
 0
 0
 0	
r"  c                    K   |                      |           d{V }|                     |di           }|                     |dg           }|                     |          S )aB  
        retrieves data on all markets for woofipro

        https://orderly.network/docs/build-on-omnichain/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
        Nr'  rows)v1PublicGetPublicInfor1  	safe_listparse_markets)r  r3  r4  r'  rg  s        r!  fetch_marketszwoofipro.fetch_markets\  sn       33F;;;;;;;;H ~~h33~~dFB//!!$'''r"  c                   K   i }|                      |          }|                     |          }t          j        ||g  d{V \  }}|                     |di           }|                     |dg           }|                     |di           }	|                     |	dg           }
|                     |
d          }t          dt          |                    D ]w}||         }| 	                    |d          }|                     |d          }| 
                    |          }i }t          dt          |                    D ]}||         }| 	                    |d          }|                     ||          }| 	                    |d          }|                     ||          }||ddd	ddd	d
ddd|                     |d          |                     |                     | 	                    |d                              ||gd	||<   |                     |d|ddd|ddddd	|                     |d          dd	d|d          ||<   y|S )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
        Nr'  rg  chain_idr   tokenchain_detailsr,   rN  )r   depositwithdrawal_feedecimals)	r+   networkr]  rH  rp  r   feer\  r/  minimum_withdraw_amount)rp  r   )r+   r,   coder\  rH  rt  networksrp  r   r]  r/  )v1PublicGetPublicTokenv1PublicGetPublicChainInfoasynciogatherr1  ri  index_byrangelenr2  r`  network_id_to_codera  r  parse_precisionsafe_currency_structure)r  r3  resulttokenPromisechainPromisetokenResponsechainResponse	tokenData	tokenRows	chainData	chainRowsindexedChainsirn  
currencyIdrw  rv  resultingNetworksjnetworkEntry	networkId
networkRownetworkNamenetworkCodes                           r!  fetch_currencieszwoofipro.fetch_currencies  s      226::. 66v>>-4^lL=Y-Z'Z'Z'Z'Z'Z'Z$}NN=&"==	NN9fb99	NN=&"==	NN9fb99	i<<q#i..)) 5	 5	AaLE))%99J~~e_==H**:66D&(1c(mm,,  '{ ,,\:FF	!^^M9EE
"..z6BB"55k4HH#* $(#'% %
 $(#'$ $	 	 ## $++L:JKK!%!2!243G3GHXHXYegqHrHr3s3s!t!t):6%2 2!+..(  77 !-   $#   
  $//7PQQ#! !	 	 )9 9  F4LL, r"  c                     |                      ||          }d }|0|                      ||          }|                     |          }||d}|S )NrU  currency)r2  r`  )r  itemfeeTokenKeyfeeAmountKeyfeeCostrt  feeCurrencyIdfeeCurrencyCodes           r!  parse_token_and_fee_tempz!woofipro.parse_token_and_fee_temp  sc    ""466 ,,T;??M"55mDDO+ C 
r"  Ntradec                    d|v }|                      |d          }|                     |d          }|                     ||          }|d         }|                     |d          }|                     |d          }|                     |d          }	|                     |dd          }
|                     |
d	          }|||
d	<   t	          j        ||          }|                     |d
          }|                     |d          }d }|r |                     |d          dk    }|rdnd}|                     |||                     |          ||||||	|d |
|d|          S )Nr+   executed_timestampr<  executed_priceexecuted_quantityorder_id	fee_assetrt  rU  sideis_makerrJ  r   r   )r+   r7  datetimer<  r  r  rM  rU  r   takerOrMakerrG  rt  r/  )	r8  r2  safe_marketr  r&   
string_mulsafe_string_lower
safe_tradeiso8601)r  r  r:  isFromFetchOrderr7  rb  r<  r  rM  r  rt  r  rU  r  r+   r  isMakers                    r!  parse_tradezwoofipro.parse_trade  s   8 !EM%%e-ABB	##E844!!(F33!  (899!!%)<==##E:66++E;FF""3//!CK!%00%%eV44eT**  	;&&uj99S@G&-:777L"Y//( 
  
   	r"  r<  sincer  c                 p  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |di           }|                     |dg           }	|                     |	|||          S )aB  
        get the list of most recent trades for a particular symbol

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr<  r+   r  r'  rg  )load_marketsr:  v1PublicGetPublicMarketTradesextendr1  ri  parse_trades)
r  r<  r  r  r3  r:  requestr4  r'  rg  s
             r!  fetch_tradeszwoofipro.fetch_trades9  s       !!!!!!!!!V$$fTl
 $GG;;DKKQW<X<XYYYYYYYY  ~~h33~~dFB//  vue<<<r"  c                    |                      |d          }|                     |          }|                     |d          }|                     |d          }|                     |d          }|                      |d          }|                      |d          }t          j        ||          }	i d|d|d         dd dd d|                     d	          d
d d|d|                     |          d|                     |d          d|d|                     |          dd dd dd d|                     |d          d|d|                     |          d|                     |	          iS )Nr<  next_funding_timeest_funding_rate_timestamplast_funding_rate_timestampr/  	markPrice
indexPriceinterestRater*  estimatedSettlePricer7  r  fundingRateest_funding_ratefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatelast_funding_ratepreviousFundingTimestamppreviousFundingDatetimeinterval)	r2  r:  r8  r&   
string_subr  r  ra  parse_funding_interval)
r  r  r:  r<  r  estFundingRateTimestamplastFundingRateTimestampfundingTimeStringnextFundingTimeStringmillisecondsIntervals
             r!  parse_funding_ratezwoofipro.parse_funding_rate`  s    !!+x88V$$#00>QRR"&"3"3KA]"^"^#'#4#4[B_#`#`  ,,[:WXX $ 0 0>Q R R&12GIZ[[
K
fX&
 
 $	

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

        https://orderly.network/docs/build-on-omnichain/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>`
        N)fetch_funding_rate)r  r<  r3  s      r!  fetch_funding_intervalzwoofipro.fetch_funding_interval  s0       ,,VV<<<<<<<<<r"  c                 0  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetch the current funding rate

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr<  r+   r'  )r  r:  "v1PublicGetPublicFundingRateSymbolr  r1  r  r  r<  r3  r:  r  r4  r'  s          r!  r  zwoofipro.fetch_funding_rate  s       !!!!!!!!!V$$fTl
 @@WV\A]A]^^^^^^^^  ~~h33&&tV444r"  symbolsc                 "  K   |                                   d{V  |                     |          }|                     |           d{V }|                     |di           }|                     |dg           }|                     ||          S )a  
        fetch the current funding rate for multiple markets

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr'  rg  )r  market_symbolsv1PublicGetPublicFundingRatesr1  ri  parse_funding_rates)r  r  r3  r4  r'  rg  s         r!  fetch_funding_rateszwoofipro.fetch_funding_rates  s       !!!!!!!!!%%g..;;FCCCCCCCC$ ~~h33~~dFB//''g666r"  c           
        K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d||||dd           d{V S i }|(|                     |          }|d         }|d         |d<   |||d	<   |                     d
||d          \  }}|                     |                     ||                     d{V }|                     |di           }	|                     |	dg           }
g }t          dt          |
                    D ]}|
|         }|                     |d          }|                     |d          }|                    ||                     |          |                     |d          ||                     |          d           |                     |d          }|                     ||||          S )a  
        fetches historical funding rate prices

        https://orderly.network/docs/build-on-omnichain/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>`
        NFrq   paginatepage   r<  r+   start_tend_tgMbP?r'  rg  r   funding_rate_timestampfunding_rate)r/  r<  r  r7  r  r7  )r  handle_option_and_params fetch_paginated_call_incrementalr:  handle_until_option#v1PublicGetPublicFundingRateHistoryr  r1  ri  r}  r~  r2  r8  appendsafe_symbolra  r  sort_byfilter_by_symbol_since_limit)r  r<  r  r  r3  r  r  r:  r4  r'  r  ratesr  entryrb  r7  sorteds                    r!  fetch_funding_rate_historyz#woofipro.fetch_funding_rate_history  sV      !!!!!!!!!88AZ\fgg& 	D>>?XZ`bginpvx~  AC  D  D  D  D  D  D  D  D  D[[((FH%F &tGH!&GI227GVUSSAA$++gW]B^B^________( ~~h33fb11q#f++&& 
	 
	A1IE''x88H))%1IJJILL**844#//~FF& LL33      e[1100NNNr"  c           	         |                      |d          }|                     ||          }|                      |d          }|                     d          }|                     |d          }|                     |d          }|                      |d          }	|	dk    rt          j        |          n|}|||||                     |          d |                     |          |dS )	Nr<  funding_feeUSDCupdated_timer  payment_typePay)r/  r<  rv  r7  r  r+   rM  rate)	r2  r  r`  r8  ra  r&   
string_negr  r  )
r  incomer:  rb  r<  rM  rv  r7  r  paymentTypes
             r!  parse_incomezwoofipro.parse_income#  s     ##FH55!!(F33!!&-88&&v..%%fn==	77&&v~>>0;u0D0D#F+++6"Y//''//	
 	
 		
r"  c           	        K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d||||dd           d{V S i }d}| |                     |          }|d         |d<   |||d	<   |                     |d
          }|                     |d
g          }|||d<   |t          |d          |d<   |                     |                     ||                     d{V }	| 	                    |	di           }
| 
                    |
dg           }|                     ||||          S )aV  
        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>`
        NFrm   r  r  r  r+   r<  r  untilr  sizer'  rg  )r  r  r  r:  r8  omitrO  v1PrivateGetFundingFeeHistoryr  r1  ri  parse_incomes)r  r<  r  r  r3  r  r  r:  r  r4  r'  rg  s               r!  fetch_funding_historyzwoofipro.fetch_funding_historyC  s      !!!!!!!!!88AVXbcc& 	A>>?TV\^cejlrtz|  A  A  A  A  A  A  A  A  A[[((F &tGH!&GI!!&'226G9--$GG!%ooGFO;;DKKQW<X<XYYYYYYYY0 ~~h33~~dFB//!!$u===r"  c           
        K   |                                   d{V  |                     |           d{V }|                     |di           }|                     |d          }|                     |d          }i }t	          dt          | j                            D ]g}| j        |         }|||                     t          j	        |d                    |                     t          j	        |d                    ddd||<   h|S )	a|  
        fetch the trading fees for multiple markets

        https://orderly.network/docs/build-on-omnichain/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
        Nr'  futures_maker_fee_ratefutures_taker_fee_rater   10000T)r/  r<  r   r   r   r   )
r  v1PrivateGetClientInfor1  r2  r}  r~  r  r  r&   
string_div)	r  r3  r4  r'  r   r   r  r  r<  s	            r!  fetch_trading_feeszwoofipro.fetch_trading_fees~  s(      !!!!!!!!!44V<<<<<<<<8 ~~h33  '?@@  '?@@q#dl++,, 		 		A\!_F  **7+=eW+M+MNN**7+=eW+M+MNN"! F6NN r"  c           	        K   |                                   d{V  |                     |          }d|d         i}|t          |d          }||d<   |                     |                     ||                     d{V }|                     |di           }|                     |d          }|                     |||dd	d
d          S )aZ  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://orderly.network/docs/build-on-omnichain/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
        Nr<  r+   r  	max_levelr'  r7  bidsasksr  quantity)r  r:  rO  v1PrivateGetOrderbookSymbolr  r1  r8  parse_order_book)	r  r<  r  r3  r:  r  r4  r'  r7  s	            r!  fetch_order_bookzwoofipro.fetch_order_book  s       !!!!!!!!!V$$fTl
 t$$E#(GK 99$++gv:V:VWWWWWWWW$ ~~h33%%dK88	$$T69ffgWabbbr"  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nstart_timestampopenhighlowclosevolume)r8  ra  )r  ohlcvr:  s      r!  parse_ohlcvzwoofipro.parse_ohlcv  s    e%677UF++UF++UE**UG,,UH--
 	
r"  r   	timeframec                   K   |                                   d{V  |                     |          }|d         |                     | j        ||          d}|t	          |d          |d<   |                     |                     ||                     d{V }|                     |di           }	|                     |	dg           }
| 	                    |
||||          S )a  

        https://orderly.network/docs/build-on-omnichain/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
        Nr+   )r<  rG  r  r  r'  rg  )
r  r:  r2  r   rO  v1PrivateGetKliner  r1  ri  parse_ohlcvs)r  r<  r,  r  r  r3  r:  r  r4  r'  rg  s              r!  fetch_ohlcvzwoofipro.fetch_ohlcv  s       !!!!!!!!!V$$Tl$$T_iKK
 
 "5$//GG//GV0L0LMMMMMMMM~~h33* ~~dFB//  vy%GGGr"  r   c                    |                      |g d          }|                     |g d          }|                     |                     |dd                    }|                     |d          }|                     ||          }|d         }|                     |dd          }|                     |dd	          }	|                     |d
d          }
|                     |dd          }|                     |dd          }|                     |d          }||rdnd}| 	                    |d          }|                     |                     |dd                    }|                     |                     |dd                    }t          j        |
|          }|                     |dd          }|                     |dd          }|                     |d          }|                     |d          }d }d }|                     |d          }||                     |d          }|                     |dg           }t          |          }|dk    rX|                     |d          }|                     |d           }|                     |d          }|                     |d          }|                     |d!d"          }|                     i d#|d|d$|d%|                     |          d&d d'|d|                     |          d|d|                     |          d(|                     |          d)d d*|                     |d+          d|d|d|d,|d-|||	|||
|||d.|d/|          S )0N)r7  rV  createdTime)r  orderIdalgoOrderIdclient_order_idclientOrderIdr<  order_pricer  order_quantityr  order_amountrM  
order_typerG  r(  
algoStatussuccessNEWREJECTEDr  executedtotalExecutedQuantityaverage_executed_priceaverageExecutedPrice	total_feetotalFeer  feeAssetTransactionsr   childOrdersr   r   updatedTimer  r+   r7  r  lastTradeTimestamplastUpdateTimestampr   postOnly
reduceOnlyreduce_onlyr   r   r  )averagerM  filled	remainingrU  r   rt  r/  )safe_integer_nsafe_string_n	omit_zerosafe_string_2r2  r  safe_string_lower_2safe_value_2	safe_boolr  r&   r  
safe_valuera  r~  safe_integer_2
safe_orderr  parse_order_statusparse_order_typeparse_time_in_force)r  r   r:  r7  r3  r6  rb  r<  r  rM  rU  	orderTyper(  r<  r  rO  rN  rP  rt  feeCurrencytransactionsr   r   r   rG  firstinnerChildOrdersinnerChildOrdersLengthtakeProfitOrderstopLossOrderrJ  s                                  r!  parse_orderzwoofipro.parse_order  s,   \ ''/[/[/[\\	$$U,R,R,RSSt'9'9%ARTc'd'dee##E844!!(F33!""5-AA##E+;ZHH!!%BB,,UL&II	""5(LAA..	22&7UUZF%%eV44 1 1%E\ ] ]^^..!3!3E;SUk!l!lmm&tV44	{J??((ZHHun==''~>>#!ooe];;"OOK33E#umRHH%()9%:%:"%))"&//2BA"F"F $0@! D D"&"2"2?N"S"S $ 0 0 O O"11%WW  
' 
] 
  
 Y//	 

 !$ 
 "#6 
 d--f55 
 f 
 D)))44 
 433I>> 
  
 $..>> 
 D 
 U 
 L 
  ! 
" ]# 
$ ""'  9 
  
  
: ;  	r"  r   c                 <    dddd}|                      ||d           S )Nr   r   r   )iocfok	post_onlyr  )r  r   timeInForcess      r!  r]  zwoofipro.parse_time_in_force  s1    
 

 k4@@@r"  r(  c           
      P    |#dddddddddd	}|                      |||          S |S )Nr%  closedcanceledrejected)	r=  FILLEDCANCEL_SENTCANCEL_ALL_SENT	CANCELLEDPARTIAL_FILLEDr>  
INCOMPLETE	COMPLETEDr  r  r(  statusess      r!  r[  zwoofipro.parse_order_status  sN    ")#-'"(&$%
 
H ##Hff===r"  rG  c                 <    dddd}|                      |||          S )Nr  r:  )LIMITMARKET	POST_ONLY)r  r  rG  typess      r!  r\  zwoofipro.parse_order_type  s1     
 

 %%eT4888r"  r  rM  r  c                    |                      |dd          }|                                }|                     |          }	|                                }
|	d         |
d}|                     |dd          }|                     |d          }|                     |d          }|d	u}|d	u}|                     |d
          }|d	up|p|p|                     |d          d	u}|dk    }|                     |d          }|                     |d	|          }|rdnd}|rdnd}|rdnd}|||<   |s|rd|d<   n|dk    rd|d<   n|dk    rd|d<   |r||d<   ||                     ||          ||<   |r|s| 	                    ||          ||<   n|dk    r| 	                    ||          ||<   | 
                    |g d          }|||d<   ||                     ||          |d<   d|d<   n|s|rd|d<   |	d         d dg d!}|d"         }|
d#k    rd$nd#}|rI|                     |dd|          }|d|                     ||          d%d&d'}|                    |           |rI|                     |dd|          }|d|                     ||          d%d&d'} |                    |            |g|d"<   |                     |g d(          }|                     ||          S ))aL  
 @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
        rL  rM  r+   )r<  r  r   	stopPricestopLoss
takeProfitNalgoTyperG  r{  r   r  r8  r  r7  rG  r:  r|  ri  r   rh  r   POSITIONAL_TP_SLclOrdIDr6  r5  r5  trigger_priceSTOP	algo_typeTP_SLF)r<  rM  r  child_ordersr  BUYSELLrz  T)r  r  r  rG  rM  )rL  rM  r  r6  r5  rK  r   r  r   r  r  )safe_bool_2upperr:  rT  rX  r2  r  is_post_onlyprice_to_precisionamount_to_precisionrR  safe_number_2r  r  r  )!r  r<  rG  r  rM  r  r3  rL  r^  r:  	orderSider  r   r  r  hasStopLosshasTakeProfitr  isConditionalisMarketr   rK  orderQtyKeypriceKeytypeKeyr6  outterOrderrG  	closeSider   re  r   rd  s!                                    r!  create_order_requestzwoofipro.create_order_request  s     %%flMJJ
JJLL	V$$JJLL	Tl
 
 ))&.+NN??6:66__V\::
t+#4/##FJ77$D0  IK  I=  IUYUdUdekmzU{U{  DH  VH(,,V]CC$$XtV<<$1Gjj7G+>77);&&|$ 	. .(3%%%%(-%%%%(-% 	0%/GM" $ 7 7 F FGH 	LM 	L#'#;#;FF#K#KGK  +++#'#;#;FF#K#KGK **63b3b3bcc$)6G%&#'+'>'>v|'T'TGO$#)GK   	4M 	4#*GK  ,$/ "	! !K &n5K#,#5#5EI 	2 $ 2 28^WV^ _ _%!(%)%<%<V]%S%S##'' ' ""=111 	4"&"4"4ZQXZd"e"e%!(%)%<%<V_%U%U##') ) ""?333'2mGN#6  $B  $B  $B  C  C{{7F+++r"  c                 t  K   |                                   d{V  |                     |          }|                     ||||||          }|                     |dd          }	|                     |d          }
|                     |d          }|	dup|
dup|dup|                     |d          du}d}|r|                     |           d{V }n|                     |           d{V }|                     |d          }|                     |d          |d<   | 	                    ||          }||d	<   |S )
a  
        create a trade order

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/create-order
        https://orderly.network/docs/build-on-omnichain/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>`
        Nr   r  r  r  rG  r'  r7  rG  )
r  r:  r  rT  rX  v1PrivatePostAlgoOrderv1PrivatePostOrderr1  r8  rf  )r  r<  rG  r  rM  r  r3  r:  r  r   r  r  r  r4  r'  r   s                   r!  create_orderzwoofipro.create_order  s     . !!!!!!!!!V$$++FD$vVV))&.+NN??6:66__V\::
$D0  [HD4H  [J^bLb  [gkgvgvw}  @M  hN  hN  VZ  hZ 	>!88AAAAAAAAHH "44W========H  ~~h// --hDD[  v..fr"  r   c           	        K   |                                   d{V  g }t          dt          |                    D ]?}||         }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d          }
|                     |di           }|                     |d	d
          }|                     |d          }|                     |d          }|dup|dup|dup|                     |d          du}|rt          | j        dz             | 	                    ||||	|
|          }|
                    |           Ad|i}|                     |                     ||                     d{V }|                     |di           }|                     |dg           }|                     |          S )a  
        *contract only* create a list of trade orders

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr   r<  rG  r  rM  r  r3  r   r  r  r  rG  z+ createOrders() only support non-stop orderr   r'  rg  )r  r}  r~  r2  rX  r1  rT  r"   r+   r  r  v1PrivatePostBatchOrderr  ri  parse_orders)r  r   r3  ordersRequestsr  rawOrderrb  rG  r  rM  r  orderParamsr   r  r  r  orderRequestr  r4  r'  rg  s                        r!  create_orderszwoofipro.create_ordersB  sE      !!!!!!!!!q#f++&& 	0 	0AayH''(;;H##Hf55D##Hf55D__Xx88FOOHg66E..8R@@K--k>;WWL{J??HlCCJ(4  d8L  dPZbfPf  dkokzkz  |G  IV  lW  lW  _c  lcM \"47-Z#Z[[[44XtT6SXZeffL!!,////n
 55dkk'66R6RSSSSSSSS$ ~~h33~~dFB//  &&&r"  r+   c                   K   |                                   d{V  |                     |          }d|i}	|                     |g d          }
|
|                     ||
          |	d<   |
dup|                     |d          du}|rdnd}|rdnd	}||                     ||          |	|<   ||                     ||          |	|<   |                     |g d
          }d}|r0|                     |                     |	|                     d{V }n|d         |	d<   |	                                |	d<   |	                                }| 
                    |d          }|dk    }|                     |d|          }|rd|	d<   n|dk    rd|	d<   n|dk    rd|	d<   n||	d<   |                     |g d          }|                     |g d          }|||	d<   |                     |                     |	|                     d{V }|                     |di           }|                     |d          |d<   |                     ||          S )a8  
        edit a trade order

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/edit-order
        https://orderly.network/docs/build-on-omnichain/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>`
        Nr  )r   r  r   r   r   rG  r  r8  r  r7  )r  r   r   r   trailingTriggerPricetrailingAmounttrailingPercentr+   r<  r  r   r{  r|  r:  ri  r   rh  r   r  )r  r6  r5  rK  r   r5  r'  r7  )r  r:  rR  r  rX  r  r  v1PrivatePutAlgoOrderr  r  r  r  v1PrivatePutOrderr1  r8  rf  )r  r+   r<  rG  r  rM  r  r3  r:  r  r   r  r  r  r4  r^  r   r  rK  r6  r'  s                        r!  
edit_orderzwoofipro.edit_orderw  s     & !!!!!!!!!V$$
 ))&2s2s2stt#&*&=&=fl&S&SGN#%T1jtv}7]7]ei7i$1Gjj7G+>77 $ 7 7 F FGH#'#;#;FF#K#KGK 6  $b  $b  $b  c  c 	R!77GV8T8TUUUUUUUUHH &tGH"jjllGFO

I00GGK H,H((4@@H 2(3%%%%(-%%%%(-%%(1% ..v7f7f7fggMYYv'q'q'qrrF(-:)* "33DKK4P4PQQQQQQQQH ~~h33 --hDD[f---r"  c                   K   |                      |ddd          }|                     |ddg          }|s|t          | j        dz             |                                  d{V  d}||                     |          }d|d         i}|                     |dd	          }|                     |d
|          }|du}	d}
|r|	rM||d
<   |                     |g d          }|                     | 	                    ||                     d{V }
n||d<   | 
                    | 	                    ||                     d{V }
n|	rM||d
<   |                     |g d          }|                     | 	                    ||                     d{V }
n4||d<   |                     | 	                    ||                     d{V }
d|i}|	r||d
<   n||d<   |r)| 	                    |                     |
          |          S |                     |
di           }| 	                    |                     |          |          S )a  

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/cancel-order
        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/cancel-order-by-client_order_id
        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/cancel-algo-order
        https://orderly.network/docs/build-on-omnichain/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  r6  r5  r  r  r'  )r  r  r   r+   r  r:  rT  r2  v1PrivateDeleteAlgoClientOrderr  v1PrivateDeleteAlgoOrderv1PrivateDeleteClientOrderv1PrivateDeleteOrderrf  r1  )r  r+   r<  r3  r  r:  r  clientOrderIdUnifiedclientOrderIdExchangeSpecificisByClientOrderr4  extendParamsr'  s                r!  cancel_orderzwoofipro.cancel_order  s       ""669eDD6FI#677 	[FN#DG.Y$YZZZ!!!!!!!!![[((FfTl
  $11&)_UU(,(8(8ARTh(i(i%7tC 	Y ]-J)*6+Z+Z+Z[[!%!D!DT[[QXZ`EaEa!b!bbbbbbb&(
#!%!>!>t{{7TZ?[?[!\!\\\\\\\ Y-J)*6+Z+Z+Z[[!%!@!@WV\A]A]!^!^^^^^^^&(
#!%!:!:4;;wPV;W;W!X!XXXXXXX  '/ 	$.KL*++!#L 	I;;t//99<HHH~~h33{{4++D11<@@@r"  idsc                   K   |                                   d{V  |                     |g d          }|                     |g d          }i }d}|rHd                    |          |d<   |                     |                     ||                     d{V }nGd                    |          |d<   |                     |                     ||                     d{V }|                     d|i          gS )a  
        cancel multiple orders

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/batch-cancel-orders
        https://orderly.network/docs/build-on-omnichain/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>`
        N)clOrdIDsclientOrderIdsclient_order_ids,r  	order_idsr/  )r  safe_list_nr  joinv1PrivateDeleteClientBatchOrderr  v1PrivateDeleteBatchOrderrZ  )r  r  r<  r3  r  r  r4  s          r!  cancel_orderszwoofipro.cancel_orders  s1      !!!!!!!!!))&2d2d2dee6#U#U#UVV 	Z*-((>*B*BG&'!AA$++gW]B^B^________HH#&88C==GK !;;DKKQW<X<XYYYYYYYYH H!
    	r"  c                   K   |                                   d{V  |                     |dd          }|                     |ddg          }i }| |                     |          }|d         |d<   d}|r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     d|i          gS )aJ  

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/cancel-all-pending-algo-orders
        https://orderly.network/docs/build-on-omnichain/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>`
        Nr  r  r+   r<  r/  )r  r  r  r:  v1PrivateDeleteAlgoOrdersr  v1PrivateDeleteOrdersrZ  )r  r<  r3  r  r  r:  r4  s          r!  cancel_all_orderszwoofipro.cancel_all_orders-  s#      !!!!!!!!!""669==6FI#677[[((F &tGH 	V!;;DKKQW<X<XYYYYYYYYHH!77GV8T8TUUUUUUUUH" OO  
 	
r"  c                   K   |                                   d{V  d}||                     |          }|                     |ddd          }i }|                     |g d          }|                     |g d          }d}|rl|r5||d<   |                     |                     ||                     d{V }n||d<   |                     |                     ||                     d{V }nk|r5||d<   |                     |                     ||                     d{V }n4||d<   | 	                    |                     ||                     d{V }| 
                    |d	|          }	|                     |	|          S )
a  

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/get-order-by-order_id
        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/get-order-by-client_order_id
        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/get-algo-order-by-order_id
        https://orderly.network/docs/build-on-omnichain/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  r6  r5  r5  oidr'  )r  r:  r  rR  r  (v1PrivateGetAlgoClientOrderClientOrderIdr  v1PrivateGetAlgoOrderOid$v1PrivateGetClientOrderClientOrderIdv1PrivateGetOrderOidr1  rf  )
r  r+   r<  r3  r:  r  r  r6  r4  r   s
             r!  fetch_orderzwoofipro.fetch_orderZ  s       !!!!!!!!![[((F""669eDD**63b3b3bcc6#e#e#eff 	Y ]-:)*!%!N!Nt{{[bdjOkOk!l!lllllll!#!%!>!>t{{7TZ?[?[!\!\\\\\\\ Y-:)*!%!J!J4;;W^`fKgKg!h!hhhhhhh!#!%!:!:4;;wPV;W;W!X!XXXXXXX8 &(;;///r"  c           	      *  K   |                                   d{V  d}|                     |ddd          }|rdnd}|                     |dd          \  }}|r!|                     d||||d	|           d{V S i }d}	|                     |ddg          }| |                     |          }	|	d
         |d<   |||d<   |||d<   n||d<   |rd|d<   |                     d||          \  }}d}
|r0|                     |                     ||                     d{V }
n/| 	                    |                     ||                     d{V }
| 
                    |
d|
          }|                     |d          }|                     ||	||          S )aJ  
        fetches information on multiple orders made by the user

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/get-orders
        https://orderly.network/docs/build-on-omnichain/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>`
        NFr  r  r0   r  r   r  r  r+   r<  r  r  r  r  r  r'  rg  )r  r  r  r  r  r:  r  v1PrivateGetAlgoOrdersr  v1PrivateGetOrdersrX  ri  r  )r  r<  r  r  r3  r  	isTriggermaxLimitr  r:  r4  r'  r   s                r!  fetch_orderszwoofipro.fetch_orders  s     $ !!!!!!!!!$$VVYFF	$.33388PZ[[& 	~>>}fV[]bdjlrt|}}}}}}}}}6FI#677[[((F &tGH!&GI#GFOO&GFO 	*#)GK 227GVLL 	S!88Wf9U9UVVVVVVVVHH!44T[[&5Q5QRRRRRRRRHF x::f--  >>>r"  c                    K   |                                   d{V  |                     |ddi          }|                     ||||           d{V S )J  
        fetches information on multiple orders made by the user

        https://orderly.network/docs/build-on-omnichain/evm-api/restful-api/private/get-orders
        https://orderly.network/docs/build-on-omnichain/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>`
        Nr(  ru  r  r  r  r  r<  r  r  r3  extendedParamss         r!  fetch_open_orderszwoofipro.fetch_open_orders  sp      $ !!!!!!!!!Vh-EFF&&vue^LLLLLLLLLr"  c                    K   |                                   d{V  |                     |ddi          }|                     ||||           d{V S )r  Nr(  rv  r  r  s         r!  fetch_closed_orderszwoofipro.fetch_closed_orders  sp      $ !!!!!!!!!Vh-DEE&&vue^LLLLLLLLLr"  c                 `  K   |                                   d{V  d}||                     |          }d|i}|                     |                     ||                     d{V }|                     |di           }	|                     |	dg           }
|                     |
||||          S )aK  
        fetch all the trades made from a single order

        https://orderly.network/docs/build-on-omnichain/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'  rg  )r  r:  v1PrivateGetOrderOidTradesr  r1  ri  r  )r  r+   r<  r  r  r3  r:  r  r4  r'  r   s              r!  fetch_order_tradeszwoofipro.fetch_order_trades  s       !!!!!!!!![[((F2
 88Wf9U9UVVVVVVVV, ~~h33fb11  vFFFr"  c           	      L  K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d||||dd           d{V S i }d}| |                     |          }|d         |d<   |||d	<   |||d
<   nd|d
<   |                     d||          \  }}|                     |                     ||                     d{V }|                     |di           }	|                     |	dg           }
| 	                    |
||||          S )a  

        https://orderly.network/docs/build-on-omnichain/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>`
        NFr}   r  r  r  r+   r<  r  r  r  r'  rg  )
r  r  r  r:  r  v1PrivateGetTradesr  r1  ri  r  )r  r<  r  r  r3  r  r  r:  r4  r'  r   s              r!  fetch_my_tradeszwoofipro.fetch_my_tradesL  s~      !!!!!!!!!88R\]]& 	{>>PVX]_dflntvyzzzzzzzzz[[((F &tGH!&GI#GFOO!GFO227GVLL00Wf1M1MNNNNNNNN6 ~~h33fb11  vFFFr"  c                    d|i}|                      |dg           }t          dt          |                    D ]~}||         }|                     |                     |d                    }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr/  holdingr   rn  totalfrozen)ri  r}  r~  r`  r2  accountsafe_balance)r  r4  r  balancesr  balancerv  r  s           r!  parse_balancezwoofipro.parse_balance  s    H
 >>(Ir::q#h--(( 	# 	#AqkG**4+;+;GW+M+MNNDllnnG#//CCGG $ 0 0( C CGH"F4LL  (((r"  c                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr'  )r  v1PrivateGetClientHoldingr1  r  r  r3  r4  r'  s       r!  fetch_balancezwoofipro.fetch_balance  sz       !!!!!!!!!77????????  ~~h//!!$'''r"  rv  c                   K   |                                   d {V  i }d }| |                     |          }|d         |d<   |||d<   |||d<   |                     |d          }|                     |d          }|||d<   |                     |                     ||                     d {V }|                     |di           }	||                     |	dg           gS )Nr+   balance_tokenr  pageSizerG  r'  rg  )r  r  r2  r  v1PrivateGetAssetHistoryr  r1  ri  )
r  rv  r  r  r3  r  r  transactionTyper4  r'  s
             r!  get_asset_history_rowszwoofipro.get_asset_history_rows  s     !!!!!!!!!!}}T**H'/~GO$!&GI"'GJ**66::66**&-GFO66t{{7F7S7STTTTTTTT4 ~~h33$..vr::;;r"  r  r  c                    |                      |d          }|                     ||          }|                     ||          }|                     |d          }|                      |d          }|dk    rdnd}|                     |d          }|                     |dd	          }	|                     |                      |d
          ||                      |d          d |                      |d          |                     |                      |d                    |d d |	|||                     |          | 	                    |                      |d                    |d|          S )Nrn  rM  
token_sideDEPOSITinoutrV  	fee_token
fee_amountr+   r  tx_idr(  rG  )r+   r  r  referenceAccountreferenceIdr(  rM  beforeafterrt  	directionr7  r  rG  r/  )
r2  r`  safe_currencyra  r8  r  safe_ledger_entryparse_transaction_statusr  parse_ledger_entry_type)
r  r  r  r  rv  rM  r  r  r7  rt  s
             r!  parse_ledger_entryzwoofipro.parse_ledger_entry  sv   %%dG44
&&z8<<%%j(;;!!$11l33!Y..DDU	%%dN;;	++D+|LL%%""4..''i88 $++D'::33D4D4DT84T4TUU""Y//001A1A$1O1OPP'
 '
  !  	r"  c                 :    ddd}|                      |||          S )Ntransactionr   )BALANCE
COLLATERALr  r}  s      r!  r  z woofipro.parse_ledger_entry_type  s.    $$
 
 tT222r"  c                    K   |                      ||||           d{V }|                     |d          }|                     |d          }|                     |||||          S )a  
        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-omnichain/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-entry-structure>`
        Nr   r   )r  rX  ri  parse_ledger)r  rv  r  r  r3  currencyRowsr  rg  s           r!  fetch_ledgerzwoofipro.fetch_ledger	  su       "88ueVTTTTTTTT??<33~~lA..  xvFFFr"  r  c                    |                      |d          }|                     |d          }|dk    rd}|                     |dd          }|                      |d          }|                      |d          }|                     |d	          }i d
|d|                     |dd          d|                      |d          d|d|                     |          dd d|d|d|                      |d          dd dd d|d|                     |d          d|d|                     |                      |d                    d|                     |d          dd d |d dS ) Nrn  r  r   
withdrawalr   r  target_addresssource_addressrV  r/  r+   withdraw_idtxidr  r7  r  addressaddressFrom	addressTotagextratagFromtagTorG  rM  r  r(  r-  r  comment)internalrt  rs  )r2  r  r  r8  rT  r  ra  r
  )	r  r  r  rv  movementDirectionrt  r  r  r7  s	            r!  parse_transactionzwoofipro.parse_transaction	  s    W55 22;MM
** ,++KlSS$$[2BCC	&&{4DEE%%k>BB	
K
$$$[$FF
 D$$['::
 	

 Y//
 t
 ;
 
 4##K99
 t
 T
 %
 d&&{H==
 
 d33D4D4D[RZ4[4[\\
  t((nEE!
" t#
$ )
 
 
 	
r"  c                 @    dddddd}|                      |||          S )Npendingr+  rn  )r=  
CONFIRMING
PROCESSINGrv  CANCELEDr  rw  s      r!  r
  z!woofipro.parse_transaction_status5	  s7    ##"
 
 &&999r"  c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a-  
        fetch all deposits made to an account

        https://orderly.network/docs/build-on-omnichain/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  Nfetch_deposits_withdrawalsr  r  rv  r  r  r3  r  s         r!  fetch_depositszwoofipro.fetch_deposits?	  sR       I
 44T5%U\^dIeIefffffffffr"  c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a8  
        fetch all withdrawals made from an account

        https://orderly.network/docs/build-on-omnichain/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  WITHDRAWNr,  r.  s         r!  fetch_withdrawalszwoofipro.fetch_withdrawalsP	  sR       J
 44T5%U\^dIeIefffffffffr"  c           	         K   i }|                      ||||                     ||                     d{V }|                     |d          }|                     |d          }|                     |||||          S )a  
        fetch history of deposits and withdrawals

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr   r   )r  r  rX  ri  parse_transactions)	r  rv  r  r  r3  r  r  r  rg  s	            r!  r-  z#woofipro.fetch_deposits_withdrawalsa	  s       !88ueT[[Y`bhMiMijjjjjjjj??<33~~lA.. &&tXueVLLLr"  c                    K   |                      |           d {V }|                     |di           }|                     |d          S )Nr'  r   )v1PrivateGetWithdrawNoncer1  ra  r  s       r!  get_withdraw_noncezwoofipro.get_withdraw_nonce~	  sY      77???????? ~~h33&6777r"  c                 6    d|                      |dd          z   S )N0xkeccakhex)hash)r  messages     r!  hash_messagezwoofipro.hash_message	  s    dii59999r"  c                 6   |                      |dd          |dd          dd           }|d         }|d         }|                     |                     d|d                             }d|                    dd	          z   |                    dd	          z   |z   S )
N	secp256k1rs   vr9  @   r*  )ecdsaint_to_base16sumrjust)r  r<  r   	signaturerB  rC  rE  s          r!  	sign_hashzwoofipro.sign_hash	  s    JJtCDDz:cdd+;[$OO	cNcNtxxIcN;;<<aggb#&&&S)9)99A==r"  c                 d    |                      |                     |          |dd                    S )Nr@  )rL  r>  )r  r=  r   s      r!  sign_messagezwoofipro.sign_message	  s-    ~~d//88*STT:JKKKr"  r  r  c           
        K   |                                   d{V  |                     |           |1|                                }|dk    rt          | j        dz             |                     |          }|                     | j        d          }|                     |d          }|                     |di           }	|                     |	|i           }
| 	                    |
d          }|t          | j        dz             |                     |           d{V }|                                 }|d	|d
d}ddddddddddddddddddddddgi}|                     | j        dd          |                     |          ||t          |          ||d}|                     |||          }|                     || j                  }||||d}|                     |d          }|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        make a withdrawal

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr  z withdraw() only support USDCr   chainIdrw  r+   z% withdraw() require chainId parameterOrderlyrJ  )rP  r,   verifyingContractr1   Withdrawr   string)r,   rG  uint256receiverr  rn  rM  withdrawNonceuint64r7  keyBrokerId	woofi_pro)r   rP  rV  rn  rM  rW  r7  )rK  userAddressrR  r=  r'  )r  check_addressr  r"   r+   r  r2  r   r1  ra  r   r7  nonceparse_to_intstreth_encode_structured_datarN  r   r  v1PrivatePostWithdrawRequestr  r%  )r  rv  rM  r  r  r3  r  r   rP  currencyNetworkscoinNetworkcoinNetworkIdrW  r]  domainmessageTypeswithdrawRequestmsgrK  r  r4  r'  s                         r!  r   zwoofipro.withdraw	  s      !!!!!!!!!7###::<<Dv~~"47-L#LMMM==&&#'#3#3DLB\#]#] ""6955>>(JCCnn%5wCC((d;; TW'NNOOO"55f========

!9	
 
 #X66"I66#Y77 (33!955((;;$h77

 ((}kRR((11&kk*!
 !
 --flOTT%%c4?;;	""!9&	
 
 69--::4;;wPV;W;WXXXXXXXX ~~h33%%dH555r"  c                 J    |                      |d          }||d         d ||dS )Nmax_leverager<  )r/  r<  r   longLeverageshortLeverage)r8  )r  r   r:  leverageValues       r!  parse_leveragezwoofipro.parse_leverage	  s:    ))(NCCX&)*
 
 	
r"  c                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     |di           }|                     ||          S )a  
        fetch the set leverage for a market

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr'  )r  r:  r  r1  rn  )r  r<  r3  r:  r4  r'  s         r!  fetch_leveragezwoofipro.fetch_leverage	  s       !!!!!!!!!V$$44V<<<<<<<<8 ~~h33""4000r"  r   c                    K   |                                   d{V  |dk     s|dk    rt          | j        dz             d|i}|                     |                     ||                     d{V S )a  
        set the level of leverage for a market

        https://orderly.network/docs/build-on-omnichain/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
        Nr   2   z$ leverage should be between 1 and 50r   )r  r   r+   v1PrivatePostClientLeverager  )r  r   r<  r3  r  s        r!  set_leveragezwoofipro.set_leverage
  s       !!!!!!!!!qLLhmmTW'MMNNN
 55dkk'66R6RSSSSSSSSSr"  positionc                    |                      |d          }|                     ||          }|                      |d          }d }t          j        |d          rd}nd}|                      |d          }|                      |d          }|                     |d          }|                      |d	          }	|                      |d
          }
t          j        |          }t          j        ||          }|                     i d|dd d|                      |d          d|d|                     |          dd dd dd dd dd d| 	                    |	          d| 	                    |          dd d| 	                    |
          d| 	                    |          d| 	                    |          dd | 
                    |d          | 	                    |          d d dd |d d d d d          S )Nr<  position_qtyr*  longshortrW  
mark_pricer7  average_open_priceunsettled_pnlr/  r+   r  rJ  initialMargininitialMarginPercentagemaintenanceMarginmaintenanceMarginPercentage
entryPricenotionalr   unrealizedPnl	contractsmarginRatioest_liq_pricecross)liquidationPricer  	lastPrice
collateralr   
marginTyper  r   r   r   r   )r2  r  r&   	string_gtr8  
string_absr  safe_positionr  r  ra  )r  ru  r:  rI  r  r  rW  r  r7  r  unrealisedPnlr  s               r!  parse_positionzwoofipro.parse_position.
  s   . ##Hh77!!(F33.99T3'' 	DDD''??$$X|<<	%%h<<	%%h0DEE
((?CC!$''%dI66!! #
H#
$#
 d&&vx88#
 	#

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

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr<  r+   r'  )r  r:  v1PrivateGetPositionSymbolr  r1  r  r  s          r!  fetch_positionzwoofipro.fetch_positions
  s       !!!!!!!!!V$$fTl
 88Wf9U9UVVVVVVVV6 ~~h//""4000r"  c                    K   |                                   d{V  |                     |           d{V }|                     |di           }|                     |dg           }|                     ||          S )a  
        fetch all open positions

        https://orderly.network/docs/build-on-omnichain/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>`
        Nr'  rg  )r  v1PrivateGetPositionsr1  ri  parse_positions)r  r  r3  r4  r  r   s         r!  fetch_positionszwoofipro.fetch_positions
  s       !!!!!!!!!33F;;;;;;;;N &"55NN66266	##Iw777r"  c                 *    |                                  S N)milliseconds)r  s    r!  r]  zwoofipro.nonce
  s      """r"  r   GETc                 6   |d         }|d         }|                      ||          }	|                     | j        d         |                   }
|
d|z   dz   z  }
|                     ||                     |                    }|                     |          }|dk    r$|
|	z  }
|r|
d|                     |          z   z  }
nT|                                  |dk    s|dk    r|d	k    s|d
k    s|dk    r|                     | j	        dd          }|sp| 
                    | j	        dd          }|dk    rI|                     |dg           }t          dt          |                    D ]}||d         |         d<   n||d<   |                     |          }d}t          |                                           }|
|	z  }
| j        }|                    d          dk     rd|z   }| j        ||d}||z   dz   |z   dz   |	z   }|dk    s|dk    r |                     |          }||z  }d|d<   nE|r6|
d|                     |          z   z  }
|d|                     |          z   z  }d|d<   |dk    rd}| j        }|                    d          dk    r|                    d          }|d         }|                     |                     |          |                     |          d          }|                     |                     |                    |d<   |
|||dS )Nr   r   r   r?  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_credentialsrW  r   r2  ri  r}  r~  r_  r]  r   findr   json	rawencoder   r_  eddsaencodebase58_to_binaryurlencode_base64base64_to_binary)r  pathsectionr  r3  r  r  r1   accesspathWithParamsr   isSandboxModer   
ordersListr  authtsr   r   rc  rK  s                        r!  signzwoofipro.sign
  sv   !*,,T6::##DIe$4V$<==sW}s""64#6#6t#<#<==f%%X>!C 4sT^^F3333++---&  FeOO$,:N:NRVZaRaRaeimzezez $t|]E R R$ 7#//j&QQH},,%)^^FHb%I%I
!&q#j//!:!: H HA?GF8,Q/<<H /7{+f--DTZZ\\""B>!C[F{{:&&**#f,&*n%%' G
 ;$w.4~ED6U??yy((*<'' 93!7!777CC$.."8"888D*M'X%%D[F{{:&&!++Z00q

4;;t#4#4d6K6KF6S6SU^__I+/+@+@AVAVW`AaAa+b+bG'(fdwOOOr"  httpCodereasonr   r  r  r  c
                 P   |sd S |                      |d          }
|                     |d          }|
ss| j        dz   |                     |          z   }|                     | j        d         ||           |                     | j        d         ||           t          |          d S )Nr<  rv   r  r  )rW  r2  r+   r  throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr   )r  r  r  r   r  r  r  r4  requestHeadersrequestBodyr<  	errorCodefeedbacks                r!  handle_errorszwoofipro.handle_errors  s     	4
 ..955$$Xv66	 	*w}tyy':'::H001I4QYZZZ001I9V^___)))tr"  r  )a__name__
__module____qualname__r   r  boolr%  r5  r	   r9  dictr   re  r   rk  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   rf  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
  r/  r2  r-  r7  r>  rL  rN  r   r   rn  rp  intrt  r  r  r   r  r]  r  r  __classcell__)r   s   @r!  r(   r(      s       j# j j j j j jX-t - - - - - - )+ "
 "
 "
 "
H ') 8 8S 8 8 8 8,V
4 V
F V
 V
 V
 V
p *, /( /(V /( /( /( /(b -/ _ _: _ _ _ _B
 
 
= = =v = = = = =~ <@d[] %= %= %=S %= %=bfglbm %= %= %= %=N'
 '
f '
 '
 '
 '
 '
R? ? ? @B 
= 
=3 
=k 
= 
= 
= 
= <>  5  5s  5+  5  5  5  5D <@  7  7  7|  7  7  7  7D >BPTcgpr >O >Os >O# >O]` >O >O >O >O@
 
6 
 
 
 
@ 9=4^bkm 9> 9># 9>S 9>X[ 9> 9> 9> 9>v /1 4 4[ 4 4 4 4l @DB 'c 'cS 'c 'cS\ 'c 'c 'c 'cR
 
 
4 
 
 
 
 ?CQUdhqs ,H ,H ,H ,H3 ,H^a ,Hx|  ~B  yC ,H ,H ,H ,H\n n nv n n n n n`As A A A A     9S 9 9 9 9 os{} W, W,3 W,i W,y W,Z_ W,hk W, W, W, W,r mqy{ B B BI BY BX] Bfi B B B BH FH 3' 3'$|*< 3' 3' 3' 3'j fjx|  FH G. G.3 G. G.9 G.I G._b G.ru G. G. G. G.R 9=R FA FAS FA# FA FA FA FAP AER # #tCy ## # # # #J 59 +
 +
c +
 +
 +
 +
Z 8<B C0 C0C C0 C0 C0 C0 C0J 04$UYbd Q? Q? Q?C Q?s Q?imnsit Q? Q? Q? Q?f 59tZ^gi M Mc M MTW Mnrsxny M M M M, 7;\`ik M M M3 MVY Mptuzp{ M M M M, ?CQUdhqs ,G ,G3 ,G ,G3 ,G^a ,G ,G ,G ,G\ 37TX\eg <G <GC <Gs <GRU <G <G <G <G|) ) ) ) ) *, ( ( ( ( ( (: 8<$]ajl *< *< *<C *<WZ *<qt *< *< *< *<X t x ;    63 3 3 .2SW`b G Gs G# GS Ggklwgx G G G G"
 
T 
X 
Q\ 
 
 
 
B:s : : : : 04$UYbd g g gC gs gimnyiz g g g g" 37TX\eg g gC gs gRU glpq|l} g g g g" <@daenp M MS M M[^ Muy  {F  vG M M M M: /1 8 8 8 8: : :> > >L L L QU]_ K6 K63 K6 K6 K6# K6do K6 K6 K6 K6Z
 
x 
 
 
 
 8: )1 )13 )1h )1 )1 )1 )1V ?C2 T T3 T T T T T&C Ct CV C C C CJ 8: +1 +13 +1 +1 +1 +1Z 8<B 48 48W 484PX> 48 48 48 48l# # # "*%DW[ 6P 6P 6P 6Ppc 3 S # X\ dg        r"  r(   )- ccxt.async_support.base.exchanger   ccxt.abstract.woofipror   rz  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!  <module>r     sl   6 5 5 5 5 5 . . . . . .  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  s  s  s  s  s  s  s  s  s  s  s  s  s  s       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' . . . . . . ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) . . . . . . 4 4 4 4 4 4 % % % % % %G, G, G, G, G,x G, G, G, G, G,r"  