Files
zeekayandHanzo Dev 33b43f3682 v3v4: decomplect the V3→V4 migration tooling (Rob Pike pass) + canonical RUNBOOK
The migration EXECUTED on mainnet 2026-07-05 (V4 PoolManager
0x2e317c5ce2c3e3aa720a3bb7f366f5959d940d4c, LiquidityDeployer
0x9888015bd7cda1905bbebf560f800731772957fd handed to the DAO Safe). Logic is
proven — this only removes cruft, unifies one way to do each thing, and rewrites
the docs. No proven behavior changed; verified by re-running the full pipeline.

Deleted / simplified:
- execute.py: dead `_await_pending_nonce` (never called); dead `ZERO` const;
  dead `Q96` import; inline `from v4math import liquidity_for_amount0` hoisted to
  the top import.
- Env surface trimmed to the genuinely operator-tuned knobs. Dropped never-set
  overrides: PLAN/STATE (now HERE-relative), READ_POD (= RPC_PODS[1], removing a
  vacuous len>1 guard), V4CORE_ART/LD_ART (now derived via the contracts/lib/v4-core
  symlink — no ~/work absolute path to keep in sync), snapshot OUT/RPC/TRANSPORT,
  investigate hardcoded ctx. Kept: DRY_RUN/EXECUTE, LUX_PRIVATE_KEY, GAS_PRICE_GWEI,
  SLIPPAGE_BPS, ORACLE_TICK_BAND, ONESIDED_MAX_WLUX, ONESIDED_BAND_TICKS, FINALIZE,
  ORACLE, KCTX/KNS, RPC_PODS.
- snapshot.py: collapsed the dual http/kubectl transport to kubectl-exec only,
  matching execute.py + investigate_all.py (one transport, one way); dropped the
  urllib path and the redundant `except (DecodingError, Exception)`.
- investigate_all.py: honor KCTX/KNS/KPOD from env (the Makefile already passes them).
- v4math.py: hoist `import decimal, math` to module top.
- Makefile: drop the now-dead TRANSPORT=kubectl from the snapshot target.

Load-bearing live fixes LEFT INTACT (why the run worked, do not weaken):
no-gossip nonce reconcile (_our_tx_mined), latest-based drift detection (not
pending), checksummed tx `to`, 5-validator broadcast at ≥250 gwei.

Docs:
- RUNBOOK.md rewritten as the single canonical, deterministic replay guide:
  EXECUTED status + live addresses, chain-heartbeat suspend requirement, the
  one-way pipeline (snapshot→plan→test→migrate dry-run→migrate→finalize),
  post-reboot re-run, surviving-env table, one-sided oracle dual-control.
- v3v4/LLM.md refreshed (concise agent guide, CLAUDE.md symlinks to it).
- top-level LLM.md: added a pointer/status line for v3v4 (distinct from Quasar).

Verified after cleanup: make test 16/16, python3 tools/test_red_oracle.py PASS,
and make snapshot && make plan && make migrate (dry-run) reconciles clean against
live chain (deploys + all steps report already-done, no broadcast).

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-05 10:16:32 -07:00

56 lines
2.5 KiB
Makefile

# Lux mainnet V3 -> V4 liquidity migration (DEX LP move; NOT the Quasar network migration).
# One entrypoint. Everything derives from live chain state. DRY_RUN by default.
#
# make snapshot # read all treasury V3 positions from live 96369
# make plan # classify + accounting table -> tools/plan.json
# make test # foundry unit + fuzz tests for LiquidityDeployer
# make build # canonical deployable artifacts (via_ir)
# make migrate # DRY-RUN staged executor (no broadcast) [DRY_RUN=1 default]
# make migrate DRY_RUN=0 # BROADCAST to all 5 validators (needs LUX_PRIVATE_KEY)
# make investigate # full NPM ownership map (who owns what; LETH resolution)
#
# Config (override on the command line): KCTX, KNS, GAS_PRICE_GWEI, SLIPPAGE_BPS, ORACLE
SHELL := /bin/bash
TOOLS := tools
CONTRACTS := contracts
KCTX ?= do-sfo3-lux-k8s
KNS ?= lux-mainnet
GAS_PRICE_GWEI ?= 250
SLIPPAGE_BPS ?= 100
DRY_RUN ?= 1
ORACLE ?= $(TOOLS)/oracle.json
ORACLE_TICK_BAND ?= 2000 # max |oracleTick - expected_tick| for a one-sided bid
ONESIDED_MAX_WLUX ?= 5000000000000000000000000 # 5,000,000e18 hard cap per one-sided pool
FINALIZE ?= 0 # 1 => zero LD approvals + transferOwnership LD->DAO Safe
export FOUNDRY_DISABLE_NIGHTLY_WARNING := 1
.PHONY: setup snapshot plan investigate test build migrate clean
EXECUTE := $(if $(filter 0,$(DRY_RUN)),1,0)
setup: ## clone pinned v4-core deps if missing (deterministic build inputs)
@bash scripts/setup.sh
snapshot: ## enumerate treasury V3 positions from live chain
cd $(TOOLS) && KCTX=$(KCTX) KNS=$(KNS) python3 snapshot.py
investigate: ## full NPM ownership map (all 149 NFTs) + LETH resolution
cd $(TOOLS) && KCTX=$(KCTX) KNS=$(KNS) python3 investigate_all.py
plan: ## classification + accounting table -> plan.json
cd $(TOOLS) && python3 build_plan.py
test: ## foundry unit + fuzz tests (fast profile)
cd $(CONTRACTS) && FOUNDRY_PROFILE=test forge test -vv
build: ## canonical deployable artifacts (via_ir, optimizer 44444444, bytecode_hash=none)
cd $(CONTRACTS) && forge build src/LiquidityDeployer.sol
migrate: ## staged executor. DRY_RUN=1 (default) simulates; DRY_RUN=0 broadcasts.
cd $(TOOLS) && EXECUTE=$(EXECUTE) KCTX=$(KCTX) KNS=$(KNS) \
GAS_PRICE_GWEI=$(GAS_PRICE_GWEI) SLIPPAGE_BPS=$(SLIPPAGE_BPS) \
ORACLE_TICK_BAND=$(ORACLE_TICK_BAND) ONESIDED_MAX_WLUX=$(ONESIDED_MAX_WLUX) \
FINALIZE=$(FINALIZE) ORACLE=$(notdir $(ORACLE)) python3 execute.py
clean:
rm -f $(TOOLS)/state.json