feat(chainflip): support TRX and USDT on Tron#12451
Conversation
Chainflip added Tron to its protocol (assets trx.tron and usdt.tron). Wire Tron as a supported Chainflip chain and add native TRX and USDT (TRC20) as tradeable assets, both as sell and buy sides. - caip: add usdtOnTronAssetId constant - ChainflipNetwork: add Tron - constants: register TronMainnet in supported chains, assets, and chainId -> ChainflipNetwork map - endpoints: add getUnsignedTronTransaction (deposit tx to the Chainflip deposit address; native TRX vs TRC20 via contractAddressOrUndefined) and reuse the shared getTronTransactionFees - ChainflipSwapper: wire executeTronTransaction Verified against the live broker /assets endpoint: usdt.tron returns its contractAddress in base58 (TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t), matching the caip asset reference, so getChainFlipIdFromAssetId resolves both assets without normalization. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds Tron as a supported chain in the Chainflip swapper. A new ChangesTron Support in Chainflip Swapper
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
- handle the Tron chainNamespace in getQuoteOrRate's fee/boost switches so TRX and USDT-on-Tron sell rates render instead of throwing 'Unsupported chainNamespace' and being dropped from the quote list - detect Chainflip below-minimum 400s via errors.minimalAmountNative instead of brittle detail-string matching, so the UI shows the minimum amount rather than a generic "no routes found" message Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Description
Chainflip recently added Tron to its protocol (assets
trx.tronandusdt.tron). This PR wires Tron as a supported Chainflip swapper chain and adds native TRX and USDT (TRC20) as tradeable assets — both sell and buy sides.Changes:
usdtOnTronAssetIdconstant (tron:0x2b6653dc/trc20:TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t)TronTronMainnetinChainflipSupportedChainIds,ChainflipSupportedAssetIdsByChainId([tronAssetId, usdtOnTronAssetId]), andchainIdToChainflipNetworkgetUnsignedTronTransaction(builds the deposit tx to the Chainflip deposit address — native TRX vs TRC20 resolved viacontractAddressOrUndefined) and reuse the sharedgetTronTransactionFeesexecuteTronTransactionThe generic Tron execution plumbing (Swapper/SwapperApi types,
executeTronTransaction,tradeExecution.execTronTransaction,useTradeExecutionTron dispatch) already existed, so this is mostly config wiring + a Chainflip-local deposit-tx builder. Both assets already exist in generated asset data, so they render with name/icon.Issue (if applicable)
closes #
Risk
High risk — introduces a new on-chain transaction path (Tron deposits for Chainflip swaps). Affects: Chainflip swapper, Tron chain adapter (
buildSendApiTransactionfor native TRX and TRC20 transfers), trade execution.Testing
Engineering
Verified against the live broker
/assetsendpoint that asset resolution works without normalization:trx.tron(native) returns nocontractAddress→ matches the!asset.contractAddressbranch ingetChainFlipIdFromAssetId.usdt.tronreturnscontractAddress: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"(base58), matching the caip asset reference (case-insensitive compare).To test locally:
chainflipDepositAddress.getUnsignedTronTransactionbuilds a native transfer (no contract); sell USDT-on-Tron → TRC20 transfer to the deposit address.execTronTransaction; status polling tracks the inbound deposit.pnpm run lintclean on all changed files. (Fullpnpm type-checknot run in this environment due to an unrelated local install issue; the leafcaippackage builds clean.)Operations
User-facing: TRX and USDT-on-Tron become tradeable via Chainflip. QA in a preview env: select Chainflip route, confirm TRX/USDT-on-Tron appear as sell + buy assets, run a small swap each direction.
Summary by CodeRabbit