From 0acf0557e33e2fc57b4a0a5b326352328e99ade5 Mon Sep 17 00:00:00 2001 From: Mell Date: Fri, 8 Dec 2023 11:37:11 +0200 Subject: [PATCH] Fix creator staking balance calculation --- src/utils/balance.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/utils/balance.ts b/src/utils/balance.ts index 6b8eeeaa..fe50cfbe 100644 --- a/src/utils/balance.ts +++ b/src/utils/balance.ts @@ -14,14 +14,12 @@ export const calculateBalanceForStaking = ( lockId?: string ) => { if (!data) return BN_ZERO - const { freeBalance, lockedBalance, locks } = data + const { freeBalance, totalBalance, lockedBalance, locks } = data const stakingLockedBalance = locks?.find(({ id }) => id === lockId) if (!stakingLockedBalance || - lockedBalance === stakingLockedBalance?.amount) return freeBalance + lockedBalance === stakingLockedBalance?.amount) return totalBalance - return new BN(freeBalance) - .add(new BN(lockedBalance) - .sub(new BN(stakingLockedBalance.amount))) + return new BN(totalBalance).sub(new BN(stakingLockedBalance.amount)) }