Skip to content

Commit

Permalink
fix: remove deregistered nodes from total staked if not in the contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerilym committed Jan 24, 2025
1 parent 3c77db6 commit 81d0cfa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/staking/app/mystakes/modules/useTotalStaked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ export function useTotalStaked(addressOverride?: Address) {
const { address: connectedAddress } = useWallet();
const address = addressOverride ?? connectedAddress;

const { stakes, contracts, refetch, status, enabled } = useStakes(addressOverride);
const { stakes, contracts, refetch, status, enabled, currentContractIds } =
useStakes(addressOverride);

const totalStakedAmount = useMemo(() => {
if (!address) return formatSENTBigInt(0n);

const stakedStakes = stakes.filter((stake) => {
const eventState = parseStakeEventState(stake);
return !(
eventState === STAKE_EVENT_STATE.EXITED || eventState === STAKE_EVENT_STATE.LIQUIDATED
return (
!(eventState === STAKE_EVENT_STATE.EXITED || eventState === STAKE_EVENT_STATE.LIQUIDATED) &&
currentContractIds?.has(stake.contract_id)
);
});

Expand Down

0 comments on commit 81d0cfa

Please sign in to comment.