From 13a96189b0f2638d1a13c68105c2decf54cf8327 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 3 Feb 2026 18:32:27 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../com/tangem/feature/swap/domain/SwapInteractorImpl.kt | 9 ++++++++- .../main/java/com/tangem/feature/swap/model/SwapModel.kt | 9 +++++++-- .../feature/swap/model/SwapNotificationsFactory.kt | 5 ++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt index a8b55e5af2..8b1c5ff4a5 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt @@ -1648,7 +1648,14 @@ internal class SwapInteractorImpl @AssistedInject constructor( } } } else { - IncludeFeeInAmount.Excluded + val fee = txFeeSealedState.txFee.fee.amount.value ?: BigDecimal.ZERO + getIncludeFeeInAmountForNative( + networkId = networkId, + amount = amount, + reduceBalanceBy = reduceBalanceBy, + fromToken = fromToken.currency, + feeValue = fee, + ) } } is TxFeeSealedState.Legacy -> { diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt index 496279474f..b51473e5c1 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt @@ -2194,9 +2194,14 @@ internal class SwapModel @Inject constructor( state.value = newState // If fee currency is same as from currency, we need to reload quotes to update fee info - if (newState is FeeSelectorUM.Content && + val isFeeCurrencySameAsFromCurrency = newState is FeeSelectorUM.Content && dataState.fromCryptoCurrency?.currency?.id == newState.feeExtraInfo.feeCryptoCurrencyStatus.currency.id - ) { + + // If fee currency is coin, we need to reload quotes to update fee related warnings (e.g. insufficient funds) + val isCoinFeeSelected = newState is FeeSelectorUM.Content && + newState.feeExtraInfo.feeCryptoCurrencyStatus.currency is CryptoCurrency.Coin + + if (isFeeCurrencySameAsFromCurrency || isCoinFeeSelected) { // block swap button until fee is loaded uiState = uiState.copy( swapButton = uiState.swapButton.copy( diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapNotificationsFactory.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapNotificationsFactory.kt index f7a1817cb3..6c9bd0a484 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapNotificationsFactory.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapNotificationsFactory.kt @@ -298,9 +298,12 @@ internal class SwapNotificationsFactory( quoteModel.permissionState !is PermissionDataState.PermissionLoading && feeEnoughState.feeCurrency != fromToken + val isNotEnoughFee = + quoteModel.preparedSwapConfigState.includeFeeInAmount is IncludeFeeInAmount.BalanceNotEnough + val isGaslessAvailable = iGaslessFeeSupportedForNetwork(fromToken.network) && quoteModel.swapProvider.type == ExchangeProviderType.CEX - if (shouldShowCoverWarning && !isGaslessAvailable) { + if (shouldShowCoverWarning && !isGaslessAvailable || isNotEnoughFee) { add( SwapNotificationUM.Error.UnableToCoverFeeWarning( fromToken = fromToken,