(node:8946) UnhandledPromiseRejectionWarning: Error: failed to get token accounts owned by account 3wyBGP9XptSN24oSFHwn6aiFEXGuN3NvU3FgQ3vMCrm5: Invalid param: could not find mint
Poonamsingh080 opened this issue · 0 comments
import SolanaWeb3 from '@solana/web3.js';
import Serum from '@project-serum/serum';
//import * as fs from "fs";
//import Market from '@project-serum/serum';
//import TOKEN_PROGRAM_ID from '@solana/spl-token';
//const SPL_ASSOCIATED_TOKEN_ACCOUNT = new SolanaWeb3.PublicKey(
//ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
//);
//const solanaId = JSON.parse(fs.readFileSync("/home/poonam/.config/solana/id.json", { encoding: "UTF-8" }))
//console.log(solanaId);
//const fttUsdc = Serum.MARKETS.filter;
//console.log(fttUsdc)
//import * as splToken from '@solana/spl-token';
let connection = new SolanaWeb3.Connection('https://api.devnet.solana.com');
let marketAddress = new SolanaWeb3.PublicKey('8gw8Vwb836BkroF9JJ95bQyg1TDcUAjscDxgMT9RUjc1');
let programId = new SolanaWeb3.PublicKey("4cPMvw9p9SgW6gLr7JBqhtUt9yggVDgAX7o9kDvCVjY9");
(async ()=>{
let market = await Serum.Market.load(connection, marketAddress,{},programId);
console.log(market)
// Placing orders
let owner = new SolanaWeb3.Account([
152, 176, 165, 78, 24, 97, 212, 231, 252, 44, 218,
190, 223, 118, 118, 47, 13, 169, 27, 46, 252, 243,
204, 176, 150, 174, 93, 178, 242, 41, 147, 236, 90,
27, 79, 220, 139, 16, 177, 44, 119, 83, 173, 242,
200, 166, 203, 224, 0, 60, 17, 156, 189, 173, 211,
72, 6, 254, 142, 97, 24, 130, 208, 134
]);
console.log(owner)
let payer = new SolanaWeb3.PublicKey('DHgXCwjLLJEyN45LdxJUWToU6gXZXPuHgkb3B4eMVuj'); // spl-token account ..issue in this line
market.placeOrder(connection, {
owner,
payer,
side: 'buy', // 'buy' or 'sell'
price: 123.45,
size: 17.0,
orderType: 'limit', // 'limit', 'ioc', 'postOnly'
});
})();
// const Market = new Sereum.Market();
// console.log(Market)
// import Serum from '@project-serum/serum';
// console.log(Serum.MARKET)
// import pkg1 from '@project-serum/serum';
// console.log(new pkg1.Market())
// const { Market } = pkg;
// console.log(pkg.Market)
// console.log(market)
//Fetching orderbooks
//let bids = market;
//let asks = market;
//L2 orderbook data
// let getL2 = {};
// console.log(bids)
// 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'
//);
//}
// Retrieving open orders by owner
// console.log(owner.publicKey)
// console.log('owner.publicKey')
// let myOrders = market.loadOrdersForOwner(connection, owner.publicKey);
// Cancelling orders
// for (let order of myOrders) {
// market.cancelOrder(connection, owner, order);
// }
// // Retrieving fills
// for (let fill of market.loadFills(connection)) {
// console.log(fill.orderId, fill.price, fill.size, fill.side);
// }
// Settle funds
// for (let openOrders of market.findOpenOrdersAccountsForOwner(
// connection,
// owner.publicKey,
// )) {
// if (openOrders.baseTokenFree > 0 || openOrders.quoteTokenFree > 0) {
// // spl-token accounts to which to send the proceeds from trades
// let baseTokenAccount = new PublicKey('...');
// let quoteTokenAccount = new PublicKey('...');
// market.settleFunds(
// connection,
// owner,
// openOrders,
// baseTokenAccount,
// quoteTokenAccount,
// );
// }
// }
kindly suggest