Updated on 2026-08-14
This commit is contained in:
parent
e86615242b
commit
32398842df
2 changed files with 7 additions and 9 deletions
|
|
@ -73,6 +73,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
isSubtractAvailable = isSubtractAvailable,
|
||||
reduceAmountBy = reduceAmountBy,
|
||||
)
|
||||
val minimumRequirement = yield.args.enter.args[Yield.Args.ArgType.AMOUNT]?.minimum.orZero()
|
||||
val sendingAmount = if (isEnterAction) {
|
||||
checkAndCalculateSubtractedAmount(
|
||||
isAmountSubtractAvailable = isSubtractAvailable,
|
||||
|
|
@ -84,7 +85,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
} else {
|
||||
// No amount is taken from account balance on exit or pending actions
|
||||
BigDecimal.ZERO
|
||||
}
|
||||
}.max(minimumRequirement)
|
||||
|
||||
val notifications = buildList {
|
||||
// errors
|
||||
|
|
@ -106,7 +107,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
amountState = amountState,
|
||||
feeState = feeState,
|
||||
sendingAmount = sendingAmount,
|
||||
isFeeCoverage = isFeeCoverage && isEnterAction,
|
||||
isFeeCoverage = isFeeCoverage && isEnterAction && !sendingAmount.equals(minimumRequirement),
|
||||
)
|
||||
|
||||
addInfoNotifications(prevState)
|
||||
|
|
@ -223,11 +224,10 @@ internal class AddStakingNotificationsTransformer(
|
|||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
onClick: (CryptoCurrency) -> Unit,
|
||||
) {
|
||||
val minimumRequirement = yield.args.enter.args[Yield.Args.ArgType.AMOUNT]?.minimum
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: BigDecimal.ZERO
|
||||
if (!isSubtractionAvailable) return
|
||||
|
||||
val showNotification = sendingAmount + feeAmount > balance - minimumRequirement.orZero()
|
||||
val showNotification = sendingAmount + feeAmount > balance
|
||||
if (showNotification) {
|
||||
val notification = if (actionType == StakingActionCommonType.ENTER) {
|
||||
NotificationUM.Error.TotalExceedsBalance
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ internal class SetConfirmationStateLoadingTransformer(
|
|||
availableValidators = yield.validators,
|
||||
),
|
||||
notifications = persistentListOf(),
|
||||
footerText = getFooter(prevState),
|
||||
footerText = getFooter(prevState, chosenValidator),
|
||||
transactionDoneState = TransactionDoneState.Empty,
|
||||
pendingAction = possibleConfirmationState?.pendingAction,
|
||||
pendingActions = possibleConfirmationState?.pendingActions,
|
||||
|
|
@ -45,14 +45,12 @@ internal class SetConfirmationStateLoadingTransformer(
|
|||
)
|
||||
}
|
||||
|
||||
private fun getFooter(state: StakingUiState): TextReference {
|
||||
private fun getFooter(state: StakingUiState, validator: Yield.Validator): TextReference {
|
||||
val amountState = state.amountState as? AmountState.Data
|
||||
val confirmationState = state.confirmationState as? StakingStates.ConfirmationState.Data
|
||||
val validatorState = confirmationState?.validatorState as? ValidatorState.Content
|
||||
|
||||
val isEnterAction = state.actionType == StakingActionCommonType.ENTER
|
||||
|
||||
val apr = validatorState?.chosenValidator?.apr.orZero()
|
||||
val apr = validator.apr.orZero()
|
||||
val amountDecimal = amountState?.amountTextField?.fiatAmount?.value
|
||||
val potentialReward = amountDecimal?.multiply(apr)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue