Last active
September 14, 2023 23:35
-
-
Save chuckbergeron/9dbf6cf9e80fe00daaa48e4f497a53c2 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 calculateProfit = async ( | |
gasCostUsd: number, | |
context: DrawAuctionContext, | |
): Promise<boolean> => { | |
const grossProfitUsd = | |
context.state === DrawAuctionState.RngStartVrfHelper | |
? context.rngExpectedRewardUsd | |
: context.rngRelayExpectedRewardUsd; | |
let netProfitUsd; | |
if (context.state === DrawAuctionState.RngStartVrfHelper) { | |
netProfitUsd = grossProfitUsd - gasCostUsd - context.rngFeeUsd; | |
} else { | |
netProfitUsd = grossProfitUsd - gasCostUsd; | |
} | |
const profitable = netProfitUsd > MIN_PROFIT_THRESHOLD_USD; | |
return profitable; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment