Updated on 2026-08-14

This commit is contained in:
Tangem 2024-12-26 14:35:07 +03:00
commit 646d33dfa2

View file

@ -638,6 +638,7 @@ internal class StakingViewModel @Inject constructor(
amount = amount.orZero(), amount = amount.orZero(),
fee = fee.orZero(), fee = fee.orZero(),
reduceAmountBy = confirmationState?.reduceAmountBy.orZero(), reduceAmountBy = confirmationState?.reduceAmountBy.orZero(),
actionType = value.actionType,
) )
val currencyStatus = getCurrencyCheckUseCase( val currencyStatus = getCurrencyCheckUseCase(
userWalletId = userWalletId, userWalletId = userWalletId,
@ -697,14 +698,21 @@ internal class StakingViewModel @Inject constructor(
amount: BigDecimal, amount: BigDecimal,
fee: BigDecimal, fee: BigDecimal,
reduceAmountBy: BigDecimal, reduceAmountBy: BigDecimal,
actionType: StakingActionCommonType,
): BigDecimal? { ): BigDecimal? {
val subtractedBalanceAmount = checkAndCalculateSubtractedAmount( // TODO split for different networks
isAmountSubtractAvailable = isAmountSubtractAvailable, val subtractedBalanceAmount = when (actionType) {
cryptoCurrencyStatus = cryptoCurrencyStatus, StakingActionCommonType.Enter -> checkAndCalculateSubtractedAmount(
amountValue = amount.orZero(), isAmountSubtractAvailable = isAmountSubtractAvailable,
feeValue = fee.orZero(), cryptoCurrencyStatus = cryptoCurrencyStatus,
reduceAmountBy = reduceAmountBy, amountValue = amount.orZero(),
) feeValue = fee.orZero(),
reduceAmountBy = reduceAmountBy,
)
StakingActionCommonType.Exit,
is StakingActionCommonType.Pending,
-> BigDecimal.ZERO
}
val statusValue = cryptoCurrencyStatus.value as? CryptoCurrencyStatus.Loaded val statusValue = cryptoCurrencyStatus.value as? CryptoCurrencyStatus.Loaded
return statusValue?.let { it.amount - subtractedBalanceAmount - fee.orZero() } return statusValue?.let { it.amount - subtractedBalanceAmount - fee.orZero() }
} }