瀏覽代碼

feat(staking): filter out publishers with no capacity (#1878)

Connor Prussin 1 年之前
父節點
當前提交
152099a595
共有 1 個文件被更改,包括 22 次插入3 次删除
  1. 22 3
      apps/staking/src/components/OracleIntegrityStaking/index.tsx

+ 22 - 3
apps/staking/src/components/OracleIntegrityStaking/index.tsx

@@ -64,7 +64,12 @@ export const OracleIntegrityStaking = ({
   );
 
   const otherPublishers = useMemo(
-    () => publishers.filter((publisher) => !publisher.isSelf),
+    () =>
+      publishers.filter(
+        (publisher) =>
+          !publisher.isSelf &&
+          (publisher.poolCapacity > 0n || hasAnyPositions(publisher)),
+      ),
     [publishers],
   );
 
@@ -454,7 +459,10 @@ const Publisher = ({
     publisher.publicKey,
   );
   const utilizationPercent = useMemo(
-    () => Number((100n * publisher.poolUtilization) / publisher.poolCapacity),
+    () =>
+      publisher.poolCapacity > 0n
+        ? Number((100n * publisher.poolUtilization) / publisher.poolCapacity)
+        : Number.NaN,
     [publisher.poolUtilization, publisher.poolCapacity],
   );
 
@@ -490,7 +498,9 @@ const Publisher = ({
                       "mix-blend-difference": percentage < 100,
                     })}
                   >
-                    {`${utilizationPercent.toString()}%`}
+                    {Number.isNaN(utilizationPercent)
+                      ? "Empty Pool"
+                      : `${utilizationPercent.toString()}%`}
                   </div>
                 </div>
                 <Label className="mt-1 flex flex-row items-center justify-center gap-1 text-sm">
@@ -690,6 +700,15 @@ const useTransferActionForPublisher = (
     [action, publisher],
   );
 
+const hasAnyPositions = ({ positions }: PublisherProps["publisher"]) =>
+  positions !== undefined &&
+  [
+    positions.warmup,
+    positions.staked,
+    positions.cooldown,
+    positions.cooldown2,
+  ].some((value) => value !== undefined && value > 0n);
+
 enum SortField {
   PublisherName,
   PoolUtilization,