
    E#i7a                    4   S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJ r   S S	KJ!r!  S S
KJ"r"  S SKJ#r#  S SKJ$r$  S SKJ%r%  S SKJ&r&  S SKJ'r'  S SK(J)r)  S SK*J+r+   " S S\\5      r,g)    )Exchange)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)RateLimitExceeded)OnMaintenance)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
0 4S\\   4S jjrS rS\4S jr0 4S\4S	 jjrS
0 4S\S\S\4S jjrSLS\S\	S\4S jjrS
0 4S\S\4S jjr0 4S\S\4S jjrSLS\S\	S\4S jjrS
S
S
0 4S\S\S\4S jjrS
S
0 4S\S\S\S\\   4S jjr 0 4S\!4S jjr"SLS\	S\#4S jjr$SS
S
0 4S\S\S\S\S\\#   4
S jjr%0 4S\4S jjr&S\4S  jr'SLS!\S\	S\(4S" jjr)S
0 4S#\S\4S$ jjr*S
S
S
0 4S#\S\S\S\4S% jjr+S
S
S
0 4S\S\S\S\\(   4S& jjr,S
S
S
0 4S\S\S\S\\(   4S' jjr-S
S
S
0 4S\S\S\S\\(   4S( jjr.S
0 4S\S)\/S*\0S+\1S,\24
S- jjr3S
0 4S#\S\4S. jjr4S
0 4S\4S/ jjr50 4S0 jr6S
0 4S1\S+\1S2\S3\S\74
S4 jjr8S5 r9SLS6\S7\:S\;4S8 jjr<S
S
S
0 4S1\S\S\S\\;   4S9 jjr=S
S
S
0 4S1\S\S\S\\7   4S: jjr>S
S
S
0 4S1\S\S\S\\7   4S; jjr?S
S
S
0 4S1\S\S\S\\7   4S< jjr@S= rASLS>\S7\:S\74S? jjrB0 4S1\S\C4S@ jjrDSASB0 S
S
4SC jrES1\FSD\SE\SF\SG\SH\4SI jrGSASB0 S
S
0 4SJ jrHSKrIU =rJ$ )Mcoinbaseexchange   returnc                    > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	U R                  S
   _SS_S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 S S_S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S_S.S_S/S_S0S_E0 S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_E0 SBS_SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_E0 SSS_STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_E0 SdS_SeS_SfS_SgS_ShS_SiS_SjS_SkSl_SmS_SnS_SoS_SpS_SqS_SrS_SsS_StS_SuS_ESSSv.E_SwSxSySzS{S|S}S~._SS_SSSS.SSSS.SSSS/S._SSSSS._SS/ SQ0/ SQ/ SQ/ SQS.S._SSS0_S[
        _SSSU R                  S5      U R                  S5      S.SSSSSSSSS.SSSSSSS.S.S._SSSSS SSSS SSSSS.SSSSSSSS.S SSSSSS.SSSSS.SSSSSS.SSSSSSSS.SSSSSSSSS.SSy0S.	SS0S S S.S S S.S._SS0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSSSSSS.E0_S[        [        [        [        [        [        [        [        [        S.	[        [        [        [        [        [        [        S.S.0E5      $ )Nidr(   namezCoinbase Exchange	countriesUS	rateLimitd   	userAgentchromeproThasCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateDepositAddresscreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage	setMarginsetMarginMode)setPositionModewithdraw
timeframes<   ,  i  i  i`T  iQ )1m5m15m1h6h1dhostnamezexchange.coinbase.comurlsz0https://api-public.sandbox.exchange.coinbase.com)publicprivatezQhttps://github.com/ccxt/ccxt/assets/43336371/34a65553-88aa-4a38-a714-064bd228b97ezhttps://api.{hostname}zhttps://coinbase.com/z.https://docs.cloud.coinbase.com/exchange/docs/z#https://docs.pro.coinbase.com/#feeszIhttps://support.pro.coinbase.com/customer/en/portal/articles/2945310-fees)testlogoapiwwwdocfeesrequiredCredentials)apiKeysecretpasswordr   get)
currenciesproductszproducts/{id}zproducts/{id}/bookzproducts/{id}/candleszproducts/{id}/statszproducts/{id}/tickerzproducts/{id}/tradestimezproducts/spark-lineszproducts/volume-summary)0zaddress-bookaccountszaccounts/{id}zaccounts/{id}/holdszaccounts/{id}/ledgerzaccounts/{id}/transferszcoinbase-accountsfillsfundingr   zmargin/profile_informationzmargin/buying_powerzmargin/withdrawal_powerzmargin/withdrawal_power_allzmargin/exit_planzmargin/liquidation_historyzmargin/position_refresh_amountszmargin/statusoracleordersorders/{id}orders/client:{client_oid}z
otc/orderszpayment-methodspositionprofileszprofiles/{id}zreports/{report_id}	transfersztransfers/{transfer_id}zusers/self/exchange-limitszusers/self/hold-balanceszusers/self/trailing-volumezwithdrawals/fee-estimatezconversions/{conversion_id}conversionszconversions/feeszloans/lending-overviewzloans/lending-overview-xmzloans/loan-previewzloans/loan-preview-xmzloans/repayment-previewzloans/repayment-preview-xmzloans/interest/{loan_id}z loans/interest/history/{loan_id}zloans/interestzloans/assetsloans)r   zdeposits/coinbase-accountzdeposits/payment-methodz coinbase-accounts/{id}/addresseszfunding/repayr   zposition/closezprofiles/margin-transferzprofiles/transferreportszwithdrawals/coinbasezwithdrawals/coinbase-accountzwithdrawals/cryptozwithdrawals/payment-methodz
loans/openzloans/repay-interestzloans/repay-principal)r   r   r   )r   postdeletecommonCurrenciesCGLDCELOprecisionModer   z0.004z0.006)	tierBased
percentagemakertakerr   g333333?r)   )BCHBTCLTCETHEURUSD
   )r   r   r   deposit)tradingr   features)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   r   r   r   r      )r   r   r   daysBackCanceledr   r   r   r   r   )	sandboxrE   createOrdersrw   r   r|   r   rU   rx   extendsdefault)linearinverse)r   r7   r9   r:   optionsnetworksr   bitcoinr   ethereumSOLsolanaARBONEarbitrumAVAXC	avacchainMATICpolygonBASEbaseSUIsuiOPoptimismNEARnearAPTaptosKAVAkavaBLASTblastXLMstellarSEIseiADAcardanoCOREcoredaoalgorandosmosiscelohederazksyncstackstezoselrondlitecoincosmosfilecoinpolkadotdogecoinrippledash)ALGOOSMOr   HBARZKSYNCSTXXTZEGLDr   ATOMFILDOTDOGEXRPDASH
exceptions)	zInsufficient fundsNotFoundzInvalid API Keyzinvalid signaturezInvalid PassphrasezInvalid order idzPrivate rate limit exceededzTrading pair not availablezProduct not found)zOrder already donezorder not foundzprice too smallzprice too precisezunder maintenancezsize is too smallzCancel only mode)exactbroad)deep_extendsuperr(   describe
userAgentsr%   parse_numberr   r"   r   r!   r#   r   r$   )self	__class__s    O/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/coinbaseexchange.pyr?  coinbaseexchange.describe   sf
   &6 F H |K
$|K
'|K
 $|K
 	|K

 2|K
 4|K
  iii %i 	i
 %i %i Ui $Ui 'i i "4i ti $Ui  i 'i  t!i" 7#i$ 9%%i& &u'i( ()i* '+i, (-i. "4/i0  1i2 3i4 &u5i6 "57i8 +E9i: )%;i< #E=i> ,U?i@ $TAiB 'CiD (EiF "4GiH &uIiJ  KiL +DMiN &uOiP 'QiR (SiT #EUiV *5WiX $UYiZ u[i\ "5]i^ *5_i` +Eaib )%cid teif  gih !%iij %ekil $Umin &uoip -eqir /sit "5uiv #Ewix +Eyiz {i| !%}i~ "5i@ &uAiB +ECiD  EiF dGiH $UIiJ +EKiL %eMiN "4OiP uQiR #ESiT dUiV !$WiX tYiZ #D[i\  ]i^ '_i` $Uaib !%cid *5eif (gih %eiij )%kil )%min toip qir Tsit tuiv "5wix #Dyiz $Z{i| )%}i~ #Di@ AiB #ECiD &uEiF uGiH uIiJ UKiL  MiN $) Qi|K
b c|K
r /s|K
t PQ l67 /G9_u|K
V " $W|K
`   1d&MK!\a|K
Z ![|K
` Ya|K
b !%"&!..w7!..w7	 "'"'    #!!  !   #! c|K
Z #&*(,,0,1).+06:#'#'"&#'	( #($)$)+027/4#')$, %)&+!$$*%+*.& ',#($)*/	# ',!$#($)*/( ',!$$*%+#($)*/$ ',!$$*,-%+#($)*/	*  #ACJ y ##
 ##YP[|K
|
  E9E :E
 8E jE [E YE FE 5E *E FE  7!E$ F%E, W-E. 9/E2 53E8 99E< I=E> '%"$ ' $" % & %%%&#"GEG}
|K
L *; -':)<*=(43D2B)5
 +8'4'3)5)6)5(5M|K
 | |	    c                    U R                  U5      n0 n[        S[        U5      5       GH  nX$   nU R                  US5      nU R                  US5      nU R	                  U5      nU R                  US0 5      n	0 n
U R                  US/ 5      n[        S[        U5      5       H  nX   nU R                  US5      nU R                  U5      nUU R                  US5      UU R                  US5      S:H  SSSSS	U R                  US
5      U R                  US5      S.0U R                  US5      US.X'   M     U R                  UUUU R                  U	S5      UU R                  US5      S:H  SSSU R                  US5      U R                  U	S5      SS.U R                  U	S
5      U R                  U	S5      S.S.U
S.5      X8'   GM     U$ )a  
fetches all available currencies on an exchange

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

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
r   r,   r-   detailssupported_networksstatusonlineNr   min_withdrawal_amountmax_withdrawal_amountminmaxcontract_address)r,   r-   networkactiver   r   fee	precisionlimitscontractinfotypemax_precisionmin_size)amountr   )r,   coderX  rY  r-   rS  r   r   rT  rU  rV  r   )
publicGetCurrenciesrangelensafe_stringsafe_currency_code	safe_dict	safe_listnetwork_id_to_codesafe_numbersafe_currency_structure)rB  paramsresponseresulticurrencyr,   r-   r]  rH  r   supportedNetworksjrR  	networkIdnetworkCodes                   rD  fetch_currencies!coinbaseexchange.fetch_currencies  s    ++F3T q#h-(A{H!!(D1B##Hf5D**2.DnnXy"=GH $x9Mr R1c"345+. ,,Wd;	"55i@# ,,Wf=*"..wAXM $#!%"#'#3#3G=T#U#'#3#3G=T#U% !% 0 0:L M#!)%	 6,  77 ((&9**8X>(J !--hH  $//D#
  $//9PQ#//9PQ!	 %+9 FL= )j rF  c                    U R                  U5      n/ n[        S[        U5      5       GH,  nX$   nU R                  US5      nUR	                  S5      u  pxU R                  U5      n	U R                  U5      n
U R                  US5      nUR                  U R                  U R                  S   0 SU_SU	S-   U
-   _SU	_S	U
_S
S_SU_SU_SS_SS_SS_SU R                  US5      _SS_SS_SS_SUS:H  _SS_SS_SSSSSSU R                  US5      U R                  US5      S.SSS.SSS.SSS.U R                  US 5      SS.S!.SUS".
E5      5        GM/     U$ )#a  
retrieves data on all markets for coinbaseexchange

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

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r   r,   -rJ  r   symbol/r  quotesettleNbaseIdquoteIdsettleIdrY  r7   Tr8   margin_enabledr9   Fr:   r;   rS  rK  rW  r   base_incrementquote_increment)r\  pricerN  min_market_funds)r   r\  r  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTyperU  rV  createdrX  )publicGetProductsr_  r`  ra  splitrb  appendextendr   
safe_valuerf  )rB  rh  ri  rj  rk  marketr,   ry  rz  r  rw  rJ  s               rD  fetch_marketscoinbaseexchange.fetch_marketsE  s.    ))&1b q#h-(A[F!!&$/B hhsmOF **62D++G4E%%fh7FMM$++dii	&: 0=b0=$*u,0= 0= 	0=
 $0= &0= 70= D0= 0= 0= $//&2BC0= 0= %0= %0= 6X-0=  E!0=" $#0=$   $"&""..v7GH!--f6GH  $#!
  $#
  $#
  $//8JK#$  _0= 0 0 )v rF  c                 f    U R                  5         U R                  U5      nU R                  X!5      $ )aP  
fetch all the accounts associated with a profile

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

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
)load_marketsprivateGetAccountsparse_accountsrB  rh  ri  s      rD  fetch_accountscoinbaseexchange.fetch_accounts  s3     	**62* ""844rF  c                 r    U R                  US5      nU R                  US5      S U R                  U5      US.$ )Nrl  r,   )r,   rY  r]  rX  )ra  rb  )rB  account
currencyIds      rD  parse_accountcoinbaseexchange.parse_account  sD     %%gz:
""7D1++J7	
 	
rF  c                 X   SU0n[        S[        U5      5       H}  nX   nU R                  US5      nU R                  U5      nU R	                  5       nU R                  US5      US'   U R                  US5      US'   U R                  US5      US	'   XrU'   M     U R                  U5      $ )
NrX  r   rl  	availablefreeholdusedbalancetotal)r_  r`  ra  rb  r  safe_balance)rB  ri  rj  rk  r  r  r]  r  s           rD  parse_balancecoinbaseexchange.parse_balance  s    )q#h-(AkG))':>J**:6DllnG"..wDGFO"..w?GFO#//CGG"4L )   ((rF  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )aR  
query for balance and get the amount of funds available for trading or funds locked in orders

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

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
)r  r  r  r  s      rD  fetch_balancecoinbaseexchange.fetch_balance  s1     	**62!!(++rF  Nru  r   c                     U R                  5         U R                  U5      SS.nU R                  U R                  XC5      5      nU R	                  XQ5      nU R                  US5      US'   U$ )a  

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

fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
   )r,   levelsequencenonce)r  	market_idpublicGetProductsIdBookr  parse_order_booksafe_integer)rB  ru  r   rh  requestri  	orderbooks          rD  fetch_order_book!coinbaseexchange.fetch_order_book  sr     	
 ..(
 //G0LM  ))(;	!..xD	'rF  tickerr  c                    S nS nS nS nS nS nS n	S n
Uc  S OUS   n[        U[        5      (       a#  U R                  US5      nU R                  5       nOU R	                  U R                  US5      5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  US	S
5      nU R                  US5      n
U R                  0 SU_SU_SU R                  U5      _SU_SU_SU_SS _SU_SS _SS _SU	_SU_S
U_SS _SS _SS _SS _U
S US.EU5      $ )Nru     r   bidaskhighlowopenr  lastvolume	timestampdatetime	bidVolume	askVolumevwapclosepreviousClosechanger   average)
baseVolumequoteVolumerX  )	
isinstancelistra  milliseconds	parse8601r  safe_string_2safe_tickeriso8601)rB  r  r  r  r  r  r  r  r  r  r  ru  s               rD  parse_tickercoinbaseexchange.parse_ticker2  s   F 	 .vh/?fd####FA.D))+Itvv'FGI""651C""651C##FF3D""651C##FF3D%%fgv>D%%fh7F !
f!
!
 Y/!
 D	!

 3!
 3!
 !
 3!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ !)!
* + 	rF  symbolsc                    U R                  5         U R                  U5      n0 nU R                  U R                  X25      5      n0 n[	        UR                  5       5      nSn[        S[        U5      5       HW  nXh   n	U R                  XI/ 5      n
U R                  U
S/ 5      nU R                  U	SU5      nUS   nU R                  X5      X]'   MY     U R                  USU5      $ )a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

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

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
rt  r   Nru  )r  market_symbolspublicGetProductsSparkLinesr  r  keysr_  r`  r  safe_marketr  filter_by_array_tickers)rB  r  rh  r  ri  rj  	marketIds	delimiterrk  marketIdentryfirstr  ru  s                 rD  fetch_tickerscoinbaseexchange.fetch_tickers  s     	%%g.33DKK4PQ* )		q#i.)A |HOOH;EOOE1b1E%%hi@FH%F!..u=FN * ++FHgFFrF  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  SS5      n[	        X5      " U R                  XB5      5      nU R                  Xc5      $ )a  

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

fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
r,   fetchTickerMethodpublicGetProductsIdTicker)r  r  ra  r   getattrr  r  )rB  ru  rh  r  r  methodri  s          rD  fetch_tickercoinbaseexchange.fetch_ticker  su     	V$&,
 !!$,,0CE`a4(W)EF.   22rF  tradec                 
   U R                  U R                  USS5      5      nU R                  US5      nU R                  XBS5      nS nS nS nU R	                  US5      nUbF  US-   n	U R                  X5      nU R                  US5      n
U
b  U
S:X  a  S	OS
nU R                  X&5      nU R                  USS5      nUUS   US.nU R                  US5      nUS   S:X  a  SOSnU R                  US5      nU R                  US5      nU R                  US5      nUc  Ub  Ub  US   S:X  a  SOSnU R                  US5      nU R                  US5      nU R                  UUUUU R                  U5      US   S UUUUUUS.U5      $ )Nr   
created_at
product_idrt  rz  _value	liquidityTr   r   	fill_feesrT  rw  r  rl  ratetrade_idsidebuysellorder_idmaker_order_idtaker_order_idr  sizeru  )r,   orderrX  r  r  ru  rY  takerOrMakerr  r  r\  rT  r  )r  r  ra  r  safe_string_lower
safe_trader  )rB  r  r  r  r  feeRater  r  feeCurrencyId	costFieldr  feeCostrT  r,   r  orderIdmakerOrderIdtakerOrderIdr  r\  s                       rD  parse_tradecoinbaseexchange.parse_trade  s   . NN4#5#5eV\#RS	##E<8!!(C8..vyA$%0I##E5D((<I$+4+;w'**6@$$UK?w

 eZ0-50vu""5*5''/?@''/?@l&>\E]"6]e35&D  0!!%0"Y/X&( 
  	rF  sincec                    Uc  [        U R                  S-   5      eSnU R                  USS5      u  pTU(       a  U R                  SXX4S5      $ U R	                  5         U R                  U5      nSUS   0nUb  X7S'   Ub  U R                  U5      US	'   U R                  US
S5      nUb'  U R                  US
/5      nU R                  U5      US'   U R                  U R                  Xt5      5      n	U R                  XX#5      $ )a  

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

fetch all trades made by the user
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
: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>`
z+ fetchMyTrades() requires a symbol argumentFrw   paginater1   r  r,   r   
start_dateuntilend_date)r   r,   handle_option_and_paramsfetch_paginated_call_dynamicr  r  r  safe_value_2omitprivateGetFillsr  parse_trades)
rB  ru  r  r   rh  r
  r  r  r  ri  s
             rD  fetch_my_trades coinbaseexchange.fetch_my_trades  s    >#DGG.[$[\\88R\]44_fUZdghhV$&,
 $G$(LL$7GL!!!&':>YYvy1F"&,,u"5GJ''G(DE  5@@rF  c                     U R                  5         U R                  U5      nSUS   0nUb  X6S'   U R                  U R                  Xd5      5      nU R	                  XuX#5      $ )a  

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

get the list of most recent trades for a particular symbol
:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
r,   r   )r  r  publicGetProductsIdTradesr  r  )rB  ru  r  r   rh  r  r  ri  s           rD  fetch_tradescoinbaseexchange.fetch_tradesB  sl     	V$&,
 $G11$++g2NO   5@@rF  c                    U R                  5         U R                  U5      nU R                  US5      nU R                  US5      n0 n[        S[	        U R
                  5      5       H  nU R
                  U   nUUUUSSS.XW'   M     U$ )a=  
fetch the trading fees for multiple markets

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

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
maker_fee_ratetaker_fee_rater   T)rX  ru  r   r   r   r   )r  privateGetFeesrf  r_  r`  r  )rB  rh  ri  r   r   rj  rk  ru  s           rD  fetch_trading_fees#coinbaseexchange.fetch_trading_feesc  s     	&&v.   +;<  +;<q#dll+,A\\!_F  "!FN - rF  c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr      r  r   r     )safe_timestamprf  )rB  ohlcvr  s      rD  parse_ohlcvcoinbaseexchange.parse_ohlcv  sn     q)UA&UA&UA&UA&UA&
 	
rF  r   	timeframec           	         U R                  5         SnU R                  USSS5      u  peU(       a  U R                  SXXBUS5      $ U R                  U5      nU R	                  U R
                  U5      nSUS   0n	Ub  XS'   OX)S'   U R                  USS5      n
U R                  US/5      nUb  U R                  U5      U	S	'   Uc  SnO[        SU5      nU
co  US
-  nU R                  X;-  5      (       a+  U R                  U R                  US-
  U-  U5      5      U	S'   O;U R                  U R                  XK-  U5      5      U	S'   OU R                  U
5      U	S'   U R                  U R                  X5      5      nU R                  XX#U5      $ )a  

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

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
: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 int[][]: A list of candles ordered, open, high, low, close, volume
Frx   r
  r   r,   granularityr  endstarti  r   )r  r  "fetch_paginated_call_deterministicr  r  r   r  r  r  rO  is_round_numbersumpublicGetProductsIdCandlesr  parse_ohlcvs)rB  ru  r'  r  r   rh  r
  r  parsedTimeframer  r  parsedTimeframeMillisecondsri  s                rD  fetch_ohlcvcoinbaseexchange.fetch_ohlcv  s    	88z[`a::<X]jpruvvV$++DOOYG&,
 &%4M"%.M"!!&'596G9-#||E2GG}C}.=.D+''(KLL%)\\$((EAIId;dfk2l%mGEN%)\\$((5;^`e2f%gGEN!%e!4224;;w3OP   9UKKrF  c                 H    U R                  U5      nU R                  US5      $ )z
fetches the current integer timestamp in milliseconds from the exchange server
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
epoch)publicGetTimer#  r  s      rD  
fetch_timecoinbaseexchange.fetch_time  s)     %%f- ""8W55rF  rJ  c                 8    SSSSSSS.nU R                  X!U5      $ )Nr  closedcanceled)pendingrS  r  doner<  	cancelingra  )rB  rJ  statusess      rD  parse_order_status#coinbaseexchange.parse_order_status  s0    "
 &99rF  r  c                    U R                  U R                  US5      5      nU R                  US5      nU R                  XBS5      nU R                  U R                  US5      5      nU R                  US5      nUS:X  a  US:X  a  SnU R                  US5      nU R                  US	5      nU R                  US
U5      n	U R                  US5      n
U R	                  US5      nS nUb	  UUS   S S.nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  US5      nU R                  US5      nU R                  0 SU_SU_SU_SU_SU R                  U5      _SS _SU_SUS   _SU_SU_SU_SU_SU_SU_SU
_S U	_S!U_S US S S".EU5      $ )#Nr  r  rt  rJ  done_reasonr;  r<  r  filled_sizer  executed_valuer  rw  r  r,   rY  r  time_in_force	post_only
stop_price
client_oidclientOrderIdrX  r  r  lastTradeTimestampru  r   postOnlyr   r  r\  filled)	remainingrT  r  trades)r  ra  r  rB  rf  r  
safe_orderr  )rB  r  r  r  r  rJ  
doneReasonr  rO  r\  r  r  rT  r,   rY  r  r   rN  r   rL  s                       rD  parse_ordercoinbaseexchange.parse_order  s   , NN4#3#3E<#HI	##E<8!!(C8(()9)9%)JK%%e];
hZ:%=F  0!!%7!!%8'78""5+6"7OC
 eT*v.v.&&uo>??5+6''|<((=  
" 
] 
 E 
 	 

 Y/ 
 !$ 
 f 
 fX& 
 D 
 ; 
  
 D 
 U 
 L 
 D 
  f! 
" f# 
$ + 
, - 	rF  r,   c                     U R                  5         0 nU R                  USS5      nSnUc  SnXS'   OSnXTS'   U R                  USS/5      n[        X5      " U R	                  XC5      5      nU R                  U5      $ )av  

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

fetches information on an order made by the user
:param str id: the order id
:param str symbol: not used by coinbaseexchange fetchOrder
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rL  rK  NprivateGetOrdersIdr,   privateGetOrdersClientClientOid)r  r  r  r  r  rT  )rB  r,   ru  rh  r  rL  r  ri  s           rD  fetch_ordercoinbaseexchange.fetch_order2  s     	**6?LQ )FDM6F$1L!YYv'FGF4(W)EF))rF  c                     U R                  5         SnUb  U R                  U5      nSU0nU R                  U R                  Xu5      5      nU R	                  XX45      $ )a  
fetch all the trades made from a single order
:param str id: order id
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nr  )r  r  r  r  r  )	rB  r,   ru  r  r   rh  r  r  ri  s	            rD  fetch_order_trades#coinbaseexchange.fetch_order_tradesK  sc     	[[(F
 ''G(DE  5@@rF  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )aN  

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

fetches information on multiple orders made by the user
:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch open orders for
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rJ  allfetch_open_ordersr  rB  ru  r  r   rh  r  s         rD  fetch_orderscoinbaseexchange.fetch_orders_  s.     e
 %%fUKK<XYYrF  c                    U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4S5      $ 0 nSnUb  U R                  U5      nUS   US'   Ub  X6S'   Ub  U R	                  U5      US	'   U R                  US
S5      nUb'  U R                  US
/5      nU R	                  U5      US'   U R                  U R                  Xd5      5      n	U R                  XX#5      $ )a  

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

fetch all unfilled currently open orders
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of  open orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch open orders 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>`
Fr|   r
  r1   Nr,   r  r   r  r  r  )
r  r  r  r  r  r  r  privateGetOrdersr  parse_orders)
rB  ru  r  r   rh  r
  r  r  r  ri  s
             rD  ra  "coinbaseexchange.fetch_open_ordersq  s	    	88ART^_445FW\fijj[[(F$*4LGL!$G$(LL$7GL!!!&':>YYvy1F"&,,u"5GJ((W)EF  5@@rF  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )aU  

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

fetches information on multiple closed orders made by the user
:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch open orders for
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rJ  r>  r`  rb  s         rD  fetch_closed_orders$coinbaseexchange.fetch_closed_orders  s.     f
 %%fUKK<XYYrF  rY  r  r\  r  c                    U R                  5         U R                  U5      nUUUS   S.nU R                  USS5      n	U	b  XS'   U R                  U/ SQ5      n
U
b  U R	                  X5      US'   U R                  USS5      nUb  XS'   U R                  US	S
S5      nU(       a  SUS
'   U R                  U/ SQ5      nUS:X  a)  U R	                  X5      US'   U R                  X5      US'   OdUS:X  a^  U R                  USS5      nUc  Ub  XE-  nOU R                  USS/5      nUb  U R                  X5      US'   OU R                  X5      US'   U R                  U R                  X5      5      nU R                  X5      $ )ag  

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

create a trade order
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r,   )rY  r  r  rL  rK  )	stopPricerJ  r   rJ  r   rH  rN  rI  FT)	r   rH  rm  rJ  rL  rK  rN  rI  r   r   r  r  r  r  funds)r  r  r  safe_number_nprice_to_precisionr  r  amount_to_precisionsafe_number_2cost_to_precisionprivatePostOrdersr  rT  )rB  ru  rY  r  r\  r  rh  r  r  rL  r   r   rN  r  ri  s                  rD  create_ordercoinbaseexchange.create_order  s    	V$  ,
( **6?LQ$$1L!))&2]^#$($;$;F$QGL!((P"'2O$$$VZeL#'GK 6  $g  h7?#66vEGG"66vFGFOX%%ffg>D|$!>D6FG+<=#'#9#9&#G "&":":6"J))$++g*FG( 11rF  c                 :   U R                  5         0 nU R                  USS5      nSnUc  SnXS'   OSnXTS'   U R                  USS/5      nSnUb  U R                  U5      nUS   US'   [	        X5      " U R                  XC5      5      nU R                  S	U05      $ )
ae  

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

cancels an open order
:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rL  rK  NprivateDeleteOrdersIdr,   "privateDeleteOrdersClientClientOidru  r  rX  )r  r  r  r  r  r  rR  )	rB  r,   ru  rh  r  rL  r  r  ri  s	            rD  cancel_ordercoinbaseexchange.cancel_order  s     	
 **6?LQ ,FDM9F$1L!YYv'FGF[[(F$*8$4GL!4(W)EF122rF  c                     U R                  5         0 nSnUb  U R                  U5      nUS   US'   U R                  U R                  X25      5      nU R	                  SU05      /$ )a  

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

cancel all open orders
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nru  r  rX  )r  r  privateDeleteOrdersr  rR  )rB  ru  rh  r  r  ri  s         rD  cancel_all_orders"coinbaseexchange.cancel_all_orders  sm     	[[(F$*8$4GL!++DKK,HI 2344rF  c                 $    U R                  U5      $ N)privateGetPaymentMethods)rB  rh  s     rD  fetch_payment_methods&coinbaseexchange.fetch_payment_methods-  s    ,,V44rF  r]  addresstagc                    U R                  XE5      u  pEU R                  U5        U R                  5         U R                  U5      nUS   US.nSnSU;   a  US-  nOSU;   a  US-  nOUS-  nX7S	'   Ub  XGS
'   [	        X5      " U R                  Xu5      5      n	U	(       d*  [        U R                  S-   U R                  U	5      -   5      eU R                  X5      $ )a  
make a withdrawal

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod
https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawcoinbaseaccount

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag:
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
r,   )rl  r\  privatePostWithdrawalspayment_method_idPaymentMethodcoinbase_account_idCoinbaseAccountCryptocrypto_addressdestination_tagz withdraw() error: )
handle_withdraw_tag_and_paramscheck_addressr  rl  r  r  r   r,   jsonparse_transaction)
rB  r]  r\  r  r  rh  rl  r  r  ri  s
             rD  r   coinbaseexchange.withdraw0  s     99#F7#==& 
 *&(o%F"f,''FhF(/$%-0)*4(W)EF*? ?$))HBU UVV%%h99rF  c                 6    SSSSSS.nU R                  X!U5      $ )Ntransferr  rT  rebate)r  matchrT  r  
conversionr@  )rB  rY  typess      rD  parse_ledger_entry_type(coinbaseexchange.parse_ledger_entry_typeU  s-    "!
 T22rF  itemrl  c                 P   U R                  US5      nU R                  US5      nS nU R                  US5      n[        R                  " Xd5      n[        R                  " US5      (       a  Sn[        R                  " U5      nOSnU R                  U5      nU R                  U5      n	U R                  U5      n
U R                  U R                  US5      5      nU R                  U R                  US5      5      nU R                  S U5      nU R                  US	0 5      nS nS nS nUS
:X  a7  U R                  US5      nU R                  US5      nU R                  US5      nOU R                  US5      nSnU R                  UUUU R                  U5      UUUUUUUU
U	US S.U5      $ )Nr,   r\  r  0outinr  rY  rH  r  fromtoprofile_transfer_idr  ok)rX  r,   r  r  	directionr  referenceAccountreferenceIdrY  rl  r\  beforeafterrJ  rT  )ra  r&   
string_sub	string_lt
string_absrA  r  r  r  rb  safe_ledger_entryr  )rB  r  rl  r,   amountStringr  afterStringbeforeStringr\  r  r  r  rY  r]  rH  r  r  r  rJ  s                      rD  parse_ledger_entry#coinbaseexchange.parse_ledger_entry_  s   2 dD)''h7	&&tY7))+D\3//I"--l;LI""<0!!+.""<0NN4??4#FG	++D,<,<T6,JK&&tX6//$	26:&&w7G#//>**74IJK**7J?K%%"Y/" 0&'
  ! 	rF  c                    Uc  [        U R                  S-   5      eU R                  5         U R                  5         U R	                  U5      nU R                  U R                  S5      nU R                  Xa5      nUc  [        U R                  S-   U-   5      eSUS   0nUb  U R                  U5      US'   Ub  X8S'   U R                  USS5      n	U	b'  U R                  US/5      nU R                  U	5      US'   U R                  U R                  X5      5      n
[        S	[        U
5      5       H
  nXU   S
'   M     U R!                  XX#5      $ )ar  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

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

: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 int [params.until]: the latest time in ms to fetch trades for
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
z$ fetchLedger() requires a code paramr]  z- fetchLedger() could not find account id for r,   r  r   r  r  r   rl  )r   r,   r  load_accountsrl  index_byr   r  r   r  r  r  privateGetAccountsIdLedgerr  r_  r`  parse_ledger)rB  r]  r  r   rh  rl  accountsByCurrencyCoder  r  r  ri  rk  s               rD  fetch_ledgercoinbaseexchange.fetch_ledger  sM    <#DGG.T$TUU==&!%t}}f!E//"8??*Y Y\` `aa'$-
 $(LL$7GL!$G!!&':>YYvy1F"&,,u"5GJ224;;w3OPq#h-(A&*QK
# )  UBBrF  c                    U R                  5         U R                  5         SnU R                  US5      nUcd  Uba  U R                  U5      nU R	                  U R
                  S5      nU R                  Xq5      nUc  [        U R                  S-   U-   5      eUS   n0 n	Ub  XiS'   Ub  X9S'   Sn
Uc  U R                  U R                  X5      5      n
[        S[        U
5      5       HL  nU R                  X   S5      nU R                  U R                  U5      nU R                  US5      nXU   S'   MN     OCU R                  U R                  X5      5      n
[        S[        U
5      5       H
  nXU   S'   M     U R                  XX#5      $ )	a  
fetch history of deposits and withdrawals

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

:param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
:param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
:param int [limit]: max number of deposit/withdrawals to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.id]: account id, when defined, the endpoint used is '/accounts/{account_id}/transfers/' instead of '/transfers/'
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr,   r]  z: fetchDepositsWithdrawals() could not find account id for r   r   
account_idrl  )r  r  ra  rl  r  r   r  r   r,   privateGetTransfersr  r_  r`  accountsByIdprivateGetAccountsIdTransfersparse_transactions)rB  r]  r  r   rh  rl  r,   r  r  r  ri  rk  r  	codeInners                 rD  fetch_deposits_withdrawals+coinbaseexchange.fetch_deposits_withdrawals  s    	fd+:==.)-t}}f)M&//*@G?'2n(nqu(uvvT]>DM$G://G0LMH: 1c(m,!--hk<H
//$*;*;ZH ,,Wf=	*3J'	 - 99$++g:VWH6 1c(m,*.J' -&&x5HHrF  c           	      J    U R                  XX0R                  SS0U5      5      $ )a8  
fetch all deposits made to an account

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

: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
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
rY  r   r  r  rB  r]  r  r   rh  s        rD  fetch_depositscoinbaseexchange.fetch_deposits5  s*     ..tE;;PVXaObdjCkllrF  c           	      J    U R                  XX0R                  SS0U5      5      $ )aC  
fetch all withdrawals made from an account

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

: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
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
rY  r   r  r  s        rD  fetch_withdrawals"coinbaseexchange.fetch_withdrawalsD  s*     ..tE;;PVXbOcekClmmrF  c                     U R                  US5      nU(       a  gU R                  US5      nU R                  US5      nU(       a  gU(       a  U(       d  gg)Ncanceled_atr<  processed_atcompleted_atr  failedr=  )r  )rB  transactionr<  	processed	completeds        rD  parse_transaction_status)coinbaseexchange.parse_transaction_statusS  sI    ??;>OOK@	OOK@	yrF  r  c                 ~   U R                  US0 5      nU R                  U R                  US5      5      nU R                  US5      nU R                  XR5      nU R	                  US5      nU R                  US5      nU R                  US5      n	U R                  USU	5      n	S S S S.n
US:X  a9  S	nU R                  US
U	5      n	U R	                  US5      nUb  Ub  X{-  nXS'   XjS'   U R                  US5      n0 SU_SU R                  US5      _SU R                  US5      _SU_SU_SU R                  U5      _SU_SU R                  U5      _SU_SU R                  U5      _SU	_SS _SU R                  US5      _SU R                  US5      _SS _SS _SU R                  U R                  US5      5      _S SU
S.E$ ) NrH  r  rl  r\  rY  r  )rl  r  r  r   
withdrawalsent_to_addressrT  r  rR  rX  r,   txidcrypto_transaction_hashrJ  r  r  r  addressFrom	addressTor  r  tagFromtagToupdatedr  F)commentinternalrT  )r  r  ra  rb  rf  re  r  r  )rB  r  rl  rH  r  r  r]  r\  rY  r  rT  r  ro  s                rD  r  "coinbaseexchange.parse_transaction`  sg   > //+y"=NN4#3#3K#NO	%%k:>
&&z<!!+x8V4""7,<="";0@'J

 :D&&w0A7KG&&w6G"%%F%F"&J$$Wi8	
K
$"";5
 D$$W.GH
 D	

 
 t..y9
 f
 d33K@
 
 Y/
 w
 4
 ))'3CD
 4##G->?
 t
  T!
" t~~d&6&6{N&ST#
$ )
 	
rF  c                 V   U R                  5         U R                  U5      nU R                  U R                  S5      nUc=  U R	                  5       nX@R                  S'   U R                  US5      U R                  S'   US   nU R                  U R                  S   U5      nUc$  [        U R                  S-   U-   S-   U-   S-   5      eSUS   0nU R                  U R                  Xr5      5      nU R                  US	5      n	U R                  US
5      n
UU R                  U	5      SU
US.$ )aw  
create a currency deposit address

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

: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>`
coinbaseAccountsNrl  coinbaseAccountsByCurrencyIdr,   z5 createDepositAddress() could not find currency code z with id = z0 in self.options['coinbaseAccountsByCurrencyId']r  r  )rl  r  rR  r  rX  )r  rl  r  r   privateGetCoinbaseAccountsr  r    r,   &privatePostCoinbaseAccountsIdAddressesr  ra  r  )rB  r]  rh  rl  r   r  r  r  ri  r  r  s              rD  create_deposit_address'coinbaseexchange.create_deposit_address  sM    	==&??4<<1CD668H/7LL+,;?==S];^DLL78d^
//$,,/M"NPZ[? +b!bei!ily!y  }G  "G  J|  "|  }  }'$-
 >>t{{7?[\""8Y7x):;))'2
 	
rF  r   GETc                    SU R                  X5      -   nU R                  X@R                  U5      5      nUS:X  a  U(       a  USU R                  U5      -   -  nU R	                  U R
                  S   U   5      U-   n	US:X  a  U R                  5         [        U R                  5       5      n
SnUS:w  a  U(       a  U R                  U5      nUnX-   U-   U-   nS n U R                  U R                  5      nU R                  U R!                  U5      U["        R$                  S5      nU R&                  UU
U R(                  S	S
.nXXeS.$ ! [         a  n[        U R                  S-   5      eS nAff = f)Nrv  r  ?r   r    z sign() invalid base64 secretbase64zapplication/json)zCB-ACCESS-KEYzCB-ACCESS-SIGNzCB-ACCESS-TIMESTAMPzCB-ACCESS-PASSPHRASEzContent-Type)urlr  bodyheaders)implode_paramsr  extract_params	urlencodeimplode_hostnamer   check_required_credentialsstrr  r  base64_to_binaryr   	Exceptionr   r,   hmacencodehashlibsha256r   r   )rB  pathr   r  rh  r  r  r  queryr  r  payloadwhatr   e	signatures                   rD  signcoinbaseexchange.sign  sb   ++D99		&"5"5d";<U?3!666##DIIe$4S$9:WD)++-

%EG99U+D"G>G+g5DFU..t{{; 		$++d"3VW^^XVI!%"+',(, 2G dOO  U)$''4S*STTUs   E 
E/E**E/reasonr  r  r  r  c
                 >   US:X  d  US:X  a  US   S:X  am  U R                  US5      n
U R                  S-   U
-   nU R                  U R                  S   X5        U R	                  U R                  S   X5        [        U5      e[        U R                  S-   U-   5      eg )	Ni  i  r   {message r;  r<  )ra  r,   throw_exactly_matched_exceptionr9  throw_broadly_matched_exceptionr   )rB  r]  r  r  r  r  r  ri  requestHeadersrequestBodyr
  feedbacks               rD  handle_errorscoinbaseexchange.handle_errors  s    CKTS[Aw#~**8Y?77S=7244T__W5Mwa44T__W5Mwa#H--# 455rF  c           	          U R                  XX4XVU5      n[        U[        5      (       d0  SU;   a*  [        U R                  S-   U R                  U5      -   5      eU$ )Nr
  r  )fetch2r  r  r   r,   r  )	rB  r  r   r  rh  r  r  configri  s	            rD  r  coinbaseexchange.request  sQ    ;;t&'P(C((H$#DGGcMDIIh4G$GHHrF   r  )K__name__
__module____qualname____firstlineno__r   r?  r   rq  r   r   r  r   r  r  r   r  r  r  r   r   r  dictr   r  r   r   r  r  r   r  r   r  r  r   r  r  r%  r3  r8  rB  r   rT  rY  r\  rc  ra  rj  r   r   floatr   ru  rz  r~  r  r   r   r  r	   r   r  r  r  r  r  r  r  r
   r  r  intr  r  __static_attributes____classcell__)rC  s   @rD  r(   r(      sm   }# }~ ') iZ iV $& v$v, vp %' 54= 5B
&) ) $& ,( , :>b %s %3 %Y %NM4 M M6 M^ 04B ,GW ,G7 ,G\ 02 (33 (3f (3TC Cv C CJ -1tRV_a "Ac "A "AC "AH 6:UW A3 As A# A\`af\g AB )+ { B
 
4 
( 9=4^bkm 6L# 6L# 6LS 6LX[ 6Lrvw{r| 6Lp !# 6s 6	: 	:F Fv F FP 26b *c *3 *2 9=4^bkm AS A# AS AX[ A( *.Dt\^ Z3 Zc Z Zcghmcn Z$ /3TXac !A !A3 !Ac !Ahlmrhs !AF 154VZce Z# ZS ZPS Zjnotju Z$ gksu S23 S2i S2y S2RW S2`c S2j 37r 3s 3C 3> /32 5 5& ,. 5 KOWY #:S #:% #:# #:C #:^i #:J3Dt Dx D; DL (,$TZ\ +C +CC +Cs +Caefqar +CZ 6:[_hj aIs aI# aIUX aIost  pA aIF *.Dt\^ m3 mc m mcghsct m -1tRV_a nc n nC nfjkvfw nK
T K
X K
Q\ K
Z 8: "
3 "
n "
H &eBSW P>	# 	s 	 	c 	TX 	`c 	 !)r4VZce  rF  r(   )-ccxt.base.exchanger   ccxt.abstract.coinbaseexchanger   r  ccxt.base.typesr   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$   ccxt.base.decimal_to_precisionr%   ccxt.base.preciser&   r(   r  rF  rD  <module>r(     sk    ( 6  `  `  `  `  `  `  * 0 - . . + ) * . * 4 %gx grF  