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.


/// @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);
}

Last updated