raydium-sdk icon indicating copy to clipboard operation
raydium-sdk copied to clipboard

Fetch Info simulation error

Open vlcr777888 opened this issue 11 months ago • 12 comments

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

vlcr777888 avatar Mar 21 '24 14:03 vlcr777888

People who have the same problem 1 2 3 4 5

vlcr777888 avatar Mar 21 '24 14:03 vlcr777888

same error

Giopi avatar Mar 30 '24 19:03 Giopi

Is there any solution found yet?

nuhfurkan avatar Apr 18 '24 13:04 nuhfurkan

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

mdatsev avatar Apr 19 '24 12:04 mdatsev

I have same issue. I tried to do a call just for the 1 pool.

alexrepetskyi avatar Apr 26 '24 23:04 alexrepetskyi

same error

WhoIsMars avatar Apr 28 '24 10:04 WhoIsMars

same

roshaans avatar May 19 '24 05:05 roshaans

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

easoninus avatar May 26 '24 04:05 easoninus

Anybody find a solution so far??

mcfriend99 avatar Jun 09 '24 02:06 mcfriend99

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;
    }
  }

roshaans avatar Jun 09 '24 06:06 roshaans

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?

ParzifaL-03 avatar Sep 04 '24 16:09 ParzifaL-03