> For the complete documentation index, see [llms.txt](https://docs.ston.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ston.fi/developer-section/dex.md).

# DEX

Direct pool swaps, liquidity, LP farming, data APIs, and contract references on TON.

STON.fi DEX is a non-custodial automated market maker on TON. Use it for direct pool swaps, liquidity provision, and LP farming. For aggregated swaps across connected liquidity sources or cross-chain swaps, choose [Omniston](/developer-section/omniston.md).

## Choose an operation

* [Swap](/developer-section/dex/sdk/swap.md): simulate a direct swap and build its transaction.
* [Add liquidity](/developer-section/dex/sdk/provide-liquidity.md): deposit assets and receive LP tokens representing a pool share; supported v2 flows include single-sided provision.
* [Withdraw liquidity](/developer-section/dex/sdk/burn-lp-tokens.md): burn issued LP tokens to release underlying assets.
* [Recover pending liquidity](/developer-section/dex/sdk/refund-liquidity.md): return tokens held in an LP account before LP issuance.
* [Farm](/developer-section/dex/sdk/farm.md): stake LP tokens, claim rewards, and manage a Farm NFT.
* [Claim integrator fees](/developer-section/dex/sdk/vault-operations.md): withdraw accrued DEX v2 Vault fees.

## Integration and data

Use the [TypeScript/JavaScript SDK](/developer-section/dex/sdk.md) to build transactions and the [REST API](/developer-section/dex/api.md) for asset/pool metadata, simulation, and operation queries. Start with [Setup and environments](/developer-section/dex/sdk/v2.md), then follow an operation guide. Send built transactions with a [TON wallet](/developer-section/common/transaction-sending.md).

Trading fees accrue to the pool according to its fee configuration and each LP’s share. See [Fees](/developer-section/dex/fees.md) for trading versus integrator fees.

## Versions and references

DEX v1/v2 are contract generations, separate from npm SDK package versions. Current SDK packages include wrappers for more than one generation; choose contracts matching the deployed pool/router. See [Versions and migrations](/developer-section/dex/migration.md) for existing integrations.

For advanced integrations, use [Architecture](/developer-section/dex/architecture.md), [Contract reference](/developer-section/dex/smart-contracts.md), and [Message flows](/developer-section/dex/smart-contracts/v2/examples.md). Pool code is immutable and router upgrades have a time lock; consult the relevant contract version and [Security resources](/getting-started/security.md) for details.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ston.fi/developer-section/dex.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
