
    i%                        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 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)Balances
CurrenciesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)RateLimitExceeded)	TICK_SIZE)Precisec                       e Zd Z fdZi fdee         fdZdefdZdddi fdede	d	e	dee
         fd
Zd/dede
fdZdi fde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i fdede	d	e	dee         fdZd/dedefdZi fdZi fdZd/dedefdZdefdZi fdefdZdddi fdede	d	e	dee         fdZdddi fdede	d	e	dee         fdZ di fdefdZ!di fdedefdZ"di fdede#de$de%d e&f
d!Z'd/dedefd"Z(d# Z)i fde*fd$Z+i fd%efd&Z,dddi fd%ede	d	e	dee-         fd'Z.d( Z/d/d)e0de-fd*Z1d+d,i ddfd-Z2d. Z3 xZ4S )0wazirxc                    |                      t          t          |                                           dddg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d%dd&dd'dd(dd)di d*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:di d;dd<dd=dd>dd?dd@ddAddBddCddDddEddFddGddHddIddJddKdddddddddLdMdNdOidPdQdRdSdTdUdVdWdVdVdVdVdVdVdVdX	idVdVdVdVdVdWdWdYdYdZdVdVd[d\dWd]d\dVd^d_d`da|                     db          |                     db          dcit
          ddt          t          t          t          t          t          t          t          t          t          t          deidfdgdhdidjdkdldmdndodp
dqi drds          S )tNr!   WazirXINv2  TCORSFspotmarginswapfutureoption	addMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeesfetchTransactionsfetchTransfersfetchWithdrawalsreduceMarginrepayCrossMargin)repayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModetransferwithdrawzehttps://user-images.githubusercontent.com/1294454/148647666-c109c20b-f8ac-472f-91c3-5f658cb90f49.jpegrestzhttps://api.wazirx.com/sapi/v1zhttps://wazirx.comz3https://docs.wazirx.com/#public-rest-api-for-wazirxzhttps://wazirx.com/feesz"https://wazirx.com/invite/k7rrnks5)logoapiwwwdocfeesreferralget   g      ?)	exchangeInfodepthpingsystemStatusztickers/24hrzticker/24hrtimetradesklines   <   )account	allOrdersfundshistoricalTrades
openOrdersordermyTradescoinszcrypto/withdrawszcrypto/deposits/addressz!sub_account/fund_transfer/historyzsub_account/accountsg?)r   z
order/test)r   r   )ry   postdelete)publicprivateWRXz0.0)makertakerexact)z-1121199920022005207820982031211321152136940011m5m30m1h2h4h6h12h1d1w)
r   r   r   r   r   r   r   r   r   r   i'  )
recvWindownetworks)idname	countriesversion	rateLimitprohasurlsrt   rw   precisionMode
exceptions
timeframesoptions)deep_extendsuperr!   describeparse_numberr   r   r   r   r   r   r   )self	__class__s    _/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/wazirx.pyr   zwazirx.describe   s   fd 3 3 < < > >LLL %L 	L
 %L %L UL "4L tL $UL  L tL (L 'L (L  "4!L" #L L$  %L& &u'L( +E)L* )%+L, $U-L. '/L0 (1L2 "43L4 &t5L6 1%7L8  9L: +E;L< &u=L> #E?L@ *5ALB $UCLD "5EL L LF *5GLH +EILJ )%KLL  MLN %eOLP "5QLR +ESLT ULV !%WLX  YLZ d[L\ +E]L^ "4_L` eaLb !$cLd teLf  gL L Lh $UiLj !%kLl %emLn )%oLp tqLr tsLt uLv TwLx tyLz "5{L| #E}L~ 'L@ $UALB !%CLD #DELF GLH #EIL LJ (-$"!&#(!!WL L L\ @< ,L1@	 	 ()!$ !()()'( !"#"#
 
 $%%&!",-&'!$$'!#,.35=>01  "%&) 
 "%&' ' & &P !2!25!9!9DDUDUV[D\D\]] '&&-&,&(&&-)     $ IkA
 kA
 k k k	    returnc                    K   |                      |           d{V }|                     |dg           }|                     |          S )a
  
        :see: https://docs.wazirx.com/#exchange-info
        retrieves data on all markets for wazirx
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Nsymbols)publicGetExchangeInfo
safe_valueparse_markets)r   paramsresponsemarketss       r   fetch_marketszwazirx.fetch_markets   sX       33F;;;;;;;;6 //(Ir::!!'***r   c                    |                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                     |d          }|                     |d          }d }	t          dt	          |                    D ]<}
||
         }|                      |d          }|dk    r|                     |d	          }	=|                     | j        |i           }|                      |d
d          }t          j        |d          }|                      |dd          }t          j        |d          }|                      |d          }i d|d|dz   |z   d|d|dd d|d|dd ddd|ddddddddd|dk    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	baseAsset
quoteAssetisSpotTradingAllowedfiltersr   
filterTypePRICE_FILTERminPricer   z0.2100r   statusr   /basequotesettlebaseIdquoteIdsettleIdtyper(   r)   Fr*   r+   r,   activetradingcontractlinearbaseAssetPrecisionquoteAssetPrecision)amountpriceminmax)leverager   r   cost)inverser   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_coder   rangelensafe_numberrw   r   
string_divr   parse_precision)r   marketr   r   r   r   r   isSpotr   r   jfilterr   feetakerStringmakerStringr   s                    r   parse_marketzwazirx.parse_market   s]   fh//!!&+66""6<88&&v..''00)?@@//&)44q#g,,'' 	@ 	@AQZF))&,??J^++++FJ??oodi33++C%@@(e<<++C%@@(e<<!!&(332
"2
dSj5(2
 D2
 U	2

 d2
 f2
 w2
 2
 F2
 F2
 e2
 E2
 e2
 e2
 v*2
  !2
" d#2
$ &&{33&&{33 "++D,@,@AQAQRXZnAoAo,p,pqq**4+?+?@P@PQWYn@o@o+p+pqq    
 $ 
   
    $ c2
 2
 2
 2	
r   r   Nr   sincelimitc                 
  K   |                                   d{V  |                     |          }|d         |                     | j        ||          d}|t	          |d          |d<   |                     |d          }|                     |dg          }||                     |dz            |d<   |||d	<   |                     | 	                    ||                     d{V }	| 
                    |	||||          S )
a  
        :see: https://docs.wazirx.com/#kline-candlestick-data
        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. Available values [1m,5m,15m,30m,1h,2h,4h,6h,12h,1d,1w]
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in s of the latest candle to fetch
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr   )r   intervali  r  untilr&   	startTimeendTime)load_marketsr   r   r   r   safe_integeromitparse_to_intpublicGetKlinesextendparse_ohlcvs)
r   r   	timeframer  r  r   r   requestr  r   s
             r   fetch_ohlcvzwazirx.fetch_ohlcv4  s0      !!!!!!!!!V$$Tl(()YOO
 
 "5$//GG!!&'226G9--#'#4#4UT\#B#BGK !&GI--dkk'6.J.JKKKKKKKK   69eUKKKr   r   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   rz               )safe_timestampr   )r   ohlcvr   s      r   parse_ohlcvzwazirx.parse_ohlcvW  s    
 q))UA&&UA&&UA&&UA&&UA&&
 	
r   c                 >  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |d          }|                     |||          S )a%  
        :see: https://docs.wazirx.com/#order-book
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :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  	timestamp)r  r   publicGetDepthr  r	  parse_order_book)r   r   r  r   r   r  r   r  s           r   fetch_order_bookzwazirx.fetch_order_bookd  s       !!!!!!!!!V$$fTl
 $GG,,T[[&-I-IJJJJJJJJ %%h<<	$$XvyAAAr   c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||          S )a  
        :see: https://docs.wazirx.com/#24hr-ticker-price-change-statistics
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r   )r  r   publicGetTicker24hrr  parse_ticker)r   r   r   r   r  tickers         r   fetch_tickerzwazirx.fetch_ticker  s       !!!!!!!!!V$$fTl
 //GV0L0LMMMMMMMM    000r   r   c                 4  K   |                                   d{V  |                                  d{V }i }t          dt          |                    D ],}||         }|                     |          }|d         }|||<   -|                     |d|          S )a  
        :see: https://docs.wazirx.com/#24hr-tickers-price-change-statistics
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r   )r  publicGetTickers24hrr   r   r!  filter_by_array_tickers)	r   r   r   tickersresultir"  parsedTickerr   s	            r   fetch_tickerszwazirx.fetch_tickers  s       !!!!!!!!!1133333333$ q#g,,'' 	* 	*AQZF,,V44L!(+F)F6NN++FHgFFFr   c                   K   |                                   d{V  |                     |          }d|d         i}|t          |d          |d<   |                     | j        dd          }d}|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     ||||          S )	a  
        :see: https://docs.wazirx.com/#recent-trades-list
        get the list of most recent trades for a particular symbol
        :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  fetchTradesMethodpublicGetTradesprivateGetHistoricalTrades)	r  r   r   r   r   r/  r  r.  parse_trades)	r   r   r  r  r   r   r  methodr   s	            r   fetch_tradeszwazirx.fetch_trades  s      !!!!!!!!!V$$fTl
 "5$//GG!!$,0CEVWW111!<<T[[RX=Y=YZZZZZZZZHH!11$++gv2N2NOOOOOOOOH   65%@@@r   c                    |                      |d          }|                     |d          }|                     |          }|                     d |          }|                     |d          }|rdnd}|                     |d          }|                     |d          }	|                     |d          }
|                     |||||d	         |d |d ||	|
d d
|          S )Nr   r   isBuyerMakersellbuyr   qtyquoteQtyr   )r   r   r  datetimer   r   r   sidetakerOrMakerr   r   r   r   )r   r	  iso8601safe_marketr   r   
safe_trade)r   trader   r   r  r9  r4  r:  r   r   r   s              r   parse_tradezwazirx.parse_trade  s    eT**%%eV44	<<	**!!$//un==%0vv5  00!!%//z22" X&  
  
   	r   c                    K   |                      |           d{V }|                     |d          }|dk    rdndddd|dS )aD  
        :see: https://docs.wazirx.com/#system-status
        the latest known information on the availability of the exchange API
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
        Nr   normalokmaintenance)r   updatedetaurlr   )publicGetSystemStatusr   )r   r   r   r   s       r   fetch_statuszwazirx.fetch_status  sp       33F;;;;;;;; !!(H55%11dd
 
 	
r   c                 h   K   |                      |           d{V }|                     |d          S )aK  
        :see: https://docs.wazirx.com/#check-server-time
        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        N
serverTime)publicGetTimer	  r   r   r   s      r   
fetch_timezwazirx.fetch_time%  sE       ++F33333333   <888r   c                    |                      |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|          S )Nr   	lastPrice	openPrice	highPricelowPricevolumebidPriceaskPriceatr  r9  highlowbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechange
percentageaverage)
baseVolumequoteVolumer   )r   r=  r	  safe_tickerr<  )r   r"  r   marketIdr   ra  r_  rX  rY  rf  rZ  r\  r  s                r   r!  zwazirx.parse_ticker4  s     ##FH55!!(F33!444444vz22%%fh77
vz22vz22%%fd33	 !
f!
!
 Y//!
 D	!

 3!
 3!
 !
 3!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %)!
 !
 !
* +  	r   c                 p   d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr   r   assetfreelockedused)r   r   r   r   r   safe_balance)r   r   r(  r)  balancer   coder   s           r   parse_balancezwazirx.parse_balancef  s    (#q#h--(( 	# 	#AqkG!!'733B**2..DllnnG"..w??GFO"..wAAGFO"F4LL  (((r   c                    K   |                                   d{V  |                     |           d{V }|                     |          S )a_  
        :see: https://docs.wazirx.com/#fund-details-user_data
        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        N)r  privateGetFundsrr  rM  s      r   fetch_balancezwazirx.fetch_balancer  sg       !!!!!!!!!--f55555555 !!(+++r   c                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|||d<   |||d<   |                     |                     ||                     d{V }|                     ||||          }|                     |d|          }|S )a)  
        :see: https://docs.wazirx.com/#all-orders-user_data
        fetches information on multiple orders made by the user
        :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
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) fetchOrders() requires a symbol argumentr   r   r  r  )r   r   r  r   privateGetAllOrdersr  parse_orders	filter_by)	r   r   r  r  r   r   r  r   orderss	            r   fetch_orderszwazirx.fetch_orders  s       >#DG.Y$YZZZ!!!!!!!!!V$$fTl
 #(GK $GG11$++gv2N2NOOOOOOOO< ""8VUEBB&99r   c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     ||||          }|S )a  
        :see: https://docs.wazirx.com/#current-open-orders-user_data
        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   )r  r   privateGetOpenOrdersr  rx  )	r   r   r  r  r   r  r   r   rz  s	            r   fetch_open_orderszwazirx.fetch_open_orders  s       !!!!!!!!![[((F &tGH224;;w3O3OPPPPPPPP8 ""8VUEBBr   c                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|                     |                     ||                     d{V S )a  
        :see: https://docs.wazirx.com/#cancel-all-open-orders-on-a-symbol-trade
        cancel all open orders in a market
        :param str symbol: unified market symbol of the market to cancel orders in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz- cancelAllOrders() requires a symbol argumentr   r   )r   r   r  r   privateDeleteOpenOrdersr  )r   r   r   r   r  s        r   cancel_all_orderszwazirx.cancel_all_orders  s       >#DG.]$]^^^!!!!!!!!!V$$fTl
 11$++gv2N2NOOOOOOOOOr   r   c                 4  K   |t          | j        dz             |                                  d{V  |                     |          }|d         |d}|                     |                     ||                     d{V }|                     |          S )a~  
        :see: https://docs.wazirx.com/#cancel-order-trade
        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
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentr   )r   orderId)r   r   r  r   privateDeleteOrderr  parse_order)r   r   r   r   r   r  r   s          r   cancel_orderzwazirx.cancel_order  s       >#DG.Y$YZZZ!!!!!!!!!V$$Tl
 
 00Wf1M1MNNNNNNNN)))r   r   r:  r   r   c                 F  K   |                                 }|dk    r|dk    rt          | j        dz             |t          | j        dz             |                                  d{V  |                     |          }|d         ||dd}|                     ||          |d<   |                     |d	          }	|	d|d
<   |                     ||	          |d	<   |                     |                     ||                     d{V }
| 	                    |
|          S )a  
        :see: https://docs.wazirx.com/#new-order-trade
        create a trade 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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  
stop_limitz8 createOrder() supports limit and stop_limit orders onlyNz( createOrder() requires a price argumentr   )r   r:  quantityr   r   	stopPricer   )
lowerr   r   r  r   price_to_precisionr   privatePostOrderr  r  )r   r   r   r:  r   r   r   r   r  r  r   s              r   create_orderzwazirx.create_order  sO      zz||GOO$,"6"6*d deee=*T TUUU!!!!!!!!!V$$Tl	
 
  2265AA$$V[99	 *GFO#'#:#:69#M#MGK ..t{{7F/K/KLLLLLLLL &111r   c                    |                      |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 g d|          S )NcreatedTimeupdatedTimer   r  executedQtyr   r   r   r   r:  r   clientOrderIdr  r9  lastTradeTimestamptimeInForcepostOnlyr   filled	remainingr   )r   re  r   )r	  r   safe_symbolparse_order_statussafe_string_lower
safe_orderr<  )r   r   r   r   rE  ri  r   r   r  r   r   r   r   r:  s                 r   r  zwazirx.parse_order>  s    ##E=99##E=99##E844!!(F33!!%44!!%77(()9)9%)J)JKKeT**  00%%eV44%%eV44  
E 
" 
 T 
 	 

 W-- 
 !' 
 f 
 f 
 D 
 4 
  
 D 
 U 
 f 
 f 
  ! 
" D# 
$ ) 
  
  
* +  	r   c                 <    dddd}|                      |||          S )Nr_  closedcanceled)waitdonecancelr   r   r   statusess      r   r  zwazirx.parse_order_statusm  s1     
 

 &&999r   c                 |  K   |                      d          sdS |                     |           d{V }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |d          }|                     |dg           }	i }
d}d}d}d}d}d}d}t          dt          |	                    D ]}|	|         }|                     |d          }|                     |          }|                     | 	                    |                     |d                              }||nt          ||          }|                     |d	          }|r|n|}|                     |d
          }|r|n|}|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }||||o||||                     |          ||                     |          |                     |          d|                     |          dddd	|
|<   |||||o||||                     |          |ddd|                     |          |                     |          d|                     |          ddd|
d||<   |S )a  
        fetches all available currencies on an exchange
        :see: https://docs.wazirx.com/#all-coins-39-information-user_data
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        FNr   currencyr   networkListnetworkr   depositEnablewithdrawEnablewithdrawFeeminWithdrawAmountmaxWithdrawAmountdepositDustr   )rq   deposit)	r   r   r  r   r  rq   r   r   r   )r   rq   r  )r   rq  r   r   r   r  rq   r   r   r   r   )check_required_credentialsprivateGetCoinsr   r   r   r   	safe_listnetwork_id_to_coder   r   r   	safe_boolr   
string_min)r   r   r   r(  r)  r  
currencyIdrq  r   chainsr   minPrecisionminWithdrawFeeStringminWithdrawStringmaxWithdrawStringminDepositStringr  rq   r   chain	networkIdnetworkCoder   depositAllowedwithdrawAllowedwithdrawFeeStringminNetworkWithdrawStringmaxNetworkWithdrawStringminNetworkDepositStrings                                r   fetch_currencieszwazirx.fetch_currenciesu  sd      ..u55 	4--f55555555^ q#h--(( Q	 Q	A{H))(J??J**:66D##Hf55D^^HmR@@FHL#'  $ $#GH1c&kk** ) )q	 ,,UI>>	"55i@@ --d.B.B4CSCSTY[fCgCg.h.hii	-9-AyyLZcHdHd!%!G!G-;I..'"&..8H"I"I/>M??X$($4$4UM$J$J!$0AUA]+<+<dkdv  xI  K_  e`  e`(+/+;+;ECV+W+W(+7EVE^(@(@elew  yQ  Sd  fe  fe%+/+;+;ECV+W+W(+7EVE^(@(@elew  yQ  Sd  fe  fe%*.*:*:5-*P*P'*6CSC['>'>bibt  vM  O_  c`  c`$!#*,@- /,,->??!* $(#4#45M#N#N#'#4#45M#N#N% %
 $(#4#45L#M#M#'$ $	 	) )%%* ! !.h"$(()=>>)  $# 
  $001BCC#001BCC! !
  $001ABB#     %1 F4LL4 r   rq  c                   K   |                                   d{V  |                     |          }|                     |d          }|                     |d          }|t	          | j        dz             |d         |                     ||          d}|                     |                     ||                     d{V }||                     |d          d|                     ||          |dS )a  
        fetch the deposit address for a currency associated with self account
        :see: https://docs.wazirx.com/#deposit-address-supporting-network-user_data
        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: unified network code, you can get network from fetchCurrencies
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr  z3 fetchDepositAddress() requires a network parameterr   )coinr  address)r  r  tagr  r   )	r  r  r   r
  r   r   network_code_to_idprivateGetCryptoDepositsAddressr  )r   rq  r   r  r  r  r   s          r   fetch_deposit_addresszwazirx.fetch_deposit_address  s      !!!!!!!!!==&&&&vy9969--#DG.c$cdddTN..{DAA
 
 ==dkk'SY>Z>Z[[[[[[[[ '')<<..{DAA
 
 	
r   c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |                     |d          }|                     |dg          }|||d<   |||d<   |                     |                     ||                     d{V }|                     ||||          S )au  
        fetch all withdrawals made from an account
        :see: https://docs.wazirx.com/#withdraw-history-supporting-network-user_data
        :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
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   r  r  r  r  r  )r  r  r	  r
  privateGetCryptoWithdrawsr  parse_transactions)	r   rq  r  r  r   r  r  r  r   s	            r   fetch_withdrawalszwazirx.fetch_withdrawals%  s      !!!!!!!!!}}T**H&tnGFO$GG!!&'226G9--#(GK !&GI77GV8T8TUUUUUUUU& &&x5%HHHr   c                 >    ddddd}|                      |||          S )NrC  failpendingr  )0123r  r  s      r   parse_transaction_statuszwazirx.parse_transaction_statusS  s4    	
 
 &&999r   r  c                 @   |                      |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S )Nr  	createdAtlastUpdatedr   transactionFee)r   r  r   r   txidtxIdr  r9  r  r  	addressToaddressFromr  tagTotagFromr   
withdrawalr   r  rE  )r   internalcomment)r   r   	parse8601r  r   r<  r  )
r   transactionr  r  rq  r  rE  r   feeCostr   s
             r   parse_transactionzwazirx.parse_transaction\  s,   " %%k6::
&&z8<<NN4#3#3K#M#MNN	..!1!1+}!M!MNN..t/?/?X/V/VWW"";0@AA  C
K
$"";55
 D$$[&99
 	

 Y//
 t..t/?/?Y/W/WXX
 t''Y??
 ))+yAA
 4
 4
 T
 t
 L
 d&&{H==
 
  f!
" w#
$ )
 
 
 	
r   r   GETc                 n   | j         d         d         dz   |z   }|dk    r|r|d|                     |          z   z  }|dk    r|                                  |                                 }|                     | j        d         |d|          }	|                     |	          }	|                     |                     |                     |	                    |                     | j	                  t          j                  }
|d|                     |	          z   z  }|d	|
z   z  }d
| j        d}||||dS )Nrt   rr   r   r   ?r   r   )r   r  z&signature=z!application/x-www-form-urlencoded)zContent-Typez	X-Api-Key)rG  r1  bodyheaders)r   	urlencoder  millisecondsr  r   keysorthmacencodesecrethashlibsha256apiKey)r   pathrt   r1  r   r  r  rG  r  data	signatures              r   signzwazirx.sign  s@   iv&,t3(?? 4sT^^F3333)++---))++I;;dl<.HW`aacijjD<<%%D		$++dnnT.B.B"C"CT[[QUQ\E]E]_f_mnnI3----C%	11C C![ G fdwOOOr   c
                     |d S |                      |d          }
|
>| j        dz   |z   }|                     | j        d         |
|           t	          |          d S )Nrq   r   )r   r   throw_exactly_matched_exceptionr   r   )r   rq  reasonrG  r1  r  r  r   requestHeadersrequestBody	errorCodefeedbacks               r   handle_errorszwazirx.handle_errors  sm     4$$Xv66	 w}t+H001I9V^___)))tr   )N)5__name__
__module____qualname__r   r   r	   r   r   strr   listr  r  r   r  r   r#  r   r   r+  r   r2  r@  rI  rN  r!  r   rr  ru  r   r   r{  r~  r  r  r   r   floatr
   r  r  r  r   r  r  r   r  r  r   r  r  r  __classcell__)r   s   @r   r!   r!      s<       l l l l l\ *, #+ #+V #+ #+ #+ #+JF
f F
 F
 F
 F
P 8<$]ajl !L !L !LC !LWZ !Lquvzq{ !L !L !L !LF
 
 
4 
 
 
 
 @DB B BS B BS\ B B B BB 68 1 1 1F 1 1 1 1> 6:" !G !G7 !G !G !G !G !GF <@d[] !A !A !AS !A !Abfglbm !A !A !A !AF" " "5 " " " "H )+ 
 
 
 
. ') 9 9 9 90 06 0V 0 0 0 0d
) 
) 
) 
) 
) *, , , , , , ,( 04$UYbd 5 5 5C 5s 5imnsit 5 5 5 5n 59tZ^gi - -c - -TW -nrsxny - - - -^ 59 P Pc P P P P" 9=R * *S *# * * * *( mqy{ +2 +2 +2I +2Y +2X] +2fi +2 +2 +2 +2Z- - -5 - - - -^: : : -/ K K: K K K KZ =? !
 !
 !
 !
 !
 !
F 37TX\eg ,I ,IC ,Is ,IRU ,Ilpq|l} ,I ,I ,I ,I\: : :2
 2
x 2
; 2
 2
 2
 2
h &eBSW P P P P&      r   r!   )& ccxt.async_support.base.exchanger   ccxt.abstract.wazirxr   r  ccxt.base.typesr   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   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r!    r   r   <module>r     s   6 5 5 5 5 5 , , , , , ,  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h       * * * * * * - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) . . . . . . 4 4 4 4 4 4 % % % % % %W W W W WX{ W W W W Wr   