Refactor jupiter supported currency checks for swaps (#2886)
David Adegoke committed
Feb 10, 2026 at 14:44 UTC
2309f408d2a492f0d9cd55068dbfaf5b72846a12
1 file changed
+8
-12
lib/exchange/provider/jupiter_exchange_provider.dart
+8
-12
@@ -18,13 +18,9 @@ import 'package:cw_core/utils/proxy_wrapper.dart';
18
class JupiterExchangeProvider extends ExchangeProvider {
19
JupiterExchangeProvider();
20
21
- // Jupiter only supports Solana tokens
22
- static const List<CryptoCurrency> _notSupported = [];
23
-
24
- static final List<CryptoCurrency> _supportedCurrencies = CryptoCurrency.all
25
- .where((c) => c.tag == 'SOL' || c == CryptoCurrency.sol)
26
- .where((c) => !_notSupported.contains(c))
27
- .toList();
21
+ // Jupiter only supports Solana native SOL and Solana tokens
22
+ bool _isSolanaCurrency(CryptoCurrency currency) =>
23
+ currency == CryptoCurrency.sol || currency.tag == 'SOL';
24
25
static const _baseUrl = 'api.jup.ag';
26
static const _orderPath = '/ultra/v1/order';
@@ -88,7 +84,7 @@ class JupiterExchangeProvider extends ExchangeProvider {
84
// - errorCode 3: Minimum amount for gasless
85
86
// only return null for supported currencies
91
- if (_supportedCurrencies.contains(from) && _supportedCurrencies.contains(to)) {
87
+ if (_isSolanaCurrency(from) && _isSolanaCurrency(to)) {
88
return Limits(min: null, max: null);
89
} else {
90
throw Exception('not supported');
@@ -136,7 +132,7 @@ class JupiterExchangeProvider extends ExchangeProvider {
132
}) async {
133
try {
134
// must support both
139
- if (!_supportedCurrencies.contains(from) || !_supportedCurrencies.contains(to)) {
135
+ if (!_isSolanaCurrency(from) || !_isSolanaCurrency(to)) {
136
return 0.0;
137
}
138
final inputMint = _getTokenMint(from);
@@ -227,9 +223,9 @@ class JupiterExchangeProvider extends ExchangeProvider {
223
}) async {
224
try {
225
// must support both
230
- if (!_supportedCurrencies.contains(request.fromCurrency) ||
231
- !_supportedCurrencies.contains(request.toCurrency)) {
232
- throw "not supported currencies";
226
+ if (!_isSolanaCurrency(request.fromCurrency) ||
227
+ !_isSolanaCurrency(request.toCurrency)) {
228
+ throw 'not supported currencies';
229
}
230
231
final inputMint = _getTokenMint(request.fromCurrency);