> For the complete documentation index, see [llms.txt](https://docs.nullmask.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nullmask.io/user-guide/swapping.md).

# Swapping

Shielded swaps execute Uniswap V2 token swaps within the privacy pool. Your trading activity is hidden from on-chain observers.

## Steps

1. Navigate to the **Swap** screen
2. Select the input token (From)
3. Select the output token (To)
4. The app checks if a valid Uniswap pair exists
5. Enter the input amount
6. The app fetches a quote showing the expected output
7. Optionally adjust slippage and deadline settings
8. Confirm the swap transaction in your wallet

## What Happens

1. The wallet signs a Uniswap V2 swap transaction
2. The proxy intercepts and generates a ZK proof
3. The contract verifies the proof
4. The contract executes the actual swap on Uniswap V2
5. The swap output is captured as a new note in the Merkle tree

## Swap Types

| From   | To     | Uniswap Function           |
| ------ | ------ | -------------------------- |
| ETH    | ERC-20 | `swapExactETHForTokens`    |
| ERC-20 | ETH    | `swapExactTokensForETH`    |
| ERC-20 | ERC-20 | `swapExactTokensForTokens` |

## Output Notes

Each swap creates 3 notes:

| Note             | Contains                          |
| ---------------- | --------------------------------- |
| Swap output note | The tokens received from the swap |
| Change note      | Leftover input token balance      |
| Fee change note  | Leftover fee-asset balance        |

## Fee Handling

* If the fee token matches the swap input token, fees are deducted from the input pool
* If they differ (e.g., paying ETH fees for an ERC-20→ERC-20 swap), separate fee notes are required

### ERC-20 → ERC-20 Swaps

These generate 3 transaction entries in history:

1. One outgoing ERC-20 (input)
2. One incoming ERC-20 (output)
3. One outgoing ETH (fee)

## Slippage and Deadline

* **Slippage**: Minimum acceptable output (set via `amountOutMin`)
* **Deadline**: Maximum block timestamp for the swap to execute

Both are enforced by the Uniswap V2 router on-chain.


---

# 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.nullmask.io/user-guide/swapping.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.
