
    ei                         d dl mZ d dlm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  G d dee          Z dS )    )Exchange)ImplicitAPI)AnyBalances
CurrenciesIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFees)List)ExchangeError)ArgumentsRequired)InsufficientFunds)InvalidOrder)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdee         fdZdedefdZ	i fde
fdZdi fdedefd	Zd-dedefd
Zdi fdededefdZddi fdedededee         fdZd-dededefdZi fdefdZdefdZdi fdedededededefdZ di fdede!fdZ"dddi fde!dededee         fdZ#dddi fde!dededee         fdZ$d-dededefdZ%d-de!de!fd Z&i fde'fd!Z(d-defd"Z)d#d$i ddfd%Z*d&e+d'ed(ed)ed*ed+efd,Z, xZ-S ).	cryptomusreturnc                 $   |                      t          t          |                                           i ddddddgddd	d
dddddi dd ddddddddddddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBdi dCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSdi dTddUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcddddi deddfddgddhddiddjddkddlddmddnddoddpddqddrddsddtddudi dvddwddxddyddzdd{dd|dd}dd~dddddddddddddddddddddddddddd
di dddddddddddddddddddidddddddddddddidddddd|                     d          |                     d          diddddddddddddddddddddddddddddddddddddiddi dt
          t          t          t          dĜi dŜdt          ddddȜdi i          S )Nidr   name	Cryptomus	countriesCA	rateLimitd   versionv2	certifiedFprohasCORSspotTmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscancelWithdrawcloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistory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fetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransfersfetchVolatilityHistoryfetchWithdrawalsreduceMargin)
repayCrossMarginrepayIsolatedMarginrepayMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModetransferwithdraw
timeframesurlszOhttps://github.com/user-attachments/assets/8e0b1c48-7c01-4177-9224-f1b01d89d7e7zhttps://api.cryptomus.com)publicprivatezhttps://cryptomus.comz"https://doc.cryptomus.com/personalzhttps://cryptomus.com/tariffsz,https://app.cryptomus.com/signup/?ref=JRP4yj)logoapiwwwdocfeesreferralr   get   )zv2/user-api/exchange/marketsz!v2/user-api/exchange/market/pricezv1/exchange/market/assetsz,v1/exchange/market/order-book/{currencyPair}zv1/exchange/market/tickersz(v1/exchange/market/trades/{currencyPair})v2/user-api/exchange/ordersz#v2/user-api/exchange/orders/historyz$v2/user-api/exchange/account/balancez$v2/user-api/exchange/account/tariffszv2/user-api/payment/serviceszv2/user-api/payout/serviceszv2/user-api/transaction/list)r   z"v2/user-api/exchange/orders/marketz%v2/user-api/exchange/orders/{orderId})r   postdeleter   tradingz0.02)
percentagefeeSidemakertakeroptionsbscdashpolygonarbitrumsoltonethtronltcxmrbchdoge	avalanchebtcrub)BEP20DASHPOLYGONARBSOLTONERC20TRC20LTCXMRBCHDOGEAVAXBTCRUBr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   levelr   )!createMarketBuyOrderRequiresPricenetworksnetworksByIdr   commonCurrencies
exceptions)5006zInsufficient funds.zMinimum amount 15 USDT)exactbroadprecisionModerequiredCredentials)apiKeyuidfeatures)	deep_extendsuperr   describeparse_numberr   r   r   r   )self	__class__s    L/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/cryptomus.pyr   zcryptomus.describe   s
   i 6 6 ? ? A A xD
+xD
KxD
 $xD
 	xD

 txD
 xD
 5xD
  BBB %B 	B
 %B %B UB $UB 'B B "5B 'B tB B !%B  $U!B"  #B B$ %e%B& ''B( /)B* $U+B, ,U-B. 0/B0 t1B2 73B4 9%5B6 &u7B8 (9B: ';B< &u=B> (?B@ "5ABB (CBD ,UEB B BF -eGBH %eIBJ  KBL MBN &uOBP "5QBR +ESBT )%UBV #EWBX ,UYBZ /[B\ &u]B^ #E_B` $UaBb )%cBd $UeBf $UgB B Bh +EiBj 'kBl (mBn "5oBp &uqBr  sBt +EuBv &uwBx 'yBz ({B| #E}B~ *5B@ $UABB uCBD "5EBF *5GBH +EIB B BJ )%KBL uMBN  OBP !%QBR %eSBT $UUBV &uWBX -eYBZ /[B\ "5]B^ #E_B` +EaBb cBd !%eBf "5gBh &uiBj +EkB B Bl  mBn eoBp $UqBr +EsBt %euBv !%wBx "4yBz u{B| #E}B~ dB@ !$ABB uCBD #EEBF  GBH 'IBJ $UKBL !%MB B BN *5OBP (QBR %eSBT )%UBV )%WBX uYBZ u[B\ ]B^ U_B` taBb "5cBd #DeBf $UgBh !%iBj )%kBl #EmBn oB Bp %*',$ $"!&#(!!CB B BxD
V "WxD
X i9:  /;7J
 
YxD
n 89=>56HI67DE 	 89?@@A@A897889  89>? 
 @  oxD
j "&$!..v66!..v66	 kxD
z 59""(%  "#   "'   $ #"( %  "#   "!'  ! !$ Q#I' '{xD
J KxD
L (*+<.:	   MxD
d YexD
f "$ $gxD
n oxD
 xD
 x x x	    c                     |                      |          }|                     |dg           }|                     |          S )a  
        retrieves data on all markets for the exchange

        https://doc.cryptomus.com/personal/market-cap/tickers

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        result)!publicGetV2UserApiExchangeMarkets	safe_listparse_markets)r   paramsresponser   s       r   fetch_marketszcryptomus.fetch_markets  sB     99&AA( (B77!!&)))r   marketc                 R   |                      |d          }|                    d          }|d         }|d         }|                     |          }|                     |          }|                     | j        d          }|                     i d|d|dz   |z   d|d	|d
|d|dddddd dddddddddddddd dd i dd dd dd d|                     |d          d|                     |d          d|                     |d          dd d |                      |d           d!d d"d d#d d$d d%|                     | 	                    |                      |d&                              |                     | 	                    |                      |d'                              d(d)|                     |d*          |                     |d+          d,|                     |d-          |                     |d.          d,d d d,d d d,d/d0d d1|          S )2Nsymbol_r   r   r   r    /basequotebaseIdquoteIdactiveTtyper-   subTyper.   Fr/   r0   r1   contractsettlesettleIdcontractSizelinearinverser   r   r   	tierBasedr   expiryexpiryDatetimestrike
optionType	precision	quotePrecbasePrec)amountpricelimitsquoteMinSizequoteMaxSizeminmaxbaseMinSizebaseMaxSize)r  r  leveragecostcreatedinfo)
safe_stringsplitsafe_currency_code	safe_dictr   safe_market_structuresafe_number	safe_boolr   parse_precision)	r   r   marketIdpartsr  r  r  r  r   s	            r   parse_marketzcryptomus.parse_market/  sk    ##FH55s##q(&&v..''00~~di33)) 6+
(6+
dSj5(6+
 D6+
 U	6+

 f6+
 w6+
 d6+
 F6+
 t6+
 D6+
 e6+
 E6+
 e6+
 e6+
 6+
  d!6+
" #6+
 6+
$ D%6+
& d'6+
( t)6+
* T%%dG44+6+
, T%%dG44-6+
. $..|<</6+
0 16+
2 t''i8836+
4 d56+
6 d76+
8 d96+
: $;6+
< ++D,@,@AQAQRXZeAfAf,g,ghh**4+?+?@P@PQWYc@d@d+e+eff =6+
D ++FNCC++FNCC 
  ++FMBB++FMBB 
   
    E6+
h ti6+
j Fk6+
 6+
 6 6 6	r   c                 `   |                      |          }|                     |d          }|                     |d          }t          |                                          }i }t          dt          |                    D ]*}||         }|                     |          }	i }
||         }t          dt          |                    D ]}||         }|                     |d          }| 	                    |          }||| 
                    |d          | 
                    |d          d| 
                    |d          | 
                    |d	          dd
d|                     |d          |                     |d          dd|d	|
|<   |                     ||	|
|d          ||	<   ,|S )a  
        fetches all available currencies on an exchange

        https://doc.cryptomus.com/personal/market-cap/assets

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r   currency_coder   network_codemin_withdrawmax_withdrawr  min_depositmax_deposit)r   depositNcan_withdrawcan_deposit)	r    networkr  r  r9  r   feer  r&  )r    coder   r&  )publicGetV1ExchangeMarketAssetsr   group_bylistkeysrangelenr)  r'  network_id_to_coder,  r-  safe_currency_structure)r   r   r   coinsgroupedByIdrB  r   ir    r>  r   networkEntriesjnetworkEntry	networkIdnetworkCodes                   r   fetch_currencieszcryptomus.fetch_currencies}  s    77??& x22mmE?;;K$$&&''q#d))$$ "	 "	AaB**2..DH(_N1c.1122  -a0 ,,\>JJ	"55i@@#* $(#3#3L.#Q#Q#'#3#3L.#Q#Q% %
 $(#3#3L-#P#P#'#3#3L-#P#P$ $	 	 ##~~lNKK $|] K K!%(%) )%%(  77$&	9 9  F4LL r   Nsymbolsc                     |                                   |                     |          }|                     |          }|                     |d          }|                     ||          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://doc.cryptomus.com/personal/market-cap/tickers

        :param str[] [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>`
        data)load_marketsmarket_symbols publicGetV1ExchangeMarketTickersr   parse_tickers)r   rP  r   r   rR  s        r   fetch_tickerszcryptomus.fetch_tickers  sg     	%%g..88@@ ~~h//!!$000r   c                    |                      |d          }|                     ||          }|d         }|                      |d          }|                     i d|dd dd dd dd dd d	d d
d dd dd dd d|d|dd dd dd dd |                      |d          |                      |d          |d|          S )Ncurrency_pairr  
last_price	timestampdatetimehighlowbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechanger   averagebase_volumequote_volume)
baseVolumequoteVolumer&  )r'  safe_marketsafe_ticker)r   tickerr   r/  r  rf  s         r   parse_tickerzcryptomus.parse_ticker  sq    ##FO<<!!(F33!55 !
f!
!
 !
 D	!

 4!
 4!
 !
 4!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6=AA++FNCC)!
 !
 !
* +  	r   r  limitc           	         |                                   |                     |          }d|d         i}d}|                     |dd|          \  }}||d<   |                     |                     ||                    }|                     |di           }|                     |d          }	|                     |||	dd	d
d          S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://doc.cryptomus.com/personal/market-cap/orderbook

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.level]: 0 or 1 or 2 or 3 or 4 or 5 - the level of volume
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        currencyPairr    r   r   r   rR  r[  bidsasksr  quantity)rS  r   handle_option_and_params.publicGetV1ExchangeMarketOrderBookCurrencyPairextendr*  safe_timestampparse_order_book)
r   r  rr  r   r   requestr   r   rR  r[  s
             r   fetch_order_bookzcryptomus.fetch_order_book  s     	V$$F4L
 55f>NPWY^__v FFt{{SZ\bGcGcdd( ~~h33''k::	$$T69ffgWabbbr   sincec                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |d          }|                     ||||          S )a0  
        get the list of most recent trades for a particular symbol

        https://doc.cryptomus.com/personal/market-cap/trades

        :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(maximum value is 100)
        :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>`
        rt  r    rR  )rS  r   +publicGetV1ExchangeMarketTradesCurrencyPairrz  r   parse_trades)	r   r  r  rr  r   r   r}  r   rR  s	            r   fetch_tradeszcryptomus.fetch_trades.  s     	V$$F4L
 CCDKKPWY_D`D`aa ~~h//  vue<<<r   tradec                 v   |                      |d          }|                     |                     |d          ||                     |          |d         |                     |d          |                     |d          |                     |d          |                     |d          d d d d d d|d	|          S )
Nr[  trade_idr  r	  r  rk  rj  currencyr$  )r    r[  r\  r  sider  r  r$  takerOrMakerr	  orderr=  r&  )r{  
safe_trader'  iso8601)r   r  r   r[  s       r   parse_tradezcryptomus.parse_tradeQ  s     ''{;;	""5*55"Y//X&$$UF33%%eW55&&un==$$UM::    ! 
  
" #  	r   c                     |                                   i }|                     |                     ||                    }|                     |dg           }|                     |          S )a]  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://doc.cryptomus.com/personal/converts/balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        r   )rS  )privateGetV2UserApiExchangeAccountBalancerz  r   parse_balance)r   r   r}  r   r   s        r   fetch_balancezcryptomus.fetch_balancep  sh     	AA$++gW]B^B^__ (B77!!&)))r   c                 p   d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr&  r   rp  	availablefreeheldused)rC  rD  r'  r)  accountsafe_balance)r   balancer   rI  balanceEntry
currencyIdr>  r  s           r   r  zcryptomus.parse_balance  s     G
 q#g,,'' 	# 	#A"1:L)),AAJ**:66DllnnG"..|[IIGFO"..|VDDGFO"F4LL  (((r   r	  r  r  r  c                    |                                   |                     |          }|d         |dd}|                     |d          }	|	|                     |d          }|	|d<   |dk    }
|                     |          }|                     |          }d}|                     |d          \  }}d}|d	k    r|
r^d
}|                     |ddd
          \  }}|r3||t          | j        dz             |t          j
        ||          }n|r|n|}||d<   n||d<   |                     |                     ||                    }np|dk    rS|t          | j        dz   |z   dz             ||d<   ||d<   |                     |                     ||                    }nt          | j        dz             |                     ||          S )a  
        create a trade order

        https://doc.cryptomus.com/personal/exchange/market-order-creation
        https://doc.cryptomus.com/personal/exchange/limit-order-creation

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or for spot
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders(only for limit orders)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
        :param str [params.clientOrderId]: a unique identifier for the order(optional)
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r    ccxt)r   	directiontagclientOrderIdNclient_order_idbuyr$  r   TrC   r   z createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option of param to False and pass the cost to spend in the amount argumentvaluerw  rr  z0 createOrder() requires a price parameter for a z orderr  z9 createOrder() requires a type parameter(limit or market))rS  r   r'  omitnumber_to_stringhandle_param_stringrx  r   r    r   
string_mul(privatePostV2UserApiExchangeOrdersMarketrz  r   "privatePostV2UserApiExchangeOrdersparse_order)r   r  r	  r  r  r  r   r   r}  r  sideBuyamountToStringpriceToStringr$  r   r   s                   r   create_orderzcryptomus.create_order  sE   " 	V$$Tl
 

 ((AA$YYv77F)6G%&%-..v66--e44//??f8 5481<@<Y<YZ`bo  rU  W[  =\  =\9164 <DL*47  6q  ,q  r  r  r&1.-PP#';44^D#'  &4
#DDT[[QXZ`EaEabbHHW__}'2d(dgk(knv(vwww"0GJ$GG>>t{{7TZ?[?[\\HH#DG.i$ijjj &111r   r    c                     |                                   i }||d<   |                     |                     ||                    }|                     d|i          S )a  
        cancels an open limit order

        https://doc.cryptomus.com/personal/exchange/limit-order-cancellation

        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in(not used in cryptomus)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        orderIdr&  )rS  +privateDeleteV2UserApiExchangeOrdersOrderIdrz  
safe_order)r   r    r  r   r}  r   s         r   cancel_orderzcryptomus.cancel_order  sa     		CCDKKPWY_D`D`aa 1222r   c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |dg           }g }	t          dt          |                    D ]3}
||
         }|	                    |                     ||                     4|	S )a#  
        fetches information on multiple orders made by the user

        https://doc.cryptomus.com/personal/exchange/history-of-completed-orders

        :param str symbol: unified market symbol of the market orders were made in(not used in cryptomus)
        :param int [since]: the earliest time in ms to fetch orders for(not used in cryptomus)
        :param int [limit]: the maximum number of order structures to retrieve(not used in cryptomus)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.direction]: order direction 'buy' or 'sell'
        :param str [params.order_id]: order id
        :param str [params.client_order_id]: client order id
        :param str [params.limit]: A special parameter that sets the maximum number of records the request will return
        :param str [params.offset]: A special parameter that sets the number of records from the beginning of the list
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr    r   rr  r   r   )	rS  r   (privateGetV2UserApiExchangeOrdersHistoryrz  r   rC  rD  appendr  )r   r  r  rr  r   r}  r   r   r   ordersrI  r  s               r    fetch_canceled_and_closed_ordersz*cryptomus.fetch_canceled_and_closed_orders  s    " 	[[((F &tGH$GG@@WV\A]A]^^P (B77q#f++&& 	; 	;A1IEMM$**5&99::::r   c                 *   |                                   d}||                     |          }i }||d         |d<   |                     |                     ||                    }|                     |dg           }|                     ||dd          S )a  
        fetch all unfilled currently open orders

        https://doc.cryptomus.com/personal/exchange/list-of-active-orders

        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for(not used in cryptomus)
        :param int [limit]: the maximum number of  open orders structures to retrieve(not used in cryptomus)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.direction]: order direction 'buy' or 'sell'
        :param str [params.order_id]: order id
        :param str [params.client_order_id]: client order id
        :param str [params.limit]: A special parameter that sets the maximum number of records the request will return
        :param str [params.offset]: A special parameter that sets the number of records from the beginning of the list
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr    r   r   )rS  r   !privateGetV2UserApiExchangeOrdersrz  r   parse_orders)	r   r  r  rr  r   r   r}  r   r   s	            r   fetch_open_orderszcryptomus.fetch_open_orders=  s    " 	[[((F
 &tGH99$++gv:V:VWW( (B77  t<<<r   r  c           	         |                      |dd          }|                     |d          }|                     ||          }|                     |d          }|                     |          }|                     |di           }|                     |d          }|                     |d          }	|                     |d          }
|                     |d	          }|                     |d
g           }d }|                     |d          }|                     |d          }|,|                     |          |                     |d          d}||                     |d          }|                     |d          }|                     |d          }|                     |                     |d                    }|                     |d          }| 	                    i d|d|d|d| 
                    |          dd d|d         d|	dd dd d|
d	|d|                     |d          d|                     |d          d|d|d|d |                     |d!          d ||d |d"|          S )#Norder_idr    r  	createdAtdealaverageFilledPricer	  r  r  transactionsr   feeCurrencyr=  r  filledPricerw  r  stater  r[  r\  lastTradeTimestamptimeInForcepostOnlyr  	stopPricestopLossPricetriggerPricer  r$  ri  filledfilledQuantity)	remainingstatusr=  tradesr&  )safe_string_2r'  rn  	parse8601r*  r,  r   r)  parse_order_statusr  r  )r   r  r   r    r/  dateTimer[  r  r  r	  r  r  transactionr=  firstTxr  r  r$  r  r  s                       r   r  zcryptomus.parse_orderm  s   r z488##E844!!(F33##E;77NN8,,	~~eVR00!--d4HIIv..{33  00nnT>2>>..a00&&w>>" 33K@@((%88 C =$$Wm<<E!!%44w//(()9)9%)I)IJJ((@@  
" 
] 
  
 Y//	 

 !$ 
 fX& 
 D 
 4 
  
 D 
 U 
 ))%AA 
 D,,UODD 
 f 
 D 
  )! 
" d&&u.>??# 
$ - 
  
  
. /  	r   r  c                 B    ddddddd}|                      |||          S )Nrd  closedcanceledexpiredfailed)r  	completedpartially_completed	cancelledr  r  )r'  )r   r  statusess      r   r  zcryptomus.parse_order_status  s:    !#)# 
 
 &&999r   c           	      ^   |                      |          }|                     |di           }|                     |di           }|                     |d          }|                     |d          }t          j        |d          }t          j        |d          }|                     |dg           }i }|                     |          }	t          dt          | j	                            D ]B}
| j	        |
         }||| 
                    |          | 
                    |          dd|	d	||<   C|S )
aU  
        fetch the trading fees for multiple markets

        https://trade-docs.coinlist.co/?javascript--nodejs#list-fees

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/?id=fee-structure>` indexed by market symbols
        r   current_tariff_stepmaker_percenttaker_percent100tariff_stepsr   T)r&  r  r   r   r   r  tiers))privateGetV2UserApiExchangeAccountTariffsr*  r'  r   
string_divr   parse_fee_tiersrC  rD  rP  r   )r   r   r   rR  currentFeeTiermakerFeetakerFeefeeTiersr   r  rI  r  s               r   fetch_trading_feeszcryptomus.fetch_trading_fees  s8    AA&IIb ~~h"55.CRHH##NODD##NODD%h66%h66>>$;;$$X..q#dl++,, 
	 
	A\!_F  **844**844"! F6NN r   c                    g }g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }	t	          j        |	d          }	t	          j        |d          }|                    ||                     |	          g           |                    ||                     |          g           ||dS )Nr   from_turnoverr  r  r  )r   r   )rC  rD  r,  r'  r   r  r  r   )
r   r  r   	takerFees	makerFeesrI  tierturnoverr   r   s
             r   r  zcryptomus.parse_fee_tiers3  s    		q#h--(( 	C 	CAA;D''o>>H$$T?;;E$$T?;;E&ue44E&ue44Eh(9(9%(@(@ABBBh(9(9%(@(@ABBBB
 
 	
r   r   GETc                    |                      ||          }|                     ||                     |                    }| j        d         |         dz   |z   }|dk    r|                                  d}	d| j        i}|dk    r|                     |          }|}	d|d<   n0|                     |          }
t          |
          d	k    r|d
|
z   z  }| 	                    |	          }|| j
        z   }|                     |                     |          d          }||d<   n0|                     |          }
t          |
          d	k    r|d
|
z   z  }||||dS )Nr   r  r    userIdr  zapplication/jsonzContent-Typer   ?md5sign)urlmethodbodyheaders)implode_paramsr  extract_paramsr   check_required_credentialsr   json	urlencoderD  string_to_base64secrethashencode)r   pathr   r  r   r   r  endpointr  
jsonParamsqueryjsonParamsBase64stringToSign	signatures                 r   r  zcryptomus.signD  si   &&tV4464#6#6t#<#<==is#c)H4)++---J$(G yy((!
*<''v..u::??3;&C#44Z@@+dk9L		$++l";";UCCI'GFOONN6**E5zzQsU{"fdwOOOr   httpCodereasonr  r  r   r  c
                    |d S d|v rT|                      |d          }
| j        dz   |z   }|                     | j        d         |
|           t	          |          d|v rv|                      |d          }| j        dz   |z   }|                     | j        d         ||           |                     | j        d         ||           t	          |          d S )Nr>   r   messager   )r'  r    throw_exactly_matched_exceptionr   r   throw_broadly_matched_exception)r   r  r  r  r  r   r  r   requestHeadersrequestBodyr>  feedbackr  s                r   handle_errorszcryptomus.handle_errors`  s    4X##Hf55Dw}t+H001I4QYZZZ)))("" &&x;;Gw}t+H001I7T\]]]001I7T\]]])))tr   )N).__name__
__module____qualname__r   r   r   r	   r   dictr1  r   rO  r   r   rW  r   rq  strr   r   r~  r   r  r  r   r  r  r   r   floatr
   r   r  r   r  r  r  r  r  r   r  r  r  intr  __classcell__)r   s   @r   r   r      sK       y# y y y y y yv $& * *$v, * * * *@L4 LF L L L L\ ') C CZ C C C CJ 04B 1 1W 17 1 1 1 18" "6 "V " " " "H :>b *c *cs *c3 *cY *c *c *c *cX 6:UW != !=3 !=s !=# !=\`af\g != != != !=F  v     > $& * *( * * * *4) ) ) ) )* gksu >2 >23 >2i >2y >2RW >2`c >2z >2 >2 >2 >2@ 37r 3 3s 3C 3 3 3 3, >BPTcgpr F Fs F# F]` Fw{  }B  xC F F F FP /3TXac .= .= .=3 .=c .=hlmrhs .= .= .= .=`i i iv i i i i iV	: 	: 	: 	: 	: 	: 	: )+ N N{ N N N N`
 
 
 
 
 
" &eBSW P P P P8c 3 S # X\ dg        r   r   N)!ccxt.base.exchanger   ccxt.abstract.cryptomusr   ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r   r   <module>r,     s   ( ' ' ' ' ' / / / / / / c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c       * * * * * * . . . . . . . . . . . . ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %_ _ _ _ _+ _ _ _ _ _r   