# Users cannot stop loss in AutoRange and AutoExit 

AutoRange/AutoExit call _validateSwap even when amountIn=0 (no swap), so TWAP deviation >1% reverts withdrawals, blocking automated stop-loss exits.

- Payout: Contest reward
- Severity: medium
- Program: Revert Lend
- Credited: ktg
- Disclosed: 2024-05-22
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-03-revert-lend-findings/issues/202
- Library page: https://bugbountylibrary.com/r/c4%3A2024-03-revert-lend%3AM-18
- Tags: domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic

**Target:** AutoRange/AutoExit automator contracts (Automator._validateSwap)
**Root cause:** Automator._validateSwap is invoked unconditionally after liquidity removal, even when amountIn=0 signals no swap is intended; the TWAP tick-difference check then reverts the whole execute call.
**Steps:**
1. Configure AutoRange for a position with maxTWAPTickDifference=100, TWAPSeconds=60.
2. Mock Uniswap V3 pool.observe so twapTick differs from currentTick by >100 ticks (~1%).
3. Call `autoRange.execute(ExecuteParams(tokenId, false, 0, "", liquidity, 0, 0, block.timestamp, reward))` with amountIn=0 (no swap).
4. Observe revert from TWAPCheckFailed inside _validateSwap despite no swap requested.
**How found:** Code reading of AutoRange.execute/AutoExit.execute flow: noticed _validateSwap called after _decreaseFullLiquidityAndCollect regardless of amountIn, and that amountIn=0 is documented as 'no swap', making the TWAP check unnecessary in that path.
**Exploitation:** Not an attack; operator-triggered execute reverts whenever price deviates >maxTWAPTickDifference from TWAP, so automated stop-loss/exit and no-swap withdrawals fail until price returns within band.
**Insight:** When a param like amountIn=0 explicitly disables an action, audit whether downstream validation for that action is still executed; guard checks on the same condition that gates the action.
