diff --git a/examples/with-solana/src/jupiterSwap.ts b/examples/with-solana/src/jupiterSwap.ts index 1e3c2f02f..442ca5fb8 100644 --- a/examples/with-solana/src/jupiterSwap.ts +++ b/examples/with-solana/src/jupiterSwap.ts @@ -46,13 +46,13 @@ const createSwap = async () => { console.log(`\nUsing existing Solana address from ENV: "${solAddress}"`); } - // Swapping SOL to USDC with input 0.05 SOL and 1% slippage + // Swapping SOL to USDC with input 0.01 SOL and 1% slippage // See example here: https://station.jup.ag/docs/apis/swap-api const quoteResponse = await ( await fetch( "https://quote-api.jup.ag/v6/quote?inputMint=So11111111111111111111111111111111111111112\ &outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\ -&amount=50000000\ +&amount=10000000\ &slippageBps=100" ) ).json(); @@ -73,6 +73,9 @@ const createSwap = async () => { wrapAndUnwrapSol: true, // feeAccount is optional. Use if you want to charge a fee. feeBps must have been passed in /quote API. // feeAccount: "fee_account_public_key" + dynamicComputeUnitLimit: true, // allow dynamic compute limit instead of max 1,400,000 + // custom priority fee + prioritizationFeeLamports: "auto", // or custom lamports: 1000 }), }) ).json(); diff --git a/examples/with-solana/src/utils/retrySender.ts b/examples/with-solana/src/utils/retrySender.ts index fbd83f001..79e6933d1 100644 --- a/examples/with-solana/src/utils/retrySender.ts +++ b/examples/with-solana/src/utils/retrySender.ts @@ -19,6 +19,7 @@ type TransactionSenderAndConfirmationWaiterArgs = { const SEND_OPTIONS = { skipPreflight: true, + maxRetries: 3, }; export async function transactionSenderAndConfirmationWaiter({ @@ -38,7 +39,7 @@ export async function transactionSenderAndConfirmationWaiter({ const abortableResender = async () => { while (true) { - await wait(2_000); + await wait(1_000); if (abortSignal.aborted) return; try { await connection.sendRawTransaction( @@ -70,7 +71,7 @@ export async function transactionSenderAndConfirmationWaiter({ new Promise(async (resolve) => { // in case ws socket died while (!abortSignal.aborted) { - await wait(2_000); + await wait(1_000); const tx = await connection.getSignatureStatus(txid, { searchTransactionHistory: false, }); @@ -83,6 +84,7 @@ export async function transactionSenderAndConfirmationWaiter({ } catch (e) { if (e instanceof TransactionExpiredBlockheightExceededError) { // we consume this error and getTransaction would return null + console.warn(`failed to confirm transaction: ${e}`); return; } else { // invalid state from web3.js