0

Currently, I am fetching all liquidity-related data from Raydium API. (https://api.raydium.io/v2/sdk/liquidity/mainnet.json) And then matching with my desired token address to filter the right PoolKeys. But this process is taking too much time. Is there any way to do it faster?

Here is my code snippet

// Pass both token addresses (mint), and it will return the data of the pool of those tokens.
const getPoolKeys = async (tokenA, tokenB) => {
    const liquidityJsonResp = await fetch(liquidityFile);
    if (!liquidityJsonResp.ok) return
    const liquidityJson = await liquidityJsonResp.json()
    const allPoolKeysJson = [...(liquidityJson?.official ?? []), ...(liquidityJson?.unOfficial ?? [])]

    const poolData = allPoolKeysJson.find(
        (i) => (i.baseMint === tokenA && i.quoteMint === tokenB) || (i.baseMint === tokenB && i.quoteMint === tokenA)
    )
    if (!poolData) return null
    return jsonInfo2PoolKeys(poolData)
};

2 Answers 2

0

I didn't find a better way either, so what I did is to get that mainnet.json and then trim it for the necessary tokens, and then just use the trimmed mainnet.json.

I added it here Solana: How to perform token swaps using the Raydium SDK

0

I have found a faster and better solution. Check this repo https://github.com/CoreDevsLtd/getPools_solana_raydium

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.