> For the complete documentation index, see [llms.txt](https://docs.algebra.finance/algebra-integral-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.algebra.finance/algebra-integral-documentation/algebra-v1-technical-reference/contracts/api-reference-v1.9-directional-fees/v1.9-directional-fees-periphery/poolinitializer.md).

# PoolInitializer

Creates and initializes Algebra Pools

*Developer note: Credit to Uniswap Labs under GPL-2.0-or-later license: <https://github.com/Uniswap/v3-periphery>*

## Functions

### createAndInitializePoolIfNecessary

`function createAndInitializePoolIfNecessary(address token0, address token1, uint160 sqrtPriceX96) external payable returns (address pool)` payable external

Creates a new pool if it does not exist, then initializes if not initialized *Developer note: This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool*

| Name         | Type    | Description                                                 |
| ------------ | ------- | ----------------------------------------------------------- |
| token0       | address | The contract address of token0 of the pool                  |
| token1       | address | The contract address of token1 of the pool                  |
| sqrtPriceX96 | uint160 | The initial square root price of the pool as a Q64.96 value |

**Returns:**

| Name | Type    | Description                                                                                                           |
| ---- | ------- | --------------------------------------------------------------------------------------------------------------------- |
| pool | address | Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary |


---

# 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.algebra.finance/algebra-integral-documentation/algebra-v1-technical-reference/contracts/api-reference-v1.9-directional-fees/v1.9-directional-fees-periphery/poolinitializer.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.
