Код: Выделить всё
`const params = {
inputMint: "So11111111111111111111111111111111111111112",
outputMint: "9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump",
amount: 10000000,
slippageBps: 20,
onlyDirectRoutes: true,
autoSlippage: true
};
const quote = await jupiterTrader.getQuoteBase(params);`
`async getSwapTransaction(quoteResponse) {
return await promiseRetry(async (retry) => {
try {
const response = await fetch('https://quote-api.jup.ag/v6/swap', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
quoteResponse,
userPublicKey: this.wallet.publicKey.toString(),
wrapAndUnwrapSol: true,
dynamicComputeUnitLimit: true,
prioritizationFeeLamports: 'auto'
})
});
if (!response.ok) {
throw new Error(`API请求失败: ${response.status}`);
}
return response.json();
} catch (error) {
return retry(error);
}
}, this.RETRY_OPTIONS);
}`
Подробнее здесь: https://stackoverflow.com/questions/793 ... ap-transac