
    i:                    L   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" 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CurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)RateLimitExceeded)OnMaintenance)InvalidNonce)	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d5d
ede
fdZdddi fdede	de	fdZdefdZi fdefdZdi fdede	defdZd5d
edefdZi fdefdZdi fdedefdZdddi fdede	de	fdZd5defdZd Zd5d
edefdZdddi fdede	de	dee         fdZ d5d
ede!fdZ"ddi fdede	de	dee!         fdZ#di fdede$de%d e&d!e'f
d"Z(di fd#edefd$Z)d% Z*d5defd&Z+i fdefd'Z,di fd(ee         fd)Z-i fded e&d*ed+ede.f
d,Z/d5defd-Z0d. Z1di fded e&fd/Z2d5dede3fd0Z4d1d2i ddfd3Z5d4 Z6 xZ7S )6zondac           (      d   |                      t          t          |                                           dddg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	d/d	d0dd1dd2d	d3d	d4d	d5d	d6d	d7d	d8dd9di d:d	d;dd<d	d=d	d>d	d?d	d@d dAd	dBd	dCd dDd	dEd	dFd	dGd	dHd	dIddJddKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d_d`dadbgdcdddedfg dgidhg diidfg djig dkg dldmdngdogdpd`|                     dq          |                     dr          dd	ds|                     dt          |                     du          dd|                     du          |                     dv          g|                     dw          |                     dx          g|                     dy          |                     dz          g|                     d{          |                     d|          g|                     d}          |                     d~          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     dt          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          gg|                     dt          |                     dv          g|                     d          |                     dx          g|                     d          |                     dz          g|                     d          |                     d|          g|                     d          |                     d~          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          ggdddJi idddg dddidt
          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          t          t          t          t          t           t          t"          t          t          t          t"          t          dddid          S )Nr&   ZondaEE  CORSTspotmarginFswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateOrdercreateReduceOnlyOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrdersfetchOrderBookfetchOrderBooksfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchWithdrawalfetchWithdrawalsreduceMarginsetLeverage	setMarginsetMarginModesetPositionModetransferwithdraw6018030090018003600720014400216004320086400259200604800)1m3m5m15m30m1h2h4h6h12h1d3d1wzzondacrypto.exchangez-https://auth.zondaglobal.com/ref/jHlbB4mIkdS1zdhttps://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpgzhttps://zondaglobal.comzhttps://{hostname}/API/Publicz-https://{hostname}/API/Trading/tradingApi.phpzhttps://api.{hostname}/rest)publicprivatev1_01Publicv1_01Privatez"https://docs.zondacrypto.exchange/z https://github.com/BitBayNet/APIz2https://zondaglobal.com/en/helpdesk/zonda-exchangez1https://zondaglobal.com/legal/zonda-exchange/fees)referrallogowwwapidocsupportfeesget)z{id}/allz{id}/marketz{id}/orderbookz{id}/tickerz{id}/tradespost)	infotradecancel	orderbookordersrm   rn   historytransactions)ztrading/tickerztrading/ticker/{symbol}ztrading/statsztrading/stats/{symbol}ztrading/orderbook/{symbol}ztrading/transactions/{symbol}z,trading/candle/history/{symbol}/{resolution})z&api_payments/deposits/crypto/addresseszpayments/withdrawal/{detailId}zpayments/deposit/{detailId}ztrading/offerztrading/stop/offertrading/config/{symbol}ztrading/history/transactionszbalances/BITBAY/historybalances/BITBAY/balancez#fiat_cantor/rate/{baseId}/{quoteId}zfiat_cantor/history)ztrading/offer/{symbol}ztrading/stop/offer/{symbol}r   r   z7balances/BITBAY/balance/transfer/{source}/{destination}zfiat_cantor/exchangezapi_payments/withdrawals/cryptozapi_payments/withdrawals/fiatz*trading/offer/{symbol}/{id}/{side}/{price}z/trading/stop/offer/{symbol}/{id}/{side}/{price}zbalances/BITBAY/balance/{id})r   r   deleteputz0.0z0.001)makertaker
percentage	tierBasedz0.0030z0.00430z0.00421250z0.00413750z0.00407500z0.003910000z0.003815000z0.003720000z0.003625000z0.003537500z0.003450000z0.003375000z0.0032100000z0.0031150000200000z0.0029250000z0.0028375000z0.0027500000z0.0026625000z0.0025875000z0.0024z0.0023z0.0022z0.0021z0.0020z0.0019z0.0018z0.0017)r   r   )r   r   r   r   tiers)tradingfiatfunding!v1_01PublicGetTradingTickerSymbolv1_01PublicGetTradingTicker)EURUSDGBPPLNfillResponseFromRequest)fetchTickerMethodfetchTickersMethodfiatCurrenciesrm   400401402403404405406408501502503504505506509510FUNDS_NOT_SUFFICIENT)"OFFER_FUNDS_NOT_EXCEEDING_MINIMUMSOFFER_NOT_FOUND&OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLEDACTION_LIMIT_EXCEEDEDUNDER_MAINTENANCEREQUEST_TIMESTAMP_TOO_OLDPERMISSIONS_NOT_SUFFICIENTINVALID_STOP_RATETIMEOUTRESPONSE_TIMEOUTACTION_BLOCKEDINVALID_HASH_SIGNATUREGGCzGlobal Game Coin)idname	countries	rateLimithas
timeframeshostnameurlsr   r   optionsprecisionMode
exceptionscommonCurrencies)deep_extendsuperr&   describeparse_numberr#   r   r   r   r   r"   r   r   r   r   r    r!   r   )self	__class__s    P/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/zonda.pyr   zzonda.describe   s{   eT 2 2 ; ; = =EEE %E 	E
 %E %E UE "5E tE E $UE  E 'E tE (E  !E" +E#E E$ )%%E& ''E( ()E* +E, &t-E. (/E0  1E2 &u3E4 #E5E6 *57E8 $U9E: "5;E< *5=E> +E?E@ tAEB  CED %eEE E EF "5GEH IEJ !%KEL  MEN dOEP +EQER !%SET "4UEV !$WEX "5YEZ  [E\ $U]E^ !%_E` %eaEb )%cEd teEf gE E Eh UiEj tkEl "5mEn #EoEp &uqEr 'sEt $TuEv  wEx "5yEz #D{E| }E~ uE@ UAEB  CED "5EEF DGEH DIE EN   /K~0=N#@$A	  96 PK &      
 
 
    
   	 	 	 EI
 79! !EB BJ "..u55!..w77"&!&	  "..x88!..x88"&!% "..x88$:K:KC:P:PQ!..x88$:K:KF:S:ST!..x88$:K:KF:S:ST!..x88$:K:KF:S:ST!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV'", "..x88$:K:KC:P:PQ!..x88$:K:KF:S:ST!..x88$:K:KF:S:ST!..x88$:K:KF:S:ST!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KG:T:TU!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV'"-+ +1 1f s< <| &I&C">">">-t	  ' } |  |  |	 
 |  |  (  |  *  *  |  }  *  ' " }# $ y% & '(9' ( 7C#0:R):%2-9.>%1($1"2*=?     D )!mY@
 Y@
 Y Y Y	    returnc                     |                      |          }|                     |di           }t          |                                          }|                     |          S )a  
        :see: https://docs.zondacrypto.exchange/reference/ticker-1
        retrieves data on all markets for zonda
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        items)r   
safe_valuelistvaluesparse_markets)r   paramsresponser   marketss        r   fetch_marketszzonda.fetch_markets:  sW     33F;;( '266u||~~&&!!'***r   c                    |                      |di           }|                     |d          }|                      |di           }|                      |di           }|                     |d          }|                     |d          }|                     |          }|                     |          }	|                      | j        di           }
|                      | j        dg           }|                     ||          s|                     |	|          r|                      | j        di           }
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d dddd d |                     |
d          |                     |
d          d d d d d |                     |                     |                     |d                              |                     |                     |                     |d                              d d d d!|                     |d"          d d!d d d!d d d!d#d |d$S )%Nmarketcodefirstsecondcurrencyr   r   r   r   symbol/basequotesettlebaseIdquoteIdsettleIdtyper,   Tr-   Fr.   r/   r0   activecontractlinearr   r   scale)amountprice)minmaxminOffer)leverager  r  cost)inverser   r   contractSizeexpiryexpiryDatetime
optionTypestrike	precisionlimitscreatedr   )	r   safe_stringsafe_currency_coder   r   in_arraysafe_numberr   parse_precision)r   itemr  r   r  r  r  r  r  r  r   r   s               r   parse_marketzzonda.parse_marketY  s   x44ff--44266!!%44""6:66&&v..''00ty)R887GLL==~.. 	:$--~2V2V 	:??49fb99D2
"2
dSj5(2
 D2
 U	2

 d2
 f2
 w2
 2
 F2
 D2
 e2
 E2
 e2
 e2
 d2
  !2
" d#2
$ %%dG44%%dG44 "++D,@,@AQAQRWY`AaAa,b,bcc**4+?+?@P@PQWY`@a@a+b+bcc    
  ++E:>> 
   
    $ c2
 2
 2
 2	
r   Nr	  sincelimitc                     |                                   i }|                     |                     ||                    }|                     |dg           }|                     |d||ddi          S )a  
        :see: https://docs.zondacrypto.exchange/reference/active-orders
        fetch all unfilled currently open orders
        :param str symbol: not used by zonda fetchOpenOrders
        :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>`
        r   Nstatusopen)load_marketsv1_01PrivateGetTradingOfferextend	safe_listparse_orders)r   r	  r-  r.  r   requestr   r   s           r   fetch_open_orderszzonda.fetch_open_orders  sr     	33DKK4P4PQQx"55  eUXv<NOOOr   r  c           	      t   |                      |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|          S )Nr  -timestartAmountcurrentAmountpostOnlyr   clientOrderIdr   	timestampdatetimelastTradeTimestampr0  r	  r  modetimeInForceside	offerTyper  rate	stopPricetriggerPricer  r  )filled	remainingaveragefeetrades)r&  safe_symbolsafe_integerr   
safe_orderiso8601safe_string_lower)	r   orderr  marketIdr	  r@  r  rK  r>  s	            r   parse_orderzzonda.parse_order  s   & ##E844!!(FC88%%eV44	!!%77$$UO<<	??5*55  
$""5$// 
T 
 E 
 	 

 Y// 
 !$ 
 d 
 f 
 D$$UF33 
 4 
  
 D**5+>> 
 T%%eV44 
  
 D 
  f! 
" D# 
$ "- 
  
  
. /  	r   c                    |                                   i }|r0|                     |          g}|                     |          }||d<   d|                     |                     ||                    i}|                     |          }|                     |d          }	|                     |	d||          }
||
S |                     |
|          S )a  
        :see: https://docs.zondacrypto.exchange/reference/transactions-history
        fetch all trades made by the user
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        r  queryr   N)	r2  	market_idr	  jsonr4  )v1_01PrivateGetTradingHistoryTransactionsr   parse_tradesfilter_by_symbol)r   r	  r-  r.  r   r7  r  rX  r   r   results              r   fetch_my_tradeszzonda.fetch_my_trades  s     	 	)~~f--.G[[((F!(GI$))DKK$@$@AABAA%HH* '22""5$u==>M$$VV444r   c                    |                      |d          }|-t          | j        dz   |                     |          z             d|i}t	          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d	<   |||<   | 	                    |          S )
Nbalancesz empty balance response r   r   r  lockedFundsusedavailableFundsfree)
r   r   r   rZ  rangelenr&  r'  accountsafe_balance)	r   r   ra  r^  ibalance
currencyIdr  rh  s	            r   parse_balancezzonda.parse_balance	  s    ??8Z88*D DtyyQYGZGZ Z[[[(#q#h--(( 	# 	#AqkG))':>>J**:66DllnnG"..wFFGFO"..w8HIIGFO"F4LL  (((r   c                 ~    |                                   |                     |          }|                     |          S )ak  
        :see: https://docs.zondacrypto.exchange/reference/list-of-wallets
        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>`
        )r2  $v1_01PrivateGetBalancesBITBAYBalancerm  )r   r   r   s      r   fetch_balancezzonda.fetch_balance  s=     	<<VDD!!(+++r   c           	         |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |dg           }|                     |dg           }|                     |d          }	|d         |                     |dd          |                     |dd          |	|                     |	          |                     |d          d	S )
a9  
        :see: https://docs.zondacrypto.exchange/reference/orderbook-2
        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
        r	  r   buysellr@  racaseqNo)r	  bidsasksr@  rA  nonce)r2  r  $v1_01PublicGetTradingOrderbookSymbolr4  r   rP  parse_bids_asksrR  )
r   r	  r.  r   r  r7  r   rawBidsrawAsksr@  s
             r   fetch_order_bookzzonda.fetch_order_book#  s    	V$$fTl
 <<T[[RX=Y=YZZ$ //(E266//(FB77%%h<<	X&(($==(($=="Y//&&x99
 
 	
r   c                    |                      |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|          S )Nr  r  mr;  rG  r	  r@  rA  highhlowlbid
highestBid	bidVolumeask	lowestAsk	askVolumevwapr1  r24hcloselastpreviousClosepreviousRatechanger   rL  v)
baseVolumequoteVolumer   )	r   safe_string_2safe_marketrP  safe_tickerrO  rR  r&  r)  )r   tickerr  tickerMarketrU  r@  rG  s          r   parse_tickerzzonda.parse_tickerO  s   L vx88%%lFC@@!!(F33%%ff55	vv.. !
d&&x88!
!
 Y//!
 D$$VS11	!

 4##FC00!
 4##FL99!
 !
 4##FK88!
 !
 D!
 D$$VV44!
 T!
 D!
 T__V^DD!
 d!
  $!!
" t#!
$ **6377)!
 !
 !
* +  	r   c                     |                                   |                     |          }d|d         i}d}|                     | j        d|          }|                     |dd|          }d}||k    r*|                     |                     ||                    }nG|dk    r*|                     |                     ||                    }nt          | j	        dz             | 
                    |d	d
          }	|                     |	|          S )a  
        v1_01PublicGetTradingTickerSymbol retrieves timestamp, datetime, bid, ask, close, last, previousClose, v1_01PublicGetTradingStatsSymbol retrieves high, low, volume and opening price of an asset
        :see: https://docs.zondacrypto.exchange/reference/market-statistics
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.method]: v1_01PublicGetTradingTickerSymbol(default) or v1_01PublicGetTradingStatsSymbol
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        r	  r   r   r   methodN v1_01PublicGetTradingStatsSymbolzo fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"r  stats)r2  r  r&  r   r  r   r4  r  r   r   safe_value_2r  )
r   r	  r   r  r7  r  defaultMethodr   r   r  s
             r   fetch_tickerzzonda.fetch_ticker  s.    	V$$fTl
 5((7JFSS ..vxATVcdd&&==dkk'SY>Z>Z[[HH: "DDD<<T[[RX=Y=YZZHH TW  (Y  Y  Z  Z  Z!!(Hg>>  ///r   symbolsc                    |                                   d}|                     | j        d|          }|                     |dd|          }d}||k    r|                     |          }n3|dk    r|                     |          }nt          | j        dz             |                     |d          }| 	                    ||          S )a  
         * @ignore
        v1_01PublicGetTradingTicker retrieves timestamp, datetime, bid, ask, close, last, previousClose for each market, v1_01PublicGetTradingStats retrieves high, low, volume and opening price of each market
        :see: https://docs.zondacrypto.exchange/reference/market-statistics
        :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
        :param str [params.method]: v1_01PublicGetTradingTicker(default) or v1_01PublicGetTradingStats
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        r   r   r  Nv1_01PublicGetTradingStatszd fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"r   )
r2  r&  r   r  r   r  r   r   	safe_dictparse_tickers)r   r  r   r  r  r   r   r   s           r   fetch_tickerszzonda.fetch_tickers  s     	.((7KVTT!//BVXeff''77??HH@  #???66v>>HH" TW  (N  N  O  O  Ox11!!%111r   r  c                 N   g }|0|                      |          }|                    |d                    d|i}|||d<   |||d<   |                     ||          }|                     d|                     |          i          }|d         }	|                     |	d||          S )aa  
        :see: https://docs.zondacrypto.exchange/reference/operations-history
        fetch the history of changes, actions done by the user or operations that altered balance of the user
        :param str code: unified currency code, default is None
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entrys to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
        Nr   balanceCurrenciesfromTimer.  rX  r   )r  appendr4  $v1_01PrivateGetBalancesBITBAYHistoryrZ  parse_ledger)
r   r  r-  r.  r   r  r  r7  r   r   s
             r   fetch_ledgerzzonda.fetch_ledger  s     }}T**H$$Xd^444!2
 "'GJ$GG++gv..<<gtyyQXGYGY=Z[[!  eU;;;r   r  c                    |                      |d          }|                     |di           }|                     |d          }|                     |di           }|                     |d          }d}t          j        |d          rd}t          j        |          }|                     |d	i           }	|                     |d
i           }
||                     |d          |d |                     |d          d |                     |                     |d                    |                     |          |                     |          | 	                    |	d          | 	                    |
d          d|| 
                    |          d dS )Nr;  rk  r  r  totalinr   outfundsBefore
fundsAfter	historyIddetailIdr  ok)r   r   	directionrh  referenceIdreferenceAccountr  r  r  beforeafterr0  r@  rA  rM  )rP  r   r&  r$   	string_lt
string_negparse_ledger_entry_typer'  r   r)  rR  )r   r+  r  r@  rk  rl  r  r  r  r  r  s              r   parse_ledger_entryzzonda.parse_ledger_entry4  s   X %%dF33	//$	266%%gz::
x44!!&'22	VS)) 	0I'//F oodM2>>__T<<<
""455"++D*== $001A1A$1O1OPP//
;;''//&&{G<<%%j'::"Y//
 
 	
r   c                 R    ddddddddddddddd}|                      |||          S )NtransactionrM  r   )	ADD_FUNDSBITCOIN_GOLD_FORKCREATE_BALANCEFUNDS_MIGRATIONWITHDRAWAL_LOCK_FUNDSWITHDRAWAL_SUBTRACT_FUNDSWITHDRAWAL_UNLOCK_FUNDSTRANSACTION_COMMISSION_OUTCOMETRANSACTION_COMMISSION_RETURN TRANSACTION_OFFER_ABORTED_RETURN"TRANSACTION_OFFER_COMPLETED_RETURNTRANSACTION_POST_INCOMETRANSACTION_POST_OUTCOMETRANSACTION_PRE_LOCKINGr&  )r   r  typess      r   r  zzonda.parse_ledger_entry_type_  sR    &!.+,%2)6'4.3-20729'.(/'.
 
  tT222r   c           	      0   |                      |di           }|                     |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )N   r   or  r  cr  )r   rP  r)  )r   ohlcvr  r  s       r   parse_ohlcvzzonda.parse_ohlcvr  s     q"--eQ''UC((UC((UC((UC((UC((
 	
r   r|   c                 h   |                                   |                     |          }|d         dz   |d         z   }||                     | j        ||          d}|d}nt	          |d          }|                     |          }	||	z  dz  }
|&|                                 |d	<   |d	         |
z
  |d
<   n$||d
<   |                     |d
         |
          |d	<   |                     | 	                    ||                    }| 
                    |dg           }|                     |||||          S )a  
        :see: https://docs.zondacrypto.exchange/reference/candles-chart
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r  r:  r  )r	  
resolutionNd   i*  r*   tofromr   )r2  r  r&  r   r  parse_timeframemillisecondssum2v1_01PublicGetTradingCandleHistorySymbolResolutionr4  r5  parse_ohlcvs)r   r	  	timeframer-  r.  r   r  tradingSymbolr7  duration	timeranger   r   s                r   fetch_ohlcvzzonda.fetch_ohlcv  sM    	V$$x(3.	1BB#**4?IyQQ
 
 =EEu%%E''	22H$t+	= --//GDM%dmi7GFOO#GFO HHWV_i@@GDMJJ4;;W^`fKgKghh x"55  	5%HHHr   c                    |                      |dd          }|                     |dd          }|                     |d          }d }||rdnd}|                     |dd	          }|                     |d
d          }|                     |d          }	|                     |d          }
|                     |
|d          }|d         }d }|	|dk    r|d         n|d         }||	d}|                     |d          }d }||rdnd}|                     |                     |d          |||                     |          |||||d |||d|          S )Nr;  t
userActiontywasTakerr   r   rG  rr  acommissionValuer  r:  r	  rr  r  r  )r  r  offerIdr.  r   )r   rT  r@  rA  r	  r  rE  r  r  r  takerOrMakerrM  r   )safe_integer_2safe_string_lower_2r   r  r&  r  
safe_traderR  )r   r   r  r@  rE  r  r  priceStringamountStringfeeCostStringrU  r	  rM  feeCurrencyrT  r  s                   r   parse_tradezzonda.parse_trade  s   D ''vs;;	''|TBB??5*55 &.;77GL((<<))%3??((0ABB##E844!!(FC88!$-1U]]&..K'% C   	22#177D""5$//"Y// "( 
  
   	r   c                 T   |                                   |                     |          }|d         dz   |d         z   }d|i}||dz
  |d<   |||d<   |                     |                     ||                    }|                     |d	          }	|                     |	|||          S )
a)  
        :see: https://docs.zondacrypto.exchange/reference/last-transactions
        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>`
        r  r:  r  r	  Nr  r  r.  r   )r2  r  'v1_01PublicGetTradingTransactionsSymbolr4  r5  r\  )
r   r	  r-  r.  r   r  r  r7  r   r   s
             r   fetch_tradeszzonda.fetch_trades  s     	V$$x(3.	1BBm
 "'!)GJ$GG??GU[@\@\]]x11  u===r   r  rE  r  r  c                 v   |                                   |                     |          }|d         dz   |d         z   }t          |                     ||                    }||                                |d}	|                     |dd          }
|
du}|dk    }|d	k    }|d
k    p|o|}|dk    p|o|}|p|}|s|r#|                     ||          |	d<   |rd
nd|	d<   n%|s|r
|rdnd	|	d<   nt          | j        dz             | 	                    |ddg          }d}|r\|st          | j        dz             |                     ||
          |	d<   | 
                    |                     |	|                    }n)|                     |                     |	|                    }|                     |dd          }|                     |dd          }|rdn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i          S )*a`  
        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  r:  r  )r	  rF  r  rH  stopLossPriceNr.  r  z
stop-limitzstop-marketrG  rC  z createOrder() invalid typezj createOrder() zonda requires `triggerPrice` or `stopPrice` parameter for stop-limit or stop-market ordersstopRater  stopOfferId	completedFclosedr1  r   r   r   r@  rA  rB  r0  r	  r  rE  r  r  r  rJ  rK  rL  rM  rN  r?  )r2  r  floatamount_to_precisionupperr  price_to_precisionr   r   omit&v1_01PrivatePostTradingStopOfferSymbolr4  "v1_01PrivatePostTradingOfferSymbolr  	safe_boolr   rQ  )r   r	  r  rE  r  r  r   r  r  r7  r  isStopLossPriceisLimitOrderisMarketOrderisStopLimitisStopMarketisStopOrderr   r   r  r0  r   s                         r   create_orderzzonda.create_order  sS    	V$$x(3.	1BBt//??@@#
 

 ))&+OO't3w(|+R1Q/},S1R?!1\ 	I; 	I"55feDDGFO.9FllwGFOO 	Il 	I/;ImmGFOO*G GHHH6K#ABB 	]" \#DG  /[  %[  \  \  \"&"9"9&-"P"PGJBB4;;wX^C_C_``HH>>t{{7TZ?[?[\\Hn )]CCNN8[%@@	&2Fx@@  
" 
H 
  
 	 

 !$ 
 f 
 f 
 D 
 D 
 U 
 f 
 D 
 d 
  
 t 
  4! 
" l# 
$ T% 
  
   	r   r   c                    |                      |d          }|t          | j        dz             |                     |d          }|t          | j        dz             |                                  |                     |          }|d         dz   |d         z   }||||d	}|                     |                     ||                    S )
a  
        :see: https://docs.zondacrypto.exchange/reference/cancel-order
        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>`
        rE  Nz; cancelOrder() requires a `side` parameter("buy" or "sell")r  z< cancelOrder() requires a `price` parameter(float or string)r  r:  r  )r	  r   rE  r  )r&  r   r   r   r2  r  /v1_01PrivateDeleteTradingOfferSymbolIdSidePricer4  )	r   r   r	  r   rE  r  r  r  r7  s	            r   cancel_orderzzonda.cancel_order  s     //<*g ghhh00=*h hiiiV$$x(3.	1BB#	
 
 CCDKKPWY_D`D`aaar   c                 <    dddd}|                      ||d          S )NT)r   r   r   F)r
  )r   r  r   s      r   is_fiatzzonda.is_fiat  s/    
 

 ~~nh>>>r   c                     |                      |d          }|                      |d          }|                     |           |                     ||          ||                      |d          d |dS )Nr  addresstag)r  r  r  networkr   )r&  check_addressr'  )r   depositAddressr  rl  r  s        r   parse_deposit_addresszzonda.parse_deposit_address  s     %%njAA
"">9==7###//
HEE##NE::"
 
 	
r   c                 >   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |d          }|                     |d          }|                     ||          S )a  
        :see: https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto
        fetch the deposit address for a currency associated with self account
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.walletId]: Wallet id to filter deposit adresses.
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        r  r   datar   )r2  r  1v1_01PrivateGetApiPaymentsDepositsCryptoAddressesr4  r   r  r  )r   r  r   r  r7  r   r  r  s           r   fetch_deposit_addresszzonda.fetch_deposit_address  s     	==&&
 II$++V]_eJfJfgg x00tQ''))%:::r   codesc                     |                                   |                     |          }|                     |d          }|                     ||          S )a  
        :see: https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto
        fetch deposit addresses for multiple currencies and chain types
        :param str[]|None codes: zonda does not support filtering filtering by multiple codes and will ignore self parameter.
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `address structures <https://docs.ccxt.com/#/?id=address-structure>`
        r  )r2  r   r5  parse_deposit_addresses)r   r"  r   r   r  s        r   fetch_deposit_addresseszzonda.fetch_deposit_addresses  sT     	II&QQ ~~h//++D%888r   fromAccount	toAccountc                    |                                   |                     |          }||||                     ||          d}|                     |                     ||                    }|                     ||          }	|                     | j        di           }
|                     |
dd          }|r||	d<   |	S )a  
        :see: https://docs.zondacrypto.exchange/reference/internal-transfer
        transfer currency internally between wallets on the same account
        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        )sourcedestinationr  fundsrm   r   Tr  )	r2  r  currency_to_precision>v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestinationr4  parse_transferr   r   r
  )r   r  r  r&  r'  r   r  r7  r   rm   transferOptionsr   s               r   rm   zzonda.transfer  s     	==&&!$//f==	
 
 VVW[WbWbcjlrWsWstt: &&x:://$,
BGG"&..B[]a"b"b" 	(!'HXr   c                 t   |                      |d          }|                     |di           }|                      |d          }|                     |di           }|                      |d          }|                      |d          }|d d d |                     ||          d |||                     |          d	S )Nr0  r  r   r  r  )	r   r   r@  rA  r  r  r&  r'  r0  )r&  r   r'  parse_transfer_status)	r   rm   r  r0  r&  fromIdr  toIdrl  s	            r   r.  zzonda.parse_transfer>  s    : !!(H55ooh;;!!+t44__XtR00D))%%k:>>
//
HEE!0088

 

 
	
r   c                 :    ddd}|                      |||          S )Nr  failed)OkFailr  )r   r0  statusess      r   r1  zzonda.parse_transfer_statusm  s.    
 
 &&999r   c                    |                      ||          \  }}|                     |           |                                  d}|                     |          }|d         ||d}|                     |          r*|                     |                     ||                    }n0|||d<   |                     |                     ||                    }|                     |d          }	| 	                    |	|          S )a  
        :see: https://docs.zondacrypto.exchange/reference/crypto-withdrawal-1
        make a withdrawal
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   )r  r  r  r  r  )
handle_withdraw_tag_and_paramsr  r2  r  r  *v1_01PrivatePostApiPaymentsWithdrawalsFiatr4  ,v1_01PrivatePostApiPaymentsWithdrawalsCryptor  parse_transaction)
r   r  r  r  r  r   r   r  r7  r  s
             r   rn   zzonda.withdrawt  s
    99#vFFV7###==&& 
 
 << 	gFFt{{SZ\bGcGcddHH!$HHU\^dIeIeffH ~~h//%%dH555r   c                     |                      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 d d |dS )Nr   txidr@  rA  r  addressFromr  	addressTor  r  r  r  r0  updatedtagFromr  tagTocomment)internalrM  r   )safe_currencyr&  )r   r  r  s      r   r=  zzonda.parse_transaction  s    %%dH55
$"";55
D
 
 	

 t
 4
 t
 
 d
 D
 (
 d
 t
 t
 4
  T!
" t#
$ )
 
 
 	
r   r   GETc           	         |                      | j        d         |                   }|dk    rg|                     ||                     |                    }|d|                     ||          z   dz   z  }|r|d|                     |          z   z  }nP|dk    rd|                     ||                     |                    }|d|                     ||          z   z  }|r|d|                     |          z   z  }n|dk    r8|                                  |                     ||                     |                    }|d|                     ||          z   z  }t          |                                           }	d }
|dk    r(|r|d|                     |          z   z  }| j	        |	z   }
n$|"| 
                    |          }| j	        |	z   |z   }
|	|                                 | j	        |                     |                     |
          |                     | j                  t          j                  d	d
}n|                                  |                     |                     ||                                 d|                    }d| j	        |                     |                     |          |                     | j                  t          j                  d}||||dS )Nr   r   r
  z.json?r   r   POSTzapplication/json)zRequest-TimestampzOperation-IdAPI-KeyAPI-HashContent-Type)r  momentz!application/x-www-form-urlencoded)rN  rL  rM  )urlr  bodyheaders)implode_hostnamer   r  extract_paramsimplode_params	urlencodecheck_required_credentialsstrr  apiKeyrZ  uuidhmacencodesecrethashlibsha512r4  ry  )r   pathr   r  r   rR  rQ  rP  rX  ry  payloads              r   signz
zonda.sign  s   ##DIe$4S$9::(??IIfd&9&9$&?&?@@E3,,T6:::WDDC 3sT^^E2222M!!IIfd&9&9$&?&?@@E3,,T6::::C 3sT^^E2222N""++---IIfd&9&9$&?&?@@E3,,T6::::C))++,,EG 73!6!666C+-yy''+-4%* $		; IIdkk'&:&:DKK<T<TV]Vdee 2 GG ++--->>$++**,,/ / # #  D
 !D; IIdkk$&7&7T[9Q9QSZSabb G
 fdwOOOr   c
                    |d S d|v rN|                      |d          }
| j        dz   |z   }|                     | j        |
|           t	          |          d|v r|                      |d          }|dk    rv|                     |d          }| j        dz   |z   }t          dt          |                    D ]&}||         }|                     | j        ||           't	          |          d S )Nr   r0  r7  errorsr   )r&  r   throw_exactly_matched_exceptionr   r   r   rf  rg  )r   httpCodereasonrP  r  rR  rQ  r   requestHeadersrequestBodyr  feedbackr0  re  rj  errors                   r   handle_errorszzonda.handle_errors  s   4X4 ##Hf55Dw}t+H00$QQQ)))!! %%h99F8<<7S=4/q#f++.. [ [A"1IE88%QYZZZZ#H---tr   )N)8__name__
__module____qualname__r   r   r   r  r,  r   r   r
   r8  rV  r_  r   rm  rp  rX  r   r~  r   r  r  r   r   r  r  r   r  r  r   r  r  r   r  r  r   r   r  r	   r  r  r  r  r!  r%  r   rm   r.  r1  rn   r   r=  rb  rm  __classcell__)r   s   @r   r&   r&      s       Z Z Z Z Zx $& + +$v, + + + +>@
F @
 @
 @
 @
D /3TXac P P P3 Pc Phlmrhs P P P P 0 0 05 0 0 0 0d -1tRV_a *5 *5c *5 *5C *5 *5 *5 *5X) ) ) ) ) $& 	, 	,( 	, 	, 	, 	, :>b *
 *
s *
3 *
Y *
 *
 *
 *
X@ @6 @V @ @ @ @D 02 A0 A03 A0 A0 A0 A0F 04B D2 D2W D27 D2 D2 D2 D2L (,$TZ\ < < <C <s < < < <4i
 i
 i
 i
 i
 i
V	3 3 3&
 
 
4 
 
 
 
0 26DW[df ,I ,I# ,Ic ,IQT ,Ikoptku ,I ,I ,I ,I\H H H5 H H H HT 6:UW > >3 >s ># >\`af\g > > > >0 gksu x x3 xi xy xRW x`c x x x xt 37r b bs bC b b b b8? ? ?
 
h 
 
 
 
* 79 ; ;# ; ; ; ;@ :>b 9 9T#Y 9 9 9 94 [] 5 5S 5% 5c 5c 5an 5 5 5 5n-
 -
 -
 -
 -
 -
^: : : ?C2 &6 &6S &6% &6 &6 &6 &6P
 
x 
; 
 
 
 
@ &eBSW +P +P +P +PZ- - - - - - -r   r&   )+ccxt.base.exchanger   ccxt.abstract.zondar   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   r   r   r    r!   r"   ccxt.base.decimal_to_precisionr#   ccxt.base.preciser$   r&    r   r   <module>rz     sl   ( ' ' ' ' ' + + + + + +  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * 5 5 5 5 5 5 . . . . . . * * * * * * ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %z z z z zHk z z z z zr   