Updated on 2026-08-14

This commit is contained in:
Tangem 2024-08-21 21:03:42 +05:00
parent c6fc1ab4da
commit cb203637f5
6 changed files with 81 additions and 38 deletions

View file

@ -100,6 +100,7 @@
<string name="common_enable">Aktivieren</string>
<string name="common_enabled">Aktiviert</string>
<string name="common_error">Fehler</string>
<string name="common_exchange">Umtausch</string>
<string name="common_explore">Erkunden</string>
<string name="common_explore_transaction_history">Transaktionsverlauf einsehen</string>
<string name="common_explorer">Explorer</string>
@ -878,6 +879,8 @@
<string name="warning_low_signatures_message">Auf dieser Karte sind nur noch %s Unterschriften übrig. Du musst dein gesamtes Guthaben abheben.</string>
<string name="warning_low_signatures_title">Geringe Anzahl von Unterschriften</string>
<string name="warning_manage_tokens_legacy_derivation_message">Token in verschiedenen Netzwerken können unterschiedliche Adressen haben. Überprüfe bei der Überweisung noch einmal, ob deine Adresse mit der des Netzwerks übereinstimmt.</string>
<string name="warning_matic_migration_message">MATIC wird auf POL migriert. Es gibt jedoch keine Frist, und MATIC wird noch nicht abgeschafft. Du kannst MATIC-Token weiterhin verwenden oder sie über eien Exchange gegen POL tauschen.</string>
<string name="warning_matic_migration_title">Migration von MATIC zu POL</string>
<plurals name="warning_missing_derivation_message">
<item quantity="one">Verwende deine Karte, um eine Adresse für das %d-Netz zu erhalten</item>
<item quantity="other">Verwende deine Karte, um mehrere Adressen für die %d-Netzwerke zu erhalten</item>

View file

@ -114,6 +114,10 @@
<string name="common_go_to_provider">Go to provider</string>
<string name="common_go_to_token">Go to token</string>
<string name="common_import">Import</string>
<plurals name="common_in_days">
<item quantity="one">in %d day</item>
<item quantity="other">in %d days</item>
</plurals>
<string name="common_later">Later</string>
<string name="common_locked">Locked</string>
<string name="common_main_network">Main network</string>
@ -656,12 +660,12 @@
<string name="staking_details_market_rating">Market rating</string>
<string name="staking_details_metrics_block_header">Metrics</string>
<string name="staking_details_minimum_requirement">Minimum Requirement</string>
<string name="staking_details_no_rewards_to_claim">No rewards to claim</string>
<string name="staking_details_no_rewards_to_claim">No rewards</string>
<string name="staking_details_reward_claiming">Reward claiming</string>
<string name="staking_details_reward_claiming_info">Method of receiving staking rewards.\nIt can be either automatic, where the reward is credited to your address, or manual, where you need to withdraw the reward by creating a transaction to receive it.</string>
<string name="staking_details_reward_schedule">Reward schedule</string>
<string name="staking_details_reward_schedule_info">This is a schedule that determines when participants in staking receive their rewards.</string>
<string name="staking_details_rewards_to_claim">Rewards to claim: %s</string>
<string name="staking_details_rewards_to_claim">Rewards: %s</string>
<string name="staking_details_title">Staking %s</string>
<string name="staking_details_unbonding_period">Unbonding Period</string>
<string name="staking_details_unbonding_period_info">The period you must wait after requesting to withdraw funds from staking before the tokens become available.</string>
@ -674,7 +678,8 @@
<string name="staking_notification_earn_rewards_text_period_month">Staking allows you to earn %1$s. Your staking rewards arrive every month.</string>
<string name="staking_notification_earn_rewards_text_period_week">Staking allows you to earn %1$s. Your staking rewards arrive every week.</string>
<string name="staking_notification_earn_rewards_title">Earn staking rewards</string>
<string name="staking_notification_unstake_text">Rewards stop accruing immediately after you unstake. The unstaking process takes %s.</string>
<string name="staking_notification_unstake_text">Rewards stop accruing immediately after you start unstaking. The unstaking process takes %s.</string>
<string name="staking_ready_to_withdraw">Ready to withdraw</string>
<string name="staking_rebond">Rebond</string>
<string name="staking_restake">Restake</string>
<string name="staking_restake_rewards">Restake rewards</string>
@ -695,6 +700,7 @@
<string name="staking_stake_more">Stake more</string>
<string name="staking_title_stake">Stake %s</string>
<string name="staking_title_unstake">Unstake %s</string>
<string name="staking_unbonding">Unbonding</string>
<string name="staking_unlocked_locked">Unlock locked</string>
<string name="staking_unstaked">Unstaked</string>
<string name="staking_unstaked_footer">Check unstaked to claim your assets</string>
@ -876,6 +882,8 @@
<string name="warning_low_signatures_message">Only %s signatures are left on this card. You must withdraw all of your funds.</string>
<string name="warning_low_signatures_title">Low signature count</string>
<string name="warning_manage_tokens_legacy_derivation_message">Tokens on different networks can have different addresses. Double-check that your address matches the network when you transfer funds.</string>
<string name="warning_matic_migration_message">MATIC is being migrated to POL. However there is no deadline set and MATIC isn\'t being deprecated yet. You can safely continue using MATIC token or use exchanges to swap it for POL.</string>
<string name="warning_matic_migration_title">MATIC to POL Migration</string>
<plurals name="warning_missing_derivation_message">
<item quantity="one">Use your card to get an address for %d network</item>
<item quantity="other">Use your card to get an addresses for %d networks</item>

View file

@ -26,6 +26,7 @@ internal class YieldBalanceConverter : Converter<YieldBalanceConverter.Data, Yie
rawCurrencyId = item.tokenDTO.coinGeckoId,
rawNetworkId = item.tokenDTO.network.name,
validatorAddress = item.validatorAddress,
date = item.date?.toDateTime(),
pendingActions = pendingActionConverter.convertList(item.pendingActions),
)
},

View file

@ -1,6 +1,7 @@
package com.tangem.domain.staking.model.stakekit
import com.tangem.domain.staking.model.stakekit.action.StakingActionType
import org.joda.time.DateTime
import java.math.BigDecimal
sealed class YieldBalance {
@ -38,6 +39,7 @@ data class BalanceItem(
val rawCurrencyId: String?,
val rawNetworkId: String,
val validatorAddress: String?,
val date: DateTime?,
val pendingActions: List<PendingAction>,
)

View file

@ -1,10 +1,7 @@
package com.tangem.features.staking.impl.presentation.state.converters
import com.tangem.common.extensions.isZero
import com.tangem.core.ui.extensions.pluralReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.extensions.*
import com.tangem.core.ui.utils.BigDecimalFormatter
import com.tangem.core.ui.utils.parseBigDecimal
import com.tangem.domain.appcurrency.model.AppCurrency
@ -18,6 +15,8 @@ import com.tangem.utils.Provider
import com.tangem.utils.converter.Converter
import com.tangem.utils.isNullOrZero
import kotlinx.collections.immutable.toPersistentList
import org.joda.time.DateTime
import java.util.Calendar
internal class YieldBalancesConverter(
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
@ -88,7 +87,7 @@ internal class YieldBalancesConverter(
}
val cryptoAmount = balance.amount
val fiatAmount = cryptoCurrencyStatus.value.fiatRate?.times(cryptoAmount)
val unbondingPeriod = yield.metadata.cooldownPeriod.days
val unbonding = getUnbondingDate(balance.date)
validator?.let {
BalanceState(
validator = validator,
@ -108,11 +107,7 @@ internal class YieldBalancesConverter(
),
),
rawCurrencyId = balance.rawCurrencyId,
unbondingPeriod = pluralReference(
id = R.plurals.common_days,
count = unbondingPeriod,
formatArgs = wrappedList(unbondingPeriod),
),
unbondingPeriod = unbonding,
pendingActions = balance.pendingActions.toPersistentList(),
)
}
@ -153,4 +148,32 @@ internal class YieldBalancesConverter(
BalanceType.UNKNOWN,
-> false
}
private fun getUnbondingDate(date: DateTime?): TextReference {
val now = DateTime.now().millis
val nowCalendar = Calendar.getInstance()
nowCalendar.resetHours()
val endDate = Calendar.getInstance()
endDate.timeInMillis = date?.millis ?: now
endDate.resetHours()
val days = ((endDate.timeInMillis - nowCalendar.timeInMillis) / DAY_IN_MILLIS).toInt()
return if (days > 0) {
pluralReference(R.plurals.common_in_days, days, wrappedList(days))
} else {
resourceReference(R.string.common_today)
}
}
private fun Calendar.resetHours() {
this[Calendar.HOUR_OF_DAY] = 0
this[Calendar.MINUTE] = 0
this[Calendar.SECOND] = 0
this[Calendar.MILLISECOND] = 0
}
private companion object {
const val DAY_IN_MILLIS = 24 * 60 * 60 * 1000
}
}

View file

@ -232,31 +232,37 @@ private fun ActiveStakingBlock(groups: ImmutableList<BalanceGroupedState>, onCli
@Composable
private fun getCaption(balanceType: BalanceType, balance: BalanceState): TextReference {
return if (balanceType == BalanceType.UNSTAKING) {
combinedReference(
resourceReference(R.string.staking_details_unbonding_period),
annotatedReference {
appendSpace()
appendColored(
text = balance.unbondingPeriod.resolveReference(),
color = TangemTheme.colors.text.accent,
)
},
)
} else {
combinedReference(
resourceReference(R.string.app_name),
annotatedReference {
appendSpace()
appendColored(
text = BigDecimalFormatter.formatPercent(
percent = balance.validator.apr.orZero(),
useAbsoluteValue = true,
),
color = TangemTheme.colors.text.accent,
)
},
)
return when (balanceType) {
BalanceType.UNSTAKING -> {
combinedReference(
resourceReference(R.string.staking_unbonding),
annotatedReference {
appendSpace()
appendColored(
text = balance.unbondingPeriod.resolveReference(),
color = TangemTheme.colors.text.accent,
)
},
)
}
BalanceType.UNSTAKED -> {
resourceReference(R.string.staking_ready_to_withdraw)
}
else -> {
combinedReference(
resourceReference(R.string.staking_details_apr),
annotatedReference {
appendSpace()
appendColored(
text = BigDecimalFormatter.formatPercent(
percent = balance.validator.apr.orZero(),
useAbsoluteValue = true,
),
color = TangemTheme.colors.text.accent,
)
},
)
}
}
}