Skip to content

Map OKX error code 51005 (honeypot token) to NotFound#4293

Merged
squadgazzz merged 2 commits intomainfrom
okx-map-honeypot-error-code
Mar 25, 2026
Merged

Map OKX error code 51005 (honeypot token) to NotFound#4293
squadgazzz merged 2 commits intomainfrom
okx-map-honeypot-error-code

Conversation

@squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Mar 24, 2026

Description

Map undocumented OKX error code 51005 to NotFound instead of the generic Api error.

OKX returns this code for tokens flagged as honeypots or leveraged tokens (e.g. "0x.. cannot be traded as it may be a honeypot or leveraged token"). This is functionally identical to 82104 (token not supported) - the token simply can't be traded. Previously, it fell through to Error::Api and produced unnecessary warn-level logs. We've encountered false-positive alerts for the Tornado.Cash token, which doesn't seem to be a honeypot at all.

Code 51005 is not in the OKX error code docs.

How to test

Existing tests

Undocumented OKX error code for tokens flagged as honeypots or
leveraged tokens. These can't be traded and should be treated the
same as unsupported tokens rather than logging at warn level.
@squadgazzz squadgazzz requested a review from a team as a code owner March 24, 2026 19:42
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new error code 51005 to the handle_api_error function in crates/solvers/src/infra/dex/okx/mod.rs, mapping it to Error::NotFound for undocumented honeypot or leveraged token issues. I have no feedback to provide on the current changes.

Copy link
Contributor

@jmg-duarte jmg-duarte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

FYI: this seems documented in a different OKX offering API https://tr.okx.com/docs-v5/en/#error-code-rest-api-public (you'll need to search for the code). Super weird...

@squadgazzz
Copy link
Contributor Author

FYI: this seems documented in a different OKX offering API tr.okx.com/docs-v5/en#error-code-rest-api-public (you'll need to search for the code). Super weird...

It looks like a different API. The error code is about the order amount, which is irrelevant to the response we receive.

@squadgazzz squadgazzz added the hotfix Labels PRs that should be applied into production right away label Mar 25, 2026
@squadgazzz squadgazzz added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit f962723 Mar 25, 2026
19 checks passed
@squadgazzz squadgazzz deleted the okx-map-honeypot-error-code branch March 25, 2026 09:47
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

hotfix Labels PRs that should be applied into production right away

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants