fix: track ts explicitly in DeployLocal bootstrap to avoid Forge block.timestamp reset

Forge resets block.timestamp to its pre-warp value after each state-changing
call (e.g. recenter()). The second vm.warp(block.timestamp + 301) in the VWAP
bootstrap was therefore warping to the same timestamp as the first warp, so
lastRecenterTime + 60 > block.timestamp and the second recenter() reverted
with "recenter cooldown".

Fix: store ts = block.timestamp + 301 before the first warp and increment it
explicitly (ts += 301) before the second warp, mirroring the same pattern
applied to VWAPFloorProtection.t.sol and SupplyCorruption.t.sol.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-13 22:45:22 +00:00
parent 1a410a30b7
commit df2f0a87e5

View file

@ -141,7 +141,10 @@ contract DeployLocal is Script {
console.log("\n[7/7] Bootstrapping VWAP with seed trade..."); console.log("\n[7/7] Bootstrapping VWAP with seed trade...");
// Step 1: Advance time so TWAP oracle has sufficient history. // Step 1: Advance time so TWAP oracle has sufficient history.
vm.warp(block.timestamp + 301); // Track ts explicitly Forge resets block.timestamp after state-changing calls,
// so block.timestamp + 301 would warp to the same value if used in Step 4.
uint256 ts = block.timestamp + 301;
vm.warp(ts);
// Step 2: Fund LM and place initial bootstrap positions. // Step 2: Fund LM and place initial bootstrap positions.
(bool funded,) = address(liquidityManager).call{ value: SEED_LM_ETH }(""); (bool funded,) = address(liquidityManager).call{ value: SEED_LM_ETH }("");
@ -155,7 +158,8 @@ contract DeployLocal is Script {
console.log(" Seed buy executed -> fee generated in anchor position"); console.log(" Seed buy executed -> fee generated in anchor position");
// Step 4: Warp forward so TWAP settles at post-buy price and cooldown elapses. // Step 4: Warp forward so TWAP settles at post-buy price and cooldown elapses.
vm.warp(block.timestamp + 301); ts += 301;
vm.warp(ts);
// Step 5: Second recenter records VWAP (bootstrap path + ethFee > 0). // Step 5: Second recenter records VWAP (bootstrap path + ethFee > 0).
liquidityManager.recenter(); liquidityManager.recenter();