@ango-ya/ccxt
Version:
A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges
1,143 lines (1,140 loc) • 242 kB
JavaScript
// ----------------------------------------------------------------------------
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
// ---------------------------------------------------------------------------
import Exchange from './abstract/mexc.js';
import { BadRequest, InvalidNonce, BadSymbol, InvalidOrder, InvalidAddress, ExchangeError, ArgumentsRequired, NotSupported, InsufficientFunds, PermissionDenied, AuthenticationError, AccountSuspended, OnMaintenance } from './base/errors.js';
import { TICK_SIZE } from './base/functions/number.js';
import { Precise } from './base/Precise.js';
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
// ---------------------------------------------------------------------------
/**
* @class mexc
* @augments Exchange
*/
export default class mexc extends Exchange {
describe() {
return this.deepExtend(super.describe(), {
'id': 'mexc',
'name': 'MEXC Global',
'countries': ['SC'],
'rateLimit': 50,
'version': 'v3',
'certified': true,
'pro': true,
'has': {
'CORS': undefined,
'spot': true,
'margin': true,
'swap': true,
'future': false,
'option': false,
'addMargin': true,
'callLoadMarkets': true,
'cancelAllOrders': true,
'cancelOrder': true,
'cancelOrders': undefined,
'closeAllPositions': false,
'closePosition': false,
'createDepositAddress': true,
'createMarketBuyOrderWithCost': true,
'createMarketOrderWithCost': false,
'createMarketSellOrderWithCost': false,
'createOrder': true,
'createOrders': true,
'createReduceOnlyOrder': true,
'deposit': undefined,
'editOrder': undefined,
'fetchAccounts': true,
'fetchBalance': true,
'fetchBidsAsks': true,
'fetchBorrowRateHistory': undefined,
'fetchCanceledOrders': true,
'fetchClosedOrder': undefined,
'fetchClosedOrders': true,
'fetchCrossBorrowRate': false,
'fetchCrossBorrowRates': false,
'fetchCurrencies': true,
'fetchDeposit': undefined,
'fetchDepositAddress': true,
'fetchDepositAddresses': undefined,
'fetchDepositAddressesByNetwork': true,
'fetchDeposits': true,
'fetchDepositWithdrawFee': 'emulated',
'fetchDepositWithdrawFees': true,
'fetchFundingHistory': true,
'fetchFundingRate': true,
'fetchFundingRateHistory': true,
'fetchFundingRates': undefined,
'fetchIndexOHLCV': true,
'fetchIsolatedBorrowRate': false,
'fetchIsolatedBorrowRates': false,
'fetchL2OrderBook': true,
'fetchLedger': undefined,
'fetchLedgerEntry': undefined,
'fetchLeverageTiers': true,
'fetchMarginMode': false,
'fetchMarketLeverageTiers': undefined,
'fetchMarkets': true,
'fetchMarkOHLCV': true,
'fetchMyTrades': true,
'fetchOHLCV': true,
'fetchOpenOrder': undefined,
'fetchOpenOrders': true,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrderBooks': undefined,
'fetchOrders': true,
'fetchOrderTrades': true,
'fetchPosition': true,
'fetchPositionMode': true,
'fetchPositions': true,
'fetchPositionsRisk': undefined,
'fetchPremiumIndexOHLCV': false,
'fetchStatus': true,
'fetchTicker': true,
'fetchTickers': true,
'fetchTime': true,
'fetchTrades': true,
'fetchTradingFee': undefined,
'fetchTradingFees': true,
'fetchTradingLimits': undefined,
'fetchTransactionFee': 'emulated',
'fetchTransactionFees': true,
'fetchTransactions': undefined,
'fetchTransfer': true,
'fetchTransfers': true,
'fetchWithdrawal': undefined,
'fetchWithdrawals': true,
'reduceMargin': true,
'repayCrossMargin': false,
'repayIsolatedMargin': false,
'setLeverage': true,
'setMarginMode': undefined,
'setPositionMode': true,
'signIn': undefined,
'transfer': undefined,
'withdraw': true,
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/137283979-8b2a818d-8633-461b-bfca-de89e8c446b2.jpg',
'api': {
'spot': {
'public': 'https://api.mexc.com',
'private': 'https://api.mexc.com',
},
'spot2': {
'public': 'https://www.mexc.com/open/api/v2',
'private': 'https://www.mexc.com/open/api/v2',
},
'contract': {
'public': 'https://contract.mexc.com/api/v1/contract',
'private': 'https://contract.mexc.com/api/v1/private',
},
'broker': {
'private': 'https://api.mexc.com/api/v3/broker',
},
},
'www': 'https://www.mexc.com/',
'doc': [
'https://mexcdevelop.github.io/apidocs/',
],
'fees': [
'https://www.mexc.com/fee',
],
'referral': 'https://m.mexc.com/auth/signup?inviteCode=1FQ1G',
},
'api': {
'spot': {
'public': {
'get': {
'ping': 1,
'time': 1,
'exchangeInfo': 10,
'depth': 1,
'trades': 5,
'historicalTrades': 1,
'aggTrades': 1,
'klines': 1,
'avgPrice': 1,
'ticker/24hr': 1,
'ticker/price': 1,
'ticker/bookTicker': 1,
'etf/info': 1,
},
},
'private': {
'get': {
'order': 2,
'openOrders': 3,
'allOrders': 10,
'account': 10,
'myTrades': 10,
'sub-account/list': 1,
'sub-account/apiKey': 1,
'capital/config/getall': 10,
'capital/deposit/hisrec': 1,
'capital/withdraw/history': 1,
'capital/withdraw/address': 10,
'capital/deposit/address': 10,
'capital/transfer': 1,
'capital/transfer/tranId': 1,
'capital/transfer/internal': 1,
'capital/sub-account/universalTransfer': 1,
'capital/convert': 1,
'capital/convert/list': 1,
'margin/loan': 1,
'margin/allOrders': 1,
'margin/myTrades': 1,
'margin/openOrders': 1,
'margin/maxTransferable': 1,
'margin/priceIndex': 1,
'margin/order': 1,
'margin/isolated/account': 1,
'margin/maxBorrowable': 1,
'margin/repay': 1,
'margin/isolated/pair': 1,
'margin/forceLiquidationRec': 1,
'margin/isolatedMarginData': 1,
'margin/isolatedMarginTier': 1,
'rebate/taxQuery': 1,
'rebate/detail': 1,
'rebate/detail/kickback': 1,
'rebate/referCode': 1,
'rebate/affiliate/commission': 1,
'rebate/affiliate/withdraw': 1,
'rebate/affiliate/commission/detail': 1,
'mxDeduct/enable': 1,
'userDataStream': 1,
},
'post': {
'order': 1,
'order/test': 1,
'sub-account/virtualSubAccount': 1,
'sub-account/apiKey': 1,
'sub-account/futures': 1,
'sub-account/margin': 1,
'batchOrders': 10,
'capital/withdraw/apply': 1,
'capital/transfer': 1,
'capital/transfer/internal': 1,
'capital/deposit/address': 1,
'capital/sub-account/universalTransfer': 1,
'capital/convert': 10,
'mxDeduct/enable': 1,
'userDataStream': 1,
},
'put': {
'userDataStream': 1,
},
'delete': {
'order': 1,
'openOrders': 1,
'sub-account/apiKey': 1,
'margin/order': 1,
'margin/openOrders': 1,
'userDataStream': 1,
},
},
},
'contract': {
'public': {
'get': {
'ping': 2,
'detail': 100,
'support_currencies': 2,
'depth/{symbol}': 2,
'depth_commits/{symbol}/{limit}': 2,
'index_price/{symbol}': 2,
'fair_price/{symbol}': 2,
'funding_rate/{symbol}': 2,
'kline/{symbol}': 2,
'kline/index_price/{symbol}': 2,
'kline/fair_price/{symbol}': 2,
'deals/{symbol}': 2,
'ticker': 2,
'risk_reverse': 2,
'risk_reverse/history': 2,
'funding_rate/history': 2,
},
},
'private': {
'get': {
'account/assets': 2,
'account/asset/{currency}': 2,
'account/transfer_record': 2,
'position/list/history_positions': 2,
'position/open_positions': 2,
'position/funding_records': 2,
'position/position_mode': 2,
'order/list/open_orders/{symbol}': 2,
'order/list/history_orders': 2,
'order/external/{symbol}/{external_oid}': 2,
'order/get/{order_id}': 2,
'order/batch_query': 8,
'order/deal_details/{order_id}': 2,
'order/list/order_deals': 2,
'planorder/list/orders': 2,
'stoporder/list/orders': 2,
'stoporder/order_details/{stop_order_id}': 2,
'account/risk_limit': 2,
'account/tiered_fee_rate': 2,
'position/leverage': 2,
},
'post': {
'position/change_margin': 2,
'position/change_leverage': 2,
'position/change_position_mode': 2,
'order/submit': 2,
'order/submit_batch': 40,
'order/cancel': 2,
'order/cancel_with_external': 2,
'order/cancel_all': 2,
'account/change_risk_level': 2,
'planorder/place': 2,
'planorder/cancel': 2,
'planorder/cancel_all': 2,
'stoporder/cancel': 2,
'stoporder/cancel_all': 2,
'stoporder/change_price': 2,
'stoporder/change_plan_price': 2,
},
},
},
'spot2': {
'public': {
'get': {
'market/symbols': 1,
'market/coin/list': 2,
'common/timestamp': 1,
'common/ping': 2,
'market/ticker': 1,
'market/depth': 1,
'market/deals': 1,
'market/kline': 1,
'market/api_default_symbols': 2,
},
},
'private': {
'get': {
'account/info': 1,
'order/open_orders': 1,
'order/list': 1,
'order/query': 1,
'order/deals': 1,
'order/deal_detail': 1,
'asset/deposit/address/list': 2,
'asset/deposit/list': 2,
'asset/address/list': 2,
'asset/withdraw/list': 2,
'asset/internal/transfer/record': 10,
'account/balance': 10,
'asset/internal/transfer/info': 10,
'market/api_symbols': 2,
},
'post': {
'order/place': 1,
'order/place_batch': 1,
'order/advanced/place_batch': 1,
'asset/withdraw': 2,
'asset/internal/transfer': 10,
},
'delete': {
'order/cancel': 1,
'order/cancel_by_symbol': 1,
'asset/withdraw': 2,
},
},
},
'broker': {
'private': {
'get': {
'sub-account/universalTransfer': 1,
'sub-account/list': 1,
'sub-account/apiKey': 1,
'capital/deposit/subAddress': 1,
'capital/deposit/subHisrec': 1,
'capital/deposit/subHisrec/getall': 1,
},
'post': {
'sub-account/virtualSubAccount': 1,
'sub-account/apiKey': 1,
'capital/deposit/subAddress': 1,
'capital/withdraw/apply': 1,
'sub-account/universalTransfer': 1,
'sub-account/futures': 1,
},
'delete': {
'sub-account/apiKey': 1,
},
},
},
},
'precisionMode': TICK_SIZE,
'timeframes': {
'1m': '1m',
'5m': '5m',
'15m': '15m',
'30m': '30m',
'1h': '1h',
'4h': '4h',
'8h': '8h',
'1d': '1d',
'1w': '1w',
'1M': '1M', // spot, swap
},
'fees': {
'trading': {
'tierBased': false,
'percentage': true,
'maker': this.parseNumber('0.002'),
'taker': this.parseNumber('0.002'),
},
},
'options': {
'createMarketBuyOrderRequiresPrice': true,
'unavailableContracts': {
'BTC/USDT:USDT': true,
'LTC/USDT:USDT': true,
'ETH/USDT:USDT': true,
},
'fetchMarkets': {
'types': {
'spot': true,
'swap': {
'linear': true,
'inverse': false,
},
},
},
'timeframes': {
'spot': {
'1m': '1m',
'5m': '5m',
'15m': '15m',
'30m': '30m',
'1h': '60m',
'4h': '4h',
'1d': '1d',
'1M': '1M',
},
'swap': {
'1m': 'Min1',
'5m': 'Min5',
'15m': 'Min15',
'30m': 'Min30',
'1h': 'Min60',
'4h': 'Hour4',
'8h': 'Hour8',
'1d': 'Day1',
'1w': 'Week1',
'1M': 'Month1',
},
},
'defaultType': 'spot',
'defaultNetwork': 'ETH',
'defaultNetworks': {
'ETH': 'ETH',
'USDT': 'ERC20',
'USDC': 'ERC20',
'BTC': 'BTC',
'LTC': 'LTC',
},
'networks': {
'ABBC': 'ABBC',
'ACA': 'ACALA',
'ADA': 'Cardano(ADA)',
'AE': 'AE',
'ALGO': 'Algorand(ALGO)',
'ALPH': 'Alephium(ALPH)',
'AME': 'AME',
'AOK': 'AOK',
'APT': 'APTOS(APT)',
'AR': 'AR',
'ARB': 'Arbitrum One(ARB)',
'ARBNOVA': 'ARBNOVA',
'ARBONE': 'ArbitrumOne(ARB)',
'ARK': 'ARK',
'ASTR': 'ASTAR',
'ATOM': 'Cosmos(ATOM)',
'AVAXC': 'Avalanche C Chain(AVAX CCHAIN)',
'AVAXX': 'Avalanche X Chain(AVAX XCHAIN)',
'AZERO': 'Aleph Zero(AZERO)',
'BCH': 'Bitcoin Cash(BCH)',
'BDX': 'BDX',
'BEAM': 'BEAM',
'BEP2': 'BNB Beacon Chain(BEP2)',
'BEP20': 'BNB Smart Chain(BEP20)',
'BITCI': 'BITCI',
'BNC': 'BNC',
'BNCDOT': 'BNCPOLKA',
'BOBA': 'BOBA',
'BSC': 'BEP20(BSC)',
'BSV': 'Bitcoin SV(BSV)',
'BTC': 'Bitcoin(BTC)',
'BTM': 'BTM2',
'CELO': 'CELO',
'CFX': 'CFX',
'CHZ': 'Chiliz Legacy Chain(CHZ)',
'CHZ2': 'Chiliz Chain(CHZ2)',
'CKB': 'CKB',
'CLORE': 'Clore.ai(CLORE)',
'CRC20': 'CRONOS',
'CSPR': 'CSPR',
'DASH': 'DASH',
'DC': 'Dogechain(DC)',
'DCR': 'DCR',
'DNX': 'Dynex(DNX)',
'DOGE': 'Dogecoin(DOGE)',
'DOT': 'Polkadot(DOT)',
'DYM': 'Dymension(DYM)',
'EDG': 'EDG',
'EGLD': 'EGLD',
'EOS': 'EOS',
'ERC20': 'Ethereum(ERC20)',
'ETC': 'Ethereum Classic(ETC)',
'ETHF': 'ETF',
'ETHW': 'ETHW',
'EVER': 'EVER',
'FET': 'FET',
'FIL': 'FIL',
'FIO': 'FIO',
'FLOW': 'FLOW',
'FSN': 'FSN',
'FTM': 'Fantom(FTM)',
'FUSE': 'FUSE',
'GLMR': 'GLMR',
'GRIN': 'GRIN',
'HBAR': 'Hedera(HBAR)',
'HIVE': 'HIVE',
'HRC20': 'HECO',
'HYDRA': 'HYDRA',
'ICP': 'Internet Computer(ICP)',
'INDEX': 'Index Chain',
'IOST': 'IOST',
'IOTA': 'IOTA',
'IOTX': 'IOTX',
'IRIS': 'IRIS',
'KAR': 'KAR',
'KAS': 'Kaspa(KAS)',
'KAVA': 'KAVA',
'KDA': 'KDA',
'KILT': 'KILT',
'KLAY': 'Klaytn(KLAY)',
'KMA': 'KMA',
'KSM': 'KSM',
'LAT': 'LAT',
'LAVA': 'Elysium(LAVA)',
'LTC': 'Litecoin(LTC)',
'LUNA': 'Terra(LUNA)',
'MASS': 'MASS',
'MATIC': 'Polygon(MATIC)',
'MCOIN': 'Mcoin Network',
'METIS': 'METIS',
'MINA': 'MINA',
'MNT': 'Mantle(MNT)',
'MOVR': 'MOVR',
'MTRG': 'Meter(MTRG)',
'NAS': 'NAS',
'NEAR': 'NEAR Protocol(NEAR)',
'NEBL': 'NEBL',
'NEM': 'NEM',
'NEO': 'NEO',
'NEO3': 'NEO3',
'NEOXA': 'Neoxa Network',
'NULS': 'NULS',
'OASIS': 'ROSE',
'OASYS': 'OASYS',
'OKC': 'OKT',
'OMN': 'Omega Network(OMN)',
'OMNI': 'OMNI',
'ONE': 'ONE',
'ONT': 'ONT',
'OPTIMISM': 'Optimism(OP)',
'OSMO': 'OSMO',
'PLCU': 'PLCU',
'POKT': 'POKT',
'QKC': 'QKC',
'QTUM': 'QTUM',
'RAP20': 'RAP20 (Rangers Mainnet)',
'REI': 'REI',
'RSK': 'RBTC',
'RVN': 'Ravencoin(RVN)',
'SATOX': 'Satoxcoin(SATOX)',
'SC': 'SC',
'SCRT': 'SCRT',
'SDN': 'SDN',
'SGB': 'SGB',
'SOL': 'Solana(SOL)',
'STAR': 'STAR',
'STARK': 'Starknet(STARK)',
'STEEM': 'STEEM',
'SYS': 'SYS',
'TAO': 'Bittensor(TAO)',
'TIA': 'Celestia(TIA)',
'TOMO': 'TOMO',
'TON': 'Toncoin(TON)',
'TRC10': 'TRC10',
'TRC20': 'Tron(TRC20)',
'UGAS': 'UGAS(Ultrain)',
'VET': 'VeChain(VET)',
'VEX': 'Vexanium(VEX)',
'VSYS': 'VSYS',
'WAVES': 'WAVES',
'WAX': 'WAX',
'WEMIX': 'WEMIX',
'XCH': 'Chia(XCH)',
'XDC': 'XDC',
'XEC': 'XEC',
'XLM': 'Stellar(XLM)',
'XMR': 'Monero(XMR)',
'XNA': 'Neurai(XNA)',
'XPR': 'XPR Network',
'XRD': 'XRD',
'XRP': 'Ripple(XRP)',
'XTZ': 'XTZ',
'XVG': 'XVG',
'XYM': 'XYM',
'ZEC': 'ZEC',
'ZEN': 'ZEN',
'ZIL': 'Zilliqa(ZIL)',
'ZTG': 'ZTG',
// todo: uncomment below after concensus
// 'ALAYA': 'ATP',
// 'ANDUSCHAIN': 'DEB',
// 'ASSETMANTLE': 'MNTL',
// 'AXE': 'AXE',
// 'BITCOINHD': 'BHD',
// 'BITCOINVAULT': 'BTCV',
// 'BITKUB': 'KUB',
// 'BITSHARES_OLD': 'BTS',
// 'BITSHARES': 'NBS',
// 'BYTZ': 'BYTZ',
// 'CANTO': 'CANTO', // CANTOEVM
// 'CENNZ': 'CENNZ',
// 'CHAINX': 'PCX',
// 'CONCODRIUM': 'CCD',
// 'CONTENTVALUENETWORK': 'CVNT',
// 'CORTEX': 'CTXC',
// 'CYPHERIUM': 'CPH',
// 'DANGNN': 'DGC',
// 'DARWINIASMARTCHAIN': 'Darwinia Smart Chain',
// 'DHEALTH': 'DHP',
// 'DOGECOIN': [ 'DOGE', 'DOGECHAIN' ], // todo after unification
// 'DRAC': 'DRAC',
// 'DRAKEN': 'DRK',
// 'ECOCHAIN': 'ECOC',
// 'ELECTRAPROTOCOL': 'XEP',
// 'EMERALD': 'EMERALD', // sits on top of OASIS
// 'EVMOS': 'EVMOS', // EVMOSETH is different
// 'EXOSAMA': 'SAMA',
// 'FIBOS': 'FO',
// 'FILECASH': 'FIC',
// 'FIRMACHAIN': 'FCT',
// 'FIRO': 'XZC',
// 'FNCY': 'FNCY',
// 'FRUITS': 'FRTS',
// 'GLEEC': 'GLEEC',
// 'GXCHAIN': 'GXC',
// 'HANDSHAKE': 'HNS',
// 'HPB': 'HPB',
// 'HSHARE': 'HC',
// 'HUAHUA': 'HUAHUA',
// 'HUPAYX': 'HPX',
// 'INDEXCHAIN': 'IDX',
// 'INTCHAIN': 'INT',
// 'INTEGRITEE': 'TEER',
// 'INTERLAY': 'INTR',
// 'IOEX': 'IOEX',
// 'JUNO': 'JUNO',
// 'KASPA': 'KASPA',
// 'KEKCHAIN': 'KEKCHAIN',
// 'KINTSUGI': 'KINT',
// 'KOINOS': 'KOINOS',
// 'KONSTELLATION': 'DARC',
// 'KUJIRA': 'KUJI',
// 'KULUPU': 'KLP',
// 'LBRY': 'LBC',
// 'LEDGIS': 'LED',
// 'LIGHTNINGBITCOIN': 'LBTC',
// 'LINE': 'LINE',
// 'MDNA': 'DNA',
// 'MDUKEY': 'MDU',
// 'METAMUI': 'MMUI',
// 'METAVERSE_ETP': 'ETP',
// 'METER': 'MTRG',
// 'MEVERSE': 'MEVerse',
// 'NEWTON': 'NEW',
// 'NODLE': 'NODLE',
// 'ORIGYN': 'OGY',
// 'PAC': 'PAC',
// 'PASTEL': 'PSL',
// 'PHALA': 'Khala',
// 'PLEX': 'PLEX',
// 'PMG': 'PMG',
// 'POINT': 'POINT', // POINTEVM is different
// 'PROOFOFMEMES': 'POM',
// 'PROXIMAX': 'XPX',
// 'RCHAIN': 'REV',
// 'REBUS': 'REBUS', // REBUSEVM is different
// 'RIZON': 'ATOLO',
// 'SENTINEL': 'DVPN',
// 'SERO': 'SERO',
// 'TECHPAY': 'TPC',
// 'TELOSCOIN': 'TLOS', // todo
// 'TERRA': 'LUNA2',
// 'TERRACLASSIC': 'LUNC',
// 'TLOS': 'TELOS', // todo
// 'TOMAINFO': 'TON',
// 'TONGTONG': 'TTC',
// 'TURTLECOIN': 'TRTL',
// 'ULORD': 'UT',
// 'ULTRAIN': 'UGAS',
// 'UMEE': 'UMEE',
// 'VDIMENSION': 'VOLLAR',
// 'VEXANIUM': 'VEX',
// 'VNT': 'VNT',
// 'WAYKICHAIN': 'WICC',
// 'WHITECOIN': 'XWC',
// 'WITNET': 'WIT',
// 'XDAI': 'XDAI',
// 'XX': 'XX',
// 'YAS': 'YAS',
// 'ZENITH': 'ZENITH',
// 'ZKSYNC': 'ZKSYNC',
// // 'BAJUN': '',
// OKB <> OKT (for usdt it's exception) for OKC, PMEER, FLARE, STRD, ZEL, FUND, "NONE", CRING, FREETON, QTZ (probably unique network is meant), HT, BSC(RACAV1), BSC(RACAV2), AMBROSUS, BAJUN, NOM. their individual info is at https://www.mexc.com/api/platform/asset/spot/{COINNAME}
},
'networksById': {
'Aleph Zero(AZERO)': 'AZERO',
'Alephium(ALPH)': 'ALPH',
'Algorand(ALGO)': 'ALGO',
'APTOS(APT)': 'APT',
'Arbitrum One(ARB)': 'ARB',
'Avalanche C Chain(AVAX CCHAIN)': 'AVAXC',
'Avalanche X Chain(AVAX XCHAIN)': 'AVAXX',
'BEP20(BSC)': 'BSC',
'Bitcoin Cash(BCH)': 'BCH',
'Bitcoin SV(BSV)': 'BSV',
'Bitcoin(BTC)': 'BTC',
'Bittensor(TAO)': 'TAO',
'BNB Beacon Chain(BEP2)': 'BEP2',
'BNB Smart Chain(BEP20-RACAV1)': 'BSC',
'BNB Smart Chain(BEP20-RACAV2)': 'BSC',
'BNB Smart Chain(BEP20)': 'BSC',
'Cardano(ADA)': 'ADA',
'Celestia(TIA)': 'TIA',
'Chia(XCH)': 'XCH',
'Chiliz Chain(CHZ2)': 'CHZ2',
'Chiliz Legacy Chain(CHZ)': 'CHZ',
'Clore.ai(CLORE)': 'CLORE',
'Cosmos(ATOM)': 'ATOM',
'Dogechain(DC)': 'DC',
'Dogecoin(DOGE)': 'DOGE',
'Dymension(DYM)': 'DYM',
'Dynex(DNX)': 'DNX',
'Elysium(LAVA)': 'LAVA',
'Ethereum Classic(ETC)': 'ETC',
'Ethereum(ERC20)': 'ERC20',
'Fantom(FTM)': 'FTM',
'Hedera(HBAR)': 'HBAR',
'Index Chain': 'INDEX',
'Internet Computer(ICP)': 'ICP',
'Kaspa(KAS)': 'KAS',
'Klaytn(KLAY)': 'KLAY',
'Litecoin(LTC)': 'LTC',
'Mantle(MNT)': 'MNT',
'Mcoin Network': 'MCOIN',
'Meter(MTRG)': 'MTRG',
'Monero(XMR)': 'XMR',
'NEAR Protocol(NEAR)': 'NEAR',
'Neoxa Network': 'NEOXA',
'Neurai(XNA)': 'XNA',
'Omega Network(OMN)': 'OMN',
'Optimism(OP)': 'OPTIMISM',
'Polkadot(DOT)': 'DOT',
'Polygon(MATIC)': 'MATIC',
'RAP20 (Rangers Mainnet)': 'RAP20',
'Ravencoin(RVN)': 'RVN',
'Ripple(XRP)': 'XRP',
'Satoxcoin(SATOX)': 'SATOX',
'Solana(SOL)': 'SOL',
'Starknet(STARK)': 'STARK',
'Stellar(XLM)': 'XLM',
'Terra(LUNA)': 'LUNA',
'Toncoin(TON)': 'TON',
'Tron(TRC20)': 'TRC20',
'UGAS(Ultrain)': 'UGAS',
'VeChain(VET)': 'VET',
'Vexanium(VEX)': 'VEX',
'XPR Network': 'XPR',
'Zilliqa(ZIL)': 'ZIL',
// TODO: uncomment below after deciding unified name
// 'PEPE COIN BSC':
// 'SMART BLOCKCHAIN':
// 'f(x)Core':
// 'Syscoin Rollux':
// 'Syscoin UTXO':
// 'zkSync Era':
// 'zkSync Lite':
// 'Darwinia Smart Chain':
// 'Arbitrum One(ARB-Bridged)':
// 'Optimism(OP-Bridged)':
// 'Polygon(MATIC-Bridged)':
},
'recvWindow': 5 * 1000,
'maxTimeTillEnd': 90 * 86400 * 1000 - 1,
'broker': 'CCXT',
},
'commonCurrencies': {
'BEYONDPROTOCOL': 'BEYOND',
'BIFI': 'BIFIF',
'BYN': 'BeyondFi',
'COFI': 'COFIX',
'DFI': 'DfiStarter',
'DFT': 'dFuture',
'DRK': 'DRK',
'EGC': 'Egoras Credit',
'FLUX1': 'FLUX',
'FLUX': 'FLUX1',
'FREE': 'FreeRossDAO',
'GAS': 'GASDAO',
'GASNEO': 'GAS',
'GMT': 'GMT Token',
'STEPN': 'GMT',
'HERO': 'Step Hero',
'MIMO': 'Mimosa',
'PROS': 'Pros.Finance',
'SIN': 'Sin City Token',
'SOUL': 'Soul Swap',
},
'exceptions': {
'exact': {
// until mexc migrates fully to v3, it might be worth to note the version & market aside errors, not easily remove obsolete version's exceptions in future
'-1128': BadRequest,
'-2011': BadRequest,
'-1121': BadSymbol,
'10101': InsufficientFunds,
'2009': InvalidOrder,
'2011': BadRequest,
'30004': InsufficientFunds,
'33333': BadRequest,
'44444': BadRequest,
'1002': InvalidOrder,
'30019': BadRequest,
'30005': InvalidOrder,
'2003': InvalidOrder,
'2005': InsufficientFunds,
'400': BadRequest,
// '500': OnMaintenance, // {"code": 500,"message": "Under maintenance, please try again later","announcement": "https://www.mexc.com/support/articles/17827791510263"}
'600': BadRequest,
'70011': PermissionDenied,
'88004': InsufficientFunds,
'88009': ExchangeError,
'88013': InvalidOrder,
'88015': InsufficientFunds,
'700003': InvalidNonce,
'26': ExchangeError,
'602': AuthenticationError,
'10001': AuthenticationError,
'10007': BadSymbol,
'10015': BadRequest,
'10072': BadRequest,
'10073': BadRequest,
'10095': InvalidOrder,
'10096': InvalidOrder,
'10097': InvalidOrder,
'10098': InvalidOrder,
'10099': BadRequest,
'10100': BadRequest,
'10102': InvalidOrder,
'10103': ExchangeError,
'10200': BadRequest,
'10201': BadRequest,
'10202': BadRequest,
'10206': BadRequest,
'10211': BadRequest,
'10212': BadRequest,
'10216': ExchangeError,
'10219': ExchangeError,
'10222': BadRequest,
'10232': BadRequest,
'10259': ExchangeError,
'10265': ExchangeError,
'10268': BadRequest,
'20001': ExchangeError,
'20002': ExchangeError,
'22222': BadRequest,
'30000': ExchangeError,
'30001': InvalidOrder,
'30002': InvalidOrder,
'30003': InvalidOrder,
'30010': InvalidOrder,
'30014': InvalidOrder,
'30016': InvalidOrder,
'30018': AccountSuspended,
'30020': AuthenticationError,
'30021': BadRequest,
'30025': InvalidOrder,
'30026': BadRequest,
'30027': InvalidOrder,
'30028': InvalidOrder,
'30029': InvalidOrder,
'30032': InvalidOrder,
'30041': InvalidOrder,
'60005': ExchangeError,
'700001': AuthenticationError,
'700002': AuthenticationError,
'700004': BadRequest,
'700005': InvalidNonce,
'700006': BadRequest,
'700007': PermissionDenied,
'700008': BadRequest,
'730001': BadRequest,
'730002': BadRequest,
'730000': ExchangeError,
'730003': ExchangeError,
'730100': ExchangeError,
'730600': BadRequest,
'730601': BadRequest,
'730602': BadRequest,
'730700': BadRequest,
'730701': BadRequest,
'730702': BadRequest,
'730703': BadRequest,
'730704': BadRequest,
'730705': BadRequest,
'730706': BadRequest,
'730707': BadRequest,
'730101': BadRequest,
'140001': BadRequest,
'140002': AuthenticationError, // sub account is forbidden
},
'broad': {
'Order quantity error, please try to modify.': BadRequest,
'Combination of optional parameters invalid': BadRequest,
'api market order is disabled': BadRequest,
'Contract not allow place order!': InvalidOrder,
'Oversold': InvalidOrder,
'Insufficient position': InsufficientFunds,
'Insufficient balance!': InsufficientFunds,
'Bid price is great than max allow price': InvalidOrder,
'Invalid symbol.': BadSymbol,
'Param error!': BadRequest,
'maintenance': OnMaintenance, // {"code": 500,"message": "Under maintenance, please try again later","announcement": "https://www.mexc.com/support/articles/17827791510263"}
},
},
});
}
async callLoadMarkets(coinListData = undefined, marketData = undefined) {
/**
* @method
* @name mexc#callLoadMarkets
* @description call fetchCurrencies and fetchMarkets api
* @param {coinListData} data extra parameters specific to the mexc api endpoint
* @param {marketData} data extra parameters specific to the mexc api endpoint
*/
await this.loadMarkets(coinListData, marketData);
}
async fetchStatus(params = {}) {
/**
* @method
* @name mexc#fetchStatus
* @description the latest known information on the availability of the exchange API
* @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 [marketType, query] = this.handleMarketTypeAndParams('fetchStatus', undefined, params);
let response = undefined;
let status = undefined;
let updated = undefined;
if (marketType === 'spot') {
response = await this.spotPublicGetPing(query);
//
// {}
//
const keys = Object.keys(response);
const length = keys.length;
status = length ? this.json(response) : 'ok';
}
else if (marketType === 'swap') {
response = await this.contractPublicGetPing(query);
//
// {"success":true,"code":"0","data":"1648124374985"}
//
status = this.safeValue(response, 'success') ? 'ok' : this.json(response);
updated = this.safeInteger(response, 'data');
}
return {
'status': status,
'updated': updated,
'url': undefined,
'eta': undefined,
'info': response,
};
}
async fetchTime(params = {}) {
/**
* @method
* @name mexc#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
const [marketType, query] = this.handleMarketTypeAndParams('fetchTime', undefined, params);
let response = undefined;
if (marketType === 'spot') {
response = await this.spotPublicGetTime(query);
//
// {"serverTime": "1647519277579"}
//
return this.safeInteger(response, 'serverTime');
}
else if (marketType === 'swap') {
response = await this.contractPublicGetPing(query);
//
// {"success":true,"code":"0","data":"1648124374985"}
//
return this.safeInteger(response, 'data');
}
return undefined;
}
async fetchCurrencies(params = {}) {
/**
* @method
* @name mexc#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
// this endpoint requires authentication
// while fetchCurrencies is a public API method by design
// therefore we check the keys here
// and fallback to generating the currencies from the markets
if (!this.checkRequiredCredentials(false)) {
return undefined;
}
const response = await this.spotPrivateGetCapitalConfigGetall(params);
//
// {
// "coin": "QANX",
// "name": "QANplatform",
// "networkList": [
// {
// "coin": "QANX",
// "depositDesc": null,
// "depositEnable": true,
// "minConfirm": "0",
// "name": "QANplatform",
// "network": "BEP20(BSC)",
// "withdrawEnable": false,
// "withdrawFee": "42.000000000000000000",
// "withdrawIntegerMultiple": null,
// "withdrawMax": "24000000.000000000000000000",
// "withdrawMin": "20.000000000000000000",
// "sameAddress": false,
// "contract": "0xAAA7A10a8ee237ea61E8AC46C50A8Db8bCC1baaa"
// },
// {
// "coin": "QANX",
// "depositDesc": null,
// "depositEnable": true,
// "minConfirm": "0",
// "name": "QANplatform",
// "network": "ERC20",
// "withdrawEnable": true,
// "withdrawFee": "2732.000000000000000000",
// "withdrawIntegerMultiple": null,
// "withdrawMax": "24000000.000000000000000000",
// "withdrawMin": "240.000000000000000000",
// "sameAddress": false,
// "contract": "0xAAA7A10a8ee237ea61E8AC46C50A8Db8bCC1baaa"
// }
// ]
// }
//
const result = {};
for (let i = 0; i < response.length; i++) {
const currency = response[i];
const id = this.safeString(currency, 'coin');
const code = this.safeCurrencyCode(id);
const name = this.safeString(currency, 'name');
let currencyActive = false;
let currencyFee = undefined;
let currencyWithdrawMin = undefined;
let currencyWithdrawMax = undefined;
let depositEnabled = false;
let withdrawEnabled = false;
const networks = {};
const chains = this.safeValue(currency, 'networkList', []);
for (let j = 0; j < chains.length; j++) {
const chain = chains[j];
const networkId = this.safeString(chain, 'network');
const network = this.networkIdToCode(networkId);
const isDepositEnabled = this.safeBool(chain, 'depositEnable', false);
const isWithdrawEnabled = this.safeBool(chain, 'withdrawEnable', false);
const active = (isDepositEnabled && isWithdrawEnabled);
currencyActive = active || currencyActive;
const withdrawMin = this.safeString(chain, 'withdrawMin');
const withdrawMax = this.safeString(chain, 'withdrawMax');
currencyWithdrawMin = (currencyWithdrawMin === undefined) ? withdrawMin : currencyWithdrawMin;
currencyWithdrawMax = (currencyWithdrawMax === undefined) ? withdrawMax : currencyWithdrawMax;
const fee = this.safeNumber(chain, 'withdrawFee');
currencyFee = (currencyFee === undefined) ? fee : currencyFee;
if (Precise.stringGt(currencyWithdrawMin, withdrawMin)) {
currencyWithdrawMin = withdrawMin;
}
if (Precise.stringLt(currencyWithdrawMax, withdrawMax)) {
currencyWithdrawMax = withdrawMax;
}
if (isDepositEnabled) {
depositEnabled = true;
}
if (isWithdrawEnabled) {
withdrawEnabled = true;
}
networks[network] = {
'info': chain,
'id': networkId,
'network': network,
'active': active,
'deposit': isDepositEnabled,
'withdraw': isWithdrawEnabled,
'fee': fee,
'precision': undefined,
'limits': {
'withdraw': {
'min': withdrawMin,
'max': withdrawMax,
},
},
};
}
const networkKeys = Object.keys(networks);
const networkKeysLength = networkKeys.length;
if ((networkKeysLength === 1) || ('NONE' in networks)) {
const defaultNetwork = this.safeValue2(networks, 'NONE', networkKeysLength - 1);
if (defaultNetwork !== undefined) {
currencyFee = defaultNetwork['fee'];
}
}
result[code] = {
'info': currency,
'id': id,
'code': code,
'name': name,
'active': currencyActive,
'deposit': depositEnabled,
'withdraw': withdrawEnabled,
'fee': currencyFee,
'precision': undefined,
'limits': {
'amount': {
'min': undefined,
'max': undefined,
},
'withdraw': {
'min': currencyWithdrawMin,
'max': currencyWithdrawMax,