diff --git a/staking/app/StakeConnection.ts b/staking/app/StakeConnection.ts index 3a097431..b3c9d669 100644 --- a/staking/app/StakeConnection.ts +++ b/staking/app/StakeConnection.ts @@ -1021,12 +1021,19 @@ export class StakeAccount { let unlockingDuration = this.config.unlockingDuration; let currentEpochBI = BigInt(currentEpoch.toString()); - const withdrawable = this.stakeAccountPositionsWasm.getWithdrawable( - BigInt(this.tokenBalance.toString()), - unvestedBalance, - currentEpochBI, - unlockingDuration - ); + let withdrawable: BigInt; + try { + withdrawable = this.stakeAccountPositionsWasm.getWithdrawable( + BigInt(this.tokenBalance.toString()), + unvestedBalance, + currentEpochBI, + unlockingDuration + ); + } catch (e) { + throw Error( + "This account has less tokens than the unlocking schedule or your staking position requires. Please contact support." + ); + } const withdrawableBN = new BN(withdrawable.toString()); const unvestedBN = new BN(unvestedBalance.toString());