Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-20 13:52:27 +04:00
parent 84b2c6ffcd
commit bac57ca199
4 changed files with 16 additions and 4 deletions

View file

@ -7,6 +7,7 @@ import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.model.getOrCreateModel
import com.tangem.domain.express.models.ExpressError
import com.tangem.domain.express.models.ExpressProvider
import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWalletId
@ -53,6 +54,7 @@ internal class SwapNotificationsComponent(
val fromCryptoCurrencyStatus: CryptoCurrencyStatus? = null,
val priceImpact: PriceImpact? = null,
val provider: ExpressProvider? = null,
val rateType: ExpressRateType? = null,
val shouldIncludeFeeInBalanceCheck: Boolean = false,
val feeValue: BigDecimal? = null,
)

View file

@ -8,6 +8,7 @@ import com.tangem.core.decompose.model.ParamsContainer
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.express.models.ExpressError
import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.transaction.usecase.IsMemoRequiredUseCase
import com.tangem.features.swap.v2.api.subcomponents.SwapAmountUpdateTrigger
import com.tangem.features.swap.v2.impl.amount.entity.PriceImpact
@ -150,21 +151,28 @@ internal class SwapNotificationsModel @Inject constructor(
fun MutableList<NotificationUM>.addExpressErrorNotification() {
val expressError = notificationData.expressError ?: return
val fromCryptoCurrency = notificationData.fromCryptoCurrency ?: return
val toCryptoCurrency = notificationData.toCryptoCurrencyStatus?.currency ?: return
val amountErrorCurrency = if (notificationData.rateType == ExpressRateType.Fixed) {
toCryptoCurrency
} else {
fromCryptoCurrency
}
val errorNotification = when (expressError) {
is ExpressError.AmountError.TooSmallError -> SwapNotificationUM.Error.MinimalAmountError(
expressError.amount.format {
crypto(
symbol = fromCryptoCurrency.symbol,
decimals = fromCryptoCurrency.decimals,
symbol = amountErrorCurrency.symbol,
decimals = amountErrorCurrency.decimals,
)
},
)
is ExpressError.AmountError.TooBigError -> SwapNotificationUM.Error.MaximumAmountError(
expressError.amount.format {
crypto(
symbol = fromCryptoCurrency.symbol,
decimals = fromCryptoCurrency.decimals,
symbol = amountErrorCurrency.symbol,
decimals = amountErrorCurrency.decimals,
)
},
)

View file

@ -141,6 +141,7 @@ internal class SendWithSwapConfirmComponent @AssistedInject constructor(
enteredFromAmount = model.confirmData.enteredFromAmount,
fromCryptoCurrencyStatus = model.confirmData.fromCryptoCurrencyStatus,
priceImpact = model.confirmData.priceImpact,
rateType = model.confirmData.rateType,
),
),
)

View file

@ -463,6 +463,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
fromCryptoCurrencyStatus = confirmData.fromCryptoCurrencyStatus,
priceImpact = confirmData.priceImpact,
provider = confirmData.quote?.provider,
rateType = confirmData.rateType,
shouldIncludeFeeInBalanceCheck = isFixedRate && isAmountSubtractAvailable,
feeValue = confirmData.fee?.amount?.value,
),