fix(ton-trading-bot): surface per-DEX errors in get_arbitrage_opportunities#108
Merged
xlabtg merged 3 commits intoxlabtg:mainfrom Apr 5, 2026
Merged
fix(ton-trading-bot): surface per-DEX errors in get_arbitrage_opportunities#108xlabtg merged 3 commits intoxlabtg:mainfrom
xlabtg merged 3 commits intoxlabtg:mainfrom
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: xlabtg#102
…nities
Previously, sdk.ton.dex.quote() failures were silently swallowed and
returned a generic "Could not fetch DEX quotes" message with no indication
of which DEX failed or why.
Switch to individual quoteSTONfi / quoteDeDust calls run in parallel so:
- Each DEX failure is logged with its specific error message and the
affected asset pair (e.g. "StonFi quote failed for TON→USDT: …")
- When all DEXes fail, the error response includes per-DEX details
("Could not fetch DEX quotes — stonfi: …; dedust: …")
- When only one DEX fails, the function continues and returns partial
results instead of aborting entirely
- Remove unsupported tonco/swapcoffee keys from dexFees (the SDK
only exposes quoteSTONfi and quoteDeDust)
Tests added:
- error message includes actual DEX error, not the generic message
- succeeds with partial quotes when only one DEX fails
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:Claude Sonnet 4.6:
Total input tokens: 52.2K + 1.6M cached Claude Haiku 4.5:
Total input tokens: 43.6K + 777.9K cached 🤖 Models used:
📎 Log file uploaded as Gist (1327KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
Author
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit ab305cd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ton_trading_get_arbitrage_opportunitiesconsistently fails with the generic error "Could not fetch DEX quotes" (fixes #102).The root cause was two-fold:
sdk.ton.dex.quote()(aggregated) but that method's failure was silently caught and turned into anull— the actual error was only logged as a warning, invisible to the caller.dexFeeslistedtoncoandswapcoffeeas expected DEX keys, but the SDK only exposesquoteSTONfiandquoteDeDust— so those entries could never be populated.Fix
sdk.ton.dex.quote()to individualsdk.ton.dex.quoteSTONfi()/sdk.ton.dex.quoteDeDust()calls run in parallel.StonFi quote failed for TON→USDT: Router contract not found).Could not fetch DEX quotes — stonfi: …; dedust: ….tonco/swapcoffeefromdexFees— the SDK does not expose quote methods for those DEXes.How to reproduce
Tests added
error message includes the actual DEX error, not just a generic messagesucceeds with partial quotes when only one DEX failssuccess: truewith an empty opportunities list rather than failing completely when one DEX is unavailableAll 106 tests pass locally (
node --test plugins/ton-trading-bot/tests/index.test.js).🤖 Generated with Claude Code