Skip to content

Commit

Permalink
fix: unstake all in pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-1979 committed Jan 29, 2025
1 parent 970edb1 commit 20a8eb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/polkagate/snap.git"
},
"source": {
"shasum": "87YP0SaD+aVCL7sNXBS+d87d/Z0IrbWEFe8rnp7tWj0=",
"shasum": "n/cGTSXC/ISmYws91BlFw9I7qCKDJfmkzkIwsPsfGqM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { amountToHuman } from "../../../../../util/amountToHuman";
import type { StakeFormErrors, StakingPoolContextType } from "../../../types";
import type { PoolUnstakeFormState } from "../types";
import { amountToMachine } from "../../../../../util/amountToMachine";
import { STAKED_AMOUNT_DECIMAL_POINT } from "../../../const";

/**
* Validate the unstake stake pool form.
Expand All @@ -24,10 +25,13 @@ export function unstakePoolFormValidation(
const netStaked = new BN(pooledBalance ?? 0).sub(new BN(claimable ?? 0));
const remaining = netStaked.sub(amountToMachine(String(amount), decimal));

if (
Number(amount) >
Number(amountToHuman(netStaked, decimal))
) {
const isUnstakingAll = Number(amountToHuman(netStaked, decimal, STAKED_AMOUNT_DECIMAL_POINT)) === Number(amount);
if (isUnstakingAll) {
return errors;
}

if (Number(amount) > Number(amountToHuman(netStaked, decimal))) {

errors.amount = 'More than staked amount!';

} else if (remaining.lt(new BN(minJoinBond ?? 0))) {
Expand Down

0 comments on commit 20a8eb8

Please sign in to comment.