• Fetches all possible liquidity pools between two token mints in Orca Whirlpools. If a pool does not exist, it creates a placeholder account for the uninitialized pool with default data

    Parameters

    • rpc: Rpc<GetAccountInfoApi & GetMultipleAccountsApi & GetProgramAccountsApi>

      The Solana RPC client.

    • tokenMintOne: Address

      The first token mint address in the pool.

    • tokenMintTwo: Address

      The second token mint address in the pool.

    Returns Promise<PoolInfo[]>

    • A promise that resolves to an array of pool information for each pool between the two tokens.
    import { fetchWhirlpoolsByTokenPair, setWhirlpoolsConfig } from '@orca-so/whirlpools';
    import { createSolanaRpc, devnet, address } from '@solana/web3.js';

    await setWhirlpoolsConfig('solanaDevnet');
    const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));

    const tokenMintOne = address("So11111111111111111111111111111111111111112");
    const tokenMintTwo = address("BRjpCHtyQLNCo8gqRUr8jtdAj5AjPYQaoqbvcZiHok1k");

    const poolInfos = await fetchWhirlpoolsByTokenPair(
    devnetRpc,
    tokenMintOne,
    tokenMintTwo
    );

    poolInfos.forEach((poolInfo) => {
    if (poolInfo.initialized) {
    console.log("Pool is initialized:", poolInfo);
    } else {
    console.log("Pool is not initialized:", poolInfo);
    }
    });