harb/scripts/harb-evaluator/bootstrap-light.sh
johba 6a1bb71463 fix: config.ts reads infrastructure.weth but no tooling generates it (#611)
Add infrastructure.weth to deployments-local.json output in both
bootstrap-common.sh (write_deployments_json) and bootstrap-light.sh,
so non-Base local forks get the correct WETH address from the
deployment file instead of silently falling back to the Base hardcode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 09:29:28 +00:00

81 lines
3.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Lightweight bootstrap for red-team / evaluator use.
# Starts only Anvil + deploys contracts. No ponder, no webapp, no txnbot.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
ONCHAIN_DIR="$REPO_ROOT/onchain"
RPC_URL="http://localhost:8545"
CAST="$HOME/.foundry/bin/cast"
FORGE="$HOME/.foundry/bin/forge"
log() { echo "[bootstrap-light] $*"; }
die() { log "ERROR: $*" >&2; exit 1; }
# 1. Start Anvil (docker)
log "Starting Anvil..."
cd "$REPO_ROOT"
sudo docker compose down -v 2>/dev/null || true
sudo docker compose up -d anvil
for i in $(seq 1 30); do
$CAST chain-id --rpc-url "$RPC_URL" 2>/dev/null && break
sleep 1
done
$CAST chain-id --rpc-url "$RPC_URL" >/dev/null 2>&1 || die "Anvil not responding"
log "Anvil running"
# 2. Clear ERC-4337 code from well-known addresses (fork safety)
DEPLOYER=$($CAST wallet address --mnemonic "test test test test test test test test test test test junk" 2>/dev/null)
log "Clearing code from deployer ($DEPLOYER) + feeDest"
$CAST rpc --rpc-url "$RPC_URL" anvil_setCode "$DEPLOYER" "0x" 2>/dev/null || true
$CAST rpc --rpc-url "$RPC_URL" anvil_setCode "0xf6a3eef9088A255c32b6aD2025f83E57291D9011" "0x" 2>/dev/null || true
# 3. Deploy contracts — capture output for addresses
log "Deploying contracts..."
cd "$ONCHAIN_DIR"
# Fix ownership of forge artifacts (docker creates root-owned files)
sudo chown -R "$(id -u):$(id -g)" cache out broadcast 2>/dev/null || true
rm -f deployments-local.json # force fresh
DEPLOY_OUT=$($FORGE script script/DeployLocal.sol --rpc-url "$RPC_URL" --broadcast 2>&1)
echo "$DEPLOY_OUT" | grep -E "^\[|deployed|complete|Summary" || true
# 4. Extract addresses from output and write deployments-local.json
KRK=$(echo "$DEPLOY_OUT" | grep -oP 'Kraiken deployed: \K0x[a-fA-F0-9]+')
[[ -n "$KRK" ]] || die "Could not extract Kraiken address from deploy output"
STAKE=$(echo "$DEPLOY_OUT" | grep -oP 'Stake deployed: \K0x[a-fA-F0-9]+')
[[ -n "$STAKE" ]] || die "Could not extract Stake address from deploy output"
OPT=$(echo "$DEPLOY_OUT" | grep -oP 'Optimizer deployed: \K0x[a-fA-F0-9]+')
[[ -n "$OPT" ]] || die "Could not extract Optimizer address from deploy output"
LM=$(echo "$DEPLOY_OUT" | grep -oP 'LiquidityManager deployed: \K0x[a-fA-F0-9]+')
[[ -n "$LM" ]] || die "Could not extract LiquidityManager address from deploy output"
POOL=$(echo "$DEPLOY_OUT" | grep -oP 'Pool: \K0x[a-fA-F0-9]+' | head -1)
[[ -n "$POOL" ]] || die "Could not extract Pool address from deploy output"
# Base Sepolia Uniswap V3 Factory — must match v3Factory constant in DeployLocal.sol
V3_FACTORY="0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24"
WETH=0x4200000000000000000000000000000000000006
cat > "$ONCHAIN_DIR/deployments-local.json" << EOF
{
"contracts": {
"Kraiken": "$KRK",
"Stake": "$STAKE",
"LiquidityManager": "$LM",
"OptimizerProxy": "$OPT",
"Pool": "$POOL",
"V3Factory": "$V3_FACTORY"
},
"infrastructure": {
"weth": "$WETH"
}
}
EOF
# 5. Verify
VWAP=$($CAST call --rpc-url "$RPC_URL" "$LM" "cumulativeVolume()(uint256)" 2>/dev/null || echo "0")
log "LiquidityManager: $LM"
log "cumulativeVolume: $VWAP"
[[ "$VWAP" != "0" ]] && log "✅ Bootstrap complete — VWAP active" || log "⚠️ VWAP not bootstrapped"