0

I’m working with a public GitHub repo (you can find it here: https://github.com/AL-THE-BOT-FATHER/raydium_py) that interacts with the Raydium decentralized exchange using Python. I’m trying to fetch liquidity pool keys but am encountering the following error:

Fetching pool keys...
Error fetching pool keys: a bytes-like object is required, not 'solders.account_decoder.ParsedAccount'
No pool keys found....

Here’s the relevant part of the code (utils.py in the repo) from the repo that is causing the issue:

def fetch_pool_keys(pair_address: str) -> Optional[PoolKeys]:
    try:
        amm_id = Pubkey.from_string(pair_address)
        amm_data = client.get_account_info_json_parsed(amm_id, commitment=Processed).value.data
        amm_data_decoded = LIQUIDITY_STATE_LAYOUT_V4.parse(amm_data)
        marketId = Pubkey.from_bytes(amm_data_decoded.serumMarket)
        marketInfo = client.get_account_info_json_parsed(marketId, commitment=Processed).value.data
        market_decoded = MARKET_STATE_LAYOUT_V3.parse(marketInfo)
        vault_signer_nonce = market_decoded.vault_signer_nonce

        pool_keys = PoolKeys(
            amm_id=amm_id,
            base_mint=Pubkey.from_bytes(market_decoded.base_mint),
            quote_mint=Pubkey.from_bytes(market_decoded.quote_mint),
            base_decimals=amm_data_decoded.coinDecimals,
            quote_decimals=amm_data_decoded.pcDecimals,
            open_orders=Pubkey.from_bytes(amm_data_decoded.ammOpenOrders),
            target_orders=Pubkey.from_bytes(amm_data_decoded.ammTargetOrders),
            base_vault=Pubkey.from_bytes(amm_data_decoded.poolCoinTokenAccount),
            quote_vault=Pubkey.from_bytes(amm_data_decoded.poolPcTokenAccount),
            market_id=marketId,
            market_authority=Pubkey.create_program_address( 
                [bytes(marketId), bytes_of(vault_signer_nonce)],
                OPEN_BOOK_PROGRAM,
            ),
            market_base_vault=Pubkey.from_bytes(market_decoded.base_vault),
            market_quote_vault=Pubkey.from_bytes(market_decoded.quote_vault),
            bids=Pubkey.from_bytes(market_decoded.bids),
            asks=Pubkey.from_bytes(market_decoded.asks),
            event_queue=Pubkey.from_bytes(market_decoded.event_queue),
        )

        return pool_keys
    except Exception as e:
        print(f"Error fetching pool keys: {e}")
        return None

The error suggests that there’s a problem with how I’m handling the ParsedAccount object, stating that a bytes-like object is required but a solders.account_decoder.ParsedAccount is being passed. Despite trying multiple approaches, I keep hitting the same error.

Additionally, the creator of the repo mentioned that Free-Tier RPCs might not work correctly, and recommended using Helius or Quicknode. I’ve tested both services, including the paid versions, but the error persists.

Has anyone encountered a similar issue or have any suggestions for resolving it? Any guidance would be greatly appreciated!

PS: The method is used for buying and selling. While buying works fine, when trying to sell there appears this error...

2
  • I suggest removing the try/except from your code to see what is the real error you're getting. I arrived here because I'm playing with the same code as well, and got the same error. When I removed the try/except, I realized that the get_account_info_json_parsed runs well, but the value.data field of the response is empty. Maybe you're having the same issue. I haven't solved it yet. If you come up with something let me know :) Commented Dec 11, 2024 at 15:11
  • @Cristóbal thanks for your answer. For me the error remains the same, have you found a solution yet? Commented Dec 12, 2024 at 14:11

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.