
    !:hΨ                         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  G d	 d
ee      Zy)    )Exchange)ImplicitAPIN)AnyBalancesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrTickerTradeTradingFeesTransaction)List)
BadRequest)	TICK_SIZE)Precisec                   0    e Zd Zdef 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.d
e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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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.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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edefd"Z%i fd#ede&fd$Z'd.d%e(de&fd&Z)di fd#ede"d'ede*fd(Z+d.d)ed%e(de*fd*Z,d+d,i ddfd-Z- xZ.S )/independentreservereturnc                    | j                  t        t        |          ddddg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@dAdBdCg dDidEg dFid?dG| j	                  dH      | j	                  dH      dd
dIid
d
d
d d
d
d
d d
d
d
d
dJd
d
d
d
d
d
d
dKd d
dLd d d
dMd
d
d
d
dNd
dLd
d
d
dOd d
dLd d d d
d
d
dPd dQ	d d dRd d dRdSdTdUit
        i dVdWdXdWdYdZd[d\d]dWd^d_d`dadbdWdcdddedfdgdWdhdidjdWdkdWdldWdmdWdndWi dodWdpdWdqdWdrdsdtdWdudvdwdWdxdydzd{d|dWd}dWd~dWdddd{dd{ddWddWdZdWd\d_dadddfdiddydsdvd{dddd      S )Nr   zIndependent ReserveAUNZi  TCORSspotmarginFswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRates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fetchTrades)fetchTradingFeefetchTradingFeesreduceMarginsetLeveragesetMarginModesetPositionModewithdrawzdhttps://user-images.githubusercontent.com/51840849/87182090-1e9e9080-c2ec-11ea-8e49-563db9a38f37.jpgz)https://api.independentreserve.com/Publicz*https://api.independentreserve.com/Private)publicprivatez"https://www.independentreserve.comz&https://www.independentreserve.com/API)logoapiwwwdocget)GetValidPrimaryCurrencyCodesGetValidSecondaryCurrencyCodesGetValidLimitOrderTypesGetValidMarketOrderTypesGetValidOrderTypesGetValidTransactionTypesGetMarketSummaryGetOrderBookGetAllOrdersGetTradeHistorySummaryGetRecentTrades
GetFxRatesGetOrderMinimumVolumesGetCryptoWithdrawalFeesGetCryptoWithdrawalFees2GetNetworksGetPrimaryCurrencyConfig2post)GetOpenOrdersGetClosedOrdersGetClosedFilledOrdersGetOrderDetailsGetAccountsGetTransactionsGetFiatBankAccounts GetDigitalCurrencyDepositAddress!GetDigitalCurrencyDepositAddress2"GetDigitalCurrencyDepositAddresses#GetDigitalCurrencyDepositAddresses2	GetTradesGetBrokerageFeesGetDigitalCurrencyWithdrawalPlaceLimitOrderPlaceMarketOrderCancelOrder0SynchDigitalCurrencyDepositAddressWithBlockchainRequestFiatWithdrawalWithdrawFiatCurrencyWithdrawDigitalCurrencyWithdrawCryptotradingz0.005)takermaker
percentage	tierBased)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceicebergd   )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   )	sandboxr)   createOrdersrC   rF   rE   fetchOrdersr1   
fetchOHLCV)linearinverse)r    r"   r#   PLAPlayChipUSDTEthereumUSDCBTCBitcoinBCHBitcoinCashETHLTCLitecoinXRP	XrpLedgerZRXEOSEosIoXLMStellarBATETCEthereumClassicLINKMKRDAICOMPSNXYFIAAVEGRTDOTPolkadotUNIADACardanoMATICDOGEDogecoinSOLSolanaMANASANDSHIBTRXTronRENDERWIFRLUSDPEPE	BitcoinSV)r   r   r   r   r   r   r   r   BSVr   r   r   r   r   )defaultNetworksnetworks)idname	countries	rateLimitprohasurlsr\   feesfeaturescommonCurrenciesprecisionModeoptions)deep_extendsuperr   describeparse_numberr   )self	__class__s    Q/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/independentreserve.pyr   zindependentreserve.describe   s!   &8$ H J&);;; %; 	;
 %; %; U; t; $U;  ; t; (; '; (; "5;  !;" +E#;$ )%%;& $T';( ');* (+;, &t-;. (/;0 1%1;2 &u3;4 #E5;6 *57;8 $U9;: "5;;< *5=;> +E?;@  A;B %eC;D "5E;F G;H !%I;J  K;L +EM;N "4O;P dQ;R !$S;T  U;V 'W;X $UY;Z !%[;\ *5];^ (_;` %ea;b )%c;d te;f tg;h $)$( %$!&#( u;z IK <?  ,  -0d !..w7!..w7"&!&	  %&+(-,0,1).+06:#(#("'#(	( #(/4$)$)+027#()$, %)&+!$$(%)*/& ',#($)*/	# ',!$#($)*/( $(&+!$$(,0%)#($)*/	* #'q9v ##
 ##CJ z! '#$J#$J#$ 9#$ =	#$
 :#$ :#$ ;#$ :#$ 7#$ 9#$ :#$ ,#$ J#$ :#$ :#$  J!#$" :##$$ :%#$& J'#$( :)#$* :+#$, :-#$. 9/#$0 Z1#$2 J3#$4 85#$6 J7#$8 J9#$: J;#$< 6=#$> h?#$@ 8A#$B ZC#$D JE#$J %%(%&"$,&&%$#!K5YBM
 B B	    c                 L   | j                  |      }| j                  |      }| j                  |      }|||g\  }}}g }t        dt	        |            D ]  }	||	   }
| j                  |
      }| j                  ||
      }t        dt	        |            D ]  }||   }| j                  |      }|
dz   |z   }|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dddddd|dddddddddd|d
         |S )z
        retrieves data on all markets for independentreserve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   /r   symbolbasequotesettleNbaseIdquoteIdsettleIdtyper    Tr!   Fr"   r#   r$   activecontractr   )amountprice)minmax)r   r  r  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)%publicGetGetValidPrimaryCurrencyCodes'publicGetGetValidSecondaryCurrencyCodespublicGetGetOrderMinimumVolumesrangelensafe_currency_codesafe_numberappend)r   paramsbaseCurrenciesPromisequoteCurrenciesPromiselimitsPromisebaseCurrenciesquoteCurrenciesr  resultir   r   	minAmountjr   r   r   s                    r   fetch_marketsz independentreserve.fetch_markets  s,    !% J J6 R!%!M!Mf!U<<VD3HJ`bo2p/ q#n-. 8	A#A&F**62D((8I1c/23 4)!,//8c\G+ 0"0dSj500 D0 U	0
 d0 f0 w0 0 F0 D0 e0 E0 e0 e0 d0  !0" d#0$  $$("&*""&"&!%" $(#'%
 $-#'#
 $(#'"
 $(#'!$  $_0 0	4	8	r r   c                 .   d|i}t        dt        |            D ]i  }||   }| j                  |d      }| j                  |      }| j	                         }| j                  |d      |d<   | j                  |d      |d<   |||<   k | j                  |      S )Nr  r   CurrencyCodeAvailableBalancefreeTotalBalancetotal)r  r  safe_stringr  accountsafe_balance)r   responser  r  balance
currencyIdcoder*  s           r   parse_balancez independentreserve.parse_balanceg  s    )q#h-( 	#AqkG))'>BJ**:6DllnG"..w8JKGFO#//HGG"F4L	#   ((r   c                 f    | j                          | j                  |      }| j                  |      S )a!  
        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>`
        )load_marketsprivatePostGetAccountsr0  )r   r  r,  s      r   fetch_balancez independentreserve.fetch_balances  s1     	..v6!!(++r   Nr   r   c           	         | j                          | j                  |      }|d   |d   d}| j                  | j                  ||            }| j	                  | j                  |d            }| j                  ||d   |dddd	      S )
a  
        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   primaryCurrencyCodesecondaryCurrencyCodeCreatedTimestampUtcr   	BuyOrders
SellOrdersPriceVolume)r2  marketpublicGetGetOrderBookextend	parse8601r)  parse_order_book)r   r   r   r  r>  requestr,  	timestamps           r   fetch_order_bookz#independentreserve.fetch_order_book}  s     	V$#)(#3%+I%6
 --dkk'6.JKNN4#3#3H>S#TU	$$Xvh/?KYegnpxyyr   tickerr>  c                 p   | j                  | j                  |d            }| j                  |d      }| j                  |d      }d }|
||dz   |z   }| j                  ||d      }|d   }| j                  |d      }| j                  i d|d|d| j	                  |      d	| j                  |d
      d| j                  |d      d| j                  |d      dd d| j                  |d      dd dd dd d|d|dd dd dd d| j                  |d      | j                  |d      d |d|      S )Nr9  PrimaryCurrencyCodeSecondaryCurrencyCoder   r   	LastPricerD  datetimehighDayHighestPricelowDayLowestPricebidCurrentHighestBidPrice	bidVolumeaskCurrentLowestOfferPrice	askVolumevwapopencloselastpreviousClosechanger   averageDayAvgPrice DayVolumeXbtInSecondaryCurrrency)
baseVolumequoteVolumer  )rA  r)  safe_marketsafe_tickeriso8601)	r   rF  r>  rD  r   r   defaultMarketIdr   rY  s	            r   parse_tickerzindependentreserve.parse_ticker  s    NN4#3#3F<Q#RS	!!&*?@""6+BCW%8$slW4O!!/63?!4 !
f!
!
 Y/!
 D$$V->?	!

 4##F,<=!
 4##F,DE!
 !
 4##F,EF!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t''>#!
$ **63UV)!
* + 	r   c                     | j                          | j                  |      }|d   |d   d}| j                  | j                  ||            }| j	                  ||      S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        r   r   r6  )r2  r>  publicGetGetMarketSummaryr@  re  )r   r   r  r>  rC  r,  s         r   fetch_tickerzindependentreserve.fetch_ticker  sg     	V$#)(#3%+I%6
 11$++gv2NO   622r   orderc           
      8   d }| j                  |d      }| j                  |d      }d }d }|-|+| j                  |      }| j                  |      }|dz   |z   }n||d   }|d   }|d   }| j                  |dd      }d }	|Z|j                  d	      d
k\  rd}	n|j                  d      d
k\  rd}	|j                  d      d
k\  rd}n|j                  d      d
k\  rd}| j	                  | j                  |d            }
| j                  |d      }| j                  |d      }d }||t        j                  ||      }| j                  i d|d| j                  |d      dd d|
d| j                  |
      dd d|d|dd dd d|	d | j                  |d!      d"d d#| j                  |d$      d%| j                  |d&      d'| j                  |d(d)      d*|| j                  |d+      | j                  | j                  |d,            |||d-d d.|      S )/NrH  rI  r   r   r   r   Typer   Bidr   buyOffersellr
   r>  Limitr   r9  VolumeFilled
FeePercentr  r   	OrderGuidclientOrderIdrD  rK  lastTradeTimestampr   r   postOnlysider  r<  r   r  Valuer\  AvgPricer  VolumeOrderedr=  filledOutstandingStatus)rater  currency)	remainingstatusfeetrades)
r)  r  safe_string_2findrA  r   
string_mul
safe_orderrc  parse_order_status)r   ri  r>  r   r   r   r   r   	orderTyperw  rD  r{  feeRatefeeCosts                 r   parse_orderzindependentreserve.parse_order  s   d !!%)>?""5*ABW%8**62D++G4ECZ%'FH%F&>D7OE&&ufkB	 ~~e$)(A-~~h'1,$	(A-#	NN4#3#3E;P#QR	!!%8""5,76#5((&9G  
E 
$""5+6 
 T 
 	 

 Y/ 
 !$ 
 f 
 I 
 4 
  
 D 
 T%%eW5 
 D 
 D$$UG4 
 t''z: 
  d((J! 
" f# 
$ ))%?--d.>.>uh.OP 
 3 
4 5 	r   r  c                 <    dddddddd}| j                  |||      S )NrW  closedcanceled)OpenPartiallyFilledFilledPartiallyFilledAndCancelled	CancelledPartiallyFilledAndExpiredExpired)r)  )r   r  statusess      r   r  z%independentreserve.parse_order_statusF  s5    %+5#)3!
 &&99r   r   c                     | j                          | j                  | j                  d|i|            }d}|| 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>`
        	orderGuidN)r2  privatePostGetOrderDetailsr@  r>  r  )r   r   r   r  r,  r>  s         r   fetch_orderzindependentreserve.fetch_orderR  sg     	224;;@
4  [[(F&11r   sincec                 :   | j                          | j                  i       }d}|!| j                  |      }|d   |d<   |d   |d<   |d}d|d<   ||d	<   | 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>`
        Nr   r7  r   r8  2      	pageIndexpageSizeData)r2  orderedr>  privatePostGetOpenOrdersr@  	safe_listparse_orders	r   r   r  r   r  rC  r>  r,  datas	            r   fetch_open_ordersz$independentreserve.fetch_open_ordersc  s     	,,r"[[(F-3H-=G)*/5i/@G+,=E #
00Wf1MN~~h3  vue<<r   c                 :   | j                          | j                  i       }d}|!| j                  |      }|d   |d<   |d   |d<   |d}d|d<   ||d	<   | j                  | j	                  ||            }| j                  |d
g       }| j                  ||||      S )a  
        fetches information on multiple closed orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r7  r   r8  r  r  r  r  r  )r2  r  r>  privatePostGetClosedOrdersr@  r  r  r  s	            r   fetch_closed_ordersz&independentreserve.fetch_closed_orders{  s     	,,r"[[(F-3H-=G)*/5i/@G+,=E #
224;;w3OP~~h3  vue<<r   r  c                    | j                          | j                  |dd      }|d}| j                  ||d      }| j                  | j	                  ||            }d}|| j                  |      }| j                  |d   |||      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>`
        r  r  Nr  )r  r  r  )r2  safe_integerr  privatePostGetTradesr@  r>  parse_trades)	r   r   r  r   r  r  rC  r,  r>  s	            r   fetch_my_tradesz"independentreserve.fetch_my_trades  s     	%%fk1=	=E,," 
  ,,T[[&-IJ[[(F  &!165%HHr   tradec                    | j                  |d         }| j                  |d      }| j                  |d      }| j                  |dd      }| j                  |dd      }| j                  |      }| j                  |      }	| j                  t	        j
                  ||            }
| j                  |d      }| j                  |d	      }d }|
||d
z   |z   }| j                  ||d
      }| j                  |d      }|-|j                  d      dk\  rd}n|j                  d      dk\  rd}| j                  |||| j                  |      ||d |d ||	|
d d|      S )NTradeTimestampUtc	TradeGuidrs  r<  SecondaryCurrencyTradePriceVolumeTradedPrimaryCurrencyAmountrH  rI  r   r   rl  r   rm  rn  ro  )r   r  rD  rK  r   ri  r   rw  takerOrMakerr  r  r  r  )
rA  r)  r  r   r   r  safe_symbolr  
safe_traderc  )r   r  r>  rD  r   orderIdpriceStringamountStringr  r  r  r   r   marketIdr   rw  s                   r   parse_tradezindependentreserve.parse_trade  s   NN5)<#=>	e[1""5+6((9VW))%AXY!!+.""<0  !3!3K!NO!!%)>?""5*ABW%8|g-H!!(FC8{3yy1$7#q("Y/  
  	r   c                     | j                          | j                  |      }|d   |d   dd}| j                  | j                  ||            }| j	                  |d   |||      S )a  
        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  )r7  r8  numberOfRecentTradesToRetrieveTrades)r2  r>  publicGetGetRecentTradesr@  r  )r   r   r  r   r  r>  rC  r,  s           r   fetch_tradeszindependentreserve.fetch_trades  sq     	V$#)(#3%+I%6.0

 00Wf1MN  (!3VUEJJr   c                 4   | j                          | j                  |      }i }t        dt        |            D ]D  }||   }| j	                  |d      }| j                  |      }| j                  |d      }||d||<   F i }	t        dt        | j                              D ]t  }| j                  |   }
| j                  |
      }| j                  ||d   i       }| j                  |d      |
| j                  |d      | j                  |d      ddd	|	|
<   v |	S )
a  
        fetch the trading fees for multiple markets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        r   r$  Fee)r  r  r   r  r  T)r  r   r   r   r   r   )
r2  privatePostGetBrokerageFeesr  r  r)  r  r  symbolsr>  
safe_value)r   r  r,  r   r  r  r.  r/  
tradingFeer  r   r>  s               r   fetch_trading_feesz%independentreserve.fetch_trading_fees  s/    	33F; q#h-( 	A1+C))#~>J**:6D))#u5J!DJ	 q#dll+, 	A\\!_F[[(F//$v;CV4 ))#u5))#u5"!F6N		 r   r   rw  r  r  c                    | j                          | j                  |      }| j                  |      }||dk(  rdndz  }| j                  |d   |d   |d      }	d}
||	d<   |d	k(  r'||	d
<   | j	                  | j                  |	|            }
n!| j                  | j                  |	|            }
| j                  |
|
d   d|      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 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>`
        ro  rn  rl  r   r   )r7  r8  r  Nvolumer   r  rs  )r  r   )r2  r>  
capitalizer  privatePostPlaceLimitOrderr@  privatePostPlaceMarketOrderr  )r   r   r   rw  r  r  r  r>  r  rC  r,  s              r   create_orderzindependentreserve.create_order  s     	V$OOD)	We;	,,#)(#3%+I%6" 
 
 "7?$GG66t{{7F7STH77GV8TUH;' 
  	r   c                     | j                          d|i}| j                  | j                  ||            }| j                  |      S )a  
        cancels an open order

        https://www.independentreserve.com/features/api#CancelOrder

        :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>`
        r  )r2  privatePostCancelOrderr@  r  )r   r   r   r  rC  r,  s         r   cancel_orderzindependentreserve.cancel_order,  sL     	
 ..t{{7F/KL  ))r   r/  c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |      S )a  
        fetch the deposit address for a currency associated with self account

        https://www.independentreserve.com/features/api#GetDigitalCurrencyDepositAddress

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        r7  r   )r2  r  +privatePostGetDigitalCurrencyDepositAddressr@  parse_deposit_address)r   r/  r  r  rC  r,  s         r   fetch_deposit_addressz(independentreserve.fetch_deposit_addressM  s`     	==&!8D>
 CCDKKPWY_D`a ))(33r   r  c                     | j                  |d      }| j                  |       || j                  |d      d || j                  |d      dS )Nr   r/  Tag)r  r  networkaddresstag)r)  check_address)r   depositAddressr  r  s       r   r  z(independentreserve.parse_deposit_addressg  sX     "">3CD7#"((6:##NE:
 	
r   r  c                 t   | j                  ||      \  }}| j                          | j                  |      }|d   || j                  ||      d}|||d<   d}| j	                  |      \  }}|t        | j                  dz         | j                  | j                  ||            }	| j                  |	|      S )a[  
        make a withdrawal

        https://www.independentreserve.com/features/api#WithdrawDigitalCurrency

        :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

 EXCHANGE SPECIFIC PARAMETERS
        :param dict [params.comment]: withdrawal comment, should not exceed 500 characters
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        r   )r7  withdrawalAddressr  NdestinationTagz1 withdraw() does not accept params["networkCode"])
handle_withdraw_tag_and_paramsr2  r  currency_to_precisionhandle_network_code_and_paramsr   r   "privatePostWithdrawDigitalCurrencyr@  parse_transaction)
r   r/  r  r  r  r  r  rC  networkCoder,  s
             r   rX   zindependentreserve.withdrawz  s      99#vFV==&#+D>!(00v>

 ?(+G$%"AA&IV"TWW'ZZ[[::4;;wPV;WX$ %%h99r   transactionc                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  ||      }	i d|d| j                  |d	      d
d ddd|	dd d| j                  |d      d| j                  |d      d| j	                  |      d|d|dd d|d|dd d|dd d |	| j                  |d      d dddS ) NAmountDestinationrH  r9  Addressr  r  r   TransactionGuidtxidr   rX   r  r  r  Totalr  r}  rD  rK  r  addressFrom	addressTor  tagFromtagToupdatedr  )r  r  r~  F)commentr  internal)	safe_dictr)  r  r  rA  )
r   r  r  r  destinationr.  rK  r  r  r/  s
             r   r  z$independentreserve.parse_transaction  s   $ X6nn[-@%%k3HI
##K1FG"";	:{E2&&z8<
K
$"";0AB
 D
 J	

 
 t
 d&&vw7
 d&&{H=
 1
 
 w
 4
 
 3
 t
  S!
" t#
$  ((7
 1
 	
r   rY   GETc                 T   | j                   d   |   dz   |z   }|dk(  r|r|d| j                  |      z   z  }ni| j                          | j                         }|d| j                  z   dt        |      z   g}	t        |j                               }
t        dt        |
            D ],  }|
|   }t        ||         }|	j                  |dz   |z          . d	j                  |	      }| j                  | j                  |      | j                  | j                        t        j                         }| j#                  i       }| j                  |d
<   ||d<   |j%                         |d<   t        dt        |
            D ]  }|
|   }||   ||<    | j'                  |      }ddi}||||dS )Nr\   r   rY   ?zapiKey=znonce=r   =,apiKeynonce	signaturezContent-Typezapplication/json)urlmethodbodyheaders)r   	urlencodecheck_required_credentialsr  r   strlistkeysr  r  r  joinhmacencodesecrethashlibsha256r  upperjson)r   pathr\   r  r  r  r  r  r  authr  r  keyvaluemessager  querys                    r   signzindependentreserve.sign  s   iis#c)D0(?sT^^F333++-JJLEDKK'3u:%D
 &D1c$i( /1gF3K(C#I-./ hhtnG		$++g"6DKK8PRYR`R`aILL$E"kkE(O"E'N!*!2E+1c$i( )1g#C[c
) 99U#D%'9:GfdwOOr   )N)/__name__
__module____qualname__r   r   r   r
   r"  r   r0  r4  r	  r	   r   rE  dictr   re  rh  r   r  r   r  r  r  r  r  r   r  r  r   r  r   r   floatr   r  r  r   r  r   r  r   rX   r  r  __classcell__)r   s   @r   r   r      s   C# CJ $& N$v, N`
) 
) $& ,( , :>b zs z3 zY z$,4 , ,6 ,\ 02 33 3f 3:j jv j jX
: 
: 26b 2c 23 2" /3TXac = =3 =c =hlmrhs =0 154VZce =# =S =PS =jnotju =0 -1tRT]_ Ic I IC I.# #v # #J 6:UW K3 Ks K# K\`af\g K& )+ ({ (T gksu 3 i y RW `c @ 37r *s *C *B 79 4# 4^ 44
h 
R` 
& DHPR 0:S 0:% 0:# 0:Wb 0:d2
T 2
X 2
Q\ 2
h &eBSW Pr   r   )ccxt.base.exchanger    ccxt.abstract.independentreserver   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r   r   <module>r)     sL    ( 8  l  l  l  l  l  ' 4 %mP; mPr   