Updated on 2026-08-14

This commit is contained in:
Tangem 2024-03-15 17:36:00 +00:00
parent bee7b16acc
commit 9d03d44bf7
2 changed files with 13 additions and 3 deletions

View file

@ -14,6 +14,7 @@ internal class ExchangeStatusConverter : Converter<ExchangeStatusResponse, Excha
},
txId = value.externalTxId,
txExternalUrl = value.externalTxUrl,
txExternalId = value.externalTxId,
)
}
}

View file

@ -1480,7 +1480,16 @@ internal class SwapInteractorImpl @Inject constructor(
fromTokenStatus.currency.network.derivationPath.value,
)
nativeTokenBalance?.let { balance ->
if (balance.value.minus(spendAmount.value) > fee.multiply(percentsToFeeIncrease)) {
val balanceToCheck = when (fromTokenStatus.currency) {
is CryptoCurrency.Token -> {
balance.value
}
is CryptoCurrency.Coin -> {
// need to check balance minus amount only if amount to swap in native token
balance.value.minus(spendAmount.value)
}
}
if (balanceToCheck > fee.multiply(percentsToFeeIncrease)) {
SwapFeeState.Enough
} else {
val nativeToken = getNativeToken(fromTokenStatus.currency.network.backendId)
@ -1510,9 +1519,9 @@ internal class SwapInteractorImpl @Inject constructor(
} else {
val token = currenciesRepository
.getMultiCurrencyWalletCurrenciesSync(userWalletId)
.filterIsInstance<CryptoCurrency.Token>()
.find {
it is CryptoCurrency.Token &&
it.contractAddress.equals(feePaidCurrency.contractAddress, ignoreCase = true) &&
it.contractAddress.equals(feePaidCurrency.contractAddress, ignoreCase = true) &&
it.network.derivationPath == fromTokenStatus.currency.network.derivationPath
}
SwapFeeState.NotEnough(