Updated on 2026-08-14

This commit is contained in:
Tangem 2026-05-13 12:37:42 +05:00
commit 9ab78e4614
2 changed files with 27 additions and 23 deletions

View file

@ -1223,6 +1223,23 @@ internal class SwapInteractorImpl @Inject constructor(
},
)
val fee = when (txFeeSealedState) {
is TxFeeSealedState.Component -> txFeeSealedState.txFee.fee.amount.value
is TxFeeSealedState.Legacy -> {
when (val txFee = txFeeSealedState.txFeeState) {
TxFeeState.Empty -> BigDecimal.ZERO
is TxFeeState.MultipleFeeState -> txFee.priorityFee.fee.amount.value
is TxFeeState.SingleFeeState -> txFee.fee.fee.amount.value
}
}
}
val feeState = getFeeState(
fromSwapCurrencyStatus = fromSwapCurrencyStatus,
fee = fee,
spendAmount = amount,
)
when (provider.type) {
ExchangeProviderType.DEX, ExchangeProviderType.DEX_BRIDGE -> {
val state = updatePermissionState(
@ -1236,26 +1253,11 @@ internal class SwapInteractorImpl @Inject constructor(
state.copy(
preparedSwapConfigState = state.preparedSwapConfigState.copy(
isBalanceEnough = isBalanceWithoutFeeEnough,
feeState = feeState,
),
)
}
ExchangeProviderType.CEX -> {
val fee = when (txFeeSealedState) {
is TxFeeSealedState.Component -> txFeeSealedState.txFee.fee.amount.value
is TxFeeSealedState.Legacy -> {
when (val txFee = txFeeSealedState.txFeeState) {
TxFeeState.Empty -> BigDecimal.ZERO
is TxFeeState.MultipleFeeState -> txFee.priorityFee.fee.amount.value
is TxFeeState.SingleFeeState -> txFee.fee.fee.amount.value
}
}
}
val feeState = getFeeState(
fromSwapCurrencyStatus = fromSwapCurrencyStatus,
fee = fee,
spendAmount = amount,
)
swapState.copy(
permissionState = PermissionDataState.Empty,
preparedSwapConfigState = PreparedSwapConfigState(

View file

@ -306,23 +306,25 @@ internal class SwapNotificationsFactory(
) {
if (hideFee) return
val fromCurrency = quoteModel.fromTokenInfo.swapCurrencyStatus.currency
val feeEnoughState = quoteModel.preparedSwapConfigState.feeState as? SwapFeeState.NotEnough ?: return
val shouldShowCoverWarning = quoteModel.preparedSwapConfigState.isBalanceEnough &&
val feeEnoughState = quoteModel.preparedSwapConfigState.feeState as? SwapFeeState.NotEnough
val shouldShowCoverWarning = !quoteModel.preparedSwapConfigState.isBalanceEnough &&
quoteModel.permissionState !is PermissionDataState.PermissionLoading &&
feeCryptoCurrencyStatus?.currency != fromCurrency
val isNotEnoughFee =
val isCEXProvider = quoteModel.swapProvider.type == ExchangeProviderType.CEX
val isNotEnoughFee = feeEnoughState is SwapFeeState.NotEnough && !isCEXProvider ||
quoteModel.preparedSwapConfigState.includeFeeInAmount is IncludeFeeInAmount.BalanceNotEnough
val isGaslessAvailable = iGaslessFeeSupportedForNetwork(fromCurrency.network) &&
quoteModel.swapProvider.type == ExchangeProviderType.CEX
val isGaslessAvailable = iGaslessFeeSupportedForNetwork(fromCurrency.network) && isCEXProvider
if (shouldShowCoverWarning && !isGaslessAvailable || isNotEnoughFee) {
add(
SwapNotificationUM.Error.UnableToCoverFeeWarning(
fromToken = fromCurrency,
feeCurrency = feeCryptoCurrencyStatus?.currency,
currencyName = feeEnoughState.currencyName ?: fromCurrency.network.name,
currencySymbol = feeEnoughState.currencySymbol ?: fromCurrency.network.currencySymbol,
currencyName = feeEnoughState?.currencyName ?: fromCurrency.network.name,
currencySymbol = feeEnoughState?.currencySymbol ?: fromCurrency.network.currencySymbol,
onConfirmClick = actions.onBuyClick,
),
)