Updated on 2026-08-14
This commit is contained in:
commit
0cc3e8e4e4
13 changed files with 74 additions and 48 deletions
|
|
@ -19,7 +19,7 @@ class StakingApyFlowUseCase(private val stakingRepository: StakingRepository) {
|
|||
return stakingRepository.getEnabledYields()
|
||||
.map { yields ->
|
||||
yields.associate { yield ->
|
||||
val key = "${yield.token.network.name.lowercase()}_${yield.token.symbol}"
|
||||
val key = "${yield.token.coinGeckoId}_${yield.token.symbol}"
|
||||
val apy = calculateApy(yield)
|
||||
key to apy
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@ import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
|||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.swap.SwapErrorResolver
|
||||
import com.tangem.domain.swap.SwapRepositoryV2
|
||||
import com.tangem.domain.swap.models.SwapCryptoCurrency
|
||||
import com.tangem.domain.swap.models.SwapCurrencies
|
||||
import com.tangem.domain.swap.models.SwapCurrenciesGroup
|
||||
import com.tangem.domain.swap.models.SwapPairModel
|
||||
import com.tangem.domain.swap.models.SwapTxType
|
||||
import com.tangem.domain.swap.models.*
|
||||
|
||||
/**
|
||||
* Get list of swap pairs
|
||||
|
|
@ -67,13 +63,14 @@ class GetSwapPairsUseCase(
|
|||
groupingCurrency: (SwapPairModel) -> CryptoCurrencyStatus,
|
||||
cryptoCurrencyStatusList: List<CryptoCurrencyStatus>,
|
||||
): SwapCurrenciesGroup {
|
||||
val availableCryptoCurrencies = filter { pair -> filteringCurrency(pair).currency.id == initialCurrency.id }
|
||||
val availableCryptoCurrencies = filter { pair ->
|
||||
filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId
|
||||
}.filter { pair ->
|
||||
// Search available to swap currency
|
||||
.filter { pair ->
|
||||
cryptoCurrencyStatusList.any { currencyStatus ->
|
||||
currencyStatus.currency.id == pair.to.currency.id
|
||||
}
|
||||
}.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
|
||||
cryptoCurrencyStatusList.any { currencyStatus ->
|
||||
currencyStatus.currency.id == pair.to.currency.id
|
||||
}
|
||||
}.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
|
||||
|
||||
val unavailableCryptoCurrencies =
|
||||
cryptoCurrencyStatusList - availableCryptoCurrencies.map { it.currencyStatus }.toSet()
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@ import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
|||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.swap.SwapErrorResolver
|
||||
import com.tangem.domain.swap.SwapRepositoryV2
|
||||
import com.tangem.domain.swap.models.SwapCryptoCurrency
|
||||
import com.tangem.domain.swap.models.SwapCurrencies
|
||||
import com.tangem.domain.swap.models.SwapCurrenciesGroup
|
||||
import com.tangem.domain.swap.models.SwapPairModel
|
||||
import com.tangem.domain.swap.models.SwapTxType
|
||||
import com.tangem.domain.swap.models.*
|
||||
|
||||
/**
|
||||
* Returns pais
|
||||
|
|
@ -36,7 +32,7 @@ class GetSwapSupportedPairsUseCase(
|
|||
swapTxType = swapTxType,
|
||||
)
|
||||
|
||||
val filteredOutInitial = cryptoCurrencyList.filterNot { it.id == initialCurrency.id }
|
||||
val filteredOutInitial = cryptoCurrencyList.filterNot { it.id.rawNetworkId == initialCurrency.id.rawNetworkId }
|
||||
|
||||
val fromGroup = pairs.groupPairs(
|
||||
initialCurrency = initialCurrency,
|
||||
|
|
@ -63,15 +59,16 @@ class GetSwapSupportedPairsUseCase(
|
|||
groupingCurrency: (SwapPairModel) -> CryptoCurrencyStatus,
|
||||
cryptoCurrencyList: List<CryptoCurrency>,
|
||||
): SwapCurrenciesGroup {
|
||||
val availableCryptoCurrencies = filter { pair -> filteringCurrency(pair).currency.id == initialCurrency.id }
|
||||
val availableCryptoCurrencies = filter { pair ->
|
||||
filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId
|
||||
}.filter { pair ->
|
||||
// Search available to swap currency
|
||||
.filter { pair ->
|
||||
cryptoCurrencyList.any { currencyStatus ->
|
||||
// Allowed only on networks without tx extras (e.i. memo and destination tag)
|
||||
val isExtrasSupported = currencyStatus.network.transactionExtrasType.isTxExtrasSupported()
|
||||
currencyStatus.id == pair.to.currency.id && !isExtrasSupported
|
||||
}
|
||||
}.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
|
||||
cryptoCurrencyList.any { currencyStatus ->
|
||||
// Allowed only on networks without tx extras (e.i. memo and destination tag)
|
||||
val isExtrasSupported = currencyStatus.network.transactionExtrasType.isTxExtrasSupported()
|
||||
currencyStatus.id == pair.to.currency.id && !isExtrasSupported
|
||||
}
|
||||
}.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
|
||||
|
||||
val unavailableCryptoCurrencies =
|
||||
cryptoCurrencyList - availableCryptoCurrencies.map { it.currencyStatus.currency }.toSet()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue