I was learning solana evm on devnet and I started to code a token with @solana/spl-token library and then I tried to add a liquidity to radiyum and then it asked for openbook market id , I want to know how can I generate openbook market id and why does it cost 2.78 SOL , can i just generate it myself?
1 Answer
You might assume generating a market ID in Solana is relevant to creating a token pair in Ethereum. It's a prerequisite step for creating a LP in Solana.
The cost you're seeing (2.78 SOL) is due to the rent exempt status of accounts and transaction fees.
Here are some links for your reference.
https://github.com/raydium-io/raydium-sdk-V1-demo/blob/master/src/utilsCreateMarket.ts https://github.com/raydium-io/raydium-sdk-V1-demo/blob/master/src/ammCreatePool.ts
Below is my working example.
const {
MarketV2,
MAINNET_PROGRAM_ID,
DEVNET_PROGRAM_ID
} = require('@raydium-io/raydium-sdk')
const {
connection,
makeTxVersion,
} = require('../config.js')
const { buildAndSendTx } = require('./util')
async function createMarket(input) {
const RAYDIUM_PROGRAM_ID = process.env.NETWORK == 'mainnet' ? MAINNET_PROGRAM_ID : DEVNET_PROGRAM_ID
// -------- step 1: make instructions --------
const createMarketInstruments = await MarketV2.makeCreateMarketInstructionSimple({
connection,
wallet: input.wallet.publicKey,
baseInfo: input.baseToken,
quoteInfo: input.quoteToken,
lotSize: input.lotSize, // default 1
tickSize: input.tickSize, // default 0.01
dexProgramId: RAYDIUM_PROGRAM_ID.OPENBOOK_MARKET,
makeTxVersion,
})
marketId = createMarketInstruments.address.marketId
txids = await buildAndSendTx(createMarketInstruments.innerTransactions, { skipPreflight: true })
console.log('Market Created')
console.log('Create Market Transactions :', txids)
console.log('Market Address :', marketId)
return marketId
}
module.exports = {
createMarket
};
For better understanding of market id and lot and tick size, take a look at this doc https://docs.raydium.io/raydium/updates/archive/creating-an-openbook-amm-pool#how-to-create-a-permissionless-pool