ccxt 4.2.11 → 4.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build.sh +2 -2
- package/dist/ccxt.browser.js +1347 -490
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/_virtual/agent.js +7 -0
- package/dist/cjs/_virtual/parse-proxy-response.js +7 -0
- package/dist/cjs/_virtual/promisify.js +7 -0
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/js/ccxt.js +474 -0
- package/dist/cjs/js/src/abstract/ace.js +9 -0
- package/dist/cjs/js/src/abstract/alpaca.js +9 -0
- package/dist/cjs/js/src/abstract/ascendex.js +9 -0
- package/dist/cjs/js/src/abstract/bigone.js +9 -0
- package/dist/cjs/js/src/abstract/binance.js +9 -0
- package/dist/cjs/js/src/abstract/bingx.js +9 -0
- package/dist/cjs/js/src/abstract/bit2c.js +9 -0
- package/dist/cjs/js/src/abstract/bitbank.js +9 -0
- package/dist/cjs/js/src/abstract/bitbns.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex2.js +9 -0
- package/dist/cjs/js/src/abstract/bitflyer.js +9 -0
- package/dist/cjs/js/src/abstract/bitforex.js +9 -0
- package/dist/cjs/js/src/abstract/bitget.js +9 -0
- package/dist/cjs/js/src/abstract/bithumb.js +9 -0
- package/dist/cjs/js/src/abstract/bitmart.js +9 -0
- package/dist/cjs/js/src/abstract/bitmex.js +9 -0
- package/dist/cjs/js/src/abstract/bitopro.js +9 -0
- package/dist/cjs/js/src/abstract/bitpanda.js +9 -0
- package/dist/cjs/js/src/abstract/bitrue.js +9 -0
- package/dist/cjs/js/src/abstract/bitso.js +9 -0
- package/dist/cjs/js/src/abstract/bitstamp.js +9 -0
- package/dist/cjs/js/src/abstract/bitteam.js +9 -0
- package/dist/cjs/js/src/abstract/bitvavo.js +9 -0
- package/dist/cjs/js/src/abstract/bl3p.js +9 -0
- package/dist/cjs/js/src/abstract/blockchaincom.js +9 -0
- package/dist/cjs/js/src/abstract/btcalpha.js +9 -0
- package/dist/cjs/js/src/abstract/btcbox.js +9 -0
- package/dist/cjs/js/src/abstract/btcmarkets.js +9 -0
- package/dist/cjs/js/src/abstract/btcturk.js +9 -0
- package/dist/cjs/js/src/abstract/bybit.js +9 -0
- package/dist/cjs/js/src/abstract/cex.js +9 -0
- package/dist/cjs/js/src/abstract/coinbase.js +9 -0
- package/dist/cjs/js/src/abstract/coinbasepro.js +9 -0
- package/dist/cjs/js/src/abstract/coincheck.js +9 -0
- package/dist/cjs/js/src/abstract/coinex.js +9 -0
- package/dist/cjs/js/src/abstract/coinlist.js +9 -0
- package/dist/cjs/js/src/abstract/coinmate.js +9 -0
- package/dist/cjs/js/src/abstract/coinone.js +9 -0
- package/dist/cjs/js/src/abstract/coinsph.js +9 -0
- package/dist/cjs/js/src/abstract/coinspot.js +9 -0
- package/dist/cjs/js/src/abstract/cryptocom.js +9 -0
- package/dist/cjs/js/src/abstract/currencycom.js +9 -0
- package/dist/cjs/js/src/abstract/delta.js +9 -0
- package/dist/cjs/js/src/abstract/deribit.js +9 -0
- package/dist/cjs/js/src/abstract/digifinex.js +9 -0
- package/dist/cjs/js/src/abstract/exmo.js +9 -0
- package/dist/cjs/js/src/abstract/gate.js +9 -0
- package/dist/cjs/js/src/abstract/gemini.js +9 -0
- package/dist/cjs/js/src/abstract/hitbtc.js +9 -0
- package/dist/cjs/js/src/abstract/hollaex.js +9 -0
- package/dist/cjs/js/src/abstract/htx.js +9 -0
- package/dist/cjs/js/src/abstract/huobijp.js +9 -0
- package/dist/cjs/js/src/abstract/idex.js +9 -0
- package/dist/cjs/js/src/abstract/independentreserve.js +9 -0
- package/dist/cjs/js/src/abstract/indodax.js +9 -0
- package/dist/cjs/js/src/abstract/kraken.js +9 -0
- package/dist/cjs/js/src/abstract/krakenfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kucoin.js +9 -0
- package/dist/cjs/js/src/abstract/kucoinfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kuna.js +9 -0
- package/dist/cjs/js/src/abstract/latoken.js +9 -0
- package/dist/cjs/js/src/abstract/lbank.js +9 -0
- package/dist/cjs/js/src/abstract/luno.js +9 -0
- package/dist/cjs/js/src/abstract/lykke.js +9 -0
- package/dist/cjs/js/src/abstract/mercado.js +9 -0
- package/dist/cjs/js/src/abstract/mexc.js +9 -0
- package/dist/cjs/js/src/abstract/ndax.js +9 -0
- package/dist/cjs/js/src/abstract/novadax.js +9 -0
- package/dist/cjs/js/src/abstract/oceanex.js +9 -0
- package/dist/cjs/js/src/abstract/okcoin.js +9 -0
- package/dist/cjs/js/src/abstract/okx.js +9 -0
- package/dist/cjs/js/src/abstract/p2b.js +9 -0
- package/dist/cjs/js/src/abstract/paymium.js +9 -0
- package/dist/cjs/js/src/abstract/phemex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniexfutures.js +9 -0
- package/dist/cjs/js/src/abstract/probit.js +9 -0
- package/dist/cjs/js/src/abstract/timex.js +9 -0
- package/dist/cjs/js/src/abstract/tokocrypto.js +9 -0
- package/dist/cjs/js/src/abstract/upbit.js +9 -0
- package/dist/cjs/js/src/abstract/wavesexchange.js +9 -0
- package/dist/cjs/js/src/abstract/wazirx.js +9 -0
- package/dist/cjs/js/src/abstract/whitebit.js +9 -0
- package/dist/cjs/js/src/abstract/woo.js +9 -0
- package/dist/cjs/js/src/abstract/yobit.js +9 -0
- package/dist/cjs/js/src/abstract/zaif.js +9 -0
- package/dist/cjs/js/src/abstract/zonda.js +9 -0
- package/dist/cjs/js/src/ace.js +1058 -0
- package/dist/cjs/js/src/alpaca.js +1125 -0
- package/dist/cjs/js/src/ascendex.js +3360 -0
- package/dist/cjs/js/src/base/Exchange.js +5110 -0
- package/dist/cjs/js/src/base/Precise.js +263 -0
- package/dist/cjs/js/src/base/errors.js +299 -0
- package/dist/cjs/js/src/base/functions/crypto.js +78 -0
- package/dist/cjs/js/src/base/functions/encode.js +44 -0
- package/dist/cjs/js/src/base/functions/generic.js +193 -0
- package/dist/cjs/js/src/base/functions/misc.js +96 -0
- package/dist/cjs/js/src/base/functions/number.js +297 -0
- package/dist/cjs/js/src/base/functions/platform.js +28 -0
- package/dist/cjs/js/src/base/functions/rsa.js +34 -0
- package/dist/cjs/js/src/base/functions/string.js +48 -0
- package/dist/cjs/js/src/base/functions/throttle.js +66 -0
- package/dist/cjs/js/src/base/functions/time.js +187 -0
- package/dist/cjs/js/src/base/functions/totp.js +24 -0
- package/dist/cjs/js/src/base/functions/type.js +162 -0
- package/dist/cjs/js/src/base/functions.js +157 -0
- package/dist/cjs/js/src/base/ws/Cache.js +254 -0
- package/dist/cjs/js/src/base/ws/Client.js +299 -0
- package/dist/cjs/js/src/base/ws/Future.js +34 -0
- package/dist/cjs/js/src/base/ws/OrderBook.js +107 -0
- package/dist/cjs/js/src/base/ws/OrderBookSide.js +281 -0
- package/dist/cjs/js/src/base/ws/WsClient.js +69 -0
- package/dist/cjs/js/src/bequant.js +33 -0
- package/dist/cjs/js/src/bigone.js +2209 -0
- package/dist/cjs/js/src/binance.js +9736 -0
- package/dist/cjs/js/src/binancecoinm.js +45 -0
- package/dist/cjs/js/src/binanceus.js +84 -0
- package/dist/cjs/js/src/binanceusdm.js +58 -0
- package/dist/cjs/js/src/bingx.js +3807 -0
- package/dist/cjs/js/src/bit2c.js +916 -0
- package/dist/cjs/js/src/bitbank.js +1000 -0
- package/dist/cjs/js/src/bitbay.js +17 -0
- package/dist/cjs/js/src/bitbns.js +1220 -0
- package/dist/cjs/js/src/bitcoincom.js +17 -0
- package/dist/cjs/js/src/bitfinex.js +1670 -0
- package/dist/cjs/js/src/bitfinex2.js +2990 -0
- package/dist/cjs/js/src/bitflyer.js +1045 -0
- package/dist/cjs/js/src/bitforex.js +852 -0
- package/dist/cjs/js/src/bitget.js +8291 -0
- package/dist/cjs/js/src/bithumb.js +1090 -0
- package/dist/cjs/js/src/bitmart.js +4454 -0
- package/dist/cjs/js/src/bitmex.js +2884 -0
- package/dist/cjs/js/src/bitopro.js +1724 -0
- package/dist/cjs/js/src/bitpanda.js +2002 -0
- package/dist/cjs/js/src/bitrue.js +3253 -0
- package/dist/cjs/js/src/bitso.js +1753 -0
- package/dist/cjs/js/src/bitstamp.js +2188 -0
- package/dist/cjs/js/src/bitteam.js +2309 -0
- package/dist/cjs/js/src/bitvavo.js +1968 -0
- package/dist/cjs/js/src/bl3p.js +447 -0
- package/dist/cjs/js/src/blockchaincom.js +1160 -0
- package/dist/cjs/js/src/btcalpha.js +929 -0
- package/dist/cjs/js/src/btcbox.js +565 -0
- package/dist/cjs/js/src/btcmarkets.js +1237 -0
- package/dist/cjs/js/src/btcturk.js +929 -0
- package/dist/cjs/js/src/bybit.js +7646 -0
- package/dist/cjs/js/src/cex.js +1693 -0
- package/dist/cjs/js/src/coinbase.js +3424 -0
- package/dist/cjs/js/src/coinbasepro.js +1866 -0
- package/dist/cjs/js/src/coincheck.js +843 -0
- package/dist/cjs/js/src/coinex.js +5414 -0
- package/dist/cjs/js/src/coinlist.js +2329 -0
- package/dist/cjs/js/src/coinmate.js +989 -0
- package/dist/cjs/js/src/coinone.js +1185 -0
- package/dist/cjs/js/src/coinsph.js +1933 -0
- package/dist/cjs/js/src/coinspot.js +548 -0
- package/dist/cjs/js/src/cryptocom.js +3007 -0
- package/dist/cjs/js/src/currencycom.js +2015 -0
- package/dist/cjs/js/src/delta.js +3256 -0
- package/dist/cjs/js/src/deribit.js +3306 -0
- package/dist/cjs/js/src/digifinex.js +4307 -0
- package/dist/cjs/js/src/exmo.js +2645 -0
- package/dist/cjs/js/src/fmfwio.js +34 -0
- package/dist/cjs/js/src/gate.js +7072 -0
- package/dist/cjs/js/src/gateio.js +16 -0
- package/dist/cjs/js/src/gemini.js +1801 -0
- package/dist/cjs/js/src/hitbtc.js +3660 -0
- package/dist/cjs/js/src/hitbtc3.js +19 -0
- package/dist/cjs/js/src/hollaex.js +1882 -0
- package/dist/cjs/js/src/htx.js +9049 -0
- package/dist/cjs/js/src/huobi.js +16 -0
- package/dist/cjs/js/src/huobijp.js +1918 -0
- package/dist/cjs/js/src/idex.js +1770 -0
- package/dist/cjs/js/src/independentreserve.js +761 -0
- package/dist/cjs/js/src/indodax.js +1069 -0
- package/dist/cjs/js/src/kraken.js +2857 -0
- package/dist/cjs/js/src/krakenfutures.js +2407 -0
- package/dist/cjs/js/src/kucoin.js +4489 -0
- package/dist/cjs/js/src/kucoinfutures.js +2475 -0
- package/dist/cjs/js/src/kuna.js +1949 -0
- package/dist/cjs/js/src/latoken.js +1729 -0
- package/dist/cjs/js/src/lbank.js +2851 -0
- package/dist/cjs/js/src/luno.js +1044 -0
- package/dist/cjs/js/src/lykke.js +1303 -0
- package/dist/cjs/js/src/mercado.js +897 -0
- package/dist/cjs/js/src/mexc.js +5407 -0
- package/dist/cjs/js/src/ndax.js +2450 -0
- package/dist/cjs/js/src/novadax.js +1556 -0
- package/dist/cjs/js/src/oceanex.js +964 -0
- package/dist/cjs/js/src/okcoin.js +3115 -0
- package/dist/cjs/js/src/okx.js +7330 -0
- package/dist/cjs/js/src/p2b.js +1243 -0
- package/dist/cjs/js/src/paymium.js +597 -0
- package/dist/cjs/js/src/phemex.js +4722 -0
- package/dist/cjs/js/src/poloniex.js +2356 -0
- package/dist/cjs/js/src/poloniexfutures.js +1794 -0
- package/dist/cjs/js/src/pro/alpaca.js +714 -0
- package/dist/cjs/js/src/pro/ascendex.js +957 -0
- package/dist/cjs/js/src/pro/bequant.js +33 -0
- package/dist/cjs/js/src/pro/binance.js +2796 -0
- package/dist/cjs/js/src/pro/binancecoinm.js +23 -0
- package/dist/cjs/js/src/pro/binanceus.js +51 -0
- package/dist/cjs/js/src/pro/binanceusdm.js +32 -0
- package/dist/cjs/js/src/pro/bingx.js +944 -0
- package/dist/cjs/js/src/pro/bitcoincom.js +29 -0
- package/dist/cjs/js/src/pro/bitfinex.js +672 -0
- package/dist/cjs/js/src/pro/bitfinex2.js +1159 -0
- package/dist/cjs/js/src/pro/bitget.js +1733 -0
- package/dist/cjs/js/src/pro/bitmart.js +1486 -0
- package/dist/cjs/js/src/pro/bitmex.js +1576 -0
- package/dist/cjs/js/src/pro/bitopro.js +327 -0
- package/dist/cjs/js/src/pro/bitpanda.js +1341 -0
- package/dist/cjs/js/src/pro/bitrue.js +462 -0
- package/dist/cjs/js/src/pro/bitstamp.js +547 -0
- package/dist/cjs/js/src/pro/bitvavo.js +704 -0
- package/dist/cjs/js/src/pro/blockchaincom.js +794 -0
- package/dist/cjs/js/src/pro/bybit.js +1843 -0
- package/dist/cjs/js/src/pro/cex.js +1510 -0
- package/dist/cjs/js/src/pro/coinbase.js +561 -0
- package/dist/cjs/js/src/pro/coinbasepro.js +968 -0
- package/dist/cjs/js/src/pro/coinex.js +1095 -0
- package/dist/cjs/js/src/pro/cryptocom.js +1020 -0
- package/dist/cjs/js/src/pro/currencycom.js +563 -0
- package/dist/cjs/js/src/pro/deribit.js +825 -0
- package/dist/cjs/js/src/pro/exmo.js +658 -0
- package/dist/cjs/js/src/pro/gate.js +1316 -0
- package/dist/cjs/js/src/pro/gateio.js +16 -0
- package/dist/cjs/js/src/pro/gemini.js +649 -0
- package/dist/cjs/js/src/pro/hitbtc.js +1293 -0
- package/dist/cjs/js/src/pro/hollaex.js +597 -0
- package/dist/cjs/js/src/pro/htx.js +2383 -0
- package/dist/cjs/js/src/pro/huobi.js +16 -0
- package/dist/cjs/js/src/pro/huobijp.js +606 -0
- package/dist/cjs/js/src/pro/idex.js +714 -0
- package/dist/cjs/js/src/pro/independentreserve.js +280 -0
- package/dist/cjs/js/src/pro/kraken.js +1364 -0
- package/dist/cjs/js/src/pro/krakenfutures.js +1500 -0
- package/dist/cjs/js/src/pro/kucoin.js +1052 -0
- package/dist/cjs/js/src/pro/kucoinfutures.js +981 -0
- package/dist/cjs/js/src/pro/luno.js +322 -0
- package/dist/cjs/js/src/pro/mexc.js +1170 -0
- package/dist/cjs/js/src/pro/ndax.js +545 -0
- package/dist/cjs/js/src/pro/okcoin.js +760 -0
- package/dist/cjs/js/src/pro/okx.js +1608 -0
- package/dist/cjs/js/src/pro/phemex.js +1511 -0
- package/dist/cjs/js/src/pro/poloniex.js +1253 -0
- package/dist/cjs/js/src/pro/poloniexfutures.js +1014 -0
- package/dist/cjs/js/src/pro/probit.js +586 -0
- package/dist/cjs/js/src/pro/upbit.js +234 -0
- package/dist/cjs/js/src/pro/wazirx.js +776 -0
- package/dist/cjs/js/src/pro/whitebit.js +927 -0
- package/dist/cjs/js/src/pro/woo.js +769 -0
- package/dist/cjs/js/src/probit.js +1867 -0
- package/dist/cjs/js/src/static_dependencies/fflake/browser.js +401 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +195 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +308 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +554 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +16 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1760 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +52 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +81 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +376 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1580 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +74 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +24 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +158 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +429 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +176 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +324 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +163 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +245 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1018 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +383 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +258 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +53 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +120 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +69 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +7 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +83 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +240 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +91 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +130 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +214 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +239 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +93 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +354 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +20 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +30 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +239 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +372 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +273 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +139 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +14 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +81 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +292 -0
- package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +103 -0
- package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +140 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +175 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
- package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +7 -0
- package/dist/cjs/js/src/static_dependencies/scure-base/index.js +383 -0
- package/dist/cjs/js/src/timex.js +1562 -0
- package/dist/cjs/js/src/tokocrypto.js +2542 -0
- package/dist/cjs/js/src/upbit.js +1844 -0
- package/dist/cjs/js/src/wavesexchange.js +2607 -0
- package/dist/cjs/js/src/wazirx.js +953 -0
- package/dist/cjs/js/src/whitebit.js +2309 -0
- package/dist/cjs/js/src/woo.js +2765 -0
- package/dist/cjs/js/src/yobit.js +1314 -0
- package/dist/cjs/js/src/zaif.js +736 -0
- package/dist/cjs/js/src/zonda.js +1883 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bigone.d.ts +18 -0
- package/js/src/abstract/binance.d.ts +2 -0
- package/js/src/abstract/binancecoinm.d.ts +2 -0
- package/js/src/abstract/binanceus.d.ts +2 -0
- package/js/src/abstract/binanceusdm.d.ts +2 -0
- package/js/src/abstract/bingx.d.ts +2 -0
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/abstract/gate.d.ts +11 -0
- package/js/src/abstract/gateio.d.ts +11 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/alpaca.js +18 -18
- package/js/src/base/Exchange.d.ts +5 -1
- package/js/src/base/Exchange.js +101 -12
- package/js/src/bigone.d.ts +3 -2
- package/js/src/bigone.js +429 -167
- package/js/src/binance.js +48 -34
- package/js/src/bingx.js +115 -38
- package/js/src/bitfinex.d.ts +2 -2
- package/js/src/bitfinex.js +2 -3
- package/js/src/bitget.js +33 -13
- package/js/src/bitmart.d.ts +2 -2
- package/js/src/bitmart.js +5 -5
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +2 -0
- package/js/src/coinbase.d.ts +26 -3
- package/js/src/coinbase.js +176 -26
- package/js/src/coinlist.js +3 -4
- package/js/src/coinone.js +1 -1
- package/js/src/coinsph.js +2 -3
- package/js/src/deribit.js +1 -0
- package/js/src/gate.d.ts +4 -4
- package/js/src/gate.js +96 -59
- package/js/src/gemini.js +1 -1
- package/js/src/hitbtc.d.ts +4 -4
- package/js/src/hitbtc.js +2 -3
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +29 -7
- package/js/src/huobijp.js +2 -3
- package/js/src/independentreserve.js +7 -5
- package/js/src/kraken.js +3 -6
- package/js/src/lbank.js +59 -33
- package/js/src/mexc.js +2 -1
- package/js/src/oceanex.js +1 -1
- package/js/src/okx.js +14 -3
- package/js/src/phemex.js +9 -2
- package/js/src/pro/binance.d.ts +2 -23
- package/js/src/pro/binance.js +58 -22
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/coinbase.js +4 -1
- package/js/src/pro/coinbasepro.d.ts +2 -2
- package/js/src/pro/hitbtc.d.ts +2 -2
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/okx.d.ts +1 -0
- package/js/src/pro/okx.js +52 -2
- package/js/src/pro/poloniex.d.ts +2 -2
- package/js/src/probit.js +4 -2
- package/js/src/upbit.d.ts +3 -101
- package/js/src/upbit.js +12 -12
- package/js/src/wavesexchange.js +1 -1
- package/js/src/woo.d.ts +2 -0
- package/js/src/woo.js +52 -0
- package/package.json +1 -1
- package/skip-tests.json +5 -0
|
@@ -0,0 +1,2607 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var wavesexchange$1 = require('./abstract/wavesexchange.js');
|
|
4
|
+
var errors = require('./base/errors.js');
|
|
5
|
+
var Precise = require('./base/Precise.js');
|
|
6
|
+
var ed25519 = require('./static_dependencies/noble-curves/ed25519.js');
|
|
7
|
+
var number = require('./base/functions/number.js');
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* @class wavesexchange
|
|
13
|
+
* @augments Exchange
|
|
14
|
+
*/
|
|
15
|
+
class wavesexchange extends wavesexchange$1 {
|
|
16
|
+
describe() {
|
|
17
|
+
return this.deepExtend(super.describe(), {
|
|
18
|
+
'id': 'wavesexchange',
|
|
19
|
+
'name': 'Waves.Exchange',
|
|
20
|
+
'countries': ['CH'],
|
|
21
|
+
'certified': false,
|
|
22
|
+
'pro': false,
|
|
23
|
+
'has': {
|
|
24
|
+
'CORS': undefined,
|
|
25
|
+
'spot': true,
|
|
26
|
+
'margin': false,
|
|
27
|
+
'swap': false,
|
|
28
|
+
'future': false,
|
|
29
|
+
'option': false,
|
|
30
|
+
'addMargin': false,
|
|
31
|
+
'cancelOrder': true,
|
|
32
|
+
'closeAllPositions': false,
|
|
33
|
+
'closePosition': false,
|
|
34
|
+
'createMarketOrder': true,
|
|
35
|
+
'createOrder': true,
|
|
36
|
+
'createReduceOnlyOrder': false,
|
|
37
|
+
'createStopLimitOrder': false,
|
|
38
|
+
'createStopMarketOrder': false,
|
|
39
|
+
'createStopOrder': false,
|
|
40
|
+
'fetchBalance': true,
|
|
41
|
+
'fetchBorrowRateHistories': false,
|
|
42
|
+
'fetchBorrowRateHistory': false,
|
|
43
|
+
'fetchClosedOrders': true,
|
|
44
|
+
'fetchCrossBorrowRate': false,
|
|
45
|
+
'fetchCrossBorrowRates': false,
|
|
46
|
+
'fetchDepositAddress': true,
|
|
47
|
+
'fetchDepositWithdrawFee': 'emulated',
|
|
48
|
+
'fetchDepositWithdrawFees': true,
|
|
49
|
+
'fetchFundingHistory': false,
|
|
50
|
+
'fetchFundingRate': false,
|
|
51
|
+
'fetchFundingRateHistory': false,
|
|
52
|
+
'fetchFundingRates': false,
|
|
53
|
+
'fetchIndexOHLCV': false,
|
|
54
|
+
'fetchIsolatedBorrowRate': false,
|
|
55
|
+
'fetchIsolatedBorrowRates': false,
|
|
56
|
+
'fetchLeverage': false,
|
|
57
|
+
'fetchLeverageTiers': false,
|
|
58
|
+
'fetchMarginMode': false,
|
|
59
|
+
'fetchMarkets': true,
|
|
60
|
+
'fetchMarkOHLCV': false,
|
|
61
|
+
'fetchMyTrades': true,
|
|
62
|
+
'fetchOHLCV': true,
|
|
63
|
+
'fetchOpenInterestHistory': false,
|
|
64
|
+
'fetchOpenOrders': true,
|
|
65
|
+
'fetchOrder': true,
|
|
66
|
+
'fetchOrderBook': true,
|
|
67
|
+
'fetchOrders': true,
|
|
68
|
+
'fetchPosition': false,
|
|
69
|
+
'fetchPositionMode': false,
|
|
70
|
+
'fetchPositions': false,
|
|
71
|
+
'fetchPositionsRisk': false,
|
|
72
|
+
'fetchPremiumIndexOHLCV': false,
|
|
73
|
+
'fetchTicker': true,
|
|
74
|
+
'fetchTickers': true,
|
|
75
|
+
'fetchTrades': true,
|
|
76
|
+
'fetchTransfer': false,
|
|
77
|
+
'fetchTransfers': false,
|
|
78
|
+
'reduceMargin': false,
|
|
79
|
+
'setLeverage': false,
|
|
80
|
+
'setMarginMode': false,
|
|
81
|
+
'setPositionMode': false,
|
|
82
|
+
'signIn': true,
|
|
83
|
+
'transfer': false,
|
|
84
|
+
'withdraw': true,
|
|
85
|
+
'ws': false,
|
|
86
|
+
},
|
|
87
|
+
'timeframes': {
|
|
88
|
+
'1m': '1m',
|
|
89
|
+
'5m': '5m',
|
|
90
|
+
'15m': '15m',
|
|
91
|
+
'30m': '30m',
|
|
92
|
+
'1h': '1h',
|
|
93
|
+
'2h': '2h',
|
|
94
|
+
'3h': '3h',
|
|
95
|
+
'4h': '4h',
|
|
96
|
+
'6h': '6h',
|
|
97
|
+
'12h': '12h',
|
|
98
|
+
'1d': '1d',
|
|
99
|
+
'1w': '1w',
|
|
100
|
+
'1M': '1M',
|
|
101
|
+
},
|
|
102
|
+
'urls': {
|
|
103
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/84547058-5fb27d80-ad0b-11ea-8711-78ac8b3c7f31.jpg',
|
|
104
|
+
'test': {
|
|
105
|
+
'matcher': 'https://matcher-testnet.wx.network',
|
|
106
|
+
'node': 'https://nodes-testnet.wavesnodes.com',
|
|
107
|
+
'public': 'https://api-testnet.wavesplatform.com/v0',
|
|
108
|
+
'private': 'https://api-testnet.wx.network/v1',
|
|
109
|
+
'forward': 'https://testnet.wx.network/api/v1/forward/matcher',
|
|
110
|
+
'market': 'https://testnet.wx.network/api/v1/forward/marketdata/api/v1',
|
|
111
|
+
},
|
|
112
|
+
'api': {
|
|
113
|
+
'matcher': 'https://matcher.wx.network',
|
|
114
|
+
'node': 'https://nodes.wx.network',
|
|
115
|
+
'public': 'https://api.wavesplatform.com/v0',
|
|
116
|
+
'private': 'https://api.wx.network/v1',
|
|
117
|
+
'forward': 'https://wx.network/api/v1/forward/matcher',
|
|
118
|
+
'market': 'https://wx.network/api/v1/forward/marketdata/api/v1',
|
|
119
|
+
},
|
|
120
|
+
'doc': 'https://docs.wx.network',
|
|
121
|
+
'www': 'https://wx.network',
|
|
122
|
+
},
|
|
123
|
+
'api': {
|
|
124
|
+
'matcher': {
|
|
125
|
+
'get': [
|
|
126
|
+
'matcher',
|
|
127
|
+
'matcher/settings',
|
|
128
|
+
'matcher/settings/rates',
|
|
129
|
+
'matcher/balance/reserved/{publicKey}',
|
|
130
|
+
'matcher/debug/allSnashotOffsets',
|
|
131
|
+
'matcher/debug/currentOffset',
|
|
132
|
+
'matcher/debug/lastOffset',
|
|
133
|
+
'matcher/debug/oldestSnapshotOffset',
|
|
134
|
+
'matcher/debug/config',
|
|
135
|
+
'matcher/debug/address/{address}',
|
|
136
|
+
'matcher/debug/status',
|
|
137
|
+
'matcher/debug/address/{address}/check',
|
|
138
|
+
'matcher/orderbook',
|
|
139
|
+
'matcher/orderbook/{baseId}/{quoteId}',
|
|
140
|
+
'matcher/orderbook/{baseId}/{quoteId}/publicKey/{publicKey}',
|
|
141
|
+
'matcher/orderbook/{baseId}/{quoteId}/{orderId}',
|
|
142
|
+
'matcher/orderbook/{baseId}/{quoteId}/info',
|
|
143
|
+
'matcher/orderbook/{baseId}/{quoteId}/status',
|
|
144
|
+
'matcher/orderbook/{baseId}/{quoteId}/tradableBalance/{address}',
|
|
145
|
+
'matcher/orderbook/{publicKey}',
|
|
146
|
+
'matcher/orderbook/{publicKey}/{orderId}',
|
|
147
|
+
'matcher/orders/{address}',
|
|
148
|
+
'matcher/orders/{address}/{orderId}',
|
|
149
|
+
'matcher/transactions/{orderId}',
|
|
150
|
+
'api/v1/orderbook/{baseId}/{quoteId}',
|
|
151
|
+
],
|
|
152
|
+
'post': [
|
|
153
|
+
'matcher/orderbook',
|
|
154
|
+
'matcher/orderbook/market',
|
|
155
|
+
'matcher/orderbook/cancel',
|
|
156
|
+
'matcher/orderbook/{baseId}/{quoteId}/cancel',
|
|
157
|
+
'matcher/orderbook/{baseId}/{quoteId}/calculateFee',
|
|
158
|
+
'matcher/orderbook/{baseId}/{quoteId}/delete',
|
|
159
|
+
'matcher/orderbook/{baseId}/{quoteId}/cancelAll',
|
|
160
|
+
'matcher/debug/saveSnapshots',
|
|
161
|
+
'matcher/orders/{address}/cancel',
|
|
162
|
+
'matcher/orders/cancel/{orderId}',
|
|
163
|
+
'matcher/orders/serialize',
|
|
164
|
+
],
|
|
165
|
+
'delete': [
|
|
166
|
+
'matcher/orderbook/{baseId}/{quoteId}',
|
|
167
|
+
'matcher/settings/rates/{assetId}',
|
|
168
|
+
],
|
|
169
|
+
'put': [
|
|
170
|
+
'matcher/settings/rates/{assetId}',
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
'node': {
|
|
174
|
+
'get': [
|
|
175
|
+
'addresses',
|
|
176
|
+
'addresses/balance/{address}',
|
|
177
|
+
'addresses/balance/{address}/{confirmations}',
|
|
178
|
+
'addresses/balance/details/{address}',
|
|
179
|
+
'addresses/data/{address}',
|
|
180
|
+
'addresses/data/{address}/{key}',
|
|
181
|
+
'addresses/effectiveBalance/{address}',
|
|
182
|
+
'addresses/effectiveBalance/{address}/{confirmations}',
|
|
183
|
+
'addresses/publicKey/{publicKey}',
|
|
184
|
+
'addresses/scriptInfo/{address}',
|
|
185
|
+
'addresses/scriptInfo/{address}/meta',
|
|
186
|
+
'addresses/seed/{address}',
|
|
187
|
+
'addresses/seq/{from}/{to}',
|
|
188
|
+
'addresses/validate/{address}',
|
|
189
|
+
'alias/by-address/{address}',
|
|
190
|
+
'alias/by-alias/{alias}',
|
|
191
|
+
'assets/{assetId}/distribution/{height}/{limit}',
|
|
192
|
+
'assets/balance/{address}',
|
|
193
|
+
'assets/balance/{address}/{assetId}',
|
|
194
|
+
'assets/details/{assetId}',
|
|
195
|
+
'assets/nft/{address}/limit/{limit}',
|
|
196
|
+
'blockchain/rewards',
|
|
197
|
+
'blockchain/rewards/height',
|
|
198
|
+
'blocks/address/{address}/{from}/{to}/',
|
|
199
|
+
'blocks/at/{height}',
|
|
200
|
+
'blocks/delay/{signature}/{blockNum}',
|
|
201
|
+
'blocks/first',
|
|
202
|
+
'blocks/headers/last',
|
|
203
|
+
'blocks/headers/seq/{from}/{to}',
|
|
204
|
+
'blocks/height',
|
|
205
|
+
'blocks/height/{signature}',
|
|
206
|
+
'blocks/last',
|
|
207
|
+
'blocks/seq/{from}/{to}',
|
|
208
|
+
'blocks/signature/{signature}',
|
|
209
|
+
'consensus/algo',
|
|
210
|
+
'consensus/basetarget',
|
|
211
|
+
'consensus/basetarget/{blockId}',
|
|
212
|
+
'consensus/{generatingbalance}/address',
|
|
213
|
+
'consensus/generationsignature',
|
|
214
|
+
'consensus/generationsignature/{blockId}',
|
|
215
|
+
'debug/balances/history/{address}',
|
|
216
|
+
'debug/blocks/{howMany}',
|
|
217
|
+
'debug/configInfo',
|
|
218
|
+
'debug/historyInfo',
|
|
219
|
+
'debug/info',
|
|
220
|
+
'debug/minerInfo',
|
|
221
|
+
'debug/portfolios/{address}',
|
|
222
|
+
'debug/state',
|
|
223
|
+
'debug/stateChanges/address/{address}',
|
|
224
|
+
'debug/stateChanges/info/{id}',
|
|
225
|
+
'debug/stateWaves/{height}',
|
|
226
|
+
'leasing/active/{address}',
|
|
227
|
+
'node/state',
|
|
228
|
+
'node/version',
|
|
229
|
+
'peers/all',
|
|
230
|
+
'peers/blacklisted',
|
|
231
|
+
'peers/connected',
|
|
232
|
+
'peers/suspended',
|
|
233
|
+
'transactions/address/{address}/limit/{limit}',
|
|
234
|
+
'transactions/info/{id}',
|
|
235
|
+
'transactions/status',
|
|
236
|
+
'transactions/unconfirmed',
|
|
237
|
+
'transactions/unconfirmed/info/{id}',
|
|
238
|
+
'transactions/unconfirmed/size',
|
|
239
|
+
'utils/seed',
|
|
240
|
+
'utils/seed/{length}',
|
|
241
|
+
'utils/time',
|
|
242
|
+
'wallet/seed',
|
|
243
|
+
],
|
|
244
|
+
'post': [
|
|
245
|
+
'addresses',
|
|
246
|
+
'addresses/data/{address}',
|
|
247
|
+
'addresses/sign/{address}',
|
|
248
|
+
'addresses/signText/{address}',
|
|
249
|
+
'addresses/verify/{address}',
|
|
250
|
+
'addresses/verifyText/{address}',
|
|
251
|
+
'debug/blacklist',
|
|
252
|
+
'debug/print',
|
|
253
|
+
'debug/rollback',
|
|
254
|
+
'debug/validate',
|
|
255
|
+
'node/stop',
|
|
256
|
+
'peers/clearblacklist',
|
|
257
|
+
'peers/connect',
|
|
258
|
+
'transactions/broadcast',
|
|
259
|
+
'transactions/calculateFee',
|
|
260
|
+
'tranasctions/sign',
|
|
261
|
+
'transactions/sign/{signerAddress}',
|
|
262
|
+
'tranasctions/status',
|
|
263
|
+
'utils/hash/fast',
|
|
264
|
+
'utils/hash/secure',
|
|
265
|
+
'utils/script/compileCode',
|
|
266
|
+
'utils/script/compileWithImports',
|
|
267
|
+
'utils/script/decompile',
|
|
268
|
+
'utils/script/estimate',
|
|
269
|
+
'utils/sign/{privateKey}',
|
|
270
|
+
'utils/transactionsSerialize',
|
|
271
|
+
],
|
|
272
|
+
'delete': [
|
|
273
|
+
'addresses/{address}',
|
|
274
|
+
'debug/rollback-to/{signature}',
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
'public': {
|
|
278
|
+
'get': [
|
|
279
|
+
'assets',
|
|
280
|
+
'pairs',
|
|
281
|
+
'candles/{baseId}/{quoteId}',
|
|
282
|
+
'transactions/exchange',
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
'private': {
|
|
286
|
+
'get': [
|
|
287
|
+
'deposit/addresses/{currency}',
|
|
288
|
+
'deposit/addresses/{currency}/{platform}',
|
|
289
|
+
'platforms',
|
|
290
|
+
'deposit/currencies',
|
|
291
|
+
'withdraw/currencies',
|
|
292
|
+
'withdraw/addresses/{currency}/{address}',
|
|
293
|
+
],
|
|
294
|
+
'post': [
|
|
295
|
+
'oauth2/token',
|
|
296
|
+
],
|
|
297
|
+
},
|
|
298
|
+
'forward': {
|
|
299
|
+
'get': [
|
|
300
|
+
'matcher/orders/{address}',
|
|
301
|
+
'matcher/orders/{address}/{orderId}',
|
|
302
|
+
],
|
|
303
|
+
'post': [
|
|
304
|
+
'matcher/orders/{wavesAddress}/cancel',
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
'market': {
|
|
308
|
+
'get': [
|
|
309
|
+
'tickers',
|
|
310
|
+
],
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
'currencies': {
|
|
314
|
+
'WX': this.safeCurrencyStructure({ 'id': 'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc', 'numericId': undefined, 'code': 'WX', 'precision': this.parseNumber('8') }),
|
|
315
|
+
},
|
|
316
|
+
'precisionMode': number.DECIMAL_PLACES,
|
|
317
|
+
'options': {
|
|
318
|
+
'allowedCandles': 1440,
|
|
319
|
+
'accessToken': undefined,
|
|
320
|
+
'createMarketBuyOrderRequiresPrice': true,
|
|
321
|
+
'matcherPublicKey': undefined,
|
|
322
|
+
'quotes': undefined,
|
|
323
|
+
'createOrderDefaultExpiry': 2419200000,
|
|
324
|
+
'wavesAddress': undefined,
|
|
325
|
+
'withdrawFeeUSDN': 7420,
|
|
326
|
+
'withdrawFeeWAVES': 100000,
|
|
327
|
+
'wavesPrecision': 8,
|
|
328
|
+
'messagePrefix': 'W',
|
|
329
|
+
'networks': {
|
|
330
|
+
'ERC20': 'ETH',
|
|
331
|
+
'BEP20': 'BSC',
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
'commonCurrencies': {
|
|
335
|
+
'EGG': 'Waves Ducks',
|
|
336
|
+
},
|
|
337
|
+
'requiresEddsa': true,
|
|
338
|
+
'exceptions': {
|
|
339
|
+
'3147270': errors.InsufficientFunds,
|
|
340
|
+
'112': errors.InsufficientFunds,
|
|
341
|
+
'4': errors.ExchangeError,
|
|
342
|
+
'13': errors.ExchangeNotAvailable,
|
|
343
|
+
'14': errors.ExchangeNotAvailable,
|
|
344
|
+
'3145733': errors.AccountSuspended,
|
|
345
|
+
'3148040': errors.DuplicateOrderId,
|
|
346
|
+
'3148801': errors.AuthenticationError,
|
|
347
|
+
'9440512': errors.AuthenticationError,
|
|
348
|
+
'9440771': errors.BadSymbol,
|
|
349
|
+
'9441026': errors.InvalidOrder,
|
|
350
|
+
'9441282': errors.InvalidOrder,
|
|
351
|
+
'9441286': errors.InvalidOrder,
|
|
352
|
+
'9441295': errors.InvalidOrder,
|
|
353
|
+
'9441540': errors.InvalidOrder,
|
|
354
|
+
'9441542': errors.InvalidOrder,
|
|
355
|
+
'106954752': errors.AuthenticationError,
|
|
356
|
+
'106954769': errors.AuthenticationError,
|
|
357
|
+
'106957828': errors.AuthenticationError,
|
|
358
|
+
'106960131': errors.AuthenticationError,
|
|
359
|
+
'106981137': errors.AuthenticationError,
|
|
360
|
+
'9437184': errors.BadRequest,
|
|
361
|
+
'9437193': errors.OrderNotFound,
|
|
362
|
+
'1048577': errors.BadRequest,
|
|
363
|
+
'1051904': errors.AuthenticationError,
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
setSandboxMode(enabled) {
|
|
368
|
+
this.options['messagePrefix'] = enabled ? 'T' : 'W';
|
|
369
|
+
this.options['sandboxMode'] = enabled;
|
|
370
|
+
super.setSandboxMode(enabled);
|
|
371
|
+
}
|
|
372
|
+
async getFeesForAsset(symbol, side, amount, price, params = {}) {
|
|
373
|
+
await this.loadMarkets();
|
|
374
|
+
const market = this.market(symbol);
|
|
375
|
+
amount = this.customAmountToPrecision(symbol, amount);
|
|
376
|
+
price = this.customPriceToPrecision(symbol, price);
|
|
377
|
+
const request = this.extend({
|
|
378
|
+
'baseId': market['baseId'],
|
|
379
|
+
'quoteId': market['quoteId'],
|
|
380
|
+
'orderType': side,
|
|
381
|
+
'amount': amount,
|
|
382
|
+
'price': price,
|
|
383
|
+
}, params);
|
|
384
|
+
return await this.matcherPostMatcherOrderbookBaseIdQuoteIdCalculateFee(request);
|
|
385
|
+
}
|
|
386
|
+
async customCalculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
|
|
387
|
+
const response = await this.getFeesForAsset(symbol, side, amount, price);
|
|
388
|
+
// {
|
|
389
|
+
// "base":{
|
|
390
|
+
// "feeAssetId":"WAVES",
|
|
391
|
+
// "matcherFee":"1000000"
|
|
392
|
+
// },
|
|
393
|
+
// "discount":{
|
|
394
|
+
// "feeAssetId":"EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",
|
|
395
|
+
// "matcherFee":"4077612"
|
|
396
|
+
// }
|
|
397
|
+
// }
|
|
398
|
+
const isDiscountFee = this.safeValue(params, 'isDiscountFee', false);
|
|
399
|
+
let mode = undefined;
|
|
400
|
+
if (isDiscountFee) {
|
|
401
|
+
mode = this.safeValue(response, 'discount');
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
mode = this.safeValue(response, 'base');
|
|
405
|
+
}
|
|
406
|
+
const matcherFee = this.safeString(mode, 'matcherFee');
|
|
407
|
+
const feeAssetId = this.safeString(mode, 'feeAssetId');
|
|
408
|
+
const feeAsset = this.safeCurrencyCode(feeAssetId);
|
|
409
|
+
const adjustedMatcherFee = this.currencyFromPrecision(feeAsset, matcherFee);
|
|
410
|
+
const amountAsString = this.numberToString(amount);
|
|
411
|
+
const priceAsString = this.numberToString(price);
|
|
412
|
+
const feeCost = this.feeToPrecision(symbol, this.parseNumber(adjustedMatcherFee));
|
|
413
|
+
const feeRate = Precise["default"].stringDiv(adjustedMatcherFee, Precise["default"].stringMul(amountAsString, priceAsString));
|
|
414
|
+
return {
|
|
415
|
+
'type': takerOrMaker,
|
|
416
|
+
'currency': feeAsset,
|
|
417
|
+
'rate': this.parseNumber(feeRate),
|
|
418
|
+
'cost': this.parseNumber(feeCost),
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
async getQuotes() {
|
|
422
|
+
let quotes = this.safeValue(this.options, 'quotes');
|
|
423
|
+
if (quotes) {
|
|
424
|
+
return quotes;
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
// currencies can have any name because you can create you own token
|
|
428
|
+
// as a result someone can create a fake token called BTC
|
|
429
|
+
// we use this mapping to determine the real tokens
|
|
430
|
+
// https://docs.wx.network/en/waves-matcher/matcher-api#asset-pair
|
|
431
|
+
const response = await this.matcherGetMatcherSettings();
|
|
432
|
+
// {
|
|
433
|
+
// "orderVersions": [
|
|
434
|
+
// 1,
|
|
435
|
+
// 2,
|
|
436
|
+
// 3
|
|
437
|
+
// ],
|
|
438
|
+
// "success": true,
|
|
439
|
+
// "matcherPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
440
|
+
// "orderFee": {
|
|
441
|
+
// "dynamic": {
|
|
442
|
+
// "baseFee": 300000,
|
|
443
|
+
// "rates": {
|
|
444
|
+
// "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ": 1.22639597,
|
|
445
|
+
// "62LyMjcr2DtiyF5yVXFhoQ2q414VPPJXjsNYp72SuDCH": 0.00989643,
|
|
446
|
+
// "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk": 0.0395674,
|
|
447
|
+
// "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS": 0.00018814,
|
|
448
|
+
// "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8": 26.19721262,
|
|
449
|
+
// "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu": 0.00752978,
|
|
450
|
+
// "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p": 1.84575,
|
|
451
|
+
// "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H": 0.02330273,
|
|
452
|
+
// "zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy": 0.00721412,
|
|
453
|
+
// "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3": 0.02659103,
|
|
454
|
+
// "WAVES": 1,
|
|
455
|
+
// "BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa": 0.03433583
|
|
456
|
+
// }
|
|
457
|
+
// }
|
|
458
|
+
// },
|
|
459
|
+
// "networkByte": 87,
|
|
460
|
+
// "matcherVersion": "2.1.3.5",
|
|
461
|
+
// "status": "SimpleResponse",
|
|
462
|
+
// "priceAssets": [
|
|
463
|
+
// "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
|
|
464
|
+
// "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
|
|
465
|
+
// "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
|
|
466
|
+
// "Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU",
|
|
467
|
+
// "2mX5DzVKWrAJw8iwdJnV2qtoeVG9h5nTDpTqC1wb1WEN",
|
|
468
|
+
// "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
|
|
469
|
+
// "WAVES",
|
|
470
|
+
// "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
|
|
471
|
+
// "zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy",
|
|
472
|
+
// "62LyMjcr2DtiyF5yVXFhoQ2q414VPPJXjsNYp72SuDCH",
|
|
473
|
+
// "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
|
|
474
|
+
// "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
|
|
475
|
+
// "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
|
|
476
|
+
// "BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa",
|
|
477
|
+
// "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8"
|
|
478
|
+
// ]
|
|
479
|
+
// }
|
|
480
|
+
quotes = {};
|
|
481
|
+
const priceAssets = this.safeValue(response, 'priceAssets');
|
|
482
|
+
for (let i = 0; i < priceAssets.length; i++) {
|
|
483
|
+
quotes[priceAssets[i]] = true;
|
|
484
|
+
}
|
|
485
|
+
this.options['quotes'] = quotes;
|
|
486
|
+
return quotes;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
async fetchMarkets(params = {}) {
|
|
490
|
+
/**
|
|
491
|
+
* @method
|
|
492
|
+
* @name wavesexchange#fetchMarkets
|
|
493
|
+
* @description retrieves data on all markets for wavesexchange
|
|
494
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
495
|
+
* @returns {object[]} an array of objects representing market data
|
|
496
|
+
*/
|
|
497
|
+
const response = await this.marketGetTickers();
|
|
498
|
+
//
|
|
499
|
+
// [
|
|
500
|
+
// {
|
|
501
|
+
// "symbol": "WAVES/BTC",
|
|
502
|
+
// "amountAssetID": "WAVES",
|
|
503
|
+
// "amountAssetName": "Waves",
|
|
504
|
+
// "amountAssetDecimals": 8,
|
|
505
|
+
// "amountAssetTotalSupply": "106908766.00000000",
|
|
506
|
+
// "amountAssetMaxSupply": "106908766.00000000",
|
|
507
|
+
// "amountAssetCirculatingSupply": "106908766.00000000",
|
|
508
|
+
// "priceAssetID": "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
|
|
509
|
+
// "priceAssetName": "WBTC",
|
|
510
|
+
// "priceAssetDecimals": 8,
|
|
511
|
+
// "priceAssetTotalSupply": "20999999.96007507",
|
|
512
|
+
// "priceAssetMaxSupply": "20999999.96007507",
|
|
513
|
+
// "priceAssetCirculatingSupply": "20999999.66019601",
|
|
514
|
+
// "24h_open": "0.00032688",
|
|
515
|
+
// "24h_high": "0.00033508",
|
|
516
|
+
// "24h_low": "0.00032443",
|
|
517
|
+
// "24h_close": "0.00032806",
|
|
518
|
+
// "24h_vwap": "0.00032988",
|
|
519
|
+
// "24h_volume": "42349.69440104",
|
|
520
|
+
// "24h_priceVolume": "13.97037207",
|
|
521
|
+
// "timestamp":1640232379124
|
|
522
|
+
// }
|
|
523
|
+
// ...
|
|
524
|
+
// ]
|
|
525
|
+
//
|
|
526
|
+
const result = [];
|
|
527
|
+
for (let i = 0; i < response.length; i++) {
|
|
528
|
+
const entry = response[i];
|
|
529
|
+
const baseId = this.safeString(entry, 'amountAssetID');
|
|
530
|
+
const quoteId = this.safeString(entry, 'priceAssetID');
|
|
531
|
+
const id = baseId + '/' + quoteId;
|
|
532
|
+
const marketId = this.safeString(entry, 'symbol');
|
|
533
|
+
let [base, quote] = marketId.split('/');
|
|
534
|
+
base = this.safeCurrencyCode(base);
|
|
535
|
+
quote = this.safeCurrencyCode(quote);
|
|
536
|
+
const symbol = base + '/' + quote;
|
|
537
|
+
result.push({
|
|
538
|
+
'id': id,
|
|
539
|
+
'symbol': symbol,
|
|
540
|
+
'base': base,
|
|
541
|
+
'quote': quote,
|
|
542
|
+
'settle': undefined,
|
|
543
|
+
'baseId': baseId,
|
|
544
|
+
'quoteId': quoteId,
|
|
545
|
+
'settleId': undefined,
|
|
546
|
+
'type': 'spot',
|
|
547
|
+
'spot': true,
|
|
548
|
+
'margin': false,
|
|
549
|
+
'swap': false,
|
|
550
|
+
'future': false,
|
|
551
|
+
'option': false,
|
|
552
|
+
'active': undefined,
|
|
553
|
+
'contract': false,
|
|
554
|
+
'linear': undefined,
|
|
555
|
+
'inverse': undefined,
|
|
556
|
+
'contractSize': undefined,
|
|
557
|
+
'expiry': undefined,
|
|
558
|
+
'expiryDatetime': undefined,
|
|
559
|
+
'strike': undefined,
|
|
560
|
+
'optionType': undefined,
|
|
561
|
+
'precision': {
|
|
562
|
+
'amount': this.safeInteger(entry, 'amountAssetDecimals'),
|
|
563
|
+
'price': this.safeInteger(entry, 'priceAssetDecimals'),
|
|
564
|
+
},
|
|
565
|
+
'limits': {
|
|
566
|
+
'leverage': {
|
|
567
|
+
'min': undefined,
|
|
568
|
+
'max': undefined,
|
|
569
|
+
},
|
|
570
|
+
'amount': {
|
|
571
|
+
'min': undefined,
|
|
572
|
+
'max': undefined,
|
|
573
|
+
},
|
|
574
|
+
'price': {
|
|
575
|
+
'min': undefined,
|
|
576
|
+
'max': undefined,
|
|
577
|
+
},
|
|
578
|
+
'cost': {
|
|
579
|
+
'min': undefined,
|
|
580
|
+
'max': undefined,
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
'created': undefined,
|
|
584
|
+
'info': entry,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return result;
|
|
588
|
+
}
|
|
589
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
590
|
+
/**
|
|
591
|
+
* @method
|
|
592
|
+
* @name wavesexchange#fetchOrderBook
|
|
593
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
594
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
595
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
596
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
597
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
598
|
+
*/
|
|
599
|
+
await this.loadMarkets();
|
|
600
|
+
const market = this.market(symbol);
|
|
601
|
+
const request = this.extend({
|
|
602
|
+
'baseId': market['baseId'],
|
|
603
|
+
'quoteId': market['quoteId'],
|
|
604
|
+
}, params);
|
|
605
|
+
const response = await this.matcherGetMatcherOrderbookBaseIdQuoteId(request);
|
|
606
|
+
const timestamp = this.safeInteger(response, 'timestamp');
|
|
607
|
+
const bids = this.parseOrderBookSide(this.safeValue(response, 'bids'), market, limit);
|
|
608
|
+
const asks = this.parseOrderBookSide(this.safeValue(response, 'asks'), market, limit);
|
|
609
|
+
return {
|
|
610
|
+
'symbol': symbol,
|
|
611
|
+
'bids': bids,
|
|
612
|
+
'asks': asks,
|
|
613
|
+
'timestamp': timestamp,
|
|
614
|
+
'datetime': this.iso8601(timestamp),
|
|
615
|
+
'nonce': undefined,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
parseOrderBookSide(bookSide, market = undefined, limit = undefined) {
|
|
619
|
+
const precision = market['precision'];
|
|
620
|
+
const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
|
|
621
|
+
const amountPrecision = '1e' + this.numberToString(precision['amount']);
|
|
622
|
+
const amountPrecisionString = this.numberToString(precision['amount']);
|
|
623
|
+
const pricePrecisionString = this.numberToString(precision['price']);
|
|
624
|
+
const difference = Precise["default"].stringSub(amountPrecisionString, pricePrecisionString);
|
|
625
|
+
const pricePrecision = '1e' + Precise["default"].stringSub(wavesPrecision, difference);
|
|
626
|
+
const result = [];
|
|
627
|
+
for (let i = 0; i < bookSide.length; i++) {
|
|
628
|
+
const entry = bookSide[i];
|
|
629
|
+
const entryPrice = this.safeString(entry, 'price', '0');
|
|
630
|
+
const entryAmount = this.safeString(entry, 'amount', '0');
|
|
631
|
+
let price = undefined;
|
|
632
|
+
let amount = undefined;
|
|
633
|
+
if ((pricePrecision !== undefined) && (entryPrice !== undefined)) {
|
|
634
|
+
price = Precise["default"].stringDiv(entryPrice, pricePrecision);
|
|
635
|
+
}
|
|
636
|
+
if ((amountPrecision !== undefined) && (entryAmount !== undefined)) {
|
|
637
|
+
amount = Precise["default"].stringDiv(entryAmount, amountPrecision);
|
|
638
|
+
}
|
|
639
|
+
if ((limit !== undefined) && (i > limit)) {
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
result.push([
|
|
643
|
+
this.parseNumber(price),
|
|
644
|
+
this.parseNumber(amount),
|
|
645
|
+
]);
|
|
646
|
+
}
|
|
647
|
+
return result;
|
|
648
|
+
}
|
|
649
|
+
checkRequiredKeys() {
|
|
650
|
+
if (this.apiKey === undefined) {
|
|
651
|
+
throw new errors.AuthenticationError(this.id + ' requires apiKey credential');
|
|
652
|
+
}
|
|
653
|
+
if (this.secret === undefined) {
|
|
654
|
+
throw new errors.AuthenticationError(this.id + ' requires secret credential');
|
|
655
|
+
}
|
|
656
|
+
let apiKeyBytes = undefined;
|
|
657
|
+
let secretKeyBytes = undefined;
|
|
658
|
+
try {
|
|
659
|
+
apiKeyBytes = this.base58ToBinary(this.apiKey);
|
|
660
|
+
}
|
|
661
|
+
catch (e) {
|
|
662
|
+
throw new errors.AuthenticationError(this.id + ' apiKey must be a base58 encoded public key');
|
|
663
|
+
}
|
|
664
|
+
try {
|
|
665
|
+
secretKeyBytes = this.base58ToBinary(this.secret);
|
|
666
|
+
}
|
|
667
|
+
catch (e) {
|
|
668
|
+
throw new errors.AuthenticationError(this.id + ' secret must be a base58 encoded private key');
|
|
669
|
+
}
|
|
670
|
+
const hexApiKeyBytes = this.binaryToBase16(apiKeyBytes);
|
|
671
|
+
const hexSecretKeyBytes = this.binaryToBase16(secretKeyBytes);
|
|
672
|
+
if (hexApiKeyBytes.length !== 64) {
|
|
673
|
+
throw new errors.AuthenticationError(this.id + ' apiKey must be a base58 encoded public key');
|
|
674
|
+
}
|
|
675
|
+
if (hexSecretKeyBytes.length !== 64) {
|
|
676
|
+
throw new errors.AuthenticationError(this.id + ' secret must be a base58 encoded private key');
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
680
|
+
const query = this.omit(params, this.extractParams(path));
|
|
681
|
+
const isCancelOrder = path === 'matcher/orders/{wavesAddress}/cancel';
|
|
682
|
+
path = this.implodeParams(path, params);
|
|
683
|
+
let url = this.urls['api'][api] + '/' + path;
|
|
684
|
+
let queryString = this.urlencodeWithArrayRepeat(query);
|
|
685
|
+
if ((api === 'private') || (api === 'forward')) {
|
|
686
|
+
headers = {
|
|
687
|
+
'Accept': 'application/json',
|
|
688
|
+
};
|
|
689
|
+
const accessToken = this.safeString(this.options, 'accessToken');
|
|
690
|
+
if (accessToken) {
|
|
691
|
+
headers['Authorization'] = 'Bearer ' + accessToken;
|
|
692
|
+
}
|
|
693
|
+
if (method === 'POST') {
|
|
694
|
+
headers['content-type'] = 'application/json';
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
headers['content-type'] = 'application/x-www-form-urlencoded';
|
|
698
|
+
}
|
|
699
|
+
if (isCancelOrder) {
|
|
700
|
+
body = this.json([query['orderId']]);
|
|
701
|
+
queryString = '';
|
|
702
|
+
}
|
|
703
|
+
if (queryString.length > 0) {
|
|
704
|
+
url += '?' + queryString;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
else if (api === 'matcher') {
|
|
708
|
+
if (method === 'POST') {
|
|
709
|
+
headers = {
|
|
710
|
+
'Accept': 'application/json',
|
|
711
|
+
'Content-Type': 'application/json',
|
|
712
|
+
};
|
|
713
|
+
body = this.json(query);
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
headers = query;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
if (method === 'POST') {
|
|
721
|
+
headers = {
|
|
722
|
+
'content-type': 'application/json',
|
|
723
|
+
};
|
|
724
|
+
body = this.json(query);
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
headers = {
|
|
728
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
729
|
+
};
|
|
730
|
+
if (queryString.length > 0) {
|
|
731
|
+
url += '?' + queryString;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
736
|
+
}
|
|
737
|
+
async signIn(params = {}) {
|
|
738
|
+
/**
|
|
739
|
+
* @method
|
|
740
|
+
* @name wavesexchange#signIn
|
|
741
|
+
* @description sign in, must be called prior to using other authenticated methods
|
|
742
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
743
|
+
* @returns response from exchange
|
|
744
|
+
*/
|
|
745
|
+
if (!this.safeString(this.options, 'accessToken')) {
|
|
746
|
+
const prefix = 'ffffff01';
|
|
747
|
+
const expiresDelta = 60 * 60 * 24 * 7;
|
|
748
|
+
let seconds = this.sum(this.seconds(), expiresDelta);
|
|
749
|
+
seconds = seconds.toString();
|
|
750
|
+
const clientId = 'wx.network';
|
|
751
|
+
// W for production, T for testnet
|
|
752
|
+
const defaultMessagePrefix = this.safeString(this.options, 'messagePrefix', 'W');
|
|
753
|
+
const message = defaultMessagePrefix + ':' + clientId + ':' + seconds;
|
|
754
|
+
const messageHex = this.binaryToBase16(this.encode(message));
|
|
755
|
+
const payload = prefix + messageHex;
|
|
756
|
+
const hexKey = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
757
|
+
const signature = this.axolotl(payload, hexKey, ed25519.ed25519);
|
|
758
|
+
const request = {
|
|
759
|
+
'grant_type': 'password',
|
|
760
|
+
'scope': 'general',
|
|
761
|
+
'username': this.apiKey,
|
|
762
|
+
'password': seconds + ':' + signature,
|
|
763
|
+
'client_id': clientId,
|
|
764
|
+
};
|
|
765
|
+
const response = await this.privatePostOauth2Token(request);
|
|
766
|
+
// { access_token: "eyJhbGciOXJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWciOiJiaTZiMVhMQlo0M1Q4QmRTSlVSejJBZGlQdVlpaFZQYVhhVjc4ZGVIOEpTM3M3NUdSeEU1VkZVOE5LRUI0UXViNkFHaUhpVFpuZ3pzcnhXdExUclRvZTgiLCJhIjoiM1A4VnpMU2EyM0VXNUNWY2tIYlY3ZDVCb043NWZGMWhoRkgiLCJuYiI6IlciLCJ1c2VyX25hbWUiOiJBSFhuOG5CQTRTZkxRRjdoTFFpU24xNmt4eWVoaml6QkdXMVRkcm1TWjFnRiIsInNjb3BlIjpbImdlbmVyYWwiXSwibHQiOjYwNDc5OSwicGsiOiJBSFhuOG5CQTRTZkxRRjdoTFFpU24xNmt4eWVoaml6QkdXMVRkcm1TWjFnRiIsImV4cCI6MTU5MTk3NTA1NywiZXhwMCI6MTU5MTk3NTA1NywianRpIjoiN2JhOTUxMTMtOGI2MS00NjEzLTlkZmYtNTEwYTc0NjlkOWI5IiwiY2lkIjoid2F2ZXMuZXhjaGFuZ2UifQ.B-XwexBnUAzbWknVN68RKT0ZP5w6Qk1SKJ8usL3OIwDEzCUUX9PjW-5TQHmiCRcA4oft8lqXEiCwEoNfsblCo_jTpRo518a1vZkIbHQk0-13Dm1K5ewGxfxAwBk0g49odcbKdjl64TN1yM_PO1VtLVuiTeZP-XF-S42Uj-7fcO-r7AulyQLuTE0uo-Qdep8HDCk47rduZwtJOmhFbCCnSgnLYvKWy3CVTeldsR77qxUY-vy8q9McqeP7Id-_MWnsob8vWXpkeJxaEsw1Fke1dxApJaJam09VU8EB3ZJWpkT7V8PdafIrQGeexx3jhKKxo7rRb4hDV8kfpVoCgkvFan",
|
|
767
|
+
// "token_type": "bearer",
|
|
768
|
+
// "refresh_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWciOiJiaTZiMVhMQlo0M1Q4QmRTSlVSejJBZGlQdVlpaFZQYVhhVjc4ZGVIOEpTM3M3NUdSeEU1VkZVOE5LRUI0UXViNkFHaUhpVFpuZ3pzcnhXdExUclRvZTgiLCJhIjoiM1A4VnpMU2EyM0VXNUNWY2tIYlY3ZDVCb043NWZGMWhoRkgiLCJuYiI6IlciLCJ1c2VyX25hbWUiOiJBSFhuOG5CQTRTZkxRRjdoTFFpU24xNmt4eWVoaml6QkdXMVRkcm1TWjFnRiIsInNjb3BlIjpbImdlbmVyYWwiXSwiYXRpIjoiN2JhOTUxMTMtOGI2MS00NjEzLTlkZmYtNTEwYTc0NjlkXWI5IiwibHQiOjYwNDc5OSwicGsiOiJBSFhuOG5CQTRTZkxRRjdoTFFpU24xNmt4eWVoaml6QkdXMVRkcm1TWjFnRiIsImV4cCI6MTU5Mzk2MjI1OCwiZXhwMCI6MTU5MTk3NTA1NywianRpIjoiM2MzZWRlMTktNjI5My00MTNlLWJmMWUtZTRlZDZlYzUzZTgzIiwiY2lkIjoid2F2ZXMuZXhjaGFuZ2UifQ.gD1Qj0jfqayfZpBvNY0t3ccMyK5hdbT7dY-_5L6LxwV0Knan4ndEtvygxlTOczmJUKtnA4T1r5GBFgNMZTvtViKZIbqZNysEg2OY8UxwDaF4VPeGJLg_QXEnn8wBeBQdyMafh9UQdwD2ci7x-saM4tOAGmncAygfTDxy80201gwDhfAkAGerb9kL00oWzSJScldxu--pNLDBUEHZt52MSEel10HGrzvZkkvvSh67vcQo5TOGb5KG6nh65UdJCwr41AVz4fbQPP-N2Nkxqy0TE_bqVzZxExXgvcS8TS0Z82T3ijJa_ct7B9wblpylBnvmyj3VycUzufD6uy8MUGq32D",
|
|
769
|
+
// "expires_in": 604798,
|
|
770
|
+
// "scope": "general" }
|
|
771
|
+
this.options['accessToken'] = this.safeString(response, 'access_token');
|
|
772
|
+
return this.options['accessToken'];
|
|
773
|
+
}
|
|
774
|
+
return undefined;
|
|
775
|
+
}
|
|
776
|
+
parseTicker(ticker, market = undefined) {
|
|
777
|
+
//
|
|
778
|
+
// {
|
|
779
|
+
// "symbol": "WAVES/BTC",
|
|
780
|
+
// "amountAssetID": "WAVES",
|
|
781
|
+
// "amountAssetName": "Waves",
|
|
782
|
+
// "amountAssetDecimals": 8,
|
|
783
|
+
// "amountAssetTotalSupply": "106908766.00000000",
|
|
784
|
+
// "amountAssetMaxSupply": "106908766.00000000",
|
|
785
|
+
// "amountAssetCirculatingSupply": "106908766.00000000",
|
|
786
|
+
// "priceAssetID": "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
|
|
787
|
+
// "priceAssetName": "WBTC",
|
|
788
|
+
// "priceAssetDecimals": 8,
|
|
789
|
+
// "priceAssetTotalSupply": "20999999.96007507",
|
|
790
|
+
// "priceAssetMaxSupply": "20999999.96007507",
|
|
791
|
+
// "priceAssetCirculatingSupply": "20999999.66019601",
|
|
792
|
+
// "24h_open": "0.00032688",
|
|
793
|
+
// "24h_high": "0.00033508",
|
|
794
|
+
// "24h_low": "0.00032443",
|
|
795
|
+
// "24h_close": "0.00032806",
|
|
796
|
+
// "24h_vwap": "0.00032988",
|
|
797
|
+
// "24h_volume": "42349.69440104",
|
|
798
|
+
// "24h_priceVolume": "13.97037207",
|
|
799
|
+
// "timestamp":1640232379124
|
|
800
|
+
// }
|
|
801
|
+
//
|
|
802
|
+
// fetch ticker
|
|
803
|
+
//
|
|
804
|
+
// {
|
|
805
|
+
// "firstPrice": "21749",
|
|
806
|
+
// "lastPrice": "22000",
|
|
807
|
+
// "volume": "0.73747149",
|
|
808
|
+
// "quoteVolume": "16409.44564928645471",
|
|
809
|
+
// "high": "23589.999941",
|
|
810
|
+
// "low": "21010.000845",
|
|
811
|
+
// "weightedAveragePrice": "22250.955964",
|
|
812
|
+
// "txsCount": "148",
|
|
813
|
+
// "volumeWaves": "0.0000000000680511203072"
|
|
814
|
+
// }
|
|
815
|
+
//
|
|
816
|
+
const timestamp = this.safeInteger(ticker, 'timestamp');
|
|
817
|
+
const marketId = this.safeString(ticker, 'symbol');
|
|
818
|
+
market = this.safeMarket(marketId, market, '/');
|
|
819
|
+
const symbol = market['symbol'];
|
|
820
|
+
const last = this.safeString2(ticker, '24h_close', 'lastPrice');
|
|
821
|
+
const low = this.safeString2(ticker, '24h_low', 'low');
|
|
822
|
+
const high = this.safeString2(ticker, '24h_high', 'high');
|
|
823
|
+
const vwap = this.safeString2(ticker, '24h_vwap', 'weightedAveragePrice');
|
|
824
|
+
const baseVolume = this.safeString2(ticker, '24h_volume', 'volume');
|
|
825
|
+
const quoteVolume = this.safeString2(ticker, '24h_priceVolume', 'quoteVolume');
|
|
826
|
+
const open = this.safeString2(ticker, '24h_open', 'firstPrice');
|
|
827
|
+
return this.safeTicker({
|
|
828
|
+
'symbol': symbol,
|
|
829
|
+
'timestamp': timestamp,
|
|
830
|
+
'datetime': this.iso8601(timestamp),
|
|
831
|
+
'high': high,
|
|
832
|
+
'low': low,
|
|
833
|
+
'bid': undefined,
|
|
834
|
+
'bidVolume': undefined,
|
|
835
|
+
'ask': undefined,
|
|
836
|
+
'askVolume': undefined,
|
|
837
|
+
'vwap': vwap,
|
|
838
|
+
'open': open,
|
|
839
|
+
'close': last,
|
|
840
|
+
'last': last,
|
|
841
|
+
'previousClose': undefined,
|
|
842
|
+
'change': undefined,
|
|
843
|
+
'percentage': undefined,
|
|
844
|
+
'average': undefined,
|
|
845
|
+
'baseVolume': baseVolume,
|
|
846
|
+
'quoteVolume': quoteVolume,
|
|
847
|
+
'info': ticker,
|
|
848
|
+
}, market);
|
|
849
|
+
}
|
|
850
|
+
async fetchTicker(symbol, params = {}) {
|
|
851
|
+
/**
|
|
852
|
+
* @method
|
|
853
|
+
* @name wavesexchange#fetchTicker
|
|
854
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
855
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
856
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
857
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
858
|
+
*/
|
|
859
|
+
await this.loadMarkets();
|
|
860
|
+
const market = this.market(symbol);
|
|
861
|
+
const request = {
|
|
862
|
+
'pairs': market['id'],
|
|
863
|
+
};
|
|
864
|
+
const response = await this.publicGetPairs(this.extend(request, params));
|
|
865
|
+
//
|
|
866
|
+
// {
|
|
867
|
+
// "__type":"list",
|
|
868
|
+
// "data":[
|
|
869
|
+
// {
|
|
870
|
+
// "__type":"pair",
|
|
871
|
+
// "data":{
|
|
872
|
+
// "firstPrice":0.00012512,
|
|
873
|
+
// "lastPrice":0.00012441,
|
|
874
|
+
// "low":0.00012167,
|
|
875
|
+
// "high":0.00012768,
|
|
876
|
+
// "weightedAveragePrice":0.000124710697407246,
|
|
877
|
+
// "volume":209554.26356614,
|
|
878
|
+
// "quoteVolume":26.1336583539951,
|
|
879
|
+
// "volumeWaves":209554.26356614,
|
|
880
|
+
// "txsCount":6655
|
|
881
|
+
// },
|
|
882
|
+
// "amountAsset":"WAVES",
|
|
883
|
+
// "priceAsset":"8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS"
|
|
884
|
+
// }
|
|
885
|
+
// ]
|
|
886
|
+
// }
|
|
887
|
+
//
|
|
888
|
+
const data = this.safeValue(response, 'data', []);
|
|
889
|
+
const ticker = this.safeValue(data, 0, {});
|
|
890
|
+
const dataTicker = this.safeValue(ticker, 'data', {});
|
|
891
|
+
return this.parseTicker(dataTicker, market);
|
|
892
|
+
}
|
|
893
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
894
|
+
/**
|
|
895
|
+
* @method
|
|
896
|
+
* @name wavesexchange#fetchTickers
|
|
897
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
898
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
899
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
900
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
901
|
+
*/
|
|
902
|
+
await this.loadMarkets();
|
|
903
|
+
const response = await this.marketGetTickers(params);
|
|
904
|
+
//
|
|
905
|
+
// [
|
|
906
|
+
// {
|
|
907
|
+
// "symbol": "WAVES/BTC",
|
|
908
|
+
// "amountAssetID": "WAVES",
|
|
909
|
+
// "amountAssetName": "Waves",
|
|
910
|
+
// "amountAssetDecimals": 8,
|
|
911
|
+
// "amountAssetTotalSupply": "106908766.00000000",
|
|
912
|
+
// "amountAssetMaxSupply": "106908766.00000000",
|
|
913
|
+
// "amountAssetCirculatingSupply": "106908766.00000000",
|
|
914
|
+
// "priceAssetID": "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
|
|
915
|
+
// "priceAssetName": "WBTC",
|
|
916
|
+
// "priceAssetDecimals": 8,
|
|
917
|
+
// "priceAssetTotalSupply": "20999999.96007507",
|
|
918
|
+
// "priceAssetMaxSupply": "20999999.96007507",
|
|
919
|
+
// "priceAssetCirculatingSupply": "20999999.66019601",
|
|
920
|
+
// "24h_open": "0.00032688",
|
|
921
|
+
// "24h_high": "0.00033508",
|
|
922
|
+
// "24h_low": "0.00032443",
|
|
923
|
+
// "24h_close": "0.00032806",
|
|
924
|
+
// "24h_vwap": "0.00032988",
|
|
925
|
+
// "24h_volume": "42349.69440104",
|
|
926
|
+
// "24h_priceVolume": "13.97037207",
|
|
927
|
+
// "timestamp":1640232379124
|
|
928
|
+
// }
|
|
929
|
+
// ...
|
|
930
|
+
// ]
|
|
931
|
+
//
|
|
932
|
+
return this.parseTickers(response, symbols);
|
|
933
|
+
}
|
|
934
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
935
|
+
/**
|
|
936
|
+
* @method
|
|
937
|
+
* @name wavesexchange#fetchOHLCV
|
|
938
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
939
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
940
|
+
* @param {string} timeframe the length of time each candle represents
|
|
941
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
942
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
943
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
944
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
945
|
+
*/
|
|
946
|
+
await this.loadMarkets();
|
|
947
|
+
const market = this.market(symbol);
|
|
948
|
+
const request = {
|
|
949
|
+
'baseId': market['baseId'],
|
|
950
|
+
'quoteId': market['quoteId'],
|
|
951
|
+
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
952
|
+
};
|
|
953
|
+
const allowedCandles = this.safeInteger(this.options, 'allowedCandles', 1440);
|
|
954
|
+
if (limit === undefined) {
|
|
955
|
+
limit = allowedCandles;
|
|
956
|
+
}
|
|
957
|
+
limit = Math.min(allowedCandles, limit);
|
|
958
|
+
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
959
|
+
if (since === undefined) {
|
|
960
|
+
const durationRoundedTimestamp = this.parseToInt(this.milliseconds() / duration) * duration;
|
|
961
|
+
const delta = (limit - 1) * duration;
|
|
962
|
+
const timeStart = durationRoundedTimestamp - delta;
|
|
963
|
+
request['timeStart'] = timeStart.toString();
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
966
|
+
request['timeStart'] = since.toString();
|
|
967
|
+
const timeEnd = this.sum(since, duration * limit);
|
|
968
|
+
request['timeEnd'] = timeEnd.toString();
|
|
969
|
+
}
|
|
970
|
+
const response = await this.publicGetCandlesBaseIdQuoteId(this.extend(request, params));
|
|
971
|
+
//
|
|
972
|
+
// {
|
|
973
|
+
// "__type": "list",
|
|
974
|
+
// "data": [
|
|
975
|
+
// {
|
|
976
|
+
// "__type": "candle",
|
|
977
|
+
// "data": {
|
|
978
|
+
// "time": "2020-06-09T14:47:00.000Z",
|
|
979
|
+
// "open": 0.0250385,
|
|
980
|
+
// "close": 0.0250385,
|
|
981
|
+
// "high": 0.0250385,
|
|
982
|
+
// "low": 0.0250385,
|
|
983
|
+
// "volume": 0.01033012,
|
|
984
|
+
// "quoteVolume": 0.00025865,
|
|
985
|
+
// "weightedAveragePrice": 0.0250385,
|
|
986
|
+
// "maxHeight": 2099399,
|
|
987
|
+
// "txsCount": 5,
|
|
988
|
+
// "timeClose": "2020-06-09T14:47:59.999Z"
|
|
989
|
+
// }
|
|
990
|
+
// }
|
|
991
|
+
// ]
|
|
992
|
+
// }
|
|
993
|
+
//
|
|
994
|
+
const data = this.safeValue(response, 'data', []);
|
|
995
|
+
let result = this.parseOHLCVs(data, market, timeframe, since, limit);
|
|
996
|
+
result = this.filterFutureCandles(result);
|
|
997
|
+
let lastClose = undefined;
|
|
998
|
+
const length = result.length;
|
|
999
|
+
for (let i = 0; i < result.length; i++) {
|
|
1000
|
+
const j = length - i - 1;
|
|
1001
|
+
const entry = result[j];
|
|
1002
|
+
const open = entry[1];
|
|
1003
|
+
if (open === undefined) {
|
|
1004
|
+
entry[1] = lastClose;
|
|
1005
|
+
entry[2] = lastClose;
|
|
1006
|
+
entry[3] = lastClose;
|
|
1007
|
+
entry[4] = lastClose;
|
|
1008
|
+
result[j] = entry;
|
|
1009
|
+
}
|
|
1010
|
+
lastClose = entry[4];
|
|
1011
|
+
}
|
|
1012
|
+
return result;
|
|
1013
|
+
}
|
|
1014
|
+
filterFutureCandles(ohlcvs) {
|
|
1015
|
+
const result = [];
|
|
1016
|
+
const timestamp = this.milliseconds();
|
|
1017
|
+
for (let i = 0; i < ohlcvs.length; i++) {
|
|
1018
|
+
if (ohlcvs[i][0] > timestamp) {
|
|
1019
|
+
// stop when getting data from the future
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
result.push(ohlcvs[i]);
|
|
1023
|
+
}
|
|
1024
|
+
return result;
|
|
1025
|
+
}
|
|
1026
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
1027
|
+
//
|
|
1028
|
+
// {
|
|
1029
|
+
// "__type": "candle",
|
|
1030
|
+
// "data": {
|
|
1031
|
+
// "time": "2020-06-05T20:46:00.000Z",
|
|
1032
|
+
// "open": 240.573975,
|
|
1033
|
+
// "close": 240.573975,
|
|
1034
|
+
// "high": 240.573975,
|
|
1035
|
+
// "low": 240.573975,
|
|
1036
|
+
// "volume": 0.01278413,
|
|
1037
|
+
// "quoteVolume": 3.075528,
|
|
1038
|
+
// "weightedAveragePrice": 240.573975,
|
|
1039
|
+
// "maxHeight": 2093895,
|
|
1040
|
+
// "txsCount": 5,
|
|
1041
|
+
// "timeClose": "2020-06-05T20:46:59.999Z"
|
|
1042
|
+
// }
|
|
1043
|
+
// }
|
|
1044
|
+
//
|
|
1045
|
+
const data = this.safeValue(ohlcv, 'data', {});
|
|
1046
|
+
return [
|
|
1047
|
+
this.parse8601(this.safeString(data, 'time')),
|
|
1048
|
+
this.safeNumber(data, 'open'),
|
|
1049
|
+
this.safeNumber(data, 'high'),
|
|
1050
|
+
this.safeNumber(data, 'low'),
|
|
1051
|
+
this.safeNumber(data, 'close'),
|
|
1052
|
+
this.safeNumber(data, 'volume', 0),
|
|
1053
|
+
];
|
|
1054
|
+
}
|
|
1055
|
+
async fetchDepositAddress(code, params = {}) {
|
|
1056
|
+
/**
|
|
1057
|
+
* @method
|
|
1058
|
+
* @name wavesexchange#fetchDepositAddress
|
|
1059
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
1060
|
+
* @param {string} code unified currency code
|
|
1061
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1062
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1063
|
+
*/
|
|
1064
|
+
await this.signIn();
|
|
1065
|
+
const networks = this.safeValue(this.options, 'networks', {});
|
|
1066
|
+
const rawNetwork = this.safeStringUpper(params, 'network');
|
|
1067
|
+
const network = this.safeString(networks, rawNetwork, rawNetwork);
|
|
1068
|
+
params = this.omit(params, ['network']);
|
|
1069
|
+
const supportedCurrencies = await this.privateGetPlatforms();
|
|
1070
|
+
//
|
|
1071
|
+
// {
|
|
1072
|
+
// "type": "list",
|
|
1073
|
+
// "page_info": {
|
|
1074
|
+
// "has_next_page": false,
|
|
1075
|
+
// "last_cursor": null
|
|
1076
|
+
// },
|
|
1077
|
+
// "items": [
|
|
1078
|
+
// {
|
|
1079
|
+
// "type": "platform",
|
|
1080
|
+
// "id": "ETH",
|
|
1081
|
+
// "name": "Ethereum",
|
|
1082
|
+
// "currencies": [
|
|
1083
|
+
// "BAG",
|
|
1084
|
+
// "BNT",
|
|
1085
|
+
// "CRV",
|
|
1086
|
+
// "EGG",
|
|
1087
|
+
// "ETH",
|
|
1088
|
+
// "EURN",
|
|
1089
|
+
// "FL",
|
|
1090
|
+
// "NSBT",
|
|
1091
|
+
// "USDAP",
|
|
1092
|
+
// "USDC",
|
|
1093
|
+
// "USDFL",
|
|
1094
|
+
// "USDN",
|
|
1095
|
+
// "USDT",
|
|
1096
|
+
// "WAVES"
|
|
1097
|
+
// ]
|
|
1098
|
+
// }
|
|
1099
|
+
// ]
|
|
1100
|
+
// }
|
|
1101
|
+
//
|
|
1102
|
+
const currencies = {};
|
|
1103
|
+
const networksByCurrency = {};
|
|
1104
|
+
const items = this.safeValue(supportedCurrencies, 'items', []);
|
|
1105
|
+
for (let i = 0; i < items.length; i++) {
|
|
1106
|
+
const entry = items[i];
|
|
1107
|
+
const currencyId = this.safeString(entry, 'id');
|
|
1108
|
+
const innerCurrencies = this.safeValue(entry, 'currencies', []);
|
|
1109
|
+
for (let j = 0; j < innerCurrencies.length; j++) {
|
|
1110
|
+
const currencyCode = this.safeString(innerCurrencies, j);
|
|
1111
|
+
currencies[currencyCode] = true;
|
|
1112
|
+
if (!(currencyCode in networksByCurrency)) {
|
|
1113
|
+
networksByCurrency[currencyCode] = {};
|
|
1114
|
+
}
|
|
1115
|
+
networksByCurrency[currencyCode][currencyId] = true;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
if (!(code in currencies)) {
|
|
1119
|
+
const codes = Object.keys(currencies);
|
|
1120
|
+
throw new errors.ExchangeError(this.id + ' fetchDepositAddress() ' + code + ' not supported. Currency code must be one of ' + codes.join(', '));
|
|
1121
|
+
}
|
|
1122
|
+
let response = undefined;
|
|
1123
|
+
if (network === undefined) {
|
|
1124
|
+
const request = {
|
|
1125
|
+
'currency': code,
|
|
1126
|
+
};
|
|
1127
|
+
response = await this.privateGetDepositAddressesCurrency(this.extend(request, params));
|
|
1128
|
+
}
|
|
1129
|
+
else {
|
|
1130
|
+
const supportedNetworks = networksByCurrency[code];
|
|
1131
|
+
if (!(network in supportedNetworks)) {
|
|
1132
|
+
const supportedNetworkKeys = Object.keys(supportedNetworks);
|
|
1133
|
+
throw new errors.ExchangeError(this.id + ' ' + network + ' network ' + code + ' deposit address not supported. Network must be one of ' + supportedNetworkKeys.join(', '));
|
|
1134
|
+
}
|
|
1135
|
+
if (network === 'WAVES') {
|
|
1136
|
+
const request = {
|
|
1137
|
+
'publicKey': this.apiKey,
|
|
1138
|
+
};
|
|
1139
|
+
const responseInner = await this.nodeGetAddressesPublicKeyPublicKey(this.extend(request, request));
|
|
1140
|
+
const addressInner = this.safeString(response, 'address');
|
|
1141
|
+
return {
|
|
1142
|
+
'address': addressInner,
|
|
1143
|
+
'code': code,
|
|
1144
|
+
'currency': code,
|
|
1145
|
+
'network': network,
|
|
1146
|
+
'tag': undefined,
|
|
1147
|
+
'info': responseInner,
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
else {
|
|
1151
|
+
const request = {
|
|
1152
|
+
'currency': code,
|
|
1153
|
+
'platform': network,
|
|
1154
|
+
};
|
|
1155
|
+
response = await this.privateGetDepositAddressesCurrencyPlatform(this.extend(request, params));
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
//
|
|
1159
|
+
// {
|
|
1160
|
+
// "type": "deposit_addresses",
|
|
1161
|
+
// "currency": {
|
|
1162
|
+
// "type": "deposit_currency",
|
|
1163
|
+
// "id": "ERGO",
|
|
1164
|
+
// "waves_asset_id": "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz",
|
|
1165
|
+
// "platform_id": "BSC",
|
|
1166
|
+
// "decimals": 9,
|
|
1167
|
+
// "status": "active",
|
|
1168
|
+
// "allowed_amount": {
|
|
1169
|
+
// "min": 0.001,
|
|
1170
|
+
// "max": 100000
|
|
1171
|
+
// },
|
|
1172
|
+
// "fees": {
|
|
1173
|
+
// "flat": 0,
|
|
1174
|
+
// "rate": 0
|
|
1175
|
+
// }
|
|
1176
|
+
// },
|
|
1177
|
+
// "deposit_addresses": [
|
|
1178
|
+
// "9fRAAQjF8Yqg7qicQCL884zjimsRnuwsSavsM1rUdDaoG8mThku"
|
|
1179
|
+
// ]
|
|
1180
|
+
// }
|
|
1181
|
+
const currency = this.safeValue(response, 'currency');
|
|
1182
|
+
const networkId = this.safeString(currency, 'platform_id');
|
|
1183
|
+
const networkByIds = this.safeValue(this.options, 'networkByIds', {});
|
|
1184
|
+
const unifiedNetwork = this.safeString(networkByIds, networkId, networkId);
|
|
1185
|
+
const addresses = this.safeValue(response, 'deposit_addresses');
|
|
1186
|
+
const address = this.safeString(addresses, 0);
|
|
1187
|
+
return {
|
|
1188
|
+
'address': address,
|
|
1189
|
+
'code': code,
|
|
1190
|
+
'currency': code,
|
|
1191
|
+
'tag': undefined,
|
|
1192
|
+
'network': unifiedNetwork,
|
|
1193
|
+
'info': response,
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
async getMatcherPublicKey() {
|
|
1197
|
+
// this method returns a single string
|
|
1198
|
+
const matcherPublicKey = this.safeString(this.options, 'matcherPublicKey');
|
|
1199
|
+
if (matcherPublicKey) {
|
|
1200
|
+
return matcherPublicKey;
|
|
1201
|
+
}
|
|
1202
|
+
else {
|
|
1203
|
+
const response = await this.matcherGetMatcher();
|
|
1204
|
+
// remove trailing quotes from string response
|
|
1205
|
+
this.options['matcherPublicKey'] = response.slice(1, response.length - 1);
|
|
1206
|
+
return this.options['matcherPublicKey'];
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
getAssetBytes(currencyId) {
|
|
1210
|
+
if (currencyId === 'WAVES') {
|
|
1211
|
+
return this.numberToBE(0, 1);
|
|
1212
|
+
}
|
|
1213
|
+
else {
|
|
1214
|
+
return this.binaryConcat(this.numberToBE(1, 1), this.base58ToBinary(currencyId));
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
getAssetId(currencyId) {
|
|
1218
|
+
if (currencyId === 'WAVES') {
|
|
1219
|
+
return '';
|
|
1220
|
+
}
|
|
1221
|
+
return currencyId;
|
|
1222
|
+
}
|
|
1223
|
+
customPriceToPrecision(symbol, price) {
|
|
1224
|
+
const market = this.markets[symbol];
|
|
1225
|
+
const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
|
|
1226
|
+
const amount = this.numberToString(market['precision']['amount']);
|
|
1227
|
+
const precisionPrice = this.numberToString(market['precision']['price']);
|
|
1228
|
+
const difference = Precise["default"].stringSub(amount, precisionPrice);
|
|
1229
|
+
const precision = Precise["default"].stringSub(wavesPrecision, difference);
|
|
1230
|
+
const pricePrecision = this.toPrecision(price, precision).toString();
|
|
1231
|
+
return this.parseToInt(parseFloat(pricePrecision));
|
|
1232
|
+
}
|
|
1233
|
+
customAmountToPrecision(symbol, amount) {
|
|
1234
|
+
const amountPrecision = this.numberToString(this.toPrecision(amount, this.numberToString(this.markets[symbol]['precision']['amount'])));
|
|
1235
|
+
return this.parseToInt(parseFloat(amountPrecision));
|
|
1236
|
+
}
|
|
1237
|
+
currencyToPrecision(code, amount, networkCode = undefined) {
|
|
1238
|
+
const amountPrecision = this.numberToString(this.toPrecision(amount, this.currencies[code]['precision']));
|
|
1239
|
+
return this.parseToInt(parseFloat(amountPrecision));
|
|
1240
|
+
}
|
|
1241
|
+
fromPrecision(amount, scale) {
|
|
1242
|
+
if (amount === undefined) {
|
|
1243
|
+
return undefined;
|
|
1244
|
+
}
|
|
1245
|
+
const precise = new Precise["default"](amount);
|
|
1246
|
+
precise.decimals = this.sum(precise.decimals, scale);
|
|
1247
|
+
precise.reduce();
|
|
1248
|
+
return precise.toString();
|
|
1249
|
+
}
|
|
1250
|
+
toPrecision(amount, scale) {
|
|
1251
|
+
const amountString = this.numberToString(amount);
|
|
1252
|
+
const precise = new Precise["default"](amountString);
|
|
1253
|
+
// precise.decimals should be integer
|
|
1254
|
+
precise.decimals = this.parseToInt(Precise["default"].stringSub(this.numberToString(precise.decimals), this.numberToString(scale)));
|
|
1255
|
+
precise.reduce();
|
|
1256
|
+
return precise;
|
|
1257
|
+
}
|
|
1258
|
+
currencyFromPrecision(currency, amount) {
|
|
1259
|
+
const scale = this.currencies[currency]['precision'];
|
|
1260
|
+
return this.fromPrecision(amount, scale);
|
|
1261
|
+
}
|
|
1262
|
+
priceFromPrecision(symbol, price) {
|
|
1263
|
+
const market = this.markets[symbol];
|
|
1264
|
+
const wavesPrecision = this.safeInteger(this.options, 'wavesPrecision', 8);
|
|
1265
|
+
const scale = this.sum(wavesPrecision, market['precision']['price']) - market['precision']['amount'];
|
|
1266
|
+
return this.fromPrecision(price, scale);
|
|
1267
|
+
}
|
|
1268
|
+
safeGetDynamic(settings) {
|
|
1269
|
+
const orderFee = this.safeValue(settings, 'orderFee');
|
|
1270
|
+
if ('dynamic' in orderFee) {
|
|
1271
|
+
return this.safeValue(orderFee, 'dynamic');
|
|
1272
|
+
}
|
|
1273
|
+
else {
|
|
1274
|
+
return this.safeValue(orderFee['composite']['default'], 'dynamic');
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
safeGetRates(dynamic) {
|
|
1278
|
+
const rates = this.safeValue(dynamic, 'rates');
|
|
1279
|
+
if (rates === undefined) {
|
|
1280
|
+
return { 'WAVES': 1 };
|
|
1281
|
+
}
|
|
1282
|
+
return rates;
|
|
1283
|
+
}
|
|
1284
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1285
|
+
/**
|
|
1286
|
+
* @method
|
|
1287
|
+
* @name wavesexchange#createOrder
|
|
1288
|
+
* @description create a trade order
|
|
1289
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1290
|
+
* @param {string} type 'market' or 'limit'
|
|
1291
|
+
* @param {string} side 'buy' or 'sell'
|
|
1292
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
1293
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1294
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1295
|
+
* @param {float} [params.stopPrice] The price at which a stop order is triggered at
|
|
1296
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1297
|
+
*/
|
|
1298
|
+
this.checkRequiredDependencies();
|
|
1299
|
+
this.checkRequiredKeys();
|
|
1300
|
+
await this.loadMarkets();
|
|
1301
|
+
const market = this.market(symbol);
|
|
1302
|
+
const matcherPublicKey = await this.getMatcherPublicKey();
|
|
1303
|
+
const amountAsset = this.getAssetId(market['baseId']);
|
|
1304
|
+
const priceAsset = this.getAssetId(market['quoteId']);
|
|
1305
|
+
const isMarketOrder = (type === 'market');
|
|
1306
|
+
const stopPrice = this.safeFloat2(params, 'triggerPrice', 'stopPrice');
|
|
1307
|
+
const isStopOrder = (stopPrice !== undefined);
|
|
1308
|
+
if ((isMarketOrder) && (price === undefined)) {
|
|
1309
|
+
throw new errors.InvalidOrder(this.id + ' createOrder() requires a price argument for ' + type + ' orders to determine the max price for buy and the min price for sell');
|
|
1310
|
+
}
|
|
1311
|
+
const timestamp = this.milliseconds();
|
|
1312
|
+
const defaultExpiryDelta = this.safeInteger(this.options, 'createOrderDefaultExpiry', 2419200000);
|
|
1313
|
+
const expiration = this.sum(timestamp, defaultExpiryDelta);
|
|
1314
|
+
const matcherFees = await this.getFeesForAsset(symbol, side, amount, price);
|
|
1315
|
+
// {
|
|
1316
|
+
// "base":{
|
|
1317
|
+
// "feeAssetId":"WAVES", // varies depending on the trading pair
|
|
1318
|
+
// "matcherFee":"1000000"
|
|
1319
|
+
// },
|
|
1320
|
+
// "discount":{
|
|
1321
|
+
// "feeAssetId":"EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",
|
|
1322
|
+
// "matcherFee":"4077612"
|
|
1323
|
+
// }
|
|
1324
|
+
// }
|
|
1325
|
+
const base = this.safeValue2(matcherFees, 'base', 'discount');
|
|
1326
|
+
const baseFeeAssetId = this.safeString(base, 'feeAssetId');
|
|
1327
|
+
const baseFeeAsset = this.safeCurrencyCode(baseFeeAssetId);
|
|
1328
|
+
const baseMatcherFee = this.safeString(base, 'matcherFee');
|
|
1329
|
+
const discount = this.safeValue(matcherFees, 'discount');
|
|
1330
|
+
const discountFeeAssetId = this.safeString(discount, 'feeAssetId');
|
|
1331
|
+
const discountFeeAsset = this.safeCurrencyCode(discountFeeAssetId);
|
|
1332
|
+
const discountMatcherFee = this.safeString(discount, 'matcherFee');
|
|
1333
|
+
let matcherFeeAssetId = undefined;
|
|
1334
|
+
let matcherFee = undefined;
|
|
1335
|
+
// check first if user supplied asset fee is valid
|
|
1336
|
+
if (('feeAsset' in params) || ('feeAsset' in this.options)) {
|
|
1337
|
+
const feeAsset = this.safeString(params, 'feeAsset', this.safeString(this.options, 'feeAsset'));
|
|
1338
|
+
const feeCurrency = this.currency(feeAsset);
|
|
1339
|
+
matcherFeeAssetId = this.safeString(feeCurrency, 'id');
|
|
1340
|
+
}
|
|
1341
|
+
const balances = await this.fetchBalance();
|
|
1342
|
+
if (matcherFeeAssetId !== undefined) {
|
|
1343
|
+
if (baseFeeAssetId !== matcherFeeAssetId && discountFeeAssetId !== matcherFeeAssetId) {
|
|
1344
|
+
throw new errors.InvalidOrder(this.id + ' asset fee must be ' + baseFeeAsset + ' or ' + discountFeeAsset);
|
|
1345
|
+
}
|
|
1346
|
+
const matcherFeeAsset = this.safeCurrencyCode(matcherFeeAssetId);
|
|
1347
|
+
const rawMatcherFee = (matcherFeeAssetId === baseFeeAssetId) ? baseMatcherFee : discountMatcherFee;
|
|
1348
|
+
const floatMatcherFee = parseFloat(this.currencyFromPrecision(matcherFeeAsset, rawMatcherFee));
|
|
1349
|
+
if ((matcherFeeAsset in balances) && (balances[matcherFeeAsset]['free'] >= floatMatcherFee)) {
|
|
1350
|
+
matcherFee = parseInt(rawMatcherFee);
|
|
1351
|
+
}
|
|
1352
|
+
else {
|
|
1353
|
+
throw new errors.InsufficientFunds(this.id + ' not enough funds of the selected asset fee');
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
if (matcherFeeAssetId === undefined) {
|
|
1357
|
+
// try to the pay the fee using the base first then discount asset
|
|
1358
|
+
const floatBaseMatcherFee = parseFloat(this.currencyFromPrecision(baseFeeAsset, baseMatcherFee));
|
|
1359
|
+
if ((baseFeeAsset in balances) && (balances[baseFeeAsset]['free'] >= floatBaseMatcherFee)) {
|
|
1360
|
+
matcherFeeAssetId = baseFeeAssetId;
|
|
1361
|
+
matcherFee = parseInt(baseMatcherFee);
|
|
1362
|
+
}
|
|
1363
|
+
else {
|
|
1364
|
+
const floatDiscountMatcherFee = parseFloat(this.currencyFromPrecision(discountFeeAsset, discountMatcherFee));
|
|
1365
|
+
if ((discountFeeAsset in balances) && (balances[discountFeeAsset]['free'] >= floatDiscountMatcherFee)) {
|
|
1366
|
+
matcherFeeAssetId = discountFeeAssetId;
|
|
1367
|
+
matcherFee = parseInt(discountMatcherFee);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
if (matcherFeeAssetId === undefined) {
|
|
1372
|
+
throw new errors.InsufficientFunds(this.id + ' not enough funds on none of the eligible asset fees');
|
|
1373
|
+
}
|
|
1374
|
+
amount = this.customAmountToPrecision(symbol, amount);
|
|
1375
|
+
price = this.customPriceToPrecision(symbol, price);
|
|
1376
|
+
const assetPair = {
|
|
1377
|
+
'amountAsset': amountAsset,
|
|
1378
|
+
'priceAsset': priceAsset,
|
|
1379
|
+
};
|
|
1380
|
+
const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
|
|
1381
|
+
const chainId = (sandboxMode) ? 84 : 87;
|
|
1382
|
+
const body = {
|
|
1383
|
+
'senderPublicKey': this.apiKey,
|
|
1384
|
+
'matcherPublicKey': matcherPublicKey,
|
|
1385
|
+
'assetPair': assetPair,
|
|
1386
|
+
'orderType': side,
|
|
1387
|
+
'price': price,
|
|
1388
|
+
'amount': amount,
|
|
1389
|
+
'timestamp': timestamp,
|
|
1390
|
+
'expiration': expiration,
|
|
1391
|
+
'matcherFee': parseInt(matcherFee),
|
|
1392
|
+
'priceMode': 'assetDecimals',
|
|
1393
|
+
'version': 4,
|
|
1394
|
+
'chainId': chainId,
|
|
1395
|
+
};
|
|
1396
|
+
if (isStopOrder) {
|
|
1397
|
+
//
|
|
1398
|
+
// {
|
|
1399
|
+
// "v": 1, // version (int)
|
|
1400
|
+
// "c": { // condition (object)
|
|
1401
|
+
// "t": "sp", // condition type. for now only "stop-price" (string)
|
|
1402
|
+
// "v": { // value (object)
|
|
1403
|
+
// "p": "123", // price (long)
|
|
1404
|
+
// },
|
|
1405
|
+
// },
|
|
1406
|
+
// }
|
|
1407
|
+
//
|
|
1408
|
+
const attachment = {
|
|
1409
|
+
'v': 1,
|
|
1410
|
+
'c': {
|
|
1411
|
+
't': 'sp',
|
|
1412
|
+
'v': {
|
|
1413
|
+
'p': this.customPriceToPrecision(symbol, stopPrice),
|
|
1414
|
+
},
|
|
1415
|
+
},
|
|
1416
|
+
};
|
|
1417
|
+
body['attachment'] = this.binaryToBase58(this.encode(JSON.stringify(attachment)));
|
|
1418
|
+
}
|
|
1419
|
+
if (matcherFeeAssetId !== 'WAVES') {
|
|
1420
|
+
body['matcherFeeAssetId'] = matcherFeeAssetId;
|
|
1421
|
+
}
|
|
1422
|
+
let serializedOrder = await this.matcherPostMatcherOrdersSerialize(body);
|
|
1423
|
+
if ((serializedOrder[0] === '"') && (serializedOrder[(serializedOrder.length - 1)] === '"')) {
|
|
1424
|
+
serializedOrder = serializedOrder.slice(1, serializedOrder.length - 1);
|
|
1425
|
+
}
|
|
1426
|
+
const signature = this.axolotl(this.binaryToBase16(this.base58ToBinary(serializedOrder)), this.binaryToBase16(this.base58ToBinary(this.secret)), ed25519.ed25519);
|
|
1427
|
+
body['signature'] = signature;
|
|
1428
|
+
//
|
|
1429
|
+
// {
|
|
1430
|
+
// "success": true,
|
|
1431
|
+
// "message": {
|
|
1432
|
+
// "version": 4,
|
|
1433
|
+
// "id": "8VR49dLZFaYcVwzx9TqVMTAZCSUoyB74kLUHrEPCSJgN",
|
|
1434
|
+
// "sender": "3MpEdBXtsRHRj2TvZURSb8uLDxzneVbYczW",
|
|
1435
|
+
// "senderPublicKey": "8aUTNqHGCBiubySBRhcS1N6NC5jLczhVcndRfMAuwtkY",
|
|
1436
|
+
// "matcherPublicKey": "8QUAqtTckM5B8gvcuP7mMswat9SjKUuafJMusEoSn1Gy",
|
|
1437
|
+
// "assetPair": {
|
|
1438
|
+
// "amountAsset": "EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",
|
|
1439
|
+
// "priceAsset": "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"
|
|
1440
|
+
// },
|
|
1441
|
+
// "orderType": "sell",
|
|
1442
|
+
// "amount": 100000,
|
|
1443
|
+
// "price": 480000,
|
|
1444
|
+
// "timestamp": 1690852043772,
|
|
1445
|
+
// "expiration": 1693271243772,
|
|
1446
|
+
// "matcherFee": 83327570,
|
|
1447
|
+
// "signature": "3QYDWQVSP4kdqpTLodCuboh8bpWd6GW5s1pQyKdce1JBDwX6t4kH5Xtuq35pqo94gxjo3cfG6k6Xuic2JaYLubkK",
|
|
1448
|
+
// "proofs": [
|
|
1449
|
+
// "3QYDWQVSP4kdqpTLodCuboh8bpWd6GW5s1pQyKdce1JBDwX6t4kH5Xtuq35pqo94gxjo3cfG6k6Xuic2JaYLubkK"
|
|
1450
|
+
// ],
|
|
1451
|
+
// "matcherFeeAssetId": "EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc",
|
|
1452
|
+
// "eip712Signature": null,
|
|
1453
|
+
// "priceMode": "assetDecimals",
|
|
1454
|
+
// "attachment": "2PQ4akZHnMSZrQissuu5uudoXbgsipeDnFcRtXtjVgkdm1gUWEgGzp"
|
|
1455
|
+
// },
|
|
1456
|
+
// "status": "OrderAccepted"
|
|
1457
|
+
// }
|
|
1458
|
+
//
|
|
1459
|
+
if (isMarketOrder) {
|
|
1460
|
+
const response = await this.matcherPostMatcherOrderbookMarket(body);
|
|
1461
|
+
const value = this.safeValue(response, 'message');
|
|
1462
|
+
return this.parseOrder(value, market);
|
|
1463
|
+
}
|
|
1464
|
+
else {
|
|
1465
|
+
const response = await this.matcherPostMatcherOrderbook(body);
|
|
1466
|
+
const value = this.safeValue(response, 'message');
|
|
1467
|
+
return this.parseOrder(value, market);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1471
|
+
/**
|
|
1472
|
+
* @method
|
|
1473
|
+
* @name wavesexchange#cancelOrder
|
|
1474
|
+
* @description cancels an open order
|
|
1475
|
+
* @param {string} id order id
|
|
1476
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1477
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1478
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1479
|
+
*/
|
|
1480
|
+
this.checkRequiredDependencies();
|
|
1481
|
+
this.checkRequiredKeys();
|
|
1482
|
+
await this.signIn();
|
|
1483
|
+
const wavesAddress = await this.getWavesAddress();
|
|
1484
|
+
const response = await this.forwardPostMatcherOrdersWavesAddressCancel({
|
|
1485
|
+
'wavesAddress': wavesAddress,
|
|
1486
|
+
'orderId': id,
|
|
1487
|
+
});
|
|
1488
|
+
// {
|
|
1489
|
+
// "success":true,
|
|
1490
|
+
// "message":[[{"orderId":"EBpJeGM36KKFz5gTJAUKDBm89V8wqxKipSFBdU35AN3c","success":true,"status":"OrderCanceled"}]],
|
|
1491
|
+
// "status":"BatchCancelCompleted"
|
|
1492
|
+
// }
|
|
1493
|
+
const message = this.safeValue(response, 'message');
|
|
1494
|
+
const firstMessage = this.safeValue(message, 0);
|
|
1495
|
+
const firstOrder = this.safeValue(firstMessage, 0);
|
|
1496
|
+
const returnedId = this.safeString(firstOrder, 'orderId');
|
|
1497
|
+
return {
|
|
1498
|
+
'info': response,
|
|
1499
|
+
'id': returnedId,
|
|
1500
|
+
'clientOrderId': undefined,
|
|
1501
|
+
'timestamp': undefined,
|
|
1502
|
+
'datetime': undefined,
|
|
1503
|
+
'lastTradeTimestamp': undefined,
|
|
1504
|
+
'symbol': symbol,
|
|
1505
|
+
'type': undefined,
|
|
1506
|
+
'side': undefined,
|
|
1507
|
+
'price': undefined,
|
|
1508
|
+
'amount': undefined,
|
|
1509
|
+
'cost': undefined,
|
|
1510
|
+
'average': undefined,
|
|
1511
|
+
'filled': undefined,
|
|
1512
|
+
'remaining': undefined,
|
|
1513
|
+
'status': undefined,
|
|
1514
|
+
'fee': undefined,
|
|
1515
|
+
'trades': undefined,
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1519
|
+
/**
|
|
1520
|
+
* @method
|
|
1521
|
+
* @name wavesexchange#fetchOrder
|
|
1522
|
+
* @description fetches information on an order made by the user
|
|
1523
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1524
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1525
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1526
|
+
*/
|
|
1527
|
+
this.checkRequiredDependencies();
|
|
1528
|
+
this.checkRequiredKeys();
|
|
1529
|
+
await this.loadMarkets();
|
|
1530
|
+
let market = undefined;
|
|
1531
|
+
if (symbol !== undefined) {
|
|
1532
|
+
market = this.market(symbol);
|
|
1533
|
+
}
|
|
1534
|
+
const timestamp = this.milliseconds();
|
|
1535
|
+
const byteArray = [
|
|
1536
|
+
this.base58ToBinary(this.apiKey),
|
|
1537
|
+
this.numberToBE(timestamp, 8),
|
|
1538
|
+
];
|
|
1539
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
1540
|
+
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
1541
|
+
const signature = this.axolotl(this.binaryToBase16(binary), hexSecret, ed25519.ed25519);
|
|
1542
|
+
const request = {
|
|
1543
|
+
'Timestamp': timestamp.toString(),
|
|
1544
|
+
'Signature': signature,
|
|
1545
|
+
'publicKey': this.apiKey,
|
|
1546
|
+
'orderId': id,
|
|
1547
|
+
};
|
|
1548
|
+
const response = await this.matcherGetMatcherOrderbookPublicKeyOrderId(this.extend(request, params));
|
|
1549
|
+
return this.parseOrder(response, market);
|
|
1550
|
+
}
|
|
1551
|
+
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1552
|
+
/**
|
|
1553
|
+
* @method
|
|
1554
|
+
* @name wavesexchange#fetchOrders
|
|
1555
|
+
* @description fetches information on multiple orders made by the user
|
|
1556
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1557
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1558
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1559
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1560
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1561
|
+
*/
|
|
1562
|
+
this.checkRequiredDependencies();
|
|
1563
|
+
this.checkRequiredKeys();
|
|
1564
|
+
if (symbol === undefined) {
|
|
1565
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
|
|
1566
|
+
}
|
|
1567
|
+
await this.loadMarkets();
|
|
1568
|
+
const market = this.market(symbol);
|
|
1569
|
+
const timestamp = this.milliseconds();
|
|
1570
|
+
const byteArray = [
|
|
1571
|
+
this.base58ToBinary(this.apiKey),
|
|
1572
|
+
this.numberToBE(timestamp, 8),
|
|
1573
|
+
];
|
|
1574
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
1575
|
+
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
1576
|
+
const signature = this.axolotl(this.binaryToBase16(binary), hexSecret, ed25519.ed25519);
|
|
1577
|
+
const request = {
|
|
1578
|
+
'Accept': 'application/json',
|
|
1579
|
+
'Timestamp': timestamp.toString(),
|
|
1580
|
+
'Signature': signature,
|
|
1581
|
+
'publicKey': this.apiKey,
|
|
1582
|
+
'baseId': market['baseId'],
|
|
1583
|
+
'quoteId': market['quoteId'],
|
|
1584
|
+
};
|
|
1585
|
+
const response = await this.matcherGetMatcherOrderbookBaseIdQuoteIdPublicKeyPublicKey(this.extend(request, params));
|
|
1586
|
+
// [ { id: "3KicDeWayY2mdrRoYdCkP3gUAoUZUNT1AA6GAtWuPLfa",
|
|
1587
|
+
// "type": "sell",
|
|
1588
|
+
// "orderType": "limit",
|
|
1589
|
+
// "amount": 1,
|
|
1590
|
+
// "fee": 300000,
|
|
1591
|
+
// "price": 100000000,
|
|
1592
|
+
// "timestamp": 1591651254076,
|
|
1593
|
+
// "filled": 0,
|
|
1594
|
+
// "filledFee": 0,
|
|
1595
|
+
// "feeAsset": "WAVES",
|
|
1596
|
+
// "status": "Accepted",
|
|
1597
|
+
// "assetPair":
|
|
1598
|
+
// { amountAsset: null,
|
|
1599
|
+
// "priceAsset": "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS" },
|
|
1600
|
+
// "avgWeighedPrice": 0 }, ... ]
|
|
1601
|
+
return this.parseOrders(response, market, since, limit);
|
|
1602
|
+
}
|
|
1603
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1604
|
+
/**
|
|
1605
|
+
* @method
|
|
1606
|
+
* @name wavesexchange#fetchOpenOrders
|
|
1607
|
+
* @description fetch all unfilled currently open orders
|
|
1608
|
+
* @param {string} symbol unified market symbol
|
|
1609
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1610
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
1611
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1612
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1613
|
+
*/
|
|
1614
|
+
await this.loadMarkets();
|
|
1615
|
+
await this.signIn();
|
|
1616
|
+
let market = undefined;
|
|
1617
|
+
if (symbol !== undefined) {
|
|
1618
|
+
market = this.market(symbol);
|
|
1619
|
+
}
|
|
1620
|
+
const address = await this.getWavesAddress();
|
|
1621
|
+
const request = {
|
|
1622
|
+
'address': address,
|
|
1623
|
+
'activeOnly': true,
|
|
1624
|
+
};
|
|
1625
|
+
const response = await this.forwardGetMatcherOrdersAddress(request);
|
|
1626
|
+
return this.parseOrders(response, market, since, limit);
|
|
1627
|
+
}
|
|
1628
|
+
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1629
|
+
/**
|
|
1630
|
+
* @method
|
|
1631
|
+
* @name wavesexchange#fetchClosedOrders
|
|
1632
|
+
* @description fetches information on multiple closed orders made by the user
|
|
1633
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1634
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1635
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1636
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1637
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1638
|
+
*/
|
|
1639
|
+
await this.loadMarkets();
|
|
1640
|
+
await this.signIn();
|
|
1641
|
+
let market = undefined;
|
|
1642
|
+
if (symbol !== undefined) {
|
|
1643
|
+
market = this.market(symbol);
|
|
1644
|
+
}
|
|
1645
|
+
const address = await this.getWavesAddress();
|
|
1646
|
+
const request = {
|
|
1647
|
+
'address': address,
|
|
1648
|
+
'closedOnly': true,
|
|
1649
|
+
};
|
|
1650
|
+
const response = await this.forwardGetMatcherOrdersAddress(request);
|
|
1651
|
+
// [
|
|
1652
|
+
// {
|
|
1653
|
+
// "id": "9aXcxvXai73jbAm7tQNnqaQ2PwUjdmWuyjvRTKAHsw4f",
|
|
1654
|
+
// "type": "buy",
|
|
1655
|
+
// "orderType": "limit",
|
|
1656
|
+
// "amount": 23738330,
|
|
1657
|
+
// "fee": 300000,
|
|
1658
|
+
// "price": 3828348334,
|
|
1659
|
+
// "timestamp": 1591926905636,
|
|
1660
|
+
// "filled": 23738330,
|
|
1661
|
+
// "filledFee": 300000,
|
|
1662
|
+
// "feeAsset": "WAVES",
|
|
1663
|
+
// "status": "Filled",
|
|
1664
|
+
// "assetPair": {
|
|
1665
|
+
// "amountAsset": "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
|
|
1666
|
+
// "priceAsset": null
|
|
1667
|
+
// },
|
|
1668
|
+
// "avgWeighedPrice": 3828348334
|
|
1669
|
+
// }, ...
|
|
1670
|
+
// ]
|
|
1671
|
+
return this.parseOrders(response, market, since, limit);
|
|
1672
|
+
}
|
|
1673
|
+
parseOrderStatus(status) {
|
|
1674
|
+
const statuses = {
|
|
1675
|
+
'Cancelled': 'canceled',
|
|
1676
|
+
'Accepted': 'open',
|
|
1677
|
+
'Filled': 'closed',
|
|
1678
|
+
'PartiallyFilled': 'open',
|
|
1679
|
+
};
|
|
1680
|
+
return this.safeString(statuses, status, status);
|
|
1681
|
+
}
|
|
1682
|
+
getSymbolFromAssetPair(assetPair) {
|
|
1683
|
+
// a blank string or null can indicate WAVES
|
|
1684
|
+
const baseId = this.safeString(assetPair, 'amountAsset', 'WAVES');
|
|
1685
|
+
const quoteId = this.safeString(assetPair, 'priceAsset', 'WAVES');
|
|
1686
|
+
return this.safeCurrencyCode(baseId) + '/' + this.safeCurrencyCode(quoteId);
|
|
1687
|
+
}
|
|
1688
|
+
parseOrder(order, market = undefined) {
|
|
1689
|
+
//
|
|
1690
|
+
// createOrder
|
|
1691
|
+
//
|
|
1692
|
+
// {
|
|
1693
|
+
// "version": 4,
|
|
1694
|
+
// "id": "BshyeHXDfJmTnjTdBYt371jD4yWaT3JTP6KpjpsiZepS",
|
|
1695
|
+
// "sender": "3P8VzLSa23EW5CVckHbV7d5BoN75fF1hhFH",
|
|
1696
|
+
// "senderPublicKey": "AHXn8nBA4SfLQF7hLQiSn16kxyehjizBGW1TdrmSZ1gF",
|
|
1697
|
+
// "matcherPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
1698
|
+
// "assetPair": {
|
|
1699
|
+
// "amountAsset": "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
|
|
1700
|
+
// "priceAsset": "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
|
|
1701
|
+
// },
|
|
1702
|
+
// "orderType": "buy",
|
|
1703
|
+
// "amount": 10000,
|
|
1704
|
+
// "price": 400000000,
|
|
1705
|
+
// "timestamp": 1599848586891,
|
|
1706
|
+
// "expiration": 1602267786891,
|
|
1707
|
+
// "matcherFee": 3008,
|
|
1708
|
+
// "matcherFeeAssetId": "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
|
|
1709
|
+
// "signature": "3D2h8ubrhuWkXbVn4qJ3dvjmZQxLoRNfjTqb9uNpnLxUuwm4fGW2qGH6yKFe2SQPrcbgkS3bDVe7SNtMuatEJ7qy",
|
|
1710
|
+
// "proofs": [
|
|
1711
|
+
// "3D2h8ubrhuWkXbVn4qJ3dvjmZQxLoRNfjTqb9uNpnLxUuwm4fGW2qGH6yKFe2SQPrcbgkS3bDVe7SNtMuatEJ7qy",
|
|
1712
|
+
// ],
|
|
1713
|
+
// "attachment":"77rnoyFX5BDr15hqZiUtgXKSN46zsbHHQjVNrTMLZcLz62mmFKr39FJ"
|
|
1714
|
+
// }
|
|
1715
|
+
//
|
|
1716
|
+
//
|
|
1717
|
+
// fetchOrder, fetchOrders, fetchOpenOrders, fetchClosedOrders
|
|
1718
|
+
//
|
|
1719
|
+
// {
|
|
1720
|
+
// "id": "81D9uKk2NfmZzfG7uaJsDtxqWFbJXZmjYvrL88h15fk8",
|
|
1721
|
+
// "type": "buy",
|
|
1722
|
+
// "orderType": "limit",
|
|
1723
|
+
// "amount": 30000000000,
|
|
1724
|
+
// "filled": 0,
|
|
1725
|
+
// "price": 1000000,
|
|
1726
|
+
// "fee": 300000,
|
|
1727
|
+
// "filledFee": 0,
|
|
1728
|
+
// "feeAsset": "WAVES",
|
|
1729
|
+
// "timestamp": 1594303779322,
|
|
1730
|
+
// "status": "Cancelled",
|
|
1731
|
+
// "assetPair": {
|
|
1732
|
+
// "amountAsset": "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
|
|
1733
|
+
// "priceAsset": "WAVES"
|
|
1734
|
+
// },
|
|
1735
|
+
// "avgWeighedPrice": 0,
|
|
1736
|
+
// "version": 4,
|
|
1737
|
+
// "totalExecutedPriceAssets": 0, // in fetchOpenOrder/s
|
|
1738
|
+
// "attachment":"77rnoyFX5BDr15hqZiUtgXKSN46zsbHHQjVNrTMLZcLz62mmFKr39FJ"
|
|
1739
|
+
// }
|
|
1740
|
+
//
|
|
1741
|
+
const timestamp = this.safeInteger(order, 'timestamp');
|
|
1742
|
+
const side = this.safeString2(order, 'type', 'orderType');
|
|
1743
|
+
let type = 'limit';
|
|
1744
|
+
if ('type' in order) {
|
|
1745
|
+
// fetchOrders
|
|
1746
|
+
type = this.safeString(order, 'orderType', type);
|
|
1747
|
+
}
|
|
1748
|
+
const id = this.safeString(order, 'id');
|
|
1749
|
+
const filledString = this.safeString(order, 'filled');
|
|
1750
|
+
const priceString = this.safeString(order, 'price');
|
|
1751
|
+
const amountString = this.safeString(order, 'amount');
|
|
1752
|
+
const assetPair = this.safeValue(order, 'assetPair');
|
|
1753
|
+
let symbol = undefined;
|
|
1754
|
+
if (assetPair !== undefined) {
|
|
1755
|
+
symbol = this.getSymbolFromAssetPair(assetPair);
|
|
1756
|
+
}
|
|
1757
|
+
else if (market !== undefined) {
|
|
1758
|
+
symbol = market['symbol'];
|
|
1759
|
+
}
|
|
1760
|
+
const amountCurrency = this.safeCurrencyCode(this.safeString(assetPair, 'amountAsset', 'WAVES'));
|
|
1761
|
+
const price = this.priceFromPrecision(symbol, priceString);
|
|
1762
|
+
const amount = this.currencyFromPrecision(amountCurrency, amountString);
|
|
1763
|
+
const filled = this.currencyFromPrecision(amountCurrency, filledString);
|
|
1764
|
+
const average = this.priceFromPrecision(symbol, this.safeString(order, 'avgWeighedPrice'));
|
|
1765
|
+
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
1766
|
+
let fee = undefined;
|
|
1767
|
+
if ('type' in order) {
|
|
1768
|
+
const currency = this.safeCurrencyCode(this.safeString(order, 'feeAsset'));
|
|
1769
|
+
fee = {
|
|
1770
|
+
'currency': currency,
|
|
1771
|
+
'fee': this.parseNumber(this.currencyFromPrecision(currency, this.safeString(order, 'filledFee'))),
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
else {
|
|
1775
|
+
const currency = this.safeCurrencyCode(this.safeString(order, 'matcherFeeAssetId', 'WAVES'));
|
|
1776
|
+
fee = {
|
|
1777
|
+
'currency': currency,
|
|
1778
|
+
'fee': this.parseNumber(this.currencyFromPrecision(currency, this.safeString(order, 'matcherFee'))),
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
let triggerPrice = undefined;
|
|
1782
|
+
const attachment = this.safeString(order, 'attachment');
|
|
1783
|
+
if (attachment !== undefined) {
|
|
1784
|
+
const decodedAttachment = this.parseJson(this.decode(this.base58ToBinary(attachment)));
|
|
1785
|
+
if (decodedAttachment !== undefined) {
|
|
1786
|
+
const c = this.safeValue(decodedAttachment, 'c');
|
|
1787
|
+
if (c !== undefined) {
|
|
1788
|
+
const v = this.safeValue(c, 'v');
|
|
1789
|
+
if (v !== undefined) {
|
|
1790
|
+
triggerPrice = this.safeString(v, 'p');
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
return this.safeOrder({
|
|
1796
|
+
'info': order,
|
|
1797
|
+
'id': id,
|
|
1798
|
+
'clientOrderId': undefined,
|
|
1799
|
+
'timestamp': timestamp,
|
|
1800
|
+
'datetime': this.iso8601(timestamp),
|
|
1801
|
+
'lastTradeTimestamp': undefined,
|
|
1802
|
+
'symbol': symbol,
|
|
1803
|
+
'type': type,
|
|
1804
|
+
'timeInForce': undefined,
|
|
1805
|
+
'postOnly': undefined,
|
|
1806
|
+
'side': side,
|
|
1807
|
+
'price': price,
|
|
1808
|
+
'stopPrice': triggerPrice,
|
|
1809
|
+
'triggerPrice': triggerPrice,
|
|
1810
|
+
'amount': amount,
|
|
1811
|
+
'cost': undefined,
|
|
1812
|
+
'average': average,
|
|
1813
|
+
'filled': filled,
|
|
1814
|
+
'remaining': undefined,
|
|
1815
|
+
'status': status,
|
|
1816
|
+
'fee': fee,
|
|
1817
|
+
'trades': undefined,
|
|
1818
|
+
}, market);
|
|
1819
|
+
}
|
|
1820
|
+
async getWavesAddress() {
|
|
1821
|
+
const cachedAddreess = this.safeString(this.options, 'wavesAddress');
|
|
1822
|
+
if (cachedAddreess === undefined) {
|
|
1823
|
+
const request = {
|
|
1824
|
+
'publicKey': this.apiKey,
|
|
1825
|
+
};
|
|
1826
|
+
const response = await this.nodeGetAddressesPublicKeyPublicKey(request);
|
|
1827
|
+
this.options['wavesAddress'] = this.safeString(response, 'address');
|
|
1828
|
+
return this.options['wavesAddress'];
|
|
1829
|
+
}
|
|
1830
|
+
else {
|
|
1831
|
+
return cachedAddreess;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
async fetchBalance(params = {}) {
|
|
1835
|
+
/**
|
|
1836
|
+
* @method
|
|
1837
|
+
* @name wavesexchange#fetchBalance
|
|
1838
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1839
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1840
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1841
|
+
*/
|
|
1842
|
+
// makes a lot of different requests to get all the data
|
|
1843
|
+
// in particular:
|
|
1844
|
+
// fetchMarkets, getWavesAddress,
|
|
1845
|
+
// getTotalBalance (doesn't include waves), getReservedBalance (doesn't include waves)
|
|
1846
|
+
// getReservedBalance (includes WAVES)
|
|
1847
|
+
// I couldn't find another way to get all the data
|
|
1848
|
+
this.checkRequiredDependencies();
|
|
1849
|
+
this.checkRequiredKeys();
|
|
1850
|
+
await this.loadMarkets();
|
|
1851
|
+
const wavesAddress = await this.getWavesAddress();
|
|
1852
|
+
const request = {
|
|
1853
|
+
'address': wavesAddress,
|
|
1854
|
+
};
|
|
1855
|
+
const totalBalance = await this.nodeGetAssetsBalanceAddress(request);
|
|
1856
|
+
// {
|
|
1857
|
+
// "address": "3P8VzLSa23EW5CVckHbV7d5BoN75fF1hhFH",
|
|
1858
|
+
// "balances": [
|
|
1859
|
+
// {
|
|
1860
|
+
// "assetId": "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
|
|
1861
|
+
// "balance": 1177200,
|
|
1862
|
+
// "reissuable": false,
|
|
1863
|
+
// "minSponsoredAssetFee": 7420,
|
|
1864
|
+
// "sponsorBalance": 47492147189709,
|
|
1865
|
+
// "quantity": 999999999775381400,
|
|
1866
|
+
// "issueTransaction": {
|
|
1867
|
+
// "senderPublicKey": "BRnVwSVctnV8pge5vRpsJdWnkjWEJspFb6QvrmZvu3Ht",
|
|
1868
|
+
// "quantity": 1000000000000000000,
|
|
1869
|
+
// "fee": 100400000,
|
|
1870
|
+
// "description": "Neutrino USD",
|
|
1871
|
+
// "type": 3,
|
|
1872
|
+
// "version": 2,
|
|
1873
|
+
// "reissuable": false,
|
|
1874
|
+
// "script": null,
|
|
1875
|
+
// "sender": "3PC9BfRwJWWiw9AREE2B3eWzCks3CYtg4yo",
|
|
1876
|
+
// "feeAssetId": null,
|
|
1877
|
+
// "chainId": 87,
|
|
1878
|
+
// "proofs": [
|
|
1879
|
+
// "3HNpbVkgP69NWSeb9hGYauiQDaXrRXh3tXFzNsGwsAAXnFrA29SYGbLtziW9JLpXEq7qW1uytv5Fnm5XTUMB2BxU"
|
|
1880
|
+
// ],
|
|
1881
|
+
// "assetId": "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
|
|
1882
|
+
// "decimals": 6,
|
|
1883
|
+
// "name": "USD-N",
|
|
1884
|
+
// "id": "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
|
|
1885
|
+
// "timestamp": 1574429393962
|
|
1886
|
+
// }
|
|
1887
|
+
// }
|
|
1888
|
+
// ]
|
|
1889
|
+
// }
|
|
1890
|
+
const balances = this.safeValue(totalBalance, 'balances', []);
|
|
1891
|
+
const result = {};
|
|
1892
|
+
let timestamp = undefined;
|
|
1893
|
+
const assetIds = [];
|
|
1894
|
+
const nonStandardBalances = [];
|
|
1895
|
+
for (let i = 0; i < balances.length; i++) {
|
|
1896
|
+
const entry = balances[i];
|
|
1897
|
+
const entryTimestamp = this.safeInteger(entry, 'timestamp');
|
|
1898
|
+
timestamp = (timestamp === undefined) ? entryTimestamp : Math.max(timestamp, entryTimestamp);
|
|
1899
|
+
const issueTransaction = this.safeValue(entry, 'issueTransaction');
|
|
1900
|
+
const currencyId = this.safeString(entry, 'assetId');
|
|
1901
|
+
const balance = this.safeString(entry, 'balance');
|
|
1902
|
+
if (issueTransaction === undefined) {
|
|
1903
|
+
assetIds.push(currencyId);
|
|
1904
|
+
nonStandardBalances.push(balance);
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1907
|
+
const decimals = this.safeInteger(issueTransaction, 'decimals');
|
|
1908
|
+
let code = undefined;
|
|
1909
|
+
if (currencyId in this.currencies_by_id) {
|
|
1910
|
+
code = this.safeCurrencyCode(currencyId);
|
|
1911
|
+
result[code] = this.account();
|
|
1912
|
+
result[code]['total'] = this.fromPrecision(balance, decimals);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
const nonStandardAssets = assetIds.length;
|
|
1916
|
+
if (nonStandardAssets) {
|
|
1917
|
+
const requestInner = {
|
|
1918
|
+
'ids': assetIds,
|
|
1919
|
+
};
|
|
1920
|
+
const response = await this.publicGetAssets(requestInner);
|
|
1921
|
+
const data = this.safeValue(response, 'data', []);
|
|
1922
|
+
for (let i = 0; i < data.length; i++) {
|
|
1923
|
+
const entry = data[i];
|
|
1924
|
+
const balance = nonStandardBalances[i];
|
|
1925
|
+
const inner = this.safeValue(entry, 'data');
|
|
1926
|
+
const decimals = this.safeInteger(inner, 'precision');
|
|
1927
|
+
const ticker = this.safeString(inner, 'ticker');
|
|
1928
|
+
const code = this.safeCurrencyCode(ticker);
|
|
1929
|
+
result[code] = this.account();
|
|
1930
|
+
result[code]['total'] = this.fromPrecision(balance, decimals);
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
const currentTimestamp = this.milliseconds();
|
|
1934
|
+
const byteArray = [
|
|
1935
|
+
this.base58ToBinary(this.apiKey),
|
|
1936
|
+
this.numberToBE(currentTimestamp, 8),
|
|
1937
|
+
];
|
|
1938
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
1939
|
+
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
1940
|
+
const signature = this.axolotl(this.binaryToBase16(binary), hexSecret, ed25519.ed25519);
|
|
1941
|
+
const matcherRequest = {
|
|
1942
|
+
'publicKey': this.apiKey,
|
|
1943
|
+
'signature': signature,
|
|
1944
|
+
'timestamp': currentTimestamp.toString(),
|
|
1945
|
+
};
|
|
1946
|
+
const reservedBalance = await this.matcherGetMatcherBalanceReservedPublicKey(matcherRequest);
|
|
1947
|
+
// { WAVES: 200300000 }
|
|
1948
|
+
const reservedKeys = Object.keys(reservedBalance);
|
|
1949
|
+
for (let i = 0; i < reservedKeys.length; i++) {
|
|
1950
|
+
const currencyId = reservedKeys[i];
|
|
1951
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1952
|
+
if (!(code in result)) {
|
|
1953
|
+
result[code] = this.account();
|
|
1954
|
+
}
|
|
1955
|
+
const amount = this.safeString(reservedBalance, currencyId);
|
|
1956
|
+
if (code in this.currencies) {
|
|
1957
|
+
result[code]['used'] = this.currencyFromPrecision(code, amount);
|
|
1958
|
+
}
|
|
1959
|
+
else {
|
|
1960
|
+
result[code]['used'] = amount;
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
const wavesRequest = {
|
|
1964
|
+
'address': wavesAddress,
|
|
1965
|
+
};
|
|
1966
|
+
const wavesTotal = await this.nodeGetAddressesBalanceAddress(wavesRequest);
|
|
1967
|
+
// {
|
|
1968
|
+
// "address": "3P8VzLSa23EW5CVckHbV7d5BoN75fF1hhFH",
|
|
1969
|
+
// "confirmations": 0,
|
|
1970
|
+
// "balance": 909085978
|
|
1971
|
+
// }
|
|
1972
|
+
result['WAVES'] = this.safeValue(result, 'WAVES', {});
|
|
1973
|
+
result['WAVES']['total'] = this.currencyFromPrecision('WAVES', this.safeString(wavesTotal, 'balance'));
|
|
1974
|
+
const codes = Object.keys(result);
|
|
1975
|
+
for (let i = 0; i < codes.length; i++) {
|
|
1976
|
+
const code = codes[i];
|
|
1977
|
+
if (this.safeValue(result[code], 'used') === undefined) {
|
|
1978
|
+
result[code]['used'] = '0';
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
result['timestamp'] = timestamp;
|
|
1982
|
+
result['datetime'] = this.iso8601(timestamp);
|
|
1983
|
+
return this.safeBalance(result);
|
|
1984
|
+
}
|
|
1985
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1986
|
+
/**
|
|
1987
|
+
* @method
|
|
1988
|
+
* @name wavesexchange#fetchMyTrades
|
|
1989
|
+
* @description fetch all trades made by the user
|
|
1990
|
+
* @param {string} symbol unified market symbol
|
|
1991
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1992
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
1993
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1994
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1995
|
+
*/
|
|
1996
|
+
await this.loadMarkets();
|
|
1997
|
+
const address = await this.getWavesAddress();
|
|
1998
|
+
const request = {
|
|
1999
|
+
'sender': address,
|
|
2000
|
+
};
|
|
2001
|
+
let market = undefined;
|
|
2002
|
+
if (symbol !== undefined) {
|
|
2003
|
+
market = this.market(symbol);
|
|
2004
|
+
request['amountAsset'] = market['baseId'];
|
|
2005
|
+
request['priceAsset'] = market['quoteId'];
|
|
2006
|
+
}
|
|
2007
|
+
const response = await this.publicGetTransactionsExchange(request);
|
|
2008
|
+
const data = this.safeValue(response, 'data');
|
|
2009
|
+
//
|
|
2010
|
+
// {
|
|
2011
|
+
// "__type":"list",
|
|
2012
|
+
// "isLastPage":true,
|
|
2013
|
+
// "lastCursor":"MzA2MjQ0MzAwMDI5OjpkZXNj",
|
|
2014
|
+
// "data": [
|
|
2015
|
+
// {
|
|
2016
|
+
// "__type":"transaction",
|
|
2017
|
+
// "data": {
|
|
2018
|
+
// "id":"GbjPqco2wRP5QSrY5LimFrUyJaM535K9nhK5zaQ7J7Tx",
|
|
2019
|
+
// "timestamp":"2022-04-06T19:56:31.479Z",
|
|
2020
|
+
// "height":3062443,
|
|
2021
|
+
// "type":7,
|
|
2022
|
+
// "version":2,
|
|
2023
|
+
// "proofs":[
|
|
2024
|
+
// "57mYrANw61eiArCTv2eYwzXm71jYC2KpZ5AeM9zHEstuRaYSAWSuSE7njAJYJu8zap6DMCm3nzqc6es3wQFDpRCN"
|
|
2025
|
+
// ],
|
|
2026
|
+
// "fee":0.003,
|
|
2027
|
+
// "applicationStatus":"succeeded",
|
|
2028
|
+
// "sender":"3PEjHv3JGjcWNpYEEkif2w8NXV4kbhnoGgu",
|
|
2029
|
+
// "senderPublicKey":"9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2030
|
+
// "buyMatcherFee":0,
|
|
2031
|
+
// "sellMatcherFee":0.00141728,
|
|
2032
|
+
// "price":215.7431,
|
|
2033
|
+
// "amount":0.09,
|
|
2034
|
+
// "order1": {
|
|
2035
|
+
// "id":"49qiuQj5frdZ6zpTCEpMuKPMAh1EimwXpXWB4BeCw33h",
|
|
2036
|
+
// "senderPublicKey":"CjUfoH3dsDZsf5UuAjqqzpWHXgvKzBZpVG9YixF7L48K",
|
|
2037
|
+
// "matcherPublicKey":"9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2038
|
+
// "assetPair": {
|
|
2039
|
+
// "amountAsset":"7TMu26hAs7B2oW6c5sfx45KSZT7GQA3TZNYuCav8Dcqt",
|
|
2040
|
+
// "priceAsset":"DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
|
|
2041
|
+
// },
|
|
2042
|
+
// "orderType":"buy",
|
|
2043
|
+
// "price":215.7431,
|
|
2044
|
+
// "sender":"3PR9WmaHV5ueVw2Wr9xsiCG3t4ySXzkkGLy",
|
|
2045
|
+
// "amount":0.36265477,
|
|
2046
|
+
// "timestamp":"2022-04-06T19:55:06.832Z",
|
|
2047
|
+
// "expiration":"2022-05-05T19:55:06.832Z",
|
|
2048
|
+
// "matcherFee":3.000334,
|
|
2049
|
+
// "signature":"2rBWhdeuRJNpQfXfTFtcR8x8Lpic8FUHPdLML9uxABRUuxe48YRJcZxbncwWAh9LWFCEUZiztv7RZBZfGMWfFxTs",
|
|
2050
|
+
// "matcherFeeAssetId":"DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
|
|
2051
|
+
// },
|
|
2052
|
+
// "order2": {
|
|
2053
|
+
// "id":"AkxiJqCuv6wm8K41TUSgFNwShZMnCbMDT78MqrcWpQ53",
|
|
2054
|
+
// "senderPublicKey":"72o7qNKyne5hthB1Ww6famE7uHrk5vTVB2ZfUMBEqL3Y",
|
|
2055
|
+
// "matcherPublicKey":"9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2056
|
+
// "assetPair": {
|
|
2057
|
+
// "amountAsset":"7TMu26hAs7B2oW6c5sfx45KSZT7GQA3TZNYuCav8Dcqt",
|
|
2058
|
+
// "priceAsset":"DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
|
|
2059
|
+
// },
|
|
2060
|
+
// "orderType":"sell",
|
|
2061
|
+
// "price":210,
|
|
2062
|
+
// "sender":"3P3CzbjGgiqEyUBeKZYfgZtyaZfMG8fjoUD",
|
|
2063
|
+
// "amount":0.09,
|
|
2064
|
+
// "timestamp":"2022-04-06T19:56:18.535Z",
|
|
2065
|
+
// "expiration":"2022-05-04T19:56:18.535Z",
|
|
2066
|
+
// "matcherFee":0.00141728,
|
|
2067
|
+
// "signature":"5BZCjYn6QzVkMXBFDBnzcAUBdCZqhq9hQfRXFHfLUQCsbis4zeriw4sUqLa1BZRT2isC6iY4Z4HtekikPqZ461PT",
|
|
2068
|
+
// "matcherFeeAssetId":"7TMu26hAs7B2oW6c5sfx45KSZT7GQA3TZNYuCav8Dcqt"
|
|
2069
|
+
// }
|
|
2070
|
+
// }
|
|
2071
|
+
// },...
|
|
2072
|
+
// ]
|
|
2073
|
+
// }
|
|
2074
|
+
//
|
|
2075
|
+
return this.parseTrades(data, market, since, limit);
|
|
2076
|
+
}
|
|
2077
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
2078
|
+
/**
|
|
2079
|
+
* @method
|
|
2080
|
+
* @name wavesexchange#fetchTrades
|
|
2081
|
+
* @description get the list of most recent trades for a particular symbol
|
|
2082
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
2083
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
2084
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
2085
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2086
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
2087
|
+
*/
|
|
2088
|
+
await this.loadMarkets();
|
|
2089
|
+
const market = this.market(symbol);
|
|
2090
|
+
const request = {
|
|
2091
|
+
'amountAsset': market['baseId'],
|
|
2092
|
+
'priceAsset': market['quoteId'],
|
|
2093
|
+
};
|
|
2094
|
+
if (limit !== undefined) {
|
|
2095
|
+
request['limit'] = Math.min(limit, 100);
|
|
2096
|
+
}
|
|
2097
|
+
if (since !== undefined) {
|
|
2098
|
+
request['timeStart'] = since;
|
|
2099
|
+
}
|
|
2100
|
+
const response = await this.publicGetTransactionsExchange(request);
|
|
2101
|
+
const data = this.safeValue(response, 'data');
|
|
2102
|
+
//
|
|
2103
|
+
// {
|
|
2104
|
+
// "__type":"list",
|
|
2105
|
+
// "isLastPage":false,
|
|
2106
|
+
// "lastCursor":"MzA2MjM2MTAwMDU0OjpkZXNj",
|
|
2107
|
+
// "data": [
|
|
2108
|
+
// {
|
|
2109
|
+
// "__type":"transaction",
|
|
2110
|
+
// "data": {
|
|
2111
|
+
// "id":"F42WsvSsyEzvpPLFjVhQKkSNuopooP4zMkjSUs47NeML",
|
|
2112
|
+
// "timestamp":"2022-04-06T18:39:49.145Z",
|
|
2113
|
+
// "height":3062361,
|
|
2114
|
+
// "type":7,
|
|
2115
|
+
// "version":2,
|
|
2116
|
+
// "proofs": [
|
|
2117
|
+
// "39iJv82kFi4pyuBxYeZpP45NXXjbrCXdVsHPAAvj32UMLmTXLjMTfV43PcmZDSAuS93HKSDo1aKJrin8UvkeE9Bs"
|
|
2118
|
+
// ],
|
|
2119
|
+
// "fee":0.003,
|
|
2120
|
+
// "applicationStatus":"succeeded",
|
|
2121
|
+
// "sender":"3PEjHv3JGjcWNpYEEkif2w8NXV4kbhnoGgu",
|
|
2122
|
+
// "senderPublicKey":"9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2123
|
+
// "buyMatcherFee":0.02314421,
|
|
2124
|
+
// "sellMatcherFee":0,
|
|
2125
|
+
// "price":217.3893,
|
|
2126
|
+
// "amount":0.34523025,
|
|
2127
|
+
// "order1": {
|
|
2128
|
+
// "id":"HkM36PHGaeeZdDKT1mYgZXhaU9PRZ54RZiJc2K4YMT3Q",
|
|
2129
|
+
// "senderPublicKey":"7wYCaDcc6GX1Jx2uS7QgLHBypBKvrezTS1HfiW6Xe4Bk",
|
|
2130
|
+
// "matcherPublicKey":"9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2131
|
+
// "assetPair": {
|
|
2132
|
+
// "amountAsset":"7TMu26hAs7B2oW6c5sfx45KSZT7GQA3TZNYuCav8Dcqt",
|
|
2133
|
+
// "priceAsset":"DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
|
|
2134
|
+
// },
|
|
2135
|
+
// "orderType":"buy",
|
|
2136
|
+
// "price":225.2693,
|
|
2137
|
+
// "sender":"3PLPc8f4DGYaF9C9bwJ2uVmHqRv3NCjg5VQ",
|
|
2138
|
+
// "amount":2.529,
|
|
2139
|
+
// "timestamp":"2022-04-06T18:39:48.796Z",
|
|
2140
|
+
// "expiration":"2022-05-05T18:39:48.796Z",
|
|
2141
|
+
// "matcherFee":0.17584444,
|
|
2142
|
+
// "signature":"2yQfJoomv86evQDw36fg1uiRkHvPDZtRp3qvxqTBWPvz4JLTHGQtEHJF5NGTvym6U93CtgNprngzmD9ecHBjxf6U",
|
|
2143
|
+
// "matcherFeeAssetId":"Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on"
|
|
2144
|
+
// },
|
|
2145
|
+
// "order2": {
|
|
2146
|
+
// "id":"F7HKmeuzwWdk3wKitHLnVx5MuD4wBWPpphQ8kUGx4tT9",
|
|
2147
|
+
// "senderPublicKey":"CjUfoH3dsDZsf5UuAjqqzpWHXgvKzBZpVG9YixF7L48K",
|
|
2148
|
+
// "matcherPublicKey":"9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2149
|
+
// "assetPair": {
|
|
2150
|
+
// "amountAsset":"7TMu26hAs7B2oW6c5sfx45KSZT7GQA3TZNYuCav8Dcqt",
|
|
2151
|
+
// "priceAsset":"DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
|
|
2152
|
+
// },
|
|
2153
|
+
// "orderType":"sell",
|
|
2154
|
+
// "price":217.3893,
|
|
2155
|
+
// "sender":"3PR9WmaHV5ueVw2Wr9xsiCG3t4ySXzkkGLy",
|
|
2156
|
+
// "amount":0.35767793,
|
|
2157
|
+
// "timestamp":"2022-04-06T18:32:01.390Z",
|
|
2158
|
+
// "expiration":"2022-05-05T18:32:01.390Z",
|
|
2159
|
+
// "matcherFee":0.0139168,
|
|
2160
|
+
// "signature":"34HgWVLPgeYWkiSvAc5ChVepGTYDQDug2dMTSincs6idEyoM7AtaZuH3mqQ5RJG2fcxxH2QSB723Qq3dgLQwQmKf",
|
|
2161
|
+
// "matcherFeeAssetId":"7TMu26hAs7B2oW6c5sfx45KSZT7GQA3TZNYuCav8Dcqt"
|
|
2162
|
+
// }
|
|
2163
|
+
// }
|
|
2164
|
+
// }, ...
|
|
2165
|
+
// ]
|
|
2166
|
+
// }
|
|
2167
|
+
//
|
|
2168
|
+
return this.parseTrades(data, market, since, limit);
|
|
2169
|
+
}
|
|
2170
|
+
parseTrade(trade, market = undefined) {
|
|
2171
|
+
//
|
|
2172
|
+
// { __type: "transaction",
|
|
2173
|
+
// "data":
|
|
2174
|
+
// { id: "HSdruioHqvYHeyn9hhyoHdRWPB2bFA8ujeCPZMK6992c",
|
|
2175
|
+
// "timestamp": "2020-06-09T19:34:51.897Z",
|
|
2176
|
+
// "height": 2099684,
|
|
2177
|
+
// "type": 7,
|
|
2178
|
+
// "version": 2,
|
|
2179
|
+
// "proofs":
|
|
2180
|
+
// [ "26teDHERQgwjjHqEn4REcDotNG8M21xjou3X42XuDuCvrRkQo6aPyrswByH3UrkWG8v27ZAaVNzoxDg4teNcLtde" ],
|
|
2181
|
+
// "fee": 0.003,
|
|
2182
|
+
// "sender": "3PEjHv3JGjcWNpYEEkif2w8NXV4kbhnoGgu",
|
|
2183
|
+
// "senderPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2184
|
+
// "buyMatcherFee": 0.00299999,
|
|
2185
|
+
// "sellMatcherFee": 0.00299999,
|
|
2186
|
+
// "price": 0.00012003,
|
|
2187
|
+
// "amount": 60.80421562,
|
|
2188
|
+
// "order1":
|
|
2189
|
+
// { id: "CBRwP3ar4oMvvpUiGyfxc1syh41488SDi2GkrjuBDegv",
|
|
2190
|
+
// "senderPublicKey": "DBXSHBz96NFsMu7xh4fi2eT9ZnyxefAHXsMxUayzgC6a",
|
|
2191
|
+
// "matcherPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2192
|
+
// "assetPair": [Object],
|
|
2193
|
+
// "orderType": "buy",
|
|
2194
|
+
// "price": 0.00012003,
|
|
2195
|
+
// "sender": "3PJfFRgVuJ47UY4ckb74EGzEBzkHXtmG1LA",
|
|
2196
|
+
// "amount": 60.80424773,
|
|
2197
|
+
// "timestamp": "2020-06-09T19:34:51.885Z",
|
|
2198
|
+
// "expiration": "2020-06-10T12:31:31.885Z",
|
|
2199
|
+
// "matcherFee": 0.003,
|
|
2200
|
+
// "signature": "4cA3ZAb3XAEEXaFG7caqpto5TRbpR5PkhZpxoNQZ9ZReNvjuJQs5a3THnumv7rcqmVUiVtuHAgk2f67ANcqtKyJ8",
|
|
2201
|
+
// "matcherFeeAssetId": null },
|
|
2202
|
+
// "order2":
|
|
2203
|
+
// { id: "CHJSLQ6dfSPs6gu2mAegrMUcRiDEDqaj2GKfvptMjS3M",
|
|
2204
|
+
// "senderPublicKey": "3RUC4NGFZm9H8VJhSSjJyFLdiE42qNiUagDcZPwjgDf8",
|
|
2205
|
+
// "matcherPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
|
|
2206
|
+
// "assetPair": [Object],
|
|
2207
|
+
// "orderType": "sell",
|
|
2208
|
+
// "price": 0.00012003,
|
|
2209
|
+
// "sender": "3P9vKoQpMZtaSkHKpNh977YY9ZPzTuntLAq",
|
|
2210
|
+
// "amount": 60.80424773,
|
|
2211
|
+
// "timestamp": "2020-06-09T19:34:51.887Z",
|
|
2212
|
+
// "expiration": "2020-06-10T12:31:31.887Z",
|
|
2213
|
+
// "matcherFee": 0.003,
|
|
2214
|
+
// "signature": "3SFyrcqzou2ddZyNisnLYaGhLt5qRjKxH8Nw3s4T5U7CEKGX9DDo8dS27RgThPVGbYF1rYET1FwrWoQ2UFZ6SMTR",
|
|
2215
|
+
// "matcherFeeAssetId": null } } }
|
|
2216
|
+
//
|
|
2217
|
+
const data = this.safeValue(trade, 'data');
|
|
2218
|
+
const datetime = this.safeString(data, 'timestamp');
|
|
2219
|
+
const timestamp = this.parse8601(datetime);
|
|
2220
|
+
const id = this.safeString(data, 'id');
|
|
2221
|
+
const priceString = this.safeString(data, 'price');
|
|
2222
|
+
const amountString = this.safeString(data, 'amount');
|
|
2223
|
+
const order1 = this.safeValue(data, 'order1');
|
|
2224
|
+
const order2 = this.safeValue(data, 'order2');
|
|
2225
|
+
let order = undefined;
|
|
2226
|
+
// order2 arrived after order1
|
|
2227
|
+
if (this.safeString(order1, 'senderPublicKey') === this.apiKey) {
|
|
2228
|
+
order = order1;
|
|
2229
|
+
}
|
|
2230
|
+
else {
|
|
2231
|
+
order = order2;
|
|
2232
|
+
}
|
|
2233
|
+
let symbol = undefined;
|
|
2234
|
+
const assetPair = this.safeValue(order, 'assetPair');
|
|
2235
|
+
if (assetPair !== undefined) {
|
|
2236
|
+
symbol = this.getSymbolFromAssetPair(assetPair);
|
|
2237
|
+
}
|
|
2238
|
+
else if (market !== undefined) {
|
|
2239
|
+
symbol = market['symbol'];
|
|
2240
|
+
}
|
|
2241
|
+
const side = this.safeString(order, 'orderType');
|
|
2242
|
+
const orderId = this.safeString(order, 'id');
|
|
2243
|
+
const fee = {
|
|
2244
|
+
'cost': this.safeString(order, 'matcherFee'),
|
|
2245
|
+
'currency': this.safeCurrencyCode(this.safeString(order, 'matcherFeeAssetId', 'WAVES')),
|
|
2246
|
+
};
|
|
2247
|
+
return this.safeTrade({
|
|
2248
|
+
'info': trade,
|
|
2249
|
+
'timestamp': timestamp,
|
|
2250
|
+
'datetime': datetime,
|
|
2251
|
+
'symbol': symbol,
|
|
2252
|
+
'id': id,
|
|
2253
|
+
'order': orderId,
|
|
2254
|
+
'type': undefined,
|
|
2255
|
+
'side': side,
|
|
2256
|
+
'takerOrMaker': undefined,
|
|
2257
|
+
'price': priceString,
|
|
2258
|
+
'amount': amountString,
|
|
2259
|
+
'cost': undefined,
|
|
2260
|
+
'fee': fee,
|
|
2261
|
+
}, market);
|
|
2262
|
+
}
|
|
2263
|
+
parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
|
|
2264
|
+
const depositWithdrawFees = {};
|
|
2265
|
+
codes = this.marketCodes(codes);
|
|
2266
|
+
for (let i = 0; i < response.length; i++) {
|
|
2267
|
+
const entry = response[i];
|
|
2268
|
+
const dictionary = entry;
|
|
2269
|
+
const currencyId = this.safeString(dictionary, currencyIdKey);
|
|
2270
|
+
const currency = this.safeValue(this.currencies_by_id, currencyId);
|
|
2271
|
+
const code = this.safeString(currency, 'code', currencyId);
|
|
2272
|
+
if ((codes === undefined) || (this.inArray(code, codes))) {
|
|
2273
|
+
let depositWithdrawFee = this.safeValue(depositWithdrawFees, code);
|
|
2274
|
+
if (depositWithdrawFee === undefined) {
|
|
2275
|
+
depositWithdrawFee = {
|
|
2276
|
+
'info': [dictionary],
|
|
2277
|
+
'withdraw': {
|
|
2278
|
+
'fee': undefined,
|
|
2279
|
+
'percentage': undefined,
|
|
2280
|
+
},
|
|
2281
|
+
'deposit': {
|
|
2282
|
+
'fee': undefined,
|
|
2283
|
+
'percentage': undefined,
|
|
2284
|
+
},
|
|
2285
|
+
'networks': {},
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
else {
|
|
2289
|
+
depositWithdrawFee = depositWithdrawFees[code];
|
|
2290
|
+
depositWithdrawFee['info'] = this.arrayConcat(depositWithdrawFee['info'], [dictionary]);
|
|
2291
|
+
}
|
|
2292
|
+
const networkId = this.safeString(dictionary, 'platform_id');
|
|
2293
|
+
const currencyCode = this.safeString(currency, 'code');
|
|
2294
|
+
const networkCode = this.networkIdToCode(networkId, currencyCode);
|
|
2295
|
+
let network = this.safeValue(depositWithdrawFee['networks'], networkCode);
|
|
2296
|
+
if (network === undefined) {
|
|
2297
|
+
network = {
|
|
2298
|
+
'withdraw': {
|
|
2299
|
+
'fee': undefined,
|
|
2300
|
+
'percentage': undefined,
|
|
2301
|
+
},
|
|
2302
|
+
'deposit': {
|
|
2303
|
+
'fee': undefined,
|
|
2304
|
+
'percentage': undefined,
|
|
2305
|
+
},
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
const feeType = this.safeString(dictionary, 'type');
|
|
2309
|
+
const fees = this.safeValue(dictionary, 'fees');
|
|
2310
|
+
let networkKey = 'deposit';
|
|
2311
|
+
if (feeType === 'withdrawal_currency') {
|
|
2312
|
+
networkKey = 'withdraw';
|
|
2313
|
+
}
|
|
2314
|
+
network[networkKey] = { 'fee': this.safeNumber(fees, 'flat'), 'percentage': false };
|
|
2315
|
+
depositWithdrawFee['networks'][networkCode] = network;
|
|
2316
|
+
depositWithdrawFees[code] = depositWithdrawFee;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
const depositWithdrawFeesKeys = Object.keys(depositWithdrawFees);
|
|
2320
|
+
for (let i = 0; i < depositWithdrawFeesKeys.length; i++) {
|
|
2321
|
+
const code = depositWithdrawFeesKeys[i];
|
|
2322
|
+
const entry = depositWithdrawFees[code];
|
|
2323
|
+
const networks = this.safeValue(entry, 'networks');
|
|
2324
|
+
const networkKeys = Object.keys(networks);
|
|
2325
|
+
const networkKeysLength = networkKeys.length;
|
|
2326
|
+
if (networkKeysLength === 1) {
|
|
2327
|
+
const network = this.safeValue(networks, networkKeys[0]);
|
|
2328
|
+
depositWithdrawFees[code]['withdraw'] = this.safeValue(network, 'withdraw');
|
|
2329
|
+
depositWithdrawFees[code]['deposit'] = this.safeValue(network, 'deposit');
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
return depositWithdrawFees;
|
|
2333
|
+
}
|
|
2334
|
+
async fetchDepositWithdrawFees(codes = undefined, params = {}) {
|
|
2335
|
+
/**
|
|
2336
|
+
* @method
|
|
2337
|
+
* @name wavesexchange#fetchDepositWithdrawFees
|
|
2338
|
+
* @description fetch deposit and withdraw fees
|
|
2339
|
+
* @see https://docs.wx.network/en/api/gateways/deposit/currencies
|
|
2340
|
+
* @see https://docs.wx.network/en/api/gateways/withdraw/currencies
|
|
2341
|
+
* @param {string[]|undefined} codes list of unified currency codes
|
|
2342
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2343
|
+
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
2344
|
+
*/
|
|
2345
|
+
await this.loadMarkets();
|
|
2346
|
+
let data = [];
|
|
2347
|
+
let promises = [];
|
|
2348
|
+
promises.push(this.privateGetDepositCurrencies(params));
|
|
2349
|
+
promises.push(this.privateGetWithdrawCurrencies(params));
|
|
2350
|
+
promises = await Promise.all(promises);
|
|
2351
|
+
//
|
|
2352
|
+
// {
|
|
2353
|
+
// "type": "list",
|
|
2354
|
+
// "page_info": {
|
|
2355
|
+
// "has_next_page": false,
|
|
2356
|
+
// "last_cursor": null
|
|
2357
|
+
// },
|
|
2358
|
+
// "items": [
|
|
2359
|
+
// {
|
|
2360
|
+
// "type": "deposit_currency",
|
|
2361
|
+
// "id": "WEST",
|
|
2362
|
+
// "platform_id": "WEST",
|
|
2363
|
+
// "waves_asset_id": "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
|
|
2364
|
+
// "platform_asset_id": "WEST",
|
|
2365
|
+
// "decimals": 8,
|
|
2366
|
+
// "status": "active",
|
|
2367
|
+
// "allowed_amount": {
|
|
2368
|
+
// "min": 0.1,
|
|
2369
|
+
// "max": 2000000
|
|
2370
|
+
// },
|
|
2371
|
+
// "fees": {
|
|
2372
|
+
// "flat": 0,
|
|
2373
|
+
// "rate": 0
|
|
2374
|
+
// }
|
|
2375
|
+
// },
|
|
2376
|
+
// ]
|
|
2377
|
+
// }
|
|
2378
|
+
//
|
|
2379
|
+
//
|
|
2380
|
+
// {
|
|
2381
|
+
// "type": "list",
|
|
2382
|
+
// "page_info": {
|
|
2383
|
+
// "has_next_page": false,
|
|
2384
|
+
// "last_cursor": null
|
|
2385
|
+
// },
|
|
2386
|
+
// "items": [
|
|
2387
|
+
// {
|
|
2388
|
+
// "type": "withdrawal_currency",
|
|
2389
|
+
// "id": "BTC",
|
|
2390
|
+
// "platform_id": "BTC",
|
|
2391
|
+
// "waves_asset_id": "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
|
|
2392
|
+
// "platform_asset_id": "BTC",
|
|
2393
|
+
// "decimals": 8,
|
|
2394
|
+
// "status": "inactive",
|
|
2395
|
+
// "allowed_amount": {
|
|
2396
|
+
// "min": 0.001,
|
|
2397
|
+
// "max": 10
|
|
2398
|
+
// },
|
|
2399
|
+
// "fees": {
|
|
2400
|
+
// "flat": 0.001,
|
|
2401
|
+
// "rate": 0
|
|
2402
|
+
// }
|
|
2403
|
+
// },
|
|
2404
|
+
// ]
|
|
2405
|
+
// }
|
|
2406
|
+
//
|
|
2407
|
+
for (let i = 0; i < promises.length; i++) {
|
|
2408
|
+
const items = this.safeValue(promises[i], 'items');
|
|
2409
|
+
data = this.arrayConcat(data, items);
|
|
2410
|
+
}
|
|
2411
|
+
return this.parseDepositWithdrawFees(data, codes, 'id');
|
|
2412
|
+
}
|
|
2413
|
+
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2414
|
+
const errorCode = this.safeString(response, 'error');
|
|
2415
|
+
const success = this.safeValue(response, 'success', true);
|
|
2416
|
+
const Exception = this.safeValue(this.exceptions, errorCode);
|
|
2417
|
+
if (Exception !== undefined) {
|
|
2418
|
+
const messageInner = this.safeString(response, 'message');
|
|
2419
|
+
throw new Exception(this.id + ' ' + messageInner);
|
|
2420
|
+
}
|
|
2421
|
+
const message = this.safeString(response, 'message');
|
|
2422
|
+
if (message === 'Validation Error') {
|
|
2423
|
+
throw new errors.BadRequest(this.id + ' ' + body);
|
|
2424
|
+
}
|
|
2425
|
+
if (!success) {
|
|
2426
|
+
throw new errors.ExchangeError(this.id + ' ' + body);
|
|
2427
|
+
}
|
|
2428
|
+
return undefined;
|
|
2429
|
+
}
|
|
2430
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
2431
|
+
/**
|
|
2432
|
+
* @method
|
|
2433
|
+
* @name wavesexchange#withdraw
|
|
2434
|
+
* @description make a withdrawal
|
|
2435
|
+
* @param {string} code unified currency code
|
|
2436
|
+
* @param {float} amount the amount to withdraw
|
|
2437
|
+
* @param {string} address the address to withdraw to
|
|
2438
|
+
* @param {string} tag
|
|
2439
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2440
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2441
|
+
*/
|
|
2442
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
2443
|
+
// currently only works for BTC and WAVES
|
|
2444
|
+
if (code !== 'WAVES') {
|
|
2445
|
+
const supportedCurrencies = await this.privateGetWithdrawCurrencies();
|
|
2446
|
+
const currencies = {};
|
|
2447
|
+
const items = this.safeValue(supportedCurrencies, 'items', []);
|
|
2448
|
+
for (let i = 0; i < items.length; i++) {
|
|
2449
|
+
const entry = items[i];
|
|
2450
|
+
const currencyCode = this.safeString(entry, 'id');
|
|
2451
|
+
currencies[currencyCode] = true;
|
|
2452
|
+
}
|
|
2453
|
+
if (!(code in currencies)) {
|
|
2454
|
+
const codes = Object.keys(currencies);
|
|
2455
|
+
throw new errors.ExchangeError(this.id + ' withdraw() ' + code + ' not supported. Currency code must be one of ' + codes.toString());
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
await this.loadMarkets();
|
|
2459
|
+
const hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
|
|
2460
|
+
const set = {};
|
|
2461
|
+
for (let i = 0; i < hexChars.length; i++) {
|
|
2462
|
+
const key = hexChars[i];
|
|
2463
|
+
set[key] = true;
|
|
2464
|
+
}
|
|
2465
|
+
let isErc20 = true;
|
|
2466
|
+
const noPrefix = this.remove0xPrefix(address);
|
|
2467
|
+
const lower = noPrefix.toLowerCase();
|
|
2468
|
+
const stringLength = lower.length * 1;
|
|
2469
|
+
for (let i = 0; i < stringLength; i++) {
|
|
2470
|
+
const character = lower[i];
|
|
2471
|
+
if (!(character in set)) {
|
|
2472
|
+
isErc20 = false;
|
|
2473
|
+
break;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
await this.signIn();
|
|
2477
|
+
let proxyAddress = undefined;
|
|
2478
|
+
if (code === 'WAVES' && !isErc20) {
|
|
2479
|
+
proxyAddress = address;
|
|
2480
|
+
}
|
|
2481
|
+
else {
|
|
2482
|
+
const withdrawAddressRequest = {
|
|
2483
|
+
'address': address,
|
|
2484
|
+
'currency': code,
|
|
2485
|
+
};
|
|
2486
|
+
const withdrawAddress = await this.privateGetWithdrawAddressesCurrencyAddress(withdrawAddressRequest);
|
|
2487
|
+
const currencyInner = this.safeValue(withdrawAddress, 'currency');
|
|
2488
|
+
const allowedAmount = this.safeValue(currencyInner, 'allowed_amount');
|
|
2489
|
+
const minimum = this.safeNumber(allowedAmount, 'min');
|
|
2490
|
+
if (amount <= minimum) {
|
|
2491
|
+
throw new errors.BadRequest(this.id + ' ' + code + ' withdraw failed, amount ' + amount.toString() + ' must be greater than the minimum allowed amount of ' + minimum.toString());
|
|
2492
|
+
}
|
|
2493
|
+
// {
|
|
2494
|
+
// "type": "withdrawal_addresses",
|
|
2495
|
+
// "currency": {
|
|
2496
|
+
// "type": "withdrawal_currency",
|
|
2497
|
+
// "id": "BTC",
|
|
2498
|
+
// "waves_asset_id": "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
|
|
2499
|
+
// "decimals": 8,
|
|
2500
|
+
// "status": "active",
|
|
2501
|
+
// "allowed_amount": {
|
|
2502
|
+
// "min": 0.001,
|
|
2503
|
+
// "max": 20
|
|
2504
|
+
// },
|
|
2505
|
+
// "fees": {
|
|
2506
|
+
// "flat": 0.001,
|
|
2507
|
+
// "rate": 0
|
|
2508
|
+
// }
|
|
2509
|
+
// },
|
|
2510
|
+
// "proxy_addresses": [
|
|
2511
|
+
// "3P3qqmkiLwNHB7x1FeoE8bvkRtULwGpo9ga"
|
|
2512
|
+
// ]
|
|
2513
|
+
// }
|
|
2514
|
+
const proxyAddresses = this.safeValue(withdrawAddress, 'proxy_addresses', []);
|
|
2515
|
+
proxyAddress = this.safeString(proxyAddresses, 0);
|
|
2516
|
+
}
|
|
2517
|
+
const fee = this.safeInteger(this.options, 'withdrawFeeWAVES', 100000); // 0.001 WAVES
|
|
2518
|
+
const feeAssetId = 'WAVES';
|
|
2519
|
+
const type = 4; // transfer
|
|
2520
|
+
const version = 2;
|
|
2521
|
+
const amountInteger = this.currencyToPrecision(code, amount);
|
|
2522
|
+
const currency = this.currency(code);
|
|
2523
|
+
const timestamp = this.milliseconds();
|
|
2524
|
+
const byteArray = [
|
|
2525
|
+
this.numberToBE(4, 1),
|
|
2526
|
+
this.numberToBE(2, 1),
|
|
2527
|
+
this.base58ToBinary(this.apiKey),
|
|
2528
|
+
this.getAssetBytes(currency['id']),
|
|
2529
|
+
this.getAssetBytes(feeAssetId),
|
|
2530
|
+
this.numberToBE(timestamp, 8),
|
|
2531
|
+
this.numberToBE(amountInteger, 8),
|
|
2532
|
+
this.numberToBE(fee, 8),
|
|
2533
|
+
this.base58ToBinary(proxyAddress),
|
|
2534
|
+
this.numberToBE(0, 2),
|
|
2535
|
+
];
|
|
2536
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
2537
|
+
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
2538
|
+
const signature = this.axolotl(this.binaryToBase16(binary), hexSecret, ed25519.ed25519);
|
|
2539
|
+
const request = {
|
|
2540
|
+
'senderPublicKey': this.apiKey,
|
|
2541
|
+
'amount': amountInteger,
|
|
2542
|
+
'fee': fee,
|
|
2543
|
+
'type': type,
|
|
2544
|
+
'version': version,
|
|
2545
|
+
'attachment': '',
|
|
2546
|
+
'feeAssetId': this.getAssetId(feeAssetId),
|
|
2547
|
+
'proofs': [
|
|
2548
|
+
signature,
|
|
2549
|
+
],
|
|
2550
|
+
'assetId': this.getAssetId(currency['id']),
|
|
2551
|
+
'recipient': proxyAddress,
|
|
2552
|
+
'timestamp': timestamp,
|
|
2553
|
+
'signature': signature,
|
|
2554
|
+
};
|
|
2555
|
+
const result = await this.nodePostTransactionsBroadcast(request);
|
|
2556
|
+
//
|
|
2557
|
+
// {
|
|
2558
|
+
// "id": "string",
|
|
2559
|
+
// "signature": "string",
|
|
2560
|
+
// "fee": 0,
|
|
2561
|
+
// "timestamp": 1460678400000,
|
|
2562
|
+
// "recipient": "3P274YB5qseSE9DTTL3bpSjosZrYBPDpJ8k",
|
|
2563
|
+
// "amount": 0
|
|
2564
|
+
// }
|
|
2565
|
+
//
|
|
2566
|
+
return this.parseTransaction(result, currency);
|
|
2567
|
+
}
|
|
2568
|
+
parseTransaction(transaction, currency = undefined) {
|
|
2569
|
+
//
|
|
2570
|
+
// withdraw
|
|
2571
|
+
//
|
|
2572
|
+
// {
|
|
2573
|
+
// "id": "string",
|
|
2574
|
+
// "signature": "string",
|
|
2575
|
+
// "fee": 0,
|
|
2576
|
+
// "timestamp": 1460678400000,
|
|
2577
|
+
// "recipient": "3P274YB5qseSE9DTTL3bpSjosZrYBPDpJ8k",
|
|
2578
|
+
// "amount": 0
|
|
2579
|
+
// }
|
|
2580
|
+
//
|
|
2581
|
+
currency = this.safeCurrency(undefined, currency);
|
|
2582
|
+
return {
|
|
2583
|
+
'id': undefined,
|
|
2584
|
+
'txid': undefined,
|
|
2585
|
+
'timestamp': undefined,
|
|
2586
|
+
'datetime': undefined,
|
|
2587
|
+
'network': undefined,
|
|
2588
|
+
'addressFrom': undefined,
|
|
2589
|
+
'address': undefined,
|
|
2590
|
+
'addressTo': undefined,
|
|
2591
|
+
'amount': undefined,
|
|
2592
|
+
'type': undefined,
|
|
2593
|
+
'currency': currency['code'],
|
|
2594
|
+
'status': undefined,
|
|
2595
|
+
'updated': undefined,
|
|
2596
|
+
'tagFrom': undefined,
|
|
2597
|
+
'tag': undefined,
|
|
2598
|
+
'tagTo': undefined,
|
|
2599
|
+
'comment': undefined,
|
|
2600
|
+
'internal': undefined,
|
|
2601
|
+
'fee': undefined,
|
|
2602
|
+
'info': transaction,
|
|
2603
|
+
};
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
module.exports = wavesexchange;
|