# IV1SwapRouter

Functions for swapping tokens via DragonswapV1

### Functions <a href="#functions" id="functions"></a>

#### swapExactTokensForTokens <a href="#swapexacttokensfortokens" id="swapexacttokensfortokens"></a>

Swaps `amountIn` of one token for as much as possible of another token

*Setting `amountIn` to 0 will cause the contract to look up its own balance, and swap the entire amount, enabling contracts to send tokens before calling this function.*

```solidity
function swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to)
    external
    payable
    returns (uint256 amountOut);
```

**Parameters**

| Name           | Type        | Description                                        |
| -------------- | ----------- | -------------------------------------------------- |
| `amountIn`     | `uint256`   | The amount of token to swap                        |
| `amountOutMin` | `uint256`   | The minimum amount of output that must be received |
| `path`         | `address[]` | The ordered list of tokens to swap through         |
| `to`           | `address`   | The recipient address                              |

**Returns**

| Name        | Type      | Description                      |
| ----------- | --------- | -------------------------------- |
| `amountOut` | `uint256` | The amount of the received token |

#### swapTokensForExactTokens <a href="#swaptokensforexacttokens" id="swaptokensforexacttokens"></a>

Swaps as little as possible of one token for an exact amount of another token

```solidity
function swapTokensForExactTokens(uint256 amountOut, uint256 amountInMax, address[] calldata path, address to)
    external
    payable
    returns (uint256 amountIn);
```

**Parameters**

| Name          | Type        | Description                                          |
| ------------- | ----------- | ---------------------------------------------------- |
| `amountOut`   | `uint256`   | The amount of token to swap for                      |
| `amountInMax` | `uint256`   | The maximum amount of input that the caller will pay |
| `path`        | `address[]` | The ordered list of tokens to swap through           |
| `to`          | `address`   | The recipient address                                |

**Returns**

| Name       | Type      | Description                |
| ---------- | --------- | -------------------------- |
| `amountIn` | `uint256` | The amount of token to pay |


---

# 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.dragonswap.app/dragonswap/resources/developer-resources/smart-contracts/dragonswapv2/smart-router/interfaces/iv1swaprouter.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.
