Price Impact
What is Price Impact?
Small swap: Uses 1 bin → Low impact
Large swap: Uses 5 bins → High impactBasic Impact Calculation
async function calculatePriceImpact(
pair: LBPair,
amountIn: bigint,
xtoy: boolean
): Promise<number> {
// Get spot price
const spotPrice = getPriceFromBinId(
pair.parameters.active_id,
Number(pair.binStep)
);
// Calculate output
const amountOut = await calculateSwapOutput(pair, amountIn, xtoy);
// Calculate execution price
const executionPrice = xtoy
? Number(amountOut) / Number(amountIn)
: Number(amountIn) / Number(amountOut);
// Price impact percentage
return ((executionPrice - spotPrice) / spotPrice) * 100;
}Bin-by-Bin Analysis
Impact Thresholds
Depth Chart Analysis
Optimal Trade Size
Real-Time Display
Key Insights
Related Topics
Last updated