fix: address review feedback on bootstrap recovery (#644)

- Fix positions() ABI selector: uint256 -> uint8 (Stage enum)
- Replace fixed sleeps with polling loops checking on-chain timestamps
- Add trailing period to 'amplitude not reached.' error hint
- Remove 'was never set' feeDestination scenario (always set by deploy)
- Clarify warning comment scope in bootstrap-common.sh

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-19 22:59:21 +00:00
parent fbe8384342
commit 8cfbf74e89
3 changed files with 29 additions and 9 deletions

View file

@ -256,7 +256,7 @@ cast call $LM_ADDRESS "feeDestination()(address)" --rpc-url $BASE_RPC
cast call $LM_ADDRESS "feeDestinationLocked()(bool)" --rpc-url $BASE_RPC cast call $LM_ADDRESS "feeDestinationLocked()(bool)" --rpc-url $BASE_RPC
# Check if positions exist (non-zero liquidity = positions deployed) # Check if positions exist (non-zero liquidity = positions deployed)
cast call $LM_ADDRESS "positions(uint256)(int24,int24,uint128)" 1 --rpc-url $BASE_RPC cast call $LM_ADDRESS "positions(uint8)(int24,int24,uint128)" 1 --rpc-url $BASE_RPC
``` ```
### Recovery steps ### Recovery steps
@ -278,7 +278,7 @@ cast call $LM_ADDRESS "positions(uint256)(int24,int24,uint128)" 1 --rpc-url $BAS
4. **Verify** — confirm `cumulativeVolume > 0` (Step 7) 4. **Verify** — confirm `cumulativeVolume > 0` (Step 7)
5. **If `feeDestination` needs correction** (e.g., was never set or was set to the wrong address): 5. **If `feeDestination` needs correction** (e.g., was set to the wrong address):
```bash ```bash
# Only works if feeDestinationLocked is false # Only works if feeDestinationLocked is false
cast send $LM_ADDRESS \ cast send $LM_ADDRESS \

View file

@ -121,7 +121,7 @@ fund_liquidity_manager() {
bootstrap_vwap() { bootstrap_vwap() {
detect_swap_router detect_swap_router
# WARNING: If the second recenter() below fails mid-sequence, the LM is left # WARNING: If the second recenter() call later in this function fails mid-sequence, the LM is left
# with positions deployed but cumulativeVolume == 0 (partial bootstrap). # with positions deployed but cumulativeVolume == 0 (partial bootstrap).
# For mainnet recovery see docs/mainnet-bootstrap.md or scripts/recover-bootstrap.sh. # For mainnet recovery see docs/mainnet-bootstrap.md or scripts/recover-bootstrap.sh.
# Idempotency guard: if a previous run already bootstrapped VWAP, skip. # Idempotency guard: if a previous run already bootstrapped VWAP, skip.

View file

@ -139,8 +139,17 @@ if [[ "$NOW" -lt "$COOLDOWN_END" ]]; then
if [[ "$DRY_RUN" == "true" ]]; then if [[ "$DRY_RUN" == "true" ]]; then
exit 0 exit 0
fi fi
info "Waiting ${REMAINING}s for cooldown ..." info "Polling for recenter cooldown to elapse ..."
sleep "$REMAINING" while true; do
NOW="$(cast block latest --rpc-url "$RPC_URL" --field timestamp 2>/dev/null || echo "0")"
if [[ "$NOW" -ge "$COOLDOWN_END" ]]; then
info "Recenter cooldown elapsed."
break
fi
REMAINING=$(( COOLDOWN_END - NOW ))
info " ${REMAINING}s remaining ..."
sleep 5
done
fi fi
# ── Optional: extra seed buy ───────────────────────────────────────── # ── Optional: extra seed buy ─────────────────────────────────────────
@ -173,9 +182,20 @@ if [[ -n "$SEED_ETH" && -n "$KRAIKEN" ]]; then
"($WETH,$KRAIKEN,10000,$DEPLOYER_ADDR,$SEED_WEI,0,$SQRT_LIMIT)" "($WETH,$KRAIKEN,10000,$DEPLOYER_ADDR,$SEED_WEI,0,$SQRT_LIMIT)"
info "Seed buy complete." info "Seed buy complete."
# Wait for cooldown after potential recenter trigger # Poll until recenter cooldown elapses
info "Waiting 65s for recenter cooldown ..." info "Polling for recenter cooldown to elapse ..."
sleep 65 LAST_RECENTER_AFTER="$(cast call --rpc-url "$RPC_URL" "$LM_ADDRESS" "lastRecenterTime()(uint256)" 2>/dev/null || echo "0")"
COOLDOWN_TARGET=$(( LAST_RECENTER_AFTER + 60 ))
while true; do
NOW="$(cast block latest --rpc-url "$RPC_URL" --field timestamp 2>/dev/null || echo "0")"
if [[ "$NOW" -ge "$COOLDOWN_TARGET" ]]; then
info "Recenter cooldown elapsed."
break
fi
REMAINING=$(( COOLDOWN_TARGET - NOW ))
info " ${REMAINING}s remaining ..."
sleep 5
done
fi fi
fi fi
@ -191,7 +211,7 @@ if ! cast send --rpc-url "$RPC_URL" --private-key "$PRIVATE_KEY" \
"$LM_ADDRESS" "recenter()" 2>&1; then "$LM_ADDRESS" "recenter()" 2>&1; then
error "recenter() reverted. Check the revert reason above." error "recenter() reverted. Check the revert reason above."
error "Common causes:" error "Common causes:"
error " - 'amplitude not reached' -> need larger seed buy (use --seed-eth with --kraiken)" error " - 'amplitude not reached.' -> need larger seed buy (use --seed-eth with --kraiken)"
error " - 'price deviated from oracle' -> wait for TWAP history" error " - 'price deviated from oracle' -> wait for TWAP history"
error " - 'recenter cooldown' -> wait 60s and retry" error " - 'recenter cooldown' -> wait 60s and retry"
exit 1 exit 1