
    E#i6                    0   S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJ r   S SKJ!r!  S SKJ"r"  S SKJ#r#  S SKJ$r$  S SK%J&r&  S SK'J(r(   " S S\\5      r)g)    )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                   >  ^  \ rS rSrS\4U 4S jjrU 4S jr0 4S\4S jjrS0 4S\4S jjr	S	 r
0 4S\\   4S
 jjrS0 4S\S\S\4S jjrSVS\4S jjrS rSS0 SS4S jr0 4S jrSWS\S\S\4S jjr0 4S\S\4S jjrS0 4S\S\4S jjrSSS0 4S\S\S\S\S\\   4
S jjrS rSWS\S\4S jjr0 4S \S\ 4S! jjr!S" r"S# r#S$ r$SWS \S%\%4S& jjr&S \S'\4S( jr'S\S)\%4S* jr(S\S+\4S, jr)S\S%\%4S- jr*S\S'\4S. jr+S/ r,S0 r-S0 4S\S1\.S2\/S%\%S)\04
S3 jjr1S0 4S4\S\24S5 jjr3S0 4S4\S\24S6 jjr4SSS0 4S\2S\S\S\\5   4S7 jjr6SSS0 4S\2S\S\S\\5   4S8 jjr7SSS0 4S\2S\S\S\\5   4S9 jjr8S:\24S; jr9S< r:SWS=\S\S\54S> jjr;S? r<0 4S\=4S@ jjr>SXSA jr?SSS0 4S\2S\S\4SB jjr@SS0 4S\S\S\S\\A   4SC jjrBSWSD\S\S\A4SE jjrCSVSF\S\4SG jjrDS0 4SF\4SH jjrES \FSI\SJ\SK\SL\SM\4SN jrGS0 4S \S%\%SO\SP\2S\H4
SQ jjrISWSR\SS\JS\H4ST jjrKSUrLU =rM$ )Ywavesexchange   returnc                 $  > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S_S
S_S0 SS _SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_S S_S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S _S.S _E0 S/S0_S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_E0 SAS_SBS_SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_E0 SRS_SSS_STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_E0 ScS_SdS_SeS_SfS_SgS_ShS_SiS_SjS_SkS_SlS_SmS_SnS_SoS_SpS_SqS_SrS_SsS_E_StSuSvSwSxSySzS{S|S}S~SSSS._SSSSSSSSS.SSSSSSS./ SQSS._S/ SQ/ SQSS/S/S./ SQ/ SQSS/S.S/ SQ0/ SQS/S.SS/S/S.SS/0S._SSU R	                  SS SU R                  S5      S.5      0_S[        _SSS SS S SS SSSSSSS.S._SSSSSS SSS SSSSS.SSSSSSSS.S SSSSSS.SSSSS.SSSSSS.SSS S SSSS.SSSSSSSSS.SS 0S.	S S S.S S S.S._SSS0_SS_S0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _[        [        [        [        [        [         [        [        S.E_5      $ )Nidr%   namezWaves.Exchange	countriesCH	certifiedFprodexT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)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
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icebergd   )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?   createOrdersrq   ry   rv   r{   rL   rr   )linearinverse)r2   r4   r5   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    L/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/wavesexchange.pyr  wavesexchange.describe   sZ
   mT C E YH
/YH
$YH
 $YH
 	YH

 5YH
 4Y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& "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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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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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YH
^ _YH
| }CBHBR[  <6@:JS ,3}YH
r 6 ?:
 ;[0dEL: .7GgR   ' 3<
 ? !q}sYH
n
 d22:hw{  FJ  Y]  Yj  Yj  kq  Yr  4s  to
YH
t
 Yu
YH
v
 "&#59$(,6 $#'$*"&!$""w
YH
X #&+(,,1,0).+06:#(#("'#'	( #($)$)+026/4#()$, %)&+!$$*%+*/& ',#($)*/	# ',!$#($)*/( ',!$$(%)#($)*.$ ',!$$*,-%+#($)*/	*  #ACJ ##
 ##SMYYH
t }!uYH
z T{YH
|  ,( ] *	
 * + + . . 9 < < < < <  <!" 0#$ 1000%(%.3}YH
 Y Y	    c                 x   > U(       a  SOSU R                   S'   XR                   S'   [        [        U ]  U5        g )NTr   r   sandboxMode)r   r  r%   set_sandbox_mode)r  enabledr   s     r!  r'  wavesexchange.set_sandbox_mode  s0    /6C_%&-]#mT3G<r#  symbolc                     U R                  5         U R                  U5      nU R                  X5      nU R                  X5      nU R	                  US   US   UUUS.U5      nU R                  U5      $ )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_asset wavesexchange.get_fees_for_asset  s    V$++F;))&8++X&i(
  HHQQr#  takerc                 Z   U R                  XXE5      nU R                  USS5      n	S n
U	(       a  U R                  US5      n
OU R                  US5      n
U R                  U
S5      nU R                  U
S5      nU R	                  U5      nU R                  X5      nU R                  U5      nU R                  U5      nU R                  XR                  U5      5      n[        R                  " U[        R                  " UU5      5      nUUU R                  U5      U R                  U5      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*  rB  r6  r/  r0  takerOrMakerr7  responser=  moder@  rA  feeAssetadjustedMatcherFeeamountAsStringpriceAsStringfeeCostfeeRates                      r!  custom_calculate_fee"wavesexchange.custom_calculate_fee  s   **6G vF??8Z8D??8V4D%%dL9
%%dL9
**:6!;;HQ..v6--e4''0A0ABT0UV$$%79K9KN\i9jk  %%g.%%g.	
 	
r#  c                     U R                  U R                  S5      nU(       a  U$ U R                  5       n0 nU R                  US5      n[        S[	        U5      5       H
  nSXU   '   M     XR                  S'   U$ )Nr   priceAssetsr   T)rG  r   matcherGetMatcherSettingsrangelen)r  r   rP  r[  is        r!  
get_quoteswavesexchange.get_quotes,  sy    x8M 557Hb F//(MBK1c+./)-1~& 0%+LL"Mr#  c                    U R                  5       n/ n[        S[        U5      5       GHD  nX$   nU R                  US5      nU R                  US5      nUS-   U-   nU R                  US5      n	U	R	                  S5      u  pU R                  U
5      n
U R                  U5      nU
S-   U-   nUR                  0 SU_SU_SU
_SU_S	S
_SU_SU_SS
_SS_SS_SS_SS_SS_SS_SS
_SS_SS
_S
S
S
S
S
S
U R                  U R                  U R                  US5      5      5      U R                  U R                  U R                  US5      5      5      S.S
S
S.S
S
S.S
S
S.S
S
S.S.S
US.
E5        GMG     U$ )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-  settleIdrB  r2   Tr3   Fr4   r5   r6   activecontractr   amountAssetDecimalspriceAssetDecimals)r/  r0  )minmax)r   r/  r0  rE  )
r   contractSizeexpiryexpiryDatetimestrike
optionTyper   limitscreatedinfo)	marketGetTickersr]  r^  rH  splitrI  appendr  parse_precision)r  r7  rP  resultr_  entryr,  r-  r)   marketIdr?  rf  r*  s                r!  fetch_marketswavesexchange.fetch_marketsm  sH    ((*: q#h-(AKE%%e_=F&&un=G#'B''x8H"..-KD**40D++E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[]rEs0tu!..t/C/CDDTDTUZ\pDq/rs  $#!
  $#
  $#
  $#$  _0 0 )v r#  Nr   c                 x   U R                  5         U R                  U5      nU R                  US   US   S.U5      nU R                  U5      nU R	                  US5      nU R                  U R                  US5      XB5      nU R                  U R                  US5      XB5      n	UUU	UU R                  U5      SS.$ )	a  
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_siderG  iso8601)
r  r*  r   r7  r   r8  rP  r  r  r  s
             r!  fetch_order_bookwavesexchange.fetch_order_book  s     	V$++X&i(
  ??H%%h<	))$//(F*KV[))$//(F*KV["Y/
 	
r#  c                 j   US   nU R                  U R                  SS5      nU R                  US5      nU R                  US5      n[        R                  " Xg5      n[        R                  " XX5      n	/ n
[	        S[        U5      5       H  nX   nU R                  USS5      nU R                  USS5      nS nS nU	b  Ub  [        R                  " X5      nUb  Ub  [        R                  " X5      nUb  X:  a    U
$ U
R                  U R                  U5      U R                  U5      /5        M     U
$ )Nr   r   r   r/  r0  r   0)	rH  r   r#   rM  r]  r^  rN  ry  r  )r  bookSider   r   r   r   amountPrecisionStringpricePrecisionString
differencepricePrecisionr{  r_  r|  
entryPriceentryAmountr0  r/  s                    r!  r  #wavesexchange.parse_order_book_side  s?   ;'	))$,,8H&Q $ 0 0H E#//	7C''(=T
 ++NGq#h-(AKE))%#>J**5(C@KEF*1G**:F%18O ++KO!	
 	 MM!!%(!!&)  )  r#  c                    U R                   c  [        U R                  S-   5      eU R                  c  [        U R                  S-   5      eS nS n U R	                  U R                   5      n U R	                  U R                  5      nU R                  U5      nU R                  U5      n[        U5      S:w  a  [        U R                  S-   5      e[        U5      S:w  a  [        U R                  S-   5      eg! [
         a  n[        U R                  S-   5      eS nAff = f! [
         a  n[        U R                  S-   5      eS nAff = f)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_keys!wavesexchange.check_required_keys  s:   ;;%dgg0M&MNN;;%dgg0M&MNN	_//<K	`!224;;?N ..{; 11.A~"$%dgg0]&]^^ !R'%dgg0^&^__  	_%dgg0]&]^^	_  	`%dgg0^&^__	`s0   C8 ,D" 8
DDD"
E	,EE	r   GETc                    U R                  X@R                  U5      5      nUS:H  nU R                  X5      nU R                  S   U   S-   U-   n	U R	                  U5      n
US:X  d  US:X  av  SS0nU R                  U R                  S5      nU(       a  S	U-   US
'   US:X  a  SUS'   OSUS'   U(       a  U R                  US   /5      nSn
[        U
5      S:  a  U	SU
-   -  n	O]US:X  a   US:X  a  SSS.nU R                  U5      nO:UnO7US:X  a  SS0nU R                  U5      nOSS0n[        U
5      S:  a  U	SU
-   -  n	XXeS.$ )Nr   r   re  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_repeatrH  r   jsonr^  )r  pathr   r  r7  r  r  queryisCancelOrderr  queryStringr   s               r!  signwavesexchange.sign  s   		&"5"5d";< FF""40iis#c)D066u=9#"2,G **4<<GK+4{+B(*<'*M'yy%	"2!34 ;!#s[((I0$6 yy'"$6 yy' #$G {#a'3,,CdOOr#  c                 n   U R                  U R                  S5      (       Gd  SnSnU R                  U R                  5       U5      n[	        U5      nSnU R                  U R                  SS5      nUS-   U-   S-   U-   nU R                  U R                  U5      5      nX(-   n	U R                  U R                  U R                  5      5      n
U R                  XS5      nS	S
U R                  US-   U-   US.nU R                  U5      nU R                  US5      U R                  S'   U R                  S   $ g)z
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)rH  r   sumsecondsstrr  encoder  r  axolotlr  privatePostOauth2Token)r  r7  prefixexpiresDeltar  clientIddefaultMessagePrefixmessage
messageHexpayloadhexKey	signaturer8  rP  s                 r!  sign_inwavesexchange.sign_inJ  s0    m<<F+Lhht||~|<G'lG#H#'#3#3DLL/SV#W *S08;cAGKG..t{{7/CDJ)G**4+@+@+MNFWi@I(" KK#cMI5%G 227;H +/*:*:8^*TDLL'<<..r#  tickerr   c                 6   U R                  US5      nU R                  US5      nU R                  XBS5      nUS   nU R                  USS5      nU R                  USS5      nU R                  USS	5      nU R                  US
S5      n	U R                  USS5      n
U R                  USS5      nU R                  USS5      nU R	                  0 SU_SU_SU R                  U5      _S	U_SU_SS _SS _SS _SS _SU	_SU_SU_SU_SS _SS _SS _SS _U
UUS.EU5      $ ) Nr  r*  re  	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  rv  )r  rH  safe_marketsafe_string_2safe_tickerr  )r  r  r   r  r}  r*  r  r  r  r  r  r  r  s                r!  parse_tickerwavesexchange.parse_tickerq  s   P %%fk:	##FH5!!(C8!!!&+{C  E:!!&*f=!!&*6LM''hG
((1BMR!!&*lC !
f!
!
 Y/!
 D	!

 3!
 4!
 !
 4!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r#  c                 &   U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US/ 5      nU R	                  US0 5      nU R                  US0 5      nU R                  X5      $ )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  rG  	safe_dictr  )	r  r*  r7  r   r8  rP  r  r  
dataTickers	            r!  fetch_tickerwavesexchange.fetch_ticker  s     	V$VD\
 &&t{{7'CD0 x4q"-^^FFB7
  44r#  symbolsc                 f    U R                  5         U R                  U5      nU R                  X15      $ )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  rw  parse_tickers)r  r  r7  rP  s       r!  fetch_tickerswavesexchange.fetch_tickers  s3     	((0: !!(44r#  r   	timeframesincec                     U R                  5         U R                  U5      nUS   US   U R                  U R                  X"5      S.nU R	                  U R
                  SS5      nU R	                  US5      n	U	SLn
Uc  Un[        X5      nU R                  U5      S-  nUca  U R                  5       nU
(       a  U	OUnU R                  X-  5      U-  nUS	-
  U-  nX-
  n[        U5      US
'   U
(       a  [        U	5      US'   OF[        U5      US
'   U
(       a  [        U	5      US'   O"U R                  X;U-  5      n[        U5      US'   U R                  US5      nU R                  U R                  Xu5      5      nU R                  US/ 5      nU R!                  UXbX45      nU R#                  U5      nSn[%        U5      n['        S[%        U5      5       H6  nUU-
  S	-
  nUU   nUS	   nUc  UUS	'   UUS'   UUS'   UUS'   UUU'   US   nM8     U$ )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   rH  r   r  r   rm  parse_timeframemillisecondsparse_to_intr  r  r  publicGetCandlesBaseIdQuoteIdr4  rG  parse_ohlcvsfilter_future_candlesr^  r]  )r  r*  r  r  r   r7  r   r8  r   r
  untilIsDefineddurationnowr  durationRoundedTimestampdeltar  rP  r  r{  	lastCloselengthr_  jr|  r  s                             r!  fetch_ohlcvwavesexchange.fetch_ohlcv  s9    	V$X&i((()O

 **4<<9I4P!!&'2d*="EN*''	2T9=##%C-e3G'+'8'89K'Lx'W$QY(*E08I#&y>GK %(Z	"#&u:GK %(Z	"((5U*:;%(\	"67+55dkk'6RS0 x4""4EI++F3	Vq#f+&A
QA1IE8D|$a$a$a$a!q	aI ' r#  c                     / nU R                  5       n[        S[        U5      5       H$  nX   S   U:  a    U$ UR                  X   5        M&     U$ )Nr   )r  r]  r^  ry  )r  ohlcvsr{  r  r_  s        r!  r  #wavesexchange.filter_future_candlese  sW    %%'	q#f+&Ay|i' MM&)$	 '
 r#  c           
         U R                  US0 5      nU R                  U R                  US5      5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  USS5      /$ )	Nr  timer  r  r  r  r  r   )rG  	parse8601rH  safe_number)r  ohlcvr   r  s       r!  parse_ohlcvwavesexchange.parse_ohlcvo  s    & ufb1NN4++D&9:T6*T6*T5)T7+T8Q/
 	
r#  r   c                    U R                  5         U R                  U R                  S0 5      nU R                  US5      nU R	                  X4U5      nU R                  US/5      nU R                  5       n0 n0 nU R                  US/ 5      n	[        S[        U	5      5       Hm  n
X   nU R	                  US5      nU R                  US/ 5      n[        S[        U5      5       H(  nU R	                  X5      nSX'   X;  a  0 X'   SX   U'   M*     Mo     X;  aI  [        UR                  5       5      n[        U R                  S-   U-   S	-   S
R                  U5      -   5      eSnUc&  SU0nU R                  U R                  UU5      5      nOX   nUU;  aO  [        UR                  5       5      n[        U R                  S-   U-   S-   U-   S-   S
R                  U5      -   5      eUS:X  aI  SU R                   0nU R#                  U R                  UU5      5      nU R	                  US5      nUUUUSS.$ UUS.nU R%                  U R                  UU5      5      nU R                  US5      nU R	                  US5      nU R                  U R                  S0 5      nU R	                  UUU5      nU R                  US5      nU R	                  US5      nUUUUSS.$ )a  
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, NrC   z	 network z7 deposit address not supported. Network must be one of WAVES	publicKeyaddress)rv  rC  r+  r1  tag)rC  platformplatform_idnetworkByIdsdeposit_addresses)r  rG  r   safe_string_upperrH  r  privateGetPlatformsr]  r^  listkeysr   r)   join"privateGetDepositAddressesCurrencyr4  r  "nodeGetAddressesPublicKeyPublicKey*privateGetDepositAddressesCurrencyPlatform)r  r   r7  r   
rawNetworkr+  supportedCurrenciesr   networksByCurrencyr,  r_  r|  
currencyIdinnerCurrenciesr  currencyCodecodesrP  r8  supportedNetworkssupportedNetworkKeysresponseInneraddressInnerrC  	networkIdr5  unifiedNetworkr   r1  s                                r!  fetch_deposit_address#wavesexchange.fetch_deposit_address  sO    	??4<<R@++FI>
""8D6I;/"668B 
#% 3WbAq#e*%AHE))%6J"ooe\2FO1c/23#//C+/
($:79&4?C"0< 4	 & "*+E*C Cd JM| |  @D  @I  @I  JO  @P  !P  Q  Q?DG >>t{{7TZ?[\H 2 800'+,=,B,B,D'E$#DGGcMG$;k$ID$P  TM  %M  PT  PY  PY  Zn  Po  %o  p  p'!! !% G GT[]dHe f#//)D) $&+  !% '!  JJ4;;W^`fKgh0 ??8Z8$$X}=	t||^RH)),	9MOOH.AB	""9a0%
 	
r#  c                     U R                  U R                  S5      nU(       a  U$ U R                  5       nUS[        U5      S-
   U R                  S'   U R                  S   $ )Nr   r   )rH  r   matcherGetMatcherr^  )r  r   rP  s      r!  get_matcher_public_key$wavesexchange.get_matcher_public_key  s`    ++DLL:LM##--/H/7#h-!:K/LDLL+,<< 233r#  c                     US:X  a  U R                  SS5      $ U R                  U R                  SS5      U R                  U5      5      $ )Nr/  r   r   )number_to_bebinary_concatr  r  rB  s     r!  get_asset_byteswavesexchange.get_asset_bytes  sI     $$Q**%%d&7&71&=t?T?TU_?`aar#  c                     US:X  a  gU$ )Nr/  r   rU  s     r!  get_asset_idwavesexchange.get_asset_id  s     r#  r/  c                     U R                  U5      n[        R                  " U R                  U5      U R	                  US5      5      n[        U5      $ Nr   )rC  r#   rM  rK  rH  int)r  r   r/  networkCoderC  stringValues         r!  to_real_currency_amount%wavesexchange.to_real_currency_amount"  sG    ==&(()>)>v)FHXHXYacnHop;r#  amountStringc                     XR                   ;  a  U$ U R                  U5      nU R                  US5      n[        R                  " X$5      $ r]  )r   rC  rH  r#   rN  )r  r   rc  rC  precisionAmounts        r!  rJ  'wavesexchange.from_real_currency_amount'  sC    '==&**8[A!!,@@r#  r0  c                     U R                  U5      n[        R                  " U R                  U5      U R	                  US   S5      5      n[        U5      $ Nr   r0  r   r#   rM  rK  rH  r^  )r  r*  r0  r   r`  s        r!  r3  "wavesexchange.to_real_symbol_price.  sM    V$(()>)>u)EtGWGWX^_jXkmtGuv;r#  priceStringc                 r    U R                   U   n[        R                  " X R                  US   S5      5      $ rh  )marketsr#   rN  rH  )r  r*  rk  r   s       r!  from_real_symbol_price$wavesexchange.from_real_symbol_price3  s4    f%!!+/?/?{@SU\/]^^r#  c                     U R                  U5      n[        R                  " U R                  U5      U R	                  US   S5      5      n[        U5      $ Nr   r/  ri  )r  r*  r/  r   r`  s        r!  r2  #wavesexchange.to_real_symbol_amount7  sM    V$(()>)>v)FHXHXY_`kYlnvHwx;r#  c                 X    U R                   U   n[        R                  " X#S   S   5      $ rq  )rm  r#   rN  )r  r*  rc  r   s       r!  from_real_symbol_amount%wavesexchange.from_real_symbol_amount<  s+    f%!!,{0CH0MNNr#  c                     U R                  US5      nSU;   a  U R                  US5      $ U R                  US   S   S5      $ )NorderFeedynamic	compositedefaultrG  )r  settingsrw  s      r!  safe_get_dynamicwavesexchange.safe_get_dynamic@  sF    ??8Z8 ??8Y77??8K#8#CYOOr#  c                 8    U R                  US5      nUc  SS0$ U$ )Nratesr/  r   r{  )r  rx  r  s      r!  safe_get_rateswavesexchange.safe_get_ratesG  s&    1=Q<r#  rB  r6  c                 
   U R                  5         U R                  5         U R                  5         U R                  U5      nU R	                  5       nU R                  US   5      n	U R                  US   5      n
US:H  nU R                  USS5      nUSLnU(       a!  Uc  [        U R                  S-   U-   S-   5      eU R                  5       nSnU R                  US	S
U R                  U R                  SS5      5      u  pU R                  X5      nU R                  XXE5      nU R                  USS5      nU R!                  US5      nU R#                  U5      nU R!                  US5      nU R%                  US5      nU R!                  US5      nU R#                  U5      nU R!                  US5      nSnSnSU;   d  SU R                  ;   aP  U R!                  USU R!                  U R                  S5      5      nU R'                  U5      nU R!                  US5      nU R)                  5       nUb  UU:w  a'  UU:w  a!  [        U R                  S-   U-   S-   U-   5      eU R#                  U5      nUU:X  a  UOUn [+        U R-                  UU 5      5      n!UU;   a  UU   S   U!:  a  [/        U 5      nO[1        U R                  S-   5      eU R-                  UU5      n"U R-                  UU5      n#UcQ  UU;   a#  UU   S   [+        U"5      :  a  Un[/        U5      nO(UU;   a"  UU   S   [+        U#5      :  a  Un[/        U5      nUc-  [1        U R                  S-   U-   S-   U"-   S-   U-   S-   U#-   5      eU R3                  X5      nU R5                  X5      nU	U
S.n$U R7                  U R                  SS5      n%U%(       a  SOSn&U R8                  UU$UUUUU[/        U5      SSU&S .n'U(       aP  S!S"S#U R5                  X5      0S$.S%.n(U R;                  U R=                  [>        R@                  " U(5      5      5      U'S&'   US':w  a  UU'S('   U RC                  U'5      n)U)S)   S*:X  a&  U)[E        U)5      S!-
     S*:X  a  U)S![E        U)5      S!-
   n)U RG                  U RI                  U RK                  U)5      5      U RI                  U RK                  U RL                  5      5      S+5      n*U*U'S,'   U(       aE  U RO                  U RQ                  U'U5      5      n+U RS                  U+S-5      n,U RU                  U,U5      $ U RW                  U RQ                  U'U5      5      n+U RS                  U+S-5      n,U RU                  U,U5      $ ).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>  rA  r@  rR  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   rP  rZ  safe_float_2r   r)   r  handle_option_and_paramsr  r   r  r9  safe_value_2rH  rI  rG  rC  fetch_balancefloatrJ  r^  r   r2  r3  rF  r  binary_to_base58r  r  dumps!matcherPostMatcherOrdersSerializer^  r  r  r  r  !matcherPostMatcherOrderbookMarketr4  r  parse_ordermatcherPostMatcherOrderbook)-r  r*  rB  r6  r/  r0  r7  r   r   r  r  isMarketOrderr   isStopOrderr  defaultExpiryDeltar  matcherFeesr?  baseFeeAssetIdbaseFeeAssetbaseMatcherFeer>  discountFeeAssetIddiscountFeeAssetdiscountMatcherFeer  r@  rR  feeCurrencybalancesmatcherFeeAssetrawMatcherFeefloatMatcherFeefloatBaseMatcherFeefloatDiscountMatcherFeer  r&  r  r  r  serializedOrderr  rP  values-                                                r!  create_orderwavesexchange.create_orderM  s0    	((*  "V$668''x(89&&vi'89
)((M#4/tww)XX[__  cj   j  k  k%%'	!%)%B%B6=Zikok|k|  ~B  ~J  ~J  Lf  hr  ls  &t"XXi<
--fFJ   fjA))$=..~>))$=??;
;!--hE223EF!--hE 
& jDLL&@''
D<L<LT\\[e<fgH--1K $ 0 0d C%%'(!227IM^7^"477-B#B\#QTZ#Z]m#mnn"556GHO/@N/RNYkM#D$B$B?Ta$bcO8+(?2KF2SWf2f /
'2_(_``"<<\>Z"&"@"@AQSe"f$(x/Ef/MQVWjQk/k$2! 0
$0x@P7QRX7Y]bcz]{7{(:%!$%7!8J$#DGG.f$fiu$ux{${  R  %R  U[  %[  ^n  %n  qt  %t  wN  %N  O  O++F;))&8&$
	 nnT\\=%H$"2#{{ 0""$j/(
  T66vL J "&!6!6t{{4::jCY7Z![D'(9D$%@@FA#%OS=QTU=U,W[^,^-aO0Dq0HIOLL!6!6t7L7L_7]!^`d`u`uvz  wL  wL  MQ  MX  MX  wY  aZ  \e  f	%[@ ==dkk$PV>WXHNN8Y7E##E62277D&8QRHNN8Y7E##E622r#  r)   c                    U R                  5         U R                  5         U R                  5         U R                  5       nU R	                  UUS.5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  0 SU_SU	_SS_S	S_S
S_SS_SU_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS0E5      $ )au  
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  rv  r)   clientOrderIdNr  r  lastTradeTimestampr*  rB  r6  r0  r/  rE  r  filled	remainingstatusfeetrades)r  r  r  get_waves_address*forwardPostMatcherOrdersWavesAddressCancelrG  rH  
safe_order)
r  r)   r*  r7  r   rP  r  firstMessage
firstOrder
returnedIds
             r!  cancel_orderwavesexchange.cancel_order  s}    	((*  "--/BB(D
  //(I6w2__\15
%%j)<
  
H 
* 
 T 
 	 

  
 !$ 
 f 
 D 
 D 
 T 
 d 
 D 
 t 
 d 
  
  d! 
" 4# 
$ d% 
  	r#  c                 X   U R                  5         U R                  5         U R                  5         SnUb  U R                  U5      nU R	                  5       nU R                  U R                  5      U R                  US5      /nU R                  U5      nU R                  U R                  U R                  5      5      nU R                  U R                  U5      US5      n	[        U5      U	U R                  US.n
U R                  U R                  X5      5      nU R                  X5      $ )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	Signaturer0  r  )r  r  r1  r   r  r  r  rS  binary_concat_arrayr  r  r  r  *matcherGetMatcherOrderbookPublicKeyOrderIdr4  r  )r  r)   r*  r7  r   r  	byteArraybinary	hexSecretr  r8  rP  s               r!  fetch_orderwavesexchange.fetch_order*  s    	((*  "[[(F%%'	!!$++.i+
	 )))4))$*?*?*LM	LL!6!6v!>	9U	Y"	
 BB4;;wC_`11r#  c                    U R                  5         U R                  5         Uc  [        U R                  S-   5      eU R	                  5         U R                  U5      nU R                  5       nU R                  U R                  5      U R                  US5      /nU R                  U5      nU R                  U R                  U R                  5      5      n	U R                  U R                  U5      U	S5      n
S[        U5      U
U R                  US   US   S.nU R                  U R!                  X5      5      nU R#                  XX#5      $ )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>`
z) fetchOrders() requires a symbol argumentr  r  r  r,  r-  )r  r  r  r0  r,  r-  )r  r  r   r)   r1  r   r  r  r  rS  r  r  r  r  r  9matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKeyr4  parse_orders)r  r*  r  r   r7  r   r  r  r  r  r  r8  rP  s                r!  fetch_orderswavesexchange.fetch_ordersL  s4    	((*  ">#DGG.Y$YZZV$%%'	!!$++.i+
	 )))4))$*?*?*LM	LL!6!6v!>	9U	(Y"X&i(
 QQRVR]R]^eRno    5@@r#  c                     U R                  5         U R                  5         SnUb  U R                  U5      nU R                  5       nUSS.nU R	                  U5      nU R                  XX#5      $ )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)r1  
activeOnlyr1  r  r   r  forwardGetMatcherOrdersAddressr  	r  r*  r  r   r7  r   r1  r8  rP  s	            r!  fetch_open_orderswavesexchange.fetch_open_orders}  sr     	[[(F((*
 66w?  5@@r#  c                     U R                  5         U R                  5         SnUb  U R                  U5      nU R                  5       nUSS.nU R	                  U5      nU R                  XX#5      $ )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)r1  
closedOnlyr  r  s	            r!  fetch_closed_orders!wavesexchange.fetch_closed_orders  st     	[[(F((*
 66w?*   5@@r#  r  c                 4    SSSSS.nU R                  X!U5      $ )Ncanceledr  closed)	CancelledAcceptedFilledPartiallyFilled)rH  )r  r  statusess      r!  parse_order_status wavesexchange.parse_order_status  s*    #%	
 &99r#  c                     U R                  USS5      nU R                  USS5      nU R                  U5      S-   U R                  U5      -   $ )Nr  r/  r  re  )rH  rI  )r  r  r,  r-  s       r!  get_symbol_from_asset_pair(wavesexchange.get_symbol_from_asset_pair  sP    !!)]GD""9lGD&&v.4t7N7Nw7WWWr#  orderc           
         U R                  US5      nU R                  USS5      nSnSU;   a  U R                  USU5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  US	5      n
S nU
b  U R	                  U
5      nOUb  US
   nU R                  U R                  U
SS5      5      nU R                  X5      nU R                  X5      nU R                  X5      nU R                  XR                  US5      5      nU R                  U R                  US5      5      nS nSU;   aV  U R                  U R                  US5      5      nUU R                  U R                  UU R                  US5      5      5      S.nOVU R                  U R                  USS5      5      nUU R                  U R                  UU R                  US5      5      5      S.nS nU R                  US5      nUbn  U R                  U R                  U R                  U5      5      5      nUb<  U R                  US5      nUb'  U R                  US5      nUb  U R                  US5      nU R                  0 SU_SU_SS _SU_SU R                  U5      _SS _S
U_SU_SS _SS _SU_SU_SU_SU_S S _S!U_SU_S UUS S".EU5      $ )#Nr  rB  r.  r   r)   r  r0  r/  r  r*  r  r/  avgWeighedPricer  rR  	filledFee)rC  r  r  r@  r  r  r  r  rv  r  r  r  r   postOnlyr6  r   rE  r  )r  r  r  r  )r  r  rH  rG  r  rI  rn  rJ  r  r  
parse_jsondecoder  r  r  )r  r  r   r  r6  rB  r)   filledStringrk  rc  r  r*  amountCurrencyr0  r/  r  r  r  r  r   r   r  decodedAttachmentr  r  s                            r!  r  wavesexchange.parse_order  s   j %%e[9	!!%=U?##E;=DeT*''x8&&ug6''x8OOE;7	 44Y?FH%F001A1A)]\c1de++F@//M//M--f6F6FuN_6`a(()9)9%)JKU?**4+;+;E:+NOD (()G)GdN^N^_dfqNr)stC
 **4+;+;ECVX_+`aD (()G)GdN^N^_dfrNs)tuC %%e\:
! $D<Q<QR\<]0^ _ ,OO$5s;=3/A}'+'7'73'?  
E 
" 
 T 
 	 

 Y/ 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
 L 
 f 
 D 
  w! 
" f# 
$ + 
, - 	r#  c                     U R                  U R                  S5      nUcM  SU R                  0nU R                  U5      nU R                  US5      U R                  S'   U R                  S   $ U$ )Nr   r0  r1  )rH  r   r  r=  )r  cachedAddreessr8  rP  s       r!  r  wavesexchange.get_waves_addressF  sp    ))$,,G!T[[G >>wGH+/+;+;Hi+PDLL(<<//!!r#  c                 j   U R                  5         U R                  5         U R                  5         U R                  5       nSU0nU R	                  U5      nU R                  US/ 5      n0 nSn/ n/ n	[        S[        U5      5       H  n
XZ   nU R                  US5      nUc  UO
[        X|5      nU R                  US5      nU R                  US5      nU R                  US5      nXR                  ;   nU(       a>  U R                  U5      nU R                  5       UU'   U R                  UU5      UU   S	'   M  Ub  M  UR                  U5        U	R                  U5        M     [        U5      nU(       a  S
U0nU R!                  U5      nU R                  US/ 5      n[        S[        U5      5       H  n
UU
   nX   nU R                  US5      nU R#                  U R                  US5      5      nU R                  US5      nU R                  U5      nU R                  5       UU'   [$        R&                  " UU5      UU   S	'   M     U R)                  5       nU R+                  U R,                  5      U R/                  US5      /nU R1                  U5      nU R3                  U R+                  U R4                  5      5      nU R7                  U R3                  U5      US5      nU R,                  U[9        U5      S.nU R;                  U5      n[=        UR?                  5       5      n [        S[        U 5      5       H\  n
U U
   nU R                  U5      nUU;  a  U R                  5       UU'   U R                  UU5      n!U R                  UU!5      UU   S'   M^     SU0n"U RA                  U"5      n#U R                  USU R                  5       5      US'   U R                  SU R                  U#S5      5      US   S	'   U RC                  U5      nXvS'   U RE                  U5      US'   U RG                  U5      $ )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>`
r1  r  Nr   r  issueTransactionassetIdbalancetotalidsr  r   r  r  r  )r0  r  r  usedr/  r  )$r  r  r1  r  nodeGetAssetsBalanceAddressrG  r]  r^  r  rn  rH  currencies_by_idrI  accountrJ  ry  publicGetAssetsrz  r#   rN  r  r  r  rS  r  r  r  r  r  )matcherGetMatcherBalanceReservedPublicKeyr9  r:  nodeGetAddressesBalanceAddressset_undefined_balances_to_zeror  safe_balance)$r  r7  r   r8  totalBalancer  r{  r  assetIdsnonStandardBalancesr_  r|  entryTimestampr  rB  r  currencyExistsr   nonStandardAssetsrequestInnerrP  r  innerr   r  currentTimestampr  r  r  r  matcherRequestreservedBalancereservedKeysr/  wavesRequest
wavesTotals$                                       r!  r  wavesexchange.fetch_balanceR  s    	((*  "--/|
 77@F ??<R@	 q#h-(AKE!..ukBN+4+<3yCaI#u6HI))%;J&&ui8G(,A,AAN..z:#||~t(,(F(FtW(UtW%!)
+#**73 )  Mx"L ++L9H??8VR8D1c$i(Q-0v6 001A1A%1UV	))%:..v6#||~t(/(:(:7I(NtW% )  ,,.!!$++..2
	 )))4))$*?*?*LM	LL!6!6v!>	9U	"-. 

 HHXO0023q#l+,A%aJ**:6DFN#||~t%%ozBF#'#A#A$#OF4L  - |
 88F
 //&'4<<>Jw#'#A#A'4K[K[\fhqKr#sw 44V<'{!\\)4z  ((r#  c                     [        UR                  5       5      n[        S[        U5      5       H%  nX4   nU R	                  X   S5      b  M  SX   U'   M'     U$ )Nr   r  r  )r9  r:  r]  r^  rG  )r  r  keyrE  r_  r   s         r!  r  ,wavesexchange.set_undefined_balances_to_zero  sT    X]]_%q#e*%A8Dx~v6>&)s# & r#  c                     U R                  5         U R                  5       nSU0nSnUb!  U R                  U5      nUS   US'   US   US'   U R                  U5      nU R	                  US5      n	U R                  XX#5      $ )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,  r  r-  r  r  )r1  r  r   publicGetTransactionsExchangerG  parse_trades)
r  r*  r  r   r7  r1  r8  r   rP  r  s
             r!  fetch_my_tradeswavesexchange.fetch_my_trades  s     	((*g
 [[(F%+H%5GM"$*9$5GL!55g>x0F   u<<r#  c                     U R                  5         U R                  U5      nUS   US   S.nUb  [        US5      US'   Ub  X&S'   U R                  U5      nU R	                  US5      nU R                  XX#5      $ )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-  r  r   r   r  r  )r1  r   rm  r%  rG  r&  )	r  r*  r  r   r7  r   r8  rP  r  s	            r!  fetch_tradeswavesexchange.fetch_trades7  s     	V$!(+ +
 "5#GG#(K 55g>x0F   u<<r#  tradec                    U R                  US5      nU R                  US5      nU R                  U5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  US5      n
S nU R                  U	S5      U R                  :X  a  U	nOsU R                  U
S5      U R                  :X  a  U
nOPU R                  U	S5      nU R                  U
S5      nU R                  U5      nU R                  U5      nX:  a  U	nOU
nS nU R                  US	5      nUb  U R	                  U5      nOUb  US
   nU R                  US5      nU R                  US5      nU R                  US5      U R                  U R                  USS5      5      S.nU R                  UUUUUUS US UUS US.U5      $ )Nr  r  r)   r0  r/  order1order2r  r  r*  r.  r@  r  r/  )rE  rC  )rv  r  r  r*  r)   r  rB  r6  rO  r0  r/  rE  r  )rG  rH  r%  r  r  rI  
safe_trade)r  r,  r   r  r  r  r)   rk  rc  r.  r/  r  date1date2ts1ts2r*  r  r6  r  r  s                        r!  parse_tradewavesexchange.parse_trade  s   ^ uf-##D+6NN8,	dD)&&tW5''h7x0x0F$56$++EEf&78DKKGE $$V[9E$$V[9E..'C..'CyOOE;7	 44Y?FH%F{3""5$/$$UL9//0@0@H[]d0ef
 "   " 
  	r#  rE  c                 z   0 nU R                  U5      n[        S[        U5      5       GHN  nX   nUnU R                  Xs5      nU R	                  U R
                  U5      n	U R                  U	SU5      n
Ub  U R                  X5      (       d  Me  U R	                  XJ5      nUc  U/S S S.S S S.0 S.nOXJ   nU R                  US   U/5      US'   U R                  US5      nU R                  U	S5      nU R                  X5      nU R	                  US   U5      nUc  S S S.S S S.S.nU R                  US	5      nU R	                  US
5      nSnUS:X  a  SnU R                  US5      SS.UU'   XS   U'   XU
'   GMQ     [        UR                  5       5      n[        S[        U5      5       H  nUU   n
XJ   nU R	                  US5      n[        UR                  5       5      n[        U5      nUS:X  d  MJ  U R	                  UUS   5      nU R	                  US5      XJ   S'   U R	                  US5      XJ   S'   M     U$ )Nr   r   )r  r  )rv  r   depositr   rv  r4  r   )r   r8  rB  feesr8  withdrawal_currencyr   flatFr   )market_codesr]  r^  rH  rG  r
  in_arrayarray_concatnetwork_id_to_coder&  r9  r:  )r  rP  rE  currencyIdKeydepositWithdrawFeesr_  r|  
dictionaryrB  rC  r   depositWithdrawFeerJ  rD  r_  r+  feeTyper9  
networkKeydepositWithdrawFeesKeysr   networkKeysnetworkKeysLengths                          r!  parse_deposit_withdraw_fees)wavesexchange.parse_deposit_withdraw_fees  s   $&!!%(q#h-(AKEJ))*DJt'<'<jIH##HfjAD4==#=#=%)__5H%O"%-!+#'*.%
 $(*.$ %'*& *=)B&151B1BCUV\C]`j_k1l&v. ,,ZG	#//&A"55iN//*<Z*H+V? $(*.%
 $(*.$	G **:v>z6:&
33!+J.2.>.>tV.L\a&b
#>E:.{;,>D)] )^ #'':'?'?'A"Bq#567A*1-D'-Euj9Hx}}/K #K 0 A%//(KNC8<Q[8\#)*57;wPY7Z#))4 8 #"r#  c                 T   U R                  5         / n/ nUR                  U R                  U5      5        UR                  U R                  U5      5        Un[	        S[        U5      5       H(  nU R                  XE   S5      nU R                  X65      nM*     U R                  X1S5      $ )au  
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  ry  privateGetDepositCurrenciesprivateGetWithdrawCurrenciesr]  r^  rG  r>  rI  )r  rE  r7  r  promisesr_  r,  s          r!  fetch_deposit_withdraw_fees)wavesexchange.fetch_deposit_withdraw_fees5	  s     	88@A99&ABr q#h-(AOOHK9E$$T1D ) //TBBr#  reasonr  r  r  r  c
                    U R                  US5      n
U R                  USS5      nU R                  U R                  U
5      nUb*  U R                  US5      nU" U R                  S-   U-   5      eU R                  US5      nUS:X  a  [        U R                  S-   U-   5      eU(       d  [        U R                  S-   U-   5      eg )NerrorsuccessTr  r.  zValidation Error)rH  rF  rG  r   r)   r   r   )r  r   rQ  r  r  r  r  rP  requestHeadersrequestBody	errorCoderT  r  messageInnerr  s                  r!  handle_errorswavesexchange.handle_errors	  s    $$Xw7	..9d;OODOOY?	 ++Hi@LDGGcML899""8Y7((TWWs]T122# 455r#  r1  r2  c                    U R                  XE5      u  pEUS:w  a  U R                  5       n0 nU R                  US/ 5      n[        S[	        U5      5       H  n	X   n
U R                  U
S5      nSX{'   M     X;  aC  [        UR                  5       5      n[        U R                  S-   U-   S-   [        U5      -   5      eU R                  5         / SQn0 n[        S[	        U5      5       H  n	X   nSX'   M     SnU R                  U5      nUR                  5       n[	        U5      S	-  n[        SU5       H  n	UU	   nUU;  d  M  S
n  O   U R                  5         SnUS:X  a
  U(       d  UnOUUS.nU R                  U5      nU R                  US5      nU R                  US5      nU R!                  US5      nUU::  a9  [#        U R                  S-   U-   S-   [        U5      -   S-   [        U5      -   5      eU R                  US/ 5      nU R                  US5      nU R%                  U R&                  SS5      nSnSnSnU R)                  X5      n U R+                  U5      n!U R-                  5       n"U R/                  SS	5      U R/                  SS	5      U R1                  U R2                  5      U R5                  U!S   5      U R5                  U5      U R/                  U"S5      U R/                  U S5      U R/                  US5      U R1                  U5      U R/                  SS5      /
n#U R7                  U#5      n$U R9                  U R1                  U R:                  5      5      n%U R=                  U R9                  U$5      U%S5      n&U R2                  U UUUSU R?                  U5      U&/U R?                  U!S   5      UU"U&S.n'U RA                  U'5      n(U RC                  U(U!5      $ )aO  
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)r1  rC  rC  allowed_amountrm  r.  z withdraw failed, amount z4 must be greater than the minimum allowed amount of proxy_addressesr   r   r  r  r  r  r  )r  r/  r  rB  r  r  rA  proofsr  	recipientr  r  )"handle_withdraw_tag_and_paramsrM  rG  r]  r^  rH  r9  r:  r   r)   r  r1  remove0x_prefixlowerr  *privateGetWithdrawAddressesCurrencyAddressr&  r   r  r   ra  rC  r  rS  r  r  rV  r  r  r  r  rZ  nodePostTransactionsBroadcastparse_transaction))r  r   r/  r1  r2  r7  r@  r   r,  r_  r|  rD  rE  hexCharssetr!  isErc20noPrefixrn  stringLength	characterproxyAddresswithdrawAddressRequestwithdrawAddresscurrencyInnerallowedAmountminimumproxyAddressesr  rA  rB  r  amountIntegerrC  r  r  r  r  r  r8  r{  s)                                            r!  r   wavesexchange.withdraw	  s    99#F7?"&"C"C"E!JOO$7"EE1c%j)#//t<+/
( * &Z__./#DGGn$<t$CFu$ux{  }B  yC  %C  D  Dcq#h-(A+CCH ) ''0 5zA~q,'AaI$	 (
 	7?7"L # ," #MMNdeO OOOZHM OOM;KLM&&}e<G  3!58S!SVYZ`Va!a  e[  "[  ^a  bi  ^j  "j  k  k, "___>OQSTN++NA>L.@&I
44TB==&%%'	a#a#!!$++.  $0  ,i+mQ/c1%!!,/a#
	 )))4))$*?*?*LM	LL!6!6v!>	9U	#{{#++J7 (($8%""
  33G< %%fh77r#  transactionrC  c           	         U R                  S U5      nUS   nU R                  US5      nUS:X  a  SOSnU R                  U R                  X0R                  US5      5      5      nU R                  US5      nU R                  USS	5      nU R	                  U5      n	U R                  U R                  X5      5      n
U R                  US
5      n0 SU R                  US5      _SS _S
U_SU R                  U5      _SS _SU R                  US5      _SS _SU R                  US5      _SU_SU_SUS   _SS _SS _SS _SS _SS _SS _S U	U
S.US.E$ )Nr   rB  r  r   r8  r/  r  rA  r/  r  r)   txidr  r+  addressFromr$  r1  	addressTork  rC  r  updatedtagFromr2  tagTocomment)rC  rE  )internalr  rv  )safe_currencyrH  r  rJ  rI  r  r  )r  r  rC  r   typeRawrB  r/  	feeStringrA  feeCode	feeAmountr  s               r!  rq  wavesexchange.parse_transaction
  s   > %%dH5"";7%nz9""4#A#A$HXHXYdfnHo#pq$$[%8	%%k<I
))*5%%d&D&DW&XY	%%k;?	
$"";5
D
 
 Y/	

 t
 4++KB
 t
 ))+{C
 f
 D
 (
 d
 t
 t
 4
  T!
" t#
$ #!  /
 	
r#  rY  )NN)N)r  )N__name__
__module____qualname____firstlineno__r   r  r'  r  r9  rX  r`  r   r
   r~  r	   r   r  r  r  r  r  dictr   r  r  r   r   r  r9  r  r  r(  r   rL  rP  rV  rZ  r  ra  rJ  r3  rn  r2  rt  r}  r  r   r   r   r  r   r  r  r   r  r  r  r  r  r  r  r   r  r  r'  r   r*  r5  rI  rO  r^  rY  r   r   r   rq  __static_attributes____classcell__)r   s   @r!  r%   r%      s   Z# Zx=
 KM R R Y`hj 
3 
B?B $& _$v, _B :>b 
s 
3 
Y 
<# 4. &eBSW +PZ   %NH4 H H6 HT 02 *53 *5f *5X 04B %5W %57 %5N 9=4^bkm U# U# US UX[ Urvw{r| Un
 
4 
: 79 ~
# ~
^ ~
@	4b
 C    
Ac A A 3  u  
_S _s _ C    
Oc O OP gksu j33 j3i j3y j3RW j3`c j3X 37r /s /C /b 26b  2c  23  2D *.Dt\^ /A3 /Ac /A /Acghmcn /Ab /3TXac A A3 Ac Ahlmrhs A, 154VZce (A# (AS (APS (Ajnotju (AT: :Xx xv x xt
" $& )( )B -1tRV_a Z=c Z= Z=C Z=x 6:UW Z=3 Z=s Z=# Z=\`af\g Z=xa av a aF=#7 =#be =#~ <@ LC LC\# s  c TX `c  KOWY }8S }8% }8# }8C }8^i }8~A
T A
X A
Q\ 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%   rY  r#  r!  <module>r     sh    ( 3  q  q  q  q  q  * 0 - . ' & . ) * - 1 4 %w(
Hk w(
r#  