1

I am using node js @solana/web3 and @solana/spl-token and spl-token-swap libraries to perform a swap of token. I am confused with what should be the value of tokenSwapStateAccount and where would I get it ? Can anyone help me with this ?

const swapInstruction = TokenSwap.swapInstruction(
  tokenSwapStateAccount,
  swapAuthority,
  userPublicKey,
  userTokenA,
  poolTokenA,
  poolTokenB,
  userTokenB,
  poolMint,
  feeAccount,
  null,
  TOKEN_SWAP_PROGRAM_ID,
  TOKEN_PROGRAM_ID,
  amount * 10 ** MintInfoTokenA.decimals,
  0
)

transaction.add(swapInstruction)

1 Answer 1

1

tokenSwapStateAccount refers to the "pool" account that describes things like the token mints involved in the pool and the mint for the LP tokens.

You can see how it's created in the spl-token-swap tests at https://github.com/solana-labs/solana-program-library/blob/74df99dec0309a682ce29765e76f67be30474ea9/token-swap/js/test/main.test.ts#L131

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.