Conversation
This commit adds proper support for Tron contract calls in ButterSwap integration but temporarily disables Tron due to persistent contract revert issues with Butter Network's Tron contracts. Changes: - Add buildCustomApiTx() to TronChainAdapter supporting arbitrary contract calls with both raw calldata and method/args formats - Fix ButterSwap to use buildCustomApiTx for Tron swaps with proper value handling (only send value for native TRX swaps) - Add method/args fields to butterSwapTransactionMetadata type - Fix allowanceContract to use buildTx.to for Tron (Butter doesn't return route.contract for Tron chains) - Add referrer parameter for same-chain Tron swaps (similar to Solana) - Temporarily disable Tron support until Butter's contract revert issue can be resolved The transaction building logic is correct and should work once Butter Network fixes their Tron contract issues. Multiple test attempts resulted in contract reverts despite correct calldata, approvals, and transaction structure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis change introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant Swapper as ButterSwap Swapper
participant Quote as getTradeQuote
participant TxBuilder as getUnsignedTronTransaction
participant Adapter as TronChainAdapter
participant API as TronGrid API
Swapper->>Quote: Request trade quote (Tron)
Quote->>Quote: Adjust allowanceContract for Tron
Quote->>Quote: Attach method/args to metadata
Quote-->>Swapper: Return quote with metadata
Swapper->>TxBuilder: Build unsigned transaction
TxBuilder->>TxBuilder: Detect butterSwapTransactionMetadata
TxBuilder->>Adapter: Call buildCustomApiTx(from, to, data, value, method, args)
Adapter->>API: Send triggersmartcontract request
API-->>Adapter: Return transaction with raw_data_hex
Adapter->>Adapter: Extract and normalize raw_data_hex
Adapter-->>TxBuilder: Return TronSignTx
TxBuilder-->>Swapper: Return unsigned transaction
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
gomesalexandre
left a comment
There was a problem hiding this comment.
Confirmed happy on both sides
https://jam.dev/c/1a8b3de5-86ed-4db3-93c8-eb3ece98e80f
Also oh boi dem rates and fees 💀
Description
We were not supporting smart contract calls when swapping for TRON, this was the main reason why it was failing
Another thing: every swaps are applying a 20 TRX fees, quite expensive, so don't forget to have as much TRX in your pockets
Issue (if applicable)
Spotted in release thread
Risk
Quite high
Testing
Engineering
Operations
Screenshots (if applicable)
https://jam.dev/c/fcee306c-8ecf-49e5-af98-f1ae3d264d02
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.