Skip to content

Commit

Permalink
👷🏻‍♂️ Add check for reduce-only co specifying zero size delta to prev…
Browse files Browse the repository at this point in the history
…ent griefing
  • Loading branch information
JaredBorders committed Dec 5, 2023
1 parent ae5c23d commit e3c0de5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Engine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ contract Engine is IEngine, EIP712, EIP7412 {
_withdrawEth(msg.sender, _co.orderDetails.accountId, _fee);

/// @notice get size delta from order details
/// @dev up to the caller to not waste gas by passing in a size delta of zero
int128 sizeDelta = _co.orderDetails.sizeDelta;

/// @notice handle reduce only orders
Expand All @@ -473,8 +472,9 @@ contract Engine is IEngine, EIP712, EIP7412 {
return (retOrder, 0);
}

// ensure incoming size delta is NOT the same sign; i.e. reduce only orders cannot increase position size
if (positionSize.isSameSign(sizeDelta)) {
// ensure incoming size delta is non-zero and NOT the same sign;
// i.e. reduce only orders cannot increase position size
if (sizeDelta == 0 || positionSize.isSameSign(sizeDelta)) {
return (retOrder, 0);
}

Expand Down

0 comments on commit e3c0de5

Please sign in to comment.