
    ei>                    \   d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlm Z  d dl!m"Z" d dl!m#Z# d dl!m$Z$ d d	l!m%Z% d d
l!m&Z& d dl!m'Z' d dl!m(Z( d dl!m)Z) d dl!m*Z* d dl!m+Z+ d dl!m,Z, d dl-m.Z. d dl/m0Z0  G d dee          Z1dS )    )Exchange)ImplicitAPIN)AccountAnyBalances
Conversion
CurrenciesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersTradeTradingFeesTransactionMarketInterface)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)InvalidNonce)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdefdZi fdee         fdZ	i fdee         fdZ
i fdee         fdZi fdee         fdZd Zi fd	edefd
Zdddi fdededefdZdddi fdededefdZdddi fd	ededefdZdddi fd	edededee         fdZdddi fd	edededee         fdZdddi fd	edededee         fdZdefdZddededefdZddededefdZi fdee         fdZ i fdee         fdZ!i fdee         fdZ"de#fd Z$de#fd!Z%i fd"Z&i fde'fd#Z(di fd$e)de*fd%Z+di f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/i fdefd)Z0i fdefd*Z1dd+edede.fd,Z2i fd-Z3i fde4fd.Z5dddi fd	edededee6         fd/Z7d0 Z8d1 Z9dd2edede6fd3Z:i fd4Z;di fdefd5Z<ddi fd	edefd6Z=i fded7e>fd8Z?di fded9e@d:eAd;e>d<eBf
d=ZCdd>ededeDfd?ZEdefd@ZFd9efdAZGdBefdCZHdi fdDedefdEZIdi fdFee         defdGZJddi fdDeded9e@d:eAd;eBd<eBfdHZKdi fdDedefdIZLdddJi fdedededeeD         fdKZMdddi fdededefdLZNdddi fdedededeeD         fdMZOdddi fdedededeeD         fdNZPdddi fdededefdOZQdPddi fdedQedededeeR         f
dRZSddedeRfdSZTddi fdedededee         fdTZUdddi fdededefdUZVdi fdededeWfdVZXdi fd$e)fdWZYdi fd	ed;e>dXedYedef
dZZZi fd	edee         fd[Z[ddedefd\Z\i fd	ed;e>dDefd]Z]di fdDed	efd^Z^i fd_Z_i fdDefd`Z`i fdaZadb Zbdi fdcedded;eBdecfdeZddi fdDedcedded;eBdecf
dfZedi fdDed	edecfdgZfddhediedjedecfdkZgdi fded:eAdeDfdlZhdi fd$e)deei         fdmZji fdefdnZkddoedefdpZli fdemfdqZni fdredee         fdsZodtefduZpddwedxedyefdzZqd{ Zrg d|i ddfd}Zsd	etd~edyedxededefdZudi fde)dee         fdZv xZwS )coinbasereturnc                 .   |                      t          t          |                                           i ddddddgddd	d
ddddd| j        d         dddi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d0d
d1dd2d
d3dd4dd5dd6di d7dd8dd9d
d:d
d;d
d<d
d=d
d>d
d?dd@ddAddBddCd
dDd
dEd
dFddGdi dHdIdJddKddLddMddNddOddPd
dQd
dRd
dSd
dTd
dUd
dVd
dWd
dXd
dYd
i dZd
d[d
d\dd]d
d^d
d_d
d`d
dad
dbd
dcd
ddd
ded
dfd
dgddhd
did
djdi dkd
dlddmd
dnddoddpd
dqd
drd
dsddtd
dud
dvddwddxddyddzd
d{d
i d|dd}d
d~d
dd
dd
dd
ddddddddddIdddd
dddd
dd
dd
d
d
d
d
d
ddddddidddgddgdddddddddddddddddii ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddii dddddddddddddddddddddddddddddddddddddddddddʜddddddddddddd˜ddiddd̜ddd͜dd|                     dЦ          |                     dѦ          dd|                     dҦ          |                     dѦ          g|                     dӦ          |                     dԦ          g|                     dզ          |                     d֦          g|                     dצ          |                     dئ          g|                     d٦          |                     dڦ          g|                     dۦ          |                     dܦ          g|                     dݦ          |                     dަ          g|                     dߦ          |                     d          g|                     d          |                     d          gg	|                     dҦ          |                     dԦ          g|                     dӦ          |                     d֦          g|                     dզ          |                     d          g|                     dצ          |                     d          g|                     d٦          |                     d          g|                     dۦ          |                     d          g|                     dݦ          |                     d          g|                     dߦ          |                     d          g|                     d          |                     d          gg	ddidt          di dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          t          t          t          t          t          t          t          dt          t          t          ddd ddddddddd	d
dii dd
dddg ddFddidddgdddgdddddddddgddd d!d
dd"dd#d6d$d7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
d d
d
d
d/d
d d d,d
d
d
d0d
d d d d,d
d
d
d1d2d3id4	d5d6id5d6id d7d5d6id d7d8d9          S (:  Nidr,   namezCoinbase Advanced	countriesUSproT	certifiedF	rateLimit"   versionv2	userAgentchromeheadersz
CB-VERSIONz
2018-05-30hasCORSspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercancelOrderscloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateLimitBuyOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrdercreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledOrdersfetchClosedOrdersfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressemulatedfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositMethodIdfetchDepositMethodIdsfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchL2OrderBookfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyBuysfetchMyLiquidationsfetchMySellsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMargin)repayMarginsetLeverage	setMarginsetMarginModesetPositionModewithdrawurlszchttps://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpgrestzhttps://api.coinbase.comzhttps://www.coinbase.comz&https://developers.coinbase.com/api/v2z;https://docs.cloud.coinbase.com/advanced-trade/docs/welcomezYhttps://support.coinbase.com/customer/portal/articles/2109597-buy-sell-bank-transfer-feesz&https://www.coinbase.com/advanced-feesz6https://www.coinbase.com/join/58cbe25a355148797479dbd2)logoapiwwwdocfeesreferralrequiredCredentials)apiKeysecretr   getg333333%@)
currencieszcurrencies/cryptotimezexchange-rateszusers/{user_id}zprices/{symbol}/buyzprices/{symbol}/sellzprices/{symbol}/spotaccountsaccounts/{account_id}accounts/{account_id}/addressesz,accounts/{account_id}/addresses/{address_id}z9accounts/{account_id}/addresses/{address_id}/transactions"accounts/{account_id}/transactions3accounts/{account_id}/transactions/{transaction_id}accounts/{account_id}/buysz#accounts/{account_id}/buys/{buy_id}accounts/{account_id}/sellsz%accounts/{account_id}/sells/{sell_id}accounts/{account_id}/depositsz+accounts/{account_id}/deposits/{deposit_id}!accounts/{account_id}/withdrawalsz1accounts/{account_id}/withdrawals/{withdrawal_id}zpayment-methodsz#payment-methods/{payment_method_id})userz	user/auth)r   zaccounts/{account_id}/primaryr   r   z<accounts/{account_id}/transactions/{transaction_id}/completez:accounts/{account_id}/transactions/{transaction_id}/resendr   z*accounts/{account_id}/buys/{buy_id}/commitr   z,accounts/{account_id}/sells/{sell_id}/commitr   z2accounts/{account_id}/deposits/{deposit_id}/commitr   z8accounts/{account_id}/withdrawals/{withdrawal_id}/commit)r   r   )zaccounts/{id}r   )r   postputdelete)publicprivate   )zbrokerage/timezbrokerage/market/product_bookzbrokerage/market/productsz&brokerage/market/products/{product_id}z.brokerage/market/products/{product_id}/candlesz-brokerage/market/products/{product_id}/tickerzbrokerage/accounts   z!brokerage/accounts/{account_uuid}z!brokerage/orders/historical/batchz!brokerage/orders/historical/fillsz&brokerage/orders/historical/{order_id}zbrokerage/productszbrokerage/products/{product_id}z'brokerage/products/{product_id}/candlesz&brokerage/products/{product_id}/tickerzbrokerage/best_bid_askzbrokerage/product_bookzbrokerage/transaction_summarybrokerage/portfolios%brokerage/portfolios/{portfolio_uuid}"brokerage/convert/trade/{trade_id}zbrokerage/cfm/balance_summaryzbrokerage/cfm/positions)z$brokerage/cfm/positions/{product_id}brokerage/cfm/sweepsz)brokerage/intx/portfolio/{portfolio_uuid}z)brokerage/intx/positions/{portfolio_uuid}z2brokerage/intx/positions/{portfolio_uuid}/{symbol}zbrokerage/payment_methodsz-brokerage/payment_methods/{payment_method_id}zbrokerage/key_permissions)zbrokerage/orderszbrokerage/orders/batch_cancelzbrokerage/orders/editzbrokerage/orders/edit_previewzbrokerage/orders/previewr   zbrokerage/portfolios/move_fundszbrokerage/convert/quoter   zbrokerage/cfm/sweeps/schedulezbrokerage/intx/allocatezbrokerage/orders/close_position)r   r   )r8   v3r   tradingz0.012z0.006010000z0.00450000z0.0025100000z0.0021000000z0.001815000000z0.001675000000z0.0012	250000000z0.0008	400000000z0.0005z0.0015z0.001z0.0006z0.0003z0.0)takermaker)r   r   	tierBased
percentagetiersprecisionMode
exceptionstwo_factor_requiredparam_requiredvalidation_errorinvalid_requestpersonal_details_requiredidentity_verification_requiredjumio_verification_required&jumio_face_match_verification_requiredunverified_emailauthentication_errorinvalid_authentication_methodinvalid_tokenrevoked_tokenexpired_tokeninvalid_scope	not_foundrate_limit_exceeded)internal_server_errorUNSUPPORTED_ORDER_CONFIGURATIONINSUFFICIENT_FUNDPERMISSION_DENIEDINVALID_ARGUMENT)PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICEPREVIEW_INSUFFICIENT_FUND)z&Insufficient balance in source accountzrequest timestamp expiredz%order with self orderID was not found)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CGLDCELO
usePrivatebrokerIdccxtstablePairs)zBUSD-USDz	CBETH-ETHzDAI-USDzGUSD-USDzGYEN-USDzPAX-USDzPAX-USDTzUSDC-EURzUSDC-GBPzUSDT-EURzUSDT-GBPzUSDT-USDz	USDT-USDCzWBTC-BTCexpiresi  walletfiat
v3AccountsACCOUNT_TYPE_CRYPTOACCOUNT_TYPE_FIATnetworksethereumstellar)ERC20XLM!createMarketBuyOrderRequiresPriceadvancedfetchMarketsV3timeDifferencer   adjustForTimeDifferencefetchTickerV3fetchTickersV3fetchAccountsV3v2PrivateGetAccountsv2PublicGetTimeuser_native_currencyUSD)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi  i'  )r<  limitdaysBack	untilDayssymbolRequired)r<  triggerrE  rN  )r<  rK  rO  rE  rN  )r<  rK  rL  rM  rO  rE  rN  )r<  rK  rL  daysBackCanceledrM  rO  rE  rN  rK  ,  )	sandboxrT   createOrdersr   r   r   r   rh   r   extendsdefault)linearinverse)rU  r>   r@   rA   )commonCurrenciesoptionsfeatures)deep_extendsuperr,   describe
userAgentsparse_numberr)   r   r   r'   r"   r#   r    r$   r(   r%   )self	__class__s    Y/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/coinbase.pyr]  zcoinbase.describe   s   h 5 5 > > @ @ fC
*fC
'fC
 $fC
 4	fC

 fC
 fC
 tfC
 2fC
 lfC
"  ~~~ %~ 	~
 %~ %~ U~ $U~ '~ ~ t~ ~ $U~  ~ %d~  '!~" &t#~ ~$ '%~& ''~( /)~* ,U+~, (-~. 0/~0 t1~2 73~4 9%5~6 &t7~8 (9~: ';~< (=~> "4?~@ 4A~B TC~D  E~ ~ ~F G~H  I~J &uK~L "5M~N +EO~P )%Q~R #ES~T ,UU~V &tW~X $TY~Z $T[~\ $T]~^ +E_~` 'a~b (c~d "4e~f g~ ~ ~h &zi~j (k~l 1$m~n 'o~p (q~r  s~t +Du~v &uw~x 'y~z ({~| #E}~~ *5~@ $UA~B uC~D "5E~F *5G~H +EI~ ~ ~J )%K~L #EM~N tO~P  Q~R !%S~T %eU~V $UW~X &uY~Z -e[~\ /]~^ "5_~` #Ea~b +Ec~d e~f !%g~h "5i~j tk~ ~ ~l &um~n o~p +Eq~r  s~t du~v $Uw~x +Ey~z %e{~| "4}~~ u~@ #EA~B dC~D !$E~F tG~H  I~J 'K~L $UM~ ~ ~N !$O~P *5Q~R (S~T %eU~V )%W~X )%Y~Z t[~\ ]~^ T_~` ta~b ":c~d #De~f )%g~h #Di~j k~l #Em~n &uo~ ~p  %$"!&#( {~ ~ ~#fC
` }6 2<Q
 p< U afC
@ "$ $AfC
H  *.15$(.2/3374848	  	  & 3T  >t  KD	 
 XY]  A$  RSW  9$  B4  :4  DT  =d  J4  @  PQU   .t! " B4# $ %))-'     , )-=A?CBF\`Z^:>JN;?LP>BRVAEX\! !" 6:$(   
 .2SW# #U.  . < <~ ./=>9:FGNOMN   	 0! ?  @  @	 
 Ea  1!  >q  Fq  Ea  5a  5a  <Q  3A  DQ  A!   <Q! " 6q# $ EF45IJIJRS9:MN9:3     8 12=>56=>8945?@78BC=>78?@! !  DQ  FG45# #]2  2 > >}} }IfC
D	 !..w77!..w77!%"& "..s33T5F5Fw5O5OP!..w779J9J79S9ST!..w779J9J89T9TU!..x88$:K:KG:T:TU!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX!..{;;T=N=Nx=X=XY!..{;;T=N=Nx=X=XY
" "..s33T5F5Fw5O5OP!..w779J9J89T9TU!..w779J9J89T9TU!..x88$:K:KG:T:TU!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX!..{;;T=N=Nu=U=UV!..{;;T=N=Nu=U=UV
"  E	fC
D
 YE
fC
F
 )+>$m ' &}	
 01D 56I 23F =>Q '(; +,? 45H $%8 $%8 $%8 $%8   !" *+<#$ .;7A):)9(2AM1B1  6 ?P1==J 7   G
fC
H "#'&   	 	IfC
^ !eF    H   H   H "t$	  )'  '$ !( 4T)* D+,  0-. !!/0 *512 34  056  !278  69: .;< '= D  %&*(,,0,0)-+/6:#'#'"&#'	( ( #($)$(+/26/4#()$ $, %)&+!%$(%**/& & ',#($)*/	# # ',!%#($)*/( ( ',!%$(%*#($)*/$ $ ',!%$(,0%*#($)*/	* 	*  #AC CJ y
 "9  $	  "9  $	 ]T TcfC
 fC
 fC
 f f f	    c                 r  K   |                      | j        dd          }|                      |d|          }|                     |d          }d}|dk    r3|                     |           d{V }|                     |di           }n|                     |           d{V }|                     |dd          S )a  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-time#http-request

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.method]: 'v2PublicGetTime' or 'v3PublicGetBrokerageTime' default is 'v2PublicGetTime'
        :returns int: the current integer timestamp in milliseconds from the exchange server
        r   r5  methodNdataepochepochSeconds)safe_stringrY  omitr5  	safe_dictv3PublicGetBrokerageTimesafe_timestamp_2)r`  paramsdefaultMethodre  responses        rb  
fetch_timezcoinbase.fetch_time  s       (({DUVV!!&(MBB68,,&&&!11&99999999H ~~h;;HH!::6BBBBBBBBH $$XwGGGrc  c                    K   |                      | j        dd          }|dk    r|                     |           d{V S |                     |           d{V S )a  
        fetch all the accounts associated with a profile

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getaccounts
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-accounts#list-accounts

        :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 dictionary of `account structures <https://docs.ccxt.com/?id=account-structure>` indexed by the account type
        r^   r3  N)ri  rY  fetch_accounts_v3fetch_accounts_v2r`  rn  re  s      rb  fetch_accountszcoinbase.fetch_accounts*  sz       !!$,ARSS&&&//777777777++F333333333rc  c                 |  K   |                                   d {V  d}|                     |dd          \  }}|r#|                     dd d d |ddd d	  	         d {V S ddi}|                     |                     ||                     d {V }|                     |dg           }|                     |d	i           }|                     |d          }|                     |dg           }t          |          }	|	d
z
  }
|                     ||
          }||dk    r
||d<   |||
<   | 	                    ||          S )NFr^   paginatenext_starting_afterstarting_afterd   rK  rf  
paginationr    )
load_marketshandle_option_and_paramsfetch_paginated_call_cursorr4  extend	safe_listrk  ri  lenparse_accounts)r`  rn  rx  requestrp  rf  r|  cursorr   length	lastIndexlasts               rb  rt  zcoinbase.fetch_accounts_v2:  s     !!!!!!!!!88R\]]& 	Y99/4QUW[]cez  }M  OS  UX  Y  Y  Y  Y  Y  Y  Y  Y  YS
 224;;w3O3OPPPPPPPPZ ~~h33^^HlB??
!!*.CDD>>(FB77XQJ	~~h	22Vr\\*0D&'"&HY""4000rc  c                 ,  K   |                                   d {V  d}|                     |dd          \  }}|r#|                     dd d d |ddd d	  	         d {V S ddi}|                     |                     ||                     d {V }|                     |dg           }t          |          }|                     |d          }|dk    r-|+|d	k    r%|d
z
  }|                     ||          }	||	d<   |	||<   | 	                    ||          S )NFr^   rx  r     rK  r   r   r}  r   )
r~  r  r  v3PrivateGetBrokerageAccountsr  r  r  ri  rk  r  )
r`  rn  rx  r  rp  r   accountsLengthr  r  r  s
             rb  rs  zcoinbase.fetch_accounts_v3|  s     !!!!!!!!!88R\]]& 	D99/4QUW[]cemowy}  @C  D  D  D  D  D  D  D  D  DS
 ;;DKKQW<X<XYYYYYYYY> >>(J;;X!!(H55QV%7fll&*I>>(I66D#DN"&HY""8V444rc  c                 F  K   |                      |           d{V }|                     |dg           }g }t          dt          |                    D ]L}||         }|                    |                     |d          |                     |d          d|d           M|S )ai  
        fetch all the portfolios

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_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
        N
portfoliosr   uuidtyper/   r  codeinfo)v3PrivateGetBrokeragePortfoliosr  ranger  appendri  )r`  rn  rp  r  resulti	portfolios          rb  fetch_portfolioszcoinbase.fetch_portfolios  s       ==fEEEEEEEE^^HlB??
q#j//** 	 	A"1IMM&&y&99((F;;!	      rc  c                    |                      |d          }|                     |d          }|                     |di           }|                     |d|          }|                     |d          }|                     |d          }|                    d          }|                     |dd          ||                     |d	          n||                     |          |d
S )Nactivecurrencyr  r0   r   r/   r  r   r  )	safe_boolri  rk  splitsafe_string_2safe_string_lowersafe_currency_code)	r`  accountr  currencyIdV3r  
currencyIdtypeV3typeV2partss	            rb  parse_accountzcoinbase.parse_account  s    p 22''<<>>':r::%%hEE
!!'622!!'622S!!$$WdF;;9?9KD**5!444RX++J77	
 
 	
rc  r  c                 x  K   |                      |d          }|                     |d          }|n|                                  d{V  t          dt	          | j                            D ]1}| j        |         }|d         |k    r|d         dk    r
|d         } n2|t          | j        dz   |z   d	z             d|i}|                     | 	                    ||                     d{V }| 
                    |d
i           }|                      |d          }	|                      |d          }
||	|
d|dS )a  
        create a currency deposit address

        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-addresses#create-address

        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        
account_idNr   r  r  r"  r/   zO createDepositAddress() could not find the account with matching currency code z?, specify an `account_id` extra param to target specific walletrf  destination_tagaddress)r  tagr  networkr  )ri  rj  load_accountsr  r  r   r   r/   'v2PrivatePostAccountsAccountIdAddressesr  rk  )r`  r  rn  	accountIdr  r  r  rp  rf  r  r  s              rb  create_deposit_addresszcoinbase.create_deposit_address
  s      $$V\::	6<00$$&&&&&&&&&1c$-0011  -*6?d**wv(/J/J 'IE*{ {  C  !C  FG  !G  H  H  H)
 EEdkkRY[aFbFbccccccccJ ~~h33t%677""433
 
 	
rc  NsymbolsincerK  c                 0  K   |                      ||          }|                                  d{V  |                     |ddg          }|                     |                     ||                     d{V }|                     |d         d||          S )a  
 @ignore
        fetch sells

        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-sells#list-sells

        :param str symbol: not used by coinbase fetchMySells()
        :param int [since]: timestamp in ms of the earliest sell, default is None
        :param int [limit]: max number of sells to return, default is 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  rf  )prepare_account_requestr~  rj  "v2PrivateGetAccountsAccountIdSellsr  parse_trades)r`  r  r  rK  rn  r  querysellss           rb  fetch_my_sellszcoinbase.fetch_my_sellsR  s       ..uf==!!!!!!!!!		&<"=>>==dkk'SX>Y>YZZZZZZZZ  veUCCCrc  c                 0  K   |                      ||          }|                                  d{V  |                     |ddg          }|                     |                     ||                     d{V }|                     |d         d||          S )a  
 @ignore
        fetch buys

        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-buys#list-buys

        :param str symbol: not used by coinbase fetchMyBuys()
        :param int [since]: timestamp in ms of the earliest buy, default is None
        :param int [limit]: max number of buys to return, default is 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  rf  )r  r~  rj  !v2PrivateGetAccountsAccountIdBuysr  r  )r`  r  r  rK  rn  r  r  buyss           rb  fetch_my_buyszcoinbase.fetch_my_buysf  s       ..uf==!!!!!!!!!		&<"=>>;;DKKQV<W<WXXXXXXXX  ftUEBBBrc  c                    K   d }|                      |||           d {V \  }}|                                  d {V   t          | |          |                     ||                     d {V }|                     |d         d ||          S )Nrf  )*prepare_account_request_with_currency_coder~  getattrr  parse_transactions)r`  re  r  r  rK  rn  r  rp  s           rb  fetch_transactions_with_methodz'coinbase.fetch_transactions_with_methodz  s       $ O OPTV[]c d ddddddd!!!!!!!!!.v..t{{7F/K/KLLLLLLLL&&x'7ueLLLrc  c                    K   d}|                      |dd          \  }}|dk    r7|                     d||||           d{V }|                     |ddd          S |                     d	||||           d{V S )
a  
        Fetch all withdrawals made from an account. Won't return crypto withdrawals. Use fetchLedger for those.

        https://docs.cdp.coinbase.com/coinbase-app/docs/api-withdrawals#list-withdrawals

        :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.currencyType]: "fiat" or "crypto"
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr   currencyTypecrypto)v2PrivateGetAccountsAccountIdTransactionsr  
withdrawalF(v2PrivateGetAccountsAccountIdWithdrawalsr  r  filter_by_arrayr`  r  r  rK  rn  r  resultss          rb  fetch_withdrawalszcoinbase.fetch_withdrawals  s       #<<VEWYghhf8## ??@kmqsxz  BH  I  I  I  I  I  I  I  IG''uMMM889ceikprwy  A  A  A  A  A  A  A  A  	Arc  c                    K   d}|                      |dd          \  }}|dk    r7|                     d||||           d{V }|                     |ddd          S |                     d	||||           d{V S )
a  
        Fetch all fiat deposits made to an account. Won't return crypto deposits or staking rewards. Use fetchLedger for those.

        https://docs.cdp.coinbase.com/coinbase-app/docs/api-deposits#list-deposits

        :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.currencyType]: "fiat" or "crypto"
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr   r  r  r  r  r\   F%v2PrivateGetAccountsAccountIdDepositsr  r  s          rb  fetch_depositszcoinbase.fetch_deposits  s       #<<VEWYghhf8## ??@kmqsxz  BH  I  I  I  I  I  I  I  IG''EJJJ889`bfhmotv|}}}}}}}}}rc  c                    K   |                                   d{V  |                     d||||           d{V }|                     |dddgd          S )a|  
        fetch history of deposits and withdrawals

        https://docs.cdp.coinbase.com/coinbase-app/docs/api-transactions

        :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 = 50, Min: 1, Max: 100
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  r  r\   r  F)r~  r  r  )r`  r  r  rK  rn  r  s         rb  fetch_deposits_withdrawalsz#coinbase.fetch_deposits_withdrawals  s       !!!!!!!!!;;<gimotv{  ~D  E  E  E  E  E  E  E  E##GVi5NPUVVVrc  statusc                 <    dddd}|                      |||          S )Npendingokcanceled)created	completedr  ri  r`  r  statusess      rb  parse_transaction_statusz!coinbase.parse_transaction_status  s1     "
 

 &&999rc  transactionr  c                    |                      |d          }d }d }|                     |di           }|dk    r.|                     |d          }|                     |di           }n-|                     |d          }|                     |di           }||                     |d          }|                      |d          }t          j        |          }|                     |                      |d	                    }	|	|                     |d
          }
|
rdnd}	|                      |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|}|                     |ddg          s/t          j        |d          rd}nt          j        |d          r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#iS )$Nr  r  sendtransaction_amounttransaction_feesubtotalfeeamountr  	committedr  r  r/   r  
created_atresourcer\   r  r   tor  network_namer  txidhash	timestampdatetime	addressToaddressFromr  tagTotagFromupdated
updated_atcostr  )ri  rk  r*   
string_absr  r  in_array	string_gt	string_lt	parse8601network_id_to_coder_  r  safe_number)r`  r  r  transactionTypeamountAndCurrencyObject	feeObjectr  amountStringamountStringAbsr  r  r/   r  feeCurrencyIdr  r  r  toObjectr  	networkIds                       rb  parse_transactionzcoinbase.parse_transaction  s   t **;??"&	..i<<f$$&*nnW>R&S&S#w0A2FFII&*nn[*&M&M#{E2>>I"*&*nn[(&K&K#''(?JJ!,\::..t/?/?X/V/VWW>{K@@I&5TTIFk400%%&=zJJ
((J??##K>>##K<<}}TI|#<== 	$ s33 $ "<55 $#>>+t44$$Xy99	$$Wn==	
K
"
 D$$Wfb99
 11	

 
 t..y99
 y
 
 4
 4
 T
 t
 D
 d''88
 //
HEE
  f!
" t~~d&6&6{L&Q&QRR#
$ ((H== 33MBB %
 
 	
rc  trademarketc                    d }|                      |di           }|                      |di           }|                      |di           }|                      |di           }|                     |d          }|                     ||d          }|	|d         }nb|                     |d          }	|                     |d          }
|	4|
2|                     |	          }|                     |
          }|d	z   |z   }|                     |d
          }|                     |d          }d }|                     |d          }|r|}t          j        ||          }|                     |d          }|                     |d|          }|                     |d|          }d }d }||t          j        ||          }n|}||t          j        ||          }n|}|                     |d          }|                     |d| 	                    |                    }||
||d         }| 
                    |g d          }|                     |dd          }|                     |d          }|                     ||                     |dd          |                     |d          |                     |          ||d |dk    rd n||dk    rd n||||||                     |          dd          S )Ntotalr  r  r  
product_id-r  r  /size_in_quotepricesize
commissionquote)r  
trade_timer   r  sideliquidity_indicatorr/   trade_idorder_idunknown_order_sideunknown_liquidity_indicatorr  )r  r/   orderr  r  r  r  r  takerOrMakerr  r  r  r  )rk  ri  safe_marketr  r  r*   
string_div
string_mulr  r_  safe_string_nsafe_string_lower_2r  
safe_trader  r   )r`  r  r  r  totalObjectamountObjectsubtotalObjectr  marketIdbaseIdquoteIdbaser  sizeInQuotev3Pricev3Costv3Amount	v3FeeCostr  
costStringpriceStringr  r  feeCostr  r  r   s                              rb  parse_tradezcoinbase.parse_trade  sF   | nnUGR88~~eXr::z2>>NN5%44	##E<88!!(FC88H%FF%%lJ??F&&{J??G")<..v66//88e+nnUO<<""5'22##E622 	=F)(G<<H$$UL99	''hII%%nhGG
")A!,ZFFKK!K#,*B%k<@@DDD((J??""9h8I8I)8T8TUU!(:AT"7OM%%e-Q-Q-QRR''z6BB--e5JKK$$UD*==%%eZ8811 !%999DD%15R%R%RDDYe " 33MBB  
  
   	rc  c                   K   | j         d         r|                                  d{V  |                     | j         dd          }|dk    r|                     |           d{V S |                     |           d{V S )ad  

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpublicproducts
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates

        retrieves data on all markets for coinbase
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.usePrivate]: use private endpoint for fetching markets
        :returns dict[]: an array of objects representing market data
        r0  Nr   r.  )rY  load_time_differenceri  fetch_markets_v3fetch_markets_v2ru  s      rb  fetch_marketszcoinbase.fetch_markets  s       <12 	.++---------!!$,@PQQ%%%..v666666666**6222222222rc  c                 
  K   |                      |           d {V }|                     |di           }|                     |di           }|                     |dg           }|                     |d          }|                     |                     |di           di           }t	          |                                          }g }	t          dt          |                    D ]}
||
         }|                     |          }||v rdnd}|dk    rt          dt          |                    D ]}||         }| 	                    |d          }|                     |          }|	
                    |                     i d|d	z   |z   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 )"Nr   exchangeRatesrf  r/   ratesr   r#  r  r  r  r  r-  r  settler+  r,  settleIdr  r>   Tr?   Fr@   rA   rB   r  contractrV  r  r  minmaxmin_sizerF  r  r  r  )	rW  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitsr  )fetch_currencies_from_cacherk  r  index_bylistkeysr  r  r  ri  r  safe_market_structurer  )r`  rn  rp  r   r=  rf  dataByIdr>  baseIdsr  r  r+  r-  r  jquoteCurrencyr,  r  s                     rb  r:  zcoinbase.fetch_markets_v2#  s     99&AAAAAAAA^^HlB??
x"EE~~j&"55==t,,t~~mVRHH'SUVVuzz||$$q#g,,'' 9	 9	AQZF**622D$0066xDxq#d)),, 3 3A$(GM"..}dCCG 33G<<EMM$"<"< />fslW4/> $*u"4/> />  	/>
 !$/> !&/> "7/> #D/> /> /> !%/> /> !%/> !%/> !$/>  #E!/>" !$#/>$ $((,"&*."&&*&*%)& & (,'+) )
 (,'+' '
 (,'+& &
 (,'7'7z'R'R'+% %# #$ !.]/> /> /> /# /# / / / /` rc  c           	        K   d}|                      |ddd          \  }}g }|r)|                    |                     |                     n(|                    |                     |                     |                     d          r(|                    |                     |                     g }	 |                     |                     |ddi                    |                     |                     |ddd                    g}n# t          $ r}g }Y d }~nd }~ww xY wt          j	        |  d {V }d }	 t          j	        |  d {V }n# t          $ r}g }Y d }~nd }~ww xY w| 
                    |di           }| 
                    |d	i           }	| 
                    |di           }
| 
                    |d	i           }| 
                    |di           }| 
                    |d	i           }| 
                    |	d
i           }| 
                    |d
i           }| 
                    |d
i           }|                     |dg           }g }t          dt          |                    D ]1}|                    |                     ||         |                     2|                     |
dg           }t          dt          |                    D ]1}|                    |                     ||         |                     2|                     |dg           }t          dt          |                    D ]1}|                    |                     ||         |                     2g }t          dt          |                    D ]s}||         }|                     |di           }|                     |dg           }t          |          }|dk    r|d         |d<   nd |d<   |                    |           t|S )NFr   r  product_typeFUTURE	PERPETUAL)rY  contract_expiry_typer   r   fee_tierproductsr  alias_toalias)r  r  v3PrivateGetBrokerageProducts"v3PublicGetBrokerageMarketProductscheck_required_credentials'v3PrivateGetBrokerageTransactionSummaryr  	Exceptionasynciogatherrk  r  r  r  parse_spot_marketparse_contract_market
safe_value)r`  rn  r  spotUnresolvedPromisesunresolvedContractPromisesepromisescontractPromisesr>   r   expiringFuturesperpetualFuturesexpiringFeesperpetualFeesfeeTierexpiringFeeTierperpetualFeeTierrf  r  r  
futureDataperpetualData
newMarketsr  r  realMarketIdsr  s                              rb  r9  zcoinbase.fetch_markets_v3h  s     
!::6>S_afgg
F!# 	["))$*L*LV*T*TUUUU"))$*Q*QRX*Y*YZZZ\ **511 	`"))$*V*VW]*^*^___0 &("	,77F^]eLf8g8ghh77F]e  @K  ML  ML  9M  9M  N  N*&&  	, 	, 	,)+&&&&&&	, )?@@@@@@@	"%,^5O%PPPPPPP 	" 	" 	"!	"~~h2..~~h2....)91bAA>>*:ArBB~~&62>>'7B??( ..z266..z2FF>>-RHH~~dJ33q#d))$$ 	D 	DAMM$00a'BBCCCC^^OZDD
q#j//** 	V 	VAMM$44Z]OTTUUUU'7RHHq#m,,-- 	Z 	ZAMM$44]15EGWXXYYYY
q#f++&& 		& 		&AAYF??66266D NN4R@@M''Fzz"/"2w"&wf%%%%s1   5AD 
D#DD#=E 
E(E##E(c                    |                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                     |d          }|                     |d          }	|                     | j        dg           }
|                     | j        d         d          }|                     | j        d         d	          }|                     ||
          rd
n|                     |d|          }|                     ||
          rdn|                     |d|          }| 	                    i d|d|dz   |z   d|d|dd d|d|dd d|d|dk    dd ddddddd|	 ddd d d ||d d d d d |                     |d!          | 
                    |d"d#          d$d d d%|                     |d&          |                     |d'          d%d d d%|                     |d(          |                     |d)          d%d*d |d+          S ),Nr  base_currency_idquote_currency_idrY  trading_disabledr   r   r   r   gh㈵>taker_fee_rateg        maker_fee_rater/   r  r  r-  r  r?  r+  r,  r@  r  r>   r?   r@   FrA   rB   r  rA  rV  base_incrementprice_incrementquote_incrementrB  rC  base_min_sizebase_max_sizequote_min_sizequote_max_sizerG  rW  r   r   rH  rI  rJ  rK  rL  rM  rN  r  r  )ri  r  r  r  r  rY  r  r   r  rS  safe_number_2)r`  r  rt  r/   r+  r,  r-  r  
marketTypetradingDisabledr   defaultTakerFeedefaultMakerFeetakerFeemakerFees                  rb  rh  zcoinbase.parse_spot_market  s6   @ fl33!!&*<==""6+>??&&v..''00++FNCC
..1CDDnnT\="EE**49Y+?II**49Y+?II"mmB<<~77$BRBRSZ\ln}B~B~--K88z33d>N>NwXhjy>z>z)) 2+
"2+
dSj5(2+
 D2+
 U	2+

 d2+
 f2+
 w2+
 2+
 J2+
 Z6)2+
 d2+
 E2+
 e2+
 e2+
 /)2+
  !2+
" d#2+
$  "**63CDD++F4EGXYY    
  ++FODD++FODD 
   
  ++F4DEE++F4DEE  $ c2+
 2+
 2+
 2 2 2	rc  c                    |                      |d          }|                     |di           }|                      |d          }|                     |d          }|                      |d          }|                     |          }|                     |          }	|dk    }
|                      |d          }|                      |d          }|                     |          }|                     |          }|                     |d	          }|d
z   |z   }d }|
rd}|dz   |z   }n#d}|dz   |z   dz   |                     |          z   }|                     |d          }|                     |d          }|r|n|                     d          }|r|n|                     d          }| 	                    i d|d|d|d|d|d|d|d|d|ddddd|
d|
 ddd | d!d"d#d"d|||||	d d |                     |d$          | 
                    |d%d&          d'd d d(|                     |d)          |                     |d*          d(d d d(|                     |d+          |                     |d,          d(d-d |d.          S )/Nr  future_product_detailsr\  contract_sizecontract_expiryr[  contract_root_unitr}  is_disabledr  r@   :rA   r  r  r  z0.06z0.04r/   r  r-  r  r?  r+  r,  r@  r  r>   Fr?   rB   r  rA  TrV  r  r  r  rB  rC  r  r  r  r  rG  r  )ri  rk  r  r   iso8601r  r  yymmddr_  rS  r  )r`  r  rt  r/   futureProductDetailscontractExpiryTyperH  contractExpireexpireTimestampexpireDateTimeisSwapr+  r,  r-  r  r  r  r  takerFeeRatemakerFeeRater   r   s                         rb  ri  zcoinbase.parse_contract_marketW  s   l fl33#~~f6NPRSS!--.BDZ[[''(<oNN))*>@QRR..88o66$3!!"68LMM""6+>??&&v..''00..??e# 	ODc\E)FFDc\E)C/$++o2N2NNF''1ABB''1ABB ,K$2C2CF2K2K ,K$2C2CF2K2K)) 2+
"2+
f2+
 D2+
 U	2+

 e2+
 f2+
 w2+
 2+
 D2+
 E2+
 e2+
 F2+
 &j2+
 e2+
 /)2+
  !2+
" d#2+
$ (%,**63CDD++F4EGXYY    
  ++FODD++FODD 
   
  ++F4DEE++F4DEE  $ c2+
 2+
 2+
 2 2 2	rc  c                   K   |                      | j        di           }|                     |d          }|                     |dd          }|                                 }|	||z
  |k    r|                     |          |                     |          g}t          j        |  d {V }|                      |di           }|                      |di           }	|                     |dg           }
|                     |	dg           }| 	                    |           d {V }| 
                    ||                     |
|          ||d          | j        d<   |                      | j        di           S )	Nrn   r  r!    r   r   rf  )r   r=  r  )rk  rY  safe_integermillisecondsv2PublicGetCurrenciesv2PublicGetCurrenciesCryptorf  rg  r  v2PublicGetExchangeRatesr  array_concat)r`  rn  rY  r  r!  nowrn  promisesResultfiatResponsecryptoResponsefiatData
cryptoDatar=  s                rb  rO  z$coinbase.fetch_currencies_from_cache  s     ../@"EE%%g{;;	##GY==!!C)Ow#>#>**6220088H $+>8#<<<<<<<N>>.!R@@L "^^NArBBN ~~lFB??HCCJ"&"?"?"G"GGGGGGGM.2kk'"//*EE!. D D / /DL*+
 ~~dl,=rBBBrc  c                 (  K   |                      |          |                     |          |                     |          g}t          j        |  d{V }|                     |di           }|                     |di           }|                     |di           }|                     |dg           }|                     |dg           }|                     |di           }	|                     |	di           }
t          |
                                          }| 	                    ||          }i }i }i }t          dt          |                    D ]}||         }|                     |d          }|                     |dd	          }|                     |          }|                     |d
          }|                                | j        d         |<   |                                | j        d         |<   |dnd}|                     |||||dddddi |                     |d          ddddddd          ||<   ||                                }|||<   |||<   t          dt          |                    D ]A}||         }|                     |          }||vr|                     i ||di d          ||<   B|                     || j        d                   | j        d<   |                     || j        d                   | j        d<   |S )a  
        fetches all available currencies on an exchange

        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr   r      rf  r>  asset_idr/   r  r0   r'  networksByIdr  r#  TrF  rC  )r  r   )r  r/   r  r  r0   r  r\   r   r  rM  r'  rN  )r  r/   r  r  r'  )r  r  r  rf  rg  rk  r  rQ  rR  r  r  r  ri  r  r  lowerrY  safe_currency_structurer  r  )r`  rn  rn  r  r  r  ratesResponser  r  	ratesDatar>  ratesIdsr   r  r'  r  r  r  assetIdr/   r  r0   r  lowerCaseNamer  s                            rb  fetch_currencieszcoinbase.fetch_currenciesG  sY      &&v..,,V44))&11

  '~x8888888~~na<< 2>>  ~q"==>>,;;^^NFB??
NN=&"==	y'266

%%&&x<<
q#j//** #	3 #	3A!!}H&&x<<G##HdF;;B**2..D##Hf55D-1ZZ\\DL$T*15DL(. ' 388&D77  !  $//*EE# 
  $#! !	 	9 9  F4L. " $

!..2]+q#h--(( 
	 
	A!!J**:66DFNN#;;$ $ "= =    t $(;;xj9Q#R#RZ '+{{<nA]'^'^^$rc  symbolsc                    K   |                      | j        dd          }|dk    r|                     ||           d{V S |                     ||           d{V S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getproducts
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates

        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.usePrivate]: use private endpoint for fetching tickers
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        r   r2  N)ri  rY  fetch_tickers_v3fetch_tickers_v2)r`  r  rn  re  s       rb  fetch_tickerszcoinbase.fetch_tickers  s~       !!$,@PQQ%%%..w?????????**7F;;;;;;;;;rc  c                   K   |                                   d {V  |                     |          }i }|                     |                     ||                     d {V }|                     |di           }|                     |di           }|                     |d          }i }t          |                                          }	d}
t          dt          |	                    D ]P}|	|         }||
z   |z   }| 
                    |d |
          }|d         }|                     ||         |          ||<   Q|                     |d|          S )Nrf  r>  r  r  r   r  )r~  market_symbolsr  r  rk  ri  rQ  rR  r  r  r!  parse_tickerfilter_by_array_tickers)r`  r  rn  r  rp  rf  r>  r,  r  rU  	delimiterr  r+  r*  r  r  s                   rb  r  zcoinbase.fetch_tickers_v2  sj     !!!!!!!!!%%g..
 66t{{7F7S7STTTTTTTT ~~h33tWb11""444uzz||$$	q#g,,'' 	F 	FAQZF	)G3H%%hi@@FH%F!..uV}fEEF6NN++FHgFFFrc  c                 r  K   |                                   d {V  |                     |          }i }||                     |          |d<   d }|                     d|                     |          |d          \  }}||dk    r|dk    rdnd|d<   d }d}|                     |dd	d          \  }}|r0|                     |                     ||                     d {V }n/|                     |                     ||                     d {V }| 	                    |d
g           }i }t          dt          |                    D ]X}	||	         }
|                     |
d          }|                     |d d          }|d         }|                     |
|          ||<   Y|                     |d|          S )Nproduct_idsr   rU  r@   rZ  SPOTrY  Fr  r^  r   r  r  r  )r~  r  
market_idshandle_market_type_and_paramsget_market_from_symbolsr  ra  r  rb  r  r  r  ri  r!  r  r  )r`  r  rn  r  r  rp  r  rf  r  r  entryr*  r  r  s                 rb  r  zcoinbase.fetch_tickers_v3  s     !!!!!!!!!%%g..%)__W%=%=GM"
!??PTPlPlmtPuPuw}  @I  J  J
F!jI&=&=3=3G3GhhfGN#
!::6>S_afgg
F 	c!??GU[@\@\]]]]]]]]HH!DDT[[QXZ`EaEabbbbbbbbHL ~~h
B77q#d))$$ 	> 	>AGE''|<<H%%hc::FH%F!..uf==F6NN++FHgFFFrc  c                    K   |                      | j        dd          }|dk    r|                     ||           d{V S |                     ||           d{V S )ar  
        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/advanced-trade/reference/retailbrokerageapi_getmarkettrades
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-spot-price
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-buy-price
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-sell-price

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.usePrivate]: whether to use the private endpoint for fetching the ticker
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        r   r1  N)ri  rY  fetch_ticker_v3fetch_ticker_v2)r`  r  rn  re  s       rb  fetch_tickerzcoinbase.fetch_ticker"  s|       !!$,OO_$$--ff=========))&&999999999rc  c                 |  K   |                                   d {V  |                     |          }|                     d|d         i|          }|                     |           d {V }|                     |           d {V }|                     |           d {V }|                     |di           }|                     |di           }	|                     |di           }
|                     |
d          |                     |	d          |                     |d          d}|                     ||          S )Nr  r/   rf  r  )bidaskr  )	r~  r  r  v2PublicGetPricesSymbolSpotv2PublicGetPricesSymbolBuyv2PublicGetPricesSymbolSellrk  r  r  )r`  r  rn  r  r  r>   r  r  spotDataaskDatabidData
bidAskLasts               rb  r  zcoinbase.fetch_ticker_v25  sr     !!!!!!!!!V$$++fTl
  55g>>>>>>>> 33G<<<<<<<< 44W======== >>$33..fb11..fb11##GX66##GX66%%h99
 


   V444rc  c                 j  K   |                                   d {V  |                     |          }|d         dd}d}|                     |ddd          \  }}d }|r0|                     |                     ||                     d {V }n/|                     |                     ||                     d {V }|                     |dg           }|                     |di           }|                     ||          }	| 	                    |d	          |	d
<   | 	                    |d          |	d<   |	S )Nr/   r   )r  rK  Fr   r  tradesr   best_bidr  best_askr  )
r~  r  r  ,v3PrivateGetBrokerageProductsProductIdTickerr  1v3PublicGetBrokerageMarketProductsProductIdTickerr  rk  r  r  )
r`  r  rn  r  r  r  rp  rf  firsttickers
             rb  r  zcoinbase.fetch_ticker_v3Q  sm     !!!!!!!!!V$$ ,
 
 
!::6=R^`eff
F 	r!NNt{{[bdjOkOkllllllllHH!SSTXT_T_`gioTpTpqqqqqqqqH& ~~h"55tQ++""5&11((:>>u((:>>urc  r  c                    |                      |d          }|                      |d          }d }d }d|v r|                     |dg           }|                     |dg           }|                     |di           }	|                     |di           }
|                      |	d          }|                      |	d          }|                      |
d          }|                      |
d          }|                     |d          }|                     ||          }|                      |d          }|                     |d	          }|                     i d
|d
         d|                     |          d|d|d|d|dd dd d|d|dd dd d|dd dd d|                      |d          dd |                      |d          |                      |d          |d|          S )Nr  r  bidsasksr   r  r  r  r   r  r  r  r  highlow	bidVolume	askVolumevwapopenclosepreviousClosechanger   price_percentage_change_24haverage
volume_24happroximate_quote_24h_volume)
baseVolumequoteVolumer  )r  r  rk  ri  r!  safe_tickerr   )r`  r  r  r  r  r  r  r  r  firstBidfirstAskr*  r  r  s                 rb  r  zcoinbase.parse_tickerx  s   v vu--vu--		f>>&&"55D>>&&"55D~~dAr22H~~dAr22H""8W55C((6::I""8W55C((6::I##FL99!!(F3300##FF33 !
fX&!
11!
 !
 3	!

 3!
 D!
 D!
 4!
 !
 !
 D!
 D!
 T!
 T!
 d!
  $**63PQQ!!
" t#!
$ **6<@@++F4RSS)!
 !
 !
* +  	rc  c                    |                      |ddg           }|                     |d| j        d                   }|                     |d| j        d                   }d|i}t          dt	          |                    D ]\}||         }|                     |d          }	|                     |	|          r|                     |d          }
|
|                     |
d          }|                     |          }|                     |
d	          }|}|                     ||          }|| 	                                }||d
<   ||d<   n<t          j        |d
         |          |d
<   t          j        |d         |          |d<   |||<   |                     |	|          r9|                     |d          }|                     |d          }|
||                     |d          }|                     |          }|                     |d          }|                     |d          }t          j        ||          }|                     ||          }|$| 	                                }||d
<   ||d<   ||d<   nZt          j        |d
         |          |d
<   t          j        |d         |          |d<   t          j        |d         |          |d<   |||<   ^|                     |          S )Nrf  r   r  r$  r  r   balancer  r  freer  available_balanceholdvalueused)safe_list_2r  rY  r  r  ri  r  rk  r  r  r*   
string_addsafe_balance)r`  rp  rn  balancesr   r$  r  br  r  r  r  r  r  r  r  	availabler  r  s                      rb  parse_custom_balancezcoinbase.parse_custom_balance  s   ##Hfj"EE>>&&$,z2JKK^^FFDL4NOO
)q#h--(( &	+ &	+AqkG##GV44D}}T8,, #+w	::$!%!1!1%!D!DJ22:>>D ,,UH==E D"nnVT::G"&,,..*.+0((*1*<WV_e*T*T+2+=gg>NPU+V+V(#*F4LtZ00 + NN74GHH	~~gv66(T-=!%!1!1)Z!H!HJ22:>>D++D'::D++Iw??D#.tT::E"nnVT::G"&,,..*.*.+0((*1*<WV_d*S*S*1*<WV_d*S*S+2+=gg>NPU+V+V(#*F4L  (((rc  c                   K   |                                   d{V  i }d}|                     |dd          }|                     |dg          }d}|                     dd|          \  }}|                     | j        dd          }|dk    r0|                     |                     ||                     d{V }nq|s|dk    r5d|d<   |                     |                     ||                     d{V }n4d|d<   | 	                    |                     ||                     d{V }||d	<   | 
                    ||          S )
a8  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getaccounts
        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-accounts#list-accounts
        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfcmbalancesummary

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.v3]: default False, set True to use v3 api endpoint
        :param str [params.type]: "spot"(default) or "swap" or "future"
        :param int [params.limit]: default 250, maximum number of accounts to return
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        Nr   Fr_   r  rA   r  rK  r  )r~  r  rj  r  ri  rY  &v3PrivateGetBrokerageCfmBalanceSummaryr  r  r4  r  )r`  rn  r  rp  isV3r  re  s          rb  fetch_balancezcoinbase.fetch_balance)	  s      !!!!!!!!!~~fdE226D6**
!??PTV\]]
F!!$,@_``!!!HHU\^dIeIeffffffffHH 	U"AAA"GG!??GU[@\@\]]]]]]]]HH"GG!66t{{7F7S7STTTTTTTTHP $v((6:::rc  c                   K   |                                   d{V  d}|                     |dd          \  }}|r#|                     d||||dddd	  	         d{V S d}||                     |          }d}|                     |||           d{V \  }}|                     |                     ||                     d{V }|                     |d         |||          }	t          |	          }
|
d	k    r|	S |
d
z
  }| 	                    |	|          }| 	                    |di           }| 
                    |d          }||dk    r||d         d<   ||	|<   |	S )a  
        Fetch the history of changes, i.e. actions done by the user or operations that altered the balance. Will return staking rewards, and crypto deposits or withdrawals.

        https://docs.cdp.coinbase.com/coinbase-app/docs/api-transactions#list-transactions

        :param str [code]: unified currency code, default is None
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entries to return, default is None
        :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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict: a `ledger structure <https://docs.ccxt.com/?id=ledger-entry-structure>`
        NFr   rx  ry  rz  r{  rf  r   r   r|  r}  r  )r~  r  r  r  r  r  r  parse_ledgerr  rk  ri  )r`  r  r  rK  rn  rx  r  r  rp  ledgerr  r  r  r|  r  s                  rb  fetch_ledgerzcoinbase.fetch_ledger	  s      !!!!!!!!!88PZ[[& 	Y99-uV[]cez  }M  OS  UX  Y  Y  Y  Y  Y  Y  Y  Y  Y}}T**H $ O OPTV[]c d ddddddd GGT[]cHdHdeeeeeeee""8F#3XueLLVQ;;MQJ	~~fi00^^HlB??
!!*.CDDVr\\28DL./ $F9rc  c                 8    ddi}|                      |||          S )Nr  r  r  )r`  r  typess      rb  parse_ledger_entry_statusz"coinbase.parse_ledger_entry_status	  s(    
 vv666rc  c           
      H    dddddddddd	}|                      |||          S )Nr  r  )	buysellfiat_depositfiat_withdrawalexchange_depositexchange_withdrawalr  pro_depositpro_withdrawalr  r`  r  r  s      rb  parse_ledger_entry_typez coinbase.parse_ledger_entry_type	  sC    ), -#0!(+

 

 tT222rc  itemc                    |                      |di           }|                     |d          }d }t          j        |d          rd}t          j        |          }nd}|                     |d          }|                     ||          }|                     ||          }d }|                      |di           }	|                      |	d          }
|
G|                     |
d          }|                     ||          }|                     |
d          }||d}|                     |                     |d	                    }|                     |d
          }| 	                    |                     |d                    }| 
                    |                     |d                    }|                     |d          }d }|2|                    d          }t          |          }|dk    r|d         }|                     ||||                     |          ||d d |||                     |          d d ||d|          S )Nr  r   outinr  r  r  r  r  r/   r  r  resource_pathr  r   )r  r/   r  r  	directionr  referenceIdreferenceAccountr  r  r  beforeafterr  r  )rk  ri  r*   r  
string_negr  safe_currencyr  r   r  r  r  r  safe_ledger_entryr  r_  )r`  r  r  
amountInfor  r   r  r  r  networkInfofeeInfor  feeCurrencyCode	feeAmountr  r/   r  r  pathr  r  numPartss                         rb  parse_ledger_entryzcoinbase.parse_ledger_entry	  sc   h ^^D(B77
!!*h77	VS)) 	I'//FFI%%j*==
&&z8<<%%j(;; nnT9b99...?@@ ,,WjAAM"55mXNNO(((;;I!+ C NN4#3#3D,#G#GHH	dD))++D,<,<T6,J,JKK//0@0@x0P0PQQo66	JJsOOE5zzH!||!!H	%%"Y//"  $''//'
 '
  !  	rc  c                   K   |                                   d {V  |                     d|           d {V  t          dt          | j                            D ]%}| j        |         }|d         |k    r
|d         c S &d S )NFr   r  r/   )r~  r  r  r  r   )r`  r  rn  r  r  s        rb  find_account_idzcoinbase.find_account_id
  s      !!!!!!!!!  /////////q#dm,,-- 	% 	%AmA&Gv$&&t}$$$ 'trc  c                 |    |                      |dd          }|t          | j        dz             d|i}|||d<   |S )Nr  r  zN prepareAccountRequest() method requires an account_id(or accountId) parameterrK  )r  r!   r/   )r`  rK  rn  r  r  s        rb  r  z coinbase.prepare_account_request  sX    &&v|[II	#DG.~$~)
 $GGrc  c                 .  K   |                      |dd          }|                     |ddg          }|T|t          | j        dz             |                     ||           d {V }|t          | j        dz   |z   dz             d|i}|||d<   ||gS )Nr  r  zz prepareAccountRequestWithCurrencyCode() method requires an account_id(or accountId) parameter OR a currency code argumentzG prepareAccountRequestWithCurrencyCode() could not find account id for zS. You might try to generate the deposit address in the website for that coin first.rK  )r  rj  r!   r/   r1  r   )r`  r  rK  rn  r  r  s         rb  r  z3coinbase.prepare_account_request_with_currency_code  s      &&v|[II	6L+#>??|'  3o  )o  p  p  p"224@@@@@@@@I #DG.w$wz~$~  BW  %W  X  X  X)
 $GG  rc  r  c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d<   |                     |dd|d|           d{V S )a  
        create a market buy order by providing the symbol and cost

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_postorder

        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr>   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr,  r  r  )r~  r  r&   r/   create_order)r`  r  r  rn  r  s        rb  !create_market_buy_order_with_costz*coinbase.create_market_buy_order_with_cost"  s       !!!!!!!!!V$$f~ 	ftw)ddeee6;23&&vxdFSSSSSSSSSrc  r  r  r  r  c                   K   |                                   d{V  |                     |          }|                     | j        dd          }|dz   |                                 z   |d         |                                d}	|                     |d          }
|
r8|                     |d          }||d<   |                     |||           d{V S | 	                    |g d	          }| 
                    |d
          }| 
                    |d          }|du}|du}|du}|                     |d          }|dk    rdn|                     |ddd          }|                     |d          }|                     |d          }|dk    rG|r|
|dk    rdnd}|dk    s|d|t          | j        dz             d|                     ||          |                     ||          |                     ||          ||di|	d<   n
d|                     ||          |                     ||          |                     ||          |di|	d<   n|s|rd}|r#|
|dk    rdnd}|                     ||          }n"|
|dk    rdnd}|                     ||          }d|                     ||          |                     ||          ||di|	d<   n=|dk    s|O|t          | j        dz             d|                     ||          |                     ||          ||d i|	d<   n|d!k    r4d"|                     ||          |                     ||          d#i|	d<   n|d$k    r4d%|                     ||          |                     ||          d#i|	d<   nrd&|                     ||          |                     ||          |d'i|	d<   n=|s|s|rt!          | j        d(z             |d)         r|dk    rd}d}|                     |d*d+d          \  }}| 
                    |d,          }|                     |d,          }||                     ||          }n|ro|t'          | j        d-z             |                     |          }|                     |          }t+          j        ||          }|                     ||          }n|                     ||          }d.d/|ii|	d<   nd.d0|                     ||          ii|	d<   |                     |d1          }||d2k    rd3|	d4<   n|d5k    rd6|	d4<   |                     |g d7          }|                     |d8d9d          }d}|r^|                     |d8d9g          }|                     |	d:          }	|                     |                     |	|                     d{V }n/|                     |                     |	|                     d{V }|                     |d;          }|dur|                     |d<          } |                     | d=          }!|                     | d>          }"| S|                     | j        d?         |!|"           |                     | j        d@         |!|"           t          |"          |                     |dAi           }#|                     |#|          S )Baq  
        create a trade order

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_postorder

        :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]: price to trigger stop orders
        :param float [params.triggerPrice]: price to trigger stop orders
        :param float [params.stopLossPrice]: price to trigger stop-loss orders
        :param float [params.takeProfitPrice]: price to trigger take-profit orders
        :param bool [params.postOnly]: True or False
        :param str [params.timeInForce]: 'GTC', 'IOC', 'GTD' or 'PO', 'FOK'
        :param str [params.stop_direction]: 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
        :param str [params.end_time]: '2023-05-25T17:01:05.092Z' for 'GTD' orders
        :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
        :param boolean [params.preview]: default to False, wether to use the test/preview endpoint or not
        :param float [params.leverage]: default to 1, the leverage to use for the order
        :param str [params.marginMode]: 'cross' or 'isolated'
        :param str [params.retail_portfolio_id]: portfolio uid
        :param boolean [params.is_max]: Used in conjunction with tradable_balance to indicate the user wants to use their entire tradable balance
        :param str [params.tradable_balance]: amount of tradable balance
        :param float [params.reduceOnly]: set to True for closing a position or use closePosition
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr  r  r  r/   )client_order_idr  r  
reduceOnlyr  )	stopPrice
stop_pricer=  r@  rA  rC  r:  TpostOnly	post_onlyFend_timestop_directionrK  r  STOP_DIRECTION_STOP_DOWNSTOP_DIRECTION_STOP_UPr;  z= createOrder() requires an end_time parameter for a GTD orderstop_limit_stop_limit_gtd)	base_sizelimit_pricer;  r?  r>  order_configurationstop_limit_stop_limit_gtc)rC  rD  r;  r?  limit_limit_gtd)rC  rD  r>  r=  r8  sor_limit_ioc)rC  rD  r9  limit_limit_foklimit_limit_gtc)rC  rD  r=  z3 createOrder() only stop limit orders are supportedr>   rT   r,  r  a	   createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumentmarket_market_ioc
quote_sizerC  r<  isolatedISOLATEDmargin_typecrossCROSS)rC  r=  r@  rA  r:  r;  stopDirectionr?  clientOrderIdr<  r=  r>  r<  previewtestr8  successerror_responseerrormessager  r	  success_response)r~  r  ri  rY  r  upperr  rj  close_positionsafe_number_nr  safe_bool_2r   r/   amount_to_precisionprice_to_precisionr&   r  cost_to_precisionr$   number_to_stringr*   r#  #v3PrivatePostBrokerageOrdersPreviewr  v3PrivatePostBrokerageOrdersrk  throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionparse_order)$r`  r  r  r  r  r  rn  r  r/   r  r9  r=  r@  rA  isStop
isStopLossisTakeProfitrC  r<  endTimerR  	tpslPricer  r,  r  r  r4  costRequestr<  rT  rp  rV  errorResponse
errorTitleerrorMessagerf  s$                                       rb  r5  zcoinbase.create_order4  s     < !!!!!!!!!V$$dlJ??!Cx$))++5 ,JJLL
 

 ^^FL99
 	CYYv|44F%F8,,VT6BBBBBBBBB))&2]2]2]^^((AA**63DEET)"$.
&d2&&v}=='4//44d6F6Fvz[fhm6n6n""6:66((1ABB7?? K (CG5==$>$>WoM5((g.A+DG6u,uvvv3)-)A)A&&)Q)Q+/+B+B65+Q+Q*.*A*A&,*W*W.;(/6 66G122 4)-)A)A&&)Q)Q+/+B+B65+Q+Q*.*A*A&,*W*W.;	6 66G122  3| 3 	 Q$,EIU]](@(@Ys $ 7 7 N NII$,GKu}}(B(B[s $ 7 7 P PI/%)%=%=ff%M%M'+'>'>vu'M'M&/*7	2 22-..  5((g.A+DG6u,uvvv))-)A)A&&)Q)Q+/+B+B65+Q+Q(/)1	, ,6G122 !E))')-)A)A&&)Q)Q+/+B+B65+Q+Q* *6G122 !E))))-)A)A&&)Q)Q+/+B+B65+Q+Q, ,6G122 *)-)A)A&&)Q)Q+/+B+B65+Q+Q)1, ,6G122  d d| d"47-b#bcccf~ 45==481<@<Y<YZ`bo  rU  W[  =\  =\916''776622# 2264@@EE6 	C}*47  6A  ,A  B  B  B'+'<'<V'D'D&*&;&;E&B&B&-&8{&S&S $ 6 6v{ K K 2266BBE'$e*2-.. (#T%=%=ff%M%M*2-.
 %%fl;;
!Z'')3&&w&&)0&6  $i  $i  $i  j  j""69feDD 	]YYv	6':;;Fii):;;G!EEdkkRY[aFbFbccccccccHH!>>t{{7TZ?[?[\\\\\\\\HL ..955$ NN85EFFM))-AAJ++M9EEL(44T_W5Mz[ghhh44T_W5Mz[ghhh#L111~~h(:B??f---rc  r  c           
         |                      |d          }|                     ||d          }||                     ||          }|                     |di           }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d          }
|                     |d	          }|d up|d up|d u}|	d up|
d u}d }d }d }d }|rQd }||}n||}n|}|                      |d
          }|                      |d          }|                     |d          }nw|r_|	|	n|
}|                      |d
          }|                      |d          }|                     |d          }|                      |d          }n|                      |d          }|                      |d          }|                      |d          }d }|
||d         }|                     i d|d|                      |d          d|                      |d          d|                     |          d|dd d|d|                     |                      |d                    d|                     |                      |d                    d|d| 	                    |d          d |d!|d"|d#|                      |d$          d%d d&d |                      |d'          | 
                    |                      |d(                    |                      |d          |d)d d*|          S )+Nr  r  rE  rJ  rG  rH  rF  rB  rK  rD  rC  r=  r;  created_time
total_feesr  r  r/   r  rS  r8  r  r  lastTradeTimestampr  r  
order_typerC  time_in_forcer<  r  r  r=  r  filledfilled_size	remainingr  average_filled_pricer  r  )r  r  r  r  )ri  safe_symbolr!  rk  r  
safe_orderr   parse_order_typeparse_time_in_forcer  parse_order_status)r`  r  r  r*  r  orderConfigurationlimitGTClimitGTDlimitIOCstopLimitGTCstopLimitGTD	marketIOCisLimitrh  r  r  r<  r=  target
stopTargetr  	totalFeescurrencyFees                          rb  rg  zcoinbase.parse_order  s0   ~ ##E<88!!(FC88%%ff55F!^^E3H"MM>>"46GHH>>"46GHH>>"4oFF~~&8:UVV~~&8:UVVNN#57JKK	D(]hd.B]X\H\t+JT1I 	>F#!%!!$$V];;E%%fk::F~~fk::HH 	>*6*BJ$$Z??E%%j+>>F~~j+>>H++JEELL%%i==F##E>::$$UL99	!(: /K  
E 
$""5*55 
 T--e5FGG 
 11	 

  
 !$ 
 f 
 D))$*:*:5,*O*OPP 
 433D4D4DUO4\4\]] 
  
 D**5&99 
 U 
 L 
 f 
 d&&um<< 
  ! 
" D# 
$ ''/EFF--d.>.>uh.O.OPP((=='  1 
  
  
2 3  	rc  c                 B    dddddd d}|                      |||          S )Nr  closedr  )OPENFILLED	CANCELLEDEXPIREDFAILEDUNKNOWN_ORDER_STATUSr  r  s      rb  r  zcoinbase.parse_order_status  s:    #! $(
 
 &&999rc  c                 N    |dk    rd S ddddd}|                      |||          S )NUNKNOWN_ORDER_TYPEr  rK  )MARKETLIMITSTOP
STOP_LIMITr  r  s      rb  r}  zcoinbase.parse_order_type  sE    '''4!	
 
 tT222rc  rC  c                 @    ddddd d}|                      |||          S )NGTCr;  r8  r9  )GOOD_UNTIL_CANCELLEDGOOD_UNTIL_DATE_TIMEIMMEDIATE_OR_CANCELFILL_OR_KILLUNKNOWN_TIME_IN_FORCEr  )r`  rC  timeInForcess      rb  r~  zcoinbase.parse_time_in_force  s7    $)$)#(!%)
 
 k;GGGrc  r/   c                    K   |                                   d{V  |                     |g||           d{V }|                     |di           S )a  
        cancels an open order

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders

        :param str id: order id
        :param str symbol: not used by coinbase 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~  cancel_ordersrk  )r`  r/   r  rn  orderss        rb  cancel_orderzcoinbase.cancel_order  sm       !!!!!!!!!))2$????????~~fa,,,rc  idsc                   K   |                                   d{V  d}||                     |          }d|i}|                     |                     ||                     d{V }|                     |dg           }t          dt          |                    D ]9}|                     ||         d          }	|	durt          | j	        dz             :| 
                    ||          S )a  
        cancel multiple orders

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders

        :param str[] ids: order ids
        :param str symbol: not used by coinbase cancelOrders()
        :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>`
        N	order_idsr  r   rV  Tz? cancelOrders() has failed, check your arguments and parameters)r~  r  'v3PrivatePostBrokerageOrdersBatchCancelr  r  r  r  r  r"   r/   parse_orders)
r`  r  r  rn  r  r  rp  r  r  rV  s
             rb  r  zcoinbase.cancel_orders  s      !!!!!!!!![[((F
 EEdkkRY[aFbFbcccccccc )R88q#f++&& 	n 	nAnnVAY	::Gd"" +l!lmmm #  000rc  c                 *  K   |                                   d{V  |                     |          }d|i}	||                     ||          |	d<   ||                     ||          |	d<   |                     |ddd          }
d}|
rH|                     |ddg          }|                     |                     |	|                     d{V }n/|                     |                     |	|                     d{V }| 	                    ||          S )aL  
        edit a trade order

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_editorder

        :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 boolean [params.preview]: default to False, wether to use the test/preview endpoint or not
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr  r  r  rT  rU  F)
r~  r  r_  r`  r^  rj  'v3PrivatePostBrokerageOrdersEditPreviewr   v3PrivatePostBrokerageOrdersEditrg  )r`  r/   r  r  r  r  r  rn  r  r  rT  rp  s               rb  
edit_orderzcoinbase.edit_order  sL       !!!!!!!!!V$$
 "66vvFFGFO#66vuEEGG""69feDD 	aYYv	6':;;F!II$++V]_eJfJfggggggggHH!BB4;;wX^C_C_````````H &111rc  c                 ,  K   |                                   d{V  d}||                     |          }d|i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetches information on an order made by the user

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorder

        :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>`
        Nr  r  )r~  r  ,v3PrivateGetBrokerageOrdersHistoricalOrderIdr  rk  rg  )r`  r/   r  rn  r  r  rp  r  s           rb  fetch_orderzcoinbase.fetch_order  s       !!!!!!!!![[((F
 JJ4;;W^`fKgKghhhhhhhhP x"55v...rc  r{  c                   K   |                                   d{V  d}|                     |dd          \  }}|r#|                     d||||dddd	  	         d{V S d}||                     |          }i }||d         |d<   |||d	<   ||                     |          |d
<   |                     |dg          }|/|                     |dg          }|                     |          |d<   |                     |                     ||                     d{V }	| 	                    |	dg           }
| 
                    |
d          }|                     |	d          }||dk    r
||d<   ||
d<   |                     |
|||          S )a  
        fetches information on multiple orders made by the user

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

        :param str symbol: unified market symbol that the orders were made in
        :param int [since]: the earliest time in ms to fetch orders
        :param int [limit]: the maximum number of order structures to retrieve
        :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 Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        NFr   rx  r  r  r/   r  rK  
start_dateuntilend_dater  r   r}  )r~  r  r  r  r  safe_integer_nrj  *v3PrivateGetBrokerageOrdersHistoricalBatchr  r  rk  ri  r  )r`  r  r  rK  rn  rx  r  r  r  rp  r  r  r  s                rb  fetch_orderszcoinbase.fetch_ordersU  s      !!!!!!!!!88PZ[[& 	G99-QVX]_egoqy{  BF  G  G  G  G  G  G  G  G  G[[((F$*4LGL!$GG$(LL$7$7GL!##FWI66YYvy11F"&,,u"5"5GJHHU\^dIeIeffffffffV (B77vq))!!(H55Vr\\$E(OF1I  >>>rc  c                   K   |                                   d {V  d }||                     |          }d|i}||d         |d<   |d}||d<   ||                     |          |d<   |                     |dg          }|/|                     |dg          }|                     |          |d<   |                     |                     ||                     d {V }	|                     |	d	g           }
|                     |
d
          }| 	                    |	d          }||dk    r
||d<   ||
d
<   | 
                    |
|||          S )Norder_statusr/   r  r{  rK  r  r  r  r  r   r  r}  )r~  r  r  r  rj  r  r  r  rk  ri  r  )r`  r  r  r  rK  rn  r  r  r  rp  r  r  r  s                rb  fetch_orders_by_statuszcoinbase.fetch_orders_by_status  s     !!!!!!!!![[((FF
 $*4LGL!=E $(LL$7$7GL!##FWI66YYvy11F"&,,u"5"5GJHHU\^dIeIeffffffffV (B77vq))!!(H55Vr\\$E(OF1I  >>>rc  c                    K   |                                   d{V  d}|                     |dd          \  }}|r#|                     d||||dddd	  	         d{V S |                     d||||           d{V S )a  
        fetches information on all currently open orders

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

        :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.until]: the latest time in ms to fetch trades for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        NFr   rx  r  r{  r  r~  r  r  r  r`  r  r  rK  rn  rx  s         rb  fetch_open_orderszcoinbase.fetch_open_orders  s       !!!!!!!!!88ART^__& 	J99:KVUZ\aciksu}  @D  FI  J  J  J  J  J  J  J  J  J00vVVVVVVVVVrc  c                    K   |                                   d{V  d}|                     |dd          \  }}|r#|                     d||||dddd	  	         d{V S |                     d||||           d{V S )a  
        fetches information on multiple closed orders made by the user

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

        :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 closed 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.until]: the latest time in ms to fetch trades for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        NFrh   rx  r  r{  r  r  r  s         rb  fetch_closed_orderszcoinbase.fetch_closed_orders  s       !!!!!!!!!88ATV`aa& 	L99:MvW\^cekmuw  BF  HK  L  L  L  L  L  L  L  L  L0065%QWXXXXXXXXXrc  c                 D   K   |                      d||||           d{V S )a[  
        fetches information on multiple canceled orders made by the user

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

        :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 canceled order structures to retrieve
        :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>`
        r  N)r  )r`  r  r  rK  rn  s        rb  fetch_canceled_orderszcoinbase.fetch_canceled_orders  s7       00feUTZ[[[[[[[[[rc  r  	timeframec           
        K   |                                   d{V  d}||nt          ||          }d}|                     |ddd          \  }}|r$|                     d||||||dz
             d{V S |                     |          }|d         |                     | j        ||          d}	|                     |d	d
g          }
|                     |d	g          }| 	                    |          }||z  }d}|,| 
                    |                     |dz                      }nCt          |                                           }t          j        |t          |                    }||	d<   |
/| 
                    |                     |
dz                      |	d
<   n%t          j        |t          |                    |	d
<   d}d}|                     |ddd          \  }}|r0|                     |                     |	|                     d{V }n/|                     |                     |	|                     d{V }|                     |dg           }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpubliccandles

        :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, not used by coinbase
        :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)
        :param boolean [params.usePrivate]: default False, when True will use the private endpoint to fetch the candles
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NrQ  Fr   rx  r   r/   )r  granularityr  endr  startr  candles)r~  rD  r  "fetch_paginated_call_deterministicr  ri  r
  r  rj  parse_timeframerb  parse_to_intstrsecondsr*   
string_subr  -v3PrivateGetBrokerageProductsProductIdCandlesr  2v3PublicGetBrokerageMarketProductsProductIdCandlesr  parse_ohlcvs)r`  r  r  r  rK  rn  maxLimitrx  r  r  r  durationrequestedDurationsinceStringr  rp  r  r  s                     rb  fetch_ohlcvzcoinbase.fetch_ohlcv'  s       !!!!!!!!!"]UH1E1E88z[`aa& 	F@@vW\^cenpv  yA  DE  yE  F  F  F  F  F  F  F  F  FV$$ ,++DOY	RR
 
 ##FWe,<==6G9--''	22!H,//0A0A%$,0O0OPPKKdllnn%%C!,S#6G2H2HIIK&!2243D3DUT\3R3RSSGENN %/SAR=S=STTGEN
!::6<Q]_dee
F 	s!OOPTP[P[\cekPlPlmmmmmmmmHH!TTUYU`U`ahjpUqUqrrrrrrrrH ..9b99  &)UEJJJrc  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr  r  r  r  r  volume)safe_timestampr  )r`  ohlcvr  s      rb  parse_ohlcvzcoinbase.parse_ohlcvk  s     w//UF++UF++UE**UG,,UH--
 	
rc  c                 ,  K   |                                   d{V  |                     |          }d|d         i}|.|                     |                     |dz                      |d<   |t	          |d          |d<   d}|                     |dd          \  }}|/|                     |                     |dz                      |d	<   n|t          | j        d
z             d}d}	|                     |ddd          \  }	}|	r0|                     | 	                    ||                     d{V }n/| 
                    | 	                    ||                     d{V }|                     |dg           }
|                     |
|||          S )a  
        get the list of most recent trades for a particular symbol

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpublicmarkettrades

        :param str symbol: unified market symbol of the trades
        :param int [since]: not used by coinbase fetchTrades
        :param int [limit]: the maximum number of trade structures to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.usePrivate]: default False, when True will use the private endpoint to fetch the trades
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr  r/   r  r  rK  r   r  r  zI fetchTrades() requires a `until` parameter when you use `since` argumentFr  r  )r~  r  rb  r  rD  r  r!   r/   r  r  r  r  r  )r`  r  r  rK  rn  r  r  r  rp  r  r  s              rb  fetch_tradeszcoinbase.fetch_trades  s      !!!!!!!!!V$$&,
 #44T5F5Fut|5T5TUUGG"5$//GG55fmWUUv!2243D3DUT\3R3RSSGENN#DG.y$yzzz
!::6=R^`eff
F 	r!NNt{{[bdjOkOkllllllllHH!SSTXT_T_`gioTpTpqqqqqqqqH" (B77  >>>rc  c                   K   |                                   d{V  d}|                     |dd          \  }}|r#|                     d||||dddd	  	         d{V S d}||                     |          }i }||d         |d<   |||d	<   ||                     |          |d
<   |                     |dg          }|/|                     |dg          }|                     |          |d<   |                     |                     ||                     d{V }	| 	                    |	dg           }
| 
                    |
d          }|                     |	d          }||dk    r
||d<   ||
d<   |                     |
|||          S )ag  
        fetch all trades made by the user

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfills

        :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>`
        NFr   rx  r  r  r/   r  rK  start_sequence_timestampr  end_sequence_timestampfillsr   r}  )r~  r  r  r  r  r  rj  *v3PrivateGetBrokerageOrdersHistoricalFillsr  r  rk  ri  r  )r`  r  r  rK  rn  rx  r  r  r  rp  r  r  r  s                rb  fetch_my_tradeszcoinbase.fetch_my_trades  s      !!!!!!!!!88R\]]& 	H99/6SXZ_agiqs{  ~B  DG  H  H  H  H  H  H  H  H  H[[((F$*4LGL!$GG26,,u2E2EG./##FWI66YYvy11F04U0C0CG,-HHU\^dIeIeffffffff0 '266vq))!!(H55Vr\\$E(OF1I  >>>rc  c           	      @  K   |                                   d{V  |                     |          }d|d         i}|||d<   d}d}|                     |ddd          \  }}|r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     |d	          }	|                     |	          }
| 	                    |||
d
ddd          S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpublicproductbook

        :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
        :param boolean [params.usePrivate]: default False, when True will use the private endpoint to fetch the order book
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        Nr  r/   rK  Fr   r  	pricebookr   r  r  r  r  )
r~  r  r   v3PrivateGetBrokerageProductBookr  %v3PublicGetBrokerageMarketProductBookrk  ri  r   parse_order_book)r`  r  rK  rn  r  r  rp  r  rf  r   r  s              rb  fetch_order_bookzcoinbase.fetch_order_book  s\      !!!!!!!!!V$$&,
 $GG
!::6CSUachii
F 	f!BB4;;wX^C_C_````````HH!GGT[]cHdHdeeeeeeeeH* ~~hR88f--NN4((	$$T69ffgW]^^^rc  c                 T  K   |                                   d{V  |                     |          }i }||                     |          |d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||          S )a  
        fetches the bid and ask price and volume for multiple markets

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getbestbidask

        :param str[] [symbols]: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        Nr  
pricebooks)r~  r  r  v3PrivateGetBrokerageBestBidAskr  r  parse_tickers)r`  r  rn  r  rp  tickerss         rb  fetch_bids_askszcoinbase.fetch_bids_asks+  s       !!!!!!!!!%%g..%)__W%=%=GM"==dkk'SY>Z>Z[[[[[[[[. ..<<<!!'7333rc  r  r  c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }d||                     |          |d         d}|                     |dd          }|                     |ddg          }|W|t          | j        dz             | 	                    ||           d{V }|t          | j        dz   |z             ||d<   n||d<   |||d	<   |                     |                     ||                     d{V }	|                     |	d
i           }
|                     |
|          S )at  
        make a withdrawal

        https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/send-crypto

        :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 str [params.network]: the cryptocurrency network to use for the withdrawal using the lowercase name like bitcoin, ethereum, solana, etc.
        :param dict [params.travel_rule_data]: some regions require travel rule information for crypto withdrawals, see the exchange docs for details https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/travel-rule
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  r/   )r  r  r  r  r  r  zV withdraw() requires an account_id(or accountId) parameter OR a currency code argumentz* withdraw() could not find account id for r  rf  )handle_withdraw_tag_and_paramscheck_addressr~  r  rb  r  rj  r!   r/   r1  r   *v2PrivatePostAccountsAccountIdTransactionsr  rk  r  )r`  r  r  r  r  rn  r  r  r  rp  rf  s              rb  r   zcoinbase.withdrawT  s      99#vFFV7###!!!!!!!!!==&&++F33 	
 
 &&v|[II	6L+#>??|'  3K  )K  L  L  L"224@@@@@@@@I #DG.Z$Z]a$abbb$-GL!!$-GL!?),G%&HHU\^dIeIeffffffffj ~~h33%%dH555rc  c                   K   |                                   d{V  |                     |          }d}|                     |d         d|           d{V \  }}|                     |                     ||                     d{V }|                     |dg           }|                     |dd          }|                     |d          S )a  
        fetch the deposit address for a currency associated with self account

        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses

        :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>`
        Nr  rf  Fr  )r~  r  r  &v2PrivateGetAccountsAccountIdAddressesr  r  parse_deposit_addressesrP  )r`  r  rn  r  r  rp  rf  addressStructuress           rb  "fetch_deposit_addresses_by_networkz+coinbase.fetch_deposit_addresses_by_network  s       !!!!!!!!!==&& $ O OPXY_P`bfhn o oooooooDDT[[QXZ`EaEabbbbbbbbp ~~h33 88tUKK}}.	:::rc  c                    |                      |d          }|                     |           |                      |d          }|                     d |          }|                      |d          }d }|,|                    d          }|                      |d          }n|                      |d          }|                     |d          }	||                     ||          |                     ||          ||                      |	d          d	S )
Nr  r  address_labelr  r   r  address_infor  )r  r  r  r  r  )ri  r  r  r  rk  r  )
r`  depositAddressr  r  r
  r  addressLabelr  splitAddressLabeladdressInfos
             rb  parse_deposit_addresszcoinbase.parse_deposit_address  s   r "">9==7###$$^Y??	&&tX66''HH
# , 2 23 7 7))*;Q??JJ)).*EEJnn^^DD"//
HEE..y$??##K1BCC
 
 	
rc  c                 P  K   |                                   d{V  |                     |dd          }|                     |ddg          }|Q|t          | j        dz             |                     ||           d{V }|t          | j        dz   |z             ||                     |          |                                |dd}| 	                    | 
                    ||                     d{V }|                     |dd	i           }|                     |          S )
aa  
        make a deposit

        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#deposit-funds

        :param str code: unified currency code
        :param float amount: the amount to deposit
        :param str id: the payment method id to be used for the deposit, can be retrieved from v2PrivateGetPaymentMethods
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.accountId]: the id of the account to deposit into
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  r  zU deposit() requires an account_id(or accountId) parameter OR a currency code argumentz) deposit() could not find account id for T)r  r  r  payment_methodcommitrf  transfer)r~  r  rj  r!   r/   r1  r   rb  r[  &v2PrivatePostAccountsAccountIdDepositsr  safe_dict_2r  )	r`  r  r  r/   rn  r  r  rp  rf  s	            rb  r\   zcoinbase.depositI  sl      !!!!!!!!!&&v|[II	6L+#>??|'  3J  )J  K  K  K"224@@@@@@@@I #DG.Y$Y\`$`aaa#++F33

 
 
 DDT[[QXZ`EaEabbbbbbbbL &*bAA%%d+++rc  c                    K   |                                   d{V  |                     |dd          }|                     |ddg          }|Q|t          | j        dz             |                     ||           d{V }|t          | j        dz   |z             ||d}|                     |                     ||                     d{V }| 	                    |ddi           }| 
                    |          S )	a.  
        fetch information on a deposit, fiat only, for crypto transactions use fetchLedger

        https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#show-deposit

        :param str id: deposit id
        :param str [code]: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.accountId]: the id of the account that the funds were deposited into
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  r  zZ fetchDeposit() requires an account_id(or accountId) parameter OR a currency code argumentz. fetchDeposit() could not find account id for )r  
deposit_idrf  r  )r~  r  rj  r!   r/   r1  r   .v2PrivateGetAccountsAccountIdDepositsDepositIdr  r  r  )r`  r/   r  rn  r  r  rp  rf  s           rb  fetch_depositzcoinbase.fetch_deposit  sM      !!!!!!!!!&&v|[II	6L+#>??|'  3O  )O  P  P  P"224@@@@@@@@I #DG.^$^ae$efff#
 
 LLT[[Y`bhMiMijjjjjjjjL &*bAA%%d+++rc  c                    K   |                                   d{V  |                     |           d{V }|                     |dg           }|                     |          S )a~  
        fetch the deposit id for a fiat currency associated with self account

        https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpaymentmethods

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an array of `deposit id structures <https://docs.ccxt.com/?id=deposit-id-structure>`
        Npayment_methods)r~  #v3PrivateGetBrokeragePaymentMethodsr  parse_deposit_method_ids)r`  rn  rp  r  s       rb  fetch_deposit_method_idsz!coinbase.fetch_deposit_method_ids  s}       !!!!!!!!!AA&IIIIIIII( *;R@@,,V444rc  c                    K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |di           }|                     |          S )a  
        fetch the deposit id for a fiat currency associated with self account

        https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpaymentmethod

        :param str id: the deposit payment method id
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `deposit id structure <https://docs.ccxt.com/?id=deposit-id-structure>`
        Npayment_method_idr  )r~  2v3PrivateGetBrokeragePaymentMethodsPaymentMethodIdr  rk  parse_deposit_method_id)r`  r/   rn  r  rp  r  s         rb  fetch_deposit_method_idz coinbase.fetch_deposit_method_id  s       !!!!!!!!!
 PPQUQ\Q\]dflQmQmnnnnnnnn$ *:B??++F333rc  c                     g }t          dt          |                    D ]F}|                     |                     ||                   |          }|                    |           G|S )Nr   )r  r  r  r  r  )r`  r  rn  r  r  r/   s         rb  r  z!coinbase.parse_deposit_method_ids  se    q#c((## 	 	AT99#a&AA6JJBMM"rc  c                     ||                      |d          |                      |d          |                     |d          |                      |d          dS )Nr/   r  verifiedr0   )r  r/   r  r  r  )ri  r  )r`  	depositIds     rb  r  z coinbase.parse_deposit_method_id  s^    ""9d33((J??y*==##Iv66
 
 	
rc  fromCodetoCodec                 "  K   |                                   d{V  |||                     |          d}|                     |                     ||                     d{V }|                     |di           }|                     |          S )a  
        fetch a quote for converting from one currency to another

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_createconvertquote

        :param str fromCode: the currency that you want to sell and convert from
        :param str toCode: the currency that you want to buy and convert into
        :param float [amount]: how much you want to trade in units of the from currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param dict [params.trade_incentive_metadata]: an object to fill in user incentive data
        :param str [params.trade_incentive_metadata.user_incentive_id]: the id of the incentive
        :param str [params.trade_incentive_metadata.code_val]: the code value of the incentive
        :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
        N)from_account
to_accountr  r  )r~  rb  "v3PrivatePostBrokerageConvertQuoter  rk  parse_conversion)r`  r  r  r  rn  r  rp  rf  s           rb  fetch_convert_quotezcoinbase.fetch_convert_quote%  s       !!!!!!!!!$ ++F33
 

 @@WV\A]A]^^^^^^^^~~h44$$T***rc  c                    K   |                                   d{V  |||d}|                     |                     ||                     d{V }|                     |di           }|                     |          S )a  
        convert from one currency to another

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_commitconverttrade

        :param str id: the id of the trade that you want to make
        :param str fromCode: the currency that you want to sell and convert from
        :param str toCode: the currency that you want to buy and convert into
        :param float [amount]: how much you want to trade in units of the from currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
        Nr  r  r  r  )r~  )v3PrivatePostBrokerageConvertTradeTradeIdr  rk  r   )	r`  r/   r  r  r  rn  r  rp  rf  s	            rb  create_convert_tradezcoinbase.create_convert_trade>  s       !!!!!!!!!$ 
 

 GGT[]cHdHdeeeeeeee~~h44$$T***rc  c                   K   |                                   d{V  |t          | j        dz             |                     |d          }|t          | j        dz             |                     |d          }|||d}|                     |                     ||                     d{V }|                     |di           }|                     |          S )a:  
        fetch the data for a conversion trade

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getconverttrade

        :param str id: the id of the trade that you want to commit
        :param str code: the unified currency code that was converted from
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param strng params['toCode']: the unified currency code that was converted into
        :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
        Nz- fetchConvertTrade() requires a code argumentr  z0 fetchConvertTrade() requires a toCode parameterr#  r  )	r~  r!   r/   ri  rj  (v3PrivateGetBrokerageConvertTradeTradeIdr  rk  r   )r`  r/   r  rn  r  r  rp  rf  s           rb  fetch_convert_tradezcoinbase.fetch_convert_tradeU  s       !!!!!!!!!<#DG.]$]^^^!!&(33>#DG.`$`aaa68,,  
 

 FFt{{SZ\bGcGcdddddddd~~h44$$T***rc  
conversionfromCurrency
toCurrencyc                    |                      |d          }|                     ||          }|                      |d          }|                     ||          }|                     |d          }|                     |d          }	|                     |	d          }
|d d |                      |d          ||                     |d          |d d |                     |
d          d
S )	Nsource_currencytarget_currencyuser_entered_amount	total_feer  r/   r  )
r  r  r  r/   r*  
fromAmountr+  toAmountr  r  )ri  r  rk  r  )r`  r)  r*  r+  fromCoinr  r  r  fromAmountStructurefeeStructurefeeAmountStructures              rb  r   zcoinbase.parse_conversionq  s    ##J0ABB**8\BBj*;<<((Z88"nnZ9NOO~~j+>>!^^L(CC"":t44$**+>HH ##$6@@
 
 	
rc  c                   K   |                                   d{V  |                     |          }|                     |dd          }|                     |d          }d|d         i}|t	          | j        dz             ||d<   |                     |                     ||                     d{V }|                     |di           }| 	                    |          S )ai  
        *futures only* closes open positions for a market

        https://docs.cdp.coinbase.com/coinbase-app/trade/reference/retailbrokerageapi_closeposition

        :param str symbol: Unified CCXT market symbol
        :param str [side]: not used by coinbase
        :param dict [params]: extra parameters specific to the coinbase api endpoint
 @param {str}  params.clientOrderId *mandatory* the client order id of the position to close
        :param float [params.size]: the size of the position to close, optional
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr8  rS  r  r/   z3 closePosition() requires a clientOrderId parameterrZ  )
r~  r  r  rj  r!   r/   )v3PrivatePostBrokerageOrdersClosePositionr  rk  rg  )	r`  r  r  rn  r  rS  r  rp  r  s	            rb  r\  zcoinbase.close_position  s       !!!!!!!!!V$$**63DoVV6?33&,
  #DG.c$cddd%2!"GGT[]cHdHdeeeeeeeex);R@@&&&rc  c                 L  K   |                                   d{V  |                     |          }d}||                     |d                   }d}|                     d||          \  }}d}|dk    r|                     |           d{V }nhd}|                     |dd          \  }}|t          | j        dz             d|i}|                     | 	                    ||                     d{V }| 
                    |dg           }|                     ||          S )	aA  
        fetch all open positions

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfcmpositions
        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getintxpositions

        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.portfolio]: the portfolio UUID to fetch positions for
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>`
        Nr   r   rA   r  z fetchPositions() requires a "portfolio" value in params(eg: dbcb91e7-2bc9-515), or set.options["portfolio"]. You can get a list of portfolios with fetchPortfolios()portfolio_uuid	positions)r~  r  r  r  !v3PrivateGetBrokerageCfmPositionsr  r!   r/   /v3PrivateGetBrokerageIntxPositionsPortfolioUuidr  r  parse_positions)	r`  r  rn  r  r  rp  r  r  r;  s	            rb  fetch_positionszcoinbase.fetch_positions  sw      !!!!!!!!!%%g..[[,,F99:JFTZ[[f8!CCFKKKKKKKKHHI $ = =fFVXc d dIv '  3Z  )Z  [  [  [ )G "QQRVR]R]^egmRnRnooooooooHNN8["==	##Iw777rc  c                 v  K   |                                   d{V  |                     |          }d}|d         rc|                     |d          }|t          | j        dz             d|i}|                     |                     ||                     d{V }nod}|                     |dd          \  }}|t          | j        dz             |d         |d	}|                     |                     ||                     d{V }| 	                    |d
i           }	| 
                    |	|          S )a@  
        fetch data on a single open contract trade position

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getintxposition
        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfcmposition

        :param str symbol: unified market symbol of the market the position is held in, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.product_id]: *futures only* the product id of the position to fetch, required for futures markets only
        :param str [params.portfolio]: *perpetual/swaps only* the portfolio UUID to fetch the position for, required for perpetual/swaps markets only
        :returns dict: a `position structure <https://docs.ccxt.com/?id=position-structure>`
        NrA   r  z2 fetchPosition() requires a "product_id" in paramsr   r  z fetchPosition() requires a "portfolio" value in params(eg: dbcb91e7-2bc9-515), or set.options["portfolio"]. You can get a list of portfolios with fetchPortfolios()r/   )r  r:  position)r~  r  ri  r!   r/   *v3PrivateGetBrokerageCfmPositionsProductIdr  r  5v3PrivateGetBrokerageIntxPositionsPortfolioUuidSymbolrk  parse_position)
r`  r  rn  r  rp  	productIdfutureRequestr  r  rA  s
             rb  fetch_positionzcoinbase.fetch_position  s      !!!!!!!!!V$$( 	v((>>I '2f(fgggi#M "LLT[[YfhnMoMoppppppppHHI $ = =fFVXc d dIv '  3Y  )Y  Z  Z  Z ,"+ G "WWX\XcXcdkmsXtXtuuuuuuuuH>>(J;;""8V444rc  rA  c                    |                      |dd          }|                     ||          }|                      |d          }d }|
|dk    rdnd}|                     |di           }|                      |d          }|d	k    rd
nd}|                     |di           }	|                     |di           }
|                     |
d          }|                     |di           }|                     |di           }|                     i d|d|                      |d          d|                     ||          d|                     |d          d|d|d|                     |d          d|                     |	d          dd dd d|                     |d          d|d         dd dd d |d!d d"d d d d d |                     |d#          d d |                     |d$          d d d d%          S )&Nr  r}  rO  MARGIN_TYPE_CROSSrP  rM  position_notionalposition_sidePOSITION_SIDE_LONGlongshortunrealized_pnlliquidation_pricer  r  portfolio_summaryr  r/   r  notionalr<  liquidationPrice
entryPriceunrealizedPnlrealizedPnlr   	contractsnet_sizerH  	markPrice	lastPricer  rD  r  
collateralrF  )r  lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentager[  initialMargininitialMarginPercentagerF  marginRatior@  rA  )ri  r!  rk  r  safe_positionr{  )r`  rA  r  r*  	rawMarginr<  notionalObjectpositionSider  unrealizedPNLObjectliquidationPriceObjectrS  
vwapObjectsummaryObjects                 rb  rD  zcoinbase.parse_position  s   t ##Hh;;!!(F33$$X}==	
 %.2E%E%EJJ2ErJJ''/BB&*>>>vvW"nnX7GLL!%:Mr!R!R++,BGLL^^Hfb99
x1DbII!! #
H#
$""8\::#
 d&&x88#
 ((AA	#

 *#
  0#
 $**:w??#
 T--.A7KK#
 4#
 $#
 ))(J??#
 F>2#
 #
 #
 D#
  d!#
" ##
$ #'!%+/**=,GG!'+((:>>!#9#
 #
 #
   	rc  c                 J  K   |                                   d{V  d}|                     dd|          \  }}|dk    }|rdnd}d|i}|                     |                     ||                     d{V }|                     |di           }|                     |d          }|                     |d	          }	i }
t          d
t          | j                            D ]C}| j        |         }| 	                    |          }|r|d         s
|s|d         s||||	dd|
|<   D|
S )a  

        https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_gettransactionsummary/

        fetch the trading fees for multiple markets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'swap'
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/?id=fee-structure>` indexed by market symbols
        Nr   r>   r  rZ  rY  r]  r  r  r   T)r  r  r   r   r   )
r~  r  rd  r  rk  r  r  r  r  r  )r`  rn  r  isSpotproductTyper  rp  rf  	taker_fee
marker_feer  r  r  r  s                 rb  fetch_trading_feeszcoinbase.fetch_trading_feeso  s{      !!!!!!!!!99:LdTZ[[f&. &4ffHK
 EEdkkRY[aFbFbcccccccc0 ~~h
B77$$T+;<<	%%d,<==
q#dl++,, 
	 
	A\!_F[[((F 6&> 6 &. $$&'"&" "v rc  portfolioUuidc                    K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |          }|S )a  
        Fetch details for a specific portfolio by UUID

        https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getportfolios

        :param str portfolioUuid: The unique identifier of the portfolio to fetch
        :param Dict [params]: Extra parameters specific to the exchange API endpoint
        :returns any[]: An account structure <https://docs.ccxt.com/?id=account-structure>
        Nr:  )r~  ,v3PrivateGetBrokeragePortfoliosPortfolioUuidr  parse_portfolio_details)r`  rp  rn  r  rp  r  s         rb  fetch_portfolio_detailsz coinbase.fetch_portfolio_details  s       !!!!!!!!!m
 JJ4;;W^`fKgKghhhhhhhh--h77rc  portfolioDatac                    |d         }|                      |di           }|                     |dd          }|                     |dd          }|                     |dg           }g }t          dt	          |                    D ]}||         }	|                     |	d	d          }
|                     |	d
d          }|                     |          }|                     |	dd          }|                     |          }||z
  }|                      |	di           }|                     |dd          }|                      |	di           }|                     |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d          d|                     |          |                     |dd          |                     |	dd          |                     |                     |	d d                    |                     |	d!d          |                     |	d"d          d#}|                    |            |S )$N	breakdownr  r0   Unknownr  r}  spot_positionsr   assetavailable_to_trade_fiatr   total_balance_fiat
cost_basisr  average_entry_pricer  r  hold_amountwallet_namer  account_uuidtotal_balance_cryptoavailable_to_trade_cryptoavailable_to_transfer_fiatavailable_to_transfer_crypto
allocationcost_basis_currencyr7  is_cashF
asset_uuidrO  asset_coloraccount_type)average_entry_price_currencyr  rO  r  r  )rk  ri  r  r  r  r_  r  r  )r`  ru  rw  portfolioInfoportfolioNamerp  spotPositionsparsedPositionsr  rA  currencyCodeavailableBalanceStravailableBalancetotalBalanceFiatStrtotalBalanceFiat
holdAmountcostBasisDictcostBasisStraverageEntryPriceDictaverageEntryPriceStrpositionDatas                        rb  rs  z coinbase.parse_portfolio_details  s   !+.	y+rBB((	JJ((CCy2BBGGq#m,,-- $	1 $	1A*1-H++HgyIIL"&"2"28=VX["\"\#001DEE"&"2"28=QSV"W"W#001DEE),<<J NN8\2FFM++M7CHHL$(NN8=RTV$W$W!#'#3#34I7TW#X#X "L"#%5" " }	"
 m"  0 0>2 N N" %&6" '(9(9$:J:J8Ukmp:q:q(r(r" *4+<+<T=M=MhXqsv=w=w+x+x" ,T->->t?O?OPXZuwz?{?{-|-|" -d.?.?@P@PQY[wy|@}@}.~.~" /0A0A$BRBRS[]xz}B~B~00" d//0@0@<Y\0]0]^^" d//==" &t'7'7zSX'Y'Y"  4>>(IuEE!"" &t'8'89M'N'N#"$ 150@0@AVXbdi0j0j"..xrJJ"&"3"3D4D4DXO_ad4e4e"f"f#//-LL $ 0 0>2 N N-" " "L0 ""<0000rc  Fr  re  urlc           
      0   d }|A|dz   |                     dd          z   }|                    d          }|dk    r
|d|         }|                     d          }|rdnd}|rd	nd
}	|g|	||dz   | j        |d}
||s||
d<   n|g|
d<   |rS|                     | j                  }|                     |dd          }|                     |
|dd| j        |dd          S |                     |
|                     | j                  dd| j        |dd          S )Nr  zhttps://r}  ?r      cdp_serviceretail_rest_api_proxycdpzcoinbase-cloudx   )audissnbfexpsubiaturiuris    sha256FEdDSA)kidnoncealgES256)	replacefindrandom_bytesr   base64_to_binaryr   array_slicejwtencode)r`  r  re  r  useEddsar  quesPosr  r  r  r  	byteArrayseeds                rb  create_auth_tokenzcoinbase.create_auth_token  sy    ?3,Z!<!<<ChhsmmG {{!G)n!!"%%'Dmm-D5ee%55S=;
 
 ? (!$#&% 	F--dk::I##Iq"55D88GT8UDKZ_ho<p<pqqq 88GT[[%=%=xX\Xcns  }D  QE  QE  F  F  Frc  c                 F    |                                  | j        d         z
  S )Nr/  )r  rY  )r`  s    rb  r  zcoinbase.nonce  s!      ""T\2B%CCCrc  GETc                    |d         }|d         dk    }|dk    }	|	rdnd}
d|
z   dz   |                      ||          z   }|                     ||                     |                    }|}|dk    r|r|d	|                     |          z   z  }| j        d
         d         |z   }|rQ|                     | j        d          }d }||}n
| j        r!|                     d          sd| j        z   }n|                                  | 	                                }d}|dk    r|r| 
                    |          }|}n|	s|r|d	|                     |          z   z  }| j                            d          dk    p| j                            d          }t!          | j                  dk    p5|                     | j        dd          p| j                            d          }|s|rQ|r1| j                            d          rt)          | j        dz             |                     ||||          }d|z   }n|                                 }|                     |dz            }t3          |          }||z   |z   |z   }|                     |                     |          |                     | j                  t8          j                  }| j        ||dd}|"|dd}|dk    r|r| 
                    |          }||||dS )Nr   r   r   r   zapi/v3r8   r  r  r  r   r   AuthorizationFzBearer r}  zorganizations/z
-----BEGINX   v2CloudAPiKey=zV apiKey should contain the name(eg: organizations/3b910e93....) and not the public keyr  zapplication/json)zCB-ACCESS-KEYzCB-ACCESS-SIGNzCB-ACCESS-TIMESTAMPContent-Type)r  r  )r  re  bodyr;   )implode_paramsrj  extract_paramsurlencode_with_array_repeatr   ri  r;   tokenrc  r  json	urlencoder   r  r   
startswithr  r  rY  endswithr!   r/   r  r  r  r  hmacr  hashlibr  )r`  r-  r   re  rn  r;   r  r7   signedr  pathPartfullPathr  	savedPathr  authorizationauthorizationStringr  payloadisCloudAPiKeyisV2CloudAPiKeyr  r  r  timestampStringauth	signatures                              rb  signzcoinbase.sign  s   a&Q9$$ $/884>C'$*=*=dF*K*KK		&$"5"5d";";<<	U?? JC$"B"B5"I"IIIiv&1 E	0 ,,T\?KKM"&(&3## 8D$C$CE$J$J 8&/$*&<##//111,,..U?? '#yy//"& C  C#sT^^E-B-B'BBG
 "&!1!12B!C!Cq!H sdkNdNdeqNrNr"%dk"2"2b"8  #NDNN4<Yhjo<p<p  #Ntxt  uI  uI  JM  uN  uN  #O #$ T)?)?)M)M T/  ;S  1S  T  T  T& !227FCYYE*3e*;'' JJLLE $ 1 1%$, ? ?I&))nnO*V3i?'ID $		$++d*;*;T[[=U=UW^We f fI)-*3/>(:	 G #.%8$6  U?? 0#yy//fdwOOOrc  reasonr;   r  c
                 N   |d S | j         dz   |z   }
|                     |d          }|j|                     |dd          }|                     | j        d         ||
           |                     | j        d         ||
           t          |
          |                     |d          }|j|                     |dd          }|                     | j        d         ||
           |                     | j        d         ||
           t          |
          |                     |d          }|t          |t                    rt          |          }|d	k    r|                     |d	         d
          }|                     |d	         d          }|S|                     | j        d         ||
           |                     | j        d         ||
           t          |
          | j        d         }d|vr/|s-t          | j         dz   |                     |          z             d S )Nr  rX  error_descriptionr  r	  rW  preview_failure_reasonerrorsr   r/   rY  r-  rf  z$ failed due to a malformed response )r/   ri  r  re  r   rf  r   rk  r  
isinstancerQ  r  rY  r  )r`  r  r  r  re  r;   r  rp  requestHeadersrequestBodyfeedback	errorCoderp  rn  errorMessageInnerr  	numErrorsadvancedTrades                     rb  handle_errorszcoinbase.handle_errorse  s8   47S=4'D $$Xw77	 --h8KWUUL001I9V^___001I<Yabbb)))x1ABB$ $ 2 2=BZ\t u u001IK\^fggg001IK\^fggg)))(33&$'' 6KK	q== $ 0 0D A AI#'#3#3F1Iy#I#IL ,<<T_W=UW`bjkkk<<T_W=UWcemnnn+H555Z0(""]"*P PSWS\S\]eSfSf fgggtrc  codesc                 "  K   |                                   d{V  |                     d|          }|                     |                     ||                     d{V }|                     |dg           }|                     ||di           S )a9  
        fetch deposit addresses for multiple currencies(when available)

        https://coinbase-migration.mintlify.app/coinbase-app/transfer-apis/onchain-addresses

        :param str[] [codes]: list of unified currency codes, default is None(all currencies)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.accountId]: account ID to fetch deposit addresses for
        :returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by currency code
        Nrf  F)r~  r  r  r  r  r  )r`  r  rn  r  rp  rf  s         rb  fetch_deposit_addressesz coinbase.fetch_deposit_addresses  s       !!!!!!!!!..tV<<DDT[[QXZ`EaEabbbbbbbb~~h33++D%CCCrc  )N)NN)NNF)x__name__
__module____qualname__r   r]  r   rq  r   r   rv  rt  rs  r  r  r  r   r  r   r  r  r  r   r  r  r  r  dictr
   r  r   r   r6  r;  r:  r9  r   rh  ri  rO  r	   r  r   r   r  r  r  r   r  r  r  r  r  r   r  r   r  r  r  r/  r1  r  r  floatr6  r   r   r   r5  r   rg  r  r}  r~  r  r  r  r  r  r  r  r  r  rQ  r  r  r  r  r   r  r  r   r  r  r\   r  r  r  r  r  r   r!  r%  r(  r   r\  r   r?  rG  rD  r   ro  rt  rs  r  r  r  intr  r  __classcell__)ra  s   @rb  r,   r,      sB       g# g g g g g gR ') "H "HS "H "H "H "HH +- 4 4g 4 4 4 4  .0 @1 @1DM @1 @1 @1 @1D .0 05 05DM 05 05 05 05d -/  4=    ,D
 D
 D
L >@ F
 F
 F
N F
 F
 F
 F
P 26DW[df D D3 Dc DQT D D D D( 154VZce C C# CS CPS C C C C( HLZ^mqz| M M MTW Mgj M M M M 37TX\eg A AC As ARU Alpq|l} A A A A( 04$UYbd ~ ~ ~C ~s ~imnyiz ~ ~ ~ ~( <@daenp W WS W W[^ Wuy  {F  vG W W W W :s : : : :P
 P
T P
X P
Q\ P
 P
 P
 P
d{ { {v { { { { {z *, 3 3V 3 3 3 3& -/ C C4< C C C CJ -/ M M4< M M M M^^O ^ ^ ^ ^@A A A A AF 8: +C +C +C +CZ -/ g g: g g g gR 6:" < <7 < < < < <" 9=R G Gg GG G G G GB 9=R >G >Gg >GG >G >G >G >G@ 68 : : :F : : : :& 9; 5 5C 5 5 5 58 9; % %C % % % %NA A4 A A6 A A A AF 57 ,) ,) ,) ,)\ *, f; f; f; f; f; f;P .2SW`b & &s &# &S &gklwgx & & & &P7 7 73 3 3o ot ox o; o o o ob	 24     48 	 	S 	 	 	 	 LP^bkm ! !S !X[ ! ! ! !  XZ T Tc T T T T T$ mqy{ `. `. `.I `.Y `.X] `.fi `. `. `. `.DA A Av A A A A AF	: 	: 	: 	: 	:	3S 	3 	3 	3 	3Hs H H H H 9=R - -S -# - - - - AER #1 #1tCy #1# #1 #1 #1 #1J fjx|  FH )2 )23 )2 )29 )2I )2_b )2ru )2 )2 )2 )2V 8<B ;/ ;/C ;/ ;/ ;/ ;/ ;/z 04$UXac R? R? R?C R?s R?hlmrhs R? R? R? R?h BFTXgktv D? D?3 D?c D?ad D? D? D? D?L 59tZ^gi W Wc W WTW Wnrsxny W W W W* 7;\`ik Y Y Y3 YVY Yptuzp{ Y Y Y Y* 9=4^bkm \ \# \S \X[ \ \ \ \ ?CQUdhqs BK BK BK BK3 BK^a BKx|  ~B  yC BK BK BK BKH
 
 
4 
 
 
 
, <@d[] 4? 4? 4?S 4? 4?bfglbm 4? 4? 4? 4?l 37TX\eg ?? ??C ??s ??RU ?? ?? ?? ??B @DB 1_ 1_S 1_ 1_S\ 1_ 1_ 1_ 1_f 8<B '4 '4W '4 '4 '4 '4R QU]_ \6 \63 \6 \6 \6# \6do \6 \6 \6 \6| JL H; H;S H;PTUcPd H; H; H; H;TK
 K
h K
R` K
 K
 K
 K
Z GI D, D,# D,u D,# D, D, D, D,L 8<B @, @,c @, @, @, @, @,D 57 5 5 5 5B =? !4 !4 !4 !4 !4 !4F 46    
 
 
 SW_a + +# +s +C +fp + + + +2 ]aik + +S +C + +VY +pz + + + +. >B" + +C +s +Q[ + + + +8
 
4 
x 
\d 
pz 
 
 
 
* CGr ' '3 'i 'V[ ' ' ' '6 8<B  8  8W  84PX>  8  8  8  8D 8: #5 #53 #5 #5 #5 #5JE Et EV E E E EN /1 9 9[ 9 9 9 9v HJ  3 dSVi    $,T , , , ,\"F "F "Fc "Fs "F "F "F "FHD D D  b$T RP RP RP RPh?# ?s ? ?c ?TX ?`c ? ? ? ?B >B" D D7 DQUVdQe D D D D D D D Drc  r,   )2 ccxt.async_support.base.exchanger   ccxt.abstract.coinbaser   rf  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r    r!   r"   r#   r$   r%   r&   r'   r(   ccxt.base.decimal_to_precisionr)   ccxt.base.preciser*   r,    rc  rb  <module>r     s   6 5 5 5 5 5 . . . . . .   G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) . . . . . . ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %ZND ZND ZND ZND ZNDx ZND ZND ZND ZND ZNDrc  