Skip to content

Commit

Permalink
fix(okx): fix #22228 (#22402)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcriadoperez committed May 6, 2024
1 parent 2270634 commit 0e2adae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
19 changes: 18 additions & 1 deletion ts/src/okx.ts
Expand Up @@ -2,7 +2,7 @@
// ---------------------------------------------------------------------------

import Exchange from './abstract/okx.js';
import { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, InsufficientFunds, InvalidNonce, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, BadSymbol, RateLimitExceeded, NetworkError, CancelPending, NotSupported, AccountNotEnabled, ContractUnavailable } from './base/errors.js';
import { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, DDoSProtection, PermissionDenied, InsufficientFunds, InvalidNonce, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, BadSymbol, RateLimitExceeded, NetworkError, CancelPending, NotSupported, AccountNotEnabled, ContractUnavailable } from './base/errors.js';
import { Precise } from './base/Precise.js';
import { TICK_SIZE } from './base/functions/number.js';
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
Expand Down Expand Up @@ -891,7 +891,24 @@ export default class okx extends Exchange {
'60017': BadRequest, // Invalid url path
'60018': BadRequest, // The {0} {1} {2} {3} {4} does not exist
'60019': BadRequest, // Invalid op {op}
'60020': ExchangeError, // APIKey subscription amount exceeds the limit
'60021': AccountNotEnabled, // This operation does not support multiple accounts login
'60022': AuthenticationError, // Bulk login partially succeeded
'60023': DDoSProtection, // Bulk login requests too frequent
'60024': AuthenticationError, // Wrong passphrase
'60025': ExchangeError, // Token subscription amount exceeds the limit
'60026': AuthenticationError, // Batch login by APIKey and token simultaneously is not supported
'60027': ArgumentsRequired, // Parameter {0} can not be empty
'60028': NotSupported, // The current operation is not supported by this URL
'60029': AccountNotEnabled, // Only users who are VIP5 and above in trading fee tier are allowed to subscribe to books-l2-tbt channel
'60030': AccountNotEnabled, // Only users who are VIP4 and above in trading fee tier are allowed to subscribe to books50-l2-tbt channel
'60031': AuthenticationError, // The WebSocket endpoint does not support multiple account batch login,
'60032': AuthenticationError, // API key doesn't exist,
'63999': ExchangeError, // Internal system error
'64000': BadRequest, // Subscription parameter uly is unavailable anymore, please replace uly with instFamily. More details can refer to: https://www.okx.com/help-center/changes-to-v5-api-websocket-subscription-parameter-and-url,
'64001': BadRequest, // This channel has been migrated to the business URL. Please subscribe using the new URL. More details can refer to: https://www.okx.com/help-center/changes-to-v5-api-websocket-subscription-parameter-and-url,
'64002': BadRequest, // This channel is not supported by business URL. Please use "/private" URL(for private channels), or "/public" URL(for public channels). More details can refer to: https://www.okx.com/help-center/changes-to-v5-api-websocket-subscription-parameter-and-url,
'64003': AccountNotEnabled, // Your trading fee tier doesnt meet the requirement to access this channel
'70010': BadRequest, // Timestamp parameters need to be in Unix timestamp format in milliseconds.
'70013': BadRequest, // endTs needs to be bigger than or equal to beginTs.
'70016': BadRequest, // Please specify your instrument settings for at least one instType.
Expand Down
19 changes: 6 additions & 13 deletions ts/src/pro/okx.ts
Expand Up @@ -2,7 +2,7 @@
// ---------------------------------------------------------------------------

import okxRest from '../okx.js';
import { ArgumentsRequired, AuthenticationError, BadRequest, InvalidNonce } from '../base/errors.js';
import { ArgumentsRequired, BadRequest, ExchangeError, InvalidNonce } from '../base/errors.js';
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
import type { Int, OrderSide, OrderType, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Position, Balances, Num } from '../base/types.js';
Expand Down Expand Up @@ -1562,27 +1562,20 @@ export default class okx extends okxRest {
// { event: 'error', msg: "Illegal request: {"op":"subscribe","args":["spot/ticker:BTC-USDT"]}", code: "60012" }
// { event: 'error", msg: "channel:ticker,instId:BTC-USDT doesn"t exist", code: "60018" }
//
const errorCode = this.safeInteger (message, 'code');
const errorCode = this.safeString (message, 'code');
try {
if (errorCode) {
if (errorCode && errorCode !== '0') {
const feedback = this.id + ' ' + this.json (message);
this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback);
const messageString = this.safeValue (message, 'msg');
if (messageString !== undefined) {
this.throwBroadlyMatchedException (this.exceptions['broad'], messageString, feedback);
}
throw new ExchangeError (feedback);
}
} catch (e) {
if (e instanceof AuthenticationError) {
const messageHash = 'authenticated';
client.reject (e, messageHash);
if (messageHash in client.subscriptions) {
delete client.subscriptions[messageHash];
}
return false;
} else {
client.reject (e);
}
client.reject (e);
return false;
}
return message;
}
Expand Down

0 comments on commit 0e2adae

Please sign in to comment.