Skip to content

chore: Make BinanceAPI more robust#3055

Open
dijanin-brat wants to merge 9 commits intomasterfrom
dijanin-brat/fixBinanaceApiProxyFail
Open

chore: Make BinanceAPI more robust#3055
dijanin-brat wants to merge 9 commits intomasterfrom
dijanin-brat/fixBinanaceApiProxyFail

Conversation

@dijanin-brat
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Collaborator

@pxrl pxrl left a comment

Choose a reason for hiding this comment

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

Looks good - only minor comments 👍

const err = _err.toString();
if (KNOWN_BINANCE_ERROR_REASONS.some((errorReason) => err.includes(errorReason)) && nRetries < maxRetries) {
const err = stringifyBinanceError(_err);
const stringError = _err.toString();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Some errors we can read with _err.toString and for others we need to have more granular parsing. That is why we have both variations here so we cover both cases.

@pxrl
Copy link
Copy Markdown
Collaborator

pxrl commented Mar 25, 2026

@codex Review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 57412d4196

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +324 to +325
if (BINANCE_EMPTY_RESPONSE_ERROR_PATTERNS.some((r) => err.includes(r) || stringError.includes(r))) {
return [];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fail closed when withdrawal-history fetch fails

This change treats proxy/HTTP/parse failures from withdrawHistory as an empty successful response, which makes callers interpret an API outage as "no prior withdrawals." In binanceFinalizer, amountToFinalize is computed from deposits minus withdrawals, so if this endpoint fails while deposits/balances still load, the bot can re-withdraw already-finalized deposits and overpay recipients (limited only by current Binance balance). This should propagate an error (or explicitly mark the run degraded) instead of silently returning [].

Useful? React with 👍 / 👎.

);
routesWithCoins.push(route);
});
this.availableRoutes = routesWithCoins;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep route pruning consistent with rebalancer route evaluation

Pruning this.availableRoutes here can leave the Binance adapter with zero supported routes, but the rebalancer client still iterates its original rebalanceRoutes and invokes Binance getEstimatedCost/initializeRebalance on those routes. Because both methods assert supportsRoute, a transient accountCoins outage now leads to Route is not supported exceptions during rebalance evaluation rather than gracefully skipping Binance routes. The client-visible route set must be synchronized or calls should be gated by adapter.supportsRoute(route).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants