Create Market
Harcoded addresses
For a market to be displayed on the LFJ website, it needs to be created using the official config stated in the deployment addresses section.
const config = new PublicKey("LFJxVxETTXwoxuuFCpqj3KihrYxmJc7maQFg4UjHZ3r");
The official config is using WSOL as the quote token.
const wSol = new PublicKey("So11111111111111111111111111111111111111112");
We will use the Metaplex Metadata program for the token metadata.
const metaplexMetadata = new PublicKey(
"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
);
Some creation parameters that can be customized.
const name = "Test Market";
const symbol = "TEST";
const uri = "https://example.com/metadata.json";
// - Swap authority: Swaps can be restricted, requiring the signature of the swap authority to execute swaps
const swapAuthority = null;
Token address
The token address can be generated randomly or mined using solana-keygen grind
.
const baseTokenMint = Keypair.generate();
The token metadata account address needs to be computed.
const token0Metadata = PublicKey.findProgramAddressSync(
[
Buffer.from("metadata"),
metaplexMetadata.toBuffer(),
baseTokenMint.publicKey.toBuffer(),
],
metaplexMetadata
)[0];
Anchor will compute for us all the required ATAs.
Transaction
const connection = new anchor.web3.Connection(
process.env.RPC_URL ?? ""
);
const wallet = anchor.Wallet.local();
const program = new Program<TokenMillV2>(TokenMillIdl as any, {
connection,
});
const tx = await program.methods
.createMarket(name, symbol, uri, swapAuthority)
.accountsPartial({
tokenMillConfig: config,
tokenMint0: baseTokenMint.publicKey,
token0Metadata,
tokenMint1: wSol,
creator: wallet.publicKey,
})
.signers([wallet.payer, baseTokenMint])
.transaction();
const txSignature = await connection.sendTransaction(tx, [
wallet.payer,
baseTokenMint,
]);
await connection.confirmTransaction(txSignature);
Last updated