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

# Pool Factory

This contract is owned and managed by the product's team. It allows developers to deploy and set up their own pools. The following are the main technical aspects of this contract:

See [FactoryBase.sol]().

## Deployers Allow List

In order for a developer to be able to use the factory, they must first be added to the allow list in the Factory contract. Currently, only the product team can add or remove a deployer to the allow list. If you are interested in using our product and being added to the allow list, reach out at [liquidity@thrackle.io](mailto:liquidity@thrackle.io) .

## Pool Configurations

For the pool to be properly setup, it is important to understand the parameters that it requires:

### Pairs

A pool serves as a trading means for a pair of ERC20 tokens. This pair is composed of one ERC20 that we will call *the x-token* and another ERC20 that we will call *the y-token* aka **collateral token**.

### Available *y* Tokens

This token can be chosen from a predetermined list which is maintained by the product's team. Currently available y-tokens are:

| Network          | Token | Address                                      |
| ---------------- | ----- | -------------------------------------------- |
| Ethereum Mainnet | USDC  | `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48` |
| Base Mainnet     | USDC  | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
| Ethereum Sepolia | USDC  | `0x0BabdC1ef40e72C9D0ea04d831738cC923AdB9b4` |
| Ethereum Sepolia | wETH  | `0x177257fC3a214b8c2dD3142AaC7b0bb8a9fbD5a4` |
| Base Sepolia     | USDC  | `0xfAAB528466868AAD7A5732F113De93f5133EF2ea` |
| Base Sepolia     | wETH  | `0xe1d1a2C9e186D035E9d2c6a9c8a0B4025d76e7E7` |

*Note:* The pool's default for decimals is 18. Upon creation of a pool an offset will be set for Collateral tokens with less than 18 decimals. The offset will be applied during swaps to make sure the difference in decimals is accounted for.

### *x* Token

This can actually be any ERC20 token, even *y token*s, as long as it complies with the supply requirements:

* **Max Supply For x-tokens**: The total supply of an x-token is set at construction, immutable, and must not be more than [100 billion tokens (assuming it has 18 decimals)](/concepts/bounds) to be part of a pool.

* **Token uses 18 decimals**: It is an expectation for the x-token to use 18 decimals.

Visit the [Token Support](/concepts/token-support) page for a more explicit list of token requirements.

### LP Fees

Pools have an LP-fee feature which initial value must be set through the factory. Take into account that this fee value can also be updated at any time in the pool contract itself after deployed. The LP fee is the percentage of the swaps that the pool will set aside as a liquidity-provider fee. The fee will be collected and accumulated in y-tokens. This is a percentage expected to be in basis points (100 -> 1%).

### Curve Parameters

* **b**: The slope of the tbc function. Related to the price impact of trades, if the slope is higher, a certain trade will move the price more.

* **c**: The y-intercept of the tbc function. This is the price of the x-token when the pool is empty.

* **C**: The concentration parameter of the tbc function.

* **lowerPrice**: The initial lower price for an x-token. This is basically the initial price, in WAD, of the x-token to be bought from the pool. This value is expected in WAD (1 -> 1 \* 1e18).

* **xMin**: The minimum value of variable x.

* **xMax**: The highest price for an x-token.

* **V**: Vector field parameter.

* **Z<sub>n</sub>**: A balancing quantity that needs to be added to L for fair LP fee accounting.

* **w<sub>inactive</sub>**: The amount of liquidity that is inactive. It cannot extract revenue, cannot further add liquidity and removal of liquidity is on a modified flow.

## Protocol Fees

Protocol fees are a portion of each swap that will go towards the protocol as a compensation for its service provided.

The management of the protocol fee is under complete control of the protocol, and the factory plays a central role in this management.

The following are the properties of the factory's protocol fees:

* Protocol fees can be updated at any time only by the *owner* of the factory.
* Protocol fees can be 0.
* Protocol fees are expressed in basis points.
* Protocol fees can be as high as 0.20%.

### Factory's protocol fee value

The factory is in charge of setting the initial value of the protocol fees of the pools at deployment time. Only the *owner* of the factory can set this value. The following functions are available to manage the protocol fee:

```solidity theme={null}
/**
 * @dev fee percentage for swaps for the protocol
 * @return the percentage for swaps in basis points that will go towards the protocol
 */
function protocolFee() external returns (uint16);

/**
 * @dev This is the function to update the protocol fees per trading.
 * @param _protocolFee percentage of the transaction that will get collected as fees (in percentage basis points:
 * 10000 -> 100.00%; 500 -> 5.00%; 1 -> 0.01%)
 */
function setProtocolFee(uint16 _protocolFee) external;
```

### Factory's protocol fee collector

The factory is also in charge of setting the initial address of the protocol fee collector of the pools at deployment time. Only the *owner* of the factory can set this value. The following functions are available to manage this address:

```solidity theme={null}
/**
 * @dev protocol-fee collector address
 * @return the current protocolFeeCollector address
 */
function protocolFeeCollector() external returns (address);

/**
 * @dev proposed protocol-fee collector address
 * @return the current proposedProtocolFeeCollector address
 */
function proposedProtocolFeeCollector() external returns (address);

/**
 * @dev function to propose a new protocol fee collector
 * @param _protocolFeeCollector the new fee collector
 * @notice that only the current fee collector address can call this function
 */
function proposeProtocolFeeCollector(address _protocolFeeCollector) external;

/**
 * @dev function to confirm a new protocol fee collector
 * @notice that only the already proposed fee collector can call this function
 */
function confirmProtocolFeeCollector() external;
```

Notice that the process of assigning a new protocol fee collector is a 2-step process in order to prevent human errors from setting the wrong address:

1. The *owner* of the factory proposes a new protocol fee collector address through the function `proposeProtocolFeeCollector`.
2. The proposed protocol fee collector account then needs to call the `confirmProtocolFeeCollector` function to accept/confirm this role.

## Usage

### Deploy A New ALTBC Pool

To deploy a new ALTBC pool, call the following function on the [ALTBCFactory](/reference/factory/ALTBCFactory.sol/contract.ALTBCFactory) contract:

```solidity theme={null}
/**
 * @dev deploys an ALTBC pool
 * @param _xToken address of the X token (x axis)
 * @param _yToken address of the Y token (y axis)
 * @param _lpFee percentage of the fees in percentage basis points
 * @param _tbcInput input data for the pool
 * @param _xAdd the initial liquidity of xTokens that will be transferred to the pool
 * @param _name the name of the pool
 * @param _symbol the symbol of the pool
 * @return deployedPool the address of the deployed pool
 * @notice Only allowed deployers can deploy pools and only allowed yTokens are allowed
 */
function createPool(
    address _xToken,
    address _yToken,
    uint16 _lpFee,
    ALTBCInput memory _tbcInput,
    uint256 _xAdd,
    string memory _name,
    string memory _symbol
) external onlyAllowedDeployers onlyAllowedYTokens(_yToken) returns (address deployedPool)
```

This function returns the address of the new pool. *See [Pool documentation](/concepts/pool) for more details.*
