Open 0xtristan opened 3 years ago
Other newcomers also running into this issue. I can raise a PR to update it if you'd like? https://discord.com/channels/739225212658122886/752530209848295555/823214372452564993
To get this example working, where do I find a programAddress
and a marketAddress
pls?
To get this example working, where do I find a
programAddress
and amarketAddress
pls?
Hello @armaniferrante @npomfret @0xtristan I had clone the code, executed npm run build & npm start command successfully. but i don't understand how i will execute place order & other function. when i execute usage code in separate node js program i am getting bad secret key error. kindly help me in this.
Thanks in Advance
@armaniferrante is it possible to test serum examples on devnet?
Market addresses: https://github.com/project-serum/serum-ts/blob/master/packages/serum/src/markets.json (an incomplete list)
The above list seems to be for the mainnet? Would they also work for the devnet?
Guys this is a really poor documentation. You guys @armaniferrante need to seriously explain the params used in the example. I was using the same example
import { Account, Connection, PublicKey } from '@solana/web3.js';
import { Market } from '@project-serum/serum';
let connection = new Connection('https://testnet.solana.com');
// token address: for MSOL/USDC
let marketAddress = new PublicKey('6oGsL2puUgySccKzn9XA9afqF217LfxP5ocq4B3LWsjy');
// program address/PID (IDK) 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
let programAddress = new PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin");
let market = await Market.load(connection, marketAddress, {}, programAddress);
let mainAcc = '6QneB2NPPhBwZWuKxBWnvUCwBY1vFgYrz746PwrHqKWk';
// Fetching orderbooks
let bids = await market.loadBids(connection);
let asks = await market.loadAsks(connection);
// L2 orderbook data
for (let [price, size] of bids.getL2(20)) {
console.log(price, size);
}
// Full orderbook data
for (let order of asks) {
console.log(
order.orderId,
order.price,
order.size,
order.side, // 'buy' or 'sell'
);
}
Just to fetch the MSOL/USDC
price and orderbook but instead get
/Users/pedro/Desktop/Home/gi/node_modules/@solana/web3.js/lib/index.cjs.js:5459
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
^
Error: failed to get info about account 6oGsL2puUgySccKzn9XA9afqF217LfxP5ocq4B3LWsjy: FetchError: request to https://testnet.solana.com/ failed, reason: connect ETIMEDOUT 139.178.68.207:443
at Connection.getAccountInfo (/Users/pedro/Desktop/Home/gi/node_modules/@solana/web3.js/lib/index.cjs.js:5459:13)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Function.load (/Users/pedro/Desktop/Home/gi/node_modules/@project-serum/serum/lib/market.js:133:45)
at async file:///Users/pedro/Desktop/Home/gi/serum-interactions/src/getOrderbook.js:9:14
Any help guys @0xtristan @npomfret ?
I'm pretty sure there is an easy way to lookup these ids. I will have a play and report back if I find it
@npomfret any hints ?
Was just wondering if the JS example for interfacing with a Serum market needs updating. I've tried running it and run into the same error that the
Market.load()
expects aprogramId
, otherwise it tries to do equality operations on an undefined argument. I imagine perhaps the API has changed in the meantime? https://github.com/project-serum/serum-ts/blob/master/packages/serum/README.mdWhich throws the following error as described above:
Managed to get around it simply by passing in the programId of the Serum v3 program: