From 5636c39a30556f11e390ef962ccfc5a3109d4080 Mon Sep 17 00:00:00 2001 From: Jibles Date: Fri, 20 Mar 2026 03:49:25 +0000 Subject: [PATCH] fix: use buffered gas estimate and wait for swap tx confirmation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Swap transactions (particularly USDC → ETH on Arbitrum) reverted on-chain because the provider gas limit was used as-is, ignoring the simulation's 20% buffered estimate. Now uses the greater of the two values. Additionally, swap steps now wait for on-chain confirmation before showing a success toast, so reverted transactions correctly surface as errors. Fixes: tic-94af, tic-32f9 Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/agentic-chat/src/components/tools/useSwapExecution.tsx | 6 ++++++ apps/agentic-chat/src/utils/chains/evm/transaction.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/agentic-chat/src/components/tools/useSwapExecution.tsx b/apps/agentic-chat/src/components/tools/useSwapExecution.tsx index 446a883d..448eb605 100644 --- a/apps/agentic-chat/src/components/tools/useSwapExecution.tsx +++ b/apps/agentic-chat/src/components/tools/useSwapExecution.tsx @@ -104,6 +104,12 @@ export const useSwapExecution = ( ctx.setSubstatus('Requesting signature...') const swapTxHash = await executeSwap(swapTx, { solanaSigner }) ctx.setMeta({ txHash: swapTxHash }) + + if (chainNamespace === CHAIN_NAMESPACE.Evm) { + ctx.setSubstatus('Waiting for confirmation...') + await waitForConfirmedReceipt(Number(chainReference), swapTxHash as `0x${string}`) + } + ctx.advanceStep() ctx.markTerminal() ctx.persist() diff --git a/apps/agentic-chat/src/utils/chains/evm/transaction.ts b/apps/agentic-chat/src/utils/chains/evm/transaction.ts index fb86ddee..6fb7adc7 100644 --- a/apps/agentic-chat/src/utils/chains/evm/transaction.ts +++ b/apps/agentic-chat/src/utils/chains/evm/transaction.ts @@ -50,7 +50,7 @@ export async function sendEvmTransaction(params: TransactionParams): Promise estimatedGas ? gas : estimatedGas } catch (error) { if (error instanceof SimulationError) throw error console.warn('[simulation] EVM simulation failed, proceeding without:', error)