From 9943f33070e7d63ee9b6d970ae5abdae9b2c6255 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 14 Apr 2026 15:45:21 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../features/send/v2/api/SendNotificationsComponent.kt | 1 + .../notifications/model/NotificationsModel.kt | 4 ++++ .../v2/impl/notifications/SwapNotificationsComponent.kt | 2 ++ .../v2/impl/notifications/model/SwapNotificationsModel.kt | 7 ++++++- .../sendviaswap/confirm/model/SendWithSwapConfirmModel.kt | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/SendNotificationsComponent.kt b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/SendNotificationsComponent.kt index b6c92acf3a..8e8192a6db 100644 --- a/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/SendNotificationsComponent.kt +++ b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/SendNotificationsComponent.kt @@ -41,6 +41,7 @@ interface SendNotificationsComponent { val fee: Fee?, val feeError: GetFeeError?, val feeCryptoCurrencyStatus: CryptoCurrencyStatus, + val isReduceAmountAvailable: Boolean = true, ) } diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt index 8d0fd0bb25..676eb712c2 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt @@ -108,6 +108,10 @@ internal class NotificationsModel @Inject constructor( } private suspend fun checkIfSubtractAvailable() { + if (!notificationData.isReduceAmountAvailable) { + isAmountSubtractAvailable = false + return + } val feeCurrencyId = notificationData.feeCryptoCurrencyStatus.currency.id val fee = notificationData.fee isAmountSubtractAvailable = isAmountSubtractAvailableUseCase( diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt index 580b1c629a..f68c3e608d 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt @@ -53,6 +53,8 @@ internal class SwapNotificationsComponent( val fromCryptoCurrencyStatus: CryptoCurrencyStatus? = null, val priceImpact: PriceImpact? = null, val provider: ExpressProvider? = null, + val shouldIncludeFeeInBalanceCheck: Boolean = false, + val feeValue: BigDecimal? = null, ) } } \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt index f69bf413d1..8855010bf1 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt @@ -132,7 +132,12 @@ internal class SwapNotificationsModel @Inject constructor( private fun MutableList.addInsufficientFundsNotification() { val enteredFromAmount = notificationData.enteredFromAmount ?: return val balance = notificationData.fromCryptoCurrencyStatus?.value?.amount ?: return - if (enteredFromAmount > balance) { + val totalRequired = if (notificationData.shouldIncludeFeeInBalanceCheck) { + enteredFromAmount + (notificationData.feeValue ?: BigDecimal.ZERO) + } else { + enteredFromAmount + } + if (totalRequired > balance) { add(SwapNotificationUM.Error.InsufficientFunds) } } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt index 3c71e14050..c335013569 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt @@ -23,6 +23,7 @@ import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resourceReference import com.tangem.domain.account.status.usecase.GetAccountCurrencyByAddressUseCase import com.tangem.domain.express.models.ExpressOperationType +import com.tangem.domain.express.models.ExpressRateType import com.tangem.domain.express.models.ExpressProviderType import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.models.currency.CryptoCurrency @@ -432,6 +433,7 @@ internal class SendWithSwapConfirmModel @Inject constructor( private fun updateConfirmNotifications() { modelScope.launch { + val isFixedRate = amountUM?.swapRateType == ExpressRateType.Fixed val feeCryptoCurrencyStatus = feeUMV2?.feeExtraInfo?.feeCryptoCurrencyStatus ?: params.primaryFeePaidCurrencyStatusFlow.value sendNotificationsUpdateTrigger.triggerUpdate( @@ -448,6 +450,7 @@ internal class SendWithSwapConfirmModel @Inject constructor( fee = confirmData.fee, feeError = confirmData.feeError, feeCryptoCurrencyStatus = feeCryptoCurrencyStatus, + isReduceAmountAvailable = !isFixedRate, ), ) swapNotificationsUpdateTrigger.triggerUpdate( @@ -462,6 +465,8 @@ internal class SendWithSwapConfirmModel @Inject constructor( fromCryptoCurrencyStatus = confirmData.fromCryptoCurrencyStatus, priceImpact = confirmData.priceImpact, provider = confirmData.quote?.provider, + shouldIncludeFeeInBalanceCheck = isFixedRate && isAmountSubtractAvailable, + feeValue = confirmData.fee?.amount?.value, ), ) uiState.transformerUpdate(