v1 to v2
Migration guide from SDK v1 to v2 - upgrade to vault-based architecture and new features
This guide covers the migration from STON.fi SDK v1 to v2.
Overview
SDK v2 introduces architectural improvements and new contract types:
Support for CPI (Constant Product with Concentrated Liquidity) pools
Support for WStable (Weighted Stable) pools
New routing architecture
Enhanced utility functions for handling jetton amounts
Factory helpers for contract instantiation
Breaking Changes
Router and Pool Method Calls
The base Router and Pool method calls are now deprecated. You must specify the pool type explicitly.
v1:
import { DEX } from '@ston-fi/sdk';
const router = new DEX.v1.Router(address);
const swapParams = await router.getSwapJettonToJettonTxParams({
// parameters
});v2:
New Contract Types
v2 adds support for different pool types:
New Features
Utility Functions
New functions for handling jetton amounts with decimals:
Factory Functions
New factory helpers for creating contract instances:
Migration Steps
Update Package
Update Router/Pool Calls
Replace all direct
RouterandPoolcalls with typed versions:Update Method Calls
Most method signatures remain the same, just the class instantiation changes:
Use New Utilities
When working with token amounts, use the new utility functions:
Code Examples
Swap Migration
v1:
v2:
Pool Operations Migration
v1:
v2:
Working with Different Pool Types
Backwards Compatibility
The SDK v2 maintains compatibility with existing smart contracts
Method signatures remain largely unchanged
The main change is in how you instantiate Router and Pool classes
Common Issues
TypeScript Errors
If you see TypeScript errors about missing CPI or WStable properties, ensure you're using the correct import:
Runtime Errors
If you encounter "method not found" errors, verify you're using the correct pool type for your target pool.
Need Help?
Review the SDK documentation
Check the CHANGELOG for detailed changes
Ask in Telegram
Last updated