Skip to content

Commit

Permalink
fix: adjust verifier formulas to epoch 3
Browse files Browse the repository at this point in the history
  • Loading branch information
leoni-q committed Apr 27, 2024
1 parent 1654cba commit eac0b4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion epoch-verifier/src/data/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ export function individualDonationsByProposals(context: Context): Map<Address, b
}

export function rewardsByProject(context: Context): Map<Address, Reward> {
return new Map(context.rewards.map((r) => [r.proposal, r] as const))
return new Map(context.rewards
.filter(r => r.matched !== BigInt(0))
.map((r) => [r.proposal, r] as const)
);
}
2 changes: 1 addition & 1 deletion epoch-verifier/src/data/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class HttpFetcher {
}

async apiGetAllocations(epoch: number): Promise<AllocationRecord[] | null> {
return this._get_array(`/allocations/epoch/${epoch}`, "users' allocations", AllocationImpl, (data: ApiAllocations) => data.allocations)
return this._get_array(`/allocations/epoch/${epoch}?includeZeroAllocations=true`, "users' allocations", AllocationImpl, (data: ApiAllocations) => data.allocations)
}

async apiGetRewards(epoch: number): Promise<Reward[] | null>{
Expand Down
9 changes: 6 additions & 3 deletions epoch-verifier/src/verifications/donations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export function verifyMatchingFundFromEpochInfo(context: Context): VerificationR
}

export function verifyAllEpochRewards(context: Context): VerificationResult {
const allBudgets = context.epochInfo.individualRewards + context.epochInfo.ppf + context.epochInfo.matchedRewards + context.epochInfo.communityFund + context.epochInfo.operationalCost
return assertEq(allBudgets, context.epochInfo.stakingProceeds)
const allBudgets = context.epochInfo.individualRewards + context.epochInfo.ppf - context.epochInfo.patronsRewards + context.epochInfo.matchedRewards + context.epochInfo.communityFund + context.epochInfo.operationalCost
return assertEq(allBudgets, context.epochInfo.stakingProceeds, BigInt(100))
}

export function verifyTotalWithdrawals(context: Context): VerificationResult {
Expand All @@ -77,6 +77,9 @@ export function verifyTotalWithdrawals(context: Context): VerificationResult {
.map(([user, donationsSum]) => context.budgets.get(user)! - donationsSum)
.reduce((acc, user_claimed) => acc + user_claimed, BigInt(0))

const rewards = context.rewards.reduce((acc, reward) => acc + reward.allocated + reward.matched, BigInt(0))
const rewards = context.rewards
.filter((reward) => reward.matched !== BigInt(0))
.reduce((acc, reward) => acc + reward.allocated + reward.matched, BigInt(0))

return assertEq(claimed + rewards, context.epochInfo.totalWithdrawals)
}

0 comments on commit eac0b4b

Please sign in to comment.