2026-03-13 11:55:22 +00:00
|
|
|
#!/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
|
2026-03-14 20:58:34 +00:00
|
|
|
$CAST rpc --rpc-url "$RPC_URL" anvil_setCode "0xf6a3eef9088A255c32b6aD2025f83E57291D9011" "0x" 2>/dev/null || true
|
2026-03-13 11:55:22 +00:00
|
|
|
|
|
|
|
|
# 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]+')
|
2026-03-17 23:37:01 +00:00
|
|
|
[[ -n "$KRK" ]] || die "Could not extract Kraiken address from deploy output"
|
2026-03-13 11:55:22 +00:00
|
|
|
STAKE=$(echo "$DEPLOY_OUT" | grep -oP 'Stake deployed: \K0x[a-fA-F0-9]+')
|
2026-03-17 23:37:01 +00:00
|
|
|
[[ -n "$STAKE" ]] || die "Could not extract Stake address from deploy output"
|
2026-03-13 11:55:22 +00:00
|
|
|
OPT=$(echo "$DEPLOY_OUT" | grep -oP 'Optimizer deployed: \K0x[a-fA-F0-9]+')
|
2026-03-17 23:37:01 +00:00
|
|
|
[[ -n "$OPT" ]] || die "Could not extract Optimizer address from deploy output"
|
2026-03-13 11:55:22 +00:00
|
|
|
LM=$(echo "$DEPLOY_OUT" | grep -oP 'LiquidityManager deployed: \K0x[a-fA-F0-9]+')
|
|
|
|
|
|
|
|
|
|
[[ -n "$LM" ]] || die "Could not extract LiquidityManager address from deploy output"
|
|
|
|
|
|
2026-03-16 12:02:17 +00:00
|
|
|
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"
|
|
|
|
|
|
2026-03-13 11:55:22 +00:00
|
|
|
cat > "$ONCHAIN_DIR/deployments-local.json" << EOF
|
|
|
|
|
{
|
|
|
|
|
"contracts": {
|
|
|
|
|
"Kraiken": "$KRK",
|
|
|
|
|
"Stake": "$STAKE",
|
|
|
|
|
"LiquidityManager": "$LM",
|
2026-03-16 12:02:17 +00:00
|
|
|
"OptimizerProxy": "$OPT",
|
|
|
|
|
"Pool": "$POOL",
|
|
|
|
|
"V3Factory": "$V3_FACTORY"
|
2026-03-13 11:55:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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"
|