Swap
Execute token swaps on Ferra pools.
Quick Start
// Simple swap: 1 SUI -> USDC
const swapParams = {
pool_id: '0x...',
coinTypeA: '0x2::sui::SUI',
coinTypeB: '0x...::usdc::USDC',
a2b: true, // SUI -> USDC
by_amount_in: true, // Fix input amount
amount: '1000000000', // 1 SUI
amount_limit: '990000', // Min 990 USDC (1% slippage)
}
const tx = await sdk.Swap.createSwapTransactionPayload(swapParams)
const result = await sdk.fullClient.signAndExecuteTransaction({
transaction: tx,
signer: keypair
})Swap Parameters
Parameter
Type
Description
Swap Directions
Swap A to B
Swap B to A
Fix Output Amount
Calculate Slippage
Gas Optimization (SUI)
Partner Swaps
Advanced Usage
Manual Coin Management
Batch Swaps
Complete Example
Error Handling
Important Notes
Last updated