
    ei!8                    @   d dl mZ d dlmZ d dl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 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) d dl*m+Z+  G d dee          Z,dS )    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesIntLeverage	LeveragesMarginModificationMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTradingFees)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)ExchangeNotAvailable)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdZi fdefdZi fdee	         fdZ
i fdefdZi f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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dee         fdZ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
d
d
i fdedededefdZdDde de	defdZ!i fde"fdZ#d
i fdede$de%de&de'f
dZ(d
i fd Z)d
i fdedefd!Z*d
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
i fdedefd$Z.dDd%e de	de,fd&Z/d
i fdede%de,fd'Z0d
i fdede1fd(Z2i fdede3fd)Z4d
i fd*e5defd+Z6d
i fdefd,Z7i fdede&de8fd-Z9i fdede&de8fd.Z:i fdee	         fd/Z;i fdee	         fd0Z<de"fd1Z=dDd2e de	fd3Z>dDd*e de	de3fd4Z?dDd5e de	defd6Z@dDd7e de	defd8ZAdDde	de8fd9ZBd:d;i d
d
fd<ZCd=e5d>ed?ed@edAe dBefdCZD xZES )Ezebpayreturnc                    |                      t          t          |                                           i ddddddg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d-dd.dd/dd0dd1ddddddddddddd2d3d4d5d6d7d8d9d:d;d<d=d>
d?d@dAdBdCdDdEdCdFdGdHdIdJdKdLdLdLdLdLdLdLdLdLdLdM
idLdLdLdLdLdLdLdLdNdOdLidPdCdQdLidLdLdLdLdLdRdLdLdLdSdTdLdLdLdLdLdLdLdUdLdLdLdLdLdLdVdWdLidXdCdYdZt          d[i d\i d]ddd^d_d`ddgiddadbdcd/dddeiiidft
          t          t          t          t          t          t          t          t          t
          t
          t          t          t          t          dgdht
          idii          S )jNidr'   nameZebpay	countriesIN	rateLimit2   versionv1	certifiedFprohasCORSspotTmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercancelOrdersclosePositioncreateOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeveragesfetchMarketsfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrder)fetchOrderBookfetchOrderTradesfetchPositionsfetchTickerfetchTickersfetchTradesfetchTradingFeereduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage
timeframes            <   x   i  i  i  i`'  )
1m5m15m30m1h2h4h12h1d1wurlszOhttps://github.com/user-attachments/assets/8094e7be-55a7-46f4-a087-0ca31b48ecadzhttps://sapi.zebpay.comzhttps://futuresbe.zebpay.com)r7   r9   zhttps://www.zebstage.comz"https://dev-futuresbe.zebstage.comzhttps://www.zebpay.comz/https://github.com/zebpay/zebpay-api-referencesz&https://zebpay.com/in/features/pricing)logoapitestwwwdocfeesrv   get
   )
zv2/system/timezv2/system/statuszv2/market/orderbookzv2/market/tradeszv2/market/tickerzv2/market/allTickerszv2/ex/exchangeInfozv2/ex/currencieszv2/market/klineszv2/ex/tradefees)zv1/system/timezv1/system/statuszv1/exchange/tradefeezv1/exchange/tradefeeszv1/market/orderBookzv1/market/ticker24Hrzv1/market/marketszv1/market/aggTradezv1/market/klines)r{   postv2/ex/orders)r~   zv2/account/balancezv2/ex/tradefeev2/ex/orderzv2/ex/order/fills)r   r~   zv2/ex/orders/cancelAll)r}   r{   delete)zv1/wallet/balancev1/trade/orderzv1/trade/order/open-orderszv1/trade/userLeverageszv1/trade/userLeveragezv1/trade/positionszv1/trade/history)r   zv1/trade/order/addTPSLzv1/trade/addMarginzv1/trade/reduceMarginzv1/trade/position/closezv1/trade/update/userLeverager   )r{   r}   r   )publicprivateprecisionModerz   commonCurrenciesrequiredCredentials)apiKeysecretoptionstypes)rS   defaultTypefeaturesdefaultlimitd   
exceptions)774004014034044295005033013zOrder quantity is out of rangezInvalid trade order typezInsufficient marginzinsufficient balancezleverage must be in [1,8]zthe request you sent is invalidr   )exactbroad)deep_extendsuperr'   describer$   r   r   r   r!   r"   r#   r    r   )self	__class__s    I/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/zebpay.pyr   zzebpay.describe   sB   fd 3 3 < < > > FA
(FA
HFA
 $FA
 	FA

 tFA
 FA
 5FA
  ... %. 	.
 %. $. T. $U. '. . "4. t. .  . t.  !." &u#. .$ "5%.& +E'.( )%).* #E+., ,U-.. '/.0 (1.2 "43.4 *55.6 +E7.8  9.: !$;.< =.>  ?.@ dA.B "4C.D dE. .F #'$("&# $##' $$)',#[. . .FA
n  oFA
F i5: 
 7@  0H@ GFA
b  .00235020246240202/1     /102465735461324	  	  /!  D +B! -/24.0+-13    ,.,.68# # & 24.0:<68572402    /168245779<>! ! -b#% %( (AI IcFA
v YwFA
x ByFA
z  !{FA
~ "$ $FA
F ff-!  &	 GFA
R  #SFA
` &%.'',//)6B0<+<,=1;7A $ #L% aFA
 FA
 F F F	    c                    d}|                      dd|          \  }}|dk    }d}i }|r|                     |          }|}n,|                     |          }|                     |di           }|                     |dd          }|ddd|dS )a  
        the latest known information on the availability of the exchange API

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#system-status
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/system.md#get-system-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fetchStatusr7   datasystemStatusstatus)r   updatedetaurlinfo)handle_market_type_and_paramspublicSpotGetV2SystemStatuspublicSwapGetV1SystemStatus	safe_dictsafe_string_2)r   paramstypeisSpotresponser   r   s          r   fetch_statuszzebpay.fetch_status   s     99-vVVf&. 	877??HDD77??H>>(FB77D ##D.(CC
 
 	
r   c                 
   d}|                      dd|          \  }}|dk    }d}i }|r|                     |          }|}n,|                     |          }|                     |di           }|                     |d          }|S )a,  
        fetches the current integer timestamp in milliseconds from the poloniexfutures server

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-server-time
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/system.md#get-system-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the poloniexfutures server
        N	fetchTimer7   r   	timestamp)r   publicSpotGetV2SystemTimepublicSwapGetV1SystemTimer   safe_integer)r   r   r   r   r   r   times          r   
fetch_timezzebpay.fetch_time  s     99+tVTTf&. 	855f==HDD55f==H>>(FB77D   {33r   c                 B   g }|                      | j        d          }ddg}|                     |d|          }t          dt	          |                    D ]}||         }|dk    r)|                    |                     |                     9|dk    r)|                    |                     |                     ht          | j	        dz   |z   dz             |}|                     |dg           }	|                     |dg           }
| 
                    |	|
          S )	a  
        retrieves data on all markets for zebpay

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-trading-pairs
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#fetch-markets

        :param dict [params]: extra parameters specific to the exchange api endpoint
        :returns dict[]: an array of objects representing market data
        rS   r7   r9   r   r   z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typerd   )r   r   	safe_listrangelenappendfetch_spot_marketsfetch_swap_marketsr   r*   array_concat)r   r   promisesUnresolvedfetchMarketsOptionsdefaultMarketsr   ir   promisesspotMarketsfutureMarketss              r   fetch_marketszzebpay.fetch_markets1  s=     "nnT\>JJ &)2G^LLq#e**%% 	I 	IA8Dv~~"))$*A*A&*I*IJJJJ"))$*A*A&*I*IJJJJ#DG.[$[^b$b  fH  %H  I  I  I%nnXq"55xB77  m<<<r   c                    |                      |          }|                     |dg           }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |d          }	|                     |                     |                     |d                              }
|                     |dg           }i }d}d}d}d}d}t          dt          |                    D ]X}||         }|                     |d	          }|                     |          }| 	                    |d
          du }|r|n|}| 	                    |d          du }|r|n|}|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }||||o||||                     |          |
|                     |          dd|                     |          dddd	||<   Z|                     ||||	|o||||                     |          |
ddd|                     |          dd|                     |          ddd|d          ||<   |S )aY  
        fetches all available currencies on an exchange

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-coin-settings

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r   r   currencyr+   	precisionchainsNFchainIdisDepositEnabledTisWithdrawEnabledwithdrawalFeewithdrawalMinSizedepositMinSizeminmax)withdrawdeposit)	r   r*   networkactiver   r   feer   limits)amountr   r   )r   coder*   r+   r   r   r   r   r   r   networks)publicSpotGetV2ExCurrenciesr   r   r   safe_stringsafe_currency_codeparse_numberparse_precisionnetwork_id_to_code	safe_boolr%   
string_minsafe_currency_structure)r   r   r   rowsresultr   r   
currencyIdr   r+   r   r   r   minWithdrawFeeStringminWithdrawStringminDepositStringr   r   jchain	networkIdnetworkCodedepositAllowedwithdrawAllowedwithdrawFeeStringminNetworkWithdrawStringminNetworkDepositStrings                              r   fetch_currencieszzebpay.fetch_currenciesL  s    33F;;@ ~~h33q#d))$$ K	 K	AAwH))(J??J**:66D##Hf55D))$*>*>t?O?OPXZe?f?f*g*ghhI^^Hh;;FH#'  $#GH1c&kk** $ $q	 ,,UI>>	"55i@@!%7I!J!Jd!R-;I..'"&..8K"L"LPT"T/>M??X$($4$4UO$L$L!$0AUA]+<+<dkdv  xI  K_  e`  e`(+/+;+;ECV+W+W(+7EVE^(@(@elew  yQ  Sd  fe  fe%*.*:*:5BR*S*S'*6CSC['>'>bibt  vM  O_  c`  c`$!#*,@- /,,->??!* $(#4#45M#N#N#'% %
 $(#4#45L#M#M#'$ $	 	) )%%(  77  !.h"$(()=>>&  $# 
  $001BCC#! !
  $001ABB#     %19 9  F4LL4 r   symbolc                    |                                   |                     |          }d}| d|d         i}|d         rA|                     |                     ||                    }|                     |di           }nV|                     |                     ||                    }|                     |dg           }|                     |d          }|                     ||          S )a  
        fetch the trading fees for a market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-exchange-fee
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/exchange.md#get-trade-fee-single-symbol

        :param str symbol: unified symbol of the market to fetch the order book for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param dict [params.side]: side to fetch trading fee
        :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>`
        Nr   r*   r7   r   r   )load_marketsmarketprivateSpotGetV2ExTradefeeextendr   publicSwapGetV1ExchangeTradefeer   parse_trading_fee)r   r   r   r   r   r   requestresponseDatas           r   fetch_trading_feezzebpay.fetch_trading_fee  s     	V$$fTl
 &> !	366t{{7F7S7STTH >>(FB77DD;;DKKQW<X<XYYH   >>(FB??L>>,22D%%dF333r   c                 f   d}|                      dd|          \  }}d}|dk    r|                     |          }n|                     |          }|                     |dg           }i }t	          dt          |                    D ]*}|                     ||                   }|d         }|||<   +|S )a  
        fetch the trading fees for multiple markets

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/exchange.md#get-trade-fees-all-symbols

        :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fetchTradingFeesr7   r   r   r   )r   publicSpotGetV2ExTradefees publicSwapGetV1ExchangeTradefeesr   r   r   r  )	r   r   r   r   rz   r   r   r   r   s	            r   fetch_trading_feeszzebpay.fetch_trading_fees  s     99:LdTZ[[f6>>66v>>HH<<VDDH ~~h33q#d))$$ 	! 	!A((a11C]F F6NNr   Nr   c           	         |                                   |                     |          }d|d         i}d}|d         r1|||d<   |                     |                     ||                    }n)|                     |                     ||                    }|                     |di           }|                     ||d         dddd	d
          }|                     |d          |d<   |S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-order-book
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-order-book

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        r   r*   Nr7   r   r   bidsasksr   rd   nonce)r   r   publicSpotGetV2MarketOrderbookr  publicSwapGetV1MarketOrderBookr   parse_order_bookr   )	r   r   r   r   r   r  r   bookData	orderbooks	            r   fetch_order_bookzzebpay.fetch_order_book"  s     	V$$fTl
 &> 	Y #(  ::4;;wPV;W;WXXHH::4;;wPV;W;WXXH>>(FB77))(F84DdFTZ\]_`aa	!..xAA	'r   c                 |   |                                   |                     |          }d|d         i}d}|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-ticker
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-24hr-ticker

        :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>`
        r   r*   Nr7   r   )r   r   publicSpotGetV2MarketTickerr  publicSwapGetV1MarketTicker24Hrr   parse_tickerr   r   r   r   r  r   r   s          r   fetch_tickerzzebpay.fetch_tickerK  s     	V$$fTl
 &> 	Z77GV8T8TUUHH( ;;DKKQW<X<XYYH~~h33  v...r   symbolsc                 V   d}|                      dd|          \  }}|dk    rt          | j        dz   |z   dz             |                                  |                     |          }|                     |          }|                     |dg           }|                     ||          S )aQ  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-all-tickers

        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        Nr\   r7   z! fetchTickers() does not support  marketsr   )r   r!   r*   r   market_symbolspublicSpotGetV2MarketAllTickersr   parse_tickers)r   r  r   r   r   
tickerLists         r   fetch_tickerszzebpay.fetch_tickersu  s     99.$PVWWf6>>tw)LLtSV``aaa%%g..77??& ^^Hfb99
!!*g666r   rj   sincec                    |                                   |                     |          }|d}d|d         i}|d         r |                     | j        ||          |d<   n||d<   |d         r|||d<   ||d         r||d	<   n||d
<   |                     |dd          }|||d<   |                     |ddg          }d}	|d         rE||t          | j        dz             |                     | 	                    ||                    }	n)| 
                    | 	                    ||                    }	|                     |	dg           }
|                     |
||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-klinescandlesticks
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#-get-k-lines-ohlcv-data

        :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]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.endtime]: the latest time in ms to fetch orders for
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr   r   r*   r7   intervalcontractr   	startTimer%  untilendtimeendTimezR fetchOHLCV() requires a both a since and until/endtime parameter for spot marketsr   )r   r   r   rc   safe_integer_2omitr   r*   publicSpotGetV2MarketKlinesr  publicSwapPostV1MarketKlinesr   parse_ohlcvs)r   r   	timeframer%  r   r   r   r  r*  r   r   s              r   fetch_ohlcvzzebpay.fetch_ohlcv  s    	V$$=EfTl
 &> 	,"&"2"24?Iy"Y"YGJ"+GJ* 	%5#4$GGf~ )',$$#( ##FGY??!&GIYYv	7';<<F&> 	W}'  3G  )G  H  H  H77GV8T8TUUHH88Wf9U9UVVH@ ~~h33  vy%GGGr   c                    |                                   |                     |          }d|d         i}|d         r|||d<   d}|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |dg           }|                     ||||          S )a  
        get the list of most recent trades for a particular symbol

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-recent-trades
        https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-aggregate-trades

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        r   r*   r7   Nr   r   )r   r   publicSpotGetV2MarketTradesr  publicSwapGetV1MarketAggTrader   parse_trades)	r   r   r%  r   r   r   r  r   r   s	            r   fetch_tradeszzebpay.fetch_trades  s     	V$$fTl
 &> 	%e/$GG&> 	X77GV8T8TUUHH99$++gv:V:VWWH ~~h33  vue<<<r   c                    |                                   d}||                     |          }d}|                     d||          \  }}d}|dk    rt          | j        dz             |                     |          }|                     |di           }|                     |dg           }	|                     |	|||          S )ac  
        get the list of most recent trades for a particular symbol

        https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-trade-history

        :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>`
        NrT   r7   z. fetchMyTrades() does not support spot marketsr   items)	r   r   r   r!   r*   privateSwapGetV1TradeHistoryr   r   r7  )
r   r   r%  r   r   r   r   r   r   r:  s
             r   fetch_my_tradeszzebpay.fetch_my_trades  s     	[[((F99/6SYZZf6>>tw)YYZZZ88@@H~~h33tWb11  u===r   r*   c                 `   d}|                      dd|          \  }}|dk    rt          | j        dz   |z   dz             |                                  d|i}|                     |                     ||                    }|                     |di           }	|	g}
|                     |
          S )aW  
        fetch all the trades made from a single order

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-order-fills

        :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>`
        NrY   r7   z% fetchOrderTrades() does not support r  orderIdr   )r   r!   r*   r   privateSpotGetV2ExOrderFillsr  r   r7  )r   r*   r   r%  r   r   r   r  r   r   tradess              r   fetch_order_tradeszzebpay.fetch_order_trades,  s     99:LdTZ[[f6>>tw)PPSWWZddeeer
 44T[[&5Q5QRR$ ~~h33  (((r   trader   c                 b   |                      |dd          }|                      |dd          }|                     |dd          }|                     |d          }|                     ||d          }|d         }|                     |d          }|                     |d	          }	|                      |d
d          }
|                     ||||                     |          |||                     |d          |d |	|
|                     |d          |                     |d          d|          S )Nr*   aggregateTradeIdorderr   	tradeTimer   _sidepricer   quantityr   costr   )r*   r   r   datetimer   rE  r   rH  takerOrMakerrI  r   rK  r   )r   r-  r   safe_marketsafe_string_lower
safe_tradeiso8601r   )r   rB  r   r*   r>  r   marketIdr   rH  priceStringamountStrings              r   parse_tradezzebpay.parse_tradeW  sH   B t-?@@$$UD'::''{KHH	##E844!!(FC88!%%eV44&&ug66))%:FF"Y//**5&99  "$$UF33>>%// 
  
   	r   c                     |                                   d}|                     dd|          \  }}|dk    }d}|r|                     |          }n|                     |          }|                     |          S )a4  
        query for balance and get the amount of funds available for trading or funds locked in orders

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-account-balance
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/wallet.md#get-wallet-balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        NrE   r7   )r   r   privateSpotGetV2AccountBalanceprivateSwapGetV1WalletBalanceparse_balance)r   r   r   r   r   s        r   fetch_balancezzebpay.fetch_balance  s     	99.$PVWWf&. 	B::6BBHH99&AAH& !!(+++r   r   rH  r   rI  c                 &   |                                   |                     |          }|                                }|                     |d          }	|                     |d          }
|                     |g d          }|d         |                                d}d}|d         rH|                     ||||||          \  }}|                     |                     ||                    }nu|                     |dd	          }|                     |d
d          }||d
<   | 	                    | 
                    |d         |                    |d<   ||d<   |	du}|
du}|s|r|r,| 	                    |                     ||	                    |d<   |r,| 	                    |                     ||
                    |d<   |                     |                     ||                    }ny||d<   |dk    rE|t          | j        dz             | 	                    |                     ||                    |d<   |                     |                     ||                    }|                     |di           }|                     ||          S )a  
        Create an order on the exchange

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#place-new-order
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#--create-order

        :param str symbol: Unified CCXT market symbol
        :param str type: 'limit' or 'market'
        :param str side: 'buy' or 'sell'
        :param float amount: the amount of currency to trade
        :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 str [params.formType]: The price at which a trigger order is triggered at
        :param str [params.marginAsset]: The asset the order creates, default is INR.
        :param boolean [params.takeProfit]: Takeprofit flag for the order.
        :param boolean [params.stopLoss]: Stop loss flag for the order.
        :param str [params.positionId]: PositionId of the order.
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        takeProfitPricestopLossPrice)marginAssetr\  r\  r*   )r   rH  Nr7   r^  INRformType
ORDER_FORMr   r   r   z9 createOrder() requires a price argument for limit ordersrI  r   )r   r   upperr   r.  order_requestprivateSpotPostV2ExOrdersr  safe_string_upperparse_to_numericamount_to_precisionprice_to_precision"privateSwapPostV1TradeOrderAddTPSLr   r*   privateSwapPostV1TradeOrderr   parse_order)r   r   r   rH  r   rI  r   r   upperCaseTyper\  r]  r  r   r^  r`  hasTPhasSLr   s                     r   create_orderzzebpay.create_order  s   ( 	V$$

**63DEE((AA6#X#X#XYYTlJJLL
 
 &> 	Z"00vwPUW]^^OGV55dkk'66R6RSSHH**6=%HHK--fj,OOH"*GJ $ 5 5d6N6NvVZ|]c6d6d e eGH%0GM"#4/E!-E Z Z y151F1FtG^G^_egvGwGw1x1xG-. u/3/D/DTE\E\]cerEsEs/t/tGO,BB4;;wX^C_C_``"/7??}/:u0uvvv'+'<'<T=T=TU[]b=c=c'd'dGG$;;DKKQW<X<XYY ~~h33f---r   c                 j   |                                 }|                     |dd           }|                     |ddd           }	|                     |dd          }
|                     |d|                                           }|                     |g d          }||d<   ||d<   |
|d<   |d	k    r3|	t          | j        d
z             |                     ||	          |d<   nM||                     ||          |d<   | 	                    ||          |d<   |                     ||          |d<   ||gS )Nr]  quoteOrderQtyrK  timeInForceGTCclientOrderId)r]  rK  rr  rt  r   MARKETz* spot market orders require cost in paramsquoteOrderAmountr   rI  )
rb  r   r   uuidr.  r   r*   cost_to_precisionrh  rg  )r   r   r   r   r  rI  r   rl  triggerPricerq  rr  rt  s               r   rc  zzebpay.order_request  sP   

''FF**6?FDQQ&&v}eDD(($))++NN6#\#\#\]]'#0 !,H$$$#DG.Z$Z[[[*.*@*@*W*WG&'''+/+B+B6<+X+X( $ 8 8 H HGH#66vuEEGG  r   c                    |                                   |                     |          }d}i }|d         r/||d<   |                     |                     ||                    }nh|                     |d          }|t          | j        dz             ||d<   |d         |d<   |                     |                     ||                    }|                     | 	                    |d                    S )	a  
        cancels an open order

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#cancel-order
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-cancel-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 dict [params.timestamp]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr7   r>  rt  zA cancelOrder() requires a clientOrderId parameter for swap ordersr*   r   r   )
r   r   privateSpotDeleteV2ExOrderr  r   r   r*   privateSwapDeleteV1TradeOrderrk  r   )r   r*   r   r   r   r   r  rt  s           r   cancel_orderzzebpay.cancel_order  s     	V$$&> 		X!#GI66t{{7F7S7STTHH ,,V_EEM$'2u(uvvv'4GO$ &tGH99$++gv:V:VWWH x @ @AAAr   c                 0   d}|                      dd|          \  }}|dk    rt          | j        dz   |z   dz             |                                  |                     |          }|                     |di           }|                     |          }|gS )a  
        cancels all open orders

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#cancel-all-orders

        :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 dict [params.timestamp]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr@   r7   z$ cancelAllOrders() does not support r  r   )r   r!   r*   r   $privateSpotDeleteV2ExOrdersCancelAllr   rk  )r   r   r   r   r   r   parsedOrders          r   cancel_all_orderszzebpay.cancel_all_orders3  s     99:KTSYZZf6>>tw)OORVVYccddd<<VDD ~~h33&&t,,}r   c                 B   |                                   |                     |          }d|d         i}d}g }|d         rdd|d<   |||d<   |                     |                     ||                    }|                     |di           }	|                     |	d	g           }ne|||d
<   |||d<   |                     |                     ||                    }|                     |di           }	|                     |	dg           }|                     ||d|          S )a  
        fetches information on multiple open orders made by the user

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-orders
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-open-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
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        r   r*   Nr7   rd   currentPagepageSizer   r:  r%  r   )r   r   privateSpotGetV2ExOrdersr  r   r   $privateSwapGetV1TradeOrderOpenOrdersparse_orders)
r   r   r%  r   r   r   r  r   ordersr  s
             r   fetch_open_orderszzebpay.fetch_open_ordersP  s>    	V$$fTl
 &> 	>%&GM" &+
#44T[[&5Q5QRRH>>(FB??L^^L'2>>FF #(  #( @@WV\A]A]^^H>>(FB??L^^L&"==F4   u===r   c                 ~   |                                   |                     |          }i }d}|d         r/||d<   |                     |                     ||                    }n.||d<   |                     |                     ||                    }|                     |d          }|                     ||          S )a  
        fetches information on an order made by the user

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-order-details
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-order-details

        :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 str [params.clientOrderId]: cancel order by client order id
        :param str [params.timestamp]: cancel order by client order id
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr7   r>  r*   r   )r   r   privateSpotGetV2ExOrderr  privateSwapGetV1TradeOrderr   rk  )r   r*   r   r   r   r  r   r  s           r   fetch_orderzzebpay.fetch_order  s     	V$$&> 	U!#GI33DKK4P4PQQHHGDM66t{{7F7S7STTH4 ~~h77f555r   rE  c           
         |                      |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|          }|S )Nr   r   r   rI  rH  r   rt  rr  r   r>  r*   postOnly
reduceOnlyry  rK  filled	remainingrL  r   )r   r   lastTradeTimestamplastUpdateTimestampaverager@  )r   rN  safe_numberrQ  rO  
safe_order)r   rE  r   rR  r   r   r   rL  rI  rH  r   rt  rr  r   r>  r  s                   r   rk  zzebpay.parse_order  s   $ ##E844!!(F33!v..$$UK88	<<	**  00v..!!%22((@@&&um<<''x88""5)T::oo '
''
]'
 f'
 D	'

 ;'
 '
 $'
 D'
 f'
 U'
 D'
 D'
 d'
 '
 '
  !'
" 4#'
$ "&#'/'
 '
 '
0 1 2 r   c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )a5  
        closes open positions for a market

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-close-position

        :param str symbol: Unified CCXT market symbol
        :param str side: not used by kucoinfutures closePositions
        :param dict [params]: extra parameters specific to the okx api endpoint
        :param str [params.positionId]: client order id of the order
        :returns dict[]: `A list of position structures <https://docs.ccxt.com/?id=position-structure>`
        r   r*   r   )r   r   #privateSwapPostV1TradePositionCloser  r   rk  )r   r   rH  r   r   r  r   r   s           r   close_positionzzebpay.close_position  s     	V$$fTl
 ;;DKKQW<X<XYY~~h33f---r   c                     |                                   |                     |          }|                     |dg           }|                     ||d          S )a  
        fetch the set leverage for all contract and margin markets

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-all-user-leverages

        :param str[] [symbols]: a list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `leverage structures <https://docs.ccxt.com/?id=leverage-structure>`
        r   r   )r   "privateSwapGetV1TradeUserLeveragesr   parse_leverages)r   r  r   r   leveragePreferencess        r   fetch_leverageszzebpay.fetch_leverages  sZ     	::6BB #nnXvrBB##$7(KKKr   c                 8   |                                   |                     |          }d|d                                         i}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        fetch the set leverage for a market

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#get-user-leverage-single-symbol

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage structure <https://docs.ccxt.com/?id=leverage-structure>`
        r   r*   r   )r   r   rb  !privateSwapGetV1TradeUserLeverager  r   parse_leverager  s          r   fetch_leveragezzebpay.fetch_leverage,  s     	V$$fTl((**
 99$++gv:V:VWW ~~h33""4000r   leveragec                     |t          | j        dz             |                                  |                     |          }||d         d}|                     |                     ||                    }|S )a  
        set the level of leverage for a market

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-update-user-leverage

        :param float 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
        Nz) setLeverage() requires a symbol argumentr*   )r  r   )r   r*   r   r   (privateSwapPostV1TradeUpdateUserLeverager  )r   r  r   r   r   r  r   s          r   set_leveragezzebpay.set_leverageD  s     >#DG.Y$YZZZV$$ Tl
 
 @@WV\A]A]^^r   c                 <   |                                   i }||                     |          |d<   |                     |                     ||                    }|                     |dg           }|                     |          }|                     |d|d          S )ao  

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#--get-positions

        Fetches current contract trading positions
        :param str[] symbols: List of unified symbols
        :param dict [params]: Not used by krakenfutures
        :returns: Parsed exchange response for positions
        Nr  r   r   F)r   
market_idsprivateSwapGetV1TradePositionsr  r   parse_positionsfilter_by_array_positions)r   r  r   r  r   	positionsr   s          r   fetch_positionszzebpay.fetch_positions]  s     	!%!9!9GI66t{{7F7S7STT NN8VR88	%%i00--fhOOOr   c                 D   |                                   |                     |          }|d         |d}|                     |                     ||                    }|                     |di           }|                     |                     ||          |dd          S )aF  
        add margin

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-add-margin-to-position

        :param str symbol: unified market symbol
        :param float amount: amount of margin to add
        :param dict [params]: extra parameters specific to the exchange API endpoint.
        :param str [params.positionId]: PositionId of the order to add margin.
        :param str [params.timestamp]: Tiemstamp.
        :returns dict: a `margin structure <https://docs.ccxt.com/?id=margin-structure>`
        r*   r   r   r   inr   	direction)r   r   privateSwapPostV1TradeAddMarginr  r   parse_margin_modificationr   r   r   r   r   r  r   r   s           r   
add_marginzzebpay.add_margin}  s     	V$$Tl
 
 77GV8T8TUU& ~~h33{{499$GGJ
 J
   	r   c                 D   |                                   |                     |          }|d         |d}|                     |                     ||                    }|                     |di           }|                     |                     ||          |dd          S )aM  
        add margin

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-reduce-margin-from-position

        :param str symbol: unified market symbol.
        :param float amount: amount of margin to add.
        :param dict [params]: extra parameters specific to the exchange API endpoint.
        :param str [params.positionId]: PositionId of the order to add margin.
        :param str [params.timestamp]: Tiemstamp.
        :returns dict: a `margin structure <https://docs.ccxt.com/?id=margin-structure>`
        r*   r  r   outr  )r   r   "privateSwapPostV1TradeReduceMarginr  r   r  r  s           r   reduce_marginzzebpay.reduce_margin  s     	V$$Tl
 
 ::4;;wPV;W;WXX ~~h33{{499$GGJ
 J
   	r   c                 *   |                      |          }g }|                     |di           }|                     |dg           }t          dt	          |                    D ].}||         }|                     |d          }|                     |d          }	|                     |d          }
|                     |	          }|                     |
          }|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!           0|S )"Nr   r  r   r   	baseAsset
quoteAsset/r*   basequotebaseIdquoteIdr   r7   Tr9   Fr8   r:   r;   r   r(  takertakerFeemakermakerFeestrikelotSztickSzr   rI  r   )r   rI  rK  
optionTyper   r   r   )	publicSpotGetV2ExExchangeInfor   r   r   r   r   r   r   r  )r   r   r   r   r   marketsr   r   r*   r  r  r  r  r   s                 r   r   zzebpay.fetch_spot_markets  s{   55f==& ~~h33..y"55q#g,,'' .	 .	AQZF!!&(33B%%fk::F&&v|<<G**622D++G44ECZ%'FMM &b&&& & 	&
 && 7& & & & %& %& %& $& D& ))&*==&  ))&*==!&" $#&$ #"..vw??!--fh??   $# 
  $# 
  $#   K& & & & & & &N r   c                    |                      |          }g }|                     |di           }|                     |dg           }t          dt	          |                    D ]}||         }|                     |d          }|                     |d          }	|                     |d          }
|                     |	          }|                     |
          }|                     |
          }|                     |d          }|dz   |z   }|                    |                     i d	|d|d
z   |z   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%i|d&                     |S )'Nr   r  r   r   r  r  r   r  r*   :r  r  r  r  r7   Fr8   r9   Tr:   r   r;   r   Openr(  r  r  r  r  r  r  r  r  r  minLeveragemaxLeverager   r  )
publicSwapGetV1MarketMarketsr   r   r   r   r   r   r   safe_market_structurer  )r   r   r   r   r   r  r   r   r*   r  r  r  r  settler   r   s                   r   r   zzebpay.fetch_swap_markets  s   44V<<0 ~~h33..y"55q#g,,'' (	 (	AQZF!!&(33B%%fk::F&&v|<<G**622D++G44E,,W55F%%fh77FCZ%'FMM$44 6b6&3,/6 6 	6
 &6 76 6 %6 6 %6 6 %6 6V+6 D6 ))&*==6  ))&*==!6" $#6$ #"..vw??!--fh?? 
 #//FF#//FF! ! ;6 6 6      > r   c                    |d d d}|                      |dg           }t          dt          |                    D ]}||         }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d<   |                     |d          }|                     |          }|||<   |                     |          S )N)r   r   rL  r   r   totalfreeusedr   )r   r   r   accountr   r   safe_balance)	r   r   r   currencyListr   entryr  r   r   s	            r   rY  zzebpay.parse_balance^  s    
 

 ~~h;;q#l++,, 	# 	#A OEllnnG#//w??GG"..uf==GFO"..uf==GFO))%<<J**:66D"F4LL  (((r   positionc                 h   |                      |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S )Nr  rL  r   r   r   initialMargininitialMarginPercentagemaintenanceMarginmaintenanceMarginPercentage
entryPricenotionalunrealizedPnl	contractscontractSizemarginRatioliquidationPrice	markPriceisolatedrH  )
collateral
marginTyperH  
percentage)r  r   rN  	parse8601)r   r  r   r  rL  rR  s         r   parse_positionzzebpay.parse_positionp  s    ##Hj99##Hj99##Hh77!!(F33
H
h
 11
 	

 T--hHH
 &t
  
 *4
 $**8\BB
 ((:>>
 
 T
 ))(K@@
 D,,V^DD
 4
   0 0;M N N!
" #
$ $$$Xv66+
 
 
 	
r   c                     |                      |d          }|                     |d          }|                     |d          }|                     |d          }|                      |d          }|||||dS )Nr   r   longLeverageshortLeverage
marginMode)r   r   r  r  r  )r   r   r   )r   r  r   rR  r   leverageValueleverageValueShortr  s           r   r  zzebpay.parse_leverage  s    ##Hh77~~h//))(NCC!..xII%%h==
$)/
 
 	
r   r   c                     |                      |d          }|                     ||          }|||                     |dd          |                     |dd          d d dS )Nr   makerFeeRater  takerFeeRater  )r   r   r  r  r  	tierBased)r   safe_symbolsafe_number_2)r   r   r   rR  r   s        r   r  zzebpay.parse_trading_fee  sq    ##C22!!(F33''^ZHH''^ZHH
 
 	
r   tickerc           	         |                      |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|          S )Nr   tsr   closelastr  	bidVolume	askVolumer*   rL  highlowbidaskvwapopenpreviousClosechanger  
baseVolumequoteVolume)r  r  r  r  r   )r-  r   rN  safe_tickerrQ  )
r   r   r   r   rR  r  r  r  r  r  s
             r   r  zzebpay.parse_ticker  s]   & ''T4HH	##FH55!!(++  $7755%%fl;;
$$V[99	$$V[99	 !
(!
fX&!
 !
 Y//	!

 D$$VV44!
 4##FE22!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D!
 U!
 D!
 T--foFF!
  d&&vx88!!
" *#!
$ ''	::**6<@@++FMBB-!
 !
 !
. /  	r   c                     |                                  }||d         d d |                     |d          d |                     |d          |                     |d          ||                     |          d
S )Nr*   r   r   r   )
r   r   r   r  r   r  r   r   r   rL  )millisecondsr  r   rQ  )r   r   r   r   s       r   r  z zebpay.parse_margin_modification  s     %%''	Tl&&tX66$$T622&&tX66"Y//
 
 	
r   r   GETc                 R   |                      |d          }|                    d          dk    }|rdnd}| j        d         |         }	d|                     ||          z   }
|	|
z  }	t	          |                                           }d}|                      ||                     |                    }|}|                     |d	d
          }|d
k    rF|dk    s|dk    r|r|	d|                     |          z   z  }	n%t          j
        |          }ddd}n
|                                  |dk    }||d<   |dk    s|dk    rm|rk|                     |          }|                     |                     |          |                     | j                  t          j        d          }|	d|z   z  }	nb| 	                    |          }|                     |                     |          |                     | j                  t          j        d          }d| j        |d}d|d<   |	|||dS )Nr   zv1/r9   r7   rv   z/api/ r   r   r  DELETE?ccxtzapplication/json)ReferrerContent-Typer   hex)r  zX-AUTH-APIKEYzX-AUTH-SIGNATUREr  )r   methodbodyheaders)r.  findrt   implode_paramsstrr  extract_paramsr   	urlencodejsondumpscheck_required_credentialshmacencoder   hashlibsha256r   )r   pathrv   r  r   r   r  isV1
marketTyper   tailr   	signaturequeryqueryLengthaccessr   queryStrings                     r   signzzebpay.sign  sC   6=11yy"$#/VV
iz*,,T6:::t))++,,				&$"5"5d";";<<!!#q(33X&H"4"4 73!6!666Cz&)) &$6 
 ++---6)F"+F;6X#5#5&#5"nnV44 IIdkk+&>&>DK@X@XZaZhjopp	s[(( yy(( IIdkk$&7&7T[9Q9QSZSachii	"!%$- G
 '9GN#fdwOOOr   r   reasonr   r  r   r  c
                    |s$|                      | j        d         ||           d S |                     |dd          }
|                     |dd          }| j        dz   |z   }|                      | j        d         ||           |                     | j        d         ||           |                     | j        d         |
|           d S )Nr   r   
statusCodemsgstatusDescription r   )throw_broadly_matched_exceptionr   r   r*   throw_exactly_matched_exception)r   r   r7  r   r  r   r  r   requestHeadersrequestBody	errorCodemessagefeedbacks                r   handle_errorszzebpay.handle_errors)  s     	001I4QUVVV4 &&xFF	$$Xu6IJJ7S=7*,,T_W-EwPXYYY,,T_W-EwPXYYY,,T_W-EyRZ[[[tr   )N)F__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r   r#  r   r  r   r  r   r  r   r  r   r   r$  listr3  r   r8  r   r<  rA  dictrU  r   rZ  r   r   floatr   ro  rc  r}  r  r   r  r  rk  r  r
   r  r	   r  intr  r  r   r  r  r   r   rY  r  r  r  r  r  r6  rD  __classcell__)r   s   @r   r'   r'      s       G# G G G G G GR #% '
 '
 '
 '
R !# ! !s ! ! ! !F $& = =$v, = = = =6 ') w wZ w w w wr 57 54 54 54;N 54 54 54 54n )+ $ ${ $ $ $ $L :>b ' 's '3 'Y ' ' ' 'R 02 (/ (/3 (/f (/ (/ (/ (/T 04B $7 $7W $77 $7 $7 $7 $7L 26DW[df LH LH# LHc LHQT LHkoptku LH LH LH LH\ 6:UW &= &=3 &=s &=# &=\`af\g &= &= &= &=P -1tRV_a > >c > >C >fjkpfq > > > >6 9=4^bkm )) ))S ))# ))S ))X[ )) )) )) ))V8 8 8v 8 8 8 8 8t $& %, %,( %, %, %, %,N gksu ?. ?.3 ?.i ?.y ?.RW ?.`c ?. ?. ?. ?.B BFb ! ! ! !* 37r #B #Bs #BC #B #B #B #BJ /32      : /3TXac <> <> <>3 <>c <>hlmrhs <> <> <> <>| 26b 26 26c 263 26 26 26 26h8 8 8v 8 8 8 8 8t =A . .S .	 .PU . . . .* 26b L Lw LY L L L L6 24 1 1S 1 1 1 1 10 9=R  S #    2 26b P Pw P P P P@ =? * * *e *CU * * * *X @B $ $C $ $FX $ $ $ $L )+ F FtF| F F F FP )+ E EtF| E E E EN) ) ) ) )$&
 &
t &
V &
 &
 &
 &
P
 
t 
V 
x 
 
 
 


 

T 

6 

EX 

 

 

 

2 24 2 26 2 2 2 2h
 
f 
HZ 
 
 
 
0 &eBSW )P )P )P )PV# s  c TX `c        r   r'   )-ccxt.base.exchanger   ccxt.abstract.zebpayr   r+  r&  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r    r!   r"   r#   ccxt.base.decimal_to_precisionr$   ccxt.base.preciser%   r'    r   r   <module>rU     so   ( ' ' ' ' ' , , , , , ,   a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) . . . . . . 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %` ` ` ` `X{ ` ` ` ` `r   