Updated on 2026-08-14
This commit is contained in:
parent
e7a2a07ed8
commit
4407663b8b
7 changed files with 32 additions and 16 deletions
|
|
@ -1209,6 +1209,7 @@
|
|||
<string name="staking_reward_schedule_month">Monthly</string>
|
||||
<string name="staking_reward_schedule_week">Weekly</string>
|
||||
<string name="staking_rewards">Rewards</string>
|
||||
<string name="staking_soloana_details_auto_claiming_rewards_daily_text">Rewards on Solana are automatically added to your staking balance and cannot be shown separately.</string>
|
||||
<string name="staking_stake_locked">Stake locked</string>
|
||||
<string name="staking_stake_more">Stake more</string>
|
||||
<string name="staking_stake_more_button_unavailability_reason">When staking %1$s, your entire %2$s balance is staked. Any additional %2$s you deposit to your Tangem Wallet will also be automatically staked.</string>
|
||||
|
|
|
|||
|
|
@ -107,12 +107,14 @@ enum class BalanceType(val order: Int) {
|
|||
}
|
||||
|
||||
@Serializable
|
||||
enum class RewardBlockType {
|
||||
NoRewards,
|
||||
Rewards,
|
||||
RewardsRequirementsError,
|
||||
RewardUnavailable,
|
||||
;
|
||||
sealed interface RewardBlockType {
|
||||
data object NoRewards : RewardBlockType
|
||||
data object Rewards : RewardBlockType
|
||||
data object RewardsRequirementsError : RewardBlockType
|
||||
sealed interface RewardUnavailable : RewardBlockType {
|
||||
data object DefaultRewardUnavailable : RewardUnavailable
|
||||
data object SolanaRewardUnavailable : RewardUnavailable
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicated whether action can be performed on available reward
|
||||
|
|
@ -120,11 +122,11 @@ enum class RewardBlockType {
|
|||
*/
|
||||
val isActionable: Boolean
|
||||
get() = when (this) {
|
||||
NoRewards,
|
||||
RewardUnavailable,
|
||||
is NoRewards,
|
||||
is RewardUnavailable,
|
||||
-> false
|
||||
RewardsRequirementsError,
|
||||
Rewards,
|
||||
is RewardsRequirementsError,
|
||||
is Rewards,
|
||||
-> true
|
||||
}
|
||||
}
|
||||
|
|
@ -546,7 +546,7 @@ internal class StakingModel @Inject constructor(
|
|||
val rewardBlockType = yieldBalance?.reward?.rewardBlockType
|
||||
val rewardPendingActionConstraints = yieldBalance?.reward?.rewardConstraints
|
||||
|
||||
if (rewardBlockType == RewardBlockType.RewardsRequirementsError) {
|
||||
if (rewardBlockType is RewardBlockType.RewardsRequirementsError) {
|
||||
val minimumAmount = rewardPendingActionConstraints?.amountArg?.minimum
|
||||
// Temporary fix, until StakeKit adds minimum requirement amount to balance response
|
||||
val minimumAmountValue = if (minimumAmount == null && yieldBalance.integrationId != null) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.tangem.domain.staking.model.stakekit.Yield
|
|||
import com.tangem.domain.staking.utils.getRewardStakingBalance
|
||||
import com.tangem.features.staking.impl.presentation.state.InnerYieldBalanceState
|
||||
import com.tangem.features.staking.impl.presentation.state.YieldReward
|
||||
import com.tangem.lib.crypto.BlockchainUtils
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isStakingRewardUnavailable
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
|
@ -91,7 +92,13 @@ internal class YieldBalancesConverter(
|
|||
val isRewardsClaimable = rewards?.isNotEmpty() == true
|
||||
|
||||
return when {
|
||||
isStakingRewardUnavailable(blockchainId) -> RewardBlockType.RewardUnavailable
|
||||
isStakingRewardUnavailable(blockchainId) -> {
|
||||
if (BlockchainUtils.isSolana(blockchainId)) {
|
||||
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable
|
||||
} else {
|
||||
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
|
||||
}
|
||||
}
|
||||
isRewardsClaimable && isActionable -> RewardBlockType.Rewards
|
||||
isRewardsClaimable && !isActionable -> RewardBlockType.RewardsRequirementsError
|
||||
else -> RewardBlockType.NoRewards
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ internal object InitialStakingStatePreview {
|
|||
reward = YieldReward(
|
||||
rewardsFiat = "100 $",
|
||||
rewardsCrypto = "100 SOL",
|
||||
rewardBlockType = RewardBlockType.RewardUnavailable,
|
||||
rewardBlockType = RewardBlockType.RewardUnavailable.DefaultRewardUnavailable,
|
||||
rewardConstraints = null,
|
||||
),
|
||||
isActionable = true,
|
||||
|
|
|
|||
|
|
@ -233,10 +233,14 @@ private fun StakingRewardBlock(
|
|||
append(reward.rewardsCrypto.orMaskWithStars(isBalanceHidden))
|
||||
} to TangemTheme.colors.text.primary1
|
||||
}
|
||||
RewardBlockType.RewardUnavailable -> {
|
||||
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable -> {
|
||||
resourceReference(R.string.staking_details_auto_claiming_rewards_daily_text) to
|
||||
TangemTheme.colors.text.tertiary
|
||||
}
|
||||
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable -> {
|
||||
resourceReference(R.string.staking_soloana_details_auto_claiming_rewards_daily_text) to
|
||||
TangemTheme.colors.text.tertiary
|
||||
}
|
||||
RewardBlockType.NoRewards -> {
|
||||
resourceReference(R.string.staking_details_no_rewards_to_claim) to TangemTheme.colors.text.tertiary
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,14 +156,16 @@ internal class TokenDetailsStakingInfoConverter(
|
|||
private fun getRewardText(status: CryptoCurrencyStatus, stakingRewardAmount: BigDecimal?): TextReference {
|
||||
val blockchainId = status.currency.network.rawId
|
||||
val rewardBlockType = when {
|
||||
isStakingRewardUnavailable(blockchainId) -> RewardBlockType.RewardUnavailable
|
||||
isStakingRewardUnavailable(blockchainId) -> RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
|
||||
stakingRewardAmount.isNullOrZero() -> RewardBlockType.NoRewards
|
||||
else -> RewardBlockType.Rewards
|
||||
}
|
||||
|
||||
return when (rewardBlockType) {
|
||||
RewardBlockType.NoRewards -> resourceReference(R.string.staking_details_no_rewards_to_claim)
|
||||
RewardBlockType.RewardUnavailable -> TextReference.EMPTY
|
||||
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable,
|
||||
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable,
|
||||
-> TextReference.EMPTY
|
||||
RewardBlockType.RewardsRequirementsError,
|
||||
RewardBlockType.Rewards,
|
||||
-> resourceReference(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue