# Factory

The `UniswapV2Factory` contract is a core component of the Fathom DEX. It is responsible for creating and managing pairs (liquidity pools) for token exchanges.

### State Variables

#### feeTo

* **Type:** `address`
* **Description:** Address to which protocol fees are sent.

#### feeToSetter

* **Type:** `address`
* **Description:** Address with the permission to update the `feeTo` address.

#### getPair

* **Type:** `mapping(address => mapping(address => address))`
* **Description:** Mapping from two token addresses to the address of their liquidity pool.

#### allPairs

* **Type:** `address[]`
* **Description:** Array of all created pair addresses.

### Set Functions

#### createPair

* **Parameters:**
  * `address tokenA`: The first token of the pair.
  * `address tokenB`: The second token of the pair.
* **Returns:**
  * `address pair`: The address of the created pair.
* **Description:** Creates a new liquidity pair for `tokenA` and `tokenB`. Emits the `PairCreated` event.

#### setFeeTo

* **Parameters:**
  * `address _feeTo`: The address to set as the fee recipient.
* **Description:** Sets the address to which protocol fees are sent. Can only be called by the `feeToSetter`.

#### setFeeToSetter

* **Parameters:**
  * `address _feeToSetter`: The address to set as the new `feeToSetter`.
* **Description:** Sets the address that can update the fee recipient. Can only be called by the current `feeToSetter`.

### Read Functions

#### allPairsLength

* **Parameters:** None
* **Returns:**
  * `uint`: The length of the `allPairs` array.
* **Description:** Returns the number of all pairs created.

#### getInitHash

* **Parameters:** None
* **Returns:**
  * `bytes32`: The keccak256 hash of the UniswapV2Pair creation code.
* **Description:** Returns the initialization hash of the UniswapV2Pair contract.

### Events

#### PairCreated

* **Parameters:**
  * `address indexed token0`: The first token of the pair.
  * `address indexed token1`: The second token of the pair.
  * `address pair`: The address of the created pair.
  * `uint`: The total number of pairs.
* **Description:** Emitted when a new pair is created.


---

# 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.fathom.fi/dex/interfaces/factory.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.
