From 9bb0c2ec48323ec317a5f43b7ec88f61781b0439 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 9 Mar 2023 12:35:17 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../com/tangem/tap/proxy/TransactionManagerImpl.kt | 9 ++++++++- .../feature/swap/domain/SwapInteractorImpl.kt | 3 +++ .../com/tangem/lib/crypto/TransactionManager.kt | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt b/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt index 14349d169f..6ec7b292bb 100644 --- a/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt +++ b/app/src/main/java/com/tangem/tap/proxy/TransactionManagerImpl.kt @@ -148,6 +148,7 @@ class TransactionManagerImpl( amountToSend: BigDecimal, currencyToSend: Currency, destinationAddress: String, + increaseBy: Int?, data: String?, derivationPath: String?, ): ProxyFee { @@ -161,7 +162,13 @@ class TransactionManagerImpl( currency = currencyToSend, destinationAddress = destinationAddress, data = data, - ) + ).let { + if (increaseBy != null && increaseBy != 0) { + it.multiply(increaseBy.toBigInteger()).divide(BigInteger("100")) + } else { + it + } + } return when (val gasPrice = walletManager.getGasPrice()) { is Result.Success -> { val fee = gasLimit.multiply(gasPrice.data).toBigDecimal( 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 f1ef395ed1..2bb5569c19 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 @@ -411,6 +411,7 @@ internal class SwapInteractorImpl @Inject constructor( amountToSend = amount.value, currencyToSend = cryptoCurrencyConverter.convert(fromToken), destinationAddress = swapData.transaction.toWalletAddress, + increaseBy = INCREASE_GAS_LIMIT_BY, data = swapData.transaction.data, derivationPath = derivationPath, ) @@ -529,6 +530,7 @@ internal class SwapInteractorImpl @Inject constructor( amountToSend = BigDecimal.ZERO, currencyToSend = userWalletManager.getNativeTokenForNetwork(networkId), destinationAddress = transactionData.toAddress, + increaseBy = INCREASE_GAS_LIMIT_BY, data = transactionData.data, derivationPath = derivationPath, ) @@ -645,6 +647,7 @@ internal class SwapInteractorImpl @Inject constructor( private const val ZERO_BALANCE = "0" private const val DEFAULT_BLOCKCHAIN_INCH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" private const val INCREASE_FEE_TO_CHECK_ENOUGH_PERCENT = 1.4 + private const val INCREASE_GAS_LIMIT_BY = 125 private const val USDT_SYMBOL = "USDT" private const val USDC_SYMBOL = "USDC" private const val INFINITY_SYMBOL = "∞" diff --git a/libs/crypto/src/main/java/com/tangem/lib/crypto/TransactionManager.kt b/libs/crypto/src/main/java/com/tangem/lib/crypto/TransactionManager.kt index 02c08a1d6b..97deab1626 100644 --- a/libs/crypto/src/main/java/com/tangem/lib/crypto/TransactionManager.kt +++ b/libs/crypto/src/main/java/com/tangem/lib/crypto/TransactionManager.kt @@ -33,6 +33,18 @@ interface TransactionManager { derivationPath: String?, ): SendTxResult + /** + * Get fee + * + * @param networkId network id of blockchain + * @param amountToSend amount + * @param currencyToSend currency to send in tx + * @param destinationAddress address to send tx + * @param increaseBy percents in format 125 = 25% + * @param data data for tx + * @param derivationPath derivation path + * @return + */ @Suppress("LongParameterList") @Throws(IllegalStateException::class) suspend fun getFee( @@ -40,6 +52,7 @@ interface TransactionManager { amountToSend: BigDecimal, currencyToSend: Currency, destinationAddress: String, + increaseBy: Int?, data: String?, derivationPath: String?, ): ProxyFee