1

I'm trying to use Typescript to sell and buy in pumpfun but I got an error when I tried to sell it

here is my code

//@ts-ignore
const decimals = mintData.value?.data.parsed.info.decimals;
const virtualTokenReserves = (
    bondingCurveData.virtualTokenReserves as any
).toNumber();
const virtualSolReserves = (
    bondingCurveData.virtualSolReserves as any
).toNumber();
const adjustedVirtualTokenReserves = virtualTokenReserves / 10 ** decimals;
const adjustedVirtualSolReserves = virtualSolReserves / LAMPORTS_PER_SOL;
const virtualTokenPrice =
    adjustedVirtualSolReserves / adjustedVirtualTokenReserves;

let ata = new PublicKey(atalist[keypair.publicKey.toString()]);
let balance = await connection.getTokenAccountBalance(ata);
let amount = Math.floor(Number(balance.value.uiAmount));
let final_amount = new BN(amount * 10 ** decimals);
const slippage = new BN(amount * virtualTokenPrice * LAMPORTS_PER_SOL * 0.8);
const sellIx = await program.methods
    .sell(final_amount, slippage)
    .accounts({
        global,
        feeRecipient,
        user: keypair.publicKey,
        mint: mint,
        bondingCurve: bondingCurve,
        associatedBondingCurve: associatedBondingCurve,
        tokenProgram: spl.TOKEN_PROGRAM_ID,
        associatedUser: keylist[keypair.publicKey.toBase58()],
        //associatedUser: atalist[ata],associatedUser
        rent: SYSVAR_RENT_PUBKEY,
        systemProgram: SystemProgram.programId,
        eventAuthority,
        program: PUMP_PROGRAM,
    })
    .instruction();
const message = new TransactionMessage({
    payerKey: payer.publicKey,
    recentBlockhash: blockhash,
    instructions: sellIx,
}).compileToV0Message([lut]);

Here is my error message

Bundle cc898264d12e995b329c81f6a1ae4a40324a0410b33c54f9110756b5e7fa7ccf sent.
Received bundle result: {
  bundleId: 'cc898264d12e995b329c81f6a1ae4a40324a0410b33c54f9110756b5e7fa7ccf',
  accepted: undefined,
  rejected: {
    stateAuctionBidRejected: undefined,
    winningBatchBidRejected: undefined,
    simulationFailure: {
      txSignature: '3Q4MdfHfhaLZj1QqGetV8szwVZe4QjS68cPuoGCkZBwsoyhhhJ2EdT6V7VC2cwGWt1SgrxaWAjwrZoYUCBveBqZ3',
      msg: 'A transaction in the bundle failed to execute: [signature=3Q4MdfHfhaLZj1QqGetV8szwVZe4QjS68cPuoGCkZBwsoyhhhJ2EdT6V7VC2cwGWt1SgrxaWAjwrZoYUCBveBqZ3, error=Error processing Instruction 2: Program failed to complete]'
    },
    internalError: undefined,
    droppedBundle: undefined
  },
  finalized: undefined,
  processed: undefined,
  dropped: undefined
}

I don't totally understand why the error occur I would appreciate you guys if you could help me out

Thanks

0

Your Answer

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