# Swap

## Overview

The `UniswapSwapAndLiquidity` contract is designed to interact with the Uniswap V2 decentralized exchange platform.&#x20;

It facilitates two primary DeFi activities: swapping tokens and adding liquidity to Uniswap pools.&#x20;

By integrating with the Uniswap V2 Router, this contract provides users with the ability to engage in token swaps and liquidity provision directly through the contract, simplifying and streamlining these processes.

## Methods

## <mark style="color:blue;">`swapTokens`</mark>

Swaps tokens using the Uniswap V2 Router

### Parameters

| Name            | Type      | Description                                    |
| --------------- | --------- | ---------------------------------------------- |
| `_tokenIn`      | `address` | The address of the input token.                |
| `_tokenOut`     | `address` | The address of the output token.               |
| `_amountIn`     | `uint256` | The amount of input tokens to swap.            |
| `_amountOutMin` | `uint256` | The minimum amount of output tokens to accept. |
| `_to`           | `address` | The address to send output tokens to.          |

## <mark style="color:blue;">`addLiquidity`</mark>

Adds liquidity to a Uniswap pool.

### Parameters

| Name          | Type      | Description                                    |
| ------------- | --------- | ---------------------------------------------- |
| `_tokenA`     | `address` | The address of the first token.                |
| `_tokenB`     | `address` | The address of the second token.               |
| `_amountA`    | `uint256` | The amount of the first token.                 |
| `_amountB`    | `uint256` | The amount of the second token.                |
| `_amountAMin` | `uint256` | The minimum amount of the first token to add.  |
| `_amountBMin` | `uint256` | The minimum amount of the second token to add. |


---

# 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.volary.io/template-library/smart-contracts/swap.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.
