Skip to content

Instantly share code, notes, and snippets.

@chuckbergeron
Last active September 14, 2023 21:43
Show Gist options
  • Save chuckbergeron/53cbb706e45635f8f6188bc82ce8a302 to your computer and use it in GitHub Desktop.
Save chuckbergeron/53cbb706e45635f8f6188bc82ce8a302 to your computer and use it in GitHub Desktop.
PoolTogether v5 Hyperstructure - Draw Auction Bot, Calculate Profit
const checkBalance = (context: DrawAuctionContext) => {
const cannotAffordRngFee = context.relayer.rngFeeTokenBalance.lt(context.rngFeeAmount);
if (cannotAffordRngFee) {
console.warn(
`Need to increase relayer/bot's balance of '${context.rngFeeToken.symbol}' to pay RNG fee.`,
);
} else {
console.log('Sufficient balance ✔');
}
};
const increaseRngFeeAllowance = async (
signer,
context: DrawAuctionContext,
auctionContracts: AuctionContracts,
) => {
const rngFeeTokenContract = new ethers.Contract(context.rngFeeToken.address, ERC20Abi, signer);
const allowance = context.relayer.rngFeeTokenAllowance;
if (allowance.lt(context.rngFeeAmount)) {
const tx = await rngFeeTokenContract.approve(
auctionContracts.chainlinkVRFV2DirectRngAuctionHelperContract.address,
ethers.constants.MaxInt256,
);
await tx.wait();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment