# get\_toks\_per\_share

This on-chain view returns amount of token A and token B for the specified amount of LP tokens in a specific liquidity pool (pair). Also can return a list of responses for a list of requests.

### Call parameters

```pascaligo
type token_id_t         is nat

type toks_per_shr_req_t is [@layout:comb] record [
  pair_id                 : token_id_t;
  shares_amt              : nat;
]

list(toks_per_shr_req_t)
```

<table><thead><tr><th width="150">Field</th><th width="202.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>pair_id</td><td>token_id_t (nat)</td><td>Pair ID for which you need to get tokens amount per shares</td></tr><tr><td>shares_amt</td><td>nat</td><td>Amount of shares to get info about tokens</td></tr></tbody></table>

### Return type

```pascaligo
type token_id_t         is nat

type toks_per_shr_t     is [@layout:comb] record [
  token_a_amt             : nat;
  token_b_amt             : nat;
]

type toks_per_shr_req_t is [@layout:comb] record [
  pair_id                 : token_id_t;
  shares_amt              : nat;
]

type toks_per_shr_res_t is [@layout:comb] record [
  request                 : toks_per_shr_req_t;
  tokens_per_share        : toks_per_shr_t;
]

list(toks_per_shr_res_t)
```

#### toks\_per\_shr\_req\_t

<table><thead><tr><th>Field</th><th width="152.00000000000003">Type</th><th>Description</th></tr></thead><tbody><tr><td>pair_id</td><td>token_id_t (nat)</td><td>Pair ID for which you need to get tokens amount per shares</td></tr><tr><td>shares_amt</td><td>nat</td><td>Amount of shares to get info about tokens</td></tr></tbody></table>

#### toks\_per\_shr\_t

<table><thead><tr><th>Field</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>token_a_amt</td><td>nat</td><td>Amount of tokens A per shares</td></tr><tr><td>token_b_amt</td><td>nat</td><td>Amount of tokens B per shares</td></tr></tbody></table>

#### toks\_per\_shr\_res\_t

| Field              | Type                                          | Description                |
| ------------------ | --------------------------------------------- | -------------------------- |
| request            | [toks\_per\_shr\_req\_t](#toks_per_shr_req_t) | Tokens per shares request  |
| tokens\_per\_share | [toks\_per\_shr\_t](#toks_per_shr_t)          | Tokens per shares response |

### Usage

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

```javascript
const dexCoreAddress = "KT1...";
const params = [
    {
        pair_id: 1,
        shares_amt: 100,
    },
    ...
];
const viewCaller = "tz1...";
const dexCore = await tezos.contract.at(dexCoreAddress);
const tokensPerShares = await dexCore.contract.contractViews.get_toks_per_share(params).executeView({ viewCaller: viewCaller });
```

{% endtab %}
{% endtabs %}

### Errors

* `108` - pair (pool) with the specified `token_id` not listed.
* `109` - pair doesn't have a liquidity.


---

# 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/on-chain-views-overview/get_toks_per_share.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.
