Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-10 13:24:16 +05:00
parent 76c129f205
commit a13a54accd
32 changed files with 665 additions and 35 deletions

View file

@ -19,6 +19,10 @@ dependencies {
/** Tangem SDKs */
implementation(tangemDeps.blockchain)
// region AndroidX libraries
implementation(deps.androidx.datastore)
// endregion
/** Core */
implementation(projects.core.datasource)
implementation(projects.core.utils)

View file

@ -12,6 +12,10 @@ import com.tangem.data.yield.supply.converters.YieldTokenChartConverter
import com.tangem.datasource.api.common.response.getOrThrow
import com.tangem.datasource.api.tangemTech.YieldSupplyApi
import com.tangem.datasource.api.tangemTech.models.YieldSupplyChangeTokenStatusBody
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.preferences.PreferencesKeys
import com.tangem.datasource.local.preferences.utils.get
import com.tangem.datasource.local.preferences.utils.store
import com.tangem.datasource.local.yieldsupply.YieldMarketsStore
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
@ -35,6 +39,7 @@ internal class DefaultYieldSupplyRepository(
private val walletManagersFacade: WalletManagersFacade,
private val dispatchers: CoroutineDispatcherProvider,
private val analyticsExceptionHandler: AnalyticsExceptionHandler,
private val appPreferencesStore: AppPreferencesStore,
) : YieldSupplyRepository {
private val statusMap: MutableMap<String, YieldSupplyEnterStatus> = ConcurrentHashMap()
@ -174,10 +179,18 @@ internal class DefaultYieldSupplyRepository(
null
}
private fun Set<TxInfo>.hasYieldEnterTransactions(yieldAddress: String) = any { txInfo ->
txInfo.type is TxInfo.TransactionType.YieldSupply.Enter ||
txInfo.type == TxInfo.TransactionType.Approve &&
(txInfo.interactionAddressType as? TxInfo.InteractionAddressType.Contract)?.address == yieldAddress
override fun getShouldShowYieldPromoBanner(): Flow<Boolean> {
return appPreferencesStore.get(PreferencesKeys.YIELD_SUPPLY_SHOULD_SHOW_MAIN_PROMO_KEY, true)
}
override suspend fun setShouldShowYieldPromoBanner(shouldShow: Boolean) {
appPreferencesStore.store(PreferencesKeys.YIELD_SUPPLY_SHOULD_SHOW_MAIN_PROMO_KEY, shouldShow)
}
private fun Set<TxInfo>.hasYieldEnterTransactions(yieldAddress: String) = any {
it.type == TxInfo.TransactionType.YieldSupply.Enter ||
it.type == TxInfo.TransactionType.Approve &&
(it.interactionAddressType as? TxInfo.InteractionAddressType.Contract)?.address == yieldAddress
}
private fun Set<TxInfo>.hasYieldExitTransactions() = any {

View file

@ -5,6 +5,7 @@ import com.tangem.data.yield.supply.DefaultYieldSupplyRepository
import com.tangem.data.yield.supply.DefaultYieldSupplyErrorResolver
import com.tangem.data.yield.supply.DefaultYieldSupplyTransactionRepository
import com.tangem.datasource.api.tangemTech.YieldSupplyApi
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.yieldsupply.YieldMarketsStore
import com.tangem.domain.walletmanager.WalletManagersFacade
import com.tangem.domain.yield.supply.YieldSupplyRepository
@ -41,6 +42,7 @@ internal object YieldSupplyDataModule {
walletManagersFacade: WalletManagersFacade,
dispatchers: CoroutineDispatcherProvider,
analyticsExceptionHandler: AnalyticsExceptionHandler,
appPreferencesStore: AppPreferencesStore,
): YieldSupplyRepository {
return DefaultYieldSupplyRepository(
yieldSupplyApi = yieldSupplyApi,
@ -48,6 +50,7 @@ internal object YieldSupplyDataModule {
dispatchers = dispatchers,
walletManagersFacade = walletManagersFacade,
analyticsExceptionHandler = analyticsExceptionHandler,
appPreferencesStore = appPreferencesStore,
)
}