Skip to content

Claude/build dlmm bot uk6dq#23

Open
anunnaki13 wants to merge 20 commits into
yunus-0x:mainfrom
anunnaki13:claude/build-dlmm-bot-UK6dq
Open

Claude/build dlmm bot uk6dq#23
anunnaki13 wants to merge 20 commits into
yunus-0x:mainfrom
anunnaki13:claude/build-dlmm-bot-UK6dq

Conversation

@anunnaki13

Copy link
Copy Markdown

No description provided.

claude added 20 commits April 6, 2026 07:22
…et mode preset system

- Fix lessons.js evolveThresholds: rename minFeeTvlRatio → minFeeActiveTvlRatio (matches
  actual config key). Add null guard for maxVolatility so evolution skips when not configured.
- Add config.screening.maxVolatility (default null) and config.strategy.binsAbove (default 0)
- Add maxVolatility API filter to discoverPools() in screening.js
- New market-mode.js: 5 presets (bullish/bearish/sideways/volatile/conservative) that bundle
  binsAbove, stopLossPct, trailingTriggerPct, trailingDropPct, outOfRangeWaitMinutes,
  maxVolatility, minVolume, minOrganic, minHolders into a single mode switch
- New tools: set_market_mode, get_market_mode — available in SCREENER/MANAGER/GENERAL roles
- applyMarketModeOnStartup() called in index.js to restore persisted mode on restart
- Market mode displayed in all agent system prompts when not "auto"
- executor.js CONFIG_MAP: added binsAbove and maxVolatility as individually tunable keys

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
… guard

Critical fix — below-range OOR (token dump):
- Added Rule 4b: when active_bin < lower_bin && OOR > belowOORWaitMinutes (default 15m),
  close immediately. Position is now 100% base token with max IL and decaying.
  Previously only stop-loss at -50% protected this case — too late.
- New config: belowOORWaitMinutes (default 15m, vs 30m for above-range OOR)
- OOR notification threshold now correctly uses belowOORWaitMinutes when below range

Pool quality metrics (screening.js condensePool):
- fee_per_position_est: fee_window / active_positions — detects overcrowded pools where
  your share of fees is diluted by hundreds of LPs. Low = bad signal regardless of total fees.
- daily_yield_pct_est: extrapolates current fee rate to 24h yield %. Gives LLM a concrete
  profit signal: below 5%/day = marginal, above 15%/day = excellent.

Price momentum guard (screening.js getTopCandidates):
- maxEntry5mPricePct filter: skip pools where price already pumped > threshold in window.
  Deploying into a post-pump pool = LPing at the top, then price dumps below your range.
- minEntry5mPricePct filter: skip pools in freefall (price already dropped beyond threshold).
- Both default null (disabled). Activated by market mode presets or manual config.

Market mode presets updated with belowOORWaitMinutes + momentum guard per mode.
SCREENER prompt updated to explain fee_per_position_est and daily_yield_pct_est signals.
executor.js CONFIG_MAP: belowOORWaitMinutes, maxEntry5mPricePct, minEntry5mPricePct added.

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
- Dynamic bins_below: auto-scale from 35→90→120 based on pool volatility
  instead of fixed 69; LLM override still respected when explicitly provided
- Composite pool scoring (0-100): ranks pools by daily_yield_pct_est,
  fee_per_position_est, organic_score, smart money signals, risk penalties;
  getTopCandidates returns pools sorted by quality_score
- Rebalance-on-OOR (Rule 4): when price pumps above range, close + immediately
  redeploy at new active bin in same pool; skips screening cycle, keeps
  capital working with zero dead time; config.management.rebalanceOnOOR=true
- Fee velocity exit (Rule 6): tracks per-position fee accumulation rate via
  18-snapshot rolling window; exits if fee rate drops below 20% of peak rate
  (minFeeVelocityPct); catches dying pools ~1-2h before 24h yield metric
- Rule 4b (below-OOR) never rebalances — token in freefall, always closes
- New config keys: rebalanceOnOOR, minFeeVelocityPct, feeVelocityMinAgeMin
- Management report now shows FeeVel% and REBALANCE action in status line

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
- Fix merge conflict in README
- Add management rules table with all 6 rules + rebalance/fee velocity
- Document composite pool scoring system (0-100 scale, signal weights)
- Document dynamic bins_below calculation table
- Document market mode presets (bullish/bearish/sideways/volatile/conservative)
- Add full config reference for all new keys (rebalanceOnOOR, minFeeVelocityPct,
  feeVelocityMinAgeMin, belowOORWaitMinutes, maxVolatility, momentum guards)
- Add changelog section documenting all recent improvements
- Update architecture to include market-mode.js

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
…rategy auto-select

Tier 1 (direct profit impact):
- Adaptive PnL-based stop-loss: effectiveSL = max(stopLossPct, peak_pnl - maxDrawdownFromPeak)
  floor rises as position peaks — never lose more than maxDrawdownFromPeak(12%) from best PnL seen.
  Only activates when peak > 1% to avoid noise tightening SL prematurely.
- Graduated position sizing: deploy 30% more for quality_score≥70, 25% less for score<50;
  top_score fetched from getTopCandidates before computing deployAmount (highScoreSizeMult/lowScoreSizeMult)
- Strategy auto-select: each pool gets recommended_strategy (bid_ask or spot) based on
  volatility, mcap, token_age, organic_score — LLM instructed to use it by default
- Volume acceleration in scoring: +10pts if volume surging >50%, −15pts if collapsing <−50%;
  hard filter: skip if volume_change_pct < minVolumeAccelPct (default -60%)

Tier 2 (operational optimization):
- Pool age window filter: skip tokens <4h old (inflated metrics) or >7d (saturated);
  configurable via minPoolAgeHours/maxPoolAgeHours
- Time-of-day bias: off-peak hours (outside 14-22 UTC + 01-08 UTC) apply 1.3× multiplier
  on minVolume and minFeeActiveTvlRatio — prevents deploying into quiet off-hours pools
- Smart claim threshold: when fee velocity >150% → claim at 40% of base threshold (lock gains);
  when velocity <50% → claim at 200% threshold (save gas); configurable via smartClaimHotMult/Cold
- volume_change & quality_score/recommended_strategy now shown in candidate blocks for LLM

New config keys: maxDrawdownFromPeak, minPoolAgeHours, maxPoolAgeHours, minVolumeAccelPct,
timeOfDayBias, offPeakMultiplier, highScoreSizeMult, lowScoreSizeMult,
smartClaimHotMult, smartClaimColdMult

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
REBALANCE action requires deploy_position in step 2 after close, but
MANAGER_TOOLS was missing it — causing "I do not have deploy_position
in my toolset" blocking all OOR rebalances.

Also:
- Added get_active_bin and get_pool_memory to MANAGER_TOOLS
- Renamed pool: to pool_address: in action blocks for clarity
- Added strategy field to action blocks so LLM reuses same strategy
- Updated REBALANCE rule: skip_swap=true on close (price above range
  = 100% SOL, no base token), use get_wallet_balance for amount,
  and explicit pool_address reference

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
- dashboard.js: Express + WebSocket server (port 3000, token auth)
  - REST API: GET /api/status|positions|candidates|performance|config|logs
  - POST /api/config for live config updates
  - POST /api/action for manage/screen/close/claim/set_market_mode
  - WebSocket /ws: real-time log streaming + position snapshots every 60s
- dashboard.html: single-file dark terminal UI
  - Live positions with PnL, fee velocity, in-range badge
  - Candidates table with quality score and volume change
  - Config editor with inline save
  - WebSocket log stream with auto-reconnect
- logger.js: emit logs to process event bus for dashboard streaming
- package.json: add express ^4.21.2 and ws ^8.18.0 dependencies

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
- index.js: import and start dashboard in both TTY and non-TTY modes,
  passing runManagementCycle and runScreeningCycle as action handlers
- README.md: add dashboard setup section (port, token, firewall, access URL)
  and add DASHBOARD_PORT / DASHBOARD_TOKEN to .env example

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
1. dashboard.html:
   - Add token login overlay: shown on 401 response or WS close 4001
   - TOKEN is now mutable (let instead of const) so login updates it
   - HDRS() is now a function so updated TOKEN is used after login
   - api() wrapped in try/catch — shows console error, returns null
   - api() handles non-2xx properly (returns null, logs warning)
   - WS close 4001 (auth failure) shows login overlay instead of reconnect
   - loadStatus() shows "API error" on !d.ok instead of silently returning
   - loadPositions() shows "Could not load positions" on failure

2. dashboard.js:
   - /api/status: never returns 500 — each section has own try/catch,
     always returns { ok: true } even if wallet/positions fail
   - /api/status: fixed market_mode field (current_mode not active)
   - /api/config: add try/catch to synchronous route handler

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
… scoring

A1: Dynamic bins_above — price now sits in middle of range, not at top
  - bid_ask: bins_above = 20% of bins_below (small upside buffer)
  - spot/curve: bins_above = 35% of bins_below (symmetric range)
  - Prevents immediate OOR on any minor upward price tick
  - User override via config.strategy.binsAbove still works

A2: Entry timing filters — don't deploy into post-pump or freefall
  - maxEntry5mPricePct: 12 (skip if price already +12% in window)
  - minEntry5mPricePct: -20 (skip if price dumped >-20% in window)
  - athFilterPct: -15 (skip if price > 85% of ATH)
  - All configurable via user-config.json

A3: Strategy-aware stop loss
  - bid_ask (meme/volatile): -20% SL (cut losses fast)
  - spot/curve (established): -35% SL (give more room to revert)
  - takeProfitFeePct raised from 5% → 20% (let winners run)
  - maxDrawdownFromPeak tightened 12% → 8% (lock in more gains)
  - New config keys: bidAskStopLossPct, spotStopLossPct

A4: Rebalanced quality scoring weights
  - fee_per_position: 15pts → 25pts (competition signal is most important)
  - daily_yield: 20pts → 15pts (less weight on raw rate)
  - Net effect: pools with few competing LPs rank significantly higher

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
…g depth

B2: Dual-sided deploy for spot strategy
  - Screener checks wallet token holdings before deploy
  - If wallet holds ≥ $0.50 of pool's base token AND strategy=spot:
    candidate block shows DUAL_SIDE_AVAILABLE=yes with exact balance
  - LLM instructed to pass amount_x + base_mint for dual-sided LP
  - Earns fees on BOTH price directions vs SOL-only single-sided
  - Fixed strategyBlock: removed hardcoded bins_above=0 reference

B3: Expanded scoring — 3 new signals
  - Time-in-range bonus: lower volatility → longer active → more fee (max +8pts)
    vol≤1=+8, vol=2=+5, vol=3=+3, vol≥5=+0
  - Pool age sweet spot: 6-48h = +8pts, 48-72h = +4pts, <6h = -5pts
    (sweet spot: discovered but not yet LP-saturated)
  - LP competition signal: active_positions≤3 = +6pts, ≤8 = +3pts
    active_pct<30% (LPs abandoning) = -8pts

B4: Smart rebalance decision
  - OOR above range now checks fee_velocity_pct before rebalancing
  - If fee_velocity < rebalanceMinFeeVelocity (default 30%) → CLOSE instead
  - Pool was already dying when it went OOR → no point redeploying there
  - New config key: rebalanceMinFeeVelocity (default 30)

B-bonus: Tighter defaults
  - maxPoolAgeHours: 168h → 72h (3 days max, avoid saturated pools)
  - minPoolAgeHours: 4h → 6h (stricter: metrics more reliable after 6h)
  - minVolumeAccelPct: -60% → -40% (exit earlier on declining volume)

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
…fast redeploy

C1: Bin step scoring (new signal)
  - bin_step ≤ 80: +5pts (finest granularity = most fee per crossing)
  - bin_step ≤ 100: +3pts (good fee rate)
  - bin_step ≥ 120: -3pts (coarse = fewer fee events)

C2: Volume consistency signal (active/open positions ratio)
  - churn ≥ 70% (most LPs in range): +4pts (price stable, consistent volume)
  - churn < 30% (most LPs OOR): -6pts (very choppy, hard to stay in range)

C3: Fast redeploy after close
  - Detects when a position was just closed (beforeCount > afterCount)
  - Uses 1-min cooldown instead of 5-min for post-close screening trigger
  - Capital freed up → redeploy within 1 minute vs up to 5 minutes before

C4: Losing streak protection
  - Tracks last 5 closed positions via getPerformanceHistory()
  - 2 consecutive losses: 75% size (caution mode)
  - 3 consecutive losses: 50% size (defensive mode)
  - 4+ consecutive losses: 30% size (capital preservation mode)
  - Resets automatically on next winning position

C5: Min fee-per-position hard filter
  - New config: minFeePerPosition (default $1.50)
  - Skips pools where expected fee slice < threshold
  - Filters out overcrowded pools where gas cost > fee earned
  - Configurable via update_config or user-config.json

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
- Remove dashboard.js and dashboard.html
- Remove startDashboard import and calls from index.js
- Remove process.emit("dashboard:log") from logger.js
- Remove express and ws from package.json

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
Scoring already penalizes old pools via sweet spot bonus/penalty.
Hard filter at 72h was too strict — no candidates when few new pools available.

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
Older pools are not inherently bad — scoring already handles preference
via pool age sweet spot bonus and fee_per_position signal.
Hard max was causing empty screening in low-activity periods.

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
Two bugs in prompt.js:
1. DEPLOY RULES told LLM: "bins_above = ${config.strategy.binsAbove ?? 0}" which
   caused LLM to explicitly pass bins_above=0, bypassing dlmm.js auto-calculation
   (0 is not null, so the auto-calc branch was never taken). Now tells LLM
   NOT to pass bins_above at all.
2. LLM misinterpreted { dry_run: true } response as "blocked by system" — added
   explicit DRY_RUN MODE rule: treat dry_run: true as a successful simulation.

Also removed binsAbove display from marketModeBlock to avoid LLM confusion.

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
Two bugs in prompt.js:
1. DEPLOY RULES told LLM: "bins_above = ${config.strategy.binsAbove ?? 0}" which
   caused LLM to explicitly pass bins_above=0, bypassing dlmm.js auto-calculation
   (0 is not null, so the auto-calc branch was never taken). Now tells LLM
   NOT to pass bins_above at all.
2. LLM misinterpreted { dry_run: true } response as "blocked by system" — added
   explicit DRY_RUN MODE rule: treat dry_run: true as a successful simulation.

Also removed binsAbove display from marketModeBlock to avoid LLM confusion.

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
README.md:
- Remove web dashboard section (removed from codebase)
- Remove DASHBOARD_PORT/DASHBOARD_TOKEN from .env example
- Update management rules: strategy-aware SL, smart rebalance gate, updated TP (20%)
- Add strategy-aware stop loss table (bid_ask=-20%, spot=-35%)
- Update composite quality score table with new signals and weights
- Add minFeePerPosition hard filter documentation
- Fix dynamic bins_below table (was showing wrong formula/values)
- Add bins_above auto-calculation section
- Update config reference: new keys (bidAskStopLossPct, spotStopLossPct,
  rebalanceMinFeeVelocity, minFeePerPosition, minPoolAgeHours, maxPoolAgeHours,
  athFilterPct), updated defaults (stopLossPct=-35, takeProfitFeePct=20,
  maxDrawdownFromPeak=8, maxEntry5mPricePct=12, minEntry5mPricePct=-20)
- Remove binsAbove from strategy config table (now auto-calculated)
- Rewrite changelog with all recent improvements

CLAUDE.md:
- Add deploy_position, get_active_bin, get_pool_memory to MANAGER_TOOLS docs
- Add all new config keys to config table
- Expand bins section to cover bins_above auto-calculation
- Remove resolved known issue (evolveThresholds key names — fixed)

https://claude.ai/code/session_01KRQBeT9ftvwPpjGYPrZuBc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants