raydium-sdk
raydium-sdk copied to clipboard
Fetch Info simulation error
Hello, I found the problem while calling Liquidity.fetchInfo() from liquidity.ts
static async fetchInfo({ connection, poolKeys }: LiquidityFetchInfoParams) {
sometimes it gives an error
reason: 'failed to simulate for instructions'
sometimes its works correctly (from 100 calls it work only aprx for 60)
how to figure out what the reason? tried with different rpc public and paid ones, problem remains
also found some folks at Raydium discord with the same problem
same error
Is there any solution found yet?
I have the same problem. It's hard to reproduce and when it happens the sdk hides the details of why it failed. I opened another issue #77
I have same issue. I tried to do a call just for the 1 pool.
same error
same
Same error on localhost by clone program from devnet to local.
solana-test-validator -r \
--ledger ~/.anchor/test-ledger \
--url devnet \
--clone-upgradeable-program HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8 \
--clone-upgradeable-program EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj \
--clone 3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR \
--clone 8QN9yfKqWDoKjvZmqFsgCzAqwZBQuzVVnC388dN5RCPo \
--clone RaydiumSimuLateTransaction11111111111111111
Got an error Program HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8 failed: instruction modified data of a read-only account
by calling Liquidity.fetchInfo
functions.
But it seems working fine on devnet
Anybody find a solution so far??
Yes. In my case, I just needed to call the Raydium FetchInfo API to fetch the updated reserves. I simply wrote a method to do this for me.
const reserves = await this.calculateReserves(poolKeys) as LiquidityPoolInfo
private async calculateReserves(poolKeys: LiquidityPoolKeysV4) {
try {
const baseAmount = await this.getTokenAmount(poolKeys.baseVault);
const quoteAmount = await this.getTokenAmount(poolKeys.quoteVault);
logger.info("base vault", poolKeys.baseVault)
logger.info("quote vault", poolKeys.quoteVault)
logger.info("base decimals", poolKeys.baseDecimals)
logger.info("quote decimals", poolKeys.quoteDecimals)
const baseReserve = baseAmount.div(new BN(10).pow(new BN(poolKeys.baseDecimals)));
const quoteReserve = quoteAmount.div(new BN(10).pow(new BN(poolKeys.quoteDecimals)));
console.log('Base Reserve:', baseReserve.toString());
console.log('Quote Reserve:', quoteReserve.toString());
return { baseReserve, quoteReserve };
} catch (error) {
console.error('Failed to calculate reserves:', error);
throw error;
}
}
Yes. In my case, I just needed to call the Raydium FetchInfo API to fetch the updated reserves. I simply wrote a method to do this for me.
@roshaans is that working fine?