Updated on 2026-08-14

This commit is contained in:
Tangem 2026-01-16 12:59:42 +02:00
parent 6311ce2e3c
commit 6dc6e28205
4 changed files with 41 additions and 0 deletions

View file

@ -111,6 +111,8 @@ sealed interface RewardBlockType {
data object NoRewards : RewardBlockType
data object Rewards : RewardBlockType
data object RewardsRequirementsError : RewardBlockType
data object EthereumEarnedRewards : RewardBlockType
sealed interface RewardUnavailable : RewardBlockType {
data object DefaultRewardUnavailable : RewardUnavailable
data object SolanaRewardUnavailable : RewardUnavailable
@ -124,6 +126,7 @@ sealed interface RewardBlockType {
get() = when (this) {
is NoRewards,
is RewardUnavailable,
is EthereumEarnedRewards,
-> false
is RewardsRequirementsError,
is Rewards,

View file

@ -83,6 +83,16 @@ internal class YieldBalancesConverter(
val blockchainId = cryptoCurrencyStatus.currency.network.rawId
val isCoin = cryptoCurrencyStatus.currency.id.isCoin
val p2pEthPoolBalance = stakingBalance as? StakingBalance.Data.P2PEthPool
if (p2pEthPoolBalance != null) {
val hasEarnedRewards = !p2pEthPoolBalance.totalRewards.isZero()
return if (hasEarnedRewards) {
RewardBlockType.EthereumEarnedRewards
} else {
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
}
}
val stakeKitBalance = stakingBalance as? StakingBalance.Data.StakeKit
val rewards = stakeKitBalance?.balance?.items
?.filter { it.type == BalanceType.REWARDS && !it.amount.isZero() }

View file

@ -243,6 +243,12 @@ private fun StakingRewardBlock(
append(reward.rewardsCrypto.orMaskWithStars(isBalanceHidden))
} to TangemTheme.colors.text.primary1
}
RewardBlockType.EthereumEarnedRewards -> {
resourceReference(
id = R.string.staking_details_autocompound_rewards_earned,
formatArgs = wrappedList(reward.rewardsCrypto.orMaskWithStars(isBalanceHidden)),
) to TangemTheme.colors.text.primary1
}
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable -> {
resourceReference(R.string.staking_details_auto_claiming_rewards_daily_text) to
TangemTheme.colors.text.tertiary

View file

@ -175,8 +175,16 @@ internal class TokenDetailsStakingInfoConverter(
private fun getRewardText(status: CryptoCurrencyStatus, stakingRewardAmount: BigDecimal?): TextReference {
val blockchainId = status.currency.network.rawId
val isCoin = status.currency.id.isCoin
val stakingBalance = status.value.stakingBalance
val rewardBlockType = when {
stakingBalance is StakingBalance.Data.P2PEthPool -> {
if (stakingBalance.totalRewards.isNullOrZero()) {
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
} else {
RewardBlockType.EthereumEarnedRewards
}
}
isStakingRewardUnavailable(blockchainId, isCoin) -> {
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
}
@ -189,6 +197,20 @@ internal class TokenDetailsStakingInfoConverter(
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable,
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable,
-> TextReference.EMPTY
RewardBlockType.EthereumEarnedRewards -> {
val cryptoRewardAmount = (stakingBalance as? StakingBalance.Data.P2PEthPool)?.totalRewards
resourceReference(
R.string.staking_details_autocompound_rewards_earned,
wrappedList(
cryptoRewardAmount.format {
crypto(
symbol = status.currency.symbol,
decimals = status.currency.decimals,
)
},
),
)
}
RewardBlockType.RewardsRequirementsError,
RewardBlockType.Rewards,
-> resourceReference(