Skip to content

Commit

Permalink
fix obvious bug where claimFeesUsd wasn't being set
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckbergeron committed Jul 6, 2023
1 parent 78f5903 commit 9fabb0a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions packages/library/src/claimerProfitablePrizeTxs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,15 @@ const calculateProfit = async (
);
printSpacer();

// To push through a non-profitable tx for debugging:
// const profitable = true;
const profitable = netProfitUsd > MIN_PROFIT_THRESHOLD_USD;
const profitable = claimCount > 1;
logTable({
MIN_PROFIT_THRESHOLD_USD: `$${MIN_PROFIT_THRESHOLD_USD}`,
'Net profit (USD)': `$${roundTwoDecimalPlaces(netProfitUsd)}`,
'Profitable?': profitable ? '✔' : '✗',
});
printSpacer();

if (claimCount > 0) {
if (profitable) {
console.log(chalk.yellow(`Submitting transaction to claim ${claimCount} prize(s):`));
logClaims(claimsSlice);
} else {
Expand Down Expand Up @@ -570,21 +568,19 @@ const getClaimInfo = async (
chalk.dim(`($${nextClaimFeesUsd})`),
);
printSpacer();
// console.log(chalk.dim(`if ((nextClaimFeesUsd - claimFeesUsd) > totalCostUsd)`));
// console.log(chalk.dim(`($${nextClaimFeesUsd} - $${claimFeesUsd}) > $${totalCostUsd}`));

// To push through a non-profitable tx for debugging:
// To push through 1 non-profitable tx for debugging:
// if (numClaims === 1) {
// claimCount = numClaims;
// claimFees = nextClaimFees;
// if (numClaims === 1) {
// return { claimCount, claimFeesUsd, totalCostUsd };
// }

if (nextClaimFeesUsd - claimFeesUsd > totalCostUsd) {
console.log('true');
claimCount = numClaims;
claimFees = nextClaimFees;
claimFeesUsd = nextClaimFeesUsd;
} else {
console.log(`false`);
break;
}
}
Expand Down

0 comments on commit 9fabb0a

Please sign in to comment.