UNPKG

@jalmonter/ccxt

Version:

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges

1,128 lines (1,126 loc) 203 kB
'use strict'; var kucoin$1 = require('./abstract/kucoin.js'); var errors = require('./base/errors.js'); var Precise = require('./base/Precise.js'); var number = require('./base/functions/number.js'); var sha256 = require('./static_dependencies/noble-hashes/sha256.js'); // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- /** * @class kucoin * @augments Exchange */ class kucoin extends kucoin$1 { describe() { return this.deepExtend(super.describe(), { 'id': 'kucoin', 'name': 'KuCoin', 'countries': ['SC'], 'rateLimit': 10, 'version': 'v2', 'certified': true, 'pro': true, 'comment': 'Platform 2.0', 'quoteJsonNumbers': false, 'has': { 'CORS': undefined, 'spot': true, 'margin': true, 'swap': false, 'future': false, 'option': false, 'borrowCrossMargin': true, 'borrowIsolatedMargin': true, 'cancelAllOrders': true, 'cancelOrder': true, 'closeAllPositions': false, 'closePosition': false, 'createDepositAddress': true, 'createOrder': true, 'createOrders': true, 'createPostOnlyOrder': true, 'createStopLimitOrder': true, 'createStopMarketOrder': true, 'createStopOrder': true, 'editOrder': true, 'fetchAccounts': true, 'fetchBalance': true, 'fetchBorrowInterest': true, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, 'fetchClosedOrders': true, 'fetchCrossBorrowRate': false, 'fetchCrossBorrowRates': false, 'fetchCurrencies': true, 'fetchDepositAddress': true, 'fetchDepositAddressesByNetwork': true, 'fetchDeposits': true, 'fetchDepositWithdrawFee': true, 'fetchDepositWithdrawFees': true, 'fetchFundingHistory': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, 'fetchL3OrderBook': true, 'fetchLedger': true, 'fetchLeverageTiers': false, 'fetchMarginMode': false, 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, 'fetchMarkOHLCV': false, 'fetchMyTrades': true, 'fetchOHLCV': true, 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, 'fetchOpenOrders': true, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrderBooks': false, 'fetchOrdersByStatus': true, 'fetchOrderTrades': true, 'fetchPositionMode': false, 'fetchPremiumIndexOHLCV': false, 'fetchStatus': true, 'fetchTicker': true, 'fetchTickers': true, 'fetchTime': true, 'fetchTrades': true, 'fetchTradingFee': true, 'fetchTradingFees': false, 'fetchTransactionFee': true, 'fetchTransfers': false, 'fetchWithdrawals': true, 'repayCrossMargin': true, 'repayIsolatedMargin': true, 'setLeverage': false, 'setMarginMode': false, 'setPositionMode': false, 'signIn': false, 'transfer': true, 'withdraw': true, }, 'urls': { 'logo': 'https://user-images.githubusercontent.com/51840849/87295558-132aaf80-c50e-11ea-9801-a2fb0c57c799.jpg', 'referral': 'https://www.kucoin.com/ucenter/signup?rcode=E5wkqe', 'api': { 'public': 'https://api.kucoin.com', 'private': 'https://api.kucoin.com', 'futuresPrivate': 'https://api-futures.kucoin.com', 'futuresPublic': 'https://api-futures.kucoin.com', 'webExchange': 'https://kucoin.com/_api', }, 'www': 'https://www.kucoin.com', 'doc': [ 'https://docs.kucoin.com', ], }, 'requiredCredentials': { 'apiKey': true, 'secret': true, 'password': true, }, 'api': { // level VIP0 // Spot => 3000/30s => 100/s // Weight = x => 100/(100/x) = x // Futures Management Public => 2000/30s => 200/3/s // Weight = x => 100/(200/3/x) = x*1.5 'public': { 'get': { // spot trading 'currencies': 4.5, 'currencies/{currency}': 4.5, 'symbols': 6, 'market/orderbook/level1': 3, 'market/allTickers': 22.5, 'market/stats': 22.5, 'markets': 4.5, 'market/orderbook/level{level}_{limit}': 6, 'market/orderbook/level2_20': 3, 'market/orderbook/level2_100': 6, 'market/histories': 4.5, 'market/candles': 4.5, 'prices': 4.5, 'timestamp': 4.5, 'status': 4.5, // margin trading 'mark-price/{symbol}/current': 3, 'margin/config': 25, // 25SW }, 'post': { // ws 'bullet-public': 15, // 10PW }, }, 'private': { 'get': { // account 'user-info': 30, 'accounts': 7.5, 'accounts/{accountId}': 7.5, 'accounts/ledgers': 3, 'hf/accounts/ledgers': 2, 'hf/margin/account/ledgers': 2, 'transaction-history': 3, 'sub/user': 30, 'sub-accounts/{subUserId}': 22.5, 'sub-accounts': 30, 'sub/api-key': 30, // funding 'margin/account': 40, 'margin/accounts': 15, 'isolated/accounts': 15, 'deposit-addresses': 7.5, 'deposits': 7.5, 'hist-deposits': 7.5, 'withdrawals': 30, 'hist-withdrawals': 30, 'withdrawals/quotas': 30, 'accounts/transferable': 30, 'transfer-list': 30, 'base-fee': 3, 'trade-fees': 3, // spot trading 'market/orderbook/level{level}': 3, 'market/orderbook/level2': 3, 'market/orderbook/level3': 3, 'hf/orders/active': 2, 'hf/orders/active/symbols': 2, 'hf/orders/done': 2, 'hf/orders/{orderId}': 2, 'hf/orders/client-order/{clientOid}': 2, 'hf/orders/dead-cancel-all/query': 2, 'hf/fills': 2, 'orders': 2, 'limit/orders': 3, 'orders/{orderId}': 2, 'order/client-order/{clientOid}': 3, 'fills': 10, 'limit/fills': 20, 'stop-order': 8, 'stop-order/{orderId}': 3, 'stop-order/queryOrderByClientOid': 3, // margin trading 'hf/margin/orders/active': 4, 'hf/margin/orders/done': 10, 'hf/margin/orders/{orderId}': 4, 'hf/margin/orders/client-order/{clientOid}': 5, 'hf/margin/fills': 5, 'etf/info': 25, 'risk/limit/strategy': 20, 'isolated/symbols': 20, 'isolated/account/{symbol}': 50, 'margin/borrow': 15, 'margin/repay': 15, 'project/list': 10, 'project/marketInterestRate': 7.5, 'redeem/orders': 10, 'purchase/orders': 10, // 10SW }, 'post': { // account 'sub/user/created': 22.5, 'sub/api-key': 30, 'sub/api-key/update': 45, // funding 'deposit-addresses': 30, 'withdrawals': 7.5, 'accounts/universal-transfer': 6, 'accounts/sub-transfer': 45, 'accounts/inner-transfer': 15, 'transfer-out': 30, 'transfer-in': 30, // spot trading 'hf/orders': 1, 'hf/orders/test': 1, 'hf/orders/sync': 1, 'hf/orders/multi': 1, 'hf/orders/multi/sync': 1, 'hf/orders/alter': 3, 'hf/orders/dead-cancel-all': 2, 'orders': 2, 'orders/test': 2, 'orders/multi': 3, 'stop-order': 2, // margin trading 'hf/margin/order': 5, 'hf/margin/order/test': 5, 'margin/order': 5, 'margin/order/test': 5, 'margin/borrow': 15, 'margin/repay': 10, 'purchase': 15, 'redeem': 15, 'lend/purchase/update': 10, // ws 'bullet-private': 10, // 10SW }, 'delete': { // account 'sub/api-key': 45, // funding 'withdrawals/{withdrawalId}': 30, // spot trading 'hf/orders/{orderId}': 1, 'hf/orders/sync/{orderId}': 1, 'hf/orders/client-order/{clientOid}': 1, 'hf/orders/sync/client-order/{clientOid}': 1, 'hf/orders/cancel/{orderId}': 2, 'hf/orders': 2, 'orders/{orderId}': 3, 'order/client-order/{clientOid}': 5, 'orders': 20, 'stop-order/{orderId}': 3, 'stop-order/cancelOrderByClientOid': 5, 'stop-order/cancel': 3, // margin trading 'hf/margin/orders/{orderId}': 5, 'hf/margin/orders/client-order/{clientOid}': 5, 'hf/margin/orders': 10, // 10SW }, }, 'futuresPublic': { 'get': { 'contracts/active': 4.5, 'contracts/{symbol}': 4.5, 'ticker': 3, 'level2/snapshot': 4.5, 'level2/depth20': 7.5, 'level2/depth100': 15, 'trade/history': 7.5, 'kline/query': 4.5, 'interest/query': 7.5, 'index/query': 3, 'mark-price/{symbol}/current': 4.5, 'premium/query': 4.5, 'funding-rate/{symbol}/current': 3, 'timestamp': 3, 'status': 6, // ? 'level2/message/query': 1.3953, }, 'post': { // ws 'bullet-public': 15, // 10PW }, }, 'futuresPrivate': { 'get': { // account 'transaction-history': 3, // funding 'account-overview': 7.5, 'account-overview-all': 9, 'transfer-list': 30, // futures 'orders': 3, 'stopOrders': 9, 'recentDoneOrders': 7.5, 'orders/{orderId}': 7.5, 'orders/byClientOid': 7.5, 'fills': 7.5, 'recentFills': 4.5, 'openOrderStatistics': 15, 'position': 3, 'positions': 3, 'contracts/risk-limit/{symbol}': 7.5, 'funding-history': 7.5, // 5FW }, 'post': { // funding 'transfer-out': 30, 'transfer-in': 30, // futures 'orders': 3, 'orders/test': 3, 'position/margin/auto-deposit-status': 6, 'position/margin/deposit-margin': 6, 'position/risk-limit-level/change': 6, // ws 'bullet-private': 15, // 10FW }, 'delete': { 'orders/{orderId}': 1.5, 'orders': 45, 'stopOrders': 22.5, // 15FW }, }, 'webExchange': { 'get': { 'currency/currency/chain-info': 1, // this is temporary from webApi }, }, }, 'timeframes': { '1m': '1min', '3m': '3min', '5m': '5min', '15m': '15min', '30m': '30min', '1h': '1hour', '2h': '2hour', '4h': '4hour', '6h': '6hour', '8h': '8hour', '12h': '12hour', '1d': '1day', '1w': '1week', }, 'precisionMode': number.TICK_SIZE, 'exceptions': { 'exact': { 'order not exist': errors.OrderNotFound, 'order not exist.': errors.OrderNotFound, 'order_not_exist': errors.OrderNotFound, 'order_not_exist_or_not_allow_to_cancel': errors.InvalidOrder, 'Order size below the minimum requirement.': errors.InvalidOrder, 'The withdrawal amount is below the minimum requirement.': errors.ExchangeError, 'Unsuccessful! Exceeded the max. funds out-transfer limit': errors.InsufficientFunds, '400': errors.BadRequest, '401': errors.AuthenticationError, '403': errors.NotSupported, '404': errors.NotSupported, '405': errors.NotSupported, '415': errors.NotSupported, '429': errors.RateLimitExceeded, '500': errors.ExchangeNotAvailable, '503': errors.ExchangeNotAvailable, '101030': errors.PermissionDenied, '103000': errors.InvalidOrder, '130101': errors.BadRequest, '130102': errors.ExchangeError, '130103': errors.OrderNotFound, '130104': errors.ExchangeError, '130105': errors.InsufficientFunds, '130106': errors.NotSupported, '130107': errors.ExchangeError, '130108': errors.OrderNotFound, '130201': errors.PermissionDenied, '130202': errors.ExchangeError, '130203': errors.InsufficientFunds, '130204': errors.BadRequest, '200004': errors.InsufficientFunds, '210014': errors.InvalidOrder, '210021': errors.InsufficientFunds, '230003': errors.InsufficientFunds, '260000': errors.InvalidAddress, '260100': errors.InsufficientFunds, '300000': errors.InvalidOrder, '400000': errors.BadSymbol, '400001': errors.AuthenticationError, '400002': errors.InvalidNonce, '400003': errors.AuthenticationError, '400004': errors.AuthenticationError, '400005': errors.AuthenticationError, '400006': errors.AuthenticationError, '400007': errors.AuthenticationError, '400008': errors.NotSupported, '400100': errors.BadRequest, '400200': errors.InvalidOrder, '400350': errors.InvalidOrder, '400370': errors.InvalidOrder, '400400': errors.BadRequest, '400500': errors.InvalidOrder, '400600': errors.BadSymbol, '400760': errors.InvalidOrder, '401000': errors.BadRequest, '411100': errors.AccountSuspended, '415000': errors.BadRequest, '400303': errors.PermissionDenied, '500000': errors.ExchangeNotAvailable, '260220': errors.InvalidAddress, '900014': errors.BadRequest, // {"code":"900014","msg":"Invalid chainId"} }, 'broad': { 'Exceeded the access frequency': errors.RateLimitExceeded, 'require more permission': errors.PermissionDenied, }, }, 'fees': { 'trading': { 'tierBased': true, 'percentage': true, 'taker': this.parseNumber('0.001'), 'maker': this.parseNumber('0.001'), 'tiers': { 'taker': [ [this.parseNumber('0'), this.parseNumber('0.001')], [this.parseNumber('50'), this.parseNumber('0.001')], [this.parseNumber('200'), this.parseNumber('0.0009')], [this.parseNumber('500'), this.parseNumber('0.0008')], [this.parseNumber('1000'), this.parseNumber('0.0007')], [this.parseNumber('2000'), this.parseNumber('0.0007')], [this.parseNumber('4000'), this.parseNumber('0.0006')], [this.parseNumber('8000'), this.parseNumber('0.0005')], [this.parseNumber('15000'), this.parseNumber('0.00045')], [this.parseNumber('25000'), this.parseNumber('0.0004')], [this.parseNumber('40000'), this.parseNumber('0.00035')], [this.parseNumber('60000'), this.parseNumber('0.0003')], [this.parseNumber('80000'), this.parseNumber('0.00025')], ], 'maker': [ [this.parseNumber('0'), this.parseNumber('0.001')], [this.parseNumber('50'), this.parseNumber('0.0009')], [this.parseNumber('200'), this.parseNumber('0.0007')], [this.parseNumber('500'), this.parseNumber('0.0005')], [this.parseNumber('1000'), this.parseNumber('0.0003')], [this.parseNumber('2000'), this.parseNumber('0')], [this.parseNumber('4000'), this.parseNumber('0')], [this.parseNumber('8000'), this.parseNumber('0')], [this.parseNumber('15000'), this.parseNumber('-0.00005')], [this.parseNumber('25000'), this.parseNumber('-0.00005')], [this.parseNumber('40000'), this.parseNumber('-0.00005')], [this.parseNumber('60000'), this.parseNumber('-0.00005')], [this.parseNumber('80000'), this.parseNumber('-0.00005')], ], }, }, 'funding': { 'tierBased': false, 'percentage': false, 'withdraw': {}, 'deposit': {}, }, }, 'commonCurrencies': { 'BIFI': 'BIFIF', 'VAI': 'VAIOT', }, 'options': { 'version': 'v1', 'symbolSeparator': '-', 'fetchMyTradesMethod': 'private_get_fills', 'fetchCurrencies': { 'webApiEnable': true, 'webApiRetries': 1, 'webApiMuteFailure': true, }, 'fetchMarkets': { 'fetchTickersFees': true, }, 'withdraw': { 'includeFee': false, }, // endpoint versions 'versions': { 'public': { 'GET': { // spot trading 'currencies': 'v3', 'currencies/{currency}': 'v3', 'symbols': 'v2', }, }, 'private': { 'GET': { // account 'user-info': 'v2', 'hf/margin/account/ledgers': 'v3', 'sub/user': 'v2', 'sub-accounts': 'v2', // funding 'margin/accounts': 'v3', 'isolated/accounts': 'v3', // 'deposit-addresses': 'v2', 'deposit-addresses': 'v1', // spot trading 'market/orderbook/level2': 'v3', 'market/orderbook/level3': 'v3', 'market/orderbook/level{level}': 'v3', // margin trading 'hf/margin/orders/active': 'v3', 'hf/margin/orders/done': 'v3', 'hf/margin/orders/{orderId}': 'v3', 'hf/margin/orders/client-order/{clientOid}': 'v3', 'hf/margin/fills': 'v3', 'etf/info': 'v3', 'margin/borrow': 'v3', 'margin/repay': 'v3', 'project/list': 'v3', 'project/marketInterestRate': 'v3', 'redeem/orders': 'v3', 'purchase/orders': 'v3', }, 'POST': { // account 'sub/user/created': 'v2', // funding 'accounts/universal-transfer': 'v3', 'accounts/sub-transfer': 'v2', 'accounts/inner-transfer': 'v2', 'transfer-out': 'v3', // spot trading // margin trading 'hf/margin/order': 'v3', 'hf/margin/order/test': 'v3', 'margin/borrow': 'v3', 'margin/repay': 'v3', 'purchase': 'v3', 'redeem': 'v3', 'lend/purchase/update': 'v3', }, 'DELETE': { // account // funding // spot trading 'hf/margin/orders/{orderId}': 'v3', 'hf/margin/orders/client-order/{clientOid}': 'v3', 'hf/margin/orders': 'v3', // margin trading }, }, 'futuresPrivate': { 'POST': { 'transfer-out': 'v3', }, }, }, 'partner': { // the support for spot and future exchanges as separate settings 'spot': { 'id': 'ccxt', 'key': '9e58cc35-5b5e-4133-92ec-166e3f077cb8', }, 'future': { 'id': 'ccxtfutures', 'key': '1b327198-f30c-4f14-a0ac-918871282f15', }, // exchange-wide settings are also supported // 'id': 'ccxt' // 'key': '9e58cc35-5b5e-4133-92ec-166e3f077cb8', }, 'accountsByType': { 'spot': 'trade', 'margin': 'margin', 'cross': 'margin', 'isolated': 'isolated', 'main': 'main', 'funding': 'main', 'future': 'contract', 'swap': 'contract', 'mining': 'pool', 'hf': 'trade_hf', }, 'networks': { 'BTC': 'btc', 'BTCNATIVESEGWIT': 'bech32', 'ERC20': 'eth', 'TRC20': 'trx', 'HRC20': 'heco', 'MATIC': 'matic', 'KCC': 'kcc', 'SOL': 'sol', 'ALGO': 'algo', 'EOS': 'eos', 'BEP20': 'bsc', 'BEP2': 'bnb', 'ARBONE': 'arbitrum', 'AVAXX': 'avax', 'AVAXC': 'avaxc', 'TLOS': 'tlos', 'CFX': 'cfx', 'ACA': 'aca', 'OPTIMISM': 'optimism', 'ONT': 'ont', 'GLMR': 'glmr', 'CSPR': 'cspr', 'KLAY': 'klay', 'XRD': 'xrd', 'RVN': 'rvn', 'NEAR': 'near', 'APT': 'aptos', 'ETHW': 'ethw', 'TON': 'ton', 'BCH': 'bch', 'BSV': 'bchsv', 'BCHA': 'bchabc', 'OSMO': 'osmo', 'NANO': 'nano', 'XLM': 'xlm', 'VET': 'vet', 'IOST': 'iost', 'ZIL': 'zil', 'XRP': 'xrp', 'TOMO': 'tomo', 'XMR': 'xmr', 'COTI': 'coti', 'XTZ': 'xtz', 'ADA': 'ada', 'WAX': 'waxp', 'THETA': 'theta', 'ONE': 'one', 'IOTEX': 'iotx', 'NULS': 'nuls', 'KSM': 'ksm', 'LTC': 'ltc', 'WAVES': 'waves', 'DOT': 'dot', 'STEEM': 'steem', 'QTUM': 'qtum', 'DOGE': 'doge', 'FIL': 'fil', 'XYM': 'xym', 'FLUX': 'flux', 'ATOM': 'atom', 'XDC': 'xdc', 'KDA': 'kda', 'ICP': 'icp', 'CELO': 'celo', 'LSK': 'lsk', 'VSYS': 'vsys', 'KAR': 'kar', 'XCH': 'xch', 'FLOW': 'flow', 'BAND': 'band', 'EGLD': 'egld', 'HBAR': 'hbar', 'XPR': 'xpr', 'AR': 'ar', 'FTM': 'ftm', 'KAVA': 'kava', 'KMA': 'kma', 'XEC': 'xec', 'IOTA': 'iota', 'HNT': 'hnt', 'ASTR': 'astr', 'PDEX': 'pdex', 'METIS': 'metis', 'ZEC': 'zec', 'POKT': 'pokt', 'OASYS': 'oas', 'OASIS': 'oasis', 'ETC': 'etc', 'AKT': 'akt', 'FSN': 'fsn', 'SCRT': 'scrt', 'CFG': 'cfg', 'ICX': 'icx', 'KMD': 'kmd', 'NEM': 'NEM', 'STX': 'stx', 'DGB': 'dgb', 'DCR': 'dcr', 'CKB': 'ckb', 'ELA': 'ela', 'HYDRA': 'hydra', 'BTM': 'btm', 'KARDIA': 'kai', 'SXP': 'sxp', 'NEBL': 'nebl', 'ZEN': 'zen', 'SDN': 'sdn', 'LTO': 'lto', 'WEMIX': 'wemix', // 'BOBA': 'boba', // tbd 'EVER': 'ever', 'BNC': 'bnc', 'BNCDOT': 'bncdot', // 'CMP': 'cmp', // todo: after consensus 'AION': 'aion', 'GRIN': 'grin', 'LOKI': 'loki', 'QKC': 'qkc', 'TT': 'TT', 'PIVX': 'pivx', 'SERO': 'sero', 'METER': 'meter', 'STATEMINE': 'statemine', 'DVPN': 'dvpn', 'XPRT': 'xprt', 'MOVR': 'movr', 'ERGO': 'ergo', 'ABBC': 'abbc', 'DIVI': 'divi', 'PURA': 'pura', 'DFI': 'dfi', // 'NEO': 'neo', // tbd neo legacy 'NEON3': 'neon3', 'DOCK': 'dock', 'TRUE': 'true', 'CS': 'cs', 'ORAI': 'orai', // below will be uncommented after consensus // 'BITCOINDIAMON': 'bcd', // 'BITCOINGOLD': 'btg', // 'HTR': 'htr', // 'DEROHE': 'derohe', // 'NDAU': 'ndau', // 'HPB': 'hpb', // 'AXE': 'axe', // 'BITCOINPRIVATE': 'btcp', // 'EDGEWARE': 'edg', // 'JUPITER': 'jup', // 'VELAS': 'vlx', // vlxevm is different // // 'terra' luna lunc TBD // 'DIGITALBITS': 'xdb', // // fra is fra-emv on kucoin // 'PASTEL': 'psl', // // sysevm // 'CONCORDIUM': 'ccd', // 'AURORA': 'aurora', // 'PHA': 'pha', // a.k.a. khala // 'PAL': 'pal', // 'RSK': 'rbtc', // 'NIX': 'nix', // 'NIM': 'nim', // 'NRG': 'nrg', // 'RFOX': 'rfox', // 'PIONEER': 'neer', // 'PIXIE': 'pix', // 'ALEPHZERO': 'azero', // 'ACHAIN': 'act', // actevm is different // 'BOSCOIN': 'bos', // 'ELECTRONEUM': 'etn', // 'GOCHAIN': 'go', // 'SOPHIATX': 'sphtx', // 'WANCHAIN': 'wan', // 'ZEEPIN': 'zpt', // 'MATRIXAI': 'man', // 'METADIUM': 'meta', // 'METAHASH': 'mhc', // // eosc --"eosforce" tbd // 'IOTCHAIN': 'itc', // 'CONTENTOS': 'cos', // 'CPCHAIN': 'cpc', // 'INTCHAIN': 'int', // // 'DASH': 'dash', tbd digita-cash // 'WALTONCHAIN': 'wtc', // 'CONSTELLATION': 'dag', // 'ONELEDGER': 'olt', // 'AIRDAO': 'amb', // a.k.a. AMBROSUS // 'ENERGYWEB': 'ewt', // 'WAVESENTERPRISE': 'west', // 'HYPERCASH': 'hc', // 'ENECUUM': 'enq', // 'HAVEN': 'xhv', // 'CHAINX': 'pcx', // // 'FLUXOLD': 'zel', // zel seems old chain (with uppercase FLUX in kucoin UI and with id 'zel') // 'BUMO': 'bu', // 'DEEPONION': 'onion', // 'ULORD': 'ut', // 'ASCH': 'xas', // 'SOLARIS': 'xlr', // 'APOLLO': 'apl', // 'PIRATECHAIN': 'arrr', // 'ULTRA': 'uos', // 'EMONEY': 'ngm', // 'AURORACHAIN': 'aoa', // 'KLEVER': 'klv', // undetermined: xns(insolar), rhoc, luk (luniverse), kts (klimatas), bchn (bitcoin cash node), god (shallow entry), lit (litmus), }, 'marginModes': { 'cross': 'MARGIN_TRADE', 'isolated': 'MARGIN_ISOLATED_TRADE', 'spot': 'TRADE', }, }, }); } nonce() { return this.milliseconds(); } async fetchTime(params = {}) { /** * @method * @name kucoin#fetchTime * @description fetches the current integer timestamp in milliseconds from the exchange server * @see https://docs.kucoin.com/#server-time * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {int} the current integer timestamp in milliseconds from the exchange server */ const response = await this.publicGetTimestamp(params); // // { // "code":"200000", // "msg":"success", // "data":1546837113087 // } // return this.safeInteger(response, 'data'); } async fetchStatus(params = {}) { /** * @method * @name kucoin#fetchStatus * @description the latest known information on the availability of the exchange API * @see https://docs.kucoin.com/#service-status * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure} */ const response = await this.publicGetStatus(params); // // { // "code":"200000", // "data":{ // "status":"open", //open, close, cancelonly // "msg":"upgrade match engine" //remark for operation // } // } // const data = this.safeValue(response, 'data', {}); const status = this.safeString(data, 'status'); return { 'status': (status === 'open') ? 'ok' : 'maintenance', 'updated': undefined, 'eta': undefined, 'url': undefined, 'info': response, }; } async fetchMarkets(params = {}) { /** * @method * @name kucoin#fetchMarkets * @description retrieves data on all markets for kucoin * @see https://docs.kucoin.com/#get-symbols-list-deprecated * @see https://docs.kucoin.com/#get-all-tickers * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} an array of objects representing market data */ const response = await this.publicGetSymbols(params); // // { // "code": "200000", // "data": [ // { // "symbol": "XLM-USDT", // "name": "XLM-USDT", // "baseCurrency": "XLM", // "quoteCurrency": "USDT", // "feeCurrency": "USDT", // "market": "USDS", // "baseMinSize": "0.1", // "quoteMinSize": "0.01", // "baseMaxSize": "10000000000", // "quoteMaxSize": "99999999", // "baseIncrement": "0.0001", // "quoteIncrement": "0.000001", // "priceIncrement": "0.000001", // "priceLimitRate": "0.1", // "isMarginEnabled": true, // "enableTrading": true // }, // ] // } // const data = this.safeValue(response, 'data'); const options = this.safeValue(this.options, 'fetchMarkets', {}); const fetchTickersFees = this.safeValue(options, 'fetchTickersFees', true); let tickersResponse = {}; if (fetchTickersFees) { tickersResponse = await this.publicGetMarketAllTickers(params); } // // { // "code": "200000", // "data": { // "time":1602832092060, // "ticker":[ // { // "symbol": "BTC-USDT", // symbol // "symbolName":"BTC-USDT", // Name of trading pairs, it would change after renaming // "buy": "11328.9", // bestAsk // "sell": "11329", // bestBid // "changeRate": "-0.0055", // 24h change rate // "changePrice": "-63.6", // 24h change price // "high": "11610", // 24h highest price // "low": "11200", // 24h lowest price // "vol": "2282.70993217", // 24h volume,the aggregated trading volume in BTC // "volValue": "25984946.157790431", // 24h total, the trading volume in quote currency of last 24 hours // "last": "11328.9", // last price // "averagePrice": "11360.66065903", // 24h average transaction price yesterday // "takerFeeRate": "0.001", // Basic Taker Fee // "makerFeeRate": "0.001", // Basic Maker Fee // "takerCoefficient": "1", // Taker Fee Coefficient // "makerCoefficient": "1" // Maker Fee Coefficient // } // ] // } // } // const tickersData = this.safeValue(tickersResponse, 'data', {}); const tickers = this.safeValue(tickersData, 'ticker', []); const tickersByMarketId = this.indexBy(tickers, 'symbol'); const result = []; for (let i = 0; i < data.length; i++) { const market = data[i]; const id = this.safeString(market, 'symbol'); const [baseId, quoteId] = id.split('-'); const base = this.safeCurrencyCode(baseId); const quote = this.safeCurrencyCode(quoteId); // const quoteIncrement = this.safeNumber (market, 'quoteIncrement'); const ticker = this.safeValue(tickersByMarketId, id, {}); const makerFeeRate = this.safeString(ticker, 'makerFeeRate'); const takerFeeRate = this.safeString(ticker, 'takerFeeRate'); const makerCoefficient = this.safeString(ticker, 'makerCoefficient'); const takerCoefficient = this.safeString(ticker, 'takerCoefficient'); result.push({ 'id': id, 'symbol': base + '/' + quote, 'base': base, 'quote': quote, 'settle': undefined, 'baseId': baseId, 'quoteId': quoteId, 'settleId': undefined, 'type': 'spot', 'spot': true, 'margin': this.safeValue(market, 'isMarginEnabled'), 'swap': false, 'future': false, 'option': false, 'active': this.safeValue(market, 'enableTrading'), 'contract': false, 'linear': undefined, 'inverse': undefined, 'taker': this.parseNumber(Precise["default"].stringMul(takerFeeRate, takerCoefficient)), 'maker': this.parseNumber(Precise["default"].stringMul(makerFeeRate, makerCoefficient)), 'contractSize': undefined, 'expiry': undefined, 'expiryDatetime': undefined, 'strike': undefined, 'optionType': undefined, 'precision': { 'amount': this.safeNumber(market, 'baseIncrement'), 'price': this.safeNumber(market, 'priceIncrement'), }, 'limits': { 'leverage': { 'min': undefined, 'max': undefined, }, 'amount': { 'min': this.safeNumber(market, 'baseMinSize'), 'max': this.safeNumber(market, 'baseMaxSize'), }, 'price': { 'min': undefined, 'max': undefined, }, 'cost': { 'min': this.safeNumber(market, 'quoteMinSize'), 'max': this.safeNumber(market, 'quoteMaxSize'), }, }, 'created': undefined, 'info': market, }); } return result; } async fetchCurrencies(params = {}) { /** * @method * @name kucoin#fetchCurrencies * @description fetches all available currencies on an exchange * @see https://docs.kucoin.com/#get-currencies * @param {object} params extra parameters specific to the exchange API endpoint * @returns {object} an associative dictionary of currencies */ const promises = []; promises.push(this.publicGetCurrencies(params)); // // { // "code":"200000", // "data":[ // { // "currency":"CSP", // "name":"CSP", // "fullName":"Caspian", // "precision":8, // "confirms":null, // "contractAddress":null, // "isMarginEnabled":false, // "isDebitEnabled":false, // "chains":[ // { // "chainName":"ERC20", // "chain":"eth", // "withdrawalMinSize":"2999", // "withdrawalMinFee":"2999", // "isWithdrawEnabled":false, // "isDepositEnabled":false, // "confirms":12, // "preConfirms":12, // "contractAddress":"0xa6446d655a0c34bc4f05042ee88170d056cbaf45", // "depositFeeRate": "0.001", // present for some currencies/networks // } // ] // }, // } // promises.push(this.fetchWebEndpoint('fetchCurrencies', 'webExchangeGetCurrencyCurrencyChainInfo', true)); // // { // "success": true, // "code": "200", // "msg": "success", // "retry": false, // "data": [ // { // "status": "enabled", // "currency": "BTC", // "isChainEnabled": "true", // "chain": "btc", // "chainName": "BTC", // "chainFullName": "Bitcoin", // "walletPrecision": "8", // "isDepositEnabled": "true", // "depositMinSize": "0.00005", // "confirmationCount": "2", // "isWithdrawEnabled": "true", // "withdrawMinSize": "0.001", // "withdrawMinFee": "0.0005", // "withdrawFeeRate": "0", // "depositDisabledTip": "Wallet Maintenance", // "preDepositTipEnabled": "true", // "preDepositTip": "Do not transfer from ETH network directly", // "withdrawDisabledTip": "", // "preWithdrawTipEnabled": "false", // "preWithdrawTip": "", // "orgAddress": "", // "userAddressName": "Memo", // }, // ] // } // const responses = await Promise.all(promises); const currenciesResponse = this.safeValue(responses, 0, {}); const currenciesData = this.safeValue(currenciesResponse, 'data', []); const additionalResponse = this.safeValue(responses, 1, {}); const additionalData = this.safeValue(additionalResponse, 'data', []); const additionalDataGrouped = this.groupBy(additionalData, 'currency'); const result = {}; for (let i = 0; i < currenciesData.length; i++) { const entry = currenciesData[i]; const id = this.safeString(entry, 'currency'); const name = this.safeString(entry, 'fullName'); const code = this.safeCurrencyCode(id); let isWithdrawEnabled = undefined; let isDepositEnabled = undefined; const networks = {}; const chains = this.safeValue(entry, 'chains', []); const extraChainsData = this.indexBy(this.safeValue(additionalDataGrouped, id, []), 'chain'); const rawPrecision = this.safeString(entry, 'precision'); const precision = this.parseNumber(this.parsePrecision(rawPrecision)); const chainsLength = chains.length; if (!chainsLength) { // https://t.me/KuCoin_API/173118 isWithdrawEnabled = false; isDepositEnabled = false; } for (let j = 0; j < chainsLength; j++) { const chain = chains[j]; const chainId = this.safeString(chain, 'chainId'); const networkCode = this.networkIdToCode(chainId); const chainWithdrawEnabled = this.safeValue(chain, 'isWithdrawEnabled', false); if (isWithdrawEnabled === undefined) { isWithdrawEnabled = chainWithdrawEnabled; } else { isWithdrawEnabled = isWithdrawEnabled || chainWithdrawEnabled; } const chainDepositEnabled = this.safeValue(chain, 'isDepositE