// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.19; import { LiquidityManager } from "../src/LiquidityManager.sol"; import "forge-std/Script.sol"; /** * @title BootstrapVWAPPhase2 * @notice Second phase of the VWAP bootstrap for Base mainnet deployments. * * Run this script >= 60 seconds after DeployBase (or DeployBaseMainnet/DeployBaseSepolia) * finishes. The first recenter() sets lastRecenterTime; the 60-second cooldown must * elapse before this second recenter() can succeed. * * What this does: * - Calls liquidityManager.recenter() a second time. * - At this point cumulativeVolume == 0 (bootstrap path) and the seed buy has * generated ethFee > 0, so recenter() records the VWAP anchor. * - Asserts cumulativeVolume > 0 to confirm bootstrap success. * * Usage: * export LM_ADDRESS= * * # Option A — env-var key (CI/CD): * export PRIVATE_KEY=0x * forge script script/BootstrapVWAPPhase2.s.sol --tc BootstrapVWAPPhase2 \ * --fork-url $BASE_RPC --broadcast * * # Option B — .secret seed-phrase file (local): * echo "" > .secret * forge script script/BootstrapVWAPPhase2.s.sol --tc BootstrapVWAPPhase2 \ * --fork-url $BASE_RPC --broadcast */ contract BootstrapVWAPPhase2 is Script { function run() public { address lmAddress = vm.envAddress("LM_ADDRESS"); LiquidityManager lm = LiquidityManager(payable(lmAddress)); // PRIVATE_KEY=0 / empty silently falls back to .secret (0 is an invalid secp256k1 key). uint256 privateKey = vm.envOr("PRIVATE_KEY", uint256(0)); if (privateKey == 0) { string memory seedPhrase = vm.readFile(".secret"); privateKey = vm.deriveKey(seedPhrase, 0); } vm.startBroadcast(privateKey); console.log("Running VWAP bootstrap phase 2 on LiquidityManager:", lmAddress); lm.recenter(); uint256 cumVol = lm.cumulativeVolume(); require(cumVol > 0, "VWAP bootstrap failed: cumulativeVolume is still 0"); console.log("VWAP bootstrapped successfully. cumulativeVolume:", cumVol); vm.stopBroadcast(); } }