Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-16 16:58:38 +05:00
parent 709eb125b3
commit 8dec1af7aa
21 changed files with 124 additions and 12 deletions

View file

@ -628,7 +628,11 @@ internal class ChildFactory @Inject constructor(
is AppRoute.YieldSupplyPromo -> {
createComponentChild(
context = context,
params = YieldSupplyPromoComponent.Params(route.userWalletId, route.cryptoCurrency),
params = YieldSupplyPromoComponent.Params(
userWalletId = route.userWalletId,
currency = route.cryptoCurrency,
apy = route.apy,
),
componentFactory = yieldSupplyPromoComponentFactory,
)
}

View file

@ -410,5 +410,6 @@ sealed class AppRoute(val path: String) : Route {
data class YieldSupplyPromo(
val userWalletId: UserWalletId,
val cryptoCurrency: CryptoCurrency,
val apy: String,
) : AppRoute(path = "/yield_supply_promo/${userWalletId.stringValue}/${cryptoCurrency.symbol}")
}

View file

@ -262,7 +262,7 @@
<string name="common_import">Importieren</string>
<string name="common_in_progress">In Arbeit</string>
<string name="common_later">Später</string>
<string name="common_learn_more">Mehr erfahren</string>
<string name="common_learn_more">Mehr erfahren</string>
<string name="common_left">%1$s übrig</string>
<string name="common_legacy_bitcoin_address">Legacy Bitcoin</string>
<string name="common_locked">Gesperrt</string>

View file

@ -895,7 +895,7 @@
<item quantity="other">最大%d日</item>
</plurals>
<string name="onramp_timing_minutes">%s分</string>
<string name="onramp_title_available_from___">下記より利用可能</string>
<string name="onramp_title_available_from">下記より利用可能</string>
<string name="onramp_title_you_get">以下が手に入ります。</string>
<string name="onramp_tos_external_providers">サービスは外部プロバイダーによって提供されます。 \nTangemは責任を負いません。</string>
<string name="onramp_transaction_status_footer_text">この画面を閉じて、トークンの詳細画面で取引状況を確認できます。</string>

View file

@ -202,7 +202,7 @@
<string name="common_import">Импортировать</string>
<string name="common_in_progress">В процессе</string>
<string name="common_later">Позже</string>
<string name="common_learn_more">Узнать больше</string>
<string name="common_learn_more">Узнать больше</string>
<string name="common_left">Осталось %1$s</string>
<string name="common_locked">Заблокирован</string>
<string name="common_main_network">Основная сеть</string>

View file

@ -22,6 +22,7 @@
<string name="account_archived_recover_error_message">You have already exceeded the limit of 20 active accounts. Archive one to recover.</string>
<string name="account_archived_recover_error_title">Can\'t recover account</string>
<string name="account_archived_title">Archived</string>
<string name="account_could_not_archive">We couldnt archive account. Please try again later.</string>
<string name="account_could_not_create">We couldnt create account. Please try again later.</string>
<string name="account_create_success_message">Account created</string>
<string name="account_details_archive">Archive account</string>
@ -260,6 +261,7 @@
<string name="common_from">From</string>
<string name="common_generate_addresses">Synchronize addresses</string>
<string name="common_get_started">Get started</string>
<string name="common_get_token">Get token</string>
<string name="common_go_to_provider">Go to provider</string>
<string name="common_go_to_token">Go to token</string>
<string name="common_got_it">Got it</string>
@ -268,7 +270,7 @@
<string name="common_import">Import</string>
<string name="common_in_progress">In progress</string>
<string name="common_later">Later</string>
<string name="common_learn_more">Learn more</string>
<string name="common_learn_more">Learn more</string>
<string name="common_left">%1$s left</string>
<string name="common_legacy_bitcoin_address">Legacy Bitcoin</string>
<string name="common_locked">Locked</string>
@ -617,6 +619,7 @@
<string name="manage_tokens_unavailable_description">The selected token is currently unavailable for actions within the crypto wallet. But worry not, you can express your interest by upvoting it.</string>
<string name="manage_tokens_unavailable_vote">Upvote</string>
<string name="manage_tokens_wallet_support_only_one_network_title">The wallet doesn\'t support more than one network</string>
<string name="markets_about_coin_header">About coin</string>
<string name="markets_add_to_my_portfolio_description">To buy, exchange, or receive this asset, add it to your portfolio</string>
<string name="markets_add_to_my_portfolio_unavailable_description">This asset is currently not supported in the wallet</string>
<string name="markets_add_to_my_portfolio_unavailable_for_wallet_description">This asset is not available for this wallet</string>
@ -652,6 +655,7 @@
<string name="markets_sort_by_trending_title">Trending</string>
<string name="markets_staking_banner_description_placeholder">Staking is the easiest way to receive rewards on your crypto. %s</string>
<string name="markets_staking_banner_title">Earn up to %s APY</string>
<string name="markets_token_added">Token Added</string>
<string name="markets_token_details_about_token_title">About %s</string>
<plurals name="markets_token_details_amount_exchanges">
<item quantity="one">%d exchange</item>
@ -917,7 +921,7 @@
<item quantity="other">up to %d days</item>
</plurals>
<string name="onramp_timing_minutes">%s min</string>
<string name="onramp_title_available_from___">Available from </string>
<string name="onramp_title_available_from">Available from</string>
<string name="onramp_title_you_get">You get</string>
<string name="onramp_tos_external_providers">Service is provided by an external provider. \nTangem is not responsible.</string>
<string name="onramp_transaction_status_footer_text">You can close this screen and check the transaction status on the token details screen.</string>
@ -1300,6 +1304,10 @@
<string name="swapping_to_title">You receive</string>
<string name="swapping_token_list_title">Choose token</string>
<string name="swapping_token_not_available">not available</string>
<string name="tangem_pay_deposit">Deposit</string>
<string name="tangem_pay_fee_subtitle">Service fees</string>
<string name="tangem_pay_fee_title">Fee</string>
<string name="tangem_pay_withdrawal">Withdrawal</string>
<string name="tangempay_card_details_error_text">Failed to load data. Try again later.</string>
<string name="tangempay_card_details_hide_text">Hide</string>
<string name="tangempay_card_details_receive_error_description">Technical issues detected. Please try again later or contact support.</string>
@ -1335,6 +1343,7 @@
<string name="token_button_unavailability_reason_pending_transaction_send">Sending funds will be available once the pending transaction(s) in network %s is complete</string>
<string name="token_button_unavailability_reason_sell_unavailable">Selling %s is not supported by current providers, but we are working to add more options.</string>
<string name="token_button_unavailability_reason_staking_unavailable">Staking %s is not supported by current providers, but we are working to add more options.</string>
<string name="token_button_unavailability_reason_yield_supply_approval">Text here</string>
<string name="token_details_generate_xpub">Generate XPUB</string>
<string name="token_details_hide_alert_hide">Hide</string>
<string name="token_details_hide_alert_message">You are about to hide this token from the main screen. You can add it back anytime through the manage tokens page.</string>
@ -1822,8 +1831,8 @@
<string name="yield_module_promo_screen_self_custodial_subtitle">Aave is a decentralized protocol managing over $81.9billion in total value.</string>
<string name="yield_module_promo_screen_self_custodial_title">Decentralized and self-custodial</string>
<string name="yield_module_promo_screen_terms_disclaimer">By using service, you agree with provider\n%1$s and %2$s</string>
<string name="yield_module_promo_screen_title">Earn %s%% yearly</string>
<string name="yield_module_promo_screen_variable_rate_info">Aave • Variable Interest Rate</string>
<string name="yield_module_promo_screen_title">Connect Aave</string>
<string name="yield_module_promo_screen_variable_rate_info">Aave %1$s%% • Variable Interest Rate</string>
<string name="yield_module_provider">Aave</string>
<string name="yield_module_rate_info_sheet_chart_average">Avg %s</string>
<string name="yield_module_rate_info_sheet_chart_title">Last year returns</string>

View file

@ -4,7 +4,9 @@ import com.tangem.blockchain.blockchains.polkadot.ExistentialDepositProvider
import com.tangem.blockchain.common.FeeResourceAmountProvider
import com.tangem.blockchain.common.MinimumSendAmountProvider
import com.tangem.blockchain.common.ReserveAmountProvider
import com.tangem.blockchain.common.Token
import com.tangem.blockchain.common.UtxoAmountLimitProvider
import com.tangem.blockchainsdk.utils.toBlockchain
import com.tangem.data.tokens.converters.UtxoConverter
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
@ -21,6 +23,7 @@ import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.extensions.isZero
import com.tangem.utils.extensions.orZero
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.math.BigDecimal
internal class DefaultCurrencyChecksRepository(
@ -161,4 +164,22 @@ internal class DefaultCurrencyChecksRepository(
else -> null
}
}
override suspend fun getProtocolBalance(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): BigDecimal? {
require(cryptoCurrency is CryptoCurrency.Token)
return runCatching {
val walletManager = walletManagersFacade.getOrCreateWalletManager(
userWalletId = userWalletId,
blockchain = cryptoCurrency.network.toBlockchain(),
derivationPath = cryptoCurrency.network.derivationPath.value,
) ?: error("Wallet manager not found")
walletManager.getProtocolBalance(
token = Token(
symbol = cryptoCurrency.symbol,
contractAddress = cryptoCurrency.contractAddress,
decimals = cryptoCurrency.decimals,
),
)
}.onFailure(Timber::e).getOrThrow()
}
}

View file

@ -68,4 +68,10 @@ sealed class CryptoCurrencyWarning {
val requiredAmount: BigDecimal,
val currencyDecimals: Int,
) : CryptoCurrencyWarning()
data class YieldSupplyNotDepositedAmount(
val currency: CryptoCurrency,
val currencySymbol: String,
val amount: BigDecimal,
) : CryptoCurrencyWarning()
}

View file

@ -51,7 +51,8 @@ class GetCurrencyWarningsUseCase(
flowOf(currencyChecksRepository.getRentInfoWarning(userWalletId, currencyStatus)),
flowOf(currencyChecksRepository.getExistentialDeposit(userWalletId, currency.network)),
flowOf(currencyChecksRepository.getFeeResourceAmount(userWalletId, currency.network)),
) { coinRelatedWarnings, maybeRentWarning, maybeEdWarning, maybeFeeResource ->
flowOf(currencyChecksRepository.getProtocolBalance(userWalletId, currency)),
) { coinRelatedWarnings, maybeRentWarning, maybeEdWarning, maybeFeeResource, yieldSupplyProtocolBalance ->
setOfNotNull(
maybeRentWarning,
maybeEdWarning?.let { getExistentialDepositWarning(currency, it) },
@ -62,6 +63,7 @@ class GetCurrencyWarningsUseCase(
getBeaconChainShutdownWarning(rawId = currency.network.id.rawId),
getAssetRequirementsWarning(userWalletId = userWalletId, currency = currency),
getMigrationFromMaticToPolWarning(currency),
getYieldSupplyWarning(cryptoCurrencyStatus = currencyStatus, yieldSupplyProtocolBalance),
)
}.flowOn(dispatchers.io)
}
@ -261,6 +263,28 @@ class GetCurrencyWarningsUseCase(
}
}
private fun getYieldSupplyWarning(
cryptoCurrencyStatus: CryptoCurrencyStatus,
protocolBalance: BigDecimal?,
): CryptoCurrencyWarning? {
val value = cryptoCurrencyStatus.value
val isActive = value.yieldSupplyStatus?.isActive == true
val amount = value.amount
if (!isActive || protocolBalance == null || amount == null) return null
val notDepositedAmount = amount.minus(protocolBalance)
return if (notDepositedAmount > BigDecimal.ZERO) {
CryptoCurrencyWarning.YieldSupplyNotDepositedAmount(
currency = cryptoCurrencyStatus.currency,
amount = notDepositedAmount,
currencySymbol = cryptoCurrencyStatus.currency.symbol,
)
} else {
null
}
}
private fun BigDecimal?.isZero(): Boolean {
return this?.signum() == 0
}

View file

@ -61,4 +61,11 @@ interface CurrencyChecksRepository {
currencyStatus: CryptoCurrencyStatus,
balanceAfterTransaction: BigDecimal,
): CryptoCurrencyWarning.Rent?
/**
* Returns the YieldSupplied protocol balance in Aave for the given `cryptoCurrency`.
* 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?
}

View file

@ -7,6 +7,7 @@ import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.tokens.model.analytics.TokenSwapPromoAnalyticsEvent
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification
import com.tangem.features.yield.supply.api.analytics.YieldSupplyAnalytics
internal class TokenDetailsNotificationsAnalyticsSender(
private val cryptoCurrency: CryptoCurrency,
@ -44,6 +45,10 @@ internal class TokenDetailsNotificationsAnalyticsSender(
is TokenDetailsNotification.KaspaIncompleteTransactionWarning -> TokenDetailsAnalyticsEvent.Notice.Reveal(
currency = cryptoCurrency,
)
is TokenDetailsNotification.YieldSupplyNotTransferedToAave -> YieldSupplyAnalytics.NoticeNotEnoughMinAmount(
token = cryptoCurrency.symbol,
blockchain = cryptoCurrency.network.name,
)
is TokenDetailsNotification.NetworksUnreachable,
is TokenDetailsNotification.ExistentialDeposit,
is TokenDetailsNotification.NetworksNoAccount,

View file

@ -6,6 +6,7 @@ import com.tangem.core.ui.components.notifications.NotificationConfig
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.networkIconResId
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.wallet.UserWallet
@ -257,4 +258,12 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) {
iconResId = R.drawable.ic_error_sync_24,
),
)
data class YieldSupplyNotTransferedToAave(val tokenName: String, val amount: String) : Warning(
title = resourceReference(
id = R.string.yield_module_amount_not_transfered_to_aave_title,
wrappedList(amount, tokenName),
),
subtitle = stringReference(""),
)
}

View file

@ -24,6 +24,7 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import timber.log.Timber
import java.math.BigDecimal
import kotlin.String
internal class TokenDetailsNotificationConverter(
private val userWalletId: UserWalletId,
@ -155,6 +156,10 @@ internal class TokenDetailsNotificationConverter(
)
is CryptoCurrencyWarning.MigrationMaticToPol -> MigrationMaticToPol
is CryptoCurrencyWarning.UsedOutdatedDataWarning -> UsedOutdatedData
is CryptoCurrencyWarning.YieldSupplyNotDepositedAmount -> YieldSupplyNotTransferedToAave(
tokenName = warning.currencySymbol,
amount = warning.amount.format { crypto(symbol = "", decimals = warning.currency.decimals) },
)
}
}

View file

@ -10,6 +10,7 @@ interface YieldSupplyPromoComponent : ComposableContentComponent {
data class Params(
val userWalletId: UserWalletId,
val currency: CryptoCurrency,
val apy: String,
)
interface Factory : ComponentFactory<Params, YieldSupplyPromoComponent>

View file

@ -9,6 +9,7 @@ internal sealed class YieldSupplyUM {
data object Initial : YieldSupplyUM()
data class Available(
val apy: String,
val title: TextReference,
val onClick: () -> Unit,
) : YieldSupplyUM()
@ -18,6 +19,7 @@ internal sealed class YieldSupplyUM {
data object Unavailable : YieldSupplyUM()
data class Content(
val apy: String,
val title: TextReference,
val subtitle: TextReference,
val rewardsApy: TextReference,

View file

@ -144,10 +144,17 @@ internal class YieldSupplyModel @Inject constructor(
}
override fun onStartEarningClick() {
val yieldSupplyUM = uiState.value
val apy = when (yieldSupplyUM) {
is YieldSupplyUM.Available -> yieldSupplyUM.apy
is YieldSupplyUM.Content -> yieldSupplyUM.apy
else -> ""
}
appRouter.push(
YieldSupplyPromo(
userWalletId = params.userWalletId,
cryptoCurrency = params.cryptoCurrency,
apy = apy,
),
)
}
@ -218,6 +225,7 @@ internal class YieldSupplyModel @Inject constructor(
),
onClick = ::onActiveClick,
isAllowedToSpend = yieldSupplyStatus.isAllowedToSpend,
apy = tokenStatus.apy.toString(),
)
}
}.onLeft {

View file

@ -21,6 +21,7 @@ internal class YieldSupplyTokenStatusSuccessTransformer(
formatArgs = wrappedList(tokenStatus.apy),
),
onClick = onStartEarningClick,
apy = tokenStatus.apy.toString(),
)
}
}

View file

@ -308,6 +308,7 @@ private class PreviewProvider : PreviewParameterProvider<YieldSupplyUM> {
R.string.yield_module_token_details_earn_notification_title,
wrappedList("5.1"),
),
apy = "5.1",
onClick = {},
),
YieldSupplyUM.Content(
@ -315,6 +316,7 @@ private class PreviewProvider : PreviewParameterProvider<YieldSupplyUM> {
subtitle = stringReference("Interest accrues automatically"),
rewardsApy = stringReference("5.1 % APY"),
onClick = {},
apy = "5.1",
isAllowedToSpend = false,
),
YieldSupplyUM.Content(
@ -322,6 +324,7 @@ private class PreviewProvider : PreviewParameterProvider<YieldSupplyUM> {
subtitle = stringReference("Interest accrues automatically"),
rewardsApy = stringReference("5.1 % APY"),
onClick = {},
apy = "5.1",
isAllowedToSpend = true,
),
YieldSupplyUM.Loading,

View file

@ -6,4 +6,5 @@ data class YieldSupplyPromoUM(
val tosLink: String,
val policyLink: String,
val title: TextReference,
val subtitle: TextReference,
)

View file

@ -33,7 +33,11 @@ internal class YieldSupplyPromoModel @Inject constructor(
val uiState: YieldSupplyPromoUM = YieldSupplyPromoUM(
tosLink = "https://tangem.com/terms-of-service/", // TODO replace with real link
policyLink = "https://tangem.com/privacy-policy/", // TODO replace with real link
title = resourceReference(R.string.yield_module_promo_screen_title, wrappedList("5.3")),
title = resourceReference(R.string.yield_module_promo_screen_title),
subtitle = resourceReference(
R.string.yield_module_promo_screen_variable_rate_info,
wrappedList(params.apy),
),
)
init {

View file

@ -73,7 +73,7 @@ internal fun YieldSupplyPromoContent(
SpacerH8()
Label(
state = LabelUM(
text = resourceReference(R.string.yield_module_promo_screen_variable_rate_info),
text = yieldSupplyPromoUM.subtitle,
style = LabelStyle.REGULAR,
icon = R.drawable.ic_information_24,
onIconClick = clickIntents::onApyInfoClick,
@ -223,7 +223,8 @@ private fun YieldSupplyPromoContent_Preview() {
yieldSupplyPromoUM = YieldSupplyPromoUM(
tosLink = "https://tangem.com/terms-of-service/",
policyLink = "https://tangem.com/privacy-policy/",
title = resourceReference(R.string.yield_module_promo_screen_title, wrappedList("5.3")),
title = resourceReference(R.string.yield_module_promo_screen_title),
subtitle = resourceReference(R.string.yield_module_promo_screen_variable_rate_info, wrappedList("5.3")),
),
clickIntents = object : YieldSupplyPromoClickIntents {
override fun onBackClick() {}