> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exponent.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Withdraw Liquidity

> Low-level instruction to withdraw liquidity from an LP position

# createWithdrawLiquidityInstruction

Builds a raw instruction to withdraw liquidity from an LP position and claim accumulated fees. This removes a specified amount of liquidity from the position, returning PT and SY tokens to the owner along with any accrued trading fees.

## Usage

```typescript theme={null}
import { createWithdrawLiquidityInstruction } from "@exponent-labs/exponent-sdk/client/clmm";
import { PublicKey, SystemProgram } from "@solana/web3.js";

const ix = createWithdrawLiquidityInstruction({
  owner: ownerKeypair.publicKey,
  market: marketAddress,
  lpPosition: lpPositionAccount,
  ticks: ticksAccount,
  tokenPtDst: ownerPtTokenAccount,
  tokenSyDst: ownerSyTokenAccount,
  tokenPtEscrow: marketPtEscrow,
  tokenSyEscrow: marketSyEscrow,
  addressLookupTable: lookupTableAddress,
  tokenProgram: tokenProgramId,
  syProgram: syProgramId,
  systemProgram: SystemProgram.programId,
  eventAuthority: eventAuthorityPda,
  program: clmmProgramId,
  liquidityToRemove: 500_000_000n,
  minPtOut: 200_000_000n,
  minSyOut: 200_000_000n,
});
```

## Accounts

| Name                 | Type        | Signer | Writable | Description                   |
| -------------------- | ----------- | ------ | -------- | ----------------------------- |
| `owner`              | `PublicKey` | Yes    | Yes      | Wallet withdrawing liquidity  |
| `market`             | `PublicKey` | No     | Yes      | The CLMM market account       |
| `lpPosition`         | `PublicKey` | No     | Yes      | LP position account           |
| `ticks`              | `PublicKey` | No     | Yes      | The market tick array account |
| `tokenPtDst`         | `PublicKey` | No     | Yes      | Owner's PT token account      |
| `tokenSyDst`         | `PublicKey` | No     | Yes      | Owner's SY token account      |
| `tokenPtEscrow`      | `PublicKey` | No     | Yes      | Market PT escrow account      |
| `tokenSyEscrow`      | `PublicKey` | No     | Yes      | Market SY escrow account      |
| `addressLookupTable` | `PublicKey` | No     | No       | Market address lookup table   |
| `tokenProgram`       | `PublicKey` | No     | No       | SPL Token program             |
| `syProgram`          | `PublicKey` | No     | No       | SY program                    |
| `systemProgram`      | `PublicKey` | No     | No       | System program                |
| `eventAuthority`     | `PublicKey` | No     | No       | Event authority PDA           |
| `program`            | `PublicKey` | No     | No       | CLMM program ID               |

## Args

| Name                | Type  | Description                     |
| ------------------- | ----- | ------------------------------- |
| `liquidityToRemove` | `u64` | Amount of LP tokens to withdraw |
| `minPtOut`          | `u64` | Minimum PT tokens to receive    |
| `minSyOut`          | `u64` | Minimum SY tokens to receive    |

## Returns

`TransactionInstruction` — a transaction instruction ready to be added to a transaction.
