# Swap Operations

Execute token swaps through DLMM's bin-based liquidity system. This section covers swap execution, direction handling, output calculations, and advanced features like price impact analysis and slippage protection for optimal trading experiences.

### Prerequisites

Before performing swaps, ensure you have:

* Sufficient balance of the input token
* Understanding of X→Y and Y→X swap directions
* Knowledge of bin-based price impact
* Familiarity with slippage concepts
* Connected wallet with gas for transactions

### What You'll Learn

This section covers comprehensive swap operations in DLMM:

#### [Execute Swap](/integration/dlmm/typescript-sdk/swap-operations/execute-swap.md)

Perform token swaps through DLMM pairs. Learn transaction building, input validation, and how swaps traverse through multiple bins to fill orders.

#### [Swap Direction](/integration/dlmm/typescript-sdk/swap-operations/swap-direction.md)

Master the difference between X→Y and Y→X swaps, token ordering conventions, and how swap direction affects price calculations and fee structures.

#### [Calculate Swap Output](/integration/dlmm/typescript-sdk/swap-operations/calculate-swap-output.md)

Preview exact output amounts before executing swaps. Simulate trades through bins, account for fees, and optimize trade sizes for best execution.

#### [Price Impact](/integration/dlmm/typescript-sdk/swap-operations/price-impact.md)

Calculate and analyze price impact across affected bins. Understand how trade size moves through liquidity tiers and impacts final execution price.

#### [Slippage Protection](/integration/dlmm/typescript-sdk/swap-operations/slippage-protection.md)

Set minimum output amounts to protect against MEV and price movements. Learn optimal slippage tolerances for different market conditions and trade sizes.


---

# 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.ferra.ag/integration/dlmm/typescript-sdk/swap-operations.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.
