Price Impact
Calculate and manage price impact for swaps in CLMM pools.
Quick Start
// Calculate price impact before swap
const pool = await sdk.Pool.getPool(poolId)
const ticks = await sdk.Pool.fetchTicks({
pool_id: poolId,
coinTypeA: pool.coinTypeA,
coinTypeB: pool.coinTypeB
})
const result = sdk.Swap.calculateRates({
currentPool: pool,
coinTypeA: pool.coinTypeA,
coinTypeB: pool.coinTypeB,
decimalsA: 9,
decimalsB: 6,
a2b: true,
byAmountIn: true,
amount: new BN('1000000000'), // 1 SUI
swapTicks: ticks
})
console.log(`Price Impact: ${result.priceImpactPct.toFixed(2)}%`)Understanding Price Impact
Calculate Methods
Method 1: Local Calculation
Method 2: From PreSwap
Router Price Impact
Impact Thresholds
Minimize Price Impact
1. Split Large Trades
2. Use Multiple Pools
Complete Example
Price Impact Formula
Important Notes
Last updated