From 14cbec446e89b7111014cf4c7ea3d3b4bde2a51e Mon Sep 17 00:00:00 2001 From: Tangem Date: Sun, 18 Jan 2026 11:10:11 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../GetBalanceNotEnoughForFeeWarningUseCase.kt | 17 +++++++++-------- .../notifications/model/NotificationsModel.kt | 2 +- .../impl/presentation/model/StakingModel.kt | 5 +++-- .../model/YieldSupplyNotificationsModel.kt | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetBalanceNotEnoughForFeeWarningUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetBalanceNotEnoughForFeeWarningUseCase.kt index 9f8fe6fc0c..102ad31f39 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetBalanceNotEnoughForFeeWarningUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetBalanceNotEnoughForFeeWarningUseCase.kt @@ -34,27 +34,28 @@ class GetBalanceNotEnoughForFeeWarningUseCase( fee: BigDecimal, userWalletId: UserWalletId, tokenStatus: CryptoCurrencyStatus, - coinStatus: CryptoCurrencyStatus, + feeStatus: CryptoCurrencyStatus, ): Either = Either.catch { withContext(dispatchers.io) { val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, tokenStatus.currency.network) - val coinBalance = coinStatus.value.amount ?: BigDecimal.ZERO + val feeTokenBalance = feeStatus.value.amount ?: BigDecimal.ZERO val isFeePaidByCoin = tokenStatus.currency is CryptoCurrency.Token val isFeePaidByToken = feePaidCurrency is FeePaidCurrency.Token && tokenStatus.currency.id != feePaidCurrency.tokenId - val isNetworkSupportGasless = currencyChecksRepository.isNetworkSupportedForGaslessTx( - coinStatus.currency.network, - ) + + val isFeePaidByGaslessToken = + currencyChecksRepository.isNetworkSupportedForGaslessTx(feeStatus.currency.network) && + feeStatus.currency is CryptoCurrency.Token val warning = when { feePaidCurrency is FeePaidCurrency.Coin && isFeePaidByCoin && - fee > coinBalance && - !isNetworkSupportGasless -> { + fee > feeTokenBalance && + !isFeePaidByGaslessToken -> { CryptoCurrencyWarning.BalanceNotEnoughForFee( tokenCurrency = tokenStatus.currency, - coinCurrency = coinStatus.currency, + coinCurrency = feeStatus.currency, ) } feePaidCurrency is FeePaidCurrency.Token && isFeePaidByToken && fee > feePaidCurrency.balance -> { 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 7c4bc6ef9d..87cb0d5f97 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 @@ -235,7 +235,7 @@ internal class NotificationsModel @Inject constructor( fee = feeValue, userWalletId = userWalletId, tokenStatus = cryptoCurrencyStatus, - coinStatus = feeCryptoCurrencyStatus, + feeStatus = notificationData.feeCryptoCurrencyStatus, ).getOrNull() addExceedBalanceNotification( diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt index fa875ef820..cc46fde53c 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt @@ -852,12 +852,13 @@ internal class StakingModel @Inject constructor( val amount = amountState?.amountTextField?.cryptoAmount?.value val fee = feeState?.fee?.amount?.value - val currencyWarning = if (feeCryptoCurrencyStatus != null && fee != null) { + val feeStatus = feeCryptoCurrencyStatus + val currencyWarning = if (feeStatus != null && fee != null) { getBalanceNotEnoughForFeeWarningUseCase( fee = fee, userWalletId = userWalletId, tokenStatus = cryptoCurrencyStatus, - coinStatus = feeCryptoCurrencyStatus ?: cryptoCurrencyStatus, + feeStatus = feeStatus, ).getOrNull() } else { null diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/notifications/model/YieldSupplyNotificationsModel.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/notifications/model/YieldSupplyNotificationsModel.kt index 9dc753015c..f6163ccc3c 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/notifications/model/YieldSupplyNotificationsModel.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/notifications/model/YieldSupplyNotificationsModel.kt @@ -54,7 +54,7 @@ internal class YieldSupplyNotificationsModel @Inject constructor( fee = data.feeValue.orZero(), userWalletId = params.userWalletId, tokenStatus = cryptoCurrencyStatus, - coinStatus = feeCryptoCurrencyStatus, + feeStatus = feeCryptoCurrencyStatus, ).getOrNull() addExceedsBalanceNotification(