# invest\_liquidity

An entrypoint for liquidity investment in the specific liquidity pool (pair). Also it [votes](https://docs.quipuswap.com/smart-contracts/dex-2.0/bucket-contract/entrypoints-overview/vote) for the users' bakers in case of liquidity investment to TOK/TEZ pools.

### Call parameters

```pascaligo
type token_id_t         is nat

type invest_liquidity_t is [@layout:comb] record [
  pair_id                 : token_id_t;
  token_a_in              : nat;
  token_b_in              : nat;
  shares                  : nat;
  shares_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>token_a_in</td><td>nat</td><td>Max amount of token A allowed to be spent</td></tr><tr><td>token_b_in</td><td>nat</td><td>Max amount of token B allowed to be spent</td></tr><tr><td>shares</td><td>nat</td><td>Amount of LP tokens to be acquired</td></tr><tr><td>shares_receiver</td><td>address</td><td>Receiver of LP tokens</td></tr><tr><td>candidate</td><td>key_hash</td><td>Baker for voting (is used only in time of investment to 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

{% hint style="danger" %}
Note: you need to pass positive TEZ/mutez amount to the ***send()*** method in case of FA1.2/TEZ or FA2/TEZ liquidity investment (see example below).

Also don't forget to add the [DexCore](https://docs.quipuswap.com/smart-contracts/dex-2.0/dexcore-contract) contract as the operator for your FA2 tokens or make an approve for spending of FA1.2 tokens in time of liquidity investment.
{% endhint %}

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

```javascript
const dexCoreAddress = "KT1...";
const parmas = {
    pair_id: 0,
    token_a_in: 100,
    token_b_in: 100,
    shares: 100,
    shares_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.invest_liquidity(parmas).send({ amount: parmas.token_b_in, mutez: true });

await operation.confirmation();
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Pass `candidate: "tz1ZZZZZZZZZZZZZZZZZZZZZZZZZZZZNkiRg"`in case of TOK/TOK exchange
{% endhint %}

### Errors

* `108` - pair (pool) with the specified `token_id` not listed.
* `109` - pair doesn't have a liquidity.
* `110` - zero amount of LP tokens (shares) expected.
* `111` - low token A amount in.
* `112` - low token B amount in.
* `136` - reentrancy.
* `141` - wrong amount of TEZ tokens were attached to transaction.
* `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). Only in case of investment to TOK/TOK liquidity pools (pairs).


---

# Agent Instructions: 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/invest_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.
