2

I'm following along with this site https://www.soldev.app/course/token-swap.

However, there seems to be a version difference in the use of TokenSwap.withdrawAllTokenTypesInstruction: I'm using the latest version (0.4.0), but above site is using 0.1.3.

The difference is that the arguments for the withdrawAllTokenTypesInstruction are different, and in my version(0.4.0):

static depositAllTokenTypesInstruction(
    tokenSwap: PublicKey,
    authority: PublicKey,
    userTransferAuthority: PublicKey,
    sourceA: PublicKey,
    sourceB: PublicKey,
    intoA: PublicKey,
    intoB: PublicKey,
    poolToken: PublicKey,
    poolAccount: PublicKey,
    mintA: PublicKey,
    mintB: PublicKey,
    swapProgramId: PublicKey,
    tokenProgramIdA: PublicKey,
    tokenProgramIdB: PublicKey,
    poolTokenProgramId: PublicKey,
    poolTokenAmount: bigint,
    maximumTokenA: bigint,
    maximumTokenB: bigint,
  )

and my guess is that the argument "poolTokenProgramId" is incorrect, I used TOKEN_PROGRAM_ID(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA) for that argument, but I am getting an error.

What should I put as the value of poolTokenProgramId?

This is my code

const depositIx = TokenSwap.depositAllTokenTypesInstruction(
            tokenSwapStateAccount,
            swapAuthority,
            publicKey,
            kryptATA,
            scroogeATA,
            poolKryptAccount,
            poolScroogeAccount,
            poolMint,
            tokenAccountPool,
            kryptMint,
            ScroogeCoinMint,
            TOKEN_SWAP_PROGRAM_ID,
            token.TOKEN_PROGRAM_ID,
            token.TOKEN_PROGRAM_ID,
            token.TOKEN_PROGRAM_ID,
            poolTokenAmount * 10 ** poolMintInfo.decimals,
            100e9,
            100e9,
        );

and this is error code

client.js:1 WalletSendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: incorrect program id for instruction
    at StandardWalletAdapter.sendTransaction (adapter.js:205:1)
    at async eval (WalletProviderBase.js:152:1) StandardWalletAdapter {_events: Events, _eventsCount: 4, signTransaction: ƒ, signAllTransactions: ƒ, signMessage: ƒ}
5
  • Could you provide more details about the error you’re getting? If it fails at simulation, pass {skipPreflight = true} when sending your tx to be able to view the failed transaction on-chain.
    – Orion
    Commented Jan 22 at 13:30
  • This is error in console, Uncaught (in promise) WalletSendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: incorrect program id for instruction And I modified my code like this, let txid = await sendTransaction(tx, connection, {skipPreflight = true}); but I couldn't see it on-chain.
    – MONO
    Commented Jan 22 at 13:59
  • I think your swap program id is incorrect
    – wei1769
    Commented Jan 22 at 22:54
  • Oh thank you!!!!, The above error was resolved by changing the TOKEN_SWAP_PROGRAM_ID to OLD_TOKEN_SWAP_PROGRAM_ID, but another error occurred. Error: The provided token program does not match the token program expected by the swap custom program error: 0x18 help me plz :'(
    – MONO
    Commented Jan 24 at 5:11
  • Oh I Resolved. I put the same token.TOKEN_PROGRAM_ID in mintA and mintB above and it works fine.
    – MONO
    Commented Jan 24 at 5:23

2 Answers 2

2

It solved with this code

const depositIx = TokenSwap.depositAllTokenTypesInstruction(
    tokenSwapStateAccount,
    swapAuthority,
    publicKey,
    kryptATA,
    scroogeATA,
    poolKryptAccount,
    poolScroogeAccount,
    poolMint,
    tokenAccountPool,
    token.TOKEN_PROGRAM_ID, // TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
    token.TOKEN_PROGRAM_ID,
    OLD_TOKEN_SWAP_PROGRAM_ID, // SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8
    token.TOKEN_PROGRAM_ID,
    token.TOKEN_PROGRAM_ID,
    token.TOKEN_PROGRAM_ID,
    poolTokenAmount * 10 ** poolMintInfo.decimals,
    100e9,
    100e9,
);

-1

How did u solve the problem, I faced it too. Did u create the token swap with old program id?

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.