Updated on 2026-08-14
This commit is contained in:
parent
53b02cfb10
commit
2be7445212
81 changed files with 4444 additions and 3434 deletions
|
|
@ -26,12 +26,11 @@ import com.tangem.domain.utils.convertToSdkAmount
|
|||
import com.tangem.features.send.v2.api.subcomponents.feeSelector.utils.FeeCalculationUtils
|
||||
import com.tangem.features.swap.v2.impl.common.ConfirmData
|
||||
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM
|
||||
import com.tangem.utils.logging.TangemLogger
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import com.tangem.utils.logging.TangemLogger
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal class SwapTransactionSender @AssistedInject constructor(
|
||||
|
|
@ -91,7 +90,7 @@ internal class SwapTransactionSender @AssistedInject constructor(
|
|||
val feeValue = confirmData.fee?.amount?.value ?: return
|
||||
val destination = confirmData.enteredDestination ?: return
|
||||
|
||||
val (swapDataRequestAmount, swapDataRequestCurrency) = when (confirmData.amountType) {
|
||||
val swapDataRequestAmount = when (confirmData.amountType) {
|
||||
SwapAmountType.From -> {
|
||||
val amountValue = confirmData.enteredFromAmount ?: return
|
||||
val subtracted = FeeCalculationUtils.checkAndCalculateSubtractedAmount(
|
||||
|
|
@ -101,11 +100,11 @@ internal class SwapTransactionSender @AssistedInject constructor(
|
|||
feeValue = feeValue,
|
||||
reduceAmountBy = confirmData.reduceAmountBy,
|
||||
)
|
||||
subtracted to fromStatus
|
||||
subtracted
|
||||
}
|
||||
SwapAmountType.To -> {
|
||||
val amountValue = confirmData.enteredToAmount ?: return
|
||||
amountValue to toStatus
|
||||
amountValue
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +116,7 @@ internal class SwapTransactionSender @AssistedInject constructor(
|
|||
val swapData = getSwapDataUseCase(
|
||||
userWallet = userWallet,
|
||||
fromCryptoCurrencyStatus = fromStatus,
|
||||
amount = swapDataRequestAmount.toStringWithRightOffset(swapDataRequestCurrency.currency.decimals),
|
||||
amount = swapDataRequestAmount,
|
||||
amountType = confirmData.amountType,
|
||||
toCryptoCurrency = toStatus.currency,
|
||||
toAddress = destination,
|
||||
|
|
@ -208,7 +207,8 @@ internal class SwapTransactionSender @AssistedInject constructor(
|
|||
ifRight = { txHash ->
|
||||
val timestamp = System.currentTimeMillis()
|
||||
swapTransactionSentUseCase.invoke(
|
||||
userWallet = userWallet,
|
||||
fromUserWallet = userWallet,
|
||||
toUserWallet = userWallet,
|
||||
fromCryptoCurrencyStatus = fromStatus,
|
||||
toCryptoCurrencyStatus = toStatus,
|
||||
fromAccount = fromAccount,
|
||||
|
|
@ -225,10 +225,6 @@ internal class SwapTransactionSender @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun BigDecimal.toStringWithRightOffset(decimals: Int): String {
|
||||
return setScale(decimals, RoundingMode.HALF_DOWN).movePointRight(decimals).toPlainString()
|
||||
}
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(userWallet: UserWallet): SwapTransactionSender
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue