Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flickering debug for agents.fun #611

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const useEpochEndTime = () => {
return { data, isLoading };
};

/**
* Staking rewards for the current epoch
*/
export const StakingRewardsThisEpoch = () => {
const { data: epochEndTimeInMs } = useEpochEndTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ const DisplayRewards = () => {
const reward = getFormattedReward(availableRewardsForEpochEth);

const earnedTag = useMemo(() => {
if (isStakingRewardsDetailsLoading && !isStakingRewardsDetailsError)
if (isStakingRewardsDetailsLoading && !isStakingRewardsDetailsError) {
return <Skeleton.Input size="small" />;
}
if (isEligibleForRewards) {
return <Tag color="success">Earned</Tag>;
}
Expand Down
21 changes: 11 additions & 10 deletions frontend/context/RewardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
20 changes: 12 additions & 8 deletions frontend/service/agents/Memeooor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export abstract class MemeooorBaseService extends StakedAgentService {
stakingTokenProxyContract.minStakingDeposit(),
stakingTokenProxyContract.tsCheckpoint(),
activityChecker.livenessRatio(),
activityChecker.getMultisigNonces(),
activityChecker.getMultisigNonces(agentMultisigAddress),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the ABI, and it seems we’re supposed to pass the argument, which is the error I shared in the group. (Also, we were not catching hence moved inside "Try" block)

Screensh2PM

];
const multicallResponse = await provider.all(contractCalls);

Expand Down Expand Up @@ -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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were passing an empty array and the contract call was failing.

e Screen3M


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
Expand Down
Loading