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.
Checking if the liquidity pool exists using SaucerSwap’s REST API is also a suitable alternative. For more information, see Get V1 liquidity pools
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
The ordering of tokens for tokenA and tokenB does not matter.
When working with HBAR, use the wrapped HBAR token ID (WHBAR) for either tokenA or tokenB.
Code overview
Next steps
Create a new pool (V1)
Create the pool if it does not exist yet.
Fetch all pools (V1)
List every V1 pool from the REST API.