> 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/on-chain-views-overview/get_swap_min_res.md).

# get\_swap\_min\_res

This on-chain view returns a minimum result (output) of a swap.

### Call parameters

```pascaligo
type token_id_t         is nat

type swap_direction_t   is
| A_to_b
| B_to_a

type swap_slice_t       is [@layout:comb] record [
  direction               : swap_direction_t;
  pair_id                 : token_id_t;
]

type get_swap_min_res_t is [@layout:comb] record [
  swaps                   : list(swap_slice_t);
  amount_in               : nat;
]
```

#### swap\_slice\_t

<table><thead><tr><th>Field</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>direction</td><td>swap_direction_t</td><td>Swap direction: A->B or B->A</td></tr><tr><td>pair_id</td><td>token_id_t (nat)</td><td>ID of a pair in which swap will be executed</td></tr></tbody></table>

#### get\_swap\_min\_res\_t

<table><thead><tr><th width="150">Field</th><th width="202.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>swaps</td><td>list(<a href="#swap_slice_t">swap_slice_t</a>)</td><td>A route of a swap</td></tr><tr><td>amount_in</td><td>nat</td><td>Amount of tokens to swap from</td></tr></tbody></table>

### Return type

```pascaligo
nat
```

### Usage

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

```javascript
const dexCoreAddress = "KT1...";
const params = {
    swaps: [
        {
            direction: {
                a_to_b: undefinded,
            },
            pair_id: 1,
        },
        ...
    ],
    amount_in: 1000,
};
const viewCaller = "tz1...";
const dexCore = await tezos.contract.at(dexCoreAddress);
const swapMinRes = await dexCore.contract.contractViews.get_swap_min_res(params).executeView({ viewCaller: viewCaller });
```

{% endtab %}
{% endtabs %}

### Errors

* `108` - pair (pool) with the specified `token_id` not listed.
* `109` - pair doesn't have a liquidity.
* `113` - a [Bucket](/smart-contracts/dex-2.0/bucket-contract.md) contract not found (not TOK/TEZ LP pair).
* `117` - empty route of swaps.
* `118` - zero amount in was passed as the parameter.
* `119` - wrong route of a swap.


---

# 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.quipuswap.com/smart-contracts/dex-2.0/dexcore-contract/on-chain-views-overview/get_swap_min_res.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.
