Rango: Add Tron swap support - #484
Open
j0ntz wants to merge 1 commit into
Open
Conversation
2 tasks
Contributor
Author
j0ntz
force-pushed
the
jon/rango-tron-contract-call
branch
from
August 14, 2026 17:24
49ca31d to
dc41dc5
Compare
j0ntz
marked this pull request as ready for review
August 14, 2026 17:24
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
A TRON quote fell through to the EVM transaction handler and threw, even though the chain was already mapped. Build the spend from the TriggerSmartContract call Rango returns, passing it to the currency plugin intact, and turn the router allowance Rango returns alongside a TRC20 sell into a pre-transaction.
j0ntz
force-pushed
the
jon/rango-tron-contract-call
branch
from
August 14, 2026 17:38
dc41dc5 to
bcccdb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
Needs
edge-currency-accountbasedTron contract-call support to execute (PR linked in the description).Description
Asana: https://app.asana.com/0/1215088146871429/1216839790397157
tron -> TRONhas been in the Rango mapping all along, so TRON quotes were already beingrequested. Building the transaction was the missing half:
tx.type === 'TRON'fell into thedefault:branch, which runsasEvmTransaction(tx)and throws.What changed
asTronTransactionreads Rango'sraw_data(andapprove_raw_data) as aTriggerSmartContractpayload. Every level uses.withRest, so nothing the provider sent isdropped before it reaches the currency plugin —
parameter.type_urlis serialized into thesigned raw data, so losing it would change the transaction.
TRONcase builds aspendInfocarrying{ contractJson, feeLimit }inotherParamsand targeting the router address. A TRC20 sell also needs an allowance, which Rango returns
inline as
approve_raw_data; that becomes atokenApprovalpre-transaction, the same shapethe EVM path already uses.
hexToTronAddressconverts the hex addresses in a contract payload to the base58check formwallets and spend targets speak.
Testing
Unit tests cover the address conversion against the USDT contract, the Sun Swap router, and an
owner address.
Driven against the live Rango API with stub wallets: a native TRX sell produces one swap
spendInfowithcall_valueset and no approval; a USDT sell produces the095ea7b3approvalpre-transaction followed by the swap.
Then end to end on the iOS sim with edge-currency-accountbased#1088
linked in: a TRX → USDT swap through Rango reached the success scene, and on-chain
42fd4970…9650
is a
TriggerSmartContractwithcontractRet: SUCCESS, selectorcef95229against the Sun Swaprouter, delivering 13.004043 USDT in the same transaction. Screenshots in a comment below.
Note
Medium Risk
Adds a new on-chain swap execution path with TRC20 approvals; validation mitigates wrong-spender approvals, but execution still depends on companion Tron contract-call support in the currency plugin.
Overview
Rango TRON swaps no longer hit the EVM
defaultbranch and fail parsing. Responses withtx.type === 'TRON'are validated and turned into wallet spends that pass Rango’sTriggerSmartContractpayload through to the Tron currency plugin viaotherParams.contractJsonandfeeLimit.For TRC20 sells, when Rango includes
approve_raw_data, the plugin queues atokenApprovalpre-transaction (same pattern as EVM). It decodes the approval spender from call data and rejects approvals that don’t target the swap router or the token being sold.Address helpers
hexToTronAddressanddecodeTronApprovalSpenderconvert hex contract addresses to base58 and parseapprove()calldata; unit tests cover known contracts and error cases.Reviewed by Cursor Bugbot for commit bcccdb3. Bugbot is set up for automated code reviews on this repo. Configure here.