feat: OptimizerV3 with direct 2D staking-to-LP parameter mapping
Core protocol changes for launch readiness: - OptimizerV3: binary bear/bull mapping from (staking%, avgTax) — avoids exploitable AW 30-90 kill zone. Bear: AS=30%, AW=100, CI=0, DD=0.3e18. Bull: AS=100%, AW=20, CI=0, DD=1e18. UUPS upgradeable with __gap[48]. - Directional VWAP: only records prices on ETH inflow (buys), preventing sell-side dilution of price memory - Floor formula: unified max(scarcity, mirror, clamp) — VWAP mirror uses distance from adjusted VWAP as floor distance, no branching - PriceOracle (M-1 fix): correct fallback TWAP divisor (60000s, not 300s) - Access control (M-2 fix): deployer-only guard on one-time setters - Recenter rate limit (M-3 fix): 60-second cooldown for open recenters - Safe fallback params: recenter() optimizer-failure defaults changed from exploitable CI=50%/AW=50 to safe bear-mode CI=0/AW=100 - Recentered event for monitoring and indexing - VERSION bump to 2, kraiken-lib COMPATIBLE_CONTRACT_VERSIONS updated Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
21857ae8ca
commit
85350caf52
38 changed files with 3793 additions and 205 deletions
40
.claude/hooks/supervisor/on-error.sh
Executable file
40
.claude/hooks/supervisor/on-error.sh
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
# Claude Code PostToolUseFailure hook — fires when a tool call fails.
|
||||
#
|
||||
# Option D: bash pre-filter for known patterns, LLM triage for the rest.
|
||||
#
|
||||
# - API 500 → always triage (transient, likely needs nudge)
|
||||
# - API 429 → log + wait (rate limit, will resolve)
|
||||
# - Other tool errors → triage (might be important)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
SUPERVISOR_DIR="${SCRIPT_DIR%/hooks}"
|
||||
|
||||
INPUT=$(cat)
|
||||
|
||||
TOOL=$(echo "$INPUT" | jq -r '.tool_name // "unknown"')
|
||||
ERROR=$(echo "$INPUT" | jq -r '.error // .tool_error // "unknown"' | head -c 500)
|
||||
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // "unknown"')
|
||||
CWD=$(echo "$INPUT" | jq -r '.cwd // "unknown"')
|
||||
|
||||
# Bash pre-filter
|
||||
if echo "$ERROR" | grep -qi "429\|rate.limit"; then
|
||||
# Rate limited — log it, don't triage. It'll resolve.
|
||||
echo "[$(date -u +%FT%TZ)] RATE_LIMITED | $TOOL | $CWD" >> "${CCS_LOG_FILE:-/tmp/ccs-triage.log}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if echo "$ERROR" | grep -qi "500\|internal.server.error\|api_error"; then
|
||||
# API 500 — high chance agent is stuck on this. Triage.
|
||||
"$SUPERVISOR_DIR/triage.sh" "error:api_500" "$CWD" \
|
||||
"Tool: $TOOL | Error: $ERROR | Session: $SESSION_ID" &
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Other errors — could be anything. Let LLM decide.
|
||||
"$SUPERVISOR_DIR/triage.sh" "error:$TOOL" "$CWD" \
|
||||
"Tool: $TOOL | Error: $ERROR | Session: $SESSION_ID" &
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue