From 2309f408d2a492f0d9cd55068dbfaf5b72846a12 Mon Sep 17 00:00:00 2001 From: David Adegoke <64401859+Blazebrain@users.noreply.github.com> Date: Tue, 10 Feb 2026 14:44:37 +0100 Subject: [PATCH] Refactor jupiter supported currency checks for swaps (#2886) --- .../provider/jupiter_exchange_provider.dart | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/exchange/provider/jupiter_exchange_provider.dart b/lib/exchange/provider/jupiter_exchange_provider.dart index 2bd5708e5..379bd4243 100644 --- a/lib/exchange/provider/jupiter_exchange_provider.dart +++ b/lib/exchange/provider/jupiter_exchange_provider.dart @@ -18,13 +18,9 @@ import 'package:cw_core/utils/proxy_wrapper.dart'; class JupiterExchangeProvider extends ExchangeProvider { JupiterExchangeProvider(); - // Jupiter only supports Solana tokens - static const List _notSupported = []; - - static final List _supportedCurrencies = CryptoCurrency.all - .where((c) => c.tag == 'SOL' || c == CryptoCurrency.sol) - .where((c) => !_notSupported.contains(c)) - .toList(); + // Jupiter only supports Solana native SOL and Solana tokens + bool _isSolanaCurrency(CryptoCurrency currency) => + currency == CryptoCurrency.sol || currency.tag == 'SOL'; static const _baseUrl = 'api.jup.ag'; static const _orderPath = '/ultra/v1/order'; @@ -88,7 +84,7 @@ class JupiterExchangeProvider extends ExchangeProvider { // - errorCode 3: Minimum amount for gasless // only return null for supported currencies - if (_supportedCurrencies.contains(from) && _supportedCurrencies.contains(to)) { + if (_isSolanaCurrency(from) && _isSolanaCurrency(to)) { return Limits(min: null, max: null); } else { throw Exception('not supported'); @@ -136,7 +132,7 @@ class JupiterExchangeProvider extends ExchangeProvider { }) async { try { // must support both - if (!_supportedCurrencies.contains(from) || !_supportedCurrencies.contains(to)) { + if (!_isSolanaCurrency(from) || !_isSolanaCurrency(to)) { return 0.0; } final inputMint = _getTokenMint(from); @@ -227,9 +223,9 @@ class JupiterExchangeProvider extends ExchangeProvider { }) async { try { // must support both - if (!_supportedCurrencies.contains(request.fromCurrency) || - !_supportedCurrencies.contains(request.toCurrency)) { - throw "not supported currencies"; + if (!_isSolanaCurrency(request.fromCurrency) || + !_isSolanaCurrency(request.toCurrency)) { + throw 'not supported currencies'; } final inputMint = _getTokenMint(request.fromCurrency);