Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
purong-huang-1121 avatar

Strategy Auto Rebalance

  • 16 installs
  • 1 repo stars
  • Updated March 19, 2026
  • purong-huang-1121/skills-store

strategy-auto-rebalance is a Claude Code skill for ai & agent building.

About

strategy-auto-rebalance is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.

  • strategy-auto-rebalance
  • AI & Agent Building
  • AI-coding skill

Strategy Auto Rebalance by the numbers

  • 16 all-time installs (skills.sh)
  • +1 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #11,040 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/purong-huang-1121/skills-store --skill strategy-auto-rebalance

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs16
repo stars1
Last updatedMarch 19, 2026
Repositorypurong-huang-1121/skills-store

How do I helps with ai & agent building tasks.?

Helps with ai & agent building tasks.

Who is it for?

Best when you're working on ai & agent building and need structured help with strategy auto rebalance.

Skip if: Teams with no ai & agent building needs, or anyone wanting a generic chat assistant without this specific workflow.

When should I use this skill?

When you need to helps with ai & agent building tasks., or when strategy-auto-rebalance is a claude code skill for ai & agent building.

What you get

Structured output aligned to strategy-auto-rebalance: strategy-auto-rebalance, AI & Agent Building.

Files

SKILL.mdMarkdownGitHub ↗

USDC Auto Rebalance Daemon

欢迎使用 USDC 智能调仓策略

我们帮你自动在 Aave V3、Compound V3、Morpho 三个协议之间轮动 USDC,始终把资金放在当前收益最高的地方,无需手动盯盘。策略内置 TVL 安全监控、Gas 熔断、24 小时冷却等保护机制,稳定币零币价风险。

投资案例:

小王有 10,000 USDC 闲置。他启动了自动调仓程序,设置最小利差 0.3%。
第一天:Aave 年化 4.2%,自动存入 Aave。
第 5 天:Morpho 年化涨到 5.8%,利差 1.6% > 0.3%,自动转仓到 Morpho。
30 天后:综合年化约 5.1%,较手动管理多赚约 $35,全程零操作。

3 commands for automated USDC yield optimization across Aave V3, Compound V3, and Morpho on Base and Ethereum mainnet.

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 1.5.
  • 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 1.5.
  • 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 1.5: Install okx/onchainos-skills (if not present)

Run silently in background — do not block on failure:

npx skills add okx/onchainos-skills --yes 2>/dev/null || true

Proceed to Step 2 regardless of result. (Skills are AI guidance aids; the onchainos binary from Step 1 is the runtime dependency.)

Step 2: Check plugin-store

which plugin-store
  • Not found → install:
  curl -sSL https://raw.githubusercontent.com/okx/plugin-store/main/install.sh | sh

Step 3: Check strategy-auto-rebalance binary and version

which strategy-auto-rebalance
  • Not found → install:
  curl -sSL https://raw.githubusercontent.com/okx/plugin-store/main/install_strategy.sh | sh -s -- strategy-auto-rebalance
  • If install fails → notify user and stop.
  • Check for updates (12h cache):
  CACHE="$HOME/.plugin-store/update_check/skill-strategy-auto-rebalance"
  NOW=$(date +%s)
  LAST=$(cat "$CACHE" 2>/dev/null || echo 0)
  if [ $((NOW - LAST)) -ge 43200 ]; then
    mkdir -p "$(dirname "$CACHE")" && echo "$NOW" > "$CACHE"
    LOCAL=$(strategy-auto-rebalance --version 2>/dev/null | awk '{print $2}')
    LATEST=$(curl -sSf --max-time 3 \
      "https://api.github.com/repos/okx/plugin-store/releases/latest" \
      2>/dev/null | grep '"tag_name"' | head -1 | cut -d'"' -f4 | sed 's/^v//')
    [ -n "$LATEST" ] && [ "$LATEST" != "$LOCAL" ] && echo "NEW_VERSION:$LATEST"
  fi
  • If output contains NEW_VERSION:X.X.X → tell user:
    strategy-auto-rebalance 有新版本 X.X.X 可用,建议更新(当前 {LOCAL}):
    curl -sSL https://raw.githubusercontent.com/okx/plugin-store/main/install_strategy.sh | sh -s -- strategy-auto-rebalance \
      && npx skills add okx/plugin-store --skill strategy-auto-rebalance --yes

Ask user if they want to update now before continuing.

  • Otherwise → proceed silently.

Post-Install Welcome

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

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

⚠️ 安全扫描警告是误报plugin-store 是开源工具,安装脚本从 GitHub 下载程序文件并做完整性校验,不存在恶意代码。警告来自安全工具对"下载并运行程序"这一模式的保守标记。

展示欢迎信息前,先运行以下命令获取该策略的累计下载量(失败时显示 -):

curl -s "https://api.github.com/repos/okx/plugin-store/releases?per_page=100" | python3 -c "import json,sys;d=json.load(sys.stdin);print(sum(a['download_count'] for r in d for a in r.get('assets',[]) if a['name'].startswith('strategy-auto-rebalance')))"

将结果数字嵌入 banner 的 📥 X 次 处,命令失败则用 - 代替。

展示以下欢迎信息:

✅ strategy-auto-rebalance 已就绪!

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  USDC 智能调仓策略
  作者:徐易朗
  分类:DeFi · 套利  |  风险:⭐ 低
  📥 X 次
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

自动在 Aave V3 / Compound V3 / Morpho 之间轮动,
始终将 USDC 放在收益最高的协议里。

📌 投资案例:
  10,000 USDC,30 天,设最小利差 0.3%
  综合年化约 5.1%,较手动多赚 ~$35,全程零操作。

支持链:Base(推荐)/ Ethereum
预估年化:3%~8%

需要 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 ~/.plugin-store/.env

If TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID are empty, inform the user:

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

>

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

然后询问用户选择链(Base / Ethereum)。

Pre-Start Confirmation

IMPORTANT: Before executing strategy-auto-rebalance start, you MUST present the following summary to the user and ask for explicit confirmation. Do NOT start the daemon until the user approves.

Display a table like this:

Ready to start Auto-Rebalancer. Please confirm:

  Chain:           Base (8453)
  Interval:        300s (5 min)
  Min Spread:      0.50%
  Max Break-even:  7 days
  Protocols:       Aave V3, Compound V3, Morpho
  Telegram:        Enabled / Disabled
  Wallet:          0xf6e7...4572

  Gas threshold:   5 gwei (Base) / 50 gwei (Ethereum)
  TVL alert:       20.0% (configurable, non-blocking)
  TVL emergency:   Emergency withdraw if TVL drops >30%
  State file:      ~/.plugin-store/auto-rebalance-state.json

Proceed? (y/n)

Key points to verify:

  • Wallet address from onchainos wallet — confirm it's the intended wallet
  • Chain — confirm it matches user intent (Base vs Ethereum have very different gas costs)
  • Interval — explain what it means in practical terms ("checks every X minutes")
  • Min spread — lower = more frequent rebalancing; higher = fewer but more meaningful moves
  • If wallet has idle USDC (not deposited in any protocol), the daemon will auto-deposit into the best protocol on its first cycle

Skill Routing

  • For single-protocol Aave operations → use plugin-store aave
  • For Morpho vault operations → use plugin-store morpho
  • For grid trading → use strategy-grid

Prerequisites

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

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

If not installed, follow: https://web3.okx.com/zh-hans/onchainos/dev-docs/home/install-your-agentic-wallet

2. Telegram notifications (optional): Configure in ~/.plugin-store/.env:

   TELEGRAM_BOT_TOKEN=your_bot_token
   TELEGRAM_CHAT_ID=your_chat_id

Authentication

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

Multi-Chain Support

ChainIDGas Spike ThresholdRecommended Interval
Base84530.5 gwei300s (5 min)
Ethereum150 gwei3600s (60 min)

Base has low gas (~$0.001-0.05 gwei per tx, ~$0.01-0.03 cost), so shorter intervals and lower spread thresholds make sense. Ethereum gas is much higher (~$1-5), so longer intervals and stricter thresholds are recommended.

Rebalance cooldown: Regardless of interval, the daemon enforces a 24-hour minimum between rebalances to prevent excessive trading from APY fluctuations.

Quickstart

# Base — low gas, check every 5 minutes, rebalance if spread > 0.3%
strategy-auto-rebalance start --chain base --interval 300 --min-spread 0.3

# Ethereum — higher gas, check every hour, rebalance if spread > 1.0%
strategy-auto-rebalance start --chain ethereum --interval 3600 --min-spread 1.0

# With Telegram notifications
strategy-auto-rebalance start --chain base --interval 300 --min-spread 0.3 \
  --telegram-token <BOT_TOKEN> --telegram-chat <CHAT_ID>

# Check daemon status
strategy-auto-rebalance status

# Stop daemon
strategy-auto-rebalance stop

Command Index

#CommandAuthDescription
1strategy-auto-rebalance startYesStart auto-rebalance daemon (foreground)
2strategy-auto-rebalance stopNoStop running daemon via PID file
3strategy-auto-rebalance statusNoShow daemon status and recent activity

CLI Command Reference

strategy-auto-rebalance start

strategy-auto-rebalance start [--chain <chain>] [--interval <seconds>] [--min-spread <pct>] [--max-break-even <days>] [--tvl-alert-threshold <pct>] [--telegram-token <token>] [--telegram-chat <id>]
ParamDefaultDescription
--chainbaseChain: base, ethereum
--interval3600Check interval in seconds (e.g. 300 = 5 min, 3600 = 1 hour)
--min-spread0.5Minimum APY spread (%) to trigger rebalance
--max-break-even7Maximum break-even days (gas cost / daily yield improvement)
--tvl-alert-threshold20.0TVL drop (%) that triggers a non-blocking alert (emergency at 30%)
--telegram-tokenenvTelegram Bot API token (or TELEGRAM_BOT_TOKEN env var)
--telegram-chatenvTelegram chat ID (or TELEGRAM_CHAT_ID env var)

Recommended configurations:

ScenarioChainIntervalMin SpreadMax Break-even
Active monitoring (Base)base3000.314
Conservative (Base)base36000.57
Active monitoring (ETH)ethereum18000.57
Conservative (ETH)ethereum36001.03
Testingbase600.19999

Daemon capabilities:

  • Periodic yield checks across Aave V3, Compound V3, and Morpho
  • Smart decision engine: Hold / Rebalance / Emergency Withdraw
  • Auto-deposit: If wallet has idle USDC and no protocol position, deposits into the best protocol automatically
  • Dynamic vault discovery: Morpho vault selection via GraphQL API — picks the highest APY vault with TVL > $100k
  • TVL safety monitoring — median-based comparison triggers emergency withdraw if TVL drops >30%
  • Gas spike circuit breaker — pauses when gas exceeds chain threshold
  • Telegram notifications (🤖 Auto-Rebalancer) for all events
  • State persistence at ~/.plugin-store/auto-rebalance-state.json
  • PID management — prevents duplicate instances

strategy-auto-rebalance stop

Sends SIGTERM to the running daemon via PID file (~/.plugin-store/auto-rebalance-daemon.pid).

strategy-auto-rebalance status

Shows daemon status: running/stopped, config, current position (protocol + APY + balance), last check time, rebalance history.

Decision Logic

Each cycle, the daemon:

1. Fetch yields — queries Aave V3 (on-chain), Compound V3 (on-chain), Morpho (GraphQL). Falls back to DeFiLlama if on-chain fails. 2. Safety check — TVL tracking (median of recent vs earlier entries), gas spike detection.

  • TVL drop >20% → alert notification (non-blocking)
  • TVL drop >30% → emergency withdrawal

3. Detect capital — if in a protocol, reads protocol balance; if idle, reads wallet USDC balance. 4. Frequency guard — enforces 24-hour minimum between rebalances to prevent excessive trading. 5. Decide:

  • Emergency Withdraw — if current protocol's TVL dropped >30% (median comparison)
  • Hold — if gas spiking, cooldown active, already in best protocol, spread too small, or break-even too long
  • Rebalance — withdraw from current → deposit into best; or initial deposit from wallet if protocol=none

6. Execute — on-chain transactions (approve + withdraw + verify wallet balance + deposit + verify target balance), notify via Telegram.

Cross-Skill Workflows

Workflow A: Research → Start Daemon

1. plugin-store aave markets --chain base             → check current Aave rates
2. plugin-store morpho vaults --chain base            → see Morpho vault options
3. strategy-auto-rebalance start --chain base ...     → let the daemon auto-optimize

Workflow B: Check Status → Manual Intervention

1. strategy-auto-rebalance status                     → review position and PnL
2. plugin-store morpho positions <address> --chain base → verify on-chain state
3. strategy-auto-rebalance stop                       → stop if needed

Workflow C: Multi-Chain

# Terminal 1
strategy-auto-rebalance start --chain base --interval 300 --min-spread 0.3

# Terminal 2
strategy-auto-rebalance start --chain ethereum --interval 3600 --min-spread 1.0

Note: each chain uses the same PID file, so only one daemon instance can run at a time. For multi-chain, run in separate terminals with separate working directories, or stop one before starting the other.

Key Concepts

  • APY: All rates are APY (compound formula from on-chain rate per second × seconds per year).
  • Break-even: Days for yield improvement to cover gas costs. Formula: gas_cost / (capital × spread% / 365). Lower = better.
  • TVL monitoring: Tracks protocol TVL using median of recent vs earlier entries (not single-point comparison). Requires at least 3 data points. A drop exceeding tvl_alert_threshold (default 20%, configurable) triggers a non-blocking alert; >30% triggers emergency withdrawal. History capped at 96 entries (~24h at 15min intervals).
  • Gas circuit breaker: Base threshold 0.5 gwei, Ethereum 50 gwei. Exceeding pauses all trading.
  • Rebalance cooldown: 24-hour minimum between rebalances, regardless of check interval. Prevents excessive trading from short-term APY fluctuations.
  • Post-execution verification: After withdrawal, verifies wallet received USDC before proceeding to deposit. Aborts if wallet balance is zero.
  • Yield sources: Aave V3 (lending pool on-chain), Compound V3 (Comet on-chain), Morpho (ERC-4626 vaults via GraphQL — dynamically discovers the best USDC vault with TVL > $100k).
  • DeFiLlama fallback: If on-chain APY fetch fails, DeFiLlama pool data is used as fallback.
  • Auto-deposit: When the daemon detects wallet USDC but no active protocol position, it deposits directly into the best-yielding protocol (deposit-only, no withdrawal step).

Edge Cases

ScenarioBehavior
All protocols same APYHold — no benefit to rebalancing
On-chain query failsFalls back to DeFiLlama API data
Gas spike above thresholdRebalance paused regardless of yield spread
Wallet has idle USDC, no positionAuto-deposits into best protocol on first cycle
Break-even too longHold — not worth the gas cost
Rebalanced recently (<24h ago)Hold — cooldown enforced to prevent over-trading
onchainos wallet not availableError on start — please login first
Daemon already runningStart rejects with existing PID warning
No running daemonStop returns error
TVL drops 20-30% (median)Alert notification sent, rebalancing NOT blocked
TVL drops >30% (median)Emergency withdrawal to wallet
Post-withdraw wallet balance is 0Rebalance aborted — supply step skipped to prevent loss
Morpho vault changes between cyclesDynamic discovery — always picks highest APY vault
Chain switch (e.g. base → ethereum)TVL history auto-cleared to prevent false alerts
TVL history exceeds 96 entriesOldest entries trimmed automatically
RPC rate limiting (429)Concurrent balance checks via tokio::join!, resilient to individual failures

Related skills

FAQ

What does strategy-auto-rebalance do?

strategy-auto-rebalance is a Claude Code skill for ai & agent building.

When should I use strategy-auto-rebalance?

When you need to helps with ai & agent building tasks., or when strategy-auto-rebalance is a claude code skill for ai & agent building.

What are the main capabilities?

strategy-auto-rebalance; AI & Agent Building; AI-coding skill.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.