Skip to content

Commit

Permalink
Merge pull request #142 from dappforce/fix-staking-modal
Browse files Browse the repository at this point in the history
Add check for minimumRemainingAmount
  • Loading branch information
olehmell authored Feb 7, 2024
2 parents 3f1611f + 8aad095 commit a51c258
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/creatorsStaking/modals/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ export const StakeOrIncreaseStakeAmountInput = (
setInputError('Amount exceeds available balance')
} else if (amountWithDecimals.lte(new BN(0))) {
setInputError('Amount must be greater than 0')
} else if (
minimumRemainingAmount &&
new BN(availableBalance.toString())
.minus(amountWithDecimals)
.lt(minimumRemainingAmount)
) {
const minimumRemainingAmountWithDecimals = convertToBalanceWithDecimal(
minimumRemainingAmount,
decimals || 0
)

setInputError(
`You must leave at least ${minimumRemainingAmountWithDecimals} SUB in your account`
)
} else {
setInputError(undefined)
}
Expand Down Expand Up @@ -165,7 +179,7 @@ export const UnstakeAmountInput = (props: CommonAmountInputProps) => {
const amountWithDecimals = balanceWithDecimal(amountValue, decimals || 0)

const canUnstake =
locked &&
locked &&
new BN(locked)
.minus(amountWithDecimals)
.gte(new BN(minimumStakingAmount || 0))
Expand Down

0 comments on commit a51c258

Please sign in to comment.