Skip to content

Instantly share code, notes, and snippets.

@chuckbergeron
Last active September 12, 2023 22:45
Show Gist options
  • Save chuckbergeron/825d53f3b6a51a887b2899f7e221868b to your computer and use it in GitHub Desktop.
Save chuckbergeron/825d53f3b6a51a887b2899f7e221868b to your computer and use it in GitHub Desktop.
PoolTogether v5 Hyperstructure - Prize Claiming Bot, Calculating Profitable Claims
const calculateProfit = async (
vault: string,
tierIndex: number,
claimerContract: Contract,
groupedClaims: any,
): Promise<ClaimPrizesParams> => {
const { claimCount, claimFeesUsd, totalCostUsd, minVrgdaFeePerClaim } =
await getClaimInfo(
claimerContract,
tierIndex,
groupedClaims,
);
const claimsSlice = groupedClaims.slice(0, claimCount);
const claimPrizesParams = buildParams(
vault,
tierIndex,
claimsSlice,
minVrgdaFeePerClaim,
);
return claimPrizesParams;
};
const buildParams = (
vault: string,
tier: number,
claims: Claim[],
minVrgdaFeePerClaim: string,
): ClaimPrizesParams => {
let winners: string[] = [];
let prizeIndices: number[][] = [];
claims.forEach((claim) => {
winners.push(claim.winner);
prizeIndices.push([claim.prizeIndex]);
});
return {
vault,
tier,
winners,
prizeIndices,
feeRecipient: FEE_RECIPIENT,
minVrgdaFeePerClaim,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment