Skip to content

Commit a41e257

Browse files
fix: clear3 refuses a side with non-positive output or negative ratio
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cb756fc commit a41e257

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎src/concrete/raindex/RaindexV6.sol‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,16 @@ contract RaindexV6 is IRaindexV6, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
631631
ClearStateChangeV2 memory clearStateChange =
632632
calculateClearStateChange(aliceOrderIOCalculation, bobOrderIOCalculation);
633633

634+
// Each side must be one `takeOrders4` would take.
635+
if (
636+
!clearStateChange.aliceOutput.gt(LibDecimalFloat.FLOAT_ZERO)
637+
|| !clearStateChange.bobOutput.gt(LibDecimalFloat.FLOAT_ZERO)
638+
|| aliceOrderIOCalculation.IORatio.lt(LibDecimalFloat.FLOAT_ZERO)
639+
|| bobOrderIOCalculation.IORatio.lt(LibDecimalFloat.FLOAT_ZERO)
640+
) {
641+
revert ClearZeroAmount();
642+
}
643+
634644
Float aliceBounty = clearStateChange.aliceOutput.sub(clearStateChange.bobInput);
635645
Float bobBounty = clearStateChange.bobOutput.sub(clearStateChange.aliceInput);
636646

@@ -672,14 +682,6 @@ contract RaindexV6 is IRaindexV6, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
672682

673683
handleIO(aliceOrderIOCalculation);
674684
handleIO(bobOrderIOCalculation);
675-
676-
// Do this last so we don't swallow errors from the handle IO.
677-
// Slither false positive. clearStateChange is a memory variable that
678-
// cannot be modified by reentrancy, and clear3 is nonReentrant.
679-
//slither-disable-next-line reentrancy-balance
680-
if (clearStateChange.aliceOutput.isZero() && clearStateChange.bobOutput.isZero()) {
681-
revert ClearZeroAmount();
682-
}
683685
}
684686

685687
/// Main entrypoint into an order calculates the amount and IO ratio. Both

‎src/error/ErrRaindexV6.sol‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ error NegativePush();
4444
/// Throws when a negative bounty is calculated.
4545
error NegativeBounty();
4646

47-
/// Thrown when clear output amounts are both zero.
47+
/// Thrown when either side of a clear has a non-positive output or a negative
48+
/// IO ratio.
4849
error ClearZeroAmount();

0 commit comments

Comments
 (0)