# Withdraw

Withdraw liquidity from vaults. Users can withdraw their LP tokens and receive the underlying assets.

```typescript
/**
 * @param {Object} params - The parameters for the calculateWithdrawAmount function.
 * @param {string} params.vault_id - The ID of the vault.
 * @param {boolean} params.fix_amount_a - Whether to fix the amount of token A. If true, the input_amount represents token A amount; if false, it represents token B amount.
 * @param {string} params.input_amount - The input amount. If is_ft_input is true, this is the LP token amount; if false, this is the token amount (either A or B based on fix_amount_a).
 * @param {number} params.slippage - The slippage percentage (eg: 0.01 = 1%)
 * @param {boolean} params.is_ft_input - Whether the input is LP token. If true, input_amount is LP token amount; if false, input_amount is token amount.
 * @param {InputType} params.side - The withdrawal type. Both for withdrawing both tokens, OneSide for withdrawing a single token.
 * @param {string} params.max_ft_amount - The amount of LP tokens held by the user. In OneSide mode, this value is used to balance the withdrawal amount.
 */
const result = await sdk.Vaults.calculateWithdrawAmount({
  vault_id,
  fix_amount_a: true,
  input_amount: '1000000000',
  slippage: 0.01,
  is_ft_input: false,
  side: InputType.Both,
  max_ft_amount: '',
})

/**
 * @param {Object} params - The parameters for the withdraw function.
 * @param {string} params.vault_id - The ID of the vault.
 * @param {number} params.slippage - The slippage percentage (0-1).
 * @param {string} params.ft_amount - The amount of LP tokens to burn.
 * @param {string} params.return_coin - Optional. If set to true, returns the coin object. The user needs to handle it.
 */
const tx = new Transaction()
const { return_coin_a, return_coin_b } = await sdk.Vaults.withdraw(
  {
    vault_id,
    slippage: 0.01,
    ft_amount: result.burn_ft_amount,
    return_coin: true,
  },
  tx
)
if (return_coin_a) {
  tx.transferObjects([return_coin_a], sdk.senderAddress)
}
if (return_coin_b) {
  tx.transferObjects([return_coin_b], sdk.senderAddress)
}

const send_key_pair = 'THE_KEY_PAIR_GENERATED_BY_YOUR_PRIVATE_KEY'

const tx_result = await sdk.fullClient.sendTransaction(send_key_pair, payload)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://cetus-1.gitbook.io/cetus-developer-docs/developer/via-sdk-v2/sdk-modules/cetusprotocol-vaults-sdk/withdraw.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.
