3

I am trying to get token accounts from mint and owner address.

Mint : 7HR9uH1QgDS53GfzoNgG9jieKVY1FARN1oYDQyZ63X4y  
Owner: GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL -> Raydium LP Token
Token Program : TOKEN_2022_PROGRAM_ID

With following code

getAssociatedTokenAddressSync(mint, owner, true, TOKEN_2022_PROGRAM_ID);

I am getting : gf8LBrffvbUh3zbnw4dGJ9nCuMAFJZhrG2aYrg2e6NJ

Whereas per solscan, it should be 2SwqDsKAMjLKYkUhwJGmSQ5aC3HShVJt2ZWH4i4tnRi4 https://solscan.io/account/2SwqDsKAMjLKYkUhwJGmSQ5aC3HShVJt2ZWH4i4tnRi4

Any idea ?

2 Answers 2

3
+50

This address is not the associated token account. If you see the initialization transaction at https://explorer.solana.com/tx/4AA66xmswj3hkvW4fEvjFMdpBCFTckdq1sQgvn8tC2aRo4TD61kX3pufyLowHVHwVuqWiWb5w8Xkf8rNYBccDRyC, you'll see that the account is not created with the associated token account program in #4.12. It's likely some other program-derived address.

gf8LBrffvbUh3zbnw4dGJ9nCuMAFJZhrG2aYrg2e6NJ is the correct ATA.

0

The reason this doesn't work is because this is not an ATA. Instead, it's a Raydium vault PDA. You can see the seeds used to derive it here:

// The provided mint
const mint = new PublicKey('7HR9uH1QgDS53GfzoNgG9jieKVY1FARN1oYDQyZ63X4y');
// The state account for the provided market (https://solscan.io/account/5M1cRSDQT4aYZTgcCfoZc3At1A4cod861A2jcPes46jY)
const poolState = new PublicKey('5M1cRSDQT4aYZTgcCfoZc3At1A4cod861A2jcPes46jY');
// The Raydium CLMM program address
const prog = new PublicKey('CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C');
// From https://github.com/raydium-io/raydium-cp-swap/blob/59cfb316901c64cc4c40df68f88c6a31f078228a/programs/cp-swap/src/states/pool.rs#L7
const seed = 'pool_vault';

// From the Raydium source code linked above
const poolAccount = PublicKey.findProgramAddressSync(
    [Buffer.from(seed), poolState.toBytes(), mint.toBytes()],
    prog,
)[0];

// Logs 2SwqDsKAMjLKYkUhwJGmSQ5aC3HShVJt2ZWH4i4tnRi4
console.log(poolAccount.toBase58());

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.