Skip to content

Commit

Permalink
fix: avoid underflowing when should revert(out())
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-something committed Nov 9, 2023
1 parent 62b44a4 commit d166038
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions contracts/JBTiered721DelegateStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {
}
}

event reserved(uint);
event leftToMint(uint);

/// @notice Record token mints in the provided tiers.
/// @param _amount The amount to base the mints on. All mints' price floors must fit within this amount.
/// @param _tierIds The tier IDs to mint from.
Expand Down Expand Up @@ -783,8 +786,7 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {

// Make sure there are enough units available.
if (
_storedTier.remainingQuantity - _numberOfReservedTokensOutstandingFor(msg.sender, _tierId, _storedTier)
== 0
_storedTier.remainingQuantity <= _numberOfReservedTokensOutstandingFor(msg.sender, _tierId, _storedTier)
) revert OUT();

// Mint the tokens.
Expand All @@ -802,6 +804,9 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {
leftoverAmount = leftoverAmount - _storedTier.price;
++_i;
}

emit reserved(_numberOfReservedTokensOutstandingFor(msg.sender, _tierId, _storedTier));
emit leftToMint(_storedTier.remainingQuantity);
}
}

Expand Down

0 comments on commit d166038

Please sign in to comment.