> For the complete documentation index, see [llms.txt](https://docs.gnoswap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gnoswap.io/contracts/router/exact_in.gno.md).

# exact\_in.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/router/v1/exact_in.gno>" %}

## ExactInSwapRoute

```go
func ExactInSwapRoute(
	cur realm,
	inputToken string,
	outputToken string,
	amountIn string,
	routeArr string,
	quoteArr string,
	amountOutMin string,
	deadline int64,
	referrer string
) (string, string)
```

ExactInSwapRoute runs a exact-in direction swap through the route that offers the most favorable exchange rate.

#### Parameters

| Name           | Type   | Description                                                                                  |
| -------------- | ------ | -------------------------------------------------------------------------------------------- |
| `cur`          | realm  | Pass `cross` as argument.                                                                    |
| `inputToken`   | string | The path of the input token.                                                                 |
| `outputToken`  | string | The path of the output token.                                                                |
| `amountIn`     | string | The amount of the input token.                                                               |
| `routeArr`     | string | The route of the swap.                                                                       |
| `quoteArr`     | string | The share of each split of the route.                                                        |
| `amountOutMin` | string | Limits the number of tokens while routing the swap. The minimum amount of tokens to receive. |
| `deadline`     | int64  | The timestamp for transaction to be expired.                                                 |
| `referrer`     | string | The referrer address for reward tracking.                                                    |

#### Return Values

| Name       | Type   | Description                                                         |
| ---------- | ------ | ------------------------------------------------------------------- |
| `tokenIn`  | string | The amount sent to the pool from the user (the input of the swap).  |
| `tokenOut` | string | The amount sent to the user from the pool (the output of the swap). |

#### Return Values

| Name       | Type   | Description                                                         |
| ---------- | ------ | ------------------------------------------------------------------- |
| `tokenIn`  | string | The amount sent to the pool from the user (the input of the swap).  |
| `tokenOut` | string | The amount sent to the user from the pool (the output of the swap). |

## ExactOutSingleSwapRoute

```go
func ExactOutSingleSwapRoute(
	cur realm,
	inputToken string,
	outputToken string,
	amountOut string,
	routeArr string,
	amountInMax string,
	sqrtPriceLimitX96 string,
	deadline int64,
	referrer string
) (string, string)
```

ExactOutSingleSwapRoute executes a single-hop swap with exact output amount.

#### Parameters

| Name                | Type   | Description                          |
| ------------------- | ------ | ------------------------------------ |
| `cur`               | realm  | Pass `cross` as argument.            |
| `inputToken`        | string | path of input token                  |
| `outputToken`       | string | path of output token                 |
| `amountOut`         | string | exact output amount                  |
| `routeArr`          | string | encoded route                        |
| `amountInMax`       | string | maximum input amount                 |
| `sqrtPriceLimitX96` | string | price limit for the swap             |
| `deadline`          | int64  | transaction deadline                 |
| `referrer`          | string | referrer address for reward tracking |

#### Return Values

| Name        | Type   | Description          |
| ----------- | ------ | -------------------- |
| `amountIn`  | string | actual input amount  |
| `amountOut` | string | actual output amount |
