-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
I am trying to learn how to launch a legacy AMMv4 pool on Raydium on Devnet
I was able to create an OpenBook market with the output in the terminal as follows:
Success! You just created an OpenBook market on devnet!
You're now ready to create the Raydium AMM pool linked to that market.
✅ Got Market ID: Gj9i13ggMzKpZ6TDkbpgK3ZWNab3ZVtEzxyHapgJMV1A
I proceeded to try creating a legacy AMMv4 pool by running the following code (for learning purposes, I wanted it to be AMMv4.)
// Create a Raydium Legacy AMM v4 pool on Devnet
// Requirements: node.js, npm install dotenv @raydium-io/raydium-sdk-v2 @solana/web3.js @solana/spl-token
import { config } from 'dotenv';
config();
import {
Connection,
Keypair,
PublicKey,
sendAndConfirmTransaction,
Transaction,
} from '@solana/web3.js';
import {
getAssociatedTokenAddressSync,
createAssociatedTokenAccountInstruction,
} from '@solana/spl-token';
import {
TxVersion,
DEVNET_PROGRAM_ID,
makeCreatePoolV4InstructionV2
} from '@raydium-io/raydium-sdk-v2';
const RPC_URL = 'https://api.devnet.solana.com';
const connection = new Connection(RPC_URL, 'confirmed');
const WALLET = Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(process.env.PRIVATE_KEY))
);
const BASE_MINT = new PublicKey('5QRutHk9sPSkwbrFQHmgY8ETy49RDe1HpaXwj1zMDaRK'); // GIGACHAD
const QUOTE_MINT = new PublicKey('So11111111111111111111111111111111111111112'); // wSOL
const OPENBOOK_MARKET = new PublicKey('Gj9i13ggMzKpZ6TDkbpgK3ZWNab3ZVtEzxyHapgJMV1A');
const BASE_AMOUNT = 6042069100;
const QUOTE_AMOUNT = 1_000_000_000; // 1 wSOL
async function main() {
const ownerBaseATA = getAssociatedTokenAddressSync(BASE_MINT, WALLET.publicKey);
const ownerQuoteATA = getAssociatedTokenAddressSync(QUOTE_MINT, WALLET.publicKey);
const ixInitBaseATA = await connection.getAccountInfo(ownerBaseATA)
? []
: [createAssociatedTokenAccountInstruction(WALLET.publicKey, ownerBaseATA, WALLET.publicKey, BASE_MINT)];
const ixInitQuoteATA = await connection.getAccountInfo(ownerQuoteATA)
? []
: [createAssociatedTokenAccountInstruction(WALLET.publicKey, ownerQuoteATA, WALLET.publicKey, QUOTE_MINT)];
const result = await makeCreatePoolV4InstructionV2({
connection,
programId: DEVNET_PROGRAM_ID.AmmV4,
marketId: OPENBOOK_MARKET,
baseMint: BASE_MINT,
quoteMint: QUOTE_MINT,
baseAmount: BASE_AMOUNT,
quoteAmount: QUOTE_AMOUNT,
ownerInfo: {
feePayer: WALLET.publicKey,
wallet: WALLET.publicKey,
tokenAccounts: [ownerBaseATA, ownerQuoteATA],
},
makeTxVersion: TxVersion.V0,
});
if (!result || !Array.isArray(result.innerTransactions)) {
throw new Error('Raydium SDK did not return valid innerTransactions');
}
for (const iTx of result.innerTransactions) {
const tx = new Transaction().add(...iTx.instructions);
tx.feePayer = WALLET.publicKey;
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
const txid = await sendAndConfirmTransaction(connection, tx, [WALLET, ...iTx.signers]);
console.log('Confirmed tx:', txid);
}
console.log('✅ Legacy AMM v4 Pool created');
}
main().catch((err) => {
console.error('❌ Pool creation failed:', err);
});
Looking at search results for AMMv4 through the github repo, I am really confused if it's doable anymore. Does raydium-sdk no longer support this?
I was looking for a demo for creating a legacy AMMv4 liquidity pool but couldn't find one.
Could someone point me in the right direction?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels