diff --git a/apps/dashboard/src/lib/validators/uptime-module.spec.ts b/apps/dashboard/src/lib/validators/uptime-module.spec.ts
index 898bfcfb1..da5fa4ae0 100644
--- a/apps/dashboard/src/lib/validators/uptime-module.spec.ts
+++ b/apps/dashboard/src/lib/validators/uptime-module.spec.ts
@@ -32,10 +32,10 @@ describe('uptime module', () => {
expect(uptimeModule.getDataForUptime('1month')).toEqual({})
})
- it('should throw when trying to get APY', () => {
- expect(() =>
+ it('should return undefined when trying to get APY', () => {
+ expect(
uptimeModule.getApy({} as ValidatorCollectionItem, '1month')
- ).toThrowError(/Invalid totalAmountStaked/)
+ ).toBeUndefined()
})
})
diff --git a/apps/dashboard/src/lib/validators/uptime-module.ts b/apps/dashboard/src/lib/validators/uptime-module.ts
index c8e75f297..3b54414a0 100644
--- a/apps/dashboard/src/lib/validators/uptime-module.ts
+++ b/apps/dashboard/src/lib/validators/uptime-module.ts
@@ -60,7 +60,7 @@ export const UptimeModule = (
getDataForUptime: (uptime: UptimeValue) => uptimeData[uptime] || {},
getApy: (validator: ValidatorCollectionItem, uptime: UptimeValue) => {
if (!totalAmountStaked || totalAmountStaked.isZero()) {
- throw new Error('Invalid totalAmountStaked')
+ return undefined
}
const address = validator.address
const fee = Number(validator.effective_fee_factor?.current?.fee_factor)
diff --git a/apps/dashboard/src/pages/navbar-pages/staking/validator-details/ApyDetail.svelte b/apps/dashboard/src/pages/navbar-pages/staking/validator-details/ApyDetail.svelte
index 80219a814..51dd8bc44 100644
--- a/apps/dashboard/src/pages/navbar-pages/staking/validator-details/ApyDetail.svelte
+++ b/apps/dashboard/src/pages/navbar-pages/staking/validator-details/ApyDetail.svelte
@@ -23,11 +23,9 @@
uptimeModule.getDataForUptime($lastQueriedUptime)}
{#if validatorsUptimeData && Object.keys(validatorsUptimeData).length > 0}
{@const data = validator.typed.value}
-
- {validator.typed.value.percentageTotalStake
- ? `${truncateNumber(
- uptimeModule.getApy(data.validator, $lastQueriedUptime)
- )}%`
+ {@const apy = uptimeModule.getApy(data.validator, $lastQueriedUptime)}
+ {validator.typed.value.percentageTotalStake && apy
+ ? `${truncateNumber(apy)}%`
: 'N/A'}
{:else}