
    !:hO                         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"  G d dee      Z#y)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTrade)List)ExchangeError)ArgumentsRequired)
BadRequest)	BadSymbol)OrderNotFound)OnMaintenance)	TICK_SIZE)Precisec                        e Zd Zdef fdZi fdefdZi fde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di fdedefdZi fdedefdZd/dededefdZd/ded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e fdZ"d/de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di fde ded	efd!Z&di fdede fd"Z'di fd#edee(   fd$Z)d%d&i ddfd'Z*d(e+d)ed*ed+ed,ed-efd.Z, xZ-S )0coinonereturnc                    | j                  t        t        |          dddgdddi dd dd	d
ddddddddddd	dddddddd	dddddddddd	i dddddddddddd	ddd d	d!dd"dd#dd$dd%dd&dd'dd(dd)di d*dd+dd,d	d-dd.d	d/dd0d	d1d	d2d	d3dd4dd5dd6dd7dd8dd9dd:dd	d	d	ddddd	d;d<d=d>d?d@dAdBdCdDd	d	dEdFg dGidFg dHidIg dJidIg dKidIg dLidMdNdd	dOdOdPidddd dddd dddddQddddddddRd ddSdTdTd	dUdddd	dVdd ddd	dWd d d dX	d d dYd d dYdZt        t
        t        t        t        d[d\d]id^      S )_Nr   CoinOneKR2   v2FCORSspotTmarginswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTradesfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCV)fetchTickerfetchTickersfetchTradesreduceMarginsetLeveragesetMarginModesetPositionModewszchttps://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpgzhttps://api.coinone.co.krz#https://api.coinone.co.kr/public/v2zhttps://api.coinone.co.kr/v2zhttps://api.coinone.co.kr/v2.1)restv2Public	v2Privatev2_1Privatezhttps://coinone.co.krzhttps://doc.coinone.co.kr)logoapiwwwdoc)apiKeysecretget)	orderbookticker
ticker_utctrades)range_unitszmarkets/{quote_currency}z*markets/{quote_currency}/{target_currency}z,orderbook/{quote_currency}/{target_currency}z)trades/{quote_currency}/{target_currency}zticker_new/{quote_currency}z-ticker_new/{quote_currency}/{target_currency}zticker_utc_new/{quote_currency}z1ticker_utc_new/{quote_currency}/{target_currency}
currencieszcurrencies/{currency}z(chart/{quote_currency}/{target_currency}post)account/deposit_addresszaccount/btc_deposit_addressaccount/balancezaccount/daily_balanceaccount/user_infoaccount/virtual_accountzorder/cancel_allorder/cancelorder/limit_buyorder/limit_sellorder/complete_ordersorder/limit_orderszorder/order_infotransaction/auth_numbertransaction/historytransaction/krw/historytransaction/btcztransaction/coin)rt   rs   ru   rv   rw   rx   ry   r{   rz   zorder/query_orderr|   r   r}   r~   )zaccount/balance/allrt   zaccount/trade_feez4account/trade_fee/{quote_currency}/{target_currency}zorder/limitrw   zorder/cancel/allzorder/open_orderszorder/open_orders/allrz   zorder/complete_orders/allz
order/infor~   ztransaction/coin/historyz!transaction/coin/withdrawal/limit)publicrb   privaterc   rd   tradinggMb`?)	tierBased
percentagetakermaker)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergd   i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )	sandboxr1   createOrdersrL   rO   rN   fetchOrdersr9   
fetchOHLCV)linearinverse)r'   r)   r*   )104107108405SOCz	Soda Coin)idname	countries	rateLimitversionprohasurlsrequiredCredentialsrf   feesfeaturesprecisionMode
exceptionscommonCurrencies)	deep_extendsuperr   describer   r   r   r   r   )self	__class__s    F/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/coinone.pyr   zcoinone.describe   sl   gt = ?<<< %< 	<
 %< %< U< t< $U<  < $U< t< (< '< (<  "5!<" #<$ +E%<& )%'<( $U)<* '+<, (-<. "4/<0 &u1<2 (3<4 1%5<6 &u7<8 #E9<: *5;<< $U=<> "5?<@ *5A<B +EC<D  E<F %eG<H "5I<J K<L !%M<N  O<P +EQ<R "4S<T dU<V !$W<X  Y<Z '[<\ $U]<^ !%_<` *5a<b (c<d %ee<f )%g<h  $ $# %$!&#(w<| ~7 E!?#C	 /2
 $    "  .  &   CTl !&"&""	  %&+(-,0,1).+06:#(#("'#(	( #($)$)+027/4#()$, %)&+!$$*%+*.& ',#($)*.	# ',!%#($)*.( $()-"&_0d ##
 ##m:v '$! $	 {!euB
 u u	    c                 P   | j                  |      }i }| j                  |dg       }t        dt        |            D ]  }||   }| j	                  |d      }| j                  |      }| j	                  |dd      dk(  }	| j	                  |dd      dk(  }
|dk7  rd	nd
}| j                  |||| j	                  |d      d|
|	| j                  |d      | j                  | j                  | j	                  |d                  ddd| j                  |d      dddi |d      ||<    |S )a  
        fetches all available currencies on an exchange

        https://docs.coinone.co.kr/reference/currencies

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        rq   r   symbolwithdraw_status normaldeposit_statusKRWcryptofiatr   Nwithdrawal_feemax_precisionminmaxwithdrawal_min_amount)amountwithdraw)r   codeinfor   activedepositr   fee	precisionlimitsnetworkstype)
v2PublicGetCurrencies	safe_listrangelensafe_stringsafe_currency_codesafe_currency_structuresafe_numberparse_numberparse_precision)r   paramsresponseresultrq   ientryr   r   isWithdrawEnabledisDepositEnabledr   s               r   fetch_currencieszcoinone.fetch_currencies  sg    --f5* ^^HlB?
q#j/* 	AqME!!%2B**2.D $ 0 08I2 NRZ Z#//7GLPXX $8FD77((7+-''/?@!..t/C/CDDTDTUZ\kDl/mn  $#
  $//7NO#!	 +9 F4L	< r   c                    ddi}| j                  |      }| j                  |dg       }g }t        dt        |            D ]  }| j	                  ||      }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |	      }| j                  |
      }|j                  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| j                  d      | j                  d      | j                  d      ddddddddddddddd|d 
       	 |S )!a  
        retrieves data on all markets for coinone

        https://docs.coinone.co.kr/v1.0/reference/tickers

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        quote_currencyr   tickersr   r   target_currencyr   /basequotesettleNbaseIdquoteIdsettleIdr   r'   Tr(   Fr)   r*   r+   r   contractr   z1e-4z1e-8)r   pricecostr   )r   r   r   r   )
r   contractSizeexpiryexpiryDatetimestrike
optionTyper   r   createdr   )
!v2PublicGetTickerNewQuoteCurrencyr   r   r   
safe_valuer   safe_string_upperr   appendr   )r   r   requestr   r   r   r   r   r   r   r   r   r   s                r   fetch_marketszcoinone.fetch_marketsO  s2    e
 99'BD ..9b9q#g,' 8	AOOGQ/E!!%.B++E3DEF,,U4DEG**62D++G4EMM 1b1$*u,1 1 	1
 $1 &1 71 D1 1 1 %1 1 %1 %1 $1  E!1" $#1$   $"&""//7!..v6 --f5  $#!
  $#
  $#
  $#$  a1 18	r r   c                 n   d|i}| j                  |g d      }t        |j                               }t        dt	        |            D ]\  }||   }||   }| j                  |      }| j                         }	| j                  |d      |	d<   | j                  |d      |	d<   |	||<   ^ | j                  |      S )Nr   )	errorCoder   normalWalletsr   availfreebalancetotal)	omitlistkeysr   r   r   accountr   safe_balance)
r   r   r   balancescurrencyIdsr   
currencyIdr  r   r  s
             r   parse_balancezcoinone.parse_balance  s    )99X (
 
 8==?+q#k*+ 	#A$QJz*G**:6DllnG"..w@GFO#//CGG"F4L	#   ((r   c                 f    | j                          | j                  |      }| j                  |      S )aY  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://docs.coinone.co.kr/v1.0/reference/v21

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )load_marketsv2PrivatePostAccountBalancer  )r   r   r   s      r   fetch_balancezcoinone.fetch_balance  s1     	33F;!!(++r   Nr   r   c           	         | j                          | j                  |      }|d   |d   d}|||d<   | j                  | j                  ||            }| j	                  |d      }| j                  ||d   |ddd	d
      S )a1  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.coinone.co.kr/v1.0/reference/orderbook

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        r   r   r   r   size	timestampr   bidsasksr   qty)r  market/v2PublicGetOrderbookQuoteCurrencyTargetCurrencyextendsafe_integerparse_order_book)r   r   r   r   r!  r  r   r  s           r   fetch_order_bookzcoinone.fetch_order_book  s     	V$$Wo%f~
 #GFOGGT[]cHde0 %%h<	$$Xvh/?FTZ\cejkkr   symbolsc                    | j                          | j                  |      }ddi}d}d}|U| j                  |d      }| j                  |      }|d   |d<   |d   |d<   | j	                  | j                  ||            }n!| j                  | j                  ||            }| j                  |dg       }| j                  ||      S )	aF  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://docs.coinone.co.kr/v1.0/reference/tickers
        https://docs.coinone.co.kr/v1.0/reference/ticker

        :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>`
        r   r   Nr   r   r   r   r   )	r  market_symbolsr   r!  /v2PublicGetTickerNewQuoteCurrencyTargetCurrencyr#  r   r   parse_tickers)r   r'  r   r  r!  r   firstdatas           r   fetch_tickerszcoinone.fetch_tickers  s     	%%g.e
 $$Wa0E[['F(.wG$%)/G%&KKDKKX_agLhiH==dkk'SY>Z[HD ~~h	26!!$00r   c                    | j                          | j                  |      }|d   |d   d}| j                  | j                  ||            }| j	                  |dg       }| j                  |di       }| j                  ||      S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://docs.coinone.co.kr/v1.0/reference/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   r  r   r   )r  r!  r*  r#  r   	safe_dictparse_ticker)r   r   r   r!  r  r   r-  rm   s           r   fetch_tickerzcoinone.fetch_tickerE  s     	V$$Wo%f~
 GGT[]cHdeD ~~h	26a,  00r   rm   r!  c                    | j                  |d      }| j                  |d      }| j                  |dg       }| j                  |dg       }| j                  |d      }| j                  |d      }| j                  |      }	| j                  |      }
| j	                  i d|	dz   |
z   d|d	| j                  |      d
| j                  |d
      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      dd d| j                  |d      d|d|dd dd dd dd | j                  |d      | j                  |d      |d|      S )Nr  last	best_asks	best_bidsr   r   r   r   datetimehighlowbidr   	bidVolumer   ask	askVolumevwapopenr,  closepreviousClosechanger   averagetarget_volumequote_volume)
baseVolumequoteVolumer   )r$  r   r   r   safe_tickeriso8601)r   rm   r!  r  r4  r  r  r   r   r   r   s              r   r1  zcoinone.parse_ticker{  s   6 %%fk:	/~~fk26~~fk26!!&*;<""6+;<&&v.''0 !
dSj5(!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##D'2!
 ))$6!
 4##D'2!
 ))$6!
 D!
 D$$VW5!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6?C++FNC)!
* + 	r   tradec                 @   | j                  |d      }| j                  d |      }| j                  |d      }d }||rdnd}| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	d }
|	Qt	        j
                  |	      }	| j                  |d	      }t	        j
                  |      }|dk(  r|d
   n|d   }|	||d}
| j                  | j                  |d      ||| j                  |      ||d   d |d ||d |
d|      S )Nr  is_seller_makersellbuyr   r   orderIdr   feeRater   r   )r   currencyrater   r   )r   r   r  r7  orderr   r   sidetakerOrMakerr   r   r   r   )r$  safe_market	safe_boolr   r   
string_abs
safe_traderI  )r   rJ  r!  r  isSellerMakerrT  priceStringamountStringrO  feeCostStringr   feeRateStringfeeCurrencyCodes                r   parse_tradezcoinone.parse_trade  sV   0 %%e[9	!!$/u.?@$*6D&&ug6''u5""5)4((6$#..}=M ,,UI>M#..}=M26&.fWovf~O%+%C
 ""5$/"Y/X&  " 
  	r   sincec                    | j                          | j                  |      }|d   |d   d}|t        |d      |d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||||      S )a)  
        get the list of most recent trades for a particular symbol

        https://docs.coinone.co.kr/v1.0/reference/recent-completed-orders

        :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  transactions)r  r!  r   ,v2PublicGetTradesQuoteCurrencyTargetCurrencyr#  r   parse_trades)	r   r   ra  r   r   r!  r  r   r-  s	            r   fetch_tradeszcoinone.fetch_trades  s     	V$$Wo%f~
 !%oGFODDT[[QXZ`Eab& ~~h;  vue<<r   r   rT  r   r   c                 D   |dk7  rt        | j                  dz         | j                          | j                  |      }||d   |d}d| j	                  |      z   | j	                  |      z   }	 t        | |	      | j                  ||            }
| j                  |
|      S )a  
        create a trade order

        https://doc.coinone.co.kr/#tag/Order-V2/operation/v2_order_limit_buy
        https://doc.coinone.co.kr/#tag/Order-V2/operation/v2_order_limit_sell

        :param str symbol: unified symbol of the market to create an order in
        :param str type: must be 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r   z' createOrder() allows limit orders onlyr   )r   rQ  r   privatePostOrder)r   r   r  r!  
capitalizegetattrr#  parse_order)r   r   r   rT  r   r   r   r!  r  methodr   s              r   create_orderzcoinone.create_order  s     7?*S STTV$t

 $dood&;;dood>SS(74(Wf)EF &11r   r   c                     |t        | j                  dz         | j                          | j                  |      }||d   d}| j	                  | j                  ||            }| j                  ||      S )a_  
        fetches information on an order made by the user
        :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>`
        z( fetchOrder() requires a symbol argumentr   )order_idrQ  )r   r   r  r!  v2PrivatePostOrderQueryOrderr#  rl  )r   r   r   r   r!  r  r   s          r   fetch_orderzcoinone.fetch_order?  s{     >#DGG.X$XYYV$t
 44T[[&5QR, &11r   statusc                 8    dddddd}| j                  |||      S )Nr?  closedcanceled)livepartially_filledpartially_canceledfilledrv  )r   )r   rs  statusess      r   parse_order_statuszcoinone.parse_order_statusg  s/     &"("
 &&99r   rS  c                    | j                  |d      }| j                  |d      }| j                  |d      }d }d }|| j                  |      }|| j                  |      }d }|||dz   |z   }| j                  ||d      }| j                  |dd      }	| j	                  |dd      }
|
d	k(  rd
}
n|
dk(  rd}
| j                  |d      }| j	                  |dd      }| j                  |d      }|dk(  r||t        j                  ||      }|rd}| j                  |      }d }| j                  |d      }||
d
k(  r|n|}|| j                  |d      |d}| j                  i d|d|dd d|	d| j                  |	      dd d|dddd dd d|
d| j                  |d      d d d!d d"| j                  |d#      d$|d%| j                  |d&      |||d d'|      S )(NrO  baseCurrencytargetCurrencyr   r  	updatedAtr   rT  r<  rM  r:  rN  	remainQtyoriginalQtyr   rs  rw  rv  r   rP  )r   rR  rQ  r   r   clientOrderIdr7  lastTradeTimestampr   r   r   postOnlyr   r   r   rC  averageExecutedPricer   rz  executedQty)	remainingrs  r   ro   )
r   r   rV  safe_timestamp_2safe_string_2r   	string_ltr|  
safe_orderrI  )r   rS  r!  r   r   r   r   r   r   r  rT  remainingStringr\  rs  
isLessThanr   r]  r_  s                     r   rl  zcoinone.parse_orderq  s   X eY/!!%8""5*:;**62D++G4E5#4CZ%'F%%ffc:F))%kJ	!!%85=DU]D**5+>))%F!!%2V+,2J$..M
'F((0((6$(,eTO%((	:+C
   
E 
" 
 T 
 	 

 Y/ 
 !$ 
 f 
 G 
 4 
  
 D 
 T%%eW5 
 D 
 D 
 t''/EF 
  l! 
" d&&um<# 
$ )+ 
, - 	r   c                    |t        | j                  dz         | j                          | j                  |      }d|d   i}| j	                  | j                  ||            }| j                  |dg       }| j                  ||||      S )a  
        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        zG fetchOpenOrders() allows fetching closed orders with a specific symbolrQ  r   limitOrders)r   r   r  r!  privatePostOrderLimitOrdersr#  r   parse_orders)	r   r   ra  r   r   r!  r  r   r  s	            r   fetch_open_orderszcoinone.fetch_open_orders  s     >*s sttV$t
 33DKK4PQ$ nnX}bA  feUCCr   c                    |t        | j                  dz         | j                          | j                  |      }d|d   i}| j	                  | j                  ||            }| j                  |dg       }| j                  ||||      S )a  
        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>`
        z+ fetchMyTrades() requires a symbol argumentrQ  r   completeOrders)r   r   r  r!   v2PrivatePostOrderCompleteOrdersr#  r   rf  )	r   r   ra  r   r   r!  r  r   r  s	            r   fetch_my_tradeszcoinone.fetch_my_trades  s     >#DGG.[$[\\V$t
 88Wf9UV* 2BBG  FFr   c                    |t        | j                  dz         | j                  |d      }| j                  |d      }| j                  |d      }|||t        | j                  dz         | j	                          ||||| j                  |      d}| j                  | j                  ||            }| j                  |      S )aD  
        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>`
        z cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder.r   r   is_askz\ cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument.)rp  r   r   r  rQ  )	r   r   r   r$  r  	market_idv2PrivatePostOrderCancelr#  r  )	r   r   r   r   r   r   isAskr  r   s	            r   cancel_orderzcoinone.cancel_order*  s     >#DGG  /_  %_  `  `  1vu-!!&(3Ms{#DGG  /M  %M  N  Nv.
 00Wf1MN x((r   codesc                 R   | j                          | j                  |      }| j                  |di       }t        |j	                               }i }t        dt        |            D ]  }||   }||   }	|	r|	dk(  r|j                  d      }
| j                  |
d      }| j                  |
d      }| j                  |      }| j                  ||      }||	|dddd}| j                  |d|	      }| j                  |       ||d<   ||d	<   |d
k(  s|dk(  r|	|d
<   ||	g|d	<   |||<    |S )a]  
        fetch deposit addresses for multiple currencies and chain types
        :param str[]|None codes: list of unified currency codes, default is None
        :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>`
        walletAddressr   z-1_   N)r   rQ  networkaddresstagr  r   r  memo)r  "v2PrivatePostAccountDepositAddressr0  r  r  r   r   splitr  r   r   check_address)r   r  r   r   r  r  r   r   keyvaluepartsr  
secondPartr   depositAddressr  s                   r   fetch_deposit_addresseszcoinone.fetch_deposit_addressesL  s^    	::6B x"EM&&()q#d)$ 	*Aq'C!#&Eu}IIcNE2J2J**:6D!__VT:N%! $##" &&~y%HGw'(/N9%%,N6"e#zV';(-u%*15)9v&)F4L3	*4 r   r   GETc                 (   | j                  ||      }| j                  || j                  |            }| j                  d   d   dz   }	|dk(  r| j                  d   d   dz   }	d}n5|dk(  r| j                  d   d   dz   }	n|dk(  r| j                  d   d   dz   }	|dk(  r|	|z  }	|r|	d| j	                  |      z   z  }	n| j                          |	|z  }	t        | j                               }
| j                  | j                  | j                  |
d	|            }| j                  |      }|}| j                  j                         }| j                  | j                  |      | j                  |      t         j"                        }d
||d}|	|||dS )Nrf   ra   r   rb   r   rc   rd   ?)access_tokennoncezapplication/json)zContent-TypezX-COINONE-PAYLOADzX-COINONE-SIGNATURE)urlrm  bodyheaders)implode_paramsr  extract_paramsr   	urlencodecheck_required_credentialsstrr  jsonr#  ri   string_to_base64rj   upperhmacencodehashlibsha512)r   pathrf   rm  r   r  r  r  queryr  r  r  payloadrj   	signatures                  r   signzcoinone.sign  s   %%dF3		&$"5"5d";<iiv&,*))E":.4CCK))E";/#5CM!))E"=1C7C(?7NCsT^^E222++-7NC

%E99T[[ $*  D ++D1GD[[&&(F		$++g"6F8KW^^\I 2%,'0G
 fdwOOr   r   reasonr  rm  r  r  c
                     |y | j                  |d      }
|
?|
dk7  r:| j                  dz   |z   }| j                  | j                  |
|       t	        |      y )N
error_code0 )r   r   throw_exactly_matched_exceptionr   r   )r   r   r  r  rm  r  r  r   requestHeadersrequestBodyr  feedbacks               r   handle_errorszcoinone.handle_errors  sb    
 $$X|<	 Y#%5ww}t+H00)XV))r   )N).__name__
__module____qualname__r   r   r   r   r   r
   r  r   r  r  r  r	   r   r&  r   r   r.  r   r2  dictr1  r   r`  rg  r   r   floatr   rn  r   rr  r|  r   rl  r  r  r  r   r  r  intr  __classcell__)r   s   @r   r   r      s   v# vp ') >Z >@ $& i$v, iV) )$ $& ,( , :>b ,ls ,l3 ,lY ,l\ 04B <1W <17 <1| 02 413 41f 41l84 8 86 8t; ;v ; ;z 6:UW (=3 (=s (=# (=\`af\g (=T gksu !23 !2i !2y !2RW !2`c !2F 26b &2c &23 &2P: :h hv h hT /3TXac %D %D3 %Dc %Dhlmrhs %DN -1tRV_a &Gc &G &GC &GP 37r  )s  )C  )D 8<B 4W 44P^K_ 4l &eBSW  PD# s  c TX `c r   r   )$ccxt.base.exchanger   ccxt.abstract.coinoner   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   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r   r   <module>r     sY    ( -  f  f  f  f  f  * . ' & * * 4 %[h [r   