solanatoken-swap-programsolana-program-librarysolana-web3js

How can I retrieve market ids for Solana token swap program?


Having mint addresses of two spl tokens on Solana mainnet, I need to find public key of all possible markets (i.e. marketId in the following code snippet) available on Solana to get token swap info from:

const tokenSwap = await TokenSwap.loadTokenSwap(
    con,
    new PublicKey(marketId),// << HERE
    TOKEN_SWAP_PROGRAM_ID,
    payerAaccount
);

I could not find any repository (similar to Raydium or Serum lp addresses) on github or anywhere else. Where can I find a list of liquid markets for spl token swap program? and/or is there any other way to calculate or retrieve token swap info based on token mint addresses?


Solution

  • To get the addresses of markets for two mint addresses, you'll need to go through a few steps.

    Note, however, that the current TOKEN_SWAP_PROGRAM_ID is deprecated by Serum in favor of using the Serum orderbooks. You may have to use their SDKs for Serum, or Raydium's to interact with those programs.