Check PRIVATE_KEY env var first in BootstrapVWAPPhase2.s.sol, DeployBase.sol, and BaseDeploy.sol; fall back to .secret seed-phrase file when unset. This allows CI/CD environments to inject keys via environment variables while preserving the existing local .secret workflow unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
2.1 KiB
Solidity
56 lines
2.1 KiB
Solidity
// 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=<deployed LiquidityManager address>
|
|
*
|
|
* # Option A — env-var key (CI/CD):
|
|
* export PRIVATE_KEY=0x<hex-private-key>
|
|
* forge script script/BootstrapVWAPPhase2.s.sol --tc BootstrapVWAPPhase2 \
|
|
* --fork-url $BASE_RPC --broadcast
|
|
*
|
|
* # Option B — .secret seed-phrase file (local):
|
|
* echo "<seed phrase>" > .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));
|
|
|
|
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();
|
|
}
|
|
}
|