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

@ -139,8 +139,17 @@ if [[ "$NOW" -lt "$COOLDOWN_END" ]]; then
if [[ "$DRY_RUN" == "true" ]]; then
exit 0
fi
info "Waiting ${REMAINING}s for cooldown ..."
sleep "$REMAINING"
info "Polling for recenter cooldown to elapse ..."
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
# ── 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)"
info "Seed buy complete."
# Wait for cooldown after potential recenter trigger
info "Waiting 65s for recenter cooldown ..."
sleep 65
# Poll until recenter cooldown elapses
info "Polling for recenter cooldown to elapse ..."
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
@ -191,7 +211,7 @@ if ! cast send --rpc-url "$RPC_URL" --private-key "$PRIVATE_KEY" \
"$LM_ADDRESS" "recenter()" 2>&1; then
error "recenter() reverted. Check the revert reason above."
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 " - 'recenter cooldown' -> wait 60s and retry"
exit 1