Skip to content

feat(chainflip): support TRX and USDT on Tron#12451

Merged
kaladinlight merged 3 commits into
shapeshift:developfrom
CumpsD:feat/chainflip-tron-trx-usdt
Jun 22, 2026
Merged

feat(chainflip): support TRX and USDT on Tron#12451
kaladinlight merged 3 commits into
shapeshift:developfrom
CumpsD:feat/chainflip-tron-trx-usdt

Conversation

@CumpsD

@CumpsD CumpsD commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

Chainflip recently added Tron to its protocol (assets trx.tron and usdt.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:

  • caip: add usdtOnTronAssetId constant (tron:0x2b6653dc/trc20:TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t)
  • ChainflipNetwork: add Tron
  • constants: register TronMainnet in ChainflipSupportedChainIds, ChainflipSupportedAssetIdsByChainId ([tronAssetId, usdtOnTronAssetId]), and chainIdToChainflipNetwork
  • endpoints: add getUnsignedTronTransaction (builds the deposit tx to the Chainflip deposit address — native TRX vs TRC20 resolved via contractAddressOrUndefined) and reuse the shared getTronTransactionFees
  • ChainflipSwapper: wire executeTronTransaction

The generic Tron execution plumbing (Swapper/SwapperApi types, executeTronTransaction, tradeExecution.execTronTransaction, useTradeExecution Tron 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 PRs Require 2 approvals

High risk — introduces a new on-chain transaction path (Tron deposits for Chainflip swaps). Affects: Chainflip swapper, Tron chain adapter (buildSendApiTransaction for native TRX and TRC20 transfers), trade execution.

Testing

Engineering

Verified against the live broker /assets endpoint that asset resolution works without normalization:

  • trx.tron (native) returns no contractAddress → matches the !asset.contractAddress branch in getChainFlipIdFromAssetId.
  • usdt.tron returns contractAddress: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" (base58), matching the caip asset reference (case-insensitive compare).

To test locally:

  1. Trade pair with TRX or USDT-on-Tron as sell asset → quote returns a chainflipDepositAddress.
  2. Sell native TRX → getUnsignedTronTransaction builds a native transfer (no contract); sell USDT-on-Tron → TRC20 transfer to the deposit address.
  3. Sign + broadcast via the Tron adapter through execTronTransaction; status polling tracks the inbound deposit.
  4. Buy-side: e.g. ETH → USDT-on-Tron resolves and egresses to a Tron address.

pnpm run lint clean on all changed files. (Full pnpm type-check not run in this environment due to an unrelated local install issue; the leaf caip package builds clean.)

Operations

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

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

  • New Features
    • Added comprehensive Tron blockchain support to swaps, including full transaction execution capabilities
    • Enabled trading of USDT and other supported assets on the Tron network through Chainflip
    • Improved swap quote validation with enhanced error detection for minimum transaction amount thresholds

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>
@CumpsD CumpsD requested a review from a team as a code owner June 20, 2026 22:54
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5ec7a5c5-f372-4ef0-bfb9-d649b21e28e3

📥 Commits

Reviewing files that changed from the base of the PR and between 1f652af and 5936118.

📒 Files selected for processing (6)
  • packages/caip/src/constants.ts
  • packages/swapper/src/swappers/ChainflipSwapper/ChainflipSwapper.ts
  • packages/swapper/src/swappers/ChainflipSwapper/constants.ts
  • packages/swapper/src/swappers/ChainflipSwapper/endpoints.ts
  • packages/swapper/src/swappers/ChainflipSwapper/types.ts
  • packages/swapper/src/swappers/ChainflipSwapper/utils/getQuoteOrRate.ts

📝 Walkthrough

Walkthrough

Adds Tron as a supported chain in the Chainflip swapper. A new usdtOnTronAssetId CAIP constant is introduced, ChainflipNetwork.Tron is added to the enum, Tron chain/asset entries are registered in Chainflip constants, Tron fee estimation is added to getQuoteOrRate, and getUnsignedTronTransaction plus executeTronTransaction are wired into the API and swapper object. Minimum-amount error detection is also refactored to use structured HTTP 400 field inspection.

Changes

Tron Support in Chainflip Swapper

Layer / File(s) Summary
CAIP constant, ChainflipNetwork enum, and Chainflip chain/asset constants
packages/caip/src/constants.ts, packages/swapper/src/swappers/ChainflipSwapper/types.ts, packages/swapper/src/swappers/ChainflipSwapper/constants.ts
Adds usdtOnTronAssetId CAIP constant and ChainflipNetwork.Tron enum member. Extends ChainflipSupportedChainIds, ChainflipSupportedAssetIdsByChainId, and chainIdToChainflipNetwork with Tron entries.
Tron fee data and error detection in getQuoteOrRate
packages/swapper/src/swappers/ChainflipSwapper/utils/getQuoteOrRate.ts
Adds CHAIN_NAMESPACE.Tron to getFeeData (self-send fee estimation via Tron adapter) and getMaxBoostFee (returns 0). Replaces string-matching minimum-amount error detection with a structured HTTP 400 and errors.minimalAmountNative[0] check.
Unsigned Tron transaction building and swapper wiring
packages/swapper/src/swappers/ChainflipSwapper/endpoints.ts, packages/swapper/src/swappers/ChainflipSwapper/ChainflipSwapper.ts
Adds getUnsignedTronTransaction and getTronTransactionFees to chainflipApi. Exposes executeTronTransaction in the chainflipSwapper exported object.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hop, hop, hooray — Tron joins the swap!
A CAIP constant lands with a little plop.
Fee data flows through the adapter fast,
Deposit address locked in, the tx is cast.
Minimum amounts checked the structured way,
This rabbit ships Tron swaps today! 🎉

🚥 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(chainflip): support TRX and USDT on Tron' clearly and concisely summarizes the main feature added: enabling TRX and USDT support on Tron for the Chainflip swapper.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

kaladinlight and others added 2 commits June 22, 2026 12:58
- 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>
@kaladinlight kaladinlight merged commit 6c49515 into shapeshift:develop Jun 22, 2026
4 checks passed
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.

2 participants