ccxt
Version:
907 lines (904 loc) • 215 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var sha2_js = require('@noble/hashes/sha2.js');
var woo$1 = require('./abstract/woo.js');
var errors = require('./base/errors.js');
var Precise = require('./base/Precise.js');
var number = require('./base/functions/number.js');
// ----------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/**
* @class woo
* @augments Exchange
*/
class woo extends woo$1["default"] {
describe() {
return this.deepExtend(super.describe(), {
'id': 'woo',
'name': 'WOO X',
'countries': ['KY'], // Cayman Islands
'rateLimit': 100,
'version': 'v1',
'certified': true,
'pro': true,
'hostname': 'woox.io',
'has': {
'CORS': undefined,
'spot': true,
'margin': true,
'swap': true,
'future': false,
'option': false,
'addMargin': true,
'cancelAllOrders': true,
'cancelAllOrdersAfter': true,
'cancelOrder': true,
'cancelWithdraw': false, // exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://docx.woo.io/wootrade-documents/#cancel-withdraw-request
'closeAllPositions': false,
'closePosition': false,
'createConvertTrade': true,
'createDepositAddress': false,
'createMarketBuyOrderWithCost': true,
'createMarketOrder': false,
'createMarketOrderWithCost': false,
'createMarketSellOrderWithCost': true,
'createOrder': true,
'createOrderWithTakeProfitAndStopLoss': true,
'createReduceOnlyOrder': true,
'createStopLimitOrder': false,
'createStopLossOrder': true,
'createStopMarketOrder': false,
'createStopOrder': false,
'createTakeProfitOrder': true,
'createTrailingAmountOrder': true,
'createTrailingPercentOrder': true,
'createTriggerOrder': true,
'fetchAccounts': true,
'fetchBalance': true,
'fetchCanceledOrders': false,
'fetchClosedOrder': false,
'fetchClosedOrders': true,
'fetchConvertCurrencies': true,
'fetchConvertQuote': true,
'fetchConvertTrade': true,
'fetchConvertTradeHistory': true,
'fetchCurrencies': true,
'fetchDepositAddress': true,
'fetchDepositAddresses': false,
'fetchDepositAddressesByNetwork': false,
'fetchDeposits': true,
'fetchDepositsWithdrawals': true,
'fetchFundingHistory': true,
'fetchFundingInterval': true,
'fetchFundingIntervals': false,
'fetchFundingRate': true,
'fetchFundingRateHistory': true,
'fetchFundingRates': true,
'fetchIndexOHLCV': false,
'fetchLedger': true,
'fetchLeverage': true,
'fetchMarginAdjustmentHistory': false,
'fetchMarginMode': false,
'fetchMarkets': true,
'fetchMarkOHLCV': false,
'fetchMyTrades': true,
'fetchOHLCV': true,
'fetchOpenInterestHistory': false,
'fetchOpenOrder': false,
'fetchOpenOrders': true,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrders': true,
'fetchOrderTrades': true,
'fetchPosition': true,
'fetchPositionADLRank': true,
'fetchPositionHistory': false,
'fetchPositionMode': false,
'fetchPositions': true,
'fetchPositionsADLRank': true,
'fetchPositionsHistory': false,
'fetchPremiumIndexOHLCV': false,
'fetchStatus': true,
'fetchTicker': false,
'fetchTickers': false,
'fetchTime': true,
'fetchTrades': true,
'fetchTradingFee': true,
'fetchTradingFees': true,
'fetchTransactions': 'emulated',
'fetchTransfers': true,
'fetchWithdrawals': true,
'reduceMargin': false,
'sandbox': true,
'setLeverage': true,
'setMargin': false,
'setPositionMode': true,
'transfer': true,
'withdraw': true, // exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://docx.woo.io/wootrade-documents/#token-withdraw
},
'timeframes': {
'1m': '1m',
'5m': '5m',
'15m': '15m',
'30m': '30m',
'1h': '1h',
'4h': '4h',
'12h': '12h',
'1d': '1d',
'1w': '1w',
'1M': '1mon',
'1y': '1y',
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg',
'api': {
'pub': 'https://api-pub.woox.io',
'public': 'https://api.{hostname}',
'private': 'https://api.{hostname}',
},
'test': {
'pub': 'https://api-pub.staging.woox.io',
'public': 'https://api.staging.woox.io',
'private': 'https://api.staging.woox.io',
},
'www': 'https://woox.io/',
'doc': [
'https://docs.woox.io/',
],
'fees': [
'https://support.woox.io/hc/en-001/articles/4404611795353--Trading-Fees',
],
'referral': {
'url': 'https://woox.io/register?ref=DIJT0CNL',
'discount': 0.35,
},
},
'api': {
'v1': {
'pub': {
'get': {
'hist/kline': 10,
'hist/trades': 10,
},
},
'public': {
'get': {
'info': 1,
'info/{symbol}': 1,
'system_info': 1,
'market_trades': 1,
'token': 1,
'token_network': 1,
'funding_rates': 1,
'funding_rate/{symbol}': 1,
'funding_rate_history': 1,
'futures': 1,
'futures/{symbol}': 1,
'orderbook/{symbol}': 1,
'kline': 1,
},
},
'private': {
'get': {
'client/token': 1,
'order/{oid}': 1,
'client/order/{client_order_id}': 1,
'orders': 1,
'client/trade/{tid}': 1,
'order/{oid}/trades': 1,
'client/trades': 1,
'client/hist_trades': 1,
'staking/yield_history': 1,
'client/holding': 1,
'asset/deposit': 10,
'asset/history': 60,
'sub_account/all': 60,
'sub_account/assets': 60,
'sub_account/asset_detail': 60,
'sub_account/ip_restriction': 10,
'asset/main_sub_transfer_history': 30,
'token_interest': 60,
'token_interest/{token}': 60,
'interest/history': 60,
'interest/repay': 60,
'funding_fee/history': 30,
'positions': 3.33, // 30 requests per 10 seconds
'position/{symbol}': 3.33,
'client/transaction_history': 60,
'client/futures_leverage': 60,
},
'post': {
'order': 1, // 10 requests per 1 second per symbol
'order/cancel_all_after': 1,
'asset/ltv': 30,
'asset/internal_withdraw': 30,
'interest/repay': 60,
'client/account_mode': 120,
'client/position_mode': 5,
'client/leverage': 120,
'client/futures_leverage': 30,
'client/isolated_margin': 30,
},
'delete': {
'order': 1,
'client/order': 1,
'orders': 1,
'asset/withdraw': 120, // implemented in ccxt, disabled on the exchange side https://docx.woo.io/wootrade-documents/#cancel-withdraw-request
},
},
},
'v2': {
'private': {
'get': {
'client/holding': 1,
},
},
},
'v3': {
'public': {
'get': {
'systemInfo': 1, // 10/1s
'instruments': 1, // 10/1s
'token': 1, // 10/1s
'tokenNetwork': 1, // 10/1s
'tokenInfo': 1, // 10/1s
'marketTrades': 1, // 10/1s
'marketTradesHistory': 1, // 10/1s
'orderbook': 1, // 10/1s
'kline': 1, // 10/1s
'klineHistory': 1, // 10/1s
'futures': 1, // 10/1s
'fundingRate': 1, // 10/1s
'fundingRateHistory': 1, // 10/1s
'insuranceFund': 1, // 10/1s
},
},
'private': {
'get': {
'trade/order': 2, // 5/1s
'trade/orders': 1, // 10/1s
'trade/algoOrder': 1, // 10/1s
'trade/algoOrders': 1, // 10/1s
'trade/transaction': 1, // 10/1s
'trade/transactionHistory': 5, // 2/1s
'trade/tradingFee': 5, // 2/1s
'account/info': 60, // 10/60s
'account/tokenConfig': 1, // 10/1s
'account/symbolConfig': 1, // 10/1s
'account/subAccounts/all': 60, // 10/60s
'account/referral/summary': 60, // 10/60s
'account/referral/rewardHistory': 60, // 10/60s
'account/credentials': 60, // 10/60s
'asset/balances': 1, // 10/1s
'asset/token/history': 60, // 10/60s
'asset/transfer/history': 30, // 20/60s
'asset/wallet/history': 60, // 10/60s
'asset/wallet/deposit': 60, // 10/60s
'asset/staking/yieldHistory': 60, // 10/60s
'futures/positions': 3.33, // 30/10s
'futures/leverage': 60, // 10/60s
'futures/defaultMarginMode': 60, // 10/60s
'futures/fundingFee/history': 30, // 20/60s
'spotMargin/interestRate': 60, // 10/60s
'spotMargin/interestHistory': 60, // 10/60s
'spotMargin/maxMargin': 60, // 10/60s
'algo/order/{oid}': 1,
'algo/orders': 1,
'positions': 3.33,
'buypower': 1,
'convert/exchangeInfo': 1,
'convert/assetInfo': 1,
'convert/rfq': 60,
'convert/trade': 1,
'convert/trades': 1,
},
'post': {
'trade/order': 2, // 5/1s
'trade/algoOrder': 5, // 2/1s
'trade/cancelAllAfter': 1, // 10/1s
'account/tradingMode': 120, // 5/60s
'account/listenKey': 20, // 5/10s
'asset/transfer': 30, // 20/60s
'asset/wallet/withdraw': 60, // 10/60s
'spotMargin/leverage': 120, // 5/60s
'spotMargin/interestRepay': 60, // 10/60s
'algo/order': 5,
'convert/rft': 60,
},
'put': {
'trade/order': 2, // 5/1s
'trade/algoOrder': 2, // 5/1s
'futures/leverage': 60, // 10/60s
'futures/positionMode': 120, // 5/60s
'order/{oid}': 2,
'order/client/{client_order_id}': 2,
'algo/order/{oid}': 2,
'algo/order/client/{client_order_id}': 2,
},
'delete': {
'trade/order': 1, // 10/1s
'trade/orders': 1, // 10/1s
'trade/algoOrder': 1, // 10/1s
'trade/algoOrders': 1, // 10/1s
'trade/allOrders': 1, // 10/1s
'algo/order/{order_id}': 1,
'algo/orders/pending': 1,
'algo/orders/pending/{symbol}': 1,
'orders/pending': 1,
},
},
},
},
'fees': {
'trading': {
'tierBased': true,
'percentage': true,
'maker': this.parseNumber('0.0002'),
'taker': this.parseNumber('0.0005'),
},
},
'options': {
'timeDifference': 0, // the difference between system clock and exchange clock
'adjustForTimeDifference': false, // controls the adjustment logic upon instantiation
'sandboxMode': false,
'createMarketBuyOrderRequiresPrice': true,
// these network aliases require manual mapping here
'network-aliases-for-tokens': {
'HT': 'ERC20',
'OMG': 'ERC20',
'UATOM': 'ATOM',
'ZRX': 'ZRX',
},
'networks': {
'TRX': 'TRON',
'TRC20': 'TRON',
'ERC20': 'ETH',
'BEP20': 'BSC',
'ARB': 'Arbitrum',
},
'networksById': {
'TRX': 'TRC20',
'TRON': 'TRC20',
},
// override defaultNetworkCodePriorities for a specific currency
'defaultNetworkCodeForCurrencies': {
// 'USDT': 'TRC20',
// 'BTC': 'BTC',
},
'transfer': {
'fillResponseFromRequest': true,
},
'brokerId': 'bc830de7-50f3-460b-9ee0-f430f83f9dad',
},
'features': {
'default': {
'sandbox': true,
'createOrder': {
'marginMode': true,
'triggerPrice': true,
'triggerPriceType': {
'last': true,
'mark': true,
'index': false,
},
'triggerDirection': false,
'stopLossPrice': false, // todo by triggerPrice
'takeProfitPrice': false, // todo by triggerPrice
'attachedStopLossTakeProfit': undefined,
'timeInForce': {
'IOC': true,
'FOK': true,
'PO': true,
'GTD': true,
},
'hedged': false,
'trailing': true,
'leverage': false,
'marketBuyByCost': true,
'marketBuyRequiresPrice': false,
'selfTradePrevention': false,
'iceberg': true, // todo implement
},
'createOrders': undefined,
'fetchMyTrades': {
'marginMode': false,
'limit': 500,
'daysBack': 90,
'untilDays': 10000,
'symbolRequired': false,
},
'fetchOrder': {
'marginMode': false,
'trigger': true,
'trailing': false,
'symbolRequired': false,
},
'fetchOpenOrders': {
'marginMode': false,
'limit': 500,
'trigger': true,
'trailing': true,
'symbolRequired': false,
},
'fetchOrders': {
'marginMode': false,
'limit': 500,
'daysBack': undefined,
'untilDays': 100000,
'trigger': true,
'trailing': true,
'symbolRequired': false,
},
'fetchClosedOrders': {
'marginMode': false,
'limit': 500,
'daysBack': undefined,
'daysBackCanceled': undefined,
'untilDays': 100000,
'trigger': true,
'trailing': true,
'symbolRequired': false,
},
'fetchOHLCV': {
'limit': 1000,
},
},
'spot': {
'extends': 'default',
},
'forSwap': {
'extends': 'default',
'createOrder': {
'hedged': true,
},
},
'swap': {
'linear': {
'extends': 'forSwap',
},
'inverse': undefined,
},
'future': {
'linear': undefined,
'inverse': undefined,
},
},
'commonCurrencies': {},
'exceptions': {
'exact': {
'-1000': errors.OperationFailed, // { "code": -1000, "message": "An unknown error occurred while processing the request" } || {"success":false,"code":"-1000","message":"An internal error has occurred. We are unable to process your request. Please try again later."}
'-1001': errors.AuthenticationError, // { "code": -1001, "message": "The api key or secret is in wrong format" }
'-1002': errors.AuthenticationError, // { "code": -1002, "message": "API key or secret is invalid, it may because key have insufficient permission or the key is expired/revoked." }
'-1003': errors.RateLimitExceeded, // { "code": -1003, "message": "Rate limit exceed." }
'-1004': errors.BadRequest, // { "code": -1004, "message": "An unknown parameter was sent." }
'-1005': errors.BadRequest, // { "code": -1005, "message": "Some parameters are in wrong format for api." }
'-1006': errors.BadRequest, // { "code": -1006, "message": "The data is not found in server." }
'-1007': errors.BadRequest, // { "code": -1007, "message": "The data is already exists or your request is duplicated." }
'-1008': errors.InvalidOrder, // { "code": -1008, "message": "The quantity of settlement is too high than you can request." }
'-1009': errors.BadRequest, // { "code": -1009, "message": "Can not request withdrawal settlement, you need to deposit other arrears first." }
'-1012': errors.BadRequest, // { "code": -1012, "message": "Amount is required for buy market orders when margin disabled."} The place/cancel order request is rejected by internal module, it may because the account is in liquidation or other internal errors. Please try again in a few seconds." }
'-1101': errors.InvalidOrder, // { "code": -1101, "message": "The risk exposure for client is too high, it may cause by sending too big order or the leverage is too low. please refer to client info to check the current exposure." }
'-1102': errors.InvalidOrder, // { "code": -1102, "message": "The order value (price * size) is too small." }
'-1103': errors.InvalidOrder, // { "code": -1103, "message": "The order price is not following the tick size rule for the symbol." }
'-1104': errors.InvalidOrder, // { "code": -1104, "message": "The order quantity is not following the step size rule for the symbol." }
'-1105': errors.InvalidOrder, // { "code": -1105, "message": "Price is X% too high or X% too low from the mid price." }
'317136': errors.InvalidOrder, // Edit tpsl quantity is not allowed for quantity bracket
'317137': errors.InvalidOrder, // Edit quantity should edit both legs
'317138': errors.InvalidOrder, // Edit quantity should be same for both legs
'317139': errors.InvalidOrder, // Trigger price of 1st leg should not be empty for STOP_BRACKET
'317140': errors.InvalidOrder, // The quantity of a quantity TP/SL order should not be empty.
'317141': errors.InvalidOrder, // The algo quantity TP/SL limit order should have field price
'317142': errors.InvalidOrder, // The algo trigger type of quantity TP/SL should not be CLOSE_POSITION
'317143': errors.InvalidOrder, // The side of TP/SL legs should be the same
'317144': errors.InvalidOrder, // IndexPrice is not supported for non spot symbol `${symbol}`
'317145': errors.InvalidOrder, // same as INVALID_PRICE_QUOTE_MIN but different ‘code’
'317146': errors.InvalidOrder, // same as INVALID_PRICE_QUOTE_MAX but different ‘code’
'317147': errors.InvalidOrder, // same as INVALID_PRICE_TICKER_SIZE but different ‘code’
'317148': errors.BadRequest, // symbol can’t be empty.
'317149': errors.OrderNotFound, // same with TRADE_NOT_FOUND with different ErrorCodes
'317150': errors.InvalidOrder, // trigger price must be greater than `${price}`
'317151': errors.InvalidOrder, // trigger price must be less than `${price}`
'317152': errors.OrderNotFound, // The order not found for the order id : `${orderId}`
'317153': errors.OrderNotFound, // child order not found for the order id : `${orderId}`
'317154': errors.OperationFailed, // RPC failed: error: `${msg}`
'317155': errors.BadSymbol, // unsupported symbol: `${symbol}`
'317156': errors.BadSymbol, // unsupported symbol: `${symbol}`
'317157': errors.InvalidOrder, // Trading with `${symbol1}`/`${symbol2}` is temporarily suspended. Please try again later.
'317158': errors.InvalidOrder, // Trading with `${token}`-PERP is temporarily suspended. Please try again later.
'317159': errors.BadSymbol, // This pair is currently not supported.
'317160': errors.InvalidOrder, // The order id and symbol are not matched
'317161': errors.InvalidOrder, // The order is completed
'317162': errors.BadRequest, // The params should not be null or 0
'317163': errors.InvalidOrder, // cannot edit TP/SL quantity under bracket order
'317164': errors.InvalidOrder, // Invalid client order id
'317165': errors.InvalidOrder, // invalid order id list
'317166': errors.InvalidOrder, // invalid client order id list
'317167': errors.InvalidOrder, // unsupported algo type: `${algoType}`
'317168': errors.OperationFailed, // Order failed due to internal service error. Please contact customer service.
'317169': errors.InvalidOrder, // Trading with `${left}`/`${right}` is temporarily suspended. Please try again later.
'317170': errors.InvalidOrder, // The order quantity must bigger than the executed quantity.
'317171': errors.BadRequest, // error path format
'317172': errors.BadRequest, // The userId should not be null or 0
'317173': errors.BadRequest, // The orderId should not be null or 0
'317174': errors.InvalidOrder, // The order is processing
'317176': errors.InvalidOrder, // The trigger after should from 0 to `${maxTriggerAfter}`
'317177': errors.InvalidOrder, // Order has terminated
'317178': errors.BadRequest, // The receive window is invalid.
'317179': errors.BadRequest, // Request has failed as the receive window: `${recv_window}` millisecond is exceeded from `${api_timestamp}`
'317184': errors.OrderNotFound, // The order cannot be found, or it is already completed.
'317206': errors.InvalidOrder, // Spot trading is disabled while futures credits are active. Please remove or fully utilize your futures credits to enable spot trading.
'317207': errors.InsufficientFunds, // Request failed. Please ensure you have sufficient USDT to cover the futures credits currently in use.
'302001': errors.ExchangeError, // data status is not expected
'302002': errors.ExchangeError, // The data doesn’t exist.
'302003': errors.BadRequest, // The param number is invalid.
'302004': errors.BadRequest, // invalid params
'302005': errors.ExchangeError, // An error has occurred due to other pending requests. Please try again later.
'302101': errors.BadSymbol, // symbol is not exists
'302102': errors.InsufficientFunds, // Your margin is insufficient! Please liquidate assets.
'302103': errors.InsufficientFunds, // Your margin will be insufficient after withdrawal.
'302104': errors.InsufficientFunds, // Your margin will be insufficient after this action.
'302109': errors.OperationFailed, // create order engine error
'302110': errors.ExchangeError, // application is lock now
'302111': errors.InvalidOrder, // Your account position is being liquidated. Trading has been suspended at the moment. Please try again later.
'302112': errors.InvalidOrder, // Remaining order quantity is smaller than transaction quantity
'302113': errors.InvalidOrder, // Order side is not same as transaction side
'302114': errors.InvalidOrder, // Order price too small
'302115': errors.InvalidOrder, // Order quantity too small
'302117': errors.DuplicateOrderId, // The client_order_id is repeated.
'302118': errors.InsufficientFunds, // no enough balance to close
'302119': errors.InsufficientFunds, // Insufficient funds. Please enable margin trading. Note that certain coins do not allow for leverage trading.
'302120': errors.InvalidOrder, // Please lower the leverage ratio below 1.0 and close your short positions.
'302121': errors.InvalidOrder, // Please repay your interest.
'302122': errors.InvalidOrder, // Remaining order amount is smaller than transaction quantity
'302123': errors.ExchangeError, // user group data not found
'302125': errors.InvalidOrder, // Quantity should be less than your position.
'302126': errors.InvalidOrder, // Attempt failed. Please close your futures positions, cancel open orders and try again.
'302127': errors.InvalidOrder, // Your order is terminated.
'302128': errors.InsufficientFunds, // Insufficient `${token}`. Note that `${baseToken}` do not allow for margin trading.
'302129': errors.OrderNotFound, // The order doesn’t exist.
'302130': errors.InvalidOrder, // The order didn’t update.
'302131': errors.InvalidOrder, // Please enable futures trading in Margin & Futures tab. You can create subaccounts to separate margin and futures positions.
'302132': errors.InvalidOrder, // Attempt failed. Please close your negative positions and try again.
'302133': errors.InvalidOrder, // Please repay your interest.
'302134': errors.BadRequest, // The details are empty.
'302135': errors.BadRequest, // The amount must be positive.
'302136': errors.BadRequest, // Your balance must be positive.
'302137': errors.InvalidOrder, // You don’t have enough position for MKT close. Please check your open orders.
'302138': errors.InvalidOrder, // Insufficient position for reduce only order.
'302140': errors.InvalidOrder, // The order price is too small.
'302141': errors.InvalidOrder, // The order quantity is too small.
'302142': errors.InvalidOrder, // The order quantity must bigger than the executed quantity.
'302143': errors.ExchangeError, // Application not found.
'302144': errors.InvalidOrder, // There isn’t a positive amount to repay the interest balance.
'302145': errors.InsufficientFunds, // Your margin will be insufficient after disabling this token as collateral.
'302147': errors.InvalidOrder, // Amount is required for buy market orders when margin disabled.
'302148': errors.InvalidOrder, // Amount is required for ASK buy order when margin disabled.
'302149': errors.InvalidOrder, // Amount is required for BID buy order when margin disabled.
'302150': errors.InvalidOrder, // Quantity is required for sell market orders when margin disabled.
'302151': errors.InvalidOrder, // Quantity is required for ASK sell order when margin disabled.
'302152': errors.InvalidOrder, // Quantity is required for BID sell order when margin disabled.
'302154': errors.InsufficientFunds, // Insufficient `${stableToken}`.
'302155': errors.InsufficientFunds, // Insufficient `${token}`. Please enable margin trading for leverage trading.
'302156': errors.InvalidOrder, // Short selling `${token}` is not available now.
'302157': errors.InsufficientFunds, // Insufficient `${token}`. Please enable margin trading in Margin & Futures tab for spot leverage trading.
'302159': errors.RequestTimeout, // Your request has timed out. Please try again later.
'302160': errors.InvalidOrder, // Reduce only orders are only supported under spot pairs quoted by your account currency `${AccountCurrency}`.
'302162': errors.InvalidOrder, // You are not able to place this order under Reduce Only trading mode.
'302163': errors.InvalidOrder, // Reduce only orders are not allowed.
'302164': errors.InvalidOrder, // The order value should be greater or equal to `${minNotional}`.
'302165': errors.ExchangeError, // The token has no price.
'302166': errors.InvalidOrder, // Token balance cannot be negative under Spot Only.
'302167': errors.InvalidOrder, // Token balance cannot be negative under Spot & Futures.
'302168': errors.InvalidOrder, // The token is not enabled for margin.
'302169': errors.InsufficientFunds, // Collateral is not sufficient to cover initial margin requirements under Spot & Margin.
'302170': errors.InsufficientFunds, // Collateral is not sufficient to cover initial margin requirements under Spot & Futures.
'302171': errors.InvalidOrder, // Buy or sell orders by amount are not supported under Reduce Only trading mode.
'302172': errors.InvalidOrder, // `${token}` max position size of `${maxPosition}` is exceeded.
'302177': errors.InvalidOrder, // Pending new orders cannot be edited.
'302178': errors.InvalidOrder, // Order is rejected as you have an existing market close order.
'302185': errors.InvalidOrder, // Your order request cannot be processed at this moment because the position mode is currently being switched.
'302186': errors.InvalidOrder, // The position side you’ve used is not compatible with your current position mode.
'302188': errors.InvalidOrder, // exceed max open notional
'302189': errors.InvalidOrder, // Changing isolated position leverage is not allowed when there is a pending order.
'302190': errors.InvalidOrder, // Unable to adjust isolated margin while there are pending orders. Please cancel them to proceed.
'302191': errors.InvalidOrder, // Only adjustments to futures isolated margin are allowed.
'302192': errors.InvalidOrder, // The amount exceeds the withdrawable margin limit.
'302193': errors.InsufficientFunds, // The amount exceeds the available USDT balance.
'302194': errors.InvalidOrder, // Maximum number of isolated pending orders for `${symbol}` reached.
'302195': errors.InvalidOrder, // The position side you’ve used is invalid
'302196': errors.InvalidOrder, // Please use up all of your active futures credits before adding more.
'302197': errors.InvalidOrder, // Futures credits cannot be reduced while there are open positions.
'302198': errors.InvalidOrder, // Futures credits cannot be reduced while there are still pending orders.
'302199': errors.InvalidOrder, // Please switch to futures trading mode to adjust futures credits.
'302301': errors.InsufficientFunds, // The balance isn’t enough.
'302303': errors.InvalidOrder, // Too many pending orders on reduce only order
'302305': errors.InsufficientFunds, // Failed to update cross margin leverages due to insufficient margin. Please top up or close your cross positions to proceed.
'302306': errors.BadRequest, // Invalid leverage, please provide positive integer leverage
'302307': errors.AccountSuspended, // The account has been suspended
'302308': errors.InvalidOrder, // Attempt failed. Please close your futures positions, cancel open orders and try again.
'302309': errors.InvalidOrder, // Spot trading is disabled while futures credits are active. Please remove or fully utilize your futures credits to enable spot trading
'302310': errors.InsufficientFunds, // Request failed. Please ensure you have sufficient USDT to cover the futures credits currently in use.
'302311': errors.ExchangeError, // This request is currently being processed.
'302312': errors.ExchangeError, // This request is currently being processed.
'302313': errors.ExchangeError, // This request is currently being processed.
'302314': errors.InvalidOrder, // Quantity should be less than your position.
'302999': errors.ExchangeError, // An unknown error has occurred.
'311001': errors.ExchangeError, // The data status is invalid.
'311002': errors.ExchangeError, // The data does not exist.
'311004': errors.ExchangeError, // The parameters are invalid.
'311999': errors.OperationFailed, // There is a system error.
},
'broad': {
'Can not place': errors.ExchangeError, // { "code": -1011, "message": "Can not place/cancel orders, it may because internal network error. Please try again in a few seconds." }
'maintenance': errors.OnMaintenance, // {"code":"-1011","message":"The system is under maintenance.","success":false}
'symbol must not be blank': errors.BadRequest, // when sending 'cancelOrder' without symbol [-1005]
'The token is not supported': errors.BadRequest, // when getting incorrect token's deposit address [-1005]
'Your order and symbol are not valid or already canceled': errors.BadRequest, // actual response whensending 'cancelOrder' for already canceled id [-1006]
'Insufficient WOO. Please enable margin trading for leverage trading': errors.BadRequest, // when selling insufficient token [-1012]
},
},
'precisionMode': number.TICK_SIZE,
});
}
/**
* @method
* @name woo#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo
* @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.v3PublicGetSystemInfo(params);
//
// {
// "success": true,
// "data": {
// "status": 0,
// "msg": "System is functioning properly.",
// "estimatedEndTime": 1749963600362
// },
// "timestamp": 1751442989564
// }
//
const data = this.safeDict(response, 'data', {});
let status = this.safeString(data, 'status');
if (status === undefined) {
status = 'error';
}
else if (status === '0') {
status = 'ok';
}
else {
status = 'maintenance';
}
return {
'status': status,
'updated': undefined,
'eta': undefined,
'url': undefined,
'info': response,
};
}
/**
* @method
* @name woo#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo
* @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.v3PublicGetSystemInfo(params);
//
// {
// "success": true,
// "data": {
// "status": 0,
// "msg": "System is functioning properly.",
// "estimatedEndTime": 1749963600362
// },
// "timestamp": 1751442989564
// }
//
return this.safeInteger(response, 'timestamp');
}
/**
* @method
* @name woo#fetchMarkets
* @description retrieves data on all markets for woo
* @see https://developer.woox.io/api-reference/endpoint/public_data/instruments
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
async fetchMarkets(params = {}) {
if (this.options['adjustForTimeDifference']) {
await this.loadTimeDifference();
}
const response = await this.v3PublicGetInstruments(params);
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "SPOT_AAVE_USDT",
// "status": "TRADING",
// "baseAsset": "AAVE",
// "baseAssetMultiplier": 1,
// "quoteAsset": "USDT",
// "quoteMin": "0",
// "quoteMax": "100000",
// "quoteTick": "0.01",
// "baseMin": "0.005",
// "baseMax": "5000",
// "baseTick": "0.0001",
// "minNotional": "1",
// "bidCapRatio": "1.1",
// "bidFloorRatio": null,
// "askCapRatio": null,
// "askFloorRatio": "0.9",
// "orderMode": "NORMAL",
// "impactNotional": null,
// "isAllowedRpi": false,
// "tickGranularity": null
// }
// ]
// },
// "timestamp": 1751512951338
// }
//
const data = this.safeDict(response, 'data', {});
const rows = this.safeList(data, 'rows', []);
return this.parseMarkets(rows);
}
parseMarket(market) {
const marketId = this.safeString(market, 'symbol', '');
const parts = marketId.split('_');
const first = this.safeString(parts, 0);
let marketType = undefined;
let spot = false;
let swap = false;
if (first === 'SPOT') {
spot = true;
marketType = 'spot';
}
else if (first === 'PERP') {
swap = true;
marketType = 'swap';
}
const baseId = this.safeString(parts, 1);
const quoteId = this.safeString(parts, 2);
const base = this.safeCurrencyCode(baseId);
const quote = this.safeCurrencyCode(quoteId);
let settleId = undefined;
let settle = undefined;
let symbol = base + '/' + quote;
let contractSize = undefined;
let linear = undefined;
let inverse = undefined;
let margin = true;
const contract = swap;
if (contract) {
margin = false;
settleId = this.safeString(parts, 2);
settle = this.safeCurrencyCode(settleId);
symbol = base + '/' + quote + ':' + settle;
contractSize = this.parseNumber('1');
linear = true;
inverse = false;
}
const active = this.safeString(market, 'status') === 'TRADING';
return this.safeMarketStructure({
'id': marketId,
'symbol': symbol,
'base': base,
'quote': quote,
'settle': settle,
'baseId': baseId,
'quoteId': quoteId,
'settleId': settleId,
'type': marketType,
'spot': spot,
'margin': margin,
'swap': swap,
'future': false,
'option': false,
'active': active,
'contract': contract,
'linear': linear,
'inverse': inverse,
'contractSize': contractSize,
'expiry': undefined,
'expiryDatetime': undefined,
'strike': undefined,
'optionType': undefined,
'precision': {
'amount': this.safeNumber(market, 'baseTick'),
'price': this.safeNumber(market, 'quoteTick'),
},
'limits': {
'leverage': {
'min': undefined,
'max': undefined,
},
'amount': {
'min': this.safeNumber(market, 'baseMin'),
'max': this.safeNumber(market, 'baseMax'),
},
'price': {
'min': this.safeNumber(market, 'quoteMin'),
'max': this.safeNumber(market, 'quoteMax'),
},
'cost': {
'min': this.safeNumber(market, 'minNotional'),
'max': undefined,
},
},
'created': undefined,
'info': market,
});
}
/**
* @method
* @name woo#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://developer.woox.io/api-reference/endpoint/public_data/marketTrades
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
if (this.markets === undefined) {
await this.loadMarkets();
}
const market = this.market(symbol);
const request = {
'symbol': market['id'],
};
if (limit !== undefined) {
request['limit'] = limit;
}
const response = await this.v3PublicGetMarketTrades(this.extend(request, params));
//
// {
// "success": true,
// "data": {
// "rows": [
// {
// "symbol": "SPOT_BTC_USDT",
// "side": "SELL",
// "source": 0,
// "executedPrice": "108741.01",
// "executedQuantity": "0.02477",
// "executedTimestamp": 1751513940144
// }
// ]
// },
// "timestamp": 1751513988543
// }
//
const data = this.safeDict(response, 'data', {});
const rows = this.safeList(data, 'rows', []);
return this.parseTrades(rows, market, since, limit);
}
parseTrade(trade, market = undefined) {
//
// public/market_trades
//
// {
// "symbol": "SPOT_BTC_USDT",
// "side": "SELL",
// "source": 0,
// "executedPrice": "108741.01",
// "executedQuantity": "0.02477",
// "executedTimestamp": 1751513940144
// }
//
// fetchOrderTrades, fetchOrder
//
// {
// "id": 1734947821,
// "symbol": "SPOT_