Skip to content

Instantly share code, notes, and snippets.

@chuckbergeron
Last active September 12, 2023 20:18
Show Gist options
  • Save chuckbergeron/56ec245ac460f4b1feaeb22b202a793d to your computer and use it in GitHub Desktop.
Save chuckbergeron/56ec245ac460f4b1feaeb22b202a793d to your computer and use it in GitHub Desktop.
PoolTogether v5 Hyperstructure - Prize Claiming Bot, Find and Group Unclaimed
const findAndGroupUnclaimed = async (claims: Claim[]) => {
// Cross-reference claimed prizes to flag if a prize has been claimed or not
claims = await flagClaimedRpc(readProvider, contracts, claims);
let unclaimedClaims = claims.filter((claim) => !claim.claimed);
console.log(`${unclaimedClaims.length} prizes remaining to be claimed...`);
if (unclaimedClaims.length === 0) {
console.log(`No prizes left to claim. Exiting ...`);
return;
}
// Sort unclaimed claims by tier so largest prizes (with the largest rewards) are first
unclaimedClaims = unclaimedClaims.sort((a, b) => a.tier - b.tier);
// Group claims by vault & tier
const unclaimedClaimsGrouped = groupBy(unclaimedClaims, (item) => [item.vault, item.tier]);
return unclaimedClaimsGrouped;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment