> For the complete documentation index, see [llms.txt](https://docs.hyperion.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperion.xyz/developer/via-contract/features-available/remove-liquidity-zap-out.md).

# Remove liquidity (zap out)

## Function

To withdraw liquidity from a position and receive the funds as a single asset (a "zap out" transaction), use the `remove_liquidity_single` function in the `router_v3` module.

This function simplifies the withdrawal process. It takes your liquidity position (composed of two assets), removes it from the pool, and automatically swaps one of the assets for the other, so you receive the entire value in a single, specified token.

```rust
public entry fun remove_liquidity_single(
    lp: &signer,
    lp_object: Object<position_v3::Info>,
    liquidity_delta: u128,
    to_meta: Object<Metadata>,
    slippage_numerators: u256,
    slippage_denominator: u256
) {
    // ... function body ...
}
```

### Parameters

| Parameter              | Type                        | Description                                                                                                                                                                                                             |
| ---------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `lp`                   | `&signer`                   | The signer of the transaction, representing the liquidity provider who owns the position.                                                                                                                               |
| `lp_object`            | `Object<position_v3::Info>` | The liquidity position object from which you are withdrawing.                                                                                                                                                           |
| `liquidity_delta`      | `u128`                      | The amount of liquidity units to remove. This is **not a token amount** but an abstract `u128` value representing your share in the pool. To withdraw everything, use the full `liquidity` value from your `lp_object`. |
| `to_meta`              | `Object<Metadata>`          | The metadata of the **single token** you wish to receive as output. For example, if your position is APT/USDT, you can specify the USDT metadata here to receive all your funds in USDT.                                |
| `slippage_numerators`  | `u256`                      | The numerator for calculating slippage tolerance on the internal swap required to consolidate your assets. For a 1% slippage, this would be `99`.                                                                       |
| `slippage_denominator` | `u256`                      | The denominator for calculating slippage tolerance, typically `100`. This protects you from unfavorable price changes during the internal swap.                                                                         |

### Detailed Parameter Explanation

#### **Liquidity Delta (`liquidity_delta`)**

This is the most critical parameter to understand correctly.

* **What it is**: `liquidity_delta` represents the "amount of liquidity" you want to remove, which is an abstract unit calculated by the protocol. It is **not** an amount of Token A or Token B.
* **How to get it**: You typically read the current `liquidity` value from your `lp_object` . If you want to withdraw all your funds, you would pass this full value as the `liquidity_delta`. If you only want to withdraw a portion (e.g., 50%), you would pass half of that value.

#### **Slippage Tolerance (`slippage_numerators` / `slippage_denominator`)**

This setting is crucial because the function performs an internal swap.

* **Example**: Imagine your position is in a APT/USDT pool. When you call this function and set `to_meta` to be USDT's metadata, the function does the following:
  1. Removes your proportional share of APT and USDT from the pool.
  2. Internally swaps the APT portion for USDT.
  3. Sends you the total amount of USDT.
* **Meaning**: The slippage tolerance applies to step 2. Setting `slippage_numerators` to `99` and `slippage_denominator` to `100` means you are willing to accept up to 1% negative slippage on the APT-to-USDT swap. If the price impact is worse than that, the transaction will fail, protecting your funds.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.hyperion.xyz/developer/via-contract/features-available/remove-liquidity-zap-out.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
