diff --git a/domain/models/src/main/kotlin/com/tangem/domain/models/staking/YieldBalanceItem.kt b/domain/models/src/main/kotlin/com/tangem/domain/models/staking/YieldBalanceItem.kt index c8dbe3b3d9..198e8a00f7 100644 --- a/domain/models/src/main/kotlin/com/tangem/domain/models/staking/YieldBalanceItem.kt +++ b/domain/models/src/main/kotlin/com/tangem/domain/models/staking/YieldBalanceItem.kt @@ -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, diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/converters/YieldBalancesConverter.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/converters/YieldBalancesConverter.kt index 5e73aad950..7725be5eee 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/converters/YieldBalancesConverter.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/converters/YieldBalancesConverter.kt @@ -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() } diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt index 61c54c78ea..d0604549f9 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/ui/StakingInitialInfoContent.kt @@ -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 diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt index 81f0f9314e..ba6a44c2be 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStakingInfoConverter.kt @@ -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(