Updated on 2026-08-14
This commit is contained in:
parent
d52133d13e
commit
9943f33070
5 changed files with 18 additions and 1 deletions
|
|
@ -41,6 +41,7 @@ interface SendNotificationsComponent {
|
|||
val fee: Fee?,
|
||||
val feeError: GetFeeError?,
|
||||
val feeCryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
val isReduceAmountAvailable: Boolean = true,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -132,7 +132,12 @@ internal class SwapNotificationsModel @Inject constructor(
|
|||
private fun MutableList<NotificationUM>.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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue