
    E#i                       S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJ r   S SKJ!r!  S SKJ"r"  S SK#J$r$  S SK%J&r&   " S S\\5      r'g)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntMarginModificationMarketOrder	OrderSide	OrderTypePositionStrStringsTickerTickersTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InvalidOrder)DuplicateOrderId)	TICK_SIZE)Precisec                   T  ^  \ rS rSrS\4U 4S jjr0 4S\4S jjrS\S\4S jr0 4S jr	S	 r
S
SS0 4S\S\S\S\S\\   4
S jjrS]S\S\4S jjrSSS0 4S\S\S\4S jjrS]S\4S jjrS]S\4S jjrSSS0 4S\S\S\4S jjrS]S\4S jjrSSS0 4S\S\S\S\\   4S jjrS]S\S\S\4S jjrS\S\4S jr0 4S\S\4S  jjrS! r0 4S" jr 0 4S# jr!0 4S$ jr"0 4S\S%\#S\$4S& jjr%SSS0 4S\S\S\S\\&   4S' jjr'0 4S\4S( jjr(S]S)\S\4S* jjr)S0 4S+\*S\\+   4S, jjr,SSS0 4S\S\S\S\\&   4S- jjr-SSS0 4S\S\S\S\\&   4S. jjr.S\4S/ jr/S]S0\S\S\&4S1 jjr0S]S2\S\S\14S3 jjr20 4S\\   4S4 jjr3S\S\4S5 jr40 4S\54S6 jjr6S\S\4S7 jr7S0 4S+\*S\84S8 jjr90 4S\S\:4S9 jjr;S]S:\<S\S\:4S; jjr=0 4S\>4S< jjr?S\>4S= jr@0 4S\S%\#S>\S?\S\4
S@ jjrAS0 4S\SA\BSB\CS%\#SC\#4
SD jjrDS]SE\S\S\E4SF jjrFS\4SG jrGSA\4SH jrHS0 4SI\S\4SJ jjrIS0 4S\4SK jjrJSS0 4SI\S\SA\BSB\CS%\#SC\#4SL jjrKS0 4SI\S\4SM jjrLSSS0 4S\S\S\S\\E   4SN jjrMSSS0 4S\S\S\4SO jjrNS0 4S\S%\#SP\SQ\S\&4
SR jjrOSS rP/ ST0 SS4SU jrQS\RSV\SW\SX\SY\SZ\4S[ jrSS\rTU =rU$ )^coinbaseinternational   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S
_SS_SS_SU R                  S   _SSS0_S0 SS
_SS
_SS
_SS
_SS
_SS_SS_SS
_SS
_SS_SS_S S_S!S
_S"S
_S#S
_S$S
_S%S_0 S&S_S'S
_S(S_S)S
_S*S
_S+S_S,S
_S-S
_S.S
_S/S
_S0S
_S1S
_S2S_S3S_S4S_S5S_S6S_E0 S7S_S8S_S9S
_S:S
_S;S
_S<S_S=S
_S>S_S?S_S@S_SAS_SBS_SCS_SDS_SES_SFS_SGS_E0 SHS
_SIS_SJS
_SKS
_SLS
_SMS
_SNS_SOS
_SPS
_SQS_SRS_SSS
_STS_SUS_SVS
_SWS_SXS_E0 SYS_SZS
_S[S
_S\S_S]S_S^S_S_S_S`S
_SaS
_SbS_ScS
_SdS_SeS
_SfS_SgS_ShS
_E_SiSjSkSl0SkSm0SnSo/Sp/SqSr._SsS
S
S
St._SuSSv/ SwQ0/ SxQ/ SyQSzS{/S|Sz/S}.S~.0_SSU R                  S5      U R                  S5      S
S
U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      //U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      //S.S.0_S[        _S0 [        [        [        [        [        [        [        [        [        [        S.
S._SSSSSSSSSS._SSqSS0SSSSSSSS.S.S
SS
S S
SSS S
S
S
S
S
S.SSSSS
S
SS.S SSS SSS.SSSSS.SSSSSS.S S SS0S.	SS0SS0SS0S.S S S.S.S.E5      $ )Nidr#   namezCoinbase International	countriesUS	certifiedFproT	rateLimitd   versionv1	userAgentchromeheadersz
CB-VERSIONz
2018-05-30hasCORSspotmarginswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateLimitBuyOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrdercreateMarketSellOrderWithCostcreateOrdercreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL2OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyBuysfetchMySellsfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransfersfetchWithdrawalsreduceMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModewithdrawurlszQhttps://github.com/ccxt/ccxt/assets/43336371/866ae638-6ab5-4ebf-ab2c-cdcce9545625restz*https://api.international.coinbase.com/apiz!https://api-n5e1.coinbase.com/apiz"https://international.coinbase.comz)https://docs.cloud.coinbase.com/intx/docszlhttps://help.coinbase.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees )logoapitestwwwdocfeesreferralrequiredCredentials)apiKeysecretpasswordr   get)assetszassets/{assets}zassets/{asset}/networksinstrumentszinstruments/{instrument}zinstruments/{instrument}/quotez instruments/{instrument}/fundingz instruments/{instrument}/candles)ordersorders/{id}
portfoliosportfolios/{portfolio}zportfolios/{portfolio}/detailzportfolios/{portfolio}/summaryzportfolios/{portfolio}/balancesz'portfolios/{portfolio}/balances/{asset}z portfolios/{portfolio}/positionsz-portfolios/{portfolio}/positions/{instrument}zportfolios/fillszportfolios/{portfolio}/fills	transfersztransfers/{transfer_uuid})	r   r   zportfolios/marginzportfolios/transferztransfers/withdrawztransfers/addressz transfers/create-counterparty-idz"transfers/validate-counterparty-idztransfers/withdraw/counterpartyr   r   r   )r   postputdelete)publicprivater   tradingz0.004z0.002010000005000000z0.00351000000050000000z0.003	250000000z0.0025z0.0016z0.001z0.0008z0.0005)takermaker)r   r   	tierBased
percentagetiersprecisionMode
exceptions)
DUPLICATE_CLIENT_ORDER_IDzOrder rejectedzmarket orders must be IoCztif is requiredzInvalid replace order requestUnauthorizedzinvalid result_limitzis a required fieldz	Not Foundzip not allowed)exactbroad
timeframes
ONE_MINUTEFIVE_MINUTEFIFTEEN_MINUTETHIRTY_MINUTEONE_HOURTWO_HOURSIX_HOURONE_DAY)1m5m15m30m1h2h6h1dnfqkvdjpmethodv1PrivatePostTransfersWithdrawETHARBITRUMAVAXOPTIMISMMATICSOLBTC)ethereumarbitrum	avacchainoptimismpolygonsolanabitcoin)brokerId	portfolior   networksById)IOCFOKPOGTDGTC)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg'  )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   r   i,  )	r   rI   createOrdersrl   rp   ro   rr   rV   rm   extendsdefault)linearinverse)r   r6   r8   r9   )optionsfeatures)deep_extendsuperr#   describe
userAgentsparse_numberr    r   r   r   r   r   )self	__class__s    T/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/coinbaseinternational.pyr   coinbaseinternational.describe   s{	   &;T K M vP
)vP
,vP
 $vP
 	vP

 4vP
 vP
 tvP
 2vP
 lvP
  UUU $U 	U
 $U %U UU "4U tU U $UU  U 'U &tU 'U  '!U" /#U$ ,U%U& ('U( 0)U* t+U, &t-U. (/U0 '1U2 (3U4 "45U6 T7U8  9U: ;U<  =U> +E?U@ )%AUB &uCUD $UEUF 'GUH (IUJ "4KUL  MUN &tOUP #EQUR *4SUT $UUUV "5WUX *5YUZ +E[U\ #E]U^ u_U`  aUb %ecUd /eUf "5gUh iUj !%kUl tmUn oUp  qUr dsUt +EuUv "4wUx dyUz !%{U| u}U~  U@ 'AUB $UCUD !$EUF (GUH %eIUJ )%KUL tMUN OUP UQUR uSUT "5UUV #EWUX !$YUZ #D[U\ ]U^ 4_U` uaUb TcUd  eUf "5gUh DiUvP
D kH ? <? C EvP
f " $gvP
p  	   
! *4 
 %)#A$ 24qvP
Z !..w7!..w7!%"& "..s3T5F5Fw5OP!..y94;L;LW;UV!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mg<VW!..{;T=N=Nx=XY" "..s3T5F5Fw5OP!..y94;L;LX;VW!..y94;L;LW;UV!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..{;T=N=Ns=ST"[vP
N YOvP
P 1A&21='35A$4,6+5!+&9QvP
n "#'&   	ovP
D '> !& *!' *&#$!$  $&+(,,0,0).+06:#'#'"&#'#'( #($)$)+026/3#(+$. %)&+!$$(%**/& ',#($)*/	# ',!$#($)*/( $()-#a3j y
 "9 "9 	 ##ADcvP
 v v	    
methodNamec                    S nU R                  X!S5      u  p2Ub	  US:w  a  X2/$ U R                  U R                  S5      nUb	  US:w  a  XB/$ U R                  5       n[	        S[        U5      5       HV  nXV   nU R                  US0 5      nU R                  US5      (       d  M3  U R                  US5      n	XR                  S'   X/s  $    [        U R                  S-   U-   S-   5      e)	Nr   r   r   info
is_defaultportfolio_id z]() requires a portfolio parameter or set the default portfolio with self.options["portfolio"])
handle_option_and_paramssafe_stringr   fetch_accountsrangelen	safe_dict	safe_boolr   r'   )
r  r  paramsr   defaultPortfolioaccountsiaccountr  portfolioIds
             r  handle_portfolio_and_params1coinbaseinternational.handle_portfolio_and_paramsQ  s    	 99&kZ	!	R&&++DLL+F(/?2/E$--&&(q#h-(AkG>>'626D~~dL11"..t^D,7[)#,, )  #
 :  >]  !]  ^  	^r  currencyCodec                 h   S nU R                  X2S5      u  pCUc  U R                  U5        U R                  U   S   nU R                  USS5      nUcM  U R	                  U5      (       a  [        U R                  S-   U-   S-   5      eU R                  U5      nUS   nXC/$ U R                  Xa5      nXC/$ )Nnetwork_arn_idnetworksnetworkCodenetworkz5 createDepositAddress network not found for currency z# please specify networkId in paramsr'   )	r  load_currency_networks
currenciessafe_string_2is_emptyr   r'   find_default_networknetwork_code_to_id)r  r  r  r  	networkIdr  r   defaultNetworks           r  handle_network_id_and_params2coinbaseinternational.handle_network_id_and_paramsc  s    	 99&N^_	''5|4Z@H((	JG==**$TWW/f%fiu%u  y^  &^  _  _!%!:!:8!D*40	 "" !33GJ	""r  c                 f    U R                  5         U R                  U5      nU R                  X!5      $ )a>  
fetch all the accounts associated with a profile

https://docs.cloud.coinbase.com/intx/reference/getportfolios

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
)load_marketsv1PrivateGetPortfoliosparse_accountsr  r  responses      r  r  $coinbaseinternational.fetch_accountst  s3     	..v6$ ""844r  c                 2    U R                  USS5      S S US.$ )Nr
  portfolio_uuid)r'   typecoder  )r#  )r  r  s     r  parse_account#coinbaseinternational.parse_account  s*    " $$Wn>NO	
 	
r  r   Nr.   symbol	timeframesincer   c           	      P   U R                  5         SnU R                  USS5      u  peU(       a  U R                  SXXBUS5      $ U R                  U5      nUS   U R	                  U R
                  X"5      S.nUb  U R                  U5      US'   O[        U R                  S-   5      eU R                  US	5      n	U	b&  U R                  US	5      nU R                  U	5      US
'   U R                  U R                  X5      5      n
U R                  U
S/ 5      nU R                  XX#U5      $ )a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://docs.cdp.coinbase.com/intx/reference/getinstrumentcandles

: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, default 100 max 10000
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
:param int [params.until]: timestamp in ms of the latest candle to fetch
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
Frm   paginater   r'   )
instrumentgranularitystartz' fetchOHLCV() requires a since argumentuntilendaggregations)r,  r  "fetch_paginated_call_deterministicmarketr  r   iso8601r   r'   safe_integeromit'v1PublicGetInstrumentsInstrumentCandlesextend	safe_listparse_ohlcvs)r  r8  r9  r:  r   r  r<  rD  requestunitlr0  candless               r  fetch_ohlcv!coinbaseinternational.fetch_ohlcv  s'    	88zZ::<X]jprwxxV$ ,++DOOYR
 #||E2GG#DGG.W$WXX!!&'2YYvw/F!\\%0GEN??G@\] ..>2>  )EJJr  rD  c           	          U R                  U R                  USS5      5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr?  timeopenhighlowclosevolume)	parse8601r#  safe_number)r  ohlcvrD  s      r  parse_ohlcv!coinbaseinternational.parse_ohlcv  sy     NN4--eWfEFUF+UF+UE*UG,UH-
 	
r  c           	         Uc  [        U R                  S-   5      eU R                  5         SnU R                  USS5      u  pTSnU R                  USSS5      u  pdSnU(       a  U R	                  SXX4Xv5      $ U R                  U5      nU R                  XGS	5      S	-
  n	US
   U R                  USSX-  5      S.n
Ub  X:S'   U R                  U R                  X5      5      nU R                  US/ 5      nU R                  XX#5      $ )aA  
fetches historical funding rate prices

https://docs.cloud.coinbase.com/intx/reference/getinstrumentfunding

:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: timestamp in ms of the earliest funding rate to fetch
:param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
Nz5 fetchFundingRateHistory() requires a symbol argumentFr]   r<  maxEntriesPerRequestr.   ccxtPageKey   r'   offsetresult_offset)r=  rb  result_limitresults)r   r'   r,  r   fetch_paginated_call_incrementalrD  rF  safe_integer_2'v1PublicGetInstrumentsInstrumentFundingrI  rJ  parse_funding_rate_histories)r  r8  r:  r   r  r<  r^  pageKeyrD  pagerL  r0  rawRatess                r  fetch_funding_rate_history0coinbaseinternational.fetch_funding_rate_history  s6    >#DGG.e$eff88AZ\fg#'+'D'DVMfh~  AD  (E$889RTZchry  Q  QV$  !4q8 ,!00?TXTop
 &+N#??G@\]$ >>(Ir:005PPr  c                 $    U R                  X5      $ N)parse_funding_rate)r  r  rD  s      r  parse_funding_rate_history0coinbaseinternational.parse_funding_rate_history$  s    &&t44r  c                 .   U R                  USS5      n0 SU_SU R                  S U5      _SU R                  US5      _SS _SS _S	S _S
U R                  U5      _SU_SU R                  US5      _SU R                  U5      _SU_SS _SS _SS _SS _SS _SS _$ )N
event_timerR  r  r8  	markPrice
mark_price
indexPriceinterestRateestimatedSettlePrice	timestampdatetimefundingRatefunding_ratefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)r#  safe_symbolrY  rX  )r  contractrD  r  s       r  rp  (coinbaseinternational.parse_funding_rate'  s#    ,,X|VL
H
d&&tV4
 ))(LA
 $	

 D
 #D
 8
 
 4++HnE
  ?
 
 t
 #D
 "4
 "4
  '!
" &t#
 	
r  c                 d   U R                  5         SS0nSnUb  U R                  U5      nSnU R                  USS5      u  ptUb  XuS'   Ub  U R                  U5      US'   Ub  X5S'   OSUS'   U R	                  U R                  XT5      5      nU R                  US	/ 5      n	U R                  XX#5      $ )
a  
fetch the history of funding payments paid and received on self account

https://docs.cdp.coinbase.com/intx/reference/gettransfers

:param str [symbol]: unified market symbol
:param int [since]: the earliest time in ms to fetch funding history for
:param int [limit]: the maximum number of funding history structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
r4  FUNDINGNr[   r   	time_fromrc  r.   rd  )r,  rD  r  rE  v1PrivateGetTransfersrI  rJ  parse_incomes)
r  r8  r:  r   r  rL  rD  r   r0  fundingss
             r  fetch_funding_history+coinbaseinternational.fetch_funding_historyE  s     	I
 [[(F
!::6CXZfg
!$.L!#'<<#6GK &+N#&)GN#--dkk'.JK>>(Ir:!!(EAAr  c           
      R   U R                  US5      nU R                  X2S S5      nU R                  US5      nU R                  U5      nU R                  US5      nU R	                  U5      nUUS   UUU R                  U5      U R                  US5      U R                  US5      S S.$ )Nr8  r  
created_atassettransfer_uuidamount)r  r8  r5  rz  r{  r'   r  rate)r  safe_marketrF  rX  safe_currency_coderE  rY  )r  incomerD  marketIdr{  rz  
currencyIdr5  s           r  parse_income"coinbaseinternational.parse_incomef  s    . ##FH5!!(D*E$$V\:NN8,	%%fg6
&&z2X&"Y/""6?;&&vx8	
 		
r  r5  c                 d   U R                  5         SS0nSnUb  U R                  U5      nSnU R                  USS5      u  ptUb  XuS'   Ub  U R                  U5      US'   Ub  X5S'   OSUS'   U R	                  U R                  XT5      5      nU R                  US	/ 5      n	U R                  XX#5      $ )
a  
fetch a history of internal transfers made on an account

https://docs.cdp.coinbase.com/intx/reference/gettransfers

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for
:param int [limit]: the maximum number of  transfers structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
r4  INTERNALNr   r   r  rc  r.   rd  )r,  currencyr  rE  r  rI  rJ  parse_transfers)
r  r5  r:  r   r  rL  r  r   r0  r   s
             r  fetch_transfers%coinbaseinternational.fetch_transfers  s     	J
 }}T*H
!::6CSUab
!$.L!#'<<#6GK &+N#&)GN#--dkk'.JKNN8Y;	##IFFr  transferr  c                    U R                  US5      nU R                  U5      nU R                  US5      nU R                  U5      nU R	                  US0 5      nU R                  US5      nU R	                  US0 5      n	U R                  U	S5      n
UU R                  US5      UU R                  U5      UU R                  US5      UU
U R                  U R                  US5      5      S	.	$ )
Nr  r  from_portfolior'   to_portfolior  r  status	r  r'   rz  r{  r  r  fromAccount	toAccountr  )rF  rX  r  r  r  rE  rY  parse_transfer_status)r  r  r  r{  rz  r  r5  fromPorfoliofromId
toPorfoliotoIds              r  parse_transfer$coinbaseinternational.parse_transfer  s    . $$X|<NN8,	%%h8
&&z2~~h0@"E!!,5^^HnbA

D1""8_="Y/&&x:!001A1A(H1UV

 
	
r  r  c                 4    SSSSS.nU R                  X!U5      $ )Nfailedokpending)FAILED	PROCESSEDNEWSTARTEDr  r  r  statusess      r  r  +coinbaseinternational.parse_transfer_status  s*     	
 &99r  c                    U R                  5         SnU R                  USSS5      u  p2SnU R                  SU5      u  pBSU0nUS:X  a4  U R                  U5      nUS   US'   SnU R	                  USU5      u  prXuS'   [        X5      " U R                  XR5      5      nU R                  US	5      n	U R                  US
S5      n
UU	U
SUS.$ )a  
create a currency deposit address

https://docs.cloud.coinbase.com/intx/reference/createaddress
https://docs.cloud.coinbase.com/intx/reference/createcounterpartyid

:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network_arn_id]: Identifies the blockchain network(e.g., networks/ethereum-mainnet/assets/313ef8a9-ae5a-5f2f-8a56-572c0e2a4d5a) if not provided will pick default
:param str [params.network]: unified network code to identify the blockchain network
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
NrA   r   v1PrivatePostTransfersAddressr   r'   r  r  destination_tagaddresscounterparty_id)r  tagr  r   r  )	r,  r  r  r  r)  getattrrI  r  r#  )r  r5  r  r   r   rL  r  r'  r0  r  r  s              r  create_deposit_address,coinbaseinternational.create_deposit_address  s    	66v?UW_  bA  B	 <<=SU[\	
 44}}T*H'~GGI $ A A$H^`f gI(1$%4(W)EF x):;$$Xy:KL
 	
r  c                     U R                  U5      n[        S[        U5      5       H(  nX#   S   nU R                  USS5      nUSL d  M$  X#   s  $    US   $ )Nr   r  r	  FT)to_arrayr  r  r  )r  r  networksArrayr  r  r	  s         r  r%  *coinbaseinternational.find_default_network  sc    h/q#m,-A #F+DlEBJT!$''	 .
 Qr  c                     U R                  U5      nU R                  US5      nUb  gSUS   0nU R                  U5      nU R                  U5      US'   g)Nr  Fr  r'   T)r  r  v1PublicGetAssetsAssetNetworksparse_networks)r  r5  r  r  r  rL  rawNetworkss          r  r!  ,coinbaseinternational.load_currency_networks  se    ==&>>(J7Xd^
 99'B&  $22;?r  c                     0 n[        S[        U5      5       H-  nU R                  U R                  X   5      U5      nXSUS   '   M/     U$ )Nr   r   )r  r  rI  parse_network)r  r  r  resultr  r   s         r  r  $coinbaseinternational.parse_networks=  sM    q#h-(Akk$"4"4X["A6JG)079%& ) r  c                 ^   U R                  US5      nU R                  U5      nU R                  US5      nU R                  U/ SQS5      nU R                  UUU R                  US5      U R	                  Xd5      S S S S S U R                  US5      U R                  US5      S.S S S.S	.S
.
5      $ )N
asset_namer  )network_namedisplay_namer  r   r  min_withdrawal_amtmax_withdrawal_amtminmaxr   deposit)
r  r'   r(   r   activer  r   	precisionfeelimits)r  r  safe_string_nsafe_networknetwork_id_to_coderY  )r  r   r  r  r  r'  networkIdForCodes          r  r  #coinbaseinternational.parse_networkD  s      %%g|<
..z:$$W.>?	--g7ikmn  $$Wn=../?N  ++G5IJ++G5IJ
  	"
  	r  r  c                     SnU R                  SU5      u  pCUb  [        U R                  S-   5      eUUS.nU R                  U R	                  XS5      5      $ )a  
Either adds or reduces margin in order to set the margin to a specific value

https://docs.cloud.coinbase.com/intx/reference/setportfoliomarginoverride

:param str symbol: unified market symbol of the market to set margin in
:param float amount: the amount to set the margin to
:param dict [params]: parameters specific to the exchange API endpoint
:returns dict: A `margin structure <https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure>`
Nr   z9 setMargin() only allows setting margin to full portfolio)r   margin_override)r  r   r'   v1PrivatePostPortfoliosMarginrI  )r  r8  r  r  r   rL  s         r  
set_margin coinbaseinternational.set_marginn  sb     	 <<[&Q	TWW'bbcc"%
 11$++g2NOOr  c           	         U R                  5         SnU R                  USS5      u  pTSnU R                  USSS5      u  pdSnU(       a  U R                  SXX4Xv5      $ U R                  XGS5      S-
  nSU R	                  US	SX-  5      0n	Ub  U R                  U5      U	S
'   Ub  [        US5      n
XS'   SnU R                  USS5      u  pUb  XS'   SnU R                  USS5      u  pUb  U R                  U5      U	S'   U R                  U R                  X5      5      nU R                  US/ 5      nU R                  U5      $ )af  
fetch history of deposits and withdrawals

https://docs.cloud.coinbase.com/intx/reference/gettransfers

:param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
:param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
:param int [limit]: max number of deposit/withdrawals to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.portfolios]: Identifies the portfolios by UUID(e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID(e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
:param int [params.until]: Only find transfers updated before self time. Use timestamp format
:param str [params.status]: The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
:param str [params.type]: The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NfetchDepositsWithdrawalsr<  r^  r.   r_  r`  rb  ra  r  rc  r   r@  time_tord  )r,  r  re  rF  rf  rE  r  r  rI  rJ  parse_transactions)r  r5  r:  r   r  r<  r^  ri  rj  rL  newLimitr   r@  r0  rawTransactionss                  r  fetch_deposits_withdrawals0coinbaseinternational.fetch_deposits_withdrawals  s   " 	88A[]gh#'+'D'DVMgi  BE  (F$889SUYbgqx  P  P  !4q8T00?TXTop
 #'<<#6GK 5#H&.N#
!::6C]_kl
!$.L!55f>XZab!%e!4GI--dkk'.JK6 ..9bA&&77r  c                     U R                  5         U R                  U5      nSnU R                  SU5      u  p2UU R                  U5      S.nU R	                  U R                  XB5      5      nU R                  U5      $ )aY  

https://docs.cloud.coinbase.com/intx/reference/getportfolioposition

fetch data on an open position
:param str symbol: unified market symbol of the market the position is held in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nrs   )r   r=  )r,  r8  r  	market_id2v1PrivateGetPortfoliosPortfolioPositionsInstrumentrI  parse_position)r  r8  r  r   rL  positions         r  fetch_position$coinbaseinternational.fetch_position  s}     	V$	 <<_fU	"..0
 JJ4;;W^Kgh  ""8,,r  r  c           
      :   U R                  US5      nU R                  US5      nU R                  X2S5      nSn[        R                  " US5      (       a  Sn[        R                  " SU5      nU R                  0 SU_S	U R                  US	5      _SUS   _S
S _SU R                  US5      _SS _SS _SU R                  US5      _SU_SU R                  U5      _SU R                  US5      _SS _SS _SS _SS _SS _SU R                  US5      _S S S S S S S.E5      $ )Nr8  net_size-longr   shortz-1r  r'   
entryPriceru  rv  notional
collateralunrealizedPnlunrealized_pnlside	contractscontractSizerz  r{  r   maintenanceMarginmaintenanceMarginPercentageinitialMarginim_contribution)initialMarginPercentager   liquidationPricemarginRatior   r   )r  r  r!   	string_le
string_mulsafe_positionrY  r   )r  r  rD  r  quantityr  s         r  r  $coinbaseinternational.parse_position  s     ##Hh7##Hj9!!(C8Xs++D))$9H!! #
H#
$""8T2#
 fX&#
 $	#

 ))(LA#
 #
 $#
 T--h8HI#
 D#
 **84#
 D,,V^D#
 #
 #
 d#
  #
  *4!#
" T--h8IJ##
$ (, $/#
  	r  symbolsc                 2   U R                  5         SnU R                  SU5      u  p2SU0nU R                  U R                  XB5      5      nU R	                  U5      nU R                  U5      (       a  U$ U R                  U5      nU R                  USUS5      $ )aF  

https://docs.cloud.coinbase.com/intx/reference/getportfoliopositions

fetch all open positions
:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nrv   r   r8  F)r,  r  (v1PrivateGetPortfoliosPortfolioPositionsrI  parse_positionsr$  market_symbolsfilter_by_array_positions)r  r  r  r   rL  r0  	positionss          r  fetch_positions%coinbaseinternational.fetch_positions   s     		 <<=MvV	
 @@WA]^$ ((2	==!!%%g.--i7ERRr  c                 P    U R                  5         SUS'   U R                  XX45      $ )a  
fetch all withdrawals made from an account

https://docs.cloud.coinbase.com/intx/reference/gettransfers

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.portfolios]: Identifies the portfolios by UUID(e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID(e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
:param int [params.until]: Only find transfers updated before self time. Use timestamp format
:param str [params.status]: The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
:param str [params.type]: The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
WITHDRAWr4  r,  r  r  r5  r:  r   r  s        r  fetch_withdrawals'coinbaseinternational.fetch_withdrawalsH  s,    " 	#v..tEJJr  c                 P    U R                  5         SUS'   U R                  XX45      $ )a  
fetch all deposits made to an account
:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.portfolios]: Identifies the portfolios by UUID(e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID(e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
:param int [params.until]: Only find transfers updated before self time. Use timestamp format
:param str [params.status]: The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
:param str [params.type]: The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
DEPOSITr4  r!  r"  s        r  fetch_deposits$coinbaseinternational.fetch_deposits]  s,     	"v..tEJJr  c                 4    SSSSS.nU R                  X!U5      $ )Nr  r  canceled)r  r  r  r  r  r  s      r  parse_transaction_status.coinbaseinternational.parse_transaction_statuso  s*      	
 &99r  transactionc           
         U R                  US5      nU R                  US0 5      nU R                  USSU R                  U/ SQ5      S/5      nU R                  US0 5      nU R                  USSU R                  U/ SQ5      S	/5      n0 S
U_SU R                  US5      _SU R                  US5      _SU R                  U5      _SU_SU R	                  U R                  US5      5      _SS _SU_SU_SS _SS _SS _SU R                  US5      _SU R                  US5      _SU R                  U R                  US5      U5      _SU R                  U R                  US5      5      _SU R                  U5      _S S S S!.0E$ )"N
updated_atr  from_addressfrom_cb_account)r'   uuidr(   from_counterparty_id
to_addressto_cb_accountto_counterparty_idr  r'   r  txidtransaction_uuidrz  r{  r   r  r  	addressToaddressFromr  tagTotagFromr4  resourcer  r  r  r  updatedr  costr  )r  r  r  rX  r  rY  r  r+  )r  r-  r  r{  r  r:  r  r9  s           r  parse_transaction'coinbaseinternational.parse_transactionx  s3    ##K>~~k3CRH((~GXZ^ZlZlmy  |R  [S  Uk  7l  m^^K1A2F
&&{\?TXTfTfgq  tJ  UK  Ma  5b  c	
K
$"";@
 D$$[2DE
 1	

 
 t..t/?/?^/\]
 t
 
 ;
 4
 T
 t
 D$$[*=
 d&&{H=
 //0@0@g0VX`a
  d33D4D4D[RZ4[\!
" t~~h/#
$  %
 	
r  tradec                    U R                  US5      nU R                  US5      nU R                  UU R                  USS5      U R                  US5      U R                  U5      UU R	                  X25      S U R                  US5      S U R                  US5      U R                  US5      S U R                  US	5      U R                  U R                  US
5      5      S.S.5      $ )Nr8  rt  fill_idexec_idorder_idr  
fill_pricefill_qtyr  	fee_assetr?  )r  r'   orderrz  r{  r8  r4  r  takerOrMakerpricer  r@  r  )r  
safe_trader#  rX  r  safe_string_lowerrY  r  )r  rC  rD  r  r{  s        r  parse_trade!coinbaseinternational.parse_trade  s    B ##E84##E<8$$UIyA%%eZ81 &&x8**5&9 %%e\:&&uj9((6 33D4D4DUK4XY 
  	r  c                 F    U R                  U5      nU R                  U5      $ )a  

https://docs.cloud.coinbase.com/intx/reference/getinstruments

retrieves data on all markets for coinbaseinternational
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
)v1PublicGetInstrumentsparse_marketsr/  s      r  fetch_markets#coinbaseinternational.fetch_markets  s(     ..v6d !!(++r  c                 R   U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nUS:H  nU R                  nUS-   U-   nS n	U(       d
  Un	USU-   -  n0 SU_S	UR                  5       _SU_S
U_SU_SU	(       a  U	OS _SU_SU_SU	(       a  U	OS _SU(       a  SOS_SU_SS_SU(       + _SS_SS_SU R                  US5      S:H  _SU(       + _U(       a  S OX:H  U(       a  S OX:g  US   S   US   S   U(       a  S OSS S S S U R                  US5      U R                  US5      U R                  US5      S .S U R                  US!5      S".S U(       a  S OU R                  US#5      S".S S S".U R                  US$5      S S".S%.US S&.E$ )'Nr8  base_asset_namequote_asset_namer4  SPOT/:r'   lowercaseIdbasequotesettlebaseIdquoteIdsettleIdr6   r8   r7   Fr9   r:   r  trading_stateTRADINGr  r   r   r   r`  base_incrementquote_increment)r  rM  r@  base_imfr  position_limit_qtymin_notional_value)r   r  rM  r@  )r   r   r   r   r	  expiryexpiryDatetimestrike
optionTyper  r  r  created)r  r   lowerrY  )
r  rD  r  ra  rb  typeIdisSpotr   r8  rc  s
             r  parse_market"coinbaseinternational.parse_market  ss   ^ ##FH5!!&*;<""6+=>!!&&1F"yy#'HcGm#F4
(4
8>>+4
 f4
 F	4

 W4
 (h4
 f4
 w4
 H$4
 fF&4
 F4
 e4
 J4
 e4
 e4
  d&&v?9L!4
" F
#4
$ %d8+>%tH,?)_W-)_W-$*D"**63CD))&2CD((1BC  ++FJ?
  #)4t/?/?H\/]
  
  ++F4HI$ g4
 4	
r  c                 F    U R                  U5      nU R                  U5      $ )z
fetches all available currencies on an exchange

https://docs.cloud.coinbase.com/intx/reference/getassets

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
)v1PublicGetAssetsparse_currencies)r  r  r"  s      r  fetch_currencies&coinbaseinternational.fetch_currencies~  s'     ++F3
 $$Z00r  c                     U R                  US5      nU R                  U5      nU R                  US5      nU R                  UUUS UUS:H  S S S S S U R                  S.5      $ )Nr  r  ACTIVE)r'   r(   r5  r  r  r  r  r   r  r  r   r  )r  r  safe_currency_structurer  )r  r  r'   r5  statusIds        r  parse_currency$coinbaseinternational.parse_currency  s}     h5&&r*##Hh7++8+kk-
  	r  c                    U R                  5         U R                  U5      nU R                  U5      n0 n[        S[	        U5      5       H_  nX5   nU R                  US5      nU R                  U5      nU R                  US0 5      n	U R                  XR                  U5      5      XH'   Ma     U R                  USUS5      $ )a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://docs.cloud.coinbase.com/intx/reference/getinstruments

: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   r8  r_  T)r,  r  rS  r  r  r  r  r  parse_tickerr  filter_by_array)
r  r  r  r   tickersr  r=  r  r8  r_  s
             r  fetch_tickers#coinbaseinternational.fetch_tickers  s     	%%g.11&9q#k*+A$J''
H=H%%h/FNN:w;E"//7G7G7QRGO , ##GXwEEr  c                     U R                  5         U R                  U5      nSU R                  U5      0nU R                  U R	                  XB5      5      nU R                  XS5      $ )a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs.cloud.coinbase.com/intx/reference/getinstrumentquote

: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,  rD  r  %v1PublicGetInstrumentsInstrumentQuoterI  r  )r  r8  r  rD  rL  tickers         r  fetch_ticker"coinbaseinternational.fetch_ticker  s_     	V$$..0
 ;;DKK<XY  00r  r  c                    U R                  US5      nU R                  0 SU_SU R                  S U5      _SU R                  U5      _SU_SU R	                  US5      _SU R	                  US5      _S	U R	                  US
5      _SU R	                  US5      _SS _SS _SS _SS _SS _SS _SS _SS _SS _S S S U R	                  US5      U R	                  US5      S.E5      $ )Nrz  r  r8  r{  bidbest_bid_price	bidVolumebest_bid_sizeaskbest_ask_price	askVolumebest_ask_sizerT  rU  rS  rV  lastchanger   averagevwaprv  index_price)
baseVolumequoteVolumepreviousCloseru  rw  )r  safe_tickerr  rX  rY  )r  r  rD  r{  s       r  r  "coinbaseinternational.parse_ticker  sr   $ ##FK8 !
F!
d&&tV4!
 1!
 	!

 4##F,<=!
 ))&/B!
 4##F,<=!
 ))&/B!
 D!
 4!
 D!
 T!
 D!
 d!
 $!
  t!!
" D#!
$ !))&,?**6=A-!
  	r  c                     U R                  5         SnU R                  SU5      u  p!SU0nU R                  U R                  X15      5      nU R	                  U5      $ )a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://docs.cloud.coinbase.com/intx/reference/getportfoliobalances

:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.v3]: default False, set True to use v3 api endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
NrQ   r   )r,  r  'v1PrivateGetPortfoliosPortfolioBalancesrI  parse_balance)r  r  r   rL  balancess        r  fetch_balance#coinbaseinternational.fetch_balance  sd     		 <<^VT	
 ??G@\]$ !!(++r  c                 .   SU0n[        S[        U5      5       Hh  nX   nU R                  US5      nU R                  U5      nU R	                  5       nU R                  US5      US'   U R                  US5      US'   XrU'   Mj     U R                  U5      $ )Nr  r   r  r  totalholdused)r  r  r  r  r  safe_balance)r  r0  r  r  
rawBalancer  r5  r  s           r  r  #coinbaseinternational.parse_balance,  s    " H
 q#h-(A!J))*lCJ**:6DllnG#//
JGGG"..z6BGFO"4L )   ((r  r  r  c           
          U R                  5         U R                  U5      nUS   UUUS.nU R                  U R                  Xu5      5      nU R	                  US5      n	USSSUUUUU	(       a  SS.	$ SS.	$ )a  
Transfer an amount of asset from one portfolio to another.

https://docs.cloud.coinbase.com/intx/reference/createportfolioassettransfer

: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://github.com/ccxt/ccxt/wiki/Manual#transfer-structure>`
r'   )r  ammountfromtosuccessNr  r  r  )r,  r  v1PrivatePostPortfoliosTransferrI  r  )
r  r5  r  r  r  r  r  rL  r0  r  s
             r  r  coinbaseinternational.transferI  s     	==&d^	
 77G8TU..95&"%d

 
	
 ,4

 
	
r  r4  r  rM  c                 R   U R                  5         U R                  U5      nUR                  5       nU R                  U/ SQ5      n	U R	                  U R
                  SS5      n
U
S-   U R                  5       -   nUSS nUUR                  5       US   U R                  US   U5      S	.nU	b  US:X  a  SnOSnXS'   XS'   US:X  a  Uc  [        U R                  S-   5      eX\S'   S
nU R                  SU5      u  pUb  XS'   U R                  USS5      nU R                  USS5      nUS:X  a$  Ub  US:w  a  [        U R                  S-   5      eSnOUc  SOUnUb  XS'   XS'   U R                  U/ SQ5      nU R                  U R                  X5      5      nU R!                  UU5      $ )a_  
create a trade order

https://docs.cloud.coinbase.com/intx/reference/createorder

: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 you want to trade in units of the base currency, quote currency for 'market' 'buy' orders
:param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.stopPrice]: alias for triggerPrice
:param float [params.triggerPrice]: price to trigger stop orders
:param float [params.stopLossPrice]: price to trigger stop-loss orders
:param bool [params.postOnly]: True or False
:param str [params.tif]: 'GTC', 'IOC', 'GTD' default is 'GTC' for limit orders and 'IOC' for market orders
:param str [params.expire_time]: The expiration time required for orders with the time in force set to GTT. Must not go beyond 30 days of the current time. Uses ISO-8601 format(e.g., 2023-03-16T23:59:53Z)
:param str [params.stp_mode]: Possible values: [NONE, AGGRESSING, BOTH] Specifies the behavior for self match handling. None disables the functionality, new cancels the newest order, and both cancels both orders.
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
)r   	stopPrice
stop_pricer   r   r  r      r'   r8  )client_order_idr  r=  sizeNr   
STOP_LIMITSTOPr  r4  zA createOrder() requires a price parameter for a limit order typesrM  rI   r   postOnly	post_onlytifr   MARKETr   z7 createOrder() market orders must have tif set to "IOC"r   )r  userr  r   )r,  rD  uppersafe_number_nr  r   r2  amount_to_precisionr   r'   r  safe_bool_2r#  rG  v1PrivatePostOrdersrI  parse_order)r  r8  r4  r  r  rM  r  rD  rq  r   clientOrderIdprefixclientOrderIdrL  r   r  r  r0  s                    r  create_order"coinbaseinternational.create_orderl  s   * 	V$))&2]^"..t||ZT+c1DIIK?%a+,JJL ,,,VH-=vF	
 #w%$0L! 7?}"477-p#pqq$G	 <<]FS	 #,K ##FJD  >X3%<"477-f#fggCK%cC#+K 6#YZ++DKK,HI0 &11r  rK  c           
         U R                  US5      nU R                  US5      nS nUb  SU0nU R                  USS5      nU R                  0 SU_SU R                  US5      _S	U R                  US
5      _SU R	                  U5      _SU_SS _SU R                  X25      _SU R                  U R                  US5      5      _SU R                  US5      _SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _U R                  US5      U R                  U R                  US5      5      US S.EU5      $ )Nr8  r  r@  submit_timert  r  r'   rG  r  r  rz  r{  lastTradeTimestampr4  r   r  r  r  rM  r   r  r  r  filledexec_qty	remaining
leaves_qty	avg_priceorder_status)r  r  r  trades)	r  rY  r#  
safe_orderrX  r  parse_order_typerO  parse_order_status)r  rK  rD  r  feeCostr  r{  s          r  r  !coinbaseinternational.parse_order  s   0 ##E84""5%0C %%e]LI  
E 
$""5*5 
 T--e5FG 
 1	 

  
 !$ 
 d&&x8 
 D))$*:*:5&*IJ 
 4++E59 
  
 D**5&9 
 T%%eW5 
 D,,ULA 
 d&&uf5 
 d&&uj9 
  ))%>! 
" D# 
$ ''{;--d.>.>un.UV+ 
, - 	r  c                 @    SSSSSSSSSSS.
nU R                  X!U5      $ )NrS  closedr*  rejectedexpired)
r  PARTIAL_FILLEDFILLEDCANCELEDREPLACEDPENDING_CANCELREJECTEDPENDING_NEWEXPIREDPENDING_REPLACEr  r  s      r  r  (coinbaseinternational.parse_order_status  s<    $""$"! %
 &99r  c                 B    US:X  a  g SSSSS.nU R                  X!U5      $ )NUNKNOWN_ORDER_TYPErD  r   )r  LIMITr  r  r  )r  r4  typess      r  r  &coinbaseinternational.parse_order_type  s6    ''!	
 T22r  r'   c                     U R                  5         SnU R                  SU5      u  pCUUS.nSnUb  U R                  U5      nU R                  U R	                  XS5      5      nU R                  Xv5      $ )aN  
cancels an open order

https://docs.cloud.coinbase.com/intx/reference/cancelorder

:param str id: order id
:param str symbol: not used by coinbaseinternational cancelOrder()
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr=   )r   r'   )r,  r  rD  v1PrivateDeleteOrdersIdrI  r  )r  r'   r8  r  r   rL  rD  r   s           r  cancel_order"coinbaseinternational.cancel_order  s~     		 <<]FS	"
 [[(F--dkk'.JK0 //r  c                     U R                  5         SnU R                  SU5      u  p2SU0nSnU(       a  U R                  U5      nUS   US'   U R                  U R	                  XB5      5      nU R                  Xe5      $ )a:  
cancel all open orders
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr<   r   r'   r=  )r,  r  rD  v1PrivateDeleteOrdersrI  parse_orders)r  r8  r  r   rL  rD  r   s          r  cancel_all_orders'coinbaseinternational.cancel_all_ordersE  s     		 <<=NPVW	
 [[(F$*4LGL!++DKK,HI  00r  c                    U R                  5         U R                  U5      nSU0n	Sn
U R                  SU5      u  pU
b  XS'   Ub  U R                  X%5      U	S'   Ub  U R	                  X&5      U	S'   U R                  U/ SQ5      nUb  XS'   U R                  US	S
5      nUc  [        U R                  S-   5      eXS	'   U R                  U R                  X5      5      nU R                  X5      $ )a  
edit a trade order

https://docs.cloud.coinbase.com/intx/reference/modifyorder

:param str id: cancel order id
: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
:param str params['clientOrderId']: client order id
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r'   NrO   r   r  rM  )r  r  r   r  r  r  z/ editOrder() requires a clientOrderId parameter)r,  rD  r  r  price_to_precisionr  r#  r   r'   v1PrivatePutOrdersIdrI  r  )r  r'   r8  r4  r  r  rM  r  rD  rL  r   r   r  rK  s                 r  
edit_order coinbaseinternational.edit_orderY  s     	V$"
 	 <<[&Q	 #,K "66vFGFO#66vEGG))&2]^#$0L!**63DoV TWW'XXYY%2!"))$++g*FG..r  c                     U R                  5         SnUb  U R                  U5      nSnU R                  SU5      u  pSUUS.nU R                  U R	                  Xc5      5      nU R                  Xt5      $ )an  
fetches information on an order made by the user

https://docs.cloud.coinbase.com/intx/reference/modifyorder

:param str id: the order id
:param str symbol: unified market symbol that 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>`
Nrp   )r'   r   )r,  rD  r  v1PrivateGetOrdersIdrI  r  )r  r'   r8  r  rD  r   rL  rK  s           r  fetch_order!coinbaseinternational.fetch_order  s~     	[[(F	 <<\6R	"
 ))$++g*FG4 ..r  c           	         U R                  5         SnU R                  SU5      u  pTSnU R                  USS5      u  pdSnU R                  USSS5      u  ptSnU(       a  U R                  SXX4X5      $ U R	                  XHS5      S-
  n	UU R                  US	S
X-  5      S.n
SnU(       a  U R                  U5      nXS'   Ub"  US:  a  [        U R                  S-   5      eX:S'   Ub  U R                  U5      U
S'   U R                  U R                  X5      5      nU R                  US/ 5      nU R                  XX#5      $ )aq  
fetches information on all currently open orders

https://docs.cloud.coinbase.com/intx/reference/getorders

:param str symbol: unified market symbol of the orders
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: the maximum number of open order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:param int [params.offset]: offset
:param str [params.event_type]: The most recent type of event that happened to the order. Allowed values: NEW, TRADE, REPLACED
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nro   Fr<  r^  r.   r_  r`  ra  rb  )r   rb  r=  z' fetchOpenOrders() maximum limit is 100rc  ref_datetimerd  )r,  r  r  re  rF  rf  rD  r   r'   rE  v1PrivateGetOrdersrI  rJ  r  )r  r8  r:  r   r  r   r<  r^  ri  rj  rL  rD  r0  	rawOrderss                 r  fetch_open_orders'coinbaseinternational.fetch_open_orders  sr    		 <<=NPVW	88ART^_#'+'D'DVM^`vx{'|$889JF[`jq  I  I  !4q8"!00?TXTop
 [[(F$*L!s{ +T!TUU&+N#&*ll5&9GN#**4;;w+GHF NN8Y;	  EAAr  c           	         U R                  5         SnU R                  USS5      u  pTSnSnU R                  USSS5      u  ptU(       a  U R                  SXX4Xg5      $ SnUb  U R                  U5      nU R	                  XFS5      S-
  n	S	U R                  US
S	X-  5      0n
Ub"  US:  a  [        U R                  S-   5      eX:S'   Ub  U R                  U5      U
S'   U R                  US/5      nUb'  U R                  US/5      nU R                  U5      U
S'   U R                  U R                  X5      5      nU R                  US/ 5      nU R                  XX#5      $ )a
  
fetch all trades made by the user

https://docs.cloud.coinbase.com/intx/reference/getmultiportfoliofills

:param str symbol: unified market symbol of the trades
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: the maximum number of trade structures to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch trades for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Frl   r<  r_  Nr^  r.   r`  rb  ra  z^ fetchMyTrades() maximum limit is 100. Consider setting paginate to True to fetch more trades.rc  r  r@  r  rd  )r,  r  re  rD  rF  rf  r   r'   rE  r  rG  v1PrivateGetPortfoliosFillsrI  rJ  parse_trades)r  r8  r:  r   r  r<  ri  r^  rD  rj  rL  r@  r0  r  s                 r  fetch_my_trades%coinbaseinternational.fetch_my_trades  s    	88R\]#'+'D'DV_^tvy'z$88&Y^ho  G  G[[(F  !4q8T00?TXTop
 s{   ,L  "L  M  M&+N##'<<#6GK ""6G95YYvy1F&*ll5&9GN#33DKK4PQR )R8  >>r  r  r  c           	         U R                  XE5      u  pEU R                  U5        U R                  5         U R                  U5      nSnU R	                  SU5      u  puSnU R                  USSS5      u  pSn	U R                  USU5      u  pUSUS   UUUS   U	U R                  5       S.n
[        X5      " U R                  X5      5      nU R                  X5      $ )aa  
make a withdrawal

https://docs.cloud.coinbase.com/intx/reference/withdraw
https://docs.cloud.coinbase.com/intx/reference/counterpartywithdraw

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str [tag]: an optional tag for the withdrawal
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.add_network_fee_to_total]: if True, deducts network fee from the portfolio, otherwise deduct fee from the withdrawal
:param str [params.network_arn_id]: Identifies the blockchain network(e.g., networks/ethereum-mainnet/assets/313ef8a9-ae5a-5f2f-8a56-572c0e2a4d5a)
:param str [params.nonce]: a unique integer representing the withdrawal request
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr   r   r   sendr'   )r   r4  r  r  r  r  r  nonce)handle_withdraw_tag_and_paramscheck_addressr,  r  r  r  r)  r
  r  rI  rA  )r  r5  r  r  r  r  r  r   r   r'  rL  r0  s               r  r   coinbaseinternational.withdrawR  s    " 99#F7#==&	 <<ZP	66vz8Uuv	 ==dJPVW	"d^ 'ZZ\	
 4(W)EF %%h99r  c                 x   U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nUc  Ub  US:  nUc  Ub  US:  nU R                  US5      n	U=(       a    Un
US   U	U R                  US5      U R                  US	5      U R                  US
U
5      UUU R                  US5      U R                  US5      U R                  US5      US.U R                  US5      US.S.S.
$ )Nr   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  rY  r  )r  r   withdrawEnableddepositEnabledr  r   withdrawMaxr  
depositMaxr'  	isEnableds              r  r  "coinbaseinternational.safe_network  s]   ..*=;2>>&*5&&x7..3%%gu5
"{'>*QO!j&<(1nN$$Wd3	$7	FO$$Wf5'';nnWh	B%'##GU3))';?  ++He<&
  ++GU;%	
 	
r  GETc                    US   nUS   S:H  nSU-   S-   U R                  X5      -   n	U R                  X@R                  U5      5      n
SU	-   nUS:X  d  US:X  a  U
(       a  U	SU R                  U
5      -   -  n	U R                  S	   S
   U	-   nU(       a  U R                  5         [        U R                  5       5      nSnUS:w  a  U
(       a  U R                  U
5      nUnX-   U-   U-   nU R                  U R                  U5      U R                  U R                  5      [        R                  S5      nUUU R                  U R                   S.nXXeS.$ )Nr   r`  r   r[  z/apir  DELETE?r   r   r   base64)zCB-ACCESS-TIMESTAMPzCB-ACCESS-SIGNzCB-ACCESS-PASSPHRASEzCB-ACCESS-KEY)urlr   bodyr3   )implode_paramsrG  extract_paramsurlencode_with_array_repeatr   check_required_credentialsstrr
  jsonhmacencodebase64_to_binaryr   hashlibsha256r   r   )r  pathr   r   r  r3   r  r/   signedfullPathquery	savedPathr  r
  payloadauth	signatures                    r  signcoinbaseinternational.sign  sK   a&Q9$=3&)<)<T)JJ		&"5"5d";<X%	U?f0C$"B"B5"IIIiiv&1++-

%EG99U+D"G>I-7D		$++d"3T5J5J4;;5WY`YgYgiqrI',"+(,!%	G dOOr  reasonr  r   r3   r  c
                     Uc  g U R                   S-   U-   n
U R                  US5      nUbI  U R                  U R                  S   X5        U R	                  U R                  S   X5        [        U
5      eg )Nr  titler   r   )r'   r  throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   )r  r5  r1  r  r   r3   r  r0  requestHeadersrequestBodyfeedbackerrMsgs               r  handle_errors#coinbaseinternational.handle_errors  sw     77S=4'!!(G4001I6\001I6\))r   ro  )V__name__
__module____qualname____firstlineno__r   r   r   r  r)  r  r6  r
   r   listrO  r   r[  r   rl  rq  rp  r  r  r   r  dictr   r  r  r	   r  r%  r!  r  r  floatr   r  r   r  r  r  r   r   r  r#  r'  r+  rA  r   rP  rU  rs  r   rx  r~  r   r  r   r  objectr  r   r  r  r  r   r   r  r   r  r  r  r  r  r  r  r  r  r   r  r/  intr:  __static_attributes____classcell__)r  s   @r  r#   r#      s    w# wr	 CE ^c ^$# ## #" %' 5<
. 9=4^ajl 1K# 1K# 1KS 1KX[ 1Kquvzq{ 1Kf
 
4 
( 8<$]ajl 2Q 2QC 2QWZ 2Qh5v 5
6 
< 37TX\eg BC Bs BRU BB&
6 &
P +/TPT]_ GC Gs G# Gdhivdw GB)
t )
x )
= )
V:C :C : 8: 1
3 1
n 1
f  35 < /1  -/ (T =? P Pe PCU P* 6:[_hj F8s F8# F8UX F8ost  pA F8P 24 "-S "-H/t /V /b 26b &Sw &ST(^ &SP -1tRV_a Kc K KC Kfjkvfw K* *.Dt\^ K3 Kc K Kcghsct K$:s :!
T !
X !
Q\ !
F4 4v 4 4l $& ;,$v, ;,zn
4 n
F n
` ') 1Z 12t  : 04B FW F7 F, 02 13 1f 1$*6 *6 *V *X $& ",( ",H) ): [] !
S !
% !
c !
c !
an !
F imuw V23 V2i V2y V2RW V2`e V2p6 6v 6 6p: :	3S 	3 37r -0s -0C -0^ /32 1 1( bfvz  DF %/S %/# %/Y %/i %/Y^ %/ns %/N 26b //c //3 //b /3TXac LB LB3 LBc LBhlmrhs LB\ -1tRV_a Q?c Q? Q?C Q?f KOWY +:S +:% +:# +:C +:^i +:Z"
H  b$T P8# s  c TX `c  r  r#   )(ccxt.base.exchanger   #ccxt.abstract.coinbaseinternationalr   r%  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr    ccxt.base.preciser!   r#   r<  r  r  <module>rO     sb    ( ;  Z  Z  Z  Z  Z  Z  * 0 - . ' ) - 4 %x"Hk x"r  