Developers who have gotten a STON.fi token swap to run in a sandbox are now being warned that the jump to mainnet can wipe out user funds if a few seemingly harmless shortcuts are left in the code. A community-authored checklist released on a developer blog outlines the exact points where most integrations fail and offers a concrete recipe for a production-ready launch.
Why the transition matters
STON.fi provides a router that aggregates liquidity across multiple DEXes on the TON blockchain. Projects that want to offer users a one-click swap typically call the router from a front-end or a smart-contract wrapper. In a test environment the router address is static, the fee schedule is known, and the sandbox tolerates mis-directed transactions. On mainnet, however, the router can be upgraded, fee parameters can change, and a single misplaced address sends real tokens to a dead contract. The financial stakes are therefore the difference between a smooth user experience and a loss that can damage a project’s reputation overnight.
The most common mistake: hard-coding values
A recurring pattern in failed launches is the hard-coding of the router address or fee constants that were valid during testing. When STON.fi upgrades its router—a routine event to improve performance or patch bugs—the hard-coded address no longer points to a functional contract. The integration either throws an error that users never see or, worse, silently routes funds to an address that cannot process them. The community guide stresses a single rule: let the STON.fi REST API decide which router to use.
A step-by-step safety checklist
The checklist breaks the migration process into four logical layers—environment, contract interaction, fee calculation, and edge-case handling.
Validate environment variables early. Point the WebSocket endpoint and the REST API base URL at the sandbox while testing; switch them to mainnet nodes before launch. A typo here can redirect a real swap to the test router, locking tokens forever.
Never embed contract addresses. Run a simulation request against the STON.fi API, pull the current router address from the response, and feed it into your
dexFactory(or equivalent contract-factory) at runtime. This automatically adapts to any future router upgrade.Compute fees on the fly. Pull fee parameters from the API’s configuration payload and use them in your fee-math routine. Hard-coded percentages become obsolete the moment the platform tweaks its economics.
Prefer the official SDK and TonConnect. The SDK builds BOC (Bag of Cells) structures for you and includes checks for gas limits, data encoding, and signature validation. Manual BOC compilation should be reserved for highly specialized use-cases the SDK cannot cover.
Exercise failure-mode testing. Simulate out-of-gas scenarios, insufficient allowance, and malformed replies in the sandbox. Verify that your contract refunds the user or emits a clear error event. Relying on users to discover these bugs in production invites churn.
Confirm referral withdrawal paths. In the second version of the DEX, referral fees land in a dedicated Vault contract instead of a wallet. Your integration must call the Vault’s withdrawal method and handle the received tokens before crediting the referrer’s account.
What developers are debating
Some developers argue that the SDK adds unnecessary overhead and that a handcrafted BOC payload can be smaller and cheaper in gas. The guide acknowledges this view but points out that the SDK also bundles updates to the router address and fee schema, meaning a manually built payload must be revisited after every STON.fi upgrade. The trade-off is therefore between marginal gas savings and the risk of a silent breakage.
What to watch next
- Router upgrade announcements. STON.fi posts upcoming router changes on its developer channel. Subscribing to those feeds lets you pre-emptively test the new address in a sandbox before the mainnet switch.
- Fee-parameter revisions. Because fee percentages can be adjusted to respond to market conditions, bake a periodic pull of the configuration endpoint into any monitoring service.
- SDK version releases. New SDK releases often include bug fixes for edge cases discovered after a mainnet launch. Keeping the SDK up to date is as important as updating the router address.
Poin utamanya jelas: swap yang “berhasil dalam pengujian” tidak secara otomatis menjamin pengalaman mainnet yang aman. Dengan mengambil setiap nilai kritis—mulai dari alamat router hingga jadwal biaya—langsung dari API STON.fi yang aktif, serta dengan menguji jalur kesalahan secara ketat sebelum pengguna melihat antarmuka tersebut, pengembang dapat melindungi dana pengguna dan menjaga kepercayaan saat mereka memasuki tahap produksi akhir.
Sumber: https://dev.to/web3kd/the-last-mile-taking-a-stonfi-integration-from-test-network-to-real-users-2ho0
