diff --git a/onchain/script/backtesting/AttackRunner.s.sol b/onchain/script/backtesting/AttackRunner.s.sol index 351ee35..10d2bd7 100644 --- a/onchain/script/backtesting/AttackRunner.s.sol +++ b/onchain/script/backtesting/AttackRunner.s.sol @@ -252,13 +252,18 @@ contract AttackRunner is Script { _executeSell(line); } else if (_eq(op, "recenter")) { vm.startBroadcast(RECENTER_PK); - // Capture direction: true = price moved up, false = price moved down. - // recenter() reverts (not returns false) when amplitude is insufficient, - // so a successful call is always a real recenter regardless of direction. - _lastRecenterIsUp = ILM(lmAddr).recenter(); - _hasRecentered = true; + // recenter() reverts when amplitude is insufficient (price hasn't moved far enough + // from the anchor center). Use try/catch so attacks with round-trip buy→sell cycles + // — where the net price movement is near zero — don't abort the whole script. + // A caught revert means no state change occurred; skip the snapshot for this step. + try ILM(lmAddr).recenter() returns (bool isUp) { + _lastRecenterIsUp = isUp; + _hasRecentered = true; + isRecenter = true; + } catch { + console.log("recenter: skipped (amplitude not reached)"); + } vm.stopBroadcast(); - isRecenter = true; } else if (_eq(op, "stake")) { _executeStake(line); } else if (_eq(op, "unstake")) {