From c9e0ac85d4c3e78428d650c2dc73f32aee02c3a7 Mon Sep 17 00:00:00 2001 From: David Cumps Date: Thu, 9 Jul 2026 15:55:28 +0200 Subject: [PATCH] feat(exchange): add TRX and USDT-on-Tron to Chainflip (#3341) Chainflip added Tron support with asset ids trx.tron and usdt.tron. Enable both for swaps in the Chainflip provider. Tron needs explicit handling because Chainflip's network slug is 'tron', while Cake uses the 'TRX' tag (and null for native TRX), so the generic title.tag normalization can't produce the right ids: - _supported: add trx, usdttrc20 - _normalizeCurrency: map trx -> trx.tron, usdttrc20 -> usdt.tron - _normalizeNetworkName: TRON -> Tron (status lookup in findTradeById) - _toCurrency: reverse-map trx.tron/usdt.tron for trade resolution Co-authored-by: Claude Opus 4.8 (1M context) --- lib/exchange/provider/chainflip_exchange_provider.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/exchange/provider/chainflip_exchange_provider.dart b/lib/exchange/provider/chainflip_exchange_provider.dart index e82fa6d4a..99b2830cd 100644 --- a/lib/exchange/provider/chainflip_exchange_provider.dart +++ b/lib/exchange/provider/chainflip_exchange_provider.dart @@ -29,6 +29,8 @@ class ChainflipExchangeProvider extends ExchangeProvider { CryptoCurrency.arbEth, CryptoCurrency.usdcArb, CryptoCurrency.usdtArb, + CryptoCurrency.trx, + CryptoCurrency.usdttrc20, ]; static const _baseURL = 'chainflip-broker.io'; @@ -315,6 +317,11 @@ class ChainflipExchangeProvider extends ExchangeProvider { } String _normalizeCurrency(CryptoCurrency currency) { + // Chainflip uses 'tron' as the network slug, but Cake uses tag 'TRX' (and null + // for native TRX), so these can't go through the generic title.tag logic below. + if (currency == CryptoCurrency.trx) return 'trx.tron'; + if (currency == CryptoCurrency.usdttrc20) return 'usdt.tron'; + final tag = currency.tag?.toLowerCase(); final title = currency.title.toLowerCase(); @@ -330,6 +337,7 @@ class ChainflipExchangeProvider extends ExchangeProvider { 'ETHEREUM' => 'Ethereum', 'ARBITRUM' => 'Arbitrum', 'SOLANA' => 'Solana', + 'TRON' => 'Tron', _ => name }; @@ -350,6 +358,8 @@ class ChainflipExchangeProvider extends ExchangeProvider { 'eth.arb' => CryptoCurrency.arbEth, 'usdc.arb' => CryptoCurrency.usdcArb, 'usdt.arb' => CryptoCurrency.usdtArb, + 'trx.tron' => CryptoCurrency.trx, + 'usdt.tron' => CryptoCurrency.usdttrc20, _ => null };