Magma Developer SDK
  • Getting started
  • Prerequisites
  • Features Available
  • Retrieve clmm pools
  • Retrieve positions
  • Retrieve reward
  • Retrieve ticks
  • Create clmm pool
  • Open position
  • Add liquidity
  • Remove liquidity
  • Close position
  • Collect fees
  • Collect rewards
  • Preswap
  • Swap
  • Partner swap
  • Smart router
  • Price impact
  • Minimum received & Maximum sold
  • Fee
  • Liquidity correlation calculation
  • APR correlation calculation
Powered by GitBook
On this page

Price impact

How to calculate price impact?

Price impact means the variation rate between the prices of the two coins in actual transactions and the pre-calculated prices.

The SDK providers the sdk.Swap.calculateSwapPriceImpact method to calculated it.

const res = await sdk.RouterV2.getBestRouter(USDT, USDC, 100000000, true, 5, '', undefined, true, false)

const priceImpact =  sdk.Swap.calculateSwapPriceImpact(res.result.splitPaths)
console.log('priceImpact: ', priceImpact )
PreviousSmart routerNextMinimum received & Maximum sold

Last updated 4 months ago