> For the complete documentation index, see [llms.txt](https://docs.syncswap.xyz/api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.syncswap.xyz/api-documentation/core-architecture/pool-master.md).

# Pool Master

The Pool Master is a registry for all liquidity pools and manages the whitelist of pool factories.

The master inherits the interface of the fee manager to support the queries of pools' trading fees and the protocol fees in one place.

## Interface

See the Fee Manager for more information regarding fees.

```solidity

/// @dev The master contract to create pools and manage whitelisted factories.
/// Inheriting the fee manager interface to support fee queries.
interface IPoolMaster is IFeeManager {
    event SetFactoryWhitelisted(address indexed factory, bool whitelisted);

    event RegisterPool(
        address indexed factory,
        address indexed pool,
        uint16 indexed poolType,
        bytes data
    );

    event UpdateFeeManager(address indexed previousFeeManager, address indexed newFeeManager);

    function vault() external view returns (address);

    function feeManager() external view returns (address);

    // Fees
    function setFeeManager(address) external;

    // Factories
    function isFactoryWhitelisted(address) external view returns (bool);

    function setFactoryWhitelisted(address factory, bool whitelisted) external;

    // Pools
    function isPool(address) external view returns (bool);

    function getPool(bytes32) external view returns (address);
    
    function pools(uint index) external view returns (address);
    
    function poolsLength() external view returns (uint);

    function createPool(address factory, bytes calldata data) external returns (address pool);

    function registerPool(address pool, uint16 poolType, bytes calldata data) external;
}

/// @dev The manager contract to control fees.
/// Management functions are omitted.
interface IFeeManager {
    // [Deprecated] The old interface before the dynamic fees update.
    //function defaultSwapFee(uint16 poolType) external view returns (uint24);

    // [Deprecated] The old interface before the dynamic fees update.
    //function customSwapFee(address pool) external view returns (uint24);

    // [Deprecated] The old interface before the dynamic fees update.
    //function feeRecipient() external view returns (address);

    // [Deprecated] The old interface before the dynamic fees update.
    //function protocolFee(uint16 poolType) external view returns (uint24);
    
    // [Deprecated] The old interface before the dynamic fees update.
    //function getSwapFee(address pool) external view returns (uint24 swapFee);
    
    // [Recommended] The new interface after the dynamic fees update.
    /// @dev Returns `0` for zero pool fee.
    function getSwapFee(
        address pool,
        address sender,
        address tokenIn,
        address tokenOut,
        bytes calldata data
    ) external view returns (uint24 fee);
    
    // [Recommended] The new interface after the dynamic fees update.
    /// @dev Returns `0` for zero pool fee.
    function getProtocolFee(address pool) external view returns (uint24 fee);
    
    // [Recommended] The new interface after the dynamic fees update.
    function getFeeRecipient() external view returns (address recipient);
}

```


---

# 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.syncswap.xyz/api-documentation/core-architecture/pool-master.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.
