Updated on 2026-08-14
This commit is contained in:
parent
36b9e004ba
commit
ed80b29c78
5 changed files with 74 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ import com.tangem.common.ui.notifications.NotificationUM
|
|||
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.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
|
|
@ -51,6 +52,7 @@ internal class SwapNotificationsComponent(
|
|||
val enteredFromAmount: BigDecimal? = null,
|
||||
val fromCryptoCurrencyStatus: CryptoCurrencyStatus? = null,
|
||||
val priceImpact: PriceImpact? = null,
|
||||
val provider: ExpressProvider? = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.tangem.features.swap.v2.impl.notifications.model
|
|||
|
||||
import com.tangem.blockchain.common.BlockchainSdkError
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
|
|
@ -17,6 +18,7 @@ import com.tangem.features.swap.v2.impl.notifications.SwapNotificationsComponent
|
|||
import com.tangem.features.swap.v2.impl.notifications.SwapNotificationsComponent.Params.SwapNotificationData
|
||||
import com.tangem.features.swap.v2.impl.notifications.SwapNotificationsUpdateListener
|
||||
import com.tangem.features.swap.v2.impl.notifications.entity.SwapNotificationUM
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.analytics.SendWithSwapAnalyticEvents
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -29,6 +31,7 @@ import kotlinx.coroutines.launch
|
|||
import java.math.BigDecimal
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@ModelScoped
|
||||
internal class SwapNotificationsModel @Inject constructor(
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
|
|
@ -36,6 +39,7 @@ internal class SwapNotificationsModel @Inject constructor(
|
|||
private val swapNotificationsUpdateTrigger: DefaultSwapNotificationsUpdateTrigger,
|
||||
private val swapAmountUpdateTrigger: SwapAmountUpdateTrigger,
|
||||
private val validateTransactionUseCase: ValidateTransactionUseCase,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
paramsContainer: ParamsContainer,
|
||||
) : Model() {
|
||||
|
||||
|
|
@ -80,6 +84,34 @@ internal class SwapNotificationsModel @Inject constructor(
|
|||
.isNotEmpty()
|
||||
swapNotificationsUpdateTrigger.callbackHasError(hasErrorNotification)
|
||||
uiState.value = notifications.toImmutableList()
|
||||
|
||||
val fromCurrency = notificationData.fromCryptoCurrency
|
||||
val toCurrency = notificationData.toCryptoCurrencyStatus?.currency
|
||||
val provider = notificationData.provider
|
||||
if (fromCurrency != null && toCurrency != null && provider != null) {
|
||||
if (notifications.any { it is SwapNotificationUM.Warning.HighPriceImpact }) {
|
||||
analyticsEventHandler.send(
|
||||
SendWithSwapAnalyticEvents.HighPriceImpact(
|
||||
sendToken = fromCurrency.symbol,
|
||||
receiveToken = toCurrency.symbol,
|
||||
sendBlockchain = fromCurrency.network.name,
|
||||
receiveBlockchain = toCurrency.network.name,
|
||||
providerName = provider.name,
|
||||
),
|
||||
)
|
||||
}
|
||||
if (notifications.any { it is SwapNotificationUM.Warning.TradeTooHigh }) {
|
||||
analyticsEventHandler.send(
|
||||
SendWithSwapAnalyticEvents.TradeTooLarge(
|
||||
sendToken = fromCurrency.symbol,
|
||||
receiveToken = toCurrency.symbol,
|
||||
sendBlockchain = fromCurrency.network.name,
|
||||
receiveBlockchain = toCurrency.network.name,
|
||||
providerName = provider.name,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun MutableList<NotificationUM>.addDestinationTagRequiredNotification() {
|
||||
|
|
|
|||
|
|
@ -133,6 +133,41 @@ internal sealed class SendWithSwapAnalyticEvents(
|
|||
),
|
||||
)
|
||||
|
||||
class HighPriceImpact(
|
||||
val sendToken: String,
|
||||
val receiveToken: String,
|
||||
val sendBlockchain: String,
|
||||
val receiveBlockchain: String,
|
||||
val providerName: String,
|
||||
) : SendWithSwapAnalyticEvents(
|
||||
event = "Notice - High price impact",
|
||||
params = mapOf(
|
||||
SEND_TOKEN to sendToken,
|
||||
RECEIVE_TOKEN to receiveToken,
|
||||
"Send Blockchain" to sendBlockchain,
|
||||
"Receive Blockchain" to receiveBlockchain,
|
||||
PROVIDER to providerName,
|
||||
),
|
||||
)
|
||||
|
||||
class TradeTooLarge(
|
||||
val sendToken: String,
|
||||
val receiveToken: String,
|
||||
val sendBlockchain: String,
|
||||
val receiveBlockchain: String,
|
||||
val providerName: String,
|
||||
|
||||
) : SendWithSwapAnalyticEvents(
|
||||
event = "Notice - Trade too large",
|
||||
params = mapOf(
|
||||
SEND_TOKEN to sendToken,
|
||||
RECEIVE_TOKEN to receiveToken,
|
||||
"Send Blockchain" to sendBlockchain,
|
||||
"Receive Blockchain" to receiveBlockchain,
|
||||
PROVIDER to providerName,
|
||||
),
|
||||
)
|
||||
|
||||
enum class ErrorScreen {
|
||||
Amount,
|
||||
Confirm,
|
||||
|
|
|
|||
|
|
@ -460,6 +460,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
enteredFromAmount = confirmData.enteredFromAmount,
|
||||
fromCryptoCurrencyStatus = confirmData.fromCryptoCurrencyStatus,
|
||||
priceImpact = confirmData.priceImpact,
|
||||
provider = confirmData.quote?.provider,
|
||||
),
|
||||
)
|
||||
uiState.transformerUpdate(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue