Skip to content

Commit

Permalink
feat: Add tsCheckpoint to getAgentStakingRewardsInfo function
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed Jun 17, 2024
1 parent bccc507 commit 9672712
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions frontend/service/Autonolas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const getAgentStakingRewardsInfo = async ({
serviceStakingTokenMechUsageContract.rewardsPerSecond(),
serviceStakingTokenMechUsageContract.calculateStakingReward(serviceId),
serviceStakingTokenMechUsageContract.minStakingDeposit(),
serviceStakingTokenMechUsageContract.tsCheckpoint(),
];

await gnosisMulticallProvider.init();
Expand All @@ -79,6 +80,7 @@ const getAgentStakingRewardsInfo = async ({
rewardsPerSecond,
accruedServiceStakingRewards,
minimumStakingDeposit,
lastTsCheckpoint,
] = multicallResponse;

/**
Expand All @@ -97,17 +99,16 @@ const getAgentStakingRewardsInfo = async ({
uint256 inactivity;}
*/

const livenessRatioFormatted = livenessRatio / 1e18;

const multisigNonce = serviceInfo[2][1];

const eligibleRequests = mechRequestCount - multisigNonce;

const eligibilityMargin =
livenessPeriod * livenessRatioFormatted +
const requiredMechRequests =
(Math.ceil(Math.max(livenessPeriod, Date.now() * 1000 - lastTsCheckpoint)) *
livenessRatio) /
1e18 +
REQUIRED_MECH_REQUESTS_SAFETY_MARGIN;

const isEligibleForRewards = eligibleRequests >= eligibilityMargin;
const mechRequestCountOnLastCheckpoint = serviceInfo[2][1];
const eligibleRequests = mechRequestCount - mechRequestCountOnLastCheckpoint;

const isEligibleForRewards = eligibleRequests >= requiredMechRequests;

const availableRewardsForEpoch = rewardsPerSecond * livenessPeriod;

Expand Down

0 comments on commit 9672712

Please sign in to comment.