> For the complete documentation index, see [llms.txt](https://docs.ferra.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ferra.ag/integration/dlmm/typescript-sdk/swap-operations.md).

# 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.
