Skip to content

Commit

Permalink
Merge pull request #4024 from tangem/hotfix/5.19.1
Browse files Browse the repository at this point in the history
Hotfix/5.19.1
  • Loading branch information
kozarezvlad authored Dec 26, 2024
2 parents 8a42ad4 + 0ff37fc commit 8b1ff92
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ internal class StakingViewModel @Inject constructor(
amount = amount.orZero(),
fee = fee.orZero(),
reduceAmountBy = confirmationState?.reduceAmountBy.orZero(),
actionType = value.actionType,
)
val currencyStatus = getCurrencyCheckUseCase(
userWalletId = userWalletId,
Expand Down Expand Up @@ -697,14 +698,21 @@ internal class StakingViewModel @Inject constructor(
amount: BigDecimal,
fee: BigDecimal,
reduceAmountBy: BigDecimal,
actionType: StakingActionCommonType,
): BigDecimal? {
val subtractedBalanceAmount = checkAndCalculateSubtractedAmount(
isAmountSubtractAvailable = isAmountSubtractAvailable,
cryptoCurrencyStatus = cryptoCurrencyStatus,
amountValue = amount.orZero(),
feeValue = fee.orZero(),
reduceAmountBy = reduceAmountBy,
)
// TODO split for different networks
val subtractedBalanceAmount = when (actionType) {
StakingActionCommonType.Enter -> checkAndCalculateSubtractedAmount(
isAmountSubtractAvailable = isAmountSubtractAvailable,
cryptoCurrencyStatus = cryptoCurrencyStatus,
amountValue = amount.orZero(),
feeValue = fee.orZero(),
reduceAmountBy = reduceAmountBy,
)
StakingActionCommonType.Exit,
is StakingActionCommonType.Pending,
-> BigDecimal.ZERO
}
val statusValue = cryptoCurrencyStatus.value as? CryptoCurrencyStatus.Loaded
return statusValue?.let { it.amount - subtractedBalanceAmount - fee.orZero() }
}
Expand Down

0 comments on commit 8b1ff92

Please # to comment.