@@ -64,7 +64,6 @@ import {
6464} from "../../lib/LibRaindex.sol " ;
6565import {RaindexV6FlashLender} from "../../abstract/RaindexV6FlashLender.sol " ;
6666import {LibBytes32Array} from "rain-solmem-0.1.28/src/lib/LibBytes32Array.sol " ;
67- import {LibBytes32Matrix} from "rain-solmem-0.1.28/src/lib/LibBytes32Matrix.sol " ;
6867
6968import {LibFormatDecimalFloat} from "rain-math-float-0.3.10/src/lib/format/LibFormatDecimalFloat.sol " ;
7069import {
@@ -314,7 +313,10 @@ contract RaindexV6 is IRaindexV7, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
314313 /// with a context of the order hash and the caller.
315314 function _doOrderPost (bytes32 orderHash , TaskV3[] calldata post ) internal {
316315 LibRaindex.doPost (
317- LibBytes32Matrix.matrixFrom (LibBytes32Array.arrayFrom (orderHash, bytes32 (uint256 (uint160 (msg .sender ))))),
316+ LibRaindex.callingContextColumn (
317+ CONTEXT_CALLING_CONTEXT_COLUMN,
318+ LibBytes32Array.arrayFrom (orderHash, bytes32 (uint256 (uint160 (msg .sender ))))
319+ ),
318320 post
319321 );
320322 }
@@ -346,6 +348,7 @@ contract RaindexV6 is IRaindexV7, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
346348 msg .sender ,
347349 quoteConfig.signedContext,
348350 new bytes32 [](0 ),
351+ false ,
349352 false
350353 );
351354 // true is quote3's "order is live" result required by IRaindexV7.
@@ -436,7 +439,8 @@ contract RaindexV6 is IRaindexV7, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
436439 msg .sender ,
437440 takeOrderConfig.signedContext,
438441 new bytes32 [](0 ),
439- true
442+ true ,
443+ false
440444 );
441445
442446 // Skip orders that are too expensive rather than revert as we have
@@ -630,7 +634,8 @@ contract RaindexV6 is IRaindexV7, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
630634 bobOrder.owner,
631635 bobSignedContext,
632636 new bytes32 [](0 ),
633- false
637+ false ,
638+ true
634639 );
635640 (, OrderIOCalculationV4 memory bobOrderIOCalculation ) = calculateOrderIO (
636641 bobOrder,
@@ -639,7 +644,8 @@ contract RaindexV6 is IRaindexV7, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
639644 aliceOrder.owner,
640645 aliceSignedContext,
641646 new bytes32 [](0 ),
642- false
647+ false ,
648+ true
643649 );
644650
645651 // Each side must be one `takeOrders5` would take. Given this, each
@@ -715,6 +721,8 @@ contract RaindexV6 is IRaindexV7, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
715721 /// single-order callers (`quote`, `clear4`).
716722 /// @param skipFailure If true, a reverting calculate eval or a stack shorter
717723 /// than `CALCULATE_ORDER_MIN_OUTPUTS` returns false instead of reverting.
724+ /// @param clearing Whether the order column includes the clearer row; true
725+ /// only for `clear4`.
718726 /// @return False if `skipFailure` caught a failure, in which case the
719727 /// calculation is zeroed and MUST NOT be used.
720728 /// @return The order IO calculation.
@@ -725,15 +733,23 @@ contract RaindexV6 is IRaindexV7, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
725733 address counterparty ,
726734 SignedContextV2[] memory signedContext ,
727735 bytes32 [] memory stateOverlay ,
728- bool skipFailure
736+ bool skipFailure ,
737+ bool clearing
729738 ) internal view returns (bool , OrderIOCalculationV4 memory ) {
730739 unchecked {
731740 bytes32 [][] memory context;
732741 {
733742 bytes32 [][] memory callingContext = new bytes32 [][](CALLING_CONTEXT_COLUMNS);
734- callingContext[CONTEXT_CALLING_CONTEXT_COLUMN - 1 ] = LibBytes32Array.arrayFrom (
735- order.hash (), bytes32 (uint256 (uint160 (order.owner))), bytes32 (uint256 (uint160 (counterparty)))
736- );
743+ callingContext[CONTEXT_CALLING_CONTEXT_COLUMN - 1 ] = clearing
744+ ? LibBytes32Array.arrayFrom (
745+ order.hash (),
746+ bytes32 (uint256 (uint160 (order.owner))),
747+ bytes32 (uint256 (uint160 (counterparty))),
748+ bytes32 (uint256 (uint160 (msg .sender )))
749+ )
750+ : LibBytes32Array.arrayFrom (
751+ order.hash (), bytes32 (uint256 (uint160 (order.owner))), bytes32 (uint256 (uint160 (counterparty)))
752+ );
737753
738754 // The calculations column holds the calculated max output and IO
739755 // ratio, which only become known after the calculate eval below.
0 commit comments