# Swap

Swaps are made with an Asset Transfer transaction together with an Application Call.

An amount of the other asset is sent to the user by the pool using an inner transaction.

The type of swap may be either fixed-input or fixed-output. If the type is fixed-output an extra inner transaction is sent to return any change from the input amount to the user (see below). A fixed-output swap has a higher transaction fee because it requires one extra inner transaction.

A swap fee is charged on all swaps. The fee is set per pool as basis points. This fee is deducted from the input amount before applying the swap formula to calculate the output.

The formulae for fixed-input and fixed-output swaps are described in [Formula IV.A & IV.B](https://docs.tinyman.org/protocol-specification/pages/RArypJMatkCdksZvFhuW#iv.-swapping) respectively.

## **Slippage Tolerance**

Swaps have slippage tolerance to allow for changes to the exchange rate between the time the swap was prepared and the swap was executed. For a fixed-input swap, a minimum output amount is included in the Application Call arguments. If the calculated output amount is less than this amount the swap will fail.

For a fixed-output swap, the slippage tolerance is included in the input amount and the exact output amount is specified in the arguments. If the calculated input amount required to achieve the target output amount is less than the provided input amount the swap fails. If it is greater then the change is returned to the user by an inner transaction.

[Transaction Details for swap](/v2-integration/protocol-methods/swap.md)


---

# 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.tinyman.org/protocol-specification/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.
