fix: Handle fiat amount edgecase that makes crypto amount decimal length greater than multiplier length (#3135)

* fix: Handle fiat amount edgecase that makes crypto amount decimal length greater than multiplier length * fix: Switch currency decimal for crypto conversion

David Adegoke committed Mar 27, 2026 at 00:35 UTC ebfc339117a9666c27442199b62b93619bc2c823
2 files changed +2 -3
cw_core/lib/parse_fixed.dart
+1 -2
@@ -45,8 +45,7 @@ BigInt parseFixed(String value, int decimals) {
45 var fraction = (comps.length == 2 ? comps[1] : "0").padRight(decimals, "0");
46
47 if (fraction.length > multiplier.length - 1) {
48 - throw FormatException(
49 - "fractional component exceeds decimals, underflow, parseFixed");
48 + throw FormatException("fractional component exceeds decimals, underflow, parseFixed");
49 }
50
51 final wholeValue = BigInt.parse(whole);
lib/view_model/exchange/exchange_view_model.dart
+1 -1
@@ -763,7 +763,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
763 if (price == null || price == 0.0) return;
764
765 final crypto = _enteredAmount / price;
766 - final depositAmountTmp = crypto.toString().withMaxDecimals(receiveCurrency.decimals);
766 + final depositAmountTmp = crypto.toString().withMaxDecimals(depositCurrency.decimals);
767 if (_depositAmount != depositAmountTmp) {
768 changeDepositAmount(amount: depositAmountTmp, isCanonical: true);
769 }