Skip to content

invoke_arbitrage call failed #3

@1500256797

Description

@1500256797

CPI call failed. Although I successfully completed all the steps according to the tutorial, the program execution failed at the invoke_arbitrage step. This is my on-chain record, which is strange because I didn't make any modifications to the contract.

I've tried many methods but none of them work. Do you have any suggestions?

here is code


/// Invokes the arbitrage trade by sending a cross-program invocation (CPI)
/// first to the swap program we intend to buy from (receive), and then
/// immediately send another CPI to the swap program we intend to sell to
fn invoke_arbitrage(
    buy: (Pubkey, &[AccountInfo], u64),
    sell: (Pubkey, &[AccountInfo], u64),
) -> ProgramResult {
    let (buy_swap_ix_data, sell_swap_ix_data) = build_ix_datas(buy.2, sell.2);
    let ix_buy = Instruction::new_with_borsh(
        buy.0,
        &buy_swap_ix_data,
        buy.1.iter().map(ToAccountMeta::to_account_meta).collect(),
    );
    let ix_sell = Instruction::new_with_borsh(
        sell.0,
        &sell_swap_ix_data,
        sell.1.iter().map(ToAccountMeta::to_account_meta).collect(),
    );
    msg!("Executing buy ...");
    invoke(&ix_buy, buy.1)?;
    msg!("Executing sell ...");
    invoke(&ix_sell, sell.1)?;
    Ok(())
}

here is tx :

#1 Unknown Program (CUpZa6BrZUB5Gxg5DpUEp6gpvkT6VD77QSCbMR98WrE8) instruction
> Program log: get all accounts
> Program log: swap1 poll1 7GvGoEYPdJC2CdXbBC8LkNuduFA1Nq6q4JqRCXMq7Zgs 2B3b5fc4UsobG3WYsJwcCmwB7rCM4xL7TSdzzUTN9n4M
> Program log: swap2 poll2 HkajruugY9wqhqoQaYGwh5k1gbBbNVvXNmqQHWbkZnAP ENjzHsPFvQHtecySggo4uS94dDACWBdxUp9ZED4pyARe
> Program log: user account 8pi6Hsg4asYkvyfHd7d5fxqvbVkkSHKvnNceXEmZ8VTB 165
> Program log: user account 8pi6Hsg4asYkvyfHd7d5fxqvbVkkSHKvnNceXEmZ8VTB 165
> Program log: get token accounts user
> Program log: get token accounts swap 1
> Program log: get token accounts swap 2
> Program log: before try arbitrage
> Program log: Swap #1 Pool: 2B3b5fc4UsobG3WYsJwcCmwB7rCM4xL7TSdzzUTN9n4M
> Program log: Swap #2 Pool: ENjzHsPFvQHtecySggo4uS94dDACWBdxUp9ZED4pyARe
> Program log: PLACING TRADE!
> Program log: Buy on Swap #2 and sell on Swap #1
> Program log: Executing buy ...
> Program [CUpZa6BrZUB5Gxg5DpUEp6gpvkT6VD77QSCbMR98WrE8](https://solscan.io/account/CUpZa6BrZUB5Gxg5DpUEp6gpvkT6VD77QSCbMR98WrE8?cluster=devnet) consumed 112239 of 200000 compute units
> Program returned error: Access violation in unknown section at address 0xb of size 374

https://solscan.io/tx/3B2HwhzUFrHoPUfPVfmx7EE4Hr4vAEN2cQctWLgszp5A7E2CxpvtDkQsWBzDK3zvP8daJVBEY6nUnpr576Rcukwt?cluster=devnet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions