Skip to main content
The add and remove liquidity functions enable users to earn LP fees by providing liquidity to pools.

Pool Types

Users can only add liquidity to constant product pools. Single-sided pools only receive an initial deposit of asset A, at which point they trade against a bonding curve until they bond. Constant product pools require an initial deposit of both assets.

Simulate Before Adding

Adding liquidity has to be done in the right ratio to maintain the pool’s price. Always simulate to check expected LP tokens and potential refunds:
If you add liquidity in the wrong ratio, you will be atomically refunded the excess asset.

Execute Liquidity Addition

Optimal Amount Calculation

Avoid refunds by calculating optimal amounts:

Tracking Your Position

Monitor LP Holdings

Calculate Returns

Track your investment performance:

Removing Liquidity

Simulate Removal

Check what you’ll receive before removing:

Execute Removal

Remove liquidity and claim accumulated fees:

Partial vs Full Removal

Complete Liquidity Lifecycle

Error Handling

The SDK provides typed errors with automatic fund recovery. See Error Handling for the complete guide.

Best Practices

  1. Always simulate first: Check expected outcomes before executing
  2. Track impermanent loss: Understand the risks of providing liquidity
  3. Regular monitoring: Check your position and fees periodically

Next Steps