diff --git a/frontend/components/MainPage/sections/RewardsSection/StakingRewardsThisEpoch.tsx b/frontend/components/MainPage/sections/RewardsSection/StakingRewardsThisEpoch.tsx index d88812f1..2dc1c0ac 100644 --- a/frontend/components/MainPage/sections/RewardsSection/StakingRewardsThisEpoch.tsx +++ b/frontend/components/MainPage/sections/RewardsSection/StakingRewardsThisEpoch.tsx @@ -38,6 +38,9 @@ const useEpochEndTime = () => { return { data, isLoading }; }; +/** + * Staking rewards for the current epoch + */ export const StakingRewardsThisEpoch = () => { const { data: epochEndTimeInMs } = useEpochEndTime(); diff --git a/frontend/components/MainPage/sections/RewardsSection/index.tsx b/frontend/components/MainPage/sections/RewardsSection/index.tsx index d64cb34a..44698a73 100644 --- a/frontend/components/MainPage/sections/RewardsSection/index.tsx +++ b/frontend/components/MainPage/sections/RewardsSection/index.tsx @@ -35,8 +35,9 @@ const DisplayRewards = () => { const reward = getFormattedReward(availableRewardsForEpochEth); const earnedTag = useMemo(() => { - if (isStakingRewardsDetailsLoading && !isStakingRewardsDetailsError) + if (isStakingRewardsDetailsLoading && !isStakingRewardsDetailsError) { return ; + } if (isEligibleForRewards) { return Earned; } diff --git a/frontend/context/RewardProvider.tsx b/frontend/context/RewardProvider.tsx index dab0b040..fe0a29ed 100644 --- a/frontend/context/RewardProvider.tsx +++ b/frontend/context/RewardProvider.tsx @@ -63,23 +63,24 @@ const useStakingRewardsDetails = () => { token!, ), queryFn: async () => { - if (!multisig || !token || !selectedStakingProgramId) return null; - const response = - await selectedAgentConfig.serviceApi.getAgentStakingRewardsInfo({ - agentMultisigAddress: multisig, - serviceId: token, - stakingProgramId: selectedStakingProgramId, - chainId: currentChainId, - }); + try { + const response = + await selectedAgentConfig.serviceApi.getAgentStakingRewardsInfo({ + agentMultisigAddress: multisig!, + serviceId: token!, + stakingProgramId: selectedStakingProgramId!, + chainId: currentChainId, + }); - if (!response) return null; + if (!response) return null; - try { const parsed = StakingRewardsInfoSchema.parse(response); return parsed; } catch (e) { console.error('Error parsing staking rewards info', e); } + + return null; }, enabled: !!isOnline && diff --git a/frontend/service/agents/Memeooor.ts b/frontend/service/agents/Memeooor.ts index 81f84267..956304b7 100644 --- a/frontend/service/agents/Memeooor.ts +++ b/frontend/service/agents/Memeooor.ts @@ -48,7 +48,7 @@ export abstract class MemeooorBaseService extends StakedAgentService { stakingTokenProxyContract.minStakingDeposit(), stakingTokenProxyContract.tsCheckpoint(), activityChecker.livenessRatio(), - activityChecker.getMultisigNonces(), + activityChecker.getMultisigNonces(agentMultisigAddress), ]; const multicallResponse = await provider.all(contractCalls); @@ -82,13 +82,17 @@ export abstract class MemeooorBaseService extends StakedAgentService { const lastMultisigNonces = serviceInfo[2]; const nowInSeconds = Math.floor(Date.now() / 1000); - const [isEligibleForRewards] = await provider.all([ - activityChecker.isRatioPass( - currentMultisigNonces, - lastMultisigNonces, - Math.ceil(nowInSeconds - tsCheckpoint), - ), - ]); + const isServiceStaked = serviceInfo[2].length > 0; + + const [isEligibleForRewards] = isServiceStaked + ? await provider.all([ + activityChecker.isRatioPass( + currentMultisigNonces, + lastMultisigNonces, + Math.ceil(nowInSeconds - tsCheckpoint), + ), + ]) + : [false]; const availableRewardsForEpoch = Math.max( rewardsPerSecond * livenessPeriod, // expected rewards for the epoch