From f170659a35acc9321df32ac62a8ff9cfe703560f Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 22 Feb 2023 14:48:16 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../feature/swap/domain/SwapInteractorImpl.kt | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt index e759fd412c..5d5e32dc6e 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt @@ -52,7 +52,7 @@ internal class SwapInteractorImpl @Inject constructor( // replace tokens in wallet tokens list with loaded same val loadedOnWalletsMap = mutableSetOf() - val tokensInWallet = userWalletManager.getUserTokens(networkId, false) + val tokensInWallet = userWalletManager.getUserTokens(networkId, true) .filter { it.symbol != initialCurrency.symbol } .map { token -> allLoadedTokens.firstOrNull { it.symbol == token.symbol }?.let { @@ -288,8 +288,9 @@ internal class SwapInteractorImpl @Inject constructor( amountFormatter.formatSwapAmountToUI(amount, it.symbol) }, amountEquivalent = balance?.value?.toFiatString( - rates[it.id]?.toBigDecimal() ?: BigDecimal.ZERO, - appCurrency.symbol, + rateValue = rates[it.id]?.toBigDecimal() ?: BigDecimal.ZERO, + fiatCurrencyName = appCurrency.symbol, + formatWithSpaces = true, ), ), ) @@ -334,7 +335,11 @@ internal class SwapInteractorImpl @Inject constructor( return SwapState.EmptyAmountState( fromTokenWalletBalance = fromTokenBalance?.let { amountFormatter.formatSwapAmountToUI(it, "") }.orEmpty(), toTokenWalletBalance = toTokenBalance?.let { amountFormatter.formatSwapAmountToUI(it, "") }.orEmpty(), - zeroAmountEquivalent = BigDecimal.ZERO.toFiatString(BigDecimal.ONE, appCurrency.symbol), + zeroAmountEquivalent = BigDecimal.ZERO.toFiatString( + rateValue = BigDecimal.ONE, + fiatCurrencyName = appCurrency.symbol, + formatWithSpaces = true, + ), ) } @@ -405,7 +410,7 @@ internal class SwapInteractorImpl @Inject constructor( val nativeToken = userWalletManager.getNativeTokenForNetwork(networkId) val rates = repository.getRates(appCurrency.code, listOf(fromTokenId, toTokenId, nativeToken.id)) return rates[nativeToken.id]?.toBigDecimal()?.let { rate -> - " (${fee.toFiatString(rate, appCurrency.symbol)})" + " (${fee.toFiatString(rate, appCurrency.symbol, true)})" }.orEmpty() } @@ -485,8 +490,9 @@ internal class SwapInteractorImpl @Inject constructor( tokenWalletBalance = fromTokenBalance?.let { amountFormatter.formatSwapAmountToUI(it, "") } ?: ZERO_BALANCE, tokenFiatBalance = fromTokenAmount.value.toFiatString( - rates[fromToken.id]?.toBigDecimal() ?: BigDecimal.ZERO, - appCurrency.symbol, + rateValue = rates[fromToken.id]?.toBigDecimal() ?: BigDecimal.ZERO, + fiatCurrencyName = appCurrency.symbol, + formatWithSpaces = true, ), ), toTokenInfo = TokenSwapInfo( @@ -495,8 +501,9 @@ internal class SwapInteractorImpl @Inject constructor( tokenWalletBalance = toTokenBalance?.let { amountFormatter.formatSwapAmountToUI(it, "") } ?: ZERO_BALANCE, tokenFiatBalance = toTokenAmount.value.toFiatString( - rates[toToken.id]?.toBigDecimal() ?: BigDecimal.ZERO, - appCurrency.symbol, + rateValue = rates[toToken.id]?.toBigDecimal() ?: BigDecimal.ZERO, + fiatCurrencyName = appCurrency.symbol, + formatWithSpaces = true, ), ), fee = formattedFee,