Skip to content

Commit

Permalink
Merge pull request #31 from ProjectOpenSea/fix-updateStatus-issue
Browse files Browse the repository at this point in the history
drop denominator=1 logic in updateStatus
  • Loading branch information
0age authored Feb 28, 2024
2 parents f3b7b89 + b788e8c commit 1b0919f
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/core/lib/OrderValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ contract OrderValidator is Executor, ZoneInteraction {
// Retrieve the order status using the derived order hash.
OrderStatus storage orderStatus = _orderStatus[orderHash];

bool hasCarryOrNoNumerator = numerator == 0;
bool hasCarry = false;

uint256 orderStatusSlot;
uint256 filledNumerator;
Expand Down Expand Up @@ -443,29 +443,12 @@ contract OrderValidator is Executor, ZoneInteraction {
MaxUint120
)

// If denominator of 1 supplied, fill entire remaining amount.
if eq(denominator, 1) {
// Set the amount to fill to the remaining amount.
numerator := sub(filledDenominator, filledNumerator)

hasCarryOrNoNumerator := iszero(numerator)

// Set the fill size to the current size.
denominator := filledDenominator

// Set the filled amount to the current size.
filledNumerator := filledDenominator

// Exit the "loop" early.
break
}

// If supplied denominator is equal to the current one:
if eq(denominator, filledDenominator) {
// Increment the filled numerator by the new numerator.
filledNumerator := add(numerator, filledNumerator)

hasCarryOrNoNumerator := gt(filledNumerator, denominator)
hasCarry := gt(filledNumerator, denominator)

// Exit the "loop" early.
break
Expand All @@ -482,7 +465,7 @@ contract OrderValidator is Executor, ZoneInteraction {
// Increment the filled numerator by the new numerator.
filledNumerator := add(numerator, filledNumerator)

hasCarryOrNoNumerator := gt(filledNumerator, denominator)
hasCarry := gt(filledNumerator, denominator)

// Check filledNumerator and denominator for uint120 overflow.
if or(
Expand Down Expand Up @@ -540,7 +523,7 @@ contract OrderValidator is Executor, ZoneInteraction {
}
}

if (hasCarryOrNoNumerator) {
if (hasCarry) {
if (revertOnInvalid) {
revert OrderAlreadyFilled(orderHash);
} else {
Expand Down

0 comments on commit 1b0919f

Please sign in to comment.