How to Properly Handle STON.fi Swap Failures Across All Execution Stages

Developers building on STON.fi must account for swap failures at multiple distinct stages — including simulation, transaction building, wallet approval, submission, and on-chain execution — rather than treating all errors as a single generic exception. Because TON contract interactions are asynchronous, a successful TonConnect sendTransaction() call only confirms the message was broadcast, not that the swap completed successfully. Experts recommend implementing a multi-state status machine with states such as 'submitted', 'confirming', 'refunded', and 'failed' instead of relying on a simple loading flag. STON.fi's v2 integration guidance also advises against hardcoding router addresses, recommending an API-driven workflow that dynamically selects the correct router version. Pre-submission checks — including network validation, token decimals, and sufficient TON balance — are essential before opening the wallet connection.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in