2

I keep getting this error and totally lost, can someone please help?

The code is in python, i am using raydium pool keys to send a simulated transaction so i can calculate the price for my swap.

Instructions i am passing:

def make_simulate_pool_info_instruction(accounts, mint, ctx):
        accountProgramId = ctx.get_account_info_json_parsed(Pubkey.from_string(mint))
        TOKEN_PROGRAM_ID = accountProgramId.value.owner
        keys = [
        AccountMeta(pubkey=accounts["amm_id"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["authority"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["open_orders"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["base_vault"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["quote_vault"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["lp_mint"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["market_id"], is_signer=False, is_writable=False),     
        ]
        data = POOL_INFO_LAYOUT.build(
            dict(
                instruction=12,
                simulate_type=0
            )
        )
        return Instruction(AMM_PROGRAM_ID, data, keys)

Rest of Python code:

pool_keys = fetch_pool_keys(mint)

sim_inst = make_simulate_pool_info_instruction(pool_keys, mint, solana_client)

recent_blockhash = solana_client.get_latest_blockhash().value.blockhash
txn = Transaction(fee_payer=sender.pubkey(), recent_blockhash=recent_blockhash)

txn.add(sim_inst)
txn.sign(sender)
temp = solana_client.simulate_transaction(txn)

Error that i keep getting:

 [
'Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 invoke [1]',
"Program log: panicked at 'called `Result::unwrap()` on an `Err` value: Custom(27)', src/processor.rs:4251:85", 
'Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 consumed 6492 of 200000 compute units',
'Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 failed: SBF program panicked'
   ]

I got the code from an old github repo of 2022 for transaction simulation.

3
  • Fixed it, thanks to raydium sdk... by adding this to instructions: AccountMeta(pubkey=accounts['event_queue'], is_signer=False, is_writable=False)
    – kokiez
    Commented Dec 26, 2023 at 6:55
  • Great! Can you post the solution an an answer and mark it as accepted?
    – Ademola
    Commented Dec 28, 2023 at 21:13
  • 1
    Thanks for letting me know @Ademola, back then my rep was less so thats why i commented under the post
    – kokiez
    Commented Dec 29, 2023 at 0:47

1 Answer 1

2

Fixed it, thanks to raydium sdk... by adding this to instructions: AccountMeta(pubkey=accounts['event_queue'], is_signer=False, is_writable=False)

Complete instructions:

def make_simulate_pool_info_instruction(accounts, mint, ctx):
        accountProgramId = ctx.get_account_info_json_parsed(Pubkey.from_string(mint))
        TOKEN_PROGRAM_ID = accountProgramId.value.owner
        keys = [
        AccountMeta(pubkey=accounts["amm_id"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["authority"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["open_orders"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["base_vault"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["quote_vault"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["lp_mint"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["market_id"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts['event_queue'], is_signer=False, is_writable=False)     
        ]
        data = POOL_INFO_LAYOUT.build(
            dict(
                instruction=12,
                simulate_type=0
            )
        )
        return Instruction(AMM_PROGRAM_ID, data, keys)
3
  • 1
    Good stuff. Thanks!
    – Ademola
    Commented Dec 29, 2023 at 6:55
  • What is POOL_INFO_LAYOUT @Ademola? Commented Jan 6 at 7:35
  • 1
    @randomdatascientist used to create instructions data type. for more details you may look at it in raydium-sdk>liquidity which is in typescript or my github project "raydium-convert-SOLorTokens"
    – kokiez
    Commented Jan 6 at 11:02

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.