Updated on 2026-08-14
This commit is contained in:
parent
088d6f64bd
commit
4578bb824e
2 changed files with 18 additions and 9 deletions
|
|
@ -1841,6 +1841,7 @@
|
|||
<string name="token_details_balance_available">Available balance</string>
|
||||
<string name="token_details_balance_total">Total balance</string>
|
||||
<string name="token_details_earn_staking_subtitle">Up to %s APR</string>
|
||||
<string name="token_details_earn_staking_subtitle_apy">Up to %s APY</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>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import com.tangem.domain.models.staking.StakingBalance
|
|||
import com.tangem.domain.staking.model.StakingAvailability
|
||||
import com.tangem.domain.staking.model.StakingEntryInfo
|
||||
import com.tangem.domain.staking.model.StakingOption
|
||||
import com.tangem.domain.staking.model.common.RewardInfo
|
||||
import com.tangem.domain.staking.model.common.RewardType
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsUM
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
|
|
@ -124,7 +126,7 @@ internal class UpdateStakingNotificationTransformer(
|
|||
tone = EarnBlockUM.TitleUM.Tone.Primary,
|
||||
),
|
||||
subtitleUM = EarnBlockUM.SubtitleUM.Text(
|
||||
text = stakeAvailableSubtitle(availability.option.displayApy),
|
||||
text = stakeAvailableSubtitle(availability.option.displayRewardInfo),
|
||||
style = EarnBlockUM.SubtitleUM.Style.Small,
|
||||
tone = EarnBlockUM.SubtitleUM.Tone.Disabled,
|
||||
),
|
||||
|
|
@ -136,11 +138,17 @@ internal class UpdateStakingNotificationTransformer(
|
|||
)
|
||||
}
|
||||
|
||||
private fun stakeAvailableSubtitle(apy: BigDecimal?): TextReference {
|
||||
return if (apy != null) {
|
||||
private fun stakeAvailableSubtitle(rewardInfo: RewardInfo?): TextReference {
|
||||
return if (rewardInfo != null) {
|
||||
val resId = when (rewardInfo.type) {
|
||||
RewardType.APR -> CoreResR.string.token_details_earn_staking_subtitle
|
||||
RewardType.APY,
|
||||
RewardType.UNKNOWN,
|
||||
-> CoreResR.string.token_details_earn_staking_subtitle_apy
|
||||
}
|
||||
resourceReference(
|
||||
CoreResR.string.token_details_earn_staking_subtitle,
|
||||
wrappedList(apy.format { percent() }),
|
||||
resId,
|
||||
wrappedList(rewardInfo.rate.format { percent() }),
|
||||
)
|
||||
} else {
|
||||
resourceReference(CoreResR.string.staking_notification_earn_rewards_text)
|
||||
|
|
@ -273,10 +281,10 @@ private fun StakingBalance.Data?.getRewardAmount(): BigDecimal = when (this) {
|
|||
null -> BigDecimal.ZERO
|
||||
}
|
||||
|
||||
private val StakingOption.displayApy: BigDecimal?
|
||||
private val StakingOption.displayRewardInfo: RewardInfo?
|
||||
get() = when (this) {
|
||||
is StakingOption.StakeKit -> yield.preferredValidators
|
||||
.mapNotNull { it.rewardInfo?.rate }
|
||||
.maxOrNull()
|
||||
is StakingOption.P2PEthPool -> apy
|
||||
.mapNotNull { it.rewardInfo }
|
||||
.maxByOrNull { it.rate }
|
||||
is StakingOption.P2PEthPool -> RewardInfo(rate = apy, type = RewardType.APY)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue