# Pool Initialization

Pools can be initialized for a given pair by using callpath index 0:

```
userCmd(1, abi.encode(
  71,        // Fixed initPool subcode  
  base,      // address
  quote,     // address
  poolIdx,   // uint256
  price      // uint128
)
```

In addition to the fixed initPool command sub-code (71), the following parameters are passed to initialize a pool:

* base - The address of the base token or virtual token
* quote - The address of the quote token or virtual token
* poolIdx - The arbitrary index of the pool type the user is swapping on.
* price - The initial price in the pool. Represented as Q64.64 square root (see [Type Conventions](/developers/type-conventions.md) for description of how to represent prices)

Initializing a pool will require a permanent commitment of a small amount of base and quote tokens (based on the set `newPoolLiquidity` in the `CrocSwapDex` contract). Pool initialization will always try funding based on the user's surplus collateral. If insufficient will try to collect tokens directly.&#x20;

Therefore user must either fund their surplus collateral, approve ERC20 tokens, or send sufficient quantity in `msg.value` of the call. (See [Token Transfers](/developers/token-transfers.md) for more information on these mechanics.)


---

# 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.ambient.finance/developers/dex-contract-interface/pool-initialization.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.
