I am unable to create a new market on openbook-dex. I am trying to get the createMarket.ts script from their example repo (https://github.com/openbook-dex/scripts-v2/) to function. It is not clear from the example what values should be set for all parameters, as there are a number of commented out lines. Code below as I am executing it, with the commented lines removed and loading a helper script where I load the rpc. I have been using the solana devnet for my tests. I have minted a new token for this test, and using that address for the baseMint, and the authority loaded via the keyphrase json is the mint authority for that token.
import {
Keypair,
PublicKey,
ComputeBudgetProgram,
SystemProgram,
Transaction,
Connection,
} from "@solana/web3.js";
import {
AnchorProvider,
BN,
Program,
Wallet,
getProvider,
} from "@coral-xyz/anchor";
import { createAccount } from "./solana_utils";
import { MintUtils } from "./mint_utils";
import { OpenBookV2Client } from "@openbook-dex/openbook-v2";
import { RPC, authority, connection, programId } from "./utils";
import { HTTP_URL, WSS_URL } from "./constants";
function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function main() {
const wallet = new Wallet(authority);
const provider = new AnchorProvider(new Connection(HTTP_URL, {wsEndpoint: WSS_URL}), wallet, {
commitment: "confirmed",
});
const client = new OpenBookV2Client(provider, programId);
console.log(
"starting with balance: ",
await provider.connection.getBalance(authority.publicKey)
);
const baseMint = new PublicKey("EoSHYd5zpfZDkC33gssK98sy8Q3QGXKkVaAwsEAqBTZi"); //Base Mint: Your token mint address.
//SOL
const quoteMint = new PublicKey("So11111111111111111111111111111111111111112"); //Quote Mint: The token you wish to pair with your token.
const oracleAId = null;
const oracleBId = null;
const name = "VVCT-SOL";
const [ixs, signers] = await client.createMarketIx(
authority.publicKey, // payer
name, // name
quoteMint, // quoteMint
baseMint, // baseMint
new BN(1), // quoteLotSize
new BN(1000000), // baseLotSize
new BN(0), // makerfee
new BN(0), // takerfee
new BN(0), // timeExpiry
oracleAId, // oracleA
oracleBId, // oracleB
null, // openOrdersAdmin
null, // consumeEventsAdmin
null, // closeMarketAdmin
);
const tx = await client.sendAndConfirmTransaction(ixs, {
additionalSigners: signers,
});
console.log("created market", tx);
console.log(
"finished with balance: ",
await connection.getBalance(authority.publicKey)
);
}
main();
and the contents of my helper script:
const NETWORK = "DEVNET"; //DEVNET or MAINNET
export var HTTP_URL = '';
export var WSS_URL = '';
if (NETWORK == "DEVNET") {
HTTP_URL = "https://api.devnet.solana.com";
WSS_URL = "wss://api.devnet.solana.com";
} else if (NETWORK == "MAINNET") {
HTTP_URL = "https://api.mainnet-beta.solana.com";
WSS_URL = "wss://api.mainnet-beta.solana.com";
}
when run, this returns:
(node:4183492) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
starting with balance: 980597400
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
code: 'ERR_UNHANDLED_REJECTION'
}
the rejection is happening in the sendAndConfirmTransaction call, but the error isn't helpful in determining why.
I found a successful transaction to the same program on devnet here: https://explorer.solana.com/tx/3JkmfJE6tKoodGhRkQaq4dP4LXSw3Je8rQCw6X7YW4qB6HT4mAqxk1HPGpLGhgQ6ce1w3WwPmR3wUNcq1FeD6zpz?cluster=devnet but it is not clear to me why mine fails. Based on the successful transaction, I have also tried setting oracleAId and oracleBId to new PublicKey("opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb"), which is the openbook v2 programId, but I get the same error.