> ## Documentation Index
> Fetch the complete documentation index at: https://tech.ramses.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# RamsesV3Factory

Deploys Ramses V3 pools and manages control over pool protocol fees. Uses the AccessHub pattern for governance instead of simple ownership.

## Functions

### createPool

```solidity theme={null}
  function createPool(
    address tokenA,
    address tokenB,
    int24 tickSpacing,
    uint160 sqrtPriceX96
  ) external returns (address pool)
```

Creates a pool for the given two tokens and tick spacing, optionally initializing it with a price

tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. The fee is automatically derived from the `tickSpacingInitialFee` mapping. The call will revert if the pool already exists, the token arguments are invalid, or no fee has been enabled for the given tick spacing. If `sqrtPriceX96` is non-zero, the pool will be initialized with that price.

#### Parameters:

| Name           | Type    | Description                                                     |
| :------------- | :------ | :-------------------------------------------------------------- |
| `tokenA`       | address | One of the two tokens in the desired pool                       |
| `tokenB`       | address | The other of the two tokens in the desired pool                 |
| `tickSpacing`  | int24   | The desired tick spacing for the pool                           |
| `sqrtPriceX96` | uint160 | The initial sqrt price of the pool as a Q64.96 (0 to skip init) |

#### Return Values:

| Name   | Type    | Description                           |
| :----- | :------ | :------------------------------------ |
| `pool` | address | The address of the newly created pool |

### enableTickSpacing

```solidity theme={null}
  function enableTickSpacing(
    int24 tickSpacing,
    uint24 initialFee
  ) external
```

Enables a tick spacing with the given default fee

Maps tick spacing values to their default fee amounts. This is the inverse of Uniswap V3's `enableFeeAmount`. Only callable by governance (AccessHub).

#### Parameters:

| Name          | Type   | Description                                                            |
| :------------ | :----- | :--------------------------------------------------------------------- |
| `tickSpacing` | int24  | The spacing between ticks to enable                                    |
| `initialFee`  | uint24 | The default fee amount, denominated in hundredths of a bip (i.e. 1e-6) |

### setFeeProtocol

```solidity theme={null}
  function setFeeProtocol(
    uint24 _feeProtocol
  ) external
```

Sets the default protocol fee for all pools. Only callable by governance (AccessHub).

#### Parameters:

| Name           | Type   | Description                                                 |
| :------------- | :----- | :---------------------------------------------------------- |
| `_feeProtocol` | uint24 | The new default protocol fee, denominated in 1e-6 precision |

### setPoolFeeProtocol

```solidity theme={null}
  function setPoolFeeProtocol(
    address pool,
    uint24 _feeProtocol
  ) external
```

Sets the protocol fee for a specific pool. Only callable by governance (AccessHub). Pass `type(uint24).max` to revert the pool to the global default.

#### Parameters:

| Name           | Type    | Description                                    |
| :------------- | :------ | :--------------------------------------------- |
| `pool`         | address | The pool address to update                     |
| `_feeProtocol` | uint24  | The new protocol fee for the pool (1e-6 basis) |

### gaugeFeeSplitEnable

```solidity theme={null}
  function gaugeFeeSplitEnable(
    address pool
  ) external
```

Enables gauge fee splitting for a pool. When called by the voter contract, sets the pool's fee protocol to 100% so all fees route through the FeeCollector for distribution to voters. When called by other addresses, simply refreshes the pool's fee protocol from the factory.

#### Parameters:

| Name   | Type    | Description                               |
| :----- | :------ | :---------------------------------------- |
| `pool` | address | The pool to enable gauge fee splitting on |

### setFeeCollector

```solidity theme={null}
  function setFeeCollector(
    address _feeCollector
  ) external
```

Updates the fee collector address. Only callable by governance (AccessHub).

#### Parameters:

| Name            | Type    | Description                   |
| :-------------- | :------ | :---------------------------- |
| `_feeCollector` | address | The new fee collector address |

### setVoter

```solidity theme={null}
  function setVoter(
    address _voter
  ) external
```

Updates the voter contract address. Only callable by governance (AccessHub).

#### Parameters:

| Name     | Type    | Description           |
| :------- | :------ | :-------------------- |
| `_voter` | address | The new voter address |

### setFee

```solidity theme={null}
  function setFee(
    address _pool,
    uint24 _fee
  ) external
```

Sets the swap fee for a specific pool. Only callable by governance (AccessHub).

#### Parameters:

| Name    | Type    | Description                                                      |
| :------ | :------ | :--------------------------------------------------------------- |
| `_pool` | address | The pool to update                                               |
| `_fee`  | uint24  | The new swap fee, denominated in hundredths of a bip (i.e. 1e-6) |

## State Variables

### voter

```solidity theme={null}
  function voter(
  ) external returns (address)
```

Returns the address of the Voter contract used for gauge integration.

### feeCollector

```solidity theme={null}
  function feeCollector(
  ) external view returns (address)
```

Returns the address of the FeeCollector contract that routes protocol fees.

### feeProtocol

```solidity theme={null}
  function feeProtocol(
  ) external view returns (uint24)
```

Returns the default protocol fee applied to pools that don't have a pool-specific override.

### tickSpacingInitialFee

```solidity theme={null}
  function tickSpacingInitialFee(
    int24 tickSpacing
  ) external view returns (uint24 initialFee)
```

Returns the default fee for a given tick spacing. Returns 0 if the tick spacing is not enabled.

### poolFeeProtocol

```solidity theme={null}
  function poolFeeProtocol(
    address pool
  ) external view returns (uint24)
```

Returns the effective protocol fee for a specific pool. Falls back to the global `feeProtocol` if no pool-specific override is set.

## Events

### PoolCreated

```solidity theme={null}
  event PoolCreated(
    address token0,
    address token1,
    uint24 fee,
    int24 tickSpacing,
    address pool
  )
```

Emitted when a pool is created

#### Parameters:

| Name          | Type    | Description                                                                       |
| :------------ | :------ | :-------------------------------------------------------------------------------- |
| `token0`      | address | The first token of the pool by address sort order                                 |
| `token1`      | address | The second token of the pool by address sort order                                |
| `fee`         | uint24  | The fee collected upon every swap in the pool, denominated in hundredths of a bip |
| `tickSpacing` | int24   | The minimum number of ticks between initialized ticks                             |
| `pool`        | address | The address of the created pool                                                   |

### TickSpacingEnabled

```solidity theme={null}
  event TickSpacingEnabled(
    int24 tickSpacing,
    uint24 fee
  )
```

Emitted when a new tick spacing is enabled for pool creation via the factory

#### Parameters:

| Name          | Type   | Description                                      |
| :------------ | :----- | :----------------------------------------------- |
| `tickSpacing` | int24  | The tick spacing that was enabled                |
| `fee`         | uint24 | The default fee associated with the tick spacing |

### SetFeeProtocol

```solidity theme={null}
  event SetFeeProtocol(
    uint24 feeProtocolOld,
    uint24 feeProtocolNew
  )
```

Emitted when the default protocol fee is changed

#### Parameters:

| Name             | Type   | Description               |
| :--------------- | :----- | :------------------------ |
| `feeProtocolOld` | uint24 | The previous protocol fee |
| `feeProtocolNew` | uint24 | The updated protocol fee  |

### SetPoolFeeProtocol

```solidity theme={null}
  event SetPoolFeeProtocol(
    address pool,
    uint24 feeProtocolOld,
    uint24 feeProtocolNew
  )
```

Emitted when a pool-specific protocol fee is changed

#### Parameters:

| Name             | Type    | Description               |
| :--------------- | :------ | :------------------------ |
| `pool`           | address | The pool address          |
| `feeProtocolOld` | uint24  | The previous protocol fee |
| `feeProtocolNew` | uint24  | The updated protocol fee  |

### FeeAdjustment

```solidity theme={null}
  event FeeAdjustment(
    address pool,
    uint24 newFee
  )
```

Emitted when a pool's swap fee is changed

#### Parameters:

| Name     | Type    | Description      |
| :------- | :------ | :--------------- |
| `pool`   | address | The pool address |
| `newFee` | uint24  | The new swap fee |

### FeeCollectorChanged

```solidity theme={null}
  event FeeCollectorChanged(
    address indexed oldFeeCollector,
    address indexed newFeeCollector
  )
```

Emitted when the fee collector address is changed

#### Parameters:

| Name              | Type    | Description                |
| :---------------- | :------ | :------------------------- |
| `oldFeeCollector` | address | The previous fee collector |
| `newFeeCollector` | address | The new fee collector      |
