Last active
September 19, 2023 18:26
-
-
Save chuckbergeron/19dc6923b0a93d7701afa6cf90011638 to your computer and use it in GitHub Desktop.
PoolTogether v5 Hyperstructure - Prize Claiming Bot, main() Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Contract, BigNumber } from 'ethers'; | |
import { JsonRpcProvider } from '@ethersproject/providers' | |
import { formatUnits } from '@ethersproject/units'; | |
import { | |
computeDrawWinners, | |
downloadContractsBlob, | |
flagClaimedRpc, | |
Claim, | |
ContractsBlob, | |
} from '@generationsoftware/pt-v5-utils-js'; | |
import groupBy from 'lodash.groupby'; | |
// The params required by the `claimPrizes()` contract | |
// function on the Claimer.sol contract | |
interface ClaimPrizesParams { | |
vault: string; | |
tier: number; | |
winners: string[]; | |
prizeIndices: number[][]; | |
feeRecipient: string; | |
minVrgdaFeePerClaim: string; | |
} | |
const CONTRACTS_VERSION = { | |
major: 1, | |
minor: 0, | |
patch: 0, | |
}; | |
// the address you want earned fees to accrue to | |
const FEE_RECIPIENT = '0x0000000000000000000000000000000000000000' | |
const CHAIN_ID = 10; // Optimism | |
const readProvider = new JsonRpcProvider(YOUR_JSON_RPC_PROVIDER_URL); | |
const main = async () => { | |
const claimerContract = getClaimerContract(chainId, readProvider, contracts) | |
const claims: Claim[] = await getClaims(); | |
const unclaimedClaimsGrouped = await findAndGroupUnclaimed(claims) | |
await loopUnclaimedGroups(unclaimedClaimsGrouped, claimerContract) | |
} | |
main() | |
const getClaimerContract = (chainId: number, readProvider: Provider, contracts: ContractsBlob): Contract => { | |
const claimerContract = getContract( | |
'Claimer', | |
chainId, | |
readProvider, | |
contracts, | |
CONTRACTS_VERSION, | |
); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment