From 31140e61b03473849f442f5c777b109334db34e3 Mon Sep 17 00:00:00 2001 From: belopash Date: Thu, 9 May 2024 20:57:06 +0500 Subject: [PATCH 1/5] fix: fix total worker reward display value --- src/api/subsquid-network-squid/workers-graphql.ts | 4 ++-- src/pages/WorkersPage/MyWorkerStat.tsx | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api/subsquid-network-squid/workers-graphql.ts b/src/api/subsquid-network-squid/workers-graphql.ts index 5d6f2a1..97c6b8b 100644 --- a/src/api/subsquid-network-squid/workers-graphql.ts +++ b/src/api/subsquid-network-squid/workers-graphql.ts @@ -49,7 +49,7 @@ export class BlockchainApiWorker { }[] = []; myDelegationsTotal: Decimal; myDelegationsRewardsTotal: Decimal; - totalReward: Decimal; + totalReward: string; constructor({ worker, address }: { worker: WorkerFragmentFragment; address?: `0x${string}` }) { const totalDelegation = fromSqd(worker.totalDelegation); @@ -74,7 +74,7 @@ export class BlockchainApiWorker { new Decimal(0), ); - this.totalReward = new Decimal(this.claimedReward).add(this.claimableReward); + this.totalReward = new Decimal(this.claimedReward).add(this.claimableReward).toFixed(0); } } diff --git a/src/pages/WorkersPage/MyWorkerStat.tsx b/src/pages/WorkersPage/MyWorkerStat.tsx index 133af91..5e4d856 100644 --- a/src/pages/WorkersPage/MyWorkerStat.tsx +++ b/src/pages/WorkersPage/MyWorkerStat.tsx @@ -48,9 +48,7 @@ export const MyWorkerStat = ({ worker }: { worker: BlockchainApiWorker }) => { Total rewards - - {formatSqd(SQD_TOKEN, new Decimal(worker.claimedReward).add(worker.claimableReward))} - + {formatSqd(SQD_TOKEN, worker.totalReward)} From fca7a02b7a5c7a69a3db0f122e1d3254f2223955 Mon Sep 17 00:00:00 2001 From: belopash Date: Fri, 10 May 2024 15:07:51 +0500 Subject: [PATCH 2/5] feat: hide uptime graph --- src/pages/WorkersPage/WorkerStatistics.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pages/WorkersPage/WorkerStatistics.tsx b/src/pages/WorkersPage/WorkerStatistics.tsx index 9c0f5df..7467e5d 100644 --- a/src/pages/WorkersPage/WorkerStatistics.tsx +++ b/src/pages/WorkersPage/WorkerStatistics.tsx @@ -93,7 +93,7 @@ export const WorkerStatistics = ({ worker }: { worker: BlockchainApiFullWorker } - + {/* */} {/**/} @@ -105,14 +105,20 @@ export const WorkerStatistics = ({ worker }: { worker: BlockchainApiFullWorker } {/* */} {/**/} - Queries, last 24 hours / last 90 days + Uptime, 24 hours / 90 days + + {percentFormatter(worker.uptime24Hours)} / {percentFormatter(worker.uptime90Days)} + + + + Queries, 24 hours / 90 days {numberWithSpacesFormatter(worker.queries24Hours)} /{' '} {numberWithSpacesFormatter(worker.queries90Days)} - Data served, last 24 hours / last 90 days + Data served, 24 hours / 90 days {bytesFormatter(worker.servedData24Hours)} / {bytesFormatter(worker.servedData90Days)} From 7c27aa72adc298cdfe8c0988937222aaf6ef4b16 Mon Sep 17 00:00:00 2001 From: belopash Date: Fri, 10 May 2024 17:52:36 +0500 Subject: [PATCH 3/5] feat: hide 0 delegator apr if there are no delegators --- src/api/subsquid-network-squid/workers-graphql.ts | 2 +- src/pages/DashboardPage/Workers.tsx | 6 +++++- src/pages/WorkersPage/WorkerStatistics.tsx | 8 +++++--- src/pages/WorkersPage/WorkersPage.tsx | 6 ++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/api/subsquid-network-squid/workers-graphql.ts b/src/api/subsquid-network-squid/workers-graphql.ts index 97c6b8b..0667f4b 100644 --- a/src/api/subsquid-network-squid/workers-graphql.ts +++ b/src/api/subsquid-network-squid/workers-graphql.ts @@ -149,7 +149,7 @@ export function useWorkers({ case WorkerSortBy.DelegationCapacity: return a.totalDelegations.capacity.minus(b.totalDelegations.capacity).toNumber(); case WorkerSortBy.StakerAPR: - return (a.stakerApr || 0) - (b.stakerApr || 0); + return (a.stakerApr || 0) - (b.stakerApr || 0) || a.delegationCount - b.delegationCount; case WorkerSortBy.WorkerAPR: return (a.apr || 0) - (b.apr || 0); default: diff --git a/src/pages/DashboardPage/Workers.tsx b/src/pages/DashboardPage/Workers.tsx index 4826892..674db3d 100644 --- a/src/pages/DashboardPage/Workers.tsx +++ b/src/pages/DashboardPage/Workers.tsx @@ -139,7 +139,11 @@ export function Workers() { {percentFormatter(worker.uptime24Hours)} {percentFormatter(worker.apr)} - {percentFormatter(worker.stakerApr)} + + {worker.delegationCount || worker.stakerApr + ? percentFormatter(worker.stakerApr) + : '-'} + {/*{formatSqd(worker.totalDelegations.capacity, 0)}*/} {dateFormat(worker.createdAt)} diff --git a/src/pages/WorkersPage/WorkerStatistics.tsx b/src/pages/WorkersPage/WorkerStatistics.tsx index 7467e5d..107d91e 100644 --- a/src/pages/WorkersPage/WorkerStatistics.tsx +++ b/src/pages/WorkersPage/WorkerStatistics.tsx @@ -11,8 +11,6 @@ import { BlockchainApiFullWorker } from '@api/subsquid-network-squid'; import { Card } from '@components/Card'; import { Online } from '@components/Online'; -import { UptimeGraph } from './UptimeGraph'; - export const WorkerColumnLabel = styled(Box, { name: 'WorkerColumnLabel', })(() => ({ @@ -65,7 +63,11 @@ export const WorkerStatistics = ({ worker }: { worker: BlockchainApiFullWorker } Delegator APR - {percentFormatter(worker.stakerApr)} + + {worker.delegationCount || worker.stakerApr + ? percentFormatter(worker.stakerApr) + : '-'} + {/**/} diff --git a/src/pages/WorkersPage/WorkersPage.tsx b/src/pages/WorkersPage/WorkersPage.tsx index 48a5ea9..c53adc1 100644 --- a/src/pages/WorkersPage/WorkersPage.tsx +++ b/src/pages/WorkersPage/WorkersPage.tsx @@ -44,6 +44,7 @@ export function MyWorkers() { Status Uptime, 24h APR, 7d + Delegator APR, 7d Total reward @@ -64,6 +65,11 @@ export function MyWorkers() { {percentFormatter(worker.uptime24Hours)} {percentFormatter(worker.apr)} + + {worker.delegationCount || worker.stakerApr + ? percentFormatter(worker.stakerApr) + : '-'} + {formatSqd(SQD_TOKEN, worker.totalReward)} From 6bac686300ade48e22bec79b8a50e80f865cdeb4 Mon Sep 17 00:00:00 2001 From: belopash Date: Fri, 10 May 2024 20:08:04 +0500 Subject: [PATCH 4/5] fix: don't display null aprs --- src/pages/DashboardPage/Workers.tsx | 6 ++---- src/pages/DelegationsPage/DelegationsPage.tsx | 4 +++- src/pages/WorkersPage/MyWorkerStat.tsx | 3 +-- src/pages/WorkersPage/WorkerStatistics.tsx | 6 +----- src/pages/WorkersPage/WorkersPage.tsx | 6 ++---- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/pages/DashboardPage/Workers.tsx b/src/pages/DashboardPage/Workers.tsx index 674db3d..f43d150 100644 --- a/src/pages/DashboardPage/Workers.tsx +++ b/src/pages/DashboardPage/Workers.tsx @@ -138,11 +138,9 @@ export function Workers() { {percentFormatter(worker.uptime24Hours)} - {percentFormatter(worker.apr)} + {worker.apr != null ? percentFormatter(worker.apr) : '-'} - {worker.delegationCount || worker.stakerApr - ? percentFormatter(worker.stakerApr) - : '-'} + {worker.stakerApr != null ? percentFormatter(worker.stakerApr) : '-'} {/*{formatSqd(worker.totalDelegations.capacity, 0)}*/} {dateFormat(worker.createdAt)} diff --git a/src/pages/DelegationsPage/DelegationsPage.tsx b/src/pages/DelegationsPage/DelegationsPage.tsx index f7b4378..e560036 100644 --- a/src/pages/DelegationsPage/DelegationsPage.tsx +++ b/src/pages/DelegationsPage/DelegationsPage.tsx @@ -54,7 +54,9 @@ export function MyDelegations() { {formatSqd(SQD_TOKEN, worker.myDelegationsTotal)} - {percentFormatter(worker.stakerApr)} + + {worker.stakerApr != null ? percentFormatter(worker.stakerApr) : '-'} + {formatSqd(SQD_TOKEN, worker.myDelegationsRewardsTotal)} diff --git a/src/pages/WorkersPage/MyWorkerStat.tsx b/src/pages/WorkersPage/MyWorkerStat.tsx index 5e4d856..e387576 100644 --- a/src/pages/WorkersPage/MyWorkerStat.tsx +++ b/src/pages/WorkersPage/MyWorkerStat.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { percentFormatter } from '@lib/formatters/formatters.ts'; import { Box, Divider, Stack, styled } from '@mui/material'; -import Decimal from 'decimal.js'; import { formatSqd } from '@api/contracts/utils'; import { BlockchainApiWorker } from '@api/subsquid-network-squid'; @@ -36,7 +35,7 @@ export const MyWorkerStat = ({ worker }: { worker: BlockchainApiWorker }) => { Worker APR - {percentFormatter(worker.apr)} + {worker.apr != null ? percentFormatter(worker.apr) : '-'} diff --git a/src/pages/WorkersPage/WorkerStatistics.tsx b/src/pages/WorkersPage/WorkerStatistics.tsx index 107d91e..49a4c3e 100644 --- a/src/pages/WorkersPage/WorkerStatistics.tsx +++ b/src/pages/WorkersPage/WorkerStatistics.tsx @@ -63,11 +63,7 @@ export const WorkerStatistics = ({ worker }: { worker: BlockchainApiFullWorker } Delegator APR - - {worker.delegationCount || worker.stakerApr - ? percentFormatter(worker.stakerApr) - : '-'} - + {worker.stakerApr != null ? percentFormatter(worker.stakerApr) : '-'} {/**/} diff --git a/src/pages/WorkersPage/WorkersPage.tsx b/src/pages/WorkersPage/WorkersPage.tsx index c53adc1..4108f0f 100644 --- a/src/pages/WorkersPage/WorkersPage.tsx +++ b/src/pages/WorkersPage/WorkersPage.tsx @@ -64,11 +64,9 @@ export function MyWorkers() { {percentFormatter(worker.uptime24Hours)} - {percentFormatter(worker.apr)} + {worker.apr != null ? percentFormatter(worker.apr) : '-'} - {worker.delegationCount || worker.stakerApr - ? percentFormatter(worker.stakerApr) - : '-'} + {worker.stakerApr != null ? percentFormatter(worker.stakerApr) : '-'} {formatSqd(SQD_TOKEN, worker.totalReward)} From e135a65eb15d17fb530c43fb0877cfb3cbb797d5 Mon Sep 17 00:00:00 2001 From: belopash Date: Sat, 11 May 2024 16:35:04 +0500 Subject: [PATCH 5/5] fix: increase Decimal precision --- src/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index 0893f2b..f88ca2e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { info } from '@logger'; import * as Sentry from '@sentry/react'; +import Decimal from 'decimal.js'; import { createRoot } from 'react-dom/client'; import { useNavigate } from 'react-router-dom'; import { useDisconnect } from 'wagmi'; @@ -10,6 +11,8 @@ import { queryClient } from '@api/client'; import App from './App'; +Decimal.set({ precision: 30, rounding: 3 }); + declare global { interface process { env: {