Skip to content

fix: use buffered gas estimate and wait for swap tx confirmation#221

Merged
premiumjibles merged 1 commit into
mainfrom
worktree-tic-94af
Mar 22, 2026
Merged

fix: use buffered gas estimate and wait for swap tx confirmation#221
premiumjibles merged 1 commit into
mainfrom
worktree-tic-94af

Conversation

@premiumjibles
Copy link
Copy Markdown
Contributor

@premiumjibles premiumjibles commented Mar 20, 2026

Summary

  • Gas limit fix: When both a provider gas limit and a simulated estimate exist, use the greater of the two. Previously the simulation's 20% buffered estimate was discarded when a provider limit was present, causing on-chain reverts (particularly USDC → ETH on Arbitrum).
  • Swap confirmation: Swap step now waits for on-chain receipt confirmation before showing success toast. Reverted transactions fall into the error path and show an error toast instead of a false success.

Fixes: tic-94af, tic-32f9

Test plan

  • Initiate USDC → ETH swap on Arbitrum, verify tx confirms without revert
  • Verify "Waiting for confirmation..." substatus appears after signing
  • Verify successful swap shows success toast only after on-chain confirmation
  • Verify a reverted swap shows error toast, not success toast
  • bun run type-check && bun test pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved swap transaction execution on EVM chains by ensuring transactions are properly confirmed before advancing to the next step.
  • Chores

    • Enhanced gas fee calculation to intelligently select between provided and estimated gas values for more reliable transactions.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shapeshift-agentic Ready Ready Preview, Comment Mar 22, 2026 11:03pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 20, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2ca65500-b507-448c-a6ab-5d9e40e413b5

📥 Commits

Reviewing files that changed from the base of the PR and between 5e3bc32 and 5636c39.

📒 Files selected for processing (2)
  • apps/agentic-chat/src/components/tools/useSwapExecution.tsx
  • apps/agentic-chat/src/utils/chains/evm/transaction.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

The swap execution flow now includes EVM-only post-transaction confirmation waiting, ensuring swap transactions are confirmed before advancing. Additionally, gas handling logic was updated to select the larger value between explicitly provided gas and simulated estimated gas.

Changes

Cohort / File(s) Summary
Swap Execution Confirmation
apps/agentic-chat/src/components/tools/useSwapExecution.tsx
Added EVM-only post-transaction confirmation wait after swap execution, updating substatus to "Waiting for confirmation..." and awaiting receipt confirmation before advancing to next step.
Gas Handling Logic
apps/agentic-chat/src/utils/chains/evm/transaction.ts
Updated gas parameter selection to use the larger value between explicitly provided gas and simulated estimated gas instead of only falling back to estimated gas when no explicit limit is provided.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A hop, skip, and confirmation's way,
Our swaps now pause to see the light of day,
Gas calculations leap with wisdom's might,
Each transaction waits—a rabbit's delight! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-tic-94af

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

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) <noreply@anthropic.com>
@premiumjibles premiumjibles marked this pull request as ready for review March 22, 2026 23:03
@premiumjibles premiumjibles merged commit 0670971 into main Mar 22, 2026
3 of 4 checks passed
@premiumjibles premiumjibles deleted the worktree-tic-94af branch March 22, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant