Merge pull request 'fix: fix: Debug failing round-trip-safe attack in evolution fitness (#595)' (#602) from fix/issue-595 into master

This commit is contained in:
johba 2026-03-12 09:35:19 +01:00
commit a075f8bd61

View file

@ -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 buysell 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")) {