
    i                    D   d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dl%m&Z& d dl'm(Z(  G d dee          Z)dS )    )Exchange)ImplicitAPIN)BalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)Any)ExchangeError)AuthenticationError)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)DuplicateOrderId)ExchangeNotAvailable)DECIMAL_PLACES)Precisec                   L    e Zd Z fdZ fdZi fdefdZdi fdefdZd Zi fde	e
         fd	Zd
i fdededefdZdEdefdZd Zddi d
d
fdZi fdZdFde
defdZi f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 ZdFde
defdZi fdefdZd Zd  Zd! Z d" Z!d# Z"dFd$Z#d% Z$d& Z%d' Z&d( Z'd) Z(d* Z)d
i fded+e*d,e+d-e,d.e-f
d/Z.d
i fd0ede/fd1Z0d
i fd0ede/fd2Z1d
d
d
i fde/dedede	e2         fd3Z3d
d
d
i fde/dedede	e2         fd4Z4d
d
d
i fde/dedede	e2         fd5Z5d6 Z6d7 Z7dFde
de2fd8Z8d9 Z9i fde:fd:Z;d
d
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>dFde
de=fd=Z?dEd>ede@fd?ZAd
i fd>efd@ZBdA ZCd
i fded-e,fdBZDdFdCeEdeFfdDZG xZHS )Gwavesexchangec                    |                      t          t          |                                           dddg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d'dd(di d)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7dd8dd9ddddddddddddd:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdPdWdXdYg dZg d[d\d]gd]gd^g d_g d`dadbgdcddg deig dfdggdhdidjgdkgdhdddlgidPdm|                     dnd dm|                     do          dp          it          dqd dd d drd dsdtdudvdwdxdydzd{d|idi d}t          d~t          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          t          t          t          t          t          t           t          t          dd          S )Nr$   zWaves.ExchangeCHFCORSspotTmarginswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositAddressfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers)fetchTradesfetchTransferfetchTransfersreduceMarginsetLeveragesetMarginModesetPositionModesignIntransferwithdrawws1m5m15m30m1h2h3h4h6h12h1d1w1M)rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   zchttps://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpgz"https://matcher-testnet.wx.networkz$https://nodes-testnet.wavesnodes.comz(https://api-testnet.wavesplatform.com/v0z!https://api-testnet.wx.network/v1z1https://testnet.wx.network/api/v1/forward/matcherz;https://testnet.wx.network/api/v1/forward/marketdata/api/v1)matchernodepublicprivateforwardmarketzhttps://matcher.wx.networkzhttps://nodes.wx.networkz https://api.wavesplatform.com/v0zhttps://api.wx.network/v1z)https://wx.network/api/v1/forward/matcherz3https://wx.network/api/v1/forward/marketdata/api/v1zhttps://docs.wx.networkzhttps://wx.network)logotestapidocwww)rs   zmatcher/settingszmatcher/settings/ratesz$matcher/balance/reserved/{publicKey}zmatcher/debug/allSnashotOffsetszmatcher/debug/currentOffsetzmatcher/debug/lastOffsetz"matcher/debug/oldestSnapshotOffsetzmatcher/debug/configzmatcher/debug/address/{address}zmatcher/debug/statusz%matcher/debug/address/{address}/checkmatcher/orderbook$matcher/orderbook/{baseId}/{quoteId}z:matcher/orderbook/{baseId}/{quoteId}/publicKey/{publicKey}z.matcher/orderbook/{baseId}/{quoteId}/{orderId}z)matcher/orderbook/{baseId}/{quoteId}/infoz+matcher/orderbook/{baseId}/{quoteId}/statusz>matcher/orderbook/{baseId}/{quoteId}/tradableBalance/{address}zmatcher/orderbook/{publicKey}z'matcher/orderbook/{publicKey}/{orderId}matcher/orders/{address}"matcher/orders/{address}/{orderId}zmatcher/transactions/{orderId}z#api/v1/orderbook/{baseId}/{quoteId})r~   zmatcher/orderbook/marketzmatcher/orderbook/cancelz+matcher/orderbook/{baseId}/{quoteId}/cancelz1matcher/orderbook/{baseId}/{quoteId}/calculateFeez+matcher/orderbook/{baseId}/{quoteId}/deletez.matcher/orderbook/{baseId}/{quoteId}/cancelAllzmatcher/debug/saveSnapshotszmatcher/orders/{address}/cancelzmatcher/orders/cancel/{orderId}zmatcher/orders/serializer   z matcher/settings/rates/{assetId})getpostdeleteput)D	addresseszaddresses/balance/{address}z+addresses/balance/{address}/{confirmations}z#addresses/balance/details/{address}addresses/data/{address}zaddresses/data/{address}/{key}z$addresses/effectiveBalance/{address}z4addresses/effectiveBalance/{address}/{confirmations}zaddresses/publicKey/{publicKey}zaddresses/scriptInfo/{address}z#addresses/scriptInfo/{address}/metazaddresses/seed/{address}zaddresses/seq/{from}/{to}zaddresses/validate/{address}zalias/by-address/{address}zalias/by-alias/{alias}z.assets/{assetId}/distribution/{height}/{limit}zassets/balance/{address}z"assets/balance/{address}/{assetId}zassets/details/{assetId}z"assets/nft/{address}/limit/{limit}zblockchain/rewardszblockchain/rewards/heightz%blocks/address/{address}/{from}/{to}/zblocks/at/{height}z#blocks/delay/{signature}/{blockNum}zblocks/firstzblocks/headers/lastzblocks/headers/seq/{from}/{to}zblocks/heightzblocks/height/{signature}zblocks/lastzblocks/seq/{from}/{to}zblocks/signature/{signature}zconsensus/algozconsensus/basetargetzconsensus/basetarget/{blockId}z%consensus/{generatingbalance}/addresszconsensus/generationsignaturez'consensus/generationsignature/{blockId}z debug/balances/history/{address}zdebug/blocks/{howMany}zdebug/configInfozdebug/historyInfoz
debug/infozdebug/minerInfozdebug/portfolios/{address}zdebug/statez$debug/stateChanges/address/{address}zdebug/stateChanges/info/{id}zdebug/stateWaves/{height}zleasing/active/{address}z
node/stateznode/versionz	peers/allzpeers/blacklistedzpeers/connectedzpeers/suspendedz,transactions/address/{address}/limit/{limit}ztransactions/info/{id}ztransactions/statusztransactions/unconfirmedz"transactions/unconfirmed/info/{id}ztransactions/unconfirmed/sizez
utils/seedzutils/seed/{length}z
utils/timezwallet/seed)r   r   zaddresses/sign/{address}zaddresses/signText/{address}zaddresses/verify/{address}zaddresses/verifyText/{address}zdebug/blacklistzdebug/printzdebug/rollbackzdebug/validatez	node/stopzpeers/clearblacklistzpeers/connectztransactions/broadcastztransactions/calculateFeeztranasctions/signz!transactions/sign/{signerAddress}ztranasctions/statuszutils/hash/fastzutils/hash/securezutils/script/compileCodezutils/script/compileWithImportszutils/script/decompilezutils/script/estimatezutils/sign/{privateKey}zutils/transactionsSerializezaddresses/{address}zdebug/rollback-to/{signature})r   r   r   r   )assetspairszcandles/{baseId}/{quoteId}ztransactions/exchange)zdeposit/addresses/{currency}z'deposit/addresses/{currency}/{platform}	platformszdeposit/currencieszwithdraw/currenciesz'withdraw/addresses/{currency}/{address}zoauth2/token)r   r   r   r   $matcher/orders/{wavesAddress}/canceltickersWX,EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc8)id	numericIdcode	precision      d  i  順    WETHBSC)ERC20BEP20)allowedCandlesaccessToken!createMarketBuyOrderRequiresPricematcherPublicKeyquotescreateOrderDefaultExpirywavesAddresswithdrawFeeUSDNwithdrawFeeWAVESwavesPrecisionmessagePrefixnetworksEGGzWaves Ducks31472701124131431457333148040314880194405129440771944102694412829441286944129594415409441542	106954752)	106954769	106957828	106960131	1069811379437184943719310485771051904)r   name	countries	certifiedprohas
timeframesurlsr{   
currenciesprecisionModeoptionscommonCurrenciesrequiresEddsa
exceptions)deep_extendsuperr$   describesafe_currency_structureparse_to_intr!   r   r   r    r   r   r   r   r   r   r   )self	__class__s    f/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/wavesexchange.pyr   zwavesexchange.describe   s]   mT : : C C E E!$??? %? 	?
 %? %? U? t? $U?  ? $T? t? (? '? (?  "5!?" #? ?$ +E%?& )%'?( $T)?* '+?, (-?. &t/?0 *:1?2 +D3?4 &u5?6 #E7?8 *59?: $U;?< "5=?> *5??@ +EA?B  C?D %eE? ? ?F "5G?H I?J !%K?L  M?N dO?P +EQ?R "4S?T dU?V !$W?X tY?Z  [?\ $U]?^ !%_?` %ea?b )%c?d te?f g? ?h  $!&"' %$!&#(! }? ? ?B    ~CBHBR[   <6@:JS  1+' .  6   ?:
 ;[0 0dE E EL  : .7Gg gR       '  3<
 ?  !q} }~ d22:hw{  FJ  Y]  Yj  Yj  kn  Yo  Yo  4p  4p  q  q ,"&#59$(,6 $#'$*"#!$""  $ }! ",( ] *	
 * + + . . 9 < < < < <  <!" 0#$ 1000%(%.3  C
\H
 \H
 \ \ \	    c                     |rdnd| j         d<   || j         d<   t          t          |                               |           d S )NTr   r   sandboxMode)r   r   r$   set_sandbox_mode)r   enabledr   s     r   r   zwavesexchange.set_sandbox_mode}  sH    /6(?C_%&-]#mT""33G<<<<<r   symbolc                 B  K   |                                   d {V  |                     |          }|                     ||          }|                     ||          }|                     |d         |d         |||d|          }|                     |           d {V S )NbaseIdquoteId)r   r   	orderTypeamountprice)load_marketsrx   custom_amount_to_precisioncustom_price_to_precisionextend4matcherPostMatcherOrderbookBaseIdQuoteIdCalculateFee)r   r   sider   r   paramsrx   requests           r   get_fees_for_assetz wavesexchange.get_fees_for_asset  s      !!!!!!!!!V$$00@@..vu==++X&i(
 
   NNwWWWWWWWWWr   takerc                   K   |                      ||||           d {V }|                     |dd          }	d }
|	r|                     |d          }
n|                     |d          }
|                     |
d          }|                     |
d          }|                     |          }|                     ||          }|                     |          }|                     |          }|                     ||                     |                    }t          j
        |t          j        ||                    }|||                     |          |                     |          dS )NisDiscountFeeFdiscountbase
matcherFee
feeAssetId)typecurrencyratecost)r   	safe_bool
safe_valuesafe_stringsafe_currency_codecurrency_from_precisionnumber_to_stringfee_to_precisionparse_numberr"   
string_div
string_mul)r   r   r   r   r   r   takerOrMakerr   responser   moder   r   feeAssetadjustedMatcherFeeamountAsStringpriceAsStringfeeCostfeeRates                      r   custom_calculate_feez"wavesexchange.custom_calculate_fee  sr     00vuMMMMMMMM vFF 	5??8Z88DD??8V44D%%dL99
%%dL99
**:66!99(JOO..v66--e44''0A0ABT0U0UVV$%79KN\i9j9jkk  %%g..%%g..	
 
 	
r   c                   K   |                      | j        d          }|r|S |                                  d {V }i }|                      |d          }t          dt	          |                    D ]}d|||         <   || j        d<   |S )Nr   priceAssetsr   T)r   r   matcherGetMatcherSettingsrangelen)r   r   r  r  is        r   
get_quoteszwavesexchange.get_quotes  s      x88 =	M ";;========Hb F//(MBBK1c+..// . .)-{1~&&%+DL"Mr   returnc                   K   |                                   d{V }g }t          dt          |                    D ]0}||         }|                     |d          }|                     |d          }|dz   |z   }|                     |d          }	|	                    d          \  }
}|                     |
          }
|                     |          }|
dz   |z   }|                    i d|d|d|
d	|d
dd|d|dddddddddddddddddddddddddd|                     |d          |                     |d          ddddddddddddddd|d
           2|S )z
        retrieves data on all markets for wavesexchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Nr   amountAssetIDpriceAssetID/r   r   r   quotesettler   r   settleIdr   r(   Tr)   Fr*   r+   r,   activecontractlinearamountAssetDecimalspriceAssetDecimals)r   r   )minmax)leverager   r   r   )
inversecontractSizeexpiryexpiryDatetimestrike
optionTyper   limitscreatedinfo)marketGetTickersr  r  r   splitr   appendsafe_integer)r   r   r  resultr  entryr   r   r   marketIdr   r  r   s                r   fetch_marketszwavesexchange.fetch_markets  s      ..00000000: q#h--(( :	 :	AQKE%%e_==F&&un==G#'B''x88H"..--KD%**400D++E22ECZ%'FMM 0b0&0 0 	0
 $0 &0 70 D0 0 0 %0 0 %0 %0 $0  E!0" $#0$   $"&""//7LMM!..u6JKK   $#! !
  $# 
  $# 
  $#  $  _0 0 0 0 0 0 0b r   Nlimitc                   K   |                                   d{V  |                     |          }|                     |d         |d         d|          }|                     |           d{V }|                     |d          }|                     |                     |d          ||          }|                     |                     |d          ||          }	|||	||                     |          ddS )	a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nr   r   )r   r   	timestampbidsasks)r   r8  r9  r7  datetimenonce)r   rx   r   'matcherGetMatcherOrderbookBaseIdQuoteIdr0  parse_order_book_sider   iso8601)
r   r   r5  r   rx   r   r  r7  r8  r9  s
             r   fetch_order_bookzwavesexchange.fetch_order_bookS  s$      !!!!!!!!!V$$++X&i(
 
   EEgNNNNNNNN%%h<<	))$//(F*K*KVUZ[[))$//(F*K*KVUZ[["Y//
 
 	
r   c                    |d         }|                      | j        dd          }d|                     |d                   z   }|                     |d                   }|                     |d                   }t          j        ||          }	dt          j        ||	          z   }
g }t          dt          |                    D ]}||         }|                      |dd          }|                      |dd          }d }d }|
|t          j        ||
          }||t          j        ||          }|||k    r n>|                    | 	                    |          | 	                    |          g           |S )	Nr   r   r   1er   r   r   0)
r   r   r   r"   
string_subr  r  r  r/  r   )r   bookSiderx   r5  r   r   amountPrecisionamountPrecisionStringpricePrecisionString
differencepricePrecisionr1  r  r2  
entryPriceentryAmountr   r   s                     r   r=  z#wavesexchange.parse_order_book_siden  s   ;'	))$,8H#NN!6!6y7J!K!KK $ 5 5i6I J J#44Yw5GHH'(=?STT
 2>: N NNq#h--(( 	 	AQKE))%#>>J**5(C@@KEF*1G*:~FF++2I +KII!E		MM!!%((!!&))     r   c                    | j         t          | j        dz             | j        t          | j        dz             d }d }	 |                     | j                   }n)# t
          $ r}t          | j        dz             d }~ww xY w	 |                     | j                  }n)# t
          $ r}t          | j        dz             d }~ww xY w|                     |          }|                     |          }t          |          dk    rt          | j        dz             t          |          dk    rt          | j        dz             d S )Nz requires apiKey credentialz requires secret credentialz+ apiKey must be a base58 encoded public keyz, secret must be a base58 encoded private key@   )apiKeyr   r   secretbase58_to_binary	Exceptionbinary_to_base16r  )r   apiKeyBytessecretKeyBytesehexApiKeyByteshexSecretKeyBytess         r   check_required_keysz!wavesexchange.check_required_keys  sv   ;%dg0M&MNNN;%dg0M&MNNN	_//<<KK 	_ 	_ 	_%dg0]&]^^^	_	`!224;??NN 	` 	` 	`%dg0^&^___	`..{;; 11.AA~"$$%dg0]&]^^^ !!R''%dg0^&^___ ('s0   A 
B'A>>BB" "
C,CCru   GETc                    |                      ||                     |                    }|dk    }|                     ||          }| j        d         |         dz   |z   }	|                     |          }
|dk    s|dk    rvddi}|                     | j        d          }|rd	|z   |d
<   |dk    rd|d<   nd|d<   |r|                     |d         g          }d}
t          |
          dk    r|	d|
z   z  }	ni|dk    r$|dk    rddd}|                     |          }nB|}n?|dk    rddi}|                     |          }nddi}t          |
          dk    r|	d|
z   z  }	|	|||dS )Nr   r{   r  rv   rw   Acceptapplication/jsonr   zBearer AuthorizationPOSTzcontent-typez!application/x-www-form-urlencodedorderId r   ?rs   )r[  zContent-Type)urlmethodbodyheaders)	omitextract_paramsimplode_paramsr   urlencode_with_array_repeatr   r   jsonr  )r   pathr{   rc  r   re  rd  queryisCancelOrderrb  queryStringr   s               r   signzwavesexchange.sign  s   		&$"5"5d";";<< FF""400is#c)D066u==9#"2"2,G **4<GGK C+4{+B(*<''*M' !yy%	"2!344 ;!##s[((I0$6  yy''"$6 yy'' #$G {##a''3,,CfdwOOOr   c                   K   |                      | j        d          s1d}d}|                     |                                 |          }t	          |          }d}|                      | j        dd          }|dz   |z   dz   |z   }|                     |                     |                    }||z   }	|                     |                     | j                            }
| 	                    |	|
d          }d	d
| j
        |dz   |z   |d}|                     |           d{V }|                      |d          | j        d<   | j        d         S dS )z
        sign in, must be called prior to using other authenticated methods
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns: response from exchange
        r   ffffff01i:	 z
wx.networkr   r   :ed25519passwordgeneral)
grant_typescopeusernamert  	client_idNaccess_token)r   r   sumsecondsstrrR  encoderP  rO  axolotlrN  privatePostOauth2Token)r   r   prefixexpiresDeltar|  clientIddefaultMessagePrefixmessage
messageHexpayloadhexKey	signaturer   r  s                 r   sign_inzwavesexchange.sign_in  si      m<< 	/F+Lhht||~~|<<G'llG#H#'#3#3DL/SV#W#W *S08;cAGKG..t{{7/C/CDDJz)G**4+@+@+M+MNNFWfi@@I(" K#cMI5% G "88AAAAAAAAH +/*:*:8^*T*TDL'<..tr   rx   c                    |                      |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|          S ) Nr7  r   r  	24h_close	lastPrice24h_lowlow24h_highhigh24h_vwapweightedAveragePrice
24h_volumevolume24h_priceVolumequoteVolume24h_open
firstPricer:  bid	bidVolumeask	askVolumevwapopencloselastpreviousClosechange
percentageaverage)
baseVolumer  r,  )r0  r   safe_marketsafe_string_2safe_tickerr>  )r   tickerrx   r7  r3  r   r  r  r  r  r  r  r  s                r   parse_tickerzwavesexchange.parse_ticker  s   P %%fk::	##FH55!!(FC88!!!&+{CC  E::!!&*f==!!&*6LMM''hGG
((1BMRR!!&*lCC !
f!
!
 Y//!
 D	!

 3!
 4!
 !
 4!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r   c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r   datar   )r   rx   publicGetPairsr   r   	safe_dictr  )	r   r   r   rx   r   r  r  r  
dataTickers	            r   fetch_tickerzwavesexchange.fetch_ticker:  s       !!!!!!!!!V$$VD\
 ,,T[[&-I-IJJJJJJJJ0 x44q"--^^FFB77
  V444r   symbolsc                    K   |                                   d{V  |                     |           d{V }|                     ||          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :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>`
        N)r   r-  parse_tickers)r   r  r   r  s       r   fetch_tickerszwavesexchange.fetch_tickersc  si       !!!!!!!!!..v66666666: !!(G444r   rf   sincec                 (  K   |                                   d{V  |                     |          }|d         |d         |                     | j        ||          d}|                     | j        dd          }||}t          ||          }|                     |          dz  }	|M|                     | 	                                |	z            |	z  }
|dz
  |	z  }|
|z
  }t          |          |d	<   n=t          |          |d	<   |                     ||	|z            }t          |          |d
<   |                     |                     ||                     d{V }|                     |dg           }|                     |||||          }|                     |          }d}t#          |          }t%          dt#          |                    D ]=}||z
  dz
  }||         }|d         }|||d<   ||d<   ||d<   ||d<   |||<   |d         }>|S )aQ  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr   r   )r   r   intervalr   r   i     	timeStarttimeEndr  r            )r   rx   r   r   r0  r   r!  parse_timeframer   millisecondsr}  r{  publicGetCandlesBaseIdQuoteIdr   r   parse_ohlcvsfilter_future_candlesr  r  )r   r   	timeframer  r5  r   rx   r   r   durationdurationRoundedTimestampdeltar  r  r  r  r1  	lastCloselengthr  jr2  r  s                          r   fetch_ohlcvzwavesexchange.fetch_ohlcv  sY      !!!!!!!!!V$$X&i((()YOO
 

 **4<9I4PP="ENE**''	22T9='+'8'89J9J9L9Lx9W'X'X[c'c$QY(*E058I#&y>>GK  #&u::GK hhuh&677G!$WGI;;DKKQW<X<XYYYYYYYY0 x44""4E5II++F33	Vq#f++&& 
	! 
	!A
QA1IE8D|$a$a$a$a!q	aIIr   c                     g }|                                  }t          dt          |                    D ]1}||         d         |k    r n|                    ||                    2|S )Nr   )r  r  r  r/  )r   ohlcvsr1  r7  r  s        r   r  z#wavesexchange.filter_future_candles  sm    %%''	q#f++&& 	% 	%Aay|i''MM&)$$$$r   c           
      X   |                      |di           }|                     |                     |d                    |                     |d          |                     |d          |                     |d          |                     |d          |                     |dd          gS )	Nr  timer  r  r  r  r  r   )r   	parse8601r   safe_number)r   ohlcvrx   r  s       r   parse_ohlcvzwavesexchange.parse_ohlcv  s    & ufb11NN4++D&99::T6**T6**T5))T7++T8Q//
 	
r   r   c                   K   |                                   d{V  |                     | j        di           }|                     |d          }|                     |||          }|                     |dg          }|                                  d{V }i }i }|                     |dg           }	t          dt          |	                    D ]}
|	|
         }|                     |d          }|                     |dg           }t          dt          |                    D ]1}|                     ||          }d||<   ||vri ||<   d||         |<   2||vrTt          |
                                          }t          | j        d	z   |z   d
z   d                    |          z             d}|4d|i}|                     |                     ||                     d{V }n||         }||vrZt          |
                                          }t          | j        dz   |z   dz   |z   dz   d                    |          z             |dk    rWd| j        i}|                     |                     ||                     d{V }|                     |d          }||||d|dS ||d}|                     |                     ||                     d{V }|                     |d          }|                     |d          }|                     | j        di           }|                     |||          }|                     |d          }|                     |d          }|||d||dS )a9  
        fetch the deposit address for a currency associated with self account
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr   networkitemsr   r   r   Tz fetchDepositAddress() - not supported. Currency code must be one of z, r    z	 network z7 deposit address not supported. Network must be one of WAVES	publicKeyaddress)r  r   r   r  tagr,  )r   platformplatform_idnetworkByIdsdeposit_addresses)r  r   r   r  r  r,  )r  r   r   safe_string_upperr   rf  privateGetPlatformsr  r  listkeysr   r   join"privateGetDepositAddressesCurrencyr   rN  "nodeGetAddressesPublicKeyPublicKey*privateGetDepositAddressesCurrencyPlatform)r   r   r   r   
rawNetworkr  supportedCurrenciesr   networksByCurrencyr  r  r2  
currencyIdinnerCurrenciesr  currencyCodecodesr  r   supportedNetworkssupportedNetworkKeysresponseInneraddressInnerr   	networkIdr  unifiedNetworkr   r  s                                r   fetch_deposit_addressz#wavesexchange.fetch_deposit_address  sl      llnn??4<R@@++FI>>
""8ZDD6I;//$($<$<$>$>>>>>>>B 
 3WbAAq#e**%% 		D 		DA!HE))%66J"ooe\2FFO1c/2233 D D#//CC+/
<($(:::79&|4?C"<0<<D 
""**++E*C Cd JM| |  @D  @I  @I  JO  @P  @P  !P  Q  Q  Q?DG "DDT[[QXZ`EaEabbbbbbbbHH 24 8000'+,=,B,B,D,D'E'E$#DGcMG$;k$ID$P  TM  %M  PT  PY  PY  Zn  Po  Po  %o  p  p  p'!! '+&M&MdkkZacjNkNk&l&l l l l l l l#//)DD+  $&)   !% '  "&!P!PQUQ\Q\]dflQmQm!n!nnnnnnn0 ??8Z88$$X}==	t|^RHH)),	9MMOOH.ABB	""9a00%
 
 	
r   c                    K   |                      | j        d          }|r|S |                                  d {V }|dt          |          dz
           | j        d<   | j        d         S )Nr   r  )r   r   matcherGetMatcherr  )r   r   r  s      r   get_matcher_public_keyz$wavesexchange.get_matcher_public_key|  s      ++DL:LMM 	4##!3355555555H/7#h--!:K8K/LDL+,< 233r   c                     |dk    r|                      dd          S |                     |                      dd          |                     |                    S )Nr  r   r  )number_to_bebinary_concatrP  r   r  s     r   get_asset_byteszwavesexchange.get_asset_bytes  sX      $$Q***%%d&7&71&=&=t?T?TU_?`?`aaar   c                     |dk    rdS |S )Nr  r`   r  s     r   get_asset_idzwavesexchange.get_asset_id  s      2r   c                    | j         |         }|                     | j        dd          }|                     |d         d                   }|                     |d         d                   }t	          j        ||          }t	          j        ||          }|                     |t          |                    }	|                     t          |	                    S )Nr   r   r   r   r   )
marketsr   r   r   r"   rC  to_precisionr}  r   float)
r   r   r   rx   r   r   precisionPricerH  r   rI  s
             r   r   z'wavesexchange.custom_price_to_precision  s    f%))$,8H#NN&&vk':8'DEE..vk/B7/KLL'??
&~zBB	**5#i..AA  ~!6!6777r   c           	          |                      |                     ||                      | j        |         d         d                                       }|                     t	          |                    S )Nr   r   )r   r  r  r   r  )r   r   r   rE  s       r   r   z(wavesexchange.custom_amount_to_precision  s    //0A0A&$J_J_`d`lms`t  vA  aB  CK  aL  KM  KM  1N  1N  O  O  !7!7888r   c                     |                      |                     || j        |         d                             }|                     t	          |                    S Nr   )r   r  r   r   r  )r   r   r   networkCoderE  s        r   currency_to_precisionz#wavesexchange.currency_to_precision  sO    //0A0A&$/Z^J_`kJl0m0mnn  !7!7888r   c                     |d S t          |          }|                     |j        |          |_        |                                 t	          |          S N)r"   r{  decimalsreducer}  )r   r   scaleprecises       r   from_precisionzwavesexchange.from_precision  sL    >4&//88G$4e<<7||r   c                 D   |                      |          }t          |          }|                     t          j        |                      |j                  |                      |                              |_        |                                 t          |          }|S r  )r   r"   r   rC  r  r  r}  )r   r   r  amountStringr  stringValues         r   r  zwavesexchange.to_precision  s    ,,V44,'',,W-?@U@UV]Vf@g@gimi~i~  @E  jF  jF  .G  .G  H  H'llr   c                 T    | j         |         d         }|                     ||          S r	  )r   r  )r   r   r   r  s       r   r   z%wavesexchange.currency_from_precision  s)    )+6""65111r   c                     | j         |         }|                     | j        dd          }|                     ||d         d                   |d         d         z
  }|                     ||          S )Nr   r   r   r   r   )r  r0  r   r{  r  )r   r   r   rx   r   r  s         r   price_from_precisionz"wavesexchange.price_from_precision  sl    f%**4<9I1MM)<W)EFFP[I\]eIff""5%000r   c                     |                      |d          }d|v r|                      |d          S |                      |d         d         d          S )NorderFeedynamic	compositedefaultr   )r   settingsr  s      r   safe_get_dynamiczwavesexchange.safe_get_dynamic  sR    ??8Z88  ??8Y777??8K#8#CYOOOr   c                 >    |                      |d          }|ddiS |S )Nratesr  r  r  )r   r  r"  s      r   safe_get_rateszwavesexchange.safe_get_rates  s)    11=Q<r   r   r   r   r   c                 0  K   |                                   |                                  |                                  d{V  |                     |          }|                                  d{V }|                     |d                   }	|                     |d                   }
|dk    }|                     |dd          }|du}|r|t          | j        dz   |z   dz             | 	                                }| 
                    | j        d	d
          }|                     ||          }|                     ||||           d{V }|                     |dd          }|                     |d          }|                     |          }|                     |d          }|                     |d          }|                     |d          }|                     |          }|                     |d          }d}d}d|v s	d| j        v r[|                     |d|                     | j        d                    }|                     |          }|                     |d          }|                                  d{V }|||k    r&||k    r t          | j        dz   |z   dz   |z             |                     |          }||k    r|n|} t)          |                     ||                     }!||v r"||         d         |!k    rt-          |           }nt/          | j        dz             |t)          |                     ||                    }"||v r$||         d         |"k    r|}t-          |          }nJt)          |                     ||                    }#||v r#||         d         |#k    r|}t-          |          }|t/          | j        dz             |                     ||          }|                     ||          }|	|
d}$|                     | j        dd          }%|%rdnd}&| j        ||$|||||t-          |          dd|&d}'|r[ddd |                     ||          id!d"}(|                     |                     t=          j        |(                              |'d#<   |d$k    r||'d%<   |                      |'           d{V })|)d&         d'k    r6|)tC          |)          dz
           d'k    r|)dtC          |)          dz
           })| "                    | #                    | $                    |)                    | #                    | $                    | j%                            d(          }*|*|'d)<   |rG| &                    |'           d{V }+| '                    |+d*          },| (                    |,|          S | )                    |'           d{V }+| '                    |+d*          },| (                    |,|          S )+a  
        create a trade order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fullfilled, 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]: The price at which a stop order is triggered at
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   rx   triggerPrice	stopPricez- createOrder() requires a price argument for zE orders to determine the max price for buy and the min price for sellr   r   r   r   r   r   r  r   z asset fee must be z or freez+ not enough funds of the selected asset feez4 not enough funds on none of the eligible asset feesamountAsset
priceAssetr   FT   W   assetDecimalsr  )senderPublicKeyr   	assetPairr   r   r   r7  
expirationr   	priceModeversionchainIdr  spp)tv)r7  c
attachmentr  matcherFeeAssetIdr   "rs  r  r  )*check_required_dependenciesrX  r   rx   r  r  safe_float_2r   r   r  r0  r   r{  r   safe_value_2r   r   r   r   fetch_balancer  r   intr   r   r   r   rN  binary_to_base58r~  rj  dumps!matcherPostMatcherOrdersSerializer  r  rR  rP  rO  !matcherPostMatcherOrderbookMarketr  parse_ordermatcherPostMatcherOrderbook)-r   r   r   r   r   r   r   rx   r   r)  r*  isMarketOrderr&  isStopOrderr7  defaultExpiryDeltar0  matcherFeesr   baseFeeAssetIdbaseFeeAssetbaseMatcherFeer   discountFeeAssetIddiscountFeeAssetdiscountMatcherFeer:  r   r  feeCurrencybalancesmatcherFeeAssetrawMatcherFeefloatMatcherFeefloatBaseMatcherFeefloatDiscountMatcherFeer/  r   r3  rd  r9  serializedOrderr  r  values-                                                r   create_orderzwavesexchange.create_order  s)      	((***  """!!!!!!!!!V$$!%!<!<!>!>>>>>>>''x(899&&vi'899
)%%fnkJJ	 , 	ktw)XX[__  cj   j  k  k  k%%''	!..t|=WYcddXXi);<<
 33FD&%PPPPPPPP   fjAA))$==..~>>))$==??;
;;!--hEE223EFF!--hEE 
&  jDL&@&@''
D<L<LT\[e<f<fggH--11K $ 0 0d C C++--------(!2227IM^7^7^"47-B#B\#QTZ#Z]m#mnnn"556GHHO/@N/R/RNNYkM#D$@$@R_$`$`aaO8++(?2KF2SWf2f2f //

'2_(_```$"'(D(D\Sa(b(b"c"c((x/Ef/MQd/d/d$2! 00

*/0L0LM]_q0r0r*s*s'$00x@P7QRX7Y]t7t7t(:%!$%7!8!8J$#DG.d$deee00@@..vu==&$
 
	 nnT\=%HH$-""2#{ 0""$j//(
 
  	\ T;;FINN  J "&!6!6t{{4:jCYCY7Z7Z![![D''(9D$% $ F Ft L LLLLLLLA#%%OS=Q=QTU=U,W[^,^,^-aO0D0Dq0H.HIOLL!6!6t7L7L_7]7]!^!^`d`u`uvz  wL  wL  MQ  MX  wY  wY  aZ  aZ  \e  f  f	%[@  	3!CCDIIIIIIIIHNN8Y77E##E6222!==dCCCCCCCCHNN8Y77E##E6222r   r   c                   K   |                                   |                                  |                                  d{V  |                                  d{V }|                     ||d           d{V }|                     |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iS )aD  
        cancels an open order
        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        N)r   r_  r  r   r_  r,  r   clientOrderIdr7  r:  lastTradeTimestampr   r   r   r   r   r   r  filled	remainingstatusfeetrades)r<  rX  r  get_waves_address*forwardPostMatcherOrdersWavesAddressCancelr   r   )
r   r   r   r   r   r  r  firstMessage
firstOrder
returnedIds
             r   cancel_orderzwavesexchange.cancel_ordert  s      	((***  """llnn!3355555555HH(J
 J
         //(I66w22__\155
%%j)<<

H
*
 T
 	

 
 !$
 f
 D
 D
 T
 d
 D
 t
 d
 
  d!
" 4#
$ d%
 
 	
r   c                   K   |                                   |                                  |                                  d{V  d}||                     |          }|                                 }|                     | j                  |                     |d          g}|                     |          }| 	                    |                     | j
                            }|                     | 	                    |          |d          }	t          |          |	| j        |d}
|                     |                     |
|                     d{V }|                     ||          S )a?  
        fetches information on an order made by the user
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   rs  )	Timestamp	Signaturer  r_  )r<  rX  r   rx   r  rP  rN  r  binary_concat_arrayrR  rO  r  r}  *matcherGetMatcherOrderbookPublicKeyOrderIdr   rE  )r   r   r   r   rx   r7  	byteArraybinary	hexSecretr  r   r  s               r   fetch_orderzwavesexchange.fetch_order  sr      	((***  """!!!!!!!!![[((F%%''	!!$+..i++
	 )))44))$*?*?*L*LMM	LL!6!6v!>!>	9UU	Y"	
 
 HHU\^dIeIeffffffff&111r   c                 "  K   |                                   |                                  |t          | j        dz             |                                  d{V  |                     |          }|                                 }|                     | j                  | 	                    |d          g}| 
                    |          }|                     |                     | j                            }	|                     |                     |          |	d          }
dt          |          |
| j        |d         |d         d}|                     |                     ||                     d{V }|                     ||||          S )	a  
        fetches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) fetchOrders() requires a symbol argumentr   rs  r\  r   r   )r[  rj  rk  r  r   r   )r<  rX  r   r   r   rx   r  rP  rN  r  rl  rR  rO  r  r}  9matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKeyr   parse_orders)r   r   r  r5  r   rx   r7  rn  ro  rp  r  r   r  s                r   fetch_orderszwavesexchange.fetch_orders  s      	((***  """>#DG.Y$YZZZ!!!!!!!!!V$$%%''	!!$+..i++
	 )))44))$*?*?*L*LMM	LL!6!6v!>!>	9UU	(Y"X&i(
 
 WWX\XcXcdkmsXtXtuuuuuuuu    65%@@@r   c                 D  K   |                                   d{V  |                                  d{V  d}||                     |          }|                                  d{V }|dd}|                     |           d{V }|                     ||||          S )a  
        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        NT)r  
activeOnlyr   r  rx   rc  forwardGetMatcherOrdersAddressrt  	r   r   r  r5  r   rx   r  r   r  s	            r   fetch_open_orderszwavesexchange.fetch_open_orders  s       !!!!!!!!!llnn[[((F..00000000
 
 <<WEEEEEEEE  65%@@@r   c                 D  K   |                                   d{V  |                                  d{V  d}||                     |          }|                                  d{V }|dd}|                     |           d{V }|                     ||||          S )a  
        fetches information on multiple closed orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        NT)r  
closedOnlyrx  rz  s	            r   fetch_closed_ordersz!wavesexchange.fetch_closed_orders  s       !!!!!!!!!llnn[[((F..00000000
 
 <<WEEEEEEEE*   65%@@@r   c                 >    ddddd}|                      |||          S )Ncanceledr  closed)	CancelledAcceptedFilledPartiallyFilled)r   )r   r`  statusess      r   parse_order_statusz wavesexchange.parse_order_status1  s4    #%	
 
 &&999r   c                     |                      |dd          }|                      |dd          }|                     |          dz   |                     |          z   S )Nr)  r  r*  r  )r   r   )r   r/  r   r   s       r   get_symbol_from_asset_pairz(wavesexchange.get_symbol_from_asset_pair:  s\    !!)]GDD""9lGDD&&v..4t7N7Nw7W7WWWr   c           
         |                      |d          }|                     |dd          }d}d|v r|                     |d|          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d	          }
d }|
|                     |
          }n
||d
         }|                     |                     |
dd                    }|                     ||          }|                     ||	          }|                     ||          }|                     ||                     |d                    }|                     |                     |d                    }d }d|v rj|                     |                     |d                    }|| 	                    |                     ||                     |d                              d}nj|                     |                     |dd                    }|| 	                    |                     ||                     |d                              d}d }|                     |d          }|| 
                    |                     |                     |                              }|F|                     |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#|          S )$Nr7  r   r   r5  r   r^  r   r   r/  r   r)  r  avgWeighedPricer`  r  	filledFee)r   ra  r:  r   r9  r8  r7  r5  r,  r\  r:  r]  timeInForcepostOnlyr   r&  r%  r   r  )r^  r_  r`  ra  rb  )r0  r  r   r   r  r   r  r   r  r   
parse_jsondecoderP  
safe_orderr>  )r   orderrx   r7  r   r   r   filledStringpriceStringr  r/  r   amountCurrencyr   r   r^  r  r`  ra  r   r%  r9  decodedAttachmentr8  r7  s                            r   rE  zwavesexchange.parse_order@  s,   j %%e[99	!!%==U??##E;==DeT**''x88&&ug66''x88OOE;77	 44Y??FFH%F001A1A)]\c1d1dee))&+>>--nlKK--nlKK++FD4D4DUL]4^4^__(()9)9%)J)JKKU??..t/?/?z/R/RSSH$(()E)EhPTP`P`afhsPtPt)u)uvv CC
 ..t/?/?GZ\c/d/deeH$(()E)EhPTP`P`afhtPuPu)v)vww C %%e\::
! $D<Q<QR\<]<]0^0^ _ _ ,OO$5s;;=3//A}'+'7'73'?'?  
E 
" 
 T 
 	 

 Y// 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
  
 L 
 f 
  D! 
" w# 
$ - 
  
  
. /  	r   c                    K   |                      | j        d          }|Od| j        i}|                     |           d {V }|                      |d          | j        d<   | j        d         S |S )Nr   r  r  )r   r   rN  r  )r   cachedAddreessr   r  s       r   rc  zwavesexchange.get_waves_address  s      ))$,GG!T[G "DDWMMMMMMMMH+/+;+;Hi+P+PDL(<//!!r   c                   K   |                                   |                                  |                                  d{V  |                                  d{V }d|i}|                     |           d{V }|                     |dg           }i }d}g }g }	t          dt          |                    D ]}
||
         }|                     |d          }||nt          ||          }|                     |d          }| 
                    |d          }| 
                    |d          }|+|                    |           |	                    |           |                     |d	          }d}|| j        v rK|                     |          }|                                 ||<   |                     ||          ||         d
<   t          |          }|rd|i}|                     |           d{V }|                     |dg           }t          dt          |                    D ]}
||
         }|	|
         }|                     |d          }|                     |d          }| 
                    |d          }|                     |          }|                                 ||<   |                     ||          ||         d
<   |                                 }|                     | j                  |                     |d          g}|                     |          }|                     |                     | j                            }|                     |                     |          |d          }| j        |t3          |          d}|                     |           d{V }t7          |                                          }t          dt          |                    D ]}
||
         }|                     |          }||vr|                                 ||<   | 
                    ||          } || j        v r |                     ||           ||         d<   y| ||         d<   d|i}!|                     |!           d{V }"|                     |di           |d<   |                     d| 
                    |"d                    |d         d
<   t7          |                                          }#t          dt          |#                    D ]1}
|#|
         }|                     ||         d          d||         d<   2||d<   |                      |          |d<   | !                    |          S )a!  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        Nr  rR  r   r7  issueTransactionassetIdbalancer  totalidsr  r   r  r   rs  )r  r  r7  usedr  rB  r:  )"r<  rX  r   rc  nodeGetAssetsBalanceAddressr   r  r  r0  r"  r   r/  currencies_by_idr   accountr  publicGetAssetsr  rP  rN  r  rl  rR  rO  r  r}  )matcherGetMatcherBalanceReservedPublicKeyr  r  r   r   nodeGetAddressesBalanceAddressr>  safe_balance)$r   r   r   r   totalBalancerR  r1  r7  assetIdsnonStandardBalancesr  r2  entryTimestampr  r  r  r  r   nonStandardAssetsrequestInnerr  r  innerr  currentTimestamprn  ro  rp  r  matcherRequestreservedBalancereservedKeysr   wavesRequest
wavesTotalr  s$                                       r   r?  zwavesexchange.fetch_balance  s      	((***  """!!!!!!!!!!3355555555|
 "==gFFFFFFFFF ??<R@@	 q#h--(( 	O 	OAQKE!..ukBBN+4+<3yR`CaCaI#u6HII))%;;J&&ui88G'
+++#**7333(()9:FFHDT222..z::#||~~t(,(;(;GX(N(NtW%MM 	OxL "11,????????H??8VR88D1c$ii(( O OQ-a0v66,,UK@@))%::..v66#||~~t(,(;(;GX(N(NtW%%,,..!!$+...22
	 )))44))$*?*?*L*LMM	LL!6!6v!>!>	9UU	"-..
 

 !% N N~ ^ ^^^^^^^O002233q#l++,, 		. 		.A%aJ**:66DFNN#||~~t%%ozBBFt&&'+'C'CD&'Q'QtV$$'-tV$$|
  >>|LLLLLLLL
 //&'2>>w#'#?#?IYIYZdfoIpIp#q#qw V[[]]##q#e**%% 	+ 	+A8Dvd|V44<'*tV$'{!\\)44z  (((r   c                 f  K   |                                   d{V  |                                  d{V }d|i}d}|+|                     |          }|d         |d<   |d         |d<   |                     |           d{V }|                     |d          }	|                     |	|||          S )a  
        fetch all trades made by the user
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nsenderr   r)  r   r*  r  )r   rc  rx   publicGetTransactionsExchanger   parse_trades)
r   r   r  r5  r   r  r   rx   r  r  s
             r   fetch_my_tradeszwavesexchange.fetch_my_tradesQ  s       !!!!!!!!!..00000000g
 [[((F%+H%5GM"$*9$5GL!;;GDDDDDDDDx00F   vue<<<r   c                 P  K   |                                   d{V  |                     |          }|d         |d         d}|t          |d          |d<   |||d<   |                     |           d{V }|                     |d          }|                     ||||          S )	a  
        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        Nr   r   r(  d   r5  r  r  )r   rx   r!  r  r   r  )	r   r   r  r5  r   rx   r   r  r  s	            r   fetch_tradeszwavesexchange.fetch_trades  s       !!!!!!!!!V$$!(+ +
 
 "5#GG#(GK ;;GDDDDDDDDx00F   vue<<<r   c                 B   |                      |d          }|                     |d          }|                     |          }|                     |d          }|                     |d          }|                     |d          }|                      |d          }	|                      |d          }
d }|                     |	d          | j        k    r|	}n|
}d }|                      |d	          }||                     |          }n
||d
         }|                     |d          }|                     |d          }|                     |d          |                     |                     |dd                    d}|                     ||||||d |d ||d |d|          S )Nr  r7  r   r   r   order1order2r.  r/  r   r   r   r:  r  )r   r   )r,  r7  r:  r   r   r  r   r   r  r   r   r   ra  )r   r   r  rN  r  r   
safe_trade)r   traderx   r  r:  r7  r   r  r  r  r  r  r   r/  r   r_  ra  s                    r   parse_tradezwavesexchange.parse_trade  s   ^ uf--##D+66NN8,,	dD))&&tW55''h77x00x00F$566$+EEEEEOOE;77	 44Y??FFH%F{33""5$//$$UL99//0@0@H[]d0e0eff
 
 "   " 
  
   	r   r  c                 t   i }|                      |          }t          dt          |                    D ]}||         }|}|                     ||          }|                     | j        |          }	|                     |	d|          }
||                     |
|          r|                     ||
          }||gd d dd d di d}n(||
         }|                     |d         |g          |d<   |                     |d          }|                     |	d          }|                     ||          }|                     |d         |          }|d d dd d dd}|                     |d	          }|                     |d
          }d}|dk    rd}| 	                    |d          dd||<   ||d         |<   |||
<   t          |                                          }t          dt          |                    D ]}||         }
||
         }|                     |d          }t          |                                          }t          |          }|dk    rZ|                     ||d                   }|                     |d          ||
         d<   |                     |d          ||
         d<   |S )Nr   r   )ra  r  )r,  rd   depositr   r,  r  r   )rd   r  r   feesr  withdrawal_currencyrd   flatFr  )market_codesr  r  r   r   r  in_arrayarray_concatnetwork_id_to_coder  r  r  )r   r  r  currencyIdKeydepositWithdrawFeesr  r2  
dictionaryr  r   r   depositWithdrawFeer  r  r
  r  feeTyper  
networkKeydepositWithdrawFeesKeysr   networkKeysnetworkKeysLengths                          r   parse_deposit_withdraw_feesz)wavesexchange.parse_deposit_withdraw_fees\  s'    !!%((q#h--(( .	? .	?AQKEJ))*mDDJt'<jIIH##HfjAAD4==u#=#=%)__5H$%O%O"%-!+#'*.% %
 $(*.$ $ %'* *&& *=T)B&151B1BCUV\C]`j_k1l1l&v. ,,ZGG	#//&AA"55iNN//*<Z*H+VV? $(*.% %
 $(*.$ $	 	G **:v>>z6::&
333!+J.2.>.>tV.L.L\a&b&b
#>E":.{;,>#D)"&':'?'?'A'A"B"Bq#56677 		[ 		[A*1-D'-Euj99Hx}}//K #K 0 0 A%%//(KNCC8<Q[8\8\#D)*57;wPY7Z7Z#D))4""r   c                   K   |                                   d{V  g }g }|                    |                     |                     |                    |                     |                     t	          j        |  d{V }t          dt          |                    D ]4}|                     ||         d          }| 	                    ||          }5| 
                    ||d          S )a  
        fetch deposit and withdraw fees
        :see: https://docs.wx.network/en/api/gateways/deposit/currencies
        :see: https://docs.wx.network/en/api/gateways/withdraw/currencies
        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
        Nr   r  r   )r   r/  privateGetDepositCurrenciesprivateGetWithdrawCurrenciesasynciogatherr  r  r   r  r  )r   r  r   r  promisesr  r  s          r   fetch_deposit_withdraw_feesz)wavesexchange.fetch_deposit_withdraw_fees  s       !!!!!!!!!88@@AAA99&AABBB 2222222r q#h--(( 	2 	2AOOHQK99E$$T511DD//eTBBBr   c
                    |                      |d          }
|                     |dd          }|                     | j        |
          }|,|                      |d          } || j        dz   |z             |                      |d          }|dk    rt          | j        dz   |z             |st          | j        dz   |z             d S )NerrorsuccessTr  r  zValidation Error)r   r   r   r   r   r   r   )r   r   reasonrb  rc  re  rd  r  requestHeadersrequestBody	errorCoder  rQ  messageInnerr  s                  r   handle_errorszwavesexchange.handle_errors  s    $$Xw77	..9d;;OODOY??	 ++Hi@@L)DGcML8999""8Y77(((TWs]T1222 	6# 4555tr   c                 Z	  K   |                      ||          \  }}|dk    r|                                  d{V }i }|                     |dg           }t          dt	          |                    D ]%}	||	         }
|                     |
d          }d||<   &||vrNt          |                                          }t          | j	        dz   |z   dz   t          |          z             |                                  d{V  g d	}i }t          dt	          |                    D ]}	||	         }d||<   d}|                     |          }|                                }t	          |          d
z  }t          d|          D ]}	||	         }||vrd} n|                                  d{V  d}|dk    r|s|}n||d}|                     |           d{V }|                     |d          }|                     |d          }|                     |d          }||k    r@t#          | j	        dz   |z   dz   t          |          z   dz   t          |          z             |                     |dg           }|                     |d          }|                     | j        dd          }d}d}d}|                     ||          } |                     |          }!|                                 }"|                     dd
          |                     dd
          |                     | j                  |                     |!d                   |                     |          |                     |"d          |                     | d          |                     |d          |                     |          |                     dd          g
}#|                     |#          }$|                     |                     | j                            }%|                     |                     |$          |%d          }&| j        | |||d|                     |          |&g|                     |!d                   ||"|&d}'|                      |'           d{V }(| !                    |(|!          S )a  
        make a withdrawal
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        r  Nr  r   r   Tz withdraw() r  )rB  123r   567r   9abr8  drU  fr  F)r  r   r   allowed_amountr!  r  z withdraw failed, amount z4 must be greater than the minimum allowed amount of proxy_addressesr   r   r  r  r   rs  r`  )r.  r   ra  r   r2  r9  r   proofsr  	recipientr7  r  )"handle_withdraw_tag_and_paramsr  r   r  r  r   r  r  r   r   r}  r   remove0x_prefixlowerr  *privateGetWithdrawAddressesCurrencyAddressr  r   r0  r   r  r   r  r  rP  rN  r  rl  rR  rO  r  r  nodePostTransactionsBroadcastparse_transaction))r   r   r   r  r  r   r  r   r  r  r2  r  r  hexCharssetkeyisErc20noPrefixr  stringLength	characterproxyAddresswithdrawAddressRequestwithdrawAddresscurrencyInnerallowedAmountminimumproxyAddressesra  r   r   r2  amountIntegerr   r7  rn  ro  rp  r  r   r1  s)                                            r   rd   zwavesexchange.withdraw  s^      99#vFFV7??(,(I(I(K(K"K"K"K"K"K"KJOO$7"EEE1c%jj)) 0 0a#//t<<+/
<((J&&Z__..//#DGn$<t$CFu$ux{  }B  yC  yC  %C  D  D  D!!!!!!!!!cccq#h--(( 	 	A1+CCHH''00  5zzA~q,'' 	 	AaI$$ % llnn7??7?"LL # & &" %)$S$STj$k$kkkkkkkO OOOZHHM OOM;KLLM&&}e<<G   3!58S!SVYZ`VaVa!a  e[  "[  ^a  bi  ^j  ^j  "j  k  k  k, "___>OQSTTN++NA>>L.@&II
224@@==&&%%''	a##a##!!$+..  $00  ,,i++mQ//c1%%!!,//a##
	 )))44))$*?*?*L*LMM	LL!6!6v!>!>	9UU	#{#++J77 (($88%""
 
  99'BBBBBBBB %%fh777r   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 d |dS )Nr   txidr7  r:  r  addressFromr  	addressTor   r   r   r   r`  updatedtagFromr  tagTocomment)internalra  r,  )safe_currency)r   transactionr   s      r   r  zwavesexchange.parse_transactiont	  s
    %%dH55
$
D
 
 	

 t
 4
 t
 
 d
 D
 (
 d
 t
 t
 4
  T!
" t#
$ )
 
 
 	
r   )NNr  )I__name__
__module____qualname__r   r   r}  r   r  r  r   r   r4  r   r   r?  r=  rX  ro  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	   rZ  r   rh  rq  r
   ru  r{  r~  r  r  rE  rc  r   r?  r  r   r  r  r   r  r  r  rd   r   r   r  __classcell__)r   s   @r   r$   r$      sb       ] ] ] ] ]~
= = = = =
 QS X Xs X X X X _fnp 
 
 
 
 
 
B? ? ?B *, _ _V _ _ _ _B @DB 
 
S 
 
S\ 
 
 
 
6 #    6` ` `, &eBSW +P +P +P +PZ $& " " " "HH H6 HV H H H HT 68 '5 '5 '5F '5 '5 '5 '5R 6:" %5 %57 %5 %5 %5 %5 %5N 8<$]ajl G G GC GWZ Gquvzq{ G G G GR  
 
 
4 
 
 
 
: =? @
 @
 @
 @
 @
 @
D	4 	4 	4b b b  
8 8 89 9 99 9 9 9    2 2 21 1 1P P P   mqy{ f3 f3 f3I f3Y f3X] f3fi f3 f3 f3 f3P 9=R ,
 ,
S ,
# ,
 ,
 ,
 ,
\ 8<B 2 2C 2 2 2 2 2< 04$UYbd /A /A /AC /As /Aimnsit /A /A /A /Ab 59tZ^gi A Ac A ATW Anrsxny A A A A, 7;\`ik (A (A (A3 (AVY (Aptuzp{ (A (A (A (AT: : :X X Xy y y5 y y y yv
" 
" 
" *, H) H) H) H) H) H)T 37TX\eg W= W=C W=s W=RU W= W= W= W=r <@d[] W= W= W=S W= W=bfglbm W= W= W= W=rW W W5 W W W Wr=# =#7 =#be =# =# =# =#~ BFb JC JCw JC JC JC JCX   EIQS }8 }83 }8 }8 }8 }8 }8~#
 #
x #
; #
 #
 #
 #
 #
 #
 #
 #
r   r$   )* ccxt.async_support.base.exchanger   ccxt.abstract.wavesexchanger   r  rj  ccxt.base.typesr   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   r   r   r   r    ccxt.base.decimal_to_precisionr!   ccxt.base.preciser"   r$   r   r   r   <module>r      sW   6 5 5 5 5 5 3 3 3 3 3 3   \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \             * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * - - - - - - 1 1 1 1 1 1 9 9 9 9 9 9 % % % % % %{%
 {%
 {%
 {%
 {%
Hk {%
 {%
 {%
 {%
 {%
r   