From 17ea21d018b35e9bcc97f197f56d95da91dd983a Mon Sep 17 00:00:00 2001 From: artemkolodko Date: Tue, 19 Dec 2023 17:36:44 +0000 Subject: [PATCH] Add total undelegated to Staked --- src/pages/AddressPage/StakingDelegations.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pages/AddressPage/StakingDelegations.tsx b/src/pages/AddressPage/StakingDelegations.tsx index 2a024c7..b4269a6 100644 --- a/src/pages/AddressPage/StakingDelegations.tsx +++ b/src/pages/AddressPage/StakingDelegations.tsx @@ -32,10 +32,16 @@ function StakingDelegations(props: { delegations: StakingDelegation[] }) { let totalAmountBig = Big(0) let totalRewardsBig = Big(0) + let totalUndelegated = Big(0) delegations.forEach(delegation => { totalAmountBig = totalAmountBig.plus(Big(delegation.amount)) totalRewardsBig = totalRewardsBig.plus(Big(delegation.reward)) + + const undelegated = delegation.undelegations.reduce((acc, item) => { + return acc.plus(Big(item.amount)) + }, Big(0)) + totalUndelegated = totalUndelegated.plus(undelegated) }) const totalAmount = totalAmountBig.div(Big(10 ** 18)).round(2).toString() @@ -84,6 +90,12 @@ function StakingDelegations(props: { delegations: StakingDelegation[] }) { {items.length > 0 && } + {totalUndelegated.gt(0) && + + Undelegated: + + + } } }