Hello, Actually i am trying to swap through but getting this error in response
> (node:48584) UnhandledPromiseRejectionWarning: Error: Unable to find nonce
> at Object.getVaultOwnerAndNonce (/Users/talhazulifqar1/Documents/trading-bot-project/jpool-trading-bot-backend/node_modules/@project-serum/swap/lib/utils.js:32:11)
> at Swap.swapDirectTxs (/Users/talhazulifqar1/Documents/trading-bot-project/jpool-trading-bot-backend/node_modules/@project-serum/swap/lib/index.js:212:45)
> at Swap.swapTxs (/Users/talhazulifqar1/Documents/trading-bot-project/jpool-trading-bot-backend/node_modules/@project-serum/swap/lib/index.js:156:31)
> at Swap.swap (/Users/talhazulifqar1/Documents/trading-bot-project/jpool-trading-bot-backend/node_modules/@project-serum/swap/lib/index.js:106:30)
> at swapHappen (/Users/talhazulifqar1/Documents/trading-bot-project/jpool-trading-bot-backend/app.js:179:31)
> at Object. (/Users/talhazulifqar1/Documents/trading-bot-project/jpool-trading-bot-backend/app.js:196:1)
> at Module._compile (internal/modules/cjs/loader.js:1072:14)
> at Object.Module._extensions…js (internal/modules/cjs/loader.js:1101:10)
> at Module.load (internal/modules/cjs/loader.js:937:32)
> at Function.Module._load (internal/modules/cjs/loader.js:778:12)
> (Use node --trace-warnings ...
to show where the warning was created)
> (node:48584) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see Command-line API | Node.js v17.8.0 Documentation). (rejection id: 2)
> (node:48584) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Here is my Code that i am trying to execute
const swapHappen = async () => {
var from = web3.Keypair.generate();
const wallet = new web3.PublicKey(
'8aVeZkZ2b92QdFXhKZtGf3273J7L8hHgRnQmphDKV6v2'
);
const tokenList = ['9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT']; // market address
const connection = new Connection(
'https://api.mainnet-beta.solana.com',
'recent'
);
const provider = { connection, wallet: from };
const client = new Swap(provider, tokenList);
// console.log('client :', client);
const fromPubKeyMint = new web3.PublicKey(
'So11111111111111111111111111111111111111112'
);
const toPubKeyMint = new web3.PublicKey(
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
);
const result = await client.swap({
fromMint: fromPubKeyMint,
toMint: toPubKeyMint,
fromMarket: new web3.PublicKey(
'9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT'
),
amount: new Decimal(1.0),
minExchangeRate: new Decimal(0.1),
});
console.log('result :', result);
};
//
swapHappen();