# Initialize new DEX flow

Deploy and initialization of DEX pool from factory performs in 2 steps. This is required because of the complexity of the contract itself and the size of stored lambda functions in it, so one-operation deployment exceeds gas limits.

### Step 1

{% hint style="warning" %}
QUIPU token should be approved (updated operators) before calling this method.
{% endhint %}

In first step, the contract deploys the main body of DEX, with copied admin and token lambdas and "frozen" flag, and charges QUIPU tokens as deploy fees, if the sender is not whitelisted.

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

### Step 2

{% hint style="warning" %}
Underlying tokens should be approved (updated operators) before calling this method.
{% endhint %}

Step two do three operations: copy dex lambdas (as largest by size), "unfreezes" DEX, and call invest with balanced values of all underlying tokens. As the DEX pool contract had not received any investments yet, this investment is initial and equal to investing when performed [add\_pool](/smart-contracts/quipuswap-stable-swap-dex/standalone-dex/add-new-dex/add_pool.md)(Standalone version).

{% content-ref url="/pages/zthVkcEQQQnvLZQCg8Ga" %}
[start\_dex](/smart-contracts/quipuswap-stable-swap-dex/factory/initialize-new-dex-flow/start_dex.md)
{% endcontent-ref %}


---

# 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/factory/initialize-new-dex-flow.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.
