# Add new dex

This page describes creation of new DEX pool.&#x20;

{% hint style="warning" %}
These contract methods are called only by `admin` of that contract.
{% endhint %}

Creation of pool consist of some parameters for seeting up DEX config.

#### a\_constant

Constant A used for manipulating with swap function. As larger the value of A, as more the function tends to be constant sum invariant. This constant is stored inside the contact as  $$A\_{storage} = A \* n^{n-1}$$ where $$2 \le n \le 4$$ - number of DEX underlying tokens. You could read more about this constant at Curve [whitepaper](https://curve.fi/files/stableswap-paper.pdf) and an explanation of Curve formulas.

{% embed url="<https://miguelmota.com/blog/understanding-stableswap-curve>" %}
An explanation of Curve formulas
{% endembed %}

#### input\_tokens

This param is a set of FA12/FA2 tokens that would be traded on DEX. `Set` type in Tezos contract is the sorted list of unique values, so you must keep in mind that for setting up `tokens_info` and when calling DEX.

#### tokens\_info

Token Info contains initial data for [Storage and types overview](/smart-contracts/quipuswap-stable-swap-dex/standalone-dex/storage-and-types-overview.md#token-information-type-pool-underlying-token-info).&#x20;

{% content-ref url="/pages/n3lsAcESil7i0lTtyJzr" %}
[add\_pool](/smart-contracts/quipuswap-stable-swap-dex/standalone-dex/add-new-dex/add_pool.md)
{% endcontent-ref %}

### Token info setting

When you want to initialise pool, you should setup initial `reserves`, `rate` and `precision_multiplier` in correct way:

> Let 4 `TBC` = 2 `TXZ` = 1 `TEH` (from example)

Then calculate $$LCM$$ of these ratios $$= 4$$

Token info for `TBC`

> `precision_multiplier` - $$10^{decimal\_{LP} - decimal\_{TBC}}$$
>
> `rate` - $$10^{decimal\_{LP}} \* 10^{decimal\_{LP} - decimal\_{TBC}} \* (ratio\_{TBC}/LCM)$$
>
> `reserves` - $$N \* 10^{decimal\_{TBC}} \* ratio\_{TBC}$$

Token info for `TXZ`

> `precision_multiplier` - $$10^{decimal\_{LP} - decimal\_{TXZ}}$$
>
> `rate` - $$10^{decimal\_{LP}} \* 10^{decimal\_{LP} - decimal\_{TXZ}} \* (ratio\_{TXZ}/LCM)$$
>
> `reserves` - $$N \* 10^{decimal\_{TXZ}} \* ratio\_{TXZ}$$

Token info for `TEH`

> `precision_multiplier` - $$10^{decimal\_{LP} - decimal\_{TEH}}$$
>
> `rate` - $$10^{decimal\_{LP}} \* 10^{decimal\_{LP} - decimal\_{TEH}} \* (ratio\_{TEH}/LCM)$$
>
> `reserves` - $$N \* 10^{decimal\_{TEH}} \* ratio\_{TEH}$$

Then you should receive $$LPT = 10^{decimal\_{LP}} \* LCM \* tokensCount$$ LP tokens.

Details of how to calculate values are in this table. (You can copy and play with this sheet)

{% embed url="<https://docs.google.com/spreadsheets/d/16sfuK6o8mWxOtG4pagxvRiUoswmA4SUO4aFzDa8yTD8/edit?usp=sharing>" %}
Stable exchange with switching of amount of tokens
{% endembed %}


---

# 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.quipuswap.com/smart-contracts/quipuswap-stable-swap-dex/standalone-dex/add-new-dex.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.
