# Remove Liquidity Overview

Understand how to withdraw liquidity from DLMM positions, collect accumulated fees, and manage partial or complete exits from pools.

### What is Removing Liquidity?

In DLMM, removing liquidity means:

* Withdrawing tokens from specific bins
* Collecting accumulated trading fees
* Reducing or closing your position
* Receiving tokens based on current bin reserves

### Core Concepts

#### Partial vs Complete Removal

* **Partial**: Remove from selected bins only
* **Complete**: Withdraw all liquidity and fees
* **Close Position**: Complete removal + burn NFT

#### Token Returns

You receive tokens based on:

* Your share of each bin's reserves
* Accumulated fees in those bins
* Current price (may differ from entry)

#### Fee Collection

* Fees are automatically included in removal
* No separate claim transaction needed
* Proportional to your liquidity share

### The Workflow

#### 1. Check Position Status

```typescript
const bins = await sdk.Position.getPositionBins(pair, positionId);
const amounts = await sdk.Position.getPositionBinsAmount(pair, positionId);
```

#### 2. Calculate Expected Output

Preview what you'll receive:

```typescript
// Check each bin's value
amounts.forEach(bin => {
  console.log(`Bin ${bin.id}: ${bin.amountX} X, ${bin.amountY} Y`);
});
```

#### 3. Execute Removal

Two main options:

* Remove from specific bins
* Remove all and close position

### Removal Strategies

#### Range Exit

Remove liquidity outside active range:

```
Before: ████ ████ ████ ████ ████
After:  ████ ████ [active] 
        (removed)         (removed)
```

#### Profit Taking

Remove from bins with accumulated fees:

```
Fees:   Low  Low  HIGH  Low  Low
Action: Keep Keep REMOVE Keep Keep
```

#### Rebalancing

Remove and re-add with new distribution:

1. Remove from current bins
2. Calculate new optimal range
3. Add with updated strategy

### What You Receive

For each bin removed:

```
Your tokens = (Your liquidity / Total liquidity) × (Reserves + Fees)
```

Example:

* Your liquidity: 1000
* Total in bin: 10000
* Bin reserves: 50000 X, 100000 Y
* Your share: 10% of everything

### Important Considerations

#### Price Impact

* Current price may differ from entry
* Can result in more of one token
* This is impermanent loss realized

#### Gas Optimization

* Removing many bins costs more gas
* Consider batching operations
* Complete removal is gas-efficient

#### Timing

* No lock periods in DLMM
* Remove anytime markets are open
* Consider fee accumulation rates

### Common Patterns

#### Emergency Exit

```typescript
// Quick complete withdrawal
await sdk.Pair.removeAndClosePosition(pair, positionId);
```

#### Selective Removal

```typescript
// Remove only profitable bins
const profitableBins = bins.filter(b => b.fees > threshold);
await sdk.Pair.removeLiquidity(pair, {
  positionId,
  binIds: profitableBins.map(b => b.id)
});
```

#### Fee Harvesting

```typescript
// Remove and re-add to collect fees
// 1. Remove all
// 2. Add back immediately
```

### Next Steps

Choose your removal approach:

1. **Partial Removal**: [Remove from Specific Bins](/integration/dlmm/typescript-sdk/remove-liquidity/remove-from-specific-bins.md)
2. **Complete Exit**: [Remove All Liquidity](/integration/dlmm/typescript-sdk/remove-liquidity/remove-all-liquidity.md)
3. **Preview First**: [Calculate Output Amounts](/integration/dlmm/typescript-sdk/remove-liquidity/calculate-output-amounts.md)

### Related Topics

* [Position Management](/integration/dlmm/typescript-sdk/position-management.md) - Check bins
* [Close Position](/integration/dlmm/typescript-sdk/position-management/close-position.md) - Remove and burn
* [Calculate Position Fees](/integration/dlmm/typescript-sdk/fees-and-analytics/calculate-position-fees.md) - Track earnings


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ferra.ag/integration/dlmm/typescript-sdk/remove-liquidity/remove-liquidity-overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
