strategy-ranking-sniper

Use when the user asks about SOL ranking sniper, Solana top token sniping, trending token bot, ranking-based auto-trading, 排行榜狙击, SOL sniper bot, momentum score trading, ranking exit strategy, or wants to run/configure/monitor the ranking sniper bot. Covers: automated sniping of SOL tokens entering the OKX trending ranking, 3-layer safety filter (Slot Guard + Advanced Safety + Holder Risk Scan), momentum scoring (0-125), 6-layer exit system (ranking exit + hard stop + fast stop + trailing + time stop + gradient TP), Telegram notifications, and configurable parameters via JSON config file. Do NOT use for manual token lookup — use okx-dex-token. Do NOT use for grid trading — use strategy-grid-trade. Do NOT use for memepump scanning — use strategy-memepump-scanner.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "strategy-ranking-sniper" with this command: npx skills add purong-huang-1121/skills-store/purong-huang-1121-skills-store-strategy-ranking-sniper

SOL Ranking Sniper v1.0.0

欢迎使用 SOL 涨幅榜狙击策略

我们实时监控 OKX DEX 涨幅榜,当新币进入榜单时自动触发买入,跌出榜单时自动卖出。策略内置 25 项安全检查(流动性、持仓集中度、Dev 钱包等)+ 动量评分(0-125分),只交易评分达标的高质量标的,6 层退出机制全程保护仓位。

投资案例:

小陈用 2 SOL 启动涨幅榜狙击。某天上午一个新币 $BONK2 冲进涨幅榜前 10,动量评分 98 分,安全检查全过。 机器人以均价 $0.0012 自动买入,持仓期间 $BONK2 继续拉升 40%。 跌出榜单触发排名退出,以 $0.00165 自动卖出,单笔盈利约 $82(+37.5%)。 同日另一个币安全检查未通过(Dev 钱包集中度过高),自动跳过,规避了一次归零风险。

Automated Solana token sniper that monitors the OKX DEX trending ranking, applies a 3-layer safety filter with momentum scoring, and executes trades with a 6-layer exit system. Available as standalone strategy-ranking-sniper binary.

Pre-flight Checks

Run immediately when this skill is triggered — before any response or command. Always follow these steps in order. Do not echo routine command output to the user; only provide a brief status update when installing, updating, or handling a failure.

Step 1: Check onchainos

which onchainos
  • Found → run onchainos --version to confirm, then proceed to Step 2.
  • Not found → install automatically:
    curl -sSL https://raw.githubusercontent.com/okx/onchainos-skills/main/install.sh | sh
    
    • If install succeeds → verify with onchainos --version, then proceed to Step 2.
    • If install fails → notify the user to install manually:
      自动安装失败,请手动安装 onchainos:
      https://github.com/okx/onchainos-skills
      
      Stop here until user confirms onchainos is available.

Step 2: Check skills-store

which skills-store
  • Not found → install:

    curl -sSL https://raw.githubusercontent.com/purong-huang-1121/skills-store/main/install.sh | sh
    
  • Check for updates: Read ~/.cargo/bin/.skills-store/last_check_ranking_sniper and compare with current timestamp:

    cached_ts=$(cat ~/.cargo/bin/.skills-store/last_check_ranking_sniper 2>/dev/null || true)
    now=$(date +%s)
    
    • If cached_ts is non-empty and (now - cached_ts) < 43200 (12 hours), skip the update.
    • Otherwise, run the installer to check for updates.

Step 3: Check strategy-ranking-sniper

which strategy-ranking-sniper
  • Found → proceed.
  • Not found → install:
    curl -sSL https://raw.githubusercontent.com/purong-huang-1121/skills-store/main/install_strategy.sh | sh -s -- strategy-ranking-sniper
    
    • If install succeeds → verify with strategy-ranking-sniper --version, then proceed.
    • If install fails → notify the user:
      自动安装失败,请手动安装 strategy-ranking-sniper:
      curl -sSL https://raw.githubusercontent.com/purong-huang-1121/skills-store/main/install_strategy.sh | sh -s -- strategy-ranking-sniper
      
      Stop here until user confirms installation.

Skill Routing

  • For manual token lookup / analytics -> use okx-dex-token
  • For DEX swap -> use okx-dex-swap
  • For token prices / charts -> use okx-dex-market
  • For wallet balances -> use okx-wallet-portfolio
  • For grid trading -> use strategy-grid-trade
  • For DeFi yield -> use strategy-defi-yield
  • For memepump scanning -> use strategy-memepump-scanner

Architecture Overview

+---------------------------------------------------------------------------+
|                     SOL Ranking Sniper v1.0.0                             |
|                                                                           |
|  Ranking API -> Slot Guard -> Advanced Safety -> Holder Risk -> Score ->  |
|  fetch_ranking  (13 checks)   (9 checks)        (3 checks)    0-125     |
|  (Top N by      change/liq/   risk_level/        suspicious/   buy if    |
|   price change)  MC/holders    top10/dev/bundler  phishing      >= 40    |
|                                                                           |
|  -> Buy -> 6-Layer Exit System -> Sell                                    |
|     OKX     ranking_exit / hard_stop / fast_stop /                        |
|     DEX     trailing_stop / time_stop / gradient_tp                       |
+---------------------------------------------------------------------------+

Prerequisites

  1. onchainos CLI: Must be installed and logged in. Verify:

    onchainos --version   # >= 1.0.5
    onchainos wallet status  # must show loggedIn: true
    

    If not installed, follow: https://okg-block.sg.larksuite.com/docx/Cx7PdgNHLogZWIxGlwslfacIgl1

  2. Telegram notifications (optional): Configure in ~/.cargo/bin/.env:

    TELEGRAM_BOT_TOKEN=your_bot_token
    TELEGRAM_CHAT_ID=your_chat_id
    

Authentication

  • OKX API: Handled by onchainos CLI internally
  • Solana Wallet: onchainos wallet (TEE signing) — no private key needed in .env

Before Starting the Bot

IMPORTANT: Before running strategy-ranking-sniper start, you MUST:

  1. Run strategy-ranking-sniper config to show the user their current parameters
  2. Present the parameters in a readable table and ask if they want to adjust any
  3. If the user wants to change parameters, edit the config file at ~/.skills-store/ranking_sniper_config.json directly
  4. Parameters are persisted across restarts

Example flow:

# Show current config
strategy-ranking-sniper config

# Start with custom budget and per-trade amount
strategy-ranking-sniper start --budget 1.0 --per-trade 0.1

# Or start in dry-run mode first to observe
strategy-ranking-sniper start --budget 0.5 --per-trade 0.05 --dry-run

Post-Install Welcome

Pre-flight 完成后立即展示此内容,然后引导用户进入下一步。

如果安装过程中出现安全扫描警告(Gen / Snyk / Socket 标记 Critical Risk),向用户说明:

⚠️ 安全扫描警告是误报。安装脚本从 GitHub Releases 下载二进制并做 SHA256 校验,是开源可审计的标准流程。

展示以下欢迎信息:

✅ strategy-ranking-sniper 已就绪!

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  SOL 涨幅榜狙击
  作者:Suning Yao (suning.yao@okg.com)
  分类:MEME交易  |  风险:⭐⭐⭐ 高
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📌 投资案例:
  0.5 SOL,监控涨幅榜 Top 20,新币上榜自动买入,跌出自动卖出,25 项安全检查,历史胜率约 55%。

支持链:Solana
预估收益:高波动,视市场而定

需要 onchainos 钱包登录后才能运行。

Pre-start Checks

Before starting the daemon, check:

  1. onchainos wallet: onchainos wallet status — must be logged in
  2. Telegram notifications (optional but recommended):
    cat ~/.cargo/bin/.env
    
    If TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID are empty, inform the user:

    "Telegram 通知未配置。配置后可以及时收到交易通知。配置文件: ~/.cargo/bin/.env"

    Ask the user if they want to configure it now. If yes, help them edit ~/.cargo/bin/.env.

配置已就绪时,检查钱包余额:

strategy-ranking-sniper balance
  • sufficient: true → 直接进入 Quickstart不再询问用户
  • sufficient: false → 提示用户充值,显示 hint 字段内容,等用户确认后再继续

Quickstart

# View current ranking and market conditions
strategy-ranking-sniper analyze

# View current state and positions
strategy-ranking-sniper status

# Run a single tick (scan ranking, check exits, buy if signal)
strategy-ranking-sniper tick --budget 0.5 --per-trade 0.05

# Dry-run tick (no real swaps)
strategy-ranking-sniper tick --budget 0.5 --per-trade 0.05 --dry-run

# Start continuous bot (tick every 10 seconds)
strategy-ranking-sniper start --budget 0.5 --per-trade 0.05

# Stop running bot
strategy-ranking-sniper stop

# Emergency: sell all open positions
strategy-ranking-sniper sell-all

Command Index

#CommandAuthDescription
1strategy-ranking-sniper tickYesExecute one tick: fetch ranking, check exits, scan new entries
2strategy-ranking-sniper startYesStart foreground bot loop (tick every 10s)
3strategy-ranking-sniper stopNoStop running bot via PID file
4strategy-ranking-sniper statusNoShow current state, positions, and PnL
5strategy-ranking-sniper reportNoDetailed PnL and performance report
6strategy-ranking-sniper historyNoShow trade history
7strategy-ranking-sniper reset --forceNoClear all state data
8strategy-ranking-sniper analyzeNo*Market analysis (current ranking, top tokens)
9strategy-ranking-sniper test-tradeYesBuy+sell round-trip for a token (dev/debug)
10strategy-ranking-sniper configNoShow all configurable parameters
11strategy-ranking-sniper sell-allYesForce-sell all open positions immediately
12strategy-ranking-sniper sellYesSell a specific token by address

*Analyze requires onchainos wallet for ranking data.

Core Strategy

What It Does

  1. Every 10 seconds, fetches the top N Solana tokens by 5-minute price change from OKX DEX ranking
  2. For existing positions: checks 6-layer exit system (ranking exit, stops, trailing, TP)
  3. For new tokens entering the ranking: applies 3-layer safety filter (25 total checks)
  4. Calculates momentum score (0-125) — only buys if score >= threshold
  5. Executes swap via OKX DEX aggregator with Solana on-chain signing
  6. Sends Telegram notifications on buy/sell/error events

What It Won't Do

RuleReason
No tokens already seenknown_tokens set prevents re-entry
No tokens in cooldownPost-sell cooldown (default 30min)
No buying above max positionsDefault 5 simultaneous positions
No buying below budgetBudget tracking prevents over-deployment
No buying with low scoreMomentum score must meet threshold
No buying with high risk3-layer safety filter rejects unsafe tokens
No trading after daily loss limitAuto-stops at configured % loss
No trading after circuit breaker5 consecutive errors triggers 1h cooldown

3-Layer Safety Filter (25 Checks)

Layer 1: Slot Guard (13 checks from ranking data)

#CheckDefault ThresholdProduction Suggestion
1Price change min>= 1%15%
2Price change max<= 150%150%
3Liquidity>= $1,000$5,000
4Market cap min>= $1,000$5,000
5Market cap max<= $50M$10M
6Holders>= 530
7Buy ratio (buy/total TX)>= 40%55%
8Unique traders>= 520
9Skip system tokensSOL, USDC, etc.-
10Cooldown checkNot in cooldown-
11Position limit< max_positions-
12Already holdingNot holding-
13Daily loss limitNot exceeded-

Layer 2: Advanced Safety (9 checks from advanced-info API)

#CheckDefault ThresholdProduction Suggestion
14Risk control level<= 31
15Honeypot tagNot present-
16Top 10 concentration<= 80%50%
17Dev holding<= 50%20%
18Bundler holding<= 50%15%
19LP burned>= 0%80%
20Dev rug pull count<= 10010
21Sniper holding<= 50%20%
22Block internal (PumpFun)falsetrue

Layer 3: Holder Risk Scan (3 checks from holder API)

#CheckDefault ThresholdProduction Suggestion
23Suspicious holder total %<= 50%10%
24Suspicious holder count<= 505
25Phishing holdersallowedblocked

Note: Default thresholds are relaxed for testing. For production use, update the config file with the "Production Suggestion" values.


Momentum Score (0-125)

Base Score (0-100)

ComponentMax PointsFormula
Buy Score40buy_ratio x 40
Change Penalty20if change > 100%: 20 - (change-100)/10; else: change/5
Trader Score20min(traders/50, 1) x 20
Liquidity Score20min(liquidity/50000, 1) x 20

Bonus Score (0-25, capped)

BonusPointsCondition
Smart Money+8smartMoneyBuy tag present
Low Concentration+5/+2Top10 < 30% / < 50%
DS Paid+3dsPaid tag present
Community+2dexScreenerTokenCommunityTakeOver tag
Low Sniper+4/+2Sniper < 5% / < 10%
Dev Clean+3Dev hold 0% AND rug count < 3
Zero Suspicious+2No active suspicious holders

Buy threshold: Default 10 (testing), production suggestion 40.


6-Layer Exit System

Priority order (first match exits):

LayerExit TypeConditionAction
1Ranking ExitToken drops off top N ranking (after 60s)FULL sell
2Hard StopPnL <= -25%FULL sell
3Fast StopPnL <= -8% after 5 minutesFULL sell
4Trailing StopDrawdown >= 12% from peak (activates at +8%)FULL sell
5Time StopElapsed >= time_stop_secs (default 6h)FULL sell
6Gradient TPPnL >= TP levelPARTIAL sell (25%/35%/40%)

Gradient Take-Profit Levels

LevelDefault TriggerSell Portion
TP1+5%25%
TP2+15%35%
TP3+30%40%

Configurable Parameters

Parameters are persisted at ~/.skills-store/ranking_sniper_config.json. View with strategy-ranking-sniper config. Edit the JSON file directly to change values.

Money Management

ParameterDefaultDescription
budget_sol0.5Total SOL budget for the strategy
per_trade_sol0.05SOL amount per buy trade
max_positions5Maximum simultaneous positions
gas_reserve_sol0.01SOL reserved for gas fees
min_wallet_balance0.1Minimum wallet balance to maintain
daily_loss_limit_pct15.0Daily loss limit (% of budget)
dry_runfalseSimulate without executing swaps

Trading Parameters

ParameterDefaultDescription
slippage_pct"3"DEX slippage tolerance (%)
score_buy_threshold10Momentum score threshold (0-125)
tick_interval_secs10Polling interval (seconds)
cooldown_minutes30Post-sell cooldown per token (minutes)
top_n20Number of ranking entries to scan

Exit System

ParameterDefaultDescription
hard_stop_pct-25.0Hard stop-loss (%)
fast_stop_time_secs300Fast stop window (seconds)
fast_stop_pct-8.0Fast stop threshold (%)
trailing_activate_pct8.0Trailing stop activation (%)
trailing_drawdown_pct12.0Trailing stop drawdown (%)
time_stop_secs21600Time stop (seconds, default 6h)
tp_levels[5, 15, 30]Gradient take-profit levels (%)

Circuit Breaker

ParameterDefaultDescription
max_consecutive_errors5Errors before circuit breaker trips
cooldown_after_errors3600Cooldown after breaker (seconds)

CLI Command Reference

strategy-ranking-sniper tick

Execute one tick cycle: fetch ranking, check exits for existing positions, scan for new entry signals, execute trades.

strategy-ranking-sniper tick [--budget <sol>] [--per-trade <sol>] [--dry-run]
ParamRequiredDefaultDescription
--budgetNo0.5Total SOL budget
--per-tradeNo0.05SOL per buy trade
--dry-runNofalseSimulate without real swaps

Return fields:

FieldDescription
tick_timeISO 8601 timestamp
positionsNumber of open positions
remaining_budget_solRemaining SOL budget
daily_pnl_solDaily PnL in SOL
actionsArray of actions taken (buy/exit/skip/buy_failed)
dry_runWhether this was a dry-run

Action types in output:

  • buy — New position opened (symbol, price, amount_sol, score, tx_hash)
  • exit — Position closed (symbol, reason, exit_type, pnl_pct, pnl_sol, tx_hash)
  • skip — Token rejected by safety filter or score (symbol, reason)
  • buy_failed — Buy swap failed (symbol, error)
  • exit_failed — Sell swap failed (symbol, reason, error)
  • no_ranking_data — No ranking data available

strategy-ranking-sniper start

Start the bot in foreground, executing tick every 10 seconds. Creates a PID file at ~/.skills-store/ranking_sniper.pid. Use Ctrl+C or ranking-sniper stop to terminate. Logs to ~/.skills-store/ranking_sniper.log.

strategy-ranking-sniper start [--budget <sol>] [--per-trade <sol>] [--dry-run]
ParamRequiredDefaultDescription
--budgetNo0.5Total SOL budget
--per-tradeNo0.05SOL per buy trade
--dry-runNofalseSimulate without real swaps

Prints the full parameter summary before starting. Sends Telegram notification on start/stop if configured.

strategy-ranking-sniper stop

Stop a running bot by sending SIGTERM to the process in the PID file.

strategy-ranking-sniper stop

strategy-ranking-sniper status

Show current bot state, open positions, PnL overview, and whether the bot is running.

strategy-ranking-sniper status

Return fields:

FieldDescription
bot_runningWhether a bot process is active
stoppedWhether the bot was stopped by a limit
stop_reasonReason for stop (if applicable)
positionsArray of open position details
position_countNumber of open positions
remaining_budget_solRemaining SOL budget
daily_pnl_solDaily PnL in SOL
known_tokens_countTotal tokens seen
consecutive_errorsCurrent error count

strategy-ranking-sniper report

Detailed performance report with win/loss stats.

strategy-ranking-sniper report

Return fields:

FieldDescription
total_buysTotal buy trades
total_sellsTotal sell trades
successful_tradesSuccessful trade count
failed_tradesFailed trade count
total_invested_solTotal SOL invested
total_returned_solTotal SOL returned from sells
total_pnl_solTotal realized PnL in SOL
daily_pnl_solToday's PnL
win_countWinning trades
loss_countLosing trades
win_rateWin percentage

strategy-ranking-sniper history

Show trade history (most recent first).

strategy-ranking-sniper history [--limit <n>]
ParamRequiredDefaultDescription
--limitNo50Number of trades to show

Each trade includes: time, symbol, token_address, action (BUY/SELL), price, amount_sol, score, exit_reason, pnl_pct, pnl_sol, tx_hash.

strategy-ranking-sniper reset

Delete all sniper state. Requires --force flag for safety.

strategy-ranking-sniper reset --force
ParamRequiredDefaultDescription
--forceYes-Required to confirm destructive action

strategy-ranking-sniper analyze

Market analysis showing the current trending ranking, top tokens, and bot state summary.

strategy-ranking-sniper analyze

Return fields:

FieldDescription
ranking_countNumber of tokens in current ranking
top_tokensArray of top tokens (symbol, address, change_24h, market_cap, volume, holders)
known_tokens_countTotal tokens the bot has seen
active_positionsNumber of open positions

strategy-ranking-sniper test-trade

Execute a buy+sell round-trip for a specific token. For development and debugging only. Buys a small amount of the token, waits a few seconds, then sells it back.

strategy-ranking-sniper test-trade <token_address> [--amount <sol>]
ParamRequiredDefaultDescription
<token_address>Yes-Token contract address on Solana
--amountNo0.01SOL amount to buy

Return fields:

FieldDescription
tokenToken address
amount_solSOL amount used
buy.tx_hashBuy transaction hash
buy.pricePrice at buy time
buy.amount_outToken amount received
sell.tx_hashSell transaction hash
sell.amount_outSOL amount received back
price_beforePrice before buy
price_afterPrice after sell

strategy-ranking-sniper config

Show all configurable parameters and their current values, organized by category. Also shows the config file and log file paths.

strategy-ranking-sniper config

Displays parameter groups:

  • Money management (budget, per_trade, max_positions, etc.)
  • Trading parameters (slippage, score threshold, tick interval, etc.)
  • Layer 1 Slot Guard thresholds
  • Layer 2 Advanced Safety thresholds
  • Layer 3 Holder Risk Scan thresholds
  • Exit system (stops, trailing, take-profit levels)
  • Circuit breaker
  • Logging
  • Telegram notifications

strategy-ranking-sniper sell-all

Force-sell all open positions immediately. Retries with halved amounts if liquidity is insufficient (up to 4 attempts per position).

strategy-ranking-sniper sell-all

Return fields:

FieldDescription
soldNumber of positions successfully sold
failedNumber of positions that failed to sell
resultsArray of per-position results (symbol, token, status, tx_hash, sol_out, error)

strategy-ranking-sniper sell

Sell a specific token by contract address with a raw token amount.

strategy-ranking-sniper sell <token_address> --amount <raw_amount>
ParamRequiredDefaultDescription
<token_address>Yes-Token contract address
--amountYes-Raw token amount (in smallest units)

Return fields:

FieldDescription
tokenToken address
tx_hashTransaction hash
sol_outSOL received (human-readable)
amount_out_lamportsSOL received in lamports

OKX API Endpoints Used

Market Data APIs

EndpointMethodPurpose
/api/v6/dex/market/token/toplistGETFetch trending token ranking by price change
/api/v6/dex/market/token/advanced-infoGETToken safety data (risk level, tags, dev/bundler/sniper %)
/api/v6/dex/market/price-infoPOSTReal-time token price
/api/v6/dex/market/token/holderGETHolder data filtered by tag (suspicious/phishing)

Trade Execution APIs

EndpointMethodPurpose
/api/v6/dex/aggregator/swapGETGet swap transaction data
/api/v6/dex/pre-transaction/broadcast-transactionPOSTBroadcast signed transaction via OKX
/api/v6/dex/post-transaction/ordersGETPoll transaction confirmation status

Solana RPC (Direct)

MethodPurpose
getLatestBlockhashFresh blockhash for transaction signing
sendTransactionDirect broadcast to Solana network
getSignatureStatusesVerify transaction confirmation
getTokenAccountsByOwnerCheck wSOL ATA balance

Execution Pipeline

fetch_ranking(top_n=20)              <- OKX /token/toplist (sort by 5m change)
    |
    +-> For each existing position:
    |     fetch_price(token)          <- OKX /price-info
    |     check_exits(6 layers)       <- engine.rs pure function
    |     If exit signal -> sell      <- OKX /aggregator/swap + sign + broadcast
    |
    +-> For each new token in ranking:
          known_tokens check           <- skip if already seen
          budget + position check      <- skip if insufficient
          fetch_advanced_info()        <- OKX /token/advanced-info
          run_slot_guard(13 checks)    <- engine.rs pure function
          run_advanced_safety(9 checks)<- engine.rs pure function
          fetch_holder_risk()          <- OKX /token/holder (tag 6 + 8)
          run_holder_risk_scan(3 chks) <- engine.rs pure function
          calc_momentum_score()        <- engine.rs (0-125)
          If score >= threshold:
            fetch_price()              <- OKX /price-info
            buy_token()                <- OKX /aggregator/swap + sign + broadcast

Cross-Skill Workflows

Workflow A: Analyze Then Snipe

User: "What's trending on Solana right now? Start sniping if it looks good."

1. strategy-ranking-sniper analyze          -> see current ranking + top tokens
2. strategy-ranking-sniper config           -> review parameters
       | user adjusts thresholds if needed
3. strategy-ranking-sniper tick --dry-run   -> dry-run to see what passes filters
       | looks good
4. strategy-ranking-sniper start --budget 0.5 --per-trade 0.05  -> go live
5. strategy-ranking-sniper status           -> monitor positions

Workflow B: Monitor and Emergency Exit

User: "Check my sniper positions. Sell everything if it's losing."

1. strategy-ranking-sniper status           -> see positions + PnL
       | user sees losses
2. strategy-ranking-sniper sell-all         -> emergency exit all positions
3. strategy-ranking-sniper report           -> review final stats

Workflow C: Research a Specific Token

User: "The sniper bought TOKEN, tell me more about it."

1. strategy-ranking-sniper status                              -> get token address
2. okx-dex-token    skills-store token search TOKEN --chain solana -> token details
3. okx-dex-market   skills-store market kline --address <addr> --chain solana -> chart
4. okx-wallet-portfolio  skills-store portfolio balance --chain solana -> wallet balance

Workflow D: Test Before Deploying

User: "I want to test the sniper on a specific token before going live."

1. okx-dex-token    skills-store token search HYPE --chain solana              -> find token
2. strategy-ranking-sniper test-trade <token_address> --amount 0.01        -> round-trip test
3. strategy-ranking-sniper start --budget 0.5 --per-trade 0.05 --dry-run  -> dry-run session
       | verify actions look correct
4. strategy-ranking-sniper start --budget 0.5 --per-trade 0.05            -> go live

State Persistence

State is stored at ~/.skills-store/ranking_sniper_state.json with atomic writes (write to .tmp, rename).

FilePurpose
~/.skills-store/ranking_sniper_state.jsonFull bot state (positions, trades, stats, known tokens)
~/.skills-store/ranking_sniper_config.jsonUser-configurable parameters
~/.skills-store/ranking_sniper.pidPID file for running bot
~/.skills-store/ranking_sniper.logExecution log

State includes:

  • known_tokens — Set of all token addresses ever seen (prevents re-entry)
  • positions — Map of token_address -> Position (with buy price, time, peak PnL, trailing state)
  • trades — Trade history (last 100 entries)
  • stats — Cumulative stats (buys, sells, invested, returned, daily PnL)
  • errors — Consecutive error tracking for circuit breaker
  • last_sell_times — Per-token cooldown timestamps

Key Concepts

  • Ranking-based entry: Unlike signal-based scanners, this bot only considers tokens that appear in the OKX top-N trending list. Entry is triggered by a token being new to the ranking AND passing all safety checks.
  • Ranking-based exit: The primary exit signal is a token dropping off the ranking entirely. This is Layer 1 of the exit system and takes priority over most other exit conditions.
  • Momentum Score: A composite score (0-125) combining buy pressure, price change, trader count, liquidity, and bonus signals (smart money, low concentration, etc.). Prevents buying tokens that pass safety but lack momentum.
  • Known tokens set: Once a token is seen in the ranking, it enters the known_tokens set permanently (within a session). The bot will never re-enter the same token. Use reset --force to clear.
  • Gradient take-profit: Sells in 3 tranches (25%/35%/40%) at increasing profit levels, rather than all-at-once. Locks in partial profit while allowing further upside.
  • Trailing stop: Activates when PnL reaches a threshold (default +8%), then sells if price drops by the drawdown percentage (default 12%) from the peak.
  • Dry-run mode: Executes the full pipeline (ranking fetch, safety checks, scoring) but skips actual swap execution. Actions are logged as DRY_RUN. Useful for validating filter parameters.

Edge Cases

ScenarioBehavior
No ranking data availableSaves state, outputs no_ranking_data
Circuit breaker tripped (5 errors)Rejects all ticks for cooldown period (default 1h)
Daily loss limit exceededBot stops, requires reset --force to restart
Bot previously stopped by limitRejects ticks with reason, requires reset
Budget exhaustedSkips all new buys, continues monitoring exits
Max positions reachedSkips new buys, continues monitoring exits
Token already in known_tokensSkipped silently (no re-entry)
Sell fails (insufficient liquidity)sell-all retries with halved amounts (up to 4x)
Advanced-info API failsToken skipped with reason
Price fetch failsPosition exit check skipped for that token
onchainos wallet not availableError on tick/start/sell commands — please login first
Bot already runningstart rejects with existing PID warning
No running botstop returns error
Reset without --forceReturns error, requires confirmation
wSOL ATA missingAuto-created and funded before buy swap
Blockhash expiredFresh blockhash fetched from Solana RPC
Solana RPC broadcast failsFalls back to OKX broadcast endpoint
Transaction not confirmedPolled for up to 60 seconds before failing

Troubleshooting

SymptomCauseFix
"onchainos wallet not available"Not logged inRun onchainos wallet status and login if needed
Circuit breaker tripsRepeated API/swap failuresCheck logs at ~/.skills-store/ranking_sniper.log, fix root cause, wait 1h or reset
No buys happeningScore threshold too high, or safety filters too strictTry --dry-run to see skip reasons, adjust config thresholds
All tokens skipped by slot_guardThresholds set to production valuesFor testing, lower min_change_pct, min_liquidity, min_holders, etc.
Sell fails repeatedlyLow liquidity tokenUse sell-all (auto-retries with halved amounts) or manual sell
"Bot stopped" on tickDaily loss limit or prior stopRun ranking-sniper reset --force to clear state
High slippage on swapsSlippage tolerance mismatchAdjust slippage_pct in config (default 3%, raise to 5-10% for low-liquidity memes)
Telegram not workingMissing or incorrect bot token/chat IDSet in config file or env vars, verify with Telegram BotFather

Security Notes

  • Wallet signing: onchainos wallet (TEE signing) — private keys never leave the secure enclave
  • API auth: Handled by onchainos CLI internally
  • Atomic state writes: Write to .tmp file then rename to prevent corruption
  • Fail-closed: API failures result in skipping the token, not proceeding with partial data
  • Capital controls: Budget tracking, position limits, daily loss limits, and circuit breaker prevent runaway losses

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

skills-store

No summary provided by upstream source.

Repository SourceNeeds Review
General

strategy-grid-trade

No summary provided by upstream source.

Repository SourceNeeds Review
General

strategy-signal-tracker

No summary provided by upstream source.

Repository SourceNeeds Review
General

strategy-auto-rebalance

No summary provided by upstream source.

Repository SourceNeeds Review