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

# Check if a pool exists (V1)

> Check whether a SaucerSwap V1 liquidity pool exists on-chain with the factory getPair function before creating a pool or adding liquidity on Hedera.

When adding a new or existing liquidity pool, the initial step is typically to verify if the liquidity pool already exists before determining the next course of action. The factory contract provides a method to retrieve the pool address, if it exists, as shown below.

<Tip>
  Checking if the liquidity pool exists using SaucerSwap's REST API is also a suitable alternative. For more information, see [Get V1 liquidity pools](/developers/v1/liquidity/fetch-all-pools)
</Tip>

## Get the existing liquidity pool if it exists

*No gas cost — read-only call.*

Get the existing liquidity pool's CREATE2 EVM address if it exists. If the pool does not exist on-chain, a zero address will be returned.

Function name: `getPair`

| Parameter Name   | Description                     |
| ---------------- | ------------------------------- |
| *address tokenA* | EVM address of the first token  |
| *address tokenB* | EVM address of the second token |

<CodeGroup>
  ```solidity IUniswapV2Factory.sol theme={null}
  function getPair(
    address tokenA,
    address tokenB
  ) external view returns (address pair);
  ```
</CodeGroup>

<Note>
  The ordering of tokens for tokenA and tokenB does not matter.
</Note>

<Tip>
  When working with HBAR, use the wrapped HBAR token ID ([WHBAR](https://hashscan.io/mainnet/token/0.0.1456986)) for either tokenA or tokenB.
</Tip>

### Code overview

<Tabs>
  <Tab title="JSON RPC">
    Resources:

    * [SaucerSwap deployed contract IDs](/developers/contracts)
    * [Ethers.js docs (v6)](https://docs.ethers.org/v6/)
    * [Hedera JSON RPC Relay](https://docs.hedera.com/evm/tutorials/intermediate/json-rpc-connections)

    ```typescript theme={null}
    import * as ethers from 'ethers'; //V6

    //Set one of Hedera's JSON RPC Relay as the provider
    const provider = new ethers.JsonRpcProvider(hederaJsonRelayUrl, '', {
      batchMaxCount: 1, //workaround for V6
    });

    //load ABI data containing the Factory's getPair function
    const interfaces = new ethers.Interface(abi);

    const factoryContract = new ethers.Contract(factoryEvmAddress, interfaces.fragments, provider);
    const result = await factoryContract.getPair(tokenA, tokenB); //(tokenB, tokenA) will give same result
    const poolEvmAddress = result; //address pool
    ```
  </Tab>
</Tabs>

## Next steps

<CardGroup cols={2}>
  <Card title="Create a new pool (V1)" href="/developers/v1/liquidity/create-a-new-pool">
    Create the pool if it does not exist yet.
  </Card>

  <Card title="Fetch all pools (V1)" href="/developers/v1/liquidity/fetch-all-pools">
    List every V1 pool from the REST API.
  </Card>
</CardGroup>
