From a6315aa9151aad793770a76416fb24d86ae7d676 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Thu, 6 Aug 2020 13:35:39 +0200 Subject: [PATCH] Take unlocking and redeemable into account to bond more funds (#3348) * take unlocking and redeemable into account * spacing --- packages/page-staking/src/Actions/Account/BondExtra.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/page-staking/src/Actions/Account/BondExtra.tsx b/packages/page-staking/src/Actions/Account/BondExtra.tsx index c3c1e3660f..c052326c33 100644 --- a/packages/page-staking/src/Actions/Account/BondExtra.tsx +++ b/packages/page-staking/src/Actions/Account/BondExtra.tsx @@ -37,7 +37,9 @@ function BondExtra ({ controllerId, onClose, stakingInfo, stashId }: Props): Rea useEffect((): void => { if (stakingInfo && stakingInfo.stakingLedger && stashBalance) { - const available = stashBalance.freeBalance.sub(stakingInfo.stakingLedger.active.unwrap()); + const sumUnlocking = stakingInfo.unlocking?.reduce((acc, { value }) => acc.add(value), BN_ZERO) || BN_ZERO; + const redeemable = stakingInfo.redeemable || BN_ZERO; + const available = stashBalance.freeBalance.sub(stakingInfo.stakingLedger.active.unwrap()).sub(sumUnlocking).sub(redeemable); setStartBalance( available.gt(api.consts.balances.existentialDeposit)