# Factory Pool Deployer Interface

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

/**
 * @title IRainDeployer
 * @notice Interface for the RainDeployer contract.
 */
interface IRainDeployer {
    /* ========================== STRUCTS ======================================= */

    /**
     * @notice Struct to define parameters for creating a RainPool.
     * @param isPublic Indicates whether the pool is public or private.
     * @param resolverIsAI Indicates whether the owner is the pool resolver or not.
     * @param poolOwner The address of the pool owner.
     * @param referrer The address of the pool referrer.
     * @param startTime The timestamp when the pool starts.
     * @param endTime The timestamp when the pool ends.
     * @param numberOfOptions The total number of options available in the pool.
     * @param oracleEndTime The timestamp when oracle results should be finalized.
     * @param ipfsUri The IPFS URI containing metadata for the pool.
     * @param initialLiquidity The amount of initial liquidity added to the pool.
     * @param liquidityPercentages An array representing the percentage allocation of liquidity to each option.
     * @param poolResolver Address of the pool resolver
     */
    struct Params {
        bool isPublic;
        bool resolverIsAI;
        address poolOwner;
        address referrer;
        uint256 startTime;
        uint256 endTime;
        uint256 numberOfOptions;
        uint256 oracleEndTime;
        string ipfsUri;
        uint256 initialLiquidity;
        uint256[] liquidityPercentages;
        address poolResolver;
    }

    /* =============================  EVENTS ==================================== */

    /**
     * @notice Emitted when a new pool is created.
     * @param poolAddress The address of the newly created pool.
     * @param poolCreator The address of the pool creator.
     * @param uri The IPFS URI containing pool metadata.
     */
    event PoolCreated(
        address indexed poolAddress,
        address indexed poolCreator,
        string uri
    );

    /* ============================= ERRORS ================================= */

    /**
     * @dev Thrown when an action is attempted by an address that is not a created pool.
     */
    error OnlyCreatedPool();

    /**
     * @dev Thrown when the address is not valid.
     */
    error InvalidAddress();

    /* ============================= FUNCTIONS ================================= */

    /**
     * @notice Returns the address of the Oracle Factory used for creating oracle contracts.
     * @dev This address is set during deployment and used for resolving results.
     * @return The address of the Oracle Factory contract.
     */
    function oracleFactoryAddress() external view returns (address);

    /**
     * @notice Returns the address of the base token used in the pools.
     * @dev The base token is the primary currency used for transactions within the platform.
     * @return The address of the base token contract.
     */
    function baseToken() external view returns (address);

    /**
     * @notice Returns the platform's designated address for receiving fees.
     * @dev All platform fees are transferred to this address.
     * @return The address where platform fees are collected.
     */
    function platformAddress() external view returns (address);

    /**
     * @notice Returns the address for the backend pool result resolver AI.
     * @return The address of the resolver AI.
     */
    function resolverAI() external view returns (address);

    /**
     * @notice Returns the total number of pools created.
     * @dev This value is incremented each time a new pool is deployed.
     * @return The total count of deployed pools.
     */
    function totalPools() external view returns (uint256);

    /**
     * @notice Returns the number of decimals of the base token.
     * @dev This is used to normalize token amounts within the platform.
     * @return The decimal precision of the base token.
     */
    function baseTokenDecimals() external view returns (uint256);

    /**
     * @notice Returns the liquidity fee percentage.
     * @dev The liquidity fee is applied to the total pool funds.
     * @return The liquidity fee percentage.
     */
    function liquidityFee() external view returns (uint256);

    /**
     * @notice Returns the platform fee percentage.
     * @dev This fee is deducted from the total pool funds as a platform charge.
     * @return The platform fee percentage.
     */
    function platformFee() external view returns (uint256);

    /**
     * @notice Returns the fixed fee charged for oracle services.
     * @dev This fee is applied for using an external oracle to resolve pool outcomes.
     * @return The fixed oracle service fee.
     */
    function oracleFixedFee() external view returns (uint256);

    /**
     * @notice Returns the fee percentage allocated to pool creators.
     * @dev Pool creators receive a percentage of the total pool funds as their share.
     * @return The creator fee percentage.
     */
    function creatorFee() external view returns (uint256);

    /**
     * @notice Returns the fee percentage allocated to result resolvers.
     * @dev This fee compensates external resolvers who determine the pool outcome.
     * @return The result resolver fee percentage.
     */
    function resultResolverFee() external view returns (uint256);

    /**
     * @notice Returns the address of the `disputeResolverAI`.
     * @dev This is the address for the dispute resolver AI.
     * @return The address of the Dispute Resolver.
     */
    function disputeResolverAI() external view returns (address);

    /**
     * @notice Returns the current pool index for a given user.
     * @dev Each user has a unique pool index that tracks their pool creations.
     * @param user The address of the user.
     * @return The current pool index associated with the user.
     */
    function currentIndex(address user) external view returns (uint256);

    /**
     * @notice Returns the address of a specific pool created by a user.
     * @dev This function allows retrieval of pools based on user address and index.
     * @param user The address of the pool creator.
     * @param index The index of the pool for the user.
     * @return The address of the user's pool at the specified index.
     */
    function userPools(
        address user,
        uint256 index
    ) external view returns (address);

    /**
     * @notice Returns the address of a pool based on its global index.
     * @dev Pools are assigned unique global indices when deployed.
     * @param index The global index of the pool.
     * @return The address of the pool at the specified index.
     */
    function allPools(uint256 index) external view returns (address);

    /**
     * @notice Checks if a given address corresponds to a deployed pool.
     * @dev This function verifies if a pool was created using the deployer contract.
     * @param pool The address of the pool to check.
     * @return True if the pool exists, false otherwise.
     */
    function createdPools(address pool) external view returns (bool);

    /**
     * @notice Returns the address of a pool based on its global index.
     * @return The address of the rain token.
     */
    function rainToken() external view returns (address);

    /**
     * @notice Returns the address of a pool based on its global index.
     * @return The address of the pool mainnet uniswap v3 swaprouter .
     */
    function swapRouter() external view returns (address);

    /**
     * @notice Returns all function selectors provided by a specific facet.
     * @dev The `facet` parameter corresponds to the facet contract’s address
     *      registered within the diamond storage.
     * @param facet The facet address to query.
     * @param index The facet address to query.
     * @return The `facetSelectors`. The array of 4-byte function selectors implemented by that facet.
     */
    function facetFunctionSelectors(
        address facet,
        uint256 index
    ) external view returns (bytes4);

    /**
     * @notice Returns the address of the DiamondCut facet.
     * @dev This facet handles adding, replacing, or removing functions within the diamond.
     * @return The address of the DiamondCut facet.
     */
    function diamondCutFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondLoupe facet.
     * @dev This facet provides introspection functions for inspecting diamond facets and selectors.
     * @return The address of the DiamondLoupe facet.
     */
    function diamondLoupeFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondTrading facet.
     * @dev This facet contains the logic related to trading or marketplace operations.
     * @return The address of the DiamondTrading facet.
     */
    function diamondTradingFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondResolution facet.
     * @dev This facet manages dispute resolutions or settlement logic.
     * @return The address of the DiamondResolution facet.
     */
    function diamondResolutionFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondDispute facet.
     * @dev This facet contains the logic for initiating and handling disputes.
     * @return The address of the DiamondDispute facet.
     */
    function diamondDisputeFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondClaim facet.
     * @dev This facet manages claim logic, such as withdrawals, settlements, or reward claims.
     * @return The address of the DiamondClaim facet.
     */
    function diamondClaimFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondCancelOrder facet.
     * @dev This facet provides functionality for canceling or invalidating active orders.
     * @return The address of the DiamondCancelOrder facet.
     */
    function diamondCancelOrderFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondInfo facet.
     * @dev This facet provides informational and metadata retrieval functions.
     * @return The address of the DiamondInfo facet.
     */
    function diamondInfoFacet() external view returns (address);

    /**
     * @notice Returns the address of the DiamondGetter facet.
     * @dev This facet exposes read-only getter functions for on-chain data inspection.
     * @return The address of the DiamondGetter facet.
     */
    function diamondGetterFacet() external view returns (address);

    /**
     * @notice Initializes the Rain Deployer contract with required parameters.
     * @dev This function sets the core addresses and fee structures for the contract.
     * It should only be called once during contract deployment.
     * @param _rainFactory The address of the RainFactory contract.
     * @param _oracleFactoryAddress The address of the Oracle Factory contract.
     * @param _baseToken The address of the base token used for transactions.
     * @param _platformAddress The address where platform fees are collected.
     * @param _resolverAI The address of the pool result resolver AI.
     * @param _rainToken The address of the Rain Token.
     * @param _swapRouter The address of the uniswap v3 Swap Router.
     * @param _baseTokenDecimals The number of decimals of the base token.
     * @param _liquidityFee The percentage fee allocated for liquidity providers.
     * @param _platformFee The percentage fee collected by the platform.
     * @param _oracleFixedFee The fixed fee for using an oracle service.
     * @param _creatorFee The percentage fee allocated to pool creators.
     * @param _resultResolverFee The percentage fee paid to result resolvers.
     */
    function initialize(
        address _rainFactory,
        address _oracleFactoryAddress,
        address _baseToken,
        address _platformAddress,
        address _resolverAI,
        address _rainToken,
        address _swapRouter,
        uint256 _baseTokenDecimals,
        uint256 _liquidityFee,
        uint256 _platformFee,
        uint256 _oracleFixedFee,
        uint256 _creatorFee,
        uint256 _resultResolverFee
    ) external;

    /**
     * @notice Creates a new RainPool contract instance with the given parameters.
     * @dev Deploys a new RainPool contract and transfers the necessary base tokens
     * for initial liquidity and oracle fees if applicable.
     * @param params A struct containing all required parameters for pool creation.
     * @return The address of the newly created RainPool contract.
     */
    function createPool(
        IRainDeployer.Params memory params
    ) external returns (address);

    /**
     * @notice Creates an external oracle for resolving a pool's outcome.
     * @dev This function deploys a new oracle via the oracle factory contract.
     * @param numberOfOracles The number of oracle nodes to be created.
     * @param oracleReward The total reward distributed among the oracle nodes.
     * @param fixedFee A fixed fee for oracle creation.
     * @param creator The address of the pool creator.
     * @param endTime The timestamp when the oracle's result should be finalized.
     * @param totalNumberOfOptions The number of possible outcomes the oracle will validate.
     * @param questionUri A reference URI (e.g., IPFS) containing the event details.
     * @return The address of the newly created oracle.
     */
    function createOracle(
        uint256 numberOfOracles,
        uint256 oracleReward,
        uint256 fixedFee,
        address creator,
        uint256 endTime,
        uint256 totalNumberOfOptions,
        string memory questionUri
    ) external returns (address);

    /* =========================== SETTERS ====================================== */

    function setRainToken(address newRainToken) external;

    function setSwapRouter(address newSwapRouter) external;

    /**
     * @notice Updates the address of the resolver AI EOA.
     * @dev Can only be called by the contract owner.
     * @param newResolverAI The new resolver AI EOA address.
     */
    function setResolverAI(address newResolverAI) external;

    /**
     * @notice Updates the address of the Oracle Factory contract.
     * @dev Can only be called by the contract owner.
     * @param newOracleFactoryAddress The new oracle factory address.
     */
    function setOracleFactoryAddress(address newOracleFactoryAddress) external;

    /**
     * @notice Updates the base token and its decimal precision.
     * @dev Can only be called by the contract owner.
     * @param newBaseToken The address of the new base token.
     * @param newBaseTokenDecimals The decimal precision of the new base token.
     */
    function setBaseToken(
        address newBaseToken,
        uint256 newBaseTokenDecimals
    ) external;

    /**
     * @notice Updates the fixed fee required for oracle creation.
     * @dev Can only be called by the contract owner.
     * @param newOracleFixedFee The new oracle fixed fee.
     */
    function setOracleFixedFee(uint256 newOracleFixedFee) external;

    /**
     * @notice Updates the fee allocated to pool creators.
     * @dev Can only be called by the contract owner.
     * @param newCreatorFee The new creator fee.
     */
    function setCreatorFee(uint256 newCreatorFee) external;

    /**
     * @notice Updates the fee allocated to the result resolver.
     * @dev Can only be called by the contract owner.
     * @param newResultResolverFee The new result resolver fee.
     */
    function setResultResolverFee(uint256 newResultResolverFee) external;

    /**
     * @notice Updates the platform's treasury address.
     * @dev Can only be called by the contract owner.
     * @param newPlatformAddress The new platform address.
     */
    function setPlatformAddress(address newPlatformAddress) external;

    /**
     * @notice Updates the liquidity fee percentage.
     * @dev Can only be called by the contract owner.
     * @param newLiquidityFee The new liquidity fee percentage.
     */
    function setLiquidityFee(uint256 newLiquidityFee) external;

    /**
     * @notice Updates the platform fee percentage.
     * @dev Can only be called by the contract owner.
     * @param newPlatformFee The new platform fee percentage.
     */
    function setPlatformFee(uint256 newPlatformFee) external;

    /**
     * @notice Updates the address of the Dispute Resolver AI.
     * @dev Can only be called by the contract owner.
     * @param newDisputeResolverAI The new RainFactory address.
     */
    function setDisputeResolverAI(address newDisputeResolverAI) external;
}

```


---

# 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://rain-4.gitbook.io/rain-docs/factory-pool-deployer-interface.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.
