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
This commit is contained in:
David Adegoke
2026-03-27 00:35:06 +01:00
committed by GitHub
parent 6378e929b6
commit ebfc339117
2 changed files with 2 additions and 3 deletions
+1 -2
View File
@@ -45,8 +45,7 @@ BigInt parseFixed(String value, int decimals) {
var fraction = (comps.length == 2 ? comps[1] : "0").padRight(decimals, "0");
if (fraction.length > multiplier.length - 1) {
throw FormatException(
"fractional component exceeds decimals, underflow, parseFixed");
throw FormatException("fractional component exceeds decimals, underflow, parseFixed");
}
final wholeValue = BigInt.parse(whole);
@@ -763,7 +763,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
if (price == null || price == 0.0) return;
final crypto = _enteredAmount / price;
final depositAmountTmp = crypto.toString().withMaxDecimals(receiveCurrency.decimals);
final depositAmountTmp = crypto.toString().withMaxDecimals(depositCurrency.decimals);
if (_depositAmount != depositAmountTmp) {
changeDepositAmount(amount: depositAmountTmp, isCanonical: true);
}