Smart Contracts
STON.fi smart contract documentation - technical references for v1 and v2 DEX contracts
Direct smart contract interaction documentation for the STON.fi DEX protocol.
Important: These docs describe the low-level smart contract architecture, methods, and opcodes. For production applications, we strongly recommend using the official SDK + TonConnect instead of manually compiling BOCs and sending transactions. The SDK provides better developer experience, handles edge cases, and receives official support. Custom BOC compilation should only be used for specialized/advanced use cases.
Contract Architecture
The DEX consists of four main contract types:
Router: Entry point for all operations
Pool: Manages liquidity and swaps for token pairs
Account: Tracks user liquidity positions
Wallet: Handles LP token operations
Versions
Latest contract implementation with:
Enhanced liquidity management
Vault system for fee collection
Optimized gas consumption
Original contract implementation:
Standard AMM functionality
Proven security and reliability
Key Differences Between Versions
Single-sided LP
❌
✅
Vault System
❌
✅
Gas Efficiency
Standard
Optimized
LP Token Burns
Manual
Automatic
Integration Considerations
Use the SDK for most integrations
Direct contract calls for advanced use cases
Always test on testnet first
Consider gas optimization strategies
Security
All contracts are:
Open source
Audited
Immutable (pools)
Time-locked (router upgrades)
Last updated