# 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](https://docs.quipuswap.com/smart-contracts/dex-2.0/bucket-contract) 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.
