Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-17 16:01:41 +05:00
parent 6afae8e619
commit 63125dc0f3
7 changed files with 54 additions and 23 deletions

View file

@ -165,19 +165,23 @@ internal class DefaultCurrencyChecksRepository(
}
}
override suspend fun getProtocolBalance(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): BigDecimal? {
require(cryptoCurrency is CryptoCurrency.Token)
override suspend fun getProtocolBalance(
userWalletId: UserWalletId,
cryptoCurrencyStatus: CryptoCurrencyStatus,
): BigDecimal? {
val token = cryptoCurrencyStatus.currency as? CryptoCurrency.Token ?: return null
if (cryptoCurrencyStatus.value.yieldSupplyStatus?.isActive == false) return null
return runCatching {
val walletManager = walletManagersFacade.getOrCreateWalletManager(
userWalletId = userWalletId,
blockchain = cryptoCurrency.network.toBlockchain(),
derivationPath = cryptoCurrency.network.derivationPath.value,
blockchain = token.network.toBlockchain(),
derivationPath = token.network.derivationPath.value,
) ?: error("Wallet manager not found")
walletManager.getProtocolBalance(
token = Token(
symbol = cryptoCurrency.symbol,
contractAddress = cryptoCurrency.contractAddress,
decimals = cryptoCurrency.decimals,
symbol = token.symbol,
contractAddress = token.contractAddress,
decimals = token.decimals,
),
)
}.onFailure(Timber::e).getOrThrow()

View file

@ -51,7 +51,7 @@ class GetCurrencyWarningsUseCase(
flowOf(currencyChecksRepository.getRentInfoWarning(userWalletId, currencyStatus)),
flowOf(currencyChecksRepository.getExistentialDeposit(userWalletId, currency.network)),
flowOf(currencyChecksRepository.getFeeResourceAmount(userWalletId, currency.network)),
flowOf(currencyChecksRepository.getProtocolBalance(userWalletId, currency)),
flowOf(currencyChecksRepository.getProtocolBalance(userWalletId, currencyStatus)),
) { coinRelatedWarnings, maybeRentWarning, maybeEdWarning, maybeFeeResource, yieldSupplyProtocolBalance ->
setOfNotNull(
maybeRentWarning,

View file

@ -67,5 +67,5 @@ interface CurrencyChecksRepository {
* This represents the amount supplied to the protocol for the specified `userWalletId`
* (e.g., aTokens balance). Returns null if not applicable or unknown.
*/
suspend fun getProtocolBalance(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): BigDecimal?
suspend fun getProtocolBalance(userWalletId: UserWalletId, cryptoCurrencyStatus: CryptoCurrencyStatus): BigDecimal?
}

View file

@ -45,7 +45,7 @@ internal class TokenDetailsNotificationsAnalyticsSender(
is TokenDetailsNotification.KaspaIncompleteTransactionWarning -> TokenDetailsAnalyticsEvent.Notice.Reveal(
currency = cryptoCurrency,
)
is TokenDetailsNotification.YieldSupplyNotTransferedToAave -> YieldSupplyAnalytics.NoticeNotEnoughMinAmount(
is TokenDetailsNotification.YieldSupplyNotTransferedToAave -> YieldSupplyAnalytics.NoticeAmountNotDeposited(
token = cryptoCurrency.symbol,
blockchain = cryptoCurrency.network.name,
)

View file

@ -33,6 +33,17 @@ sealed class YieldSupplyAnalytics(
),
)
data class StopEarningScreen(
val token: String,
val blockchain: String,
) : YieldSupplyAnalytics(
event = "Stop Earning Screen",
params = mapOf(
TOKEN_PARAM to token,
BLOCKCHAIN to blockchain,
),
)
data class ButtonStartEarning(
val token: String,
val blockchain: String,
@ -55,6 +66,17 @@ sealed class YieldSupplyAnalytics(
),
)
data class ButtonGiveApprove(
val token: String,
val blockchain: String,
) : YieldSupplyAnalytics(
event = " Button - Give Approve",
params = mapOf(
TOKEN_PARAM to token,
BLOCKCHAIN to blockchain,
),
)
data object ButtonFeePolicy : YieldSupplyAnalytics(
event = "Button - Fee Policy",
)
@ -150,22 +172,11 @@ sealed class YieldSupplyAnalytics(
event = "APY Chart",
)
data class NoticeCommissionTooHigh(
data class NoticeAmountNotDeposited(
val token: String,
val blockchain: String,
) : YieldSupplyAnalytics(
event = "Notice - Commission Is Too High",
params = mapOf(
TOKEN_PARAM to token,
BLOCKCHAIN to blockchain,
),
)
data class NoticeNotEnoughMinAmount(
val token: String,
val blockchain: String,
) : YieldSupplyAnalytics(
event = "Notice - Not Enough Min Amount",
event = "Notice - Amount Not Deposited",
params = mapOf(
TOKEN_PARAM to token,
BLOCKCHAIN to blockchain,

View file

@ -119,6 +119,11 @@ internal class YieldSupplyApproveModel @Inject constructor(
val yieldSupplyFeeUM = uiState.value.yieldSupplyFeeUM as? YieldSupplyFeeUM.Content ?: return
uiState.update(YieldSupplyTransactionInProgressTransformer)
analyticsEventHandler.send(YieldSupplyAnalytics.ButtonGiveApprove(
token = cryptoCurrency.symbol,
blockchain = cryptoCurrency.network.name,
))
modelScope.launch(dispatchers.default) {
sendTransactionUseCase(
txData = yieldSupplyFeeUM.transactionDataList.first(),

View file

@ -97,6 +97,13 @@ internal class YieldSupplyStopEarningModel @Inject constructor(
)
init {
val currency = params.cryptoCurrencyStatusFlow.value.currency
analytics.send(
YieldSupplyAnalytics.StopEarningScreen(
token = currency.symbol,
blockchain = currency.network.name,
),
)
modelScope.launch {
appCurrency = getSelectedAppCurrencyUseCase.invokeSync().getOrElse { AppCurrency.Default }
subscribeOnCurrencyStatusUpdates()
@ -133,6 +140,10 @@ internal class YieldSupplyStopEarningModel @Inject constructor(
ifLeft = { error ->
Timber.e(error.toString())
uiState.update(YieldSupplyTransactionReadyTransformer)
analytics.send(YieldSupplyAnalytics.EarnErrors(
action = YieldSupplyAnalytics.Action.Stop,
errorDescription = error.getAnalyticsDescription(),
))
yieldSupplyAlertFactory.getSendTransactionErrorState(
error = error,
popBack = params.callback::onBackClick,