ccxt
Version:
930 lines (927 loc) • 151 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var sha2_js = require('@noble/hashes/sha2.js');
var toobit$1 = require('./abstract/toobit.js');
var errors = require('./base/errors.js');
var Precise = require('./base/Precise.js');
var number = require('./base/functions/number.js');
// ----------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/**
* @class toobit
* @augments Exchange
*/
class toobit extends toobit$1["default"] {
describe() {
return this.deepExtend(super.describe(), {
'id': 'toobit',
'name': 'Toobit',
'countries': ['KY'], // Cayman Islands
'version': 'v1',
'rateLimit': 20, // 50 requests per second
'certified': false,
'pro': true,
'has': {
'CORS': undefined,
'spot': true,
'margin': false,
'swap': true,
'future': false,
'option': false,
'borrowCrossMargin': false,
'borrowIsolatedMargin': false,
'borrowMargin': false,
'cancelAllOrders': true,
'cancelOrder': true,
'cancelOrders': true,
'createOrder': true,
'fetchAllGreeks': false,
'fetchBalance': true,
'fetchBidsAsks': true,
'fetchBorrowInterest': false,
'fetchBorrowRate': false,
'fetchBorrowRateHistories': false,
'fetchBorrowRateHistory': false,
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchClosedOrders': true,
'fetchCrossBorrowRate': false,
'fetchCrossBorrowRates': false,
'fetchCurrencies': true,
'fetchDepositAddress': true,
'fetchDeposits': true,
'fetchFundingRateHistory': true,
'fetchFundingRates': true,
'fetchGreeks': false,
'fetchIndexOHLCV': true,
'fetchIsolatedBorrowRate': false,
'fetchIsolatedBorrowRates': false,
'fetchLastPrices': true,
'fetchLedger': true,
'fetchLeverage': true,
'fetchMarkets': true,
'fetchMarkOHLCV': true,
'fetchMyTrades': true,
'fetchOHLCV': true,
'fetchOpenOrders': true,
'fetchOption': false,
'fetchOptionChain': false,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrders': true,
'fetchPositions': true,
'fetchStatus': true,
'fetchTickers': true,
'fetchTime': true,
'fetchTrades': true,
'fetchTradingFees': true,
'fetchVolatilityHistory': false,
'fetchWithdrawals': true,
'repayCrossMargin': false,
'repayIsolatedMargin': false,
'setLeverage': true,
'setMarginMode': true,
'transfer': true,
'withdraw': true,
},
'urls': {
'logo': 'https://github.com/user-attachments/assets/58e1b718-c6fd-49e2-8a49-797da6b9c008',
'api': {
'common': 'https://api.toobit.com',
'private': 'https://api.toobit.com',
},
'www': 'https://www.toobit.com/',
'doc': [
'https://api-docs.toobit.com/',
],
'referral': {
'url': 'https://www.toobit.com/en-US/r?i=IFFPy0',
'discount': 0.1,
},
'fees': 'https://www.toobit.com/fee',
},
'api': {
'common': {
'get': {
'api/v1/time': 1,
'api/v1/ping': 1,
'api/v1/exchangeInfo': 1,
'quote/v1/depth': 1, // todo: by limit 1-10
'quote/v1/depth/merged': 1,
'quote/v1/trades': 1,
'quote/v1/klines': 1,
'quote/v1/index/klines': 1,
'quote/v1/indexPriceComponents': 1,
'quote/v1/markPrice/klines': 1,
'quote/v1/markPrice': 10, // 5 requests per second
'quote/v1/index': 1,
'quote/v1/ticker/24hr': 40, // todo: 1-40 depending noSymbol
'quote/v1/contract/ticker/24hr': 40, // todo: 1-40 depending noSymbol
'quote/v1/ticker/price': 1,
'quote/v1/contract/ticker/price': 1,
'quote/v1/ticker/bookTicker': 1,
'quote/v1/contract/ticker/bookTicker': 1,
'api/v1/futures/fundingRate': 1,
'api/v1/futures/historyFundingRate': 1,
'api/v1/futures/riskLimits': 1,
},
},
'private': {
'get': {
'api/v1/account': 5,
'api/v1/account/checkApiKey': 1,
'api/v1/spot/order': 1 * 1.67,
'api/v1/spot/openOrders': 1 * 1.67,
'api/v1/futures/openOrders': 1 * 1.67,
'api/v1/spot/tradeOrders': 5 * 1.67,
'api/v1/futures/historyOrders': 5 * 1.67,
'api/v1/account/trades': 5 * 1.67,
'api/v1/account/balanceFlow': 5,
'api/v1/account/depositOrders': 5,
'api/v1/account/withdrawOrders': 5,
'api/v1/account/deposit/address': 1,
// contracts
'api/v1/subAccount': 5,
'api/v1/account/subAccount': 5,
'api/v1/subAccount/list': 5,
'api/v1/futures/accountLeverage': 1,
'api/v1/futures/order': 1 * 1.67,
'api/v1/futures/positions': 5 * 1.67,
'api/v1/futures/historyPositions': 5,
'api/v1/futures/balance': 5,
'api/v1/futures/userTrades': 5 * 1.67,
'api/v1/futures/balanceFlow': 5,
'api/v1/futures/commissionRate': 5,
'api/v1/futures/todayPnl': 5,
'api/v1/account/download/detail': 10,
'api/v1/agent/inviteUserList': 1,
'api/v1/agent/commissionDataList': 1,
'api/v1/agent/commissionDataInfo': 1,
'api/v1/agent/inviteRelationCheck': 1,
'api/v1/agent/depositDetailList': 1,
'api/v1/agent/querySubAgentData': 1,
'api/v1/agent/spotOrdersList': 1,
'api/v1/agent/futuresOrdersList': 1,
'api/v1/agent/futuresPositionsList': 1,
'api/v1/agent/invite-commission-detail': 1,
'api/v1/agent/user/export': 1,
'api/v1/agent/export-list': 1,
'api/v1/agent/export-url': 1,
},
'post': {
'api/v1/spot/orderTest': 1 * 1.67,
'api/v1/spot/order': 1 * 1.67,
'api/v1/futures/order': 1 * 1.67,
'api/v1/spot/batchOrders': 2 * 1.67,
'api/v1/subAccount/transfer': 1,
'api/v1/account/withdraw': 1,
// contracts
'api/v1/futures/marginType': 1,
'api/v1/futures/leverage': 1,
'api/v1/futures/batchOrders': 2 * 1.67,
'api/v1/futures/position/trading-stop': 3 * 1.67,
'api/v1/futures/positionMargin': 1,
'api/v1/futures/order/update': 2 * 1.67,
'api/v1/futures/autoAddMargin': 1,
'api/v1/futures/flashClose': 1,
'api/v1/futures/reversePosition': 5,
'api/v1/account/download/apply': 1000,
'api/v1/userDataStream': 1,
'api/v1/listenKey': 1,
},
'delete': {
'api/v1/spot/order': 1 * 1.67,
'api/v1/futures/order': 1 * 1.67,
'api/v1/spot/openOrders': 5 * 1.67,
'api/v1/futures/batchOrders': 3 * 1.67,
'api/v1/spot/cancelOrderByIds': 5 * 1.67,
'api/v1/futures/cancelOrderByIds': 3 * 1.67,
'api/v1/userDataStream': 1,
'api/v1/listenKey': 1,
},
'put': {
'api/v1/userDataStream': 1,
'api/v1/listenKey': 1,
},
},
},
'timeframes': {
'1m': '1m',
'3m': '3m',
'5m': '5m',
'15m': '15m',
'30m': '30m',
'1h': '1h',
'2h': '2h',
'4h': '4h',
'6h': '6h',
'8h': '8h',
'12h': '12h',
'1d': '1d',
'1w': '1w',
'1M': '1M',
},
'precisionMode': number.TICK_SIZE,
'exceptions': {
'exact': {
'-1000': errors.OperationFailed, // An unknown error occurred while processing the request.
'-1001': errors.OperationFailed, // Internal error; unable to process your request. Please try again.
'-1002': errors.PermissionDenied, // You are not authorized to execute this request.
'-1003': errors.RateLimitExceeded, // Too many requests queued.
'-1004': errors.BadRequest, // {"code":-1004,"msg":"Missing required parameter \u0027xyz\u0027"} | {"code":-1004,"msg":"Bad request"}
'-1005': errors.PermissionDenied, // No Permission
'-1006': errors.OperationFailed, // An unexpected response was received from the message bus. Execution status unknown.
'-1007': errors.OperationFailed, // Timeout waiting for response from backend server. Send status unknown; execution status unknown.
'-1014': errors.OperationFailed, // Unsupported order combination.
'-1015': errors.RateLimitExceeded, // Reach the rate limit .Please slow down your request speed.
'-1016': errors.OperationRejected, // This service is no longer available.
'-1020': errors.OperationRejected, // This operation is not supported.
'-1021': errors.OperationRejected, // Timestamp for this request is outside of the recvWindow.
'-1022': errors.OperationRejected, // Signature for this request is not valid.
'-1023': errors.PermissionDenied, // Please set IP whitelist before using API
'-1031': errors.OperationRejected, // The feature has been suspended
'-1100': errors.BadRequest, // Illegal characters found in a parameter.
'-1101': errors.BadRequest, // Too many parameters sent for this endpoint.
'-1102': errors.BadRequest, // A mandatory parameter was not sent, was empty/null, or malformed.
'-1103': errors.BadRequest, // An unknown parameter was sent.
'-1104': errors.BadRequest, // Not all sent parameters were read.
'-1105': errors.BadRequest, // A parameter was empty.
'-1106': errors.BadRequest, // A parameter was sent when not required.
'-1107': errors.PermissionDenied, // The accessKey is missing from the request header or parameters, or the accessKey is not in the correct format.
'-1111': errors.BadRequest, // Precision is over the maximum defined for this asset.
'-1112': errors.OperationRejected, // No orders on book for symbol.
'-1114': errors.BadRequest, // TimeInForce parameter sent when not required.
'-1115': errors.BadRequest, // Invalid timeInForce.
'-1116': errors.BadRequest, // Invalid orderType.
'-1117': errors.BadRequest, // Invalid side.
'-1118': errors.InvalidOrder, // New client order ID was empty.
'-1119': errors.InvalidOrder, // Original client order ID was empty.
'-1120': errors.BadRequest, // Invalid interval.
'-1121': errors.BadSymbol, // Invalid symbol.
'-1125': errors.OperationRejected, // This listenKey does not exist.
'-1127': errors.OperationRejected, // Lookup interval is too big.
'-1128': errors.BadRequest, // Combination of optional parameters invalid.
'-1129': errors.BadRequest, // The time range cannot exceed one year.
'-1130': errors.BadRequest, // Invalid data sent for a parameter.
'-1131': errors.InsufficientFunds, // Balance insufficient
'-1132': errors.OperationRejected, // Order price too high.
'-1133': errors.OperationRejected, // Order price lower than the minimum,please check general broker info.
'-1134': errors.OperationRejected, // Order price decimal too long,please check general broker info.
'-1135': errors.OperationRejected, // Order quantity too large.
'-1136': errors.OperationRejected, // Order quantity lower than the minimum.
'-1137': errors.OperationRejected, // Order quantity decimal too long.
'-1138': errors.OperationRejected, // Order price exceeds permissible range.
'-1139': errors.OperationRejected, // Order has been filled.
'-1140': errors.OperationRejected, // Transaction amount lower than the minimum.
'-1141': errors.InvalidOrder, // Duplicate clientOrderId
'-1142': errors.InvalidOrder, // Order has been canceled
'-1143': errors.OrderNotFound, // Cannot be found on order book
'-1144': errors.OperationRejected, // Order has been locked
'-1145': errors.OperationRejected, // This order type does not support cancellation
'-1146': errors.OperationFailed, // Order creation timeout
'-1147': errors.OperationFailed, // Order cancellation timeout
'-1148': errors.InvalidOrder, // Market order amount decimal too long
'-1149': errors.OperationFailed, // Create order failed
'-1150': errors.OperationFailed, // Cancel order failed
'-1151': errors.OperationRejected, // The trading pair is not open yet
'-1153': errors.PermissionDenied, // User not exist
'-1156': errors.InvalidOrder, // Order quantity invalid
'-1157': errors.OperationRejected, // The trading pair is not available for api trading
'-1158': errors.InvalidOrder, // create limit maker order failed
'-1161': errors.OperationRejected, // Reduce margin forbidden
'-1164': errors.OperationRejected, // Auto add margin error
'-1165': errors.BadRequest, // Invalid stopType.
'-1166': errors.BadRequest, // Invalid callbackType.
'-1170': errors.OperationRejected, // finance account exist.
'-1171': errors.ExchangeError, // account not exist.
'-1172': errors.OperationFailed, // Balance transfer failed.
'-1181': errors.PermissionDenied, // Currently not allowed to withdraw.
'-1182': errors.PermissionDenied, // Currently not allowed to deposit.
'-1193': errors.OperationRejected, // Create order count limit
'-1194': errors.OperationRejected, // Create market order forbidden
'-1195': errors.OperationRejected, // Create limit order price too small
'-1196': errors.OperationRejected, // Create limit order price too big
'-1197': errors.OperationRejected, // Create limit order buy price too big
'-1198': errors.OperationRejected, // Create limit order sell price too small
'-1199': errors.OperationRejected, // Create order buy quantity too small
'-1200': errors.OperationRejected, // Create order buy quantity too big
'-1201': errors.OperationRejected, // Create limit order sell price too big
'-1202': errors.OperationRejected, // Create order sell quantity too small
'-1203': errors.OperationRejected, // Create order sell quantity too big
'-1204': errors.PermissionDenied, // account not authorized
'-1205': errors.BadRequest, // same account not transfer
'-1206': errors.OperationRejected, // Orders over the maximum transaction amount
'-1207': errors.InvalidOrder, // planOrder count limit.
'-1208': errors.InvalidOrder, // stopProfitLoss order count limit.
'-1209': errors.InvalidOrder, // stopProfitLoss order position limit.
'-1210': errors.InvalidOrder, // dynamic stop profit long fallQuantity high.
'-1211': errors.InvalidOrder, // dynamic stop profit activePrice low.
'-1212': errors.InvalidOrder, // dynamic stop profit activePrice high.
'-1213': errors.BadSymbol, // Account symbol does not match
'-1214': errors.PermissionDenied, // No opening trades
'-1215': errors.PermissionDenied, // No closing trades
'-1216': errors.OperationRejected, // Trigger transfer limit failed
'-1217': errors.InvalidOrder, // Create stop order buy price too big
'-1300': errors.BadRequest, // Duplicate transferId
'-1400': errors.BadRequest, // API voucher type is not allowed.
'-1401': errors.PermissionDenied, // You are not eligible to use API trial voucher.
'-1402': errors.OperationFailed, // API voucher query failed.
'-1403': errors.OperationFailed, // API voucher receive failed.
'-1404': errors.ExchangeError, // API voucher agent config failed.
'-1405': errors.ExchangeError, // API voucher not found.
'-1406': errors.OperationRejected, // API voucher is already in use.
'-1407': errors.OperationRejected, // API voucher threshold is not met.
'-1408': errors.InsufficientFunds, // Contract asset is less than zero.
'-1409': errors.OperationRejected, // API voucher status is invalid.
'-1410': errors.InsufficientFunds, // API voucher system account balance is insufficient.
'-1411': errors.OperationRejected, // API voucher transfer is processing.
'-1412': errors.OperationRejected, // API voucher can not be merged.
'-1413': errors.BadRequest, // API voucher trade rate does not match.
'-1414': errors.BadRequest, // API voucher fee rule does not match.
'-1415': errors.BadRequest, // API voucher token does not match.
'-1416': errors.InsufficientFunds, // Some API vouchers can not be received due to insufficient system balance.
'-1417': errors.OperationRejected, // Some API vouchers do not meet the receiving threshold.
'-2010': errors.OperationFailed, // NEW_ORDER_REJECTED
'-2011': errors.OperationFailed, // CANCEL_REJECTED
'-2013': errors.OrderNotFound, // Order does not exist.
'-2014': errors.PermissionDenied, // API-key format invalid.
'-2015': errors.PermissionDenied, // Invalid API-key, IP, or permissions for action.
'-2016': errors.BadRequest, // No trading window could be found for the symbol. Try ticker/24hrs instead.
'-2017': errors.PermissionDenied, // The API key has expired. Please update your API key immediately.
'-2018': errors.PermissionDenied, // API triggered risk control restrictions have been suspended, if you have any questions, please contact support@toobit.com .
// errors above 3xxx are from swap API
'-3000': errors.BadRequest, // Option not exist.
'-3001': errors.OperationRejected, // The option has expired.
'-3002': errors.InvalidOrder, // Order failed: position exceeded limit
'-3050': errors.ExchangeError, // The ApiKey corresponding to the account already exists
'-3051': errors.OperationRejected, // The sub-user has assets are not allowed to be deleted
'-3052': errors.BadRequest, // sub-user id error
'-3101': errors.OperationRejected, // Open margin account error
'-3102': errors.OperationRejected, // Get margin safety error
'-3103': errors.BadRequest, // Risk config is not exit
'-3105': errors.OperationRejected, // Token can not borrow
'-3107': errors.OperationRejected, // Token can not withdraw
'-3108': errors.OperationRejected, // Get token avail withdraw error
'-3109': errors.OperationRejected, // Margin withdraw failed
'-3110': errors.InsufficientFunds, // Margin avail withdraw not enough failed
'-3116': errors.OperationRejected, // Repay fail
'-3117': errors.OperationRejected, // Get margin all position fail
'-3120': errors.OperationRejected, // Get repay order fail
'-3124': errors.OperationRejected, // Position and order data error
'-3125': errors.OperationRejected, // Position size cannot meet target leverage
'-3126': errors.OperationRejected, // Adjust leverage fail
'-3127': errors.OperationFailed, // Adjust leverage timeout
'-3128': errors.OperationRejected, // The margin mode cannot be changed while you have an open order/position
'-3129': errors.BadRequest, // Cone futures change position type error
'-3130': errors.OperationRejected, // Order margin insufficient
'-3131': errors.NotSupported, // Leverage reduction is not supported in Isolated Margin Mode with open positions.
'-3132': errors.InvalidOrder, // Maximum allowed leverage reached, please lower your leverage.
'-3133': errors.InvalidOrder, // The number of open orders exceeds the limit.
'-3136': errors.OperationRejected, // Quick symbol activity only limit/buy/ioc order is supported
'-3137': errors.OperationRejected, // Open countdown is not over
'-3138': errors.OperationRejected, // Open activity pre_hold is handling
'-3139': errors.OperationRejected, // Open activity max amount limit
'-3140': errors.OperationRejected, // Open activity min amount limit
'-3141': errors.InvalidOrder, // Invalid long stop profit price.
'-3142': errors.InvalidOrder, // Invalid long stop loss price.
'-3143': errors.InvalidOrder, // Invalid short stop profit price.
'-3144': errors.InvalidOrder, // Invalid short stop loss price.
'-3145': errors.InvalidOrder, // No position, Please confirm your position direction.
'-3147': errors.OperationRejected, // previous transfer is being processed. please try again later.
'-3148': errors.InvalidOrder, // create order exceeds max futures risk limit.
'-3149': errors.InvalidOrder, // The reduction in margin is unlawful.
'-3150': errors.NotSupported, // cross position margin adjustments are not supported.
'-3151': errors.NotSupported, // Separate position mode is not supported.
'-3152': errors.BadRequest, // Separate-position mismatch: position mode must be SEPARATE.
'-3153': errors.BadRequest, // Whole-position mismatch: position mode must be WHOLE.
'-32045': errors.ExchangeError, // Copy trading follower not found.
'-32090': errors.OperationRejected, // Trading pair change is not allowed.
'-32093': errors.OperationRejected, // Copy trading position type cannot be changed.
'-120041': errors.PermissionDenied, // Copy trading leader is not available.
'-120047': errors.ExchangeError, // Leader does not exist.
'-120055': errors.OperationRejected, // The follower currently has copy position, cannot be removed.
'-120067': errors.ExchangeError, // Copy trading level config not found.
'-120072': errors.BadRequest, // Copy trading leader config is invalid.
'-120073': errors.OperationRejected, // Unable to switch invite setting.
'-120078': errors.BadRequest, // unLeadStartTime or unLeadEndTime is invalid.
'-120510': errors.BadRequest, // Invite code already exists.
'-120511': errors.BadRequest, // Invite code contains sensitive content.
'-120512': errors.BadRequest, // Invite code is invalid.
},
'broad': {
'Unknown order sent': errors.OrderNotFound,
'Duplicate order sent': errors.InvalidOrder,
'Market is closed': errors.OperationRejected,
'Account has insufficient balance for requested action': errors.InsufficientFunds,
'Market orders are not supported for this symbol': errors.OperationRejected,
'Iceberg orders are not supported for this symbol': errors.OperationRejected,
'Stop loss orders are not supported for this symbol': errors.OperationRejected,
'Stop loss limit orders are not supported for this symbol': errors.OperationRejected,
'Take profit orders are not supported for this symbol': errors.OperationRejected,
'Take profit limit orders are not supported for this symbol': errors.OperationRejected,
'QTY is zero or less': errors.BadRequest,
'IcebergQty exceeds QTY': errors.OperationRejected,
'This action disabled is on this account': errors.PermissionDenied,
'Unsupported order combination': errors.BadRequest,
'Order would trigger immediately': errors.OperationRejected,
'Cancel order is invalid. Check origClOrdId and orderId': errors.OperationRejected,
'Order would immediately match and take': errors.OperationRejected,
},
},
'commonCurrencies': {},
'options': {
'defaultType': 'spot',
'accountsByType': {
'spot': 'MAIN',
'swap': 'FUTURES',
},
'networks': {
'BTC': 'BTC',
'ERC20': 'ETH',
'ETH': 'ETH',
'BEP20': 'BSC',
'TRC20': 'TRX',
'SOL': 'SOL',
'MATIC': 'MATIC',
'ARBONE': 'ARBITRUM',
'BASE': 'BASE',
'TON': 'TON',
'AVAXC': 'AVAXC',
'DOGE': 'DOGE',
'XRP': 'XRP',
'DOT': 'DOT',
'ADA': 'ADA',
'LTC': 'LTC',
'APT': 'APT',
'ATOM': 'ATOM',
'ALGO': 'ALGO',
'NEAR': 'NEAR',
'XLM': 'XLM',
'SUI': 'SUI',
'ETC': 'ETC',
'EOS': 'EOS',
'WAVES': 'WAVES',
'ICP': 'ICP',
'ONE': 'ONE',
// 'CHZ2': 'CHZ2',
},
'networksById': {
'ETH': 'ERC20',
'ERC20': 'ERC20',
},
},
'features': {
'spot': {
'sandbox': false,
'createOrder': {
'marginMode': false,
'triggerPrice': true,
'triggerPriceType': undefined,
'triggerDirection': false,
'stopLossPrice': false,
'takeProfitPrice': false,
'attachedStopLossTakeProfit': undefined,
'timeInForce': {
'IOC': true,
'FOK': true,
'PO': true,
'GTD': false,
},
'hedged': false,
'trailing': false,
'leverage': false,
'marketBuyRequiresPrice': false,
'marketBuyByCost': false,
'selfTradePrevention': false,
'iceberg': false,
},
'createOrders': undefined,
'fetchOHLCV': {
'limit': 1000,
},
'fetchMyTrades': {
'marginMode': false,
'limit': 1000,
'daysBack': 100000,
'untilDays': 100000,
'symbolRequired': true,
},
'fetchOrder': {
'marginMode': false,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchOpenOrders': {
'marginMode': false,
'limit': 1000,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchOrders': {
'marginMode': false,
'limit': 500,
'daysBack': 100000,
'untilDays': 100000,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchClosedOrders': undefined,
},
'forDerivatives': {
'createOrders': undefined,
},
'swap': {
'linear': undefined,
'inverse': undefined,
},
'future': {
'linear': undefined,
'inverse': undefined,
},
},
});
}
/**
* @method
* @name toobit#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://toobit-docs.github.io/apidocs/spot/v1/en/#test-connectivity
* @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}
*/
async fetchStatus(params = {}) {
const response = await this.commonGetApiV1Ping(params);
return {
'status': 'ok',
'updated': undefined,
'eta': undefined,
'url': undefined,
'info': response,
};
}
/**
* @method
* @name toobit#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://api-docs.toobit.com/api/spot-market-data.html#check-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
*/
async fetchTime(params = {}) {
const response = await this.commonGetApiV1Time(params);
//
// {
// "serverTime": 1699827319559
// }
//
return this.safeInteger(response, 'serverTime');
}
/**
* @method
* @name toobit#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://api-docs.toobit.com/api/spot-market-data.html#exchange-information
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
async fetchCurrencies(params = {}) {
const response = await this.commonGetApiV1ExchangeInfo(params);
this.options['exchangeInfo'] = response; // we store it in options for later use in fetchMarkets
//
// {
// "timezone": "UTC",
// "serverTime": "1755583099926",
// "brokerFilters": [],
// "symbols": [
// {
// "filters": [
// {
// "minPrice": "0.01",
// "maxPrice": "10000000.00000000",
// "tickSize": "0.01",
// "filterType": "PRICE_FILTER"
// },
// {
// "minQty": "0.0001",
// "maxQty": "4000",
// "stepSize": "0.0001",
// "filterType": "LOT_SIZE"
// },
// {
// "minNotional": "5",
// "filterType": "MIN_NOTIONAL"
// },
// {
// "minAmount": "5",
// "maxAmount": "6600000",
// "minBuyPrice": "0.01",
// "filterType": "TRADE_AMOUNT"
// },
// {
// "maxSellPrice": "99999999",
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "LIMIT_TRADING"
// },
// {
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "MARKET_TRADING"
// },
// {
// "noAllowMarketStartTime": "0",
// "noAllowMarketEndTime": "0",
// "limitOrderStartTime": "0",
// "limitOrderEndTime": "0",
// "limitMinPrice": "0",
// "limitMaxPrice": "0",
// "filterType": "OPEN_QUOTE"
// }
// ],
// "exchangeId": "301",
// "symbol": "ETHUSDT",
// "symbolName": "ETHUSDT",
// "status": "TRADING",
// "baseAsset": "ETH",
// "baseAssetName": "ETH",
// "baseAssetPrecision": "0.0001",
// "quoteAsset": "USDT",
// "quoteAssetName": "USDT",
// "quotePrecision": "0.01",
// "icebergAllowed": false,
// "isAggregate": false,
// "allowMargin": true,
// }
// ],
// "options": [],
// "contracts": [
// {
// "filters": [ ... ],
// "exchangeId": "301",
// "symbol": "BTC-SWAP-USDT",
// "symbolName": "BTC-SWAP-USDTUSDT",
// "status": "TRADING",
// "baseAsset": "BTC-SWAP-USDT",
// "baseAssetPrecision": "0.001",
// "quoteAsset": "USDT",
// "quoteAssetPrecision": "0.1",
// "icebergAllowed": false,
// "inverse": false,
// "index": "BTC",
// "indexToken": "BTCUSDT",
// "marginToken": "USDT",
// "marginPrecision": "0.0001",
// "contractMultiplier": "0.001",
// "underlying": "BTC",
// "riskLimits": [
// {
// "riskLimitId": "200020911",
// "quantity": "42000.0",
// "initialMargin": "0.02",
// "maintMargin": "0.01",
// "isWhite": false
// },
// {
// "riskLimitId": "200020912",
// "quantity": "84000.0",
// "initialMargin": "0.04",
// "maintMargin": "0.02",
// "isWhite": false
// },
// ...
// ]
// },
// ],
// "coins": [
// {
// "orgId": "9001",
// "coinId": "TCOM",
// "coinName": "TCOM",
// "coinFullName": "TCOM",
// "allowWithdraw": true,
// "allowDeposit": true,
// "chainTypes": [
// {
// "chainType": "BSC",
// "withdrawFee": "49.55478",
// "minWithdrawQuantity": "77",
// "maxWithdrawQuantity": "0",
// "minDepositQuantity": "48",
// "allowDeposit": true,
// "allowWithdraw": false
// }
// ],
// "isVirtual": false
// },
// ...
//
const coins = this.safeList(response, 'coins', []);
const result = {};
for (let i = 0; i < coins.length; i++) {
const coin = coins[i];
const parsed = this.parseCurrency(coin);
if (parsed !== undefined) {
const code = parsed['code'];
result[code] = parsed;
}
}
return result;
}
parseCurrency(rawCurrency) {
const id = this.safeString(rawCurrency, 'coinId');
const code = this.safeCurrencyCode(id);
const networks = {};
const rawNetworks = this.safeList(rawCurrency, 'chainTypes', []);
for (let j = 0; j < rawNetworks.length; j++) {
const rawNetwork = rawNetworks[j];
const networkId = this.safeString(rawNetwork, 'chainType');
const networkCode = this.networkIdToCode(networkId, code);
if (networkCode !== undefined) {
networks[networkCode] = {
'id': networkId,
'network': networkCode,
'margin': undefined,
'deposit': this.safeBool(rawNetwork, 'allowDeposit'),
'withdraw': this.safeBool(rawNetwork, 'allowWithdraw'),
'active': undefined,
'fee': this.safeNumber(rawNetwork, 'withdrawFee'),
'precision': undefined,
'limits': {
'deposit': {
'min': this.safeNumber(rawNetwork, 'minDepositQuantity'),
'max': undefined,
},
'withdraw': {
'min': this.safeNumber(rawNetwork, 'minWithdrawQuantity'),
'max': this.safeNumber(rawNetwork, 'maxWithdrawQuantity'),
},
},
'info': rawNetwork,
};
}
}
return this.safeCurrencyStructure({
'id': id,
'code': code,
'name': this.safeString(rawCurrency, 'coinFullName'),
'type': undefined,
'active': undefined,
'deposit': this.safeBool(rawCurrency, 'allowDeposit'),
'withdraw': this.safeBool(rawCurrency, 'allowWithdraw'),
'fee': undefined,
'precision': undefined,
'limits': {
'amount': {
'min': undefined,
'max': undefined,
},
'withdraw': {
'min': undefined,
'max': undefined,
},
},
'networks': networks,
'info': rawCurrency,
});
}
/**
* @method
* @name toobit#fetchMarkets
* @description retrieves data on all markets for toobit
* @see https://api-docs.toobit.com/api/spot-market-data.html#exchange-information
* @see https://api-docs.toobit.com/api/usdt-m-market-data.html#exchange-information
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
async fetchMarkets(params = {}) {
let response = this.safeDict(this.options, 'exchangeInfo');
if (response !== undefined) {
this.options['exchangeInfo'] = undefined; // reset it to avoid using old cached data
}
else {
response = await this.commonGetApiV1ExchangeInfo(params);
}
//
// {
// "timezone": "UTC",
// "serverTime": "1755583099926",
// "brokerFilters": [],
// "symbols": [
// {
// "filters": [
// {
// "minPrice": "0.01",
// "maxPrice": "10000000.00000000",
// "tickSize": "0.01",
// "filterType": "PRICE_FILTER"
// },
// {
// "minQty": "0.0001",
// "maxQty": "4000",
// "stepSize": "0.0001",
// "filterType": "LOT_SIZE"
// },
// {
// "minNotional": "5",
// "filterType": "MIN_NOTIONAL"
// },
// {
// "minAmount": "5",
// "maxAmount": "6600000",
// "minBuyPrice": "0.01",
// "filterType": "TRADE_AMOUNT"
// },
// {
// "maxSellPrice": "99999999",
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "LIMIT_TRADING"
// },
// {
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "MARKET_TRADING"
// },
// {
// "noAllowMarketStartTime": "0",
// "noAllowMarketEndTime": "0",
// "limitOrderStartTime": "0",
// "limitOrderEndTime": "0",
// "limitMinPrice": "0",
// "limitMaxPrice": "0",
// "filterType": "OPEN_QUOTE"
// }
// ],
// "exchangeId": "301",
// "symbol": "ETHUSDT",
// "symbolName": "ETHUSDT",
// "status": "TRADING",
// "baseAsset": "ETH",
// "baseAssetName": "ETH",
// "baseAssetPrecision": "0.0001",
// "quoteAsset": "USDT",
// "quoteAssetName": "USDT",
// "quotePrecision": "0.01",
// "icebergAllowed": false,
// "isAggregate": false,
// "allowMargin": true,
// }
// ],
// "options": [],
// "contracts": [
// {
// "filters": [ ... ],
// "exchangeId": "301",
// "symbol": "BTC-SWAP-USDT",
// "symbolName": "BTC-SWAP-USDTUSDT",
// "status": "TRADING",
// "baseAsset": "BTC-SWAP-USDT",
// "baseAssetPrecision": "0.001",
// "quoteAsset": "USDT",
// "quoteAssetPrecision": "0.1",
// "icebergAllowed": false,
// "inverse": false,
// "index": "BTC",
// "indexToken": "BTCUSDT",
// "marginToken": "USDT",
// "marginPrecision": "0.0001",
// "contractMultiplier": "0.001",
// "underlying": "BTC",
// "riskLimits": [
// {
// "riskLimitId": "200020911",
// "quantity": "42000.0",
// "initialMargin": "0.02",
// "maintMargin": "0.01",
// "isWhite": false
// },
// {
// "riskLimitId": "200020912",
// "quantity": "84000.0",
// "initialMargin": "0.04",
// "maintMargin": "0.02",
// "isWhite": false
// },
// ...
// ]
// },
// ],
// "coins": [
// {
// "orgId": "9001",
// "coinId": "TCOM",
// "coinName": "TCOM",
// "coinFullName": "TCOM",
// "allowWithdraw": true,
// "allowDeposit": true,
// "chainTypes": [
// {
// "chainType": "BSC",
// "withdrawFee": "49.55478",
// "minWithdrawQuantity": "77",
// "maxWithdrawQuantity": "0",
// "minDepositQuantity": "48",
// "allowDe