Creating a Market

Creating a market is permissionless, so that anyone can create a new market using the Rust CLI or the JS library.

Make sure to crank the markets you create otherwise they may fail to function ⚠️

In order to create a market you will need:

  • The Pyth oracle symbol of the market

  • The initial amount of virtual quote currency you want for the market

Using the JS library

Example for BTC/USD

const connection = new Connection(ENDPOINT, "confirmed");
const secretKey = fs.readFileSync("...").toString();
const admin = Keypair.fromSecretKey(Buffer.from(JSON.parse(secretKey)));
// Mint of the
const mint = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // USDC Mint
const initial_v_pc_amount = 976040125199; // This is an example, use something different
let [signers, instructions] = await createMarket(
connection,
admin.publicKey,
admin.publicKey,
"BTC/USD",
mint,
6,
new Numberu64(initial_v_pc_amount)
);
let marketAddress = signers[0].publicKey;
console.log(
await signAndSendTransactionInstructions(
connection,
signers,
admin,
instructions
)
);
console.log("Created market at ", marketAddress.toBase58());
// Wait for propagation
await sleep(5_000);
[signers, instructions] = await addInstance(
connection,
marketAddress,
admin.publicKey,
admin.publicKey,
3,
50
);
signers.push(admin);
console.log(
await signAndSendTransactionInstructions(
connection,
signers,
admin,
instructions
)
);
// Wait for propagation
await sleep(5_000);
[signers, instructions] = await addInstance(
connection,
marketAddress,
admin.publicKey,
admin.publicKey,
3,
50
);
signers.push(admin);
console.log(
await signAndSendTransactionInstructions(
connection,
signers,
admin,
instructions
)
);

Using the Rust CLI