Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-17 14:26:57 +05:00
parent cc037ed347
commit 56b509927c
8 changed files with 35 additions and 10 deletions

View file

@ -114,6 +114,7 @@ internal class DefaultRampManager(
userWalletId: UserWalletId,
cryptoCurrencyStatus: CryptoCurrencyStatus,
): ScenarioUnavailabilityReason {
val yieldSupplyStatus = cryptoCurrencyStatus.value.yieldSupplyStatus
return when {
cryptoCurrencyStatus.value.amount.isNullOrZero() -> {
ScenarioUnavailabilityReason.EmptyBalance(ScenarioUnavailabilityReason.WithdrawalScenario.SEND)
@ -127,6 +128,9 @@ internal class DefaultRampManager(
networkName = cryptoCurrencyStatus.currency.network.name,
)
}
yieldSupplyStatus?.isAllowedToSpend == false && yieldSupplyStatus.isActive -> {
ScenarioUnavailabilityReason.YieldSupplyApprovalRequired
}
else -> ScenarioUnavailabilityReason.None
}
}

View file

@ -68,6 +68,9 @@ fun ScenarioUnavailabilityReason.getUnavailabilityReasonText(): TextReference {
-> {
resourceReference(id = R.string.token_button_unavailability_reason_loading)
}
ScenarioUnavailabilityReason.YieldSupplyApprovalRequired -> resourceReference(
R.string.token_button_unavailability_reason_yield_supply_approval,
)
ScenarioUnavailabilityReason.None -> {
throw IllegalArgumentException("The unavailability reason must be other than None")
}

View file

@ -1305,10 +1305,19 @@
<string name="swapping_token_list_title">Choose token</string>
<string name="swapping_token_not_available">not available</string>
<string name="tangem_pay_deposit">Deposit</string>
<string name="tangem_pay_dispute">Dispute</string>
<string name="tangem_pay_explore_transaction">Explore transaction</string>
<string name="tangem_pay_fee_subtitle">Service fees</string>
<string name="tangem_pay_fee_title">Fee</string>
<string name="tangem_pay_status_completed">Completed</string>
<string name="tangem_pay_status_declined">Declined</string>
<string name="tangem_pay_status_pending">Pending</string>
<string name="tangem_pay_transaction_declined_notification_text">The bank rejected this transaction request.</string>
<string name="tangem_pay_transaction_fee_notification_text">This fee goes to cover the cost of handling your transfer.</string>
<string name="tangem_pay_withdrawal">Withdrawal</string>
<string name="tangempay_card_details_change_pin">Change PIN</string>
<string name="tangempay_card_details_error_text">Failed to load data. Try again later.</string>
<string name="tangempay_card_details_freeze_card">Freeze Card</string>
<string name="tangempay_card_details_hide_text">Hide</string>
<string name="tangempay_card_details_receive_error_description">Technical issues detected. Please try again later or contact support.</string>
<string name="tangempay_card_details_receive_error_title">Receive unavailable now</string>

View file

@ -56,6 +56,8 @@ sealed class ScenarioUnavailabilityReason {
data object TrustlineRequired : ScenarioUnavailabilityReason()
data object YieldSupplyApprovalRequired : ScenarioUnavailabilityReason()
enum class WithdrawalScenario {
SELL, SEND // TODO staking create&process STAKING
}

View file

@ -192,6 +192,7 @@ sealed class TokenScreenAnalyticsEvent(
is ScenarioUnavailabilityReason.NotExchangeable,
is ScenarioUnavailabilityReason.NotSupportedBySellService,
is ScenarioUnavailabilityReason.StakingUnavailable,
ScenarioUnavailabilityReason.YieldSupplyApprovalRequired,
-> UNAVAILABLE
ScenarioUnavailabilityReason.UnassociatedAsset -> ASSET_REQUIREMENT
ScenarioUnavailabilityReason.TrustlineRequired -> TRUSTLINE_REQUIREMENT

View file

@ -1,7 +1,6 @@
package com.tangem.domain.tokens.actions
import com.tangem.domain.exchange.RampStateManager
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
@ -69,7 +68,7 @@ internal class CommonActionsFactory(
async {
getSwapUnavailabilityReason(
userWalletId = userWallet.walletId,
currency = cryptoCurrencyStatus.currency,
currencyStatus = cryptoCurrencyStatus,
requirementsDeferred = requirementsDeferred,
)
}
@ -175,17 +174,21 @@ internal class CommonActionsFactory(
private suspend fun getSwapUnavailabilityReason(
userWalletId: UserWalletId,
currency: CryptoCurrency,
currencyStatus: CryptoCurrencyStatus,
requirementsDeferred: Deferred<AssetRequirementsCondition?>?,
): ScenarioUnavailabilityReason {
val swapUnavailabilityReason = rampStateManager
.availableForSwap(userWalletId = userWalletId, cryptoCurrency = currency)
.availableForSwap(userWalletId = userWalletId, cryptoCurrency = currencyStatus.currency)
val shouldCheckAssetRequirements =
swapUnavailabilityReason == ScenarioUnavailabilityReason.None && requirementsDeferred != null
return if (shouldCheckAssetRequirements) {
getReceiveScenario(requirementsDeferred.await())
} else {
swapUnavailabilityReason
val yieldSupplyStatus = currencyStatus.value.yieldSupplyStatus
val isUnavailableByYieldSupply = yieldSupplyStatus?.isAllowedToSpend == false && yieldSupplyStatus.isActive
return when {
isUnavailableByYieldSupply -> ScenarioUnavailabilityReason.YieldSupplyApprovalRequired
shouldCheckAssetRequirements -> getReceiveScenario(requirementsDeferred.await())
else -> swapUnavailabilityReason
}
}
}

View file

@ -402,7 +402,10 @@ internal class OnrampTokenListModel @Inject constructor(
cryptoCurrency = status.currency,
).isAvailable() && !status.currency.isCustom
isAvailable && status.value !is CryptoCurrencyStatus.NoQuote
val supplyStatus = status.value.yieldSupplyStatus
val isUnavailableByYieldSupply = supplyStatus?.isAllowedToSpend == false && supplyStatus.isActive
isAvailable && status.value !is CryptoCurrencyStatus.NoQuote && !isUnavailableByYieldSupply
}
}
}

View file

@ -19,8 +19,8 @@ import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.yield.supply.usecase.YieldSupplyGetProtocolBalanceUseCase
import com.tangem.domain.yield.supply.usecase.YieldSupplyGetTokenStatusUseCase
import com.tangem.domain.yield.supply.usecase.YieldSupplyMinAmountUseCase
import com.tangem.features.yield.supply.impl.R
import com.tangem.features.yield.supply.api.analytics.YieldSupplyAnalytics
import com.tangem.features.yield.supply.impl.R
import com.tangem.features.yield.supply.impl.common.formatter.YieldSupplyMinAmountFormatter
import com.tangem.features.yield.supply.impl.subcomponents.active.YieldSupplyActiveComponent
import com.tangem.features.yield.supply.impl.subcomponents.active.entity.YieldSupplyActiveContentUM