Skip to content

Commit

Permalink
Merge branch 'fix/optimistic-rewards' into fix/service-update-on-start
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed Dec 9, 2024
2 parents 680a338 + b63c99b commit cdedcf4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
18 changes: 14 additions & 4 deletions frontend/context/RewardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,24 @@ const useStakingRewardsDetails = () => {
token!,
),
queryFn: async () => {
if (!multisig || !token || !selectedStakingProgramId) return;
const response = await currentAgent.serviceApi.getAgentStakingRewardsInfo(
{
agentMultisigAddress: multisig!,
serviceId: token!,
stakingProgramId: selectedStakingProgramId!,
agentMultisigAddress: multisig,
serviceId: token,
stakingProgramId: selectedStakingProgramId,
chainId: currentChainId,
},
);
return StakingRewardsInfoSchema.parse(response);

if (!response) return;

try {
const parsed = StakingRewardsInfoSchema.parse(response);
return parsed;
} catch (e) {
console.error('Error parsing staking rewards info', e);
}
},
enabled:
!!isOnline &&
Expand Down Expand Up @@ -133,6 +142,7 @@ export const RewardProvider = ({ children }: PropsWithChildren) => {
refetch: refetchStakingRewardsDetails,
isFetched: isStakingRewardsDetailsFetched,
} = useStakingRewardsDetails();

const {
data: availableRewardsForEpoch,
refetch: refetchAvailableRewardsForEpoch,
Expand Down
11 changes: 8 additions & 3 deletions frontend/types/Autonolas.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { z } from 'zod';

const zodBigNumber = z.object({
_isBigNumber: z.boolean(),
_hex: z.string().startsWith('0x'),
});

export const StakingRewardsInfoSchema = z.object({
// mechRequestCount: z.number(),
serviceInfo: z.array(z.unknown()),
livenessPeriod: z.number(),
livenessRatio: z.number(),
rewardsPerSecond: z.number(),
livenessPeriod: zodBigNumber,
livenessRatio: zodBigNumber,
rewardsPerSecond: zodBigNumber,
isEligibleForRewards: z.boolean(),
availableRewardsForEpoch: z.number(),
accruedServiceStakingRewards: z.number(),
Expand Down

0 comments on commit cdedcf4

Please sign in to comment.