Skip to content

Commit 152099a

Browse files
authored
feat(staking): filter out publishers with no capacity (#1878)
1 parent 74fa075 commit 152099a

File tree

1 file changed

+22
-3
lines changed
  • apps/staking/src/components/OracleIntegrityStaking

1 file changed

+22
-3
lines changed

apps/staking/src/components/OracleIntegrityStaking/index.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ export const OracleIntegrityStaking = ({
6464
);
6565

6666
const otherPublishers = useMemo(
67-
() => publishers.filter((publisher) => !publisher.isSelf),
67+
() =>
68+
publishers.filter(
69+
(publisher) =>
70+
!publisher.isSelf &&
71+
(publisher.poolCapacity > 0n || hasAnyPositions(publisher)),
72+
),
6873
[publishers],
6974
);
7075

@@ -454,7 +459,10 @@ const Publisher = ({
454459
publisher.publicKey,
455460
);
456461
const utilizationPercent = useMemo(
457-
() => Number((100n * publisher.poolUtilization) / publisher.poolCapacity),
462+
() =>
463+
publisher.poolCapacity > 0n
464+
? Number((100n * publisher.poolUtilization) / publisher.poolCapacity)
465+
: Number.NaN,
458466
[publisher.poolUtilization, publisher.poolCapacity],
459467
);
460468

@@ -490,7 +498,9 @@ const Publisher = ({
490498
"mix-blend-difference": percentage < 100,
491499
})}
492500
>
493-
{`${utilizationPercent.toString()}%`}
501+
{Number.isNaN(utilizationPercent)
502+
? "Empty Pool"
503+
: `${utilizationPercent.toString()}%`}
494504
</div>
495505
</div>
496506
<Label className="mt-1 flex flex-row items-center justify-center gap-1 text-sm">
@@ -690,6 +700,15 @@ const useTransferActionForPublisher = (
690700
[action, publisher],
691701
);
692702

703+
const hasAnyPositions = ({ positions }: PublisherProps["publisher"]) =>
704+
positions !== undefined &&
705+
[
706+
positions.warmup,
707+
positions.staked,
708+
positions.cooldown,
709+
positions.cooldown2,
710+
].some((value) => value !== undefined && value > 0n);
711+
693712
enum SortField {
694713
PublisherName,
695714
PoolUtilization,

0 commit comments

Comments
 (0)