Skip to main content

V3 Add Liquidity Example

A complete example of minting a V3 concentrated liquidity position with a custom price range.

Full Code

Key Points

  1. Token order matters: token0 must have a lower address than token1. The helper sortTokens() handles this.
  2. Tick alignment: tickLower and tickUpper must be multiples of tickSpacing. Use nearestUsableTick().
  3. Fee tier: Must match an existing pool. Check with factory.getPool() first.
  4. Slippage: Set amount0Min / amount1Min to non-zero values in production.
  5. Native KAS: If one token is KAS, send it as { value: kasAmount } in the mint call.

Managing the Position

After minting, use the tokenId for: