Calculate Output Amounts

Preview exact token amounts you'll receive before removing liquidity. Essential for setting expectations and avoiding surprises from price movements.

Prerequisites

  • Position ID to analyze

  • Understanding of bin reserves and fees

  • Current pair state data

Basic Calculation

// Get amounts for all bins in position
const amounts = await sdk.Position.getPositionBinsAmount(pair, positionId);

// Calculate total returns
const totals = amounts.reduce((sum, bin) => ({
  x: sum.x + bin.amountX,
  y: sum.y + bin.amountY
}), { x: 0n, y: 0n });

console.log("Will receive:", {
  tokenX: formatUnits(totals.x, 18),
  tokenY: formatUnits(totals.y, 6)
});

Understanding the Calculation

For each bin, you receive:

The SDK's getPositionBinsAmount handles this automatically.

Preview Specific Bins

Manual Calculation Method

Compare to Initial Investment

Include Price Impact

Preview with Slippage

Common Patterns

Full Position Preview

Important Notes

  • Amounts include accumulated fees

  • Price changes affect token ratios

  • Calculation assumes no other trades

  • Always use recent data

Last updated