> 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/smart-contracts/v1.md).

# v1 Smart Contracts

> **Important**: This API reference documents low-level smart contract methods and opcodes. For **production applications**, we **strongly recommend** using the [official SDK](/developer-section/dex/sdk/v2.md) + [TonConnect](https://docs.ton.org/develop/dapps/ton-connect/overview) instead of manually compiling BOCs and sending transactions. The SDK provides better developer experience, handles edge cases, and receives official support. Custom BOC compilation should only be used for specialized/advanced use cases.

## Overview

The section contains separate documents for each smart contract used in AMM:

* [Pool](/developer-section/dex/smart-contracts/v1/pool.md)
* [Router](/developer-section/dex/smart-contracts/v1/router.md)
* [LpAccount](/developer-section/dex/smart-contracts/v1/lpaccount.md)
* [LpWallet](/developer-section/dex/smart-contracts/v1/lpwallet.md)

Source code of all smart contracts can be found in this [**Github repo**](https://github.com/ston-fi/dex-core)

> **Note**: Protocol fees in DEX v1 are collected in ASK jetton.

## Referral Fees

DEX v1 pays the referrer share of a swap fee directly inside the swap transaction. The rate is fixed at **0.1 %** and the amount is transferred to the provided `referrer_address` automatically. See the [Omniston referral fees guide](/developer-section/omniston/referral-fees.md#referral-fees-with-dex-v1) (note: although the guide is Omniston-centric, the referenced paragraph specifically covers DEX V1 referral fees).

You can monitor referral payouts using the Stats & Vaults REST API:

* `GET /v1/stats/fee_accruals` – shows all operations that led to fee accrual for the referrer, filterable by period
* `GET /v1/stats/fee_withdrawals` – lists all fee withdrawals from the referrer's vaults by period
* `GET /v1/stats/fees` – returns aggregated referral fee information, such as total accrued USD value, for the selected time frame

The full specification is available in the [Swagger UI](https://api.ston.fi/swagger-ui/#/).


---

# 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.ston.fi/developer-section/dex/smart-contracts/v1.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.
