> For the complete documentation index, see [llms.txt](https://docs.mav.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mav.xyz/technical-reference/maverick-v1/v1-contracts/factory.md).

# Factory

### **Table of Contents**

* [**Contract Details**](#contract-details)
* [**Events**](#events)
  * [PoolCreated](#event-poolcreated)
  * [SetFactoryProtocolFeeRatio](#event-setfactoryprotocolfeeratio)
  * [SetFactoryOwner](#event-setfactoryowner)
* [**Functions**](#functions)
  * [create()](#fn-create)
  * [lookup()](#fn-lookup)
  * [owner()](#fn-owner)
  * [position()](#fn-position)
  * [protocolFeeRatio()](#fn-protocolfeeratio)
  * [isFactoryPool()](#fn-isfactorypool)

## **Contract Details** <a href="#contract-details" id="contract-details"></a>

* **Name :** *IFactory*
* **Solidity Version :** *^0.8.0*
* *SPDX License-Identifier : GPL-2.0-or-later*
* **`Factory` is Deployed to**
  * Ethereum: [`0xEb6625D65a0553c9dBc64449e56abFe519bd9c9B`](https://etherscan.io/address/0xEb6625D65a0553c9dBc64449e56abFe519bd9c9B)
  * ZKSync Era: [`0x2C1a605f843A2E18b7d7772f0Ce23c236acCF7f5`](https://explorer.zksync.io/address/0x2C1a605f843A2E18b7d7772f0Ce23c236acCF7f5)
* Code: [Github](https://github.com/maverickprotocol/maverick-v1-interfaces/blob/main/contracts/interfaces/IFactory.sol)

## **Events** <a href="#events" id="events"></a>

### PoolCreated <a href="#event-poolcreated" id="event-poolcreated"></a>

Event emitted when a new pool is created.

```solidity
event PoolCreated(
    address poolAddress,
    uint256 fee,
    uint256 tickSpacing,
    int32 activeTick,
    int256 lookback,
    uint64 protocolFeeRatio,
    IERC20 tokenA,
    IERC20 tokenB
);
```

* Parameters :
  * `poolAddress` : The `address` of the created pool
  * `fee` : The rate in `prbmath 60x18` decimal format
  * `tickSpacing` : The bin width represented as `1.0001^tickSpacing`
  * `activeTick` : The initial active tick of the pool
  * `lookback` : The time-weighted average price *(TWAP)* lookback in whole seconds
  * `protocolFeeRatio` : The ratio of the swap fee that is kept for the protocol
  * `tokenA` : The `ERC20` token A used in the pool
  * `tokenB` : The `ERC20` token B used in the pool

### SetFactoryProtocolFeeRatio <a href="#event-setfactoryprotocolfeeratio" id="event-setfactoryprotocolfeeratio"></a>

Event emitted when the protocol fee ratio is updated.

```solidity
event SetFactoryProtocolFeeRatio(uint64 protocolFeeRatio);
```

* Parameters :
  * `protocolFeeRatio` : The new protocol fee ratio

### SetFactoryOwner <a href="#event-setfactoryowner" id="event-setfactoryowner"></a>

Event emitted when the owner of the factory is updated.

```solidity
event SetFactoryOwner(address owner);
```

* Parameters :
  * `owner` : The new owner `address`

## **Functions** <a href="#functions" id="functions"></a>

### create() <a href="#fn-create" id="fn-create"></a>

Creates a new pool.

```solidity
function create(
    uint256 _fee,
    uint256 _tickSpacing,
    int256 _lookback,
    int32 _activeTick,
    IERC20 _tokenA,
    IERC20 _tokenB
) external returns (IPool);
```

* Parameters :
  * `_fee` : The rate in `prbmath 60x18` decimal format
  * `_tickSpacing` : The bin width represented as `1.0001^tickSpacing`
  * `_lookback` : The time-weighted average price (TWAP) lookback in whole seconds
  * `_activeTick` : The initial active tick of the pool
  * `_tokenA` : The ERC20 token A to be used in the pool
  * `_tokenB` : The ERC20 token B to be used in the pool
* Returns :
  * `IPool` : An instance of the `IPool` interface representing the created pool

### lookup() <a href="#fn-lookup" id="fn-lookup"></a>

Looks up an existing pool based on the specified parameters.

```solidity
function lookup(
    uint256 fee,
    uint256 tickSpacing,
    int256 lookback,
    IERC20 tokenA,
    IERC20 tokenB
) external view returns (IPool);
```

* Parameters :
  * `fee` : The rate in `prbmath 60x18` decimal format
  * `tickSpacing` : The bin width represented as `1.0001^tickSpacing`
  * `lookback` : The time-weighted average price *(TWAP)* lookback in whole `seconds`
  * `tokenA` : The `ERC20` token A used in the pool
  * `tokenB` : The `ERC20` token B used in the pool
* Returns :
  * `IPool` : An instance of the `IPool` interface representing the found pool, or a `zero` address if no pool matches the parameters

### owner() <a href="#fn-owner" id="fn-owner"></a>

Retrieves the address of the factory owner.

```solidity
function owner() external view returns (address);
```

* Returns :
  * `address` : The `address` of the factory owner<br>

### position() <a href="#fn-position" id="fn-position"></a>

Retrieves the IPosition interface associated with the factory.

```solidity
function position() external view returns (IPosition);
```

* Returns :
  * `IPosition` : An instance of the `IPosition` interface associated with the factory

### protocolFeeRatio() <a href="#fn-protocolfeeratio" id="fn-protocolfeeratio"></a>

Retrieves the current protocol fee ratio.

```solidity
function protocolFeeRatio() external view returns (uint64);
```

* Returns :
  * The current protocol fee ratio in `uint64`.

### isFactoryPool(IPool pool) <a href="#fn-isfactorypool" id="fn-isfactorypool"></a>

Checks if a pool is owned by the factory.

```solidity
function isFactoryPool(IPool pool) external view returns (bool);
```

* Parameters :
  * `pool` : An instance of the `IPool` interface representing the pool to check.
* Returns :
  * A `boolean` indicating whether the pool is owned by the factory.


---

# 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.mav.xyz/technical-reference/maverick-v1/v1-contracts/factory.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.
