Updated on 2026-08-14

This commit is contained in:
Tangem 2026-03-17 22:16:55 +07:00
parent bbf13f1ae8
commit b37737ce8c
25 changed files with 102 additions and 45 deletions

View file

@ -41,7 +41,8 @@ interface TangemExpressApi {
@Query("fromNetwork") fromNetwork: String,
@Query("toContractAddress") toContractAddress: String,
@Query("toNetwork") toNetwork: String,
@Query("fromAmount") fromAmount: String,
@Query("fromAmount") fromAmount: String?,
@Query("toAmount") toAmount: String? = null,
@Query("fromDecimals") fromDecimals: Int,
@Query("toDecimals") toDecimals: Int,
@Query("providerId") providerId: String,
@ -57,7 +58,8 @@ interface TangemExpressApi {
@Query("toContractAddress") toContractAddress: String,
@Query("fromAddress") fromAddress: String,
@Query("toNetwork") toNetwork: String,
@Query("fromAmount") fromAmount: String,
@Query("fromAmount") fromAmount: String?,
@Query("toAmount") toAmount: String? = null,
@Query("fromDecimals") fromDecimals: Int,
@Query("toDecimals") toDecimals: Int,
@Query("providerId") providerId: String,

View file

@ -32,6 +32,7 @@ import com.tangem.domain.quotes.single.SingleQuoteStatusProducer
import com.tangem.domain.quotes.single.SingleQuoteStatusSupplier
import com.tangem.domain.swap.SwapRepositoryV2
import com.tangem.domain.swap.models.*
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.tokens.operations.CryptoCurrencyStatusFactory
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.CoroutineScope
@ -177,12 +178,26 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
userWallet: UserWallet,
fromCryptoCurrency: CryptoCurrency,
toCryptoCurrency: CryptoCurrency,
fromAmount: BigDecimal,
amount: BigDecimal,
amountType: SwapAmountType,
provider: ExpressProvider,
rateType: ExpressRateType,
): SwapQuoteModel = withContext(coroutineDispatcher.io) {
val response = tangemExpressApi.getExchangeQuote(
fromAmount = fromAmount.movePointRight(fromCryptoCurrency.decimals).toString(),
fromAmount = if (amountType == SwapAmountType.From) {
amount.movePointRight(
fromCryptoCurrency.decimals,
).toString()
} else {
null
},
toAmount = if (amountType == SwapAmountType.To) {
amount.movePointRight(
toCryptoCurrency.decimals,
).toString()
} else {
null
},
fromNetwork = fromCryptoCurrency.network.backendId,
fromContractAddress = fromCryptoCurrency.getContractAddress(),
fromDecimals = fromCryptoCurrency.decimals,
@ -199,10 +214,12 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
).getOrThrow()
val toTokenAmount = requireNotNull(response.toAmount.toBigDecimalOrNull()?.movePointLeft(response.toDecimals))
val fromTokenAmount = response.fromAmount.toBigDecimalOrNull()?.movePointLeft(response.fromDecimals)
return@withContext SwapQuoteModel(
provider = provider,
toTokenAmount = toTokenAmount,
fromTokenAmount = fromTokenAmount,
allowanceContract = response.allowanceContract,
)
}
@ -211,7 +228,8 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
userWallet: UserWallet,
fromCryptoCurrencyStatus: CryptoCurrencyStatus,
toCryptoCurrency: CryptoCurrency,
fromAmount: String,
amount: String,
amountType: SwapAmountType,
toAddress: String,
toExtraId: String?,
expressProvider: ExpressProvider,
@ -241,7 +259,8 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
toAddress = toAddress,
fromDecimals = fromCurrency.decimals,
toDecimals = toCryptoCurrency.decimals,
fromAmount = fromAmount,
fromAmount = if (amountType == SwapAmountType.From) amount else null,
toAmount = if (amountType == SwapAmountType.To) amount else null,
providerId = expressProvider.providerId,
rateType = rateType.name.lowercase(),
requestId = requestId,

View file

@ -0,0 +1,6 @@
package com.tangem.domain.swap.models
enum class SwapAmountType {
From,
To,
}

View file

@ -8,10 +8,12 @@ import java.math.BigDecimal
*
* @property provider swap provider
* @property toTokenAmount amount of token you want to receive
* @property fromTokenAmount amount of from-token required (for fixed rate quotes)
* @property allowanceContract whether swap occurs via third token
*/
data class SwapQuoteModel(
val provider: ExpressProvider,
val toTokenAmount: BigDecimal,
val fromTokenAmount: BigDecimal?,
val allowanceContract: String?,
)

View file

@ -0,0 +1,7 @@
package com.tangem.domain.swap.models
enum class SwapRateMode {
FLOAT_ONLY,
FIXED_ONLY,
FLOAT_AND_FIXED,
}

View file

@ -52,7 +52,8 @@ interface SwapRepositoryV2 {
* @param userWallet selected user wallet
* @param fromCryptoCurrency currency being swapped from
* @param toCryptoCurrency currency being swapped to
* @param fromAmount swap amount
* @param amount swap amount
* @param amountType specifies whether amount is fromAmount or toAmount
* @param provider selected express provider
* @param rateType rate type
*/
@ -60,7 +61,8 @@ interface SwapRepositoryV2 {
userWallet: UserWallet,
fromCryptoCurrency: CryptoCurrency,
toCryptoCurrency: CryptoCurrency,
fromAmount: BigDecimal,
amount: BigDecimal,
amountType: SwapAmountType,
provider: ExpressProvider,
rateType: ExpressRateType,
): SwapQuoteModel
@ -71,7 +73,8 @@ interface SwapRepositoryV2 {
* @param userWallet selected user wallet
* @param fromCryptoCurrencyStatus currency status being swapped from
* @param toCryptoCurrency currency being swapped to
* @param fromAmount swap amount
* @param amount swap amount
* @param amountType specifies whether amount is fromAmount or toAmount
* @param toAddress destination address
* @param expressProvider selected swap provider
* @param rateType selected provider rate type
@ -81,7 +84,8 @@ interface SwapRepositoryV2 {
userWallet: UserWallet,
fromCryptoCurrencyStatus: CryptoCurrencyStatus,
toCryptoCurrency: CryptoCurrency,
fromAmount: String,
amount: String,
amountType: SwapAmountType,
toAddress: String,
toExtraId: String?,
expressProvider: ExpressProvider,

View file

@ -10,6 +10,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.SwapAmountType
import com.tangem.domain.swap.models.SwapDataModel
@Suppress("LongParameterList")
@ -21,7 +22,8 @@ class GetSwapDataUseCase(
suspend operator fun invoke(
userWallet: UserWallet,
fromCryptoCurrencyStatus: CryptoCurrencyStatus,
fromAmount: String,
amount: String,
amountType: SwapAmountType,
toCryptoCurrency: CryptoCurrency,
toAddress: String,
toExtraId: String?,
@ -32,7 +34,8 @@ class GetSwapDataUseCase(
swapRepositoryV2.getSwapData(
userWallet = userWallet,
fromCryptoCurrencyStatus = fromCryptoCurrencyStatus,
fromAmount = fromAmount,
amount = amount,
amountType = amountType,
toCryptoCurrency = toCryptoCurrency,
toAddress = toAddress,
toExtraId = toExtraId,

View file

@ -7,6 +7,7 @@ import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.swap.SwapErrorResolver
import com.tangem.domain.swap.SwapRepositoryV2
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapQuoteModel
import com.tangem.domain.models.wallet.UserWallet
import java.math.BigDecimal
@ -14,6 +15,7 @@ import java.math.BigDecimal
/**
* Get swap quote for selected pair
*/
@Suppress("LongParameterList")
class GetSwapQuoteUseCase(
private val swapRepositoryV2: SwapRepositoryV2,
private val swapErrorResolver: SwapErrorResolver,
@ -23,23 +25,28 @@ class GetSwapQuoteUseCase(
* @param userWallet selected user wallet
* @param fromCryptoCurrency currency swap from
* @param toCryptoCurrency currency swap to
* @param fromAmount swap amount
* @param amount swap amount
* @param rateType rate type for the quote. Float API does not support [SwapAmountType.To].
* @param provider swap provider
*/
suspend operator fun invoke(
userWallet: UserWallet,
fromCryptoCurrency: CryptoCurrency,
toCryptoCurrency: CryptoCurrency,
fromAmount: BigDecimal,
amount: BigDecimal,
amountType: SwapAmountType,
rateType: ExpressRateType,
provider: ExpressProvider,
): Either<ExpressError, SwapQuoteModel> = Either.catch {
swapRepositoryV2.getSwapQuote(
userWallet = userWallet,
fromCryptoCurrency = fromCryptoCurrency,
toCryptoCurrency = toCryptoCurrency,
fromAmount = fromAmount,
amount = amount,
amountType = amountType,
provider = provider,
rateType = ExpressRateType.Float, // todo rate type
rateType = rateType,
)
}.mapLeft(swapErrorResolver::resolve)
}

View file

@ -1,9 +1,9 @@
package com.tangem.domain.swap.usecase
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.swap.SwapTransactionRepository
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.SwapDirection
@ -30,22 +30,22 @@ class SelectInitialPairUseCase(
secondaryCryptoCurrency: CryptoCurrency?,
swapCurrencies: SwapCurrencies,
swapDirection: SwapDirection,
): CryptoCurrencyStatus? {
): SwapCryptoCurrency? {
val swapCurrenciesGroup = swapCurrencies.getGroupWithDirection(swapDirection)
return tryToGetAlreadySelectedCurrency(secondaryCryptoCurrency, swapCurrenciesGroup)
?: tryGetFromCache(userWallet, primaryCryptoCurrency, swapCurrenciesGroup)
?: tryGetWithMaxAmount(swapCurrenciesGroup)
?: swapCurrenciesGroup.available.firstOrNull()?.currencyStatus
?: swapCurrenciesGroup.available.firstOrNull()
}
private fun tryToGetAlreadySelectedCurrency(
secondaryCryptoCurrency: CryptoCurrency?,
swapCurrenciesGroup: SwapCurrenciesGroup,
): CryptoCurrencyStatus? {
): SwapCryptoCurrency? {
return secondaryCryptoCurrency?.let {
swapCurrenciesGroup.available.firstOrNull { currency ->
secondaryCryptoCurrency.id == currency.currencyStatus.currency.id
}?.currencyStatus
}
}
}
@ -53,19 +53,19 @@ class SelectInitialPairUseCase(
userWallet: UserWallet,
primaryCryptoCurrency: CryptoCurrency,
swapCurrenciesGroup: SwapCurrenciesGroup,
): CryptoCurrencyStatus? {
): SwapCryptoCurrency? {
val id = swapTransactionRepository.getLastSwappedCryptoCurrencyId(userWallet.walletId) ?: return null
return if (id != primaryCryptoCurrency.id.value) {
swapCurrenciesGroup.available.find { it.currencyStatus.currency.id.value == id }?.currencyStatus
swapCurrenciesGroup.available.find { it.currencyStatus.currency.id.value == id }
} else {
null
}
}
private fun tryGetWithMaxAmount(swapCurrenciesGroup: SwapCurrenciesGroup): CryptoCurrencyStatus? {
private fun tryGetWithMaxAmount(swapCurrenciesGroup: SwapCurrenciesGroup): SwapCryptoCurrency? {
return swapCurrenciesGroup.available.maxByOrNull {
it.currencyStatus.value.fiatAmount.orZero()
}?.currencyStatus
}
}
}

View file

@ -7,6 +7,7 @@ import com.tangem.core.ui.extensions.TextReference
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapCurrencies
import com.tangem.domain.swap.models.SwapDirection
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM
@ -92,9 +93,4 @@ sealed class PriceImpactUM {
data object Empty : PriceImpactUM()
data class Value(val value: Float) : PriceImpactUM()
}
enum class SwapAmountType {
From,
To,
}

View file

@ -1,7 +1,7 @@
package com.tangem.features.swap.v2.impl.amount.model
import com.tangem.common.ui.amountScreen.AmountScreenClickIntents
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.domain.swap.models.SwapAmountType
internal interface SwapAmountClickIntents : AmountScreenClickIntents {

View file

@ -20,6 +20,7 @@ import com.tangem.datasource.local.swap.SwapBestRateAnimationStore
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.express.models.ExpressError
import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.notifications.ShouldShowNotificationUseCase
@ -43,7 +44,6 @@ import com.tangem.features.swap.v2.impl.amount.SwapAmountReduceListener
import com.tangem.features.swap.v2.impl.amount.SwapAmountUpdateListener
import com.tangem.features.swap.v2.impl.amount.analytics.SwapAmountAnalyticEvents
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.amount.model.converter.SwapQuoteUMConverter
import com.tangem.features.swap.v2.impl.amount.model.transformers.*
@ -525,7 +525,7 @@ internal class SwapAmountModel @Inject constructor(
private fun initPairs(swapCurrencies: SwapCurrencies, secondaryCryptoCurrency: CryptoCurrency?) {
modelScope.launch {
val secondaryStatus = selectInitialPairUseCase(
val swapCryptoCurrency = selectInitialPairUseCase(
primaryCryptoCurrency = primaryCryptoCurrency,
secondaryCryptoCurrency = secondaryCryptoCurrency,
userWallet = userWallet,
@ -533,6 +533,8 @@ internal class SwapAmountModel @Inject constructor(
swapDirection = params.swapDirection,
)
val secondaryStatus = swapCryptoCurrency?.currencyStatus
val primaryStatus = (uiState.value as? SwapAmountUM.Content)?.primaryCryptoCurrencyStatus
if (secondaryStatus != null && primaryStatus != null) {
initCurrencies(primaryStatus, secondaryStatus)
@ -594,6 +596,7 @@ internal class SwapAmountModel @Inject constructor(
}
}
@Suppress("LongMethod")
private fun loadQuotes(isSilentReload: Boolean) {
val state = uiState.value as? SwapAmountUM.Content ?: return
if (state.secondaryCryptoCurrencyStatus == null) return
@ -629,7 +632,9 @@ internal class SwapAmountModel @Inject constructor(
userWallet = userWallet,
fromCryptoCurrency = fromCryptoCurrency,
toCryptoCurrency = toCryptoCurrency,
fromAmount = fromAmountValue,
amount = fromAmountValue,
amountType = SwapAmountType.From,
rateType = ExpressRateType.Float,
provider = provider,
).fold(
ifLeft = { error ->

View file

@ -5,9 +5,9 @@ import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.format.bigdecimal.percent
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapDirection
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.utils.extensions.isZero
import com.tangem.utils.isNullOrZero

View file

@ -15,10 +15,10 @@ import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapDirection
import com.tangem.features.swap.v2.impl.R
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.utils.StringsSigns.DOT
@Suppress("LongParameterList")

View file

@ -5,9 +5,9 @@ import com.tangem.common.ui.amountScreen.models.AmountState
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapDirection
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.amount.model.converter.SwapAmountFieldConverter
import com.tangem.utils.transformer.Transformer

View file

@ -6,10 +6,10 @@ import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapCurrencies
import com.tangem.domain.swap.models.SwapDirection
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.amount.model.converter.SwapAmountFieldConverter
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM

View file

@ -6,9 +6,9 @@ import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapCurrencies
import com.tangem.domain.swap.models.SwapDirection
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.amount.model.converter.SwapAmountFieldConverter
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM

View file

@ -5,8 +5,8 @@ import com.tangem.common.ui.amountScreen.models.AmountState
import com.tangem.common.ui.amountScreen.models.EnterAmountBoundary
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.utils.parseBigDecimal
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.amount.model.SwapAmountQuoteUtils.calculatePriceImpact
import com.tangem.features.swap.v2.impl.amount.model.converter.SwapAmountErrorConverter

View file

@ -37,9 +37,9 @@ import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.features.swap.v2.impl.R
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.amount.ui.preview.SwapAmountContentPreview
import com.tangem.features.swap.v2.impl.chooseprovider.ui.SwapChooseProviderContent

View file

@ -39,9 +39,9 @@ import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.features.swap.v2.impl.R
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.amount.model.SwapAmountClickIntents
import com.tangem.features.swap.v2.impl.amount.ui.preview.SwapAmountClickIntentsStub

View file

@ -1,6 +1,6 @@
package com.tangem.features.swap.v2.impl.amount.ui.preview
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.model.SwapAmountClickIntents
internal object SwapAmountClickIntentsStub : SwapAmountClickIntents {

View file

@ -12,10 +12,10 @@ import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.network.Network
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapCurrencies
import com.tangem.domain.swap.models.SwapDirection
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM
import com.tangem.utils.StringsSigns

View file

@ -4,6 +4,7 @@ import com.tangem.blockchain.common.transaction.Fee
import com.tangem.domain.express.models.ExpressRateType
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.transaction.error.GetFeeError
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM
import java.math.BigDecimal
@ -21,4 +22,5 @@ internal data class ConfirmData(
val fromAccount: Account?,
val quote: SwapQuoteUM?,
val rateType: ExpressRateType?,
val amountType: SwapAmountType,
)

View file

@ -29,6 +29,7 @@ import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.isHotWallet
import com.tangem.domain.settings.IsSendTapHelpEnabledUseCase
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapDirection.Companion.withSwapDirection
import com.tangem.domain.tokens.IsAmountSubtractAvailableUseCase
import com.tangem.domain.transaction.error.GetFeeError
@ -158,6 +159,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
fromAccount = params.accountFlow.value,
quote = amountUM?.selectedQuote,
rateType = amountUM?.swapRateType,
amountType = amountUM?.selectedAmountType ?: SwapAmountType.From,
)
}

View file

@ -11,6 +11,7 @@ import com.tangem.domain.express.models.ExpressProviderType
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapDataModel
import com.tangem.domain.swap.models.SwapDataTransactionModel
import com.tangem.domain.swap.models.SwapTxType
@ -101,7 +102,8 @@ internal class SwapTransactionSender @AssistedInject constructor(
val swapData = getSwapDataUseCase(
userWallet = userWallet,
fromCryptoCurrencyStatus = fromStatus,
fromAmount = fromAmount.toStringWithRightOffset(fromStatus.currency.decimals),
amount = fromAmount.toStringWithRightOffset(fromStatus.currency.decimals),
amountType = SwapAmountType.From,
toCryptoCurrency = toStatus.currency,
toAddress = destination,
toExtraId = confirmData.enteredMemo,