Skip to content

Conversation

@NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Jan 22, 2026

Description

This task activates TRON blockchain support for the existing Butter swapper integration, enabling users to swap tokens to and from the TRON chain using the ButterSwap protocol. Butter is already integrated as a swapper in the ShapeShift platform supporting EVM chains, Bitcoin, and Solana. This implementation extends that support to include TRON by adding the necessary chain ID mappings, native token address handling, chain validation updates, and TRON-specific transaction building/fee methods.

Issue (if applicable)

closes #11214

Risk

Low

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • Swap from any chains to TRX using Butter
  • Try to swap TRX to a TRC20
  • Cross TRC20 swaps
  • TRC20 to TRX
  • Verify balance is updated
  • Verify all statuses are updated in the action center

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/476682f3-bffa-4af2-8549-8474fd511422

Summary by CodeRabbit

  • New Features
    • Added Tron blockchain support to ButterSwap swapper, enabling trading on the Tron network including transaction execution, fee calculation, quote generation, rate calculation, status tracking, and route resolution.

✏️ Tip: You can customize this high-level summary in your review settings.

Minimoi and others added 6 commits January 21, 2026 17:05
…nChainId)

Add TRON chain ID mapping to ButterSwap helpers.ts for the Butter API.
This maps the Butter API chain ID 728126428 to KnownChainIds.TronMainnet.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… handling

- Import tronChainId from @shapeshiftoss/caip
- Add TRON_NATIVE_ADDRESS constant (T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb)
- Handle TRON native token in sellAssetAddress resolution
- Handle TRON native token in buyAssetAddress resolution

This follows the same pattern as the existing Solana native address handling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…TradeQuote

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ndle butterSwapTransactionMetadata

Add butterSwapTransactionMetadata to the destructuring from the trade step and
include butterSwapTransactionMetadata.to in the fallback chain for determining
the transaction destination address. This enables the existing tron-utils to
work with ButterSwap quotes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…TronTransaction to ButterSwap endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

This pull request adds Tron blockchain support to ButterSwap swapper. Changes include importing and exporting Tron transaction utilities, extending chain validation logic to include Tron, adding Tron chain ID mappings, implementing Tron transaction status checking with contractRet-based logic, and extending destination address resolution for Tron transactions.

Changes

Cohort / File(s) Summary
ButterSwap API Exports
packages/swapper/src/swappers/ButterSwap/ButterSwap.ts, packages/swapper/src/swappers/ButterSwap/endpoints.ts
Exposes Tron transaction execution and fee/quote helpers (executeTronTransaction, getTronTransactionFees, getUnsignedTronTransaction) in public API alongside existing EVM and Solana handlers.
Chain Validation & Routing
packages/swapper/src/swappers/ButterSwap/swapperApi/getTradeQuote.ts, packages/swapper/src/swappers/ButterSwap/swapperApi/getTradeRate.ts, packages/swapper/src/swappers/ButterSwap/xhr.ts
Extends unsupported chain checks and routing logic to explicitly permit and handle Tron (tronChainId) chain assets. Adds TRON native address constant for proper route resolution.
Trade Status Handling
packages/swapper/src/swappers/ButterSwap/swapperApi/checkTradeStatus.ts
Adds Tron-specific transaction status determination using adapter.httpProvider.getTransaction() and evaluates contractRet field (SUCCESS/REVERT with confirmation count) for status resolution.
Chain ID Mappings
packages/swapper/src/swappers/ButterSwap/utils/helpers.ts
Maps ButterSwap chain identifier 728126428 to KnownChainIds.TronMainnet in BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID mapping.
Transaction Utilities
packages/swapper/src/tron-utils/getUnsignedTronTransaction.ts
Extends destination address (to) fallback chain to include butterSwapTransactionMetadata?.to alongside existing relayTransactionMetadata and nearIntentsSpecific sources.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • gomesalexandre
  • 0xApotheosis

Poem

🐇 A whisper in the swap so fine,
Tron joins the ButterSwap design,
With chains now mapped and routes so bright,
Transaction fees take gentle flight! 🦋✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: enable butter for TRON' clearly and concisely describes the main change: adding TRON blockchain support to the Butter swapper, which aligns with all the code changes in the changeset.
Linked Issues check ✅ Passed The pull request successfully addresses issue #11214 by implementing ButterSwap support for TRON, including chain ID mappings, native token handling, chain validation, and transaction fee utilities.
Out of Scope Changes check ✅ Passed All changes are directly related to adding TRON support to ButterSwap: chain mappings, native address handling, chain validation updates, and transaction/fee utilities. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch auto-claude/009-we-are-supporting-butter-as-a-swapper-but-we-didn-

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.

@NeOMakinG NeOMakinG marked this pull request as ready for review January 22, 2026 17:36
@NeOMakinG NeOMakinG requested a review from a team as a code owner January 22, 2026 17:36
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/swapper/src/swappers/ButterSwap/swapperApi/checkTradeStatus.ts`:
- Around line 63-71: The current logic in checkTradeStatus (variables:
contractRet, tx.confirmations, TxStatus) leaves many confirmed TRON transactions
with non‑'SUCCESS' contractRet as Pending; change the branching so that if
tx.confirmations > 0 then any contractRet !== 'SUCCESS' is set to
TxStatus.Failed (only 'SUCCESS' => TxStatus.Confirmed), and keep the existing
behavior for unconfirmed TXs where contractRet === 'REVERT' maps to
TxStatus.Failed otherwise TxStatus.Pending; update the ternary/if logic
accordingly to use these checks.

@premiumjibles premiumjibles self-requested a review January 23, 2026 22:09
Copy link
Collaborator

@premiumjibles premiumjibles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and was able to get quotes across a variety of pairs I tired. Tested ETH on arb -> TRX https://jam.dev/c/64a0536a-e48b-49a4-bed9-1dfd12b5ea7f

Was unable to test TRX -> TRC tokens due to limited funds without doing a million dust transactions. Will leave that to release testing

@premiumjibles premiumjibles enabled auto-merge (squash) January 23, 2026 23:12
@premiumjibles premiumjibles merged commit 457ae86 into develop Jan 25, 2026
4 checks passed
@premiumjibles premiumjibles deleted the auto-claude/009-we-are-supporting-butter-as-a-swapper-but-we-didn- branch January 25, 2026 11:53
@coderabbitai coderabbitai bot mentioned this pull request Jan 27, 2026
1 task
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.

Implement butter for TRON

3 participants