Last active
September 14, 2023 21:43
-
-
Save chuckbergeron/53cbb706e45635f8f6188bc82ce8a302 to your computer and use it in GitHub Desktop.
PoolTogether v5 Hyperstructure - Draw Auction Bot, Calculate Profit
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
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