Skip to content

tradeV2.fetchRoutePoolBasicInfo not working #153

@lwandsyj

Description

@lwandsyj

I'm using Router Swap to swap tokens. It works on devnet, but tradeV2.fetchRoutePoolBasicInfo doesn't respond on mainnet. The request goes unanswered for several minutes.

This is my test code:

import { SolanaNodeManager } from '../src/utils'
import { initSdk } from '../src/raydium'
import { clusterApiUrl, Connection, Keypair } from '@solana/web3.js'
import bs58 from 'bs58'
import { Raydium, AMM_V4, CLMM_PROGRAM_ID, CREATE_CPMM_POOL_PROGRAM } from '@raydium-io/raydium-sdk-v2'

// 可用的RPC节点列表
const RPC_ENDPOINTS = [
"https://wider-delicate-aura.solana-mainnet.quiknode.pro/e2348b868a6fe56384efe6abb94a15f8962be9d0"
]

async function main() {
let connection: Connection | null = null

// 尝试使用多个RPC节点
for (const endpoint of RPC_ENDPOINTS) {
    try {

        connection = new Connection(endpoint, 'confirmed')
        
        // 测试连接
        const slot = await connection.getSlot()
        break
    } catch (error:any) {
        continue
    }
}

if (!connection) {
    return
}

const pair = Keypair.generate().secretKey
const raydium = await Raydium.load({
    owner: Keypair.fromSecretKey(pair),
    connection,
    cluster: "mainnet",
    disableFeatureCheck: true,
    blockhashCommitment: 'finalized',
})

try {
    const pools = await raydium.tradeV2.fetchRoutePoolBasicInfo({
        amm: AMM_V4,
        clmm: CLMM_PROGRAM_ID,
        cpmm: CREATE_CPMM_POOL_PROGRAM,
    })
    
} catch (error:any) {
    try {
        const response = await fetch('https://api.raydium.io/v2/sdk/liquidity/mainnet.json')
        const data:any = await response.json()
        
    } catch (backupError:any) {
       
    }
}

}

main().catch(console.error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions