> For the complete documentation index, see [llms.txt](https://docs.quipuswap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quipuswap.com/smart-contracts/dex-2.0/dexcore-contract/entrypoints-overview/dex-entrypoints/divest_liquidity.md).

# divest\_liquidity

An entrypoint for liquidity divestment from the specific liquidity pool (pair). Also it [votes](/smart-contracts/dex-2.0/bucket-contract/entrypoints-overview/vote.md) for the users' bakers in case of liquidity divestment from TOK/TEZ pools.

### Call parameters

```pascaligo
type token_id_t         is nat

type divest_liquidity_t is [@layout:comb] record [
  pair_id                 : token_id_t;
  min_token_a_out         : nat;
  min_token_b_out         : nat;
  shares                  : nat;
  liquidity_receiver      : address;
  candidate               : key_hash;
  deadline                : timestamp;
]
```

<table><thead><tr><th width="191">Field</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>pair_id</td><td>token_id_t (nat)</td><td>Identifier of the liquidity pool (pair)</td></tr><tr><td>min_token_a_out</td><td>nat</td><td>The minimum number of token A that the user agrees to</td></tr><tr><td>min_token_b_out</td><td>nat</td><td>The minimum number of token B that the user agrees to</td></tr><tr><td>shares</td><td>nat</td><td>Amount of LP tokens to use in time of divestment</td></tr><tr><td>liquidity_receiver</td><td>address</td><td>Receiver of tokens A and tokens B</td></tr><tr><td>candidate</td><td>key_hash</td><td>Baker for voting (is used only in time of divestment from TOK/TEZ exchanges)</td></tr><tr><td>deadline</td><td>timestamp</td><td>The time until which the transaction remains valid and will not be rejected</td></tr></tbody></table>

### Usage

{% tabs %}
{% tab title="🌮 Taquito" %}

```javascript
const dexCoreAddress = "KT1...";
const parmas = {
    pair_id: 0,
    min_token_a_out: 100,
    min_token_b_out: 100,
    shares: 100,
    liquidity_receiver: "tz1.../KT1...",
    candidate: "tz1...",
    deadline: String(Date.parse((await tezos.rpc.getBlockHeader()).timestamp) / 1000 + 100),
};
const dexCore = await tezos.contract.at(dexCoreAddress);
const operation = await dexCore.methodsObject.divest_liquidity(parmas).send();

await operation.confirmation();
```

{% endtab %}
{% endtabs %}

### Errors

* `108` - pair (pool) with the specified `token_id` not listed.
* `109` - pair doesn't have a liquidity.
* `114` - insufficient liquidity.
* `115` - dust output (zero tokens amount expected).
* `116` - high expectations of output tokens.
* `136` - reentrancy.
* `142` - wrong reserves state after execution of the operation.
* `144` - action outdated (the time until which the transaction remained valid was passed).
* `412` - non payable entrypoint (can't accept TEZ tokens during call of an entrypoint).


---

# 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://docs.quipuswap.com/smart-contracts/dex-2.0/dexcore-contract/entrypoints-overview/dex-entrypoints/divest_liquidity.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.
