
    i}V                       d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlm Z  d dl!m"Z" d dl#m$Z$  G d dee          Z%dS )    )Exchange)ImplicitAPIN)Balances
CurrenciesCurrencyIntMarketOrder	OrderSide	OrderTypePositionStrStringsTickerTickersTradeTransactionTransferEntry)List)Any)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InvalidOrder)DuplicateOrderId)	TICK_SIZE)Precisec                       e Zd Z fdZi fdefdZdedefdZi fdZd Zdddi fd	e	d
e
de
fdZdDdefdZdDdefdZi fdefdZd Zi fdZi fdZi fdZ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i fd	efdZdDdefdZdi f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  Z!dDd!e"defd"Z#dDdede$fd#Z%i fdee         fd$Z&defd%Z'i fde(fd&Z)d' Z*di fdede+fd(Z,i fd	ede-fd)Z.dDd*e/dede-fd+Z0i fde1fd,Z2de1fd-Z3i fdeded.ed/ede4f
d0Z5di fd	ed1e6d2e7ded3ef
d4Z8dDdede9fd5Z:d6 Z;d7 Z<di fd8ed	e	fd9Z=di fd	efd:Z>ddi fd8ed	ed1e6d2e7ded3efd;Z?di fd8ed	e	fd<Z@dddi fd	e	d
e
de
dee9         fd=ZAdddi fd	e	d
e
de
fd>ZBdi fdedefd?ZCd@ ZDg dAi ddfdBZEdC ZF xZGS )Ecoinbaseinternationalc                 
   |                      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 dHddIddJddKddLddMddNddOddPddQddRddSddTddUddVddWddXddddddddddddddYdZd[d\d]id\d^id_d`gdagdbdcddddddedfddgg dhig dig djdkdlgdmdkgdndoidpdq|                     dr          |                     ds          dd|                     dt          |                     dr          g|                     du          |                     dr          g|                     dv          |                     dw          g|                     dx          |                     dw          g|                     dy          |                     dz          g|                     d{          |                     d|          gg|                     dt          |                     ds          g|                     du          |                     d}          g|                     dv          |                     d~          g|                     dx          |                     d          g|                     dy          |                     d          g|                     d{          |                     dt          ggddidt          di t          t          t          t          t          t          t          t          t          t          d
ddddddddddddddbddidddddddddi          S )Nidr!   namezCoinbase International	countriesUS	certifiedTpro	rateLimitd   versionv1	userAgentchromeheadersz
CB-VERSIONz
2018-05-30hasCORSspotmarginswapfutureoptionF	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateLimitBuyOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrdercreateMarketSellOrderWithCostcreateOrdercreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL2OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyBuysfetchMySellsfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTicker)fetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchWithdrawalsreduceMarginsetLeverage	setMarginsetMarginModesetPositionModewithdrawurlszQhttps://github.com/ccxt/ccxt/assets/43336371/866ae638-6ab5-4ebf-ab2c-cdcce9545625restz*https://api.international.coinbase.com/apiz!https://api-n5e1.coinbase.com/apiz"https://international.coinbase.comz)https://docs.cloud.coinbase.com/intx/docszlhttps://help.coinbase.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees )logoapitestwwwdocfeesreferralrequiredCredentials)apiKeysecretpasswordr   get)assetszassets/{assets}zassets/{asset}/networksinstrumentszinstruments/{instrument}zinstruments/{instrument}/quotez instruments/{instrument}/fundingr   )ordersorders/{id}
portfoliosportfolios/{portfolio}zportfolios/{portfolio}/detailzportfolios/{portfolio}/summaryzportfolios/{portfolio}/balancesz'portfolios/{portfolio}/balances/{asset}z portfolios/{portfolio}/positionsz-portfolios/{portfolio}/positions/{instrument}zportfolios/fillszportfolios/{portfolio}/fills	transfersztransfers/{transfer_uuid})	r   r   zportfolios/marginzportfolios/transferztransfers/withdrawztransfers/addressz transfers/create-counterparty-idz"transfers/validate-counterparty-idztransfers/withdraw/counterpartyr   r   r   )r   postputdelete)publicprivater   tradingz0.004z0.002010000005000000z0.00351000000050000000z0.003	250000000z0.0025z0.0016z0.001z0.0008z0.0005)takermaker)r   r   	tierBased
percentagetiersprecisionMode
exceptions)
DUPLICATE_CLIENT_ORDER_IDzOrder rejectedzmarket orders must be IoCztif is requiredzInvalid replace order requestUnauthorizedzinvalid result_limitzis a required fieldz	Not Foundzip not allowed)exactbroad
timeframes
ONE_MINUTEFIVE_MINUTEFIFTEEN_MINUTETHIRTY_MINUTEONE_HOURTWO_HOURSIX_HOURONE_DAY)1m5m15m30m1h2h6h1doptionsnfqkvdjpmethodv1PrivatePostTransfersWithdrawETHARBITRUMAVAXOPTIMISMMATICSOLBTC)ethereumarbitrum	avacchainoptimismpolygonsolanabitcoin)brokerId	portfolior   networksById)deep_extendsuperr!   describe
userAgentsparse_numberr   r   r   r   r   r   )self	__class__s    n/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/coinbaseinternational.pyr   zcoinbaseinternational.describe   s   &;T B B K K M M mP
)mP
,mP
 $mP
 	mP

 4mP
 mP
 tmP
 2mP
 lmP
  QQQ $Q 	Q
 $Q %Q UQ "4Q tQ Q $UQ  Q 'Q &tQ 'Q  '!Q" /#Q Q$ ,U%Q& ('Q( 0)Q* t+Q, &t-Q. (/Q0 '1Q2 (3Q4 "45Q6 T7Q8  9Q: ;Q<  =Q> +E?Q@ )%AQB &uCQD $UEQ Q QF 'GQH (IQJ "4KQL  MQN &uOQP #EQQR *4SQT $UUQV "5WQX *5YQZ +E[Q\ #E]Q^ u_Q`  aQb %ecQd /eQf "5gQ Q Qh iQj !%kQl tmQn oQp  qQr esQt +EuQv "4wQx dyQz !%{Q| u}Q~  Q@ $UAQB !$CQD %eEQF )%GQH tIQ QJ !%"$#($)$( %$!!&#( aQ Q QmP
| kH ? <? C  }mP
^ " $ $_mP
h  	  	  	       
! 
! 
! *4 
 %)#A$  $ 2 24imP
R !..w77!..w77!%"& "..s33T5F5Fw5O5OP!..y994;L;LW;U;UV!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..z::D<M<Mg<V<VW!..{;;T=N=Nx=X=XY" "..s33T5F5Fw5O5OP!..y994;L;LX;V;VW!..y994;L;LW;U;UV!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX!..{;;T=N=Ns=S=ST"  SmP
F YGmP
H 1A&21='35A$4,6+5!+&9  ImP
f "#'&   	 	gmP
z &> !& *!' *&#$! ! {mP
 mP
 m m m	    
methodNamec                   K   d }|                      ||d          \  }}|
|dk    r||gS |                     | j        d          }|
|dk    r||gS |                                  d {V }t	          dt          |                    D ]]}||         }|                     |di           }|                     |d          r&|                     |d          }	|	| j        d<   |	|gc S ^t          | j	        dz   |z   dz             )	Nr   r   r   info
is_defaultportfolio_id z]() requires a portfolio parameter or set the default portfolio with self.options["portfolio"])
handle_option_and_paramssafe_stringr   fetch_accountsrangelen	safe_dict	safe_boolr   r#   )
r   r   paramsr   defaultPortfolioaccountsiaccountr   portfolioIds
             r   handle_portfolio_and_paramsz1coinbaseinternational.handle_portfolio_and_params	  sQ     	 99&*kZZ	6!	Rv&&++DL+FF(/?2/E/E$f--,,........q#h--(( 	- 	-AqkG>>'6266D~~dL11 -"..t^DD,7[)#V,,,,-  #
 :  >]  !]  ^  ^  	^r   currencyCodec                   K   d }|                      ||d          \  }}||                     |           d {V  | j        |         d         }|                     |dd          }|P|                     |          rt          | j        dz   |z   dz             |                     |          }|d         }n|                     ||          }||gS )Nnetwork_arn_idnetworksnetworkCodenetworkz5 createDepositAddress network not found for currency z# please specify networkId in paramsr#   )	r   load_currency_networks
currenciessafe_string_2is_emptyr   r#   find_default_networknetwork_code_to_id)r   r   r   r   	networkIdr   r   defaultNetworks           r   handle_network_id_and_paramsz2coinbaseinternational.handle_network_id_and_params  s     	 99&*N^__	6--l;;;;;;;;;|4Z@H((	JJG==** _$TW/f%fiu%u  y^  &^  _  _  _!%!:!:8!D!D*40		 33G\JJ	6""r   c                    K   |                                   d{V  |                     |           d{V }|                     ||          S )aj  
        fetch all the accounts associated with a profile
        :see: https://docs.cloud.coinbase.com/intx/reference/getportfolios
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
        N)load_marketsv1PrivateGetPortfoliosparse_accountsr   r   responses      r   r   z$coinbaseinternational.fetch_accounts,  si       !!!!!!!!!44V<<<<<<<<$ ""8V444r   c                 :    |                      |dd          d d |dS )Nr   portfolio_uuid)r#   typecoder   )r   )r   r   s     r   parse_accountz#coinbaseinternational.parse_accountH  s2    " $$Wn>NOO	
 
 	
r   Nsymbolsincelimitc           	        K   |t          | j        dz             |                                  d{V  d}|                     |dd          \  }}d}|                     |ddd          \  }}d}|r!|                     d||||||           d{V S |                     |          }|                     ||d	          d	z
  }	|d
         |                     |dd|	|z            d}
|||
d<   |                     | 	                    |
|                     d{V }| 
                    |dg           }|                     ||||          S )a  
        fetches historical funding rate prices
        :see: https://docs.cloud.coinbase.com/intx/reference/getinstrumentfunding
        :param str symbol: unified symbol of the market to fetch the funding rate history for
        :param int [since]: timestamp in ms of the earliest funding rate to fetch
        :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        Nz5 fetchFundingRateHistory() requires a symbol argumentFrY   paginatemaxEntriesPerRequestr*   ccxtPageKey   r#   offsetresult_offset)
instrumentr  result_limitresults)r   r#   r  r    fetch_paginated_call_incrementalmarketsafe_integersafe_integer_2'v1PublicGetInstrumentsInstrumentFundingextend	safe_listparse_funding_rate_histories)r   r  r  r  r   r  r  pageKeyr  pagerequestr  rawRatess                r   fetch_funding_rate_historyz0coinbaseinternational.fetch_funding_rate_history_  s      >#DG.e$efff!!!!!!!!!88AZ\fgg&#'+'D'DVMfh~  AD  (E  (E$f 	W>>?XZ`bginpvx  BV  W  W  W  W  W  W  W  W  WV$$  !44q8 ,!00?TX[oTopp
 
 &+GN#EEdkkRY[aFbFbcccccccc$ >>(Ir::0065%PPPr   r  c                 .    |                      ||          S N)parse_funding_rate)r   r   r  s      r   parse_funding_rate_historyz0coinbaseinternational.parse_funding_rate_history  s    &&tV444r   c                 ^   |                      |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 )N
event_timetimer   r  	markPrice
mark_price
indexPriceinterestRateestimatedSettlePrice	timestampdatetimefundingRatefunding_ratefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)r   safe_symbolsafe_number	parse8601)r   contractr  r6  s       r   r'  z(coinbaseinternational.parse_funding_rate  s5    ,,X|VLL
H
d&&tV44
 ))(LAA
 $	

 D
 #D
 88
 
 4++HnEE
  ? ?
 
 t
 #D
 "4
 "4
  '!
" &t#
 	
r   r	  c                 &  K   |                                   d{V  d}|                     |ddd          \  }}d}|                     d|           d{V \  }}d|i}|dk    rG|                     |          }|d         |d<   d}|                     |d|           d{V \  }}||d<    t          | |          |                     ||                     d{V }|                     |d	          }	|                     |d
d          }
||	|
|dS )a  
        create a currency deposit address
        :see: https://docs.cloud.coinbase.com/intx/reference/createaddress
        :see: https://docs.cloud.coinbase.com/intx/reference/createcounterpartyid
        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network_arn_id]: Identifies the blockchain network(e.g., networks/ethereum-mainnet/assets/313ef8a9-ae5a-5f2f-8a56-572c0e2a4d5a) if not provided will pick default
        :param str [params.network]: unified network code to identify the blockchain network
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr=   r   v1PrivatePostTransfersAddressr   r#   assetr   destination_tagaddresscounterparty_id)currencytagrE  r   )	r  r   r   rG  r   getattrr  r   r   )r   r	  r   r   r   r"  rG  r   r  rH  rE  s              r   create_deposit_addressz,coinbaseinternational.create_deposit_address  s      !!!!!!!!!66v?UW_  bA  B  B	"&"B"BCY[a"b"bbbbbbb	6
 444}}T**H'~GGI&*&G&GNdfl&m&m m m m m m mIv(1G$%.v..t{{7F/K/KLLLLLLLL x):;;$$Xy:KLL	
 
 	
r   c                     |                      |          }t          dt          |                    D ]5}||         d         }|                     |dd          }|du r
||         c S 6|d         S )Nr   r   r   FT)to_arrayr   r   r   )r   r   networksArrayr   r   r   s         r   r   z*coinbaseinternational.find_default_network  s    h//q#m,,-- 	( 	(A #F+DlEBBJT!!$Q'''' "Qr   c                    K   |                      |          }|                     |d          }|d S d|d         i}|                     |           d {V }d S )Nr   rC  r#   )rG  r   v1PublicGetAssetsAssetNetworks)r   r	  r   rG  r   r"  rawNetworkss          r   r   z,coinbaseinternational.load_currency_networks  sp      ==&&>>(J77FXd^
 !??HHHHHHHHr   c                     i }t          dt          |                    D ]<}|                     |                     ||                   |          }|||d         <   =|S )Nr   r   )r   r   r  parse_network)r   r   r   resultr   r   s         r   parse_networksz$coinbaseinternational.parse_networks  sb    q#h--(( 	1 	1Akk$"4"4Xa["A"A6JJG)0F79%&&r   c                    |                      |d          }|                     |          }|                      |d          }|                     |||                      |d          |                     |                     |g dd          |          d d d d d |                     |d          |                     |d          dd d dd	d

          S )N
asset_namer   display_name)network_namerW  r   r   min_withdrawal_amtmax_withdrawal_amtminmaxr   deposit)
r   r#   r$   r   activer_  r   	precisionfeelimits)r   safe_currency_codesafe_networknetwork_id_to_codesafe_string_nr>  )r   r   r   
currencyIdr   r   s         r   rR  z#coinbaseinternational.parse_network  s     %%g|<<
..z::$$W.>??	  $$Wn==..t/A/A'K}K}K}  @B  0C  0C  EQ  R  R  ++G5IJJ++G5IJJ 
   	 	"
 "
   	r   amountreturnc                    K   d}|                      d|           d{V \  }}|t          | j        dz             ||d}|                     |                     ||                     d{V S )a  
        Either adds or reduces margin in order to set the margin to a specific value
        :see: https://docs.cloud.coinbase.com/intx/reference/setportfoliomarginoverride
        :param str symbol: unified market symbol of the market to set margin in
        :param float amount: the amount to set the margin to
        :param dict [params]: parameters specific to the exchange API endpoint
        :returns dict: A `margin structure <https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure>`
        Nr}   z9 setMargin() only allows setting margin to full portfolio)r   margin_override)r   r   r#   v1PrivatePostPortfoliosMarginr  )r   r  ri  r   r   r"  s         r   
set_marginz coinbaseinternational.set_margin(  s       	"&"B"B;PV"W"WWWWWWW	6TW'bbccc"%
 
 77GV8T8TUUUUUUUUUr   c           	      .  K   |                                   d{V  d}|                     |dd          \  }}d}|                     |ddd          \  }}d}|r!|                     d||||||           d{V S |                     ||d          dz
  }d|                     |d	d||z            i}	||                     |          |	d
<   |t          |d          }
|
|	d<   d}|                     |dd          \  }}|||	d<   d}|                     |dd          \  }}||                     |          |	d<   |                     |                     |	|                     d{V }| 	                    |dg           }| 
                    |          S )a  
        fetch history of deposits and withdrawals
        :see: https://docs.cloud.coinbase.com/intx/reference/gettransfers
        :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
        :param int [limit]: max number of deposit/withdrawals to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.portfolios]: Identifies the portfolios by UUID(e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID(e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
        :param int [params.until]: Only find transfers updated before self time. Use timestamp format
        :param str [params.status]: The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
        :param str [params.type]: The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NfetchDepositsWithdrawalsr  r  r*   r  r  r  r  	time_fromr  r   untiltime_tor  )r  r   r  r  r  iso8601r\  v1PrivateGetTransfersr  r  parse_transactions)r   r	  r  r  r   r  r  r   r!  r"  newLimitr   rr  r  rawTransactionss                  r   fetch_deposits_withdrawalsz0coinbaseinternational.fetch_deposits_withdrawals;  s4      !!!!!!!!!88A[]ghh&#'+'D'DVMgi  BE  (F  (F$f 	V>>?Y[_afhmouw~  AU  V  V  V  V  V  V  V  V  V  !44q8T00?TX[oTopp
 #'<<#6#6GK 5#H&.GN#
!::6C]_kll
F!$.GL!55f>XZabbv!%e!4!4GI33DKK4P4PQQQQQQQQ6 ..9bAA&&777r   c                 ^  K   |                                   d{V  |                     |          }d}|                     d|           d{V \  }}||                     |          d}|                     |                     ||                     d{V }|                     |          S )a  
        :see: https://docs.cloud.coinbase.com/intx/reference/getportfolioposition
        fetch data on an open position
        :param str symbol: unified market symbol of the market the position is held in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nro   )r   r  )r  r  r   	market_id2v1PrivateGetPortfoliosPortfolioPositionsInstrumentr  parse_position)r   r  r   r   r"  positions         r   fetch_positionz$coinbaseinternational.fetch_position  s       !!!!!!!!!V$$	"&"B"B?TZ"["[[[[[[[	6"..00
 
 PPQUQ\Q\]dflQmQmnnnnnnnn  ""8,,,r   c           
         |                      |d          }|                      |d          }|                     ||d          }d}t          j        |d          rd}t          j        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          S )Nr  net_size-longr   shortz-1r   r#   
entryPricer,  r-  notional
collateralunrealizedPnlunrealized_pnlside	contractscontractSizer1  r2  hedgedmaintenanceMarginmaintenanceMarginPercentageinitialMarginim_contribution)initialMarginPercentageleverageliquidationPricemarginRatio
marginModer   )r   safe_marketr   	string_le
string_mulsafe_positionr>  r   )r   r~  r  marketIdquantityr  s         r   r}  z$coinbaseinternational.parse_position  s     ##Hh77##Hj99!!(FC88Xs++ 	:D)$99H!! #
H#
$""8T22#
 fX&#
 $	#

 ))(LAA#
 #
 $#
 T--h8HII#
 D#
 **844#
 D,,V^DD#
 #
 #
 d#
  #
  *4!#
" T--h8IJJ##
$ (, $/#
 #
 #
   	r   symbolsc                   K   |                                   d{V  d}|                     d|           d{V \  }}d|i}|                     |                     ||                     d{V }|                     |          }|                     |          r|S |                     |          }|                     |d|d          S )a  
        :see: https://docs.cloud.coinbase.com/intx/reference/getportfoliopositions
        fetch all open positions
        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [method]: method name to call, "positionRisk", "account" or "option", default is "positionRisk"
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nrq   r   r  F)r  r   (v1PrivateGetPortfoliosPortfolioPositionsr  parse_positionsr   market_symbolsfilter_by_array_positions)r   r  r   r   r"  r  	positionss          r   fetch_positionsz%coinbaseinternational.fetch_positions  s       !!!!!!!!!	"&"B"BCSU["\"\\\\\\\	6
 FFt{{SZ\bGcGcdddddddd$ ((22	==!! 	%%g..--i7ERRRr   c                    K   |                                   d{V  d|d<   |                     ||||           d{V S )a  
        fetch all withdrawals made from an account
        :see: https://docs.cloud.coinbase.com/intx/reference/gettransfers
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.portfolios]: Identifies the portfolios by UUID(e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID(e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
        :param int [params.until]: Only find transfers updated before self time. Use timestamp format
        :param str [params.status]: The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
        :param str [params.type]: The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NWITHDRAWr  r  ry  r   r	  r  r  r   s        r   fetch_withdrawalsz'coinbaseinternational.fetch_withdrawals  sa       !!!!!!!!!#v44T5%PPPPPPPPPr   c                    K   |                                   d{V  d|d<   |                     ||||           d{V S )a*  
        fetch all deposits made to an account
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.portfolios]: Identifies the portfolios by UUID(e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID(e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
        :param int [params.until]: Only find transfers updated before self time. Use timestamp format
        :param str [params.status]: The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
        :param str [params.type]: The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NDEPOSITr  r  r  s        r   fetch_depositsz$coinbaseinternational.fetch_deposits  sa       !!!!!!!!!"v44T5%PPPPPPPPPr   c                 >    ddddd}|                      |||          S )Nokpendingcanceled)	PROCESSEDNEWSTARTEDFAILEDr   r   statusstatusess      r   parse_transaction_statusz.coinbaseinternational.parse_transaction_status   s4      	
 
 &&999r   rG  c           
         |                      |d          }|                     |di           }|                     |dd|                     |g d          dg          }|                     |di           }|                     |dd|                     |g d          d	g          }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!iS )"N
updated_atfrom_portfoliofrom_addressfrom_cb_account)r#   uuidr$   from_counterparty_id
to_addressto_cb_accountto_counterparty_idr   r#   transfer_uuidtxidtransaction_uuidr1  r2  r   rX  rE  	addressToaddressFromrH  tagTotagFromr  resourceri  rG  rC  r  updatedrb  costrG  )r   r   rg  r?  rf  r>  rd  r  )r   transactionrG  r2  fromPorfolior  
toPorfolior  s           r   parse_transactionz'coinbaseinternational.parse_transaction)  s    ##K>>~~k3CRHH((~GXZ^ZlZlmy  |R  |R  |R  [S  [S  Uk  7l  m  m^^K1A2FF
&&{\?TXTfTfgq  tJ  tJ  tJ  UK  UK  Ma  5b  c  c	
K
$"";@@
 D$$[2DEE
 11	

 
 t..t/?/?^/\/\]]
 t
 
 ;
 4
 T
 t
 D$$[*==
 d&&{H==
 //0@0@g0V0VX`aa
  d33D4D4D[RZ4[4[\\!
" t~~h//#
$   %
 
 	
r   c                 4   |                      |d          }|                      |d          }|                     ||                     |dd          |                      |d          |                     |          ||                     ||          d |                     |d          d |                     |d          |                     |d          d |                     |d	          |                     |                      |d
                    dd          S )Nr  r*  fill_idexec_idorder_idr  
fill_pricefill_qtyrb  	fee_assetr  )r   r#   orderr1  r2  r  r  r  takerOrMakerpriceri  r  rb  )r   
safe_trader   r?  r=  safe_string_lowerr>  rd  )r   trader  r  r2  s        r   parse_tradez!coinbaseinternational.parse_tradeL  s   B ##E844##E<88$$UIyAA%%eZ8811 &&x88**5&99 %%e\::&&uj99((66 33D4D4DUK4X4XYY  
  
   	r   c                 f   K   |                      |           d{V }|                     |          S )a0  
        :see: https://docs.cloud.coinbase.com/intx/reference/getinstruments
        retrieves data on all markets for coinbaseinternational
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        N)v1PublicGetInstrumentsparse_marketsr  s      r   fetch_marketsz#coinbaseinternational.fetch_markets  sD       44V<<<<<<<<d !!(+++r   c                 l   |                      |d          }|                      |d          }|                      |d          }|                      |d          }|dk    }| j        }|dz   |z   }d }	|s
|}	|d|z   z  }i d|d	|                                d|d
|d|d|	r|	nd d|d|d|	r|	nd d|rdndd|ddd| ddddd|                      |d          dk    d| |rd n|	|k    |rd n|	|k    |d         d         |d         d         |rd ndd d d d |                     |d          |                     |d          |                     |d          d d |                     |d!          d"d |rd n|                     |d#          d"d d d"|                     |d$          d d"d%|d d&S )'Nr  base_asset_namequote_asset_namer  SPOT/:r#   lowercaseIdbasequotesettlebaseIdquoteIdsettleIdr2   r4   r3   Fr5   r6   r`  trading_stateTRADINGr@  r   r   r   r  base_incrementquote_increment)ri  r  r  base_imfr[  position_limit_qtymin_notional_value)r  ri  r  r  )linearinverser   r   r  expiryexpiryDatetimestrike
optionTypera  rc  r   created)r   r   lowerr>  )
r   r  r  r  r  typeIdisSpotr   r  r  s
             r   parse_marketz"coinbaseinternational.parse_market  s   ^ ##FH55!!&*;<<""6+=>>!!&&11F"y#' 	$HcGm#F4
(4
8>>++4
 f4
 F	4

 W4
 (4hh4
 f4
 w4
 H6$4
 f0FF&4
 F4
 e4
 J4
 e4
 e4
  d&&v??9L!4
" F
#4
$ %?dd8w+>%@ttH,?)_W-)_W-$*1DD"**63CDD))&2CDD((1BCC   ++FJ?? 
  #)]44t/?/?H\/]/] 
   
  ++F4HII  $ g4
 4
 4
 4	
r   c                    K   |                      |           d{V }i }t          dt          |                    D ](}|                     ||                   }|||d         <   )|S )a  
        fetches all available currencies on an exchange
        :see: https://docs.cloud.coinbase.com/intx/reference/getassets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr   r	  )v1PublicGetAssetsr   r   parse_currency)r   r   r   rS  r   rG  s         r   fetch_currenciesz&coinbaseinternational.fetch_currencies-  s        11&99999999
 q#j//** 	0 	0A**:a=99H'/F8F#$$r   c                     |                      |d          }|                     |          }|                      |d          }|||d ||dk    d d d d d | j        dS )NrV  r  ACTIVE)r#   r$   r	  ra  r   r`  r_  r   r   rb  r   rc  )r   rd  rc  )r   rG  r#   r	  statusIds        r   r  z$coinbaseinternational.parse_currencyH  s{     h55&&r**##Hh778+k
 
 	
r   c                   K   |                                   d{V  |                     |          }|                     |           d{V }i }t          dt	          |                    D ]x}||         }|                     |d          }|                     |          }|                     |di           }	|                     |	| 	                    |                    ||<   y| 
                    |d|d          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://docs.cloud.coinbase.com/intx/reference/getinstruments
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r  r  T)r  r  r  r   r   r   r=  r   parse_tickerr  filter_by_array)
r   r  r   r   tickersr   r  r  r  r  s
             r   fetch_tickersz#coinbaseinternational.fetch_tickerse  s      !!!!!!!!!%%g.. 77????????q#k**++ 	S 	SA$QJ''
H==H%%h//FNN:w;;E"//t7G7G7Q7QRRGFOO##GXwEEEr   c                   K   |                                   d{V  |                     |          }d|                     |          i}|                     |                     ||                     d{V }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://docs.cloud.coinbase.com/intx/reference/getinstrumentquote
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr  )r  r  r{  %v1PublicGetInstrumentsInstrumentQuoter  r  )r   r  r   r  r"  tickers         r   fetch_tickerz"coinbaseinternational.fetch_tickery  s       !!!!!!!!!V$$$..00
 AA$++gW]B^B^________  000r   r  c                    |                      |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          S )Nr1  r   r  r2  bidbest_bid_price	bidVolumebest_bid_sizeaskbest_ask_price	askVolumebest_ask_sizehighlowopencloselastchanger   averagevwap)
baseVolumequoteVolumepreviousClose)r   safe_tickerr=  r?  r>  )r   r  r  r2  s       r   r  z"coinbaseinternational.parse_ticker  sv   $ ##FK88 !
F!
d&&tV44!
 11!
 	!

 4##F,<==!
 ))&/BB!
 4##F,<==!
 ))&/BB!
 D!
 4!
 D!
 T!
 D!
 d!
 $!
  t!!
" D#!
$ !)!
 !
 !
   	r   c                   K   |                                   d{V  d}|                     d|           d{V \  }}d|i}|                     |                     ||                     d{V }|                     |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://docs.cloud.coinbase.com/intx/reference/getportfoliobalances
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.v3]: default False, set True to use v3 api endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        NrM   r   )r  r   'v1PrivateGetPortfoliosPortfolioBalancesr  parse_balance)r   r   r   r"  balancess        r   fetch_balancez#coinbaseinternational.fetch_balance  s       !!!!!!!!!	"&"B"B>SY"Z"ZZZZZZZ	6
 EEdkkRY[aFbFbcccccccc$ !!(+++r   c                 p   d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr   r   rV  r  totalholdused)r   r   r   rd  r   safe_balance)r   r  rS  r   
rawBalancerh  r	  r   s           r   r+  z#coinbaseinternational.parse_balance  s    " H
 q#h--(( 	# 	#A!!J))*lCCJ**:66DllnnG#//
JGGGG"..z6BBGFO"F4LL  (((r   fromAccount	toAccountc           
      (  K   |                                   d{V  |                     |          }|d         |||d}|                     |                     ||                     d{V }|                     |d          }	|ddd|||||	rdndd	S )a4  
        Transfer an amount of asset from one portfolio to another.
        :see: https://docs.cloud.coinbase.com/intx/reference/createportfolioassettransfer
        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure>`
        Nr#   )rC  ammountfromtosuccessr  failed)	r   r#   r1  r2  rG  ri  r4  r5  r  )r  rG  v1PrivatePostPortfoliosTransferr  r   )
r   r	  ri  r4  r5  r   rG  r"  r  r:  s
             r   transferzcoinbaseinternational.transfer  s       !!!!!!!!!==&&d^	
 
 ==dkk'SY>Z>Z[[[[[[[[..955&"%3dd8

 

 
	
r   r  r  r  c                   K   |                                   d{V  |                     |          }|                                }|                     |g d          }	|                     | j        dd          }
|
dz   |                                 z   }|dd         }||                                |d         |                     |d	         |          d
}|	|dk    rd}nd}|	|d<   ||d<   |dk    r|t          | j	        dz             ||d<   d}| 
                    d|           d{V \  }}|||d<   |                     |dd          }|                     |dd          }|dk    r"||dk    rt          | j	        dz             d}n|dn|}|||d<   ||d<   |                     |g d          }|                     |                     ||                     d{V }|                     ||          S )a  
        create a trade order
        :see: https://docs.cloud.coinbase.com/intx/reference/createorder
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, quote currency for 'market' 'buy' orders
        :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.stopPrice]: 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 bool [params.postOnly]: True or False
        :param str [params.tif]: 'GTC', 'IOC', 'GTD' default is 'GTC' for limit orders and 'IOC' for market orders
        :param str [params.expire_time]: The expiration time required for orders with the time in force set to GTT. Must not go beyond 30 days of the current time. Uses ISO-8601 format(e.g., 2023-03-16T23:59:53Z)
        :param str [params.stp_mode]: Possible values: [NONE, AGGRESSING, BOTH] Specifies the behavior for self match handling. None disables the functionality, new cancels the newest order, and both cancels both orders.
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        N)triggerPrice	stopPrice
stop_pricer   r   r  r      r#   r  )client_order_idr  r  sizer  
STOP_LIMITSTOPrA  r  z@createOrder() requires a price parameter for a limit order typesr  rE   r   postOnly	post_onlytiftimeInForceMARKETIOCz6createOrder() market orders must have tif set to "IOC"GTC)rC  userrG  rJ  )r  r  uppersafe_number_nr   r   r  amount_to_precisionr   r#   r   safe_bool_2r   omitv1PrivatePostOrdersr  parse_order)r   r  r  r  ri  r  r   r  r  r@  clientOrderIdprefixclientOrderIdr"  r   rG  rI  r  s                    r   create_orderz"coinbaseinternational.create_order  sl     & !!!!!!!!!V$$&&v/Z/Z/Z[[	"..t|ZTT+c1DIIKK?%ad+,JJLL ,,,VH-=vFF	
 
  w%$-GL! 7??}"47-o#oppp$GG	"&"B"B=RX"Y"YYYYYYY	6 #,GK ##FJDD  >>X3%<<"47-e#efffCCK%%cC#+GK 6#Y#Y#YZZ11$++gv2N2NOOOOOOOO0 &111r   c                    |                      |d          }|                     |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|          S ) Nr  rb  r  submit_timer*  r   r#   r  rW  rC  r1  r2  lastTradeTimestampr  rJ  rI  rG  r  r  r@  rA  r?  ri  rD  filledexec_qty	remaining
leaves_qty	avg_priceorder_status)r  r#  r  rb  trades)	r   r>  r   
safe_orderr?  r=  parse_order_typer  parse_order_status)r   r  r  r  feeCostrb  r2  s          r   rU  z!coinbaseinternational.parse_orderi  so   0 ##E844""5%00C %%e]LII  
E 
$""5*55 
 T--e5FGG 
 11	 

  
 !$ 
 d&&x88 
 D))$*:*:5&*I*IJJ 
 4++E599 
  
 D**5&99 
 T%%eW55 
 ))%>> 
 D,,ULAA 
 d&&uf55 
  d&&uj99! 
" ))%>># 
$ ''{;;--d.>.>un.U.UVV- 
  
  
. /  	r   c                 J    ddddddddddd
}|                      |||          S )Nr  closedr  rejectedexpired)
r  PARTIAL_FILLEDFILLEDCANCELEDREPLACEDPENDING_CANCELREJECTEDPENDING_NEWEXPIREDPENDING_REPLACEr  r  s      r   re  z(coinbaseinternational.parse_order_status  sF    $""$"! %
 
 &&999r   c                 N    |dk    rd S ddddd}|                      |||          S )NUNKNOWN_ORDER_TYPEr  r  )rK  LIMITrF  rE  r  )r   r  typess      r   rd  z&coinbaseinternational.parse_order_type  sE    '''4!	
 
 tT222r   r#   c                 B  K   |                                   d{V  d}|                     d|           d{V \  }}||d}d}||                     |          }|                     |                     ||                     d{V }|                     ||          S )a  
        cancels an open order
        :see: https://docs.cloud.coinbase.com/intx/reference/cancelorder
        :param str id: order id
        :param str symbol: not used by coinbaseinternational cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr9   )r   r#   )r  r   r  v1PrivateDeleteOrdersIdr  rU  )r   r#   r  r   r   r"  r  r   s           r   cancel_orderz"coinbaseinternational.cancel_order  s       !!!!!!!!!	"&"B"B=RX"Y"YYYYYYY	6"
 
 [[((F33DKK4P4PQQQQQQQQ0 ///r   c                 V  K   |                                   d{V  d}|                     d|           d{V \  }}d|i}d}|r |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     ||          S )ab  
        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>`
        Nr8   r   r#   r  )r  r   r  v1PrivateDeleteOrdersr  parse_orders)r   r  r   r   r"  r  r   s          r   cancel_all_ordersz'coinbaseinternational.cancel_all_orders  s       !!!!!!!!!	"&"B"BCTV\"]"]]]]]]]	6
  	1[[((F$*4LGL!11$++gv2N2NOOOOOOOO  000r   c                 Z  K   |                                   d{V  |                     |          }d|i}	d}
|                     d|           d{V \  }
}|
|
|	d<   ||                     ||          |	d<   ||                     ||          |	d<   |                     |g d          }|||	d<   |                     |d	d
          }|t          | j        dz             ||	d	<   | 	                    | 
                    |	|                     d{V }|                     ||          S )a	  
        edit a trade order
        :see: https://docs.cloud.coinbase.com/intx/reference/modifyorder
        :param str id: cancel order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str params['clientOrderId']: client order id
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr#   rK   r   rD  r  )r@  rA  r?  rA  rC  rW  z/ editOrder() requires a clientOrderId parameter)r  r  r   rQ  price_to_precisionrP  r   r   r#   v1PrivatePutOrdersIdr  rU  )r   r#   r  r  r  ri  r  r   r  r"  r   r@  rW  r  s                 r   
edit_orderz coinbaseinternational.edit_order  s      !!!!!!!!!V$$"
 	"&"B"B;PV"W"WWWWWWW	6 #,GK "66vvFFGFO#66vuEEGG&&v/Z/Z/Z[[	 $-GL!**63DoVV TW'XXYYY%2!"//GV0L0LMMMMMMMMv...r   c                 B  K   |                                   d{V  d}||                     |          }d}|                     d|           d{V \  }}||d}|                     |                     ||                     d{V }|                     ||          S )a  
        fetches information on an order made by the user
        :see: https://docs.cloud.coinbase.com/intx/reference/modifyorder
        :param str id: the order id
        :param str symbol: unified market symbol that the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nrl   )r#   r   )r  r  r   v1PrivateGetOrdersIdr  rU  )r   r#   r  r   r  r   r"  r  s           r   fetch_orderz!coinbaseinternational.fetch_order"  s       !!!!!!!!![[((F	"&"B"B<QW"X"XXXXXXX	6"
 
 //GV0L0LMMMMMMMM4 v...r   c           	        K   |                                   d{V  d}|                     d|           d{V \  }}d}|                     |dd          \  }}d}|                     |ddd          \  }}d}|r!|                     d||||||           d{V S |                     ||d          dz
  }	||                     |d	d
|	|z            d}
d}|r|                     |          }||
d<   |"|dk    rt          | j        dz             ||
d<   || 	                    |          |
d<   | 
                    |                     |
|                     d{V }|                     |dg           }|                     ||||          S )a  
        fetches information on all currently open orders
        :see: https://docs.cloud.coinbase.com/intx/reference/getorders
        :param str symbol: unified market symbol of the orders
        :param int [since]: timestamp in ms of the earliest order, default is None
        :param int [limit]: the maximum number of open order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :param int [params.offset]: offset
        :param str [params.event_type]: The most recent type of event that happened to the order. Allowed values: NEW, TRADE, REPLACED
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nrk   Fr  r  r*   r  r  r  r  )r   r  r  z' fetchOpenOrders() maximum limit is 100r  ref_datetimer  )r  r   r   r  r  r  r  r   r#   rt  v1PrivateGetOrdersr  r  r}  )r   r  r  r  r   r   r  r  r   r!  r"  r  r  	rawOrderss                 r   fetch_open_ordersz'coinbaseinternational.fetch_open_ordersQ  s3      !!!!!!!!!	"&"B"BCTV\"]"]]]]]]]	688ART^__&#'+'D'DVM^`vx{'|'|$f 	O>>?PRXZ_afhnpw  zN  O  O  O  O  O  O  O  O  O  !44q8"!00?TX[oTopp
 
  	+[[((F$*GL!s{{ +T!TUUU&+GN#&*ll5&9&9GN#00Wf1M1MNNNNNNNNF NN8Y;;	  FE5AAAr   c           	      b  K   |                                   d{V  d}|                     |dd          \  }}d}d}|                     |ddd          \  }}|r!|                     d||||||           d{V S d}||                     |          }|                     ||d          dz
  }	d	|                     |d
d	|	|z            i}
|"|dk    rt          | j        dz             ||
d<   ||                     |          |
d<   | 	                    |ddg          }|0| 
                    |ddg          }|                     |          |
d<   |                     |                     |
|                     d{V }|                     |dg           }|                     ||||          S )a^  
        fetch all trades made by the user
        :see: https://docs.cloud.coinbase.com/intx/reference/getmultiportfoliofills
        :param str symbol: unified market symbol of the trades
        :param int [since]: timestamp in ms of the earliest order, default is None
        :param int [limit]: the maximum number of trade structures to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch trades for
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        NFrh   r  r  r  r*   r  r  r  z^ fetchMyTrades() maximum limit is 100. Consider setting paginate to True to fetch more trades.r  rq  rr  tillr  r  )r  r   r  r  r  r  r   r#   rt  rg  rS  v1PrivateGetPortfoliosFillsr  r  parse_trades)r   r  r  r  r   r  r   r  r  r!  r"  rr  r  rb  s                 r   fetch_my_tradesz%coinbaseinternational.fetch_my_trades  sH      !!!!!!!!!88R\]]&#'+'D'DV_^tvy'z'z$f 	M>>PVX]_dflnu  xL  M  M  M  M  M  M  M  M  M[[((F  !44q8T00?TX[oTopp
 s{{   ,L  "L  M  M  M&+GN##'<<#6#6GK ""6GV+<==YYv'899F&*ll5&9&9GN#99$++gv:V:VWWWWWWWWR )R88  >>>r   c           	      d  K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }d}|                     d|           d{V \  }}d}|                     |ddd          \  }}d}	|                     |d|           d{V \  }	}|d|d         |||d         |	|                                 d}
 t          | |          | 	                    |
|                     d{V }| 
                    ||          S )a  
        make a withdrawal
        :see: https://docs.cloud.coinbase.com/intx/reference/withdraw
        :see: https://docs.cloud.coinbase.com/intx/reference/counterpartywithdraw
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str [tag]: an optional tag for the withdrawal
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.add_network_fee_to_total]: if True, deducts network fee from the portfolio, otherwise deduct fee from the withdrawal
        :param str [params.network_arn_id]: Identifies the blockchain network(e.g., networks/ethereum-mainnet/assets/313ef8a9-ae5a-5f2f-8a56-572c0e2a4d5a)
        :param str [params.nonce]: a unique integer representing the withdrawal request
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   r   r   sendr#   )r   r  rC  rE  ri  rG  r   nonce)handle_withdraw_tag_and_paramscheck_addressr  rG  r   r   r   r  rI  r  r  )r   r	  ri  rE  rH  r   rG  r   r   r   r"  r  s               r   r   zcoinbaseinternational.withdraw  sy      99#vFFV7###!!!!!!!!!==&&	"&"B"B:v"V"VVVVVVV	666vz8Uuvv	"&"C"CD*V\"]"]]]]]]]	6"d^ 'ZZ\\	
 	
 /v..t{{7F/K/KLLLLLLLL %%h999r   c                    |                      |d          }|                      |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|||dk    }|||dk    }|                     |d          }	|o|}
|d         |	|                     |d          |                     |d	          |                      |d
|
          |||                     |d          |                     |d          |                     |d          |d|                     |d          |ddd
S )Nr   r_  rc  r]  r   r#   r   r$   r   r`  rb  ra  r\  r[  r^  )
r   r#   r$   r   r`  r_  r   rb  ra  rc  )r   r   r>  r   )r   r   withdrawEnableddepositEnabledrc  r   withdrawMaxr_  
depositMaxr   	isEnableds              r   re  z"coinbaseinternational.safe_network  s   ..*==;;22>>&*55&&x77..33%%gu55
"{'>*QO!j&<(1nN$$Wd33	$7	FO$$Wf55'';;nnWh	BB%'##GU33))';??  ++He<<& 
  ++GU;;% 	 	
 
 	
r   GETc                    |d         }|d         dk    }d|z   dz   |                      ||          z   }	|                     ||                     |                    }
d|	z   }|dk    s|dk    r|
r|	d|                     |
          z   z  }	| j        d	         d
         |	z   }|r|                                  t          |                                           }d}|dk    r|
r|                     |
          }|}||z   |z   |z   }| 	                    | 
                    |          |                     | j                  t          j        d          }||| j        | j        d}||||dS )Nr   r  r   r  z/apir  DELETE?r   r   r   base64)zCB-ACCESS-TIMESTAMPzCB-ACCESS-SIGNzCB-ACCESS-PASSPHRASEzCB-ACCESS-KEY)urlr   bodyr/   )implode_paramsrS  extract_paramsurlencode_with_array_repeatr   check_required_credentialsstrr  jsonhmacencodebase64_to_binaryr   hashlibsha256r   r   )r   pathr   r   r   r/   r  r+   signedfullPathquery	savedPathr  r  payloadauth	signatures                    r   signzcoinbaseinternational.sign=  s   a&Q9$=3&)<)<T6)J)JJ		&$"5"5d";";<<X%	U??f00 JC$"B"B5"I"IIIiv&1 	++---

%%EG #99U++D"G6>I-7D		$++d"3"3T5J5J4;5W5WY`YgiqrrI',"+(,!%	 G fdwOOOr   c
                     |d S | j         dz   |z   }
|                     |d          }|S|                     | j        d         ||
           |                     | j        d         ||
           t          |
          d S )Nr   titler   r   )r#   r   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   )r   r	  reasonr  r   r/   r  r  requestHeadersrequestBodyfeedbackerrMsgs               r   handle_errorsz#coinbaseinternational.handle_errorsY  s     47S=4'!!(G44001I6S[\\\001I6S[\\\)))tr   r&  )H__name__
__module____qualname__r   r  r   r   r   r
  r   r   r$  r	   r(  r'  rJ  r   r   rT  rR  floatr   rn  r   r   ry  r  r}  r   r   r  r  r  r  r   r  r   r  r  r  r   r  r  r   r  r   r  objectr  r   r-  r+  r   r=  r   r   rX  r
   rU  re  rd  rz  r~  r  r  r  r  r   re  r  r  __classcell__)r   s   @r   r!   r!      s
       n n n n n` IK ^ ^C ^ ^ ^ ^$#s #PS # # # #" +- 5 5 5 58
 
 
. >BPTcgpr /Q /Qs /Q# /Q]` /Q /Q /Q /Qb5 5v 5 5 5 5
 
6 
 
 
 
< >@ .
 .
 .
 .
 .
 .
`      9; I I I I /1     -/ ' ' ' 'R CE V Vs VE V V V V V& <@daenp D8 D8S D8 D8[^ D8uy  {F  vG D8 D8 D8 D8L 8:  -  -3  -  -  -  -D/ /v / / / /b 8<B %S %SW %S4PX> %S %S %S %SN 37TX\eg Q QC Qs QRU Qlpq|l} Q Q Q Q& 04$UYbd Q Q QC Qs Qimnyiz Q Q Q Q$: : :!
 !
x !
; !
 !
 !
 !
F4 4 45 4 4 4 4l *, 9, 9,V 9, 9, 9, 9,vn
f n
 n
 n
 n
` -/  :    6
 
 
: 6:" F F7 F F F F F( 68 1 1 1F 1 1 1 1 ( (6 (6 (V ( ( ( (T *,  ,  ,  ,  ,  ,  ,D) ) ) ) ): ac 
 
3 
 
C 
TW 
gt 
 
 
 
B os{} T2 T2 T2I T2Y T2X] T2fk T2 T2 T2 T2l7 7 75 7 7 7 7r: : :	3 	3 	3 9=R +0 +0S +0# +0 +0 +0 +0Z 59 1 1c 1 1 1 1( hl  }A  JL #/ #/3 #/ #/9 #/I #/_d #/ty #/ #/ #/ #/J 8<B -/ -/C -/ -/ -/ -/ -/^ 59tZ^gi JB JBc JB JBTW JBnrsxny JB JB JB JBX 37TX\eg O? O?C O?s O?RU O? O? O? O?b EIQS ): ):3 ): ): ): ): ):V"
 "
 "
H  b$T P P P P8      r   r!   )& ccxt.async_support.base.exchanger   #ccxt.abstract.coinbaseinternationalr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   typingr   r   ccxt.base.errorsr   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r!    r   r   <module>r     s   6 5 5 5 5 5 ; ; ; ; ; ;  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q             * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' ) ) ) ) ) ) - - - - - - 4 4 4 4 4 4 % % % % % %Q Q Q Q QHk Q Q Q Q Qr   