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?
To get the addresses of markets for two mint addresses, you'll need to go through a few steps.
TokenSwap
type by decoding, e.g. https://github.com/solana-labs/solana-program-library/blob/07bf49fdb820f8e3a40550998723e4878506af0b/token-swap/js/src/index.ts#L258mintA
and mintB
are the ones expected: https://github.com/solana-labs/solana-program-library/blob/07bf49fdb820f8e3a40550998723e4878506af0b/token-swap/js/src/index.ts#L65Note, 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.