Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-21 20:02:42 +05:00
parent 1e6d95e494
commit f947c7d620
9 changed files with 40 additions and 4 deletions

View file

@ -1,6 +1,7 @@
package com.tangem.domain.swap
import com.tangem.domain.express.models.ExpressProvider
import com.tangem.domain.express.models.ExpressProviderType
import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.swap.models.SwapDataModel
@ -23,11 +24,13 @@ interface SwapRepositoryV2 {
* @param userWallet selected user wallet
* @param initialCurrency currency being swapped (either to or from)
* @param cryptoCurrencyStatusList list of currencies might be swapped
* @param filterProviderTypes filters only specified provider types, if empty returns providers as is
*/
suspend fun getPairs(
userWallet: UserWallet,
initialCurrency: CryptoCurrency,
cryptoCurrencyStatusList: List<CryptoCurrencyStatus>,
filterProviderTypes: List<ExpressProviderType>,
): List<SwapPairModel>
/** Express getPairs request variant without providers request */

View file

@ -1,6 +1,7 @@
package com.tangem.domain.swap.usecase
import arrow.core.Either
import com.tangem.domain.express.models.ExpressProviderType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.swap.SwapErrorResolver
import com.tangem.domain.swap.SwapRepositoryV2
@ -23,16 +24,19 @@ class GetSwapPairsUseCase(
* @param userWallet selected user wallet
* @param initialCurrency initial currency to swap (to or from)
* @param cryptoCurrencyStatusList list of added cryptocurrencies
* @param filterProviderTypes filters only specified provider types, if empty returns providers as is
*/
suspend operator fun invoke(
userWallet: UserWallet,
initialCurrency: CryptoCurrency,
cryptoCurrencyStatusList: List<CryptoCurrencyStatus>,
filterProviderTypes: List<ExpressProviderType>,
) = Either.catch {
val pairs = swapRepositoryV2.getPairs(
userWallet = userWallet,
initialCurrency = initialCurrency,
cryptoCurrencyStatusList = cryptoCurrencyStatusList,
filterProviderTypes = filterProviderTypes,
)
val fromGroup = pairs.groupPairs(