
    ei4                    8   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ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)AnyBalancesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)DuplicateOrderId)ExchangeNotAvailable)	TICK_SIZE)Precisec                       e Zd Zdef 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dUdefdZd Zddi d
d
fdZi fdZdVded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de
e         f
dZd ZdVdedefdZi fdedefd Z d! Z!d" Z"d# Z#dVded$e$fd%Z%ded&efd'Z&ded(e$fd)Z'ded*efd+Z(ded$e$fd,Z)ded&efd-Z*d. Z+d/ Z,d
i fded0e-d1e.d$e$d(e/f
d2Z0d
i fd3ede1fd4Z2d
i fd3ede1fd5Z3d
d
d
i fde1dedede
e4         fd6Z5d
d
d
i fde1dedede
e4         fd7Z6d
d
d
i fde1dedede
e4         fd8Z7d9e1fd:Z8d; Z9dVd<edede4fd=Z:d> Z;i fde<fd?Z=dWdAZ>d
d
d
i fde1dedefdBZ?d
d
i fdededede
e@         fdCZAdVdDedede@fdEZBdUdFedefdGZCd
i fdFefdHZDdeEdIedJedKedLedMefdNZFd
i fded$e$dOedPe1deGf
dQZHdVdRedSeIdeGfdTZJ xZKS )Xwavesexchange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d/d d0d i d1d2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dvdwdxdydzd{d|d}d~ddddddddddddddddddddddg ddddg dg dddgdgdi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddg dddgddg dig ddgdddgdgdddgiddd|                     dd d|                     d          d          idt          ddd dd d dd dddddd dddddddd ddd dddddddddddddd dddddddddddddddddddd d dddd	ddddddddd
dd id	d d dd d dddddidddi dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          d t          d!t          d"t          d#t          d$t          t          t          t          t          t          t           t          t          d%i          S (&  Nidr%   namezWaves.Exchange	countriesCH	certifiedFprodexT	rateLimit
   hasCORSspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTransferfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdrawws
timeframes1m5m15m30m1h2h3h4h6h12h1d1w1M)r   r   r   r   r   r   r   r   r   r   r   r   r   urlszchttps://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/v1)zhttps://docs.wx.networkzhttps://docs.waves.techz&https://api.wavesplatform.com/v0/docs/z0https://nodes.wavesnodes.com/api-docs/index.htmlz2https://matcher.waves.exchange/api-docs/index.htmlzhttps://wx.network)logotestapidocwwwr   )r   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	addresses   zaddresses/balance/{address}   z+addresses/balance/{address}/{confirmations}z#addresses/balance/details/{address}addresses/data/{address}g@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}d   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
currenciesWX,EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc1e-8)r(   	numericIdcode	precisionprecisionModeoptions      d  i  順 g:0yE>WETHBSC)ERC20BEP20)allowedCandlesaccessToken!createMarketBuyOrderRequiresPricematcherPublicKeyquotescreateOrderDefaultExpirywavesAddresswithdrawFeeUSDNwithdrawFeeWAVESwavesPrecisionmessagePrefixnetworksfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg)r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   r   )	r   r@   createOrdersrr   rz   rw   r|   rM   rs   )linearinverse)r3   r5   r6   commonCurrenciesEGGzWaves DucksrequiresEddsa
exceptions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)deep_extendsuperr%   describesafe_currency_structureparse_numberr"   r   r   r!   r   r    r   r   r   r   r   )self	__class__s    P/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/wavesexchange.pyr  zwavesexchange.describe   sn   mT : : C C E E ZH
/ZH
$ZH
 $ZH
 	ZH

 5ZH
 4ZH
 ZH
  ggg %g 	g
 %g %g Ug $Ug 'g g tg $Ug  g $Tg tg  (!g" '#g g$ (%g& "5'g( !%)g* +g, &u-g. "5/g0 +E1g2 )%3g4 #E5g6 ,U7g8 $T9g: ';g< (=g> "5?g@ &tAgB (CgD 1$Eg g gF *:GgH +DIgJ &uKgL 'MgN (OgP #EQgR *5SgT $UUgV uWgX "5YgZ *5[g\ +E]g^ )%_g`  agb !%cgd %eegf $Ugg g gh &uigj -ekgl /mgn "5ogp #Eqgr +Esgt ugv !%wgx !%ygz "5{g| &u}g~ +Eg@  AgB dCgD $UEgF +EGgH %eIg g gJ "4KgL uMgN #EOgP dQgR !$SgT tUgV  WgX 'YgZ $U[g\ !%]g^ *5_g` (agb %ecgd )%egf )%ggh tigj kg g gl tmgn  ogp !%qgr (sgt )%ugv wgx #Eygz &u{g| 4}g~ ug@ UAgB  CgD "5EgF $GgH EIgJ DKgL eMg gZH
`  aZH
~ }CBHBR[   <6@:JS    ,3 ZH
t   6   ?:
 ;[0 0dE#QE5qE FqE >q	E
 3HE 9(E ?E OPQE :1E 9!E >qE 3AE 4QE 7E 5aE  1!!E" I(#E E$ 3H%E& =a'E( 3A)E* =a+E, -a-E. 4Q/E0 @1E2 -c3E4 >q5E6 '7E8 .q9E: 9!;E< (=E> 4Q?E@ &qAEB 1#CED 7EE E EF )!GEH /IEJ 9!KEL @MEN 8OEP B1QER ;ASET 1!UEV +AWEX ,QYEZ %a[E\ *1]E^ 5a_E` &qaEb ?cEd 7eEf 4QgE E Eh 3AiEj %akEl 'mEn $QoEp ,QqEr *1sEt *1uEv GwEx 1!yEz .q{E| 3A}E~ =aE@ 8AEB %aCED .qEEF %aGEH &qIE EL  : .7Gg gR       '  3<
 ?  !q} }uZH
p
 d22:hw{  FJ  Y]  Yj  Yj  kq  Yr  Yr  4s  4s  t  tq
ZH
v
 Yw
ZH
x
 "&#59$(,6 $#'$*"&!$""  y
ZH
Z #&+(,,1,0).+06:#(#("'#'	( ( #($)$)+026/4#()$ $, %)&+!$$*%+*/& & ',#($)*/	# # ',!$#($)*/( ( ',!$$(%)#($)*.$ $ ',!$$*,-%+#($)*/	* 	*  #AC CJ ## 
 ## SM M[ZH
v }!wZH
| T}ZH
~  ,( ] *	
 * + + . . 9 < < < < <  <!" 0#$ 1000%(%.3  ZH
 ZH
 Z Z Z	    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                 &   |                                   |                     |          }|                     ||          }|                     ||          }|                     |d         |d         |||d|          }|                     |          S )NbaseIdquoteId)r,  r-  	orderTypeamountprice)load_marketsr   to_real_symbol_amountto_real_symbol_priceextend4matcherPostMatcherOrderbookBaseIdQuoteIdCalculateFee)r!  r*  sider/  r0  paramsr   requests           r#  get_fees_for_assetz wavesexchange.get_fees_for_asset  s    V$$++FF;;))&%88++X&i(
 
   HHQQQr$  takerc                    |                      ||||          }|                     |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)r9  	safe_bool
safe_valuesafe_stringsafe_currency_codefrom_real_currency_amountnumber_to_stringfee_to_precisionr   r#   
string_div
string_mul)r!  r*  rA  r6  r/  r0  takerOrMakerr7  responser<  moder?  r@  feeAssetadjustedMatcherFeeamountAsStringpriceAsStringfeeCostfeeRates                      r#  custom_calculate_feez"wavesexchange.custom_calculate_fee  s\   **64GG vFF 	5??8Z88DD??8V44D%%dL99
%%dL99
**:66!;;HjQQ..v66--e44''0A0ABT0U0UVV$%79KN\i9j9jkk  %%g..%%g..	
 
 	
r$  c                    |                      | j        d          }|r|S |                                 }i }|                      |d          }t          dt	          |                    D ]}d|||         <   || j        d<   |S )Nr   priceAssetsr   T)rF  r   matcherGetMatcherSettingsrangelen)r!  r   rO  rY  is        r#  
get_quoteszwavesexchange.get_quotes-  s    x88 =	M 5577Hb F//(MBBK1c+..// . .)-{1~&&%+DL"Mr$  c                 h   |                                  }g }t          dt          |                    D ]|}||         }|                     |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
           ~|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
        r   amountAssetIDpriceAssetID/r*  r(   r>  quotesettleNr,  r-  settleIdrA  r3   Tr4   Fr5   r6   r7   activecontractr   amountAssetDecimalspriceAssetDecimals)r/  r0  )minmax)r   r/  r0  rD  )
r   contractSizeexpiryexpiryDatetimestrike
optionTyper   limitscreatedinfo)	marketGetTickersr[  r\  rG  splitrH  appendr   parse_precision)r!  r7  rO  resultr]  entryr,  r-  r(   marketIdr>  rc  r*  s                r#  fetch_marketszwavesexchange.fetch_marketsn  s    ((**: 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$   $"&""//0D0DTEUEUV[]rEsEs0t0tuu!..t/C/CDDTDTUZ\pDqDq/r/rss   $#! !
  $# 
  $# 
  $#  $  _0 0 0 0 0 0 0b r$  Nr   c                    |                                   |                     |          }|                     |d         |d         d|          }|                     |          }|                     |d          }|                     |                     |d          ||          }|                     |                     |d          ||          }	|||	||                     |          ddS )	aD  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://matcher.waves.exchange/api-docs/index.html#/markets/getOrderBook

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        r,  r-  )r,  r-  	timestampbidsasksN)r*  r~  r  r}  datetimenonce)r1  r   r4  'matcherGetMatcherOrderbookBaseIdQuoteIdsafe_integerparse_order_book_siderF  iso8601)
r!  r*  r   r7  r   r8  rO  r}  r~  r  s
             r#  fetch_order_bookzwavesexchange.fetch_order_book  s     	V$$++X&i(
 
   ??HH%%h<<	))$//(F*K*KVUZ[[))$//(F*K*KVUZ[["Y//
 
 	
r$  c                    |d         }|                      | j        dd          }|                      |d          }|                      |d          }t          j        ||          }t          j        ||          }	g }
t	          dt          |                    D ]}||         }|                      |dd          }|                      |dd          }d }d }|	|t          j        ||	          }||t          j        ||          }|||k    r n>|
                    |                     |          |                     |          g           |
S )Nr   r   r   r/  r0  r   0)	rG  r   r#   rL  r[  r\  rM  rv  r   )r!  bookSider   r   r   r   amountPrecisionStringpricePrecisionString
differencepricePrecisionrx  r]  ry  
entryPriceentryAmountr0  r/  s                    r#  r  z#wavesexchange.parse_order_book_side  st   ;'	))$,8H&QQ $ 0 0H E E#//	7CC'(=?STT
 +NJGGq#h--(( 	 	AQKE))%#>>J**5(C@@KEF*1G*:~FF%18O +K9NOO!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@   T)apiKeyr   r(   secretbase58_to_binary	Exceptionbinary_to_base16r\  )r!  apiKeyBytessecretKeyBytesehexApiKeyByteshexSecretKeyBytess         r#  check_required_keysz!wavesexchange.check_required_keys  ss   ;%dg0M&MNNN;%dg0M&MNNN	_//<<KK 	_ 	_ 	_%dg0]&]^^^	_	`!224;??NN 	` 	` 	`%dg0^&^___	`..{;; 11.AA~"$$%dg0]&]^^^ !!R''%dg0^&^___ts0   A 
B'A>>BB" "
C,CCr   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   rb  r   r   Acceptapplication/jsonr   zBearer AuthorizationPOSTzcontent-typez!application/x-www-form-urlencodedorderId r   ?r   )r  zContent-Type)urlmethodbodyheaders)	omitextract_paramsimplode_paramsr   urlencode_with_array_repeatrG  r   jsonr\  )r!  pathr   r  r7  r  r  queryisCancelOrderr  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                    |                      | j        d          s+d}d}|                     |                                 |          }t	          |          }d}|                      | j        dd          }|dz   |z   dz   |z   }|                     |                     |                    }||z   }	|                     |                     | j                            }
| 	                    |	|
d          }d	d
| j
        |dz   |z   |d}|                     |          }|                      |d          | j        d<   | j        d         S dS )a  
        sign in, must be called prior to using other authenticated methods

        https://docs.wx.network/en/api/auth/oauth2-token

        :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usernamer  	client_idaccess_tokenN)rG  r   sumsecondsstrr  encoder  r  axolotlr  privatePostOauth2Token)r!  r7  prefixexpiresDeltar  clientIddefaultMessagePrefixmessage
messageHexpayloadhexKey	signaturer8  rO  s                 r#  sign_inzwavesexchange.sign_inK  sS    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 227;;H +/*:*:8^*T*TDL'<..tr$  tickerr   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 ) Nr}  r*  rb  	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  rs  )r  rG  safe_marketsafe_string_2safe_tickerr  )r!  r  r   r}  rz  r*  r  r  r  r  r  r  r  s                r#  parse_tickerzwavesexchange.parse_tickerr  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                 p   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |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

        https://api.wavesplatform.com/v0/docs/#/pairs/getPairsListAll

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        r   r(   datar   )r1  r   publicGetPairsr4  rF  	safe_dictr  )	r!  r*  r7  r   r8  rO  r  r  
dataTickers	            r#  fetch_tickerzwavesexchange.fetch_ticker  s     	V$$VD\
 &&t{{7F'C'CDD0 x44q"--^^FFB77
  V444r$  symbolsc                     |                                   |                     |          }|                     ||          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :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>`
        )r1  rt  parse_tickers)r!  r  r7  rO  s       r#  fetch_tickerszwavesexchange.fetch_tickers  sA     	((00: !!(G444r$  r   	timeframesincec                    |                                   |                     |          }|d         |d         |                     | j        ||          d}|                     | j        dd          }|                     |d          }	|	du}
||}t          ||          }|                     |          dz  }|i|                                 }|
r|	n|}| 	                    ||z            |z  }|d	z
  |z  }||z
  }t          |          |d
<   |
rt          |	          |d<   nRt          |          |d
<   |
rt          |	          |d<   n+|                     |||z            }t          |          |d<   |                     |d          }|                     |                     ||                    }|                     |dg           }|                     |||||          }|                     |          }d}t%          |          }t'          dt%          |                    D ]=}||z
  d	z
  }||         }|d	         }|||d	<   ||d<   ||d<   ||d<   |||<   |d         }>|S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://api.wavesplatform.com/v0/docs/#/candles/getCandles

        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest candle to fetch
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r,  r-  )r,  r-  intervalr   r   untilNi  r   	timeStarttimeEndr  r            )r1  r   rG  r   r  r   rj  parse_timeframemillisecondsparse_to_intr  r  r  publicGetCandlesBaseIdQuoteIdr4  rF  parse_ohlcvsfilter_future_candlesr\  r[  )r!  r*  r  r  r   r7  r   r8  r   r  untilIsDefineddurationnowr   durationRoundedTimestampdeltar  rO  r  rx  	lastCloselengthr]  jry  r  s                             r#  fetch_ohlcvzwavesexchange.fetch_ohlcv  s    	V$$X&i((()YOO
 

 **4<9I4PP!!&'22d*="ENE**''	22T9=##%%C-6ee3G'+'8'889K'L'Lx'W$QY(*E058I#&y>>GK  0%(ZZ	"#&u::GK  2%(ZZ	""((5(U*:;;%(\\	"67++55dkk'66R6RSS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\  rv  )r!  ohlcvsrx  r}  r]  s        r#  r	  z#wavesexchange.filter_future_candlesf  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   )rF  	parse8601rG  safe_number)r!  ohlcvr   r  s       r#  parse_ohlcvzwavesexchange.parse_ohlcvp  s    & ufb11NN4++D&99::T6**T6**T5))T7++T8Q//
 	
r$  r   c                    |                                   |                     | j        di           }|                     |d          }|                     |||          }|                     |dg          }|                                 }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}|.d|i}|                     |                     ||                    }n||         }||vrZt          |
                                          }t          | j        dz   |z   dz   |z   dz   d
                    |          z             |dk    rPd| j        i}|                     |                     ||                    }|                     |d          }||||ddS ||d}|                     |                     ||                    }|                     |d          }|                     |d          }|                     | j        di           }|                     |||          }|                     |d          }|                     |d          }||||ddS )a7  
        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>`
        r   networkitemsr   r(   r   Tz fetchDepositAddress() - not supported. Currency code must be one of z, NrB   z	 network z7 deposit address not supported. Network must be one of WAVES	publicKeyaddress)rs  rB  r  r"  tag)rB  platformplatform_idnetworkByIdsdeposit_addresses)r  rF  r   safe_string_upperrG  r  privateGetPlatformsr[  r\  listkeysr   r(   join"privateGetDepositAddressesCurrencyr4  r  "nodeGetAddressesPublicKeyPublicKey*privateGetDepositAddressesCurrencyPlatform)r!  r   r7  r   
rawNetworkr  supportedCurrenciesr   networksByCurrencyr  r]  ry  
currencyIdinnerCurrenciesr  currencyCodecodesrO  r8  supportedNetworkssupportedNetworkKeysresponseInneraddressInnerrB  	networkIdr&  unifiedNetworkr   r"  s                                r#  fetch_deposit_addressz#wavesexchange.fetch_deposit_address  s    	??4<R@@++FI>>
""8ZDD6I;//"6688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 >>t{{7TZ?[?[\\HH 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'!!! !% G GT[]dHeHe f f#//)DD) $&+   !% '! !  JJ4;;W^`fKgKghh0 ??8Z88$$X}==	t|^RHH)),	9MMOOH.ABB	""9a00%
 
 	
r$  c                     |                      | j        d          }|r|S |                                 }|dt          |          dz
           | j        d<   | j        d         S )Nr   r   )rG  r   matcherGetMatcherr\  )r!  r   rO  s      r#  get_matcher_public_keyz$wavesexchange.get_matcher_public_key  sj    ++DL:LMM 	4##--//H/7#h--!:K8K/LDL+,< 233r$  c                     |dk    r|                      dd          S |                     |                      dd          |                     |                    S )Nr   r   r   )number_to_bebinary_concatr  r!  r3  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   rD  s     r#  get_asset_idzwavesexchange.get_asset_id  s      2r$  r/  c                     |                      |          }t          j        |                     |          |                     |d                    }t          |          S Nr   )rB  r#   rL  rJ  rG  int)r!  r   r/  networkCoderB  stringValues         r#  to_real_currency_amountz%wavesexchange.to_real_currency_amount#  sS    ==&&()>)>v)F)FHXHXYacnHoHopp;r$  amountStringc                     || j         vr|S |                     |          }|                     |d          }t          j        ||          S rJ  )r   rB  rG  r#   rM  )r!  r   rO  rB  precisionAmounts        r#  rI  z'wavesexchange.from_real_currency_amount(  sN    ''==&&**8[AA!,@@@r$  r0  c                     |                      |          }t          j        |                     |          |                     |d         d                    }t          |          S Nr   r0  r   r#   rL  rJ  rG  rK  )r!  r*  r0  r   rM  s        r#  r3  z"wavesexchange.to_real_symbol_price/  sY    V$$()>)>u)E)EtGWGWX^_jXkmtGuGuvv;r$  priceStringc                 z    | j         |         }t          j        ||                     |d         d                    S rS  )marketsr#   rM  rG  )r!  r*  rU  r   s       r#  from_real_symbol_pricez$wavesexchange.from_real_symbol_price4  s7    f%!+t/?/?{@SU\/]/]^^^r$  c                     |                      |          }t          j        |                     |          |                     |d         d                    }t          |          S Nr   r/  rT  )r!  r*  r/  r   rM  s        r#  r2  z#wavesexchange.to_real_symbol_amount8  sY    V$$()>)>v)F)FHXHXY_`kYlnvHwHwxx;r$  c                 ^    | j         |         }t          j        ||d         d                   S rZ  )rW  r#   rM  )r!  r*  rO  r   s       r#  from_real_symbol_amountz%wavesexchange.from_real_symbol_amount=  s+    f%!,{0CH0MNNNr$  c                     |                      |d          }d|v r|                      |d          S |                      |d         d         d          S )NorderFeedynamic	compositedefaultrF  )r!  settingsr^  s      r#  safe_get_dynamiczwavesexchange.safe_get_dynamicA  sR    ??8Z88  ??8Y777??8K#8#CYOOOr$  c                 >    |                      |d          }|ddiS |S )Nratesr   r   rb  )r!  r_  rf  s      r#  safe_get_rateszwavesexchange.safe_get_ratesH  s)    11=Q<r$  rA  r6  c                    |                                   |                                  |                                  |                     |          }|                                 }|                     |d                   }	|                     |d                   }
|dk    }|                     |dd          }|du}|r|t          | j        dz   |z   dz             | 	                                }d}| 
                    |d	d
|                     | j        dd                    \  }}|                     ||          }|                     ||||          }|                     |dd          }|                     |d          }|                     |          }|                     |d          }|                     |d          }|                     |d          }|                     |          }|                     |d          }d}d}d|v s	d| j        v r[|                     |d|                     | j        d                    }|                     |          }|                     |d          }|                                 }|||k    r&||k    r t          | j        dz   |z   dz   |z             |                     |          }||k    r|n|} t+          |                     ||                     }!||v r"||         d         |!k    rt/          |           }nt1          | j        dz             |                     ||          }"|                     ||          }#|i||v r1||         d         t+          |"          k    r|}t/          |          }n4||v r0||         d         t+          |#          k    r|}t/          |          }|,t1          | j        dz   |z   dz   |"z   dz   |z   dz   |#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)         d*k    r6|)tE          |)          d!z
           d*k    r|)d!tE          |)          d!z
           })| #                    | $                    | %                    |)                    | $                    | %                    | j&                            d+          }*|*|'d,<   |rU| '                    | (                    |'|                    }+| )                    |+d-          },| *                    |,|          S | +                    | (                    |'|                    }+| )                    |+d-          },| *                    |,|          S ).a  
        create a trade order

        https://matcher.waves.exchange/api-docs/index.html#/serialize/serializeOrder

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.triggerPrice]: The price at which a stop order is triggered at
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r,  r-  r   r   	stopPriceNz- createOrder() requires a price argument for zE orders to determine the max price for buy and the min price for sellr@   defaultExpiryr   r   r>  r=  r@  r?  rQ  r(   z asset fee must be z or freez+ not enough funds of the selected asset feez6 not enough funds on none of the eligible asset fees: r  amountAsset
priceAssetr'  FT   W   assetDecimalsr  )senderPublicKeyr   	assetPairr.  r0  r/  r}  
expirationr?  	priceModeversionchainIdr   spp)tv)r{  c
attachmentr   matcherFeeAssetIdr   "r  r  r  ),check_required_dependenciesr  r1  r   r@  rH  safe_float_2r   r(   r  handle_option_and_paramsr  r   r  r9  safe_value_2rG  rH  rF  rB  fetch_balancefloatrI  rK  r   r2  r3  rE  r  binary_to_base58r  r  dumps!matcherPostMatcherOrdersSerializer\  r  r  r  r  !matcherPostMatcherOrderbookMarketr4  r  parse_ordermatcherPostMatcherOrderbook)-r!  r*  rA  r6  r/  r0  r7  r   r   rm  rn  isMarketOrderr   isStopOrderr}  defaultExpiryDeltart  matcherFeesr>  baseFeeAssetIdbaseFeeAssetbaseMatcherFeer=  discountFeeAssetIddiscountFeeAssetdiscountMatcherFeer~  r?  rQ  feeCurrencybalancesmatcherFeeAssetrawMatcherFeefloatMatcherFeefloatBaseMatcherFeefloatDiscountMatcherFeers  r'  rw  r  r}  serializedOrderr  rO  values-                                                r#  create_orderzwavesexchange.create_orderN  s\    	((***  """V$$6688''x(899&&vi'899
)((MM#4/ 	ktw)XX[__  cj   j  k  k  k%%''	!%)%B%B6=Zikok|k|  ~B  ~J  Lf  hr  ls  ls  &t  &t"FXXi);<<
--fdFEJJ   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$B$B?Ta$b$bccO8++(?2KF2SWf2f2f //

'2_(_```"<<\>ZZ"&"@"@AQSe"f"f$((x/Ef/MQVWjQkQk/k/k$2! 00

$00x@P7QRX7Y]bcz]{]{7{7{(:%!$%7!8!8J$#DG.f$fiu$ux{${  R  %R  U[  %[  ^n  %n  qt  %t  wN  %N  O  O  O++FF;;))&%88&$
 
	 nnT\=%HH$-""2#{ 0""$j//(
 
  	\ T66v|LL    J "&!6!6t{{4:jCYCY7Z7Z![![D''(9D$%@@FF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==dkk$PV>W>WXXHNN8Y77E##E622277D&8Q8QRRHNN8Y77E##E6222r$  r(   c                    |                                   |                                  |                                  |                                 }|                     ||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i          S )a  
        cancels an open order

        https://matcher.waves.exchange/api-docs/index.html#/cancel/cancelOrdersByIdsWithKeyOrSignature

        :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>`
        )r   r  r  r   r  rs  r(   clientOrderIdNr}  r  lastTradeTimestampr*  rA  r6  r0  r/  rD  r  filled	remainingstatusfeetrades)r  r  r  get_waves_address*forwardPostMatcherOrdersWavesAddressCancelrF  rG  
safe_order)
r!  r(   r*  r7  r   rO  r  firstMessage
firstOrder
returnedIds
             r#  cancel_orderzwavesexchange.cancel_order  s    	((***  """--//BB(D
 D
   //(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                    |                                   |                                  |                                  d}||                     |          }|                                 }|                     | j                  |                     |d          g}|                     |          }| 	                    |                     | j
                            }|                     | 	                    |          |d          }	t          |          |	| j        |d}
|                     |                     |
|                    }|                     ||          S )a  
        fetches information on an order made by the user

        https://matcher.waves.exchange/api-docs/index.html#/status/getOrderStatusByPKAndIdWithSig

        :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  )	Timestamp	Signaturer!  r  )r  r  r1  r   r  r  r  rB  binary_concat_arrayr  r  r  r  *matcherGetMatcherOrderbookPublicKeyOrderIdr4  r  )r!  r(   r*  r7  r   r}  	byteArraybinary	hexSecretr  r8  rO  s               r#  fetch_orderzwavesexchange.fetch_order+  sI    	((***  """[[((F%%''	!!$+..i++
	 )))44))$*?*?*L*LMM	LL!6!6v!>!>	9UU	Y"	
 
 BB4;;wX^C_C_``&111r$  c                    |                                   |                                  |t          | j        dz             |                                  |                     |          }|                                 }|                     | j                  | 	                    |d          g}| 
                    |          }|                     |                     | j                            }	|                     |                     |          |	d          }
dt          |          |
| j        |d         |d         d}|                     |                     ||                    }|                     ||||          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  r  r  r,  r-  )r  r  r  r!  r,  r-  )r  r  r   r(   r1  r   r  r  r  rB  r  r  r  r  r  9matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKeyr4  parse_orders)r!  r*  r  r   r7  r   r}  r  r  r  r  r8  rO  s                r#  fetch_orderszwavesexchange.fetch_ordersM  ss    	((***  """>#DG.Y$YZZZV$$%%''	!!$+..i++
	 )))44))$*?*?*L*LMM	LL!6!6v!>!>	9UU	(Y"X&i(
 
 QQRVR]R]^egmRnRnoo    65%@@@r$  c                    |                                   |                                  d}||                     |          }|                                 }|dd}|                     |          }|                     ||||          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r1  r  r   r  forwardGetMatcherOrdersAddressr  	r!  r*  r  r   r7  r   r"  r8  rO  s	            r#  fetch_open_orderszwavesexchange.fetch_open_orders~  s     	[[((F((**
 
 66w??  65%@@@r$  c                    |                                   |                                  d}||                     |          }|                                 }|dd}|                     |          }|                     ||||          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"  
closedOnlyr  r  s	            r#  fetch_closed_ordersz!wavesexchange.fetch_closed_orders  s     	[[((F((**
 
 66w??*   65%@@@r$  r  c                 >    ddddd}|                      |||          S )Ncanceledr  closed)	CancelledAcceptedFilledPartiallyFilled)rG  )r!  r  statusess      r#  parse_order_statusz wavesexchange.parse_order_status  s4    #%	
 
 &&999r$  c                     |                      |dd          }|                      |dd          }|                     |          dz   |                     |          z   S )Nrm  r   rn  rb  )rG  rH  )r!  rs  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$  orderc           
         |                      |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 )#Nr}  rA  r.  r   r(   r  r0  r/  rs  r*  rm  r   avgWeighedPricer  rQ  	filledFee)rB  r  r~  r?  r}  r|  r{  ry  rs  r  r  r  r   postOnlyr6  r   rD  r  )r  r  r  r  )r  r  rG  rF  r  rH  rX  rI  r  r   
parse_jsondecoder  r  r  )r!  r  r   r}  r6  rA  r(   filledStringrU  rO  rs  r*  amountCurrencyr0  r/  r  r  r  r  r   r   r}  decodedAttachmentr|  r{  s                            r#  r  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++FK@@//MM//MM--fd6F6FuN_6`6`aa(()9)9%)J)JKKU??**4+;+;E:+N+NOOD (()G)GdN^N^_dfqNrNr)s)stt CC
 **4+;+;ECVX_+`+`aaD (()G)GdN^N^_dfrNsNs)t)tuu 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! 
" f# 
$ + 
  
  
, -  	r$  c                     |                      | j        d          }|Id| j        i}|                     |          }|                      |d          | j        d<   | j        d         S |S )Nr   r!  r"  )rG  r   r  r.  )r!  cachedAddreessr8  rO  s       r#  r  zwavesexchange.get_waves_addressG  sq    ))$,GG!T[G >>wGGH+/+;+;Hi+P+PDL(<//!!r$  c                 	   |                                   |                                  |                                  |                                 }d|i}|                     |          }|                     |dg           }i }d}g }g }	t          dt          |                    D ]}
||
         }|                     |d          }||nt          ||          }|                     |d          }| 
                    |d          }| 
                    |d          }|| j        v }|rL|                     |          }|                                 ||<   |                     ||          ||         d	<   |*|                    |           |	                    |           t          |          }|rd
|i}|                     |          }|                     |dg           }t          dt          |                    D ]}
||
         }|	|
         }|                     |d          }|                     | 
                    |d                    }| 
                    |d          }|                     |          }|                                 ||<   t%          j        ||          ||         d	<   |                                 }|                     | j                  |                     |d          g}|                     |          }|                     |                     | j                            }|                     |                     |          |d          }| j        |t9          |          d}|                     |          }t=          |                                          } t          dt          |                     D ]o}
| |
         }|                     |          }||vr|                                 ||<   | 
                    ||          }!|                     ||!          ||         d<   pd|i}"|                      |"          }#|                     |d|                                           |d<   |                     d| 
                    |#d                    |d         d	<   | !                    |          }||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>`
        r"  r  Nr   r}  issueTransactionassetIdbalancetotalidsr  r   r  r  r  )r!  r  r}  usedr   r  )$r  r  r1  r  nodeGetAssetsBalanceAddressrF  r[  r\  r  rk  rG  currencies_by_idrH  accountrI  rv  publicGetAssetsrw  r#   rM  r  r  r  rB  r  r  r  r  r  )matcherGetMatcherBalanceReservedPublicKeyr*  r+  nodeGetAddressesBalanceAddressset_undefined_balances_to_zeror  safe_balance)$r!  r7  r   r8  totalBalancer  rx  r}  assetIdsnonStandardBalancesr]  ry  entryTimestampr  r3  r  currencyExistsr   nonStandardAssetsrequestInnerrO  r  innerr   r  currentTimestampr  r  r  r  matcherRequestreservedBalancereservedKeysr/  wavesRequest
wavesTotals$                                       r#  r  zwavesexchange.fetch_balanceS  s    	((***  """--//|
 77@@F ??<R@@	 q#h--(( 	4 	4AQKE!..ukBBN+4+<3yR`CaCaI#u6HII))%;;J&&ui88G(D,AAN 4..z::#||~~t(,(F(FtW(U(UtW%%!)
+++#**7333MM 	Ox"L ++L99H??8VR88D1c$ii(( O OQ-a0v66 001A1A%1U1UVV	))%::..v66#||~~t(/(:7I(N(NtW%%,,..!!$+...22
	 )))44))$*?*?*L*LMM	LL!6!6v!>!>	9UU	"-.. 
  

 HHXXO002233q#l++,, 	P 	PA%aJ**:66DFNN#||~~t%%ozBBF#'#A#A$#O#OF4L  |
 88FF
 //&'4<<>>JJw#'#A#A'4K[K[\fhqKrKr#s#sw 44V<<'{!\\)44z  (((r$  r  c                     t          |                                          }t          dt          |                    D ]1}||         }|                     ||         d          d||         |<   2|S )Nr   r  r  )r*  r+  r[  r\  rF  )r!  r  keyr6  r]  r   s         r#  r  z,wavesexchange.set_undefined_balances_to_zero  sk    X]]__%%q#e**%% 	* 	*A8Dx~v66>&)s#r$  c                 >   |                                   |                                 }d|i}d}|+|                     |          }|d         |d<   |d         |d<   |                     |          }|                     |d          }	|                     |	|||          S )a  
        fetch all trades made by the user

        https://api.wavesplatform.com/v0/docs/#/transactions/searchTxsExchange

        :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>`
        senderNr,  rm  r-  rn  r  )r1  r  r   publicGetTransactionsExchangerF  parse_trades)
r!  r*  r  r   r7  r"  r8  r   rO  r  s
             r#  fetch_my_tradeszwavesexchange.fetch_my_trades  s     	((**g
 [[((F%+H%5GM"$*9$5GL!55g>>x00F   vue<<<r$  c                 4   |                                   |                     |          }|d         |d         d}|t          |d          |d<   |||d<   |                     |          }|                     |d          }|                     ||||          S )	a,  
        get the list of most recent trades for a particular symbol

        https://api.wavesplatform.com/v0/docs/#/transactions/searchTxsExchange

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        r,  r-  rl  Nr   r   r  r  )r1  r   rj  r  rF  r  )	r!  r*  r  r   r7  r   r8  rO  r  s	            r#  fetch_tradeszwavesexchange.fetch_trades8  s     	V$$!(+ +
 
 "5#GG#(GK 55g>>x00F   vue<<<r$  tradec                 D   |                      |d          }|                     |d          }|                     |          }|                     |d          }|                     |d          }|                     |d          }|                      |d          }	|                      |d          }
d }|                     |	d          | j        k    r|	}n|                     |
d          | j        k    r|
}na|                     |	d          }|                     |
d          }|                     |          }|                     |          }||k    r|	}n|
}d }|                      |d	          }||                     |          }n
||d
         }|                     |d          }|                     |d          }|                     |d          |                     |                     |dd                    d}|                     ||||||d |d ||d |d|          S )Nr  r}  r(   r0  r/  order1order2rr  rs  r*  r.  r?  r~  r   )rD  rB  )rs  r}  r  r*  r(   r  rA  r6  rN  r0  r/  rD  r  )rF  rG  r  r  r  rH  
safe_trade)r!  r  r   r  r  r}  r(   rU  rO  r  r  r  date1date2ts1ts2r*  rs  r6  r  r  s                        r#  parse_tradezwavesexchange.parse_trade  sT   ^ 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f&788DKGGEE $$V[99E$$V[99E..''C..''CSyyOOE;77	 44Y??FFH%F{33""5$//$$UL99//0@0@H[]d0e0eff
 
 "   " 
  
   	r$  r6  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   )r  r  )rs  r   depositr   rs  r%  r   )r   r  rA  feesr  withdrawal_currencyr   flatFr   )market_codesr[  r\  rG  rF  r  in_arrayarray_concatnetwork_id_to_coder  r*  r+  )r!  rO  r6  currencyIdKeydepositWithdrawFeesr]  ry  
dictionaryr3  rB  r   depositWithdrawFeer;  r5  rL  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                    |                                   g }g }|                    |                     |                     |                    |                     |                     |}t	          dt          |                    D ]4}|                     ||         d          }|                     ||          }5|                     ||d          S )a  
        fetch deposit and withdraw fees

        https://docs.wx.network/en/api/gateways/deposit/currencies
        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>`
        r   r  r(   )	r1  rv  privateGetDepositCurrenciesprivateGetWithdrawCurrenciesr[  r\  rF  r  r  )r!  r6  r7  r  promisesr]  r  s          r#  fetch_deposit_withdraw_feesz)wavesexchange.fetch_deposit_withdraw_fees6	  s     	88@@AAA99&AABBBr q#h--(( 	2 	2AOOHQK99E$$T511DD//eTBBBr$  reasonr  r  r  r  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)rG  rE  rF  r  r(   r   r   )r!  r   r%  r  r  r  r  rO  requestHeadersrequestBody	errorCoder(  r  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$  r"  r#  c                 	   |                      ||          \  }}|dk    r|                                 }i }|                     |dg           }t          dt	          |                    D ]%}	||	         }
|                     |
d          }d||<   &||vrNt          |                                          }t          | j	        dz   |z   dz   t          |          z             |                                  g d}i }t          dt	          |                    D ]}	||	         }d||<   d}|                     |          }|                                }t	          |          d	z  }t          d|          D ]}	||	         }||vrd
} n|                                  d}|dk    r|s|}n||d}|                     |          }|                     |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}'|                      |'          }(| !                    |(|!          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   r  r   r(   Tz withdraw() r  )r  123r  56789abr|  dr  fr   FN)r"  rB  rB  allowed_amountrj  r  z withdraw failed, amount z4 must be greater than the minimum allowed amount of proxy_addressesr   r   r  r  r  r  r  )rr  r/  r  rA  rv  r}  r@  proofsr  	recipientr}  r  )"handle_withdraw_tag_and_paramsr"  rF  r[  r\  rG  r*  r+  r   r(   r  r1  remove0x_prefixlowerr  *privateGetWithdrawAddressesCurrencyAddressr  r   r  r   rN  rB  r  rB  r  r  rE  r  r  r  r  rH  nodePostTransactionsBroadcastparse_transaction))r!  r   r/  r"  r#  r7  r1  r   r  r]  ry  r5  r6  hexCharssetr  isErc20noPrefixrA  stringLength	characterproxyAddresswithdrawAddressRequestwithdrawAddresscurrencyInnerallowedAmountminimumproxyAddressesr  r@  rA  rv  amountIntegerrB  r}  r  r  r  r  r8  rx  s)                                            r#  r   zwavesexchange.withdraw	  s    99#vFFV7??"&"C"C"E"E!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$$ % 	7??7?"LL # , ," #MMNdeeO 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
44T6BB==&&%%''	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%""
 
  33G<< %%fh777r$  transactionrB  c           	          |                      d |          }|d         }|                     |d          }|dk    rdn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S )Nr   rA  r  r   r  r/  r  r@  r   r}  r(   txidr  r  addressFromr  r"  	addressTor>  rB  r  updatedtagFromr#  tagTocomment)rB  rD  )internalr  rs  )safe_currencyrG  r   rI  rH  r  r  )r!  rS  rB  r   typeRawrA  r/  	feeStringr@  feeCode	feeAmountr}  s               r#  rD  zwavesexchange.parse_transaction
  s1   > %%dH55"";77%nnzz9""4#A#A$HXHXYdfnHoHo#p#pqq$$[%88	%%k<II
))*55%%d&D&DWi&X&XYY	%%k;??	
$"";55
D
 
 Y//	

 t
 4++KBB
 t
 ))+{CC
 f
 D
 (
 d
 t
 t
 4
  T!
" t#
$ #!   /
 
 
 	
r$  )NN)N)r  )L__name__
__module____qualname__r   r  r(  r  r9  rW  r^  r   r
   r{  r	   r   r  r  r  r  r  dictr   r  r  r   r   r  r*  r  r	  r  r   r=  r@  rE  rH  r  rN  rI  r3  rX  r2  r\  rd  rg  r   r   r   r  r   r  r  r   r  r  r  r  r  r  r  r   r  r  r   r   r  r  r  r$  rK  r-  r   r   r   rD  __classcell__)r"  s   @r#  r%   r%      s       [# [ [ [ [ [ [z= = = = =
 KM R R R R R R Y`hj 
 
3 
 
 
 
B? ? ?B $& _ _$v, _ _ _ _B :>b 
 
s 
3 
Y 
 
 
 
< #    4  . &eBSW +P +P +P +PZ   % % % %NH H4 H H6 H H H HT 02 *5 *53 *5f *5 *5 *5 *5X 04B %5 %5W %57 %5 %5 %5 %5N 9=4^bkm U U# U# US UX[ Urvw{r| U U U Un  
 
 
4 
 
 
 
: 79 ~
 ~
# ~
^ ~
 ~
 ~
 ~
@	4 	4 	4b b b  
   C          
Ac A A A A A 3  u        
_S _s _ _ _ _ C          
Oc O O O O OP P P   gksu j3 j33 j3i j3y j3RW j3`c j3 j3 j3 j3X 37r / /s /C / / / /b 26b  2  2c  23  2  2  2  2D *.Dt\^ /A /A3 /Ac /A /Acghmcn /A /A /A /Ab /3TXac A A A3 Ac Ahlmrhs A A A A, 154VZce (A (A# (AS (APS (Ajnotju (A (A (A (AT: : : : :X X Xx x xv x x x x xt
" 
" 
" $& ) )( ) ) ) )B    -1tRV_a Z= Z=c Z= Z=C Z= Z= Z= Z=x 6:UW Z= Z=3 Z=s Z=# Z=\`af\g Z= Z= Z= Z=xa a av a a a a aF=# =#7 =#be =# =# =# =#~ <@ LC LC LC LC LC LC\# s  c TX `c     KOWY }8 }8S }8% }8# }8C }8^i }8 }8 }8 }8~A
 A
T A
X A
Q\ A
 A
 A
 A
 A
 A
 A
 A
r$  r%   )*ccxt.base.exchanger   ccxt.abstract.wavesexchanger   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r   r   r    r!   ccxt.base.decimal_to_precisionr"   ccxt.base.preciser#   r%   rG  r$  r#  <module>rn     sT   ( ' ' ' ' ' 3 3 3 3 3 3  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * - - - - - - 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %x(
 x(
 x(
 x(
 x(
Hk x(
 x(
 x(
 x(
 x(
r$  