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,1770 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var idex$1 = require('./abstract/idex.js');
|
|
4
|
+
var number = require('./base/functions/number.js');
|
|
5
|
+
var errors = require('./base/errors.js');
|
|
6
|
+
var Precise = require('./base/Precise.js');
|
|
7
|
+
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
8
|
+
var sha3 = require('./static_dependencies/noble-hashes/sha3.js');
|
|
9
|
+
var secp256k1 = require('./static_dependencies/noble-curves/secp256k1.js');
|
|
10
|
+
var crypto = require('./base/functions/crypto.js');
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
/**
|
|
15
|
+
* @class idex
|
|
16
|
+
* @augments Exchange
|
|
17
|
+
*/
|
|
18
|
+
class idex extends idex$1 {
|
|
19
|
+
describe() {
|
|
20
|
+
return this.deepExtend(super.describe(), {
|
|
21
|
+
'id': 'idex',
|
|
22
|
+
'name': 'IDEX',
|
|
23
|
+
'countries': ['US'],
|
|
24
|
+
'rateLimit': 1000,
|
|
25
|
+
'version': 'v3',
|
|
26
|
+
'pro': true,
|
|
27
|
+
'certified': false,
|
|
28
|
+
'requiresWeb3': true,
|
|
29
|
+
'has': {
|
|
30
|
+
'CORS': undefined,
|
|
31
|
+
'spot': true,
|
|
32
|
+
'margin': false,
|
|
33
|
+
'swap': false,
|
|
34
|
+
'future': false,
|
|
35
|
+
'option': false,
|
|
36
|
+
'addMargin': false,
|
|
37
|
+
'cancelAllOrders': true,
|
|
38
|
+
'cancelOrder': true,
|
|
39
|
+
'cancelOrders': false,
|
|
40
|
+
'closeAllPositions': false,
|
|
41
|
+
'closePosition': false,
|
|
42
|
+
'createDepositAddress': false,
|
|
43
|
+
'createOrder': true,
|
|
44
|
+
'createReduceOnlyOrder': false,
|
|
45
|
+
'createStopLimitOrder': true,
|
|
46
|
+
'createStopMarketOrder': true,
|
|
47
|
+
'createStopOrder': true,
|
|
48
|
+
'fetchBalance': true,
|
|
49
|
+
'fetchBorrowRateHistories': false,
|
|
50
|
+
'fetchBorrowRateHistory': false,
|
|
51
|
+
'fetchClosedOrders': true,
|
|
52
|
+
'fetchCrossBorrowRate': false,
|
|
53
|
+
'fetchCrossBorrowRates': false,
|
|
54
|
+
'fetchCurrencies': true,
|
|
55
|
+
'fetchDeposit': true,
|
|
56
|
+
'fetchDeposits': true,
|
|
57
|
+
'fetchFundingHistory': false,
|
|
58
|
+
'fetchFundingRate': false,
|
|
59
|
+
'fetchFundingRateHistory': false,
|
|
60
|
+
'fetchFundingRates': false,
|
|
61
|
+
'fetchIndexOHLCV': false,
|
|
62
|
+
'fetchIsolatedBorrowRate': false,
|
|
63
|
+
'fetchIsolatedBorrowRates': false,
|
|
64
|
+
'fetchLeverage': false,
|
|
65
|
+
'fetchLeverageTiers': false,
|
|
66
|
+
'fetchMarginMode': false,
|
|
67
|
+
'fetchMarkets': true,
|
|
68
|
+
'fetchMarkOHLCV': false,
|
|
69
|
+
'fetchMyTrades': true,
|
|
70
|
+
'fetchOHLCV': true,
|
|
71
|
+
'fetchOpenInterestHistory': false,
|
|
72
|
+
'fetchOpenOrders': true,
|
|
73
|
+
'fetchOrder': true,
|
|
74
|
+
'fetchOrderBook': true,
|
|
75
|
+
'fetchOrders': false,
|
|
76
|
+
'fetchPosition': false,
|
|
77
|
+
'fetchPositionMode': false,
|
|
78
|
+
'fetchPositions': false,
|
|
79
|
+
'fetchPositionsRisk': false,
|
|
80
|
+
'fetchPremiumIndexOHLCV': false,
|
|
81
|
+
'fetchTicker': true,
|
|
82
|
+
'fetchTickers': true,
|
|
83
|
+
'fetchTrades': true,
|
|
84
|
+
'fetchTradingFee': false,
|
|
85
|
+
'fetchTradingFees': true,
|
|
86
|
+
'fetchTransactions': false,
|
|
87
|
+
'fetchWithdrawal': true,
|
|
88
|
+
'fetchWithdrawals': true,
|
|
89
|
+
'reduceMargin': false,
|
|
90
|
+
'setLeverage': false,
|
|
91
|
+
'setMarginMode': false,
|
|
92
|
+
'setPositionMode': false,
|
|
93
|
+
'transfer': false,
|
|
94
|
+
'withdraw': true,
|
|
95
|
+
},
|
|
96
|
+
'timeframes': {
|
|
97
|
+
'1m': '1m',
|
|
98
|
+
'5m': '5m',
|
|
99
|
+
'15m': '15m',
|
|
100
|
+
'30m': '30m',
|
|
101
|
+
'1h': '1h',
|
|
102
|
+
'6h': '6h',
|
|
103
|
+
'1d': '1d',
|
|
104
|
+
},
|
|
105
|
+
'urls': {
|
|
106
|
+
'test': {
|
|
107
|
+
'MATIC': 'https://api-sandbox-matic.idex.io',
|
|
108
|
+
},
|
|
109
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/94481303-2f222100-01e0-11eb-97dd-bc14c5943a86.jpg',
|
|
110
|
+
'api': {
|
|
111
|
+
'MATIC': 'https://api-matic.idex.io',
|
|
112
|
+
},
|
|
113
|
+
'www': 'https://idex.io',
|
|
114
|
+
'doc': [
|
|
115
|
+
'https://docs.idex.io/',
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
'api': {
|
|
119
|
+
'public': {
|
|
120
|
+
'get': {
|
|
121
|
+
'ping': 1,
|
|
122
|
+
'time': 1,
|
|
123
|
+
'exchange': 1,
|
|
124
|
+
'assets': 1,
|
|
125
|
+
'markets': 1,
|
|
126
|
+
'tickers': 1,
|
|
127
|
+
'candles': 1,
|
|
128
|
+
'trades': 1,
|
|
129
|
+
'orderbook': 1,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
'private': {
|
|
133
|
+
'get': {
|
|
134
|
+
'user': 1,
|
|
135
|
+
'wallets': 1,
|
|
136
|
+
'balances': 1,
|
|
137
|
+
'orders': 0.1,
|
|
138
|
+
'fills': 0.1,
|
|
139
|
+
'deposits': 1,
|
|
140
|
+
'withdrawals': 1,
|
|
141
|
+
'wsToken': 1,
|
|
142
|
+
},
|
|
143
|
+
'post': {
|
|
144
|
+
'wallets': 1,
|
|
145
|
+
'orders': 0.1,
|
|
146
|
+
'orders/test': 0.1,
|
|
147
|
+
'withdrawals': 1,
|
|
148
|
+
},
|
|
149
|
+
'delete': {
|
|
150
|
+
'orders': 0.1,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
'options': {
|
|
155
|
+
'defaultTimeInForce': 'gtc',
|
|
156
|
+
'defaultSelfTradePrevention': 'cn',
|
|
157
|
+
'network': 'MATIC',
|
|
158
|
+
},
|
|
159
|
+
'exceptions': {
|
|
160
|
+
'INVALID_ORDER_QUANTITY': errors.InvalidOrder,
|
|
161
|
+
'INSUFFICIENT_FUNDS': errors.InsufficientFunds,
|
|
162
|
+
'SERVICE_UNAVAILABLE': errors.ExchangeNotAvailable,
|
|
163
|
+
'EXCEEDED_RATE_LIMIT': errors.DDoSProtection,
|
|
164
|
+
'INVALID_PARAMETER': errors.BadRequest,
|
|
165
|
+
'WALLET_NOT_ASSOCIATED': errors.InvalidAddress,
|
|
166
|
+
'INVALID_WALLET_SIGNATURE': errors.AuthenticationError,
|
|
167
|
+
},
|
|
168
|
+
'requiredCredentials': {
|
|
169
|
+
'walletAddress': true,
|
|
170
|
+
'privateKey': true,
|
|
171
|
+
'apiKey': true,
|
|
172
|
+
'secret': true,
|
|
173
|
+
},
|
|
174
|
+
'precisionMode': number.TICK_SIZE,
|
|
175
|
+
'paddingMode': number.PAD_WITH_ZERO,
|
|
176
|
+
'commonCurrencies': {},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
priceToPrecision(symbol, price) {
|
|
180
|
+
//
|
|
181
|
+
// we override priceToPrecision to fix the following issue
|
|
182
|
+
// https://github.com/ccxt/ccxt/issues/13367
|
|
183
|
+
// {"code":"INVALID_PARAMETER","message":"invalid value provided for request parameter \"price\": all quantities and prices must be below 100 billion, above 0, need to be provided as strings, and always require 4 decimals ending with 4 zeroes"}
|
|
184
|
+
//
|
|
185
|
+
const market = this.market(symbol);
|
|
186
|
+
const info = this.safeValue(market, 'info', {});
|
|
187
|
+
const quoteAssetPrecision = this.safeInteger(info, 'quoteAssetPrecision');
|
|
188
|
+
price = this.decimalToPrecision(price, number.ROUND, market['precision']['price'], this.precisionMode);
|
|
189
|
+
return this.decimalToPrecision(price, number.TRUNCATE, quoteAssetPrecision, number.DECIMAL_PLACES, number.PAD_WITH_ZERO);
|
|
190
|
+
}
|
|
191
|
+
async fetchMarkets(params = {}) {
|
|
192
|
+
/**
|
|
193
|
+
* @method
|
|
194
|
+
* @name idex#fetchMarkets
|
|
195
|
+
* @description retrieves data on all markets for idex
|
|
196
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
197
|
+
* @returns {object[]} an array of objects representing market data
|
|
198
|
+
*/
|
|
199
|
+
const response = await this.publicGetMarkets(params);
|
|
200
|
+
//
|
|
201
|
+
// [
|
|
202
|
+
// {
|
|
203
|
+
// "market": "ETH-USDC",
|
|
204
|
+
// "type": "hybrid",
|
|
205
|
+
// "status": "activeHybrid",
|
|
206
|
+
// "baseAsset": "ETH",
|
|
207
|
+
// "baseAssetPrecision": "8",
|
|
208
|
+
// "quoteAsset": "USDC",
|
|
209
|
+
// "quoteAssetPrecision": "8",
|
|
210
|
+
// "makerFeeRate": "0.0000",
|
|
211
|
+
// "takerFeeRate": "0.2500",
|
|
212
|
+
// "takerIdexFeeRate": "0.0500",
|
|
213
|
+
// "takerLiquidityProviderFeeRate": "0.2000",
|
|
214
|
+
// "tickSize": "0.01000000"
|
|
215
|
+
// },
|
|
216
|
+
// ]
|
|
217
|
+
//
|
|
218
|
+
const response2 = await this.publicGetExchange();
|
|
219
|
+
//
|
|
220
|
+
// {
|
|
221
|
+
// "timeZone": "UTC",
|
|
222
|
+
// "serverTime": "1654460599952",
|
|
223
|
+
// "maticDepositContractAddress": "0x3253a7e75539edaeb1db608ce6ef9aa1ac9126b6",
|
|
224
|
+
// "maticCustodyContractAddress": "0x3bcc4eca0a40358558ca8d1bcd2d1dbde63eb468",
|
|
225
|
+
// "maticUsdPrice": "0.60",
|
|
226
|
+
// "gasPrice": "180",
|
|
227
|
+
// "volume24hUsd": "10015814.46",
|
|
228
|
+
// "totalVolumeUsd": "1589273533.28",
|
|
229
|
+
// "totalTrades": "1534904",
|
|
230
|
+
// "totalValueLockedUsd": "12041929.44",
|
|
231
|
+
// "idexStakingValueLockedUsd": "20133816.98",
|
|
232
|
+
// "idexTokenAddress": "0x9Cb74C8032b007466865f060ad2c46145d45553D",
|
|
233
|
+
// "idexUsdPrice": "0.07",
|
|
234
|
+
// "idexMarketCapUsd": "48012346.00",
|
|
235
|
+
// "makerFeeRate": "0.0000",
|
|
236
|
+
// "takerFeeRate": "0.0025",
|
|
237
|
+
// "takerIdexFeeRate": "0.0005",
|
|
238
|
+
// "takerLiquidityProviderFeeRate": "0.0020",
|
|
239
|
+
// "makerTradeMinimum": "10.00000000",
|
|
240
|
+
// "takerTradeMinimum": "1.00000000",
|
|
241
|
+
// "withdrawMinimum": "0.50000000",
|
|
242
|
+
// "liquidityAdditionMinimum": "0.50000000",
|
|
243
|
+
// "liquidityRemovalMinimum": "0.40000000",
|
|
244
|
+
// "blockConfirmationDelay": "64"
|
|
245
|
+
// }
|
|
246
|
+
//
|
|
247
|
+
const maker = this.safeNumber(response2, 'makerFeeRate');
|
|
248
|
+
const taker = this.safeNumber(response2, 'takerFeeRate');
|
|
249
|
+
const makerMin = this.safeString(response2, 'makerTradeMinimum');
|
|
250
|
+
const takerMin = this.safeString(response2, 'takerTradeMinimum');
|
|
251
|
+
const minCostETH = this.parseNumber(Precise["default"].stringMin(makerMin, takerMin));
|
|
252
|
+
const result = [];
|
|
253
|
+
for (let i = 0; i < response.length; i++) {
|
|
254
|
+
const entry = response[i];
|
|
255
|
+
const marketId = this.safeString(entry, 'market');
|
|
256
|
+
const baseId = this.safeString(entry, 'baseAsset');
|
|
257
|
+
const quoteId = this.safeString(entry, 'quoteAsset');
|
|
258
|
+
const base = this.safeCurrencyCode(baseId);
|
|
259
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
260
|
+
const basePrecision = this.parseNumber(this.parsePrecision(this.safeString(entry, 'baseAssetPrecision')));
|
|
261
|
+
const quotePrecision = this.parseNumber(this.parsePrecision(this.safeString(entry, 'quoteAssetPrecision')));
|
|
262
|
+
const status = this.safeString(entry, 'status');
|
|
263
|
+
let minCost = undefined;
|
|
264
|
+
if (quote === 'ETH') {
|
|
265
|
+
minCost = minCostETH;
|
|
266
|
+
}
|
|
267
|
+
result.push({
|
|
268
|
+
'id': marketId,
|
|
269
|
+
'symbol': base + '/' + quote,
|
|
270
|
+
'base': base,
|
|
271
|
+
'quote': quote,
|
|
272
|
+
'settle': undefined,
|
|
273
|
+
'baseId': baseId,
|
|
274
|
+
'quoteId': quoteId,
|
|
275
|
+
'settleId': undefined,
|
|
276
|
+
'type': 'spot',
|
|
277
|
+
'spot': true,
|
|
278
|
+
'margin': false,
|
|
279
|
+
'swap': false,
|
|
280
|
+
'future': false,
|
|
281
|
+
'option': false,
|
|
282
|
+
'active': (status !== 'inactive'),
|
|
283
|
+
'contract': false,
|
|
284
|
+
'linear': undefined,
|
|
285
|
+
'inverse': undefined,
|
|
286
|
+
'taker': taker,
|
|
287
|
+
'maker': maker,
|
|
288
|
+
'contractSize': undefined,
|
|
289
|
+
'expiry': undefined,
|
|
290
|
+
'expiryDatetime': undefined,
|
|
291
|
+
'strike': undefined,
|
|
292
|
+
'optionType': undefined,
|
|
293
|
+
'precision': {
|
|
294
|
+
'amount': basePrecision,
|
|
295
|
+
'price': this.safeNumber(entry, 'tickSize'),
|
|
296
|
+
},
|
|
297
|
+
'limits': {
|
|
298
|
+
'leverage': {
|
|
299
|
+
'min': undefined,
|
|
300
|
+
'max': undefined,
|
|
301
|
+
},
|
|
302
|
+
'amount': {
|
|
303
|
+
'min': basePrecision,
|
|
304
|
+
'max': undefined,
|
|
305
|
+
},
|
|
306
|
+
'price': {
|
|
307
|
+
'min': quotePrecision,
|
|
308
|
+
'max': undefined,
|
|
309
|
+
},
|
|
310
|
+
'cost': {
|
|
311
|
+
'min': minCost,
|
|
312
|
+
'max': undefined,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
'created': undefined,
|
|
316
|
+
'info': entry,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
async fetchTicker(symbol, params = {}) {
|
|
322
|
+
/**
|
|
323
|
+
* @method
|
|
324
|
+
* @name idex#fetchTicker
|
|
325
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
326
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
327
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
328
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
329
|
+
*/
|
|
330
|
+
await this.loadMarkets();
|
|
331
|
+
const market = this.market(symbol);
|
|
332
|
+
const request = {
|
|
333
|
+
'market': market['id'],
|
|
334
|
+
};
|
|
335
|
+
// [
|
|
336
|
+
// {
|
|
337
|
+
// "market": "DIL-ETH",
|
|
338
|
+
// "time": 1598367493008,
|
|
339
|
+
// "open": "0.09695361",
|
|
340
|
+
// "high": "0.10245881",
|
|
341
|
+
// "low": "0.09572507",
|
|
342
|
+
// "close": "0.09917079",
|
|
343
|
+
// "closeQuantity": "0.71320950",
|
|
344
|
+
// "baseVolume": "309.17380612",
|
|
345
|
+
// "quoteVolume": "30.57633981",
|
|
346
|
+
// "percentChange": "2.28",
|
|
347
|
+
// "numTrades": 205,
|
|
348
|
+
// "ask": "0.09910476",
|
|
349
|
+
// "bid": "0.09688340",
|
|
350
|
+
// "sequence": 3902
|
|
351
|
+
// }
|
|
352
|
+
// ]
|
|
353
|
+
const response = await this.publicGetTickers(this.extend(request, params));
|
|
354
|
+
const ticker = this.safeValue(response, 0);
|
|
355
|
+
return this.parseTicker(ticker, market);
|
|
356
|
+
}
|
|
357
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
358
|
+
/**
|
|
359
|
+
* @method
|
|
360
|
+
* @name idex#fetchTickers
|
|
361
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
362
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
363
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
364
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
365
|
+
*/
|
|
366
|
+
await this.loadMarkets();
|
|
367
|
+
// [
|
|
368
|
+
// {
|
|
369
|
+
// "market": "DIL-ETH",
|
|
370
|
+
// "time": 1598367493008,
|
|
371
|
+
// "open": "0.09695361",
|
|
372
|
+
// "high": "0.10245881",
|
|
373
|
+
// "low": "0.09572507",
|
|
374
|
+
// "close": "0.09917079",
|
|
375
|
+
// "closeQuantity": "0.71320950",
|
|
376
|
+
// "baseVolume": "309.17380612",
|
|
377
|
+
// "quoteVolume": "30.57633981",
|
|
378
|
+
// "percentChange": "2.28",
|
|
379
|
+
// "numTrades": 205,
|
|
380
|
+
// "ask": "0.09910476",
|
|
381
|
+
// "bid": "0.09688340",
|
|
382
|
+
// "sequence": 3902
|
|
383
|
+
// }, ...
|
|
384
|
+
// ]
|
|
385
|
+
const response = await this.publicGetTickers(params);
|
|
386
|
+
return this.parseTickers(response, symbols);
|
|
387
|
+
}
|
|
388
|
+
parseTicker(ticker, market = undefined) {
|
|
389
|
+
// {
|
|
390
|
+
// "market": "DIL-ETH",
|
|
391
|
+
// "time": 1598367493008,
|
|
392
|
+
// "open": "0.09695361",
|
|
393
|
+
// "high": "0.10245881",
|
|
394
|
+
// "low": "0.09572507",
|
|
395
|
+
// "close": "0.09917079",
|
|
396
|
+
// "closeQuantity": "0.71320950",
|
|
397
|
+
// "baseVolume": "309.17380612",
|
|
398
|
+
// "quoteVolume": "30.57633981",
|
|
399
|
+
// "percentChange": "2.28",
|
|
400
|
+
// "numTrades": 205,
|
|
401
|
+
// "ask": "0.09910476",
|
|
402
|
+
// "bid": "0.09688340",
|
|
403
|
+
// "sequence": 3902
|
|
404
|
+
// }
|
|
405
|
+
const marketId = this.safeString(ticker, 'market');
|
|
406
|
+
market = this.safeMarket(marketId, market, '-');
|
|
407
|
+
const symbol = market['symbol'];
|
|
408
|
+
const timestamp = this.safeInteger(ticker, 'time');
|
|
409
|
+
const close = this.safeString(ticker, 'close');
|
|
410
|
+
return this.safeTicker({
|
|
411
|
+
'symbol': symbol,
|
|
412
|
+
'timestamp': timestamp,
|
|
413
|
+
'datetime': this.iso8601(timestamp),
|
|
414
|
+
'high': this.safeString(ticker, 'high'),
|
|
415
|
+
'low': this.safeString(ticker, 'low'),
|
|
416
|
+
'bid': this.safeString(ticker, 'bid'),
|
|
417
|
+
'bidVolume': undefined,
|
|
418
|
+
'ask': this.safeString(ticker, 'ask'),
|
|
419
|
+
'askVolume': undefined,
|
|
420
|
+
'vwap': undefined,
|
|
421
|
+
'open': this.safeString(ticker, 'open'),
|
|
422
|
+
'close': close,
|
|
423
|
+
'last': close,
|
|
424
|
+
'previousClose': undefined,
|
|
425
|
+
'change': undefined,
|
|
426
|
+
'percentage': this.safeString(ticker, 'percentChange'),
|
|
427
|
+
'average': undefined,
|
|
428
|
+
'baseVolume': this.safeString(ticker, 'baseVolume'),
|
|
429
|
+
'quoteVolume': this.safeString(ticker, 'quoteVolume'),
|
|
430
|
+
'info': ticker,
|
|
431
|
+
}, market);
|
|
432
|
+
}
|
|
433
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
434
|
+
/**
|
|
435
|
+
* @method
|
|
436
|
+
* @name idex#fetchOHLCV
|
|
437
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
438
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
439
|
+
* @param {string} timeframe the length of time each candle represents
|
|
440
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
441
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
442
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
443
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
444
|
+
*/
|
|
445
|
+
await this.loadMarkets();
|
|
446
|
+
const market = this.market(symbol);
|
|
447
|
+
const request = {
|
|
448
|
+
'market': market['id'],
|
|
449
|
+
'interval': timeframe,
|
|
450
|
+
};
|
|
451
|
+
if (since !== undefined) {
|
|
452
|
+
request['start'] = since;
|
|
453
|
+
}
|
|
454
|
+
if (limit !== undefined) {
|
|
455
|
+
request['limit'] = limit;
|
|
456
|
+
}
|
|
457
|
+
const response = await this.publicGetCandles(this.extend(request, params));
|
|
458
|
+
if (Array.isArray(response)) {
|
|
459
|
+
// [
|
|
460
|
+
// {
|
|
461
|
+
// "start": 1598345580000,
|
|
462
|
+
// "open": "0.09771286",
|
|
463
|
+
// "high": "0.09771286",
|
|
464
|
+
// "low": "0.09771286",
|
|
465
|
+
// "close": "0.09771286",
|
|
466
|
+
// "volume": "1.45340410",
|
|
467
|
+
// "sequence": 3853
|
|
468
|
+
// }, ...
|
|
469
|
+
// ]
|
|
470
|
+
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
// {"nextTime":1595536440000}
|
|
474
|
+
return [];
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
478
|
+
// {
|
|
479
|
+
// "start": 1598345580000,
|
|
480
|
+
// "open": "0.09771286",
|
|
481
|
+
// "high": "0.09771286",
|
|
482
|
+
// "low": "0.09771286",
|
|
483
|
+
// "close": "0.09771286",
|
|
484
|
+
// "volume": "1.45340410",
|
|
485
|
+
// "sequence": 3853
|
|
486
|
+
// }
|
|
487
|
+
const timestamp = this.safeInteger(ohlcv, 'start');
|
|
488
|
+
const open = this.safeNumber(ohlcv, 'open');
|
|
489
|
+
const high = this.safeNumber(ohlcv, 'high');
|
|
490
|
+
const low = this.safeNumber(ohlcv, 'low');
|
|
491
|
+
const close = this.safeNumber(ohlcv, 'close');
|
|
492
|
+
const volume = this.safeNumber(ohlcv, 'volume');
|
|
493
|
+
return [timestamp, open, high, low, close, volume];
|
|
494
|
+
}
|
|
495
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
496
|
+
/**
|
|
497
|
+
* @method
|
|
498
|
+
* @name idex#fetchTrades
|
|
499
|
+
* @description get the list of most recent trades for a particular symbol
|
|
500
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
501
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
502
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
503
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
504
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
505
|
+
*/
|
|
506
|
+
await this.loadMarkets();
|
|
507
|
+
const market = this.market(symbol);
|
|
508
|
+
const request = {
|
|
509
|
+
'market': market['id'],
|
|
510
|
+
};
|
|
511
|
+
if (since !== undefined) {
|
|
512
|
+
request['start'] = since;
|
|
513
|
+
}
|
|
514
|
+
if (limit !== undefined) {
|
|
515
|
+
request['limit'] = Math.min(limit, 1000);
|
|
516
|
+
}
|
|
517
|
+
// [
|
|
518
|
+
// {
|
|
519
|
+
// "fillId": "b5467d00-b13e-3fa9-8216-dd66735550fc",
|
|
520
|
+
// "price": "0.09771286",
|
|
521
|
+
// "quantity": "1.45340410",
|
|
522
|
+
// "quoteQuantity": "0.14201627",
|
|
523
|
+
// "time": 1598345638994,
|
|
524
|
+
// "makerSide": "buy",
|
|
525
|
+
// "sequence": 3853
|
|
526
|
+
// }, ...
|
|
527
|
+
// ]
|
|
528
|
+
const response = await this.publicGetTrades(this.extend(request, params));
|
|
529
|
+
return this.parseTrades(response, market, since, limit);
|
|
530
|
+
}
|
|
531
|
+
parseTrade(trade, market = undefined) {
|
|
532
|
+
//
|
|
533
|
+
// public trades
|
|
534
|
+
// {
|
|
535
|
+
// "fillId":"a4883704-850b-3c4b-8588-020b5e4c62f1",
|
|
536
|
+
// "price":"0.20377008",
|
|
537
|
+
// "quantity":"47.58448728",
|
|
538
|
+
// "quoteQuantity":"9.69629509",
|
|
539
|
+
// "time":1642091300873,
|
|
540
|
+
// "makerSide":"buy",
|
|
541
|
+
// "type":"hybrid", // one of either: "orderBook", "hybrid", or "pool"
|
|
542
|
+
// "sequence":31876
|
|
543
|
+
// }
|
|
544
|
+
//
|
|
545
|
+
// private trades
|
|
546
|
+
// {
|
|
547
|
+
// "fillId":"83429066-9334-3582-b710-78858b2f0d6b",
|
|
548
|
+
// "price":"0.20717368",
|
|
549
|
+
// "quantity":"15.00000000",
|
|
550
|
+
// "quoteQuantity":"3.10760523",
|
|
551
|
+
// "orderBookQuantity":"0.00000003",
|
|
552
|
+
// "orderBookQuoteQuantity":"0.00000001",
|
|
553
|
+
// "poolQuantity":"14.99999997",
|
|
554
|
+
// "poolQuoteQuantity":"3.10760522",
|
|
555
|
+
// "time":1642083351215,
|
|
556
|
+
// "makerSide":"sell",
|
|
557
|
+
// "sequence":31795,
|
|
558
|
+
// "market":"IDEX-USDC",
|
|
559
|
+
// "orderId":"4fe993f0-747b-11ec-bd08-79d4a0b6e47c",
|
|
560
|
+
// "side":"buy",
|
|
561
|
+
// "fee":"0.03749989",
|
|
562
|
+
// "feeAsset":"IDEX",
|
|
563
|
+
// "gas":"0.40507261",
|
|
564
|
+
// "liquidity":"taker",
|
|
565
|
+
// "type":"hybrid",
|
|
566
|
+
// "txId":"0x69f6d82a762d12e3201efd0b3e9cc1969351e3c6ea3cf07c47c66bf24a459815",
|
|
567
|
+
// "txStatus":"mined"
|
|
568
|
+
// }
|
|
569
|
+
//
|
|
570
|
+
const id = this.safeString(trade, 'fillId');
|
|
571
|
+
const priceString = this.safeString(trade, 'price');
|
|
572
|
+
const amountString = this.safeString(trade, 'quantity');
|
|
573
|
+
const costString = this.safeString(trade, 'quoteQuantity');
|
|
574
|
+
const timestamp = this.safeInteger(trade, 'time');
|
|
575
|
+
const marketId = this.safeString(trade, 'market');
|
|
576
|
+
const symbol = this.safeSymbol(marketId, market, '-');
|
|
577
|
+
// this code handles the duality of public vs private trades
|
|
578
|
+
const makerSide = this.safeString(trade, 'makerSide');
|
|
579
|
+
const oppositeSide = (makerSide === 'buy') ? 'sell' : 'buy';
|
|
580
|
+
const side = this.safeString(trade, 'side', oppositeSide);
|
|
581
|
+
const takerOrMaker = this.safeString(trade, 'liquidity', 'taker');
|
|
582
|
+
const feeCostString = this.safeString(trade, 'fee');
|
|
583
|
+
let fee = undefined;
|
|
584
|
+
if (feeCostString !== undefined) {
|
|
585
|
+
const feeCurrencyId = this.safeString(trade, 'feeAsset');
|
|
586
|
+
fee = {
|
|
587
|
+
'cost': feeCostString,
|
|
588
|
+
'currency': this.safeCurrencyCode(feeCurrencyId),
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
const orderId = this.safeString(trade, 'orderId');
|
|
592
|
+
return this.safeTrade({
|
|
593
|
+
'info': trade,
|
|
594
|
+
'timestamp': timestamp,
|
|
595
|
+
'datetime': this.iso8601(timestamp),
|
|
596
|
+
'symbol': symbol,
|
|
597
|
+
'id': id,
|
|
598
|
+
'order': orderId,
|
|
599
|
+
'type': 'limit',
|
|
600
|
+
'side': side,
|
|
601
|
+
'takerOrMaker': takerOrMaker,
|
|
602
|
+
'price': priceString,
|
|
603
|
+
'amount': amountString,
|
|
604
|
+
'cost': costString,
|
|
605
|
+
'fee': fee,
|
|
606
|
+
}, market);
|
|
607
|
+
}
|
|
608
|
+
async fetchTradingFees(params = {}) {
|
|
609
|
+
/**
|
|
610
|
+
* @method
|
|
611
|
+
* @name idex#fetchTradingFees
|
|
612
|
+
* @description fetch the trading fees for multiple markets
|
|
613
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
614
|
+
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
615
|
+
*/
|
|
616
|
+
this.checkRequiredCredentials();
|
|
617
|
+
await this.loadMarkets();
|
|
618
|
+
const nonce = this.uuidv1();
|
|
619
|
+
const request = {
|
|
620
|
+
'nonce': nonce,
|
|
621
|
+
};
|
|
622
|
+
let response = undefined;
|
|
623
|
+
response = await this.privateGetUser(this.extend(request, params));
|
|
624
|
+
//
|
|
625
|
+
// {
|
|
626
|
+
// "depositEnabled": true,
|
|
627
|
+
// "orderEnabled": true,
|
|
628
|
+
// "cancelEnabled": true,
|
|
629
|
+
// "withdrawEnabled": true,
|
|
630
|
+
// "totalPortfolioValueUsd": "0.00",
|
|
631
|
+
// "makerFeeRate": "0.0000",
|
|
632
|
+
// "takerFeeRate": "0.0025",
|
|
633
|
+
// "takerIdexFeeRate": "0.0005",
|
|
634
|
+
// "takerLiquidityProviderFeeRate": "0.0020"
|
|
635
|
+
// }
|
|
636
|
+
//
|
|
637
|
+
const maker = this.safeNumber(response, 'makerFeeRate');
|
|
638
|
+
const taker = this.safeNumber(response, 'takerFeeRate');
|
|
639
|
+
const result = {};
|
|
640
|
+
for (let i = 0; i < this.symbols.length; i++) {
|
|
641
|
+
const symbol = this.symbols[i];
|
|
642
|
+
result[symbol] = {
|
|
643
|
+
'info': response,
|
|
644
|
+
'symbol': symbol,
|
|
645
|
+
'maker': maker,
|
|
646
|
+
'taker': taker,
|
|
647
|
+
'percentage': true,
|
|
648
|
+
'tierBased': false,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
return result;
|
|
652
|
+
}
|
|
653
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
654
|
+
/**
|
|
655
|
+
* @method
|
|
656
|
+
* @name idex#fetchOrderBook
|
|
657
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
658
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
659
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
660
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
661
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
662
|
+
*/
|
|
663
|
+
await this.loadMarkets();
|
|
664
|
+
const market = this.market(symbol);
|
|
665
|
+
const request = {
|
|
666
|
+
'market': market['id'],
|
|
667
|
+
'level': 2,
|
|
668
|
+
};
|
|
669
|
+
if (limit !== undefined) {
|
|
670
|
+
request['limit'] = limit;
|
|
671
|
+
}
|
|
672
|
+
// {
|
|
673
|
+
// "sequence": 36416753,
|
|
674
|
+
// "bids": [
|
|
675
|
+
// [ '0.09672815', "8.22284267", 1 ],
|
|
676
|
+
// [ '0.09672814', "1.83685554", 1 ],
|
|
677
|
+
// [ '0.09672143', "4.10962617", 1 ],
|
|
678
|
+
// [ '0.09658884', "4.03863759", 1 ],
|
|
679
|
+
// [ '0.09653781', "3.35730684", 1 ],
|
|
680
|
+
// [ '0.09624660', "2.54163586", 1 ],
|
|
681
|
+
// [ '0.09617490', "1.93065030", 1 ]
|
|
682
|
+
// ],
|
|
683
|
+
// "asks": [
|
|
684
|
+
// [ '0.09910476', "3.22840154", 1 ],
|
|
685
|
+
// [ '0.09940587', "3.39796593", 1 ],
|
|
686
|
+
// [ '0.09948189', "4.25088898", 1 ],
|
|
687
|
+
// [ '0.09958362', "2.42195784", 1 ],
|
|
688
|
+
// [ '0.09974393', "4.25234367", 1 ],
|
|
689
|
+
// [ '0.09995250', "3.40192141", 1 ]
|
|
690
|
+
// ]
|
|
691
|
+
// }
|
|
692
|
+
const response = await this.publicGetOrderbook(this.extend(request, params));
|
|
693
|
+
const nonce = this.safeInteger(response, 'sequence');
|
|
694
|
+
return {
|
|
695
|
+
'symbol': symbol,
|
|
696
|
+
'timestamp': undefined,
|
|
697
|
+
'datetime': undefined,
|
|
698
|
+
'nonce': nonce,
|
|
699
|
+
'bids': this.parseSide(response, 'bids'),
|
|
700
|
+
'asks': this.parseSide(response, 'asks'),
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
parseSide(book, side) {
|
|
704
|
+
const bookSide = this.safeValue(book, side, []);
|
|
705
|
+
const result = [];
|
|
706
|
+
for (let i = 0; i < bookSide.length; i++) {
|
|
707
|
+
const order = bookSide[i];
|
|
708
|
+
const price = this.safeNumber(order, 0);
|
|
709
|
+
const amount = this.safeNumber(order, 1);
|
|
710
|
+
const orderCount = this.safeInteger(order, 2);
|
|
711
|
+
result.push([price, amount, orderCount]);
|
|
712
|
+
}
|
|
713
|
+
const descending = side === 'bids';
|
|
714
|
+
return this.sortBy(result, 0, descending);
|
|
715
|
+
}
|
|
716
|
+
async fetchCurrencies(params = {}) {
|
|
717
|
+
/**
|
|
718
|
+
* @method
|
|
719
|
+
* @name idex#fetchCurrencies
|
|
720
|
+
* @description fetches all available currencies on an exchange
|
|
721
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
722
|
+
* @returns {object} an associative dictionary of currencies
|
|
723
|
+
*/
|
|
724
|
+
const response = await this.publicGetAssets(params);
|
|
725
|
+
//
|
|
726
|
+
// [
|
|
727
|
+
// {
|
|
728
|
+
// "name": "Ethereum",
|
|
729
|
+
// "symbol": "ETH",
|
|
730
|
+
// "contractAddress": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
|
|
731
|
+
// "assetDecimals": "18",
|
|
732
|
+
// "exchangeDecimals": "8",
|
|
733
|
+
// "maticPrice": "3029.38503483"
|
|
734
|
+
// },
|
|
735
|
+
// ]
|
|
736
|
+
//
|
|
737
|
+
const result = {};
|
|
738
|
+
for (let i = 0; i < response.length; i++) {
|
|
739
|
+
const entry = response[i];
|
|
740
|
+
const name = this.safeString(entry, 'name');
|
|
741
|
+
const currencyId = this.safeString(entry, 'symbol');
|
|
742
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
743
|
+
const precision = this.parseNumber(this.parsePrecision(this.safeString(entry, 'exchangeDecimals')));
|
|
744
|
+
result[code] = {
|
|
745
|
+
'id': currencyId,
|
|
746
|
+
'code': code,
|
|
747
|
+
'info': entry,
|
|
748
|
+
'type': undefined,
|
|
749
|
+
'name': name,
|
|
750
|
+
'active': undefined,
|
|
751
|
+
'deposit': undefined,
|
|
752
|
+
'withdraw': undefined,
|
|
753
|
+
'fee': undefined,
|
|
754
|
+
'precision': precision,
|
|
755
|
+
'limits': {
|
|
756
|
+
'amount': { 'min': precision, 'max': undefined },
|
|
757
|
+
'withdraw': { 'min': precision, 'max': undefined },
|
|
758
|
+
},
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
return result;
|
|
762
|
+
}
|
|
763
|
+
parseBalance(response) {
|
|
764
|
+
const result = {
|
|
765
|
+
'info': response,
|
|
766
|
+
'timestamp': undefined,
|
|
767
|
+
'datetime': undefined,
|
|
768
|
+
};
|
|
769
|
+
for (let i = 0; i < response.length; i++) {
|
|
770
|
+
const entry = response[i];
|
|
771
|
+
const currencyId = this.safeString(entry, 'asset');
|
|
772
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
773
|
+
const account = this.account();
|
|
774
|
+
account['total'] = this.safeString(entry, 'quantity');
|
|
775
|
+
account['free'] = this.safeString(entry, 'availableForTrade');
|
|
776
|
+
account['used'] = this.safeString(entry, 'locked');
|
|
777
|
+
result[code] = account;
|
|
778
|
+
}
|
|
779
|
+
return this.safeBalance(result);
|
|
780
|
+
}
|
|
781
|
+
async fetchBalance(params = {}) {
|
|
782
|
+
/**
|
|
783
|
+
* @method
|
|
784
|
+
* @name idex#fetchBalance
|
|
785
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
786
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
787
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
788
|
+
*/
|
|
789
|
+
this.checkRequiredCredentials();
|
|
790
|
+
await this.loadMarkets();
|
|
791
|
+
const nonce1 = this.uuidv1();
|
|
792
|
+
const request = {
|
|
793
|
+
'nonce': nonce1,
|
|
794
|
+
'wallet': this.walletAddress,
|
|
795
|
+
};
|
|
796
|
+
// [
|
|
797
|
+
// {
|
|
798
|
+
// "asset": "DIL",
|
|
799
|
+
// "quantity": "0.00000000",
|
|
800
|
+
// "availableForTrade": "0.00000000",
|
|
801
|
+
// "locked": "0.00000000",
|
|
802
|
+
// "usdValue": null
|
|
803
|
+
// }, ...
|
|
804
|
+
// ]
|
|
805
|
+
const extendedRequest = this.extend(request, params);
|
|
806
|
+
if (extendedRequest['wallet'] === undefined) {
|
|
807
|
+
throw new errors.BadRequest(this.id + ' fetchBalance() wallet is undefined, set this.walletAddress or "address" in params');
|
|
808
|
+
}
|
|
809
|
+
let response = undefined;
|
|
810
|
+
try {
|
|
811
|
+
response = await this.privateGetBalances(extendedRequest);
|
|
812
|
+
}
|
|
813
|
+
catch (e) {
|
|
814
|
+
if (e instanceof errors.InvalidAddress) {
|
|
815
|
+
const walletAddress = extendedRequest['wallet'];
|
|
816
|
+
await this.associateWallet(walletAddress);
|
|
817
|
+
response = await this.privateGetBalances(extendedRequest);
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
throw e;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return this.parseBalance(response);
|
|
824
|
+
}
|
|
825
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
826
|
+
/**
|
|
827
|
+
* @method
|
|
828
|
+
* @name idex#fetchMyTrades
|
|
829
|
+
* @description fetch all trades made by the user
|
|
830
|
+
* @param {string} symbol unified market symbol
|
|
831
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
832
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
833
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
834
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
835
|
+
*/
|
|
836
|
+
this.checkRequiredCredentials();
|
|
837
|
+
await this.loadMarkets();
|
|
838
|
+
let market = undefined;
|
|
839
|
+
const request = {
|
|
840
|
+
'nonce': this.uuidv1(),
|
|
841
|
+
'wallet': this.walletAddress,
|
|
842
|
+
};
|
|
843
|
+
if (symbol !== undefined) {
|
|
844
|
+
market = this.market(symbol);
|
|
845
|
+
request['market'] = market['id'];
|
|
846
|
+
}
|
|
847
|
+
if (since !== undefined) {
|
|
848
|
+
request['start'] = since;
|
|
849
|
+
}
|
|
850
|
+
if (limit !== undefined) {
|
|
851
|
+
request['limit'] = limit;
|
|
852
|
+
}
|
|
853
|
+
// [
|
|
854
|
+
// {
|
|
855
|
+
// "fillId": "48582d10-b9bb-3c4b-94d3-e67537cf2472",
|
|
856
|
+
// "price": "0.09905990",
|
|
857
|
+
// "quantity": "0.40000000",
|
|
858
|
+
// "quoteQuantity": "0.03962396",
|
|
859
|
+
// "time": 1598873478762,
|
|
860
|
+
// "makerSide": "sell",
|
|
861
|
+
// "sequence": 5053,
|
|
862
|
+
// "market": "DIL-ETH",
|
|
863
|
+
// "orderId": "7cdc8e90-eb7d-11ea-9e60-4118569f6e63",
|
|
864
|
+
// "side": "buy",
|
|
865
|
+
// "fee": "0.00080000",
|
|
866
|
+
// "feeAsset": "DIL",
|
|
867
|
+
// "gas": "0.00857497",
|
|
868
|
+
// "liquidity": "taker",
|
|
869
|
+
// "txId": "0xeaa02b112c0b8b61bc02fa1776a2b39d6c614e287c1af90df0a2e591da573e65",
|
|
870
|
+
// "txStatus": "mined"
|
|
871
|
+
// }
|
|
872
|
+
// ]
|
|
873
|
+
const extendedRequest = this.extend(request, params);
|
|
874
|
+
if (extendedRequest['wallet'] === undefined) {
|
|
875
|
+
throw new errors.BadRequest(this.id + ' fetchMyTrades() walletAddress is undefined, set this.walletAddress or "address" in params');
|
|
876
|
+
}
|
|
877
|
+
let response = undefined;
|
|
878
|
+
try {
|
|
879
|
+
response = await this.privateGetFills(extendedRequest);
|
|
880
|
+
}
|
|
881
|
+
catch (e) {
|
|
882
|
+
if (e instanceof errors.InvalidAddress) {
|
|
883
|
+
const walletAddress = extendedRequest['wallet'];
|
|
884
|
+
await this.associateWallet(walletAddress);
|
|
885
|
+
response = await this.privateGetFills(extendedRequest);
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
throw e;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
return this.parseTrades(response, market, since, limit);
|
|
892
|
+
}
|
|
893
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
894
|
+
/**
|
|
895
|
+
* @method
|
|
896
|
+
* @name idex#fetchOrder
|
|
897
|
+
* @description fetches information on an order made by the user
|
|
898
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
899
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
900
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
901
|
+
*/
|
|
902
|
+
const request = {
|
|
903
|
+
'orderId': id,
|
|
904
|
+
};
|
|
905
|
+
return await this.fetchOrdersHelper(symbol, undefined, undefined, this.extend(request, params));
|
|
906
|
+
}
|
|
907
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
908
|
+
/**
|
|
909
|
+
* @method
|
|
910
|
+
* @name idex#fetchOpenOrders
|
|
911
|
+
* @description fetch all unfilled currently open orders
|
|
912
|
+
* @param {string} symbol unified market symbol
|
|
913
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
914
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
915
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
916
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
917
|
+
*/
|
|
918
|
+
const request = {
|
|
919
|
+
'closed': false,
|
|
920
|
+
};
|
|
921
|
+
return await this.fetchOrdersHelper(symbol, since, limit, this.extend(request, params));
|
|
922
|
+
}
|
|
923
|
+
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
924
|
+
/**
|
|
925
|
+
* @method
|
|
926
|
+
* @name idex#fetchClosedOrders
|
|
927
|
+
* @description fetches information on multiple closed orders made by the user
|
|
928
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
929
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
930
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
931
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
932
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
933
|
+
*/
|
|
934
|
+
const request = {
|
|
935
|
+
'closed': true,
|
|
936
|
+
};
|
|
937
|
+
return await this.fetchOrdersHelper(symbol, since, limit, this.extend(request, params));
|
|
938
|
+
}
|
|
939
|
+
async fetchOrdersHelper(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
940
|
+
await this.loadMarkets();
|
|
941
|
+
const request = {
|
|
942
|
+
'nonce': this.uuidv1(),
|
|
943
|
+
'wallet': this.walletAddress,
|
|
944
|
+
};
|
|
945
|
+
let market = undefined;
|
|
946
|
+
if (symbol !== undefined) {
|
|
947
|
+
market = this.market(symbol);
|
|
948
|
+
request['market'] = market['id'];
|
|
949
|
+
}
|
|
950
|
+
if (since !== undefined) {
|
|
951
|
+
request['start'] = since;
|
|
952
|
+
}
|
|
953
|
+
if (limit !== undefined) {
|
|
954
|
+
request['limit'] = limit;
|
|
955
|
+
}
|
|
956
|
+
const response = await this.privateGetOrders(this.extend(request, params));
|
|
957
|
+
// fetchClosedOrders / fetchOpenOrders
|
|
958
|
+
// [
|
|
959
|
+
// {
|
|
960
|
+
// "market": "DIL-ETH",
|
|
961
|
+
// "orderId": "7cdc8e90-eb7d-11ea-9e60-4118569f6e63",
|
|
962
|
+
// "wallet": "0x0AB991497116f7F5532a4c2f4f7B1784488628e1",
|
|
963
|
+
// "time": 1598873478650,
|
|
964
|
+
// "status": "filled",
|
|
965
|
+
// "type": "limit",
|
|
966
|
+
// "side": "buy",
|
|
967
|
+
// "originalQuantity": "0.40000000",
|
|
968
|
+
// "executedQuantity": "0.40000000",
|
|
969
|
+
// "cumulativeQuoteQuantity": "0.03962396",
|
|
970
|
+
// "avgExecutionPrice": "0.09905990",
|
|
971
|
+
// "price": "1.00000000",
|
|
972
|
+
// "fills": [
|
|
973
|
+
// {
|
|
974
|
+
// "fillId": "48582d10-b9bb-3c4b-94d3-e67537cf2472",
|
|
975
|
+
// "price": "0.09905990",
|
|
976
|
+
// "quantity": "0.40000000",
|
|
977
|
+
// "quoteQuantity": "0.03962396",
|
|
978
|
+
// "time": 1598873478650,
|
|
979
|
+
// "makerSide": "sell",
|
|
980
|
+
// "sequence": 5053,
|
|
981
|
+
// "fee": "0.00080000",
|
|
982
|
+
// "feeAsset": "DIL",
|
|
983
|
+
// "gas": "0.00857497",
|
|
984
|
+
// "liquidity": "taker",
|
|
985
|
+
// "txId": "0xeaa02b112c0b8b61bc02fa1776a2b39d6c614e287c1af90df0a2e591da573e65",
|
|
986
|
+
// "txStatus": "mined"
|
|
987
|
+
// }
|
|
988
|
+
// ]
|
|
989
|
+
// }
|
|
990
|
+
// ]
|
|
991
|
+
// fetchOrder
|
|
992
|
+
// { market: "DIL-ETH",
|
|
993
|
+
// "orderId": "7cdc8e90-eb7d-11ea-9e60-4118569f6e63",
|
|
994
|
+
// "wallet": "0x0AB991497116f7F5532a4c2f4f7B1784488628e1",
|
|
995
|
+
// "time": 1598873478650,
|
|
996
|
+
// "status": "filled",
|
|
997
|
+
// "type": "limit",
|
|
998
|
+
// "side": "buy",
|
|
999
|
+
// "originalQuantity": "0.40000000",
|
|
1000
|
+
// "executedQuantity": "0.40000000",
|
|
1001
|
+
// "cumulativeQuoteQuantity": "0.03962396",
|
|
1002
|
+
// "avgExecutionPrice": "0.09905990",
|
|
1003
|
+
// "price": "1.00000000",
|
|
1004
|
+
// "fills":
|
|
1005
|
+
// [ { fillId: "48582d10-b9bb-3c4b-94d3-e67537cf2472",
|
|
1006
|
+
// "price": "0.09905990",
|
|
1007
|
+
// "quantity": "0.40000000",
|
|
1008
|
+
// "quoteQuantity": "0.03962396",
|
|
1009
|
+
// "time": 1598873478650,
|
|
1010
|
+
// "makerSide": "sell",
|
|
1011
|
+
// "sequence": 5053,
|
|
1012
|
+
// "fee": "0.00080000",
|
|
1013
|
+
// "feeAsset": "DIL",
|
|
1014
|
+
// "gas": "0.00857497",
|
|
1015
|
+
// "liquidity": "taker",
|
|
1016
|
+
// "txId": "0xeaa02b112c0b8b61bc02fa1776a2b39d6c614e287c1af90df0a2e591da573e65",
|
|
1017
|
+
// "txStatus": "mined" } ] }
|
|
1018
|
+
if (Array.isArray(response)) {
|
|
1019
|
+
return this.parseOrders(response, market, since, limit);
|
|
1020
|
+
}
|
|
1021
|
+
else {
|
|
1022
|
+
return this.parseOrder(response, market);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
parseOrderStatus(status) {
|
|
1026
|
+
// https://docs.idex.io/#order-states-amp-lifecycle
|
|
1027
|
+
const statuses = {
|
|
1028
|
+
'active': 'open',
|
|
1029
|
+
'partiallyFilled': 'open',
|
|
1030
|
+
'rejected': 'canceled',
|
|
1031
|
+
'filled': 'closed',
|
|
1032
|
+
};
|
|
1033
|
+
return this.safeString(statuses, status, status);
|
|
1034
|
+
}
|
|
1035
|
+
parseOrder(order, market = undefined) {
|
|
1036
|
+
//
|
|
1037
|
+
// {
|
|
1038
|
+
// "market": "DIL-ETH",
|
|
1039
|
+
// "orderId": "7cdc8e90-eb7d-11ea-9e60-4118569f6e63",
|
|
1040
|
+
// "wallet": "0x0AB991497116f7F5532a4c2f4f7B1784488628e1",
|
|
1041
|
+
// "time": 1598873478650,
|
|
1042
|
+
// "status": "filled",
|
|
1043
|
+
// "type": "limit",
|
|
1044
|
+
// "side": "buy",
|
|
1045
|
+
// "originalQuantity": "0.40000000",
|
|
1046
|
+
// "executedQuantity": "0.40000000",
|
|
1047
|
+
// "cumulativeQuoteQuantity": "0.03962396",
|
|
1048
|
+
// "avgExecutionPrice": "0.09905990",
|
|
1049
|
+
// "price": "1.00000000",
|
|
1050
|
+
// "fills": [
|
|
1051
|
+
// {
|
|
1052
|
+
// "fillId": "48582d10-b9bb-3c4b-94d3-e67537cf2472",
|
|
1053
|
+
// "price": "0.09905990",
|
|
1054
|
+
// "quantity": "0.40000000",
|
|
1055
|
+
// "quoteQuantity": "0.03962396",
|
|
1056
|
+
// "time": 1598873478650,
|
|
1057
|
+
// "makerSide": "sell",
|
|
1058
|
+
// "sequence": 5053,
|
|
1059
|
+
// "fee": "0.00080000",
|
|
1060
|
+
// "feeAsset": "DIL",
|
|
1061
|
+
// "gas": "0.00857497",
|
|
1062
|
+
// "liquidity": "taker",
|
|
1063
|
+
// "txId": "0xeaa02b112c0b8b61bc02fa1776a2b39d6c614e287c1af90df0a2e591da573e65",
|
|
1064
|
+
// "txStatus": "mined"
|
|
1065
|
+
// }
|
|
1066
|
+
// ]
|
|
1067
|
+
// }
|
|
1068
|
+
//
|
|
1069
|
+
const timestamp = this.safeInteger(order, 'time');
|
|
1070
|
+
const fills = this.safeValue(order, 'fills', []);
|
|
1071
|
+
const id = this.safeString(order, 'orderId');
|
|
1072
|
+
const clientOrderId = this.safeString(order, 'clientOrderId');
|
|
1073
|
+
const marketId = this.safeString(order, 'market');
|
|
1074
|
+
const side = this.safeString(order, 'side');
|
|
1075
|
+
const symbol = this.safeSymbol(marketId, market, '-');
|
|
1076
|
+
const type = this.safeString(order, 'type');
|
|
1077
|
+
const amount = this.safeString(order, 'originalQuantity');
|
|
1078
|
+
const filled = this.safeString(order, 'executedQuantity');
|
|
1079
|
+
const average = this.safeString(order, 'avgExecutionPrice');
|
|
1080
|
+
const price = this.safeString(order, 'price');
|
|
1081
|
+
const rawStatus = this.safeString(order, 'status');
|
|
1082
|
+
const timeInForce = this.safeStringUpper(order, 'timeInForce');
|
|
1083
|
+
const status = this.parseOrderStatus(rawStatus);
|
|
1084
|
+
return this.safeOrder({
|
|
1085
|
+
'info': order,
|
|
1086
|
+
'id': id,
|
|
1087
|
+
'clientOrderId': clientOrderId,
|
|
1088
|
+
'timestamp': timestamp,
|
|
1089
|
+
'datetime': this.iso8601(timestamp),
|
|
1090
|
+
'lastTradeTimestamp': undefined,
|
|
1091
|
+
'symbol': symbol,
|
|
1092
|
+
'type': type,
|
|
1093
|
+
'timeInForce': timeInForce,
|
|
1094
|
+
'postOnly': undefined,
|
|
1095
|
+
'side': side,
|
|
1096
|
+
'price': price,
|
|
1097
|
+
'stopPrice': undefined,
|
|
1098
|
+
'triggerPrice': undefined,
|
|
1099
|
+
'amount': amount,
|
|
1100
|
+
'cost': undefined,
|
|
1101
|
+
'average': average,
|
|
1102
|
+
'filled': filled,
|
|
1103
|
+
'remaining': undefined,
|
|
1104
|
+
'status': status,
|
|
1105
|
+
'fee': undefined,
|
|
1106
|
+
'trades': fills,
|
|
1107
|
+
}, market);
|
|
1108
|
+
}
|
|
1109
|
+
async associateWallet(walletAddress, params = {}) {
|
|
1110
|
+
const nonce = this.uuidv1();
|
|
1111
|
+
const noPrefix = this.remove0xPrefix(walletAddress);
|
|
1112
|
+
const byteArray = [
|
|
1113
|
+
this.base16ToBinary(nonce),
|
|
1114
|
+
this.base16ToBinary(noPrefix),
|
|
1115
|
+
];
|
|
1116
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
1117
|
+
const hash = this.hash(binary, sha3.keccak_256, 'hex');
|
|
1118
|
+
const signature = this.signMessageString(hash, this.privateKey);
|
|
1119
|
+
// {
|
|
1120
|
+
// "address": "0x0AB991497116f7F5532a4c2f4f7B1784488628e1",
|
|
1121
|
+
// "totalPortfolioValueUsd": "0.00",
|
|
1122
|
+
// "time": 1598468353626
|
|
1123
|
+
// }
|
|
1124
|
+
const request = {
|
|
1125
|
+
'parameters': {
|
|
1126
|
+
'nonce': nonce,
|
|
1127
|
+
'wallet': walletAddress,
|
|
1128
|
+
},
|
|
1129
|
+
'signature': signature,
|
|
1130
|
+
};
|
|
1131
|
+
const result = await this.privatePostWallets(request);
|
|
1132
|
+
return result;
|
|
1133
|
+
}
|
|
1134
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1135
|
+
/**
|
|
1136
|
+
* @method
|
|
1137
|
+
* @name idex#createOrder
|
|
1138
|
+
* @description create a trade order, https://docs.idex.io/#create-order
|
|
1139
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1140
|
+
* @param {string} type 'market' or 'limit'
|
|
1141
|
+
* @param {string} side 'buy' or 'sell'
|
|
1142
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
1143
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1144
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1145
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1146
|
+
*/
|
|
1147
|
+
this.checkRequiredCredentials();
|
|
1148
|
+
await this.loadMarkets();
|
|
1149
|
+
const market = this.market(symbol);
|
|
1150
|
+
const nonce = this.uuidv1();
|
|
1151
|
+
let typeEnum = undefined;
|
|
1152
|
+
const stopLossTypeEnums = {
|
|
1153
|
+
'stopLoss': 3,
|
|
1154
|
+
'stopLossLimit': 4,
|
|
1155
|
+
'takeProfit': 5,
|
|
1156
|
+
'takeProfitLimit': 6,
|
|
1157
|
+
};
|
|
1158
|
+
let stopPriceString = undefined;
|
|
1159
|
+
if ((type === 'stopLossLimit') || (type === 'takeProfitLimit') || ('stopPrice' in params)) {
|
|
1160
|
+
if (!('stopPrice' in params)) {
|
|
1161
|
+
throw new errors.BadRequest(this.id + ' createOrder() stopPrice is a required parameter for ' + type + 'orders');
|
|
1162
|
+
}
|
|
1163
|
+
stopPriceString = this.priceToPrecision(symbol, params['stopPrice']);
|
|
1164
|
+
}
|
|
1165
|
+
const limitTypeEnums = {
|
|
1166
|
+
'limit': 1,
|
|
1167
|
+
'limitMaker': 2,
|
|
1168
|
+
};
|
|
1169
|
+
let priceString = undefined;
|
|
1170
|
+
const typeLower = type.toLowerCase();
|
|
1171
|
+
const limitOrder = typeLower.indexOf('limit') >= 0;
|
|
1172
|
+
if (type in limitTypeEnums) {
|
|
1173
|
+
typeEnum = limitTypeEnums[type];
|
|
1174
|
+
priceString = this.priceToPrecision(symbol, price);
|
|
1175
|
+
}
|
|
1176
|
+
else if (type in stopLossTypeEnums) {
|
|
1177
|
+
typeEnum = stopLossTypeEnums[type];
|
|
1178
|
+
priceString = this.priceToPrecision(symbol, price);
|
|
1179
|
+
}
|
|
1180
|
+
else if (type === 'market') {
|
|
1181
|
+
typeEnum = 0;
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
throw new errors.BadRequest(this.id + ' ' + type + ' is not a valid order type');
|
|
1185
|
+
}
|
|
1186
|
+
let amountEnum = 0; // base quantity
|
|
1187
|
+
if ('quoteOrderQuantity' in params) {
|
|
1188
|
+
if (type !== 'market') {
|
|
1189
|
+
throw new errors.NotSupported(this.id + ' createOrder() quoteOrderQuantity is not supported for ' + type + ' orders, only supported for market orders');
|
|
1190
|
+
}
|
|
1191
|
+
amountEnum = 1;
|
|
1192
|
+
amount = this.safeNumber(params, 'quoteOrderQuantity');
|
|
1193
|
+
}
|
|
1194
|
+
const sideEnum = (side === 'buy') ? 0 : 1;
|
|
1195
|
+
const walletBytes = this.remove0xPrefix(this.walletAddress);
|
|
1196
|
+
const network = this.safeString(this.options, 'network', 'ETH');
|
|
1197
|
+
const orderVersion = this.getSupportedMapping(network, {
|
|
1198
|
+
'ETH': 1,
|
|
1199
|
+
'BSC': 2,
|
|
1200
|
+
'MATIC': 4,
|
|
1201
|
+
});
|
|
1202
|
+
const amountString = this.amountToPrecision(symbol, amount);
|
|
1203
|
+
// https://docs.idex.io/#time-in-force
|
|
1204
|
+
const timeInForceEnums = {
|
|
1205
|
+
'gtc': 0,
|
|
1206
|
+
'ioc': 2,
|
|
1207
|
+
'fok': 3,
|
|
1208
|
+
};
|
|
1209
|
+
const defaultTimeInForce = this.safeString(this.options, 'defaultTimeInForce', 'gtc');
|
|
1210
|
+
const timeInForce = this.safeString(params, 'timeInForce', defaultTimeInForce);
|
|
1211
|
+
let timeInForceEnum = undefined;
|
|
1212
|
+
if (timeInForce in timeInForceEnums) {
|
|
1213
|
+
timeInForceEnum = timeInForceEnums[timeInForce];
|
|
1214
|
+
}
|
|
1215
|
+
else {
|
|
1216
|
+
const allOptions = Object.keys(timeInForceEnums);
|
|
1217
|
+
const asString = allOptions.join(', ');
|
|
1218
|
+
throw new errors.BadRequest(this.id + ' ' + timeInForce + ' is not a valid timeInForce, please choose one of ' + asString);
|
|
1219
|
+
}
|
|
1220
|
+
// https://docs.idex.io/#self-trade-prevention
|
|
1221
|
+
const selfTradePreventionEnums = {
|
|
1222
|
+
'dc': 0,
|
|
1223
|
+
'co': 1,
|
|
1224
|
+
'cn': 2,
|
|
1225
|
+
'cb': 3,
|
|
1226
|
+
};
|
|
1227
|
+
const defaultSelfTradePrevention = this.safeString(this.options, 'defaultSelfTradePrevention', 'cn');
|
|
1228
|
+
const selfTradePrevention = this.safeString(params, 'selfTradePrevention', defaultSelfTradePrevention);
|
|
1229
|
+
let selfTradePreventionEnum = undefined;
|
|
1230
|
+
if (selfTradePrevention in selfTradePreventionEnums) {
|
|
1231
|
+
selfTradePreventionEnum = selfTradePreventionEnums[selfTradePrevention];
|
|
1232
|
+
}
|
|
1233
|
+
else {
|
|
1234
|
+
const allOptions = Object.keys(selfTradePreventionEnums);
|
|
1235
|
+
const asString = allOptions.join(', ');
|
|
1236
|
+
throw new errors.BadRequest(this.id + ' ' + selfTradePrevention + ' is not a valid selfTradePrevention, please choose one of ' + asString);
|
|
1237
|
+
}
|
|
1238
|
+
const byteArray = [
|
|
1239
|
+
this.numberToBE(orderVersion, 1),
|
|
1240
|
+
this.base16ToBinary(nonce),
|
|
1241
|
+
this.base16ToBinary(walletBytes),
|
|
1242
|
+
this.encode(market['id']),
|
|
1243
|
+
this.numberToBE(typeEnum, 1),
|
|
1244
|
+
this.numberToBE(sideEnum, 1),
|
|
1245
|
+
this.encode(amountString),
|
|
1246
|
+
this.numberToBE(amountEnum, 1),
|
|
1247
|
+
];
|
|
1248
|
+
if (limitOrder) {
|
|
1249
|
+
const encodedPrice = this.encode(priceString);
|
|
1250
|
+
byteArray.push(encodedPrice);
|
|
1251
|
+
}
|
|
1252
|
+
if (type in stopLossTypeEnums) {
|
|
1253
|
+
const encodedPrice = this.encode(stopPriceString || priceString);
|
|
1254
|
+
byteArray.push(encodedPrice);
|
|
1255
|
+
}
|
|
1256
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
1257
|
+
if (clientOrderId !== undefined) {
|
|
1258
|
+
byteArray.push(this.encode(clientOrderId));
|
|
1259
|
+
}
|
|
1260
|
+
const after = [
|
|
1261
|
+
this.numberToBE(timeInForceEnum, 1),
|
|
1262
|
+
this.numberToBE(selfTradePreventionEnum, 1),
|
|
1263
|
+
this.numberToBE(0, 8), // unused
|
|
1264
|
+
];
|
|
1265
|
+
const allBytes = this.arrayConcat(byteArray, after);
|
|
1266
|
+
const binary = this.binaryConcatArray(allBytes);
|
|
1267
|
+
const hash = this.hash(binary, sha3.keccak_256, 'hex');
|
|
1268
|
+
const signature = this.signMessageString(hash, this.privateKey);
|
|
1269
|
+
const request = {
|
|
1270
|
+
'parameters': {
|
|
1271
|
+
'nonce': nonce,
|
|
1272
|
+
'market': market['id'],
|
|
1273
|
+
'side': side,
|
|
1274
|
+
'type': type,
|
|
1275
|
+
'wallet': this.walletAddress,
|
|
1276
|
+
'selfTradePrevention': selfTradePrevention,
|
|
1277
|
+
},
|
|
1278
|
+
'signature': signature,
|
|
1279
|
+
};
|
|
1280
|
+
if (type !== 'market') {
|
|
1281
|
+
request['parameters']['timeInForce'] = timeInForce;
|
|
1282
|
+
}
|
|
1283
|
+
if (limitOrder) {
|
|
1284
|
+
request['parameters']['price'] = priceString;
|
|
1285
|
+
}
|
|
1286
|
+
if (type in stopLossTypeEnums) {
|
|
1287
|
+
request['parameters']['stopPrice'] = stopPriceString || priceString;
|
|
1288
|
+
}
|
|
1289
|
+
if (amountEnum === 0) {
|
|
1290
|
+
request['parameters']['quantity'] = amountString;
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
request['parameters']['quoteOrderQuantity'] = amountString;
|
|
1294
|
+
}
|
|
1295
|
+
if (clientOrderId !== undefined) {
|
|
1296
|
+
request['parameters']['clientOrderId'] = clientOrderId;
|
|
1297
|
+
}
|
|
1298
|
+
// {
|
|
1299
|
+
// "market": "DIL-ETH",
|
|
1300
|
+
// "orderId": "7cdc8e90-eb7d-11ea-9e60-4118569f6e63",
|
|
1301
|
+
// "wallet": "0x0AB991497116f7F5532a4c2f4f7B1784488628e1",
|
|
1302
|
+
// "time": 1598873478650,
|
|
1303
|
+
// "status": "filled",
|
|
1304
|
+
// "type": "limit",
|
|
1305
|
+
// "side": "buy",
|
|
1306
|
+
// "originalQuantity": "0.40000000",
|
|
1307
|
+
// "executedQuantity": "0.40000000",
|
|
1308
|
+
// "cumulativeQuoteQuantity": "0.03962396",
|
|
1309
|
+
// "price": "1.00000000",
|
|
1310
|
+
// "fills": [
|
|
1311
|
+
// {
|
|
1312
|
+
// "fillId": "48582d10-b9bb-3c4b-94d3-e67537cf2472",
|
|
1313
|
+
// "price": "0.09905990",
|
|
1314
|
+
// "quantity": "0.40000000",
|
|
1315
|
+
// "quoteQuantity": "0.03962396",
|
|
1316
|
+
// "time": 1598873478650,
|
|
1317
|
+
// "makerSide": "sell",
|
|
1318
|
+
// "sequence": 5053,
|
|
1319
|
+
// "fee": "0.00080000",
|
|
1320
|
+
// "feeAsset": "DIL",
|
|
1321
|
+
// "gas": "0.00857497",
|
|
1322
|
+
// "liquidity": "taker",
|
|
1323
|
+
// "txStatus": "pending"
|
|
1324
|
+
// }
|
|
1325
|
+
// ],
|
|
1326
|
+
// "avgExecutionPrice": "0.09905990"
|
|
1327
|
+
// }
|
|
1328
|
+
// we don't use extend here because it is a signed endpoint
|
|
1329
|
+
const response = await this.privatePostOrders(request);
|
|
1330
|
+
return this.parseOrder(response, market);
|
|
1331
|
+
}
|
|
1332
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
1333
|
+
/**
|
|
1334
|
+
* @method
|
|
1335
|
+
* @name idex#withdraw
|
|
1336
|
+
* @description make a withdrawal
|
|
1337
|
+
* @param {string} code unified currency code
|
|
1338
|
+
* @param {float} amount the amount to withdraw
|
|
1339
|
+
* @param {string} address the address to withdraw to
|
|
1340
|
+
* @param {string} tag
|
|
1341
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1342
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1343
|
+
*/
|
|
1344
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
1345
|
+
this.checkRequiredCredentials();
|
|
1346
|
+
await this.loadMarkets();
|
|
1347
|
+
const nonce = this.uuidv1();
|
|
1348
|
+
const amountString = this.currencyToPrecision(code, amount);
|
|
1349
|
+
const currency = this.currency(code);
|
|
1350
|
+
const walletBytes = this.remove0xPrefix(this.walletAddress);
|
|
1351
|
+
const byteArray = [
|
|
1352
|
+
this.base16ToBinary(nonce),
|
|
1353
|
+
this.base16ToBinary(walletBytes),
|
|
1354
|
+
this.encode(currency['id']),
|
|
1355
|
+
this.encode(amountString),
|
|
1356
|
+
this.numberToBE(1, 1), // bool set to true
|
|
1357
|
+
];
|
|
1358
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
1359
|
+
const hash = this.hash(binary, sha3.keccak_256, 'hex');
|
|
1360
|
+
const signature = this.signMessageString(hash, this.privateKey);
|
|
1361
|
+
const request = {
|
|
1362
|
+
'parameters': {
|
|
1363
|
+
'nonce': nonce,
|
|
1364
|
+
'wallet': address,
|
|
1365
|
+
'asset': currency['id'],
|
|
1366
|
+
'quantity': amountString,
|
|
1367
|
+
},
|
|
1368
|
+
'signature': signature,
|
|
1369
|
+
};
|
|
1370
|
+
const response = await this.privatePostWithdrawals(request);
|
|
1371
|
+
//
|
|
1372
|
+
// {
|
|
1373
|
+
// "withdrawalId": "a61dcff0-ec4d-11ea-8b83-c78a6ecb3180",
|
|
1374
|
+
// "asset": "ETH",
|
|
1375
|
+
// "assetContractAddress": "0x0000000000000000000000000000000000000000",
|
|
1376
|
+
// "quantity": "0.20000000",
|
|
1377
|
+
// "time": 1598962883190,
|
|
1378
|
+
// "fee": "0.00024000",
|
|
1379
|
+
// "txStatus": "pending",
|
|
1380
|
+
// "txId": null
|
|
1381
|
+
// }
|
|
1382
|
+
//
|
|
1383
|
+
return this.parseTransaction(response, currency);
|
|
1384
|
+
}
|
|
1385
|
+
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1386
|
+
/**
|
|
1387
|
+
* @method
|
|
1388
|
+
* @name idex#cancelAllOrders
|
|
1389
|
+
* @description cancel all open orders
|
|
1390
|
+
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
1391
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1392
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1393
|
+
*/
|
|
1394
|
+
this.checkRequiredCredentials();
|
|
1395
|
+
await this.loadMarkets();
|
|
1396
|
+
let market = undefined;
|
|
1397
|
+
if (symbol !== undefined) {
|
|
1398
|
+
market = this.market(symbol);
|
|
1399
|
+
}
|
|
1400
|
+
const nonce = this.uuidv1();
|
|
1401
|
+
const request = {
|
|
1402
|
+
'parameters': {
|
|
1403
|
+
'nonce': nonce,
|
|
1404
|
+
'wallet': this.walletAddress,
|
|
1405
|
+
},
|
|
1406
|
+
};
|
|
1407
|
+
const walletBytes = this.remove0xPrefix(this.walletAddress);
|
|
1408
|
+
const byteArray = [
|
|
1409
|
+
this.base16ToBinary(nonce),
|
|
1410
|
+
this.base16ToBinary(walletBytes),
|
|
1411
|
+
];
|
|
1412
|
+
if (market !== undefined) {
|
|
1413
|
+
byteArray.push(this.encode(market['id']));
|
|
1414
|
+
request['parameters']['market'] = market['id'];
|
|
1415
|
+
}
|
|
1416
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
1417
|
+
const hash = this.hash(binary, sha3.keccak_256, 'hex');
|
|
1418
|
+
const signature = this.signMessageString(hash, this.privateKey);
|
|
1419
|
+
request['signature'] = signature;
|
|
1420
|
+
// [ { orderId: "688336f0-ec50-11ea-9842-b332f8a34d0e" } ]
|
|
1421
|
+
const response = await this.privateDeleteOrders(this.extend(request, params));
|
|
1422
|
+
return this.parseOrders(response, market);
|
|
1423
|
+
}
|
|
1424
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1425
|
+
/**
|
|
1426
|
+
* @method
|
|
1427
|
+
* @name idex#cancelOrder
|
|
1428
|
+
* @description cancels an open order
|
|
1429
|
+
* @param {string} id order id
|
|
1430
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1431
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1432
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1433
|
+
*/
|
|
1434
|
+
this.checkRequiredCredentials();
|
|
1435
|
+
await this.loadMarkets();
|
|
1436
|
+
let market = undefined;
|
|
1437
|
+
if (symbol !== undefined) {
|
|
1438
|
+
market = this.market(symbol);
|
|
1439
|
+
}
|
|
1440
|
+
const nonce = this.uuidv1();
|
|
1441
|
+
const walletBytes = this.remove0xPrefix(this.walletAddress);
|
|
1442
|
+
const byteArray = [
|
|
1443
|
+
this.base16ToBinary(nonce),
|
|
1444
|
+
this.base16ToBinary(walletBytes),
|
|
1445
|
+
this.encode(id),
|
|
1446
|
+
];
|
|
1447
|
+
const binary = this.binaryConcatArray(byteArray);
|
|
1448
|
+
const hash = this.hash(binary, sha3.keccak_256, 'hex');
|
|
1449
|
+
const signature = this.signMessageString(hash, this.privateKey);
|
|
1450
|
+
const request = {
|
|
1451
|
+
'parameters': {
|
|
1452
|
+
'nonce': nonce,
|
|
1453
|
+
'wallet': this.walletAddress,
|
|
1454
|
+
'orderId': id,
|
|
1455
|
+
},
|
|
1456
|
+
'signature': signature,
|
|
1457
|
+
};
|
|
1458
|
+
// [ { orderId: "688336f0-ec50-11ea-9842-b332f8a34d0e" } ]
|
|
1459
|
+
const response = await this.privateDeleteOrders(this.extend(request, params));
|
|
1460
|
+
const canceledOrder = this.safeValue(response, 0);
|
|
1461
|
+
return this.parseOrder(canceledOrder, market);
|
|
1462
|
+
}
|
|
1463
|
+
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1464
|
+
const errorCode = this.safeString(response, 'code');
|
|
1465
|
+
const message = this.safeString(response, 'message');
|
|
1466
|
+
if (errorCode in this.exceptions) {
|
|
1467
|
+
const Exception = this.exceptions[errorCode];
|
|
1468
|
+
throw new Exception(this.id + ' ' + message);
|
|
1469
|
+
}
|
|
1470
|
+
if (errorCode !== undefined) {
|
|
1471
|
+
throw new errors.ExchangeError(this.id + ' ' + message);
|
|
1472
|
+
}
|
|
1473
|
+
return undefined;
|
|
1474
|
+
}
|
|
1475
|
+
async fetchDeposit(id, code = undefined, params = {}) {
|
|
1476
|
+
/**
|
|
1477
|
+
* @method
|
|
1478
|
+
* @name idex#fetchDeposit
|
|
1479
|
+
* @description fetch information on a deposit
|
|
1480
|
+
* @param {string} id deposit id
|
|
1481
|
+
* @param {string} code not used by idex fetchDeposit ()
|
|
1482
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1483
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1484
|
+
*/
|
|
1485
|
+
await this.loadMarkets();
|
|
1486
|
+
const nonce = this.uuidv1();
|
|
1487
|
+
const request = {
|
|
1488
|
+
'nonce': nonce,
|
|
1489
|
+
'wallet': this.walletAddress,
|
|
1490
|
+
'depositId': id,
|
|
1491
|
+
};
|
|
1492
|
+
const response = await this.privateGetDeposits(this.extend(request, params));
|
|
1493
|
+
return this.parseTransaction(response);
|
|
1494
|
+
}
|
|
1495
|
+
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1496
|
+
/**
|
|
1497
|
+
* @method
|
|
1498
|
+
* @name idex#fetchDeposits
|
|
1499
|
+
* @description fetch all deposits made to an account
|
|
1500
|
+
* @param {string} code unified currency code
|
|
1501
|
+
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
1502
|
+
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
1503
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1504
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1505
|
+
*/
|
|
1506
|
+
params = this.extend({
|
|
1507
|
+
'method': 'privateGetDeposits',
|
|
1508
|
+
}, params);
|
|
1509
|
+
return await this.fetchTransactionsHelper(code, since, limit, params);
|
|
1510
|
+
}
|
|
1511
|
+
async fetchTime(params = {}) {
|
|
1512
|
+
/**
|
|
1513
|
+
* @method
|
|
1514
|
+
* @name idex#fetchTime
|
|
1515
|
+
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
1516
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1517
|
+
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
1518
|
+
*/
|
|
1519
|
+
const response = await this.publicGetTime(params);
|
|
1520
|
+
//
|
|
1521
|
+
// { serverTime: "1655258263236" }
|
|
1522
|
+
//
|
|
1523
|
+
return this.safeInteger(response, 'serverTime');
|
|
1524
|
+
}
|
|
1525
|
+
async fetchWithdrawal(id, code = undefined, params = {}) {
|
|
1526
|
+
/**
|
|
1527
|
+
* @method
|
|
1528
|
+
* @name idex#fetchWithdrawal
|
|
1529
|
+
* @description fetch data on a currency withdrawal via the withdrawal id
|
|
1530
|
+
* @param {string} id withdrawal id
|
|
1531
|
+
* @param {string} code not used by idex.fetchWithdrawal
|
|
1532
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1533
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1534
|
+
*/
|
|
1535
|
+
await this.loadMarkets();
|
|
1536
|
+
const nonce = this.uuidv1();
|
|
1537
|
+
const request = {
|
|
1538
|
+
'nonce': nonce,
|
|
1539
|
+
'wallet': this.walletAddress,
|
|
1540
|
+
'withdrawalId': id,
|
|
1541
|
+
};
|
|
1542
|
+
const response = await this.privateGetWithdrawals(this.extend(request, params));
|
|
1543
|
+
return this.parseTransaction(response);
|
|
1544
|
+
}
|
|
1545
|
+
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1546
|
+
/**
|
|
1547
|
+
* @method
|
|
1548
|
+
* @name idex#fetchWithdrawals
|
|
1549
|
+
* @description fetch all withdrawals made from an account
|
|
1550
|
+
* @param {string} code unified currency code
|
|
1551
|
+
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
1552
|
+
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
1553
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1554
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1555
|
+
*/
|
|
1556
|
+
params = this.extend({
|
|
1557
|
+
'method': 'privateGetWithdrawals',
|
|
1558
|
+
}, params);
|
|
1559
|
+
return await this.fetchTransactionsHelper(code, since, limit, params);
|
|
1560
|
+
}
|
|
1561
|
+
async fetchTransactionsHelper(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1562
|
+
await this.loadMarkets();
|
|
1563
|
+
const nonce = this.uuidv1();
|
|
1564
|
+
const request = {
|
|
1565
|
+
'nonce': nonce,
|
|
1566
|
+
'wallet': this.walletAddress,
|
|
1567
|
+
};
|
|
1568
|
+
let currency = undefined;
|
|
1569
|
+
if (code !== undefined) {
|
|
1570
|
+
currency = this.currency(code);
|
|
1571
|
+
request['asset'] = currency['id'];
|
|
1572
|
+
}
|
|
1573
|
+
if (since !== undefined) {
|
|
1574
|
+
request['start'] = since;
|
|
1575
|
+
}
|
|
1576
|
+
if (limit !== undefined) {
|
|
1577
|
+
request['limit'] = limit;
|
|
1578
|
+
}
|
|
1579
|
+
// [
|
|
1580
|
+
// {
|
|
1581
|
+
// "depositId": "e9970cc0-eb6b-11ea-9e89-09a5ebc1f98e",
|
|
1582
|
+
// "asset": "ETH",
|
|
1583
|
+
// "quantity": "1.00000000",
|
|
1584
|
+
// "txId": "0xcd4aac3171d7131cc9e795568c67938675185ac17641553ef54c8a7c294c8142",
|
|
1585
|
+
// "txTime": 1598865853000,
|
|
1586
|
+
// "confirmationTime": 1598865930231
|
|
1587
|
+
// }
|
|
1588
|
+
// ]
|
|
1589
|
+
const method = params['method'];
|
|
1590
|
+
params = this.omit(params, 'method');
|
|
1591
|
+
let response = undefined;
|
|
1592
|
+
if (method === 'privateGetDeposits') {
|
|
1593
|
+
response = await this.privateGetDeposits(this.extend(request, params));
|
|
1594
|
+
}
|
|
1595
|
+
else if (method === 'privateGetWithdrawals') {
|
|
1596
|
+
response = await this.privateGetWithdrawals(this.extend(request, params));
|
|
1597
|
+
}
|
|
1598
|
+
else {
|
|
1599
|
+
throw new errors.NotSupported(this.id + ' fetchTransactionsHelper() not support this method');
|
|
1600
|
+
}
|
|
1601
|
+
return this.parseTransactions(response, currency, since, limit);
|
|
1602
|
+
}
|
|
1603
|
+
parseTransactionStatus(status) {
|
|
1604
|
+
const statuses = {
|
|
1605
|
+
'mined': 'ok',
|
|
1606
|
+
};
|
|
1607
|
+
return this.safeString(statuses, status, status);
|
|
1608
|
+
}
|
|
1609
|
+
parseTransaction(transaction, currency = undefined) {
|
|
1610
|
+
//
|
|
1611
|
+
// fetchDeposits
|
|
1612
|
+
//
|
|
1613
|
+
// {
|
|
1614
|
+
// "depositId": "e9970cc0-eb6b-11ea-9e89-09a5ebc1f98f",
|
|
1615
|
+
// "asset": "ETH",
|
|
1616
|
+
// "quantity": "1.00000000",
|
|
1617
|
+
// "txId": "0xcd4aac3171d7131cc9e795568c67938675185ac17641553ef54c8a7c294c8142",
|
|
1618
|
+
// "txTime": 1598865853000,
|
|
1619
|
+
// "confirmationTime": 1598865930231
|
|
1620
|
+
// }
|
|
1621
|
+
//
|
|
1622
|
+
// fetchWithdrwalas
|
|
1623
|
+
//
|
|
1624
|
+
// {
|
|
1625
|
+
// "withdrawalId": "a62d8760-ec4d-11ea-9fa6-47904c19499b",
|
|
1626
|
+
// "asset": "ETH",
|
|
1627
|
+
// "assetContractAddress": "0x0000000000000000000000000000000000000000",
|
|
1628
|
+
// "quantity": "0.20000000",
|
|
1629
|
+
// "time": 1598962883288,
|
|
1630
|
+
// "fee": "0.00024000",
|
|
1631
|
+
// "txId": "0x305e9cdbaa85ad029f50578d13d31d777c085de573ed5334d95c19116d8c03ce",
|
|
1632
|
+
// "txStatus": "mined"
|
|
1633
|
+
// }
|
|
1634
|
+
//
|
|
1635
|
+
// withdraw
|
|
1636
|
+
//
|
|
1637
|
+
// {
|
|
1638
|
+
// "withdrawalId": "a61dcff0-ec4d-11ea-8b83-c78a6ecb3180",
|
|
1639
|
+
// "asset": "ETH",
|
|
1640
|
+
// "assetContractAddress": "0x0000000000000000000000000000000000000000",
|
|
1641
|
+
// "quantity": "0.20000000",
|
|
1642
|
+
// "time": 1598962883190,
|
|
1643
|
+
// "fee": "0.00024000",
|
|
1644
|
+
// "txStatus": "pending",
|
|
1645
|
+
// "txId": null
|
|
1646
|
+
// }
|
|
1647
|
+
//
|
|
1648
|
+
let type = undefined;
|
|
1649
|
+
if ('depositId' in transaction) {
|
|
1650
|
+
type = 'deposit';
|
|
1651
|
+
}
|
|
1652
|
+
else if (('withdrawId' in transaction) || ('withdrawalId' in transaction)) {
|
|
1653
|
+
type = 'withdrawal';
|
|
1654
|
+
}
|
|
1655
|
+
let id = this.safeString2(transaction, 'depositId', 'withdrawId');
|
|
1656
|
+
id = this.safeString(transaction, 'withdrawalId', id);
|
|
1657
|
+
const code = this.safeCurrencyCode(this.safeString(transaction, 'asset'), currency);
|
|
1658
|
+
const amount = this.safeNumber(transaction, 'quantity');
|
|
1659
|
+
const txid = this.safeString(transaction, 'txId');
|
|
1660
|
+
const timestamp = this.safeInteger2(transaction, 'txTime', 'time');
|
|
1661
|
+
let fee = undefined;
|
|
1662
|
+
if ('fee' in transaction) {
|
|
1663
|
+
fee = {
|
|
1664
|
+
'cost': this.safeNumber(transaction, 'fee'),
|
|
1665
|
+
'currency': 'ETH',
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
const rawStatus = this.safeString(transaction, 'txStatus');
|
|
1669
|
+
const status = this.parseTransactionStatus(rawStatus);
|
|
1670
|
+
const updated = this.safeInteger(transaction, 'confirmationTime');
|
|
1671
|
+
return {
|
|
1672
|
+
'info': transaction,
|
|
1673
|
+
'id': id,
|
|
1674
|
+
'txid': txid,
|
|
1675
|
+
'timestamp': timestamp,
|
|
1676
|
+
'datetime': this.iso8601(timestamp),
|
|
1677
|
+
'network': undefined,
|
|
1678
|
+
'address': undefined,
|
|
1679
|
+
'addressTo': undefined,
|
|
1680
|
+
'addressFrom': undefined,
|
|
1681
|
+
'tag': undefined,
|
|
1682
|
+
'tagTo': undefined,
|
|
1683
|
+
'tagFrom': undefined,
|
|
1684
|
+
'type': type,
|
|
1685
|
+
'amount': amount,
|
|
1686
|
+
'currency': code,
|
|
1687
|
+
'status': status,
|
|
1688
|
+
'updated': updated,
|
|
1689
|
+
'comment': undefined,
|
|
1690
|
+
'internal': undefined,
|
|
1691
|
+
'fee': fee,
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
calculateRateLimiterCost(api, method, path, params, config = {}) {
|
|
1695
|
+
const hasApiKey = (this.apiKey !== undefined);
|
|
1696
|
+
const hasSecret = (this.secret !== undefined);
|
|
1697
|
+
const hasWalletAddress = (this.walletAddress !== undefined);
|
|
1698
|
+
const hasPrivateKey = (this.privateKey !== undefined);
|
|
1699
|
+
const defaultCost = this.safeValue(config, 'cost', 1);
|
|
1700
|
+
const authenticated = hasApiKey && hasSecret && hasWalletAddress && hasPrivateKey;
|
|
1701
|
+
return authenticated ? (defaultCost / 2) : defaultCost;
|
|
1702
|
+
}
|
|
1703
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1704
|
+
const network = this.safeString(this.options, 'network', 'ETH');
|
|
1705
|
+
const version = this.safeString(this.options, 'version', 'v1');
|
|
1706
|
+
let url = this.urls['api'][network] + '/' + version + '/' + path;
|
|
1707
|
+
const keys = Object.keys(params);
|
|
1708
|
+
const length = keys.length;
|
|
1709
|
+
let query = undefined;
|
|
1710
|
+
if (length > 0) {
|
|
1711
|
+
if (method === 'GET') {
|
|
1712
|
+
query = this.urlencode(params);
|
|
1713
|
+
url = url + '?' + query;
|
|
1714
|
+
}
|
|
1715
|
+
else {
|
|
1716
|
+
body = this.json(params);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
headers = {
|
|
1720
|
+
'Content-Type': 'application/json',
|
|
1721
|
+
};
|
|
1722
|
+
if (this.apiKey !== undefined) {
|
|
1723
|
+
headers['IDEX-API-Key'] = this.apiKey;
|
|
1724
|
+
}
|
|
1725
|
+
if (api === 'private') {
|
|
1726
|
+
let payload = undefined;
|
|
1727
|
+
if (method === 'GET') {
|
|
1728
|
+
payload = query;
|
|
1729
|
+
}
|
|
1730
|
+
else {
|
|
1731
|
+
payload = body;
|
|
1732
|
+
}
|
|
1733
|
+
headers['IDEX-HMAC-Signature'] = this.hmac(this.encode(payload), this.encode(this.secret), sha256.sha256, 'hex');
|
|
1734
|
+
}
|
|
1735
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1736
|
+
}
|
|
1737
|
+
remove0xPrefix(hexData) {
|
|
1738
|
+
if (hexData.slice(0, 2) === '0x') {
|
|
1739
|
+
return hexData.slice(2);
|
|
1740
|
+
}
|
|
1741
|
+
else {
|
|
1742
|
+
return hexData;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
hashMessage(message) {
|
|
1746
|
+
// takes a hex encoded message
|
|
1747
|
+
const binaryMessage = this.base16ToBinary(this.remove0xPrefix(message));
|
|
1748
|
+
const prefix = this.encode('\x19Ethereum Signed Message:\n' + binaryMessage.byteLength);
|
|
1749
|
+
return '0x' + this.hash(this.binaryConcat(prefix, binaryMessage), sha3.keccak_256, 'hex');
|
|
1750
|
+
}
|
|
1751
|
+
signHash(hash, privateKey) {
|
|
1752
|
+
const signature = crypto.ecdsa(hash.slice(-64), privateKey.slice(-64), secp256k1.secp256k1, undefined);
|
|
1753
|
+
return {
|
|
1754
|
+
'r': '0x' + signature['r'],
|
|
1755
|
+
's': '0x' + signature['s'],
|
|
1756
|
+
'v': 27 + signature['v'],
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
signMessage(message, privateKey) {
|
|
1760
|
+
return this.signHash(this.hashMessage(message), privateKey.slice(-64));
|
|
1761
|
+
}
|
|
1762
|
+
signMessageString(message, privateKey) {
|
|
1763
|
+
// still takes the input as a hex string
|
|
1764
|
+
// same as above but returns a string instead of an object
|
|
1765
|
+
const signature = this.signMessage(message, privateKey);
|
|
1766
|
+
return signature['r'] + this.remove0xPrefix(signature['s']) + this.binaryToBase16(this.numberToBE(signature['v'], 1));
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
module.exports = idex;
|