Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-15 19:45:24 +05:00
parent c551b2dea9
commit 938c8e72cb
6 changed files with 34 additions and 8 deletions

View file

@ -272,7 +272,7 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
override suspend fun swapTransactionSent(
userWallet: UserWallet,
fromCryptoCurrencyStatus: CryptoCurrencyStatus,
toAddress: String,
payInAddress: String,
txId: String,
txHash: String,
txExtraId: String?,
@ -288,7 +288,7 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
txId = txId,
fromNetwork = fromCryptoCurrencyStatus.currency.network.backendId,
fromAddress = fromCryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value.orEmpty(),
payinAddress = toAddress,
payinAddress = payInAddress,
payinExtraId = txExtraId,
txHash = txHash,
),

View file

@ -93,7 +93,7 @@ interface SwapRepositoryV2 {
*
* @param userWallet selected user wallet
* @param fromCryptoCurrencyStatus currency status being swapped from
* @param toAddress swap destination address
* @param payInAddress swap destination address
* @param txId transaction id in ExpressApi
* @param txHash transaction hash in blockchain
* @param txExtraId extra transaction id in ExpressApi
@ -101,7 +101,7 @@ interface SwapRepositoryV2 {
suspend fun swapTransactionSent(
userWallet: UserWallet,
fromCryptoCurrencyStatus: CryptoCurrencyStatus,
toAddress: String,
payInAddress: String,
txId: String,
txHash: String,
txExtraId: String?,

View file

@ -32,7 +32,10 @@ class GetSwapSupportedPairsUseCase(
swapTxType = swapTxType,
)
val filteredOutInitial = cryptoCurrencyList.filterNot { it.id.rawNetworkId == initialCurrency.id.rawNetworkId }
val filteredOutInitial = cryptoCurrencyList.filterNot { currency ->
currency.id.rawNetworkId == initialCurrency.id.rawNetworkId &&
currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId
}
val fromGroup = pairs.groupPairs(
initialCurrency = initialCurrency,

View file

@ -27,6 +27,7 @@ class SwapTransactionSentUseCase(
swapDataTransactionModel: SwapDataTransactionModel,
provider: ExpressProvider,
txHash: String,
payInAddress: String,
timestamp: Long,
swapTxType: SwapTxType,
) = Either.catch {
@ -63,7 +64,7 @@ class SwapTransactionSentUseCase(
swapRepositoryV2.swapTransactionSent(
userWallet = userWallet,
fromCryptoCurrencyStatus = fromCryptoCurrencyStatus,
toAddress = swapDataTransactionModel.txTo,
payInAddress = payInAddress,
txId = swapDataTransactionModel.txId,
txHash = txHash,
txExtraId = swapDataTransactionModel.txExtraId,

View file

@ -1,7 +1,9 @@
package com.tangem.features.swap.v2.impl.sendviaswap.confirm.model
import arrow.core.getOrElse
import com.tangem.blockchain.blockchains.ethereum.EthereumTransactionExtras
import com.tangem.blockchain.common.transaction.Fee
import com.tangem.blockchain.yieldsupply.providers.ethereum.yield.EthereumYieldSupplySendCallData
import com.tangem.domain.express.models.ExpressError
import com.tangem.domain.express.models.ExpressOperationType
import com.tangem.domain.express.models.ExpressProvider
@ -152,6 +154,13 @@ internal class SwapTransactionSender @AssistedInject constructor(
return
}
val ethereumCallData = (txData.extras as? EthereumTransactionExtras)?.callData
val payInAddress = if (ethereumCallData is EthereumYieldSupplySendCallData) {
ethereumCallData.destinationAddress
} else {
txData.destinationAddress
}
sendTransactionUseCase(
txData = txData,
userWallet = userWallet,
@ -169,6 +178,7 @@ internal class SwapTransactionSender @AssistedInject constructor(
swapDataTransactionModel = swapTransaction,
provider = provider,
txHash = txHash,
payInAddress = payInAddress,
timestamp = timestamp,
swapTxType = SwapTxType.SendWithSwap,
)

View file

@ -3,6 +3,7 @@ package com.tangem.feature.swap.domain
import android.util.Base64
import arrow.core.Either
import arrow.core.getOrElse
import com.tangem.blockchain.blockchains.ethereum.EthereumTransactionExtras
import com.tangem.blockchain.blockchains.solana.SolanaTransactionHelper
import com.tangem.blockchain.common.Amount
import com.tangem.blockchain.common.Blockchain
@ -11,6 +12,7 @@ import com.tangem.blockchain.common.TransactionExtras
import com.tangem.blockchain.common.smartcontract.SmartContractCallDataProviderFactory
import com.tangem.blockchain.common.transaction.Fee
import com.tangem.blockchain.common.transaction.TransactionFee
import com.tangem.blockchain.yieldsupply.providers.ethereum.yield.EthereumYieldSupplySendCallData
import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.blockchainsdk.utils.toBlockchain
import com.tangem.blockchainsdk.utils.toNetworkId
@ -870,6 +872,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
Timber.e(it, "Failed to create swap dex tx data")
return SwapTransactionState.Error.UnknownError
}
return handleSwapResult(
provider = provider,
networkId = networkId,
@ -881,7 +884,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
amount = amount,
derivationPath = derivationPath,
txData = txData,
payInAddress = txData.destinationAddress,
payInAddress = getPayoutAddress(txData),
)
}
@ -1087,7 +1090,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
txId = exchangeDataCex.txId,
fromNetwork = currencyToSend.currency.network.backendId,
fromAddress = currencyToSend.value.networkAddress?.defaultAddress?.value.orEmpty(),
payInAddress = txData.destinationAddress,
payInAddress = getPayoutAddress(txData),
txHash = txHash,
payInExtraId = exchangeDataCex.txExtraId,
)
@ -2307,6 +2310,15 @@ internal class SwapInteractorImpl @AssistedInject constructor(
}
}
private fun getPayoutAddress(txData: TransactionData.Uncompiled): String {
val ethereumCallData = (txData.extras as? EthereumTransactionExtras)?.callData
return if (ethereumCallData is EthereumYieldSupplySendCallData) {
ethereumCallData.destinationAddress
} else {
txData.destinationAddress
}
}
companion object {
private const val INCREASE_GAS_LIMIT_FOR_DEX = 112 // 12%
private const val INCREASE_GAS_LIMIT_FOR_SEND = 105 // 5%