Router Swap
Execute optimized swaps through Ferra's smart router for best rates.
Overview
Quick Start
// 1. Find best route
const bestRoute = await sdk.Router.getBestInternalRouter(
'0x2::sui::SUI', // From token
'0x...::usdc::USDC', // To token
new BN('1000000000'), // Amount (1 SUI)
true, // Fix input amount
0.01, // 1% slippage
'' // No partner
)
// 2. Create swap transaction
if (bestRoute && !bestRoute.isExceed) {
const tx = await TransactionUtil.buildRouterSwapTransaction(
sdk,
bestRoute.createTxParams,
true, // byAmountIn
allCoinAssets
)
const result = await sdk.fullClient.signAndExecuteTransaction({
transaction: tx,
signer: keypair
})
}Find Optimal Route
Basic Route Finding
With Fallback Options
Route Types
Single-Hop Route
Multi-Hop Route
Complete Swap Flow
Load Graph Data
Advanced Features
TVL-Based Routing
Custom Path Preferences
Fix Output Amount
Error Handling
Route Information
Important Notes
Last updated