> For the complete documentation index, see [llms.txt](https://doc.torch.finance/dex/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.torch.finance/dex/developer-guide/dex-sdk-guide/withdraw-liquidity.md).

# Withdraw Liquidity

This guide explains how to withdraw liquidity using the Torch Finance SDK, covering multiple scenarios and pools. The guide assumes the following setup:

* **Base Pools**: Liquidity pools composed of specific assets, represented by their respective LP tokens.
  * Examples:
    * **TON**, **tsTON**, and **stTON** → LP Token: **TriTon**
    * **USDT**, **USDC**, and **crvUSD** → LP Token: **TriUSD**
* **Meta Pools**: Liquidity pools built on top of Base Pools, combining Base Pool LP tokens with additional assets.
  * Examples:
    * **TriTon** + **hTON** → Meta Pool
    * **TriUSD** + **scrvUSD** → Meta Pool

***

## Modes of Withdrawal

### **Single Mode**

* Withdraw only one specific asset from the pool.
* May involve slippage depending on liquidity conditions.

### **Balanced Mode**

* Withdraw all assets in proportion to their pool balance.
* Ensures minimal slippage and avoids disrupting pool balance.
* **Cannot specify a particular asset to withdraw** in this mode.

***

## Example 1: Withdraw Only One Liquidity from the Base Pool

If you want to withdraw only **TON** liquidity from the **Base Pool**, you must specify the asset (`TON`) in **Single Mode**:

```typescript
const withdrawParams: WithdrawParams = {
  mode: "Single", // Single Mode: Withdraw one specific asset
  queryId,
  pool: LSDPoolAddress, // Base Pool address
  burnLpAmount: toUnit(0.01, LpDecimals), // Amount of Base Pool LP tokens (TriTon) to remove
  withdrawAsset: Asset.ton(), // Specify the asset to withdraw (TON)
};
```

* **Use Case**: This is ideal if you only need **TON** and want to avoid receiving other pool assets (e.g., **tsTON** or **stTON**).
* **Caution**: May result in slippage depending on pool liquidity.

## Example 2: Withdraw Liquidity in a Balanced Proportion from the Base Pool

If you want to withdraw liquidity proportionally across all assets in the **Base Pool** (**TON**, **tsTON**, and **stTON**), use **Balanced Mode**:

```typescript
const withdrawParams: WithdrawParams = {
  mode: "Balanced", // Balanced Mode: Withdraw all assets proportionally
  queryId,
  pool: LSDPoolAddress, // Base Pool address
  burnLpAmount: toUnit(0.01, LpDecimals), // Amount of Base Pool LP tokens (TriTon) to remove
};
```

* **Use Case**: Use this mode to receive all assets (TON, tsTON, stTON) in equal proportion.
* **Note**: Balanced Mode ensures minimal slippage and avoids skewing the pool’s balance.

## Example 3: Withdraw Liquidity from Both the Meta Pool and the Base Pool

If you want to withdraw liquidity from the **Meta Pool**, followed by a withdrawal from the **Base Pool**, remember:

{% hint style="warning" %}
You **cannot specify an asset** for the Meta Pool withdrawal under this scenario. Meta Pool withdrawals will only return **TriTon** tokens (LP tokens of the Base Pool) .
{% endhint %}

```typescript
const withdrawParams: WithdrawParams = {
  mode: "Single", // Meta Pool withdrawal mode
  queryId,
  pool: MetaPoolAddress, // Meta Pool address
  burnLpAmount: toUnit(0.01, LpDecimals), // Amount of Meta Pool LP tokens to remove
  nextWithdraw: {
    mode: "Balanced", // Base Pool withdrawal mode
    pool: LSDPoolAddress, // Base Pool address
  },
};
```

* **Use Case**: Withdraw Meta Pool liquidity, and then proportionally withdraw Base Pool liquidity to receive **TON**, **tsTON**, and **stTON**.
* **Note**: Meta Pool withdrawals output **TriTon** tokens, which can then be used for Base Pool withdrawals.

## Example 4: Withdraw from the Meta Pool and Retrieve Only **One Asset at the end**

If you want to withdraw from the **Meta Pool** and receive only **TON** as the final output, specify **Single Mode** in the Base Pool withdrawal step:

```typescript
const withdrawParams: WithdrawParams = {
  mode: "Single", // Meta Pool withdrawal mode
  queryId,
  pool: MetaPoolAddress, // Meta Pool address
  burnLpAmount: toUnit(0.01, LpDecimals), // Amount of Meta Pool LP tokens to remove
  nextWithdraw: {
    mode: "Single", // Base Pool withdrawal mode
    pool: LSDPoolAddress, // Base Pool address
    withdrawAsset: Asset.ton(), // Specify the final asset (TON)
  },
};

```

* **Use Case**: Withdraw liquidity from the Meta Pool and directly convert it to **TON** without receiving other Base Pool assets.
* **Caution**: This process involves two steps, and slippage may apply in the Base Pool withdrawal.

####
